roosterjs-content-model-types 9.52.0 → 9.53.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.
@@ -55,4 +55,16 @@ export declare type ExperimentalFeature = GraduatedExperimentalFeature
55
55
  /**
56
56
  * Transform the table border colors when switching from light to dark mode
57
57
  */
58
- | 'TransformTableBorderColors';
58
+ | 'TransformTableBorderColors'
59
+ /**
60
+ * When the editor content div is inside a Shadow DOM, enable shadow root detection
61
+ * in DOMHelper so that selection, focus, and element appending work correctly within
62
+ * the shadow boundary.
63
+ */
64
+ | 'ShadowDom'
65
+ /**
66
+ * Strip invisible unicode characters (U+E0000 to U+EFFFF) from text segments during DOM to Model conversion.
67
+ * These characters can be used to hide text in HTML and may cause unexpected behavior.
68
+ * @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
69
+ */
70
+ | 'FilterInvisibleUnicode';
@@ -1 +1 @@
1
- {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features (Graduated, only keep them for backward compatibility)\n */\nexport type GraduatedExperimentalFeature =\n /**\n * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n | 'PersistCache'\n /**\n * @deprecated\n * Workaround for the Legacy Image Edit\n */\n | 'LegacyImageSelection'\n\n /**\n * @deprecated\n * Prevent default browser behavior for copy/cut event,\n * and set the clipboard data with custom implementation.\n */\n | 'CustomCopyCut'\n\n /**\n * @deprecated\n * Export editor content as HTML using HTMLFast option\n */\n | 'ExportHTMLFast'\n\n /**\n * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options\n * Use Content Model handle ENTER key\n */\n | 'HandleEnterKey'\n\n /**\n * @deprecated\n * Get cloned root element from an independent HTML document instead of current document.\n * So any operation to the cloned root won't trigger network request for resources like images\n */\n | 'CloneIndependentRoot'\n\n /**\n * @deprecated\n * Allow caching list item elements.\n */\n | 'CacheList';\n\n/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n | GraduatedExperimentalFeature\n\n /**\n * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,\n * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the\n * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures\n * the original formatting of the selection marker is kept to match the pending format.\n */\n | 'KeepSelectionMarkerWhenEnteringTextNode'\n\n /**\n * Transform the table border colors when switching from light to dark mode\n */\n | 'TransformTableBorderColors';\n"]}
1
+ {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features (Graduated, only keep them for backward compatibility)\n */\nexport type GraduatedExperimentalFeature =\n /**\n * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n | 'PersistCache'\n /**\n * @deprecated\n * Workaround for the Legacy Image Edit\n */\n | 'LegacyImageSelection'\n\n /**\n * @deprecated\n * Prevent default browser behavior for copy/cut event,\n * and set the clipboard data with custom implementation.\n */\n | 'CustomCopyCut'\n\n /**\n * @deprecated\n * Export editor content as HTML using HTMLFast option\n */\n | 'ExportHTMLFast'\n\n /**\n * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options\n * Use Content Model handle ENTER key\n */\n | 'HandleEnterKey'\n\n /**\n * @deprecated\n * Get cloned root element from an independent HTML document instead of current document.\n * So any operation to the cloned root won't trigger network request for resources like images\n */\n | 'CloneIndependentRoot'\n\n /**\n * @deprecated\n * Allow caching list item elements.\n */\n | 'CacheList';\n\n/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n | GraduatedExperimentalFeature\n\n /**\n * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,\n * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the\n * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures\n * the original formatting of the selection marker is kept to match the pending format.\n */\n | 'KeepSelectionMarkerWhenEnteringTextNode'\n\n /**\n * Transform the table border colors when switching from light to dark mode\n */\n | 'TransformTableBorderColors'\n\n /**\n * When the editor content div is inside a Shadow DOM, enable shadow root detection\n * in DOMHelper so that selection, focus, and element appending work correctly within\n * the shadow boundary.\n */\n | 'ShadowDom'\n\n /**\n * Strip invisible unicode characters (U+E0000 to U+EFFFF) from text segments during DOM to Model conversion.\n * These characters can be used to hide text in HTML and may cause unexpected behavior.\n * @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n */\n | 'FilterInvisibleUnicode';\n"]}
@@ -102,4 +102,20 @@ export interface DOMHelper {
102
102
  * @returns An array of Ranges that match the search criteria
103
103
  */
104
104
  getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];
105
+ /**
106
+ * Get the current selection range, handling shadow DOM StaticRange conversion.
107
+ * Returns a live Range in all browsers.
108
+ */
109
+ getSelectionRange(): Range | null;
110
+ /**
111
+ * Set the selection to the given range, handling browser differences for shadow DOM.
112
+ * @param range The range to set
113
+ * @param isReverted Whether the selection is reverted (focus before anchor)
114
+ */
115
+ setSelectionRange(range: Range, isReverted?: boolean): void;
116
+ /**
117
+ * Append an element to the correct root container (shadow root or document.body)
118
+ * @param element The element to append
119
+ */
120
+ appendToRoot(element: HTMLElement): void;
105
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\n\n/**\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 * Find the closest block element ancestor from the given node within current editing scope\n * @param startFrom The node to start the search from\n * @returns The closest block element ancestor\n */\n findClosestBlockElement(startFrom: Node): HTMLElement;\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 /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement;\n\n /**\n * Get format of the container element\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors\n */\n getContainerFormat(\n isInDarkMode?: boolean,\n darkColorHandler?: DarkColorHandler\n ): ContentModelSegmentFormat;\n\n /**\n * Get text ranges by searching for a specific text, with options to match case and whole word.\n * This will only search within editable elements.\n * @param text The text to search for\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole word\n * @returns An array of Ranges that match the search criteria\n */\n getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];\n}\n"]}
1
+ {"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\n\n/**\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 * Find the closest block element ancestor from the given node within current editing scope\n * @param startFrom The node to start the search from\n * @returns The closest block element ancestor\n */\n findClosestBlockElement(startFrom: Node): HTMLElement;\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 /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement;\n\n /**\n * Get format of the container element\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors\n */\n getContainerFormat(\n isInDarkMode?: boolean,\n darkColorHandler?: DarkColorHandler\n ): ContentModelSegmentFormat;\n\n /**\n * Get text ranges by searching for a specific text, with options to match case and whole word.\n * This will only search within editable elements.\n * @param text The text to search for\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole word\n * @returns An array of Ranges that match the search criteria\n */\n getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];\n\n /**\n * Get the current selection range, handling shadow DOM StaticRange conversion.\n * Returns a live Range in all browsers.\n */\n getSelectionRange(): Range | null;\n\n /**\n * Set the selection to the given range, handling browser differences for shadow DOM.\n * @param range The range to set\n * @param isReverted Whether the selection is reverted (focus before anchor)\n */\n setSelectionRange(range: Range, isReverted?: boolean): void;\n\n /**\n * Append an element to the correct root container (shadow root or document.body)\n * @param element The element to append\n */\n appendToRoot(element: HTMLElement): void;\n}\n"]}
@@ -55,4 +55,16 @@ export declare type ExperimentalFeature = GraduatedExperimentalFeature
55
55
  /**
56
56
  * Transform the table border colors when switching from light to dark mode
57
57
  */
