roosterjs-content-model-core 0.21.3 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/coreApi/addUndoSnapshot.d.ts +11 -0
- package/lib/coreApi/addUndoSnapshot.js +30 -0
- package/lib/coreApi/addUndoSnapshot.js.map +1 -0
- package/lib/coreApi/attachDomEvent.d.ts +10 -0
- package/lib/coreApi/attachDomEvent.js +36 -0
- package/lib/coreApi/attachDomEvent.js.map +1 -0
- package/lib/coreApi/focus.d.ts +7 -0
- package/lib/coreApi/focus.js +23 -0
- package/lib/coreApi/focus.js.map +1 -0
- package/lib/coreApi/formatContentModel.js +46 -27
- package/lib/coreApi/formatContentModel.js.map +1 -1
- package/lib/coreApi/getDOMSelection.js +11 -27
- package/lib/coreApi/getDOMSelection.js.map +1 -1
- package/lib/coreApi/hasFocus.d.ts +8 -0
- package/lib/coreApi/hasFocus.js +15 -0
- package/lib/coreApi/hasFocus.js.map +1 -0
- package/lib/coreApi/restoreUndoSnapshot.d.ts +8 -0
- package/lib/coreApi/restoreUndoSnapshot.js +36 -0
- package/lib/coreApi/restoreUndoSnapshot.js.map +1 -0
- package/lib/coreApi/setContentModel.js +5 -7
- package/lib/coreApi/setContentModel.js.map +1 -1
- package/lib/coreApi/setDOMSelection.js +150 -30
- package/lib/coreApi/setDOMSelection.js.map +1 -1
- package/lib/coreApi/triggerEvent.d.ts +9 -0
- package/lib/coreApi/triggerEvent.js +37 -0
- package/lib/coreApi/triggerEvent.js.map +1 -0
- package/lib/corePlugin/ContentModelCopyPastePlugin.d.ts +7 -2
- package/lib/corePlugin/ContentModelCopyPastePlugin.js +68 -48
- package/lib/corePlugin/ContentModelCopyPastePlugin.js.map +1 -1
- package/lib/corePlugin/ContentModelFormatPlugin.js +1 -11
- package/lib/corePlugin/ContentModelFormatPlugin.js.map +1 -1
- package/lib/corePlugin/DOMEventPlugin.js +24 -17
- package/lib/corePlugin/DOMEventPlugin.js.map +1 -1
- package/lib/corePlugin/EntityPlugin.js +16 -4
- package/lib/corePlugin/EntityPlugin.js.map +1 -1
- package/lib/corePlugin/LifecyclePlugin.js +1 -10
- package/lib/corePlugin/LifecyclePlugin.js.map +1 -1
- package/lib/corePlugin/SelectionPlugin.js +89 -22
- package/lib/corePlugin/SelectionPlugin.js.map +1 -1
- package/lib/corePlugin/UndoPlugin.d.ts +8 -0
- package/lib/corePlugin/UndoPlugin.js +222 -0
- package/lib/corePlugin/UndoPlugin.js.map +1 -0
- package/lib/corePlugin/createStandaloneEditorCorePlugins.js +2 -0
- package/lib/corePlugin/createStandaloneEditorCorePlugins.js.map +1 -1
- package/lib/corePlugin/utils/applyDefaultFormat.js +1 -1
- package/lib/corePlugin/utils/applyDefaultFormat.js.map +1 -1
- package/lib/corePlugin/utils/deleteEmptyList.d.ts +7 -0
- package/lib/corePlugin/utils/deleteEmptyList.js +44 -0
- package/lib/corePlugin/utils/deleteEmptyList.js.map +1 -0
- package/lib/editor/SnapshotsManagerImpl.d.ts +6 -0
- package/lib/editor/SnapshotsManagerImpl.js +104 -0
- package/lib/editor/SnapshotsManagerImpl.js.map +1 -0
- package/lib/editor/createStandaloneEditorCore.js +2 -0
- package/lib/editor/createStandaloneEditorCore.js.map +1 -1
- package/lib/editor/standaloneCoreApiMap.js +12 -0
- package/lib/editor/standaloneCoreApiMap.js.map +1 -1
- package/lib/index.d.ts +12 -1
- package/lib/index.js +26 -1
- package/lib/index.js.map +1 -1
- package/lib/metadata/updateListMetadata.d.ts +7 -0
- package/lib/metadata/updateListMetadata.js +17 -1
- package/lib/metadata/updateListMetadata.js.map +1 -1
- package/lib/modelApi/edit/deleteExpandedSelection.js +2 -1
- package/lib/modelApi/edit/deleteExpandedSelection.js.map +1 -1
- package/lib/publicApi/color/transformColor.d.ts +9 -0
- package/lib/publicApi/color/transformColor.js +37 -0
- package/lib/publicApi/color/transformColor.js.map +1 -0
- package/lib/publicApi/domUtils/eventUtils.d.ts +7 -0
- package/lib/publicApi/domUtils/eventUtils.js +21 -1
- package/lib/publicApi/domUtils/eventUtils.js.map +1 -1
- package/lib/publicApi/domUtils/getSegmentTextFormat.d.ts +7 -0
- package/lib/publicApi/domUtils/getSegmentTextFormat.js +33 -0
- package/lib/publicApi/domUtils/getSegmentTextFormat.js.map +1 -0
- package/lib/publicApi/domUtils/readFile.d.ts +7 -0
- package/lib/publicApi/domUtils/readFile.js +23 -0
- package/lib/publicApi/domUtils/readFile.js.map +1 -0
- package/lib/publicApi/domUtils/tableCellUtils.d.ts +13 -0
- package/lib/publicApi/domUtils/tableCellUtils.js +57 -0
- package/lib/publicApi/domUtils/tableCellUtils.js.map +1 -0
- package/lib/publicApi/model/paste.d.ts +2 -2
- package/lib/publicApi/model/paste.js.map +1 -1
- package/lib/publicApi/selection/deleteSelection.js +1 -3
- package/lib/publicApi/selection/deleteSelection.js.map +1 -1
- package/lib/publicApi/selection/hasSelectionInBlock.d.ts +6 -0
- package/lib/publicApi/selection/hasSelectionInBlock.js +25 -0
- package/lib/publicApi/selection/hasSelectionInBlock.js.map +1 -0
- package/lib/publicApi/selection/hasSelectionInBlockGroup.d.ts +6 -0
- package/lib/publicApi/selection/hasSelectionInBlockGroup.js +18 -0
- package/lib/publicApi/selection/hasSelectionInBlockGroup.js.map +1 -0
- package/lib/publicApi/selection/hasSelectionInSegment.d.ts +6 -0
- package/lib/publicApi/selection/hasSelectionInSegment.js +13 -0
- package/lib/publicApi/selection/hasSelectionInSegment.js.map +1 -0
- package/lib/publicApi/table/getSelectedCells.d.ts +6 -0
- package/lib/publicApi/table/getSelectedCells.js +33 -0
- package/lib/publicApi/table/getSelectedCells.js.map +1 -0
- package/lib/publicApi/undo/redo.d.ts +6 -0
- package/lib/publicApi/undo/redo.js +17 -0
- package/lib/publicApi/undo/redo.js.map +1 -0
- package/lib/publicApi/undo/undo.d.ts +6 -0
- package/lib/publicApi/undo/undo.js +20 -0
- package/lib/publicApi/undo/undo.js.map +1 -0
- package/lib/utils/createSnapshotSelection.d.ts +5 -0
- package/lib/utils/createSnapshotSelection.js +92 -0
- package/lib/utils/createSnapshotSelection.js.map +1 -0
- package/lib/utils/extractClipboardItems.d.ts +9 -0
- package/lib/utils/extractClipboardItems.js +84 -0
- package/lib/utils/extractClipboardItems.js.map +1 -0
- package/lib/utils/restoreSnapshotColors.d.ts +5 -0
- package/lib/utils/restoreSnapshotColors.js +19 -0
- package/lib/utils/restoreSnapshotColors.js.map +1 -0
- package/lib/utils/restoreSnapshotHTML.d.ts +5 -0
- package/lib/utils/restoreSnapshotHTML.js +61 -0
- package/lib/utils/restoreSnapshotHTML.js.map +1 -0
- package/lib/utils/restoreSnapshotSelection.d.ts +5 -0
- package/lib/utils/restoreSnapshotSelection.js +72 -0
- package/lib/utils/restoreSnapshotSelection.js.map +1 -0
- package/lib-amd/coreApi/addUndoSnapshot.d.ts +11 -0
- package/lib-amd/coreApi/addUndoSnapshot.js +31 -0
- package/lib-amd/coreApi/addUndoSnapshot.js.map +1 -0
- package/lib-amd/coreApi/attachDomEvent.d.ts +10 -0
- package/lib-amd/coreApi/attachDomEvent.js +37 -0
- package/lib-amd/coreApi/attachDomEvent.js.map +1 -0
- package/lib-amd/coreApi/focus.d.ts +7 -0
- package/lib-amd/coreApi/focus.js +25 -0
- package/lib-amd/coreApi/focus.js.map +1 -0
- package/lib-amd/coreApi/formatContentModel.js +46 -27
- package/lib-amd/coreApi/formatContentModel.js.map +1 -1
- package/lib-amd/coreApi/getDOMSelection.js +11 -27
- package/lib-amd/coreApi/getDOMSelection.js.map +1 -1
- package/lib-amd/coreApi/hasFocus.d.ts +8 -0
- package/lib-amd/coreApi/hasFocus.js +17 -0
- package/lib-amd/coreApi/hasFocus.js.map +1 -0
- package/lib-amd/coreApi/restoreUndoSnapshot.d.ts +8 -0
- package/lib-amd/coreApi/restoreUndoSnapshot.js +34 -0
- package/lib-amd/coreApi/restoreUndoSnapshot.js.map +1 -0
- package/lib-amd/coreApi/setContentModel.js +5 -7
- package/lib-amd/coreApi/setContentModel.js.map +1 -1
- package/lib-amd/coreApi/setDOMSelection.js +148 -31
- package/lib-amd/coreApi/setDOMSelection.js.map +1 -1
- package/lib-amd/coreApi/triggerEvent.d.ts +9 -0
- package/lib-amd/coreApi/triggerEvent.js +39 -0
- package/lib-amd/coreApi/triggerEvent.js.map +1 -0
- package/lib-amd/corePlugin/ContentModelCopyPastePlugin.d.ts +7 -2
- package/lib-amd/corePlugin/ContentModelCopyPastePlugin.js +65 -48
- package/lib-amd/corePlugin/ContentModelCopyPastePlugin.js.map +1 -1
- package/lib-amd/corePlugin/ContentModelFormatPlugin.js +1 -11
- package/lib-amd/corePlugin/ContentModelFormatPlugin.js.map +1 -1
- package/lib-amd/corePlugin/DOMEventPlugin.js +24 -18
- package/lib-amd/corePlugin/DOMEventPlugin.js.map +1 -1
- package/lib-amd/corePlugin/EntityPlugin.js +16 -5
- package/lib-amd/corePlugin/EntityPlugin.js.map +1 -1
- package/lib-amd/corePlugin/LifecyclePlugin.js +1 -10
- package/lib-amd/corePlugin/LifecyclePlugin.js.map +1 -1
- package/lib-amd/corePlugin/SelectionPlugin.js +88 -23
- package/lib-amd/corePlugin/SelectionPlugin.js.map +1 -1
- package/lib-amd/corePlugin/UndoPlugin.d.ts +8 -0
- package/lib-amd/corePlugin/UndoPlugin.js +220 -0
- package/lib-amd/corePlugin/UndoPlugin.js.map +1 -0
- package/lib-amd/corePlugin/createStandaloneEditorCorePlugins.js +2 -1
- package/lib-amd/corePlugin/createStandaloneEditorCorePlugins.js.map +1 -1
- package/lib-amd/corePlugin/utils/applyDefaultFormat.js +1 -1
- package/lib-amd/corePlugin/utils/applyDefaultFormat.js.map +1 -1
- package/lib-amd/corePlugin/utils/deleteEmptyList.d.ts +7 -0
- package/lib-amd/corePlugin/utils/deleteEmptyList.js +43 -0
- package/lib-amd/corePlugin/utils/deleteEmptyList.js.map +1 -0
- package/lib-amd/editor/SnapshotsManagerImpl.d.ts +6 -0
- package/lib-amd/editor/SnapshotsManagerImpl.js +106 -0
- package/lib-amd/editor/SnapshotsManagerImpl.js.map +1 -0
- package/lib-amd/editor/createStandaloneEditorCore.js +2 -0
- package/lib-amd/editor/createStandaloneEditorCore.js.map +1 -1
- package/lib-amd/editor/standaloneCoreApiMap.js +7 -1
- package/lib-amd/editor/standaloneCoreApiMap.js.map +1 -1
- package/lib-amd/index.d.ts +12 -1
- package/lib-amd/index.js +15 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/metadata/updateListMetadata.d.ts +7 -0
- package/lib-amd/metadata/updateListMetadata.js +17 -1
- package/lib-amd/metadata/updateListMetadata.js.map +1 -1
- package/lib-amd/modelApi/edit/deleteExpandedSelection.js +2 -2
- package/lib-amd/modelApi/edit/deleteExpandedSelection.js.map +1 -1
- package/lib-amd/publicApi/color/transformColor.d.ts +9 -0
- package/lib-amd/publicApi/color/transformColor.js +39 -0
- package/lib-amd/publicApi/color/transformColor.js.map +1 -0
- package/lib-amd/publicApi/domUtils/eventUtils.d.ts +7 -0
- package/lib-amd/publicApi/domUtils/eventUtils.js +21 -1
- package/lib-amd/publicApi/domUtils/eventUtils.js.map +1 -1
- package/lib-amd/publicApi/domUtils/getSegmentTextFormat.d.ts +7 -0
- package/lib-amd/publicApi/domUtils/getSegmentTextFormat.js +35 -0
- package/lib-amd/publicApi/domUtils/getSegmentTextFormat.js.map +1 -0
- package/lib-amd/publicApi/domUtils/readFile.d.ts +7 -0
- package/lib-amd/publicApi/domUtils/readFile.js +25 -0
- package/lib-amd/publicApi/domUtils/readFile.js.map +1 -0
- package/lib-amd/publicApi/domUtils/tableCellUtils.d.ts +13 -0
- package/lib-amd/publicApi/domUtils/tableCellUtils.js +58 -0
- package/lib-amd/publicApi/domUtils/tableCellUtils.js.map +1 -0
- package/lib-amd/publicApi/model/paste.d.ts +2 -2
- package/lib-amd/publicApi/model/paste.js.map +1 -1
- package/lib-amd/publicApi/selection/deleteSelection.js +1 -3
- package/lib-amd/publicApi/selection/deleteSelection.js.map +1 -1
- package/lib-amd/publicApi/selection/hasSelectionInBlock.d.ts +6 -0
- package/lib-amd/publicApi/selection/hasSelectionInBlock.js +25 -0
- package/lib-amd/publicApi/selection/hasSelectionInBlock.js.map +1 -0
- package/lib-amd/publicApi/selection/hasSelectionInBlockGroup.d.ts +6 -0
- package/lib-amd/publicApi/selection/hasSelectionInBlockGroup.js +19 -0
- package/lib-amd/publicApi/selection/hasSelectionInBlockGroup.js.map +1 -0
- package/lib-amd/publicApi/selection/hasSelectionInSegment.d.ts +6 -0
- package/lib-amd/publicApi/selection/hasSelectionInSegment.js +14 -0
- package/lib-amd/publicApi/selection/hasSelectionInSegment.js.map +1 -0
- package/lib-amd/publicApi/table/getSelectedCells.d.ts +6 -0
- package/lib-amd/publicApi/table/getSelectedCells.js +34 -0
- package/lib-amd/publicApi/table/getSelectedCells.js.map +1 -0
- package/lib-amd/publicApi/undo/redo.d.ts +6 -0
- package/lib-amd/publicApi/undo/redo.js +19 -0
- package/lib-amd/publicApi/undo/redo.js.map +1 -0
- package/lib-amd/publicApi/undo/undo.d.ts +6 -0
- package/lib-amd/publicApi/undo/undo.js +22 -0
- package/lib-amd/publicApi/undo/undo.js.map +1 -0
- package/lib-amd/utils/createSnapshotSelection.d.ts +5 -0
- package/lib-amd/utils/createSnapshotSelection.js +93 -0
- package/lib-amd/utils/createSnapshotSelection.js.map +1 -0
- package/lib-amd/utils/extractClipboardItems.d.ts +9 -0
- package/lib-amd/utils/extractClipboardItems.js +85 -0
- package/lib-amd/utils/extractClipboardItems.js.map +1 -0
- package/lib-amd/utils/restoreSnapshotColors.d.ts +5 -0
- package/lib-amd/utils/restoreSnapshotColors.js +20 -0
- package/lib-amd/utils/restoreSnapshotColors.js.map +1 -0
- package/lib-amd/utils/restoreSnapshotHTML.d.ts +5 -0
- package/lib-amd/utils/restoreSnapshotHTML.js +62 -0
- package/lib-amd/utils/restoreSnapshotHTML.js.map +1 -0
- package/lib-amd/utils/restoreSnapshotSelection.d.ts +5 -0
- package/lib-amd/utils/restoreSnapshotSelection.js +73 -0
- package/lib-amd/utils/restoreSnapshotSelection.js.map +1 -0
- package/lib-mjs/coreApi/addUndoSnapshot.d.ts +11 -0
- package/lib-mjs/coreApi/addUndoSnapshot.js +26 -0
- package/lib-mjs/coreApi/addUndoSnapshot.js.map +1 -0
- package/lib-mjs/coreApi/attachDomEvent.d.ts +10 -0
- package/lib-mjs/coreApi/attachDomEvent.js +32 -0
- package/lib-mjs/coreApi/attachDomEvent.js.map +1 -0
- package/lib-mjs/coreApi/focus.d.ts +7 -0
- package/lib-mjs/coreApi/focus.js +19 -0
- package/lib-mjs/coreApi/focus.js.map +1 -0
- package/lib-mjs/coreApi/formatContentModel.js +46 -27
- package/lib-mjs/coreApi/formatContentModel.js.map +1 -1
- package/lib-mjs/coreApi/getDOMSelection.js +11 -27
- package/lib-mjs/coreApi/getDOMSelection.js.map +1 -1
- package/lib-mjs/coreApi/hasFocus.d.ts +8 -0
- package/lib-mjs/coreApi/hasFocus.js +11 -0
- package/lib-mjs/coreApi/hasFocus.js.map +1 -0
- package/lib-mjs/coreApi/restoreUndoSnapshot.d.ts +8 -0
- package/lib-mjs/coreApi/restoreUndoSnapshot.js +32 -0
- package/lib-mjs/coreApi/restoreUndoSnapshot.js.map +1 -0
- package/lib-mjs/coreApi/setContentModel.js +5 -7
- package/lib-mjs/coreApi/setContentModel.js.map +1 -1
- package/lib-mjs/coreApi/setDOMSelection.js +150 -30
- package/lib-mjs/coreApi/setDOMSelection.js.map +1 -1
- package/lib-mjs/coreApi/triggerEvent.d.ts +9 -0
- package/lib-mjs/coreApi/triggerEvent.js +33 -0
- package/lib-mjs/coreApi/triggerEvent.js.map +1 -0
- package/lib-mjs/corePlugin/ContentModelCopyPastePlugin.d.ts +7 -2
- package/lib-mjs/corePlugin/ContentModelCopyPastePlugin.js +66 -47
- package/lib-mjs/corePlugin/ContentModelCopyPastePlugin.js.map +1 -1
- package/lib-mjs/corePlugin/ContentModelFormatPlugin.js +2 -12
- package/lib-mjs/corePlugin/ContentModelFormatPlugin.js.map +1 -1
- package/lib-mjs/corePlugin/DOMEventPlugin.js +25 -18
- package/lib-mjs/corePlugin/DOMEventPlugin.js.map +1 -1
- package/lib-mjs/corePlugin/EntityPlugin.js +16 -4
- package/lib-mjs/corePlugin/EntityPlugin.js.map +1 -1
- package/lib-mjs/corePlugin/LifecyclePlugin.js +1 -10
- package/lib-mjs/corePlugin/LifecyclePlugin.js.map +1 -1
- package/lib-mjs/corePlugin/SelectionPlugin.js +89 -22
- package/lib-mjs/corePlugin/SelectionPlugin.js.map +1 -1
- package/lib-mjs/corePlugin/UndoPlugin.d.ts +8 -0
- package/lib-mjs/corePlugin/UndoPlugin.js +218 -0
- package/lib-mjs/corePlugin/UndoPlugin.js.map +1 -0
- package/lib-mjs/corePlugin/createStandaloneEditorCorePlugins.js +2 -0
- package/lib-mjs/corePlugin/createStandaloneEditorCorePlugins.js.map +1 -1
- package/lib-mjs/corePlugin/utils/applyDefaultFormat.js +1 -1
- package/lib-mjs/corePlugin/utils/applyDefaultFormat.js.map +1 -1
- package/lib-mjs/corePlugin/utils/deleteEmptyList.d.ts +7 -0
- package/lib-mjs/corePlugin/utils/deleteEmptyList.js +40 -0
- package/lib-mjs/corePlugin/utils/deleteEmptyList.js.map +1 -0
- package/lib-mjs/editor/SnapshotsManagerImpl.d.ts +6 -0
- package/lib-mjs/editor/SnapshotsManagerImpl.js +100 -0
- package/lib-mjs/editor/SnapshotsManagerImpl.js.map +1 -0
- package/lib-mjs/editor/createStandaloneEditorCore.js +2 -0
- package/lib-mjs/editor/createStandaloneEditorCore.js.map +1 -1
- package/lib-mjs/editor/standaloneCoreApiMap.js +12 -0
- package/lib-mjs/editor/standaloneCoreApiMap.js.map +1 -1
- package/lib-mjs/index.d.ts +12 -1
- package/lib-mjs/index.js +12 -1
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/metadata/updateListMetadata.d.ts +7 -0
- package/lib-mjs/metadata/updateListMetadata.js +15 -0
- package/lib-mjs/metadata/updateListMetadata.js.map +1 -1
- package/lib-mjs/modelApi/edit/deleteExpandedSelection.js +2 -1
- package/lib-mjs/modelApi/edit/deleteExpandedSelection.js.map +1 -1
- package/lib-mjs/publicApi/color/transformColor.d.ts +9 -0
- package/lib-mjs/publicApi/color/transformColor.js +33 -0
- package/lib-mjs/publicApi/color/transformColor.js.map +1 -0
- package/lib-mjs/publicApi/domUtils/eventUtils.d.ts +7 -0
- package/lib-mjs/publicApi/domUtils/eventUtils.js +19 -0
- package/lib-mjs/publicApi/domUtils/eventUtils.js.map +1 -1
- package/lib-mjs/publicApi/domUtils/getSegmentTextFormat.d.ts +7 -0
- package/lib-mjs/publicApi/domUtils/getSegmentTextFormat.js +29 -0
- package/lib-mjs/publicApi/domUtils/getSegmentTextFormat.js.map +1 -0
- package/lib-mjs/publicApi/domUtils/readFile.d.ts +7 -0
- package/lib-mjs/publicApi/domUtils/readFile.js +19 -0
- package/lib-mjs/publicApi/domUtils/readFile.js.map +1 -0
- package/lib-mjs/publicApi/domUtils/tableCellUtils.d.ts +13 -0
- package/lib-mjs/publicApi/domUtils/tableCellUtils.js +52 -0
- package/lib-mjs/publicApi/domUtils/tableCellUtils.js.map +1 -0
- package/lib-mjs/publicApi/model/paste.d.ts +2 -2
- package/lib-mjs/publicApi/model/paste.js.map +1 -1
- package/lib-mjs/publicApi/selection/deleteSelection.js +1 -3
- package/lib-mjs/publicApi/selection/deleteSelection.js.map +1 -1
- package/lib-mjs/publicApi/selection/hasSelectionInBlock.d.ts +6 -0
- package/lib-mjs/publicApi/selection/hasSelectionInBlock.js +22 -0
- package/lib-mjs/publicApi/selection/hasSelectionInBlock.js.map +1 -0
- package/lib-mjs/publicApi/selection/hasSelectionInBlockGroup.d.ts +6 -0
- package/lib-mjs/publicApi/selection/hasSelectionInBlockGroup.js +15 -0
- package/lib-mjs/publicApi/selection/hasSelectionInBlockGroup.js.map +1 -0
- package/lib-mjs/publicApi/selection/hasSelectionInSegment.d.ts +6 -0
- package/lib-mjs/publicApi/selection/hasSelectionInSegment.js +10 -0
- package/lib-mjs/publicApi/selection/hasSelectionInSegment.js.map +1 -0
- package/lib-mjs/publicApi/table/getSelectedCells.d.ts +6 -0
- package/lib-mjs/publicApi/table/getSelectedCells.js +29 -0
- package/lib-mjs/publicApi/table/getSelectedCells.js.map +1 -0
- package/lib-mjs/publicApi/undo/redo.d.ts +6 -0
- package/lib-mjs/publicApi/undo/redo.js +13 -0
- package/lib-mjs/publicApi/undo/redo.js.map +1 -0
- package/lib-mjs/publicApi/undo/undo.d.ts +6 -0
- package/lib-mjs/publicApi/undo/undo.js +16 -0
- package/lib-mjs/publicApi/undo/undo.js.map +1 -0
- package/lib-mjs/utils/createSnapshotSelection.d.ts +5 -0
- package/lib-mjs/utils/createSnapshotSelection.js +88 -0
- package/lib-mjs/utils/createSnapshotSelection.js.map +1 -0
- package/lib-mjs/utils/extractClipboardItems.d.ts +9 -0
- package/lib-mjs/utils/extractClipboardItems.js +80 -0
- package/lib-mjs/utils/extractClipboardItems.js.map +1 -0
- package/lib-mjs/utils/restoreSnapshotColors.d.ts +5 -0
- package/lib-mjs/utils/restoreSnapshotColors.js +15 -0
- package/lib-mjs/utils/restoreSnapshotColors.js.map +1 -0
- package/lib-mjs/utils/restoreSnapshotHTML.d.ts +5 -0
- package/lib-mjs/utils/restoreSnapshotHTML.js +57 -0
- package/lib-mjs/utils/restoreSnapshotHTML.js.map +1 -0
- package/lib-mjs/utils/restoreSnapshotSelection.d.ts +5 -0
- package/lib-mjs/utils/restoreSnapshotSelection.js +68 -0
- package/lib-mjs/utils/restoreSnapshotSelection.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AddUndoSnapshot } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Add an undo snapshot to current undo snapshot stack
|
|
5
|
+
* @param core The StandaloneEditorCore object
|
|
6
|
+
* @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
|
|
7
|
+
* @param entityStates @optional Entity states related to this snapshot.
|
|
8
|
+
* Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState
|
|
9
|
+
* when undo/redo to this snapshot
|
|
10
|
+
*/
|
|
11
|
+
export declare const addUndoSnapshot: AddUndoSnapshot;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addUndoSnapshot = void 0;
|
|
4
|
+
var createSnapshotSelection_1 = require("../utils/createSnapshotSelection");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Add an undo snapshot to current undo snapshot stack
|
|
8
|
+
* @param core The StandaloneEditorCore object
|
|
9
|
+
* @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
|
|
10
|
+
* @param entityStates @optional Entity states related to this snapshot.
|
|
11
|
+
* Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState
|
|
12
|
+
* when undo/redo to this snapshot
|
|
13
|
+
*/
|
|
14
|
+
var addUndoSnapshot = function (core, canUndoByBackspace, entityStates) {
|
|
15
|
+
var lifecycle = core.lifecycle, api = core.api, contentDiv = core.contentDiv, darkColorHandler = core.darkColorHandler, undo = core.undo;
|
|
16
|
+
if (!lifecycle.shadowEditFragment) {
|
|
17
|
+
var selection = api.getDOMSelection(core);
|
|
18
|
+
var snapshot = {
|
|
19
|
+
html: contentDiv.innerHTML,
|
|
20
|
+
knownColors: darkColorHandler.getKnownColorsCopy(),
|
|
21
|
+
entityStates: entityStates,
|
|
22
|
+
isDarkMode: !!lifecycle.isDarkMode,
|
|
23
|
+
selection: (0, createSnapshotSelection_1.createSnapshotSelection)(contentDiv, selection),
|
|
24
|
+
};
|
|
25
|
+
undo.snapshotsManager.addSnapshot(snapshot, !!canUndoByBackspace);
|
|
26
|
+
undo.snapshotsManager.hasNewContent = false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.addUndoSnapshot = addUndoSnapshot;
|
|
30
|
+
//# sourceMappingURL=addUndoSnapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addUndoSnapshot.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/addUndoSnapshot.ts"],"names":[],"mappings":";;;AAAA,4EAA2E;AAG3E;;;;;;;;GAQG;AACI,IAAM,eAAe,GAAoB,UAAC,IAAI,EAAE,kBAAkB,EAAE,YAAY;IAC3E,IAAA,SAAS,GAA8C,IAAI,UAAlD,EAAE,GAAG,GAAyC,IAAI,IAA7C,EAAE,UAAU,GAA6B,IAAI,WAAjC,EAAE,gBAAgB,GAAW,IAAI,iBAAf,EAAE,IAAI,GAAK,IAAI,KAAT,CAAU;IAEpE,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE;QAC/B,IAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAM,QAAQ,GAAa;YACvB,IAAI,EAAE,UAAU,CAAC,SAAS;YAC1B,WAAW,EAAE,gBAAgB,CAAC,kBAAkB,EAAE;YAClD,YAAY,cAAA;YACZ,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU;YAClC,SAAS,EAAE,IAAA,iDAAuB,EAAC,UAAU,EAAE,SAAS,CAAC;SAC5D,CAAC;QAEF,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,kBAAkB,CAAC,CAAC;QAClE,IAAI,CAAC,gBAAgB,CAAC,aAAa,GAAG,KAAK,CAAC;KAC/C;AACL,CAAC,CAAC;AAhBW,QAAA,eAAe,mBAgB1B","sourcesContent":["import { createSnapshotSelection } from '../utils/createSnapshotSelection';\nimport type { AddUndoSnapshot, Snapshot } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Add an undo snapshot to current undo snapshot stack\n * @param core The StandaloneEditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\nexport const addUndoSnapshot: AddUndoSnapshot = (core, canUndoByBackspace, entityStates) => {\n const { lifecycle, api, contentDiv, darkColorHandler, undo } = core;\n\n if (!lifecycle.shadowEditFragment) {\n const selection = api.getDOMSelection(core);\n const snapshot: Snapshot = {\n html: contentDiv.innerHTML,\n knownColors: darkColorHandler.getKnownColorsCopy(),\n entityStates,\n isDarkMode: !!lifecycle.isDarkMode,\n selection: createSnapshotSelection(contentDiv, selection),\n };\n\n undo.snapshotsManager.addSnapshot(snapshot, !!canUndoByBackspace);\n undo.snapshotsManager.hasNewContent = false;\n }\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AttachDomEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Attach a DOM event to the editor content DIV
|
|
5
|
+
* @param core The StandaloneEditorCore object
|
|
6
|
+
* @param eventName The DOM event name
|
|
7
|
+
* @param pluginEventType Optional event type. When specified, editor will trigger a plugin event with this name when the DOM event is triggered
|
|
8
|
+
* @param beforeDispatch Optional callback function to be invoked when the DOM event is triggered before trigger plugin event
|
|
9
|
+
*/
|
|
10
|
+
export declare const attachDomEvent: AttachDomEvent;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.attachDomEvent = void 0;
|
|
4
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Attach a DOM event to the editor content DIV
|
|
8
|
+
* @param core The StandaloneEditorCore object
|
|
9
|
+
* @param eventName The DOM event name
|
|
10
|
+
* @param pluginEventType Optional event type. When specified, editor will trigger a plugin event with this name when the DOM event is triggered
|
|
11
|
+
* @param beforeDispatch Optional callback function to be invoked when the DOM event is triggered before trigger plugin event
|
|
12
|
+
*/
|
|
13
|
+
var attachDomEvent = function (core, eventMap) {
|
|
14
|
+
var disposers = (0, roosterjs_content_model_dom_1.getObjectKeys)(eventMap || {}).map(function (key) {
|
|
15
|
+
var _a = eventMap[key], pluginEventType = _a.pluginEventType, beforeDispatch = _a.beforeDispatch;
|
|
16
|
+
var eventName = key;
|
|
17
|
+
var onEvent = function (event) {
|
|
18
|
+
if (beforeDispatch) {
|
|
19
|
+
beforeDispatch(event);
|
|
20
|
+
}
|
|
21
|
+
if (pluginEventType != null) {
|
|
22
|
+
core.api.triggerEvent(core, {
|
|
23
|
+
eventType: pluginEventType,
|
|
24
|
+
rawEvent: event,
|
|
25
|
+
}, false /*broadcast*/);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
core.contentDiv.addEventListener(eventName, onEvent);
|
|
29
|
+
return function () {
|
|
30
|
+
core.contentDiv.removeEventListener(eventName, onEvent);
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return function () { return disposers.forEach(function (disposers) { return disposers(); }); };
|
|
34
|
+
};
|
|
35
|
+
exports.attachDomEvent = attachDomEvent;
|
|
36
|
+
//# sourceMappingURL=attachDomEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachDomEvent.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/attachDomEvent.ts"],"names":[],"mappings":";;;AAAA,2EAA4D;AAI5D;;;;;;;GAOG;AACI,IAAM,cAAc,GAAmB,UAAC,IAAI,EAAE,QAAQ;IACzD,IAAM,SAAS,GAAG,IAAA,2CAAa,EAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAA,GAAG;QAC7C,IAAA,KAAsC,QAAQ,CAAC,GAAG,CAAC,EAAjD,eAAe,qBAAA,EAAE,cAAc,oBAAkB,CAAC;QAC1D,IAAM,SAAS,GAAG,GAAgC,CAAC;QACnD,IAAM,OAAO,GAAG,UAAC,KAA4C;YACzD,IAAI,cAAc,EAAE;gBAChB,cAAc,CAAC,KAAK,CAAC,CAAC;aACzB;YAED,IAAI,eAAe,IAAI,IAAI,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,YAAY,CACjB,IAAI,EACY;oBACZ,SAAS,EAAE,eAAe;oBAC1B,QAAQ,EAAE,KAAK;iBAClB,EACD,KAAK,CAAC,aAAa,CACtB,CAAC;aACL;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAErD,OAAO;YACH,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,cAAM,OAAA,SAAS,CAAC,OAAO,CAAC,UAAA,SAAS,IAAI,OAAA,SAAS,EAAE,EAAX,CAAW,CAAC,EAA3C,CAA2C,CAAC;AAC7D,CAAC,CAAC;AA7BW,QAAA,cAAc,kBA6BzB","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport type { AttachDomEvent } from 'roosterjs-content-model-types';\nimport type { PluginDomEvent } from 'roosterjs-editor-types';\n\n/**\n * @internal\n * Attach a DOM event to the editor content DIV\n * @param core The StandaloneEditorCore object\n * @param eventName The DOM event name\n * @param pluginEventType Optional event type. When specified, editor will trigger a plugin event with this name when the DOM event is triggered\n * @param beforeDispatch Optional callback function to be invoked when the DOM event is triggered before trigger plugin event\n */\nexport const attachDomEvent: AttachDomEvent = (core, eventMap) => {\n const disposers = getObjectKeys(eventMap || {}).map(key => {\n const { pluginEventType, beforeDispatch } = eventMap[key];\n const eventName = key as keyof HTMLElementEventMap;\n const onEvent = (event: HTMLElementEventMap[typeof eventName]) => {\n if (beforeDispatch) {\n beforeDispatch(event);\n }\n\n if (pluginEventType != null) {\n core.api.triggerEvent(\n core,\n <PluginDomEvent>{\n eventType: pluginEventType,\n rawEvent: event,\n },\n false /*broadcast*/\n );\n }\n };\n\n core.contentDiv.addEventListener(eventName, onEvent);\n\n return () => {\n core.contentDiv.removeEventListener(eventName, onEvent);\n };\n });\n\n return () => disposers.forEach(disposers => disposers());\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.focus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Focus to editor. If there is a cached selection range, use it as current selection
|
|
7
|
+
* @param core The StandaloneEditorCore object
|
|
8
|
+
*/
|
|
9
|
+
var focus = function (core) {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!core.lifecycle.shadowEditFragment) {
|
|
12
|
+
var api = core.api, selection = core.selection;
|
|
13
|
+
if (!api.hasFocus(core) && ((_a = selection.selection) === null || _a === void 0 ? void 0 : _a.type) == 'range') {
|
|
14
|
+
api.setDOMSelection(core, selection.selection, true /*skipSelectionChangedEvent*/);
|
|
15
|
+
}
|
|
16
|
+
// fallback, in case editor still have no focus
|
|
17
|
+
if (!core.api.hasFocus(core)) {
|
|
18
|
+
core.contentDiv.focus();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.focus = focus;
|
|
23
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/focus.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,IAAM,KAAK,GAAU,UAAA,IAAI;;IAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE;QAC5B,IAAA,GAAG,GAAgB,IAAI,IAApB,EAAE,SAAS,GAAK,IAAI,UAAT,CAAU;QAEhC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAA,MAAA,SAAS,CAAC,SAAS,0CAAE,IAAI,KAAI,OAAO,EAAE;YAC7D,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC;SACtF;QAED,+CAA+C;QAC/C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;SAC3B;KACJ;AACL,CAAC,CAAC;AAbW,QAAA,KAAK,SAahB","sourcesContent":["import type { Focus } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The StandaloneEditorCore object\n */\nexport const focus: Focus = core => {\n if (!core.lifecycle.shadowEditFragment) {\n const { api, selection } = core;\n\n if (!api.hasFocus(core) && selection.selection?.type == 'range') {\n api.setDOMSelection(core, selection.selection, true /*skipSelectionChangedEvent*/);\n }\n\n // fallback, in case editor still have no focus\n if (!core.api.hasFocus(core)) {\n core.contentDiv.focus();\n }\n }\n};\n"]}
|
|
@@ -14,7 +14,8 @@ var ChangeSource_1 = require("../constants/ChangeSource");
|
|
|
14
14
|
* @param options More options, see FormatWithContentModelOptions
|
|
15
15
|
*/
|
|
16
16
|
var formatContentModel = function (core, formatter, options) {
|
|
17
|
-
var _a
|
|
17
|
+
var _a;
|
|
18
|
+
var _b = options || {}, apiName = _b.apiName, onNodeCreated = _b.onNodeCreated, getChangeData = _b.getChangeData, changeSource = _b.changeSource, rawEvent = _b.rawEvent, selectionOverride = _b.selectionOverride;
|
|
18
19
|
var model = core.api.createContentModel(core, undefined /*option*/, selectionOverride);
|
|
19
20
|
var context = {
|
|
20
21
|
newEntities: [],
|
|
@@ -23,48 +24,53 @@ var formatContentModel = function (core, formatter, options) {
|
|
|
23
24
|
newImages: [],
|
|
24
25
|
};
|
|
25
26
|
var hasFocus = core.api.hasFocus(core);
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var changed = formatter(model, context);
|
|
28
|
+
var skipUndoSnapshot = context.skipUndoSnapshot, clearModelCache = context.clearModelCache, entityStates = context.entityStates, canUndoByBackspace = context.canUndoByBackspace;
|
|
29
|
+
if (changed) {
|
|
30
|
+
var isNested = core.undo.isNested;
|
|
31
|
+
var shouldAddSnapshot = !skipUndoSnapshot && !isNested;
|
|
32
|
+
var selection = void 0;
|
|
33
|
+
if (shouldAddSnapshot) {
|
|
34
|
+
core.undo.isNested = true;
|
|
35
|
+
if (core.undo.snapshotsManager.hasNewContent || entityStates) {
|
|
36
|
+
core.api.addUndoSnapshot(core, !!canUndoByBackspace);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
29
40
|
handleImages(core, context);
|
|
30
41
|
selection =
|
|
31
|
-
core.api.setContentModel(core, model, hasFocus ? undefined : { ignoreSelection: true }, // If editor did not have focus before format, do not set focus after format
|
|
32
|
-
onNodeCreated)
|
|
42
|
+
(_a = core.api.setContentModel(core, model, hasFocus ? undefined : { ignoreSelection: true }, // If editor did not have focus before format, do not set focus after format
|
|
43
|
+
onNodeCreated)) !== null && _a !== void 0 ? _a : undefined;
|
|
33
44
|
handlePendingFormat(core, context, selection);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
if (shouldAddSnapshot) {
|
|
46
|
+
core.api.addUndoSnapshot(core, !!canUndoByBackspace, entityStates);
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
49
|
+
finally {
|
|
50
|
+
if (!isNested) {
|
|
51
|
+
core.undo.isNested = false;
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
var eventData = {
|
|
44
55
|
eventType: 7 /* ContentChanged */,
|
|
45
|
-
contentModel:
|
|
46
|
-
selection:
|
|
56
|
+
contentModel: clearModelCache ? undefined : model,
|
|
57
|
+
selection: clearModelCache ? undefined : selection,
|
|
47
58
|
source: changeSource || ChangeSource_1.ChangeSource.Format,
|
|
48
59
|
data: getChangeData === null || getChangeData === void 0 ? void 0 : getChangeData(),
|
|
49
60
|
additionalData: {
|
|
50
61
|
formatApiName: apiName,
|
|
51
62
|
},
|
|
52
|
-
changedEntities: context
|
|
53
|
-
.map(function (entity) { return ({
|
|
54
|
-
entity: entity,
|
|
55
|
-
operation: 'newEntity',
|
|
56
|
-
rawEvent: rawEvent,
|
|
57
|
-
}); })
|
|
58
|
-
.concat(context.deletedEntities.map(function (entry) { return ({
|
|
59
|
-
entity: entry.entity,
|
|
60
|
-
operation: entry.operation,
|
|
61
|
-
rawEvent: rawEvent,
|
|
62
|
-
}); })),
|
|
63
|
+
changedEntities: getChangedEntities(context, rawEvent),
|
|
63
64
|
};
|
|
64
65
|
core.api.triggerEvent(core, eventData, true /*broadcast*/);
|
|
66
|
+
if (canUndoByBackspace && (selection === null || selection === void 0 ? void 0 : selection.type) == 'range') {
|
|
67
|
+
core.undo.snapshotsManager.hasNewContent = false;
|
|
68
|
+
core.undo.posContainer = selection.range.startContainer;
|
|
69
|
+
core.undo.posOffset = selection.range.startOffset;
|
|
70
|
+
}
|
|
65
71
|
}
|
|
66
72
|
else {
|
|
67
|
-
if (
|
|
73
|
+
if (clearModelCache) {
|
|
68
74
|
core.cache.cachedModel = undefined;
|
|
69
75
|
core.cache.cachedSelection = undefined;
|
|
70
76
|
}
|
|
@@ -98,4 +104,17 @@ function handlePendingFormat(core, context, selection) {
|
|
|
98
104
|
};
|
|
99
105
|
}
|
|
100
106
|
}
|
|
107
|
+
function getChangedEntities(context, rawEvent) {
|
|
108
|
+
return context.newEntities
|
|
109
|
+
.map(function (entity) { return ({
|
|
110
|
+
entity: entity,
|
|
111
|
+
operation: 'newEntity',
|
|
112
|
+
rawEvent: rawEvent,
|
|
113
|
+
}); })
|
|
114
|
+
.concat(context.deletedEntities.map(function (entry) { return ({
|
|
115
|
+
entity: entry.entity,
|
|
116
|
+
operation: entry.operation,
|
|
117
|
+
rawEvent: rawEvent,
|
|
118
|
+
}); }));
|
|
119
|
+
}
|
|
101
120
|
//# sourceMappingURL=formatContentModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatContentModel.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/formatContentModel.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AAWzD;;;;;;;;;GASG;AACI,IAAM,kBAAkB,GAAuB,UAAC,IAAI,EAAE,SAAS,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"formatContentModel.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/formatContentModel.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AAWzD;;;;;;;;;GASG;AACI,IAAM,kBAAkB,GAAuB,UAAC,IAAI,EAAE,SAAS,EAAE,OAAO;;IACrE,IAAA,KACF,OAAO,IAAI,EAAE,EADT,OAAO,aAAA,EAAE,aAAa,mBAAA,EAAE,aAAa,mBAAA,EAAE,YAAY,kBAAA,EAAE,QAAQ,cAAA,EAAE,iBAAiB,uBACvE,CAAC;IAElB,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IACzF,IAAM,OAAO,GAAkC;QAC3C,WAAW,EAAE,EAAE;QACf,eAAe,EAAE,EAAE;QACnB,QAAQ,UAAA;QACR,SAAS,EAAE,EAAE;KAChB,CAAC;IAEF,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEzC,IAAM,OAAO,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClC,IAAA,gBAAgB,GAAwD,OAAO,iBAA/D,EAAE,eAAe,GAAuC,OAAO,gBAA9C,EAAE,YAAY,GAAyB,OAAO,aAAhC,EAAE,kBAAkB,GAAK,OAAO,mBAAZ,CAAa;IAExF,IAAI,OAAO,EAAE;QACT,IAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QACpC,IAAM,iBAAiB,GAAG,CAAC,gBAAgB,IAAI,CAAC,QAAQ,CAAC;QACzD,IAAI,SAAS,SAA0B,CAAC;QAExC,IAAI,iBAAiB,EAAE;YACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YAE1B,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,IAAI,YAAY,EAAE;gBAC1D,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,kBAAkB,CAAC,CAAC;aACxD;SACJ;QAED,IAAI;YACA,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAE5B,SAAS;gBACL,MAAA,IAAI,CAAC,GAAG,CAAC,eAAe,CACpB,IAAI,EACJ,KAAK,EACL,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,4EAA4E;gBAC9H,aAAa,CAChB,mCAAI,SAAS,CAAC;YAEnB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;YAE9C,IAAI,iBAAiB,EAAE;gBACnB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;aACtE;SACJ;gBAAS;YACN,IAAI,CAAC,QAAQ,EAAE;gBACX,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;aAC9B;SACJ;QAED,IAAM,SAAS,GAAoC;YAC/C,SAAS,wBAAgC;YACzC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;YACjD,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YAClD,MAAM,EAAE,YAAY,IAAI,2BAAY,CAAC,MAAM;YAC3C,IAAI,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,EAAI;YACvB,cAAc,EAAE;gBACZ,aAAa,EAAE,OAAO;aACzB;YACD,eAAe,EAAE,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC;SACzD,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAE3D,IAAI,kBAAkB,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,OAAO,EAAE;YAClD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,GAAG,KAAK,CAAC;YACjD,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;YACxD,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC;SACrD;KACJ;SAAM;QACH,IAAI,eAAe,EAAE;YACjB,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC;YACnC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC;SAC1C;QAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;KACtE;AACL,CAAC,CAAC;AA/EW,QAAA,kBAAkB,sBA+E7B;AAEF,SAAS,YAAY,CAAC,IAA0B,EAAE,OAAsC;IACpF,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAEnD,IAAI,QAAQ,EAAE;YACF,IAAA,IAAI,GAAY,QAAQ,KAApB,EAAE,KAAK,GAAK,QAAQ,MAAb,CAAc;YACjC,IAAM,eAAe,GAAG,EAAE,CAAC;YAC3B,IAAM,UAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,eAAe,CAAC,CAAC;YACzD,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,UAAA,KAAK;gBAC3B,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAM,UAAQ,OAAI,CAAC;YAC5C,CAAC,CAAC,CAAC;SACN;KACJ;AACL,CAAC;AAED,SAAS,mBAAmB,CACxB,IAA0B,EAC1B,OAAsC,EACtC,SAA+B;;IAE/B,IAAM,aAAa,GACf,OAAO,CAAC,gBAAgB,IAAI,UAAU;QAClC,CAAC,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,aAAa,0CAAE,MAAM;QACnC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAEnC,IAAI,aAAa,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;QAC1E,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG;YACxB,MAAM,4BAAO,aAAa,CAAE;YAC5B,YAAY,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc;YAC5C,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW;SACzC,CAAC;KACL;AACL,CAAC;AAED,SAAS,kBAAkB,CACvB,OAAsC,EACtC,QAAgB;IAEhB,OAAO,OAAO,CAAC,WAAW;SACrB,GAAG,CACA,UAAC,MAAM,IAAoB,OAAA,CAAC;QACxB,MAAM,QAAA;QACN,SAAS,EAAE,WAAW;QACtB,QAAQ,UAAA;KACX,CAAC,EAJyB,CAIzB,CACL;SACA,MAAM,CACH,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,CAAC;QAClC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,UAAA;KACX,CAAC,EAJmC,CAInC,CAAC,CACN,CAAC;AACV,CAAC","sourcesContent":["import { ChangeSource } from '../constants/ChangeSource';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport type {\n ChangedEntity,\n ContentModelContentChangedEvent,\n DOMSelection,\n FormatContentModel,\n FormatWithContentModelContext,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The StandaloneEditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatWithContentModelOptions\n */\nexport const formatContentModel: FormatContentModel = (core, formatter, options) => {\n const { apiName, onNodeCreated, getChangeData, changeSource, rawEvent, selectionOverride } =\n options || {};\n\n const model = core.api.createContentModel(core, undefined /*option*/, selectionOverride);\n const context: FormatWithContentModelContext = {\n newEntities: [],\n deletedEntities: [],\n rawEvent,\n newImages: [],\n };\n\n const hasFocus = core.api.hasFocus(core);\n\n const changed = formatter(model, context);\n const { skipUndoSnapshot, clearModelCache, entityStates, canUndoByBackspace } = context;\n\n if (changed) {\n const isNested = core.undo.isNested;\n const shouldAddSnapshot = !skipUndoSnapshot && !isNested;\n let selection: DOMSelection | undefined;\n\n if (shouldAddSnapshot) {\n core.undo.isNested = true;\n\n if (core.undo.snapshotsManager.hasNewContent || entityStates) {\n core.api.addUndoSnapshot(core, !!canUndoByBackspace);\n }\n }\n\n try {\n handleImages(core, context);\n\n selection =\n core.api.setContentModel(\n core,\n model,\n hasFocus ? undefined : { ignoreSelection: true }, // If editor did not have focus before format, do not set focus after format\n onNodeCreated\n ) ?? undefined;\n\n handlePendingFormat(core, context, selection);\n\n if (shouldAddSnapshot) {\n core.api.addUndoSnapshot(core, !!canUndoByBackspace, entityStates);\n }\n } finally {\n if (!isNested) {\n core.undo.isNested = false;\n }\n }\n\n const eventData: ContentModelContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n contentModel: clearModelCache ? undefined : model,\n selection: clearModelCache ? undefined : selection,\n source: changeSource || ChangeSource.Format,\n data: getChangeData?.(),\n additionalData: {\n formatApiName: apiName,\n },\n changedEntities: getChangedEntities(context, rawEvent),\n };\n\n core.api.triggerEvent(core, eventData, true /*broadcast*/);\n\n if (canUndoByBackspace && selection?.type == 'range') {\n core.undo.snapshotsManager.hasNewContent = false;\n core.undo.posContainer = selection.range.startContainer;\n core.undo.posOffset = selection.range.startOffset;\n }\n } else {\n if (clearModelCache) {\n core.cache.cachedModel = undefined;\n core.cache.cachedSelection = undefined;\n }\n\n handlePendingFormat(core, context, core.api.getDOMSelection(core));\n }\n};\n\nfunction handleImages(core: StandaloneEditorCore, context: FormatWithContentModelContext) {\n if (context.newImages.length > 0) {\n const viewport = core.api.getVisibleViewport(core);\n\n if (viewport) {\n const { left, right } = viewport;\n const minMaxImageSize = 10;\n const maxWidth = Math.max(right - left, minMaxImageSize);\n context.newImages.forEach(image => {\n image.format.maxWidth = `${maxWidth}px`;\n });\n }\n }\n}\n\nfunction handlePendingFormat(\n core: StandaloneEditorCore,\n context: FormatWithContentModelContext,\n selection?: DOMSelection | null\n) {\n const pendingFormat =\n context.newPendingFormat == 'preserve'\n ? core.format.pendingFormat?.format\n : context.newPendingFormat;\n\n if (pendingFormat && selection?.type == 'range' && selection.range.collapsed) {\n core.format.pendingFormat = {\n format: { ...pendingFormat },\n posContainer: selection.range.startContainer,\n posOffset: selection.range.startOffset,\n };\n }\n}\n\nfunction getChangedEntities(\n context: FormatWithContentModelContext,\n rawEvent?: Event\n): ChangedEntity[] {\n return context.newEntities\n .map(\n (entity): ChangedEntity => ({\n entity,\n operation: 'newEntity',\n rawEvent,\n })\n )\n .concat(\n context.deletedEntities.map(entry => ({\n entity: entry.entity,\n operation: entry.operation,\n rawEvent,\n }))\n );\n}\n"]}
|
|
@@ -6,36 +6,20 @@ exports.getDOMSelection = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
var getDOMSelection = function (core) {
|
|
8
8
|
var _a;
|
|
9
|
-
return
|
|
9
|
+
return core.lifecycle.shadowEditFragment
|
|
10
|
+
? null
|
|
11
|
+
: (_a = core.selection.selection) !== null && _a !== void 0 ? _a : getNewSelection(core);
|
|
10
12
|
};
|
|
11
13
|
exports.getDOMSelection = getDOMSelection;
|
|
12
14
|
function getNewSelection(core) {
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
var selection = (_a = core.contentDiv.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
17
|
+
var range = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
|
|
18
|
+
return range && core.contentDiv.contains(range.commonAncestorContainer)
|
|
19
|
+
? {
|
|
17
20
|
type: 'range',
|
|
18
|
-
range:
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
else if (rangeEx.type == 1 /* TableSelection */ && rangeEx.coordinates) {
|
|
22
|
-
return {
|
|
23
|
-
type: 'table',
|
|
24
|
-
table: rangeEx.table,
|
|
25
|
-
firstColumn: rangeEx.coordinates.firstCell.x,
|
|
26
|
-
lastColumn: rangeEx.coordinates.lastCell.x,
|
|
27
|
-
firstRow: rangeEx.coordinates.firstCell.y,
|
|
28
|
-
lastRow: rangeEx.coordinates.lastCell.y,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
else if (rangeEx.type == 2 /* ImageSelection */) {
|
|
32
|
-
return {
|
|
33
|
-
type: 'image',
|
|
34
|
-
image: rangeEx.image,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
21
|
+
range: range,
|
|
22
|
+
}
|
|
23
|
+
: null;
|
|
40
24
|
}
|
|
41
25
|
//# sourceMappingURL=getDOMSelection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDOMSelection.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/getDOMSelection.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getDOMSelection.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/getDOMSelection.ts"],"names":[],"mappings":";;;AAMA;;GAEG;AACI,IAAM,eAAe,GAAoB,UAAA,IAAI;;IAChD,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB;QACpC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAA,IAAI,CAAC,SAAS,CAAC,SAAS,mCAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEF,SAAS,eAAe,CAAC,IAA0B;;IAC/C,IAAM,SAAS,GAAG,MAAA,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,0CAAE,YAAY,EAAE,CAAC;IAC5E,IAAM,KAAK,GAAG,SAAS,IAAI,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAErF,OAAO,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,uBAAuB,CAAC;QACnE,CAAC,CAAC;YACI,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,KAAK;SACf;QACH,CAAC,CAAC,IAAI,CAAC;AACf,CAAC","sourcesContent":["import type {\n DOMSelection,\n GetDOMSelection,\n StandaloneEditorCore,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const getDOMSelection: GetDOMSelection = core => {\n return core.lifecycle.shadowEditFragment\n ? null\n : core.selection.selection ?? getNewSelection(core);\n};\n\nfunction getNewSelection(core: StandaloneEditorCore): DOMSelection | null {\n const selection = core.contentDiv.ownerDocument.defaultView?.getSelection();\n const range = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;\n\n return range && core.contentDiv.contains(range.commonAncestorContainer)\n ? {\n type: 'range',\n range: range,\n }\n : null;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HasFocus } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Check if the editor has focus now
|
|
5
|
+
* @param core The StandaloneEditorCore object
|
|
6
|
+
* @returns True if the editor has focus, otherwise false
|
|
7
|
+
*/
|
|
8
|
+
export declare const hasFocus: HasFocus;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasFocus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Check if the editor has focus now
|
|
7
|
+
* @param core The StandaloneEditorCore object
|
|
8
|
+
* @returns True if the editor has focus, otherwise false
|
|
9
|
+
*/
|
|
10
|
+
var hasFocus = function (core) {
|
|
11
|
+
var activeElement = core.contentDiv.ownerDocument.activeElement;
|
|
12
|
+
return !!(activeElement && core.contentDiv.contains(activeElement));
|
|
13
|
+
};
|
|
14
|
+
exports.hasFocus = hasFocus;
|
|
15
|
+
//# sourceMappingURL=hasFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasFocus.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/hasFocus.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,IAAM,QAAQ,GAAa,UAAA,IAAI;IAClC,IAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC;IAClE,OAAO,CAAC,CAAC,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC;AAHW,QAAA,QAAQ,YAGnB","sourcesContent":["import type { HasFocus } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Check if the editor has focus now\n * @param core The StandaloneEditorCore object\n * @returns True if the editor has focus, otherwise false\n */\nexport const hasFocus: HasFocus = core => {\n const activeElement = core.contentDiv.ownerDocument.activeElement;\n return !!(activeElement && core.contentDiv.contains(activeElement));\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RestoreUndoSnapshot } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Restore an undo snapshot into editor
|
|
5
|
+
* @param core The editor core object
|
|
6
|
+
* @param step Steps to move, can be 0, positive or negative
|
|
7
|
+
*/
|
|
8
|
+
export declare const restoreUndoSnapshot: RestoreUndoSnapshot;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.restoreUndoSnapshot = void 0;
|
|
4
|
+
var ChangeSource_1 = require("../constants/ChangeSource");
|
|
5
|
+
var restoreSnapshotColors_1 = require("../utils/restoreSnapshotColors");
|
|
6
|
+
var restoreSnapshotHTML_1 = require("../utils/restoreSnapshotHTML");
|
|
7
|
+
var restoreSnapshotSelection_1 = require("../utils/restoreSnapshotSelection");
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
* Restore an undo snapshot into editor
|
|
11
|
+
* @param core The editor core object
|
|
12
|
+
* @param step Steps to move, can be 0, positive or negative
|
|
13
|
+
*/
|
|
14
|
+
var restoreUndoSnapshot = function (core, snapshot) {
|
|
15
|
+
core.api.triggerEvent(core, {
|
|
16
|
+
eventType: 20 /* BeforeSetContent */,
|
|
17
|
+
newContent: snapshot.html,
|
|
18
|
+
}, true /*broadcast*/);
|
|
19
|
+
try {
|
|
20
|
+
core.undo.isRestoring = true;
|
|
21
|
+
(0, restoreSnapshotHTML_1.restoreSnapshotHTML)(core, snapshot);
|
|
22
|
+
(0, restoreSnapshotSelection_1.restoreSnapshotSelection)(core, snapshot);
|
|
23
|
+
(0, restoreSnapshotColors_1.restoreSnapshotColors)(core, snapshot);
|
|
24
|
+
var event_1 = {
|
|
25
|
+
eventType: 7 /* ContentChanged */,
|
|
26
|
+
entityStates: snapshot.entityStates,
|
|
27
|
+
source: ChangeSource_1.ChangeSource.SetContent,
|
|
28
|
+
};
|
|
29
|
+
core.api.triggerEvent(core, event_1, false /*broadcast*/);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
core.undo.isRestoring = false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.restoreUndoSnapshot = restoreUndoSnapshot;
|
|
36
|
+
//# sourceMappingURL=restoreUndoSnapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restoreUndoSnapshot.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/restoreUndoSnapshot.ts"],"names":[],"mappings":";;;AAAA,0DAAyD;AAEzD,wEAAuE;AACvE,oEAAmE;AACnE,8EAA6E;AAM7E;;;;;GAKG;AACI,IAAM,mBAAmB,GAAwB,UAAC,IAAI,EAAE,QAAQ;IACnE,IAAI,CAAC,GAAG,CAAC,YAAY,CACjB,IAAI,EACJ;QACI,SAAS,2BAAkC;QAC3C,UAAU,EAAE,QAAQ,CAAC,IAAI;KAC5B,EACD,IAAI,CAAC,aAAa,CACrB,CAAC;IAEF,IAAI;QACA,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAE7B,IAAA,yCAAmB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACpC,IAAA,mDAAwB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACzC,IAAA,6CAAqB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEtC,IAAM,OAAK,GAAoC;YAC3C,SAAS,wBAAgC;YACzC,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,MAAM,EAAE,2BAAY,CAAC,UAAU;SAClC,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,OAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;KAC3D;YAAS;QACN,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;KACjC;AACL,CAAC,CAAC;AA3BW,QAAA,mBAAmB,uBA2B9B","sourcesContent":["import { ChangeSource } from '../constants/ChangeSource';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport { restoreSnapshotColors } from '../utils/restoreSnapshotColors';\nimport { restoreSnapshotHTML } from '../utils/restoreSnapshotHTML';\nimport { restoreSnapshotSelection } from '../utils/restoreSnapshotSelection';\nimport type {\n ContentModelContentChangedEvent,\n RestoreUndoSnapshot,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Restore an undo snapshot into editor\n * @param core The editor core object\n * @param step Steps to move, can be 0, positive or negative\n */\nexport const restoreUndoSnapshot: RestoreUndoSnapshot = (core, snapshot) => {\n core.api.triggerEvent(\n core,\n {\n eventType: PluginEventType.BeforeSetContent,\n newContent: snapshot.html,\n },\n true /*broadcast*/\n );\n\n try {\n core.undo.isRestoring = true;\n\n restoreSnapshotHTML(core, snapshot);\n restoreSnapshotSelection(core, snapshot);\n restoreSnapshotColors(core, snapshot);\n\n const event: ContentModelContentChangedEvent = {\n eventType: PluginEventType.ContentChanged,\n entityStates: snapshot.entityStates,\n source: ChangeSource.SetContent,\n };\n\n core.api.triggerEvent(core, event, false /*broadcast*/);\n } finally {\n core.undo.isRestoring = false;\n }\n};\n"]}
|
|
@@ -17,13 +17,11 @@ var setContentModel = function (core, model, option, onNodeCreated) {
|
|
|
17
17
|
var selection = (0, roosterjs_content_model_dom_1.contentModelToDom)(core.contentDiv.ownerDocument, core.contentDiv, model, modelToDomContext, onNodeCreated);
|
|
18
18
|
if (!core.lifecycle.shadowEditFragment) {
|
|
19
19
|
core.cache.cachedSelection = selection || undefined;
|
|
20
|
-
if (selection) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
core.selection.selectionRange = selection.range;
|
|
26
|
-
}
|
|
20
|
+
if (!(option === null || option === void 0 ? void 0 : option.ignoreSelection) && selection) {
|
|
21
|
+
core.api.setDOMSelection(core, selection);
|
|
22
|
+
}
|
|
23
|
+
else if (!selection || selection.type !== 'range') {
|
|
24
|
+
core.selection.selection = selection;
|
|
27
25
|
}
|
|
28
26
|
core.cache.cachedModel = model;
|
|
29
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setContentModel.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/setContentModel.ts"],"names":[],"mappings":";;;;AAAA,2EAIqC;AAGrC;;;;;;GAMG;AACI,IAAM,eAAe,GAAoB,UAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa;IAC/E,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,IAAM,SAAS,GAAG,IAAA,+CAAiB,EAC/B,IAAI,CAAC,UAAU,CAAC,aAAa,EAC7B,IAAI,CAAC,UAAU,EACf,KAAK,EACL,iBAAiB,EACjB,aAAa,CAChB,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE;QACpC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,SAAS,IAAI,SAAS,CAAC;QAEpD,IAAI,
|
|
1
|
+
{"version":3,"file":"setContentModel.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-core/lib/coreApi/setContentModel.ts"],"names":[],"mappings":";;;;AAAA,2EAIqC;AAGrC;;;;;;GAMG;AACI,IAAM,eAAe,GAAoB,UAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa;IAC/E,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,IAAM,SAAS,GAAG,IAAA,+CAAiB,EAC/B,IAAI,CAAC,UAAU,CAAC,aAAa,EAC7B,IAAI,CAAC,UAAU,EACf,KAAK,EACL,iBAAiB,EACjB,aAAa,CAChB,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE;QACpC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,SAAS,IAAI,SAAS,CAAC;QAEpD,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,eAAe,CAAA,IAAI,SAAS,EAAE;YACvC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SAC7C;aAAM,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,OAAO,EAAE;YACjD,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC;SACxC;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC;KAClC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AA3BW,QAAA,eAAe,mBA2B1B","sourcesContent":["import {\n contentModelToDom,\n createModelToDomContext,\n createModelToDomContextWithConfig,\n} from 'roosterjs-content-model-dom';\nimport type { SetContentModel } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Set content with content model\n * @param core The editor core object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n */\nexport const setContentModel: SetContentModel = (core, model, option, onNodeCreated) => {\n const editorContext = core.api.createEditorContext(core);\n const modelToDomContext = option\n ? createModelToDomContext(editorContext, ...(core.defaultModelToDomOptions || []), option)\n : createModelToDomContextWithConfig(core.defaultModelToDomConfig, editorContext);\n\n const selection = contentModelToDom(\n core.contentDiv.ownerDocument,\n core.contentDiv,\n model,\n modelToDomContext,\n onNodeCreated\n );\n\n if (!core.lifecycle.shadowEditFragment) {\n core.cache.cachedSelection = selection || undefined;\n\n if (!option?.ignoreSelection && selection) {\n core.api.setDOMSelection(core, selection);\n } else if (!selection || selection.type !== 'range') {\n core.selection.selection = selection;\n }\n\n core.cache.cachedModel = model;\n }\n\n return selection;\n};\n"]}
|