roosterjs-content-model-types 0.22.0 → 0.23.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 (58) hide show
  1. package/lib/editor/IStandaloneEditor.d.ts +49 -1
  2. package/lib/editor/IStandaloneEditor.js.map +1 -1
  3. package/lib/editor/StandaloneEditorCore.d.ts +47 -97
  4. package/lib/editor/StandaloneEditorCore.js.map +1 -1
  5. package/lib/editor/StandaloneEditorOptions.d.ts +13 -0
  6. package/lib/editor/StandaloneEditorOptions.js.map +1 -1
  7. package/lib/event/ContentModelBeforePasteEvent.d.ts +31 -2
  8. package/lib/event/ContentModelBeforePasteEvent.js.map +1 -1
  9. package/lib/index.d.ts +5 -4
  10. package/lib/index.js.map +1 -1
  11. package/lib/parameter/ClipboardData.d.ts +2 -1
  12. package/lib/parameter/ClipboardData.js.map +1 -1
  13. package/lib/parameter/ValueSanitizer.d.ts +10 -0
  14. package/lib/parameter/ValueSanitizer.js +3 -0
  15. package/lib/parameter/ValueSanitizer.js.map +1 -0
  16. package/lib/pluginState/DOMEventPluginState.d.ts +0 -5
  17. package/lib/pluginState/DOMEventPluginState.js.map +1 -1
  18. package/lib/pluginState/StandaloneEditorPluginState.d.ts +0 -8
  19. package/lib/pluginState/StandaloneEditorPluginState.js.map +1 -1
  20. package/lib-amd/editor/IStandaloneEditor.d.ts +49 -1
  21. package/lib-amd/editor/IStandaloneEditor.js.map +1 -1
  22. package/lib-amd/editor/StandaloneEditorCore.d.ts +47 -97
  23. package/lib-amd/editor/StandaloneEditorCore.js.map +1 -1
  24. package/lib-amd/editor/StandaloneEditorOptions.d.ts +13 -0
  25. package/lib-amd/editor/StandaloneEditorOptions.js.map +1 -1
  26. package/lib-amd/event/ContentModelBeforePasteEvent.d.ts +31 -2
  27. package/lib-amd/event/ContentModelBeforePasteEvent.js.map +1 -1
  28. package/lib-amd/index.d.ts +5 -4
  29. package/lib-amd/index.js.map +1 -1
  30. package/lib-amd/parameter/ClipboardData.d.ts +2 -1
  31. package/lib-amd/parameter/ClipboardData.js.map +1 -1
  32. package/lib-amd/parameter/ValueSanitizer.d.ts +10 -0
  33. package/lib-amd/parameter/ValueSanitizer.js +5 -0
  34. package/lib-amd/parameter/ValueSanitizer.js.map +1 -0
  35. package/lib-amd/pluginState/DOMEventPluginState.d.ts +0 -5
  36. package/lib-amd/pluginState/DOMEventPluginState.js.map +1 -1
  37. package/lib-amd/pluginState/StandaloneEditorPluginState.d.ts +0 -8
  38. package/lib-amd/pluginState/StandaloneEditorPluginState.js.map +1 -1
  39. package/lib-mjs/editor/IStandaloneEditor.d.ts +49 -1
  40. package/lib-mjs/editor/IStandaloneEditor.js.map +1 -1
  41. package/lib-mjs/editor/StandaloneEditorCore.d.ts +47 -97
  42. package/lib-mjs/editor/StandaloneEditorCore.js.map +1 -1
  43. package/lib-mjs/editor/StandaloneEditorOptions.d.ts +13 -0
  44. package/lib-mjs/editor/StandaloneEditorOptions.js.map +1 -1
  45. package/lib-mjs/event/ContentModelBeforePasteEvent.d.ts +31 -2
  46. package/lib-mjs/event/ContentModelBeforePasteEvent.js.map +1 -1
  47. package/lib-mjs/index.d.ts +5 -4
  48. package/lib-mjs/index.js.map +1 -1
  49. package/lib-mjs/parameter/ClipboardData.d.ts +2 -1
  50. package/lib-mjs/parameter/ClipboardData.js.map +1 -1
  51. package/lib-mjs/parameter/ValueSanitizer.d.ts +10 -0
  52. package/lib-mjs/parameter/ValueSanitizer.js +2 -0
  53. package/lib-mjs/parameter/ValueSanitizer.js.map +1 -0
  54. package/lib-mjs/pluginState/DOMEventPluginState.d.ts +0 -5
  55. package/lib-mjs/pluginState/DOMEventPluginState.js.map +1 -1
  56. package/lib-mjs/pluginState/StandaloneEditorPluginState.d.ts +0 -8
  57. package/lib-mjs/pluginState/StandaloneEditorPluginState.js.map +1 -1
  58. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ import type { PasteType } from '../enum/PasteType';
