roosterjs-content-model-types 0.21.2 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/lib/editor/IStandaloneEditor.d.ts +26 -4
  2. package/lib/editor/IStandaloneEditor.js.map +1 -1
  3. package/lib/editor/StandaloneEditorCore.d.ts +42 -164
  4. package/lib/editor/StandaloneEditorCore.js.map +1 -1
  5. package/lib/editor/StandaloneEditorCorePlugins.d.ts +7 -1
  6. package/lib/editor/StandaloneEditorCorePlugins.js.map +1 -1
  7. package/lib/editor/StandaloneEditorOptions.d.ts +6 -0
  8. package/lib/editor/StandaloneEditorOptions.js.map +1 -1
  9. package/lib/event/ContentModelContentChangedEvent.d.ts +6 -1
  10. package/lib/event/ContentModelContentChangedEvent.js.map +1 -1
  11. package/lib/event/ContentModelSelectionChangedEvent.d.ts +21 -0
  12. package/lib/event/ContentModelSelectionChangedEvent.js +3 -0
  13. package/lib/event/ContentModelSelectionChangedEvent.js.map +1 -0
  14. package/lib/format/ContentModelTableFormat.d.ts +2 -1
  15. package/lib/format/ContentModelTableFormat.js.map +1 -1
  16. package/lib/index.d.ts +11 -2
  17. package/lib/index.js.map +1 -1
  18. package/lib/parameter/ClipboardData.d.ts +57 -0
  19. package/lib/parameter/ClipboardData.js +3 -0
  20. package/lib/parameter/ClipboardData.js.map +1 -0
  21. package/lib/parameter/DOMEventRecord.d.ts +19 -0
  22. package/lib/parameter/DOMEventRecord.js +3 -0
  23. package/lib/parameter/DOMEventRecord.js.map +1 -0
  24. package/lib/parameter/EdgeLinkPreview.d.ts +25 -0
  25. package/lib/parameter/EdgeLinkPreview.js +3 -0
  26. package/lib/parameter/EdgeLinkPreview.js.map +1 -0
  27. package/lib/parameter/FormatWithContentModelContext.d.ts +29 -0
  28. package/lib/parameter/FormatWithContentModelContext.js.map +1 -1
  29. package/lib/parameter/Snapshot.d.ts +96 -0
  30. package/lib/parameter/Snapshot.js +3 -0
  31. package/lib/parameter/Snapshot.js.map +1 -0
  32. package/lib/parameter/SnapshotsManager.d.ts +35 -0
  33. package/lib/parameter/SnapshotsManager.js +3 -0
  34. package/lib/parameter/SnapshotsManager.js.map +1 -0
  35. package/lib/pluginState/CopyPastePluginState.d.ts +14 -0
  36. package/lib/pluginState/CopyPastePluginState.js +3 -0
  37. package/lib/pluginState/CopyPastePluginState.js.map +1 -0
  38. package/lib/pluginState/SelectionPluginState.d.ts +2 -10
  39. package/lib/pluginState/SelectionPluginState.js.map +1 -1
  40. package/lib/pluginState/StandaloneEditorPluginState.d.ts +7 -2
  41. package/lib/pluginState/StandaloneEditorPluginState.js.map +1 -1
  42. package/lib/pluginState/UndoPluginState.d.ts +30 -0
  43. package/lib/pluginState/UndoPluginState.js +3 -0
  44. package/lib/pluginState/UndoPluginState.js.map +1 -0
  45. package/lib/selection/DOMSelection.d.ts +2 -17
  46. package/lib/selection/DOMSelection.js.map +1 -1
  47. package/lib/selection/TableSelectionCoordinates.d.ts +21 -0
  48. package/lib/selection/TableSelectionCoordinates.js +3 -0
  49. package/lib/selection/TableSelectionCoordinates.js.map +1 -0
  50. package/lib-amd/editor/IStandaloneEditor.d.ts +26 -4
  51. package/lib-amd/editor/IStandaloneEditor.js.map +1 -1
  52. package/lib-amd/editor/StandaloneEditorCore.d.ts +42 -164
  53. package/lib-amd/editor/StandaloneEditorCore.js.map +1 -1
  54. package/lib-amd/editor/StandaloneEditorCorePlugins.d.ts +7 -1
  55. package/lib-amd/editor/StandaloneEditorCorePlugins.js.map +1 -1
  56. package/lib-amd/editor/StandaloneEditorOptions.d.ts +6 -0
  57. package/lib-amd/editor/StandaloneEditorOptions.js.map +1 -1
  58. package/lib-amd/event/ContentModelContentChangedEvent.d.ts +6 -1
  59. package/lib-amd/event/ContentModelContentChangedEvent.js.map +1 -1
  60. package/lib-amd/event/ContentModelSelectionChangedEvent.d.ts +21 -0
  61. package/lib-amd/event/ContentModelSelectionChangedEvent.js +5 -0
  62. package/lib-amd/event/ContentModelSelectionChangedEvent.js.map +1 -0
  63. package/lib-amd/format/ContentModelTableFormat.d.ts +2 -1
  64. package/lib-amd/format/ContentModelTableFormat.js.map +1 -1
  65. package/lib-amd/index.d.ts +11 -2
  66. package/lib-amd/index.js.map +1 -1
  67. package/lib-amd/parameter/ClipboardData.d.ts +57 -0
  68. package/lib-amd/parameter/ClipboardData.js +5 -0
  69. package/lib-amd/parameter/ClipboardData.js.map +1 -0
  70. package/lib-amd/parameter/DOMEventRecord.d.ts +19 -0
  71. package/lib-amd/parameter/DOMEventRecord.js +5 -0
  72. package/lib-amd/parameter/DOMEventRecord.js.map +1 -0
  73. package/lib-amd/parameter/EdgeLinkPreview.d.ts +25 -0
  74. package/lib-amd/parameter/EdgeLinkPreview.js +5 -0
  75. package/lib-amd/parameter/EdgeLinkPreview.js.map +1 -0
  76. package/lib-amd/parameter/FormatWithContentModelContext.d.ts +29 -0
  77. package/lib-amd/parameter/FormatWithContentModelContext.js.map +1 -1
  78. package/lib-amd/parameter/Snapshot.d.ts +96 -0
  79. package/lib-amd/parameter/Snapshot.js +5 -0
  80. package/lib-amd/parameter/Snapshot.js.map +1 -0
  81. package/lib-amd/parameter/SnapshotsManager.d.ts +35 -0
  82. package/lib-amd/parameter/SnapshotsManager.js +5 -0
  83. package/lib-amd/parameter/SnapshotsManager.js.map +1 -0
  84. package/lib-amd/pluginState/CopyPastePluginState.d.ts +14 -0
  85. package/lib-amd/pluginState/CopyPastePluginState.js +5 -0
  86. package/lib-amd/pluginState/CopyPastePluginState.js.map +1 -0
  87. package/lib-amd/pluginState/SelectionPluginState.d.ts +2 -10
  88. package/lib-amd/pluginState/SelectionPluginState.js.map +1 -1
  89. package/lib-amd/pluginState/StandaloneEditorPluginState.d.ts +7 -2
  90. package/lib-amd/pluginState/StandaloneEditorPluginState.js.map +1 -1
  91. package/lib-amd/pluginState/UndoPluginState.d.ts +30 -0
  92. package/lib-amd/pluginState/UndoPluginState.js +5 -0
  93. package/lib-amd/pluginState/UndoPluginState.js.map +1 -0
  94. package/lib-amd/selection/DOMSelection.d.ts +2 -17
  95. package/lib-amd/selection/DOMSelection.js.map +1 -1
  96. package/lib-amd/selection/TableSelectionCoordinates.d.ts +21 -0
  97. package/lib-amd/selection/TableSelectionCoordinates.js +5 -0
  98. package/lib-amd/selection/TableSelectionCoordinates.js.map +1 -0
  99. package/lib-mjs/editor/IStandaloneEditor.d.ts +26 -4
  100. package/lib-mjs/editor/IStandaloneEditor.js.map +1 -1
  101. package/lib-mjs/editor/StandaloneEditorCore.d.ts +42 -164
  102. package/lib-mjs/editor/StandaloneEditorCore.js.map +1 -1
  103. package/lib-mjs/editor/StandaloneEditorCorePlugins.d.ts +7 -1
  104. package/lib-mjs/editor/StandaloneEditorCorePlugins.js.map +1 -1
  105. package/lib-mjs/editor/StandaloneEditorOptions.d.ts +6 -0
  106. package/lib-mjs/editor/StandaloneEditorOptions.js.map +1 -1
  107. package/lib-mjs/event/ContentModelContentChangedEvent.d.ts +6 -1
  108. package/lib-mjs/event/ContentModelContentChangedEvent.js.map +1 -1
  109. package/lib-mjs/event/ContentModelSelectionChangedEvent.d.ts +21 -0
  110. package/lib-mjs/event/ContentModelSelectionChangedEvent.js +2 -0
  111. package/lib-mjs/event/ContentModelSelectionChangedEvent.js.map +1 -0
  112. package/lib-mjs/format/ContentModelTableFormat.d.ts +2 -1
  113. package/lib-mjs/format/ContentModelTableFormat.js.map +1 -1
  114. package/lib-mjs/index.d.ts +11 -2
  115. package/lib-mjs/index.js.map +1 -1
  116. package/lib-mjs/parameter/ClipboardData.d.ts +57 -0
  117. package/lib-mjs/parameter/ClipboardData.js +2 -0
  118. package/lib-mjs/parameter/ClipboardData.js.map +1 -0
  119. package/lib-mjs/parameter/DOMEventRecord.d.ts +19 -0
  120. package/lib-mjs/parameter/DOMEventRecord.js +2 -0
  121. package/lib-mjs/parameter/DOMEventRecord.js.map +1 -0
  122. package/lib-mjs/parameter/EdgeLinkPreview.d.ts +25 -0
  123. package/lib-mjs/parameter/EdgeLinkPreview.js +2 -0
  124. package/lib-mjs/parameter/EdgeLinkPreview.js.map +1 -0
  125. package/lib-mjs/parameter/FormatWithContentModelContext.d.ts +29 -0
  126. package/lib-mjs/parameter/FormatWithContentModelContext.js.map +1 -1
  127. package/lib-mjs/parameter/Snapshot.d.ts +96 -0
  128. package/lib-mjs/parameter/Snapshot.js +2 -0
  129. package/lib-mjs/parameter/Snapshot.js.map +1 -0
  130. package/lib-mjs/parameter/SnapshotsManager.d.ts +35 -0
  131. package/lib-mjs/parameter/SnapshotsManager.js +2 -0
  132. package/lib-mjs/parameter/SnapshotsManager.js.map +1 -0
  133. package/lib-mjs/pluginState/CopyPastePluginState.d.ts +14 -0
  134. package/lib-mjs/pluginState/CopyPastePluginState.js +2 -0
  135. package/lib-mjs/pluginState/CopyPastePluginState.js.map +1 -0
  136. package/lib-mjs/pluginState/SelectionPluginState.d.ts +2 -10
  137. package/lib-mjs/pluginState/SelectionPluginState.js.map +1 -1
  138. package/lib-mjs/pluginState/StandaloneEditorPluginState.d.ts +7 -2
  139. package/lib-mjs/pluginState/StandaloneEditorPluginState.js.map +1 -1
  140. package/lib-mjs/pluginState/UndoPluginState.d.ts +30 -0
  141. package/lib-mjs/pluginState/UndoPluginState.js +2 -0
  142. package/lib-mjs/pluginState/UndoPluginState.js.map +1 -0
  143. package/lib-mjs/selection/DOMSelection.d.ts +2 -17
  144. package/lib-mjs/selection/DOMSelection.js.map +1 -1
  145. package/lib-mjs/selection/TableSelectionCoordinates.d.ts +21 -0
  146. package/lib-mjs/selection/TableSelectionCoordinates.js +2 -0
  147. package/lib-mjs/selection/TableSelectionCoordinates.js.map +1 -0
  148. package/package.json +1 -1
