roosterjs-content-model-dom 9.61.0 → 9.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constants/EmptySegmentFormat.js +1 -0
- package/lib/constants/EmptySegmentFormat.js.map +1 -1
- package/lib/formatHandlers/segment/boldFormatHandler.js +2 -1
- package/lib/formatHandlers/segment/boldFormatHandler.js.map +1 -1
- package/lib/formatHandlers/segment/superOrSubScriptFormatHandler.js +10 -2
- package/lib/formatHandlers/segment/superOrSubScriptFormatHandler.js.map +1 -1
- package/lib/modelApi/common/stripInvisibleUnicode.js +2 -2
- package/lib/modelApi/common/stripInvisibleUnicode.js.map +1 -1
- package/lib/modelApi/editing/mergeModel.js +20 -12
- package/lib/modelApi/editing/mergeModel.js.map +1 -1
- package/lib-amd/constants/EmptySegmentFormat.js +1 -0
- package/lib-amd/constants/EmptySegmentFormat.js.map +1 -1
- package/lib-amd/formatHandlers/segment/boldFormatHandler.js +2 -2
- package/lib-amd/formatHandlers/segment/boldFormatHandler.js.map +1 -1
- package/lib-amd/formatHandlers/segment/superOrSubScriptFormatHandler.js +10 -2
- package/lib-amd/formatHandlers/segment/superOrSubScriptFormatHandler.js.map +1 -1
- package/lib-amd/modelApi/common/stripInvisibleUnicode.js +2 -2
- package/lib-amd/modelApi/common/stripInvisibleUnicode.js.map +1 -1
- package/lib-amd/modelApi/editing/mergeModel.js +20 -12
- package/lib-amd/modelApi/editing/mergeModel.js.map +1 -1
- package/lib-mjs/constants/EmptySegmentFormat.js +1 -0
- package/lib-mjs/constants/EmptySegmentFormat.js.map +1 -1
- package/lib-mjs/formatHandlers/segment/boldFormatHandler.js +2 -1
- package/lib-mjs/formatHandlers/segment/boldFormatHandler.js.map +1 -1
- package/lib-mjs/formatHandlers/segment/superOrSubScriptFormatHandler.js +10 -2
- package/lib-mjs/formatHandlers/segment/superOrSubScriptFormatHandler.js.map +1 -1
- package/lib-mjs/modelApi/common/stripInvisibleUnicode.js +2 -2
- package/lib-mjs/modelApi/common/stripInvisibleUnicode.js.map +1 -1
- package/lib-mjs/modelApi/editing/mergeModel.js +20 -12
- package/lib-mjs/modelApi/editing/mergeModel.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptySegmentFormat.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/EmptySegmentFormat.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,kBAAkB,GAAkD;IAC7E,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","sourcesContent":["import type { ContentModelSegmentFormat } from 'roosterjs-content-model-types';\n\n/**\n * Provide a default empty instance of segment format with all its properties\n */\nexport const EmptySegmentFormat: Readonly<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"]}
|
|
1
|
+
{"version":3,"file":"EmptySegmentFormat.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/EmptySegmentFormat.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,kBAAkB,GAAkD;IAC7E,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,wBAAwB,EAAE,EAAE;IAC5B,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,KAAK;CACnB,CAAC","sourcesContent":["import type { ContentModelSegmentFormat } from 'roosterjs-content-model-types';\n\n/**\n * Provide a default empty instance of segment format with all its properties\n */\nexport const EmptySegmentFormat: Readonly<Required<ContentModelSegmentFormat>> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptFontSize: '',\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.boldFormatHandler = void 0;
|
|
4
|
+
var isBlockElement_1 = require("../../domToModel/utils/isBlockElement");
|
|
4
5
|
var shouldSetValue_1 = require("../utils/shouldSetValue");
|
|
5
6
|
var moveChildNodes_1 = require("../../domUtils/moveChildNodes");
|
|
6
7
|
/**
|
|
@@ -20,7 +21,7 @@ exports.boldFormatHandler = {
|
|
|
20
21
|
var blockFontWeight = context.implicitFormat.fontWeight;
|
|
21
22
|
if ((blockFontWeight && blockFontWeight != format.fontWeight) ||
|
|
22
23
|
(!blockFontWeight && format.fontWeight && format.fontWeight != 'normal')) {
|
|
23
|
-
if (format.fontWeight == 'bold') {
|
|
24
|
+
if (format.fontWeight == 'bold' && !(0, isBlockElement_1.isBlockElement)(element)) {
|
|
24
25
|
(0, moveChildNodes_1.wrapAllChildNodes)(element, 'b');
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boldFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/boldFormatHandler.ts"],"names":[],"mappings":";;;AAAA,0DAAyD;AACzD,gEAAkE;AAIlE;;GAEG;AACU,QAAA,iBAAiB,GAA8B;IACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;QAC1C,IAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU,CAAC;QAEvE,IAAI,IAAA,+BAAc,EAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE;YAC/E,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;SAClC;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,WAAW,EAAE;YAC1C,OAAO;SACV;QAED,IAAM,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;QAE1D,IACI,CAAC,eAAe,IAAI,eAAe,IAAI,MAAM,CAAC,UAAU,CAAC;YACzD,CAAC,CAAC,eAAe,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,EAC1E;YACE,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"boldFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/boldFormatHandler.ts"],"names":[],"mappings":";;;AAAA,wEAAuE;AACvE,0DAAyD;AACzD,gEAAkE;AAIlE;;GAEG;AACU,QAAA,iBAAiB,GAA8B;IACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;QAC1C,IAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU,CAAC;QAEvE,IAAI,IAAA,+BAAc,EAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE;YAC/E,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;SAClC;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,WAAW,EAAE;YAC1C,OAAO;SACV;QAED,IAAM,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;QAE1D,IACI,CAAC,eAAe,IAAI,eAAe,IAAI,MAAM,CAAC,UAAU,CAAC;YACzD,CAAC,CAAC,eAAe,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,EAC1E;YACE,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,IAAI,CAAC,IAAA,+BAAc,EAAC,OAAO,CAAC,EAAE;gBACzD,IAAA,kCAAiB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;aACnC;iBAAM;gBACH,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC;aAC5D;SACJ;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { isBlockElement } from '../../domToModel/utils/isBlockElement';\nimport { shouldSetValue } from '../utils/shouldSetValue';\nimport { wrapAllChildNodes } from '../../domUtils/moveChildNodes';\nimport type { BoldFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const boldFormatHandler: FormatHandler<BoldFormat> = {\n parse: (format, element, context, defaultStyle) => {\n const fontWeight = element.style.fontWeight || defaultStyle.fontWeight;\n\n if (shouldSetValue(fontWeight, '400', format.fontWeight, defaultStyle.fontWeight)) {\n format.fontWeight = fontWeight;\n }\n },\n apply: (format, element, context) => {\n if (typeof format.fontWeight === 'undefined') {\n return;\n }\n\n const blockFontWeight = context.implicitFormat.fontWeight;\n\n if (\n (blockFontWeight && blockFontWeight != format.fontWeight) ||\n (!blockFontWeight && format.fontWeight && format.fontWeight != 'normal')\n ) {\n if (format.fontWeight == 'bold' && !isBlockElement(element)) {\n wrapAllChildNodes(element, 'b');\n } else {\n element.style.fontWeight = format.fontWeight || 'normal';\n }\n }\n },\n};\n"]}
|
|
@@ -9,12 +9,17 @@ exports.superOrSubScriptFormatHandler = {
|
|
|
9
9
|
parse: function (format, element, context, defaultStyle) {
|
|
10
10
|
var verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;
|
|
11
11
|
var fontSize = element.style.fontSize || defaultStyle.fontSize;
|
|
12
|
-
|
|
12
|
+
var inheritFontSize = (element.tagName == 'SUP' || element.tagName == 'SUB') && fontSize == 'inherit';
|
|
13
|
+
if (isSuperOrSubScript(fontSize, verticalAlign) ||
|
|
14
|
+
(inheritFontSize && (verticalAlign == 'super' || verticalAlign == 'sub'))) {
|
|
13
15
|
format.superOrSubScriptSequence = (format.superOrSubScriptSequence || '')
|
|
14
16
|
.split(' ')
|
|
15
17
|
.concat(verticalAlign)
|
|
16
18
|
.join(' ')
|
|
17
19
|
.trim();
|
|
20
|
+
if (inheritFontSize) {
|
|
21
|
+
format.superOrSubScriptFontSize = 'inherit';
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
apply: function (format, element) {
|
|
@@ -25,7 +30,10 @@ exports.superOrSubScriptFormatHandler = {
|
|
|
25
30
|
.forEach(function (value) {
|
|
26
31
|
var tagName = value == 'super' ? 'sup' : value == 'sub' ? 'sub' : null;
|
|
27
32
|
if (tagName) {
|
|
28
|
-
(0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
|
|
33
|
+
var wrapper = (0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
|
|
34
|
+
if (format.superOrSubScriptFontSize) {
|
|
35
|
+
wrapper.style.fontSize = format.superOrSubScriptFontSize;
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
});
|
|
31
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superOrSubScriptFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/superOrSubScriptFormatHandler.ts"],"names":[],"mappings":";;;AAAA,gEAAkE;AAIlE;;GAEG;AACU,QAAA,6BAA6B,GAA0C;IAChF,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;QAC1C,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,YAAY,CAAC,aAAa,CAAC;QAChF,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC;QAEjE,IAAI,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"superOrSubScriptFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/superOrSubScriptFormatHandler.ts"],"names":[],"mappings":";;;AAAA,gEAAkE;AAIlE;;GAEG;AACU,QAAA,6BAA6B,GAA0C;IAChF,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;QAC1C,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,YAAY,CAAC,aAAa,CAAC;QAChF,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC;QAEjE,IAAM,eAAe,GACjB,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,QAAQ,IAAI,SAAS,CAAC;QAEpF,IACI,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC;YAC3C,CAAC,eAAe,IAAI,CAAC,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,KAAK,CAAC,CAAC,EAC3E;YACE,MAAM,CAAC,wBAAwB,GAAG,CAAC,MAAM,CAAC,wBAAwB,IAAI,EAAE,CAAC;iBACpE,KAAK,CAAC,GAAG,CAAC;iBACV,MAAM,CAAC,aAAa,CAAC;iBACrB,IAAI,CAAC,GAAG,CAAC;iBACT,IAAI,EAAE,CAAC;YACZ,IAAI,eAAe,EAAE;gBACjB,MAAM,CAAC,wBAAwB,GAAG,SAAS,CAAC;aAC/C;SACJ;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,MAAM,CAAC,wBAAwB,EAAE;YACjC,MAAM,CAAC,wBAAwB;iBAC1B,KAAK,CAAC,GAAG,CAAC;iBACV,OAAO,EAAE;iBACT,OAAO,CAAC,UAAA,KAAK;gBACV,IAAM,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;gBAEzE,IAAI,OAAO,EAAE;oBACT,IAAM,OAAO,GAAG,IAAA,kCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBACpD,IAAI,MAAM,CAAC,wBAAwB,EAAE;wBACjC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC;qBAC5D;iBACJ;YACL,CAAC,CAAC,CAAC;SACV;IACL,CAAC;CACJ,CAAC;AAEF;;GAEG;AACH,SAAgB,kBAAkB,CAC9B,QAA4B,EAC5B,aAAiC;IAEjC,OAAO,QAAQ,IAAI,SAAS,IAAI,CAAC,aAAa,IAAI,KAAK,IAAI,aAAa,IAAI,OAAO,CAAC,CAAC;AACzF,CAAC;AALD,gDAKC","sourcesContent":["import { wrapAllChildNodes } from '../../domUtils/moveChildNodes';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { SuperOrSubScriptFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const superOrSubScriptFormatHandler: FormatHandler<SuperOrSubScriptFormat> = {\n parse: (format, element, context, defaultStyle) => {\n const verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;\n const fontSize = element.style.fontSize || defaultStyle.fontSize;\n\n const inheritFontSize =\n (element.tagName == 'SUP' || element.tagName == 'SUB') && fontSize == 'inherit';\n\n if (\n isSuperOrSubScript(fontSize, verticalAlign) ||\n (inheritFontSize && (verticalAlign == 'super' || verticalAlign == 'sub'))\n ) {\n format.superOrSubScriptSequence = (format.superOrSubScriptSequence || '')\n .split(' ')\n .concat(verticalAlign)\n .join(' ')\n .trim();\n if (inheritFontSize) {\n format.superOrSubScriptFontSize = 'inherit';\n }\n }\n },\n apply: (format, element) => {\n if (format.superOrSubScriptSequence) {\n format.superOrSubScriptSequence\n .split(' ')\n .reverse()\n .forEach(value => {\n const tagName = value == 'super' ? 'sup' : value == 'sub' ? 'sub' : null;\n\n if (tagName) {\n const wrapper = wrapAllChildNodes(element, tagName);\n if (format.superOrSubScriptFontSize) {\n wrapper.style.fontSize = format.superOrSubScriptFontSize;\n }\n }\n });\n }\n },\n};\n\n/**\n * @internal\n */\nexport function isSuperOrSubScript(\n fontSize: string | undefined,\n verticalAlign: string | undefined\n): verticalAlign is 'sub' | 'super' {\n return fontSize == 'smaller' && (verticalAlign == 'sub' || verticalAlign == 'super');\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripInvisibleUnicode = void 0;
|
|
4
4
|
// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
|
|
5
|
-
// there are some invisible unicode characters in the range of U+E0000 to U+
|
|
5
|
+
// there are some invisible unicode characters in the range of U+E0000 to U+E007F, which are used for hiding text in HTML.
|
|
6
6
|
// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
|
|
7
|
-
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{
|
|
7
|
+
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{E007F}]/gu;
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
* Strip invisible unicode characters from the given string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,0HAA0H;AAC1H,+IAA+I;AAC/I,IAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAE1D;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAFD,sDAEC","sourcesContent":["// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n// there are some invisible unicode characters in the range of U+E0000 to U+
|
|
1
|
+
{"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,0HAA0H;AAC1H,+IAA+I;AAC/I,IAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAE1D;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAFD,sDAEC","sourcesContent":["// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n// there are some invisible unicode characters in the range of U+E0000 to U+E007F, which are used for hiding text in HTML.\n// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.\nconst INVISIBLE_UNICODE_REGEX = /[\\u{E0000}-\\u{E007F}]/gu;\n\n/**\n * @internal\n * Strip invisible unicode characters from the given string\n * @param value The string to be processed\n * @returns The string with invisible unicode characters removed\n */\nexport function stripInvisibleUnicode(value: string): string {\n return value.replace(INVISIBLE_UNICODE_REGEX, '');\n}\n"]}
|
|
@@ -28,21 +28,22 @@ var KeysOfSegmentFormat = (0, getObjectKeys_1.getObjectKeys)(EmptySegmentFormat_
|
|
|
28
28
|
* @returns Insert point after merge, or null if there is no insert point
|
|
29
29
|
*/
|
|
30
30
|
function mergeModel(target, source, context, options) {
|
|
31
|
-
var _a, _b;
|
|
31
|
+
var _a, _b, _c;
|
|
32
32
|
var insertPosition = (_a = options === null || options === void 0 ? void 0 : options.insertPosition) !== null && _a !== void 0 ? _a : (0, deleteSelection_1.deleteSelection)(target, [], context).insertPoint;
|
|
33
|
-
var
|
|
33
|
+
var _d = options || {}, addParagraphAfterMergedContent = _d.addParagraphAfterMergedContent, mergeFormat = _d.mergeFormat, mergeParagraphAfterList = _d.mergeParagraphAfterList, mergeTable = _d.mergeTable;
|
|
34
34
|
if (mergeParagraphAfterList && insertPosition && ((_b = source.blocks[0]) === null || _b === void 0 ? void 0 : _b.blockType) == 'Paragraph') {
|
|
35
35
|
moveParagraphAfterListIntoList(insertPosition);
|
|
36
36
|
}
|
|
37
37
|
if (addParagraphAfterMergedContent && !mergeTable) {
|
|
38
|
-
var
|
|
38
|
+
var _e = insertPosition || {}, paragraph = _e.paragraph, marker = _e.marker;
|
|
39
39
|
var newPara = (0, createParagraph_1.createParagraph)(false /* isImplicit */, paragraph === null || paragraph === void 0 ? void 0 : paragraph.format, marker === null || marker === void 0 ? void 0 : marker.format);
|
|
40
40
|
(0, addBlock_1.addBlock)(source, newPara);
|
|
41
41
|
}
|
|
42
42
|
if (insertPosition) {
|
|
43
43
|
if (mergeFormat && mergeFormat != 'none') {
|
|
44
|
-
var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})),
|
|
45
|
-
|
|
44
|
+
var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})), ((options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator)
|
|
45
|
+
? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (_c = insertPosition.paragraph.decorator) === null || _c === void 0 ? void 0 : _c.format), insertPosition.paragraph.segmentFormat) : undefined)), insertPosition.marker.format);
|
|
46
|
+
applyDefaultFormat(source, newFormat, mergeFormat, options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator);
|
|
46
47
|
}
|
|
47
48
|
for (var i = 0; i < source.blocks.length; i++) {
|
|
48
49
|
var block = source.blocks[i];
|
|
@@ -320,7 +321,7 @@ function insertBlock(markerPosition, block) {
|
|
|
320
321
|
(0, mutate_1.mutateBlock)(path[0]).blocks.splice(blockIndex, 0, block);
|
|
321
322
|
}
|
|
322
323
|
}
|
|
323
|
-
function applyDefaultFormat(group, format, applyDefaultFormatOption) {
|
|
324
|
+
function applyDefaultFormat(group, format, applyDefaultFormatOption, preserveParagraphDecorator) {
|
|
324
325
|
group.blocks.forEach(function (block) {
|
|
325
326
|
var _a;
|
|
326
327
|
mergeBlockFormat(applyDefaultFormatOption, block);
|
|
@@ -329,28 +330,32 @@ function applyDefaultFormat(group, format, applyDefaultFormatOption) {
|
|
|
329
330
|
if (block.blockGroupType == 'ListItem') {
|
|
330
331
|
(0, mutate_1.mutateBlock)(block).formatHolder.format = mergeSegmentFormat(applyDefaultFormatOption, format, block.formatHolder.format);
|
|
331
332
|
}
|
|
332
|
-
applyDefaultFormat(block, format, applyDefaultFormatOption);
|
|
333
|
+
applyDefaultFormat(block, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
333
334
|
break;
|
|
334
335
|
case 'Table':
|
|
335
336
|
block.rows.forEach(function (row) {
|
|
336
337
|
return row.cells.forEach(function (cell) {
|
|
337
|
-
applyDefaultFormat(cell, format, applyDefaultFormatOption);
|
|
338
|
+
applyDefaultFormat(cell, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
338
339
|
});
|
|
339
340
|
});
|
|
340
341
|
break;
|
|
341
342
|
case 'Paragraph':
|
|
342
343
|
var paragraphFormat_1 = ((_a = block.decorator) === null || _a === void 0 ? void 0 : _a.format) || {};
|
|
343
344
|
var paragraph = (0, mutate_1.mutateBlock)(block);
|
|
345
|
+
var paragraphTargetFormat_1 = applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
|
|
346
|
+
preserveParagraphDecorator
|
|
347
|
+
? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, format), paragraphFormat_1) : format;
|
|
344
348
|
paragraph.segments.forEach(function (segment) {
|
|
345
349
|
if (segment.segmentType == 'General') {
|
|
346
|
-
applyDefaultFormat(segment, format, applyDefaultFormatOption);
|
|
350
|
+
applyDefaultFormat(segment, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
347
351
|
}
|
|
348
|
-
segment.format = mergeSegmentFormat(applyDefaultFormatOption,
|
|
352
|
+
segment.format = mergeSegmentFormat(applyDefaultFormatOption, paragraphTargetFormat_1, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, paragraphFormat_1), segment.format));
|
|
349
353
|
if (segment.link) {
|
|
350
354
|
segment.link.format = mergeLinkFormat(applyDefaultFormatOption, format, segment.link.format);
|
|
351
355
|
}
|
|
352
356
|
});
|
|
353
|
-
if (applyDefaultFormatOption === 'keepSourceEmphasisFormat'
|
|
357
|
+
if (applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
|
|
358
|
+
!preserveParagraphDecorator) {
|
|
354
359
|
delete paragraph.decorator;
|
|
355
360
|
}
|
|
356
361
|
break;
|
|
@@ -400,7 +405,7 @@ function mergeSegmentFormat(applyDefaultFormatOption, targetFormat, sourceFormat
|
|
|
400
405
|
}
|
|
401
406
|
function getSemanticFormat(segmentFormat) {
|
|
402
407
|
var result = {};
|
|
403
|
-
var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline;
|
|
408
|
+
var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline, strikethrough = segmentFormat.strikethrough;
|
|
404
409
|
if (fontWeight && fontWeight != 'normal') {
|
|
405
410
|
result.fontWeight = fontWeight;
|
|
406
411
|
}
|
|
@@ -410,6 +415,9 @@ function getSemanticFormat(segmentFormat) {
|
|
|
410
415
|
if (underline) {
|
|
411
416
|
result.underline = underline;
|
|
412
417
|
}
|
|
418
|
+
if (strikethrough) {
|
|
419
|
+
result.strikethrough = strikethrough;
|
|
420
|
+
}
|
|
413
421
|
return result;
|
|
414
422
|
}
|
|
415
423
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/mergeModel.ts"],"names":[],"mappings":";;;;AAAA,+CAA8C;AAC9C,mDAAkD;AAClD,uDAAsD;AACtD,iDAAgD;AAChD,6DAA4D;AAC5D,+DAA8D;AAC9D,2EAA0E;AAC1E,+DAA8D;AAC9D,qDAAoD;AACpD,yEAAwE;AACxE,yFAAwF;AACxF,+DAA8D;AAC9D,2CAA+C;AAC/C,yEAAwE;AACxE,mDAAkD;AAqBlD,IAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzD,IAAM,mBAAmB,GAAG,IAAA,6BAAa,EAAC,uCAAkB,CAAC,CAAC;AAI9D;;;;;;;GAOG;AACH,SAAgB,UAAU,CACtB,MAAoC,EACpC,MAA4B,EAC5B,OAAmC,EACnC,OAA0B;;IAE1B,IAAM,cAAc,GAChB,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,mCAAI,IAAA,iCAAe,EAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC;IAE1E,IAAA,KACF,OAAO,IAAI,EAAE,EADT,8BAA8B,oCAAA,EAAE,WAAW,iBAAA,EAAE,uBAAuB,6BAAA,EAAE,UAAU,gBACvE,CAAC;IAElB,IAAI,uBAAuB,IAAI,cAAc,IAAI,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,0CA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CAAC;KACjC;IAED,IAAI,MAAM,KAAK,CAAC,EAAE;QACd,OAAO,aAAa,CAAC;KACxB;IAED,IAAI,cAAc,GAAG,aAAa,CAAC;IACnC,IAAI,kBAAkB,GAAG,MAAM,CAAC;IAEhC,OAAO,kBAAkB,GAAG,CAAC,EAAE;QAC3B,cAAc,EAAE,CAAC;QAEjB,IAAI,cAAc,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE;YACpC,kBAAkB,EAAE,CAAC;SACxB;aAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE;YAC5C,kBAAkB,EAAE,CAAC;SACxB;KACJ;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC;AAED,SAAS,iBAAiB,CACtB,KAAgC,EAChC,aAAqB,EACrB,MAAc,EACd,QAAgB;;IAEhB,IAAI,MAAM,KAAK,CAAC,EAAE;QACd,OAAO,aAAa,CAAC;KACxB;IAED,IAAI,cAAc,GAAG,aAAa,CAAC;IACnC,IAAI,iBAAiB,GAAG,MAAM,CAAC;IAE/B,OAAO,iBAAiB,GAAG,CAAC,EAAE;QAC1B,cAAc,EAAE,CAAC;QAEjB,IAAI,cAAc,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;YACrC,iBAAiB,EAAE,CAAC;SACvB;aAAM,IAAI,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,CAAA,EAAE;YAChE,iBAAiB,EAAE,CAAC;SACvB;KACJ;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC","sourcesContent":["import { addBlock } from '../common/addBlock';\nimport { addSegment } from '../common/addSegment';\nimport { applyTableFormat } from './applyTableFormat';\nimport { createBr } from '../creators/createBr';\nimport { createListItem } from '../creators/createListItem';\nimport { createParagraph } from '../creators/createParagraph';\nimport { createSelectionMarker } from '../creators/createSelectionMarker';\nimport { createTableCell } from '../creators/createTableCell';\nimport { deleteSelection } from './deleteSelection';\nimport { EmptySegmentFormat } from '../../constants/EmptySegmentFormat';\nimport { getClosestAncestorBlockGroupIndex } from './getClosestAncestorBlockGroupIndex';\nimport { getObjectKeys } from '../..//domUtils/getObjectKeys';\nimport { mutateBlock } from '../common/mutate';\nimport { normalizeContentModel } from '../common/normalizeContentModel';\nimport { normalizeTable } from './normalizeTable';\nimport type {\n ContentModelBlock,\n ContentModelBlockFormat,\n ContentModelDocument,\n ContentModelHyperLinkFormat,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n ContentModelTable,\n FormatContentModelContext,\n InsertPoint,\n MergeModelOption,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelTable,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst HeadingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\nconst KeysOfSegmentFormat = getObjectKeys(EmptySegmentFormat);\n\ntype MergeFormatTypes = 'mergeAll' | 'keepSourceEmphasisFormat' | 'preferSource' | 'preferTarget';\n\n/**\n * Merge source model into target mode\n * @param target Target Content Model that will merge content into\n * @param source Source Content Model will be merged to target model\n * @param context Format context. When call this function inside formatContentModel, provide this context so that formatContentModel will do extra handling to the result\n * @param options More options, see MergeModelOption\n * @returns Insert point after merge, or null if there is no insert point\n */\nexport function mergeModel(\n target: ReadonlyContentModelDocument,\n source: ContentModelDocument,\n context?: FormatContentModelContext,\n options?: MergeModelOption\n): InsertPoint | null {\n const insertPosition =\n options?.insertPosition ?? deleteSelection(target, [], context).insertPoint;\n\n const { addParagraphAfterMergedContent, mergeFormat, mergeParagraphAfterList, mergeTable } =\n options || {};\n\n if (mergeParagraphAfterList && insertPosition && source.blocks[0]?.blockType == 'Paragraph') {\n moveParagraphAfterListIntoList(insertPosition);\n }\n\n if (addParagraphAfterMergedContent && !mergeTable) {\n const { paragraph, marker } = insertPosition || {};\n const newPara = createParagraph(false /* isImplicit */, paragraph?.format, marker?.format);\n addBlock(source, newPara);\n }\n\n if (insertPosition) {\n if (mergeFormat && mergeFormat != 'none') {\n const newFormat: ContentModelSegmentFormat = {\n ...(target.format || {}),\n ...insertPosition.marker.format,\n };\n\n applyDefaultFormat(source, newFormat, mergeFormat);\n }\n\n for (let i = 0; i < source.blocks.length; i++) {\n const block = source.blocks[i];\n\n switch (block.blockType) {\n case 'Paragraph':\n mergeParagraph(insertPosition, block, i == 0, context, options);\n break;\n\n case 'Divider':\n insertBlock(insertPosition, block);\n break;\n\n case 'Entity':\n insertBlock(insertPosition, block);\n context?.newEntities.push(block);\n break;\n\n case 'Table':\n if (source.blocks.length == 1 && mergeTable) {\n mergeTables(insertPosition, block, source);\n } else {\n insertBlock(insertPosition, block);\n }\n break;\n\n case 'BlockGroup':\n switch (block.blockGroupType) {\n case 'General':\n case 'FormatContainer':\n insertBlock(insertPosition, block);\n break;\n case 'ListItem':\n mergeList(insertPosition, block);\n break;\n }\n break;\n }\n }\n }\n\n normalizeContentModel(target);\n\n return insertPosition;\n}\n\nfunction moveParagraphAfterListIntoList(insertPosition: InsertPoint) {\n const { paragraph, path } = insertPosition;\n const parent = path[0];\n const paragraphIndex = parent.blocks.indexOf(paragraph);\n const previousBlock = parent.blocks[paragraphIndex - 1];\n\n if (\n paragraph.segments.every(\n segment => segment.segmentType == 'SelectionMarker' || segment.segmentType == 'Br'\n ) &&\n previousBlock?.blockType == 'BlockGroup' &&\n previousBlock.blockGroupType == 'ListItem'\n ) {\n const newListItem = createListItem(previousBlock.levels, previousBlock.formatHolder.format);\n const paragraphAfterList = createParagraph(false, paragraph.format);\n\n addBlock(newListItem, paragraph);\n paragraphAfterList.segments.push(createBr());\n mutateBlock(parent).blocks.splice(paragraphIndex, 1, newListItem, paragraphAfterList);\n path.unshift(newListItem);\n }\n}\n\nfunction mergeParagraph(\n markerPosition: InsertPoint,\n newPara: ContentModelParagraph,\n mergeToCurrentParagraph: boolean,\n context?: FormatContentModelContext,\n option?: MergeModelOption\n) {\n const { paragraph, marker } = markerPosition;\n const newParagraph = mergeToCurrentParagraph\n ? paragraph\n : splitParagraph(markerPosition, newPara.format);\n const segmentIndex = newParagraph.segments.indexOf(marker);\n\n if (option?.mergeFormat == 'none' && mergeToCurrentParagraph) {\n newParagraph.segments.forEach(segment => {\n segment.format = { ...(newParagraph.segmentFormat || {}), ...segment.format };\n });\n delete newParagraph.segmentFormat;\n }\n if (segmentIndex >= 0) {\n for (let i = 0; i < newPara.segments.length; i++) {\n const segment = newPara.segments[i];\n\n newParagraph.segments.splice(segmentIndex + i, 0, segment);\n\n if (context) {\n if (segment.segmentType == 'Entity') {\n context.newEntities.push(segment);\n }\n\n if (segment.segmentType == 'Image') {\n context.newImages.push(segment);\n }\n }\n }\n }\n\n if (newPara.decorator) {\n newParagraph.decorator = { ...newPara.decorator };\n if (HeadingTags.indexOf(newParagraph.decorator.tagName) > -1) {\n const sourceKeys: (keyof ContentModelSegmentFormat)[] = getObjectKeys(\n newParagraph.decorator.format\n );\n const segmentDecoratorKeys: (keyof ContentModelSegmentFormat)[] = getObjectKeys(\n newParagraph.segmentFormat || {}\n );\n\n sourceKeys.forEach(key => {\n if (segmentDecoratorKeys.indexOf(key) > -1) {\n delete newParagraph.segmentFormat?.[key];\n }\n });\n }\n }\n\n if (!mergeToCurrentParagraph) {\n newParagraph.format = newPara.format;\n } else {\n newParagraph.format = {\n ...newParagraph.format,\n ...newPara.format,\n };\n }\n}\n\nfunction mergeTables(\n markerPosition: InsertPoint,\n newTable: ContentModelTable,\n source: ContentModelDocument\n) {\n const { tableContext, marker } = markerPosition;\n\n if (tableContext && source.blocks.length == 1 && source.blocks[0] == newTable) {\n const { table: readonlyTable, colIndex, rowIndex } = tableContext;\n const table = mutateBlock(readonlyTable);\n\n const newTableColCount = newTable.rows[0]?.cells.length || 0;\n const newTableRowCount = newTable.rows.length;\n\n const lastTargetColIndex = getTargetColIndex(table, rowIndex, colIndex, newTableColCount);\n const extraColsNeeded = lastTargetColIndex - table.rows[0].cells.length;\n\n newTable.rows.forEach(row => {\n row.cells.forEach(cell => {\n cell.spanAbove = false;\n });\n });\n\n if (extraColsNeeded > 0) {\n const currentColCount = table.rows[0].cells.length;\n for (let col = 0; col < extraColsNeeded; col++) {\n const newColIndex = currentColCount + col;\n for (let k = 0; k < table.rows.length; k++) {\n const leftCell = table.rows[k]?.cells[newColIndex - 1];\n table.rows[k].cells[newColIndex] = createTableCell(\n false /*spanLeft*/,\n leftCell?.spanAbove,\n leftCell?.isHeader,\n leftCell?.format\n );\n }\n }\n }\n\n const lastTargetRowIndex = getTargetRowIndex(table, rowIndex, newTableRowCount, colIndex);\n const extraRowsNeeded = lastTargetRowIndex - table.rows.length;\n\n if (extraRowsNeeded > 0) {\n const currentRowCount = table.rows.length;\n const colCount = table.rows[0]?.cells.length || 0;\n for (let row = 0; row < extraRowsNeeded; row++) {\n const newRowIndex = currentRowCount + row;\n table.rows[newRowIndex] = {\n cells: [],\n format: {},\n height: 0,\n };\n for (let k = 0; k < colCount; k++) {\n const aboveCell = table.rows[newRowIndex - 1]?.cells[k];\n table.rows[newRowIndex].cells[k] = createTableCell(\n aboveCell?.spanLeft,\n false /*spanAbove*/,\n false /*isHeader*/,\n aboveCell?.format\n );\n }\n }\n }\n\n const logicalRowOffsets: number[] = [];\n let logicalRowCount = 0;\n for (let i = 0; i < newTableRowCount; i++) {\n logicalRowOffsets[i] = logicalRowCount;\n const row = newTable.rows[i];\n if (row && row.cells.some(cell => !cell.spanAbove)) {\n logicalRowCount++;\n }\n }\n\n for (let i = 0; i < newTable.rows.length; i++) {\n const sourceRow = newTable.rows[i];\n const targetRowIndex = getTargetRowIndex(\n table,\n rowIndex,\n logicalRowOffsets[i],\n colIndex\n );\n\n const logicalColOffsets: number[] = [];\n let logicalColCount = 0;\n for (let j = 0; j < sourceRow.cells.length; j++) {\n logicalColOffsets[j] = logicalColCount;\n if (!sourceRow.cells[j]?.spanLeft) {\n logicalColCount++;\n }\n }\n\n for (let j = 0; j < newTable.rows[i].cells.length; j++) {\n const newCell = sourceRow.cells[j];\n\n const targetColIndex = getTargetColIndex(\n table,\n targetRowIndex,\n colIndex,\n logicalColOffsets[j]\n );\n\n const oldCell = table.rows[targetRowIndex]?.cells[targetColIndex];\n\n table.rows[targetRowIndex].cells[targetColIndex] = newCell;\n\n if (i == 0 && j == 0) {\n const newMarker = createSelectionMarker(marker.format);\n const newPara = addSegment(newCell, newMarker);\n\n if (markerPosition.path[0] == oldCell) {\n // Update insert point to match the change result\n markerPosition.path[0] = newCell;\n markerPosition.marker = newMarker;\n markerPosition.paragraph = newPara;\n }\n }\n }\n }\n\n normalizeTable(table, markerPosition.marker.format);\n applyTableFormat(table, undefined /*newFormat*/, true /*keepCellShade*/);\n } else if (!mergeTableAfterPreviousTable(markerPosition, newTable)) {\n insertBlock(markerPosition, newTable);\n }\n}\n\nfunction mergeTableAfterPreviousTable(\n markerPosition: InsertPoint,\n newTable: ContentModelTable\n): boolean {\n const { marker, paragraph, path } = markerPosition;\n const parent = path[0];\n const paragraphIndex = parent.blocks.indexOf(paragraph);\n const previousBlock = parent.blocks[paragraphIndex - 1];\n\n if (\n paragraphIndex > 0 &&\n paragraph.segments.indexOf(marker) == 0 &&\n previousBlock?.blockType == 'Table' &&\n previousBlock.rows[0]?.cells.length > 0 &&\n newTable.rows[0]?.cells.length > 0\n ) {\n const table = mutateBlock(previousBlock);\n const columnCount = Math.max(\n ...table.rows.map(row => row.cells.length),\n ...newTable.rows.map(row => row.cells.length)\n );\n\n extendTableRows(table, columnCount);\n extendTableRows(newTable, columnCount);\n\n table.rows.push(...newTable.rows);\n\n return true;\n }\n\n return false;\n}\n\nfunction extendTableRows(table: ShallowMutableContentModelTable, columnCount: number) {\n table.rows.forEach(row => {\n const currentColumnCount = row.cells.length;\n const lastCell = row.cells[currentColumnCount - 1];\n\n if (lastCell) {\n for (let col = currentColumnCount; col < columnCount; col++) {\n const spanCell = createTableCell(\n true /* spanLeft */,\n false /* spanAbove */,\n lastCell.isHeader,\n lastCell.format,\n lastCell.dataset\n );\n\n row.cells.push(spanCell);\n }\n }\n });\n}\n\nfunction mergeList(markerPosition: InsertPoint, newList: ContentModelListItem) {\n splitParagraph(markerPosition, newList.format);\n\n const { path, paragraph } = markerPosition;\n\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell']);\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listParent = path[listItemIndex + 1]; // It is ok here when index is -1, that means there is no list and we just insert a new paragraph and use path[0] as its parent\n const blockIndex = listParent.blocks.indexOf(listItem || paragraph);\n\n if (blockIndex >= 0) {\n mutateBlock(listParent).blocks.splice(blockIndex, 0, newList);\n }\n\n if (listItem) {\n listItem?.levels.forEach((level, i) => {\n newList.levels[i] = { ...level };\n });\n }\n}\n\nfunction splitParagraph(markerPosition: InsertPoint, newParaFormat: ContentModelBlockFormat) {\n const { paragraph, marker, path } = markerPosition;\n const segmentIndex = paragraph.segments.indexOf(marker);\n const paraIndex = path[0].blocks.indexOf(paragraph);\n const newParagraph: ShallowMutableContentModelParagraph = createParagraph(\n false /*isImplicit*/,\n { ...paragraph.format, ...newParaFormat },\n paragraph.segmentFormat\n );\n\n if (segmentIndex >= 0) {\n newParagraph.segments = paragraph.segments.splice(segmentIndex);\n }\n\n if (paraIndex >= 0) {\n mutateBlock(path[0]).blocks.splice(paraIndex + 1, 0, newParagraph);\n }\n\n const listItemIndex = getClosestAncestorBlockGroupIndex(\n path,\n ['ListItem'],\n ['FormatContainer', 'TableCell']\n );\n const listItem = path[listItemIndex] as ContentModelListItem;\n\n if (listItem) {\n const listParent = listItemIndex >= 0 ? path[listItemIndex + 1] : null;\n const blockIndex = listParent ? listParent.blocks.indexOf(listItem) : -1;\n\n if (blockIndex >= 0 && listParent) {\n const newListItem = createListItem(listItem.levels, listItem.formatHolder.format);\n\n if (paraIndex >= 0) {\n newListItem.blocks = listItem.blocks.splice(paraIndex + 1);\n }\n\n if (blockIndex >= 0) {\n mutateBlock(listParent).blocks.splice(blockIndex + 1, 0, newListItem);\n }\n\n path[listItemIndex] = newListItem;\n }\n }\n\n markerPosition.paragraph = newParagraph;\n\n return newParagraph;\n}\n\nfunction insertBlock(markerPosition: InsertPoint, block: ContentModelBlock) {\n const { path } = markerPosition;\n const newParaFormat = block.blockType !== 'Paragraph' ? {} : block.format;\n const newPara = splitParagraph(markerPosition, newParaFormat);\n const blockIndex = path[0].blocks.indexOf(newPara);\n\n if (blockIndex >= 0) {\n mutateBlock(path[0]).blocks.splice(blockIndex, 0, block);\n }\n}\n\nfunction applyDefaultFormat(\n group: ReadonlyContentModelBlockGroup,\n format: ContentModelSegmentFormat,\n applyDefaultFormatOption: MergeFormatTypes\n) {\n group.blocks.forEach(block => {\n mergeBlockFormat(applyDefaultFormatOption, block);\n\n switch (block.blockType) {\n case 'BlockGroup':\n if (block.blockGroupType == 'ListItem') {\n mutateBlock(block).formatHolder.format = mergeSegmentFormat(\n applyDefaultFormatOption,\n format,\n block.formatHolder.format\n );\n }\n applyDefaultFormat(block, format, applyDefaultFormatOption);\n break;\n\n case 'Table':\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n applyDefaultFormat(cell, format, applyDefaultFormatOption);\n })\n );\n break;\n\n case 'Paragraph':\n const paragraphFormat = block.decorator?.format || {};\n const paragraph = mutateBlock(block);\n\n paragraph.segments.forEach(segment => {\n if (segment.segmentType == 'General') {\n applyDefaultFormat(segment, format, applyDefaultFormatOption);\n }\n\n segment.format = mergeSegmentFormat(applyDefaultFormatOption, format, {\n ...paragraphFormat,\n ...segment.format,\n });\n\n if (segment.link) {\n segment.link.format = mergeLinkFormat(\n applyDefaultFormatOption,\n format,\n segment.link.format\n );\n }\n });\n\n if (applyDefaultFormatOption === 'keepSourceEmphasisFormat') {\n delete paragraph.decorator;\n }\n break;\n }\n });\n}\n\nfunction mergeBlockFormat(applyDefaultFormatOption: string, block: ReadonlyContentModelBlock) {\n if (applyDefaultFormatOption == 'keepSourceEmphasisFormat' && block.format.backgroundColor) {\n delete mutateBlock(block).format.backgroundColor;\n }\n}\n\n/**\n * Hyperlink format type definition only contains backgroundColor and underline.\n * So create a minimum object with the styles supported in Hyperlink to be used in merge.\n */\nfunction getSegmentFormatInLinkFormat(\n targetFormat: ContentModelSegmentFormat\n): ContentModelSegmentFormat {\n const result: ContentModelHyperLinkFormat = {};\n if (targetFormat.backgroundColor) {\n result.backgroundColor = targetFormat.backgroundColor;\n }\n if (targetFormat.underline) {\n result.underline = targetFormat.underline;\n }\n\n return result;\n}\n\nfunction mergeLinkFormat(\n applyDefaultFormatOption: MergeFormatTypes,\n targetFormat: ContentModelSegmentFormat,\n sourceFormat: ContentModelHyperLinkFormat\n) {\n switch (applyDefaultFormatOption) {\n case 'mergeAll':\n case 'preferSource':\n return { ...getSegmentFormatInLinkFormat(targetFormat), ...sourceFormat };\n case 'keepSourceEmphasisFormat':\n return {\n // Hyperlink segment format contains other attributes such as LinkFormat\n // so we have to retain them\n ...getFormatWithoutSegmentFormat(sourceFormat),\n // Link format only have Text color, background color, Underline, but only\n // text color + background color should be merged from the target\n ...getSegmentFormatInLinkFormat(targetFormat),\n // Get the semantic format of the source\n ...getSemanticFormat(sourceFormat),\n // The text color of the hyperlink should not be merged and\n // we should always retain the source text color\n ...getHyperlinkTextColor(sourceFormat),\n };\n case 'preferTarget':\n return { ...sourceFormat, ...getSegmentFormatInLinkFormat(targetFormat) };\n }\n}\n\nfunction mergeSegmentFormat(\n applyDefaultFormatOption: MergeFormatTypes,\n targetFormat: ContentModelSegmentFormat,\n sourceFormat: ContentModelSegmentFormat\n): ContentModelSegmentFormat {\n switch (applyDefaultFormatOption) {\n case 'mergeAll':\n case 'preferSource':\n return { ...targetFormat, ...sourceFormat };\n case 'preferTarget':\n return { ...sourceFormat, ...targetFormat };\n case 'keepSourceEmphasisFormat':\n return {\n ...getFormatWithoutSegmentFormat(sourceFormat),\n ...targetFormat,\n ...getSemanticFormat(sourceFormat),\n };\n }\n}\n\nfunction getSemanticFormat(segmentFormat: ContentModelSegmentFormat): ContentModelSegmentFormat {\n const result: ContentModelSegmentFormat = {};\n\n const { fontWeight, italic, underline } = segmentFormat;\n\n if (fontWeight && fontWeight != 'normal') {\n result.fontWeight = fontWeight;\n }\n if (italic) {\n result.italic = italic;\n }\n if (underline) {\n result.underline = underline;\n }\n\n return result;\n}\n\n/**\n * Segment format can also contain other type of metadata, for example in Images/Hyperlink,\n * we want to preserve these properties when merging format\n */\nfunction getFormatWithoutSegmentFormat(\n sourceFormat: ContentModelSegmentFormat\n): ContentModelSegmentFormat {\n const resultFormat = {\n ...sourceFormat,\n };\n KeysOfSegmentFormat.forEach(key => delete resultFormat[key]);\n return resultFormat;\n}\n\nfunction getHyperlinkTextColor(sourceFormat: ContentModelHyperLinkFormat) {\n const result: ContentModelHyperLinkFormat = {};\n if (sourceFormat.textColor) {\n result.textColor = sourceFormat.textColor;\n }\n\n return result;\n}\n\nfunction getTargetColIndex(\n table: ReadonlyContentModelTable,\n rowIndex: number,\n startColIndex: number,\n offset: number\n): number {\n const row = table.rows[rowIndex];\n if (!row) {\n return startColIndex + offset;\n }\n\n if (offset === 0) {\n return startColIndex;\n }\n\n let targetColIndex = startColIndex;\n let logicalCellsToSkip = offset;\n\n while (logicalCellsToSkip > 0) {\n targetColIndex++;\n\n if (targetColIndex >= row.cells.length) {\n logicalCellsToSkip--;\n } else if (!row.cells[targetColIndex].spanLeft) {\n logicalCellsToSkip--;\n }\n }\n\n return targetColIndex;\n}\n\nfunction getTargetRowIndex(\n table: ReadonlyContentModelTable,\n startRowIndex: number,\n offset: number,\n colIndex: number\n): number {\n if (offset === 0) {\n return startRowIndex;\n }\n\n let targetRowIndex = startRowIndex;\n let logicalRowsToSkip = offset;\n\n while (logicalRowsToSkip > 0) {\n targetRowIndex++;\n\n if (targetRowIndex >= table.rows.length) {\n logicalRowsToSkip--;\n } else if (!table.rows[targetRowIndex]?.cells[colIndex]?.spanAbove) {\n logicalRowsToSkip--;\n }\n }\n\n return targetRowIndex;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mergeModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/mergeModel.ts"],"names":[],"mappings":";;;;AAAA,+CAA8C;AAC9C,mDAAkD;AAClD,uDAAsD;AACtD,iDAAgD;AAChD,6DAA4D;AAC5D,+DAA8D;AAC9D,2EAA0E;AAC1E,+DAA8D;AAC9D,qDAAoD;AACpD,yEAAwE;AACxE,yFAAwF;AACxF,+DAA8D;AAC9D,2CAA+C;AAC/C,yEAAwE;AACxE,mDAAkD;AAqBlD,IAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzD,IAAM,mBAAmB,GAAG,IAAA,6BAAa,EAAC,uCAAkB,CAAC,CAAC;AAI9D;;;;;;;GAOG;AACH,SAAgB,UAAU,CACtB,MAAoC,EACpC,MAA4B,EAC5B,OAAmC,EACnC,OAA0B;;IAE1B,IAAM,cAAc,GAChB,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,mCAAI,IAAA,iCAAe,EAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC;IAE1E,IAAA,KACF,OAAO,IAAI,EAAE,EADT,8BAA8B,oCAAA,EAAE,WAAW,iBAAA,EAAE,uBAAuB,6BAAA,EAAE,UAAU,gBACvE,CAAC;IAElB,IAAI,uBAAuB,IAAI,cAAc,IAAI,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,0CAAE,SAAS,KAAI,WAAW,EAAE;QACzF,8BAA8B,CAAC,cAAc,CAAC,CAAC;KAClD;IAED,IAAI,8BAA8B,IAAI,CAAC,UAAU,EAAE;QACzC,IAAA,KAAwB,cAAc,IAAI,EAAE,EAA1C,SAAS,eAAA,EAAE,MAAM,YA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A,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,CAAA,EAAE;YAChE,iBAAiB,EAAE,CAAC;SACvB;KACJ;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC","sourcesContent":["import { addBlock } from '../common/addBlock';\nimport { addSegment } from '../common/addSegment';\nimport { applyTableFormat } from './applyTableFormat';\nimport { createBr } from '../creators/createBr';\nimport { createListItem } from '../creators/createListItem';\nimport { createParagraph } from '../creators/createParagraph';\nimport { createSelectionMarker } from '../creators/createSelectionMarker';\nimport { createTableCell } from '../creators/createTableCell';\nimport { deleteSelection } from './deleteSelection';\nimport { EmptySegmentFormat } from '../../constants/EmptySegmentFormat';\nimport { getClosestAncestorBlockGroupIndex } from './getClosestAncestorBlockGroupIndex';\nimport { getObjectKeys } from '../..//domUtils/getObjectKeys';\nimport { mutateBlock } from '../common/mutate';\nimport { normalizeContentModel } from '../common/normalizeContentModel';\nimport { normalizeTable } from './normalizeTable';\nimport type {\n ContentModelBlock,\n ContentModelBlockFormat,\n ContentModelDocument,\n ContentModelHyperLinkFormat,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegmentFormat,\n ContentModelTable,\n FormatContentModelContext,\n InsertPoint,\n MergeModelOption,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelTable,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst HeadingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\nconst KeysOfSegmentFormat = getObjectKeys(EmptySegmentFormat);\n\ntype MergeFormatTypes = 'mergeAll' | 'keepSourceEmphasisFormat' | 'preferSource' | 'preferTarget';\n\n/**\n * Merge source model into target mode\n * @param target Target Content Model that will merge content into\n * @param source Source Content Model will be merged to target model\n * @param context Format context. When call this function inside formatContentModel, provide this context so that formatContentModel will do extra handling to the result\n * @param options More options, see MergeModelOption\n * @returns Insert point after merge, or null if there is no insert point\n */\nexport function mergeModel(\n target: ReadonlyContentModelDocument,\n source: ContentModelDocument,\n context?: FormatContentModelContext,\n options?: MergeModelOption\n): InsertPoint | null {\n const insertPosition =\n options?.insertPosition ?? deleteSelection(target, [], context).insertPoint;\n\n const { addParagraphAfterMergedContent, mergeFormat, mergeParagraphAfterList, mergeTable } =\n options || {};\n\n if (mergeParagraphAfterList && insertPosition && source.blocks[0]?.blockType == 'Paragraph') {\n moveParagraphAfterListIntoList(insertPosition);\n }\n\n if (addParagraphAfterMergedContent && !mergeTable) {\n const { paragraph, marker } = insertPosition || {};\n const newPara = createParagraph(false /* isImplicit */, paragraph?.format, marker?.format);\n addBlock(source, newPara);\n }\n\n if (insertPosition) {\n if (mergeFormat && mergeFormat != 'none') {\n const newFormat: ContentModelSegmentFormat = {\n ...(target.format || {}),\n ...(options?.preserveParagraphDecorator\n ? {\n ...insertPosition.paragraph.decorator?.format,\n ...insertPosition.paragraph.segmentFormat,\n }\n : undefined),\n ...insertPosition.marker.format,\n };\n\n applyDefaultFormat(source, newFormat, mergeFormat, options?.preserveParagraphDecorator);\n }\n\n for (let i = 0; i < source.blocks.length; i++) {\n const block = source.blocks[i];\n\n switch (block.blockType) {\n case 'Paragraph':\n mergeParagraph(insertPosition, block, i == 0, context, options);\n break;\n\n case 'Divider':\n insertBlock(insertPosition, block);\n break;\n\n case 'Entity':\n insertBlock(insertPosition, block);\n context?.newEntities.push(block);\n break;\n\n case 'Table':\n if (source.blocks.length == 1 && mergeTable) {\n mergeTables(insertPosition, block, source);\n } else {\n insertBlock(insertPosition, block);\n }\n break;\n\n case 'BlockGroup':\n switch (block.blockGroupType) {\n case 'General':\n case 'FormatContainer':\n insertBlock(insertPosition, block);\n break;\n case 'ListItem':\n mergeList(insertPosition, block);\n break;\n }\n break;\n }\n }\n }\n\n normalizeContentModel(target);\n\n return insertPosition;\n}\n\nfunction moveParagraphAfterListIntoList(insertPosition: InsertPoint) {\n const { paragraph, path } = insertPosition;\n const parent = path[0];\n const paragraphIndex = parent.blocks.indexOf(paragraph);\n const previousBlock = parent.blocks[paragraphIndex - 1];\n\n if (\n paragraph.segments.every(\n segment => segment.segmentType == 'SelectionMarker' || segment.segmentType == 'Br'\n ) &&\n previousBlock?.blockType == 'BlockGroup' &&\n previousBlock.blockGroupType == 'ListItem'\n ) {\n const newListItem = createListItem(previousBlock.levels, previousBlock.formatHolder.format);\n const paragraphAfterList = createParagraph(false, paragraph.format);\n\n addBlock(newListItem, paragraph);\n paragraphAfterList.segments.push(createBr());\n mutateBlock(parent).blocks.splice(paragraphIndex, 1, newListItem, paragraphAfterList);\n path.unshift(newListItem);\n }\n}\n\nfunction mergeParagraph(\n markerPosition: InsertPoint,\n newPara: ContentModelParagraph,\n mergeToCurrentParagraph: boolean,\n context?: FormatContentModelContext,\n option?: MergeModelOption\n) {\n const { paragraph, marker } = markerPosition;\n const newParagraph = mergeToCurrentParagraph\n ? paragraph\n : splitParagraph(markerPosition, newPara.format);\n const segmentIndex = newParagraph.segments.indexOf(marker);\n\n if (option?.mergeFormat == 'none' && mergeToCurrentParagraph) {\n newParagraph.segments.forEach(segment => {\n segment.format = { ...(newParagraph.segmentFormat || {}), ...segment.format };\n });\n delete newParagraph.segmentFormat;\n }\n if (segmentIndex >= 0) {\n for (let i = 0; i < newPara.segments.length; i++) {\n const segment = newPara.segments[i];\n\n newParagraph.segments.splice(segmentIndex + i, 0, segment);\n\n if (context) {\n if (segment.segmentType == 'Entity') {\n context.newEntities.push(segment);\n }\n\n if (segment.segmentType == 'Image') {\n context.newImages.push(segment);\n }\n }\n }\n }\n\n if (newPara.decorator) {\n newParagraph.decorator = { ...newPara.decorator };\n if (HeadingTags.indexOf(newParagraph.decorator.tagName) > -1) {\n const sourceKeys: (keyof ContentModelSegmentFormat)[] = getObjectKeys(\n newParagraph.decorator.format\n );\n const segmentDecoratorKeys: (keyof ContentModelSegmentFormat)[] = getObjectKeys(\n newParagraph.segmentFormat || {}\n );\n\n sourceKeys.forEach(key => {\n if (segmentDecoratorKeys.indexOf(key) > -1) {\n delete newParagraph.segmentFormat?.[key];\n }\n });\n }\n }\n\n if (!mergeToCurrentParagraph) {\n newParagraph.format = newPara.format;\n } else {\n newParagraph.format = {\n ...newParagraph.format,\n ...newPara.format,\n };\n }\n}\n\nfunction mergeTables(\n markerPosition: InsertPoint,\n newTable: ContentModelTable,\n source: ContentModelDocument\n) {\n const { tableContext, marker } = markerPosition;\n\n if (tableContext && source.blocks.length == 1 && source.blocks[0] == newTable) {\n const { table: readonlyTable, colIndex, rowIndex } = tableContext;\n const table = mutateBlock(readonlyTable);\n\n const newTableColCount = newTable.rows[0]?.cells.length || 0;\n const newTableRowCount = newTable.rows.length;\n\n const lastTargetColIndex = getTargetColIndex(table, rowIndex, colIndex, newTableColCount);\n const extraColsNeeded = lastTargetColIndex - table.rows[0].cells.length;\n\n newTable.rows.forEach(row => {\n row.cells.forEach(cell => {\n cell.spanAbove = false;\n });\n });\n\n if (extraColsNeeded > 0) {\n const currentColCount = table.rows[0].cells.length;\n for (let col = 0; col < extraColsNeeded; col++) {\n const newColIndex = currentColCount + col;\n for (let k = 0; k < table.rows.length; k++) {\n const leftCell = table.rows[k]?.cells[newColIndex - 1];\n table.rows[k].cells[newColIndex] = createTableCell(\n false /*spanLeft*/,\n leftCell?.spanAbove,\n leftCell?.isHeader,\n leftCell?.format\n );\n }\n }\n }\n\n const lastTargetRowIndex = getTargetRowIndex(table, rowIndex, newTableRowCount, colIndex);\n const extraRowsNeeded = lastTargetRowIndex - table.rows.length;\n\n if (extraRowsNeeded > 0) {\n const currentRowCount = table.rows.length;\n const colCount = table.rows[0]?.cells.length || 0;\n for (let row = 0; row < extraRowsNeeded; row++) {\n const newRowIndex = currentRowCount + row;\n table.rows[newRowIndex] = {\n cells: [],\n format: {},\n height: 0,\n };\n for (let k = 0; k < colCount; k++) {\n const aboveCell = table.rows[newRowIndex - 1]?.cells[k];\n table.rows[newRowIndex].cells[k] = createTableCell(\n aboveCell?.spanLeft,\n false /*spanAbove*/,\n false /*isHeader*/,\n aboveCell?.format\n );\n }\n }\n }\n\n const logicalRowOffsets: number[] = [];\n let logicalRowCount = 0;\n for (let i = 0; i < newTableRowCount; i++) {\n logicalRowOffsets[i] = logicalRowCount;\n const row = newTable.rows[i];\n if (row && row.cells.some(cell => !cell.spanAbove)) {\n logicalRowCount++;\n }\n }\n\n for (let i = 0; i < newTable.rows.length; i++) {\n const sourceRow = newTable.rows[i];\n const targetRowIndex = getTargetRowIndex(\n table,\n rowIndex,\n logicalRowOffsets[i],\n colIndex\n );\n\n const logicalColOffsets: number[] = [];\n let logicalColCount = 0;\n for (let j = 0; j < sourceRow.cells.length; j++) {\n logicalColOffsets[j] = logicalColCount;\n if (!sourceRow.cells[j]?.spanLeft) {\n logicalColCount++;\n }\n }\n\n for (let j = 0; j < newTable.rows[i].cells.length; j++) {\n const newCell = sourceRow.cells[j];\n\n const targetColIndex = getTargetColIndex(\n table,\n targetRowIndex,\n colIndex,\n logicalColOffsets[j]\n );\n\n const oldCell = table.rows[targetRowIndex]?.cells[targetColIndex];\n\n table.rows[targetRowIndex].cells[targetColIndex] = newCell;\n\n if (i == 0 && j == 0) {\n const newMarker = createSelectionMarker(marker.format);\n const newPara = addSegment(newCell, newMarker);\n\n if (markerPosition.path[0] == oldCell) {\n // Update insert point to match the change result\n markerPosition.path[0] = newCell;\n markerPosition.marker = newMarker;\n markerPosition.paragraph = newPara;\n }\n }\n }\n }\n\n normalizeTable(table, markerPosition.marker.format);\n applyTableFormat(table, undefined /*newFormat*/, true /*keepCellShade*/);\n } else if (!mergeTableAfterPreviousTable(markerPosition, newTable)) {\n insertBlock(markerPosition, newTable);\n }\n}\n\nfunction mergeTableAfterPreviousTable(\n markerPosition: InsertPoint,\n newTable: ContentModelTable\n): boolean {\n const { marker, paragraph, path } = markerPosition;\n const parent = path[0];\n const paragraphIndex = parent.blocks.indexOf(paragraph);\n const previousBlock = parent.blocks[paragraphIndex - 1];\n\n if (\n paragraphIndex > 0 &&\n paragraph.segments.indexOf(marker) == 0 &&\n previousBlock?.blockType == 'Table' &&\n previousBlock.rows[0]?.cells.length > 0 &&\n newTable.rows[0]?.cells.length > 0\n ) {\n const table = mutateBlock(previousBlock);\n const columnCount = Math.max(\n ...table.rows.map(row => row.cells.length),\n ...newTable.rows.map(row => row.cells.length)\n );\n\n extendTableRows(table, columnCount);\n extendTableRows(newTable, columnCount);\n\n table.rows.push(...newTable.rows);\n\n return true;\n }\n\n return false;\n}\n\nfunction extendTableRows(table: ShallowMutableContentModelTable, columnCount: number) {\n table.rows.forEach(row => {\n const currentColumnCount = row.cells.length;\n const lastCell = row.cells[currentColumnCount - 1];\n\n if (lastCell) {\n for (let col = currentColumnCount; col < columnCount; col++) {\n const spanCell = createTableCell(\n true /* spanLeft */,\n false /* spanAbove */,\n lastCell.isHeader,\n lastCell.format,\n lastCell.dataset\n );\n\n row.cells.push(spanCell);\n }\n }\n });\n}\n\nfunction mergeList(markerPosition: InsertPoint, newList: ContentModelListItem) {\n splitParagraph(markerPosition, newList.format);\n\n const { path, paragraph } = markerPosition;\n\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell']);\n const listItem = path[listItemIndex] as ContentModelListItem;\n const listParent = path[listItemIndex + 1]; // It is ok here when index is -1, that means there is no list and we just insert a new paragraph and use path[0] as its parent\n const blockIndex = listParent.blocks.indexOf(listItem || paragraph);\n\n if (blockIndex >= 0) {\n mutateBlock(listParent).blocks.splice(blockIndex, 0, newList);\n }\n\n if (listItem) {\n listItem?.levels.forEach((level, i) => {\n newList.levels[i] = { ...level };\n });\n }\n}\n\nfunction splitParagraph(markerPosition: InsertPoint, newParaFormat: ContentModelBlockFormat) {\n const { paragraph, marker, path } = markerPosition;\n const segmentIndex = paragraph.segments.indexOf(marker);\n const paraIndex = path[0].blocks.indexOf(paragraph);\n const newParagraph: ShallowMutableContentModelParagraph = createParagraph(\n false /*isImplicit*/,\n { ...paragraph.format, ...newParaFormat },\n paragraph.segmentFormat\n );\n\n if (segmentIndex >= 0) {\n newParagraph.segments = paragraph.segments.splice(segmentIndex);\n }\n\n if (paraIndex >= 0) {\n mutateBlock(path[0]).blocks.splice(paraIndex + 1, 0, newParagraph);\n }\n\n const listItemIndex = getClosestAncestorBlockGroupIndex(\n path,\n ['ListItem'],\n ['FormatContainer', 'TableCell']\n );\n const listItem = path[listItemIndex] as ContentModelListItem;\n\n if (listItem) {\n const listParent = listItemIndex >= 0 ? path[listItemIndex + 1] : null;\n const blockIndex = listParent ? listParent.blocks.indexOf(listItem) : -1;\n\n if (blockIndex >= 0 && listParent) {\n const newListItem = createListItem(listItem.levels, listItem.formatHolder.format);\n\n if (paraIndex >= 0) {\n newListItem.blocks = listItem.blocks.splice(paraIndex + 1);\n }\n\n if (blockIndex >= 0) {\n mutateBlock(listParent).blocks.splice(blockIndex + 1, 0, newListItem);\n }\n\n path[listItemIndex] = newListItem;\n }\n }\n\n markerPosition.paragraph = newParagraph;\n\n return newParagraph;\n}\n\nfunction insertBlock(markerPosition: InsertPoint, block: ContentModelBlock) {\n const { path } = markerPosition;\n const newParaFormat = block.blockType !== 'Paragraph' ? {} : block.format;\n const newPara = splitParagraph(markerPosition, newParaFormat);\n const blockIndex = path[0].blocks.indexOf(newPara);\n\n if (blockIndex >= 0) {\n mutateBlock(path[0]).blocks.splice(blockIndex, 0, block);\n }\n}\n\nfunction applyDefaultFormat(\n group: ReadonlyContentModelBlockGroup,\n format: ContentModelSegmentFormat,\n applyDefaultFormatOption: MergeFormatTypes,\n preserveParagraphDecorator?: boolean\n) {\n group.blocks.forEach(block => {\n mergeBlockFormat(applyDefaultFormatOption, block);\n\n switch (block.blockType) {\n case 'BlockGroup':\n if (block.blockGroupType == 'ListItem') {\n mutateBlock(block).formatHolder.format = mergeSegmentFormat(\n applyDefaultFormatOption,\n format,\n block.formatHolder.format\n );\n }\n applyDefaultFormat(\n block,\n format,\n applyDefaultFormatOption,\n preserveParagraphDecorator\n );\n break;\n\n case 'Table':\n block.rows.forEach(row =>\n row.cells.forEach(cell => {\n applyDefaultFormat(\n cell,\n format,\n applyDefaultFormatOption,\n preserveParagraphDecorator\n );\n })\n );\n break;\n\n case 'Paragraph':\n const paragraphFormat = block.decorator?.format || {};\n const paragraph = mutateBlock(block);\n const paragraphTargetFormat =\n applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&\n preserveParagraphDecorator\n ? { ...format, ...paragraphFormat }\n : format;\n\n paragraph.segments.forEach(segment => {\n if (segment.segmentType == 'General') {\n applyDefaultFormat(\n segment,\n format,\n applyDefaultFormatOption,\n preserveParagraphDecorator\n );\n }\n\n segment.format = mergeSegmentFormat(\n applyDefaultFormatOption,\n paragraphTargetFormat,\n {\n ...paragraphFormat,\n ...segment.format,\n }\n );\n\n if (segment.link) {\n segment.link.format = mergeLinkFormat(\n applyDefaultFormatOption,\n format,\n segment.link.format\n );\n }\n });\n\n if (\n applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&\n !preserveParagraphDecorator\n ) {\n delete paragraph.decorator;\n }\n break;\n }\n });\n}\n\nfunction mergeBlockFormat(applyDefaultFormatOption: string, block: ReadonlyContentModelBlock) {\n if (applyDefaultFormatOption == 'keepSourceEmphasisFormat' && block.format.backgroundColor) {\n delete mutateBlock(block).format.backgroundColor;\n }\n}\n\n/**\n * Hyperlink format type definition only contains backgroundColor and underline.\n * So create a minimum object with the styles supported in Hyperlink to be used in merge.\n */\nfunction getSegmentFormatInLinkFormat(\n targetFormat: ContentModelSegmentFormat\n): ContentModelSegmentFormat {\n const result: ContentModelHyperLinkFormat = {};\n if (targetFormat.backgroundColor) {\n result.backgroundColor = targetFormat.backgroundColor;\n }\n if (targetFormat.underline) {\n result.underline = targetFormat.underline;\n }\n\n return result;\n}\n\nfunction mergeLinkFormat(\n applyDefaultFormatOption: MergeFormatTypes,\n targetFormat: ContentModelSegmentFormat,\n sourceFormat: ContentModelHyperLinkFormat\n) {\n switch (applyDefaultFormatOption) {\n case 'mergeAll':\n case 'preferSource':\n return { ...getSegmentFormatInLinkFormat(targetFormat), ...sourceFormat };\n case 'keepSourceEmphasisFormat':\n return {\n // Hyperlink segment format contains other attributes such as LinkFormat\n // so we have to retain them\n ...getFormatWithoutSegmentFormat(sourceFormat),\n // Link format only have Text color, background color, Underline, but only\n // text color + background color should be merged from the target\n ...getSegmentFormatInLinkFormat(targetFormat),\n // Get the semantic format of the source\n ...getSemanticFormat(sourceFormat),\n // The text color of the hyperlink should not be merged and\n // we should always retain the source text color\n ...getHyperlinkTextColor(sourceFormat),\n };\n case 'preferTarget':\n return { ...sourceFormat, ...getSegmentFormatInLinkFormat(targetFormat) };\n }\n}\n\nfunction mergeSegmentFormat(\n applyDefaultFormatOption: MergeFormatTypes,\n targetFormat: ContentModelSegmentFormat,\n sourceFormat: ContentModelSegmentFormat\n): ContentModelSegmentFormat {\n switch (applyDefaultFormatOption) {\n case 'mergeAll':\n case 'preferSource':\n return { ...targetFormat, ...sourceFormat };\n case 'preferTarget':\n return { ...sourceFormat, ...targetFormat };\n case 'keepSourceEmphasisFormat':\n return {\n ...getFormatWithoutSegmentFormat(sourceFormat),\n ...targetFormat,\n ...getSemanticFormat(sourceFormat),\n };\n }\n}\n\nfunction getSemanticFormat(segmentFormat: ContentModelSegmentFormat): ContentModelSegmentFormat {\n const result: ContentModelSegmentFormat = {};\n\n const { fontWeight, italic, underline, strikethrough } = segmentFormat;\n\n if (fontWeight && fontWeight != 'normal') {\n result.fontWeight = fontWeight;\n }\n if (italic) {\n result.italic = italic;\n }\n if (underline) {\n result.underline = underline;\n }\n if (strikethrough) {\n result.strikethrough = strikethrough;\n }\n\n return result;\n}\n\n/**\n * Segment format can also contain other type of metadata, for example in Images/Hyperlink,\n * we want to preserve these properties when merging format\n */\nfunction getFormatWithoutSegmentFormat(\n sourceFormat: ContentModelSegmentFormat\n): ContentModelSegmentFormat {\n const resultFormat = {\n ...sourceFormat,\n };\n KeysOfSegmentFormat.forEach(key => delete resultFormat[key]);\n return resultFormat;\n}\n\nfunction getHyperlinkTextColor(sourceFormat: ContentModelHyperLinkFormat) {\n const result: ContentModelHyperLinkFormat = {};\n if (sourceFormat.textColor) {\n result.textColor = sourceFormat.textColor;\n }\n\n return result;\n}\n\nfunction getTargetColIndex(\n table: ReadonlyContentModelTable,\n rowIndex: number,\n startColIndex: number,\n offset: number\n): number {\n const row = table.rows[rowIndex];\n if (!row) {\n return startColIndex + offset;\n }\n\n if (offset === 0) {\n return startColIndex;\n }\n\n let targetColIndex = startColIndex;\n let logicalCellsToSkip = offset;\n\n while (logicalCellsToSkip > 0) {\n targetColIndex++;\n\n if (targetColIndex >= row.cells.length) {\n logicalCellsToSkip--;\n } else if (!row.cells[targetColIndex].spanLeft) {\n logicalCellsToSkip--;\n }\n }\n\n return targetColIndex;\n}\n\nfunction getTargetRowIndex(\n table: ReadonlyContentModelTable,\n startRowIndex: number,\n offset: number,\n colIndex: number\n): number {\n if (offset === 0) {\n return startRowIndex;\n }\n\n let targetRowIndex = startRowIndex;\n let logicalRowsToSkip = offset;\n\n while (logicalRowsToSkip > 0) {\n targetRowIndex++;\n\n if (targetRowIndex >= table.rows.length) {\n logicalRowsToSkip--;\n } else if (!table.rows[targetRowIndex]?.cells[colIndex]?.spanAbove) {\n logicalRowsToSkip--;\n }\n }\n\n return targetRowIndex;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptySegmentFormat.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/EmptySegmentFormat.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACU,QAAA,kBAAkB,GAAkD;QAC7E,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","sourcesContent":["import type { ContentModelSegmentFormat } from 'roosterjs-content-model-types';\n\n/**\n * Provide a default empty instance of segment format with all its properties\n */\nexport const EmptySegmentFormat: Readonly<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"]}
|
|
1
|
+
{"version":3,"file":"EmptySegmentFormat.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/EmptySegmentFormat.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACU,QAAA,kBAAkB,GAAkD;QAC7E,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,wBAAwB,EAAE,EAAE;QAC5B,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACnB,CAAC","sourcesContent":["import type { ContentModelSegmentFormat } from 'roosterjs-content-model-types';\n\n/**\n * Provide a default empty instance of segment format with all its properties\n */\nexport const EmptySegmentFormat: Readonly<Required<ContentModelSegmentFormat>> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptFontSize: '',\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "../utils/shouldSetValue", "../../domUtils/moveChildNodes"], function (require, exports, shouldSetValue_1, moveChildNodes_1) {
|
|
1
|
+
define(["require", "exports", "../../domToModel/utils/isBlockElement", "../utils/shouldSetValue", "../../domUtils/moveChildNodes"], function (require, exports, isBlockElement_1, shouldSetValue_1, moveChildNodes_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.boldFormatHandler = void 0;
|
|
@@ -19,7 +19,7 @@ define(["require", "exports", "../utils/shouldSetValue", "../../domUtils/moveChi
|
|
|
19
19
|
var blockFontWeight = context.implicitFormat.fontWeight;
|
|
20
20
|
if ((blockFontWeight && blockFontWeight != format.fontWeight) ||
|
|
21
21
|
(!blockFontWeight && format.fontWeight && format.fontWeight != 'normal')) {
|
|
22
|
-
if (format.fontWeight == 'bold') {
|
|
22
|
+
if (format.fontWeight == 'bold' && !(0, isBlockElement_1.isBlockElement)(element)) {
|
|
23
23
|
(0, moveChildNodes_1.wrapAllChildNodes)(element, 'b');
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boldFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/boldFormatHandler.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"boldFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/boldFormatHandler.ts"],"names":[],"mappings":";;;;IAMA;;OAEG;IACU,QAAA,iBAAiB,GAA8B;QACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;YAC1C,IAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU,CAAC;YAEvE,IAAI,IAAA,+BAAc,EAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE;gBAC/E,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;aAClC;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;YAC5B,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,WAAW,EAAE;gBAC1C,OAAO;aACV;YAED,IAAM,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;YAE1D,IACI,CAAC,eAAe,IAAI,eAAe,IAAI,MAAM,CAAC,UAAU,CAAC;gBACzD,CAAC,CAAC,eAAe,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,EAC1E;gBACE,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,IAAI,CAAC,IAAA,+BAAc,EAAC,OAAO,CAAC,EAAE;oBACzD,IAAA,kCAAiB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;iBACnC;qBAAM;oBACH,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC;iBAC5D;aACJ;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { isBlockElement } from '../../domToModel/utils/isBlockElement';\nimport { shouldSetValue } from '../utils/shouldSetValue';\nimport { wrapAllChildNodes } from '../../domUtils/moveChildNodes';\nimport type { BoldFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const boldFormatHandler: FormatHandler<BoldFormat> = {\n parse: (format, element, context, defaultStyle) => {\n const fontWeight = element.style.fontWeight || defaultStyle.fontWeight;\n\n if (shouldSetValue(fontWeight, '400', format.fontWeight, defaultStyle.fontWeight)) {\n format.fontWeight = fontWeight;\n }\n },\n apply: (format, element, context) => {\n if (typeof format.fontWeight === 'undefined') {\n return;\n }\n\n const blockFontWeight = context.implicitFormat.fontWeight;\n\n if (\n (blockFontWeight && blockFontWeight != format.fontWeight) ||\n (!blockFontWeight && format.fontWeight && format.fontWeight != 'normal')\n ) {\n if (format.fontWeight == 'bold' && !isBlockElement(element)) {\n wrapAllChildNodes(element, 'b');\n } else {\n element.style.fontWeight = format.fontWeight || 'normal';\n }\n }\n },\n};\n"]}
|
|
@@ -9,12 +9,17 @@ define(["require", "exports", "../../domUtils/moveChildNodes"], function (requir
|
|
|
9
9
|
parse: function (format, element, context, defaultStyle) {
|
|
10
10
|
var verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;
|
|
11
11
|
var fontSize = element.style.fontSize || defaultStyle.fontSize;
|
|
12
|
-
|
|
12
|
+
var inheritFontSize = (element.tagName == 'SUP' || element.tagName == 'SUB') && fontSize == 'inherit';
|
|
13
|
+
if (isSuperOrSubScript(fontSize, verticalAlign) ||
|
|
14
|
+
(inheritFontSize && (verticalAlign == 'super' || verticalAlign == 'sub'))) {
|
|
13
15
|
format.superOrSubScriptSequence = (format.superOrSubScriptSequence || '')
|
|
14
16
|
.split(' ')
|
|
15
17
|
.concat(verticalAlign)
|
|
16
18
|
.join(' ')
|
|
17
19
|
.trim();
|
|
20
|
+
if (inheritFontSize) {
|
|
21
|
+
format.superOrSubScriptFontSize = 'inherit';
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
apply: function (format, element) {
|
|
@@ -25,7 +30,10 @@ define(["require", "exports", "../../domUtils/moveChildNodes"], function (requir
|
|
|
25
30
|
.forEach(function (value) {
|
|
26
31
|
var tagName = value == 'super' ? 'sup' : value == 'sub' ? 'sub' : null;
|
|
27
32
|
if (tagName) {
|
|
28
|
-
(0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
|
|
33
|
+
var wrapper = (0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
|
|
34
|
+
if (format.superOrSubScriptFontSize) {
|
|
35
|
+
wrapper.style.fontSize = format.superOrSubScriptFontSize;
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
});
|
|
31
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superOrSubScriptFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/superOrSubScriptFormatHandler.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACU,QAAA,6BAA6B,GAA0C;QAChF,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;YAC1C,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,YAAY,CAAC,aAAa,CAAC;YAChF,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC;YAEjE,IAAI,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"superOrSubScriptFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/superOrSubScriptFormatHandler.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACU,QAAA,6BAA6B,GAA0C;QAChF,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;YAC1C,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,YAAY,CAAC,aAAa,CAAC;YAChF,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC;YAEjE,IAAM,eAAe,GACjB,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,QAAQ,IAAI,SAAS,CAAC;YAEpF,IACI,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAC3C,CAAC,eAAe,IAAI,CAAC,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,KAAK,CAAC,CAAC,EAC3E;gBACE,MAAM,CAAC,wBAAwB,GAAG,CAAC,MAAM,CAAC,wBAAwB,IAAI,EAAE,CAAC;qBACpE,KAAK,CAAC,GAAG,CAAC;qBACV,MAAM,CAAC,aAAa,CAAC;qBACrB,IAAI,CAAC,GAAG,CAAC;qBACT,IAAI,EAAE,CAAC;gBACZ,IAAI,eAAe,EAAE;oBACjB,MAAM,CAAC,wBAAwB,GAAG,SAAS,CAAC;iBAC/C;aACJ;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;YACnB,IAAI,MAAM,CAAC,wBAAwB,EAAE;gBACjC,MAAM,CAAC,wBAAwB;qBAC1B,KAAK,CAAC,GAAG,CAAC;qBACV,OAAO,EAAE;qBACT,OAAO,CAAC,UAAA,KAAK;oBACV,IAAM,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;oBAEzE,IAAI,OAAO,EAAE;wBACT,IAAM,OAAO,GAAG,IAAA,kCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBACpD,IAAI,MAAM,CAAC,wBAAwB,EAAE;4BACjC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC;yBAC5D;qBACJ;gBACL,CAAC,CAAC,CAAC;aACV;QACL,CAAC;KACJ,CAAC;IAEF;;OAEG;IACH,SAAgB,kBAAkB,CAC9B,QAA4B,EAC5B,aAAiC;QAEjC,OAAO,QAAQ,IAAI,SAAS,IAAI,CAAC,aAAa,IAAI,KAAK,IAAI,aAAa,IAAI,OAAO,CAAC,CAAC;IACzF,CAAC;IALD,gDAKC","sourcesContent":["import { wrapAllChildNodes } from '../../domUtils/moveChildNodes';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { SuperOrSubScriptFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const superOrSubScriptFormatHandler: FormatHandler<SuperOrSubScriptFormat> = {\n parse: (format, element, context, defaultStyle) => {\n const verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;\n const fontSize = element.style.fontSize || defaultStyle.fontSize;\n\n const inheritFontSize =\n (element.tagName == 'SUP' || element.tagName == 'SUB') && fontSize == 'inherit';\n\n if (\n isSuperOrSubScript(fontSize, verticalAlign) ||\n (inheritFontSize && (verticalAlign == 'super' || verticalAlign == 'sub'))\n ) {\n format.superOrSubScriptSequence = (format.superOrSubScriptSequence || '')\n .split(' ')\n .concat(verticalAlign)\n .join(' ')\n .trim();\n if (inheritFontSize) {\n format.superOrSubScriptFontSize = 'inherit';\n }\n }\n },\n apply: (format, element) => {\n if (format.superOrSubScriptSequence) {\n format.superOrSubScriptSequence\n .split(' ')\n .reverse()\n .forEach(value => {\n const tagName = value == 'super' ? 'sup' : value == 'sub' ? 'sub' : null;\n\n if (tagName) {\n const wrapper = wrapAllChildNodes(element, tagName);\n if (format.superOrSubScriptFontSize) {\n wrapper.style.fontSize = format.superOrSubScriptFontSize;\n }\n }\n });\n }\n },\n};\n\n/**\n * @internal\n */\nexport function isSuperOrSubScript(\n fontSize: string | undefined,\n verticalAlign: string | undefined\n): verticalAlign is 'sub' | 'super' {\n return fontSize == 'smaller' && (verticalAlign == 'sub' || verticalAlign == 'super');\n}\n"]}
|
|
@@ -3,9 +3,9 @@ define(["require", "exports"], function (require, exports) {
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.stripInvisibleUnicode = void 0;
|
|
5
5
|
// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
|
|
6
|
-
// there are some invisible unicode characters in the range of U+E0000 to U+
|
|
6
|
+
// there are some invisible unicode characters in the range of U+E0000 to U+E007F, which are used for hiding text in HTML.
|
|
7
7
|
// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
|
|
8
|
-
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{
|
|
8
|
+
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{E007F}]/gu;
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
11
11
|
* Strip invisible unicode characters from the given string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;;IAAA,oGAAoG;IACpG,0HAA0H;IAC1H,+IAA+I;IAC/I,IAAM,uBAAuB,GAAG,yBAAyB,CAAC;IAE1D;;;;;OAKG;IACH,SAAgB,qBAAqB,CAAC,KAAa;QAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAFD,sDAEC","sourcesContent":["// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n// there are some invisible unicode characters in the range of U+E0000 to U+
|
|
1
|
+
{"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;;IAAA,oGAAoG;IACpG,0HAA0H;IAC1H,+IAA+I;IAC/I,IAAM,uBAAuB,GAAG,yBAAyB,CAAC;IAE1D;;;;;OAKG;IACH,SAAgB,qBAAqB,CAAC,KAAa;QAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAFD,sDAEC","sourcesContent":["// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n// there are some invisible unicode characters in the range of U+E0000 to U+E007F, which are used for hiding text in HTML.\n// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.\nconst INVISIBLE_UNICODE_REGEX = /[\\u{E0000}-\\u{E007F}]/gu;\n\n/**\n * @internal\n * Strip invisible unicode characters from the given string\n * @param value The string to be processed\n * @returns The string with invisible unicode characters removed\n */\nexport function stripInvisibleUnicode(value: string): string {\n return value.replace(INVISIBLE_UNICODE_REGEX, '');\n}\n"]}
|