58
- | 'TransformTableBorderColors';
58
+ | 'TransformTableBorderColors'
59
+ /**
60
+ * When the editor content div is inside a Shadow DOM, enable shadow root detection
61
+ * in DOMHelper so that selection, focus, and element appending work correctly within
62
+ * the shadow boundary.
63
+ */
64
+ | 'ShadowDom'
65
+ /**
66
+ * Strip invisible unicode characters (U+E0000 to U+EFFFF) from text segments during DOM to Model conversion.
67
+ * These characters can be used to hide text in HTML and may cause unexpected behavior.
68
+ * @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
69
+ */
70
+ | 'FilterInvisibleUnicode';
@@ -1 +1 @@
1
- {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features (Graduated, only keep them for backward compatibility)\n */\nexport type GraduatedExperimentalFeature =\n /**\n * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n | 'PersistCache'\n /**\n * @deprecated\n * Workaround for the Legacy Image Edit\n */\n | 'LegacyImageSelection'\n\n /**\n * @deprecated\n * Prevent default browser behavior for copy/cut event,\n * and set the clipboard data with custom implementation.\n */\n | 'CustomCopyCut'\n\n /**\n * @deprecated\n * Export editor content as HTML using HTMLFast option\n */\n | 'ExportHTMLFast'\n\n /**\n * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options\n * Use Content Model handle ENTER key\n */\n | 'HandleEnterKey'\n\n /**\n * @deprecated\n * Get cloned root element from an independent HTML document instead of current document.\n * So any operation to the cloned root won't trigger network request for resources like images\n */\n | 'CloneIndependentRoot'\n\n /**\n * @deprecated\n * Allow caching list item elements.\n */\n | 'CacheList';\n\n/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n | GraduatedExperimentalFeature\n\n /**\n * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,\n * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the\n * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures\n * the original formatting of the selection marker is kept to match the pending format.\n */\n | 'KeepSelectionMarkerWhenEnteringTextNode'\n\n /**\n * Transform the table border colors when switching from light to dark mode\n */\n | 'TransformTableBorderColors';\n"]}
1
+ {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features (Graduated, only keep them for backward compatibility)\n */\nexport type GraduatedExperimentalFeature =\n /**\n * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n | 'PersistCache'\n /**\n * @deprecated\n * Workaround for the Legacy Image Edit\n */\n | 'LegacyImageSelection'\n\n /**\n * @deprecated\n * Prevent default browser behavior for copy/cut event,\n * and set the clipboard data with custom implementation.\n */\n | 'CustomCopyCut'\n\n /**\n * @deprecated\n * Export editor content as HTML using HTMLFast option\n */\n | 'ExportHTMLFast'\n\n /**\n * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options\n * Use Content Model handle ENTER key\n */\n | 'HandleEnterKey'\n\n /**\n * @deprecated\n * Get cloned root element from an independent HTML document instead of current document.\n * So any operation to the cloned root won't trigger network request for resources like images\n */\n | 'CloneIndependentRoot'\n\n /**\n * @deprecated\n * Allow caching list item elements.\n */\n | 'CacheList';\n\n/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n | GraduatedExperimentalFeature\n\n /**\n * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,\n * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the\n * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures\n * the original formatting of the selection marker is kept to match the pending format.\n */\n | 'KeepSelectionMarkerWhenEnteringTextNode'\n\n /**\n * Transform the table border colors when switching from light to dark mode\n */\n | 'TransformTableBorderColors'\n\n /**\n * When the editor content div is inside a Shadow DOM, enable shadow root detection\n * in DOMHelper so that selection, focus, and element appending work correctly within\n * the shadow boundary.\n */\n | 'ShadowDom'\n\n /**\n * Strip invisible unicode characters (U+E0000 to U+EFFFF) from text segments during DOM to Model conversion.\n * These characters can be used to hide text in HTML and may cause unexpected behavior.\n * @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n */\n | 'FilterInvisibleUnicode';\n"]}
@@ -102,4 +102,20 @@ export interface DOMHelper {
102
102
  * @returns An array of Ranges that match the search criteria
103
103
  */
104
104
  getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];
105
+ /**
106
+ * Get the current selection range, handling shadow DOM StaticRange conversion.
107
+ * Returns a live Range in all browsers.
108
+ */
109
+ getSelectionRange(): Range | null;
110
+ /**
111
+ * Set the selection to the given range, handling browser differences for shadow DOM.
112
+ * @param range The range to set
113
+ * @param isReverted Whether the selection is reverted (focus before anchor)
114
+ */
115
+ setSelectionRange(range: Range, isReverted?: boolean): void;
116
+ /**
117
+ * Append an element to the correct root container (shadow root or document.body)
118
+ * @param element The element to append
119
+ */
120
+ appendToRoot(element: HTMLElement): void;
105
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\n\n/**\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 * Find the closest block element ancestor from the given node within current editing scope\n * @param startFrom The node to start the search from\n * @returns The closest block element ancestor\n */\n findClosestBlockElement(startFrom: Node): HTMLElement;\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 /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement;\n\n /**\n * Get format of the container element\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors\n */\n getContainerFormat(\n isInDarkMode?: boolean,\n darkColorHandler?: DarkColorHandler\n ): ContentModelSegmentFormat;\n\n /**\n * Get text ranges by searching for a specific text, with options to match case and whole word.\n * This will only search within editable elements.\n * @param text The text to search for\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole word\n * @returns An array of Ranges that match the search criteria\n */\n getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];\n}\n"]}
1
+ {"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\n\n/**\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 * Find the closest block element ancestor from the given node within current editing scope\n * @param startFrom The node to start the search from\n * @returns The closest block element ancestor\n */\n findClosestBlockElement(startFrom: Node): HTMLElement;\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 /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement;\n\n /**\n * Get format of the container element\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors\n */\n getContainerFormat(\n isInDarkMode?: boolean,\n darkColorHandler?: DarkColorHandler\n ): ContentModelSegmentFormat;\n\n /**\n * Get text ranges by searching for a specific text, with options to match case and whole word.\n * This will only search within editable elements.\n * @param text The text to search for\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole word\n * @returns An array of Ranges that match the search criteria\n */\n getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];\n\n /**\n * Get the current selection range, handling shadow DOM StaticRange conversion.\n * Returns a live Range in all browsers.\n */\n getSelectionRange(): Range | null;\n\n /**\n * Set the selection to the given range, handling browser differences for shadow DOM.\n * @param range The range to set\n * @param isReverted Whether the selection is reverted (focus before anchor)\n */\n setSelectionRange(range: Range, isReverted?: boolean): void;\n\n /**\n * Append an element to the correct root container (shadow root or document.body)\n * @param element The element to append\n */\n appendToRoot(element: HTMLElement): void;\n}\n"]}
@@ -55,4 +55,16 @@ export declare type ExperimentalFeature = GraduatedExperimentalFeature
55
55
  /**
56
56
  * Transform the table border colors when switching from light to dark mode
57
57
  */