@@ -1,3 +1,6 @@
1
+ import type { DOMEventRecord } from '../parameter/DOMEventRecord';
2
+ import type { SnapshotsManager } from '../parameter/SnapshotsManager';
3
+ import type { Snapshot } from '../parameter/Snapshot';
1
4
  import type { CompatiblePluginEventType } from 'roosterjs-editor-types/lib/compatibleTypes';
2
5
  import type { ContentModelDocument } from '../group/ContentModelDocument';
3
6
  import type { ContentModelSegmentFormat } from '../format/ContentModelSegmentFormat';
@@ -7,7 +10,7 @@ import type { EditorEnvironment } from '../parameter/EditorEnvironment';
7
10
  import type { ModelToDomOption } from '../context/ModelToDomOption';
8
11
  import type { OnNodeCreated } from '../context/ModelToDomSettings';
9
12
  import type { ContentModelFormatter, FormatWithContentModelOptions } from '../parameter/FormatWithContentModelOptions';
10
- import type { EditorUndoState, PluginEventData, PluginEventFromType, PluginEventType } from 'roosterjs-editor-types';
13
+ import type { PluginEventData, PluginEventFromType, PluginEventType } from 'roosterjs-editor-types';
11
14
  /**
12
15
  * An interface of standalone Content Model editor.
13
16
  * (This interface is still under development, and may still be changed in the future with some breaking changes)
@@ -42,7 +45,7 @@ export interface IStandaloneEditor {
42
45
  * This is the replacement of IEditor.select.
43
46
  * @param selection The selection to set
44
47
  */
45
- setDOMSelection(selection: DOMSelection): void;
48
+ setDOMSelection(selection: DOMSelection | null): void;
46
49
  /**
47
50
  * The general API to do format change with Content Model
48
51
  * It will grab a Content Model for current editor content, and invoke a callback function
@@ -81,9 +84,9 @@ export interface IStandaloneEditor {
81
84
  */
82
85
  triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(eventType: T, data: PluginEventData<T>, broadcast?: boolean): PluginEventFromType<T>;
83
86
  /**
84
- * Whether there is an available undo/redo snapshot
87
+ * Get undo snapshots manager
85
88
  */
86
- getUndoState(): EditorUndoState;
89
+ getSnapshotsManager(): SnapshotsManager;
87
90
  /**
88
91
  * Check if the editor is in dark mode
89
92
  * @returns True if the editor is in dark mode, otherwise false
@@ -96,4 +99,23 @@ export interface IStandaloneEditor {
96
99
  * @returns current zoom scale number
97
100
  */
98
101
  getZoomScale(): number;
102
+ /**
103
+ * Add a single undo snapshot to undo stack
104
+ */
105
+ takeSnapshot(): void;
106
+ /**
107
+ * Restore an undo snapshot into editor
108
+ * @param snapshot The snapshot to restore
109
+ */
110
+ restoreSnapshot(snapshot: Snapshot): void;
111
+ /**
112
+ * Check if editor is in IME input sequence
113
+ * @returns True if editor is in IME input sequence, otherwise false
114
+ */
115
+ isInIME(): boolean;
116
+ /**
117
+ * Attach a DOM event to the editor content DIV
118
+ * @param eventMap A map from event name to its handler
119
+ */
120
+ attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void;
99
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IStandaloneEditor.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/IStandaloneEditor.ts"],"names":[],"mappings":"","sourcesContent":["import type { CompatiblePluginEventType } from 'roosterjs-editor-types/lib/compatibleTypes';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { ContentModelSegmentFormat } from '../format/ContentModelSegmentFormat';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { OnNodeCreated } from '../context/ModelToDomSettings';\nimport type {\n ContentModelFormatter,\n FormatWithContentModelOptions,\n} from '../parameter/FormatWithContentModelOptions';\nimport type {\n EditorUndoState,\n PluginEventData,\n PluginEventFromType,\n PluginEventType,\n} from 'roosterjs-editor-types';\n\n/**\n * An interface of standalone Content Model editor.\n * (This interface is still under development, and may still be changed in the future with some breaking changes)\n */\nexport interface IStandaloneEditor {\n /**\n * Create Content Model from DOM tree in this editor\n * @param rootNode Optional start node. If provided, Content Model will be created from this node (including itself),\n * otherwise it will create Content Model for the whole content in editor.\n * @param option The options to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When specified, use this selection to override existing selection inside editor\n */\n createContentModel(\n option?: DomToModelOption,\n selectionOverride?: DOMSelection\n ): ContentModelDocument;\n\n /**\n * Set content with content model\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n * @param onNodeCreated An optional callback that will be called when a DOM node is created\n */\n setContentModel(\n model: ContentModelDocument,\n option?: ModelToDomOption,\n onNodeCreated?: OnNodeCreated\n ): DOMSelection | null;\n\n /**\n * Get current running environment, such as if editor is running on Mac\n */\n getEnvironment(): EditorEnvironment;\n\n /**\n * Get current DOM selection.\n * This is the replacement of IEditor.getSelectionRangeEx.\n */\n getDOMSelection(): DOMSelection | null;\n\n /**\n * Set DOMSelection into editor content.\n * This is the replacement of IEditor.select.\n * @param selection The selection to set\n */\n setDOMSelection(selection: DOMSelection): void;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\n formatContentModel(\n formatter: ContentModelFormatter,\n options?: FormatWithContentModelOptions\n ): void;\n\n /**\n * Get pending format of editor if any, or return null\n */\n getPendingFormat(): ContentModelSegmentFormat | null;\n\n //#region Editor API copied from legacy editor, will be ported to use Content Model instead\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean;\n\n /**\n * Get document which contains this editor\n * @returns The HTML document which contains this editor\n */\n getDocument(): Document;\n\n /**\n * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.\n */\n focus(): void;\n\n /**\n * Trigger an event to be dispatched to all plugins\n * @param eventType Type of the event\n * @param data data of the event with given type, this is the rest part of PluginEvent with the given type\n * @param broadcast indicates if the event needs to be dispatched to all plugins\n * True means to all, false means to allow exclusive handling from one plugin unless no one wants that\n * @returns the event object which is really passed into plugins. Some plugin may modify the event object so\n * the result of this function provides a chance to read the modified result\n */\n triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast?: boolean\n ): PluginEventFromType<T>;\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState;\n\n /**\n * Check if the editor is in dark mode\n * @returns True if the editor is in dark mode, otherwise false\n */\n isDarkMode(): boolean;\n\n /**\n * Get current zoom scale, default value is 1\n * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale\n * to let editor behave correctly especially for those mouse drag/drop behaviors\n * @returns current zoom scale number\n */\n getZoomScale(): number;\n\n //#endregion\n}\n"]}
1
+ {"version":3,"file":"IStandaloneEditor.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/IStandaloneEditor.ts"],"names":[],"mappings":"","sourcesContent":["import type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { SnapshotsManager } from '../parameter/SnapshotsManager';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { CompatiblePluginEventType } from 'roosterjs-editor-types/lib/compatibleTypes';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { ContentModelSegmentFormat } from '../format/ContentModelSegmentFormat';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { OnNodeCreated } from '../context/ModelToDomSettings';\nimport type {\n ContentModelFormatter,\n FormatWithContentModelOptions,\n} from '../parameter/FormatWithContentModelOptions';\nimport type { PluginEventData, PluginEventFromType, PluginEventType } from 'roosterjs-editor-types';\n\n/**\n * An interface of standalone Content Model editor.\n * (This interface is still under development, and may still be changed in the future with some breaking changes)\n */\nexport interface IStandaloneEditor {\n /**\n * Create Content Model from DOM tree in this editor\n * @param rootNode Optional start node. If provided, Content Model will be created from this node (including itself),\n * otherwise it will create Content Model for the whole content in editor.\n * @param option The options to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When specified, use this selection to override existing selection inside editor\n */\n createContentModel(\n option?: DomToModelOption,\n selectionOverride?: DOMSelection\n ): ContentModelDocument;\n\n /**\n * Set content with content model\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n * @param onNodeCreated An optional callback that will be called when a DOM node is created\n */\n setContentModel(\n model: ContentModelDocument,\n option?: ModelToDomOption,\n onNodeCreated?: OnNodeCreated\n ): DOMSelection | null;\n\n /**\n * Get current running environment, such as if editor is running on Mac\n */\n getEnvironment(): EditorEnvironment;\n\n /**\n * Get current DOM selection.\n * This is the replacement of IEditor.getSelectionRangeEx.\n */\n getDOMSelection(): DOMSelection | null;\n\n /**\n * Set DOMSelection into editor content.\n * This is the replacement of IEditor.select.\n * @param selection The selection to set\n */\n setDOMSelection(selection: DOMSelection | null): void;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\n formatContentModel(\n formatter: ContentModelFormatter,\n options?: FormatWithContentModelOptions\n ): void;\n\n /**\n * Get pending format of editor if any, or return null\n */\n getPendingFormat(): ContentModelSegmentFormat | null;\n\n //#region Editor API copied from legacy editor, will be ported to use Content Model instead\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean;\n\n /**\n * Get document which contains this editor\n * @returns The HTML document which contains this editor\n */\n getDocument(): Document;\n\n /**\n * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.\n */\n focus(): void;\n\n /**\n * Trigger an event to be dispatched to all plugins\n * @param eventType Type of the event\n * @param data data of the event with given type, this is the rest part of PluginEvent with the given type\n * @param broadcast indicates if the event needs to be dispatched to all plugins\n * True means to all, false means to allow exclusive handling from one plugin unless no one wants that\n * @returns the event object which is really passed into plugins. Some plugin may modify the event object so\n * the result of this function provides a chance to read the modified result\n */\n triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast?: boolean\n ): PluginEventFromType<T>;\n\n /**\n * Get undo snapshots manager\n */\n getSnapshotsManager(): SnapshotsManager;\n\n /**\n * Check if the editor is in dark mode\n * @returns True if the editor is in dark mode, otherwise false\n */\n isDarkMode(): boolean;\n\n /**\n * Get current zoom scale, default value is 1\n * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale\n * to let editor behave correctly especially for those mouse drag/drop behaviors\n * @returns current zoom scale number\n */\n getZoomScale(): number;\n\n /**\n * Add a single undo snapshot to undo stack\n */\n takeSnapshot(): void;\n\n /**\n * Restore an undo snapshot into editor\n * @param snapshot The snapshot to restore\n */\n restoreSnapshot(snapshot: Snapshot): void;\n\n /**\n * Check if editor is in IME input sequence\n * @returns True if editor is in IME input sequence, otherwise false\n */\n isInIME(): boolean;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void;\n\n //#endregion\n}\n"]}
@@ -1,5 +1,8 @@
1
- import type { CompatibleColorTransformDirection, CompatibleGetContentMode } from 'roosterjs-editor-types/lib/compatibleTypes';
2
- import type { ColorTransformDirection, ContentChangedData, ContentMetadata, DOMEventHandler, DarkColorHandler, EditorPlugin, GetContentMode, ImageSelectionRange, InsertOption, NodePosition, PluginEvent, PositionType, Rect, SelectionPath, SelectionRangeEx, StyleBasedFormatState, TableSelection, TableSelectionRange, TrustedHTMLHandler } from 'roosterjs-editor-types';
1
+ import type { DOMEventRecord } from '../parameter/DOMEventRecord';
2
+ import type { Snapshot } from '../parameter/Snapshot';
3
+ import type { EntityState } from '../parameter/FormatWithContentModelContext';
4
+ import type { CompatibleGetContentMode } from 'roosterjs-editor-types/lib/compatibleTypes';
5
+ import type { ContentMetadata, DarkColorHandler, EditorPlugin, GetContentMode, InsertOption, NodePosition, PluginEvent, Rect, StyleBasedFormatState, TrustedHTMLHandler } from 'roosterjs-editor-types';
3
6
  import type { ContentModelDocument } from '../group/ContentModelDocument';
