@witchcraft/editor 0.0.1
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/@types/@tiptap/core/index.d.ts +3 -0
- package/README.md +111 -0
- package/dist/module.d.mts +15 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +68 -0
- package/dist/runtime/assets/base.css +1 -0
- package/dist/runtime/assets/handle-arrow.svg +16 -0
- package/dist/runtime/assets/handle-border-circles-single.svg +44 -0
- package/dist/runtime/assets/handle-border-circles.svg +27 -0
- package/dist/runtime/assets/handle-temp.svg +1 -0
- package/dist/runtime/assets/utils.css +1 -0
- package/dist/runtime/components/CodeBlockThemePicker.d.vue.ts +12 -0
- package/dist/runtime/components/CodeBlockThemePicker.vue +123 -0
- package/dist/runtime/components/CodeBlockThemePicker.vue.d.ts +12 -0
- package/dist/runtime/components/Commands.d.vue.ts +10 -0
- package/dist/runtime/components/Commands.vue +60 -0
- package/dist/runtime/components/Commands.vue.d.ts +10 -0
- package/dist/runtime/components/Editor.d.vue.ts +40 -0
- package/dist/runtime/components/Editor.vue +208 -0
- package/dist/runtime/components/Editor.vue.d.ts +40 -0
- package/dist/runtime/components/EditorDemoApp.d.vue.ts +2 -0
- package/dist/runtime/components/EditorDemoApp.vue +104 -0
- package/dist/runtime/components/EditorDemoApp.vue.d.ts +2 -0
- package/dist/runtime/components/EditorDemoControls.d.vue.ts +12 -0
- package/dist/runtime/components/EditorDemoControls.vue +36 -0
- package/dist/runtime/components/EditorDemoControls.vue.d.ts +12 -0
- package/dist/runtime/components/TestWrapper.d.vue.ts +11 -0
- package/dist/runtime/components/TestWrapper.vue +63 -0
- package/dist/runtime/components/TestWrapper.vue.d.ts +11 -0
- package/dist/runtime/composables/useEditor.d.ts +9 -0
- package/dist/runtime/composables/useEditor.js +17 -0
- package/dist/runtime/composables/useWindowDebugging.d.ts +3 -0
- package/dist/runtime/composables/useWindowDebugging.js +16 -0
- package/dist/runtime/demo/App.d.vue.ts +2 -0
- package/dist/runtime/demo/App.vue +101 -0
- package/dist/runtime/demo/App.vue.d.ts +2 -0
- package/dist/runtime/demo/README.md +1 -0
- package/dist/runtime/demo/main.d.ts +1 -0
- package/dist/runtime/demo/main.js +4 -0
- package/dist/runtime/demo/tailwind.css +1 -0
- package/dist/runtime/env.d.ts +2 -0
- package/dist/runtime/injectionKeys.d.ts +6 -0
- package/dist/runtime/injectionKeys.js +3 -0
- package/dist/runtime/main.lib.d.ts +2 -0
- package/dist/runtime/main.lib.js +2 -0
- package/dist/runtime/pm/commands/backspace.d.ts +12 -0
- package/dist/runtime/pm/commands/backspace.js +26 -0
- package/dist/runtime/pm/commands/changeAttrs.d.ts +9 -0
- package/dist/runtime/pm/commands/changeAttrs.js +15 -0
- package/dist/runtime/pm/commands/deleteSelection.d.ts +9 -0
- package/dist/runtime/pm/commands/deleteSelection.js +8 -0
- package/dist/runtime/pm/commands/enter.d.ts +14 -0
- package/dist/runtime/pm/commands/enter.js +9 -0
- package/dist/runtime/pm/commands/insertBreak.d.ts +9 -0
- package/dist/runtime/pm/commands/insertBreak.js +22 -0
- package/dist/runtime/pm/features/Base/Base.d.ts +4 -0
- package/dist/runtime/pm/features/Base/Base.js +32 -0
- package/dist/runtime/pm/features/Base/commands/deleteNodes.d.ts +10 -0
- package/dist/runtime/pm/features/Base/commands/deleteNodes.js +29 -0
- package/dist/runtime/pm/features/Base/commands/setCursorVisible.d.ts +12 -0
- package/dist/runtime/pm/features/Base/commands/setCursorVisible.js +7 -0
- package/dist/runtime/pm/features/Base/plugins/debugSelectionPlugin.d.ts +9 -0
- package/dist/runtime/pm/features/Base/plugins/debugSelectionPlugin.js +48 -0
- package/dist/runtime/pm/features/Base/plugins/isCursorVisiblePlugin.d.ts +3 -0
- package/dist/runtime/pm/features/Base/plugins/isCursorVisiblePlugin.js +26 -0
- package/dist/runtime/pm/features/Base/plugins/isUsingTouchPlugin.d.ts +3 -0
- package/dist/runtime/pm/features/Base/plugins/isUsingTouchPlugin.js +38 -0
- package/dist/runtime/pm/features/Base/plugins/selectingIndicator.d.ts +5 -0
- package/dist/runtime/pm/features/Base/plugins/selectingIndicator.js +35 -0
- package/dist/runtime/pm/features/Base/plugins/unfocusedSelectionIndicatorPlugin.d.ts +33 -0
- package/dist/runtime/pm/features/Base/plugins/unfocusedSelectionIndicatorPlugin.js +66 -0
- package/dist/runtime/pm/features/Base/types.d.ts +3 -0
- package/dist/runtime/pm/features/Base/types.js +0 -0
- package/dist/runtime/pm/features/BaseShortcuts/BaseShortcuts.d.ts +3 -0
- package/dist/runtime/pm/features/BaseShortcuts/BaseShortcuts.js +34 -0
- package/dist/runtime/pm/features/Blockquote/Blockquote.d.ts +5 -0
- package/dist/runtime/pm/features/Blockquote/Blockquote.js +65 -0
- package/dist/runtime/pm/features/Blockquote/commands/blockquoteEnter.d.ts +11 -0
- package/dist/runtime/pm/features/Blockquote/commands/blockquoteEnter.js +31 -0
- package/dist/runtime/pm/features/Blockquote/commands/blockquoteShiftEnter.d.ts +11 -0
- package/dist/runtime/pm/features/Blockquote/commands/blockquoteShiftEnter.js +12 -0
- package/dist/runtime/pm/features/Blocks/Blocks.d.ts +2 -0
- package/dist/runtime/pm/features/Blocks/Blocks.js +2 -0
- package/dist/runtime/pm/features/Blocks/Item.d.ts +11 -0
- package/dist/runtime/pm/features/Blocks/Item.js +157 -0
- package/dist/runtime/pm/features/Blocks/List.d.ts +4 -0
- package/dist/runtime/pm/features/Blocks/List.js +59 -0
- package/dist/runtime/pm/features/Blocks/commands/changeItemType.d.ts +20 -0
- package/dist/runtime/pm/features/Blocks/commands/changeItemType.js +40 -0
- package/dist/runtime/pm/features/Blocks/commands/changeTypeAttr.d.ts +14 -0
- package/dist/runtime/pm/features/Blocks/commands/changeTypeAttr.js +28 -0
- package/dist/runtime/pm/features/Blocks/commands/copyOrMoveItem.d.ts +23 -0
- package/dist/runtime/pm/features/Blocks/commands/copyOrMoveItem.js +124 -0
- package/dist/runtime/pm/features/Blocks/commands/deleteItem.d.ts +12 -0
- package/dist/runtime/pm/features/Blocks/commands/deleteItem.js +8 -0
- package/dist/runtime/pm/features/Blocks/commands/indentItem.d.ts +12 -0
- package/dist/runtime/pm/features/Blocks/commands/indentItem.js +58 -0
- package/dist/runtime/pm/features/Blocks/commands/itemMenuCommands.d.ts +18 -0
- package/dist/runtime/pm/features/Blocks/commands/itemMenuCommands.js +40 -0
- package/dist/runtime/pm/features/Blocks/commands/moveItem.d.ts +12 -0
- package/dist/runtime/pm/features/Blocks/commands/moveItem.js +80 -0
- package/dist/runtime/pm/features/Blocks/commands/setNode.d.ts +20 -0
- package/dist/runtime/pm/features/Blocks/commands/setNode.js +87 -0
- package/dist/runtime/pm/features/Blocks/commands/splitItem.d.ts +17 -0
- package/dist/runtime/pm/features/Blocks/commands/splitItem.js +87 -0
- package/dist/runtime/pm/features/Blocks/commands/unindentItem.d.ts +12 -0
- package/dist/runtime/pm/features/Blocks/commands/unindentItem.js +42 -0
- package/dist/runtime/pm/features/Blocks/components/DragTreeHandle.d.vue.ts +0 -0
- package/dist/runtime/pm/features/Blocks/components/DragTreeHandle.vue +122 -0
- package/dist/runtime/pm/features/Blocks/components/DragTreeHandle.vue.d.ts +0 -0
- package/dist/runtime/pm/features/Blocks/components/ItemMenu.d.vue.ts +6 -0
- package/dist/runtime/pm/features/Blocks/components/ItemMenu.vue +78 -0
- package/dist/runtime/pm/features/Blocks/components/ItemMenu.vue.d.ts +6 -0
- package/dist/runtime/pm/features/Blocks/components/ItemNodeView.d.vue.ts +92 -0
- package/dist/runtime/pm/features/Blocks/components/ItemNodeView.vue +350 -0
- package/dist/runtime/pm/features/Blocks/components/ItemNodeView.vue.d.ts +92 -0
- package/dist/runtime/pm/features/Blocks/components/defaultItemMenu.d.ts +5 -0
- package/dist/runtime/pm/features/Blocks/components/defaultItemMenu.js +42 -0
- package/dist/runtime/pm/features/Blocks/composables/useDragWithThreshold.d.ts +1 -0
- package/dist/runtime/pm/features/Blocks/composables/useDragWithThreshold.js +0 -0
- package/dist/runtime/pm/features/Blocks/composables/useHandleHeight.d.ts +5 -0
- package/dist/runtime/pm/features/Blocks/composables/useHandleHeight.js +22 -0
- package/dist/runtime/pm/features/Blocks/composables/useHasChildren.d.ts +5 -0
- package/dist/runtime/pm/features/Blocks/composables/useHasChildren.js +10 -0
- package/dist/runtime/pm/features/Blocks/composables/useNodeStates.d.ts +7 -0
- package/dist/runtime/pm/features/Blocks/composables/useNodeStates.js +20 -0
- package/dist/runtime/pm/features/Blocks/itemMenuMenuItems.d.ts +20 -0
- package/dist/runtime/pm/features/Blocks/itemMenuMenuItems.js +138 -0
- package/dist/runtime/pm/features/Blocks/plugins/ensureLastItemIsContentPlugin.d.ts +11 -0
- package/dist/runtime/pm/features/Blocks/plugins/ensureLastItemIsContentPlugin.js +36 -0
- package/dist/runtime/pm/features/Blocks/plugins/itemBlockIdPlugin.d.ts +8 -0
- package/dist/runtime/pm/features/Blocks/plugins/itemBlockIdPlugin.js +30 -0
- package/dist/runtime/pm/features/Blocks/plugins/itemHasSingularSelectionPlugin.d.ts +3 -0
- package/dist/runtime/pm/features/Blocks/plugins/itemHasSingularSelectionPlugin.js +30 -0
- package/dist/runtime/pm/features/Blocks/plugins/itemMenuPlugin.d.ts +4 -0
- package/dist/runtime/pm/features/Blocks/plugins/itemMenuPlugin.js +17 -0
- package/dist/runtime/pm/features/Blocks/states/stateful.d.ts +2 -0
- package/dist/runtime/pm/features/Blocks/states/stateful.js +37 -0
- package/dist/runtime/pm/features/Blocks/states/task/cancelled.svg +32 -0
- package/dist/runtime/pm/features/Blocks/states/task/checked.svg +27 -0
- package/dist/runtime/pm/features/Blocks/states/task/checked2.svg +24 -0
- package/dist/runtime/pm/features/Blocks/states/task/partial.svg +24 -0
- package/dist/runtime/pm/features/Blocks/states/task/partial2.svg +31 -0
- package/dist/runtime/pm/features/Blocks/states/task/unchecked.svg +20 -0
- package/dist/runtime/pm/features/Blocks/types.d.ts +43 -0
- package/dist/runtime/pm/features/Blocks/types.js +2 -0
- package/dist/runtime/pm/features/Blocks/utils/createItemMenuCommandExecuter.d.ts +3 -0
- package/dist/runtime/pm/features/Blocks/utils/createItemMenuCommandExecuter.js +24 -0
- package/dist/runtime/pm/features/Blocks/utils/fixBlockIds.d.ts +4 -0
- package/dist/runtime/pm/features/Blocks/utils/fixBlockIds.js +23 -0
- package/dist/runtime/pm/features/Blocks/utils/isValidId.d.ts +2 -0
- package/dist/runtime/pm/features/Blocks/utils/isValidId.js +7 -0
- package/dist/runtime/pm/features/CodeBlock/CodeBlock.d.ts +16 -0
- package/dist/runtime/pm/features/CodeBlock/CodeBlock.js +91 -0
- package/dist/runtime/pm/features/CodeBlock/build/generateHighlightJsInfo.d.ts +1 -0
- package/dist/runtime/pm/features/CodeBlock/build/generateHighlightJsInfo.js +63 -0
- package/dist/runtime/pm/features/CodeBlock/commands/codeBlockEnterOrSplit.d.ts +9 -0
- package/dist/runtime/pm/features/CodeBlock/commands/codeBlockEnterOrSplit.js +28 -0
- package/dist/runtime/pm/features/CodeBlock/commands/codeBlockIndent.d.ts +9 -0
- package/dist/runtime/pm/features/CodeBlock/commands/codeBlockIndent.js +39 -0
- package/dist/runtime/pm/features/CodeBlock/commands/codeBlockUnindent.d.ts +9 -0
- package/dist/runtime/pm/features/CodeBlock/commands/codeBlockUnindent.js +50 -0
- package/dist/runtime/pm/features/CodeBlock/commands/focusCodeBlockLanguage.d.ts +9 -0
- package/dist/runtime/pm/features/CodeBlock/commands/focusCodeBlockLanguage.js +27 -0
- package/dist/runtime/pm/features/CodeBlock/components/CodeBlockView.d.vue.ts +92 -0
- package/dist/runtime/pm/features/CodeBlock/components/CodeBlockView.vue +112 -0
- package/dist/runtime/pm/features/CodeBlock/components/CodeBlockView.vue.d.ts +92 -0
- package/dist/runtime/pm/features/CodeBlock/composables/useAsyncCodeBlockHighlighting.d.ts +28 -0
- package/dist/runtime/pm/features/CodeBlock/composables/useAsyncCodeBlockHighlighting.js +137 -0
- package/dist/runtime/pm/features/CodeBlock/composables/useHighlightJsTheme.d.ts +37 -0
- package/dist/runtime/pm/features/CodeBlock/composables/useHighlightJsTheme.js +101 -0
- package/dist/runtime/pm/features/CodeBlock/highlightJsInfo.d.ts +17 -0
- package/dist/runtime/pm/features/CodeBlock/highlightJsInfo.js +711 -0
- package/dist/runtime/pm/features/CodeBlock/types.d.ts +4 -0
- package/dist/runtime/pm/features/CodeBlock/types.js +2 -0
- package/dist/runtime/pm/features/Collaboration/Collaboration.d.ts +66 -0
- package/dist/runtime/pm/features/Collaboration/Collaboration.js +169 -0
- package/dist/runtime/pm/features/CommandsMenus/CommandBar.d.ts +19 -0
- package/dist/runtime/pm/features/CommandsMenus/CommandBar.js +97 -0
- package/dist/runtime/pm/features/CommandsMenus/commandBarMenuItems.d.ts +20 -0
- package/dist/runtime/pm/features/CommandsMenus/commandBarMenuItems.js +188 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandBar.d.vue.ts +8 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandBar.vue +58 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandBar.vue.d.ts +8 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandBarItem.d.vue.ts +12 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandBarItem.vue +42 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandBarItem.vue.d.ts +12 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuGroup.d.vue.ts +10 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuGroup.vue +55 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuGroup.vue.d.ts +10 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuItem.d.vue.ts +11 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuItem.vue +58 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuItem.vue.d.ts +11 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuList.d.vue.ts +11 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuList.vue +54 -0
- package/dist/runtime/pm/features/CommandsMenus/components/CommandMenuList.vue.d.ts +11 -0
- package/dist/runtime/pm/features/CommandsMenus/components/TextIcon.d.vue.ts +5 -0
- package/dist/runtime/pm/features/CommandsMenus/components/TextIcon.vue +13 -0
- package/dist/runtime/pm/features/CommandsMenus/components/TextIcon.vue.d.ts +5 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/HighlightIcon.d.vue.ts +8 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/HighlightIcon.vue +45 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/HighlightIcon.vue.d.ts +8 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/SubscriptIcon.d.vue.ts +2 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/SubscriptIcon.vue +5 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/SubscriptIcon.vue.d.ts +2 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/SuperscriptIcon.d.vue.ts +2 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/SuperscriptIcon.vue +5 -0
- package/dist/runtime/pm/features/CommandsMenus/icons/SuperscriptIcon.vue.d.ts +2 -0
- package/dist/runtime/pm/features/CommandsMenus/types.d.ts +61 -0
- package/dist/runtime/pm/features/CommandsMenus/types.js +5 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/defaultCommandExecutor.d.ts +3 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/defaultCommandExecutor.js +11 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/findCommand.d.ts +10 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/findCommand.js +16 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/popupPositionModifier.d.ts +5 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/popupPositionModifier.js +9 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/popupVerticalPositioner.d.ts +5 -0
- package/dist/runtime/pm/features/CommandsMenus/utils/popupVerticalPositioner.js +11 -0
- package/dist/runtime/pm/features/Document/Document.d.ts +3 -0
- package/dist/runtime/pm/features/Document/Document.js +6 -0
- package/dist/runtime/pm/features/DocumentApi/DocumentApi.d.ts +85 -0
- package/dist/runtime/pm/features/DocumentApi/DocumentApi.js +161 -0
- package/dist/runtime/pm/features/DocumentApi/composables/useEditorContent.d.ts +13 -0
- package/dist/runtime/pm/features/DocumentApi/composables/useEditorContent.js +76 -0
- package/dist/runtime/pm/features/DocumentApi/composables/useTestDocumentApi.d.ts +23 -0
- package/dist/runtime/pm/features/DocumentApi/composables/useTestDocumentApi.js +70 -0
- package/dist/runtime/pm/features/DocumentApi/types.d.ts +133 -0
- package/dist/runtime/pm/features/DocumentApi/types.js +1 -0
- package/dist/runtime/pm/features/DocumentApi/utils/convertFullTransactionForPartialState.d.ts +3 -0
- package/dist/runtime/pm/features/DocumentApi/utils/convertFullTransactionForPartialState.js +37 -0
- package/dist/runtime/pm/features/DocumentApi/utils/convertTrForInstance.d.ts +4 -0
- package/dist/runtime/pm/features/DocumentApi/utils/convertTrForInstance.js +13 -0
- package/dist/runtime/pm/features/DocumentApi/utils/convertTransactionForFullState.d.ts +2 -0
- package/dist/runtime/pm/features/DocumentApi/utils/convertTransactionForFullState.js +22 -0
- package/dist/runtime/pm/features/DocumentApi/utils/copyMeta.d.ts +2 -0
- package/dist/runtime/pm/features/DocumentApi/utils/copyMeta.js +6 -0
- package/dist/runtime/pm/features/DocumentApi/utils/getEmbedJson.d.ts +1 -0
- package/dist/runtime/pm/features/DocumentApi/utils/getEmbedJson.js +14 -0
- package/dist/runtime/pm/features/DocumentApi/utils/getEmbedNodeFromDoc.d.ts +1 -0
- package/dist/runtime/pm/features/DocumentApi/utils/getEmbedNodeFromDoc.js +14 -0
- package/dist/runtime/pm/features/DocumentApi/utils/getStateEmbedRange.d.ts +9 -0
- package/dist/runtime/pm/features/DocumentApi/utils/getStateEmbedRange.js +19 -0
- package/dist/runtime/pm/features/DocumentApi/utils/isEmbedId.d.ts +2 -0
- package/dist/runtime/pm/features/DocumentApi/utils/isEmbedId.js +3 -0
- package/dist/runtime/pm/features/EmbeddedDocument/Embedded.d.ts +24 -0
- package/dist/runtime/pm/features/EmbeddedDocument/Embedded.js +73 -0
- package/dist/runtime/pm/features/EmbeddedDocument/EmbeddedDocument.d.ts +23 -0
- package/dist/runtime/pm/features/EmbeddedDocument/EmbeddedDocument.js +70 -0
- package/dist/runtime/pm/features/EmbeddedDocument/components/EmbeddedDocumentPicker.d.vue.ts +14 -0
- package/dist/runtime/pm/features/EmbeddedDocument/components/EmbeddedDocumentPicker.vue +171 -0
- package/dist/runtime/pm/features/EmbeddedDocument/components/EmbeddedDocumentPicker.vue.d.ts +14 -0
- package/dist/runtime/pm/features/EmbeddedDocument/components/EmbeddedNodeView.d.vue.ts +92 -0
- package/dist/runtime/pm/features/EmbeddedDocument/components/EmbeddedNodeView.vue +172 -0
- package/dist/runtime/pm/features/EmbeddedDocument/components/EmbeddedNodeView.vue.d.ts +92 -0
- package/dist/runtime/pm/features/EmbeddedDocument/composables/useEmbeddedEditor.d.ts +31 -0
- package/dist/runtime/pm/features/EmbeddedDocument/composables/useEmbeddedEditor.js +199 -0
- package/dist/runtime/pm/features/EmbeddedDocument/types.d.ts +49 -0
- package/dist/runtime/pm/features/EmbeddedDocument/types.js +6 -0
- package/dist/runtime/pm/features/EmbeddedDocument/utils/isEmbeddedBlock.d.ts +9 -0
- package/dist/runtime/pm/features/EmbeddedDocument/utils/isEmbeddedBlock.js +3 -0
- package/dist/runtime/pm/features/EmbeddedDocument/utils/redirectFromEmbedded.d.ts +28 -0
- package/dist/runtime/pm/features/EmbeddedDocument/utils/redirectFromEmbedded.js +17 -0
- package/dist/runtime/pm/features/FileLoader/FileLoader.d.ts +16 -0
- package/dist/runtime/pm/features/FileLoader/FileLoader.js +99 -0
- package/dist/runtime/pm/features/FileLoader/FileLoaderHandler/FileLoaderHandler.d.ts +28 -0
- package/dist/runtime/pm/features/FileLoader/FileLoaderHandler/FileLoaderHandler.js +69 -0
- package/dist/runtime/pm/features/FileLoader/FileLoaderHandler/TestFileLoaderHandler.d.ts +11 -0
- package/dist/runtime/pm/features/FileLoader/FileLoaderHandler/TestFileLoaderHandler.js +49 -0
- package/dist/runtime/pm/features/FileLoader/commands/insertFile.d.ts +17 -0
- package/dist/runtime/pm/features/FileLoader/commands/insertFile.js +39 -0
- package/dist/runtime/pm/features/FileLoader/components/FileLoaderNodeView.d.vue.ts +92 -0
- package/dist/runtime/pm/features/FileLoader/components/FileLoaderNodeView.vue +38 -0
- package/dist/runtime/pm/features/FileLoader/components/FileLoaderNodeView.vue.d.ts +92 -0
- package/dist/runtime/pm/features/FileLoader/plugins/fileLoaderPlugin.d.ts +5 -0
- package/dist/runtime/pm/features/FileLoader/plugins/fileLoaderPlugin.js +61 -0
- package/dist/runtime/pm/features/FileLoader/types.d.ts +73 -0
- package/dist/runtime/pm/features/FileLoader/types.js +0 -0
- package/dist/runtime/pm/features/FileLoader/utils/cleanupFileLoaderNode.d.ts +4 -0
- package/dist/runtime/pm/features/FileLoader/utils/cleanupFileLoaderNode.js +27 -0
- package/dist/runtime/pm/features/FileLoader/utils/cleanupFileLoaderNodes.d.ts +9 -0
- package/dist/runtime/pm/features/FileLoader/utils/cleanupFileLoaderNodes.js +22 -0
- package/dist/runtime/pm/features/FileLoader/utils/findLoadingNodePos.d.ts +2 -0
- package/dist/runtime/pm/features/FileLoader/utils/findLoadingNodePos.js +11 -0
- package/dist/runtime/pm/features/FileLoader/utils/optionsCheck.d.ts +3 -0
- package/dist/runtime/pm/features/FileLoader/utils/optionsCheck.js +8 -0
- package/dist/runtime/pm/features/FileLoader/utils/readAsDataUrl.d.ts +1 -0
- package/dist/runtime/pm/features/FileLoader/utils/readAsDataUrl.js +12 -0
- package/dist/runtime/pm/features/HardBreak/HardBreak.d.ts +5 -0
- package/dist/runtime/pm/features/HardBreak/HardBreak.js +14 -0
- package/dist/runtime/pm/features/Heading/Heading.d.ts +24 -0
- package/dist/runtime/pm/features/Heading/Heading.js +85 -0
- package/dist/runtime/pm/features/Heading/commands/changeLevelAttr.d.ts +16 -0
- package/dist/runtime/pm/features/Heading/commands/changeLevelAttr.js +33 -0
- package/dist/runtime/pm/features/Heading/types.d.ts +14 -0
- package/dist/runtime/pm/features/Heading/types.js +0 -0
- package/dist/runtime/pm/features/Highlight/Highlight.d.ts +72 -0
- package/dist/runtime/pm/features/Highlight/Highlight.js +163 -0
- package/dist/runtime/pm/features/Highlight/retyped/tiptapHighlight.d.ts +3 -0
- package/dist/runtime/pm/features/Highlight/retyped/tiptapHighlight.js +5 -0
- package/dist/runtime/pm/features/Highlight/types.d.ts +27 -0
- package/dist/runtime/pm/features/Highlight/types.js +2 -0
- package/dist/runtime/pm/features/History/History.d.ts +35 -0
- package/dist/runtime/pm/features/History/History.js +63 -0
- package/dist/runtime/pm/features/Iframe/Iframe.d.ts +21 -0
- package/dist/runtime/pm/features/Iframe/Iframe.js +127 -0
- package/dist/runtime/pm/features/Iframe/IframeParsers.d.ts +37 -0
- package/dist/runtime/pm/features/Iframe/IframeParsers.js +88 -0
- package/dist/runtime/pm/features/Iframe/components/IframeNodeView.d.vue.ts +92 -0
- package/dist/runtime/pm/features/Iframe/components/IframeNodeView.vue +82 -0
- package/dist/runtime/pm/features/Iframe/components/IframeNodeView.vue.d.ts +92 -0
- package/dist/runtime/pm/features/Iframe/types.d.ts +5 -0
- package/dist/runtime/pm/features/Iframe/types.js +0 -0
- package/dist/runtime/pm/features/Image/Image.d.ts +2 -0
- package/dist/runtime/pm/features/Image/Image.js +13 -0
- package/dist/runtime/pm/features/Link/Link.d.ts +38 -0
- package/dist/runtime/pm/features/Link/Link.js +241 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuExternalLink.d.vue.ts +28 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuExternalLink.vue +114 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuExternalLink.vue.d.ts +28 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuInternalLink.d.vue.ts +29 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuInternalLink.vue +107 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuInternalLink.vue.d.ts +29 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuLink.d.vue.ts +11 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuLink.vue +126 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuLink.vue.d.ts +11 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuLinkActions.d.vue.ts +18 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuLinkActions.vue +57 -0
- package/dist/runtime/pm/features/Link/components/BubbleMenuLinkActions.vue.d.ts +18 -0
- package/dist/runtime/pm/features/Link/types.d.ts +44 -0
- package/dist/runtime/pm/features/Link/types.js +3 -0
- package/dist/runtime/pm/features/Menus/Menus.d.ts +45 -0
- package/dist/runtime/pm/features/Menus/Menus.js +142 -0
- package/dist/runtime/pm/features/Menus/components/MarkMenuManager.d.vue.ts +6 -0
- package/dist/runtime/pm/features/Menus/components/MarkMenuManager.vue +166 -0
- package/dist/runtime/pm/features/Menus/components/MarkMenuManager.vue.d.ts +6 -0
- package/dist/runtime/pm/features/Menus/types.d.ts +51 -0
- package/dist/runtime/pm/features/Menus/types.js +3 -0
- package/dist/runtime/pm/features/Menus/utils/isMarkMenu.d.ts +2 -0
- package/dist/runtime/pm/features/Menus/utils/isMarkMenu.js +3 -0
- package/dist/runtime/pm/features/Tables/commands/tableEnter.d.ts +15 -0
- package/dist/runtime/pm/features/Tables/commands/tableEnter.js +19 -0
- package/dist/runtime/pm/features/Tables/index.d.ts +9 -0
- package/dist/runtime/pm/features/Tables/index.js +44 -0
- package/dist/runtime/pm/schema.d.ts +4 -0
- package/dist/runtime/pm/schema.js +80 -0
- package/dist/runtime/pm/testSchema.d.ts +5 -0
- package/dist/runtime/pm/testSchema.js +30 -0
- package/dist/runtime/pm/utils/createDropIndicator.d.ts +23 -0
- package/dist/runtime/pm/utils/createDropIndicator.js +32 -0
- package/dist/runtime/pm/utils/createStateOnlyPluginApply.d.ts +2 -0
- package/dist/runtime/pm/utils/createStateOnlyPluginApply.js +9 -0
- package/dist/runtime/pm/utils/createStateOnlyPluginObjApply.d.ts +2 -0
- package/dist/runtime/pm/utils/createStateOnlyPluginObjApply.js +14 -0
- package/dist/runtime/pm/utils/dropPointInfo.d.ts +56 -0
- package/dist/runtime/pm/utils/dropPointInfo.js +28 -0
- package/dist/runtime/pm/utils/findUpwards.d.ts +20 -0
- package/dist/runtime/pm/utils/findUpwards.js +18 -0
- package/dist/runtime/pm/utils/getChildChunks.d.ts +3 -0
- package/dist/runtime/pm/utils/getChildChunks.js +15 -0
- package/dist/runtime/pm/utils/getDiffReplacementRange.d.ts +20 -0
- package/dist/runtime/pm/utils/getDiffReplacementRange.js +9 -0
- package/dist/runtime/pm/utils/getElMaxVisualSize.d.ts +9 -0
- package/dist/runtime/pm/utils/getElMaxVisualSize.js +7 -0
- package/dist/runtime/pm/utils/getElPropertyAsInt.d.ts +1 -0
- package/dist/runtime/pm/utils/getElPropertyAsInt.js +8 -0
- package/dist/runtime/pm/utils/getGroupNodeNames.d.ts +2 -0
- package/dist/runtime/pm/utils/getGroupNodeNames.js +7 -0
- package/dist/runtime/pm/utils/getMarkPosition.d.ts +11 -0
- package/dist/runtime/pm/utils/getMarkPosition.js +34 -0
- package/dist/runtime/pm/utils/getMarksInSelection.d.ts +3 -0
- package/dist/runtime/pm/utils/getMarksInSelection.js +16 -0
- package/dist/runtime/pm/utils/getTypeByName.d.ts +2 -0
- package/dist/runtime/pm/utils/getTypeByName.js +5 -0
- package/dist/runtime/pm/utils/index.d.ts +15 -0
- package/dist/runtime/pm/utils/index.js +15 -0
- package/dist/runtime/pm/utils/internal/createNodeTypesList.d.ts +2 -0
- package/dist/runtime/pm/utils/internal/createNodeTypesList.js +17 -0
- package/dist/runtime/pm/utils/internal/debugMap.d.ts +7 -0
- package/dist/runtime/pm/utils/internal/debugMap.js +24 -0
- package/dist/runtime/pm/utils/internal/debugNode.d.ts +2 -0
- package/dist/runtime/pm/utils/internal/debugNode.js +18 -0
- package/dist/runtime/pm/utils/internal/debugSel.d.ts +5 -0
- package/dist/runtime/pm/utils/internal/debugSel.js +8 -0
- package/dist/runtime/pm/utils/internal/recurse.d.ts +2 -0
- package/dist/runtime/pm/utils/internal/recurse.js +39 -0
- package/dist/runtime/pm/utils/internal/stripBlockId.d.ts +2 -0
- package/dist/runtime/pm/utils/internal/stripBlockId.js +9 -0
- package/dist/runtime/pm/utils/mapSelection.d.ts +8 -0
- package/dist/runtime/pm/utils/mapSelection.js +12 -0
- package/dist/runtime/pm/utils/nodesBetween.d.ts +21 -0
- package/dist/runtime/pm/utils/nodesBetween.js +21 -0
- package/dist/runtime/pm/utils/pointToPmPoint.d.ts +2 -0
- package/dist/runtime/pm/utils/pointToPmPoint.js +3 -0
- package/dist/runtime/pm/utils/splitIntoChunks.d.ts +32 -0
- package/dist/runtime/pm/utils/splitIntoChunks.js +31 -0
- package/dist/runtime/testDocuments.d.ts +53 -0
- package/dist/runtime/testDocuments.js +122 -0
- package/dist/runtime/types/index.d.ts +53 -0
- package/dist/runtime/types/index.js +9 -0
- package/dist/types.d.mts +3 -0
- package/package.json +238 -0
- package/src/module.ts +101 -0
- package/src/runtime/assets/base.css +83 -0
- package/src/runtime/assets/handle-arrow.svg +16 -0
- package/src/runtime/assets/handle-border-circles-single.svg +44 -0
- package/src/runtime/assets/handle-border-circles.svg +27 -0
- package/src/runtime/assets/handle-temp.svg +1 -0
- package/src/runtime/assets/utils.css +9 -0
- package/src/runtime/components/CodeBlockThemePicker.vue +125 -0
- package/src/runtime/components/Commands.vue +67 -0
- package/src/runtime/components/Editor.vue +330 -0
- package/src/runtime/components/EditorDemoApp.vue +118 -0
- package/src/runtime/components/EditorDemoControls.vue +38 -0
- package/src/runtime/components/TestWrapper.vue +74 -0
- package/src/runtime/composables/useEditor.ts +29 -0
- package/src/runtime/composables/useWindowDebugging.ts +20 -0
- package/src/runtime/demo/App.vue +114 -0
- package/src/runtime/demo/README.md +1 -0
- package/src/runtime/demo/main.ts +8 -0
- package/src/runtime/demo/tailwind.css +4 -0
- package/src/runtime/env.d.ts +2 -0
- package/src/runtime/injectionKeys.ts +10 -0
- package/src/runtime/main.lib.ts +2 -0
- package/src/runtime/pm/commands/backspace.ts +44 -0
- package/src/runtime/pm/commands/changeAttrs.ts +37 -0
- package/src/runtime/pm/commands/deleteSelection.ts +22 -0
- package/src/runtime/pm/commands/enter.ts +27 -0
- package/src/runtime/pm/commands/insertBreak.ts +40 -0
- package/src/runtime/pm/features/Base/Base.ts +39 -0
- package/src/runtime/pm/features/Base/commands/deleteNodes.ts +54 -0
- package/src/runtime/pm/features/Base/commands/setCursorVisible.ts +24 -0
- package/src/runtime/pm/features/Base/plugins/debugSelectionPlugin.ts +57 -0
- package/src/runtime/pm/features/Base/plugins/isCursorVisiblePlugin.ts +28 -0
- package/src/runtime/pm/features/Base/plugins/isUsingTouchPlugin.ts +40 -0
- package/src/runtime/pm/features/Base/plugins/selectingIndicator.ts +38 -0
- package/src/runtime/pm/features/Base/plugins/unfocusedSelectionIndicatorPlugin.ts +107 -0
- package/src/runtime/pm/features/Base/types.ts +3 -0
- package/src/runtime/pm/features/BaseShortcuts/BaseShortcuts.ts +39 -0
- package/src/runtime/pm/features/Blockquote/Blockquote.ts +75 -0
- package/src/runtime/pm/features/Blockquote/commands/blockquoteEnter.ts +51 -0
- package/src/runtime/pm/features/Blockquote/commands/blockquoteShiftEnter.ts +26 -0
- package/src/runtime/pm/features/Blocks/Blocks.ts +3 -0
- package/src/runtime/pm/features/Blocks/Item.ts +176 -0
- package/src/runtime/pm/features/Blocks/List.ts +67 -0
- package/src/runtime/pm/features/Blocks/commands/changeItemType.ts +64 -0
- package/src/runtime/pm/features/Blocks/commands/changeTypeAttr.ts +47 -0
- package/src/runtime/pm/features/Blocks/commands/copyOrMoveItem.ts +179 -0
- package/src/runtime/pm/features/Blocks/commands/deleteItem.ts +24 -0
- package/src/runtime/pm/features/Blocks/commands/indentItem.ts +105 -0
- package/src/runtime/pm/features/Blocks/commands/itemMenuCommands.ts +62 -0
- package/src/runtime/pm/features/Blocks/commands/moveItem.ts +128 -0
- package/src/runtime/pm/features/Blocks/commands/setNode.ts +186 -0
- package/src/runtime/pm/features/Blocks/commands/splitItem.ts +116 -0
- package/src/runtime/pm/features/Blocks/commands/unindentItem.ts +82 -0
- package/src/runtime/pm/features/Blocks/components/DragTreeHandle.vue +142 -0
- package/src/runtime/pm/features/Blocks/components/ItemMenu.vue +88 -0
- package/src/runtime/pm/features/Blocks/components/ItemNodeView.vue +394 -0
- package/src/runtime/pm/features/Blocks/components/defaultItemMenu.ts +45 -0
- package/src/runtime/pm/features/Blocks/composables/useDragWithThreshold.ts +0 -0
- package/src/runtime/pm/features/Blocks/composables/useHandleHeight.ts +28 -0
- package/src/runtime/pm/features/Blocks/composables/useHasChildren.ts +14 -0
- package/src/runtime/pm/features/Blocks/composables/useNodeStates.ts +29 -0
- package/src/runtime/pm/features/Blocks/itemMenuMenuItems.ts +143 -0
- package/src/runtime/pm/features/Blocks/plugins/ensureLastItemIsContentPlugin.ts +52 -0
- package/src/runtime/pm/features/Blocks/plugins/itemBlockIdPlugin.ts +40 -0
- package/src/runtime/pm/features/Blocks/plugins/itemHasSingularSelectionPlugin.ts +32 -0
- package/src/runtime/pm/features/Blocks/plugins/itemMenuPlugin.ts +21 -0
- package/src/runtime/pm/features/Blocks/states/stateful.ts +41 -0
- package/src/runtime/pm/features/Blocks/states/task/cancelled.svg +32 -0
- package/src/runtime/pm/features/Blocks/states/task/checked.svg +27 -0
- package/src/runtime/pm/features/Blocks/states/task/checked2.svg +24 -0
- package/src/runtime/pm/features/Blocks/states/task/partial.svg +24 -0
- package/src/runtime/pm/features/Blocks/states/task/partial2.svg +31 -0
- package/src/runtime/pm/features/Blocks/states/task/unchecked.svg +20 -0
- package/src/runtime/pm/features/Blocks/types.ts +51 -0
- package/src/runtime/pm/features/Blocks/utils/createItemMenuCommandExecuter.ts +47 -0
- package/src/runtime/pm/features/Blocks/utils/fixBlockIds.ts +28 -0
- package/src/runtime/pm/features/Blocks/utils/isValidId.ts +8 -0
- package/src/runtime/pm/features/CodeBlock/CodeBlock.ts +104 -0
- package/src/runtime/pm/features/CodeBlock/build/generateHighlightJsInfo.js +63 -0
- package/src/runtime/pm/features/CodeBlock/commands/codeBlockEnterOrSplit.ts +55 -0
- package/src/runtime/pm/features/CodeBlock/commands/codeBlockIndent.ts +67 -0
- package/src/runtime/pm/features/CodeBlock/commands/codeBlockUnindent.ts +74 -0
- package/src/runtime/pm/features/CodeBlock/commands/focusCodeBlockLanguage.ts +44 -0
- package/src/runtime/pm/features/CodeBlock/components/CodeBlockView.vue +126 -0
- package/src/runtime/pm/features/CodeBlock/composables/useAsyncCodeBlockHighlighting.ts +185 -0
- package/src/runtime/pm/features/CodeBlock/composables/useHighlightJsTheme.ts +150 -0
- package/src/runtime/pm/features/CodeBlock/highlightJsInfo.ts +733 -0
- package/src/runtime/pm/features/CodeBlock/types.ts +7 -0
- package/src/runtime/pm/features/Collaboration/Collaboration.ts +295 -0
- package/src/runtime/pm/features/CommandsMenus/CommandBar.ts +130 -0
- package/src/runtime/pm/features/CommandsMenus/commandBarMenuItems.ts +209 -0
- package/src/runtime/pm/features/CommandsMenus/components/CommandBar.vue +63 -0
- package/src/runtime/pm/features/CommandsMenus/components/CommandBarItem.vue +48 -0
- package/src/runtime/pm/features/CommandsMenus/components/CommandMenuGroup.vue +59 -0
- package/src/runtime/pm/features/CommandsMenus/components/CommandMenuItem.vue +67 -0
- package/src/runtime/pm/features/CommandsMenus/components/CommandMenuList.vue +60 -0
- package/src/runtime/pm/features/CommandsMenus/components/TextIcon.vue +14 -0
- package/src/runtime/pm/features/CommandsMenus/icons/HighlightIcon.vue +51 -0
- package/src/runtime/pm/features/CommandsMenus/icons/SubscriptIcon.vue +5 -0
- package/src/runtime/pm/features/CommandsMenus/icons/SuperscriptIcon.vue +5 -0
- package/src/runtime/pm/features/CommandsMenus/types.ts +73 -0
- package/src/runtime/pm/features/CommandsMenus/utils/defaultCommandExecutor.ts +22 -0
- package/src/runtime/pm/features/CommandsMenus/utils/findCommand.ts +37 -0
- package/src/runtime/pm/features/CommandsMenus/utils/popupPositionModifier.ts +14 -0
- package/src/runtime/pm/features/CommandsMenus/utils/popupVerticalPositioner.ts +16 -0
- package/src/runtime/pm/features/Document/Document.ts +9 -0
- package/src/runtime/pm/features/DocumentApi/DocumentApi.ts +272 -0
- package/src/runtime/pm/features/DocumentApi/composables/useEditorContent.ts +105 -0
- package/src/runtime/pm/features/DocumentApi/composables/useTestDocumentApi.ts +95 -0
- package/src/runtime/pm/features/DocumentApi/types.ts +143 -0
- package/src/runtime/pm/features/DocumentApi/utils/convertFullTransactionForPartialState.ts +54 -0
- package/src/runtime/pm/features/DocumentApi/utils/convertTrForInstance.ts +24 -0
- package/src/runtime/pm/features/DocumentApi/utils/convertTransactionForFullState.ts +39 -0
- package/src/runtime/pm/features/DocumentApi/utils/copyMeta.ts +8 -0
- package/src/runtime/pm/features/DocumentApi/utils/getEmbedJson.ts +16 -0
- package/src/runtime/pm/features/DocumentApi/utils/getEmbedNodeFromDoc.ts +15 -0
- package/src/runtime/pm/features/DocumentApi/utils/getStateEmbedRange.ts +26 -0
- package/src/runtime/pm/features/DocumentApi/utils/isEmbedId.ts +5 -0
- package/src/runtime/pm/features/EmbeddedDocument/Embedded.ts +110 -0
- package/src/runtime/pm/features/EmbeddedDocument/EmbeddedDocument.ts +102 -0
- package/src/runtime/pm/features/EmbeddedDocument/components/EmbeddedDocumentPicker.vue +188 -0
- package/src/runtime/pm/features/EmbeddedDocument/components/EmbeddedNodeView.vue +187 -0
- package/src/runtime/pm/features/EmbeddedDocument/composables/useEmbeddedEditor.ts +302 -0
- package/src/runtime/pm/features/EmbeddedDocument/types.ts +61 -0
- package/src/runtime/pm/features/EmbeddedDocument/utils/isEmbeddedBlock.ts +12 -0
- package/src/runtime/pm/features/EmbeddedDocument/utils/redirectFromEmbedded.ts +48 -0
- package/src/runtime/pm/features/FileLoader/FileLoader.ts +120 -0
- package/src/runtime/pm/features/FileLoader/FileLoaderHandler/FileLoaderHandler.ts +100 -0
- package/src/runtime/pm/features/FileLoader/FileLoaderHandler/TestFileLoaderHandler.ts +61 -0
- package/src/runtime/pm/features/FileLoader/commands/insertFile.ts +87 -0
- package/src/runtime/pm/features/FileLoader/components/FileLoaderNodeView.vue +38 -0
- package/src/runtime/pm/features/FileLoader/plugins/fileLoaderPlugin.ts +70 -0
- package/src/runtime/pm/features/FileLoader/types.ts +91 -0
- package/src/runtime/pm/features/FileLoader/utils/cleanupFileLoaderNode.ts +39 -0
- package/src/runtime/pm/features/FileLoader/utils/cleanupFileLoaderNodes.ts +42 -0
- package/src/runtime/pm/features/FileLoader/utils/findLoadingNodePos.ts +16 -0
- package/src/runtime/pm/features/FileLoader/utils/optionsCheck.ts +16 -0
- package/src/runtime/pm/features/FileLoader/utils/readAsDataUrl.ts +12 -0
- package/src/runtime/pm/features/HardBreak/HardBreak.ts +21 -0
- package/src/runtime/pm/features/Heading/Heading.ts +130 -0
- package/src/runtime/pm/features/Heading/commands/changeLevelAttr.ts +55 -0
- package/src/runtime/pm/features/Heading/types.ts +17 -0
- package/src/runtime/pm/features/Highlight/Highlight.ts +234 -0
- package/src/runtime/pm/features/Highlight/retyped/tiptapHighlight.d.ts +3 -0
- package/src/runtime/pm/features/Highlight/retyped/tiptapHighlight.js +5 -0
- package/src/runtime/pm/features/Highlight/types.ts +25 -0
- package/src/runtime/pm/features/History/History.ts +112 -0
- package/src/runtime/pm/features/Iframe/Iframe.ts +163 -0
- package/src/runtime/pm/features/Iframe/IframeParsers.ts +116 -0
- package/src/runtime/pm/features/Iframe/components/IframeNodeView.vue +83 -0
- package/src/runtime/pm/features/Iframe/types.ts +7 -0
- package/src/runtime/pm/features/Image/Image.ts +16 -0
- package/src/runtime/pm/features/Link/Link.ts +313 -0
- package/src/runtime/pm/features/Link/components/BubbleMenuExternalLink.vue +125 -0
- package/src/runtime/pm/features/Link/components/BubbleMenuInternalLink.vue +130 -0
- package/src/runtime/pm/features/Link/components/BubbleMenuLink.vue +149 -0
- package/src/runtime/pm/features/Link/components/BubbleMenuLinkActions.vue +65 -0
- package/src/runtime/pm/features/Link/types.ts +53 -0
- package/src/runtime/pm/features/Menus/Menus.ts +195 -0
- package/src/runtime/pm/features/Menus/components/MarkMenuManager.vue +203 -0
- package/src/runtime/pm/features/Menus/types.ts +64 -0
- package/src/runtime/pm/features/Menus/utils/isMarkMenu.ts +5 -0
- package/src/runtime/pm/features/Tables/commands/tableEnter.ts +40 -0
- package/src/runtime/pm/features/Tables/index.ts +60 -0
- package/src/runtime/pm/schema.ts +128 -0
- package/src/runtime/pm/testSchema.ts +34 -0
- package/src/runtime/pm/utils/createDropIndicator.ts +61 -0
- package/src/runtime/pm/utils/createStateOnlyPluginApply.ts +11 -0
- package/src/runtime/pm/utils/createStateOnlyPluginObjApply.ts +16 -0
- package/src/runtime/pm/utils/dropPointInfo.ts +85 -0
- package/src/runtime/pm/utils/findUpwards.ts +43 -0
- package/src/runtime/pm/utils/getChildChunks.ts +24 -0
- package/src/runtime/pm/utils/getDiffReplacementRange.ts +32 -0
- package/src/runtime/pm/utils/getElMaxVisualSize.ts +14 -0
- package/src/runtime/pm/utils/getElPropertyAsInt.ts +8 -0
- package/src/runtime/pm/utils/getGroupNodeNames.ts +9 -0
- package/src/runtime/pm/utils/getMarkPosition.ts +57 -0
- package/src/runtime/pm/utils/getMarksInSelection.ts +19 -0
- package/src/runtime/pm/utils/getTypeByName.ts +7 -0
- package/src/runtime/pm/utils/index.ts +17 -0
- package/src/runtime/pm/utils/internal/createNodeTypesList.ts +25 -0
- package/src/runtime/pm/utils/internal/debugMap.ts +36 -0
- package/src/runtime/pm/utils/internal/debugNode.ts +38 -0
- package/src/runtime/pm/utils/internal/debugSel.ts +10 -0
- package/src/runtime/pm/utils/internal/recurse.ts +44 -0
- package/src/runtime/pm/utils/internal/stripBlockId.ts +10 -0
- package/src/runtime/pm/utils/mapSelection.ts +21 -0
- package/src/runtime/pm/utils/nodesBetween.ts +47 -0
- package/src/runtime/pm/utils/pointToPmPoint.ts +5 -0
- package/src/runtime/pm/utils/splitIntoChunks.ts +68 -0
- package/src/runtime/testDocuments.ts +130 -0
- package/src/runtime/types/index.ts +56 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies/moves an item to be before/after/child of the target item.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Command } from "@tiptap/core"
|
|
6
|
+
import { Fragment, Slice } from "@tiptap/pm/model"
|
|
7
|
+
import { TextSelection } from "@tiptap/pm/state"
|
|
8
|
+
import { ReplaceAroundStep } from "@tiptap/pm/transform"
|
|
9
|
+
|
|
10
|
+
import { redirectFromEmbedded } from "../../EmbeddedDocument/utils/redirectFromEmbedded.js"
|
|
11
|
+
|
|
12
|
+
declare module "@tiptap/core" {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
|
+
interface Commands<ReturnType> {
|
|
15
|
+
copyOrMoveItem: {
|
|
16
|
+
/**
|
|
17
|
+
* @redirectable
|
|
18
|
+
*/
|
|
19
|
+
copyOrMoveItem: (
|
|
20
|
+
itemPos: number,
|
|
21
|
+
moveItemPos: number,
|
|
22
|
+
position: "before" | "after" | "child",
|
|
23
|
+
options?: {
|
|
24
|
+
move?: boolean
|
|
25
|
+
}
|
|
26
|
+
) => ReturnType
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Copies or moves a single list item. This is for using while dragging an item. */
|
|
32
|
+
export const copyOrMoveItem = ({
|
|
33
|
+
listNodeTypeName = "list",
|
|
34
|
+
itemNodeTypeName = "item"
|
|
35
|
+
}: {
|
|
36
|
+
listNodeTypeName?: string
|
|
37
|
+
itemNodeTypeName?: string
|
|
38
|
+
} = {}) =>
|
|
39
|
+
(
|
|
40
|
+
itemPos: number,
|
|
41
|
+
moveItemPos: number,
|
|
42
|
+
position: "before" | "after" | "child",
|
|
43
|
+
{
|
|
44
|
+
move = true
|
|
45
|
+
}: { move?: boolean } = {}
|
|
46
|
+
): Command =>
|
|
47
|
+
({ tr, state, view, commands, dispatch }): boolean => {
|
|
48
|
+
const redirect = redirectFromEmbedded(
|
|
49
|
+
view,
|
|
50
|
+
"copyOrMoveItem",
|
|
51
|
+
{ args: [itemPos, moveItemPos, position, { move }], view, commands }
|
|
52
|
+
)
|
|
53
|
+
if (redirect.redirected) {
|
|
54
|
+
return redirect.result as any // todo
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const listNode = state.schema.nodes[listNodeTypeName]
|
|
58
|
+
const itemNode = state.schema.nodes[itemNodeTypeName]
|
|
59
|
+
const $targetItem = tr.doc.resolve(moveItemPos)
|
|
60
|
+
const $item = tr.doc.resolve(itemPos)
|
|
61
|
+
if ($item.node().type.name !== itemNodeTypeName) {
|
|
62
|
+
throw new Error(`itemPos ${itemPos} does not point to node type ${itemNodeTypeName} but to ${$item.node().type.name}`)
|
|
63
|
+
}
|
|
64
|
+
if ($targetItem.node().type.name !== itemNodeTypeName) {
|
|
65
|
+
throw new Error(`moveItemPos ${moveItemPos} does not point to node type ${itemNodeTypeName} but to ${$targetItem.node().type.name}`)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// internally we use $target pointing at the first node of the item (e.g. a paragraph or some other block content)
|
|
69
|
+
// this makes it easier to tell if it has a list child after the p or not
|
|
70
|
+
const $target = tr.doc.resolve($targetItem.start() + 1)
|
|
71
|
+
// sometimes the target is still pointing at an item
|
|
72
|
+
// this happens with blocks that have no inline content, such as embedded docs
|
|
73
|
+
// these require some special handling and shifting of positions since we cant resolve to a ResolvedPos whose .node() is the block
|
|
74
|
+
const targetIsContentless = $target.node().type.name === $targetItem.node().type.name
|
|
75
|
+
const parent = targetIsContentless ? $targetItem.node() : $target.node(-1)
|
|
76
|
+
const nodeAfterIsList = parent.childCount > 1 && parent.child(1).type.name === listNodeTypeName
|
|
77
|
+
|
|
78
|
+
const { from, to } = state.selection.map(tr.doc, tr.mapping)
|
|
79
|
+
const beforeItemPos = $item.before()
|
|
80
|
+
const afterItemPos = $item.after()
|
|
81
|
+
|
|
82
|
+
const selectionFromOffset = from > beforeItemPos && from < afterItemPos ? state.selection.from - beforeItemPos : undefined
|
|
83
|
+
const selectionToOffset = to > beforeItemPos && to < afterItemPos ? state.selection.to - beforeItemPos : undefined
|
|
84
|
+
function restoreSelection(start: number): void {
|
|
85
|
+
if (!dispatch) return
|
|
86
|
+
// attempt to restore selection to inside the item if it was inside
|
|
87
|
+
// this will also restore it to just the start if it was touching
|
|
88
|
+
if (selectionFromOffset) {
|
|
89
|
+
tr.setSelection(TextSelection.create(
|
|
90
|
+
tr.doc,
|
|
91
|
+
start + selectionFromOffset,
|
|
92
|
+
selectionToOffset && selectionToOffset + start
|
|
93
|
+
))
|
|
94
|
+
} else if (selectionToOffset) {
|
|
95
|
+
// otherwise to the end if it was touching
|
|
96
|
+
tr.setSelection(TextSelection.create(
|
|
97
|
+
tr.doc,
|
|
98
|
+
selectionToOffset && selectionToOffset + start
|
|
99
|
+
))
|
|
100
|
+
} else {
|
|
101
|
+
// otherwise to the start of the item
|
|
102
|
+
const $start = tr.doc.resolve(start)
|
|
103
|
+
const sel = TextSelection.findFrom($start, 1, true)
|
|
104
|
+
if (sel) {
|
|
105
|
+
tr.setSelection(sel)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const deleteItemIfWanted = (): void => {
|
|
111
|
+
if (!dispatch) return
|
|
112
|
+
if (move) {
|
|
113
|
+
const isLastItem = $item.index(-1) === 0
|
|
114
|
+
const offset = (isLastItem ? 2 : 1)
|
|
115
|
+
const start = $item.start() - offset
|
|
116
|
+
const end = $item.end() + offset
|
|
117
|
+
tr.delete(start, end)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (position === "after") {
|
|
121
|
+
if (!nodeAfterIsList) {
|
|
122
|
+
const slice = tr.doc.slice($item.start() - 1, $item.end() + 1)
|
|
123
|
+
deleteItemIfWanted()
|
|
124
|
+
if (dispatch) tr.replace(tr.mapping.map($target.end()), undefined, slice)
|
|
125
|
+
restoreSelection(tr.mapping.map($target.end()) + 2)
|
|
126
|
+
return true
|
|
127
|
+
} else {
|
|
128
|
+
// start/end need to point at the start/end of the child list
|
|
129
|
+
// this is more foolproof than using .after due to contentless blocks
|
|
130
|
+
let start = $targetItem.start() + $targetItem.node().child(0).nodeSize
|
|
131
|
+
let end = start + $targetItem.node().child(1).nodeSize
|
|
132
|
+
const slice = new Slice(
|
|
133
|
+
Fragment.from([itemNode.create({}), $item.node()]),
|
|
134
|
+
1,
|
|
135
|
+
1
|
|
136
|
+
)
|
|
137
|
+
deleteItemIfWanted()
|
|
138
|
+
start = tr.mapping.map(start)
|
|
139
|
+
end = tr.mapping.map(end)
|
|
140
|
+
if (dispatch) {
|
|
141
|
+
tr.step(new ReplaceAroundStep(
|
|
142
|
+
start,
|
|
143
|
+
end,
|
|
144
|
+
start,
|
|
145
|
+
end,
|
|
146
|
+
slice,
|
|
147
|
+
slice.size,
|
|
148
|
+
false
|
|
149
|
+
))
|
|
150
|
+
}
|
|
151
|
+
restoreSelection(start + 1)
|
|
152
|
+
return true
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (position === "before") {
|
|
156
|
+
deleteItemIfWanted()
|
|
157
|
+
const start = tr.mapping.map($target.before(targetIsContentless ? undefined : -1))
|
|
158
|
+
if (dispatch) tr.insert(start, $item.node())
|
|
159
|
+
restoreSelection(start)
|
|
160
|
+
return true
|
|
161
|
+
}
|
|
162
|
+
if (position === "child") {
|
|
163
|
+
const slice = new Slice(
|
|
164
|
+
Fragment.from([listNode.create({}, $item.node())]),
|
|
165
|
+
0,
|
|
166
|
+
nodeAfterIsList ? 1 : 0
|
|
167
|
+
)
|
|
168
|
+
deleteItemIfWanted()
|
|
169
|
+
const unmappedStart = $target.start() + $target.node().child(0).nodeSize + (targetIsContentless ? 0 : 1)
|
|
170
|
+
const start = tr.mapping.map(unmappedStart)
|
|
171
|
+
const end = nodeAfterIsList
|
|
172
|
+
? start + 1
|
|
173
|
+
: undefined
|
|
174
|
+
if (dispatch) tr.replace(start, end, slice)
|
|
175
|
+
restoreSelection(start + 1)
|
|
176
|
+
return true
|
|
177
|
+
}
|
|
178
|
+
return false
|
|
179
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Command } from "@tiptap/core"
|
|
2
|
+
|
|
3
|
+
import { redirectFromEmbedded } from "../../EmbeddedDocument/utils/redirectFromEmbedded.js"
|
|
4
|
+
|
|
5
|
+
declare module "@tiptap/core" {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
deleteItem: {
|
|
9
|
+
/**
|
|
10
|
+
* @redirectable
|
|
11
|
+
*/
|
|
12
|
+
deleteItem: (pos?: number | undefined) => ReturnType
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const deleteItem = (type: string) =>
|
|
18
|
+
(pos?: number | undefined): Command =>
|
|
19
|
+
({ view, commands }): boolean => {
|
|
20
|
+
const redirect = redirectFromEmbedded(view, "deleteItem", { args: [pos], view, commands })
|
|
21
|
+
if (redirect.redirected) { return redirect.result as any }
|
|
22
|
+
|
|
23
|
+
return commands.deleteNodes(type, pos)
|
|
24
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Command } from "@tiptap/core"
|
|
2
|
+
import type { Node } from "@tiptap/pm/model"
|
|
3
|
+
import { Fragment, Slice } from "@tiptap/pm/model"
|
|
4
|
+
import { TextSelection } from "@tiptap/pm/state"
|
|
5
|
+
import { ReplaceAroundStep } from "@tiptap/pm/transform"
|
|
6
|
+
|
|
7
|
+
import { getTypeByName } from "../../../utils/getTypeByName.js"
|
|
8
|
+
import { mapSelection } from "../../../utils/mapSelection.js"
|
|
9
|
+
import { splitIntoChunks } from "../../../utils/splitIntoChunks.js"
|
|
10
|
+
import { redirectFromEmbedded } from "../../EmbeddedDocument/utils/redirectFromEmbedded.js"
|
|
11
|
+
|
|
12
|
+
declare module "@tiptap/core" {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
|
+
interface Commands<ReturnType> {
|
|
15
|
+
indentItem: {
|
|
16
|
+
/**
|
|
17
|
+
* @redirectable
|
|
18
|
+
*/
|
|
19
|
+
indentItem: (from?: number, to?: number) => ReturnType
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const indentItem = (
|
|
26
|
+
itemTypeName: string,
|
|
27
|
+
listTypeName: string
|
|
28
|
+
) =>
|
|
29
|
+
(from?: number, to?: number): Command => ({ state, dispatch, tr, editor, view, commands }): boolean => {
|
|
30
|
+
const redirect = redirectFromEmbedded(view, "indentItem", { args: [from, to], view, commands })
|
|
31
|
+
if (redirect.redirected) { return redirect.result as any }
|
|
32
|
+
|
|
33
|
+
const listType = getTypeByName(editor.schema, listTypeName)
|
|
34
|
+
const itemType = getTypeByName(editor.schema, itemTypeName)
|
|
35
|
+
|
|
36
|
+
const sel = from !== undefined
|
|
37
|
+
? TextSelection.create(tr.doc, from, to)
|
|
38
|
+
: state.selection.map(tr.doc, tr.mapping)
|
|
39
|
+
|
|
40
|
+
const chunks = splitIntoChunks(tr.doc, itemType, sel)
|
|
41
|
+
const blockRangeFilter = (node: Node): boolean => node.childCount > 0 && node.firstChild!.type === itemType
|
|
42
|
+
|
|
43
|
+
let canChange = false
|
|
44
|
+
for (const chunk of chunks) {
|
|
45
|
+
const { $from, $to } = mapSelection(tr, chunk)
|
|
46
|
+
const range = $from.blockRange($to, blockRangeFilter)
|
|
47
|
+
if (!range) continue
|
|
48
|
+
canChange = true
|
|
49
|
+
const start = range.start
|
|
50
|
+
const end = range.end
|
|
51
|
+
|
|
52
|
+
// A
|
|
53
|
+
// B <- first child of A
|
|
54
|
+
const itemIndex = $from.index(-1)
|
|
55
|
+
const isFirstChild = itemIndex === 0
|
|
56
|
+
// A <- nodebefore
|
|
57
|
+
// B <-
|
|
58
|
+
const nodeBefore = !isFirstChild
|
|
59
|
+
? $from.node(-1).child(itemIndex - 1)
|
|
60
|
+
: undefined
|
|
61
|
+
// A
|
|
62
|
+
// B <- nested node before
|
|
63
|
+
// C <-
|
|
64
|
+
const nodeBeforeIsNested = nodeBefore?.lastChild?.type === listType
|
|
65
|
+
|
|
66
|
+
// item [list [item?]]
|
|
67
|
+
const fragment = Fragment.from(
|
|
68
|
+
itemType.create(
|
|
69
|
+
null,
|
|
70
|
+
Fragment.from(listType.create(
|
|
71
|
+
null,
|
|
72
|
+
Fragment.from(nodeBeforeIsNested ? itemType.create() : null)
|
|
73
|
+
))
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
// make sibling of previous by leaving /item /list /item open
|
|
78
|
+
const startOpen = nodeBeforeIsNested
|
|
79
|
+
? 3
|
|
80
|
+
// just wrap in list
|
|
81
|
+
: isFirstChild
|
|
82
|
+
? 0
|
|
83
|
+
// nest under sibling by leaving /item open
|
|
84
|
+
: 1
|
|
85
|
+
|
|
86
|
+
const slice = new Slice(
|
|
87
|
+
fragment,
|
|
88
|
+
startOpen,
|
|
89
|
+
0
|
|
90
|
+
)
|
|
91
|
+
if (dispatch) {
|
|
92
|
+
// debugNode(slice, `${slice.openStart}-${slice.openEnd}`)
|
|
93
|
+
tr.step(new ReplaceAroundStep(
|
|
94
|
+
start - startOpen,
|
|
95
|
+
end,
|
|
96
|
+
start,
|
|
97
|
+
end,
|
|
98
|
+
slice,
|
|
99
|
+
isFirstChild ? 2 : 1,
|
|
100
|
+
true
|
|
101
|
+
))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return canChange
|
|
105
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils"
|
|
2
|
+
import type { Command } from "@tiptap/core"
|
|
3
|
+
|
|
4
|
+
import { findUpwards } from "../../../utils/findUpwards.js"
|
|
5
|
+
import { itemMenuPluginKey } from "../types.js"
|
|
6
|
+
|
|
7
|
+
declare module "@tiptap/core" {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
itemMenu: {
|
|
11
|
+
openItemMenu: (id?: string) => ReturnType
|
|
12
|
+
closeItemMenu: (id?: string) => ReturnType
|
|
13
|
+
toggleItemMenu: (id?: string) => ReturnType
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare module "../../../../types/index.js" {
|
|
19
|
+
interface MenuCloseCommands {
|
|
20
|
+
closeItemMenu: "closeItemMenu"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const openItemMenu = (itemTypeName: string) =>
|
|
25
|
+
(id?: string): Command =>
|
|
26
|
+
({ tr, state, dispatch }) => {
|
|
27
|
+
const menu = itemMenuPluginKey.getState(state)
|
|
28
|
+
id ??= findUpwards(
|
|
29
|
+
tr.doc,
|
|
30
|
+
state.selection.map(tr.doc, tr.mapping).from,
|
|
31
|
+
$pos => {
|
|
32
|
+
if ($pos.node().type.name === itemTypeName) return true
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
).$pos?.node().attrs.blockId
|
|
36
|
+
if (!id) { unreachable() }
|
|
37
|
+
if (menu?.opened && menu.id === id) return false
|
|
38
|
+
if (dispatch) {
|
|
39
|
+
tr.setMeta("addToHistory", false)
|
|
40
|
+
|
|
41
|
+
tr.setMeta(itemMenuPluginKey, { opened: true, id })
|
|
42
|
+
}
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const closeItemMenu = () => (): Command => ({ tr, state, dispatch }) => {
|
|
47
|
+
const menu = itemMenuPluginKey.getState(state)
|
|
48
|
+
if (menu && !menu.opened) return false
|
|
49
|
+
if (dispatch) {
|
|
50
|
+
tr.setMeta("addToHistory", false)
|
|
51
|
+
tr.setMeta(itemMenuPluginKey, { opened: false, id: undefined })
|
|
52
|
+
}
|
|
53
|
+
return true
|
|
54
|
+
}
|
|
55
|
+
export const toggleItemMenu = () => (id?: string): Command => ({ commands, state }) => {
|
|
56
|
+
const menu = itemMenuPluginKey.getState(state)
|
|
57
|
+
if (menu?.opened) {
|
|
58
|
+
return commands.closeItemMenu()
|
|
59
|
+
} else {
|
|
60
|
+
return commands.openItemMenu(id)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Command } from "@tiptap/core"
|
|
2
|
+
import type { ResolvedPos } from "@tiptap/pm/model"
|
|
3
|
+
import { TextSelection } from "@tiptap/pm/state"
|
|
4
|
+
|
|
5
|
+
import { getTypeByName } from "../../../utils/getTypeByName.js"
|
|
6
|
+
import { debugNode } from "../../../utils/internal/debugNode.js"
|
|
7
|
+
import { nodesBetween } from "../../../utils/nodesBetween.js"
|
|
8
|
+
import { redirectFromEmbedded } from "../../EmbeddedDocument/utils/redirectFromEmbedded.js"
|
|
9
|
+
|
|
10
|
+
declare module "@tiptap/core" {
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
+
interface Commands<ReturnType> {
|
|
14
|
+
moveItem: {
|
|
15
|
+
/**
|
|
16
|
+
* @redirectable
|
|
17
|
+
*/
|
|
18
|
+
moveItem: (
|
|
19
|
+
dir: "down" | "up",
|
|
20
|
+
pos?: number,
|
|
21
|
+
) => ReturnType
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const moveItem = (
|
|
26
|
+
itemTypeName: string
|
|
27
|
+
) =>
|
|
28
|
+
(
|
|
29
|
+
dir: "down" | "up" = "down",
|
|
30
|
+
pos?: number
|
|
31
|
+
): Command =>
|
|
32
|
+
({ state, dispatch, tr, editor, commands, view }): boolean => {
|
|
33
|
+
const redirect = redirectFromEmbedded(view, "moveItem", { args: [pos], view, commands })
|
|
34
|
+
if (redirect.redirected) { return redirect.result as any }
|
|
35
|
+
|
|
36
|
+
const itemType = getTypeByName(editor.schema, itemTypeName)
|
|
37
|
+
const { $from, $to, from, to } = pos
|
|
38
|
+
? TextSelection.create(tr.doc, pos, pos)
|
|
39
|
+
: state.selection.map(tr.doc, tr.mapping)
|
|
40
|
+
const sharedDepth = Math.min($from.depth, $to.depth)
|
|
41
|
+
|
|
42
|
+
// get a slice of equal depths
|
|
43
|
+
// - A1
|
|
44
|
+
// - B|1
|
|
45
|
+
// - A|2
|
|
46
|
+
// would move A1 to A2
|
|
47
|
+
const $targetFrom = tr.doc.resolve($from.before($from.depth - sharedDepth - 1) + 1)
|
|
48
|
+
const $targetTo = tr.doc.resolve($to.before(sharedDepth - $to.depth - 1) + 1)
|
|
49
|
+
debugNode($targetFrom, `$targetFrom`)
|
|
50
|
+
debugNode($targetTo, `$targetTo`)
|
|
51
|
+
const range = $targetFrom.blockRange($targetTo)
|
|
52
|
+
if (!range) return false
|
|
53
|
+
const start = range.$from.start()
|
|
54
|
+
const end = range.$to.end()
|
|
55
|
+
const slice = tr.doc.slice(start, end)
|
|
56
|
+
|
|
57
|
+
const itemBefore = $targetFrom.before()
|
|
58
|
+
const itemAfter = $targetTo.after()
|
|
59
|
+
const selectionFromOffset = from > itemBefore && from < itemAfter ? state.selection.from - itemBefore : undefined
|
|
60
|
+
const selectionToOffset = to > itemBefore && to < itemAfter ? state.selection.to - itemBefore : undefined
|
|
61
|
+
|
|
62
|
+
function restoreSelection(start: number): void {
|
|
63
|
+
if (dispatch && selectionFromOffset) {
|
|
64
|
+
tr.setSelection(TextSelection.create(
|
|
65
|
+
tr.doc,
|
|
66
|
+
start + selectionFromOffset,
|
|
67
|
+
selectionToOffset && selectionToOffset + start
|
|
68
|
+
))
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (dir === "up") {
|
|
73
|
+
const index = $targetFrom.index(-1)
|
|
74
|
+
const isFirstTopLevelItem = sharedDepth <= 2 && index === 0
|
|
75
|
+
if (isFirstTopLevelItem) return false
|
|
76
|
+
const $itemBefore
|
|
77
|
+
= $targetFrom.index(-1) === 0
|
|
78
|
+
// get parent
|
|
79
|
+
? tr.doc.resolve($targetFrom.before(-2) + 1)
|
|
80
|
+
// get previous sibling
|
|
81
|
+
: tr.doc.resolve($targetFrom.start() - 2)
|
|
82
|
+
if (!$itemBefore || $itemBefore.node().type.name !== itemType.name) return false
|
|
83
|
+
if (dispatch) {
|
|
84
|
+
tr.delete(start - 2, end + 2)
|
|
85
|
+
const selStart = tr.mapping.map($itemBefore.start()) - 1
|
|
86
|
+
tr.insert(tr.mapping.map($itemBefore.start()), slice.content)
|
|
87
|
+
restoreSelection(selStart)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (dir === "down") {
|
|
91
|
+
// search forward until we find the next item
|
|
92
|
+
// we don't do something like above, because the next item might be
|
|
93
|
+
// way further up (less deep), but we can't know how many levels up
|
|
94
|
+
let $afterItem: ResolvedPos | undefined
|
|
95
|
+
nodesBetween(tr.doc, {
|
|
96
|
+
$from: tr.doc.resolve($to.pos),
|
|
97
|
+
$to: tr.doc.resolve(tr.doc.resolve(0).end())
|
|
98
|
+
|
|
99
|
+
}, (node, pos) => {
|
|
100
|
+
if (!$afterItem && node?.type.name === itemType.name) {
|
|
101
|
+
$afterItem = tr.doc.resolve(pos + 1)
|
|
102
|
+
}
|
|
103
|
+
return false
|
|
104
|
+
})
|
|
105
|
+
if (!$afterItem) return false
|
|
106
|
+
// sibling
|
|
107
|
+
if ($afterItem.depth === sharedDepth - 1) {
|
|
108
|
+
if (dispatch) {
|
|
109
|
+
tr.delete(start - 2, end + 2)
|
|
110
|
+
const selStart = tr.mapping.map($afterItem.end() + 1)
|
|
111
|
+
tr.insert(tr.mapping.map($afterItem.end() + 1), slice.content)
|
|
112
|
+
restoreSelection(selStart)
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
if (dispatch) {
|
|
116
|
+
// the next item is at a much higher depth
|
|
117
|
+
// we make it the child instead
|
|
118
|
+
const $child = tr.doc.resolve($afterItem.start() + 1)
|
|
119
|
+
const insertPos = $child.end() + 1
|
|
120
|
+
tr.delete(start - 2, end + 2)
|
|
121
|
+
const selStart = tr.mapping.map(insertPos)
|
|
122
|
+
tr.insert(tr.mapping.map(insertPos), slice.content)
|
|
123
|
+
restoreSelection(selStart)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true
|
|
128
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type Command, getNodeType } from "@tiptap/core"
|
|
2
|
+
import { Fragment, type Node, type NodeType, Slice } from "@tiptap/pm/model"
|
|
3
|
+
import { Selection, TextSelection } from "@tiptap/pm/state"
|
|
4
|
+
|
|
5
|
+
declare module "@tiptap/core" {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
customSetNode: {
|
|
9
|
+
/**
|
|
10
|
+
* Override's tiptaps' setNode with one that:
|
|
11
|
+
*
|
|
12
|
+
* - Handles non-text node conversions.
|
|
13
|
+
* - Can passed a position.
|
|
14
|
+
* - Correctly preserves marks (only if allowed by the wanted node type).
|
|
15
|
+
* - Attempts to preserve the selection, including inside the node.
|
|
16
|
+
*
|
|
17
|
+
* Note that if a node does not set it's marks property and it's schema's markSet is null, this function takes it as all marks being allowed.
|
|
18
|
+
*/
|
|
19
|
+
setNode: (
|
|
20
|
+
typeOrName: string | NodeType,
|
|
21
|
+
attributes?: Record<string, any>,
|
|
22
|
+
pos?: number
|
|
23
|
+
) => ReturnType
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const setNode = () =>
|
|
29
|
+
(
|
|
30
|
+
typeOrName: string | NodeType,
|
|
31
|
+
attributes = {},
|
|
32
|
+
pos?: number
|
|
33
|
+
): Command => ({ state, tr, dispatch }) => {
|
|
34
|
+
const type = getNodeType(typeOrName, state.schema)
|
|
35
|
+
|
|
36
|
+
const $target = tr.doc.resolve(pos ?? tr.selection.from)
|
|
37
|
+
const targetStart = $target.start()
|
|
38
|
+
const targetEnd = $target.end()
|
|
39
|
+
const targetNode = $target.node()
|
|
40
|
+
|
|
41
|
+
const selection = tr.selection
|
|
42
|
+
const offsets: { pos: number, offset: number }[] = []
|
|
43
|
+
let newNodeStartOffset = 0
|
|
44
|
+
let oldNodeStartOffset = 0
|
|
45
|
+
/**
|
|
46
|
+
* When a node is not a text block, we grab all the inline text content,
|
|
47
|
+
* and stick it into the new node type.
|
|
48
|
+
*/
|
|
49
|
+
if (!type.isTextblock || !targetNode.type.isTextblock) {
|
|
50
|
+
/**
|
|
51
|
+
* This requires some custom mapping shenanigans.
|
|
52
|
+
*
|
|
53
|
+
* TODO: See if we can do this with StepMap instead.
|
|
54
|
+
* TODO: Extract to a function.
|
|
55
|
+
*
|
|
56
|
+
* Basically every time we find a text node, we keep track of the total offset created by the wrapping nodes. So given a target like this:
|
|
57
|
+
*
|
|
58
|
+
* ```
|
|
59
|
+
* target [pos: 0]
|
|
60
|
+
* child [1]
|
|
61
|
+
* text [2]
|
|
62
|
+
* child [3]
|
|
63
|
+
* text [4]
|
|
64
|
+
* [ ...or any various combinations]
|
|
65
|
+
*
|
|
66
|
+
* We can think of the positions like this:
|
|
67
|
+
* ```
|
|
68
|
+
* 0 1 2 3 4 5
|
|
69
|
+
* | [ wrappers* ] | Text | [wrappers*] | Text | [wrappers*] |
|
|
70
|
+
* ```
|
|
71
|
+
* And using the offset at each position, we can map postions from text nodes like this:
|
|
72
|
+
* ```
|
|
73
|
+
* 0 [prev: 1-2] 1 [prev: 3-4] 2
|
|
74
|
+
* | Text | Text |
|
|
75
|
+
* ````
|
|
76
|
+
*/
|
|
77
|
+
// first we create the node, letting it create any children it needs
|
|
78
|
+
const newNode = type.createAndFill(attributes)
|
|
79
|
+
if (!newNode) return false
|
|
80
|
+
let depth = 1
|
|
81
|
+
let childNode = newNode
|
|
82
|
+
// find the deepest parent that can contain text
|
|
83
|
+
while (childNode.childCount > 0) {
|
|
84
|
+
childNode = childNode.firstChild!
|
|
85
|
+
depth++
|
|
86
|
+
if (childNode.isTextblock) break
|
|
87
|
+
}
|
|
88
|
+
// get the start offset of the text for selection mapping
|
|
89
|
+
newNodeStartOffset = depth
|
|
90
|
+
// we need to know which marks this child accepts, NOT it's parent or root convert type
|
|
91
|
+
const insertNodeType = childNode.type
|
|
92
|
+
|
|
93
|
+
// for selection mapping
|
|
94
|
+
let oldNode = targetNode
|
|
95
|
+
depth = 0
|
|
96
|
+
while (oldNode.childCount > 0) {
|
|
97
|
+
oldNode = oldNode.firstChild!
|
|
98
|
+
depth++
|
|
99
|
+
if (oldNode.isTextblock) break
|
|
100
|
+
}
|
|
101
|
+
oldNodeStartOffset = depth
|
|
102
|
+
|
|
103
|
+
// map the offsets and capture the nodes
|
|
104
|
+
const nodes: Node[] = []
|
|
105
|
+
let offset = 0
|
|
106
|
+
let lastPos = 0
|
|
107
|
+
|
|
108
|
+
targetNode.nodesBetween(0, targetNode.content.size, (node, pos) => {
|
|
109
|
+
if (node.isText) {
|
|
110
|
+
offset += pos - lastPos
|
|
111
|
+
lastPos = pos - node.content.size + 1
|
|
112
|
+
offsets.push({ pos: targetStart + pos, offset: offset - oldNodeStartOffset })
|
|
113
|
+
// create doesn't validate marks
|
|
114
|
+
// so we manually filter out those that aren't allowed
|
|
115
|
+
nodes.push(state.schema.text(
|
|
116
|
+
node.text ?? "",
|
|
117
|
+
insertNodeType.allowedMarks(node.marks)
|
|
118
|
+
))
|
|
119
|
+
}
|
|
120
|
+
return true
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
if (newNodeStartOffset === undefined) return false
|
|
124
|
+
const contentNodes = nodes.length > 0 && insertNodeType.isTextblock ? nodes : undefined
|
|
125
|
+
// note that attempting to build the node, even with createAndFill, tends to fail when we pass the contentNodes
|
|
126
|
+
// so they are inserted after instead
|
|
127
|
+
if (dispatch) {
|
|
128
|
+
tr.replace(
|
|
129
|
+
targetStart,
|
|
130
|
+
targetEnd,
|
|
131
|
+
new Slice(Fragment.from(newNode), 0, 0)
|
|
132
|
+
)
|
|
133
|
+
if (contentNodes) {
|
|
134
|
+
tr.insert(targetStart + newNodeStartOffset, contentNodes)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
if (dispatch) {
|
|
139
|
+
tr.setBlockType(targetStart, undefined, type, attributes)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// prevent clearing the document when we change the type of a node
|
|
143
|
+
// without inline content
|
|
144
|
+
// see https://github.com/ueberdosis/tiptap/issues/5490
|
|
145
|
+
if (dispatch) {
|
|
146
|
+
tr.setMeta("preventClearDocument", true)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// while only changing from a non-text node requires we use offsets
|
|
150
|
+
// this is all done from here for both cases since they might both need to use Selection.findFrom
|
|
151
|
+
// in some rare instances (such as cross cell table selections) we fallback
|
|
152
|
+
// to the mapped positions
|
|
153
|
+
// it's not that we can't map them correctly only that the editor does not have a correct state because they are psuedo selections
|
|
154
|
+
// would have to investigate how to get them properly
|
|
155
|
+
|
|
156
|
+
// also findFrom seems to be needed to get a nice selection
|
|
157
|
+
// otherwise the mapped position is often one step after the node which is not what we want
|
|
158
|
+
|
|
159
|
+
if (dispatch) {
|
|
160
|
+
const mappedFrom = tr.mapping.map(selection.from)
|
|
161
|
+
const mappedTo = tr.mapping.map(selection.to)
|
|
162
|
+
|
|
163
|
+
const wantedFromOffset = offsets.findLast(_ => selection.from >= _.pos)?.offset ?? 0
|
|
164
|
+
|
|
165
|
+
const from = selection.from >= targetStart && selection.from <= targetEnd
|
|
166
|
+
? (selection.from - wantedFromOffset + newNodeStartOffset - oldNodeStartOffset)
|
|
167
|
+
: Selection.findFrom(tr.doc.resolve(mappedFrom), -1, true)?.from
|
|
168
|
+
|
|
169
|
+
const wantedToOffset = offsets.findLast(_ => selection.to >= _.pos)?.offset ?? 0
|
|
170
|
+
const to = selection.to >= targetStart && selection.to <= targetEnd
|
|
171
|
+
? (selection.to - wantedToOffset + newNodeStartOffset - oldNodeStartOffset)
|
|
172
|
+
: Selection.findFrom(tr.doc.resolve(mappedTo), -1, true)?.to
|
|
173
|
+
|
|
174
|
+
tr.setSelection(
|
|
175
|
+
TextSelection.create(
|
|
176
|
+
tr.doc,
|
|
177
|
+
// avoid errors from out of range positions just in case
|
|
178
|
+
// all this position mapping is quite finicky
|
|
179
|
+
from && from > 0 && from < tr.doc.content.size ? from : mappedFrom,
|
|
180
|
+
to && to > 0 && to < tr.doc.content.size ? to : mappedTo
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return true
|
|
186
|
+
}
|