Class UndoManager

java.lang.Object
io.keikai.doc.collab.lib0.ObservableV2
io.keikai.doc.collab.utils.UndoManager

public class UndoManager extends ObservableV2
Fires 'stack-item-added' event when a stack item was added to either the undo- or the redo-stack. You may store additional stack information via the metadata property on `event.stackItem.meta` (it is a `Map` of metadata properties). Fires 'stack-item-popped' event when a stack item was popped from either the undo- or the redo-stack. You may restore the saved stack information from `event.stackItem.meta`.
  • Constructor Details

    • UndoManager

      public UndoManager(AbstractType typeScope)
      Parameters:
      typeScope - Accepts single type
    • UndoManager

      public UndoManager(AbstractType typeScope, UndoManagerOptions options)
      Parameters:
      typeScope - Accepts single type
      options -
    • UndoManager

      public UndoManager(List<AbstractType> typeScopes)
      Parameters:
      typeScopes - Accepts an array of types
    • UndoManager

      public UndoManager(List<AbstractType> typeScopes, UndoManagerOptions options)
      Parameters:
      typeScopes - Accepts an array of types
      options -
  • Method Details

    • getScope

      public List<AbstractType> getScope()
    • getDoc

      public Doc getDoc()
    • getDeleteFilter

      public Function<Object,Boolean> getDeleteFilter()
    • getTrackedOrigins

      public Set<Object> getTrackedOrigins()
    • getCaptureTransaction

      public Function<Object,Boolean> getCaptureTransaction()
    • getUndoStack

      public List<StackItem> getUndoStack()
    • getRedoStack

      public List<StackItem> getRedoStack()
    • isUndoing

      public boolean isUndoing()
    • isRedoing

      public boolean isRedoing()
    • getCurrStackItem

      public StackItem getCurrStackItem()
    • setCurrStackItem

      public void setCurrStackItem(StackItem currStackItem)
    • getLastChange

      public long getLastChange()
    • isIgnoreRemoteMapChanges

      public boolean isIgnoreRemoteMapChanges()
    • getCaptureTimeout

      public int getCaptureTimeout()
    • addToScope

      public void addToScope(AbstractType yType)
      Parameters:
      yType -
    • addToScope

      public void addToScope(List<AbstractType> yTypes)
      Parameters:
      yTypes -
    • addTrackedOrigin

      public void addTrackedOrigin(Object origin)
    • removeTrackedOrigin

      public void removeTrackedOrigin(Object origin)
    • clear

      public void clear(boolean clearUndoStack, boolean clearRedoStack)
    • stopCapturing

      public void stopCapturing()
      UndoManager merges Undo-StackItem if they are created within time-gap smaller than `options.captureTimeout`. Call `um.stopCapturing()` so that the next StackItem won't be merged.
    • undo

      public StackItem undo()
      Undo last changes on type.
      Returns:
      {StackItem?} Returns StackItem if a change was applied
    • redo

      public StackItem redo()
      Redo last undo operation.
      Returns:
      {StackItem?} Returns StackItem if a change was applied
    • canUndo

      public boolean canUndo()
      Are undo steps available?
      Returns:
      {boolean} `true` if undo is possible
    • canRedo

      public boolean canRedo()
      Are redo steps available?
      Returns:
      {boolean} `true` if redo is possible
    • destroy

      public void destroy()
      Overrides:
      destroy in class ObservableV2
    • clearUndoManagerStackItem

      public static void clearUndoManagerStackItem(Transaction tr, UndoManager um, StackItem stackItem)
      Clear an UndoManager stack item.
      Parameters:
      tr - The current transaction.
      um - The UndoManager instance.
      stackItem - The stack item to clear.
    • popStackItem

      public static StackItem popStackItem(UndoManager undoManager, List<StackItem> stack, String eventType)
      Pop an item from the undo/redo stack.
      Parameters:
      undoManager - The UndoManager instance.
      stack - The stack from which to pop the item.
      eventType - The event type ("undo" or "redo").
      Returns:
      The popped stack item, or null if no item was popped.
    • onStackItemAdded

      public void onStackItemAdded(Consumer<StackItemEvent> eventListener)
    • onStackItemAdded

      public void onStackItemAdded(BiConsumer<StackItemEvent,UndoManager> eventListener)
    • onStackItemPopped

      public void onStackItemPopped(Consumer<StackItemEvent> eventListener)
    • onStackItemPopped

      public void onStackItemPopped(BiConsumer<StackItemEvent,UndoManager> eventListener)
    • onStackCleared

      public void onStackCleared(Consumer<UndoManager.StackClearedStatus> eventListener)
    • onStackItemUpdated

      public void onStackItemUpdated(Consumer<StackItemEvent> eventListener)
    • onStackItemUpdated

      public void onStackItemUpdated(BiConsumer<StackItemEvent,UndoManager> eventListener)