4
7
  import type { StandaloneEditorCorePluginState, UnportedCorePluginState } from '../pluginState/StandaloneEditorPluginState';
5
8
  import type { DOMSelection } from '../selection/DOMSelection';
@@ -39,8 +42,9 @@ export declare type SetContentModel = (core: StandaloneEditorCore, model: Conten
39
42
  * Set current DOM selection from editor. This is the replacement of core API select
40
43
  * @param core The StandaloneEditorCore object
41
44
  * @param selection The selection to set
45
+ * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent
42
46
  */
43
- export declare type SetDOMSelection = (core: StandaloneEditorCore, selection: DOMSelection) => void;
47
+ export declare type SetDOMSelection = (core: StandaloneEditorCore, selection: DOMSelection | null, skipSelectionChangedEvent?: boolean) => void;
44
48
  /**
45
49
  * The general API to do format change with Content Model
46
50
  * It will grab a Content Model for current editor content, and invoke a callback function
@@ -57,17 +61,6 @@ export declare type FormatContentModel = (core: StandaloneEditorCore, formatter:
57
61
  * @param isOn True to switch On, False to switch Off
58
62
  */
59
63
  export declare type SwitchShadowEdit = (core: StandaloneEditorCore, isOn: boolean) => void;
60
- /**
61
- * TODO: Remove this Core API and use setDOMSelection instead
62
- * Select content according to the given information.
63
- * There are a bunch of allowed combination of parameters. See IEditor.select for more details
64
- * @param core The editor core object
65
- * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path
66
- * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection, or null
67
- * @param arg3 (optional) A Node
68
- * @param arg4 (optional) An offset number, or a PositionType
69
- */
70
- export declare type Select = (core: StandaloneEditorCore, arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection | null, arg3?: Node, arg4?: number | PositionType) => boolean;
71
64
  /**
72
65
  * Trigger a plugin event
73
66
  * @param core The StandaloneEditorCore object
@@ -76,63 +69,19 @@ export declare type Select = (core: StandaloneEditorCore, arg1: Range | Selectio
76
69
  */
77
70
  export declare type TriggerEvent = (core: StandaloneEditorCore, pluginEvent: PluginEvent, broadcast: boolean) => void;
78
71
  /**
79
- * Get current selection range
80
- * @param core The StandaloneEditorCore object
81
- * @returns A Range object of the selection range
82
- */
83
- export declare type GetSelectionRangeEx = (core: StandaloneEditorCore) => SelectionRangeEx;
84
- /**
85
- * Edit and transform color of elements between light mode and dark mode
72
+ * Add an undo snapshot to current undo snapshot stack
86
73
  * @param core The StandaloneEditorCore object
87
- * @param rootNode The root HTML node to transform
88
- * @param includeSelf True to transform the root node as well, otherwise false
89
- * @param callback The callback function to invoke before do color transformation
90
- * @param direction To specify the transform direction, light to dark, or dark to light
91
- * @param forceTransform By default this function will only work when editor core is in dark mode.
92
- * Pass true to this value to force do color transformation even editor core is in light mode
93
- * @param fromDarkModel Whether the given content is already in dark mode
94
- */
95
- export declare type TransformColor = (core: StandaloneEditorCore, rootNode: Node | null, includeSelf: boolean, callback: (() => void) | null, direction: ColorTransformDirection | CompatibleColorTransformDirection, forceTransform?: boolean, fromDarkMode?: boolean) => void;
96
- /**
97
- * Call an editing callback with adding undo snapshots around, and trigger a ContentChanged event if change source is specified.
98
- * Undo snapshot will not be added if this call is nested inside another addUndoSnapshot() call.
99
- * @param core The StandaloneEditorCore object
100
- * @param callback The editing callback, accepting current selection start and end position, returns an optional object used as the data field of ContentChangedEvent.
101
- * @param changeSource The ChangeSource string of ContentChangedEvent. @default ChangeSource.Format. Set to null to avoid triggering ContentChangedEvent
102
74
  * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
103
- * @param additionalData Optional parameter to provide additional data related to the ContentChanged Event.
75
+ * @param entityStates @optional Entity states related to this snapshot.
76
+ * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState
77
+ * when undo/redo to this snapshot
104
78
  */
105
- export declare type AddUndoSnapshot = (core: StandaloneEditorCore, callback: ((start: NodePosition | null, end: NodePosition | null) => any) | null, changeSource: string | null, canUndoByBackspace: boolean, additionalData?: ContentChangedData) => void;
79
+ export declare type AddUndoSnapshot = (core: StandaloneEditorCore, canUndoByBackspace: boolean, entityStates?: EntityState[]) => void;
106
80
  /**
107
81
  * Retrieves the rect of the visible viewport of the editor.
108
82
  * @param core The StandaloneEditorCore object
109
83
  */
110
84
  export declare type GetVisibleViewport = (core: StandaloneEditorCore) => Rect | null;
111
- /**
112
- * Change the editor selection to the given range
113
- * @param core The StandaloneEditorCore object
114
- * @param range The range to select
115
- * @param skipSameRange When set to true, do nothing if the given range is the same with current selection
116
- * in editor, otherwise it will always remove current selection range and set to the given one.
117
- * This parameter is always treated as true in Edge to avoid some weird runtime exception.
118
- */
119
- export declare type SelectRange = (core: StandaloneEditorCore, range: Range, skipSameRange?: boolean) => boolean;
120
- /**
121
- * Select a table and save data of the selected range
122
- * @param core The StandaloneEditorCore object
123
- * @param image image to select
124
- * @returns true if successful
125
- */
126
- export declare type SelectImage = (core: StandaloneEditorCore, image: HTMLImageElement | null) => ImageSelectionRange | null;
127
- /**
128
- * Select a table and save data of the selected range
129
- * @param core The StandaloneEditorCore object
130
- * @param table table to select
131
- * @param coordinates first and last cell of the selection, if this parameter is null, instead of
132
- * selecting, will unselect the table.
133
- * @returns true if successful
134
- */
135
- export declare type SelectTable = (core: StandaloneEditorCore, table: HTMLTableElement | null, coordinates?: TableSelection) => TableSelectionRange | null;
136
85
  /**
137
86
  * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
138
87
  * if triggerContentChangedEvent is set to true
@@ -141,13 +90,6 @@ export declare type SelectTable = (core: StandaloneEditorCore, table: HTMLTableE
141
90
  * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
142
91
  */
143
92
  export declare type SetContent = (core: StandaloneEditorCore, content: string, triggerContentChangedEvent: boolean, metadata?: ContentMetadata) => void;
144
- /**
145
- * Get current or cached selection range
146
- * @param core The StandaloneEditorCore object
147
- * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now
148
- * @returns A Range object of the selection range
149
- */
150
- export declare type GetSelectionRange = (core: StandaloneEditorCore, tryGetFromCache: boolean) => Range | null;
151
93
  /**
152
94
  * Check if the editor has focus now
153
95
  * @param core The StandaloneEditorCore object
@@ -170,7 +112,7 @@ export declare type InsertNode = (core: StandaloneEditorCore, node: Node, option
170
112
  * @param core The StandaloneEditorCore object
171
113
  * @param eventMap A map from event name to its handler
172
114
  */
173
- export declare type AttachDomEvent = (core: StandaloneEditorCore, eventMap: Record<string, DOMEventHandler>) => () => void;
115
+ export declare type AttachDomEvent = (core: StandaloneEditorCore, eventMap: Record<string, DOMEventRecord>) => () => void;
174
116
  /**
175
117
  * Get current editor content as HTML string
176
118
  * @param core The StandaloneEditorCore object
@@ -189,7 +131,7 @@ export declare type GetStyleBasedFormatState = (core: StandaloneEditorCore, node
189
131
  * @param core The StandaloneEditorCore object
190
132
  * @param step Steps to move, can be 0, positive or negative
191
133
  */
192
- export declare type RestoreUndoSnapshot = (core: StandaloneEditorCore, step: number) => void;
134
+ export declare type RestoreUndoSnapshot = (core: StandaloneEditorCore, snapshot: Snapshot) => void;
193
135
  /**
194
136
  * Ensure user will type into a container element rather than into the editor content DIV directly
195
137
  * @param core The StandaloneEditorCore object.
@@ -230,6 +172,7 @@ export interface PortedCoreApiMap {
230
172
  * Set current DOM selection from editor. This is the replacement of core API select
231
173
  * @param core The StandaloneEditorCore object
232
174
  * @param selection The selection to set
175
+ * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent
233
176
  */
234
177
  setDOMSelection: SetDOMSelection;
235
178
  /**
@@ -253,84 +196,51 @@ export interface PortedCoreApiMap {
253
196
  * @param core The StandaloneEditorCore object
254
197
  */
255
198
  getVisibleViewport: GetVisibleViewport;
256
- }
257
- /**
258
- * Temp interface
259
- * TODO: Port these core API
260
- */
261
- export interface UnportedCoreApiMap {
262
199
  /**
263
- * Select content according to the given information.
264
- * There are a bunch of allowed combination of parameters. See IEditor.select for more details
265
- * @param core The editor core object
266
- * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path
267
- * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection, or null
268
- * @param arg3 (optional) A Node
269
- * @param arg4 (optional) An offset number, or a PositionType
270
- */
271
- select: Select;
272
- /**
273
- * Trigger a plugin event
274
- * @param core The StandaloneEditorCore object
275
- * @param pluginEvent The event object to trigger
276
- * @param broadcast Set to true to skip the shouldHandleEventExclusively check
277
- */
278
- triggerEvent: TriggerEvent;
279
- /**
280
- * Get current or cached selection range
200
+ * Check if the editor has focus now
281
201
  * @param core The StandaloneEditorCore object
282
- * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now
283
- * @returns A Range object of the selection range
202
+ * @returns True if the editor has focus, otherwise false
284
203
  */
285
- getSelectionRangeEx: GetSelectionRangeEx;
204
+ hasFocus: HasFocus;
286
205
  /**
287
- * Edit and transform color of elements between light mode and dark mode
206
+ * Focus to editor. If there is a cached selection range, use it as current selection
288
207
  * @param core The StandaloneEditorCore object
289
- * @param rootNode The root HTML element to transform
290
- * @param includeSelf True to transform the root node as well, otherwise false
291
- * @param callback The callback function to invoke before do color transformation
292
- * @param direction To specify the transform direction, light to dark, or dark to light
293
- * @param forceTransform By default this function will only work when editor core is in dark mode.
294
- * Pass true to this value to force do color transformation even editor core is in light mode
295
- * @param fromDarkModel Whether the given content is already in dark mode
296
208
  */
297
- transformColor: TransformColor;
209
+ focus: Focus;
298
210
  /**
299
- * Call an editing callback with adding undo snapshots around, and trigger a ContentChanged event if change source is specified.
300
- * Undo snapshot will not be added if this call is nested inside another addUndoSnapshot() call.
211
+ * Add an undo snapshot to current undo snapshot stack
301
212
  * @param core The StandaloneEditorCore object
302
- * @param callback The editing callback, accepting current selection start and end position, returns an optional object used as the data field of ContentChangedEvent.
303
- * @param changeSource The ChangeSource string of ContentChangedEvent. @default ChangeSource.Format. Set to null to avoid triggering ContentChangedEvent
304
- * @param canUndoByBackspace True if this action can be undone when user presses Backspace key (aka Auto Complete).
213
+ * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
214
+ * @param entityStates @optional Entity states related to this snapshot.
215
+ * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState
216
+ * when undo/redo to this snapshot
305
217
  */
306
218
  addUndoSnapshot: AddUndoSnapshot;
307
219
  /**
308
- * Change the editor selection to the given range
309
- * @param core The StandaloneEditorCore object
310
- * @param range The range to select
311
- * @param skipSameRange When set to true, do nothing if the given range is the same with current selection
312
- * in editor, otherwise it will always remove current selection range and set to the given one.
313
- * This parameter is always treated as true in Edge to avoid some weird runtime exception.
220
+ * Restore an undo snapshot into editor
221
+ * @param core The editor core object
222
+ * @param step Steps to move, can be 0, positive or negative
314
223
  */
315
- selectRange: SelectRange;
224
+ restoreUndoSnapshot: RestoreUndoSnapshot;
316
225
  /**
317
- * Select a image and save data of the selected range
226
+ * Attach a DOM event to the editor content DIV
318
227
  * @param core The StandaloneEditorCore object
319
- * @param image image to select
320
- * @param imageId the id of the image element
321
- * @returns true if successful
228
+ * @param eventMap A map from event name to its handler
322
229
  */
323
- selectImage: SelectImage;
230
+ attachDomEvent: AttachDomEvent;
324
231
  /**
325
- * Select a table and save data of the selected range
232
+ * Trigger a plugin event
326
233
  * @param core The StandaloneEditorCore object
327
- * @param table table to select
328
- * @param coordinates first and last cell of the selection, if this parameter is null, instead of
329
- * selecting, will unselect the table.
330
- * @param shouldAddStyles Whether need to update the style elements
331
- * @returns true if successful
234
+ * @param pluginEvent The event object to trigger
235
+ * @param broadcast Set to true to skip the shouldHandleEventExclusively check
332
236
  */
333
- selectTable: SelectTable;
237
+ triggerEvent: TriggerEvent;
238
+ }
239
+ /**
240
+ * Temp interface
241
+ * TODO: Port these core API
242
+ */
243
+ export interface UnportedCoreApiMap {
334
244
  /**
335
245
  * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
336
246
  * if triggerContentChangedEvent is set to true
@@ -339,38 +249,12 @@ export interface UnportedCoreApiMap {
339
249
  * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
340
250
  */
341
251
  setContent: SetContent;
342
- /**
343
- * Get current or cached selection range
344
- * @param core The StandaloneEditorCore object
345
- * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now
346
- * @returns A Range object of the selection range
347
- */
348
- getSelectionRange: GetSelectionRange;
349
- /**
350
- * Check if the editor has focus now
351
- * @param core The StandaloneEditorCore object
352
- * @returns True if the editor has focus, otherwise false
353
- */
354
- hasFocus: HasFocus;
355
- /**
356
- * Focus to editor. If there is a cached selection range, use it as current selection
357
- * @param core The StandaloneEditorCore object
358
- */
359
- focus: Focus;
360
252
  /**
361
253
  * Insert a DOM node into editor content
362
254
  * @param core The StandaloneEditorCore object. No op if null.
363
255
  * @param option An insert option object to specify how to insert the node
364
256
  */
365
257
  insertNode: InsertNode;
366
- /**
367
- * Attach a DOM event to the editor content DIV
368
- * @param core The StandaloneEditorCore object
369
- * @param eventName The DOM event name
370
- * @param pluginEventType Optional event type. When specified, editor will trigger a plugin event with this name when the DOM event is triggered
371
- * @param beforeDispatch Optional callback function to be invoked when the DOM event is triggered before trigger plugin event
372
- */
373
- attachDomEvent: AttachDomEvent;
374
258
  /**
375
259
  * Get current editor content as HTML string
376
260
  * @param core The StandaloneEditorCore object
@@ -384,12 +268,6 @@ export interface UnportedCoreApiMap {
384
268
  * @param node The node to get style from
385
269
  */
386
270
  getStyleBasedFormatState: GetStyleBasedFormatState;
387
- /**
388
- * Restore an undo snapshot into editor
389
- * @param core The editor core object
390
- * @param step Steps to move, can be 0, positive or negative
391
- */
392
- restoreUndoSnapshot: RestoreUndoSnapshot;
393
271
  /**
394
272
  * Ensure user will type into a container element rather than into the editor content DIV directly
395
273
  * @param core The EditorCore object.
@@ -1 +1 @@
1
- {"version":3,"file":"StandaloneEditorCore.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorCore.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CompatibleColorTransformDirection,\n CompatibleGetContentMode,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport type {\n ColorTransformDirection,\n ContentChangedData,\n ContentMetadata,\n DOMEventHandler,\n DarkColorHandler,\n EditorPlugin,\n GetContentMode,\n ImageSelectionRange,\n InsertOption,\n NodePosition,\n PluginEvent,\n PositionType,\n Rect,\n SelectionPath,\n SelectionRangeEx,\n StyleBasedFormatState,\n TableSelection,\n TableSelectionRange,\n TrustedHTMLHandler,\n} from 'roosterjs-editor-types';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type {\n StandaloneEditorCorePluginState,\n UnportedCorePluginState,\n} from '../pluginState/StandaloneEditorPluginState';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { DomToModelSettings } from '../context/DomToModelSettings';\nimport type { EditorContext } from '../context/EditorContext';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { ModelToDomSettings, OnNodeCreated } from '../context/ModelToDomSettings';\nimport type {\n ContentModelFormatter,\n FormatWithContentModelOptions,\n} from '../parameter/FormatWithContentModelOptions';\n\n/**\n * Create a EditorContext object used by ContentModel API\n * @param core The StandaloneEditorCore object\n */\nexport type CreateEditorContext = (core: StandaloneEditorCore) => EditorContext;\n\n/**\n * Create Content Model from DOM tree in this editor\n * @param core The StandaloneEditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed, use this selection range instead of current selection in editor\n */\nexport type CreateContentModel = (\n core: StandaloneEditorCore,\n option?: DomToModelOption,\n selectionOverride?: DOMSelection\n) => ContentModelDocument;\n\n/**\n * Get current DOM selection from editor\n * @param core The StandaloneEditorCore object\n */\nexport type GetDOMSelection = (core: StandaloneEditorCore) => DOMSelection | null;\n\n/**\n * Set content with content model. This is the replacement of core API getSelectionRangeEx\n * @param core The StandaloneEditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n * @param onNodeCreated An optional callback that will be called when a DOM node is created\n */\nexport type SetContentModel = (\n core: StandaloneEditorCore,\n model: ContentModelDocument,\n option?: ModelToDomOption,\n onNodeCreated?: OnNodeCreated\n) => DOMSelection | null;\n\n/**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The StandaloneEditorCore object\n * @param selection The selection to set\n */\nexport type SetDOMSelection = (core: StandaloneEditorCore, selection: DOMSelection) => void;\n\n/**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The StandaloneEditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\nexport type FormatContentModel = (\n core: StandaloneEditorCore,\n formatter: ContentModelFormatter,\n options?: FormatWithContentModelOptions\n) => void;\n\n/**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The StandaloneEditorCore object\n * @param isOn True to switch On, False to switch Off\n */\nexport type SwitchShadowEdit = (core: StandaloneEditorCore, isOn: boolean) => void;\n\n/**\n * TODO: Remove this Core API and use setDOMSelection instead\n * Select content according to the given information.\n * There are a bunch of allowed combination of parameters. See IEditor.select for more details\n * @param core The editor core object\n * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path\n * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection, or null\n * @param arg3 (optional) A Node\n * @param arg4 (optional) An offset number, or a PositionType\n */\nexport type Select = (\n core: StandaloneEditorCore,\n arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null,\n arg2?: NodePosition | number | PositionType | TableSelection | null,\n arg3?: Node,\n arg4?: number | PositionType\n) => boolean;\n\n/**\n * Trigger a plugin event\n * @param core The StandaloneEditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\nexport type TriggerEvent = (\n core: StandaloneEditorCore,\n pluginEvent: PluginEvent,\n broadcast: boolean\n) => void;\n\n/**\n * Get current selection range\n * @param core The StandaloneEditorCore object\n * @returns A Range object of the selection range\n */\nexport type GetSelectionRangeEx = (core: StandaloneEditorCore) => SelectionRangeEx;\n\n/**\n * Edit and transform color of elements between light mode and dark mode\n * @param core The StandaloneEditorCore object\n * @param rootNode The root HTML node to transform\n * @param includeSelf True to transform the root node as well, otherwise false\n * @param callback The callback function to invoke before do color transformation\n * @param direction To specify the transform direction, light to dark, or dark to light\n * @param forceTransform By default this function will only work when editor core is in dark mode.\n * Pass true to this value to force do color transformation even editor core is in light mode\n * @param fromDarkModel Whether the given content is already in dark mode\n */\nexport type TransformColor = (\n core: StandaloneEditorCore,\n rootNode: Node | null,\n includeSelf: boolean,\n callback: (() => void) | null,\n direction: ColorTransformDirection | CompatibleColorTransformDirection,\n forceTransform?: boolean,\n fromDarkMode?: boolean\n) => void;\n\n/**\n * Call an editing callback with adding undo snapshots around, and trigger a ContentChanged event if change source is specified.\n * Undo snapshot will not be added if this call is nested inside another addUndoSnapshot() call.\n * @param core The StandaloneEditorCore object\n * @param callback The editing callback, accepting current selection start and end position, returns an optional object used as the data field of ContentChangedEvent.\n * @param changeSource The ChangeSource string of ContentChangedEvent. @default ChangeSource.Format. Set to null to avoid triggering ContentChangedEvent\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param additionalData Optional parameter to provide additional data related to the ContentChanged Event.\n */\nexport type AddUndoSnapshot = (\n core: StandaloneEditorCore,\n callback: ((start: NodePosition | null, end: NodePosition | null) => any) | null,\n changeSource: string | null,\n canUndoByBackspace: boolean,\n additionalData?: ContentChangedData\n) => void;\n\n/**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The StandaloneEditorCore object\n */\nexport type GetVisibleViewport = (core: StandaloneEditorCore) => Rect | null;\n\n/**\n * Change the editor selection to the given range\n * @param core The StandaloneEditorCore object\n * @param range The range to select\n * @param skipSameRange When set to true, do nothing if the given range is the same with current selection\n * in editor, otherwise it will always remove current selection range and set to the given one.\n * This parameter is always treated as true in Edge to avoid some weird runtime exception.\n */\nexport type SelectRange = (\n core: StandaloneEditorCore,\n range: Range,\n skipSameRange?: boolean\n) => boolean;\n\n/**\n * Select a table and save data of the selected range\n * @param core The StandaloneEditorCore object\n * @param image image to select\n * @returns true if successful\n */\nexport type SelectImage = (\n core: StandaloneEditorCore,\n image: HTMLImageElement | null\n) => ImageSelectionRange | null;\n\n/**\n * Select a table and save data of the selected range\n * @param core The StandaloneEditorCore object\n * @param table table to select\n * @param coordinates first and last cell of the selection, if this parameter is null, instead of\n * selecting, will unselect the table.\n * @returns true if successful\n */\nexport type SelectTable = (\n core: StandaloneEditorCore,\n table: HTMLTableElement | null,\n coordinates?: TableSelection\n) => TableSelectionRange | null;\n\n/**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * if triggerContentChangedEvent is set to true\n * @param core The StandaloneEditorCore object\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\nexport type SetContent = (\n core: StandaloneEditorCore,\n content: string,\n triggerContentChangedEvent: boolean,\n metadata?: ContentMetadata\n) => void;\n\n/**\n * Get current or cached selection range\n * @param core The StandaloneEditorCore object\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now\n * @returns A Range object of the selection range\n */\nexport type GetSelectionRange = (\n core: StandaloneEditorCore,\n tryGetFromCache: boolean\n) => Range | null;\n\n/**\n * Check if the editor has focus now\n * @param core The StandaloneEditorCore object\n * @returns True if the editor has focus, otherwise false\n */\nexport type HasFocus = (core: StandaloneEditorCore) => boolean;\n\n/**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The StandaloneEditorCore object\n */\nexport type Focus = (core: StandaloneEditorCore) => void;\n\n/**\n * Insert a DOM node into editor content\n * @param core The StandaloneEditorCore object. No op if null.\n * @param option An insert option object to specify how to insert the node\n */\nexport type InsertNode = (\n core: StandaloneEditorCore,\n node: Node,\n option: InsertOption | null\n) => boolean;\n\n/**\n * Attach a DOM event to the editor content DIV\n * @param core The StandaloneEditorCore object\n * @param eventMap A map from event name to its handler\n */\nexport type AttachDomEvent = (\n core: StandaloneEditorCore,\n eventMap: Record<string, DOMEventHandler>\n) => () => void;\n\n/**\n * Get current editor content as HTML string\n * @param core The StandaloneEditorCore object\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\nexport type GetContent = (\n core: StandaloneEditorCore,\n mode: GetContentMode | CompatibleGetContentMode\n) => string;\n\n/**\n * Get style based format state from current selection, including font name/size and colors\n * @param core The StandaloneEditorCore objects\n * @param node The node to get style from\n */\nexport type GetStyleBasedFormatState = (\n core: StandaloneEditorCore,\n node: Node | null\n) => StyleBasedFormatState;\n\n/**\n * Restore an undo snapshot into editor\n * @param core The StandaloneEditorCore object\n * @param step Steps to move, can be 0, positive or negative\n */\nexport type RestoreUndoSnapshot = (core: StandaloneEditorCore, step: number) => void;\n\n/**\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param core The StandaloneEditorCore object.\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n * @param deprecated Deprecated parameter, not used\n */\nexport type EnsureTypeInContainer = (\n core: StandaloneEditorCore,\n position: NodePosition,\n keyboardEvent?: KeyboardEvent,\n deprecated?: boolean\n) => void;\n\n/**\n * Temp interface\n * TODO: Port other core API\n */\nexport interface PortedCoreApiMap {\n /**\n * Create a EditorContext object used by ContentModel API\n * @param core The StandaloneEditorCore object\n */\n createEditorContext: CreateEditorContext;\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param core The StandaloneEditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n */\n createContentModel: CreateContentModel;\n\n /**\n * Get current DOM selection from editor\n * @param core The StandaloneEditorCore object\n */\n getDOMSelection: GetDOMSelection;\n\n /**\n * Set content with content model\n * @param core The StandaloneEditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n */\n setContentModel: SetContentModel;\n\n /**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The StandaloneEditorCore object\n * @param selection The selection to set\n */\n setDOMSelection: SetDOMSelection;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The StandaloneEditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\n formatContentModel: FormatContentModel;\n\n /**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The StandaloneEditorCore object\n * @param isOn True to switch On, False to switch Off\n */\n switchShadowEdit: SwitchShadowEdit;\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The StandaloneEditorCore object\n */\n getVisibleViewport: GetVisibleViewport;\n}\n\n/**\n * Temp interface\n * TODO: Port these core API\n */\nexport interface UnportedCoreApiMap {\n /**\n * Select content according to the given information.\n * There are a bunch of allowed combination of parameters. See IEditor.select for more details\n * @param core The editor core object\n * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path\n * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection, or null\n * @param arg3 (optional) A Node\n * @param arg4 (optional) An offset number, or a PositionType\n */\n select: Select;\n\n /**\n * Trigger a plugin event\n * @param core The StandaloneEditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\n triggerEvent: TriggerEvent;\n\n /**\n * Get current or cached selection range\n * @param core The StandaloneEditorCore object\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now\n * @returns A Range object of the selection range\n */\n getSelectionRangeEx: GetSelectionRangeEx;\n\n /**\n * Edit and transform color of elements between light mode and dark mode\n * @param core The StandaloneEditorCore object\n * @param rootNode The root HTML element to transform\n * @param includeSelf True to transform the root node as well, otherwise false\n * @param callback The callback function to invoke before do color transformation\n * @param direction To specify the transform direction, light to dark, or dark to light\n * @param forceTransform By default this function will only work when editor core is in dark mode.\n * Pass true to this value to force do color transformation even editor core is in light mode\n * @param fromDarkModel Whether the given content is already in dark mode\n */\n transformColor: TransformColor;\n\n /**\n * Call an editing callback with adding undo snapshots around, and trigger a ContentChanged event if change source is specified.\n * Undo snapshot will not be added if this call is nested inside another addUndoSnapshot() call.\n * @param core The StandaloneEditorCore object\n * @param callback The editing callback, accepting current selection start and end position, returns an optional object used as the data field of ContentChangedEvent.\n * @param changeSource The ChangeSource string of ContentChangedEvent. @default ChangeSource.Format. Set to null to avoid triggering ContentChangedEvent\n * @param canUndoByBackspace True if this action can be undone when user presses Backspace key (aka Auto Complete).\n */\n addUndoSnapshot: AddUndoSnapshot;\n\n /**\n * Change the editor selection to the given range\n * @param core The StandaloneEditorCore object\n * @param range The range to select\n * @param skipSameRange When set to true, do nothing if the given range is the same with current selection\n * in editor, otherwise it will always remove current selection range and set to the given one.\n * This parameter is always treated as true in Edge to avoid some weird runtime exception.\n */\n selectRange: SelectRange;\n\n /**\n * Select a image and save data of the selected range\n * @param core The StandaloneEditorCore object\n * @param image image to select\n * @param imageId the id of the image element\n * @returns true if successful\n */\n selectImage: SelectImage;\n\n /**\n * Select a table and save data of the selected range\n * @param core The StandaloneEditorCore object\n * @param table table to select\n * @param coordinates first and last cell of the selection, if this parameter is null, instead of\n * selecting, will unselect the table.\n * @param shouldAddStyles Whether need to update the style elements\n * @returns true if successful\n */\n selectTable: SelectTable;\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * if triggerContentChangedEvent is set to true\n * @param core The StandaloneEditorCore object\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent: SetContent;\n\n /**\n * Get current or cached selection range\n * @param core The StandaloneEditorCore object\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now\n * @returns A Range object of the selection range\n */\n getSelectionRange: GetSelectionRange;\n\n /**\n * Check if the editor has focus now\n * @param core The StandaloneEditorCore object\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus: HasFocus;\n\n /**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The StandaloneEditorCore object\n */\n focus: Focus;\n\n /**\n * Insert a DOM node into editor content\n * @param core The StandaloneEditorCore object. No op if null.\n * @param option An insert option object to specify how to insert the node\n */\n insertNode: InsertNode;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param core The StandaloneEditorCore object\n * @param eventName The DOM event name\n * @param pluginEventType Optional event type. When specified, editor will trigger a plugin event with this name when the DOM event is triggered\n * @param beforeDispatch Optional callback function to be invoked when the DOM event is triggered before trigger plugin event\n */\n attachDomEvent: AttachDomEvent;\n\n /**\n * Get current editor content as HTML string\n * @param core The StandaloneEditorCore object\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent: GetContent;\n\n /**\n * Get style based format state from current selection, including font name/size and colors\n * @param core The StandaloneEditorCore objects\n * @param node The node to get style from\n */\n getStyleBasedFormatState: GetStyleBasedFormatState;\n\n /**\n * Restore an undo snapshot into editor\n * @param core The editor core object\n * @param step Steps to move, can be 0, positive or negative\n */\n restoreUndoSnapshot: RestoreUndoSnapshot;\n\n /**\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param core The EditorCore object.\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n * @param deprecated Deprecated parameter, not used\n */\n ensureTypeInContainer: EnsureTypeInContainer;\n}\n\n/**\n * The interface for the map of core API for Content Model editor.\n * Editor can call call API from this map under StandaloneEditorCore object\n */\nexport interface StandaloneCoreApiMap extends PortedCoreApiMap, UnportedCoreApiMap {}\n\n/**\n * Represents the core data structure of a Content Model editor\n */\nexport interface StandaloneEditorCore\n extends StandaloneEditorCorePluginState,\n UnportedCorePluginState,\n StandaloneEditorDefaultSettings {\n /**\n * The content DIV element of this editor\n */\n readonly contentDiv: HTMLDivElement;\n\n /**\n * Core API map of this editor\n */\n readonly api: StandaloneCoreApiMap;\n\n /**\n * Original API map of this editor. Overridden core API can use API from this map to call the original version of core API.\n */\n readonly originalApi: StandaloneCoreApiMap;\n\n /**\n * An array of editor plugins.\n */\n readonly plugins: EditorPlugin[];\n\n /**\n * Editor running environment\n */\n readonly environment: EditorEnvironment;\n\n /**\n * Dark model handler for the editor, used for variable-based solution.\n * If keep it null, editor will still use original dataset-based dark mode solution.\n */\n readonly darkColorHandler: DarkColorHandler;\n\n /**\n * A handler to convert HTML string to a trust HTML string.\n * By default it will just return the original HTML string directly.\n * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n */\n readonly trustedHTMLHandler: TrustedHTMLHandler;\n}\n\n/**\n * Default DOM and Content Model conversion settings for an editor\n */\nexport interface StandaloneEditorDefaultSettings {\n /**\n * Default DOM to Content Model options\n */\n defaultDomToModelOptions: (DomToModelOption | undefined)[];\n\n /**\n * Default Content Model to DOM options\n */\n defaultModelToDomOptions: (ModelToDomOption | undefined)[];\n\n /**\n * Default DOM to Content Model config, calculated from defaultDomToModelOptions,\n * will be used for creating content model if there is no other customized options\n */\n defaultDomToModelConfig: DomToModelSettings;\n\n /**\n * Default Content Model to DOM config, calculated from defaultModelToDomOptions,\n * will be used for setting content model if there is no other customized options\n */\n defaultModelToDomConfig: ModelToDomSettings;\n}\n"]}
1
+ {"version":3,"file":"StandaloneEditorCore.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorCore.ts"],"names":[],"mappings":"","sourcesContent":["import type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { EntityState } from '../parameter/FormatWithContentModelContext';\nimport type { CompatibleGetContentMode } from 'roosterjs-editor-types/lib/compatibleTypes';\nimport type {\n ContentMetadata,\n DarkColorHandler,\n EditorPlugin,\n GetContentMode,\n InsertOption,\n NodePosition,\n PluginEvent,\n Rect,\n StyleBasedFormatState,\n TrustedHTMLHandler,\n} from 'roosterjs-editor-types';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type {\n StandaloneEditorCorePluginState,\n UnportedCorePluginState,\n} from '../pluginState/StandaloneEditorPluginState';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { DomToModelSettings } from '../context/DomToModelSettings';\nimport type { EditorContext } from '../context/EditorContext';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { ModelToDomSettings, OnNodeCreated } from '../context/ModelToDomSettings';\nimport type {\n ContentModelFormatter,\n FormatWithContentModelOptions,\n} from '../parameter/FormatWithContentModelOptions';\n\n/**\n * Create a EditorContext object used by ContentModel API\n * @param core The StandaloneEditorCore object\n */\nexport type CreateEditorContext = (core: StandaloneEditorCore) => EditorContext;\n\n/**\n * Create Content Model from DOM tree in this editor\n * @param core The StandaloneEditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed, use this selection range instead of current selection in editor\n */\nexport type CreateContentModel = (\n core: StandaloneEditorCore,\n option?: DomToModelOption,\n selectionOverride?: DOMSelection\n) => ContentModelDocument;\n\n/**\n * Get current DOM selection from editor\n * @param core The StandaloneEditorCore object\n */\nexport type GetDOMSelection = (core: StandaloneEditorCore) => DOMSelection | null;\n\n/**\n * Set content with content model. This is the replacement of core API getSelectionRangeEx\n * @param core The StandaloneEditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n * @param onNodeCreated An optional callback that will be called when a DOM node is created\n */\nexport type SetContentModel = (\n core: StandaloneEditorCore,\n model: ContentModelDocument,\n option?: ModelToDomOption,\n onNodeCreated?: OnNodeCreated\n) => DOMSelection | null;\n\n/**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The StandaloneEditorCore object\n * @param selection The selection to set\n * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent\n */\nexport type SetDOMSelection = (\n core: StandaloneEditorCore,\n selection: DOMSelection | null,\n skipSelectionChangedEvent?: boolean\n) => void;\n\n/**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The StandaloneEditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\nexport type FormatContentModel = (\n core: StandaloneEditorCore,\n formatter: ContentModelFormatter,\n options?: FormatWithContentModelOptions\n) => void;\n\n/**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The StandaloneEditorCore object\n * @param isOn True to switch On, False to switch Off\n */\nexport type SwitchShadowEdit = (core: StandaloneEditorCore, isOn: boolean) => void;\n\n/**\n * Trigger a plugin event\n * @param core The StandaloneEditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\nexport type TriggerEvent = (\n core: StandaloneEditorCore,\n pluginEvent: PluginEvent,\n broadcast: boolean\n) => void;\n\n/**\n * Add an undo snapshot to current undo snapshot stack\n * @param core The StandaloneEditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\nexport type AddUndoSnapshot = (\n core: StandaloneEditorCore,\n canUndoByBackspace: boolean,\n entityStates?: EntityState[]\n) => void;\n\n/**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The StandaloneEditorCore object\n */\nexport type GetVisibleViewport = (core: StandaloneEditorCore) => Rect | null;\n\n/**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * if triggerContentChangedEvent is set to true\n * @param core The StandaloneEditorCore object\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\nexport type SetContent = (\n core: StandaloneEditorCore,\n content: string,\n triggerContentChangedEvent: boolean,\n metadata?: ContentMetadata\n) => void;\n\n/**\n * Check if the editor has focus now\n * @param core The StandaloneEditorCore object\n * @returns True if the editor has focus, otherwise false\n */\nexport type HasFocus = (core: StandaloneEditorCore) => boolean;\n\n/**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The StandaloneEditorCore object\n */\nexport type Focus = (core: StandaloneEditorCore) => void;\n\n/**\n * Insert a DOM node into editor content\n * @param core The StandaloneEditorCore object. No op if null.\n * @param option An insert option object to specify how to insert the node\n */\nexport type InsertNode = (\n core: StandaloneEditorCore,\n node: Node,\n option: InsertOption | null\n) => boolean;\n\n/**\n * Attach a DOM event to the editor content DIV\n * @param core The StandaloneEditorCore object\n * @param eventMap A map from event name to its handler\n */\nexport type AttachDomEvent = (\n core: StandaloneEditorCore,\n eventMap: Record<string, DOMEventRecord>\n) => () => void;\n\n/**\n * Get current editor content as HTML string\n * @param core The StandaloneEditorCore object\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\nexport type GetContent = (\n core: StandaloneEditorCore,\n mode: GetContentMode | CompatibleGetContentMode\n) => string;\n\n/**\n * Get style based format state from current selection, including font name/size and colors\n * @param core The StandaloneEditorCore objects\n * @param node The node to get style from\n */\nexport type GetStyleBasedFormatState = (\n core: StandaloneEditorCore,\n node: Node | null\n) => StyleBasedFormatState;\n\n/**\n * Restore an undo snapshot into editor\n * @param core The StandaloneEditorCore object\n * @param step Steps to move, can be 0, positive or negative\n */\nexport type RestoreUndoSnapshot = (core: StandaloneEditorCore, snapshot: Snapshot) => void;\n\n/**\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param core The StandaloneEditorCore object.\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n * @param deprecated Deprecated parameter, not used\n */\nexport type EnsureTypeInContainer = (\n core: StandaloneEditorCore,\n position: NodePosition,\n keyboardEvent?: KeyboardEvent,\n deprecated?: boolean\n) => void;\n\n/**\n * Temp interface\n * TODO: Port other core API\n */\nexport interface PortedCoreApiMap {\n /**\n * Create a EditorContext object used by ContentModel API\n * @param core The StandaloneEditorCore object\n */\n createEditorContext: CreateEditorContext;\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param core The StandaloneEditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n */\n createContentModel: CreateContentModel;\n\n /**\n * Get current DOM selection from editor\n * @param core The StandaloneEditorCore object\n */\n getDOMSelection: GetDOMSelection;\n\n /**\n * Set content with content model\n * @param core The StandaloneEditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n */\n setContentModel: SetContentModel;\n\n /**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The StandaloneEditorCore object\n * @param selection The selection to set\n * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent\n */\n setDOMSelection: SetDOMSelection;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The StandaloneEditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\n formatContentModel: FormatContentModel;\n\n /**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The StandaloneEditorCore object\n * @param isOn True to switch On, False to switch Off\n */\n switchShadowEdit: SwitchShadowEdit;\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The StandaloneEditorCore object\n */\n getVisibleViewport: GetVisibleViewport;\n\n /**\n * Check if the editor has focus now\n * @param core The StandaloneEditorCore object\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus: HasFocus;\n\n /**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The StandaloneEditorCore object\n */\n focus: Focus;\n\n /**\n * Add an undo snapshot to current undo snapshot stack\n * @param core The StandaloneEditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\n addUndoSnapshot: AddUndoSnapshot;\n\n /**\n * Restore an undo snapshot into editor\n * @param core The editor core object\n * @param step Steps to move, can be 0, positive or negative\n */\n restoreUndoSnapshot: RestoreUndoSnapshot;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param core The StandaloneEditorCore object\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent: AttachDomEvent;\n\n /**\n * Trigger a plugin event\n * @param core The StandaloneEditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\n triggerEvent: TriggerEvent;\n}\n\n/**\n * Temp interface\n * TODO: Port these core API\n */\nexport interface UnportedCoreApiMap {\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * if triggerContentChangedEvent is set to true\n * @param core The StandaloneEditorCore object\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent: SetContent;\n\n /**\n * Insert a DOM node into editor content\n * @param core The StandaloneEditorCore object. No op if null.\n * @param option An insert option object to specify how to insert the node\n */\n insertNode: InsertNode;\n\n /**\n * Get current editor content as HTML string\n * @param core The StandaloneEditorCore object\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent: GetContent;\n\n /**\n * Get style based format state from current selection, including font name/size and colors\n * @param core The StandaloneEditorCore objects\n * @param node The node to get style from\n */\n getStyleBasedFormatState: GetStyleBasedFormatState;\n\n /**\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param core The EditorCore object.\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n * @param deprecated Deprecated parameter, not used\n */\n ensureTypeInContainer: EnsureTypeInContainer;\n}\n\n/**\n * The interface for the map of core API for Content Model editor.\n * Editor can call call API from this map under StandaloneEditorCore object\n */\nexport interface StandaloneCoreApiMap extends PortedCoreApiMap, UnportedCoreApiMap {}\n\n/**\n * Represents the core data structure of a Content Model editor\n */\nexport interface StandaloneEditorCore\n extends StandaloneEditorCorePluginState,\n UnportedCorePluginState,\n StandaloneEditorDefaultSettings {\n /**\n * The content DIV element of this editor\n */\n readonly contentDiv: HTMLDivElement;\n\n /**\n * Core API map of this editor\n */\n readonly api: StandaloneCoreApiMap;\n\n /**\n * Original API map of this editor. Overridden core API can use API from this map to call the original version of core API.\n */\n readonly originalApi: StandaloneCoreApiMap;\n\n /**\n * An array of editor plugins.\n */\n readonly plugins: EditorPlugin[];\n\n /**\n * Editor running environment\n */\n readonly environment: EditorEnvironment;\n\n /**\n * Dark model handler for the editor, used for variable-based solution.\n * If keep it null, editor will still use original dataset-based dark mode solution.\n */\n readonly darkColorHandler: DarkColorHandler;\n\n /**\n * A handler to convert HTML string to a trust HTML string.\n * By default it will just return the original HTML string directly.\n * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n */\n readonly trustedHTMLHandler: TrustedHTMLHandler;\n}\n\n/**\n * Default DOM and Content Model conversion settings for an editor\n */\nexport interface StandaloneEditorDefaultSettings {\n /**\n * Default DOM to Content Model options\n */\n defaultDomToModelOptions: (DomToModelOption | undefined)[];\n\n /**\n * Default Content Model to DOM options\n */\n defaultModelToDomOptions: (ModelToDomOption | undefined)[];\n\n /**\n * Default DOM to Content Model config, calculated from defaultDomToModelOptions,\n * will be used for creating content model if there is no other customized options\n */\n defaultDomToModelConfig: DomToModelSettings;\n\n /**\n * Default Content Model to DOM config, calculated from defaultModelToDomOptions,\n * will be used for setting content model if there is no other customized options\n */\n defaultModelToDomConfig: ModelToDomSettings;\n}\n"]}
@@ -1,10 +1,12 @@
1
+ import type { CopyPastePluginState } from '../pluginState/CopyPastePluginState';
2
+ import type { UndoPluginState } from '../pluginState/UndoPluginState';
1
3
  import type { SelectionPluginState } from '../pluginState/SelectionPluginState';
