roosterjs-content-model-core 9.50.0 → 9.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/lib/command/exportContent/exportContent.d.ts +3 -3
  2. package/lib/command/exportContent/exportContent.js +2 -2
  3. package/lib/command/exportContent/exportContent.js.map +1 -1
  4. package/lib/coreApi/createEditorContext/createEditorContext.js +2 -2
  5. package/lib/coreApi/createEditorContext/createEditorContext.js.map +1 -1
  6. package/lib/editor/Editor.js +0 -1
  7. package/lib/editor/Editor.js.map +1 -1
  8. package/lib/editor/core/DOMHelperImpl.d.ts +3 -0
  9. package/lib/editor/core/DOMHelperImpl.js +3 -9
  10. package/lib/editor/core/DOMHelperImpl.js.map +1 -1
  11. package/lib/editor/core/createEditorCore.js +2 -4
  12. package/lib/editor/core/createEditorCore.js.map +1 -1
  13. package/lib-amd/command/exportContent/exportContent.d.ts +3 -3
  14. package/lib-amd/command/exportContent/exportContent.js +2 -2
  15. package/lib-amd/command/exportContent/exportContent.js.map +1 -1
  16. package/lib-amd/coreApi/createEditorContext/createEditorContext.js +2 -2
  17. package/lib-amd/coreApi/createEditorContext/createEditorContext.js.map +1 -1
  18. package/lib-amd/editor/Editor.js +0 -1
  19. package/lib-amd/editor/Editor.js.map +1 -1
  20. package/lib-amd/editor/core/DOMHelperImpl.d.ts +3 -0
  21. package/lib-amd/editor/core/DOMHelperImpl.js +3 -9
  22. package/lib-amd/editor/core/DOMHelperImpl.js.map +1 -1
  23. package/lib-amd/editor/core/createEditorCore.js +2 -4
  24. package/lib-amd/editor/core/createEditorCore.js.map +1 -1
  25. package/lib-mjs/command/exportContent/exportContent.d.ts +3 -3
  26. package/lib-mjs/command/exportContent/exportContent.js +2 -2
  27. package/lib-mjs/command/exportContent/exportContent.js.map +1 -1
  28. package/lib-mjs/coreApi/createEditorContext/createEditorContext.js +2 -2
  29. package/lib-mjs/coreApi/createEditorContext/createEditorContext.js.map +1 -1
  30. package/lib-mjs/editor/Editor.js +1 -2
  31. package/lib-mjs/editor/Editor.js.map +1 -1
  32. package/lib-mjs/editor/core/DOMHelperImpl.d.ts +3 -0
  33. package/lib-mjs/editor/core/DOMHelperImpl.js +3 -9
  34. package/lib-mjs/editor/core/DOMHelperImpl.js.map +1 -1
  35. package/lib-mjs/editor/core/createEditorCore.js +2 -4
  36. package/lib-mjs/editor/core/createEditorCore.js.map +1 -1
  37. package/package.json +3 -3
@@ -2,7 +2,7 @@ import type { IEditor, ModelToDomOption, ModelToTextCallbacks } from 'roosterjs-
2
2
  /**
3
3
  * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity
4
4
  * @param editor The editor to get content from
5
- * @param mode Specify HTML to get HTML. This is the default option
5
+ * @param mode Specify HTML to get HTML.
6
6
  * @param options @optional Options for Model to DOM conversion
7
7
  */
8
8
  export declare function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;
@@ -10,9 +10,9 @@ export declare function exportContent(editor: IEditor, mode?: 'HTML', options?:
10
10
  * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.
11
11
  * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.
12
12
  * @param editor The editor to get content from
13
- * @param mode Specify HTMLFast to get HTML result.
13
+ * @param mode Specify HTMLFast to get HTML result. This is the default option
14
14
  */
15
- export declare function exportContent(editor: IEditor, mode: 'HTMLFast'): string;
15
+ export declare function exportContent(editor: IEditor, mode?: 'HTMLFast'): string;
16
16
  /**
17
17
  * Export plain text content
18
18
  * @param editor The editor to get content from
@@ -5,7 +5,7 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
5
  // Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version
6
6
  // Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach
7
7
  function exportContent(editor, mode, optionsOrCallbacks) {
8
- if (mode === void 0) { mode = 'HTML'; }
8
+ if (mode === void 0) { mode = 'HTMLFast'; }
9
9
  var model;
10
10
  switch (mode) {
11
11
  case 'PlainTextFast':
@@ -14,6 +14,7 @@ function exportContent(editor, mode, optionsOrCallbacks) {
14
14
  model = editor.getContentModelCopy('clean');
15
15
  return (0, roosterjs_content_model_dom_1.contentModelToText)(model, undefined /*separator*/, optionsOrCallbacks);
16
16
  case 'HTMLFast':
17
+ default:
17
18
  var clonedRoot = editor.getDOMHelper().getClonedRoot();
