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
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
RoosterJS
|
|
2
|
+
Copyright (c) Microsoft Corporation
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE
|
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
[](https://github.com/microsoft/roosterjs/actions/workflows/build-and-deploy.yml)
|
|
2
|
+
|
|
3
|
+
# Rooster
|
|
4
|
+
|
|
5
|
+
Rooster is a framework-independent JavaScript rich-text editor neatly nested
|
|
6
|
+
inside one HTML `<div>` element. Editing operations performed by end users are
|
|
7
|
+
handled in simple ways to generate the final HTML.
|
|
8
|
+
|
|
9
|
+
To view the sample site, please click the link below:
|
|
10
|
+
|
|
11
|
+
[RoosterJs Sample Site](https://microsoft.github.io/roosterjs/index.html).
|
|
12
|
+
|
|
13
|
+
## Upgrade from RoosterJs 7.\*
|
|
14
|
+
|
|
15
|
+
Please see [here](https://github.com/microsoft/roosterjs/wiki/RoosterJs-8).
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
### Packages
|
|
20
|
+
|
|
21
|
+
Rooster contains 6 basic packages.
|
|
22
|
+
|
|
23
|
+
1. [roosterjs](https://microsoft.github.io/roosterjs/docs/modules/roosterjs.html):
|
|
24
|
+
A facade of all Rooster code for those who want a quick start. Use the
|
|
25
|
+
`createEditor()` function in roosterjs to create an editor with default
|
|
26
|
+
configurations.
|
|
27
|
+
|
|
28
|
+
2. [roosterjs-editor-core](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_core.html):
|
|
29
|
+
Defines the core editor and plugin infrastructure. Use `roosterjs-editor-core`
|
|
30
|
+
instead of `roosterjs` to build and customize your own editor.
|
|
31
|
+
|
|
32
|
+
3. [roosterjs-editor-api](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_api.html):
|
|
33
|
+
Defines APIs for editor operations. Use these APIs to modify content and
|
|
34
|
+
formatting in the editor you built using `roosterjs-editor-core`.
|
|
35
|
+
|
|
36
|
+
4. [roosterjs-editor-dom](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_dom.html):
|
|
37
|
+
Defines APIs for DOM operations. Use `roosterjs-editor-api` instead unless
|
|
38
|
+
you want to access DOM API directly.
|
|
39
|
+
|
|
40
|
+
5. [roosterjs-editor-plugins](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_plugins.html):
|
|
41
|
+
Defines basic plugins for common features. Examples: making hyperlinks,
|
|
42
|
+
pasting HTML content, inserting inline images.
|
|
43
|
+
|
|
44
|
+
6. [roosterjs-editor-types](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types.html):
|
|
45
|
+
Defines public interfaces and enumerations.
|
|
46
|
+
|
|
47
|
+
There are also some extension packages to provide additional functionalities.
|
|
48
|
+
|
|
49
|
+
1. [roosterjs-color-utils](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_color_utils.html):
|
|
50
|
+
Provide color transformation utility to make editor work under dark mode.
|
|
51
|
+
|
|
52
|
+
2. [roosterjs-react](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_react.html):
|
|
53
|
+
Provide a React wrapper of roosterjs so it can be easily used with React.
|
|
54
|
+
|
|
55
|
+
3. [roosterjs-editor-types-compatible](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types_compatible.html):
|
|
56
|
+
Provide types that are compatible with isolatedModules mode. When using isolatedModules mode,
|
|
57
|
+
"const enum" will not work correctly, this package provides enums with prefix "Compatible" in
|
|
58
|
+
their names and they have the same value with const enums in roosterjs-editor-types package
|
|
59
|
+
|
|
60
|
+
### APIs
|
|
61
|
+
|
|
62
|
+
Rooster provides DOM level APIs (in `roosterjs-editor-dom`), core APIs (in `roosterjs-editor-core`), and formatting APIs
|
|
63
|
+
(in `roosterjs-editor-api`) to perform editing operations.
|
|
64
|
+
|
|
65
|
+
`roosterjs-editor-dom` provides several levels of DOM operations:
|
|
66
|
+
|
|
67
|
+
- Perform basic DOM operations such as `wrap()`, `unwrap()`, ...
|
|
68
|
+
- Wrap a given DOM node with `InlineElement` or `BlockElement` and perform
|
|
69
|
+
operations with DOM Walker API.
|
|
70
|
+
- Perform DOM operations on a given scope using scopers.
|
|
71
|
+
- Travel among `InlineElements` and `BlockElements` with scope using
|
|
72
|
+
ContentTraverser API.
|
|
73
|
+
|
|
74
|
+
`roosterjs-editor-core` provides APIs for editor core. Editor class will call such
|
|
75
|
+
APIs to perform basic editor operations. These APIs are overridable by specifying
|
|
76
|
+
API overrides in Editor options when creating the editor.
|
|
77
|
+
|
|
78
|
+
`roosterjs-editor-api` provides APIs for scenario-based operations triggered by
|
|
79
|
+
user interaction.
|
|
80
|
+
|
|
81
|
+
## Plugins
|
|
82
|
+
|
|
83
|
+
Rooster supports plugins. You can use built-in plugins or build your own.
|
|
84
|
+
Plugins call APIs to communicate with the editor. When an operation is
|
|
85
|
+
performed by the user or when content is changed by code, the editor will
|
|
86
|
+
trigger events for the plugins to handle.
|
|
87
|
+
|
|
88
|
+
Here's a sample plugin which will show a dialog containing "Hello Rooster" when
|
|
89
|
+
an "a" is typed in the editor:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
class HelloRooster implements EditorPlugin {
|
|
93
|
+
getName() {
|
|
94
|
+
return 'HelloRooster';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
initialize(editor: IEditor) {}
|
|
98
|
+
|
|
99
|
+
dispose() {}
|
|
100
|
+
|
|
101
|
+
onPluginEvent(e: PluginEvent) {
|
|
102
|
+
if (e.eventType == PluginEventType.KeyPress && e.rawEvent.which == 65) {
|
|
103
|
+
alert('Hello Rooster');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Installation
|
|
110
|
+
|
|
111
|
+
Install via NPM or Yarn:
|
|
112
|
+
|
|
113
|
+
`yarn add roosterjs`
|
|
114
|
+
|
|
115
|
+
You can also install sub packages separately:
|
|
116
|
+
|
|
117
|
+
`yarn add roosterjs-editor-core`
|
|
118
|
+
|
|
119
|
+
`yarn add roosterjs-editor-api`
|
|
120
|
+
|
|
121
|
+
`...`
|
|
122
|
+
|
|
123
|
+
In order to run the code below, you may also need to install [webpack](https://webpack.js.org/):
|
|
124
|
+
|
|
125
|
+
`yarn add webpack -g`
|
|
126
|
+
|
|
127
|
+
## Usage
|
|
128
|
+
|
|
129
|
+
### A quick start
|
|
130
|
+
|
|
131
|
+
1. Create `editor.htm` which contains a DIV with some styles, buttons to handle some click events and a reference to rooster.js (update with the path to your rooster.js file):
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<html>
|
|
135
|
+
<body>
|
|
136
|
+
<div style="width: 500px; height: 400px; border: solid 1px black" id="contentDiv"></div>
|
|
137
|
+
<button id="buttonB">B</button> <button id="buttonI">I</button>
|
|
138
|
+
<button id="buttonU">U</button>
|
|
139
|
+
<script src="rooster.js"></script>
|
|
140
|
+
<script>
|
|
141
|
+
var contentDiv = document.getElementById('contentDiv');
|
|
142
|
+
var editor = roosterjs.createEditor(contentDiv);
|
|
143
|
+
|
|
144
|
+
editor.setContent('Welcome to <b>RoosterJs</b>!');
|
|
145
|
+
document.getElementById('buttonB').addEventListener('click', function () {
|
|
146
|
+
roosterjs.toggleBold(editor);
|
|
147
|
+
});
|
|
148
|
+
document.getElementById('buttonI').addEventListener('click', function () {
|
|
149
|
+
roosterjs.toggleItalic(editor);
|
|
150
|
+
});
|
|
151
|
+
document.getElementById('buttonU').addEventListener('click', function () {
|
|
152
|
+
roosterjs.toggleUnderline(editor);
|
|
153
|
+
});
|
|
154
|
+
</script>
|
|
155
|
+
</body>
|
|
156
|
+
</html>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
2. Navigate to editor.htm, you will see a editor shown in the page which includes buttons with bold, italic, underline
|
|
160
|
+
actions.
|
|
161
|
+
|
|
162
|
+
## Sample code
|
|
163
|
+
|
|
164
|
+
To view the sample site, please click [here](https://microsoft.github.io/roosterjs/index.html).
|
|
165
|
+
|
|
166
|
+
To build the sample site code yourself, follow these instructions:
|
|
167
|
+
|
|
168
|
+
1. Get dependencies using [yarn](https://yarnpkg.com) or [npm](https://www.npmjs.com/):
|
|
169
|
+
|
|
170
|
+
```cmd
|
|
171
|
+
yarn
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. Build the source code, and start the sample editor:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
yarn start
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
or
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
npm start
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Debugging
|
|
187
|
+
|
|
188
|
+
There are two options for debugging:
|
|
189
|
+
|
|
190
|
+
1. Debugging from VSCode
|
|
191
|
+
|
|
192
|
+
- Ensure the sample editor is running
|
|
193
|
+
- Set the breakpoints within VSCode
|
|
194
|
+
- Select "Debug app in Chrome" from the VSCode debugging configuration dropdown
|
|
195
|
+
<img src="/assets/readme-images/debug-in-VSCode.png" width="411" height="278"><br>
|
|
196
|
+
- Run the scenario that needs to be debugged
|
|
197
|
+
|
|
198
|
+
2. Debugging directly from the development tools within the web browser
|
|
199
|
+
- The directions for how to do this are specific to each web browser. By opening the developer
|
|
200
|
+
tools for the web browser that Rooster is running on, you will be able to set breakpoints in
|
|
201
|
+
the code and debug accordingly.
|
|
202
|
+
|
|
203
|
+
## Running tests
|
|
204
|
+
|
|
205
|
+
There are two ways that tests can be run:
|
|
206
|
+
|
|
207
|
+
1. Run all tests or a single test from VSCode<br>
|
|
208
|
+
- (Skip if running all tests) Ensure the file that you want to test is selected (ie: toggleBold.ts
|
|
209
|
+
or toggleBoldTest.ts)
|
|
210
|
+
- Select "Test all files" or "Test current file" from the VSCode debugging configuration dropdown
|
|
211
|
+
<img src="/assets/readme-images/test-in-VSCode.png" width="402" height="268">
|
|
212
|
+
2. Run all tests from command line
|
|
213
|
+
```
|
|
214
|
+
yarn test
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Dependencies
|
|
218
|
+
|
|
219
|
+
As a NodeJs package, RoosterJs has dependencies for runtime (specified in package.json under each sub
|
|
220
|
+
packages in "dependencies" section) and dependencies for build time (specified in package.json under
|
|
221
|
+
root path in "devDependencies" section).
|
|
222
|
+
|
|
223
|
+
For runtime dependencies, there are two parts:
|
|
224
|
+
|
|
225
|
+
- Internal dependencies (a RoosterJs package depends on other RoosterJs packages)
|
|
226
|
+
- External dependencies (RoosterJs depends on other NPM packages)
|
|
227
|
+
|
|
228
|
+
Currently we have very few external dependencies. Before adding any new dependency, we need to check:
|
|
229
|
+
|
|
230
|
+
1. What's the value of the new dependency and the code using the dependency bring into roosterjs?
|
|
231
|
+
If we add a new dependency and create our new API to just call into the dependency, that new API
|
|
232
|
+
doesn't actually bring too much value, and people who uses roosterjs in their project can do this
|
|
233
|
+
themselves in their code, and we should not add such dependency to people who don't really need it.
|
|
234
|
+
|
|
235
|
+
2. What's the dependency tree of the dependency?
|
|
236
|
+
If we introduce a new dependency which has a deep dependency tree, we need to be careful since it
|
|
237
|
+
means we are actually adding a lot of new dependencies and our code size may be increased a lot.
|
|
238
|
+
|
|
239
|
+
3. How much functionalities do we need from the dependency?
|
|
240
|
+
If the dependency provides a lot of functionalities but we actually only need a small piece of them,
|
|
241
|
+
we may need to consider other solutions, such as find another smaller one, or do it ourselves.
|
|
242
|
+
|
|
243
|
+
4. What's the license of the dependency?
|
|
244
|
+
A dependency package under MIT license is good to be used for RoosterJs. For other licenses, we need
|
|
245
|
+
to review and see if we can take it as a dependency.
|
|
246
|
+
|
|
247
|
+
If you still feel a new dependency is required after checking these questions, we can review it and
|
|
248
|
+
finally decide whether we should add the new dependency.
|
|
249
|
+
|
|
250
|
+
For build time dependencies, it is more flexible to add new dependencies since it won't increase runtime
|
|
251
|
+
code size or dependencies.
|
|
252
|
+
|
|
253
|
+
## More documentation
|
|
254
|
+
|
|
255
|
+
We are still working on more documentation in [roosterjs wiki](https://github.com/Microsoft/roosterjs/wiki) and [API reference](https://microsoft.github.io/roosterjs/docs/index.html).
|
|
256
|
+
|
|
257
|
+
## License - MIT
|
|
258
|
+
|
|
259
|
+
License
|
|
260
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
261
|
+
|
|
262
|
+
Licensed under the [MIT](LICENSE) License.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Possible change sources. Here are the predefined sources.
|
|
3
|
+
* It can also be other string if the change source can't fall into these sources.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ChangeSource: {
|
|
6
|
+
/**
|
|
7
|
+
* Content changed by auto link
|
|
8
|
+
*/
|
|
9
|
+
AutoLink: string;
|
|
10
|
+
/**
|
|
11
|
+
* Content changed by create link
|
|
12
|
+
*/
|
|
13
|
+
CreateLink: string;
|
|
14
|
+
/**
|
|
15
|
+
* Content changed by format
|
|
16
|
+
*/
|
|
17
|
+
Format: string;
|
|
18
|
+
/**
|
|
19
|
+
* Content changed by image resize
|
|
20
|
+
*/
|
|
21
|
+
ImageResize: string;
|
|
22
|
+
/**
|
|
23
|
+
* Content changed by paste
|
|
24
|
+
*/
|
|
25
|
+
Paste: string;
|
|
26
|
+
/**
|
|
27
|
+
* Content changed by setContent API
|
|
28
|
+
*/
|
|
29
|
+
SetContent: string;
|
|
30
|
+
/**
|
|
31
|
+
* Content changed by cut operation
|
|
32
|
+
*/
|
|
33
|
+
Cut: string;
|
|
34
|
+
/**
|
|
35
|
+
* Content changed by drag & drop operation
|
|
36
|
+
*/
|
|
37
|
+
Drop: string;
|
|
38
|
+
/**
|
|
39
|
+
* Insert a new entity into editor
|
|
40
|
+
*/
|
|
41
|
+
InsertEntity: string;
|
|
42
|
+
/**
|
|
43
|
+
* Editor is switched to dark mode, content color is changed
|
|
44
|
+
*/
|
|
45
|
+
SwitchToDarkMode: string;
|
|
46
|
+
/**
|
|
47
|
+
* Editor is switched to light mode, content color is changed
|
|
48
|
+
*/
|
|
49
|
+
SwitchToLightMode: string;
|
|
50
|
+
/**
|
|
51
|
+
* List chain reorganized numbers of lists
|
|
52
|
+
*/
|
|
53
|
+
ListChain: string;
|
|
54
|
+
/**
|
|
55
|
+
* Keyboard event, used by Content Model.
|
|
56
|
+
* Data of this event will be the key code number
|
|
57
|
+
*/
|
|
58
|
+
Keyboard: string;
|
|
59
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangeSource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Possible change sources. Here are the predefined sources.
|
|
6
|
+
* It can also be other string if the change source can't fall into these sources.
|
|
7
|
+
*/
|
|
8
|
+
exports.ChangeSource = {
|
|
9
|
+
/**
|
|
10
|
+
* Content changed by auto link
|
|
11
|
+
*/
|
|
12
|
+
AutoLink: 'AutoLink',
|
|
13
|
+
/**
|
|
14
|
+
* Content changed by create link
|
|
15
|
+
*/
|
|
16
|
+
CreateLink: 'CreateLink',
|
|
17
|
+
/**
|
|
18
|
+
* Content changed by format
|
|
19
|
+
*/
|
|
20
|
+
Format: 'Format',
|
|
21
|
+
/**
|
|
22
|
+
* Content changed by image resize
|
|
23
|
+
*/
|
|
24
|
+
ImageResize: 'ImageResize',
|
|
25
|
+
/**
|
|
26
|
+
* Content changed by paste
|
|
27
|
+
*/
|
|
28
|
+
Paste: 'Paste',
|
|
29
|
+
/**
|
|
30
|
+
* Content changed by setContent API
|
|
31
|
+
*/
|
|
32
|
+
SetContent: 'SetContent',
|
|
33
|
+
/**
|
|
34
|
+
* Content changed by cut operation
|
|
35
|
+
*/
|
|
36
|
+
Cut: 'Cut',
|
|
37
|
+
/**
|
|
38
|
+
* Content changed by drag & drop operation
|
|
39
|
+
*/
|
|
40
|
+
Drop: 'Drop',
|
|
41
|
+
/**
|
|
42
|
+
* Insert a new entity into editor
|
|
43
|
+
*/
|
|
44
|
+
InsertEntity: 'InsertEntity',
|
|
45
|
+
/**
|
|
46
|
+
* Editor is switched to dark mode, content color is changed
|
|
47
|
+
*/
|
|
48
|
+
SwitchToDarkMode: 'SwitchToDarkMode',
|
|
49
|
+
/**
|
|
50
|
+
* Editor is switched to light mode, content color is changed
|
|
51
|
+
*/
|
|
52
|
+
SwitchToLightMode: 'SwitchToLightMode',
|
|
53
|
+
/**
|
|
54
|
+
* List chain reorganized numbers of lists
|
|
55
|
+
*/
|
|
56
|
+
ListChain: 'ListChain',
|
|
57
|
+
/**
|
|
58
|
+
* Keyboard event, used by Content Model.
|
|
59
|
+
* Data of this event will be the key code number
|
|
60
|
+
*/
|
|
61
|
+
Keyboard: 'Keyboard',
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=ChangeSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangeSource.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/constants/ChangeSource.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,YAAY,GAAG;IACxB;;OAEG;IACH,QAAQ,EAAE,UAAU;IACpB;;OAEG;IACH,UAAU,EAAE,YAAY;IACxB;;OAEG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,WAAW,EAAE,aAAa;IAC1B;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,UAAU,EAAE,YAAY;IACxB;;OAEG;IACH,GAAG,EAAE,KAAK;IACV;;OAEG;IACH,IAAI,EAAE,MAAM;IACZ;;OAEG;IACH,YAAY,EAAE,cAAc;IAC5B;;OAEG;IACH,gBAAgB,EAAE,kBAAkB;IACpC;;OAEG;IACH,iBAAiB,EAAE,mBAAmB;IACtC;;OAEG;IACH,SAAS,EAAE,WAAW;IACtB;;;OAGG;IACH,QAAQ,EAAE,UAAU;CACvB,CAAC","sourcesContent":["/**\n * Possible change sources. Here are the predefined sources.\n * It can also be other string if the change source can't fall into these sources.\n */\nexport const ChangeSource = {\n /**\n * Content changed by auto link\n */\n AutoLink: 'AutoLink',\n /**\n * Content changed by create link\n */\n CreateLink: 'CreateLink',\n /**\n * Content changed by format\n */\n Format: 'Format',\n /**\n * Content changed by image resize\n */\n ImageResize: 'ImageResize',\n /**\n * Content changed by paste\n */\n Paste: 'Paste',\n /**\n * Content changed by setContent API\n */\n SetContent: 'SetContent',\n /**\n * Content changed by cut operation\n */\n Cut: 'Cut',\n /**\n * Content changed by drag & drop operation\n */\n Drop: 'Drop',\n /**\n * Insert a new entity into editor\n */\n InsertEntity: 'InsertEntity',\n /**\n * Editor is switched to dark mode, content color is changed\n */\n SwitchToDarkMode: 'SwitchToDarkMode',\n /**\n * Editor is switched to light mode, content color is changed\n */\n SwitchToLightMode: 'SwitchToLightMode',\n /**\n * List chain reorganized numbers of lists\n */\n ListChain: 'ListChain',\n /**\n * Keyboard event, used by Content Model.\n * Data of this event will be the key code number\n */\n Keyboard: 'Keyboard',\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CreateContentModel } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Create Content Model from DOM tree in this editor
|
|
5
|
+
* @param core The editor core object
|
|
6
|
+
* @param option The option to customize the behavior of DOM to Content Model conversion
|
|
7
|
+
* @param selectionOverride When passed, use this selection range instead of current selection in editor
|
|
8
|
+
*/
|
|
9
|
+
export declare const createContentModel: CreateContentModel;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContentModel = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var cloneModel_1 = require("../publicApi/model/cloneModel");
|
|
6
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* Create Content Model from DOM tree in this editor
|
|
10
|
+
* @param core The editor core object
|
|
11
|
+
* @param option The option to customize the behavior of DOM to Content Model conversion
|
|
12
|
+
* @param selectionOverride When passed, use this selection range instead of current selection in editor
|
|
13
|
+
*/
|
|
14
|
+
var createContentModel = function (core, option, selectionOverride) {
|
|
15
|
+
var cachedModel = selectionOverride ? null : core.cache.cachedModel;
|
|
16
|
+
if (cachedModel && core.lifecycle.shadowEditFragment) {
|
|
17
|
+
// When in shadow edit, use a cloned model so we won't pollute the cached one
|
|
18
|
+
cachedModel = (0, cloneModel_1.cloneModel)(cachedModel, { includeCachedElement: true });
|
|
19
|
+
}
|
|
20
|
+
if (cachedModel) {
|
|
21
|
+
return cachedModel;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
var selection = selectionOverride || core.api.getDOMSelection(core) || undefined;
|
|
25
|
+
var model = internalCreateContentModel(core, selection, option);
|
|
26
|
+
if (!option && !selectionOverride) {
|
|
27
|
+
core.cache.cachedModel = model;
|
|
28
|
+
core.cache.cachedSelection = selection;
|
|
29
|
+
}
|
|
30
|
+
return model;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.createContentModel = createContentModel;
|
|
34
|
+
function internalCreateContentModel(core, selection, option) {
|
|
35
|
+
var editorContext = core.api.createEditorContext(core);
|
|
36
|
+
var domToModelContext = option
|
|
37
|
+
? roosterjs_content_model_dom_1.createDomToModelContext.apply(void 0, (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([editorContext], (0, tslib_1.__read)((core.defaultDomToModelOptions || [])), false), [option], false)) : (0, roosterjs_content_model_dom_1.createDomToModelContextWithConfig)(core.defaultDomToModelConfig, editorContext);
|
|
38
|
+
return (0, roosterjs_content_model_dom_1.domToContentModel)(core.contentDiv, domToModelContext, selection);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=createContentModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContentModel.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createContentModel.ts"],"names":[],"mappings":";;;;AAAA,4DAA2D;AAC3D,2EAIqC;AASrC;;;;;;GAMG;AACI,IAAM,kBAAkB,GAAuB,UAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB;IAClF,IAAI,WAAW,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;IAEpE,IAAI,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE;QAClD,6EAA6E;QAC7E,WAAW,GAAG,IAAA,uBAAU,EAAC,WAAW,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;KACzE;IAED,IAAI,WAAW,EAAE;QACb,OAAO,WAAW,CAAC;KACtB;SAAM;QACH,IAAM,SAAS,GAAG,iBAAiB,IAAI,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC;QACnF,IAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAElE,IAAI,CAAC,MAAM,IAAI,CAAC,iBAAiB,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC;SAC1C;QAED,OAAO,KAAK,CAAC;KAChB;AACL,CAAC,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B;AAEF,SAAS,0BAA0B,CAC/B,IAAuC,EACvC,SAAwB,EACxB,MAAyB;IAEzB,IAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACzD,IAAM,iBAAiB,GAAG,MAAM;QAC5B,CAAC,CAAC,qDAAuB,sEAAC,aAAa,uBAAK,CAAC,IAAI,CAAC,wBAAwB,IAAI,EAAE,CAAC,YAAE,MAAM,WACzF,CAAC,CAAC,IAAA,+DAAiC,EAAC,IAAI,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;IAErF,OAAO,IAAA,+CAAiB,EAAC,IAAI,CAAC,UAAU,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { cloneModel } from '../publicApi/model/cloneModel';\nimport {\n createDomToModelContext,\n createDomToModelContextWithConfig,\n domToContentModel,\n} from 'roosterjs-content-model-dom';\nimport type { EditorCore } from 'roosterjs-editor-types';\nimport type {\n DOMSelection,\n DomToModelOption,\n CreateContentModel,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Create Content Model from DOM tree in this editor\n * @param core The editor core object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed, use this selection range instead of current selection in editor\n */\nexport const createContentModel: CreateContentModel = (core, option, selectionOverride) => {\n let cachedModel = selectionOverride ? null : core.cache.cachedModel;\n\n if (cachedModel && core.lifecycle.shadowEditFragment) {\n // When in shadow edit, use a cloned model so we won't pollute the cached one\n cachedModel = cloneModel(cachedModel, { includeCachedElement: true });\n }\n\n if (cachedModel) {\n return cachedModel;\n } else {\n const selection = selectionOverride || core.api.getDOMSelection(core) || undefined;\n const model = internalCreateContentModel(core, selection, option);\n\n if (!option && !selectionOverride) {\n core.cache.cachedModel = model;\n core.cache.cachedSelection = selection;\n }\n\n return model;\n }\n};\n\nfunction internalCreateContentModel(\n core: StandaloneEditorCore & EditorCore,\n selection?: DOMSelection,\n option?: DomToModelOption\n) {\n const editorContext = core.api.createEditorContext(core);\n const domToModelContext = option\n ? createDomToModelContext(editorContext, ...(core.defaultDomToModelOptions || []), option)\n : createDomToModelContextWithConfig(core.defaultDomToModelConfig, editorContext);\n\n return domToContentModel(core.contentDiv, domToModelContext, selection);\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEditorContext = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Create a EditorContext object used by ContentModel API
|
|
7
|
+
*/
|
|
8
|
+
var createEditorContext = function (core) {
|
|
9
|
+
var lifecycle = core.lifecycle, format = core.format, darkColorHandler = core.darkColorHandler, contentDiv = core.contentDiv, cache = core.cache;
|
|
10
|
+
var context = {
|
|
11
|
+
isDarkMode: lifecycle.isDarkMode,
|
|
12
|
+
defaultFormat: format.defaultFormat,
|
|
13
|
+
darkColorHandler: darkColorHandler,
|
|
14
|
+
addDelimiterForEntity: true,
|
|
15
|
+
allowCacheElement: true,
|
|
16
|
+
domIndexer: cache.domIndexer,
|
|
17
|
+
};
|
|
18
|
+
checkRootRtl(contentDiv, context);
|
|
19
|
+
checkZoomScale(contentDiv, context);
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
22
|
+
exports.createEditorContext = createEditorContext;
|
|
23
|
+
function checkZoomScale(element, context) {
|
|
24
|
+
var _a;
|
|
25
|
+
var originalWidth = ((_a = element === null || element === void 0 ? void 0 : element.getBoundingClientRect()) === null || _a === void 0 ? void 0 : _a.width) || 0;
|
|
26
|
+
var visualWidth = element.offsetWidth;
|
|
27
|
+
if (visualWidth > 0 && originalWidth > 0) {
|
|
28
|
+
context.zoomScale = Math.round((originalWidth / visualWidth) * 100) / 100;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function checkRootRtl(element, context) {
|
|
32
|
+
var _a;
|
|
33
|
+
var style = (_a = element === null || element === void 0 ? void 0 : element.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(element);
|
|
34
|
+
if ((style === null || style === void 0 ? void 0 : style.direction) == 'rtl') {
|
|
35
|
+
context.isRootRtl = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=createEditorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEditorContext.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/createEditorContext.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,IAAM,mBAAmB,GAAwB,UAAA,IAAI;IAChD,IAAA,SAAS,GAAkD,IAAI,UAAtD,EAAE,MAAM,GAA0C,IAAI,OAA9C,EAAE,gBAAgB,GAAwB,IAAI,iBAA5B,EAAE,UAAU,GAAY,IAAI,WAAhB,EAAE,KAAK,GAAK,IAAI,MAAT,CAAU;IAExE,IAAM,OAAO,GAAkB;QAC3B,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,gBAAgB,EAAE,gBAAgB;QAClC,qBAAqB,EAAE,IAAI;QAC3B,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,KAAK,CAAC,UAAU;KAC/B,CAAC;IAEF,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAClC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAhBW,QAAA,mBAAmB,uBAgB9B;AAEF,SAAS,cAAc,CAAC,OAAoB,EAAE,OAAsB;;IAChE,IAAM,aAAa,GAAG,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,qBAAqB,EAAE,0CAAE,KAAK,KAAI,CAAC,CAAC;IACnE,IAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAExC,IAAI,WAAW,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC,EAAE;QACtC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;KAC7E;AACL,CAAC;AAED,SAAS,YAAY,CAAC,OAAoB,EAAE,OAAsB;;IAC9D,IAAM,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAC,WAAW,0CAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5E,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,KAAI,KAAK,EAAE;QAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;KAC5B;AACL,CAAC","sourcesContent":["import type { EditorContext, CreateEditorContext } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Create a EditorContext object used by ContentModel API\n */\nexport const createEditorContext: CreateEditorContext = core => {\n const { lifecycle, format, darkColorHandler, contentDiv, cache } = core;\n\n const context: EditorContext = {\n isDarkMode: lifecycle.isDarkMode,\n defaultFormat: format.defaultFormat,\n darkColorHandler: darkColorHandler,\n addDelimiterForEntity: true,\n allowCacheElement: true,\n domIndexer: cache.domIndexer,\n };\n\n checkRootRtl(contentDiv, context);\n checkZoomScale(contentDiv, context);\n\n return context;\n};\n\nfunction checkZoomScale(element: HTMLElement, context: EditorContext) {\n const originalWidth = element?.getBoundingClientRect()?.width || 0;\n const visualWidth = element.offsetWidth;\n\n if (visualWidth > 0 && originalWidth > 0) {\n context.zoomScale = Math.round((originalWidth / visualWidth) * 100) / 100;\n }\n}\n\nfunction checkRootRtl(element: HTMLElement, context: EditorContext) {\n const style = element?.ownerDocument.defaultView?.getComputedStyle(element);\n\n if (style?.direction == 'rtl') {\n context.isRootRtl = true;\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FormatContentModel } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* The general API to do format change with Content Model
|
|
5
|
+
* It will grab a Content Model for current editor content, and invoke a callback function
|
|
6
|
+
* to do format change. Then according to the return value, write back the modified content model into editor.
|
|
7
|
+
* If there is cached model, it will be used and updated.
|
|
8
|
+
* @param core The StandaloneEditorCore object
|
|
9
|
+
* @param formatter Formatter function, see ContentModelFormatter
|
|
10
|
+
* @param options More options, see FormatWithContentModelOptions
|
|
11
|
+
*/
|
|
12
|
+
export declare const formatContentModel: FormatContentModel;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatContentModel = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ChangeSource_1 = require("../constants/ChangeSource");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* The general API to do format change with Content Model
|
|
9
|
+
* It will grab a Content Model for current editor content, and invoke a callback function
|
|
10
|
+
* to do format change. Then according to the return value, write back the modified content model into editor.
|
|
11
|
+
* If there is cached model, it will be used and updated.
|
|
12
|
+
* @param core The StandaloneEditorCore object
|
|
13
|
+
* @param formatter Formatter function, see ContentModelFormatter
|
|
14
|
+
* @param options More options, see FormatWithContentModelOptions
|
|
15
|
+
*/
|
|
16
|
+
var formatContentModel = function (core, formatter, options) {
|
|
17
|
+
var _a = options || {}, apiName = _a.apiName, onNodeCreated = _a.onNodeCreated, getChangeData = _a.getChangeData, changeSource = _a.changeSource, rawEvent = _a.rawEvent, selectionOverride = _a.selectionOverride;
|
|
18
|
+
var model = core.api.createContentModel(core, undefined /*option*/, selectionOverride);
|
|
19
|
+
var context = {
|
|
20
|
+
newEntities: [],
|
|
21
|
+
deletedEntities: [],
|
|
22
|
+
rawEvent: rawEvent,
|
|
23
|
+
newImages: [],
|
|
24
|
+
};
|
|
25
|
+
var selection;
|
|
26
|
+
if (formatter(model, context)) {
|
|
27
|
+
var writeBack = function () {
|
|
28
|
+
handleNewEntities(core, context);
|
|
29
|
+
handleDeletedEntities(core, context);
|
|
30
|
+
handleImages(core, context);
|
|
31
|
+
selection =
|
|
32
|
+
core.api.setContentModel(core, model, undefined /*options*/, onNodeCreated) ||
|
|
33
|
+
undefined;
|
|
34
|
+
handlePendingFormat(core, context, selection);
|
|
35
|
+
};
|
|
36
|
+
if (context.skipUndoSnapshot) {
|
|
37
|
+
writeBack();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
core.api.addUndoSnapshot(core, writeBack, null /*changeSource, passing undefined here to avoid triggering ContentChangedEvent. We will trigger it using it with Content Model below */, false /*canUndoByBackspace*/, {
|
|
41
|
+
formatApiName: apiName,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
var eventData = {
|
|
45
|
+
eventType: 7 /* ContentChanged */,
|
|
46
|
+
contentModel: context.clearModelCache ? undefined : model,
|
|
47
|
+
selection: context.clearModelCache ? undefined : selection,
|
|
48
|
+
source: changeSource || ChangeSource_1.ChangeSource.Format,
|
|
49
|
+
data: getChangeData === null || getChangeData === void 0 ? void 0 : getChangeData(),
|
|
50
|
+
additionalData: {
|
|
51
|
+
formatApiName: apiName,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
core.api.triggerEvent(core, eventData, true /*broadcast*/);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if (context.clearModelCache) {
|
|
58
|
+
core.cache.cachedModel = undefined;
|
|
59
|
+
core.cache.cachedSelection = undefined;
|
|
60
|
+
}
|
|
61
|
+
handlePendingFormat(core, context, core.api.getDOMSelection(core));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.formatContentModel = formatContentModel;
|
|
65
|
+
function handleNewEntities(core, context) {
|
|
66
|
+
// TODO: Ideally we can trigger NewEntity event here. But to be compatible with original editor code, we don't do it here for now.
|
|
67
|
+
// Once Content Model Editor can be standalone, we can change this behavior to move triggering NewEntity event code
|
|
68
|
+
// from EntityPlugin to here
|
|
69
|
+
if (core.lifecycle.isDarkMode) {
|
|
70
|
+
context.newEntities.forEach(function (entity) {
|
|
71
|
+
core.api.transformColor(core, entity.wrapper, true /*includeSelf*/, null /*callback*/, 0 /* LightToDark */);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// This is only used for compatibility with old editor
|
|
76
|
+
// TODO: Remove this map once we have standalone editor
|
|
77
|
+
var EntityOperationMap = {
|
|
78
|
+
overwrite: 6 /* Overwrite */,
|
|
79
|
+
removeFromEnd: 5 /* RemoveFromEnd */,
|
|
80
|
+
removeFromStart: 4 /* RemoveFromStart */,
|
|
81
|
+
};
|
|
82
|
+
function handleDeletedEntities(core, context) {
|
|
83
|
+
context.deletedEntities.forEach(function (_a) {
|
|
84
|
+
var _b = _a.entity, wrapper = _b.wrapper, _c = _b.entityFormat, id = _c.id, entityType = _c.entityType, isReadonly = _c.isReadonly, operation = _a.operation;
|
|
85
|
+
if (id && entityType) {
|
|
86
|
+
// TODO: Revisit this entity parameter for standalone editor, we may just directly pass ContentModelEntity object instead
|
|
87
|
+
var entity = {
|
|
88
|
+
id: id,
|
|
89
|
+
type: entityType,
|
|
90
|
+
isReadonly: !!isReadonly,
|
|
91
|
+
wrapper: wrapper,
|
|
92
|
+
};
|
|
93
|
+
core.api.triggerEvent(core, {
|
|
94
|
+
eventType: 15 /* EntityOperation */,
|
|
95
|
+
entity: entity,
|
|
96
|
+
operation: EntityOperationMap[operation],
|
|
97
|
+
rawEvent: context.rawEvent,
|
|
98
|
+
}, false /*broadcast*/);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function handleImages(core, context) {
|
|
103
|
+
if (context.newImages.length > 0) {
|
|
104
|
+
var viewport = core.getVisibleViewport();
|
|
105
|
+
if (viewport) {
|
|
106
|
+
var left = viewport.left, right = viewport.right;
|
|
107
|
+
var minMaxImageSize = 10;
|
|
108
|
+
var maxWidth_1 = Math.max(right - left, minMaxImageSize);
|
|
109
|
+
context.newImages.forEach(function (image) {
|
|
110
|
+
image.format.maxWidth = maxWidth_1 + "px";
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function handlePendingFormat(core, context, selection) {
|
|
116
|
+
var _a;
|
|
117
|
+
var pendingFormat = context.newPendingFormat == 'preserve'
|
|
118
|
+
? (_a = core.format.pendingFormat) === null || _a === void 0 ? void 0 : _a.format
|
|
119
|
+
: context.newPendingFormat;
|
|
120
|
+
if (pendingFormat && (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' && selection.range.collapsed) {
|
|
121
|
+
core.format.pendingFormat = {
|
|
122
|
+
format: (0, tslib_1.__assign)({}, pendingFormat),
|
|
123
|
+
posContainer: selection.range.startContainer,
|
|
124
|
+
posOffset: selection.range.startOffset,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=formatContentModel.js.map
|