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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-dom/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EACH,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oCA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mC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC","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,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EACH,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE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BAAkB,EAAE,MAAM,gCAAgC,CAAC","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,58 @@
1
+ /**
2
+ * Check whether the given range of table cells can be merged without splitting existing spans.
3
+ * @param rows The table rows to check
4
+ * @param firstRow The first row index of the range
5
+ * @param firstCol The first column index of the range
6
+ * @param lastRow The last row index of the range
7
+ * @param lastCol The last column index of the range
8
+ */
9
+ export function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
10
+ var noSpanAbove = firstCol == lastCol ||
11
+ rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
12
+ var noSpanLeft = firstRow == lastRow ||
13
+ rows.every(function (row, rowIndex) {
14
+ return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
15
+ });
16
+ var noDifferentBelowSpan = rows[lastRow].cells
17
+ .map(function (_, colIndex) {
18
+ return colIndex >= firstCol && colIndex <= lastCol
19
+ ? getBelowSpanCount(rows, lastRow, colIndex)
20
+ : -1;
21
+ })
22
+ .every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
23
+ var noDifferentRightSpan = rows
24
+ .map(function (_, rowIndex) {
25
+ return rowIndex >= firstRow && rowIndex <= lastRow
26
+ ? getRightSpanCount(rows, rowIndex, lastCol)
27
+ : -1;
28
+ })
29
+ .every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
30
+ return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
31
+ }
32
+ function getBelowSpanCount(rows, rowIndex, colIndex) {
33
+ var _a, _b;
34
+ var spanCount = 0;
35
+ for (var row = rowIndex + 1; row < rows.length; row++) {
36
+ if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
37
+ spanCount++;
38
+ }
39
+ else {
40
+ break;
41
+ }
42
+ }
43
+ return spanCount;
44
+ }
45
+ function getRightSpanCount(rows, rowIndex, colIndex) {
46
+ var _a, _b, _c;
47
+ var spanCount = 0;
48
+ for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
49
+ if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
50
+ spanCount++;
51
+ }
52
+ else {
53
+ break;
54
+ }
55
+ }
56
+ return spanCount;
57
+ }
58
+ //# 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,MAAM,UAAU,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,KAA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AEnD,OAAO,WAAW,IAAI,UAAU,IAAI,oBAAoB,IAAI,oBAAoB,CAAC;AACrF,CAAC;AAED,SAAS,iBAAiB,CACtB,IAA6C,EAC7C,QAAgB,EAChB,QAAgB;;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,MAAA,MAAA,IAAI,CAAC,GAAG,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;YACvC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,iBAAiB,CACtB,IAA6C,EAC7C,QAAgB,EAChB,QAAgB;;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,MAAM,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"]}
@@ -1,5 +1,6 @@
1
1
  import { __assign } from "tslib";
2
2
  import { extractBorderValues } from '../../domUtils/style/borderValues';
3
+ import { canMergeCells } from './canMergeCells';
3
4
  import { getClosestAncestorBlockGroupIndex } from './getClosestAncestorBlockGroupIndex';
4
5
  import { getImageMetadata } from '../metadata/updateImageMetadata';
5
6
  import { getTableMetadata } from '../metadata/updateTableMetadata';
@@ -20,6 +21,7 @@ import { parseValueWithUnit } from '../../formatHandlers/utils/parseValueWithUni
20
21
  export function retrieveModelFormatState(model, pendingFormat, formatState, conflictSolution, domHelper, isInDarkMode, colorHandler) {
21
22
  if (conflictSolution === void 0) { conflictSolution = 'remove'; }
22
23
  var firstTableContext;
24
+ var lastTableContext;
23
25
  var firstBlock;
24
26
  var isFirst = true;
25
27
  var isFirstImage = true;
@@ -91,7 +93,7 @@ export function retrieveModelFormatState(model, pendingFormat, formatState, conf
91
93
  // Merge table format
92
94
  if (tableContext.table == table &&
93
95
  (tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)) {
94
- formatState.canMergeTableCell = true;
96
+ lastTableContext = tableContext;
95
97
  formatState.isMultilineSelection = true;
96
98
  }
97
99
  }
@@ -104,6 +106,9 @@ export function retrieveModelFormatState(model, pendingFormat, formatState, conf
104
106
  }, {
105
107
  includeListFormatHolder: 'never',
106
108
  });
109
+ if (firstTableContext && lastTableContext) {
110
+ formatState.canMergeTableCell = canMergeCells(firstTableContext.table.rows, firstTableContext.rowIndex, firstTableContext.colIndex, lastTableContext.rowIndex, lastTableContext.colIndex);
111
+ }
107
112
  if (formatState.fontSize) {
108
113
  formatState.fontSize = px2Pt(formatState.fontSize);
109
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/retrieveModelFormatState.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,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O,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 { 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,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAiBnF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,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,gBAA2D,CAAC;IAChE,IAAI,UAAiD,CAAC;IACtD,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,YAAY,GAAG,IAAI,CAAC;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G,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"]}
package/package.json CHANGED
@@ -3,9 +3,9 @@
3
3
  "description": "Content Model for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-types": "^9.59.0"
6
+ "roosterjs-content-model-types": "^9.61.0"
7
7
  },
8
- "version": "9.59.0",
8
+ "version": "9.61.0",
9
9
  "main": "./lib/index.js",
10
10
  "typings": "./lib/index.d.ts",
11
11
  "module": "./lib-mjs/index.js",