@blocknote/core 0.17.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +2774 -1804
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +27 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +99 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +97 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +88 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +116 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +106 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +57 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +43 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +27 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +29 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +157 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +27 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +64 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +145 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +252 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/insertContentAt.js +64 -0
- package/dist/src/api/blockManipulation/insertContentAt.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +76 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +33 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +1 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js +172 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +1 -0
- package/dist/src/api/clipboard/clipboard.test.js +246 -0
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +8 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +38 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +109 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +26 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +57 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +132 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js +35 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +1 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js +72 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +1 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +21 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +141 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +96 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js +31 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +57 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +1 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +33 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +1 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +37 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +1 -0
- package/dist/src/api/getBlockInfoFromPos.js +171 -0
- package/dist/src/api/getBlockInfoFromPos.js.map +1 -0
- package/dist/src/api/nodeConversions/blockToNode.js +197 -0
- package/dist/src/api/nodeConversions/blockToNode.js.map +1 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +50 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js +54 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js +316 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +1 -0
- package/dist/src/api/nodeUtil.js +28 -0
- package/dist/src/api/nodeUtil.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.js +19 -0
- package/dist/src/api/parsers/html/parseHTML.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.test.js +470 -0
- package/dist/src/api/parsers/html/parseHTML.test.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.js +106 -0
- package/dist/src/api/parsers/html/util/nestedLists.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js +166 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js +52 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +109 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -0
- package/dist/src/api/testUtil/cases/customBlocks.js +313 -0
- package/dist/src/api/testUtil/cases/customBlocks.js.map +1 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js +91 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +1 -0
- package/dist/src/api/testUtil/cases/customStyles.js +83 -0
- package/dist/src/api/testUtil/cases/customStyles.js.map +1 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js +673 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +1 -0
- package/dist/src/api/testUtil/index.js +2 -0
- package/dist/src/api/testUtil/index.js.map +1 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js +114 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +1 -0
- package/dist/src/api/testUtil/paste.js +29 -0
- package/dist/src/api/testUtil/paste.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +97 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +5 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +273 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +90 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +70 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +317 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +15 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +1 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +141 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +106 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +6 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +111 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +218 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +41 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +58 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +128 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +51 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +130 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +57 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +103 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +6 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockHelpers.js +50 -0
- package/dist/src/blocks/defaultBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js +40 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +1 -0
- package/dist/src/blocks/defaultBlocks.js +50 -0
- package/dist/src/blocks/defaultBlocks.js.map +1 -0
- package/dist/src/blocks/defaultProps.js +19 -0
- package/dist/src/blocks/defaultProps.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +750 -0
- package/dist/src/editor/BlockNoteEditor.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.test.js +65 -0
- package/dist/src/editor/BlockNoteEditor.test.js.map +1 -0
- package/dist/src/editor/BlockNoteExtensions.js +149 -0
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -0
- package/dist/src/editor/BlockNoteSchema.js +38 -0
- package/dist/src/editor/BlockNoteSchema.js.map +1 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js +169 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +1 -0
- package/dist/src/editor/cursorPositionTypes.js +2 -0
- package/dist/src/editor/cursorPositionTypes.js.map +1 -0
- package/dist/src/editor/defaultColors.js +77 -0
- package/dist/src/editor/defaultColors.js.map +1 -0
- package/dist/src/editor/selectionTypes.js +2 -0
- package/dist/src/editor/selectionTypes.js.map +1 -0
- package/dist/src/editor/transformPasted.js +79 -0
- package/dist/src/editor/transformPasted.js.map +1 -0
- package/dist/src/exporter/Exporter.js +36 -0
- package/dist/src/exporter/Exporter.js.map +1 -0
- package/dist/src/exporter/index.js +3 -0
- package/dist/src/exporter/index.js.map +1 -0
- package/dist/src/exporter/mapping.js +12 -0
- package/dist/src/exporter/mapping.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +30 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +39 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +1 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +131 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +1 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +195 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +309 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +247 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +51 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +81 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +183 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +68 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +1 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +339 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/dragging.js +128 -0
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +245 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +26 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +244 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +1 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +553 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +36 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js +29 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorMark.js +37 -0
- package/dist/src/extensions/TextColor/TextColorMark.js.map +1 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +58 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +1 -0
- package/dist/src/extensions/UniqueID/UniqueID.js +283 -0
- package/dist/src/extensions/UniqueID/UniqueID.js.map +1 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js +13 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +1 -0
- package/dist/src/extensions-shared/UiElementPosition.js +2 -0
- package/dist/src/extensions-shared/UiElementPosition.js.map +1 -0
- package/dist/src/i18n/dictionary.js +4 -0
- package/dist/src/i18n/dictionary.js.map +1 -0
- package/dist/src/i18n/locales/ar.js +298 -0
- package/dist/src/i18n/locales/ar.js.map +1 -0
- package/dist/src/i18n/locales/de.js +313 -0
- package/dist/src/i18n/locales/de.js.map +1 -0
- package/dist/src/i18n/locales/en.js +314 -0
- package/dist/src/i18n/locales/en.js.map +1 -0
- package/dist/src/i18n/locales/es.js +312 -0
- package/dist/src/i18n/locales/es.js.map +1 -0
- package/dist/src/i18n/locales/fr.js +313 -0
- package/dist/src/i18n/locales/fr.js.map +1 -0
- package/dist/src/i18n/locales/hr.js +308 -0
- package/dist/src/i18n/locales/hr.js.map +1 -0
- package/dist/src/i18n/locales/index.js +16 -0
- package/dist/src/i18n/locales/index.js.map +1 -0
- package/dist/src/i18n/locales/is.js +305 -0
- package/dist/src/i18n/locales/is.js.map +1 -0
- package/dist/src/i18n/locales/ja.js +333 -0
- package/dist/src/i18n/locales/ja.js.map +1 -0
- package/dist/src/i18n/locales/ko.js +326 -0
- package/dist/src/i18n/locales/ko.js.map +1 -0
- package/dist/src/i18n/locales/nl.js +313 -0
- package/dist/src/i18n/locales/nl.js.map +1 -0
- package/dist/src/i18n/locales/pl.js +297 -0
- package/dist/src/i18n/locales/pl.js.map +1 -0
- package/dist/src/i18n/locales/pt.js +305 -0
- package/dist/src/i18n/locales/pt.js.map +1 -0
- package/dist/src/i18n/locales/ru.js +340 -0
- package/dist/src/i18n/locales/ru.js.map +1 -0
- package/dist/src/i18n/locales/vi.js +312 -0
- package/dist/src/i18n/locales/vi.js.map +1 -0
- package/dist/src/i18n/locales/zh.js +346 -0
- package/dist/src/i18n/locales/zh.js.map +1 -0
- package/dist/src/index.js +55 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pm-nodes/BlockContainer.js +72 -0
- package/dist/src/pm-nodes/BlockContainer.js.map +1 -0
- package/dist/src/pm-nodes/BlockGroup.js +43 -0
- package/dist/src/pm-nodes/BlockGroup.js.map +1 -0
- package/dist/src/pm-nodes/Doc.js +7 -0
- package/dist/src/pm-nodes/Doc.js.map +1 -0
- package/dist/src/pm-nodes/index.js +4 -0
- package/dist/src/pm-nodes/index.js.map +1 -0
- package/dist/src/schema/blocks/createSpec.js +126 -0
- package/dist/src/schema/blocks/createSpec.js.map +1 -0
- package/dist/src/schema/blocks/internal.js +147 -0
- package/dist/src/schema/blocks/internal.js.map +1 -0
- package/dist/src/schema/blocks/types.js +2 -0
- package/dist/src/schema/blocks/types.js.map +1 -0
- package/dist/src/schema/index.js +11 -0
- package/dist/src/schema/index.js.map +1 -0
- package/dist/src/schema/inlineContent/createSpec.js +64 -0
- package/dist/src/schema/inlineContent/createSpec.js.map +1 -0
- package/dist/src/schema/inlineContent/internal.js +52 -0
- package/dist/src/schema/inlineContent/internal.js.map +1 -0
- package/dist/src/schema/inlineContent/types.js +10 -0
- package/dist/src/schema/inlineContent/types.js.map +1 -0
- package/dist/src/schema/propTypes.js +2 -0
- package/dist/src/schema/propTypes.js.map +1 -0
- package/dist/src/schema/styles/createSpec.js +48 -0
- package/dist/src/schema/styles/createSpec.js.map +1 -0
- package/dist/src/schema/styles/internal.js +53 -0
- package/dist/src/schema/styles/internal.js.map +1 -0
- package/dist/src/schema/styles/types.js +2 -0
- package/dist/src/schema/styles/types.js.map +1 -0
- package/dist/src/util/EventEmitter.js +33 -0
- package/dist/src/util/EventEmitter.js.map +1 -0
- package/dist/src/util/browser.js +17 -0
- package/dist/src/util/browser.js.map +1 -0
- package/dist/src/util/combineByGroup.js +20 -0
- package/dist/src/util/combineByGroup.js.map +1 -0
- package/dist/src/util/esmDependencies.js +35 -0
- package/dist/src/util/esmDependencies.js.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/typescript.js +12 -0
- package/dist/src/util/typescript.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/webpack-stats.json +1 -1
- package/package.json +9 -7
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +30 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +25 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +2 -2
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +104 -39
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +40 -0
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +3 -5
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +100 -0
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +10 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +40 -0
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +30 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +11 -7
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +87 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +5 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +192 -107
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +48 -33
- package/src/api/clipboard/clipboard.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -0
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +49 -0
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/python/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/table/allColWidths/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html +1 -0
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/internalHTMLSerializer.ts +2 -7
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +75 -33
- package/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/codeBlock/python/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/table/allColWidths/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/table/basic/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/table/mixedColWidths/markdown.md +5 -0
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +113 -58
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +711 -0
- package/src/api/nodeConversions/blockToNode.ts +62 -26
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +35 -22
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +5 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/testUtil/cases/defaultSchema.ts +95 -0
- package/src/api/testUtil/partialBlockTestUtil.ts +41 -4
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +369 -0
- package/src/blocks/CodeBlockContent/defaultSupportedLanguages.ts +96 -0
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +10 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +19 -31
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +5 -9
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +6 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +5 -9
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +4 -8
- package/src/blocks/TableBlockContent/TableBlockContent.ts +83 -8
- package/src/blocks/TableBlockContent/TableExtension.ts +10 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/blocks/defaultBlocks.ts +4 -0
- package/src/editor/Block.css +71 -3
- package/src/editor/BlockNoteEditor.test.ts +2 -2
- package/src/editor/BlockNoteEditor.ts +18 -21
- package/src/editor/BlockNoteExtensions.ts +2 -3
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +43 -5
- package/src/editor/transformPasted.ts +6 -3
- package/src/exporter/Exporter.ts +101 -0
- package/src/exporter/index.ts +2 -0
- package/src/exporter/mapping.ts +75 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +201 -48
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +1 -1
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +5 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +5 -0
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -1
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +22 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +225 -120
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +299 -294
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +310 -274
- package/src/i18n/locales/fr.ts +6 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +10 -4
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +9 -0
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/README.md +127 -28
- package/src/schema/blocks/createSpec.ts +4 -1
- package/src/schema/blocks/internal.ts +12 -2
- package/src/schema/blocks/types.ts +3 -1
- package/src/util/combineByGroup.ts +25 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +22 -2
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +22 -8
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +3 -0
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +2 -3
- package/types/src/api/getBlockInfoFromPos.d.ts +55 -5
- package/types/src/api/nodeConversions/blockToNode.d.ts +1 -1
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +3 -1
- package/types/src/api/testUtil/cases/customBlocks.d.ts +22 -8
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +22 -8
- package/types/src/api/testUtil/cases/customStyles.d.ts +22 -8
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -0
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +57 -0
- package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +1 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +1 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -12
- package/types/src/blocks/TableBlockContent/TableExtension.d.ts +3 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +45 -16
- package/types/src/editor/BlockNoteEditor.d.ts +4 -3
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +1 -0
- package/types/src/editor/defaultColors.d.ts +76 -0
- package/types/src/exporter/Exporter.d.ts +43 -0
- package/types/src/exporter/index.d.ts +2 -0
- package/types/src/exporter/mapping.d.ts +30 -0
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +9 -5
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/i18n/locales/de.d.ts +6 -0
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/es.d.ts +6 -0
- package/types/src/index.d.ts +6 -0
- package/types/src/schema/blocks/createSpec.d.ts +1 -1
- package/types/src/schema/blocks/internal.d.ts +2 -2
- package/types/src/schema/blocks/types.d.ts +3 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Plugin, PluginKey, PluginView } from "prosemirror-state";
|
|
2
2
|
import { Decoration, DecorationSet, EditorView } from "prosemirror-view";
|
|
3
3
|
import { nodeToBlock } from "../../api/nodeConversions/nodeToBlock.js";
|
|
4
|
+
import { getNodeById } from "../../api/nodeUtil.js";
|
|
4
5
|
import { checkBlockIsDefaultType } from "../../blocks/defaultBlockTypeGuards.js";
|
|
5
|
-
import {
|
|
6
|
+
import { DefaultBlockSchema } from "../../blocks/defaultBlocks.js";
|
|
6
7
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
7
8
|
import {
|
|
8
9
|
BlockFromConfigNoChildren,
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
StyleSchema,
|
|
12
13
|
} from "../../schema/index.js";
|
|
13
14
|
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
14
|
-
import { getDraggableBlockFromElement } from "../
|
|
15
|
+
import { getDraggableBlockFromElement } from "../getDraggableBlockFromElement.js";
|
|
15
16
|
|
|
16
17
|
let dragImageElement: HTMLElement | undefined;
|
|
17
18
|
|
|
@@ -20,12 +21,14 @@ export type TableHandlesState<
|
|
|
20
21
|
S extends StyleSchema
|
|
21
22
|
> = {
|
|
22
23
|
show: boolean;
|
|
23
|
-
|
|
24
|
+
showAddOrRemoveRowsButton: boolean;
|
|
25
|
+
showAddOrRemoveColumnsButton: boolean;
|
|
26
|
+
referencePosCell: DOMRect | undefined;
|
|
24
27
|
referencePosTable: DOMRect;
|
|
25
28
|
|
|
26
29
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], I, S>;
|
|
27
|
-
colIndex: number;
|
|
28
|
-
rowIndex: number;
|
|
30
|
+
colIndex: number | undefined;
|
|
31
|
+
rowIndex: number | undefined;
|
|
29
32
|
|
|
30
33
|
draggingState:
|
|
31
34
|
| {
|
|
@@ -34,6 +37,8 @@ export type TableHandlesState<
|
|
|
34
37
|
mousePos: number;
|
|
35
38
|
}
|
|
36
39
|
| undefined;
|
|
40
|
+
|
|
41
|
+
widgetContainer: HTMLElement | undefined;
|
|
37
42
|
};
|
|
38
43
|
|
|
39
44
|
function setHiddenDragImage(rootEl: Document | ShadowRoot) {
|
|
@@ -70,28 +75,45 @@ function getChildIndex(node: Element) {
|
|
|
70
75
|
|
|
71
76
|
// Finds the DOM element corresponding to the table cell that the target element
|
|
72
77
|
// is currently in. If the target element is not in a table cell, returns null.
|
|
73
|
-
function domCellAround(target: Element
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
function domCellAround(target: Element) {
|
|
79
|
+
let currentTarget: Element | undefined = target;
|
|
80
|
+
while (
|
|
81
|
+
currentTarget &&
|
|
82
|
+
currentTarget.nodeName !== "TD" &&
|
|
83
|
+
currentTarget.nodeName !== "TH" &&
|
|
84
|
+
!currentTarget.classList.contains("tableWrapper")
|
|
85
|
+
) {
|
|
86
|
+
if (currentTarget.classList.contains("ProseMirror")) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const parent: ParentNode | null = currentTarget.parentNode;
|
|
90
|
+
|
|
91
|
+
if (!parent || !(parent instanceof Element)) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
currentTarget = parent;
|
|
79
95
|
}
|
|
80
|
-
|
|
96
|
+
|
|
97
|
+
return currentTarget.nodeName === "TD" || currentTarget.nodeName === "TH"
|
|
98
|
+
? {
|
|
99
|
+
type: "cell",
|
|
100
|
+
domNode: currentTarget,
|
|
101
|
+
tbodyNode: currentTarget.closest("tbody"),
|
|
102
|
+
}
|
|
103
|
+
: {
|
|
104
|
+
type: "wrapper",
|
|
105
|
+
domNode: currentTarget,
|
|
106
|
+
tbodyNode: currentTarget.querySelector("tbody"),
|
|
107
|
+
};
|
|
81
108
|
}
|
|
82
109
|
|
|
83
110
|
// Hides elements in the DOMwith the provided class names.
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
for (let i = 0; i < elementsToHide.length; i++) {
|
|
92
|
-
(elementsToHide[i] as HTMLElement).style.visibility = "hidden";
|
|
93
|
-
}
|
|
94
|
-
});
|
|
111
|
+
function hideElements(selector: string, rootEl: Document | ShadowRoot) {
|
|
112
|
+
const elementsToHide = rootEl.querySelectorAll(selector);
|
|
113
|
+
|
|
114
|
+
for (let i = 0; i < elementsToHide.length; i++) {
|
|
115
|
+
(elementsToHide[i] as HTMLElement).style.visibility = "hidden";
|
|
116
|
+
}
|
|
95
117
|
}
|
|
96
118
|
|
|
97
119
|
export class TableHandlesView<
|
|
@@ -104,6 +126,7 @@ export class TableHandlesView<
|
|
|
104
126
|
|
|
105
127
|
public tableId: string | undefined;
|
|
106
128
|
public tablePos: number | undefined;
|
|
129
|
+
public tableElement: HTMLElement | undefined;
|
|
107
130
|
|
|
108
131
|
public menuFrozen = false;
|
|
109
132
|
|
|
@@ -130,25 +153,20 @@ export class TableHandlesView<
|
|
|
130
153
|
|
|
131
154
|
pmView.dom.addEventListener("mousemove", this.mouseMoveHandler);
|
|
132
155
|
pmView.dom.addEventListener("mousedown", this.viewMousedownHandler);
|
|
133
|
-
|
|
156
|
+
window.addEventListener("mouseup", this.mouseUpHandler);
|
|
134
157
|
|
|
135
158
|
pmView.root.addEventListener(
|
|
136
159
|
"dragover",
|
|
137
160
|
this.dragOverHandler as EventListener
|
|
138
161
|
);
|
|
139
162
|
pmView.root.addEventListener("drop", this.dropHandler as EventListener);
|
|
140
|
-
|
|
141
|
-
// Setting capture=true ensures that any parent container of the editor that
|
|
142
|
-
// gets scrolled will trigger the scroll event. Scroll events do not bubble
|
|
143
|
-
// and so won't propagate to the document by default.
|
|
144
|
-
pmView.root.addEventListener("scroll", this.scrollHandler, true);
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
viewMousedownHandler = () => {
|
|
148
166
|
this.mouseState = "down";
|
|
149
167
|
};
|
|
150
168
|
|
|
151
|
-
|
|
169
|
+
mouseUpHandler = (event: MouseEvent) => {
|
|
152
170
|
this.mouseState = "up";
|
|
153
171
|
this.mouseMoveHandler(event);
|
|
154
172
|
};
|
|
@@ -158,100 +176,150 @@ export class TableHandlesView<
|
|
|
158
176
|
return;
|
|
159
177
|
}
|
|
160
178
|
|
|
161
|
-
if (this.mouseState === "
|
|
179
|
+
if (this.mouseState === "selecting") {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (
|
|
184
|
+
!(event.target instanceof Element) ||
|
|
185
|
+
!this.pmView.dom.contains(event.target)
|
|
186
|
+
) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const target = domCellAround(event.target);
|
|
191
|
+
|
|
192
|
+
if (
|
|
193
|
+
target?.type === "cell" &&
|
|
194
|
+
this.mouseState === "down" &&
|
|
195
|
+
!this.state?.draggingState
|
|
196
|
+
) {
|
|
197
|
+
// hide draghandles when selecting text as they could be in the way of the user
|
|
162
198
|
this.mouseState = "selecting";
|
|
163
199
|
|
|
164
200
|
if (this.state?.show) {
|
|
165
201
|
this.state.show = false;
|
|
202
|
+
this.state.showAddOrRemoveRowsButton = false;
|
|
203
|
+
this.state.showAddOrRemoveColumnsButton = false;
|
|
166
204
|
this.emitUpdate();
|
|
167
205
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (this.mouseState === "selecting") {
|
|
171
206
|
return;
|
|
172
207
|
}
|
|
173
208
|
|
|
174
|
-
const target = domCellAround(event.target as HTMLElement);
|
|
175
|
-
|
|
176
209
|
if (!target || !this.editor.isEditable) {
|
|
177
210
|
if (this.state?.show) {
|
|
178
211
|
this.state.show = false;
|
|
212
|
+
this.state.showAddOrRemoveRowsButton = false;
|
|
213
|
+
this.state.showAddOrRemoveColumnsButton = false;
|
|
179
214
|
this.emitUpdate();
|
|
180
215
|
}
|
|
181
216
|
return;
|
|
182
217
|
}
|
|
183
218
|
|
|
184
|
-
|
|
185
|
-
const rowIndex = getChildIndex(target.parentElement!);
|
|
186
|
-
const cellRect = target.getBoundingClientRect();
|
|
187
|
-
const tableRect =
|
|
188
|
-
target.parentElement?.parentElement?.getBoundingClientRect();
|
|
189
|
-
|
|
190
|
-
if (!tableRect) {
|
|
219
|
+
if (!target.tbodyNode) {
|
|
191
220
|
return;
|
|
192
221
|
}
|
|
193
222
|
|
|
194
|
-
const
|
|
223
|
+
const tableRect = target.tbodyNode.getBoundingClientRect();
|
|
224
|
+
|
|
225
|
+
const blockEl = getDraggableBlockFromElement(target.domNode, this.pmView);
|
|
195
226
|
if (!blockEl) {
|
|
196
227
|
return;
|
|
197
228
|
}
|
|
229
|
+
this.tableElement = blockEl.node;
|
|
198
230
|
|
|
199
|
-
let tableBlock:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// node for the table, so we would effectively be doing the same work twice.
|
|
203
|
-
this.editor._tiptapEditor.state.doc.descendants((node, pos) => {
|
|
204
|
-
if (typeof tableBlock !== "undefined") {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (node.type.name !== "blockContainer" || node.attrs.id !== blockEl.id) {
|
|
209
|
-
return true;
|
|
210
|
-
}
|
|
231
|
+
let tableBlock:
|
|
232
|
+
| BlockFromConfigNoChildren<DefaultBlockSchema["table"], I, S>
|
|
233
|
+
| undefined;
|
|
211
234
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.editor.schema.styleSchema,
|
|
217
|
-
this.editor.blockCache
|
|
218
|
-
);
|
|
235
|
+
const pmNodeInfo = getNodeById(
|
|
236
|
+
blockEl.id,
|
|
237
|
+
this.editor._tiptapEditor.state.doc
|
|
238
|
+
);
|
|
219
239
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
240
|
+
const block = nodeToBlock(
|
|
241
|
+
pmNodeInfo.node,
|
|
242
|
+
this.editor.schema.blockSchema,
|
|
243
|
+
this.editor.schema.inlineContentSchema,
|
|
244
|
+
this.editor.schema.styleSchema,
|
|
245
|
+
this.editor.blockCache
|
|
246
|
+
);
|
|
224
247
|
|
|
225
|
-
|
|
226
|
-
|
|
248
|
+
if (checkBlockIsDefaultType("table", block, this.editor)) {
|
|
249
|
+
this.tablePos = pmNodeInfo.posBeforeNode + 1;
|
|
250
|
+
tableBlock = block;
|
|
251
|
+
}
|
|
227
252
|
|
|
228
253
|
if (!tableBlock) {
|
|
229
254
|
return;
|
|
230
255
|
}
|
|
231
256
|
|
|
232
257
|
this.tableId = blockEl.id;
|
|
258
|
+
const widgetContainer = target.domNode
|
|
259
|
+
.closest(".tableWrapper")
|
|
260
|
+
?.querySelector(".table-widgets-container") as HTMLElement;
|
|
261
|
+
|
|
262
|
+
if (target?.type === "wrapper") {
|
|
263
|
+
// if we're just to the right or below the table, show the extend buttons
|
|
264
|
+
// (this is a bit hacky. It would probably be cleaner to render the extend buttons in the Table NodeView instead)
|
|
265
|
+
const belowTable =
|
|
266
|
+
event.clientY >= tableRect.bottom - 1 && // -1 to account for fractions of pixels in "bottom"
|
|
267
|
+
event.clientY < tableRect.bottom + 20;
|
|
268
|
+
const toRightOfTable =
|
|
269
|
+
event.clientX >= tableRect.right - 1 &&
|
|
270
|
+
event.clientX < tableRect.right + 20;
|
|
271
|
+
|
|
272
|
+
// without this check, we'd also hide draghandles when hovering over them
|
|
273
|
+
const hideHandles =
|
|
274
|
+
event.clientX > tableRect.right || event.clientY > tableRect.bottom;
|
|
275
|
+
|
|
276
|
+
this.state = {
|
|
277
|
+
...this.state!,
|
|
278
|
+
show: true,
|
|
279
|
+
showAddOrRemoveRowsButton: belowTable,
|
|
280
|
+
showAddOrRemoveColumnsButton: toRightOfTable,
|
|
281
|
+
referencePosTable: tableRect,
|
|
282
|
+
block: tableBlock,
|
|
283
|
+
widgetContainer,
|
|
284
|
+
colIndex: hideHandles ? undefined : this.state!.colIndex,
|
|
285
|
+
rowIndex: hideHandles ? undefined : this.state!.rowIndex,
|
|
286
|
+
referencePosCell: hideHandles
|
|
287
|
+
? undefined
|
|
288
|
+
: this.state!.referencePosCell,
|
|
289
|
+
};
|
|
290
|
+
} else {
|
|
291
|
+
const colIndex = getChildIndex(target.domNode);
|
|
292
|
+
const rowIndex = getChildIndex(target.domNode.parentElement!);
|
|
293
|
+
const cellRect = target.domNode.getBoundingClientRect();
|
|
294
|
+
|
|
295
|
+
if (
|
|
296
|
+
this.state !== undefined &&
|
|
297
|
+
this.state.show &&
|
|
298
|
+
this.tableId === blockEl.id &&
|
|
299
|
+
this.state.rowIndex === rowIndex &&
|
|
300
|
+
this.state.colIndex === colIndex
|
|
301
|
+
) {
|
|
302
|
+
// no update needed
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
233
305
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
306
|
+
this.state = {
|
|
307
|
+
show: true,
|
|
308
|
+
showAddOrRemoveColumnsButton:
|
|
309
|
+
colIndex === tableBlock.content.rows[0].cells.length - 1,
|
|
310
|
+
showAddOrRemoveRowsButton:
|
|
311
|
+
rowIndex === tableBlock.content.rows.length - 1,
|
|
312
|
+
referencePosTable: tableRect,
|
|
313
|
+
|
|
314
|
+
block: tableBlock,
|
|
315
|
+
draggingState: undefined,
|
|
316
|
+
referencePosCell: cellRect,
|
|
317
|
+
colIndex: colIndex,
|
|
318
|
+
rowIndex: rowIndex,
|
|
319
|
+
|
|
320
|
+
widgetContainer,
|
|
321
|
+
};
|
|
242
322
|
}
|
|
243
|
-
|
|
244
|
-
this.state = {
|
|
245
|
-
show: true,
|
|
246
|
-
referencePosCell: cellRect,
|
|
247
|
-
referencePosTable: tableRect,
|
|
248
|
-
|
|
249
|
-
block: tableBlock,
|
|
250
|
-
colIndex: colIndex,
|
|
251
|
-
rowIndex: rowIndex,
|
|
252
|
-
|
|
253
|
-
draggingState: undefined,
|
|
254
|
-
};
|
|
255
323
|
this.emitUpdate();
|
|
256
324
|
|
|
257
325
|
return false;
|
|
@@ -265,12 +333,8 @@ export class TableHandlesView<
|
|
|
265
333
|
event.preventDefault();
|
|
266
334
|
event.dataTransfer!.dropEffect = "move";
|
|
267
335
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
"column-resize-handle",
|
|
271
|
-
"prosemirror-dropcursor-block",
|
|
272
|
-
"prosemirror-dropcursor-inline",
|
|
273
|
-
],
|
|
336
|
+
hideElements(
|
|
337
|
+
".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",
|
|
274
338
|
this.pmView.root
|
|
275
339
|
);
|
|
276
340
|
|
|
@@ -358,25 +422,37 @@ export class TableHandlesView<
|
|
|
358
422
|
};
|
|
359
423
|
|
|
360
424
|
dropHandler = (event: DragEvent) => {
|
|
425
|
+
this.mouseState = "up";
|
|
361
426
|
if (this.state === undefined || this.state.draggingState === undefined) {
|
|
362
427
|
return;
|
|
363
428
|
}
|
|
364
429
|
|
|
430
|
+
if (
|
|
431
|
+
this.state.rowIndex === undefined ||
|
|
432
|
+
this.state.colIndex === undefined
|
|
433
|
+
) {
|
|
434
|
+
throw new Error(
|
|
435
|
+
"Attempted to drop table row or column, but no table block was hovered prior."
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
365
439
|
event.preventDefault();
|
|
366
440
|
|
|
441
|
+
const { draggingState, colIndex, rowIndex } = this.state;
|
|
442
|
+
|
|
367
443
|
const rows = this.state.block.content.rows;
|
|
368
444
|
|
|
369
|
-
if (
|
|
370
|
-
const rowToMove = rows[
|
|
371
|
-
rows.splice(
|
|
372
|
-
rows.splice(
|
|
445
|
+
if (draggingState.draggedCellOrientation === "row") {
|
|
446
|
+
const rowToMove = rows[draggingState.originalIndex];
|
|
447
|
+
rows.splice(draggingState.originalIndex, 1);
|
|
448
|
+
rows.splice(rowIndex, 0, rowToMove);
|
|
373
449
|
} else {
|
|
374
450
|
const cellsToMove = rows.map(
|
|
375
|
-
(row) => row.cells[
|
|
451
|
+
(row) => row.cells[draggingState.originalIndex]
|
|
376
452
|
);
|
|
377
453
|
rows.forEach((row, rowIndex) => {
|
|
378
|
-
row.cells.splice(
|
|
379
|
-
row.cells.splice(
|
|
454
|
+
row.cells.splice(draggingState.originalIndex, 1);
|
|
455
|
+
row.cells.splice(colIndex, 0, cellsToMove[rowIndex]);
|
|
380
456
|
});
|
|
381
457
|
}
|
|
382
458
|
|
|
@@ -392,26 +468,45 @@ export class TableHandlesView<
|
|
|
392
468
|
// the existing selection out of the block.
|
|
393
469
|
this.editor.setTextCursorPosition(this.state.block.id);
|
|
394
470
|
};
|
|
471
|
+
// Updates drag handle positions on table content updates.
|
|
472
|
+
update() {
|
|
473
|
+
if (!this.state || !this.state.show) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
395
476
|
|
|
396
|
-
|
|
397
|
-
if (
|
|
398
|
-
|
|
399
|
-
`[data-node-type="blockContainer"][data-id="${this.tableId}"] table`
|
|
400
|
-
)!;
|
|
401
|
-
const cellElement = tableElement.querySelector(
|
|
402
|
-
`tr:nth-child(${this.state.rowIndex + 1}) > td:nth-child(${
|
|
403
|
-
this.state.colIndex + 1
|
|
404
|
-
})`
|
|
405
|
-
)!;
|
|
406
|
-
|
|
407
|
-
this.state.referencePosTable = tableElement.getBoundingClientRect();
|
|
408
|
-
this.state.referencePosCell = cellElement.getBoundingClientRect();
|
|
409
|
-
this.emitUpdate();
|
|
477
|
+
const tableBody = this.tableElement!.querySelector("tbody");
|
|
478
|
+
if (!tableBody) {
|
|
479
|
+
return;
|
|
410
480
|
}
|
|
411
|
-
|
|
481
|
+
|
|
482
|
+
if (
|
|
483
|
+
this.state.rowIndex !== undefined &&
|
|
484
|
+
this.state.colIndex !== undefined
|
|
485
|
+
) {
|
|
486
|
+
// If rows or columns are deleted in the update, the hovered indices for
|
|
487
|
+
// those may now be out of bounds. If this is the case, they are moved to
|
|
488
|
+
// the new last row or column.
|
|
489
|
+
if (this.state.rowIndex >= tableBody.children.length) {
|
|
490
|
+
this.state.rowIndex = tableBody.children.length - 1;
|
|
491
|
+
}
|
|
492
|
+
if (this.state.colIndex >= tableBody.children[0].children.length) {
|
|
493
|
+
this.state.colIndex = tableBody.children[0].children.length - 1;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const row = tableBody.children[this.state.rowIndex];
|
|
497
|
+
const cell = row.children[this.state.colIndex];
|
|
498
|
+
this.state.referencePosCell = cell.getBoundingClientRect();
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
this.state.block = this.editor.getBlock(this.state.block.id)!;
|
|
502
|
+
this.state.referencePosTable = tableBody.getBoundingClientRect();
|
|
503
|
+
this.emitUpdate();
|
|
504
|
+
}
|
|
412
505
|
|
|
413
506
|
destroy() {
|
|
414
507
|
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
508
|
+
window.removeEventListener("mouseup", this.mouseUpHandler);
|
|
509
|
+
this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler);
|
|
415
510
|
this.pmView.root.removeEventListener(
|
|
416
511
|
"dragover",
|
|
417
512
|
this.dragOverHandler as EventListener
|
|
@@ -420,7 +515,6 @@ export class TableHandlesView<
|
|
|
420
515
|
"drop",
|
|
421
516
|
this.dropHandler as EventListener
|
|
422
517
|
);
|
|
423
|
-
this.pmView.root.removeEventListener("scroll", this.scrollHandler, true);
|
|
424
518
|
}
|
|
425
519
|
}
|
|
426
520
|
|
|
@@ -467,6 +561,10 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
467
561
|
? this.view.state.rowIndex
|
|
468
562
|
: this.view.state.colIndex;
|
|
469
563
|
|
|
564
|
+
if (newIndex === undefined) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
|
|
470
568
|
const decorations: Decoration[] = [];
|
|
471
569
|
|
|
472
570
|
if (newIndex === this.view.state.draggingState.originalIndex) {
|
|
@@ -547,6 +645,7 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
547
645
|
(newIndex > this.view.state.draggingState.originalIndex
|
|
548
646
|
? cellNode.nodeSize - 2
|
|
549
647
|
: 0);
|
|
648
|
+
|
|
550
649
|
decorations.push(
|
|
551
650
|
// The widget is a small bar which spans the height of the cell.
|
|
552
651
|
Decoration.widget(decorationPos, () => {
|
|
@@ -592,7 +691,10 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
592
691
|
dataTransfer: DataTransfer | null;
|
|
593
692
|
clientX: number;
|
|
594
693
|
}) => {
|
|
595
|
-
if (
|
|
694
|
+
if (
|
|
695
|
+
this.view!.state === undefined ||
|
|
696
|
+
this.view!.state.colIndex === undefined
|
|
697
|
+
) {
|
|
596
698
|
throw new Error(
|
|
597
699
|
"Attempted to drag table column, but no table block was hovered prior."
|
|
598
700
|
);
|
|
@@ -628,7 +730,10 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
628
730
|
dataTransfer: DataTransfer | null;
|
|
629
731
|
clientY: number;
|
|
630
732
|
}) => {
|
|
631
|
-
if (
|
|
733
|
+
if (
|
|
734
|
+
this.view!.state === undefined ||
|
|
735
|
+
this.view!.state.rowIndex === undefined
|
|
736
|
+
) {
|
|
632
737
|
throw new Error(
|
|
633
738
|
"Attempted to drag table row, but no table block was hovered prior."
|
|
634
739
|
);
|
|
@@ -62,7 +62,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
|
|
|
62
62
|
lastNode = lastNode.lastChild;
|
|
63
63
|
|
|
64
64
|
if (!lastNode || lastNode.type.name !== "blockContainer") {
|
|
65
|
-
|
|
65
|
+
return true; // not a blockContainer, but for example Columns. Insert trailing node
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const lastContentNode = lastNode.firstChild;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorView } from "prosemirror-view";
|
|
2
|
+
|
|
3
|
+
export function getDraggableBlockFromElement(
|
|
4
|
+
element: Element,
|
|
5
|
+
view: EditorView
|
|
6
|
+
) {
|
|
7
|
+
while (
|
|
8
|
+
element &&
|
|
9
|
+
element.parentElement &&
|
|
10
|
+
element.parentElement !== view.dom &&
|
|
11
|
+
element.getAttribute?.("data-node-type") !== "blockContainer"
|
|
12
|
+
) {
|
|
13
|
+
element = element.parentElement;
|
|
14
|
+
}
|
|
15
|
+
if (element.getAttribute?.("data-node-type") !== "blockContainer") {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return { node: element as HTMLElement, id: element.getAttribute("data-id")! };
|
|
19
|
+
}
|
package/src/i18n/locales/ar.ts
CHANGED
|
@@ -52,6 +52,12 @@ export const ar: Dictionary = {
|
|
|
52
52
|
aliases: ["ف", "فقرة"],
|
|
53
53
|
group: "الكتل الأساسية",
|
|
54
54
|
},
|
|
55
|
+
code_block: {
|
|
56
|
+
title: "كود",
|
|
57
|
+
subtext: "يستخدم لعرض الكود مع تحديد الصيغة",
|
|
58
|
+
aliases: ["كود", "مسبق"],
|
|
59
|
+
group: "الكتل الأساسية",
|
|
60
|
+
},
|
|
55
61
|
table: {
|
|
56
62
|
title: "جدول",
|
|
57
63
|
subtext: "يستخدم للجداول",
|