roosterjs-content-model-dom 0.18.0 → 0.20.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.
@@ -2,7 +2,7 @@ import type { ElementProcessor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  * @param group
5
- * @param element
5
+ * @param node
6
6
  * @param context
7
7
  */
8
8
  export declare const delimiterProcessor: ElementProcessor<Node>;
@@ -1,24 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.delimiterProcessor = void 0;
4
- var tslib_1 = require("tslib");
5
- var getRegularSelectionOffsets_1 = require("../utils/getRegularSelectionOffsets");
6
- var childProcessor_1 = require("./childProcessor");
4
+ var addSelectionMarker_1 = require("../utils/addSelectionMarker");
7
5
  /**
8
6
  * @internal
9
7
  * @param group
10
- * @param element
8
+ * @param node
11
9
  * @param context
12
10
  */
13
- var delimiterProcessor = function (group, element, context) {
14
- var index = 0;
15
- var _a = (0, tslib_1.__read)((0, getRegularSelectionOffsets_1.getRegularSelectionOffsets)(context, element), 2), nodeStartOffset = _a[0], nodeEndOffset = _a[1];
16
- for (var child = element.firstChild; child; child = child.nextSibling) {
17
- (0, childProcessor_1.handleRegularSelection)(index, context, group, nodeStartOffset, nodeEndOffset);
18
- (0, exports.delimiterProcessor)(group, child, context);
19
- index++;
11
+ var delimiterProcessor = function (group, node, context) {
12
+ var _a, _b;
13
+ var range = ((_a = context.selection) === null || _a === void 0 ? void 0 : _a.type) == 'range' ? context.selection.range : null;
14
+ if (range) {
15
+ if (node.contains(range.startContainer)) {
16
+ context.isInSelection = true;
17
+ (0, addSelectionMarker_1.addSelectionMarker)(group, context);
18
+ }
19
+ if (((_b = context.selection) === null || _b === void 0 ? void 0 : _b.type) == 'range' && node.contains(range.endContainer)) {
20
+ if (!context.selection.range.collapsed) {
21
+ (0, addSelectionMarker_1.addSelectionMarker)(group, context);
22
+ }
23
+ context.isInSelection = false;
24
+ }
20
25
  }
21
- (0, childProcessor_1.handleRegularSelection)(index, context, group, nodeStartOffset, nodeEndOffset);
22
26
  };
23
27
  exports.delimiterProcessor = delimiterProcessor;
24
28
  //# sourceMappingURL=delimiterProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delimiterProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.ts"],"names":[],"mappings":";;;;AAAA,kFAAiF;AACjF,mDAA0D;AAG1D;;;;;GAKG;AACI,IAAM,kBAAkB,GAA2B,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;IAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;IACR,IAAA,KAAA,oBAAmC,IAAA,uDAA0B,EAAC,OAAO,EAAE,OAAO,CAAC,IAAA,EAA9E,eAAe,QAAA,EAAE,aAAa,QAAgD,CAAC;IAEtF,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE;QACnE,IAAA,uCAAsB,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;QAE9E,IAAA,0BAAkB,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,KAAK,EAAE,CAAC;KACX;IAED,IAAA,uCAAsB,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;AAClF,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B","sourcesContent":["import { getRegularSelectionOffsets } from '../utils/getRegularSelectionOffsets';\nimport { handleRegularSelection } from './childProcessor';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @param group\n * @param element\n * @param context\n */\nexport const delimiterProcessor: ElementProcessor<Node> = (group, element, context) => {\n let index = 0;\n const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, element);\n\n for (let child = element.firstChild; child; child = child.nextSibling) {\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n\n delimiterProcessor(group, child, context);\n index++;\n }\n\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n};\n"]}
1
+ {"version":3,"file":"delimiterProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AAGjE;;;;;GAKG;AACI,IAAM,kBAAkB,GAA2B,UAAC,KAAK,EAAE,IAAI,EAAE,OAAO;;IAC3E,IAAM,KAAK,GAAG,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAElF,IAAI,KAAK,EAAE;QACP,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YACrC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;YAE7B,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SACtC;QAED,IAAI,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;YACzE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;gBACpC,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aACtC;YAED,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC;SACjC;KACJ;AACL,CAAC,CAAC;AAlBW,QAAA,kBAAkB,sBAkB7B","sourcesContent":["import { addSelectionMarker } from '../utils/addSelectionMarker';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @param group\n * @param node\n * @param context\n */\nexport const delimiterProcessor: ElementProcessor<Node> = (group, node, context) => {\n const range = context.selection?.type == 'range' ? context.selection.range : null;\n\n if (range) {\n if (node.contains(range.startContainer)) {\n context.isInSelection = true;\n\n addSelectionMarker(group, context);\n }\n\n if (context.selection?.type == 'range' && node.contains(range.endContainer)) {\n if (!context.selection.range.collapsed) {\n addSelectionMarker(group, context);\n }\n\n context.isInSelection = false;\n }\n }\n};\n"]}
@@ -32,6 +32,16 @@ exports.marginFormatHandler = {
32
32
  }
33
33
  }
34
34
  });