2
+ import type { ClipboardData } from '../parameter/ClipboardData';
1
3
  import type { DOMEventRecord } from '../parameter/DOMEventRecord';
2
4
  import type { SnapshotsManager } from '../parameter/SnapshotsManager';
3
5
  import type { Snapshot } from '../parameter/Snapshot';
@@ -10,7 +12,7 @@ import type { EditorEnvironment } from '../parameter/EditorEnvironment';
10
12
  import type { ModelToDomOption } from '../context/ModelToDomOption';
11
13
  import type { OnNodeCreated } from '../context/ModelToDomSettings';
12
14
  import type { ContentModelFormatter, FormatWithContentModelOptions } from '../parameter/FormatWithContentModelOptions';
13
- import type { PluginEventData, PluginEventFromType, PluginEventType } from 'roosterjs-editor-types';
15
+ import type { DarkColorHandler, PluginEventData, PluginEventFromType, PluginEventType } from 'roosterjs-editor-types';
14
16
  /**
15
17
  * An interface of standalone Content Model editor.
16
18
  * (This interface is still under development, and may still be changed in the future with some breaking changes)
@@ -92,6 +94,11 @@ export interface IStandaloneEditor {
92
94
  * @returns True if the editor is in dark mode, otherwise false
93
95
  */
94
96
  isDarkMode(): boolean;
97
+ /**
98
+ * Set the dark mode state and transforms the content to match the new state.
99
+ * @param isDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.
100
+ */
101
+ setDarkModeState(isDarkMode?: boolean): void;
95
102
  /**
96
103
  * Get current zoom scale, default value is 1
97
104
  * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale
@@ -118,4 +125,45 @@ export interface IStandaloneEditor {
118
125
  * @param eventMap A map from event name to its handler
119
126
  */
120
127
  attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void;
128
+ /**
129
+ * Check if editor is in Shadow Edit mode
130
+ */
131
+ isInShadowEdit(): boolean;
132
+ /**
133
+ * Make the editor in "Shadow Edit" mode.
134
+ * In Shadow Edit mode, all format change will finally be ignored.
135
+ * This can be used for building a live preview feature for format button, to allow user
136
+ * see format result without really apply it.
137
+ * This function can be called repeated. If editor is already in shadow edit mode, we can still
138
+ * use this function to do more shadow edit operation.
139
+ */
140
+ startShadowEdit(): void;
141
+ /**
142
+ * Leave "Shadow Edit" mode, all changes made during shadow edit will be discarded
143
+ */
144
+ stopShadowEdit(): void;
145
+ /**
146
+ * Check if the given DOM node is in editor
147
+ * @param node The node to check
148
+ */
149
+ isNodeInEditor(node: Node): boolean;
150
+ /**
151
+ * Paste into editor using a clipboardData object
152
+ * @param clipboardData Clipboard data retrieved from clipboard
153
+ * @param pasteType Type of paste
154
+ */
155
+ pasteFromClipboard(clipboardData: ClipboardData, pasteType?: PasteType): void;
156
+ /**
157
+ * Get a darkColorHandler object for this editor.
158
+ */
159
+ getDarkColorHandler(): DarkColorHandler;
160
+ /**
161
+ * Dispose this editor, dispose all plugins and custom data
162
+ */
163
+ dispose(): void;
164
+ /**
165
+ * Check if focus is in editor now
166
+ * @returns true if focus is in editor, otherwise false
167
+ */
168
+ hasFocus(): boolean;
121
169
  }
