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.
- package/lib/domUtils/isUnsafeUrl.d.ts +10 -0
- package/lib/domUtils/isUnsafeUrl.js +32 -0
- package/lib/domUtils/isUnsafeUrl.js.map +1 -0
- package/lib/formatHandlers/segment/linkFormatHandler.js +3 -2
- package/lib/formatHandlers/segment/linkFormatHandler.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -4
- package/lib/index.js.map +1 -1
- package/lib/modelApi/editing/canMergeCells.d.ts +10 -0
- package/lib/modelApi/editing/canMergeCells.js +62 -0
- package/lib/modelApi/editing/canMergeCells.js.map +1 -0
- package/lib/modelApi/editing/retrieveModelFormatState.js +6 -1
- package/lib/modelApi/editing/retrieveModelFormatState.js.map +1 -1
- package/lib-amd/domUtils/isUnsafeUrl.d.ts +10 -0
- package/lib-amd/domUtils/isUnsafeUrl.js +34 -0
- package/lib-amd/domUtils/isUnsafeUrl.js.map +1 -0
- package/lib-amd/formatHandlers/segment/linkFormatHandler.js +3 -3
- package/lib-amd/formatHandlers/segment/linkFormatHandler.js.map +1 -1
- package/lib-amd/index.d.ts +2 -0
- package/lib-amd/index.js +4 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/modelApi/editing/canMergeCells.d.ts +10 -0
- package/lib-amd/modelApi/editing/canMergeCells.js +64 -0
- package/lib-amd/modelApi/editing/canMergeCells.js.map +1 -0
- package/lib-amd/modelApi/editing/retrieveModelFormatState.js +6 -2
- package/lib-amd/modelApi/editing/retrieveModelFormatState.js.map +1 -1
- package/lib-mjs/domUtils/isUnsafeUrl.d.ts +10 -0
- package/lib-mjs/domUtils/isUnsafeUrl.js +28 -0
- package/lib-mjs/domUtils/isUnsafeUrl.js.map +1 -0
- package/lib-mjs/formatHandlers/segment/linkFormatHandler.js +3 -2
- package/lib-mjs/formatHandlers/segment/linkFormatHandler.js.map +1 -1
- package/lib-mjs/index.d.ts +2 -0
- package/lib-mjs/index.js +2 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/modelApi/editing/canMergeCells.d.ts +10 -0
- package/lib-mjs/modelApi/editing/canMergeCells.js +58 -0
- package/lib-mjs/modelApi/editing/canMergeCells.js.map +1 -0
- package/lib-mjs/modelApi/editing/retrieveModelFormatState.js +6 -1
- package/lib-mjs/modelApi/editing/retrieveModelFormatState.js.map +1 -1
- package/package.json +2 -2
package/lib-amd/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-amd/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
define(["require", "exports", "./domToModel/domToContentModel", "./modelToDom/contentModelToDom", "./modelToText/contentModelToText", "./domToModel/processors/childProcessor", "./domToModel/processors/entityProcessor", "./domToModel/processors/tableProcessor", "./domToModel/processors/formatContainerProcessor", "./domToModel/utils/getRegularSelectionOffsets", "./domToModel/utils/parseFormat", "./domToModel/utils/areSameFormats", "./domToModel/utils/isBlockElement", "./domToModel/utils/buildSelectionMarker", "./modelApi/metadata/updateMetadata", "./domUtils/isNodeOfType", "./domUtils/isElementOfType", "./domUtils/getObjectKeys", "./domUtils/getSafeIdSelector", "./domUtils/toArray", "./domUtils/moveChildNodes", "./domUtils/wrap", "./domUtils/unwrap", "./domUtils/entityUtils", "./domUtils/reuseCachedElement", "./domUtils/isWhiteSpacePreserved", "./domUtils/normalizeRect", "./domUtils/scrollRectIntoView", "./domUtils/hiddenProperties/undeletableLink", "./modelApi/creators/createBr", "./modelApi/creators/createListItem", "./modelApi/creators/createFormatContainer", "./modelApi/creators/createParagraph", "./modelApi/creators/createSelectionMarker", "./modelApi/creators/createTable", "./modelApi/creators/createTableCell", "./modelApi/creators/createText", "./modelApi/creators/createImage", "./modelApi/creators/createContentModelDocument", "./modelApi/creators/createParagraphDecorator", "./modelApi/creators/createGeneralSegment", "./modelApi/creators/createGeneralBlock", "./modelApi/creators/createEntity", "./modelApi/creators/createDivider", "./modelApi/creators/createListLevel", "./modelApi/creators/createEmptyModel", "./modelApi/creators/createTableRow", "./modelApi/common/mutate", "./modelApi/common/addBlock", "./modelApi/common/addDecorators", "./modelApi/common/addDecorators", "./modelApi/common/addDecorators", "./modelApi/common/addTextSegment", "./modelApi/common/normalizeParagraph", "./modelApi/common/normalizeContentModel", "./modelApi/typeCheck/isGeneralSegment", "./modelApi/common/unwrapBlock", "./modelApi/common/addSegment", "./modelApi/common/isEmpty", "./modelApi/common/normalizeSegment", "./modelApi/common/mergeTextSegments", "./modelApi/common/normalizeSegmentFormat", "./modelApi/block/setParagraphNotImplicit", "./modelApi/block/copyFormat", "./modelApi/list/getOrderedListNumberStr", "./modelApi/list/getAutoListStyleType", "./formatHandlers/utils/parseValueWithUnit", "./formatHandlers/utils/borderKeys", "./formatHandlers/utils/color", "./domToModel/context/createDomToModelContext", "./modelToDom/context/createModelToDomContext", "./domUtils/style/isBold", "./domUtils/selection/getSelectionRootNode", "./domUtils/selection/getDOMInsertPointRect", "./domUtils/selection/trimModelForSelection", "./domUtils/event/eventUtils", "./domUtils/event/getNodePositionFromEvent", "./domUtils/style/borderValues", "./domUtils/stringUtil", "./domUtils/table/parseTableCells", "./domUtils/readFile", "./domUtils/retrieveDocumentMetadata", "./domUtils/style/transformColor", "./domUtils/style/normalizeFontFamily", "./domUtils/event/extractClipboardItems", "./domUtils/event/createPasteFragment", "./domUtils/event/cacheGetEventData", "./domUtils/hiddenProperties/paragraphMarker", "./domUtils/hiddenProperties/imageState", "./domUtils/getRangesByText", "./modelApi/typeCheck/isBlockGroupOfType", "./modelApi/selection/iterateSelections", "./modelApi/selection/collectSelections", "./modelApi/selection/getSelectedCells", "./modelApi/selection/hasSelectionInBlock", "./modelApi/selection/hasSelectionInSegment", "./modelApi/selection/hasSelectionInBlockGroup", "./modelApi/selection/setSelection", "./modelApi/editing/cloneModel", "./modelApi/editing/mergeModel", "./modelApi/editing/deleteSelection", "./modelApi/editing/deleteSegment", "./modelApi/editing/deleteBlock", "./modelApi/editing/applyTableFormat", "./modelApi/editing/normalizeTable", "./modelApi/editing/setTableCellBackgroundColor", "./modelApi/editing/retrieveModelFormatState", "./modelApi/editing/getListStyleTypeFromString", "./modelApi/editing/getSegmentTextFormat", "./modelApi/editing/getClosestAncestorBlockGroupIndex", "./modelApi/editing/runEditSteps", "./modelApi/metadata/updateImageMetadata", "./modelApi/metadata/updateTableCellMetadata", "./modelApi/metadata/updateTableMetadata", "./modelApi/metadata/updateListMetadata", "./constants/ChangeSource", "./constants/BulletListType", "./constants/NumberingListType", "./constants/TableBorderFormat", "./constants/OrderedListStyleMap", "./constants/UnorderedListStyleMap", "./constants/EmptySegmentFormat"], function (require, exports, domToContentModel_1, contentModelToDom_1, contentModelToText_1, childProcessor_1, entityProcessor_1, tableProcessor_1, formatContainerProcessor_1, getRegularSelectionOffsets_1, parseFormat_1, areSameFormats_1, isBlockElement_1, buildSelectionMarker_1, updateMetadata_1, isNodeOfType_1, isElementOfType_1, getObjectKeys_1, getSafeIdSelector_1, toArray_1, moveChildNodes_1, wrap_1, unwrap_1, entityUtils_1, reuseCachedElement_1, isWhiteSpacePreserved_1, normalizeRect_1, scrollRectIntoView_1, undeletableLink_1, createBr_1, createListItem_1, createFormatContainer_1, createParagraph_1, createSelectionMarker_1, createTable_1, createTableCell_1, createText_1, createImage_1, createContentModelDocument_1, createParagraphDecorator_1, createGeneralSegment_1, createGeneralBlock_1, createEntity_1, createDivider_1, createListLevel_1, createEmptyModel_1, createTableRow_1, mutate_1, addBlock_1, addDecorators_1, addDecorators_2, addDecorators_3, addTextSegment_1, normalizeParagraph_1, normalizeContentModel_1, isGeneralSegment_1, unwrapBlock_1, addSegment_1, isEmpty_1, normalizeSegment_1, mergeTextSegments_1, normalizeSegmentFormat_1, setParagraphNotImplicit_1, copyFormat_1, getOrderedListNumberStr_1, getAutoListStyleType_1, parseValueWithUnit_1, borderKeys_1, color_1, createDomToModelContext_1, createModelToDomContext_1, isBold_1, getSelectionRootNode_1, getDOMInsertPointRect_1, trimModelForSelection_1, eventUtils_1, getNodePositionFromEvent_1, borderValues_1, stringUtil_1, parseTableCells_1, readFile_1, retrieveDocumentMetadata_1, transformColor_1, normalizeFontFamily_1, extractClipboardItems_1, createPasteFragment_1, cacheGetEventData_1, paragraphMarker_1, imageState_1, getRangesByText_1, isBlockGroupOfType_1, iterateSelections_1, collectSelections_1, getSelectedCells_1, hasSelectionInBlock_1, hasSelectionInSegment_1, hasSelectionInBlockGroup_1, setSelection_1, cloneModel_1, mergeModel_1, deleteSelection_1, deleteSegment_1, deleteBlock_1, applyTableFormat_1, normalizeTable_1, setTableCellBackgroundColor_1, retrieveModelFormatState_1, getListStyleTypeFromString_1, getSegmentTextFormat_1, getClosestAncestorBlockGroupIndex_1, runEditSteps_1, updateImageMetadata_1, updateTableCellMetadata_1, updateTableMetadata_1, updateListMetadata_1, ChangeSource_1, BulletListType_1, NumberingListType_1, TableBorderFormat_1, OrderedListStyleMap_1, UnorderedListStyleMap_1, EmptySegmentFormat_1) {
|
|
1
|
+
define(["require", "exports", "./domToModel/domToContentModel", "./modelToDom/contentModelToDom", "./modelToText/contentModelToText", "./domToModel/processors/childProcessor", "./domToModel/processors/entityProcessor", "./domToModel/processors/tableProcessor", "./domToModel/processors/formatContainerProcessor", "./domToModel/utils/getRegularSelectionOffsets", "./domToModel/utils/parseFormat", "./domToModel/utils/areSameFormats", "./domToModel/utils/isBlockElement", "./domToModel/utils/buildSelectionMarker", "./modelApi/metadata/updateMetadata", "./domUtils/isNodeOfType", "./domUtils/isElementOfType", "./domUtils/isUnsafeUrl", "./domUtils/getObjectKeys", "./domUtils/getSafeIdSelector", "./domUtils/toArray", "./domUtils/moveChildNodes", "./domUtils/wrap", "./domUtils/unwrap", "./domUtils/entityUtils", "./domUtils/reuseCachedElement", "./domUtils/isWhiteSpacePreserved", "./domUtils/normalizeRect", "./domUtils/scrollRectIntoView", "./domUtils/hiddenProperties/undeletableLink", "./modelApi/creators/createBr", "./modelApi/creators/createListItem", "./modelApi/creators/createFormatContainer", "./modelApi/creators/createParagraph", "./modelApi/creators/createSelectionMarker", "./modelApi/creators/createTable", "./modelApi/creators/createTableCell", "./modelApi/creators/createText", "./modelApi/creators/createImage", "./modelApi/creators/createContentModelDocument", "./modelApi/creators/createParagraphDecorator", "./modelApi/creators/createGeneralSegment", "./modelApi/creators/createGeneralBlock", "./modelApi/creators/createEntity", "./modelApi/creators/createDivider", "./modelApi/creators/createListLevel", "./modelApi/creators/createEmptyModel", "./modelApi/creators/createTableRow", "./modelApi/common/mutate", "./modelApi/common/addBlock", "./modelApi/common/addDecorators", "./modelApi/common/addDecorators", "./modelApi/common/addDecorators", "./modelApi/common/addTextSegment", "./modelApi/common/normalizeParagraph", "./modelApi/common/normalizeContentModel", "./modelApi/typeCheck/isGeneralSegment", "./modelApi/common/unwrapBlock", "./modelApi/common/addSegment", "./modelApi/common/isEmpty", "./modelApi/common/normalizeSegment", "./modelApi/common/mergeTextSegments", "./modelApi/common/normalizeSegmentFormat", "./modelApi/block/setParagraphNotImplicit", "./modelApi/block/copyFormat", "./modelApi/list/getOrderedListNumberStr", "./modelApi/list/getAutoListStyleType", "./formatHandlers/utils/parseValueWithUnit", "./formatHandlers/utils/borderKeys", "./formatHandlers/utils/color", "./domToModel/context/createDomToModelContext", "./modelToDom/context/createModelToDomContext", "./domUtils/style/isBold", "./domUtils/selection/getSelectionRootNode", "./domUtils/selection/getDOMInsertPointRect", "./domUtils/selection/trimModelForSelection", "./domUtils/event/eventUtils", "./domUtils/event/getNodePositionFromEvent", "./domUtils/style/borderValues", "./domUtils/stringUtil", "./domUtils/table/parseTableCells", "./domUtils/readFile", "./domUtils/retrieveDocumentMetadata", "./domUtils/style/transformColor", "./domUtils/style/normalizeFontFamily", "./domUtils/event/extractClipboardItems", "./domUtils/event/createPasteFragment", "./domUtils/event/cacheGetEventData", "./domUtils/hiddenProperties/paragraphMarker", "./domUtils/hiddenProperties/imageState", "./domUtils/getRangesByText", "./modelApi/typeCheck/isBlockGroupOfType", "./modelApi/selection/iterateSelections", "./modelApi/selection/collectSelections", "./modelApi/selection/getSelectedCells", "./modelApi/selection/hasSelectionInBlock", "./modelApi/selection/hasSelectionInSegment", "./modelApi/selection/hasSelectionInBlockGroup", "./modelApi/selection/setSelection", "./modelApi/editing/cloneModel", "./modelApi/editing/canMergeCells", "./modelApi/editing/mergeModel", "./modelApi/editing/deleteSelection", "./modelApi/editing/deleteSegment", "./modelApi/editing/deleteBlock", "./modelApi/editing/applyTableFormat", "./modelApi/editing/normalizeTable", "./modelApi/editing/setTableCellBackgroundColor", "./modelApi/editing/retrieveModelFormatState", "./modelApi/editing/getListStyleTypeFromString", "./modelApi/editing/getSegmentTextFormat", "./modelApi/editing/getClosestAncestorBlockGroupIndex", "./modelApi/editing/runEditSteps", "./modelApi/metadata/updateImageMetadata", "./modelApi/metadata/updateTableCellMetadata", "./modelApi/metadata/updateTableMetadata", "./modelApi/metadata/updateListMetadata", "./constants/ChangeSource", "./constants/BulletListType", "./constants/NumberingListType", "./constants/TableBorderFormat", "./constants/OrderedListStyleMap", "./constants/UnorderedListStyleMap", "./constants/EmptySegmentFormat"], function (require, exports, domToContentModel_1, contentModelToDom_1, contentModelToText_1, childProcessor_1, entityProcessor_1, tableProcessor_1, formatContainerProcessor_1, getRegularSelectionOffsets_1, parseFormat_1, areSameFormats_1, isBlockElement_1, buildSelectionMarker_1, updateMetadata_1, isNodeOfType_1, isElementOfType_1, isUnsafeUrl_1, getObjectKeys_1, getSafeIdSelector_1, toArray_1, moveChildNodes_1, wrap_1, unwrap_1, entityUtils_1, reuseCachedElement_1, isWhiteSpacePreserved_1, normalizeRect_1, scrollRectIntoView_1, undeletableLink_1, createBr_1, createListItem_1, createFormatContainer_1, createParagraph_1, createSelectionMarker_1, createTable_1, createTableCell_1, createText_1, createImage_1, createContentModelDocument_1, createParagraphDecorator_1, createGeneralSegment_1, createGeneralBlock_1, createEntity_1, createDivider_1, createListLevel_1, createEmptyModel_1, createTableRow_1, mutate_1, addBlock_1, addDecorators_1, addDecorators_2, addDecorators_3, addTextSegment_1, normalizeParagraph_1, normalizeContentModel_1, isGeneralSegment_1, unwrapBlock_1, addSegment_1, isEmpty_1, normalizeSegment_1, mergeTextSegments_1, normalizeSegmentFormat_1, setParagraphNotImplicit_1, copyFormat_1, getOrderedListNumberStr_1, getAutoListStyleType_1, parseValueWithUnit_1, borderKeys_1, color_1, createDomToModelContext_1, createModelToDomContext_1, isBold_1, getSelectionRootNode_1, getDOMInsertPointRect_1, trimModelForSelection_1, eventUtils_1, getNodePositionFromEvent_1, borderValues_1, stringUtil_1, parseTableCells_1, readFile_1, retrieveDocumentMetadata_1, transformColor_1, normalizeFontFamily_1, extractClipboardItems_1, createPasteFragment_1, cacheGetEventData_1, paragraphMarker_1, imageState_1, getRangesByText_1, isBlockGroupOfType_1, iterateSelections_1, collectSelections_1, getSelectedCells_1, hasSelectionInBlock_1, hasSelectionInSegment_1, hasSelectionInBlockGroup_1, setSelection_1, cloneModel_1, canMergeCells_1, mergeModel_1, deleteSelection_1, deleteSegment_1, deleteBlock_1, applyTableFormat_1, normalizeTable_1, setTableCellBackgroundColor_1, retrieveModelFormatState_1, getListStyleTypeFromString_1, getSegmentTextFormat_1, getClosestAncestorBlockGroupIndex_1, runEditSteps_1, updateImageMetadata_1, updateTableCellMetadata_1, updateTableMetadata_1, updateListMetadata_1, ChangeSource_1, BulletListType_1, NumberingListType_1, TableBorderFormat_1, OrderedListStyleMap_1, UnorderedListStyleMap_1, EmptySegmentFormat_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
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 = 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 = 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 = 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.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 = 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 = 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 = 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;
|
|
5
5
|
Object.defineProperty(exports, "domToContentModel", { enumerable: true, get: function () { return domToContentModel_1.domToContentModel; } });
|
|
6
6
|
Object.defineProperty(exports, "contentModelToDom", { enumerable: true, get: function () { return contentModelToDom_1.contentModelToDom; } });
|
|
7
7
|
Object.defineProperty(exports, "contentModelToText", { enumerable: true, get: function () { return contentModelToText_1.contentModelToText; } });
|
|
@@ -21,6 +21,7 @@ define(["require", "exports", "./domToModel/domToContentModel", "./modelToDom/co
|
|
|
21
21
|
Object.defineProperty(exports, "hasMetadata", { enumerable: true, get: function () { return updateMetadata_1.hasMetadata; } });
|
|
22
22
|
Object.defineProperty(exports, "isNodeOfType", { enumerable: true, get: function () { return isNodeOfType_1.isNodeOfType; } });
|
|
23
23
|
Object.defineProperty(exports, "isElementOfType", { enumerable: true, get: function () { return isElementOfType_1.isElementOfType; } });
|
|
24
|
+
Object.defineProperty(exports, "isUnsafeUrl", { enumerable: true, get: function () { return isUnsafeUrl_1.isUnsafeUrl; } });
|
|
24
25
|
Object.defineProperty(exports, "getObjectKeys", { enumerable: true, get: function () { return getObjectKeys_1.getObjectKeys; } });
|
|
25
26
|
Object.defineProperty(exports, "getSafeIdSelector", { enumerable: true, get: function () { return getSafeIdSelector_1.getSafeIdSelector; } });
|
|
26
27
|
Object.defineProperty(exports, "toArray", { enumerable: true, get: function () { return toArray_1.toArray; } });
|
|
@@ -140,6 +141,7 @@ define(["require", "exports", "./domToModel/domToContentModel", "./modelToDom/co
|
|
|
140
141
|
Object.defineProperty(exports, "setSelection", { enumerable: true, get: function () { return setSelection_1.setSelection; } });
|
|
141
142
|
Object.defineProperty(exports, "cloneModel", { enumerable: true, get: function () { return cloneModel_1.cloneModel; } });
|
|
142
143
|
Object.defineProperty(exports, "cloneModelForPaste", { enumerable: true, get: function () { return cloneModel_1.cloneModelForPaste; } });
|
|
144
|
+
Object.defineProperty(exports, "canMergeCells", { enumerable: true, get: function () { return canMergeCells_1.canMergeCells; } });
|
|
143
145
|
Object.defineProperty(exports, "mergeModel", { enumerable: true, get: function () { return mergeModel_1.mergeModel; } });
|
|
144
146
|
Object.defineProperty(exports, "deleteSelection", { enumerable: true, get: function () { return deleteSelection_1.deleteSelection; } });
|
|
145
147
|
Object.defineProperty(exports, "deleteSegment", { enumerable: true, get: function () { return deleteSegment_1.deleteSegment; } });
|
package/lib-amd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-dom/lib/index.ts"],"names":[],"mappings":";;;;IAAS,sHAAA,iBAAiB,OAAA;IACjB,sHAAA,iBAAiB,OAAA;IACjB,wHAAA,kBAAkB,OAAA;IAGvB,gHAAA,cAAc,OAAA;IACd,wHAAA,sBAAsB,OAAA;IACtB,kHAAA,gBAAgB,OAAA;IAEX,kHAAA,eAAe,OAAA;IACf,gHAAA,cAAc,OAAA;IACd,oIAAA,wBAAwB,OAAA;IACxB,wIAAA,0BAA0B,OAAA;IAC1B,0GAAA,WAAW,OAAA;IACX,gHAAA,cAAc,OAAA;IACd,gHAAA,cAAc,OAAA;IACd,4HAAA,oBAAoB,OAAA;IAEpB,gHAAA,cAAc,OAAA;IAAE,6GAAA,WAAW,OAAA;IAAE,6GAAA,WAAW,OAAA;IACxC,4GAAA,YAAY,O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OAAA;IAEf,0HAAA,mBAAmB,OAAA;IAAE,uHAAA,gBAAgB,OAAA;IAE1C,wHAAA,kBAAkB,OAAA;IAClB,qHAAA,eAAe,OAAA;IACf,4HAAA,sBAAsB,OAAA;IAGjB,4GAAA,YAAY,OAAA;IACZ,gHAAA,cAAc,OAAA;IACd,sHAAA,iBAAiB,OAAA;IACjB,sHAAA,iBAAiB,OAAA;IACjB,0HAAA,mBAAmB,OAAA;IACnB,8HAAA,qBAAqB,OAAA;IACrB,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":";;;;IAAS,sHAAA,iBAAiB,OAAA;IACjB,sHAAA,iBAAiB,OAAA;IACjB,wHAAA,kBAAkB,OAAA;IAGvB,gHAAA,cAAc,OAAA;IACd,wHAAA,sBAAsB,OAAA;IACtB,kHAAA,gBAAgB,OAAA;IAEX,kHAAA,eAAe,OAAA;IACf,gHAAA,cAAc,OAAA;IACd,oIAAA,wBAAwB,OAAA;IACxB,wIAAA,0BAA0B,OAAA;IAC1B,0GAAA,WAAW,OAAA;IACX,gHAAA,cAAc,OAAA;IACd,gHAAA,cAAc,OAAA;IACd,4HAAA,oBAAoB,OAAA;IAEpB,gHAAA,cAAc,OAAA;IAAE,6GAAA,WAAW,OAAA;IAAE,6GAAA,WAAW,OAAA;IACxC,4GAAA,YAAY,OAAA;IACZ,kHAAA,eAAe,OAAA;IACf,0GAAA,WAAW,OAAA;IACX,8GAAA,aAAa,OAAA;IACb,sHAAA,iBAAiB,OAAA;I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AA;IAE1C,wHAAA,kBAAkB,OAAA;IAClB,qHAAA,eAAe,OAAA;IACf,4HAAA,sBAAsB,OAAA;IAGjB,4GAAA,YAAY,OAAA;IACZ,gHAAA,cAAc,OAAA;IACd,sHAAA,iBAAiB,OAAA;IACjB,sHAAA,iBAAiB,OAAA;IACjB,0HAAA,mBAAmB,OAAA;IACnB,8HAAA,qBAAqB,OAAA;IACrB,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,64 @@
|
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.canMergeCells = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Check whether the given range of table cells can be merged without splitting existing spans.
|
|
7
|
+
* @param rows The table rows to check
|
|
8
|
+
* @param firstRow The first row index of the range
|
|
9
|
+
* @param firstCol The first column index of the range
|
|
10
|
+
* @param lastRow The last row index of the range
|
|
11
|
+
* @param lastCol The last column index of the range
|
|
12
|
+
*/
|
|
13
|
+
function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
|
|
14
|
+
var noSpanAbove = firstCol == lastCol ||
|
|
15
|
+
rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
|
|
16
|
+
var noSpanLeft = firstRow == lastRow ||
|
|
17
|
+
rows.every(function (row, rowIndex) {
|
|
18
|
+
return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
|
|
19
|
+
});
|
|
20
|
+
var noDifferentBelowSpan = rows[lastRow].cells
|
|
21
|
+
.map(function (_, colIndex) {
|
|
22
|
+
return colIndex >= firstCol && colIndex <= lastCol
|
|
23
|
+
? getBelowSpanCount(rows, lastRow, colIndex)
|
|
24
|
+
: -1;
|
|
25
|
+
})
|
|
26
|
+
.every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
|
|
27
|
+
var noDifferentRightSpan = rows
|
|
28
|
+
.map(function (_, rowIndex) {
|
|
29
|
+
return rowIndex >= firstRow && rowIndex <= lastRow
|
|
30
|
+
? getRightSpanCount(rows, rowIndex, lastCol)
|
|
31
|
+
: -1;
|
|
32
|
+
})
|
|
33
|
+
.every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
|
|
34
|
+
return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
|
|
35
|
+
}
|
|
36
|
+
exports.canMergeCells = canMergeCells;
|
|
37
|
+
function getBelowSpanCount(rows, rowIndex, colIndex) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
var spanCount = 0;
|
|
40
|
+
for (var row = rowIndex + 1; row < rows.length; row++) {
|
|
41
|
+
if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
42
|
+
spanCount++;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return spanCount;
|
|
49
|
+
}
|
|
50
|
+
function getRightSpanCount(rows, rowIndex, colIndex) {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
var spanCount = 0;
|
|
53
|
+
for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
|
|
54
|
+
if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
55
|
+
spanCount++;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return spanCount;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
//# 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":";;;;IAEA;;;;;;;OAOG;IACH,SAAgB,aAAa,CACzB,IAA6C,EAC7C,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,OAAe;QAEf,IAAM,WAAW,GACb,QAAQ,IAAI,OAAO;YACnB,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;QACN,IAAM,UAAU,GACZ,QAAQ,IAAI,OAAO;YACnB,IAAI,CAAC,KAAK,CACN,UAAC,GAAG,EAAE,QAAQ;gBACV,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,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AAE;YACnD,IAAI,MAAA,MAAA,IAAI,CAAC,GAAG,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;gBACvC,SAAS,EAAE,CAAC;aACf;iBAAM;gBACH,MAAM;aACT;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,SAAS,iBAAiB,CACtB,IAA6C,EAC7C,QAAgB,EAChB,QAAgB;;QAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,MAAM,CAAA,EAAE,GAAG,EAAE,EAAE;YACpE,IAAI,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE;gBACtC,SAAS,EAAE,CAAC;aACf;iBAAM;gBACH,MAAM;aACT;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,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,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "../../domUtils/style/borderValues", "./getClosestAncestorBlockGroupIndex", "../metadata/updateImageMetadata", "../metadata/updateTableMetadata", "../../domUtils/style/isBold", "../selection/iterateSelections", "../../formatHandlers/utils/parseValueWithUnit"], function (require, exports, tslib_1, borderValues_1, getClosestAncestorBlockGroupIndex_1, updateImageMetadata_1, updateTableMetadata_1, isBold_1, iterateSelections_1, parseValueWithUnit_1) {
|
|
1
|
+
define(["require", "exports", "tslib", "../../domUtils/style/borderValues", "./canMergeCells", "./getClosestAncestorBlockGroupIndex", "../metadata/updateImageMetadata", "../metadata/updateTableMetadata", "../../domUtils/style/isBold", "../selection/iterateSelections", "../../formatHandlers/utils/parseValueWithUnit"], function (require, exports, tslib_1, borderValues_1, canMergeCells_1, getClosestAncestorBlockGroupIndex_1, updateImageMetadata_1, updateTableMetadata_1, isBold_1, iterateSelections_1, parseValueWithUnit_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.retrieveModelFormatState = void 0;
|
|
@@ -16,6 +16,7 @@ define(["require", "exports", "tslib", "../../domUtils/style/borderValues", "./g
|
|
|
16
16
|
function retrieveModelFormatState(model, pendingFormat, formatState, conflictSolution, domHelper, isInDarkMode, colorHandler) {
|
|
17
17
|
if (conflictSolution === void 0) { conflictSolution = 'remove'; }
|
|
18
18
|
var firstTableContext;
|
|
19
|
+
var lastTableContext;
|
|
19
20
|
var firstBlock;
|
|
20
21
|
var isFirst = true;
|
|
21
22
|
var isFirstImage = true;
|
|
@@ -87,7 +88,7 @@ define(["require", "exports", "tslib", "../../domUtils/style/borderValues", "./g
|
|
|
87
88
|
// Merge table format
|
|
88
89
|
if (tableContext.table == table &&
|
|
89
90
|
(tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)) {
|
|
90
|
-
|
|
91
|
+
lastTableContext = tableContext;
|
|
91
92
|
formatState.isMultilineSelection = true;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -100,6 +101,9 @@ define(["require", "exports", "tslib", "../../domUtils/style/borderValues", "./g
|
|
|
100
101
|
}, {
|
|
101
102
|
includeListFormatHolder: 'never',
|
|
102
103
|
});
|
|
104
|
+
if (firstTableContext && lastTableContext) {
|
|
105
|
+
formatState.canMergeTableCell = (0, canMergeCells_1.canMergeCells)(firstTableContext.table.rows, firstTableContext.rowIndex, firstTableContext.colIndex, lastTableContext.rowIndex, lastTableContext.colIndex);
|
|
106
|
+
}
|
|
103
107
|
if (formatState.fontSize) {
|
|
104
108
|
formatState.fontSize = px2Pt(formatState.fontSize);
|
|
105
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieveModelFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/modelApi/editing/retrieveModelFormatState.ts"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CAAC;oBACnB,MAAM;gBACV,KAAK,WAAW;oBACZ,MAAM;gBACV,KAAK,gBAAgB;oBACjB,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;wBAChC,MAAM,CAAC,GAAG,CAAY,GAAG,UAAU,CAAC;qBACxC;yBAAM;wBACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;qBACtB;oBACD,MAAM;aACb;SACJ;IACL,CAAC;IAED,SAAS,KAAK,CAAC,EAAU;QACrB,IAAI,EAAE,EAAE;YACJ,IAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;gBACzC,8HAA8H;gBAC9H,wBAAwB;gBACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;aAC9D;SACJ;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAED,SAAS,oBAAoB,CAAC,MAAiC;QAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IAC1E,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":";;;;IAwBA;;;;;;;;;;OAUG;IACH,SAAgB,wBAAwB,CACpC,KAAmC,EACnC,aAA+C,EAC/C,WAAoC,EACpC,gBAAmD,EACnD,SAAqB,EACrB,YAAsB,EACtB,YAA+B;QAH/B,iCAAA,EAAA,2BAAmD;QAKnD,IAAI,iBAA4D,CAAC;QACjE,IAAI,gBAA2D,CAAC;QAChE,IAAI,UAAiD,CAAC;QACtD,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,YAAY,GAAG,IAAI,CAAC;QACxB,IAAI,cAAc,GAAG,IAAI,CAAC;QAC1B,IAAI,eAAe,GAA0C,SAAS,CAAC;QAEvE,IAAM,WAAW,6BAAQ,KAAK,CAAC,MAAM,CAAE,CAAC;QAExC,OAAO,WAAW,CAAC,MAAM,CAAC;QAC1B,OAAO,WAAW,CAAC,SAAS,CAAC;QAC7B,OAAO,WAAW,CAAC,UAAU,CAAC;QAE9B,IAAA,qCAAiB,EACb,KAAK,EACL,UAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,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AC,CAAC;YAC/B,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;gBACzC,8HAA8H;gBAC9H,wBAAwB;gBACxB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;aAC9D;SACJ;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAED,SAAS,oBAAoB,CAAC,MAAiC;QAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IAC1E,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	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,28 @@
|
|
|
1
|
+
var UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];
|
|
2
|
+
var IgnoredCharacters = /[\t\n\r]/g;
|
|
3
|
+
var MaxControlCharCode = 0x20;
|
|
4
|
+
/**
|
|
5
|
+
* Check whether the given URL uses a protocol that can execute script, such as "javascript:"
|
|
6
|
+
* @param url The URL to check
|
|
7
|
+
* @returns True if the URL can execute script when navigated to, otherwise false
|
|
8
|
+
* @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
|
|
9
|
+
* character or space before they resolve its protocol. Those characters must be removed before the
|
|
10
|
+
* protocol is checked here, otherwise a value such as "java	script:" or "javascr ipt:" would
|
|
11
|
+
* be treated as safe but still executed by the browser.
|
|
12
|
+
*/
|
|
13
|
+
export function isUnsafeUrl(url) {
|
|
14
|
+
if (!url) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
var normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();
|
|
18
|
+
var colonIndex = normalizedUrl.indexOf(':');
|
|
19
|
+
return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;
|
|
20
|
+
}
|
|
21
|
+
function trimControlCharacters(url) {
|
|
22
|
+
var start = 0;
|
|
23
|
+
while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {
|
|
24
|
+
start++;
|
|
25
|
+
}
|
|
26
|
+
return url.substring(start);
|
|
27
|
+
}
|
|
28
|
+
//# 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,MAAM,UAAU,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;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	script:\" or \"javascr 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,5 @@
|
|
|
1
1
|
import { isElementOfType } from '../../domUtils/isElementOfType';
|
|
2
|
+
import { isUnsafeUrl } from '../../domUtils/isUnsafeUrl';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
@@ -15,7 +16,7 @@ export var linkFormatHandler = {
|
|
|
15
16
|
if (name_1) {
|
|
16
17
|
format.name = name_1;
|
|
17
18
|
}
|
|
18
|
-
if (href) {
|
|
19
|
+
if (href && !isUnsafeUrl(href)) {
|
|
19
20
|
format.href = href;
|
|
20
21
|
}
|
|
21
22
|
if (target) {
|
|
@@ -37,7 +38,7 @@ export var linkFormatHandler = {
|
|
|
37
38
|
},
|
|
38
39
|
apply: function (format, element) {
|
|
39
40
|
if (isElementOfType(element, 'a') && (format.href || format.name)) {
|
|
40
|
-
if (format.href) {
|
|
41
|
+
if (format.href && !isUnsafeUrl(format.href)) {
|
|
41
42
|
element.href = format.href;
|
|
42
43
|
}
|
|
43
44
|
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,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"linkFormatHandler.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-dom/lib/formatHandlers/segment/linkFormatHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIzD;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAA8B;IACxD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,eAAe,CAAC,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,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,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-mjs/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-mjs/index.js
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';
|