roosterjs-content-model-plugins 9.0.1 → 9.2.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 +19 -4
- package/lib/autoFormat/AutoFormatPlugin.js +61 -6
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib/autoFormat/hyphen/transformHyphen.d.ts +5 -0
- package/lib/autoFormat/hyphen/transformHyphen.js +35 -0
- package/lib/autoFormat/hyphen/transformHyphen.js.map +1 -0
- package/lib/autoFormat/link/createLink.js +8 -6
- package/lib/autoFormat/link/createLink.js.map +1 -1
- package/lib/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
- package/lib/autoFormat/link/createLinkAfterSpace.js +17 -34
- package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib/autoFormat/link/unlink.js +4 -5
- package/lib/autoFormat/link/unlink.js.map +1 -1
- package/lib/autoFormat/list/keyboardListTrigger.d.ts +2 -2
- package/lib/autoFormat/list/keyboardListTrigger.js +9 -19
- package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib/autoFormat/numbers/transformFraction.d.ts +5 -0
- package/lib/autoFormat/numbers/transformFraction.js +27 -0
- package/lib/autoFormat/numbers/transformFraction.js.map +1 -0
- package/lib/autoFormat/numbers/transformOrdinals.d.ts +5 -0
- package/lib/autoFormat/numbers/transformOrdinals.js +32 -0
- package/lib/autoFormat/numbers/transformOrdinals.js.map +1 -0
- package/lib/customReplace/CustomReplacePlugin.d.ts +61 -0
- package/lib/customReplace/CustomReplacePlugin.js +87 -0
- package/lib/customReplace/CustomReplacePlugin.js.map +1 -0
- package/lib/edit/EditPlugin.js +19 -1
- package/lib/edit/EditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteList.js +13 -7
- package/lib/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js +9 -2
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/keyboardDelete.js +2 -2
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardTab.js +28 -12
- package/lib/edit/keyboardTab.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnList.js +3 -3
- package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnParagraph.js +2 -2
- package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnTable.d.ts +6 -0
- package/lib/edit/tabUtils/handleTabOnTable.js +25 -0
- package/lib/edit/tabUtils/handleTabOnTable.js.map +1 -0
- package/lib/edit/tabUtils/handleTabOnTableCell.d.ts +6 -0
- package/lib/edit/tabUtils/handleTabOnTableCell.js +40 -0
- package/lib/edit/tabUtils/handleTabOnTableCell.js.map +1 -0
- package/lib/hyperlink/HyperlinkPlugin.d.ts +48 -0
- package/lib/hyperlink/HyperlinkPlugin.js +141 -0
- package/lib/hyperlink/HyperlinkPlugin.js.map +1 -0
- package/lib/hyperlink/HyperlinkToolTip.d.ts +7 -0
- package/lib/hyperlink/HyperlinkToolTip.js +3 -0
- package/lib/hyperlink/HyperlinkToolTip.js.map +1 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.js +10 -1
- package/lib/index.js.map +1 -1
- package/lib/markdown/MarkdownPlugin.d.ts +13 -4
- package/lib/markdown/MarkdownPlugin.js +31 -12
- package/lib/markdown/MarkdownPlugin.js.map +1 -1
- package/lib/markdown/utils/setFormat.d.ts +2 -2
- package/lib/markdown/utils/setFormat.js +21 -29
- package/lib/markdown/utils/setFormat.js.map +1 -1
- package/lib/picker/PickerHandler.d.ts +112 -0
- package/lib/picker/PickerHandler.js +3 -0
- package/lib/picker/PickerHandler.js.map +1 -0
- package/lib/picker/PickerHelper.d.ts +22 -0
- package/lib/picker/PickerHelper.js +3 -0
- package/lib/picker/PickerHelper.js.map +1 -0
- package/lib/picker/PickerHelperImpl.d.ts +25 -0
- package/lib/picker/PickerHelperImpl.js +54 -0
- package/lib/picker/PickerHelperImpl.js.map +1 -0
- package/lib/picker/PickerPlugin.d.ts +54 -0
- package/lib/picker/PickerPlugin.js +217 -0
- package/lib/picker/PickerPlugin.js.map +1 -0
- package/lib/picker/getQueryString.d.ts +5 -0
- package/lib/picker/getQueryString.js +36 -0
- package/lib/picker/getQueryString.js.map +1 -0
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.js +57 -0
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
- package/lib/shortcut/ShortcutPlugin.js +1 -0
- package/lib/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib/shortcut/shortcuts.d.ts +10 -3
- package/lib/shortcut/shortcuts.js +21 -4
- package/lib/shortcut/shortcuts.js.map +1 -1
- package/lib/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
- package/lib/tableEdit/OnTableEditorCreatedCallback.js +3 -0
- package/lib/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
- package/lib/tableEdit/TableEditPlugin.d.ts +4 -1
- package/lib/tableEdit/TableEditPlugin.js +5 -2
- package/lib/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib/tableEdit/editors/TableEditor.d.ts +4 -1
- package/lib/tableEdit/editors/TableEditor.js +23 -7
- package/lib/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib/tableEdit/editors/features/TableEditFeature.js +3 -3
- package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -1
- package/lib/tableEdit/editors/features/TableInserter.d.ts +2 -1
- package/lib/tableEdit/editors/features/TableInserter.js +7 -9
- package/lib/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib/tableEdit/editors/features/TableMover.d.ts +2 -1
- package/lib/tableEdit/editors/features/TableMover.js +8 -11
- package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib/tableEdit/editors/features/TableResizer.d.ts +2 -1
- package/lib/tableEdit/editors/features/TableResizer.js +19 -3
- package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +19 -4
- package/lib-amd/autoFormat/AutoFormatPlugin.js +57 -7
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-amd/autoFormat/hyphen/transformHyphen.d.ts +5 -0
- package/lib-amd/autoFormat/hyphen/transformHyphen.js +36 -0
- package/lib-amd/autoFormat/hyphen/transformHyphen.js.map +1 -0
- package/lib-amd/autoFormat/link/createLink.js +8 -6
- package/lib-amd/autoFormat/link/createLink.js.map +1 -1
- package/lib-amd/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js +18 -34
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib-amd/autoFormat/link/unlink.js +4 -5
- package/lib-amd/autoFormat/link/unlink.js.map +1 -1
- package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +2 -2
- package/lib-amd/autoFormat/list/keyboardListTrigger.js +10 -19
- package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-amd/autoFormat/numbers/transformFraction.d.ts +5 -0
- package/lib-amd/autoFormat/numbers/transformFraction.js +28 -0
- package/lib-amd/autoFormat/numbers/transformFraction.js.map +1 -0
- package/lib-amd/autoFormat/numbers/transformOrdinals.d.ts +5 -0
- package/lib-amd/autoFormat/numbers/transformOrdinals.js +33 -0
- package/lib-amd/autoFormat/numbers/transformOrdinals.js.map +1 -0
- package/lib-amd/customReplace/CustomReplacePlugin.d.ts +61 -0
- package/lib-amd/customReplace/CustomReplacePlugin.js +88 -0
- package/lib-amd/customReplace/CustomReplacePlugin.js.map +1 -0
- package/lib-amd/edit/EditPlugin.js +19 -1
- package/lib-amd/edit/EditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteList.js +13 -7
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +9 -3
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.js +2 -2
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardTab.js +27 -13
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnList.js +3 -3
- package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnTable.d.ts +6 -0
- package/lib-amd/edit/tabUtils/handleTabOnTable.js +25 -0
- package/lib-amd/edit/tabUtils/handleTabOnTable.js.map +1 -0
- package/lib-amd/edit/tabUtils/handleTabOnTableCell.d.ts +6 -0
- package/lib-amd/edit/tabUtils/handleTabOnTableCell.js +40 -0
- package/lib-amd/edit/tabUtils/handleTabOnTableCell.js.map +1 -0
- package/lib-amd/hyperlink/HyperlinkPlugin.d.ts +48 -0
- package/lib-amd/hyperlink/HyperlinkPlugin.js +142 -0
- package/lib-amd/hyperlink/HyperlinkPlugin.js.map +1 -0
- package/lib-amd/hyperlink/HyperlinkToolTip.d.ts +7 -0
- package/lib-amd/hyperlink/HyperlinkToolTip.js +5 -0
- package/lib-amd/hyperlink/HyperlinkToolTip.js.map +1 -0
- package/lib-amd/index.d.ts +9 -1
- package/lib-amd/index.js +7 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/markdown/MarkdownPlugin.d.ts +13 -4
- package/lib-amd/markdown/MarkdownPlugin.js +31 -12
- package/lib-amd/markdown/MarkdownPlugin.js.map +1 -1
- package/lib-amd/markdown/utils/setFormat.d.ts +2 -2
- package/lib-amd/markdown/utils/setFormat.js +21 -29
- package/lib-amd/markdown/utils/setFormat.js.map +1 -1
- package/lib-amd/picker/PickerHandler.d.ts +112 -0
- package/lib-amd/picker/PickerHandler.js +5 -0
- package/lib-amd/picker/PickerHandler.js.map +1 -0
- package/lib-amd/picker/PickerHelper.d.ts +22 -0
- package/lib-amd/picker/PickerHelper.js +5 -0
- package/lib-amd/picker/PickerHelper.js.map +1 -0
- package/lib-amd/picker/PickerHelperImpl.d.ts +25 -0
- package/lib-amd/picker/PickerHelperImpl.js +53 -0
- package/lib-amd/picker/PickerHelperImpl.js.map +1 -0
- package/lib-amd/picker/PickerPlugin.d.ts +54 -0
- package/lib-amd/picker/PickerPlugin.js +215 -0
- package/lib-amd/picker/PickerPlugin.js.map +1 -0
- package/lib-amd/picker/getQueryString.d.ts +5 -0
- package/lib-amd/picker/getQueryString.js +37 -0
- package/lib-amd/picker/getQueryString.js.map +1 -0
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js +58 -0
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
- package/lib-amd/shortcut/ShortcutPlugin.js +1 -0
- package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-amd/shortcut/shortcuts.d.ts +10 -3
- package/lib-amd/shortcut/shortcuts.js +21 -4
- package/lib-amd/shortcut/shortcuts.js.map +1 -1
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib-amd/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
- package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js +5 -0
- package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
- package/lib-amd/tableEdit/TableEditPlugin.d.ts +4 -1
- package/lib-amd/tableEdit/TableEditPlugin.js +5 -2
- package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib-amd/tableEdit/editors/TableEditor.d.ts +4 -1
- package/lib-amd/tableEdit/editors/TableEditor.js +23 -7
- package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js +3 -3
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +2 -1
- package/lib-amd/tableEdit/editors/features/TableInserter.js +7 -9
- package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableMover.d.ts +2 -1
- package/lib-amd/tableEdit/editors/features/TableMover.js +8 -11
- package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +2 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.js +19 -4
- package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +19 -4
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +61 -6
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-mjs/autoFormat/hyphen/transformHyphen.d.ts +5 -0
- package/lib-mjs/autoFormat/hyphen/transformHyphen.js +31 -0
- package/lib-mjs/autoFormat/hyphen/transformHyphen.js.map +1 -0
- package/lib-mjs/autoFormat/link/createLink.js +9 -7
- package/lib-mjs/autoFormat/link/createLink.js.map +1 -1
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +17 -34
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib-mjs/autoFormat/link/unlink.js +4 -5
- package/lib-mjs/autoFormat/link/unlink.js.map +1 -1
- package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +2 -2
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js +9 -19
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-mjs/autoFormat/numbers/transformFraction.d.ts +5 -0
- package/lib-mjs/autoFormat/numbers/transformFraction.js +23 -0
- package/lib-mjs/autoFormat/numbers/transformFraction.js.map +1 -0
- package/lib-mjs/autoFormat/numbers/transformOrdinals.d.ts +5 -0
- package/lib-mjs/autoFormat/numbers/transformOrdinals.js +28 -0
- package/lib-mjs/autoFormat/numbers/transformOrdinals.js.map +1 -0
- package/lib-mjs/customReplace/CustomReplacePlugin.d.ts +61 -0
- package/lib-mjs/customReplace/CustomReplacePlugin.js +84 -0
- package/lib-mjs/customReplace/CustomReplacePlugin.js.map +1 -0
- package/lib-mjs/edit/EditPlugin.js +19 -1
- package/lib-mjs/edit/EditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteList.js +13 -7
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +9 -2
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.js +2 -2
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.js +28 -12
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnList.js +3 -3
- package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnTable.d.ts +6 -0
- package/lib-mjs/edit/tabUtils/handleTabOnTable.js +21 -0
- package/lib-mjs/edit/tabUtils/handleTabOnTable.js.map +1 -0
- package/lib-mjs/edit/tabUtils/handleTabOnTableCell.d.ts +6 -0
- package/lib-mjs/edit/tabUtils/handleTabOnTableCell.js +36 -0
- package/lib-mjs/edit/tabUtils/handleTabOnTableCell.js.map +1 -0
- package/lib-mjs/hyperlink/HyperlinkPlugin.d.ts +48 -0
- package/lib-mjs/hyperlink/HyperlinkPlugin.js +138 -0
- package/lib-mjs/hyperlink/HyperlinkPlugin.js.map +1 -0
- package/lib-mjs/hyperlink/HyperlinkToolTip.d.ts +7 -0
- package/lib-mjs/hyperlink/HyperlinkToolTip.js +2 -0
- package/lib-mjs/hyperlink/HyperlinkToolTip.js.map +1 -0
- package/lib-mjs/index.d.ts +9 -1
- package/lib-mjs/index.js +5 -1
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/markdown/MarkdownPlugin.d.ts +13 -4
- package/lib-mjs/markdown/MarkdownPlugin.js +31 -12
- package/lib-mjs/markdown/MarkdownPlugin.js.map +1 -1
- package/lib-mjs/markdown/utils/setFormat.d.ts +2 -2
- package/lib-mjs/markdown/utils/setFormat.js +21 -29
- package/lib-mjs/markdown/utils/setFormat.js.map +1 -1
- package/lib-mjs/picker/PickerHandler.d.ts +112 -0
- package/lib-mjs/picker/PickerHandler.js +2 -0
- package/lib-mjs/picker/PickerHandler.js.map +1 -0
- package/lib-mjs/picker/PickerHelper.d.ts +22 -0
- package/lib-mjs/picker/PickerHelper.js +2 -0
- package/lib-mjs/picker/PickerHelper.js.map +1 -0
- package/lib-mjs/picker/PickerHelperImpl.d.ts +25 -0
- package/lib-mjs/picker/PickerHelperImpl.js +51 -0
- package/lib-mjs/picker/PickerHelperImpl.js.map +1 -0
- package/lib-mjs/picker/PickerPlugin.d.ts +54 -0
- package/lib-mjs/picker/PickerPlugin.js +214 -0
- package/lib-mjs/picker/PickerPlugin.js.map +1 -0
- package/lib-mjs/picker/getQueryString.d.ts +5 -0
- package/lib-mjs/picker/getQueryString.js +32 -0
- package/lib-mjs/picker/getQueryString.js.map +1 -0
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js +53 -0
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
- package/lib-mjs/shortcut/ShortcutPlugin.js +2 -1
- package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-mjs/shortcut/shortcuts.d.ts +10 -3
- package/lib-mjs/shortcut/shortcuts.js +20 -3
- package/lib-mjs/shortcut/shortcuts.js.map +1 -1
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
- package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js +2 -0
- package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
- package/lib-mjs/tableEdit/TableEditPlugin.d.ts +4 -1
- package/lib-mjs/tableEdit/TableEditPlugin.js +5 -2
- package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib-mjs/tableEdit/editors/TableEditor.d.ts +4 -1
- package/lib-mjs/tableEdit/editors/TableEditor.js +24 -8
- package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js +3 -3
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +2 -1
- package/lib-mjs/tableEdit/editors/features/TableInserter.js +7 -9
- package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +2 -1
- package/lib-mjs/tableEdit/editors/features/TableMover.js +8 -11
- package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +2 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.js +19 -3
- package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/package.json +5 -5
- package/lib/autoFormat/link/getLinkSegment.d.ts +0 -5
- package/lib/autoFormat/link/getLinkSegment.js +0 -27
- package/lib/autoFormat/link/getLinkSegment.js.map +0 -1
- package/lib-amd/autoFormat/link/getLinkSegment.d.ts +0 -5
- package/lib-amd/autoFormat/link/getLinkSegment.js +0 -27
- package/lib-amd/autoFormat/link/getLinkSegment.js.map +0 -1
- package/lib-mjs/autoFormat/link/getLinkSegment.d.ts +0 -5
- package/lib-mjs/autoFormat/link/getLinkSegment.js +0 -23
- package/lib-mjs/autoFormat/link/getLinkSegment.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTableResizer = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
4
5
|
var createElement_1 = require("../../../pluginUtils/CreateElement/createElement");
|
|
5
6
|
var DragAndDropHelper_1 = require("../../../pluginUtils/DragAndDrop/DragAndDropHelper");
|
|
6
7
|
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
@@ -9,7 +10,7 @@ var TABLE_RESIZER_ID = '_Table_Resizer';
|
|
|
9
10
|
/**
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
|
-
function createTableResizer(table, editor, isRTL, onStart, onEnd, contentDiv, anchorContainer) {
|
|
13
|
+
function createTableResizer(table, editor, isRTL, onStart, onEnd, contentDiv, anchorContainer, onTableEditorCreated) {
|
|
13
14
|
var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(table.getBoundingClientRect());
|
|
14
15
|
if (!isTableBottomVisible(editor, rect, contentDiv)) {
|
|
15
16
|
return null;
|
|
@@ -36,15 +37,30 @@ function createTableResizer(table, editor, isRTL, onStart, onEnd, contentDiv, an
|
|
|
36
37
|
contentDiv: contentDiv,
|
|
37
38
|
};
|
|
38
39
|
setDivPosition(context, div);
|
|
39
|
-
var featureHandler = new
|
|
40
|
+
var featureHandler = new TableResizer(div, context, hideResizer, // Resizer is hidden while dragging only
|
|
40
41
|
{
|
|
41
42
|
onDragStart: onDragStart,
|
|
42
43
|
onDragging: onDragging,
|
|
43
44
|
onDragEnd: onDragEnd,
|
|
44
|
-
}, zoomScale, editor.getEnvironment().isMobileOrTablet);
|
|
45
|
+
}, zoomScale, editor.getEnvironment().isMobileOrTablet, onTableEditorCreated);
|
|
45
46
|
return { node: table, div: div, featureHandler: featureHandler };
|
|
46
47
|
}
|
|
47
48
|
exports.createTableResizer = createTableResizer;
|
|
49
|
+
var TableResizer = /** @class */ (function (_super) {
|
|
50
|
+
(0, tslib_1.__extends)(TableResizer, _super);
|
|
51
|
+
function TableResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, onTableEditorCreated) {
|
|
52
|
+
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
53
|
+
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('TableResizer', trigger);
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
TableResizer.prototype.dispose = function () {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = this.disposer) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
59
|
+
this.disposer = undefined;
|
|
60
|
+
_super.prototype.dispose.call(this);
|
|
61
|
+
};
|
|
62
|
+
return TableResizer;
|
|
63
|
+
}(DragAndDropHelper_1.DragAndDropHelper));
|
|
48
64
|
function onDragStart(context, event) {
|
|
49
65
|
context.onStart();
|
|
50
66
|
var editor = context.editor, table = context.table;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableResizer.js","sourceRoot":"","s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AAK,OAAO,MAAZ,CAAa;IACjC,IAAM,IAAI,GAAG,IAAA,2CAAa,EAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAE1D,IAAI,IAAI,EAAE;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,GAAM,IAAI,CAAC,MAAM,OAAI,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK;YACtB,CAAC,CAAI,IAAI,CAAC,IAAI,GAAG,oBAAoB,GAAG,CAAC,OAAI;YAC7C,CAAC,CAAI,IAAI,CAAC,KAAK,OAAI,CAAC;KAC3B;AACL,CAAC;AAED,SAAS,WAAW,CAAC,OAA2B,EAAE,OAAoB;IAClE,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;AACxC,CAAC;AAED,SAAS,oBAAoB,CACzB,MAAe,EACf,IAAiB,EACjB,UAAwB;IAExB,IAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IACpD,IAAI,IAAA,0CAAY,EAAC,UAAU,EAAE,cAAc,CAAC,IAAI,eAAe,IAAI,IAAI,EAAE;QACrE,IAAM,aAAa,GAAG,IAAA,2CAAa,EAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAExE,OAAO,CACH,CAAC,CAAC,aAAa;YACf,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;YACnC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CACxC,CAAC;KACL;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport {\n getFirstSelectedTable,\n isNodeOfType,\n normalizeRect,\n normalizeTable,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\n\nconst TABLE_RESIZER_LENGTH = 12;\nconst TABLE_RESIZER_ID = '_Table_Resizer';\n\n/**\n * @internal\n */\nexport function createTableResizer(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onStart: () => void,\n onEnd: () => false,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableBottomVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const document = table.ownerDocument;\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const createElementData = {\n tag: 'div',\n style: `position: fixed; cursor: ${\n isRTL ? 'ne' : 'nw'\n }-resize; user-select: none; border: 1px solid #808080`,\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_RESIZER_ID;\n div.style.width = `${TABLE_RESIZER_LENGTH}px`;\n div.style.height = `${TABLE_RESIZER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: DragAndDropContext = {\n isRTL,\n table,\n zoomScale,\n onStart,\n onEnd,\n div,\n editor,\n contentDiv,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new DragAndDropHelper<DragAndDropContext, DragAndDropInitValue>(\n div,\n context,\n hideResizer, // Resizer is hidden while dragging only\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\ninterface DragAndDropContext {\n table: HTMLTableElement;\n isRTL: boolean;\n zoomScale: number;\n onStart: () => void;\n onEnd: () => false;\n div: HTMLDivElement;\n editor: IEditor;\n contentDiv?: EventTarget | null;\n}\n\ninterface DragAndDropInitValue {\n originalRect: DOMRect;\n originalHeights: number[];\n originalWidths: number[];\n cmTable: ContentModelTable | undefined;\n}\n\nfunction onDragStart(context: DragAndDropContext, event: MouseEvent) {\n context.onStart();\n\n const { editor, table } = context;\n\n // Get current selection\n const selection = editor.getDOMSelection();\n\n // Select first cell of the table\n editor.setDOMSelection({\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n });\n\n // Get the table content model\n const cmTable = getFirstSelectedTable(editor.getContentModelCopy('disconnected'))[0];\n\n // Restore selection\n editor.setDOMSelection(selection);\n\n // Save original widths and heights\n const heights: number[] = [];\n cmTable?.rows.forEach(row => {\n heights.push(row.height);\n });\n const widths: number[] = [];\n cmTable?.widths.forEach(width => {\n widths.push(width);\n });\n\n return {\n originalRect: table.getBoundingClientRect(),\n cmTable,\n originalHeights: heights ?? [],\n originalWidths: widths ?? [],\n };\n}\n\nfunction onDragging(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue,\n deltaX: number,\n deltaY: number\n) {\n const { isRTL, zoomScale, table } = context;\n const { originalRect, originalHeights, originalWidths, cmTable } = initValue;\n\n const ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);\n const ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;\n const shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;\n const shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;\n\n // If the width of some external table is fixed, we need to make it resizable\n table.style.setProperty('width', null);\n // If the height of some external table is fixed, we need to make it resizable\n table.style.setProperty('height', null);\n\n // Assign new widths and heights to the CM table\n if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {\n // Modify the CM Table size\n for (let i = 0; i < cmTable.rows.length; i++) {\n for (let j = 0; j < cmTable.rows[i].cells.length; j++) {\n const cell = cmTable.rows[i].cells[j];\n if (cell) {\n if (shouldResizeX && i == 0) {\n cmTable.widths[j] = (originalWidths[j] ?? 0) * ratioX;\n }\n if (shouldResizeY && j == 0) {\n cmTable.rows[i].height = (originalHeights[i] ?? 0) * ratioY;\n }\n }\n }\n }\n\n // Normalize the table\n normalizeTable(cmTable);\n\n // Writeback CM Table size changes to DOM Table\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const td = tableRow.cells[col];\n td.style.width = cmTable.widths[col] + 'px';\n td.style.height = cmTable.rows[row].height + 'px';\n }\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction onDragEnd(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue | undefined\n) {\n if (context.editor.isDisposed()) {\n return false;\n }\n if (\n isTableBottomVisible(\n context.editor,\n normalizeRect(context.table.getBoundingClientRect()),\n context.contentDiv as Node\n )\n ) {\n context.div.style.visibility = 'visible';\n setDivPosition(context, context.div);\n }\n context.onEnd();\n return false;\n}\n\nfunction setDivPosition(context: DragAndDropContext, trigger: HTMLElement) {\n const { table, isRTL } = context;\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (rect) {\n trigger.style.top = `${rect.bottom}px`;\n trigger.style.left = isRTL\n ? `${rect.left - TABLE_RESIZER_LENGTH - 2}px`\n : `${rect.right}px`;\n }\n}\n\nfunction hideResizer(context: DragAndDropContext, trigger: HTMLElement) {\n trigger.style.visibility = 'hidden';\n}\n\nfunction isTableBottomVisible(\n editor: IEditor,\n rect: Rect | null,\n contentDiv?: Node | null\n): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return (\n !!containerRect &&\n containerRect.bottom >= rect.bottom &&\n visibleViewport.bottom >= rect.bottom\n );\n }\n\n return true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TableResizer.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableResizer.ts"],"names":[],"mappings":";;;;AAAA,kFAAiF;AACjF,wFAAuF;AAGvF,2EAKqC;AAKrC,IAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,IAAM,gBAAgB,GAAG,gBAAgB,CAA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CAAC,MAAM;YACnC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CACxC,CAAC;KACL;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\n\nimport type { OnTableEditorCreatedCallback } from '../../OnTableEditorCreatedCallback';\nimport {\n getFirstSelectedTable,\n isNodeOfType,\n normalizeRect,\n normalizeTable,\n} from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, IEditor, Rect } from 'roosterjs-content-model-types';\nimport type { TableEditFeature } from './TableEditFeature';\nimport type { DragAndDropHandler } from '../../../pluginUtils/DragAndDrop/DragAndDropHandler';\n\nconst TABLE_RESIZER_LENGTH = 12;\nconst TABLE_RESIZER_ID = '_Table_Resizer';\n\n/**\n * @internal\n */\nexport function createTableResizer(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onStart: () => void,\n onEnd: () => false,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement,\n onTableEditorCreated?: OnTableEditorCreatedCallback\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableBottomVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const document = table.ownerDocument;\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const createElementData = {\n tag: 'div',\n style: `position: fixed; cursor: ${\n isRTL ? 'ne' : 'nw'\n }-resize; user-select: none; border: 1px solid #808080`,\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_RESIZER_ID;\n div.style.width = `${TABLE_RESIZER_LENGTH}px`;\n div.style.height = `${TABLE_RESIZER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: DragAndDropContext = {\n isRTL,\n table,\n zoomScale,\n onStart,\n onEnd,\n div,\n editor,\n contentDiv,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new TableResizer(\n div,\n context,\n hideResizer, // Resizer is hidden while dragging only\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n editor.getEnvironment().isMobileOrTablet,\n onTableEditorCreated\n );\n\n return { node: table, div, featureHandler };\n}\n\nclass TableResizer extends DragAndDropHelper<DragAndDropContext, DragAndDropInitValue> {\n private disposer: undefined | (() => void);\n\n constructor(\n trigger: HTMLElement,\n context: DragAndDropContext,\n onSubmit: (context: DragAndDropContext, trigger: HTMLElement) => void,\n handler: DragAndDropHandler<DragAndDropContext, DragAndDropInitValue>,\n zoomScale: number,\n forceMobile?: boolean,\n onTableEditorCreated?: OnTableEditorCreatedCallback\n ) {\n super(trigger, context, onSubmit, handler, zoomScale, forceMobile);\n this.disposer = onTableEditorCreated?.('TableResizer', trigger);\n }\n\n dispose(): void {\n this.disposer?.();\n this.disposer = undefined;\n super.dispose();\n }\n}\n\ninterface DragAndDropContext {\n table: HTMLTableElement;\n isRTL: boolean;\n zoomScale: number;\n onStart: () => void;\n onEnd: () => false;\n div: HTMLDivElement;\n editor: IEditor;\n contentDiv?: EventTarget | null;\n}\n\ninterface DragAndDropInitValue {\n originalRect: DOMRect;\n originalHeights: number[];\n originalWidths: number[];\n cmTable: ContentModelTable | undefined;\n}\n\nfunction onDragStart(context: DragAndDropContext, event: MouseEvent) {\n context.onStart();\n\n const { editor, table } = context;\n\n // Get current selection\n const selection = editor.getDOMSelection();\n\n // Select first cell of the table\n editor.setDOMSelection({\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n });\n\n // Get the table content model\n const cmTable = getFirstSelectedTable(editor.getContentModelCopy('disconnected'))[0];\n\n // Restore selection\n editor.setDOMSelection(selection);\n\n // Save original widths and heights\n const heights: number[] = [];\n cmTable?.rows.forEach(row => {\n heights.push(row.height);\n });\n const widths: number[] = [];\n cmTable?.widths.forEach(width => {\n widths.push(width);\n });\n\n return {\n originalRect: table.getBoundingClientRect(),\n cmTable,\n originalHeights: heights ?? [],\n originalWidths: widths ?? [],\n };\n}\n\nfunction onDragging(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue,\n deltaX: number,\n deltaY: number\n) {\n const { isRTL, zoomScale, table } = context;\n const { originalRect, originalHeights, originalWidths, cmTable } = initValue;\n\n const ratioX = 1.0 + (deltaX / originalRect.width) * zoomScale * (isRTL ? -1 : 1);\n const ratioY = 1.0 + (deltaY / originalRect.height) * zoomScale;\n const shouldResizeX = Math.abs(ratioX - 1.0) > 1e-3;\n const shouldResizeY = Math.abs(ratioY - 1.0) > 1e-3;\n\n // If the width of some external table is fixed, we need to make it resizable\n table.style.setProperty('width', null);\n // If the height of some external table is fixed, we need to make it resizable\n table.style.setProperty('height', null);\n\n // Assign new widths and heights to the CM table\n if (cmTable && cmTable.rows && (shouldResizeX || shouldResizeY)) {\n // Modify the CM Table size\n for (let i = 0; i < cmTable.rows.length; i++) {\n for (let j = 0; j < cmTable.rows[i].cells.length; j++) {\n const cell = cmTable.rows[i].cells[j];\n if (cell) {\n if (shouldResizeX && i == 0) {\n cmTable.widths[j] = (originalWidths[j] ?? 0) * ratioX;\n }\n if (shouldResizeY && j == 0) {\n cmTable.rows[i].height = (originalHeights[i] ?? 0) * ratioY;\n }\n }\n }\n }\n\n // Normalize the table\n normalizeTable(cmTable);\n\n // Writeback CM Table size changes to DOM Table\n for (let row = 0; row < table.rows.length; row++) {\n const tableRow = table.rows[row];\n\n if (tableRow.cells.length == 0) {\n // Skip empty row\n continue;\n }\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n const td = tableRow.cells[col];\n td.style.width = cmTable.widths[col] + 'px';\n td.style.height = cmTable.rows[row].height + 'px';\n }\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction onDragEnd(\n context: DragAndDropContext,\n event: MouseEvent,\n initValue: DragAndDropInitValue | undefined\n) {\n if (context.editor.isDisposed()) {\n return false;\n }\n if (\n isTableBottomVisible(\n context.editor,\n normalizeRect(context.table.getBoundingClientRect()),\n context.contentDiv as Node\n )\n ) {\n context.div.style.visibility = 'visible';\n setDivPosition(context, context.div);\n }\n context.onEnd();\n return false;\n}\n\nfunction setDivPosition(context: DragAndDropContext, trigger: HTMLElement) {\n const { table, isRTL } = context;\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (rect) {\n trigger.style.top = `${rect.bottom}px`;\n trigger.style.left = isRTL\n ? `${rect.left - TABLE_RESIZER_LENGTH - 2}px`\n : `${rect.right}px`;\n }\n}\n\nfunction hideResizer(context: DragAndDropContext, trigger: HTMLElement) {\n trigger.style.visibility = 'hidden';\n}\n\nfunction isTableBottomVisible(\n editor: IEditor,\n rect: Rect | null,\n contentDiv?: Node | null\n): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return (\n !!containerRect &&\n containerRect.bottom >= rect.bottom &&\n visibleViewport.bottom >= rect.bottom\n );\n }\n\n return true;\n}\n"]}
|
|
@@ -6,19 +6,31 @@ export declare type AutoFormatOptions = {
|
|
|
6
6
|
/**
|
|
7
7
|
* When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true
|
|
8
8
|
*/
|
|
9
|
-
autoBullet
|
|
9
|
+
autoBullet?: boolean;
|
|
10
10
|
/**
|
|
11
11
|
* When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true
|
|
12
12
|
*/
|
|
13
|
-
autoNumbering
|
|
13
|
+
autoNumbering?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* When press backspace before a link, remove the hyperlink
|
|
16
16
|
*/
|
|
17
|
-
autoUnlink
|
|
17
|
+
autoUnlink?: boolean;
|
|
18
18
|
/**
|
|
19
19
|
* When paste content, create hyperlink for the pasted link
|
|
20
20
|
*/
|
|
21
|
-
autoLink
|
|
21
|
+
autoLink?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Transform -- into hyphen, if typed between two words
|
|
24
|
+
*/
|
|
25
|
+
autoHyphen?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Transform 1/2, 1/4, 3/4 into fraction character
|
|
28
|
+
*/
|
|
29
|
+
autoFraction?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Transform ordinal numbers into superscript
|
|
32
|
+
*/
|
|
33
|
+
autoOrdinals?: boolean;
|
|
22
34
|
};
|
|
23
35
|
/**
|
|
24
36
|
* Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
|
|
@@ -33,6 +45,9 @@ export declare class AutoFormatPlugin implements EditorPlugin {
|
|
|
33
45
|
* - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.
|
|
34
46
|
* - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.
|
|
35
47
|
* - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.
|
|
48
|
+
* - autoHyphen: A boolean that enables or disables automatic hyphen transformation. Defaults to false.
|
|
49
|
+
* - autoFraction: A boolean that enables or disables automatic fraction transformation. Defaults to false.
|
|
50
|
+
* - autoOrdinals: A boolean that enables or disables automatic ordinal number transformation. Defaults to false.
|
|
36
51
|
*/
|
|
37
52
|
constructor(options?: AutoFormatOptions);
|
|
38
53
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "./link/createLink", "./link/createLinkAfterSpace", "./list/keyboardListTrigger", "./link/unlink"], function (require, exports, createLink_1, createLinkAfterSpace_1, keyboardListTrigger_1, unlink_1) {
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom", "./link/createLink", "./link/createLinkAfterSpace", "roosterjs-content-model-api", "./list/keyboardListTrigger", "./numbers/transformFraction", "./hyphen/transformHyphen", "./numbers/transformOrdinals", "./link/unlink"], function (require, exports, roosterjs_content_model_dom_1, createLink_1, createLinkAfterSpace_1, roosterjs_content_model_api_1, keyboardListTrigger_1, transformFraction_1, transformHyphen_1, transformOrdinals_1, unlink_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AutoFormatPlugin = void 0;
|
|
@@ -10,6 +10,9 @@ define(["require", "exports", "./link/createLink", "./link/createLinkAfterSpace"
|
|
|
10
10
|
autoNumbering: false,
|
|
11
11
|
autoUnlink: false,
|
|
12
12
|
autoLink: false,
|
|
13
|
+
autoHyphen: false,
|
|
14
|
+
autoFraction: false,
|
|
15
|
+
autoOrdinals: false,
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
15
18
|
* Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
|
|
@@ -22,6 +25,9 @@ define(["require", "exports", "./link/createLink", "./link/createLinkAfterSpace"
|
|
|
22
25
|
* - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.
|
|
23
26
|
* - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.
|
|
24
27
|
* - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.
|
|
28
|
+
* - autoHyphen: A boolean that enables or disables automatic hyphen transformation. Defaults to false.
|
|
29
|
+
* - autoFraction: A boolean that enables or disables automatic fraction transformation. Defaults to false.
|
|
30
|
+
* - autoOrdinals: A boolean that enables or disables automatic ordinal number transformation. Defaults to false.
|
|
25
31
|
*/
|
|
26
32
|
function AutoFormatPlugin(options) {
|
|
27
33
|
if (options === void 0) { options = DefaultOptions; }
|
|
@@ -73,15 +79,49 @@ define(["require", "exports", "./link/createLink", "./link/createLinkAfterSpace"
|
|
|
73
79
|
}
|
|
74
80
|
};
|
|
75
81
|
AutoFormatPlugin.prototype.handleEditorInputEvent = function (editor, event) {
|
|
82
|
+
var _this = this;
|
|
76
83
|
var rawEvent = event.rawEvent;
|
|
77
|
-
|
|
84
|
+
var selection = editor.getDOMSelection();
|
|
85
|
+
if (rawEvent.inputType === 'insertText' &&
|
|
86
|
+
selection &&
|
|
87
|
+
selection.type === 'range' &&
|
|
88
|
+
selection.range.collapsed) {
|
|
78
89
|
switch (rawEvent.data) {
|
|
79
90
|
case ' ':
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
var formatOptions_1 = {
|
|
92
|
+
changeSource: '',
|
|
93
|
+
apiName: '',
|
|
94
|
+
};
|
|
95
|
+
(0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (model, previousSegment, paragraph, _markerFormat, context) {
|
|
96
|
+
var _a = _this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering, autoLink = _a.autoLink, autoHyphen = _a.autoHyphen, autoFraction = _a.autoFraction, autoOrdinals = _a.autoOrdinals;
|
|
97
|
+
var shouldHyphen = false;
|
|
98
|
+
var shouldLink = false;
|
|
99
|
+
var shouldList = false;
|
|
100
|
+
var shouldFraction = false;
|
|
101
|
+
var shouldOrdinals = false;
|
|
102
|
+
if (autoBullet || autoNumbering) {
|
|
103
|
+
shouldList = (0, keyboardListTrigger_1.keyboardListTrigger)(model, paragraph, context, autoBullet, autoNumbering);
|
|
104
|
+
}
|
|
105
|
+
if (autoLink) {
|
|
106
|
+
shouldLink = (0, createLinkAfterSpace_1.createLinkAfterSpace)(previousSegment, paragraph, context);
|
|
107
|
+
}
|
|
108
|
+
if (autoHyphen) {
|
|
109
|
+
shouldHyphen = (0, transformHyphen_1.transformHyphen)(previousSegment, paragraph, context);
|
|
110
|
+
}
|
|
111
|
+
if (autoFraction) {
|
|
112
|
+
shouldFraction = (0, transformFraction_1.transformFraction)(previousSegment, paragraph, context);
|
|
113
|
+
}
|
|
114
|
+
if (autoOrdinals) {
|
|
115
|
+
shouldOrdinals = (0, transformOrdinals_1.transformOrdinals)(previousSegment, paragraph, context);
|
|
116
|
+
}
|
|
117
|
+
formatOptions_1.apiName = getApiName(shouldList, shouldHyphen);
|
|
118
|
+
formatOptions_1.changeSource = getChangeSource(shouldList, shouldHyphen, shouldLink);
|
|
119
|
+
return (shouldList ||
|
|
120
|
+
shouldHyphen ||
|
|
121
|
+
shouldLink ||
|
|
122
|
+
shouldFraction ||
|
|
123
|
+
shouldOrdinals);
|
|
124
|
+
}, formatOptions_1);
|
|
85
125
|
break;
|
|
86
126
|
}
|
|
87
127
|
}
|
|
@@ -107,5 +147,15 @@ define(["require", "exports", "./link/createLink", "./link/createLinkAfterSpace"
|
|
|
107
147
|
return AutoFormatPlugin;
|
|
108
148
|
}());
|
|
109
149
|
exports.AutoFormatPlugin = AutoFormatPlugin;
|
|
150
|
+
var getApiName = function (shouldList, shouldHyphen) {
|
|
151
|
+
return shouldList ? 'autoToggleList' : shouldHyphen ? 'autoHyphen' : '';
|
|
152
|
+
};
|
|
153
|
+
var getChangeSource = function (shouldList, shouldHyphen, shouldLink) {
|
|
154
|
+
return shouldList || shouldHyphen
|
|
155
|
+
? roosterjs_content_model_dom_1.ChangeSource.AutoFormat
|
|
156
|
+
: shouldLink
|
|
157
|
+
? roosterjs_content_model_dom_1.ChangeSource.AutoLink
|
|
158
|
+
: '';
|
|
159
|
+
};
|
|
110
160
|
});
|
|
111
161
|
//# sourceMappingURL=AutoFormatPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":";;;;IAsCA;;OAEG;IACH,IAAM,cAAc,GAAgC;QAChD,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;KAClB,CAAC;IAEF;;;OAGG;IACH;QAGI;;;;;;WAMG;QACH,0BAAoB,OAA2C;YAA3C,wBAAA,EAAA,wBAA2C;YAA3C,YAAO,GAAP,OAAO,CAAoC;YATvD,WAAM,GAAmB,IAAI,CAAC;QAS4B,CAAC;QAEnE;;WAEG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Ae,EAAE,KAAmB;YAC3D,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAC3D,QAAQ,QAAQ,CAAC,GAAG,EAAE;oBAClB,KAAK,WAAW;wBACZ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;4BACzB,IAAA,eAAM,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;yBAC5B;wBACD,MAAM;iBACb;aACJ;QACL,CAAC;QAEO,oDAAyB,GAAjC,UAAkC,MAAe,EAAE,KAA0B;YACjE,IAAA,QAAQ,GAAK,IAAI,CAAC,OAAO,SAAjB,CAAkB;YAClC,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,IAAI,QAAQ,EAAE;gBACrC,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;aACtB;QACL,CAAC;QACL,uBAAC;IAAD,CAAC,AA9FD,IA8FC;IA9FY,4CAAgB","sourcesContent":["import { createLink } from './link/createLink';\nimport { createLinkAfterSpace } from './link/createLinkAfterSpace';\nimport { keyboardListTrigger } from './list/keyboardListTrigger';\nimport { unlink } from './link/unlink';\nimport type {\n ContentChangedEvent,\n EditorInputEvent,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Options to customize the Content Model Auto Format Plugin\n */\nexport type AutoFormatOptions = {\n /**\n * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true\n */\n autoBullet: boolean;\n\n /**\n * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true\n */\n autoNumbering: boolean;\n\n /**\n * When press backspace before a link, remove the hyperlink\n */\n autoUnlink: boolean;\n\n /**\n * When paste content, create hyperlink for the pasted link\n */\n autoLink: boolean;\n};\n\n/**\n * @internal\n */\nconst DefaultOptions: Required<AutoFormatOptions> = {\n autoBullet: false,\n autoNumbering: false,\n autoUnlink: false,\n autoLink: false,\n};\n\n/**\n * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.\n * It can be customized with options to enable or disable auto list features.\n */\nexport class AutoFormatPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n\n /**\n * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:\n * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.\n * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.\n * - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.\n * - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.\n */\n constructor(private options: AutoFormatOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'AutoFormat';\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) {\n switch (event.eventType) {\n case 'input':\n this.handleEditorInputEvent(this.editor, event);\n break;\n case 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n case 'contentChanged':\n this.handleContentChangedEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {\n const rawEvent = event.rawEvent;\n if (rawEvent.inputType === 'insertText') {\n switch (rawEvent.data) {\n case ' ':\n const { autoBullet, autoNumbering, autoLink } = this.options;\n keyboardListTrigger(editor, autoBullet, autoNumbering);\n if (autoLink) {\n createLinkAfterSpace(editor);\n }\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\n if (this.options.autoUnlink) {\n unlink(editor, rawEvent);\n }\n break;\n }\n }\n }\n\n private handleContentChangedEvent(editor: IEditor, event: ContentChangedEvent) {\n const { autoLink } = this.options;\n if (event.source == 'Paste' && autoLink) {\n createLink(editor);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":";;;;IA2DA;;OAEG;IACH,IAAM,cAAc,GAA+B;QAC/C,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;QACnB,YAAY,EAAE,KAAK;KACtB,CAAC;IAEF;;;OAGG;IACH;QAEI;;;;;;;;;WASG;QACH,0BAAoB,OAA2C;YAA3C,wBAAA,EAAA,wBAA2C;YAA3C,YAAO,GAAP,OAAO,CAAoC;YAXvD,WAAM,GAAmB,IAAI,CAAC;QAW4B,CAAC;QAEnE;;WAEG;QACH,kCAAO,GAAP;YACI,OAAO,YAAY,CAAC;QACxB,CAAC;QAED;;;;;WAKG;QACH,qCAAU,GAAV,UAAW,MAAe;YACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,kCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QAED;;;;;WAKG;QACH,wCAAa,GAAb,UAAc,KAAkB;YAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,QAAQ,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eAAM,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;yBAC5B;wBACD,MAAM;iBACb;aACJ;QACL,CAAC;QAEO,oDAAyB,GAAjC,UAAkC,MAAe,EAAE,KAA0B;YACjE,IAAA,QAAQ,GAAK,IAAI,CAAC,OAAO,SAAjB,CAAkB;YAClC,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,IAAI,QAAQ,EAAE;gBACrC,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;aACtB;QACL,CAAC;QACL,uBAAC;IAAD,CAAC,AA9KD,IA8KC;IA9KY,4CAAgB;IAgL7B,IAAM,UAAU,GAAG,UAAC,UAAmB,EAAE,YAAqB;QAC1D,OAAO,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,CAAC,CAAC;IAEF,IAAM,eAAe,GAAG,UAAC,UAAmB,EAAE,YAAqB,EAAE,UAAmB;QACpF,OAAO,UAAU,IAAI,YAAY;YAC7B,CAAC,CAAC,0CAAY,CAAC,UAAU;YACzB,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,0CAAY,CAAC,QAAQ;gBACvB,CAAC,CAAC,EAAE,CAAC;IACb,CAAC,CAAC","sourcesContent":["import { ChangeSource } from 'roosterjs-content-model-dom';\nimport { createLink } from './link/createLink';\nimport { createLinkAfterSpace } from './link/createLinkAfterSpace';\nimport { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\nimport { keyboardListTrigger } from './list/keyboardListTrigger';\nimport { transformFraction } from './numbers/transformFraction';\nimport { transformHyphen } from './hyphen/transformHyphen';\nimport { transformOrdinals } from './numbers/transformOrdinals';\nimport { unlink } from './link/unlink';\nimport type {\n ContentChangedEvent,\n EditorInputEvent,\n EditorPlugin,\n FormatContentModelOptions,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Options to customize the Content Model Auto Format Plugin\n */\nexport type AutoFormatOptions = {\n /**\n * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true\n */\n autoBullet?: boolean;\n\n /**\n * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true\n */\n autoNumbering?: boolean;\n\n /**\n * When press backspace before a link, remove the hyperlink\n */\n autoUnlink?: boolean;\n\n /**\n * When paste content, create hyperlink for the pasted link\n */\n autoLink?: boolean;\n\n /**\n * Transform -- into hyphen, if typed between two words\n */\n autoHyphen?: boolean;\n\n /**\n * Transform 1/2, 1/4, 3/4 into fraction character\n */\n autoFraction?: boolean;\n\n /**\n * Transform ordinal numbers into superscript\n */\n autoOrdinals?: boolean;\n};\n\n/**\n * @internal\n */\nconst DefaultOptions: Partial<AutoFormatOptions> = {\n autoBullet: false,\n autoNumbering: false,\n autoUnlink: false,\n autoLink: false,\n autoHyphen: false,\n autoFraction: false,\n autoOrdinals: false,\n};\n\n/**\n * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.\n * It can be customized with options to enable or disable auto list features.\n */\nexport class AutoFormatPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n /**\n * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:\n * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.\n * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.\n * - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.\n * - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.\n * - autoHyphen: A boolean that enables or disables automatic hyphen transformation. Defaults to false.\n * - autoFraction: A boolean that enables or disables automatic fraction transformation. Defaults to false.\n * - autoOrdinals: A boolean that enables or disables automatic ordinal number transformation. Defaults to false.\n */\n constructor(private options: AutoFormatOptions = DefaultOptions) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'AutoFormat';\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) {\n switch (event.eventType) {\n case 'input':\n this.handleEditorInputEvent(this.editor, event);\n break;\n case 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n case 'contentChanged':\n this.handleContentChangedEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {\n const rawEvent = event.rawEvent;\n const selection = editor.getDOMSelection();\n if (\n rawEvent.inputType === 'insertText' &&\n selection &&\n selection.type === 'range' &&\n selection.range.collapsed\n ) {\n switch (rawEvent.data) {\n case ' ':\n const formatOptions: FormatContentModelOptions = {\n changeSource: '',\n apiName: '',\n };\n formatTextSegmentBeforeSelectionMarker(\n editor,\n (model, previousSegment, paragraph, _markerFormat, context) => {\n const {\n autoBullet,\n autoNumbering,\n autoLink,\n autoHyphen,\n autoFraction,\n autoOrdinals,\n } = this.options;\n let shouldHyphen = false;\n let shouldLink = false;\n let shouldList = false;\n let shouldFraction = false;\n let shouldOrdinals = false;\n\n if (autoBullet || autoNumbering) {\n shouldList = keyboardListTrigger(\n model,\n paragraph,\n context,\n autoBullet,\n autoNumbering\n );\n }\n\n if (autoLink) {\n shouldLink = createLinkAfterSpace(\n previousSegment,\n paragraph,\n context\n );\n }\n\n if (autoHyphen) {\n shouldHyphen = transformHyphen(previousSegment, paragraph, context);\n }\n\n if (autoFraction) {\n shouldFraction = transformFraction(\n previousSegment,\n paragraph,\n context\n );\n }\n\n if (autoOrdinals) {\n shouldOrdinals = transformOrdinals(\n previousSegment,\n paragraph,\n context\n );\n }\n\n formatOptions.apiName = getApiName(shouldList, shouldHyphen);\n formatOptions.changeSource = getChangeSource(\n shouldList,\n shouldHyphen,\n shouldLink\n );\n\n return (\n shouldList ||\n shouldHyphen ||\n shouldLink ||\n shouldFraction ||\n shouldOrdinals\n );\n },\n formatOptions\n );\n\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\n if (this.options.autoUnlink) {\n unlink(editor, rawEvent);\n }\n break;\n }\n }\n }\n\n private handleContentChangedEvent(editor: IEditor, event: ContentChangedEvent) {\n const { autoLink } = this.options;\n if (event.source == 'Paste' && autoLink) {\n createLink(editor);\n }\n }\n}\n\nconst getApiName = (shouldList: boolean, shouldHyphen: boolean) => {\n return shouldList ? 'autoToggleList' : shouldHyphen ? 'autoHyphen' : '';\n};\n\nconst getChangeSource = (shouldList: boolean, shouldHyphen: boolean, shouldLink: boolean) => {\n return shouldList || shouldHyphen\n ? ChangeSource.AutoFormat\n : shouldLink\n ? ChangeSource.AutoLink\n : '';\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentModelParagraph, ContentModelText, FormatContentModelContext } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function transformHyphen(previousSegment: ContentModelText, paragraph: ContentModelParagraph, context: FormatContentModelContext): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
define(["require", "exports", "../../pluginUtils/splitTextSegment"], function (require, exports, splitTextSegment_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.transformHyphen = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
function transformHyphen(previousSegment, paragraph, context) {
|
|
9
|
+
var segments = previousSegment.text.split(' ');
|
|
10
|
+
var dashes = segments[segments.length - 2];
|
|
11
|
+
if (dashes === '--') {
|
|
12
|
+
var textIndex = previousSegment.text.lastIndexOf('--');
|
|
13
|
+
var textSegment = (0, splitTextSegment_1.splitTextSegment)(previousSegment, paragraph, textIndex, textIndex + 2);
|
|
14
|
+
textSegment.text = textSegment.text.replace('--', '—');
|
|
15
|
+
context.canUndoByBackspace = true;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
var text = segments.pop();
|
|
20
|
+
var hasDashes = text && (text === null || text === void 0 ? void 0 : text.indexOf('--')) > -1;
|
|
21
|
+
if (hasDashes && text.trim() !== '--') {
|
|
22
|
+
var textIndex = previousSegment.text.indexOf(text);
|
|
23
|
+
var textSegment = (0, splitTextSegment_1.splitTextSegment)(previousSegment, paragraph, textIndex, textIndex + text.length - 1);
|
|
24
|
+
var textLength = textSegment.text.length;
|
|
25
|
+
if (textSegment.text[0] !== '-' && textSegment.text[textLength - 1] !== '-') {
|
|
26
|
+
textSegment.text = textSegment.text.replace('--', '—');
|
|
27
|
+
context.canUndoByBackspace = true;
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
exports.transformHyphen = transformHyphen;
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=transformHyphen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformHyphen.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts"],"names":[],"mappings":";;;;IAOA;;OAEG;IACH,SAAgB,eAAe,CAC3B,eAAiC,EACjC,SAAgC,EAChC,OAAkC;QAElC,IAAM,QAAQ,GAAG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AAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBACvD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;oBAClC,OAAO,IAAI,CAAC;iBACf;aACJ;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAnCD,0CAmCC","sourcesContent":["import { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type {\n ContentModelParagraph,\n ContentModelText,\n FormatContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function transformHyphen(\n previousSegment: ContentModelText,\n paragraph: ContentModelParagraph,\n context: FormatContentModelContext\n): boolean {\n const segments = previousSegment.text.split(' ');\n const dashes = segments[segments.length - 2];\n if (dashes === '--') {\n const textIndex = previousSegment.text.lastIndexOf('--');\n const textSegment = splitTextSegment(previousSegment, paragraph, textIndex, textIndex + 2);\n\n textSegment.text = textSegment.text.replace('--', '—');\n context.canUndoByBackspace = true;\n return true;\n } else {\n const text = segments.pop();\n const hasDashes = text && text?.indexOf('--') > -1;\n if (hasDashes && text.trim() !== '--') {\n const textIndex = previousSegment.text.indexOf(text);\n const textSegment = splitTextSegment(\n previousSegment,\n paragraph,\n textIndex,\n textIndex + text.length - 1\n );\n\n const textLength = textSegment.text.length;\n if (textSegment.text[0] !== '-' && textSegment.text[textLength - 1] !== '-') {\n textSegment.text = textSegment.text.replace('--', '—');\n context.canUndoByBackspace = true;\n return true;\n }\n }\n }\n return false;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "roosterjs-content-model-dom", "
|
|
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
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createLink = void 0;
|
|
@@ -6,12 +6,12 @@ define(["require", "exports", "roosterjs-content-model-dom", "./getLinkSegment"]
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
function createLink(editor) {
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
if (link &&
|
|
12
|
-
(0, roosterjs_content_model_dom_1.addLink)(
|
|
9
|
+
(0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (_model, linkSegment, _paragraph) {
|
|
10
|
+
var linkData = null;
|
|
11
|
+
if (!linkSegment.link && (linkData = (0, roosterjs_content_model_api_1.matchLink)(linkSegment.text))) {
|
|
12
|
+
(0, roosterjs_content_model_dom_1.addLink)(linkSegment, {
|
|
13
13
|
format: {
|
|
14
|
-
href:
|
|
14
|
+
href: linkData.normalizedUrl,
|
|
15
15
|
underline: true,
|
|
16
16
|
},
|
|
17
17
|
dataset: {},
|
|
@@ -19,6 +19,8 @@ define(["require", "exports", "roosterjs-content-model-dom", "./getLinkSegment"]
|
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
return false;
|
|
22
|
+
}, {
|
|
23
|
+
changeSource: roosterjs_content_model_dom_1.ChangeSource.AutoLink,
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
exports.createLink = createLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLink.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,MAAM,
|
|
1
|
+
{"version":3,"file":"createLink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLink.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,IAAA,oEAAsC,EAClC,MAAM,EACN,UAAC,MAAM,EAAE,WAAW,EAAE,UAAU;YAC5B,IAAI,QAAQ,GAAoB,IAAI,CAAC;YACrC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,GAAG,IAAA,uCAAS,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE;gBAC/D,IAAA,qCAAO,EAAC,WAAW,EAAE;oBACjB,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ,CAAC,aAAa;wBAC5B,SAAS,EAAE,IAAI;qBAClB;oBACD,OAAO,EAAE,EAAE;iBACd,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;aACf;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,EACD;YACI,YAAY,EAAE,0CAAY,CAAC,QAAQ;SACtC,CACJ,CAAC;IACN,CAAC;IArBD,gCAqBC","sourcesContent":["import { addLink, ChangeSource } from 'roosterjs-content-model-dom';\nimport { formatTextSegmentBeforeSelectionMarker, matchLink } from 'roosterjs-content-model-api';\nimport type { IEditor, LinkData } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function createLink(editor: IEditor) {\n formatTextSegmentBeforeSelectionMarker(\n editor,\n (_model, linkSegment, _paragraph) => {\n let linkData: LinkData | null = null;\n if (!linkSegment.link && (linkData = matchLink(linkSegment.text))) {\n addLink(linkSegment, {\n format: {\n href: linkData.normalizedUrl,\n underline: true,\n },\n dataset: {},\n });\n return true;\n }\n return false;\n },\n {\n changeSource: ChangeSource.AutoLink,\n }\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelParagraph, ContentModelText, FormatContentModelContext } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function createLinkAfterSpace(
|
|
5
|
+
export declare function createLinkAfterSpace(previousSegment: ContentModelText, paragraph: ContentModelParagraph, context: FormatContentModelContext): boolean;
|
|
@@ -1,43 +1,27 @@
|
|
|
1
|
-
define(["require", "exports", "roosterjs-content-model-
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-api", "../../pluginUtils/splitTextSegment"], function (require, exports, roosterjs_content_model_api_1, splitTextSegment_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createLinkAfterSpace = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
function createLinkAfterSpace(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var linkSegment = (0, splitTextSegment_1.splitTextSegment)(textSegment, paragraph, textSegment.text.length - link.trimLeft().length, textSegment.text.trimRight().length);
|
|
26
|
-
linkSegment.link = {
|
|
27
|
-
format: {
|
|
28
|
-
href: linkData.normalizedUrl,
|
|
29
|
-
underline: true,
|
|
30
|
-
},
|
|
31
|
-
dataset: {},
|
|
32
|
-
};
|
|
33
|
-
context.canUndoByBackspace = true;
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
});
|
|
8
|
+
function createLinkAfterSpace(previousSegment, paragraph, context) {
|
|
9
|
+
var link = previousSegment.text.split(' ').pop();
|
|
10
|
+
var url = link === null || link === void 0 ? void 0 : link.trim();
|
|
11
|
+
var linkData = null;
|
|
12
|
+
if (url && link && (linkData = (0, roosterjs_content_model_api_1.matchLink)(url))) {
|
|
13
|
+
var linkSegment = (0, splitTextSegment_1.splitTextSegment)(previousSegment, paragraph, previousSegment.text.length - link.trimLeft().length, previousSegment.text.trimRight().length);
|
|
14
|
+
linkSegment.link = {
|
|
15
|
+
format: {
|
|
16
|
+
href: linkData.normalizedUrl,
|
|
17
|
+
underline: true,
|
|
18
|
+
},
|
|
19
|
+
dataset: {},
|
|
20
|
+
};
|
|
21
|
+
context.canUndoByBackspace = true;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
41
25
|
}
|
|
42
26
|
exports.createLinkAfterSpace = createLinkAfterSpace;
|
|
43
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLinkAfterSpace.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"createLinkAfterSpace.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts"],"names":[],"mappings":";;;;IASA;;OAEG;IACH,SAAgB,oBAAoB,CAChC,eAAiC,EACjC,SAAgC,EAChC,OAAkC;QAElC,IAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACnD,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;QACzB,IAAI,QAAQ,GAAoB,IAAI,CAAC;QACrC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,QAAQ,GAAG,IAAA,uCAAS,EAAC,GAAG,CAAC,CAAC,EAAE;YAC5C,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,eAAe,EACf,SAAS,EACT,eAAe,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EACpD,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAC1C,CAAC;YACF,WAAW,CAAC,IAAI,GAAG;gBACf,MAAM,EAAE;oBACJ,IAAI,EAAE,QAAQ,CAAC,aAAa;oBAC5B,SAAS,EAAE,IAAI;iBAClB;gBACD,OAAO,EAAE,EAAE;aACd,CAAC;YAEF,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;YAElC,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IA5BD,oDA4BC","sourcesContent":["import { matchLink } from 'roosterjs-content-model-api';\nimport { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type {\n ContentModelParagraph,\n ContentModelText,\n FormatContentModelContext,\n LinkData,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function createLinkAfterSpace(\n previousSegment: ContentModelText,\n paragraph: ContentModelParagraph,\n context: FormatContentModelContext\n) {\n const link = previousSegment.text.split(' ').pop();\n const url = link?.trim();\n let linkData: LinkData | null = null;\n if (url && link && (linkData = matchLink(url))) {\n const linkSegment = splitTextSegment(\n previousSegment,\n paragraph,\n previousSegment.text.length - link.trimLeft().length,\n previousSegment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkData.normalizedUrl,\n underline: true,\n },\n dataset: {},\n };\n\n context.canUndoByBackspace = true;\n\n return true;\n }\n return false;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-api"], function (require, exports, roosterjs_content_model_api_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.unlink = void 0;
|
|
@@ -6,10 +6,9 @@ define(["require", "exports", "./getLinkSegment"], function (require, exports, g
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
function unlink(editor, rawEvent) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
link.link = undefined;
|
|
9
|
+
(0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (_model, linkSegment, _paragraph) {
|
|
10
|
+
if (linkSegment === null || linkSegment === void 0 ? void 0 : linkSegment.link) {
|
|
11
|
+
linkSegment.link = undefined;
|
|
13
12
|
rawEvent.preventDefault();
|
|
14
13
|
return true;
|
|
15
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/unlink.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"unlink.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/unlink.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,MAAM,CAAC,MAAe,EAAE,QAAuB;QAC3D,IAAA,oEAAsC,EAAC,MAAM,EAAE,UAAC,MAAM,EAAE,WAAW,EAAE,UAAU;YAC3E,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,EAAE;gBACnB,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC;gBAC7B,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAE1B,OAAO,IAAI,CAAC;aACf;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAVD,wBAUC","sourcesContent":["import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\n\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function unlink(editor: IEditor, rawEvent: KeyboardEvent) {\n formatTextSegmentBeforeSelectionMarker(editor, (_model, linkSegment, _paragraph) => {\n if (linkSegment?.link) {\n linkSegment.link = undefined;\n rawEvent.preventDefault();\n\n return true;\n }\n return false;\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelDocument, ContentModelParagraph, FormatContentModelContext } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function keyboardListTrigger(
|
|
5
|
+
export declare function keyboardListTrigger(model: ContentModelDocument, paragraph: ContentModelParagraph, context: FormatContentModelContext, shouldSearchForBullet?: boolean, shouldSearchForNumbering?: boolean): boolean;
|
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
define(["require", "exports", "./getListTypeStyle", "roosterjs-content-model-
|
|
1
|
+
define(["require", "exports", "./getListTypeStyle", "roosterjs-content-model-api"], function (require, exports, getListTypeStyle_1, roosterjs_content_model_api_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.keyboardListTrigger = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
function keyboardListTrigger(
|
|
8
|
+
function keyboardListTrigger(model, paragraph, context, shouldSearchForBullet, shouldSearchForNumbering) {
|
|
9
9
|
if (shouldSearchForBullet === void 0) { shouldSearchForBullet = true; }
|
|
10
10
|
if (shouldSearchForNumbering === void 0) { shouldSearchForNumbering = true; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
var listType = listStyleType.listType, styleType = listStyleType.styleType, index = listStyleType.index;
|
|
20
|
-
triggerList(model, listType, styleType, index);
|
|
21
|
-
context.canUndoByBackspace = true;
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
}, {
|
|
26
|
-
apiName: 'autoToggleList',
|
|
27
|
-
});
|
|
11
|
+
var listStyleType = (0, getListTypeStyle_1.getListTypeStyle)(model, shouldSearchForBullet, shouldSearchForNumbering);
|
|
12
|
+
if (listStyleType) {
|
|
13
|
+
paragraph.segments.splice(0, 1);
|
|
14
|
+
var listType = listStyleType.listType, styleType = listStyleType.styleType, index = listStyleType.index;
|
|
15
|
+
triggerList(model, listType, styleType, index);
|
|
16
|
+
context.canUndoByBackspace = true;
|
|
17
|
+
return true;
|
|
28
18
|
}
|
|
19
|
+
return false;
|
|
29
20
|
}
|
|
30
21
|
exports.keyboardListTrigger = keyboardListTrigger;
|
|
31
22
|
var triggerList = function (model, listType, styleType, index) {
|