@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,12 @@
|
|
|
1
|
+
export async function readAsDataUrl(file: File): Promise<string> {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const fileReader = new FileReader()
|
|
4
|
+
fileReader.readAsDataURL(file)
|
|
5
|
+
fileReader.onload = () => {
|
|
6
|
+
resolve(fileReader.result as string)
|
|
7
|
+
}
|
|
8
|
+
fileReader.onerror = e => {
|
|
9
|
+
reject(e)
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HardBreak as TipTapHardBreak } from "@tiptap/extension-hard-break"
|
|
2
|
+
/**
|
|
3
|
+
* Extends the tiptap hard break extension to set the linebreakReplacement option (which tiptap does not expose).
|
|
4
|
+
* This option tells prosemirror that when converting between blocks that can/can't show whitespace, it should use this node type to represent line breaks in node types that don't display them.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8
|
+
export const HardBreak = TipTapHardBreak.extend({
|
|
9
|
+
extendNodeSchema(extension) {
|
|
10
|
+
// this is called multiple timese, once per node type ???
|
|
11
|
+
if (extension.name === "hardBreak") {
|
|
12
|
+
return {
|
|
13
|
+
linebreakReplacement: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return {}
|
|
17
|
+
},
|
|
18
|
+
addKeyboardShortcuts() {
|
|
19
|
+
return {}
|
|
20
|
+
}
|
|
21
|
+
})
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { isArray } from "@alanscodelog/utils/isArray"
|
|
2
|
+
import { keys } from "@alanscodelog/utils/keys"
|
|
3
|
+
import { mergeAttributes, Node, textblockTypeInputRule } from "@tiptap/core"
|
|
4
|
+
|
|
5
|
+
import { changeLevelAttr } from "./commands/changeLevelAttr.js"
|
|
6
|
+
import type { HeadingNodeOptions } from "./types.js"
|
|
7
|
+
|
|
8
|
+
declare module "@tiptap/core" {
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11
|
+
interface Commands<ReturnType> {
|
|
12
|
+
heading: {
|
|
13
|
+
setHeading: (opts: {
|
|
14
|
+
level: HeadingNodeOptions["levels"][number]
|
|
15
|
+
onlyHeading: boolean
|
|
16
|
+
}, pos?: number) => ReturnType
|
|
17
|
+
toggleHeading: (opts: {
|
|
18
|
+
level: HeadingNodeOptions["levels"][number]
|
|
19
|
+
}) => ReturnType
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Like tiptap's Heading extension, but makes it easier to configure per-level html attributes.
|
|
26
|
+
*
|
|
27
|
+
* Also the setHeading command has an option to only change the heading level if the text is already a heading.
|
|
28
|
+
*
|
|
29
|
+
* This is useful for when you want to change the heading level of a heading that is already in the document.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// am not just extending because that drag's in tiptap's heading commands interface
|
|
33
|
+
// and these commands have different signatures
|
|
34
|
+
// it's less painful to just re-write
|
|
35
|
+
// also might need to add heading ids/slugs in the future to make it possible to embed via headings
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
38
|
+
export const Heading = Node.create<HeadingNodeOptions>({
|
|
39
|
+
name: "heading" satisfies NodeHeadingName,
|
|
40
|
+
content: "inline*",
|
|
41
|
+
group: "block",
|
|
42
|
+
defining: true,
|
|
43
|
+
addOptions() {
|
|
44
|
+
return {
|
|
45
|
+
levels: [1, 2, 3, 4, 5, 6],
|
|
46
|
+
HTMLAttributes: {
|
|
47
|
+
class: [
|
|
48
|
+
"text-xl",
|
|
49
|
+
"text-2xl/normal",
|
|
50
|
+
"text-3xl/normal",
|
|
51
|
+
"text-4xl/normal",
|
|
52
|
+
"text-5xl/normal",
|
|
53
|
+
"text-6xl/normal"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
addAttributes() {
|
|
60
|
+
return {
|
|
61
|
+
level: {
|
|
62
|
+
default: 1,
|
|
63
|
+
rendered: false
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
parseHTML() {
|
|
68
|
+
return this.options.levels
|
|
69
|
+
.map((level: HeadingNodeOptions["levels"][number]) => ({
|
|
70
|
+
tag: `h${level}`,
|
|
71
|
+
attrs: { level }
|
|
72
|
+
}))
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
76
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
77
|
+
const level = this.options.levels.includes(node.attrs.level)
|
|
78
|
+
? node.attrs.level
|
|
79
|
+
: this.options.levels[0]
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
82
|
+
const thisFinalHTMLAttributes = { ...this.options.HTMLAttributes }
|
|
83
|
+
for (const key of keys(thisFinalHTMLAttributes)) {
|
|
84
|
+
if (isArray(thisFinalHTMLAttributes[key])) {
|
|
85
|
+
thisFinalHTMLAttributes[key] = thisFinalHTMLAttributes[key][level - 1]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [
|
|
89
|
+
`h${level}`,
|
|
90
|
+
mergeAttributes(
|
|
91
|
+
thisFinalHTMLAttributes,
|
|
92
|
+
HTMLAttributes,
|
|
93
|
+
{
|
|
94
|
+
level
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
0
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
addCommands() {
|
|
101
|
+
return {
|
|
102
|
+
setHeading: changeLevelAttr({
|
|
103
|
+
attributeKey: "level",
|
|
104
|
+
nodeType: this.type.name,
|
|
105
|
+
allowedValues: this.options.levels,
|
|
106
|
+
toggleGroups: ["block"]
|
|
107
|
+
}),
|
|
108
|
+
toggleHeading: ({ level = 1 }: { level: number }) => ({ commands }) => {
|
|
109
|
+
if (!this.options.levels.includes(level as any)) {
|
|
110
|
+
return false
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return commands.toggleNode(this.name, "paragraph", { level })
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
addInputRules() {
|
|
118
|
+
// taken from tiptap-extension-heading
|
|
119
|
+
return this.options.levels.map(level => textblockTypeInputRule({
|
|
120
|
+
find: new RegExp(`^(#{1,${level}})\\s$`),
|
|
121
|
+
type: this.type,
|
|
122
|
+
getAttributes: {
|
|
123
|
+
level
|
|
124
|
+
}
|
|
125
|
+
}))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
export type NodeHeadingName = "heading"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Command, getNodeType } from "@tiptap/core"
|
|
2
|
+
|
|
3
|
+
import type { CommandAttributeOptions, CommandToggleNodesOptions } from "../../../../types/index.js"
|
|
4
|
+
import { findUpwards } from "../../../utils/findUpwards.js"
|
|
5
|
+
import { createNodeTypesList } from "../../../utils/internal/createNodeTypesList.js"
|
|
6
|
+
|
|
7
|
+
declare module "@tiptap/core" {
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
changeLevelAttr: {
|
|
12
|
+
changeLevelAttr: (opts: {
|
|
13
|
+
level: number
|
|
14
|
+
onlyHeading: boolean
|
|
15
|
+
}, pos?: number) => ReturnType
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const changeLevelAttr = ({
|
|
21
|
+
nodeType,
|
|
22
|
+
allowedValues,
|
|
23
|
+
attributeKey,
|
|
24
|
+
toggleGroups,
|
|
25
|
+
toggleNodeTypeNames
|
|
26
|
+
}: CommandAttributeOptions<number>
|
|
27
|
+
& CommandToggleNodesOptions
|
|
28
|
+
) =>
|
|
29
|
+
({
|
|
30
|
+
level,
|
|
31
|
+
onlyHeadings = false
|
|
32
|
+
}: {
|
|
33
|
+
level: number
|
|
34
|
+
onlyHeadings?: boolean
|
|
35
|
+
}, pos?: number): Command =>
|
|
36
|
+
({ state, commands, tr, editor }) => {
|
|
37
|
+
if (!allowedValues.includes(level)) { return false }
|
|
38
|
+
const nodeTypes = createNodeTypesList(
|
|
39
|
+
editor.schema,
|
|
40
|
+
[nodeType],
|
|
41
|
+
onlyHeadings ? undefined : toggleNodeTypeNames,
|
|
42
|
+
onlyHeadings ? undefined : toggleGroups
|
|
43
|
+
)
|
|
44
|
+
const nodeTypeType = getNodeType(nodeType, editor.schema)
|
|
45
|
+
const from = pos ?? state.selection.map(tr.doc, tr.mapping).from
|
|
46
|
+
|
|
47
|
+
const nodePos = findUpwards(tr.doc, from, $pos => {
|
|
48
|
+
if (nodeTypes.includes($pos.node().type.name)) {
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
return false
|
|
52
|
+
})?.$pos?.pos
|
|
53
|
+
if (!nodePos) return false
|
|
54
|
+
return commands.setNode(nodeTypeType, { [`${attributeKey}`]: level }, nodePos - 1)
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface HeadingNodeOptions<T extends number[] = [1, 2, 3, 4, 5, 6]> {
|
|
2
|
+
/**
|
|
3
|
+
* The available heading levels.
|
|
4
|
+
*/
|
|
5
|
+
levels: T
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The HTML attributes for the heading node.
|
|
9
|
+
*
|
|
10
|
+
* Each value can also be an array of values for each heading level.
|
|
11
|
+
*
|
|
12
|
+
* The default adds tailwind text size classes.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
HTMLAttributes: Record<string, any>
|
|
17
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { keys } from "@alanscodelog/utils/keys"
|
|
2
|
+
import {
|
|
3
|
+
Mark,
|
|
4
|
+
markInputRule,
|
|
5
|
+
markPasteRule,
|
|
6
|
+
mergeAttributes
|
|
7
|
+
} from "@tiptap/core"
|
|
8
|
+
import { Plugin } from "@tiptap/pm/state"
|
|
9
|
+
|
|
10
|
+
import { inputRegex, pasteRegex } from "./retyped/tiptapHighlight.js"
|
|
11
|
+
import { type HighlightMarkOptions, highlightPluginKey } from "./types.js"
|
|
12
|
+
|
|
13
|
+
import { createStateOnlyPluginObjApply } from "../../utils/createStateOnlyPluginObjApply.js"
|
|
14
|
+
|
|
15
|
+
declare module "@tiptap/core" {
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18
|
+
interface Commands<ReturnType> {
|
|
19
|
+
highlight: {
|
|
20
|
+
/**
|
|
21
|
+
* Set a highlight mark.
|
|
22
|
+
*
|
|
23
|
+
* The color must be one of the keys in the configured `colors` option or it will throw an error.
|
|
24
|
+
*
|
|
25
|
+
* If no color is provided, the default color will be used.
|
|
26
|
+
*/
|
|
27
|
+
setHighlight: (color?: keyof HighlightMarkOptions["colors"]) => ReturnType
|
|
28
|
+
/**
|
|
29
|
+
* Toggle a highlight mark.
|
|
30
|
+
*
|
|
31
|
+
* The color must be one of the keys in the configured `colors` option or it will throw an error.
|
|
32
|
+
*
|
|
33
|
+
* If no color is provided, the default color will be used.
|
|
34
|
+
*/
|
|
35
|
+
toggleHighlight: (color?: keyof HighlightMarkOptions["colors"]) => ReturnType
|
|
36
|
+
/**
|
|
37
|
+
* Unset a highlight mark.
|
|
38
|
+
*/
|
|
39
|
+
unsetHighlight: () => ReturnType
|
|
40
|
+
/**
|
|
41
|
+
* Set the highlight options.
|
|
42
|
+
*
|
|
43
|
+
* Note that you will need to keep the same keys to avoid having to manually migrate the doc. You can add more keys, but again, not remove any without having to migrate the doc. That's why they are named slot* by default, to avoid tight coupling with colors.
|
|
44
|
+
*/
|
|
45
|
+
setHighlightOptions: (options: Partial<HighlightMarkOptions>) => ReturnType
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const defaultColors = {
|
|
51
|
+
slot1: {
|
|
52
|
+
name: "Yellow",
|
|
53
|
+
color: "rgba(255, 234, 54, 0.5)",
|
|
54
|
+
matches: ["#ffff00", "yellow"]
|
|
55
|
+
},
|
|
56
|
+
slot2: {
|
|
57
|
+
name: "Orange",
|
|
58
|
+
color: "rgba(255, 132, 0, 0.5)",
|
|
59
|
+
matches: ["#ffa500", "orange"]
|
|
60
|
+
},
|
|
61
|
+
slot3: {
|
|
62
|
+
name: "Red",
|
|
63
|
+
color: "rgba(255, 0, 0, 0.5)",
|
|
64
|
+
matches: ["#ff0000", "red"]
|
|
65
|
+
},
|
|
66
|
+
slot4: {
|
|
67
|
+
name: "Green",
|
|
68
|
+
color: "rgba(70, 177, 0, 0.5)",
|
|
69
|
+
matches: ["#008000", "green"]
|
|
70
|
+
},
|
|
71
|
+
slot5: {
|
|
72
|
+
name: "Blue",
|
|
73
|
+
color: "rgba(0, 101, 255, 0.5)",
|
|
74
|
+
matches: ["#0000ff", "blue"]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* For highlighting text with pre-configured colors.
|
|
80
|
+
*
|
|
81
|
+
* Colors can be changed on the fly using setHighlightOptions.
|
|
82
|
+
*
|
|
83
|
+
* The Commands feature includes a HighlightIcon component designed to work with this extension. It's included in the CommandBar menu by default.
|
|
84
|
+
*
|
|
85
|
+
* See also `createToggleHighlightCommand` in commandBarMenuItems.ts for creating a custom number of commands with custom prefixes if needed.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
89
|
+
export const Highlight = Mark.create<HighlightMarkOptions>({
|
|
90
|
+
name: "highlight" satisfies MarkHighlightName,
|
|
91
|
+
addOptions() {
|
|
92
|
+
return {
|
|
93
|
+
defaultColor: "slot1",
|
|
94
|
+
colors: defaultColors,
|
|
95
|
+
HTMLAttributes: {}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
addAttributes() {
|
|
100
|
+
return {
|
|
101
|
+
color: {
|
|
102
|
+
default: null,
|
|
103
|
+
parseHTML: element => {
|
|
104
|
+
const color = element.getAttribute("data-color")
|
|
105
|
+
// <mark data-color="slot1"></mark>
|
|
106
|
+
if (color && color in this.options.colors) {
|
|
107
|
+
return color
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// <mark style="background-color: yellow"></mark>
|
|
111
|
+
const bgColor = element.style.backgroundColor
|
|
112
|
+
// attempt to match against the color (unlikely) or alternative matches
|
|
113
|
+
const foundSimilar = keys(this.options.colors).find(key => {
|
|
114
|
+
const c = this.options.colors[key]
|
|
115
|
+
if (
|
|
116
|
+
c.color === color
|
|
117
|
+
|| (color && c.matches?.includes(color))
|
|
118
|
+
|| c.color === bgColor
|
|
119
|
+
|| c.matches?.includes(bgColor)
|
|
120
|
+
) return true
|
|
121
|
+
return false
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
if (foundSimilar) {
|
|
125
|
+
return foundSimilar
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (color) {
|
|
129
|
+
return this.options.defaultColor
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return false
|
|
133
|
+
},
|
|
134
|
+
renderHTML: attributes => {
|
|
135
|
+
const color = attributes.color as keyof HighlightMarkOptions["colors"]
|
|
136
|
+
// is this even possible? it was in the original tiptap code
|
|
137
|
+
if (!color) {
|
|
138
|
+
return {}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const finalColor = this.options.colors[color]
|
|
142
|
+
return {
|
|
143
|
+
"data-color": finalColor.color,
|
|
144
|
+
style: `background-color: ${finalColor.color}; color: inherit`
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
parseHTML() {
|
|
152
|
+
return [
|
|
153
|
+
{
|
|
154
|
+
tag: "mark"
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
160
|
+
renderHTML({ HTMLAttributes }) {
|
|
161
|
+
return ["mark", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
addCommands() {
|
|
165
|
+
return {
|
|
166
|
+
setHighlightOptions: (options: Partial<HighlightMarkOptions>) => ({ tr, dispatch }) => {
|
|
167
|
+
if (dispatch) {
|
|
168
|
+
tr.setMeta(highlightPluginKey, {
|
|
169
|
+
...options,
|
|
170
|
+
colors: (options.colors ? { ...options.colors } : undefined)
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
return true
|
|
174
|
+
},
|
|
175
|
+
setHighlight: color => ({ commands }) => {
|
|
176
|
+
if (color === undefined) {
|
|
177
|
+
return commands.setMark(this.name, { color: this.options.defaultColor })
|
|
178
|
+
}
|
|
179
|
+
if (color in this.options.colors) {
|
|
180
|
+
return commands.setMark(this.name, { color })
|
|
181
|
+
} else {
|
|
182
|
+
// typescript eslint is drunk, color is not an object
|
|
183
|
+
throw new Error(`Color ${color as string} not found in the Highlight options.`)
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
toggleHighlight: color => ({ commands }) => {
|
|
187
|
+
if (color === undefined) {
|
|
188
|
+
return commands.toggleMark(this.name, { color: this.options.defaultColor })
|
|
189
|
+
}
|
|
190
|
+
if (color in this.options.colors) {
|
|
191
|
+
return commands.toggleMark(this.name, { color })
|
|
192
|
+
} else {
|
|
193
|
+
throw new Error(`Color ${color as string} not found in the Highlight options.`)
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
unsetHighlight: () => ({ commands }) => commands.unsetMark(this.name)
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
addProseMirrorPlugins() {
|
|
200
|
+
const self = this
|
|
201
|
+
return [
|
|
202
|
+
new Plugin({
|
|
203
|
+
key: highlightPluginKey,
|
|
204
|
+
state: {
|
|
205
|
+
init() {
|
|
206
|
+
return {
|
|
207
|
+
...self.options,
|
|
208
|
+
colors: { ...self.options.colors }
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
apply: createStateOnlyPluginObjApply(highlightPluginKey)
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
addInputRules() {
|
|
217
|
+
return [
|
|
218
|
+
markInputRule({
|
|
219
|
+
find: inputRegex,
|
|
220
|
+
type: this.type
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
addPasteRules() {
|
|
226
|
+
return [
|
|
227
|
+
markPasteRule({
|
|
228
|
+
find: pasteRegex,
|
|
229
|
+
type: this.type
|
|
230
|
+
})
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
export type MarkHighlightName = "highlight"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PluginKey } from "@tiptap/pm/state"
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributesOptions } from "../../../types/index.js"
|
|
4
|
+
|
|
5
|
+
export interface HighlightMarkOptions<T extends string = `slot${[1, 2, 3, 4, 5][number]}`> extends HTMLAttributesOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The colors to use for the highlight in Record<name, {color: string, name: string}> format.
|
|
8
|
+
*
|
|
9
|
+
* This is to allow the colors/slots to be configurable by the user without needing to change the document when they do so since only the key is stored.
|
|
10
|
+
*
|
|
11
|
+
* The value is a record to allow additional properties to be stored.
|
|
12
|
+
*
|
|
13
|
+
* The `matches` property can be used to specify an additional array of strings/colors to match when parsing HTML.
|
|
14
|
+
*
|
|
15
|
+
* The default is Record<"slotX", {color: "rgbaa(...)", name: "colorName", matches?: [name, "#color"]}>
|
|
16
|
+
*/
|
|
17
|
+
colors: Record<T, { color: string, name: string, matches?: string[] }>
|
|
18
|
+
/**
|
|
19
|
+
* For when a non-matching color is found in the HTML. Default is slot1 which is yellow.
|
|
20
|
+
*/
|
|
21
|
+
defaultColor: T
|
|
22
|
+
}
|
|
23
|
+
export const highlightPluginKey = new PluginKey<{
|
|
24
|
+
colors: HighlightMarkOptions["colors"]
|
|
25
|
+
}>("highlightPluginKey")
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Command, Dispatch, Extension } from "@tiptap/core"
|
|
2
|
+
import TipTapHistoryExtension from "@tiptap/extension-history"
|
|
3
|
+
import { history, redo, undo } from "@tiptap/pm/history"
|
|
4
|
+
import { type EditorState, Plugin, PluginKey, type Transaction } from "@tiptap/pm/state"
|
|
5
|
+
|
|
6
|
+
declare module "@tiptap/core" {
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
historyExtended: {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Set the functions needed to forward history commands.
|
|
14
|
+
*
|
|
15
|
+
* Set to null to disable. Should be set to null before destroying the editor.
|
|
16
|
+
*/
|
|
17
|
+
setHistoryRedirect: (
|
|
18
|
+
redirectState?: () => EditorState | undefined,
|
|
19
|
+
redirectDispatch?: Dispatch
|
|
20
|
+
) => ReturnType
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module "@tiptap/extension-history" {
|
|
26
|
+
interface HistoryOptions {
|
|
27
|
+
/**
|
|
28
|
+
* If set, undo and redo will be forwarded to the editor this function returns instead of the current one. This makes handling embedded editors easier.
|
|
29
|
+
*
|
|
30
|
+
* This is a function so as to make it easier to always get the latest state.
|
|
31
|
+
*/
|
|
32
|
+
redirectState?: () => EditorState | undefined
|
|
33
|
+
/**
|
|
34
|
+
* Required if redirectState is set. Tells the extension how to forward the transactions.
|
|
35
|
+
*/
|
|
36
|
+
redirectDispatch?: Dispatch
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const filterKey = "filterForHistoryForwarding"
|
|
41
|
+
/**
|
|
42
|
+
* Extends the existing history extension to allow for forwarding of history for embedded editors.
|
|
43
|
+
*
|
|
44
|
+
* The embedded editor node view will take care of
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
48
|
+
export const History = (TipTapHistoryExtension as any as Extension /* vue-tsc issue */).extend({
|
|
49
|
+
name: "history",
|
|
50
|
+
addOptions() {
|
|
51
|
+
return {
|
|
52
|
+
depth: 100,
|
|
53
|
+
newGroupDelay: 500,
|
|
54
|
+
redirectState: undefined,
|
|
55
|
+
redirectDispatch: undefined
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
addCommands() {
|
|
60
|
+
return {
|
|
61
|
+
undo: (): Command => ({ state, dispatch, tr }) => {
|
|
62
|
+
const redirectState = this.options.redirectState?.()
|
|
63
|
+
const redirectDispatch = dispatch && this.options.redirectDispatch
|
|
64
|
+
if (redirectState) {
|
|
65
|
+
// commands create transactions whether we return true or not
|
|
66
|
+
// and because we apply our own transaction before the command ends
|
|
67
|
+
// it thinks there is a state mismatch when it tries to apply the
|
|
68
|
+
// command transaction
|
|
69
|
+
// so we use the plugin to filter it out
|
|
70
|
+
if (dispatch) {
|
|
71
|
+
tr.setMeta(filterKey, true)
|
|
72
|
+
}
|
|
73
|
+
return undo(redirectState, redirectDispatch)
|
|
74
|
+
} else {
|
|
75
|
+
return undo(state, dispatch)
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
redo: (): Command => ({ state, dispatch, tr }) => {
|
|
79
|
+
const redirectState = this.options.redirectState?.()
|
|
80
|
+
const redirectDispatch = this.options.redirectDispatch
|
|
81
|
+
if (redirectState) {
|
|
82
|
+
tr.setMeta(filterKey, true)
|
|
83
|
+
redo(redirectState, redirectDispatch)
|
|
84
|
+
return true
|
|
85
|
+
} else {
|
|
86
|
+
return redo(state, dispatch)
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
setHistoryRedirect: (redirectState?: () => EditorState | undefined, redirectDispatch?: Dispatch): Command => ({ dispatch }) => {
|
|
90
|
+
if (dispatch) {
|
|
91
|
+
this.options.redirectState = redirectState
|
|
92
|
+
this.options.redirectDispatch = redirectDispatch
|
|
93
|
+
}
|
|
94
|
+
return true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
addProseMirrorPlugins() {
|
|
99
|
+
return [
|
|
100
|
+
history(this.options),
|
|
101
|
+
new Plugin({
|
|
102
|
+
key: new PluginKey("history-forwarding"),
|
|
103
|
+
filterTransaction: (transaction: Transaction) => {
|
|
104
|
+
if (transaction.getMeta(filterKey)) {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
return true
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
})
|