roosterjs-content-model-dom 9.48.0 → 9.50.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 (61) hide show
  1. package/lib/domUtils/stripInvisibleUnicode.d.ts +12 -0
  2. package/lib/domUtils/stripInvisibleUnicode.js +22 -0
  3. package/lib/domUtils/stripInvisibleUnicode.js.map +1 -0
  4. package/lib/formatHandlers/common/borderColorFormatHandler.js +4 -2
  5. package/lib/formatHandlers/common/borderColorFormatHandler.js.map +1 -1
  6. package/lib/index.d.ts +2 -0
  7. package/lib/index.js +7 -3
  8. package/lib/index.js.map +1 -1
  9. package/lib/modelApi/block/copyFormat.js +2 -0
  10. package/lib/modelApi/block/copyFormat.js.map +1 -1
  11. package/lib/modelApi/common/sanitizeInvisibleUnicode.d.ts +9 -0
  12. package/lib/modelApi/common/sanitizeInvisibleUnicode.js +118 -0
  13. package/lib/modelApi/common/sanitizeInvisibleUnicode.js.map +1 -0
  14. package/lib/modelApi/selection/collectSelections.d.ts +7 -0
  15. package/lib/modelApi/selection/collectSelections.js +5 -2
  16. package/lib/modelApi/selection/collectSelections.js.map +1 -1
  17. package/lib/modelToDom/context/createModelToDomContext.js +1 -0
  18. package/lib/modelToDom/context/createModelToDomContext.js.map +1 -1
  19. package/lib/modelToDom/handlers/handleList.js +2 -0
  20. package/lib/modelToDom/handlers/handleList.js.map +1 -1
  21. package/lib-amd/domUtils/stripInvisibleUnicode.d.ts +12 -0
  22. package/lib-amd/domUtils/stripInvisibleUnicode.js +24 -0
  23. package/lib-amd/domUtils/stripInvisibleUnicode.js.map +1 -0
  24. package/lib-amd/formatHandlers/common/borderColorFormatHandler.js +4 -2
  25. package/lib-amd/formatHandlers/common/borderColorFormatHandler.js.map +1 -1
  26. package/lib-amd/index.d.ts +2 -0
  27. package/lib-amd/index.js +4 -2
  28. package/lib-amd/index.js.map +1 -1
  29. package/lib-amd/modelApi/block/copyFormat.js +2 -0
  30. package/lib-amd/modelApi/block/copyFormat.js.map +1 -1
  31. package/lib-amd/modelApi/common/sanitizeInvisibleUnicode.d.ts +9 -0
  32. package/lib-amd/modelApi/common/sanitizeInvisibleUnicode.js +118 -0
  33. package/lib-amd/modelApi/common/sanitizeInvisibleUnicode.js.map +1 -0
  34. package/lib-amd/modelApi/selection/collectSelections.d.ts +7 -0
  35. package/lib-amd/modelApi/selection/collectSelections.js +5 -2
  36. package/lib-amd/modelApi/selection/collectSelections.js.map +1 -1
  37. package/lib-amd/modelToDom/context/createModelToDomContext.js +1 -0
  38. package/lib-amd/modelToDom/context/createModelToDomContext.js.map +1 -1
  39. package/lib-amd/modelToDom/handlers/handleList.js +2 -0
  40. package/lib-amd/modelToDom/handlers/handleList.js.map +1 -1
  41. package/lib-mjs/domUtils/stripInvisibleUnicode.d.ts +12 -0
  42. package/lib-mjs/domUtils/stripInvisibleUnicode.js +18 -0
  43. package/lib-mjs/domUtils/stripInvisibleUnicode.js.map +1 -0
  44. package/lib-mjs/formatHandlers/common/borderColorFormatHandler.js +4 -2
  45. package/lib-mjs/formatHandlers/common/borderColorFormatHandler.js.map +1 -1
  46. package/lib-mjs/index.d.ts +2 -0
  47. package/lib-mjs/index.js +2 -0
  48. package/lib-mjs/index.js.map +1 -1
  49. package/lib-mjs/modelApi/block/copyFormat.js +2 -0
  50. package/lib-mjs/modelApi/block/copyFormat.js.map +1 -1
  51. package/lib-mjs/modelApi/common/sanitizeInvisibleUnicode.d.ts +9 -0
  52. package/lib-mjs/modelApi/common/sanitizeInvisibleUnicode.js +114 -0
  53. package/lib-mjs/modelApi/common/sanitizeInvisibleUnicode.js.map +1 -0
  54. package/lib-mjs/modelApi/selection/collectSelections.d.ts +7 -0
  55. package/lib-mjs/modelApi/selection/collectSelections.js +5 -2
  56. package/lib-mjs/modelApi/selection/collectSelections.js.map +1 -1
  57. package/lib-mjs/modelToDom/context/createModelToDomContext.js +1 -0
  58. package/lib-mjs/modelToDom/context/createModelToDomContext.js.map +1 -1
  59. package/lib-mjs/modelToDom/handlers/handleList.js +2 -0
  60. package/lib-mjs/modelToDom/handlers/handleList.js.map +1 -1
  61. package/package.json +2 -2
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Strip invisible Unicode characters from a string.
3
+ * This removes zero-width characters, bidirectional marks, Unicode Tags (U+E0001-U+E00FF),
4
+ * interlinear annotation anchors, Mongolian free variation selectors,
5
+ * and other invisible formatting characters that can be used to hide content in links.
6
+ *
7
+ * @remarks This function strips ZWJ (U+200D) which may affect emoji sequences.
8
+ * It should only be applied to href attributes, not to visible text content.
9
+ * @param value The string to strip invisible characters from
10
+ * @returns The string with invisible characters removed
11
+ */
12
+ export declare function stripInvisibleUnicode(value: string): string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripInvisibleUnicode = void 0;
4
+ var INVISIBLE_UNICODE_REGEX =
5
+ // eslint-disable-next-line no-misleading-character-class
6
+ /[\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2028\u2029\u2060-\u2064\u2066-\u2069\u3164\uFEFF\uFFA0\uFFF9-\uFFFB]|\uDB40[\uDC01-\uDCFF]/g;
7
+ /**
8
+ * Strip invisible Unicode characters from a string.
9
+ * This removes zero-width characters, bidirectional marks, Unicode Tags (U+E0001-U+E00FF),
10
+ * interlinear annotation anchors, Mongolian free variation selectors,
11
+ * and other invisible formatting characters that can be used to hide content in links.
12
+ *
13
+ * @remarks This function strips ZWJ (U+200D) which may affect emoji sequences.
14
+ * It should only be applied to href attributes, not to visible text content.
15
+ * @param value The string to strip invisible characters from
16
+ * @returns The string with invisible characters removed
17
+ */
18
+ function stripInvisibleUnicode(value) {
19
+ return value.replace(INVISIBLE_UNICODE_REGEX, '');
20
+ }
21
+ exports.stripInvisibleUnicode = stripInvisibleUnicode;
22
+ //# sourceMappingURL=stripInvisibleUnicode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripInvisibleUnicode.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/domUtils/stripInvisibleUnicode.ts"],"names":[],"mappings":";;;AAAA,IAAM,uBAAuB;AACzB,yDAAyD;AACzD,iLAAiL,CAAC;AAEtL;;;;;;;;;;GAUG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAFD,sDAEC","sourcesContent":["const INVISIBLE_UNICODE_REGEX =\n // eslint-disable-next-line no-misleading-character-class\n /[\\u00AD\\u034F\\u061C\\u115F\\u1160\\u17B4\\u17B5\\u180B-\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2028\\u2029\\u2060-\\u2064\\u2066-\\u2069\\u3164\\uFEFF\\uFFA0\\uFFF9-\\uFFFB]|\\uDB40[\\uDC01-\\uDCFF]/g;\n\n/**\n * Strip invisible Unicode characters from a string.\n * This removes zero-width characters, bidirectional marks, Unicode Tags (U+E0001-U+E00FF),\n * interlinear annotation anchors, Mongolian free variation selectors,\n * and other invisible formatting characters that can be used to hide content in links.\n *\n * @remarks This function strips ZWJ (U+200D) which may affect emoji sequences.\n * It should only be applied to href attributes, not to visible text content.\n * @param value The string to strip invisible characters from\n * @returns The string with invisible characters removed\n */\nexport function stripInvisibleUnicode(value: string): string {\n return value.replace(INVISIBLE_UNICODE_REGEX, '');\n}\n"]}
@@ -22,6 +22,7 @@ var BorderStyleKeyMap = {
22
22
  borderBottom: 'border-bottom-style',
23
23
  borderLeft: 'border-left-style',
24
24
  };
25
+ var DEFAULT_COLOR = '#000000';
25
26
  /**
26
27
  * @internal
27
28
  */
