roosterjs-content-model-dom 9.51.0 → 9.53.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.
Files changed (52) hide show
  1. package/lib/formatHandlers/block/directionFormatHandler.js +4 -2
  2. package/lib/formatHandlers/block/directionFormatHandler.js.map +1 -1
  3. package/lib/formatHandlers/common/borderFormatHandler.js +12 -1
  4. package/lib/formatHandlers/common/borderFormatHandler.js.map +1 -1
  5. package/lib/modelApi/common/addTextSegment.js +6 -1
  6. package/lib/modelApi/common/addTextSegment.js.map +1 -1
  7. package/lib/modelApi/common/stripInvisibleUnicode.d.ts +7 -0
  8. package/lib/modelApi/common/stripInvisibleUnicode.js +18 -0
  9. package/lib/modelApi/common/stripInvisibleUnicode.js.map +1 -0
  10. package/lib/modelApi/creators/createSelectionMarker.js +11 -2
  11. package/lib/modelApi/creators/createSelectionMarker.js.map +1 -1
  12. package/lib/modelToDom/handlers/handleFormatContainer.js +9 -7
  13. package/lib/modelToDom/handlers/handleFormatContainer.js.map +1 -1
  14. package/lib/modelToDom/handlers/handleListItem.js +3 -1
  15. package/lib/modelToDom/handlers/handleListItem.js.map +1 -1
  16. package/lib/modelToDom/handlers/handleTable.js +3 -1
  17. package/lib/modelToDom/handlers/handleTable.js.map +1 -1
  18. package/lib-amd/formatHandlers/block/directionFormatHandler.js +4 -2
  19. package/lib-amd/formatHandlers/block/directionFormatHandler.js.map +1 -1
  20. package/lib-amd/formatHandlers/common/borderFormatHandler.js +12 -2
  21. package/lib-amd/formatHandlers/common/borderFormatHandler.js.map +1 -1
  22. package/lib-amd/modelApi/common/addTextSegment.js +6 -2
  23. package/lib-amd/modelApi/common/addTextSegment.js.map +1 -1
  24. package/lib-amd/modelApi/common/stripInvisibleUnicode.d.ts +7 -0
  25. package/lib-amd/modelApi/common/stripInvisibleUnicode.js +20 -0
  26. package/lib-amd/modelApi/common/stripInvisibleUnicode.js.map +1 -0
  27. package/lib-amd/modelApi/creators/createSelectionMarker.js +10 -2
  28. package/lib-amd/modelApi/creators/createSelectionMarker.js.map +1 -1
  29. package/lib-amd/modelToDom/handlers/handleFormatContainer.js +9 -7
  30. package/lib-amd/modelToDom/handlers/handleFormatContainer.js.map +1 -1
  31. package/lib-amd/modelToDom/handlers/handleListItem.js +3 -1
  32. package/lib-amd/modelToDom/handlers/handleListItem.js.map +1 -1
  33. package/lib-amd/modelToDom/handlers/handleTable.js +3 -1
  34. package/lib-amd/modelToDom/handlers/handleTable.js.map +1 -1
  35. package/lib-mjs/formatHandlers/block/directionFormatHandler.js +4 -2
  36. package/lib-mjs/formatHandlers/block/directionFormatHandler.js.map +1 -1
  37. package/lib-mjs/formatHandlers/common/borderFormatHandler.js +12 -1
  38. package/lib-mjs/formatHandlers/common/borderFormatHandler.js.map +1 -1
  39. package/lib-mjs/modelApi/common/addTextSegment.js +6 -1
  40. package/lib-mjs/modelApi/common/addTextSegment.js.map +1 -1
  41. package/lib-mjs/modelApi/common/stripInvisibleUnicode.d.ts +7 -0
  42. package/lib-mjs/modelApi/common/stripInvisibleUnicode.js +14 -0
  43. package/lib-mjs/modelApi/common/stripInvisibleUnicode.js.map +1 -0
  44. package/lib-mjs/modelApi/creators/createSelectionMarker.js +11 -2
  45. package/lib-mjs/modelApi/creators/createSelectionMarker.js.map +1 -1
  46. package/lib-mjs/modelToDom/handlers/handleFormatContainer.js +9 -7
  47. package/lib-mjs/modelToDom/handlers/handleFormatContainer.js.map +1 -1
  48. package/lib-mjs/modelToDom/handlers/handleListItem.js +3 -1
  49. package/lib-mjs/modelToDom/handlers/handleListItem.js.map +1 -1
  50. package/lib-mjs/modelToDom/handlers/handleTable.js +3 -1
  51. package/lib-mjs/modelToDom/handlers/handleTable.js.map +1 -1
  52. package/package.json +2 -2
@@ -12,11 +12,13 @@ exports.directionFormatHandler = {
12
12
  format.direction = dir == 'rtl' ? 'rtl' : 'ltr';
13
13
  }
14
14
  },
15
- apply: function (format, element) {
15
+ apply: function (format, element, context) {
16
16
  if (format.direction) {
17
17
  element.style.direction = format.direction;
18
18
  }
19
- if (format.direction == 'rtl' && (0, isElementOfType_1.isElementOfType)(element, 'table')) {
19
+ if (format.direction == 'rtl' &&
20
+ (0, isElementOfType_1.isElementOfType)(element, 'table') &&
21
+ context.implicitFormat.direction != 'rtl') {
20
22
  element.style.justifySelf = 'flex-end';
21
23
  }
22
24
  },
@@ -1 +1 @@
1
- {"version":3,"file":"directionFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/block/directionFormatHandler.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AAIjE;;GAEG;AACU,QAAA,sBAAsB,GAAmC;IAClE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC;QAE7E,IAAI,GAAG,EAAE;YACL,MAAM,CAAC,SAAS,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;SACnD;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,MAAM,CAAC,SAAS,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;SAC9C;QAED,IAAI,MAAM,CAAC,SAAS,IAAI,KAAK,IAAI,IAAA,iCAAe,EAAC,OAAO,EAAE,OAAO,CAAC,EAAE;YAChE,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;SAC1C;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport type { DirectionFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const directionFormatHandler: FormatHandler<DirectionFormat> = {\n parse: (format, element, _, defaultStyle) => {\n const dir = element.style.direction || element.dir || defaultStyle.direction;\n\n if (dir) {\n format.direction = dir == 'rtl' ? 'rtl' : 'ltr';\n }\n },\n apply: (format, element) => {\n if (format.direction) {\n element.style.direction = format.direction;\n }\n\n if (format.direction == 'rtl' && isElementOfType(element, 'table')) {\n element.style.justifySelf = 'flex-end';\n }\n },\n};\n"]}
1
+ {"version":3,"file":"directionFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/block/directionFormatHandler.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AAIjE;;GAEG;AACU,QAAA,sBAAsB,GAAmC;IAClE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC;QAE7E,IAAI,GAAG,EAAE;YACL,MAAM,CAAC,SAAS,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;SACnD;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,IAAI,MAAM,CAAC,SAAS,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;SAC9C;QAED,IACI,MAAM,CAAC,SAAS,IAAI,KAAK;YACzB,IAAA,iCAAe,EAAC,OAAO,EAAE,OAAO,CAAC;YACjC,OAAO,CAAC,cAAc,CAAC,SAAS,IAAI,KAAK,EAC3C;YACE,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;SAC1C;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport type { DirectionFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const directionFormatHandler: FormatHandler<DirectionFormat> = {\n parse: (format, element, _, defaultStyle) => {\n const dir = element.style.direction || element.dir || defaultStyle.direction;\n\n if (dir) {\n format.direction = dir == 'rtl' ? 'rtl' : 'ltr';\n }\n },\n apply: (format, element, context) => {\n if (format.direction) {\n element.style.direction = format.direction;\n }\n\n if (\n format.direction == 'rtl' &&\n isElementOfType(element, 'table') &&\n context.implicitFormat.direction != 'rtl'\n ) {\n element.style.justifySelf = 'flex-end';\n }\n },\n};\n"]}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.borderFormatHandler = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var borderKeys_1 = require("../utils/borderKeys");
6
+ var borderValues_1 = require("../../domUtils/style/borderValues");
6
7
  // This array needs to match BorderKeys array
7
8
  var BorderWidthKeys = [
8
9
  'borderTopWidth',
@@ -31,7 +32,17 @@ exports.borderFormatHandler = {
31
32
  width = '0px';
32
33
  }
33
34
  if (value && width != defaultWidth) {
34
- format[key] = value == 'none' ? '' : value;
35
+ var result = value;
36
+ if (result.includes('initial')) {
37
+ // Remove 'initial' from the last part (color) of the border value
38
+ // since browsers ignore it when setting the inline style property
39
+ var border = (0, borderValues_1.extractBorderValues)(value);
40
+ if (border.color === 'initial') {
41
+ border.color = '';
42
+ }
43
+ result = (0, borderValues_1.combineBorderValue)(border);
44
+ }
45
+ format[key] = result == 'none' ? '' : result;
35
46
  }
36
47
  });
37
48
  var borderRadius = element.style.borderRadius;
