roosterjs-content-model-dom 9.26.0 → 9.29.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/BulletListType.d.ts +12 -0
- package/lib/constants/BulletListType.js +13 -1
- package/lib/constants/BulletListType.js.map +1 -1
- package/lib/constants/UnorderedListStyleMap.js +4 -1
- package/lib/constants/UnorderedListStyleMap.js.map +1 -1
- package/lib/domToModel/processors/knownElementProcessor.js +7 -1
- package/lib/domToModel/processors/knownElementProcessor.js.map +1 -1
- package/lib/domToModel/processors/tableProcessor.js +1 -0
- package/lib/domToModel/processors/tableProcessor.js.map +1 -1
- package/lib/domUtils/hiddenProperties/hiddenProperty.d.ts +4 -0
- package/lib/domUtils/hiddenProperties/hiddenProperty.js.map +1 -1
- package/lib/domUtils/hiddenProperties/imageState.d.ts +8 -0
- package/lib/domUtils/hiddenProperties/imageState.js +19 -0
- package/lib/domUtils/hiddenProperties/imageState.js.map +1 -0
- package/lib/domUtils/style/normalizeFontFamily.d.ts +7 -0
- package/lib/domUtils/style/normalizeFontFamily.js +40 -0
- package/lib/domUtils/style/normalizeFontFamily.js.map +1 -0
- package/lib/formatHandlers/defaultFormatHandlers.js +4 -1
- package/lib/formatHandlers/defaultFormatHandlers.js.map +1 -1
- package/lib/formatHandlers/segment/imageStateFormatHandler.d.ts +6 -0
- package/lib/formatHandlers/segment/imageStateFormatHandler.js +21 -0
- package/lib/formatHandlers/segment/imageStateFormatHandler.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +16 -3
- package/lib/index.js.map +1 -1
- package/lib/modelApi/block/copyFormat.d.ts +25 -0
- package/lib/modelApi/block/copyFormat.js +76 -0
- package/lib/modelApi/block/copyFormat.js.map +1 -0
- package/lib/modelApi/common/normalizeContentModel.js +2 -1
- package/lib/modelApi/common/normalizeContentModel.js.map +1 -1
- package/lib/modelApi/common/normalizeSegmentFormat.d.ts +8 -0
- package/lib/modelApi/common/normalizeSegmentFormat.js +28 -0
- package/lib/modelApi/common/normalizeSegmentFormat.js.map +1 -0
- package/lib/modelApi/common/unwrapBlock.d.ts +2 -2
- package/lib/modelApi/common/unwrapBlock.js +10 -2
- package/lib/modelApi/common/unwrapBlock.js.map +1 -1
- package/lib/modelApi/editing/retrieveModelFormatState.js +3 -0
- package/lib/modelApi/editing/retrieveModelFormatState.js.map +1 -1
- package/lib-amd/constants/BulletListType.d.ts +12 -0
- package/lib-amd/constants/BulletListType.js +13 -1
- package/lib-amd/constants/BulletListType.js.map +1 -1
- package/lib-amd/constants/UnorderedListStyleMap.js +4 -1
- package/lib-amd/constants/UnorderedListStyleMap.js.map +1 -1
- package/lib-amd/domToModel/processors/knownElementProcessor.js +7 -2
- package/lib-amd/domToModel/processors/knownElementProcessor.js.map +1 -1
- package/lib-amd/domToModel/processors/tableProcessor.js +1 -0
- package/lib-amd/domToModel/processors/tableProcessor.js.map +1 -1
- package/lib-amd/domUtils/hiddenProperties/hiddenProperty.d.ts +4 -0
- package/lib-amd/domUtils/hiddenProperties/hiddenProperty.js.map +1 -1
- package/lib-amd/domUtils/hiddenProperties/imageState.d.ts +8 -0
- package/lib-amd/domUtils/hiddenProperties/imageState.js +20 -0
- package/lib-amd/domUtils/hiddenProperties/imageState.js.map +1 -0
- package/lib-amd/domUtils/style/normalizeFontFamily.d.ts +7 -0
- package/lib-amd/domUtils/style/normalizeFontFamily.js +42 -0
- package/lib-amd/domUtils/style/normalizeFontFamily.js.map +1 -0
- package/lib-amd/formatHandlers/defaultFormatHandlers.js +4 -2
- package/lib-amd/formatHandlers/defaultFormatHandlers.js.map +1 -1
- package/lib-amd/formatHandlers/segment/imageStateFormatHandler.d.ts +6 -0
- package/lib-amd/formatHandlers/segment/imageStateFormatHandler.js +22 -0
- package/lib-amd/formatHandlers/segment/imageStateFormatHandler.js.map +1 -0
- package/lib-amd/index.d.ts +4 -0
- package/lib-amd/index.js +11 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/modelApi/block/copyFormat.d.ts +25 -0
- package/lib-amd/modelApi/block/copyFormat.js +77 -0
- package/lib-amd/modelApi/block/copyFormat.js.map +1 -0
- package/lib-amd/modelApi/common/normalizeContentModel.js +2 -2
- package/lib-amd/modelApi/common/normalizeContentModel.js.map +1 -1
- package/lib-amd/modelApi/common/normalizeSegmentFormat.d.ts +8 -0
- package/lib-amd/modelApi/common/normalizeSegmentFormat.js +25 -0
- package/lib-amd/modelApi/common/normalizeSegmentFormat.js.map +1 -0
- package/lib-amd/modelApi/common/unwrapBlock.d.ts +2 -2
- package/lib-amd/modelApi/common/unwrapBlock.js +10 -3
- package/lib-amd/modelApi/common/unwrapBlock.js.map +1 -1
- package/lib-amd/modelApi/editing/retrieveModelFormatState.js +3 -1
- package/lib-amd/modelApi/editing/retrieveModelFormatState.js.map +1 -1
- package/lib-mjs/constants/BulletListType.d.ts +12 -0
- package/lib-mjs/constants/BulletListType.js +13 -1
- package/lib-mjs/constants/BulletListType.js.map +1 -1
- package/lib-mjs/constants/UnorderedListStyleMap.js +4 -1
- package/lib-mjs/constants/UnorderedListStyleMap.js.map +1 -1
- package/lib-mjs/domToModel/processors/knownElementProcessor.js +7 -1
- package/lib-mjs/domToModel/processors/knownElementProcessor.js.map +1 -1
- package/lib-mjs/domToModel/processors/tableProcessor.js +1 -0
- package/lib-mjs/domToModel/processors/tableProcessor.js.map +1 -1
- package/lib-mjs/domUtils/hiddenProperties/hiddenProperty.d.ts +4 -0
- package/lib-mjs/domUtils/hiddenProperties/hiddenProperty.js.map +1 -1
- package/lib-mjs/domUtils/hiddenProperties/imageState.d.ts +8 -0
- package/lib-mjs/domUtils/hiddenProperties/imageState.js +14 -0
- package/lib-mjs/domUtils/hiddenProperties/imageState.js.map +1 -0
- package/lib-mjs/domUtils/style/normalizeFontFamily.d.ts +7 -0
- package/lib-mjs/domUtils/style/normalizeFontFamily.js +36 -0
- package/lib-mjs/domUtils/style/normalizeFontFamily.js.map +1 -0
- package/lib-mjs/formatHandlers/defaultFormatHandlers.js +4 -1
- package/lib-mjs/formatHandlers/defaultFormatHandlers.js.map +1 -1
- package/lib-mjs/formatHandlers/segment/imageStateFormatHandler.d.ts +6 -0
- package/lib-mjs/formatHandlers/segment/imageStateFormatHandler.js +18 -0
- package/lib-mjs/formatHandlers/segment/imageStateFormatHandler.js.map +1 -0
- package/lib-mjs/index.d.ts +4 -0
- package/lib-mjs/index.js +4 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/modelApi/block/copyFormat.d.ts +25 -0
- package/lib-mjs/modelApi/block/copyFormat.js +72 -0
- package/lib-mjs/modelApi/block/copyFormat.js.map +1 -0
- package/lib-mjs/modelApi/common/normalizeContentModel.js +2 -1
- package/lib-mjs/modelApi/common/normalizeContentModel.js.map +1 -1
- package/lib-mjs/modelApi/common/normalizeSegmentFormat.d.ts +8 -0
- package/lib-mjs/modelApi/common/normalizeSegmentFormat.js +24 -0
- package/lib-mjs/modelApi/common/normalizeSegmentFormat.js.map +1 -0
- package/lib-mjs/modelApi/common/unwrapBlock.d.ts +2 -2
- package/lib-mjs/modelApi/common/unwrapBlock.js +10 -2
- package/lib-mjs/modelApi/common/unwrapBlock.js.map +1 -1
- package/lib-mjs/modelApi/editing/retrieveModelFormatState.js +3 -0
- package/lib-mjs/modelApi/editing/retrieveModelFormatState.js.map +1 -1
- package/package.json +2 -2
|
@@ -42,6 +42,18 @@ export declare const BulletListType: {
|
|
|
42
42
|
* Bullet type circle
|
|
43
43
|
*/
|
|
44
44
|
Circle: number;
|
|
45
|
+
/**
|
|
46
|
+
* Box Shadow bullet type
|
|
47
|
+
*/
|
|
48
|
+
BoxShadow: number;
|
|
49
|
+
/**
|
|
50
|
+
* Rhombus with a cross inside
|
|
51
|
+
*/
|
|
52
|
+
Xrhombus: number;
|
|
53
|
+
/**
|
|
54
|
+
* Check mark bullet type
|
|
55
|
+
*/
|
|
56
|
+
CheckMark: number;
|
|
45
57
|
/**
|
|
46
58
|
* Maximum value of the enum
|
|
47
59
|
*/
|
|
@@ -45,9 +45,21 @@ exports.BulletListType = {
|
|
|
45
45
|
* Bullet type circle
|
|
46
46
|
*/
|
|
47
47
|
Circle: 9,
|
|
48
|
+
/**
|
|
49
|
+
* Box Shadow bullet type
|
|
50
|
+
*/
|
|
51
|
+
BoxShadow: 10,
|
|
52
|
+
/**
|
|
53
|
+
* Rhombus with a cross inside
|
|
54
|
+
*/
|
|
55
|
+
Xrhombus: 11,
|
|
56
|
+
/**
|
|
57
|
+
* Check mark bullet type
|
|
58
|
+
*/
|
|
59
|
+
CheckMark: 12,
|
|
48
60
|
/**
|
|
49
61
|
* Maximum value of the enum
|
|
50
62
|
*/
|
|
51
|
-
Max:
|
|
63
|
+
Max: 12,
|
|
52
64
|
};
|
|
53
65
|
//# sourceMappingURL=BulletListType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulletListType.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/BulletListType.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,cAAc,GAAG;IAC1B;;OAEG;IACH,GAAG,EAAE,CAAC;IACN;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,MAAM,EAAE,CAAC;IACT;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,CAAC;IACZ;;OAEG;IACH,aAAa,EAAE,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC;IACT;;OAEG;IACH,eAAe,EAAE,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,CAAC;IACT;;OAEG;IACH,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"BulletListType.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/BulletListType.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,cAAc,GAAG;IAC1B;;OAEG;IACH,GAAG,EAAE,CAAC;IACN;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,MAAM,EAAE,CAAC;IACT;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,CAAC;IACZ;;OAEG;IACH,aAAa,EAAE,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC;IACT;;OAEG;IACH,eAAe,EAAE,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,CAAC;IACT;;OAEG;IACH,SAAS,EAAE,EAAE;IACb;;OAEG;IACH,QAAQ,EAAE,EAAE;IACZ;;OAEG;IACH,SAAS,EAAE,EAAE;IACb;;OAEG;IACH,GAAG,EAAE,EAAE;CACV,CAAC","sourcesContent":["/**\n * Enum used to control the different types of bullet list\n */\nexport const BulletListType = {\n /**\n * Minimum value of the enum\n */\n Min: 1,\n /**\n * Bullet triggered by *\n */\n Disc: 1,\n /**\n * Bullet triggered by -\n */\n Dash: 2,\n /**\n * Bullet triggered by --\n */\n Square: 3,\n /**\n * Bullet triggered by >\n */\n ShortArrow: 4,\n /**\n * Bullet triggered by ->\n */\n LongArrow: 5,\n /**\n * Bullet triggered by =>\n */\n UnfilledArrow: 6,\n /**\n * Bullet triggered by —\n */\n Hyphen: 7,\n /**\n * Bullet triggered by -->\n */\n DoubleLongArrow: 8,\n /**\n * Bullet type circle\n */\n Circle: 9,\n /**\n * Box Shadow bullet type\n */\n BoxShadow: 10,\n /**\n * Rhombus with a cross inside\n */\n Xrhombus: 11,\n /**\n * Check mark bullet type\n */\n CheckMark: 12,\n /**\n * Maximum value of the enum\n */\n Max: 12,\n};\n"]}
|
|
@@ -8,7 +8,7 @@ var BulletListType_1 = require("./BulletListType");
|
|
|
8
8
|
*/
|
|
9
9
|
exports.UnorderedListStyleMap = (_a = {},
|
|
10
10
|
_a[BulletListType_1.BulletListType.Disc] = 'disc',
|
|
11
|
-
_a[BulletListType_1.BulletListType.Square] = '
|
|
11
|
+
_a[BulletListType_1.BulletListType.Square] = 'square',
|
|
12
12
|
_a[BulletListType_1.BulletListType.Circle] = 'circle',
|
|
13
13
|
_a[BulletListType_1.BulletListType.Dash] = '"- "',
|
|
14
14
|
_a[BulletListType_1.BulletListType.LongArrow] = '"➔ "',
|
|
@@ -16,5 +16,8 @@ exports.UnorderedListStyleMap = (_a = {},
|
|
|
16
16
|
_a[BulletListType_1.BulletListType.ShortArrow] = '"➢ "',
|
|
17
17
|
_a[BulletListType_1.BulletListType.UnfilledArrow] = '"➪ "',
|
|
18
18
|
_a[BulletListType_1.BulletListType.Hyphen] = '"— "',
|
|
19
|
+
_a[BulletListType_1.BulletListType.CheckMark] = '"✔ "',
|
|
20
|
+
_a[BulletListType_1.BulletListType.Xrhombus] = '"❖ "',
|
|
21
|
+
_a[BulletListType_1.BulletListType.BoxShadow] = '"❑ "',
|
|
19
22
|
_a);
|
|
20
23
|
//# sourceMappingURL=UnorderedListStyleMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnorderedListStyleMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/UnorderedListStyleMap.ts"],"names":[],"mappings":";;;;AAAA,mDAAkD;AAElD;;GAEG;AACU,QAAA,qBAAqB;IAC9B,GAAC,+BAAc,CAAC,IAAI,IAAG,MAAM;IAC7B,GAAC,+BAAc,CAAC,MAAM,IAAG,
|
|
1
|
+
{"version":3,"file":"UnorderedListStyleMap.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/constants/UnorderedListStyleMap.ts"],"names":[],"mappings":";;;;AAAA,mDAAkD;AAElD;;GAEG;AACU,QAAA,qBAAqB;IAC9B,GAAC,+BAAc,CAAC,IAAI,IAAG,MAAM;IAC7B,GAAC,+BAAc,CAAC,MAAM,IAAG,QAAQ;IACjC,GAAC,+BAAc,CAAC,MAAM,IAAG,QAAQ;IACjC,GAAC,+BAAc,CAAC,IAAI,IAAG,MAAM;IAC7B,GAAC,+BAAc,CAAC,SAAS,IAAG,MAAM;IAClC,GAAC,+BAAc,CAAC,eAAe,IAAG,MAAM;IACxC,GAAC,+BAAc,CAAC,UAAU,IAAG,MAAM;IACnC,GAAC,+BAAc,CAAC,aAAa,IAAG,MAAM;IACtC,GAAC,+BAAc,CAAC,MAAM,IAAG,MAAM;IAC/B,GAAC,+BAAc,CAAC,SAAS,IAAG,MAAM;IAClC,GAAC,+BAAc,CAAC,QAAQ,IAAG,MAAM;IACjC,GAAC,+BAAc,CAAC,SAAS,IAAG,MAAM;QACpC","sourcesContent":["import { BulletListType } from './BulletListType';\n\n/**\n * Style map for unordered list\n */\nexport const UnorderedListStyleMap: Record<number, string> = {\n [BulletListType.Disc]: 'disc',\n [BulletListType.Square]: 'square',\n [BulletListType.Circle]: 'circle',\n [BulletListType.Dash]: '\"- \"',\n [BulletListType.LongArrow]: '\"➔ \"',\n [BulletListType.DoubleLongArrow]: '\"➔ \"',\n [BulletListType.ShortArrow]: '\"➢ \"',\n [BulletListType.UnfilledArrow]: '\"➪ \"',\n [BulletListType.Hyphen]: '\"— \"',\n [BulletListType.CheckMark]: '\"✔ \"',\n [BulletListType.Xrhombus]: '\"❖ \"',\n [BulletListType.BoxShadow]: '\"❑ \"',\n};\n"]}
|
|
@@ -7,6 +7,7 @@ var createParagraph_1 = require("../../modelApi/creators/createParagraph");
|
|
|
7
7
|
var formatContainerProcessor_1 = require("./formatContainerProcessor");
|
|
8
8
|
var getDefaultStyle_1 = require("../utils/getDefaultStyle");
|
|
9
9
|
var isBlockElement_1 = require("../utils/isBlockElement");
|
|
10
|
+
var entityUtils_1 = require("../../domUtils/entityUtils");
|
|
10
11
|
var parseFormat_1 = require("../utils/parseFormat");
|
|
11
12
|
var stackFormat_1 = require("../utils/stackFormat");
|
|
12
13
|
var FormatContainerTriggerStyles = [
|
|
@@ -27,6 +28,7 @@ var FormatContainerTriggerStyles = [
|
|
|
27
28
|
'minWidth',
|
|
28
29
|
'minHeight',
|
|
29
30
|
];
|
|
31
|
+
var FormatContainerTriggerAttributes = ['id'];
|
|
30
32
|
var ByPassFormatContainerTags = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'P', 'A'];
|
|
31
33
|
var SegmentDecoratorTags = ['A', 'CODE'];
|
|
32
34
|
/**
|
|
@@ -38,6 +40,9 @@ var knownElementProcessor = function (group, element, context) {
|
|
|
38
40
|
shouldUseFormatContainer(element, context)) {
|
|
39
41
|
(0, formatContainerProcessor_1.formatContainerProcessor)(group, element, context);
|
|
40
42
|
}
|
|
43
|
+
else if ((0, entityUtils_1.isBlockEntityContainer)(element)) {
|
|
44
|
+
context.elementProcessors.child(group, element, context);
|
|
45
|
+
}
|
|
41
46
|
else if (isBlock) {
|
|
42
47
|
var decorator = context.blockDecorator.tagName ? context.blockDecorator : undefined;
|
|
43
48
|
var isSegmentDecorator = SegmentDecoratorTags.indexOf(element.tagName) >= 0;
|
|
@@ -80,7 +85,8 @@ function shouldUseFormatContainer(element, context) {
|
|
|
80
85
|
}
|
|
81
86
|
// For block element with positive value of border width or top/bottom margin/padding,
|
|
82
87
|
// we need to use format container
|
|
83
|
-
if (FormatContainerTriggerStyles.some(function (key) { return parseInt(style[key] || defaultStyle[key] || '') > 0; })
|
|
88
|
+
if (FormatContainerTriggerStyles.some(function (key) { return parseInt(style[key] || defaultStyle[key] || '') > 0; }) ||
|
|
89
|
+
FormatContainerTriggerAttributes.some(function (attr) { return element.hasAttribute(attr); })) {
|
|
84
90
|
return true;
|
|
85
91
|
}
|
|
86
92
|
// For margin left/right with value "auto", we need to use format container
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knownElementProcessor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domToModel/processors/knownElementProcessor.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,mDAAkD;AAClD,2EAA0E;AAC1E,uEAAsE;AACtE,4DAA2D;AAC3D,0DAAyD;AACzD,oDAAmD;AACnD,oDAAm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EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;YACnF,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAEpD,IAAA,+BAAc,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,CAAC,kBAAkB,EAAE;YAChC,IAAA,mBAAQ,EACJ,KAAK,EACL,IAAA,iCAAe,EACX,IAAI,CAAC,cAAc,EACnB,OAAO,CAAC,WAAW,EACnB,SAAS,CAAC,iBAAiB,EAC3B,SAAS,CACZ,CACJ,CAAC;SACL;KACJ;SAAM;QACH,IAAA,yBAAW,EACP,OAAO,EACP;YACI,OAAO,EAAE,cAAc;YACvB,SAAS,EAAE,cAAc;YACzB,IAAI,EAAE,aAAa;SACtB,EACD;YACI,IAAA,yBAAW,EAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YAEpF,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,IAAI,GAAG,EAAE;gBACpD,IAAA,yBAAW,EACP,OAAO,EACP,OAAO,CAAC,aAAa,CAAC,gBAAgB,EACtC,OAAO,CAAC,IAAI,CAAC,MAAM,EACnB,OAAO,CACV,CAAC;aACL;YAED,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC,CACJ,CAAC;KACL;AACL,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"knownElementProcessor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domToModel/processors/knownElementProcessor.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,mDAAkD;AAClD,2EAA0E;AAC1E,uEAAsE;AACtE,4DAA2D;AAC3D,0DA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J,CAAC;KACL;AACL,CAAC,CAAC;AA1DW,QAAA,qBAAqB,yBA0DhC;AAEF,SAAS,wBAAwB,CAAC,OAAoB,EAAE,OAA0B;IAC9E,oFAAoF;IACpF,IAAI,yBAAyB,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACzD,OAAO,KAAK,CAAC;KAChB;IAED,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAM,YAAY,GAAG,IAAA,iCAAe,EAAC,OAAO,CAAC,CAAC;IAE9C,IAAM,OAAO,GAAG,KAAK,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAE3D,qEAAqE;IACrE,IAAI,OAAO,IAAI,OAAO,IAAI,aAAa,EAAE;QACrC,OAAO,IAAI,CAAC;KACf;IAED,sFAAsF;IACtF,kCAAkC;IAClC,IACI,4BAA4B,CAAC,IAAI,CAC7B,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAE,KAAK,CAAC,GAAG,CAAY,IAAK,YAAY,CAAC,GAAG,CAAY,IAAI,EAAE,CAAC,GAAG,CAAC,EAA3E,CAA2E,CACrF;QACD,gCAAgC,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAA1B,CAA0B,CAAC,EAC3E;QACE,OAAO,IAAI,CAAC;KACf;IAED,2EAA2E;IAC3E,IAAI,KAAK,CAAC,UAAU,IAAI,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,MAAM,EAAE;QAC3D,OAAO,IAAI,CAAC;KACf;IAED,sEAAsE;IACtE,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;QAC/B,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { blockProcessor } from './blockProcessor';\nimport { createParagraph } from '../../modelApi/creators/createParagraph';\nimport { formatContainerProcessor } from './formatContainerProcessor';\nimport { getDefaultStyle } from '../utils/getDefaultStyle';\nimport { isBlockElement } from '../utils/isBlockElement';\nimport { isBlockEntityContainer } from '../../domUtils/entityUtils';\nimport { parseFormat } from '../utils/parseFormat';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelSegmentFormat,\n DomToModelContext,\n ElementProcessor,\n} from 'roosterjs-content-model-types';\n\nconst FormatContainerTriggerStyles: (keyof CSSStyleDeclaration)[] = [\n 'marginBottom',\n 'marginTop',\n 'paddingBottom',\n 'paddingTop',\n 'paddingLeft',\n 'paddingRight',\n 'borderTopWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'width',\n 'height',\n 'maxWidth',\n 'maxHeight',\n 'minWidth',\n 'minHeight',\n];\nconst FormatContainerTriggerAttributes = ['id'];\nconst ByPassFormatContainerTags = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'P', 'A'];\nconst SegmentDecoratorTags = ['A', 'CODE'];\n\n/**\n * @internal\n */\nexport const knownElementProcessor: ElementProcessor<HTMLElement> = (group, element, context) => {\n const isBlock = isBlockElement(element);\n\n if (\n (isBlock || element.style.display == 'inline-block') && // For inline-block here, we will also check if it should be represented as Format Container\n shouldUseFormatContainer(element, context)\n ) {\n formatContainerProcessor(group, element, context);\n } else if (isBlockEntityContainer(element)) {\n context.elementProcessors.child(group, element, context);\n } else if (isBlock) {\n const decorator = context.blockDecorator.tagName ? context.blockDecorator : undefined;\n const isSegmentDecorator = SegmentDecoratorTags.indexOf(element.tagName) >= 0;\n\n stackFormat(context, { segment: 'shallowCloneForBlock', paragraph: 'shallowClone' }, () => {\n const segmentFormat: ContentModelSegmentFormat = {};\n\n parseFormat(element, context.formatParsers.segmentOnBlock, segmentFormat, context);\n Object.assign(context.segmentFormat, segmentFormat);\n\n blockProcessor(group, element, context, segmentFormat);\n });\n\n if (isBlock && !isSegmentDecorator) {\n addBlock(\n group,\n createParagraph(\n true /*isImplicit*/,\n context.blockFormat,\n undefined /*segmentFormat*/,\n decorator\n )\n );\n }\n } else {\n stackFormat(\n context,\n {\n segment: 'shallowClone',\n paragraph: 'shallowClone',\n link: 'cloneFormat',\n },\n () => {\n parseFormat(element, context.formatParsers.segment, context.segmentFormat, context);\n\n if (context.link.format.href && element.tagName != 'A') {\n parseFormat(\n element,\n context.formatParsers.segmentUnderLink,\n context.link.format,\n context\n );\n }\n\n context.elementProcessors.child(group, element, context);\n }\n );\n }\n};\n\nfunction shouldUseFormatContainer(element: HTMLElement, context: DomToModelContext) {\n // For those tags that we know we should not use format container, just return false\n if (ByPassFormatContainerTags.indexOf(element.tagName) >= 0) {\n return false;\n }\n\n const style = element.style;\n const defaultStyle = getDefaultStyle(element);\n\n const bgcolor = style.getPropertyValue('background-color');\n\n // For block element with background, we need to use format container\n if (bgcolor && bgcolor != 'transparent') {\n return true;\n }\n\n // For block element with positive value of border width or top/bottom margin/padding,\n // we need to use format container\n if (\n FormatContainerTriggerStyles.some(\n key => parseInt((style[key] as string) || (defaultStyle[key] as string) || '') > 0\n ) ||\n FormatContainerTriggerAttributes.some(attr => element.hasAttribute(attr))\n ) {\n return true;\n }\n\n // For margin left/right with value \"auto\", we need to use format container\n if (style.marginLeft == 'auto' || style.marginRight == 'auto') {\n return true;\n }\n\n // For element with \"align\" attribute, we need to use format container\n if (element.getAttribute('align')) {\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -76,6 +76,7 @@ var tableProcessor = function (group, tableElement, context) {
|
|
|
76
76
|
}
|
|
77
77
|
(0, parseFormat_1.parseFormat)(tr, context.formatParsers.block, context.blockFormat, context);
|
|
78
78
|
(0, parseFormat_1.parseFormat)(tr, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
79
|
+
tableRow.height = parseInt(tr.style.height) || 0;
|
|
79
80
|
var _loop_2 = function (sourceCol, targetCol) {
|
|
80
81
|
for (; tableRow.cells[targetCol]; targetCol++) { }
|
|
81
82
|
var td = tr.cells[sourceCol];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableProcessor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domToModel/processors/tableProcessor.ts"],"names":[],"mappings":";;;;AAAA,2DAA0D;AAC1D,mEAAkE;AAClE,2EAA0E;AAC1E,wEAAuE;AACvE,sFAAqF;AACrF,kEAAiE;AACjE,4DAA2D;AAC3D,oDAAmD;AACnD,oFAAmF;AACnF,oDAAmD;AASnD;;;;;;;;;;;;;;;;GAgBG;AACI,IAAM,cAAc,GAAuC,UAC9D,KAAK,EACL,YAAY,EACZ,OAAO;IAEP,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,sBAAsB,EAAE,EACtE;;QACI,IAAA,yBAAW,EAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAErF,IAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACzE,IAAM,cAAc,GAAG,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QACrF,IAAM,aAAa,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAC;QAC5C,IAAM,iBAAiB,GAAG,aAAa,IAAI,YAAY,CAAC;QACxD,IAAM,oBAAoB,GAAG,0BAA0B,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAE/E,IAAI,OAAO,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,aAAa,GAAG,YAAY,CAAC;SACtC;QAED,MAAA,OAAO,CAAC,UAAU,0CAAE,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAEjD,IAAA,yB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,EAC5B,MAAA,SAAS,CAAC,KAAK,mCAAI,EAAE,EACrB,SAAS,CAAC,WAAW,EACrB,IAAI,CACP,CAAC;4BAEF,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC;4BAC7B,OAAO,IAAI,KAAK,CAAC;yBACpB;qBACJ;iBACJ;aACJ;SACJ;KACJ;IAED,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAuB,EAAE,OAA0B;IACnF,QAAQ,OAAO,CAAC,oBAAoB,EAAE;QAClC,KAAK,IAAI,CAAC;QACV,KAAK,KAAK;YACN,OAAO,IAAI,CAAC;QAEhB,KAAK,UAAU;YACX,IAAM,aAAa,GAAG,IAAA,2CAAoB,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAE9D,OAAO,CACH,CAAC,CAAC,aAAa;gBACf,CAAC,aAAa,IAAI,KAAK;oBACnB,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC;oBAC7B,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACrC,CAAC;QAEN;YACI,OAAO,KAAK,CAAC;KACpB;AACL,CAAC","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { createTable } from '../../modelApi/creators/createTable';\nimport { createTableCell } from '../../modelApi/creators/createTableCell';\nimport { getBoundingClientRect } from '../utils/getBoundingClientRect';\nimport { getSelectionRootNode } from '../../domUtils/selection/getSelectionRootNode';\nimport { isElementOfType } from '../../domUtils/isElementOfType';\nimport { isNodeOfType } from '../../domUtils/isNodeOfType';\nimport { parseFormat } from '../utils/parseFormat';\nimport { parseValueWithUnit } from '../../formatHandlers/utils/parseValueWithUnit';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelTableCellFormat,\n DatasetFormat,\n DomToModelContext,\n ElementProcessor,\n SizeFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * Content Model Element Processor for table\n *\n * For Table with merged/splitted cells, HTML uses colSpan and rowSpan attributes to specify how it should be rendered.\n * To make it easier to edit a table, we will use a different way to describe table.\n *\n * 1. For a m * n table (m rows, n columns), we always create a m * n array for the cells.\n * 2. For a regular table cell, it is mapped to one item of this array\n * 3. For a merged/splitted table cell, it will has colSpan/rowSpan value. We also created TableCell model for those spanned\n * cells, and use \"spanLeft\" and \"spanAbove\" to mark its state\n * 4. When edit table, we always edit on this mapped m * n array because it always has an item for each cell\n * 5. When write back to DOM, we create TD/TH elements for those non-spanned cells, and mark its colSpan/rowSpan value according\n * its neighbour cell's spanLeft/spanAbove attribute\n * @param group The parent block group\n * @param parent Parent DOM node to process\n * @param context DOM to Content Model context\n */\nexport const tableProcessor: ElementProcessor<HTMLTableElement> = (\n group,\n tableElement,\n context\n) => {\n stackFormat(\n context,\n { segment: 'shallowCloneForBlock', paragraph: 'shallowCloneForGroup' },\n () => {\n parseFormat(tableElement, context.formatParsers.block, context.blockFormat, context);\n\n const table = createTable(tableElement.rows.length, context.blockFormat);\n const tableSelection = context.selection?.type == 'table' ? context.selection : null;\n const selectedTable = tableSelection?.table;\n const hasTableSelection = selectedTable == tableElement;\n const recalculateTableSize = shouldRecalculateTableSize(tableElement, context);\n\n if (context.allowCacheElement) {\n table.cachedElement = tableElement;\n }\n\n context.domIndexer?.onTable(tableElement, table);\n\n parseFormat(tableElement, context.formatParsers.table, table.format, context);\n parseFormat(tableElement, context.formatParsers.tableBorder, table.format, context);\n parseFormat(\n tableElement,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n parseFormat(tableElement, context.formatParsers.dataset, table.dataset, context);\n addBlock(group, table);\n\n const columnPositions: (number | undefined)[] = [0];\n const hasColGroup = processColGroup(tableElement, context, columnPositions);\n const rowPositions: number[] = [0];\n const zoomScale = context.zoomScale || 1;\n\n for (let row = 0; row < tableElement.rows.length; row++) {\n const tr = tableElement.rows[row];\n const tableRow = table.rows[row];\n\n const tbody = tr.parentNode;\n\n if (\n isNodeOfType(tbody, 'ELEMENT_NODE') &&\n (isElementOfType(tbody, 'tbody') ||\n isElementOfType(tbody, 'thead') ||\n isElementOfType(tbody, 'tfoot'))\n ) {\n parseFormat(tbody, context.formatParsers.tableRow, tableRow.format, context);\n } else if (context.allowCacheElement) {\n tableRow.cachedElement = tr;\n }\n\n parseFormat(tr, context.formatParsers.tableRow, tableRow.format, context);\n\n stackFormat(context, { paragraph: 'shallowClone', segment: 'shallowClone' }, () => {\n const parent = tr.parentElement;\n const parentTag = parent?.tagName;\n\n if (\n parent &&\n (parentTag == 'TBODY' || parentTag == 'THEAD' || parentTag == 'TFOOT')\n ) {\n // If there is TBODY around TR, retrieve format from TBODY first, in case some format are declared there\n parseFormat(\n parent,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n parent,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n }\n\n parseFormat(tr, context.formatParsers.block, context.blockFormat, context);\n parseFormat(\n tr,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n\n for (\n let sourceCol = 0, targetCol = 0;\n sourceCol < tr.cells.length;\n sourceCol++\n ) {\n for (; tableRow.cells[targetCol]; targetCol++) {}\n\n const td = tr.cells[sourceCol];\n const hasSelectionBeforeCell = context.isInSelection;\n\n if (recalculateTableSize) {\n const colEnd = targetCol + td.colSpan;\n const rowEnd = row + td.rowSpan;\n const needCalcWidth = columnPositions[colEnd] === undefined;\n const needCalcHeight = rowPositions[rowEnd] === undefined;\n\n if (needCalcWidth || needCalcHeight) {\n const rect = getBoundingClientRect(td);\n\n if (rect.width > 0 || rect.height > 0) {\n if (needCalcWidth) {\n const pos = columnPositions[targetCol];\n\n columnPositions[colEnd] =\n (typeof pos == 'number' ? pos : 0) +\n rect.width / zoomScale;\n }\n\n if (needCalcHeight) {\n rowPositions[rowEnd] =\n rowPositions[row] + rect.height / zoomScale;\n }\n }\n }\n }\n\n stackFormat(\n context,\n { paragraph: 'shallowClone', segment: 'shallowClone' },\n () => {\n parseFormat(\n td,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.segmentOnTableCell,\n context.segmentFormat,\n context\n );\n\n const cellFormat: ContentModelTableCellFormat = {\n ...context.blockFormat,\n };\n const dataset: DatasetFormat = {};\n\n parseFormat(\n td,\n context.formatParsers.tableCell,\n cellFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.tableBorder,\n cellFormat,\n context\n );\n parseFormat(td, context.formatParsers.dataset, dataset, context);\n\n for (\n let colSpan = 1;\n colSpan <= td.colSpan;\n colSpan++, targetCol++\n ) {\n for (let rowSpan = 1; rowSpan <= td.rowSpan; rowSpan++) {\n const hasTd = colSpan == 1 && rowSpan == 1;\n const cell = createTableCell(\n colSpan > 1,\n rowSpan > 1,\n td.tagName == 'TH',\n cellFormat\n );\n\n cell.dataset = { ...dataset };\n\n const spannedRow = table.rows[row + rowSpan - 1];\n\n if (spannedRow) {\n spannedRow.cells[targetCol] = cell;\n }\n\n if (hasTd) {\n // When there is COLGROUP, width on table cell should be ignored, so we should not cache the table cell,\n // and always recreate it when write back using the table formats\n if (context.allowCacheElement && !hasColGroup) {\n cell.cachedElement = td;\n }\n\n const { listParent, levels } = context.listFormat;\n\n context.listFormat.listParent = undefined;\n context.listFormat.levels = [];\n\n try {\n context.elementProcessors.child(cell, td, context);\n } finally {\n context.listFormat.listParent = listParent;\n context.listFormat.levels = levels;\n }\n }\n\n const hasSelectionAfterCell = context.isInSelection;\n\n if (\n (hasSelectionBeforeCell && hasSelectionAfterCell) ||\n (hasTableSelection &&\n tableSelection &&\n row >= tableSelection.firstRow &&\n row <= tableSelection.lastRow &&\n targetCol >= tableSelection.firstColumn &&\n targetCol <= tableSelection.lastColumn)\n ) {\n cell.isSelected = true;\n }\n }\n }\n }\n );\n }\n });\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n if (!tableRow.cells[col]) {\n tableRow.cells[col] = createTableCell(\n false,\n false,\n false,\n context.blockFormat\n );\n }\n }\n }\n\n table.widths = calcSizes(columnPositions);\n\n const heights = calcSizes(rowPositions);\n\n table.rows.forEach((row, i) => {\n if (heights[i] > 0) {\n row.height = heights[i];\n }\n });\n }\n );\n};\n\nfunction calcSizes(positions: (number | undefined)[]): number[] {\n const result: number[] = [];\n let lastPos = 0;\n\n for (let i = positions.length - 1; i >= 0; i--) {\n const pos = positions[i];\n\n if (typeof pos == 'number') {\n lastPos = pos;\n break;\n }\n }\n\n for (let i = positions.length - 2; i >= 0; i--) {\n const pos = positions[i];\n if (pos === undefined) {\n result[i] = 0;\n } else {\n result[i] = lastPos - pos;\n lastPos = pos;\n }\n }\n\n return result;\n}\n\nfunction processColGroup(\n table: HTMLElement,\n context: DomToModelContext,\n result: (number | undefined)[]\n): boolean {\n let lastPos = 0;\n let hasColGroup = false;\n\n for (let child = table.firstChild; child; child = child.nextSibling) {\n if (isNodeOfType(child, 'ELEMENT_NODE') && child.tagName == 'COLGROUP') {\n hasColGroup = true;\n\n for (let col = child.firstChild; col; col = col.nextSibling) {\n if (isNodeOfType(col, 'ELEMENT_NODE') && col.tagName == 'COL') {\n const colFormat: SizeFormat = {};\n\n parseFormat(col, context.formatParsers.tableColumn, colFormat, context);\n\n for (let i = 0; i < parseInt(col.getAttribute('span') ?? '1'); i++) {\n if (colFormat.width === undefined) {\n result.push(undefined);\n } else {\n const width = parseValueWithUnit(\n colFormat.width ?? '',\n undefined /*element*/,\n 'px'\n );\n\n result.push(width + lastPos);\n lastPos += width;\n }\n }\n }\n }\n }\n }\n\n return hasColGroup;\n}\n\nfunction shouldRecalculateTableSize(table: HTMLTableElement, context: DomToModelContext): boolean {\n switch (context.recalculateTableSize) {\n case true:\n case 'all':\n return true;\n\n case 'selected':\n const selectionRoot = getSelectionRootNode(context.selection);\n\n return (\n !!selectionRoot &&\n (selectionRoot == table ||\n table.contains(selectionRoot) ||\n selectionRoot.contains(table))\n );\n\n default:\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tableProcessor.js","sourceRoot":"","sources":["../../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AAK,GAAG,IAAA,uCAAkB,EAC5B,MAAA,SAAS,CAAC,KAAK,mCAAI,EAAE,EACrB,SAAS,CAAC,WAAW,EACrB,IAAI,CACP,CAAC;4BAEF,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC;4BAC7B,OAAO,IAAI,KAAK,CAAC;yBACpB;qBACJ;iBACJ;aACJ;SACJ;KACJ;IAED,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAuB,EAAE,OAA0B;IACnF,QAAQ,OAAO,CAAC,oBAAoB,EAAE;QAClC,KAAK,IAAI,CAAC;QACV,KAAK,KAAK;YACN,OAAO,IAAI,CAAC;QAEhB,KAAK,UAAU;YACX,IAAM,aAAa,GAAG,IAAA,2CAAoB,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAE9D,OAAO,CACH,CAAC,CAAC,aAAa;gBACf,CAAC,aAAa,IAAI,KAAK;oBACnB,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC;oBAC7B,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACrC,CAAC;QAEN;YACI,OAAO,KAAK,CAAC;KACpB;AACL,CAAC","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { createTable } from '../../modelApi/creators/createTable';\nimport { createTableCell } from '../../modelApi/creators/createTableCell';\nimport { getBoundingClientRect } from '../utils/getBoundingClientRect';\nimport { getSelectionRootNode } from '../../domUtils/selection/getSelectionRootNode';\nimport { isElementOfType } from '../../domUtils/isElementOfType';\nimport { isNodeOfType } from '../../domUtils/isNodeOfType';\nimport { parseFormat } from '../utils/parseFormat';\nimport { parseValueWithUnit } from '../../formatHandlers/utils/parseValueWithUnit';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelTableCellFormat,\n DatasetFormat,\n DomToModelContext,\n ElementProcessor,\n SizeFormat,\n} from 'roosterjs-content-model-types';\n\n/**\n * Content Model Element Processor for table\n *\n * For Table with merged/splitted cells, HTML uses colSpan and rowSpan attributes to specify how it should be rendered.\n * To make it easier to edit a table, we will use a different way to describe table.\n *\n * 1. For a m * n table (m rows, n columns), we always create a m * n array for the cells.\n * 2. For a regular table cell, it is mapped to one item of this array\n * 3. For a merged/splitted table cell, it will has colSpan/rowSpan value. We also created TableCell model for those spanned\n * cells, and use \"spanLeft\" and \"spanAbove\" to mark its state\n * 4. When edit table, we always edit on this mapped m * n array because it always has an item for each cell\n * 5. When write back to DOM, we create TD/TH elements for those non-spanned cells, and mark its colSpan/rowSpan value according\n * its neighbour cell's spanLeft/spanAbove attribute\n * @param group The parent block group\n * @param parent Parent DOM node to process\n * @param context DOM to Content Model context\n */\nexport const tableProcessor: ElementProcessor<HTMLTableElement> = (\n group,\n tableElement,\n context\n) => {\n stackFormat(\n context,\n { segment: 'shallowCloneForBlock', paragraph: 'shallowCloneForGroup' },\n () => {\n parseFormat(tableElement, context.formatParsers.block, context.blockFormat, context);\n\n const table = createTable(tableElement.rows.length, context.blockFormat);\n const tableSelection = context.selection?.type == 'table' ? context.selection : null;\n const selectedTable = tableSelection?.table;\n const hasTableSelection = selectedTable == tableElement;\n const recalculateTableSize = shouldRecalculateTableSize(tableElement, context);\n\n if (context.allowCacheElement) {\n table.cachedElement = tableElement;\n }\n\n context.domIndexer?.onTable(tableElement, table);\n\n parseFormat(tableElement, context.formatParsers.table, table.format, context);\n parseFormat(tableElement, context.formatParsers.tableBorder, table.format, context);\n parseFormat(\n tableElement,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n parseFormat(tableElement, context.formatParsers.dataset, table.dataset, context);\n addBlock(group, table);\n\n const columnPositions: (number | undefined)[] = [0];\n const hasColGroup = processColGroup(tableElement, context, columnPositions);\n const rowPositions: number[] = [0];\n const zoomScale = context.zoomScale || 1;\n\n for (let row = 0; row < tableElement.rows.length; row++) {\n const tr = tableElement.rows[row];\n const tableRow = table.rows[row];\n\n const tbody = tr.parentNode;\n\n if (\n isNodeOfType(tbody, 'ELEMENT_NODE') &&\n (isElementOfType(tbody, 'tbody') ||\n isElementOfType(tbody, 'thead') ||\n isElementOfType(tbody, 'tfoot'))\n ) {\n parseFormat(tbody, context.formatParsers.tableRow, tableRow.format, context);\n } else if (context.allowCacheElement) {\n tableRow.cachedElement = tr;\n }\n\n parseFormat(tr, context.formatParsers.tableRow, tableRow.format, context);\n\n stackFormat(context, { paragraph: 'shallowClone', segment: 'shallowClone' }, () => {\n const parent = tr.parentElement;\n const parentTag = parent?.tagName;\n\n if (\n parent &&\n (parentTag == 'TBODY' || parentTag == 'THEAD' || parentTag == 'TFOOT')\n ) {\n // If there is TBODY around TR, retrieve format from TBODY first, in case some format are declared there\n parseFormat(\n parent,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n parent,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n }\n\n parseFormat(tr, context.formatParsers.block, context.blockFormat, context);\n parseFormat(\n tr,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n\n tableRow.height = parseInt(tr.style.height) || 0;\n\n for (\n let sourceCol = 0, targetCol = 0;\n sourceCol < tr.cells.length;\n sourceCol++\n ) {\n for (; tableRow.cells[targetCol]; targetCol++) {}\n\n const td = tr.cells[sourceCol];\n const hasSelectionBeforeCell = context.isInSelection;\n if (recalculateTableSize) {\n const colEnd = targetCol + td.colSpan;\n const rowEnd = row + td.rowSpan;\n const needCalcWidth = columnPositions[colEnd] === undefined;\n const needCalcHeight = rowPositions[rowEnd] === undefined;\n\n if (needCalcWidth || needCalcHeight) {\n const rect = getBoundingClientRect(td);\n\n if (rect.width > 0 || rect.height > 0) {\n if (needCalcWidth) {\n const pos = columnPositions[targetCol];\n\n columnPositions[colEnd] =\n (typeof pos == 'number' ? pos : 0) +\n rect.width / zoomScale;\n }\n\n if (needCalcHeight) {\n rowPositions[rowEnd] =\n rowPositions[row] + rect.height / zoomScale;\n }\n }\n }\n }\n\n stackFormat(\n context,\n { paragraph: 'shallowClone', segment: 'shallowClone' },\n () => {\n parseFormat(\n td,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.segmentOnTableCell,\n context.segmentFormat,\n context\n );\n\n const cellFormat: ContentModelTableCellFormat = {\n ...context.blockFormat,\n };\n const dataset: DatasetFormat = {};\n\n parseFormat(\n td,\n context.formatParsers.tableCell,\n cellFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.tableBorder,\n cellFormat,\n context\n );\n parseFormat(td, context.formatParsers.dataset, dataset, context);\n\n for (\n let colSpan = 1;\n colSpan <= td.colSpan;\n colSpan++, targetCol++\n ) {\n for (let rowSpan = 1; rowSpan <= td.rowSpan; rowSpan++) {\n const hasTd = colSpan == 1 && rowSpan == 1;\n const cell = createTableCell(\n colSpan > 1,\n rowSpan > 1,\n td.tagName == 'TH',\n cellFormat\n );\n\n cell.dataset = { ...dataset };\n\n const spannedRow = table.rows[row + rowSpan - 1];\n\n if (spannedRow) {\n spannedRow.cells[targetCol] = cell;\n }\n\n if (hasTd) {\n // When there is COLGROUP, width on table cell should be ignored, so we should not cache the table cell,\n // and always recreate it when write back using the table formats\n if (context.allowCacheElement && !hasColGroup) {\n cell.cachedElement = td;\n }\n\n const { listParent, levels } = context.listFormat;\n\n context.listFormat.listParent = undefined;\n context.listFormat.levels = [];\n\n try {\n context.elementProcessors.child(cell, td, context);\n } finally {\n context.listFormat.listParent = listParent;\n context.listFormat.levels = levels;\n }\n }\n\n const hasSelectionAfterCell = context.isInSelection;\n\n if (\n (hasSelectionBeforeCell && hasSelectionAfterCell) ||\n (hasTableSelection &&\n tableSelection &&\n row >= tableSelection.firstRow &&\n row <= tableSelection.lastRow &&\n targetCol >= tableSelection.firstColumn &&\n targetCol <= tableSelection.lastColumn)\n ) {\n cell.isSelected = true;\n }\n }\n }\n }\n );\n }\n });\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n if (!tableRow.cells[col]) {\n tableRow.cells[col] = createTableCell(\n false,\n false,\n false,\n context.blockFormat\n );\n }\n }\n }\n\n table.widths = calcSizes(columnPositions);\n\n const heights = calcSizes(rowPositions);\n\n table.rows.forEach((row, i) => {\n if (heights[i] > 0) {\n row.height = heights[i];\n }\n });\n }\n );\n};\n\nfunction calcSizes(positions: (number | undefined)[]): number[] {\n const result: number[] = [];\n let lastPos = 0;\n\n for (let i = positions.length - 1; i >= 0; i--) {\n const pos = positions[i];\n\n if (typeof pos == 'number') {\n lastPos = pos;\n break;\n }\n }\n\n for (let i = positions.length - 2; i >= 0; i--) {\n const pos = positions[i];\n if (pos === undefined) {\n result[i] = 0;\n } else {\n result[i] = lastPos - pos;\n lastPos = pos;\n }\n }\n\n return result;\n}\n\nfunction processColGroup(\n table: HTMLElement,\n context: DomToModelContext,\n result: (number | undefined)[]\n): boolean {\n let lastPos = 0;\n let hasColGroup = false;\n\n for (let child = table.firstChild; child; child = child.nextSibling) {\n if (isNodeOfType(child, 'ELEMENT_NODE') && child.tagName == 'COLGROUP') {\n hasColGroup = true;\n\n for (let col = child.firstChild; col; col = col.nextSibling) {\n if (isNodeOfType(col, 'ELEMENT_NODE') && col.tagName == 'COL') {\n const colFormat: SizeFormat = {};\n\n parseFormat(col, context.formatParsers.tableColumn, colFormat, context);\n\n for (let i = 0; i < parseInt(col.getAttribute('span') ?? '1'); i++) {\n if (colFormat.width === undefined) {\n result.push(undefined);\n } else {\n const width = parseValueWithUnit(\n colFormat.width ?? '',\n undefined /*element*/,\n 'px'\n );\n\n result.push(width + lastPos);\n lastPos += width;\n }\n }\n }\n }\n }\n }\n\n return hasColGroup;\n}\n\nfunction shouldRecalculateTableSize(table: HTMLTableElement, context: DomToModelContext): boolean {\n switch (context.recalculateTableSize) {\n case true:\n case 'all':\n return true;\n\n case 'selected':\n const selectionRoot = getSelectionRootNode(context.selection);\n\n return (\n !!selectionRoot &&\n (selectionRoot == table ||\n table.contains(selectionRoot) ||\n selectionRoot.contains(table))\n );\n\n default:\n return false;\n }\n}\n"]}
|
|
@@ -11,6 +11,10 @@ export interface HiddenProperty {
|
|
|
11
11
|
* Specify we should not delete this element when delete/backspace key is pressed
|
|
12
12
|
*/
|
|
13
13
|
undeletable?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Specify the image state. Example: if the image is in editable state
|
|
16
|
+
*/
|
|
17
|
+
imageState?: string;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hiddenProperty.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domUtils/hiddenProperties/hiddenProperty.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"hiddenProperty.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domUtils/hiddenProperties/hiddenProperty.ts"],"names":[],"mappings":";;;AAyBA;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,IAAU,EACV,GAAQ;IAER,IAAM,sBAAsB,GAAG,IAA8B,CAAC;IAC9D,IAAM,cAAc,GAAG,sBAAsB,CAAC,yBAAyB,CAAC;IAExE,OAAO,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5D,CAAC;AARD,8CAQC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,IAAU,EACV,GAAQ,EACR,KAA0B;IAE1B,IAAM,sBAAsB,GAAG,IAA8B,CAAC;IAC9D,IAAM,cAAc,GAAG,sBAAsB,CAAC,yBAAyB,IAAI,EAAE,CAAC;IAE9E,cAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5B,sBAAsB,CAAC,yBAAyB,GAAG,cAAc,CAAC;AACtE,CAAC;AAVD,8CAUC","sourcesContent":["/**\n * @internal\n */\nexport interface HiddenProperty {\n /**\n * A marker string that can be used to identify a specific paragraph in the DOM.\n * This is useful for scenarios where you need to track or manipulate specific paragraphs\n */\n paragraphMarker?: string;\n\n /**\n * Specify we should not delete this element when delete/backspace key is pressed\n */\n undeletable?: boolean;\n\n /**\n * Specify the image state. Example: if the image is in editable state\n */\n imageState?: string;\n}\n\ninterface NodeWithHiddenProperty extends Node {\n __roosterjsHiddenProperty?: HiddenProperty;\n}\n\n/**\n * @internal\n */\nexport function getHiddenProperty<Key extends keyof HiddenProperty>(\n node: Node,\n key: Key\n): HiddenProperty[Key] | undefined {\n const nodeWithHiddenProperty = node as NodeWithHiddenProperty;\n const hiddenProperty = nodeWithHiddenProperty.__roosterjsHiddenProperty;\n\n return hiddenProperty ? hiddenProperty[key] : undefined;\n}\n\n/**\n * @internal\n */\nexport function setHiddenProperty<Key extends keyof HiddenProperty>(\n node: Node,\n key: Key,\n value: HiddenProperty[Key]\n) {\n const nodeWithHiddenProperty = node as NodeWithHiddenProperty;\n const hiddenProperty = nodeWithHiddenProperty.__roosterjsHiddenProperty || {};\n\n hiddenProperty[key] = value;\n nodeWithHiddenProperty.__roosterjsHiddenProperty = hiddenProperty;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get image state from element. This is used to store a image state.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getImageState(element: HTMLElement): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Set image state to element. This is used to store a image state.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setImageState(element: HTMLElement, marker: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setImageState = exports.getImageState = void 0;
|
|
4
|
+
var hiddenProperty_1 = require("./hiddenProperty");
|
|
5
|
+
/**
|
|
6
|
+
* Get image state from element. This is used to store a image state.
|
|
7
|
+
*/
|
|
8
|
+
function getImageState(element) {
|
|
9
|
+
return (0, hiddenProperty_1.getHiddenProperty)(element, 'imageState');
|
|
10
|
+
}
|
|
11
|
+
exports.getImageState = getImageState;
|
|
12
|
+
/**
|
|
13
|
+
* Set image state to element. This is used to store a image state.
|
|
14
|
+
*/
|
|
15
|
+
function setImageState(element, marker) {
|
|
16
|
+
(0, hiddenProperty_1.setHiddenProperty)(element, 'imageState', marker);
|
|
17
|
+
}
|
|
18
|
+
exports.setImageState = setImageState;
|
|
19
|
+
//# sourceMappingURL=imageState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domUtils/hiddenProperties/imageState.ts"],"names":[],"mappings":";;;AAAA,mDAAwE;AAExE;;GAEG;AACH,SAAgB,aAAa,CAAC,OAAoB;IAC9C,OAAO,IAAA,kCAAiB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC;AAFD,sCAEC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,OAAoB,EAAE,MAAc;IAC9D,IAAA,kCAAiB,EAAC,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAFD,sCAEC","sourcesContent":["import { getHiddenProperty, setHiddenProperty } from './hiddenProperty';\n\n/**\n * Get image state from element. This is used to store a image state.\n */\nexport function getImageState(element: HTMLElement): string | undefined {\n return getHiddenProperty(element, 'imageState');\n}\n\n/**\n * Set image state to element. This is used to store a image state.\n */\nexport function setImageState(element: HTMLElement, marker: string): void {\n setHiddenProperty(element, 'imageState', marker);\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize font family string to a standard format
|
|
3
|
+
* Add quotes around font family names that contain non-alphanumeric/dash characters
|
|
4
|
+
* @param fontFamily The font family string to normalize
|
|
5
|
+
* @returns The normalized font family string
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeFontFamily(fontFamily: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeFontFamily = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Normalize font family string to a standard format
|
|
6
|
+
* Add quotes around font family names that contain non-alphanumeric/dash characters
|
|
7
|
+
* @param fontFamily The font family string to normalize
|
|
8
|
+
* @returns The normalized font family string
|
|
9
|
+
*/
|
|
10
|
+
function normalizeFontFamily(fontFamily) {
|
|
11
|
+
var existingQuotedFontsRegex = /".*?"/g;
|
|
12
|
+
var match = existingQuotedFontsRegex.exec(fontFamily);
|
|
13
|
+
var start = 0;
|
|
14
|
+
var result = [];
|
|
15
|
+
while (match) {
|
|
16
|
+
process(fontFamily, result, start, match.index);
|
|
17
|
+
start = match.index + match[0].length;
|
|
18
|
+
result.push(match[0]);
|
|
19
|
+
match = existingQuotedFontsRegex.exec(fontFamily);
|
|
20
|
+
}
|
|
21
|
+
process(fontFamily, result, start, fontFamily.length);
|
|
22
|
+
return result.join(', ');
|
|
23
|
+
}
|
|
24
|
+
exports.normalizeFontFamily = normalizeFontFamily;
|
|
25
|
+
function process(fontFamily, result, start, end) {
|
|
26
|
+
var families = fontFamily.substring(start, end).split(',');
|
|
27
|
+
families.forEach(function (family) {
|
|
28
|
+
family = family.trim();
|
|
29
|
+
if (family) {
|
|
30
|
+
// Check if the family name contains non-alphanumeric characters
|
|
31
|
+
if (/[^a-zA-Z0-9\-]/.test(family)) {
|
|
32
|
+
result.push("\"" + family + "\"");
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
result.push(family);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=normalizeFontFamily.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeFontFamily.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/domUtils/style/normalizeFontFamily.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,UAAkB;IAClD,IAAM,wB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* Add quotes around font family names that contain non-alphanumeric/dash characters\n * @param fontFamily The font family string to normalize\n * @returns The normalized font family string\n */\nexport function normalizeFontFamily(fontFamily: string): string {\n const existingQuotedFontsRegex = /\".*?\"/g;\n let match = existingQuotedFontsRegex.exec(fontFamily);\n let start = 0;\n const result: string[] = [];\n\n while (match) {\n process(fontFamily, result, start, match.index);\n\n start = match.index + match[0].length;\n result.push(match[0]);\n\n match = existingQuotedFontsRegex.exec(fontFamily);\n }\n\n process(fontFamily, result, start, fontFamily.length);\n\n return result.join(', ');\n}\n\nfunction process(fontFamily: string, result: string[], start: number, end: number) {\n const families = fontFamily.substring(start, end).split(',');\n\n families.forEach(family => {\n family = family.trim();\n\n if (family) {\n // Check if the family name contains non-alphanumeric characters\n if (/[^a-zA-Z0-9\\-]/.test(family)) {\n result.push(`\"${family}\"`);\n } else {\n result.push(family);\n }\n }\n });\n}\n"]}
|
|
@@ -18,6 +18,7 @@ var fontSizeFormatHandler_1 = require("./segment/fontSizeFormatHandler");
|
|
|
18
18
|
var getObjectKeys_1 = require("../domUtils/getObjectKeys");
|
|
19
19
|
var htmlAlignFormatHandler_1 = require("./block/htmlAlignFormatHandler");
|
|
20
20
|
var idFormatHandler_1 = require("./common/idFormatHandler");
|
|
21
|
+
var imageStateFormatHandler_1 = require("./segment/imageStateFormatHandler");
|
|
21
22
|
var italicFormatHandler_1 = require("./segment/italicFormatHandler");
|
|
22
23
|
var letterSpacingFormatHandler_1 = require("./segment/letterSpacingFormatHandler");
|
|
23
24
|
var lineHeightFormatHandler_1 = require("./block/lineHeightFormatHandler");
|
|
@@ -57,6 +58,7 @@ var defaultFormatHandlerMap = {
|
|
|
57
58
|
entity: entityFormatHandler_1.entityFormatHandler,
|
|
58
59
|
htmlAlign: htmlAlignFormatHandler_1.htmlAlignFormatHandler,
|
|
59
60
|
id: idFormatHandler_1.idFormatHandler,
|
|
61
|
+
imageState: imageStateFormatHandler_1.imageStateFormatHandler,
|
|
60
62
|
italic: italicFormatHandler_1.italicFormatHandler,
|
|
61
63
|
letterSpacing: letterSpacingFormatHandler_1.letterSpacingFormatHandler,
|
|
62
64
|
lineHeight: lineHeightFormatHandler_1.lineHeightFormatHandler,
|
|
@@ -169,6 +171,7 @@ exports.defaultFormatKeysPerCategory = {
|
|
|
169
171
|
'display',
|
|
170
172
|
'float',
|
|
171
173
|
'verticalAlign',
|
|
174
|
+
'imageState',
|
|
172
175
|
],
|
|
173
176
|
link: [
|
|
174
177
|
'link',
|
|
@@ -187,7 +190,7 @@ exports.defaultFormatKeysPerCategory = {
|
|
|
187
190
|
code: ['fontFamily', 'display'],
|
|
188
191
|
dataset: ['dataset'],
|
|
189
192
|
divider: (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(sharedBlockFormats), false), (0, tslib_1.__read)(sharedContainerFormats), false), ['display', 'size', 'htmlAlign'], false),
|
|
190
|
-
container: (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(sharedContainerFormats), false), ['htmlAlign', 'size', 'display'], false),
|
|
193
|
+
container: (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(sharedContainerFormats), false), ['htmlAlign', 'size', 'display', 'id'], false),
|
|
191
194
|
entity: ['entity'],
|
|
192
195
|
general: ['textColor', 'backgroundColor'], // General model still need to do color transformation in dark mode
|
|
193
196
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultFormatHandlers.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/defaultFormatHandlers.ts"],"names":[],"mappings":";;;;AAAA,gEAA+D;AAC/D,sFAAqF;AACrF,iEAAgE;AAChE,0EAAyE;AACzE,oEAAmE;AACnE,0EAAyE;AACzE,sEAAqE;AACrE,yEAAwE;AACxE,qEAAoE;AACpE,oEAAmE;AACnE,kEAAiE;AACjE,6EAA4E;AAC5E,yEAAwE;AACxE,2DAA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AAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,KAA0B,CAAC;IACtE,OAAO,MAAM,CAAC;AAClB,CAAC,EACc,EAAE,CACpB,CAAC;AAEF;;GAEG;AACU,QAAA,qBAAqB,GAAmB,IAAA,6BAAa,EAAC,uBAAuB,CAAC,CAAC,MAAM,CAC9F,UAAC,MAAM,EAAE,GAAG;IACR,MAAM,CAAC,GAAG,CAAC,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,KAA2B,CAAC;IACvE,OAAO,MAAM,CAAC;AAClB,CAAC,EACe,EAAE,CACrB,CAAC","sourcesContent":["import { ariaFormatHandler } from './common/ariaFormatHandler';\nimport { backgroundColorFormatHandler } from './common/backgroundColorFormatHandler';\nimport { boldFormatHandler } from './segment/boldFormatHandler';\nimport { borderBoxFormatHandler } from './common/borderBoxFormatHandler';\nimport { borderFormatHandler } from './common/borderFormatHandler';\nimport { boxShadowFormatHandler } from './common/boxShadowFormatHandler';\nimport { datasetFormatHandler } from './common/datasetFormatHandler';\nimport { directionFormatHandler } from './block/directionFormatHandler';\nimport { displayFormatHandler } from './block/displayFormatHandler';\nimport { entityFormatHandler } from './entity/entityFormatHandler';\nimport { floatFormatHandler } from './common/floatFormatHandler';\nimport { fontFamilyFormatHandler } from './segment/fontFamilyFormatHandler';\nimport { fontSizeFormatHandler } from './segment/fontSizeFormatHandler';\nimport { getObjectKeys } from '../domUtils/getObjectKeys';\nimport { htmlAlignFormatHandler } from './block/htmlAlignFormatHandler';\nimport { idFormatHandler } from './common/idFormatHandler';\nimport { italicFormatHandler } from './segment/italicFormatHandler';\nimport { letterSpacingFormatHandler } from './segment/letterSpacingFormatHandler';\nimport { lineHeightFormatHandler } from './block/lineHeightFormatHandler';\nimport { linkFormatHandler } from './segment/linkFormatHandler';\nimport { listItemThreadFormatHandler } from './list/listItemThreadFormatHandler';\nimport { listLevelThreadFormatHandler } from './list/listLevelThreadFormatHandler';\nimport { listStyleFormatHandler } from './list/listStyleFormatHandler';\nimport { marginFormatHandler } from './block/marginFormatHandler';\nimport { paddingFormatHandler } from './block/paddingFormatHandler';\nimport { sizeFormatHandler } from './common/sizeFormatHandler';\nimport { strikeFormatHandler } from './segment/strikeFormatHandler';\nimport { superOrSubScriptFormatHandler } from './segment/superOrSubScriptFormatHandler';\nimport { tableLayoutFormatHandler } from './table/tableLayoutFormatHandler';\nimport { tableSpacingFormatHandler } from './table/tableSpacingFormatHandler';\nimport { textAlignFormatHandler } from './block/textAlignFormatHandler';\nimport { textColorFormatHandler } from './segment/textColorFormatHandler';\nimport { textColorOnTableCellFormatHandler } from './table/textColorOnTableCellFormatHandler';\nimport { textIndentFormatHandler } from './block/textIndentFormatHandler';\nimport { undeletableLinkFormatHandler } from './segment/undeletableLinkFormatHandler';\nimport { underlineFormatHandler } from './segment/underlineFormatHandler';\nimport { verticalAlignFormatHandler } from './common/verticalAlignFormatHandler';\nimport { whiteSpaceFormatHandler } from './block/whiteSpaceFormatHandler';\nimport { wordBreakFormatHandler } from './common/wordBreakFormatHandler';\nimport type { FormatHandler } from './FormatHandler';\nimport type {\n ContentModelFormatMap,\n FormatApplier,\n FormatAppliers,\n FormatHandlerTypeMap,\n FormatKey,\n FormatParser,\n FormatParsers,\n} from 'roosterjs-content-model-types';\n\ntype FormatHandlers = {\n [Key in FormatKey]: FormatHandler<FormatHandlerTypeMap[Key]>;\n};\n\nconst defaultFormatHandlerMap: FormatHandlers = {\n aria: ariaFormatHandler,\n backgroundColor: backgroundColorFormatHandler,\n bold: boldFormatHandler,\n border: borderFormatHandler,\n borderBox: borderBoxFormatHandler,\n boxShadow: boxShadowFormatHandler,\n dataset: datasetFormatHandler,\n direction: directionFormatHandler,\n display: displayFormatHandler,\n float: floatFormatHandler,\n fontFamily: fontFamilyFormatHandler,\n fontSize: fontSizeFormatHandler,\n entity: entityFormatHandler,\n htmlAlign: htmlAlignFormatHandler,\n id: idFormatHandler,\n italic: italicFormatHandler,\n letterSpacing: letterSpacingFormatHandler,\n lineHeight: lineHeightFormatHandler,\n link: linkFormatHandler,\n listItemThread: listItemThreadFormatHandler,\n listLevelThread: listLevelThreadFormatHandler,\n listStyle: listStyleFormatHandler,\n margin: marginFormatHandler,\n padding: paddingFormatHandler,\n size: sizeFormatHandler,\n strike: strikeFormatHandler,\n superOrSubScript: superOrSubScriptFormatHandler,\n tableLayout: tableLayoutFormatHandler,\n tableSpacing: tableSpacingFormatHandler,\n textAlign: textAlignFormatHandler,\n textColor: textColorFormatHandler,\n textColorOnTableCell: textColorOnTableCellFormatHandler,\n textIndent: textIndentFormatHandler,\n undeletableLink: undeletableLinkFormatHandler,\n underline: underlineFormatHandler,\n verticalAlign: verticalAlignFormatHandler,\n whiteSpace: whiteSpaceFormatHandler,\n wordBreak: wordBreakFormatHandler,\n};\n\nconst styleBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'letterSpacing',\n 'fontFamily',\n 'fontSize',\n];\n\nconst elementBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'strike',\n 'underline',\n 'superOrSubScript',\n 'italic',\n 'bold',\n];\nconst sharedBlockFormats: (keyof FormatHandlerTypeMap)[] = [\n 'direction',\n 'textAlign',\n 'textIndent',\n 'lineHeight',\n 'whiteSpace',\n];\nconst sharedContainerFormats: (keyof FormatHandlerTypeMap)[] = [\n 'backgroundColor',\n 'margin',\n 'padding',\n 'border',\n];\n\n/**\n * @internal\n */\nexport const defaultFormatKeysPerCategory: {\n [key in keyof ContentModelFormatMap]: (keyof FormatHandlerTypeMap)[];\n} = {\n block: sharedBlockFormats,\n listItemThread: ['listItemThread'],\n listLevelThread: ['listLevelThread'],\n listItemElement: [\n ...sharedBlockFormats,\n 'direction',\n 'textAlign',\n 'lineHeight',\n 'margin',\n 'listStyle',\n ],\n listLevel: ['direction', 'textAlign', 'margin', 'padding', 'listStyle', 'backgroundColor'],\n styleBasedSegment: [...styleBasedSegmentFormats, 'textColor', 'backgroundColor', 'lineHeight'],\n elementBasedSegment: elementBasedSegmentFormats,\n segment: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColor',\n 'backgroundColor',\n 'lineHeight',\n ],\n segmentOnBlock: [...styleBasedSegmentFormats, ...elementBasedSegmentFormats, 'textColor'],\n segmentOnTableCell: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColorOnTableCell',\n ],\n tableCell: [\n 'border',\n 'backgroundColor',\n 'padding',\n 'verticalAlign',\n 'wordBreak',\n 'textColor',\n 'htmlAlign',\n 'size',\n ],\n tableRow: ['backgroundColor'],\n tableColumn: ['size'],\n table: [\n 'aria',\n 'id',\n 'border',\n 'backgroundColor',\n 'display',\n 'htmlAlign',\n 'margin',\n 'size',\n 'tableLayout',\n 'textColor',\n ],\n tableBorder: ['borderBox', 'tableSpacing'],\n tableCellBorder: ['borderBox'],\n image: [\n 'id',\n 'size',\n 'margin',\n 'padding',\n 'borderBox',\n 'border',\n 'boxShadow',\n 'display',\n 'float',\n 'verticalAlign',\n ],\n link: [\n 'link',\n 'textColor',\n 'underline',\n 'display',\n 'margin',\n 'padding',\n 'backgroundColor',\n 'border',\n 'size',\n 'textAlign',\n 'undeletableLink',\n ],\n segmentUnderLink: ['textColor'],\n code: ['fontFamily', 'display'],\n dataset: ['dataset'],\n divider: [...sharedBlockFormats, ...sharedContainerFormats, 'display', 'size', 'htmlAlign'],\n container: [...sharedContainerFormats, 'htmlAlign', 'size', 'display'],\n entity: ['entity'],\n general: ['textColor', 'backgroundColor'], // General model still need to do color transformation in dark mode\n};\n\n/**\n * @internal\n */\nexport const defaultFormatParsers: FormatParsers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].parse as FormatParser<any>;\n return result;\n },\n <FormatParsers>{}\n);\n\n/**\n * @internal\n */\nexport const defaultFormatAppliers: FormatAppliers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].apply as FormatApplier<any>;\n return result;\n },\n <FormatAppliers>{}\n);\n"]}
|
|
1
|
+
{"version":3,"file":"defaultFormatHandlers.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/defaultFormatHandlers.ts"],"names":[],"mappings":";;;;AAAA,gEAA+D;AAC/D,sFAAqF;AACrF,iEAAgE;AAChE,0EAAyE;AACzE,oEAAmE;AACnE,0EAAyE;AACzE,sEAAqE;AACrE,yEAAwE;AACxE,qEAAoE;AACpE,oEAAmE;AACnE,kEAAiE;AACjE,6EAA4E;AAC5E,yEAAwE;AACxE,2DAA0D;AAC1D,yEAAwE;AACxE,4DAA2D;AAC3D,6EAA4E;AAC5E,qEAAoE;AACpE,mFAAkF;AAClF,2EAA0E;AAC1E,iEAAgE;AAChE,kFAAiF;AACjF,oFAAmF;AACnF,wEAAuE;AACvE,mEAAkE;AAClE,qEAAoE;AACpE,gEAA+D;AAC/D,qEAAoE;AACpE,yFAAwF;AACxF,6EAA4E;AAC5E,+EAA8E;AAC9E,yEAAwE;AACxE,2EAA0E;AAC1E,+FAA8F;AAC9F,2EAA0E;AAC1E,uFAAsF;AACtF,2EAA0E;AAC1E,kFAAiF;AACjF,2EAA0E;AAC1E,0EAAyE;AAgBzE,IAAM,uBAAuB,GAAmB;IAC5C,IAAI,EAAE,qCAAiB;IACvB,eAAe,EAAE,2DAA4B;IAC7C,IAAI,EAAE,qCAAiB;IACvB,MAAM,EAAE,yCAAmB;IAC3B,SAAS,EAAE,+CAAsB;IACjC,SAAS,EAAE,+CAAsB;IACjC,OAAO,EAAE,2CAAoB;IAC7B,SAAS,EAAE,+CAAsB;IACjC,OAAO,EAAE,2CAAoB;IAC7B,KAAK,EAAE,uCAAkB;IACzB,UAAU,EAAE,iDAAuB;IACnC,QAAQ,EAAE,6CAAqB;IAC/B,MAAM,EAAE,yCAAmB;IAC3B,SAAS,EAAE,+CAAsB;IACjC,EAAE,EAAE,iCAAe;IACnB,UAAU,EAAE,iDAAuB;IACnC,MAAM,EAAE,yCA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,2GAAM,kBAAkB,+BAAK,sBAAsB,YAAE,SAAS,EAAE,MAAM,EAAE,WAAW,SAAC;IAC3F,SAAS,gFAAM,sBAAsB,YAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,SAAC;IAC5E,MAAM,EAAE,CAAC,QAAQ,CAAC;IAClB,OAAO,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,EAAE,mEAAmE;CACjH,CAAC;AAEF;;GAEG;AACU,QAAA,oBAAoB,GAAkB,IAAA,6BAAa,EAAC,uBAAuB,CAAC,CAAC,MAAM,CAC5F,UAAC,MAAM,EAAE,GAAG;IACR,MAAM,CAAC,GAAG,CAAC,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,KAA0B,CAAC;IACtE,OAAO,MAAM,CAAC;AAClB,CAAC,EACc,EAAE,CACpB,CAAC;AAEF;;GAEG;AACU,QAAA,qBAAqB,GAAmB,IAAA,6BAAa,EAAC,uBAAuB,CAAC,CAAC,MAAM,CAC9F,UAAC,MAAM,EAAE,GAAG;IACR,MAAM,CAAC,GAAG,CAAC,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,KAA2B,CAAC;IACvE,OAAO,MAAM,CAAC;AAClB,CAAC,EACe,EAAE,CACrB,CAAC","sourcesContent":["import { ariaFormatHandler } from './common/ariaFormatHandler';\nimport { backgroundColorFormatHandler } from './common/backgroundColorFormatHandler';\nimport { boldFormatHandler } from './segment/boldFormatHandler';\nimport { borderBoxFormatHandler } from './common/borderBoxFormatHandler';\nimport { borderFormatHandler } from './common/borderFormatHandler';\nimport { boxShadowFormatHandler } from './common/boxShadowFormatHandler';\nimport { datasetFormatHandler } from './common/datasetFormatHandler';\nimport { directionFormatHandler } from './block/directionFormatHandler';\nimport { displayFormatHandler } from './block/displayFormatHandler';\nimport { entityFormatHandler } from './entity/entityFormatHandler';\nimport { floatFormatHandler } from './common/floatFormatHandler';\nimport { fontFamilyFormatHandler } from './segment/fontFamilyFormatHandler';\nimport { fontSizeFormatHandler } from './segment/fontSizeFormatHandler';\nimport { getObjectKeys } from '../domUtils/getObjectKeys';\nimport { htmlAlignFormatHandler } from './block/htmlAlignFormatHandler';\nimport { idFormatHandler } from './common/idFormatHandler';\nimport { imageStateFormatHandler } from './segment/imageStateFormatHandler';\nimport { italicFormatHandler } from './segment/italicFormatHandler';\nimport { letterSpacingFormatHandler } from './segment/letterSpacingFormatHandler';\nimport { lineHeightFormatHandler } from './block/lineHeightFormatHandler';\nimport { linkFormatHandler } from './segment/linkFormatHandler';\nimport { listItemThreadFormatHandler } from './list/listItemThreadFormatHandler';\nimport { listLevelThreadFormatHandler } from './list/listLevelThreadFormatHandler';\nimport { listStyleFormatHandler } from './list/listStyleFormatHandler';\nimport { marginFormatHandler } from './block/marginFormatHandler';\nimport { paddingFormatHandler } from './block/paddingFormatHandler';\nimport { sizeFormatHandler } from './common/sizeFormatHandler';\nimport { strikeFormatHandler } from './segment/strikeFormatHandler';\nimport { superOrSubScriptFormatHandler } from './segment/superOrSubScriptFormatHandler';\nimport { tableLayoutFormatHandler } from './table/tableLayoutFormatHandler';\nimport { tableSpacingFormatHandler } from './table/tableSpacingFormatHandler';\nimport { textAlignFormatHandler } from './block/textAlignFormatHandler';\nimport { textColorFormatHandler } from './segment/textColorFormatHandler';\nimport { textColorOnTableCellFormatHandler } from './table/textColorOnTableCellFormatHandler';\nimport { textIndentFormatHandler } from './block/textIndentFormatHandler';\nimport { undeletableLinkFormatHandler } from './segment/undeletableLinkFormatHandler';\nimport { underlineFormatHandler } from './segment/underlineFormatHandler';\nimport { verticalAlignFormatHandler } from './common/verticalAlignFormatHandler';\nimport { whiteSpaceFormatHandler } from './block/whiteSpaceFormatHandler';\nimport { wordBreakFormatHandler } from './common/wordBreakFormatHandler';\nimport type { FormatHandler } from './FormatHandler';\nimport type {\n ContentModelFormatMap,\n FormatApplier,\n FormatAppliers,\n FormatHandlerTypeMap,\n FormatKey,\n FormatParser,\n FormatParsers,\n} from 'roosterjs-content-model-types';\n\ntype FormatHandlers = {\n [Key in FormatKey]: FormatHandler<FormatHandlerTypeMap[Key]>;\n};\n\nconst defaultFormatHandlerMap: FormatHandlers = {\n aria: ariaFormatHandler,\n backgroundColor: backgroundColorFormatHandler,\n bold: boldFormatHandler,\n border: borderFormatHandler,\n borderBox: borderBoxFormatHandler,\n boxShadow: boxShadowFormatHandler,\n dataset: datasetFormatHandler,\n direction: directionFormatHandler,\n display: displayFormatHandler,\n float: floatFormatHandler,\n fontFamily: fontFamilyFormatHandler,\n fontSize: fontSizeFormatHandler,\n entity: entityFormatHandler,\n htmlAlign: htmlAlignFormatHandler,\n id: idFormatHandler,\n imageState: imageStateFormatHandler,\n italic: italicFormatHandler,\n letterSpacing: letterSpacingFormatHandler,\n lineHeight: lineHeightFormatHandler,\n link: linkFormatHandler,\n listItemThread: listItemThreadFormatHandler,\n listLevelThread: listLevelThreadFormatHandler,\n listStyle: listStyleFormatHandler,\n margin: marginFormatHandler,\n padding: paddingFormatHandler,\n size: sizeFormatHandler,\n strike: strikeFormatHandler,\n superOrSubScript: superOrSubScriptFormatHandler,\n tableLayout: tableLayoutFormatHandler,\n tableSpacing: tableSpacingFormatHandler,\n textAlign: textAlignFormatHandler,\n textColor: textColorFormatHandler,\n textColorOnTableCell: textColorOnTableCellFormatHandler,\n textIndent: textIndentFormatHandler,\n undeletableLink: undeletableLinkFormatHandler,\n underline: underlineFormatHandler,\n verticalAlign: verticalAlignFormatHandler,\n whiteSpace: whiteSpaceFormatHandler,\n wordBreak: wordBreakFormatHandler,\n};\n\nconst styleBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'letterSpacing',\n 'fontFamily',\n 'fontSize',\n];\n\nconst elementBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'strike',\n 'underline',\n 'superOrSubScript',\n 'italic',\n 'bold',\n];\nconst sharedBlockFormats: (keyof FormatHandlerTypeMap)[] = [\n 'direction',\n 'textAlign',\n 'textIndent',\n 'lineHeight',\n 'whiteSpace',\n];\nconst sharedContainerFormats: (keyof FormatHandlerTypeMap)[] = [\n 'backgroundColor',\n 'margin',\n 'padding',\n 'border',\n];\n\n/**\n * @internal\n */\nexport const defaultFormatKeysPerCategory: {\n [key in keyof ContentModelFormatMap]: (keyof FormatHandlerTypeMap)[];\n} = {\n block: sharedBlockFormats,\n listItemThread: ['listItemThread'],\n listLevelThread: ['listLevelThread'],\n listItemElement: [\n ...sharedBlockFormats,\n 'direction',\n 'textAlign',\n 'lineHeight',\n 'margin',\n 'listStyle',\n ],\n listLevel: ['direction', 'textAlign', 'margin', 'padding', 'listStyle', 'backgroundColor'],\n styleBasedSegment: [...styleBasedSegmentFormats, 'textColor', 'backgroundColor', 'lineHeight'],\n elementBasedSegment: elementBasedSegmentFormats,\n segment: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColor',\n 'backgroundColor',\n 'lineHeight',\n ],\n segmentOnBlock: [...styleBasedSegmentFormats, ...elementBasedSegmentFormats, 'textColor'],\n segmentOnTableCell: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColorOnTableCell',\n ],\n tableCell: [\n 'border',\n 'backgroundColor',\n 'padding',\n 'verticalAlign',\n 'wordBreak',\n 'textColor',\n 'htmlAlign',\n 'size',\n ],\n tableRow: ['backgroundColor'],\n tableColumn: ['size'],\n table: [\n 'aria',\n 'id',\n 'border',\n 'backgroundColor',\n 'display',\n 'htmlAlign',\n 'margin',\n 'size',\n 'tableLayout',\n 'textColor',\n ],\n tableBorder: ['borderBox', 'tableSpacing'],\n tableCellBorder: ['borderBox'],\n image: [\n 'id',\n 'size',\n 'margin',\n 'padding',\n 'borderBox',\n 'border',\n 'boxShadow',\n 'display',\n 'float',\n 'verticalAlign',\n 'imageState',\n ],\n link: [\n 'link',\n 'textColor',\n 'underline',\n 'display',\n 'margin',\n 'padding',\n 'backgroundColor',\n 'border',\n 'size',\n 'textAlign',\n 'undeletableLink',\n ],\n segmentUnderLink: ['textColor'],\n code: ['fontFamily', 'display'],\n dataset: ['dataset'],\n divider: [...sharedBlockFormats, ...sharedContainerFormats, 'display', 'size', 'htmlAlign'],\n container: [...sharedContainerFormats, 'htmlAlign', 'size', 'display', 'id'],\n entity: ['entity'],\n general: ['textColor', 'backgroundColor'], // General model still need to do color transformation in dark mode\n};\n\n/**\n * @internal\n */\nexport const defaultFormatParsers: FormatParsers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].parse as FormatParser<any>;\n return result;\n },\n <FormatParsers>{}\n);\n\n/**\n * @internal\n */\nexport const defaultFormatAppliers: FormatAppliers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].apply as FormatApplier<any>;\n return result;\n },\n <FormatAppliers>{}\n);\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageStateFormatHandler = void 0;
|
|
4
|
+
var imageState_1 = require("../../domUtils/hiddenProperties/imageState");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
exports.imageStateFormatHandler = {
|
|
9
|
+
parse: function (format, element) {
|
|
10
|
+
var marker = (0, imageState_1.getImageState)(element);
|
|
11
|
+
if (marker) {
|
|
12
|
+
format.imageState = marker;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
apply: function (format, element) {
|
|
16
|
+
if (format.imageState) {
|
|
17
|
+
(0, imageState_1.setImageState)(element, format.imageState);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=imageStateFormatHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageStateFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/imageStateFormatHandler.ts"],"names":[],"mappings":";;;AAAA,yEAA0F;AAI1F;;GAEG;AACU,QAAA,uBAAuB,GAAoC;IACpE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAM,MAAM,GAAG,IAAA,0BAAa,EAAC,OAAO,CAAC,CAAC;QACtC,IAAI,MAAM,EAAE;YACR,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;SAC9B;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,MAAM,CAAC,UAAU,EAAE;YACnB,IAAA,0BAAa,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;SAC7C;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { getImageState, setImageState } from '../../domUtils/hiddenProperties/imageState';\nimport type { ImageStateFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const imageStateFormatHandler: FormatHandler<ImageStateFormat> = {\n parse: (format, element) => {\n const marker = getImageState(element);\n if (marker) {\n format.imageState = marker;\n }\n },\n apply: (format, element) => {\n if (format.imageState) {\n setImageState(element, format.imageState);\n }\n },\n};\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -54,7 +54,9 @@ export { addSegment } from './modelApi/common/addSegment';
|
|
|
54
54
|
export { isEmpty } from './modelApi/common/isEmpty';
|
|
55
55
|
export { normalizeSingleSegment } from './modelApi/common/normalizeSegment';
|
|
56
56
|
export { mergeTextSegments } from './modelApi/common/mergeTextSegments';
|
|
57
|
+
export { normalizeSegmentFormat } from './modelApi/common/normalizeSegmentFormat';
|
|
57
58
|
export { setParagraphNotImplicit } from './modelApi/block/setParagraphNotImplicit';
|
|
59
|
+
export { copyFormat, ListFormats, ListFormatsToKeep, ListFormatsToMove, ParagraphFormats, } from './modelApi/block/copyFormat';
|
|
58
60
|
export { getOrderedListNumberStr } from './modelApi/list/getOrderedListNumberStr';
|
|
59
61
|
export { getAutoListStyleType } from './modelApi/list/getAutoListStyleType';
|
|
60
62
|
export { parseValueWithUnit } from './formatHandlers/utils/parseValueWithUnit';
|
|
@@ -71,9 +73,11 @@ export { isPunctuation, isSpace, normalizeText } from './domUtils/stringUtil';
|
|
|
71
73
|
export { parseTableCells } from './domUtils/table/parseTableCells';
|
|
72
74
|
export { readFile } from './domUtils/readFile';
|
|
73
75
|
export { transformColor } from './domUtils/style/transformColor';
|
|
76
|
+
export { normalizeFontFamily } from './domUtils/style/normalizeFontFamily';
|
|
74
77
|
export { extractClipboardItems } from './domUtils/event/extractClipboardItems';
|
|
75
78
|
export { cacheGetEventData } from './domUtils/event/cacheGetEventData';
|
|
76
79
|
export { setParagraphMarker, getParagraphMarker, } from './domUtils/hiddenProperties/paragraphMarker';
|
|
80
|
+
export { setImageState, getImageState } from './domUtils/hiddenProperties/imageState';
|
|
77
81
|
export { isBlockGroupOfType } from './modelApi/typeCheck/isBlockGroupOfType';
|
|
78
82
|
export { iterateSelections } from './modelApi/selection/iterateSelections';
|
|
79
83
|
export { getFirstSelectedListItem, getFirstSelectedTable, getOperationalBlocks, getSelectedParagraphs, getSelectedSegments, getSelectedSegmentsAndParagraphs, } from './modelApi/selection/collectSelections';
|