roosterjs-content-model-dom 9.59.0 → 9.61.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 (40) hide show
  1. package/lib/domUtils/isUnsafeUrl.d.ts +10 -0
  2. package/lib/domUtils/isUnsafeUrl.js +32 -0
  3. package/lib/domUtils/isUnsafeUrl.js.map +1 -0
  4. package/lib/formatHandlers/segment/linkFormatHandler.js +3 -2
  5. package/lib/formatHandlers/segment/linkFormatHandler.js.map +1 -1
  6. package/lib/index.d.ts +2 -0
  7. package/lib/index.js +8 -4
  8. package/lib/index.js.map +1 -1
  9. package/lib/modelApi/editing/canMergeCells.d.ts +10 -0
  10. package/lib/modelApi/editing/canMergeCells.js +62 -0
  11. package/lib/modelApi/editing/canMergeCells.js.map +1 -0
  12. package/lib/modelApi/editing/retrieveModelFormatState.js +6 -1
  13. package/lib/modelApi/editing/retrieveModelFormatState.js.map +1 -1
  14. package/lib-amd/domUtils/isUnsafeUrl.d.ts +10 -0
  15. package/lib-amd/domUtils/isUnsafeUrl.js +34 -0
  16. package/lib-amd/domUtils/isUnsafeUrl.js.map +1 -0
  17. package/lib-amd/formatHandlers/segment/linkFormatHandler.js +3 -3
  18. package/lib-amd/formatHandlers/segment/linkFormatHandler.js.map +1 -1
  19. package/lib-amd/index.d.ts +2 -0
  20. package/lib-amd/index.js +4 -2
  21. package/lib-amd/index.js.map +1 -1
  22. package/lib-amd/modelApi/editing/canMergeCells.d.ts +10 -0
  23. package/lib-amd/modelApi/editing/canMergeCells.js +64 -0
  24. package/lib-amd/modelApi/editing/canMergeCells.js.map +1 -0
  25. package/lib-amd/modelApi/editing/retrieveModelFormatState.js +6 -2
  26. package/lib-amd/modelApi/editing/retrieveModelFormatState.js.map +1 -1
  27. package/lib-mjs/domUtils/isUnsafeUrl.d.ts +10 -0
  28. package/lib-mjs/domUtils/isUnsafeUrl.js +28 -0
  29. package/lib-mjs/domUtils/isUnsafeUrl.js.map +1 -0
  30. package/lib-mjs/formatHandlers/segment/linkFormatHandler.js +3 -2
  31. package/lib-mjs/formatHandlers/segment/linkFormatHandler.js.map +1 -1
  32. package/lib-mjs/index.d.ts +2 -0
  33. package/lib-mjs/index.js +2 -0
  34. package/lib-mjs/index.js.map +1 -1
  35. package/lib-mjs/modelApi/editing/canMergeCells.d.ts +10 -0
  36. package/lib-mjs/modelApi/editing/canMergeCells.js +58 -0
  37. package/lib-mjs/modelApi/editing/canMergeCells.js.map +1 -0
  38. package/lib-mjs/modelApi/editing/retrieveModelFormatState.js +6 -1
  39. package/lib-mjs/modelApi/editing/retrieveModelFormatState.js.map +1 -1
  40. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Check whether the given URL uses a protocol that can execute script, such as "javascript:"
3
+ * @param url The URL to check
4
+ * @returns True if the URL can execute script when navigated to, otherwise false
5
+ * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
6
+ * character or space before they resolve its protocol. Those characters must be removed before the
7
+ * protocol is checked here, otherwise a value such as "java	script:" or "javascr
ipt:" would
8
+ * be treated as safe but still executed by the browser.
9
+ */
10
+ export declare function isUnsafeUrl(url: string | null | undefined): boolean;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUnsafeUrl = void 0;
4
+ var UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];
5
+ var IgnoredCharacters = /[\t\n\r]/g;
6
+ var MaxControlCharCode = 0x20;
7
+ /**
8
+ * Check whether the given URL uses a protocol that can execute script, such as "javascript:"
9
+ * @param url The URL to check
10
+ * @returns True if the URL can execute script when navigated to, otherwise false
11
+ * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
12
+ * character or space before they resolve its protocol. Those characters must be removed before the
13
+ * protocol is checked here, otherwise a value such as "java	script:" or "javascr
ipt:" would
14
+ * be treated as safe but still executed by the browser.
15
+ */
16
+ function isUnsafeUrl(url) {
17
+ if (!url) {
18
+ return false;
19
+ }
20
+ var normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();
21
+ var colonIndex = normalizedUrl.indexOf(':');
22
+ return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;
23
+ }
24
+ exports.isUnsafeUrl = isUnsafeUrl;
25
+ function trimControlCharacters(url) {
26
+ var start = 0;
27
+ while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {
28
+ start++;
29
+ }
30
+ return url.substring(start);
31
+ }
32
+ //# sourceMappingURL=isUnsafeUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUnsafeUrl.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts"],"names":[],"mappings":";;;AAAA,IAAM,eAAe,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC/F,IAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,IAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,GAA8B;IACtD,IAAI,CAAC,GAAG,EAAE;QACN,OAAO,KAAK,CAAC;KAChB;IAED,IAAM,aAAa,GAAG,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9F,IAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9C,OAAO,UAAU,IAAI,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;AACnG,CAAC;AATD,kCASC;AAED,SAAS,qBAAqB,CAAC,GAAW;IACtC,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,kBAAkB,EAAE;QACtE,KAAK,EAAE,CAAC;KACX;IAED,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","sourcesContent":["const UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];\nconst IgnoredCharacters = /[\\t\\n\\r]/g;\nconst MaxControlCharCode = 0x20;\n\n/**\n * Check whether the given URL uses a protocol that can execute script, such as \"javascript:\"\n * @param url The URL to check\n * @returns True if the URL can execute script when navigated to, otherwise false\n * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control\n * character or space before they resolve its protocol. Those characters must be removed before the\n * protocol is checked here, otherwise a value such as \"java&#9;script:\" or \"javascr&#13;ipt:\" would\n * be treated as safe but still executed by the browser.\n */\nexport function isUnsafeUrl(url: string | null | undefined): boolean {\n if (!url) {\n return false;\n }\n\n const normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();\n const colonIndex = normalizedUrl.indexOf(':');\n\n return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;\n}\n\nfunction trimControlCharacters(url: string): string {\n let start = 0;\n\n while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {\n start++;\n }\n\n return url.substring(start);\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.linkFormatHandler = void 0;
4
4
  var isElementOfType_1 = require("../../domUtils/isElementOfType");
5
+ var isUnsafeUrl_1 = require("../../domUtils/isUnsafeUrl");
5
6
  /**
6
7
  * @internal
7
8
  */
