roosterjs-content-model-types 0.20.0 → 0.21.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.
- package/lib/editor/StandaloneEditorCore.d.ts +345 -16
- package/lib/editor/StandaloneEditorCore.js.map +1 -1
- package/lib/editor/StandaloneEditorCorePlugins.d.ts +40 -0
- package/lib/editor/StandaloneEditorCorePlugins.js +3 -0
- package/lib/editor/StandaloneEditorCorePlugins.js.map +1 -0
- package/lib/editor/StandaloneEditorOptions.d.ts +59 -0
- package/lib/editor/StandaloneEditorOptions.js.map +1 -1
- package/lib/enum/EntityOperation.d.ts +5 -1
- package/lib/enum/EntityOperation.js.map +1 -1
- package/lib/event/ContentModelContentChangedEvent.d.ts +25 -2
- package/lib/event/ContentModelContentChangedEvent.js.map +1 -1
- package/lib/format/metadata/ListMetadataFormat.d.ts +4 -146
- package/lib/format/metadata/ListMetadataFormat.js +0 -145
- package/lib/format/metadata/ListMetadataFormat.js.map +1 -1
- package/lib/format/metadata/TableMetadataFormat.d.ts +2 -75
- package/lib/format/metadata/TableMetadataFormat.js +0 -75
- package/lib/format/metadata/TableMetadataFormat.js.map +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.js +0 -6
- package/lib/index.js.map +1 -1
- package/lib/parameter/EditorEnvironment.d.ts +4 -0
- package/lib/parameter/EditorEnvironment.js.map +1 -1
- package/lib/pluginState/DOMEventPluginState.d.ts +30 -0
- package/lib/pluginState/{ContentModelPluginState.js → DOMEventPluginState.js} +1 -1
- package/lib/pluginState/DOMEventPluginState.js.map +1 -0
- package/lib/pluginState/EntityPluginState.d.ts +26 -0
- package/lib/pluginState/EntityPluginState.js +3 -0
- package/lib/pluginState/EntityPluginState.js.map +1 -0
- package/lib/pluginState/LifecyclePluginState.d.ts +18 -0
- package/lib/pluginState/LifecyclePluginState.js +3 -0
- package/lib/pluginState/LifecyclePluginState.js.map +1 -0
- package/lib/pluginState/SelectionPluginState.d.ts +30 -0
- package/lib/pluginState/SelectionPluginState.js +3 -0
- package/lib/pluginState/SelectionPluginState.js.map +1 -0
- package/lib/pluginState/StandaloneEditorPluginState.d.ts +49 -0
- package/lib/pluginState/StandaloneEditorPluginState.js +3 -0
- package/lib/pluginState/StandaloneEditorPluginState.js.map +1 -0
- package/lib-amd/editor/StandaloneEditorCore.d.ts +345 -16
- package/lib-amd/editor/StandaloneEditorCore.js.map +1 -1
- package/lib-amd/editor/StandaloneEditorCorePlugins.d.ts +40 -0
- package/lib-amd/editor/StandaloneEditorCorePlugins.js +5 -0
- package/lib-amd/editor/StandaloneEditorCorePlugins.js.map +1 -0
- package/lib-amd/editor/StandaloneEditorOptions.d.ts +59 -0
- package/lib-amd/editor/StandaloneEditorOptions.js.map +1 -1
- package/lib-amd/enum/EntityOperation.d.ts +5 -1
- package/lib-amd/enum/EntityOperation.js.map +1 -1
- package/lib-amd/event/ContentModelContentChangedEvent.d.ts +25 -2
- package/lib-amd/event/ContentModelContentChangedEvent.js.map +1 -1
- package/lib-amd/format/metadata/ListMetadataFormat.d.ts +4 -146
- package/lib-amd/format/metadata/ListMetadataFormat.js +0 -145
- package/lib-amd/format/metadata/ListMetadataFormat.js.map +1 -1
- package/lib-amd/format/metadata/TableMetadataFormat.d.ts +2 -75
- package/lib-amd/format/metadata/TableMetadataFormat.js +0 -75
- package/lib-amd/format/metadata/TableMetadataFormat.js.map +1 -1
- package/lib-amd/index.d.ts +10 -5
- package/lib-amd/index.js +1 -5
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/parameter/EditorEnvironment.d.ts +4 -0
- package/lib-amd/parameter/EditorEnvironment.js.map +1 -1
- package/lib-amd/pluginState/DOMEventPluginState.d.ts +30 -0
- package/lib-amd/pluginState/{ContentModelPluginState.js → DOMEventPluginState.js} +1 -1
- package/lib-amd/pluginState/DOMEventPluginState.js.map +1 -0
- package/lib-amd/pluginState/EntityPluginState.d.ts +26 -0
- package/lib-amd/pluginState/EntityPluginState.js +5 -0
- package/lib-amd/pluginState/EntityPluginState.js.map +1 -0
- package/lib-amd/pluginState/LifecyclePluginState.d.ts +18 -0
- package/lib-amd/pluginState/LifecyclePluginState.js +5 -0
- package/lib-amd/pluginState/LifecyclePluginState.js.map +1 -0
- package/lib-amd/pluginState/SelectionPluginState.d.ts +30 -0
- package/lib-amd/pluginState/SelectionPluginState.js +5 -0
- package/lib-amd/pluginState/SelectionPluginState.js.map +1 -0
- package/lib-amd/pluginState/StandaloneEditorPluginState.d.ts +49 -0
- package/lib-amd/pluginState/StandaloneEditorPluginState.js +5 -0
- package/lib-amd/pluginState/StandaloneEditorPluginState.js.map +1 -0
- package/lib-mjs/editor/StandaloneEditorCore.d.ts +345 -16
- package/lib-mjs/editor/StandaloneEditorCore.js.map +1 -1
- package/lib-mjs/editor/StandaloneEditorCorePlugins.d.ts +40 -0
- package/lib-mjs/editor/StandaloneEditorCorePlugins.js +2 -0
- package/lib-mjs/editor/StandaloneEditorCorePlugins.js.map +1 -0
- package/lib-mjs/editor/StandaloneEditorOptions.d.ts +59 -0
- package/lib-mjs/editor/StandaloneEditorOptions.js.map +1 -1
- package/lib-mjs/enum/EntityOperation.d.ts +5 -1
- package/lib-mjs/enum/EntityOperation.js.map +1 -1
- package/lib-mjs/event/ContentModelContentChangedEvent.d.ts +25 -2
- package/lib-mjs/event/ContentModelContentChangedEvent.js.map +1 -1
- package/lib-mjs/format/metadata/ListMetadataFormat.d.ts +4 -146
- package/lib-mjs/format/metadata/ListMetadataFormat.js +1 -144
- package/lib-mjs/format/metadata/ListMetadataFormat.js.map +1 -1
- package/lib-mjs/format/metadata/TableMetadataFormat.d.ts +2 -75
- package/lib-mjs/format/metadata/TableMetadataFormat.js +1 -74
- package/lib-mjs/format/metadata/TableMetadataFormat.js.map +1 -1
- package/lib-mjs/index.d.ts +10 -5
- package/lib-mjs/index.js +1 -2
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/parameter/EditorEnvironment.d.ts +4 -0
- package/lib-mjs/parameter/EditorEnvironment.js.map +1 -1
- package/lib-mjs/pluginState/DOMEventPluginState.d.ts +30 -0
- package/lib-mjs/pluginState/DOMEventPluginState.js +2 -0
- package/lib-mjs/pluginState/DOMEventPluginState.js.map +1 -0
- package/lib-mjs/pluginState/EntityPluginState.d.ts +26 -0
- package/lib-mjs/pluginState/EntityPluginState.js +2 -0
- package/lib-mjs/pluginState/EntityPluginState.js.map +1 -0
- package/lib-mjs/pluginState/LifecyclePluginState.d.ts +18 -0
- package/lib-mjs/pluginState/LifecyclePluginState.js +2 -0
- package/lib-mjs/pluginState/LifecyclePluginState.js.map +1 -0
- package/lib-mjs/pluginState/SelectionPluginState.d.ts +30 -0
- package/lib-mjs/pluginState/SelectionPluginState.js +2 -0
- package/lib-mjs/pluginState/SelectionPluginState.js.map +1 -0
- package/lib-mjs/pluginState/StandaloneEditorPluginState.d.ts +49 -0
- package/lib-mjs/pluginState/StandaloneEditorPluginState.js +2 -0
- package/lib-mjs/pluginState/StandaloneEditorPluginState.js.map +1 -0
- package/package.json +1 -1
- package/lib/pluginState/ContentModelPluginState.d.ts +0 -21
- package/lib/pluginState/ContentModelPluginState.js.map +0 -1
- package/lib-amd/pluginState/ContentModelPluginState.d.ts +0 -21
- package/lib-amd/pluginState/ContentModelPluginState.js.map +0 -1
- package/lib-mjs/pluginState/ContentModelPluginState.d.ts +0 -21
- package/lib-mjs/pluginState/ContentModelPluginState.js +0 -2
- package/lib-mjs/pluginState/ContentModelPluginState.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
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';
|
|
2
3
|
import type { ContentModelDocument } from '../group/ContentModelDocument';
|
|
3
|
-
import type {
|
|
4
|
+
import type { StandaloneEditorCorePluginState, UnportedCorePluginState } from '../pluginState/StandaloneEditorPluginState';
|
|
4
5
|
import type { DOMSelection } from '../selection/DOMSelection';
|
|
5
6
|
import type { DomToModelOption } from '../context/DomToModelOption';
|
|
6
7
|
import type { DomToModelSettings } from '../context/DomToModelSettings';
|
|
@@ -13,19 +14,19 @@ import type { ContentModelFormatter, FormatWithContentModelOptions } from '../pa
|
|
|
13
14
|
* Create a EditorContext object used by ContentModel API
|
|
14
15
|
* @param core The StandaloneEditorCore object
|
|
15
16
|
*/
|
|
16
|
-
export declare type CreateEditorContext = (core: StandaloneEditorCore
|
|
17
|
+
export declare type CreateEditorContext = (core: StandaloneEditorCore) => EditorContext;
|
|
17
18
|
/**
|
|
18
19
|
* Create Content Model from DOM tree in this editor
|
|
19
20
|
* @param core The StandaloneEditorCore object
|
|
20
21
|
* @param option The option to customize the behavior of DOM to Content Model conversion
|
|
21
22
|
* @param selectionOverride When passed, use this selection range instead of current selection in editor
|
|
22
23
|
*/
|
|
23
|
-
export declare type CreateContentModel = (core: StandaloneEditorCore
|
|
24
|
+
export declare type CreateContentModel = (core: StandaloneEditorCore, option?: DomToModelOption, selectionOverride?: DOMSelection) => ContentModelDocument;
|
|
24
25
|
/**
|
|
25
26
|
* Get current DOM selection from editor
|
|
26
27
|
* @param core The StandaloneEditorCore object
|
|
27
28
|
*/
|
|
28
|
-
export declare type GetDOMSelection = (core: StandaloneEditorCore
|
|
29
|
+
export declare type GetDOMSelection = (core: StandaloneEditorCore) => DOMSelection | null;
|
|
29
30
|
/**
|
|
30
31
|
* Set content with content model. This is the replacement of core API getSelectionRangeEx
|
|
31
32
|
* @param core The StandaloneEditorCore object
|
|
@@ -33,13 +34,13 @@ export declare type GetDOMSelection = (core: StandaloneEditorCore & EditorCore)
|
|
|
33
34
|
* @param option Additional options to customize the behavior of Content Model to DOM conversion
|
|
34
35
|
* @param onNodeCreated An optional callback that will be called when a DOM node is created
|
|
35
36
|
*/
|
|
36
|
-
export declare type SetContentModel = (core: StandaloneEditorCore
|
|
37
|
+
export declare type SetContentModel = (core: StandaloneEditorCore, model: ContentModelDocument, option?: ModelToDomOption, onNodeCreated?: OnNodeCreated) => DOMSelection | null;
|
|
37
38
|
/**
|
|
38
39
|
* Set current DOM selection from editor. This is the replacement of core API select
|
|
39
40
|
* @param core The StandaloneEditorCore object
|
|
40
41
|
* @param selection The selection to set
|
|
41
42
|
*/
|
|
42
|
-
export declare type SetDOMSelection = (core: StandaloneEditorCore
|
|
43
|
+
export declare type SetDOMSelection = (core: StandaloneEditorCore, selection: DOMSelection) => void;
|
|
43
44
|
/**
|
|
44
45
|
* The general API to do format change with Content Model
|
|
45
46
|
* It will grab a Content Model for current editor content, and invoke a callback function
|
|
@@ -49,12 +50,159 @@ export declare type SetDOMSelection = (core: StandaloneEditorCore & EditorCore,
|
|
|
49
50
|
* @param formatter Formatter function, see ContentModelFormatter
|
|
50
51
|
* @param options More options, see FormatWithContentModelOptions
|
|
51
52
|
*/
|
|
52
|
-
export declare type FormatContentModel = (core: StandaloneEditorCore
|
|
53
|
+
export declare type FormatContentModel = (core: StandaloneEditorCore, formatter: ContentModelFormatter, options?: FormatWithContentModelOptions) => void;
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* Switch the Shadow Edit mode of editor On/Off
|
|
56
|
+
* @param core The StandaloneEditorCore object
|
|
57
|
+
* @param isOn True to switch On, False to switch Off
|
|
58
|
+
*/
|
|
59
|
+
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
|
+
/**
|
|
72
|
+
* Trigger a plugin event
|
|
73
|
+
* @param core The StandaloneEditorCore object
|
|
74
|
+
* @param pluginEvent The event object to trigger
|
|
75
|
+
* @param broadcast Set to true to skip the shouldHandleEventExclusively check
|
|
76
|
+
*/
|
|
77
|
+
export declare type TriggerEvent = (core: StandaloneEditorCore, pluginEvent: PluginEvent, broadcast: boolean) => void;
|
|
78
|
+
/**
|
|
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
|
|
86
|
+
* @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
|
+
* @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.
|
|
104
|
+
*/
|
|
105
|
+
export declare type AddUndoSnapshot = (core: StandaloneEditorCore, callback: ((start: NodePosition | null, end: NodePosition | null) => any) | null, changeSource: string | null, canUndoByBackspace: boolean, additionalData?: ContentChangedData) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves the rect of the visible viewport of the editor.
|
|
108
|
+
* @param core The StandaloneEditorCore object
|
|
109
|
+
*/
|
|
110
|
+
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
|
+
/**
|
|
137
|
+
* Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
|
|
138
|
+
* if triggerContentChangedEvent is set to true
|
|
139
|
+
* @param core The StandaloneEditorCore object
|
|
140
|
+
* @param content HTML content to set in
|
|
141
|
+
* @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
|
|
142
|
+
*/
|
|
143
|
+
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
|
+
/**
|
|
152
|
+
* Check if the editor has focus now
|
|
153
|
+
* @param core The StandaloneEditorCore object
|
|
154
|
+
* @returns True if the editor has focus, otherwise false
|
|
155
|
+
*/
|
|
156
|
+
export declare type HasFocus = (core: StandaloneEditorCore) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Focus to editor. If there is a cached selection range, use it as current selection
|
|
159
|
+
* @param core The StandaloneEditorCore object
|
|
160
|
+
*/
|
|
161
|
+
export declare type Focus = (core: StandaloneEditorCore) => void;
|
|
162
|
+
/**
|
|
163
|
+
* Insert a DOM node into editor content
|
|
164
|
+
* @param core The StandaloneEditorCore object. No op if null.
|
|
165
|
+
* @param option An insert option object to specify how to insert the node
|
|
166
|
+
*/
|
|
167
|
+
export declare type InsertNode = (core: StandaloneEditorCore, node: Node, option: InsertOption | null) => boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Attach a DOM event to the editor content DIV
|
|
170
|
+
* @param core The StandaloneEditorCore object
|
|
171
|
+
* @param eventMap A map from event name to its handler
|
|
172
|
+
*/
|
|
173
|
+
export declare type AttachDomEvent = (core: StandaloneEditorCore, eventMap: Record<string, DOMEventHandler>) => () => void;
|
|
174
|
+
/**
|
|
175
|
+
* Get current editor content as HTML string
|
|
176
|
+
* @param core The StandaloneEditorCore object
|
|
177
|
+
* @param mode specify what kind of HTML content to retrieve
|
|
178
|
+
* @returns HTML string representing current editor content
|
|
179
|
+
*/
|
|
180
|
+
export declare type GetContent = (core: StandaloneEditorCore, mode: GetContentMode | CompatibleGetContentMode) => string;
|
|
181
|
+
/**
|
|
182
|
+
* Get style based format state from current selection, including font name/size and colors
|
|
183
|
+
* @param core The StandaloneEditorCore objects
|
|
184
|
+
* @param node The node to get style from
|
|
56
185
|
*/
|
|
57
|
-
export
|
|
186
|
+
export declare type GetStyleBasedFormatState = (core: StandaloneEditorCore, node: Node | null) => StyleBasedFormatState;
|
|
187
|
+
/**
|
|
188
|
+
* Restore an undo snapshot into editor
|
|
189
|
+
* @param core The StandaloneEditorCore object
|
|
190
|
+
* @param step Steps to move, can be 0, positive or negative
|
|
191
|
+
*/
|
|
192
|
+
export declare type RestoreUndoSnapshot = (core: StandaloneEditorCore, step: number) => void;
|
|
193
|
+
/**
|
|
194
|
+
* Ensure user will type into a container element rather than into the editor content DIV directly
|
|
195
|
+
* @param core The StandaloneEditorCore object.
|
|
196
|
+
* @param position The position that user is about to type to
|
|
197
|
+
* @param keyboardEvent Optional keyboard event object
|
|
198
|
+
* @param deprecated Deprecated parameter, not used
|
|
199
|
+
*/
|
|
200
|
+
export declare type EnsureTypeInContainer = (core: StandaloneEditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, deprecated?: boolean) => void;
|
|
201
|
+
/**
|
|
202
|
+
* Temp interface
|
|
203
|
+
* TODO: Port other core API
|
|
204
|
+
*/
|
|
205
|
+
export interface PortedCoreApiMap {
|
|
58
206
|
/**
|
|
59
207
|
* Create a EditorContext object used by ContentModel API
|
|
60
208
|
* @param core The StandaloneEditorCore object
|
|
@@ -94,12 +242,173 @@ export interface StandaloneCoreApiMap {
|
|
|
94
242
|
* @param options More options, see FormatWithContentModelOptions
|
|
95
243
|
*/
|
|
96
244
|
formatContentModel: FormatContentModel;
|
|
245
|
+
/**
|
|
246
|
+
* Switch the Shadow Edit mode of editor On/Off
|
|
247
|
+
* @param core The StandaloneEditorCore object
|
|
248
|
+
* @param isOn True to switch On, False to switch Off
|
|
249
|
+
*/
|
|
97
250
|
switchShadowEdit: SwitchShadowEdit;
|
|
251
|
+
/**
|
|
252
|
+
* Retrieves the rect of the visible viewport of the editor.
|
|
253
|
+
* @param core The StandaloneEditorCore object
|
|
254
|
+
*/
|
|
255
|
+
getVisibleViewport: GetVisibleViewport;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Temp interface
|
|
259
|
+
* TODO: Port these core API
|
|
260
|
+
*/
|
|
261
|
+
export interface UnportedCoreApiMap {
|
|
262
|
+
/**
|
|
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
|
|
281
|
+
* @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
|
|
284
|
+
*/
|
|
285
|
+
getSelectionRangeEx: GetSelectionRangeEx;
|
|
286
|
+
/**
|
|
287
|
+
* Edit and transform color of elements between light mode and dark mode
|
|
288
|
+
* @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
|
+
*/
|
|
297
|
+
transformColor: TransformColor;
|
|
298
|
+
/**
|
|
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.
|
|
301
|
+
* @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).
|
|
305
|
+
*/
|
|
306
|
+
addUndoSnapshot: AddUndoSnapshot;
|
|
307
|
+
/**
|
|
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.
|
|
314
|
+
*/
|
|
315
|
+
selectRange: SelectRange;
|
|
316
|
+
/**
|
|
317
|
+
* Select a image and save data of the selected range
|
|
318
|
+
* @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
|
|
322
|
+
*/
|
|
323
|
+
selectImage: SelectImage;
|
|
324
|
+
/**
|
|
325
|
+
* Select a table and save data of the selected range
|
|
326
|
+
* @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
|
|
332
|
+
*/
|
|
333
|
+
selectTable: SelectTable;
|
|
334
|
+
/**
|
|
335
|
+
* Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
|
|
336
|
+
* if triggerContentChangedEvent is set to true
|
|
337
|
+
* @param core The StandaloneEditorCore object
|
|
338
|
+
* @param content HTML content to set in
|
|
339
|
+
* @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
|
|
340
|
+
*/
|
|
341
|
+
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
|
+
/**
|
|
361
|
+
* Insert a DOM node into editor content
|
|
362
|
+
* @param core The StandaloneEditorCore object. No op if null.
|
|
363
|
+
* @param option An insert option object to specify how to insert the node
|
|
364
|
+
*/
|
|
365
|
+
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
|
+
/**
|
|
375
|
+
* Get current editor content as HTML string
|
|
376
|
+
* @param core The StandaloneEditorCore object
|
|
377
|
+
* @param mode specify what kind of HTML content to retrieve
|
|
378
|
+
* @returns HTML string representing current editor content
|
|
379
|
+
*/
|
|
380
|
+
getContent: GetContent;
|
|
381
|
+
/**
|
|
382
|
+
* Get style based format state from current selection, including font name/size and colors
|
|
383
|
+
* @param core The StandaloneEditorCore objects
|
|
384
|
+
* @param node The node to get style from
|
|
385
|
+
*/
|
|
386
|
+
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
|
+
/**
|
|
394
|
+
* Ensure user will type into a container element rather than into the editor content DIV directly
|
|
395
|
+
* @param core The EditorCore object.
|
|
396
|
+
* @param position The position that user is about to type to
|
|
397
|
+
* @param keyboardEvent Optional keyboard event object
|
|
398
|
+
* @param deprecated Deprecated parameter, not used
|
|
399
|
+
*/
|
|
400
|
+
ensureTypeInContainer: EnsureTypeInContainer;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The interface for the map of core API for Content Model editor.
|
|
404
|
+
* Editor can call call API from this map under StandaloneEditorCore object
|
|
405
|
+
*/
|
|
406
|
+
export interface StandaloneCoreApiMap extends PortedCoreApiMap, UnportedCoreApiMap {
|
|
98
407
|
}
|
|
99
408
|
/**
|
|
100
409
|
* Represents the core data structure of a Content Model editor
|
|
101
410
|
*/
|
|
102
|
-
export interface StandaloneEditorCore extends
|
|
411
|
+
export interface StandaloneEditorCore extends StandaloneEditorCorePluginState, UnportedCorePluginState, StandaloneEditorDefaultSettings {
|
|
103
412
|
/**
|
|
104
413
|
* The content DIV element of this editor
|
|
105
414
|
*/
|
|
@@ -112,6 +421,30 @@ export interface StandaloneEditorCore extends ContentModelPluginState {
|
|
|
112
421
|
* Original API map of this editor. Overridden core API can use API from this map to call the original version of core API.
|
|
113
422
|
*/
|
|
114
423
|
readonly originalApi: StandaloneCoreApiMap;
|
|
424
|
+
/**
|
|
425
|
+
* An array of editor plugins.
|
|
426
|
+
*/
|
|
427
|
+
readonly plugins: EditorPlugin[];
|
|
428
|
+
/**
|
|
429
|
+
* Editor running environment
|
|
430
|
+
*/
|
|
431
|
+
readonly environment: EditorEnvironment;
|
|
432
|
+
/**
|
|
433
|
+
* Dark model handler for the editor, used for variable-based solution.
|
|
434
|
+
* If keep it null, editor will still use original dataset-based dark mode solution.
|
|
435
|
+
*/
|
|
436
|
+
readonly darkColorHandler: DarkColorHandler;
|
|
437
|
+
/**
|
|
438
|
+
* A handler to convert HTML string to a trust HTML string.
|
|
439
|
+
* By default it will just return the original HTML string directly.
|
|
440
|
+
* To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler
|
|
441
|
+
*/
|
|
442
|
+
readonly trustedHTMLHandler: TrustedHTMLHandler;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Default DOM and Content Model conversion settings for an editor
|
|
446
|
+
*/
|
|
447
|
+
export interface StandaloneEditorDefaultSettings {
|
|
115
448
|
/**
|
|
116
449
|
* Default DOM to Content Model options
|
|
117
450
|
*/
|
|
@@ -130,8 +463,4 @@ export interface StandaloneEditorCore extends ContentModelPluginState {
|
|
|
130
463
|
* will be used for setting content model if there is no other customized options
|
|
131
464
|
*/
|
|
132
465
|
defaultModelToDomConfig: ModelToDomSettings;
|
|
133
|
-
/**
|
|
134
|
-
* Editor running environment
|
|
135
|
-
*/
|
|
136
|
-
environment: EditorEnvironment;
|
|
137
466
|
}
|
|
@@ -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 { EditorCore, SwitchShadowEdit } from 'roosterjs-editor-types';\nimport type { ContentModelDocument } from '../group/ContentModelDocument';\nimport type { ContentModelPluginState } from '../pluginState/ContentModelPluginState';\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 & EditorCore) => 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 & EditorCore,\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 & EditorCore) => 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 & EditorCore,\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 = (\n core: StandaloneEditorCore & EditorCore,\n selection: DOMSelection\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 & EditorCore,\n formatter: ContentModelFormatter,\n options?: FormatWithContentModelOptions\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 */\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 // TODO: This is copied from legacy editor core, will be ported to use new types later\n switchShadowEdit: SwitchShadowEdit;\n}\n\n/**\n * Represents the core data structure of a Content Model editor\n */\nexport interface StandaloneEditorCore extends ContentModelPluginState {\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 * 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 /**\n * Editor running environment\n */\n environment: EditorEnvironment;\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 {\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"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SelectionPluginState } from '../pluginState/SelectionPluginState';
|
|
2
|
+
import type { EntityPluginState } from '../pluginState/EntityPluginState';
|
|
3
|
+
import type { LifecyclePluginState } from '../pluginState/LifecyclePluginState';
|
|
4
|
+
import type { DOMEventPluginState } from '../pluginState/DOMEventPluginState';
|
|
5
|
+
import type { ContentModelCachePluginState } from '../pluginState/ContentModelCachePluginState';
|
|
6
|
+
import type { ContentModelFormatPluginState } from '../pluginState/ContentModelFormatPluginState';
|
|
7
|
+
import type { CopyPastePluginState, PluginWithState } from 'roosterjs-editor-types';
|
|
8
|
+
/**
|
|
9
|
+
* Core plugins for standalone editor
|
|
10
|
+
*/
|
|
11
|
+
export interface StandaloneEditorCorePlugins {
|
|
12
|
+
/**
|
|
13
|
+
* ContentModel cache plugin manages cached Content Model, and refresh the cache when necessary
|
|
14
|
+
*/
|
|
15
|
+
readonly cache: PluginWithState<ContentModelCachePluginState>;
|
|
16
|
+
/**
|
|
17
|
+
* ContentModelFormat plugins helps editor to do formatting on top of content model.
|
|
18
|
+
*/
|
|
19
|
+
readonly format: PluginWithState<ContentModelFormatPluginState>;
|
|
20
|
+
/**
|
|
21
|
+
* Copy and paste plugin for handling onCopy and onPaste event
|
|
22
|
+
*/
|
|
23
|
+
readonly copyPaste: PluginWithState<CopyPastePluginState>;
|
|
24
|
+
/**
|
|
25
|
+
* DomEvent plugin helps handle additional DOM events such as IME composition, cut, drop.
|
|
26
|
+
*/
|
|
27
|
+
readonly domEvent: PluginWithState<DOMEventPluginState>;
|
|
28
|
+
/**
|
|
29
|
+
* Selection plugin handles selection, including range selection, table selection, and image selection
|
|
30
|
+
*/
|
|
31
|
+
readonly selection: PluginWithState<SelectionPluginState>;
|
|
32
|
+
/**
|
|
33
|
+
* Entity Plugin handles all operations related to an entity and generate entity specified events
|
|
34
|
+
*/
|
|
35
|
+
readonly entity: PluginWithState<EntityPluginState>;
|
|
36
|
+
/**
|
|
37
|
+
* Lifecycle plugin handles editor initialization and disposing
|
|
38
|
+
*/
|
|
39
|
+
readonly lifecycle: PluginWithState<LifecyclePluginState>;
|
|
40
|
+
}
|
|
@@ -0,0 +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,5 +1,9 @@
|
|
|
1
|
+
import type { ContentModelSegmentFormat } from '../format/ContentModelSegmentFormat';
|
|
2
|
+
import type { StandaloneCoreApiMap } from './StandaloneEditorCore';
|
|
3
|
+
import type { EditorPlugin, TrustedHTMLHandler } from 'roosterjs-editor-types';
|
|
1
4
|
import type { DomToModelOption } from '../context/DomToModelOption';
|
|
2
5
|
import type { ModelToDomOption } from '../context/ModelToDomOption';
|
|
6
|
+
import type { ContentModelDocument } from '../group/ContentModelDocument';
|
|
3
7
|
/**
|
|
4
8
|
* Options for Content Model editor
|
|
5
9
|
*/
|
|
@@ -16,4 +20,59 @@ export interface StandaloneEditorOptions {
|
|
|
16
20
|
* Reuse existing DOM structure if possible, and update the model when content or selection is changed
|
|
17
21
|
*/
|
|
18
22
|
cacheModel?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* List of plugins.
|
|
25
|
+
* The order of plugins here determines in what order each event will be dispatched.
|
|
26
|
+
* Plugins not appear in this list will not be added to editor, including built-in plugins.
|
|
27
|
+
* Default value is empty array.
|
|
28
|
+
*/
|
|
29
|
+
plugins?: EditorPlugin[];
|
|
30
|
+
/**
|
|
31
|
+
* Default format of editor content. This will be applied to empty content.
|
|
32
|
+
* If there is already content inside editor, format of existing content will not be changed.
|
|
33
|
+
* Default value is the computed style of editor content DIV
|
|
34
|
+
*/
|
|
35
|
+
defaultSegmentFormat?: ContentModelSegmentFormat;
|
|
36
|
+
/**
|
|
37
|
+
* Allowed custom content type when paste besides text/plain, text/html and images
|
|
38
|
+
* Only text types are supported, and do not add "text/" prefix to the type values
|
|
39
|
+
*/
|
|
40
|
+
allowedCustomPasteType?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* The scroll container to get scroll event from.
|
|
43
|
+
* By default, the scroll container will be the same with editor content DIV
|
|
44
|
+
*/
|
|
45
|
+
scrollContainer?: HTMLElement;
|
|
46
|
+
/**
|
|
47
|
+
* Base dark mode color. We will use this color to calculate the dark mode color from a given light mode color
|
|
48
|
+
* @default #333333
|
|
49
|
+
*/
|
|
50
|
+
baseDarkColor?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Customized trusted type handler used for sanitizing HTML string before assign to DOM tree
|
|
53
|
+
* This is required when trusted-type Content-Security-Policy (CSP) is enabled.
|
|
54
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
55
|
+
*/
|
|
56
|
+
trustedHTMLHandler?: TrustedHTMLHandler;
|
|
57
|
+
/**
|
|
58
|
+
* A function map to override default core API implementation
|
|
59
|
+
* Default value is null
|
|
60
|
+
*/
|
|
61
|
+
coreApiOverride?: Partial<StandaloneCoreApiMap>;
|
|
62
|
+
/**
|
|
63
|
+
* Color of the border of a selectedImage. Default color: '#DB626C'
|
|
64
|
+
*/
|
|
65
|
+
imageSelectionBorderColor?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Initial Content Model
|
|
68
|
+
*/
|
|
69
|
+
initialModel?: ContentModelDocument;
|
|
70
|
+
/**
|
|
71
|
+
* Whether to skip the adjust editor process when for light/dark mode
|
|
72
|
+
*/
|
|
73
|
+
doNotAdjustEditorColor?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* If the editor is currently in dark mode
|
|
76
|
+
*/
|
|
77
|
+
inDarkMode?: boolean;
|
|
19
78
|
}
|
|
@@ -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 { DomToModelOption } from '../context/DomToModelOption';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\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"]}
|
|
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 * Base dark mode color. We will use this color to calculate the dark mode color from a given light mode color\n * @default #333333\n */\n baseDarkColor?: 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"]}
|