roosterjs-content-model-plugins 0.26.4 → 0.28.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/autoFormat/AutoFormatPlugin.d.ts +11 -2
- package/lib/autoFormat/AutoFormatPlugin.js +24 -4
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib/autoFormat/link/createLink.d.ts +5 -0
- package/lib/autoFormat/link/createLink.js +26 -0
- package/lib/autoFormat/link/createLink.js.map +1 -0
- package/lib/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
- package/lib/autoFormat/link/createLinkAfterSpace.js +39 -0
- package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -0
- package/lib/autoFormat/link/getLinkSegment.d.ts +5 -0
- package/lib/autoFormat/link/getLinkSegment.js +27 -0
- package/lib/autoFormat/link/getLinkSegment.js.map +1 -0
- package/lib/autoFormat/link/unlink.d.ts +5 -0
- package/lib/autoFormat/link/unlink.js +20 -0
- package/lib/autoFormat/link/unlink.js.map +1 -0
- package/lib/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
- package/lib/autoFormat/list/getIndex.js.map +1 -0
- package/lib/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
- package/lib/autoFormat/list/getListTypeStyle.js.map +1 -0
- package/lib/autoFormat/list/getNumberingListStyle.js.map +1 -0
- package/lib/autoFormat/list/keyboardListTrigger.d.ts +5 -0
- package/lib/autoFormat/{keyboardListTrigger.js → list/keyboardListTrigger.js} +17 -15
- package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -0
- package/lib/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
- package/lib/contextMenuBase/ContextMenuPluginBase.js +84 -0
- package/lib/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
- package/lib/edit/EditPlugin.d.ts +3 -3
- package/lib/edit/EditPlugin.js +1 -1
- package/lib/edit/EditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js +20 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
- package/lib/edit/deleteSteps/deleteEmptyQuote.js +60 -0
- package/lib/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
- package/lib/edit/deleteSteps/deleteList.js +2 -1
- package/lib/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.d.ts +2 -2
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js +40 -10
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/keyboardDelete.d.ts +3 -3
- package/lib/edit/keyboardDelete.js +10 -2
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +2 -2
- package/lib/edit/keyboardInput.js +2 -1
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.d.ts +2 -2
- package/lib/edit/keyboardTab.js +19 -11
- package/lib/edit/keyboardTab.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnList.d.ts +7 -0
- package/lib/edit/tabUtils/handleTabOnList.js +34 -0
- package/lib/edit/tabUtils/handleTabOnList.js.map +1 -0
- package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
- package/lib/edit/tabUtils/handleTabOnParagraph.js +81 -0
- package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
- package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +22 -1
- package/lib/index.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.js +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib/paste/PastePlugin.d.ts +2 -3
- package/lib/paste/PastePlugin.js +6 -7
- package/lib/paste/PastePlugin.js.map +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/constants.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +6 -6
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.js +2 -1
- package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -17
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +1 -1
- package/lib/paste/utils/addParser.js +2 -1
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib/paste/utils/getStyles.js.map +1 -1
- package/lib/paste/utils/linkParser.js.map +1 -1
- package/lib/paste/utils/setProcessor.js.map +1 -1
- package/lib/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
- package/lib/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib/pluginUtils/CreateElement/createElement.d.ts +2 -2
- package/lib/pluginUtils/CreateElement/createElement.js +2 -1
- package/lib/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib/pluginUtils/Disposable.d.ts +1 -1
- package/lib/pluginUtils/Disposable.js.map +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js +2 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
- package/lib/pluginUtils/Rect/getIntersectedRect.js +4 -3
- package/lib/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib/shortcut/ShortcutCommand.d.ts +44 -0
- package/lib/shortcut/ShortcutCommand.js +3 -0
- package/lib/shortcut/ShortcutCommand.js.map +1 -0
- package/lib/shortcut/ShortcutPlugin.d.ts +51 -0
- package/lib/shortcut/ShortcutPlugin.js +120 -0
- package/lib/shortcut/ShortcutPlugin.js.map +1 -0
- package/lib/shortcut/shortcuts.d.ts +85 -0
- package/lib/shortcut/shortcuts.js +211 -0
- package/lib/shortcut/shortcuts.js.map +1 -0
- package/lib/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
- package/lib/shortcut/utils/setShortcutIndentationCommand.js +22 -0
- package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
- package/lib/tableEdit/TableEditPlugin.d.ts +47 -0
- package/lib/tableEdit/TableEditPlugin.js +156 -0
- package/lib/tableEdit/TableEditPlugin.js.map +1 -0
- package/lib/tableEdit/editors/TableEditor.d.ts +73 -0
- package/lib/tableEdit/editors/TableEditor.js +294 -0
- package/lib/tableEdit/editors/TableEditor.js.map +1 -0
- package/lib/tableEdit/editors/features/CellResizer.d.ts +6 -0
- package/lib/tableEdit/editors/features/CellResizer.js +169 -0
- package/lib/tableEdit/editors/features/CellResizer.js.map +1 -0
- package/lib/tableEdit/editors/features/TableEditFeature.d.ts +13 -0
- package/lib/tableEdit/editors/features/TableEditFeature.js +17 -0
- package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -0
- package/lib/tableEdit/editors/features/TableInserter.d.ts +6 -0
- package/lib/tableEdit/editors/features/TableInserter.js +113 -0
- package/lib/tableEdit/editors/features/TableInserter.js.map +1 -0
- package/lib/tableEdit/editors/features/TableMover.d.ts +8 -0
- package/lib/tableEdit/editors/features/TableMover.js +83 -0
- package/lib/tableEdit/editors/features/TableMover.js.map +1 -0
- package/lib/tableEdit/editors/features/TableResizer.d.ts +6 -0
- package/lib/tableEdit/editors/features/TableResizer.js +166 -0
- package/lib/tableEdit/editors/features/TableResizer.js.map +1 -0
- package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +11 -2
- package/lib-amd/autoFormat/AutoFormatPlugin.js +21 -4
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-amd/autoFormat/link/createLink.d.ts +5 -0
- package/lib-amd/autoFormat/link/createLink.js +26 -0
- package/lib-amd/autoFormat/link/createLink.js.map +1 -0
- package/lib-amd/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js +38 -0
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -0
- package/lib-amd/autoFormat/link/getLinkSegment.d.ts +5 -0
- package/lib-amd/autoFormat/link/getLinkSegment.js +27 -0
- package/lib-amd/autoFormat/link/getLinkSegment.js.map +1 -0
- package/lib-amd/autoFormat/link/unlink.d.ts +5 -0
- package/lib-amd/autoFormat/link/unlink.js +21 -0
- package/lib-amd/autoFormat/link/unlink.js.map +1 -0
- package/lib-amd/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
- package/lib-amd/autoFormat/list/getIndex.js.map +1 -0
- package/lib-amd/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
- package/lib-amd/autoFormat/list/getListTypeStyle.js.map +1 -0
- package/lib-amd/autoFormat/list/getNumberingListStyle.js.map +1 -0
- package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +5 -0
- package/lib-amd/autoFormat/list/keyboardListTrigger.js +46 -0
- package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -0
- package/lib-amd/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
- package/lib-amd/contextMenuBase/ContextMenuPluginBase.js +86 -0
- package/lib-amd/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
- package/lib-amd/edit/EditPlugin.d.ts +3 -3
- package/lib-amd/edit/EditPlugin.js +1 -1
- package/lib-amd/edit/EditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +19 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js +60 -0
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteList.js +2 -1
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -2
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +40 -10
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.d.ts +3 -3
- package/lib-amd/edit/keyboardDelete.js +10 -3
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.d.ts +2 -2
- package/lib-amd/edit/keyboardInput.js +2 -2
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.d.ts +2 -2
- package/lib-amd/edit/keyboardTab.js +18 -12
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +7 -0
- package/lib-amd/edit/tabUtils/handleTabOnList.js +34 -0
- package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -0
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +81 -0
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
- package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-amd/index.d.ts +5 -0
- package/lib-amd/index.js +19 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-amd/paste/PastePlugin.d.ts +2 -3
- package/lib-amd/paste/PastePlugin.js +6 -7
- package/lib-amd/paste/PastePlugin.js.map +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/constants.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +6 -6
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js +2 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -17
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +1 -1
- package/lib-amd/paste/utils/addParser.js +2 -1
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-amd/paste/utils/getStyles.js.map +1 -1
- package/lib-amd/paste/utils/linkParser.js.map +1 -1
- package/lib-amd/paste/utils/setProcessor.js.map +1 -1
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib-amd/pluginUtils/CreateElement/createElement.d.ts +2 -2
- package/lib-amd/pluginUtils/CreateElement/createElement.js +2 -1
- package/lib-amd/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib-amd/pluginUtils/Disposable.d.ts +1 -1
- package/lib-amd/pluginUtils/Disposable.js.map +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js +2 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js +4 -3
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib-amd/shortcut/ShortcutCommand.d.ts +44 -0
- package/lib-amd/shortcut/ShortcutCommand.js +5 -0
- package/lib-amd/shortcut/ShortcutCommand.js.map +1 -0
- package/lib-amd/shortcut/ShortcutPlugin.d.ts +51 -0
- package/lib-amd/shortcut/ShortcutPlugin.js +120 -0
- package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -0
- package/lib-amd/shortcut/shortcuts.d.ts +85 -0
- package/lib-amd/shortcut/shortcuts.js +210 -0
- package/lib-amd/shortcut/shortcuts.js.map +1 -0
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +22 -0
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
- package/lib-amd/tableEdit/TableEditPlugin.d.ts +47 -0
- package/lib-amd/tableEdit/TableEditPlugin.js +156 -0
- package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -0
- package/lib-amd/tableEdit/editors/TableEditor.d.ts +73 -0
- package/lib-amd/tableEdit/editors/TableEditor.js +290 -0
- package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +6 -0
- package/lib-amd/tableEdit/editors/features/CellResizer.js +166 -0
- package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/TableEditFeature.d.ts +13 -0
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js +19 -0
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +6 -0
- package/lib-amd/tableEdit/editors/features/TableInserter.js +111 -0
- package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/TableMover.d.ts +8 -0
- package/lib-amd/tableEdit/editors/features/TableMover.js +81 -0
- package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +6 -0
- package/lib-amd/tableEdit/editors/features/TableResizer.js +164 -0
- package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -0
- package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +11 -2
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +24 -4
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-mjs/autoFormat/link/createLink.d.ts +5 -0
- package/lib-mjs/autoFormat/link/createLink.js +22 -0
- package/lib-mjs/autoFormat/link/createLink.js.map +1 -0
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +35 -0
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -0
- package/lib-mjs/autoFormat/link/getLinkSegment.d.ts +5 -0
- package/lib-mjs/autoFormat/link/getLinkSegment.js +23 -0
- package/lib-mjs/autoFormat/link/getLinkSegment.js.map +1 -0
- package/lib-mjs/autoFormat/link/unlink.d.ts +5 -0
- package/lib-mjs/autoFormat/link/unlink.js +16 -0
- package/lib-mjs/autoFormat/link/unlink.js.map +1 -0
- package/lib-mjs/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
- package/lib-mjs/autoFormat/list/getIndex.js.map +1 -0
- package/lib-mjs/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
- package/lib-mjs/autoFormat/list/getListTypeStyle.js.map +1 -0
- package/lib-mjs/autoFormat/list/getNumberingListStyle.js.map +1 -0
- package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +5 -0
- package/lib-mjs/autoFormat/{keyboardListTrigger.js → list/keyboardListTrigger.js} +17 -15
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -0
- package/lib-mjs/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
- package/lib-mjs/contextMenuBase/ContextMenuPluginBase.js +81 -0
- package/lib-mjs/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
- package/lib-mjs/edit/EditPlugin.d.ts +3 -3
- package/lib-mjs/edit/EditPlugin.js +1 -1
- package/lib-mjs/edit/EditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +20 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js +56 -0
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js +2 -1
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -2
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +42 -12
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.d.ts +3 -3
- package/lib-mjs/edit/keyboardDelete.js +10 -2
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.d.ts +2 -2
- package/lib-mjs/edit/keyboardInput.js +2 -1
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.d.ts +2 -2
- package/lib-mjs/edit/keyboardTab.js +19 -11
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +7 -0
- package/lib-mjs/edit/tabUtils/handleTabOnList.js +30 -0
- package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -0
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +77 -0
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-mjs/index.d.ts +5 -0
- package/lib-mjs/index.js +4 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PastePlugin.d.ts +2 -3
- package/lib-mjs/paste/PastePlugin.js +1 -2
- package/lib-mjs/paste/PastePlugin.js.map +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +2 -14
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +1 -1
- package/lib-mjs/paste/utils/addParser.js +1 -1
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-mjs/paste/utils/getStyles.js.map +1 -1
- package/lib-mjs/paste/utils/linkParser.js.map +1 -1
- package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib-mjs/pluginUtils/CreateElement/createElement.d.ts +2 -2
- package/lib-mjs/pluginUtils/CreateElement/createElement.js +1 -1
- package/lib-mjs/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib-mjs/pluginUtils/Disposable.d.ts +1 -1
- package/lib-mjs/pluginUtils/Disposable.js.map +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js +2 -2
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib-mjs/shortcut/ShortcutCommand.d.ts +44 -0
- package/lib-mjs/shortcut/ShortcutCommand.js +2 -0
- package/lib-mjs/shortcut/ShortcutCommand.js.map +1 -0
- package/lib-mjs/shortcut/ShortcutPlugin.d.ts +51 -0
- package/lib-mjs/shortcut/ShortcutPlugin.js +117 -0
- package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -0
- package/lib-mjs/shortcut/shortcuts.d.ts +85 -0
- package/lib-mjs/shortcut/shortcuts.js +208 -0
- package/lib-mjs/shortcut/shortcuts.js.map +1 -0
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +18 -0
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
- package/lib-mjs/tableEdit/TableEditPlugin.d.ts +47 -0
- package/lib-mjs/tableEdit/TableEditPlugin.js +153 -0
- package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -0
- package/lib-mjs/tableEdit/editors/TableEditor.d.ts +73 -0
- package/lib-mjs/tableEdit/editors/TableEditor.js +291 -0
- package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +6 -0
- package/lib-mjs/tableEdit/editors/features/CellResizer.js +165 -0
- package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.d.ts +13 -0
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js +13 -0
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +6 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.js +109 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +8 -0
- package/lib-mjs/tableEdit/editors/features/TableMover.js +79 -0
- package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +6 -0
- package/lib-mjs/tableEdit/editors/features/TableResizer.js +162 -0
- package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -0
- package/package.json +5 -5
- package/lib/autoFormat/keyboardListTrigger.d.ts +0 -5
- package/lib/autoFormat/keyboardListTrigger.js.map +0 -1
- package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
- package/lib/autoFormat/utils/getIndex.js.map +0 -1
- package/lib/autoFormat/utils/getListTypeStyle.js.map +0 -1
- package/lib/autoFormat/utils/getNumberingListStyle.js.map +0 -1
- package/lib/pluginUtils/Rect/normalizeRect.d.ts +0 -7
- package/lib/pluginUtils/Rect/normalizeRect.js +0 -20
- package/lib/pluginUtils/Rect/normalizeRect.js.map +0 -1
- package/lib-amd/autoFormat/keyboardListTrigger.d.ts +0 -5
- package/lib-amd/autoFormat/keyboardListTrigger.js +0 -44
- package/lib-amd/autoFormat/keyboardListTrigger.js.map +0 -1
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
- package/lib-amd/autoFormat/utils/getIndex.js.map +0 -1
- package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +0 -1
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +0 -1
- package/lib-amd/pluginUtils/Rect/normalizeRect.d.ts +0 -7
- package/lib-amd/pluginUtils/Rect/normalizeRect.js +0 -22
- package/lib-amd/pluginUtils/Rect/normalizeRect.js.map +0 -1
- package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +0 -5
- package/lib-mjs/autoFormat/keyboardListTrigger.js.map +0 -1
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
- package/lib-mjs/autoFormat/utils/getIndex.js.map +0 -1
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +0 -1
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +0 -1
- package/lib-mjs/pluginUtils/Rect/normalizeRect.d.ts +0 -7
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js +0 -17
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js.map +0 -1
- /package/lib/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
- /package/lib/autoFormat/{utils → list}/getIndex.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/getIndex.js +0 -0
- /package/lib/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
- /package/lib-amd/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getIndex.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getIndex.js +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getIndex.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getIndex.js +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-model-api"], function (require, exports, roosterjs_content_model_dom_1, roosterjs_content_model_api_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.handleTabOnParagraph = void 0;
|
|
5
|
+
var tabSpaces = ' ';
|
|
6
|
+
var space = ' ';
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
The handleTabOnParagraph function will handle the tab key in following scenarios:
|
|
10
|
+
* 1. When the selection is collapsed and the cursor is at the end of a paragraph, add 4 spaces.
|
|
11
|
+
* 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to indent the whole paragraph
|
|
12
|
+
* 3. When the selection is collapsed and the cursor is at the middle of a paragraph, add 4 spaces.
|
|
13
|
+
* 4. When the selection is not collapsed, replace the selected range with a single space.
|
|
14
|
+
* 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to indent the whole paragraph
|
|
15
|
+
The handleTabOnParagraph function will handle the shift + tab key in a indented paragraph in following scenarios:
|
|
16
|
+
* 1. When the selection is collapsed and the cursor is at the end of a paragraph, remove 4 spaces.
|
|
17
|
+
* 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to outdent the whole paragraph
|
|
18
|
+
* 3. When the selection is collapsed and the cursor is at the middle of a paragraph, remove 4 spaces.
|
|
19
|
+
* 4. When the selection is not collapsed, replace the selected range with a 4 space.
|
|
20
|
+
* 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to outdent the whole paragraph
|
|
21
|
+
*/
|
|
22
|
+
function handleTabOnParagraph(model, paragraph, rawEvent) {
|
|
23
|
+
var selectedSegments = paragraph.segments.filter(function (segment) { return segment.isSelected; });
|
|
24
|
+
var isCollapsed = selectedSegments.length === 1 && selectedSegments[0].segmentType === 'SelectionMarker';
|
|
25
|
+
var isAllSelected = paragraph.segments.every(function (segment) { return segment.isSelected; });
|
|
26
|
+
if ((paragraph.segments[0].segmentType === 'SelectionMarker' && isCollapsed) || isAllSelected) {
|
|
27
|
+
(0, roosterjs_content_model_api_1.setModelIndentation)(model, rawEvent.shiftKey ? 'outdent' : 'indent');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (!isCollapsed) {
|
|
31
|
+
var firstSelectedSegmentIndex_1 = undefined;
|
|
32
|
+
var lastSelectedSegmentIndex_1 = undefined;
|
|
33
|
+
paragraph.segments.forEach(function (segment, index) {
|
|
34
|
+
if (segment.isSelected) {
|
|
35
|
+
if (!firstSelectedSegmentIndex_1) {
|
|
36
|
+
firstSelectedSegmentIndex_1 = index;
|
|
37
|
+
}
|
|
38
|
+
lastSelectedSegmentIndex_1 = index;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (firstSelectedSegmentIndex_1 && lastSelectedSegmentIndex_1) {
|
|
42
|
+
var firstSelectedSegment = paragraph.segments[firstSelectedSegmentIndex_1];
|
|
43
|
+
var spaceText = (0, roosterjs_content_model_dom_1.createText)(rawEvent.shiftKey ? tabSpaces : space, firstSelectedSegment.format);
|
|
44
|
+
var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(firstSelectedSegment.format);
|
|
45
|
+
paragraph.segments.splice(firstSelectedSegmentIndex_1, lastSelectedSegmentIndex_1 - firstSelectedSegmentIndex_1 + 1, spaceText, marker);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
var markerIndex = paragraph.segments.findIndex(function (segment) { return segment.segmentType === 'SelectionMarker'; });
|
|
53
|
+
if (!rawEvent.shiftKey) {
|
|
54
|
+
var markerFormat = paragraph.segments[markerIndex].format;
|
|
55
|
+
var tabText = (0, roosterjs_content_model_dom_1.createText)(tabSpaces, markerFormat);
|
|
56
|
+
paragraph.segments.splice(markerIndex, 0, tabText);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
var tabText = paragraph.segments[markerIndex - 1];
|
|
60
|
+
var tabSpacesLength = tabSpaces.length;
|
|
61
|
+
if (tabText.segmentType == 'Text') {
|
|
62
|
+
var tabSpaceTextLength = tabText.text.length - tabSpacesLength;
|
|
63
|
+
if (tabText.text === tabSpaces) {
|
|
64
|
+
paragraph.segments.splice(markerIndex - 1, 1);
|
|
65
|
+
}
|
|
66
|
+
else if (tabText.text.substring(tabSpaceTextLength) === tabSpaces) {
|
|
67
|
+
tabText.text = tabText.text.substring(0, tabSpaceTextLength);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
rawEvent.preventDefault();
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
exports.handleTabOnParagraph = handleTabOnParagraph;
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=handleTabOnParagraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleTabOnParagraph.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/tabUtils/handleTabOnParagraph.ts"],"names":[],"mappings":";;;;IAIA,IAAM,SAAS,GAAG,MAAM,CAAC;IACzB,IAAM,KAAK,GAAG,GAAG,CAAC;IAElB;;;;;;;;;;;;;;OAcG;IACH,SAAgB,oBAAoB,CAChC,KAA2B,EAC3B,SAAgC,EAChC,QAAuB;QAEvB,IAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;QAClF,IAAM,WAAW,GACb,gBAAgB,CAAC,MAAM,KAAK,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,iBAAiB,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C","sourcesContent":["import { createSelectionMarker, createText } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { ContentModelDocument, ContentModelParagraph } from 'roosterjs-content-model-types';\n\nconst tabSpaces = ' ';\nconst space = ' ';\n\n/**\n * @internal\n The handleTabOnParagraph function will handle the tab key in following scenarios:\n * 1. When the selection is collapsed and the cursor is at the end of a paragraph, add 4 spaces.\n * 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to indent the whole paragraph\n * 3. When the selection is collapsed and the cursor is at the middle of a paragraph, add 4 spaces.\n * 4. When the selection is not collapsed, replace the selected range with a single space.\n * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to indent the whole paragraph\n The handleTabOnParagraph function will handle the shift + tab key in a indented paragraph in following scenarios:\n * 1. When the selection is collapsed and the cursor is at the end of a paragraph, remove 4 spaces.\n * 2. When the selection is collapsed and the cursor is at the start of a paragraph, call setModelIndention function to outdent the whole paragraph\n * 3. When the selection is collapsed and the cursor is at the middle of a paragraph, remove 4 spaces.\n * 4. When the selection is not collapsed, replace the selected range with a 4 space.\n * 5. When the selection is not collapsed, but all segments are selected, call setModelIndention function to outdent the whole paragraph\n */\nexport function handleTabOnParagraph(\n model: ContentModelDocument,\n paragraph: ContentModelParagraph,\n rawEvent: KeyboardEvent\n) {\n const selectedSegments = paragraph.segments.filter(segment => segment.isSelected);\n const isCollapsed =\n selectedSegments.length === 1 && selectedSegments[0].segmentType === 'SelectionMarker';\n const isAllSelected = paragraph.segments.every(segment => segment.isSelected);\n if ((paragraph.segments[0].segmentType === 'SelectionMarker' && isCollapsed) || isAllSelected) {\n setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');\n } else {\n if (!isCollapsed) {\n let firstSelectedSegmentIndex: number | undefined = undefined;\n let lastSelectedSegmentIndex: number | undefined = undefined;\n\n paragraph.segments.forEach((segment, index) => {\n if (segment.isSelected) {\n if (!firstSelectedSegmentIndex) {\n firstSelectedSegmentIndex = index;\n }\n lastSelectedSegmentIndex = index;\n }\n });\n if (firstSelectedSegmentIndex && lastSelectedSegmentIndex) {\n const firstSelectedSegment = paragraph.segments[firstSelectedSegmentIndex];\n const spaceText = createText(\n rawEvent.shiftKey ? tabSpaces : space,\n firstSelectedSegment.format\n );\n const marker = createSelectionMarker(firstSelectedSegment.format);\n paragraph.segments.splice(\n firstSelectedSegmentIndex,\n lastSelectedSegmentIndex - firstSelectedSegmentIndex + 1,\n spaceText,\n marker\n );\n } else {\n return false;\n }\n } else {\n const markerIndex = paragraph.segments.findIndex(\n segment => segment.segmentType === 'SelectionMarker'\n );\n if (!rawEvent.shiftKey) {\n const markerFormat = paragraph.segments[markerIndex].format;\n const tabText = createText(tabSpaces, markerFormat);\n paragraph.segments.splice(markerIndex, 0, tabText);\n } else {\n const tabText = paragraph.segments[markerIndex - 1];\n const tabSpacesLength = tabSpaces.length;\n if (tabText.segmentType == 'Text') {\n const tabSpaceTextLength = tabText.text.length - tabSpacesLength;\n if (tabText.text === tabSpaces) {\n paragraph.segments.splice(markerIndex - 1, 1);\n } else if (tabText.text.substring(tabSpaceTextLength) === tabSpaces) {\n tabText.text = tabText.text.substring(0, tabSpaceTextLength);\n } else {\n return false;\n }\n }\n }\n }\n }\n\n rawEvent.preventDefault();\n return true;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLeafSiblingBlock.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"getLeafSiblingBlock.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/utils/getLeafSiblingBlock.ts"],"names":[],"mappings":";;;;IA6BA;;OAEG;IACH,SAAgB,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;QAEf,IAAM,OAAO,sDAAO,IAAI,SAAC,CAAC;;YAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACzB,IAAM,KAAK,GAAG,K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AS,IAAI,WAAW,IAAI,CAAC,cAAY,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAO,CAAC,CAAC,IAAI,CAAC,EAA/E,CAA+E,CAC9D,CAAC;gBAE3B,IAAI,IAAI,EAAE;oBACN,qFAAqF;oBACrF,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAY,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAEvE,IAAI,cAAc,EAAE;wCAET,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,gBAAA,EAAE;qBACxD;yBAAM;wBACH,gDAAgD;wBAChD,KAAK,GAAG,IAAI,CAAC;qBAChB;iBACJ;qBAAM;;iBAGN;aACJ;iBAAM,IAAI,KAAK,CAAC,cAAc,IAAI,UAAU,IAAI,KAAK,CAAC,cAAc,IAAI,WAAW,EAAE;gBAClF,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,KAAK,GAAG,KAAK,CAAC;aACjB;iBAAM;;aAEN;;QAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;SA0DxB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IApED,kDAoEC","sourcesContent":["import { isGeneralSegment } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelParagraph,\n ContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport type BlockAndPath = {\n /**\n * The sibling block\n */\n block: ContentModelBlock;\n\n /**\n * Path of this sibling block\n */\n path: ContentModelBlockGroup[];\n\n /**\n * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.\n * Use this property to return the sibling sibling under the same paragraph\n */\n siblingSegment?: ContentModelSegment;\n};\n\n/**\n * @internal\n */\nexport function getLeafSiblingBlock(\n path: ContentModelBlockGroup[],\n block: ContentModelBlock,\n isNext: boolean\n): BlockAndPath | null {\n const newPath = [...path];\n\n while (newPath.length > 0) {\n const group = newPath[0];\n const index = group.blocks.indexOf(block);\n\n if (index < 0) {\n break;\n }\n\n let nextBlock = group.blocks[index + (isNext ? 1 : -1)];\n\n if (nextBlock) {\n while (nextBlock.blockType == 'BlockGroup') {\n const child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];\n\n if (!child) {\n return { block: nextBlock, path: newPath };\n } else if (child.blockType != 'BlockGroup') {\n newPath.unshift(nextBlock);\n return { block: child, path: newPath };\n } else {\n newPath.unshift(nextBlock);\n nextBlock = child;\n }\n }\n\n return { block: nextBlock, path: newPath };\n } else if (isGeneralSegment(group)) {\n // For general segment, we need to check if there is sibling segment under the same paragraph\n // First let's find the parent paragraph of this segment\n newPath.shift();\n\n let segmentIndex = -1;\n const segment = group;\n const para = newPath[0]?.blocks.find(\n x => x.blockType == 'Paragraph' && (segmentIndex = x.segments.indexOf(segment)) >= 0\n ) as ContentModelParagraph;\n\n if (para) {\n // Now we have found the parent paragraph, so let's check if it has a sibling segment\n const siblingSegment = para.segments[segmentIndex + (isNext ? 1 : -1)];\n\n if (siblingSegment) {\n // Return this block, path and segment since we have found it\n return { block: para, path: newPath, siblingSegment };\n } else {\n // No sibling segment, let's keep go upper level\n block = para;\n }\n } else {\n // Parent sibling is not found (in theory this should never happen), just return null\n break;\n }\n } else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {\n newPath.shift();\n block = group;\n } else {\n break;\n }\n }\n\n return null;\n}\n"]}
|
package/lib-amd/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export { TableEditPlugin } from './tableEdit/TableEditPlugin';
|
|
1
2
|
export { PastePlugin } from './paste/PastePlugin';
|
|
2
3
|
export { EditPlugin } from './edit/EditPlugin';
|
|
3
4
|
export { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';
|
|
5
|
+
export { ShortcutBold, ShortcutItalic, ShortcutUnderline, ShortcutClearFormat, ShortcutUndo, ShortcutUndo2, ShortcutRedo, ShortcutRedoMacOS, ShortcutBullet, ShortcutNumbering, ShortcutIncreaseFont, ShortcutDecreaseFont, ShortcutIndentList, ShortcutOutdentList, } from './shortcut/shortcuts';
|
|
6
|
+
export { ShortcutPlugin } from './shortcut/ShortcutPlugin';
|
|
7
|
+
export { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';
|
|
8
|
+
export { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';
|
package/lib-amd/index.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
define(["require", "exports", "./paste/PastePlugin", "./edit/EditPlugin", "./autoFormat/AutoFormatPlugin"], function (require, exports, PastePlugin_1, EditPlugin_1, AutoFormatPlugin_1) {
|
|
1
|
+
define(["require", "exports", "./tableEdit/TableEditPlugin", "./paste/PastePlugin", "./edit/EditPlugin", "./autoFormat/AutoFormatPlugin", "./shortcut/shortcuts", "./shortcut/ShortcutPlugin", "./contextMenuBase/ContextMenuPluginBase"], function (require, exports, TableEditPlugin_1, PastePlugin_1, EditPlugin_1, AutoFormatPlugin_1, shortcuts_1, ShortcutPlugin_1, ContextMenuPluginBase_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.AutoFormatPlugin = exports.EditPlugin = exports.PastePlugin = void 0;
|
|
4
|
+
exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.PastePlugin = exports.TableEditPlugin = void 0;
|
|
5
|
+
Object.defineProperty(exports, "TableEditPlugin", { enumerable: true, get: function () { return TableEditPlugin_1.TableEditPlugin; } });
|
|
5
6
|
Object.defineProperty(exports, "PastePlugin", { enumerable: true, get: function () { return PastePlugin_1.PastePlugin; } });
|
|
6
7
|
Object.defineProperty(exports, "EditPlugin", { enumerable: true, get: function () { return EditPlugin_1.EditPlugin; } });
|
|
7
8
|
Object.defineProperty(exports, "AutoFormatPlugin", { enumerable: true, get: function () { return AutoFormatPlugin_1.AutoFormatPlugin; } });
|
|
9
|
+
Object.defineProperty(exports, "ShortcutBold", { enumerable: true, get: function () { return shortcuts_1.ShortcutBold; } });
|
|
10
|
+
Object.defineProperty(exports, "ShortcutItalic", { enumerable: true, get: function () { return shortcuts_1.ShortcutItalic; } });
|
|
11
|
+
Object.defineProperty(exports, "ShortcutUnderline", { enumerable: true, get: function () { return shortcuts_1.ShortcutUnderline; } });
|
|
12
|
+
Object.defineProperty(exports, "ShortcutClearFormat", { enumerable: true, get: function () { return shortcuts_1.ShortcutClearFormat; } });
|
|
13
|
+
Object.defineProperty(exports, "ShortcutUndo", { enumerable: true, get: function () { return shortcuts_1.ShortcutUndo; } });
|
|
14
|
+
Object.defineProperty(exports, "ShortcutUndo2", { enumerable: true, get: function () { return shortcuts_1.ShortcutUndo2; } });
|
|
15
|
+
Object.defineProperty(exports, "ShortcutRedo", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedo; } });
|
|
16
|
+
Object.defineProperty(exports, "ShortcutRedoMacOS", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedoMacOS; } });
|
|
17
|
+
Object.defineProperty(exports, "ShortcutBullet", { enumerable: true, get: function () { return shortcuts_1.ShortcutBullet; } });
|
|
18
|
+
Object.defineProperty(exports, "ShortcutNumbering", { enumerable: true, get: function () { return shortcuts_1.ShortcutNumbering; } });
|
|
19
|
+
Object.defineProperty(exports, "ShortcutIncreaseFont", { enumerable: true, get: function () { return shortcuts_1.ShortcutIncreaseFont; } });
|
|
20
|
+
Object.defineProperty(exports, "ShortcutDecreaseFont", { enumerable: true, get: function () { return shortcuts_1.ShortcutDecreaseFont; } });
|
|
21
|
+
Object.defineProperty(exports, "ShortcutIndentList", { enumerable: true, get: function () { return shortcuts_1.ShortcutIndentList; } });
|
|
22
|
+
Object.defineProperty(exports, "ShortcutOutdentList", { enumerable: true, get: function () { return shortcuts_1.ShortcutOutdentList; } });
|
|
23
|
+
Object.defineProperty(exports, "ShortcutPlugin", { enumerable: true, get: function () { return ShortcutPlugin_1.ShortcutPlugin; } });
|
|
24
|
+
Object.defineProperty(exports, "ContextMenuPluginBase", { enumerable: true, get: function () { return ContextMenuPluginBase_1.ContextMenuPluginBase; } });
|
|
8
25
|
});
|
|
9
26
|
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;;IAAS,kHAAA,eAAe,OAAA;IACf,0GAAA,WAAW,OAAA;IACX,wGAAA,UAAU,OAAA;IACV,oHAAA,gBAAgB,OAAA;IAGrB,yGAAA,YAAY,OAAA;IACZ,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,gHAAA,mBAAmB,OAAA;IACnB,yGAAA,YAAY,OAAA;IACZ,0GAAA,aAAa,OAAA;IACb,yGAAA,YAAY,OAAA;IACZ,8GAAA,iBAAiB,OAAA;IACjB,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,iHAAA,oBAAoB,OAAA;IACpB,iHAAA,oBAAoB,OAAA;IACpB,+GAAA,kBAAkB,OAAA;IAClB,gHAAA,mBAAmB,OAAA;IAEd,gHAAA,cAAc,OAAA;IAEd,8HAAA,qBAAqB,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';\n\nexport {\n ShortcutBold,\n ShortcutItalic,\n ShortcutUnderline,\n ShortcutClearFormat,\n ShortcutUndo,\n ShortcutUndo2,\n ShortcutRedo,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n ShortcutIndentList,\n ShortcutOutdentList,\n} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\n"]}
|
|
@@ -38,7 +38,7 @@ define(["require", "exports", "tslib", "../utils/addParser", "roosterjs-content-
|
|
|
38
38
|
event.fragment.replaceChildren(firstChild.lastChild);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
(0, addParser_1.
|
|
41
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'tableCell', function (format, element) {
|
|
42
42
|
if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {
|
|
43
43
|
format.borderBottom = DEFAULT_BORDER_STYLE;
|
|
44
44
|
format.borderLeft = DEFAULT_BORDER_STYLE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";;;;IAKA,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;IACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;IACxC,IAAM,gBAAgB,GAAG,o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,CAAC,IAAY,EAAE,UAAkB;QACzD,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;YAC/B,IAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAChD,IAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACzC,IAAI,GAAG,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC;SAC9B;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;YAC/B,IAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACtD,IAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAbD,oCAaC","sourcesContent":["import { addParser } from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\nconst LAST_TD_END_REGEX = /<\\/\\s*td\\s*>((?!<\\/\\s*tr\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_END_REGEX = /<\\/\\s*tr\\s*>((?!<\\/\\s*table\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;\nconst LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;\nconst DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';\n\n/**\n * @internal\n * Convert pasted content from Excel, add borders when source doc doesn't have a border\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromExcel(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler,\n allowExcelNoBorderTable?: boolean\n) {\n const { fragment, htmlBefore, clipboardData } = event;\n const html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;\n\n if (html && clipboardData.html != html) {\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');\n moveChildNodes(fragment, doc?.body);\n }\n\n // For Excel Online\n const firstChild = fragment.firstChild;\n if (\n isNodeOfType(firstChild, 'ELEMENT_NODE') &&\n firstChild.tagName == 'div' &&\n firstChild.firstChild\n ) {\n const tableFound = Array.from(firstChild.childNodes).every((child: Node) => {\n // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag\n const tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;\n\n return tagName == 'META'\n ? true\n : tagName == 'TABLE'\n ? child == firstChild.lastChild\n : false;\n });\n\n // Extract Table from Div\n if (tableFound && firstChild.lastChild) {\n event.fragment.replaceChildren(firstChild.lastChild);\n }\n }\n\n addParser(event.domToModelOption, 'tableCell', (format, element) => {\n if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {\n format.borderBottom = DEFAULT_BORDER_STYLE;\n format.borderLeft = DEFAULT_BORDER_STYLE;\n format.borderRight = DEFAULT_BORDER_STYLE;\n format.borderTop = DEFAULT_BORDER_STYLE;\n }\n });\n\n setProcessor(event.domToModelOption, 'child', (group, element, context) => {\n const segmentFormat = { ...context.segmentFormat };\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat.textColor = group.format.textColor;\n }\n\n context.defaultElementProcessors.child(group, element, context);\n\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat = segmentFormat;\n delete group.format.textColor;\n }\n });\n}\n\n/**\n * @internal Export for test only\n * @param html Source html\n */\n\nexport function excelHandler(html: string, htmlBefore: string): string {\n if (html.match(LAST_TD_END_REGEX)) {\n const trMatch = htmlBefore.match(LAST_TR_REGEX);\n const tr = trMatch ? trMatch[0] : '<TR>';\n html = tr + html + '</TR>';\n }\n if (html.match(LAST_TR_END_REGEX)) {\n const tableMatch = htmlBefore.match(LAST_TABLE_REGEX);\n const table = tableMatch ? tableMatch[0] : '<TABLE>';\n html = table + html + '</TABLE>';\n }\n\n return html;\n}\n"]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { EditorPlugin,
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
4
4
|
* 1. Content copied from Word
|
|
5
5
|
* 2. Content copied from Excel
|
|
6
6
|
* 3. Content copied from Word Online or OneNote Online
|
|
7
7
|
* 4. Content copied from Power Point
|
|
8
|
-
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
9
8
|
*/
|
|
10
9
|
export declare class PastePlugin implements EditorPlugin {
|
|
11
10
|
private allowExcelNoBorderTable?;
|
|
@@ -26,7 +25,7 @@ export declare class PastePlugin implements EditorPlugin {
|
|
|
26
25
|
* editor reference so that it can call to any editor method or format API later.
|
|
27
26
|
* @param editor The editor object
|
|
28
27
|
*/
|
|
29
|
-
initialize(editor:
|
|
28
|
+
initialize(editor: IEditor): void;
|
|
30
29
|
/**
|
|
31
30
|
* The last method that editor will call to a plugin before it is disposed.
|
|
32
31
|
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
@@ -8,7 +8,6 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
|
|
|
8
8
|
* 2. Content copied from Excel
|
|
9
9
|
* 3. Content copied from Word Online or OneNote Online
|
|
10
10
|
* 4. Content copied from Power Point
|
|
11
|
-
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
12
11
|
*/
|
|
13
12
|
var PastePlugin = /** @class */ (function () {
|
|
14
13
|
/**
|
|
@@ -79,13 +78,13 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
|
|
|
79
78
|
(0, processPastedContentFromPowerPoint_1.processPastedContentFromPowerPoint)(event, this.editor.getTrustedHTMLHandler());
|
|
80
79
|
break;
|
|
81
80
|
}
|
|
82
|
-
(0, addParser_1.
|
|
83
|
-
(0, addParser_1.
|
|
84
|
-
(0, addParser_1.
|
|
85
|
-
(0, addParser_1.
|
|
81
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'link', linkParser_1.parseLink);
|
|
82
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'tableCell', deprecatedColorParser_1.deprecatedBorderColorParser);
|
|
83
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'tableCell', tableBorderParser);
|
|
84
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'table', deprecatedColorParser_1.deprecatedBorderColorParser);
|
|
86
85
|
if (pasteType === 'mergeFormat') {
|
|
87
|
-
(0, addParser_1.
|
|
88
|
-
(0, addParser_1.
|
|
86
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'block', blockElementParser);
|
|
87
|
+
(0, addParser_1.addParser)(event.domToModelOption, 'listLevel', blockElementParser);
|
|
89
88
|
}
|
|
90
89
|
};
|
|
91
90
|
return PastePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages
|
|
1
|
+
{"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/paste/PastePlugin.ts"],"names":[],"mappings":";;;;IAoBA;;;;;;OAMG;IACH;QAGI;;;;WAIG;QACH,qBAAoB,uBAAiC;YAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;YAP7C,WAAM,GAAmB,IAAI,CAAC;QAOkB,CAAC;QAEzD;;WAEG;QACH,6BAAO,GAAP;YACI,OAAO,OAAO,CAAC;QACnB,CAAC;QAED;;;;;WAKG;QACH,gCAAU,GAAV,UAAW,MAAe;YACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,6BAAO,GAAP;YACI,IAAI,CAAC,MAAM,G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wCAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC5C,IACI,QAAQ;oBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import { addParser } from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type {\n BorderFormat,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n EditorPlugin,\n FormatParser,\n IEditor,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\n * 1. Content copied from Word\n * 2. Content copied from Excel\n * 3. Content copied from Word Online or OneNote Online\n * 4. Content copied from Power Point\n */\nexport class PastePlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n\n /**\n * Construct a new instance of Paste class\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\n * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(private allowExcelNoBorderTable?: boolean) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Paste';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (!this.editor || event.eventType != 'beforePaste') {\n return;\n }\n\n if (!event.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(event, false);\n const pasteType = event.pasteType;\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());\n break;\n case 'wacComponents':\n processPastedContentWacComponents(event);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n event,\n this.editor.getTrustedHTMLHandler(),\n this.allowExcelNoBorderTable\n );\n }\n break;\n case 'googleSheets':\n event.domToModelOption.additionalAllowedTags.push(\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME as Lowercase<string>\n );\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());\n break;\n }\n\n addParser(event.domToModelOption, 'link', parseLink);\n addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'tableCell', tableBorderParser);\n addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);\n\n if (pasteType === 'mergeFormat') {\n addParser(event.domToModelOption, 'block', blockElementParser);\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\n }\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/PowerPoint/processPastedContentFromPowerPoint.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IAEH,SAAgB,kCAAkC,CAC9C,KAAuB,EACvB,kBAAsC;QAE9B,IAAA,QAAQ,GAAoB,KAAK,SAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QAE1C,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,EAAE;YAClE,gFAAgF;YAChF,gCAAgC;YAChC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACvC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EACtC,WAAW,CACd,CAAC;YAEF,IAAA,4CAAc,EAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;SACvC;IACL,CAAC;IAhBD,gFAgBC","sourcesContent":["import { moveChildNodes } from 'roosterjs-content-model-dom';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Convert pasted content from PowerPoint\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromPowerPoint(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler\n) {\n const { fragment, clipboardData } = event;\n\n if (clipboardData.html && !clipboardData.text && clipboardData.image) {\n // It is possible that PowerPoint copied both image and HTML but not plain text.\n // We always prefer HTML if any.\n const doc = new DOMParser().parseFromString(\n trustedHTMLHandler(clipboardData.html),\n 'text/html'\n );\n\n moveChildNodes(fragment, doc?.body);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WacComponents/constants.ts"],"names":[],"mappings":";;;;IAAA;;QAEI;IACS,QAAA,sCAAsC,GAAa;QAC5D,wBAAwB;QACxB,yBAAyB;QACzB,0BAA0B;QAC1B,2BAA2B;QAC3B,wBAAwB;QACxB,qBAAqB;KACxB,CAAC;IACF;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,YAAY,GAAW,gBAAgB,CAAC;IACrD;;QAEI;IACS,QAAA,eAAe,GAAW,mBAAmB,CAAC;IAC3D;;QAEI;IACS,QAAA,eAAe,GAAW,gBAAgB,CAAC;IACxD;;QAEI;IACS,QAAA,SAAS,GAAW,WAAW,CAAC;IAC7C;;QAEI;IACS,QAAA,iCAAiC,GAAW,sBAAsB,CAAC;IAChF;;QAEI;IACS,QAAA,uBAAuB,GAAW,sBAAsB,CAAC;IACtE;;QAEI;IACS,QAAA,+BAA+B,GAAW,yBAAyB,CAAC;IACjF;;QAEI;IACS,QAAA,qBAAqB,iFAC3B,8CAAsC;QACzC,wBAAwB;cAC1B;IACF;;QAEI;IACS,QAAA,qBAAqB,GAC9B,iBAAc,yBAAiB,aAAO,uBAAe,qBAAe,yBAAiB,aAAO,uBAAe,cAAS,uBAAe,cAAS,oBAAY,UAAK,+BAAuB,UAAK,uCAA+B,MAAG;QAC3N,8CAAsC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,wBAAqB,CAAC,QAAI,EAA1B,CAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC","sourcesContent":["/**\n * @internal\n **/\nexport const WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES: string[] = [\n 'TableInsertRowGapBlank',\n 'TableColumnResizeHandle',\n 'TableCellTopBorderHandle',\n 'TableCellLeftBorderHandle',\n 'TableHoverColumnHandle',\n 'TableHoverRowHandle',\n];\n/**\n * @internal\n **/\nexport const BULLET_LIST_STYLE: string = 'BulletListStyle';\n/**\n * @internal\n **/\nexport const NUMBER_LIST_STYLE: string = 'NumberListStyle';\n/**\n * @internal\n **/\nexport const IMAGE_BORDER: string = 'WACImageBorder';\n/**\n * @internal\n **/\nexport const IMAGE_CONTAINER: string = 'WACImageContainer';\n/**\n * @internal\n **/\nexport const OUTLINE_ELEMENT: string = 'OutlineElement';\n/**\n * @internal\n **/\nexport const PARAGRAPH: string = 'Paragraph';\n/**\n * @internal\n **/\nexport const LIST_CONTAINER_ELEMENT_CLASS_NAME: string = 'ListContainerWrapper';\n/**\n * @internal\n **/\nexport const COMMENT_HIGHLIGHT_CLASS: string = 'CommentHighlightRest';\n/**\n * @internal\n **/\nexport const COMMENT_HIGHLIGHT_CLICKED_CLASS: string = 'CommentHighlightClicked';\n/**\n * @internal\n **/\nexport const TEMP_ELEMENTS_CLASSES: string[] = [\n ...WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES,\n 'ListMarkerWrappingSpan',\n];\n/**\n * @internal\n **/\nexport const WAC_IDENTIFY_SELECTOR: string =\n `ul[class^=\"${BULLET_LIST_STYLE}\"]>.${OUTLINE_ELEMENT},ol[class^=\"${NUMBER_LIST_STYLE}\"]>.${OUTLINE_ELEMENT},span.${IMAGE_CONTAINER},span.${IMAGE_BORDER},.${COMMENT_HIGHLIGHT_CLASS},.${COMMENT_HIGHLIGHT_CLICKED_CLASS},` +\n WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(c => `table div[class^=\"${c}\"]`).join(',');\n"]}
|
|
@@ -145,12 +145,12 @@ define(["require", "exports", "tslib", "../utils/addParser", "roosterjs-content-
|
|
|
145
145
|
* @param ev BeforePasteEvent
|
|
146
146
|
*/
|
|
147
147
|
function processPastedContentWacComponents(ev) {
|
|
148
|
-
(0, addParser_1.
|
|
149
|
-
(0, addParser_1.
|
|
150
|
-
(0, addParser_1.
|
|
151
|
-
(0, addParser_1.
|
|
152
|
-
(0, addParser_1.
|
|
153
|
-
(0, addParser_1.
|
|
148
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'segment', wacSubSuperParser);
|
|
149
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'listItemThread', wacListItemParser);
|
|
150
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'listLevel', wacListLevelParser);
|
|
151
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'container', wacContainerParser);
|
|
152
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'table', wacContainerParser);
|
|
153
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'segment', wacCommentParser);
|
|
154
154
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wacElementProcessor);
|
|
155
155
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'li', wacLiElementProcessor);
|
|
156
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentWacComponents.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WacComponents/processPastedContentWacComponents.ts"],"names":[],"mappings":";;;;IAuBA,IAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,IAAM,qBAAqB,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAa1D;;;OAGG;IACH,IAAM,iBAAiB,GAA4C,UAC/D,MAAiC,EACjC,OAAoB;QAEpB,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC;QAClD,IAAI,aAAa,KAAK,OAAO,EAAE;YAC3B,MAAM,CAAC,wBAAwB,GAAG,OAAO,CAAC;SAC7C;QACD,IAAI,aAAa,KAAK,KAAK,EAAE;YACzB,MAAM,CAAC,wBAAwB,GAAG,KAAK,CAAC;SAC3C;IACL,CAAC,CAAC;IAEF;;;;;;;OAOG;IACH,IAAM,mBAAmB,GAAkC,UACvD,KAA6B,EAC7B,OAAoB,EACpB,OAA0B;QAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;QAEnC,IAAI,OAAO,CAAC,OAAO,CAAC,iCAAqB,CAAC,EAAE;YACxC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,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AAM,SAAS,GAAG,QAAQ,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC,iBAAiB,CAAC,KAAI,EAAE,CAAC,CAAC;QAExE,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC9B,CAAC","sourcesContent":["import addParser from '../utils/addParser';\nimport { createListLevel, parseFormat } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport {\n COMMENT_HIGHLIGHT_CLASS,\n COMMENT_HIGHLIGHT_CLICKED_CLASS,\n LIST_CONTAINER_ELEMENT_CLASS_NAME,\n TEMP_ELEMENTS_CLASSES,\n WAC_IDENTIFY_SELECTOR,\n} from './constants';\nimport type {\n BeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelBlockGroup,\n ContentModelListItemLevelFormat,\n ContentModelListLevel,\n ContentModelSegmentFormat,\n DomToModelContext,\n DomToModelListFormat,\n ElementProcessor,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\nconst LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];\nconst LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');\n\ninterface WacContext extends DomToModelListFormat {\n /**\n * Current list levels\n */\n currentListLevels?: ContentModelListLevel[];\n /**\n * Array to keep the start of the lists and determine if the start override should be set.\n */\n listItemThread?: number[];\n}\n\n/**\n * Wac components do not use sub and super tags, instead only add vertical align to a span.\n * This parser normalize the content for content model\n */\nconst wacSubSuperParser: FormatParser<ContentModelSegmentFormat> = (\n format: ContentModelSegmentFormat,\n element: HTMLElement\n): void => {\n const verticalAlign = element.style.verticalAlign;\n if (verticalAlign === 'super') {\n format.superOrSubScriptSequence = 'super';\n }\n if (verticalAlign === 'sub') {\n format.superOrSubScriptSequence = 'sub';\n }\n};\n\n/**\n * This processor does:\n * 1) Remove the display and margin of the element.\n * 2) When an element should be ignored but should handle the child elements call the default child processor.\n * 3) Removes the End of Paragraph element to avoid empty lines, we should only remove this if the previous element of the EOP is an EmptyTextRun\n * 4) Finally call the default processor.\n * @returns\n */\nconst wacElementProcessor: ElementProcessor<HTMLElement> = (\n group: ContentModelBlockGroup,\n element: HTMLElement,\n context: DomToModelContext\n): void => {\n const elementTag = element.tagName;\n\n if (element.matches(WAC_IDENTIFY_SELECTOR)) {\n element.style.removeProperty('display');\n element.style.removeProperty('margin');\n }\n\n if (element.classList.contains(LIST_CONTAINER_ELEMENT_CLASS_NAME)) {\n context.elementProcessors.child(group, element, context);\n return;\n }\n\n if (TEMP_ELEMENTS_CLASSES.some(className => element.classList.contains(className))) {\n return;\n } else if (shouldClearListContext(elementTag, element, context)) {\n const { listFormat } = context;\n listFormat.levels = [];\n listFormat.listParent = undefined;\n }\n\n context.defaultElementProcessors.element(group, element, context);\n};\n\n/**\n * This processor calls the default list processor and then sets the correct list level and list bullet.\n */\nconst wacLiElementProcessor: ElementProcessor<HTMLLIElement> = (\n group: ContentModelBlockGroup,\n element: HTMLLIElement,\n context: DomToModelContext\n): void => {\n const level = parseInt(element.getAttribute('data-aria-level') ?? '');\n const listFormat = context.listFormat as WacContext;\n const listType =\n listFormat.levels[context.listFormat.levels.length - 1]?.listType ||\n (element.closest('ol,ul')?.tagName.toUpperCase() as 'UL' | 'OL');\n const newLevel: ContentModelListLevel = createListLevel(listType, context.blockFormat);\n parseFormat(element, context.formatParsers.listLevelThread, newLevel.format, context);\n parseFormat(element, context.formatParsers.listLevel, newLevel.format, context);\n context.listFormat.levels = listFormat.currentListLevels || context.listFormat.levels;\n\n if (level > 0) {\n if (level > context.listFormat.levels.length) {\n while (level != context.listFormat.levels.length) {\n context.listFormat.levels.push(newLevel);\n }\n } else {\n context.listFormat.levels.splice(level, context.listFormat.levels.length - 1);\n context.listFormat.levels[level - 1] = newLevel;\n }\n }\n\n context.defaultElementProcessors.li?.(group, element, context);\n\n const listParent = listFormat.listParent;\n if (listParent) {\n const lastblock = listParent.blocks[listParent.blocks.length - 1];\n if (lastblock.blockType == 'BlockGroup' && lastblock.blockGroupType == 'ListItem') {\n const currentLevel = lastblock.levels[lastblock.levels.length - 1];\n updateStartOverride(currentLevel, element, context);\n }\n }\n\n const newLevels: ContentModelListLevel[] = [];\n listFormat.levels.forEach(v => {\n const newValue: ContentModelListLevel = {\n dataset: { ...v.dataset },\n format: { ...v.format },\n listType: v.listType,\n };\n newLevels.push(newValue);\n });\n listFormat.currentListLevels = newLevels;\n listFormat.levels = [];\n};\n\n/**\n * This parsers does:\n * 1) Sets the display for dummy item to undefined when the current style is block.\n * 2) Removes the Margin Left\n */\nconst wacListItemParser: FormatParser<ContentModelListItemLevelFormat> = (\n format: ContentModelListItemLevelFormat,\n element: HTMLElement\n): void => {\n if (element.style.display === 'block') {\n format.displayForDummyItem = undefined;\n }\n\n format.marginLeft = undefined;\n};\n\n/**\n * Wac usually adds padding to lists which is unwanted so remove it.\n */\nconst wacListLevelParser: FormatParser<ContentModelListItemLevelFormat> = (\n format: ContentModelListItemLevelFormat\n): void => {\n format.marginLeft = undefined;\n format.paddingLeft = undefined;\n};\n\n/**\n * This function returns whether we need to clear the list format.\n * Word Online wraps lists inside divs to have this structure:\n *\n * <div class='ListContainerWrapper'>\n * <ol>...</ol>\n * </div>\n * <div>\n * <p>...</p>\n * <div>\n * <div class='ListContainerWrapper'>\n * <ol>...</ol>\n * </div>\n *\n * So if a elements is not contained inside of a list we should clear the list context to prevent normal text to be\n * transformed into list\n * For the above scenario, if we do not clear the format, the content inside of the second div would be transformed to a list too.\n */\nfunction shouldClearListContext(\n elementTag: string,\n element: HTMLElement,\n context: DomToModelContext\n) {\n return (\n context.listFormat.levels.length > 0 &&\n LIST_ELEMENT_TAGS.every(tag => tag != elementTag) &&\n !element.closest(LIST_ELEMENT_SELECTOR)\n );\n}\n\nconst wacCommentParser: FormatParser<ContentModelSegmentFormat> = (\n format: ContentModelSegmentFormat,\n element: HTMLElement\n): void => {\n if (\n element.className.includes(COMMENT_HIGHLIGHT_CLASS) ||\n element.className.includes(COMMENT_HIGHLIGHT_CLICKED_CLASS)\n ) {\n delete format.backgroundColor;\n }\n};\n/**\n * @internal\n * Convert pasted content from Office Online\n * Once it is known that the document is from WAC\n * We need to remove the display property and margin from all the list item\n * @param ev BeforePasteEvent\n */\nexport function processPastedContentWacComponents(ev: BeforePasteEvent) {\n addParser(ev.domToModelOption, 'segment', wacSubSuperParser);\n addParser(ev.domToModelOption, 'listItemThread', wacListItemParser);\n addParser(ev.domToModelOption, 'listLevel', wacListLevelParser);\n addParser(ev.domToModelOption, 'container', wacContainerParser);\n addParser(ev.domToModelOption, 'table', wacContainerParser);\n addParser(ev.domToModelOption, 'segment', wacCommentParser);\n\n setProcessor(ev.domToModelOption, 'element', wacElementProcessor);\n setProcessor(ev.domToModelOption, 'li', wacLiElementProcessor);\n}\n\nconst wacContainerParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.marginLeft.startsWith('-')) {\n delete format.marginLeft;\n }\n};\n\nfunction updateStartOverride(\n currentLevel: ContentModelListLevel | undefined,\n element: HTMLLIElement,\n ctx: DomToModelContext\n) {\n if (!currentLevel || currentLevel.listType == 'UL') {\n return;\n }\n\n const list = element.closest('ol');\n const listFormat = ctx.listFormat as WacContext;\n const [start, listLevel] = extractWordListMetadata(list, element);\n\n if (!listFormat.listItemThread) {\n listFormat.listItemThread = [];\n }\n\n const thread: number | undefined = listFormat.listItemThread[listLevel];\n if (thread && start - thread != 1) {\n currentLevel.format.startNumberOverride = start;\n }\n listFormat.listItemThread[listLevel] = start;\n}\nfunction extractWordListMetadata(\n list: HTMLElement | null | undefined,\n item: HTMLElement | null | undefined\n) {\n const itemIndex =\n item && Array.from(list?.querySelectorAll('li') || []).indexOf(item as HTMLLIElement);\n const start =\n parseInt(list?.getAttribute('start') || '1') + (itemIndex && itemIndex > 0 ? itemIndex : 0);\n const listLevel = parseInt(item?.getAttribute('data-aria-level') || '');\n\n return [start, listLevel];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"processPastedContentWacComponents.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WacComponents/processPastedContentWacComponents.ts"],"names":[],"mappings":";;;;IAuBA,IAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,IAAM,qBAAqB,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAa1D;;;OAGG;IACH,IAAM,iBAAiB,GAA4C,UAC/D,MAAiC,EACjC,OAAoB;QAEpB,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC;QAClD,IAAI,aAAa,KAAK,OAAO,EAAE;YAC3B,MAAM,CAAC,wBAAwB,GAAG,OAAO,CAAC;SAC7C;QACD,IAAI,aAAa,KAAK,KAAK,EAAE;YACzB,MAAM,CAAC,wBAAwB,GAAG,KAAK,CAAC;SAC3C;IACL,CAAC,CAAC;IAEF;;;;;;;OAOG;IACH,IAAM,mBAAmB,GAAkC,UACvD,KAA6B,EAC7B,OAAoB,EACpB,OAA0B;QAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;QAEnC,IAAI,OAAO,CAAC,OAAO,CAAC,iCAAqB,CAAC,EAAE;YACxC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;SAC1C;QAED,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,6CAAiC,CAAC,EAAE;YAC/D,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACzD,OAAO;SACV;QAED,IAAI,iCAAqB,CAAC,IAAI,CAAC,UAAA,SAAS,IAAI,OAAA,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAArC,CAAqC,CAAC,EAAE;YAChF,OAAO;SAC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AAE,OAAO,CAAC,IAAA,EAA1D,KAAK,QAAA,EAAE,SAAS,QAA0C,CAAC;QAElE,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;YAC5B,UAAU,CAAC,cAAc,GAAG,EAAE,CAAC;SAClC;QAED,IAAM,MAAM,GAAuB,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACxE,IAAI,MAAM,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,EAAE;YAC/B,YAAY,CAAC,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC;SACnD;QACD,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;IACjD,CAAC;IACD,SAAS,uBAAuB,CAC5B,IAAoC,EACpC,IAAoC;QAEpC,IAAM,SAAS,GACX,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,CAAC,IAAI,CAAC,KAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAqB,CAAC,CAAC;QAC1F,IAAM,KAAK,GACP,QAAQ,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC,OAAO,CAAC,KAAI,GAAG,CAAC,GAAG,CAAC,SAAS,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChG,IAAM,SAAS,GAAG,QAAQ,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC,iBAAiB,CAAC,KAAI,EAAE,CAAC,CAAC;QAExE,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC9B,CAAC","sourcesContent":["import { addParser } from '../utils/addParser';\nimport { createListLevel, parseFormat } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport {\n COMMENT_HIGHLIGHT_CLASS,\n COMMENT_HIGHLIGHT_CLICKED_CLASS,\n LIST_CONTAINER_ELEMENT_CLASS_NAME,\n TEMP_ELEMENTS_CLASSES,\n WAC_IDENTIFY_SELECTOR,\n} from './constants';\nimport type {\n BeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelBlockGroup,\n ContentModelListItemLevelFormat,\n ContentModelListLevel,\n ContentModelSegmentFormat,\n DomToModelContext,\n DomToModelListFormat,\n ElementProcessor,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\nconst LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];\nconst LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');\n\ninterface WacContext extends DomToModelListFormat {\n /**\n * Current list levels\n */\n currentListLevels?: ContentModelListLevel[];\n /**\n * Array to keep the start of the lists and determine if the start override should be set.\n */\n listItemThread?: number[];\n}\n\n/**\n * Wac components do not use sub and super tags, instead only add vertical align to a span.\n * This parser normalize the content for content model\n */\nconst wacSubSuperParser: FormatParser<ContentModelSegmentFormat> = (\n format: ContentModelSegmentFormat,\n element: HTMLElement\n): void => {\n const verticalAlign = element.style.verticalAlign;\n if (verticalAlign === 'super') {\n format.superOrSubScriptSequence = 'super';\n }\n if (verticalAlign === 'sub') {\n format.superOrSubScriptSequence = 'sub';\n }\n};\n\n/**\n * This processor does:\n * 1) Remove the display and margin of the element.\n * 2) When an element should be ignored but should handle the child elements call the default child processor.\n * 3) Removes the End of Paragraph element to avoid empty lines, we should only remove this if the previous element of the EOP is an EmptyTextRun\n * 4) Finally call the default processor.\n * @returns\n */\nconst wacElementProcessor: ElementProcessor<HTMLElement> = (\n group: ContentModelBlockGroup,\n element: HTMLElement,\n context: DomToModelContext\n): void => {\n const elementTag = element.tagName;\n\n if (element.matches(WAC_IDENTIFY_SELECTOR)) {\n element.style.removeProperty('display');\n element.style.removeProperty('margin');\n }\n\n if (element.classList.contains(LIST_CONTAINER_ELEMENT_CLASS_NAME)) {\n context.elementProcessors.child(group, element, context);\n return;\n }\n\n if (TEMP_ELEMENTS_CLASSES.some(className => element.classList.contains(className))) {\n return;\n } else if (shouldClearListContext(elementTag, element, context)) {\n const { listFormat } = context;\n listFormat.levels = [];\n listFormat.listParent = undefined;\n }\n\n context.defaultElementProcessors.element(group, element, context);\n};\n\n/**\n * This processor calls the default list processor and then sets the correct list level and list bullet.\n */\nconst wacLiElementProcessor: ElementProcessor<HTMLLIElement> = (\n group: ContentModelBlockGroup,\n element: HTMLLIElement,\n context: DomToModelContext\n): void => {\n const level = parseInt(element.getAttribute('data-aria-level') ?? '');\n const listFormat = context.listFormat as WacContext;\n const listType =\n listFormat.levels[context.listFormat.levels.length - 1]?.listType ||\n (element.closest('ol,ul')?.tagName.toUpperCase() as 'UL' | 'OL');\n const newLevel: ContentModelListLevel = createListLevel(listType, context.blockFormat);\n parseFormat(element, context.formatParsers.listLevelThread, newLevel.format, context);\n parseFormat(element, context.formatParsers.listLevel, newLevel.format, context);\n context.listFormat.levels = listFormat.currentListLevels || context.listFormat.levels;\n\n if (level > 0) {\n if (level > context.listFormat.levels.length) {\n while (level != context.listFormat.levels.length) {\n context.listFormat.levels.push(newLevel);\n }\n } else {\n context.listFormat.levels.splice(level, context.listFormat.levels.length - 1);\n context.listFormat.levels[level - 1] = newLevel;\n }\n }\n\n context.defaultElementProcessors.li?.(group, element, context);\n\n const listParent = listFormat.listParent;\n if (listParent) {\n const lastblock = listParent.blocks[listParent.blocks.length - 1];\n if (lastblock.blockType == 'BlockGroup' && lastblock.blockGroupType == 'ListItem') {\n const currentLevel = lastblock.levels[lastblock.levels.length - 1];\n updateStartOverride(currentLevel, element, context);\n }\n }\n\n const newLevels: ContentModelListLevel[] = [];\n listFormat.levels.forEach(v => {\n const newValue: ContentModelListLevel = {\n dataset: { ...v.dataset },\n format: { ...v.format },\n listType: v.listType,\n };\n newLevels.push(newValue);\n });\n listFormat.currentListLevels = newLevels;\n listFormat.levels = [];\n};\n\n/**\n * This parsers does:\n * 1) Sets the display for dummy item to undefined when the current style is block.\n * 2) Removes the Margin Left\n */\nconst wacListItemParser: FormatParser<ContentModelListItemLevelFormat> = (\n format: ContentModelListItemLevelFormat,\n element: HTMLElement\n): void => {\n if (element.style.display === 'block') {\n format.displayForDummyItem = undefined;\n }\n\n format.marginLeft = undefined;\n};\n\n/**\n * Wac usually adds padding to lists which is unwanted so remove it.\n */\nconst wacListLevelParser: FormatParser<ContentModelListItemLevelFormat> = (\n format: ContentModelListItemLevelFormat\n): void => {\n format.marginLeft = undefined;\n format.paddingLeft = undefined;\n};\n\n/**\n * This function returns whether we need to clear the list format.\n * Word Online wraps lists inside divs to have this structure:\n *\n * <div class='ListContainerWrapper'>\n * <ol>...</ol>\n * </div>\n * <div>\n * <p>...</p>\n * <div>\n * <div class='ListContainerWrapper'>\n * <ol>...</ol>\n * </div>\n *\n * So if a elements is not contained inside of a list we should clear the list context to prevent normal text to be\n * transformed into list\n * For the above scenario, if we do not clear the format, the content inside of the second div would be transformed to a list too.\n */\nfunction shouldClearListContext(\n elementTag: string,\n element: HTMLElement,\n context: DomToModelContext\n) {\n return (\n context.listFormat.levels.length > 0 &&\n LIST_ELEMENT_TAGS.every(tag => tag != elementTag) &&\n !element.closest(LIST_ELEMENT_SELECTOR)\n );\n}\n\nconst wacCommentParser: FormatParser<ContentModelSegmentFormat> = (\n format: ContentModelSegmentFormat,\n element: HTMLElement\n): void => {\n if (\n element.className.includes(COMMENT_HIGHLIGHT_CLASS) ||\n element.className.includes(COMMENT_HIGHLIGHT_CLICKED_CLASS)\n ) {\n delete format.backgroundColor;\n }\n};\n/**\n * @internal\n * Convert pasted content from Office Online\n * Once it is known that the document is from WAC\n * We need to remove the display property and margin from all the list item\n * @param ev BeforePasteEvent\n */\nexport function processPastedContentWacComponents(ev: BeforePasteEvent) {\n addParser(ev.domToModelOption, 'segment', wacSubSuperParser);\n addParser(ev.domToModelOption, 'listItemThread', wacListItemParser);\n addParser(ev.domToModelOption, 'listLevel', wacListLevelParser);\n addParser(ev.domToModelOption, 'container', wacContainerParser);\n addParser(ev.domToModelOption, 'table', wacContainerParser);\n addParser(ev.domToModelOption, 'segment', wacCommentParser);\n\n setProcessor(ev.domToModelOption, 'element', wacElementProcessor);\n setProcessor(ev.domToModelOption, 'li', wacLiElementProcessor);\n}\n\nconst wacContainerParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.marginLeft.startsWith('-')) {\n delete format.marginLeft;\n }\n};\n\nfunction updateStartOverride(\n currentLevel: ContentModelListLevel | undefined,\n element: HTMLLIElement,\n ctx: DomToModelContext\n) {\n if (!currentLevel || currentLevel.listType == 'UL') {\n return;\n }\n\n const list = element.closest('ol');\n const listFormat = ctx.listFormat as WacContext;\n const [start, listLevel] = extractWordListMetadata(list, element);\n\n if (!listFormat.listItemThread) {\n listFormat.listItemThread = [];\n }\n\n const thread: number | undefined = listFormat.listItemThread[listLevel];\n if (thread && start - thread != 1) {\n currentLevel.format.startNumberOverride = start;\n }\n listFormat.listItemThread[listLevel] = start;\n}\nfunction extractWordListMetadata(\n list: HTMLElement | null | undefined,\n item: HTMLElement | null | undefined\n) {\n const itemIndex =\n item && Array.from(list?.querySelectorAll('li') || []).indexOf(item as HTMLLIElement);\n const start =\n parseInt(list?.getAttribute('start') || '1') + (itemIndex && itemIndex > 0 ? itemIndex : 0);\n const listLevel = parseInt(item?.getAttribute('data-aria-level') || '');\n\n return [start, listLevel];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordMetadata.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"WordMetadata.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/WordMetadata.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @internal\n * Metadata used when processing word desktop lists\n */\nexport interface WordMetadata {\n readonly 'mso-level-number-format'?: string;\n readonly 'mso-level-start-at'?: string;\n readonly 'mso-level-text'?: string;\n}\n"]}
|
|
@@ -20,4 +20,4 @@ import type { BeforePasteEvent } from 'roosterjs-content-model-types';
|
|
|
20
20
|
* 5. Save data in record and only use the required information.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export declare function getStyleMetadata(ev: BeforePasteEvent, trustedHTMLHandler: (val: string) => string): Map<string, WordMetadata>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStyleMetadata = void 0;
|
|
4
5
|
var FORMATING_REGEX = /[\n\t'{}"]+/g;
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
@@ -74,6 +75,6 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
74
75
|
});
|
|
75
76
|
return metadataMap;
|
|
76
77
|
}
|
|
77
|
-
exports.
|
|
78
|
+
exports.getStyleMetadata = getStyleMetadata;
|
|
78
79
|
});
|
|
79
80
|
//# sourceMappingURL=getStyleMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStyleMetadata.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"getStyleMetadata.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/getStyleMetadata.ts"],"names":[],"mappings":";;;;IAIA,IAAM,eAAe,GAAG,cAAc,CAAC;IAEvC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAgB,gBAAgB,CAC5B,EAAoB,EACpB,kBAA2C;QAE3C,IAAM,WAAW,GAA8B,IAAI,GAAG,EAAE,CAAC;QACzD,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC;QAC5F,IAAM,MA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;wBACd,IAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC;wBAC5E,IAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC;wBAChF,KAAK;wBACL,MAAM,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC;qBACvC;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAM,IAAI,GAAiB;oBACvB,yBAAyB,EAAE,MAAM,CAAC,yBAAyB,CAAC;oBAC5D,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,CAAC,IAAI,GAAG;oBACzD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,CAAC;iBAC7C,CAAC;gBACF,IAAI,IAAA,2CAAa,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAX,CAAW,CAAC,EAAE;oBAC9C,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;iBACvC;;YAzCL,OAAO,KAAK,IAAI,CAAC;;aA0ChB;QACL,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACvB,CAAC;IAzDD,4CAyDC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport type { WordMetadata } from './WordMetadata';\nimport type { BeforePasteEvent } from 'roosterjs-content-model-types';\n\nconst FORMATING_REGEX = /[\\n\\t'{}\"]+/g;\n\n/**\n * @internal\n * Word Desktop content has a style tag that contains data for the lists.\n * So this function query that style tag and extract the data from the innerHTML, since it is not available from the HTMLStyleElement.sheet.\n *\n * The format is like:\n * example of style element content\n * @list l0:level1 {\n * styleTag: styleValue;\n * ...\n * }\n *\n * To extract the data:\n * 1. Substring the value of the style selector, using @ index and { index\n * 2. Substring the value of the style rules by Substring the content between { and }\n * 3. Split the value of the rules using ; as separator { styleTag: styleValue; styleTag1: StyleValue1 } = ['styleTag: styleValue', 'styleTag1: StyleValue1']\n * 4. Split the value of the rule using : as separator: styleTag: styleValue = [styleTag, styleValue]\n * 5. Save data in record and only use the required information.\n *\n */\nexport function getStyleMetadata(\n ev: BeforePasteEvent,\n trustedHTMLHandler: (val: string) => string\n) {\n const metadataMap: Map<string, WordMetadata> = new Map();\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(ev.htmlBefore), 'text/html');\n const styles = doc.querySelectorAll('style');\n\n styles.forEach(style => {\n const text = style?.innerHTML.trim() || '';\n\n let index = 0;\n while (index >= 0) {\n const indexAt = text.indexOf('@', index + 1);\n const indexCurlyEnd = text.indexOf('}', indexAt);\n const indexCurlyStart = text.indexOf('{', indexAt);\n index = indexAt;\n\n // 1.\n const metadataName = text\n .substring(indexAt + 1, indexCurlyStart)\n .replace(FORMATING_REGEX, '')\n .replace('list', '')\n .trimRight()\n .trimLeft();\n\n // 2.\n const dataName = text\n .substring(indexCurlyStart, indexCurlyEnd + 1)\n .trimLeft()\n .trimRight();\n const record: Record<string, string> = {};\n\n // 3.\n const entries = dataName.split(';');\n entries.forEach(entry => {\n // 4.\n const [key, value] = entry.split(':');\n if (key && value) {\n const formatedKey = key.replace(FORMATING_REGEX, '').trimRight().trimLeft();\n const formatedValue = value.replace(FORMATING_REGEX, '').trimRight().trimLeft();\n // 5.\n record[formatedKey] = formatedValue;\n }\n });\n\n const data: WordMetadata = {\n 'mso-level-number-format': record['mso-level-number-format'],\n 'mso-level-start-at': record['mso-level-start-at'] || '1',\n 'mso-level-text': record['mso-level-text'],\n };\n if (getObjectKeys(data).some(key => !!data[key])) {\n metadataMap.set(metadataName, data);\n }\n }\n });\n return metadataMap;\n}\n"]}
|
|
@@ -2,21 +2,18 @@ define(["require", "exports", "../utils/addParser", "./getStyleMetadata", "../ut
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.processPastedContentFromWordDesktop = void 0;
|
|
5
|
-
var PERCENTAGE_REGEX = /%/;
|
|
6
|
-
var DEFAULT_BROWSER_LINE_HEIGHT_PERCENTAGE = 120;
|
|
7
5
|
/**
|
|
8
6
|
* @internal
|
|
9
7
|
* Handles Pasted content when source is Word Desktop
|
|
10
8
|
* @param ev BeforePasteEvent
|
|
11
9
|
*/
|
|
12
10
|
function processPastedContentFromWordDesktop(ev, trustedHTMLHandler) {
|
|
13
|
-
var metadataMap = (0, getStyleMetadata_1.
|
|
11
|
+
var metadataMap = (0, getStyleMetadata_1.getStyleMetadata)(ev, trustedHTMLHandler);
|
|
14
12
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wordDesktopElementProcessor(metadataMap));
|
|
15
|
-
(0, addParser_1.
|
|
16
|
-
(0, addParser_1.
|
|
17
|
-
(0, addParser_1.
|
|
18
|
-
(0, addParser_1.
|
|
19
|
-
(0, addParser_1.default)(ev.domToModelOption, 'table', wordTableParser);
|
|
13
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'block', removeNegativeTextIndentParser_1.removeNegativeTextIndentParser);
|
|
14
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'listLevel', listLevelParser);
|
|
15
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'container', wordTableParser);
|
|
16
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'table', wordTableParser);
|
|
20
17
|
}
|
|
21
18
|
exports.processPastedContentFromWordDesktop = processPastedContentFromWordDesktop;
|
|
22
19
|
var wordDesktopElementProcessor = function (metadataKey) {
|
|
@@ -29,15 +26,6 @@ define(["require", "exports", "../utils/addParser", "./getStyleMetadata", "../ut
|
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
28
|
};
|
|
32
|
-
function removeNonValidLineHeight(format, element, context, defaultStyle) {
|
|
33
|
-
//If the line height is less than the browser default line height, line between the text is going to be too narrow
|
|
34
|
-
var parsedLineHeight;
|
|
35
|
-
if (PERCENTAGE_REGEX.test(element.style.lineHeight) &&
|
|
36
|
-
!isNaN((parsedLineHeight = parseInt(element.style.lineHeight))) &&
|
|
37
|
-
parsedLineHeight < DEFAULT_BROWSER_LINE_HEIGHT_PERCENTAGE) {
|
|
38
|
-
format.lineHeight = defaultStyle.lineHeight;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
29
|
function listLevelParser(format, element, context, defaultStyle) {
|
|
42
30
|
if (element.style.marginLeft != '') {
|
|
43
31
|
format.marginLeft = defaultStyle.marginLeft;
|