@@ -18,7 +19,7 @@ exports.linkFormatHandler = {
18
19
  if (name_1) {
19
20
  format.name = name_1;
20
21
  }
21
- if (href) {
22
+ if (href && !(0, isUnsafeUrl_1.isUnsafeUrl)(href)) {
22
23
  format.href = href;
23
24
  }
24
25
  if (target) {
@@ -40,7 +41,7 @@ exports.linkFormatHandler = {
40
41
  },
41
42
  apply: function (format, element) {
42
43
  if ((0, isElementOfType_1.isElementOfType)(element, 'a') && (format.href || format.name)) {
43
- if (format.href) {
44
+ if (format.href && !(0, isUnsafeUrl_1.isUnsafeUrl)(format.href)) {
44
45
  element.href = format.href;
45
46
  }
46
47
  if (format.name) {
@@ -1 +1 @@
1
- {"version":3,"file":"linkFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/linkFormatHandler.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AAIjE;;GAEG;AACU,QAAA,iBAAiB,GAA8B;IACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,IAAA,iCAAe,EAAC,OAAO,EAAE,GAAG,CAAC,EAAE;YAC/B,IAAM,MAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAC1B,IAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,0EAA0E;YACrH,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC9B,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YACxB,IAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;YACtB,IAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YACpC,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAE5B,IAAI,MAAI,EAAE;gBACN,MAAM,CAAC,IAAI,GAAG,MAAI,CAAC;aACtB;YAED,IAAI,IAAI,EAAE;gBACN,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;aACtB;YAED,IAAI,MAAM,EAAE;gBACR,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;aAC1B;YAED,IAAI,EAAE,EAAE;gBACJ,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;aACxB;YAED,IAAI,GAAG,EAAE;gBACL,MAAM,CAAC,YAAY,GAAG,GAAG,CAAC;aAC7B;YAED,IAAI,KAAK,EAAE;gBACP,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;aAC9B;YAED,IAAI,SAAS,EAAE;gBACX,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;aAClC;SACJ;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,IAAA,iCAAe,EAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;YAC/D,IAAI,MAAM,CAAC,IAAI,EAAE;gBACb,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;aAC9B;YAED,IAAI,MAAM,CAAC,IAAI,EAAE;gBACb,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;aAC9B;YAED,IAAI,MAAM,CAAC,MAAM,EAAE;gBACf,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;aAClC;YAED,IAAI,MAAM,CAAC,QAAQ,EAAE;gBACjB,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;aAChC;YAED,IAAI,MAAM,CAAC,WAAW,EAAE;gBACpB,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;aAC1C;YAED,IAAI,MAAM,CAAC,WAAW,EAAE;gBACpB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;aACtC;YAED,IAAI,MAAM,CAAC,YAAY,EAAE;gBACrB,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;aACrC;SACJ;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { LinkFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const linkFormatHandler: FormatHandler<LinkFormat> = {\n parse: (format, element) => {\n if (isElementOfType(element, 'a')) {\n const name = element.name;\n const href = element.getAttribute('href'); // Use getAttribute to get original HREF but not the resolved absolute url\n const target = element.target;\n const rel = element.rel;\n const id = element.id;\n const className = element.className;\n const title = element.title;\n\n if (name) {\n format.name = name;\n }\n\n if (href) {\n format.href = href;\n }\n\n if (target) {\n format.target = target;\n }\n\n if (id) {\n format.anchorId = id;\n }\n\n if (rel) {\n format.relationship = rel;\n }\n\n if (title) {\n format.anchorTitle = title;\n }\n\n if (className) {\n format.anchorClass = className;\n }\n }\n },\n apply: (format, element) => {\n if (isElementOfType(element, 'a') && (format.href || format.name)) {\n if (format.href) {\n element.href = format.href;\n }\n\n if (format.name) {\n element.name = format.name;\n }\n\n if (format.target) {\n element.target = format.target;\n }\n\n if (format.anchorId) {\n element.id = format.anchorId;\n }\n\n if (format.anchorClass) {\n element.className = format.anchorClass;\n }\n\n if (format.anchorTitle) {\n element.title = format.anchorTitle;\n }\n\n if (format.relationship) {\n element.rel = format.relationship;\n }\n }\n },\n};\n"]}
1
+ {"version":3,"file":"linkFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/linkFormatHandler.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AACjE,0DAAyD;AAIzD;;GAEG;AACU,QAAA,iBAAiB,GAA8B;IACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,IAAA,iCAAe,EAAC,OAAO,EAAE,GAAG,CAAC,EAAE;YAC/B,IAAM,MAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAC1B,IAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,0EAA0E;YACrH,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC9B,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YACxB,IAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;YACtB,IAAM,SA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,CAAC,QAAQ,CAAC;aAChC;YAED,IAAI,MAAM,CAAC,WAAW,EAAE;gBACpB,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;aAC1C;YAED,IAAI,MAAM,CAAC,WAAW,EAAE;gBACpB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;aACtC;YAED,IAAI,MAAM,CAAC,YAAY,EAAE;gBACrB,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;aACrC;SACJ;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport { isUnsafeUrl } from '../../domUtils/isUnsafeUrl';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { LinkFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const linkFormatHandler: FormatHandler<LinkFormat> = {\n parse: (format, element) => {\n if (isElementOfType(element, 'a')) {\n const name = element.name;\n const href = element.getAttribute('href'); // Use getAttribute to get original HREF but not the resolved absolute url\n const target = element.target;\n const rel = element.rel;\n const id = element.id;\n const className = element.className;\n const title = element.title;\n\n if (name) {\n format.name = name;\n }\n\n if (href && !isUnsafeUrl(href)) {\n format.href = href;\n }\n\n if (target) {\n format.target = target;\n }\n\n if (id) {\n format.anchorId = id;\n }\n\n if (rel) {\n format.relationship = rel;\n }\n\n if (title) {\n format.anchorTitle = title;\n }\n\n if (className) {\n format.anchorClass = className;\n }\n }\n },\n apply: (format, element) => {\n if (isElementOfType(element, 'a') && (format.href || format.name)) {\n if (format.href && !isUnsafeUrl(format.href)) {\n element.href = format.href;\n }\n\n if (format.name) {\n element.name = format.name;\n }\n\n if (format.target) {\n element.target = format.target;\n }\n\n if (format.anchorId) {\n element.id = format.anchorId;\n }\n\n if (format.anchorClass) {\n element.className = format.anchorClass;\n }\n\n if (format.anchorTitle) {\n element.title = format.anchorTitle;\n }\n\n if (format.relationship) {\n element.rel = format.relationship;\n }\n }\n },\n};\n"]}
package/lib/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { buildSelectionMarker } from './domToModel/utils/buildSelectionMarker';
13
13
  export { updateMetadata, getMetadata, hasMetadata } from './modelApi/metadata/updateMetadata';
14
14
  export { isNodeOfType } from './domUtils/isNodeOfType';
15
15
  export { isElementOfType } from './domUtils/isElementOfType';
16
+ export { isUnsafeUrl } from './domUtils/isUnsafeUrl';
16
17
  export { getObjectKeys } from './domUtils/getObjectKeys';
17
18
  export { getSafeIdSelector } from './domUtils/getSafeIdSelector';
18
19
  export { toArray } from './domUtils/toArray';
@@ -95,6 +96,7 @@ export { hasSelectionInSegment } from './modelApi/selection/hasSelectionInSegmen
95
96
  export { hasSelectionInBlockGroup } from './modelApi/selection/hasSelectionInBlockGroup';
96
97
  export { setSelection } from './modelApi/selection/setSelection';
97
98
  export { cloneModel, cloneModelForPaste } from './modelApi/editing/cloneModel';
99
+ export { canMergeCells } from './modelApi/editing/canMergeCells';
98
100
  export { mergeModel } from './modelApi/editing/mergeModel';
99
101
  export { deleteSelection } from './modelApi/editing/deleteSelection';
100
102
  export { deleteSegment } from './modelApi/editing/deleteSegment';
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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.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.addData = 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.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.cloneModelForPaste = 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.createPasteFragment = 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 = 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 = exports.getSegmentTextFormat = void 0;
3
+ 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.isUnsafeUrl = 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.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.addData = 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 = exports.createImage = void 0;
5
+ 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.canMergeCells = exports.cloneModelForPaste = 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.createPasteFragment = 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 = exports.trimModelForSelection = exports.getDOMInsertPointRect = 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 = exports.getSegmentTextFormat = exports.getListStyleTypeFromString = exports.retrieveModelFormatState = 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");
@@ -38,6 +38,8 @@ var isNodeOfType_1 = require("./domUtils/isNodeOfType");
38
38
  Object.defineProperty(exports, "isNodeOfType", { enumerable: true, get: function () { return isNodeOfType_1.isNodeOfType; } });
39
39
  var isElementOfType_1 = require("./domUtils/isElementOfType");
40
40
  Object.defineProperty(exports, "isElementOfType", { enumerable: true, get: function () { return isElementOfType_1.isElementOfType; } });
41
+ var isUnsafeUrl_1 = require("./domUtils/isUnsafeUrl");
42
+ Object.defineProperty(exports, "isUnsafeUrl", { enumerable: true, get: function () { return isUnsafeUrl_1.isUnsafeUrl; } });
41
43
  var getObjectKeys_1 = require("./domUtils/getObjectKeys");
42
44
  Object.defineProperty(exports, "getObjectKeys", { enumerable: true, get: function () { return getObjectKeys_1.getObjectKeys; } });
43
45
  var getSafeIdSelector_1 = require("./domUtils/getSafeIdSelector");
@@ -239,6 +241,8 @@ Object.defineProperty(exports, "setSelection", { enumerable: true, get: function
239
241
  var cloneModel_1 = require("./modelApi/editing/cloneModel");
240
242
  Object.defineProperty(exports, "cloneModel", { enumerable: true, get: function () { return cloneModel_1.cloneModel; } });
241
243
  Object.defineProperty(exports, "cloneModelForPaste", { enumerable: true, get: function () { return cloneModel_1.cloneModelForPaste; } });
244
+ var canMergeCells_1 = require("./modelApi/editing/canMergeCells");
245
+ Object.defineProperty(exports, "canMergeCells", { enumerable: true, get: function () { return canMergeCells_1.canMergeCells; } });
242
246
  var mergeModel_1 = require("./modelApi/editing/mergeModel");
243
247
  Object.defineProperty(exports, "mergeModel", { enumerable: true, get: function () { return mergeModel_1.mergeModel; } });
244
248
  var deleteSelection_1 = require("./modelApi/editing/deleteSelection");
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,OAA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,oHAAA,gBAAgB,OAAA;AAAE,+HAAA,2BAA2B,OAAA;AACtD,oEAI2C;AAHvC,gHAAA,cAAc,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 { addData } 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 { createPasteFragment } from './domUtils/event/createPasteFragment';\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, cloneModelForPaste } 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;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,sDAAqD;AAA5C,0GAAA,WAAW,OAAA;AACpB,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,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,sDAUgC;AAT5B,8GAAA,eAAe,OAAA;AACf,uHAAA,wBAAwB,OAAA;A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AgG;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 { isUnsafeUrl } from './domUtils/isUnsafeUrl';\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 { addData } 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 { createPasteFragment } from './domUtils/event/createPasteFragment';\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, cloneModelForPaste } from './modelApi/editing/cloneModel';\nexport { canMergeCells } from './modelApi/editing/canMergeCells';\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"]}
@@ -0,0 +1,10 @@
1
+ import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Check whether the given range of table cells can be merged without splitting existing spans.
4
+ * @param rows The table rows to check
5
+ * @param firstRow The first row index of the range
6
+ * @param firstCol The first column index of the range
7
+ * @param lastRow The last row index of the range
8
+ * @param lastCol The last column index of the range
9
+ */
10
+ export declare function canMergeCells(rows: readonly ReadonlyContentModelTableRow[], firstRow: number, firstCol: number, lastRow: number, lastCol: number): boolean;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canMergeCells = void 0;
4
+ /**
5
+ * Check whether the given range of table cells can be merged without splitting existing spans.
6
+ * @param rows The table rows to check
7
+ * @param firstRow The first row index of the range
8
+ * @param firstCol The first column index of the range
9
+ * @param lastRow The last row index of the range
10
+ * @param lastCol The last column index of the range
11
+ */
12
+ function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
13
+ var noSpanAbove = firstCol == lastCol ||
14
+ rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
15
+ var noSpanLeft = firstRow == lastRow ||
16
+ rows.every(function (row, rowIndex) {
17
+ return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
18
+ });
19
+ var noDifferentBelowSpan = rows[lastRow].cells
20
+ .map(function (_, colIndex) {
21
+ return colIndex >= firstCol && colIndex <= lastCol
22
+ ? getBelowSpanCount(rows, lastRow, colIndex)
23
+ : -1;
24
+ })
25
+ .every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
26
+ var noDifferentRightSpan = rows
27
+ .map(function (_, rowIndex) {
28
+ return rowIndex >= firstRow && rowIndex <= lastRow
29
+ ? getRightSpanCount(rows, rowIndex, lastCol)
30
+ : -1;
31
+ })
32
+ .every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
33
+ return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
34
+ }
35
+ exports.canMergeCells = canMergeCells;
36
+ function getBelowSpanCount(rows, rowIndex, colIndex) {
37
+ var _a, _b;
38
+ var spanCount = 0;
39
+ for (var row = rowIndex + 1; row < rows.length; row++) {
40
+ if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
41
+ spanCount++;
42
+ }
43
+ else {
44
+ break;
45
+ }
46
+ }
47
+ return spanCount;
48
+ }
49
+ function getRightSpanCount(rows, rowIndex, colIndex) {
50
+ var _a, _b, _c;
51
+ var spanCount = 0;
52
+ for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
53
+ if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
54
+ spanCount++;
55
+ }
56
+ else {
57
+ break;
58
+ }
59
+ }
60
+ return spanCount;
61
+ }
62
+ //# sourceMappingURL=canMergeCells.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canMergeCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,SAAgB,aAAa,CACzB,IAA6C,EAC7C,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,OAAe;IAEf,IAAM,WAAW,GACb,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CACtB,UAAC,IAAI,EAAE,QAAQ,IAAK,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAA5D,CAA4D,CACnF,CAAC;IACN,IAAM,UAAU,GACZ,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,KAAK,CACN,UAAC,GAAG,EAAE,QAAQ;YACV,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ;QAA1E,CAA0E,CACjF,CAAC;IAEN,IAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK;SAC3C,GAAG,CAAC,UAAC,CAAC,EAAE,QAAQ;QACb,OAAA,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,OAAO;YACvC,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC;YAC5C,CAAC,CAAC,CAAC,CAAC;IAFR,CAEQ,CACX;SACA,KAAK,CAAC,UAAC,CAAC,EAAE,CAAC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M,CAAA,EAAE,GAAG,EAAE,EAAE;QACpE,IAAI,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE;YACtC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';\n\n/**\n * Check whether the given range of table cells can be merged without splitting existing spans.\n * @param rows The table rows to check\n * @param firstRow The first row index of the range\n * @param firstCol The first column index of the range\n * @param lastRow The last row index of the range\n * @param lastCol The last column index of the range\n */\nexport function canMergeCells(\n rows: readonly ReadonlyContentModelTableRow[],\n firstRow: number,\n firstCol: number,\n lastRow: number,\n lastCol: number\n): boolean {\n const noSpanAbove =\n firstCol == lastCol ||\n rows[firstRow].cells.every(\n (cell, colIndex) => colIndex < firstCol || colIndex > lastCol || !cell.spanAbove\n );\n const noSpanLeft =\n firstRow == lastRow ||\n rows.every(\n (row, rowIndex) =>\n rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft\n );\n\n const noDifferentBelowSpan = rows[lastRow].cells\n .map((_, colIndex) =>\n colIndex >= firstCol && colIndex <= lastCol\n ? getBelowSpanCount(rows, lastRow, colIndex)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstCol]);\n const noDifferentRightSpan = rows\n .map((_, rowIndex) =>\n rowIndex >= firstRow && rowIndex <= lastRow\n ? getRightSpanCount(rows, rowIndex, lastCol)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstRow]);\n\n return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;\n}\n\nfunction getBelowSpanCount(\n rows: readonly ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let row = rowIndex + 1; row < rows.length; row++) {\n if (rows[row]?.cells[colIndex]?.spanAbove) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n\nfunction getRightSpanCount(\n rows: readonly ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let col = colIndex + 1; col < rows[rowIndex]?.cells.length; col++) {\n if (rows[rowIndex]?.cells[col]?.spanLeft) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n"]}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.retrieveModelFormatState = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var borderValues_1 = require("../../domUtils/style/borderValues");
6
+ var canMergeCells_1 = require("./canMergeCells");
6
7
  var getClosestAncestorBlockGroupIndex_1 = require("./getClosestAncestorBlockGroupIndex");
7
8
  var updateImageMetadata_1 = require("../metadata/updateImageMetadata");
8
9
  var updateTableMetadata_1 = require("../metadata/updateTableMetadata");
@@ -23,6 +24,7 @@ var parseValueWithUnit_1 = require("../../formatHandlers/utils/parseValueWithUni
23
24
  function retrieveModelFormatState(model, pendingFormat, formatState, conflictSolution, domHelper, isInDarkMode, colorHandler) {
24
25
  if (conflictSolution === void 0) { conflictSolution = 'remove'; }
25
26
  var firstTableContext;
27
+ var lastTableContext;
26
28
  var firstBlock;
27
29
  var isFirst = true;
28
30
  var isFirstImage = true;
@@ -94,7 +96,7 @@ function retrieveModelFormatState(model, pendingFormat, formatState, conflictSol
94
96
  // Merge table format
95
97
  if (tableContext.table == table &&
96
98
  (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)) {
97
- formatState.canMergeTableCell = true;
99
+ lastTableContext = tableContext;
98
100
  formatState.isMultilineSelection = true;
99
101
  }
100
102
  }
@@ -107,6 +109,9 @@ function retrieveModelFormatState(model, pendingFormat, formatState, conflictSol
107
109
  }, {
108
110
  includeListFormatHolder: 'never',
109
111
  });
112
+ if (firstTableContext && lastTableContext) {
113
+ formatState.canMergeTableCell = (0, canMergeCells_1.canMergeCells)(firstTableContext.table.rows, firstTableContext.rowIndex, firstTableContext.colIndex, lastTableContext.rowIndex, lastTableContext.colIndex);
114
+ }
110
115
  if (formatState.fontSize) {
111
116
  formatState.fontSize = px2Pt(formatState.fontSize);
112
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/retrieveModelFormatState.ts"],"names":[],"mappings":";;;;AAAA,kEAAwE;AACxE,yFAAwF;AACxF,uEAAmE;AACnE,uEAAmE;AACnE,sDAAqD;AACrD,oEAAmE;AACnE,oFAAmF;AAiBnF;;;;;;;;;;GAUG;AACH,SAAgB,wBAAwB,CACpC,KAAmC,EACnC,aAA+C,EAC/C,WAAoC,EACpC,gBAAmD,EACnD,SAAqB,EACrB,YAAsB,EACtB,YAA+B;IAH/B,iCAAA,EAAA,2BAAmD;IAKnD,IAAI,iBAA4D,CAAC;IACjE,IAAI,UAAiD,CAAC;IACtD,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,YAAY,GAAG,IAAI,CAAC;IACxB,IAAI,cAAc,GAAG,IAAI,CAAC;IAC1B,IAAI,eAAe,GAA0C,SAAS,CAAC;IAEvE,IAAM,WAAW,6BAAQ,KAAK,CAAC,MAAM,CAAE,CAAC;IAExC,OAAO,WAAW,CAAC,MAAM,CAAC;IAC1B,OAAO,WAAW,CAAC,SAAS,CAAC;IAC7B,OAAO,WAAW,CAAC,UAAU,CAAC;IAE9B,IAAA,qCAAiB,EACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ;QAChC,oBAAoB;QACpB,uBAAuB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAEtE,uBAAuB;QACvB,IAAI,KAAK,EAAE;YACP,IAAI,UAAU,EAAE;gBACZ,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC;aAC3C;iBAAM;gBACH,UAAU,GAAG,KA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ues';\nimport { getClosestAncestorBlockGroupIndex } from './getClosestAncestorBlockGroupIndex';\nimport { getImageMetadata } from '../metadata/updateImageMetadata';\nimport { getTableMetadata } from '../metadata/updateTableMetadata';\nimport { isBold } from '../../domUtils/style/isBold';\nimport { iterateSelections } from '../selection/iterateSelections';\nimport { parseValueWithUnit } from '../../formatHandlers/utils/parseValueWithUnit';\nimport type {\n ConflictFormatSolution,\n ContentModelFormatState,\n ContentModelSegmentFormat,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelBlock,\n ReadonlyContentModelImage,\n ReadonlyTableSelectionContext,\n ReadonlyContentModelParagraph,\n ReadonlyContentModelFormatContainer,\n ReadonlyContentModelListItem,\n ReadonlyContentModelDocument,\n DOMHelper,\n DarkColorHandler,\n} from 'roosterjs-content-model-types';\n\n/**\n * Retrieve format state from the given Content Model\n * @param model The Content Model to retrieve format state from\n * @param pendingFormat Existing pending format, if any\n * @param formatState Existing format state object, used for receiving the result\n * @param conflictSolution The strategy for handling format conflicts\n * @param domHelper Optional DOMHelper to retrieve container format\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param colorHandler Optional DarkColorHandler to handle dark mode colors\n *\n */\nexport function retrieveModelFormatState(\n model: ReadonlyContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState,\n conflictSolution: ConflictFormatSolution = 'remove',\n domHelper?: DOMHelper,\n isInDarkMode?: boolean,\n colorHandler?: DarkColorHandler\n) {\n let firstTableContext: ReadonlyTableSelectionContext | undefined;\n let firstBlock: ReadonlyContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n let containerFormat: ContentModelSegmentFormat | undefined = undefined;\n\n const modelFormat = { ...model.format };\n\n delete modelFormat.italic;\n delete modelFormat.underline;\n delete modelFormat.fontWeight;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst, conflictSolution);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst, conflictSolution);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n let currentFormat = Object.assign(\n {},\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n );\n\n // Sometimes the content may not specify all required format but just leverage the container format to do so.\n // In this case, we need to merge the container format into the current format\n // to make sure the current format contains all required format.\n if (!hasAllRequiredFormat(currentFormat)) {\n if (!containerFormat) {\n containerFormat =\n domHelper?.getContainerFormat(isInDarkMode, colorHandler) ??\n modelFormat;\n }\n\n currentFormat = Object.assign({}, containerFormat, currentFormat);\n }\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n currentFormat,\n conflictSolution\n );\n\n mergeValue(\n formatState,\n 'isCodeInline',\n !!segment?.code,\n isFirst,\n conflictSolution\n );\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n formatState.imageEditingMetadata = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n formatState.canMergeTableCell = true;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat,\n conflictSolution: ConflictFormatSolution = 'remove'\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst, conflictSolution);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst, conflictSolution);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst, conflictSolution);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst, conflictSolution);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst, conflictSolution);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst, conflictSolution);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst, conflictSolution);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst, conflictSolution);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n conflictSolution,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst, conflictSolution);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst, conflictSolution);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst, conflictSolution);\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst, conflictSolution);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ReadonlyContentModelParagraph,\n isFirst: boolean,\n conflictSolution: ConflictFormatSolution = 'remove'\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst, conflictSolution);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst, conflictSolution);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst, conflictSolution);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst, conflictSolution);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst, conflictSolution);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ReadonlyContentModelBlockGroup[],\n isFirst: boolean,\n conflictSolution: ConflictFormatSolution = 'remove'\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ReadonlyContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst, conflictSolution);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst, conflictSolution);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ReadonlyContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst,\n conflictSolution\n );\n}\n\nfunction retrieveTableFormat(\n tableContext: ReadonlyTableSelectionContext,\n result: ContentModelFormatState\n) {\n const tableFormat = getTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ReadonlyContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n result.imageEditingMetadata = getImageMetadata(image);\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n conflictSolution: ConflictFormatSolution = 'remove',\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n switch (conflictSolution) {\n case 'remove':\n delete format[key];\n break;\n case 'keepFirst':\n break;\n case 'returnMultiple':\n if (typeof format[key] === 'string') {\n (format[key] as string) = 'Multiple';\n } else {\n delete format[key];\n }\n break;\n }\n }\n}\n\nfunction px2Pt(px: string) {\n if (px) {\n const index = px.indexOf('px');\n if (index !== -1 && index === px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value to be a little less than the actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n }\n return px;\n}\n\nfunction hasAllRequiredFormat(format: ContentModelSegmentFormat) {\n return !!format.fontFamily && !!format.fontSize && !!format.textColor;\n}\n"]}
1
+ {"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/retrieveModelFormatState.ts"],"names":[],"mappings":";;;;AAAA,kEAAwE;AACxE,iDAAgD;AAChD,yFAAwF;AACxF,uEAAmE;AACnE,uEAAmE;AACnE,sDAAqD;AACrD,oEAAmE;AACnE,oFAAmF;AAiBnF;;;;;;;;;;GAUG;AACH,SAAgB,wBAAwB,CACpC,KAAmC,EACnC,aAA+C,EAC/C,WAAoC,EACpC,gBAAmD,EACnD,SAAqB,EACrB,YAAsB,EACtB,YAA+B;IAH/B,iCAAA,EAAA,2BAAmD;IAKnD,IAAI,iBAA4D,CAAC;IACj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gBACT,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACnB,MAAM;YACV,KAAK,WAAW;gBACZ,MAAM;YACV,KAAK,gBAAgB;gBACjB,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;oBAChC,MAAM,CAAC,GAAG,CAAY,GAAG,UAAU,CAAC;iBACxC;qBAAM;oBACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACtB;gBACD,MAAM;SACb;KACJ;AACL,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACrB,IAAI,EAAE,EAAE;QACJ,IAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YACzC,8HAA8H;YAC9H,wBAAwB;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;SAC9D;KACJ;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAiC;IAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;AAC1E,CAAC","sourcesContent":["import { extractBorderValues } from '../../domUtils/style/borderValues';\nimport { canMergeCells } from './canMergeCells';\nimport { getClosestAncestorBlockGroupIndex } from './getClosestAncestorBlockGroupIndex';\nimport { getImageMetadata } from '../metadata/updateImageMetadata';\nimport { getTableMetadata } from '../metadata/updateTableMetadata';\nimport { isBold } from '../../domUtils/style/isBold';\nimport { iterateSelections } from '../selection/iterateSelections';\nimport { parseValueWithUnit } from '../../formatHandlers/utils/parseValueWithUnit';\nimport type {\n ConflictFormatSolution,\n ContentModelFormatState,\n ContentModelSegmentFormat,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelBlock,\n ReadonlyContentModelImage,\n ReadonlyTableSelectionContext,\n ReadonlyContentModelParagraph,\n ReadonlyContentModelFormatContainer,\n ReadonlyContentModelListItem,\n ReadonlyContentModelDocument,\n DOMHelper,\n DarkColorHandler,\n} from 'roosterjs-content-model-types';\n\n/**\n * Retrieve format state from the given Content Model\n * @param model The Content Model to retrieve format state from\n * @param pendingFormat Existing pending format, if any\n * @param formatState Existing format state object, used for receiving the result\n * @param conflictSolution The strategy for handling format conflicts\n * @param domHelper Optional DOMHelper to retrieve container format\n * @param isInDarkMode Optional flag to indicate if the environment is in dark mode\n * @param colorHandler Optional DarkColorHandler to handle dark mode colors\n *\n */\nexport function retrieveModelFormatState(\n model: ReadonlyContentModelDocument,\n pendingFormat: ContentModelSegmentFormat | null,\n formatState: ContentModelFormatState,\n conflictSolution: ConflictFormatSolution = 'remove',\n domHelper?: DOMHelper,\n isInDarkMode?: boolean,\n colorHandler?: DarkColorHandler\n) {\n let firstTableContext: ReadonlyTableSelectionContext | undefined;\n let lastTableContext: ReadonlyTableSelectionContext | undefined;\n let firstBlock: ReadonlyContentModelBlock | undefined;\n let isFirst = true;\n let isFirstImage = true;\n let isFirstSegment = true;\n let containerFormat: ContentModelSegmentFormat | undefined = undefined;\n\n const modelFormat = { ...model.format };\n\n delete modelFormat.italic;\n delete modelFormat.underline;\n delete modelFormat.fontWeight;\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n // Structure formats\n retrieveStructureFormat(formatState, path, isFirst, conflictSolution);\n\n // Multiple line format\n if (block) {\n if (firstBlock) {\n formatState.isMultilineSelection = true;\n } else {\n firstBlock = block;\n }\n }\n\n if (block?.blockType == 'Paragraph') {\n // Paragraph formats\n retrieveParagraphFormat(formatState, block, isFirst, conflictSolution);\n\n // Segment formats\n segments?.forEach(segment => {\n if (isFirstSegment || segment.segmentType != 'SelectionMarker') {\n let currentFormat = Object.assign(\n {},\n block.format,\n block.decorator?.format,\n segment.format,\n segment.code?.format,\n segment.link?.format,\n pendingFormat\n );\n\n // Sometimes the content may not specify all required format but just leverage the container format to do so.\n // In this case, we need to merge the container format into the current format\n // to make sure the current format contains all required format.\n if (!hasAllRequiredFormat(currentFormat)) {\n if (!containerFormat) {\n containerFormat =\n domHelper?.getContainerFormat(isInDarkMode, colorHandler) ??\n modelFormat;\n }\n\n currentFormat = Object.assign({}, containerFormat, currentFormat);\n }\n\n retrieveSegmentFormat(\n formatState,\n isFirst,\n currentFormat,\n conflictSolution\n );\n\n mergeValue(\n formatState,\n 'isCodeInline',\n !!segment?.code,\n isFirst,\n conflictSolution\n );\n }\n\n // We only care the format of selection marker when it is the first selected segment. This is because when selection marker\n // is after some other selected segments, it mostly like appears at the beginning of a seconde line when the whole first line\n // is selected (e.g. triple-click on a line) then the second selection marker doesn't contain a correct format, so we need to\n // ignore it\n isFirstSegment = false;\n\n formatState.canUnlink = formatState.canUnlink || !!segment.link;\n formatState.canAddImageAltText =\n formatState.canAddImageAltText ||\n segments.some(segment => segment.segmentType == 'Image');\n\n isFirst = false;\n\n if (segment.segmentType === 'Image') {\n if (isFirstImage) {\n retrieveImageFormat(segment, formatState);\n isFirstImage = false;\n } else {\n formatState.imageFormat = undefined;\n formatState.imageEditingMetadata = undefined;\n }\n }\n });\n\n isFirst = false;\n }\n\n if (tableContext) {\n if (firstTableContext) {\n const { table, colIndex, rowIndex } = firstTableContext;\n\n // Merge table format\n if (\n tableContext.table == table &&\n (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)\n ) {\n lastTableContext = tableContext;\n formatState.isMultilineSelection = true;\n }\n } else {\n // Table formats\n retrieveTableFormat(tableContext, formatState);\n firstTableContext = tableContext;\n }\n }\n },\n {\n includeListFormatHolder: 'never',\n }\n );\n\n if (firstTableContext && lastTableContext) {\n formatState.canMergeTableCell = canMergeCells(\n firstTableContext.table.rows,\n firstTableContext.rowIndex,\n firstTableContext.colIndex,\n lastTableContext.rowIndex,\n lastTableContext.colIndex\n );\n }\n\n if (formatState.fontSize) {\n formatState.fontSize = px2Pt(formatState.fontSize);\n }\n}\n\nfunction retrieveSegmentFormat(\n result: ContentModelFormatState,\n isFirst: boolean,\n mergedFormat: ContentModelSegmentFormat,\n conflictSolution: ConflictFormatSolution = 'remove'\n) {\n const superOrSubscript = mergedFormat.superOrSubScriptSequence?.split(' ')?.pop();\n\n mergeValue(result, 'isBold', isBold(mergedFormat.fontWeight), isFirst, conflictSolution);\n mergeValue(result, 'isItalic', mergedFormat.italic, isFirst, conflictSolution);\n mergeValue(result, 'isUnderline', mergedFormat.underline, isFirst, conflictSolution);\n mergeValue(result, 'isStrikeThrough', mergedFormat.strikethrough, isFirst, conflictSolution);\n mergeValue(result, 'isSuperscript', superOrSubscript == 'super', isFirst, conflictSolution);\n mergeValue(result, 'isSubscript', superOrSubscript == 'sub', isFirst, conflictSolution);\n mergeValue(result, 'letterSpacing', mergedFormat.letterSpacing, isFirst, conflictSolution);\n\n mergeValue(result, 'fontName', mergedFormat.fontFamily, isFirst, conflictSolution);\n mergeValue(\n result,\n 'fontSize',\n mergedFormat.fontSize,\n isFirst,\n conflictSolution,\n val => parseValueWithUnit(val, undefined, 'pt') + 'pt'\n );\n mergeValue(result, 'backgroundColor', mergedFormat.backgroundColor, isFirst, conflictSolution);\n mergeValue(result, 'textColor', mergedFormat.textColor, isFirst, conflictSolution);\n mergeValue(result, 'fontWeight', mergedFormat.fontWeight, isFirst, conflictSolution);\n mergeValue(result, 'lineHeight', mergedFormat.lineHeight, isFirst, conflictSolution);\n}\n\nfunction retrieveParagraphFormat(\n result: ContentModelFormatState,\n paragraph: ReadonlyContentModelParagraph,\n isFirst: boolean,\n conflictSolution: ConflictFormatSolution = 'remove'\n) {\n const headingLevel = parseInt((paragraph.decorator?.tagName || '').substring(1));\n const validHeadingLevel = headingLevel >= 1 && headingLevel <= 6 ? headingLevel : undefined;\n\n mergeValue(result, 'marginBottom', paragraph.format.marginBottom, isFirst, conflictSolution);\n mergeValue(result, 'marginTop', paragraph.format.marginTop, isFirst, conflictSolution);\n mergeValue(result, 'headingLevel', validHeadingLevel, isFirst, conflictSolution);\n mergeValue(result, 'textAlign', paragraph.format.textAlign, isFirst, conflictSolution);\n mergeValue(result, 'direction', paragraph.format.direction, isFirst, conflictSolution);\n}\n\nfunction retrieveStructureFormat(\n result: ContentModelFormatState,\n path: ReadonlyContentModelBlockGroup[],\n isFirst: boolean,\n conflictSolution: ConflictFormatSolution = 'remove'\n) {\n const listItemIndex = getClosestAncestorBlockGroupIndex(path, ['ListItem'], []);\n const containerIndex = getClosestAncestorBlockGroupIndex(path, ['FormatContainer'], []);\n\n if (listItemIndex >= 0) {\n const listItem = path[listItemIndex] as ReadonlyContentModelListItem;\n const listType = listItem?.levels[listItem.levels.length - 1]?.listType;\n\n mergeValue(result, 'isBullet', listType == 'UL', isFirst, conflictSolution);\n mergeValue(result, 'isNumbering', listType == 'OL', isFirst, conflictSolution);\n }\n\n mergeValue(\n result,\n 'isBlockQuote',\n containerIndex >= 0 &&\n (path[containerIndex] as ReadonlyContentModelFormatContainer)?.tagName == 'blockquote',\n isFirst,\n conflictSolution\n );\n}\n\nfunction retrieveTableFormat(\n tableContext: ReadonlyTableSelectionContext,\n result: ContentModelFormatState\n) {\n const tableFormat = getTableMetadata(tableContext.table);\n\n result.isInTable = true;\n result.tableHasHeader = tableContext.table.rows.some(row =>\n row.cells.some(cell => cell.isHeader)\n );\n\n if (tableFormat) {\n result.tableFormat = tableFormat;\n }\n}\n\nfunction retrieveImageFormat(image: ReadonlyContentModelImage, result: ContentModelFormatState) {\n const { format } = image;\n const borderKey = 'borderTop';\n const extractedBorder = extractBorderValues(format[borderKey]);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n result.imageFormat = {\n borderColor,\n borderWidth,\n borderStyle,\n boxShadow: format.boxShadow,\n borderRadius: format.borderRadius,\n };\n result.imageEditingMetadata = getImageMetadata(image);\n}\n\nfunction mergeValue<K extends keyof ContentModelFormatState>(\n format: ContentModelFormatState,\n key: K,\n newValue: ContentModelFormatState[K] | undefined,\n isFirst: boolean,\n conflictSolution: ConflictFormatSolution = 'remove',\n parseFn: (val: ContentModelFormatState[K]) => ContentModelFormatState[K] = val => val\n) {\n if (isFirst) {\n if (newValue !== undefined) {\n format[key] = newValue;\n }\n } else if (parseFn(newValue) !== parseFn(format[key])) {\n switch (conflictSolution) {\n case 'remove':\n delete format[key];\n break;\n case 'keepFirst':\n break;\n case 'returnMultiple':\n if (typeof format[key] === 'string') {\n (format[key] as string) = 'Multiple';\n } else {\n delete format[key];\n }\n break;\n }\n }\n}\n\nfunction px2Pt(px: string) {\n if (px) {\n const index = px.indexOf('px');\n if (index !== -1 && index === px.length - 2) {\n // Edge may not handle the floating computing well which causes the calculated value to be a little less than the actual value\n // So add 0.05 to fix it\n return Math.round(parseFloat(px) * 75 + 0.05) / 100 + 'pt';\n }\n }\n return px;\n}\n\nfunction hasAllRequiredFormat(format: ContentModelSegmentFormat) {\n return !!format.fontFamily && !!format.fontSize && !!format.textColor;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Check whether the given URL uses a protocol that can execute script, such as "javascript:"
3
+ * @param url The URL to check
4
+ * @returns True if the URL can execute script when navigated to, otherwise false
5
+ * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
6
+ * character or space before they resolve its protocol. Those characters must be removed before the
7
+ * protocol is checked here, otherwise a value such as "java&#9;script:" or "javascr&#13;ipt:" would
8
+ * be treated as safe but still executed by the browser.
9
+ */
10
+ export declare function isUnsafeUrl(url: string | null | undefined): boolean;
@@ -0,0 +1,34 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isUnsafeUrl = void 0;
5
+ var UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];
6
+ var IgnoredCharacters = /[\t\n\r]/g;
7
+ var MaxControlCharCode = 0x20;
8
+ /**
9
+ * Check whether the given URL uses a protocol that can execute script, such as "javascript:"
10
+ * @param url The URL to check
11
+ * @returns True if the URL can execute script when navigated to, otherwise false
12
+ * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
13
+ * character or space before they resolve its protocol. Those characters must be removed before the
14
+ * protocol is checked here, otherwise a value such as "java&#9;script:" or "javascr&#13;ipt:" would
15
+ * be treated as safe but still executed by the browser.
16
+ */
17
+ function isUnsafeUrl(url) {
18
+ if (!url) {
19
+ return false;
20
+ }
21
+ var normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();
22
+ var colonIndex = normalizedUrl.indexOf(':');
23
+ return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;
24
+ }
25
+ exports.isUnsafeUrl = isUnsafeUrl;
26
+ function trimControlCharacters(url) {
27
+ var start = 0;
28
+ while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {
29
+ start++;
30
+ }
31
+ return url.substring(start);
32
+ }
33
+ });
34
+ //# sourceMappingURL=isUnsafeUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUnsafeUrl.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts"],"names":[],"mappings":";;;;IAAA,IAAM,eAAe,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/F,IAAM,iBAAiB,GAAG,WAAW,CAAC;IACtC,IAAM,kBAAkB,GAAG,IAAI,CAAC;IAEhC;;;;;;;;OAQG;IACH,SAAgB,WAAW,CAAC,GAA8B;QACtD,IAAI,CAAC,GAAG,EAAE;YACN,OAAO,KAAK,CAAC;SAChB;QAED,IAAM,aAAa,GAAG,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9F,IAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAE9C,OAAO,UAAU,IAAI,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;IACnG,CAAC;IATD,kCASC;IAED,SAAS,qBAAqB,CAAC,GAAW;QACtC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,OAAO,KAAK,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,kBAAkB,EAAE;YACtE,KAAK,EAAE,CAAC;SACX;QAED,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC","sourcesContent":["const UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];\nconst IgnoredCharacters = /[\\t\\n\\r]/g;\nconst MaxControlCharCode = 0x20;\n\n/**\n * Check whether the given URL uses a protocol that can execute script, such as \"javascript:\"\n * @param url The URL to check\n * @returns True if the URL can execute script when navigated to, otherwise false\n * @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control\n * character or space before they resolve its protocol. Those characters must be removed before the\n * protocol is checked here, otherwise a value such as \"java&#9;script:\" or \"javascr&#13;ipt:\" would\n * be treated as safe but still executed by the browser.\n */\nexport function isUnsafeUrl(url: string | null | undefined): boolean {\n if (!url) {\n return false;\n }\n\n const normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();\n const colonIndex = normalizedUrl.indexOf(':');\n\n return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;\n}\n\nfunction trimControlCharacters(url: string): string {\n let start = 0;\n\n while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {\n start++;\n }\n\n return url.substring(start);\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "../../domUtils/isElementOfType"], function (require, exports, isElementOfType_1) {
1
+ define(["require", "exports", "../../domUtils/isElementOfType", "../../domUtils/isUnsafeUrl"], function (require, exports, isElementOfType_1, isUnsafeUrl_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.linkFormatHandler = void 0;
@@ -18,7 +18,7 @@ define(["require", "exports", "../../domUtils/isElementOfType"], function (requi
18
18
  if (name_1) {
19
19
  format.name = name_1;
20
20
  }
21
- if (href) {
21
+ if (href && !(0, isUnsafeUrl_1.isUnsafeUrl)(href)) {
22
22
  format.href = href;
23
23
  }
24
24
  if (target) {
@@ -40,7 +40,7 @@ define(["require", "exports", "../../domUtils/isElementOfType"], function (requi
40
40
  },
41
41
  apply: function (format, element) {
42
42
  if ((0, isElementOfType_1.isElementOfType)(element, 'a') && (format.href || format.name)) {
43
- if (format.href) {
43
+ if (format.href && !(0, isUnsafeUrl_1.isUnsafeUrl)(format.href)) {
44
44
  element.href = format.href;
45
45
  }
46
46
  if (format.name) {
@@ -1 +1 @@
1
- {"version":3,"file":"linkFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/linkFormatHandler.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACU,QAAA,iBAAiB,GAA8B;QACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;YACnB,IAAI,IAAA,iCAAe,EAAC,OAAO,EAAE,GAAG,CAAC,EAAE;gBAC/B,IAAM,MAAI,GAAG,OAAO,CAAC,IAAI,CAAC;gBAC1B,IAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,0EAA0E;gBACrH,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC9B,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;gBACxB,IAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;gBACtB,IA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OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;iBAC1C;gBAED,IAAI,MAAM,CAAC,WAAW,EAAE;oBACpB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;iBACtC;gBAED,IAAI,MAAM,CAAC,YAAY,EAAE;oBACrB,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;iBACrC;aACJ;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { LinkFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const linkFormatHandler: FormatHandler<LinkFormat> = {\n parse: (format, element) => {\n if (isElementOfType(element, 'a')) {\n const name = element.name;\n const href = element.getAttribute('href'); // Use getAttribute to get original HREF but not the resolved absolute url\n const target = element.target;\n const rel = element.rel;\n const id = element.id;\n const className = element.className;\n const title = element.title;\n\n if (name) {\n format.name = name;\n }\n\n if (href) {\n format.href = href;\n }\n\n if (target) {\n format.target = target;\n }\n\n if (id) {\n format.anchorId = id;\n }\n\n if (rel) {\n format.relationship = rel;\n }\n\n if (title) {\n format.anchorTitle = title;\n }\n\n if (className) {\n format.anchorClass = className;\n }\n }\n },\n apply: (format, element) => {\n if (isElementOfType(element, 'a') && (format.href || format.name)) {\n if (format.href) {\n element.href = format.href;\n }\n\n if (format.name) {\n element.name = format.name;\n }\n\n if (format.target) {\n element.target = format.target;\n }\n\n if (format.anchorId) {\n element.id = format.anchorId;\n }\n\n if (format.anchorClass) {\n element.className = format.anchorClass;\n }\n\n if (format.anchorTitle) {\n element.title = format.anchorTitle;\n }\n\n if (format.relationship) {\n element.rel = format.relationship;\n }\n }\n },\n};\n"]}
1
+ {"version":3,"file":"linkFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/linkFormatHandler.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACU,QAAA,i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I,CAAC,EAAE;gBAC/D,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,IAAA,yBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC1C,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;iBAC9B;gBAED,IAAI,MAAM,CAAC,IAAI,EAAE;oBACb,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;iBAC9B;gBAED,IAAI,MAAM,CAAC,MAAM,EAAE;oBACf,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;iBAClC;gBAED,IAAI,MAAM,CAAC,QAAQ,EAAE;oBACjB,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;iBAChC;gBAED,IAAI,MAAM,CAAC,WAAW,EAAE;oBACpB,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;iBAC1C;gBAED,IAAI,MAAM,CAAC,WAAW,EAAE;oBACpB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;iBACtC;gBAED,IAAI,MAAM,CAAC,YAAY,EAAE;oBACrB,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;iBACrC;aACJ;QACL,CAAC;KACJ,CAAC","sourcesContent":["import { isElementOfType } from '../../domUtils/isElementOfType';\nimport { isUnsafeUrl } from '../../domUtils/isUnsafeUrl';\nimport type { FormatHandler } from '../FormatHandler';\nimport type { LinkFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const linkFormatHandler: FormatHandler<LinkFormat> = {\n parse: (format, element) => {\n if (isElementOfType(element, 'a')) {\n const name = element.name;\n const href = element.getAttribute('href'); // Use getAttribute to get original HREF but not the resolved absolute url\n const target = element.target;\n const rel = element.rel;\n const id = element.id;\n const className = element.className;\n const title = element.title;\n\n if (name) {\n format.name = name;\n }\n\n if (href && !isUnsafeUrl(href)) {\n format.href = href;\n }\n\n if (target) {\n format.target = target;\n }\n\n if (id) {\n format.anchorId = id;\n }\n\n if (rel) {\n format.relationship = rel;\n }\n\n if (title) {\n format.anchorTitle = title;\n }\n\n if (className) {\n format.anchorClass = className;\n }\n }\n },\n apply: (format, element) => {\n if (isElementOfType(element, 'a') && (format.href || format.name)) {\n if (format.href && !isUnsafeUrl(format.href)) {\n element.href = format.href;\n }\n\n if (format.name) {\n element.name = format.name;\n }\n\n if (format.target) {\n element.target = format.target;\n }\n\n if (format.anchorId) {\n element.id = format.anchorId;\n }\n\n if (format.anchorClass) {\n element.className = format.anchorClass;\n }\n\n if (format.anchorTitle) {\n element.title = format.anchorTitle;\n }\n\n if (format.relationship) {\n element.rel = format.relationship;\n }\n }\n },\n};\n"]}