@@ -1 +1 @@
1
- {"version":3,"file":"borderFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/borderFormatHandler.ts"],"names":[],"mappings":";;;;AAAA,kDAAiD;AAIjD,6CAA6C;AAC7C,IAAM,eAAe,GAAkC;IACnD,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;CACpB,CAAC;AAEF,IAAM,gBAAgB,GAAuD;I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AAC,UAAA,GAAG;YACf,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,KAAK,EAAE;gBACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aAC9B;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,YAAY,EAAE;YACrB,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;SACpD;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { BorderKeys } from '../utils/borderKeys';\nimport type { BorderFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n// This array needs to match BorderKeys array\nconst BorderWidthKeys: (keyof CSSStyleDeclaration)[] = [\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n];\n\nconst BorderRadiusKeys: (keyof BorderFormat & keyof CSSStyleDeclaration)[] = [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomLeftRadius',\n 'borderBottomRightRadius',\n];\n\nconst AllKeys = [...BorderKeys, ...BorderRadiusKeys];\n\n/**\n * @internal\n */\nexport const borderFormatHandler: FormatHandler<BorderFormat> = {\n parse: (format, element, _, defaultStyle) => {\n BorderKeys.forEach((key, i) => {\n const value = element.style[key];\n const defaultWidth = defaultStyle[BorderWidthKeys[i]] ?? '0px';\n let width = element.style[BorderWidthKeys[i]];\n\n if (width == '0') {\n width = '0px';\n }\n\n if (value && width != defaultWidth) {\n format[key] = value == 'none' ? '' : value;\n }\n });\n\n const borderRadius = element.style.borderRadius;\n\n if (borderRadius) {\n format.borderRadius = borderRadius;\n } else {\n BorderRadiusKeys.forEach(key => {\n const value = element.style[key];\n\n if (value) {\n format[key] = value;\n }\n });\n }\n },\n apply: (format, element) => {\n AllKeys.forEach(key => {\n const value = format[key];\n\n if (value) {\n element.style[key] = value;\n }\n });\n\n if (format.borderRadius) {\n element.style.borderRadius = format.borderRadius;\n }\n },\n};\n"]}
1
+ {"version":3,"file":"borderFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/borderFormatHandler.ts"],"names":[],"mappings":";;;;AAAA,kDAAiD;AAEjD,kEAA4F;AAG5F,6CAA6C;AAC7C,IAAM,eAAe,GAAkC;IACnD,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;CACpB,CAAC;AAEF,IAAM,gBAAgB,GAAuD;IACzE,qBAAqB;IACrB,sBAAsB;IACtB,wBAAwB;IACxB,yBAAyB;CAC5B,CAAC;AAEF,IAAM,OAAO,iFAAO,uBAAU,+BAAK,gBAAgB,SAAC,CAAC;AAErD;;GAEG;AACU,QAAA,mBAAmB,GAAgC;IAC5D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;QACpC,uBAAU,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,CAAC;;YACtB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACjC,IAAM,YAAY,GAAG,MAAA,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,mCAAI,KAAK,CAAC;YAC/D,IAAI,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;YAE9C,IAAI,KAAK,IAAI,GAAG,EAAE;gBACd,KAAK,GAAG,KAAK,CAAC;aACjB;YAED,IAAI,KAAK,IAAI,KAAK,IAAI,YAAY,EAAE;gBAChC,IAAI,MAAM,GAAG,KAAK,CAAC;gBACnB,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;oBAC5B,kEAAkE;oBAClE,kEAAkE;oBAClE,IAAM,MAAM,GAAG,IAAA,kCAAmB,EAAC,KAAK,CAAC,CAAC;oBAC1C,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;wBAC5B,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;qBACrB;oBACD,MAAM,GAAG,IAAA,iCAAkB,EAAC,MAAM,CAAC,CAAC;iBACvC;gBACD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;aAChD;QACL,CAAC,CAAC,CAAC;QAEH,IAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC;QAEhD,IAAI,YAAY,EAAE;YACd,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;SACtC;aAAM;YACH,gBAAgB,CAAC,OAAO,CAAC,UAAA,GAAG;gBACxB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAEjC,IAAI,KAAK,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBACvB;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,OAAO,CAAC,OAAO,CAAC,UAAA,GAAG;YACf,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,KAAK,EAAE;gBACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aAC9B;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,YAAY,EAAE;YACrB,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;SACpD;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { BorderKeys } from '../utils/borderKeys';\nimport type { BorderFormat } from 'roosterjs-content-model-types';\nimport { combineBorderValue, extractBorderValues } from '../../domUtils/style/borderValues';\nimport type { FormatHandler } from '../FormatHandler';\n\n// This array needs to match BorderKeys array\nconst BorderWidthKeys: (keyof CSSStyleDeclaration)[] = [\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n];\n\nconst BorderRadiusKeys: (keyof BorderFormat & keyof CSSStyleDeclaration)[] = [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomLeftRadius',\n 'borderBottomRightRadius',\n];\n\nconst AllKeys = [...BorderKeys, ...BorderRadiusKeys];\n\n/**\n * @internal\n */\nexport const borderFormatHandler: FormatHandler<BorderFormat> = {\n parse: (format, element, _, defaultStyle) => {\n BorderKeys.forEach((key, i) => {\n const value = element.style[key];\n const defaultWidth = defaultStyle[BorderWidthKeys[i]] ?? '0px';\n let width = element.style[BorderWidthKeys[i]];\n\n if (width == '0') {\n width = '0px';\n }\n\n if (value && width != defaultWidth) {\n let result = value;\n if (result.includes('initial')) {\n // Remove 'initial' from the last part (color) of the border value\n // since browsers ignore it when setting the inline style property\n const border = extractBorderValues(value);\n if (border.color === 'initial') {\n border.color = '';\n }\n result = combineBorderValue(border);\n }\n format[key] = result == 'none' ? '' : result;\n }\n });\n\n const borderRadius = element.style.borderRadius;\n\n if (borderRadius) {\n format.borderRadius = borderRadius;\n } else {\n BorderRadiusKeys.forEach(key => {\n const value = element.style[key];\n\n if (value) {\n format[key] = value;\n }\n });\n }\n },\n apply: (format, element) => {\n AllKeys.forEach(key => {\n const value = format[key];\n\n if (value) {\n element.style[key] = value;\n }\n });\n\n if (format.borderRadius) {\n element.style.borderRadius = format.borderRadius;\n }\n },\n};\n"]}
@@ -7,6 +7,7 @@ var createText_1 = require("../creators/createText");
7
7
  var ensureParagraph_1 = require("./ensureParagraph");
8
8
  var hasSpacesOnly_1 = require("./hasSpacesOnly");
9
9
  var isWhiteSpacePreserved_1 = require("../../domUtils/isWhiteSpacePreserved");