2
4
  import type { EntityPluginState } from '../pluginState/EntityPluginState';
3
5
  import type { LifecyclePluginState } from '../pluginState/LifecyclePluginState';
4
6
  import type { DOMEventPluginState } from '../pluginState/DOMEventPluginState';
5
7
  import type { ContentModelCachePluginState } from '../pluginState/ContentModelCachePluginState';
6
8
  import type { ContentModelFormatPluginState } from '../pluginState/ContentModelFormatPluginState';
7
- import type { CopyPastePluginState, PluginWithState } from 'roosterjs-editor-types';
9
+ import type { PluginWithState } from 'roosterjs-editor-types';
8
10
  /**
9
11
  * Core plugins for standalone editor
10
12
  */
@@ -33,6 +35,10 @@ export interface StandaloneEditorCorePlugins {
33
35
  * Entity Plugin handles all operations related to an entity and generate entity specified events
34
36
  */
35
37
  readonly entity: PluginWithState<EntityPluginState>;
38
+ /**
39
+ * Undo plugin provides the ability to undo/redo
40
+ */
41
+ readonly undo: PluginWithState<UndoPluginState>;
36
42
  /**
37
43
  * Lifecycle plugin handles editor initialization and disposing
38
44
  */
@@ -1 +1 @@
1
- {"version":3,"file":"StandaloneEditorCorePlugins.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorCorePlugins.ts"],"names":[],"mappings":"","sourcesContent":["import type { SelectionPluginState } from '../pluginState/SelectionPluginState';\nimport type { EntityPluginState } from '../pluginState/EntityPluginState';\nimport type { LifecyclePluginState } from '../pluginState/LifecyclePluginState';\nimport type { DOMEventPluginState } from '../pluginState/DOMEventPluginState';\nimport type { ContentModelCachePluginState } from '../pluginState/ContentModelCachePluginState';\nimport type { ContentModelFormatPluginState } from '../pluginState/ContentModelFormatPluginState';\nimport type { CopyPastePluginState, PluginWithState } from 'roosterjs-editor-types';\n\n/**\n * Core plugins for standalone editor\n */\nexport interface StandaloneEditorCorePlugins {\n /**\n * ContentModel cache plugin manages cached Content Model, and refresh the cache when necessary\n */\n readonly cache: PluginWithState<ContentModelCachePluginState>;\n\n /**\n * ContentModelFormat plugins helps editor to do formatting on top of content model.\n */\n readonly format: PluginWithState<ContentModelFormatPluginState>;\n\n /**\n * Copy and paste plugin for handling onCopy and onPaste event\n */\n readonly copyPaste: PluginWithState<CopyPastePluginState>;\n\n /**\n * DomEvent plugin helps handle additional DOM events such as IME composition, cut, drop.\n */\n readonly domEvent: PluginWithState<DOMEventPluginState>;\n\n /**\n * Selection plugin handles selection, including range selection, table selection, and image selection\n */\n readonly selection: PluginWithState<SelectionPluginState>;\n\n /**\n * Entity Plugin handles all operations related to an entity and generate entity specified events\n */\n readonly entity: PluginWithState<EntityPluginState>;\n\n /**\n * Lifecycle plugin handles editor initialization and disposing\n */\n readonly lifecycle: PluginWithState<LifecyclePluginState>;\n}\n"]}
1
+ {"version":3,"file":"StandaloneEditorCorePlugins.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorCorePlugins.ts"],"names":[],"mappings":"","sourcesContent":["import type { CopyPastePluginState } from '../pluginState/CopyPastePluginState';\nimport type { UndoPluginState } from '../pluginState/UndoPluginState';\nimport type { SelectionPluginState } from '../pluginState/SelectionPluginState';\nimport type { EntityPluginState } from '../pluginState/EntityPluginState';\nimport type { LifecyclePluginState } from '../pluginState/LifecyclePluginState';\nimport type { DOMEventPluginState } from '../pluginState/DOMEventPluginState';\nimport type { ContentModelCachePluginState } from '../pluginState/ContentModelCachePluginState';\nimport type { ContentModelFormatPluginState } from '../pluginState/ContentModelFormatPluginState';\nimport type { PluginWithState } from 'roosterjs-editor-types';\n\n/**\n * Core plugins for standalone editor\n */\nexport interface StandaloneEditorCorePlugins {\n /**\n * ContentModel cache plugin manages cached Content Model, and refresh the cache when necessary\n */\n readonly cache: PluginWithState<ContentModelCachePluginState>;\n\n /**\n * ContentModelFormat plugins helps editor to do formatting on top of content model.\n */\n readonly format: PluginWithState<ContentModelFormatPluginState>;\n\n /**\n * Copy and paste plugin for handling onCopy and onPaste event\n */\n readonly copyPaste: PluginWithState<CopyPastePluginState>;\n\n /**\n * DomEvent plugin helps handle additional DOM events such as IME composition, cut, drop.\n */\n readonly domEvent: PluginWithState<DOMEventPluginState>;\n\n /**\n * Selection plugin handles selection, including range selection, table selection, and image selection\n */\n readonly selection: PluginWithState<SelectionPluginState>;\n\n /**\n * Entity Plugin handles all operations related to an entity and generate entity specified events\n */\n readonly entity: PluginWithState<EntityPluginState>;\n\n /**\n * Undo plugin provides the ability to undo/redo\n */\n readonly undo: PluginWithState<UndoPluginState>;\n\n /**\n * Lifecycle plugin handles editor initialization and disposing\n */\n readonly lifecycle: PluginWithState<LifecyclePluginState>;\n}\n"]}
@@ -4,6 +4,7 @@ import type { EditorPlugin, TrustedHTMLHandler } from 'roosterjs-editor-types';
4
4
  import type { DomToModelOption } from '../context/DomToModelOption';