35
+ var marginBlockStart = element.style.marginBlockStart || defaultStyle.marginBlockStart;
36
+ var marginTop = element.style.marginTop || defaultStyle.marginTop;
37
+ if (marginBlockStart && !marginTop) {
38
+ format.marginBlockStart = (0, parseValueWithUnit_1.parseValueWithUnit)(marginBlockStart) + 'px';
39
+ }
40
+ var marginBlockEnd = element.style.marginBlockEnd || defaultStyle.marginBlockEnd;
41
+ var marginBottom = element.style.marginBottom || defaultStyle.marginBottom;
42
+ if (marginBlockEnd && !marginBottom) {
43
+ format.marginBlockEnd = (0, parseValueWithUnit_1.parseValueWithUnit)(marginBlockEnd) + 'px';
44
+ }
35
45
  },
36
46
  apply: function (format, element, context) {
37
47
  MarginKeys.forEach(function (key) {
@@ -40,6 +50,12 @@ exports.marginFormatHandler = {
40
50
  element.style[key] = value || '0';
41
51
  }
42
52
  });
53
+ if (format.marginBlockStart && !format.marginTop) {
54
+ element.style.marginBlockStart = format.marginBlockStart;
55
+ }
56
+ if (format.marginBlockEnd && !format.marginBottom) {
57
+ element.style.marginBlockEnd = format.marginBlockEnd;
58
+ }
43
59
  },
44
60
  };
45
61
  //# sourceMappingURL=marginFormatHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/block/marginFormatHandler.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AAIjE,IAAM,UAAU,GAAuD;IACnE,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;CACf,CAAC;AAEF;;GAEG;AACU,QAAA,mBAAmB,GAAgC;IAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;YAEtD,IAAI,KAAK,EAAE;gBACP,QAAQ,GAAG,EAAE;oBACT,KAAK,WAAW,CAAC;oBACjB,KAAK,cAAc;wBACf,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;wBACpB,MAAM;oBAEV,KAAK,YAAY,CAAC;oBAClB,KAAK,aAAa;wBACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;4BACrB,CAAC,CAAC,IAAA,uCAAkB,EAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC;gCAC9C,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC;gCAClC,IAAI;4BACN,CAAC,CAAC,KAAK,CAAC;wBACZ,MAAM;iBACb;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC;aACrC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const value = element.style[key] || defaultStyle[key];\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\n if (value != context.implicitFormat[key]) {\n element.style[key] = value || '0';\n }\n });\n },\n};\n"]}