58
- | 'TransformTableBorderColors';
58
+ | 'TransformTableBorderColors'
59
+ /**
60
+ * When the editor content div is inside a Shadow DOM, enable shadow root detection
61
+ * in DOMHelper so that selection, focus, and element appending work correctly within
62
+ * the shadow boundary.
63
+ */
64
+ | 'ShadowDom'
65
+ /**
66
+ * Strip invisible unicode characters (U+E0000 to U+EFFFF) from text segments during DOM to Model conversion.
67
+ * These characters can be used to hide text in HTML and may cause unexpected behavior.
68
+ * @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
69
+ */
70
+ | 'FilterInvisibleUnicode';
@@ -1 +1 @@
1
- {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features (Graduated, only keep them for backward compatibility)\n */\nexport type GraduatedExperimentalFeature =\n /**\n * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n | 'PersistCache'\n /**\n * @deprecated\n * Workaround for the Legacy Image Edit\n */\n | 'LegacyImageSelection'\n\n /**\n * @deprecated\n * Prevent default browser behavior for copy/cut event,\n * and set the clipboard data with custom implementation.\n */\n | 'CustomCopyCut'\n\n /**\n * @deprecated\n * Export editor content as HTML using HTMLFast option\n */\n | 'ExportHTMLFast'\n\n /**\n * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options\n * Use Content Model handle ENTER key\n */\n | 'HandleEnterKey'\n\n /**\n * @deprecated\n * Get cloned root element from an independent HTML document instead of current document.\n * So any operation to the cloned root won't trigger network request for resources like images\n */\n | 'CloneIndependentRoot'\n\n /**\n * @deprecated\n * Allow caching list item elements.\n */\n | 'CacheList';\n\n/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n | GraduatedExperimentalFeature\n\n /**\n * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,\n * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the\n * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures\n * the original formatting of the selection marker is kept to match the pending format.\n */\n | 'KeepSelectionMarkerWhenEnteringTextNode'\n\n /**\n * Transform the table border colors when switching from light to dark mode\n */\n | 'TransformTableBorderColors';\n"]}
1
+ {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features (Graduated, only keep them for backward compatibility)\n */\nexport type GraduatedExperimentalFeature =\n /**\n * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n | 'PersistCache'\n /**\n * @deprecated\n * Workaround for the Legacy Image Edit\n */\n | 'LegacyImageSelection'\n\n /**\n * @deprecated\n * Prevent default browser behavior for copy/cut event,\n * and set the clipboard data with custom implementation.\n */\n | 'CustomCopyCut'\n\n /**\n * @deprecated\n * Export editor content as HTML using HTMLFast option\n */\n | 'ExportHTMLFast'\n\n /**\n * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options\n * Use Content Model handle ENTER key\n */\n | 'HandleEnterKey'\n\n /**\n * @deprecated\n * Get cloned root element from an independent HTML document instead of current document.\n * So any operation to the cloned root won't trigger network request for resources like images\n */\n | 'CloneIndependentRoot'\n\n /**\n * @deprecated\n * Allow caching list item elements.\n */\n | 'CacheList';\n\n/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n | GraduatedExperimentalFeature\n\n /**\n * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,\n * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the\n * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures\n * the original formatting of the selection marker is kept to match the pending format.\n */\n | 'KeepSelectionMarkerWhenEnteringTextNode'\n\n /**\n * Transform the table border colors when switching from light to dark mode\n */\n | 'TransformTableBorderColors'\n\n /**\n * When the editor content div is inside a Shadow DOM, enable shadow root detection\n * in DOMHelper so that selection, focus, and element appending work correctly within\n * the shadow boundary.\n */\n | 'ShadowDom'\n\n /**\n * Strip invisible unicode characters (U+E0000 to U+EFFFF) from text segments during DOM to Model conversion.\n * These characters can be used to hide text in HTML and may cause unexpected behavior.\n * @see https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n */\n | 'FilterInvisibleUnicode';\n"]}
@@ -102,4 +102,20 @@ export interface DOMHelper {
102
102
  * @returns An array of Ranges that match the search criteria
103
103
  */
104
104
  getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];
105
+ /**
106
+ * Get the current selection range, handling shadow DOM StaticRange conversion.
107
+ * Returns a live Range in all browsers.
108
+ */
109
+ getSelectionRange(): Range | null;
110
+ /**
111
+ * Set the selection to the given range, handling browser differences for shadow DOM.
112
+ * @param range The range to set
113
+ * @param isReverted Whether the selection is reverted (focus before anchor)
114
+ */
115
+ setSelectionRange(range: Range, isReverted?: boolean): void;
116
+ /**
117
+ * Append an element to the correct root container (shadow root or document.body)
118
+ * @param element The element to append
119
+ */
120
+ appendToRoot(element: HTMLElement): void;
105
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\n\n/**\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 * Find the closest block element ancestor from the given node within current editing scope\n * @param startFrom The node to start the search from\n * @returns The closest block element ancestor\n */\n findClosestBlockElement(startFrom: Node): HTMLElement;\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 /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement;\n\n /**\n * Get format of the container element\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors\n */\n getContainerFormat(\n isInDarkMode?: boolean,\n darkColorHandler?: DarkColorHandler\n ): ContentModelSegmentFormat;\n\n /**\n * Get text ranges by searching for a specific text, with options to match case and whole word.\n * This will only search within editable elements.\n * @param text The text to search for\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole word\n * @returns An array of Ranges that match the search criteria\n */\n getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];\n}\n"]}
1
+ {"version":3,"file":"DOMHelper.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/parameter/DOMHelper.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\n\n/**\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 * Find the closest block element ancestor from the given node within current editing scope\n * @param startFrom The node to start the search from\n * @returns The closest block element ancestor\n */\n findClosestBlockElement(startFrom: Node): HTMLElement;\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 /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement;\n\n /**\n * Get format of the container element\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors\n */\n getContainerFormat(\n isInDarkMode?: boolean,\n darkColorHandler?: DarkColorHandler\n ): ContentModelSegmentFormat;\n\n /**\n * Get text ranges by searching for a specific text, with options to match case and whole word.\n * This will only search within editable elements.\n * @param text The text to search for\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole word\n * @returns An array of Ranges that match the search criteria\n */\n getRangesByText(text: string, matchCase: boolean, wholeWord: boolean): Range[];\n\n /**\n * Get the current selection range, handling shadow DOM StaticRange conversion.\n * Returns a live Range in all browsers.\n */\n getSelectionRange(): Range | null;\n\n /**\n * Set the selection to the given range, handling browser differences for shadow DOM.\n * @param range The range to set\n * @param isReverted Whether the selection is reverted (focus before anchor)\n */\n setSelectionRange(range: Range, isReverted?: boolean): void;\n\n /**\n * Append an element to the correct root container (shadow root or document.body)\n * @param element The element to append\n */\n appendToRoot(element: HTMLElement): void;\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "roosterjs-content-model-types",
3
3
  "description": "Types for roosterjs",
4
4
  "dependencies": {},
5
- "version": "9.52.0",
5
+ "version": "9.53.0",
6
6
  "main": "./lib/index.js",
7
7
  "typings": "./lib/index.d.ts",
8
8
  "module": "./lib-mjs/index.js",