10
+ var stripInvisibleUnicode_1 = require("./stripInvisibleUnicode");
10
11
  /**
11
12
  * Add a new text segment to current paragraph
12
13
  * @param group Current BlockGroup that the paragraph belong to
@@ -22,7 +23,11 @@ function addTextSegment(group, text, context) {
22
23
  if (!(0, hasSpacesOnly_1.hasSpacesOnly)(text) ||
23
24
  ((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.segments.length) !== null && _a !== void 0 ? _a : 0) > 0 ||
24
25
  (0, isWhiteSpacePreserved_1.isWhiteSpacePreserved)(paragraph === null || paragraph === void 0 ? void 0 : paragraph.format.whiteSpace)) {
25
- textModel = (0, createText_1.createText)(text, context.segmentFormat);
26
+ var filteredText = context.experimentalFeatures &&
27
+ context.experimentalFeatures.indexOf('FilterInvisibleUnicode') > -1
28
+ ? (0, stripInvisibleUnicode_1.stripInvisibleUnicode)(text)
29
+ : text;
30
+ textModel = (0, createText_1.createText)(filteredText, context.segmentFormat);
26
31
  if (context.isInSelection) {
27
32
  textModel.isSelected = true;
28
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"addTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/addTextSegment.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAChD,2CAA0C;AAC1C,qDAAoD;AACpD,qDAAoD;AACpD,iDAAgD;AAChD,8EAA6E;AAO7E;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAA6B,EAC7B,IAAY,EACZ,OAA0B;;IAE1B,IAAI,SAAuC,CAAC;IAE5C,IAAI,IAAI,EAAE;QACN,IAAM,SAAS,GAAG,IAAA,iCAAe,EAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAE9D,IACI,CAAC,IAAA,6BAAa,EAAC,IAAI,CAAC;YACpB,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC;YACrC,IAAA,6CAAqB,EAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,UAAU,CAAC,EACrD;YACE,SAAS,GAAG,IAAA,uBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;YAEpD,IAAI,OAAO,CAAC,aAAa,EAAE;gBACvB,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;aAC/B;YAED,IAAA,6BAAa,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAElC,IAAA,uBAAU,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;SACrD;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AA5BD,wCA4BC","sourcesContent":["import { addDecorators } from './addDecorators';\nimport { addSegment } from './addSegment';\nimport { createText } from '../creators/createText';\nimport { ensureParagraph } from './ensureParagraph';\nimport { hasSpacesOnly } from './hasSpacesOnly';\nimport { isWhiteSpacePreserved } from '../../domUtils/isWhiteSpacePreserved';\nimport type {\n ContentModelBlockGroup,\n ContentModelText,\n DomToModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Add a new text segment to current paragraph\n * @param group Current BlockGroup that the paragraph belong to\n * @param text Text content of the text segment\n * @param context Current DOM to Model context\n * @returns A new Text segment, or undefined if the input text is empty\n */\nexport function addTextSegment(\n group: ContentModelBlockGroup,\n text: string,\n context: DomToModelContext\n): ContentModelText | undefined {\n let textModel: ContentModelText | undefined;\n\n if (text) {\n const paragraph = ensureParagraph(group, context.blockFormat);\n\n if (\n !hasSpacesOnly(text) ||\n (paragraph?.segments.length ?? 0) > 0 ||\n isWhiteSpacePreserved(paragraph?.format.whiteSpace)\n ) {\n textModel = createText(text, context.segmentFormat);\n\n if (context.isInSelection) {\n textModel.isSelected = true;\n }\n\n addDecorators(textModel, context);\n\n addSegment(group, textModel, context.blockFormat);\n }\n }\n\n return textModel;\n}\n"]}
1
+ {"version":3,"file":"addTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/addTextSegment.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAChD,2CAA0C;AAC1C,qDAAoD;AACpD,qDAAoD;AACpD,iDAAgD;AAChD,8EAA6E;AAC7E,iEAAgE;AAOhE;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAA6B,EAC7B,IAAY,EACZ,OAA0B;;IAE1B,IAAI,SAAuC,CAAC;IAE5C,IAAI,IAAI,EAAE;QACN,IAAM,SAAS,GAAG,IAAA,iCAAe,EAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAE9D,IACI,CAAC,IAAA,6BAAa,EAAC,IAAI,CAAC;YACpB,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC;YACrC,IAAA,6CAAqB,EAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,UAAU,CAAC,EACrD;YACE,IAAM,YAAY,GACd,OAAO,CAAC,oBAAoB;gBAC5B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;gBAC/D,CAAC,CAAC,IAAA,6CAAqB,EAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,IAAI,CAAC;YAEf,SAAS,GAAG,IAAA,uBAAU,EAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;YAE5D,IAAI,OAAO,CAAC,aAAa,EAAE;gBACvB,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;aAC/B;YAED,IAAA,6BAAa,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAElC,IAAA,uBAAU,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;SACrD;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAlCD,wCAkCC","sourcesContent":["import { addDecorators } from './addDecorators';\nimport { addSegment } from './addSegment';\nimport { createText } from '../creators/createText';\nimport { ensureParagraph } from './ensureParagraph';\nimport { hasSpacesOnly } from './hasSpacesOnly';\nimport { isWhiteSpacePreserved } from '../../domUtils/isWhiteSpacePreserved';\nimport { stripInvisibleUnicode } from './stripInvisibleUnicode';\nimport type {\n ContentModelBlockGroup,\n ContentModelText,\n DomToModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Add a new text segment to current paragraph\n * @param group Current BlockGroup that the paragraph belong to\n * @param text Text content of the text segment\n * @param context Current DOM to Model context\n * @returns A new Text segment, or undefined if the input text is empty\n */\nexport function addTextSegment(\n group: ContentModelBlockGroup,\n text: string,\n context: DomToModelContext\n): ContentModelText | undefined {\n let textModel: ContentModelText | undefined;\n\n if (text) {\n const paragraph = ensureParagraph(group, context.blockFormat);\n\n if (\n !hasSpacesOnly(text) ||\n (paragraph?.segments.length ?? 0) > 0 ||\n isWhiteSpacePreserved(paragraph?.format.whiteSpace)\n ) {\n const filteredText =\n context.experimentalFeatures &&\n context.experimentalFeatures.indexOf('FilterInvisibleUnicode') > -1\n ? stripInvisibleUnicode(text)\n : text;\n\n textModel = createText(filteredText, context.segmentFormat);\n\n if (context.isInSelection) {\n textModel.isSelected = true;\n }\n\n addDecorators(textModel, context);\n\n addSegment(group, textModel, context.blockFormat);\n }\n }\n\n return textModel;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ * Strip invisible unicode characters from the given string
4
+ * @param value The string to be processed
5
+ * @returns The string with invisible unicode characters removed
6
+ */
7
+ export declare function stripInvisibleUnicode(value: string): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripInvisibleUnicode = void 0;
4
+ // According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
5
+ // there are some invisible unicode characters in the range of U+E0000 to U+EFFFF, which are used for hiding text in HTML.
6
+ // We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
7
+ var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{EFFFF}]/gu;
8
+ /**
9
+ * @internal
10
+ * Strip invisible unicode characters from the given string
11
+ * @param value The string to be processed
12
+ * @returns The string with invisible unicode characters removed
13
+ */
14
+ function stripInvisibleUnicode(value) {
15
+ return value.replace(INVISIBLE_UNICODE_REGEX, '');
16
+ }
17
+ exports.stripInvisibleUnicode = stripInvisibleUnicode;
18
+ //# sourceMappingURL=stripInvisibleUnicode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,0HAA0H;AAC1H,+IAA+I;AAC/I,IAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAE1D;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAFD,sDAEC","sourcesContent":["// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n// there are some invisible unicode characters in the range of U+E0000 to U+EFFFF, which are used for hiding text in HTML.\n// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.\nconst INVISIBLE_UNICODE_REGEX = /[\\u{E0000}-\\u{EFFFF}]/gu;\n\n/**\n * @internal\n * Strip invisible unicode characters from the given string\n * @param value The string to be processed\n * @returns The string with invisible unicode characters removed\n */\nexport function stripInvisibleUnicode(value: string): string {\n return value.replace(INVISIBLE_UNICODE_REGEX, '');\n}\n"]}
@@ -1,16 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSelectionMarker = void 0;
4
- var tslib_1 = require("tslib");
4
+ var EmptySegmentFormat_1 = require("../../constants/EmptySegmentFormat");
5
+ var getObjectKeys_1 = require("../../domUtils/getObjectKeys");
5
6
  /**
6
7
  * Create a ContentModelSelectionMarker model
7
8
  * @param format @optional The format of this model
8
9
  */
9
10
  function createSelectionMarker(format) {
11
+ var filteredFormat = {};
12
+ if (format) {
13
+ (0, getObjectKeys_1.getObjectKeys)(EmptySegmentFormat_1.EmptySegmentFormat).forEach(function (key) {
14
+ if (key in format) {
15
+ filteredFormat[key] = format[key];
16
+ }
17
+ });
18
+ }
10
19
  return {
11
20
  segmentType: 'SelectionMarker',
12
21
  isSelected: true,
13
- format: (0, tslib_1.__assign)({}, format),
22
+ format: filteredFormat,
14
23
  };
15
24
  }
16
25
  exports.createSelectionMarker = createSelectionMarker;
@@ -1 +1 @@
1
- {"version":3,"file":"createSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/creators/createSelectionMarker.ts"],"names":[],"mappings":";;;;AAKA;;;GAGG;AACH,SAAgB,qBAAqB,CACjC,MAA4C;IAE5C,OAAO;QACH,WAAW,EAAE,iBAAiB;QAC9B,UAAU,EAAE,IAAI;QAChB,MAAM,4BAAO,MAAM,CAAE;KACxB,CAAC;AACN,CAAC;AARD,sDAQC","sourcesContent":["import type {\n ContentModelSegmentFormat,\n ContentModelSelectionMarker,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create a ContentModelSelectionMarker model\n * @param format @optional The format of this model\n */\nexport function createSelectionMarker(\n format?: Readonly<ContentModelSegmentFormat>\n): ContentModelSelectionMarker {\n return {\n segmentType: 'SelectionMarker',\n isSelected: true,\n format: { ...format },\n };\n}\n"]}
1
+ {"version":3,"file":"createSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/creators/createSelectionMarker.ts"],"names":[],"mappings":";;;AAAA,yEAAwE;AACxE,8DAA6D;AAM7D;;;GAGG;AACH,SAAgB,qBAAqB,CACjC,MAA4C;IAE5C,IAAM,cAAc,GAA8B,EAAE,CAAC;IAErD,IAAI,MAAM,EAAE;QACR,IAAA,6BAAa,EAAC,uCAAkB,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;YACzC,IAAI,GAAG,IAAI,MAAM,EAAE;gBACd,cAAc,CAAC,GAAG,CAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;aAC9C;QACL,CAAC,CAAC,CAAC;KACN;IAED,OAAO;QACH,WAAW,EAAE,iBAAiB;QAC9B,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,cAAc;KACzB,CAAC;AACN,CAAC;AAlBD,sDAkBC","sourcesContent":["import { EmptySegmentFormat } from '../../constants/EmptySegmentFormat';\nimport { getObjectKeys } from '../../domUtils/getObjectKeys';\nimport type {\n ContentModelSegmentFormat,\n ContentModelSelectionMarker,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create a ContentModelSelectionMarker model\n * @param format @optional The format of this model\n */\nexport function createSelectionMarker(\n format?: Readonly<ContentModelSegmentFormat>\n): ContentModelSelectionMarker {\n const filteredFormat: ContentModelSegmentFormat = {};\n\n if (format) {\n getObjectKeys(EmptySegmentFormat).forEach(key => {\n if (key in format) {\n (filteredFormat[key] as any) = format[key];\n }\n });\n }\n\n return {\n segmentType: 'SelectionMarker',\n isSelected: true,\n format: filteredFormat,\n };\n}\n"]}
@@ -31,14 +31,16 @@ var handleFormatContainer = function (doc, parent, container, context, refNode)
31
31
  (0, applyFormat_1.applyFormat)(containerNode_1, context.formatAppliers.segmentOnBlock, container.format, context);
32
32
  (0, applyFormat_1.applyFormat)(containerNode_1, context.formatAppliers.container, container.format, context);
33
33
  });
34
- if (container.tagName == 'pre') {
35
- (0, stackFormat_1.stackFormat)(context, PreChildFormat, function () {
34
+ (0, stackFormat_1.stackFormat)(context, container.format.direction ? { direction: container.format.direction } : null, function () {
35
+ if (container.tagName == 'pre') {
36
+ (0, stackFormat_1.stackFormat)(context, PreChildFormat, function () {
37
+ context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
38
+ });
39
+ }
40
+ else {
36
41
  context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
37
- });
38
- }
39
- else {
40
- context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
41
- }
42
+ }
43
+ });
42
44
  element = containerNode_1;
43
45
  }
