roosterjs-content-model-core 0.20.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/LICENSE +25 -0
- package/README.md +262 -0
- package/lib/constants/ChangeSource.d.ts +59 -0
- package/lib/constants/ChangeSource.js +63 -0
- package/lib/constants/ChangeSource.js.map +1 -0
- package/lib/coreApi/createContentModel.d.ts +9 -0
- package/lib/coreApi/createContentModel.js +40 -0
- package/lib/coreApi/createContentModel.js.map +1 -0
- package/lib/coreApi/createEditorContext.d.ts +6 -0
- package/lib/coreApi/createEditorContext.js +38 -0
- package/lib/coreApi/createEditorContext.js.map +1 -0
- package/lib/coreApi/formatContentModel.d.ts +12 -0
- package/lib/coreApi/formatContentModel.js +128 -0
- package/lib/coreApi/formatContentModel.js.map +1 -0
- package/lib/coreApi/getDOMSelection.d.ts +5 -0
- package/lib/coreApi/getDOMSelection.js +41 -0
- package/lib/coreApi/getDOMSelection.js.map +1 -0
- package/lib/coreApi/setContentModel.d.ts +9 -0
- package/lib/coreApi/setContentModel.js +33 -0
- package/lib/coreApi/setContentModel.js.map +1 -0
- package/lib/coreApi/setDOMSelection.d.ts +5 -0
- package/lib/coreApi/setDOMSelection.js +41 -0
- package/lib/coreApi/setDOMSelection.js.map +1 -0
- package/lib/coreApi/switchShadowEdit.d.ts +8 -0
- package/lib/coreApi/switchShadowEdit.js +54 -0
- package/lib/coreApi/switchShadowEdit.js.map +1 -0
- package/lib/corePlugin/ContentModelCachePlugin.d.ts +53 -0
- package/lib/corePlugin/ContentModelCachePlugin.js +169 -0
- package/lib/corePlugin/ContentModelCachePlugin.js.map +1 -0
- package/lib/corePlugin/ContentModelCopyPastePlugin.d.ts +46 -0
- package/lib/corePlugin/ContentModelCopyPastePlugin.js +233 -0
- package/lib/corePlugin/ContentModelCopyPastePlugin.js.map +1 -0
- package/lib/corePlugin/ContentModelFormatPlugin.d.ts +59 -0
- package/lib/corePlugin/ContentModelFormatPlugin.js +147 -0
- package/lib/corePlugin/ContentModelFormatPlugin.js.map +1 -0
- package/lib/corePlugin/ContentModelTypeInContainerPlugin.d.ts +23 -0
- package/lib/corePlugin/ContentModelTypeInContainerPlugin.js +32 -0
- package/lib/corePlugin/ContentModelTypeInContainerPlugin.js.map +1 -0
- package/lib/corePlugin/utils/addRangeToSelection.d.ts +4 -0
- package/lib/corePlugin/utils/addRangeToSelection.js +16 -0
- package/lib/corePlugin/utils/addRangeToSelection.js.map +1 -0
- package/lib/corePlugin/utils/applyDefaultFormat.d.ts +9 -0
- package/lib/corePlugin/utils/applyDefaultFormat.js +79 -0
- package/lib/corePlugin/utils/applyDefaultFormat.js.map +1 -0
- package/lib/corePlugin/utils/applyPendingFormat.d.ts +8 -0
- package/lib/corePlugin/utils/applyPendingFormat.js +51 -0
- package/lib/corePlugin/utils/applyPendingFormat.js.map +1 -0
- package/lib/corePlugin/utils/areSameSelection.d.ts +6 -0
- package/lib/corePlugin/utils/areSameSelection.js +36 -0
- package/lib/corePlugin/utils/areSameSelection.js.map +1 -0
- package/lib/corePlugin/utils/contentModelDomIndexer.d.ts +6 -0
- package/lib/corePlugin/utils/contentModelDomIndexer.js +190 -0
- package/lib/corePlugin/utils/contentModelDomIndexer.js.map +1 -0
- package/lib/editor/createContentModelEditorCore.d.ts +6 -0
- package/lib/editor/createContentModelEditorCore.js +50 -0
- package/lib/editor/createContentModelEditorCore.js.map +1 -0
- package/lib/editor/promoteToContentModelEditorCore.d.ts +8 -0
- package/lib/editor/promoteToContentModelEditorCore.js +72 -0
- package/lib/editor/promoteToContentModelEditorCore.js.map +1 -0
- package/lib/index.d.ts +29 -0
- package/lib/index.js +71 -0
- package/lib/index.js.map +1 -0
- package/lib/metadata/definitionCreators.d.ts +48 -0
- package/lib/metadata/definitionCreators.js +95 -0
- package/lib/metadata/definitionCreators.js.map +1 -0
- package/lib/metadata/updateImageMetadata.d.ts +7 -0
- package/lib/metadata/updateImageMetadata.js +28 -0
- package/lib/metadata/updateImageMetadata.js.map +1 -0
- package/lib/metadata/updateListMetadata.d.ts +15 -0
- package/lib/metadata/updateListMetadata.js +181 -0
- package/lib/metadata/updateListMetadata.js.map +1 -0
- package/lib/metadata/updateTableCellMetadata.d.ts +7 -0
- package/lib/metadata/updateTableCellMetadata.js +20 -0
- package/lib/metadata/updateTableCellMetadata.js.map +1 -0
- package/lib/metadata/updateTableMetadata.d.ts +7 -0
- package/lib/metadata/updateTableMetadata.js +32 -0
- package/lib/metadata/updateTableMetadata.js.map +1 -0
- package/lib/modelApi/edit/deleteExpandedSelection.d.ts +7 -0
- package/lib/modelApi/edit/deleteExpandedSelection.js +99 -0
- package/lib/modelApi/edit/deleteExpandedSelection.js.map +1 -0
- package/lib/modelApi/edit/deleteSingleChar.d.ts +4 -0
- package/lib/modelApi/edit/deleteSingleChar.js +36 -0
- package/lib/modelApi/edit/deleteSingleChar.js.map +1 -0
- package/lib/override/tablePreProcessor.d.ts +5 -0
- package/lib/override/tablePreProcessor.js +25 -0
- package/lib/override/tablePreProcessor.js.map +1 -0
- package/lib/publicApi/domUtils/borderValues.d.ts +13 -0
- package/lib/publicApi/domUtils/borderValues.js +48 -0
- package/lib/publicApi/domUtils/borderValues.js.map +1 -0
- package/lib/publicApi/domUtils/eventUtils.d.ts +13 -0
- package/lib/publicApi/domUtils/eventUtils.js +29 -0
- package/lib/publicApi/domUtils/eventUtils.js.map +1 -0
- package/lib/publicApi/domUtils/stringUtil.d.ts +18 -0
- package/lib/publicApi/domUtils/stringUtil.js +35 -0
- package/lib/publicApi/domUtils/stringUtil.js.map +1 -0
- package/lib/publicApi/model/cloneModel.d.ts +30 -0
- package/lib/publicApi/model/cloneModel.js +207 -0
- package/lib/publicApi/model/cloneModel.js.map +1 -0
- package/lib/publicApi/model/getClosestAncestorBlockGroupIndex.d.ts +12 -0
- package/lib/publicApi/model/getClosestAncestorBlockGroupIndex.js +28 -0
- package/lib/publicApi/model/getClosestAncestorBlockGroupIndex.js.map +1 -0
- package/lib/publicApi/model/isBlockGroupOfType.d.ts +8 -0
- package/lib/publicApi/model/isBlockGroupOfType.js +14 -0
- package/lib/publicApi/model/isBlockGroupOfType.js.map +1 -0
- package/lib/publicApi/model/mergeModel.d.ts +36 -0
- package/lib/publicApi/model/mergeModel.js +262 -0
- package/lib/publicApi/model/mergeModel.js.map +1 -0
- package/lib/publicApi/model/paste.d.ts +14 -0
- package/lib/publicApi/model/paste.js +150 -0
- package/lib/publicApi/model/paste.js.map +1 -0
- package/lib/publicApi/selection/collectSelections.d.ts +50 -0
- package/lib/publicApi/selection/collectSelections.js +182 -0
- package/lib/publicApi/selection/collectSelections.js.map +1 -0
- package/lib/publicApi/selection/deleteBlock.d.ts +11 -0
- package/lib/publicApi/selection/deleteBlock.js +56 -0
- package/lib/publicApi/selection/deleteBlock.js.map +1 -0
- package/lib/publicApi/selection/deleteSegment.d.ts +10 -0
- package/lib/publicApi/selection/deleteSegment.js +88 -0
- package/lib/publicApi/selection/deleteSegment.js.map +1 -0
- package/lib/publicApi/selection/deleteSelection.d.ts +9 -0
- package/lib/publicApi/selection/deleteSelection.js +44 -0
- package/lib/publicApi/selection/deleteSelection.js.map +1 -0
- package/lib/publicApi/selection/getSelectionRootNode.d.ts +9 -0
- package/lib/publicApi/selection/getSelectionRootNode.js +23 -0
- package/lib/publicApi/selection/getSelectionRootNode.js.map +1 -0
- package/lib/publicApi/selection/iterateSelections.d.ts +48 -0
- package/lib/publicApi/selection/iterateSelections.js +147 -0
- package/lib/publicApi/selection/iterateSelections.js.map +1 -0
- package/lib/publicApi/selection/setSelection.d.ts +8 -0
- package/lib/publicApi/selection/setSelection.js +131 -0
- package/lib/publicApi/selection/setSelection.js.map +1 -0
- package/lib/publicApi/table/applyTableFormat.d.ts +8 -0
- package/lib/publicApi/table/applyTableFormat.js +241 -0
- package/lib/publicApi/table/applyTableFormat.js.map +1 -0
- package/lib/publicApi/table/normalizeTable.d.ts +13 -0
- package/lib/publicApi/table/normalizeTable.js +121 -0
- package/lib/publicApi/table/normalizeTable.js.map +1 -0
- package/lib/publicApi/table/setTableCellBackgroundColor.d.ts +15 -0
- package/lib/publicApi/table/setTableCellBackgroundColor.js +105 -0
- package/lib/publicApi/table/setTableCellBackgroundColor.js.map +1 -0
- package/lib-amd/constants/ChangeSource.d.ts +59 -0
- package/lib-amd/constants/ChangeSource.js +65 -0
- package/lib-amd/constants/ChangeSource.js.map +1 -0
- package/lib-amd/coreApi/createContentModel.d.ts +9 -0
- package/lib-amd/coreApi/createContentModel.js +39 -0
- package/lib-amd/coreApi/createContentModel.js.map +1 -0
- package/lib-amd/coreApi/createEditorContext.d.ts +6 -0
- package/lib-amd/coreApi/createEditorContext.js +40 -0
- package/lib-amd/coreApi/createEditorContext.js.map +1 -0
- package/lib-amd/coreApi/formatContentModel.d.ts +12 -0
- package/lib-amd/coreApi/formatContentModel.js +128 -0
- package/lib-amd/coreApi/formatContentModel.js.map +1 -0
- package/lib-amd/coreApi/getDOMSelection.d.ts +5 -0
- package/lib-amd/coreApi/getDOMSelection.js +43 -0
- package/lib-amd/coreApi/getDOMSelection.js.map +1 -0
- package/lib-amd/coreApi/setContentModel.d.ts +9 -0
- package/lib-amd/coreApi/setContentModel.js +33 -0
- package/lib-amd/coreApi/setContentModel.js.map +1 -0
- package/lib-amd/coreApi/setDOMSelection.d.ts +5 -0
- package/lib-amd/coreApi/setDOMSelection.js +43 -0
- package/lib-amd/coreApi/setDOMSelection.js.map +1 -0
- package/lib-amd/coreApi/switchShadowEdit.d.ts +8 -0
- package/lib-amd/coreApi/switchShadowEdit.js +55 -0
- package/lib-amd/coreApi/switchShadowEdit.js.map +1 -0
- package/lib-amd/corePlugin/ContentModelCachePlugin.d.ts +53 -0
- package/lib-amd/corePlugin/ContentModelCachePlugin.js +169 -0
- package/lib-amd/corePlugin/ContentModelCachePlugin.js.map +1 -0
- package/lib-amd/corePlugin/ContentModelCopyPastePlugin.d.ts +46 -0
- package/lib-amd/corePlugin/ContentModelCopyPastePlugin.js +226 -0
- package/lib-amd/corePlugin/ContentModelCopyPastePlugin.js.map +1 -0
- package/lib-amd/corePlugin/ContentModelFormatPlugin.d.ts +59 -0
- package/lib-amd/corePlugin/ContentModelFormatPlugin.js +145 -0
- package/lib-amd/corePlugin/ContentModelFormatPlugin.js.map +1 -0
- package/lib-amd/corePlugin/ContentModelTypeInContainerPlugin.d.ts +23 -0
- package/lib-amd/corePlugin/ContentModelTypeInContainerPlugin.js +34 -0
- package/lib-amd/corePlugin/ContentModelTypeInContainerPlugin.js.map +1 -0
- package/lib-amd/corePlugin/utils/addRangeToSelection.d.ts +4 -0
- package/lib-amd/corePlugin/utils/addRangeToSelection.js +18 -0
- package/lib-amd/corePlugin/utils/addRangeToSelection.js.map +1 -0
- package/lib-amd/corePlugin/utils/applyDefaultFormat.d.ts +9 -0
- package/lib-amd/corePlugin/utils/applyDefaultFormat.js +78 -0
- package/lib-amd/corePlugin/utils/applyDefaultFormat.js.map +1 -0
- package/lib-amd/corePlugin/utils/applyPendingFormat.d.ts +8 -0
- package/lib-amd/corePlugin/utils/applyPendingFormat.js +50 -0
- package/lib-amd/corePlugin/utils/applyPendingFormat.js.map +1 -0
- package/lib-amd/corePlugin/utils/areSameSelection.d.ts +6 -0
- package/lib-amd/corePlugin/utils/areSameSelection.js +38 -0
- package/lib-amd/corePlugin/utils/areSameSelection.js.map +1 -0
- package/lib-amd/corePlugin/utils/contentModelDomIndexer.d.ts +6 -0
- package/lib-amd/corePlugin/utils/contentModelDomIndexer.js +189 -0
- package/lib-amd/corePlugin/utils/contentModelDomIndexer.js.map +1 -0
- package/lib-amd/editor/createContentModelEditorCore.d.ts +6 -0
- package/lib-amd/editor/createContentModelEditorCore.js +44 -0
- package/lib-amd/editor/createContentModelEditorCore.js.map +1 -0
- package/lib-amd/editor/promoteToContentModelEditorCore.d.ts +8 -0
- package/lib-amd/editor/promoteToContentModelEditorCore.js +64 -0
- package/lib-amd/editor/promoteToContentModelEditorCore.js.map +1 -0
- package/lib-amd/index.d.ts +29 -0
- package/lib-amd/index.js +44 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/metadata/definitionCreators.d.ts +48 -0
- package/lib-amd/metadata/definitionCreators.js +97 -0
- package/lib-amd/metadata/definitionCreators.js.map +1 -0
- package/lib-amd/metadata/updateImageMetadata.d.ts +7 -0
- package/lib-amd/metadata/updateImageMetadata.js +28 -0
- package/lib-amd/metadata/updateImageMetadata.js.map +1 -0
- package/lib-amd/metadata/updateListMetadata.d.ts +15 -0
- package/lib-amd/metadata/updateListMetadata.js +179 -0
- package/lib-amd/metadata/updateListMetadata.js.map +1 -0
- package/lib-amd/metadata/updateTableCellMetadata.d.ts +7 -0
- package/lib-amd/metadata/updateTableCellMetadata.js +20 -0
- package/lib-amd/metadata/updateTableCellMetadata.js.map +1 -0
- package/lib-amd/metadata/updateTableMetadata.d.ts +7 -0
- package/lib-amd/metadata/updateTableMetadata.js +31 -0
- package/lib-amd/metadata/updateTableMetadata.js.map +1 -0
- package/lib-amd/modelApi/edit/deleteExpandedSelection.d.ts +7 -0
- package/lib-amd/modelApi/edit/deleteExpandedSelection.js +96 -0
- package/lib-amd/modelApi/edit/deleteExpandedSelection.js.map +1 -0
- package/lib-amd/modelApi/edit/deleteSingleChar.d.ts +4 -0
- package/lib-amd/modelApi/edit/deleteSingleChar.js +37 -0
- package/lib-amd/modelApi/edit/deleteSingleChar.js.map +1 -0
- package/lib-amd/override/tablePreProcessor.d.ts +5 -0
- package/lib-amd/override/tablePreProcessor.js +25 -0
- package/lib-amd/override/tablePreProcessor.js.map +1 -0
- package/lib-amd/publicApi/domUtils/borderValues.d.ts +13 -0
- package/lib-amd/publicApi/domUtils/borderValues.js +50 -0
- package/lib-amd/publicApi/domUtils/borderValues.js.map +1 -0
- package/lib-amd/publicApi/domUtils/eventUtils.d.ts +13 -0
- package/lib-amd/publicApi/domUtils/eventUtils.js +31 -0
- package/lib-amd/publicApi/domUtils/eventUtils.js.map +1 -0
- package/lib-amd/publicApi/domUtils/stringUtil.d.ts +18 -0
- package/lib-amd/publicApi/domUtils/stringUtil.js +37 -0
- package/lib-amd/publicApi/domUtils/stringUtil.js.map +1 -0
- package/lib-amd/publicApi/model/cloneModel.d.ts +30 -0
- package/lib-amd/publicApi/model/cloneModel.js +208 -0
- package/lib-amd/publicApi/model/cloneModel.js.map +1 -0
- package/lib-amd/publicApi/model/getClosestAncestorBlockGroupIndex.d.ts +12 -0
- package/lib-amd/publicApi/model/getClosestAncestorBlockGroupIndex.js +30 -0
- package/lib-amd/publicApi/model/getClosestAncestorBlockGroupIndex.js.map +1 -0
- package/lib-amd/publicApi/model/isBlockGroupOfType.d.ts +8 -0
- package/lib-amd/publicApi/model/isBlockGroupOfType.js +16 -0
- package/lib-amd/publicApi/model/isBlockGroupOfType.js.map +1 -0
- package/lib-amd/publicApi/model/mergeModel.d.ts +36 -0
- package/lib-amd/publicApi/model/mergeModel.js +258 -0
- package/lib-amd/publicApi/model/mergeModel.js.map +1 -0
- package/lib-amd/publicApi/model/paste.d.ts +14 -0
- package/lib-amd/publicApi/model/paste.js +146 -0
- package/lib-amd/publicApi/model/paste.js.map +1 -0
- package/lib-amd/publicApi/selection/collectSelections.d.ts +50 -0
- package/lib-amd/publicApi/selection/collectSelections.js +180 -0
- package/lib-amd/publicApi/selection/collectSelections.js.map +1 -0
- package/lib-amd/publicApi/selection/deleteBlock.d.ts +11 -0
- package/lib-amd/publicApi/selection/deleteBlock.js +58 -0
- package/lib-amd/publicApi/selection/deleteBlock.js.map +1 -0
- package/lib-amd/publicApi/selection/deleteSegment.d.ts +10 -0
- package/lib-amd/publicApi/selection/deleteSegment.js +87 -0
- package/lib-amd/publicApi/selection/deleteSegment.js.map +1 -0
- package/lib-amd/publicApi/selection/deleteSelection.d.ts +9 -0
- package/lib-amd/publicApi/selection/deleteSelection.js +44 -0
- package/lib-amd/publicApi/selection/deleteSelection.js.map +1 -0
- package/lib-amd/publicApi/selection/getSelectionRootNode.d.ts +9 -0
- package/lib-amd/publicApi/selection/getSelectionRootNode.js +25 -0
- package/lib-amd/publicApi/selection/getSelectionRootNode.js.map +1 -0
- package/lib-amd/publicApi/selection/iterateSelections.d.ts +48 -0
- package/lib-amd/publicApi/selection/iterateSelections.js +148 -0
- package/lib-amd/publicApi/selection/iterateSelections.js.map +1 -0
- package/lib-amd/publicApi/selection/setSelection.d.ts +8 -0
- package/lib-amd/publicApi/selection/setSelection.js +132 -0
- package/lib-amd/publicApi/selection/setSelection.js.map +1 -0
- package/lib-amd/publicApi/table/applyTableFormat.d.ts +8 -0
- package/lib-amd/publicApi/table/applyTableFormat.js +236 -0
- package/lib-amd/publicApi/table/applyTableFormat.js.map +1 -0
- package/lib-amd/publicApi/table/normalizeTable.d.ts +13 -0
- package/lib-amd/publicApi/table/normalizeTable.js +121 -0
- package/lib-amd/publicApi/table/normalizeTable.js.map +1 -0
- package/lib-amd/publicApi/table/setTableCellBackgroundColor.d.ts +15 -0
- package/lib-amd/publicApi/table/setTableCellBackgroundColor.js +105 -0
- package/lib-amd/publicApi/table/setTableCellBackgroundColor.js.map +1 -0
- package/lib-mjs/constants/ChangeSource.d.ts +59 -0
- package/lib-mjs/constants/ChangeSource.js +60 -0
- package/lib-mjs/constants/ChangeSource.js.map +1 -0
- package/lib-mjs/coreApi/createContentModel.d.ts +9 -0
- package/lib-mjs/coreApi/createContentModel.js +36 -0
- package/lib-mjs/coreApi/createContentModel.js.map +1 -0
- package/lib-mjs/coreApi/createEditorContext.d.ts +6 -0
- package/lib-mjs/coreApi/createEditorContext.js +34 -0
- package/lib-mjs/coreApi/createEditorContext.js.map +1 -0
- package/lib-mjs/coreApi/formatContentModel.d.ts +12 -0
- package/lib-mjs/coreApi/formatContentModel.js +124 -0
- package/lib-mjs/coreApi/formatContentModel.js.map +1 -0
- package/lib-mjs/coreApi/getDOMSelection.d.ts +5 -0
- package/lib-mjs/coreApi/getDOMSelection.js +37 -0
- package/lib-mjs/coreApi/getDOMSelection.js.map +1 -0
- package/lib-mjs/coreApi/setContentModel.d.ts +9 -0
- package/lib-mjs/coreApi/setContentModel.js +29 -0
- package/lib-mjs/coreApi/setContentModel.js.map +1 -0
- package/lib-mjs/coreApi/setDOMSelection.d.ts +5 -0
- package/lib-mjs/coreApi/setDOMSelection.js +37 -0
- package/lib-mjs/coreApi/setDOMSelection.js.map +1 -0
- package/lib-mjs/coreApi/switchShadowEdit.d.ts +8 -0
- package/lib-mjs/coreApi/switchShadowEdit.js +50 -0
- package/lib-mjs/coreApi/switchShadowEdit.js.map +1 -0
- package/lib-mjs/corePlugin/ContentModelCachePlugin.d.ts +53 -0
- package/lib-mjs/corePlugin/ContentModelCachePlugin.js +165 -0
- package/lib-mjs/corePlugin/ContentModelCachePlugin.js.map +1 -0
- package/lib-mjs/corePlugin/ContentModelCopyPastePlugin.d.ts +46 -0
- package/lib-mjs/corePlugin/ContentModelCopyPastePlugin.js +228 -0
- package/lib-mjs/corePlugin/ContentModelCopyPastePlugin.js.map +1 -0
- package/lib-mjs/corePlugin/ContentModelFormatPlugin.d.ts +59 -0
- package/lib-mjs/corePlugin/ContentModelFormatPlugin.js +143 -0
- package/lib-mjs/corePlugin/ContentModelFormatPlugin.js.map +1 -0
- package/lib-mjs/corePlugin/ContentModelTypeInContainerPlugin.d.ts +23 -0
- package/lib-mjs/corePlugin/ContentModelTypeInContainerPlugin.js +29 -0
- package/lib-mjs/corePlugin/ContentModelTypeInContainerPlugin.js.map +1 -0
- package/lib-mjs/corePlugin/utils/addRangeToSelection.d.ts +4 -0
- package/lib-mjs/corePlugin/utils/addRangeToSelection.js +12 -0
- package/lib-mjs/corePlugin/utils/addRangeToSelection.js.map +1 -0
- package/lib-mjs/corePlugin/utils/applyDefaultFormat.d.ts +9 -0
- package/lib-mjs/corePlugin/utils/applyDefaultFormat.js +75 -0
- package/lib-mjs/corePlugin/utils/applyDefaultFormat.js.map +1 -0
- package/lib-mjs/corePlugin/utils/applyPendingFormat.d.ts +8 -0
- package/lib-mjs/corePlugin/utils/applyPendingFormat.js +47 -0
- package/lib-mjs/corePlugin/utils/applyPendingFormat.js.map +1 -0
- package/lib-mjs/corePlugin/utils/areSameSelection.d.ts +6 -0
- package/lib-mjs/corePlugin/utils/areSameSelection.js +32 -0
- package/lib-mjs/corePlugin/utils/areSameSelection.js.map +1 -0
- package/lib-mjs/corePlugin/utils/contentModelDomIndexer.d.ts +6 -0
- package/lib-mjs/corePlugin/utils/contentModelDomIndexer.js +187 -0
- package/lib-mjs/corePlugin/utils/contentModelDomIndexer.js.map +1 -0
- package/lib-mjs/editor/createContentModelEditorCore.d.ts +6 -0
- package/lib-mjs/editor/createContentModelEditorCore.js +46 -0
- package/lib-mjs/editor/createContentModelEditorCore.js.map +1 -0
- package/lib-mjs/editor/promoteToContentModelEditorCore.d.ts +8 -0
- package/lib-mjs/editor/promoteToContentModelEditorCore.js +68 -0
- package/lib-mjs/editor/promoteToContentModelEditorCore.js.map +1 -0
- package/lib-mjs/index.d.ts +29 -0
- package/lib-mjs/index.js +30 -0
- package/lib-mjs/index.js.map +1 -0
- package/lib-mjs/metadata/definitionCreators.d.ts +48 -0
- package/lib-mjs/metadata/definitionCreators.js +87 -0
- package/lib-mjs/metadata/definitionCreators.js.map +1 -0
- package/lib-mjs/metadata/updateImageMetadata.d.ts +7 -0
- package/lib-mjs/metadata/updateImageMetadata.js +24 -0
- package/lib-mjs/metadata/updateImageMetadata.js.map +1 -0
- package/lib-mjs/metadata/updateListMetadata.d.ts +15 -0
- package/lib-mjs/metadata/updateListMetadata.js +177 -0
- package/lib-mjs/metadata/updateListMetadata.js.map +1 -0
- package/lib-mjs/metadata/updateTableCellMetadata.d.ts +7 -0
- package/lib-mjs/metadata/updateTableCellMetadata.js +16 -0
- package/lib-mjs/metadata/updateTableCellMetadata.js.map +1 -0
- package/lib-mjs/metadata/updateTableMetadata.d.ts +7 -0
- package/lib-mjs/metadata/updateTableMetadata.js +28 -0
- package/lib-mjs/metadata/updateTableMetadata.js.map +1 -0
- package/lib-mjs/modelApi/edit/deleteExpandedSelection.d.ts +7 -0
- package/lib-mjs/modelApi/edit/deleteExpandedSelection.js +95 -0
- package/lib-mjs/modelApi/edit/deleteExpandedSelection.js.map +1 -0
- package/lib-mjs/modelApi/edit/deleteSingleChar.d.ts +4 -0
- package/lib-mjs/modelApi/edit/deleteSingleChar.js +32 -0
- package/lib-mjs/modelApi/edit/deleteSingleChar.js.map +1 -0
- package/lib-mjs/override/tablePreProcessor.d.ts +5 -0
- package/lib-mjs/override/tablePreProcessor.js +21 -0
- package/lib-mjs/override/tablePreProcessor.js.map +1 -0
- package/lib-mjs/publicApi/domUtils/borderValues.d.ts +13 -0
- package/lib-mjs/publicApi/domUtils/borderValues.js +43 -0
- package/lib-mjs/publicApi/domUtils/borderValues.js.map +1 -0
- package/lib-mjs/publicApi/domUtils/eventUtils.d.ts +13 -0
- package/lib-mjs/publicApi/domUtils/eventUtils.js +24 -0
- package/lib-mjs/publicApi/domUtils/eventUtils.js.map +1 -0
- package/lib-mjs/publicApi/domUtils/stringUtil.d.ts +18 -0
- package/lib-mjs/publicApi/domUtils/stringUtil.js +29 -0
- package/lib-mjs/publicApi/domUtils/stringUtil.js.map +1 -0
- package/lib-mjs/publicApi/model/cloneModel.d.ts +30 -0
- package/lib-mjs/publicApi/model/cloneModel.js +203 -0
- package/lib-mjs/publicApi/model/cloneModel.js.map +1 -0
- package/lib-mjs/publicApi/model/getClosestAncestorBlockGroupIndex.d.ts +12 -0
- package/lib-mjs/publicApi/model/getClosestAncestorBlockGroupIndex.js +24 -0
- package/lib-mjs/publicApi/model/getClosestAncestorBlockGroupIndex.js.map +1 -0
- package/lib-mjs/publicApi/model/isBlockGroupOfType.d.ts +8 -0
- package/lib-mjs/publicApi/model/isBlockGroupOfType.js +10 -0
- package/lib-mjs/publicApi/model/isBlockGroupOfType.js.map +1 -0
- package/lib-mjs/publicApi/model/mergeModel.d.ts +36 -0
- package/lib-mjs/publicApi/model/mergeModel.js +258 -0
- package/lib-mjs/publicApi/model/mergeModel.js.map +1 -0
- package/lib-mjs/publicApi/model/paste.d.ts +14 -0
- package/lib-mjs/publicApi/model/paste.js +145 -0
- package/lib-mjs/publicApi/model/paste.js.map +1 -0
- package/lib-mjs/publicApi/selection/collectSelections.d.ts +50 -0
- package/lib-mjs/publicApi/selection/collectSelections.js +173 -0
- package/lib-mjs/publicApi/selection/collectSelections.js.map +1 -0
- package/lib-mjs/publicApi/selection/deleteBlock.d.ts +11 -0
- package/lib-mjs/publicApi/selection/deleteBlock.js +52 -0
- package/lib-mjs/publicApi/selection/deleteBlock.js.map +1 -0
- package/lib-mjs/publicApi/selection/deleteSegment.d.ts +10 -0
- package/lib-mjs/publicApi/selection/deleteSegment.js +84 -0
- package/lib-mjs/publicApi/selection/deleteSegment.js.map +1 -0
- package/lib-mjs/publicApi/selection/deleteSelection.d.ts +9 -0
- package/lib-mjs/publicApi/selection/deleteSelection.js +40 -0
- package/lib-mjs/publicApi/selection/deleteSelection.js.map +1 -0
- package/lib-mjs/publicApi/selection/getSelectionRootNode.d.ts +9 -0
- package/lib-mjs/publicApi/selection/getSelectionRootNode.js +19 -0
- package/lib-mjs/publicApi/selection/getSelectionRootNode.js.map +1 -0
- package/lib-mjs/publicApi/selection/iterateSelections.d.ts +48 -0
- package/lib-mjs/publicApi/selection/iterateSelections.js +143 -0
- package/lib-mjs/publicApi/selection/iterateSelections.js.map +1 -0
- package/lib-mjs/publicApi/selection/setSelection.d.ts +8 -0
- package/lib-mjs/publicApi/selection/setSelection.js +127 -0
- package/lib-mjs/publicApi/selection/setSelection.js.map +1 -0
- package/lib-mjs/publicApi/table/applyTableFormat.d.ts +8 -0
- package/lib-mjs/publicApi/table/applyTableFormat.js +237 -0
- package/lib-mjs/publicApi/table/applyTableFormat.js.map +1 -0
- package/lib-mjs/publicApi/table/normalizeTable.d.ts +13 -0
- package/lib-mjs/publicApi/table/normalizeTable.js +117 -0
- package/lib-mjs/publicApi/table/normalizeTable.js.map +1 -0
- package/lib-mjs/publicApi/table/setTableCellBackgroundColor.d.ts +15 -0
- package/lib-mjs/publicApi/table/setTableCellBackgroundColor.js +100 -0
- package/lib-mjs/publicApi/table/setTableCellBackgroundColor.js.map +1 -0
- package/package.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paste.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/model/paste.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,OAAO,EACH,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,iCAAiC,EACjC,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,oBAAoB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,qCAAqC;AACrC,0DAA0D;AAC1D,IAAM,YAAY,GAAoC;IAClD,OAAO,iBAAsB;IAC7B,WAAW,qBAA0B;IACrC,WAAW,qBAA0B;IACrC,MAAM,gBAAqB;CAC9B,CAAC;AACF,IAAM,kBAAkB,GAAwC;IAC5D,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,KAAK;IACb,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,KAAK;IACpB,wBAAwB,EAAE,EAAE;IAC5B,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,KAAK;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CACjB,MAAmC,EACnC,aAA4B,EAC5B,SAA+B;IAA/B,0BAAA,EAAA,oBAA+B;IAE/B,IAAI,aAAa,CAAC,mBAAmB,EAAE;QACnC,kDAAkD;QAClD,MAAM,CAAC,UAAU,CAAC,aA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C,CAAC,SAAS,IAAI,aAAa,IAAI,CAAC,IAAI,IAAI,YAAY,CAAC,EACvD;QACE,cAAc;QACd,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;KAC5C;SAAM,IAAI,SAAS,IAAI,aAAa,IAAI,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE;QACxE,cAAc,CAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;KACvC;SAAM,IAAI,IAAI,EAAE;QACb,aAAa;QACb,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;KACtD;IAED,IAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAErE,cAAc,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEtC,2BAA2B,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IAE5D,IAAI,WAAW,GAAiC,KAAK,CAAC;IAEtD,0IAA0I;IAC1I,IAAI,SAAS,KAAK,aAAa,EAAE;QAC7B,WAAW,GAAG,MAAM,CAAC,kBAAkB,uBAEnC,KAAK,EACL,IAAI,CAAC,eAAe,CACS,CAAC;KACrC;IAED,8EAA8E;IAC9E,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAE/C,OAAO,WAAW,CAAC;AACvB,CAAC","sourcesContent":["import { ChangeSource } from '../../constants/ChangeSource';\nimport { GetContentMode, PasteType as OldPasteType, PluginEventType } from 'roosterjs-editor-types';\nimport { getSelectedSegments } from '../selection/collectSelections';\nimport { mergeModel } from './mergeModel';\nimport type {\n ContentModelDocument,\n ContentModelSegmentFormat,\n FormatWithContentModelContext,\n InsertPoint,\n PasteType,\n ContentModelBeforePasteEventData,\n ContentModelBeforePasteEvent,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\nimport type { ClipboardData, IEditor } from 'roosterjs-editor-types';\nimport {\n applySegmentFormatToElement,\n createDomToModelContext,\n domToContentModel,\n moveChildNodes,\n} from 'roosterjs-content-model-dom';\nimport {\n createDefaultHtmlSanitizerOptions,\n handleImagePaste,\n handleTextPaste,\n retrieveMetadataFromClipboard,\n sanitizePasteContent,\n} from 'roosterjs-editor-dom';\n\n// Map new PasteType to old PasteType\n// TODO: We can remove this once we have standalone editor\nconst PasteTypeMap: Record<PasteType, OldPasteType> = {\n asImage: OldPasteType.AsImage,\n asPlainText: OldPasteType.AsPlainText,\n mergeFormat: OldPasteType.MergeFormat,\n normal: OldPasteType.Normal,\n};\nconst EmptySegmentFormat: Required<ContentModelSegmentFormat> = {\n backgroundColor: '',\n fontFamily: '',\n fontSize: '',\n fontWeight: '',\n italic: false,\n letterSpacing: '',\n lineHeight: '',\n strikethrough: false,\n superOrSubScriptSequence: '',\n textColor: '',\n underline: false,\n};\n\n/**\n * Paste into editor using a clipboardData object\n * @param editor The editor to paste content into\n * @param clipboardData Clipboard data retrieved from clipboard\n * @param pasteType Type of content to paste. @default normal\n */\nexport function paste(\n editor: IStandaloneEditor & IEditor,\n clipboardData: ClipboardData,\n pasteType: PasteType = 'normal'\n) {\n if (clipboardData.snapshotBeforePaste) {\n // Restore original content before paste a new one\n editor.setContent(clipboardData.snapshotBeforePaste);\n } else {\n clipboardData.snapshotBeforePaste = editor.getContent(GetContentMode.RawHTMLWithSelection);\n }\n\n editor.focus();\n let originalFormat: ContentModelSegmentFormat | undefined;\n\n editor.formatContentModel(\n (model, context) => {\n const eventData = createBeforePasteEventData(editor, clipboardData, pasteType);\n const currentSegment = getSelectedSegments(model, true /*includingFormatHolder*/)[0];\n const { fontFamily, fontSize, textColor, backgroundColor, letterSpacing, lineHeight } =\n currentSegment?.format ?? {};\n const {\n domToModelOption,\n fragment,\n customizedMerge,\n } = triggerPluginEventAndCreatePasteFragment(\n editor,\n clipboardData,\n pasteType,\n eventData,\n { fontFamily, fontSize, textColor, backgroundColor, letterSpacing, lineHeight }\n );\n\n const pasteModel = domToContentModel(\n fragment,\n createDomToModelContext(undefined /*editorContext*/, domToModelOption)\n );\n\n const insertPoint = mergePasteContent(\n model,\n context,\n pasteModel,\n pasteType == 'mergeFormat',\n customizedMerge\n );\n\n if (insertPoint) {\n originalFormat = insertPoint.marker.format;\n }\n\n if (originalFormat) {\n context.newPendingFormat = { ...EmptySegmentFormat, ...originalFormat }; // Use empty format as initial value to clear any other format inherits from pasted content\n }\n\n return true;\n },\n\n {\n changeSource: ChangeSource.Paste,\n getChangeData: () => clipboardData,\n apiName: 'paste',\n }\n );\n}\n\n/**\n * @internal\n * Export only for unit test\n */\nexport function mergePasteContent(\n model: ContentModelDocument,\n context: FormatWithContentModelContext,\n pasteModel: ContentModelDocument,\n applyCurrentFormat: boolean,\n customizedMerge:\n | undefined\n | ((source: ContentModelDocument, target: ContentModelDocument) => InsertPoint | null)\n): InsertPoint | null {\n return customizedMerge\n ? customizedMerge(model, pasteModel)\n : mergeModel(model, pasteModel, context, {\n mergeFormat: applyCurrentFormat ? 'keepSourceEmphasisFormat' : 'none',\n mergeTable: shouldMergeTable(pasteModel),\n });\n}\n\nfunction shouldMergeTable(pasteModel: ContentModelDocument): boolean | undefined {\n // If model contains a table and a paragraph element after the table with a single BR segment, remove the Paragraph after the table\n if (\n pasteModel.blocks.length == 2 &&\n pasteModel.blocks[0].blockType === 'Table' &&\n pasteModel.blocks[1].blockType === 'Paragraph' &&\n pasteModel.blocks[1].segments.length === 1 &&\n pasteModel.blocks[1].segments[0].segmentType === 'Br'\n ) {\n pasteModel.blocks.splice(1);\n }\n // Only merge table when the document contain a single table.\n return pasteModel.blocks.length === 1 && pasteModel.blocks[0].blockType === 'Table';\n}\n\nfunction createBeforePasteEventData(\n editor: IEditor,\n clipboardData: ClipboardData,\n pasteType: PasteType\n): ContentModelBeforePasteEventData {\n const options = createDefaultHtmlSanitizerOptions();\n\n // Remove \"caret-color\" style generated by Safari to make sure caret shows in right color after paste\n options.cssStyleCallbacks['caret-color'] = () => false;\n\n return {\n clipboardData,\n fragment: editor.getDocument().createDocumentFragment(),\n sanitizingOption: options,\n htmlBefore: '',\n htmlAfter: '',\n htmlAttributes: {},\n domToModelOption: {},\n pasteType: PasteTypeMap[pasteType],\n };\n}\n\n/**\n * This function is used to create a BeforePasteEvent object after trigger the event, so other plugins can modify the event object\n * This function will also create a DocumentFragment for paste.\n */\nfunction triggerPluginEventAndCreatePasteFragment(\n editor: IEditor,\n clipboardData: ClipboardData,\n pasteType: PasteType,\n eventData: ContentModelBeforePasteEventData,\n currentFormat: ContentModelSegmentFormat\n): ContentModelBeforePasteEventData {\n const event = {\n eventType: PluginEventType.BeforePaste,\n ...eventData,\n } as ContentModelBeforePasteEvent;\n\n const { fragment } = event;\n const { rawHtml, text, imageDataUri } = clipboardData;\n const trustedHTMLHandler = editor.getTrustedHTMLHandler();\n\n const doc: Document | undefined = rawHtml\n ? new DOMParser().parseFromString(trustedHTMLHandler(rawHtml), 'text/html')\n : undefined;\n\n // Step 2: Retrieve Metadata from Html and the Html that was copied.\n retrieveMetadataFromClipboard(doc, event, trustedHTMLHandler);\n\n // Step 3: Fill the BeforePasteEvent object, especially the fragment for paste\n if (\n (pasteType == 'asImage' && imageDataUri) ||\n (pasteType != 'asPlainText' && !text && imageDataUri)\n ) {\n // Paste image\n handleImagePaste(imageDataUri, fragment);\n } else if (pasteType != 'asPlainText' && rawHtml && doc ? doc.body : false) {\n moveChildNodes(fragment, doc?.body);\n } else if (text) {\n // Paste text\n handleTextPaste(text, null /*position*/, fragment);\n }\n\n const formatContainer = fragment.ownerDocument.createElement('span');\n\n moveChildNodes(formatContainer, fragment);\n fragment.appendChild(formatContainer);\n\n applySegmentFormatToElement(formatContainer, currentFormat);\n\n let pluginEvent: ContentModelBeforePasteEvent = event;\n\n // Step 4: Trigger BeforePasteEvent so that plugins can do proper change before paste, when the type of paste is different than Plain Text\n if (pasteType !== 'asPlainText') {\n pluginEvent = editor.triggerPluginEvent(\n PluginEventType.BeforePaste,\n event,\n true /* broadcast */\n ) as ContentModelBeforePasteEvent;\n }\n\n // Step 5. Sanitize the fragment before paste to make sure the content is safe\n sanitizePasteContent(event, null /*position*/);\n\n return pluginEvent;\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ContentModelBlock, ContentModelBlockGroup, ContentModelBlockGroupType, ContentModelDocument, ContentModelListItem, ContentModelParagraph, ContentModelSegment, ContentModelTable } from 'roosterjs-content-model-types';
|
|
2
|
+
import type { TypeOfBlockGroup } from '../model/getClosestAncestorBlockGroupIndex';
|
|
3
|
+
/**
|
|
4
|
+
* Represent a pair of parent block group and child block
|
|
5
|
+
*/
|
|
6
|
+
export declare type OperationalBlocks<T extends ContentModelBlockGroup> = {
|
|
7
|
+
/**
|
|
8
|
+
* The parent block group
|
|
9
|
+
*/
|
|
10
|
+
parent: ContentModelBlockGroup;
|
|
11
|
+
/**
|
|
12
|
+
* The child block
|
|
13
|
+
*/
|
|
14
|
+
block: ContentModelBlock | T;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get an array of selected parent paragraph and child segment pair
|
|
18
|
+
* @param model The Content Model to get selection from
|
|
19
|
+
* @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSelectedSegmentsAndParagraphs(model: ContentModelDocument, includingFormatHolder: boolean): [ContentModelSegment, ContentModelParagraph | null][];
|
|
22
|
+
/**
|
|
23
|
+
* Get an array of selected segments from a content model
|
|
24
|
+
* @param model The Content Model to get selection from
|
|
25
|
+
* @param includingFormatHolder True means also include format holder as segment from list item
|
|
26
|
+
*/
|
|
27
|
+
export declare function getSelectedSegments(model: ContentModelDocument, includingFormatHolder: boolean): ContentModelSegment[];
|
|
28
|
+
/**
|
|
29
|
+
* Get any array of selected paragraphs from a content model
|
|
30
|
+
* @param model The Content Model to get selection from
|
|
31
|
+
*/
|
|
32
|
+
export declare function getSelectedParagraphs(model: ContentModelDocument): ContentModelParagraph[];
|
|
33
|
+
/**
|
|
34
|
+
* Get an array of block group - block pair that is of the expected block group type from selection
|
|
35
|
+
* @param model The Content Model to get selection from
|
|
36
|
+
* @param blockGroupTypes The expected block group types
|
|
37
|
+
* @param stopTypes Block group types that will stop searching when hit
|
|
38
|
+
* @param deepFirst True means search in deep first, otherwise wide first
|
|
39
|
+
*/
|
|
40
|
+
export declare function getOperationalBlocks<T extends ContentModelBlockGroup>(model: ContentModelDocument, blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes: ContentModelBlockGroupType[], deepFirst?: boolean): OperationalBlocks<T>[];
|
|
41
|
+
/**
|
|
42
|
+
* Get the first selected table from content model
|
|
43
|
+
* @param model The Content Model to get selection from
|
|
44
|
+
*/
|
|
45
|
+
export declare function getFirstSelectedTable(model: ContentModelDocument): [ContentModelTable | undefined, ContentModelBlockGroup[]];
|
|
46
|
+
/**
|
|
47
|
+
* Get the first selected list item from content model
|
|
48
|
+
* @param model The Content Model to get selection from
|
|
49
|
+
*/
|
|
50
|
+
export declare function getFirstSelectedListItem(model: ContentModelDocument): ContentModelListItem | undefined;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { getClosestAncestorBlockGroupIndex } from '../model/getClosestAncestorBlockGroupIndex';
|
|
3
|
+
import { isBlockGroupOfType } from '../model/isBlockGroupOfType';
|
|
4
|
+
import { iterateSelections } from './iterateSelections';
|
|
5
|
+
/**
|
|
6
|
+
* Get an array of selected parent paragraph and child segment pair
|
|
7
|
+
* @param model The Content Model to get selection from
|
|
8
|
+
* @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null
|
|
9
|
+
*/
|
|
10
|
+
export function getSelectedSegmentsAndParagraphs(model, includingFormatHolder) {
|
|
11
|
+
var selections = collectSelections(model, {
|
|
12
|
+
includeListFormatHolder: includingFormatHolder ? 'allSegments' : 'never',
|
|
13
|
+
});
|
|
14
|
+
var result = [];
|
|
15
|
+
selections.forEach(function (_a) {
|
|
16
|
+
var segments = _a.segments, block = _a.block;
|
|
17
|
+
if (segments && ((includingFormatHolder && !block) || (block === null || block === void 0 ? void 0 : block.blockType) == 'Paragraph')) {
|
|
18
|
+
segments.forEach(function (segment) {
|
|
19
|
+
if (segment.segmentType != 'Entity' || !segment.entityFormat.isReadonly) {
|
|
20
|
+
result.push([segment, (block === null || block === void 0 ? void 0 : block.blockType) == 'Paragraph' ? block : null]);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get an array of selected segments from a content model
|
|
29
|
+
* @param model The Content Model to get selection from
|
|
30
|
+
* @param includingFormatHolder True means also include format holder as segment from list item
|
|
31
|
+
*/
|
|
32
|
+
export function getSelectedSegments(model, includingFormatHolder) {
|
|
33
|
+
return getSelectedSegmentsAndParagraphs(model, includingFormatHolder).map(function (x) { return x[0]; });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get any array of selected paragraphs from a content model
|
|
37
|
+
* @param model The Content Model to get selection from
|
|
38
|
+
*/
|
|
39
|
+
export function getSelectedParagraphs(model) {
|
|
40
|
+
var selections = collectSelections(model, { includeListFormatHolder: 'never' });
|
|
41
|
+
var result = [];
|
|
42
|
+
removeUnmeaningfulSelections(selections);
|
|
43
|
+
selections.forEach(function (_a) {
|
|
44
|
+
var block = _a.block;
|
|
45
|
+
if ((block === null || block === void 0 ? void 0 : block.blockType) == 'Paragraph') {
|
|
46
|
+
result.push(block);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get an array of block group - block pair that is of the expected block group type from selection
|
|
53
|
+
* @param model The Content Model to get selection from
|
|
54
|
+
* @param blockGroupTypes The expected block group types
|
|
55
|
+
* @param stopTypes Block group types that will stop searching when hit
|
|
56
|
+
* @param deepFirst True means search in deep first, otherwise wide first
|
|
57
|
+
*/
|
|
58
|
+
export function getOperationalBlocks(model, blockGroupTypes, stopTypes, deepFirst) {
|
|
59
|
+
var result = [];
|
|
60
|
+
var findSequence = deepFirst ? blockGroupTypes.map(function (type) { return [type]; }) : [blockGroupTypes];
|
|
61
|
+
var selections = collectSelections(model, {
|
|
62
|
+
includeListFormatHolder: 'never',
|
|
63
|
+
contentUnderSelectedTableCell: 'ignoreForTable', // When whole table is selected, we treat the table as a single block
|
|
64
|
+
});
|
|
65
|
+
removeUnmeaningfulSelections(selections);
|
|
66
|
+
selections.forEach(function (_a) {
|
|
67
|
+
var path = _a.path, block = _a.block;
|
|
68
|
+
var _loop_1 = function (i) {
|
|
69
|
+
var groupIndex = getClosestAncestorBlockGroupIndex(path, findSequence[i], stopTypes);
|
|
70
|
+
if (groupIndex >= 0) {
|
|
71
|
+
if (result.filter(function (x) { return x.block == path[groupIndex]; }).length <= 0) {
|
|
72
|
+
result.push({
|
|
73
|
+
parent: path[groupIndex + 1],
|
|
74
|
+
block: path[groupIndex],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return "break";
|
|
78
|
+
}
|
|
79
|
+
else if (i == findSequence.length - 1 && block) {
|
|
80
|
+
result.push({
|
|
81
|
+
parent: path[0],
|
|
82
|
+
block: block,
|
|
83
|
+
});
|
|
84
|
+
return "break";
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
for (var i = 0; i < findSequence.length; i++) {
|
|
88
|
+
var state_1 = _loop_1(i);
|
|
89
|
+
if (state_1 === "break")
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the first selected table from content model
|
|
97
|
+
* @param model The Content Model to get selection from
|
|
98
|
+
*/
|
|
99
|
+
export function getFirstSelectedTable(model) {
|
|
100
|
+
var selections = collectSelections(model, { includeListFormatHolder: 'never' });
|
|
101
|
+
var table;
|
|
102
|
+
var resultPath = [];
|
|
103
|
+
removeUnmeaningfulSelections(selections);
|
|
104
|
+
selections.forEach(function (_a) {
|
|
105
|
+
var block = _a.block, tableContext = _a.tableContext, path = _a.path;
|
|
106
|
+
if (!table) {
|
|
107
|
+
if ((block === null || block === void 0 ? void 0 : block.blockType) == 'Table') {
|
|
108
|
+
table = block;
|
|
109
|
+
resultPath = __spreadArray([], __read(path), false);
|
|
110
|
+
}
|
|
111
|
+
else if (tableContext === null || tableContext === void 0 ? void 0 : tableContext.table) {
|
|
112
|
+
table = tableContext.table;
|
|
113
|
+
var parent_1 = path.filter(function (group) { return group.blocks.indexOf(tableContext.table) >= 0; })[0];
|
|
114
|
+
var index = path.indexOf(parent_1);
|
|
115
|
+
resultPath = index >= 0 ? path.slice(index) : [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return [table, resultPath];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get the first selected list item from content model
|
|
123
|
+
* @param model The Content Model to get selection from
|
|
124
|
+
*/
|
|
125
|
+
export function getFirstSelectedListItem(model) {
|
|
126
|
+
var listItem;
|
|
127
|
+
getOperationalBlocks(model, ['ListItem'], ['TableCell']).forEach(function (r) {
|
|
128
|
+
if (!listItem && isBlockGroupOfType(r.block, 'ListItem')) {
|
|
129
|
+
listItem = r.block;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return listItem;
|
|
133
|
+
}
|
|
134
|
+
function collectSelections(model, option) {
|
|
135
|
+
var selections = [];
|
|
136
|
+
iterateSelections(model, function (path, tableContext, block, segments) {
|
|
137
|
+
selections.push({
|
|
138
|
+
path: path,
|
|
139
|
+
tableContext: tableContext,
|
|
140
|
+
block: block,
|
|
141
|
+
segments: segments,
|
|
142
|
+
});
|
|
143
|
+
}, option);
|
|
144
|
+
return selections;
|
|
145
|
+
}
|
|
146
|
+
function removeUnmeaningfulSelections(selections) {
|
|
147
|
+
if (selections.length > 1 &&
|
|
148
|
+
isOnlySelectionMarkerSelected(selections, false /*checkFirstParagraph*/)) {
|
|
149
|
+
selections.pop();
|
|
150
|
+
}
|
|
151
|
+
// Remove head paragraph if first selection marker is the only selection
|
|
152
|
+
if (selections.length > 1 &&
|
|
153
|
+
isOnlySelectionMarkerSelected(selections, true /*checkFirstParagraph*/)) {
|
|
154
|
+
selections.shift();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function isOnlySelectionMarkerSelected(selections, checkFirstParagraph) {
|
|
158
|
+
var _a;
|
|
159
|
+
var selection = selections[checkFirstParagraph ? 0 : selections.length - 1];
|
|
160
|
+
if (((_a = selection.block) === null || _a === void 0 ? void 0 : _a.blockType) == 'Paragraph' &&
|
|
161
|
+
selection.segments &&
|
|
162
|
+
selection.segments.length > 0) {
|
|
163
|
+
var allSegments = selection.block.segments;
|
|
164
|
+
var segment = selection.segments[0];
|
|
165
|
+
return (selection.segments.length == 1 &&
|
|
166
|
+
segment.segmentType == 'SelectionMarker' &&
|
|
167
|
+
segment == allSegments[checkFirstParagraph ? allSegments.length - 1 : 0]);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=collectSelections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectSelections.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/selection/collectSelections.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA8BxD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC5C,KAA2B,EAC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E,KAAK,CAAC,uBAAuB,CAAC,EAC1E;QACE,UAAU,CAAC,GAAG,EAAE,CAAC;KACpB;IAED,wEAAwE;IACxE,IACI,UAAU,CAAC,MAAM,GAAG,CAAC;QACrB,6BAA6B,CAAC,UAAU,EAAE,IAAI,CAAC,uBAAuB,CAAC,EACzE;QACE,UAAU,CAAC,KAAK,EAAE,CAAC;KACtB;AACL,CAAC;AAED,SAAS,6BAA6B,CAClC,UAA2B,EAC3B,mBAA4B;;IAE5B,IAAM,SAAS,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE9E,IACI,CAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,SAAS,KAAI,WAAW;QACzC,SAAS,CAAC,QAAQ;QAClB,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAC/B;QACE,IAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7C,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CACH,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;YAC9B,OAAO,CAAC,WAAW,IAAI,iBAAiB;YACxC,OAAO,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from '../model/getClosestAncestorBlockGroupIndex';\nimport { isBlockGroupOfType } from '../model/isBlockGroupOfType';\nimport { iterateSelections } from './iterateSelections';\nimport type { IterateSelectionsOption } from './iterateSelections';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelBlockGroupType,\n ContentModelDocument,\n ContentModelListItem,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelTable,\n TableSelectionContext,\n} from 'roosterjs-content-model-types';\nimport type { TypeOfBlockGroup } from '../model/getClosestAncestorBlockGroupIndex';\n\n/**\n * Represent a pair of parent block group and child block\n */\nexport type OperationalBlocks<T extends ContentModelBlockGroup> = {\n /**\n * The parent block group\n */\n parent: ContentModelBlockGroup;\n\n /**\n * The child block\n */\n block: ContentModelBlock | T;\n};\n\n/**\n * Get an array of selected parent paragraph and child segment pair\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null\n */\nexport function getSelectedSegmentsAndParagraphs(\n model: ContentModelDocument,\n includingFormatHolder: boolean\n): [ContentModelSegment, ContentModelParagraph | null][] {\n const selections = collectSelections(model, {\n includeListFormatHolder: includingFormatHolder ? 'allSegments' : 'never',\n });\n const result: [ContentModelSegment, ContentModelParagraph | null][] = [];\n\n selections.forEach(({ segments, block }) => {\n if (segments && ((includingFormatHolder && !block) || block?.blockType == 'Paragraph')) {\n segments.forEach(segment => {\n if (segment.segmentType != 'Entity' || !segment.entityFormat.isReadonly) {\n result.push([segment, block?.blockType == 'Paragraph' ? block : null]);\n }\n });\n }\n });\n\n return result;\n}\n\n/**\n * Get an array of selected segments from a content model\n * @param model The Content Model to get selection from\n * @param includingFormatHolder True means also include format holder as segment from list item\n */\nexport function getSelectedSegments(\n model: ContentModelDocument,\n includingFormatHolder: boolean\n): ContentModelSegment[] {\n return getSelectedSegmentsAndParagraphs(model, includingFormatHolder).map(x => x[0]);\n}\n\n/**\n * Get any array of selected paragraphs from a content model\n * @param model The Content Model to get selection from\n */\nexport function getSelectedParagraphs(model: ContentModelDocument): ContentModelParagraph[] {\n const selections = collectSelections(model, { includeListFormatHolder: 'never' });\n const result: ContentModelParagraph[] = [];\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ block }) => {\n if (block?.blockType == 'Paragraph') {\n result.push(block);\n }\n });\n\n return result;\n}\n\n/**\n * Get an array of block group - block pair that is of the expected block group type from selection\n * @param model The Content Model to get selection from\n * @param blockGroupTypes The expected block group types\n * @param stopTypes Block group types that will stop searching when hit\n * @param deepFirst True means search in deep first, otherwise wide first\n */\nexport function getOperationalBlocks<T extends ContentModelBlockGroup>(\n model: ContentModelDocument,\n blockGroupTypes: TypeOfBlockGroup<T>[],\n stopTypes: ContentModelBlockGroupType[],\n deepFirst?: boolean\n): OperationalBlocks<T>[] {\n const result: OperationalBlocks<T>[] = [];\n const findSequence = deepFirst ? blockGroupTypes.map(type => [type]) : [blockGroupTypes];\n const selections = collectSelections(model, {\n includeListFormatHolder: 'never',\n contentUnderSelectedTableCell: 'ignoreForTable', // When whole table is selected, we treat the table as a single block\n });\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ path, block }) => {\n for (let i = 0; i < findSequence.length; i++) {\n const groupIndex = getClosestAncestorBlockGroupIndex(path, findSequence[i], stopTypes);\n\n if (groupIndex >= 0) {\n if (result.filter(x => x.block == path[groupIndex]).length <= 0) {\n result.push({\n parent: path[groupIndex + 1],\n block: path[groupIndex] as T,\n });\n }\n break;\n } else if (i == findSequence.length - 1 && block) {\n result.push({\n parent: path[0],\n block: block,\n });\n break;\n }\n }\n });\n\n return result;\n}\n\n/**\n * Get the first selected table from content model\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedTable(\n model: ContentModelDocument\n): [ContentModelTable | undefined, ContentModelBlockGroup[]] {\n const selections = collectSelections(model, { includeListFormatHolder: 'never' });\n let table: ContentModelTable | undefined;\n let resultPath: ContentModelBlockGroup[] = [];\n\n removeUnmeaningfulSelections(selections);\n\n selections.forEach(({ block, tableContext, path }) => {\n if (!table) {\n if (block?.blockType == 'Table') {\n table = block;\n resultPath = [...path];\n } else if (tableContext?.table) {\n table = tableContext.table;\n\n const parent = path.filter(\n group => group.blocks.indexOf(tableContext.table) >= 0\n )[0];\n const index = path.indexOf(parent);\n resultPath = index >= 0 ? path.slice(index) : [];\n }\n }\n });\n\n return [table, resultPath];\n}\n\n/**\n * Get the first selected list item from content model\n * @param model The Content Model to get selection from\n */\nexport function getFirstSelectedListItem(\n model: ContentModelDocument\n): ContentModelListItem | undefined {\n let listItem: ContentModelListItem | undefined;\n\n getOperationalBlocks(model, ['ListItem'], ['TableCell']).forEach(r => {\n if (!listItem && isBlockGroupOfType<ContentModelListItem>(r.block, 'ListItem')) {\n listItem = r.block;\n }\n });\n\n return listItem;\n}\n\ninterface SelectionInfo {\n path: ContentModelBlockGroup[];\n segments?: ContentModelSegment[];\n block?: ContentModelBlock;\n tableContext?: TableSelectionContext;\n}\n\nfunction collectSelections(\n model: ContentModelDocument,\n option?: IterateSelectionsOption\n): SelectionInfo[] {\n const selections: SelectionInfo[] = [];\n\n iterateSelections(\n model,\n (path, tableContext, block, segments) => {\n selections.push({\n path,\n tableContext,\n block,\n segments,\n });\n },\n option\n );\n\n return selections;\n}\n\nfunction removeUnmeaningfulSelections(selections: SelectionInfo[]) {\n if (\n selections.length > 1 &&\n isOnlySelectionMarkerSelected(selections, false /*checkFirstParagraph*/)\n ) {\n selections.pop();\n }\n\n // Remove head paragraph if first selection marker is the only selection\n if (\n selections.length > 1 &&\n isOnlySelectionMarkerSelected(selections, true /*checkFirstParagraph*/)\n ) {\n selections.shift();\n }\n}\n\nfunction isOnlySelectionMarkerSelected(\n selections: SelectionInfo[],\n checkFirstParagraph: boolean\n): boolean {\n const selection = selections[checkFirstParagraph ? 0 : selections.length - 1];\n\n if (\n selection.block?.blockType == 'Paragraph' &&\n selection.segments &&\n selection.segments.length > 0\n ) {\n const allSegments = selection.block.segments;\n const segment = selection.segments[0];\n\n return (\n selection.segments.length == 1 &&\n segment.segmentType == 'SelectionMarker' &&\n segment == allSegments[checkFirstParagraph ? allSegments.length - 1 : 0]\n );\n } else {\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ContentModelBlock, FormatWithContentModelContext } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Delete a content model block from current selection
|
|
4
|
+
* @param blocks Array of the block to delete
|
|
5
|
+
* @param blockToDelete The block to delete
|
|
6
|
+
* @param replacement @optional If specified, use this block to replace the deleted block
|
|
7
|
+
* @param context @optional Context object provided by formatContentModel API
|
|
8
|
+
* @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.
|
|
9
|
+
* If not specified, only selected entity will be deleted
|
|
10
|
+
*/
|
|
11
|
+
export declare function deleteBlock(blocks: ContentModelBlock[], blockToDelete: ContentModelBlock, replacement?: ContentModelBlock, context?: FormatWithContentModelContext, direction?: 'forward' | 'backward'): boolean;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a content model block from current selection
|
|
3
|
+
* @param blocks Array of the block to delete
|
|
4
|
+
* @param blockToDelete The block to delete
|
|
5
|
+
* @param replacement @optional If specified, use this block to replace the deleted block
|
|
6
|
+
* @param context @optional Context object provided by formatContentModel API
|
|
7
|
+
* @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.
|
|
8
|
+
* If not specified, only selected entity will be deleted
|
|
9
|
+
*/
|
|
10
|
+
export function deleteBlock(blocks, blockToDelete, replacement, context, direction) {
|
|
11
|
+
var index = blocks.indexOf(blockToDelete);
|
|
12
|
+
switch (blockToDelete.blockType) {
|
|
13
|
+
case 'Table':
|
|
14
|
+
case 'Divider':
|
|
15
|
+
replacement ? blocks.splice(index, 1, replacement) : blocks.splice(index, 1);
|
|
16
|
+
return true;
|
|
17
|
+
case 'Entity':
|
|
18
|
+
var operation = blockToDelete.isSelected
|
|
19
|
+
? 'overwrite'
|
|
20
|
+
: direction == 'forward'
|
|
21
|
+
? 'removeFromStart'
|
|
22
|
+
: direction == 'backward'
|
|
23
|
+
? 'removeFromEnd'
|
|
24
|
+
: undefined;
|
|
25
|
+
if (operation !== undefined) {
|
|
26
|
+
replacement ? blocks.splice(index, 1, replacement) : blocks.splice(index, 1);
|
|
27
|
+
context === null || context === void 0 ? void 0 : context.deletedEntities.push({
|
|
28
|
+
entity: blockToDelete,
|
|
29
|
+
operation: operation,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
case 'BlockGroup':
|
|
34
|
+
switch (blockToDelete.blockGroupType) {
|
|
35
|
+
case 'General':
|
|
36
|
+
if (replacement) {
|
|
37
|
+
blocks.splice(index, 1, replacement);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// no op, let browser handle it
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
case 'ListItem':
|
|
45
|
+
case 'FormatContainer':
|
|
46
|
+
blocks.splice(index, 1);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=deleteBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/selection/deleteBlock.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACvB,MAA2B,EAC3B,aAAgC,EAChC,WAA+B,EAC/B,OAAuC,EACvC,SAAkC;IAElC,IAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C,QAAQ,aAAa,CAAC,SAAS,EAAE;QAC7B,KAAK,OAAO,CAAC;QACb,KAAK,SAAS;YACV,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC;QAEhB,KAAK,QAAQ;YACT,IAAM,SAAS,GAAuC,aAAa,CAAC,UAAU;gBAC1E,CAAC,CAAC,WAAW;gBACb,CAAC,CAAC,SAAS,IAAI,SAAS;oBACxB,CAAC,CAAC,iBAAiB;oBACnB,CAAC,CAAC,SAAS,IAAI,UAAU;wBACzB,CAAC,CAAC,eAAe;wBACjB,CAAC,CAAC,SAAS,CAAC;YAEhB,IAAI,SAAS,KAAK,SAAS,EAAE;gBACzB,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAC7E,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CAAC,IAAI,CAAC;oBAC1B,MAAM,EAAE,aAAa;oBACrB,SAAS,WAAA;iBACZ,CAAC,CAAC;aACN;YAED,OAAO,IAAI,CAAC;QAEhB,KAAK,YAAY;YACb,QAAQ,aAAa,CAAC,cAAc,EAAE;gBAClC,KAAK,SAAS;oBACV,IAAI,WAAW,EAAE;wBACb,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;wBACrC,OAAO,IAAI,CAAC;qBACf;yBAAM;wBACH,+BAA+B;wBAC/B,OAAO,KAAK,CAAC;qBAChB;gBAEL,KAAK,UAAU,CAAC;gBAChB,KAAK,iBAAiB;oBAClB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;oBACxB,OAAO,IAAI,CAAC;aACnB;KACR;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import type {\n ContentModelBlock,\n EntityRemovalOperation,\n FormatWithContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Delete a content model block from current selection\n * @param blocks Array of the block to delete\n * @param blockToDelete The block to delete\n * @param replacement @optional If specified, use this block to replace the deleted block\n * @param context @optional Context object provided by formatContentModel API\n * @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.\n * If not specified, only selected entity will be deleted\n */\nexport function deleteBlock(\n blocks: ContentModelBlock[],\n blockToDelete: ContentModelBlock,\n replacement?: ContentModelBlock,\n context?: FormatWithContentModelContext,\n direction?: 'forward' | 'backward'\n): boolean {\n const index = blocks.indexOf(blockToDelete);\n\n switch (blockToDelete.blockType) {\n case 'Table':\n case 'Divider':\n replacement ? blocks.splice(index, 1, replacement) : blocks.splice(index, 1);\n return true;\n\n case 'Entity':\n const operation: EntityRemovalOperation | undefined = blockToDelete.isSelected\n ? 'overwrite'\n : direction == 'forward'\n ? 'removeFromStart'\n : direction == 'backward'\n ? 'removeFromEnd'\n : undefined;\n\n if (operation !== undefined) {\n replacement ? blocks.splice(index, 1, replacement) : blocks.splice(index, 1);\n context?.deletedEntities.push({\n entity: blockToDelete,\n operation,\n });\n }\n\n return true;\n\n case 'BlockGroup':\n switch (blockToDelete.blockGroupType) {\n case 'General':\n if (replacement) {\n blocks.splice(index, 1, replacement);\n return true;\n } else {\n // no op, let browser handle it\n return false;\n }\n\n case 'ListItem':\n case 'FormatContainer':\n blocks.splice(index, 1);\n return true;\n }\n }\n\n return false;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentModelParagraph, ContentModelSegment, FormatWithContentModelContext } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Delete a content model segment from current selection
|
|
4
|
+
* @param paragraph Parent paragraph of the segment to delete
|
|
5
|
+
* @param segmentToDelete The segment to delete
|
|
6
|
+
* @param context @optional Context object provided by formatContentModel API
|
|
7
|
+
* @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.
|
|
8
|
+
* If not specified, only selected entity will be deleted
|
|
9
|
+
*/
|
|
10
|
+
export declare function deleteSegment(paragraph: ContentModelParagraph, segmentToDelete: ContentModelSegment, context?: FormatWithContentModelContext, direction?: 'forward' | 'backward'): boolean;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { deleteSingleChar } from '../../modelApi/edit/deleteSingleChar';
|
|
2
|
+
import { isWhiteSpacePreserved, normalizeSingleSegment } from 'roosterjs-content-model-dom';
|
|
3
|
+
import { normalizeText } from '../domUtils/stringUtil';
|
|
4
|
+
/**
|
|
5
|
+
* Delete a content model segment from current selection
|
|
6
|
+
* @param paragraph Parent paragraph of the segment to delete
|
|
7
|
+
* @param segmentToDelete The segment to delete
|
|
8
|
+
* @param context @optional Context object provided by formatContentModel API
|
|
9
|
+
* @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.
|
|
10
|
+
* If not specified, only selected entity will be deleted
|
|
11
|
+
*/
|
|
12
|
+
export function deleteSegment(paragraph, segmentToDelete, context, direction) {
|
|
13
|
+
var segments = paragraph.segments;
|
|
14
|
+
var index = segments.indexOf(segmentToDelete);
|
|
15
|
+
var preserveWhiteSpace = isWhiteSpacePreserved(paragraph);
|
|
16
|
+
var isForward = direction == 'forward';
|
|
17
|
+
var isBackward = direction == 'backward';
|
|
18
|
+
if (!preserveWhiteSpace) {
|
|
19
|
+
normalizePreviousSegment(segments, index);
|
|
20
|
+
}
|
|
21
|
+
switch (segmentToDelete.segmentType) {
|
|
22
|
+
case 'Br':
|
|
23
|
+
case 'Image':
|
|
24
|
+
case 'SelectionMarker':
|
|
25
|
+
segments.splice(index, 1);
|
|
26
|
+
return true;
|
|
27
|
+
case 'Entity':
|
|
28
|
+
var operation = segmentToDelete.isSelected
|
|
29
|
+
? 'overwrite'
|
|
30
|
+
: isForward
|
|
31
|
+
? 'removeFromStart'
|
|
32
|
+
: isBackward
|
|
33
|
+
? 'removeFromEnd'
|
|
34
|
+
: undefined;
|
|
35
|
+
if (operation !== undefined) {
|
|
36
|
+
segments.splice(index, 1);
|
|
37
|
+
context === null || context === void 0 ? void 0 : context.deletedEntities.push({
|
|
38
|
+
entity: segmentToDelete,
|
|
39
|
+
operation: operation,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
case 'Text':
|
|
44
|
+
var text = segmentToDelete.text;
|
|
45
|
+
if (text.length == 0 || segmentToDelete.isSelected) {
|
|
46
|
+
segments.splice(index, 1);
|
|
47
|
+
}
|
|
48
|
+
else if (direction) {
|
|
49
|
+
text = deleteSingleChar(text, isForward); // isForward ? text.substring(1) : text.substring(0, text.length - 1);
|
|
50
|
+
if (!preserveWhiteSpace) {
|
|
51
|
+
text = normalizeText(text, isForward);
|
|
52
|
+
}
|
|
53
|
+
if (text == '') {
|
|
54
|
+
segments.splice(index, 1);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
segmentToDelete.text = text;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
case 'General':
|
|
62
|
+
if (segmentToDelete.isSelected) {
|
|
63
|
+
segments.splice(index, 1);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// No op if a general segment is not selected, let browser handle general segment
|
|
68
|
+
// TODO: Need to revisit this
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function normalizePreviousSegment(segments, currentIndex) {
|
|
74
|
+
var _a;
|
|
75
|
+
var index = currentIndex - 1;
|
|
76
|
+
while (((_a = segments[index]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'SelectionMarker') {
|
|
77
|
+
index--;
|
|
78
|
+
}
|
|
79
|
+
var segment = segments[index];
|
|
80
|
+
if (segment) {
|
|
81
|
+
normalizeSingleSegment(segment);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=deleteSegment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteSegment.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/selection/deleteSegment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM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AI,CAAC,MAAM,IAAI,CAAC,IAAI,eAAe,CAAC,UAAU,EAAE;gBAChD,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aAC7B;iBAAM,IAAI,SAAS,EAAE;gBAClB,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,uEAAuE;gBAEjH,IAAI,CAAC,kBAAkB,EAAE;oBACrB,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;iBACzC;gBAED,IAAI,IAAI,IAAI,EAAE,EAAE;oBACZ,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC7B;qBAAM;oBACH,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC;iBAC/B;aACJ;YAED,OAAO,IAAI,CAAC;QAEhB,KAAK,SAAS;YACV,IAAI,eAAe,CAAC,UAAU,EAAE;gBAC5B,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAC1B,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,iFAAiF;gBACjF,6BAA6B;gBAC7B,OAAO,KAAK,CAAC;aAChB;KACR;AACL,CAAC;AAED,SAAS,wBAAwB,CAAC,QAA+B,EAAE,YAAoB;;IACnF,IAAI,KAAK,GAAG,YAAY,GAAG,CAAC,CAAC;IAE7B,OAAO,CAAA,MAAA,QAAQ,CAAC,KAAK,CAAC,0CAAE,WAAW,KAAI,iBAAiB,EAAE;QACtD,KAAK,EAAE,CAAC;KACX;IAED,IAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACT,sBAAsB,CAAC,OAAO,CAAC,CAAC;KACnC;AACL,CAAC","sourcesContent":["import { deleteSingleChar } from '../../modelApi/edit/deleteSingleChar';\nimport { isWhiteSpacePreserved, normalizeSingleSegment } from 'roosterjs-content-model-dom';\nimport { normalizeText } from '../domUtils/stringUtil';\nimport type {\n ContentModelParagraph,\n ContentModelSegment,\n EntityRemovalOperation,\n FormatWithContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Delete a content model segment from current selection\n * @param paragraph Parent paragraph of the segment to delete\n * @param segmentToDelete The segment to delete\n * @param context @optional Context object provided by formatContentModel API\n * @param direction @optional Whether this is deleting forward or backward. This is only used for deleting entity.\n * If not specified, only selected entity will be deleted\n */\nexport function deleteSegment(\n paragraph: ContentModelParagraph,\n segmentToDelete: ContentModelSegment,\n context?: FormatWithContentModelContext,\n direction?: 'forward' | 'backward'\n): boolean {\n const segments = paragraph.segments;\n const index = segments.indexOf(segmentToDelete);\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph);\n const isForward = direction == 'forward';\n const isBackward = direction == 'backward';\n\n if (!preserveWhiteSpace) {\n normalizePreviousSegment(segments, index);\n }\n\n switch (segmentToDelete.segmentType) {\n case 'Br':\n case 'Image':\n case 'SelectionMarker':\n segments.splice(index, 1);\n return true;\n\n case 'Entity':\n const operation: EntityRemovalOperation | undefined = segmentToDelete.isSelected\n ? 'overwrite'\n : isForward\n ? 'removeFromStart'\n : isBackward\n ? 'removeFromEnd'\n : undefined;\n if (operation !== undefined) {\n segments.splice(index, 1);\n context?.deletedEntities.push({\n entity: segmentToDelete,\n operation,\n });\n }\n\n return true;\n\n case 'Text':\n let text = segmentToDelete.text;\n\n if (text.length == 0 || segmentToDelete.isSelected) {\n segments.splice(index, 1);\n } else if (direction) {\n text = deleteSingleChar(text, isForward); // isForward ? text.substring(1) : text.substring(0, text.length - 1);\n\n if (!preserveWhiteSpace) {\n text = normalizeText(text, isForward);\n }\n\n if (text == '') {\n segments.splice(index, 1);\n } else {\n segmentToDelete.text = text;\n }\n }\n\n return true;\n\n case 'General':\n if (segmentToDelete.isSelected) {\n segments.splice(index, 1);\n return true;\n } else {\n // No op if a general segment is not selected, let browser handle general segment\n // TODO: Need to revisit this\n return false;\n }\n }\n}\n\nfunction normalizePreviousSegment(segments: ContentModelSegment[], currentIndex: number) {\n let index = currentIndex - 1;\n\n while (segments[index]?.segmentType == 'SelectionMarker') {\n index--;\n }\n\n const segment = segments[index];\n\n if (segment) {\n normalizeSingleSegment(segment);\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContentModelDocument, DeleteSelectionResult, DeleteSelectionStep, FormatWithContentModelContext } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Delete selected content from Content Model
|
|
4
|
+
* @param model The model to delete selected content from
|
|
5
|
+
* @param additionalSteps @optional Addition delete steps
|
|
6
|
+
* @param formatContext @optional A context object provided by formatContentModel API
|
|
7
|
+
* @returns A DeleteSelectionResult object to specify the deletion result
|
|
8
|
+
*/
|
|
9
|
+
export declare function deleteSelection(model: ContentModelDocument, additionalSteps?: (DeleteSelectionStep | null)[], formatContext?: FormatWithContentModelContext): DeleteSelectionResult;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { deleteExpandedSelection } from '../../modelApi/edit/deleteExpandedSelection';
|
|
3
|
+
/**
|
|
4
|
+
* Delete selected content from Content Model
|
|
5
|
+
* @param model The model to delete selected content from
|
|
6
|
+
* @param additionalSteps @optional Addition delete steps
|
|
7
|
+
* @param formatContext @optional A context object provided by formatContentModel API
|
|
8
|
+
* @returns A DeleteSelectionResult object to specify the deletion result
|
|
9
|
+
*/
|
|
10
|
+
export function deleteSelection(model, additionalSteps, formatContext) {
|
|
11
|
+
if (additionalSteps === void 0) { additionalSteps = []; }
|
|
12
|
+
var context = deleteExpandedSelection(model, formatContext);
|
|
13
|
+
additionalSteps.forEach(function (step) {
|
|
14
|
+
if (step &&
|
|
15
|
+
isValidDeleteSelectionContext(context) &&
|
|
16
|
+
context.deleteResult == 'notDeleted') {
|
|
17
|
+
step(context);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
mergeParagraphAfterDelete(context);
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
function isValidDeleteSelectionContext(context) {
|
|
24
|
+
return !!context.insertPoint;
|
|
25
|
+
}
|
|
26
|
+
// If we end up with multiple paragraphs impacted, we need to merge them
|
|
27
|
+
function mergeParagraphAfterDelete(context) {
|
|
28
|
+
var _a;
|
|
29
|
+
var insertPoint = context.insertPoint, deleteResult = context.deleteResult, lastParagraph = context.lastParagraph, lastTableContext = context.lastTableContext;
|
|
30
|
+
if (insertPoint &&
|
|
31
|
+
deleteResult != 'notDeleted' &&
|
|
32
|
+
deleteResult != 'nothingToDelete' &&
|
|
33
|
+
lastParagraph &&
|
|
34
|
+
lastParagraph != insertPoint.paragraph &&
|
|
35
|
+
lastTableContext == insertPoint.tableContext) {
|
|
36
|
+
(_a = insertPoint.paragraph.segments).push.apply(_a, __spreadArray([], __read(lastParagraph.segments), false));
|
|
37
|
+
lastParagraph.segments = [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=deleteSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/selection/deleteSelection.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAUtF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC3B,KAA2B,EAC3B,eAAoD,EACpD,aAA6C;IAD7C,gCAAA,EAAA,oBAAoD;IAGpD,IAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAE9D,eAAe,CAAC,OAAO,CAAC,UAAA,IAAI;QACxB,IACI,IAAI;YACJ,6BAA6B,CAAC,OAAO,CAAC;YACtC,OAAO,CAAC,YAAY,IAAI,YAAY,EACtC;YACE,IAAI,CAAC,OAAO,CAAC,CAAC;SACjB;IACL,CAAC,CAAC,CAAC;IAEH,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,6BAA6B,CAClC,OAA+B;IAE/B,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;AACjC,CAAC;AAED,wEAAwE;AACxE,SAAS,yBAAyB,CAAC,OAA+B;;IACtD,IAAA,WAAW,GAAoD,OAAO,YAA3D,EAAE,YAAY,GAAsC,OAAO,aAA7C,EAAE,aAAa,GAAuB,OAAO,cAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;IAE/E,IACI,WAAW;QACX,YAAY,IAAI,YAAY;QAC5B,YAAY,IAAI,iBAAiB;QACjC,aAAa;QACb,aAAa,IAAI,WAAW,CAAC,SAAS;QACtC,gBAAgB,IAAI,WAAW,CAAC,YAAY,EAC9C;QACE,CAAA,KAAA,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAA,CAAC,IAAI,oCAAI,aAAa,CAAC,QAAQ,WAAE;QAC/D,aAAa,CAAC,QAAQ,GAAG,EAAE,CAAC;KAC/B;AACL,CAAC","sourcesContent":["import { deleteExpandedSelection } from '../../modelApi/edit/deleteExpandedSelection';\nimport type {\n ContentModelDocument,\n DeleteSelectionContext,\n DeleteSelectionResult,\n DeleteSelectionStep,\n FormatWithContentModelContext,\n ValidDeleteSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * Delete selected content from Content Model\n * @param model The model to delete selected content from\n * @param additionalSteps @optional Addition delete steps\n * @param formatContext @optional A context object provided by formatContentModel API\n * @returns A DeleteSelectionResult object to specify the deletion result\n */\nexport function deleteSelection(\n model: ContentModelDocument,\n additionalSteps: (DeleteSelectionStep | null)[] = [],\n formatContext?: FormatWithContentModelContext\n): DeleteSelectionResult {\n const context = deleteExpandedSelection(model, formatContext);\n\n additionalSteps.forEach(step => {\n if (\n step &&\n isValidDeleteSelectionContext(context) &&\n context.deleteResult == 'notDeleted'\n ) {\n step(context);\n }\n });\n\n mergeParagraphAfterDelete(context);\n\n return context;\n}\n\nfunction isValidDeleteSelectionContext(\n context: DeleteSelectionContext\n): context is ValidDeleteSelectionContext {\n return !!context.insertPoint;\n}\n\n// If we end up with multiple paragraphs impacted, we need to merge them\nfunction mergeParagraphAfterDelete(context: DeleteSelectionContext) {\n const { insertPoint, deleteResult, lastParagraph, lastTableContext } = context;\n\n if (\n insertPoint &&\n deleteResult != 'notDeleted' &&\n deleteResult != 'nothingToDelete' &&\n lastParagraph &&\n lastParagraph != insertPoint.paragraph &&\n lastTableContext == insertPoint.tableContext\n ) {\n insertPoint.paragraph.segments.push(...lastParagraph.segments);\n lastParagraph.segments = [];\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DOMSelection } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get root node of a given DOM selection
|
|
4
|
+
* For table selection, root node is the selected table
|
|
5
|
+
* For image selection, root node is the selected image
|
|
6
|
+
* For range selection, root node is the common ancestor container node of the selection range
|
|
7
|
+
* @param selection The selection to get root node from
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSelectionRootNode(selection: DOMSelection | undefined): Node | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get root node of a given DOM selection
|
|
3
|
+
* For table selection, root node is the selected table
|
|
4
|
+
* For image selection, root node is the selected image
|
|
5
|
+
* For range selection, root node is the common ancestor container node of the selection range
|
|
6
|
+
* @param selection The selection to get root node from
|
|
7
|
+
*/
|
|
8
|
+
export function getSelectionRootNode(selection) {
|
|
9
|
+
return !selection
|
|
10
|
+
? undefined
|
|
11
|
+
: selection.type == 'range'
|
|
12
|
+
? selection.range.commonAncestorContainer
|
|
13
|
+
: selection.type == 'table'
|
|
14
|
+
? selection.table
|
|
15
|
+
: selection.type == 'image'
|
|
16
|
+
? selection.image
|
|
17
|
+
: undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=getSelectionRootNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectionRootNode.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-core/lib/publicApi/selection/getSelectionRootNode.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAmC;IACpE,OAAO,CAAC,SAAS;QACb,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC,IAAI,IAAI,OAAO;YAC3B,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,uBAAuB;YACzC,CAAC,CAAC,SAAS,CAAC,IAAI,IAAI,OAAO;gBAC3B,CAAC,CAAC,SAAS,CAAC,KAAK;gBACjB,CAAC,CAAC,SAAS,CAAC,IAAI,IAAI,OAAO;oBAC3B,CAAC,CAAC,SAAS,CAAC,KAAK;oBACjB,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC","sourcesContent":["import type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * Get root node of a given DOM selection\n * For table selection, root node is the selected table\n * For image selection, root node is the selected image\n * For range selection, root node is the common ancestor container node of the selection range\n * @param selection The selection to get root node from\n */\nexport function getSelectionRootNode(selection: DOMSelection | undefined): Node | undefined {\n return !selection\n ? undefined\n : selection.type == 'range'\n ? selection.range.commonAncestorContainer\n : selection.type == 'table'\n ? selection.table\n : selection.type == 'image'\n ? selection.image\n : undefined;\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ContentModelBlock, ContentModelBlockGroup, ContentModelSegment, TableSelectionContext } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for iterateSelections API
|
|
4
|
+
*/
|
|
5
|
+
export interface IterateSelectionsOption {
|
|
6
|
+
/**
|
|
7
|
+
* For selected table cell, this property determines how do we handle its content.
|
|
8
|
+
* include: No matter if table cell is selected, always invoke callback function for selected content (default value)
|
|
9
|
+
* ignoreForTable: When the whole table is selected we invoke callback for the table (using block parameter) but skip
|
|
10
|
+
* all its cells and content, otherwise keep invoking callback for table cell and content
|
|
11
|
+
* ignoreForTableOrCell: If whole table is selected, same with ignoreForTable, or if a table cell is selected, only
|
|
12
|
+
* invoke callback for the table cell itself but not for its content, otherwise keep invoking callback for content.
|
|
13
|
+
* @default include
|
|
14
|
+
*/
|
|
15
|
+
contentUnderSelectedTableCell?: 'include' | 'ignoreForTable' | 'ignoreForTableOrCell';
|
|
16
|
+
/**
|
|
17
|
+
* For a selected general element, this property determines how do we handle its content.
|
|
18
|
+
* contentOnly: (Default) When the whole general element is selected, we only invoke callback for its selected content
|
|
19
|
+
* generalElementOnly: When the whole general element is selected, we only invoke callback for the general element (using block or
|
|
20
|
+
* segment parameter depends on if it is a block or segment), but skip all its content.
|
|
21
|
+
* both: When general element is selected, we invoke callback first for its content, then for general element itself
|
|
22
|
+
*/
|
|
23
|
+
contentUnderSelectedGeneralElement?: 'contentOnly' | 'generalElementOnly' | 'both';
|
|
24
|
+
/**
|
|
25
|
+
* Whether call the callback for the list item format holder segment
|
|
26
|
+
* anySegment: call the callback if any segment is selected under a list item
|
|
27
|
+
* allSegments: call the callback only when all segments under the list item are selected
|
|
28
|
+
* never: never call the callback for list item format holder
|
|
29
|
+
* @default allSegments
|
|
30
|
+
*/
|
|
31
|
+
includeListFormatHolder?: 'anySegment' | 'allSegments' | 'never';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The callback function type for iterateSelections
|
|
35
|
+
* @param path The block group path of current selection
|
|
36
|
+
* @param tableContext Table context of current selection
|
|
37
|
+
* @param block Block of current selection
|
|
38
|
+
* @param segments Segments of current selection
|
|
39
|
+
* @returns True to stop iterating, otherwise keep going
|
|
40
|
+
*/
|
|
41
|
+
export declare type IterateSelectionsCallback = (path: ContentModelBlockGroup[], tableContext?: TableSelectionContext, block?: ContentModelBlock, segments?: ContentModelSegment[]) => void | boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Iterate all selected elements in a given model
|
|
44
|
+
* @param group The given Content Model to iterate selection from
|
|
45
|
+
* @param callback The callback function to access the selected element
|
|
46
|
+
* @param option Option to determine how to iterate
|
|
47
|
+
*/
|
|
48
|
+
export declare function iterateSelections(group: ContentModelBlockGroup, callback: IterateSelectionsCallback, option?: IterateSelectionsOption): void;
|