roosterjs-content-model-core 0.26.3 → 0.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/coreApi/createEditorContext.js +4 -20
- package/lib/coreApi/createEditorContext.js.map +1 -1
- package/lib/publicApi/model/createModelFromHtml.js +1 -1
- package/lib/publicApi/model/createModelFromHtml.js.map +1 -1
- package/lib/utils/createDomToModelContextForSanitizing.d.ts +1 -1
- package/lib/utils/createDomToModelContextForSanitizing.js +3 -4
- package/lib/utils/createDomToModelContextForSanitizing.js.map +1 -1
- package/lib/utils/getRootComputedStyleForContext.d.ts +5 -0
- package/lib/utils/getRootComputedStyleForContext.js +15 -0
- package/lib/utils/getRootComputedStyleForContext.js.map +1 -0
- package/lib/utils/paste/mergePasteContent.js +1 -1
- package/lib/utils/paste/mergePasteContent.js.map +1 -1
- package/lib-amd/coreApi/createEditorContext.js +3 -20
- package/lib-amd/coreApi/createEditorContext.js.map +1 -1
- package/lib-amd/publicApi/model/createModelFromHtml.js +1 -1
- package/lib-amd/publicApi/model/createModelFromHtml.js.map +1 -1
- package/lib-amd/utils/createDomToModelContextForSanitizing.d.ts +1 -1
- package/lib-amd/utils/createDomToModelContextForSanitizing.js +3 -5
- package/lib-amd/utils/createDomToModelContextForSanitizing.js.map +1 -1
- package/lib-amd/utils/getRootComputedStyleForContext.d.ts +5 -0
- package/lib-amd/utils/getRootComputedStyleForContext.js +16 -0
- package/lib-amd/utils/getRootComputedStyleForContext.js.map +1 -0
- package/lib-amd/utils/paste/mergePasteContent.js +1 -1
- package/lib-amd/utils/paste/mergePasteContent.js.map +1 -1
- package/lib-mjs/coreApi/createEditorContext.js +4 -20
- package/lib-mjs/coreApi/createEditorContext.js.map +1 -1
- package/lib-mjs/publicApi/model/createModelFromHtml.js +1 -1
- package/lib-mjs/publicApi/model/createModelFromHtml.js.map +1 -1
- package/lib-mjs/utils/createDomToModelContextForSanitizing.d.ts +1 -1
- package/lib-mjs/utils/createDomToModelContextForSanitizing.js +3 -4
- package/lib-mjs/utils/createDomToModelContextForSanitizing.js.map +1 -1
- package/lib-mjs/utils/getRootComputedStyleForContext.d.ts +5 -0
- package/lib-mjs/utils/getRootComputedStyleForContext.js +11 -0
- package/lib-mjs/utils/getRootComputedStyleForContext.js.map +1 -0
- package/lib-mjs/utils/paste/mergePasteContent.js +1 -1
- package/lib-mjs/utils/paste/mergePasteContent.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEditorContext = void 0;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var getRootComputedStyleForContext_1 = require("../utils/getRootComputedStyleForContext");
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
* Create a EditorContext object used by ContentModel API
|
|
9
9
|
*/
|
|
10
10
|
var createEditorContext = function (core, saveIndex) {
|
|
11
|
-
var _a
|
|
11
|
+
var _a;
|
|
12
12
|
var lifecycle = core.lifecycle, format = core.format, darkColorHandler = core.darkColorHandler, contentDiv = core.contentDiv, cache = core.cache, domHelper = core.domHelper;
|
|
13
|
-
var context = {
|
|
14
|
-
isDarkMode: lifecycle.isDarkMode,
|
|
15
|
-
defaultFormat: format.defaultFormat,
|
|
16
|
-
pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined,
|
|
17
|
-
darkColorHandler: darkColorHandler,
|
|
18
|
-
addDelimiterForEntity: true,
|
|
19
|
-
allowCacheElement: true,
|
|
20
|
-
domIndexer: saveIndex ? cache.domIndexer : undefined,
|
|
21
|
-
zoomScale: domHelper.calculateZoomScale(),
|
|
22
|
-
rootFontSize: (0, roosterjs_content_model_dom_1.parseValueWithUnit)((_b = getRootComputedStyle(core)) === null || _b === void 0 ? void 0 : _b.fontSize) || DefaultRootFontSize,
|
|
23
|
-
};
|
|
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() }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(contentDiv.ownerDocument));
|
|
24
14
|
checkRootRtl(contentDiv, context);
|
|
25
15
|
return context;
|
|
26
16
|
};
|
|
@@ -32,10 +22,4 @@ function checkRootRtl(element, context) {
|
|
|
32
22
|
context.isRootRtl = true;
|
|
33
23
|
}
|
|
34
24
|
}
|
|
35
|
-
function getRootComputedStyle(core) {
|
|
36
|
-
var _a;
|
|
37
|
-
var document = core.contentDiv.ownerDocument;
|
|
38
|
-
var rootComputedStyle = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(document.documentElement);
|
|
39
|
-
return rootComputedStyle;
|
|
40
|
-
}
|
|
41
25
|
//# sourceMappingURL=createEditorContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":";;;;AAAA,0FAAyF;AAGzF;;;GAGG;AACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;IAC5D,IAAA,SAAS,GAA6D,IAAI,UAAjE,EAAE,MAAM,GAAqD,IAAI,OAAzD,EAAE,gBAAgB,GAAmC,IAAI,iBAAvC,EAAE,UAAU,GAAuB,IAAI,WAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;IAEnF,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,IACtC,IAAA,+DAA8B,EAAC,UAAU,CAAC,aAAa,CAAC,CAC9D,CAAC;IAEF,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAlBW,QAAA,mBAAmB,uBAkB9B;AAEF,SAAS,YAAY,CAAC,OAAoB,EAAE,OAAsB;;IAC9D,IAAM,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAC,WAAW,0CAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5E,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,KAAK,EAAE;QAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;KAC5B;AACL,CAAC","sourcesContent":["import { getRootComputedStyleForContext } from '../utils/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, contentDiv, cache, domHelper } = core;\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 ...getRootComputedStyleForContext(contentDiv.ownerDocument),\n };\n\n checkRootRtl(contentDiv, context);\n\n return context;\n};\n\nfunction checkRootRtl(element: HTMLElement, context: EditorContext) {\n const style = element?.ownerDocument.defaultView?.getComputedStyle(element);\n\n if (style?.direction == 'rtl') {\n context.isRootRtl = true;\n }\n}\n"]}
|
|
@@ -17,7 +17,7 @@ function createModelFromHtml(html, options, trustedHTMLHandler, defaultSegmentFo
|
|
|
17
17
|
? new DOMParser().parseFromString((_a = trustedHTMLHandler === null || trustedHTMLHandler === void 0 ? void 0 : trustedHTMLHandler(html)) !== null && _a !== void 0 ? _a : html, 'text/html')
|
|
18
18
|
: null;
|
|
19
19
|
if (doc === null || doc === void 0 ? void 0 : doc.body) {
|
|
20
|
-
var context = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(defaultSegmentFormat, options);
|
|
20
|
+
var context = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(doc, defaultSegmentFormat, options);
|
|
21
21
|
var cssRules = doc ? (0, convertInlineCss_1.retrieveCssRules)(doc) : [];
|
|
22
22
|
(0, convertInlineCss_1.convertInlineCss)(doc, cssRules);
|
|
23
23
|
(0, roosterjs_content_model_dom_1.parseFormat)(doc.body, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModelFromHtml.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/createModelFromHtml.ts"],"names":[],"mappings":";;;AAAA,iEAAkF;AAClF,yGAAwG;AACxG,2EAA+F;AAQ/F;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAC/B,IAAY,EACZ,OAA0B,EAC1B,kBAAuC,EACvC,oBAAgD;;IAEhD,IAAM,GAAG,GAAG,IAAI;QACZ,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,mCAAI,IAAI,EAAE,WAAW,CAAC;QAClF,CAAC,CAAC,IAAI,CAAC;IAEX,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE;QACX,IAAM,OAAO,GAAG,IAAA,2EAAoC,EAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createModelFromHtml.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/createModelFromHtml.ts"],"names":[],"mappings":";;;AAAA,iEAAkF;AAClF,yGAAwG;AACxG,2EAA+F;AAQ/F;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAC/B,IAAY,EACZ,OAA0B,EAC1B,kBAAuC,EACvC,oBAAgD;;IAEhD,IAAM,GAAG,GAAG,IAAI;QACZ,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,mCAAI,IAAI,EAAE,WAAW,CAAC;QAClF,CAAC,CAAC,IAAI,CAAC;IAEX,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE;QACX,IAAM,OAAO,GAAG,IAAA,2EAAoC,EAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACzF,IAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,IAAA,mCAAgB,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAElD,IAAA,mCAAgB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAChC,IAAA,yCAAW,EAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAE5F,OAAO,IAAA,+CAAiB,EAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC/C;SAAM;QACH,OAAO,IAAA,8CAAgB,EAAC,oBAAoB,CAAC,CAAC;KACjD;AACL,CAAC;AArBD,kDAqBC","sourcesContent":["import { convertInlineCss, retrieveCssRules } from '../../utils/convertInlineCss';\nimport { createDomToModelContextForSanitizing } from '../../utils/createDomToModelContextForSanitizing';\nimport { createEmptyModel, domToContentModel, parseFormat } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelSegmentFormat,\n DomToModelOption,\n TrustedHTMLHandler,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create Content Model from HTML string\n * @param html The source HTML string\n * @param options Options for DOM to Content Model conversion\n * @param trustedHTMLHandler A string handler to convert string to trusted string\n * @returns A Content Model Document object that contains the Content Model from the give HTML, or undefined if failed to parse the source HTML\n */\nexport function createModelFromHtml(\n html: string,\n options?: DomToModelOption,\n trustedHTMLHandler?: TrustedHTMLHandler,\n defaultSegmentFormat?: ContentModelSegmentFormat\n): ContentModelDocument {\n const doc = html\n ? new DOMParser().parseFromString(trustedHTMLHandler?.(html) ?? html, 'text/html')\n : null;\n\n if (doc?.body) {\n const context = createDomToModelContextForSanitizing(doc, defaultSegmentFormat, options);\n const cssRules = doc ? retrieveCssRules(doc) : [];\n\n convertInlineCss(doc, cssRules);\n parseFormat(doc.body, context.formatParsers.segmentOnBlock, context.segmentFormat, context);\n\n return domToContentModel(doc.body, context);\n } else {\n return createEmptyModel(defaultSegmentFormat);\n }\n}\n"]}
|
|
@@ -2,4 +2,4 @@ import type { ContentModelSegmentFormat, DomToModelContext, DomToModelOption, Do
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function createDomToModelContextForSanitizing(defaultFormat?: ContentModelSegmentFormat, defaultOption?: DomToModelOption, additionalSanitizingOption?: DomToModelOptionForSanitizing): DomToModelContext;
|
|
5
|
+
export declare function createDomToModelContextForSanitizing(document: Document, defaultFormat?: ContentModelSegmentFormat, defaultOption?: DomToModelOption, additionalSanitizingOption?: DomToModelOptionForSanitizing): DomToModelContext;
|
|
@@ -6,6 +6,7 @@ var containerSizeFormatParser_1 = require("../override/containerSizeFormatParser
|
|
|
6
6
|
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
7
|
var pasteEntityProcessor_1 = require("../override/pasteEntityProcessor");
|
|
8
8
|
var pasteGeneralProcessor_1 = require("../override/pasteGeneralProcessor");
|
|
9
|
+
var getRootComputedStyleForContext_1 = require("./getRootComputedStyleForContext");
|
|
9
10
|
var pasteCopyBlockEntityParser_1 = require("../override/pasteCopyBlockEntityParser");
|
|
10
11
|
var pasteDisplayFormatParser_1 = require("../override/pasteDisplayFormatParser");
|
|
11
12
|
var pasteTextProcessor_1 = require("../override/pasteTextProcessor");
|
|
@@ -21,11 +22,9 @@ var DefaultSanitizingOption = {
|
|
|
21
22
|
/**
|
|
22
23
|
* @internal
|
|
23
24
|
*/
|
|
24
|
-
function createDomToModelContextForSanitizing(defaultFormat, defaultOption, additionalSanitizingOption) {
|
|
25
|
+
function createDomToModelContextForSanitizing(document, defaultFormat, defaultOption, additionalSanitizingOption) {
|
|
25
26
|
var sanitizingOption = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultSanitizingOption), additionalSanitizingOption);
|
|
26
|
-
return (0, roosterjs_content_model_dom_1.createDomToModelContext)({
|
|
27
|
-
defaultFormat: defaultFormat,
|
|
28
|
-
}, defaultOption, {
|
|
27
|
+
return (0, roosterjs_content_model_dom_1.createDomToModelContext)((0, tslib_1.__assign)({ defaultFormat: defaultFormat }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(document)), defaultOption, {
|
|
29
28
|
processorOverride: {
|
|
30
29
|
'#text': pasteTextProcessor_1.pasteTextProcessor,
|
|
31
30
|
entity: (0, pasteEntityProcessor_1.createPasteEntityProcessor)(sanitizingOption),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDomToModelContextForSanitizing.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/createDomToModelContextForSanitizing.ts"],"names":[],"mappings":";;;;AAAA,mFAAkF;AAClF,2EAAsE;AACtE,yEAA8E;AAC9E,2EAAgF;AAChF,qFAAgF;AAChF,iFAAgF;AAChF,qEAAoE;AAQpE,IAAM,uBAAuB,GAAkC;IAC3D,iBAAiB,EAAE,EAAE;IACrB,oBAAoB,EAAE,EAAE;IACxB,uBAAuB,EAAE,EAAE;IAC3B,qBAAqB,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;CAC1B,CAAC;AAEF;;GAEG;AACH,SAAgB,oCAAoC,CAChD,aAAyC,EACzC,aAAgC,EAChC,0BAA0D;IAE1D,IAAM,gBAAgB,mDACf,uBAAuB,GACvB,0BAA0B,CAChC,CAAC;IAEF,OAAO,IAAA,qDAAuB,
|
|
1
|
+
{"version":3,"file":"createDomToModelContextForSanitizing.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/createDomToModelContextForSanitizing.ts"],"names":[],"mappings":";;;;AAAA,mFAAkF;AAClF,2EAAsE;AACtE,yEAA8E;AAC9E,2EAAgF;AAChF,mFAAkF;AAClF,qFAAgF;AAChF,iFAAgF;AAChF,qEAAoE;AAQpE,IAAM,uBAAuB,GAAkC;IAC3D,iBAAiB,EAAE,EAAE;IACrB,oBAAoB,EAAE,EAAE;IACxB,uBAAuB,EAAE,EAAE;IAC3B,qBAAqB,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;CAC1B,CAAC;AAEF;;GAEG;AACH,SAAgB,oCAAoC,CAChD,QAAkB,EAClB,aAAyC,EACzC,aAAgC,EAChC,0BAA0D;IAE1D,IAAM,gBAAgB,mDACf,uBAAuB,GACvB,0BAA0B,CAChC,CAAC;IAEF,OAAO,IAAA,qDAAuB,0BAEtB,aAAa,eAAA,IACV,IAAA,+DAA8B,EAAC,QAAQ,CAAC,GAE/C,aAAa,EACb;QACI,iBAAiB,EAAE;YACf,OAAO,EAAE,uCAAkB;YAC3B,MAAM,EAAE,IAAA,iDAA0B,EAAC,gBAAgB,CAAC;YACpD,GAAG,EAAE,IAAA,mDAA2B,EAAC,gBAAgB,CAAC;SACrD;QACD,oBAAoB,EAAE;YAClB,OAAO,EAAE,mDAAwB;SACpC;QACD,uBAAuB,EAAE;YACrB,SAAS,EAAE,CAAC,qDAAyB,CAAC;YACtC,MAAM,EAAE,CAAC,mDAAsB,CAAC;SACnC;KACJ,EACD,gBAAgB,CACnB,CAAC;AACN,CAAC;AAjCD,oFAiCC","sourcesContent":["import { containerSizeFormatParser } from '../override/containerSizeFormatParser';\nimport { createDomToModelContext } from 'roosterjs-content-model-dom';\nimport { createPasteEntityProcessor } from '../override/pasteEntityProcessor';\nimport { createPasteGeneralProcessor } from '../override/pasteGeneralProcessor';\nimport { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport { pasteBlockEntityParser } from '../override/pasteCopyBlockEntityParser';\nimport { pasteDisplayFormatParser } from '../override/pasteDisplayFormatParser';\nimport { pasteTextProcessor } from '../override/pasteTextProcessor';\nimport type {\n ContentModelSegmentFormat,\n DomToModelContext,\n DomToModelOption,\n DomToModelOptionForSanitizing,\n} from 'roosterjs-content-model-types';\n\nconst DefaultSanitizingOption: DomToModelOptionForSanitizing = {\n processorOverride: {},\n formatParserOverride: {},\n additionalFormatParsers: {},\n additionalAllowedTags: [],\n additionalDisallowedTags: [],\n styleSanitizers: {},\n attributeSanitizers: {},\n};\n\n/**\n * @internal\n */\nexport function createDomToModelContextForSanitizing(\n document: Document,\n defaultFormat?: ContentModelSegmentFormat,\n defaultOption?: DomToModelOption,\n additionalSanitizingOption?: DomToModelOptionForSanitizing\n): DomToModelContext {\n const sanitizingOption: DomToModelOptionForSanitizing = {\n ...DefaultSanitizingOption,\n ...additionalSanitizingOption,\n };\n\n return createDomToModelContext(\n {\n defaultFormat,\n ...getRootComputedStyleForContext(document),\n },\n defaultOption,\n {\n processorOverride: {\n '#text': pasteTextProcessor,\n entity: createPasteEntityProcessor(sanitizingOption),\n '*': createPasteGeneralProcessor(sanitizingOption),\n },\n formatParserOverride: {\n display: pasteDisplayFormatParser,\n },\n additionalFormatParsers: {\n container: [containerSizeFormatParser],\n entity: [pasteBlockEntityParser],\n },\n },\n sanitizingOption\n );\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRootComputedStyleForContext = void 0;
|
|
4
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
|
+
var DefaultRootFontSize = 16;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function getRootComputedStyleForContext(document) {
|
|
10
|
+
var _a;
|
|
11
|
+
var rootComputedStyle = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(document.documentElement);
|
|
12
|
+
return { rootFontSize: (0, roosterjs_content_model_dom_1.parseValueWithUnit)(rootComputedStyle === null || rootComputedStyle === void 0 ? void 0 : rootComputedStyle.fontSize) || DefaultRootFontSize };
|
|
13
|
+
}
|
|
14
|
+
exports.getRootComputedStyleForContext = getRootComputedStyleForContext;
|
|
15
|
+
//# sourceMappingURL=getRootComputedStyleForContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRootComputedStyleForContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/getRootComputedStyleForContext.ts"],"names":[],"mappings":";;;AAAA,2EAAiE;AAGjE,IAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B;;GAEG;AACH,SAAgB,8BAA8B,CAC1C,QAAkB;;IAElB,IAAM,iBAAiB,GAAG,MAAA,QAAQ,CAAC,WAAW,0CAAE,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC3F,OAAO,EAAE,YAAY,EAAE,IAAA,gDAAkB,EAAC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,QAAQ,CAAC,IAAI,mBAAmB,EAAE,CAAC;AACpG,CAAC;AALD,wEAKC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport type { EditorContext } from 'roosterjs-content-model-types';\n\nconst DefaultRootFontSize = 16;\n\n/**\n * @internal\n */\nexport function getRootComputedStyleForContext(\n document: Document\n): Pick<EditorContext, 'rootFontSize'> {\n const rootComputedStyle = document.defaultView?.getComputedStyle(document.documentElement);\n return { rootFontSize: parseValueWithUnit(rootComputedStyle?.fontSize) || DefaultRootFontSize };\n}\n"]}
|
|
@@ -28,7 +28,7 @@ function mergePasteContent(core, eventResult, clipboardData) {
|
|
|
28
28
|
var fragment = eventResult.fragment, domToModelOption = eventResult.domToModelOption, customizedMerge = eventResult.customizedMerge, pasteType = eventResult.pasteType;
|
|
29
29
|
core.api.formatContentModel(core, function (model, context) {
|
|
30
30
|
var selectedSegment = (0, collectSelections_1.getSelectedSegments)(model, true /*includeFormatHolder*/)[0];
|
|
31
|
-
var domToModelContext = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(undefined /*defaultFormat*/, core.domToModelSettings.customized, domToModelOption);
|
|
31
|
+
var domToModelContext = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(core.contentDiv.ownerDocument, undefined /*defaultFormat*/, core.domToModelSettings.customized, domToModelOption);
|
|
32
32
|
domToModelContext.segmentFormat = selectedSegment
|
|
33
33
|
? (0, getSegmentTextFormat_1.getSegmentTextFormat)(selectedSegment)
|
|
34
34
|
: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-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AAS,IAAI,aAAa,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,MAAM;YAC7E,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC;SAC3C,CAAC;QAEF,IAAM,WAAW,GAAG,eAAe;YAC/B,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC;YACpC,CAAC,CAAC,IAAA,uBAAU,EAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAE1D,IAAI,WAAW,EAAE;YACb,OAAO,CAAC,gBAAgB,yEACjB,kBAAkB,GAClB,KAAK,CAAC,MAAM,GACZ,WAAW,CAAC,MAAM,CAAC,MAAM,CAC/B,CAAC;SACL;QAED,OAAO,IAAI,CAAC;IAChB,CAAC,EACD;QACI,YAAY,EAAE,2BAAY,CAAC,KAAK;QAChC,aAAa,EAAE,cAAM,OAAA,aAAa,EAAb,CAAa;QAClC,OAAO,EAAE,OAAO;KACnB,CACJ,CAAC;AACN,CAAC;
|
|
1
|
+
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/utils/paste/mergePasteContent.ts"],"names":[],"mappings":";;;;AAAA,6DAA4D;AAC5D,gGAA+F;AAC/F,2EAAgE;AAChE,sFAAqF;AACrF,iFAAkF;AAClF,+DAA8D;AAW9D,IAAM,kBAAkB,GAAwC;IAC5D,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,KAAK;IACb,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,KAAK;IACpB,wBAAwB,EAAE,EAAE;IAC5B,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,KAAK;CACnB,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,IAA0B,EAC1B,WAA6B,EAC7B,aAA4B;IAEpB,IAAA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AAY,EAAE,2BAAY,CAAC,KAAK;QAChC,aAAa,EAAE,cAAM,OAAA,aAAa,EAAb,CAAa;QAClC,OAAO,EAAE,OAAO;KACnB,CACJ,CAAC;AACN,CAAC;AAhDD,8CAgDC;AAED,SAAS,gBAAgB,CAAC,UAAgC;IACtD,mIAAmI;IACnI,IACI,UAAU,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC;QAC7B,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO;QAC1C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW;QAC9C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAC1C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,EACvD;QACE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC/B;IACD,6DAA6D;IAC7D,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC;AACxF,CAAC","sourcesContent":["import { ChangeSource } from '../../constants/ChangeSource';\nimport { createDomToModelContextForSanitizing } from '../createDomToModelContextForSanitizing';\nimport { domToContentModel } from 'roosterjs-content-model-dom';\nimport { getSegmentTextFormat } from '../../publicApi/domUtils/getSegmentTextFormat';\nimport { getSelectedSegments } from '../../publicApi/selection/collectSelections';\nimport { mergeModel } from '../../publicApi/model/mergeModel';\n\nimport type { MergeModelOption } from '../../publicApi/model/mergeModel';\nimport type {\n BeforePasteEvent,\n ClipboardData,\n ContentModelDocument,\n ContentModelSegmentFormat,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\nconst EmptySegmentFormat: Required<ContentModelSegmentFormat> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n\n/**\n * @internal\n */\nexport function mergePasteContent(\n core: StandaloneEditorCore,\n eventResult: BeforePasteEvent,\n clipboardData: ClipboardData\n) {\n const { fragment, domToModelOption, customizedMerge, pasteType } = eventResult;\n\n core.api.formatContentModel(\n core,\n (model, context) => {\n const selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];\n const domToModelContext = createDomToModelContextForSanitizing(\n core.contentDiv.ownerDocument,\n undefined /*defaultFormat*/,\n core.domToModelSettings.customized,\n domToModelOption\n );\n\n domToModelContext.segmentFormat = selectedSegment\n ? getSegmentTextFormat(selectedSegment)\n : {};\n\n const pasteModel = domToContentModel(fragment, domToModelContext);\n const mergeOption: MergeModelOption = {\n mergeFormat: pasteType == 'mergeFormat' ? 'keepSourceEmphasisFormat' : 'none',\n mergeTable: shouldMergeTable(pasteModel),\n };\n\n const insertPoint = customizedMerge\n ? customizedMerge(model, pasteModel)\n : mergeModel(model, pasteModel, context, mergeOption);\n\n if (insertPoint) {\n context.newPendingFormat = {\n ...EmptySegmentFormat,\n ...model.format,\n ...insertPoint.marker.format,\n };\n }\n\n return true;\n },\n {\n changeSource: ChangeSource.Paste,\n getChangeData: () => clipboardData,\n apiName: 'paste',\n }\n );\n}\n\nfunction shouldMergeTable(pasteModel: ContentModelDocument): boolean | undefined {\n // If model contains a table and a paragraph element after the table with a single BR segment, remove the Paragraph after the table\n if (\n pasteModel.blocks.length == 2 &&\n pasteModel.blocks[0].blockType === 'Table' &&\n pasteModel.blocks[1].blockType === 'Paragraph' &&\n pasteModel.blocks[1].segments.length === 1 &&\n pasteModel.blocks[1].segments[0].segmentType === 'Br'\n ) {\n pasteModel.blocks.splice(1);\n }\n // Only merge table when the document contain a single table.\n return pasteModel.blocks.length === 1 && pasteModel.blocks[0].blockType === 'Table';\n}\n"]}
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
define(["require", "exports", "
|
|
1
|
+
define(["require", "exports", "tslib", "../utils/getRootComputedStyleForContext"], function (require, exports, tslib_1, getRootComputedStyleForContext_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createEditorContext = void 0;
|
|
5
|
-
var DefaultRootFontSize = 16;
|
|
6
5
|
/**
|
|
7
6
|
* @internal
|
|
8
7
|
* Create a EditorContext object used by ContentModel API
|
|
9
8
|
*/
|
|
10
9
|
var createEditorContext = function (core, saveIndex) {
|
|
11
|
-
var _a
|
|
10
|
+
var _a;
|
|
12
11
|
var lifecycle = core.lifecycle, format = core.format, darkColorHandler = core.darkColorHandler, contentDiv = core.contentDiv, cache = core.cache, domHelper = core.domHelper;
|
|
13
|
-
var context = {
|
|
14
|
-
isDarkMode: lifecycle.isDarkMode,
|
|
15
|
-
defaultFormat: format.defaultFormat,
|
|
16
|
-
pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined,
|
|
17
|
-
darkColorHandler: darkColorHandler,
|
|
18
|
-
addDelimiterForEntity: true,
|
|
19
|
-
allowCacheElement: true,
|
|
20
|
-
domIndexer: saveIndex ? cache.domIndexer : undefined,
|
|
21
|
-
zoomScale: domHelper.calculateZoomScale(),
|
|
22
|
-
rootFontSize: (0, roosterjs_content_model_dom_1.parseValueWithUnit)((_b = getRootComputedStyle(core)) === null || _b === void 0 ? void 0 : _b.fontSize) || DefaultRootFontSize,
|
|
23
|
-
};
|
|
12
|
+
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() }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(contentDiv.ownerDocument));
|
|
24
13
|
checkRootRtl(contentDiv, context);
|
|
25
14
|
return context;
|
|
26
15
|
};
|
|
@@ -32,11 +21,5 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
|
|
|
32
21
|
context.isRootRtl = true;
|
|
33
22
|
}
|
|
34
23
|
}
|
|
35
|
-
function getRootComputedStyle(core) {
|
|
36
|
-
var _a;
|
|
37
|
-
var document = core.contentDiv.ownerDocument;
|
|
38
|
-
var rootComputedStyle = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(document.documentElement);
|
|
39
|
-
return rootComputedStyle;
|
|
40
|
-
}
|
|
41
24
|
});
|
|
42
25
|
//# sourceMappingURL=createEditorContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":";;;;IAGA;;;OAGG;IACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;QAC5D,IAAA,SAAS,GAA6D,IAAI,UAAjE,EAAE,MAAM,GAAqD,IAAI,OAAzD,EAAE,gBAAgB,GAAmC,IAAI,iBAAvC,EAAE,UAAU,GAAuB,IAAI,WAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;QAEnF,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,IACtC,IAAA,+DAA8B,EAAC,UAAU,CAAC,aAAa,CAAC,CAC9D,CAAC;QAEF,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAElC,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;IAlBW,QAAA,mBAAmB,uBAkB9B;IAEF,SAAS,YAAY,CAAC,OAAoB,EAAE,OAAsB;;QAC9D,IAAM,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAC,WAAW,0CAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAE5E,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,KAAK,EAAE;YAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;SAC5B;IACL,CAAC","sourcesContent":["import { getRootComputedStyleForContext } from '../utils/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, contentDiv, cache, domHelper } = core;\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 ...getRootComputedStyleForContext(contentDiv.ownerDocument),\n };\n\n checkRootRtl(contentDiv, context);\n\n return context;\n};\n\nfunction checkRootRtl(element: HTMLElement, context: EditorContext) {\n const style = element?.ownerDocument.defaultView?.getComputedStyle(element);\n\n if (style?.direction == 'rtl') {\n context.isRootRtl = true;\n }\n}\n"]}
|
|
@@ -15,7 +15,7 @@ define(["require", "exports", "../../utils/convertInlineCss", "../../utils/creat
|
|
|
15
15
|
? new DOMParser().parseFromString((_a = trustedHTMLHandler === null || trustedHTMLHandler === void 0 ? void 0 : trustedHTMLHandler(html)) !== null && _a !== void 0 ? _a : html, 'text/html')
|
|
16
16
|
: null;
|
|
17
17
|
if (doc === null || doc === void 0 ? void 0 : doc.body) {
|
|
18
|
-
var context = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(defaultSegmentFormat, options);
|
|
18
|
+
var context = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(doc, defaultSegmentFormat, options);
|
|
19
19
|
var cssRules = doc ? (0, convertInlineCss_1.retrieveCssRules)(doc) : [];
|
|
20
20
|
(0, convertInlineCss_1.convertInlineCss)(doc, cssRules);
|
|
21
21
|
(0, roosterjs_content_model_dom_1.parseFormat)(doc.body, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModelFromHtml.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/createModelFromHtml.ts"],"names":[],"mappings":";;;;IAUA;;;;;;OAMG;IACH,SAAgB,mBAAmB,CAC/B,IAAY,EACZ,OAA0B,EAC1B,kBAAuC,EACvC,oBAAgD;;QAEhD,IAAM,GAAG,GAAG,IAAI;YACZ,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,mCAAI,IAAI,EAAE,WAAW,CAAC;YAClF,CAAC,CAAC,IAAI,CAAC;QAEX,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE;YACX,IAAM,OAAO,GAAG,IAAA,2EAAoC,EAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createModelFromHtml.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/createModelFromHtml.ts"],"names":[],"mappings":";;;;IAUA;;;;;;OAMG;IACH,SAAgB,mBAAmB,CAC/B,IAAY,EACZ,OAA0B,EAC1B,kBAAuC,EACvC,oBAAgD;;QAEhD,IAAM,GAAG,GAAG,IAAI;YACZ,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,mCAAI,IAAI,EAAE,WAAW,CAAC;YAClF,CAAC,CAAC,IAAI,CAAC;QAEX,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE;YACX,IAAM,OAAO,GAAG,IAAA,2EAAoC,EAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;YACzF,IAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,IAAA,mCAAgB,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAElD,IAAA,mCAAgB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAChC,IAAA,yCAAW,EAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YAE5F,OAAO,IAAA,+CAAiB,EAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SAC/C;aAAM;YACH,OAAO,IAAA,8CAAgB,EAAC,oBAAoB,CAAC,CAAC;SACjD;IACL,CAAC;IArBD,kDAqBC","sourcesContent":["import { convertInlineCss, retrieveCssRules } from '../../utils/convertInlineCss';\nimport { createDomToModelContextForSanitizing } from '../../utils/createDomToModelContextForSanitizing';\nimport { createEmptyModel, domToContentModel, parseFormat } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelSegmentFormat,\n DomToModelOption,\n TrustedHTMLHandler,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create Content Model from HTML string\n * @param html The source HTML string\n * @param options Options for DOM to Content Model conversion\n * @param trustedHTMLHandler A string handler to convert string to trusted string\n * @returns A Content Model Document object that contains the Content Model from the give HTML, or undefined if failed to parse the source HTML\n */\nexport function createModelFromHtml(\n html: string,\n options?: DomToModelOption,\n trustedHTMLHandler?: TrustedHTMLHandler,\n defaultSegmentFormat?: ContentModelSegmentFormat\n): ContentModelDocument {\n const doc = html\n ? new DOMParser().parseFromString(trustedHTMLHandler?.(html) ?? html, 'text/html')\n : null;\n\n if (doc?.body) {\n const context = createDomToModelContextForSanitizing(doc, defaultSegmentFormat, options);\n const cssRules = doc ? retrieveCssRules(doc) : [];\n\n convertInlineCss(doc, cssRules);\n parseFormat(doc.body, context.formatParsers.segmentOnBlock, context.segmentFormat, context);\n\n return domToContentModel(doc.body, context);\n } else {\n return createEmptyModel(defaultSegmentFormat);\n }\n}\n"]}
|
|
@@ -2,4 +2,4 @@ import type { ContentModelSegmentFormat, DomToModelContext, DomToModelOption, Do
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function createDomToModelContextForSanitizing(defaultFormat?: ContentModelSegmentFormat, defaultOption?: DomToModelOption, additionalSanitizingOption?: DomToModelOptionForSanitizing): DomToModelContext;
|
|
5
|
+
export declare function createDomToModelContextForSanitizing(document: Document, defaultFormat?: ContentModelSegmentFormat, defaultOption?: DomToModelOption, additionalSanitizingOption?: DomToModelOptionForSanitizing): DomToModelContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "../override/containerSizeFormatParser", "roosterjs-content-model-dom", "../override/pasteEntityProcessor", "../override/pasteGeneralProcessor", "../override/pasteCopyBlockEntityParser", "../override/pasteDisplayFormatParser", "../override/pasteTextProcessor"], function (require, exports, tslib_1, containerSizeFormatParser_1, roosterjs_content_model_dom_1, pasteEntityProcessor_1, pasteGeneralProcessor_1, pasteCopyBlockEntityParser_1, pasteDisplayFormatParser_1, pasteTextProcessor_1) {
|
|
1
|
+
define(["require", "exports", "tslib", "../override/containerSizeFormatParser", "roosterjs-content-model-dom", "../override/pasteEntityProcessor", "../override/pasteGeneralProcessor", "./getRootComputedStyleForContext", "../override/pasteCopyBlockEntityParser", "../override/pasteDisplayFormatParser", "../override/pasteTextProcessor"], function (require, exports, tslib_1, containerSizeFormatParser_1, roosterjs_content_model_dom_1, pasteEntityProcessor_1, pasteGeneralProcessor_1, getRootComputedStyleForContext_1, pasteCopyBlockEntityParser_1, pasteDisplayFormatParser_1, pasteTextProcessor_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createDomToModelContextForSanitizing = void 0;
|
|
@@ -14,11 +14,9 @@ define(["require", "exports", "tslib", "../override/containerSizeFormatParser",
|
|
|
14
14
|
/**
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
function createDomToModelContextForSanitizing(defaultFormat, defaultOption, additionalSanitizingOption) {
|
|
17
|
+
function createDomToModelContextForSanitizing(document, defaultFormat, defaultOption, additionalSanitizingOption) {
|
|
18
18
|
var sanitizingOption = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultSanitizingOption), additionalSanitizingOption);
|
|
19
|
-
return (0, roosterjs_content_model_dom_1.createDomToModelContext)({
|
|
20
|
-
defaultFormat: defaultFormat,
|
|
21
|
-
}, defaultOption, {
|
|
19
|
+
return (0, roosterjs_content_model_dom_1.createDomToModelContext)((0, tslib_1.__assign)({ defaultFormat: defaultFormat }, (0, getRootComputedStyleForContext_1.getRootComputedStyleForContext)(document)), defaultOption, {
|
|
22
20
|
processorOverride: {
|
|
23
21
|
'#text': pasteTextProcessor_1.pasteTextProcessor,
|
|
24
22
|
entity: (0, pasteEntityProcessor_1.createPasteEntityProcessor)(sanitizingOption),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDomToModelContextForSanitizing.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/createDomToModelContextForSanitizing.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"createDomToModelContextForSanitizing.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/createDomToModelContextForSanitizing.ts"],"names":[],"mappings":";;;;IAeA,IAAM,uBAAuB,GAAkC;QAC3D,iBAAiB,EAAE,EAAE;QACrB,oBAAoB,EAAE,EAAE;QACxB,uBAAuB,EAAE,EAAE;QAC3B,qBAAqB,EAAE,EAAE;QACzB,wBAAwB,EAAE,EAAE;QAC5B,eAAe,EAAE,EAAE;QACnB,mBAAmB,EAAE,EAAE;KAC1B,CAAC;IAEF;;OAEG;IACH,SAAgB,oCAAoC,CAChD,QAAkB,EAClB,aAAyC,EACzC,aAAgC,EAChC,0BAA0D;QAE1D,IAAM,gBAAgB,mDACf,uBAAuB,GACvB,0BAA0B,CAChC,CAAC;QAEF,OAAO,IAAA,qDAAuB,0BAEtB,aAAa,eAAA,IACV,IAAA,+DAA8B,EAAC,QAAQ,CAAC,GAE/C,aAAa,EACb;YACI,iBAAiB,EAAE;gBACf,OAAO,EAAE,uCAAkB;gBAC3B,MAAM,EAAE,IAAA,iDAA0B,EAAC,gBAAgB,CAAC;gBACpD,GAAG,EAAE,IAAA,mDAA2B,EAAC,gBAAgB,CAAC;aACrD;YACD,oBAAoB,EAAE;gBAClB,OAAO,EAAE,mDAAwB;aACpC;YACD,uBAAuB,EAAE;gBACrB,SAAS,EAAE,CAAC,qDAAyB,CAAC;gBACtC,MAAM,EAAE,CAAC,mDAAsB,CAAC;aACnC;SACJ,EACD,gBAAgB,CACnB,CAAC;IACN,CAAC;IAjCD,oFAiCC","sourcesContent":["import { containerSizeFormatParser } from '../override/containerSizeFormatParser';\nimport { createDomToModelContext } from 'roosterjs-content-model-dom';\nimport { createPasteEntityProcessor } from '../override/pasteEntityProcessor';\nimport { createPasteGeneralProcessor } from '../override/pasteGeneralProcessor';\nimport { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport { pasteBlockEntityParser } from '../override/pasteCopyBlockEntityParser';\nimport { pasteDisplayFormatParser } from '../override/pasteDisplayFormatParser';\nimport { pasteTextProcessor } from '../override/pasteTextProcessor';\nimport type {\n ContentModelSegmentFormat,\n DomToModelContext,\n DomToModelOption,\n DomToModelOptionForSanitizing,\n} from 'roosterjs-content-model-types';\n\nconst DefaultSanitizingOption: DomToModelOptionForSanitizing = {\n processorOverride: {},\n formatParserOverride: {},\n additionalFormatParsers: {},\n additionalAllowedTags: [],\n additionalDisallowedTags: [],\n styleSanitizers: {},\n attributeSanitizers: {},\n};\n\n/**\n * @internal\n */\nexport function createDomToModelContextForSanitizing(\n document: Document,\n defaultFormat?: ContentModelSegmentFormat,\n defaultOption?: DomToModelOption,\n additionalSanitizingOption?: DomToModelOptionForSanitizing\n): DomToModelContext {\n const sanitizingOption: DomToModelOptionForSanitizing = {\n ...DefaultSanitizingOption,\n ...additionalSanitizingOption,\n };\n\n return createDomToModelContext(\n {\n defaultFormat,\n ...getRootComputedStyleForContext(document),\n },\n defaultOption,\n {\n processorOverride: {\n '#text': pasteTextProcessor,\n entity: createPasteEntityProcessor(sanitizingOption),\n '*': createPasteGeneralProcessor(sanitizingOption),\n },\n formatParserOverride: {\n display: pasteDisplayFormatParser,\n },\n additionalFormatParsers: {\n container: [containerSizeFormatParser],\n entity: [pasteBlockEntityParser],\n },\n },\n sanitizingOption\n );\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_dom_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getRootComputedStyleForContext = void 0;
|
|
5
|
+
var DefaultRootFontSize = 16;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function getRootComputedStyleForContext(document) {
|
|
10
|
+
var _a;
|
|
11
|
+
var rootComputedStyle = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(document.documentElement);
|
|
12
|
+
return { rootFontSize: (0, roosterjs_content_model_dom_1.parseValueWithUnit)(rootComputedStyle === null || rootComputedStyle === void 0 ? void 0 : rootComputedStyle.fontSize) || DefaultRootFontSize };
|
|
13
|
+
}
|
|
14
|
+
exports.getRootComputedStyleForContext = getRootComputedStyleForContext;
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=getRootComputedStyleForContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRootComputedStyleForContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/getRootComputedStyleForContext.ts"],"names":[],"mappings":";;;;IAGA,IAAM,mBAAmB,GAAG,EAAE,CAAC;IAE/B;;OAEG;IACH,SAAgB,8BAA8B,CAC1C,QAAkB;;QAElB,IAAM,iBAAiB,GAAG,MAAA,QAAQ,CAAC,WAAW,0CAAE,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC3F,OAAO,EAAE,YAAY,EAAE,IAAA,gDAAkB,EAAC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,QAAQ,CAAC,IAAI,mBAAmB,EAAE,CAAC;IACpG,CAAC;IALD,wEAKC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport type { EditorContext } from 'roosterjs-content-model-types';\n\nconst DefaultRootFontSize = 16;\n\n/**\n * @internal\n */\nexport function getRootComputedStyleForContext(\n document: Document\n): Pick<EditorContext, 'rootFontSize'> {\n const rootComputedStyle = document.defaultView?.getComputedStyle(document.documentElement);\n return { rootFontSize: parseValueWithUnit(rootComputedStyle?.fontSize) || DefaultRootFontSize };\n}\n"]}
|
|
@@ -22,7 +22,7 @@ define(["require", "exports", "tslib", "../../constants/ChangeSource", "../creat
|
|
|
22
22
|
var fragment = eventResult.fragment, domToModelOption = eventResult.domToModelOption, customizedMerge = eventResult.customizedMerge, pasteType = eventResult.pasteType;
|
|
23
23
|
core.api.formatContentModel(core, function (model, context) {
|
|
24
24
|
var selectedSegment = (0, collectSelections_1.getSelectedSegments)(model, true /*includeFormatHolder*/)[0];
|
|
25
|
-
var domToModelContext = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(undefined /*defaultFormat*/, core.domToModelSettings.customized, domToModelOption);
|
|
25
|
+
var domToModelContext = (0, createDomToModelContextForSanitizing_1.createDomToModelContextForSanitizing)(core.contentDiv.ownerDocument, undefined /*defaultFormat*/, core.domToModelSettings.customized, domToModelOption);
|
|
26
26
|
domToModelContext.segmentFormat = selectedSegment
|
|
27
27
|
? (0, getSegmentTextFormat_1.getSegmentTextFormat)(selectedSegment)
|
|
28
28
|
: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/utils/paste/mergePasteContent.ts"],"names":[],"mappings":";;;;IAgBA,IAAM,kBAAkB,GAAwC;QAC5D,eAAe,EAAE,EAAE;QACnB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,KAAK;QACpB,wBAAwB,EAAE,EAAE;QAC5B,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACnB,CAAC;IAEF;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,IAA0B,EAC1B,WAA6B,EAC7B,aAA4B;QAEpB,IAAA,QAAQ,GAAmD,WAAW,SAA9D,EAAE,gBAAgB,GAAiC,WAAW,iBAA5C,EAAE,eAAe,GAAgB,WAAW,gBAA3B,EAAE,SAAS,GAAK,WAAW,UAAhB,CA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teContent.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/utils/paste/mergePasteContent.ts"],"names":[],"mappings":";;;;IAgBA,IAAM,kBAAkB,GAAwC;QAC5D,eAAe,EAAE,EAAE;QACnB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,KAAK;QACpB,wBAAwB,EAAE,EAAE;QAC5B,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACnB,CAAC;IAEF;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,IAA0B,EAC1B,WAA6B,EAC7B,aAA4B;QAEpB,IAAA,QAAQ,GAAmD,WAAW,SAA9D,EAAE,gBAAgB,GAAiC,WAAW,iBAA5C,EAAE,eAAe,GAAgB,WAAW,gBAA3B,EAAE,SAAS,GAAK,WAAW,UAAhB,CAAiB;QAE/E,IAAI,CAAC,GAAG,CAAC,kBAAkB,CACvB,IAAI,EACJ,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,eAAe,GAAG,IAAA,uCAAmB,EAAC,KAAK,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;YACpF,IAAM,iBAAiB,GAAG,IAAA,2EAAoC,EAC1D,IAAI,CAAC,UAAU,CAAC,aAAa,EAC7B,SAAS,CAAC,iBAAiB,EAC3B,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAClC,gBAAgB,CACnB,CAAC;YAEF,iBAAiB,CAAC,aAAa,GAAG,eAAe;gBAC7C,CAAC,CAAC,IAAA,2CAAoB,EAAC,eAAe,CAAC;gBACvC,CAAC,CAAC,EAAE,CAAC;YAET,IAAM,UAAU,GAAG,IAAA,+CAAiB,EAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;YAClE,IAAM,WAAW,GAAqB;gBAClC,WAAW,EAAE,SA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C,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC;IACxF,CAAC","sourcesContent":["import { ChangeSource } from '../../constants/ChangeSource';\nimport { createDomToModelContextForSanitizing } from '../createDomToModelContextForSanitizing';\nimport { domToContentModel } from 'roosterjs-content-model-dom';\nimport { getSegmentTextFormat } from '../../publicApi/domUtils/getSegmentTextFormat';\nimport { getSelectedSegments } from '../../publicApi/selection/collectSelections';\nimport { mergeModel } from '../../publicApi/model/mergeModel';\n\nimport type { MergeModelOption } from '../../publicApi/model/mergeModel';\nimport type {\n BeforePasteEvent,\n ClipboardData,\n ContentModelDocument,\n ContentModelSegmentFormat,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\nconst EmptySegmentFormat: Required<ContentModelSegmentFormat> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n\n/**\n * @internal\n */\nexport function mergePasteContent(\n core: StandaloneEditorCore,\n eventResult: BeforePasteEvent,\n clipboardData: ClipboardData\n) {\n const { fragment, domToModelOption, customizedMerge, pasteType } = eventResult;\n\n core.api.formatContentModel(\n core,\n (model, context) => {\n const selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];\n const domToModelContext = createDomToModelContextForSanitizing(\n core.contentDiv.ownerDocument,\n undefined /*defaultFormat*/,\n core.domToModelSettings.customized,\n domToModelOption\n );\n\n domToModelContext.segmentFormat = selectedSegment\n ? getSegmentTextFormat(selectedSegment)\n : {};\n\n const pasteModel = domToContentModel(fragment, domToModelContext);\n const mergeOption: MergeModelOption = {\n mergeFormat: pasteType == 'mergeFormat' ? 'keepSourceEmphasisFormat' : 'none',\n mergeTable: shouldMergeTable(pasteModel),\n };\n\n const insertPoint = customizedMerge\n ? customizedMerge(model, pasteModel)\n : mergeModel(model, pasteModel, context, mergeOption);\n\n if (insertPoint) {\n context.newPendingFormat = {\n ...EmptySegmentFormat,\n ...model.format,\n ...insertPoint.marker.format,\n };\n }\n\n return true;\n },\n {\n changeSource: ChangeSource.Paste,\n getChangeData: () => clipboardData,\n apiName: 'paste',\n }\n );\n}\n\nfunction shouldMergeTable(pasteModel: ContentModelDocument): boolean | undefined {\n // If model contains a table and a paragraph element after the table with a single BR segment, remove the Paragraph after the table\n if (\n pasteModel.blocks.length == 2 &&\n pasteModel.blocks[0].blockType === 'Table' &&\n pasteModel.blocks[1].blockType === 'Paragraph' &&\n pasteModel.blocks[1].segments.length === 1 &&\n pasteModel.blocks[1].segments[0].segmentType === 'Br'\n ) {\n pasteModel.blocks.splice(1);\n }\n // Only merge table when the document contain a single table.\n return pasteModel.blocks.length === 1 && pasteModel.blocks[0].blockType === 'Table';\n}\n"]}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { getRootComputedStyleForContext } from '../utils/getRootComputedStyleForContext';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
* Create a EditorContext object used by ContentModel API
|
|
6
6
|
*/
|
|
7
7
|
export var createEditorContext = function (core, saveIndex) {
|
|
8
|
-
var _a
|
|
8
|
+
var _a;
|
|
9
9
|
var lifecycle = core.lifecycle, format = core.format, darkColorHandler = core.darkColorHandler, contentDiv = core.contentDiv, cache = core.cache, domHelper = core.domHelper;
|
|
10
|
-
var context = {
|
|
11
|
-
isDarkMode: lifecycle.isDarkMode,
|
|
12
|
-
defaultFormat: format.defaultFormat,
|
|
13
|
-
pendingFormat: (_a = format.pendingFormat) !== null && _a !== void 0 ? _a : undefined,
|
|
14
|
-
darkColorHandler: darkColorHandler,
|
|
15
|
-
addDelimiterForEntity: true,
|
|
16
|
-
allowCacheElement: true,
|
|
17
|
-
domIndexer: saveIndex ? cache.domIndexer : undefined,
|
|
18
|
-
zoomScale: domHelper.calculateZoomScale(),
|
|
19
|
-
rootFontSize: parseValueWithUnit((_b = getRootComputedStyle(core)) === null || _b === void 0 ? void 0 : _b.fontSize) || DefaultRootFontSize,
|
|
20
|
-
};
|
|
10
|
+
var context = __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() }, getRootComputedStyleForContext(contentDiv.ownerDocument));
|
|
21
11
|
checkRootRtl(contentDiv, context);
|
|
22
12
|
return context;
|
|
23
13
|
};
|
|
@@ -28,10 +18,4 @@ function checkRootRtl(element, context) {
|
|
|
28
18
|
context.isRootRtl = true;
|
|
29
19
|
}
|
|
30
20
|
}
|
|
31
|
-
function getRootComputedStyle(core) {
|
|
32
|
-
var _a;
|
|
33
|
-
var document = core.contentDiv.ownerDocument;
|
|
34
|
-
var rootComputedStyle = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(document.documentElement);
|
|
35
|
-
return rootComputedStyle;
|
|
36
|
-
}
|
|
37
21
|
//# sourceMappingURL=createEditorContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAGzF;;;GAGG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,SAAS;;IAC5D,IAAA,SAAS,GAA6D,IAAI,UAAjE,EAAE,MAAM,GAAqD,IAAI,OAAzD,EAAE,gBAAgB,GAAmC,IAAI,iBAAvC,EAAE,UAAU,GAAuB,IAAI,WAA3B,EAAE,KAAK,GAAgB,IAAI,MAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;IAEnF,IAAM,OAAO,cACT,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,IACtC,8BAA8B,CAAC,UAAU,CAAC,aAAa,CAAC,CAC9D,CAAC;IAEF,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,OAAoB,EAAE,OAAsB;;IAC9D,IAAM,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAC,WAAW,0CAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5E,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,KAAK,EAAE;QAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;KAC5B;AACL,CAAC","sourcesContent":["import { getRootComputedStyleForContext } from '../utils/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, contentDiv, cache, domHelper } = core;\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 ...getRootComputedStyleForContext(contentDiv.ownerDocument),\n };\n\n checkRootRtl(contentDiv, context);\n\n return context;\n};\n\nfunction checkRootRtl(element: HTMLElement, context: EditorContext) {\n const style = element?.ownerDocument.defaultView?.getComputedStyle(element);\n\n if (style?.direction == 'rtl') {\n context.isRootRtl = true;\n }\n}\n"]}
|
|
@@ -14,7 +14,7 @@ export function createModelFromHtml(html, options, trustedHTMLHandler, defaultSe
|
|
|
14
14
|
? new DOMParser().parseFromString((_a = trustedHTMLHandler === null || trustedHTMLHandler === void 0 ? void 0 : trustedHTMLHandler(html)) !== null && _a !== void 0 ? _a : html, 'text/html')
|
|
15
15
|
: null;
|
|
16
16
|
if (doc === null || doc === void 0 ? void 0 : doc.body) {
|
|
17
|
-
var context = createDomToModelContextForSanitizing(defaultSegmentFormat, options);
|
|
17
|
+
var context = createDomToModelContextForSanitizing(doc, defaultSegmentFormat, options);
|
|
18
18
|
var cssRules = doc ? retrieveCssRules(doc) : [];
|
|
19
19
|
convertInlineCss(doc, cssRules);
|
|
20
20
|
parseFormat(doc.body, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModelFromHtml.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/createModelFromHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,oCAAoC,EAAE,MAAM,kDAAkD,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAQ/F;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAC/B,IAAY,EACZ,OAA0B,EAC1B,kBAAuC,EACvC,oBAAgD;;IAEhD,IAAM,GAAG,GAAG,IAAI;QACZ,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,mCAAI,IAAI,EAAE,WAAW,CAAC;QAClF,CAAC,CAAC,IAAI,CAAC;IAEX,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE;QACX,IAAM,OAAO,GAAG,oCAAoC,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createModelFromHtml.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/createModelFromHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,oCAAoC,EAAE,MAAM,kDAAkD,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAQ/F;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAC/B,IAAY,EACZ,OAA0B,EAC1B,kBAAuC,EACvC,oBAAgD;;IAEhD,IAAM,GAAG,GAAG,IAAI;QACZ,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,mCAAI,IAAI,EAAE,WAAW,CAAC;QAClF,CAAC,CAAC,IAAI,CAAC;IAEX,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE;QACX,IAAM,OAAO,GAAG,oCAAoC,CAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACzF,IAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAElD,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAChC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAE5F,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC/C;SAAM;QACH,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;KACjD;AACL,CAAC","sourcesContent":["import { convertInlineCss, retrieveCssRules } from '../../utils/convertInlineCss';\nimport { createDomToModelContextForSanitizing } from '../../utils/createDomToModelContextForSanitizing';\nimport { createEmptyModel, domToContentModel, parseFormat } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelSegmentFormat,\n DomToModelOption,\n TrustedHTMLHandler,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create Content Model from HTML string\n * @param html The source HTML string\n * @param options Options for DOM to Content Model conversion\n * @param trustedHTMLHandler A string handler to convert string to trusted string\n * @returns A Content Model Document object that contains the Content Model from the give HTML, or undefined if failed to parse the source HTML\n */\nexport function createModelFromHtml(\n html: string,\n options?: DomToModelOption,\n trustedHTMLHandler?: TrustedHTMLHandler,\n defaultSegmentFormat?: ContentModelSegmentFormat\n): ContentModelDocument {\n const doc = html\n ? new DOMParser().parseFromString(trustedHTMLHandler?.(html) ?? html, 'text/html')\n : null;\n\n if (doc?.body) {\n const context = createDomToModelContextForSanitizing(doc, defaultSegmentFormat, options);\n const cssRules = doc ? retrieveCssRules(doc) : [];\n\n convertInlineCss(doc, cssRules);\n parseFormat(doc.body, context.formatParsers.segmentOnBlock, context.segmentFormat, context);\n\n return domToContentModel(doc.body, context);\n } else {\n return createEmptyModel(defaultSegmentFormat);\n }\n}\n"]}
|
|
@@ -2,4 +2,4 @@ import type { ContentModelSegmentFormat, DomToModelContext, DomToModelOption, Do
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function createDomToModelContextForSanitizing(defaultFormat?: ContentModelSegmentFormat, defaultOption?: DomToModelOption, additionalSanitizingOption?: DomToModelOptionForSanitizing): DomToModelContext;
|
|
5
|
+
export declare function createDomToModelContextForSanitizing(document: Document, defaultFormat?: ContentModelSegmentFormat, defaultOption?: DomToModelOption, additionalSanitizingOption?: DomToModelOptionForSanitizing): DomToModelContext;
|
|
@@ -3,6 +3,7 @@ import { containerSizeFormatParser } from '../override/containerSizeFormatParser
|
|
|
3
3
|
import { createDomToModelContext } from 'roosterjs-content-model-dom';
|
|
4
4
|
import { createPasteEntityProcessor } from '../override/pasteEntityProcessor';
|
|
5
5
|
import { createPasteGeneralProcessor } from '../override/pasteGeneralProcessor';
|
|
6
|
+
import { getRootComputedStyleForContext } from './getRootComputedStyleForContext';
|
|
6
7
|
import { pasteBlockEntityParser } from '../override/pasteCopyBlockEntityParser';
|
|
7
8
|
import { pasteDisplayFormatParser } from '../override/pasteDisplayFormatParser';
|
|
8
9
|
import { pasteTextProcessor } from '../override/pasteTextProcessor';
|
|
@@ -18,11 +19,9 @@ var DefaultSanitizingOption = {
|
|
|
18
19
|
/**
|
|
19
20
|
* @internal
|
|
20
21
|
*/
|
|
21
|
-
export function createDomToModelContextForSanitizing(defaultFormat, defaultOption, additionalSanitizingOption) {
|
|
22
|
+
export function createDomToModelContextForSanitizing(document, defaultFormat, defaultOption, additionalSanitizingOption) {
|
|
22
23
|
var sanitizingOption = __assign(__assign({}, DefaultSanitizingOption), additionalSanitizingOption);
|
|
23
|
-
return createDomToModelContext({
|
|
24
|
-
defaultFormat: defaultFormat,
|
|
25
|
-
}, defaultOption, {
|
|
24
|
+
return createDomToModelContext(__assign({ defaultFormat: defaultFormat }, getRootComputedStyleForContext(document)), defaultOption, {
|
|
26
25
|
processorOverride: {
|
|
27
26
|
'#text': pasteTextProcessor,
|
|
28
27
|
entity: createPasteEntityProcessor(sanitizingOption),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDomToModelContextForSanitizing.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/createDomToModelContextForSanitizing.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQpE,IAAM,uBAAuB,GAAkC;IAC3D,iBAAiB,EAAE,EAAE;IACrB,oBAAoB,EAAE,EAAE;IACxB,uBAAuB,EAAE,EAAE;IAC3B,qBAAqB,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oCAAoC,CAChD,aAAyC,EACzC,aAAgC,EAChC,0BAA0D;IAE1D,IAAM,gBAAgB,yBACf,uBAAuB,GACvB,0BAA0B,CAChC,CAAC;IAEF,OAAO,uBAAuB,
|
|
1
|
+
{"version":3,"file":"createDomToModelContextForSanitizing.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/createDomToModelContextForSanitizing.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQpE,IAAM,uBAAuB,GAAkC;IAC3D,iBAAiB,EAAE,EAAE;IACrB,oBAAoB,EAAE,EAAE;IACxB,uBAAuB,EAAE,EAAE;IAC3B,qBAAqB,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oCAAoC,CAChD,QAAkB,EAClB,aAAyC,EACzC,aAAgC,EAChC,0BAA0D;IAE1D,IAAM,gBAAgB,yBACf,uBAAuB,GACvB,0BAA0B,CAChC,CAAC;IAEF,OAAO,uBAAuB,YAEtB,aAAa,eAAA,IACV,8BAA8B,CAAC,QAAQ,CAAC,GAE/C,aAAa,EACb;QACI,iBAAiB,EAAE;YACf,OAAO,EAAE,kBAAkB;YAC3B,MAAM,EAAE,0BAA0B,CAAC,gBAAgB,CAAC;YACpD,GAAG,EAAE,2BAA2B,CAAC,gBAAgB,CAAC;SACrD;QACD,oBAAoB,EAAE;YAClB,OAAO,EAAE,wBAAwB;SACpC;QACD,uBAAuB,EAAE;YACrB,SAAS,EAAE,CAAC,yBAAyB,CAAC;YACtC,MAAM,EAAE,CAAC,sBAAsB,CAAC;SACnC;KACJ,EACD,gBAAgB,CACnB,CAAC;AACN,CAAC","sourcesContent":["import { containerSizeFormatParser } from '../override/containerSizeFormatParser';\nimport { createDomToModelContext } from 'roosterjs-content-model-dom';\nimport { createPasteEntityProcessor } from '../override/pasteEntityProcessor';\nimport { createPasteGeneralProcessor } from '../override/pasteGeneralProcessor';\nimport { getRootComputedStyleForContext } from './getRootComputedStyleForContext';\nimport { pasteBlockEntityParser } from '../override/pasteCopyBlockEntityParser';\nimport { pasteDisplayFormatParser } from '../override/pasteDisplayFormatParser';\nimport { pasteTextProcessor } from '../override/pasteTextProcessor';\nimport type {\n ContentModelSegmentFormat,\n DomToModelContext,\n DomToModelOption,\n DomToModelOptionForSanitizing,\n} from 'roosterjs-content-model-types';\n\nconst DefaultSanitizingOption: DomToModelOptionForSanitizing = {\n processorOverride: {},\n formatParserOverride: {},\n additionalFormatParsers: {},\n additionalAllowedTags: [],\n additionalDisallowedTags: [],\n styleSanitizers: {},\n attributeSanitizers: {},\n};\n\n/**\n * @internal\n */\nexport function createDomToModelContextForSanitizing(\n document: Document,\n defaultFormat?: ContentModelSegmentFormat,\n defaultOption?: DomToModelOption,\n additionalSanitizingOption?: DomToModelOptionForSanitizing\n): DomToModelContext {\n const sanitizingOption: DomToModelOptionForSanitizing = {\n ...DefaultSanitizingOption,\n ...additionalSanitizingOption,\n };\n\n return createDomToModelContext(\n {\n defaultFormat,\n ...getRootComputedStyleForContext(document),\n },\n defaultOption,\n {\n processorOverride: {\n '#text': pasteTextProcessor,\n entity: createPasteEntityProcessor(sanitizingOption),\n '*': createPasteGeneralProcessor(sanitizingOption),\n },\n formatParserOverride: {\n display: pasteDisplayFormatParser,\n },\n additionalFormatParsers: {\n container: [containerSizeFormatParser],\n entity: [pasteBlockEntityParser],\n },\n },\n sanitizingOption\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseValueWithUnit } from 'roosterjs-content-model-dom';
|
|
2
|
+
var DefaultRootFontSize = 16;
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function getRootComputedStyleForContext(document) {
|
|
7
|
+
var _a;
|
|
8
|
+
var rootComputedStyle = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(document.documentElement);
|
|
9
|
+
return { rootFontSize: parseValueWithUnit(rootComputedStyle === null || rootComputedStyle === void 0 ? void 0 : rootComputedStyle.fontSize) || DefaultRootFontSize };
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=getRootComputedStyleForContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRootComputedStyleForContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/utils/getRootComputedStyleForContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,IAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC1C,QAAkB;;IAElB,IAAM,iBAAiB,GAAG,MAAA,QAAQ,CAAC,WAAW,0CAAE,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC3F,OAAO,EAAE,YAAY,EAAE,kBAAkB,CAAC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,QAAQ,CAAC,IAAI,mBAAmB,EAAE,CAAC;AACpG,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport type { EditorContext } from 'roosterjs-content-model-types';\n\nconst DefaultRootFontSize = 16;\n\n/**\n * @internal\n */\nexport function getRootComputedStyleForContext(\n document: Document\n): Pick<EditorContext, 'rootFontSize'> {\n const rootComputedStyle = document.defaultView?.getComputedStyle(document.documentElement);\n return { rootFontSize: parseValueWithUnit(rootComputedStyle?.fontSize) || DefaultRootFontSize };\n}\n"]}
|
|
@@ -25,7 +25,7 @@ export function mergePasteContent(core, eventResult, clipboardData) {
|
|
|
25
25
|
var fragment = eventResult.fragment, domToModelOption = eventResult.domToModelOption, customizedMerge = eventResult.customizedMerge, pasteType = eventResult.pasteType;
|
|
26
26
|
core.api.formatContentModel(core, function (model, context) {
|
|
27
27
|
var selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];
|
|
28
|
-
var domToModelContext = createDomToModelContextForSanitizing(undefined /*defaultFormat*/, core.domToModelSettings.customized, domToModelOption);
|
|
28
|
+
var domToModelContext = createDomToModelContextForSanitizing(core.contentDiv.ownerDocument, undefined /*defaultFormat*/, core.domToModelSettings.customized, domToModelOption);
|
|
29
29
|
domToModelContext.segmentFormat = selectedSegment
|
|
30
30
|
? getSegmentTextFormat(selectedSegment)
|
|
31
31
|
: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/utils/paste/mergePasteContent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAW9D,IAAM,kBAAkB,GAAwC;IAC5D,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,KAAK;IACb,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,KAAK;IACpB,wBAAwB,EAAE,EAAE;IAC5B,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,KAAK;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC7B,IAA0B,EAC1B,WAA6B,EAC7B,aAA4B;IAEpB,IAAA,QAAQ,GAAmD,WAAW,SAA9D,EAAE,gBAAgB,GAAiC,WAAW,iBAA5C,EAAE,eAAe,GAAgB,WAAW,gBAA3B,EAAE,SAAS,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nI,IACI,UAAU,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC;QAC7B,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO;QAC1C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW;QAC9C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAC1C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,EACvD;QACE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC/B;IACD,6DAA6D;IAC7D,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC;AACxF,CAAC","sourcesContent":["import { ChangeSource } from '../../constants/ChangeSource';\nimport { createDomToModelContextForSanitizing } from '../createDomToModelContextForSanitizing';\nimport { domToContentModel } from 'roosterjs-content-model-dom';\nimport { getSegmentTextFormat } from '../../publicApi/domUtils/getSegmentTextFormat';\nimport { getSelectedSegments } from '../../publicApi/selection/collectSelections';\nimport { mergeModel } from '../../publicApi/model/mergeModel';\n\nimport type { MergeModelOption } from '../../publicApi/model/mergeModel';\nimport type {\n BeforePasteEvent,\n ClipboardData,\n ContentModelDocument,\n ContentModelSegmentFormat,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\nconst EmptySegmentFormat: Required<ContentModelSegmentFormat> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n\n/**\n * @internal\n */\nexport function mergePasteContent(\n core: StandaloneEditorCore,\n eventResult: BeforePasteEvent,\n clipboardData: ClipboardData\n) {\n const { fragment, domToModelOption, customizedMerge, pasteType } = eventResult;\n\n core.api.formatContentModel(\n core,\n (model, context) => {\n const selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];\n const domToModelContext = createDomToModelContextForSanitizing(\n undefined /*defaultFormat*/,\n core.domToModelSettings.customized,\n domToModelOption\n );\n\n domToModelContext.segmentFormat = selectedSegment\n ? getSegmentTextFormat(selectedSegment)\n : {};\n\n const pasteModel = domToContentModel(fragment, domToModelContext);\n const mergeOption: MergeModelOption = {\n mergeFormat: pasteType == 'mergeFormat' ? 'keepSourceEmphasisFormat' : 'none',\n mergeTable: shouldMergeTable(pasteModel),\n };\n\n const insertPoint = customizedMerge\n ? customizedMerge(model, pasteModel)\n : mergeModel(model, pasteModel, context, mergeOption);\n\n if (insertPoint) {\n context.newPendingFormat = {\n ...EmptySegmentFormat,\n ...model.format,\n ...insertPoint.marker.format,\n };\n }\n\n return true;\n },\n {\n changeSource: ChangeSource.Paste,\n getChangeData: () => clipboardData,\n apiName: 'paste',\n }\n );\n}\n\nfunction shouldMergeTable(pasteModel: ContentModelDocument): boolean | undefined {\n // If model contains a table and a paragraph element after the table with a single BR segment, remove the Paragraph after the table\n if (\n pasteModel.blocks.length == 2 &&\n pasteModel.blocks[0].blockType === 'Table' &&\n pasteModel.blocks[1].blockType === 'Paragraph' &&\n pasteModel.blocks[1].segments.length === 1 &&\n pasteModel.blocks[1].segments[0].segmentType === 'Br'\n ) {\n pasteModel.blocks.splice(1);\n }\n // Only merge table when the document contain a single table.\n return pasteModel.blocks.length === 1 && pasteModel.blocks[0].blockType === 'Table';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mergePasteContent.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/utils/paste/mergePasteContent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;A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MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC;AACxF,CAAC","sourcesContent":["import { ChangeSource } from '../../constants/ChangeSource';\nimport { createDomToModelContextForSanitizing } from '../createDomToModelContextForSanitizing';\nimport { domToContentModel } from 'roosterjs-content-model-dom';\nimport { getSegmentTextFormat } from '../../publicApi/domUtils/getSegmentTextFormat';\nimport { getSelectedSegments } from '../../publicApi/selection/collectSelections';\nimport { mergeModel } from '../../publicApi/model/mergeModel';\n\nimport type { MergeModelOption } from '../../publicApi/model/mergeModel';\nimport type {\n BeforePasteEvent,\n ClipboardData,\n ContentModelDocument,\n ContentModelSegmentFormat,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\nconst EmptySegmentFormat: Required<ContentModelSegmentFormat> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n\n/**\n * @internal\n */\nexport function mergePasteContent(\n core: StandaloneEditorCore,\n eventResult: BeforePasteEvent,\n clipboardData: ClipboardData\n) {\n const { fragment, domToModelOption, customizedMerge, pasteType } = eventResult;\n\n core.api.formatContentModel(\n core,\n (model, context) => {\n const selectedSegment = getSelectedSegments(model, true /*includeFormatHolder*/)[0];\n const domToModelContext = createDomToModelContextForSanitizing(\n core.contentDiv.ownerDocument,\n undefined /*defaultFormat*/,\n core.domToModelSettings.customized,\n domToModelOption\n );\n\n domToModelContext.segmentFormat = selectedSegment\n ? getSegmentTextFormat(selectedSegment)\n : {};\n\n const pasteModel = domToContentModel(fragment, domToModelContext);\n const mergeOption: MergeModelOption = {\n mergeFormat: pasteType == 'mergeFormat' ? 'keepSourceEmphasisFormat' : 'none',\n mergeTable: shouldMergeTable(pasteModel),\n };\n\n const insertPoint = customizedMerge\n ? customizedMerge(model, pasteModel)\n : mergeModel(model, pasteModel, context, mergeOption);\n\n if (insertPoint) {\n context.newPendingFormat = {\n ...EmptySegmentFormat,\n ...model.format,\n ...insertPoint.marker.format,\n };\n }\n\n return true;\n },\n {\n changeSource: ChangeSource.Paste,\n getChangeData: () => clipboardData,\n apiName: 'paste',\n }\n );\n}\n\nfunction shouldMergeTable(pasteModel: ContentModelDocument): boolean | undefined {\n // If model contains a table and a paragraph element after the table with a single BR segment, remove the Paragraph after the table\n if (\n pasteModel.blocks.length == 2 &&\n pasteModel.blocks[0].blockType === 'Table' &&\n pasteModel.blocks[1].blockType === 'Paragraph' &&\n pasteModel.blocks[1].segments.length === 1 &&\n pasteModel.blocks[1].segments[0].segmentType === 'Br'\n ) {\n pasteModel.blocks.splice(1);\n }\n // Only merge table when the document contain a single table.\n return pasteModel.blocks.length === 1 && pasteModel.blocks[0].blockType === 'Table';\n}\n"]}
|
package/package.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"description": "Content Model for roosterjs (Under development)",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
|
-
"roosterjs-content-model-dom": "^0.26.
|
|
7
|
-
"roosterjs-content-model-types": "^0.26.
|
|
6
|
+
"roosterjs-content-model-dom": "^0.26.4",
|
|
7
|
+
"roosterjs-content-model-types": "^0.26.4"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.26.
|
|
9
|
+
"version": "0.26.4",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"typings": "./lib/index.d.ts",
|
|
12
12
|
"module": "./lib-mjs/index.js",
|