44
46
  if (element) {
@@ -1 +1 @@
1
- {"version":3,"file":"handleFormatContainer.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleFormatContainer.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,yDAAkE;AAClE,wEAAuE;AACvE,oDAAmD;AASnD,IAAM,cAAc,GAAwD;IACxE,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,KAAK;CACpB,CAAC;AAEF;;GAEG;AACI,IAAM,qBAAqB,GAA0D,UACxF,GAAa,EACb,MAAY,EACZ,SAAsC,EACtC,OAA0B,EAC1B,OAAoB;;IAEpB,IAAI,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,IAAI,OAAO,EAAE;QACT,OAAO,GAAG,IAAA,uCAAkB,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAEjF,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;KAC9E;SAAM,IAAI,CAAC,IAAA,2BAAiB,EAAC,SAAS,CAAC,EAAE;QACtC,IAAM,eAAa,GAAG,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE3D,IAAI,OAAO,CAAC,iBAAiB,EAAE;YAC3B,SAAS,CAAC,aAAa,GAAG,eAAa,CAAC;SAC3C;QAED,MAAM,CAAC,YAAY,CAAC,eAAa,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAa,CAAC,CAAC;QAEhE,IAAA,yBAAW,EAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE;YACpC,IAAA,yBAAW,EAAC,eAAa,EAAE,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACxF,IAAA,yBAAW,EACP,eAAa,EACb,OAAO,CAAC,cAAc,CAAC,cAAc,EACrC,SAAS,CAAC,MAAM,EAChB,OAAO,CACV,CAAC;YAEF,IAAA,yBAAW,EAAC,eAAa,EAAE,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5F,CAAC,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,OAAO,IAAI,KAAK,EAAE;YAC5B,IAAA,yBAAW,EAAC,OAAO,EAAE,cAAc,EAAE;gBACjC,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,eAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACrF,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,eAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SACpF;QAED,OAAO,GAAG,eAAa,CAAC;KAC3B;IAED,IAAI,OAAO,EAAE;QACT,MAAA,OAAO,CAAC,aAAa,+CAArB,OAAO,EAAiB,SAAS,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAnDW,QAAA,qBAAqB,yBAmDhC","sourcesContent":["import { applyFormat } from '../utils/applyFormat';\nimport { isBlockGroupEmpty } from '../../modelApi/common/isEmpty';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelBlockFormat,\n ContentModelBlockHandler,\n ContentModelFormatContainer,\n ContentModelSegmentFormat,\n ModelToDomContext,\n} from 'roosterjs-content-model-types';\n\nconst PreChildFormat: ContentModelSegmentFormat & ContentModelBlockFormat = {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n};\n\n/**\n * @internal\n */\nexport const handleFormatContainer: ContentModelBlockHandler<ContentModelFormatContainer> = (\n doc: Document,\n parent: Node,\n container: ContentModelFormatContainer,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n let element = context.allowCacheElement ? container.cachedElement : undefined;\n\n if (element) {\n refNode = reuseCachedElement(parent, element, refNode, context.rewriteFromModel);\n\n context.modelHandlers.blockGroupChildren(doc, element, container, context);\n } else if (!isBlockGroupEmpty(container)) {\n const containerNode = doc.createElement(container.tagName);\n\n if (context.allowCacheElement) {\n container.cachedElement = containerNode;\n }\n\n parent.insertBefore(containerNode, refNode);\n context.rewriteFromModel.addedBlockElements.push(containerNode);\n\n stackFormat(context, container.tagName, () => {\n applyFormat(containerNode, context.formatAppliers.container, container.format, context);\n applyFormat(\n containerNode,\n context.formatAppliers.segmentOnBlock,\n container.format,\n context\n );\n\n applyFormat(containerNode, context.formatAppliers.container, container.format, context);\n });\n\n if (container.tagName == 'pre') {\n stackFormat(context, PreChildFormat, () => {\n context.modelHandlers.blockGroupChildren(doc, containerNode, container, context);\n });\n } else {\n context.modelHandlers.blockGroupChildren(doc, containerNode, container, context);\n }\n\n element = containerNode;\n }\n\n if (element) {\n context.onNodeCreated?.(container, element);\n }\n\n return refNode;\n};\n"]}
1
+ {"version":3,"file":"handleFormatContainer.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleFormatContainer.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,yDAAkE;AAClE,wEAAuE;AACvE,oDAAmD;AASnD,IAAM,cAAc,GAAwD;IACxE,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,KAAK;CACpB,CAAC;AAEF;;GAEG;AACI,IAAM,qBAAqB,GAA0D,UACxF,GAAa,EACb,MAAY,EACZ,SAAsC,EACtC,OAA0B,EAC1B,OAAoB;;IAEpB,IAAI,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,IAAI,OAAO,EAAE;QACT,OAAO,GAA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C,OAAO,EAAE,cAAc,EAAE;oBACjC,OAAO,CAAC,aAAa,CAAC,kBAAkB,CACpC,GAAG,EACH,eAAa,EACb,SAAS,EACT,OAAO,CACV,CAAC;gBACN,CAAC,CAAC,CAAC;aACN;iBAAM;gBACH,OAAO,CAAC,aAAa,CAAC,kBAAkB,CACpC,GAAG,EACH,eAAa,EACb,SAAS,EACT,OAAO,CACV,CAAC;aACL;QACL,CAAC,CACJ,CAAC;QAEF,OAAO,GAAG,eAAa,CAAC;KAC3B;IAED,IAAI,OAAO,EAAE;QACT,MAAA,OAAO,CAAC,aAAa,+CAArB,OAAO,EAAiB,SAAS,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAnEW,QAAA,qBAAqB,yBAmEhC","sourcesContent":["import { applyFormat } from '../utils/applyFormat';\nimport { isBlockGroupEmpty } from '../../modelApi/common/isEmpty';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelBlockFormat,\n ContentModelBlockHandler,\n ContentModelFormatContainer,\n ContentModelSegmentFormat,\n ModelToDomContext,\n} from 'roosterjs-content-model-types';\n\nconst PreChildFormat: ContentModelSegmentFormat & ContentModelBlockFormat = {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n};\n\n/**\n * @internal\n */\nexport const handleFormatContainer: ContentModelBlockHandler<ContentModelFormatContainer> = (\n doc: Document,\n parent: Node,\n container: ContentModelFormatContainer,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n let element = context.allowCacheElement ? container.cachedElement : undefined;\n\n if (element) {\n refNode = reuseCachedElement(parent, element, refNode, context.rewriteFromModel);\n\n context.modelHandlers.blockGroupChildren(doc, element, container, context);\n } else if (!isBlockGroupEmpty(container)) {\n const containerNode = doc.createElement(container.tagName);\n\n if (context.allowCacheElement) {\n container.cachedElement = containerNode;\n }\n\n parent.insertBefore(containerNode, refNode);\n context.rewriteFromModel.addedBlockElements.push(containerNode);\n\n stackFormat(context, container.tagName, () => {\n applyFormat(containerNode, context.formatAppliers.container, container.format, context);\n applyFormat(\n containerNode,\n context.formatAppliers.segmentOnBlock,\n container.format,\n context\n );\n\n applyFormat(containerNode, context.formatAppliers.container, container.format, context);\n });\n\n stackFormat(\n context,\n container.format.direction ? { direction: container.format.direction } : null,\n () => {\n if (container.tagName == 'pre') {\n stackFormat(context, PreChildFormat, () => {\n context.modelHandlers.blockGroupChildren(\n doc,\n containerNode,\n container,\n context\n );\n });\n } else {\n context.modelHandlers.blockGroupChildren(\n doc,\n containerNode,\n container,\n context\n );\n }\n }\n );\n\n element = containerNode;\n }\n\n if (element) {\n context.onNodeCreated?.(container, element);\n }\n\n return refNode;\n};\n"]}
@@ -52,7 +52,9 @@ var handleListItem = function (doc, parent, listItem, context, refNode) {
52
52
  // Need to apply listItemElement formats after applying metadata since the list numbers value relies on the result of metadata handling
53
53
  (0, applyFormat_1.applyFormat)(li, context.formatAppliers.listItemElement, listItem.format, context);
54
54
  (0, stackFormat_1.stackFormat)(context, listItem.formatHolder.format, function () {
55
- context.modelHandlers.blockGroupChildren(doc, li, listItem, context);
55
+ (0, stackFormat_1.stackFormat)(context, listItem.format.direction ? { direction: listItem.format.direction } : null, function () {
56
+ context.modelHandlers.blockGroupChildren(doc, li, listItem, context);
57
+ });
56
58
  });
57
59
  }
58
60
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"handleListItem.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleListItem.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,wDAAuD;AACvD,4EAA2E;AAC3E,wEAAuE;AACvE,wFAAuF;AACvF,oDAAmD;AACnD,gDAA+C;AAQ/C,IAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,IAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C;;GAEG;AACI,IAAM,cAAc,GAAmD,UAC1E,GAAa,EACb,MAAY,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,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAErE,IAAA,eAAM,EAAC,EAAE,CAAC,CAAC;KACd;IAED,6EAA6E;IAC7E,8EAA8E;IAC9E,8CAA8C;IAC9C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACrD,IAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,IAAA,2CAAoB,EAAC,OAAO,CAAC,EAAE;YAC/B,OAAO,CAAC,YAAY,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;SAClE;KACJ;IAED,IAAI,cAAc,EAAE;QAChB,MAAA,OAAO,CAAC,aAAa,+CAArB,OAAO,EAAiB,QAAQ,EAAE,EAAE,CAAC,CAAC;KACzC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AArFW,QAAA,cAAc,kBAqFzB","sourcesContent":["import { applyFormat } from '../utils/applyFormat';\nimport { applyMetadata } from '../utils/applyMetadata';\nimport { isGenericRoleElement } from '../../domUtils/isGenericRoleElement';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { setParagraphNotImplicit } from '../../modelApi/block/setParagraphNotImplicit';\nimport { stackFormat } from '../utils/stackFormat';\nimport { unwrap } from '../../domUtils/unwrap';\nimport type {\n ContentModelBlockHandler,\n ContentModelListItem,\n ModelToDomContext,\n ModelToDomListStackItem,\n} from 'roosterjs-content-model-types';\n\nconst HtmlRoleAttribute = 'role';\nconst PresentationRoleValue = 'presentation';\n\n/**\n * @internal\n */\nexport const handleListItem: ContentModelBlockHandler<ContentModelListItem> = (\n doc: Document,\n parent: Node,\n listItem: ContentModelListItem,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n refNode = context.modelHandlers.list(doc, parent, listItem, context, refNode);\n\n const { nodeStack } = context.listFormat;\n const leafLevel: Partial<ModelToDomListStackItem> = nodeStack?.[nodeStack.length - 1] ?? {};\n const itemRefNode = leafLevel.refNode || null;\n const listParent = leafLevel.node || parent;\n const level = listItem.levels[listItem.levels.length - 1];\n\n let li: HTMLLIElement;\n let isNewlyCreated = false;\n\n if (listItem.cachedElement) {\n li = listItem.cachedElement;\n\n // Check if the cached LI is used as refNode under another list level,\n // since we know we are going to move it under the current listParent,\n // we need to update the refNode of the previous list level to avoid removing it later\n for (let i = 0; i < nodeStack.length - 1; i++) {\n if (nodeStack[i].refNode === li) {\n nodeStack[i].refNode = li.nextSibling;\n }\n }\n\n leafLevel.refNode = reuseCachedElement(\n listParent,\n li,\n itemRefNode,\n context.rewriteFromModel\n );\n } else {\n li = doc.createElement('li');\n isNewlyCreated = true;\n\n // It is possible listParent is the same with parent param.\n // This happens when outdent a list item to cause it has no list level\n listParent.insertBefore(li, itemRefNode?.parentNode == listParent ? itemRefNode : null);\n context.rewriteFromModel.addedBlockElements.push(li);\n listItem.cachedElement = li;\n }\n\n if (level) {\n applyFormat(li, context.formatAppliers.segment, listItem.formatHolder.format, context);\n applyFormat(li, context.formatAppliers.listItemThread, level.format, context);\n\n // Need to apply metadata after applying listItem format since the list numbers value relies on the result of list thread handling\n applyMetadata(level, context.metadataAppliers.listItem, listItem.format, context);\n\n // Need to apply listItemElement formats after applying metadata since the list numbers value relies on the result of metadata handling\n applyFormat(li, context.formatAppliers.listItemElement, listItem.format, context);\n\n stackFormat(context, listItem.formatHolder.format, () => {\n context.modelHandlers.blockGroupChildren(doc, li, listItem, context);\n });\n } else {\n // There is no level for this list item, that means it should be moved out of the list\n // For each paragraph, make it not implicit so it will have a DIV around it, to avoid more paragraphs connected together\n listItem.blocks.forEach(setParagraphNotImplicit);\n\n context.modelHandlers.blockGroupChildren(doc, li, listItem, context);\n\n unwrap(li);\n }\n\n // Add role=\"presentation\" to all generic role elements inside the LI element\n // This is to make sure the elements are announced correctly by screen readers\n // when using arrow keys to navigate the list.\n for (let index = 0; index < li.children.length; index++) {\n const element = li.children.item(index);\n if (isGenericRoleElement(element)) {\n element.setAttribute(HtmlRoleAttribute, PresentationRoleValue);\n }\n }\n\n if (isNewlyCreated) {\n context.onNodeCreated?.(listItem, li);\n }\n\n return refNode;\n};\n"]}
1
+ {"version":3,"file":"handleListItem.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleListItem.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,wDAAuD;AACvD,4EAA2E;AAC3E,wEAAuE;AACvE,wFAAuF;AACvF,oDAAmD;AACnD,gDAA+C;AAQ/C,IAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,IAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C;;GAEG;AACI,IAAM,cAAc,GAAmD,UAC1E,GAAa,EACb,MAAY,EACZ,QAA8B,EAC9B,OAA0B,EAC1B,OAAoB;;IAEpB,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAEtE,IAAA,SAAS,GAAK,OAAO,CAAC,UAAU,UAAvB,CAAwB;IACzC,IAAM,SAAS,GAAqC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;IAC5F,IAAM,WAAW,GAAG,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC;IAC9C,IAAM,UAAU,GAAG,SAAS,CAAC,IAAI,IAAI,MAAM,CAAC;IAC5C,IAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1D,IAAI,EAAiB,CAAC;IACtB,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC;QAE5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AE,EAAE,CAAC,CAAC;KACzC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AA3FW,QAAA,cAAc,kBA2FzB","sourcesContent":["import { applyFormat } from '../utils/applyFormat';\nimport { applyMetadata } from '../utils/applyMetadata';\nimport { isGenericRoleElement } from '../../domUtils/isGenericRoleElement';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { setParagraphNotImplicit } from '../../modelApi/block/setParagraphNotImplicit';\nimport { stackFormat } from '../utils/stackFormat';\nimport { unwrap } from '../../domUtils/unwrap';\nimport type {\n ContentModelBlockHandler,\n ContentModelListItem,\n ModelToDomContext,\n ModelToDomListStackItem,\n} from 'roosterjs-content-model-types';\n\nconst HtmlRoleAttribute = 'role';\nconst PresentationRoleValue = 'presentation';\n\n/**\n * @internal\n */\nexport const handleListItem: ContentModelBlockHandler<ContentModelListItem> = (\n doc: Document,\n parent: Node,\n listItem: ContentModelListItem,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n refNode = context.modelHandlers.list(doc, parent, listItem, context, refNode);\n\n const { nodeStack } = context.listFormat;\n const leafLevel: Partial<ModelToDomListStackItem> = nodeStack?.[nodeStack.length - 1] ?? {};\n const itemRefNode = leafLevel.refNode || null;\n const listParent = leafLevel.node || parent;\n const level = listItem.levels[listItem.levels.length - 1];\n\n let li: HTMLLIElement;\n let isNewlyCreated = false;\n\n if (listItem.cachedElement) {\n li = listItem.cachedElement;\n\n // Check if the cached LI is used as refNode under another list level,\n // since we know we are going to move it under the current listParent,\n // we need to update the refNode of the previous list level to avoid removing it later\n for (let i = 0; i < nodeStack.length - 1; i++) {\n if (nodeStack[i].refNode === li) {\n nodeStack[i].refNode = li.nextSibling;\n }\n }\n\n leafLevel.refNode = reuseCachedElement(\n listParent,\n li,\n itemRefNode,\n context.rewriteFromModel\n );\n } else {\n li = doc.createElement('li');\n isNewlyCreated = true;\n\n // It is possible listParent is the same with parent param.\n // This happens when outdent a list item to cause it has no list level\n listParent.insertBefore(li, itemRefNode?.parentNode == listParent ? itemRefNode : null);\n context.rewriteFromModel.addedBlockElements.push(li);\n listItem.cachedElement = li;\n }\n\n if (level) {\n applyFormat(li, context.formatAppliers.segment, listItem.formatHolder.format, context);\n applyFormat(li, context.formatAppliers.listItemThread, level.format, context);\n\n // Need to apply metadata after applying listItem format since the list numbers value relies on the result of list thread handling\n applyMetadata(level, context.metadataAppliers.listItem, listItem.format, context);\n\n // Need to apply listItemElement formats after applying metadata since the list numbers value relies on the result of metadata handling\n applyFormat(li, context.formatAppliers.listItemElement, listItem.format, context);\n\n stackFormat(context, listItem.formatHolder.format, () => {\n stackFormat(\n context,\n listItem.format.direction ? { direction: listItem.format.direction } : null,\n () => {\n context.modelHandlers.blockGroupChildren(doc, li, listItem, context);\n }\n );\n });\n } else {\n // There is no level for this list item, that means it should be moved out of the list\n // For each paragraph, make it not implicit so it will have a DIV around it, to avoid more paragraphs connected together\n listItem.blocks.forEach(setParagraphNotImplicit);\n\n context.modelHandlers.blockGroupChildren(doc, li, listItem, context);\n\n unwrap(li);\n }\n\n // Add role=\"presentation\" to all generic role elements inside the LI element\n // This is to make sure the elements are announced correctly by screen readers\n // when using arrow keys to navigate the list.\n for (let index = 0; index < li.children.length; index++) {\n const element = li.children.item(index);\n if (isGenericRoleElement(element)) {\n element.setAttribute(HtmlRoleAttribute, PresentationRoleValue);\n }\n }\n\n if (isNewlyCreated) {\n context.onNodeCreated?.(listItem, li);\n }\n\n return refNode;\n};\n"]}
@@ -107,7 +107,9 @@ var handleTable = function (doc, parent, table, context, refNode) {
107
107
  (0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.tableCellBorder, cell.format, context);
108
108
  (0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.dataset, cell.dataset, context);
109
109
  }