@@ -32,7 +33,8 @@ exports.borderColorFormatHandler = {
32
33
  borderKeys_1.BorderKeys.forEach(function (key) {
33
34
  var width = element.style.getPropertyValue(BorderWidthKeyMap[key]);
34
35
  var style = element.style.getPropertyValue(BorderStyleKeyMap[key]);
35
- var borderColor = (0, color_1.retrieveElementColor)(element, key);
36
+ var color = (0, color_1.retrieveElementColor)(element, key);
37
+ var borderColor = color == 'initial' ? DEFAULT_COLOR : color;
36
38
  if (borderColor) {
37
39
  var lightModeColor = (0, color_1.getLightModeColor)(borderColor, !!context.isDarkMode, context.darkColorHandler);
38
40
  format[key] = (0, borderValues_1.combineBorderValue)({
@@ -51,10 +53,10 @@ exports.borderColorFormatHandler = {
51
53
  var value = format[key];
52
54
  if (value) {
53
55
  var borderValues = (0, borderValues_1.extractBorderValues)(value);
56
+ var borderColorProperty = borderKeys_1.BorderColorKeyMap[key];
54
57
  if (borderValues.color) {
55
58
  var transformedColor = (0, color_1.adaptColor)(element, borderValues.color, 'border', !!context.isDarkMode, context.darkColorHandler);
56
59
  if (transformedColor) {
57
- var borderColorProperty = borderKeys_1.BorderColorKeyMap[key];
58
60
  element.style.setProperty(borderColorProperty, transformedColor);
59
61
  }
60
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"borderColorFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/borderColorFormatHandler.ts"],"names":[],"mappings":";;;AAAA,wCAAqF;AACrF,kDAAoE;AACpE,kEAA4F;AAI5F;;GAEG;AACH,IAAM,iBAAiB,GAEnB;IACA,SAAS,EAAE,kBAAkB;IAC7B,WAAW,EAAE,oBAAoB;IACjC,YAAY,EAAE,qBAAqB;IACnC,UAAU,EAAE,mBAAmB;CAClC,CAAC;AAEF;;GAEG;AACH,IAAM,iBAAiB,GAEnB;IACA,SAAS,EAAE,kBAAkB;IAC7B,WAAW,EAAE,oBAAoB;IACjC,YAAY,EAAE,qBAAqB;IACnC,UAAU,EAAE,mBAAmB;CAClC,CAAC;AAEF;;GAEG;AACU,QAAA,wBAAwB,GAAgC;IACjE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,IACI,OAAO,CAAC,oBAAoB;YAC5B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAA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AC,gBAAgB,CAC3B,CAAC;wBACF,IAAI,gBAAgB,EAAE;4BAClB,IAAM,mBAAmB,GAAG,8BAAiB,CAAC,GAAG,CAAC,CAAC;4BACnD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;yBACpE;qBACJ;iBACJ;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { adaptColor, getLightModeColor, retrieveElementColor } from '../utils/color';\nimport { BorderColorKeyMap, BorderKeys } from '../utils/borderKeys';\nimport { combineBorderValue, extractBorderValues } from '../../domUtils/style/borderValues';\nimport type { BorderFormat, BorderKey } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * Keys of border width\n */\nconst BorderWidthKeyMap: {\n [key in BorderKey]: string;\n} = {\n borderTop: 'border-top-width',\n borderRight: 'border-right-width',\n borderBottom: 'border-bottom-width',\n borderLeft: 'border-left-width',\n};\n\n/**\n * Keys of border styles\n */\nconst BorderStyleKeyMap: {\n [key in BorderKey]: string;\n} = {\n borderTop: 'border-top-style',\n borderRight: 'border-right-style',\n borderBottom: 'border-bottom-style',\n borderLeft: 'border-left-style',\n};\n\n/**\n * @internal\n */\nexport const borderColorFormatHandler: FormatHandler<BorderFormat> = {\n parse: (format, element, context) => {\n if (\n context.experimentalFeatures &&\n context.experimentalFeatures.indexOf('TransformTableBorderColors') > -1\n ) {\n BorderKeys.forEach(key => {\n const width = element.style.getPropertyValue(BorderWidthKeyMap[key]);\n const style = element.style.getPropertyValue(BorderStyleKeyMap[key]);\n const borderColor = retrieveElementColor(element, key);\n\n if (borderColor) {\n const lightModeColor = getLightModeColor(\n borderColor,\n !!context.isDarkMode,\n context.darkColorHandler\n );\n\n format[key] = combineBorderValue({\n width,\n style,\n color: lightModeColor,\n });\n }\n });\n }\n },\n apply: (format, element, context) => {\n if (\n context.experimentalFeatures &&\n context.experimentalFeatures.indexOf('TransformTableBorderColors') > -1\n ) {\n BorderKeys.forEach(key => {\n const value = format[key];\n if (value) {\n const borderValues = extractBorderValues(value);\n if (borderValues.color) {\n const transformedColor = adaptColor(\n element,\n borderValues.color,\n 'border',\n !!context.isDarkMode,\n context.darkColorHandler\n );\n if (transformedColor) {\n const borderColorProperty = BorderColorKeyMap[key];\n element.style.setProperty(borderColorProperty, transformedColor);\n }\n }\n }\n });\n }\n },\n};\n"]}
1
+ {"version":3,"file":"borderColorFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/common/borderColorFormatHandler.ts"],"names":[],"mappings":";;;AAAA,wCAAqF;AACrF,kDAAoE;AACpE,kEAA4F;AAI5F;;GAEG;AACH,IAAM,iBAAiB,GAEnB;IACA,SAAS,EAAE,kBAAkB;IAC7B,WAAW,EAAE,oBAAoB;IACjC,YAAY,EAAE,qBAAqB;IACnC,UAAU,EAAE,mBAAmB;CAClC,CAAC;AAEF;;GAEG;AACH,IAAM,iBAAiB,GAEnB;IACA,SAAS,EAAE,kBAAkB;IAC7B,WAAW,EAAE,oBAAoB;IACjC,YAAY,EAAE,qBAAqB;IACnC,UAAU,EAAE,mBAAmB;CAClC,CAAC;AAEF,IAAM,aAAa,GAAG,SAAS,CAAC;AAEhC;;GAEG;AACU,QAAA,wBAAwB,GAAgC;IACjE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,IACI,OAAO,CAAC,oBAAoB;YAC5B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,EACzE;YACE,uBAAU,CAAC,OAAO,CAAC,UAAA,GAAG;gBAClB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;gBACrE,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,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CAAC;yBACpE;qBACJ;iBACJ;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { adaptColor, getLightModeColor, retrieveElementColor } from '../utils/color';\nimport { BorderColorKeyMap, BorderKeys } from '../utils/borderKeys';\nimport { combineBorderValue, extractBorderValues } from '../../domUtils/style/borderValues';\nimport type { BorderFormat, BorderKey } from 'roosterjs-content-model-types';\nimport type { FormatHandler } from '../FormatHandler';\n\n/**\n * Keys of border width\n */\nconst BorderWidthKeyMap: {\n [key in BorderKey]: string;\n} = {\n borderTop: 'border-top-width',\n borderRight: 'border-right-width',\n borderBottom: 'border-bottom-width',\n borderLeft: 'border-left-width',\n};\n\n/**\n * Keys of border styles\n */\nconst BorderStyleKeyMap: {\n [key in BorderKey]: string;\n} = {\n borderTop: 'border-top-style',\n borderRight: 'border-right-style',\n borderBottom: 'border-bottom-style',\n borderLeft: 'border-left-style',\n};\n\nconst DEFAULT_COLOR = '#000000';\n\n/**\n * @internal\n */\nexport const borderColorFormatHandler: FormatHandler<BorderFormat> = {\n parse: (format, element, context) => {\n if (\n context.experimentalFeatures &&\n context.experimentalFeatures.indexOf('TransformTableBorderColors') > -1\n ) {\n BorderKeys.forEach(key => {\n const width = element.style.getPropertyValue(BorderWidthKeyMap[key]);\n const style = element.style.getPropertyValue(BorderStyleKeyMap[key]);\n const color = retrieveElementColor(element, key);\n const borderColor = color == 'initial' ? DEFAULT_COLOR : color;\n\n if (borderColor) {\n const lightModeColor = getLightModeColor(\n borderColor,\n !!context.isDarkMode,\n context.darkColorHandler\n );\n\n format[key] = combineBorderValue({\n width,\n style,\n color: lightModeColor,\n });\n }\n });\n }\n },\n apply: (format, element, context) => {\n if (\n context.experimentalFeatures &&\n context.experimentalFeatures.indexOf('TransformTableBorderColors') > -1\n ) {\n BorderKeys.forEach(key => {\n const value = format[key];\n if (value) {\n const borderValues = extractBorderValues(value);\n const borderColorProperty = BorderColorKeyMap[key];\n if (borderValues.color) {\n const transformedColor = adaptColor(\n element,\n borderValues.color,\n 'border',\n !!context.isDarkMode,\n context.darkColorHandler\n );\n if (transformedColor) {\n element.style.setProperty(borderColorProperty, transformedColor);\n }\n }\n }\n });\n }\n },\n};\n"]}
package/lib/index.d.ts CHANGED
@@ -50,6 +50,7 @@ export { addLink } from './modelApi/common/addDecorators';
50
50
  export { addTextSegment } from './modelApi/common/addTextSegment';
51
51
  export { normalizeParagraph } from './modelApi/common/normalizeParagraph';
52
52
  export { normalizeContentModel } from './modelApi/common/normalizeContentModel';
53
+ export { sanitizeInvisibleUnicode } from './modelApi/common/sanitizeInvisibleUnicode';
53
54
  export { isGeneralSegment } from './modelApi/typeCheck/isGeneralSegment';
54
55
  export { unwrapBlock } from './modelApi/common/unwrapBlock';
55
56
  export { addSegment } from './modelApi/common/addSegment';
@@ -74,6 +75,7 @@ export { isCharacterValue, isModifierKey, isCursorMovingKey } from './domUtils/e
74
75
  export { getNodePositionFromEvent } from './domUtils/event/getNodePositionFromEvent';
75
76
  export { combineBorderValue, extractBorderValues } from './domUtils/style/borderValues';
76
77
  export { isPunctuation, isSpace, normalizeText } from './domUtils/stringUtil';
78
+ export { stripInvisibleUnicode } from './domUtils/stripInvisibleUnicode';
77
79
  export { parseTableCells } from './domUtils/table/parseTableCells';
78
80
  export { readFile } from './domUtils/readFile';
79
81
  export { retrieveDocumentMetadata } from './domUtils/retrieveDocumentMetadata';
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createImage = exports.createText = exports.createTableCell = exports.createTable = exports.createSelectionMarker = exports.createParagraph = exports.createFormatContainer = exports.createListItem = exports.createBr = exports.isLinkUndeletable = exports.setLinkUndeletable = exports.scrollRectIntoView = exports.normalizeRect = exports.isWhiteSpacePreserved = exports.reuseCachedElement = exports.findClosestBlockEntityContainer = exports.isBlockEntityContainer = exports.isEntityDelimiter = exports.addDelimiters = exports.generateEntityClassNames = exports.parseEntityFormat = exports.getAllEntityWrappers = exports.findClosestEntityWrapper = exports.isEntityElement = exports.unwrap = exports.wrap = exports.wrapAllChildNodes = exports.moveChildNodes = exports.toArray = exports.getSafeIdSelector = exports.getObjectKeys = exports.isElementOfType = exports.isNodeOfType = exports.hasMetadata = exports.getMetadata = exports.updateMetadata = exports.buildSelectionMarker = exports.isBlockElement = exports.areSameFormats = exports.parseFormat = exports.getRegularSelectionOffsets = exports.formatContainerProcessor = exports.tableProcessor = exports.entityProcessor = exports.processChildNode = exports.handleRegularSelection = exports.childProcessor = exports.contentModelToText = exports.contentModelToDom = exports.domToContentModel = void 0;
4
- exports.trimModelForSelection = exports.getDOMInsertPointRect = exports.getSelectionRootNode = exports.isBold = exports.createModelToDomConfig = exports.createModelToDomContextWithConfig = exports.createModelToDomContext = exports.createDomToModelConfig = exports.createDomToModelContextWithConfig = exports.createDomToModelContext = exports.defaultGenerateColorKey = exports.parseColor = exports.setColor = exports.getColor = exports.DeprecatedColors = exports.BorderKeys = exports.parseValueWithUnit = exports.getAutoListStyleType = exports.getOrderedListNumberStr = exports.ParagraphFormats = exports.ListFormatsToMove = exports.ListFormatsToKeep = exports.ListFormats = exports.copyFormat = exports.setParagraphNotImplicit = exports.normalizeSegmentFormat = exports.mergeTextSegments = exports.normalizeSingleSegment = exports.isEmpty = exports.addSegment = exports.unwrapBlock = exports.isGeneralSegment = exports.normalizeContentModel = exports.normalizeParagraph = exports.addTextSegment = exports.addLink = exports.addCode = exports.addBlock = exports.mutateSegment = exports.mutateSegments = exports.mutateBlock = exports.createTableRow = exports.createEmptyModel = exports.createListLevel = exports.createDivider = exports.createEntity = exports.createGeneralBlock = exports.createGeneralSegment = exports.createParagraphDecorator = exports.createContentModelDocument = void 0;
5
- exports.runEditSteps = exports.getClosestAncestorBlockGroupIndex = exports.getSegmentTextFormat = exports.getListStyleTypeFromString = exports.retrieveModelFormatState = exports.setTableCellBackgroundColor = exports.MIN_ALLOWED_TABLE_CELL_HEIGHT = exports.MIN_ALLOWED_TABLE_CELL_WIDTH = exports.normalizeTable = exports.setFirstColumnFormatBorders = exports.applyTableFormat = exports.deleteBlock = exports.deleteSegment = exports.deleteSelection = exports.mergeModel = exports.cloneModel = exports.setSelection = exports.hasSelectionInBlockGroup = exports.hasSelectionInSegment = exports.hasSelectionInBlock = exports.getSelectedCells = exports.getSelectedSegmentsAndParagraphs = exports.getSelectedSegments = exports.getSelectedParagraphs = exports.getOperationalBlocks = exports.getFirstSelectedTable = exports.getFirstSelectedListItem = exports.iterateSelections = exports.isBlockGroupOfType = exports.getRangesByText = exports.getImageState = exports.setImageState = exports.getParagraphMarker = exports.setParagraphMarker = exports.cacheGetEventData = exports.extractClipboardItems = exports.normalizeFontFamily = exports.transformColor = exports.retrieveDocumentMetadata = exports.readFile = exports.parseTableCells = exports.normalizeText = exports.isSpace = exports.isPunctuation = exports.extractBorderValues = exports.combineBorderValue = exports.getNodePositionFromEvent = exports.isCursorMovingKey = exports.isModifierKey = exports.isCharacterValue = void 0;
6
- exports.EmptySegmentFormat = exports.UnorderedListStyleMap = exports.OrderedListStyleMap = exports.TableBorderFormat = exports.NumberingListType = exports.BulletListType = exports.ChangeSource = exports.ListMetadataDefinition = exports.getListMetadata = exports.updateListMetadata = exports.getTableMetadata = exports.updateTableMetadata = exports.getTableCellMetadata = exports.updateTableCellMetadata = exports.getImageMetadata = exports.updateImageMetadata = void 0;
4
+ exports.getDOMInsertPointRect = exports.getSelectionRootNode = exports.isBold = exports.createModelToDomConfig = exports.createModelToDomContextWithConfig = exports.createModelToDomContext = exports.createDomToModelConfig = exports.createDomToModelContextWithConfig = exports.createDomToModelContext = exports.defaultGenerateColorKey = exports.parseColor = exports.setColor = exports.getColor = exports.DeprecatedColors = exports.BorderKeys = exports.parseValueWithUnit = exports.getAutoListStyleType = exports.getOrderedListNumberStr = exports.ParagraphFormats = exports.ListFormatsToMove = exports.ListFormatsToKeep = exports.ListFormats = exports.copyFormat = exports.setParagraphNotImplicit = exports.normalizeSegmentFormat = exports.mergeTextSegments = exports.normalizeSingleSegment = exports.isEmpty = exports.addSegment = exports.unwrapBlock = exports.isGeneralSegment = exports.sanitizeInvisibleUnicode = exports.normalizeContentModel = exports.normalizeParagraph = exports.addTextSegment = exports.addLink = exports.addCode = exports.addBlock = exports.mutateSegment = exports.mutateSegments = exports.mutateBlock = exports.createTableRow = exports.createEmptyModel = exports.createListLevel = exports.createDivider = exports.createEntity = exports.createGeneralBlock = exports.createGeneralSegment = exports.createParagraphDecorator = exports.createContentModelDocument = void 0;
5
+ exports.getSegmentTextFormat = exports.getListStyleTypeFromString = exports.retrieveModelFormatState = exports.setTableCellBackgroundColor = exports.MIN_ALLOWED_TABLE_CELL_HEIGHT = exports.MIN_ALLOWED_TABLE_CELL_WIDTH = exports.normalizeTable = exports.setFirstColumnFormatBorders = exports.applyTableFormat = exports.deleteBlock = exports.deleteSegment = exports.deleteSelection = exports.mergeModel = exports.cloneModel = exports.setSelection = exports.hasSelectionInBlockGroup = exports.hasSelectionInSegment = exports.hasSelectionInBlock = exports.getSelectedCells = exports.getSelectedSegmentsAndParagraphs = exports.getSelectedSegments = exports.getSelectedParagraphs = exports.getOperationalBlocks = exports.getFirstSelectedTable = exports.getFirstSelectedListItem = exports.iterateSelections = exports.isBlockGroupOfType = exports.getRangesByText = exports.getImageState = exports.setImageState = exports.getParagraphMarker = exports.setParagraphMarker = exports.cacheGetEventData = exports.extractClipboardItems = exports.normalizeFontFamily = exports.transformColor = exports.retrieveDocumentMetadata = exports.readFile = exports.parseTableCells = exports.stripInvisibleUnicode = exports.normalizeText = exports.isSpace = exports.isPunctuation = exports.extractBorderValues = exports.combineBorderValue = exports.getNodePositionFromEvent = exports.isCursorMovingKey = exports.isModifierKey = exports.isCharacterValue = exports.trimModelForSelection = void 0;
6
+ exports.EmptySegmentFormat = exports.UnorderedListStyleMap = exports.OrderedListStyleMap = exports.TableBorderFormat = exports.NumberingListType = exports.BulletListType = exports.ChangeSource = exports.ListMetadataDefinition = exports.getListMetadata = exports.updateListMetadata = exports.getTableMetadata = exports.updateTableMetadata = exports.getTableCellMetadata = exports.updateTableCellMetadata = exports.getImageMetadata = exports.updateImageMetadata = exports.runEditSteps = exports.getClosestAncestorBlockGroupIndex = void 0;
7
7
  var domToContentModel_1 = require("./domToModel/domToContentModel");
8
8
  Object.defineProperty(exports, "domToContentModel", { enumerable: true, get: function () { return domToContentModel_1.domToContentModel; } });
9
9
  var contentModelToDom_1 = require("./modelToDom/contentModelToDom");
@@ -124,6 +124,8 @@ var normalizeParagraph_1 = require("./modelApi/common/normalizeParagraph");
124
124
  Object.defineProperty(exports, "normalizeParagraph", { enumerable: true, get: function () { return normalizeParagraph_1.normalizeParagraph; } });
125
125
  var normalizeContentModel_1 = require("./modelApi/common/normalizeContentModel");
126
126
  Object.defineProperty(exports, "normalizeContentModel", { enumerable: true, get: function () { return normalizeContentModel_1.normalizeContentModel; } });
127
+ var sanitizeInvisibleUnicode_1 = require("./modelApi/common/sanitizeInvisibleUnicode");
128
+ Object.defineProperty(exports, "sanitizeInvisibleUnicode", { enumerable: true, get: function () { return sanitizeInvisibleUnicode_1.sanitizeInvisibleUnicode; } });
127
129
  var isGeneralSegment_1 = require("./modelApi/typeCheck/isGeneralSegment");
128
130
  Object.defineProperty(exports, "isGeneralSegment", { enumerable: true, get: function () { return isGeneralSegment_1.isGeneralSegment; } });
129
131
  var unwrapBlock_1 = require("./modelApi/common/unwrapBlock");
@@ -189,6 +191,8 @@ var stringUtil_1 = require("./domUtils/stringUtil");
189
191
  Object.defineProperty(exports, "isPunctuation", { enumerable: true, get: function () { return stringUtil_1.isPunctuation; } });
190
192
  Object.defineProperty(exports, "isSpace", { enumerable: true, get: function () { return stringUtil_1.isSpace; } });
191
193
  Object.defineProperty(exports, "normalizeText", { enumerable: true, get: function () { return stringUtil_1.normalizeText; } });
194
+ var stripInvisibleUnicode_1 = require("./domUtils/stripInvisibleUnicode");
195
+ Object.defineProperty(exports, "stripInvisibleUnicode", { enumerable: true, get: function () { return stripInvisibleUnicode_1.stripInvisibleUnicode; } });
192
196
  var parseTableCells_1 = require("./domUtils/table/parseTableCells");
193
197
  Object.defineProperty(exports, "parseTableCells", { enumerable: true, get: function () { return parseTableCells_1.parseTableCells; } });
194
198
  var readFile_1 = require("./domUtils/readFile");
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-dom/lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAmE;AAA1D,sHAAA,iBAAiB,OAAA;AAC1B,oEAAmE;AAA1D,sHAAA,iBAAiB,OAAA;AAC1B,uEAAsE;AAA7D,wHAAA,kBAAkB,OAAA;AAE3B,yEAIgD;AAH5C,gHAAA,cAAc,OAAA;AACd,wHAAA,sBAAsB,OAAA;AACtB,kHAAA,gBAAgB,OAAA;AAEpB,2EAA0E;AAAjE,kHAAA,eAAe,OAAA;AACxB,yEAAwE;AAA/D,gHAAA,cAAc,OAAA;AACvB,6FAA4F;AAAnF,oIAAA,wBAAwB,OAAA;AACjC,4FAA2F;AAAlF,wIAAA,0BAA0B,OAAA;AACnC,8DAA6D;AAApD,0GAAA,WAAW,OAAA;AACpB,oEAAmE;AAA1D,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,gHAAA,cAAc,OAAA;AACvB,gFAA+E;AAAtE,4HAAA,oBAAoB,OAAA;AAE7B,qEAA8F;AAArF,gHAAA,cAAc,OAAA;AAAE,6GAAA,WAAW,OAAA;AAAE,6GAAA,WAAW,OAAA;AACjD,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,8DAA6D;AAApD,kHAAA,eAAe,OAAA;AACxB,0DAAyD;AAAhD,8GAAA,aAAa,OAAA;AACtB,kEAAiE;AAAxD,sHAAA,iBAAiB,OAAA;AAC1B,8CAA6C;AAApC,kGAAA,OAAO,OAAA;AAChB,4DAA8E;AAArE,gHAAA,cAAc,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AAC1C,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0HAAA,mBAAmB,OAAA;AAAE,uHAAA,gBAAgB,OAAA;AAC9C,6EAIgD;AAH5C,wHAAA,kBAAkB,OAAA;AAClB,qHAAA,eAAe,OAAA;AACf,4HAAA,sBAAsB,OAAA;AAG1B,yDAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AACvB,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,uEAAsE;AAA7D,0HAAA,mBAAmB,OAAA;AAC5B,2EAA0E;AAAjE,8HAAA,qBAAqB,OAAA;AAC9B,qEAAoE;AAA3D,wHAAA,kBAAkB,OAAA","sourcesContent":["export { domToContentModel } from './domToModel/domToContentModel';\nexport { contentModelToDom } from './modelToDom/contentModelToDom';\nexport { contentModelToText } from './modelToText/contentModelToText';\n\nexport {\n childProcessor,\n handleRegularSelection,\n processChildNode,\n} from './domToModel/processors/childProcessor';\nexport { entityProcessor } from './domToModel/processors/entityProcessor';\nexport { tableProcessor } from './domToModel/processors/tableProcessor';\nexport { formatContainerProcessor } from './domToModel/processors/formatContainerProcessor';\nexport { getRegularSelectionOffsets } from './domToModel/utils/getRegularSelectionOffsets';\nexport { parseFormat } from './domToModel/utils/parseFormat';\nexport { areSameFormats } from './domToModel/utils/areSameFormats';\nexport { isBlockElement } from './domToModel/utils/isBlockElement';\nexport { buildSelectionMarker } from './domToModel/utils/buildSelectionMarker';\n\nexport { updateMetadata, getMetadata, hasMetadata } from './modelApi/metadata/updateMetadata';\nexport { isNodeOfType } from './domUtils/isNodeOfType';\nexport { isElementOfType } from './domUtils/isElementOfType';\nexport { getObjectKeys } from './domUtils/getObjectKeys';\nexport { getSafeIdSelector } from './domUtils/getSafeIdSelector';\nexport { toArray } from './domUtils/toArray';\nexport { moveChildNodes, wrapAllChildNodes } from './domUtils/moveChildNodes';\nexport { wrap } from './domUtils/wrap';\nexport { unwrap } from './domUtils/unwrap';\nexport {\n isEntityElement,\n findClosestEntityWrapper,\n getAllEntityWrappers,\n parseEntityFormat,\n generateEntityClassNames,\n addDelimiters,\n isEntityDelimiter,\n isBlockEntityContainer,\n findClosestBlockEntityContainer,\n} from './domUtils/entityUtils';\nexport { reuseCachedElement } from './domUtils/reuseCachedElement';\nexport { isWhiteSpacePreserved } from './domUtils/isWhiteSpacePreserved';\nexport { normalizeRect } from './domUtils/normalizeRect';\nexport { scrollRectIntoView } from './domUtils/scrollRectIntoView';\n\nexport { setLinkUndeletable, isLinkUndeletable } from './domUtils/hiddenProperties/undeletableLink';\n\nexport { createBr } from './modelApi/creators/createBr';\nexport { createListItem } from './modelApi/creators/createListItem';\nexport { createFormatContainer } from './modelApi/creators/createFormatContainer';\nexport { createParagraph } from './modelApi/creators/createParagraph';\nexport { createSelectionMarker } from './modelApi/creators/createSelectionMarker';\nexport { createTable } from './modelApi/creators/createTable';\nexport { createTableCell } from './modelApi/creators/createTableCell';\nexport { createText } from './modelApi/creators/createText';\nexport { createImage } from './modelApi/creators/createImage';\nexport { createContentModelDocument } from './modelApi/creators/createContentModelDocument';\nexport { createParagraphDecorator } from './modelApi/creators/createParagraphDecorator';\nexport { createGeneralSegment } from './modelApi/creators/createGeneralSegment';\nexport { createGeneralBlock } from './modelApi/creators/createGeneralBlock';\nexport { createEntity } from './modelApi/creators/createEntity';\nexport { createDivider } from './modelApi/creators/createDivider';\nexport { createListLevel } from './modelApi/creators/createListLevel';\nexport { createEmptyModel } from './modelApi/creators/createEmptyModel';\nexport { createTableRow } from './modelApi/creators/createTableRow';\n\nexport { mutateBlock, mutateSegments, mutateSegment } from './modelApi/common/mutate';\nexport { addBlock } from './modelApi/common/addBlock';\nexport { addCode } from './modelApi/common/addDecorators';\nexport { addLink } from './modelApi/common/addDecorators';\nexport { addTextSegment } from './modelApi/common/addTextSegment';\nexport { normalizeParagraph } from './modelApi/common/normalizeParagraph';\n\nexport { normalizeContentModel } from './modelApi/common/normalizeContentModel';\nexport { isGeneralSegment } from './modelApi/typeCheck/isGeneralSegment';\nexport { unwrapBlock } from './modelApi/common/unwrapBlock';\nexport { addSegment } from './modelApi/common/addSegment';\nexport { isEmpty } from './modelApi/common/isEmpty';\nexport { normalizeSingleSegment } from './modelApi/common/normalizeSegment';\nexport { mergeTextSegments } from './modelApi/common/mergeTextSegments';\nexport { normalizeSegmentFormat } from './modelApi/common/normalizeSegmentFormat';\n\nexport { setParagraphNotImplicit } from './modelApi/block/setParagraphNotImplicit';\nexport {\n copyFormat,\n ListFormats,\n ListFormatsToKeep,\n ListFormatsToMove,\n ParagraphFormats,\n} from './modelApi/block/copyFormat';\nexport { getOrderedListNumberStr } from './modelApi/list/getOrderedListNumberStr';\nexport { getAutoListStyleType } from './modelApi/list/getAutoListStyleType';\n\nexport { parseValueWithUnit } from './formatHandlers/utils/parseValueWithUnit';\nexport { BorderKeys } from './formatHandlers/utils/borderKeys';\nexport {\n DeprecatedColors,\n getColor,\n setColor,\n parseColor,\n defaultGenerateColorKey,\n} from './formatHandlers/utils/color';\n\nexport {\n createDomToModelContext,\n createDomToModelContextWithConfig,\n createDomToModelConfig,\n} from './domToModel/context/createDomToModelContext';\nexport {\n createModelToDomContext,\n createModelToDomContextWithConfig,\n createModelToDomConfig,\n} from './modelToDom/context/createModelToDomContext';\n\nexport { isBold } from './domUtils/style/isBold';\nexport { getSelectionRootNode } from './domUtils/selection/getSelectionRootNode';\nexport { getDOMInsertPointRect } from './domUtils/selection/getDOMInsertPointRect';\nexport { trimModelForSelection } from './domUtils/selection/trimModelForSelection';\nexport { isCharacterValue, isModifierKey, isCursorMovingKey } from './domUtils/event/eventUtils';\nexport { getNodePositionFromEvent } from './domUtils/event/getNodePositionFromEvent';\nexport { combineBorderValue, extractBorderValues } from './domUtils/style/borderValues';\nexport { isPunctuation, isSpace, normalizeText } from './domUtils/stringUtil';\nexport { parseTableCells } from './domUtils/table/parseTableCells';\nexport { readFile } from './domUtils/readFile';\nexport { retrieveDocumentMetadata } from './domUtils/retrieveDocumentMetadata';\nexport { transformColor, TransformColorOptions } from './domUtils/style/transformColor';\nexport { normalizeFontFamily } from './domUtils/style/normalizeFontFamily';\nexport { extractClipboardItems } from './domUtils/event/extractClipboardItems';\nexport { cacheGetEventData } from './domUtils/event/cacheGetEventData';\nexport {\n setParagraphMarker,\n getParagraphMarker,\n} from './domUtils/hiddenProperties/paragraphMarker';\nexport { setImageState, getImageState } from './domUtils/hiddenProperties/imageState';\nexport { getRangesByText } from './domUtils/getRangesByText';\n\nexport { isBlockGroupOfType } from './modelApi/typeCheck/isBlockGroupOfType';\n\nexport { iterateSelections } from './modelApi/selection/iterateSelections';\nexport {\n getFirstSelectedListItem,\n getFirstSelectedTable,\n getOperationalBlocks,\n getSelectedParagraphs,\n getSelectedSegments,\n getSelectedSegmentsAndParagraphs,\n} from './modelApi/selection/collectSelections';\nexport { getSelectedCells } from './modelApi/selection/getSelectedCells';\nexport { hasSelectionInBlock } from './modelApi/selection/hasSelectionInBlock';\nexport { hasSelectionInSegment } from './modelApi/selection/hasSelectionInSegment';\nexport { hasSelectionInBlockGroup } from './modelApi/selection/hasSelectionInBlockGroup';\nexport { setSelection } from './modelApi/selection/setSelection';\n\nexport { cloneModel } from './modelApi/editing/cloneModel';\nexport { mergeModel } from './modelApi/editing/mergeModel';\nexport { deleteSelection } from './modelApi/editing/deleteSelection';\nexport { deleteSegment } from './modelApi/editing/deleteSegment';\nexport { deleteBlock } from './modelApi/editing/deleteBlock';\nexport { applyTableFormat, setFirstColumnFormatBorders } from './modelApi/editing/applyTableFormat';\nexport {\n normalizeTable,\n MIN_ALLOWED_TABLE_CELL_WIDTH,\n MIN_ALLOWED_TABLE_CELL_HEIGHT,\n} from './modelApi/editing/normalizeTable';\nexport { setTableCellBackgroundColor } from './modelApi/editing/setTableCellBackgroundColor';\nexport { retrieveModelFormatState } from './modelApi/editing/retrieveModelFormatState';\nexport { getListStyleTypeFromString } from './modelApi/editing/getListStyleTypeFromString';\nexport { getSegmentTextFormat } from './modelApi/editing/getSegmentTextFormat';\nexport { getClosestAncestorBlockGroupIndex } from './modelApi/editing/getClosestAncestorBlockGroupIndex';\nexport { runEditSteps } from './modelApi/editing/runEditSteps';\n\nexport { updateImageMetadata, getImageMetadata } from './modelApi/metadata/updateImageMetadata';\nexport {\n updateTableCellMetadata,\n getTableCellMetadata,\n} from './modelApi/metadata/updateTableCellMetadata';\nexport { updateTableMetadata, getTableMetadata } from './modelApi/metadata/updateTableMetadata';\nexport {\n updateListMetadata,\n getListMetadata,\n ListMetadataDefinition,\n} from './modelApi/metadata/updateListMetadata';\n\nexport { ChangeSource } from './constants/ChangeSource';\nexport { BulletListType } from './constants/BulletListType';\nexport { NumberingListType } from './constants/NumberingListType';\nexport { TableBorderFormat } from './constants/TableBorderFormat';\nexport { OrderedListStyleMap } from './constants/OrderedListStyleMap';\nexport { UnorderedListStyleMap } from './constants/UnorderedListStyleMap';\nexport { EmptySegmentFormat } from './constants/EmptySegmentFormat';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-dom/lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAmE;AAA1D,sHAAA,iBAAiB,OAAA;AAC1B,oEAAmE;AAA1D,sHAAA,iBAAiB,OAAA;AAC1B,uEAAsE;AAA7D,wHAAA,kBAAkB,OAAA;AAE3B,yEAIgD;AAH5C,gHAAA,cAAc,OAAA;AACd,wHAAA,sBAAsB,OAAA;AACtB,kHAAA,gBAAgB,OAAA;AAEpB,2EAA0E;AAAjE,kHAAA,eAAe,OAAA;AACxB,yEAAwE;AAA/D,gHAAA,cAAc,OAAA;AACvB,6FAA4F;AAAnF,oIAAA,wBAAwB,OAAA;AACjC,4FAA2F;AAAlF,wIAAA,0BAA0B,OAAA;AACnC,8DAA6D;AAApD,0GAAA,WAAW,OAAA;AACpB,oEAAmE;AAA1D,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,gHAAA,cAAc,OAAA;AACvB,gFAA+E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Ac,OAAA;AACd,8HAAA,4BAA4B,OAAA;AAC5B,+HAAA,6BAA6B,OAAA;AAEjC,8FAA6F;AAApF,0IAAA,2BAA2B,OAAA;AACpC,wFAAuF;AAA9E,oIAAA,wBAAwB,OAAA;AACjC,4FAA2F;AAAlF,wIAAA,0BAA0B,OAAA;AACnC,gFAA+E;AAAtE,4HAAA,oBAAoB,OAAA;AAC7B,0GAAyG;AAAhG,sJAAA,iCAAiC,OAAA;AAC1C,gEAA+D;AAAtD,4GAAA,YAAY,OAAA;AAErB,+EAAgG;AAAvF,0HAAA,mBAAmB,OAAA;AAAE,uHAAA,gBAAgB,OAAA;AAC9C,uFAGqD;AAFjD,kIAAA,uBAAuB,OAAA;AACvB,+HAAA,oBAAoB,OAAA;AAExB,+EAAgG;AAAvF,0HAAA,mBAAmB,OAAA;AAAE,uHAAA,gBAAgB,OAAA;AAC9C,6EAIgD;AAH5C,wHAAA,kBAAkB,OAAA;AAClB,qHAAA,eAAe,OAAA;AACf,4HAAA,sBAAsB,OAAA;AAG1B,yDAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AACvB,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,uEAAsE;AAA7D,0HAAA,mBAAmB,OAAA;AAC5B,2EAA0E;AAAjE,8HAAA,qBAAqB,OAAA;AAC9B,qEAAoE;AAA3D,wHAAA,kBAAkB,OAAA","sourcesContent":["export { domToContentModel } from './domToModel/domToContentModel';\nexport { contentModelToDom } from './modelToDom/contentModelToDom';\nexport { contentModelToText } from './modelToText/contentModelToText';\n\nexport {\n childProcessor,\n handleRegularSelection,\n processChildNode,\n} from './domToModel/processors/childProcessor';\nexport { entityProcessor } from './domToModel/processors/entityProcessor';\nexport { tableProcessor } from './domToModel/processors/tableProcessor';\nexport { formatContainerProcessor } from './domToModel/processors/formatContainerProcessor';\nexport { getRegularSelectionOffsets } from './domToModel/utils/getRegularSelectionOffsets';\nexport { parseFormat } from './domToModel/utils/parseFormat';\nexport { areSameFormats } from './domToModel/utils/areSameFormats';\nexport { isBlockElement } from './domToModel/utils/isBlockElement';\nexport { buildSelectionMarker } from './domToModel/utils/buildSelectionMarker';\n\nexport { updateMetadata, getMetadata, hasMetadata } from './modelApi/metadata/updateMetadata';\nexport { isNodeOfType } from './domUtils/isNodeOfType';\nexport { isElementOfType } from './domUtils/isElementOfType';\nexport { getObjectKeys } from './domUtils/getObjectKeys';\nexport { getSafeIdSelector } from './domUtils/getSafeIdSelector';\nexport { toArray } from './domUtils/toArray';\nexport { moveChildNodes, wrapAllChildNodes } from './domUtils/moveChildNodes';\nexport { wrap } from './domUtils/wrap';\nexport { unwrap } from './domUtils/unwrap';\nexport {\n isEntityElement,\n findClosestEntityWrapper,\n getAllEntityWrappers,\n parseEntityFormat,\n generateEntityClassNames,\n addDelimiters,\n isEntityDelimiter,\n isBlockEntityContainer,\n findClosestBlockEntityContainer,\n} from './domUtils/entityUtils';\nexport { reuseCachedElement } from './domUtils/reuseCachedElement';\nexport { isWhiteSpacePreserved } from './domUtils/isWhiteSpacePreserved';\nexport { normalizeRect } from './domUtils/normalizeRect';\nexport { scrollRectIntoView } from './domUtils/scrollRectIntoView';\n\nexport { setLinkUndeletable, isLinkUndeletable } from './domUtils/hiddenProperties/undeletableLink';\n\nexport { createBr } from './modelApi/creators/createBr';\nexport { createListItem } from './modelApi/creators/createListItem';\nexport { createFormatContainer } from './modelApi/creators/createFormatContainer';\nexport { createParagraph } from './modelApi/creators/createParagraph';\nexport { createSelectionMarker } from './modelApi/creators/createSelectionMarker';\nexport { createTable } from './modelApi/creators/createTable';\nexport { createTableCell } from './modelApi/creators/createTableCell';\nexport { createText } from './modelApi/creators/createText';\nexport { createImage } from './modelApi/creators/createImage';\nexport { createContentModelDocument } from './modelApi/creators/createContentModelDocument';\nexport { createParagraphDecorator } from './modelApi/creators/createParagraphDecorator';\nexport { createGeneralSegment } from './modelApi/creators/createGeneralSegment';\nexport { createGeneralBlock } from './modelApi/creators/createGeneralBlock';\nexport { createEntity } from './modelApi/creators/createEntity';\nexport { createDivider } from './modelApi/creators/createDivider';\nexport { createListLevel } from './modelApi/creators/createListLevel';\nexport { createEmptyModel } from './modelApi/creators/createEmptyModel';\nexport { createTableRow } from './modelApi/creators/createTableRow';\n\nexport { mutateBlock, mutateSegments, mutateSegment } from './modelApi/common/mutate';\nexport { addBlock } from './modelApi/common/addBlock';\nexport { addCode } from './modelApi/common/addDecorators';\nexport { addLink } from './modelApi/common/addDecorators';\nexport { addTextSegment } from './modelApi/common/addTextSegment';\nexport { normalizeParagraph } from './modelApi/common/normalizeParagraph';\n\nexport { normalizeContentModel } from './modelApi/common/normalizeContentModel';\nexport { sanitizeInvisibleUnicode } from './modelApi/common/sanitizeInvisibleUnicode';\nexport { isGeneralSegment } from './modelApi/typeCheck/isGeneralSegment';\nexport { unwrapBlock } from './modelApi/common/unwrapBlock';\nexport { addSegment } from './modelApi/common/addSegment';\nexport { isEmpty } from './modelApi/common/isEmpty';\nexport { normalizeSingleSegment } from './modelApi/common/normalizeSegment';\nexport { mergeTextSegments } from './modelApi/common/mergeTextSegments';\nexport { normalizeSegmentFormat } from './modelApi/common/normalizeSegmentFormat';\n\nexport { setParagraphNotImplicit } from './modelApi/block/setParagraphNotImplicit';\nexport {\n copyFormat,\n ListFormats,\n ListFormatsToKeep,\n ListFormatsToMove,\n ParagraphFormats,\n} from './modelApi/block/copyFormat';\nexport { getOrderedListNumberStr } from './modelApi/list/getOrderedListNumberStr';\nexport { getAutoListStyleType } from './modelApi/list/getAutoListStyleType';\n\nexport { parseValueWithUnit } from './formatHandlers/utils/parseValueWithUnit';\nexport { BorderKeys } from './formatHandlers/utils/borderKeys';\nexport {\n DeprecatedColors,\n getColor,\n setColor,\n parseColor,\n defaultGenerateColorKey,\n} from './formatHandlers/utils/color';\n\nexport {\n createDomToModelContext,\n createDomToModelContextWithConfig,\n createDomToModelConfig,\n} from './domToModel/context/createDomToModelContext';\nexport {\n createModelToDomContext,\n createModelToDomContextWithConfig,\n createModelToDomConfig,\n} from './modelToDom/context/createModelToDomContext';\n\nexport { isBold } from './domUtils/style/isBold';\nexport { getSelectionRootNode } from './domUtils/selection/getSelectionRootNode';\nexport { getDOMInsertPointRect } from './domUtils/selection/getDOMInsertPointRect';\nexport { trimModelForSelection } from './domUtils/selection/trimModelForSelection';\nexport { isCharacterValue, isModifierKey, isCursorMovingKey } from './domUtils/event/eventUtils';\nexport { getNodePositionFromEvent } from './domUtils/event/getNodePositionFromEvent';\nexport { combineBorderValue, extractBorderValues } from './domUtils/style/borderValues';\nexport { isPunctuation, isSpace, normalizeText } from './domUtils/stringUtil';\nexport { stripInvisibleUnicode } from './domUtils/stripInvisibleUnicode';\nexport { parseTableCells } from './domUtils/table/parseTableCells';\nexport { readFile } from './domUtils/readFile';\nexport { retrieveDocumentMetadata } from './domUtils/retrieveDocumentMetadata';\nexport { transformColor, TransformColorOptions } from './domUtils/style/transformColor';\nexport { normalizeFontFamily } from './domUtils/style/normalizeFontFamily';\nexport { extractClipboardItems } from './domUtils/event/extractClipboardItems';\nexport { cacheGetEventData } from './domUtils/event/cacheGetEventData';\nexport {\n setParagraphMarker,\n getParagraphMarker,\n} from './domUtils/hiddenProperties/paragraphMarker';\nexport { setImageState, getImageState } from './domUtils/hiddenProperties/imageState';\nexport { getRangesByText } from './domUtils/getRangesByText';\n\nexport { isBlockGroupOfType } from './modelApi/typeCheck/isBlockGroupOfType';\n\nexport { iterateSelections } from './modelApi/selection/iterateSelections';\nexport {\n getFirstSelectedListItem,\n getFirstSelectedTable,\n getOperationalBlocks,\n getSelectedParagraphs,\n getSelectedSegments,\n getSelectedSegmentsAndParagraphs,\n} from './modelApi/selection/collectSelections';\nexport { getSelectedCells } from './modelApi/selection/getSelectedCells';\nexport { hasSelectionInBlock } from './modelApi/selection/hasSelectionInBlock';\nexport { hasSelectionInSegment } from './modelApi/selection/hasSelectionInSegment';\nexport { hasSelectionInBlockGroup } from './modelApi/selection/hasSelectionInBlockGroup';\nexport { setSelection } from './modelApi/selection/setSelection';\n\nexport { cloneModel } from './modelApi/editing/cloneModel';\nexport { mergeModel } from './modelApi/editing/mergeModel';\nexport { deleteSelection } from './modelApi/editing/deleteSelection';\nexport { deleteSegment } from './modelApi/editing/deleteSegment';\nexport { deleteBlock } from './modelApi/editing/deleteBlock';\nexport { applyTableFormat, setFirstColumnFormatBorders } from './modelApi/editing/applyTableFormat';\nexport {\n normalizeTable,\n MIN_ALLOWED_TABLE_CELL_WIDTH,\n MIN_ALLOWED_TABLE_CELL_HEIGHT,\n} from './modelApi/editing/normalizeTable';\nexport { setTableCellBackgroundColor } from './modelApi/editing/setTableCellBackgroundColor';\nexport { retrieveModelFormatState } from './modelApi/editing/retrieveModelFormatState';\nexport { getListStyleTypeFromString } from './modelApi/editing/getListStyleTypeFromString';\nexport { getSegmentTextFormat } from './modelApi/editing/getSegmentTextFormat';\nexport { getClosestAncestorBlockGroupIndex } from './modelApi/editing/getClosestAncestorBlockGroupIndex';\nexport { runEditSteps } from './modelApi/editing/runEditSteps';\n\nexport { updateImageMetadata, getImageMetadata } from './modelApi/metadata/updateImageMetadata';\nexport {\n updateTableCellMetadata,\n getTableCellMetadata,\n} from './modelApi/metadata/updateTableCellMetadata';\nexport { updateTableMetadata, getTableMetadata } from './modelApi/metadata/updateTableMetadata';\nexport {\n updateListMetadata,\n getListMetadata,\n ListMetadataDefinition,\n} from './modelApi/metadata/updateListMetadata';\n\nexport { ChangeSource } from './constants/ChangeSource';\nexport { BulletListType } from './constants/BulletListType';\nexport { NumberingListType } from './constants/NumberingListType';\nexport { TableBorderFormat } from './constants/TableBorderFormat';\nexport { OrderedListStyleMap } from './constants/OrderedListStyleMap';\nexport { UnorderedListStyleMap } from './constants/UnorderedListStyleMap';\nexport { EmptySegmentFormat } from './constants/EmptySegmentFormat';\n"]}
@@ -18,6 +18,8 @@ exports.ListFormatsToKeep = [
18
18
  'direction',
19
19
  'textAlign',
20
20
  'htmlAlign',
21
+ 'marginBottom',
22
+ 'marginTop',
21
23
  ];
22
24
  /**
23
25
  * When copy format from one block to another, these are all the formats that we can copy
@@ -1 +1 @@
1
- {"version":3,"file":"copyFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/block/copyFormat.ts"],"names":[],"mappings":";;;;AAKA;;GAEG;AACU,QAAA,iBAAiB,GAAsC;IAChE,aAAa;IACb,YAAY;IACZ,cAAc;IACd,aAAa;CAChB,CAAC;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAsC;IAChE,WAAW;IACX,WAAW;IACX,WAAW;CACd,CAAC;AAEF;;GAEG;AACU,QAAA,WAAW,GAAsC,yBAAiB,CAAC,MAAM,CAClF,yBAAiB,CACpB,CAAC;AAEF;;GAEG;AACU,QAAA,gBAAgB,GAAsC;IAC/D,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,UAAU,CACtB,YAAe,EACf,YAAe,EACf,UAAuB,EACvB,oBAA8B;;;QAE9B,KAAkB,IAAA,eAAA,sBAAA,UAAU,CAAA,sCAAA,8DAAE;YAAzB,IAAM,GAAG,uBAAA;YACV,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;gBACjC,MAAM,CAAC,MAAM,CAAC,YAAY;oBACtB,GAAC,GAAG,IAAG,YAAY,CAAC,GAAG,CAAC;wBAC1B,CAAC;gBAEH,IAAI,oBAAoB,EAAE;oBACtB,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;iBAC5B;aACJ;SACJ;;;;;;;;;AACL,CAAC;AAjBD,gCAiBC","sourcesContent":["import type {\n ContentModelBlockFormat,\n ContentModelFormatBase,\n} from 'roosterjs-content-model-types';\n\n/**\n * When copy format between list and paragraph, these are the formats that we can copy and remove from the source\n */\nexport const ListFormatsToMove: (keyof ContentModelBlockFormat)[] = [\n 'marginRight',\n 'marginLeft',\n 'paddingRight',\n 'paddingLeft',\n];\n\n/**\n * When copy format between list and paragraph, these are the formats that we can copy and keep in the source\n */\nexport const ListFormatsToKeep: (keyof ContentModelBlockFormat)[] = [\n 'direction',\n 'textAlign',\n 'htmlAlign',\n];\n\n/**\n * When copy format from one block to another, these are all the formats that we can copy\n */\nexport const ListFormats: (keyof ContentModelBlockFormat)[] = ListFormatsToMove.concat(\n ListFormatsToKeep\n);\n\n/**\n * When copy format between paragraphs, these are the formats that we can copy\n */\nexport const ParagraphFormats: (keyof ContentModelBlockFormat)[] = [\n 'backgroundColor',\n 'direction',\n 'textAlign',\n 'htmlAlign',\n 'lineHeight',\n 'textIndent',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n];\n\n/**\n * Copy formats from source to target with only specified keys\n * @param targetFormat The format object to copy format to\n * @param sourceFormat The format object to copy format from\n * @param formatKeys The format keys to copy\n * @param deleteOriginalFormat True to delete the original format from sourceFormat, false to keep it. @default false\n */\nexport function copyFormat<T extends ContentModelFormatBase>(\n targetFormat: T,\n sourceFormat: T,\n formatKeys: (keyof T)[],\n deleteOriginalFormat?: boolean\n) {\n for (const key of formatKeys) {\n if (sourceFormat[key] !== undefined) {\n Object.assign(targetFormat, {\n [key]: sourceFormat[key],\n });\n\n if (deleteOriginalFormat) {\n delete sourceFormat[key];\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"copyFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/block/copyFormat.ts"],"names":[],"mappings":";;;;AAKA;;GAEG;AACU,QAAA,iBAAiB,GAAsC;IAChE,aAAa;IACb,YAAY;IACZ,cAAc;IACd,aAAa;CAChB,CAAC;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAsC;IAChE,WAAW;IACX,WAAW;IACX,WAAW;IACX,cAAc;IACd,WAAW;CACd,CAAC;AAEF;;GAEG;AACU,QAAA,WAAW,GAAsC,yBAAiB,CAAC,MAAM,CAClF,yBAAiB,CACpB,CAAC;AAEF;;GAEG;AACU,QAAA,gBAAgB,GAAsC;IAC/D,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,UAAU,CACtB,YAAe,EACf,YAAe,EACf,UAAuB,EACvB,oBAA8B;;;QAE9B,KAAkB,IAAA,eAAA,sBAAA,UAAU,CAAA,sCAAA,8DAAE;YAAzB,IAAM,GAAG,uBAAA;YACV,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;gBACjC,MAAM,CAAC,MAAM,CAAC,YAAY;oBACtB,GAAC,GAAG,IAAG,YAAY,CAAC,GAAG,CAAC;wBAC1B,CAAC;gBAEH,IAAI,oBAAoB,EAAE;oBACtB,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;iBAC5B;aACJ;SACJ;;;;;;;;;AACL,CAAC;AAjBD,gCAiBC","sourcesContent":["import type {\n ContentModelBlockFormat,\n ContentModelFormatBase,\n} from 'roosterjs-content-model-types';\n\n/**\n * When copy format between list and paragraph, these are the formats that we can copy and remove from the source\n */\nexport const ListFormatsToMove: (keyof ContentModelBlockFormat)[] = [\n 'marginRight',\n 'marginLeft',\n 'paddingRight',\n 'paddingLeft',\n];\n\n/**\n * When copy format between list and paragraph, these are the formats that we can copy and keep in the source\n */\nexport const ListFormatsToKeep: (keyof ContentModelBlockFormat)[] = [\n 'direction',\n 'textAlign',\n 'htmlAlign',\n 'marginBottom',\n 'marginTop',\n];\n\n/**\n * When copy format from one block to another, these are all the formats that we can copy\n */\nexport const ListFormats: (keyof ContentModelBlockFormat)[] = ListFormatsToMove.concat(\n ListFormatsToKeep\n);\n\n/**\n * When copy format between paragraphs, these are the formats that we can copy\n */\nexport const ParagraphFormats: (keyof ContentModelBlockFormat)[] = [\n 'backgroundColor',\n 'direction',\n 'textAlign',\n 'htmlAlign',\n 'lineHeight',\n 'textIndent',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n];\n\n/**\n * Copy formats from source to target with only specified keys\n * @param targetFormat The format object to copy format to\n * @param sourceFormat The format object to copy format from\n * @param formatKeys The format keys to copy\n * @param deleteOriginalFormat True to delete the original format from sourceFormat, false to keep it. @default false\n */\nexport function copyFormat<T extends ContentModelFormatBase>(\n targetFormat: T,\n sourceFormat: T,\n formatKeys: (keyof T)[],\n deleteOriginalFormat?: boolean\n) {\n for (const key of formatKeys) {\n if (sourceFormat[key] !== undefined) {\n Object.assign(targetFormat, {\n [key]: sourceFormat[key],\n });\n\n if (deleteOriginalFormat) {\n delete sourceFormat[key];\n }\n }\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { ContentModelDocument } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Strip invisible Unicode characters from all text and link hrefs in a content model.
4
+ * This sanitizes the model at initialization time to prevent hidden content in links
5
+ * or text (e.g. zero-width chars, bidirectional marks, Unicode Tags).
6
+ * For General segments, all Text nodes under the element are also sanitized.
7
+ * @param model The content model document to sanitize in-place
8
+ */
9
+ export declare function sanitizeInvisibleUnicode(model: ContentModelDocument): void;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sanitizeInvisibleUnicode = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var stripInvisibleUnicode_1 = require("../../domUtils/stripInvisibleUnicode");
6
+ /**
7
+ * Strip invisible Unicode characters from all text and link hrefs in a content model.
8
+ * This sanitizes the model at initialization time to prevent hidden content in links
9
+ * or text (e.g. zero-width chars, bidirectional marks, Unicode Tags).
10
+ * For General segments, all Text nodes under the element are also sanitized.
11
+ * @param model The content model document to sanitize in-place
12
+ */
13
+ function sanitizeInvisibleUnicode(model) {
14
+ sanitizeBlockGroup(model);
15
+ }
16
+ exports.sanitizeInvisibleUnicode = sanitizeInvisibleUnicode;
17
+ function sanitizeBlockGroup(group) {
18
+ var e_1, _a;
19
+ try {
20
+ for (var _b = (0, tslib_1.__values)(group.blocks), _c = _b.next(); !_c.done; _c = _b.next()) {
21
+ var block = _c.value;
22
+ sanitizeBlock(block);
23
+ }
24
+ }
25
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
26
+ finally {
27
+ try {
28
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
29
+ }
30
+ finally { if (e_1) throw e_1.error; }
31
+ }
32
+ }
33
+ function sanitizeBlock(block) {
34
+ var e_2, _a, e_3, _b, e_4, _c;
35
+ switch (block.blockType) {
36
+ case 'Paragraph':
37
+ try {
38
+ for (var _d = (0, tslib_1.__values)(block.segments), _e = _d.next(); !_e.done; _e = _d.next()) {
39
+ var segment = _e.value;
40
+ sanitizeSegment(segment);
41
+ }
42
+ }
43
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
44
+ finally {
45
+ try {
46
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
47
+ }
48
+ finally { if (e_2) throw e_2.error; }
49
+ }
50
+ break;
51
+ case 'Table':
52
+ try {
53
+ for (var _f = (0, tslib_1.__values)(block.rows), _g = _f.next(); !_g.done; _g = _f.next()) {
54
+ var row = _g.value;
55
+ try {
56
+ for (var _h = (e_4 = void 0, (0, tslib_1.__values)(row.cells)), _j = _h.next(); !_j.done; _j = _h.next()) {
57
+ var cell = _j.value;
58
+ sanitizeBlockGroup(cell);
59
+ }
60
+ }
61
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
62
+ finally {
63
+ try {
64
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
65
+ }
66
+ finally { if (e_4) throw e_4.error; }
67
+ }
68
+ }
69
+ }
70
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
71
+ finally {
72
+ try {
73
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
74
+ }
75
+ finally { if (e_3) throw e_3.error; }
76
+ }
77
+ break;
78
+ case 'BlockGroup':
79
+ sanitizeBlockGroup(block);
80
+ if (block.blockGroupType === 'General' && block.element) {
81
+ sanitizeTextNodes(block.element);
82
+ }
83
+ break;
84
+ case 'Entity':
85
+ case 'Divider':
86
+ break;
87
+ }
88
+ }
89
+ function sanitizeSegment(segment) {
90
+ var _a;
91
+ if ((_a = segment.link) === null || _a === void 0 ? void 0 : _a.format.href) {
92
+ segment.link.format.href = (0, stripInvisibleUnicode_1.stripInvisibleUnicode)(segment.link.format.href);
93
+ }
94
+ switch (segment.segmentType) {
95
+ case 'Text':
96
+ segment.text = (0, stripInvisibleUnicode_1.stripInvisibleUnicode)(segment.text);
97
+ break;
98
+ case 'General':
99
+ sanitizeTextNodes(segment.element);
100
+ sanitizeBlockGroup(segment);
101
+ break;
102
+ case 'Image':
103
+ case 'Entity':
104
+ case 'Br':
105
+ case 'SelectionMarker':
106
+ break;
107
+ }
108
+ }
109
+ function sanitizeTextNodes(element) {
110
+ var walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_TEXT);
111
+ var node;
112
+ while ((node = walker.nextNode())) {
113
+ if (node.nodeValue) {
114
+ node.nodeValue = (0, stripInvisibleUnicode_1.stripInvisibleUnicode)(node.nodeValue);
115
+ }
116
+ }
117
+ }
118
+ //# sourceMappingURL=sanitizeInvisibleUnicode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizeInvisibleUnicode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/common/sanitizeInvisibleUnicode.ts"],"names":[],"mappings":";;;;AAAA,8EAA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AI,EAAE;QAC3B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAA,6CAAqB,EAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KAC9E;IAED,QAAQ,OAAO,CAAC,WAAW,EAAE;QACzB,KAAK,MAAM;YACP,OAAO,CAAC,IAAI,GAAG,IAAA,6CAAqB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACnD,MAAM;QAEV,KAAK,SAAS;YACV,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAC5B,MAAM;QAEV,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI,CAAC;QACV,KAAK,iBAAiB;YAClB,MAAM;KACb;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAoB;IAC3C,IAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAErF,IAAI,IAAiB,CAAC;IAEtB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAiB,CAAC,EAAE;QAC9C,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,IAAI,CAAC,SAAS,GAAG,IAAA,6CAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC1D;KACJ;AACL,CAAC","sourcesContent":["import { stripInvisibleUnicode } from '../../domUtils/stripInvisibleUnicode';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * Strip invisible Unicode characters from all text and link hrefs in a content model.\n * This sanitizes the model at initialization time to prevent hidden content in links\n * or text (e.g. zero-width chars, bidirectional marks, Unicode Tags).\n * For General segments, all Text nodes under the element are also sanitized.\n * @param model The content model document to sanitize in-place\n */\nexport function sanitizeInvisibleUnicode(model: ContentModelDocument): void {\n sanitizeBlockGroup(model);\n}\n\nfunction sanitizeBlockGroup(group: ContentModelBlockGroup): void {\n for (const block of group.blocks) {\n sanitizeBlock(block);\n }\n}\n\nfunction sanitizeBlock(block: ContentModelBlock): void {\n switch (block.blockType) {\n case 'Paragraph':\n for (const segment of block.segments) {\n sanitizeSegment(segment);\n }\n break;\n\n case 'Table':\n for (const row of block.rows) {\n for (const cell of row.cells) {\n sanitizeBlockGroup(cell);\n }\n }\n break;\n\n case 'BlockGroup':\n sanitizeBlockGroup(block);\n\n if (block.blockGroupType === 'General' && block.element) {\n sanitizeTextNodes(block.element);\n }\n break;\n\n case 'Entity':\n case 'Divider':\n break;\n }\n}\n\nfunction sanitizeSegment(segment: ContentModelSegment): void {\n if (segment.link?.format.href) {\n segment.link.format.href = stripInvisibleUnicode(segment.link.format.href);\n }\n\n switch (segment.segmentType) {\n case 'Text':\n segment.text = stripInvisibleUnicode(segment.text);\n break;\n\n case 'General':\n sanitizeTextNodes(segment.element);\n sanitizeBlockGroup(segment);\n break;\n\n case 'Image':\n case 'Entity':\n case 'Br':\n case 'SelectionMarker':\n break;\n }\n}\n\nfunction sanitizeTextNodes(element: HTMLElement): void {\n const walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_TEXT);\n\n let node: Text | null;\n\n while ((node = walker.nextNode() as Text | null)) {\n if (node.nodeValue) {\n node.nodeValue = stripInvisibleUnicode(node.nodeValue);\n }\n }\n}\n"]}
@@ -59,6 +59,13 @@ export declare function getSelectedParagraphs(model: ContentModelDocument): Cont
59
59
  * @param mutate Set to true to indicate we will mutate the selected paragraphs
60
60
  */
61
61
  export declare function getSelectedParagraphs(model: ReadonlyContentModelDocument, mutate: true): ShallowMutableContentModelParagraph[];
62
+ /**
63
+ * Get any array of selected paragraphs from a content model, return mutable paragraphs
64
+ * @param model The Content Model to get selection from
65
+ * @param mutate Set to true to indicate we will mutate the selected paragraphs
66
+ * @param removeUnmeaningful True to remove unmeaningful selection like only selection marker is selected, or head/tail paragraph is selected with selection marker at the wrong place
67
+ */
68
+ export declare function getSelectedParagraphs(model: ReadonlyContentModelDocument, mutate: true, removeUnmeaningful: boolean): ShallowMutableContentModelParagraph[];
62
69
  /**
63
70
  * Get any array of selected paragraphs from a content model (Readonly)
64
71
  * @param model The Content Model to get selection from
@@ -53,10 +53,13 @@ function getSelectedSegments(model, includingFormatHolder, mutate) {
53
53
  return segments.map(function (x) { return x[0]; });
54
54
  }
55
55
  exports.getSelectedSegments = getSelectedSegments;
56
- function getSelectedParagraphs(model, mutate) {
56
+ function getSelectedParagraphs(model, mutate, removeUnmeaningful) {
57
+ if (removeUnmeaningful === void 0) { removeUnmeaningful = true; }
57
58
  var selections = collectSelections(model, { includeListFormatHolder: 'never' });
58
59
  var result = [];
59
- removeUnmeaningfulSelections(selections);
60
+ if (removeUnmeaningful) {
61
+ removeUnmeaningfulSelections(selections);
62
+ }
60
63
  selections.forEach(function (_a) {
61
64
  var block = _a.block;
62
65
  if ((block === null || block === void 0 ? void 0 : block.blockType) == 'Paragraph') {
@@ -1 +1 @@
1
- {"version":3,"file":"collectSelections.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/selection/collectSelections.ts"],"names":[],"mappings":";;;;AAAA,kGAAiG;AACjG,sEAAqE;AACrE,yDAAwD;AACxD,2CAA+C;AA0E/C,SAAgB,gCAAgC,CAC5C,KAAmC,EACnC,qBAA8B,EAC9B,eAAyB,EACzB,MAAgB;IAMhB,IAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,EAAE;QACxC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;KAC3E,CAAC,CAAC;IACH,IAAM,MAAM,GAIN,EAAE,CAAC;IAET,UAAU,CAAC,OAAO,CAAC,UAAC,EAAyB;YAAvB,QAAQ,cAAA,EAAE,KAAK,WAAA,EAAE,IAAI,UAAA;QACvC,IAAI,QAAQ,EAAE;YACV,I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AC,QAAQ;QAClB,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAC/B;QACE,IAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7C,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CACH,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;YAC9B,OAAO,CAAC,WAAW,IAAI,iBAAiB;YACxC,OAAO,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AACD,YAAY","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from '../editing/getClosestAncestorBlockGroupIndex';\nimport { isBlockGroupOfType } from '../typeCheck/isBlockGroupOfType';\nimport { iterateSelections } from './iterateSelections';\nimport { mutateBlock } from '../common/mutate';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelBlockGroupType,\n ContentModelDocument,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelTable,\n IterateSelectionsOption,\n OperationalBlocks,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ReadonlyContentModelParagraph,\n ReadonlyContentModelSegment,\n ReadonlyContentModelTable,\n ReadonlyOperationalBlocks,\n ReadonlyTableSelectionContext,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\n TableSelectionContext,\n TypeOfBlockGroup,\n} from 'roosterjs-content-model-types';\n\n//#region getSelectedSegmentsAndParagraphs\n/**\n * Get an array of selected parent paragraph and child segment pair\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n * @param includingEntity True to include entity in result as well\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity?: boolean\n): [ContentModelSegment, ContentModelParagraph | null, ContentModelBlockGroup[]][];\n\n/**\n * Get an array of selected parent paragraph and child segment pair, return mutable paragraph and segments\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n * @param includingEntity True to include entity in result as well\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity: boolean,\n mutate: true\n): [\n ShallowMutableContentModelSegment,\n ContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n][];\n\n/**\n * Get an array of selected parent paragraph and child segment pair (Readonly)\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n * @param includingEntity True to include entity in result as well\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity?: boolean\n): [\n ReadonlyContentModelSegment,\n ReadonlyContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n][];\n\nexport function getSelectedSegmentsAndParagraphs(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity?: boolean,\n mutate?: boolean\n): [\n ReadonlyContentModelSegment,\n ReadonlyContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n][] {\n const selections = collectSelections(model, {\n includeListFormatHolder: includingFormatHolder ? 'allSegments' : 'never',\n });\n const result: [\n ReadonlyContentModelSegment,\n ReadonlyContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n ][] = [];\n\n selections.forEach(({ segments, block, path }) => {\n if (segments) {\n if (\n includingFormatHolder &&\n !block &&\n segments.length == 1 &&\n path[0].blockGroupType == 'ListItem' &&\n segments[0] == path[0].formatHolder\n ) {\n const list = path[0];\n\n if (mutate) {\n mutateBlock(list);\n }\n\n result.push([list.formatHolder, null, path]);\n } else if (block?.blockType == 'Paragraph') {\n if (mutate) {\n mutateBlock(block);\n }\n\n segments.forEach(segment => {\n if (\n includingEntity ||\n segment.segmentType != 'Entity' ||\n !segment.entityFormat.isReadonly\n ) {\n result.push([segment, block, path]);\n }\n });\n }\n } else if (block?.blockType == 'Entity' && includingEntity) {\n // Here we treat the entity as segment since they are compatible, then it has no parent paragraph\n result.push([block, null /*paragraph*/, path]);\n }\n });\n\n return result;\n}\n//#endregion\n\n//#region getSelectedSegments\n/**\n * Get an array of selected segments from a content model\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n */\nexport function getSelectedSegments(\n model: ContentModelDocument,\n includingFormatHolder: boolean\n): ContentModelSegment[];\n\n/**\n * Get an array of selected segments from a content model, return mutable segments\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n */\nexport function getSelectedSegments(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n mutate: true\n): ShallowMutableContentModelSegment[];\n\n/**\n * Get an array of selected segments from a content model (Readonly)\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n */\nexport function getSelectedSegments(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean\n): ReadonlyContentModelSegment[];\n\nexport function getSelectedSegments(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n mutate?: boolean\n): ReadonlyContentModelSegment[] {\n const segments = mutate\n ? getSelectedSegmentsAndParagraphs(\n model,\n includingFormatHolder,\n false /*includeEntity*/,\n true /*mutate*/\n )\n : getSelectedSegmentsAndParagraphs(model, includingFormatHolder);\n\n return segments.map(x => x[0]);\n}\n//#endregion\n\n//#region getSelectedParagraphs\n/**\n * Get any array of selected paragraphs from a content model\n * @param model The Content Model to get selection from\n */\nexport function getSelectedParagraphs(model: ContentModelDocument): ContentModelParagraph[];\n\n/**\n * Get any array of selected paragraphs from a content model, return mutable paragraphs\n * @param model The Content Model to get selection from\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n */\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument,\n mutate: true\n): ShallowMutableContentModelParagraph[];\n\n/**\n * Get any array of selected paragraphs from a content model (Readonly)\n * @param model The Content Model to get selection from\n */\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument\n): ReadonlyContentModelParagraph[];\n\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument,\n mutate?: boolean\n): ReadonlyContentModelParagraph[] {\n const selections = collectSelections(model, { includeListFormatHolder: 'never' });\n const result: ReadonlyContentModelParagraph[] = [];\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ block }) => {\n if (block?.blockType == 'Paragraph') {\n result.push(mutate ? mutateBlock(block) : block);\n }\n });\n\n return result;\n}\n//#endregion\n\n//#region getOperationalBlocks\n/**\n * Get an array of block group - block pair that is of the expected block group type from selection\n * @param group The root block group to search\n * @param blockGroupTypes The expected block group types\n * @param stopTypes Block group types that will stop searching when hit\n * @param deepFirst True means search in deep first, otherwise wide first\n * @param isValidTarget @optional An additional callback to validate whether a matching block group is a valid target\n */\nexport function getOperationalBlocks<T extends ContentModelBlockGroup>(\n group: ContentModelBlockGroup,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean,\n isValidTarget?: (block: ReadonlyContentModelBlockGroup) => boolean\n): OperationalBlocks<T>[];\n\n/**\n * Get an array of block group - block pair that is of the expected block group type from selection (Readonly)\n * @param group The root block group to search\n * @param blockGroupTypes The expected block group types\n * @param stopTypes Block group types that will stop searching when hit\n * @param deepFirst True means search in deep first, otherwise wide first\n * @param isValidTarget @optional An additional callback to validate whether a matching block group is a valid target\n */\nexport function getOperationalBlocks<T extends ReadonlyContentModelBlockGroup>(\n group: ReadonlyContentModelBlockGroup,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean,\n isValidTarget?: (block: ReadonlyContentModelBlockGroup) => boolean\n): ReadonlyOperationalBlocks<T>[];\n\nexport function getOperationalBlocks<T extends ContentModelBlockGroup>(\n group: ReadonlyContentModelBlockGroup,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean,\n isValidTarget?: (block: ReadonlyContentModelBlockGroup) => boolean\n): ReadonlyOperationalBlocks<T>[] {\n const result: ReadonlyOperationalBlocks<T>[] = [];\n const findSequence = deepFirst ? blockGroupTypes.map(type => [type]) : [blockGroupTypes];\n const selections = collectSelections(group, {\n includeListFormatHolder: 'never',\n contentUnderSelectedTableCell: 'ignoreForTable', // When whole table is selected, we treat the table as a single block\n });\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ path, block }) => {\n for (let i = 0; i < findSequence.length; i++) {\n const groupIndex = getClosestAncestorBlockGroupIndex(\n path,\n findSequence[i],\n stopTypes,\n isValidTarget\n );\n\n if (groupIndex >= 0) {\n if (result.filter(x => x.block == path[groupIndex]).length <= 0) {\n result.push({\n parent: path[groupIndex + 1],\n block: path[groupIndex] as T,\n path: path.slice(groupIndex + 1),\n });\n }\n break;\n } else if (i == findSequence.length - 1 && block) {\n result.push({\n parent: path[0],\n block: block,\n path,\n });\n break;\n }\n }\n });\n\n return result;\n}\n//#endregion\n\n//#region getFirstSelectedTable\n/**\n * Get the first selected table from content model\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedTable(\n model: ContentModelDocument\n): [ContentModelTable | undefined, ContentModelBlockGroup[]];\n\n/**\n * Get the first selected table from content model (Readonly)\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedTable(\n model: ReadonlyContentModelDocument\n): [ReadonlyContentModelTable | undefined, ReadonlyContentModelBlockGroup[]];\n\nexport function getFirstSelectedTable(\n model: ReadonlyContentModelDocument\n): [ReadonlyContentModelTable | undefined, ReadonlyContentModelBlockGroup[]] {\n const selections = collectSelections(model, { includeListFormatHolder: 'never' });\n let table: ReadonlyContentModelTable | undefined;\n let resultPath: ReadonlyContentModelBlockGroup[] = [];\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ block, tableContext, path }) => {\n if (!table) {\n if (block?.blockType == 'Table') {\n table = block;\n resultPath = [...path];\n } else if (tableContext?.table) {\n table = tableContext.table;\n\n const parent = path.filter(\n group => group.blocks.indexOf(tableContext.table) >= 0\n )[0];\n const index = path.indexOf(parent);\n resultPath = index >= 0 ? path.slice(index) : [];\n }\n }\n });\n\n return [table, resultPath];\n}\n//#endregion\n\n//#region getFirstSelectedListItem\n/**\n * Get the first selected list item from content model\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedListItem(\n model: ContentModelDocument\n): ContentModelListItem | undefined;\n\n/**\n * Get the first selected list item from content model (Readonly)\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedListItem(\n model: ReadonlyContentModelDocument\n): ReadonlyContentModelListItem | undefined;\n\nexport function getFirstSelectedListItem(\n model: ReadonlyContentModelDocument\n): ReadonlyContentModelListItem | undefined {\n let listItem: ContentModelListItem | undefined;\n\n getOperationalBlocks(model, ['ListItem'], ['TableCell']).forEach(r => {\n if (!listItem && isBlockGroupOfType<ContentModelListItem>(r.block, 'ListItem')) {\n listItem = r.block;\n }\n });\n\n return listItem;\n}\n//#endregion\n\n//#region collectSelections\ninterface SelectionInfo {\n path: ContentModelBlockGroup[];\n segments?: ContentModelSegment[];\n block?: ContentModelBlock;\n tableContext?: TableSelectionContext;\n}\n\ninterface ReadonlySelectionInfo {\n path: ReadonlyContentModelBlockGroup[];\n segments?: ReadonlyContentModelSegment[];\n block?: ReadonlyContentModelBlock;\n tableContext?: ReadonlyTableSelectionContext;\n}\n\nfunction collectSelections(\n group: ContentModelBlockGroup,\n option?: IterateSelectionsOption\n): SelectionInfo[];\n\nfunction collectSelections(\n group: ReadonlyContentModelBlockGroup,\n option?: IterateSelectionsOption\n): ReadonlySelectionInfo[];\n\nfunction collectSelections(\n group: ReadonlyContentModelBlockGroup,\n option?: IterateSelectionsOption\n): ReadonlySelectionInfo[] {\n const selections: ReadonlySelectionInfo[] = [];\n\n iterateSelections(\n group,\n (path, tableContext, block, segments) => {\n selections.push({\n path,\n tableContext,\n block,\n segments,\n });\n },\n option\n );\n\n return selections;\n}\n//#endregion\n\n//#region utils\nfunction removeUnmeaningfulSelections(selections: ReadonlySelectionInfo[]) {\n if (\n selections.length > 1 &&\n isOnlySelectionMarkerSelected(selections, false /*checkFirstParagraph*/)\n ) {\n selections.pop();\n }\n\n // Remove head paragraph if first selection marker is the only selection\n if (\n selections.length > 1 &&\n isOnlySelectionMarkerSelected(selections, true /*checkFirstParagraph*/)\n ) {\n selections.shift();\n }\n}\n\nfunction isOnlySelectionMarkerSelected(\n selections: ReadonlySelectionInfo[],\n checkFirstParagraph: boolean\n): boolean {\n const selection = selections[checkFirstParagraph ? 0 : selections.length - 1];\n\n if (\n selection.block?.blockType == 'Paragraph' &&\n selection.segments &&\n selection.segments.length > 0\n ) {\n const allSegments = selection.block.segments;\n const segment = selection.segments[0];\n\n return (\n selection.segments.length == 1 &&\n segment.segmentType == 'SelectionMarker' &&\n segment == allSegments[checkFirstParagraph ? allSegments.length - 1 : 0]\n );\n } else {\n return false;\n }\n}\n//#endregion\n"]}
1
+ {"version":3,"file":"collectSelections.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/selection/collectSelections.ts"],"names":[],"mappings":";;;;AAAA,kGAAiG;AACjG,sEAAqE;AACrE,yDAAwD;AACxD,2CAA+C;AA0E/C,SAAgB,gCAAgC,CAC5C,KAAmC,EACnC,qBAA8B,EAC9B,eAAyB,EACzB,MAAgB;IAMhB,IAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,EAAE;QACxC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;KAC3E,CAAC,CAAC;IACH,IAAM,MAAM,G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BAA4B;;IAE5B,IAAM,SAAS,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE9E,IACI,CAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,SAAS,KAAI,WAAW;QACzC,SAAS,CAAC,QAAQ;QAClB,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAC/B;QACE,IAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7C,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CACH,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;YAC9B,OAAO,CAAC,WAAW,IAAI,iBAAiB;YACxC,OAAO,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AACD,YAAY","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from '../editing/getClosestAncestorBlockGroupIndex';\nimport { isBlockGroupOfType } from '../typeCheck/isBlockGroupOfType';\nimport { iterateSelections } from './iterateSelections';\nimport { mutateBlock } from '../common/mutate';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelBlockGroupType,\n ContentModelDocument,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelTable,\n IterateSelectionsOption,\n OperationalBlocks,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelListItem,\n ReadonlyContentModelParagraph,\n ReadonlyContentModelSegment,\n ReadonlyContentModelTable,\n ReadonlyOperationalBlocks,\n ReadonlyTableSelectionContext,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\n TableSelectionContext,\n TypeOfBlockGroup,\n} from 'roosterjs-content-model-types';\n\n//#region getSelectedSegmentsAndParagraphs\n/**\n * Get an array of selected parent paragraph and child segment pair\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n * @param includingEntity True to include entity in result as well\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity?: boolean\n): [ContentModelSegment, ContentModelParagraph | null, ContentModelBlockGroup[]][];\n\n/**\n * Get an array of selected parent paragraph and child segment pair, return mutable paragraph and segments\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n * @param includingEntity True to include entity in result as well\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity: boolean,\n mutate: true\n): [\n ShallowMutableContentModelSegment,\n ContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n][];\n\n/**\n * Get an array of selected parent paragraph and child segment pair (Readonly)\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n * @param includingEntity True to include entity in result as well\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity?: boolean\n): [\n ReadonlyContentModelSegment,\n ReadonlyContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n][];\n\nexport function getSelectedSegmentsAndParagraphs(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n includingEntity?: boolean,\n mutate?: boolean\n): [\n ReadonlyContentModelSegment,\n ReadonlyContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n][] {\n const selections = collectSelections(model, {\n includeListFormatHolder: includingFormatHolder ? 'allSegments' : 'never',\n });\n const result: [\n ReadonlyContentModelSegment,\n ReadonlyContentModelParagraph | null,\n ReadonlyContentModelBlockGroup[]\n ][] = [];\n\n selections.forEach(({ segments, block, path }) => {\n if (segments) {\n if (\n includingFormatHolder &&\n !block &&\n segments.length == 1 &&\n path[0].blockGroupType == 'ListItem' &&\n segments[0] == path[0].formatHolder\n ) {\n const list = path[0];\n\n if (mutate) {\n mutateBlock(list);\n }\n\n result.push([list.formatHolder, null, path]);\n } else if (block?.blockType == 'Paragraph') {\n if (mutate) {\n mutateBlock(block);\n }\n\n segments.forEach(segment => {\n if (\n includingEntity ||\n segment.segmentType != 'Entity' ||\n !segment.entityFormat.isReadonly\n ) {\n result.push([segment, block, path]);\n }\n });\n }\n } else if (block?.blockType == 'Entity' && includingEntity) {\n // Here we treat the entity as segment since they are compatible, then it has no parent paragraph\n result.push([block, null /*paragraph*/, path]);\n }\n });\n\n return result;\n}\n//#endregion\n\n//#region getSelectedSegments\n/**\n * Get an array of selected segments from a content model\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n */\nexport function getSelectedSegments(\n model: ContentModelDocument,\n includingFormatHolder: boolean\n): ContentModelSegment[];\n\n/**\n * Get an array of selected segments from a content model, return mutable segments\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n */\nexport function getSelectedSegments(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n mutate: true\n): ShallowMutableContentModelSegment[];\n\n/**\n * Get an array of selected segments from a content model (Readonly)\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n */\nexport function getSelectedSegments(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean\n): ReadonlyContentModelSegment[];\n\nexport function getSelectedSegments(\n model: ReadonlyContentModelDocument,\n includingFormatHolder: boolean,\n mutate?: boolean\n): ReadonlyContentModelSegment[] {\n const segments = mutate\n ? getSelectedSegmentsAndParagraphs(\n model,\n includingFormatHolder,\n false /*includeEntity*/,\n true /*mutate*/\n )\n : getSelectedSegmentsAndParagraphs(model, includingFormatHolder);\n\n return segments.map(x => x[0]);\n}\n//#endregion\n\n//#region getSelectedParagraphs\n/**\n * Get any array of selected paragraphs from a content model\n * @param model The Content Model to get selection from\n */\nexport function getSelectedParagraphs(model: ContentModelDocument): ContentModelParagraph[];\n\n/**\n * Get any array of selected paragraphs from a content model, return mutable paragraphs\n * @param model The Content Model to get selection from\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n */\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument,\n mutate: true\n): ShallowMutableContentModelParagraph[];\n\n/**\n * Get any array of selected paragraphs from a content model, return mutable paragraphs\n * @param model The Content Model to get selection from\n * @param mutate Set to true to indicate we will mutate the selected paragraphs\n * @param removeUnmeaningful True to remove unmeaningful selection like only selection marker is selected, or head/tail paragraph is selected with selection marker at the wrong place\n */\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument,\n mutate: true,\n removeUnmeaningful: boolean\n): ShallowMutableContentModelParagraph[];\n\n/**\n * Get any array of selected paragraphs from a content model (Readonly)\n * @param model The Content Model to get selection from\n */\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument\n): ReadonlyContentModelParagraph[];\n\nexport function getSelectedParagraphs(\n model: ReadonlyContentModelDocument,\n mutate?: boolean,\n removeUnmeaningful: boolean = true\n): ReadonlyContentModelParagraph[] {\n const selections = collectSelections(model, { includeListFormatHolder: 'never' });\n const result: ReadonlyContentModelParagraph[] = [];\n\n if (removeUnmeaningful) {\n removeUnmeaningfulSelections(selections);\n }\n\n selections.forEach(({ block }) => {\n if (block?.blockType == 'Paragraph') {\n result.push(mutate ? mutateBlock(block) : block);\n }\n });\n\n return result;\n}\n//#endregion\n\n//#region getOperationalBlocks\n/**\n * Get an array of block group - block pair that is of the expected block group type from selection\n * @param group The root block group to search\n * @param blockGroupTypes The expected block group types\n * @param stopTypes Block group types that will stop searching when hit\n * @param deepFirst True means search in deep first, otherwise wide first\n * @param isValidTarget @optional An additional callback to validate whether a matching block group is a valid target\n */\nexport function getOperationalBlocks<T extends ContentModelBlockGroup>(\n group: ContentModelBlockGroup,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean,\n isValidTarget?: (block: ReadonlyContentModelBlockGroup) => boolean\n): OperationalBlocks<T>[];\n\n/**\n * Get an array of block group - block pair that is of the expected block group type from selection (Readonly)\n * @param group The root block group to search\n * @param blockGroupTypes The expected block group types\n * @param stopTypes Block group types that will stop searching when hit\n * @param deepFirst True means search in deep first, otherwise wide first\n * @param isValidTarget @optional An additional callback to validate whether a matching block group is a valid target\n */\nexport function getOperationalBlocks<T extends ReadonlyContentModelBlockGroup>(\n group: ReadonlyContentModelBlockGroup,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean,\n isValidTarget?: (block: ReadonlyContentModelBlockGroup) => boolean\n): ReadonlyOperationalBlocks<T>[];\n\nexport function getOperationalBlocks<T extends ContentModelBlockGroup>(\n group: ReadonlyContentModelBlockGroup,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean,\n isValidTarget?: (block: ReadonlyContentModelBlockGroup) => boolean\n): ReadonlyOperationalBlocks<T>[] {\n const result: ReadonlyOperationalBlocks<T>[] = [];\n const findSequence = deepFirst ? blockGroupTypes.map(type => [type]) : [blockGroupTypes];\n const selections = collectSelections(group, {\n includeListFormatHolder: 'never',\n contentUnderSelectedTableCell: 'ignoreForTable', // When whole table is selected, we treat the table as a single block\n });\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ path, block }) => {\n for (let i = 0; i < findSequence.length; i++) {\n const groupIndex = getClosestAncestorBlockGroupIndex(\n path,\n findSequence[i],\n stopTypes,\n isValidTarget\n );\n\n if (groupIndex >= 0) {\n if (result.filter(x => x.block == path[groupIndex]).length <= 0) {\n result.push({\n parent: path[groupIndex + 1],\n block: path[groupIndex] as T,\n path: path.slice(groupIndex + 1),\n });\n }\n break;\n } else if (i == findSequence.length - 1 && block) {\n result.push({\n parent: path[0],\n block: block,\n path,\n });\n break;\n }\n }\n });\n\n return result;\n}\n//#endregion\n\n//#region getFirstSelectedTable\n/**\n * Get the first selected table from content model\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedTable(\n model: ContentModelDocument\n): [ContentModelTable | undefined, ContentModelBlockGroup[]];\n\n/**\n * Get the first selected table from content model (Readonly)\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedTable(\n model: ReadonlyContentModelDocument\n): [ReadonlyContentModelTable | undefined, ReadonlyContentModelBlockGroup[]];\n\nexport function getFirstSelectedTable(\n model: ReadonlyContentModelDocument\n): [ReadonlyContentModelTable | undefined, ReadonlyContentModelBlockGroup[]] {\n const selections = collectSelections(model, { includeListFormatHolder: 'never' });\n let table: ReadonlyContentModelTable | undefined;\n let resultPath: ReadonlyContentModelBlockGroup[] = [];\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ block, tableContext, path }) => {\n if (!table) {\n if (block?.blockType == 'Table') {\n table = block;\n resultPath = [...path];\n } else if (tableContext?.table) {\n table = tableContext.table;\n\n const parent = path.filter(\n group => group.blocks.indexOf(tableContext.table) >= 0\n )[0];\n const index = path.indexOf(parent);\n resultPath = index >= 0 ? path.slice(index) : [];\n }\n }\n });\n\n return [table, resultPath];\n}\n//#endregion\n\n//#region getFirstSelectedListItem\n/**\n * Get the first selected list item from content model\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedListItem(\n model: ContentModelDocument\n): ContentModelListItem | undefined;\n\n/**\n * Get the first selected list item from content model (Readonly)\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedListItem(\n model: ReadonlyContentModelDocument\n): ReadonlyContentModelListItem | undefined;\n\nexport function getFirstSelectedListItem(\n model: ReadonlyContentModelDocument\n): ReadonlyContentModelListItem | undefined {\n let listItem: ContentModelListItem | undefined;\n\n getOperationalBlocks(model, ['ListItem'], ['TableCell']).forEach(r => {\n if (!listItem && isBlockGroupOfType<ContentModelListItem>(r.block, 'ListItem')) {\n listItem = r.block;\n }\n });\n\n return listItem;\n}\n//#endregion\n\n//#region collectSelections\ninterface SelectionInfo {\n path: ContentModelBlockGroup[];\n segments?: ContentModelSegment[];\n block?: ContentModelBlock;\n tableContext?: TableSelectionContext;\n}\n\ninterface ReadonlySelectionInfo {\n path: ReadonlyContentModelBlockGroup[];\n segments?: ReadonlyContentModelSegment[];\n block?: ReadonlyContentModelBlock;\n tableContext?: ReadonlyTableSelectionContext;\n}\n\nfunction collectSelections(\n group: ContentModelBlockGroup,\n option?: IterateSelectionsOption\n): SelectionInfo[];\n\nfunction collectSelections(\n group: ReadonlyContentModelBlockGroup,\n option?: IterateSelectionsOption\n): ReadonlySelectionInfo[];\n\nfunction collectSelections(\n group: ReadonlyContentModelBlockGroup,\n option?: IterateSelectionsOption\n): ReadonlySelectionInfo[] {\n const selections: ReadonlySelectionInfo[] = [];\n\n iterateSelections(\n group,\n (path, tableContext, block, segments) => {\n selections.push({\n path,\n tableContext,\n block,\n segments,\n });\n },\n option\n );\n\n return selections;\n}\n//#endregion\n\n//#region utils\nfunction removeUnmeaningfulSelections(selections: ReadonlySelectionInfo[]) {\n if (\n selections.length > 1 &&\n isOnlySelectionMarkerSelected(selections, false /*checkFirstParagraph*/)\n ) {\n selections.pop();\n }\n\n // Remove head paragraph if first selection marker is the only selection\n if (\n selections.length > 1 &&\n isOnlySelectionMarkerSelected(selections, true /*checkFirstParagraph*/)\n ) {\n selections.shift();\n }\n}\n\nfunction isOnlySelectionMarkerSelected(\n selections: ReadonlySelectionInfo[],\n checkFirstParagraph: boolean\n): boolean {\n const selection = selections[checkFirstParagraph ? 0 : selections.length - 1];\n\n if (\n selection.block?.blockType == 'Paragraph' &&\n selection.segments &&\n selection.segments.length > 0\n ) {\n const allSegments = selection.block.segments;\n const segment = selection.segments[0];\n\n return (\n selection.segments.length == 1 &&\n segment.segmentType == 'SelectionMarker' &&\n segment == allSegments[checkFirstParagraph ? allSegments.length - 1 : 0]\n );\n } else {\n return false;\n }\n}\n//#endregion\n"]}
@@ -43,6 +43,7 @@ function createModelToDomFormatContext() {
43
43
  listFormat: {
44
44
  threadItemCounts: [],
45
45
  nodeStack: [],
46
+ currentLevel: 0,
46
47
  },
47
48
  implicitFormat: {},
48
49
  };