index.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Transaction, Plugin, Command, EditorState } from 'prosemirror-state';
  2. /**
  3. Set a flag on the given transaction that will prevent further steps
  4. from being appended to an existing history event (so that they
  5. require a separate undo command to undo).
  6. */
  7. declare function closeHistory(tr: Transaction): Transaction;
  8. interface HistoryOptions {
  9. /**
  10. The amount of history events that are collected before the
  11. oldest events are discarded. Defaults to 100.
  12. */
  13. depth?: number;
  14. /**
  15. The delay between changes after which a new group should be
  16. started. Defaults to 500 (milliseconds). Note that when changes
  17. aren't adjacent, a new group is always started.
  18. */
  19. newGroupDelay?: number;
  20. }
  21. /**
  22. Returns a plugin that enables the undo history for an editor. The
  23. plugin will track undo and redo stacks, which can be used with the
  24. [`undo`](https://prosemirror.net/docs/ref/#history.undo) and [`redo`](https://prosemirror.net/docs/ref/#history.redo) commands.
  25. You can set an `"addToHistory"` [metadata
  26. property](https://prosemirror.net/docs/ref/#state.Transaction.setMeta) of `false` on a transaction
  27. to prevent it from being rolled back by undo.
  28. */
  29. declare function history(config?: HistoryOptions): Plugin;
  30. /**
  31. A command function that undoes the last change, if any.
  32. */
  33. declare const undo: Command;
  34. /**
  35. A command function that redoes the last undone change, if any.
  36. */
  37. declare const redo: Command;
  38. /**
  39. The amount of undoable events available in a given state.
  40. */
  41. declare function undoDepth(state: EditorState): any;
  42. /**
  43. The amount of redoable events available in a given editor state.
  44. */
  45. declare function redoDepth(state: EditorState): any;
  46. export { closeHistory, history, redo, redoDepth, undo, undoDepth };