110
- context.modelHandlers.blockGroupChildren(doc, td_1, cell, context);
110
+ (0, stackFormat_1.stackFormat)(context, cell.format.direction ? { direction: cell.format.direction } : null, function () {
111
+ context.modelHandlers.blockGroupChildren(doc, td_1, cell, context);
112
+ });
111
113
  });
112
114
  (_f = context.onNodeCreated) === null || _f === void 0 ? void 0 : _f.call(context, cell, td_1);
113
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handleTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleTable.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,yEAAqE;AACrE,yDAA6D;AAC7D,gEAA+D;AAC/D,wEAAuE;AACvE,oDAAmD;AAQnD;;GAEG;AACI,IAAM,WAAW,GAAgD,UACpE,GAAa,EACb,MAAY,EACZ,KAAwB,EACxB,OAA0B,EAC1B,OAAoB;;IAEpB,IAAI,IAAA,sBAAY,EAAC,KAAK,CAAC,EAAE;QACrB,2DAA2D;QAC3D,OAAO,OAAO,CAAC;KAClB;IAED,IAAI,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAE5E,IAAI,SAAS,EAAE;QACX,OAAO,GAAG,IAAA,uCAAkB,EAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAEnF,IAAA,+BAAc,EAAC,SAAS,CAAC,CAAC;KAC7B;SAAM;QACH,SAAS,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,OAAO,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;SACnC;QAED,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE5D,IAAA,yBAAW,EAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5E,IAAA,yBAAW,EAAC,SAA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,EAAE;4BAC3B,IAAI,CAAC,aAAa,GAAG,IAAE,CAAC;yBAC3B;wBAED,IAAA,yBAAW,EAAC,IAAE,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;wBACpE,IAAA,yBAAW,EAAC,IAAE,EAAE,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;wBACxE,IAAA,yBAAW,EACP,IAAE,EACF,OAAO,CAAC,cAAc,CAAC,eAAe,EACtC,IAAI,CAAC,MAAM,EACX,OAAO,CACV,CAAC;wBACF,IAAA,yBAAW,EAAC,IAAE,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBAC1E;oBAED,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBACrE,CAAC,CAAC,CAAC;gBAEH,MAAA,OAAO,CAAC,aAAa,+CAArB,OAAO,EAAiB,IAAI,EAAE,IAAE,CAAC,CAAC;aACrC;;QA/EL,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE;oBAA3C,GAAG;SAgFX;KACJ;IAED,MAAA,OAAO,CAAC,UAAU,0CAAE,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE9C,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAnJW,QAAA,WAAW,eAmJtB","sourcesContent":["import { applyFormat } from '../utils/applyFormat';\nimport { hasMetadata } from '../../modelApi/metadata/updateMetadata';\nimport { isBlockEmpty } from '../../modelApi/common/isEmpty';\nimport { moveChildNodes } from '../../domUtils/moveChildNodes';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelBlockHandler,\n ContentModelTable,\n ModelToDomContext,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const handleTable: ContentModelBlockHandler<ContentModelTable> = (\n doc: Document,\n parent: Node,\n table: ContentModelTable,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n if (isBlockEmpty(table)) {\n // Empty table, do not create TABLE element and just return\n return refNode;\n }\n\n let tableNode = context.allowCacheElement ? table.cachedElement : undefined;\n\n if (tableNode) {\n refNode = reuseCachedElement(parent, tableNode, refNode, context.rewriteFromModel);\n\n moveChildNodes(tableNode);\n } else {\n tableNode = doc.createElement('table');\n\n if (context.allowCacheElement) {\n table.cachedElement = tableNode;\n }\n\n parent.insertBefore(tableNode, refNode);\n context.rewriteFromModel.addedBlockElements.push(tableNode);\n\n applyFormat(tableNode, context.formatAppliers.block, table.format, context);\n applyFormat(tableNode, context.formatAppliers.table, table.format, context);\n applyFormat(tableNode, context.formatAppliers.tableBorder, table.format, context);\n applyFormat(tableNode, context.formatAppliers.dataset, table.dataset, context);\n }\n\n context.onNodeCreated?.(table, tableNode);\n\n const tbody = doc.createElement('tbody');\n tableNode.appendChild(tbody);\n\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n const tr = (context.allowCacheElement && tableRow.cachedElement) || doc.createElement('tr');\n tbody.appendChild(tr);\n moveChildNodes(tr);\n\n if (!tableRow.cachedElement) {\n if (context.allowCacheElement) {\n tableRow.cachedElement = tr;\n }\n\n applyFormat(tr, context.formatAppliers.tableRow, tableRow.format, context);\n }\n\n context.onNodeCreated?.(tableRow, tr);\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const cell = tableRow.cells[col];\n\n if (cell.isSelected) {\n const tableSelection: TableSelection = context.tableSelection || {\n type: 'table',\n table: tableNode,\n firstColumn: col,\n lastColumn: col,\n firstRow: row,\n lastRow: row,\n };\n\n if (tableSelection.table == tableNode) {\n tableSelection.lastColumn = Math.max(tableSelection.lastColumn, col);\n tableSelection.lastRow = Math.max(tableSelection.lastRow, row);\n }\n\n context.tableSelection = tableSelection;\n }\n\n if (!cell.spanAbove && !cell.spanLeft) {\n const tag = cell.isHeader ? 'th' : 'td';\n const td =\n (context.allowCacheElement && cell.cachedElement) || doc.createElement(tag);\n\n tr.appendChild(td);\n\n let rowSpan = 1;\n let colSpan = 1;\n let width = table.widths[col];\n let height = tableRow.height;\n\n for (; table.rows[row + rowSpan]?.cells[col]?.spanAbove; rowSpan++) {\n height += table.rows[row + rowSpan].height;\n }\n for (; tableRow.cells[col + colSpan]?.spanLeft; colSpan++) {\n width += table.widths[col + colSpan];\n }\n\n if (rowSpan > 1) {\n td.rowSpan = rowSpan;\n }\n\n if (colSpan > 1) {\n td.colSpan = colSpan;\n }\n\n if (!cell.cachedElement || (cell.format.useBorderBox && hasMetadata(table))) {\n if (width > 0 && !td.style.width) {\n td.style.width = width + 'px';\n }\n\n if (height > 0 && !td.style.height) {\n td.style.height = height + 'px';\n }\n }\n\n stackFormat(context, tag, () => {\n if (!cell.cachedElement) {\n if (context.allowCacheElement) {\n cell.cachedElement = td;\n }\n\n applyFormat(td, context.formatAppliers.block, cell.format, context);\n applyFormat(td, context.formatAppliers.tableCell, cell.format, context);\n applyFormat(\n td,\n context.formatAppliers.tableCellBorder,\n cell.format,\n context\n );\n applyFormat(td, context.formatAppliers.dataset, cell.dataset, context);\n }\n\n context.modelHandlers.blockGroupChildren(doc, td, cell, context);\n });\n\n context.onNodeCreated?.(cell, td);\n }\n }\n }\n\n context.domIndexer?.onTable(tableNode, table);\n\n return refNode;\n};\n"]}
1
+ {"version":3,"file":"handleTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleTable.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,yEAAqE;AACrE,yDAA6D;AAC7D,gEAA+D;AAC/D,wEAAuE;AACvE,o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xE,IAAA,yBAAW,EACP,IAAE,EACF,OAAO,CAAC,cAAc,CAAC,eAAe,EACtC,IAAI,CAAC,MAAM,EACX,OAAO,CACV,CAAC;wBACF,IAAA,yBAAW,EAAC,IAAE,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBAC1E;oBAED,IAAA,yBAAW,EACP,OAAO,EACP,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,EACnE;wBACI,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;oBACrE,CAAC,CACJ,CAAC;gBACN,CAAC,CAAC,CAAC;gBAEH,MAAA,OAAO,CAAC,aAAa,+CAArB,OAAO,EAAiB,IAAI,EAAE,IAAE,CAAC,CAAC;aACrC;;QArFL,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE;oBAA3C,GAAG;SAsFX;KACJ;IAED,MAAA,OAAO,CAAC,UAAU,0CAAE,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE9C,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAzJW,QAAA,WAAW,eAyJtB","sourcesContent":["import { applyFormat } from '../utils/applyFormat';\nimport { hasMetadata } from '../../modelApi/metadata/updateMetadata';\nimport { isBlockEmpty } from '../../modelApi/common/isEmpty';\nimport { moveChildNodes } from '../../domUtils/moveChildNodes';\nimport { reuseCachedElement } from '../../domUtils/reuseCachedElement';\nimport { stackFormat } from '../utils/stackFormat';\nimport type {\n ContentModelBlockHandler,\n ContentModelTable,\n ModelToDomContext,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const handleTable: ContentModelBlockHandler<ContentModelTable> = (\n doc: Document,\n parent: Node,\n table: ContentModelTable,\n context: ModelToDomContext,\n refNode: Node | null\n) => {\n if (isBlockEmpty(table)) {\n // Empty table, do not create TABLE element and just return\n return refNode;\n }\n\n let tableNode = context.allowCacheElement ? table.cachedElement : undefined;\n\n if (tableNode) {\n refNode = reuseCachedElement(parent, tableNode, refNode, context.rewriteFromModel);\n\n moveChildNodes(tableNode);\n } else {\n tableNode = doc.createElement('table');\n\n if (context.allowCacheElement) {\n table.cachedElement = tableNode;\n }\n\n parent.insertBefore(tableNode, refNode);\n context.rewriteFromModel.addedBlockElements.push(tableNode);\n\n applyFormat(tableNode, context.formatAppliers.block, table.format, context);\n applyFormat(tableNode, context.formatAppliers.table, table.format, context);\n applyFormat(tableNode, context.formatAppliers.tableBorder, table.format, context);\n applyFormat(tableNode, context.formatAppliers.dataset, table.dataset, context);\n }\n\n context.onNodeCreated?.(table, tableNode);\n\n const tbody = doc.createElement('tbody');\n tableNode.appendChild(tbody);\n\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n const tr = (context.allowCacheElement && tableRow.cachedElement) || doc.createElement('tr');\n tbody.appendChild(tr);\n moveChildNodes(tr);\n\n if (!tableRow.cachedElement) {\n if (context.allowCacheElement) {\n tableRow.cachedElement = tr;\n }\n\n applyFormat(tr, context.formatAppliers.tableRow, tableRow.format, context);\n }\n\n context.onNodeCreated?.(tableRow, tr);\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const cell = tableRow.cells[col];\n\n if (cell.isSelected) {\n const tableSelection: TableSelection = context.tableSelection || {\n type: 'table',\n table: tableNode,\n firstColumn: col,\n lastColumn: col,\n firstRow: row,\n lastRow: row,\n };\n\n if (tableSelection.table == tableNode) {\n tableSelection.lastColumn = Math.max(tableSelection.lastColumn, col);\n tableSelection.lastRow = Math.max(tableSelection.lastRow, row);\n }\n\n context.tableSelection = tableSelection;\n }\n\n if (!cell.spanAbove && !cell.spanLeft) {\n const tag = cell.isHeader ? 'th' : 'td';\n const td =\n (context.allowCacheElement && cell.cachedElement) || doc.createElement(tag);\n\n tr.appendChild(td);\n\n let rowSpan = 1;\n let colSpan = 1;\n let width = table.widths[col];\n let height = tableRow.height;\n\n for (; table.rows[row + rowSpan]?.cells[col]?.spanAbove; rowSpan++) {\n height += table.rows[row + rowSpan].height;\n }\n for (; tableRow.cells[col + colSpan]?.spanLeft; colSpan++) {\n width += table.widths[col + colSpan];\n }\n\n if (rowSpan > 1) {\n td.rowSpan = rowSpan;\n }\n\n if (colSpan > 1) {\n td.colSpan = colSpan;\n }\n\n if (!cell.cachedElement || (cell.format.useBorderBox && hasMetadata(table))) {\n if (width > 0 && !td.style.width) {\n td.style.width = width + 'px';\n }\n\n if (height > 0 && !td.style.height) {\n td.style.height = height + 'px';\n }\n }\n\n stackFormat(context, tag, () => {\n if (!cell.cachedElement) {\n if (context.allowCacheElement) {\n cell.cachedElement = td;\n }\n\n applyFormat(td, context.formatAppliers.block, cell.format, context);\n applyFormat(td, context.formatAppliers.tableCell, cell.format, context);\n applyFormat(\n td,\n context.formatAppliers.tableCellBorder,\n cell.format,\n context\n );\n applyFormat(td, context.formatAppliers.dataset, cell.dataset, context);\n }\n\n stackFormat(\n context,\n cell.format.direction ? { direction: cell.format.direction } : null,\n () => {\n context.modelHandlers.blockGroupChildren(doc, td, cell, context);\n }\n );\n });\n\n context.onNodeCreated?.(cell, td);\n }\n }\n }\n\n context.domIndexer?.onTable(tableNode, table);\n\n return refNode;\n};\n"]}
@@ -12,11 +12,13 @@ define(["require", "exports", "../../domUtils/isElementOfType"], function (requi
12
12
  format.direction = dir == 'rtl' ? 'rtl' : 'ltr';
13
13
  }
14
14
  },
15
- apply: function (format, element) {
15
+ apply: function (format, element, context) {
16
16
  if (format.direction) {
17
17
  element.style.direction = format.direction;
18
18
  }
19
- if (format.direction == 'rtl' && (0, isElementOfType_1.isElementOfType)(element, 'table')) {
19
+ if (format.direction == 'rtl' &&
20
+ (0, isElementOfType_1.isElementOfType)(element, 'table') &&
21
+ context.implicitFormat.direction != 'rtl') {
20
22
  element.style.justifySelf = 'flex-end';
21
23
  }
22
24
  },
@@ -1 +1 @@
1
- {"version":3,"file":"directionFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/block/directionFormatHandler.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACU,QAAA,sBAAsB,GAAmC;QAClE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;YACpC,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC;YAE7E,IAAI,GAAG,EAAE;gBACL,MAAM,CAAC,SAAS,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;aACnD;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;YACnB,IAAI,MAAM,CAAC,SAAS,EAAE;gBAClB,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;aAC9C;YAED,IAAI,MAAM,CAAC,SAAS,IAAI,KAAK,IAAI,IAAA,iCAAe,EAAC,OAAO,EAAE,OAAO,CAAC,EAAE;gBAChE,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;aAC1C;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport type { DirectionFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const directionFormatHandler: FormatHandler<DirectionFormat> = {\n parse: (format, element, _, defaultStyle) => {\n const dir = element.style.direction || element.dir || defaultStyle.direction;\n\n if (dir) {\n format.direction = dir == 'rtl' ? 'rtl' : 'ltr';\n }\n },\n apply: (format, element) => {\n if (format.direction) {\n element.style.direction = format.direction;\n }\n\n if (format.direction == 'rtl' && isElementOfType(element, 'table')) {\n element.style.justifySelf = 'flex-end';\n }\n },\n};\n"]}
1
+ {"version":3,"file":"directionFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/block/directionFormatHandler.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACU,QAAA,sBAAsB,GAAmC;QAClE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY;YACpC,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC;YAE7E,IAAI,GAAG,EAAE;gBACL,MAAM,CAAC,SAAS,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;aACnD;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;YAC5B,IAAI,MAAM,CAAC,SAAS,EAAE;gBAClB,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;aAC9C;YAED,IACI,MAAM,CAAC,SAAS,IAAI,KAAK;gBACzB,IAAA,iCAAe,EAAC,OAAO,EAAE,OAAO,CAAC;gBACjC,OAAO,CAAC,cAAc,CAAC,SAAS,IAAI,KAAK,EAC3C;gBACE,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;aAC1C;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport type { DirectionFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const directionFormatHandler: FormatHandler<DirectionFormat> = {\n parse: (format, element, _, defaultStyle) => {\n const dir = element.style.direction || element.dir || defaultStyle.direction;\n\n if (dir) {\n format.direction = dir == 'rtl' ? 'rtl' : 'ltr';\n }\n },\n apply: (format, element, context) => {\n if (format.direction) {\n element.style.direction = format.direction;\n }\n\n if (\n format.direction == 'rtl' &&\n isElementOfType(element, 'table') &&\n context.implicitFormat.direction != 'rtl'\n ) {\n element.style.justifySelf = 'flex-end';\n }\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "../utils/borderKeys"], function (require, exports, tslib_1, borderKeys_1) {
1
+ define(["require", "exports", "tslib", "../utils/borderKeys", "../../domUtils/style/borderValues"], function (require, exports, tslib_1, borderKeys_1, borderValues_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.borderFormatHandler = void 0;
@@ -30,7 +30,17 @@ define(["require", "exports", "tslib", "../utils/borderKeys"], function (require
30
30
  width = '0px';
31
31
  }
32
32
  if (value && width != defaultWidth) {
33
- format[key] = value == 'none' ? '' : value;
33
+ var result = value;
34
+ if (result.includes('initial')) {
35
+ // Remove 'initial' from the last part (color) of the border value
36
+ // since browsers ignore it when setting the inline style property
37
+ var border = (0, borderValues_1.extractBorderValues)(value);
38
+ if (border.color === 'initial') {
39
+ border.color = '';
40
+ }
41
+ result = (0, borderValues_1.combineBorderValue)(border);
42
+ }
43
+ format[key] = result == 'none' ? '' : result;
34
44
  }
35
45
  });
36
46
  var borderRadius = element.style.borderRadius;
@@ -1 +1 @@
1
- {"version":3,"file":"borderFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/borderFormatHandler.ts"],"names":[],"mappings":";;;;IAIA,6CAA6C;IAC7C,IAAM,eAAe,GAAkC;QACnD,gBAAgB;QAChB,kBAAkB;QAClB,mBAAmB;QACnB,iBAAiB;KACpB,CAAC;IAEF,IAAM,gBAAgB,GAAuD;QACzE,qBAAqB;QACrB,sBAAsB;QACtB,wBAAwB;QACxB,yBAAyB;KAC5B,CAAC;IAEF,IAAM,O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;gBAE1B,IAAI,KAAK,EAAE;oBACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBAC9B;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,YAAY,EAAE;gBACrB,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;aACpD;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { BorderKeys } from '../utils/borderKeys';\nimport type { BorderFormat } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n// This array needs to match BorderKeys array\nconst BorderWidthKeys: (keyof CSSStyleDeclaration)[] = [\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n];\n\nconst BorderRadiusKeys: (keyof BorderFormat & keyof CSSStyleDeclaration)[] = [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomLeftRadius',\n 'borderBottomRightRadius',\n];\n\nconst AllKeys = [...BorderKeys, ...BorderRadiusKeys];\n\n/**\n * @internal\n */\nexport const borderFormatHandler: FormatHandler<BorderFormat> = {\n parse: (format, element, _, defaultStyle) => {\n BorderKeys.forEach((key, i) => {\n const value = element.style[key];\n const defaultWidth = defaultStyle[BorderWidthKeys[i]] ?? '0px';\n let width = element.style[BorderWidthKeys[i]];\n\n if (width == '0') {\n width = '0px';\n }\n\n if (value && width != defaultWidth) {\n format[key] = value == 'none' ? '' : value;\n }\n });\n\n const borderRadius = element.style.borderRadius;\n\n if (borderRadius) {\n format.borderRadius = borderRadius;\n } else {\n BorderRadiusKeys.forEach(key => {\n const value = element.style[key];\n\n if (value) {\n format[key] = value;\n }\n });\n }\n },\n apply: (format, element) => {\n AllKeys.forEach(key => {\n const value = format[key];\n\n if (value) {\n element.style[key] = value;\n }\n });\n\n if (format.borderRadius) {\n element.style.borderRadius = format.borderRadius;\n }\n },\n};\n"]}
1
+ {"version":3,"file":"borderFormatHandler.js","sourceRoot":"","sources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C;oBACD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;iBAChD;YACL,CAAC,CAAC,CAAC;YAEH,IAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC;YAEhD,IAAI,YAAY,EAAE;gBACd,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;aACtC;iBAAM;gBACH,gBAAgB,CAAC,OAAO,CAAC,UAAA,GAAG;oBACxB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAEjC,IAAI,KAAK,EAAE;wBACP,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;qBACvB;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC;QACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;YACnB,OAAO,CAAC,OAAO,CAAC,UAAA,GAAG;gBACf,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAE1B,IAAI,KAAK,EAAE;oBACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBAC9B;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,YAAY,EAAE;gBACrB,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;aACpD;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { BorderKeys } from '../utils/borderKeys';\nimport type { BorderFormat } from 'roosterjs-content-model-types';\nimport { combineBorderValue, extractBorderValues } from '../../domUtils/style/borderValues';\nimport type { FormatHandler } from '../FormatHandler';\n\n// This array needs to match BorderKeys array\nconst BorderWidthKeys: (keyof CSSStyleDeclaration)[] = [\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n];\n\nconst BorderRadiusKeys: (keyof BorderFormat & keyof CSSStyleDeclaration)[] = [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomLeftRadius',\n 'borderBottomRightRadius',\n];\n\nconst AllKeys = [...BorderKeys, ...BorderRadiusKeys];\n\n/**\n * @internal\n */\nexport const borderFormatHandler: FormatHandler<BorderFormat> = {\n parse: (format, element, _, defaultStyle) => {\n BorderKeys.forEach((key, i) => {\n const value = element.style[key];\n const defaultWidth = defaultStyle[BorderWidthKeys[i]] ?? '0px';\n let width = element.style[BorderWidthKeys[i]];\n\n if (width == '0') {\n width = '0px';\n }\n\n if (value && width != defaultWidth) {\n let result = value;\n if (result.includes('initial')) {\n // Remove 'initial' from the last part (color) of the border value\n // since browsers ignore it when setting the inline style property\n const border = extractBorderValues(value);\n if (border.color === 'initial') {\n border.color = '';\n }\n result = combineBorderValue(border);\n }\n format[key] = result == 'none' ? '' : result;\n }\n });\n\n const borderRadius = element.style.borderRadius;\n\n if (borderRadius) {\n format.borderRadius = borderRadius;\n } else {\n BorderRadiusKeys.forEach(key => {\n const value = element.style[key];\n\n if (value) {\n format[key] = value;\n }\n });\n }\n },\n apply: (format, element) => {\n AllKeys.forEach(key => {\n const value = format[key];\n\n if (value) {\n element.style[key] = value;\n }\n });\n\n if (format.borderRadius) {\n element.style.borderRadius = format.borderRadius;\n }\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "./addDecorators", "./addSegment", "../creators/createText", "./ensureParagraph", "./hasSpacesOnly", "../../domUtils/isWhiteSpacePreserved"], function (require, exports, addDecorators_1, addSegment_1, createText_1, ensureParagraph_1, hasSpacesOnly_1, isWhiteSpacePreserved_1) {
1
+ define(["require", "exports", "./addDecorators", "./addSegment", "../creators/createText", "./ensureParagraph", "./hasSpacesOnly", "../../domUtils/isWhiteSpacePreserved", "./stripInvisibleUnicode"], function (require, exports, addDecorators_1, addSegment_1, createText_1, ensureParagraph_1, hasSpacesOnly_1, isWhiteSpacePreserved_1, stripInvisibleUnicode_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.addTextSegment = void 0;
@@ -17,7 +17,11 @@ define(["require", "exports", "./addDecorators", "./addSegment", "../creators/cr
17
17
  if (!(0, hasSpacesOnly_1.hasSpacesOnly)(text) ||
18
18
  ((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.segments.length) !== null && _a !== void 0 ? _a : 0) > 0 ||
19
19
  (0, isWhiteSpacePreserved_1.isWhiteSpacePreserved)(paragraph === null || paragraph === void 0 ? void 0 : paragraph.format.whiteSpace)) {
20
- textModel = (0, createText_1.createText)(text, context.segmentFormat);
20
+ var filteredText = context.experimentalFeatures &&
21
+ context.experimentalFeatures.indexOf('FilterInvisibleUnicode') > -1
22
+ ? (0, stripInvisibleUnicode_1.stripInvisibleUnicode)(text)
23
+ : text;
24
+ textModel = (0, createText_1.createText)(filteredText, context.segmentFormat);
21
25
  if (context.isInSelection) {
22
26
  textModel.isSelected = true;
23
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"addTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/addTextSegment.ts"],"names":[],"mappings":";;;;IAYA;;;;;;OAMG;IACH,SAAgB,cAAc,CAC1B,KAA6B,EAC7B,IAAY,EACZ,OAA0B;;QAE1B,IAAI,SAAuC,CAAC;QAE5C,IAAI,IAAI,EAAE;YACN,IAAM,SAAS,GAAG,IAAA,iCAAe,EAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;YAE9D,IACI,CAAC,IAAA,6BAAa,EAAC,IAAI,CAAC;gBACpB,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC;gBACrC,IAAA,6CAAqB,EAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,UAAU,CAAC,EACrD;gBACE,SAAS,GAAG,IAAA,uBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;gBAEpD,IAAI,OAAO,CAAC,aAAa,EAAE;oBACvB,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;iBAC/B;gBAED,IAAA,6BAAa,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAElC,IAAA,uBAAU,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;aACrD;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IA5BD,wCA4BC","sourcesContent":["import { addDecorators } from './addDecorators';\nimport { addSegment } from './addSegment';\nimport { createText } from '../creators/createText';\nimport { ensureParagraph } from './ensureParagraph';\nimport { hasSpacesOnly } from './hasSpacesOnly';\nimport { isWhiteSpacePreserved } from '../../domUtils/isWhiteSpacePreserved';\nimport type {\n ContentModelBlockGroup,\n ContentModelText,\n DomToModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Add a new text segment to current paragraph\n * @param group Current BlockGroup that the paragraph belong to\n * @param text Text content of the text segment\n * @param context Current DOM to Model context\n * @returns A new Text segment, or undefined if the input text is empty\n */\nexport function addTextSegment(\n group: ContentModelBlockGroup,\n text: string,\n context: DomToModelContext\n): ContentModelText | undefined {\n let textModel: ContentModelText | undefined;\n\n if (text) {\n const paragraph = ensureParagraph(group, context.blockFormat);\n\n if (\n !hasSpacesOnly(text) ||\n (paragraph?.segments.length ?? 0) > 0 ||\n isWhiteSpacePreserved(paragraph?.format.whiteSpace)\n ) {\n textModel = createText(text, context.segmentFormat);\n\n if (context.isInSelection) {\n textModel.isSelected = true;\n }\n\n addDecorators(textModel, context);\n\n addSegment(group, textModel, context.blockFormat);\n }\n }\n\n return textModel;\n}\n"]}
1
+ {"version":3,"file":"addTextSegment.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/addTextSegment.ts"],"names":[],"mappings":";;;;IAaA;;;;;;OAMG;IACH,SAAgB,cAAc,CAC1B,KAA6B,EAC7B,IAAY,EACZ,OAA0B;;QAE1B,IAAI,SAAuC,CAAC;QAE5C,IAAI,IAAI,EAAE;YACN,IAAM,SAAS,GAAG,IAAA,iCAAe,EAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;YAE9D,IACI,CAAC,IAAA,6BAAa,EAAC,IAAI,CAAC;gBACpB,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC;gBACrC,IAAA,6CAAqB,EAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,UAAU,CAAC,EACrD;gBACE,IAAM,YAAY,GACd,OAAO,CAAC,oBAAoB;oBAC5B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;oBAC/D,CAAC,CAAC,IAAA,6CAAqB,EAAC,IAAI,CAAC;oBAC7B,CAAC,CAAC,IAAI,CAAC;gBAEf,SAAS,GAAG,IAAA,uBAAU,EAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;gBAE5D,IAAI,OAAO,CAAC,aAAa,EAAE;oBACvB,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;iBAC/B;gBAED,IAAA,6BAAa,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAElC,IAAA,uBAAU,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;aACrD;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAlCD,wCAkCC","sourcesContent":["import { addDecorators } from './addDecorators';\nimport { addSegment } from './addSegment';\nimport { createText } from '../creators/createText';\nimport { ensureParagraph } from './ensureParagraph';\nimport { hasSpacesOnly } from './hasSpacesOnly';\nimport { isWhiteSpacePreserved } from '../../domUtils/isWhiteSpacePreserved';\nimport { stripInvisibleUnicode } from './stripInvisibleUnicode';\nimport type {\n ContentModelBlockGroup,\n ContentModelText,\n DomToModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Add a new text segment to current paragraph\n * @param group Current BlockGroup that the paragraph belong to\n * @param text Text content of the text segment\n * @param context Current DOM to Model context\n * @returns A new Text segment, or undefined if the input text is empty\n */\nexport function addTextSegment(\n group: ContentModelBlockGroup,\n text: string,\n context: DomToModelContext\n): ContentModelText | undefined {\n let textModel: ContentModelText | undefined;\n\n if (text) {\n const paragraph = ensureParagraph(group, context.blockFormat);\n\n if (\n !hasSpacesOnly(text) ||\n (paragraph?.segments.length ?? 0) > 0 ||\n isWhiteSpacePreserved(paragraph?.format.whiteSpace)\n ) {\n const filteredText =\n context.experimentalFeatures &&\n context.experimentalFeatures.indexOf('FilterInvisibleUnicode') > -1\n ? stripInvisibleUnicode(text)\n : text;\n\n textModel = createText(filteredText, context.segmentFormat);\n\n if (context.isInSelection) {\n textModel.isSelected = true;\n }\n\n addDecorators(textModel, context);\n\n addSegment(group, textModel, context.blockFormat);\n }\n }\n\n return textModel;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ * Strip invisible unicode characters from the given string
4
+ * @param value The string to be processed
5
+ * @returns The string with invisible unicode characters removed
6
+ */
7
+ export declare function stripInvisibleUnicode(value: string): string;
@@ -0,0 +1,20 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.stripInvisibleUnicode = void 0;
5
+ // According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
6
+ // there are some invisible unicode characters in the range of U+E0000 to U+EFFFF, which are used for hiding text in HTML.
7
+ // We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
8
+ var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{EFFFF}]/gu;
9
+ /**
10
+ * @internal
11
+ * Strip invisible unicode characters from the given string
12
+ * @param value The string to be processed
13
+ * @returns The string with invisible unicode characters removed
14
+ */
15
+ function stripInvisibleUnicode(value) {
16
+ return value.replace(INVISIBLE_UNICODE_REGEX, '');
17
+ }
18
+ exports.stripInvisibleUnicode = stripInvisibleUnicode;
19
+ });
20
+ //# sourceMappingURL=stripInvisibleUnicode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;;IAAA,oGAAoG;IACpG,0HAA0H;IAC1H,+IAA+I;IAC/I,IAAM,uBAAuB,GAAG,yBAAyB,CAAC;IAE1D;;;;;OAKG;IACH,SAAgB,qBAAqB,CAAC,KAAa;QAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAFD,sDAEC","sourcesContent":["// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/\n// there are some invisible unicode characters in the range of U+E0000 to U+EFFFF, which are used for hiding text in HTML.\n// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.\nconst INVISIBLE_UNICODE_REGEX = /[\\u{E0000}-\\u{EFFFF}]/gu;\n\n/**\n * @internal\n * Strip invisible unicode characters from the given string\n * @param value The string to be processed\n * @returns The string with invisible unicode characters removed\n */\nexport function stripInvisibleUnicode(value: string): string {\n return value.replace(INVISIBLE_UNICODE_REGEX, '');\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
1
+ define(["require", "exports", "../../constants/EmptySegmentFormat", "../../domUtils/getObjectKeys"], function (require, exports, EmptySegmentFormat_1, getObjectKeys_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.createSelectionMarker = void 0;
@@ -7,10 +7,18 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
7
7
  * @param format @optional The format of this model
8
8
  */
9
9
  function createSelectionMarker(format) {
10
+ var filteredFormat = {};
11
+ if (format) {
12
+ (0, getObjectKeys_1.getObjectKeys)(EmptySegmentFormat_1.EmptySegmentFormat).forEach(function (key) {
13
+ if (key in format) {
14
+ filteredFormat[key] = format[key];
15
+ }
16
+ });
17
+ }
10
18
  return {
11
19
  segmentType: 'SelectionMarker',
12
20
  isSelected: true,
13
- format: (0, tslib_1.__assign)({}, format),
21
+ format: filteredFormat,
14
22
  };
15
23
  }
16
24
  exports.createSelectionMarker = createSelectionMarker;
@@ -1 +1 @@
1
- {"version":3,"file":"createSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/creators/createSelectionMarker.ts"],"names":[],"mappings":";;;;IAKA;;;OAGG;IACH,SAAgB,qBAAqB,CACjC,MAA4C;QAE5C,OAAO;YACH,WAAW,EAAE,iBAAiB;YAC9B,UAAU,EAAE,IAAI;YAChB,MAAM,4BAAO,MAAM,CAAE;SACxB,CAAC;IACN,CAAC;IARD,sDAQC","sourcesContent":["import type {\n ContentModelSegmentFormat,\n ContentModelSelectionMarker,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create a ContentModelSelectionMarker model\n * @param format @optional The format of this model\n */\nexport function createSelectionMarker(\n format?: Readonly<ContentModelSegmentFormat>\n): ContentModelSelectionMarker {\n return {\n segmentType: 'SelectionMarker',\n isSelected: true,\n format: { ...format },\n };\n}\n"]}
1
+ {"version":3,"file":"createSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/creators/createSelectionMarker.ts"],"names":[],"mappings":";;;;IAOA;;;OAGG;IACH,SAAgB,qBAAqB,CACjC,MAA4C;QAE5C,IAAM,cAAc,GAA8B,EAAE,CAAC;QAErD,IAAI,MAAM,EAAE;YACR,IAAA,6BAAa,EAAC,uCAAkB,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;gBACzC,IAAI,GAAG,IAAI,MAAM,EAAE;oBACd,cAAc,CAAC,GAAG,CAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;iBAC9C;YACL,CAAC,CAAC,CAAC;SACN;QAED,OAAO;YACH,WAAW,EAAE,iBAAiB;YAC9B,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,cAAc;SACzB,CAAC;IACN,CAAC;IAlBD,sDAkBC","sourcesContent":["import { EmptySegmentFormat } from '../../constants/EmptySegmentFormat';\nimport { getObjectKeys } from '../../domUtils/getObjectKeys';\nimport type {\n ContentModelSegmentFormat,\n ContentModelSelectionMarker,\n} from 'roosterjs-content-model-types';\n\n/**\n * Create a ContentModelSelectionMarker model\n * @param format @optional The format of this model\n */\nexport function createSelectionMarker(\n format?: Readonly<ContentModelSegmentFormat>\n): ContentModelSelectionMarker {\n const filteredFormat: ContentModelSegmentFormat = {};\n\n if (format) {\n getObjectKeys(EmptySegmentFormat).forEach(key => {\n if (key in format) {\n (filteredFormat[key] as any) = format[key];\n }\n });\n }\n\n return {\n segmentType: 'SelectionMarker',\n isSelected: true,\n format: filteredFormat,\n };\n}\n"]}
@@ -28,14 +28,16 @@ define(["require", "exports", "../utils/applyFormat", "../../modelApi/common/isE
28
28
  (0, applyFormat_1.applyFormat)(containerNode_1, context.formatAppliers.segmentOnBlock, container.format, context);
29
29
  (0, applyFormat_1.applyFormat)(containerNode_1, context.formatAppliers.container, container.format, context);
30
30
  });
31
- if (container.tagName == 'pre') {
32
- (0, stackFormat_1.stackFormat)(context, PreChildFormat, function () {
31
+ (0, stackFormat_1.stackFormat)(context, container.format.direction ? { direction: container.format.direction } : null, function () {
32
+ if (container.tagName == 'pre') {
33
+ (0, stackFormat_1.stackFormat)(context, PreChildFormat, function () {
34
+ context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
35
+ });
36
+ }
37
+ else {
33
38
  context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
34
- });
35
- }
36
- else {
37
- context.modelHandlers.blockGroupChildren(doc, containerNode_1, container, context);
38
- }
39
+ }
40
+ });
39
41
  element = containerNode_1;
40
42
  }
41
43
  if (element) {