1
+ {"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/block/marginFormatHandler.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AAIjE,IAAM,UAAU,GAAuD;IACnE,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;CACf,CAAC;AAEF;;GAEG;AACU,QAAA,mBAAmB,GAAgC;IAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;YAEtD,IAAI,KAAK,EAAE;gBACP,QAAQ,GAAG,EAAE;oBACT,KAAK,WAAW,CAAC;oBACjB,KAAK,cAAc;wBACf,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;wBACpB,MAAM;oBAEV,KAAK,YAAY,CAAC;oBAClB,KAAK,aAAa;wBACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAA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AAM,CAAC,SAAS,EAAE;YAC9C,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;SAC5D;QAED,IAAI,MAAM,CAAC,cAAc,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;YAC/C,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;SACxD;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const value = element.style[key] || defaultStyle[key];\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 const marginBlockStart = element.style.marginBlockStart || defaultStyle.marginBlockStart;\n const marginTop = element.style.marginTop || defaultStyle.marginTop;\n if (marginBlockStart && !marginTop) {\n format.marginBlockStart = parseValueWithUnit(marginBlockStart) + 'px';\n }\n\n const marginBlockEnd = element.style.marginBlockEnd || defaultStyle.marginBlockEnd;\n const marginBottom = element.style.marginBottom || defaultStyle.marginBottom;\n if (marginBlockEnd && !marginBottom) {\n format.marginBlockEnd = parseValueWithUnit(marginBlockEnd) + 'px';\n }\n },\n apply: (format, element, context) => {\n MarginKeys.forEach(key => {\n const value = format[key];\n\n if (value != context.implicitFormat[key]) {\n element.style[key] = value || '0';\n }\n });\n\n if (format.marginBlockStart && !format.marginTop) {\n element.style.marginBlockStart = format.marginBlockStart;\n }\n\n if (format.marginBlockEnd && !format.marginBottom) {\n element.style.marginBlockEnd = format.marginBlockEnd;\n }\n },\n};\n"]}
@@ -2,7 +2,7 @@ import type { ElementProcessor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  * @param group
5
- * @param element
5
+ * @param node
6
6
  * @param context
7
7
  */
8
8
  export declare const delimiterProcessor: ElementProcessor<Node>;
@@ -1,22 +1,28 @@
1
- define(["require", "exports", "tslib", "../utils/getRegularSelectionOffsets", "./childProcessor"], function (require, exports, tslib_1, getRegularSelectionOffsets_1, childProcessor_1) {
1
+ define(["require", "exports", "../utils/addSelectionMarker"], function (require, exports, addSelectionMarker_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.delimiterProcessor = void 0;
5
5
  /**
6
6
  * @internal
7
7
  * @param group
8
- * @param element
8
+ * @param node
9
9
  * @param context
10
10
  */
11
- var delimiterProcessor = function (group, element, context) {
12
- var index = 0;
13
- var _a = (0, tslib_1.__read)((0, getRegularSelectionOffsets_1.getRegularSelectionOffsets)(context, element), 2), nodeStartOffset = _a[0], nodeEndOffset = _a[1];
14
- for (var child = element.firstChild; child; child = child.nextSibling) {
15
- (0, childProcessor_1.handleRegularSelection)(index, context, group, nodeStartOffset, nodeEndOffset);
16
- (0, exports.delimiterProcessor)(group, child, context);
17
- index++;
11
+ var delimiterProcessor = function (group, node, context) {
12
+ var _a, _b;
13
+ var range = ((_a = context.selection) === null || _a === void 0 ? void 0 : _a.type) == 'range' ? context.selection.range : null;
14
+ if (range) {
15
+ if (node.contains(range.startContainer)) {
16
+ context.isInSelection = true;
17
+ (0, addSelectionMarker_1.addSelectionMarker)(group, context);
18
+ }
19
+ if (((_b = context.selection) === null || _b === void 0 ? void 0 : _b.type) == 'range' && node.contains(range.endContainer)) {
20
+ if (!context.selection.range.collapsed) {
21
+ (0, addSelectionMarker_1.addSelectionMarker)(group, context);
22
+ }
23
+ context.isInSelection = false;
24
+ }
18
25
  }
19
- (0, childProcessor_1.handleRegularSelection)(index, context, group, nodeStartOffset, nodeEndOffset);
20
26
  };
21
27
  exports.delimiterProcessor = delimiterProcessor;
22
28
  });
@@ -1 +1 @@
1
- {"version":3,"file":"delimiterProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.ts"],"names":[],"mappings":";;;;IAIA;;;;;OAKG;IACI,IAAM,kBAAkB,GAA2B,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;QAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;QACR,IAAA,KAAA,oBAAmC,IAAA,uDAA0B,EAAC,OAAO,EAAE,OAAO,CAAC,IAAA,EAA9E,eAAe,QAAA,EAAE,aAAa,QAAgD,CAAC;QAEtF,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE;YACnE,IAAA,uCAAsB,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;YAE9E,IAAA,0BAAkB,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAC1C,KAAK,EAAE,CAAC;SACX;QAED,IAAA,uCAAsB,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;IAClF,CAAC,CAAC;IAZW,QAAA,kBAAkB,sBAY7B","sourcesContent":["import { getRegularSelectionOffsets } from '../utils/getRegularSelectionOffsets';\nimport { handleRegularSelection } from './childProcessor';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @param group\n * @param element\n * @param context\n */\nexport const delimiterProcessor: ElementProcessor<Node> = (group, element, context) => {\n let index = 0;\n const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, element);\n\n for (let child = element.firstChild; child; child = child.nextSibling) {\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n\n delimiterProcessor(group, child, context);\n index++;\n }\n\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n};\n"]}
1
+ {"version":3,"file":"delimiterProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,kBAAkB,GAA2B,UAAC,KAAK,EAAE,IAAI,EAAE,OAAO;;QAC3E,IAAM,KAAK,GAAG,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAElF,IAAI,KAAK,EAAE;YACP,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;gBACrC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;gBAE7B,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aACtC;YAED,IAAI,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;gBACzE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;oBACpC,IAAA,uCAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBACtC;gBAED,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC;aACjC;SACJ;IACL,CAAC,CAAC;IAlBW,QAAA,kBAAkB,sBAkB7B","sourcesContent":["import { addSelectionMarker } from '../utils/addSelectionMarker';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @param group\n * @param node\n * @param context\n */\nexport const delimiterProcessor: ElementProcessor<Node> = (group, node, context) => {\n const range = context.selection?.type == 'range' ? context.selection.range : null;\n\n if (range) {\n if (node.contains(range.startContainer)) {\n context.isInSelection = true;\n\n addSelectionMarker(group, context);\n }\n\n if (context.selection?.type == 'range' && node.contains(range.endContainer)) {\n if (!context.selection.range.collapsed) {\n addSelectionMarker(group, context);\n }\n\n context.isInSelection = false;\n }\n }\n};\n"]}
@@ -32,6 +32,16 @@ define(["require", "exports", "../utils/parseValueWithUnit"], function (require,
32
32
  }
33
33
  }
34
34
  });
35
+ var marginBlockStart = element.style.marginBlockStart || defaultStyle.marginBlockStart;
36
+ var marginTop = element.style.marginTop || defaultStyle.marginTop;
37
+ if (marginBlockStart && !marginTop) {
38
+ format.marginBlockStart = (0, parseValueWithUnit_1.parseValueWithUnit)(marginBlockStart) + 'px';
39
+ }
40
+ var marginBlockEnd = element.style.marginBlockEnd || defaultStyle.marginBlockEnd;
41
+ var marginBottom = element.style.marginBottom || defaultStyle.marginBottom;
42
+ if (marginBlockEnd && !marginBottom) {
43
+ format.marginBlockEnd = (0, parseValueWithUnit_1.parseValueWithUnit)(marginBlockEnd) + 'px';
44
+ }
35
45
  },
36
46
  apply: function (format, element, context) {
37
47
  MarginKeys.forEach(function (key) {
@@ -40,6 +50,12 @@ define(["require", "exports", "../utils/parseValueWithUnit"], function (require,
40
50
  element.style[key] = value || '0';
41
51
  }
42
52
  });
53
+ if (format.marginBlockStart && !format.marginTop) {
54
+ element.style.marginBlockStart = format.marginBlockStart;
55
+ }
56
+ if (format.marginBlockEnd && !format.marginBottom) {
57
+ element.style.marginBlockEnd = format.marginBlockEnd;
58
+ }
43
59
  },
44
60
  };
45
61
  });
