roosterjs-editor-adapter 0.26.2 → 0.26.3
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/EditorAdapter.js +1 -1
- package/lib/editor/EditorAdapter.js.map +1 -1
- package/lib-amd/editor/EditorAdapter.js +1 -1
- package/lib-amd/editor/EditorAdapter.js.map +1 -1
- package/lib-mjs/editor/EditorAdapter.js +1 -1
- package/lib-mjs/editor/EditorAdapter.js.map +1 -1
- package/package.json +4 -4
|
@@ -50,6 +50,7 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
50
50
|
* Dispose this editor, dispose all plugins and custom data
|
|
51
51
|
*/
|
|
52
52
|
EditorAdapter.prototype.dispose = function () {
|
|
53
|
+
_super.prototype.dispose.call(this);
|
|
53
54
|
var core = this.contentModelEditorCore;
|
|
54
55
|
if (core) {
|
|
55
56
|
(0, roosterjs_content_model_dom_1.getObjectKeys)(core.customData).forEach(function (key) {
|
|
@@ -61,7 +62,6 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
61
62
|
});
|
|
62
63
|
this.contentModelEditorCore = undefined;
|
|
63
64
|
}
|
|
64
|
-
_super.prototype.dispose.call(this);
|
|
65
65
|
};
|
|
66
66
|
/**
|
|
67
67
|
* Get whether this editor is disposed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorAdapter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/editor/EditorAdapter.ts"],"names":[],"mappings":";;;;;AAAA,4DAA2D;AAC3D,qDAAoD;AACpD,2EAA4D;AAC5D,iDAAgD;AAEhD,yDAIgC;AAChC,6EASsC;AAuCtC,iEAGoC;AAWpC,6DAiB8B;AAU9B,IAAM,iBAAiB;IACnB,wBAA4B,MAAM;IAClC,wBAA4B,WAAW;IACvC,4BAAgC,eAAe;IAC/C,0BAA8B,MAAM;IACpC,mCAAuC,MAAM;OAChD,CAAC;AAEF;;;GAGG;AACH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;OAGG;IACH,+BAAO,GAAP;QACI,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3C,CAAC;IAEO,2CAAmB,GAA3B;QACI,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,IAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,IAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAElD,IAAA,uDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,iDAAyB,GAAjC;QACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QAED,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IACL,oBAAC;AAAD,CAAC,AA9/BD,CAAmC,+CAAgB,GA8/BlD;AA9/BY,sCAAa","sourcesContent":["import { BridgePlugin } from '../corePlugins/BridgePlugin';\nimport { buildRangeEx } from './utils/buildRangeEx';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { insertNode } from './utils/insertNode';\nimport type { EditorAdapterCore } from '../corePlugins/BridgePlugin';\nimport {\n newEventToOldEvent,\n oldEventToNewEvent,\n OldEventTypeToNewEventType,\n} from './utils/eventConverter';\nimport {\n createModelFromHtml,\n exportContent,\n isBold,\n redo,\n retrieveModelFormatState,\n StandaloneEditor,\n transformColor,\n undo,\n} from 'roosterjs-content-model-core';\nimport {\n ChangeSource,\n ColorTransformDirection,\n ContentPosition,\n GetContentMode,\n PluginEventType,\n QueryScope,\n RegionType,\n} from 'roosterjs-editor-types';\nimport type {\n BlockElement,\n ClipboardData,\n ContentChangedData,\n ContentChangedEvent,\n DOMEventHandler,\n DefaultFormat,\n EditorUndoState,\n ExperimentalFeatures,\n GenericContentEditFeature,\n IContentTraverser,\n IPositionContentSearcher,\n InsertOption,\n NodePosition,\n PendableFormatState,\n PluginEvent,\n PluginEventData,\n PluginEventFromType,\n PositionType,\n Region,\n SelectionPath,\n SelectionRangeEx,\n SizeTransformer,\n StyleBasedFormatState,\n TableSelection,\n DOMEventHandlerObject,\n DarkColorHandler,\n IEditor,\n} from 'roosterjs-editor-types';\nimport {\n convertDomSelectionToRangeEx,\n convertRangeExToDomSelection,\n} from './utils/selectionConverter';\nimport type {\n CompatibleChangeSource,\n CompatibleColorTransformDirection,\n CompatibleContentPosition,\n CompatibleExperimentalFeatures,\n CompatibleGetContentMode,\n CompatiblePluginEventType,\n CompatibleQueryScope,\n CompatibleRegionType,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport {\n ContentTraverser,\n Position,\n PositionContentSearcher,\n cacheGetEventData,\n collapseNodes,\n contains,\n deleteSelectedContent,\n findClosestElementAncestor,\n getBlockElementAtNode,\n getRegionsFromRange,\n getSelectionPath,\n isNodeEmpty,\n isPositionAtBeginningOf,\n queryElements,\n toArray,\n wrap,\n} from 'roosterjs-editor-dom';\nimport type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';\nimport type {\n ContentModelFormatState,\n DOMEventRecord,\n ExportContentMode,\n IStandaloneEditor,\n StandaloneEditorOptions,\n} from 'roosterjs-content-model-types';\n\nconst GetContentModeMap: Record<GetContentMode, ExportContentMode> = {\n [GetContentMode.CleanHTML]: 'HTML',\n [GetContentMode.PlainText]: 'PlainText',\n [GetContentMode.PlainTextFast]: 'PlainTextFast',\n [GetContentMode.RawHTMLOnly]: 'HTML',\n [GetContentMode.RawHTMLWithSelection]: 'HTML',\n};\n\n/**\n * Editor for Content Model.\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class EditorAdapter extends StandaloneEditor implements IEditor {\n private contentModelEditorCore: EditorAdapterCore | undefined;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorAdapterOptions = {}) {\n const bridgePlugin = new BridgePlugin(\n core => {\n this.contentModelEditorCore = core;\n\n return this;\n },\n options.legacyPlugins,\n options.experimentalFeatures\n );\n\n const plugins = [bridgePlugin, ...(options.plugins ?? [])];\n const initContent = options.initialContent ?? contentDiv.innerHTML;\n const initialModel =\n initContent && !options.initialModel\n ? createModelFromHtml(\n initContent,\n options.defaultDomToModelOptions,\n options.trustedHTMLHandler,\n options.defaultSegmentFormat\n )\n : options.initialModel;\n const standaloneEditorOptions: StandaloneEditorOptions = {\n ...options,\n plugins,\n initialModel,\n };\n\n super(contentDiv, standaloneEditorOptions);\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void {\n const core = this.contentModelEditorCore;\n\n if (core) {\n getObjectKeys(core.customData).forEach(key => {\n const data = core.customData[key];\n\n if (data && data.disposer) {\n data.disposer(data.value);\n }\n\n delete core.customData[key];\n });\n\n this.contentModelEditorCore = undefined;\n }\n\n super.dispose();\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return super.isDisposed() || !this.contentModelEditorCore;\n }\n\n /**\n * Insert node into editor\n * @param node The node to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n * @returns true if node is inserted. Otherwise false\n */\n insertNode(node: Node, option?: InsertOption): boolean {\n if (node) {\n option = option || {\n position: ContentPosition.SelectionStart,\n insertOnNewLine: false,\n updateCursor: true,\n replaceSelection: true,\n insertToRegionRoot: false,\n };\n\n const { contentDiv } = this.getCore();\n\n if (option.updateCursor) {\n this.focus();\n }\n\n if (option.position == ContentPosition.Outside) {\n contentDiv.parentNode?.insertBefore(node, contentDiv.nextSibling);\n } else {\n if (this.isDarkMode()) {\n transformColor(\n node,\n true /*includeSelf*/,\n 'lightToDark',\n this.getColorManager()\n );\n }\n\n const selection = insertNode(contentDiv, this.getDOMSelection(), node, option);\n\n if (selection && option.updateCursor) {\n this.setDOMSelection(selection);\n }\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Delete a node from editor content\n * @param node The node to delete\n * @returns true if node is deleted. Otherwise false\n */\n deleteNode(node: Node): boolean {\n // Only remove the node when it falls within editor\n if (node && this.contains(node) && node.parentNode) {\n node.parentNode.removeChild(node);\n return true;\n }\n\n return false;\n }\n\n /**\n * Replace a node in editor content with another node\n * @param existingNode The existing node to be replaced\n * @param toNode node to replace to\n * @param transformColorForDarkMode (optional) Whether to transform new node to dark mode. Default is false\n * @returns true if node is replaced. Otherwise false\n */\n replaceNode(existingNode: Node, toNode: Node, transformColorForDarkMode?: boolean): boolean {\n const core = this.getCore();\n // Only replace the node when it falls within editor\n if (this.contains(existingNode) && toNode) {\n if (core.lifecycle.isDarkMode && transformColorForDarkMode) {\n this.transformToDarkColor(toNode, ColorTransformDirection.LightToDark);\n }\n\n existingNode.parentNode?.replaceChild(toNode, existingNode);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Get BlockElement at given node\n * @param node The node to create InlineElement\n * @returns The BlockElement result\n */\n getBlockElementAtNode(node: Node): BlockElement | null {\n return getBlockElementAtNode(this.getCore().contentDiv, node);\n }\n\n contains(arg: Node | Range | null): boolean {\n if (!arg) {\n return false;\n }\n return contains(this.getCore().contentDiv, <Node>arg);\n }\n\n queryElements(\n selector: string,\n scopeOrCallback:\n | QueryScope\n | CompatibleQueryScope\n | ((node: Node) => any) = QueryScope.Body,\n callback?: (node: Node) => any\n ) {\n const core = this.getCore();\n const result: HTMLElement[] = [];\n const scope = scopeOrCallback instanceof Function ? QueryScope.Body : scopeOrCallback;\n callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;\n\n const selectionEx = scope == QueryScope.Body ? null : this.getSelectionRangeEx();\n if (selectionEx) {\n selectionEx.ranges.forEach(range => {\n result.push(...queryElements(core.contentDiv, selector, callback, scope, range));\n });\n } else {\n return queryElements(core.contentDiv, selector, callback, scope, undefined /* range */);\n }\n\n return result;\n }\n\n /**\n * Collapse nodes within the given start and end nodes to their common ancestor node,\n * split parent nodes if necessary\n * @param start The start node\n * @param end The end node\n * @param canSplitParent True to allow split parent node there are nodes before start or after end under the same parent\n * and the returned nodes will be all nodes from start through end after splitting\n * False to disallow split parent\n * @returns When canSplitParent is true, returns all node from start through end after splitting,\n * otherwise just return start and end\n */\n collapseNodes(start: Node, end: Node, canSplitParent: boolean): Node[] {\n return collapseNodes(this.getCore().contentDiv, start, end, canSplitParent);\n }\n\n //#endregion\n\n //#region Content API\n\n /**\n * Check whether the editor contains any visible content\n * @param trim Whether trim the content string before check. Default is false\n * @returns True if there's no visible content, otherwise false\n */\n isEmpty(trim?: boolean): boolean {\n return isNodeEmpty(this.getCore().contentDiv, trim);\n }\n\n /**\n * Get current editor content as HTML string\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent(mode: GetContentMode | CompatibleGetContentMode = GetContentMode.CleanHTML): string {\n return exportContent(\n this,\n GetContentModeMap[mode],\n this.getCore().modelToDomSettings.customized\n );\n }\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent(content: string, triggerContentChangedEvent: boolean = true) {\n const core = this.getCore();\n const { contentDiv, api, trustedHTMLHandler, lifecycle, darkColorHandler } = core;\n\n api.triggerEvent(\n core,\n {\n eventType: 'beforeSetContent',\n newContent: content,\n },\n true /*broadcast*/\n );\n\n const newModel = createModelFromHtml(\n content,\n core.domToModelSettings.customized,\n trustedHTMLHandler,\n core.format.defaultFormat\n );\n\n api.setContentModel(core, newModel);\n\n if (triggerContentChangedEvent) {\n api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: ChangeSource.SetContent,\n },\n false /*broadcast*/\n );\n } else if (lifecycle.isDarkMode) {\n transformColor(contentDiv, false /*includeSelf*/, 'lightToDark', darkColorHandler);\n }\n }\n\n /**\n * Insert HTML content into editor\n * @param HTML content to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n */\n insertContent(content: string, option?: InsertOption) {\n if (content) {\n const doc = this.getDocument();\n const body = new DOMParser().parseFromString(\n this.getCore().trustedHTMLHandler(content),\n 'text/html'\n )?.body;\n let allNodes = body?.childNodes ? toArray(body.childNodes) : [];\n\n // If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with\n // a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped\n // separately to show up on its own line\n if (option && option.insertOnNewLine && allNodes.length > 1) {\n allNodes = [wrap(allNodes)];\n }\n\n const fragment = doc.createDocumentFragment();\n allNodes.forEach(node => fragment.appendChild(node));\n\n this.insertNode(fragment, option);\n }\n }\n\n /**\n * Delete selected content\n */\n deleteSelectedContent(): NodePosition | null {\n const range = this.getSelectionRange();\n if (range && !range.collapsed) {\n return deleteSelectedContent(this.getCore().contentDiv, range);\n }\n return null;\n }\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteAsText Force pasting as plain text. Default value is false\n * @param applyCurrentStyle True if apply format of current selection to the pasted content,\n * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored\n * @param pasteAsImage: When set to true, if the clipboardData contains a imageDataUri will paste the image to the editor\n */\n paste(\n clipboardData: ClipboardData,\n pasteAsText: boolean = false,\n applyCurrentFormat: boolean = false,\n pasteAsImage: boolean = false\n ) {\n this.pasteFromClipboard(\n clipboardData,\n pasteAsText\n ? 'asPlainText'\n : applyCurrentFormat\n ? 'mergeFormat'\n : pasteAsImage\n ? 'asImage'\n : 'normal'\n );\n }\n\n //#endregion\n\n //#region Focus and Selection\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRange(tryGetFromCache: boolean = true): Range | null {\n const selection = this.getDOMSelection();\n\n return selection?.type == 'range' ? selection.range : null;\n }\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRangeEx(): SelectionRangeEx {\n const selection = this.getDOMSelection();\n\n return convertDomSelectionToRangeEx(selection);\n }\n\n /**\n * Get current selection in a serializable format\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @returns current selection path, or null if editor never got focus before\n */\n getSelectionPath(): SelectionPath | null {\n const range = this.getSelectionRange();\n return range && getSelectionPath(this.getCore().contentDiv, range);\n }\n\n select(\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 const core = this.getCore();\n const rangeEx = buildRangeEx(core.contentDiv, arg1, arg2, arg3, arg4);\n const selection = convertRangeExToDomSelection(rangeEx);\n\n this.setDOMSelection(selection);\n return true;\n }\n\n /**\n * Get current focused position. Return null if editor doesn't have focus at this time.\n */\n getFocusedPosition(): NodePosition | null {\n const sel = this.getDocument().defaultView?.getSelection();\n if (sel?.focusNode && this.contains(sel.focusNode)) {\n return new Position(sel.focusNode, sel.focusOffset);\n }\n\n const range = this.getSelectionRange();\n if (range) {\n return Position.getStart(range);\n }\n\n return null;\n }\n\n /**\n * Get an HTML element from current cursor position.\n * When expectedTags is not specified, return value is the current node (if it is HTML element)\n * or its parent node (if current node is a Text node).\n * When expectedTags is specified, return value is the first ancestor of current node which has\n * one of the expected tags.\n * If no element found within editor by the given tag, return null.\n * @param selector Optional, an HTML selector to find HTML element with.\n * @param startFrom Start search from this node. If not specified, start from current focused position\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n */\n getElementAtCursor(\n selector?: string,\n startFrom?: Node,\n event?: PluginEvent\n ): HTMLElement | null {\n event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result\n\n return (\n cacheGetEventData(event ?? null, 'GET_ELEMENT_AT_CURSOR_' + selector, () => {\n if (!startFrom) {\n const position = this.getFocusedPosition();\n startFrom = position?.node;\n }\n return (\n startFrom &&\n findClosestElementAncestor(startFrom, this.getCore().contentDiv, selector)\n );\n }) ?? null\n );\n }\n\n /**\n * Check if this position is at beginning of the editor.\n * This will return true if all nodes between the beginning of target node and the position are empty.\n * @param position The position to check\n * @returns True if position is at beginning of the editor, otherwise false\n */\n isPositionAtBeginning(position: NodePosition): boolean {\n return isPositionAtBeginningOf(position, this.getCore().contentDiv);\n }\n\n /**\n * Get impacted regions from selection\n */\n getSelectedRegions(type: RegionType | CompatibleRegionType = RegionType.Table): Region[] {\n const selection = this.getSelectionRangeEx();\n const result: Region[] = [];\n const contentDiv = this.getCore().contentDiv;\n selection.ranges.forEach(range => {\n result.push(...(range ? getRegionsFromRange(contentDiv, range, type) : []));\n });\n return result.filter((value, index, self) => {\n return self.indexOf(value) === index;\n });\n }\n\n //#endregion\n\n //#region EVENT API\n\n addDomEventHandler(\n nameOrMap: string | Record<string, DOMEventHandler>,\n handler?: DOMEventHandler\n ): () => void {\n const eventsMap = typeof nameOrMap == 'string' ? { [nameOrMap]: handler! } : nameOrMap;\n const eventsMapResult: Record<string, DOMEventRecord> = {};\n\n getObjectKeys(eventsMap).forEach(key => {\n const handlerObj = eventsMap[key];\n let result: DOMEventRecord = {\n pluginEventType: null,\n beforeDispatch: null,\n };\n\n if (typeof handlerObj === 'number') {\n result.pluginEventType = OldEventTypeToNewEventType[handlerObj as PluginEventType];\n } else if (typeof handlerObj === 'function') {\n result.beforeDispatch = handlerObj;\n } else if (typeof handlerObj === 'object') {\n const record = handlerObj as DOMEventHandlerObject;\n result = {\n beforeDispatch: record.beforeDispatch,\n pluginEventType:\n typeof record.pluginEventType == 'number'\n ? OldEventTypeToNewEventType[record.pluginEventType]\n : undefined,\n };\n }\n\n eventsMapResult[key] = result;\n });\n\n return this.attachDomEvent(eventsMapResult);\n }\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 public triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const oldEvent = {\n eventType,\n ...data,\n } as PluginEvent;\n const newEvent = oldEventToNewEvent(oldEvent);\n const core = this.getCore();\n\n if (newEvent) {\n core.api.triggerEvent(core, newEvent, broadcast);\n return (newEventToOldEvent(newEvent, oldEvent) ?? oldEvent) as PluginEventFromType<T>;\n } else {\n return oldEvent as PluginEventFromType<T>;\n }\n }\n\n /**\n * Trigger a ContentChangedEvent\n * @param source Source of this event, by default is 'SetContent'\n * @param data additional data for this event\n */\n triggerContentChangedEvent(\n source: ChangeSource | CompatibleChangeSource | string = ChangeSource.SetContent,\n data?: any\n ) {\n this.triggerPluginEvent(PluginEventType.ContentChanged, {\n source,\n data,\n });\n }\n\n //#endregion\n\n //#region Undo API\n\n /**\n * Undo last edit operation\n */\n undo() {\n undo(this);\n }\n\n /**\n * Redo next edit operation\n */\n redo() {\n redo(this);\n }\n\n /**\n * Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger\n * ContentChangedEvent with given change source.\n * If this function is called nested, undo snapshot will only be added in the outside one\n * @param callback The callback function to perform formatting, returns a data object which will be used as\n * the data field in ContentChangedEvent if changeSource is not null.\n * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,\n * a ContentChangedEvent will be fired with change source equal to this value\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n */\n addUndoSnapshot(\n callback?: (start: NodePosition | null, end: NodePosition | null) => any,\n changeSource?: ChangeSource | CompatibleChangeSource | string,\n canUndoByBackspace?: boolean,\n additionalData?: ContentChangedData\n ) {\n const core = this.getCore();\n const undoState = core.undo;\n const isNested = undoState.isNested;\n let data: any;\n\n if (!isNested) {\n undoState.isNested = true;\n\n // When there is getEntityState, it means this is triggered by an entity change.\n // So if HTML content is not changed (hasNewContent is false), no need to add another snapshot before change\n if (\n core.undo.snapshotsManager.hasNewContent ||\n !additionalData?.getEntityState ||\n !callback\n ) {\n core.api.addUndoSnapshot(\n core,\n !!canUndoByBackspace,\n additionalData?.getEntityState?.()\n );\n }\n }\n\n try {\n if (callback) {\n const selection = core.api.getDOMSelection(core);\n const range = selection?.type == 'range' ? selection.range : null;\n data = callback(\n range && Position.getStart(range).normalize(),\n range && Position.getEnd(range).normalize()\n );\n\n if (!isNested) {\n const entityStates = additionalData?.getEntityState?.();\n\n core.api.addUndoSnapshot(core, false /*isAutoCompleteSnapshot*/, entityStates);\n }\n }\n } finally {\n if (!isNested) {\n undoState.isNested = false;\n }\n }\n\n if (callback && changeSource) {\n const event: ContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n source: changeSource,\n data: data,\n additionalData,\n };\n this.triggerPluginEvent(PluginEventType.ContentChanged, event, true /*broadcast*/);\n }\n\n if (canUndoByBackspace) {\n const selection = core.api.getDOMSelection(core);\n\n if (selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n }\n }\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState {\n const { snapshotsManager } = this.getCore().undo;\n return {\n canUndo:\n snapshotsManager.hasNewContent || snapshotsManager.canMove(-1 /*previousSnapshot*/),\n canRedo: snapshotsManager.canMove(1 /*nextSnapshot*/),\n };\n }\n\n //#endregion\n\n //#region Misc\n\n /**\n * Get custom data related to this editor\n * @param key Key of the custom data\n * @param getter Getter function. If custom data for the given key doesn't exist,\n * call this function to get one and store it if it is specified. Otherwise return undefined\n * @param disposer An optional disposer function to dispose this custom data when\n * dispose editor.\n */\n getCustomData<T>(key: string, getter?: () => T, disposer?: (value: T) => void): T {\n const core = this.getContentModelEditorCore();\n return (core.customData[key] = core.customData[key] || {\n value: getter ? getter() : undefined,\n disposer,\n }).value as T;\n }\n\n /**\n * Get default format of this editor\n * @returns Default format object of this editor\n */\n getDefaultFormat(): DefaultFormat {\n const format = this.getCore().format.defaultFormat;\n\n return {\n bold: isBold(format.fontWeight),\n italic: format.italic,\n underline: format.underline,\n fontFamily: format.fontFamily,\n fontSize: format.fontSize,\n textColor: format.textColor,\n backgroundColor: format.backgroundColor,\n };\n }\n\n /**\n * Get a content traverser for the whole editor\n * @param startNode The node to start from. If not passed, it will start from the beginning of the body\n */\n getBodyTraverser(startNode?: Node): IContentTraverser {\n return ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);\n }\n\n /**\n * Get a content traverser for current selection\n * @returns A content traverser, or null if editor never got focus before\n */\n getSelectionTraverser(range?: Range): IContentTraverser | null {\n range = range ?? this.getSelectionRange() ?? undefined;\n return range\n ? ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)\n : null;\n }\n\n /**\n * Get a content traverser for current block element start from specified position\n * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart\n * @returns A content traverser, or null if editor never got focus before\n */\n getBlockTraverser(\n startFrom: ContentPosition | CompatibleContentPosition = ContentPosition.SelectionStart\n ): IContentTraverser | null {\n const range = this.getSelectionRange();\n return range\n ? ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)\n : null;\n }\n\n /**\n * Get a text traverser of current selection\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n * @returns A content traverser, or null if editor never got focus before\n */\n getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null {\n return cacheGetEventData(event ?? null, 'ContentSearcher', () => {\n const range = this.getSelectionRange();\n return (\n range &&\n new PositionContentSearcher(this.getCore().contentDiv, Position.getStart(range))\n );\n });\n }\n\n /**\n * Run a callback function asynchronously\n * @param callback The callback function to run\n * @returns a function to cancel this async run\n */\n runAsync(callback: (editor: IEditor & IStandaloneEditor) => void) {\n const win = this.getCore().contentDiv.ownerDocument.defaultView || window;\n const handle = win.requestAnimationFrame(() => {\n if (!this.isDisposed() && callback) {\n callback(this);\n }\n });\n\n return () => {\n win.cancelAnimationFrame(handle);\n };\n }\n\n /**\n * Set DOM attribute of editor content DIV\n * @param name Name of the attribute\n * @param value Value of the attribute\n */\n setEditorDomAttribute(name: string, value: string | null) {\n this.getDOMHelper().setDomAttribute(name, value);\n }\n\n /**\n * Get DOM attribute of editor content DIV, null if there is no such attribute.\n * @param name Name of the attribute\n */\n getEditorDomAttribute(name: string): string | null {\n return this.getDOMHelper().getDomAttribute(name);\n }\n\n /**\n * @deprecated Use getVisibleViewport() instead.\n *\n * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.\n * @param element The element to calculate from. If the given element is not in editor, return value will be null\n * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value\n * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.\n * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.\n */\n getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null {\n if (this.contains(element)) {\n const contentDiv = this.getCore().contentDiv;\n const editorRect = contentDiv.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (editorRect && elementRect) {\n let x = elementRect.left - editorRect?.left;\n let y = elementRect.top - editorRect?.top;\n\n if (addScroll) {\n x += contentDiv.scrollLeft;\n y += contentDiv.scrollTop;\n }\n\n return [x, y];\n }\n }\n\n return null;\n }\n\n /**\n * Add a Content Edit feature.\n * @param feature The feature to add\n */\n addContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const array = core.edit.features[key] || [];\n array.push(feature);\n core.edit.features[key] = array;\n });\n }\n\n /**\n * Remove a Content Edit feature.\n * @param feature The feature to remove\n */\n removeContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const featureSet = core.edit.features[key];\n const index = featureSet?.indexOf(feature) ?? -1;\n if (index >= 0) {\n core.edit.features[key].splice(index, 1);\n if (core.edit.features[key].length < 1) {\n delete core.edit.features[key];\n }\n }\n });\n }\n\n /**\n * @deprecated\n * Get style based format state from current selection, including font name/size and colors\n */\n getStyleBasedFormatState(): StyleBasedFormatState {\n const format = this.retrieveFormatState();\n\n return {\n backgroundColor: format.backgroundColor,\n direction: format.direction,\n fontName: format.fontName,\n fontSize: format.fontSize,\n fontWeight: format.fontWeight,\n lineHeight: format.lineHeight,\n marginBottom: format.marginBottom,\n marginTop: format.marginTop,\n textAlign: format.textAlign,\n textColor: format.textColor,\n };\n }\n\n /**\n * @deprecated\n * Get the pendable format such as underline and bold\n * @returns The pending format state\n */\n getPendableFormatState(): PendableFormatState {\n const format = this.retrieveFormatState();\n\n return {\n isBold: format.isBold,\n isItalic: format.isItalic,\n isStrikeThrough: format.isStrikeThrough,\n isSubscript: format.isSubscript,\n isSuperscript: format.isSubscript,\n isUnderline: format.isUnderline,\n };\n }\n\n /**\n * @deprecated\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n */\n ensureTypeInContainer(position: NodePosition, keyboardEvent?: KeyboardEvent) {\n // No OP\n }\n\n //#endregion\n\n //#region Dark mode APIs\n\n /**\n * Transform the given node and all its child nodes to dark mode color if editor is in dark mode\n * @param node The node to transform\n * @param direction The transform direction. @default ColorTransformDirection.LightToDark\n */\n transformToDarkColor(\n node: Node,\n direction:\n | ColorTransformDirection\n | CompatibleColorTransformDirection = ColorTransformDirection.LightToDark\n ) {\n const core = this.getCore();\n\n if (core.lifecycle.isDarkMode) {\n transformColor(\n node,\n true /*includeSelf*/,\n direction == ColorTransformDirection.DarkToLight ? 'darkToLight' : 'lightToDark',\n core.darkColorHandler\n );\n }\n }\n\n /**\n * Check if the given experimental feature is enabled\n * @param feature The feature to check\n */\n isFeatureEnabled(feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean {\n return (\n this.getContentModelEditorCore().experimentalFeatures.indexOf(\n feature as ExperimentalFeatures\n ) >= 0\n );\n }\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 return this.getDOMHelper().calculateZoomScale();\n }\n\n /**\n * Set 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 * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.\n */\n setZoomScale(scale: number): void {\n if (scale > 0 && scale <= 10) {\n const oldValue = this.getZoomScale();\n\n if (oldValue != scale) {\n this.triggerEvent(\n 'zoomChanged',\n {\n newZoomScale: scale,\n },\n true /*broadcast*/\n );\n }\n }\n }\n\n /**\n * @deprecated Use getZoomScale() instead\n */\n getSizeTransformer(): SizeTransformer {\n return this.getContentModelEditorCore().sizeTransformer;\n }\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler {\n const core = this.getContentModelEditorCore();\n return core.darkColorHandler;\n }\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 return this.getCore().domEvent.isInIME;\n }\n\n private retrieveFormatState(): ContentModelFormatState {\n const pendingFormat = this.getPendingFormat();\n const result: ContentModelFormatState = {};\n const model = this.getContentModelCopy('reduced');\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n }\n\n /**\n * @returns the current EditorAdapterCore object\n * @throws a standard Error if there's no core object\n */\n private getContentModelEditorCore(): EditorAdapterCore {\n if (!this.contentModelEditorCore) {\n throw new Error('Editor is already disposed');\n }\n\n return this.contentModelEditorCore;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EditorAdapter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/editor/EditorAdapter.ts"],"names":[],"mappings":";;;;;AAAA,4DAA2D;AAC3D,qDAAoD;AACpD,2EAA4D;AAC5D,iDAAgD;AAEhD,yDAIgC;AAChC,6EASsC;AAuCtC,iEAGoC;AAWpC,6DAiB8B;AAU9B,IAAM,iBAAiB;IACnB,wBAA4B,MAAM;IAClC,wBAA4B,WAAW;IACvC,4BAAgC,eAAe;IAC/C,0BAA8B,MAAM;IACpC,mCAAuC,MAAM;OAChD,CAAC;AAEF;;;GAGG;AACH;IAAmC,8CAAgB;IAG/C;;;;OAIG;IACH,uBAAY,UAA0B,EAAE,OAAkC;QAAlC,wBAAA,EAAA,YAAkC;;QAA1E,iBA6BC;QA5BG,IAAM,YAAY,GAAG,IAAI,2BAAY,CACjC,UAAA,IAAI;YACA,KAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;YAEnC,OAAO,KAAI,CAAC;QAChB,CAAC,EACD,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,oBAAoB,CAC/B,CAAC;QAEF,IAAM,OAAO,+BAAI,YAAY,uBAAK,CAAC,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC,SAAC,CAAC;QAC3D,IAAM,WAAW,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,UAAU,CAAC,SAAS,CAAC;QACnE,IAAM,YAAY,GACd,WAAW,IAAI,CAAC,OAAO,CAAC,YAAY;YAChC,CAAC,CAAC,IAAA,kDAAmB,EACf,W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AAC;AAAD,CAAC,AA9/BD,CAAmC,+CAAgB,GA8/BlD;AA9/BY,sCAAa","sourcesContent":["import { BridgePlugin } from '../corePlugins/BridgePlugin';\nimport { buildRangeEx } from './utils/buildRangeEx';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { insertNode } from './utils/insertNode';\nimport type { EditorAdapterCore } from '../corePlugins/BridgePlugin';\nimport {\n newEventToOldEvent,\n oldEventToNewEvent,\n OldEventTypeToNewEventType,\n} from './utils/eventConverter';\nimport {\n createModelFromHtml,\n exportContent,\n isBold,\n redo,\n retrieveModelFormatState,\n StandaloneEditor,\n transformColor,\n undo,\n} from 'roosterjs-content-model-core';\nimport {\n ChangeSource,\n ColorTransformDirection,\n ContentPosition,\n GetContentMode,\n PluginEventType,\n QueryScope,\n RegionType,\n} from 'roosterjs-editor-types';\nimport type {\n BlockElement,\n ClipboardData,\n ContentChangedData,\n ContentChangedEvent,\n DOMEventHandler,\n DefaultFormat,\n EditorUndoState,\n ExperimentalFeatures,\n GenericContentEditFeature,\n IContentTraverser,\n IPositionContentSearcher,\n InsertOption,\n NodePosition,\n PendableFormatState,\n PluginEvent,\n PluginEventData,\n PluginEventFromType,\n PositionType,\n Region,\n SelectionPath,\n SelectionRangeEx,\n SizeTransformer,\n StyleBasedFormatState,\n TableSelection,\n DOMEventHandlerObject,\n DarkColorHandler,\n IEditor,\n} from 'roosterjs-editor-types';\nimport {\n convertDomSelectionToRangeEx,\n convertRangeExToDomSelection,\n} from './utils/selectionConverter';\nimport type {\n CompatibleChangeSource,\n CompatibleColorTransformDirection,\n CompatibleContentPosition,\n CompatibleExperimentalFeatures,\n CompatibleGetContentMode,\n CompatiblePluginEventType,\n CompatibleQueryScope,\n CompatibleRegionType,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport {\n ContentTraverser,\n Position,\n PositionContentSearcher,\n cacheGetEventData,\n collapseNodes,\n contains,\n deleteSelectedContent,\n findClosestElementAncestor,\n getBlockElementAtNode,\n getRegionsFromRange,\n getSelectionPath,\n isNodeEmpty,\n isPositionAtBeginningOf,\n queryElements,\n toArray,\n wrap,\n} from 'roosterjs-editor-dom';\nimport type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';\nimport type {\n ContentModelFormatState,\n DOMEventRecord,\n ExportContentMode,\n IStandaloneEditor,\n StandaloneEditorOptions,\n} from 'roosterjs-content-model-types';\n\nconst GetContentModeMap: Record<GetContentMode, ExportContentMode> = {\n [GetContentMode.CleanHTML]: 'HTML',\n [GetContentMode.PlainText]: 'PlainText',\n [GetContentMode.PlainTextFast]: 'PlainTextFast',\n [GetContentMode.RawHTMLOnly]: 'HTML',\n [GetContentMode.RawHTMLWithSelection]: 'HTML',\n};\n\n/**\n * Editor for Content Model.\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class EditorAdapter extends StandaloneEditor implements IEditor {\n private contentModelEditorCore: EditorAdapterCore | undefined;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorAdapterOptions = {}) {\n const bridgePlugin = new BridgePlugin(\n core => {\n this.contentModelEditorCore = core;\n\n return this;\n },\n options.legacyPlugins,\n options.experimentalFeatures\n );\n\n const plugins = [bridgePlugin, ...(options.plugins ?? [])];\n const initContent = options.initialContent ?? contentDiv.innerHTML;\n const initialModel =\n initContent && !options.initialModel\n ? createModelFromHtml(\n initContent,\n options.defaultDomToModelOptions,\n options.trustedHTMLHandler,\n options.defaultSegmentFormat\n )\n : options.initialModel;\n const standaloneEditorOptions: StandaloneEditorOptions = {\n ...options,\n plugins,\n initialModel,\n };\n\n super(contentDiv, standaloneEditorOptions);\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void {\n super.dispose();\n\n const core = this.contentModelEditorCore;\n\n if (core) {\n getObjectKeys(core.customData).forEach(key => {\n const data = core.customData[key];\n\n if (data && data.disposer) {\n data.disposer(data.value);\n }\n\n delete core.customData[key];\n });\n\n this.contentModelEditorCore = undefined;\n }\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return super.isDisposed() || !this.contentModelEditorCore;\n }\n\n /**\n * Insert node into editor\n * @param node The node to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n * @returns true if node is inserted. Otherwise false\n */\n insertNode(node: Node, option?: InsertOption): boolean {\n if (node) {\n option = option || {\n position: ContentPosition.SelectionStart,\n insertOnNewLine: false,\n updateCursor: true,\n replaceSelection: true,\n insertToRegionRoot: false,\n };\n\n const { contentDiv } = this.getCore();\n\n if (option.updateCursor) {\n this.focus();\n }\n\n if (option.position == ContentPosition.Outside) {\n contentDiv.parentNode?.insertBefore(node, contentDiv.nextSibling);\n } else {\n if (this.isDarkMode()) {\n transformColor(\n node,\n true /*includeSelf*/,\n 'lightToDark',\n this.getColorManager()\n );\n }\n\n const selection = insertNode(contentDiv, this.getDOMSelection(), node, option);\n\n if (selection && option.updateCursor) {\n this.setDOMSelection(selection);\n }\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Delete a node from editor content\n * @param node The node to delete\n * @returns true if node is deleted. Otherwise false\n */\n deleteNode(node: Node): boolean {\n // Only remove the node when it falls within editor\n if (node && this.contains(node) && node.parentNode) {\n node.parentNode.removeChild(node);\n return true;\n }\n\n return false;\n }\n\n /**\n * Replace a node in editor content with another node\n * @param existingNode The existing node to be replaced\n * @param toNode node to replace to\n * @param transformColorForDarkMode (optional) Whether to transform new node to dark mode. Default is false\n * @returns true if node is replaced. Otherwise false\n */\n replaceNode(existingNode: Node, toNode: Node, transformColorForDarkMode?: boolean): boolean {\n const core = this.getCore();\n // Only replace the node when it falls within editor\n if (this.contains(existingNode) && toNode) {\n if (core.lifecycle.isDarkMode && transformColorForDarkMode) {\n this.transformToDarkColor(toNode, ColorTransformDirection.LightToDark);\n }\n\n existingNode.parentNode?.replaceChild(toNode, existingNode);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Get BlockElement at given node\n * @param node The node to create InlineElement\n * @returns The BlockElement result\n */\n getBlockElementAtNode(node: Node): BlockElement | null {\n return getBlockElementAtNode(this.getCore().contentDiv, node);\n }\n\n contains(arg: Node | Range | null): boolean {\n if (!arg) {\n return false;\n }\n return contains(this.getCore().contentDiv, <Node>arg);\n }\n\n queryElements(\n selector: string,\n scopeOrCallback:\n | QueryScope\n | CompatibleQueryScope\n | ((node: Node) => any) = QueryScope.Body,\n callback?: (node: Node) => any\n ) {\n const core = this.getCore();\n const result: HTMLElement[] = [];\n const scope = scopeOrCallback instanceof Function ? QueryScope.Body : scopeOrCallback;\n callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;\n\n const selectionEx = scope == QueryScope.Body ? null : this.getSelectionRangeEx();\n if (selectionEx) {\n selectionEx.ranges.forEach(range => {\n result.push(...queryElements(core.contentDiv, selector, callback, scope, range));\n });\n } else {\n return queryElements(core.contentDiv, selector, callback, scope, undefined /* range */);\n }\n\n return result;\n }\n\n /**\n * Collapse nodes within the given start and end nodes to their common ancestor node,\n * split parent nodes if necessary\n * @param start The start node\n * @param end The end node\n * @param canSplitParent True to allow split parent node there are nodes before start or after end under the same parent\n * and the returned nodes will be all nodes from start through end after splitting\n * False to disallow split parent\n * @returns When canSplitParent is true, returns all node from start through end after splitting,\n * otherwise just return start and end\n */\n collapseNodes(start: Node, end: Node, canSplitParent: boolean): Node[] {\n return collapseNodes(this.getCore().contentDiv, start, end, canSplitParent);\n }\n\n //#endregion\n\n //#region Content API\n\n /**\n * Check whether the editor contains any visible content\n * @param trim Whether trim the content string before check. Default is false\n * @returns True if there's no visible content, otherwise false\n */\n isEmpty(trim?: boolean): boolean {\n return isNodeEmpty(this.getCore().contentDiv, trim);\n }\n\n /**\n * Get current editor content as HTML string\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent(mode: GetContentMode | CompatibleGetContentMode = GetContentMode.CleanHTML): string {\n return exportContent(\n this,\n GetContentModeMap[mode],\n this.getCore().modelToDomSettings.customized\n );\n }\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent(content: string, triggerContentChangedEvent: boolean = true) {\n const core = this.getCore();\n const { contentDiv, api, trustedHTMLHandler, lifecycle, darkColorHandler } = core;\n\n api.triggerEvent(\n core,\n {\n eventType: 'beforeSetContent',\n newContent: content,\n },\n true /*broadcast*/\n );\n\n const newModel = createModelFromHtml(\n content,\n core.domToModelSettings.customized,\n trustedHTMLHandler,\n core.format.defaultFormat\n );\n\n api.setContentModel(core, newModel);\n\n if (triggerContentChangedEvent) {\n api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: ChangeSource.SetContent,\n },\n false /*broadcast*/\n );\n } else if (lifecycle.isDarkMode) {\n transformColor(contentDiv, false /*includeSelf*/, 'lightToDark', darkColorHandler);\n }\n }\n\n /**\n * Insert HTML content into editor\n * @param HTML content to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n */\n insertContent(content: string, option?: InsertOption) {\n if (content) {\n const doc = this.getDocument();\n const body = new DOMParser().parseFromString(\n this.getCore().trustedHTMLHandler(content),\n 'text/html'\n )?.body;\n let allNodes = body?.childNodes ? toArray(body.childNodes) : [];\n\n // If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with\n // a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped\n // separately to show up on its own line\n if (option && option.insertOnNewLine && allNodes.length > 1) {\n allNodes = [wrap(allNodes)];\n }\n\n const fragment = doc.createDocumentFragment();\n allNodes.forEach(node => fragment.appendChild(node));\n\n this.insertNode(fragment, option);\n }\n }\n\n /**\n * Delete selected content\n */\n deleteSelectedContent(): NodePosition | null {\n const range = this.getSelectionRange();\n if (range && !range.collapsed) {\n return deleteSelectedContent(this.getCore().contentDiv, range);\n }\n return null;\n }\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteAsText Force pasting as plain text. Default value is false\n * @param applyCurrentStyle True if apply format of current selection to the pasted content,\n * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored\n * @param pasteAsImage: When set to true, if the clipboardData contains a imageDataUri will paste the image to the editor\n */\n paste(\n clipboardData: ClipboardData,\n pasteAsText: boolean = false,\n applyCurrentFormat: boolean = false,\n pasteAsImage: boolean = false\n ) {\n this.pasteFromClipboard(\n clipboardData,\n pasteAsText\n ? 'asPlainText'\n : applyCurrentFormat\n ? 'mergeFormat'\n : pasteAsImage\n ? 'asImage'\n : 'normal'\n );\n }\n\n //#endregion\n\n //#region Focus and Selection\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRange(tryGetFromCache: boolean = true): Range | null {\n const selection = this.getDOMSelection();\n\n return selection?.type == 'range' ? selection.range : null;\n }\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRangeEx(): SelectionRangeEx {\n const selection = this.getDOMSelection();\n\n return convertDomSelectionToRangeEx(selection);\n }\n\n /**\n * Get current selection in a serializable format\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @returns current selection path, or null if editor never got focus before\n */\n getSelectionPath(): SelectionPath | null {\n const range = this.getSelectionRange();\n return range && getSelectionPath(this.getCore().contentDiv, range);\n }\n\n select(\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 const core = this.getCore();\n const rangeEx = buildRangeEx(core.contentDiv, arg1, arg2, arg3, arg4);\n const selection = convertRangeExToDomSelection(rangeEx);\n\n this.setDOMSelection(selection);\n return true;\n }\n\n /**\n * Get current focused position. Return null if editor doesn't have focus at this time.\n */\n getFocusedPosition(): NodePosition | null {\n const sel = this.getDocument().defaultView?.getSelection();\n if (sel?.focusNode && this.contains(sel.focusNode)) {\n return new Position(sel.focusNode, sel.focusOffset);\n }\n\n const range = this.getSelectionRange();\n if (range) {\n return Position.getStart(range);\n }\n\n return null;\n }\n\n /**\n * Get an HTML element from current cursor position.\n * When expectedTags is not specified, return value is the current node (if it is HTML element)\n * or its parent node (if current node is a Text node).\n * When expectedTags is specified, return value is the first ancestor of current node which has\n * one of the expected tags.\n * If no element found within editor by the given tag, return null.\n * @param selector Optional, an HTML selector to find HTML element with.\n * @param startFrom Start search from this node. If not specified, start from current focused position\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n */\n getElementAtCursor(\n selector?: string,\n startFrom?: Node,\n event?: PluginEvent\n ): HTMLElement | null {\n event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result\n\n return (\n cacheGetEventData(event ?? null, 'GET_ELEMENT_AT_CURSOR_' + selector, () => {\n if (!startFrom) {\n const position = this.getFocusedPosition();\n startFrom = position?.node;\n }\n return (\n startFrom &&\n findClosestElementAncestor(startFrom, this.getCore().contentDiv, selector)\n );\n }) ?? null\n );\n }\n\n /**\n * Check if this position is at beginning of the editor.\n * This will return true if all nodes between the beginning of target node and the position are empty.\n * @param position The position to check\n * @returns True if position is at beginning of the editor, otherwise false\n */\n isPositionAtBeginning(position: NodePosition): boolean {\n return isPositionAtBeginningOf(position, this.getCore().contentDiv);\n }\n\n /**\n * Get impacted regions from selection\n */\n getSelectedRegions(type: RegionType | CompatibleRegionType = RegionType.Table): Region[] {\n const selection = this.getSelectionRangeEx();\n const result: Region[] = [];\n const contentDiv = this.getCore().contentDiv;\n selection.ranges.forEach(range => {\n result.push(...(range ? getRegionsFromRange(contentDiv, range, type) : []));\n });\n return result.filter((value, index, self) => {\n return self.indexOf(value) === index;\n });\n }\n\n //#endregion\n\n //#region EVENT API\n\n addDomEventHandler(\n nameOrMap: string | Record<string, DOMEventHandler>,\n handler?: DOMEventHandler\n ): () => void {\n const eventsMap = typeof nameOrMap == 'string' ? { [nameOrMap]: handler! } : nameOrMap;\n const eventsMapResult: Record<string, DOMEventRecord> = {};\n\n getObjectKeys(eventsMap).forEach(key => {\n const handlerObj = eventsMap[key];\n let result: DOMEventRecord = {\n pluginEventType: null,\n beforeDispatch: null,\n };\n\n if (typeof handlerObj === 'number') {\n result.pluginEventType = OldEventTypeToNewEventType[handlerObj as PluginEventType];\n } else if (typeof handlerObj === 'function') {\n result.beforeDispatch = handlerObj;\n } else if (typeof handlerObj === 'object') {\n const record = handlerObj as DOMEventHandlerObject;\n result = {\n beforeDispatch: record.beforeDispatch,\n pluginEventType:\n typeof record.pluginEventType == 'number'\n ? OldEventTypeToNewEventType[record.pluginEventType]\n : undefined,\n };\n }\n\n eventsMapResult[key] = result;\n });\n\n return this.attachDomEvent(eventsMapResult);\n }\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 public triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const oldEvent = {\n eventType,\n ...data,\n } as PluginEvent;\n const newEvent = oldEventToNewEvent(oldEvent);\n const core = this.getCore();\n\n if (newEvent) {\n core.api.triggerEvent(core, newEvent, broadcast);\n return (newEventToOldEvent(newEvent, oldEvent) ?? oldEvent) as PluginEventFromType<T>;\n } else {\n return oldEvent as PluginEventFromType<T>;\n }\n }\n\n /**\n * Trigger a ContentChangedEvent\n * @param source Source of this event, by default is 'SetContent'\n * @param data additional data for this event\n */\n triggerContentChangedEvent(\n source: ChangeSource | CompatibleChangeSource | string = ChangeSource.SetContent,\n data?: any\n ) {\n this.triggerPluginEvent(PluginEventType.ContentChanged, {\n source,\n data,\n });\n }\n\n //#endregion\n\n //#region Undo API\n\n /**\n * Undo last edit operation\n */\n undo() {\n undo(this);\n }\n\n /**\n * Redo next edit operation\n */\n redo() {\n redo(this);\n }\n\n /**\n * Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger\n * ContentChangedEvent with given change source.\n * If this function is called nested, undo snapshot will only be added in the outside one\n * @param callback The callback function to perform formatting, returns a data object which will be used as\n * the data field in ContentChangedEvent if changeSource is not null.\n * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,\n * a ContentChangedEvent will be fired with change source equal to this value\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n */\n addUndoSnapshot(\n callback?: (start: NodePosition | null, end: NodePosition | null) => any,\n changeSource?: ChangeSource | CompatibleChangeSource | string,\n canUndoByBackspace?: boolean,\n additionalData?: ContentChangedData\n ) {\n const core = this.getCore();\n const undoState = core.undo;\n const isNested = undoState.isNested;\n let data: any;\n\n if (!isNested) {\n undoState.isNested = true;\n\n // When there is getEntityState, it means this is triggered by an entity change.\n // So if HTML content is not changed (hasNewContent is false), no need to add another snapshot before change\n if (\n core.undo.snapshotsManager.hasNewContent ||\n !additionalData?.getEntityState ||\n !callback\n ) {\n core.api.addUndoSnapshot(\n core,\n !!canUndoByBackspace,\n additionalData?.getEntityState?.()\n );\n }\n }\n\n try {\n if (callback) {\n const selection = core.api.getDOMSelection(core);\n const range = selection?.type == 'range' ? selection.range : null;\n data = callback(\n range && Position.getStart(range).normalize(),\n range && Position.getEnd(range).normalize()\n );\n\n if (!isNested) {\n const entityStates = additionalData?.getEntityState?.();\n\n core.api.addUndoSnapshot(core, false /*isAutoCompleteSnapshot*/, entityStates);\n }\n }\n } finally {\n if (!isNested) {\n undoState.isNested = false;\n }\n }\n\n if (callback && changeSource) {\n const event: ContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n source: changeSource,\n data: data,\n additionalData,\n };\n this.triggerPluginEvent(PluginEventType.ContentChanged, event, true /*broadcast*/);\n }\n\n if (canUndoByBackspace) {\n const selection = core.api.getDOMSelection(core);\n\n if (selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n }\n }\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState {\n const { snapshotsManager } = this.getCore().undo;\n return {\n canUndo:\n snapshotsManager.hasNewContent || snapshotsManager.canMove(-1 /*previousSnapshot*/),\n canRedo: snapshotsManager.canMove(1 /*nextSnapshot*/),\n };\n }\n\n //#endregion\n\n //#region Misc\n\n /**\n * Get custom data related to this editor\n * @param key Key of the custom data\n * @param getter Getter function. If custom data for the given key doesn't exist,\n * call this function to get one and store it if it is specified. Otherwise return undefined\n * @param disposer An optional disposer function to dispose this custom data when\n * dispose editor.\n */\n getCustomData<T>(key: string, getter?: () => T, disposer?: (value: T) => void): T {\n const core = this.getContentModelEditorCore();\n return (core.customData[key] = core.customData[key] || {\n value: getter ? getter() : undefined,\n disposer,\n }).value as T;\n }\n\n /**\n * Get default format of this editor\n * @returns Default format object of this editor\n */\n getDefaultFormat(): DefaultFormat {\n const format = this.getCore().format.defaultFormat;\n\n return {\n bold: isBold(format.fontWeight),\n italic: format.italic,\n underline: format.underline,\n fontFamily: format.fontFamily,\n fontSize: format.fontSize,\n textColor: format.textColor,\n backgroundColor: format.backgroundColor,\n };\n }\n\n /**\n * Get a content traverser for the whole editor\n * @param startNode The node to start from. If not passed, it will start from the beginning of the body\n */\n getBodyTraverser(startNode?: Node): IContentTraverser {\n return ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);\n }\n\n /**\n * Get a content traverser for current selection\n * @returns A content traverser, or null if editor never got focus before\n */\n getSelectionTraverser(range?: Range): IContentTraverser | null {\n range = range ?? this.getSelectionRange() ?? undefined;\n return range\n ? ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)\n : null;\n }\n\n /**\n * Get a content traverser for current block element start from specified position\n * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart\n * @returns A content traverser, or null if editor never got focus before\n */\n getBlockTraverser(\n startFrom: ContentPosition | CompatibleContentPosition = ContentPosition.SelectionStart\n ): IContentTraverser | null {\n const range = this.getSelectionRange();\n return range\n ? ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)\n : null;\n }\n\n /**\n * Get a text traverser of current selection\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n * @returns A content traverser, or null if editor never got focus before\n */\n getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null {\n return cacheGetEventData(event ?? null, 'ContentSearcher', () => {\n const range = this.getSelectionRange();\n return (\n range &&\n new PositionContentSearcher(this.getCore().contentDiv, Position.getStart(range))\n );\n });\n }\n\n /**\n * Run a callback function asynchronously\n * @param callback The callback function to run\n * @returns a function to cancel this async run\n */\n runAsync(callback: (editor: IEditor & IStandaloneEditor) => void) {\n const win = this.getCore().contentDiv.ownerDocument.defaultView || window;\n const handle = win.requestAnimationFrame(() => {\n if (!this.isDisposed() && callback) {\n callback(this);\n }\n });\n\n return () => {\n win.cancelAnimationFrame(handle);\n };\n }\n\n /**\n * Set DOM attribute of editor content DIV\n * @param name Name of the attribute\n * @param value Value of the attribute\n */\n setEditorDomAttribute(name: string, value: string | null) {\n this.getDOMHelper().setDomAttribute(name, value);\n }\n\n /**\n * Get DOM attribute of editor content DIV, null if there is no such attribute.\n * @param name Name of the attribute\n */\n getEditorDomAttribute(name: string): string | null {\n return this.getDOMHelper().getDomAttribute(name);\n }\n\n /**\n * @deprecated Use getVisibleViewport() instead.\n *\n * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.\n * @param element The element to calculate from. If the given element is not in editor, return value will be null\n * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value\n * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.\n * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.\n */\n getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null {\n if (this.contains(element)) {\n const contentDiv = this.getCore().contentDiv;\n const editorRect = contentDiv.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (editorRect && elementRect) {\n let x = elementRect.left - editorRect?.left;\n let y = elementRect.top - editorRect?.top;\n\n if (addScroll) {\n x += contentDiv.scrollLeft;\n y += contentDiv.scrollTop;\n }\n\n return [x, y];\n }\n }\n\n return null;\n }\n\n /**\n * Add a Content Edit feature.\n * @param feature The feature to add\n */\n addContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const array = core.edit.features[key] || [];\n array.push(feature);\n core.edit.features[key] = array;\n });\n }\n\n /**\n * Remove a Content Edit feature.\n * @param feature The feature to remove\n */\n removeContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const featureSet = core.edit.features[key];\n const index = featureSet?.indexOf(feature) ?? -1;\n if (index >= 0) {\n core.edit.features[key].splice(index, 1);\n if (core.edit.features[key].length < 1) {\n delete core.edit.features[key];\n }\n }\n });\n }\n\n /**\n * @deprecated\n * Get style based format state from current selection, including font name/size and colors\n */\n getStyleBasedFormatState(): StyleBasedFormatState {\n const format = this.retrieveFormatState();\n\n return {\n backgroundColor: format.backgroundColor,\n direction: format.direction,\n fontName: format.fontName,\n fontSize: format.fontSize,\n fontWeight: format.fontWeight,\n lineHeight: format.lineHeight,\n marginBottom: format.marginBottom,\n marginTop: format.marginTop,\n textAlign: format.textAlign,\n textColor: format.textColor,\n };\n }\n\n /**\n * @deprecated\n * Get the pendable format such as underline and bold\n * @returns The pending format state\n */\n getPendableFormatState(): PendableFormatState {\n const format = this.retrieveFormatState();\n\n return {\n isBold: format.isBold,\n isItalic: format.isItalic,\n isStrikeThrough: format.isStrikeThrough,\n isSubscript: format.isSubscript,\n isSuperscript: format.isSubscript,\n isUnderline: format.isUnderline,\n };\n }\n\n /**\n * @deprecated\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n */\n ensureTypeInContainer(position: NodePosition, keyboardEvent?: KeyboardEvent) {\n // No OP\n }\n\n //#endregion\n\n //#region Dark mode APIs\n\n /**\n * Transform the given node and all its child nodes to dark mode color if editor is in dark mode\n * @param node The node to transform\n * @param direction The transform direction. @default ColorTransformDirection.LightToDark\n */\n transformToDarkColor(\n node: Node,\n direction:\n | ColorTransformDirection\n | CompatibleColorTransformDirection = ColorTransformDirection.LightToDark\n ) {\n const core = this.getCore();\n\n if (core.lifecycle.isDarkMode) {\n transformColor(\n node,\n true /*includeSelf*/,\n direction == ColorTransformDirection.DarkToLight ? 'darkToLight' : 'lightToDark',\n core.darkColorHandler\n );\n }\n }\n\n /**\n * Check if the given experimental feature is enabled\n * @param feature The feature to check\n */\n isFeatureEnabled(feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean {\n return (\n this.getContentModelEditorCore().experimentalFeatures.indexOf(\n feature as ExperimentalFeatures\n ) >= 0\n );\n }\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 return this.getDOMHelper().calculateZoomScale();\n }\n\n /**\n * Set 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 * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.\n */\n setZoomScale(scale: number): void {\n if (scale > 0 && scale <= 10) {\n const oldValue = this.getZoomScale();\n\n if (oldValue != scale) {\n this.triggerEvent(\n 'zoomChanged',\n {\n newZoomScale: scale,\n },\n true /*broadcast*/\n );\n }\n }\n }\n\n /**\n * @deprecated Use getZoomScale() instead\n */\n getSizeTransformer(): SizeTransformer {\n return this.getContentModelEditorCore().sizeTransformer;\n }\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler {\n const core = this.getContentModelEditorCore();\n return core.darkColorHandler;\n }\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 return this.getCore().domEvent.isInIME;\n }\n\n private retrieveFormatState(): ContentModelFormatState {\n const pendingFormat = this.getPendingFormat();\n const result: ContentModelFormatState = {};\n const model = this.getContentModelCopy('reduced');\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n }\n\n /**\n * @returns the current EditorAdapterCore object\n * @throws a standard Error if there's no core object\n */\n private getContentModelEditorCore(): EditorAdapterCore {\n if (!this.contentModelEditorCore) {\n throw new Error('Editor is already disposed');\n }\n\n return this.contentModelEditorCore;\n }\n}\n"]}
|
|
@@ -42,6 +42,7 @@ define(["require", "exports", "tslib", "../corePlugins/BridgePlugin", "./utils/b
|
|
|
42
42
|
* Dispose this editor, dispose all plugins and custom data
|
|
43
43
|
*/
|
|
44
44
|
EditorAdapter.prototype.dispose = function () {
|
|
45
|
+
_super.prototype.dispose.call(this);
|
|
45
46
|
var core = this.contentModelEditorCore;
|
|
46
47
|
if (core) {
|
|
47
48
|
(0, roosterjs_content_model_dom_1.getObjectKeys)(core.customData).forEach(function (key) {
|
|
@@ -53,7 +54,6 @@ define(["require", "exports", "tslib", "../corePlugins/BridgePlugin", "./utils/b
|
|
|
53
54
|
});
|
|
54
55
|
this.contentModelEditorCore = undefined;
|
|
55
56
|
}
|
|
56
|
-
_super.prototype.dispose.call(this);
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
59
|
* Get whether this editor is disposed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorAdapter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/editor/EditorAdapter.ts"],"names":[],"mappings":";;;;;IAmGA,IAAM,iBAAiB;QACnB,wBAA4B,MAAM;QAClC,wBAA4B,WAAW;QACvC,4BAAgC,eAAe;QAC/C,0BAA8B,MAAM;QACpC,mCAAuC,MAAM;WAChD,CAAC;IAEF;;;OAGG;IACH;QAAmC,8CAAgB;QAG/C;;;;WAIG;QACH,uBAAY,UAA0B,EAAE,OAAkC;YAAlC,wBAAA,EAAA,YAAkC;;YAA1E,iBA6BC;YA5BG,IAAM,YAAY,GAAG,IAAI,2BAAY,CACjC,UAAA,IAAI;gBACA,KAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;gBAEnC,OAAO,KAAI,CAAC;YAChB,CAAC,EACD,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,oBAAoB,CAC/B,CAAC;YAEF,IAAM,OAAO,+BAAI,YAAY,uBAAK,CAAC,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC,SAAC,CAAC;YAC3D,IAAM,WAAW,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,UAAU,CAAC,SAAS,CAAC;YACnE,IAAM,YAAY,GACd,WAAW,IAAI,CAAC,OAAO,CAAC,YAAY;gBAChC,CAAC,CAAC,IAAA,kDAAmB,EACf,WAAW,EACX,OAAO,CAAC,wBAAwB,EAChC,OAAO,CAAC,kBAAkB,EAC1B,OAAO,CAAC,oBAAoB,CAC/B;gBACH,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;YAC/B,IAAM,uBAAuB,mDAC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oBAAC;IAAD,CAAC,AA9/BD,CAAmC,+CAAgB,GA8/BlD;IA9/BY,sCAAa","sourcesContent":["import { BridgePlugin } from '../corePlugins/BridgePlugin';\nimport { buildRangeEx } from './utils/buildRangeEx';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { insertNode } from './utils/insertNode';\nimport type { EditorAdapterCore } from '../corePlugins/BridgePlugin';\nimport {\n newEventToOldEvent,\n oldEventToNewEvent,\n OldEventTypeToNewEventType,\n} from './utils/eventConverter';\nimport {\n createModelFromHtml,\n exportContent,\n isBold,\n redo,\n retrieveModelFormatState,\n StandaloneEditor,\n transformColor,\n undo,\n} from 'roosterjs-content-model-core';\nimport {\n ChangeSource,\n ColorTransformDirection,\n ContentPosition,\n GetContentMode,\n PluginEventType,\n QueryScope,\n RegionType,\n} from 'roosterjs-editor-types';\nimport type {\n BlockElement,\n ClipboardData,\n ContentChangedData,\n ContentChangedEvent,\n DOMEventHandler,\n DefaultFormat,\n EditorUndoState,\n ExperimentalFeatures,\n GenericContentEditFeature,\n IContentTraverser,\n IPositionContentSearcher,\n InsertOption,\n NodePosition,\n PendableFormatState,\n PluginEvent,\n PluginEventData,\n PluginEventFromType,\n PositionType,\n Region,\n SelectionPath,\n SelectionRangeEx,\n SizeTransformer,\n StyleBasedFormatState,\n TableSelection,\n DOMEventHandlerObject,\n DarkColorHandler,\n IEditor,\n} from 'roosterjs-editor-types';\nimport {\n convertDomSelectionToRangeEx,\n convertRangeExToDomSelection,\n} from './utils/selectionConverter';\nimport type {\n CompatibleChangeSource,\n CompatibleColorTransformDirection,\n CompatibleContentPosition,\n CompatibleExperimentalFeatures,\n CompatibleGetContentMode,\n CompatiblePluginEventType,\n CompatibleQueryScope,\n CompatibleRegionType,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport {\n ContentTraverser,\n Position,\n PositionContentSearcher,\n cacheGetEventData,\n collapseNodes,\n contains,\n deleteSelectedContent,\n findClosestElementAncestor,\n getBlockElementAtNode,\n getRegionsFromRange,\n getSelectionPath,\n isNodeEmpty,\n isPositionAtBeginningOf,\n queryElements,\n toArray,\n wrap,\n} from 'roosterjs-editor-dom';\nimport type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';\nimport type {\n ContentModelFormatState,\n DOMEventRecord,\n ExportContentMode,\n IStandaloneEditor,\n StandaloneEditorOptions,\n} from 'roosterjs-content-model-types';\n\nconst GetContentModeMap: Record<GetContentMode, ExportContentMode> = {\n [GetContentMode.CleanHTML]: 'HTML',\n [GetContentMode.PlainText]: 'PlainText',\n [GetContentMode.PlainTextFast]: 'PlainTextFast',\n [GetContentMode.RawHTMLOnly]: 'HTML',\n [GetContentMode.RawHTMLWithSelection]: 'HTML',\n};\n\n/**\n * Editor for Content Model.\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class EditorAdapter extends StandaloneEditor implements IEditor {\n private contentModelEditorCore: EditorAdapterCore | undefined;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorAdapterOptions = {}) {\n const bridgePlugin = new BridgePlugin(\n core => {\n this.contentModelEditorCore = core;\n\n return this;\n },\n options.legacyPlugins,\n options.experimentalFeatures\n );\n\n const plugins = [bridgePlugin, ...(options.plugins ?? [])];\n const initContent = options.initialContent ?? contentDiv.innerHTML;\n const initialModel =\n initContent && !options.initialModel\n ? createModelFromHtml(\n initContent,\n options.defaultDomToModelOptions,\n options.trustedHTMLHandler,\n options.defaultSegmentFormat\n )\n : options.initialModel;\n const standaloneEditorOptions: StandaloneEditorOptions = {\n ...options,\n plugins,\n initialModel,\n };\n\n super(contentDiv, standaloneEditorOptions);\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void {\n const core = this.contentModelEditorCore;\n\n if (core) {\n getObjectKeys(core.customData).forEach(key => {\n const data = core.customData[key];\n\n if (data && data.disposer) {\n data.disposer(data.value);\n }\n\n delete core.customData[key];\n });\n\n this.contentModelEditorCore = undefined;\n }\n\n super.dispose();\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return super.isDisposed() || !this.contentModelEditorCore;\n }\n\n /**\n * Insert node into editor\n * @param node The node to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n * @returns true if node is inserted. Otherwise false\n */\n insertNode(node: Node, option?: InsertOption): boolean {\n if (node) {\n option = option || {\n position: ContentPosition.SelectionStart,\n insertOnNewLine: false,\n updateCursor: true,\n replaceSelection: true,\n insertToRegionRoot: false,\n };\n\n const { contentDiv } = this.getCore();\n\n if (option.updateCursor) {\n this.focus();\n }\n\n if (option.position == ContentPosition.Outside) {\n contentDiv.parentNode?.insertBefore(node, contentDiv.nextSibling);\n } else {\n if (this.isDarkMode()) {\n transformColor(\n node,\n true /*includeSelf*/,\n 'lightToDark',\n this.getColorManager()\n );\n }\n\n const selection = insertNode(contentDiv, this.getDOMSelection(), node, option);\n\n if (selection && option.updateCursor) {\n this.setDOMSelection(selection);\n }\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Delete a node from editor content\n * @param node The node to delete\n * @returns true if node is deleted. Otherwise false\n */\n deleteNode(node: Node): boolean {\n // Only remove the node when it falls within editor\n if (node && this.contains(node) && node.parentNode) {\n node.parentNode.removeChild(node);\n return true;\n }\n\n return false;\n }\n\n /**\n * Replace a node in editor content with another node\n * @param existingNode The existing node to be replaced\n * @param toNode node to replace to\n * @param transformColorForDarkMode (optional) Whether to transform new node to dark mode. Default is false\n * @returns true if node is replaced. Otherwise false\n */\n replaceNode(existingNode: Node, toNode: Node, transformColorForDarkMode?: boolean): boolean {\n const core = this.getCore();\n // Only replace the node when it falls within editor\n if (this.contains(existingNode) && toNode) {\n if (core.lifecycle.isDarkMode && transformColorForDarkMode) {\n this.transformToDarkColor(toNode, ColorTransformDirection.LightToDark);\n }\n\n existingNode.parentNode?.replaceChild(toNode, existingNode);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Get BlockElement at given node\n * @param node The node to create InlineElement\n * @returns The BlockElement result\n */\n getBlockElementAtNode(node: Node): BlockElement | null {\n return getBlockElementAtNode(this.getCore().contentDiv, node);\n }\n\n contains(arg: Node | Range | null): boolean {\n if (!arg) {\n return false;\n }\n return contains(this.getCore().contentDiv, <Node>arg);\n }\n\n queryElements(\n selector: string,\n scopeOrCallback:\n | QueryScope\n | CompatibleQueryScope\n | ((node: Node) => any) = QueryScope.Body,\n callback?: (node: Node) => any\n ) {\n const core = this.getCore();\n const result: HTMLElement[] = [];\n const scope = scopeOrCallback instanceof Function ? QueryScope.Body : scopeOrCallback;\n callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;\n\n const selectionEx = scope == QueryScope.Body ? null : this.getSelectionRangeEx();\n if (selectionEx) {\n selectionEx.ranges.forEach(range => {\n result.push(...queryElements(core.contentDiv, selector, callback, scope, range));\n });\n } else {\n return queryElements(core.contentDiv, selector, callback, scope, undefined /* range */);\n }\n\n return result;\n }\n\n /**\n * Collapse nodes within the given start and end nodes to their common ancestor node,\n * split parent nodes if necessary\n * @param start The start node\n * @param end The end node\n * @param canSplitParent True to allow split parent node there are nodes before start or after end under the same parent\n * and the returned nodes will be all nodes from start through end after splitting\n * False to disallow split parent\n * @returns When canSplitParent is true, returns all node from start through end after splitting,\n * otherwise just return start and end\n */\n collapseNodes(start: Node, end: Node, canSplitParent: boolean): Node[] {\n return collapseNodes(this.getCore().contentDiv, start, end, canSplitParent);\n }\n\n //#endregion\n\n //#region Content API\n\n /**\n * Check whether the editor contains any visible content\n * @param trim Whether trim the content string before check. Default is false\n * @returns True if there's no visible content, otherwise false\n */\n isEmpty(trim?: boolean): boolean {\n return isNodeEmpty(this.getCore().contentDiv, trim);\n }\n\n /**\n * Get current editor content as HTML string\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent(mode: GetContentMode | CompatibleGetContentMode = GetContentMode.CleanHTML): string {\n return exportContent(\n this,\n GetContentModeMap[mode],\n this.getCore().modelToDomSettings.customized\n );\n }\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent(content: string, triggerContentChangedEvent: boolean = true) {\n const core = this.getCore();\n const { contentDiv, api, trustedHTMLHandler, lifecycle, darkColorHandler } = core;\n\n api.triggerEvent(\n core,\n {\n eventType: 'beforeSetContent',\n newContent: content,\n },\n true /*broadcast*/\n );\n\n const newModel = createModelFromHtml(\n content,\n core.domToModelSettings.customized,\n trustedHTMLHandler,\n core.format.defaultFormat\n );\n\n api.setContentModel(core, newModel);\n\n if (triggerContentChangedEvent) {\n api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: ChangeSource.SetContent,\n },\n false /*broadcast*/\n );\n } else if (lifecycle.isDarkMode) {\n transformColor(contentDiv, false /*includeSelf*/, 'lightToDark', darkColorHandler);\n }\n }\n\n /**\n * Insert HTML content into editor\n * @param HTML content to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n */\n insertContent(content: string, option?: InsertOption) {\n if (content) {\n const doc = this.getDocument();\n const body = new DOMParser().parseFromString(\n this.getCore().trustedHTMLHandler(content),\n 'text/html'\n )?.body;\n let allNodes = body?.childNodes ? toArray(body.childNodes) : [];\n\n // If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with\n // a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped\n // separately to show up on its own line\n if (option && option.insertOnNewLine && allNodes.length > 1) {\n allNodes = [wrap(allNodes)];\n }\n\n const fragment = doc.createDocumentFragment();\n allNodes.forEach(node => fragment.appendChild(node));\n\n this.insertNode(fragment, option);\n }\n }\n\n /**\n * Delete selected content\n */\n deleteSelectedContent(): NodePosition | null {\n const range = this.getSelectionRange();\n if (range && !range.collapsed) {\n return deleteSelectedContent(this.getCore().contentDiv, range);\n }\n return null;\n }\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteAsText Force pasting as plain text. Default value is false\n * @param applyCurrentStyle True if apply format of current selection to the pasted content,\n * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored\n * @param pasteAsImage: When set to true, if the clipboardData contains a imageDataUri will paste the image to the editor\n */\n paste(\n clipboardData: ClipboardData,\n pasteAsText: boolean = false,\n applyCurrentFormat: boolean = false,\n pasteAsImage: boolean = false\n ) {\n this.pasteFromClipboard(\n clipboardData,\n pasteAsText\n ? 'asPlainText'\n : applyCurrentFormat\n ? 'mergeFormat'\n : pasteAsImage\n ? 'asImage'\n : 'normal'\n );\n }\n\n //#endregion\n\n //#region Focus and Selection\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRange(tryGetFromCache: boolean = true): Range | null {\n const selection = this.getDOMSelection();\n\n return selection?.type == 'range' ? selection.range : null;\n }\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRangeEx(): SelectionRangeEx {\n const selection = this.getDOMSelection();\n\n return convertDomSelectionToRangeEx(selection);\n }\n\n /**\n * Get current selection in a serializable format\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @returns current selection path, or null if editor never got focus before\n */\n getSelectionPath(): SelectionPath | null {\n const range = this.getSelectionRange();\n return range && getSelectionPath(this.getCore().contentDiv, range);\n }\n\n select(\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 const core = this.getCore();\n const rangeEx = buildRangeEx(core.contentDiv, arg1, arg2, arg3, arg4);\n const selection = convertRangeExToDomSelection(rangeEx);\n\n this.setDOMSelection(selection);\n return true;\n }\n\n /**\n * Get current focused position. Return null if editor doesn't have focus at this time.\n */\n getFocusedPosition(): NodePosition | null {\n const sel = this.getDocument().defaultView?.getSelection();\n if (sel?.focusNode && this.contains(sel.focusNode)) {\n return new Position(sel.focusNode, sel.focusOffset);\n }\n\n const range = this.getSelectionRange();\n if (range) {\n return Position.getStart(range);\n }\n\n return null;\n }\n\n /**\n * Get an HTML element from current cursor position.\n * When expectedTags is not specified, return value is the current node (if it is HTML element)\n * or its parent node (if current node is a Text node).\n * When expectedTags is specified, return value is the first ancestor of current node which has\n * one of the expected tags.\n * If no element found within editor by the given tag, return null.\n * @param selector Optional, an HTML selector to find HTML element with.\n * @param startFrom Start search from this node. If not specified, start from current focused position\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n */\n getElementAtCursor(\n selector?: string,\n startFrom?: Node,\n event?: PluginEvent\n ): HTMLElement | null {\n event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result\n\n return (\n cacheGetEventData(event ?? null, 'GET_ELEMENT_AT_CURSOR_' + selector, () => {\n if (!startFrom) {\n const position = this.getFocusedPosition();\n startFrom = position?.node;\n }\n return (\n startFrom &&\n findClosestElementAncestor(startFrom, this.getCore().contentDiv, selector)\n );\n }) ?? null\n );\n }\n\n /**\n * Check if this position is at beginning of the editor.\n * This will return true if all nodes between the beginning of target node and the position are empty.\n * @param position The position to check\n * @returns True if position is at beginning of the editor, otherwise false\n */\n isPositionAtBeginning(position: NodePosition): boolean {\n return isPositionAtBeginningOf(position, this.getCore().contentDiv);\n }\n\n /**\n * Get impacted regions from selection\n */\n getSelectedRegions(type: RegionType | CompatibleRegionType = RegionType.Table): Region[] {\n const selection = this.getSelectionRangeEx();\n const result: Region[] = [];\n const contentDiv = this.getCore().contentDiv;\n selection.ranges.forEach(range => {\n result.push(...(range ? getRegionsFromRange(contentDiv, range, type) : []));\n });\n return result.filter((value, index, self) => {\n return self.indexOf(value) === index;\n });\n }\n\n //#endregion\n\n //#region EVENT API\n\n addDomEventHandler(\n nameOrMap: string | Record<string, DOMEventHandler>,\n handler?: DOMEventHandler\n ): () => void {\n const eventsMap = typeof nameOrMap == 'string' ? { [nameOrMap]: handler! } : nameOrMap;\n const eventsMapResult: Record<string, DOMEventRecord> = {};\n\n getObjectKeys(eventsMap).forEach(key => {\n const handlerObj = eventsMap[key];\n let result: DOMEventRecord = {\n pluginEventType: null,\n beforeDispatch: null,\n };\n\n if (typeof handlerObj === 'number') {\n result.pluginEventType = OldEventTypeToNewEventType[handlerObj as PluginEventType];\n } else if (typeof handlerObj === 'function') {\n result.beforeDispatch = handlerObj;\n } else if (typeof handlerObj === 'object') {\n const record = handlerObj as DOMEventHandlerObject;\n result = {\n beforeDispatch: record.beforeDispatch,\n pluginEventType:\n typeof record.pluginEventType == 'number'\n ? OldEventTypeToNewEventType[record.pluginEventType]\n : undefined,\n };\n }\n\n eventsMapResult[key] = result;\n });\n\n return this.attachDomEvent(eventsMapResult);\n }\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 public triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const oldEvent = {\n eventType,\n ...data,\n } as PluginEvent;\n const newEvent = oldEventToNewEvent(oldEvent);\n const core = this.getCore();\n\n if (newEvent) {\n core.api.triggerEvent(core, newEvent, broadcast);\n return (newEventToOldEvent(newEvent, oldEvent) ?? oldEvent) as PluginEventFromType<T>;\n } else {\n return oldEvent as PluginEventFromType<T>;\n }\n }\n\n /**\n * Trigger a ContentChangedEvent\n * @param source Source of this event, by default is 'SetContent'\n * @param data additional data for this event\n */\n triggerContentChangedEvent(\n source: ChangeSource | CompatibleChangeSource | string = ChangeSource.SetContent,\n data?: any\n ) {\n this.triggerPluginEvent(PluginEventType.ContentChanged, {\n source,\n data,\n });\n }\n\n //#endregion\n\n //#region Undo API\n\n /**\n * Undo last edit operation\n */\n undo() {\n undo(this);\n }\n\n /**\n * Redo next edit operation\n */\n redo() {\n redo(this);\n }\n\n /**\n * Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger\n * ContentChangedEvent with given change source.\n * If this function is called nested, undo snapshot will only be added in the outside one\n * @param callback The callback function to perform formatting, returns a data object which will be used as\n * the data field in ContentChangedEvent if changeSource is not null.\n * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,\n * a ContentChangedEvent will be fired with change source equal to this value\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n */\n addUndoSnapshot(\n callback?: (start: NodePosition | null, end: NodePosition | null) => any,\n changeSource?: ChangeSource | CompatibleChangeSource | string,\n canUndoByBackspace?: boolean,\n additionalData?: ContentChangedData\n ) {\n const core = this.getCore();\n const undoState = core.undo;\n const isNested = undoState.isNested;\n let data: any;\n\n if (!isNested) {\n undoState.isNested = true;\n\n // When there is getEntityState, it means this is triggered by an entity change.\n // So if HTML content is not changed (hasNewContent is false), no need to add another snapshot before change\n if (\n core.undo.snapshotsManager.hasNewContent ||\n !additionalData?.getEntityState ||\n !callback\n ) {\n core.api.addUndoSnapshot(\n core,\n !!canUndoByBackspace,\n additionalData?.getEntityState?.()\n );\n }\n }\n\n try {\n if (callback) {\n const selection = core.api.getDOMSelection(core);\n const range = selection?.type == 'range' ? selection.range : null;\n data = callback(\n range && Position.getStart(range).normalize(),\n range && Position.getEnd(range).normalize()\n );\n\n if (!isNested) {\n const entityStates = additionalData?.getEntityState?.();\n\n core.api.addUndoSnapshot(core, false /*isAutoCompleteSnapshot*/, entityStates);\n }\n }\n } finally {\n if (!isNested) {\n undoState.isNested = false;\n }\n }\n\n if (callback && changeSource) {\n const event: ContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n source: changeSource,\n data: data,\n additionalData,\n };\n this.triggerPluginEvent(PluginEventType.ContentChanged, event, true /*broadcast*/);\n }\n\n if (canUndoByBackspace) {\n const selection = core.api.getDOMSelection(core);\n\n if (selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n }\n }\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState {\n const { snapshotsManager } = this.getCore().undo;\n return {\n canUndo:\n snapshotsManager.hasNewContent || snapshotsManager.canMove(-1 /*previousSnapshot*/),\n canRedo: snapshotsManager.canMove(1 /*nextSnapshot*/),\n };\n }\n\n //#endregion\n\n //#region Misc\n\n /**\n * Get custom data related to this editor\n * @param key Key of the custom data\n * @param getter Getter function. If custom data for the given key doesn't exist,\n * call this function to get one and store it if it is specified. Otherwise return undefined\n * @param disposer An optional disposer function to dispose this custom data when\n * dispose editor.\n */\n getCustomData<T>(key: string, getter?: () => T, disposer?: (value: T) => void): T {\n const core = this.getContentModelEditorCore();\n return (core.customData[key] = core.customData[key] || {\n value: getter ? getter() : undefined,\n disposer,\n }).value as T;\n }\n\n /**\n * Get default format of this editor\n * @returns Default format object of this editor\n */\n getDefaultFormat(): DefaultFormat {\n const format = this.getCore().format.defaultFormat;\n\n return {\n bold: isBold(format.fontWeight),\n italic: format.italic,\n underline: format.underline,\n fontFamily: format.fontFamily,\n fontSize: format.fontSize,\n textColor: format.textColor,\n backgroundColor: format.backgroundColor,\n };\n }\n\n /**\n * Get a content traverser for the whole editor\n * @param startNode The node to start from. If not passed, it will start from the beginning of the body\n */\n getBodyTraverser(startNode?: Node): IContentTraverser {\n return ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);\n }\n\n /**\n * Get a content traverser for current selection\n * @returns A content traverser, or null if editor never got focus before\n */\n getSelectionTraverser(range?: Range): IContentTraverser | null {\n range = range ?? this.getSelectionRange() ?? undefined;\n return range\n ? ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)\n : null;\n }\n\n /**\n * Get a content traverser for current block element start from specified position\n * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart\n * @returns A content traverser, or null if editor never got focus before\n */\n getBlockTraverser(\n startFrom: ContentPosition | CompatibleContentPosition = ContentPosition.SelectionStart\n ): IContentTraverser | null {\n const range = this.getSelectionRange();\n return range\n ? ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)\n : null;\n }\n\n /**\n * Get a text traverser of current selection\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n * @returns A content traverser, or null if editor never got focus before\n */\n getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null {\n return cacheGetEventData(event ?? null, 'ContentSearcher', () => {\n const range = this.getSelectionRange();\n return (\n range &&\n new PositionContentSearcher(this.getCore().contentDiv, Position.getStart(range))\n );\n });\n }\n\n /**\n * Run a callback function asynchronously\n * @param callback The callback function to run\n * @returns a function to cancel this async run\n */\n runAsync(callback: (editor: IEditor & IStandaloneEditor) => void) {\n const win = this.getCore().contentDiv.ownerDocument.defaultView || window;\n const handle = win.requestAnimationFrame(() => {\n if (!this.isDisposed() && callback) {\n callback(this);\n }\n });\n\n return () => {\n win.cancelAnimationFrame(handle);\n };\n }\n\n /**\n * Set DOM attribute of editor content DIV\n * @param name Name of the attribute\n * @param value Value of the attribute\n */\n setEditorDomAttribute(name: string, value: string | null) {\n this.getDOMHelper().setDomAttribute(name, value);\n }\n\n /**\n * Get DOM attribute of editor content DIV, null if there is no such attribute.\n * @param name Name of the attribute\n */\n getEditorDomAttribute(name: string): string | null {\n return this.getDOMHelper().getDomAttribute(name);\n }\n\n /**\n * @deprecated Use getVisibleViewport() instead.\n *\n * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.\n * @param element The element to calculate from. If the given element is not in editor, return value will be null\n * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value\n * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.\n * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.\n */\n getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null {\n if (this.contains(element)) {\n const contentDiv = this.getCore().contentDiv;\n const editorRect = contentDiv.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (editorRect && elementRect) {\n let x = elementRect.left - editorRect?.left;\n let y = elementRect.top - editorRect?.top;\n\n if (addScroll) {\n x += contentDiv.scrollLeft;\n y += contentDiv.scrollTop;\n }\n\n return [x, y];\n }\n }\n\n return null;\n }\n\n /**\n * Add a Content Edit feature.\n * @param feature The feature to add\n */\n addContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const array = core.edit.features[key] || [];\n array.push(feature);\n core.edit.features[key] = array;\n });\n }\n\n /**\n * Remove a Content Edit feature.\n * @param feature The feature to remove\n */\n removeContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const featureSet = core.edit.features[key];\n const index = featureSet?.indexOf(feature) ?? -1;\n if (index >= 0) {\n core.edit.features[key].splice(index, 1);\n if (core.edit.features[key].length < 1) {\n delete core.edit.features[key];\n }\n }\n });\n }\n\n /**\n * @deprecated\n * Get style based format state from current selection, including font name/size and colors\n */\n getStyleBasedFormatState(): StyleBasedFormatState {\n const format = this.retrieveFormatState();\n\n return {\n backgroundColor: format.backgroundColor,\n direction: format.direction,\n fontName: format.fontName,\n fontSize: format.fontSize,\n fontWeight: format.fontWeight,\n lineHeight: format.lineHeight,\n marginBottom: format.marginBottom,\n marginTop: format.marginTop,\n textAlign: format.textAlign,\n textColor: format.textColor,\n };\n }\n\n /**\n * @deprecated\n * Get the pendable format such as underline and bold\n * @returns The pending format state\n */\n getPendableFormatState(): PendableFormatState {\n const format = this.retrieveFormatState();\n\n return {\n isBold: format.isBold,\n isItalic: format.isItalic,\n isStrikeThrough: format.isStrikeThrough,\n isSubscript: format.isSubscript,\n isSuperscript: format.isSubscript,\n isUnderline: format.isUnderline,\n };\n }\n\n /**\n * @deprecated\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n */\n ensureTypeInContainer(position: NodePosition, keyboardEvent?: KeyboardEvent) {\n // No OP\n }\n\n //#endregion\n\n //#region Dark mode APIs\n\n /**\n * Transform the given node and all its child nodes to dark mode color if editor is in dark mode\n * @param node The node to transform\n * @param direction The transform direction. @default ColorTransformDirection.LightToDark\n */\n transformToDarkColor(\n node: Node,\n direction:\n | ColorTransformDirection\n | CompatibleColorTransformDirection = ColorTransformDirection.LightToDark\n ) {\n const core = this.getCore();\n\n if (core.lifecycle.isDarkMode) {\n transformColor(\n node,\n true /*includeSelf*/,\n direction == ColorTransformDirection.DarkToLight ? 'darkToLight' : 'lightToDark',\n core.darkColorHandler\n );\n }\n }\n\n /**\n * Check if the given experimental feature is enabled\n * @param feature The feature to check\n */\n isFeatureEnabled(feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean {\n return (\n this.getContentModelEditorCore().experimentalFeatures.indexOf(\n feature as ExperimentalFeatures\n ) >= 0\n );\n }\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 return this.getDOMHelper().calculateZoomScale();\n }\n\n /**\n * Set 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 * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.\n */\n setZoomScale(scale: number): void {\n if (scale > 0 && scale <= 10) {\n const oldValue = this.getZoomScale();\n\n if (oldValue != scale) {\n this.triggerEvent(\n 'zoomChanged',\n {\n newZoomScale: scale,\n },\n true /*broadcast*/\n );\n }\n }\n }\n\n /**\n * @deprecated Use getZoomScale() instead\n */\n getSizeTransformer(): SizeTransformer {\n return this.getContentModelEditorCore().sizeTransformer;\n }\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler {\n const core = this.getContentModelEditorCore();\n return core.darkColorHandler;\n }\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 return this.getCore().domEvent.isInIME;\n }\n\n private retrieveFormatState(): ContentModelFormatState {\n const pendingFormat = this.getPendingFormat();\n const result: ContentModelFormatState = {};\n const model = this.getContentModelCopy('reduced');\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n }\n\n /**\n * @returns the current EditorAdapterCore object\n * @throws a standard Error if there's no core object\n */\n private getContentModelEditorCore(): EditorAdapterCore {\n if (!this.contentModelEditorCore) {\n throw new Error('Editor is already disposed');\n }\n\n return this.contentModelEditorCore;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EditorAdapter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/editor/EditorAdapter.ts"],"names":[],"mappings":";;;;;IAmGA,IAAM,iBAAiB;QACnB,wBAA4B,MAAM;QAClC,wBAA4B,WAAW;QACvC,4BAAgC,eAAe;QAC/C,0BAA8B,MAAM;QACpC,mCAAuC,MAAM;WAChD,CAAC;IAEF;;;OAGG;IACH;QAAmC,8CAAgB;QAG/C;;;;WAIG;QACH,uBAAY,UAA0B,EAAE,OAAk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IAAI,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC,gBAAgB,CAAC;QACjC,CAAC;QAED;;;WAGG;QACH,+BAAO,GAAP;YACI,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC3C,CAAC;QAEO,2CAAmB,GAA3B;YACI,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9C,IAAM,MAAM,GAA4B,EAAE,CAAC;YAC3C,IAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAElD,IAAA,uDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;YAEvD,OAAO,MAAM,CAAC;QAClB,CAAC;QAED;;;WAGG;QACK,iDAAyB,GAAjC;YACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;gBAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;aACjD;YAED,OAAO,IAAI,CAAC,sBAAsB,CAAC;QACvC,CAAC;QACL,oBAAC;IAAD,CAAC,AA9/BD,CAAmC,+CAAgB,GA8/BlD;IA9/BY,sCAAa","sourcesContent":["import { BridgePlugin } from '../corePlugins/BridgePlugin';\nimport { buildRangeEx } from './utils/buildRangeEx';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { insertNode } from './utils/insertNode';\nimport type { EditorAdapterCore } from '../corePlugins/BridgePlugin';\nimport {\n newEventToOldEvent,\n oldEventToNewEvent,\n OldEventTypeToNewEventType,\n} from './utils/eventConverter';\nimport {\n createModelFromHtml,\n exportContent,\n isBold,\n redo,\n retrieveModelFormatState,\n StandaloneEditor,\n transformColor,\n undo,\n} from 'roosterjs-content-model-core';\nimport {\n ChangeSource,\n ColorTransformDirection,\n ContentPosition,\n GetContentMode,\n PluginEventType,\n QueryScope,\n RegionType,\n} from 'roosterjs-editor-types';\nimport type {\n BlockElement,\n ClipboardData,\n ContentChangedData,\n ContentChangedEvent,\n DOMEventHandler,\n DefaultFormat,\n EditorUndoState,\n ExperimentalFeatures,\n GenericContentEditFeature,\n IContentTraverser,\n IPositionContentSearcher,\n InsertOption,\n NodePosition,\n PendableFormatState,\n PluginEvent,\n PluginEventData,\n PluginEventFromType,\n PositionType,\n Region,\n SelectionPath,\n SelectionRangeEx,\n SizeTransformer,\n StyleBasedFormatState,\n TableSelection,\n DOMEventHandlerObject,\n DarkColorHandler,\n IEditor,\n} from 'roosterjs-editor-types';\nimport {\n convertDomSelectionToRangeEx,\n convertRangeExToDomSelection,\n} from './utils/selectionConverter';\nimport type {\n CompatibleChangeSource,\n CompatibleColorTransformDirection,\n CompatibleContentPosition,\n CompatibleExperimentalFeatures,\n CompatibleGetContentMode,\n CompatiblePluginEventType,\n CompatibleQueryScope,\n CompatibleRegionType,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport {\n ContentTraverser,\n Position,\n PositionContentSearcher,\n cacheGetEventData,\n collapseNodes,\n contains,\n deleteSelectedContent,\n findClosestElementAncestor,\n getBlockElementAtNode,\n getRegionsFromRange,\n getSelectionPath,\n isNodeEmpty,\n isPositionAtBeginningOf,\n queryElements,\n toArray,\n wrap,\n} from 'roosterjs-editor-dom';\nimport type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';\nimport type {\n ContentModelFormatState,\n DOMEventRecord,\n ExportContentMode,\n IStandaloneEditor,\n StandaloneEditorOptions,\n} from 'roosterjs-content-model-types';\n\nconst GetContentModeMap: Record<GetContentMode, ExportContentMode> = {\n [GetContentMode.CleanHTML]: 'HTML',\n [GetContentMode.PlainText]: 'PlainText',\n [GetContentMode.PlainTextFast]: 'PlainTextFast',\n [GetContentMode.RawHTMLOnly]: 'HTML',\n [GetContentMode.RawHTMLWithSelection]: 'HTML',\n};\n\n/**\n * Editor for Content Model.\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class EditorAdapter extends StandaloneEditor implements IEditor {\n private contentModelEditorCore: EditorAdapterCore | undefined;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorAdapterOptions = {}) {\n const bridgePlugin = new BridgePlugin(\n core => {\n this.contentModelEditorCore = core;\n\n return this;\n },\n options.legacyPlugins,\n options.experimentalFeatures\n );\n\n const plugins = [bridgePlugin, ...(options.plugins ?? [])];\n const initContent = options.initialContent ?? contentDiv.innerHTML;\n const initialModel =\n initContent && !options.initialModel\n ? createModelFromHtml(\n initContent,\n options.defaultDomToModelOptions,\n options.trustedHTMLHandler,\n options.defaultSegmentFormat\n )\n : options.initialModel;\n const standaloneEditorOptions: StandaloneEditorOptions = {\n ...options,\n plugins,\n initialModel,\n };\n\n super(contentDiv, standaloneEditorOptions);\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void {\n super.dispose();\n\n const core = this.contentModelEditorCore;\n\n if (core) {\n getObjectKeys(core.customData).forEach(key => {\n const data = core.customData[key];\n\n if (data && data.disposer) {\n data.disposer(data.value);\n }\n\n delete core.customData[key];\n });\n\n this.contentModelEditorCore = undefined;\n }\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return super.isDisposed() || !this.contentModelEditorCore;\n }\n\n /**\n * Insert node into editor\n * @param node The node to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n * @returns true if node is inserted. Otherwise false\n */\n insertNode(node: Node, option?: InsertOption): boolean {\n if (node) {\n option = option || {\n position: ContentPosition.SelectionStart,\n insertOnNewLine: false,\n updateCursor: true,\n replaceSelection: true,\n insertToRegionRoot: false,\n };\n\n const { contentDiv } = this.getCore();\n\n if (option.updateCursor) {\n this.focus();\n }\n\n if (option.position == ContentPosition.Outside) {\n contentDiv.parentNode?.insertBefore(node, contentDiv.nextSibling);\n } else {\n if (this.isDarkMode()) {\n transformColor(\n node,\n true /*includeSelf*/,\n 'lightToDark',\n this.getColorManager()\n );\n }\n\n const selection = insertNode(contentDiv, this.getDOMSelection(), node, option);\n\n if (selection && option.updateCursor) {\n this.setDOMSelection(selection);\n }\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Delete a node from editor content\n * @param node The node to delete\n * @returns true if node is deleted. Otherwise false\n */\n deleteNode(node: Node): boolean {\n // Only remove the node when it falls within editor\n if (node && this.contains(node) && node.parentNode) {\n node.parentNode.removeChild(node);\n return true;\n }\n\n return false;\n }\n\n /**\n * Replace a node in editor content with another node\n * @param existingNode The existing node to be replaced\n * @param toNode node to replace to\n * @param transformColorForDarkMode (optional) Whether to transform new node to dark mode. Default is false\n * @returns true if node is replaced. Otherwise false\n */\n replaceNode(existingNode: Node, toNode: Node, transformColorForDarkMode?: boolean): boolean {\n const core = this.getCore();\n // Only replace the node when it falls within editor\n if (this.contains(existingNode) && toNode) {\n if (core.lifecycle.isDarkMode && transformColorForDarkMode) {\n this.transformToDarkColor(toNode, ColorTransformDirection.LightToDark);\n }\n\n existingNode.parentNode?.replaceChild(toNode, existingNode);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Get BlockElement at given node\n * @param node The node to create InlineElement\n * @returns The BlockElement result\n */\n getBlockElementAtNode(node: Node): BlockElement | null {\n return getBlockElementAtNode(this.getCore().contentDiv, node);\n }\n\n contains(arg: Node | Range | null): boolean {\n if (!arg) {\n return false;\n }\n return contains(this.getCore().contentDiv, <Node>arg);\n }\n\n queryElements(\n selector: string,\n scopeOrCallback:\n | QueryScope\n | CompatibleQueryScope\n | ((node: Node) => any) = QueryScope.Body,\n callback?: (node: Node) => any\n ) {\n const core = this.getCore();\n const result: HTMLElement[] = [];\n const scope = scopeOrCallback instanceof Function ? QueryScope.Body : scopeOrCallback;\n callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;\n\n const selectionEx = scope == QueryScope.Body ? null : this.getSelectionRangeEx();\n if (selectionEx) {\n selectionEx.ranges.forEach(range => {\n result.push(...queryElements(core.contentDiv, selector, callback, scope, range));\n });\n } else {\n return queryElements(core.contentDiv, selector, callback, scope, undefined /* range */);\n }\n\n return result;\n }\n\n /**\n * Collapse nodes within the given start and end nodes to their common ancestor node,\n * split parent nodes if necessary\n * @param start The start node\n * @param end The end node\n * @param canSplitParent True to allow split parent node there are nodes before start or after end under the same parent\n * and the returned nodes will be all nodes from start through end after splitting\n * False to disallow split parent\n * @returns When canSplitParent is true, returns all node from start through end after splitting,\n * otherwise just return start and end\n */\n collapseNodes(start: Node, end: Node, canSplitParent: boolean): Node[] {\n return collapseNodes(this.getCore().contentDiv, start, end, canSplitParent);\n }\n\n //#endregion\n\n //#region Content API\n\n /**\n * Check whether the editor contains any visible content\n * @param trim Whether trim the content string before check. Default is false\n * @returns True if there's no visible content, otherwise false\n */\n isEmpty(trim?: boolean): boolean {\n return isNodeEmpty(this.getCore().contentDiv, trim);\n }\n\n /**\n * Get current editor content as HTML string\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent(mode: GetContentMode | CompatibleGetContentMode = GetContentMode.CleanHTML): string {\n return exportContent(\n this,\n GetContentModeMap[mode],\n this.getCore().modelToDomSettings.customized\n );\n }\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent(content: string, triggerContentChangedEvent: boolean = true) {\n const core = this.getCore();\n const { contentDiv, api, trustedHTMLHandler, lifecycle, darkColorHandler } = core;\n\n api.triggerEvent(\n core,\n {\n eventType: 'beforeSetContent',\n newContent: content,\n },\n true /*broadcast*/\n );\n\n const newModel = createModelFromHtml(\n content,\n core.domToModelSettings.customized,\n trustedHTMLHandler,\n core.format.defaultFormat\n );\n\n api.setContentModel(core, newModel);\n\n if (triggerContentChangedEvent) {\n api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: ChangeSource.SetContent,\n },\n false /*broadcast*/\n );\n } else if (lifecycle.isDarkMode) {\n transformColor(contentDiv, false /*includeSelf*/, 'lightToDark', darkColorHandler);\n }\n }\n\n /**\n * Insert HTML content into editor\n * @param HTML content to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n */\n insertContent(content: string, option?: InsertOption) {\n if (content) {\n const doc = this.getDocument();\n const body = new DOMParser().parseFromString(\n this.getCore().trustedHTMLHandler(content),\n 'text/html'\n )?.body;\n let allNodes = body?.childNodes ? toArray(body.childNodes) : [];\n\n // If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with\n // a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped\n // separately to show up on its own line\n if (option && option.insertOnNewLine && allNodes.length > 1) {\n allNodes = [wrap(allNodes)];\n }\n\n const fragment = doc.createDocumentFragment();\n allNodes.forEach(node => fragment.appendChild(node));\n\n this.insertNode(fragment, option);\n }\n }\n\n /**\n * Delete selected content\n */\n deleteSelectedContent(): NodePosition | null {\n const range = this.getSelectionRange();\n if (range && !range.collapsed) {\n return deleteSelectedContent(this.getCore().contentDiv, range);\n }\n return null;\n }\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteAsText Force pasting as plain text. Default value is false\n * @param applyCurrentStyle True if apply format of current selection to the pasted content,\n * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored\n * @param pasteAsImage: When set to true, if the clipboardData contains a imageDataUri will paste the image to the editor\n */\n paste(\n clipboardData: ClipboardData,\n pasteAsText: boolean = false,\n applyCurrentFormat: boolean = false,\n pasteAsImage: boolean = false\n ) {\n this.pasteFromClipboard(\n clipboardData,\n pasteAsText\n ? 'asPlainText'\n : applyCurrentFormat\n ? 'mergeFormat'\n : pasteAsImage\n ? 'asImage'\n : 'normal'\n );\n }\n\n //#endregion\n\n //#region Focus and Selection\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRange(tryGetFromCache: boolean = true): Range | null {\n const selection = this.getDOMSelection();\n\n return selection?.type == 'range' ? selection.range : null;\n }\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRangeEx(): SelectionRangeEx {\n const selection = this.getDOMSelection();\n\n return convertDomSelectionToRangeEx(selection);\n }\n\n /**\n * Get current selection in a serializable format\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @returns current selection path, or null if editor never got focus before\n */\n getSelectionPath(): SelectionPath | null {\n const range = this.getSelectionRange();\n return range && getSelectionPath(this.getCore().contentDiv, range);\n }\n\n select(\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 const core = this.getCore();\n const rangeEx = buildRangeEx(core.contentDiv, arg1, arg2, arg3, arg4);\n const selection = convertRangeExToDomSelection(rangeEx);\n\n this.setDOMSelection(selection);\n return true;\n }\n\n /**\n * Get current focused position. Return null if editor doesn't have focus at this time.\n */\n getFocusedPosition(): NodePosition | null {\n const sel = this.getDocument().defaultView?.getSelection();\n if (sel?.focusNode && this.contains(sel.focusNode)) {\n return new Position(sel.focusNode, sel.focusOffset);\n }\n\n const range = this.getSelectionRange();\n if (range) {\n return Position.getStart(range);\n }\n\n return null;\n }\n\n /**\n * Get an HTML element from current cursor position.\n * When expectedTags is not specified, return value is the current node (if it is HTML element)\n * or its parent node (if current node is a Text node).\n * When expectedTags is specified, return value is the first ancestor of current node which has\n * one of the expected tags.\n * If no element found within editor by the given tag, return null.\n * @param selector Optional, an HTML selector to find HTML element with.\n * @param startFrom Start search from this node. If not specified, start from current focused position\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n */\n getElementAtCursor(\n selector?: string,\n startFrom?: Node,\n event?: PluginEvent\n ): HTMLElement | null {\n event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result\n\n return (\n cacheGetEventData(event ?? null, 'GET_ELEMENT_AT_CURSOR_' + selector, () => {\n if (!startFrom) {\n const position = this.getFocusedPosition();\n startFrom = position?.node;\n }\n return (\n startFrom &&\n findClosestElementAncestor(startFrom, this.getCore().contentDiv, selector)\n );\n }) ?? null\n );\n }\n\n /**\n * Check if this position is at beginning of the editor.\n * This will return true if all nodes between the beginning of target node and the position are empty.\n * @param position The position to check\n * @returns True if position is at beginning of the editor, otherwise false\n */\n isPositionAtBeginning(position: NodePosition): boolean {\n return isPositionAtBeginningOf(position, this.getCore().contentDiv);\n }\n\n /**\n * Get impacted regions from selection\n */\n getSelectedRegions(type: RegionType | CompatibleRegionType = RegionType.Table): Region[] {\n const selection = this.getSelectionRangeEx();\n const result: Region[] = [];\n const contentDiv = this.getCore().contentDiv;\n selection.ranges.forEach(range => {\n result.push(...(range ? getRegionsFromRange(contentDiv, range, type) : []));\n });\n return result.filter((value, index, self) => {\n return self.indexOf(value) === index;\n });\n }\n\n //#endregion\n\n //#region EVENT API\n\n addDomEventHandler(\n nameOrMap: string | Record<string, DOMEventHandler>,\n handler?: DOMEventHandler\n ): () => void {\n const eventsMap = typeof nameOrMap == 'string' ? { [nameOrMap]: handler! } : nameOrMap;\n const eventsMapResult: Record<string, DOMEventRecord> = {};\n\n getObjectKeys(eventsMap).forEach(key => {\n const handlerObj = eventsMap[key];\n let result: DOMEventRecord = {\n pluginEventType: null,\n beforeDispatch: null,\n };\n\n if (typeof handlerObj === 'number') {\n result.pluginEventType = OldEventTypeToNewEventType[handlerObj as PluginEventType];\n } else if (typeof handlerObj === 'function') {\n result.beforeDispatch = handlerObj;\n } else if (typeof handlerObj === 'object') {\n const record = handlerObj as DOMEventHandlerObject;\n result = {\n beforeDispatch: record.beforeDispatch,\n pluginEventType:\n typeof record.pluginEventType == 'number'\n ? OldEventTypeToNewEventType[record.pluginEventType]\n : undefined,\n };\n }\n\n eventsMapResult[key] = result;\n });\n\n return this.attachDomEvent(eventsMapResult);\n }\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 public triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const oldEvent = {\n eventType,\n ...data,\n } as PluginEvent;\n const newEvent = oldEventToNewEvent(oldEvent);\n const core = this.getCore();\n\n if (newEvent) {\n core.api.triggerEvent(core, newEvent, broadcast);\n return (newEventToOldEvent(newEvent, oldEvent) ?? oldEvent) as PluginEventFromType<T>;\n } else {\n return oldEvent as PluginEventFromType<T>;\n }\n }\n\n /**\n * Trigger a ContentChangedEvent\n * @param source Source of this event, by default is 'SetContent'\n * @param data additional data for this event\n */\n triggerContentChangedEvent(\n source: ChangeSource | CompatibleChangeSource | string = ChangeSource.SetContent,\n data?: any\n ) {\n this.triggerPluginEvent(PluginEventType.ContentChanged, {\n source,\n data,\n });\n }\n\n //#endregion\n\n //#region Undo API\n\n /**\n * Undo last edit operation\n */\n undo() {\n undo(this);\n }\n\n /**\n * Redo next edit operation\n */\n redo() {\n redo(this);\n }\n\n /**\n * Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger\n * ContentChangedEvent with given change source.\n * If this function is called nested, undo snapshot will only be added in the outside one\n * @param callback The callback function to perform formatting, returns a data object which will be used as\n * the data field in ContentChangedEvent if changeSource is not null.\n * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,\n * a ContentChangedEvent will be fired with change source equal to this value\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n */\n addUndoSnapshot(\n callback?: (start: NodePosition | null, end: NodePosition | null) => any,\n changeSource?: ChangeSource | CompatibleChangeSource | string,\n canUndoByBackspace?: boolean,\n additionalData?: ContentChangedData\n ) {\n const core = this.getCore();\n const undoState = core.undo;\n const isNested = undoState.isNested;\n let data: any;\n\n if (!isNested) {\n undoState.isNested = true;\n\n // When there is getEntityState, it means this is triggered by an entity change.\n // So if HTML content is not changed (hasNewContent is false), no need to add another snapshot before change\n if (\n core.undo.snapshotsManager.hasNewContent ||\n !additionalData?.getEntityState ||\n !callback\n ) {\n core.api.addUndoSnapshot(\n core,\n !!canUndoByBackspace,\n additionalData?.getEntityState?.()\n );\n }\n }\n\n try {\n if (callback) {\n const selection = core.api.getDOMSelection(core);\n const range = selection?.type == 'range' ? selection.range : null;\n data = callback(\n range && Position.getStart(range).normalize(),\n range && Position.getEnd(range).normalize()\n );\n\n if (!isNested) {\n const entityStates = additionalData?.getEntityState?.();\n\n core.api.addUndoSnapshot(core, false /*isAutoCompleteSnapshot*/, entityStates);\n }\n }\n } finally {\n if (!isNested) {\n undoState.isNested = false;\n }\n }\n\n if (callback && changeSource) {\n const event: ContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n source: changeSource,\n data: data,\n additionalData,\n };\n this.triggerPluginEvent(PluginEventType.ContentChanged, event, true /*broadcast*/);\n }\n\n if (canUndoByBackspace) {\n const selection = core.api.getDOMSelection(core);\n\n if (selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n }\n }\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState {\n const { snapshotsManager } = this.getCore().undo;\n return {\n canUndo:\n snapshotsManager.hasNewContent || snapshotsManager.canMove(-1 /*previousSnapshot*/),\n canRedo: snapshotsManager.canMove(1 /*nextSnapshot*/),\n };\n }\n\n //#endregion\n\n //#region Misc\n\n /**\n * Get custom data related to this editor\n * @param key Key of the custom data\n * @param getter Getter function. If custom data for the given key doesn't exist,\n * call this function to get one and store it if it is specified. Otherwise return undefined\n * @param disposer An optional disposer function to dispose this custom data when\n * dispose editor.\n */\n getCustomData<T>(key: string, getter?: () => T, disposer?: (value: T) => void): T {\n const core = this.getContentModelEditorCore();\n return (core.customData[key] = core.customData[key] || {\n value: getter ? getter() : undefined,\n disposer,\n }).value as T;\n }\n\n /**\n * Get default format of this editor\n * @returns Default format object of this editor\n */\n getDefaultFormat(): DefaultFormat {\n const format = this.getCore().format.defaultFormat;\n\n return {\n bold: isBold(format.fontWeight),\n italic: format.italic,\n underline: format.underline,\n fontFamily: format.fontFamily,\n fontSize: format.fontSize,\n textColor: format.textColor,\n backgroundColor: format.backgroundColor,\n };\n }\n\n /**\n * Get a content traverser for the whole editor\n * @param startNode The node to start from. If not passed, it will start from the beginning of the body\n */\n getBodyTraverser(startNode?: Node): IContentTraverser {\n return ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);\n }\n\n /**\n * Get a content traverser for current selection\n * @returns A content traverser, or null if editor never got focus before\n */\n getSelectionTraverser(range?: Range): IContentTraverser | null {\n range = range ?? this.getSelectionRange() ?? undefined;\n return range\n ? ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)\n : null;\n }\n\n /**\n * Get a content traverser for current block element start from specified position\n * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart\n * @returns A content traverser, or null if editor never got focus before\n */\n getBlockTraverser(\n startFrom: ContentPosition | CompatibleContentPosition = ContentPosition.SelectionStart\n ): IContentTraverser | null {\n const range = this.getSelectionRange();\n return range\n ? ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)\n : null;\n }\n\n /**\n * Get a text traverser of current selection\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n * @returns A content traverser, or null if editor never got focus before\n */\n getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null {\n return cacheGetEventData(event ?? null, 'ContentSearcher', () => {\n const range = this.getSelectionRange();\n return (\n range &&\n new PositionContentSearcher(this.getCore().contentDiv, Position.getStart(range))\n );\n });\n }\n\n /**\n * Run a callback function asynchronously\n * @param callback The callback function to run\n * @returns a function to cancel this async run\n */\n runAsync(callback: (editor: IEditor & IStandaloneEditor) => void) {\n const win = this.getCore().contentDiv.ownerDocument.defaultView || window;\n const handle = win.requestAnimationFrame(() => {\n if (!this.isDisposed() && callback) {\n callback(this);\n }\n });\n\n return () => {\n win.cancelAnimationFrame(handle);\n };\n }\n\n /**\n * Set DOM attribute of editor content DIV\n * @param name Name of the attribute\n * @param value Value of the attribute\n */\n setEditorDomAttribute(name: string, value: string | null) {\n this.getDOMHelper().setDomAttribute(name, value);\n }\n\n /**\n * Get DOM attribute of editor content DIV, null if there is no such attribute.\n * @param name Name of the attribute\n */\n getEditorDomAttribute(name: string): string | null {\n return this.getDOMHelper().getDomAttribute(name);\n }\n\n /**\n * @deprecated Use getVisibleViewport() instead.\n *\n * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.\n * @param element The element to calculate from. If the given element is not in editor, return value will be null\n * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value\n * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.\n * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.\n */\n getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null {\n if (this.contains(element)) {\n const contentDiv = this.getCore().contentDiv;\n const editorRect = contentDiv.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (editorRect && elementRect) {\n let x = elementRect.left - editorRect?.left;\n let y = elementRect.top - editorRect?.top;\n\n if (addScroll) {\n x += contentDiv.scrollLeft;\n y += contentDiv.scrollTop;\n }\n\n return [x, y];\n }\n }\n\n return null;\n }\n\n /**\n * Add a Content Edit feature.\n * @param feature The feature to add\n */\n addContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const array = core.edit.features[key] || [];\n array.push(feature);\n core.edit.features[key] = array;\n });\n }\n\n /**\n * Remove a Content Edit feature.\n * @param feature The feature to remove\n */\n removeContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const featureSet = core.edit.features[key];\n const index = featureSet?.indexOf(feature) ?? -1;\n if (index >= 0) {\n core.edit.features[key].splice(index, 1);\n if (core.edit.features[key].length < 1) {\n delete core.edit.features[key];\n }\n }\n });\n }\n\n /**\n * @deprecated\n * Get style based format state from current selection, including font name/size and colors\n */\n getStyleBasedFormatState(): StyleBasedFormatState {\n const format = this.retrieveFormatState();\n\n return {\n backgroundColor: format.backgroundColor,\n direction: format.direction,\n fontName: format.fontName,\n fontSize: format.fontSize,\n fontWeight: format.fontWeight,\n lineHeight: format.lineHeight,\n marginBottom: format.marginBottom,\n marginTop: format.marginTop,\n textAlign: format.textAlign,\n textColor: format.textColor,\n };\n }\n\n /**\n * @deprecated\n * Get the pendable format such as underline and bold\n * @returns The pending format state\n */\n getPendableFormatState(): PendableFormatState {\n const format = this.retrieveFormatState();\n\n return {\n isBold: format.isBold,\n isItalic: format.isItalic,\n isStrikeThrough: format.isStrikeThrough,\n isSubscript: format.isSubscript,\n isSuperscript: format.isSubscript,\n isUnderline: format.isUnderline,\n };\n }\n\n /**\n * @deprecated\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n */\n ensureTypeInContainer(position: NodePosition, keyboardEvent?: KeyboardEvent) {\n // No OP\n }\n\n //#endregion\n\n //#region Dark mode APIs\n\n /**\n * Transform the given node and all its child nodes to dark mode color if editor is in dark mode\n * @param node The node to transform\n * @param direction The transform direction. @default ColorTransformDirection.LightToDark\n */\n transformToDarkColor(\n node: Node,\n direction:\n | ColorTransformDirection\n | CompatibleColorTransformDirection = ColorTransformDirection.LightToDark\n ) {\n const core = this.getCore();\n\n if (core.lifecycle.isDarkMode) {\n transformColor(\n node,\n true /*includeSelf*/,\n direction == ColorTransformDirection.DarkToLight ? 'darkToLight' : 'lightToDark',\n core.darkColorHandler\n );\n }\n }\n\n /**\n * Check if the given experimental feature is enabled\n * @param feature The feature to check\n */\n isFeatureEnabled(feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean {\n return (\n this.getContentModelEditorCore().experimentalFeatures.indexOf(\n feature as ExperimentalFeatures\n ) >= 0\n );\n }\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 return this.getDOMHelper().calculateZoomScale();\n }\n\n /**\n * Set 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 * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.\n */\n setZoomScale(scale: number): void {\n if (scale > 0 && scale <= 10) {\n const oldValue = this.getZoomScale();\n\n if (oldValue != scale) {\n this.triggerEvent(\n 'zoomChanged',\n {\n newZoomScale: scale,\n },\n true /*broadcast*/\n );\n }\n }\n }\n\n /**\n * @deprecated Use getZoomScale() instead\n */\n getSizeTransformer(): SizeTransformer {\n return this.getContentModelEditorCore().sizeTransformer;\n }\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler {\n const core = this.getContentModelEditorCore();\n return core.darkColorHandler;\n }\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 return this.getCore().domEvent.isInIME;\n }\n\n private retrieveFormatState(): ContentModelFormatState {\n const pendingFormat = this.getPendingFormat();\n const result: ContentModelFormatState = {};\n const model = this.getContentModelCopy('reduced');\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n }\n\n /**\n * @returns the current EditorAdapterCore object\n * @throws a standard Error if there's no core object\n */\n private getContentModelEditorCore(): EditorAdapterCore {\n if (!this.contentModelEditorCore) {\n throw new Error('Editor is already disposed');\n }\n\n return this.contentModelEditorCore;\n }\n}\n"]}
|
|
@@ -47,6 +47,7 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
47
47
|
* Dispose this editor, dispose all plugins and custom data
|
|
48
48
|
*/
|
|
49
49
|
EditorAdapter.prototype.dispose = function () {
|
|
50
|
+
_super.prototype.dispose.call(this);
|
|
50
51
|
var core = this.contentModelEditorCore;
|
|
51
52
|
if (core) {
|
|
52
53
|
getObjectKeys(core.customData).forEach(function (key) {
|
|
@@ -58,7 +59,6 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
58
59
|
});
|
|
59
60
|
this.contentModelEditorCore = undefined;
|
|
60
61
|
}
|
|
61
|
-
_super.prototype.dispose.call(this);
|
|
62
62
|
};
|
|
63
63
|
/**
|
|
64
64
|
* Get whether this editor is disposed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorAdapter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/editor/EditorAdapter.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,GAC7B,MAAM,wB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AQ,IAAI,KAAK,EAAE;gBACnB,IAAI,CAAC,YAAY,CACb,aAAa,EACb;oBACI,YAAY,EAAE,KAAK;iBACtB,EACD,IAAI,CAAC,aAAa,CACrB,CAAC;aACL;SACJ;IACL,CAAC;IAED;;OAEG;IACH,0CAAkB,GAAlB;QACI,OAAO,IAAI,CAAC,yBAAyB,EAAE,CAAC,eAAe,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,2CAAmB,GAAnB;QACI,IAAM,IAAI,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,+BAAO,GAAP;QACI,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3C,CAAC;IAEO,2CAAmB,GAA3B;QACI,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,IAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,IAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAElD,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,iDAAyB,GAAjC;QACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QAED,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IACL,oBAAC;AAAD,CAAC,AA9/BD,CAAmC,gBAAgB,GA8/BlD","sourcesContent":["import { BridgePlugin } from '../corePlugins/BridgePlugin';\nimport { buildRangeEx } from './utils/buildRangeEx';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { insertNode } from './utils/insertNode';\nimport type { EditorAdapterCore } from '../corePlugins/BridgePlugin';\nimport {\n newEventToOldEvent,\n oldEventToNewEvent,\n OldEventTypeToNewEventType,\n} from './utils/eventConverter';\nimport {\n createModelFromHtml,\n exportContent,\n isBold,\n redo,\n retrieveModelFormatState,\n StandaloneEditor,\n transformColor,\n undo,\n} from 'roosterjs-content-model-core';\nimport {\n ChangeSource,\n ColorTransformDirection,\n ContentPosition,\n GetContentMode,\n PluginEventType,\n QueryScope,\n RegionType,\n} from 'roosterjs-editor-types';\nimport type {\n BlockElement,\n ClipboardData,\n ContentChangedData,\n ContentChangedEvent,\n DOMEventHandler,\n DefaultFormat,\n EditorUndoState,\n ExperimentalFeatures,\n GenericContentEditFeature,\n IContentTraverser,\n IPositionContentSearcher,\n InsertOption,\n NodePosition,\n PendableFormatState,\n PluginEvent,\n PluginEventData,\n PluginEventFromType,\n PositionType,\n Region,\n SelectionPath,\n SelectionRangeEx,\n SizeTransformer,\n StyleBasedFormatState,\n TableSelection,\n DOMEventHandlerObject,\n DarkColorHandler,\n IEditor,\n} from 'roosterjs-editor-types';\nimport {\n convertDomSelectionToRangeEx,\n convertRangeExToDomSelection,\n} from './utils/selectionConverter';\nimport type {\n CompatibleChangeSource,\n CompatibleColorTransformDirection,\n CompatibleContentPosition,\n CompatibleExperimentalFeatures,\n CompatibleGetContentMode,\n CompatiblePluginEventType,\n CompatibleQueryScope,\n CompatibleRegionType,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport {\n ContentTraverser,\n Position,\n PositionContentSearcher,\n cacheGetEventData,\n collapseNodes,\n contains,\n deleteSelectedContent,\n findClosestElementAncestor,\n getBlockElementAtNode,\n getRegionsFromRange,\n getSelectionPath,\n isNodeEmpty,\n isPositionAtBeginningOf,\n queryElements,\n toArray,\n wrap,\n} from 'roosterjs-editor-dom';\nimport type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';\nimport type {\n ContentModelFormatState,\n DOMEventRecord,\n ExportContentMode,\n IStandaloneEditor,\n StandaloneEditorOptions,\n} from 'roosterjs-content-model-types';\n\nconst GetContentModeMap: Record<GetContentMode, ExportContentMode> = {\n [GetContentMode.CleanHTML]: 'HTML',\n [GetContentMode.PlainText]: 'PlainText',\n [GetContentMode.PlainTextFast]: 'PlainTextFast',\n [GetContentMode.RawHTMLOnly]: 'HTML',\n [GetContentMode.RawHTMLWithSelection]: 'HTML',\n};\n\n/**\n * Editor for Content Model.\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class EditorAdapter extends StandaloneEditor implements IEditor {\n private contentModelEditorCore: EditorAdapterCore | undefined;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorAdapterOptions = {}) {\n const bridgePlugin = new BridgePlugin(\n core => {\n this.contentModelEditorCore = core;\n\n return this;\n },\n options.legacyPlugins,\n options.experimentalFeatures\n );\n\n const plugins = [bridgePlugin, ...(options.plugins ?? [])];\n const initContent = options.initialContent ?? contentDiv.innerHTML;\n const initialModel =\n initContent && !options.initialModel\n ? createModelFromHtml(\n initContent,\n options.defaultDomToModelOptions,\n options.trustedHTMLHandler,\n options.defaultSegmentFormat\n )\n : options.initialModel;\n const standaloneEditorOptions: StandaloneEditorOptions = {\n ...options,\n plugins,\n initialModel,\n };\n\n super(contentDiv, standaloneEditorOptions);\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void {\n const core = this.contentModelEditorCore;\n\n if (core) {\n getObjectKeys(core.customData).forEach(key => {\n const data = core.customData[key];\n\n if (data && data.disposer) {\n data.disposer(data.value);\n }\n\n delete core.customData[key];\n });\n\n this.contentModelEditorCore = undefined;\n }\n\n super.dispose();\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return super.isDisposed() || !this.contentModelEditorCore;\n }\n\n /**\n * Insert node into editor\n * @param node The node to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n * @returns true if node is inserted. Otherwise false\n */\n insertNode(node: Node, option?: InsertOption): boolean {\n if (node) {\n option = option || {\n position: ContentPosition.SelectionStart,\n insertOnNewLine: false,\n updateCursor: true,\n replaceSelection: true,\n insertToRegionRoot: false,\n };\n\n const { contentDiv } = this.getCore();\n\n if (option.updateCursor) {\n this.focus();\n }\n\n if (option.position == ContentPosition.Outside) {\n contentDiv.parentNode?.insertBefore(node, contentDiv.nextSibling);\n } else {\n if (this.isDarkMode()) {\n transformColor(\n node,\n true /*includeSelf*/,\n 'lightToDark',\n this.getColorManager()\n );\n }\n\n const selection = insertNode(contentDiv, this.getDOMSelection(), node, option);\n\n if (selection && option.updateCursor) {\n this.setDOMSelection(selection);\n }\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Delete a node from editor content\n * @param node The node to delete\n * @returns true if node is deleted. Otherwise false\n */\n deleteNode(node: Node): boolean {\n // Only remove the node when it falls within editor\n if (node && this.contains(node) && node.parentNode) {\n node.parentNode.removeChild(node);\n return true;\n }\n\n return false;\n }\n\n /**\n * Replace a node in editor content with another node\n * @param existingNode The existing node to be replaced\n * @param toNode node to replace to\n * @param transformColorForDarkMode (optional) Whether to transform new node to dark mode. Default is false\n * @returns true if node is replaced. Otherwise false\n */\n replaceNode(existingNode: Node, toNode: Node, transformColorForDarkMode?: boolean): boolean {\n const core = this.getCore();\n // Only replace the node when it falls within editor\n if (this.contains(existingNode) && toNode) {\n if (core.lifecycle.isDarkMode && transformColorForDarkMode) {\n this.transformToDarkColor(toNode, ColorTransformDirection.LightToDark);\n }\n\n existingNode.parentNode?.replaceChild(toNode, existingNode);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Get BlockElement at given node\n * @param node The node to create InlineElement\n * @returns The BlockElement result\n */\n getBlockElementAtNode(node: Node): BlockElement | null {\n return getBlockElementAtNode(this.getCore().contentDiv, node);\n }\n\n contains(arg: Node | Range | null): boolean {\n if (!arg) {\n return false;\n }\n return contains(this.getCore().contentDiv, <Node>arg);\n }\n\n queryElements(\n selector: string,\n scopeOrCallback:\n | QueryScope\n | CompatibleQueryScope\n | ((node: Node) => any) = QueryScope.Body,\n callback?: (node: Node) => any\n ) {\n const core = this.getCore();\n const result: HTMLElement[] = [];\n const scope = scopeOrCallback instanceof Function ? QueryScope.Body : scopeOrCallback;\n callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;\n\n const selectionEx = scope == QueryScope.Body ? null : this.getSelectionRangeEx();\n if (selectionEx) {\n selectionEx.ranges.forEach(range => {\n result.push(...queryElements(core.contentDiv, selector, callback, scope, range));\n });\n } else {\n return queryElements(core.contentDiv, selector, callback, scope, undefined /* range */);\n }\n\n return result;\n }\n\n /**\n * Collapse nodes within the given start and end nodes to their common ancestor node,\n * split parent nodes if necessary\n * @param start The start node\n * @param end The end node\n * @param canSplitParent True to allow split parent node there are nodes before start or after end under the same parent\n * and the returned nodes will be all nodes from start through end after splitting\n * False to disallow split parent\n * @returns When canSplitParent is true, returns all node from start through end after splitting,\n * otherwise just return start and end\n */\n collapseNodes(start: Node, end: Node, canSplitParent: boolean): Node[] {\n return collapseNodes(this.getCore().contentDiv, start, end, canSplitParent);\n }\n\n //#endregion\n\n //#region Content API\n\n /**\n * Check whether the editor contains any visible content\n * @param trim Whether trim the content string before check. Default is false\n * @returns True if there's no visible content, otherwise false\n */\n isEmpty(trim?: boolean): boolean {\n return isNodeEmpty(this.getCore().contentDiv, trim);\n }\n\n /**\n * Get current editor content as HTML string\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent(mode: GetContentMode | CompatibleGetContentMode = GetContentMode.CleanHTML): string {\n return exportContent(\n this,\n GetContentModeMap[mode],\n this.getCore().modelToDomSettings.customized\n );\n }\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent(content: string, triggerContentChangedEvent: boolean = true) {\n const core = this.getCore();\n const { contentDiv, api, trustedHTMLHandler, lifecycle, darkColorHandler } = core;\n\n api.triggerEvent(\n core,\n {\n eventType: 'beforeSetContent',\n newContent: content,\n },\n true /*broadcast*/\n );\n\n const newModel = createModelFromHtml(\n content,\n core.domToModelSettings.customized,\n trustedHTMLHandler,\n core.format.defaultFormat\n );\n\n api.setContentModel(core, newModel);\n\n if (triggerContentChangedEvent) {\n api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: ChangeSource.SetContent,\n },\n false /*broadcast*/\n );\n } else if (lifecycle.isDarkMode) {\n transformColor(contentDiv, false /*includeSelf*/, 'lightToDark', darkColorHandler);\n }\n }\n\n /**\n * Insert HTML content into editor\n * @param HTML content to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n */\n insertContent(content: string, option?: InsertOption) {\n if (content) {\n const doc = this.getDocument();\n const body = new DOMParser().parseFromString(\n this.getCore().trustedHTMLHandler(content),\n 'text/html'\n )?.body;\n let allNodes = body?.childNodes ? toArray(body.childNodes) : [];\n\n // If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with\n // a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped\n // separately to show up on its own line\n if (option && option.insertOnNewLine && allNodes.length > 1) {\n allNodes = [wrap(allNodes)];\n }\n\n const fragment = doc.createDocumentFragment();\n allNodes.forEach(node => fragment.appendChild(node));\n\n this.insertNode(fragment, option);\n }\n }\n\n /**\n * Delete selected content\n */\n deleteSelectedContent(): NodePosition | null {\n const range = this.getSelectionRange();\n if (range && !range.collapsed) {\n return deleteSelectedContent(this.getCore().contentDiv, range);\n }\n return null;\n }\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteAsText Force pasting as plain text. Default value is false\n * @param applyCurrentStyle True if apply format of current selection to the pasted content,\n * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored\n * @param pasteAsImage: When set to true, if the clipboardData contains a imageDataUri will paste the image to the editor\n */\n paste(\n clipboardData: ClipboardData,\n pasteAsText: boolean = false,\n applyCurrentFormat: boolean = false,\n pasteAsImage: boolean = false\n ) {\n this.pasteFromClipboard(\n clipboardData,\n pasteAsText\n ? 'asPlainText'\n : applyCurrentFormat\n ? 'mergeFormat'\n : pasteAsImage\n ? 'asImage'\n : 'normal'\n );\n }\n\n //#endregion\n\n //#region Focus and Selection\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRange(tryGetFromCache: boolean = true): Range | null {\n const selection = this.getDOMSelection();\n\n return selection?.type == 'range' ? selection.range : null;\n }\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRangeEx(): SelectionRangeEx {\n const selection = this.getDOMSelection();\n\n return convertDomSelectionToRangeEx(selection);\n }\n\n /**\n * Get current selection in a serializable format\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @returns current selection path, or null if editor never got focus before\n */\n getSelectionPath(): SelectionPath | null {\n const range = this.getSelectionRange();\n return range && getSelectionPath(this.getCore().contentDiv, range);\n }\n\n select(\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 const core = this.getCore();\n const rangeEx = buildRangeEx(core.contentDiv, arg1, arg2, arg3, arg4);\n const selection = convertRangeExToDomSelection(rangeEx);\n\n this.setDOMSelection(selection);\n return true;\n }\n\n /**\n * Get current focused position. Return null if editor doesn't have focus at this time.\n */\n getFocusedPosition(): NodePosition | null {\n const sel = this.getDocument().defaultView?.getSelection();\n if (sel?.focusNode && this.contains(sel.focusNode)) {\n return new Position(sel.focusNode, sel.focusOffset);\n }\n\n const range = this.getSelectionRange();\n if (range) {\n return Position.getStart(range);\n }\n\n return null;\n }\n\n /**\n * Get an HTML element from current cursor position.\n * When expectedTags is not specified, return value is the current node (if it is HTML element)\n * or its parent node (if current node is a Text node).\n * When expectedTags is specified, return value is the first ancestor of current node which has\n * one of the expected tags.\n * If no element found within editor by the given tag, return null.\n * @param selector Optional, an HTML selector to find HTML element with.\n * @param startFrom Start search from this node. If not specified, start from current focused position\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n */\n getElementAtCursor(\n selector?: string,\n startFrom?: Node,\n event?: PluginEvent\n ): HTMLElement | null {\n event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result\n\n return (\n cacheGetEventData(event ?? null, 'GET_ELEMENT_AT_CURSOR_' + selector, () => {\n if (!startFrom) {\n const position = this.getFocusedPosition();\n startFrom = position?.node;\n }\n return (\n startFrom &&\n findClosestElementAncestor(startFrom, this.getCore().contentDiv, selector)\n );\n }) ?? null\n );\n }\n\n /**\n * Check if this position is at beginning of the editor.\n * This will return true if all nodes between the beginning of target node and the position are empty.\n * @param position The position to check\n * @returns True if position is at beginning of the editor, otherwise false\n */\n isPositionAtBeginning(position: NodePosition): boolean {\n return isPositionAtBeginningOf(position, this.getCore().contentDiv);\n }\n\n /**\n * Get impacted regions from selection\n */\n getSelectedRegions(type: RegionType | CompatibleRegionType = RegionType.Table): Region[] {\n const selection = this.getSelectionRangeEx();\n const result: Region[] = [];\n const contentDiv = this.getCore().contentDiv;\n selection.ranges.forEach(range => {\n result.push(...(range ? getRegionsFromRange(contentDiv, range, type) : []));\n });\n return result.filter((value, index, self) => {\n return self.indexOf(value) === index;\n });\n }\n\n //#endregion\n\n //#region EVENT API\n\n addDomEventHandler(\n nameOrMap: string | Record<string, DOMEventHandler>,\n handler?: DOMEventHandler\n ): () => void {\n const eventsMap = typeof nameOrMap == 'string' ? { [nameOrMap]: handler! } : nameOrMap;\n const eventsMapResult: Record<string, DOMEventRecord> = {};\n\n getObjectKeys(eventsMap).forEach(key => {\n const handlerObj = eventsMap[key];\n let result: DOMEventRecord = {\n pluginEventType: null,\n beforeDispatch: null,\n };\n\n if (typeof handlerObj === 'number') {\n result.pluginEventType = OldEventTypeToNewEventType[handlerObj as PluginEventType];\n } else if (typeof handlerObj === 'function') {\n result.beforeDispatch = handlerObj;\n } else if (typeof handlerObj === 'object') {\n const record = handlerObj as DOMEventHandlerObject;\n result = {\n beforeDispatch: record.beforeDispatch,\n pluginEventType:\n typeof record.pluginEventType == 'number'\n ? OldEventTypeToNewEventType[record.pluginEventType]\n : undefined,\n };\n }\n\n eventsMapResult[key] = result;\n });\n\n return this.attachDomEvent(eventsMapResult);\n }\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 public triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const oldEvent = {\n eventType,\n ...data,\n } as PluginEvent;\n const newEvent = oldEventToNewEvent(oldEvent);\n const core = this.getCore();\n\n if (newEvent) {\n core.api.triggerEvent(core, newEvent, broadcast);\n return (newEventToOldEvent(newEvent, oldEvent) ?? oldEvent) as PluginEventFromType<T>;\n } else {\n return oldEvent as PluginEventFromType<T>;\n }\n }\n\n /**\n * Trigger a ContentChangedEvent\n * @param source Source of this event, by default is 'SetContent'\n * @param data additional data for this event\n */\n triggerContentChangedEvent(\n source: ChangeSource | CompatibleChangeSource | string = ChangeSource.SetContent,\n data?: any\n ) {\n this.triggerPluginEvent(PluginEventType.ContentChanged, {\n source,\n data,\n });\n }\n\n //#endregion\n\n //#region Undo API\n\n /**\n * Undo last edit operation\n */\n undo() {\n undo(this);\n }\n\n /**\n * Redo next edit operation\n */\n redo() {\n redo(this);\n }\n\n /**\n * Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger\n * ContentChangedEvent with given change source.\n * If this function is called nested, undo snapshot will only be added in the outside one\n * @param callback The callback function to perform formatting, returns a data object which will be used as\n * the data field in ContentChangedEvent if changeSource is not null.\n * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,\n * a ContentChangedEvent will be fired with change source equal to this value\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n */\n addUndoSnapshot(\n callback?: (start: NodePosition | null, end: NodePosition | null) => any,\n changeSource?: ChangeSource | CompatibleChangeSource | string,\n canUndoByBackspace?: boolean,\n additionalData?: ContentChangedData\n ) {\n const core = this.getCore();\n const undoState = core.undo;\n const isNested = undoState.isNested;\n let data: any;\n\n if (!isNested) {\n undoState.isNested = true;\n\n // When there is getEntityState, it means this is triggered by an entity change.\n // So if HTML content is not changed (hasNewContent is false), no need to add another snapshot before change\n if (\n core.undo.snapshotsManager.hasNewContent ||\n !additionalData?.getEntityState ||\n !callback\n ) {\n core.api.addUndoSnapshot(\n core,\n !!canUndoByBackspace,\n additionalData?.getEntityState?.()\n );\n }\n }\n\n try {\n if (callback) {\n const selection = core.api.getDOMSelection(core);\n const range = selection?.type == 'range' ? selection.range : null;\n data = callback(\n range && Position.getStart(range).normalize(),\n range && Position.getEnd(range).normalize()\n );\n\n if (!isNested) {\n const entityStates = additionalData?.getEntityState?.();\n\n core.api.addUndoSnapshot(core, false /*isAutoCompleteSnapshot*/, entityStates);\n }\n }\n } finally {\n if (!isNested) {\n undoState.isNested = false;\n }\n }\n\n if (callback && changeSource) {\n const event: ContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n source: changeSource,\n data: data,\n additionalData,\n };\n this.triggerPluginEvent(PluginEventType.ContentChanged, event, true /*broadcast*/);\n }\n\n if (canUndoByBackspace) {\n const selection = core.api.getDOMSelection(core);\n\n if (selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n }\n }\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState {\n const { snapshotsManager } = this.getCore().undo;\n return {\n canUndo:\n snapshotsManager.hasNewContent || snapshotsManager.canMove(-1 /*previousSnapshot*/),\n canRedo: snapshotsManager.canMove(1 /*nextSnapshot*/),\n };\n }\n\n //#endregion\n\n //#region Misc\n\n /**\n * Get custom data related to this editor\n * @param key Key of the custom data\n * @param getter Getter function. If custom data for the given key doesn't exist,\n * call this function to get one and store it if it is specified. Otherwise return undefined\n * @param disposer An optional disposer function to dispose this custom data when\n * dispose editor.\n */\n getCustomData<T>(key: string, getter?: () => T, disposer?: (value: T) => void): T {\n const core = this.getContentModelEditorCore();\n return (core.customData[key] = core.customData[key] || {\n value: getter ? getter() : undefined,\n disposer,\n }).value as T;\n }\n\n /**\n * Get default format of this editor\n * @returns Default format object of this editor\n */\n getDefaultFormat(): DefaultFormat {\n const format = this.getCore().format.defaultFormat;\n\n return {\n bold: isBold(format.fontWeight),\n italic: format.italic,\n underline: format.underline,\n fontFamily: format.fontFamily,\n fontSize: format.fontSize,\n textColor: format.textColor,\n backgroundColor: format.backgroundColor,\n };\n }\n\n /**\n * Get a content traverser for the whole editor\n * @param startNode The node to start from. If not passed, it will start from the beginning of the body\n */\n getBodyTraverser(startNode?: Node): IContentTraverser {\n return ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);\n }\n\n /**\n * Get a content traverser for current selection\n * @returns A content traverser, or null if editor never got focus before\n */\n getSelectionTraverser(range?: Range): IContentTraverser | null {\n range = range ?? this.getSelectionRange() ?? undefined;\n return range\n ? ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)\n : null;\n }\n\n /**\n * Get a content traverser for current block element start from specified position\n * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart\n * @returns A content traverser, or null if editor never got focus before\n */\n getBlockTraverser(\n startFrom: ContentPosition | CompatibleContentPosition = ContentPosition.SelectionStart\n ): IContentTraverser | null {\n const range = this.getSelectionRange();\n return range\n ? ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)\n : null;\n }\n\n /**\n * Get a text traverser of current selection\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n * @returns A content traverser, or null if editor never got focus before\n */\n getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null {\n return cacheGetEventData(event ?? null, 'ContentSearcher', () => {\n const range = this.getSelectionRange();\n return (\n range &&\n new PositionContentSearcher(this.getCore().contentDiv, Position.getStart(range))\n );\n });\n }\n\n /**\n * Run a callback function asynchronously\n * @param callback The callback function to run\n * @returns a function to cancel this async run\n */\n runAsync(callback: (editor: IEditor & IStandaloneEditor) => void) {\n const win = this.getCore().contentDiv.ownerDocument.defaultView || window;\n const handle = win.requestAnimationFrame(() => {\n if (!this.isDisposed() && callback) {\n callback(this);\n }\n });\n\n return () => {\n win.cancelAnimationFrame(handle);\n };\n }\n\n /**\n * Set DOM attribute of editor content DIV\n * @param name Name of the attribute\n * @param value Value of the attribute\n */\n setEditorDomAttribute(name: string, value: string | null) {\n this.getDOMHelper().setDomAttribute(name, value);\n }\n\n /**\n * Get DOM attribute of editor content DIV, null if there is no such attribute.\n * @param name Name of the attribute\n */\n getEditorDomAttribute(name: string): string | null {\n return this.getDOMHelper().getDomAttribute(name);\n }\n\n /**\n * @deprecated Use getVisibleViewport() instead.\n *\n * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.\n * @param element The element to calculate from. If the given element is not in editor, return value will be null\n * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value\n * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.\n * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.\n */\n getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null {\n if (this.contains(element)) {\n const contentDiv = this.getCore().contentDiv;\n const editorRect = contentDiv.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (editorRect && elementRect) {\n let x = elementRect.left - editorRect?.left;\n let y = elementRect.top - editorRect?.top;\n\n if (addScroll) {\n x += contentDiv.scrollLeft;\n y += contentDiv.scrollTop;\n }\n\n return [x, y];\n }\n }\n\n return null;\n }\n\n /**\n * Add a Content Edit feature.\n * @param feature The feature to add\n */\n addContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const array = core.edit.features[key] || [];\n array.push(feature);\n core.edit.features[key] = array;\n });\n }\n\n /**\n * Remove a Content Edit feature.\n * @param feature The feature to remove\n */\n removeContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const featureSet = core.edit.features[key];\n const index = featureSet?.indexOf(feature) ?? -1;\n if (index >= 0) {\n core.edit.features[key].splice(index, 1);\n if (core.edit.features[key].length < 1) {\n delete core.edit.features[key];\n }\n }\n });\n }\n\n /**\n * @deprecated\n * Get style based format state from current selection, including font name/size and colors\n */\n getStyleBasedFormatState(): StyleBasedFormatState {\n const format = this.retrieveFormatState();\n\n return {\n backgroundColor: format.backgroundColor,\n direction: format.direction,\n fontName: format.fontName,\n fontSize: format.fontSize,\n fontWeight: format.fontWeight,\n lineHeight: format.lineHeight,\n marginBottom: format.marginBottom,\n marginTop: format.marginTop,\n textAlign: format.textAlign,\n textColor: format.textColor,\n };\n }\n\n /**\n * @deprecated\n * Get the pendable format such as underline and bold\n * @returns The pending format state\n */\n getPendableFormatState(): PendableFormatState {\n const format = this.retrieveFormatState();\n\n return {\n isBold: format.isBold,\n isItalic: format.isItalic,\n isStrikeThrough: format.isStrikeThrough,\n isSubscript: format.isSubscript,\n isSuperscript: format.isSubscript,\n isUnderline: format.isUnderline,\n };\n }\n\n /**\n * @deprecated\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n */\n ensureTypeInContainer(position: NodePosition, keyboardEvent?: KeyboardEvent) {\n // No OP\n }\n\n //#endregion\n\n //#region Dark mode APIs\n\n /**\n * Transform the given node and all its child nodes to dark mode color if editor is in dark mode\n * @param node The node to transform\n * @param direction The transform direction. @default ColorTransformDirection.LightToDark\n */\n transformToDarkColor(\n node: Node,\n direction:\n | ColorTransformDirection\n | CompatibleColorTransformDirection = ColorTransformDirection.LightToDark\n ) {\n const core = this.getCore();\n\n if (core.lifecycle.isDarkMode) {\n transformColor(\n node,\n true /*includeSelf*/,\n direction == ColorTransformDirection.DarkToLight ? 'darkToLight' : 'lightToDark',\n core.darkColorHandler\n );\n }\n }\n\n /**\n * Check if the given experimental feature is enabled\n * @param feature The feature to check\n */\n isFeatureEnabled(feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean {\n return (\n this.getContentModelEditorCore().experimentalFeatures.indexOf(\n feature as ExperimentalFeatures\n ) >= 0\n );\n }\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 return this.getDOMHelper().calculateZoomScale();\n }\n\n /**\n * Set 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 * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.\n */\n setZoomScale(scale: number): void {\n if (scale > 0 && scale <= 10) {\n const oldValue = this.getZoomScale();\n\n if (oldValue != scale) {\n this.triggerEvent(\n 'zoomChanged',\n {\n newZoomScale: scale,\n },\n true /*broadcast*/\n );\n }\n }\n }\n\n /**\n * @deprecated Use getZoomScale() instead\n */\n getSizeTransformer(): SizeTransformer {\n return this.getContentModelEditorCore().sizeTransformer;\n }\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler {\n const core = this.getContentModelEditorCore();\n return core.darkColorHandler;\n }\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 return this.getCore().domEvent.isInIME;\n }\n\n private retrieveFormatState(): ContentModelFormatState {\n const pendingFormat = this.getPendingFormat();\n const result: ContentModelFormatState = {};\n const model = this.getContentModelCopy('reduced');\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n }\n\n /**\n * @returns the current EditorAdapterCore object\n * @throws a standard Error if there's no core object\n */\n private getContentModelEditorCore(): EditorAdapterCore {\n if (!this.contentModelEditorCore) {\n throw new Error('Editor is already disposed');\n }\n\n return this.contentModelEditorCore;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EditorAdapter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/editor/EditorAdapter.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,IAAI,EACJ,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,IAAI,GACP,MAAM,8BAA8B,CAAC;AAuCtC,OAAO,EACH,4BAA4B,EAC5B,4BAA4B,GAC/B,MAAM,4BAA4B,CAAC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AAE,CAAC,eAAe,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,2CAAmB,GAAnB;QACI,IAAM,IAAI,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,+BAAO,GAAP;QACI,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3C,CAAC;IAEO,2CAAmB,GAA3B;QACI,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,IAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,IAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAElD,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,iDAAyB,GAAjC;QACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QAED,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IACL,oBAAC;AAAD,CAAC,AA9/BD,CAAmC,gBAAgB,GA8/BlD","sourcesContent":["import { BridgePlugin } from '../corePlugins/BridgePlugin';\nimport { buildRangeEx } from './utils/buildRangeEx';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { insertNode } from './utils/insertNode';\nimport type { EditorAdapterCore } from '../corePlugins/BridgePlugin';\nimport {\n newEventToOldEvent,\n oldEventToNewEvent,\n OldEventTypeToNewEventType,\n} from './utils/eventConverter';\nimport {\n createModelFromHtml,\n exportContent,\n isBold,\n redo,\n retrieveModelFormatState,\n StandaloneEditor,\n transformColor,\n undo,\n} from 'roosterjs-content-model-core';\nimport {\n ChangeSource,\n ColorTransformDirection,\n ContentPosition,\n GetContentMode,\n PluginEventType,\n QueryScope,\n RegionType,\n} from 'roosterjs-editor-types';\nimport type {\n BlockElement,\n ClipboardData,\n ContentChangedData,\n ContentChangedEvent,\n DOMEventHandler,\n DefaultFormat,\n EditorUndoState,\n ExperimentalFeatures,\n GenericContentEditFeature,\n IContentTraverser,\n IPositionContentSearcher,\n InsertOption,\n NodePosition,\n PendableFormatState,\n PluginEvent,\n PluginEventData,\n PluginEventFromType,\n PositionType,\n Region,\n SelectionPath,\n SelectionRangeEx,\n SizeTransformer,\n StyleBasedFormatState,\n TableSelection,\n DOMEventHandlerObject,\n DarkColorHandler,\n IEditor,\n} from 'roosterjs-editor-types';\nimport {\n convertDomSelectionToRangeEx,\n convertRangeExToDomSelection,\n} from './utils/selectionConverter';\nimport type {\n CompatibleChangeSource,\n CompatibleColorTransformDirection,\n CompatibleContentPosition,\n CompatibleExperimentalFeatures,\n CompatibleGetContentMode,\n CompatiblePluginEventType,\n CompatibleQueryScope,\n CompatibleRegionType,\n} from 'roosterjs-editor-types/lib/compatibleTypes';\nimport {\n ContentTraverser,\n Position,\n PositionContentSearcher,\n cacheGetEventData,\n collapseNodes,\n contains,\n deleteSelectedContent,\n findClosestElementAncestor,\n getBlockElementAtNode,\n getRegionsFromRange,\n getSelectionPath,\n isNodeEmpty,\n isPositionAtBeginningOf,\n queryElements,\n toArray,\n wrap,\n} from 'roosterjs-editor-dom';\nimport type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';\nimport type {\n ContentModelFormatState,\n DOMEventRecord,\n ExportContentMode,\n IStandaloneEditor,\n StandaloneEditorOptions,\n} from 'roosterjs-content-model-types';\n\nconst GetContentModeMap: Record<GetContentMode, ExportContentMode> = {\n [GetContentMode.CleanHTML]: 'HTML',\n [GetContentMode.PlainText]: 'PlainText',\n [GetContentMode.PlainTextFast]: 'PlainTextFast',\n [GetContentMode.RawHTMLOnly]: 'HTML',\n [GetContentMode.RawHTMLWithSelection]: 'HTML',\n};\n\n/**\n * Editor for Content Model.\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class EditorAdapter extends StandaloneEditor implements IEditor {\n private contentModelEditorCore: EditorAdapterCore | undefined;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorAdapterOptions = {}) {\n const bridgePlugin = new BridgePlugin(\n core => {\n this.contentModelEditorCore = core;\n\n return this;\n },\n options.legacyPlugins,\n options.experimentalFeatures\n );\n\n const plugins = [bridgePlugin, ...(options.plugins ?? [])];\n const initContent = options.initialContent ?? contentDiv.innerHTML;\n const initialModel =\n initContent && !options.initialModel\n ? createModelFromHtml(\n initContent,\n options.defaultDomToModelOptions,\n options.trustedHTMLHandler,\n options.defaultSegmentFormat\n )\n : options.initialModel;\n const standaloneEditorOptions: StandaloneEditorOptions = {\n ...options,\n plugins,\n initialModel,\n };\n\n super(contentDiv, standaloneEditorOptions);\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void {\n super.dispose();\n\n const core = this.contentModelEditorCore;\n\n if (core) {\n getObjectKeys(core.customData).forEach(key => {\n const data = core.customData[key];\n\n if (data && data.disposer) {\n data.disposer(data.value);\n }\n\n delete core.customData[key];\n });\n\n this.contentModelEditorCore = undefined;\n }\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return super.isDisposed() || !this.contentModelEditorCore;\n }\n\n /**\n * Insert node into editor\n * @param node The node to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n * @returns true if node is inserted. Otherwise false\n */\n insertNode(node: Node, option?: InsertOption): boolean {\n if (node) {\n option = option || {\n position: ContentPosition.SelectionStart,\n insertOnNewLine: false,\n updateCursor: true,\n replaceSelection: true,\n insertToRegionRoot: false,\n };\n\n const { contentDiv } = this.getCore();\n\n if (option.updateCursor) {\n this.focus();\n }\n\n if (option.position == ContentPosition.Outside) {\n contentDiv.parentNode?.insertBefore(node, contentDiv.nextSibling);\n } else {\n if (this.isDarkMode()) {\n transformColor(\n node,\n true /*includeSelf*/,\n 'lightToDark',\n this.getColorManager()\n );\n }\n\n const selection = insertNode(contentDiv, this.getDOMSelection(), node, option);\n\n if (selection && option.updateCursor) {\n this.setDOMSelection(selection);\n }\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Delete a node from editor content\n * @param node The node to delete\n * @returns true if node is deleted. Otherwise false\n */\n deleteNode(node: Node): boolean {\n // Only remove the node when it falls within editor\n if (node && this.contains(node) && node.parentNode) {\n node.parentNode.removeChild(node);\n return true;\n }\n\n return false;\n }\n\n /**\n * Replace a node in editor content with another node\n * @param existingNode The existing node to be replaced\n * @param toNode node to replace to\n * @param transformColorForDarkMode (optional) Whether to transform new node to dark mode. Default is false\n * @returns true if node is replaced. Otherwise false\n */\n replaceNode(existingNode: Node, toNode: Node, transformColorForDarkMode?: boolean): boolean {\n const core = this.getCore();\n // Only replace the node when it falls within editor\n if (this.contains(existingNode) && toNode) {\n if (core.lifecycle.isDarkMode && transformColorForDarkMode) {\n this.transformToDarkColor(toNode, ColorTransformDirection.LightToDark);\n }\n\n existingNode.parentNode?.replaceChild(toNode, existingNode);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Get BlockElement at given node\n * @param node The node to create InlineElement\n * @returns The BlockElement result\n */\n getBlockElementAtNode(node: Node): BlockElement | null {\n return getBlockElementAtNode(this.getCore().contentDiv, node);\n }\n\n contains(arg: Node | Range | null): boolean {\n if (!arg) {\n return false;\n }\n return contains(this.getCore().contentDiv, <Node>arg);\n }\n\n queryElements(\n selector: string,\n scopeOrCallback:\n | QueryScope\n | CompatibleQueryScope\n | ((node: Node) => any) = QueryScope.Body,\n callback?: (node: Node) => any\n ) {\n const core = this.getCore();\n const result: HTMLElement[] = [];\n const scope = scopeOrCallback instanceof Function ? QueryScope.Body : scopeOrCallback;\n callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;\n\n const selectionEx = scope == QueryScope.Body ? null : this.getSelectionRangeEx();\n if (selectionEx) {\n selectionEx.ranges.forEach(range => {\n result.push(...queryElements(core.contentDiv, selector, callback, scope, range));\n });\n } else {\n return queryElements(core.contentDiv, selector, callback, scope, undefined /* range */);\n }\n\n return result;\n }\n\n /**\n * Collapse nodes within the given start and end nodes to their common ancestor node,\n * split parent nodes if necessary\n * @param start The start node\n * @param end The end node\n * @param canSplitParent True to allow split parent node there are nodes before start or after end under the same parent\n * and the returned nodes will be all nodes from start through end after splitting\n * False to disallow split parent\n * @returns When canSplitParent is true, returns all node from start through end after splitting,\n * otherwise just return start and end\n */\n collapseNodes(start: Node, end: Node, canSplitParent: boolean): Node[] {\n return collapseNodes(this.getCore().contentDiv, start, end, canSplitParent);\n }\n\n //#endregion\n\n //#region Content API\n\n /**\n * Check whether the editor contains any visible content\n * @param trim Whether trim the content string before check. Default is false\n * @returns True if there's no visible content, otherwise false\n */\n isEmpty(trim?: boolean): boolean {\n return isNodeEmpty(this.getCore().contentDiv, trim);\n }\n\n /**\n * Get current editor content as HTML string\n * @param mode specify what kind of HTML content to retrieve\n * @returns HTML string representing current editor content\n */\n getContent(mode: GetContentMode | CompatibleGetContentMode = GetContentMode.CleanHTML): string {\n return exportContent(\n this,\n GetContentModeMap[mode],\n this.getCore().modelToDomSettings.customized\n );\n }\n\n /**\n * Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered\n * @param content HTML content to set in\n * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true\n */\n setContent(content: string, triggerContentChangedEvent: boolean = true) {\n const core = this.getCore();\n const { contentDiv, api, trustedHTMLHandler, lifecycle, darkColorHandler } = core;\n\n api.triggerEvent(\n core,\n {\n eventType: 'beforeSetContent',\n newContent: content,\n },\n true /*broadcast*/\n );\n\n const newModel = createModelFromHtml(\n content,\n core.domToModelSettings.customized,\n trustedHTMLHandler,\n core.format.defaultFormat\n );\n\n api.setContentModel(core, newModel);\n\n if (triggerContentChangedEvent) {\n api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: ChangeSource.SetContent,\n },\n false /*broadcast*/\n );\n } else if (lifecycle.isDarkMode) {\n transformColor(contentDiv, false /*includeSelf*/, 'lightToDark', darkColorHandler);\n }\n }\n\n /**\n * Insert HTML content into editor\n * @param HTML content to insert\n * @param option Insert options. Default value is:\n * position: ContentPosition.SelectionStart\n * updateCursor: true\n * replaceSelection: true\n * insertOnNewLine: false\n */\n insertContent(content: string, option?: InsertOption) {\n if (content) {\n const doc = this.getDocument();\n const body = new DOMParser().parseFromString(\n this.getCore().trustedHTMLHandler(content),\n 'text/html'\n )?.body;\n let allNodes = body?.childNodes ? toArray(body.childNodes) : [];\n\n // If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with\n // a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped\n // separately to show up on its own line\n if (option && option.insertOnNewLine && allNodes.length > 1) {\n allNodes = [wrap(allNodes)];\n }\n\n const fragment = doc.createDocumentFragment();\n allNodes.forEach(node => fragment.appendChild(node));\n\n this.insertNode(fragment, option);\n }\n }\n\n /**\n * Delete selected content\n */\n deleteSelectedContent(): NodePosition | null {\n const range = this.getSelectionRange();\n if (range && !range.collapsed) {\n return deleteSelectedContent(this.getCore().contentDiv, range);\n }\n return null;\n }\n\n /**\n * Paste into editor using a clipboardData object\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteAsText Force pasting as plain text. Default value is false\n * @param applyCurrentStyle True if apply format of current selection to the pasted content,\n * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored\n * @param pasteAsImage: When set to true, if the clipboardData contains a imageDataUri will paste the image to the editor\n */\n paste(\n clipboardData: ClipboardData,\n pasteAsText: boolean = false,\n applyCurrentFormat: boolean = false,\n pasteAsImage: boolean = false\n ) {\n this.pasteFromClipboard(\n clipboardData,\n pasteAsText\n ? 'asPlainText'\n : applyCurrentFormat\n ? 'mergeFormat'\n : pasteAsImage\n ? 'asImage'\n : 'normal'\n );\n }\n\n //#endregion\n\n //#region Focus and Selection\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRange(tryGetFromCache: boolean = true): Range | null {\n const selection = this.getDOMSelection();\n\n return selection?.type == 'range' ? selection.range : null;\n }\n\n /**\n * Get current selection range from Editor.\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.\n * Default value is true\n * @returns current selection range, or null if editor never got focus before\n */\n getSelectionRangeEx(): SelectionRangeEx {\n const selection = this.getDOMSelection();\n\n return convertDomSelectionToRangeEx(selection);\n }\n\n /**\n * Get current selection in a serializable format\n * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.\n * @returns current selection path, or null if editor never got focus before\n */\n getSelectionPath(): SelectionPath | null {\n const range = this.getSelectionRange();\n return range && getSelectionPath(this.getCore().contentDiv, range);\n }\n\n select(\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 const core = this.getCore();\n const rangeEx = buildRangeEx(core.contentDiv, arg1, arg2, arg3, arg4);\n const selection = convertRangeExToDomSelection(rangeEx);\n\n this.setDOMSelection(selection);\n return true;\n }\n\n /**\n * Get current focused position. Return null if editor doesn't have focus at this time.\n */\n getFocusedPosition(): NodePosition | null {\n const sel = this.getDocument().defaultView?.getSelection();\n if (sel?.focusNode && this.contains(sel.focusNode)) {\n return new Position(sel.focusNode, sel.focusOffset);\n }\n\n const range = this.getSelectionRange();\n if (range) {\n return Position.getStart(range);\n }\n\n return null;\n }\n\n /**\n * Get an HTML element from current cursor position.\n * When expectedTags is not specified, return value is the current node (if it is HTML element)\n * or its parent node (if current node is a Text node).\n * When expectedTags is specified, return value is the first ancestor of current node which has\n * one of the expected tags.\n * If no element found within editor by the given tag, return null.\n * @param selector Optional, an HTML selector to find HTML element with.\n * @param startFrom Start search from this node. If not specified, start from current focused position\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n */\n getElementAtCursor(\n selector?: string,\n startFrom?: Node,\n event?: PluginEvent\n ): HTMLElement | null {\n event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result\n\n return (\n cacheGetEventData(event ?? null, 'GET_ELEMENT_AT_CURSOR_' + selector, () => {\n if (!startFrom) {\n const position = this.getFocusedPosition();\n startFrom = position?.node;\n }\n return (\n startFrom &&\n findClosestElementAncestor(startFrom, this.getCore().contentDiv, selector)\n );\n }) ?? null\n );\n }\n\n /**\n * Check if this position is at beginning of the editor.\n * This will return true if all nodes between the beginning of target node and the position are empty.\n * @param position The position to check\n * @returns True if position is at beginning of the editor, otherwise false\n */\n isPositionAtBeginning(position: NodePosition): boolean {\n return isPositionAtBeginningOf(position, this.getCore().contentDiv);\n }\n\n /**\n * Get impacted regions from selection\n */\n getSelectedRegions(type: RegionType | CompatibleRegionType = RegionType.Table): Region[] {\n const selection = this.getSelectionRangeEx();\n const result: Region[] = [];\n const contentDiv = this.getCore().contentDiv;\n selection.ranges.forEach(range => {\n result.push(...(range ? getRegionsFromRange(contentDiv, range, type) : []));\n });\n return result.filter((value, index, self) => {\n return self.indexOf(value) === index;\n });\n }\n\n //#endregion\n\n //#region EVENT API\n\n addDomEventHandler(\n nameOrMap: string | Record<string, DOMEventHandler>,\n handler?: DOMEventHandler\n ): () => void {\n const eventsMap = typeof nameOrMap == 'string' ? { [nameOrMap]: handler! } : nameOrMap;\n const eventsMapResult: Record<string, DOMEventRecord> = {};\n\n getObjectKeys(eventsMap).forEach(key => {\n const handlerObj = eventsMap[key];\n let result: DOMEventRecord = {\n pluginEventType: null,\n beforeDispatch: null,\n };\n\n if (typeof handlerObj === 'number') {\n result.pluginEventType = OldEventTypeToNewEventType[handlerObj as PluginEventType];\n } else if (typeof handlerObj === 'function') {\n result.beforeDispatch = handlerObj;\n } else if (typeof handlerObj === 'object') {\n const record = handlerObj as DOMEventHandlerObject;\n result = {\n beforeDispatch: record.beforeDispatch,\n pluginEventType:\n typeof record.pluginEventType == 'number'\n ? OldEventTypeToNewEventType[record.pluginEventType]\n : undefined,\n };\n }\n\n eventsMapResult[key] = result;\n });\n\n return this.attachDomEvent(eventsMapResult);\n }\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 public triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const oldEvent = {\n eventType,\n ...data,\n } as PluginEvent;\n const newEvent = oldEventToNewEvent(oldEvent);\n const core = this.getCore();\n\n if (newEvent) {\n core.api.triggerEvent(core, newEvent, broadcast);\n return (newEventToOldEvent(newEvent, oldEvent) ?? oldEvent) as PluginEventFromType<T>;\n } else {\n return oldEvent as PluginEventFromType<T>;\n }\n }\n\n /**\n * Trigger a ContentChangedEvent\n * @param source Source of this event, by default is 'SetContent'\n * @param data additional data for this event\n */\n triggerContentChangedEvent(\n source: ChangeSource | CompatibleChangeSource | string = ChangeSource.SetContent,\n data?: any\n ) {\n this.triggerPluginEvent(PluginEventType.ContentChanged, {\n source,\n data,\n });\n }\n\n //#endregion\n\n //#region Undo API\n\n /**\n * Undo last edit operation\n */\n undo() {\n undo(this);\n }\n\n /**\n * Redo next edit operation\n */\n redo() {\n redo(this);\n }\n\n /**\n * Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger\n * ContentChangedEvent with given change source.\n * If this function is called nested, undo snapshot will only be added in the outside one\n * @param callback The callback function to perform formatting, returns a data object which will be used as\n * the data field in ContentChangedEvent if changeSource is not null.\n * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,\n * a ContentChangedEvent will be fired with change source equal to this value\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n */\n addUndoSnapshot(\n callback?: (start: NodePosition | null, end: NodePosition | null) => any,\n changeSource?: ChangeSource | CompatibleChangeSource | string,\n canUndoByBackspace?: boolean,\n additionalData?: ContentChangedData\n ) {\n const core = this.getCore();\n const undoState = core.undo;\n const isNested = undoState.isNested;\n let data: any;\n\n if (!isNested) {\n undoState.isNested = true;\n\n // When there is getEntityState, it means this is triggered by an entity change.\n // So if HTML content is not changed (hasNewContent is false), no need to add another snapshot before change\n if (\n core.undo.snapshotsManager.hasNewContent ||\n !additionalData?.getEntityState ||\n !callback\n ) {\n core.api.addUndoSnapshot(\n core,\n !!canUndoByBackspace,\n additionalData?.getEntityState?.()\n );\n }\n }\n\n try {\n if (callback) {\n const selection = core.api.getDOMSelection(core);\n const range = selection?.type == 'range' ? selection.range : null;\n data = callback(\n range && Position.getStart(range).normalize(),\n range && Position.getEnd(range).normalize()\n );\n\n if (!isNested) {\n const entityStates = additionalData?.getEntityState?.();\n\n core.api.addUndoSnapshot(core, false /*isAutoCompleteSnapshot*/, entityStates);\n }\n }\n } finally {\n if (!isNested) {\n undoState.isNested = false;\n }\n }\n\n if (callback && changeSource) {\n const event: ContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n source: changeSource,\n data: data,\n additionalData,\n };\n this.triggerPluginEvent(PluginEventType.ContentChanged, event, true /*broadcast*/);\n }\n\n if (canUndoByBackspace) {\n const selection = core.api.getDOMSelection(core);\n\n if (selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n }\n }\n\n /**\n * Whether there is an available undo/redo snapshot\n */\n getUndoState(): EditorUndoState {\n const { snapshotsManager } = this.getCore().undo;\n return {\n canUndo:\n snapshotsManager.hasNewContent || snapshotsManager.canMove(-1 /*previousSnapshot*/),\n canRedo: snapshotsManager.canMove(1 /*nextSnapshot*/),\n };\n }\n\n //#endregion\n\n //#region Misc\n\n /**\n * Get custom data related to this editor\n * @param key Key of the custom data\n * @param getter Getter function. If custom data for the given key doesn't exist,\n * call this function to get one and store it if it is specified. Otherwise return undefined\n * @param disposer An optional disposer function to dispose this custom data when\n * dispose editor.\n */\n getCustomData<T>(key: string, getter?: () => T, disposer?: (value: T) => void): T {\n const core = this.getContentModelEditorCore();\n return (core.customData[key] = core.customData[key] || {\n value: getter ? getter() : undefined,\n disposer,\n }).value as T;\n }\n\n /**\n * Get default format of this editor\n * @returns Default format object of this editor\n */\n getDefaultFormat(): DefaultFormat {\n const format = this.getCore().format.defaultFormat;\n\n return {\n bold: isBold(format.fontWeight),\n italic: format.italic,\n underline: format.underline,\n fontFamily: format.fontFamily,\n fontSize: format.fontSize,\n textColor: format.textColor,\n backgroundColor: format.backgroundColor,\n };\n }\n\n /**\n * Get a content traverser for the whole editor\n * @param startNode The node to start from. If not passed, it will start from the beginning of the body\n */\n getBodyTraverser(startNode?: Node): IContentTraverser {\n return ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);\n }\n\n /**\n * Get a content traverser for current selection\n * @returns A content traverser, or null if editor never got focus before\n */\n getSelectionTraverser(range?: Range): IContentTraverser | null {\n range = range ?? this.getSelectionRange() ?? undefined;\n return range\n ? ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)\n : null;\n }\n\n /**\n * Get a content traverser for current block element start from specified position\n * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart\n * @returns A content traverser, or null if editor never got focus before\n */\n getBlockTraverser(\n startFrom: ContentPosition | CompatibleContentPosition = ContentPosition.SelectionStart\n ): IContentTraverser | null {\n const range = this.getSelectionRange();\n return range\n ? ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)\n : null;\n }\n\n /**\n * Get a text traverser of current selection\n * @param event Optional, if specified, editor will try to get cached result from the event object first.\n * If it is not cached before, query from DOM and cache the result into the event object\n * @returns A content traverser, or null if editor never got focus before\n */\n getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null {\n return cacheGetEventData(event ?? null, 'ContentSearcher', () => {\n const range = this.getSelectionRange();\n return (\n range &&\n new PositionContentSearcher(this.getCore().contentDiv, Position.getStart(range))\n );\n });\n }\n\n /**\n * Run a callback function asynchronously\n * @param callback The callback function to run\n * @returns a function to cancel this async run\n */\n runAsync(callback: (editor: IEditor & IStandaloneEditor) => void) {\n const win = this.getCore().contentDiv.ownerDocument.defaultView || window;\n const handle = win.requestAnimationFrame(() => {\n if (!this.isDisposed() && callback) {\n callback(this);\n }\n });\n\n return () => {\n win.cancelAnimationFrame(handle);\n };\n }\n\n /**\n * Set DOM attribute of editor content DIV\n * @param name Name of the attribute\n * @param value Value of the attribute\n */\n setEditorDomAttribute(name: string, value: string | null) {\n this.getDOMHelper().setDomAttribute(name, value);\n }\n\n /**\n * Get DOM attribute of editor content DIV, null if there is no such attribute.\n * @param name Name of the attribute\n */\n getEditorDomAttribute(name: string): string | null {\n return this.getDOMHelper().getDomAttribute(name);\n }\n\n /**\n * @deprecated Use getVisibleViewport() instead.\n *\n * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.\n * @param element The element to calculate from. If the given element is not in editor, return value will be null\n * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value\n * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.\n * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.\n */\n getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null {\n if (this.contains(element)) {\n const contentDiv = this.getCore().contentDiv;\n const editorRect = contentDiv.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (editorRect && elementRect) {\n let x = elementRect.left - editorRect?.left;\n let y = elementRect.top - editorRect?.top;\n\n if (addScroll) {\n x += contentDiv.scrollLeft;\n y += contentDiv.scrollTop;\n }\n\n return [x, y];\n }\n }\n\n return null;\n }\n\n /**\n * Add a Content Edit feature.\n * @param feature The feature to add\n */\n addContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const array = core.edit.features[key] || [];\n array.push(feature);\n core.edit.features[key] = array;\n });\n }\n\n /**\n * Remove a Content Edit feature.\n * @param feature The feature to remove\n */\n removeContentEditFeature(feature: GenericContentEditFeature<PluginEvent>) {\n const core = this.getContentModelEditorCore();\n feature?.keys.forEach(key => {\n const featureSet = core.edit.features[key];\n const index = featureSet?.indexOf(feature) ?? -1;\n if (index >= 0) {\n core.edit.features[key].splice(index, 1);\n if (core.edit.features[key].length < 1) {\n delete core.edit.features[key];\n }\n }\n });\n }\n\n /**\n * @deprecated\n * Get style based format state from current selection, including font name/size and colors\n */\n getStyleBasedFormatState(): StyleBasedFormatState {\n const format = this.retrieveFormatState();\n\n return {\n backgroundColor: format.backgroundColor,\n direction: format.direction,\n fontName: format.fontName,\n fontSize: format.fontSize,\n fontWeight: format.fontWeight,\n lineHeight: format.lineHeight,\n marginBottom: format.marginBottom,\n marginTop: format.marginTop,\n textAlign: format.textAlign,\n textColor: format.textColor,\n };\n }\n\n /**\n * @deprecated\n * Get the pendable format such as underline and bold\n * @returns The pending format state\n */\n getPendableFormatState(): PendableFormatState {\n const format = this.retrieveFormatState();\n\n return {\n isBold: format.isBold,\n isItalic: format.isItalic,\n isStrikeThrough: format.isStrikeThrough,\n isSubscript: format.isSubscript,\n isSuperscript: format.isSubscript,\n isUnderline: format.isUnderline,\n };\n }\n\n /**\n * @deprecated\n * Ensure user will type into a container element rather than into the editor content DIV directly\n * @param position The position that user is about to type to\n * @param keyboardEvent Optional keyboard event object\n */\n ensureTypeInContainer(position: NodePosition, keyboardEvent?: KeyboardEvent) {\n // No OP\n }\n\n //#endregion\n\n //#region Dark mode APIs\n\n /**\n * Transform the given node and all its child nodes to dark mode color if editor is in dark mode\n * @param node The node to transform\n * @param direction The transform direction. @default ColorTransformDirection.LightToDark\n */\n transformToDarkColor(\n node: Node,\n direction:\n | ColorTransformDirection\n | CompatibleColorTransformDirection = ColorTransformDirection.LightToDark\n ) {\n const core = this.getCore();\n\n if (core.lifecycle.isDarkMode) {\n transformColor(\n node,\n true /*includeSelf*/,\n direction == ColorTransformDirection.DarkToLight ? 'darkToLight' : 'lightToDark',\n core.darkColorHandler\n );\n }\n }\n\n /**\n * Check if the given experimental feature is enabled\n * @param feature The feature to check\n */\n isFeatureEnabled(feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean {\n return (\n this.getContentModelEditorCore().experimentalFeatures.indexOf(\n feature as ExperimentalFeatures\n ) >= 0\n );\n }\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 return this.getDOMHelper().calculateZoomScale();\n }\n\n /**\n * Set 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 * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.\n */\n setZoomScale(scale: number): void {\n if (scale > 0 && scale <= 10) {\n const oldValue = this.getZoomScale();\n\n if (oldValue != scale) {\n this.triggerEvent(\n 'zoomChanged',\n {\n newZoomScale: scale,\n },\n true /*broadcast*/\n );\n }\n }\n }\n\n /**\n * @deprecated Use getZoomScale() instead\n */\n getSizeTransformer(): SizeTransformer {\n return this.getContentModelEditorCore().sizeTransformer;\n }\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getDarkColorHandler(): DarkColorHandler {\n const core = this.getContentModelEditorCore();\n return core.darkColorHandler;\n }\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 return this.getCore().domEvent.isInIME;\n }\n\n private retrieveFormatState(): ContentModelFormatState {\n const pendingFormat = this.getPendingFormat();\n const result: ContentModelFormatState = {};\n const model = this.getContentModelCopy('reduced');\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n }\n\n /**\n * @returns the current EditorAdapterCore object\n * @throws a standard Error if there's no core object\n */\n private getContentModelEditorCore(): EditorAdapterCore {\n if (!this.contentModelEditorCore) {\n throw new Error('Editor is already disposed');\n }\n\n return this.contentModelEditorCore;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
6
|
"roosterjs-editor-types": "^8.60.0",
|
|
7
7
|
"roosterjs-editor-dom": "^8.60.0",
|
|
8
|
-
"roosterjs-content-model-core": "^0.26.
|
|
9
|
-
"roosterjs-content-model-dom": "^0.26.
|
|
10
|
-
"roosterjs-content-model-types": "^0.26.
|
|
8
|
+
"roosterjs-content-model-core": "^0.26.4",
|
|
9
|
+
"roosterjs-content-model-dom": "^0.26.4",
|
|
10
|
+
"roosterjs-content-model-types": "^0.26.4"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.26.
|
|
12
|
+
"version": "0.26.3",
|
|
13
13
|
"main": "./lib/index.js",
|
|
14
14
|
"typings": "./lib/index.d.ts",
|
|
15
15
|
"module": "./lib-mjs/index.js",
|