@@ -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 { 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
+ {"version":3,"file":"IStandaloneEditor.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/IStandaloneEditor.ts"],"names":[],"mappings":"","sourcesContent":["import type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport 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 {\n DarkColorHandler,\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 | 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 /**\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 * Set the dark mode state and transforms the content to match the new state.\n * @param isDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.\n */\n setDarkModeState(isDarkMode?: boolean): void;\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 /**\n * Check if editor is in Shadow Edit mode\n */\n isInShadowEdit(): boolean;\n\n /**\n * Make the editor in \"Shadow Edit\" mode.\n * In Shadow Edit mode, all format change will finally be ignored.\n * This can be used for building a live preview feature for format button, to allow user\n * see format result without really apply it.\n * This function can be called repeated. If editor is already in shadow edit mode, we can still\n * use this function to do more shadow edit operation.\n */\n startShadowEdit(): void;\n\n /**\n * Leave \"Shadow Edit\" mode, all changes made during shadow edit will be discarded\n */\n stopShadowEdit(): void;\n\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n */\n isNodeInEditor(node: Node): boolean;\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteType Type of paste\n */\n pasteFromClipboard(clipboardData: ClipboardData, pasteType?: PasteType): void;\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler;\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void;\n /**\n * Check if focus is in editor now\n * @returns true if focus is in editor, otherwise false\n */\n hasFocus(): boolean;\n}\n"]}
@@ -1,10 +1,11 @@
1
+ import type { ClipboardData } from '../parameter/ClipboardData';
2
+ import type { PasteType } from '../enum/PasteType';
1
3
  import type { DOMEventRecord } from '../parameter/DOMEventRecord';
2
4
  import type { Snapshot } from '../parameter/Snapshot';
3
5
  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';
6
+ import type { DarkColorHandler, EditorPlugin, PluginEvent, Rect, TrustedHTMLHandler } from 'roosterjs-editor-types';
6
7
  import type { ContentModelDocument } from '../group/ContentModelDocument';
7
- import type { StandaloneEditorCorePluginState, UnportedCorePluginState } from '../pluginState/StandaloneEditorPluginState';
8
+ import type { StandaloneEditorCorePluginState } from '../pluginState/StandaloneEditorPluginState';
8
9
  import type { DOMSelection } from '../selection/DOMSelection';
9
10
  import type { DomToModelOption } from '../context/DomToModelOption';
10
11
  import type { DomToModelSettings } from '../context/DomToModelSettings';