@@ -1 +1 @@
1
- {"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/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;;OAEG;IACU,QAAA,mBAAmB,GAAgC;QAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;YACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;gBAEtD,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;gBAE1B,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACtC,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 { MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const value = element.style[key] || defaultStyle[key];\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\n if (value != context.implicitFormat[key]) {\n element.style[key] = value || '0';\n }\n });\n },\n};\n"]}
1
+ {"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/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;;OAEG;IACU,QAAA,mBAAmB,GAAgC;QAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;YACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;gBAEtD,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,C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gB,GAAG,MAAM,CAAC,gBAAgB,CAAC;aAC5D;YAED,IAAI,MAAM,CAAC,cAAc,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;gBAC/C,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;aACxD;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const value = element.style[key] || defaultStyle[key];\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 const marginBlockStart = element.style.marginBlockStart || defaultStyle.marginBlockStart;\n const marginTop = element.style.marginTop || defaultStyle.marginTop;\n if (marginBlockStart && !marginTop) {\n format.marginBlockStart = parseValueWithUnit(marginBlockStart) + 'px';\n }\n\n const marginBlockEnd = element.style.marginBlockEnd || defaultStyle.marginBlockEnd;\n const marginBottom = element.style.marginBottom || defaultStyle.marginBottom;\n if (marginBlockEnd && !marginBottom) {\n format.marginBlockEnd = parseValueWithUnit(marginBlockEnd) + 'px';\n }\n },\n apply: (format, element, context) => {\n MarginKeys.forEach(key => {\n const value = format[key];\n\n if (value != context.implicitFormat[key]) {\n element.style[key] = value || '0';\n }\n });\n\n if (format.marginBlockStart && !format.marginTop) {\n element.style.marginBlockStart = format.marginBlockStart;\n }\n\n if (format.marginBlockEnd && !format.marginBottom) {\n element.style.marginBlockEnd = format.marginBlockEnd;\n }\n },\n};\n"]}
@@ -2,7 +2,7 @@ import type { ElementProcessor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  * @param group
5
- * @param element
5
+ * @param node
6
6
  * @param context
7
7
  */
8
8
  export declare const delimiterProcessor: ElementProcessor<Node>;
@@ -1,20 +1,24 @@
1
- import { __read } from "tslib";
2
- import { getRegularSelectionOffsets } from '../utils/getRegularSelectionOffsets';
3
- import { handleRegularSelection } from './childProcessor';
1
+ import { addSelectionMarker } from '../utils/addSelectionMarker';
4
2
  /**
5
3
  * @internal
6
4
  * @param group
7
- * @param element
5
+ * @param node
8
6
  * @param context
9
7
  */
10
- export var delimiterProcessor = function (group, element, context) {
11
- var index = 0;
12
- var _a = __read(getRegularSelectionOffsets(context, element), 2), nodeStartOffset = _a[0], nodeEndOffset = _a[1];
13
- for (var child = element.firstChild; child; child = child.nextSibling) {
14
- handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);
15
- delimiterProcessor(group, child, context);
16
- index++;
8
+ export var delimiterProcessor = function (group, node, context) {
9
+ var _a, _b;
10
+ var range = ((_a = context.selection) === null || _a === void 0 ? void 0 : _a.type) == 'range' ? context.selection.range : null;
11
+ if (range) {
12
+ if (node.contains(range.startContainer)) {
13
+ context.isInSelection = true;
14
+ addSelectionMarker(group, context);
15
+ }
16
+ if (((_b = context.selection) === null || _b === void 0 ? void 0 : _b.type) == 'range' && node.contains(range.endContainer)) {
17
+ if (!context.selection.range.collapsed) {
18
+ addSelectionMarker(group, context);
19
+ }
20
+ context.isInSelection = false;
21
+ }
17
22
  }
18
- handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);
19
23
  };
20
24
  //# sourceMappingURL=delimiterProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delimiterProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D;;;;;GAKG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAA2B,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;IAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;IACR,IAAA,KAAA,OAAmC,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,IAAA,EAA9E,eAAe,QAAA,EAAE,aAAa,QAAgD,CAAC;IAEtF,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE;QACnE,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;QAE9E,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,KAAK,EAAE,CAAC;KACX;IAED,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;AAClF,CAAC,CAAC","sourcesContent":["import { getRegularSelectionOffsets } from '../utils/getRegularSelectionOffsets';\nimport { handleRegularSelection } from './childProcessor';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @param group\n * @param element\n * @param context\n */\nexport const delimiterProcessor: ElementProcessor<Node> = (group, element, context) => {\n let index = 0;\n const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, element);\n\n for (let child = element.firstChild; child; child = child.nextSibling) {\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n\n delimiterProcessor(group, child, context);\n index++;\n }\n\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n};\n"]}
1
+ {"version":3,"file":"delimiterProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/delimiterProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;;;;GAKG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAA2B,UAAC,KAAK,EAAE,IAAI,EAAE,OAAO;;IAC3E,IAAM,KAAK,GAAG,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAElF,IAAI,KAAK,EAAE;QACP,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YACrC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;YAE7B,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SACtC;QAED,IAAI,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;YACzE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;gBACpC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aACtC;YAED,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC;SACjC;KACJ;AACL,CAAC,CAAC","sourcesContent":["import { addSelectionMarker } from '../utils/addSelectionMarker';\nimport type { ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @param group\n * @param node\n * @param context\n */\nexport const delimiterProcessor: ElementProcessor<Node> = (group, node, context) => {\n const range = context.selection?.type == 'range' ? context.selection.range : null;\n\n if (range) {\n if (node.contains(range.startContainer)) {\n context.isInSelection = true;\n\n addSelectionMarker(group, context);\n }\n\n if (context.selection?.type == 'range' && node.contains(range.endContainer)) {\n if (!context.selection.range.collapsed) {\n addSelectionMarker(group, context);\n }\n\n context.isInSelection = false;\n }\n }\n};\n"]}
@@ -29,6 +29,16 @@ export var marginFormatHandler = {
29
29
  }
30
30
  }