5
5
  import type { ModelToDomOption } from '../context/ModelToDomOption';
6
6
  import type { ContentModelDocument } from '../group/ContentModelDocument';
7
+ import type { SnapshotsManager } from '../parameter/SnapshotsManager';
7
8
  /**
8
9
  * Options for Content Model editor
9
10
  */
@@ -75,4 +76,9 @@ export interface StandaloneEditorOptions {
75
76
  * If the editor is currently in dark mode
76
77
  */
77
78
  inDarkMode?: boolean;
79
+ /**
80
+ * Undo snapshot service based on content metadata. Use this parameter to customize the undo snapshot service.
81
+ * When this property is set, value of undoSnapshotService will be ignored.
82
+ */
83
+ snapshotsManager?: SnapshotsManager;
78
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StandaloneEditorOptions.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../format/ContentModelSegmentFormat';\nimport type { StandaloneCoreApiMap } from './StandaloneEditorCore';\nimport type { EditorPlugin, TrustedHTMLHandler } from 'roosterjs-editor-types';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\n\n/**\n * Options for Content Model editor\n */\nexport interface StandaloneEditorOptions {\n /**\n * Default options used for DOM to Content Model conversion\n */\n defaultDomToModelOptions?: DomToModelOption;\n\n /**\n * Default options used for Content Model to DOM conversion\n */\n defaultModelToDomOptions?: ModelToDomOption;\n\n /**\n * Reuse existing DOM structure if possible, and update the model when content or selection is changed\n */\n cacheModel?: boolean;\n\n /**\n * List of plugins.\n * The order of plugins here determines in what order each event will be dispatched.\n * Plugins not appear in this list will not be added to editor, including built-in plugins.\n * Default value is empty array.\n */\n plugins?: EditorPlugin[];\n\n /**\n * Default format of editor content. This will be applied to empty content.\n * If there is already content inside editor, format of existing content will not be changed.\n * Default value is the computed style of editor content DIV\n */\n defaultSegmentFormat?: ContentModelSegmentFormat;\n\n /**\n * Allowed custom content type when paste besides text/plain, text/html and images\n * Only text types are supported, and do not add \"text/\" prefix to the type values\n */\n allowedCustomPasteType?: string[];\n\n /**\n * The scroll container to get scroll event from.\n * By default, the scroll container will be the same with editor content DIV\n */\n scrollContainer?: HTMLElement;\n\n /**\n * A util function to transform light mode color to dark mode color\n * Default value is to return the original light color\n */\n getDarkColor?: (lightColor: string) => string;\n\n /**\n * Customized trusted type handler used for sanitizing HTML string before assign to DOM tree\n * This is required when trusted-type Content-Security-Policy (CSP) is enabled.\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n trustedHTMLHandler?: TrustedHTMLHandler;\n\n /**\n * A function map to override default core API implementation\n * Default value is null\n */\n coreApiOverride?: Partial<StandaloneCoreApiMap>;\n\n /**\n * Color of the border of a selectedImage. Default color: '#DB626C'\n */\n imageSelectionBorderColor?: string;\n\n /**\n * Initial Content Model\n */\n initialModel?: ContentModelDocument;\n\n /**\n * Whether to skip the adjust editor process when for light/dark mode\n */\n doNotAdjustEditorColor?: boolean;\n\n /**\n * If the editor is currently in dark mode\n */\n inDarkMode?: boolean;\n}\n"]}
1
+ {"version":3,"file":"StandaloneEditorOptions.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../format/ContentModelSegmentFormat';\nimport type { StandaloneCoreApiMap } from './StandaloneEditorCore';\nimport type { EditorPlugin, TrustedHTMLHandler } from 'roosterjs-editor-types';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { SnapshotsManager } from '../parameter/SnapshotsManager';\n\n/**\n * Options for Content Model editor\n */\nexport interface StandaloneEditorOptions {\n /**\n * Default options used for DOM to Content Model conversion\n */\n defaultDomToModelOptions?: DomToModelOption;\n\n /**\n * Default options used for Content Model to DOM conversion\n */\n defaultModelToDomOptions?: ModelToDomOption;\n\n /**\n * Reuse existing DOM structure if possible, and update the model when content or selection is changed\n */\n cacheModel?: boolean;\n\n /**\n * List of plugins.\n * The order of plugins here determines in what order each event will be dispatched.\n * Plugins not appear in this list will not be added to editor, including built-in plugins.\n * Default value is empty array.\n */\n plugins?: EditorPlugin[];\n\n /**\n * Default format of editor content. This will be applied to empty content.\n * If there is already content inside editor, format of existing content will not be changed.\n * Default value is the computed style of editor content DIV\n */\n defaultSegmentFormat?: ContentModelSegmentFormat;\n\n /**\n * Allowed custom content type when paste besides text/plain, text/html and images\n * Only text types are supported, and do not add \"text/\" prefix to the type values\n */\n allowedCustomPasteType?: string[];\n\n /**\n * The scroll container to get scroll event from.\n * By default, the scroll container will be the same with editor content DIV\n */\n scrollContainer?: HTMLElement;\n\n /**\n * A util function to transform light mode color to dark mode color\n * Default value is to return the original light color\n */\n getDarkColor?: (lightColor: string) => string;\n\n /**\n * Customized trusted type handler used for sanitizing HTML string before assign to DOM tree\n * This is required when trusted-type Content-Security-Policy (CSP) is enabled.\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n trustedHTMLHandler?: TrustedHTMLHandler;\n\n /**\n * A function map to override default core API implementation\n * Default value is null\n */\n coreApiOverride?: Partial<StandaloneCoreApiMap>;\n\n /**\n * Color of the border of a selectedImage. Default color: '#DB626C'\n */\n imageSelectionBorderColor?: string;\n\n /**\n * Initial Content Model\n */\n initialModel?: ContentModelDocument;\n\n /**\n * Whether to skip the adjust editor process when for light/dark mode\n */\n doNotAdjustEditorColor?: boolean;\n\n /**\n * If the editor is currently in dark mode\n */\n inDarkMode?: boolean;\n\n /**\n * Undo snapshot service based on content metadata. Use this parameter to customize the undo snapshot service.\n * When this property is set, value of undoSnapshotService will be ignored.\n */\n snapshotsManager?: SnapshotsManager;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { EntityState } from '../parameter/FormatWithContentModelContext';
1
2
  import type { ContentModelEntity } from '../entity/ContentModelEntity';
2
3
  import type { EntityRemovalOperation } from '../enum/EntityOperation';
3
4
  import type { ContentModelDocument } from '../group/ContentModelDocument';
@@ -16,7 +17,7 @@ export interface ChangedEntity {
16
17
  */
17
18
  operation: EntityRemovalOperation | 'newEntity';
18
19
  /**
19
- * @optional Raw DOM event that causes the chagne
20
+ * @optional Raw DOM event that causes the change
20
21
  */
21
22
  rawEvent?: Event;
22
23
  }
@@ -36,6 +37,10 @@ export interface ContentModelContentChangedEventData extends ContentChangedEvent
36
37
  * Entities got changed (added or removed) during the content change process
37
38
  */
38
39
  readonly changedEntities?: ChangedEntity[];
40
+ /**
41
+ * Entity states related to this event
42
+ */
43
+ readonly entityStates?: EntityState[];
39
44
  }
40
45
  /**
41
46
  * Represents a change to the editor made by another plugin with content model inside