roosterjs-content-model-dom 9.61.0 → 9.63.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/domToModel/processors/listItemProcessor.js +11 -2
- package/lib/domToModel/processors/listItemProcessor.js.map +1 -1
- package/lib/formatHandlers/block/marginFormatHandler.js +3 -2
- package/lib/formatHandlers/block/marginFormatHandler.js.map +1 -1
- package/lib/formatHandlers/common/verticalAlignFormatHandler.js +7 -2
- package/lib/formatHandlers/common/verticalAlignFormatHandler.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/modelApi/list/applyWordLikeListStyles.d.ts +6 -0
- package/lib/modelApi/list/applyWordLikeListStyles.js +28 -0
- package/lib/modelApi/list/applyWordLikeListStyles.js.map +1 -0
- package/lib/modelToDom/handlers/handleListItem.js +8 -3
- package/lib/modelToDom/handlers/handleListItem.js.map +1 -1
- package/lib-amd/constants/EmptySegmentFormat.js +1 -0
- package/lib-amd/constants/EmptySegmentFormat.js.map +1 -1
- package/lib-amd/domToModel/processors/listItemProcessor.js +11 -3
- package/lib-amd/domToModel/processors/listItemProcessor.js.map +1 -1
- package/lib-amd/formatHandlers/block/marginFormatHandler.js +3 -2
- package/lib-amd/formatHandlers/block/marginFormatHandler.js.map +1 -1
- package/lib-amd/formatHandlers/common/verticalAlignFormatHandler.js +7 -2
- package/lib-amd/formatHandlers/common/verticalAlignFormatHandler.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-amd/modelApi/list/applyWordLikeListStyles.d.ts +6 -0
- package/lib-amd/modelApi/list/applyWordLikeListStyles.js +28 -0
- package/lib-amd/modelApi/list/applyWordLikeListStyles.js.map +1 -0
- package/lib-amd/modelToDom/handlers/handleListItem.js +8 -4
- package/lib-amd/modelToDom/handlers/handleListItem.js.map +1 -1
- package/lib-mjs/constants/EmptySegmentFormat.js +1 -0
- package/lib-mjs/constants/EmptySegmentFormat.js.map +1 -1
- package/lib-mjs/domToModel/processors/listItemProcessor.js +11 -2
- package/lib-mjs/domToModel/processors/listItemProcessor.js.map +1 -1
- package/lib-mjs/formatHandlers/block/marginFormatHandler.js +3 -2
- package/lib-mjs/formatHandlers/block/marginFormatHandler.js.map +1 -1
- package/lib-mjs/formatHandlers/common/verticalAlignFormatHandler.js +7 -2
- package/lib-mjs/formatHandlers/common/verticalAlignFormatHandler.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/lib-mjs/modelApi/list/applyWordLikeListStyles.d.ts +6 -0
- package/lib-mjs/modelApi/list/applyWordLikeListStyles.js +24 -0
- package/lib-mjs/modelApi/list/applyWordLikeListStyles.js.map +1 -0
- package/lib-mjs/modelToDom/handlers/handleListItem.js +8 -3
- package/lib-mjs/modelToDom/handlers/handleListItem.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyWordLikeListStyles = void 0;
|
|
4
|
+
var mutate_1 = require("../common/mutate");
|
|
5
|
+
var setParagraphNotImplicit_1 = require("../block/setParagraphNotImplicit");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* Store default Word-like list spacing in the model and retain paragraph wrappers.
|
|
9
|
+
*/
|
|
10
|
+
function applyWordLikeListStyles(listItem, inheritedDirection) {
|
|
11
|
+
var _a;
|
|
12
|
+
listItem.format.marginBottom = (_a = listItem.format.marginBottom) !== null && _a !== void 0 ? _a : '2px';
|
|
13
|
+
listItem.blocks.forEach(function (block) {
|
|
14
|
+
var _a, _b, _c, _d;
|
|
15
|
+
(0, setParagraphNotImplicit_1.setParagraphNotImplicit)(block);
|
|
16
|
+
var direction = (_d = (_b = (_a = block.format.direction) !== null && _a !== void 0 ? _a : listItem.format.direction) !== null && _b !== void 0 ? _b : (_c = listItem.levels[listItem.levels.length - 1]) === null || _c === void 0 ? void 0 : _c.format.direction) !== null && _d !== void 0 ? _d : inheritedDirection;
|
|
17
|
+
var marginKey = direction == 'rtl' ? 'marginRight' : 'marginLeft';
|
|
18
|
+
if (block.format[marginKey] == undefined) {
|
|
19
|
+
var format = (0, mutate_1.mutateBlock)(block).format;
|
|
20
|
+
format[marginKey] = '8px';
|
|
21
|
+
if (direction == 'rtl') {
|
|
22
|
+
format.direction = direction;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.applyWordLikeListStyles = applyWordLikeListStyles;
|
|
28
|
+
//# sourceMappingURL=applyWordLikeListStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyWordLikeListStyles.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/list/applyWordLikeListStyles.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,4EAA2E;AAG3E;;;GAGG;AACH,SAAgB,uBAAuB,CACnC,QAA8B,EAC9B,kBAAkC;;IAElC,QAAQ,CAAC,MAAM,CAAC,YAAY,GAAG,MAAA,QAAQ,CAAC,MAAM,CAAC,YAAY,mCAAI,KAAK,CAAC;IAErE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;;QACzB,IAAA,iDAAuB,EAAC,KAAK,CAAC,CAAC;QAE/B,IAAM,SAAS,GACX,MAAA,MAAA,MAAA,KAAK,CAAC,MAAM,CAAC,SAAS,mCACtB,QAAQ,CAAC,MAAM,CAAC,SAAS,mCACzB,MAAA,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,MAAM,CAAC,SAAS,mCAC7D,kBAAkB,CAAC;QACvB,IAAM,SAAS,GAAG,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;QAEpE,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,SAAS,EAAE;YAC9B,IAAA,MAAM,GAAK,IAAA,oBAAW,EAAC,KAAK,CAAC,OAAvB,CAAwB;YAEtC,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;YAE1B,IAAI,SAAS,IAAI,KAAK,EAAE;gBACpB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;aAChC;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AA1BD,0DA0BC","sourcesContent":["import { mutateBlock } from '../common/mutate';\nimport { setParagraphNotImplicit } from '../block/setParagraphNotImplicit';\nimport type { ContentModelListItem } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Store default Word-like list spacing in the model and retain paragraph wrappers.\n */\nexport function applyWordLikeListStyles(\n listItem: ContentModelListItem,\n inheritedDirection?: 'ltr' | 'rtl'\n) {\n listItem.format.marginBottom = listItem.format.marginBottom ?? '2px';\n\n listItem.blocks.forEach(block => {\n setParagraphNotImplicit(block);\n\n const direction =\n block.format.direction ??\n listItem.format.direction ??\n listItem.levels[listItem.levels.length - 1]?.format.direction ??\n inheritedDirection;\n const marginKey = direction == 'rtl' ? 'marginRight' : 'marginLeft';\n\n if (block.format[marginKey] == undefined) {\n const { format } = mutateBlock(block);\n\n format[marginKey] = '8px';\n\n if (direction == 'rtl') {\n format.direction = direction;\n }\n }\n });\n}\n"]}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleListItem = void 0;
|
|
4
4
|
var applyFormat_1 = require("../utils/applyFormat");
|
|
5
5
|
var applyMetadata_1 = require("../utils/applyMetadata");
|
|
6
|
+
var applyWordLikeListStyles_1 = require("../../modelApi/list/applyWordLikeListStyles");
|
|
6
7
|
var isGenericRoleElement_1 = require("../../domUtils/isGenericRoleElement");
|
|
7
8
|
var reuseCachedElement_1 = require("../../domUtils/reuseCachedElement");
|
|
8
9
|
var setParagraphNotImplicit_1 = require("../../modelApi/block/setParagraphNotImplicit");
|
|
@@ -14,10 +15,11 @@ var PresentationRoleValue = 'presentation';
|
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
16
17
|
var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
17
|
-
var _a, _b;
|
|
18
|
+
var _a, _b, _c, _d;
|
|
18
19
|
refNode = context.modelHandlers.list(doc, parent, listItem, context, refNode);
|
|
19
20
|
var nodeStack = context.listFormat.nodeStack;
|
|
20
|
-
var
|
|
21
|
+
var wordLikeStyles = ((_b = (_a = context.experimentalFeatures) === null || _a === void 0 ? void 0 : _a.indexOf('WordLikeStyles')) !== null && _b !== void 0 ? _b : -1) >= 0;
|
|
22
|
+
var leafLevel = (_c = nodeStack === null || nodeStack === void 0 ? void 0 : nodeStack[nodeStack.length - 1]) !== null && _c !== void 0 ? _c : {};
|
|
21
23
|
var itemRefNode = leafLevel.refNode || null;
|
|
22
24
|
var listParent = leafLevel.node || parent;
|
|
23
25
|
var level = listItem.levels[listItem.levels.length - 1];
|
|
@@ -45,6 +47,9 @@ var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
|
45
47
|
listItem.cachedElement = li;
|
|
46
48
|
}
|
|
47
49
|
if (level) {
|
|
50
|
+
if (wordLikeStyles) {
|
|
51
|
+
(0, applyWordLikeListStyles_1.applyWordLikeListStyles)(listItem, context.implicitFormat.direction);
|
|
52
|
+
}
|
|
48
53
|
(0, applyFormat_1.applyFormat)(li, context.formatAppliers.segment, listItem.formatHolder.format, context);
|
|
49
54
|
(0, applyFormat_1.applyFormat)(li, context.formatAppliers.listItemThread, level.format, context);
|
|
50
55
|
// Need to apply metadata after applying listItem format since the list numbers value relies on the result of list thread handling
|
|
@@ -74,7 +79,7 @@ var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
if (isNewlyCreated) {
|
|
77
|
-
(
|
|
82
|
+
(_d = context.onNodeCreated) === null || _d === void 0 ? void 0 : _d.call(context, listItem, li);
|
|
78
83
|
}
|
|
79
84
|
return refNode;
|
|
80
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleListItem.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleListItem.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,wDAAuD;AACvD,4EAA2E;AAC3E,wEAAuE;AACvE,wF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AC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,EAC3E;gBACI,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzE,CAAC,CACJ,CAAC;QACN,CAAC,CAAC,CAAC;KACN;SAAM;QACH,sFAAsF;QACtF,wHAAwH;QACxH,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,iDAAuB,CAAC,CAAC;QAEjD,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAErE,IAAA,eAAM,EAAC,EAAE,CAAC,CAAC;KACd;IAED,6EAA6E;IAC7E,8EAA8E;IAC9E,8CAA8C;IAC9C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACrD,IAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,IAAA,2CAAoB,EAAC,OAAO,CAAC,EAAE;YAC/B,OAAO,CAAC,YAAY,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;SAClE;KACJ;IAED,IAAI,cAAc,EAAE;QAChB,MAAA,OAAO,CAAC,aAAa,+CAArB,OAAO,EAAiB,QAAQ,EAAE,EAAE,CAAC,CAAC;KACzC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"handleListItem.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleListItem.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,wDAAuD;AACvD,uFAAsF;AACtF,4EAA2E;AAC3E,wEAAuE;AACvE,wFAAuF;AACvF,oDAAmD;AACnD,gDAA+C;AAQ/C,IAAM,iBAAiB,GA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yMetadata } from '../utils/applyMetadata';\nimport { applyWordLikeListStyles } from '../../modelApi/list/applyWordLikeListStyles';\nimport { isGenericRoleElement } from '../../domUtils/isGenericRoleElement';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { setParagraphNotImplicit } from '../../modelApi/block/setParagraphNotImplicit';\nimport { stackFormat } from '../utils/stackFormat';\nimport { unwrap } from '../../domUtils/unwrap';\nimport type {\n ContentModelBlockHandler,\n ContentModelListItem,\n ModelToDomContext,\n ModelToDomListStackItem,\n} from 'roosterjs-content-model-types';\n\nconst HtmlRoleAttribute = 'role';\nconst PresentationRoleValue = 'presentation';\n\n/**\n * @internal\n */\nexport const handleListItem: ContentModelBlockHandler<ContentModelListItem> = (\n doc: Document,\n parent: Node,\n listItem: ContentModelListItem,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n refNode = context.modelHandlers.list(doc, parent, listItem, context, refNode);\n\n const { nodeStack } = context.listFormat;\n const wordLikeStyles = (context.experimentalFeatures?.indexOf('WordLikeStyles') ?? -1) >= 0;\n const leafLevel: Partial<ModelToDomListStackItem> = nodeStack?.[nodeStack.length - 1] ?? {};\n const itemRefNode = leafLevel.refNode || null;\n const listParent = leafLevel.node || parent;\n const level = listItem.levels[listItem.levels.length - 1];\n\n let li: HTMLLIElement;\n let isNewlyCreated = false;\n\n if (listItem.cachedElement) {\n li = listItem.cachedElement;\n\n // Check if the cached LI is used as refNode under another list level,\n // since we know we are going to move it under the current listParent,\n // we need to update the refNode of the previous list level to avoid removing it later\n for (let i = 0; i < nodeStack.length - 1; i++) {\n if (nodeStack[i].refNode === li) {\n nodeStack[i].refNode = li.nextSibling;\n }\n }\n\n leafLevel.refNode = reuseCachedElement(\n listParent,\n li,\n itemRefNode,\n context.rewriteFromModel\n );\n } else {\n li = doc.createElement('li');\n isNewlyCreated = true;\n\n // It is possible listParent is the same with parent param.\n // This happens when outdent a list item to cause it has no list level\n listParent.insertBefore(li, itemRefNode?.parentNode == listParent ? itemRefNode : null);\n context.rewriteFromModel.addedBlockElements.push(li);\n listItem.cachedElement = li;\n }\n\n if (level) {\n if (wordLikeStyles) {\n applyWordLikeListStyles(listItem, context.implicitFormat.direction);\n }\n\n applyFormat(li, context.formatAppliers.segment, listItem.formatHolder.format, context);\n applyFormat(li, context.formatAppliers.listItemThread, level.format, context);\n\n // Need to apply metadata after applying listItem format since the list numbers value relies on the result of list thread handling\n applyMetadata(level, context.metadataAppliers.listItem, listItem.format, context);\n\n // Need to apply listItemElement formats after applying metadata since the list numbers value relies on the result of metadata handling\n applyFormat(li, context.formatAppliers.listItemElement, listItem.format, context);\n\n stackFormat(context, listItem.formatHolder.format, () => {\n stackFormat(\n context,\n listItem.format.direction ? { direction: listItem.format.direction } : null,\n () => {\n context.modelHandlers.blockGroupChildren(doc, li, listItem, context);\n }\n );\n });\n } else {\n // There is no level for this list item, that means it should be moved out of the list\n // For each paragraph, make it not implicit so it will have a DIV around it, to avoid more paragraphs connected together\n listItem.blocks.forEach(setParagraphNotImplicit);\n\n context.modelHandlers.blockGroupChildren(doc, li, listItem, context);\n\n unwrap(li);\n }\n\n // Add role=\"presentation\" to all generic role elements inside the LI element\n // This is to make sure the elements are announced correctly by screen readers\n // when using arrow keys to navigate the list.\n for (let index = 0; index < li.children.length; index++) {\n const element = li.children.item(index);\n if (isGenericRoleElement(element)) {\n element.setAttribute(HtmlRoleAttribute, PresentationRoleValue);\n }\n }\n\n if (isNewlyCreated) {\n context.onNodeCreated?.(listItem, li);\n }\n\n return refNode;\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", "../../modelApi/creators/createListItem", "../../modelApi/creators/createListLevel", "../utils/parseFormat", "../utils/stackFormat"], function (require, exports, createListItem_1, createListLevel_1, parseFormat_1, stackFormat_1) {
|
|
1
|
+
define(["require", "exports", "../../modelApi/list/applyWordLikeListStyles", "../../modelApi/creators/createListItem", "../../modelApi/creators/createListLevel", "../utils/parseFormat", "../utils/stackFormat"], function (require, exports, applyWordLikeListStyles_1, createListItem_1, createListLevel_1, parseFormat_1, stackFormat_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.listItemProcessor = void 0;
|
|
@@ -6,12 +6,13 @@ define(["require", "exports", "../../modelApi/creators/createListItem", "../../m
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
var listItemProcessor = function (group, element, context) {
|
|
9
|
-
var _a;
|
|
9
|
+
var _a, _b, _c;
|
|
10
10
|
var listFormat = context.listFormat;
|
|
11
|
+
var wordLikeStyles = ((_b = (_a = context.experimentalFeatures) === null || _a === void 0 ? void 0 : _a.indexOf('WordLikeStyles')) !== null && _b !== void 0 ? _b : -1) >= 0;
|
|
11
12
|
var originalListParent = listFormat.listParent;
|
|
12
13
|
var shouldPopListLevel = false;
|
|
13
14
|
try {
|
|
14
|
-
listFormat.listParent = (
|
|
15
|
+
listFormat.listParent = (_c = listFormat.listParent) !== null && _c !== void 0 ? _c : group;
|
|
15
16
|
var listParent_1 = listFormat.listParent;
|
|
16
17
|
if (listFormat.levels.length == 0) {
|
|
17
18
|
listFormat.levels.push((0, createListLevel_1.createListLevel)(listFormat.potentialListType || 'UL', context.blockFormat));
|
|
@@ -19,12 +20,16 @@ define(["require", "exports", "../../modelApi/creators/createListItem", "../../m
|
|
|
19
20
|
}
|
|
20
21
|
(0, stackFormat_1.stackFormat)(context, {
|
|
21
22
|
segment: 'shallowCloneForBlock',
|
|
23
|
+
paragraph: wordLikeStyles ? 'shallowClone' : undefined,
|
|
22
24
|
}, function () {
|
|
23
25
|
(0, parseFormat_1.parseFormat)(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
24
26
|
var listItem = (0, createListItem_1.createListItem)(listFormat.levels, context.segmentFormat);
|
|
25
27
|
(0, parseFormat_1.parseFormat)(element, context.formatParsers.listItemElement, listItem.format, context);
|
|
26
28
|
listParent_1.blocks.push(listItem);
|
|
27
29
|
(0, parseFormat_1.parseFormat)(element, context.formatParsers.listItemThread, listItem.levels[listItem.levels.length - 1].format, context);
|
|
30
|
+
if (wordLikeStyles && listItem.format.direction) {
|
|
31
|
+
context.blockFormat.direction = listItem.format.direction;
|
|
32
|
+
}
|
|
28
33
|
context.elementProcessors.child(listItem, element, context);
|
|
29
34
|
var firstChild = listItem.blocks[0];
|
|
30
35
|
if (listItem.blocks.length == 1 &&
|
|
@@ -33,6 +38,9 @@ define(["require", "exports", "../../modelApi/creators/createListItem", "../../m
|
|
|
33
38
|
Object.assign(listItem.format, firstChild.format);
|
|
34
39
|
firstChild.format = {};
|
|
35
40
|
}
|
|
41
|
+
if (wordLikeStyles) {
|
|
42
|
+
(0, applyWordLikeListStyles_1.applyWordLikeListStyles)(listItem, context.blockFormat.direction);
|
|
43
|
+
}
|
|
36
44
|
});
|
|
37
45
|
}
|
|
38
46
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listItemProcessor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domToModel/processors/listItemProcessor.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"listItemProcessor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domToModel/processors/listItemProcessor.ts"],"names":[],"mappings":";;;;IAOA;;OAEG;IACI,IAAM,iBAAiB,GAAoC,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;;QAC9E,IAAA,UAAU,GAAK,OAAO,WAAZ,CAAa;QAC/B,IAAM,cAAc,GAAG,CAAC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C,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,EAClD,OAAO,CACV,CAAC;gBAEF,IAAI,cAAc,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE;oBAC7C,OAAO,CAAC,WAAW,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;iBAC7D;gBAED,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBAE5D,IAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAEtC,IACI,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC;oBAC3B,UAAU,CAAC,SAAS,IAAI,WAAW;oBACnC,UAAU,CAAC,UAAU,EACvB;oBACE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;oBAClD,UAAU,CAAC,MAAM,GAAG,EAAE,CAAC;iBAC1B;gBAED,IAAI,cAAc,EAAE;oBAChB,IAAA,iDAAuB,EAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;iBACpE;YACL,CAAC,CACJ,CAAC;SACL;gBAAS;YACN,IAAI,kBAAkB,EAAE;gBACpB,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;aAC3B;YAED,UAAU,CAAC,UAAU,GAAG,kBAAkB,CAAC;SAC9C;IACL,CAAC,CAAC;IA9EW,QAAA,iBAAiB,qBA8E5B","sourcesContent":["import { applyWordLikeListStyles } from '../../modelApi/list/applyWordLikeListStyles';\nimport { createListItem } from '../../modelApi/creators/createListItem';\nimport { createListLevel } from '../../modelApi/creators/createListLevel';\nimport { parseFormat } from '../utils/parseFormat';\nimport { stackFormat } from '../utils/stackFormat';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const listItemProcessor: ElementProcessor<HTMLLIElement> = (group, element, context) => {\n const { listFormat } = context;\n const wordLikeStyles = (context.experimentalFeatures?.indexOf('WordLikeStyles') ?? -1) >= 0;\n const originalListParent = listFormat.listParent;\n let shouldPopListLevel = false;\n\n try {\n listFormat.listParent = listFormat.listParent ?? group;\n\n const listParent = listFormat.listParent;\n\n if (listFormat.levels.length == 0) {\n listFormat.levels.push(\n createListLevel(listFormat.potentialListType || 'UL', context.blockFormat)\n );\n shouldPopListLevel = true;\n }\n\n stackFormat(\n context,\n {\n segment: 'shallowCloneForBlock',\n paragraph: wordLikeStyles ? 'shallowClone' : undefined,\n },\n () => {\n parseFormat(\n element,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n\n const listItem = createListItem(listFormat.levels, context.segmentFormat);\n parseFormat(\n element,\n context.formatParsers.listItemElement,\n listItem.format,\n context\n );\n\n listParent.blocks.push(listItem);\n\n parseFormat(\n element,\n context.formatParsers.listItemThread,\n listItem.levels[listItem.levels.length - 1].format,\n context\n );\n\n if (wordLikeStyles && listItem.format.direction) {\n context.blockFormat.direction = listItem.format.direction;\n }\n\n context.elementProcessors.child(listItem, element, context);\n\n const firstChild = listItem.blocks[0];\n\n if (\n listItem.blocks.length == 1 &&\n firstChild.blockType == 'Paragraph' &&\n firstChild.isImplicit\n ) {\n Object.assign(listItem.format, firstChild.format);\n firstChild.format = {};\n }\n\n if (wordLikeStyles) {\n applyWordLikeListStyles(listItem, context.blockFormat.direction);\n }\n }\n );\n } finally {\n if (shouldPopListLevel) {\n listFormat.levels.pop();\n }\n\n listFormat.listParent = originalListParent;\n }\n};\n"]}
|
|
@@ -30,11 +30,12 @@ define(["require", "exports", "../utils/parseValueWithUnit"], function (require,
|
|
|
30
30
|
exports.marginFormatHandler = {
|
|
31
31
|
parse: function (format, element, _, defaultStyle) {
|
|
32
32
|
MarginKeys.forEach(function (key) {
|
|
33
|
-
var _a, _b;
|
|
33
|
+
var _a, _b, _c;
|
|
34
34
|
var alternativeKey = DefaultMarginKey[(_a = format.direction) !== null && _a !== void 0 ? _a : 'ltr'][key];
|
|
35
35
|
var value = element.style[key] ||
|
|
36
|
+
(alternativeKey ? (_b = element.style[alternativeKey]) === null || _b === void 0 ? void 0 : _b.toString() : '') ||
|
|
36
37
|
defaultStyle[key] ||
|
|
37
|
-
(alternativeKey ? (
|
|
38
|
+
(alternativeKey ? (_c = defaultStyle[alternativeKey]) === null || _c === void 0 ? void 0 : _c.toString() : '');
|
|
38
39
|
if (value) {
|
|
39
40
|
switch (key) {
|
|
40
41
|
case 'marginTop':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/block/marginFormatHandler.ts"],"names":[],"mappings":";;;;IAIA,IAAM,UAAU,GAAuD;QACnE,WAAW;QACX,aAAa;QACb,cAAc;QACd,YAAY;KACf,CAAC;IAEF,IAAM,gBAAgB,GAGlB;QACA,GAAG,EAAE;YACD,WAAW,EAAE,iBAAiB;YAC9B,UAAU,EAAE,mBAAmB;SAClC;QACD,GAAG,EAAE;YACD,WAAW,EAAE,mBAAmB;YAChC,UAAU,EAAE,iBAAiB;SAChC;KACJ,CAAC;IAEF,IAAM,GAAG,GAAmD;QACxD,UAAU,EAAE,aAAa;QACzB,WAAW,EAAE,YAAY;QACzB,SAAS,EAAE,WAAW;QACtB,YAAY,EAAE,cAAc;KAC/B,CAAC;IAEF;;OAEG;IACU,QAAA,mBAAmB,GAAkD;QAC9E,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;YACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;;gBAClB,IAAM,cAAc,GAAG,gBAAgB,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACxE,IAAM,KAAK,GACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;oBAClB,YAAY,CAAC,GAAG,CAAC;oBACjB,CAAC,cAAc,CAAC,CAAC,CAAC,MAAA,YAAY,CAAC,cAAc,CAAC,0CAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAErE,IAAI,KAAK,EAAE;oBACP,QAAQ,GAAG,EAAE;wBACT,KAAK,WAAW,CAAC;wBACjB,KAAK,cAAc;4BACf,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;4BACpB,MAAM;wBAEV,KAAK,YAAY,CAAC;wBAClB,KAAK,aAAa;4BACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;gCACrB,CAAC,CAAC,IAAA,uCAAkB,EAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC;oCAC9C,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC;oCAClC,IAAI;gCACN,CAAC,CAAC,KAAK,CAAC;4BACZ,MAAM;qBACb;iBACJ;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;YAC5B,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC1B,IAAM,MAAM,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;gBAE1D,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;oBACzC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC;iBACrC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { DirectionFormat, MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\nconst DefaultMarginKey: Record<\n 'ltr' | 'rtl',\n Partial<Record<keyof MarginFormat, keyof CSSStyleDeclaration>>\n> = {\n ltr: {\n marginRight: 'marginInlineEnd',\n marginLeft: 'marginInlineStart',\n },\n rtl: {\n marginRight: 'marginInlineStart',\n marginLeft: 'marginInlineEnd',\n },\n};\n\nconst LTR: Record<keyof MarginFormat, keyof MarginFormat> = {\n marginLeft: 'marginRight',\n marginRight: 'marginLeft',\n marginTop: 'marginTop',\n marginBottom: 'marginBottom',\n};\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat & DirectionFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const alternativeKey = DefaultMarginKey[format.direction ?? 'ltr'][key];\n const value: string | undefined =\n element.style[key] ||\n defaultStyle[key] ||\n (alternativeKey ? defaultStyle[alternativeKey]?.toString() : '');\n\n if (value) {\n switch (key) {\n case 'marginTop':\n case 'marginBottom':\n format[key] = value;\n break;\n\n case 'marginLeft':\n case 'marginRight':\n format[key] = format[key]\n ? parseValueWithUnit(format[key] || '', element) +\n parseValueWithUnit(value, element) +\n 'px'\n : value;\n break;\n }\n }\n });\n },\n apply: (format, element, context) => {\n MarginKeys.forEach(key => {\n const value = format[key];\n const ltrKey = format.direction == 'rtl' ? LTR[key] : key;\n\n if (value != context.implicitFormat[ltrKey]) {\n element.style[key] = value || '0';\n }\n });\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/block/marginFormatHandler.ts"],"names":[],"mappings":";;;;IAIA,IAAM,UAAU,GAAuD;QACnE,WAAW;QACX,aAAa;QACb,cAAc;QACd,YAAY;KACf,CAAC;IAEF,IAAM,gBAAgB,GAGlB;QACA,GAAG,EAA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,CAAC;oCAC9C,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC;oCAClC,IAAI;gCACN,CAAC,CAAC,KAAK,CAAC;4BACZ,MAAM;qBACb;iBACJ;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;YAC5B,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC1B,IAAM,MAAM,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;gBAE1D,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;oBACzC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC;iBACrC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { DirectionFormat, MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\nconst DefaultMarginKey: Record<\n 'ltr' | 'rtl',\n Partial<Record<keyof MarginFormat, keyof CSSStyleDeclaration>>\n> = {\n ltr: {\n marginRight: 'marginInlineEnd',\n marginLeft: 'marginInlineStart',\n },\n rtl: {\n marginRight: 'marginInlineStart',\n marginLeft: 'marginInlineEnd',\n },\n};\n\nconst LTR: Record<keyof MarginFormat, keyof MarginFormat> = {\n marginLeft: 'marginRight',\n marginRight: 'marginLeft',\n marginTop: 'marginTop',\n marginBottom: 'marginBottom',\n};\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat & DirectionFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const alternativeKey = DefaultMarginKey[format.direction ?? 'ltr'][key];\n const value: string | undefined =\n element.style[key] ||\n (alternativeKey ? element.style[alternativeKey]?.toString() : '') ||\n defaultStyle[key] ||\n (alternativeKey ? defaultStyle[alternativeKey]?.toString() : '');\n\n if (value) {\n switch (key) {\n case 'marginTop':\n case 'marginBottom':\n format[key] = value;\n break;\n\n case 'marginLeft':\n case 'marginRight':\n format[key] = format[key]\n ? parseValueWithUnit(format[key] || '', element) +\n parseValueWithUnit(value, element) +\n 'px'\n : value;\n break;\n }\n }\n });\n },\n apply: (format, element, context) => {\n MarginKeys.forEach(key => {\n const value = format[key];\n const ltrKey = format.direction == 'rtl' ? LTR[key] : key;\n\n if (value != context.implicitFormat[ltrKey]) {\n element.style[key] = value || '0';\n }\n });\n },\n};\n"]}
|
|
@@ -26,8 +26,13 @@ define(["require", "exports"], function (require, exports) {
|
|
|
26
26
|
break;
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
apply: function (format, element) {
|
|
30
|
-
|
|
29
|
+
apply: function (format, element, context) {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
if (element.tagName == 'IMG' &&
|
|
32
|
+
((_b = (_a = context.experimentalFeatures) === null || _a === void 0 ? void 0 : _a.indexOf('WordLikeStyles')) !== null && _b !== void 0 ? _b : -1) >= 0) {
|
|
33
|
+
element.style.verticalAlign = (_c = format.verticalAlign) !== null && _c !== void 0 ? _c : 'middle';
|
|
34
|
+
}
|
|
35
|
+
else if (format.verticalAlign) {
|
|
31
36
|
element.style.verticalAlign = format.verticalAlign;
|
|
32
37
|
}
|
|
33
38
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verticalAlignFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/verticalAlignFormatHandler.ts"],"names":[],"mappings":";;;;IAGA;;OAEG;IACU,QAAA,0BAA0B,GAAuC;QAC1E,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;YACnB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAE5E,QAAQ,KAAK,EAAE;gBACX,KAAK,UAAU,CAAC;gBAChB,KAAK,SAAS,CAAC;gBACf,KAAK,OAAO,CAAC;gBACb,KAAK,KAAK,CAAC;gBACX,KAAK,UAAU,CAAC;gBAChB,KAAK,aAAa,CAAC;gBACnB,KAAK,KAAK;oBACN,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC;oBAC7B,MAAM;gBAEV,KAAK,QAAQ;oBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;oBAChC,MAAM;gBAEV,KAAK,QAAQ;oBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;oBAChC,MAAM;aACb;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"verticalAlignFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/verticalAlignFormatHandler.ts"],"names":[],"mappings":";;;;IAGA;;OAEG;IACU,QAAA,0BAA0B,GAAuC;QAC1E,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;YACnB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAE5E,QAAQ,KAAK,EAAE;gBACX,KAAK,UAAU,CAAC;gBAChB,KAAK,SAAS,CAAC;gBACf,KAAK,OAAO,CAAC;gBACb,KAAK,KAAK,CAAC;gBACX,KAAK,UAAU,CAAC;gBAChB,KAAK,aAAa,CAAC;gBACnB,KAAK,KAAK;oBACN,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC;oBAC7B,MAAM;gBAEV,KAAK,QAAQ;oBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;oBAChC,MAAM;gBAEV,KAAK,QAAQ;oBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;oBAChC,MAAM;aACb;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;;YAC5B,IACI,OAAO,CAAC,OAAO,IAAI,KAAK;gBACxB,CAAC,MAAA,MAAA,OAAO,CAAC,oBAAoB,0CAAE,OAAO,CAAC,gBAAgB,CAAC,mCAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EACtE;gBACE,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,MAAA,MAAM,CAAC,aAAa,mCAAI,QAAQ,CAAC;aAClE;iBAAM,IAAI,MAAM,CAAC,aAAa,EAAE;gBAC7B,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;aACtD;QACL,CAAC;KACJ,CAAC","sourcesContent":["import type { FormatHandler } from '../FormatHandler';\nimport type { VerticalAlignFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const verticalAlignFormatHandler: FormatHandler<VerticalAlignFormat> = {\n parse: (format, element) => {\n const align = element.style.verticalAlign || element.getAttribute('valign');\n\n switch (align) {\n case 'baseline':\n case 'initial':\n case 'super':\n case 'sub':\n case 'text-top':\n case 'text-bottom':\n case 'top':\n format.verticalAlign = 'top';\n break;\n\n case 'bottom':\n format.verticalAlign = 'bottom';\n break;\n\n case 'middle':\n format.verticalAlign = 'middle';\n break;\n }\n },\n apply: (format, element, context) => {\n if (\n element.tagName == 'IMG' &&\n (context.experimentalFeatures?.indexOf('WordLikeStyles') ?? -1) >= 0\n ) {\n element.style.verticalAlign = format.verticalAlign ?? 'middle';\n } else if (format.verticalAlign) {\n element.style.verticalAlign = format.verticalAlign;\n }\n },\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"]}
|
|
@@ -13,21 +13,22 @@ define(["require", "exports", "tslib", "../common/addBlock", "../common/addSegme
|
|
|
13
13
|
* @returns Insert point after merge, or null if there is no insert point
|
|
14
14
|
*/
|
|
15
15
|
function mergeModel(target, source, context, options) {
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
var insertPosition = (_a = options === null || options === void 0 ? void 0 : options.insertPosition) !== null && _a !== void 0 ? _a : (0, deleteSelection_1.deleteSelection)(target, [], context).insertPoint;
|
|
18
|
-
var
|
|
18
|
+
var _d = options || {}, addParagraphAfterMergedContent = _d.addParagraphAfterMergedContent, mergeFormat = _d.mergeFormat, mergeParagraphAfterList = _d.mergeParagraphAfterList, mergeTable = _d.mergeTable;
|
|
19
19
|
if (mergeParagraphAfterList && insertPosition && ((_b = source.blocks[0]) === null || _b === void 0 ? void 0 : _b.blockType) == 'Paragraph') {
|
|
20
20
|
moveParagraphAfterListIntoList(insertPosition);
|
|
21
21
|
}
|
|
22
22
|
if (addParagraphAfterMergedContent && !mergeTable) {
|
|
23
|
-
var
|
|
23
|
+
var _e = insertPosition || {}, paragraph = _e.paragraph, marker = _e.marker;
|
|
24
24
|
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);
|
|
25
25
|
(0, addBlock_1.addBlock)(source, newPara);
|
|
26
26
|
}
|
|
27
27
|
if (insertPosition) {
|
|
28
28
|
if (mergeFormat && mergeFormat != 'none') {
|
|
29
|
-
var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})),
|
|
30
|
-
|
|
29
|
+
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)
|
|
30
|
+
? (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);
|
|
31
|
+
applyDefaultFormat(source, newFormat, mergeFormat, options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator);
|
|
31
32
|
}
|
|
32
33
|
for (var i = 0; i < source.blocks.length; i++) {
|
|
33
34
|
var block = source.blocks[i];
|
|
@@ -305,7 +306,7 @@ define(["require", "exports", "tslib", "../common/addBlock", "../common/addSegme
|
|
|
305
306
|
(0, mutate_1.mutateBlock)(path[0]).blocks.splice(blockIndex, 0, block);
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
|
-
function applyDefaultFormat(group, format, applyDefaultFormatOption) {
|
|
309
|
+
function applyDefaultFormat(group, format, applyDefaultFormatOption, preserveParagraphDecorator) {
|
|
309
310
|
group.blocks.forEach(function (block) {
|
|
310
311
|
var _a;
|
|
311
312
|
mergeBlockFormat(applyDefaultFormatOption, block);
|
|
@@ -314,28 +315,32 @@ define(["require", "exports", "tslib", "../common/addBlock", "../common/addSegme
|
|
|
314
315
|
if (block.blockGroupType == 'ListItem') {
|
|
315
316
|
(0, mutate_1.mutateBlock)(block).formatHolder.format = mergeSegmentFormat(applyDefaultFormatOption, format, block.formatHolder.format);
|
|
316
317
|
}
|
|
317
|
-
applyDefaultFormat(block, format, applyDefaultFormatOption);
|
|
318
|
+
applyDefaultFormat(block, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
318
319
|
break;
|
|
319
320
|
case 'Table':
|
|
320
321
|
block.rows.forEach(function (row) {
|
|
321
322
|
return row.cells.forEach(function (cell) {
|
|
322
|
-
applyDefaultFormat(cell, format, applyDefaultFormatOption);
|
|
323
|
+
applyDefaultFormat(cell, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
323
324
|
});
|
|
324
325
|
});
|
|
325
326
|
break;
|
|
326
327
|
case 'Paragraph':
|
|
327
328
|
var paragraphFormat_1 = ((_a = block.decorator) === null || _a === void 0 ? void 0 : _a.format) || {};
|
|
328
329
|
var paragraph = (0, mutate_1.mutateBlock)(block);
|
|
330
|
+
var paragraphTargetFormat_1 = applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
|
|
331
|
+
preserveParagraphDecorator
|
|
332
|
+
? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, format), paragraphFormat_1) : format;
|
|
329
333
|
paragraph.segments.forEach(function (segment) {
|
|
330
334
|
if (segment.segmentType == 'General') {
|
|
331
|
-
applyDefaultFormat(segment, format, applyDefaultFormatOption);
|
|
335
|
+
applyDefaultFormat(segment, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
332
336
|
}
|
|
333
|
-
segment.format = mergeSegmentFormat(applyDefaultFormatOption,
|
|
337
|
+
segment.format = mergeSegmentFormat(applyDefaultFormatOption, paragraphTargetFormat_1, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, paragraphFormat_1), segment.format));
|
|
334
338
|
if (segment.link) {
|
|
335
339
|
segment.link.format = mergeLinkFormat(applyDefaultFormatOption, format, segment.link.format);
|
|
336
340
|
}
|
|
337
341
|
});
|
|
338
|
-
if (applyDefaultFormatOption === 'keepSourceEmphasisFormat'
|
|
342
|
+
if (applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
|
|
343
|
+
!preserveParagraphDecorator) {
|
|
339
344
|
delete paragraph.decorator;
|
|
340
345
|
}
|
|
341
346
|
break;
|
|
@@ -385,7 +390,7 @@ define(["require", "exports", "tslib", "../common/addBlock", "../common/addSegme
|
|
|
385
390
|
}
|
|
386
391
|
function getSemanticFormat(segmentFormat) {
|
|
387
392
|
var result = {};
|
|
388
|
-
var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline;
|
|
393
|
+
var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline, strikethrough = segmentFormat.strikethrough;
|
|
389
394
|
if (fontWeight && fontWeight != 'normal') {
|
|
390
395
|
result.fontWeight = fontWeight;
|
|
391
396
|
}
|
|
@@ -395,6 +400,9 @@ define(["require", "exports", "tslib", "../common/addBlock", "../common/addSegme
|
|
|
395
400
|
if (underline) {
|
|
396
401
|
result.underline = underline;
|
|
397
402
|
}
|
|
403
|
+
if (strikethrough) {
|
|
404
|
+
result.strikethrough = strikethrough;
|
|
405
|
+
}
|
|
398
406
|
return result;
|
|
399
407
|
}
|
|
400
408
|
/**
|