@blocknote/core 0.51.4 → 0.52.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/dist/BlockNoteExtension-B_IEJHS8.js +38 -0
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +1 -0
- package/dist/BlockNoteExtension-M0znTzxP.cjs +2 -0
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +1 -0
- package/dist/ThreadStore-Bx-gSEh1.cjs +2 -0
- package/dist/ThreadStore-Bx-gSEh1.cjs.map +1 -0
- package/dist/ThreadStore-et9wB5Xt.js +11 -0
- package/dist/ThreadStore-et9wB5Xt.js.map +1 -0
- package/dist/UserStore-DCG6lsla.cjs +2 -0
- package/dist/UserStore-DCG6lsla.cjs.map +1 -0
- package/dist/UserStore-QbbPFj0z.js +73 -0
- package/dist/UserStore-QbbPFj0z.js.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -7
- package/dist/blocks-BqHv0xhc.cjs +12 -0
- package/dist/blocks-BqHv0xhc.cjs.map +1 -0
- package/dist/{blocks-DGsP5WKr.js → blocks-CiuUGa1E.js} +1093 -994
- package/dist/blocks-CiuUGa1E.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +75 -340
- package/dist/comments.js.map +1 -1
- package/dist/{en-Cj5r8sW_.cjs → en-C5Z4Ag9_.cjs} +2 -2
- package/dist/en-C5Z4Ag9_.cjs.map +1 -0
- package/dist/{en-B9hMApn4.js → en-CGKXfWma.js} +9 -1
- package/dist/en-CGKXfWma.js.map +1 -0
- package/dist/{extensions-Co4y7P63.js → extensions-CrUGDOks.js} +655 -583
- package/dist/extensions-CrUGDOks.js.map +1 -0
- package/dist/extensions-Ghr9QqqR.cjs +52 -0
- package/dist/extensions-Ghr9QqqR.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +177 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-Bcud0PIg.js → src-DTF83Cl9.js} +1243 -1297
- package/dist/src-DTF83Cl9.js.map +1 -0
- package/dist/src-OfbaVbMw.cjs +21 -0
- package/dist/src-OfbaVbMw.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +2 -0
- package/dist/y.cjs.map +1 -0
- package/dist/y.js +989 -0
- package/dist/y.js.map +1 -0
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +535 -14
- package/dist/yjs.js.map +1 -1
- package/package.json +46 -19
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -20
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +39 -29
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +2 -2
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +4 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +21 -9
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +6 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +362 -4
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +240 -30
- package/src/api/blockManipulation/getBlock/getBlock.ts +4 -9
- package/src/api/blockManipulation/selections/selection.ts +3 -6
- package/src/api/blockManipulation/selections/textCursorPosition.ts +10 -10
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/blockManipulation/tables/tables.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -4
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +2 -1
- package/src/api/exporters/markdown/htmlToMarkdown.ts +79 -43
- package/src/api/getBlockInfoFromPos.test.ts +256 -0
- package/src/api/getBlockInfoFromPos.ts +53 -15
- package/src/api/getBlocksChangedByTransaction.test.ts +2 -1
- package/src/api/getBlocksChangedByTransaction.ts +6 -6
- package/src/api/nodeConversions/blockToNode.test.ts +113 -0
- package/src/api/nodeConversions/blockToNode.ts +15 -3
- package/src/api/nodeConversions/fragmentToBlocks.ts +2 -4
- package/src/api/nodeConversions/nodeToBlock.ts +28 -58
- package/src/api/nodeUtil.ts +6 -2
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -1
- package/src/api/parsers/markdown/detectMarkdown.test.ts +1 -1
- package/src/api/parsers/markdown/markdownToHtml.ts +228 -82
- package/src/api/pmUtil.ts +18 -1
- package/src/api/positionMapping.test.ts +20 -345
- package/src/api/positionMapping.ts +13 -83
- package/src/blocks/Audio/block.ts +1 -1
- package/src/blocks/Code/block.test.ts +14 -7
- package/src/blocks/Code/block.ts +2 -2
- package/src/blocks/Image/block.ts +1 -1
- package/src/blocks/ListItem/CheckListItem/block.test.ts +1 -1
- package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +4 -11
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +47 -50
- package/src/blocks/Table/TableExtension.test.ts +9 -6
- package/src/blocks/Table/TableExtension.ts +20 -6
- package/src/blocks/Table/block.ts +18 -5
- package/src/blocks/Video/block.ts +1 -1
- package/src/blocks/utils/listItemEnterHandler.ts +3 -2
- package/src/comments/extension.ts +30 -21
- package/src/comments/index.ts +0 -3
- package/src/comments/mark.ts +4 -0
- package/src/comments/threadstore/ThreadStore.ts +4 -8
- package/src/comments/types.ts +0 -8
- package/src/editor/Block.css +307 -3
- package/src/editor/BlockNoteEditor.test.ts +21 -18
- package/src/editor/BlockNoteEditor.ts +22 -57
- package/src/editor/BlockNoteExtension.test.ts +1 -1
- package/src/editor/managers/BlockManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +249 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +7 -18
- package/src/editor/managers/ExtensionManager/index.ts +168 -68
- package/src/editor/managers/StateManager.ts +4 -3
- package/src/editor/performance.test.ts +14 -1
- package/src/editor/transformPasted.test.ts +1 -1
- package/src/extensions/Placeholder/Placeholder.ts +1 -0
- package/src/extensions/PositionMapping/PositionMapping.ts +68 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +14 -1
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +14 -11
- package/src/extensions/SideMenu/SideMenu.ts +9 -2
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +1 -1
- package/src/extensions/TableHandles/TableHandles.ts +18 -20
- package/src/extensions/TrailingNode/TrailingNode.ts +33 -1
- package/src/extensions/Versioning/Versioning.test.ts +435 -0
- package/src/extensions/Versioning/Versioning.ts +628 -0
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +469 -0
- package/src/extensions/Versioning/inMemoryVersioning.ts +263 -0
- package/src/extensions/Versioning/index.ts +2 -0
- package/src/extensions/index.ts +6 -9
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +155 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +6 -8
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +9 -9
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +8 -10
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +2 -2
- package/src/extensions/tiptap-extensions/Link/link.test.ts +26 -22
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +187 -0
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +37 -24
- package/src/extensions/tiptap-extensions/index.ts +1 -25
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +10 -1
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +11 -1
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +10 -1
- package/src/i18n/locales/hr.ts +10 -0
- package/src/i18n/locales/is.ts +10 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +10 -0
- package/src/i18n/locales/no.ts +10 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +10 -0
- package/src/i18n/locales/ru.ts +10 -0
- package/src/i18n/locales/sk.ts +10 -1
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +2 -0
- package/src/pm-nodes/BlockContainer.ts +4 -1
- package/src/pm-nodes/BlockGroup.ts +4 -1
- package/src/pm-nodes/Doc.ts +4 -1
- package/src/pm-nodes/suggestionMarks.ts +43 -0
- package/src/schema/blocks/createSpec.test.ts +123 -0
- package/src/schema/blocks/createSpec.ts +82 -24
- package/src/schema/blocks/extendBlockSpec.test.ts +188 -0
- package/src/schema/blocks/internal.ts +13 -43
- package/src/schema/blocks/types.ts +69 -22
- package/src/schema/contentTypePropagation.test.ts +182 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/inlineContent/internal.ts +1 -1
- package/src/schema/inlineContent/types.ts +3 -3
- package/src/schema/markGroups.ts +50 -0
- package/src/user/UserStore.ts +199 -0
- package/src/user/createUserStore.test.ts +126 -0
- package/src/user/index.ts +2 -0
- package/src/user/userColors.ts +72 -0
- package/src/util/string.ts +1 -1
- package/src/util/topo-sort.test.ts +1 -1
- package/src/util/typescript.ts +2 -1
- package/src/vite-env.d.ts +1 -1
- package/src/y/README.md +5 -0
- package/src/{comments/threadstore/yjs → y/comments}/RESTYjsThreadStore.ts +8 -14
- package/src/y/comments/YjsThreadStore.test.ts +295 -0
- package/src/y/comments/YjsThreadStore.ts +358 -0
- package/src/y/comments/YjsThreadStoreBase.ts +50 -0
- package/src/y/comments/index.ts +3 -0
- package/src/y/comments/yjsHelpers.ts +125 -0
- package/src/y/extensions/AttributionExtension.test.ts +86 -0
- package/src/y/extensions/AttributionExtension.ts +378 -0
- package/src/y/extensions/DiffVersioningExtension.test.ts +193 -0
- package/src/y/extensions/DiffVersioningExtension.ts +228 -0
- package/src/y/extensions/ForkYDoc.test.ts +253 -0
- package/src/y/extensions/ForkYDoc.ts +108 -0
- package/src/y/extensions/RelativePositionMapping.test.ts +418 -0
- package/src/y/extensions/RelativePositionMapping.ts +49 -0
- package/src/y/extensions/Suggestions.ts +174 -0
- package/src/y/extensions/Versioning.test.ts +395 -0
- package/src/y/extensions/Versioning.ts +115 -0
- package/src/y/extensions/YAttributionMarks.ts +320 -0
- package/src/{extensions/Collaboration → y/extensions}/YCursorPlugin.ts +15 -7
- package/src/y/extensions/YSync.ts +125 -0
- package/src/y/extensions/blockMatchNodes.ts +182 -0
- package/src/y/extensions/index.ts +156 -0
- package/src/y/index.ts +4 -0
- package/src/y/utils.test.ts +1042 -0
- package/src/y/utils.ts +242 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +50 -0
- package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all.json +20 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +32 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +1 -0
- package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
- package/src/y/versioning/__test__/fixtures/patch-response.json +4 -0
- package/src/y/versioning/__test__/yhub.test.ts +752 -0
- package/src/y/versioning/index.ts +1 -0
- package/src/y/versioning/yhub.ts +631 -0
- package/src/yjs/README.md +5 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +166 -0
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.test.ts +3 -3
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.ts +7 -3
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.ts +3 -3
- package/src/yjs/comments/index.ts +3 -0
- package/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.ts +5 -1
- package/src/yjs/extensions/FixUpSchema.test.ts +421 -0
- package/src/yjs/extensions/FixUpSchema.ts +88 -0
- package/src/yjs/extensions/ForkYDoc.test.ts +216 -0
- package/src/{extensions/Collaboration → yjs/extensions}/ForkYDoc.ts +38 -57
- package/src/yjs/extensions/RelativePositionMapping.test.ts +418 -0
- package/src/yjs/extensions/RelativePositionMapping.ts +71 -0
- package/src/yjs/extensions/Versioning.test.ts +549 -0
- package/src/yjs/extensions/Versioning.ts +83 -0
- package/src/yjs/extensions/YCursorPlugin.ts +201 -0
- package/src/{extensions/Collaboration → yjs/extensions}/YSync.ts +1 -1
- package/src/yjs/extensions/index.ts +89 -0
- package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.test.ts +1 -1
- package/src/yjs/index.ts +2 -0
- package/src/yjs/utils.test.ts +5 -15
- package/src/yjs/utils.ts +36 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +3 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +5 -9
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +4 -6
- package/types/src/api/pmUtil.d.ts +12 -1
- package/types/src/blocks/Audio/block.d.ts +2 -2
- package/types/src/blocks/Code/block.d.ts +2 -2
- package/types/src/blocks/File/block.d.ts +2 -2
- package/types/src/blocks/Heading/block.d.ts +21 -21
- package/types/src/blocks/Image/block.d.ts +3 -3
- package/types/src/blocks/ListItem/CheckListItem/block.d.ts +6 -6
- package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +6 -6
- package/types/src/blocks/Video/block.d.ts +3 -3
- package/types/src/blocks/defaultBlocks.d.ts +17 -17
- package/types/src/comments/extension.d.ts +18 -5
- package/types/src/comments/index.d.ts +0 -3
- package/types/src/comments/threadstore/ThreadStore.d.ts +4 -8
- package/types/src/comments/types.d.ts +0 -8
- package/types/src/editor/BlockNoteEditor.d.ts +8 -9
- package/types/src/editor/managers/BlockManager.d.ts +1 -1
- package/types/src/editor/managers/ExtensionManager/extensions.d.ts +2 -2
- package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
- package/types/src/editor/managers/SelectionManager.d.ts +1 -1
- package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
- package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
- package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/index.d.ts +2 -0
- package/types/src/extensions/index.d.ts +6 -9
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
- package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
- package/types/src/i18n/locales/en.d.ts +9 -1
- package/types/src/i18n/locales/fa.d.ts +9 -1
- package/types/src/i18n/locales/sk.d.ts +9 -1
- package/types/src/index.d.ts +2 -0
- package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
- package/types/src/schema/blocks/createSpec.d.ts +4 -4
- package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
- package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
- package/types/src/schema/blocks/internal.d.ts +5 -7
- package/types/src/schema/blocks/types.d.ts +22 -14
- package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
- package/types/src/schema/index.d.ts +1 -0
- package/types/src/schema/inlineContent/types.d.ts +3 -3
- package/types/src/schema/markGroups.d.ts +33 -0
- package/types/src/user/UserStore.d.ts +105 -0
- package/types/src/user/createUserStore.test.d.ts +1 -0
- package/types/src/user/index.d.ts +2 -0
- package/types/src/user/userColors.d.ts +36 -0
- package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
- package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
- package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
- package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
- package/types/src/y/comments/index.d.ts +3 -0
- package/types/src/y/comments/yjsHelpers.d.ts +13 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
- package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
- package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
- package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
- package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
- package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
- package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
- package/types/src/y/extensions/Suggestions.d.ts +36 -0
- package/types/src/y/extensions/Versioning.d.ts +17 -0
- package/types/src/y/extensions/Versioning.test.d.ts +1 -0
- package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
- package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
- package/types/src/y/extensions/YSync.d.ts +32 -0
- package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
- package/types/src/y/extensions/index.d.ts +189 -0
- package/types/src/y/index.d.ts +4 -0
- package/types/src/y/utils.d.ts +82 -0
- package/types/src/y/utils.test.d.ts +1 -0
- package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
- package/types/src/y/versioning/index.d.ts +1 -0
- package/types/src/y/versioning/yhub.d.ts +87 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
- package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
- package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
- package/types/src/yjs/comments/index.d.ts +3 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
- package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
- package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
- package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
- package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
- package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
- package/types/src/yjs/extensions/Versioning.d.ts +26 -0
- package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
- package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
- package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
- package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
- package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
- package/types/src/yjs/index.d.ts +2 -0
- package/types/src/yjs/utils.d.ts +5 -0
- package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
- package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
- package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
- package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
- package/dist/EventEmitter-CuPnGDYt.js +0 -22
- package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
- package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
- package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
- package/dist/ShowSelection-BsHFfdMi.js +0 -29
- package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
- package/dist/ShowSelection-DhXglbt8.cjs +0 -2
- package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
- package/dist/blocks-Bm6IfL1R.cjs +0 -11
- package/dist/blocks-Bm6IfL1R.cjs.map +0 -1
- package/dist/blocks-DGsP5WKr.js.map +0 -1
- package/dist/en-B9hMApn4.js.map +0 -1
- package/dist/en-Cj5r8sW_.cjs.map +0 -1
- package/dist/extensions-Co4y7P63.js.map +0 -1
- package/dist/extensions-IJK3t0sz.cjs +0 -52
- package/dist/extensions-IJK3t0sz.cjs.map +0 -1
- package/dist/src-B6rlChSc.cjs +0 -21
- package/dist/src-B6rlChSc.cjs.map +0 -1
- package/dist/src-Bcud0PIg.js.map +0 -1
- package/src/comments/userstore/UserStore.ts +0 -72
- package/src/extensions/Collaboration/Collaboration.ts +0 -55
- package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
- package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
- package/types/src/comments/userstore/UserStore.d.ts +0 -31
- package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
- /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
- /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → editor/managers/ExtensionManager/ExtensionManager.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { InputRule as
|
|
15
|
-
import { keymap as
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
1
|
+
import { $n as e, $t as t, Cn as n, Dt as r, En as i, Et as a, Fn as o, Gt as s, In as c, Jn as l, Kn as u, Mt as d, Nt as f, O as p, Ot as m, Qn as h, W as g, Xn as _, Yn as v, _n as ee, bn as te, dn as ne, en as re, f as ie, gn as ae, gt as y, hn as oe, jt as b, kt as x, m as se, qn as S, t as ce, tn as le, vn as ue, xn as de, xt as fe, yn as C, yt as pe } from "./blocks-CiuUGa1E.js";
|
|
2
|
+
import { r as me, t as he } from "./BlockNoteExtension-B_IEJHS8.js";
|
|
3
|
+
import { A as ge, D as _e, O as ve, T as ye, _ as be, b as xe, c as Se, f as Ce, g as we, h as Te, k as Ee, s as De, v as Oe, w as ke, x as Ae, y as je } from "./extensions-CrUGDOks.js";
|
|
4
|
+
import { r as Me } from "./UserStore-QbbPFj0z.js";
|
|
5
|
+
import { t as Ne } from "./en-CGKXfWma.js";
|
|
6
|
+
import { DOMParser as Pe, DOMSerializer as Fe, Fragment as w, NodeRange as Ie, Slice as T } from "prosemirror-model";
|
|
7
|
+
import { ReplaceAroundStep as E, ReplaceStep as Le, canJoin as Re, liftTarget as ze } from "prosemirror-transform";
|
|
8
|
+
import { Editor as Be, Extension as D, Mark as Ve, Node as O, combineTransactionSteps as He, createDocument as Ue, extensions as k, findChildrenInRange as We, findParentNodeClosestToPos as Ge, getAttributes as Ke, getChangedRanges as qe, getMarkRange as Je, getMarksBetween as Ye, getSchema as Xe, isNodeSelection as Ze, markPasteRule as Qe, mergeAttributes as $e, posToDOMRect as et, selectionToInsertionEnd as tt } from "@tiptap/core";
|
|
9
|
+
import { NodeSelection as A, Plugin as j, TextSelection as M } from "prosemirror-state";
|
|
10
|
+
import { Fragment as N, Slice as P } from "@tiptap/pm/model";
|
|
11
|
+
import { CellSelection as F, TableMap as nt } from "prosemirror-tables";
|
|
12
|
+
import { Plugin as rt, PluginKey as it } from "@tiptap/pm/state";
|
|
13
|
+
import { digestString as at } from "lib0/hash/fnv1a";
|
|
14
|
+
import { InputRule as ot, inputRules as st } from "@handlewithcare/prosemirror-inputrules";
|
|
15
|
+
import { keymap as ct } from "@tiptap/pm/keymap";
|
|
16
|
+
import { Text as lt } from "@tiptap/extension-text";
|
|
17
|
+
import { Gapcursor as ut } from "@tiptap/extensions/gap-cursor";
|
|
18
18
|
//#region src/schema/inlineContent/createSpec.ts
|
|
19
|
-
function
|
|
19
|
+
function dt(e, t) {
|
|
20
20
|
let n = [{
|
|
21
21
|
tag: `[data-inline-content-type="${e.type}"]`,
|
|
22
22
|
contentElement: (e) => {
|
|
@@ -33,65 +33,65 @@ function pt(e, t) {
|
|
|
33
33
|
}
|
|
34
34
|
}), n;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
38
|
-
name:
|
|
36
|
+
function ft(e, n) {
|
|
37
|
+
return le(O.create({
|
|
38
|
+
name: e.type,
|
|
39
39
|
inline: !0,
|
|
40
40
|
group: "inline",
|
|
41
|
-
draggable:
|
|
42
|
-
selectable:
|
|
43
|
-
atom:
|
|
44
|
-
content:
|
|
41
|
+
draggable: n.meta?.draggable,
|
|
42
|
+
selectable: e.content === "styled",
|
|
43
|
+
atom: e.content === "none",
|
|
44
|
+
content: e.content === "styled" ? "inline*" : "",
|
|
45
45
|
addAttributes() {
|
|
46
|
-
return
|
|
46
|
+
return ne(e.propSchema);
|
|
47
47
|
},
|
|
48
48
|
addKeyboardShortcuts() {
|
|
49
|
-
return
|
|
49
|
+
return re(e);
|
|
50
50
|
},
|
|
51
51
|
parseHTML() {
|
|
52
|
-
return
|
|
52
|
+
return dt(e, n.parse);
|
|
53
53
|
},
|
|
54
|
-
renderHTML({ node:
|
|
55
|
-
let
|
|
56
|
-
return
|
|
54
|
+
renderHTML({ node: r }) {
|
|
55
|
+
let i = this.options.editor;
|
|
56
|
+
return t(n.render.call({
|
|
57
57
|
renderType: "dom",
|
|
58
58
|
props: void 0
|
|
59
|
-
},
|
|
59
|
+
}, te(r, i.schema.inlineContentSchema, i.schema.styleSchema), () => {}, i), e.type, r.attrs, e.propSchema);
|
|
60
60
|
},
|
|
61
61
|
addNodeView() {
|
|
62
|
-
return (
|
|
63
|
-
let { node:
|
|
64
|
-
return
|
|
62
|
+
return (r) => {
|
|
63
|
+
let { node: i, getPos: a } = r, o = this.options.editor;
|
|
64
|
+
return t(n.render.call({
|
|
65
65
|
renderType: "nodeView",
|
|
66
|
-
props:
|
|
67
|
-
},
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
}, o),
|
|
66
|
+
props: r
|
|
67
|
+
}, te(i, o.schema.inlineContentSchema, o.schema.styleSchema), (e) => {
|
|
68
|
+
let t = d([e], o.pmSchema), n = a();
|
|
69
|
+
n && o.transact((e) => e.replaceWith(n, n + i.nodeSize, t));
|
|
70
|
+
}, o), e.type, i.attrs, e.propSchema);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
}),
|
|
74
|
-
...
|
|
75
|
-
toExternalHTML:
|
|
76
|
-
render(
|
|
77
|
-
return
|
|
73
|
+
}), e.propSchema, {
|
|
74
|
+
...n,
|
|
75
|
+
toExternalHTML: n.toExternalHTML,
|
|
76
|
+
render(r, i, a) {
|
|
77
|
+
return t(n.render(r, i, a), e.type, r.props, e.propSchema);
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
83
|
-
function
|
|
84
|
-
let a = typeof n == "string" ? n : n.id, o =
|
|
85
|
-
let t =
|
|
83
|
+
function pt(e, t, n, r = "before") {
|
|
84
|
+
let a = typeof n == "string" ? n : n.id, o = i(e), s = t.map((e) => {
|
|
85
|
+
let t = b(e, o);
|
|
86
86
|
return t.check(), t;
|
|
87
|
-
}), c =
|
|
87
|
+
}), c = x(a, e.doc);
|
|
88
88
|
if (!c) throw Error(`Block with ID ${a} not found`);
|
|
89
89
|
let l = c.posBeforeNode;
|
|
90
|
-
return
|
|
90
|
+
return r === "after" && (l += c.node.nodeSize), e.step(new Le(l, l, new T(w.from(s), 0, 0))), s.map((t) => C(t, e.doc));
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
|
|
94
|
-
function
|
|
94
|
+
function I(e) {
|
|
95
95
|
if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
96
96
|
let t = e.firstChild;
|
|
97
97
|
if (!t) throw Error("Invalid column: does not have child node.");
|
|
@@ -99,87 +99,89 @@ function L(e) {
|
|
|
99
99
|
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
100
100
|
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function mt(e, t) {
|
|
103
103
|
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
104
104
|
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
105
105
|
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
106
106
|
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
107
107
|
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
108
|
-
|
|
108
|
+
I(i) && e.delete(r, r + i.nodeSize);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
111
|
+
function L(e, t) {
|
|
112
|
+
mt(e, t);
|
|
113
113
|
let n = e.doc.resolve(t).nodeAfter;
|
|
114
114
|
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
115
115
|
if (n.childCount > 2) return;
|
|
116
116
|
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
117
117
|
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
118
118
|
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
119
|
-
let s =
|
|
119
|
+
let s = I(i), c = I(o);
|
|
120
120
|
if (s && c) {
|
|
121
121
|
e.delete(t, t + n.nodeSize);
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
if (s) {
|
|
125
|
-
e.step(new
|
|
125
|
+
e.step(new E(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, T.empty, 0, !1));
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
if (c) {
|
|
129
|
-
e.step(new
|
|
129
|
+
e.step(new E(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, T.empty, 0, !1));
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
135
|
-
function
|
|
136
|
-
let
|
|
137
|
-
let t =
|
|
135
|
+
function R(t, n, r, a = {}) {
|
|
136
|
+
let o = i(t), s = r.map((e) => {
|
|
137
|
+
let t = b(e, o);
|
|
138
138
|
return t.check(), t;
|
|
139
|
-
}),
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
if (!
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let p =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
139
|
+
}), c = new Set(n.map((e) => typeof e == "string" ? e : e.id)), l = [], u = /* @__PURE__ */ new Set(), d = typeof n[0] == "string" ? n[0] : n[0].id, f = 0;
|
|
140
|
+
if (t.doc.descendants((n, i) => {
|
|
141
|
+
if (c.size === 0) return !1;
|
|
142
|
+
if (!n.type.isInGroup("bnBlock")) return !0;
|
|
143
|
+
let a = e(n, t.doc);
|
|
144
|
+
if (!c.has(a)) return !0;
|
|
145
|
+
if (l.push(C(n, t.doc)), c.delete(a), r.length > 0 && a === d) {
|
|
146
|
+
let e = t.doc.nodeSize;
|
|
147
|
+
t.insert(i, s);
|
|
148
|
+
let n = t.doc.nodeSize;
|
|
149
|
+
f += e - n;
|
|
150
|
+
}
|
|
151
|
+
let o = t.doc.nodeSize, p = t.doc.resolve(i - f);
|
|
152
|
+
p.node().type.name === "column" ? u.add(p.before(-1)) : p.node().type.name === "columnList" && u.add(p.before()), p.node().type.name === "blockGroup" && p.node(p.depth - 1).type.name !== "doc" && p.node().childCount === 1 ? t.delete(p.before(), p.after()) : t.delete(i - f, i - f + n.nodeSize);
|
|
153
|
+
let m = t.doc.nodeSize;
|
|
154
|
+
return f += o - m, !1;
|
|
155
|
+
}), c.size > 0) {
|
|
156
|
+
let e = [...c].join("\n");
|
|
155
157
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
156
158
|
}
|
|
157
|
-
return
|
|
158
|
-
insertedBlocks:
|
|
159
|
-
removedBlocks:
|
|
159
|
+
return a.fixColumns !== !1 && u.forEach((e) => L(t, e)), {
|
|
160
|
+
insertedBlocks: s.map((e) => C(e, t.doc)),
|
|
161
|
+
removedBlocks: l
|
|
160
162
|
};
|
|
161
163
|
}
|
|
162
164
|
//#endregion
|
|
163
165
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
164
|
-
function
|
|
165
|
-
let
|
|
166
|
-
if (!
|
|
167
|
-
if (typeof
|
|
168
|
-
else if (Array.isArray(
|
|
169
|
-
else if (
|
|
170
|
-
else throw new
|
|
171
|
-
let
|
|
172
|
-
for (let t of
|
|
173
|
-
let
|
|
174
|
-
if (
|
|
175
|
-
let
|
|
166
|
+
function ht(e, t, n, r, i) {
|
|
167
|
+
let a;
|
|
168
|
+
if (!t) throw Error("blockContent is required");
|
|
169
|
+
if (typeof t == "string") a = d([t], e.pmSchema, r);
|
|
170
|
+
else if (Array.isArray(t)) a = d(t, e.pmSchema, r);
|
|
171
|
+
else if (t.type === "tableContent") a = f(t, e.pmSchema);
|
|
172
|
+
else throw new c(t.type);
|
|
173
|
+
let o = (i?.document ?? document).createDocumentFragment();
|
|
174
|
+
for (let t of a) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
175
|
+
let r = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
176
|
+
if (r) {
|
|
177
|
+
let a = te(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = r.render.call({
|
|
176
178
|
renderType: "dom",
|
|
177
179
|
props: void 0
|
|
178
|
-
},
|
|
179
|
-
if (
|
|
180
|
-
if (
|
|
181
|
-
let e =
|
|
182
|
-
|
|
180
|
+
}, a, () => {}, e);
|
|
181
|
+
if (s) {
|
|
182
|
+
if (o.appendChild(s.dom), s.contentDOM) {
|
|
183
|
+
let e = n.serializeFragment(t.content, i);
|
|
184
|
+
s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(e);
|
|
183
185
|
}
|
|
184
186
|
continue;
|
|
185
187
|
}
|
|
@@ -190,17 +192,17 @@ function _t(e, n, r, i, a) {
|
|
|
190
192
|
let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
|
|
191
193
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
192
194
|
} else {
|
|
193
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
195
|
+
let e = r.type.spec.toDOM(r, !0), t = Fe.renderSpec(document, e);
|
|
194
196
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
195
197
|
}
|
|
196
|
-
|
|
198
|
+
o.appendChild(n);
|
|
197
199
|
} else {
|
|
198
|
-
let e =
|
|
199
|
-
|
|
200
|
+
let e = n.serializeFragment(w.from([t]), i);
|
|
201
|
+
o.appendChild(e);
|
|
200
202
|
}
|
|
201
|
-
return
|
|
203
|
+
return o;
|
|
202
204
|
}
|
|
203
|
-
function
|
|
205
|
+
function gt(e, t, n, r) {
|
|
204
206
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
205
207
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
206
208
|
let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
|
|
@@ -212,12 +214,12 @@ function vt(e, t, n, r) {
|
|
|
212
214
|
children: o
|
|
213
215
|
}, e);
|
|
214
216
|
if (s.contentDOM && t.content) {
|
|
215
|
-
let i =
|
|
217
|
+
let i = ht(e, t.content, n, t.type, r);
|
|
216
218
|
s.contentDOM.appendChild(i);
|
|
217
219
|
}
|
|
218
220
|
if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
|
|
219
221
|
if (t.children && t.children.length > 0) {
|
|
220
|
-
let i =
|
|
222
|
+
let i = _t(e, t.children, n, r);
|
|
221
223
|
s.contentDOM?.append(i);
|
|
222
224
|
}
|
|
223
225
|
return s.dom;
|
|
@@ -226,146 +228,195 @@ function vt(e, t, n, r) {
|
|
|
226
228
|
id: t.id,
|
|
227
229
|
...a
|
|
228
230
|
}));
|
|
229
|
-
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(
|
|
231
|
+
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(vt(e, t.children, n, r)), c.dom;
|
|
230
232
|
}
|
|
231
|
-
function
|
|
233
|
+
function _t(e, t, n, r) {
|
|
232
234
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
233
235
|
for (let a of t) {
|
|
234
|
-
let t =
|
|
236
|
+
let t = gt(e, a, n, r);
|
|
235
237
|
i.appendChild(t);
|
|
236
238
|
}
|
|
237
239
|
return i;
|
|
238
240
|
}
|
|
239
|
-
var
|
|
240
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
241
|
+
var vt = (e, t, n, r) => {
|
|
242
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = _t(e, t, n, r);
|
|
241
243
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
242
|
-
},
|
|
244
|
+
}, yt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
243
245
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
244
246
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
245
247
|
else {
|
|
246
248
|
let n = t.getAttribute("data-index");
|
|
247
249
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
248
250
|
}
|
|
249
|
-
}), e),
|
|
251
|
+
}), e), bt = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
250
252
|
e.disabled = !0;
|
|
251
|
-
}), e),
|
|
253
|
+
}), e), xt = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
252
254
|
e.setAttribute("data-show-children", "true");
|
|
253
|
-
}), e),
|
|
255
|
+
}), e), St = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
254
256
|
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
255
|
-
}), e),
|
|
257
|
+
}), e), Ct = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
256
258
|
let t = document.createElement("div");
|
|
257
259
|
t.className = "tableWrapper";
|
|
258
260
|
let n = document.createElement("div");
|
|
259
261
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
260
|
-
}), e),
|
|
262
|
+
}), e), wt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
261
263
|
let t = document.createElement("span");
|
|
262
264
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
263
|
-
}), e),
|
|
264
|
-
let n =
|
|
265
|
+
}), e), Tt = (e, t) => {
|
|
266
|
+
let n = Fe.fromSchema(e), r = [
|
|
267
|
+
yt,
|
|
268
|
+
bt,
|
|
265
269
|
xt,
|
|
266
270
|
St,
|
|
267
271
|
Ct,
|
|
268
|
-
wt
|
|
269
|
-
Tt,
|
|
270
|
-
Et
|
|
272
|
+
wt
|
|
271
273
|
];
|
|
272
274
|
return { serializeBlocks: (e, i) => {
|
|
273
|
-
let a =
|
|
275
|
+
let a = vt(t, e, n, i);
|
|
274
276
|
for (let e of r) a = e(a);
|
|
275
277
|
return a.outerHTML;
|
|
276
278
|
} };
|
|
279
|
+
}, Et = (e) => {
|
|
280
|
+
let t = 0;
|
|
281
|
+
for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
|
|
282
|
+
return Math.abs(t);
|
|
283
|
+
}, z = [
|
|
284
|
+
{
|
|
285
|
+
light: "#fff0c2",
|
|
286
|
+
dark: "#8a6d1a"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
light: "#fcc9c3",
|
|
290
|
+
dark: "#8a2e24"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
light: "#d4e8eb",
|
|
294
|
+
dark: "#4a7178"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
light: "#c2eeff",
|
|
298
|
+
dark: "#1a6e8a"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
light: "#bef3ff",
|
|
302
|
+
dark: "#0a7a8a"
|
|
303
|
+
}
|
|
304
|
+
], Dt = (e) => z[Et(e) % z.length], Ot = (e, t) => {
|
|
305
|
+
if (!t || t.length === 0) return z[0];
|
|
306
|
+
let n = t[0], r = e.getUser(n);
|
|
307
|
+
return r?.color && r.colorLight ? {
|
|
308
|
+
light: r.colorLight,
|
|
309
|
+
dark: r.color
|
|
310
|
+
} : Dt(n);
|
|
311
|
+
}, kt = (e) => at(e).toString(16).padStart(8, "0"), At = (e) => {
|
|
312
|
+
let t = kt(e);
|
|
313
|
+
return {
|
|
314
|
+
light: `--user-color-${t}-light`,
|
|
315
|
+
dark: `--user-color-${t}-dark`
|
|
316
|
+
};
|
|
317
|
+
}, B = class {
|
|
318
|
+
callbacks = {};
|
|
319
|
+
on(e, t) {
|
|
320
|
+
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
321
|
+
}
|
|
322
|
+
emit(e, ...t) {
|
|
323
|
+
let n = this.callbacks[e];
|
|
324
|
+
n && n.forEach((e) => e.apply(this, t));
|
|
325
|
+
}
|
|
326
|
+
off(e, t) {
|
|
327
|
+
let n = this.callbacks[e];
|
|
328
|
+
n && (t ? this.callbacks[e] = n.filter((e) => e !== t) : delete this.callbacks[e]);
|
|
329
|
+
}
|
|
330
|
+
removeAllListeners() {
|
|
331
|
+
this.callbacks = {};
|
|
332
|
+
}
|
|
277
333
|
};
|
|
278
334
|
//#endregion
|
|
279
335
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
280
|
-
function
|
|
281
|
-
return
|
|
282
|
-
let
|
|
283
|
-
if (
|
|
336
|
+
function jt(t) {
|
|
337
|
+
return t.transact((t) => {
|
|
338
|
+
let n = l(t, t.selection.anchor), r = e(n.bnBlock.node, t.doc);
|
|
339
|
+
if (t.selection instanceof F) return {
|
|
284
340
|
type: "cell",
|
|
285
|
-
anchorBlockId:
|
|
286
|
-
anchorCellOffset:
|
|
287
|
-
headCellOffset:
|
|
341
|
+
anchorBlockId: r,
|
|
342
|
+
anchorCellOffset: t.selection.$anchorCell.pos - n.bnBlock.beforePos,
|
|
343
|
+
headCellOffset: t.selection.$headCell.pos - n.bnBlock.beforePos
|
|
288
344
|
};
|
|
289
|
-
if (
|
|
345
|
+
if (t.selection instanceof A) return {
|
|
290
346
|
type: "node",
|
|
291
|
-
anchorBlockId:
|
|
347
|
+
anchorBlockId: r
|
|
292
348
|
};
|
|
293
349
|
{
|
|
294
|
-
let
|
|
350
|
+
let i = l(t, t.selection.head);
|
|
295
351
|
return {
|
|
296
352
|
type: "text",
|
|
297
|
-
anchorBlockId:
|
|
298
|
-
headBlockId:
|
|
299
|
-
anchorOffset:
|
|
300
|
-
headOffset:
|
|
353
|
+
anchorBlockId: r,
|
|
354
|
+
headBlockId: e(i.bnBlock.node, t.doc),
|
|
355
|
+
anchorOffset: t.selection.anchor - n.bnBlock.beforePos,
|
|
356
|
+
headOffset: t.selection.head - i.bnBlock.beforePos
|
|
301
357
|
};
|
|
302
358
|
}
|
|
303
359
|
});
|
|
304
360
|
}
|
|
305
|
-
function
|
|
306
|
-
let n =
|
|
361
|
+
function Mt(e, t) {
|
|
362
|
+
let n = x(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
307
363
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
308
|
-
let
|
|
309
|
-
if (t.type === "cell")
|
|
310
|
-
else if (t.type === "node")
|
|
364
|
+
let r;
|
|
365
|
+
if (t.type === "cell") r = F.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
366
|
+
else if (t.type === "node") r = A.create(e.doc, n + 1);
|
|
311
367
|
else {
|
|
312
|
-
let
|
|
313
|
-
if (
|
|
314
|
-
|
|
368
|
+
let i = x(t.headBlockId, e.doc)?.posBeforeNode;
|
|
369
|
+
if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
370
|
+
r = M.create(e.doc, n + t.anchorOffset, i + t.headOffset);
|
|
315
371
|
}
|
|
316
|
-
e.setSelection(
|
|
372
|
+
e.setSelection(r);
|
|
317
373
|
}
|
|
318
|
-
function
|
|
374
|
+
function Nt(e) {
|
|
319
375
|
return e.flatMap((e) => e.type === "column" ? e.children : [e]);
|
|
320
376
|
}
|
|
321
|
-
function
|
|
322
|
-
e.transact(() => {
|
|
323
|
-
|
|
324
|
-
if (i?.type === "columnList") {
|
|
325
|
-
let t = r === "after" ? e.getNextBlock(i) : e.getPrevBlock(i);
|
|
326
|
-
t && (n = t, r = r === "after" ? "before" : "after");
|
|
327
|
-
}
|
|
328
|
-
e.removeBlocks(t), e.insertBlocks(At(t), n, r);
|
|
377
|
+
function V(e, t, n, r) {
|
|
378
|
+
e.transact((e) => {
|
|
379
|
+
R(e, t, [], { fixColumns: !1 }), pt(e, Nt(t), n, r);
|
|
329
380
|
});
|
|
330
381
|
}
|
|
331
|
-
function
|
|
382
|
+
function Pt(e, t, n) {
|
|
332
383
|
e.transact((r) => {
|
|
333
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
334
|
-
|
|
384
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = jt(e);
|
|
385
|
+
V(e, i, t, n), Mt(r, a);
|
|
335
386
|
});
|
|
336
387
|
}
|
|
337
|
-
function
|
|
388
|
+
function Ft(e) {
|
|
338
389
|
return !e || e.type !== "columnList";
|
|
339
390
|
}
|
|
340
|
-
function
|
|
391
|
+
function It(e, t, n) {
|
|
341
392
|
let r, i;
|
|
342
393
|
if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
|
|
343
394
|
let a = e.getParentBlock(r);
|
|
344
|
-
return
|
|
395
|
+
return Ft(a) ? {
|
|
345
396
|
referenceBlock: r,
|
|
346
397
|
placement: i
|
|
347
|
-
} :
|
|
398
|
+
} : It(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
348
399
|
}
|
|
349
|
-
function
|
|
400
|
+
function Lt(e, t, n) {
|
|
350
401
|
let r, i;
|
|
351
402
|
if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
|
|
352
403
|
let a = e.getParentBlock(r);
|
|
353
|
-
return
|
|
404
|
+
return Ft(a) ? {
|
|
354
405
|
referenceBlock: r,
|
|
355
406
|
placement: i
|
|
356
|
-
} :
|
|
407
|
+
} : Lt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
357
408
|
}
|
|
358
|
-
function
|
|
409
|
+
function Rt(e, t) {
|
|
359
410
|
e.transact(() => {
|
|
360
411
|
let n;
|
|
361
412
|
if (t) {
|
|
362
413
|
if (n = e.getBlock(t), !n) return;
|
|
363
414
|
} else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
|
|
364
|
-
let r =
|
|
365
|
-
r && (t ?
|
|
415
|
+
let r = It(e, e.getPrevBlock(n), e.getParentBlock(n));
|
|
416
|
+
r && (t ? V(e, [n], r.referenceBlock, r.placement) : Pt(e, r.referenceBlock, r.placement));
|
|
366
417
|
});
|
|
367
418
|
}
|
|
368
|
-
function
|
|
419
|
+
function zt(e, t) {
|
|
369
420
|
e.transact(() => {
|
|
370
421
|
let n;
|
|
371
422
|
if (t) {
|
|
@@ -374,100 +425,101 @@ function It(e, t) {
|
|
|
374
425
|
let t = e.getSelection();
|
|
375
426
|
n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block;
|
|
376
427
|
}
|
|
377
|
-
let r =
|
|
378
|
-
r && (t ?
|
|
428
|
+
let r = Lt(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
429
|
+
r && (t ? V(e, [n], r.referenceBlock, r.placement) : Pt(e, r.referenceBlock, r.placement));
|
|
379
430
|
});
|
|
380
431
|
}
|
|
381
432
|
//#endregion
|
|
382
433
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
383
|
-
function
|
|
434
|
+
function Bt(e, t, n) {
|
|
384
435
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
385
436
|
if (!a) return !1;
|
|
386
437
|
let o = a.startIndex;
|
|
387
438
|
if (o === 0) return !1;
|
|
388
439
|
let s = a.parent.child(o - 1);
|
|
389
440
|
if (s.type !== t) return !1;
|
|
390
|
-
let c = s.lastChild && s.lastChild.type === n, l =
|
|
391
|
-
return e.step(new
|
|
441
|
+
let c = s.lastChild && s.lastChild.type === n, l = w.from(c ? t.create() : null), u = new T(w.from(t.create(null, w.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
442
|
+
return e.step(new E(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
392
443
|
}
|
|
393
|
-
function
|
|
394
|
-
return e.transact((t) =>
|
|
444
|
+
function Vt(e) {
|
|
445
|
+
return e.transact((t) => Bt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
395
446
|
}
|
|
396
|
-
function
|
|
447
|
+
function Ht(e, t, n, r) {
|
|
397
448
|
let i = r.end, a = r.$to.end(r.depth);
|
|
398
449
|
if (i < a) {
|
|
399
450
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
400
|
-
e.step(new
|
|
451
|
+
e.step(new E(i - (s ? 2 : 1), a, i, a, new T(w.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new Ie(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
|
|
401
452
|
}
|
|
402
|
-
let o =
|
|
453
|
+
let o = ze(r);
|
|
403
454
|
if (o == null) return !1;
|
|
404
455
|
e.lift(r, o);
|
|
405
456
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
406
|
-
return
|
|
457
|
+
return Re(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
407
458
|
}
|
|
408
|
-
function
|
|
459
|
+
function H(e, t, n) {
|
|
409
460
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
410
|
-
return a && r.node(a.depth - 1).type === t ?
|
|
461
|
+
return a && r.node(a.depth - 1).type === t ? Ht(e, t, n, a) : !1;
|
|
411
462
|
}
|
|
412
|
-
function
|
|
413
|
-
return e.transact((t) =>
|
|
463
|
+
function Ut(e) {
|
|
464
|
+
return e.transact((t) => H(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
414
465
|
}
|
|
415
|
-
function
|
|
466
|
+
function Wt(e) {
|
|
416
467
|
return e.transact((e) => {
|
|
417
|
-
let { bnBlock: t } =
|
|
468
|
+
let { bnBlock: t } = _(e);
|
|
418
469
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
419
470
|
});
|
|
420
471
|
}
|
|
421
|
-
function
|
|
472
|
+
function Gt(e) {
|
|
422
473
|
return e.transact((e) => {
|
|
423
|
-
let { bnBlock: t } =
|
|
474
|
+
let { bnBlock: t } = _(e);
|
|
424
475
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
425
476
|
});
|
|
426
477
|
}
|
|
427
478
|
//#endregion
|
|
428
479
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
429
|
-
function
|
|
430
|
-
let n = typeof t == "string" ? t : t.id,
|
|
431
|
-
if (
|
|
480
|
+
function Kt(e, t) {
|
|
481
|
+
let n = x(typeof t == "string" ? t : t.id, e);
|
|
482
|
+
if (n) return C(n.node, e);
|
|
432
483
|
}
|
|
433
|
-
function
|
|
434
|
-
let n =
|
|
484
|
+
function qt(e, t) {
|
|
485
|
+
let n = x(typeof t == "string" ? t : t.id, e);
|
|
435
486
|
if (!n) return;
|
|
436
|
-
let
|
|
437
|
-
if (
|
|
487
|
+
let r = e.resolve(n.posBeforeNode).nodeBefore;
|
|
488
|
+
if (r) return C(r, e);
|
|
438
489
|
}
|
|
439
|
-
function
|
|
440
|
-
let n =
|
|
490
|
+
function Jt(e, t) {
|
|
491
|
+
let n = x(typeof t == "string" ? t : t.id, e);
|
|
441
492
|
if (!n) return;
|
|
442
|
-
let
|
|
443
|
-
if (
|
|
493
|
+
let r = e.resolve(n.posBeforeNode + n.node.nodeSize).nodeAfter;
|
|
494
|
+
if (r) return C(r, e);
|
|
444
495
|
}
|
|
445
|
-
function
|
|
446
|
-
let n = typeof t == "string" ? t : t.id,
|
|
447
|
-
if (!
|
|
448
|
-
let
|
|
449
|
-
if (
|
|
496
|
+
function Yt(e, t) {
|
|
497
|
+
let n = x(typeof t == "string" ? t : t.id, e);
|
|
498
|
+
if (!n) return;
|
|
499
|
+
let r = e.resolve(n.posBeforeNode), i = r.node(), a = r.node(-1), o = a.type.name === "doc" ? void 0 : i.type.name === "blockGroup" ? a : i;
|
|
500
|
+
if (o) return C(o, e);
|
|
450
501
|
}
|
|
451
502
|
//#endregion
|
|
452
503
|
//#region src/editor/managers/BlockManager.ts
|
|
453
|
-
var
|
|
504
|
+
var Xt = class {
|
|
505
|
+
editor;
|
|
454
506
|
constructor(e) {
|
|
455
507
|
this.editor = e;
|
|
456
508
|
}
|
|
457
509
|
get document() {
|
|
458
|
-
return this.editor.transact((e) =>
|
|
510
|
+
return this.editor.transact((e) => ue(e.doc));
|
|
459
511
|
}
|
|
460
512
|
getBlock(e) {
|
|
461
|
-
return this.editor.transact((t) =>
|
|
513
|
+
return this.editor.transact((t) => Kt(t.doc, e));
|
|
462
514
|
}
|
|
463
515
|
getPrevBlock(e) {
|
|
464
|
-
return this.editor.transact((t) =>
|
|
516
|
+
return this.editor.transact((t) => qt(t.doc, e));
|
|
465
517
|
}
|
|
466
518
|
getNextBlock(e) {
|
|
467
|
-
return this.editor.transact((t) =>
|
|
519
|
+
return this.editor.transact((t) => Jt(t.doc, e));
|
|
468
520
|
}
|
|
469
521
|
getParentBlock(e) {
|
|
470
|
-
return this.editor.transact((t) =>
|
|
522
|
+
return this.editor.transact((t) => Yt(t.doc, e));
|
|
471
523
|
}
|
|
472
524
|
forEachBlock(e, t = !1) {
|
|
473
525
|
let n = this.document.slice();
|
|
@@ -479,36 +531,37 @@ var qt = class {
|
|
|
479
531
|
r(n);
|
|
480
532
|
}
|
|
481
533
|
insertBlocks(e, t, n = "before") {
|
|
482
|
-
return this.editor.transact((r) =>
|
|
534
|
+
return this.editor.transact((r) => pt(r, e, t, n));
|
|
483
535
|
}
|
|
484
536
|
updateBlock(e, t) {
|
|
485
|
-
return this.editor.transact((n) =>
|
|
537
|
+
return this.editor.transact((n) => a(n, e, t));
|
|
486
538
|
}
|
|
487
539
|
removeBlocks(e) {
|
|
488
|
-
return this.editor.transact((t) =>
|
|
540
|
+
return this.editor.transact((t) => R(t, e, []).removedBlocks);
|
|
489
541
|
}
|
|
490
542
|
replaceBlocks(e, t) {
|
|
491
|
-
return this.editor.transact((n) =>
|
|
543
|
+
return this.editor.transact((n) => R(n, e, t));
|
|
492
544
|
}
|
|
493
545
|
canNestBlock() {
|
|
494
|
-
return
|
|
546
|
+
return Wt(this.editor);
|
|
495
547
|
}
|
|
496
548
|
nestBlock() {
|
|
497
|
-
|
|
549
|
+
Vt(this.editor);
|
|
498
550
|
}
|
|
499
551
|
canUnnestBlock() {
|
|
500
|
-
return
|
|
552
|
+
return Gt(this.editor);
|
|
501
553
|
}
|
|
502
554
|
unnestBlock() {
|
|
503
|
-
|
|
555
|
+
Ut(this.editor);
|
|
504
556
|
}
|
|
505
557
|
moveBlocksUp(e) {
|
|
506
|
-
return
|
|
558
|
+
return Rt(this.editor, e);
|
|
507
559
|
}
|
|
508
560
|
moveBlocksDown(e) {
|
|
509
|
-
return
|
|
561
|
+
return zt(this.editor, e);
|
|
510
562
|
}
|
|
511
|
-
},
|
|
563
|
+
}, Zt = class extends B {
|
|
564
|
+
editor;
|
|
512
565
|
constructor(e) {
|
|
513
566
|
super(), this.editor = e, e.on("create", () => {
|
|
514
567
|
e._tiptapEditor.on("update", ({ transaction: t, appendedTransactions: n }) => {
|
|
@@ -531,8 +584,8 @@ var qt = class {
|
|
|
531
584
|
}
|
|
532
585
|
onChange(e, t = !0) {
|
|
533
586
|
let n = ({ transaction: n, appendedTransactions: r }) => {
|
|
534
|
-
!t &&
|
|
535
|
-
return
|
|
587
|
+
!t && Qt(n) || e(this.editor, { getChanges() {
|
|
588
|
+
return Ee(n, r);
|
|
536
589
|
} });
|
|
537
590
|
};
|
|
538
591
|
return this.on("onChange", n), () => {
|
|
@@ -541,7 +594,7 @@ var qt = class {
|
|
|
541
594
|
}
|
|
542
595
|
onSelectionChange(e, t = !1) {
|
|
543
596
|
let n = (n) => {
|
|
544
|
-
!t &&
|
|
597
|
+
!t && Qt(n.transaction) || e(this.editor);
|
|
545
598
|
};
|
|
546
599
|
return this.on("onSelectionChange", n), () => {
|
|
547
600
|
this.off("onSelectionChange", n);
|
|
@@ -558,30 +611,30 @@ var qt = class {
|
|
|
558
611
|
};
|
|
559
612
|
}
|
|
560
613
|
};
|
|
561
|
-
function
|
|
614
|
+
function Qt(e) {
|
|
562
615
|
return !!e.getMeta("y-sync$");
|
|
563
616
|
}
|
|
564
617
|
//#endregion
|
|
565
618
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
566
|
-
function
|
|
619
|
+
function $t(e) {
|
|
567
620
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
568
621
|
}
|
|
569
|
-
function
|
|
622
|
+
function en(e) {
|
|
570
623
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
571
624
|
}
|
|
572
|
-
function
|
|
625
|
+
function tn(e) {
|
|
573
626
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
574
|
-
let t =
|
|
627
|
+
let t = $t(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
575
628
|
e.remove(), r.forEach((e) => {
|
|
576
629
|
e.remove();
|
|
577
630
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
578
|
-
if (
|
|
631
|
+
if (en(t)) return;
|
|
579
632
|
let n = document.createElement("li");
|
|
580
633
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
581
634
|
}), n.childNodes.length === 0 && n.remove();
|
|
582
635
|
});
|
|
583
636
|
}
|
|
584
|
-
function
|
|
637
|
+
function nn(e) {
|
|
585
638
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
586
639
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
587
640
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -589,25 +642,25 @@ function $t(e) {
|
|
|
589
642
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
590
643
|
});
|
|
591
644
|
}
|
|
592
|
-
var
|
|
593
|
-
function
|
|
594
|
-
return
|
|
645
|
+
var rn = null;
|
|
646
|
+
function an() {
|
|
647
|
+
return rn ||= document.implementation.createHTMLDocument("title");
|
|
595
648
|
}
|
|
596
|
-
function
|
|
649
|
+
function on(e) {
|
|
597
650
|
if (typeof e == "string") {
|
|
598
|
-
let t =
|
|
651
|
+
let t = an().createElement("div");
|
|
599
652
|
t.innerHTML = e, e = t;
|
|
600
653
|
}
|
|
601
|
-
return
|
|
654
|
+
return tn(e), nn(e), e;
|
|
602
655
|
}
|
|
603
656
|
//#endregion
|
|
604
657
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
605
|
-
function
|
|
658
|
+
function sn(e) {
|
|
606
659
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
607
660
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
608
661
|
return !1;
|
|
609
662
|
}
|
|
610
|
-
function
|
|
663
|
+
function cn(e) {
|
|
611
664
|
let t = new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
612
665
|
let r = n.parentElement;
|
|
613
666
|
for (; r && r !== e;) {
|
|
@@ -619,78 +672,78 @@ function an(e) {
|
|
|
619
672
|
for (; i = n.nextNode();) r.push(i);
|
|
620
673
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
621
674
|
}
|
|
622
|
-
function
|
|
623
|
-
|
|
675
|
+
function ln(e) {
|
|
676
|
+
sn(e) || cn(e);
|
|
624
677
|
}
|
|
625
678
|
//#endregion
|
|
626
679
|
//#region src/api/parsers/html/parseHTML.ts
|
|
627
|
-
function
|
|
628
|
-
let n =
|
|
629
|
-
|
|
630
|
-
let r =
|
|
631
|
-
for (let e = 0; e < r.childCount; e++) i.push(
|
|
680
|
+
function U(e, t) {
|
|
681
|
+
let n = on(e);
|
|
682
|
+
ln(n);
|
|
683
|
+
let r = Pe.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
|
|
684
|
+
for (let e = 0; e < r.childCount; e++) i.push(C(r.child(e), r));
|
|
632
685
|
return i;
|
|
633
686
|
}
|
|
634
687
|
//#endregion
|
|
635
688
|
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
636
|
-
function
|
|
689
|
+
function W(e) {
|
|
637
690
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
638
691
|
}
|
|
639
|
-
function
|
|
692
|
+
function un(e) {
|
|
640
693
|
return e ? /\w/.test(e) : !1;
|
|
641
694
|
}
|
|
642
|
-
function
|
|
695
|
+
function G(e, t, n) {
|
|
643
696
|
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
644
|
-
return
|
|
697
|
+
return un(r) && un(i);
|
|
645
698
|
}
|
|
646
|
-
function
|
|
699
|
+
function dn(e, t) {
|
|
647
700
|
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
648
701
|
let n = e[t + 1];
|
|
649
702
|
return n === "\n" ? {
|
|
650
703
|
html: "<br>\n",
|
|
651
704
|
end: t + 2
|
|
652
705
|
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
653
|
-
html:
|
|
706
|
+
html: W(n),
|
|
654
707
|
end: t + 2
|
|
655
708
|
} : null;
|
|
656
709
|
}
|
|
657
|
-
function ln(e, t) {
|
|
658
|
-
return e[t] === "`" ? Tn(e, t) : null;
|
|
659
|
-
}
|
|
660
|
-
function un(e, t) {
|
|
661
|
-
return e[t] !== "!" || e[t + 1] !== "[" ? null : En(e, t);
|
|
662
|
-
}
|
|
663
|
-
function dn(e, t) {
|
|
664
|
-
return e[t] === "[" ? Dn(e, t) : null;
|
|
665
|
-
}
|
|
666
710
|
function fn(e, t) {
|
|
667
|
-
return e[t]
|
|
711
|
+
return e[t] === "`" ? On(e, t) : null;
|
|
668
712
|
}
|
|
669
713
|
function pn(e, t) {
|
|
670
|
-
return e[t]
|
|
714
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : kn(e, t);
|
|
671
715
|
}
|
|
672
716
|
function mn(e, t) {
|
|
673
|
-
return e[t] === "
|
|
717
|
+
return e[t] === "[" ? An(e, t) : null;
|
|
674
718
|
}
|
|
675
719
|
function hn(e, t) {
|
|
676
|
-
return e[t]
|
|
720
|
+
return e[t] !== "~" || e[t + 1] !== "~" ? null : q(e, t, "~~", "<del>", "</del>");
|
|
677
721
|
}
|
|
678
722
|
function gn(e, t) {
|
|
723
|
+
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !G(e, t, 3) ? q(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
|
|
724
|
+
}
|
|
725
|
+
function _n(e, t) {
|
|
726
|
+
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !G(e, t, 2) ? q(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
|
|
727
|
+
}
|
|
728
|
+
function vn(e, t) {
|
|
729
|
+
return e[t] === "*" || e[t] === "_" && !G(e, t, 1) ? q(e, t, e[t], "<em>", "</em>") : null;
|
|
730
|
+
}
|
|
731
|
+
function yn(e, t) {
|
|
679
732
|
return e[t] === "\n" ? {
|
|
680
733
|
html: "<br>\n",
|
|
681
734
|
end: t + 1
|
|
682
735
|
} : null;
|
|
683
736
|
}
|
|
684
|
-
var
|
|
685
|
-
function
|
|
737
|
+
var bn = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, xn = /^<!--[\s\S]*?-->/, Sn = /^<!\[CDATA\[[\s\S]*?\]\]>/, Cn = /^<\?[\s\S]*?\?>/, wn = /^<![A-Za-z][\s\S]*?>/;
|
|
738
|
+
function Tn(e, t) {
|
|
686
739
|
if (e[t] !== "<") return null;
|
|
687
740
|
let n = e.substring(t);
|
|
688
741
|
for (let e of [
|
|
689
|
-
vn,
|
|
690
|
-
yn,
|
|
691
|
-
bn,
|
|
692
742
|
xn,
|
|
693
|
-
|
|
743
|
+
Sn,
|
|
744
|
+
Cn,
|
|
745
|
+
wn,
|
|
746
|
+
bn
|
|
694
747
|
]) {
|
|
695
748
|
let r = n.match(e);
|
|
696
749
|
if (r) return {
|
|
@@ -700,19 +753,19 @@ function Sn(e, t) {
|
|
|
700
753
|
}
|
|
701
754
|
return null;
|
|
702
755
|
}
|
|
703
|
-
var
|
|
704
|
-
cn,
|
|
705
|
-
ln,
|
|
706
|
-
un,
|
|
756
|
+
var En = /* @__PURE__ */ new Set("\\`![~*_\n<"), Dn = [
|
|
707
757
|
dn,
|
|
708
758
|
fn,
|
|
709
759
|
pn,
|
|
710
760
|
mn,
|
|
711
761
|
hn,
|
|
712
|
-
|
|
713
|
-
|
|
762
|
+
gn,
|
|
763
|
+
_n,
|
|
764
|
+
vn,
|
|
765
|
+
Tn,
|
|
766
|
+
yn
|
|
714
767
|
];
|
|
715
|
-
function
|
|
768
|
+
function K(e) {
|
|
716
769
|
let t = "", n = 0;
|
|
717
770
|
for (; n < e.length;) {
|
|
718
771
|
if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
|
|
@@ -720,7 +773,7 @@ function G(e) {
|
|
|
720
773
|
continue;
|
|
721
774
|
}
|
|
722
775
|
let r = !1;
|
|
723
|
-
if (
|
|
776
|
+
if (En.has(e[n])) for (let i of Dn) {
|
|
724
777
|
let a = i(e, n);
|
|
725
778
|
if (a) {
|
|
726
779
|
t += a.html, n = a.end, r = !0;
|
|
@@ -729,13 +782,13 @@ function G(e) {
|
|
|
729
782
|
}
|
|
730
783
|
if (!r) {
|
|
731
784
|
let r = n;
|
|
732
|
-
for (n++; n < e.length && !
|
|
733
|
-
t +=
|
|
785
|
+
for (n++; n < e.length && !En.has(e[n]);) n++;
|
|
786
|
+
t += W(e.substring(r, n));
|
|
734
787
|
}
|
|
735
788
|
}
|
|
736
789
|
return t;
|
|
737
790
|
}
|
|
738
|
-
function
|
|
791
|
+
function On(e, t) {
|
|
739
792
|
let n = 0, r = t;
|
|
740
793
|
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
741
794
|
let i = r;
|
|
@@ -745,46 +798,46 @@ function Tn(e, t) {
|
|
|
745
798
|
if (t === n) {
|
|
746
799
|
let t = e.substring(r, a);
|
|
747
800
|
return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
|
|
748
|
-
html: `<code>${
|
|
801
|
+
html: `<code>${W(t)}</code>`,
|
|
749
802
|
end: i
|
|
750
803
|
};
|
|
751
804
|
}
|
|
752
805
|
} else i++;
|
|
753
806
|
return null;
|
|
754
807
|
}
|
|
755
|
-
function
|
|
756
|
-
let n =
|
|
808
|
+
function kn(e, t) {
|
|
809
|
+
let n = jn(e, t + 1);
|
|
757
810
|
if (n === -1) return null;
|
|
758
811
|
let r = t + 2;
|
|
759
812
|
if (e[n + 1] !== "(") return null;
|
|
760
|
-
let i = n + 2, a =
|
|
813
|
+
let i = n + 2, a = Mn(e, i - 1);
|
|
761
814
|
if (a === -1) return null;
|
|
762
|
-
let o = e.substring(r, n), { url: s, title: c } =
|
|
763
|
-
if (
|
|
815
|
+
let o = e.substring(r, n), { url: s, title: c } = Nn(e.substring(i, a));
|
|
816
|
+
if (oe(s)) {
|
|
764
817
|
let e = o || c;
|
|
765
818
|
return {
|
|
766
|
-
html: `<video src="${
|
|
819
|
+
html: `<video src="${W(s)}"${e ? ` data-name="${W(e)}"` : ""} data-url="${W(s)}" controls></video>`,
|
|
767
820
|
end: a + 1
|
|
768
821
|
};
|
|
769
822
|
}
|
|
770
|
-
let l = c === void 0 ? "" : ` title="${
|
|
823
|
+
let l = c === void 0 ? "" : ` title="${W(c)}"`;
|
|
771
824
|
return {
|
|
772
|
-
html: `<img src="${
|
|
825
|
+
html: `<img src="${W(s)}" alt="${W(o)}"${l}>`,
|
|
773
826
|
end: a + 1
|
|
774
827
|
};
|
|
775
828
|
}
|
|
776
|
-
function
|
|
777
|
-
let n = t + 1, r =
|
|
829
|
+
function An(e, t) {
|
|
830
|
+
let n = t + 1, r = jn(e, t);
|
|
778
831
|
if (r === -1 || e[r + 1] !== "(") return null;
|
|
779
|
-
let i = r + 2, a =
|
|
832
|
+
let i = r + 2, a = Mn(e, r + 1);
|
|
780
833
|
if (a === -1) return null;
|
|
781
|
-
let o = e.substring(n, r), { url: s, title: c } =
|
|
834
|
+
let o = e.substring(n, r), { url: s, title: c } = Nn(e.substring(i, a)), l = c === void 0 ? "" : ` title="${W(c)}"`;
|
|
782
835
|
return {
|
|
783
|
-
html: `<a href="${
|
|
836
|
+
html: `<a href="${W(s)}"${l}>${K(o)}</a>`,
|
|
784
837
|
end: a + 1
|
|
785
838
|
};
|
|
786
839
|
}
|
|
787
|
-
function
|
|
840
|
+
function jn(e, t) {
|
|
788
841
|
let n = 0;
|
|
789
842
|
for (let r = t; r < e.length; r++) {
|
|
790
843
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -795,7 +848,7 @@ function On(e, t) {
|
|
|
795
848
|
}
|
|
796
849
|
return -1;
|
|
797
850
|
}
|
|
798
|
-
function
|
|
851
|
+
function Mn(e, t) {
|
|
799
852
|
let n = 0;
|
|
800
853
|
for (let r = t; r < e.length; r++) {
|
|
801
854
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -806,7 +859,7 @@ function kn(e, t) {
|
|
|
806
859
|
}
|
|
807
860
|
return -1;
|
|
808
861
|
}
|
|
809
|
-
function
|
|
862
|
+
function Nn(e) {
|
|
810
863
|
e = e.trim();
|
|
811
864
|
let t, n;
|
|
812
865
|
if (e.startsWith("<")) {
|
|
@@ -836,7 +889,7 @@ function An(e) {
|
|
|
836
889
|
title: r
|
|
837
890
|
};
|
|
838
891
|
}
|
|
839
|
-
function
|
|
892
|
+
function q(e, t, n, r, i) {
|
|
840
893
|
let a = n.length, o = t + a;
|
|
841
894
|
if (o >= e.length || e[o] === " " || e[o] === " ") return null;
|
|
842
895
|
let s = o;
|
|
@@ -860,7 +913,7 @@ function K(e, t, n, r, i) {
|
|
|
860
913
|
continue;
|
|
861
914
|
}
|
|
862
915
|
return {
|
|
863
|
-
html: r +
|
|
916
|
+
html: r + K(t) + i,
|
|
864
917
|
end: s + a
|
|
865
918
|
};
|
|
866
919
|
}
|
|
@@ -868,13 +921,13 @@ function K(e, t, n, r, i) {
|
|
|
868
921
|
}
|
|
869
922
|
return null;
|
|
870
923
|
}
|
|
871
|
-
var
|
|
872
|
-
function
|
|
924
|
+
var Pn = new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
|
|
925
|
+
function Fn(e) {
|
|
873
926
|
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
874
927
|
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
875
|
-
return t ?
|
|
928
|
+
return t ? Pn.has(t[1].toLowerCase()) : !1;
|
|
876
929
|
}
|
|
877
|
-
function
|
|
930
|
+
function J(e) {
|
|
878
931
|
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
879
932
|
for (; r < t.length;) {
|
|
880
933
|
let e = t[r];
|
|
@@ -933,7 +986,7 @@ function q(e) {
|
|
|
933
986
|
continue;
|
|
934
987
|
}
|
|
935
988
|
}
|
|
936
|
-
let s =
|
|
989
|
+
let s = In(t, r);
|
|
937
990
|
if (s) {
|
|
938
991
|
n.push(s.token), r = s.nextLine, i = !1;
|
|
939
992
|
continue;
|
|
@@ -989,7 +1042,7 @@ function q(e) {
|
|
|
989
1042
|
}), i = !1;
|
|
990
1043
|
continue;
|
|
991
1044
|
}
|
|
992
|
-
if (
|
|
1045
|
+
if (Fn(e)) {
|
|
993
1046
|
let e = [];
|
|
994
1047
|
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
995
1048
|
n.push({
|
|
@@ -1001,7 +1054,7 @@ function q(e) {
|
|
|
1001
1054
|
let l = [e];
|
|
1002
1055
|
for (r++; r < t.length;) {
|
|
1003
1056
|
let e = t[r];
|
|
1004
|
-
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) ||
|
|
1057
|
+
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Fn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
|
|
1005
1058
|
l.push(e), r++;
|
|
1006
1059
|
}
|
|
1007
1060
|
n.push({
|
|
@@ -1011,15 +1064,15 @@ function q(e) {
|
|
|
1011
1064
|
}
|
|
1012
1065
|
return n;
|
|
1013
1066
|
}
|
|
1014
|
-
function
|
|
1067
|
+
function In(e, t) {
|
|
1015
1068
|
if (t + 1 >= e.length) return null;
|
|
1016
1069
|
let n = e[t], r = e[t + 1];
|
|
1017
1070
|
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1018
|
-
let i =
|
|
1071
|
+
let i = Y(n), a = Ln(r), o = [], s = t + 2;
|
|
1019
1072
|
for (; s < e.length;) {
|
|
1020
1073
|
let t = e[s];
|
|
1021
1074
|
if (!t.includes("|")) break;
|
|
1022
|
-
o.push(
|
|
1075
|
+
o.push(Y(t)), s++;
|
|
1023
1076
|
}
|
|
1024
1077
|
return {
|
|
1025
1078
|
token: {
|
|
@@ -1031,37 +1084,37 @@ function Nn(e, t) {
|
|
|
1031
1084
|
nextLine: s
|
|
1032
1085
|
};
|
|
1033
1086
|
}
|
|
1034
|
-
function
|
|
1087
|
+
function Y(e) {
|
|
1035
1088
|
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1036
1089
|
for (let e = 0; e < r.length; e++) r[e] === "\\" && e + 1 < r.length && r[e + 1] === "|" ? (a += "|", e++) : r[e] === "|" ? (i.push(a.trim()), a = "") : a += r[e];
|
|
1037
1090
|
return i.push(a.trim()), i;
|
|
1038
1091
|
}
|
|
1039
|
-
function
|
|
1040
|
-
return
|
|
1092
|
+
function Ln(e) {
|
|
1093
|
+
return Y(e).map((e) => {
|
|
1041
1094
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1042
1095
|
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1043
1096
|
});
|
|
1044
1097
|
}
|
|
1045
|
-
function
|
|
1098
|
+
function Rn(e) {
|
|
1046
1099
|
let t = "", n = 0;
|
|
1047
1100
|
for (; n < e.length;) {
|
|
1048
1101
|
let r = e[n];
|
|
1049
1102
|
switch (r.type) {
|
|
1050
1103
|
case "heading": {
|
|
1051
1104
|
let e = r;
|
|
1052
|
-
t += `<h${e.level}>${
|
|
1105
|
+
t += `<h${e.level}>${K(e.content)}</h${e.level}>`, n++;
|
|
1053
1106
|
break;
|
|
1054
1107
|
}
|
|
1055
1108
|
case "paragraph":
|
|
1056
|
-
t += `<p>${
|
|
1109
|
+
t += `<p>${K(r.content)}</p>`, n++;
|
|
1057
1110
|
break;
|
|
1058
1111
|
case "codeBlock": {
|
|
1059
|
-
let e = r, i = e.language ? ` data-language="${
|
|
1060
|
-
t += `<pre><code${i}>${
|
|
1112
|
+
let e = r, i = e.language ? ` data-language="${W(e.language)}"` : "";
|
|
1113
|
+
t += `<pre><code${i}>${W(e.code)}</code></pre>`, n++;
|
|
1061
1114
|
break;
|
|
1062
1115
|
}
|
|
1063
1116
|
case "blockquote": {
|
|
1064
|
-
let e =
|
|
1117
|
+
let e = Rn(J(r.content));
|
|
1065
1118
|
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1066
1119
|
break;
|
|
1067
1120
|
}
|
|
@@ -1069,12 +1122,12 @@ function Y(e) {
|
|
|
1069
1122
|
t += "<hr>", n++;
|
|
1070
1123
|
break;
|
|
1071
1124
|
case "listItem": {
|
|
1072
|
-
let r =
|
|
1125
|
+
let r = zn(e, n);
|
|
1073
1126
|
t += r.html, n = r.nextIndex;
|
|
1074
1127
|
break;
|
|
1075
1128
|
}
|
|
1076
1129
|
case "table":
|
|
1077
|
-
t +=
|
|
1130
|
+
t += Vn(r), n++;
|
|
1078
1131
|
break;
|
|
1079
1132
|
case "rawHtml":
|
|
1080
1133
|
t += r.content, n++;
|
|
@@ -1084,10 +1137,10 @@ function Y(e) {
|
|
|
1084
1137
|
}
|
|
1085
1138
|
return t;
|
|
1086
1139
|
}
|
|
1087
|
-
function
|
|
1140
|
+
function zn(e, t) {
|
|
1088
1141
|
let n = "", r = t, i = null;
|
|
1089
1142
|
for (; r < e.length && e[r].type === "listItem";) {
|
|
1090
|
-
let t = e[r], a =
|
|
1143
|
+
let t = e[r], a = Bn(t.listType);
|
|
1091
1144
|
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1092
1145
|
if (a === "ordered") {
|
|
1093
1146
|
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
@@ -1097,11 +1150,11 @@ function Fn(e, t) {
|
|
|
1097
1150
|
}
|
|
1098
1151
|
if (t.listType === "task") {
|
|
1099
1152
|
let e = t.checked ? " checked" : "";
|
|
1100
|
-
n += `<li><input type="checkbox" disabled${e}><p>${
|
|
1101
|
-
} else n += `<li><p>${
|
|
1153
|
+
n += `<li><input type="checkbox" disabled${e}><p>${K(t.content)}</p>`;
|
|
1154
|
+
} else n += `<li><p>${K(t.content)}</p>`;
|
|
1102
1155
|
if (t.childContent) {
|
|
1103
|
-
let e =
|
|
1104
|
-
n +=
|
|
1156
|
+
let e = J(t.childContent);
|
|
1157
|
+
n += Rn(e);
|
|
1105
1158
|
}
|
|
1106
1159
|
n += "</li>", r++;
|
|
1107
1160
|
}
|
|
@@ -1110,16 +1163,16 @@ function Fn(e, t) {
|
|
|
1110
1163
|
nextIndex: r
|
|
1111
1164
|
};
|
|
1112
1165
|
}
|
|
1113
|
-
function
|
|
1166
|
+
function Bn(e) {
|
|
1114
1167
|
return e === "ordered" ? "ordered" : "bullet";
|
|
1115
1168
|
}
|
|
1116
|
-
function
|
|
1169
|
+
function Vn(e) {
|
|
1117
1170
|
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1118
1171
|
if (!n) {
|
|
1119
1172
|
t += "<thead><tr>";
|
|
1120
1173
|
for (let n = 0; n < r; n++) {
|
|
1121
1174
|
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1122
|
-
t += `<th${i}>${
|
|
1175
|
+
t += `<th${i}>${K(e.headers[n])}</th>`;
|
|
1123
1176
|
}
|
|
1124
1177
|
t += "</tr></thead>";
|
|
1125
1178
|
}
|
|
@@ -1129,7 +1182,7 @@ function Ln(e) {
|
|
|
1129
1182
|
t += "<tr>";
|
|
1130
1183
|
for (let i = 0; i < r; i++) {
|
|
1131
1184
|
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1132
|
-
t += `<td${o}>${
|
|
1185
|
+
t += `<td${o}>${K(r)}</td>`;
|
|
1133
1186
|
}
|
|
1134
1187
|
t += "</tr>";
|
|
1135
1188
|
}
|
|
@@ -1137,37 +1190,38 @@ function Ln(e) {
|
|
|
1137
1190
|
}
|
|
1138
1191
|
return t += "</table>", t;
|
|
1139
1192
|
}
|
|
1140
|
-
function
|
|
1141
|
-
return
|
|
1193
|
+
function Hn(e) {
|
|
1194
|
+
return Rn(J(e));
|
|
1142
1195
|
}
|
|
1143
1196
|
//#endregion
|
|
1144
1197
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1145
|
-
function
|
|
1146
|
-
return
|
|
1198
|
+
function Un(e) {
|
|
1199
|
+
return Hn(e);
|
|
1147
1200
|
}
|
|
1148
|
-
function
|
|
1149
|
-
return
|
|
1201
|
+
function Wn(e, t) {
|
|
1202
|
+
return U(Un(e), t);
|
|
1150
1203
|
}
|
|
1151
1204
|
//#endregion
|
|
1152
1205
|
//#region src/editor/managers/ExportManager.ts
|
|
1153
|
-
var
|
|
1206
|
+
var Gn = class {
|
|
1207
|
+
editor;
|
|
1154
1208
|
constructor(e) {
|
|
1155
1209
|
this.editor = e;
|
|
1156
1210
|
}
|
|
1157
1211
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
1158
|
-
return
|
|
1212
|
+
return ge(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
1159
1213
|
}
|
|
1160
1214
|
blocksToFullHTML(e = this.editor.document) {
|
|
1161
|
-
return
|
|
1215
|
+
return Tt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
1162
1216
|
}
|
|
1163
1217
|
tryParseHTMLToBlocks(e) {
|
|
1164
|
-
return
|
|
1218
|
+
return U(e, this.editor.pmSchema);
|
|
1165
1219
|
}
|
|
1166
1220
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1167
|
-
return
|
|
1221
|
+
return we(e, this.editor.pmSchema, this.editor, {});
|
|
1168
1222
|
}
|
|
1169
1223
|
tryParseMarkdownToBlocks(e) {
|
|
1170
|
-
return
|
|
1224
|
+
return Wn(e, this.editor.pmSchema);
|
|
1171
1225
|
}
|
|
1172
1226
|
pasteHTML(e, t = !1) {
|
|
1173
1227
|
let n = e;
|
|
@@ -1181,564 +1235,216 @@ var Vn = class {
|
|
|
1181
1235
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
1182
1236
|
}
|
|
1183
1237
|
pasteMarkdown(e) {
|
|
1184
|
-
let t =
|
|
1238
|
+
let t = Un(e);
|
|
1185
1239
|
return this.pasteHTML(t);
|
|
1186
1240
|
}
|
|
1187
1241
|
};
|
|
1188
1242
|
//#endregion
|
|
1189
1243
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1190
|
-
function
|
|
1191
|
-
let { bnBlock: t } =
|
|
1192
|
-
return
|
|
1193
|
-
block:
|
|
1194
|
-
prevBlock:
|
|
1195
|
-
nextBlock:
|
|
1196
|
-
parentBlock:
|
|
1244
|
+
function Kn(e) {
|
|
1245
|
+
let { bnBlock: t } = _(e), n = e.doc.resolve(t.beforePos), r = n.nodeBefore, i = e.doc.resolve(t.afterPos).nodeAfter, a;
|
|
1246
|
+
return n.depth > 1 && (a = n.node(), a.type.isInGroup("bnBlock") || (a = n.node(n.depth - 1))), {
|
|
1247
|
+
block: C(t.node, e.doc),
|
|
1248
|
+
prevBlock: r === null ? void 0 : C(r, e.doc),
|
|
1249
|
+
nextBlock: i === null ? void 0 : C(i, e.doc),
|
|
1250
|
+
parentBlock: a === void 0 ? void 0 : C(a, e.doc)
|
|
1197
1251
|
};
|
|
1198
1252
|
}
|
|
1199
|
-
function
|
|
1200
|
-
let
|
|
1201
|
-
if (!
|
|
1202
|
-
let
|
|
1203
|
-
if (
|
|
1204
|
-
let
|
|
1205
|
-
if (
|
|
1206
|
-
|
|
1253
|
+
function qn(t, r, a = "start") {
|
|
1254
|
+
let o = typeof r == "string" ? r : r.id, s = n(i(t.doc)), l = x(o, t.doc);
|
|
1255
|
+
if (!l) throw Error(`Block with ID ${o} not found`);
|
|
1256
|
+
let u = S(l), d = s.blockSchema[u.blockNoteType].content;
|
|
1257
|
+
if (u.isBlockContainer) {
|
|
1258
|
+
let e = u.blockContent;
|
|
1259
|
+
if (d === "none") {
|
|
1260
|
+
t.setSelection(A.create(t.doc, e.beforePos));
|
|
1207
1261
|
return;
|
|
1208
1262
|
}
|
|
1209
|
-
if (
|
|
1210
|
-
else if (
|
|
1211
|
-
else throw new
|
|
1212
|
-
} else
|
|
1263
|
+
if (d === "inline" || d === "plain") a === "start" ? t.setSelection(M.create(t.doc, e.beforePos + 1)) : t.setSelection(M.create(t.doc, e.afterPos - 1));
|
|
1264
|
+
else if (d === "table") a === "start" ? t.setSelection(M.create(t.doc, e.beforePos + 4)) : t.setSelection(M.create(t.doc, e.afterPos - 4));
|
|
1265
|
+
else throw new c(d);
|
|
1266
|
+
} else qn(t, e(a === "start" ? u.childContainer.node.firstChild : u.childContainer.node.lastChild, t.doc), a);
|
|
1213
1267
|
}
|
|
1214
1268
|
//#endregion
|
|
1215
|
-
//#region src/
|
|
1216
|
-
var
|
|
1269
|
+
//#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
|
|
1270
|
+
var Jn = [
|
|
1271
|
+
"vscode-editor-data",
|
|
1272
|
+
"blocknote/html",
|
|
1273
|
+
"text/markdown",
|
|
1274
|
+
"text/html",
|
|
1275
|
+
"text/plain",
|
|
1276
|
+
"Files"
|
|
1277
|
+
];
|
|
1217
1278
|
//#endregion
|
|
1218
|
-
//#region src/
|
|
1219
|
-
function
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
let i = 0;
|
|
1223
|
-
for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
|
|
1224
|
-
if (i > 0) {
|
|
1225
|
-
t.push(n.join(""));
|
|
1226
|
-
let a = parseInt(e.substring(r, r + i), 10);
|
|
1227
|
-
for (; a-- > 0;) n.pop();
|
|
1228
|
-
r += i;
|
|
1229
|
-
} else n.push(e[r]), r++;
|
|
1230
|
-
}
|
|
1231
|
-
return t;
|
|
1232
|
-
}
|
|
1233
|
-
var Kn = new Set(Gn(Wn)), qn = new Set(["localhost"]), Jn = /[.,;:!?"']+$/, Yn = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Xn = /mailto:[^\s]+/g, Zn = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Qn = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1234
|
-
function $n(e) {
|
|
1235
|
-
let t = e, n = !0;
|
|
1236
|
-
for (; n;) {
|
|
1237
|
-
n = !1;
|
|
1238
|
-
let e = t;
|
|
1239
|
-
t = t.replace(Jn, ""), t !== e && (n = !0);
|
|
1240
|
-
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1241
|
-
let i = er(t, e);
|
|
1242
|
-
if (er(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1243
|
-
else break;
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
return t;
|
|
1247
|
-
}
|
|
1248
|
-
function er(e, t) {
|
|
1249
|
-
let n = 0;
|
|
1250
|
-
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1251
|
-
return n;
|
|
1252
|
-
}
|
|
1253
|
-
function tr(e) {
|
|
1254
|
-
let t = e.split(".");
|
|
1255
|
-
return t[t.length - 1].toLowerCase();
|
|
1279
|
+
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1280
|
+
function Yn(e, t) {
|
|
1281
|
+
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1282
|
+
return e === t;
|
|
1256
1283
|
}
|
|
1257
|
-
function
|
|
1258
|
-
let
|
|
1259
|
-
|
|
1284
|
+
function Xn(e, t) {
|
|
1285
|
+
let n = e.split("/"), r = t.split("/");
|
|
1286
|
+
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1287
|
+
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1288
|
+
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1260
1289
|
}
|
|
1261
|
-
function
|
|
1262
|
-
|
|
1290
|
+
function Zn(e, t, n, r = "after") {
|
|
1291
|
+
let i;
|
|
1292
|
+
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1263
1293
|
}
|
|
1264
|
-
function
|
|
1265
|
-
if (!
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1294
|
+
async function Qn(t, n) {
|
|
1295
|
+
if (!n.uploadFile) {
|
|
1296
|
+
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
let r = "dataTransfer" in t ? t.dataTransfer : t.clipboardData;
|
|
1300
|
+
if (r === null) return;
|
|
1301
|
+
let i = null;
|
|
1302
|
+
for (let e of Jn) if (r.types.includes(e)) {
|
|
1303
|
+
i = e;
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1306
|
+
if (i !== "Files") return;
|
|
1307
|
+
let a = r.items;
|
|
1308
|
+
if (a) {
|
|
1309
|
+
t.preventDefault();
|
|
1310
|
+
for (let r = 0; r < a.length; r++) {
|
|
1311
|
+
let i = "file";
|
|
1312
|
+
for (let e of Object.values(n.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
1313
|
+
let n = t.startsWith("."), o = a[r].getAsFile();
|
|
1314
|
+
if (o && (!n && o.type && Xn(a[r].type, t) || n && Yn("." + o.name.split(".").pop(), t))) {
|
|
1315
|
+
i = e.config.type;
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
let o = a[r].getAsFile();
|
|
1320
|
+
if (o) {
|
|
1321
|
+
let r = {
|
|
1322
|
+
type: i,
|
|
1323
|
+
props: { name: o.name }
|
|
1324
|
+
}, a;
|
|
1325
|
+
if (t.type === "paste") {
|
|
1326
|
+
let e = n.getTextCursorPosition().block;
|
|
1327
|
+
a = Zn(n, e, r);
|
|
1328
|
+
} else if (t.type === "drop") {
|
|
1329
|
+
let i = {
|
|
1330
|
+
left: t.clientX,
|
|
1331
|
+
top: t.clientY
|
|
1332
|
+
}, o = n.prosemirrorView.posAtCoords(i);
|
|
1333
|
+
if (!o) return;
|
|
1334
|
+
a = n.transact((t) => {
|
|
1335
|
+
let a = e(l(t, o.pos).bnBlock.node, t.doc), s = (n.domElement?.querySelector(`[data-id="${a}"]`))?.getBoundingClientRect();
|
|
1336
|
+
return Zn(n, n.getBlock(a), r, s && (s.top + s.bottom) / 2 > i.top ? "before" : "after");
|
|
1337
|
+
});
|
|
1338
|
+
} else return;
|
|
1339
|
+
let s = await n.uploadFile(o, a), c = typeof s == "string" ? { props: { url: s } } : { ...s };
|
|
1340
|
+
n.updateBlock(a, c);
|
|
1341
|
+
}
|
|
1306
1342
|
}
|
|
1307
|
-
let a = rr(t, e.type, n);
|
|
1308
|
-
o.push({
|
|
1309
|
-
type: e.type,
|
|
1310
|
-
value: t,
|
|
1311
|
-
isLink: !0,
|
|
1312
|
-
href: a,
|
|
1313
|
-
start: r,
|
|
1314
|
-
end: i
|
|
1315
|
-
});
|
|
1316
1343
|
}
|
|
1317
|
-
return o;
|
|
1318
1344
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
[
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1345
|
+
//#endregion
|
|
1346
|
+
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1347
|
+
var $n = (e) => D.create({
|
|
1348
|
+
name: "dropFile",
|
|
1349
|
+
addProseMirrorPlugins() {
|
|
1350
|
+
return [new j({ props: { handleDOMEvents: { drop(t, n) {
|
|
1351
|
+
if (!e.isEditable) return;
|
|
1352
|
+
let r = null;
|
|
1353
|
+
for (let e of Jn) if (n.dataTransfer.types.includes(e)) {
|
|
1354
|
+
r = e;
|
|
1355
|
+
break;
|
|
1356
|
+
}
|
|
1357
|
+
return r === null ? !0 : r === "Files" ? (Qn(n, e), !0) : !1;
|
|
1358
|
+
} } } })];
|
|
1332
1359
|
}
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1360
|
+
}), er = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, tr = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, nr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, rr = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, ir = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, ar = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, or = /\n{2} {0,3}-{2,48}\n{2}/, sr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, cr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, lr = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, ur = /^\s*\|(.+\|)+\s*$/m, dr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, fr = /^\s*\|(.+\|)+\s*$/m, pr = (e) => er.test(e) || tr.test(e) || nr.test(e) || rr.test(e) || ir.test(e) || ar.test(e) || or.test(e) || sr.test(e) || cr.test(e) || lr.test(e) || ur.test(e) || dr.test(e) || fr.test(e);
|
|
1361
|
+
//#endregion
|
|
1362
|
+
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1363
|
+
function mr(e, t) {
|
|
1364
|
+
let { schema: n } = t.state;
|
|
1365
|
+
if (!e.clipboardData) return !1;
|
|
1366
|
+
let r = e.clipboardData.getData("text/plain");
|
|
1367
|
+
if (!r || !n.nodes.codeBlock) return !1;
|
|
1368
|
+
let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
|
|
1369
|
+
return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
|
|
1370
|
+
}
|
|
1371
|
+
//#endregion
|
|
1372
|
+
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1373
|
+
function hr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1374
|
+
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1375
|
+
let n = e.clipboardData?.getData("text/plain");
|
|
1376
|
+
if (n) return t.pasteText(n), !0;
|
|
1377
|
+
}
|
|
1378
|
+
let i;
|
|
1379
|
+
for (let t of Jn) if (e.clipboardData.types.includes(t)) {
|
|
1380
|
+
i = t;
|
|
1381
|
+
break;
|
|
1382
|
+
}
|
|
1383
|
+
if (!i) return !0;
|
|
1384
|
+
if (i === "vscode-editor-data") {
|
|
1385
|
+
if (mr(e, t.prosemirrorView)) return !0;
|
|
1386
|
+
i = "text/plain";
|
|
1387
|
+
}
|
|
1388
|
+
if (i === "Files") return Qn(e, t), !0;
|
|
1389
|
+
let a = e.clipboardData.getData(i);
|
|
1390
|
+
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1391
|
+
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1392
|
+
if (n) {
|
|
1393
|
+
let n = e.clipboardData.getData("text/plain");
|
|
1394
|
+
if (pr(n)) return t.pasteMarkdown(n), !0;
|
|
1336
1395
|
}
|
|
1337
|
-
return
|
|
1396
|
+
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1338
1397
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1398
|
+
var gr = (e, t) => D.create({
|
|
1399
|
+
name: "pasteFromClipboard",
|
|
1400
|
+
addProseMirrorPlugins() {
|
|
1401
|
+
return [new j({ props: { handleDOMEvents: { paste(n, r) {
|
|
1402
|
+
if (r.preventDefault(), e.isEditable) return t({
|
|
1403
|
+
event: r,
|
|
1404
|
+
editor: e,
|
|
1405
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => hr({
|
|
1406
|
+
event: r,
|
|
1407
|
+
editor: e,
|
|
1408
|
+
prioritizeMarkdownOverHTML: t,
|
|
1409
|
+
plainTextAsMarkdown: n
|
|
1410
|
+
})
|
|
1411
|
+
});
|
|
1412
|
+
} } } })];
|
|
1345
1413
|
}
|
|
1346
|
-
|
|
1414
|
+
});
|
|
1415
|
+
//#endregion
|
|
1416
|
+
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1417
|
+
function _r(e, t, n) {
|
|
1418
|
+
let r = !1, i = e.state.selection instanceof F;
|
|
1419
|
+
if (!i) {
|
|
1420
|
+
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
1421
|
+
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
1422
|
+
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
1423
|
+
}
|
|
1424
|
+
let a, o = ge(e.state.schema, n);
|
|
1425
|
+
if (i) {
|
|
1426
|
+
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
1427
|
+
let e = ee(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1428
|
+
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
1429
|
+
} else if (r) {
|
|
1430
|
+
let e = ae(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1431
|
+
a = o.exportInlineContent(e, {});
|
|
1432
|
+
} else {
|
|
1433
|
+
let e = Te(t);
|
|
1434
|
+
a = o.exportBlocks(e, {});
|
|
1435
|
+
}
|
|
1436
|
+
return a;
|
|
1347
1437
|
}
|
|
1348
|
-
function
|
|
1349
|
-
|
|
1438
|
+
function vr(e, t) {
|
|
1439
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new A(t.doc.resolve(e.state.selection.from - 1))));
|
|
1440
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = _r(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
|
|
1350
1441
|
return {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
href: rr(e, i, r),
|
|
1355
|
-
start: t,
|
|
1356
|
-
end: n
|
|
1442
|
+
clipboardHTML: n,
|
|
1443
|
+
externalHTML: i,
|
|
1444
|
+
markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : be(i)
|
|
1357
1445
|
};
|
|
1358
1446
|
}
|
|
1359
|
-
|
|
1360
|
-
return {
|
|
1361
|
-
type: "text",
|
|
1362
|
-
value: e,
|
|
1363
|
-
isLink: !1,
|
|
1364
|
-
href: e,
|
|
1365
|
-
start: t,
|
|
1366
|
-
end: n
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
//#endregion
|
|
1370
|
-
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
1371
|
-
var cr = "[\0- \xA0 -\u2029 ]", lr = new RegExp(cr), ur = RegExp(`${cr}$`), dr = new RegExp(cr, "g");
|
|
1372
|
-
//#endregion
|
|
1373
|
-
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
1374
|
-
function fr(e) {
|
|
1375
|
-
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
1376
|
-
}
|
|
1377
|
-
function pr(e) {
|
|
1378
|
-
return new ot({
|
|
1379
|
-
key: new st("autolink"),
|
|
1380
|
-
appendTransaction: (t, n, r) => {
|
|
1381
|
-
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
1382
|
-
if (!i || a) return;
|
|
1383
|
-
let { tr: o } = r;
|
|
1384
|
-
if (Ye(We(n.doc, [...t])).forEach(({ newRange: t }) => {
|
|
1385
|
-
let n = Ke(r.doc, t, (e) => e.isTextblock), i, a;
|
|
1386
|
-
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
1387
|
-
else if (n.length) {
|
|
1388
|
-
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
1389
|
-
if (!ur.test(e)) return;
|
|
1390
|
-
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
1391
|
-
}
|
|
1392
|
-
if (i && a) {
|
|
1393
|
-
let t = a.split(lr).filter(Boolean);
|
|
1394
|
-
if (t.length <= 0) return;
|
|
1395
|
-
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
1396
|
-
if (!n) return;
|
|
1397
|
-
let c = ar(n, e.defaultProtocol);
|
|
1398
|
-
if (!fr(c)) return;
|
|
1399
|
-
c.filter((e) => e.isLink).map((e) => ({
|
|
1400
|
-
...e,
|
|
1401
|
-
from: s + e.start + 1,
|
|
1402
|
-
to: s + e.end + 1
|
|
1403
|
-
})).filter((e) => r.schema.marks.code ? !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
|
|
1404
|
-
Ze(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
}), o.steps.length) return o;
|
|
1408
|
-
}
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
//#endregion
|
|
1412
|
-
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
1413
|
-
function mr(e) {
|
|
1414
|
-
return new ot({
|
|
1415
|
-
key: new st("handleClickLink"),
|
|
1416
|
-
props: { handleClick: (t, n, r) => {
|
|
1417
|
-
if (r.button !== 0 || !t.editable) return !1;
|
|
1418
|
-
let i = null;
|
|
1419
|
-
if (r.target instanceof HTMLAnchorElement && r.target.getAttribute("data-inline-content-type") === "link") i = r.target;
|
|
1420
|
-
else {
|
|
1421
|
-
let t = r.target;
|
|
1422
|
-
if (!t) return !1;
|
|
1423
|
-
let n = e.tiptapEditor.view.dom;
|
|
1424
|
-
i = t.closest("a[data-inline-content-type=\"link\"]"), i && !n.contains(i) && (i = null);
|
|
1425
|
-
}
|
|
1426
|
-
if (!i) return !1;
|
|
1427
|
-
if (e.onClick) {
|
|
1428
|
-
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
1429
|
-
return e.onClick(r, e.editor) ?? !0;
|
|
1430
|
-
}
|
|
1431
|
-
let a = Je(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
1432
|
-
return o ? (window.open(o, s), !0) : !1;
|
|
1433
|
-
} }
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
//#endregion
|
|
1437
|
-
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
1438
|
-
function hr(e) {
|
|
1439
|
-
return new ot({
|
|
1440
|
-
key: new st("handlePasteLink"),
|
|
1441
|
-
props: { handlePaste: (t, n, r) => {
|
|
1442
|
-
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
1443
|
-
if (c) return !1;
|
|
1444
|
-
let l = "";
|
|
1445
|
-
r.content.forEach((e) => {
|
|
1446
|
-
l += e.textContent;
|
|
1447
|
-
});
|
|
1448
|
-
let u = ir(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
1449
|
-
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
1450
|
-
} }
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
//#endregion
|
|
1454
|
-
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
1455
|
-
var Z = "https", gr = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
1456
|
-
function _r(e) {
|
|
1457
|
-
if (!e) return !0;
|
|
1458
|
-
let t = e.replace(dr, "");
|
|
1459
|
-
return gr.test(t);
|
|
1460
|
-
}
|
|
1461
|
-
function vr(e) {
|
|
1462
|
-
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
1463
|
-
if (t || n && !e.includes("@")) return !0;
|
|
1464
|
-
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
1465
|
-
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
1466
|
-
}
|
|
1467
|
-
var yr = k.create({
|
|
1468
|
-
name: "link",
|
|
1469
|
-
keepOnSplit: !1,
|
|
1470
|
-
exitable: !0,
|
|
1471
|
-
inclusive: !1,
|
|
1472
|
-
addOptions() {
|
|
1473
|
-
return {
|
|
1474
|
-
HTMLAttributes: {
|
|
1475
|
-
target: "_blank",
|
|
1476
|
-
rel: "noopener noreferrer nofollow",
|
|
1477
|
-
className: "bn-inline-content-section",
|
|
1478
|
-
"data-inline-content-type": "link"
|
|
1479
|
-
},
|
|
1480
|
-
editor: void 0,
|
|
1481
|
-
onClick: void 0,
|
|
1482
|
-
isValidLink: _r
|
|
1483
|
-
};
|
|
1484
|
-
},
|
|
1485
|
-
addAttributes() {
|
|
1486
|
-
return { href: {
|
|
1487
|
-
default: null,
|
|
1488
|
-
parseHTML(e) {
|
|
1489
|
-
return e.getAttribute("href");
|
|
1490
|
-
}
|
|
1491
|
-
} };
|
|
1492
|
-
},
|
|
1493
|
-
parseHTML() {
|
|
1494
|
-
let e = this.options.isValidLink;
|
|
1495
|
-
return [{
|
|
1496
|
-
tag: "a[href]",
|
|
1497
|
-
getAttrs: (t) => {
|
|
1498
|
-
let n = t.getAttribute("href");
|
|
1499
|
-
return !n || !e(n) ? !1 : null;
|
|
1500
|
-
}
|
|
1501
|
-
}];
|
|
1502
|
-
},
|
|
1503
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
1504
|
-
return this.options.isValidLink(e.href) ? [
|
|
1505
|
-
"a",
|
|
1506
|
-
tt(e, this.options.HTMLAttributes),
|
|
1507
|
-
0
|
|
1508
|
-
] : [
|
|
1509
|
-
"a",
|
|
1510
|
-
tt({
|
|
1511
|
-
...e,
|
|
1512
|
-
href: ""
|
|
1513
|
-
}, this.options.HTMLAttributes),
|
|
1514
|
-
0
|
|
1515
|
-
];
|
|
1516
|
-
},
|
|
1517
|
-
addPasteRules() {
|
|
1518
|
-
let e = this.options.isValidLink;
|
|
1519
|
-
return [et({
|
|
1520
|
-
find: (t) => {
|
|
1521
|
-
let n = [];
|
|
1522
|
-
if (t) {
|
|
1523
|
-
let r = ir(t, { defaultProtocol: Z }).filter((t) => t.isLink && e(t.value));
|
|
1524
|
-
for (let e of r) vr(e.value) && n.push({
|
|
1525
|
-
text: e.value,
|
|
1526
|
-
data: { href: e.href },
|
|
1527
|
-
index: e.start
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
return n;
|
|
1531
|
-
},
|
|
1532
|
-
type: this.type,
|
|
1533
|
-
getAttributes: (e) => ({ href: e.data?.href })
|
|
1534
|
-
})];
|
|
1535
|
-
},
|
|
1536
|
-
addProseMirrorPlugins() {
|
|
1537
|
-
let e = [];
|
|
1538
|
-
return e.push(pr({
|
|
1539
|
-
type: this.type,
|
|
1540
|
-
defaultProtocol: Z,
|
|
1541
|
-
validate: this.options.isValidLink,
|
|
1542
|
-
shouldAutoLink: vr
|
|
1543
|
-
})), e.push(mr({
|
|
1544
|
-
type: this.type,
|
|
1545
|
-
tiptapEditor: this.editor,
|
|
1546
|
-
editor: this.options.editor,
|
|
1547
|
-
onClick: this.options.onClick
|
|
1548
|
-
})), e.push(hr({
|
|
1549
|
-
editor: this.editor,
|
|
1550
|
-
defaultProtocol: Z,
|
|
1551
|
-
type: this.type,
|
|
1552
|
-
shouldAutoLink: vr,
|
|
1553
|
-
isValidLink: this.options.isValidLink
|
|
1554
|
-
})), e;
|
|
1555
|
-
}
|
|
1556
|
-
}), br = Me(({ editor: e, options: t }) => ({
|
|
1557
|
-
key: "link",
|
|
1558
|
-
tiptapExtensions: [yr.configure({
|
|
1559
|
-
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
1560
|
-
editor: e,
|
|
1561
|
-
onClick: t.onClick,
|
|
1562
|
-
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
1563
|
-
})]
|
|
1564
|
-
})), xr = [
|
|
1565
|
-
"vscode-editor-data",
|
|
1566
|
-
"blocknote/html",
|
|
1567
|
-
"text/markdown",
|
|
1568
|
-
"text/html",
|
|
1569
|
-
"text/plain",
|
|
1570
|
-
"Files"
|
|
1571
|
-
];
|
|
1572
|
-
//#endregion
|
|
1573
|
-
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1574
|
-
function Sr(e, t) {
|
|
1575
|
-
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1576
|
-
return e === t;
|
|
1577
|
-
}
|
|
1578
|
-
function Cr(e, t) {
|
|
1579
|
-
let n = e.split("/"), r = t.split("/");
|
|
1580
|
-
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1581
|
-
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1582
|
-
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1583
|
-
}
|
|
1584
|
-
function wr(e, t, n, r = "after") {
|
|
1585
|
-
let i;
|
|
1586
|
-
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1587
|
-
}
|
|
1588
|
-
async function Tr(e, t) {
|
|
1589
|
-
if (!t.uploadFile) {
|
|
1590
|
-
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1594
|
-
if (n === null) return;
|
|
1595
|
-
let r = null;
|
|
1596
|
-
for (let e of xr) if (n.types.includes(e)) {
|
|
1597
|
-
r = e;
|
|
1598
|
-
break;
|
|
1599
|
-
}
|
|
1600
|
-
if (r !== "Files") return;
|
|
1601
|
-
let i = n.items;
|
|
1602
|
-
if (i) {
|
|
1603
|
-
e.preventDefault();
|
|
1604
|
-
for (let n = 0; n < i.length; n++) {
|
|
1605
|
-
let r = "file";
|
|
1606
|
-
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
1607
|
-
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
1608
|
-
if (o && (!a && o.type && Cr(i[n].type, t) || a && Sr("." + o.name.split(".").pop(), t))) {
|
|
1609
|
-
r = e.config.type;
|
|
1610
|
-
break;
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
let a = i[n].getAsFile();
|
|
1614
|
-
if (a) {
|
|
1615
|
-
let n = {
|
|
1616
|
-
type: r,
|
|
1617
|
-
props: { name: a.name }
|
|
1618
|
-
}, i;
|
|
1619
|
-
if (e.type === "paste") {
|
|
1620
|
-
let e = t.getTextCursorPosition().block;
|
|
1621
|
-
i = wr(t, e, n);
|
|
1622
|
-
} else if (e.type === "drop") {
|
|
1623
|
-
let r = {
|
|
1624
|
-
left: e.clientX,
|
|
1625
|
-
top: e.clientY
|
|
1626
|
-
}, a = t.prosemirrorView.posAtCoords(r);
|
|
1627
|
-
if (!a) return;
|
|
1628
|
-
i = t.transact((e) => {
|
|
1629
|
-
let i = C(e.doc, a.pos), o = (t.domElement?.querySelector(`[data-id="${i.node.attrs.id}"]`))?.getBoundingClientRect();
|
|
1630
|
-
return wr(t, t.getBlock(i.node.attrs.id), n, o && (o.top + o.bottom) / 2 > r.top ? "before" : "after");
|
|
1631
|
-
});
|
|
1632
|
-
} else return;
|
|
1633
|
-
let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
|
|
1634
|
-
t.updateBlock(i, s);
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
//#endregion
|
|
1640
|
-
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1641
|
-
var Er = (e) => O.create({
|
|
1642
|
-
name: "dropFile",
|
|
1643
|
-
addProseMirrorPlugins() {
|
|
1644
|
-
return [new N({ props: { handleDOMEvents: { drop(t, n) {
|
|
1645
|
-
if (!e.isEditable) return;
|
|
1646
|
-
let r = null;
|
|
1647
|
-
for (let e of xr) if (n.dataTransfer.types.includes(e)) {
|
|
1648
|
-
r = e;
|
|
1649
|
-
break;
|
|
1650
|
-
}
|
|
1651
|
-
return r === null ? !0 : r === "Files" ? (Tr(n, e), !0) : !1;
|
|
1652
|
-
} } } })];
|
|
1653
|
-
}
|
|
1654
|
-
}), Dr = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, Or = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, kr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, Ar = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, jr = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, Mr = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, Nr = /\n{2} {0,3}-{2,48}\n{2}/, Pr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, Fr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, Ir = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Lr = /^\s*\|(.+\|)+\s*$/m, Rr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, zr = /^\s*\|(.+\|)+\s*$/m, Br = (e) => Dr.test(e) || Or.test(e) || kr.test(e) || Ar.test(e) || jr.test(e) || Mr.test(e) || Nr.test(e) || Pr.test(e) || Fr.test(e) || Ir.test(e) || Lr.test(e) || Rr.test(e) || zr.test(e);
|
|
1655
|
-
//#endregion
|
|
1656
|
-
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1657
|
-
function Vr(e, t) {
|
|
1658
|
-
let { schema: n } = t.state;
|
|
1659
|
-
if (!e.clipboardData) return !1;
|
|
1660
|
-
let r = e.clipboardData.getData("text/plain");
|
|
1661
|
-
if (!r || !n.nodes.codeBlock) return !1;
|
|
1662
|
-
let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
|
|
1663
|
-
return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
|
|
1664
|
-
}
|
|
1665
|
-
//#endregion
|
|
1666
|
-
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1667
|
-
function Hr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1668
|
-
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1669
|
-
let n = e.clipboardData?.getData("text/plain");
|
|
1670
|
-
if (n) return t.pasteText(n), !0;
|
|
1671
|
-
}
|
|
1672
|
-
let i;
|
|
1673
|
-
for (let t of xr) if (e.clipboardData.types.includes(t)) {
|
|
1674
|
-
i = t;
|
|
1675
|
-
break;
|
|
1676
|
-
}
|
|
1677
|
-
if (!i) return !0;
|
|
1678
|
-
if (i === "vscode-editor-data") {
|
|
1679
|
-
if (Vr(e, t.prosemirrorView)) return !0;
|
|
1680
|
-
i = "text/plain";
|
|
1681
|
-
}
|
|
1682
|
-
if (i === "Files") return Tr(e, t), !0;
|
|
1683
|
-
let a = e.clipboardData.getData(i);
|
|
1684
|
-
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1685
|
-
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1686
|
-
if (n) {
|
|
1687
|
-
let n = e.clipboardData.getData("text/plain");
|
|
1688
|
-
if (Br(n)) return t.pasteMarkdown(n), !0;
|
|
1689
|
-
}
|
|
1690
|
-
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1691
|
-
}
|
|
1692
|
-
var Ur = (e, t) => O.create({
|
|
1693
|
-
name: "pasteFromClipboard",
|
|
1694
|
-
addProseMirrorPlugins() {
|
|
1695
|
-
return [new N({ props: { handleDOMEvents: { paste(n, r) {
|
|
1696
|
-
if (r.preventDefault(), e.isEditable) return t({
|
|
1697
|
-
event: r,
|
|
1698
|
-
editor: e,
|
|
1699
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Hr({
|
|
1700
|
-
event: r,
|
|
1701
|
-
editor: e,
|
|
1702
|
-
prioritizeMarkdownOverHTML: t,
|
|
1703
|
-
plainTextAsMarkdown: n
|
|
1704
|
-
})
|
|
1705
|
-
});
|
|
1706
|
-
} } } })];
|
|
1707
|
-
}
|
|
1708
|
-
});
|
|
1709
|
-
//#endregion
|
|
1710
|
-
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1711
|
-
function Wr(e, t, n) {
|
|
1712
|
-
let r = !1, i = e.state.selection instanceof it;
|
|
1713
|
-
if (!i) {
|
|
1714
|
-
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
1715
|
-
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
1716
|
-
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
1717
|
-
}
|
|
1718
|
-
let a, o = me(e.state.schema, n);
|
|
1719
|
-
if (i) {
|
|
1720
|
-
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
1721
|
-
let e = oe(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1722
|
-
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
1723
|
-
} else if (r) {
|
|
1724
|
-
let e = ae(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1725
|
-
a = o.exportInlineContent(e, {});
|
|
1726
|
-
} else {
|
|
1727
|
-
let e = xe(t);
|
|
1728
|
-
a = o.exportBlocks(e, {});
|
|
1729
|
-
}
|
|
1730
|
-
return a;
|
|
1731
|
-
}
|
|
1732
|
-
function Gr(e, t) {
|
|
1733
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new M(t.doc.resolve(e.state.selection.from - 1))));
|
|
1734
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = Wr(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
|
|
1735
|
-
return {
|
|
1736
|
-
clipboardHTML: n,
|
|
1737
|
-
externalHTML: i,
|
|
1738
|
-
markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : ye(i)
|
|
1739
|
-
};
|
|
1740
|
-
}
|
|
1741
|
-
var Kr = (e) => {
|
|
1447
|
+
var yr = (e) => {
|
|
1742
1448
|
if (e.state.selection.empty) return !0;
|
|
1743
1449
|
let t = window.getSelection();
|
|
1744
1450
|
if (t && !t.isCollapsed) {
|
|
@@ -1749,37 +1455,37 @@ var Kr = (e) => {
|
|
|
1749
1455
|
}
|
|
1750
1456
|
}
|
|
1751
1457
|
return !1;
|
|
1752
|
-
},
|
|
1458
|
+
}, br = (e, t, n) => {
|
|
1753
1459
|
n.preventDefault(), n.clipboardData.clearData();
|
|
1754
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1460
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = vr(t, e);
|
|
1755
1461
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
1756
|
-
},
|
|
1462
|
+
}, xr = (e) => D.create({
|
|
1757
1463
|
name: "copyToClipboard",
|
|
1758
1464
|
addProseMirrorPlugins() {
|
|
1759
|
-
return [new
|
|
1465
|
+
return [new j({ props: { handleDOMEvents: {
|
|
1760
1466
|
copy(t, n) {
|
|
1761
|
-
return
|
|
1467
|
+
return yr(t) || br(e, t, n), !0;
|
|
1762
1468
|
},
|
|
1763
1469
|
cut(t, n) {
|
|
1764
|
-
return
|
|
1470
|
+
return yr(t) ? !0 : (br(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
1765
1471
|
},
|
|
1766
1472
|
dragstart(t, n) {
|
|
1767
1473
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1768
|
-
e.transact((e) => e.setSelection(new
|
|
1769
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1474
|
+
e.transact((e) => e.setSelection(new A(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1475
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = vr(t, e);
|
|
1770
1476
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1771
1477
|
}
|
|
1772
1478
|
} } })];
|
|
1773
1479
|
}
|
|
1774
|
-
}),
|
|
1480
|
+
}), Sr = D.create({
|
|
1775
1481
|
name: "blockBackgroundColor",
|
|
1776
1482
|
addGlobalAttributes() {
|
|
1777
1483
|
return [{
|
|
1778
1484
|
types: ["tableCell", "tableHeader"],
|
|
1779
|
-
attributes: { backgroundColor:
|
|
1485
|
+
attributes: { backgroundColor: pe() }
|
|
1780
1486
|
}];
|
|
1781
1487
|
}
|
|
1782
|
-
}),
|
|
1488
|
+
}), Cr = O.create({
|
|
1783
1489
|
name: "hardBreak",
|
|
1784
1490
|
inline: !0,
|
|
1785
1491
|
group: "inline",
|
|
@@ -1790,33 +1496,33 @@ var Kr = (e) => {
|
|
|
1790
1496
|
return [{ tag: "br" }];
|
|
1791
1497
|
},
|
|
1792
1498
|
renderHTML({ HTMLAttributes: e }) {
|
|
1793
|
-
return ["br",
|
|
1499
|
+
return ["br", $e(this.options.HTMLAttributes, e)];
|
|
1794
1500
|
},
|
|
1795
1501
|
renderText() {
|
|
1796
1502
|
return "\n";
|
|
1797
1503
|
}
|
|
1798
|
-
}),
|
|
1504
|
+
}), wr = (e, t) => {
|
|
1799
1505
|
let n = e.resolve(t), r = n.depth - 1;
|
|
1800
1506
|
if (r < 1) return;
|
|
1801
1507
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
1802
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ? v(e.resolve(i)) :
|
|
1803
|
-
},
|
|
1508
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? v(e.resolve(i)) : wr(e, i);
|
|
1509
|
+
}, X = (e, t) => {
|
|
1804
1510
|
let n = e.resolve(t), r = n.index();
|
|
1805
1511
|
if (r === 0) return;
|
|
1806
1512
|
let i = n.posAtIndex(r - 1);
|
|
1807
1513
|
return v(e.resolve(i));
|
|
1808
|
-
},
|
|
1514
|
+
}, Z = (e, t) => {
|
|
1809
1515
|
let n = e.resolve(t), r = n.index();
|
|
1810
1516
|
if (r === n.node().childCount - 1) return;
|
|
1811
1517
|
let i = n.posAtIndex(r + 1);
|
|
1812
1518
|
return v(e.resolve(i));
|
|
1813
|
-
},
|
|
1519
|
+
}, Tr = (e, t) => {
|
|
1814
1520
|
for (; t.childContainer;) {
|
|
1815
1521
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1816
1522
|
t = v(e.resolve(r));
|
|
1817
1523
|
}
|
|
1818
1524
|
return t;
|
|
1819
|
-
},
|
|
1525
|
+
}, Er = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", Dr = (e, t, n, r) => {
|
|
1820
1526
|
if (!r.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);
|
|
1821
1527
|
if (r.childContainer) {
|
|
1822
1528
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -1830,12 +1536,12 @@ var Kr = (e) => {
|
|
|
1830
1536
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
1831
1537
|
}
|
|
1832
1538
|
return !0;
|
|
1833
|
-
},
|
|
1834
|
-
let r = v(t.doc.resolve(e)), i =
|
|
1539
|
+
}, Or = (e) => ({ state: t, dispatch: n }) => {
|
|
1540
|
+
let r = v(t.doc.resolve(e)), i = X(t.doc, r.bnBlock.beforePos);
|
|
1835
1541
|
if (!i) return !1;
|
|
1836
|
-
let a =
|
|
1837
|
-
return
|
|
1838
|
-
},
|
|
1542
|
+
let a = Tr(t.doc, i);
|
|
1543
|
+
return Er(a, r) ? Dr(t, n, a, r) : !1;
|
|
1544
|
+
}, kr = D.create({
|
|
1839
1545
|
priority: 50,
|
|
1840
1546
|
addKeyboardShortcuts() {
|
|
1841
1547
|
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
@@ -1844,8 +1550,8 @@ var Kr = (e) => {
|
|
|
1844
1550
|
() => t.command(({ state: e }) => {
|
|
1845
1551
|
let n = _(e);
|
|
1846
1552
|
if (!n.isBlockContainer) return !1;
|
|
1847
|
-
let
|
|
1848
|
-
return
|
|
1553
|
+
let i = e.selection.from === n.blockContent.beforePos + 1, a = n.blockContent.node.type.name === "paragraph";
|
|
1554
|
+
return i && !a ? t.command(r(n.bnBlock.beforePos, {
|
|
1849
1555
|
type: "paragraph",
|
|
1850
1556
|
props: {}
|
|
1851
1557
|
})) : !1;
|
|
@@ -1854,24 +1560,24 @@ var Kr = (e) => {
|
|
|
1854
1560
|
let n = _(e);
|
|
1855
1561
|
if (!n.isBlockContainer) return !1;
|
|
1856
1562
|
let { blockContent: r } = n;
|
|
1857
|
-
return e.selection.from === r.beforePos + 1 ?
|
|
1563
|
+
return e.selection.from === r.beforePos + 1 ? H(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1858
1564
|
}),
|
|
1859
1565
|
() => t.command(({ state: t }) => {
|
|
1860
1566
|
let n = _(t);
|
|
1861
1567
|
if (!n.isBlockContainer) return !1;
|
|
1862
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1568
|
+
let { bnBlock: r, blockContent: i } = n, a = X(t.doc, n.bnBlock.beforePos);
|
|
1863
1569
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1864
1570
|
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1865
|
-
return o && s ? e().command(
|
|
1571
|
+
return o && s ? e().command(Or(c)).scrollIntoView().run() : !1;
|
|
1866
1572
|
}),
|
|
1867
1573
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1868
1574
|
let r = _(e);
|
|
1869
1575
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1870
|
-
let i =
|
|
1576
|
+
let i = X(e.doc, r.bnBlock.beforePos);
|
|
1871
1577
|
if (!i || i.isBlockContainer) return !1;
|
|
1872
1578
|
if (n) {
|
|
1873
1579
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
1874
|
-
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(
|
|
1580
|
+
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(M.near(t.doc.resolve(n.pos + 1))), !0;
|
|
1875
1581
|
}
|
|
1876
1582
|
return !1;
|
|
1877
1583
|
}),
|
|
@@ -1881,15 +1587,15 @@ var Kr = (e) => {
|
|
|
1881
1587
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1882
1588
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1883
1589
|
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1884
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos),
|
|
1590
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), L(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(M.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(M.near(t.doc.resolve(o.pos))))), !0;
|
|
1885
1591
|
}),
|
|
1886
1592
|
() => t.command(({ state: t }) => {
|
|
1887
1593
|
let n = _(t);
|
|
1888
1594
|
if (!n.isBlockContainer) return !1;
|
|
1889
1595
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1890
|
-
let r =
|
|
1596
|
+
let r = X(t.doc, n.bnBlock.beforePos);
|
|
1891
1597
|
if (!r) return !1;
|
|
1892
|
-
let i =
|
|
1598
|
+
let i = Tr(t.doc, r);
|
|
1893
1599
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1894
1600
|
let a = e();
|
|
1895
1601
|
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1910,9 +1616,9 @@ var Kr = (e) => {
|
|
|
1910
1616
|
() => t.command(({ state: t }) => {
|
|
1911
1617
|
let n = _(t);
|
|
1912
1618
|
if (!n.isBlockContainer) return !1;
|
|
1913
|
-
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a =
|
|
1619
|
+
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = X(t.doc, n.bnBlock.beforePos);
|
|
1914
1620
|
if (a && r && i) {
|
|
1915
|
-
let r =
|
|
1621
|
+
let r = Tr(t.doc, a);
|
|
1916
1622
|
if (!r.isBlockContainer) return !1;
|
|
1917
1623
|
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1918
1624
|
from: n.bnBlock.beforePos,
|
|
@@ -1933,7 +1639,7 @@ var Kr = (e) => {
|
|
|
1933
1639
|
if (!s.isBlockContainer) return !1;
|
|
1934
1640
|
if (a && o) {
|
|
1935
1641
|
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
1936
|
-
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content ||
|
|
1642
|
+
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || w.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1937
1643
|
from: i.beforePos,
|
|
1938
1644
|
to: i.afterPos
|
|
1939
1645
|
} : {
|
|
@@ -1946,19 +1652,19 @@ var Kr = (e) => {
|
|
|
1946
1652
|
() => t.command(({ state: t }) => {
|
|
1947
1653
|
let n = _(t);
|
|
1948
1654
|
if (!n.isBlockContainer) return !1;
|
|
1949
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1655
|
+
let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1950
1656
|
if (!a || !a.isBlockContainer) return !1;
|
|
1951
1657
|
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1952
|
-
return o && s ? e().command(
|
|
1658
|
+
return o && s ? e().command(Or(c)).scrollIntoView().run() : !1;
|
|
1953
1659
|
}),
|
|
1954
1660
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1955
1661
|
let r = _(e);
|
|
1956
1662
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1957
|
-
let i =
|
|
1663
|
+
let i = Z(e.doc, r.bnBlock.beforePos);
|
|
1958
1664
|
if (!i || i.isBlockContainer) return !1;
|
|
1959
1665
|
if (n) {
|
|
1960
1666
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1961
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1667
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), L(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(M.near(t.doc.resolve(n.pos))), !0;
|
|
1962
1668
|
}
|
|
1963
1669
|
return !1;
|
|
1964
1670
|
}),
|
|
@@ -1970,7 +1676,7 @@ var Kr = (e) => {
|
|
|
1970
1676
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1971
1677
|
if (n) {
|
|
1972
1678
|
let e = o.pos === s - 1 ? s : o.pos + 1, n = v(t.doc.resolve(e));
|
|
1973
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos),
|
|
1679
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), L(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(M.near(t.doc.resolve(e)));
|
|
1974
1680
|
}
|
|
1975
1681
|
return !0;
|
|
1976
1682
|
}),
|
|
@@ -1980,14 +1686,14 @@ var Kr = (e) => {
|
|
|
1980
1686
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1981
1687
|
if (i && a) {
|
|
1982
1688
|
let i = (e, t) => {
|
|
1983
|
-
let n =
|
|
1689
|
+
let n = Z(e, t);
|
|
1984
1690
|
if (n) return n;
|
|
1985
|
-
let r =
|
|
1691
|
+
let r = wr(e, t);
|
|
1986
1692
|
if (r) return i(e, r.bnBlock.beforePos);
|
|
1987
1693
|
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1988
1694
|
if (!a || !a.isBlockContainer) return !1;
|
|
1989
1695
|
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
|
|
1990
|
-
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content ||
|
|
1696
|
+
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || w.empty).deleteRange({
|
|
1991
1697
|
from: a.bnBlock.beforePos,
|
|
1992
1698
|
to: a.bnBlock.afterPos
|
|
1993
1699
|
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
@@ -1998,7 +1704,7 @@ var Kr = (e) => {
|
|
|
1998
1704
|
let n = _(t);
|
|
1999
1705
|
if (!n.isBlockContainer) return !1;
|
|
2000
1706
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
2001
|
-
let r =
|
|
1707
|
+
let r = Z(t.doc, n.bnBlock.beforePos);
|
|
2002
1708
|
if (!r || !r.isBlockContainer) return !1;
|
|
2003
1709
|
let i = e();
|
|
2004
1710
|
if (r.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -2015,7 +1721,7 @@ var Kr = (e) => {
|
|
|
2015
1721
|
() => t.command(({ state: t }) => {
|
|
2016
1722
|
let n = _(t);
|
|
2017
1723
|
if (!n.isBlockContainer) return !1;
|
|
2018
|
-
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a =
|
|
1724
|
+
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
|
|
2019
1725
|
if (!a || !a.isBlockContainer) return !1;
|
|
2020
1726
|
if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
|
|
2021
1727
|
let t = a.bnBlock.node.lastChild.content;
|
|
@@ -2031,220 +1737,446 @@ var Kr = (e) => {
|
|
|
2031
1737
|
let n = _(e);
|
|
2032
1738
|
if (!n.isBlockContainer) return !1;
|
|
2033
1739
|
let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
|
|
2034
|
-
return o && s && c && a > 1 ?
|
|
1740
|
+
return o && s && c && a > 1 ? H(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
2035
1741
|
}),
|
|
2036
1742
|
() => t.command(({ state: t }) => {
|
|
2037
|
-
let r = _(t), i = this.options.editor.schema.
|
|
1743
|
+
let r = _(t), i = this.options.editor.schema.blockSpecs[r.blockNoteType]?.implementation?.meta?.hardBreakShortcut ?? "shift+enter";
|
|
2038
1744
|
if (i === "none") return !1;
|
|
2039
1745
|
if (i === "shift+enter" && e || i === "enter") {
|
|
2040
1746
|
let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
|
|
2041
1747
|
return n.insert(n.selection.head, n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
|
|
2042
1748
|
}
|
|
2043
|
-
return !1;
|
|
2044
|
-
}),
|
|
2045
|
-
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
2046
|
-
let r = _(e);
|
|
2047
|
-
if (!r.isBlockContainer) return !1;
|
|
2048
|
-
let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
|
|
2049
|
-
if (o && s && c) {
|
|
2050
|
-
let a = i.afterPos, o = a + 2;
|
|
2051
|
-
if (t) {
|
|
2052
|
-
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
2053
|
-
n.insert(a, t).setSelection(new
|
|
2054
|
-
}
|
|
2055
|
-
return !0;
|
|
1749
|
+
return !1;
|
|
1750
|
+
}),
|
|
1751
|
+
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1752
|
+
let r = _(e);
|
|
1753
|
+
if (!r.isBlockContainer) return !1;
|
|
1754
|
+
let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
|
|
1755
|
+
if (o && s && c) {
|
|
1756
|
+
let a = i.afterPos, o = a + 2;
|
|
1757
|
+
if (t) {
|
|
1758
|
+
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
1759
|
+
n.insert(a, t).setSelection(new M(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1760
|
+
}
|
|
1761
|
+
return !0;
|
|
1762
|
+
}
|
|
1763
|
+
return !1;
|
|
1764
|
+
}),
|
|
1765
|
+
() => t.command(({ state: e, chain: t }) => {
|
|
1766
|
+
let n = _(e);
|
|
1767
|
+
if (!n.isBlockContainer) return !1;
|
|
1768
|
+
let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
|
|
1769
|
+
return r.node.childCount === 0 ? !1 : (t().deleteSelection().command(g(e.selection.from, i, i)).scrollIntoView().run(), !0);
|
|
1770
|
+
})
|
|
1771
|
+
]);
|
|
1772
|
+
return {
|
|
1773
|
+
Backspace: e,
|
|
1774
|
+
Delete: t,
|
|
1775
|
+
Enter: () => n(),
|
|
1776
|
+
"Shift-Enter": () => n(!0),
|
|
1777
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(se)?.store.state || this.options.editor.getExtension(y)?.store.state !== void 0) ? !1 : Vt(this.options.editor),
|
|
1778
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(se)?.store.state || this.options.editor.getExtension(y)?.store.state !== void 0) ? !1 : Ut(this.options.editor),
|
|
1779
|
+
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1780
|
+
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1781
|
+
"Mod-z": () => this.options.editor.undo(),
|
|
1782
|
+
"Mod-y": () => this.options.editor.redo(),
|
|
1783
|
+
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
}), Ar = D.create({
|
|
1787
|
+
name: "textAlignment",
|
|
1788
|
+
addGlobalAttributes() {
|
|
1789
|
+
return [{
|
|
1790
|
+
types: ["tableCell", "tableHeader"],
|
|
1791
|
+
attributes: { textAlignment: {
|
|
1792
|
+
default: "left",
|
|
1793
|
+
parseHTML: (e) => e.getAttribute("data-text-alignment"),
|
|
1794
|
+
renderHTML: (e) => e.textAlignment === "left" ? {} : { "data-text-alignment": e.textAlignment }
|
|
1795
|
+
} }
|
|
1796
|
+
}];
|
|
1797
|
+
}
|
|
1798
|
+
}), jr = D.create({
|
|
1799
|
+
name: "blockTextColor",
|
|
1800
|
+
addGlobalAttributes() {
|
|
1801
|
+
return [{
|
|
1802
|
+
types: [
|
|
1803
|
+
"table",
|
|
1804
|
+
"tableCell",
|
|
1805
|
+
"tableHeader"
|
|
1806
|
+
],
|
|
1807
|
+
attributes: { textColor: fe() }
|
|
1808
|
+
}];
|
|
1809
|
+
}
|
|
1810
|
+
}), Mr = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
1811
|
+
//#endregion
|
|
1812
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
1813
|
+
function Nr(e) {
|
|
1814
|
+
let t = [], n = [], r = 0;
|
|
1815
|
+
for (; r < e.length;) {
|
|
1816
|
+
let i = 0;
|
|
1817
|
+
for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
|
|
1818
|
+
if (i > 0) {
|
|
1819
|
+
t.push(n.join(""));
|
|
1820
|
+
let a = parseInt(e.substring(r, r + i), 10);
|
|
1821
|
+
for (; a-- > 0;) n.pop();
|
|
1822
|
+
r += i;
|
|
1823
|
+
} else n.push(e[r]), r++;
|
|
1824
|
+
}
|
|
1825
|
+
return t;
|
|
1826
|
+
}
|
|
1827
|
+
var Pr = new Set(Nr(Mr)), Fr = new Set(["localhost"]), Ir = /[.,;:!?"']+$/, Lr = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Rr = /mailto:[^\s]+/g, zr = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Br = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1828
|
+
function Vr(e) {
|
|
1829
|
+
let t = e, n = !0;
|
|
1830
|
+
for (; n;) {
|
|
1831
|
+
n = !1;
|
|
1832
|
+
let e = t;
|
|
1833
|
+
t = t.replace(Ir, ""), t !== e && (n = !0);
|
|
1834
|
+
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1835
|
+
let i = Hr(t, e);
|
|
1836
|
+
if (Hr(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1837
|
+
else break;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
return t;
|
|
1841
|
+
}
|
|
1842
|
+
function Hr(e, t) {
|
|
1843
|
+
let n = 0;
|
|
1844
|
+
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1845
|
+
return n;
|
|
1846
|
+
}
|
|
1847
|
+
function Ur(e) {
|
|
1848
|
+
let t = e.split(".");
|
|
1849
|
+
return t[t.length - 1].toLowerCase();
|
|
1850
|
+
}
|
|
1851
|
+
function Wr(e) {
|
|
1852
|
+
let t = Ur(e);
|
|
1853
|
+
return Pr.has(t);
|
|
1854
|
+
}
|
|
1855
|
+
function Gr(e, t, n) {
|
|
1856
|
+
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
1857
|
+
}
|
|
1858
|
+
function Kr(e, t) {
|
|
1859
|
+
if (!e) return [];
|
|
1860
|
+
let n = t?.defaultProtocol || "http", r = [];
|
|
1861
|
+
for (let t of e.matchAll(Lr)) r.push({
|
|
1862
|
+
type: "url",
|
|
1863
|
+
value: t[0],
|
|
1864
|
+
start: t.index,
|
|
1865
|
+
end: t.index + t[0].length
|
|
1866
|
+
});
|
|
1867
|
+
for (let t of e.matchAll(Rr)) r.push({
|
|
1868
|
+
type: "url",
|
|
1869
|
+
value: t[0],
|
|
1870
|
+
start: t.index,
|
|
1871
|
+
end: t.index + t[0].length
|
|
1872
|
+
});
|
|
1873
|
+
for (let t of e.matchAll(zr)) r.push({
|
|
1874
|
+
type: "email",
|
|
1875
|
+
value: t[0],
|
|
1876
|
+
start: t.index,
|
|
1877
|
+
end: t.index + t[0].length
|
|
1878
|
+
});
|
|
1879
|
+
for (let t of e.matchAll(Br)) r.push({
|
|
1880
|
+
type: "url",
|
|
1881
|
+
value: t[0],
|
|
1882
|
+
start: t.index,
|
|
1883
|
+
end: t.index + t[0].length
|
|
1884
|
+
});
|
|
1885
|
+
r.sort((e, t) => e.start - t.start || t.end - e.end);
|
|
1886
|
+
let i = [], a = -1;
|
|
1887
|
+
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
1888
|
+
let o = [];
|
|
1889
|
+
for (let e of i) {
|
|
1890
|
+
let t = Vr(e.value);
|
|
1891
|
+
if (!t) continue;
|
|
1892
|
+
let r = e.start, i = r + t.length;
|
|
1893
|
+
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
1894
|
+
let e = new URL("http://" + t).hostname;
|
|
1895
|
+
if (!Wr(e)) continue;
|
|
1896
|
+
}
|
|
1897
|
+
if (e.type === "email") {
|
|
1898
|
+
let e = t.split("@")[1];
|
|
1899
|
+
if (!Wr(e)) continue;
|
|
1900
|
+
}
|
|
1901
|
+
let a = Gr(t, e.type, n);
|
|
1902
|
+
o.push({
|
|
1903
|
+
type: e.type,
|
|
1904
|
+
value: t,
|
|
1905
|
+
isLink: !0,
|
|
1906
|
+
href: a,
|
|
1907
|
+
start: r,
|
|
1908
|
+
end: i
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
return o;
|
|
1912
|
+
}
|
|
1913
|
+
function qr(e, t = "http") {
|
|
1914
|
+
if (!e) return [$(e, 0, 0)];
|
|
1915
|
+
for (let [n, r] of [
|
|
1916
|
+
["(", ")"],
|
|
1917
|
+
["[", "]"],
|
|
1918
|
+
["{", "}"]
|
|
1919
|
+
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
1920
|
+
let i = e.slice(1, -1);
|
|
1921
|
+
if (Q(i)) return [
|
|
1922
|
+
$(n, 0, 1),
|
|
1923
|
+
Jr(i, 1, 1 + i.length, t),
|
|
1924
|
+
$(r, 1 + i.length, e.length)
|
|
1925
|
+
];
|
|
1926
|
+
}
|
|
1927
|
+
if (e.endsWith(".") && e.length > 1) {
|
|
1928
|
+
let n = e.slice(0, -1);
|
|
1929
|
+
if (Q(n)) return [Jr(n, 0, n.length, t), $(".", n.length, e.length)];
|
|
1930
|
+
}
|
|
1931
|
+
return Q(e) ? [Jr(e, 0, e.length, t)] : [$(e, 0, e.length)];
|
|
1932
|
+
}
|
|
1933
|
+
function Q(e) {
|
|
1934
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || Fr.has(e.toLowerCase())) return !0;
|
|
1935
|
+
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
1936
|
+
if (t) {
|
|
1937
|
+
let e = t[1].toLowerCase();
|
|
1938
|
+
if (Pr.has(e)) return !0;
|
|
1939
|
+
}
|
|
1940
|
+
return !1;
|
|
1941
|
+
}
|
|
1942
|
+
function Jr(e, t, n, r) {
|
|
1943
|
+
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
1944
|
+
return {
|
|
1945
|
+
type: i,
|
|
1946
|
+
value: e,
|
|
1947
|
+
isLink: !0,
|
|
1948
|
+
href: Gr(e, i, r),
|
|
1949
|
+
start: t,
|
|
1950
|
+
end: n
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
function $(e, t, n) {
|
|
1954
|
+
return {
|
|
1955
|
+
type: "text",
|
|
1956
|
+
value: e,
|
|
1957
|
+
isLink: !1,
|
|
1958
|
+
href: e,
|
|
1959
|
+
start: t,
|
|
1960
|
+
end: n
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
//#endregion
|
|
1964
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
1965
|
+
var Yr = "[\0- \xA0 -\u2029 ]", Xr = new RegExp(Yr), Zr = RegExp(`${Yr}$`), Qr = new RegExp(Yr, "g");
|
|
1966
|
+
//#endregion
|
|
1967
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
1968
|
+
function $r(e) {
|
|
1969
|
+
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
1970
|
+
}
|
|
1971
|
+
function ei(e) {
|
|
1972
|
+
return new rt({
|
|
1973
|
+
key: new it("autolink"),
|
|
1974
|
+
appendTransaction: (t, n, r) => {
|
|
1975
|
+
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
1976
|
+
if (!i || a) return;
|
|
1977
|
+
let { tr: o } = r;
|
|
1978
|
+
if (qe(He(n.doc, [...t])).forEach(({ newRange: t }) => {
|
|
1979
|
+
let n = We(r.doc, t, (e) => e.isTextblock), i, a;
|
|
1980
|
+
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
1981
|
+
else if (n.length) {
|
|
1982
|
+
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
1983
|
+
if (!Zr.test(e)) return;
|
|
1984
|
+
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
1985
|
+
}
|
|
1986
|
+
if (i && a) {
|
|
1987
|
+
let t = a.split(Xr).filter(Boolean);
|
|
1988
|
+
if (t.length <= 0) return;
|
|
1989
|
+
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
1990
|
+
if (!n) return;
|
|
1991
|
+
let c = qr(n, e.defaultProtocol);
|
|
1992
|
+
if (!$r(c)) return;
|
|
1993
|
+
c.filter((e) => e.isLink).map((e) => ({
|
|
1994
|
+
...e,
|
|
1995
|
+
from: s + e.start + 1,
|
|
1996
|
+
to: s + e.end + 1
|
|
1997
|
+
})).filter((e) => r.schema.marks.code ? !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
|
|
1998
|
+
Ye(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
|
|
1999
|
+
});
|
|
2056
2000
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2001
|
+
}), o.steps.length) return o;
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
//#endregion
|
|
2006
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
2007
|
+
function ti(e) {
|
|
2008
|
+
return new rt({
|
|
2009
|
+
key: new it("handleClickLink"),
|
|
2010
|
+
props: { handleClick: (t, n, r) => {
|
|
2011
|
+
if (r.button !== 0 || !t.editable) return !1;
|
|
2012
|
+
let i = null;
|
|
2013
|
+
if (r.target instanceof HTMLAnchorElement && r.target.getAttribute("data-inline-content-type") === "link") i = r.target;
|
|
2014
|
+
else {
|
|
2015
|
+
let t = r.target;
|
|
2016
|
+
if (!t) return !1;
|
|
2017
|
+
let n = e.tiptapEditor.view.dom;
|
|
2018
|
+
i = t.closest("a[data-inline-content-type=\"link\"]"), i && !n.contains(i) && (i = null);
|
|
2019
|
+
}
|
|
2020
|
+
if (!i) return !1;
|
|
2021
|
+
if (e.onClick) {
|
|
2022
|
+
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
2023
|
+
return e.onClick(r, e.editor) ?? !0;
|
|
2024
|
+
}
|
|
2025
|
+
let a = Ke(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
2026
|
+
return o ? (window.open(o, s), !0) : !1;
|
|
2027
|
+
} }
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
//#endregion
|
|
2031
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
2032
|
+
function ni(e) {
|
|
2033
|
+
return new rt({
|
|
2034
|
+
key: new it("handlePasteLink"),
|
|
2035
|
+
props: { handlePaste: (t, n, r) => {
|
|
2036
|
+
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
2037
|
+
if (c) return !1;
|
|
2038
|
+
let l = "";
|
|
2039
|
+
r.content.forEach((e) => {
|
|
2040
|
+
l += e.textContent;
|
|
2041
|
+
});
|
|
2042
|
+
let u = Kr(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
2043
|
+
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
2044
|
+
} }
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
//#endregion
|
|
2048
|
+
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
2049
|
+
var ri = "https", ii = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
2050
|
+
function ai(e) {
|
|
2051
|
+
if (!e) return !0;
|
|
2052
|
+
let t = e.replace(Qr, "");
|
|
2053
|
+
return ii.test(t);
|
|
2054
|
+
}
|
|
2055
|
+
function oi(e) {
|
|
2056
|
+
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
2057
|
+
if (t || n && !e.includes("@")) return !0;
|
|
2058
|
+
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
2059
|
+
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
2060
|
+
}
|
|
2061
|
+
var si = Ve.create({
|
|
2062
|
+
name: "link",
|
|
2063
|
+
keepOnSplit: !1,
|
|
2064
|
+
exitable: !0,
|
|
2065
|
+
inclusive: !1,
|
|
2066
|
+
addOptions() {
|
|
2066
2067
|
return {
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
"Mod-y": () => this.options.editor.redo(),
|
|
2077
|
-
"Shift-Mod-z": () => this.options.editor.redo()
|
|
2068
|
+
HTMLAttributes: {
|
|
2069
|
+
target: "_blank",
|
|
2070
|
+
rel: "noopener noreferrer nofollow",
|
|
2071
|
+
className: "bn-inline-content-section",
|
|
2072
|
+
"data-inline-content-type": "link"
|
|
2073
|
+
},
|
|
2074
|
+
editor: void 0,
|
|
2075
|
+
onClick: void 0,
|
|
2076
|
+
isValidLink: ai
|
|
2078
2077
|
};
|
|
2079
|
-
}
|
|
2080
|
-
}), ri = k.create({
|
|
2081
|
-
name: "insertion",
|
|
2082
|
-
inclusive: !1,
|
|
2083
|
-
excludes: "deletion modification insertion",
|
|
2084
|
-
addAttributes() {
|
|
2085
|
-
return { id: {
|
|
2086
|
-
default: null,
|
|
2087
|
-
validate: "number"
|
|
2088
|
-
} };
|
|
2089
2078
|
},
|
|
2090
|
-
extendMarkSchema(e) {
|
|
2091
|
-
return e.name === "insertion" ? {
|
|
2092
|
-
blocknoteIgnore: !0,
|
|
2093
|
-
inclusive: !1,
|
|
2094
|
-
toDOM(e, t) {
|
|
2095
|
-
return [
|
|
2096
|
-
"ins",
|
|
2097
|
-
{
|
|
2098
|
-
"data-id": String(e.attrs.id),
|
|
2099
|
-
"data-inline": String(t),
|
|
2100
|
-
...!t && { style: "display: contents" }
|
|
2101
|
-
},
|
|
2102
|
-
0
|
|
2103
|
-
];
|
|
2104
|
-
},
|
|
2105
|
-
parseDOM: [{
|
|
2106
|
-
tag: "ins",
|
|
2107
|
-
getAttrs(e) {
|
|
2108
|
-
return e.dataset.id ? { id: parseInt(e.dataset.id, 10) } : !1;
|
|
2109
|
-
}
|
|
2110
|
-
}]
|
|
2111
|
-
} : {};
|
|
2112
|
-
}
|
|
2113
|
-
}), ii = k.create({
|
|
2114
|
-
name: "deletion",
|
|
2115
|
-
inclusive: !1,
|
|
2116
|
-
excludes: "insertion modification deletion",
|
|
2117
2079
|
addAttributes() {
|
|
2118
|
-
return {
|
|
2080
|
+
return { href: {
|
|
2119
2081
|
default: null,
|
|
2120
|
-
|
|
2082
|
+
parseHTML(e) {
|
|
2083
|
+
return e.getAttribute("href");
|
|
2084
|
+
}
|
|
2121
2085
|
} };
|
|
2122
2086
|
},
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2087
|
+
parseHTML() {
|
|
2088
|
+
let e = this.options.isValidLink;
|
|
2089
|
+
return [{
|
|
2090
|
+
tag: "a[href]",
|
|
2091
|
+
getAttrs: (t) => {
|
|
2092
|
+
let n = t.getAttribute("href");
|
|
2093
|
+
return !n || !e(n) ? !1 : null;
|
|
2094
|
+
}
|
|
2095
|
+
}];
|
|
2096
|
+
},
|
|
2097
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2098
|
+
return this.options.isValidLink(e.href) ? [
|
|
2099
|
+
"a",
|
|
2100
|
+
$e(e, this.options.HTMLAttributes),
|
|
2101
|
+
0
|
|
2102
|
+
] : [
|
|
2103
|
+
"a",
|
|
2104
|
+
$e({
|
|
2105
|
+
...e,
|
|
2106
|
+
href: ""
|
|
2107
|
+
}, this.options.HTMLAttributes),
|
|
2108
|
+
0
|
|
2109
|
+
];
|
|
2110
|
+
},
|
|
2111
|
+
addPasteRules() {
|
|
2112
|
+
let e = this.options.isValidLink;
|
|
2113
|
+
return [Qe({
|
|
2114
|
+
find: (t) => {
|
|
2115
|
+
let n = [];
|
|
2116
|
+
if (t) {
|
|
2117
|
+
let r = Kr(t, { defaultProtocol: ri }).filter((t) => t.isLink && e(t.value));
|
|
2118
|
+
for (let e of r) oi(e.value) && n.push({
|
|
2119
|
+
text: e.value,
|
|
2120
|
+
data: { href: e.href },
|
|
2121
|
+
index: e.start
|
|
2122
|
+
});
|
|
2142
2123
|
}
|
|
2143
|
-
|
|
2144
|
-
} : {};
|
|
2145
|
-
}
|
|
2146
|
-
}), ai = k.create({
|
|
2147
|
-
name: "modification",
|
|
2148
|
-
inclusive: !1,
|
|
2149
|
-
excludes: "deletion insertion",
|
|
2150
|
-
addAttributes() {
|
|
2151
|
-
return {
|
|
2152
|
-
id: {
|
|
2153
|
-
default: null,
|
|
2154
|
-
validate: "number"
|
|
2155
|
-
},
|
|
2156
|
-
type: { validate: "string" },
|
|
2157
|
-
attrName: {
|
|
2158
|
-
default: null,
|
|
2159
|
-
validate: "string|null"
|
|
2124
|
+
return n;
|
|
2160
2125
|
},
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
};
|
|
2126
|
+
type: this.type,
|
|
2127
|
+
getAttributes: (e) => ({ href: e.data?.href })
|
|
2128
|
+
})];
|
|
2164
2129
|
},
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
getAttrs(e) {
|
|
2185
|
-
return e.dataset.id ? {
|
|
2186
|
-
id: parseInt(e.dataset.id, 10),
|
|
2187
|
-
type: e.dataset.modType,
|
|
2188
|
-
previousValue: e.dataset.modPrevVal,
|
|
2189
|
-
newValue: e.dataset.modNewVal
|
|
2190
|
-
} : !1;
|
|
2191
|
-
}
|
|
2192
|
-
}, {
|
|
2193
|
-
tag: "div[data-type='modification']",
|
|
2194
|
-
getAttrs(e) {
|
|
2195
|
-
return e.dataset.id ? {
|
|
2196
|
-
id: parseInt(e.dataset.id, 10),
|
|
2197
|
-
type: e.dataset.modType,
|
|
2198
|
-
previousValue: e.dataset.modPrevVal
|
|
2199
|
-
} : !1;
|
|
2200
|
-
}
|
|
2201
|
-
}]
|
|
2202
|
-
} : {};
|
|
2203
|
-
}
|
|
2204
|
-
}), oi = O.create({
|
|
2205
|
-
name: "textAlignment",
|
|
2206
|
-
addGlobalAttributes() {
|
|
2207
|
-
return [{
|
|
2208
|
-
types: ["tableCell", "tableHeader"],
|
|
2209
|
-
attributes: { textAlignment: {
|
|
2210
|
-
default: "left",
|
|
2211
|
-
parseHTML: (e) => e.getAttribute("data-text-alignment"),
|
|
2212
|
-
renderHTML: (e) => e.textAlignment === "left" ? {} : { "data-text-alignment": e.textAlignment }
|
|
2213
|
-
} }
|
|
2214
|
-
}];
|
|
2215
|
-
}
|
|
2216
|
-
}), si = O.create({
|
|
2217
|
-
name: "blockTextColor",
|
|
2218
|
-
addGlobalAttributes() {
|
|
2219
|
-
return [{
|
|
2220
|
-
types: [
|
|
2221
|
-
"table",
|
|
2222
|
-
"tableCell",
|
|
2223
|
-
"tableHeader"
|
|
2224
|
-
],
|
|
2225
|
-
attributes: { textColor: ue() }
|
|
2226
|
-
}];
|
|
2130
|
+
addProseMirrorPlugins() {
|
|
2131
|
+
let e = [];
|
|
2132
|
+
return e.push(ei({
|
|
2133
|
+
type: this.type,
|
|
2134
|
+
defaultProtocol: ri,
|
|
2135
|
+
validate: this.options.isValidLink,
|
|
2136
|
+
shouldAutoLink: oi
|
|
2137
|
+
})), e.push(ti({
|
|
2138
|
+
type: this.type,
|
|
2139
|
+
tiptapEditor: this.editor,
|
|
2140
|
+
editor: this.options.editor,
|
|
2141
|
+
onClick: this.options.onClick
|
|
2142
|
+
})), e.push(ni({
|
|
2143
|
+
editor: this.editor,
|
|
2144
|
+
defaultProtocol: ri,
|
|
2145
|
+
type: this.type,
|
|
2146
|
+
shouldAutoLink: oi,
|
|
2147
|
+
isValidLink: this.options.isValidLink
|
|
2148
|
+
})), e;
|
|
2227
2149
|
}
|
|
2228
|
-
}), ci = {
|
|
2150
|
+
}), ci = he(({ editor: e, options: t }) => ({
|
|
2151
|
+
key: "link",
|
|
2152
|
+
tiptapExtensions: [si.configure({
|
|
2153
|
+
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
2154
|
+
editor: e,
|
|
2155
|
+
onClick: t.onClick,
|
|
2156
|
+
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
2157
|
+
})]
|
|
2158
|
+
})), li = {
|
|
2229
2159
|
blockColor: "data-block-color",
|
|
2230
2160
|
blockStyle: "data-block-style",
|
|
2231
2161
|
id: "data-id",
|
|
2232
2162
|
depth: "data-depth",
|
|
2233
2163
|
depthChange: "data-depth-change"
|
|
2234
|
-
},
|
|
2164
|
+
}, ui = O.create({
|
|
2235
2165
|
name: "blockContainer",
|
|
2236
2166
|
group: "blockGroupChild bnBlock",
|
|
2237
2167
|
content: "blockContent blockGroup?",
|
|
2238
2168
|
priority: 50,
|
|
2239
2169
|
defining: !0,
|
|
2240
|
-
marks
|
|
2170
|
+
marks() {
|
|
2171
|
+
return p(this.editor);
|
|
2172
|
+
},
|
|
2241
2173
|
parseHTML() {
|
|
2242
2174
|
return [{
|
|
2243
2175
|
tag: "div[data-node-type=" + this.name + "]",
|
|
2244
2176
|
getAttrs: (e) => {
|
|
2245
2177
|
if (typeof e == "string") return !1;
|
|
2246
2178
|
let t = {};
|
|
2247
|
-
for (let [n, r] of Object.entries(
|
|
2179
|
+
for (let [n, r] of Object.entries(li)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
2248
2180
|
return t;
|
|
2249
2181
|
}
|
|
2250
2182
|
}, {
|
|
@@ -2260,18 +2192,20 @@ var Kr = (e) => {
|
|
|
2260
2192
|
...this.options.domAttributes?.block || {},
|
|
2261
2193
|
...e
|
|
2262
2194
|
}, r = document.createElement("div");
|
|
2263
|
-
r.className =
|
|
2195
|
+
r.className = o("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
2264
2196
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2265
2197
|
return t.appendChild(r), {
|
|
2266
2198
|
dom: t,
|
|
2267
2199
|
contentDOM: r
|
|
2268
2200
|
};
|
|
2269
2201
|
}
|
|
2270
|
-
}),
|
|
2202
|
+
}), di = O.create({
|
|
2271
2203
|
name: "blockGroup",
|
|
2272
2204
|
group: "childContainer",
|
|
2273
2205
|
content: "blockGroupChild+",
|
|
2274
|
-
marks
|
|
2206
|
+
marks() {
|
|
2207
|
+
return p(this.editor);
|
|
2208
|
+
},
|
|
2275
2209
|
parseHTML() {
|
|
2276
2210
|
return [{
|
|
2277
2211
|
tag: "div",
|
|
@@ -2283,38 +2217,31 @@ var Kr = (e) => {
|
|
|
2283
2217
|
...this.options.domAttributes?.blockGroup || {},
|
|
2284
2218
|
...e
|
|
2285
2219
|
}, n = document.createElement("div");
|
|
2286
|
-
n.className =
|
|
2220
|
+
n.className = o("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
|
|
2287
2221
|
for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
|
|
2288
2222
|
return {
|
|
2289
2223
|
dom: n,
|
|
2290
2224
|
contentDOM: n
|
|
2291
2225
|
};
|
|
2292
2226
|
}
|
|
2293
|
-
}),
|
|
2227
|
+
}), fi = O.create({
|
|
2294
2228
|
name: "doc",
|
|
2295
2229
|
topNode: !0,
|
|
2296
2230
|
content: "blockGroup",
|
|
2297
|
-
marks
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
he(e),
|
|
2302
|
-
ge(e),
|
|
2303
|
-
ke(e),
|
|
2304
|
-
de(),
|
|
2305
|
-
Ae(e)
|
|
2306
|
-
]
|
|
2307
|
-
}));
|
|
2231
|
+
marks() {
|
|
2232
|
+
return p(this.editor);
|
|
2233
|
+
}
|
|
2234
|
+
});
|
|
2308
2235
|
//#endregion
|
|
2309
2236
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
2310
2237
|
function pi(e, t) {
|
|
2311
2238
|
return [
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2239
|
+
k.ClipboardTextSerializer,
|
|
2240
|
+
k.Commands,
|
|
2241
|
+
k.Editable,
|
|
2242
|
+
k.FocusEvents,
|
|
2243
|
+
k.Tabindex,
|
|
2244
|
+
ut,
|
|
2318
2245
|
u.configure({
|
|
2319
2246
|
types: [
|
|
2320
2247
|
"blockContainer",
|
|
@@ -2324,68 +2251,70 @@ function pi(e, t) {
|
|
|
2324
2251
|
setIdAttribute: t.setIdAttribute,
|
|
2325
2252
|
isWithinEditor: e.isWithinEditor
|
|
2326
2253
|
}),
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
ri,
|
|
2330
|
-
ii,
|
|
2331
|
-
ai,
|
|
2254
|
+
Cr,
|
|
2255
|
+
lt,
|
|
2332
2256
|
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2257
|
+
jr,
|
|
2258
|
+
Sr,
|
|
2259
|
+
Ar,
|
|
2260
|
+
D.create({
|
|
2337
2261
|
name: "OverrideEscape",
|
|
2338
|
-
addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(
|
|
2262
|
+
addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(ie)?.shown() ? !1 : (e.blur(), !0) })
|
|
2339
2263
|
}),
|
|
2340
|
-
|
|
2341
|
-
|
|
2264
|
+
fi,
|
|
2265
|
+
ui.configure({
|
|
2342
2266
|
editor: e,
|
|
2343
2267
|
domAttributes: t.domAttributes
|
|
2344
2268
|
}),
|
|
2345
|
-
|
|
2269
|
+
kr.configure({
|
|
2346
2270
|
editor: e,
|
|
2347
2271
|
tabBehavior: t.tabBehavior
|
|
2348
2272
|
}),
|
|
2349
|
-
|
|
2273
|
+
di.configure({ domAttributes: t.domAttributes }),
|
|
2350
2274
|
...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
|
|
2351
2275
|
...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
|
|
2352
2276
|
editor: e,
|
|
2353
2277
|
domAttributes: t.domAttributes
|
|
2354
2278
|
})] : []]),
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2279
|
+
xr(e),
|
|
2280
|
+
gr(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2281
|
+
$n(e)
|
|
2358
2282
|
];
|
|
2359
2283
|
}
|
|
2360
2284
|
function mi(e, t) {
|
|
2361
2285
|
let n = [
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2286
|
+
ve(),
|
|
2287
|
+
_e(t),
|
|
2288
|
+
y(t),
|
|
2289
|
+
se(t),
|
|
2290
|
+
ci({
|
|
2367
2291
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
2368
2292
|
onClick: t.links?.onClick,
|
|
2369
2293
|
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
2370
2294
|
}),
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2295
|
+
ke(t),
|
|
2296
|
+
Ae(),
|
|
2297
|
+
xe(t),
|
|
2298
|
+
Me(t),
|
|
2299
|
+
Ce(t),
|
|
2300
|
+
ie(t),
|
|
2301
|
+
ye(),
|
|
2302
|
+
je(),
|
|
2303
|
+
...t.trailingBlock === !1 ? [] : [De()]
|
|
2378
2304
|
];
|
|
2379
|
-
return
|
|
2305
|
+
return "table" in e.schema.blockSpecs && n.push(Se(t)), t.animations !== !1 && n.push(Oe()), n;
|
|
2380
2306
|
}
|
|
2381
2307
|
//#endregion
|
|
2382
2308
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
2383
2309
|
var hi = class {
|
|
2310
|
+
editor;
|
|
2311
|
+
options;
|
|
2384
2312
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
2385
2313
|
extensions = [];
|
|
2386
2314
|
abortMap = /* @__PURE__ */ new Map();
|
|
2387
2315
|
extensionFactories = /* @__PURE__ */ new Map();
|
|
2388
2316
|
extensionPlugins = /* @__PURE__ */ new Map();
|
|
2317
|
+
blockNoteExtensionDependents = /* @__PURE__ */ new Map();
|
|
2389
2318
|
constructor(e, t) {
|
|
2390
2319
|
this.editor = e, this.options = t, e.onMount(() => {
|
|
2391
2320
|
for (let t of this.extensions) if (t.mount) {
|
|
@@ -2406,26 +2335,23 @@ var hi = class {
|
|
|
2406
2335
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
2407
2336
|
}
|
|
2408
2337
|
registerExtension(e) {
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
typeof e == "function" && this.extensionFactories.set(e, t);
|
|
2338
|
+
this.replaceExtension(void 0, e);
|
|
2339
|
+
}
|
|
2340
|
+
addExtension(e, t) {
|
|
2341
|
+
let n;
|
|
2342
|
+
if (n = typeof e == "function" ? e({ editor: this.editor }) : e, !(!n || this.disabledExtensions.has(n.key))) {
|
|
2343
|
+
if (t) {
|
|
2344
|
+
let e = this.blockNoteExtensionDependents.get(n.key);
|
|
2345
|
+
e || (e = /* @__PURE__ */ new Set(), this.blockNoteExtensionDependents.set(n.key, e)), e.add(t);
|
|
2346
|
+
}
|
|
2347
|
+
if (!this.extensions.some((e) => e.key === n.key)) {
|
|
2348
|
+
if (typeof e == "function") {
|
|
2349
|
+
let e = n[me];
|
|
2350
|
+
typeof e == "function" && this.extensionFactories.set(e, n);
|
|
2351
|
+
}
|
|
2352
|
+
if (this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
|
|
2353
|
+
return n;
|
|
2426
2354
|
}
|
|
2427
|
-
if (this.extensions.push(t), t.blockNoteExtensions) for (let e of t.blockNoteExtensions) this.addExtension(e);
|
|
2428
|
-
return t;
|
|
2429
2355
|
}
|
|
2430
2356
|
}
|
|
2431
2357
|
resolveExtensions(e) {
|
|
@@ -2442,43 +2368,62 @@ var hi = class {
|
|
|
2442
2368
|
return t;
|
|
2443
2369
|
}
|
|
2444
2370
|
unregisterExtension(e) {
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
let
|
|
2451
|
-
for (let
|
|
2452
|
-
e ===
|
|
2453
|
-
}), this.abortMap.get(
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2371
|
+
this.replaceExtension(e, []);
|
|
2372
|
+
}
|
|
2373
|
+
replaceExtension(e, t) {
|
|
2374
|
+
let n = this.resolveExtensions(e);
|
|
2375
|
+
e && !n.length && console.warn("No extensions found to unregister", e);
|
|
2376
|
+
let r = !1, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
2377
|
+
for (let t of n) this.extensions = this.extensions.filter((e) => e !== t), this.extensionFactories.forEach((e, n) => {
|
|
2378
|
+
e === t && this.extensionFactories.delete(n);
|
|
2379
|
+
}), this.abortMap.get(t)?.abort(), this.abortMap.delete(t), this.extensionPlugins.get(t)?.forEach((e) => {
|
|
2380
|
+
i.add(e);
|
|
2381
|
+
let t = e.spec?.key, n = typeof t == "object" && t ? t.key : t;
|
|
2382
|
+
typeof n == "string" && a.add(n);
|
|
2383
|
+
}), this.extensionPlugins.delete(t), t.tiptapExtensions && !r && (r = !0, console.warn(`Extension ${t.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`, e));
|
|
2384
|
+
let o = [].concat(t).filter(Boolean).map((e) => this.addExtension(e)).filter(Boolean), s = [];
|
|
2385
|
+
for (let e of o) e?.tiptapExtensions && console.warn(`Extension ${e.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), e?.inputRules?.length && console.warn(`Extension ${e.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), this.getProsemirrorPluginsFromExtension(e).plugins.forEach((e) => {
|
|
2386
|
+
s.push(e);
|
|
2387
|
+
});
|
|
2388
|
+
!i.size && !a.size && !s.length || this.updatePlugins((e) => [...e.filter((e) => {
|
|
2389
|
+
if (i.has(e)) return !1;
|
|
2390
|
+
if (a.size) {
|
|
2391
|
+
let t = e.spec?.key, n = typeof t == "object" && t ? t.key : t;
|
|
2392
|
+
if (typeof n == "string" && a.has(n)) return !1;
|
|
2393
|
+
}
|
|
2394
|
+
return !0;
|
|
2395
|
+
}), ...s]);
|
|
2457
2396
|
}
|
|
2458
2397
|
updatePlugins(e) {
|
|
2459
2398
|
let t = this.editor.prosemirrorState, n = t.reconfigure({ plugins: e(t.plugins.slice()) });
|
|
2460
2399
|
this.editor.prosemirrorView.updateState(n);
|
|
2461
2400
|
}
|
|
2462
2401
|
getTiptapExtensions() {
|
|
2463
|
-
let e = pi(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t =
|
|
2402
|
+
let e = pi(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = s(this.extensions.map((e) => {
|
|
2403
|
+
let t = this.blockNoteExtensionDependents.get(e.key);
|
|
2404
|
+
return t?.size ? {
|
|
2405
|
+
key: e.key,
|
|
2406
|
+
runsBefore: [...e.runsBefore ?? [], ...t]
|
|
2407
|
+
} : e;
|
|
2408
|
+
})), n = /* @__PURE__ */ new Map();
|
|
2464
2409
|
for (let r of this.extensions) {
|
|
2465
2410
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2466
2411
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
2467
|
-
a.length && e.push(
|
|
2412
|
+
a.length && e.push(D.create({
|
|
2468
2413
|
name: r.key,
|
|
2469
2414
|
priority: i,
|
|
2470
2415
|
addProseMirrorPlugins: () => a
|
|
2471
2416
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
2472
2417
|
}
|
|
2473
|
-
e.push(
|
|
2418
|
+
e.push(D.create({
|
|
2474
2419
|
name: "blocknote-input-rules",
|
|
2475
2420
|
addProseMirrorPlugins() {
|
|
2476
2421
|
let e = [];
|
|
2477
|
-
Array.from(n.keys()).sort().reverse().forEach((t) => {
|
|
2422
|
+
Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
|
|
2478
2423
|
e.push(...n.get(t));
|
|
2479
2424
|
});
|
|
2480
|
-
let t =
|
|
2481
|
-
return [t, new
|
|
2425
|
+
let t = st({ rules: e });
|
|
2426
|
+
return [t, new j({ props: { handleKeyDown(e, n) {
|
|
2482
2427
|
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2483
2428
|
let { $cursor: r } = e.state.selection;
|
|
2484
2429
|
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
@@ -2488,31 +2433,28 @@ var hi = class {
|
|
|
2488
2433
|
for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
|
|
2489
2434
|
return e;
|
|
2490
2435
|
}
|
|
2491
|
-
getProsemirrorPluginsFromExtension(
|
|
2492
|
-
let
|
|
2493
|
-
return !
|
|
2494
|
-
plugins:
|
|
2495
|
-
inputRules:
|
|
2496
|
-
} : (this.extensionPlugins.set(
|
|
2497
|
-
let o =
|
|
2498
|
-
match:
|
|
2436
|
+
getProsemirrorPluginsFromExtension(t) {
|
|
2437
|
+
let n = [...t.prosemirrorPlugins ?? []], r = [];
|
|
2438
|
+
return !t.prosemirrorPlugins?.length && !Object.keys(t.keyboardShortcuts || {}).length && !t.inputRules?.length ? {
|
|
2439
|
+
plugins: n,
|
|
2440
|
+
inputRules: r
|
|
2441
|
+
} : (this.extensionPlugins.set(t, n), t.inputRules?.length && r.push(...t.inputRules.map((t) => new ot(t.find, (n, r, i, a) => {
|
|
2442
|
+
let o = t.replace({
|
|
2443
|
+
match: r,
|
|
2499
2444
|
range: {
|
|
2500
|
-
from:
|
|
2445
|
+
from: i,
|
|
2501
2446
|
to: a
|
|
2502
2447
|
},
|
|
2503
2448
|
editor: this.editor
|
|
2504
2449
|
});
|
|
2505
2450
|
if (o) {
|
|
2506
|
-
let
|
|
2507
|
-
|
|
2508
|
-
e.deleteRange(r, a), i(e, n.bnBlock.beforePos, o);
|
|
2509
|
-
let s = n.bnBlock.node.attrs.id;
|
|
2510
|
-
return s && Un(e, s, "start"), e;
|
|
2451
|
+
let t = n.tr, r = _(t);
|
|
2452
|
+
return !r.isBlockContainer || this.editor.schema.blockSchema[r.blockNoteType]?.content !== "inline" ? null : (t.deleteRange(i, a), m(t, r.bnBlock.beforePos, o), qn(t, e(r.bnBlock.node, t.doc), "start"), t);
|
|
2511
2453
|
}
|
|
2512
2454
|
return null;
|
|
2513
|
-
}, { undoable: !0 }))), Object.keys(
|
|
2514
|
-
plugins:
|
|
2515
|
-
inputRules:
|
|
2455
|
+
}, { undoable: !0 }))), Object.keys(t.keyboardShortcuts || {}).length && n.push(ct(Object.fromEntries(Object.entries(t.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
|
|
2456
|
+
plugins: n,
|
|
2457
|
+
inputRules: r
|
|
2516
2458
|
});
|
|
2517
2459
|
}
|
|
2518
2460
|
getExtensions() {
|
|
@@ -2555,63 +2497,63 @@ function gi(e, t) {
|
|
|
2555
2497
|
//#endregion
|
|
2556
2498
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2557
2499
|
function _i(e) {
|
|
2558
|
-
let t = g(e);
|
|
2559
2500
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2560
|
-
let
|
|
2561
|
-
let
|
|
2562
|
-
if (!
|
|
2563
|
-
return
|
|
2564
|
-
},
|
|
2565
|
-
if (
|
|
2566
|
-
|
|
2567
|
-
for (let e =
|
|
2568
|
-
let
|
|
2569
|
-
for (let
|
|
2570
|
-
}
|
|
2571
|
-
} else
|
|
2572
|
-
for (let e =
|
|
2573
|
-
if (
|
|
2574
|
-
return { blocks:
|
|
2575
|
-
}
|
|
2576
|
-
function vi(e, t,
|
|
2577
|
-
let
|
|
2578
|
-
if (
|
|
2579
|
-
let
|
|
2580
|
-
if (!s) throw Error(`Block with ID ${i} not found`);
|
|
2581
|
-
let c = r(a, e.doc);
|
|
2501
|
+
let t = e.doc.resolve(h(e.doc, e.selection.from).posBeforeNode), n = e.doc.resolve(h(e.doc, e.selection.to).posBeforeNode), r = (n, r) => {
|
|
2502
|
+
let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
|
|
2503
|
+
if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
|
|
2504
|
+
return C(a, e.doc);
|
|
2505
|
+
}, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
|
|
2506
|
+
if (t.depth > a) {
|
|
2507
|
+
i.push(C(t.nodeAfter, e.doc));
|
|
2508
|
+
for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
|
|
2509
|
+
let n = t.index(e) + 1, a = t.node(e).childCount;
|
|
2510
|
+
for (let t = n; t < a; t++) i.push(r(t, e));
|
|
2511
|
+
}
|
|
2512
|
+
} else i.push(r(o, a));
|
|
2513
|
+
for (let e = o + 1; e <= s; e++) i.push(r(e, a));
|
|
2514
|
+
if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2515
|
+
return { blocks: i };
|
|
2516
|
+
}
|
|
2517
|
+
function vi(e, t, r) {
|
|
2518
|
+
let a = typeof t == "string" ? t : t.id, o = typeof r == "string" ? r : r.id, s = n(i(e));
|
|
2519
|
+
if (a === o) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${a})`);
|
|
2520
|
+
let c = x(a, e.doc);
|
|
2582
2521
|
if (!c) throw Error(`Block with ID ${a} not found`);
|
|
2583
|
-
let l = x(
|
|
2584
|
-
if (!l
|
|
2522
|
+
let l = x(o, e.doc);
|
|
2523
|
+
if (!l) throw Error(`Block with ID ${o} not found`);
|
|
2524
|
+
let u = S(c), d = S(l), f = s.blockSchema[u.blockNoteType], p = s.blockSchema[d.blockNoteType];
|
|
2585
2525
|
if (!u.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
let e = at.get(l.blockContent.node);
|
|
2589
|
-
p = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
|
|
2590
|
-
} else p = l.blockContent.beforePos + 1;
|
|
2526
|
+
if (!d.isBlockContainer || p.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${o})`);
|
|
2527
|
+
let m, h;
|
|
2591
2528
|
if (f.content === "table") {
|
|
2592
|
-
let
|
|
2593
|
-
m =
|
|
2594
|
-
} else m = u.blockContent.
|
|
2595
|
-
|
|
2529
|
+
let e = nt.get(u.blockContent.node);
|
|
2530
|
+
m = u.blockContent.beforePos + e.positionAt(0, 0, u.blockContent.node) + 1 + 2;
|
|
2531
|
+
} else m = u.blockContent.beforePos + 1;
|
|
2532
|
+
if (p.content === "table") {
|
|
2533
|
+
let t = nt.get(d.blockContent.node), n = d.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, d.blockContent.node) + 1;
|
|
2534
|
+
h = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
2535
|
+
} else h = d.blockContent.afterPos - 1;
|
|
2536
|
+
e.setSelection(M.create(e.doc, m, h));
|
|
2596
2537
|
}
|
|
2597
2538
|
function yi(e, t = !1) {
|
|
2598
|
-
let n =
|
|
2599
|
-
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2600
|
-
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2601
|
-
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2539
|
+
let n = t ? gi(e.doc, e.selection) : e.selection, r = n.$from, i = n.$to;
|
|
2602
2540
|
for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
|
|
2603
|
-
|
|
2541
|
+
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2542
|
+
for (; r.parentOffset === 0 && r.depth > 0;) r = e.doc.resolve(r.pos - 1);
|
|
2543
|
+
for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0;) r = e.doc.resolve(r.pos + 1);
|
|
2544
|
+
let a = de(e.doc.slice(r.pos, i.pos, !0));
|
|
2604
2545
|
return {
|
|
2605
2546
|
_meta: {
|
|
2606
|
-
startPos:
|
|
2607
|
-
endPos:
|
|
2547
|
+
startPos: r.pos,
|
|
2548
|
+
endPos: i.pos
|
|
2608
2549
|
},
|
|
2609
|
-
...
|
|
2550
|
+
...a
|
|
2610
2551
|
};
|
|
2611
2552
|
}
|
|
2612
2553
|
//#endregion
|
|
2613
2554
|
//#region src/editor/managers/SelectionManager.ts
|
|
2614
2555
|
var bi = class {
|
|
2556
|
+
editor;
|
|
2615
2557
|
constructor(e) {
|
|
2616
2558
|
this.editor = e;
|
|
2617
2559
|
}
|
|
@@ -2625,21 +2567,22 @@ var bi = class {
|
|
|
2625
2567
|
return this.editor.transact((n) => vi(n, e, t));
|
|
2626
2568
|
}
|
|
2627
2569
|
getTextCursorPosition() {
|
|
2628
|
-
return this.editor.transact((e) =>
|
|
2570
|
+
return this.editor.transact((e) => Kn(e));
|
|
2629
2571
|
}
|
|
2630
2572
|
setTextCursorPosition(e, t = "start") {
|
|
2631
|
-
return this.editor.transact((n) =>
|
|
2573
|
+
return this.editor.transact((n) => qn(n, e, t));
|
|
2632
2574
|
}
|
|
2633
2575
|
getSelectionBoundingBox() {
|
|
2634
2576
|
if (!this.editor.prosemirrorView) return;
|
|
2635
2577
|
let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
|
|
2636
|
-
if (
|
|
2578
|
+
if (Ze(e)) {
|
|
2637
2579
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2638
2580
|
if (e) return e.getBoundingClientRect();
|
|
2639
2581
|
}
|
|
2640
|
-
return
|
|
2582
|
+
return et(this.editor.prosemirrorView, n, r).toJSON();
|
|
2641
2583
|
}
|
|
2642
2584
|
}, xi = class {
|
|
2585
|
+
editor;
|
|
2643
2586
|
constructor(e) {
|
|
2644
2587
|
this.editor = e;
|
|
2645
2588
|
}
|
|
@@ -2731,21 +2674,22 @@ function Si(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2731
2674
|
let { parent: t } = e.doc.resolve(i);
|
|
2732
2675
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2733
2676
|
}
|
|
2734
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2677
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && tt(e, e.steps.length - 1, -1), !0;
|
|
2735
2678
|
}
|
|
2736
2679
|
//#endregion
|
|
2737
2680
|
//#region src/editor/managers/StyleManager.ts
|
|
2738
2681
|
var Ci = class {
|
|
2682
|
+
editor;
|
|
2739
2683
|
constructor(e) {
|
|
2740
2684
|
this.editor = e;
|
|
2741
2685
|
}
|
|
2742
|
-
insertInlineContent(e, { updateSelection:
|
|
2743
|
-
let
|
|
2686
|
+
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2687
|
+
let n = d(e, this.editor.pmSchema);
|
|
2744
2688
|
this.editor.transact((e) => {
|
|
2745
2689
|
Si(e, {
|
|
2746
2690
|
from: e.selection.from,
|
|
2747
2691
|
to: e.selection.to
|
|
2748
|
-
},
|
|
2692
|
+
}, n, { updateSelection: t });
|
|
2749
2693
|
});
|
|
2750
2694
|
}
|
|
2751
2695
|
getActiveStyles() {
|
|
@@ -2768,7 +2712,7 @@ var Ci = class {
|
|
|
2768
2712
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2769
2713
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2770
2714
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2771
|
-
else throw new
|
|
2715
|
+
else throw new c(e.propSchema);
|
|
2772
2716
|
}
|
|
2773
2717
|
}
|
|
2774
2718
|
removeStyles(e) {
|
|
@@ -2780,7 +2724,7 @@ var Ci = class {
|
|
|
2780
2724
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2781
2725
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2782
2726
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2783
|
-
else throw new
|
|
2727
|
+
else throw new c(e.propSchema);
|
|
2784
2728
|
}
|
|
2785
2729
|
}
|
|
2786
2730
|
getSelectedText() {
|
|
@@ -2790,7 +2734,7 @@ var Ci = class {
|
|
|
2790
2734
|
return this.editor.transact((t) => {
|
|
2791
2735
|
let n = t.doc.resolve(e), r = n.marks().find((e) => e.type.name === "link");
|
|
2792
2736
|
if (!r) return;
|
|
2793
|
-
let i =
|
|
2737
|
+
let i = Je(n, r.type);
|
|
2794
2738
|
if (i) return {
|
|
2795
2739
|
href: r.attrs.href,
|
|
2796
2740
|
from: i.from,
|
|
@@ -2830,10 +2774,10 @@ var Ci = class {
|
|
|
2830
2774
|
//#endregion
|
|
2831
2775
|
//#region src/editor/transformPasted.ts
|
|
2832
2776
|
function wi(e) {
|
|
2833
|
-
return
|
|
2777
|
+
return Ge(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2834
2778
|
}
|
|
2835
2779
|
function Ti(e, t) {
|
|
2836
|
-
let n = t.nodes.hardBreak, r =
|
|
2780
|
+
let n = t.nodes.hardBreak, r = N.empty;
|
|
2837
2781
|
return e.forEach((e) => {
|
|
2838
2782
|
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(Ti(e.content, t)), r = r.addToEnd(n.create()));
|
|
2839
2783
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
@@ -2842,7 +2786,7 @@ function Ei(e, t) {
|
|
|
2842
2786
|
let n = [];
|
|
2843
2787
|
return e.forEach((e, r, i) => {
|
|
2844
2788
|
i !== t && n.push(e);
|
|
2845
|
-
}),
|
|
2789
|
+
}), N.from(n);
|
|
2846
2790
|
}
|
|
2847
2791
|
function Di(e, t) {
|
|
2848
2792
|
let n = [];
|
|
@@ -2854,10 +2798,10 @@ function Di(e, t) {
|
|
|
2854
2798
|
n.push(i);
|
|
2855
2799
|
}
|
|
2856
2800
|
else n.push(e.child(r));
|
|
2857
|
-
return e =
|
|
2801
|
+
return e = N.from(n), e;
|
|
2858
2802
|
}
|
|
2859
2803
|
function Oi(e, t) {
|
|
2860
|
-
let n =
|
|
2804
|
+
let n = N.from(e.content);
|
|
2861
2805
|
n = Di(n, t.state.schema);
|
|
2862
2806
|
let r = ki(n, t, e);
|
|
2863
2807
|
if (r) return r;
|
|
@@ -2865,9 +2809,9 @@ function Oi(e, t) {
|
|
|
2865
2809
|
let e = !1;
|
|
2866
2810
|
if (n.descendants((t) => {
|
|
2867
2811
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2868
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new
|
|
2812
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new P(Ti(n, t.state.schema), 0, 0);
|
|
2869
2813
|
}
|
|
2870
|
-
if (!Ai(n, t)) return new
|
|
2814
|
+
if (!Ai(n, t)) return new P(n, e.openStart, e.openEnd);
|
|
2871
2815
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2872
2816
|
let r = [n.child(e)];
|
|
2873
2817
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
@@ -2877,7 +2821,7 @@ function Oi(e, t) {
|
|
|
2877
2821
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2878
2822
|
n = n.replaceChild(e, i);
|
|
2879
2823
|
}
|
|
2880
|
-
return new
|
|
2824
|
+
return new P(n, e.openStart, e.openEnd);
|
|
2881
2825
|
}
|
|
2882
2826
|
function ki(e, t, n) {
|
|
2883
2827
|
if (wi(t) || t.dragging) return null;
|
|
@@ -2886,7 +2830,7 @@ function ki(e, t, n) {
|
|
|
2886
2830
|
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2887
2831
|
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
2888
2832
|
let c = i.type.create(i.attrs, s.content), l = o.copy(o.content.replaceChild(0, c)), u = a.copy(a.content.replaceChild(0, l));
|
|
2889
|
-
return new
|
|
2833
|
+
return new P(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2890
2834
|
}
|
|
2891
2835
|
function Ai(e, t) {
|
|
2892
2836
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
@@ -2905,7 +2849,8 @@ var ji = {
|
|
|
2905
2849
|
enableInputRules: !0,
|
|
2906
2850
|
enablePasteRules: !0,
|
|
2907
2851
|
enableCoreExtensions: !1
|
|
2908
|
-
}, Mi = class e extends
|
|
2852
|
+
}, Mi = class e extends B {
|
|
2853
|
+
options;
|
|
2909
2854
|
pmSchema;
|
|
2910
2855
|
_tiptapEditor;
|
|
2911
2856
|
elementRenderer = null;
|
|
@@ -2924,7 +2869,7 @@ var ji = {
|
|
|
2924
2869
|
return new e(t ?? {});
|
|
2925
2870
|
}
|
|
2926
2871
|
constructor(e) {
|
|
2927
|
-
super(), this.options = e, this.dictionary = e.dictionary ||
|
|
2872
|
+
super(), this.options = e, this.dictionary = e.dictionary || Ne, this.settings = { tables: {
|
|
2928
2873
|
splitCells: e?.tables?.splitCells ?? !1,
|
|
2929
2874
|
cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
|
|
2930
2875
|
cellTextColor: e?.tables?.cellTextColor ?? !1,
|
|
@@ -2950,59 +2895,57 @@ var ji = {
|
|
|
2950
2895
|
}
|
|
2951
2896
|
};
|
|
2952
2897
|
}
|
|
2953
|
-
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new
|
|
2954
|
-
let n = this._extensionManager.getTiptapExtensions(), r =
|
|
2955
|
-
r && t.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
|
|
2956
|
-
let i = {
|
|
2898
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Zt(this), this._extensionManager = new hi(this, t);
|
|
2899
|
+
let n = this._extensionManager.getTiptapExtensions(), r = {
|
|
2957
2900
|
...ji,
|
|
2958
2901
|
...t._tiptapOptions,
|
|
2959
2902
|
element: null,
|
|
2960
2903
|
autofocus: t.autofocus ?? !1,
|
|
2961
2904
|
extensions: n,
|
|
2962
2905
|
editorProps: {
|
|
2906
|
+
scrollMargin: {
|
|
2907
|
+
top: 72,
|
|
2908
|
+
bottom: 72,
|
|
2909
|
+
left: 0,
|
|
2910
|
+
right: 0
|
|
2911
|
+
},
|
|
2963
2912
|
...t._tiptapOptions?.editorProps,
|
|
2964
2913
|
attributes: {
|
|
2965
2914
|
tabIndex: "0",
|
|
2966
2915
|
...t._tiptapOptions?.editorProps?.attributes,
|
|
2967
2916
|
...t.domAttributes?.editor,
|
|
2968
|
-
class:
|
|
2917
|
+
class: o("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
2969
2918
|
},
|
|
2970
2919
|
transformPasted: Oi
|
|
2971
2920
|
}
|
|
2972
2921
|
};
|
|
2973
2922
|
try {
|
|
2974
|
-
let e = t.initialContent ||
|
|
2975
|
-
type: "paragraph",
|
|
2976
|
-
id: "initialBlockId"
|
|
2977
|
-
}] : [{
|
|
2923
|
+
let e = t.initialContent || [{
|
|
2978
2924
|
type: "paragraph",
|
|
2979
2925
|
id: u.options.generateID()
|
|
2980
|
-
}]
|
|
2981
|
-
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + e);
|
|
2982
|
-
let n =
|
|
2926
|
+
}];
|
|
2927
|
+
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(e));
|
|
2928
|
+
let n = Xe(r.extensions);
|
|
2929
|
+
n.cached.blockNoteEditor = this;
|
|
2930
|
+
let i = Ue({
|
|
2983
2931
|
type: "doc",
|
|
2984
2932
|
content: [{
|
|
2985
2933
|
type: "blockGroup",
|
|
2986
|
-
content: e.map((e) =>
|
|
2934
|
+
content: e.map((e) => b(e, n, this.schema.styleSchema).toJSON())
|
|
2987
2935
|
}]
|
|
2988
|
-
}, n,
|
|
2989
|
-
this._tiptapEditor = new
|
|
2990
|
-
...
|
|
2991
|
-
content:
|
|
2936
|
+
}, n, r.parseOptions);
|
|
2937
|
+
this._tiptapEditor = new Be({
|
|
2938
|
+
...r,
|
|
2939
|
+
content: i.toJSON()
|
|
2992
2940
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
2993
2941
|
} catch (e) {
|
|
2994
2942
|
throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
|
|
2995
2943
|
}
|
|
2996
|
-
|
|
2997
|
-
this.pmSchema.nodes.doc.createAndFill = (...e) => {
|
|
2998
|
-
if (a) return a;
|
|
2999
|
-
let t = o.apply(this.pmSchema.nodes.doc, e), n = JSON.parse(JSON.stringify(t.toJSON()));
|
|
3000
|
-
return n.content[0].content[0].attrs.id = "initialBlockId", a = Re.fromJSON(this.pmSchema, n), a;
|
|
3001
|
-
}, this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
|
|
2944
|
+
this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
|
|
3002
2945
|
this.headless = !1;
|
|
3003
2946
|
}), this._tiptapEditor.on("unmount", () => {
|
|
3004
2947
|
this.headless = !0;
|
|
3005
|
-
}), this._blockManager = new
|
|
2948
|
+
}), this._blockManager = new Xt(this), this._exportManager = new Gn(this), this._selectionManager = new bi(this), this._stateManager = new xi(this), this._styleManager = new Ci(this), this.emit("create");
|
|
3006
2949
|
}
|
|
3007
2950
|
_blockManager;
|
|
3008
2951
|
_eventManager;
|
|
@@ -3025,6 +2968,7 @@ var ji = {
|
|
|
3025
2968
|
}
|
|
3026
2969
|
unregisterExtension = (...e) => this._extensionManager.unregisterExtension(...e);
|
|
3027
2970
|
registerExtension = (...e) => this._extensionManager.registerExtension(...e);
|
|
2971
|
+
replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
|
|
3028
2972
|
getExtension = ((...e) => this._extensionManager.getExtension(...e));
|
|
3029
2973
|
mount = (e, t) => {
|
|
3030
2974
|
let n = e.getRootNode(), r = typeof ShadowRoot < "u" && n instanceof ShadowRoot;
|
|
@@ -3098,7 +3042,7 @@ var ji = {
|
|
|
3098
3042
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
3099
3043
|
}
|
|
3100
3044
|
onBeforeChange(e) {
|
|
3101
|
-
return this._extensionManager.getExtension(
|
|
3045
|
+
return this._extensionManager.getExtension(ve).subscribe(e);
|
|
3102
3046
|
}
|
|
3103
3047
|
getTextCursorPosition() {
|
|
3104
3048
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -3234,6 +3178,8 @@ var ji = {
|
|
|
3234
3178
|
return this._exportManager.pasteMarkdown(e);
|
|
3235
3179
|
}
|
|
3236
3180
|
}, Ni = class {
|
|
3181
|
+
mappings;
|
|
3182
|
+
options;
|
|
3237
3183
|
constructor(e, t, n) {
|
|
3238
3184
|
this.mappings = t, this.options = n;
|
|
3239
3185
|
}
|
|
@@ -3275,6 +3221,6 @@ function Fi(e, ...t) {
|
|
|
3275
3221
|
return n;
|
|
3276
3222
|
}
|
|
3277
3223
|
//#endregion
|
|
3278
|
-
export { L as _, gi as a,
|
|
3224
|
+
export { I as C, dt as D, ft as E, L as S, pt as T, Dt as _, gi as a, Tt as b, Un as c, Jt as d, Yt as f, kt as g, Ot as h, Mi as i, U as l, B as m, Pi as n, vr as o, qt as p, Ni as r, Wn as s, Fi as t, Kt as u, z as v, mt as w, R as x, At as y };
|
|
3279
3225
|
|
|
3280
|
-
//# sourceMappingURL=src-
|
|
3226
|
+
//# sourceMappingURL=src-DTF83Cl9.js.map
|