31
31
  });
32
+ var marginBlockStart = element.style.marginBlockStart || defaultStyle.marginBlockStart;
33
+ var marginTop = element.style.marginTop || defaultStyle.marginTop;
34
+ if (marginBlockStart && !marginTop) {
35
+ format.marginBlockStart = parseValueWithUnit(marginBlockStart) + 'px';
36
+ }
37
+ var marginBlockEnd = element.style.marginBlockEnd || defaultStyle.marginBlockEnd;
38
+ var marginBottom = element.style.marginBottom || defaultStyle.marginBottom;
39
+ if (marginBlockEnd && !marginBottom) {
40
+ format.marginBlockEnd = parseValueWithUnit(marginBlockEnd) + 'px';
41
+ }
32
42
  },
33
43
  apply: function (format, element, context) {
34
44
  MarginKeys.forEach(function (key) {
@@ -37,6 +47,12 @@ export var marginFormatHandler = {
37
47
  element.style[key] = value || '0';
38
48
  }
39
49
  });
50
+ if (format.marginBlockStart && !format.marginTop) {
51
+ element.style.marginBlockStart = format.marginBlockStart;
52
+ }
53
+ if (format.marginBlockEnd && !format.marginBottom) {
54
+ element.style.marginBlockEnd = format.marginBlockEnd;
55
+ }
40
56
  },
