@blocknote/core 0.51.3 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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-D0lMxErU.js → blocks-CiuUGa1E.js} +1096 -998
- 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-D2mx2C9y.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-Dvmif2FY.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 +129 -0
- package/src/blocks/Table/TableExtension.ts +23 -20
- 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 +39 -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/ExtensionManager.test.d.ts +1 -0
- 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-D0lMxErU.js.map +0 -1
- package/dist/blocks-KyMOxPT3.cjs +0 -11
- package/dist/blocks-KyMOxPT3.cjs.map +0 -1
- package/dist/en-B9hMApn4.js.map +0 -1
- package/dist/en-Cj5r8sW_.cjs.map +0 -1
- package/dist/extensions-Cutrafjg.cjs +0 -52
- package/dist/extensions-Cutrafjg.cjs.map +0 -1
- package/dist/extensions-D2mx2C9y.js.map +0 -1
- package/dist/src-D5R5YzV7.cjs +0 -21
- package/dist/src-D5R5YzV7.cjs.map +0 -1
- package/dist/src-Dvmif2FY.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 → blocks/Table/TableExtension.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,63 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { uuidv4 as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { history as Pe, redo as Fe, undo as Ie } from "@tiptap/pm/history";
|
|
1
|
+
import { $n as e, At as t, Bt as n, Ft as r, Ht as i, In as a, It as o, Lt as s, Mt as c, Nt as l, Pt as u, Rt as d, Ut as f, Vt as p, _ as m, bn as h, g, kt as ee, r as te, yn as _, zt as v } from "./blocks-CiuUGa1E.js";
|
|
2
|
+
import { n as y, t as b } from "./BlockNoteExtension-B_IEJHS8.js";
|
|
3
|
+
import { n as ne } from "./UserStore-QbbPFj0z.js";
|
|
4
|
+
import { DOMSerializer as x, Fragment as S, Slice as re } from "prosemirror-model";
|
|
5
|
+
import { Mapping as ie, dropPoint as ae } from "prosemirror-transform";
|
|
6
|
+
import { combineTransactionSteps as oe, findChildrenInRange as se, posToDOMRect as ce } from "@tiptap/core";
|
|
7
|
+
import { uuidv4 as le } from "lib0/random";
|
|
8
|
+
import { NodeSelection as ue, Plugin as C, PluginKey as w, Selection as T, TextSelection as de } from "prosemirror-state";
|
|
9
|
+
import { DOMParser as fe, Slice as pe } from "@tiptap/pm/model";
|
|
10
|
+
import { CellSelection as me, addColumnAfter as he, addColumnBefore as ge, addRowAfter as _e, addRowBefore as ve, deleteColumn as ye, deleteRow as be, mergeCells as xe, splitCell as Se } from "prosemirror-tables";
|
|
11
|
+
import { Plugin as Ce, PluginKey as we, TextSelection as Te } from "@tiptap/pm/state";
|
|
12
|
+
import { Decoration as E, DecorationSet as D } from "prosemirror-view";
|
|
13
|
+
import Ee from "fast-deep-equal";
|
|
14
|
+
import { history as De, redo as Oe, undo as ke } from "@tiptap/pm/history";
|
|
16
15
|
//#region src/api/exporters/html/util/serializeBlocksExternalHTML.ts
|
|
17
|
-
function
|
|
16
|
+
function Ae(e) {
|
|
18
17
|
let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
|
|
19
18
|
t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
|
|
20
19
|
}
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
if (!
|
|
24
|
-
if (typeof
|
|
25
|
-
else if (Array.isArray(
|
|
26
|
-
else if (
|
|
27
|
-
else throw new
|
|
28
|
-
let o = (
|
|
29
|
-
for (let
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
let a =
|
|
20
|
+
function O(e, t, n, r) {
|
|
21
|
+
let i;
|
|
22
|
+
if (!t) throw Error("blockContent is required");
|
|
23
|
+
if (typeof t == "string") i = c([t], e.pmSchema, r?.blockType);
|
|
24
|
+
else if (Array.isArray(t)) i = c(t, e.pmSchema, r?.blockType);
|
|
25
|
+
else if (t.type === "tableContent") i = l(t, e.pmSchema);
|
|
26
|
+
else throw new a(t.type);
|
|
27
|
+
let o = (r?.document ?? document).createDocumentFragment();
|
|
28
|
+
for (let t of i) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
29
|
+
let i = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
30
|
+
if (i) {
|
|
31
|
+
let a = h(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = i.toExternalHTML ? i.toExternalHTML(a, e) : i.render.call({
|
|
33
32
|
renderType: "dom",
|
|
34
33
|
props: void 0
|
|
35
|
-
}, a, () => {},
|
|
34
|
+
}, a, () => {}, e);
|
|
36
35
|
if (s) {
|
|
37
36
|
if (o.appendChild(s.dom), s.contentDOM) {
|
|
38
|
-
let
|
|
39
|
-
s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(
|
|
37
|
+
let e = n.serializeFragment(t.content, r);
|
|
38
|
+
s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(e);
|
|
40
39
|
}
|
|
41
40
|
continue;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
} else if (
|
|
45
|
-
let n = document.createTextNode(
|
|
46
|
-
for (let r of
|
|
47
|
-
let
|
|
48
|
-
|
|
43
|
+
} else if (t.type.name === "text") {
|
|
44
|
+
let n = document.createTextNode(t.textContent);
|
|
45
|
+
for (let r of t.marks.toReversed()) if (r.type.name in e.schema.styleSpecs) {
|
|
46
|
+
let t = (e.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? e.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, e);
|
|
47
|
+
t.contentDOM.appendChild(n), n = t.dom;
|
|
49
48
|
} else {
|
|
50
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
49
|
+
let e = r.type.spec.toDOM(r, !0), t = x.renderSpec(document, e);
|
|
51
50
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
52
51
|
}
|
|
53
52
|
o.appendChild(n);
|
|
54
53
|
} else {
|
|
55
|
-
let
|
|
56
|
-
o.appendChild(
|
|
54
|
+
let e = n.serializeFragment(S.from([t]), r);
|
|
55
|
+
o.appendChild(e);
|
|
57
56
|
}
|
|
58
|
-
return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 &&
|
|
57
|
+
return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 && Ae(o.firstChild), o;
|
|
59
58
|
}
|
|
60
|
-
function
|
|
59
|
+
function je(e, t, n, r, i, a, o, s) {
|
|
61
60
|
let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
|
|
62
61
|
for (let [e, r] of Object.entries(t.schema.blockSchema[n.type].propSchema)) !(e in u) && r.default !== void 0 && (u[e] = r.default);
|
|
63
62
|
let d = l.spec?.toDOM?.(l.create({
|
|
@@ -73,10 +72,10 @@ function ze(e, t, n, r, i, a, o, s) {
|
|
|
73
72
|
if (m.dom.classList.contains("bn-block-content")) {
|
|
74
73
|
let e = [...f, ...Array.from(m.dom.attributes)].filter((e) => e.name.startsWith("data") && e.name !== "data-content-type" && e.name !== "data-file-block" && e.name !== "data-node-view-wrapper" && e.name !== "data-node-type" && e.name !== "data-id" && e.name !== "data-editable");
|
|
75
74
|
for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
|
|
76
|
-
|
|
75
|
+
Ae(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
|
|
77
76
|
} else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
|
|
78
77
|
if (m.contentDOM && n.content) {
|
|
79
|
-
let e =
|
|
78
|
+
let e = O(t, n.content, r, {
|
|
80
79
|
...s,
|
|
81
80
|
blockType: n.type
|
|
82
81
|
});
|
|
@@ -86,26 +85,26 @@ function ze(e, t, n, r, i, a, o, s) {
|
|
|
86
85
|
if (i.has(n.type) ? g = "OL" : a.has(n.type) && (g = "UL"), g) {
|
|
87
86
|
if (e.lastChild?.nodeName !== g) {
|
|
88
87
|
let t = c.createElement(g);
|
|
89
|
-
g === "OL" && "start" in u && u.start && u?.start !== 1 && t.setAttribute("start", u.start
|
|
88
|
+
g === "OL" && "start" in u && u.start && u?.start !== 1 && t.setAttribute("start", String(u.start)), e.append(t);
|
|
90
89
|
}
|
|
91
90
|
e.lastChild.appendChild(h);
|
|
92
91
|
} else e.append(h);
|
|
93
92
|
if (n.children && n.children.length > 0) {
|
|
94
93
|
let l = c.createDocumentFragment();
|
|
95
|
-
if (
|
|
94
|
+
if (Me(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
|
|
96
95
|
"childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
|
-
var
|
|
100
|
-
for (let c of n)
|
|
101
|
-
},
|
|
98
|
+
var Me = (e, t, n, r, i, a, o = 0, s) => {
|
|
99
|
+
for (let c of n) je(e, t, c, r, i, a, o, s);
|
|
100
|
+
}, Ne = (e, t, n, r, i, a) => {
|
|
102
101
|
let o = (a?.document ?? document).createDocumentFragment();
|
|
103
|
-
return
|
|
104
|
-
},
|
|
105
|
-
let n =
|
|
102
|
+
return Me(o, e, t, n, r, i, 0, a), o;
|
|
103
|
+
}, k = (e, t) => {
|
|
104
|
+
let n = x.fromSchema(e);
|
|
106
105
|
return {
|
|
107
106
|
exportBlocks: (e, r) => {
|
|
108
|
-
let i =
|
|
107
|
+
let i = Ne(t, e, n, new Set(["numberedListItem"]), new Set([
|
|
109
108
|
"bulletListItem",
|
|
110
109
|
"checkListItem",
|
|
111
110
|
"toggleListItem"
|
|
@@ -113,41 +112,41 @@ var Be = (e, t, n, r, i, a, o = 0, s) => {
|
|
|
113
112
|
return a.append(i), a.innerHTML;
|
|
114
113
|
},
|
|
115
114
|
exportInlineContent: (e, r) => {
|
|
116
|
-
let i =
|
|
115
|
+
let i = O(t, e, n, r), a = document.createElement("div");
|
|
117
116
|
return a.append(i.cloneNode(!0)), a.innerHTML;
|
|
118
117
|
}
|
|
119
118
|
};
|
|
120
119
|
};
|
|
121
120
|
//#endregion
|
|
122
121
|
//#region src/api/getBlocksChangedByTransaction.ts
|
|
123
|
-
function
|
|
124
|
-
if (
|
|
125
|
-
let
|
|
126
|
-
for (let
|
|
127
|
-
let
|
|
128
|
-
if (
|
|
122
|
+
function Pe(n, r) {
|
|
123
|
+
if (r === 0) return;
|
|
124
|
+
let i = n.resolve(r);
|
|
125
|
+
for (let r = i.depth; r > 0; r--) {
|
|
126
|
+
let a = i.node(r);
|
|
127
|
+
if (t(a)) return e(a, n);
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
|
-
function
|
|
130
|
+
function Fe(e) {
|
|
132
131
|
return e.getMeta("paste") ? { type: "paste" } : e.getMeta("uiEvent") === "drop" ? { type: "drop" } : e.getMeta("history$") ? { type: e.getMeta("history$").redo ? "redo" : "undo" } : e.getMeta("y-sync$") ? e.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
133
132
|
}
|
|
134
|
-
function
|
|
135
|
-
let
|
|
136
|
-
return
|
|
137
|
-
if (!
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
let l =
|
|
141
|
-
return
|
|
133
|
+
function Ie(n) {
|
|
134
|
+
let r = {}, i = {};
|
|
135
|
+
return n.descendants((a, o) => {
|
|
136
|
+
if (!t(a)) return !0;
|
|
137
|
+
let s = Pe(n, o), c = s ?? "__root__";
|
|
138
|
+
i[c] || (i[c] = []);
|
|
139
|
+
let l = _(a, n), u = e(a, n);
|
|
140
|
+
return r[u] = {
|
|
142
141
|
block: l,
|
|
143
|
-
parentId:
|
|
144
|
-
},
|
|
142
|
+
parentId: s
|
|
143
|
+
}, i[c].push(u), !0;
|
|
145
144
|
}), {
|
|
146
|
-
byId:
|
|
147
|
-
childrenByParent:
|
|
145
|
+
byId: r,
|
|
146
|
+
childrenByParent: i
|
|
148
147
|
};
|
|
149
148
|
}
|
|
150
|
-
function
|
|
149
|
+
function Le(e, t) {
|
|
151
150
|
let n = /* @__PURE__ */ new Set();
|
|
152
151
|
if (!e || !t) return n;
|
|
153
152
|
let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
|
|
@@ -171,8 +170,8 @@ function Ge(e, t) {
|
|
|
171
170
|
for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
|
|
172
171
|
return n;
|
|
173
172
|
}
|
|
174
|
-
function
|
|
175
|
-
let n =
|
|
173
|
+
function Re(e, t = []) {
|
|
174
|
+
let n = Fe(e), r = oe(e.before, [e, ...t]), i = Ie(r.before), a = Ie(r.doc), o = [], s = /* @__PURE__ */ new Set();
|
|
176
175
|
Object.keys(a.byId).filter((e) => !(e in i.byId)).forEach((e) => {
|
|
177
176
|
o.push({
|
|
178
177
|
type: "insert",
|
|
@@ -189,7 +188,7 @@ function Ke(e, t = []) {
|
|
|
189
188
|
}), s.add(e);
|
|
190
189
|
}), Object.keys(a.byId).filter((e) => e in i.byId).forEach((e) => {
|
|
191
190
|
let t = i.byId[e], r = a.byId[e];
|
|
192
|
-
t.parentId === r.parentId ?
|
|
191
|
+
t.parentId === r.parentId ? Ee({
|
|
193
192
|
...t.block,
|
|
194
193
|
children: void 0
|
|
195
194
|
}, {
|
|
@@ -211,7 +210,7 @@ function Ke(e, t = []) {
|
|
|
211
210
|
});
|
|
212
211
|
let c = i.childrenByParent, l = a.childrenByParent, u = new Set([...Object.keys(c), ...Object.keys(l)]), d = /* @__PURE__ */ new Set();
|
|
213
212
|
return u.forEach((e) => {
|
|
214
|
-
let t =
|
|
213
|
+
let t = Le(c[e], l[e]);
|
|
215
214
|
t.size !== 0 && t.forEach((t) => {
|
|
216
215
|
let r = i.byId[t], c = a.byId[t];
|
|
217
216
|
!r || !c || r.parentId === c.parentId && (s.has(t) || (r.parentId ?? "__root__") === e && (d.has(t) || (d.add(t), o.push({
|
|
@@ -227,17 +226,17 @@ function Ke(e, t = []) {
|
|
|
227
226
|
}
|
|
228
227
|
//#endregion
|
|
229
228
|
//#region src/extensions/BlockChange/BlockChange.ts
|
|
230
|
-
var
|
|
229
|
+
var ze = b(() => {
|
|
231
230
|
let e = [];
|
|
232
231
|
return {
|
|
233
232
|
key: "blockChange",
|
|
234
|
-
prosemirrorPlugins: [new
|
|
235
|
-
key: new
|
|
233
|
+
prosemirrorPlugins: [new C({
|
|
234
|
+
key: new w("blockChange"),
|
|
236
235
|
filterTransaction: (t) => {
|
|
237
236
|
let n;
|
|
238
237
|
return e.reduce((e, r) => e === !1 ? e : r({
|
|
239
238
|
getChanges() {
|
|
240
|
-
return n || (n =
|
|
239
|
+
return n || (n = Re(t), n);
|
|
241
240
|
},
|
|
242
241
|
tr: t
|
|
243
242
|
}) !== !1, !0);
|
|
@@ -251,189 +250,11 @@ var qe = v(() => {
|
|
|
251
250
|
};
|
|
252
251
|
});
|
|
253
252
|
//#endregion
|
|
254
|
-
//#region src/extensions/Collaboration/YCursorPlugin.ts
|
|
255
|
-
function Je(e) {
|
|
256
|
-
let t = e.charAt(0) === "#" ? e.substring(1, 7) : e, n = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), i = parseInt(t.substring(4, 6), 16), a = [
|
|
257
|
-
n / 255,
|
|
258
|
-
r / 255,
|
|
259
|
-
i / 255
|
|
260
|
-
].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
|
|
261
|
-
return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
|
|
262
|
-
}
|
|
263
|
-
function Ye(e) {
|
|
264
|
-
let t = document.createElement("span");
|
|
265
|
-
t.classList.add("bn-collaboration-cursor__base");
|
|
266
|
-
let n = document.createElement("span");
|
|
267
|
-
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${Je(e.color) ? "white" : "black"}`);
|
|
268
|
-
let r = document.createElement("span");
|
|
269
|
-
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${Je(e.color) ? "white" : "black"}`), r.insertBefore(document.createTextNode(e.name), null), n.insertBefore(r, null), t.insertBefore(document.createTextNode(""), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode(""), null), t;
|
|
270
|
-
}
|
|
271
|
-
var k = v(({ options: e }) => {
|
|
272
|
-
let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
|
|
273
|
-
return n && ("setLocalStateField" in n && typeof n.setLocalStateField == "function" && n.setLocalStateField("user", e.user), "on" in n && typeof n.on == "function" && e.showCursorLabels !== "always" && n.on("change", ({ updated: e }) => {
|
|
274
|
-
for (let n of e) {
|
|
275
|
-
let e = t.get(n);
|
|
276
|
-
e && (setTimeout(() => {
|
|
277
|
-
e.element.setAttribute("data-active", "");
|
|
278
|
-
}, 10), e.hideTimeout && clearTimeout(e.hideTimeout), t.set(n, {
|
|
279
|
-
element: e.element,
|
|
280
|
-
hideTimeout: setTimeout(() => {
|
|
281
|
-
e.element.removeAttribute("data-active");
|
|
282
|
-
}, 2e3)
|
|
283
|
-
}));
|
|
284
|
-
}
|
|
285
|
-
})), {
|
|
286
|
-
key: "yCursor",
|
|
287
|
-
prosemirrorPlugins: [n ? Ae(n, {
|
|
288
|
-
selectionBuilder: De,
|
|
289
|
-
cursorBuilder(n, r) {
|
|
290
|
-
let i = t.get(r);
|
|
291
|
-
if (!i) {
|
|
292
|
-
let a = (e.renderCursor ?? Ye)(n);
|
|
293
|
-
e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
|
|
294
|
-
let e = t.get(r);
|
|
295
|
-
e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
|
|
296
|
-
element: e.element,
|
|
297
|
-
hideTimeout: void 0
|
|
298
|
-
}));
|
|
299
|
-
}), a.addEventListener("mouseleave", () => {
|
|
300
|
-
let e = t.get(r);
|
|
301
|
-
t.set(r, {
|
|
302
|
-
element: e.element,
|
|
303
|
-
hideTimeout: setTimeout(() => {
|
|
304
|
-
e.element.removeAttribute("data-active");
|
|
305
|
-
}, 2e3)
|
|
306
|
-
});
|
|
307
|
-
})), i = {
|
|
308
|
-
element: a,
|
|
309
|
-
hideTimeout: void 0
|
|
310
|
-
}, t.set(r, i);
|
|
311
|
-
}
|
|
312
|
-
return i.element;
|
|
313
|
-
}
|
|
314
|
-
}) : void 0].filter(Boolean),
|
|
315
|
-
dependsOn: ["ySync"],
|
|
316
|
-
updateUser(e) {
|
|
317
|
-
n?.setLocalStateField("user", e);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
}), A = v(({ options: e }) => ({
|
|
321
|
-
key: "ySync",
|
|
322
|
-
prosemirrorPlugins: [je(e.fragment)],
|
|
323
|
-
runsBefore: ["default"]
|
|
324
|
-
})), j = v(() => ({
|
|
325
|
-
key: "yUndo",
|
|
326
|
-
prosemirrorPlugins: [Me()],
|
|
327
|
-
dependsOn: ["yCursor", "ySync"],
|
|
328
|
-
undoCommand: ke,
|
|
329
|
-
redoCommand: Oe
|
|
330
|
-
}));
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region src/extensions/Collaboration/ForkYDoc.ts
|
|
333
|
-
function Xe(e, t) {
|
|
334
|
-
let n = e.doc;
|
|
335
|
-
if (e._item === null) {
|
|
336
|
-
let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
|
|
337
|
-
if (r == null) throw Error("type does not exist in other ydoc");
|
|
338
|
-
return t.get(r, e.constructor);
|
|
339
|
-
} else {
|
|
340
|
-
let n = e._item, r = t.store.clients.get(n.id.client) ?? [];
|
|
341
|
-
return r[D.findIndexSS(r, n.id.clock)].content.type;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
var Ze = v(({ editor: e, options: t }) => {
|
|
345
|
-
let n, r = _({ isForked: !1 });
|
|
346
|
-
return {
|
|
347
|
-
key: "yForkDoc",
|
|
348
|
-
store: r,
|
|
349
|
-
fork() {
|
|
350
|
-
if (n) return;
|
|
351
|
-
let i = t.fragment;
|
|
352
|
-
if (!i) throw Error("No fragment to fork from");
|
|
353
|
-
let a = new D.Doc();
|
|
354
|
-
D.applyUpdate(a, D.encodeStateAsUpdate(i.doc));
|
|
355
|
-
let o = Xe(i, a);
|
|
356
|
-
n = {
|
|
357
|
-
undoStack: E.getState(e.prosemirrorState).undoManager.undoStack,
|
|
358
|
-
originalFragment: i,
|
|
359
|
-
forkedFragment: o
|
|
360
|
-
}, e.unregisterExtension([
|
|
361
|
-
j,
|
|
362
|
-
k,
|
|
363
|
-
A
|
|
364
|
-
]);
|
|
365
|
-
let s = {
|
|
366
|
-
...t,
|
|
367
|
-
fragment: o
|
|
368
|
-
};
|
|
369
|
-
e.registerExtension([A(s), j()]), r.setState({ isForked: !0 });
|
|
370
|
-
},
|
|
371
|
-
merge({ keepChanges: i }) {
|
|
372
|
-
if (!n) return;
|
|
373
|
-
e.unregisterExtension([
|
|
374
|
-
"ySync",
|
|
375
|
-
"yCursor",
|
|
376
|
-
"yUndo"
|
|
377
|
-
]);
|
|
378
|
-
let { originalFragment: a, forkedFragment: o, undoStack: s } = n;
|
|
379
|
-
if (e.registerExtension([
|
|
380
|
-
A(t),
|
|
381
|
-
k(t),
|
|
382
|
-
j()
|
|
383
|
-
]), E.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
|
|
384
|
-
let t = D.encodeStateAsUpdate(o.doc, D.encodeStateVector(a.doc));
|
|
385
|
-
D.applyUpdate(a.doc, t, e);
|
|
386
|
-
}
|
|
387
|
-
n = void 0, r.setState({ isForked: !1 });
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
}), M = (e, t) => {
|
|
391
|
-
t(e), e.forEach((e) => {
|
|
392
|
-
e instanceof D.XmlElement && M(e, t);
|
|
393
|
-
});
|
|
394
|
-
}, Qe = [(e, t) => {
|
|
395
|
-
let n = /* @__PURE__ */ new Map();
|
|
396
|
-
return e.forEach((e) => {
|
|
397
|
-
e instanceof D.XmlElement && M(e, (e) => {
|
|
398
|
-
if (e.nodeName === "blockContainer" && e.hasAttribute("id")) {
|
|
399
|
-
let t = e.getAttribute("textColor"), r = e.getAttribute("backgroundColor"), i = {
|
|
400
|
-
textColor: t === g.textColor.default ? void 0 : t,
|
|
401
|
-
backgroundColor: r === g.backgroundColor.default ? void 0 : r
|
|
402
|
-
};
|
|
403
|
-
(i.textColor || i.backgroundColor) && n.set(e.getAttribute("id"), i);
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
}), n.size === 0 ? !1 : (t.doc.descendants((e, r) => {
|
|
407
|
-
if (e.type.name === "blockContainer" && n.has(e.attrs.id)) {
|
|
408
|
-
let i = t.doc.nodeAt(r + 1);
|
|
409
|
-
if (!i) throw Error("No element found");
|
|
410
|
-
t.setNodeMarkup(r + 1, void 0, {
|
|
411
|
-
...i.attrs,
|
|
412
|
-
...n.get(e.attrs.id)
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
}), !0);
|
|
416
|
-
}], $e = v(({ options: e }) => {
|
|
417
|
-
let t = !1;
|
|
418
|
-
return {
|
|
419
|
-
key: "schemaMigration",
|
|
420
|
-
prosemirrorPlugins: [new C({
|
|
421
|
-
key: new Te("schemaMigration"),
|
|
422
|
-
appendTransaction: (n, r, i) => {
|
|
423
|
-
if (t || !n.some((e) => e.getMeta("y-sync$")) || n.every((e) => !e.docChanged) || !e.fragment.firstChild) return;
|
|
424
|
-
let a = i.tr;
|
|
425
|
-
for (let t of Qe) t(e.fragment, a);
|
|
426
|
-
if (t = !0, a.docChanged) return a;
|
|
427
|
-
}
|
|
428
|
-
})]
|
|
429
|
-
};
|
|
430
|
-
});
|
|
431
|
-
//#endregion
|
|
432
253
|
//#region src/extensions/DropCursor/utils.ts
|
|
433
|
-
function
|
|
254
|
+
function Be(e, t) {
|
|
434
255
|
return !e || !t ? !1 : !!e.closest(`.${t}`);
|
|
435
256
|
}
|
|
436
|
-
function
|
|
257
|
+
function Ve(e, t, n, r, i) {
|
|
437
258
|
let a = e.state.doc.resolve(t.pos);
|
|
438
259
|
if (a.parent.inlineContent || t.orientation === "inline") return null;
|
|
439
260
|
let o = a.nodeBefore, s = a.nodeAfter;
|
|
@@ -460,7 +281,7 @@ function tt(e, t, n, r, i) {
|
|
|
460
281
|
bottom: f + p
|
|
461
282
|
};
|
|
462
283
|
}
|
|
463
|
-
function
|
|
284
|
+
function He(e, t, n, r) {
|
|
464
285
|
let i = e.coordsAtPos(t.pos), a = n / 2 * r;
|
|
465
286
|
return {
|
|
466
287
|
left: i.left - a,
|
|
@@ -469,10 +290,10 @@ function nt(e, t, n, r) {
|
|
|
469
290
|
bottom: i.bottom
|
|
470
291
|
};
|
|
471
292
|
}
|
|
472
|
-
function
|
|
293
|
+
function Ue(e, t) {
|
|
473
294
|
e.classList.toggle("prosemirror-dropcursor-inline", t === "inline"), e.classList.toggle("prosemirror-dropcursor-block-horizontal", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-block-vertical-left", t === "block-vertical-left"), e.classList.toggle("prosemirror-dropcursor-block-vertical-right", t === "block-vertical-right"), e.classList.toggle("prosemirror-dropcursor-block", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-vertical", t === "block-vertical-left" || t === "block-vertical-right");
|
|
474
295
|
}
|
|
475
|
-
function
|
|
296
|
+
function We(e) {
|
|
476
297
|
if (!e || e === document.body && getComputedStyle(e).position === "static") return {
|
|
477
298
|
parentLeft: -window.pageXOffset,
|
|
478
299
|
parentTop: -window.pageYOffset
|
|
@@ -485,7 +306,7 @@ function it(e) {
|
|
|
485
306
|
}
|
|
486
307
|
//#endregion
|
|
487
308
|
//#region src/extensions/DropCursor/DropCursor.ts
|
|
488
|
-
var
|
|
309
|
+
var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
489
310
|
let n = null, r = null, i = -1, a = null, o = {
|
|
490
311
|
width: t.dropCursor?.width ?? 5,
|
|
491
312
|
color: t.dropCursor?.color ?? "#ddeeff",
|
|
@@ -495,9 +316,9 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
495
316
|
e?.pos === n?.pos && e?.orientation === n?.orientation || (n = e, e == null ? (r && r.parentNode && r.parentNode.removeChild(r), r = null) : c());
|
|
496
317
|
}, c = () => {
|
|
497
318
|
if (!n) return;
|
|
498
|
-
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l =
|
|
499
|
-
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)),
|
|
500
|
-
let { parentLeft: d, parentTop: f } =
|
|
319
|
+
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = Ve(t, n, o.width, s, c) ?? He(t, n, o.width, s), u = t.dom.offsetParent;
|
|
320
|
+
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), Ue(r, n.orientation);
|
|
321
|
+
let { parentLeft: d, parentTop: f } = We(u);
|
|
501
322
|
r.style.left = (l.left - d) / s + "px", r.style.top = (l.top - f) / c + "px", r.style.width = (l.right - l.left) / s + "px", r.style.height = (l.bottom - l.top) / c + "px";
|
|
502
323
|
}, l = (e) => {
|
|
503
324
|
clearTimeout(i), i = window.setTimeout(() => s(null), e);
|
|
@@ -506,7 +327,7 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
506
327
|
a = t.target instanceof Element ? t.target : null;
|
|
507
328
|
}, d = (t) => {
|
|
508
329
|
let n = t;
|
|
509
|
-
if (a &&
|
|
330
|
+
if (a && Be(a, o.exclude) || n.target instanceof Element && Be(n.target, o.exclude)) return;
|
|
510
331
|
let r = e.prosemirrorView;
|
|
511
332
|
if (!r.editable) return;
|
|
512
333
|
let i = r.posAtCoords({
|
|
@@ -516,7 +337,7 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
516
337
|
if (i && !d) {
|
|
517
338
|
let t = i.pos;
|
|
518
339
|
if (r.dragging && r.dragging.slice) {
|
|
519
|
-
let e =
|
|
340
|
+
let e = ae(r.state.doc, t, r.dragging.slice);
|
|
520
341
|
e != null && (t = e);
|
|
521
342
|
}
|
|
522
343
|
let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
|
|
@@ -557,12 +378,12 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
557
378
|
});
|
|
558
379
|
}
|
|
559
380
|
};
|
|
560
|
-
}),
|
|
381
|
+
}), qe = b(() => ({
|
|
561
382
|
key: "history",
|
|
562
|
-
prosemirrorPlugins: [
|
|
563
|
-
undoCommand:
|
|
564
|
-
redoCommand:
|
|
565
|
-
})),
|
|
383
|
+
prosemirrorPlugins: [De()],
|
|
384
|
+
undoCommand: ke,
|
|
385
|
+
redoCommand: Oe
|
|
386
|
+
})), Je = b(({ editor: e }) => {
|
|
566
387
|
function t(t) {
|
|
567
388
|
let n = e.prosemirrorView.nodeDOM(t);
|
|
568
389
|
for (; n && n.parentElement;) {
|
|
@@ -583,7 +404,7 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
583
404
|
return n.text;
|
|
584
405
|
},
|
|
585
406
|
get position() {
|
|
586
|
-
return
|
|
407
|
+
return ce(e.prosemirrorView, n.from, n.to).toJSON();
|
|
587
408
|
}
|
|
588
409
|
};
|
|
589
410
|
}
|
|
@@ -609,7 +430,7 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
609
430
|
e.deleteLink(t);
|
|
610
431
|
}
|
|
611
432
|
};
|
|
612
|
-
}),
|
|
433
|
+
}), Ye = [
|
|
613
434
|
"http",
|
|
614
435
|
"https",
|
|
615
436
|
"ftp",
|
|
@@ -620,30 +441,30 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
620
441
|
"sms",
|
|
621
442
|
"cid",
|
|
622
443
|
"xmpp"
|
|
623
|
-
],
|
|
444
|
+
], Xe = "https", Ze = new w("node-selection-keyboard"), Qe = b(() => ({
|
|
624
445
|
key: "nodeSelectionKeyboard",
|
|
625
|
-
prosemirrorPlugins: [new
|
|
626
|
-
key:
|
|
446
|
+
prosemirrorPlugins: [new C({
|
|
447
|
+
key: Ze,
|
|
627
448
|
props: { handleKeyDown: (e, t) => {
|
|
628
449
|
if ("node" in e.state.selection) {
|
|
629
450
|
if (t.ctrlKey || t.metaKey) return !1;
|
|
630
451
|
if (t.key.length === 1) return t.preventDefault(), !0;
|
|
631
452
|
if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
|
|
632
453
|
let t = e.state.tr;
|
|
633
|
-
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new
|
|
454
|
+
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new de(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
|
|
634
455
|
}
|
|
635
456
|
}
|
|
636
457
|
return !1;
|
|
637
458
|
} }
|
|
638
459
|
})]
|
|
639
|
-
})),
|
|
460
|
+
})), $e = new w("blocknote-placeholder"), et = b(({ editor: e, options: t }) => {
|
|
640
461
|
let n = t.placeholders;
|
|
641
462
|
return {
|
|
642
463
|
key: "placeholder",
|
|
643
|
-
prosemirrorPlugins: [new
|
|
644
|
-
key:
|
|
464
|
+
prosemirrorPlugins: [new C({
|
|
465
|
+
key: $e,
|
|
645
466
|
view: (t) => {
|
|
646
|
-
let r = `placeholder-selector-${
|
|
467
|
+
let r = `placeholder-selector-${le()}`;
|
|
647
468
|
t.dom.classList.add(r);
|
|
648
469
|
let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
|
|
649
470
|
a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
|
|
@@ -666,37 +487,59 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
666
487
|
let { doc: n, selection: r } = t;
|
|
667
488
|
if (!e.isEditable || !r.empty || r.$from.parent.type.spec.code) return;
|
|
668
489
|
let i = [];
|
|
669
|
-
t.doc.content.size === 6 && i.push(
|
|
490
|
+
t.doc.content.size === 6 && i.push(E.node(2, 4, { "data-is-only-empty-block": "true" }));
|
|
670
491
|
let a = r.$anchor, o = a.parent;
|
|
671
492
|
if (o.content.size === 0) {
|
|
672
493
|
let e = a.before();
|
|
673
|
-
i.push(
|
|
494
|
+
i.push(E.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
|
|
674
495
|
}
|
|
675
|
-
return
|
|
496
|
+
return D.create(n, i);
|
|
676
497
|
} }
|
|
677
498
|
})]
|
|
678
499
|
};
|
|
679
|
-
}),
|
|
500
|
+
}), tt = b(({ editor: e }) => {
|
|
501
|
+
let t = new ie(), n = 0;
|
|
502
|
+
function r() {
|
|
503
|
+
t = new ie(), n = 0;
|
|
504
|
+
}
|
|
505
|
+
let i = typeof FinalizationRegistry < "u" ? new FinalizationRegistry(() => {
|
|
506
|
+
n--, n === 0 && r();
|
|
507
|
+
}) : null;
|
|
508
|
+
return e.on("create", () => {
|
|
509
|
+
e._tiptapEditor.on("transaction", ({ transaction: e }) => {
|
|
510
|
+
n !== 0 && t.appendMapping(e.mapping);
|
|
511
|
+
}), e._tiptapEditor.on("destroy", () => {
|
|
512
|
+
r();
|
|
513
|
+
});
|
|
514
|
+
}), {
|
|
515
|
+
key: "positionMapping",
|
|
516
|
+
mapPosition: (e, r = "left") => {
|
|
517
|
+
n++;
|
|
518
|
+
let a = t.maps.length, o = () => t.slice(a).map(e, r === "left" ? -1 : 1);
|
|
519
|
+
return i && i.register(o, void 0), o;
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}), nt = new w("previous-blocks"), rt = {
|
|
680
523
|
index: "index",
|
|
681
524
|
level: "level",
|
|
682
525
|
type: "type",
|
|
683
526
|
depth: "depth",
|
|
684
527
|
"depth-change": "depth-change"
|
|
685
|
-
},
|
|
686
|
-
let
|
|
528
|
+
}, it = b(() => {
|
|
529
|
+
let t;
|
|
687
530
|
return {
|
|
688
531
|
key: "previousBlockType",
|
|
689
|
-
prosemirrorPlugins: [new
|
|
690
|
-
key:
|
|
691
|
-
view(
|
|
532
|
+
prosemirrorPlugins: [new C({
|
|
533
|
+
key: nt,
|
|
534
|
+
view(e) {
|
|
692
535
|
return {
|
|
693
|
-
update: async (
|
|
694
|
-
this.key?.getState(
|
|
695
|
-
|
|
536
|
+
update: async (e, n) => {
|
|
537
|
+
this.key?.getState(e.state).updatedBlocks.size > 0 && (t = setTimeout(() => {
|
|
538
|
+
e.dispatch(e.state.tr.setMeta(nt, { clearUpdate: !0 }));
|
|
696
539
|
}, 0));
|
|
697
540
|
},
|
|
698
541
|
destroy: () => {
|
|
699
|
-
|
|
542
|
+
t && clearTimeout(t);
|
|
700
543
|
}
|
|
701
544
|
};
|
|
702
545
|
},
|
|
@@ -708,51 +551,53 @@ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
|
708
551
|
updatedBlocks: /* @__PURE__ */ new Set()
|
|
709
552
|
};
|
|
710
553
|
},
|
|
711
|
-
apply(
|
|
712
|
-
if (
|
|
713
|
-
let
|
|
714
|
-
if (!
|
|
715
|
-
let
|
|
716
|
-
from:
|
|
717
|
-
to:
|
|
718
|
-
},
|
|
719
|
-
for (let
|
|
720
|
-
let
|
|
721
|
-
if (
|
|
722
|
-
let
|
|
723
|
-
index:
|
|
724
|
-
level:
|
|
725
|
-
type:
|
|
726
|
-
depth:
|
|
727
|
-
},
|
|
728
|
-
index:
|
|
729
|
-
level:
|
|
730
|
-
type:
|
|
731
|
-
depth:
|
|
554
|
+
apply(t, n, r, i) {
|
|
555
|
+
if (n.currentTransactionOldBlockAttrs = {}, n.updatedBlocks.clear(), !t.docChanged) return n;
|
|
556
|
+
let a = t.changedRange();
|
|
557
|
+
if (!a) return n;
|
|
558
|
+
let o = t.mapping.invert(), s = {
|
|
559
|
+
from: o.map(a.from, -1),
|
|
560
|
+
to: o.map(a.to, 1)
|
|
561
|
+
}, c = {}, l = se(r.doc, s, (e) => e.attrs.id), u = new Map(l.map((t) => [e(t.node, r.doc), t])), d = se(i.doc, a, (e) => e.attrs.id);
|
|
562
|
+
for (let t of d) {
|
|
563
|
+
let a = e(t.node, i.doc), o = u.get(a), s = o?.node.firstChild, l = t.node.firstChild;
|
|
564
|
+
if (o && s && l) {
|
|
565
|
+
let e = {
|
|
566
|
+
index: l.attrs.index,
|
|
567
|
+
level: l.attrs.level,
|
|
568
|
+
type: l.type.name,
|
|
569
|
+
depth: i.doc.resolve(t.pos).depth
|
|
570
|
+
}, u = {
|
|
571
|
+
index: s.attrs.index,
|
|
572
|
+
level: s.attrs.level,
|
|
573
|
+
type: s.type.name,
|
|
574
|
+
depth: r.doc.resolve(o.pos).depth
|
|
732
575
|
};
|
|
733
|
-
|
|
576
|
+
c[a] = u, n.currentTransactionOldBlockAttrs[a] = u, (u.index !== e.index || u.level !== e.level || u.type !== e.type || u.depth !== e.depth) && (u["depth-change"] = u.depth - e.depth, n.updatedBlocks.add(a));
|
|
734
577
|
}
|
|
735
578
|
}
|
|
736
|
-
return
|
|
579
|
+
return n.prevTransactionOldBlockAttrs = c, n;
|
|
737
580
|
}
|
|
738
581
|
},
|
|
739
|
-
props: { decorations(
|
|
740
|
-
let
|
|
741
|
-
if (
|
|
742
|
-
let
|
|
743
|
-
return
|
|
744
|
-
if (!
|
|
745
|
-
let
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
582
|
+
props: { decorations(t) {
|
|
583
|
+
let n = this.getState(t);
|
|
584
|
+
if (n.updatedBlocks.size === 0) return;
|
|
585
|
+
let r = [];
|
|
586
|
+
return t.doc.descendants((i, a) => {
|
|
587
|
+
if (!i.attrs.id) return;
|
|
588
|
+
let o = e(i, t.doc);
|
|
589
|
+
if (!n.updatedBlocks.has(o)) return;
|
|
590
|
+
let s = n.currentTransactionOldBlockAttrs[o], c = {};
|
|
591
|
+
for (let [e, t] of Object.entries(s)) c["data-prev-" + rt[e]] = t || "none";
|
|
592
|
+
r.push(E.node(a, a + i.nodeSize, { ...c }));
|
|
593
|
+
}), D.create(t.doc, r);
|
|
749
594
|
} }
|
|
750
595
|
})]
|
|
751
596
|
};
|
|
752
597
|
});
|
|
753
598
|
//#endregion
|
|
754
599
|
//#region src/extensions/getDraggableBlockFromElement.ts
|
|
755
|
-
function
|
|
600
|
+
function A(e, t) {
|
|
756
601
|
for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
|
|
757
602
|
if (e.getAttribute?.("data-node-type") === "blockContainer") return {
|
|
758
603
|
node: e,
|
|
@@ -761,60 +606,60 @@ function vt(e, t) {
|
|
|
761
606
|
}
|
|
762
607
|
//#endregion
|
|
763
608
|
//#region src/api/exporters/markdown/htmlToMarkdown.ts
|
|
764
|
-
function
|
|
609
|
+
function at(e) {
|
|
765
610
|
let t = document.createElement("div");
|
|
766
|
-
return t.innerHTML = e,
|
|
611
|
+
return t.innerHTML = e, j(t, {
|
|
767
612
|
indent: "",
|
|
768
613
|
inListItem: !1
|
|
769
614
|
}).trim() + "\n";
|
|
770
615
|
}
|
|
771
|
-
function
|
|
616
|
+
function j(e, t) {
|
|
772
617
|
let n = "", r = Array.from(e.childNodes);
|
|
773
618
|
for (let e = 0; e < r.length; e++) {
|
|
774
619
|
let i = r[e];
|
|
775
|
-
n +=
|
|
620
|
+
n += M(i, t);
|
|
776
621
|
}
|
|
777
622
|
return n;
|
|
778
623
|
}
|
|
779
|
-
function
|
|
624
|
+
function M(e, t) {
|
|
780
625
|
if (e.nodeType === 3) return e.textContent || "";
|
|
781
626
|
if (e.nodeType !== 1) return "";
|
|
782
627
|
let n = e;
|
|
783
628
|
switch (n.tagName.toLowerCase()) {
|
|
784
|
-
case "p": return
|
|
629
|
+
case "p": return ot(n, t);
|
|
785
630
|
case "h1":
|
|
786
631
|
case "h2":
|
|
787
632
|
case "h3":
|
|
788
633
|
case "h4":
|
|
789
634
|
case "h5":
|
|
790
|
-
case "h6": return
|
|
791
|
-
case "blockquote": return
|
|
792
|
-
case "pre": return
|
|
793
|
-
case "ul": return
|
|
794
|
-
case "ol": return
|
|
795
|
-
case "table": return
|
|
635
|
+
case "h6": return N(n, t);
|
|
636
|
+
case "blockquote": return st(n, t);
|
|
637
|
+
case "pre": return ct(n, t);
|
|
638
|
+
case "ul": return ut(n, t);
|
|
639
|
+
case "ol": return dt(n, t);
|
|
640
|
+
case "table": return pt(n, t);
|
|
796
641
|
case "hr": return t.indent + "***\n\n";
|
|
797
|
-
case "img": return
|
|
798
|
-
case "video": return
|
|
799
|
-
case "audio": return
|
|
800
|
-
case "embed": return
|
|
801
|
-
case "figure": return
|
|
802
|
-
case "a": return
|
|
803
|
-
case "details": return
|
|
804
|
-
case "div": return
|
|
642
|
+
case "img": return ht(n, t);
|
|
643
|
+
case "video": return gt(n, t);
|
|
644
|
+
case "audio": return _t(n, t);
|
|
645
|
+
case "embed": return vt(n, t);
|
|
646
|
+
case "figure": return yt(n, t);
|
|
647
|
+
case "a": return xt(n, t);
|
|
648
|
+
case "details": return wt(n, t);
|
|
649
|
+
case "div": return j(n, t);
|
|
805
650
|
case "br": return "";
|
|
806
|
-
default: return
|
|
651
|
+
default: return j(n, t);
|
|
807
652
|
}
|
|
808
653
|
}
|
|
809
|
-
function
|
|
810
|
-
let n =
|
|
654
|
+
function ot(e, t) {
|
|
655
|
+
let n = Et(B(e));
|
|
811
656
|
return t.inListItem ? n : t.indent + n + "\n\n";
|
|
812
657
|
}
|
|
813
|
-
function
|
|
814
|
-
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i =
|
|
658
|
+
function N(e, t) {
|
|
659
|
+
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = B(e);
|
|
815
660
|
return t.indent + r + i + "\n\n";
|
|
816
661
|
}
|
|
817
|
-
function
|
|
662
|
+
function st(e, t) {
|
|
818
663
|
let n = Array.from(e.children).filter((e) => {
|
|
819
664
|
let t = e.tagName.toLowerCase();
|
|
820
665
|
return [
|
|
@@ -829,43 +674,43 @@ function xt(e, t) {
|
|
|
829
674
|
}), r;
|
|
830
675
|
if (n.length > 0) {
|
|
831
676
|
let e = [];
|
|
832
|
-
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(
|
|
677
|
+
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(B(t)) : e.push(M(t, {
|
|
833
678
|
indent: "",
|
|
834
679
|
inListItem: !1
|
|
835
680
|
}).trim());
|
|
836
681
|
r = e.join("\n\n");
|
|
837
|
-
} else r =
|
|
682
|
+
} else r = B(e);
|
|
838
683
|
return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
|
|
839
684
|
}
|
|
840
|
-
function
|
|
685
|
+
function ct(e, t) {
|
|
841
686
|
let n = e.querySelector("code");
|
|
842
687
|
if (!n) return "";
|
|
843
|
-
let r = n.getAttribute("data-language") ||
|
|
688
|
+
let r = n.getAttribute("data-language") || lt(n.className) || "", i = P(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
|
|
844
689
|
return i ? t.indent + o + r + "\n" + i + (i.endsWith("\n") ? "" : "\n") + o + "\n\n" : t.indent + o + r + "\n" + o + "\n\n";
|
|
845
690
|
}
|
|
846
|
-
function
|
|
691
|
+
function P(e) {
|
|
847
692
|
let t = "";
|
|
848
|
-
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t +=
|
|
693
|
+
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += P(n));
|
|
849
694
|
return t;
|
|
850
695
|
}
|
|
851
|
-
function
|
|
696
|
+
function lt(e) {
|
|
852
697
|
let t = e.match(/language-(\S+)/);
|
|
853
698
|
return t ? t[1] : "";
|
|
854
699
|
}
|
|
855
|
-
function
|
|
700
|
+
function ut(e, t) {
|
|
856
701
|
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
|
|
857
|
-
for (let e of r) n +=
|
|
702
|
+
for (let e of r) n += F(e, "bullet", t);
|
|
858
703
|
return t.inListItem || (n += "\n"), n;
|
|
859
704
|
}
|
|
860
|
-
function
|
|
705
|
+
function dt(e, t) {
|
|
861
706
|
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
|
|
862
707
|
for (let e = 0; e < r.length; e++) {
|
|
863
708
|
let a = i + e;
|
|
864
|
-
n +=
|
|
709
|
+
n += F(r[e], "ordered", t, a);
|
|
865
710
|
}
|
|
866
711
|
return t.inListItem || (n += "\n"), n;
|
|
867
712
|
}
|
|
868
|
-
function
|
|
713
|
+
function F(e, t, n, r) {
|
|
869
714
|
let i = null, a = null;
|
|
870
715
|
for (let t of Array.from(e.children)) {
|
|
871
716
|
let e = t.tagName.toLowerCase();
|
|
@@ -876,8 +721,8 @@ function L(e, t, n, r) {
|
|
|
876
721
|
let c, l;
|
|
877
722
|
if (a) {
|
|
878
723
|
let e = a.querySelector("summary")?.querySelector("p");
|
|
879
|
-
l = a, c = e ?
|
|
880
|
-
} else l =
|
|
724
|
+
l = a, c = e ? B(e) : "";
|
|
725
|
+
} else l = ft(e, i), c = l ? B(l) : "";
|
|
881
726
|
let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
|
|
882
727
|
indent: d,
|
|
883
728
|
inListItem: !0
|
|
@@ -885,22 +730,22 @@ function L(e, t, n, r) {
|
|
|
885
730
|
if (a) {
|
|
886
731
|
let e = a.querySelector("summary");
|
|
887
732
|
for (let t of Array.from(a.children)) if (t !== e) if (t.tagName.toLowerCase() === "p") {
|
|
888
|
-
let e =
|
|
733
|
+
let e = B(t);
|
|
889
734
|
u += "\n" + d + e + "\n";
|
|
890
|
-
} else u +=
|
|
735
|
+
} else u += M(t, f);
|
|
891
736
|
}
|
|
892
737
|
let p = Array.from(e.children);
|
|
893
738
|
for (let e of p) {
|
|
894
739
|
let t = e.tagName.toLowerCase();
|
|
895
|
-
if (!(e === l || e === i) && t !== "input") if (t === "ul" || t === "ol") u +=
|
|
740
|
+
if (!(e === l || e === i) && t !== "input") if (t === "ul" || t === "ol") u += M(e, f);
|
|
896
741
|
else if (t === "p") {
|
|
897
|
-
let t =
|
|
742
|
+
let t = B(e);
|
|
898
743
|
u += "\n" + d + t + "\n";
|
|
899
|
-
} else u += "\n" +
|
|
744
|
+
} else u += "\n" + M(e, f);
|
|
900
745
|
}
|
|
901
746
|
return u;
|
|
902
747
|
}
|
|
903
|
-
function
|
|
748
|
+
function ft(e, t) {
|
|
904
749
|
for (let n of Array.from(e.children)) {
|
|
905
750
|
if (n === t || n.tagName.toLowerCase() === "input") continue;
|
|
906
751
|
let e = n.tagName.toLowerCase();
|
|
@@ -908,7 +753,7 @@ function Et(e, t) {
|
|
|
908
753
|
}
|
|
909
754
|
return null;
|
|
910
755
|
}
|
|
911
|
-
function
|
|
756
|
+
function pt(e, t) {
|
|
912
757
|
let n = e.querySelector("colgroup"), r = 0;
|
|
913
758
|
n && (r = n.querySelectorAll("col").length);
|
|
914
759
|
let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
|
|
@@ -918,7 +763,7 @@ function Dt(e, t) {
|
|
|
918
763
|
n.forEach((e) => {
|
|
919
764
|
for (; s[t][i] !== void 0;) i++;
|
|
920
765
|
t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
|
|
921
|
-
let n =
|
|
766
|
+
let n = mt(B(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
|
|
922
767
|
for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
|
|
923
768
|
let r = t + e;
|
|
924
769
|
s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
|
|
@@ -943,19 +788,19 @@ function Dt(e, t) {
|
|
|
943
788
|
}
|
|
944
789
|
let l = "";
|
|
945
790
|
if (a) {
|
|
946
|
-
l += t.indent +
|
|
947
|
-
for (let e = 1; e < i.length; e++) l += t.indent +
|
|
791
|
+
l += t.indent + I(i[0], c, r) + "\n", l += t.indent + L(c, r) + "\n";
|
|
792
|
+
for (let e = 1; e < i.length; e++) l += t.indent + I(i[e], c, r) + "\n";
|
|
948
793
|
} else {
|
|
949
794
|
let e = Array(r).fill("");
|
|
950
|
-
l += t.indent +
|
|
951
|
-
for (let e of i) l += t.indent +
|
|
795
|
+
l += t.indent + I(e, c, r) + "\n", l += t.indent + L(c, r) + "\n";
|
|
796
|
+
for (let e of i) l += t.indent + I(e, c, r) + "\n";
|
|
952
797
|
}
|
|
953
798
|
return l += "\n", l;
|
|
954
799
|
}
|
|
955
|
-
function
|
|
800
|
+
function mt(e) {
|
|
956
801
|
return e.replace(/\|/g, "\\|");
|
|
957
802
|
}
|
|
958
|
-
function
|
|
803
|
+
function I(e, t, n) {
|
|
959
804
|
let r = [];
|
|
960
805
|
for (let i = 0; i < n; i++) {
|
|
961
806
|
let n = i < e.length ? e[i] : "";
|
|
@@ -963,65 +808,65 @@ function R(e, t, n) {
|
|
|
963
808
|
}
|
|
964
809
|
return "|" + r.join("|") + "|";
|
|
965
810
|
}
|
|
966
|
-
function
|
|
811
|
+
function L(e, t) {
|
|
967
812
|
let n = [];
|
|
968
813
|
for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
|
|
969
814
|
return "|" + n.join("|") + "|";
|
|
970
815
|
}
|
|
971
|
-
function
|
|
816
|
+
function ht(e, t) {
|
|
972
817
|
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
973
818
|
return n ? t.indent + `\n\n` : "\n\n";
|
|
974
819
|
}
|
|
975
|
-
function
|
|
820
|
+
function gt(e, t) {
|
|
976
821
|
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
977
822
|
return n ? t.indent + `\n\n` : "\n\n";
|
|
978
823
|
}
|
|
979
|
-
function
|
|
824
|
+
function _t(e, t) {
|
|
980
825
|
let n = e.getAttribute("src") || "";
|
|
981
|
-
return n ? t.indent + `<audio src="${
|
|
826
|
+
return n ? t.indent + `<audio src="${z(n)}" controls></audio>\n\n` : "\n\n";
|
|
982
827
|
}
|
|
983
|
-
function
|
|
828
|
+
function vt(e, t) {
|
|
984
829
|
let n = e.getAttribute("src") || "";
|
|
985
830
|
return n ? t.indent + `[](${n})\n\n` : "\n\n";
|
|
986
831
|
}
|
|
987
|
-
function
|
|
832
|
+
function yt(e, t) {
|
|
988
833
|
let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
|
|
989
|
-
return n ?
|
|
834
|
+
return n ? R("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? R("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? R("audio", i.getAttribute("src") || "", "", o, t) : a ? xt(a, t) : "";
|
|
990
835
|
}
|
|
991
|
-
function
|
|
836
|
+
function R(e, t, n, r, i) {
|
|
992
837
|
if (!t) return "";
|
|
993
838
|
if (!r && e !== "audio") return i.indent + `\n\n`;
|
|
994
|
-
let a = n && n !== r ? e === "img" ? ` alt="${
|
|
839
|
+
let a = n && n !== r ? e === "img" ? ` alt="${z(n)}"` : e === "video" ? ` data-name="${z(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${z(t)}">` : `<${e} src="${z(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${bt(r)}</figcaption>` : "";
|
|
995
840
|
return i.indent + `<figure>${o}${s}</figure>\n\n`;
|
|
996
841
|
}
|
|
997
|
-
function
|
|
842
|
+
function z(e) {
|
|
998
843
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
999
844
|
}
|
|
1000
|
-
function
|
|
845
|
+
function bt(e) {
|
|
1001
846
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1002
847
|
}
|
|
1003
|
-
function
|
|
848
|
+
function xt(e, t) {
|
|
1004
849
|
let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
|
|
1005
|
-
return n ? t.indent +
|
|
850
|
+
return n ? t.indent + St(r, n) + "\n\n" : t.indent + r + "\n\n";
|
|
1006
851
|
}
|
|
1007
|
-
function
|
|
1008
|
-
return !e || e === t ? t : `[${e}](${
|
|
852
|
+
function St(e, t) {
|
|
853
|
+
return !e || e === t ? t : `[${e}](${Ct(t)})`;
|
|
1009
854
|
}
|
|
1010
|
-
function
|
|
855
|
+
function Ct(e) {
|
|
1011
856
|
return e.replace(/[\\()]/g, "\\$&");
|
|
1012
857
|
}
|
|
1013
|
-
function
|
|
858
|
+
function wt(e, t) {
|
|
1014
859
|
let n = e.querySelector("summary");
|
|
1015
|
-
if (!n) return
|
|
860
|
+
if (!n) return j(e, t);
|
|
1016
861
|
let r = n.querySelector("h1, h2, h3, h4, h5, h6");
|
|
1017
862
|
if (r) {
|
|
1018
|
-
let i =
|
|
1019
|
-
for (let r of Array.from(e.children)) r !== n && (i +=
|
|
863
|
+
let i = N(r, t);
|
|
864
|
+
for (let r of Array.from(e.children)) r !== n && (i += M(r, t));
|
|
1020
865
|
return i;
|
|
1021
866
|
}
|
|
1022
|
-
return
|
|
867
|
+
return j(n, t);
|
|
1023
868
|
}
|
|
1024
|
-
function
|
|
869
|
+
function B(e) {
|
|
1025
870
|
let t = "";
|
|
1026
871
|
for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += n.textContent || "";
|
|
1027
872
|
else if (n.nodeType === 1) {
|
|
@@ -1029,19 +874,19 @@ function U(e) {
|
|
|
1029
874
|
switch (e.tagName.toLowerCase()) {
|
|
1030
875
|
case "strong":
|
|
1031
876
|
case "b": {
|
|
1032
|
-
let { content: n, trailing: r } =
|
|
877
|
+
let { content: n, trailing: r } = Tt(B(e));
|
|
1033
878
|
n ? t += `**${n}**${r}` : t += r;
|
|
1034
879
|
break;
|
|
1035
880
|
}
|
|
1036
881
|
case "em":
|
|
1037
882
|
case "i": {
|
|
1038
|
-
let { content: n, trailing: r } =
|
|
883
|
+
let { content: n, trailing: r } = Tt(B(e));
|
|
1039
884
|
n ? t += `*${n}*${r}` : t += r;
|
|
1040
885
|
break;
|
|
1041
886
|
}
|
|
1042
887
|
case "s":
|
|
1043
888
|
case "del":
|
|
1044
|
-
t += `~~${
|
|
889
|
+
t += `~~${B(e)}~~`;
|
|
1045
890
|
break;
|
|
1046
891
|
case "code": {
|
|
1047
892
|
let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
|
|
@@ -1049,18 +894,18 @@ function U(e) {
|
|
|
1049
894
|
break;
|
|
1050
895
|
}
|
|
1051
896
|
case "u":
|
|
1052
|
-
t +=
|
|
897
|
+
t += B(e);
|
|
1053
898
|
break;
|
|
1054
899
|
case "a": {
|
|
1055
|
-
let n = e.getAttribute("href") || "", r =
|
|
1056
|
-
t +=
|
|
900
|
+
let n = e.getAttribute("href") || "", r = B(e);
|
|
901
|
+
t += St(r, n);
|
|
1057
902
|
break;
|
|
1058
903
|
}
|
|
1059
904
|
case "br":
|
|
1060
905
|
t += "\\\n";
|
|
1061
906
|
break;
|
|
1062
907
|
case "span":
|
|
1063
|
-
t +=
|
|
908
|
+
t += B(e);
|
|
1064
909
|
break;
|
|
1065
910
|
case "img": {
|
|
1066
911
|
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
@@ -1073,17 +918,17 @@ function U(e) {
|
|
|
1073
918
|
break;
|
|
1074
919
|
}
|
|
1075
920
|
case "p":
|
|
1076
|
-
t +=
|
|
921
|
+
t += B(e);
|
|
1077
922
|
break;
|
|
1078
923
|
case "input": break;
|
|
1079
924
|
default:
|
|
1080
|
-
t +=
|
|
925
|
+
t += B(e);
|
|
1081
926
|
break;
|
|
1082
927
|
}
|
|
1083
928
|
}
|
|
1084
929
|
return t;
|
|
1085
930
|
}
|
|
1086
|
-
function
|
|
931
|
+
function Tt(e) {
|
|
1087
932
|
let t = e.match(/^(.*?)(\s*)$/);
|
|
1088
933
|
return t ? {
|
|
1089
934
|
content: t[1],
|
|
@@ -1093,32 +938,29 @@ function Rt(e) {
|
|
|
1093
938
|
trailing: ""
|
|
1094
939
|
};
|
|
1095
940
|
}
|
|
1096
|
-
function
|
|
941
|
+
function Et(e) {
|
|
1097
942
|
let t = e.replace(/^(\\\n)+/, "");
|
|
1098
943
|
return t = t.replace(/(\\\n)+$/, ""), t;
|
|
1099
944
|
}
|
|
1100
945
|
//#endregion
|
|
1101
946
|
//#region src/api/exporters/markdown/markdownExporter.ts
|
|
1102
|
-
function
|
|
1103
|
-
return
|
|
947
|
+
function V(e) {
|
|
948
|
+
return at(e);
|
|
1104
949
|
}
|
|
1105
|
-
function
|
|
1106
|
-
return
|
|
950
|
+
function Dt(e, t, n, r) {
|
|
951
|
+
return V(k(t, n).exportBlocks(e, r));
|
|
1107
952
|
}
|
|
1108
953
|
//#endregion
|
|
1109
954
|
//#region src/api/nodeConversions/fragmentToBlocks.ts
|
|
1110
|
-
function
|
|
955
|
+
function Ot(e) {
|
|
1111
956
|
let t = [];
|
|
1112
|
-
return e.descendants((e) => {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
t.push(p(e, n));
|
|
1116
|
-
}), !1) : e.type.isInGroup("bnBlock") ? (t.push(p(e, n)), !1) : !0;
|
|
1117
|
-
}), t;
|
|
957
|
+
return e.descendants((e) => e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup" ? !0 : e.type.name === "columnList" && e.childCount === 1 ? (e.firstChild?.forEach((n) => {
|
|
958
|
+
t.push(_(n, e));
|
|
959
|
+
}), !1) : e.type.isInGroup("bnBlock") ? (t.push(_(e, e)), !1) : !0), t;
|
|
1118
960
|
}
|
|
1119
961
|
//#endregion
|
|
1120
962
|
//#region src/extensions/SideMenu/MultipleNodeSelection.ts
|
|
1121
|
-
var
|
|
963
|
+
var H = class e extends T {
|
|
1122
964
|
nodes;
|
|
1123
965
|
constructor(e, t) {
|
|
1124
966
|
super(e, t);
|
|
@@ -1131,7 +973,7 @@ var G = class e extends S {
|
|
|
1131
973
|
return new e(t.resolve(n), t.resolve(r));
|
|
1132
974
|
}
|
|
1133
975
|
content() {
|
|
1134
|
-
return new
|
|
976
|
+
return new re(S.from(this.nodes), 0, 0);
|
|
1135
977
|
}
|
|
1136
978
|
eq(t) {
|
|
1137
979
|
if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
|
|
@@ -1140,7 +982,7 @@ var G = class e extends S {
|
|
|
1140
982
|
}
|
|
1141
983
|
map(t, n) {
|
|
1142
984
|
let r = n.mapResult(this.from), i = n.mapResult(this.to);
|
|
1143
|
-
return i.deleted ?
|
|
985
|
+
return i.deleted ? T.near(t.resolve(r.pos)) : r.deleted ? T.near(t.resolve(i.pos)) : new e(t.resolve(r.pos), t.resolve(i.pos));
|
|
1144
986
|
}
|
|
1145
987
|
toJSON() {
|
|
1146
988
|
return {
|
|
@@ -1150,11 +992,11 @@ var G = class e extends S {
|
|
|
1150
992
|
};
|
|
1151
993
|
}
|
|
1152
994
|
};
|
|
1153
|
-
|
|
995
|
+
T.jsonID("multiple-node", H);
|
|
1154
996
|
//#endregion
|
|
1155
997
|
//#region src/extensions/SideMenu/dragging.ts
|
|
1156
|
-
var
|
|
1157
|
-
function
|
|
998
|
+
var U;
|
|
999
|
+
function kt(e, t) {
|
|
1158
1000
|
let n, r, i = t.resolve(e.from).node().type.spec.group === "blockContent", a = t.resolve(e.to).node().type.spec.group === "blockContent", o = Math.min(e.$anchor.depth, e.$head.depth);
|
|
1159
1001
|
if (i && a) {
|
|
1160
1002
|
let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
|
|
@@ -1165,51 +1007,53 @@ function Ht(e, t) {
|
|
|
1165
1007
|
to: r
|
|
1166
1008
|
};
|
|
1167
1009
|
}
|
|
1168
|
-
function
|
|
1010
|
+
function At(e, t, n = t) {
|
|
1169
1011
|
t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
|
|
1170
1012
|
let r = e.domAtPos(t).node.cloneNode(!0), i = e.domAtPos(t).node, a = (e, t) => Array.prototype.indexOf.call(e.children, t), o = a(i, e.domAtPos(t + 1).node.parentElement), s = a(i, e.domAtPos(n - 1).node.parentElement);
|
|
1171
1013
|
for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
|
|
1172
|
-
|
|
1014
|
+
jt(e.root), U = r, U.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
|
|
1173
1015
|
let c = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1178
|
-
}
|
|
1179
|
-
function
|
|
1180
|
-
if (!e.dataTransfer ||
|
|
1181
|
-
let
|
|
1182
|
-
if (!
|
|
1183
|
-
let
|
|
1184
|
-
if (
|
|
1185
|
-
let t =
|
|
1186
|
-
c && l ? (
|
|
1187
|
-
let u =
|
|
1188
|
-
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(
|
|
1016
|
+
U.className = U.className + " bn-drag-preview " + c, e.root instanceof ShadowRoot ? e.root.appendChild(U) : e.root.body.appendChild(U);
|
|
1017
|
+
}
|
|
1018
|
+
function jt(e) {
|
|
1019
|
+
U !== void 0 && (e instanceof ShadowRoot ? e.removeChild(U) : e.body.removeChild(U), U = void 0);
|
|
1020
|
+
}
|
|
1021
|
+
function Mt(e, t, n) {
|
|
1022
|
+
if (!e.dataTransfer || n.headless) return;
|
|
1023
|
+
let r = n.prosemirrorView, i = ee(t.id, r.state.doc);
|
|
1024
|
+
if (!i) throw Error(`Block with ID ${t.id} not found`);
|
|
1025
|
+
let a = i.posBeforeNode;
|
|
1026
|
+
if (a != null) {
|
|
1027
|
+
let t = r.state.selection, i = r.state.doc, { from: o, to: s } = kt(t, i), c = o <= a && a < s, l = t.$anchor.node() !== t.$head.node() || t instanceof H;
|
|
1028
|
+
c && l ? (r.dispatch(r.state.tr.setSelection(H.create(i, o, s))), At(r, o, s)) : (r.dispatch(r.state.tr.setSelection(ue.create(r.state.doc, a))), At(r, a));
|
|
1029
|
+
let u = r.state.selection.content(), d = n.pmSchema, f = r.serializeForClipboard(u).dom.innerHTML, p = k(d, n), m = Ot(u.content), h = p.exportBlocks(m, {}), g = V(h);
|
|
1030
|
+
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(U, 0, 0);
|
|
1189
1031
|
}
|
|
1190
1032
|
}
|
|
1191
1033
|
//#endregion
|
|
1192
1034
|
//#region src/extensions/SideMenu/SideMenu.ts
|
|
1193
|
-
var
|
|
1194
|
-
function
|
|
1035
|
+
var Nt = 250;
|
|
1036
|
+
function W(e, t, n = !0) {
|
|
1195
1037
|
let r = e.root.elementsFromPoint(t.left, t.top);
|
|
1196
|
-
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ?
|
|
1038
|
+
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? W(e, {
|
|
1197
1039
|
left: t.left + 50,
|
|
1198
1040
|
top: t.top
|
|
1199
|
-
}, !1) :
|
|
1041
|
+
}, !1) : A(i, e);
|
|
1200
1042
|
}
|
|
1201
|
-
function
|
|
1043
|
+
function Pt(e, t) {
|
|
1202
1044
|
if (!t.dom.firstChild) return;
|
|
1203
|
-
let n = t.dom.firstChild.getBoundingClientRect(), r =
|
|
1045
|
+
let n = t.dom.firstChild.getBoundingClientRect(), r = W(t, {
|
|
1204
1046
|
left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
|
|
1205
1047
|
top: e.y
|
|
1206
1048
|
});
|
|
1207
|
-
if (r) return
|
|
1049
|
+
if (r) return W(t, {
|
|
1208
1050
|
left: r.node.getBoundingClientRect().right - 10,
|
|
1209
1051
|
top: e.y
|
|
1210
1052
|
}, !1);
|
|
1211
1053
|
}
|
|
1212
|
-
var
|
|
1054
|
+
var Ft = class {
|
|
1055
|
+
editor;
|
|
1056
|
+
pmView;
|
|
1213
1057
|
state;
|
|
1214
1058
|
emitUpdate;
|
|
1215
1059
|
mousePos;
|
|
@@ -1231,11 +1075,11 @@ var J = class {
|
|
|
1231
1075
|
clientX: this.mousePos.x,
|
|
1232
1076
|
clientY: this.mousePos.y
|
|
1233
1077
|
});
|
|
1234
|
-
if (e?.element !== this.pmView.dom || e.distance >
|
|
1078
|
+
if (e?.element !== this.pmView.dom || e.distance > Nt) {
|
|
1235
1079
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
1236
1080
|
return;
|
|
1237
1081
|
}
|
|
1238
|
-
let t =
|
|
1082
|
+
let t = Pt(this.mousePos, this.pmView);
|
|
1239
1083
|
if (!t || !this.editor.isEditable) {
|
|
1240
1084
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
1241
1085
|
return;
|
|
@@ -1254,9 +1098,9 @@ var J = class {
|
|
|
1254
1098
|
if (!t || this.pmView.dragging) return;
|
|
1255
1099
|
let n = document.createElement("div");
|
|
1256
1100
|
n.innerHTML = t;
|
|
1257
|
-
let r =
|
|
1101
|
+
let r = fe.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
|
|
1258
1102
|
this.pmView.dragging = {
|
|
1259
|
-
slice: new
|
|
1103
|
+
slice: new pe(r.content, 0, 0),
|
|
1260
1104
|
move: !0
|
|
1261
1105
|
};
|
|
1262
1106
|
};
|
|
@@ -1288,7 +1132,7 @@ var J = class {
|
|
|
1288
1132
|
getDragEventContext = (e) => {
|
|
1289
1133
|
if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1290
1134
|
let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
|
|
1291
|
-
if (!i || i.distance >
|
|
1135
|
+
if (!i || i.distance > Nt) return;
|
|
1292
1136
|
let a = i.element === this.pmView.dom, o = a && i.distance === 0;
|
|
1293
1137
|
if (!(!a && !r)) return {
|
|
1294
1138
|
isDropPoint: a,
|
|
@@ -1306,7 +1150,7 @@ var J = class {
|
|
|
1306
1150
|
let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
|
|
1307
1151
|
if (!r && n && this.dispatchSyntheticEvent(e), n) {
|
|
1308
1152
|
if (this.pmView.dragging) return;
|
|
1309
|
-
this.pmView.dispatch(this.pmView.state.tr.setSelection(
|
|
1153
|
+
this.pmView.dispatch(this.pmView.state.tr.setSelection(Te.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
|
|
1310
1154
|
return;
|
|
1311
1155
|
} else if (i) {
|
|
1312
1156
|
setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
|
|
@@ -1320,7 +1164,7 @@ var J = class {
|
|
|
1320
1164
|
this.state?.show && this.editor.isFocused() && (this.state.show = !1, this.emitUpdate(this.state));
|
|
1321
1165
|
};
|
|
1322
1166
|
onMouseMove = (e) => {
|
|
1323
|
-
if (this.menuFrozen) return;
|
|
1167
|
+
if (this.menuFrozen || !Number.isFinite(e.clientX) || !Number.isFinite(e.clientY)) return;
|
|
1324
1168
|
this.mousePos = {
|
|
1325
1169
|
x: e.clientX,
|
|
1326
1170
|
y: e.clientY
|
|
@@ -1342,22 +1186,22 @@ var J = class {
|
|
|
1342
1186
|
destroy() {
|
|
1343
1187
|
this.state?.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.removeEventListener("dragstart", this.onDragStart), this.pmView.root.removeEventListener("dragover", this.onDragOver), this.pmView.root.removeEventListener("drop", this.onDrop, !0), this.pmView.root.removeEventListener("dragend", this.onDragEnd, !0), this.pmView.root.removeEventListener("keydown", this.onKeyDown, !0);
|
|
1344
1188
|
}
|
|
1345
|
-
},
|
|
1346
|
-
let t, n =
|
|
1189
|
+
}, It = new we("SideMenuPlugin"), Lt = b(({ editor: e }) => {
|
|
1190
|
+
let t, n = y(void 0);
|
|
1347
1191
|
return {
|
|
1348
1192
|
key: "sideMenu",
|
|
1349
1193
|
store: n,
|
|
1350
|
-
prosemirrorPlugins: [new
|
|
1351
|
-
key:
|
|
1352
|
-
view: (r) => (t = new
|
|
1194
|
+
prosemirrorPlugins: [new Ce({
|
|
1195
|
+
key: It,
|
|
1196
|
+
view: (r) => (t = new Ft(e, r, (e) => {
|
|
1353
1197
|
n.setState({ ...e });
|
|
1354
1198
|
}), t)
|
|
1355
1199
|
})],
|
|
1356
1200
|
blockDragStart(n, r) {
|
|
1357
|
-
t && (t.isDragOrigin = !0),
|
|
1201
|
+
t && (t.isDragOrigin = !0), Mt(n, r, e);
|
|
1358
1202
|
},
|
|
1359
1203
|
blockDragEnd() {
|
|
1360
|
-
|
|
1204
|
+
jt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
|
|
1361
1205
|
},
|
|
1362
1206
|
freezeMenu() {
|
|
1363
1207
|
t.menuFrozen = !0, t.state.show = !0, t.emitUpdate(t.state);
|
|
@@ -1369,19 +1213,19 @@ var J = class {
|
|
|
1369
1213
|
!t.menuFrozen && t.state?.show && (t.state.show = !1, t.emitUpdate(t.state));
|
|
1370
1214
|
}
|
|
1371
1215
|
};
|
|
1372
|
-
}),
|
|
1373
|
-
async function
|
|
1374
|
-
return
|
|
1216
|
+
}), G;
|
|
1217
|
+
async function Rt() {
|
|
1218
|
+
return G || (G = (async () => {
|
|
1375
1219
|
let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
|
|
1376
1220
|
return await n.init({ data: r }), {
|
|
1377
1221
|
emojiMart: n,
|
|
1378
1222
|
emojiData: r
|
|
1379
1223
|
};
|
|
1380
|
-
})(),
|
|
1224
|
+
})(), G);
|
|
1381
1225
|
}
|
|
1382
|
-
async function
|
|
1383
|
-
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !==
|
|
1384
|
-
let { emojiData: n, emojiMart: r } = await
|
|
1226
|
+
async function zt(e, t) {
|
|
1227
|
+
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== te.text) return [];
|
|
1228
|
+
let { emojiData: n, emojiMart: r } = await Rt();
|
|
1385
1229
|
return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
|
|
1386
1230
|
id: t.skins[0].native,
|
|
1387
1231
|
onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
|
|
@@ -1389,17 +1233,17 @@ async function Zt(e, t) {
|
|
|
1389
1233
|
}
|
|
1390
1234
|
//#endregion
|
|
1391
1235
|
//#region src/extensions/TableHandles/TableHandles.ts
|
|
1392
|
-
var
|
|
1393
|
-
function
|
|
1394
|
-
|
|
1236
|
+
var K;
|
|
1237
|
+
function Bt(e) {
|
|
1238
|
+
K || (K = document.createElement("div"), K.innerHTML = "_", K.style.opacity = "0", K.style.height = "1px", K.style.width = "1px", e instanceof Document ? e.body.appendChild(K) : e.appendChild(K));
|
|
1395
1239
|
}
|
|
1396
|
-
function
|
|
1397
|
-
|
|
1240
|
+
function Vt(e) {
|
|
1241
|
+
K &&= (e instanceof Document ? e.body.removeChild(K) : e.removeChild(K), void 0);
|
|
1398
1242
|
}
|
|
1399
|
-
function
|
|
1243
|
+
function q(e) {
|
|
1400
1244
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
1401
1245
|
}
|
|
1402
|
-
function
|
|
1246
|
+
function Ht(e) {
|
|
1403
1247
|
let t = e;
|
|
1404
1248
|
for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
|
|
1405
1249
|
if (t.classList.contains("ProseMirror")) return;
|
|
@@ -1417,11 +1261,13 @@ function en(e) {
|
|
|
1417
1261
|
tbodyNode: t.querySelector("tbody")
|
|
1418
1262
|
};
|
|
1419
1263
|
}
|
|
1420
|
-
function
|
|
1264
|
+
function Ut(e, t) {
|
|
1421
1265
|
let n = t.querySelectorAll(e);
|
|
1422
1266
|
for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
|
|
1423
1267
|
}
|
|
1424
|
-
var
|
|
1268
|
+
var Wt = class {
|
|
1269
|
+
editor;
|
|
1270
|
+
pmView;
|
|
1425
1271
|
state;
|
|
1426
1272
|
emitUpdate;
|
|
1427
1273
|
tableId;
|
|
@@ -1432,7 +1278,6 @@ var nn = class {
|
|
|
1432
1278
|
prevWasEditable = null;
|
|
1433
1279
|
constructor(e, t, n) {
|
|
1434
1280
|
this.editor = e, this.pmView = t, this.emitUpdate = () => {
|
|
1435
|
-
if (!this.state) throw Error("Attempting to update uninitialized image toolbar");
|
|
1436
1281
|
n(this.state);
|
|
1437
1282
|
}, t.dom.addEventListener("mousemove", this.mouseMoveHandler), t.dom.addEventListener("mousedown", this.viewMousedownHandler), window.addEventListener("mouseup", this.mouseUpHandler), t.root.addEventListener("dragover", this.dragOverHandler), t.root.addEventListener("drop", this.dropHandler);
|
|
1438
1283
|
}
|
|
@@ -1444,7 +1289,7 @@ var nn = class {
|
|
|
1444
1289
|
};
|
|
1445
1290
|
mouseMoveHandler = (e) => {
|
|
1446
1291
|
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
|
|
1447
|
-
let t =
|
|
1292
|
+
let t = Ht(e.target);
|
|
1448
1293
|
if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
|
|
1449
1294
|
this.mouseState = "selecting", this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1450
1295
|
return;
|
|
@@ -1454,42 +1299,45 @@ var nn = class {
|
|
|
1454
1299
|
return;
|
|
1455
1300
|
}
|
|
1456
1301
|
if (!t.tbodyNode) return;
|
|
1457
|
-
let
|
|
1458
|
-
if (!
|
|
1459
|
-
this.tableElement =
|
|
1460
|
-
let a, o = this.editor.transact((e) =>
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1302
|
+
let n = t.tbodyNode.getBoundingClientRect(), r = A(t.domNode, this.pmView);
|
|
1303
|
+
if (!r) return;
|
|
1304
|
+
this.tableElement = r.node;
|
|
1305
|
+
let i, { pmNodeInfo: a, doc: o } = this.editor.transact((e) => ({
|
|
1306
|
+
pmNodeInfo: ee(r.id, e.doc),
|
|
1307
|
+
doc: e.doc
|
|
1308
|
+
}));
|
|
1309
|
+
if (!a) throw Error(`Block with ID ${r.id} not found`);
|
|
1310
|
+
let s = _(a.node, o);
|
|
1311
|
+
if (g(this.editor, "table") && (this.tablePos = a.posBeforeNode + 1, i = s), !i) return;
|
|
1312
|
+
this.tableId = r.id;
|
|
1465
1313
|
let c = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
|
|
1466
1314
|
if (t?.type === "wrapper") {
|
|
1467
|
-
let t = e.clientY >=
|
|
1315
|
+
let t = e.clientY >= n.bottom - 1 && e.clientY < n.bottom + 20, r = e.clientX >= n.right - 1 && e.clientX < n.right + 20, a = this.state?.block?.id !== i.id || e.clientX > n.right || e.clientY > n.bottom;
|
|
1468
1316
|
this.state = {
|
|
1469
1317
|
...this.state,
|
|
1470
1318
|
show: !0,
|
|
1471
1319
|
showAddOrRemoveRowsButton: t,
|
|
1472
|
-
showAddOrRemoveColumnsButton:
|
|
1473
|
-
referencePosTable:
|
|
1474
|
-
block:
|
|
1320
|
+
showAddOrRemoveColumnsButton: r,
|
|
1321
|
+
referencePosTable: n,
|
|
1322
|
+
block: i,
|
|
1475
1323
|
widgetContainer: c,
|
|
1476
|
-
colIndex:
|
|
1477
|
-
rowIndex:
|
|
1478
|
-
referencePosCell:
|
|
1324
|
+
colIndex: a ? void 0 : this.state?.colIndex,
|
|
1325
|
+
rowIndex: a ? void 0 : this.state?.rowIndex,
|
|
1326
|
+
referencePosCell: a ? void 0 : this.state?.referencePosCell
|
|
1479
1327
|
};
|
|
1480
1328
|
} else {
|
|
1481
|
-
let e =
|
|
1482
|
-
if (this.state !== void 0 && this.state.show && this.tableId ===
|
|
1329
|
+
let e = q(t.domNode), a = q(t.domNode.parentElement), o = t.domNode.getBoundingClientRect();
|
|
1330
|
+
if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === a && this.state.colIndex === e) return;
|
|
1483
1331
|
this.state = {
|
|
1484
1332
|
show: !0,
|
|
1485
|
-
showAddOrRemoveColumnsButton: e ===
|
|
1486
|
-
showAddOrRemoveRowsButton:
|
|
1487
|
-
referencePosTable:
|
|
1488
|
-
block:
|
|
1333
|
+
showAddOrRemoveColumnsButton: e === i.content.rows[0].cells.length - 1,
|
|
1334
|
+
showAddOrRemoveRowsButton: a === i.content.rows.length - 1,
|
|
1335
|
+
referencePosTable: n,
|
|
1336
|
+
block: i,
|
|
1489
1337
|
draggingState: void 0,
|
|
1490
1338
|
referencePosCell: o,
|
|
1491
1339
|
colIndex: e,
|
|
1492
|
-
rowIndex:
|
|
1340
|
+
rowIndex: a,
|
|
1493
1341
|
widgetContainer: c
|
|
1494
1342
|
};
|
|
1495
1343
|
}
|
|
@@ -1497,27 +1345,27 @@ var nn = class {
|
|
|
1497
1345
|
};
|
|
1498
1346
|
dragOverHandler = (e) => {
|
|
1499
1347
|
if (this.state?.draggingState === void 0) return;
|
|
1500
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move",
|
|
1348
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", Ut(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
|
|
1501
1349
|
let t = {
|
|
1502
1350
|
left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
|
|
1503
1351
|
top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
|
|
1504
1352
|
}, n = this.pmView.root.elementsFromPoint(t.left, t.top).filter((e) => e.tagName === "TD" || e.tagName === "TH");
|
|
1505
1353
|
if (n.length === 0) return;
|
|
1506
|
-
let r = n[0], i = !1, a =
|
|
1354
|
+
let r = n[0], i = !1, a = q(r.parentElement), o = q(r), s = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, c = (this.state.draggingState.draggedCellOrientation === "row" ? a : o) !== s;
|
|
1507
1355
|
(this.state.rowIndex !== a || this.state.colIndex !== o) && (this.state.rowIndex = a, this.state.colIndex = o, this.state.referencePosCell = r.getBoundingClientRect(), i = !0);
|
|
1508
1356
|
let l = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
|
|
1509
|
-
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(
|
|
1357
|
+
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(J, !0));
|
|
1510
1358
|
};
|
|
1511
1359
|
dropHandler = (e) => {
|
|
1512
1360
|
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
|
|
1513
1361
|
if (this.state.rowIndex === void 0 || this.state.colIndex === void 0) throw Error("Attempted to drop table row or column, but no table block was hovered prior.");
|
|
1514
1362
|
e.preventDefault();
|
|
1515
|
-
let { draggingState:
|
|
1363
|
+
let { draggingState: t, colIndex: n, rowIndex: r } = this.state;
|
|
1516
1364
|
this.state.draggingState = void 0;
|
|
1517
|
-
let
|
|
1518
|
-
if (
|
|
1519
|
-
if (!
|
|
1520
|
-
let e =
|
|
1365
|
+
let a = this.state.block.content.columnWidths;
|
|
1366
|
+
if (t.draggedCellOrientation === "row") {
|
|
1367
|
+
if (!s(this.state.block, t.originalIndex, r)) return !1;
|
|
1368
|
+
let e = f(this.state.block, t.originalIndex, r);
|
|
1521
1369
|
this.editor.updateBlock(this.state.block, {
|
|
1522
1370
|
type: "table",
|
|
1523
1371
|
content: {
|
|
@@ -1526,13 +1374,13 @@ var nn = class {
|
|
|
1526
1374
|
}
|
|
1527
1375
|
});
|
|
1528
1376
|
} else {
|
|
1529
|
-
if (!
|
|
1530
|
-
let e =
|
|
1531
|
-
|
|
1377
|
+
if (!o(this.state.block, t.originalIndex, n)) return !1;
|
|
1378
|
+
let e = i(this.state.block, t.originalIndex, n), [r] = a.splice(t.originalIndex, 1);
|
|
1379
|
+
a.splice(n, 0, r), this.editor.updateBlock(this.state.block, {
|
|
1532
1380
|
type: "table",
|
|
1533
1381
|
content: {
|
|
1534
1382
|
...this.state.block.content,
|
|
1535
|
-
columnWidths:
|
|
1383
|
+
columnWidths: a,
|
|
1536
1384
|
rows: e
|
|
1537
1385
|
}
|
|
1538
1386
|
});
|
|
@@ -1542,10 +1390,10 @@ var nn = class {
|
|
|
1542
1390
|
update() {
|
|
1543
1391
|
if (!this.state || !this.state.show) return;
|
|
1544
1392
|
if (this.state.block = this.editor.getBlock(this.state.block.id), !this.state.block || this.state.block.type !== "table" || !this.tableElement?.isConnected) {
|
|
1545
|
-
this.state
|
|
1393
|
+
this.state = void 0, this.tableId = void 0, this.tableElement = void 0, this.emitUpdate();
|
|
1546
1394
|
return;
|
|
1547
1395
|
}
|
|
1548
|
-
let { height: e, width: t } =
|
|
1396
|
+
let { height: e, width: t } = p(this.state.block);
|
|
1549
1397
|
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >= t && (this.state.colIndex = t - 1));
|
|
1550
1398
|
let n = this.tableElement.querySelector("tbody");
|
|
1551
1399
|
if (!n) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
|
|
@@ -1558,39 +1406,39 @@ var nn = class {
|
|
|
1558
1406
|
destroy() {
|
|
1559
1407
|
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener("dragover", this.dragOverHandler), this.pmView.root.removeEventListener("drop", this.dropHandler);
|
|
1560
1408
|
}
|
|
1561
|
-
},
|
|
1562
|
-
let t,
|
|
1409
|
+
}, J = new w("TableHandlesPlugin"), Gt = b(({ editor: e }) => {
|
|
1410
|
+
let t, i = y(void 0);
|
|
1563
1411
|
return {
|
|
1564
1412
|
key: "tableHandles",
|
|
1565
|
-
store:
|
|
1566
|
-
prosemirrorPlugins: [new
|
|
1567
|
-
key:
|
|
1568
|
-
view: (
|
|
1569
|
-
|
|
1413
|
+
store: i,
|
|
1414
|
+
prosemirrorPlugins: [new C({
|
|
1415
|
+
key: J,
|
|
1416
|
+
view: (n) => (t = new Wt(e, n, (e) => {
|
|
1417
|
+
i.setState(e?.block ? {
|
|
1570
1418
|
...e,
|
|
1571
1419
|
draggingState: e.draggingState ? { ...e.draggingState } : void 0
|
|
1572
1420
|
} : void 0);
|
|
1573
1421
|
}), t),
|
|
1574
1422
|
props: { decorations: (e) => {
|
|
1575
1423
|
if (t === void 0 || t.state === void 0 || t.state.draggingState === void 0 || t.tablePos === void 0) return;
|
|
1576
|
-
let
|
|
1577
|
-
if (
|
|
1578
|
-
let i = [], { block:
|
|
1579
|
-
if (
|
|
1580
|
-
let
|
|
1581
|
-
return t.state.draggingState.draggedCellOrientation === "row" ?
|
|
1582
|
-
let a = e.doc.resolve(
|
|
1583
|
-
i.push(
|
|
1424
|
+
let r = t.state.draggingState.draggedCellOrientation === "row" ? t.state.rowIndex : t.state.colIndex;
|
|
1425
|
+
if (r === void 0) return;
|
|
1426
|
+
let i = [], { block: a, draggingState: c } = t.state, { originalIndex: l, draggedCellOrientation: u } = c;
|
|
1427
|
+
if (r === l || !a || u === "row" && !s(a, l, r) || u === "col" && !o(a, l, r)) return D.create(e.doc, i);
|
|
1428
|
+
let d = e.doc.resolve(t.tablePos + 1);
|
|
1429
|
+
return t.state.draggingState.draggedCellOrientation === "row" ? n(t.state.block, r).forEach(({ row: t, col: n }) => {
|
|
1430
|
+
let a = e.doc.resolve(d.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(n) + 1), s = o.node(), c = o.pos + (r > l ? s.nodeSize - 2 : 0);
|
|
1431
|
+
i.push(E.widget(c, () => {
|
|
1584
1432
|
let e = document.createElement("div");
|
|
1585
|
-
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0",
|
|
1433
|
+
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", r > l ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
|
|
1586
1434
|
}));
|
|
1587
|
-
}) :
|
|
1588
|
-
let a = e.doc.resolve(
|
|
1589
|
-
i.push(
|
|
1435
|
+
}) : v(t.state.block, r).forEach(({ row: t, col: n }) => {
|
|
1436
|
+
let a = e.doc.resolve(d.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(n) + 1), s = o.node(), c = o.pos + (r > l ? s.nodeSize - 2 : 0);
|
|
1437
|
+
i.push(E.widget(c, () => {
|
|
1590
1438
|
let e = document.createElement("div");
|
|
1591
|
-
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0",
|
|
1439
|
+
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", r > l ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
|
|
1592
1440
|
}));
|
|
1593
|
-
}),
|
|
1441
|
+
}), D.create(e.doc, i);
|
|
1594
1442
|
} }
|
|
1595
1443
|
})],
|
|
1596
1444
|
colDragStart(n) {
|
|
@@ -1599,12 +1447,12 @@ var nn = class {
|
|
|
1599
1447
|
draggedCellOrientation: "col",
|
|
1600
1448
|
originalIndex: t.state.colIndex,
|
|
1601
1449
|
mousePos: n.clientX
|
|
1602
|
-
}, t.emitUpdate(), e.transact((e) => e.setMeta(
|
|
1450
|
+
}, t.emitUpdate(), e.transact((e) => e.setMeta(J, {
|
|
1603
1451
|
draggedCellOrientation: t.state.draggingState.draggedCellOrientation,
|
|
1604
1452
|
originalIndex: t.state.colIndex,
|
|
1605
1453
|
newIndex: t.state.colIndex,
|
|
1606
1454
|
tablePos: t.tablePos
|
|
1607
|
-
})), !e.headless && (
|
|
1455
|
+
})), !e.headless && (Bt(e.prosemirrorView.root), n.dataTransfer.setDragImage(K, 0, 0), n.dataTransfer.effectAllowed = "move");
|
|
1608
1456
|
},
|
|
1609
1457
|
rowDragStart(n) {
|
|
1610
1458
|
if (t.state === void 0 || t.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
@@ -1612,16 +1460,16 @@ var nn = class {
|
|
|
1612
1460
|
draggedCellOrientation: "row",
|
|
1613
1461
|
originalIndex: t.state.rowIndex,
|
|
1614
1462
|
mousePos: n.clientY
|
|
1615
|
-
}, t.emitUpdate(), e.transact((e) => e.setMeta(
|
|
1463
|
+
}, t.emitUpdate(), e.transact((e) => e.setMeta(J, {
|
|
1616
1464
|
draggedCellOrientation: t.state.draggingState.draggedCellOrientation,
|
|
1617
1465
|
originalIndex: t.state.rowIndex,
|
|
1618
1466
|
newIndex: t.state.rowIndex,
|
|
1619
1467
|
tablePos: t.tablePos
|
|
1620
|
-
})), !e.headless && (
|
|
1468
|
+
})), !e.headless && (Bt(e.prosemirrorView.root), n.dataTransfer.setDragImage(K, 0, 0), n.dataTransfer.effectAllowed = "copyMove");
|
|
1621
1469
|
},
|
|
1622
1470
|
dragEnd() {
|
|
1623
1471
|
if (t.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1624
|
-
t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(
|
|
1472
|
+
t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(J, null)), !e.headless && Vt(e.prosemirrorView.root);
|
|
1625
1473
|
},
|
|
1626
1474
|
freezeHandles() {
|
|
1627
1475
|
t.menuFrozen = !0;
|
|
@@ -1633,15 +1481,15 @@ var nn = class {
|
|
|
1633
1481
|
!t.menuFrozen && t.state?.show && (t.state.show = !1, t.state.showAddOrRemoveRowsButton = !1, t.state.showAddOrRemoveColumnsButton = !1, t.emitUpdate());
|
|
1634
1482
|
},
|
|
1635
1483
|
getCellsAtRowHandle(e, t) {
|
|
1636
|
-
return
|
|
1484
|
+
return n(e, t);
|
|
1637
1485
|
},
|
|
1638
1486
|
getCellsAtColumnHandle(e, t) {
|
|
1639
|
-
return
|
|
1487
|
+
return v(e, t);
|
|
1640
1488
|
},
|
|
1641
1489
|
setCellSelection(e, n, r = n) {
|
|
1642
1490
|
if (!t) throw Error("Table handles view not initialized");
|
|
1643
1491
|
let i = e.doc.resolve(t.tablePos + 1), a = e.doc.resolve(i.posAtIndex(n.row) + 1), o = e.doc.resolve(a.posAtIndex(n.col)), s = e.doc.resolve(i.posAtIndex(r.row) + 1), c = e.doc.resolve(s.posAtIndex(r.col)), l = e.tr;
|
|
1644
|
-
return l.setSelection(new
|
|
1492
|
+
return l.setSelection(new me(o, c)), e.apply(l);
|
|
1645
1493
|
},
|
|
1646
1494
|
addRowOrColumn(t, n) {
|
|
1647
1495
|
e.exec((e, r) => {
|
|
@@ -1652,28 +1500,28 @@ var nn = class {
|
|
|
1652
1500
|
row: 0,
|
|
1653
1501
|
col: t
|
|
1654
1502
|
});
|
|
1655
|
-
return n.orientation === "row" ? n.side === "above" ?
|
|
1503
|
+
return n.orientation === "row" ? n.side === "above" ? ve(i, r) : _e(i, r) : n.side === "left" ? ge(i, r) : he(i, r);
|
|
1656
1504
|
});
|
|
1657
1505
|
},
|
|
1658
1506
|
removeRowOrColumn(t, n) {
|
|
1659
|
-
return n === "row" ? e.exec((e, n) =>
|
|
1507
|
+
return n === "row" ? e.exec((e, n) => be(this.setCellSelection(e, {
|
|
1660
1508
|
row: t,
|
|
1661
1509
|
col: 0
|
|
1662
|
-
}), n)) : e.exec((e, n) =>
|
|
1510
|
+
}), n)) : e.exec((e, n) => ye(this.setCellSelection(e, {
|
|
1663
1511
|
row: 0,
|
|
1664
1512
|
col: t
|
|
1665
1513
|
}), n));
|
|
1666
1514
|
},
|
|
1667
1515
|
mergeCells(t) {
|
|
1668
|
-
return e.exec((e, n) =>
|
|
1516
|
+
return e.exec((e, n) => xe(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
|
|
1669
1517
|
},
|
|
1670
1518
|
splitCell(t) {
|
|
1671
|
-
return e.exec((e, n) =>
|
|
1519
|
+
return e.exec((e, n) => Se(t ? this.setCellSelection(e, t) : e, n));
|
|
1672
1520
|
},
|
|
1673
1521
|
getCellSelection() {
|
|
1674
1522
|
return e.transact((e) => {
|
|
1675
1523
|
let t = e.selection, n = t.$from, r = t.$to;
|
|
1676
|
-
if (
|
|
1524
|
+
if (m(t)) {
|
|
1677
1525
|
let { ranges: e } = t;
|
|
1678
1526
|
e.forEach((e) => {
|
|
1679
1527
|
n = e.$from.min(n ?? e.$from), r = e.$to.max(r ?? e.$to);
|
|
@@ -1699,28 +1547,28 @@ var nn = class {
|
|
|
1699
1547
|
},
|
|
1700
1548
|
getMergeDirection(t) {
|
|
1701
1549
|
return e.transact((e) => {
|
|
1702
|
-
let n =
|
|
1550
|
+
let n = m(e.selection) ? e.selection : void 0;
|
|
1703
1551
|
if (!n || !t || n.ranges.length <= 1) return;
|
|
1704
|
-
let
|
|
1705
|
-
if (
|
|
1552
|
+
let i = this.getCellSelection();
|
|
1553
|
+
if (i) return r(i.from, i.to, t) ? "vertical" : "horizontal";
|
|
1706
1554
|
});
|
|
1707
1555
|
},
|
|
1708
1556
|
cropEmptyRowsOrColumns(e, t) {
|
|
1709
|
-
return
|
|
1557
|
+
return d(e, t);
|
|
1710
1558
|
},
|
|
1711
1559
|
addRowsOrColumns(e, t, n) {
|
|
1712
|
-
return
|
|
1560
|
+
return u(e, t, n);
|
|
1713
1561
|
}
|
|
1714
1562
|
};
|
|
1715
|
-
}),
|
|
1716
|
-
function
|
|
1563
|
+
}), Y = new w("trailingNode");
|
|
1564
|
+
function Kt(e, t) {
|
|
1717
1565
|
if (!t) return !1;
|
|
1718
1566
|
let n = e.lastChild?.lastChild, r = n?.firstChild;
|
|
1719
1567
|
return !(n?.type.name === "blockContainer" && r?.type.name === "paragraph" && r.content.size === 0);
|
|
1720
1568
|
}
|
|
1721
|
-
var
|
|
1569
|
+
var qt = b(({ editor: e }) => {
|
|
1722
1570
|
function t(t) {
|
|
1723
|
-
return
|
|
1571
|
+
return E.widget(t, () => {
|
|
1724
1572
|
let t = document.createElement("div");
|
|
1725
1573
|
return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (t) => {
|
|
1726
1574
|
t.preventDefault(), e.transact((t) => {
|
|
@@ -1732,27 +1580,251 @@ var on = v(({ editor: e }) => {
|
|
|
1732
1580
|
}
|
|
1733
1581
|
function n(e, n, r) {
|
|
1734
1582
|
let i = n.map(e.mapping, e.doc), a = i.find(), o = a.length > 0;
|
|
1735
|
-
return o ===
|
|
1583
|
+
return o === Kt(e.doc, r) ? i : o ? i.remove(a) : i.add(e.doc, [t(e.doc.content.size - 1)]);
|
|
1736
1584
|
}
|
|
1737
1585
|
return {
|
|
1738
1586
|
key: "trailingNode",
|
|
1739
|
-
prosemirrorPlugins: [new
|
|
1740
|
-
key:
|
|
1587
|
+
prosemirrorPlugins: [new C({
|
|
1588
|
+
key: Y,
|
|
1741
1589
|
state: {
|
|
1742
|
-
init: (t, r) => n(r.tr,
|
|
1743
|
-
apply: (t, r) => !t.docChanged && !t.getMeta(
|
|
1590
|
+
init: (t, r) => n(r.tr, D.empty, e.isEditable),
|
|
1591
|
+
apply: (t, r) => !t.docChanged && !t.getMeta(Y) ? r : n(t, r, e.isEditable)
|
|
1744
1592
|
},
|
|
1745
1593
|
view(e) {
|
|
1746
1594
|
let t = e.editable;
|
|
1747
1595
|
return { update(e) {
|
|
1748
|
-
e.editable !== t && (t = e.editable, e.dispatch(e.state.tr.setMeta(
|
|
1596
|
+
e.editable !== t && (t = e.editable, e.dispatch(e.state.tr.setMeta(Y, !0)));
|
|
1749
1597
|
} };
|
|
1750
1598
|
},
|
|
1751
|
-
props: {
|
|
1599
|
+
props: {
|
|
1600
|
+
decorations: (e) => Y.getState(e),
|
|
1601
|
+
handleKeyDown: (t, n) => {
|
|
1602
|
+
if (n.key !== "ArrowRight" && n.key !== "ArrowDown") return !1;
|
|
1603
|
+
let { selection: r } = t.state;
|
|
1604
|
+
if (!r.empty) return !1;
|
|
1605
|
+
let i = T.atEnd(t.state.doc);
|
|
1606
|
+
return r.$head.pos !== i.$head.pos || !Kt(t.state.doc, e.isEditable) ? !1 : (n.preventDefault(), !0);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1752
1609
|
})]
|
|
1753
1610
|
};
|
|
1611
|
+
}), X = Symbol("bn-current-version");
|
|
1612
|
+
function Z(e) {
|
|
1613
|
+
return [...e].sort((e, t) => t.createdAt - e.createdAt);
|
|
1614
|
+
}
|
|
1615
|
+
function Q(e) {
|
|
1616
|
+
let t = typeof e == "object" ? e.id : e;
|
|
1617
|
+
throw Error(`Snapshot not found: ${String(t)}`);
|
|
1618
|
+
}
|
|
1619
|
+
var Jt = b(({ options: e, editor: t }) => {
|
|
1620
|
+
let { endpoints: n, preview: r, getCurrentDocument: i, serializeCurrentContent: a, resolveUsers: o } = typeof e == "function" ? e(t) : e, s = typeof n == "function" ? n(t) : n, c = ne(o), l = y({
|
|
1621
|
+
snapshots: [],
|
|
1622
|
+
previewedSnapshotId: void 0,
|
|
1623
|
+
compareToSnapshotId: void 0
|
|
1624
|
+
}), u = (e) => {
|
|
1625
|
+
let t = typeof e == "object" ? e.id : e;
|
|
1626
|
+
return l.state.snapshots.find((e) => e.id === t);
|
|
1627
|
+
}, d = async () => {
|
|
1628
|
+
let e = Z(await s.list());
|
|
1629
|
+
return l.setState((t) => ({
|
|
1630
|
+
...t,
|
|
1631
|
+
snapshots: e
|
|
1632
|
+
})), e;
|
|
1633
|
+
}, f = async (e, t) => {
|
|
1634
|
+
let n = u(e);
|
|
1635
|
+
n || Q(e);
|
|
1636
|
+
let i = t?.compareTo ? u(t.compareTo) : void 0;
|
|
1637
|
+
l.setState((e) => ({
|
|
1638
|
+
...e,
|
|
1639
|
+
previewedSnapshotId: n.id,
|
|
1640
|
+
compareToSnapshotId: i?.id
|
|
1641
|
+
}));
|
|
1642
|
+
let a, o;
|
|
1643
|
+
i && (a = await s.getContent(i), s.getAttributions && (o = await s.getAttributions(n, i)));
|
|
1644
|
+
let c = await s.getContent(n);
|
|
1645
|
+
r.enterPreview(c, a, o, {
|
|
1646
|
+
snapshot: n,
|
|
1647
|
+
compareTo: i
|
|
1648
|
+
});
|
|
1649
|
+
}, p = async (e) => {
|
|
1650
|
+
if (!a) throw Error("previewCurrentVersion requires `serializeCurrentContent` to be provided to the VersioningExtension options.");
|
|
1651
|
+
let t = e?.compareTo ? u(e.compareTo) : void 0;
|
|
1652
|
+
l.setState((e) => ({
|
|
1653
|
+
...e,
|
|
1654
|
+
previewedSnapshotId: X,
|
|
1655
|
+
compareToSnapshotId: t?.id
|
|
1656
|
+
}));
|
|
1657
|
+
let n = {
|
|
1658
|
+
id: X,
|
|
1659
|
+
createdAt: Date.now(),
|
|
1660
|
+
updatedAt: Date.now()
|
|
1661
|
+
}, i, o;
|
|
1662
|
+
t && (i = await s.getContent(t), s.getAttributions && (o = await s.getAttributions(n, t)));
|
|
1663
|
+
let c = await a();
|
|
1664
|
+
r.enterPreview(c, i, o, {
|
|
1665
|
+
snapshot: n,
|
|
1666
|
+
compareTo: t
|
|
1667
|
+
});
|
|
1668
|
+
}, m = () => {
|
|
1669
|
+
l.setState((e) => ({
|
|
1670
|
+
...e,
|
|
1671
|
+
previewedSnapshotId: void 0,
|
|
1672
|
+
compareToSnapshotId: void 0
|
|
1673
|
+
})), r.exitPreview();
|
|
1674
|
+
};
|
|
1675
|
+
return {
|
|
1676
|
+
key: "versioning",
|
|
1677
|
+
store: l,
|
|
1678
|
+
userStore: c,
|
|
1679
|
+
list: async () => await d(),
|
|
1680
|
+
get canCompare() {
|
|
1681
|
+
return r.supportsComparison !== !1;
|
|
1682
|
+
},
|
|
1683
|
+
canCreate: s.create !== void 0,
|
|
1684
|
+
create: s.create ? async (e) => {
|
|
1685
|
+
let t = await s.create(i(), {
|
|
1686
|
+
name: e?.name,
|
|
1687
|
+
restoredFromSnapshot: u(e?.restoredFromSnapshot)
|
|
1688
|
+
});
|
|
1689
|
+
l.setState((e) => ({
|
|
1690
|
+
...e,
|
|
1691
|
+
snapshots: Z([...e.snapshots, t])
|
|
1692
|
+
}));
|
|
1693
|
+
let n = await s.list();
|
|
1694
|
+
return l.setState((e) => ({
|
|
1695
|
+
...e,
|
|
1696
|
+
snapshots: Z(n.some((e) => e.id === t.id) ? n : [...n, t])
|
|
1697
|
+
})), t;
|
|
1698
|
+
} : void 0,
|
|
1699
|
+
canRestore: s.restore !== void 0,
|
|
1700
|
+
restore: s.restore ? async (e) => {
|
|
1701
|
+
m();
|
|
1702
|
+
let t = u(e);
|
|
1703
|
+
t || Q(e);
|
|
1704
|
+
let n = await s.restore(i(), t);
|
|
1705
|
+
return r.applyRestore(n), await d(), n;
|
|
1706
|
+
} : void 0,
|
|
1707
|
+
canRename: s.rename !== void 0,
|
|
1708
|
+
rename: s.rename ? async (e, t) => {
|
|
1709
|
+
let n = u(e);
|
|
1710
|
+
n || Q(e), await s.rename(n, t), l.setState((n) => ({
|
|
1711
|
+
...n,
|
|
1712
|
+
snapshots: n.snapshots.map((n) => n.id === e ? {
|
|
1713
|
+
...n,
|
|
1714
|
+
name: t,
|
|
1715
|
+
updatedAt: Date.now()
|
|
1716
|
+
} : n)
|
|
1717
|
+
}));
|
|
1718
|
+
} : void 0,
|
|
1719
|
+
canRemove: s.remove !== void 0,
|
|
1720
|
+
remove: s.remove ? async (e) => {
|
|
1721
|
+
let t = u(e);
|
|
1722
|
+
t || Q(e), (l.state.previewedSnapshotId === t.id || l.state.compareToSnapshotId === t.id) && m(), await s.remove(t), l.setState((e) => ({
|
|
1723
|
+
...e,
|
|
1724
|
+
snapshots: e.snapshots.filter((e) => e.id !== t.id)
|
|
1725
|
+
})), await d();
|
|
1726
|
+
} : void 0,
|
|
1727
|
+
previewSnapshot: f,
|
|
1728
|
+
canPreviewCurrent: a !== void 0,
|
|
1729
|
+
previewCurrentVersion: a ? p : void 0,
|
|
1730
|
+
exitPreview: m
|
|
1731
|
+
};
|
|
1754
1732
|
});
|
|
1755
1733
|
//#endregion
|
|
1756
|
-
|
|
1734
|
+
//#region src/extensions/Versioning/inMemoryVersioning.ts
|
|
1735
|
+
function Yt(e) {
|
|
1736
|
+
return e.id === X ? "Current version" : e.name ?? "Unnamed version";
|
|
1737
|
+
}
|
|
1738
|
+
function Xt(e) {
|
|
1739
|
+
let t, n = !1, r = (t) => {
|
|
1740
|
+
e.replaceBlocks(e.document, t);
|
|
1741
|
+
}, i = () => e.getExtension("diffVersioning");
|
|
1742
|
+
return {
|
|
1743
|
+
get supportsComparison() {
|
|
1744
|
+
return i() !== void 0;
|
|
1745
|
+
},
|
|
1746
|
+
enterPreview(a, o, s, c) {
|
|
1747
|
+
t === void 0 && (t = e.document);
|
|
1748
|
+
let l = i();
|
|
1749
|
+
if (o && l) {
|
|
1750
|
+
l.renderDiff(a, o, c && Yt(c.snapshot)), n = !0;
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
n = !1, r(a);
|
|
1754
|
+
},
|
|
1755
|
+
exitPreview() {
|
|
1756
|
+
if (t !== void 0) {
|
|
1757
|
+
let e = i();
|
|
1758
|
+
n && e ? e.clearDiff(t) : r(t), t = void 0, n = !1;
|
|
1759
|
+
}
|
|
1760
|
+
},
|
|
1761
|
+
applyRestore(e) {
|
|
1762
|
+
let a = i();
|
|
1763
|
+
n && a ? a.clearDiff(e) : r(e), t = void 0, n = !1;
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
function $() {
|
|
1768
|
+
let e = [], t = /* @__PURE__ */ new Map(), n = 1;
|
|
1769
|
+
return {
|
|
1770
|
+
async list() {
|
|
1771
|
+
return Z([...e]);
|
|
1772
|
+
},
|
|
1773
|
+
async create(r, i) {
|
|
1774
|
+
let a = Date.now(), o = String(n++), s = {
|
|
1775
|
+
id: o,
|
|
1776
|
+
name: i?.name,
|
|
1777
|
+
createdAt: a,
|
|
1778
|
+
updatedAt: a
|
|
1779
|
+
};
|
|
1780
|
+
return e.push(s), t.set(o, structuredClone(r)), s;
|
|
1781
|
+
},
|
|
1782
|
+
async restore(r, i) {
|
|
1783
|
+
let a = String(i.id), o = t.get(a);
|
|
1784
|
+
if (!o) throw Error(`Snapshot ${a} not found`);
|
|
1785
|
+
let s = Date.now(), c = String(n++), l = {
|
|
1786
|
+
id: c,
|
|
1787
|
+
name: "Before restore",
|
|
1788
|
+
createdAt: s,
|
|
1789
|
+
updatedAt: s,
|
|
1790
|
+
restoredFromSnapshotId: a
|
|
1791
|
+
};
|
|
1792
|
+
return e.push(l), t.set(c, structuredClone(r)), structuredClone(o);
|
|
1793
|
+
},
|
|
1794
|
+
async getContent(e) {
|
|
1795
|
+
let n = String(e.id), r = t.get(n);
|
|
1796
|
+
if (!r) throw Error(`Snapshot ${n} not found`);
|
|
1797
|
+
return structuredClone(r);
|
|
1798
|
+
},
|
|
1799
|
+
async rename(t, n) {
|
|
1800
|
+
let r = e.find((e) => e.id === t.id);
|
|
1801
|
+
if (!r) throw Error(`Snapshot ${String(t.id)} not found`);
|
|
1802
|
+
r.name = n, r.updatedAt = Date.now();
|
|
1803
|
+
},
|
|
1804
|
+
async remove(n) {
|
|
1805
|
+
let r = e.findIndex((e) => e.id === n.id);
|
|
1806
|
+
if (r === -1) throw Error(`Snapshot ${String(n.id)} not found`);
|
|
1807
|
+
e.splice(r, 1), t.delete(String(n.id));
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
function Zt(e) {
|
|
1812
|
+
let t = $();
|
|
1813
|
+
return {
|
|
1814
|
+
endpoints: {
|
|
1815
|
+
...t,
|
|
1816
|
+
list: async () => [{
|
|
1817
|
+
id: X,
|
|
1818
|
+
createdAt: Date.now(),
|
|
1819
|
+
updatedAt: Date.now()
|
|
1820
|
+
}, ...await t.list()]
|
|
1821
|
+
},
|
|
1822
|
+
preview: Xt(e),
|
|
1823
|
+
getCurrentDocument: () => e.document,
|
|
1824
|
+
serializeCurrentContent: () => e.document
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
//#endregion
|
|
1828
|
+
export { k as A, Ye as C, Ke as D, Ge as E, ze as O, Xe as S, qe as T, V as _, Jt as a, et as b, Gt as c, zt as d, Lt as f, Dt as g, Ot as h, X as i, Re as k, Wt as l, It as m, Zt as n, Z as o, Ft as p, $ as r, qt as s, Xt as t, J as u, it as v, Je as w, Qe as x, tt as y };
|
|
1757
1829
|
|
|
1758
|
-
//# sourceMappingURL=extensions-
|
|
1830
|
+
//# sourceMappingURL=extensions-CrUGDOks.js.map
|