roosterjs-content-model-types 9.9.0 → 9.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context/DomIndexer.d.ts +14 -0
- package/lib/context/DomIndexer.js.map +1 -1
- package/lib/event/BeforePasteEvent.d.ts +4 -0
- package/lib/event/BeforePasteEvent.js.map +1 -1
- package/lib/parameter/DOMHelper.d.ts +2 -1
- package/lib/parameter/DOMHelper.js.map +1 -1
- package/lib/parameter/MergeModelOption.d.ts +4 -0
- package/lib/parameter/MergeModelOption.js.map +1 -1
- package/lib-amd/context/DomIndexer.d.ts +14 -0
- package/lib-amd/context/DomIndexer.js.map +1 -1
- package/lib-amd/event/BeforePasteEvent.d.ts +4 -0
- package/lib-amd/event/BeforePasteEvent.js.map +1 -1
- package/lib-amd/parameter/DOMHelper.d.ts +2 -1
- package/lib-amd/parameter/DOMHelper.js.map +1 -1
- package/lib-amd/parameter/MergeModelOption.d.ts +4 -0
- package/lib-amd/parameter/MergeModelOption.js.map +1 -1
- package/lib-mjs/context/DomIndexer.d.ts +14 -0
- package/lib-mjs/context/DomIndexer.js.map +1 -1
- package/lib-mjs/event/BeforePasteEvent.d.ts +4 -0
- package/lib-mjs/event/BeforePasteEvent.js.map +1 -1
- package/lib-mjs/parameter/DOMHelper.d.ts +2 -1
- package/lib-mjs/parameter/DOMHelper.js.map +1 -1
- package/lib-mjs/parameter/MergeModelOption.d.ts +4 -0
- package/lib-mjs/parameter/MergeModelOption.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ContentModelBlockGroup } from '../contentModel/blockGroup/ContentModelBlockGroup';
|
|
1
2
|
import type { CacheSelection } from '../pluginState/CachePluginState';
|
|
2
3
|
import type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';
|
|
3
4
|
import type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';
|
|
4
5
|
import type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';
|
|
5
6
|
import type { ContentModelTable } from '../contentModel/block/ContentModelTable';
|
|
6
7
|
import type { DOMSelection } from '../selection/DOMSelection';
|
|
8
|
+
import type { ContentModelEntity } from '../contentModel/entity/ContentModelEntity';
|
|
7
9
|
/**
|
|
8
10
|
* Represents an indexer object which provides methods to help build backward relationship
|
|
9
11
|
* from DOM node to Content Model
|
|
@@ -26,6 +28,12 @@ export interface DomIndexer {
|
|
|
26
28
|
* @param tableElement The new DOM node for this table
|
|
27
29
|
*/
|
|
28
30
|
onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Invoke when new block entity is created in DOM tree
|
|
33
|
+
* @param entity The related entity
|
|
34
|
+
* @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph
|
|
35
|
+
*/
|
|
36
|
+
onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;
|
|
29
37
|
/**
|
|
30
38
|
* When document content or selection is changed by user, we need to use this function to update the content model
|
|
31
39
|
* to reflect the latest document. This process can fail since the selected node may not have a related model data structure.
|
|
@@ -35,6 +43,12 @@ export interface DomIndexer {
|
|
|
35
43
|
* @returns True if reconcile successfully, otherwise false
|
|
36
44
|
*/
|
|
37
45
|
reconcileSelection: (model: ContentModelDocument, newSelection: DOMSelection, oldSelection?: CacheSelection) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* When id is changed from DOM element, update the new ID to related content model if possible
|
|
48
|
+
* @param element The element that has id changed
|
|
49
|
+
* @returns True if successfully updated, otherwise false
|
|
50
|
+
*/
|
|
51
|
+
reconcileElementId: (element: HTMLElement) => boolean;
|
|
38
52
|
/**
|
|
39
53
|
* When child list of editor content is changed, we can use this method to do sync the change from editor into content model.
|
|
40
54
|
* This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomIndexer.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DomIndexer.ts"],"names":[],"mappings":"","sourcesContent":["import type { CacheSelection } from '../pluginState/CachePluginState';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';\nimport type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';\nimport type { ContentModelTable } from '../contentModel/block/ContentModelTable';\nimport type { DOMSelection } from '../selection/DOMSelection';\n\n/**\n * Represents an indexer object which provides methods to help build backward relationship\n * from DOM node to Content Model\n */\nexport interface DomIndexer {\n /**\n * Invoked when processing a segment\n * @param segmentNode The new DOM node for this segment\n * @param paragraph Parent paragraph of this segment\n * @param segments The source segments\n */\n onSegment: (\n segmentNode: Node,\n paragraph: ContentModelParagraph,\n segments: ContentModelSegment[]\n ) => void;\n\n /**\n * Invoked when new paragraph node is created in DOM tree\n * @param paragraphElement The new DOM node for this paragraph\n */\n onParagraph: (paragraphElement: HTMLElement) => void;\n\n /**\n * Invoked when new table node is created in DOM tree\n * @param tableElement The new DOM node for this table\n */\n onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;\n\n /**\n * When document content or selection is changed by user, we need to use this function to update the content model\n * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.\n * @param model Current cached content model\n * @param newSelection Latest selection\n * @param oldSelection @optional Original selection before this change\n * @returns True if reconcile successfully, otherwise false\n */\n reconcileSelection: (\n model: ContentModelDocument,\n newSelection: DOMSelection,\n oldSelection?: CacheSelection\n ) => boolean;\n\n /**\n * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.\n * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,\n * and create a new TEXT node for the typed text. Here we use these information to remove original Br segment and create a new Text segment\n * in content model. But if we find anything that cannot be handled, return false so caller will invalidate the cached model\n * @param addedNodes Nodes added by browser during mutation\n * @param removedNodes Nodes removed by browser during mutation\n * @returns True if the changed nodes are successfully reconciled, otherwise false\n */\n reconcileChildList: (addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>) => boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomIndexer.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DomIndexer.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelBlockGroup } from '../contentModel/blockGroup/ContentModelBlockGroup';\nimport type { CacheSelection } from '../pluginState/CachePluginState';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';\nimport type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';\nimport type { ContentModelTable } from '../contentModel/block/ContentModelTable';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { ContentModelEntity } from '../contentModel/entity/ContentModelEntity';\n\n/**\n * Represents an indexer object which provides methods to help build backward relationship\n * from DOM node to Content Model\n */\nexport interface DomIndexer {\n /**\n * Invoked when processing a segment\n * @param segmentNode The new DOM node for this segment\n * @param paragraph Parent paragraph of this segment\n * @param segments The source segments\n */\n onSegment: (\n segmentNode: Node,\n paragraph: ContentModelParagraph,\n segments: ContentModelSegment[]\n ) => void;\n\n /**\n * Invoked when new paragraph node is created in DOM tree\n * @param paragraphElement The new DOM node for this paragraph\n */\n onParagraph: (paragraphElement: HTMLElement) => void;\n\n /**\n * Invoked when new table node is created in DOM tree\n * @param tableElement The new DOM node for this table\n */\n onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;\n\n /**\n * Invoke when new block entity is created in DOM tree\n * @param entity The related entity\n * @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph\n */\n onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;\n\n /**\n * When document content or selection is changed by user, we need to use this function to update the content model\n * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.\n * @param model Current cached content model\n * @param newSelection Latest selection\n * @param oldSelection @optional Original selection before this change\n * @returns True if reconcile successfully, otherwise false\n */\n reconcileSelection: (\n model: ContentModelDocument,\n newSelection: DOMSelection,\n oldSelection?: CacheSelection\n ) => boolean;\n\n /**\n * When id is changed from DOM element, update the new ID to related content model if possible\n * @param element The element that has id changed\n * @returns True if successfully updated, otherwise false\n */\n reconcileElementId: (element: HTMLElement) => boolean;\n\n /**\n * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.\n * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,\n * and create a new TEXT node for the typed text. Here we use these information to remove original Br segment and create a new Text segment\n * in content model. But if we find anything that cannot be handled, return false so caller will invalidate the cached model\n * @param addedNodes Nodes added by browser during mutation\n * @param removedNodes Nodes removed by browser during mutation\n * @returns True if the changed nodes are successfully reconciled, otherwise false\n */\n reconcileChildList: (addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>) => boolean;\n}\n"]}
|
|
@@ -47,4 +47,8 @@ export interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {
|
|
|
47
47
|
* customizedMerge Customized merge function to use when merging the paste fragment into the editor
|
|
48
48
|
*/
|
|
49
49
|
customizedMerge?: MergePastedContentFunc;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the current clipboard contains at least a block element.
|
|
52
|
+
*/
|
|
53
|
+
readonly containsBlockElements?: boolean;
|
|
50
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n\n /**\n * Whether the current clipboard contains at least a block element.\n */\n readonly containsBlockElements?: boolean;\n}\n"]}
|
|
@@ -5,8 +5,9 @@ export interface DOMHelper {
|
|
|
5
5
|
/**
|
|
6
6
|
* Check if the given DOM node is in editor
|
|
7
7
|
* @param node The node to check
|
|
8
|
+
* @param excludeRoot When pass true, the function will return false if the passed in node is the root node itself
|
|
8
9
|
*/
|
|
9
|
-
isNodeInEditor(node: Node): boolean;
|
|
10
|
+
isNodeInEditor(node: Node, excludeRoot?: boolean): boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Query HTML elements in editor by tag name.
|
|
12
13
|
* Be careful of this function since it will also return element under entity.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A helper class to provide DOM access APIs\n */\nexport interface DOMHelper {\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n */\n isNodeInEditor(node: Node): boolean;\n\n /**\n * Query HTML elements in editor by tag name.\n * Be careful of this function since it will also return element under entity.\n * @param tag Tag name of the element to query\n * @returns HTML Element array of the query result\n */\n queryElements<TTag extends keyof HTMLElementTagNameMap>(\n tag: TTag\n ): HTMLElementTagNameMap[TTag][];\n\n /**\n * Query HTML elements in editor by a selector string\n * Be careful of this function since it will also return element under entity.\n * @param selector Selector string to query\n * @returns HTML Element array of the query result\n */\n queryElements(selector: string): HTMLElement[];\n\n /**\n * Get plain text content of editor using textContent property\n */\n getTextContent(): string;\n\n /**\n * Calculate current zoom scale of editor\n */\n calculateZoomScale(): number;\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 setDomAttribute(name: string, value: string | null): void;\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 getDomAttribute(name: string): string | null;\n\n /**\n * Get DOM style of editor content DIV\n * @param style Name of the style\n */\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T];\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor<T extends keyof HTMLElementTagNameMap>(\n node: Node,\n selector?: T\n ): HTMLElementTagNameMap[T] | null;\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor(node: Node, selector?: string): HTMLElement | null;\n\n /**\n * Check if the editor has focus now\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean;\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A helper class to provide DOM access APIs\n */\nexport interface DOMHelper {\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n * @param excludeRoot When pass true, the function will return false if the passed in node is the root node itself\n */\n isNodeInEditor(node: Node, excludeRoot?: boolean): boolean;\n\n /**\n * Query HTML elements in editor by tag name.\n * Be careful of this function since it will also return element under entity.\n * @param tag Tag name of the element to query\n * @returns HTML Element array of the query result\n */\n queryElements<TTag extends keyof HTMLElementTagNameMap>(\n tag: TTag\n ): HTMLElementTagNameMap[TTag][];\n\n /**\n * Query HTML elements in editor by a selector string\n * Be careful of this function since it will also return element under entity.\n * @param selector Selector string to query\n * @returns HTML Element array of the query result\n */\n queryElements(selector: string): HTMLElement[];\n\n /**\n * Get plain text content of editor using textContent property\n */\n getTextContent(): string;\n\n /**\n * Calculate current zoom scale of editor\n */\n calculateZoomScale(): number;\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 setDomAttribute(name: string, value: string | null): void;\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 getDomAttribute(name: string): string | null;\n\n /**\n * Get DOM style of editor content DIV\n * @param style Name of the style\n */\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T];\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor<T extends keyof HTMLElementTagNameMap>(\n node: Node,\n selector?: T\n ): HTMLElementTagNameMap[T] | null;\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor(node: Node, selector?: string): HTMLElement | null;\n\n /**\n * Check if the editor has focus now\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean;\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeModelOption.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/MergeModelOption.ts"],"names":[],"mappings":"","sourcesContent":["import type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * Options to specify how to merge models\n */\nexport interface MergeModelOption {\n /**\n * When there is only a table to merge, whether merge this table into current table (if any), or just directly insert (nested table).\n * This is usually used when paste table inside a table\n * @default false\n */\n mergeTable?: boolean;\n\n /**\n * Use this insert position to merge instead of querying selection from target model\n * @default undefined\n */\n insertPosition?: InsertPoint;\n\n /**\n * Use this to decide whether to change the source model format when doing the merge.\n * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.\n * If the source model already has some format, it will not be overwritten.\n * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.\n * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.\n * 'none' the source segment format will not be modified.\n * @default undefined\n */\n mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MergeModelOption.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/MergeModelOption.ts"],"names":[],"mappings":"","sourcesContent":["import type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * Options to specify how to merge models\n */\nexport interface MergeModelOption {\n /**\n * When there is only a table to merge, whether merge this table into current table (if any), or just directly insert (nested table).\n * This is usually used when paste table inside a table\n * @default false\n */\n mergeTable?: boolean;\n\n /**\n * Use this insert position to merge instead of querying selection from target model\n * @default undefined\n */\n insertPosition?: InsertPoint;\n\n /**\n * Use this to decide whether to change the source model format when doing the merge.\n * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.\n * If the source model already has some format, it will not be overwritten.\n * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.\n * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.\n * 'none' the source segment format will not be modified.\n * @default undefined\n */\n mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';\n\n /**\n * Whether to add a paragraph after the merged content.\n */\n addParagraphAfterMergedContent?: boolean;\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ContentModelBlockGroup } from '../contentModel/blockGroup/ContentModelBlockGroup';
|
|
1
2
|
import type { CacheSelection } from '../pluginState/CachePluginState';
|
|
2
3
|
import type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';
|
|
3
4
|
import type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';
|
|
4
5
|
import type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';
|
|
5
6
|
import type { ContentModelTable } from '../contentModel/block/ContentModelTable';
|
|
6
7
|
import type { DOMSelection } from '../selection/DOMSelection';
|
|
8
|
+
import type { ContentModelEntity } from '../contentModel/entity/ContentModelEntity';
|
|
7
9
|
/**
|
|
8
10
|
* Represents an indexer object which provides methods to help build backward relationship
|
|
9
11
|
* from DOM node to Content Model
|
|
@@ -26,6 +28,12 @@ export interface DomIndexer {
|
|
|
26
28
|
* @param tableElement The new DOM node for this table
|
|
27
29
|
*/
|
|
28
30
|
onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Invoke when new block entity is created in DOM tree
|
|
33
|
+
* @param entity The related entity
|
|
34
|
+
* @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph
|
|
35
|
+
*/
|
|
36
|
+
onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;
|
|
29
37
|
/**
|
|
30
38
|
* When document content or selection is changed by user, we need to use this function to update the content model
|
|
31
39
|
* to reflect the latest document. This process can fail since the selected node may not have a related model data structure.
|
|
@@ -35,6 +43,12 @@ export interface DomIndexer {
|
|
|
35
43
|
* @returns True if reconcile successfully, otherwise false
|
|
36
44
|
*/
|
|
37
45
|
reconcileSelection: (model: ContentModelDocument, newSelection: DOMSelection, oldSelection?: CacheSelection) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* When id is changed from DOM element, update the new ID to related content model if possible
|
|
48
|
+
* @param element The element that has id changed
|
|
49
|
+
* @returns True if successfully updated, otherwise false
|
|
50
|
+
*/
|
|
51
|
+
reconcileElementId: (element: HTMLElement) => boolean;
|
|
38
52
|
/**
|
|
39
53
|
* When child list of editor content is changed, we can use this method to do sync the change from editor into content model.
|
|
40
54
|
* This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomIndexer.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DomIndexer.ts"],"names":[],"mappings":"","sourcesContent":["import type { CacheSelection } from '../pluginState/CachePluginState';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';\nimport type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';\nimport type { ContentModelTable } from '../contentModel/block/ContentModelTable';\nimport type { DOMSelection } from '../selection/DOMSelection';\n\n/**\n * Represents an indexer object which provides methods to help build backward relationship\n * from DOM node to Content Model\n */\nexport interface DomIndexer {\n /**\n * Invoked when processing a segment\n * @param segmentNode The new DOM node for this segment\n * @param paragraph Parent paragraph of this segment\n * @param segments The source segments\n */\n onSegment: (\n segmentNode: Node,\n paragraph: ContentModelParagraph,\n segments: ContentModelSegment[]\n ) => void;\n\n /**\n * Invoked when new paragraph node is created in DOM tree\n * @param paragraphElement The new DOM node for this paragraph\n */\n onParagraph: (paragraphElement: HTMLElement) => void;\n\n /**\n * Invoked when new table node is created in DOM tree\n * @param tableElement The new DOM node for this table\n */\n onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;\n\n /**\n * When document content or selection is changed by user, we need to use this function to update the content model\n * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.\n * @param model Current cached content model\n * @param newSelection Latest selection\n * @param oldSelection @optional Original selection before this change\n * @returns True if reconcile successfully, otherwise false\n */\n reconcileSelection: (\n model: ContentModelDocument,\n newSelection: DOMSelection,\n oldSelection?: CacheSelection\n ) => boolean;\n\n /**\n * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.\n * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,\n * and create a new TEXT node for the typed text. Here we use these information to remove original Br segment and create a new Text segment\n * in content model. But if we find anything that cannot be handled, return false so caller will invalidate the cached model\n * @param addedNodes Nodes added by browser during mutation\n * @param removedNodes Nodes removed by browser during mutation\n * @returns True if the changed nodes are successfully reconciled, otherwise false\n */\n reconcileChildList: (addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>) => boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomIndexer.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DomIndexer.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelBlockGroup } from '../contentModel/blockGroup/ContentModelBlockGroup';\nimport type { CacheSelection } from '../pluginState/CachePluginState';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';\nimport type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';\nimport type { ContentModelTable } from '../contentModel/block/ContentModelTable';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { ContentModelEntity } from '../contentModel/entity/ContentModelEntity';\n\n/**\n * Represents an indexer object which provides methods to help build backward relationship\n * from DOM node to Content Model\n */\nexport interface DomIndexer {\n /**\n * Invoked when processing a segment\n * @param segmentNode The new DOM node for this segment\n * @param paragraph Parent paragraph of this segment\n * @param segments The source segments\n */\n onSegment: (\n segmentNode: Node,\n paragraph: ContentModelParagraph,\n segments: ContentModelSegment[]\n ) => void;\n\n /**\n * Invoked when new paragraph node is created in DOM tree\n * @param paragraphElement The new DOM node for this paragraph\n */\n onParagraph: (paragraphElement: HTMLElement) => void;\n\n /**\n * Invoked when new table node is created in DOM tree\n * @param tableElement The new DOM node for this table\n */\n onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;\n\n /**\n * Invoke when new block entity is created in DOM tree\n * @param entity The related entity\n * @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph\n */\n onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;\n\n /**\n * When document content or selection is changed by user, we need to use this function to update the content model\n * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.\n * @param model Current cached content model\n * @param newSelection Latest selection\n * @param oldSelection @optional Original selection before this change\n * @returns True if reconcile successfully, otherwise false\n */\n reconcileSelection: (\n model: ContentModelDocument,\n newSelection: DOMSelection,\n oldSelection?: CacheSelection\n ) => boolean;\n\n /**\n * When id is changed from DOM element, update the new ID to related content model if possible\n * @param element The element that has id changed\n * @returns True if successfully updated, otherwise false\n */\n reconcileElementId: (element: HTMLElement) => boolean;\n\n /**\n * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.\n * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,\n * and create a new TEXT node for the typed text. Here we use these information to remove original Br segment and create a new Text segment\n * in content model. But if we find anything that cannot be handled, return false so caller will invalidate the cached model\n * @param addedNodes Nodes added by browser during mutation\n * @param removedNodes Nodes removed by browser during mutation\n * @returns True if the changed nodes are successfully reconciled, otherwise false\n */\n reconcileChildList: (addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>) => boolean;\n}\n"]}
|
|
@@ -47,4 +47,8 @@ export interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {
|
|
|
47
47
|
* customizedMerge Customized merge function to use when merging the paste fragment into the editor
|
|
48
48
|
*/
|
|
49
49
|
customizedMerge?: MergePastedContentFunc;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the current clipboard contains at least a block element.
|
|
52
|
+
*/
|
|
53
|
+
readonly containsBlockElements?: boolean;
|
|
50
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n\n /**\n * Whether the current clipboard contains at least a block element.\n */\n readonly containsBlockElements?: boolean;\n}\n"]}
|
|
@@ -5,8 +5,9 @@ export interface DOMHelper {
|
|
|
5
5
|
/**
|
|
6
6
|
* Check if the given DOM node is in editor
|
|
7
7
|
* @param node The node to check
|
|
8
|
+
* @param excludeRoot When pass true, the function will return false if the passed in node is the root node itself
|
|
8
9
|
*/
|
|
9
|
-
isNodeInEditor(node: Node): boolean;
|
|
10
|
+
isNodeInEditor(node: Node, excludeRoot?: boolean): boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Query HTML elements in editor by tag name.
|
|
12
13
|
* Be careful of this function since it will also return element under entity.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A helper class to provide DOM access APIs\n */\nexport interface DOMHelper {\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n */\n isNodeInEditor(node: Node): boolean;\n\n /**\n * Query HTML elements in editor by tag name.\n * Be careful of this function since it will also return element under entity.\n * @param tag Tag name of the element to query\n * @returns HTML Element array of the query result\n */\n queryElements<TTag extends keyof HTMLElementTagNameMap>(\n tag: TTag\n ): HTMLElementTagNameMap[TTag][];\n\n /**\n * Query HTML elements in editor by a selector string\n * Be careful of this function since it will also return element under entity.\n * @param selector Selector string to query\n * @returns HTML Element array of the query result\n */\n queryElements(selector: string): HTMLElement[];\n\n /**\n * Get plain text content of editor using textContent property\n */\n getTextContent(): string;\n\n /**\n * Calculate current zoom scale of editor\n */\n calculateZoomScale(): number;\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 setDomAttribute(name: string, value: string | null): void;\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 getDomAttribute(name: string): string | null;\n\n /**\n * Get DOM style of editor content DIV\n * @param style Name of the style\n */\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T];\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor<T extends keyof HTMLElementTagNameMap>(\n node: Node,\n selector?: T\n ): HTMLElementTagNameMap[T] | null;\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor(node: Node, selector?: string): HTMLElement | null;\n\n /**\n * Check if the editor has focus now\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean;\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A helper class to provide DOM access APIs\n */\nexport interface DOMHelper {\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n * @param excludeRoot When pass true, the function will return false if the passed in node is the root node itself\n */\n isNodeInEditor(node: Node, excludeRoot?: boolean): boolean;\n\n /**\n * Query HTML elements in editor by tag name.\n * Be careful of this function since it will also return element under entity.\n * @param tag Tag name of the element to query\n * @returns HTML Element array of the query result\n */\n queryElements<TTag extends keyof HTMLElementTagNameMap>(\n tag: TTag\n ): HTMLElementTagNameMap[TTag][];\n\n /**\n * Query HTML elements in editor by a selector string\n * Be careful of this function since it will also return element under entity.\n * @param selector Selector string to query\n * @returns HTML Element array of the query result\n */\n queryElements(selector: string): HTMLElement[];\n\n /**\n * Get plain text content of editor using textContent property\n */\n getTextContent(): string;\n\n /**\n * Calculate current zoom scale of editor\n */\n calculateZoomScale(): number;\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 setDomAttribute(name: string, value: string | null): void;\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 getDomAttribute(name: string): string | null;\n\n /**\n * Get DOM style of editor content DIV\n * @param style Name of the style\n */\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T];\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor<T extends keyof HTMLElementTagNameMap>(\n node: Node,\n selector?: T\n ): HTMLElementTagNameMap[T] | null;\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor(node: Node, selector?: string): HTMLElement | null;\n\n /**\n * Check if the editor has focus now\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean;\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeModelOption.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/MergeModelOption.ts"],"names":[],"mappings":"","sourcesContent":["import type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * Options to specify how to merge models\n */\nexport interface MergeModelOption {\n /**\n * When there is only a table to merge, whether merge this table into current table (if any), or just directly insert (nested table).\n * This is usually used when paste table inside a table\n * @default false\n */\n mergeTable?: boolean;\n\n /**\n * Use this insert position to merge instead of querying selection from target model\n * @default undefined\n */\n insertPosition?: InsertPoint;\n\n /**\n * Use this to decide whether to change the source model format when doing the merge.\n * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.\n * If the source model already has some format, it will not be overwritten.\n * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.\n * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.\n * 'none' the source segment format will not be modified.\n * @default undefined\n */\n mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MergeModelOption.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/MergeModelOption.ts"],"names":[],"mappings":"","sourcesContent":["import type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * Options to specify how to merge models\n */\nexport interface MergeModelOption {\n /**\n * When there is only a table to merge, whether merge this table into current table (if any), or just directly insert (nested table).\n * This is usually used when paste table inside a table\n * @default false\n */\n mergeTable?: boolean;\n\n /**\n * Use this insert position to merge instead of querying selection from target model\n * @default undefined\n */\n insertPosition?: InsertPoint;\n\n /**\n * Use this to decide whether to change the source model format when doing the merge.\n * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.\n * If the source model already has some format, it will not be overwritten.\n * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.\n * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.\n * 'none' the source segment format will not be modified.\n * @default undefined\n */\n mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';\n\n /**\n * Whether to add a paragraph after the merged content.\n */\n addParagraphAfterMergedContent?: boolean;\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ContentModelBlockGroup } from '../contentModel/blockGroup/ContentModelBlockGroup';
|
|
1
2
|
import type { CacheSelection } from '../pluginState/CachePluginState';
|
|
2
3
|
import type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';
|
|
3
4
|
import type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';
|
|
4
5
|
import type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';
|
|
5
6
|
import type { ContentModelTable } from '../contentModel/block/ContentModelTable';
|
|
6
7
|
import type { DOMSelection } from '../selection/DOMSelection';
|
|
8
|
+
import type { ContentModelEntity } from '../contentModel/entity/ContentModelEntity';
|
|
7
9
|
/**
|
|
8
10
|
* Represents an indexer object which provides methods to help build backward relationship
|
|
9
11
|
* from DOM node to Content Model
|
|
@@ -26,6 +28,12 @@ export interface DomIndexer {
|
|
|
26
28
|
* @param tableElement The new DOM node for this table
|
|
27
29
|
*/
|
|
28
30
|
onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Invoke when new block entity is created in DOM tree
|
|
33
|
+
* @param entity The related entity
|
|
34
|
+
* @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph
|
|
35
|
+
*/
|
|
36
|
+
onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;
|
|
29
37
|
/**
|
|
30
38
|
* When document content or selection is changed by user, we need to use this function to update the content model
|
|
31
39
|
* to reflect the latest document. This process can fail since the selected node may not have a related model data structure.
|
|
@@ -35,6 +43,12 @@ export interface DomIndexer {
|
|
|
35
43
|
* @returns True if reconcile successfully, otherwise false
|
|
36
44
|
*/
|
|
37
45
|
reconcileSelection: (model: ContentModelDocument, newSelection: DOMSelection, oldSelection?: CacheSelection) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* When id is changed from DOM element, update the new ID to related content model if possible
|
|
48
|
+
* @param element The element that has id changed
|
|
49
|
+
* @returns True if successfully updated, otherwise false
|
|
50
|
+
*/
|
|
51
|
+
reconcileElementId: (element: HTMLElement) => boolean;
|
|
38
52
|
/**
|
|
39
53
|
* When child list of editor content is changed, we can use this method to do sync the change from editor into content model.
|
|
40
54
|
* This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomIndexer.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DomIndexer.ts"],"names":[],"mappings":"","sourcesContent":["import type { CacheSelection } from '../pluginState/CachePluginState';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';\nimport type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';\nimport type { ContentModelTable } from '../contentModel/block/ContentModelTable';\nimport type { DOMSelection } from '../selection/DOMSelection';\n\n/**\n * Represents an indexer object which provides methods to help build backward relationship\n * from DOM node to Content Model\n */\nexport interface DomIndexer {\n /**\n * Invoked when processing a segment\n * @param segmentNode The new DOM node for this segment\n * @param paragraph Parent paragraph of this segment\n * @param segments The source segments\n */\n onSegment: (\n segmentNode: Node,\n paragraph: ContentModelParagraph,\n segments: ContentModelSegment[]\n ) => void;\n\n /**\n * Invoked when new paragraph node is created in DOM tree\n * @param paragraphElement The new DOM node for this paragraph\n */\n onParagraph: (paragraphElement: HTMLElement) => void;\n\n /**\n * Invoked when new table node is created in DOM tree\n * @param tableElement The new DOM node for this table\n */\n onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;\n\n /**\n * When document content or selection is changed by user, we need to use this function to update the content model\n * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.\n * @param model Current cached content model\n * @param newSelection Latest selection\n * @param oldSelection @optional Original selection before this change\n * @returns True if reconcile successfully, otherwise false\n */\n reconcileSelection: (\n model: ContentModelDocument,\n newSelection: DOMSelection,\n oldSelection?: CacheSelection\n ) => boolean;\n\n /**\n * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.\n * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,\n * and create a new TEXT node for the typed text. Here we use these information to remove original Br segment and create a new Text segment\n * in content model. But if we find anything that cannot be handled, return false so caller will invalidate the cached model\n * @param addedNodes Nodes added by browser during mutation\n * @param removedNodes Nodes removed by browser during mutation\n * @returns True if the changed nodes are successfully reconciled, otherwise false\n */\n reconcileChildList: (addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>) => boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomIndexer.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DomIndexer.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelBlockGroup } from '../contentModel/blockGroup/ContentModelBlockGroup';\nimport type { CacheSelection } from '../pluginState/CachePluginState';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelParagraph } from '../contentModel/block/ContentModelParagraph';\nimport type { ContentModelSegment } from '../contentModel/segment/ContentModelSegment';\nimport type { ContentModelTable } from '../contentModel/block/ContentModelTable';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { ContentModelEntity } from '../contentModel/entity/ContentModelEntity';\n\n/**\n * Represents an indexer object which provides methods to help build backward relationship\n * from DOM node to Content Model\n */\nexport interface DomIndexer {\n /**\n * Invoked when processing a segment\n * @param segmentNode The new DOM node for this segment\n * @param paragraph Parent paragraph of this segment\n * @param segments The source segments\n */\n onSegment: (\n segmentNode: Node,\n paragraph: ContentModelParagraph,\n segments: ContentModelSegment[]\n ) => void;\n\n /**\n * Invoked when new paragraph node is created in DOM tree\n * @param paragraphElement The new DOM node for this paragraph\n */\n onParagraph: (paragraphElement: HTMLElement) => void;\n\n /**\n * Invoked when new table node is created in DOM tree\n * @param tableElement The new DOM node for this table\n */\n onTable: (tableElement: HTMLTableElement, tableModel: ContentModelTable) => void;\n\n /**\n * Invoke when new block entity is created in DOM tree\n * @param entity The related entity\n * @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph\n */\n onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;\n\n /**\n * When document content or selection is changed by user, we need to use this function to update the content model\n * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.\n * @param model Current cached content model\n * @param newSelection Latest selection\n * @param oldSelection @optional Original selection before this change\n * @returns True if reconcile successfully, otherwise false\n */\n reconcileSelection: (\n model: ContentModelDocument,\n newSelection: DOMSelection,\n oldSelection?: CacheSelection\n ) => boolean;\n\n /**\n * When id is changed from DOM element, update the new ID to related content model if possible\n * @param element The element that has id changed\n * @returns True if successfully updated, otherwise false\n */\n reconcileElementId: (element: HTMLElement) => boolean;\n\n /**\n * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.\n * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,\n * and create a new TEXT node for the typed text. Here we use these information to remove original Br segment and create a new Text segment\n * in content model. But if we find anything that cannot be handled, return false so caller will invalidate the cached model\n * @param addedNodes Nodes added by browser during mutation\n * @param removedNodes Nodes removed by browser during mutation\n * @returns True if the changed nodes are successfully reconciled, otherwise false\n */\n reconcileChildList: (addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>) => boolean;\n}\n"]}
|
|
@@ -47,4 +47,8 @@ export interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {
|
|
|
47
47
|
* customizedMerge Customized merge function to use when merging the paste fragment into the editor
|
|
48
48
|
*/
|
|
49
49
|
customizedMerge?: MergePastedContentFunc;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the current clipboard contains at least a block element.
|
|
52
|
+
*/
|
|
53
|
+
readonly containsBlockElements?: boolean;
|
|
50
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n\n /**\n * Whether the current clipboard contains at least a block element.\n */\n readonly containsBlockElements?: boolean;\n}\n"]}
|
|
@@ -5,8 +5,9 @@ export interface DOMHelper {
|
|
|
5
5
|
/**
|
|
6
6
|
* Check if the given DOM node is in editor
|
|
7
7
|
* @param node The node to check
|
|
8
|
+
* @param excludeRoot When pass true, the function will return false if the passed in node is the root node itself
|
|
8
9
|
*/
|
|
9
|
-
isNodeInEditor(node: Node): boolean;
|
|
10
|
+
isNodeInEditor(node: Node, excludeRoot?: boolean): boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Query HTML elements in editor by tag name.
|
|
12
13
|
* Be careful of this function since it will also return element under entity.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A helper class to provide DOM access APIs\n */\nexport interface DOMHelper {\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n */\n isNodeInEditor(node: Node): boolean;\n\n /**\n * Query HTML elements in editor by tag name.\n * Be careful of this function since it will also return element under entity.\n * @param tag Tag name of the element to query\n * @returns HTML Element array of the query result\n */\n queryElements<TTag extends keyof HTMLElementTagNameMap>(\n tag: TTag\n ): HTMLElementTagNameMap[TTag][];\n\n /**\n * Query HTML elements in editor by a selector string\n * Be careful of this function since it will also return element under entity.\n * @param selector Selector string to query\n * @returns HTML Element array of the query result\n */\n queryElements(selector: string): HTMLElement[];\n\n /**\n * Get plain text content of editor using textContent property\n */\n getTextContent(): string;\n\n /**\n * Calculate current zoom scale of editor\n */\n calculateZoomScale(): number;\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 setDomAttribute(name: string, value: string | null): void;\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 getDomAttribute(name: string): string | null;\n\n /**\n * Get DOM style of editor content DIV\n * @param style Name of the style\n */\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T];\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor<T extends keyof HTMLElementTagNameMap>(\n node: Node,\n selector?: T\n ): HTMLElementTagNameMap[T] | null;\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor(node: Node, selector?: string): HTMLElement | null;\n\n /**\n * Check if the editor has focus now\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean;\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A helper class to provide DOM access APIs\n */\nexport interface DOMHelper {\n /**\n * Check if the given DOM node is in editor\n * @param node The node to check\n * @param excludeRoot When pass true, the function will return false if the passed in node is the root node itself\n */\n isNodeInEditor(node: Node, excludeRoot?: boolean): boolean;\n\n /**\n * Query HTML elements in editor by tag name.\n * Be careful of this function since it will also return element under entity.\n * @param tag Tag name of the element to query\n * @returns HTML Element array of the query result\n */\n queryElements<TTag extends keyof HTMLElementTagNameMap>(\n tag: TTag\n ): HTMLElementTagNameMap[TTag][];\n\n /**\n * Query HTML elements in editor by a selector string\n * Be careful of this function since it will also return element under entity.\n * @param selector Selector string to query\n * @returns HTML Element array of the query result\n */\n queryElements(selector: string): HTMLElement[];\n\n /**\n * Get plain text content of editor using textContent property\n */\n getTextContent(): string;\n\n /**\n * Calculate current zoom scale of editor\n */\n calculateZoomScale(): number;\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 setDomAttribute(name: string, value: string | null): void;\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 getDomAttribute(name: string): string | null;\n\n /**\n * Get DOM style of editor content DIV\n * @param style Name of the style\n */\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T];\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor<T extends keyof HTMLElementTagNameMap>(\n node: Node,\n selector?: T\n ): HTMLElementTagNameMap[T] | null;\n\n /**\n * Find closest element ancestor start from the given node which matches the given selector\n * @param node Find ancestor start from this node\n * @param selector The expected selector. If null, return the first HTML Element found from start node\n * @returns An HTML element which matches the given selector. If the given start node matches the selector,\n * returns the given node\n */\n findClosestElementAncestor(node: Node, selector?: string): HTMLElement | null;\n\n /**\n * Check if the editor has focus now\n * @returns True if the editor has focus, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean;\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeModelOption.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/MergeModelOption.ts"],"names":[],"mappings":"","sourcesContent":["import type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * Options to specify how to merge models\n */\nexport interface MergeModelOption {\n /**\n * When there is only a table to merge, whether merge this table into current table (if any), or just directly insert (nested table).\n * This is usually used when paste table inside a table\n * @default false\n */\n mergeTable?: boolean;\n\n /**\n * Use this insert position to merge instead of querying selection from target model\n * @default undefined\n */\n insertPosition?: InsertPoint;\n\n /**\n * Use this to decide whether to change the source model format when doing the merge.\n * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.\n * If the source model already has some format, it will not be overwritten.\n * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.\n * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.\n * 'none' the source segment format will not be modified.\n * @default undefined\n */\n mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MergeModelOption.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/MergeModelOption.ts"],"names":[],"mappings":"","sourcesContent":["import type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * Options to specify how to merge models\n */\nexport interface MergeModelOption {\n /**\n * When there is only a table to merge, whether merge this table into current table (if any), or just directly insert (nested table).\n * This is usually used when paste table inside a table\n * @default false\n */\n mergeTable?: boolean;\n\n /**\n * Use this insert position to merge instead of querying selection from target model\n * @default undefined\n */\n insertPosition?: InsertPoint;\n\n /**\n * Use this to decide whether to change the source model format when doing the merge.\n * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.\n * If the source model already has some format, it will not be overwritten.\n * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.\n * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.\n * 'none' the source segment format will not be modified.\n * @default undefined\n */\n mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';\n\n /**\n * Whether to add a paragraph after the merged content.\n */\n addParagraphAfterMergedContent?: boolean;\n}\n"]}
|
package/package.json
CHANGED