41
57
  };
42
58
  //# sourceMappingURL=marginFormatHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/block/marginFormatHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAIjE,IAAM,UAAU,GAAuD;IACnE,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAgC;IAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;YAEtD,IAAI,KAAK,EAAE;gBACP,QAAQ,GAAG,EAAE;oBACT,KAAK,WAAW,CAAC;oBACjB,KAAK,cAAc;wBACf,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;wBACpB,MAAM;oBAEV,KAAK,YAAY,CAAC;oBAClB,KAAK,aAAa;wBACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;4BACrB,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC;gCAC9C,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC;gCAClC,IAAI;4BACN,CAAC,CAAC,KAAK,CAAC;wBACZ,MAAM;iBACb;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC;aACrC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const value = element.style[key] || defaultStyle[key];\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\n if (value != context.implicitFormat[key]) {\n element.style[key] = value || '0';\n }\n });\n },\n};\n"]}
1
+ {"version":3,"file":"marginFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/block/marginFormatHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAIjE,IAAM,UAAU,GAAuD;IACnE,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAgC;IAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;YAEtD,IAAI,KAAK,EAAE;gBACP,QAAQ,GAAG,EAAE;oBACT,KAAK,WAAW,CAAC;oBACjB,KAAK,cAAc;wBACf,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;wBACpB,MAAM;oBAEV,KAAK,YAAY,CAAC;oBAClB,KAAK,aAAa;wBACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;4BACrB,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC;gCAC9C,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC;gCAClC,IAAI;4BACN,CAAC,CAAC,KAAK,CAAC;wBACZ,MAAM;iBACb;aACJ;Q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xD;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { parseValueWithUnit } from '../utils/parseValueWithUnit';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { MarginFormat } from 'roosterjs-content-model-types';\n\nconst MarginKeys: (keyof MarginFormat & keyof CSSStyleDeclaration)[] = [\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n];\n\n/**\n * @internal\n */\nexport const marginFormatHandler: FormatHandler<MarginFormat> = {\n parse: (format, element, _, defaultStyle) => {\n MarginKeys.forEach(key => {\n const value = element.style[key] || defaultStyle[key];\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 const marginBlockStart = element.style.marginBlockStart || defaultStyle.marginBlockStart;\n const marginTop = element.style.marginTop || defaultStyle.marginTop;\n if (marginBlockStart && !marginTop) {\n format.marginBlockStart = parseValueWithUnit(marginBlockStart) + 'px';\n }\n\n const marginBlockEnd = element.style.marginBlockEnd || defaultStyle.marginBlockEnd;\n const marginBottom = element.style.marginBottom || defaultStyle.marginBottom;\n if (marginBlockEnd && !marginBottom) {\n format.marginBlockEnd = parseValueWithUnit(marginBlockEnd) + 'px';\n }\n },\n apply: (format, element, context) => {\n MarginKeys.forEach(key => {\n const value = format[key];\n\n if (value != context.implicitFormat[key]) {\n element.style[key] = value || '0';\n }\n });\n\n if (format.marginBlockStart && !format.marginTop) {\n element.style.marginBlockStart = format.marginBlockStart;\n }\n\n if (format.marginBlockEnd && !format.marginBottom) {\n element.style.marginBlockEnd = format.marginBlockEnd;\n }\n },\n};\n"]}
package/package.json CHANGED
@@ -3,11 +3,12 @@
3
3
  "description": "Content Model for roosterjs (Under development)",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-types": "^0.18.0"
6
+ "roosterjs-content-model-types": "^0.20.0"
7
7
  },
8
- "version": "0.18.0",
8
+ "version": "0.20.0",
9
9
  "main": "./lib/index.js",
10
10
  "typings": "./lib/index.d.ts",
11
+ "module": "./lib-mjs/index.js",
11
12
  "license": "MIT",
12
13
  "repository": {
13
14
  "type": "git",