18
19
  if (editor.isDarkMode()) {
19
20
  (0, roosterjs_content_model_dom_1.transformColor)(clonedRoot, false /*includeSelf*/, 'darkToLight', editor.getColorManager(), {
@@ -22,7 +23,6 @@ function exportContent(editor, mode, optionsOrCallbacks) {
22
23
  }
23
24
  return getHTMLFromDOM(editor, clonedRoot);
24
25
  case 'HTML':
25
- default:
26
26
  model = editor.getContentModelCopy('clean');
27
27
  var doc = editor.getDocument();
28
28
  var div = doc.createElement('div');
@@ -1 +1 @@
1
- {"version":3,"file":"exportContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/exportContent/exportContent.ts"],"names":[],"mappings":";;;AAAA,2EAKqC;AA6CrC,yKAAyK;AACzK,6GAA6G;AAC7G,SAAgB,aAAa,CACzB,MAAe,EACf,IAA6C,EAC7C,kBAA4D;IAD5D,qBAAA,EAAA,aAA6C;IAG7C,IAAI,KAA2B,CAAC;IAEhC,QAAQ,IAAI,EAAE;QACV,KAAK,eAAe;YAChB,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE,CAAC;QAClD,KAAK,WAAW;YACZ,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAE5C,OAAO,IAAA,gDAAkB,EACrB,KAAK,EACL,SAAS,CAAC,aAAa,EACvB,kBAA0C,CAC7C,CAAC;QAEN,KAAK,UAAU;YACX,IAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,CAAC;YAEzD,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE;gBACrB,IAAA,4CAAc,EACV,UAAU,EACV,KAAK,CAAC,eAAe,EACrB,aAAa,EACb,MAAM,CAAC,eAAe,EAAE,EACxB;oBACI,YAAY,EAAE,MAAM,CAAC,4BAA4B,CAC7C,4BAA4B,CAC/B;iBACJ,CACJ,CAAC;aACL;YAED,OAAO,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAE9C,KAAK,MAAM,CAAC;QACZ;YACI,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAE5C,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACjC,IAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAErC,IAAA,+CAAiB,EACb,GAAG,EACH,GAAG,EACH,KAAK,EACL,IAAA,qDAAuB,EACnB,SAAS,CAAC,iBAAiB,EAC3B,kBAAsC,CACzC,CACJ,CAAC;YAEF,OAAO,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C;AACL,CAAC;AAzDD,sCAyDC;AAED,SAAS,cAAc,CAAC,MAAe,EAAE,IAAiB;IACtD,MAAM,CAAC,YAAY,CAAC,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAEvF,OAAO,IAAI,CAAC,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import {\n contentModelToDom,\n contentModelToText,\n createModelToDomContext,\n transformColor,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ExportContentMode,\n IEditor,\n ModelToDomOption,\n ModelToTextCallbacks,\n} from 'roosterjs-content-model-types';\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity\n * @param editor The editor to get content from\n * @param mode Specify HTML to get HTML. This is the default option\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.\n * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.\n * @param editor The editor to get content from\n * @param mode Specify HTMLFast to get HTML result.\n */\nexport function exportContent(editor: IEditor, mode: 'HTMLFast'): string;\n\n/**\n * Export plain text content\n * @param editor The editor to get content from\n * @param mode Specify PlainText to get plain text result\n * @param callbacks @optional Callbacks to customize conversion behavior\n */\nexport function exportContent(\n editor: IEditor,\n mode: 'PlainText',\n callbacks?: ModelToTextCallbacks\n): string;\n\n/**\n * Export plain text using editor's textContent property directly\n * @param editor The editor to get content from\n * @param mode Specify PlainTextFast to get plain text result using textContent property\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode: 'PlainTextFast'): string;\n\n// Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version\n// Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach\nexport function exportContent(\n editor: IEditor,\n mode: ExportContentMode | 'HTMLFast' = 'HTML',\n optionsOrCallbacks?: ModelToDomOption | ModelToTextCallbacks\n): string {\n let model: ContentModelDocument;\n\n switch (mode) {\n case 'PlainTextFast':\n return editor.getDOMHelper().getTextContent();\n case 'PlainText':\n model = editor.getContentModelCopy('clean');\n\n return contentModelToText(\n model,\n undefined /*separator*/,\n optionsOrCallbacks as ModelToTextCallbacks\n );\n\n case 'HTMLFast':\n const clonedRoot = editor.getDOMHelper().getClonedRoot();\n\n if (editor.isDarkMode()) {\n transformColor(\n clonedRoot,\n false /*includeSelf*/,\n 'darkToLight',\n editor.getColorManager(),\n {\n tableBorders: editor.isExperimentalFeatureEnabled(\n 'TransformTableBorderColors'\n ),\n }\n );\n }\n\n return getHTMLFromDOM(editor, clonedRoot);\n\n case 'HTML':\n default:\n model = editor.getContentModelCopy('clean');\n\n const doc = editor.getDocument();\n const div = doc.createElement('div');\n\n contentModelToDom(\n doc,\n div,\n model,\n createModelToDomContext(\n undefined /*editorContext*/,\n optionsOrCallbacks as ModelToDomOption\n )\n );\n\n return getHTMLFromDOM(editor, div);\n }\n}\n\nfunction getHTMLFromDOM(editor: IEditor, root: HTMLElement): string {\n editor.triggerEvent('extractContentWithDom', { clonedRoot: root }, true /*broadcast*/);\n\n return root.innerHTML;\n}\n"]}
1
+ {"version":3,"file":"exportContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/exportContent/exportContent.ts"],"names":[],"mappings":";;;AAAA,2EAKqC;AA6CrC,yKAAyK;AACzK,6GAA6G;AAC7G,SAAgB,aAAa,CACzB,MAAe,EACf,IAAiD,EACjD,kBAA4D;IAD5D,qBAAA,EAAA,iBAAiD;IAGjD,IAAI,KAA2B,CAAC;IAEhC,QAAQ,IAAI,EAAE;QACV,KAAK,eAAe;YAChB,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE,CAAC;QAClD,KAAK,WAAW;YACZ,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAE5C,OAAO,IAAA,gDAAkB,EACrB,KAAK,EACL,SAAS,CAAC,aAAa,EACvB,kBAA0C,CAC7C,CAAC;QAEN,KAAK,UAAU,CAAC;QAChB;YACI,IAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,CAAC;YAEzD,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE;gBACrB,IAAA,4CAAc,EACV,UAAU,EACV,KAAK,CAAC,eAAe,EACrB,aAAa,EACb,MAAM,CAAC,eAAe,EAAE,EACxB;oBACI,YAAY,EAAE,MAAM,CAAC,4BAA4B,CAC7C,4BAA4B,CAC/B;iBACJ,CACJ,CAAC;aACL;YAED,OAAO,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAE9C,KAAK,MAAM;YACP,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAE5C,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACjC,IAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAErC,IAAA,+CAAiB,EACb,GAAG,EACH,GAAG,EACH,KAAK,EACL,IAAA,qDAAuB,EACnB,SAAS,CAAC,iBAAiB,EAC3B,kBAAsC,CACzC,CACJ,CAAC;YAEF,OAAO,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C;AACL,CAAC;AAzDD,sCAyDC;AAED,SAAS,cAAc,CAAC,MAAe,EAAE,IAAiB;IACtD,MAAM,CAAC,YAAY,CAAC,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAEvF,OAAO,IAAI,CAAC,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import {\n contentModelToDom,\n contentModelToText,\n createModelToDomContext,\n transformColor,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ExportContentMode,\n IEditor,\n ModelToDomOption,\n ModelToTextCallbacks,\n} from 'roosterjs-content-model-types';\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity\n * @param editor The editor to get content from\n * @param mode Specify HTML to get HTML.\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.\n * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.\n * @param editor The editor to get content from\n * @param mode Specify HTMLFast to get HTML result. This is the default option\n */\nexport function exportContent(editor: IEditor, mode?: 'HTMLFast'): string;\n\n/**\n * Export plain text content\n * @param editor The editor to get content from\n * @param mode Specify PlainText to get plain text result\n * @param callbacks @optional Callbacks to customize conversion behavior\n */\nexport function exportContent(\n editor: IEditor,\n mode: 'PlainText',\n callbacks?: ModelToTextCallbacks\n): string;\n\n/**\n * Export plain text using editor's textContent property directly\n * @param editor The editor to get content from\n * @param mode Specify PlainTextFast to get plain text result using textContent property\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode: 'PlainTextFast'): string;\n\n// Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version\n// Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach\nexport function exportContent(\n editor: IEditor,\n mode: ExportContentMode | 'HTMLFast' = 'HTMLFast',\n optionsOrCallbacks?: ModelToDomOption | ModelToTextCallbacks\n): string {\n let model: ContentModelDocument;\n\n switch (mode) {\n case 'PlainTextFast':\n return editor.getDOMHelper().getTextContent();\n case 'PlainText':\n model = editor.getContentModelCopy('clean');\n\n return contentModelToText(\n model,\n undefined /*separator*/,\n optionsOrCallbacks as ModelToTextCallbacks\n );\n\n case 'HTMLFast':\n default:\n const clonedRoot = editor.getDOMHelper().getClonedRoot();\n\n if (editor.isDarkMode()) {\n transformColor(\n clonedRoot,\n false /*includeSelf*/,\n 'darkToLight',\n editor.getColorManager(),\n {\n tableBorders: editor.isExperimentalFeatureEnabled(\n 'TransformTableBorderColors'\n ),\n }\n );\n }\n\n return getHTMLFromDOM(editor, clonedRoot);\n\n case 'HTML':\n model = editor.getContentModelCopy('clean');\n\n const doc = editor.getDocument();\n const div = doc.createElement('div');\n\n contentModelToDom(\n doc,\n div,\n model,\n createModelToDomContext(\n undefined /*editorContext*/,\n optionsOrCallbacks as ModelToDomOption\n )\n );\n\n return getHTMLFromDOM(editor, div);\n }\n}\n\nfunction getHTMLFromDOM(editor: IEditor, root: HTMLElement): string {\n editor.triggerEvent('extractContentWithDom', { clonedRoot: root }, true /*broadcast*/);\n\n return root.innerHTML;\n}\n"]}
@@ -8,10 +8,10 @@ var getRootComputedStyleForContext_1 = require("./getRootComputedStyleForContext
8
8
  * Create a EditorContext object used by ContentModel API
9
9
  */
10
10
  var createEditorContext = function (core, saveIndex) {
11
- var _a, _b, _c;
11
+ var _a, _b;
12
12
  var lifecycle = core.lifecycle, format = core.format, darkColorHandler = core.darkColorHandler, logicalRoot = core.logicalRoot, cache = core.cache, domHelper = core.domHelper;
13
13
  saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;
14
- var context = (0, tslib_1.__assign)({ isDarkMode: lifecycle.isDarkMode, defaultFormat: format.defaultFormat, pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined, darkColorHandler: darkColorHandler, addDelimiterForEntity: true, allowCacheElement: true, allowCacheListItem: !!((_b = core.experimentalFeatures) === null || _b === void 0 ? void 0 : _b.includes('CacheList')), domIndexer: saveIndex ? cache.domIndexer : undefined, zoomScale: domHelper.calculateZoomScale(), experimentalFeatures: (_c = core.experimentalFeatures) !== null && _c !== void 0 ? _c : [], paragraphMap: core.cache.paragraphMap, editorViewWidth: domHelper.getClientWidth() }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(logicalRoot.ownerDocument));
14
+ var context = (0, tslib_1.__assign)({ isDarkMode: lifecycle.isDarkMode, defaultFormat: format.defaultFormat, pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined, darkColorHandler: darkColorHandler, addDelimiterForEntity: true, allowCacheElement: true, domIndexer: saveIndex ? cache.domIndexer : undefined, zoomScale: domHelper.calculateZoomScale(), experimentalFeatures: (_b = core.experimentalFeatures) !== null && _b !== void 0 ? _b : [], paragraphMap: core.cache.paragraphMap, editorViewWidth: domHelper.getClientWidth() }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(logicalRoot.ownerDocument));
15
15
  if (core.domHelper.isRightToLeft()) {
16
16
  context.isRootRtl = true;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/createEditorContext/createEditorContext.ts"],"names":[],"mappings":";;;;AAAA,mFAAkF;AAGlF;;;GAGG;AACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;IAC5D,IAAA,SAAS,GAA8D,IAAI,UAAlE,EAAE,MAAM,GAAsD,IAAI,OAA1D,EAAE,gBAAgB,GAAoC,IAAI,iBAAxC,EAAE,WAAW,GAAuB,IAAI,YAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;IAEpF,SAAS,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;IAE5D,IAAM,OAAO,2BACT,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,SAAS,EAChD,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,IAAI,EAC3B,iBAAiB,EAAE,IAAI,EACvB,kBAAkB,EAAE,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,oBAAoB,0CAAE,QAAQ,CAAC,WAAW,CAAC,CAAA,EACtE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACpD,SAAS,EAAE,SAAS,CAAC,kBAAkB,EAAE,EACzC,oBAAoB,EAAE,MAAA,IAAI,CAAC,oBAAoB,mCAAI,EAAE,EACrD,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,eAAe,EAAE,SAAS,CAAC,cAAc,EAAE,IACxC,IAAA,+DAA8B,EAAC,WAAW,CAAC,aAAa,CAAC,CAC/D,CAAC;IAEF,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE;QAChC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;KAC5B;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AA1BW,QAAA,mBAAmB,uBA0B9B","sourcesContent":["import { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport type { EditorContext, CreateEditorContext } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Create a EditorContext object used by ContentModel API\n */\nexport const createEditorContext: CreateEditorContext = (core, saveIndex) => {\n const { lifecycle, format, darkColorHandler, logicalRoot, cache, domHelper } = core;\n\n saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;\n\n const context: EditorContext = {\n isDarkMode: lifecycle.isDarkMode,\n defaultFormat: format.defaultFormat,\n pendingFormat: format.pendingFormat ?? undefined,\n darkColorHandler: darkColorHandler,\n addDelimiterForEntity: true,\n allowCacheElement: true,\n allowCacheListItem: !!core.experimentalFeatures?.includes('CacheList'),\n domIndexer: saveIndex ? cache.domIndexer : undefined,\n zoomScale: domHelper.calculateZoomScale(),\n experimentalFeatures: core.experimentalFeatures ?? [],\n paragraphMap: core.cache.paragraphMap,\n editorViewWidth: domHelper.getClientWidth(),\n ...getRootComputedStyleForContext(logicalRoot.ownerDocument),\n };\n\n if (core.domHelper.isRightToLeft()) {\n context.isRootRtl = true;\n }\n\n return context;\n};\n"]}
1
+ {"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/createEditorContext/createEditorContext.ts"],"names":[],"mappings":";;;;AAAA,mFAAkF;AAGlF;;;GAGG;AACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;IAC5D,IAAA,SAAS,GAA8D,IAAI,UAAlE,EAAE,MAAM,GAAsD,IAAI,OAA1D,EAAE,gBAAgB,GAAoC,IAAI,iBAAxC,EAAE,WAAW,GAAuB,IAAI,YAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;IAEpF,SAAS,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;IAE5D,IAAM,OAAO,2BACT,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,SAAS,EAChD,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,IAAI,EAC3B,iBAAiB,EAAE,IAAI,EACvB,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACpD,SAAS,EAAE,SAAS,CAAC,kBAAkB,EAAE,EACzC,oBAAoB,EAAE,MAAA,IAAI,CAAC,oBAAoB,mCAAI,EAAE,EACrD,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,eAAe,EAAE,SAAS,CAAC,cAAc,EAAE,IACxC,IAAA,+DAA8B,EAAC,WAAW,CAAC,aAAa,CAAC,CAC/D,CAAC;IAEF,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE;QAChC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;KAC5B;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAzBW,QAAA,mBAAmB,uBAyB9B","sourcesContent":["import { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport type { EditorContext, CreateEditorContext } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Create a EditorContext object used by ContentModel API\n */\nexport const createEditorContext: CreateEditorContext = (core, saveIndex) => {\n const { lifecycle, format, darkColorHandler, logicalRoot, cache, domHelper } = core;\n\n saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;\n\n const context: EditorContext = {\n isDarkMode: lifecycle.isDarkMode,\n defaultFormat: format.defaultFormat,\n pendingFormat: format.pendingFormat ?? undefined,\n darkColorHandler: darkColorHandler,\n addDelimiterForEntity: true,\n allowCacheElement: true,\n domIndexer: saveIndex ? cache.domIndexer : undefined,\n zoomScale: domHelper.calculateZoomScale(),\n experimentalFeatures: core.experimentalFeatures ?? [],\n paragraphMap: core.cache.paragraphMap,\n editorViewWidth: domHelper.getClientWidth(),\n ...getRootComputedStyleForContext(logicalRoot.ownerDocument),\n };\n\n if (core.domHelper.isRightToLeft()) {\n context.isRootRtl = true;\n }\n\n return context;\n};\n"]}
@@ -35,7 +35,6 @@ var Editor = /** @class */ (function () {
35
35
  };
36
36
  this.core = (0, createEditorCore_1.createEditorCore)(contentDiv, options);
37
37
  var initialModel = (_a = options.initialModel) !== null && _a !== void 0 ? _a : (0, roosterjs_content_model_dom_1.createEmptyModel)(this.core.format.defaultFormat);
38
- (0, roosterjs_content_model_dom_1.sanitizeInvisibleUnicode)(initialModel);
39
38
  this.core.api.setContentModel(this.core, initialModel, { ignoreSelection: true }, undefined /*onNodeCreated*/, true /*isInitializing*/);
40
39
  this.core.plugins.forEach(function (plugin) { return plugin.initialize(_this); });
41
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-core/lib/editor/Editor.ts"],"names":[],"mappings":";;;;AAAA,4DAA2D;AAC3D,2EAQqC;AA6BrC;;GAEG;AACH;IAGI;;;;OAIG;IACH,gBAAY,UAA0B,EAAE,OAA2B;QAAnE,iBAgBC;QAhBuC,wBAAA,EAAA,YAA2B;;QAP3D,SAAI,GAAsB,IAAI,CAAC;QAyZ/B,wBAAmB,GAAyB,UAAC,IAAI,EAAE,IAAI;YAC3D,IAAI,IAAI,IAAI,OAAO,EAAE;gBACjB,OAAO,SAAS,CAAC;aACpB;YAED,IAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAgB,CAAC;YAE5D,IAAI,KAAI,CAAC,UAAU,EAAE,EAAE;gBACnB,IAAM,YAAY,GAAG,KAAI,CAAC,eAAe,EAAE,CAAC;gBAE5C,IAAA,4CAAc,EAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,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AAY,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,6CAA4B,GAA5B,UAA6B,WAAyC;QAClE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACO,wBAAO,GAAjB;QACI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAsBL,aAAC;AAAD,CAAC,AA9aD,IA8aC;AA9aY,wBAAM","sourcesContent":["import { createEditorCore } from './core/createEditorCore';\nimport {\n createEmptyModel,\n ChangeSource,\n cloneModel,\n transformColor,\n createDomToModelContextWithConfig,\n domToContentModel,\n sanitizeInvisibleUnicode,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelFormatter,\n ContentModelSegmentFormat,\n DarkColorHandler,\n DOMEventRecord,\n DOMHelper,\n DOMSelection,\n EditorEnvironment,\n FormatContentModelOptions,\n IEditor,\n PluginEventData,\n PluginEventFromType,\n PluginEventType,\n Snapshot,\n SnapshotsManager,\n EditorCore,\n EditorOptions,\n Rect,\n EntityState,\n CachedElementHandler,\n DomToModelOptionForCreateModel,\n AnnounceData,\n ExperimentalFeature,\n LegacyTrustedHTMLHandler,\n DOMCreator,\n} from 'roosterjs-content-model-types';\n\n/**\n * The main editor class based on Content Model\n */\nexport class Editor implements IEditor {\n private core: EditorCore | null = null;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorOptions = {}) {\n this.core = createEditorCore(contentDiv, options);\n\n const initialModel =\n options.initialModel ?? createEmptyModel(this.core.format.defaultFormat);\n\n sanitizeInvisibleUnicode(initialModel);\n\n this.core.api.setContentModel(\n this.core,\n initialModel,\n { ignoreSelection: true },\n undefined /*onNodeCreated*/,\n true /*isInitializing*/\n );\n this.core.plugins.forEach(plugin => plugin.initialize(this));\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose() {\n const core = this.getCore();\n\n for (let i = core.plugins.length - 1; i >= 0; i--) {\n const plugin = core.plugins[i];\n\n try {\n plugin.dispose();\n } catch (e) {\n // Cache the error and pass it out, then keep going since dispose should always succeed\n core.disposeErrorHandler?.(plugin, e as Error);\n }\n }\n\n core.darkColorHandler.reset();\n\n this.core = null;\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return !this.core;\n }\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param mode What kind of Content Model we want. Currently we support the following values:\n * - disconnected: Returns a disconnected clone of Content Model from editor which you can do any change on it and it won't impact the editor content.\n * If there is any entity in editor, the returned object will contain cloned copy of entity wrapper element.\n * If editor is in dark mode, the cloned entity will be converted back to light mode.\n * - clean: Similar with disconnected, this will return a disconnected model, the difference is \"clean\" mode will not include any selection info.\n * This is usually used for exporting content\n */\n getContentModelCopy(mode: 'connected' | 'disconnected' | 'clean'): ContentModelDocument {\n const core = this.getCore();\n\n switch (mode) {\n case 'connected': // Get a connected model is deprecated. Now we will always return disconnected model\n case 'disconnected':\n return cloneModel(\n core.api.createContentModel(core, {\n tryGetFromCache: false,\n }),\n {\n includeCachedElement: this.cloneOptionCallback,\n }\n );\n\n case 'clean':\n const domToModelContext = createDomToModelContextWithConfig(\n core.environment.domToModelSettings.calculated,\n core.api.createEditorContext(core, false /*saveIndex*/)\n );\n\n return cloneModel(domToContentModel(core.physicalRoot, domToModelContext), {\n includeCachedElement: this.cloneOptionCallback,\n });\n }\n }\n\n /**\n * Get current running environment, such as if editor is running on Mac\n */\n getEnvironment(): EditorEnvironment {\n return this.getCore().environment;\n }\n\n /**\n * Get current DOM selection\n */\n getDOMSelection(): DOMSelection | null {\n const core = this.getCore();\n\n return core.api.getDOMSelection(core);\n }\n\n /**\n * Set DOMSelection into editor content.\n * @param selection The selection to set\n */\n setDOMSelection(selection: DOMSelection | null) {\n const core = this.getCore();\n\n core.api.setDOMSelection(core, selection);\n }\n\n /**\n * Set a new logical root (most likely due to focus change)\n * @param logicalRoot The new logical root (has to be child of physicalRoot)\n */\n setLogicalRoot(logicalRoot: HTMLDivElement) {\n const core = this.getCore();\n\n core.api.setLogicalRoot(core, logicalRoot);\n }\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\n formatContentModel(\n formatter: ContentModelFormatter,\n options?: FormatContentModelOptions,\n domToModelOptions?: DomToModelOptionForCreateModel\n ): void {\n const core = this.getCore();\n\n core.api.formatContentModel(core, formatter, options, domToModelOptions);\n }\n\n /**\n * Get pending format of editor if any, or return null\n */\n getPendingFormat(): ContentModelSegmentFormat | null {\n return this.getCore().format.pendingFormat?.format ?? null;\n }\n\n /**\n * Get a DOM Helper object to help access DOM tree in editor\n */\n getDOMHelper(): DOMHelper {\n return this.getCore().domHelper;\n }\n\n /**\n * Add a single undo snapshot to undo stack\n * @param entityState @optional State for entity if we want to add entity state for this snapshot\n */\n takeSnapshot(entityState?: EntityState): Snapshot | null {\n const core = this.getCore();\n\n return core.api.addUndoSnapshot(\n core,\n false /*canUndoByBackspace*/,\n entityState ? [entityState] : undefined\n );\n }\n\n /**\n * Restore an undo snapshot into editor\n * @param snapshot The snapshot to restore\n */\n restoreSnapshot(snapshot: Snapshot): void {\n const core = this.getCore();\n\n core.api.restoreUndoSnapshot(core, snapshot);\n }\n\n /**\n * Get document which contains this editor\n * @returns The HTML document which contains this editor\n */\n getDocument(): Document {\n return this.getCore().environment.document;\n }\n\n /**\n * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.\n */\n focus() {\n const core = this.getCore();\n core.api.focus(core);\n }\n\n /**\n * Check if focus is in editor now\n * @returns true if focus is in editor, otherwise false\n */\n hasFocus(): boolean {\n const core = this.getCore();\n return core.domHelper.hasFocus();\n }\n\n /**\n * Trigger an event to be dispatched to all plugins\n * @param eventType Type of the event\n * @param data data of the event with given type, this is the rest part of PluginEvent with the given type\n * @param broadcast indicates if the event needs to be dispatched to all plugins\n * True means to all, false means to allow exclusive handling from one plugin unless no one wants that\n * @returns the event object which is really passed into plugins. Some plugin may modify the event object so\n * the result of this function provides a chance to read the modified result\n */\n triggerEvent<T extends PluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const core = this.getCore();\n const event = ({\n eventType,\n ...data,\n } as any) as PluginEventFromType<T>;\n core.api.triggerEvent(core, event, broadcast);\n\n return event;\n }\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void {\n const core = this.getCore();\n return core.api.attachDomEvent(core, eventMap);\n }\n\n /**\n * Get undo snapshots manager\n */\n getSnapshotsManager(): SnapshotsManager {\n const core = this.getCore();\n\n return core.undo.snapshotsManager;\n }\n\n /**\n * Check if the editor is in dark mode\n * @returns True if the editor is in dark mode, otherwise false\n */\n isDarkMode(): boolean {\n return this.getCore().lifecycle.isDarkMode;\n }\n\n /**\n * Set the dark mode state and transforms the content to match the new state.\n * @param isDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.\n */\n setDarkModeState(isDarkMode?: boolean) {\n const core = this.getCore();\n\n if (!!isDarkMode != core.lifecycle.isDarkMode) {\n transformColor(\n core.physicalRoot,\n false /*includeSelf*/,\n isDarkMode ? 'lightToDark' : 'darkToLight',\n core.darkColorHandler,\n {\n tableBorders: this.isExperimentalFeatureEnabled('TransformTableBorderColors'),\n },\n core.format.defaultFormat.textColor\n );\n\n core.lifecycle.isDarkMode = !!isDarkMode;\n\n core.api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: isDarkMode\n ? ChangeSource.SwitchToDarkMode\n : ChangeSource.SwitchToLightMode,\n skipUndo: true,\n },\n true\n );\n }\n }\n\n /**\n * Check if editor is in Shadow Edit mode\n */\n isInShadowEdit() {\n return !!this.getCore().lifecycle.shadowEditFragment;\n }\n\n /**\n * Make the editor in \"Shadow Edit\" mode.\n * In Shadow Edit mode, all format change will finally be ignored.\n * This can be used for building a live preview feature for format button, to allow user\n * see format result without really apply it.\n * This function can be called repeated. If editor is already in shadow edit mode, we can still\n * use this function to do more shadow edit operation.\n */\n startShadowEdit() {\n const core = this.getCore();\n core.api.switchShadowEdit(core, true /*isOn*/);\n }\n\n /**\n * Leave \"Shadow Edit\" mode, all changes made during shadow edit will be discarded\n */\n stopShadowEdit() {\n const core = this.getCore();\n core.api.switchShadowEdit(core, false /*isOn*/);\n }\n\n /**\n * Get a color manager object for this editor.\n */\n getColorManager(): DarkColorHandler {\n return this.getCore().darkColorHandler;\n }\n\n /**\n * @deprecated\n * Get a function to convert HTML string to trusted HTML string.\n * By default it will just return the input HTML directly. To override this behavior,\n * pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n getTrustedHTMLHandler(): LegacyTrustedHTMLHandler {\n return this.getCore().trustedHTMLHandler;\n }\n\n /**\n * Get a function to convert HTML string to a trust Document.\n * By default it will just convert the original HTML string into a Document object directly.\n * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n getDOMCreator(): DOMCreator {\n return this.getCore().domCreator;\n }\n\n /**\n * Get the scroll container of the editor\n */\n getScrollContainer(): HTMLElement {\n return this.getCore().domEvent.scrollContainer;\n }\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n */\n getVisibleViewport(): Rect | null {\n return this.getCore().api.getVisibleViewport(this.getCore());\n }\n\n /**\n * Add CSS rules for editor\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to clear existing rules\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule.\n */\n setEditorStyle(\n key: string,\n cssRule: string | null,\n subSelectors?: 'before' | 'after' | string[]\n ): void {\n const core = this.getCore();\n\n core.api.setEditorStyle(core, key, cssRule, subSelectors);\n }\n\n /**\n * Announce the given data\n * @param announceData Data to announce\n */\n announce(announceData: AnnounceData): void {\n const core = this.getCore();\n\n core.api.announce(core, announceData);\n }\n\n /**\n * Check if a given feature is enabled\n * @param featureName The name of feature to check\n */\n isExperimentalFeatureEnabled(featureName: ExperimentalFeature | string): boolean {\n return this.getCore().experimentalFeatures.indexOf(featureName) >= 0;\n }\n\n /**\n * @returns the current EditorCore object\n * @throws a standard Error if there's no core object\n */\n protected getCore(): EditorCore {\n if (!this.core) {\n throw new Error('Editor is already disposed');\n }\n return this.core;\n }\n\n private cloneOptionCallback: CachedElementHandler = (node, type) => {\n if (type == 'cache') {\n return undefined;\n }\n\n const result = node.cloneNode(true /*deep*/) as HTMLElement;\n\n if (this.isDarkMode()) {\n const colorHandler = this.getColorManager();\n\n transformColor(result, true /*includeSelf*/, 'darkToLight', colorHandler, {\n tableBorders: this.isExperimentalFeatureEnabled('TransformTableBorderColors'),\n });\n\n result.style.color = result.style.color || 'inherit';\n result.style.backgroundColor = result.style.backgroundColor || 'inherit';\n }\n\n return result;\n };\n}\n"]}
1
+ {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-core/lib/editor/Editor.ts"],"names":[],"mappings":";;;;AAAA,4DAA2D;AAC3D,2EAOqC;AA6BrC;;GAEG;AACH;IAGI;;;;OAIG;IACH,gBAAY,UAA0B,EAAE,OAA2B;QAAnE,iBAcC;Q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+BAAc,GAAd,UACI,GAAW,EACX,OAAsB,EACtB,YAA4C;QAE5C,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAE5B,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACH,yBAAQ,GAAR,UAAS,YAA0B;QAC/B,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAE5B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,6CAA4B,GAA5B,UAA6B,WAAyC;QAClE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACO,wBAAO,GAAjB;QACI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAsBL,aAAC;AAAD,CAAC,AA5aD,IA4aC;AA5aY,wBAAM","sourcesContent":["import { createEditorCore } from './core/createEditorCore';\nimport {\n createEmptyModel,\n ChangeSource,\n cloneModel,\n transformColor,\n createDomToModelContextWithConfig,\n domToContentModel,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelFormatter,\n ContentModelSegmentFormat,\n DarkColorHandler,\n DOMEventRecord,\n DOMHelper,\n DOMSelection,\n EditorEnvironment,\n FormatContentModelOptions,\n IEditor,\n PluginEventData,\n PluginEventFromType,\n PluginEventType,\n Snapshot,\n SnapshotsManager,\n EditorCore,\n EditorOptions,\n Rect,\n EntityState,\n CachedElementHandler,\n DomToModelOptionForCreateModel,\n AnnounceData,\n ExperimentalFeature,\n LegacyTrustedHTMLHandler,\n DOMCreator,\n} from 'roosterjs-content-model-types';\n\n/**\n * The main editor class based on Content Model\n */\nexport class Editor implements IEditor {\n private core: EditorCore | null = null;\n\n /**\n * Creates an instance of Editor\n * @param contentDiv The DIV HTML element which will be the container element of editor\n * @param options An optional options object to customize the editor\n */\n constructor(contentDiv: HTMLDivElement, options: EditorOptions = {}) {\n this.core = createEditorCore(contentDiv, options);\n\n const initialModel =\n options.initialModel ?? createEmptyModel(this.core.format.defaultFormat);\n\n this.core.api.setContentModel(\n this.core,\n initialModel,\n { ignoreSelection: true },\n undefined /*onNodeCreated*/,\n true /*isInitializing*/\n );\n this.core.plugins.forEach(plugin => plugin.initialize(this));\n }\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose() {\n const core = this.getCore();\n\n for (let i = core.plugins.length - 1; i >= 0; i--) {\n const plugin = core.plugins[i];\n\n try {\n plugin.dispose();\n } catch (e) {\n // Cache the error and pass it out, then keep going since dispose should always succeed\n core.disposeErrorHandler?.(plugin, e as Error);\n }\n }\n\n core.darkColorHandler.reset();\n\n this.core = null;\n }\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean {\n return !this.core;\n }\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param mode What kind of Content Model we want. Currently we support the following values:\n * - disconnected: Returns a disconnected clone of Content Model from editor which you can do any change on it and it won't impact the editor content.\n * If there is any entity in editor, the returned object will contain cloned copy of entity wrapper element.\n * If editor is in dark mode, the cloned entity will be converted back to light mode.\n * - clean: Similar with disconnected, this will return a disconnected model, the difference is \"clean\" mode will not include any selection info.\n * This is usually used for exporting content\n */\n getContentModelCopy(mode: 'connected' | 'disconnected' | 'clean'): ContentModelDocument {\n const core = this.getCore();\n\n switch (mode) {\n case 'connected': // Get a connected model is deprecated. Now we will always return disconnected model\n case 'disconnected':\n return cloneModel(\n core.api.createContentModel(core, {\n tryGetFromCache: false,\n }),\n {\n includeCachedElement: this.cloneOptionCallback,\n }\n );\n\n case 'clean':\n const domToModelContext = createDomToModelContextWithConfig(\n core.environment.domToModelSettings.calculated,\n core.api.createEditorContext(core, false /*saveIndex*/)\n );\n\n return cloneModel(domToContentModel(core.physicalRoot, domToModelContext), {\n includeCachedElement: this.cloneOptionCallback,\n });\n }\n }\n\n /**\n * Get current running environment, such as if editor is running on Mac\n */\n getEnvironment(): EditorEnvironment {\n return this.getCore().environment;\n }\n\n /**\n * Get current DOM selection\n */\n getDOMSelection(): DOMSelection | null {\n const core = this.getCore();\n\n return core.api.getDOMSelection(core);\n }\n\n /**\n * Set DOMSelection into editor content.\n * @param selection The selection to set\n */\n setDOMSelection(selection: DOMSelection | null) {\n const core = this.getCore();\n\n core.api.setDOMSelection(core, selection);\n }\n\n /**\n * Set a new logical root (most likely due to focus change)\n * @param logicalRoot The new logical root (has to be child of physicalRoot)\n */\n setLogicalRoot(logicalRoot: HTMLDivElement) {\n const core = this.getCore();\n\n core.api.setLogicalRoot(core, logicalRoot);\n }\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\n formatContentModel(\n formatter: ContentModelFormatter,\n options?: FormatContentModelOptions,\n domToModelOptions?: DomToModelOptionForCreateModel\n ): void {\n const core = this.getCore();\n\n core.api.formatContentModel(core, formatter, options, domToModelOptions);\n }\n\n /**\n * Get pending format of editor if any, or return null\n */\n getPendingFormat(): ContentModelSegmentFormat | null {\n return this.getCore().format.pendingFormat?.format ?? null;\n }\n\n /**\n * Get a DOM Helper object to help access DOM tree in editor\n */\n getDOMHelper(): DOMHelper {\n return this.getCore().domHelper;\n }\n\n /**\n * Add a single undo snapshot to undo stack\n * @param entityState @optional State for entity if we want to add entity state for this snapshot\n */\n takeSnapshot(entityState?: EntityState): Snapshot | null {\n const core = this.getCore();\n\n return core.api.addUndoSnapshot(\n core,\n false /*canUndoByBackspace*/,\n entityState ? [entityState] : undefined\n );\n }\n\n /**\n * Restore an undo snapshot into editor\n * @param snapshot The snapshot to restore\n */\n restoreSnapshot(snapshot: Snapshot): void {\n const core = this.getCore();\n\n core.api.restoreUndoSnapshot(core, snapshot);\n }\n\n /**\n * Get document which contains this editor\n * @returns The HTML document which contains this editor\n */\n getDocument(): Document {\n return this.getCore().environment.document;\n }\n\n /**\n * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.\n */\n focus() {\n const core = this.getCore();\n core.api.focus(core);\n }\n\n /**\n * Check if focus is in editor now\n * @returns true if focus is in editor, otherwise false\n */\n hasFocus(): boolean {\n const core = this.getCore();\n return core.domHelper.hasFocus();\n }\n\n /**\n * Trigger an event to be dispatched to all plugins\n * @param eventType Type of the event\n * @param data data of the event with given type, this is the rest part of PluginEvent with the given type\n * @param broadcast indicates if the event needs to be dispatched to all plugins\n * True means to all, false means to allow exclusive handling from one plugin unless no one wants that\n * @returns the event object which is really passed into plugins. Some plugin may modify the event object so\n * the result of this function provides a chance to read the modified result\n */\n triggerEvent<T extends PluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast: boolean = false\n ): PluginEventFromType<T> {\n const core = this.getCore();\n const event = ({\n eventType,\n ...data,\n } as any) as PluginEventFromType<T>;\n core.api.triggerEvent(core, event, broadcast);\n\n return event;\n }\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void {\n const core = this.getCore();\n return core.api.attachDomEvent(core, eventMap);\n }\n\n /**\n * Get undo snapshots manager\n */\n getSnapshotsManager(): SnapshotsManager {\n const core = this.getCore();\n\n return core.undo.snapshotsManager;\n }\n\n /**\n * Check if the editor is in dark mode\n * @returns True if the editor is in dark mode, otherwise false\n */\n isDarkMode(): boolean {\n return this.getCore().lifecycle.isDarkMode;\n }\n\n /**\n * Set the dark mode state and transforms the content to match the new state.\n * @param isDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.\n */\n setDarkModeState(isDarkMode?: boolean) {\n const core = this.getCore();\n\n if (!!isDarkMode != core.lifecycle.isDarkMode) {\n transformColor(\n core.physicalRoot,\n false /*includeSelf*/,\n isDarkMode ? 'lightToDark' : 'darkToLight',\n core.darkColorHandler,\n {\n tableBorders: this.isExperimentalFeatureEnabled('TransformTableBorderColors'),\n },\n core.format.defaultFormat.textColor\n );\n\n core.lifecycle.isDarkMode = !!isDarkMode;\n\n core.api.triggerEvent(\n core,\n {\n eventType: 'contentChanged',\n source: isDarkMode\n ? ChangeSource.SwitchToDarkMode\n : ChangeSource.SwitchToLightMode,\n skipUndo: true,\n },\n true\n );\n }\n }\n\n /**\n * Check if editor is in Shadow Edit mode\n */\n isInShadowEdit() {\n return !!this.getCore().lifecycle.shadowEditFragment;\n }\n\n /**\n * Make the editor in \"Shadow Edit\" mode.\n * In Shadow Edit mode, all format change will finally be ignored.\n * This can be used for building a live preview feature for format button, to allow user\n * see format result without really apply it.\n * This function can be called repeated. If editor is already in shadow edit mode, we can still\n * use this function to do more shadow edit operation.\n */\n startShadowEdit() {\n const core = this.getCore();\n core.api.switchShadowEdit(core, true /*isOn*/);\n }\n\n /**\n * Leave \"Shadow Edit\" mode, all changes made during shadow edit will be discarded\n */\n stopShadowEdit() {\n const core = this.getCore();\n core.api.switchShadowEdit(core, false /*isOn*/);\n }\n\n /**\n * Get a color manager object for this editor.\n */\n getColorManager(): DarkColorHandler {\n return this.getCore().darkColorHandler;\n }\n\n /**\n * @deprecated\n * Get a function to convert HTML string to trusted HTML string.\n * By default it will just return the input HTML directly. To override this behavior,\n * pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n getTrustedHTMLHandler(): LegacyTrustedHTMLHandler {\n return this.getCore().trustedHTMLHandler;\n }\n\n /**\n * Get a function to convert HTML string to a trust Document.\n * By default it will just convert the original HTML string into a Document object directly.\n * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n getDOMCreator(): DOMCreator {\n return this.getCore().domCreator;\n }\n\n /**\n * Get the scroll container of the editor\n */\n getScrollContainer(): HTMLElement {\n return this.getCore().domEvent.scrollContainer;\n }\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n */\n getVisibleViewport(): Rect | null {\n return this.getCore().api.getVisibleViewport(this.getCore());\n }\n\n /**\n * Add CSS rules for editor\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to clear existing rules\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule.\n */\n setEditorStyle(\n key: string,\n cssRule: string | null,\n subSelectors?: 'before' | 'after' | string[]\n ): void {\n const core = this.getCore();\n\n core.api.setEditorStyle(core, key, cssRule, subSelectors);\n }\n\n /**\n * Announce the given data\n * @param announceData Data to announce\n */\n announce(announceData: AnnounceData): void {\n const core = this.getCore();\n\n core.api.announce(core, announceData);\n }\n\n /**\n * Check if a given feature is enabled\n * @param featureName The name of feature to check\n */\n isExperimentalFeatureEnabled(featureName: ExperimentalFeature | string): boolean {\n return this.getCore().experimentalFeatures.indexOf(featureName) >= 0;\n }\n\n /**\n * @returns the current EditorCore object\n * @throws a standard Error if there's no core object\n */\n protected getCore(): EditorCore {\n if (!this.core) {\n throw new Error('Editor is already disposed');\n }\n return this.core;\n }\n\n private cloneOptionCallback: CachedElementHandler = (node, type) => {\n if (type == 'cache') {\n return undefined;\n }\n\n const result = node.cloneNode(true /*deep*/) as HTMLElement;\n\n if (this.isDarkMode()) {\n const colorHandler = this.getColorManager();\n\n transformColor(result, true /*includeSelf*/, 'darkToLight', colorHandler, {\n tableBorders: this.isExperimentalFeatureEnabled('TransformTableBorderColors'),\n });\n\n result.style.color = result.style.color || 'inherit';\n result.style.backgroundColor = result.style.backgroundColor || 'inherit';\n }\n\n return result;\n };\n}\n"]}
@@ -3,6 +3,9 @@ import type { DOMHelper } from 'roosterjs-content-model-types';
3
3
  * @internal
4
4
  */
5
5
  export interface DOMHelperImplOption {
6
+ /**
7
+ * @deprecated This is always treated as true now
8
+ */
6
9
  cloneIndependentRoot?: boolean;
7
10
  }
8
11
  /**
@@ -5,7 +5,6 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
5
  var DOMHelperImpl = /** @class */ (function () {
6
6
  function DOMHelperImpl(contentDiv, options) {
7
7
  this.contentDiv = contentDiv;
8
- this.options = options;
9
8
  }
10
9
  DOMHelperImpl.prototype.queryElements = function (selector) {
11
10
  return (0, roosterjs_content_model_dom_1.toArray)(this.contentDiv.querySelectorAll(selector));
@@ -94,14 +93,9 @@ var DOMHelperImpl = /** @class */ (function () {
94
93
  * Get a deep cloned root element
95
94
  */
96
95
  DOMHelperImpl.prototype.getClonedRoot = function () {
97
- if (this.options.cloneIndependentRoot) {
98
- var doc = this.contentDiv.ownerDocument.implementation.createHTMLDocument();
99
- var clone = doc.importNode(this.contentDiv, true /*deep*/);
100
- return clone;
101
- }
102
- else {
103
- return this.contentDiv.cloneNode(true /*deep*/);
104
- }
96
+ var doc = this.contentDiv.ownerDocument.implementation.createHTMLDocument();
97
+ var clone = doc.importNode(this.contentDiv, true /*deep*/);
98
+ return clone;
105
99
  };
106
100
  /**
107
101
  * Get format of the container element
@@ -1 +1 @@
1
- {"version":3,"file":"DOMHelperImpl.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/editor/core/DOMHelperImpl.ts"],"names":[],"mappings":";;;AAAA,2EAOqC;AAcrC;IACI,uBAAoB,UAAuB,EAAU,OAA4B;QAA7D,eAAU,GAAV,UAAU,CAAa;QAAU,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAErF,qCAA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AAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AALD,0CAKC","sourcesContent":["import {\n getColor,\n getRangesByText,\n isBlockElement,\n isNodeOfType,\n parseValueWithUnit,\n toArray,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n DarkColorHandler,\n DOMHelper,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport interface DOMHelperImplOption {\n cloneIndependentRoot?: boolean;\n}\n\nclass DOMHelperImpl implements DOMHelper {\n constructor(private contentDiv: HTMLElement, private options: DOMHelperImplOption) {}\n\n queryElements(selector: string): HTMLElement[] {\n return toArray(this.contentDiv.querySelectorAll(selector)) as HTMLElement[];\n }\n\n getTextContent(): string {\n return this.contentDiv.textContent || '';\n }\n\n isNodeInEditor(node: Node, excludeRoot?: boolean): boolean {\n return excludeRoot && node == this.contentDiv ? false : this.contentDiv.contains(node);\n }\n\n calculateZoomScale(): number {\n const originalWidth = this.contentDiv.getBoundingClientRect()?.width || 0;\n const visualWidth = this.contentDiv.offsetWidth;\n\n return visualWidth > 0 && originalWidth > 0\n ? Math.round((originalWidth / visualWidth) * 100) / 100\n : 1;\n }\n\n setDomAttribute(name: string, value: string | null) {\n if (value === null) {\n this.contentDiv.removeAttribute(name);\n } else {\n this.contentDiv.setAttribute(name, value);\n }\n }\n\n getDomAttribute(name: string): string | null {\n return this.contentDiv.getAttribute(name);\n }\n\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T] {\n return this.contentDiv.style[style];\n }\n\n findClosestElementAncestor(startFrom: Node, selector?: string): HTMLElement | null {\n const startElement = isNodeOfType(startFrom, 'ELEMENT_NODE')\n ? startFrom\n : startFrom.parentElement;\n const closestElement = selector\n ? (startElement?.closest(selector) as HTMLElement | null)\n : startElement;\n\n return closestElement &&\n this.isNodeInEditor(closestElement) &&\n closestElement != this.contentDiv\n ? closestElement\n : null;\n }\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 let node: Node | null = startFrom;\n\n while (node && this.isNodeInEditor(node)) {\n if (isNodeOfType(node, 'ELEMENT_NODE') && isBlockElement(node)) {\n return node;\n }\n\n node = node.parentElement;\n }\n\n return this.contentDiv;\n }\n\n hasFocus(): boolean {\n const activeElement = this.contentDiv.ownerDocument.activeElement;\n return !!(activeElement && this.contentDiv.contains(activeElement));\n }\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean {\n const contentDiv = this.contentDiv;\n const style = contentDiv.ownerDocument.defaultView?.getComputedStyle(contentDiv);\n\n return style?.direction == 'rtl';\n }\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number {\n const contentDiv = this.contentDiv;\n const style = contentDiv.ownerDocument.defaultView?.getComputedStyle(contentDiv);\n const paddingLeft = parseValueWithUnit(style?.paddingLeft);\n const paddingRight = parseValueWithUnit(style?.paddingRight);\n return this.contentDiv.clientWidth - (paddingLeft + paddingRight);\n }\n\n /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement {\n if (this.options.cloneIndependentRoot) {\n const doc = this.contentDiv.ownerDocument.implementation.createHTMLDocument();\n const clone = doc.importNode(this.contentDiv, true /*deep*/);\n\n return clone;\n } else {\n return this.contentDiv.cloneNode(true /*deep*/) as HTMLElement;\n }\n }\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 const window = this.contentDiv.ownerDocument.defaultView;\n\n const style = window?.getComputedStyle(this.contentDiv);\n\n return style\n ? {\n fontSize: style.fontSize,\n fontFamily: style.fontFamily,\n fontWeight: style.fontWeight,\n textColor: getColor(\n this.contentDiv,\n false /*isBackgroundColor*/,\n !!isInDarkMode,\n darkColorHandler,\n style.color\n ),\n backgroundColor: getColor(\n this.contentDiv,\n true /*isBackgroundColor*/,\n !!isInDarkMode,\n darkColorHandler,\n style.backgroundColor\n ),\n italic: style.fontStyle == 'italic',\n letterSpacing: style.letterSpacing,\n lineHeight: style.lineHeight,\n strikethrough: style.textDecoration?.includes('line-through'),\n superOrSubScriptSequence: style.verticalAlign,\n underline: style.textDecoration?.includes('underline'),\n }\n : {};\n }\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 return getRangesByText(this.contentDiv, text, matchCase, wholeWord, true /*editableOnly*/);\n }\n}\n\n/**\n * @internal Create new instance of DOMHelper\n */\nexport function createDOMHelper(\n contentDiv: HTMLElement,\n options: DOMHelperImplOption = {}\n): DOMHelper {\n return new DOMHelperImpl(contentDiv, options);\n}\n"]}
1
+ {"version":3,"file":"DOMHelperImpl.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/editor/core/DOMHelperImpl.ts"],"names":[],"mappings":";;;AAAA,2EAOqC;AAiBrC;IACI,uBAAoB,UAAuB,EAAE,OAA6B;QAAtD,eAAU,GAAV,UAAU,CAAa;IAAkC,CAAC;IAE9E,qCAAa,GAAb,UAAc,QAAgB;QAC1B,OAAO,IAAA,qCAAO,EAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAkB,CAAC;IAChF,CAAC;IAED,sCAAc,GAAd;QACI,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,EAAE,CAAC;IAC7C,CAAC;IAED,sCAAc,GAAd,UAAe,IAAU,EAAE,WAAqB;QAC5C,OAAO,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,C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eAAe,CACxB;gBACD,MAAM,EAAE,KAAK,CAAC,SAAS,IAAI,QAAQ;gBACnC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,aAAa,EAAE,MAAA,KAAK,CAAC,cAAc,0CAAE,QAAQ,CAAC,cAAc,CAAC;gBAC7D,wBAAwB,EAAE,KAAK,CAAC,aAAa;gBAC7C,SAAS,EAAE,MAAA,KAAK,CAAC,cAAc,0CAAE,QAAQ,CAAC,WAAW,CAAC;aACzD;YACH,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;IAED;;;;;;;OAOG;IACH,uCAAe,GAAf,UAAgB,IAAY,EAAE,SAAkB,EAAE,SAAkB;QAChE,OAAO,IAAA,6CAAe,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC/F,CAAC;IACL,oBAAC;AAAD,CAAC,AAnKD,IAmKC;AAED;;GAEG;AACH,SAAgB,eAAe,CAC3B,UAAuB,EACvB,OAAiC;IAAjC,wBAAA,EAAA,YAAiC;IAEjC,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AALD,0CAKC","sourcesContent":["import {\n getColor,\n getRangesByText,\n isBlockElement,\n isNodeOfType,\n parseValueWithUnit,\n toArray,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n DarkColorHandler,\n DOMHelper,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport interface DOMHelperImplOption {\n /**\n * @deprecated This is always treated as true now\n */\n cloneIndependentRoot?: boolean;\n}\n\nclass DOMHelperImpl implements DOMHelper {\n constructor(private contentDiv: HTMLElement, options?: DOMHelperImplOption) {}\n\n queryElements(selector: string): HTMLElement[] {\n return toArray(this.contentDiv.querySelectorAll(selector)) as HTMLElement[];\n }\n\n getTextContent(): string {\n return this.contentDiv.textContent || '';\n }\n\n isNodeInEditor(node: Node, excludeRoot?: boolean): boolean {\n return excludeRoot && node == this.contentDiv ? false : this.contentDiv.contains(node);\n }\n\n calculateZoomScale(): number {\n const originalWidth = this.contentDiv.getBoundingClientRect()?.width || 0;\n const visualWidth = this.contentDiv.offsetWidth;\n\n return visualWidth > 0 && originalWidth > 0\n ? Math.round((originalWidth / visualWidth) * 100) / 100\n : 1;\n }\n\n setDomAttribute(name: string, value: string | null) {\n if (value === null) {\n this.contentDiv.removeAttribute(name);\n } else {\n this.contentDiv.setAttribute(name, value);\n }\n }\n\n getDomAttribute(name: string): string | null {\n return this.contentDiv.getAttribute(name);\n }\n\n getDomStyle<T extends keyof CSSStyleDeclaration>(style: T): CSSStyleDeclaration[T] {\n return this.contentDiv.style[style];\n }\n\n findClosestElementAncestor(startFrom: Node, selector?: string): HTMLElement | null {\n const startElement = isNodeOfType(startFrom, 'ELEMENT_NODE')\n ? startFrom\n : startFrom.parentElement;\n const closestElement = selector\n ? (startElement?.closest(selector) as HTMLElement | null)\n : startElement;\n\n return closestElement &&\n this.isNodeInEditor(closestElement) &&\n closestElement != this.contentDiv\n ? closestElement\n : null;\n }\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 let node: Node | null = startFrom;\n\n while (node && this.isNodeInEditor(node)) {\n if (isNodeOfType(node, 'ELEMENT_NODE') && isBlockElement(node)) {\n return node;\n }\n\n node = node.parentElement;\n }\n\n return this.contentDiv;\n }\n\n hasFocus(): boolean {\n const activeElement = this.contentDiv.ownerDocument.activeElement;\n return !!(activeElement && this.contentDiv.contains(activeElement));\n }\n\n /**\n * Check if the root element is in RTL mode\n */\n isRightToLeft(): boolean {\n const contentDiv = this.contentDiv;\n const style = contentDiv.ownerDocument.defaultView?.getComputedStyle(contentDiv);\n\n return style?.direction == 'rtl';\n }\n\n /**\n * Get the width of the editable area of the editor content div\n */\n getClientWidth(): number {\n const contentDiv = this.contentDiv;\n const style = contentDiv.ownerDocument.defaultView?.getComputedStyle(contentDiv);\n const paddingLeft = parseValueWithUnit(style?.paddingLeft);\n const paddingRight = parseValueWithUnit(style?.paddingRight);\n return this.contentDiv.clientWidth - (paddingLeft + paddingRight);\n }\n\n /**\n * Get a deep cloned root element\n */\n getClonedRoot(): HTMLElement {\n const doc = this.contentDiv.ownerDocument.implementation.createHTMLDocument();\n const clone = doc.importNode(this.contentDiv, true /*deep*/);\n\n return clone;\n }\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 const window = this.contentDiv.ownerDocument.defaultView;\n\n const style = window?.getComputedStyle(this.contentDiv);\n\n return style\n ? {\n fontSize: style.fontSize,\n fontFamily: style.fontFamily,\n fontWeight: style.fontWeight,\n textColor: getColor(\n this.contentDiv,\n false /*isBackgroundColor*/,\n !!isInDarkMode,\n darkColorHandler,\n style.color\n ),\n backgroundColor: getColor(\n this.contentDiv,\n true /*isBackgroundColor*/,\n !!isInDarkMode,\n darkColorHandler,\n style.backgroundColor\n ),\n italic: style.fontStyle == 'italic',\n letterSpacing: style.letterSpacing,\n lineHeight: style.lineHeight,\n strikethrough: style.textDecoration?.includes('line-through'),\n superOrSubScriptSequence: style.verticalAlign,\n underline: style.textDecoration?.includes('underline'),\n }\n : {};\n }\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 return getRangesByText(this.contentDiv, text, matchCase, wholeWord, true /*editableOnly*/);\n }\n}\n\n/**\n * @internal Create new instance of DOMHelper\n */\nexport function createDOMHelper(\n contentDiv: HTMLElement,\n options: DOMHelperImplOption = {}\n): DOMHelper {\n return new DOMHelperImpl(contentDiv, options);\n}\n"]}
@@ -14,7 +14,7 @@ var createEditorCorePlugins_1 = require("../../corePlugin/createEditorCorePlugin
14
14
  * @param options Editor options
15
15
  */
16
16
  function createEditorCore(contentDiv, options) {
17
- var _a, _b, _c;
17
+ var _a, _b;
18
18
  var corePlugins = (0, createEditorCorePlugins_1.createEditorCorePlugins)(options, contentDiv);
19
19
  var domCreator = (0, domCreator_1.createDOMCreator)(options.trustedHTMLHandler);
20
20
  return (0, tslib_1.__assign)((0, tslib_1.__assign)({ physicalRoot: contentDiv, logicalRoot: contentDiv, api: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, coreApiMap_1.coreApiMap), options.coreApiOverride), originalApi: (0, tslib_1.__assign)({}, coreApiMap_1.coreApiMap), plugins: (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([
@@ -30,9 +30,7 @@ function createEditorCore(contentDiv, options) {
30
30
  corePlugins.lifecycle,
31
31
  ], false), environment: createEditorEnvironment(contentDiv, options), darkColorHandler: (0, DarkColorHandlerImpl_1.createDarkColorHandler)(contentDiv, (_b = options.getDarkColor) !== null && _b !== void 0 ? _b : getDarkColorFallback, options.knownColors, options.generateColorKey), trustedHTMLHandler: options.trustedHTMLHandler && !(0, domCreator_1.isDOMCreator)(options.trustedHTMLHandler)
32
32
  ? options.trustedHTMLHandler
33
- : (0, domCreator_1.createTrustedHTMLHandler)(domCreator), domCreator: domCreator, domHelper: (0, DOMHelperImpl_1.createDOMHelper)(contentDiv, {
34
- cloneIndependentRoot: (_c = options.experimentalFeatures) === null || _c === void 0 ? void 0 : _c.includes('CloneIndependentRoot'),
35
- }) }, getPluginState(corePlugins)), { disposeErrorHandler: options.disposeErrorHandler, onFixUpModel: options.onFixUpModel, experimentalFeatures: options.experimentalFeatures ? (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(options.experimentalFeatures), false) : [] });
33
+ : (0, domCreator_1.createTrustedHTMLHandler)(domCreator), domCreator: domCreator, domHelper: (0, DOMHelperImpl_1.createDOMHelper)(contentDiv) }, getPluginState(corePlugins)), { disposeErrorHandler: options.disposeErrorHandler, onFixUpModel: options.onFixUpModel, experimentalFeatures: options.experimentalFeatures ? (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(options.experimentalFeatures), false) : [] });
36
34
  }
37
35
  exports.createEditorCore = createEditorCore;
38
36
  function createEditorEnvironment(contentDiv, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"createEditorCore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts"],"names":[],"mappings":";;;;AAAA,uDAAsD;AACtD,+DAAgE;AAChE,qDAAkG;AAClG,iDAAkD;AAClD,6EAAmG;AACnG,oFAAmF;AASnF;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,UAA0B,EAAE,OAAsB;;IAC/E,IAAM,WAAW,GAAG,IAAA,iDAAuB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACjE,IAAM,UAAU,GAAG,IAAA,6BAAgB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEhE,qDACI,YAAY,EAAE,UAAU,EACxB,WAAW,EAAE,UAAU,EACvB,GAAG,kDAAO,uBAAU,GAAK,OAAO,CAAC,eAAe,GAChD,WAAW,4BAAO,uBAAU,GAC5B,OAAO;YACH,WAAW,CAAC,KAAK;YACjB,WAAW,CAAC,MAAM;YAClB,WAAW,CAAC,SAAS;YACrB,WAAW,CAAC,QAAQ;YACpB,WAAW,CAAC,SAAS;YACrB,WAAW,CAAC,MAAM;+BACf,CAAC,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC;YAC3C,WAAW,CAAC,IAAI;YAChB,WAAW,CAAC,WAAW;YACvB,WAA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AAW,CAAC,WAAW,CAAC,QAAQ,EAAE;QAC/C,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE;KACpC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAC9C,OAAO,KAAK,CAAC;AACjB,CAAC;AAFD,oDAEC","sourcesContent":["import { coreApiMap } from '../../coreApi/coreApiMap';\nimport { createDarkColorHandler } from './DarkColorHandlerImpl';\nimport { createDOMCreator, createTrustedHTMLHandler, isDOMCreator } from '../../utils/domCreator';\nimport { createDOMHelper } from './DOMHelperImpl';\nimport { createDomToModelSettings, createModelToDomSettings } from './createEditorDefaultSettings';\nimport { createEditorCorePlugins } from '../../corePlugin/createEditorCorePlugins';\nimport type {\n EditorEnvironment,\n PluginState,\n EditorCore,\n EditorCorePlugins,\n EditorOptions,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal Create core object for editor\n * @param contentDiv Editor content DIV\n * @param options Editor options\n */\nexport function createEditorCore(contentDiv: HTMLDivElement, options: EditorOptions): EditorCore {\n const corePlugins = createEditorCorePlugins(options, contentDiv);\n const domCreator = createDOMCreator(options.trustedHTMLHandler);\n\n return {\n physicalRoot: contentDiv,\n logicalRoot: contentDiv,\n api: { ...coreApiMap, ...options.coreApiOverride },\n originalApi: { ...coreApiMap },\n plugins: [\n corePlugins.cache,\n corePlugins.format,\n corePlugins.copyPaste,\n corePlugins.domEvent,\n corePlugins.selection,\n corePlugins.entity,\n ...(options.plugins ?? []).filter(x => !!x),\n corePlugins.undo,\n corePlugins.contextMenu,\n corePlugins.lifecycle,\n ],\n environment: createEditorEnvironment(contentDiv, options),\n darkColorHandler: createDarkColorHandler(\n contentDiv,\n options.getDarkColor ?? getDarkColorFallback,\n options.knownColors,\n options.generateColorKey\n ),\n trustedHTMLHandler:\n options.trustedHTMLHandler && !isDOMCreator(options.trustedHTMLHandler)\n ? options.trustedHTMLHandler\n : createTrustedHTMLHandler(domCreator),\n domCreator: domCreator,\n domHelper: createDOMHelper(contentDiv, {\n cloneIndependentRoot: options.experimentalFeatures?.includes('CloneIndependentRoot'),\n }),\n ...getPluginState(corePlugins),\n disposeErrorHandler: options.disposeErrorHandler,\n onFixUpModel: options.onFixUpModel,\n experimentalFeatures: options.experimentalFeatures ? [...options.experimentalFeatures] : [],\n };\n}\n\nfunction createEditorEnvironment(\n contentDiv: HTMLElement,\n options: EditorOptions\n): EditorEnvironment {\n const navigator = contentDiv.ownerDocument.defaultView?.navigator;\n const userAgent = navigator?.userAgent ?? '';\n const appVersion = navigator?.appVersion ?? '';\n\n return {\n document: contentDiv.ownerDocument,\n domToModelSettings: createDomToModelSettings(options),\n modelToDomSettings: createModelToDomSettings(options),\n isMac: appVersion.indexOf('Mac') != -1,\n isAndroid: /android/i.test(userAgent),\n isIOS: /iPad|iPhone/.test(userAgent),\n isSafari:\n userAgent.indexOf('AppleWebKit') >= 0 &&\n userAgent.indexOf('Chrome') < 0 &&\n userAgent.indexOf('Android') < 0,\n isMobileOrTablet: getIsMobileOrTablet(userAgent),\n };\n}\n\nfunction getIsMobileOrTablet(userAgent: string) {\n // Reference: http://detectmobilebrowsers.com/\n // The default regex on the website doesn't consider tablet.\n // To support tablet, add |android|ipad|playbook|silk to the first regex according to the info in /about page\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(\n userAgent\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(\n userAgent.substring(0, 4)\n )\n ) {\n return true;\n }\n return false;\n}\n\nfunction getPluginState(corePlugins: EditorCorePlugins): PluginState {\n return {\n domEvent: corePlugins.domEvent.getState(),\n copyPaste: corePlugins.copyPaste.getState(),\n cache: corePlugins.cache.getState(),\n format: corePlugins.format.getState(),\n lifecycle: corePlugins.lifecycle.getState(),\n entity: corePlugins.entity.getState(),\n selection: corePlugins.selection.getState(),\n contextMenu: corePlugins.contextMenu.getState(),\n undo: corePlugins.undo.getState(),\n };\n}\n\n/**\n * @internal Export for test only\n * A fallback function, always return original color\n */\nexport function getDarkColorFallback(color: string) {\n return color;\n}\n"]}
1
+ {"version":3,"file":"createEditorCore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts"],"names":[],"mappings":";;;;AAAA,uDAAsD;AACtD,+DAAgE;AAChE,qDAAkG;AAClG,iDAAkD;AAClD,6EAAmG;AACnG,oFAAmF;AASnF;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,UAA0B,EAAE,OAAsB;;IAC/E,IAAM,WAAW,GAAG,IAAA,iDAAuB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACjE,IAAM,UAAU,GAAG,IAAA,6BAAgB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEhE,qDACI,YAAY,EAAE,UAAU,EACxB,WAAW,EAAE,UAAU,EACvB,GAAG,kDAAO,uBAAU,GAAK,OAAO,CAAC,eAAe,G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E,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE;QAC3C,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE;QAC3C,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE;QAC/C,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE;KACpC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAC9C,OAAO,KAAK,CAAC;AACjB,CAAC;AAFD,oDAEC","sourcesContent":["import { coreApiMap } from '../../coreApi/coreApiMap';\nimport { createDarkColorHandler } from './DarkColorHandlerImpl';\nimport { createDOMCreator, createTrustedHTMLHandler, isDOMCreator } from '../../utils/domCreator';\nimport { createDOMHelper } from './DOMHelperImpl';\nimport { createDomToModelSettings, createModelToDomSettings } from './createEditorDefaultSettings';\nimport { createEditorCorePlugins } from '../../corePlugin/createEditorCorePlugins';\nimport type {\n EditorEnvironment,\n PluginState,\n EditorCore,\n EditorCorePlugins,\n EditorOptions,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal Create core object for editor\n * @param contentDiv Editor content DIV\n * @param options Editor options\n */\nexport function createEditorCore(contentDiv: HTMLDivElement, options: EditorOptions): EditorCore {\n const corePlugins = createEditorCorePlugins(options, contentDiv);\n const domCreator = createDOMCreator(options.trustedHTMLHandler);\n\n return {\n physicalRoot: contentDiv,\n logicalRoot: contentDiv,\n api: { ...coreApiMap, ...options.coreApiOverride },\n originalApi: { ...coreApiMap },\n plugins: [\n corePlugins.cache,\n corePlugins.format,\n corePlugins.copyPaste,\n corePlugins.domEvent,\n corePlugins.selection,\n corePlugins.entity,\n ...(options.plugins ?? []).filter(x => !!x),\n corePlugins.undo,\n corePlugins.contextMenu,\n corePlugins.lifecycle,\n ],\n environment: createEditorEnvironment(contentDiv, options),\n darkColorHandler: createDarkColorHandler(\n contentDiv,\n options.getDarkColor ?? getDarkColorFallback,\n options.knownColors,\n options.generateColorKey\n ),\n trustedHTMLHandler:\n options.trustedHTMLHandler && !isDOMCreator(options.trustedHTMLHandler)\n ? options.trustedHTMLHandler\n : createTrustedHTMLHandler(domCreator),\n domCreator: domCreator,\n domHelper: createDOMHelper(contentDiv),\n ...getPluginState(corePlugins),\n disposeErrorHandler: options.disposeErrorHandler,\n onFixUpModel: options.onFixUpModel,\n experimentalFeatures: options.experimentalFeatures ? [...options.experimentalFeatures] : [],\n };\n}\n\nfunction createEditorEnvironment(\n contentDiv: HTMLElement,\n options: EditorOptions\n): EditorEnvironment {\n const navigator = contentDiv.ownerDocument.defaultView?.navigator;\n const userAgent = navigator?.userAgent ?? '';\n const appVersion = navigator?.appVersion ?? '';\n\n return {\n document: contentDiv.ownerDocument,\n domToModelSettings: createDomToModelSettings(options),\n modelToDomSettings: createModelToDomSettings(options),\n isMac: appVersion.indexOf('Mac') != -1,\n isAndroid: /android/i.test(userAgent),\n isIOS: /iPad|iPhone/.test(userAgent),\n isSafari:\n userAgent.indexOf('AppleWebKit') >= 0 &&\n userAgent.indexOf('Chrome') < 0 &&\n userAgent.indexOf('Android') < 0,\n isMobileOrTablet: getIsMobileOrTablet(userAgent),\n };\n}\n\nfunction getIsMobileOrTablet(userAgent: string) {\n // Reference: http://detectmobilebrowsers.com/\n // The default regex on the website doesn't consider tablet.\n // To support tablet, add |android|ipad|playbook|silk to the first regex according to the info in /about page\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(\n userAgent\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(\n userAgent.substring(0, 4)\n )\n ) {\n return true;\n }\n return false;\n}\n\nfunction getPluginState(corePlugins: EditorCorePlugins): PluginState {\n return {\n domEvent: corePlugins.domEvent.getState(),\n copyPaste: corePlugins.copyPaste.getState(),\n cache: corePlugins.cache.getState(),\n format: corePlugins.format.getState(),\n lifecycle: corePlugins.lifecycle.getState(),\n entity: corePlugins.entity.getState(),\n selection: corePlugins.selection.getState(),\n contextMenu: corePlugins.contextMenu.getState(),\n undo: corePlugins.undo.getState(),\n };\n}\n\n/**\n * @internal Export for test only\n * A fallback function, always return original color\n */\nexport function getDarkColorFallback(color: string) {\n return color;\n}\n"]}
@@ -2,7 +2,7 @@ import type { IEditor, ModelToDomOption, ModelToTextCallbacks } from 'roosterjs-
2
2
  /**
3
3
  * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity
4
4
  * @param editor The editor to get content from
5
- * @param mode Specify HTML to get HTML. This is the default option
5
+ * @param mode Specify HTML to get HTML.
6
6
  * @param options @optional Options for Model to DOM conversion
7
7
  */
8
8
  export declare function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;
@@ -10,9 +10,9 @@ export declare function exportContent(editor: IEditor, mode?: 'HTML', options?:
10
10
  * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.
11
11
  * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.
12
12
  * @param editor The editor to get content from
13
- * @param mode Specify HTMLFast to get HTML result.
13
+ * @param mode Specify HTMLFast to get HTML result. This is the default option
14
14
  */
15
- export declare function exportContent(editor: IEditor, mode: 'HTMLFast'): string;
15
+ export declare function exportContent(editor: IEditor, mode?: 'HTMLFast'): string;
16
16
  /**
17
17
  * Export plain text content
18
18
  * @param editor The editor to get content from
@@ -5,7 +5,7 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
5
5
  // Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version
6
6
  // Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach
7
7
  function exportContent(editor, mode, optionsOrCallbacks) {
8
- if (mode === void 0) { mode = 'HTML'; }
8
+ if (mode === void 0) { mode = 'HTMLFast'; }
9
9
  var model;
10
10
  switch (mode) {
11
11
  case 'PlainTextFast':
@@ -14,6 +14,7 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
14
14
  model = editor.getContentModelCopy('clean');
15
15
  return (0, roosterjs_content_model_dom_1.contentModelToText)(model, undefined /*separator*/, optionsOrCallbacks);
16
16
  case 'HTMLFast':
17
+ default:
17
18
  var clonedRoot = editor.getDOMHelper().getClonedRoot();
18
19
  if (editor.isDarkMode()) {
19
20
  (0, roosterjs_content_model_dom_1.transformColor)(clonedRoot, false /*includeSelf*/, 'darkToLight', editor.getColorManager(), {
@@ -22,7 +23,6 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
22
23
  }
23
24
  return getHTMLFromDOM(editor, clonedRoot);
24
25
  case 'HTML':
25
- default:
26
26
  model = editor.getContentModelCopy('clean');
27
27
  var doc = editor.getDocument();
28
28
  var div = doc.createElement('div');
@@ -1 +1 @@
1
- {"version":3,"file":"exportContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/exportContent/exportContent.ts"],"names":[],"mappings":";;;;IAkDA,yKAAyK;IACzK,6GAA6G;IAC7G,SAAgB,aAAa,CACzB,MAAe,EACf,IAA6C,EAC7C,kBAA4D;QAD5D,qBAAA,EAAA,aAA6C;QAG7C,IAAI,KAA2B,CAAC;QAEhC,QAAQ,IAAI,EAAE;YACV,KAAK,eAAe;gBAChB,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE,CAAC;YAClD,KAAK,WAAW;gBACZ,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBAE5C,OAAO,IAAA,gDAAkB,EACrB,KAAK,EACL,SAAS,CAAC,aAAa,EACvB,kBAA0C,CAC7C,CAAC;YAEN,KAAK,UAAU;gBACX,IAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,CAAC;gBAEzD,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE;oBACrB,IAAA,4CAAc,EACV,UAAU,EACV,KAAK,CAAC,eAAe,EACrB,aAAa,EACb,MAAM,CAAC,eAAe,EAAE,EACxB;wBACI,YAAY,EAAE,MAAM,CAAC,4BAA4B,CAC7C,4BAA4B,CAC/B;qBACJ,CACJ,CAAC;iBACL;gBAED,OAAO,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YAE9C,KAAK,MAAM,CAAC;YACZ;gBACI,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBAE5C,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;gBACjC,IAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAErC,IAAA,+CAAiB,EACb,GAAG,EACH,GAAG,EACH,KAAK,EACL,IAAA,qDAAuB,EACnB,SAAS,CAAC,iBAAiB,EAC3B,kBAAsC,CACzC,CACJ,CAAC;gBAEF,OAAO,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SAC1C;IACL,CAAC;IAzDD,sCAyDC;IAED,SAAS,cAAc,CAAC,MAAe,EAAE,IAAiB;QACtD,MAAM,CAAC,YAAY,CAAC,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC","sourcesContent":["import {\n contentModelToDom,\n contentModelToText,\n createModelToDomContext,\n transformColor,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ExportContentMode,\n IEditor,\n ModelToDomOption,\n ModelToTextCallbacks,\n} from 'roosterjs-content-model-types';\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity\n * @param editor The editor to get content from\n * @param mode Specify HTML to get HTML. This is the default option\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.\n * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.\n * @param editor The editor to get content from\n * @param mode Specify HTMLFast to get HTML result.\n */\nexport function exportContent(editor: IEditor, mode: 'HTMLFast'): string;\n\n/**\n * Export plain text content\n * @param editor The editor to get content from\n * @param mode Specify PlainText to get plain text result\n * @param callbacks @optional Callbacks to customize conversion behavior\n */\nexport function exportContent(\n editor: IEditor,\n mode: 'PlainText',\n callbacks?: ModelToTextCallbacks\n): string;\n\n/**\n * Export plain text using editor's textContent property directly\n * @param editor The editor to get content from\n * @param mode Specify PlainTextFast to get plain text result using textContent property\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode: 'PlainTextFast'): string;\n\n// Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version\n// Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach\nexport function exportContent(\n editor: IEditor,\n mode: ExportContentMode | 'HTMLFast' = 'HTML',\n optionsOrCallbacks?: ModelToDomOption | ModelToTextCallbacks\n): string {\n let model: ContentModelDocument;\n\n switch (mode) {\n case 'PlainTextFast':\n return editor.getDOMHelper().getTextContent();\n case 'PlainText':\n model = editor.getContentModelCopy('clean');\n\n return contentModelToText(\n model,\n undefined /*separator*/,\n optionsOrCallbacks as ModelToTextCallbacks\n );\n\n case 'HTMLFast':\n const clonedRoot = editor.getDOMHelper().getClonedRoot();\n\n if (editor.isDarkMode()) {\n transformColor(\n clonedRoot,\n false /*includeSelf*/,\n 'darkToLight',\n editor.getColorManager(),\n {\n tableBorders: editor.isExperimentalFeatureEnabled(\n 'TransformTableBorderColors'\n ),\n }\n );\n }\n\n return getHTMLFromDOM(editor, clonedRoot);\n\n case 'HTML':\n default:\n model = editor.getContentModelCopy('clean');\n\n const doc = editor.getDocument();\n const div = doc.createElement('div');\n\n contentModelToDom(\n doc,\n div,\n model,\n createModelToDomContext(\n undefined /*editorContext*/,\n optionsOrCallbacks as ModelToDomOption\n )\n );\n\n return getHTMLFromDOM(editor, div);\n }\n}\n\nfunction getHTMLFromDOM(editor: IEditor, root: HTMLElement): string {\n editor.triggerEvent('extractContentWithDom', { clonedRoot: root }, true /*broadcast*/);\n\n return root.innerHTML;\n}\n"]}
1
+ {"version":3,"file":"exportContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/exportContent/exportContent.ts"],"names":[],"mappings":";;;;IAkDA,yKAAyK;IACzK,6GAA6G;IAC7G,SAAgB,aAAa,CACzB,MAAe,EACf,IAAiD,EACjD,kBAA4D;QAD5D,qBAAA,EAAA,iBAAiD;QAGjD,IAAI,KAA2B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AAC,aAAa,CAAC,CAAC;QAEvF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC","sourcesContent":["import {\n contentModelToDom,\n contentModelToText,\n createModelToDomContext,\n transformColor,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ExportContentMode,\n IEditor,\n ModelToDomOption,\n ModelToTextCallbacks,\n} from 'roosterjs-content-model-types';\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity\n * @param editor The editor to get content from\n * @param mode Specify HTML to get HTML.\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;\n\n/**\n * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.\n * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.\n * @param editor The editor to get content from\n * @param mode Specify HTMLFast to get HTML result. This is the default option\n */\nexport function exportContent(editor: IEditor, mode?: 'HTMLFast'): string;\n\n/**\n * Export plain text content\n * @param editor The editor to get content from\n * @param mode Specify PlainText to get plain text result\n * @param callbacks @optional Callbacks to customize conversion behavior\n */\nexport function exportContent(\n editor: IEditor,\n mode: 'PlainText',\n callbacks?: ModelToTextCallbacks\n): string;\n\n/**\n * Export plain text using editor's textContent property directly\n * @param editor The editor to get content from\n * @param mode Specify PlainTextFast to get plain text result using textContent property\n * @param options @optional Options for Model to DOM conversion\n */\nexport function exportContent(editor: IEditor, mode: 'PlainTextFast'): string;\n\n// Here I didn't add 'HTMLFast' to ExportContentMode type because it will make this a breaking change and EditorAdapter will see build time error without bumping version\n// Once we are confident that 'HTMLFast' is stable, we can fully switch 'HTML' to use the 'HTMLFast' approach\nexport function exportContent(\n editor: IEditor,\n mode: ExportContentMode | 'HTMLFast' = 'HTMLFast',\n optionsOrCallbacks?: ModelToDomOption | ModelToTextCallbacks\n): string {\n let model: ContentModelDocument;\n\n switch (mode) {\n case 'PlainTextFast':\n return editor.getDOMHelper().getTextContent();\n case 'PlainText':\n model = editor.getContentModelCopy('clean');\n\n return contentModelToText(\n model,\n undefined /*separator*/,\n optionsOrCallbacks as ModelToTextCallbacks\n );\n\n case 'HTMLFast':\n default:\n const clonedRoot = editor.getDOMHelper().getClonedRoot();\n\n if (editor.isDarkMode()) {\n transformColor(\n clonedRoot,\n false /*includeSelf*/,\n 'darkToLight',\n editor.getColorManager(),\n {\n tableBorders: editor.isExperimentalFeatureEnabled(\n 'TransformTableBorderColors'\n ),\n }\n );\n }\n\n return getHTMLFromDOM(editor, clonedRoot);\n\n case 'HTML':\n model = editor.getContentModelCopy('clean');\n\n const doc = editor.getDocument();\n const div = doc.createElement('div');\n\n contentModelToDom(\n doc,\n div,\n model,\n createModelToDomContext(\n undefined /*editorContext*/,\n optionsOrCallbacks as ModelToDomOption\n )\n );\n\n return getHTMLFromDOM(editor, div);\n }\n}\n\nfunction getHTMLFromDOM(editor: IEditor, root: HTMLElement): string {\n editor.triggerEvent('extractContentWithDom', { clonedRoot: root }, true /*broadcast*/);\n\n return root.innerHTML;\n}\n"]}
@@ -7,10 +7,10 @@ define(["require", "exports", "tslib", "./getRootComputedStyleForContext"], func
7
7
  * Create a EditorContext object used by ContentModel API
8
8
  */
9
9
  var createEditorContext = function (core, saveIndex) {
10
- var _a, _b, _c;
10
+ var _a, _b;
11
11
  var lifecycle = core.lifecycle, format = core.format, darkColorHandler = core.darkColorHandler, logicalRoot = core.logicalRoot, cache = core.cache, domHelper = core.domHelper;
12
12
  saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;
13
- var context = (0, tslib_1.__assign)({ isDarkMode: lifecycle.isDarkMode, defaultFormat: format.defaultFormat, pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined, darkColorHandler: darkColorHandler, addDelimiterForEntity: true, allowCacheElement: true, allowCacheListItem: !!((_b = core.experimentalFeatures) === null || _b === void 0 ? void 0 : _b.includes('CacheList')), domIndexer: saveIndex ? cache.domIndexer : undefined, zoomScale: domHelper.calculateZoomScale(), experimentalFeatures: (_c = core.experimentalFeatures) !== null && _c !== void 0 ? _c : [], paragraphMap: core.cache.paragraphMap, editorViewWidth: domHelper.getClientWidth() }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(logicalRoot.ownerDocument));
13
+ var context = (0, tslib_1.__assign)({ isDarkMode: lifecycle.isDarkMode, defaultFormat: format.defaultFormat, pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined, darkColorHandler: darkColorHandler, addDelimiterForEntity: true, allowCacheElement: true, domIndexer: saveIndex ? cache.domIndexer : undefined, zoomScale: domHelper.calculateZoomScale(), experimentalFeatures: (_b = core.experimentalFeatures) !== null && _b !== void 0 ? _b : [], paragraphMap: core.cache.paragraphMap, editorViewWidth: domHelper.getClientWidth() }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(logicalRoot.ownerDocument));
14
14
  if (core.domHelper.isRightToLeft()) {
15
15
  context.isRootRtl = true;
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/createEditorContext/createEditorContext.ts"],"names":[],"mappings":";;;;IAGA;;;OAGG;IACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;QAC5D,IAAA,SAAS,GAA8D,IAAI,UAAlE,EAAE,MAAM,GAAsD,IAAI,OAA1D,EAAE,gBAAgB,GAAoC,IAAI,iBAAxC,EAAE,WAAW,GAAuB,IAAI,YAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;QAEpF,SAAS,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;QAE5D,IAAM,OAAO,2BACT,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,SAAS,EAChD,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,IAAI,EAC3B,iBAAiB,EAAE,IAAI,EACvB,kBAAkB,EAAE,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,oBAAoB,0CAAE,QAAQ,CAAC,WAAW,CAAC,CAAA,EACtE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACpD,SAAS,EAAE,SAAS,CAAC,kBAAkB,EAAE,EACzC,oBAAoB,EAAE,MAAA,IAAI,CAAC,oBAAoB,mCAAI,EAAE,EACrD,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,eAAe,EAAE,SAAS,CAAC,cAAc,EAAE,IACxC,IAAA,+DAA8B,EAAC,WAAW,CAAC,aAAa,CAAC,CAC/D,CAAC;QAEF,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE;YAChC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;SAC5B;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;IA1BW,QAAA,mBAAmB,uBA0B9B","sourcesContent":["import { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport type { EditorContext, CreateEditorContext } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Create a EditorContext object used by ContentModel API\n */\nexport const createEditorContext: CreateEditorContext = (core, saveIndex) => {\n const { lifecycle, format, darkColorHandler, logicalRoot, cache, domHelper } = core;\n\n saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;\n\n const context: EditorContext = {\n isDarkMode: lifecycle.isDarkMode,\n defaultFormat: format.defaultFormat,\n pendingFormat: format.pendingFormat ?? undefined,\n darkColorHandler: darkColorHandler,\n addDelimiterForEntity: true,\n allowCacheElement: true,\n allowCacheListItem: !!core.experimentalFeatures?.includes('CacheList'),\n domIndexer: saveIndex ? cache.domIndexer : undefined,\n zoomScale: domHelper.calculateZoomScale(),\n experimentalFeatures: core.experimentalFeatures ?? [],\n paragraphMap: core.cache.paragraphMap,\n editorViewWidth: domHelper.getClientWidth(),\n ...getRootComputedStyleForContext(logicalRoot.ownerDocument),\n };\n\n if (core.domHelper.isRightToLeft()) {\n context.isRootRtl = true;\n }\n\n return context;\n};\n"]}
1
+ {"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/coreApi/createEditorContext/createEditorContext.ts"],"names":[],"mappings":";;;;IAGA;;;OAGG;IACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;QAC5D,IAAA,SAAS,GAA8D,IAAI,UAAlE,EAAE,MAAM,GAAsD,IAAI,OAA1D,EAAE,gBAAgB,GAAoC,IAAI,iBAAxC,EAAE,WAAW,GAAuB,IAAI,YAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;QAEpF,SAAS,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;QAE5D,IAAM,OAAO,2BACT,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,SAAS,EAChD,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,IAAI,EAC3B,iBAAiB,EAAE,IAAI,EACvB,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACpD,SAAS,EAAE,SAAS,CAAC,kBAAkB,EAAE,EACzC,oBAAoB,EAAE,MAAA,IAAI,CAAC,oBAAoB,mCAAI,EAAE,EACrD,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,eAAe,EAAE,SAAS,CAAC,cAAc,EAAE,IACxC,IAAA,+DAA8B,EAAC,WAAW,CAAC,aAAa,CAAC,CAC/D,CAAC;QAEF,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE;YAChC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;SAC5B;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;IAzBW,QAAA,mBAAmB,uBAyB9B","sourcesContent":["import { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport type { EditorContext, CreateEditorContext } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Create a EditorContext object used by ContentModel API\n */\nexport const createEditorContext: CreateEditorContext = (core, saveIndex) => {\n const { lifecycle, format, darkColorHandler, logicalRoot, cache, domHelper } = core;\n\n saveIndex = saveIndex && !core.lifecycle.shadowEditFragment;\n\n const context: EditorContext = {\n isDarkMode: lifecycle.isDarkMode,\n defaultFormat: format.defaultFormat,\n pendingFormat: format.pendingFormat ?? undefined,\n darkColorHandler: darkColorHandler,\n addDelimiterForEntity: true,\n allowCacheElement: true,\n domIndexer: saveIndex ? cache.domIndexer : undefined,\n zoomScale: domHelper.calculateZoomScale(),\n experimentalFeatures: core.experimentalFeatures ?? [],\n paragraphMap: core.cache.paragraphMap,\n editorViewWidth: domHelper.getClientWidth(),\n ...getRootComputedStyleForContext(logicalRoot.ownerDocument),\n };\n\n if (core.domHelper.isRightToLeft()) {\n context.isRootRtl = true;\n }\n\n return context;\n};\n"]}
@@ -33,7 +33,6 @@ define(["require", "exports", "tslib", "./core/createEditorCore", "roosterjs-con
33
33
  };
34
34
  this.core = (0, createEditorCore_1.createEditorCore)(contentDiv, options);
35
35
  var initialModel = (_a = options.initialModel) !== null && _a !== void 0 ? _a : (0, roosterjs_content_model_dom_1.createEmptyModel)(this.core.format.defaultFormat);
36
- (0, roosterjs_content_model_dom_1.sanitizeInvisibleUnicode)(initialModel);
37
36
  this.core.api.setContentModel(this.core, initialModel, { ignoreSelection: true }, undefined /*onNodeCreated*/, true /*isInitializing*/);
38
37
  this.core.plugins.forEach(function (plugin) { return plugin.initialize(_this); });
39
38
  }