@@ -82,14 +83,6 @@ export declare type AddUndoSnapshot = (core: StandaloneEditorCore, canUndoByBack
82
83
  * @param core The StandaloneEditorCore object
83
84
  */
84
85
  export declare type GetVisibleViewport = (core: StandaloneEditorCore) => Rect | null;
85
- /**
86
- * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
87
- * if triggerContentChangedEvent is set to true
88
- * @param core The StandaloneEditorCore object
89
- * @param content HTML content to set in
90
- * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
91
- */
92
- export declare type SetContent = (core: StandaloneEditorCore, content: string, triggerContentChangedEvent: boolean, metadata?: ContentMetadata) => void;
93
86
  /**
94
87
  * Check if the editor has focus now
95
88
  * @param core The StandaloneEditorCore object
@@ -101,31 +94,12 @@ export declare type HasFocus = (core: StandaloneEditorCore) => boolean;
101
94
  * @param core The StandaloneEditorCore object
102
95
  */
103
96
  export declare type Focus = (core: StandaloneEditorCore) => void;
104
- /**
105
- * Insert a DOM node into editor content
106
- * @param core The StandaloneEditorCore object. No op if null.
107
- * @param option An insert option object to specify how to insert the node
108
- */
109
- export declare type InsertNode = (core: StandaloneEditorCore, node: Node, option: InsertOption | null) => boolean;
110
97
  /**
111
98
  * Attach a DOM event to the editor content DIV
112
99
  * @param core The StandaloneEditorCore object
113
100
  * @param eventMap A map from event name to its handler
114
101
  */
115
102
  export declare type AttachDomEvent = (core: StandaloneEditorCore, eventMap: Record<string, DOMEventRecord>) => () => void;
116
- /**
117
- * Get current editor content as HTML string
118
- * @param core The StandaloneEditorCore object
119
- * @param mode specify what kind of HTML content to retrieve
120
- * @returns HTML string representing current editor content
121
- */
122
- export declare type GetContent = (core: StandaloneEditorCore, mode: GetContentMode | CompatibleGetContentMode) => string;
123
- /**
124
- * Get style based format state from current selection, including font name/size and colors
125
- * @param core The StandaloneEditorCore objects
126
- * @param node The node to get style from
127
- */
128
- export declare type GetStyleBasedFormatState = (core: StandaloneEditorCore, node: Node | null) => StyleBasedFormatState;
129
103
  /**
130
104
  * Restore an undo snapshot into editor
131
105
  * @param core The StandaloneEditorCore object
@@ -133,18 +107,17 @@ export declare type GetStyleBasedFormatState = (core: StandaloneEditorCore, node
133
107
  */
134
108
  export declare type RestoreUndoSnapshot = (core: StandaloneEditorCore, snapshot: Snapshot) => void;
135
109
  /**
136
- * Ensure user will type into a container element rather than into the editor content DIV directly
110
+ * Paste into editor using a clipboardData object
137
111
  * @param core The StandaloneEditorCore object.
138
- * @param position The position that user is about to type to
139
- * @param keyboardEvent Optional keyboard event object
140
- * @param deprecated Deprecated parameter, not used
112
+ * @param clipboardData Clipboard data retrieved from clipboard
113
+ * @param pasteType Type of content to paste. @default normal
141
114
  */
142
- export declare type EnsureTypeInContainer = (core: StandaloneEditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, deprecated?: boolean) => void;
115
+ export declare type Paste = (core: StandaloneEditorCore, clipboardData: ClipboardData, pasteType: PasteType) => void;
143
116
  /**
144
- * Temp interface
145
- * TODO: Port other core API
117
+ * The interface for the map of core API for Content Model editor.
118
+ * Editor can call call API from this map under StandaloneEditorCore object
146
119
  */
147
- export interface PortedCoreApiMap {
120
+ export interface StandaloneCoreApiMap {
148
121
  /**
149
122
  * Create a EditorContext object used by ContentModel API
150
123
  * @param core The StandaloneEditorCore object
@@ -235,58 +208,18 @@ export interface PortedCoreApiMap {
235
208
  * @param broadcast Set to true to skip the shouldHandleEventExclusively check
236
209
  */
237
210
  triggerEvent: TriggerEvent;
238
- }
239
- /**
240
- * Temp interface
241
- * TODO: Port these core API
242
- */
243
- export interface UnportedCoreApiMap {
244
- /**
245
- * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
246
- * if triggerContentChangedEvent is set to true
247
- * @param core The StandaloneEditorCore object
248
- * @param content HTML content to set in
249
- * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
250
- */
251
- setContent: SetContent;
252
- /**
253
- * Insert a DOM node into editor content
254
- * @param core The StandaloneEditorCore object. No op if null.
255
- * @param option An insert option object to specify how to insert the node
256
- */
257
- insertNode: InsertNode;
258
211
  /**
259
- * Get current editor content as HTML string
260
- * @param core The StandaloneEditorCore object
261
- * @param mode specify what kind of HTML content to retrieve
262
- * @returns HTML string representing current editor content
263
- */
264
- getContent: GetContent;
265
- /**
266
- * Get style based format state from current selection, including font name/size and colors
267
- * @param core The StandaloneEditorCore objects
268
- * @param node The node to get style from
269
- */
270
- getStyleBasedFormatState: GetStyleBasedFormatState;
271
- /**
272
- * Ensure user will type into a container element rather than into the editor content DIV directly
273
- * @param core The EditorCore object.
274
- * @param position The position that user is about to type to
275
- * @param keyboardEvent Optional keyboard event object
276
- * @param deprecated Deprecated parameter, not used
212
+ * Paste into editor using a clipboardData object
213
+ * @param editor The editor to paste content into
214
+ * @param clipboardData Clipboard data retrieved from clipboard
215
+ * @param pasteType Type of content to paste. @default normal
277
216
  */
278
- ensureTypeInContainer: EnsureTypeInContainer;
279
- }
280
- /**
281
- * The interface for the map of core API for Content Model editor.
282
- * Editor can call call API from this map under StandaloneEditorCore object
283
- */
284
- export interface StandaloneCoreApiMap extends PortedCoreApiMap, UnportedCoreApiMap {
217
+ paste: Paste;
285
218
  }
286
219
  /**
287
220
  * Represents the core data structure of a Content Model editor
288
221
  */
289
- export interface StandaloneEditorCore extends StandaloneEditorCorePluginState, UnportedCorePluginState, StandaloneEditorDefaultSettings {
222
+ export interface StandaloneEditorCore extends StandaloneEditorCorePluginState {
290
223
  /**
291
224
  * The content DIV element of this editor
292
225
  */
@@ -303,6 +236,14 @@ export interface StandaloneEditorCore extends StandaloneEditorCorePluginState, U
303
236
  * An array of editor plugins.
304
237
  */
305
238
  readonly plugins: EditorPlugin[];
239
+ /**
240
+ * Settings used by DOM to Content Model conversion
241
+ */
242
+ readonly domToModelSettings: ContentModelSettings<DomToModelOption, DomToModelSettings>;
243
+ /**
244
+ * Settings used by Content Model to DOM conversion
245
+ */
246
+ readonly modelToDomSettings: ContentModelSettings<ModelToDomOption, ModelToDomSettings>;
306
247
  /**
307
248
  * Editor running environment
308
249
  */
@@ -318,27 +259,36 @@ export interface StandaloneEditorCore extends StandaloneEditorCorePluginState, U
318
259
  * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler
319
260
  */
320
261
  readonly trustedHTMLHandler: TrustedHTMLHandler;
262
+ /**
263
+ * A callback to be invoked when any exception is thrown during disposing editor
264
+ * @param plugin The plugin that causes exception
265
+ * @param error The error object we got
266
+ */
267
+ readonly disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
268
+ /**
269
+ * @deprecated Will be removed soon.
270
+ * Current zoom scale, default value is 1
271
+ * When editor is put under a zoomed container, need to pass the zoom scale number using this property
272
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
273
+ */
274
+ zoomScale: number;
321
275
  }
322
276
  /**
323
277
  * Default DOM and Content Model conversion settings for an editor
324
278
  */
325
- export interface StandaloneEditorDefaultSettings {
326
- /**
327
- * Default DOM to Content Model options
328
- */
329
- defaultDomToModelOptions: (DomToModelOption | undefined)[];
279
+ export interface ContentModelSettings<OptionType, ConfigType> {
330
280
  /**
331
- * Default Content Model to DOM options
281
+ * Built in options used by editor
332
282
  */
333
- defaultModelToDomOptions: (ModelToDomOption | undefined)[];
283
+ builtIn: OptionType;
334
284
  /**
335
- * Default DOM to Content Model config, calculated from defaultDomToModelOptions,
336
- * will be used for creating content model if there is no other customized options
285
+ * Customize options passed in from Editor Options, used for overwrite default option.
286
+ * This will also be used by copy/paste
337
287
  */
338
- defaultDomToModelConfig: DomToModelSettings;
288
+ customized: OptionType;
339
289
  /**
340
- * Default Content Model to DOM config, calculated from defaultModelToDomOptions,
341
- * will be used for setting content model if there is no other customized options
290
+ * Configuration calculated from default and customized options.
291
+ * This is a cached object so that we don't need to cache it every time when we use Content Model
342
292
  */
343
- defaultModelToDomConfig: ModelToDomSettings;
293
+ calculated: ConfigType;
344
294
  }
@@ -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 { 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
+ {"version":3,"file":"StandaloneEditorCore.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/editor/StandaloneEditorCore.ts"],"names":[],"mappings":"","sourcesContent":["import type { ClipboardData } from '../parameter/ClipboardData';\nimport type { PasteType } from '../enum/PasteType';\nimport type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { EntityState } from '../parameter/FormatWithContentModelContext';\nimport type {\n DarkColorHandler,\n EditorPlugin,\n PluginEvent,\n Rect,\n TrustedHTMLHandler,\n} from 'roosterjs-editor-types';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { StandaloneEditorCorePluginState } 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 * 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 * 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 * 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 * Paste into editor using a clipboardData object\n * @param core The StandaloneEditorCore object.\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteType Type of content to paste. @default normal\n */\nexport type Paste = (\n core: StandaloneEditorCore,\n clipboardData: ClipboardData,\n pasteType: PasteType\n) => void;\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 {\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 * Paste into editor using a clipboardData object\n * @param editor The editor to paste content into\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteType Type of content to paste. @default normal\n */\n paste: Paste;\n}\n\n/**\n * Represents the core data structure of a Content Model editor\n */\nexport interface StandaloneEditorCore extends StandaloneEditorCorePluginState {\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 * Settings used by DOM to Content Model conversion\n */\n readonly domToModelSettings: ContentModelSettings<DomToModelOption, DomToModelSettings>;\n\n /**\n * Settings used by Content Model to DOM conversion\n */\n readonly modelToDomSettings: ContentModelSettings<ModelToDomOption, ModelToDomSettings>;\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 * A callback to be invoked when any exception is thrown during disposing editor\n * @param plugin The plugin that causes exception\n * @param error The error object we got\n */\n readonly disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;\n\n /**\n * @deprecated Will be removed soon.\n * Current zoom scale, default value is 1\n * When editor is put under a zoomed container, need to pass the zoom scale number using this property\n * to let editor behave correctly especially for those mouse drag/drop behaviors\n */\n zoomScale: number;\n}\n\n/**\n * Default DOM and Content Model conversion settings for an editor\n */\nexport interface ContentModelSettings<OptionType, ConfigType> {\n /**\n * Built in options used by editor\n */\n builtIn: OptionType;\n\n /**\n * Customize options passed in from Editor Options, used for overwrite default option.\n * This will also be used by copy/paste\n */\n customized: OptionType;\n\n /**\n * Configuration calculated from default and customized options.\n * This is a cached object so that we don't need to cache it every time when we use Content Model\n */\n calculated: ConfigType;\n}\n"]}
@@ -81,4 +81,17 @@ export interface StandaloneEditorOptions {
81
81
  * When this property is set, value of undoSnapshotService will be ignored.
82
82
  */
83
83
  snapshotsManager?: SnapshotsManager;
84
+ /**
85
+ * A callback to be invoked when any exception is thrown during disposing editor
86
+ * @param plugin The plugin that causes exception
87
+ * @param error The error object we got
88
+ */
89
+ disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
90
+ /**
91
+ * @deprecated
92
+ * Current zoom scale, @default value is 1
93
+ * When editor is put under a zoomed container, need to pass the zoom scale number using this property
94
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
95
+ */
96
+ zoomScale?: number;
84
97
  }
@@ -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';\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
+ {"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 /**\n * A callback to be invoked when any exception is thrown during disposing editor\n * @param plugin The plugin that causes exception\n * @param error The error object we got\n */\n disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;\n\n /**\n * @deprecated\n * Current zoom scale, @default value is 1\n * When editor is put under a zoomed container, need to pass the zoom scale number using this property\n * to let editor behave correctly especially for those mouse drag/drop behaviors\n */\n zoomScale?: number;\n}\n"]}
@@ -1,7 +1,36 @@
1
+ import type { ValueSanitizer } from '../parameter/ValueSanitizer';
1
2
  import type { DomToModelOption } from '../context/DomToModelOption';
2
3
  import type { ContentModelDocument } from '../group/ContentModelDocument';
3
4
  import type { InsertPoint } from '../selection/InsertPoint';
4
5
  import type { BeforePasteEvent, BeforePasteEventData, CompatibleBeforePasteEvent } from 'roosterjs-editor-types';
6
+ /**
7
+ * Options for DOM to Content Model conversion for paste only
8
+ */
9
+ export interface DomToModelOptionForPaste extends Required<DomToModelOption> {
10
+ /**
11
+ * Additional allowed HTML tags in lower case. Element with these tags will be preserved
12
+ */
13
+ additionalAllowedTags: Lowercase<string>[];
14
+ /**
15
+ * Additional disallowed HTML tags in lower case. Elements with these tags will be dropped
16
+ */
17
+ additionalDisallowedTags: Lowercase<string>[];
18
+ /**
19
+ * Additional sanitizers for CSS styles
20
+ */
21
+ styleSanitizers: Record<string, ValueSanitizer>;
22
+ /**
23
+ * Additional sanitizers for CSS styles
24
+ */
25
+ attributeSanitizers: Record<string, ValueSanitizer>;
26
+ }
27
+ /**
28
+ * A function type used by merging pasted content into current Content Model
29
+ * @param target Target Content Model to merge into
30
+ * @param source Source Content Model to merge from
31
+ * @returns Insert point after merge
32
+ */
33
+ export declare type MergePastedContentFunc = (target: ContentModelDocument, source: ContentModelDocument) => InsertPoint | null;
5
34
  /**
6
35
  * Data of ContentModelBeforePasteEvent
7
36
  */
@@ -9,11 +38,11 @@ export interface ContentModelBeforePasteEventData extends BeforePasteEventData {
9
38
  /**
10
39
  * domToModel Options to use when creating the content model from the paste fragment
11
40
  */
12
- domToModelOption: Partial<DomToModelOption>;
41
+ domToModelOption: DomToModelOptionForPaste;
13
42
  /**
14
43
  * customizedMerge Customized merge function to use when merging the paste fragment into the editor
15
44
  */
16
- customizedMerge?: (target: ContentModelDocument, source: ContentModelDocument) => InsertPoint | null;
45
+ customizedMerge?: MergePastedContentFunc;
17
46
  }
18
47
  /**
19
48
  * Provides a chance for plugin to change the content before it is pasted into editor.
@@ -1 +1 @@
1
- {"version":3,"file":"ContentModelBeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/event/ContentModelBeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOption } from '../context/DomToModelOption';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\nimport type {\n BeforePasteEvent,\n BeforePasteEventData,\n CompatibleBeforePasteEvent,\n} from 'roosterjs-editor-types';\n\n/**\n * Data of ContentModelBeforePasteEvent\n */\nexport interface ContentModelBeforePasteEventData extends BeforePasteEventData {\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n domToModelOption: Partial<DomToModelOption>;\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: (\n target: ContentModelDocument,\n source: ContentModelDocument\n ) => InsertPoint | null;\n}\n\n/**\n * Provides a chance for plugin to change the content before it is pasted into editor.\n */\nexport interface ContentModelBeforePasteEvent\n extends ContentModelBeforePasteEventData,\n BeforePasteEvent {}\n\n/**\n * Provides a chance for plugin to change the content before it is pasted into editor.\n */\nexport interface CompatibleContentModelBeforePasteEvent\n extends ContentModelBeforePasteEventData,\n CompatibleBeforePasteEvent {}\n"]}
1
+ {"version":3,"file":"ContentModelBeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-types/lib/event/ContentModelBeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueSanitizer } from '../parameter/ValueSanitizer';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\nimport type {\n BeforePasteEvent,\n BeforePasteEventData,\n CompatibleBeforePasteEvent,\n} from 'roosterjs-editor-types';\n\n/**\n * Options for DOM to Content Model conversion for paste only\n */\nexport interface DomToModelOptionForPaste extends Required<DomToModelOption> {\n /**\n * Additional allowed HTML tags in lower case. Element with these tags will be preserved\n */\n additionalAllowedTags: Lowercase<string>[];\n\n /**\n * Additional disallowed HTML tags in lower case. Elements with these tags will be dropped\n */\n additionalDisallowedTags: Lowercase<string>[];\n\n /**\n * Additional sanitizers for CSS styles\n */\n styleSanitizers: Record<string, ValueSanitizer>;\n\n /**\n * Additional sanitizers for CSS styles\n */\n attributeSanitizers: Record<string, ValueSanitizer>;\n}\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of ContentModelBeforePasteEvent\n */\nexport interface ContentModelBeforePasteEventData extends BeforePasteEventData {\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n domToModelOption: DomToModelOptionForPaste;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n}\n\n/**\n * Provides a chance for plugin to change the content before it is pasted into editor.\n */\nexport interface ContentModelBeforePasteEvent\n extends ContentModelBeforePasteEventData,\n BeforePasteEvent {}\n\n/**\n * Provides a chance for plugin to change the content before it is pasted into editor.\n */\nexport interface CompatibleContentModelBeforePasteEvent\n extends ContentModelBeforePasteEventData,\n CompatibleBeforePasteEvent {}\n"]}
package/lib/index.d.ts CHANGED
@@ -112,17 +112,17 @@ export { ArrayItemType, DefinitionBase, StringDefinition, NumberDefinition, Bool
112
112
  export { ColorManager, Colors } from './context/ColorManager';
113
113
  export { IStandaloneEditor } from './editor/IStandaloneEditor';
114
114
  export { StandaloneEditorOptions } from './editor/StandaloneEditorOptions';
115
- export { CreateContentModel, CreateEditorContext, GetDOMSelection, SetContentModel, SetDOMSelection, FormatContentModel, StandaloneCoreApiMap, StandaloneEditorCore, StandaloneEditorDefaultSettings, SwitchShadowEdit, TriggerEvent, AddUndoSnapshot, PortedCoreApiMap, UnportedCoreApiMap, SetContent, HasFocus, Focus, InsertNode, AttachDomEvent, GetContent, GetStyleBasedFormatState, RestoreUndoSnapshot, EnsureTypeInContainer, GetVisibleViewport, } from './editor/StandaloneEditorCore';
115
+ export { CreateContentModel, CreateEditorContext, GetDOMSelection, SetContentModel, SetDOMSelection, FormatContentModel, StandaloneCoreApiMap, StandaloneEditorCore, ContentModelSettings, SwitchShadowEdit, TriggerEvent, AddUndoSnapshot, HasFocus, Focus, AttachDomEvent, RestoreUndoSnapshot, GetVisibleViewport, Paste, } from './editor/StandaloneEditorCore';
116
116
  export { StandaloneEditorCorePlugins } from './editor/StandaloneEditorCorePlugins';
117
117
  export { ContentModelCachePluginState } from './pluginState/ContentModelCachePluginState';
118
- export { StandaloneEditorCorePluginState, UnportedCorePluginState, } from './pluginState/StandaloneEditorPluginState';
118
+ export { StandaloneEditorCorePluginState } from './pluginState/StandaloneEditorPluginState';
119
119
  export { ContentModelFormatPluginState, PendingFormat, } from './pluginState/ContentModelFormatPluginState';
120
+ export { CopyPastePluginState } from './pluginState/CopyPastePluginState';
120
121
  export { DOMEventPluginState } from './pluginState/DOMEventPluginState';
121
122
  export { LifecyclePluginState } from './pluginState/LifecyclePluginState';
122
123
  export { EntityPluginState, KnownEntityItem } from './pluginState/EntityPluginState';
123
124
  export { SelectionPluginState } from './pluginState/SelectionPluginState';
124
125
  export { UndoPluginState } from './pluginState/UndoPluginState';
125
- export { CopyPastePluginState } from './pluginState/CopyPastePluginState';
126
126
  export { EditorEnvironment } from './parameter/EditorEnvironment';
127
127
  export { EntityState, DeletedEntity, FormatWithContentModelContext, } from './parameter/FormatWithContentModelContext';
128
128
  export { FormatWithContentModelOptions, ContentModelFormatter, } from './parameter/FormatWithContentModelOptions';
@@ -136,6 +136,7 @@ export { SnapshotsManager } from './parameter/SnapshotsManager';
136
136
  export { DOMEventHandlerFunction, DOMEventRecord } from './parameter/DOMEventRecord';
137
137
  export { EdgeLinkPreview } from './parameter/EdgeLinkPreview';
138
138
  export { ClipboardData } from './parameter/ClipboardData';
139
- export { ContentModelBeforePasteEvent, ContentModelBeforePasteEventData, CompatibleContentModelBeforePasteEvent, } from './event/ContentModelBeforePasteEvent';
139
+ export { ValueSanitizer } from './parameter/ValueSanitizer';
140
+ export { MergePastedContentFunc, DomToModelOptionForPaste, ContentModelBeforePasteEvent, ContentModelBeforePasteEventData, CompatibleContentModelBeforePasteEvent, } from './event/ContentModelBeforePasteEvent';
140
141
  export { ContentModelContentChangedEvent, CompatibleContentModelContentChangedEvent, ContentModelContentChangedEventData, ChangedEntity, } from './event/ContentModelContentChangedEvent';
141
142
  export { CompatibleContentModelSelectionChangedEvent, ContentModelSelectionChangedEvent, ContentModelSelectionChangedEventData, } from './event/ContentModelSelectionChangedEvent';