operation.d.ts 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { ExtendedType, Node, Path, Range } from '..';
  2. export declare type BaseInsertNodeOperation = {
  3. type: 'insert_node';
  4. path: Path;
  5. node: Node;
  6. };
  7. export declare type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
  8. export declare type BaseInsertTextOperation = {
  9. type: 'insert_text';
  10. path: Path;
  11. offset: number;
  12. text: string;
  13. };
  14. export declare type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
  15. export declare type BaseMergeNodeOperation = {
  16. type: 'merge_node';
  17. path: Path;
  18. position: number;
  19. properties: Partial<Node>;
  20. };
  21. export declare type MergeNodeOperation = ExtendedType<'MergeNodeOperation', BaseMergeNodeOperation>;
  22. export declare type BaseMoveNodeOperation = {
  23. type: 'move_node';
  24. path: Path;
  25. newPath: Path;
  26. };
  27. export declare type MoveNodeOperation = ExtendedType<'MoveNodeOperation', BaseMoveNodeOperation>;
  28. export declare type BaseRemoveNodeOperation = {
  29. type: 'remove_node';
  30. path: Path;
  31. node: Node;
  32. };
  33. export declare type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
  34. export declare type BaseRemoveTextOperation = {
  35. type: 'remove_text';
  36. path: Path;
  37. offset: number;
  38. text: string;
  39. };
  40. export declare type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
  41. export declare type BaseSetNodeOperation = {
  42. type: 'set_node';
  43. path: Path;
  44. properties: Partial<Node>;
  45. newProperties: Partial<Node>;
  46. };
  47. export declare type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
  48. export declare type BaseSetSelectionOperation = {
  49. type: 'set_selection';
  50. properties: null;
  51. newProperties: Range;
  52. } | {
  53. type: 'set_selection';
  54. properties: Partial<Range>;
  55. newProperties: Partial<Range>;
  56. } | {
  57. type: 'set_selection';
  58. properties: Range;
  59. newProperties: null;
  60. };
  61. export declare type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
  62. export declare type BaseSplitNodeOperation = {
  63. type: 'split_node';
  64. path: Path;
  65. position: number;
  66. properties: Partial<Node>;
  67. };
  68. export declare type SplitNodeOperation = ExtendedType<'SplitNodeOperation', BaseSplitNodeOperation>;
  69. export declare type NodeOperation = InsertNodeOperation | MergeNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation | SplitNodeOperation;
  70. export declare type SelectionOperation = SetSelectionOperation;
  71. export declare type TextOperation = InsertTextOperation | RemoveTextOperation;
  72. /**
  73. * `Operation` objects define the low-level instructions that Slate editors use
  74. * to apply changes to their internal state. Representing all changes as
  75. * operations is what allows Slate editors to easily implement history,
  76. * collaboration, and other features.
  77. */
  78. export declare type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
  79. export declare type Operation = ExtendedType<'Operation', BaseOperation>;
  80. export interface OperationInterface {
  81. isNodeOperation: (value: any) => value is NodeOperation;
  82. isOperation: (value: any) => value is Operation;
  83. isOperationList: (value: any) => value is Operation[];
  84. isSelectionOperation: (value: any) => value is SelectionOperation;
  85. isTextOperation: (value: any) => value is TextOperation;
  86. inverse: (op: Operation) => Operation;
  87. }
  88. export declare const Operation: OperationInterface;
  89. //# sourceMappingURL=operation.d.ts.map