@blocknote/core 0.55.0 → 0.57.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/NOTICE.txt +101 -0
- package/dist/BlockNoteExtension-U58cXw1g.js +64 -0
- package/dist/ThreadStore-CSEwCO0O.js +8 -0
- package/dist/{UserStore-C4TzkGEn.js → UserStore-BFv6NXA-.js} +3 -7
- package/dist/ar-DPJDxCQI.js +3 -0
- package/dist/blocknote.js +8 -6
- package/dist/blocks-BUX9dXi9.js +2063 -0
- package/dist/blocks.js +3 -2
- package/dist/comments.js +18 -19
- package/dist/de-CakHBokE.js +3 -0
- package/dist/emoji-data.js +102 -0
- package/dist/en-BGdzE27X.js +3 -0
- package/dist/{en-BAn9gxr-.js → en-Ne9rlj9Y.js} +42 -5
- package/dist/es-VeBX6MEG.js +3 -0
- package/dist/extensions-CEgexSyF.js +3091 -0
- package/dist/extensions.js +4 -4
- package/dist/fa-Dt7EYtKf.js +3 -0
- package/dist/fr-DUhhjxrJ.js +3 -0
- package/dist/getDefaultSlashMenuItems-DfDOr807.js +1939 -0
- package/dist/he-BShJg1dK.js +3 -0
- package/dist/hr-BXtyqmwg.js +3 -0
- package/dist/is-2Fb-0w_j.js +3 -0
- package/dist/it-CiZtVb3Y.js +3 -0
- package/dist/ja-CsxD3kEL.js +3 -0
- package/dist/ko-It6g03Cy.js +3 -0
- package/dist/locales.js +1418 -32
- package/dist/markGroups-BszXCkX8.js +18 -0
- package/dist/nb-CLao87La.js +3 -0
- package/dist/nl-JQSo8dht.js +3 -0
- package/dist/pl-DEMBgHEP.js +3 -0
- package/dist/pt-CBCdYAax.js +3 -0
- package/dist/ru-BQk_9Q-L.js +3 -0
- package/dist/sk-kgB2DtDL.js +3 -0
- package/dist/src-DksfoQmN.js +3574 -0
- package/dist/style.css +1 -1
- package/dist/tr-DkcSXX8f.js +3 -0
- package/dist/uk-Bib-e6bV.js +3 -0
- package/dist/uz-B2jaKhJb.js +3 -0
- package/dist/vi-V_GFRxE8.js +3 -0
- package/dist/y.js +1284 -559
- package/dist/yjs.js +211 -171
- package/dist/zh-hant-2ZrAkFnC.js +3 -0
- package/dist/zh-jglyCmjs.js +3 -0
- package/package.json +51 -27
- package/src/fonts/inter.css +111 -0
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -1
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +24 -24
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +3 -2
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -2
- package/types/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.d.ts +34 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +465 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +15 -69
- package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
- package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
- package/types/src/api/combineTransactionSteps.d.ts +12 -0
- package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
- package/types/src/api/getBlockInfoFromPos.d.ts +218 -44
- package/types/src/api/{getChangedRange.d.ts → getChangedRangeWithAttrs.d.ts} +1 -1
- package/types/src/api/getChangedRanges.d.ts +23 -0
- package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +0 -3
- package/types/src/api/parsers/markdown/autolink.d.ts +5 -0
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
- package/types/src/blocks/ToggleWrapper/createToggleFrame.d.ts +29 -0
- package/types/src/blocks/defaultBlockTypeItems.d.ts +37 -0
- package/types/src/blocks/defaultBlocks.d.ts +10 -0
- package/types/src/blocks/index.d.ts +2 -1
- package/types/src/editor/BlockNoteEditor.d.ts +38 -9
- package/types/src/editor/managers/BlockManager.d.ts +4 -3
- package/types/src/editor/managers/ExtensionManager/index.d.ts +19 -7
- package/types/src/editor/managers/StateManager.d.ts +1 -1
- package/types/src/editor/managers/StyleManager.d.ts +2 -1
- package/types/src/editor/transformPasted.d.ts +1 -1
- package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
- package/types/src/emoji-data/frimousse/common.d.ts +3 -0
- package/types/src/emoji-data/frimousse/de.d.ts +2 -0
- package/types/src/emoji-data/frimousse/en.d.ts +2 -0
- package/types/src/emoji-data/frimousse/es.d.ts +2 -0
- package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
- package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/he.d.ts +2 -0
- package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/is.d.ts +2 -0
- package/types/src/emoji-data/frimousse/it.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
- package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
- package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
- package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
- package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
- package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
- package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
- package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/types.d.ts +21 -0
- package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
- package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
- package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
- package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
- package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
- package/types/src/emoji-data/index.d.ts +3 -0
- package/types/src/emoji-data/searchEmojis.d.ts +5 -0
- package/types/src/exporter/Exporter.d.ts +11 -4
- package/types/src/exporter/mapping.d.ts +13 -1
- package/types/src/extensions/DropCursor/DropCursor.d.ts +1 -1
- package/types/src/extensions/DropCursor/dropIntoChildren.d.ts +38 -0
- package/types/src/extensions/Loading/Loading.d.ts +11 -0
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +1 -1
- package/types/src/extensions/ReadOnly/ReadOnly.d.ts +21 -0
- package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
- package/types/src/extensions/SideMenu/SideMenu.d.ts +51 -89
- package/types/src/extensions/SideMenu/blockDropHandling.d.ts +11 -0
- package/types/src/extensions/SideMenu/blockGeometry.d.ts +22 -0
- package/types/src/extensions/SideMenu/dragging.d.ts +0 -4
- package/types/src/extensions/SideMenu/sideMenuHover.d.ts +58 -0
- package/types/src/extensions/Versioning/Versioning.d.ts +36 -311
- package/types/src/extensions/Versioning/createVersioning.d.ts +32 -0
- package/types/src/extensions/Versioning/formatVersionDate.d.ts +7 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +65 -36
- package/types/src/extensions/Versioning/index.d.ts +4 -0
- package/types/src/extensions/Versioning/scrollToFirstChange.d.ts +18 -0
- package/types/src/extensions/Versioning/types.d.ts +245 -0
- package/types/src/extensions/Versioning/versioningState.d.ts +49 -0
- package/types/src/extensions/blockDOM.d.ts +37 -0
- package/types/src/extensions/index.d.ts +3 -2
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
- package/types/src/i18n/dictionary.d.ts +4 -1
- package/types/src/i18n/locales/en.d.ts +38 -0
- package/types/src/i18n/locales/fa.d.ts +38 -0
- package/types/src/i18n/locales/index.d.ts +1 -0
- package/types/src/i18n/locales/sk.d.ts +38 -0
- package/types/src/i18n/locales/tr.d.ts +378 -0
- package/types/src/index.d.ts +5 -3
- package/types/src/pm-nodes/BlockContainer.d.ts +6 -0
- package/types/src/schema/blocks/children.d.ts +39 -0
- package/types/src/schema/blocks/createSpec.d.ts +13 -0
- package/types/src/schema/blocks/frame.d.ts +109 -0
- package/types/src/schema/blocks/internal.d.ts +6 -0
- package/types/src/schema/blocks/keyboard.d.ts +111 -0
- package/types/src/schema/blocks/layoutBlockAttributes.d.ts +9 -0
- package/types/src/schema/blocks/meta.d.ts +14 -0
- package/types/src/schema/blocks/types.d.ts +228 -15
- package/types/src/schema/blocks/validateChildren.d.ts +5 -0
- package/types/src/schema/dataAttributes.d.ts +19 -0
- package/types/src/schema/index.d.ts +3 -0
- package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
- package/types/src/schema/inlineContent/internal.d.ts +1 -1
- package/types/src/schema/inlineContent/types.d.ts +2 -4
- package/types/src/schema/markGroups.d.ts +8 -0
- package/types/src/schema/styles/createSpec.d.ts +2 -1
- package/types/src/schema/styles/internal.d.ts +4 -1
- package/types/src/schema/styles/types.d.ts +2 -0
- package/types/src/user/userColors.d.ts +24 -3
- package/types/src/y/comments/RESTYjsThreadStore.d.ts +1 -1
- package/types/src/y/comments/YjsThreadStore.d.ts +1 -1
- package/types/src/y/comments/YjsThreadStoreBase.d.ts +2 -2
- package/types/src/y/comments/yjsHelpers.d.ts +5 -5
- package/types/src/y/extensions/AttributionExtension.d.ts +19 -21
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +9 -4
- package/types/src/y/extensions/ForkYDoc.d.ts +3 -1
- package/types/src/y/extensions/Versioning.d.ts +4 -15
- package/types/src/y/extensions/YAttributionMarks.d.ts +13 -2
- package/types/src/y/extensions/YCursorPlugin.d.ts +1 -0
- package/types/src/y/extensions/YSync.d.ts +4 -18
- package/types/src/y/extensions/blockMatchNodes.d.ts +0 -22
- package/types/src/y/extensions/index.d.ts +27 -44
- package/types/src/y/extensions/persistentBlockGroups.d.ts +189 -0
- package/types/src/y/extensions/snapshotCodec.d.ts +13 -0
- package/types/src/y/extensions/snapshotPreview.d.ts +21 -0
- package/types/src/y/index.d.ts +1 -0
- package/types/src/y/utils.d.ts +39 -19
- package/types/src/y/versioning/index.d.ts +1 -1
- package/types/src/y/versioning/yhub.d.ts +71 -86
- package/types/src/y/versioning/yhubClient.d.ts +67 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +2 -0
- package/types/src/yjs/extensions/Versioning.d.ts +37 -22
- package/types/src/yjs/extensions/YUndo.d.ts +3 -2
- package/types/src/yjs/extensions/index.d.ts +3 -2
- package/types/src/yjs/index.d.ts +1 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +0 -2
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +0 -1
- package/dist/BlockNoteExtension-CbvDA0F7.js +0 -80
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +0 -1
- package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
- package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
- package/dist/ThreadStore-et9wB5Xt.js +0 -11
- package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
- package/dist/UserStore-C4TzkGEn.js.map +0 -1
- package/dist/UserStore-mj3fXW4D.cjs +0 -2
- package/dist/UserStore-mj3fXW4D.cjs.map +0 -1
- package/dist/blocknote.cjs +0 -1
- package/dist/blocks-DLgTreVu.cjs +0 -12
- package/dist/blocks-DLgTreVu.cjs.map +0 -1
- package/dist/blocks-DaEUT0O1.js +0 -3527
- package/dist/blocks-DaEUT0O1.js.map +0 -1
- package/dist/blocks.cjs +0 -1
- package/dist/comments.cjs +0 -2
- package/dist/comments.cjs.map +0 -1
- package/dist/comments.js.map +0 -1
- package/dist/en-BAn9gxr-.js.map +0 -1
- package/dist/en-CHnrV5l8.cjs +0 -2
- package/dist/en-CHnrV5l8.cjs.map +0 -1
- package/dist/extensions-B1JQURVF.js +0 -2138
- package/dist/extensions-B1JQURVF.js.map +0 -1
- package/dist/extensions-CZkqKzJO.cjs +0 -58
- package/dist/extensions-CZkqKzJO.cjs.map +0 -1
- package/dist/extensions.cjs +0 -1
- package/dist/locales.cjs +0 -2
- package/dist/locales.cjs.map +0 -1
- package/dist/locales.js.map +0 -1
- package/dist/src-D5w0XAHX.js +0 -3379
- package/dist/src-D5w0XAHX.js.map +0 -1
- package/dist/src-th5uZEvx.cjs +0 -23
- package/dist/src-th5uZEvx.cjs.map +0 -1
- package/dist/webpack-stats.json +0 -1
- package/dist/y.cjs +0 -2
- package/dist/y.cjs.map +0 -1
- package/dist/y.js.map +0 -1
- package/dist/yjs.cjs +0 -2
- package/dist/yjs.cjs.map +0 -1
- package/dist/yjs.js.map +0 -1
- package/src/api/README.md +0 -8
- package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
- package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
- package/src/api/__snapshots__/blocks-deleted.json +0 -26
- package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
- package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
- package/src/api/__snapshots__/blocks-inserted.json +0 -20
- package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
- package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
- package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
- package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
- package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
- package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
- package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
- package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
- package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
- package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
- package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
- package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
- package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
- package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
- package/src/api/__snapshots__/blocks-updated-single.json +0 -42
- package/src/api/__snapshots__/blocks-updated.json +0 -42
- package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -56
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -147
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -199
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -375
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -409
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -661
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -208
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -235
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -135
- package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +0 -173
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -151
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -58
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -978
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -685
- package/src/api/blockManipulation/getBlock/getBlock.ts +0 -111
- package/src/api/blockManipulation/insertContentAt.ts +0 -83
- package/src/api/blockManipulation/selections/selection.ts +0 -267
- package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -118
- package/src/api/blockManipulation/setupTestEnv.ts +0 -191
- package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
- package/src/api/blockManipulation/tables/tables.ts +0 -887
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
- package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
- package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
- package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -435
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -253
- package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -884
- package/src/api/exporters/markdown/markdownExporter.ts +0 -41
- package/src/api/getBlockInfoFromPos.test.ts +0 -256
- package/src/api/getBlockInfoFromPos.ts +0 -291
- package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
- package/src/api/getBlocksChangedByTransaction.ts +0 -458
- package/src/api/getChangedRange.ts +0 -54
- package/src/api/nodeConversions/blockToNode.test.ts +0 -113
- package/src/api/nodeConversions/blockToNode.ts +0 -399
- package/src/api/nodeConversions/fragmentToBlocks.ts +0 -63
- package/src/api/nodeConversions/nodeToBlock.ts +0 -665
- package/src/api/nodeUtil.ts +0 -46
- package/src/api/parsers/html/parseHTML.ts +0 -80
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
- package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
- package/src/api/parsers/html/util/nestedLists.ts +0 -123
- package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
- package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
- package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
- package/src/api/parsers/markdown/markdownToHtml.ts +0 -1340
- package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
- package/src/api/pmUtil.ts +0 -79
- package/src/api/positionMapping.test.ts +0 -209
- package/src/api/positionMapping.ts +0 -42
- package/src/blocks/Audio/block.ts +0 -171
- package/src/blocks/Audio/parseAudioElement.ts +0 -5
- package/src/blocks/BlockNoteSchema.ts +0 -59
- package/src/blocks/Code/CodeBlockOptions.ts +0 -83
- package/src/blocks/Code/block.test.ts +0 -265
- package/src/blocks/Code/block.ts +0 -56
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -120
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
- package/src/blocks/Divider/block.ts +0 -49
- package/src/blocks/File/block.ts +0 -95
- package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
- package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
- package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
- package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
- package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
- package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
- package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
- package/src/blocks/Heading/block.ts +0 -188
- package/src/blocks/Image/block.ts +0 -193
- package/src/blocks/Image/parseImageElement.ts +0 -7
- package/src/blocks/ListItem/BulletListItem/block.ts +0 -127
- package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
- package/src/blocks/ListItem/CheckListItem/block.ts +0 -182
- package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +0 -63
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -242
- package/src/blocks/ListItem/NumberedListItem/block.ts +0 -141
- package/src/blocks/ListItem/ToggleListItem/block.ts +0 -128
- package/src/blocks/ListItem/getListItemContent.ts +0 -115
- package/src/blocks/PageBreak/block.ts +0 -72
- package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
- package/src/blocks/Paragraph/block.ts +0 -80
- package/src/blocks/Quote/block.ts +0 -99
- package/src/blocks/README.md +0 -3
- package/src/blocks/Table/TableExtension.test.ts +0 -231
- package/src/blocks/Table/TableExtension.ts +0 -115
- package/src/blocks/Table/block.ts +0 -500
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +0 -197
- package/src/blocks/Video/block.ts +0 -142
- package/src/blocks/Video/parseVideoElement.ts +0 -7
- package/src/blocks/defaultBlockHelpers.ts +0 -113
- package/src/blocks/defaultBlockTypeGuards.ts +0 -167
- package/src/blocks/defaultBlocks.ts +0 -208
- package/src/blocks/defaultProps.ts +0 -165
- package/src/blocks/getDetailsContent.ts +0 -77
- package/src/blocks/index.ts +0 -29
- package/src/blocks/utils/listItemEnterHandler.ts +0 -43
- package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
- package/src/comments/CommentEditorSubmitExtension.ts +0 -56
- package/src/comments/extension.ts +0 -396
- package/src/comments/index.ts +0 -8
- package/src/comments/mark.ts +0 -64
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
- package/src/comments/threadstore/ThreadStore.ts +0 -130
- package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
- package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
- package/src/comments/threadstore/tiptap/types.ts +0 -131
- package/src/comments/types.ts +0 -121
- package/src/editor/Block.css +0 -1366
- package/src/editor/BlockNoteEditor.test.ts +0 -278
- package/src/editor/BlockNoteEditor.ts +0 -1497
- package/src/editor/BlockNoteExtension.test.ts +0 -103
- package/src/editor/BlockNoteExtension.ts +0 -246
- package/src/editor/README.md +0 -3
- package/src/editor/cursorPositionTypes.ts +0 -17
- package/src/editor/defaultColors.ts +0 -77
- package/src/editor/editor.css +0 -197
- package/src/editor/managers/BlockManager.ts +0 -255
- package/src/editor/managers/EventManager.browser.test.ts +0 -334
- package/src/editor/managers/EventManager.ts +0 -260
- package/src/editor/managers/ExportManager.ts +0 -137
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
- package/src/editor/managers/ExtensionManager/extensions.ts +0 -191
- package/src/editor/managers/ExtensionManager/index.ts +0 -697
- package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
- package/src/editor/managers/SelectionManager.ts +0 -120
- package/src/editor/managers/StateManager.ts +0 -251
- package/src/editor/managers/StyleManager.browser.test.ts +0 -122
- package/src/editor/managers/StyleManager.test.ts +0 -98
- package/src/editor/managers/StyleManager.ts +0 -278
- package/src/editor/managers/index.ts +0 -8
- package/src/editor/performance.test.ts +0 -192
- package/src/editor/selectionTypes.ts +0 -14
- package/src/editor/transformPasted.test.ts +0 -295
- package/src/editor/transformPasted.ts +0 -293
- package/src/exporter/ExportImage.ts +0 -50
- package/src/exporter/Exporter.test.ts +0 -186
- package/src/exporter/Exporter.ts +0 -155
- package/src/exporter/index.ts +0 -3
- package/src/exporter/mapping.ts +0 -79
- package/src/extensions/BlockChange/BlockChange.ts +0 -67
- package/src/extensions/DropCursor/DropCursor.ts +0 -263
- package/src/extensions/DropCursor/utils.ts +0 -195
- package/src/extensions/FilePanel/FilePanel.ts +0 -41
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -151
- package/src/extensions/History/History.ts +0 -11
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
- package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
- package/src/extensions/LinkToolbar/protocols.ts +0 -13
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -75
- package/src/extensions/Placeholder/Placeholder.ts +0 -149
- package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -120
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -197
- package/src/extensions/README.md +0 -3
- package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
- package/src/extensions/SideMenu/SideMenu.ts +0 -833
- package/src/extensions/SideMenu/dragging.ts +0 -213
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -192
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
- package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -427
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -399
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -120
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
- package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
- package/src/extensions/TableHandles/TableHandles.ts +0 -1265
- package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
- package/src/extensions/Versioning/Versioning.test.ts +0 -435
- package/src/extensions/Versioning/Versioning.ts +0 -628
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -469
- package/src/extensions/Versioning/inMemoryVersioning.ts +0 -273
- package/src/extensions/Versioning/index.ts +0 -2
- package/src/extensions/getDraggableBlockFromElement.ts +0 -19
- package/src/extensions/index.ts +0 -25
- package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
- package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -204
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1002
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -179
- package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
- package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
- package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
- package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
- package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
- package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
- package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
- package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -187
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -336
- package/src/extensions/tiptap-extensions/index.ts +0 -7
- package/src/extensions-shared/UiElementPosition.ts +0 -4
- package/src/i18n/dictionary.ts +0 -17
- package/src/i18n/index.ts +0 -2
- package/src/i18n/locales/ar.ts +0 -411
- package/src/i18n/locales/de.ts +0 -445
- package/src/i18n/locales/en.ts +0 -426
- package/src/i18n/locales/es.ts +0 -424
- package/src/i18n/locales/fa.ts +0 -395
- package/src/i18n/locales/fr.ts +0 -472
- package/src/i18n/locales/he.ts +0 -426
- package/src/i18n/locales/hr.ts +0 -440
- package/src/i18n/locales/index.ts +0 -23
- package/src/i18n/locales/is.ts +0 -440
- package/src/i18n/locales/it.ts +0 -448
- package/src/i18n/locales/ja.ts +0 -466
- package/src/i18n/locales/ko.ts +0 -439
- package/src/i18n/locales/nl.ts +0 -427
- package/src/i18n/locales/no.ts +0 -444
- package/src/i18n/locales/pl.ts +0 -417
- package/src/i18n/locales/pt.ts +0 -419
- package/src/i18n/locales/ru.ts +0 -470
- package/src/i18n/locales/sk.ts +0 -424
- package/src/i18n/locales/uk.ts +0 -450
- package/src/i18n/locales/uz.ts +0 -460
- package/src/i18n/locales/vi.ts +0 -425
- package/src/i18n/locales/zh-tw.ts +0 -467
- package/src/i18n/locales/zh.ts +0 -467
- package/src/index.ts +0 -56
- package/src/locales.ts +0 -1
- package/src/pm-nodes/BlockContainer.ts +0 -91
- package/src/pm-nodes/BlockGroup.ts +0 -57
- package/src/pm-nodes/Doc.ts +0 -11
- package/src/pm-nodes/README.md +0 -141
- package/src/pm-nodes/index.ts +0 -3
- package/src/pm-nodes/suggestionMarks.ts +0 -43
- package/src/schema/README.md +0 -3
- package/src/schema/blocks/createSpec.test.ts +0 -123
- package/src/schema/blocks/createSpec.ts +0 -506
- package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
- package/src/schema/blocks/internal.test.ts +0 -86
- package/src/schema/blocks/internal.ts +0 -255
- package/src/schema/blocks/types.ts +0 -702
- package/src/schema/contentTypePropagation.test.ts +0 -182
- package/src/schema/index.ts +0 -12
- package/src/schema/inlineContent/createSpec.test.ts +0 -161
- package/src/schema/inlineContent/createSpec.ts +0 -409
- package/src/schema/inlineContent/internal.ts +0 -136
- package/src/schema/inlineContent/types.ts +0 -204
- package/src/schema/markGroups.ts +0 -50
- package/src/schema/nodeViewMutations.test.ts +0 -146
- package/src/schema/nodeViewMutations.ts +0 -49
- package/src/schema/propTypes.ts +0 -61
- package/src/schema/schema.test.ts +0 -110
- package/src/schema/schema.ts +0 -236
- package/src/schema/styles/createSpec.ts +0 -140
- package/src/schema/styles/internal.ts +0 -155
- package/src/schema/styles/types.ts +0 -57
- package/src/style.css +0 -2
- package/src/user/UserStore.ts +0 -199
- package/src/user/createUserStore.test.ts +0 -126
- package/src/user/index.ts +0 -2
- package/src/user/userColors.ts +0 -72
- package/src/util/EventEmitter.ts +0 -59
- package/src/util/README.md +0 -3
- package/src/util/Store.test.ts +0 -132
- package/src/util/Store.ts +0 -135
- package/src/util/browser.ts +0 -54
- package/src/util/combineByGroup.ts +0 -25
- package/src/util/expandToWords.ts +0 -38
- package/src/util/string.ts +0 -36
- package/src/util/table.ts +0 -110
- package/src/util/topo-sort.test.ts +0 -125
- package/src/util/topo-sort.ts +0 -206
- package/src/util/typescript.ts +0 -17
- package/src/vite-env.d.ts +0 -7
- package/src/y/README.md +0 -5
- package/src/y/comments/RESTYjsThreadStore.ts +0 -138
- package/src/y/comments/YjsThreadStore.test.ts +0 -295
- package/src/y/comments/YjsThreadStore.ts +0 -358
- package/src/y/comments/YjsThreadStoreBase.ts +0 -50
- package/src/y/comments/index.ts +0 -3
- package/src/y/comments/yjsHelpers.ts +0 -125
- package/src/y/extensions/AttributionExtension.test.ts +0 -95
- package/src/y/extensions/AttributionExtension.ts +0 -378
- package/src/y/extensions/DiffVersioningExtension.test.ts +0 -193
- package/src/y/extensions/DiffVersioningExtension.ts +0 -228
- package/src/y/extensions/ForkYDoc.test.ts +0 -253
- package/src/y/extensions/ForkYDoc.ts +0 -108
- package/src/y/extensions/RelativePositionMapping.test.ts +0 -418
- package/src/y/extensions/RelativePositionMapping.ts +0 -49
- package/src/y/extensions/Suggestions.ts +0 -174
- package/src/y/extensions/Versioning.test.ts +0 -408
- package/src/y/extensions/Versioning.ts +0 -115
- package/src/y/extensions/YAttributionMarks.ts +0 -320
- package/src/y/extensions/YCursorPlugin.ts +0 -189
- package/src/y/extensions/YSync.ts +0 -125
- package/src/y/extensions/blockMatchNodes.ts +0 -182
- package/src/y/extensions/index.ts +0 -156
- package/src/y/index.ts +0 -4
- package/src/y/utils.test.ts +0 -1042
- package/src/y/utils.ts +0 -242
- package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
- package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
- package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
- package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
- package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
- package/src/y/versioning/__test__/yhub.test.ts +0 -785
- package/src/y/versioning/index.ts +0 -1
- package/src/y/versioning/yhub.ts +0 -637
- package/src/yjs/README.md +0 -5
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -85
- package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
- package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
- package/src/yjs/comments/YjsThreadStore.ts +0 -345
- package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
- package/src/yjs/comments/index.ts +0 -3
- package/src/yjs/comments/yjsHelpers.ts +0 -127
- package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
- package/src/yjs/extensions/FixUpSchema.ts +0 -88
- package/src/yjs/extensions/ForkYDoc.test.ts +0 -253
- package/src/yjs/extensions/ForkYDoc.ts +0 -159
- package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
- package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
- package/src/yjs/extensions/Versioning.test.ts +0 -561
- package/src/yjs/extensions/Versioning.ts +0 -83
- package/src/yjs/extensions/YCursorPlugin.ts +0 -201
- package/src/yjs/extensions/YSync.ts +0 -16
- package/src/yjs/extensions/YUndo.ts +0 -12
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
- package/src/yjs/extensions/index.ts +0 -89
- package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
- package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
- package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
- package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
- package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
- package/src/yjs/index.ts +0 -3
- package/src/yjs/utils.test.ts +0 -1013
- package/src/yjs/utils.ts +0 -186
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +0 -32
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
- package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
- package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
- package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
- package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
- package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
- package/types/src/api/positionMapping.test.d.ts +0 -1
- package/types/src/blocks/Code/block.test.d.ts +0 -1
- package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
- package/types/src/blocks/ListItem/ListItemKeyboardShortcuts.d.ts +0 -2
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
- package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
- package/types/src/blocks/ToggleWrapper/createToggleWrapper.d.ts +0 -15
- package/types/src/blocks/utils/listItemEnterHandler.d.ts +0 -2
- package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
- package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
- package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
- package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
- package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
- package/types/src/editor/performance.test.d.ts +0 -1
- package/types/src/editor/transformPasted.test.d.ts +0 -1
- package/types/src/exporter/Exporter.test.d.ts +0 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
- package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
- package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
- package/types/src/extensions/Versioning/Versioning.test.d.ts +0 -1
- package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +0 -5
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
- package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
- package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
- package/types/src/schema/blocks/internal.test.d.ts +0 -1
- package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
- package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
- package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
- package/types/src/schema/schema.test.d.ts +0 -1
- package/types/src/user/createUserStore.test.d.ts +0 -1
- package/types/src/util/Store.test.d.ts +0 -1
- package/types/src/util/topo-sort.test.d.ts +0 -1
- package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
- package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
- package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
- package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
- package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
- package/types/src/y/extensions/Versioning.test.d.ts +0 -1
- package/types/src/y/utils.test.d.ts +0 -1
- package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
- package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
- package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
- package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
- package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
- package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
- package/types/src/yjs/utils.test.d.ts +0 -1
|
@@ -0,0 +1,3091 @@
|
|
|
1
|
+
import { Bt as e, C as t, D as n, E as r, Jt as i, L as a, M as o, Pt as s, S as c, St as l, T as u, W as d, X as f, Y as p, Z as m, _ as h, an as g, b as _, d as v, f as y, g as b, h as x, in as ee, l as S, m as C, s as te, sn as ne, v as re, w as ie, x as ae, y as oe } from "./getDefaultSlashMenuItems-DfDOr807.js";
|
|
2
|
+
import { i as se, n as w, r as ce, t as T } from "./BlockNoteExtension-U58cXw1g.js";
|
|
3
|
+
import { n as le } from "./UserStore-BFv6NXA-.js";
|
|
4
|
+
import { DOMSerializer as ue, Fragment as de } from "prosemirror-model";
|
|
5
|
+
import { Mapping as fe, dropPoint as pe } from "prosemirror-transform";
|
|
6
|
+
import { EditorState as me, NodeSelection as he, Plugin as E, PluginKey as D, Selection as O, TextSelection as k } from "prosemirror-state";
|
|
7
|
+
import { DOMParser as ge, Slice as _e } from "@tiptap/pm/model";
|
|
8
|
+
import { findChildrenInRange as ve, posToDOMRect as ye } from "@tiptap/core";
|
|
9
|
+
import { uuidv4 as be } from "lib0/random";
|
|
10
|
+
import { CellSelection as xe, addColumnAfter as Se, addColumnBefore as Ce, addRowAfter as we, addRowBefore as Te, deleteColumn as Ee, deleteRow as De, mergeCells as Oe, splitCell as ke } from "prosemirror-tables";
|
|
11
|
+
import { Plugin as Ae, PluginKey as je, TextSelection as Me } from "@tiptap/pm/state";
|
|
12
|
+
import { Decoration as A, DecorationSet as j } from "prosemirror-view";
|
|
13
|
+
import Ne from "fast-deep-equal";
|
|
14
|
+
import { history as Pe, redo as Fe, undo as Ie } from "@tiptap/pm/history";
|
|
15
|
+
import { createHighlightPlugin as Le } from "prosemirror-highlight";
|
|
16
|
+
import { createParser as Re } from "prosemirror-highlight/shiki";
|
|
17
|
+
// src/api/nodeUtil.ts
|
|
18
|
+
function M(e, t) {
|
|
19
|
+
let n, r;
|
|
20
|
+
if (t.firstChild.descendants((a, o) => n ? !1 : !N(a) || !a.attrs.id || i(a, t) !== e || (n = a, r = o + 1, !1)), n !== void 0 && r !== void 0) return {
|
|
21
|
+
node: n,
|
|
22
|
+
posBeforeNode: r
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function N(e) {
|
|
26
|
+
return e.type.isInGroup("bnBlock");
|
|
27
|
+
}
|
|
28
|
+
// src/extensions/blockDOM.ts
|
|
29
|
+
var P = "[data-node-type][data-id]:not([data-node-type=\"blockOuter\"])";
|
|
30
|
+
function ze(e, t) {
|
|
31
|
+
if (!t.dom.contains(e)) return;
|
|
32
|
+
let n = e.closest(".bn-editor");
|
|
33
|
+
if (n && n !== t.dom) return;
|
|
34
|
+
let r = e.closest(P);
|
|
35
|
+
return r && r !== t.dom && t.dom.contains(r) ? r : void 0;
|
|
36
|
+
}
|
|
37
|
+
function Be(e, t, n) {
|
|
38
|
+
let r = e.nodeDOM(t);
|
|
39
|
+
if (!(r instanceof Element)) return;
|
|
40
|
+
let i = r.matches("[data-node-type][data-id]:not([data-node-type=\"blockOuter\"])") ? r : r.querySelector(P);
|
|
41
|
+
return i?.getAttribute("data-id") === n ? i : void 0;
|
|
42
|
+
}
|
|
43
|
+
function Ve(e, t) {
|
|
44
|
+
let n = ze(e, t);
|
|
45
|
+
if (!n) return;
|
|
46
|
+
let r = n.getAttribute("data-id"), i = n.getAttribute("data-node-type"), a = i === "blockContainer" ? n.querySelector("[data-content-type]")?.getAttribute("data-content-type") : i, o = n.ownerDocument.defaultView?.HTMLElement;
|
|
47
|
+
if (!o || !(n instanceof o) || !r || !a) throw Error("Block root is missing its HTML element, ID, or block type.");
|
|
48
|
+
return {
|
|
49
|
+
node: n,
|
|
50
|
+
id: r,
|
|
51
|
+
type: a
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function He(e, t, n) {
|
|
55
|
+
let r = Ve(e, t);
|
|
56
|
+
for (; r;) {
|
|
57
|
+
if (n(r.type)) return r;
|
|
58
|
+
let e = r.node.parentElement;
|
|
59
|
+
r = e ? Ve(e, t) : void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function Ue(e) {
|
|
63
|
+
let t = e.closest(".bn-editor"), n = [];
|
|
64
|
+
for (let r of e.querySelectorAll(P)) r.parentElement?.closest("[data-node-type][data-id]:not([data-node-type=\"blockOuter\"])") === e && r.closest(".bn-editor") === t && n.push(r);
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
function We(e) {
|
|
68
|
+
let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
|
|
69
|
+
t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
|
|
70
|
+
}
|
|
71
|
+
function Ge(e, t, n, r) {
|
|
72
|
+
let i;
|
|
73
|
+
if (!t) throw Error("blockContent is required");
|
|
74
|
+
if (typeof t == "string") i = x([t], e.pmSchema, r?.blockType);
|
|
75
|
+
else if (Array.isArray(t)) i = x(t, e.pmSchema, r?.blockType);
|
|
76
|
+
else if (t.type === "tableContent") i = b(t, e.pmSchema);
|
|
77
|
+
else throw new l(t.type);
|
|
78
|
+
let a = (r?.document ?? document).createDocumentFragment();
|
|
79
|
+
for (let t of i) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
80
|
+
let i = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
81
|
+
if (i) {
|
|
82
|
+
let o = m(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = i.toExternalHTML ? i.toExternalHTML(o, e) : i.render.call({
|
|
83
|
+
renderType: "dom",
|
|
84
|
+
props: void 0
|
|
85
|
+
}, o, () => {}, e);
|
|
86
|
+
if (s) {
|
|
87
|
+
if (a.appendChild(s.dom), s.contentDOM) {
|
|
88
|
+
let e = n.serializeFragment(t.content, r);
|
|
89
|
+
s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(e);
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} else if (t.type.name === "text") {
|
|
95
|
+
let n = document.createTextNode(t.textContent);
|
|
96
|
+
for (let r of t.marks.toReversed()) if (r.type.name in e.schema.styleSpecs) {
|
|
97
|
+
let t = (e.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? e.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, e);
|
|
98
|
+
t.contentDOM.appendChild(n), n = t.dom;
|
|
99
|
+
} else {
|
|
100
|
+
let e = r.type.spec.toDOM(r, !0), t = ue.renderSpec(document, e);
|
|
101
|
+
t.contentDOM.appendChild(n), n = t.dom;
|
|
102
|
+
}
|
|
103
|
+
a.appendChild(n);
|
|
104
|
+
} else {
|
|
105
|
+
let e = n.serializeFragment(de.from([t]), r);
|
|
106
|
+
a.appendChild(e);
|
|
107
|
+
}
|
|
108
|
+
return a.childNodes.length === 1 && a.firstChild?.nodeType === 1 && We(a.firstChild), a;
|
|
109
|
+
}
|
|
110
|
+
function Ke(e, t, n, r, i) {
|
|
111
|
+
let a = e.toExternalHTML?.call({}, t, n, { nestingLevel: i });
|
|
112
|
+
if (a) return { output: a };
|
|
113
|
+
let o = d(n, t);
|
|
114
|
+
if (r) {
|
|
115
|
+
if (!o) throw Error(`Layout block "${t.type}" drew no frame. This is a bug in BlockNote.`);
|
|
116
|
+
return { output: {
|
|
117
|
+
dom: o.dom,
|
|
118
|
+
childrenDOM: o.slot
|
|
119
|
+
} };
|
|
120
|
+
}
|
|
121
|
+
if (!e.render) throw Error(`Block "${t.type}" has no \`render\`. This is a bug in BlockNote.`);
|
|
122
|
+
return {
|
|
123
|
+
output: e.render.call({}, t, n),
|
|
124
|
+
frame: o
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function qe(e, t, n, r, i, s, c, l) {
|
|
128
|
+
let u = l?.document ?? document, d = t.pmSchema.nodes.blockContainer, f = n.props || {};
|
|
129
|
+
for (let [e, r] of Object.entries(t.schema.blockSchema[n.type].propSchema)) !(e in f) && r.default !== void 0 && (f[e] = r.default);
|
|
130
|
+
let p = d.spec?.toDOM?.(d.create({
|
|
131
|
+
id: n.id,
|
|
132
|
+
...f
|
|
133
|
+
})), m = Array.from(p.dom.attributes), h = t.blockImplementations[n.type].implementation, g = {
|
|
134
|
+
...n,
|
|
135
|
+
props: f,
|
|
136
|
+
children: n.children ?? []
|
|
137
|
+
}, _ = ee(t.pmSchema.nodes[n.type]), { output: v, frame: y } = Ke(h, g, t, _, c), b = u.createDocumentFragment(), x;
|
|
138
|
+
if (o(v.dom) || (x = v.dom), x?.classList.contains("bn-block-content")) {
|
|
139
|
+
let e = [...m, ...Array.from(x.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");
|
|
140
|
+
for (let t of e) x.firstChild.setAttribute(t.name, t.value);
|
|
141
|
+
We(x.firstChild), c > 0 && x.firstChild.setAttribute("data-nesting-level", c.toString()), b.append(...Array.from(x.childNodes));
|
|
142
|
+
} else b.append(v.dom), _ && (x?.removeAttribute("data-node-type"), x?.removeAttribute("data-id"), v.childrenDOM?.removeAttribute(a)), c > 0 && x?.setAttribute("data-nesting-level", c.toString());
|
|
143
|
+
if (v.contentDOM) {
|
|
144
|
+
if (n.content) {
|
|
145
|
+
let e = Ge(t, n.content, r, {
|
|
146
|
+
...l,
|
|
147
|
+
blockType: n.type
|
|
148
|
+
});
|
|
149
|
+
v.contentDOM.appendChild(e);
|
|
150
|
+
}
|
|
151
|
+
let e = t.pmSchema.nodes[n.type];
|
|
152
|
+
e?.inlineContent && !e.spec.code && v.contentDOM.childNodes.length === 0 && v.contentDOM.appendChild(u.createTextNode(""));
|
|
153
|
+
}
|
|
154
|
+
let S = v.childrenDOM;
|
|
155
|
+
y && (y.slot.append(b), b.append(y.dom), S = y.slot);
|
|
156
|
+
let C;
|
|
157
|
+
if (i.has(n.type) ? C = "OL" : s.has(n.type) && (C = "UL"), C) {
|
|
158
|
+
if (e.lastChild?.nodeName !== C) {
|
|
159
|
+
let t = u.createElement(C);
|
|
160
|
+
C === "OL" && "start" in f && f.start && f?.start !== 1 && t.setAttribute("start", String(f.start)), e.append(t);
|
|
161
|
+
}
|
|
162
|
+
e.lastChild.appendChild(b);
|
|
163
|
+
} else e.append(b);
|
|
164
|
+
if (n.children && n.children.length > 0) {
|
|
165
|
+
let a = u.createDocumentFragment();
|
|
166
|
+
if (Je(a, t, n.children, r, i, s, c + 1, l), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; a.firstChild?.nodeName === "UL" || a.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(a.firstChild);
|
|
167
|
+
S ? S.append(a) : t.pmSchema.nodes[n.type].isInGroup("blockContent") || !v.contentDOM ? e.append(a) : v.contentDOM.append(a);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
var Je = (e, t, n, r, i, a, o = 0, s) => {
|
|
171
|
+
for (let c of n) qe(e, t, c, r, i, a, o, s);
|
|
172
|
+
}, Ye = (e, t, n, r, i, a) => {
|
|
173
|
+
let o = (a?.document ?? document).createDocumentFragment();
|
|
174
|
+
return Je(o, e, t, n, r, i, 0, a), o;
|
|
175
|
+
}, Xe = (e, t) => {
|
|
176
|
+
let n = ue.fromSchema(e);
|
|
177
|
+
return {
|
|
178
|
+
exportBlocks: (e, r) => {
|
|
179
|
+
let i = Ye(t, e, n, /* @__PURE__ */ new Set(["numberedListItem"]), /* @__PURE__ */ new Set([
|
|
180
|
+
"bulletListItem",
|
|
181
|
+
"checkListItem",
|
|
182
|
+
"toggleListItem"
|
|
183
|
+
]), r), a = document.createElement("div");
|
|
184
|
+
return a.append(i), a.innerHTML;
|
|
185
|
+
},
|
|
186
|
+
exportInlineContent: (e, r) => {
|
|
187
|
+
let i = Ge(t, e, n, r), a = document.createElement("div");
|
|
188
|
+
return a.append(i.cloneNode(!0)), a.innerHTML;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
// src/api/getChangedRangeWithAttrs.ts
|
|
193
|
+
function Ze(e) {
|
|
194
|
+
let { mapping: t, steps: n } = e, r = Infinity, i = -Infinity;
|
|
195
|
+
for (let e = 0; e < t.maps.length; e++) {
|
|
196
|
+
let a = t.maps[e];
|
|
197
|
+
e && (r = a.map(r, 1), i = a.map(i, -1));
|
|
198
|
+
let o = !1;
|
|
199
|
+
if (a.forEach((e, t, n, a) => {
|
|
200
|
+
o = !0, r = Math.min(r, n), i = Math.max(i, a);
|
|
201
|
+
}), !o) {
|
|
202
|
+
let t = n[e];
|
|
203
|
+
typeof t.pos == "number" ? (r = Math.min(r, t.pos), i = Math.max(i, t.pos + 1)) : typeof t.from == "number" && typeof t.to == "number" && (r = Math.min(r, t.from), i = Math.max(i, t.to));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return r === Infinity ? null : {
|
|
207
|
+
from: r,
|
|
208
|
+
to: i
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// src/api/getBlocksChangedByTransaction.ts
|
|
212
|
+
function Qe(e, t) {
|
|
213
|
+
if (t === 0) return;
|
|
214
|
+
let n = e.resolve(t);
|
|
215
|
+
for (let t = n.depth; t > 0; t--) {
|
|
216
|
+
let r = n.node(t);
|
|
217
|
+
if (N(r)) return i(r, e);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function $e(e) {
|
|
221
|
+
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" };
|
|
222
|
+
}
|
|
223
|
+
function et(e, t) {
|
|
224
|
+
let n = {}, r = {}, a = Math.max(0, Math.min(t.from, e.content.size)), o = Math.max(a, Math.min(t.to, e.content.size));
|
|
225
|
+
return e.nodesBetween(a, o, (t, a) => {
|
|
226
|
+
if (!N(t)) return !0;
|
|
227
|
+
let o = Qe(e, a), s = o ?? "__root__";
|
|
228
|
+
r[s] || (r[s] = []);
|
|
229
|
+
let c = f(t, e), l = i(t, e);
|
|
230
|
+
return n[l] = {
|
|
231
|
+
block: c,
|
|
232
|
+
parentId: o
|
|
233
|
+
}, r[s].push(l), !0;
|
|
234
|
+
}), {
|
|
235
|
+
byId: n,
|
|
236
|
+
childrenByParent: r
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function tt(e, t) {
|
|
240
|
+
let n = /* @__PURE__ */ new Set();
|
|
241
|
+
if (!e || !t) return n;
|
|
242
|
+
let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
|
|
243
|
+
if (a.length <= 1 || i.length <= 1) return n;
|
|
244
|
+
let o = {};
|
|
245
|
+
for (let e = 0; e < a.length; e++) o[a[e]] = e;
|
|
246
|
+
let s = i.map((e) => o[e]), c = s.length, l = [], u = [], d = Array(c).fill(-1), f = (e, t) => {
|
|
247
|
+
let n = 0, r = e.length;
|
|
248
|
+
for (; n < r;) {
|
|
249
|
+
let i = n + r >>> 1;
|
|
250
|
+
e[i] < t ? n = i + 1 : r = i;
|
|
251
|
+
}
|
|
252
|
+
return n;
|
|
253
|
+
};
|
|
254
|
+
for (let e = 0; e < c; e++) {
|
|
255
|
+
let t = s[e], n = f(l, t);
|
|
256
|
+
n > 0 && (d[e] = u[n - 1]), n === l.length ? (l.push(t), u.push(e)) : (l[n] = t, u[n] = e);
|
|
257
|
+
}
|
|
258
|
+
let p = /* @__PURE__ */ new Set(), m = u.at(-1) ?? -1;
|
|
259
|
+
for (; m !== -1;) p.add(m), m = d[m];
|
|
260
|
+
for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
|
|
261
|
+
return n;
|
|
262
|
+
}
|
|
263
|
+
function nt(e, t = []) {
|
|
264
|
+
let n = $e(e), r = s(e.before, [e, ...t]), i = Ze(r);
|
|
265
|
+
if (!i) return [];
|
|
266
|
+
let a = r.mapping.invert(), o = {
|
|
267
|
+
from: a.map(i.from, -1),
|
|
268
|
+
to: a.map(i.to, 1)
|
|
269
|
+
}, c = et(r.before, o), l = et(r.doc, i), u = [], d = /* @__PURE__ */ new Set();
|
|
270
|
+
Object.keys(l.byId).filter((e) => !(e in c.byId)).forEach((e) => {
|
|
271
|
+
u.push({
|
|
272
|
+
type: "insert",
|
|
273
|
+
block: l.byId[e].block,
|
|
274
|
+
source: n,
|
|
275
|
+
prevBlock: void 0
|
|
276
|
+
}), d.add(e);
|
|
277
|
+
}), Object.keys(c.byId).filter((e) => !(e in l.byId)).forEach((e) => {
|
|
278
|
+
u.push({
|
|
279
|
+
type: "delete",
|
|
280
|
+
block: c.byId[e].block,
|
|
281
|
+
source: n,
|
|
282
|
+
prevBlock: void 0
|
|
283
|
+
}), d.add(e);
|
|
284
|
+
}), Object.keys(l.byId).filter((e) => e in c.byId).forEach((e) => {
|
|
285
|
+
let t = c.byId[e], r = l.byId[e];
|
|
286
|
+
t.parentId === r.parentId ? Ne({
|
|
287
|
+
...t.block,
|
|
288
|
+
children: void 0
|
|
289
|
+
}, {
|
|
290
|
+
...r.block,
|
|
291
|
+
children: void 0
|
|
292
|
+
}) || (u.push({
|
|
293
|
+
type: "update",
|
|
294
|
+
block: r.block,
|
|
295
|
+
prevBlock: t.block,
|
|
296
|
+
source: n
|
|
297
|
+
}), d.add(e)) : (u.push({
|
|
298
|
+
type: "move",
|
|
299
|
+
block: r.block,
|
|
300
|
+
prevBlock: t.block,
|
|
301
|
+
source: n,
|
|
302
|
+
prevParent: t.parentId ? c.byId[t.parentId]?.block : void 0,
|
|
303
|
+
currentParent: r.parentId ? l.byId[r.parentId]?.block : void 0
|
|
304
|
+
}), d.add(e));
|
|
305
|
+
});
|
|
306
|
+
let f = c.childrenByParent, p = l.childrenByParent, m = /* @__PURE__ */ new Set([...Object.keys(f), ...Object.keys(p)]), h = /* @__PURE__ */ new Set();
|
|
307
|
+
return m.forEach((e) => {
|
|
308
|
+
let t = tt(f[e], p[e]);
|
|
309
|
+
t.size !== 0 && t.forEach((t) => {
|
|
310
|
+
let r = c.byId[t], i = l.byId[t];
|
|
311
|
+
r && i && r.parentId === i.parentId && (d.has(t) || (r.parentId ?? "__root__") === e && (h.has(t) || (h.add(t), u.push({
|
|
312
|
+
type: "move",
|
|
313
|
+
block: i.block,
|
|
314
|
+
prevBlock: r.block,
|
|
315
|
+
source: n,
|
|
316
|
+
prevParent: r.parentId ? c.byId[r.parentId]?.block : void 0,
|
|
317
|
+
currentParent: i.parentId ? l.byId[i.parentId]?.block : void 0
|
|
318
|
+
}), d.add(t))));
|
|
319
|
+
});
|
|
320
|
+
}), u;
|
|
321
|
+
}
|
|
322
|
+
// src/extensions/BlockChange/BlockChange.ts
|
|
323
|
+
var rt = T(() => {
|
|
324
|
+
let e = [];
|
|
325
|
+
return {
|
|
326
|
+
key: "blockChange",
|
|
327
|
+
prosemirrorPlugins: [new E({
|
|
328
|
+
key: new D("blockChange"),
|
|
329
|
+
filterTransaction: (t) => {
|
|
330
|
+
let n;
|
|
331
|
+
return e.reduce((e, r) => e === !1 ? e : r({
|
|
332
|
+
getChanges() {
|
|
333
|
+
return n || (n = nt(t), n);
|
|
334
|
+
},
|
|
335
|
+
tr: t
|
|
336
|
+
}) !== !1, !0);
|
|
337
|
+
}
|
|
338
|
+
})],
|
|
339
|
+
subscribe(t) {
|
|
340
|
+
return e.push(t), () => {
|
|
341
|
+
e.splice(e.indexOf(t), 1);
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
});
|
|
346
|
+
// src/extensions/DropCursor/utils.ts
|
|
347
|
+
function it(e, t) {
|
|
348
|
+
return !e || !t ? !1 : !!e.closest(`.${t}`);
|
|
349
|
+
}
|
|
350
|
+
function at(e, t, n, r, i) {
|
|
351
|
+
let a = e.state.doc.resolve(t.pos);
|
|
352
|
+
if (a.parent.inlineContent || t.orientation === "inline") return null;
|
|
353
|
+
let o = a.nodeBefore, s = a.nodeAfter;
|
|
354
|
+
if (!o && !s) return null;
|
|
355
|
+
let c = t.orientation === "block-vertical-left" || t.orientation === "block-vertical-right", l = c ? t.pos : t.pos - (o ? o.nodeSize : 0), u = e.nodeDOM(l);
|
|
356
|
+
if (!u) return null;
|
|
357
|
+
let d = u.getBoundingClientRect();
|
|
358
|
+
if (c) {
|
|
359
|
+
let e = n / 2 * r, i = t.orientation === "block-vertical-left" ? d.left : d.right;
|
|
360
|
+
return {
|
|
361
|
+
left: i - e,
|
|
362
|
+
right: i + e,
|
|
363
|
+
top: d.top,
|
|
364
|
+
bottom: d.bottom
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
let f = o ? d.bottom : d.top;
|
|
368
|
+
o && s && (f = (f + e.nodeDOM(t.pos).getBoundingClientRect().top) / 2);
|
|
369
|
+
let p = n / 2 * i;
|
|
370
|
+
return {
|
|
371
|
+
left: d.left,
|
|
372
|
+
right: d.right,
|
|
373
|
+
top: f - p,
|
|
374
|
+
bottom: f + p
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function ot(e, t, n, r) {
|
|
378
|
+
let i = e.coordsAtPos(t.pos), a = n / 2 * r;
|
|
379
|
+
return {
|
|
380
|
+
left: i.left - a,
|
|
381
|
+
right: i.left + a,
|
|
382
|
+
top: i.top,
|
|
383
|
+
bottom: i.bottom
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function st(e, t) {
|
|
387
|
+
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");
|
|
388
|
+
}
|
|
389
|
+
function ct(e) {
|
|
390
|
+
if (!e || e === document.body && getComputedStyle(e).position === "static") return {
|
|
391
|
+
parentLeft: -window.pageXOffset,
|
|
392
|
+
parentTop: -window.pageYOffset
|
|
393
|
+
};
|
|
394
|
+
let t = e.getBoundingClientRect(), n = t.width / e.offsetWidth, r = t.height / e.offsetHeight;
|
|
395
|
+
return {
|
|
396
|
+
parentLeft: t.left - e.scrollLeft * n,
|
|
397
|
+
parentTop: t.top - e.scrollTop * r
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
// src/api/nodeConversions/fragmentToBlocks.ts
|
|
401
|
+
function F(e) {
|
|
402
|
+
let t = [];
|
|
403
|
+
function n(e, r) {
|
|
404
|
+
let i = e.type.spec.blockConfig?.children, a = e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup", o = ee(e.type) && (!i || g(e.type) || e.childCount < ne(i));
|
|
405
|
+
a || o || !e.type.isInGroup("bnBlock") ? e.forEach((e) => n(e, o ? r : e)) : t.push(f(e, r));
|
|
406
|
+
}
|
|
407
|
+
return e.forEach((e) => n(e, e)), t;
|
|
408
|
+
}
|
|
409
|
+
// src/extensions/DropCursor/dropIntoChildren.ts
|
|
410
|
+
function lt(t, n, r) {
|
|
411
|
+
let i = n.dragging?.slice;
|
|
412
|
+
if (!i || i.openStart > 0) return;
|
|
413
|
+
let a = F(i.content), o = n.posAtCoords(r);
|
|
414
|
+
if (a.length === 0 || !o || o.inside < 0) return;
|
|
415
|
+
let s = n.state.doc.resolve(o.inside + 1), c = s.depth;
|
|
416
|
+
for (; c > 0 && !s.node(c).type.isInGroup("bnBlock");) {
|
|
417
|
+
if (s.node(c).type.name === "blockGroup") return;
|
|
418
|
+
c--;
|
|
419
|
+
}
|
|
420
|
+
if (c === 0) return;
|
|
421
|
+
let l = e(s.node(c), s.before(c));
|
|
422
|
+
if (!l.hasContent || !t.schema.blockSpecs[l.blockNoteType]?.implementation.meta.dropsIntoChildren?.(f(l.block.node, n.state.doc))) return;
|
|
423
|
+
let u = l.block.node.attrs.id, d = (e) => e.id === u || e.children.some(d);
|
|
424
|
+
if (!a.some(d)) return {
|
|
425
|
+
blockInfo: l,
|
|
426
|
+
draggedBlocks: a,
|
|
427
|
+
pos: l.children ? l.children.childrenStart : l.block.afterPos - 1
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
// src/extensions/DropCursor/DropCursor.ts
|
|
431
|
+
var ut = "bn-drag-exclude", I = new D("dropInto"), dt = T(({ editor: e, options: t }) => {
|
|
432
|
+
let n = null, r = null, i = -1, a = null, o = !1, s, c = {
|
|
433
|
+
width: t.dropCursor?.width ?? 5,
|
|
434
|
+
color: t.dropCursor?.color ?? "#ddeeff",
|
|
435
|
+
exclude: t.dropCursor?.exclude ?? "bn-drag-exclude",
|
|
436
|
+
hooks: t.dropCursor?.hooks
|
|
437
|
+
}, l = (t) => {
|
|
438
|
+
let n = e.prosemirrorView, r = I.getState(n.state);
|
|
439
|
+
(r?.blockId !== t?.blockId || r?.pos !== t?.pos) && n.dispatch(n.state.tr.setMeta(I, { into: t }));
|
|
440
|
+
}, u = (e) => {
|
|
441
|
+
(e?.pos !== n?.pos || e?.orientation !== n?.orientation) && (n = e, e == null ? (l(void 0), r && r.parentNode && r.parentNode.removeChild(r), r = null) : d());
|
|
442
|
+
}, d = () => {
|
|
443
|
+
if (!n) return;
|
|
444
|
+
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), o = a.width / i.offsetWidth, s = a.height / i.offsetHeight, l = at(t, n, c.width, o, s) ?? ot(t, n, c.width, o), u = t.dom.offsetParent;
|
|
445
|
+
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", c.color && (r.style.backgroundColor = c.color)), st(r, n.orientation);
|
|
446
|
+
let { parentLeft: d, parentTop: f } = ct(u);
|
|
447
|
+
r.style.left = (l.left - d) / o + "px", r.style.top = (l.top - f) / s + "px", r.style.width = (l.right - l.left) / o + "px", r.style.height = (l.bottom - l.top) / s + "px";
|
|
448
|
+
}, f = (e) => {
|
|
449
|
+
clearTimeout(i), i = window.setTimeout(() => u(null), e);
|
|
450
|
+
}, p = (e) => {
|
|
451
|
+
let t = e;
|
|
452
|
+
a = t.target instanceof Element ? t.target : null, o = !1, clearTimeout(s);
|
|
453
|
+
}, m = (t) => {
|
|
454
|
+
let n = t;
|
|
455
|
+
if (a && it(a, c.exclude) || n.target instanceof Element && it(n.target, c.exclude)) return;
|
|
456
|
+
let r = e.prosemirrorView;
|
|
457
|
+
if (!r.editable) return;
|
|
458
|
+
let i = r.posAtCoords({
|
|
459
|
+
left: n.clientX,
|
|
460
|
+
top: n.clientY
|
|
461
|
+
}), o = i && i.inside >= 0 && r.state.doc.nodeAt(i.inside), s = o && o.type.spec.disableDropCursor, d = typeof s == "function" ? s(r, i, n) : s;
|
|
462
|
+
if (i && !d) {
|
|
463
|
+
let t = i.pos;
|
|
464
|
+
if (r.dragging && r.dragging.slice) {
|
|
465
|
+
let e = pe(r.state.doc, t, r.dragging.slice);
|
|
466
|
+
e != null && (t = e);
|
|
467
|
+
}
|
|
468
|
+
let a = !r.state.doc.resolve(t).parent.inlineContent, o = lt(e, r, {
|
|
469
|
+
left: n.clientX,
|
|
470
|
+
top: n.clientY
|
|
471
|
+
}), s = o ? {
|
|
472
|
+
pos: o.pos,
|
|
473
|
+
orientation: "block-horizontal"
|
|
474
|
+
} : {
|
|
475
|
+
pos: t,
|
|
476
|
+
orientation: a ? "block-horizontal" : "inline"
|
|
477
|
+
}, d = s;
|
|
478
|
+
if (c.hooks?.computeDropPosition) {
|
|
479
|
+
let t = c.hooks.computeDropPosition({
|
|
480
|
+
editor: e,
|
|
481
|
+
event: n,
|
|
482
|
+
view: r,
|
|
483
|
+
defaultPosition: s
|
|
484
|
+
});
|
|
485
|
+
if (t === null) {
|
|
486
|
+
u(null);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
d = t;
|
|
490
|
+
}
|
|
491
|
+
if (u(d), o && d.pos === o.pos && d.orientation === "block-horizontal") {
|
|
492
|
+
let { block: e } = o.blockInfo;
|
|
493
|
+
l({
|
|
494
|
+
blockId: e.node.attrs.id,
|
|
495
|
+
draggedBlocks: o.draggedBlocks,
|
|
496
|
+
pos: e.beforePos
|
|
497
|
+
});
|
|
498
|
+
} else l(void 0);
|
|
499
|
+
f(5e3);
|
|
500
|
+
}
|
|
501
|
+
}, h = (t) => {
|
|
502
|
+
let n = t;
|
|
503
|
+
n.relatedTarget instanceof Node && e.prosemirrorView.dom.contains(n.relatedTarget) || u(null);
|
|
504
|
+
}, g = (t) => {
|
|
505
|
+
f(20), o = e.prosemirrorView.editable && (t.dataTransfer?.types.includes("blocknote/html") ?? !1), clearTimeout(s), o && (s = setTimeout(v, 0));
|
|
506
|
+
}, _ = () => {
|
|
507
|
+
f(20), a = null;
|
|
508
|
+
};
|
|
509
|
+
function v() {
|
|
510
|
+
if (clearTimeout(s), !o) return;
|
|
511
|
+
o = !1;
|
|
512
|
+
let t = e.prosemirrorView;
|
|
513
|
+
t.dom.blur(), t.dispatch(t.state.tr.setSelection(O.near(t.state.selection.$to, -1))), t.focus();
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
key: "dropCursor",
|
|
517
|
+
prosemirrorPlugins: [new E({
|
|
518
|
+
key: I,
|
|
519
|
+
state: {
|
|
520
|
+
init: () => void 0,
|
|
521
|
+
apply(e, t) {
|
|
522
|
+
let n = e.getMeta(I);
|
|
523
|
+
if (n) return n.into;
|
|
524
|
+
if (!t) return;
|
|
525
|
+
let { pos: r, deletedAfter: i } = e.mapping.mapResult(t.pos, 1);
|
|
526
|
+
return i ? void 0 : {
|
|
527
|
+
...t,
|
|
528
|
+
pos: r
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
props: {
|
|
533
|
+
decorations(e) {
|
|
534
|
+
let t = I.getState(e), n = t && e.doc.nodeAt(t.pos);
|
|
535
|
+
return !t || !n ? j.empty : j.create(e.doc, [A.node(t.pos, t.pos + n.nodeSize, { "data-drop-target": "true" })]);
|
|
536
|
+
},
|
|
537
|
+
handleDrop(t, n, r, i) {
|
|
538
|
+
let a = I.getState(t.state);
|
|
539
|
+
if (l(void 0), !a || !e.getBlock(a.blockId)) return !1;
|
|
540
|
+
let { blockId: o, draggedBlocks: s } = a;
|
|
541
|
+
return e.transact(() => {
|
|
542
|
+
i && e.removeBlocks(s.filter((t) => e.getBlock(t.id)));
|
|
543
|
+
let t = e.getBlock(o);
|
|
544
|
+
if (!t) throw Error("The drop target was removed with the dragged blocks");
|
|
545
|
+
t.children.length > 0 ? e.insertBlocks(s, t.children[0], "before") : e.updateBlock(t, { children: s }), e.setTextCursorPosition(s.at(-1), "end");
|
|
546
|
+
}), !0;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
})],
|
|
550
|
+
mount({ signal: e, dom: t, root: n }) {
|
|
551
|
+
n.addEventListener("dragstart", p, {
|
|
552
|
+
capture: !0,
|
|
553
|
+
signal: e
|
|
554
|
+
}), n.addEventListener("dragend", v, {
|
|
555
|
+
capture: !0,
|
|
556
|
+
signal: e
|
|
557
|
+
}), t.addEventListener("dragover", m, { signal: e }), t.addEventListener("dragleave", h, { signal: e }), t.addEventListener("drop", g, { signal: e }), t.addEventListener("dragend", _, { signal: e }), e.addEventListener("abort", () => {
|
|
558
|
+
clearTimeout(i), clearTimeout(s), u(null);
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
}), ft = T(() => ({
|
|
563
|
+
key: "history",
|
|
564
|
+
prosemirrorPlugins: [Pe()],
|
|
565
|
+
undoCommand: Ie,
|
|
566
|
+
redoCommand: Fe
|
|
567
|
+
})), pt = new D("inline-content-boundary-edit");
|
|
568
|
+
function mt(e, t, n) {
|
|
569
|
+
if (!e.empty) return e.from <= n.from && e.to >= n.to;
|
|
570
|
+
let r = n.to - n.from === 1;
|
|
571
|
+
return t === "Backspace" ? r && e.from === n.to : r && e.from === n.from;
|
|
572
|
+
}
|
|
573
|
+
var ht = T(() => ({
|
|
574
|
+
key: "inlineContentBoundaryEdit",
|
|
575
|
+
prosemirrorPlugins: [new E({
|
|
576
|
+
key: pt,
|
|
577
|
+
props: { handleKeyDown: (e, t) => {
|
|
578
|
+
if (!e.editable) return !1;
|
|
579
|
+
let n = t.key.length === 1 && !t.ctrlKey && !t.metaKey;
|
|
580
|
+
if (!n && t.key !== "Backspace" && t.key !== "Delete") return !1;
|
|
581
|
+
let { selection: r } = e.state, i = r.$from.node();
|
|
582
|
+
if (!i.type.spec.inline) return !1;
|
|
583
|
+
let a = r.$from.before(), o = a + 1, s = a + 1 + i.content.size;
|
|
584
|
+
if (n && i.content.size === 0) {
|
|
585
|
+
let n = e.state.tr.insert(o, e.state.schema.text(t.key));
|
|
586
|
+
return n.setSelection(k.create(n.doc, o + t.key.length)), e.dispatch(n), !0;
|
|
587
|
+
}
|
|
588
|
+
if (i.content.size > 0 && mt(r, t.key, {
|
|
589
|
+
from: o,
|
|
590
|
+
to: s
|
|
591
|
+
})) {
|
|
592
|
+
let t = e.state.tr.delete(o, s);
|
|
593
|
+
return t.setSelection(k.create(t.doc, o)), e.dispatch(t), !0;
|
|
594
|
+
}
|
|
595
|
+
return !1;
|
|
596
|
+
} }
|
|
597
|
+
})]
|
|
598
|
+
})), gt = T(({ editor: e }) => {
|
|
599
|
+
function t(t) {
|
|
600
|
+
let n = e.prosemirrorView.nodeDOM(t);
|
|
601
|
+
for (; n && n.parentElement;) {
|
|
602
|
+
if (n.nodeName === "A") return n;
|
|
603
|
+
n = n.parentElement;
|
|
604
|
+
}
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
function n(t) {
|
|
608
|
+
let n = e.getLinkMarkAtPos(t);
|
|
609
|
+
if (n) return {
|
|
610
|
+
range: {
|
|
611
|
+
from: n.from,
|
|
612
|
+
to: n.to
|
|
613
|
+
},
|
|
614
|
+
mark: { attrs: { href: n.href } },
|
|
615
|
+
get text() {
|
|
616
|
+
return n.text;
|
|
617
|
+
},
|
|
618
|
+
get position() {
|
|
619
|
+
return ye(e.prosemirrorView, n.from, n.to).toJSON();
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
function r() {
|
|
624
|
+
return e.transact((e) => {
|
|
625
|
+
if (e.selection.empty) return n(e.selection.anchor);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
key: "linkToolbar",
|
|
630
|
+
getLinkAtSelection: r,
|
|
631
|
+
getLinkElementAtPos: t,
|
|
632
|
+
getMarkAtPos(e, t) {
|
|
633
|
+
return n(e);
|
|
634
|
+
},
|
|
635
|
+
getLinkAtElement(t) {
|
|
636
|
+
return e.transact(() => n(e.prosemirrorView.posAtDOM(t, 0) + 1));
|
|
637
|
+
},
|
|
638
|
+
editLink(t, n, r = e.transact((e) => e.selection.anchor)) {
|
|
639
|
+
e.editLink(t, n, r);
|
|
640
|
+
},
|
|
641
|
+
deleteLink(t = e.transact((e) => e.selection.anchor)) {
|
|
642
|
+
e.deleteLink(t);
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}), _t = [
|
|
646
|
+
"http",
|
|
647
|
+
"https",
|
|
648
|
+
"ftp",
|
|
649
|
+
"ftps",
|
|
650
|
+
"mailto",
|
|
651
|
+
"tel",
|
|
652
|
+
"callto",
|
|
653
|
+
"sms",
|
|
654
|
+
"cid",
|
|
655
|
+
"xmpp"
|
|
656
|
+
], vt = "https", yt = new D("bn-read-only"), L = T(({ editor: e, options: t }) => {
|
|
657
|
+
let n = w({
|
|
658
|
+
isEditable: t?.editable ?? !0,
|
|
659
|
+
enabledSet: /* @__PURE__ */ new Set()
|
|
660
|
+
}, { onUpdate(t, n) {
|
|
661
|
+
(t.isEditable && t.enabledSet.size === 0) !== (n.isEditable && n.enabledSet.size === 0) && (e.headless || e.transact((e) => e.setMeta("editable", !0)));
|
|
662
|
+
} });
|
|
663
|
+
return {
|
|
664
|
+
key: "readOnly",
|
|
665
|
+
store: n,
|
|
666
|
+
prosemirrorPlugins: [new E({
|
|
667
|
+
key: yt,
|
|
668
|
+
props: { editable: () => n.state.isEditable && n.state.enabledSet.size === 0 }
|
|
669
|
+
})],
|
|
670
|
+
setEditable(e) {
|
|
671
|
+
n.state.isEditable !== e && n.setState({
|
|
672
|
+
...n.state,
|
|
673
|
+
isEditable: e
|
|
674
|
+
});
|
|
675
|
+
},
|
|
676
|
+
setReadOnly(e, t) {
|
|
677
|
+
n.setState({
|
|
678
|
+
...n.state,
|
|
679
|
+
enabledSet: e ? /* @__PURE__ */ new Set([...n.state.enabledSet, t]) : new Set([...n.state.enabledSet].filter((e) => e !== t))
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
}), bt = T(({ editor: e }) => {
|
|
684
|
+
let t = w(/* @__PURE__ */ new Set(), { onUpdate(t, n) {
|
|
685
|
+
t.size > 0 != n.size > 0 && e.getExtension(L)?.setReadOnly(t.size > 0, "loading");
|
|
686
|
+
} });
|
|
687
|
+
return {
|
|
688
|
+
key: "loading",
|
|
689
|
+
store: t,
|
|
690
|
+
acquire() {
|
|
691
|
+
let e = Symbol();
|
|
692
|
+
return t.setState(/* @__PURE__ */ new Set([...t.state, e])), function() {
|
|
693
|
+
if (t.state.has(e)) {
|
|
694
|
+
let n = new Set(t.state);
|
|
695
|
+
n.delete(e), t.setState(n);
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
},
|
|
699
|
+
mount({ dom: e, signal: n }) {
|
|
700
|
+
function r() {
|
|
701
|
+
e.classList.toggle("bn-loading", t.state.size > 0);
|
|
702
|
+
}
|
|
703
|
+
r();
|
|
704
|
+
let i = t.subscribe(r);
|
|
705
|
+
n.addEventListener("abort", () => {
|
|
706
|
+
i(), e.classList.remove("bn-loading");
|
|
707
|
+
}, { once: !0 });
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
}), xt = new D("node-selection-keyboard"), St = T(({ editor: e }) => ({
|
|
711
|
+
key: "nodeSelectionKeyboard",
|
|
712
|
+
prosemirrorPlugins: [new E({
|
|
713
|
+
key: xt,
|
|
714
|
+
props: { handleKeyDown: (t, n) => {
|
|
715
|
+
let { selection: r } = t.state;
|
|
716
|
+
if (r instanceof he) {
|
|
717
|
+
if (n.ctrlKey || n.metaKey) return !1;
|
|
718
|
+
if (n.key === "ArrowDown" && !n.shiftKey && !n.altKey && !n.isComposing && !r.node.isInline && r.eq(O.atEnd(t.state.doc))) {
|
|
719
|
+
let { block: t } = e.getTextCursorPosition();
|
|
720
|
+
if (e.schema.blockSchema[t.type].content === "none") return e.transact((n) => {
|
|
721
|
+
let [r] = e.insertBlocks([{ type: "paragraph" }], t, "after");
|
|
722
|
+
e.setTextCursorPosition(r, "start"), n.scrollIntoView();
|
|
723
|
+
}), n.preventDefault(), !0;
|
|
724
|
+
}
|
|
725
|
+
if (n.key.length === 1) return n.preventDefault(), !0;
|
|
726
|
+
if (n.key === "Enter" && !n.isComposing && !n.shiftKey && !n.altKey && !n.ctrlKey && !n.metaKey) {
|
|
727
|
+
let e = t.state.tr;
|
|
728
|
+
return t.dispatch(e.insert(t.state.tr.selection.$to.after(), t.state.schema.nodes.paragraph.createChecked()).setSelection(new k(e.doc.resolve(t.state.tr.selection.$to.after() + 1)))), !0;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return !1;
|
|
732
|
+
} }
|
|
733
|
+
})]
|
|
734
|
+
})), Ct = new D("blocknote-placeholder"), wt = T(({ editor: e, options: t }) => {
|
|
735
|
+
let n = t.placeholders, r = `placeholder-selector-${be()}`;
|
|
736
|
+
return {
|
|
737
|
+
key: "placeholder",
|
|
738
|
+
prosemirrorPlugins: [new E({
|
|
739
|
+
key: Ct,
|
|
740
|
+
view: (t) => {
|
|
741
|
+
let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
|
|
742
|
+
a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
|
|
743
|
+
let o = i.sheet, s = (e = "") => `.${r} .bn-block-content${e}:has(.ProseMirror-trailingBreak:only-child):after`;
|
|
744
|
+
try {
|
|
745
|
+
let { default: e, emptyDocument: t, ...r } = n || {};
|
|
746
|
+
for (let [e, t] of Object.entries(r)) {
|
|
747
|
+
let n = `[data-content-type="${e}"]`;
|
|
748
|
+
o.insertRule(`${s(n)} { content: ${JSON.stringify(t)}; }`);
|
|
749
|
+
}
|
|
750
|
+
o.insertRule(`${s("[data-is-only-empty-block]")} { content: ${JSON.stringify(t)}; }`), o.insertRule(`${s("[data-is-empty-and-focused]")} { content: ${JSON.stringify(e)}; }`);
|
|
751
|
+
} catch (e) {
|
|
752
|
+
console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)", e);
|
|
753
|
+
}
|
|
754
|
+
return { destroy: () => {
|
|
755
|
+
i.remove();
|
|
756
|
+
} };
|
|
757
|
+
},
|
|
758
|
+
props: {
|
|
759
|
+
attributes: { class: r },
|
|
760
|
+
decorations: (t) => {
|
|
761
|
+
let { doc: n, selection: r } = t;
|
|
762
|
+
if (!e.isEditable || !r.empty || r.$from.parent.type.spec.code) return;
|
|
763
|
+
let i = [];
|
|
764
|
+
t.doc.content.size === 6 && i.push(A.node(2, 4, { "data-is-only-empty-block": "true" }));
|
|
765
|
+
let a = r.$anchor, o = a.parent;
|
|
766
|
+
if (o.content.size === 0) {
|
|
767
|
+
let e = a.before();
|
|
768
|
+
i.push(A.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
|
|
769
|
+
}
|
|
770
|
+
return j.create(n, i);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
})]
|
|
774
|
+
};
|
|
775
|
+
}), Tt = T(({ editor: e }) => {
|
|
776
|
+
let t = new fe(), n = 0;
|
|
777
|
+
function r() {
|
|
778
|
+
t = new fe(), n = 0;
|
|
779
|
+
}
|
|
780
|
+
let i = typeof FinalizationRegistry < "u" ? new FinalizationRegistry(() => {
|
|
781
|
+
n--, n === 0 && r();
|
|
782
|
+
}) : null;
|
|
783
|
+
return e.on("create", () => {
|
|
784
|
+
e._tiptapEditor.on("transaction", ({ transaction: e }) => {
|
|
785
|
+
n !== 0 && t.appendMapping(e.mapping);
|
|
786
|
+
}), e._tiptapEditor.on("destroy", () => {
|
|
787
|
+
r();
|
|
788
|
+
});
|
|
789
|
+
}), {
|
|
790
|
+
key: "positionMapping",
|
|
791
|
+
mapPosition: (e, r = "left") => {
|
|
792
|
+
n++;
|
|
793
|
+
let a = t.maps.length, o = () => t.slice(a).map(e, r === "left" ? -1 : 1);
|
|
794
|
+
return i && i.register(o, void 0), o;
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
}), Et = new D("previous-blocks"), Dt = {
|
|
798
|
+
index: "index",
|
|
799
|
+
level: "level",
|
|
800
|
+
type: "type",
|
|
801
|
+
depth: "depth",
|
|
802
|
+
"depth-change": "depth-change"
|
|
803
|
+
}, Ot = T(() => {
|
|
804
|
+
let e, t = !1;
|
|
805
|
+
return {
|
|
806
|
+
key: "previousBlockType",
|
|
807
|
+
prosemirrorPlugins: [new E({
|
|
808
|
+
key: Et,
|
|
809
|
+
view(n) {
|
|
810
|
+
return t = !0, {
|
|
811
|
+
update: async (t, n) => {
|
|
812
|
+
this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
|
|
813
|
+
t.dispatch(t.state.tr.setMeta(Et, { clearUpdate: !0 }));
|
|
814
|
+
}, 0));
|
|
815
|
+
},
|
|
816
|
+
destroy: () => {
|
|
817
|
+
t = !1, e && clearTimeout(e);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
},
|
|
821
|
+
state: {
|
|
822
|
+
init() {
|
|
823
|
+
return {
|
|
824
|
+
prevTransactionOldBlockAttrs: {},
|
|
825
|
+
currentTransactionOldBlockAttrs: {},
|
|
826
|
+
updatedBlocks: /* @__PURE__ */ new Set()
|
|
827
|
+
};
|
|
828
|
+
},
|
|
829
|
+
apply(e, n, r, a) {
|
|
830
|
+
if (n.currentTransactionOldBlockAttrs = {}, n.updatedBlocks.clear(), !e.docChanged || !t) return n;
|
|
831
|
+
let o = Ze(e);
|
|
832
|
+
if (!o) return n;
|
|
833
|
+
let s = e.mapping.invert(), c = {
|
|
834
|
+
from: s.map(o.from, -1),
|
|
835
|
+
to: s.map(o.to, 1)
|
|
836
|
+
}, l = {}, u = ve(r.doc, c, (e) => e.attrs.id), d = new Map(u.map((e) => [i(e.node, r.doc), e])), f = ve(a.doc, o, (e) => e.attrs.id);
|
|
837
|
+
for (let e of f) {
|
|
838
|
+
let t = i(e.node, a.doc), o = d.get(t), s = o?.node.firstChild, c = e.node.firstChild;
|
|
839
|
+
if (o && s && c) {
|
|
840
|
+
let i = {
|
|
841
|
+
index: c.attrs.index,
|
|
842
|
+
level: c.attrs.level,
|
|
843
|
+
type: c.type.name,
|
|
844
|
+
depth: a.doc.resolve(e.pos).depth
|
|
845
|
+
}, u = {
|
|
846
|
+
index: s.attrs.index,
|
|
847
|
+
level: s.attrs.level,
|
|
848
|
+
type: s.type.name,
|
|
849
|
+
depth: r.doc.resolve(o.pos).depth
|
|
850
|
+
};
|
|
851
|
+
l[t] = u, n.currentTransactionOldBlockAttrs[t] = u, (u.index !== i.index || u.level !== i.level || u.type !== i.type || u.depth !== i.depth) && (u["depth-change"] = u.depth - i.depth, n.updatedBlocks.add(t));
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return n.prevTransactionOldBlockAttrs = l, n;
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
props: { decorations(e) {
|
|
858
|
+
let t = this.getState(e);
|
|
859
|
+
if (t.updatedBlocks.size === 0) return;
|
|
860
|
+
let n = [];
|
|
861
|
+
return e.doc.descendants((r, a) => {
|
|
862
|
+
if (!r.attrs.id) return;
|
|
863
|
+
let o = i(r, e.doc);
|
|
864
|
+
if (!t.updatedBlocks.has(o)) return;
|
|
865
|
+
let s = t.currentTransactionOldBlockAttrs[o], c = {};
|
|
866
|
+
for (let [e, t] of Object.entries(s)) c["data-prev-" + Dt[e]] = t || "none";
|
|
867
|
+
n.push(A.node(a, a + r.nodeSize, { ...c }));
|
|
868
|
+
}), j.create(e.doc, n);
|
|
869
|
+
} }
|
|
870
|
+
})]
|
|
871
|
+
};
|
|
872
|
+
});
|
|
873
|
+
// src/extensions/SideMenu/blockGeometry.ts
|
|
874
|
+
function kt(e, t) {
|
|
875
|
+
let n;
|
|
876
|
+
for (let r = 0; r < e.length; r++) {
|
|
877
|
+
let i = e[r];
|
|
878
|
+
if (!(t.y < i.top || t.y > i.bottom)) {
|
|
879
|
+
if (t.x >= i.left && t.x <= i.right) return r;
|
|
880
|
+
n ??= r;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return n;
|
|
884
|
+
}
|
|
885
|
+
function At(e, t) {
|
|
886
|
+
for (; e.matches(P);) {
|
|
887
|
+
let n = Ue(e), r = kt(n.map((e) => e.getBoundingClientRect()), t);
|
|
888
|
+
if (r === void 0) break;
|
|
889
|
+
e = n[r];
|
|
890
|
+
}
|
|
891
|
+
return e;
|
|
892
|
+
}
|
|
893
|
+
// src/extensions/SideMenu/sideMenuHover.ts
|
|
894
|
+
var jt = 10;
|
|
895
|
+
function R(e, t, n) {
|
|
896
|
+
return Math.min(Math.max(e, t), n);
|
|
897
|
+
}
|
|
898
|
+
function Mt(e, t) {
|
|
899
|
+
for (let n of e.root.elementsFromPoint(t.x, t.y)) {
|
|
900
|
+
let t = ze(n, e);
|
|
901
|
+
if (t) return t;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function Nt(e, t) {
|
|
905
|
+
let n = e.dom.firstElementChild?.getBoundingClientRect();
|
|
906
|
+
if (!n || t.y < n.top || t.y > n.bottom) return;
|
|
907
|
+
let r = Math.min(jt, n.width / 2), i = Mt(e, {
|
|
908
|
+
x: R(t.x, n.left + r, n.right - r),
|
|
909
|
+
y: t.y
|
|
910
|
+
});
|
|
911
|
+
return i ? At(i, t) : void 0;
|
|
912
|
+
}
|
|
913
|
+
function Pt(e, t, n, r, i, a) {
|
|
914
|
+
function o(t) {
|
|
915
|
+
let n = t ? He(t, e, r) : void 0;
|
|
916
|
+
return n ? {
|
|
917
|
+
kind: "block",
|
|
918
|
+
block: n
|
|
919
|
+
} : { kind: "none" };
|
|
920
|
+
}
|
|
921
|
+
if (t && e.dom.contains(t)) {
|
|
922
|
+
if (t.closest(".bn-editor") !== e.dom) return { kind: "none" };
|
|
923
|
+
let r = ze(t, e);
|
|
924
|
+
return o(r ? At(r, n) : Nt(e, n));
|
|
925
|
+
}
|
|
926
|
+
if (t && i(t)) return { kind: "editorUI" };
|
|
927
|
+
let s = e.dom.getBoundingClientRect();
|
|
928
|
+
return n.x >= s.left && n.x <= s.right && n.y >= s.top && n.y <= s.bottom ? { kind: "none" } : n.y >= s.top && n.y <= s.bottom && Math.max(s.left - n.x, n.x - s.right) <= a && !t?.closest(".bn-editor") ? o(Nt(e, n)) : { kind: "none" };
|
|
929
|
+
}
|
|
930
|
+
var Ft = 3;
|
|
931
|
+
function z(e, t, n) {
|
|
932
|
+
return (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x);
|
|
933
|
+
}
|
|
934
|
+
function It(e, t) {
|
|
935
|
+
let n = 0;
|
|
936
|
+
for (let r = 0; r < t.length; r++) {
|
|
937
|
+
let i = Math.sign(z(t[r], t[(r + 1) % t.length], e));
|
|
938
|
+
if (i !== 0) {
|
|
939
|
+
if (n === 0) n = i;
|
|
940
|
+
else if (i !== n) return !1;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return !0;
|
|
944
|
+
}
|
|
945
|
+
function Lt(e, t, n) {
|
|
946
|
+
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i, o = a === 0 ? 0 : R(((e.x - t.x) * r + (e.y - t.y) * i) / a, 0, 1);
|
|
947
|
+
return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
|
|
948
|
+
}
|
|
949
|
+
function B(e, t) {
|
|
950
|
+
return Math.hypot(e.x - R(e.x, t.left, t.right), e.y - R(e.y, t.top, t.bottom));
|
|
951
|
+
}
|
|
952
|
+
function Rt(e) {
|
|
953
|
+
let t = [...e].sort((e, t) => e.x - t.x || e.y - t.y), n = [];
|
|
954
|
+
for (let e of t) {
|
|
955
|
+
for (; n.length >= 2 && z(n[n.length - 2], n[n.length - 1], e) <= 0;) n.pop();
|
|
956
|
+
n.push(e);
|
|
957
|
+
}
|
|
958
|
+
let r = [];
|
|
959
|
+
for (let e of [...t].reverse()) {
|
|
960
|
+
for (; r.length >= 2 && z(r[r.length - 2], r[r.length - 1], e) <= 0;) r.pop();
|
|
961
|
+
r.push(e);
|
|
962
|
+
}
|
|
963
|
+
return n.pop(), r.pop(), n.concat(r);
|
|
964
|
+
}
|
|
965
|
+
function zt(e, t, n) {
|
|
966
|
+
if (B(e, n) >= B(t, n)) return !1;
|
|
967
|
+
let r = Rt([
|
|
968
|
+
t,
|
|
969
|
+
{
|
|
970
|
+
x: n.left,
|
|
971
|
+
y: n.top
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
x: n.right,
|
|
975
|
+
y: n.top
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
x: n.right,
|
|
979
|
+
y: n.bottom
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
x: n.left,
|
|
983
|
+
y: n.bottom
|
|
984
|
+
}
|
|
985
|
+
]);
|
|
986
|
+
return r.length >= 3 && It(e, r) ? !0 : r.some((t, n) => Lt(e, t, r[(n + 1) % r.length]) <= Ft);
|
|
987
|
+
}
|
|
988
|
+
// src/extensions/SideMenu/blockDropHandling.ts
|
|
989
|
+
function V(e) {
|
|
990
|
+
return e.synthetic === !0;
|
|
991
|
+
}
|
|
992
|
+
function Bt(e, t, n) {
|
|
993
|
+
let r = {
|
|
994
|
+
x: t.clientX,
|
|
995
|
+
y: t.clientY
|
|
996
|
+
}, i = t.target instanceof Element ? t.target.closest(".bn-editor") : null, a = i ? [i] : Array.from(e.root.querySelectorAll(".bn-editor")).filter((e) => B(r, e.getBoundingClientRect()) <= n), o = t;
|
|
997
|
+
if (a.length === 0) return null;
|
|
998
|
+
let s = a[0], c = Number.MAX_VALUE;
|
|
999
|
+
for (let e of a) {
|
|
1000
|
+
let t = e.querySelector(".bn-block-group").getBoundingClientRect(), n = o.clientX < t.left ? t.left - o.clientX : o.clientX > t.right ? o.clientX - t.right : 0, r = o.clientY < t.top ? t.top - o.clientY : o.clientY > t.bottom ? o.clientY - t.bottom : 0, i = Math.sqrt(n ** 2 + r ** 2);
|
|
1001
|
+
i < c && (c = i, s = e);
|
|
1002
|
+
}
|
|
1003
|
+
return {
|
|
1004
|
+
element: s,
|
|
1005
|
+
distance: c
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
function Vt(e, t, n, r) {
|
|
1009
|
+
function i(n) {
|
|
1010
|
+
return e.dragging !== null || t() || n.dataTransfer?.types.includes("blocknote/html") || n.target instanceof Node && e.dom.contains(n.target);
|
|
1011
|
+
}
|
|
1012
|
+
function a() {
|
|
1013
|
+
let t = new Event("dragleave", { bubbles: !1 });
|
|
1014
|
+
t.synthetic = !0, e.dom.dispatchEvent(t);
|
|
1015
|
+
}
|
|
1016
|
+
function o(t) {
|
|
1017
|
+
let n = e.dom.firstChild.getBoundingClientRect(), r = Object.assign(new Event(t.type, t), {
|
|
1018
|
+
clientX: Math.min(Math.max(t.clientX, n.left), n.left + n.width),
|
|
1019
|
+
clientY: Math.min(Math.max(t.clientY, n.top), n.top + n.height),
|
|
1020
|
+
dataTransfer: t.dataTransfer,
|
|
1021
|
+
preventDefault: () => t.preventDefault(),
|
|
1022
|
+
synthetic: !0
|
|
1023
|
+
});
|
|
1024
|
+
e.dom.dispatchEvent(r);
|
|
1025
|
+
}
|
|
1026
|
+
function s(r) {
|
|
1027
|
+
if (!i(r)) return;
|
|
1028
|
+
let a = !r.dataTransfer?.types.includes("blocknote/html") && !!e.dragging, o = t(), s = a || o, c = Bt(e, r, n);
|
|
1029
|
+
if (!c) return;
|
|
1030
|
+
let l = c.element === e.dom, u = l && c.distance === 0;
|
|
1031
|
+
if (l || s) return {
|
|
1032
|
+
isDropPoint: l,
|
|
1033
|
+
isDropWithinEditorBounds: u,
|
|
1034
|
+
isDragOrigin: s
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
function c(t) {
|
|
1038
|
+
let n = t.dataTransfer?.getData("blocknote/html");
|
|
1039
|
+
if (!n || e.dragging) return;
|
|
1040
|
+
let r = new (e.dom.ownerDocument.defaultView ?? globalThis.window).DOMParser().parseFromString(n, "text/html").body, { nodes: i } = e.state.schema, a = i[t.dataTransfer.getData("blocknote/parent")] ?? i.blockGroup, o = ge.fromSchema(e.state.schema).parse(r, { topNode: a.create() });
|
|
1041
|
+
e.dragging = {
|
|
1042
|
+
slice: new _e(o.content, 0, 0),
|
|
1043
|
+
move: !0
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function l(e) {
|
|
1047
|
+
if (V(e) || !i(e)) return;
|
|
1048
|
+
let t = s(e);
|
|
1049
|
+
!t || !t.isDropPoint ? a() : t.isDropWithinEditorBounds || o(e);
|
|
1050
|
+
}
|
|
1051
|
+
function u(t) {
|
|
1052
|
+
if (V(t) || !i(t)) return;
|
|
1053
|
+
let n = s(t);
|
|
1054
|
+
if (!n) {
|
|
1055
|
+
a();
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
let { isDropPoint: r, isDropWithinEditorBounds: c, isDragOrigin: l } = n;
|
|
1059
|
+
if (!c && r && o(t), r) {
|
|
1060
|
+
if (e.dragging) return;
|
|
1061
|
+
e.dispatch(e.state.tr.setSelection(Me.create(e.state.tr.doc, e.state.tr.selection.anchor)));
|
|
1062
|
+
} else l && setTimeout(() => e.dispatch(e.state.tr.deleteSelection()), 0);
|
|
1063
|
+
}
|
|
1064
|
+
function d(t) {
|
|
1065
|
+
V(t) || (e.dragging = null);
|
|
1066
|
+
}
|
|
1067
|
+
let f = e.root;
|
|
1068
|
+
f.addEventListener("dragstart", c, { signal: r }), f.addEventListener("dragover", l, { signal: r }), f.addEventListener("drop", u, {
|
|
1069
|
+
signal: r,
|
|
1070
|
+
capture: !0
|
|
1071
|
+
}), f.addEventListener("dragend", d, {
|
|
1072
|
+
signal: r,
|
|
1073
|
+
capture: !0
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
// src/extensions/tiptap-extensions/Link/helpers/tlds.ts
|
|
1077
|
+
var Ht = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
1078
|
+
// src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
1079
|
+
function Ut(e) {
|
|
1080
|
+
let t = [], n = [], r = 0;
|
|
1081
|
+
for (; r < e.length;) {
|
|
1082
|
+
let i = 0;
|
|
1083
|
+
for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
|
|
1084
|
+
if (i > 0) {
|
|
1085
|
+
t.push(n.join(""));
|
|
1086
|
+
let a = parseInt(e.substring(r, r + i), 10);
|
|
1087
|
+
for (; a-- > 0;) n.pop();
|
|
1088
|
+
r += i;
|
|
1089
|
+
} else n.push(e[r]), r++;
|
|
1090
|
+
}
|
|
1091
|
+
return t;
|
|
1092
|
+
}
|
|
1093
|
+
var Wt = new Set(Ut(Ht)), Gt = /* @__PURE__ */ new Set(["localhost"]), Kt = /[.,;:!?"']+$/, qt = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Jt = /mailto:[^\s]+/g, Yt = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Xt = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1094
|
+
function Zt(e) {
|
|
1095
|
+
let t = e, n = !0;
|
|
1096
|
+
for (; n;) {
|
|
1097
|
+
n = !1;
|
|
1098
|
+
let e = t;
|
|
1099
|
+
t = t.replace(Kt, ""), t !== e && (n = !0);
|
|
1100
|
+
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1101
|
+
let i = Qt(t, e);
|
|
1102
|
+
if (Qt(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1103
|
+
else break;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return t;
|
|
1107
|
+
}
|
|
1108
|
+
function Qt(e, t) {
|
|
1109
|
+
let n = 0;
|
|
1110
|
+
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1111
|
+
return n;
|
|
1112
|
+
}
|
|
1113
|
+
function $t(e) {
|
|
1114
|
+
return (e.split(".").at(-1) ?? "").toLowerCase();
|
|
1115
|
+
}
|
|
1116
|
+
function en(e) {
|
|
1117
|
+
let t = $t(e);
|
|
1118
|
+
return Wt.has(t);
|
|
1119
|
+
}
|
|
1120
|
+
function tn(e, t, n) {
|
|
1121
|
+
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
1122
|
+
}
|
|
1123
|
+
function nn(e, t) {
|
|
1124
|
+
if (!e) return [];
|
|
1125
|
+
let n = t?.defaultProtocol || "http", r = [];
|
|
1126
|
+
for (let t of e.matchAll(qt)) r.push({
|
|
1127
|
+
type: "url",
|
|
1128
|
+
value: t[0],
|
|
1129
|
+
start: t.index,
|
|
1130
|
+
end: t.index + t[0].length
|
|
1131
|
+
});
|
|
1132
|
+
for (let t of e.matchAll(Jt)) r.push({
|
|
1133
|
+
type: "url",
|
|
1134
|
+
value: t[0],
|
|
1135
|
+
start: t.index,
|
|
1136
|
+
end: t.index + t[0].length
|
|
1137
|
+
});
|
|
1138
|
+
for (let t of e.matchAll(Yt)) r.push({
|
|
1139
|
+
type: "email",
|
|
1140
|
+
value: t[0],
|
|
1141
|
+
start: t.index,
|
|
1142
|
+
end: t.index + t[0].length
|
|
1143
|
+
});
|
|
1144
|
+
for (let t of e.matchAll(Xt)) r.push({
|
|
1145
|
+
type: "url",
|
|
1146
|
+
value: t[0],
|
|
1147
|
+
start: t.index,
|
|
1148
|
+
end: t.index + t[0].length
|
|
1149
|
+
});
|
|
1150
|
+
r.sort((e, t) => e.start - t.start || t.end - e.end);
|
|
1151
|
+
let i = [], a = -1;
|
|
1152
|
+
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
1153
|
+
let o = [];
|
|
1154
|
+
for (let e of i) {
|
|
1155
|
+
let t = Zt(e.value);
|
|
1156
|
+
if (!t) continue;
|
|
1157
|
+
let r = e.start, i = r + t.length;
|
|
1158
|
+
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
1159
|
+
let e = new URL("http://" + t).hostname;
|
|
1160
|
+
if (!en(e)) continue;
|
|
1161
|
+
}
|
|
1162
|
+
if (e.type === "email") {
|
|
1163
|
+
let e = t.split("@")[1];
|
|
1164
|
+
if (!en(e)) continue;
|
|
1165
|
+
}
|
|
1166
|
+
let a = tn(t, e.type, n);
|
|
1167
|
+
o.push({
|
|
1168
|
+
type: e.type,
|
|
1169
|
+
value: t,
|
|
1170
|
+
isLink: !0,
|
|
1171
|
+
href: a,
|
|
1172
|
+
start: r,
|
|
1173
|
+
end: i
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
return o;
|
|
1177
|
+
}
|
|
1178
|
+
function rn(e, t = "http") {
|
|
1179
|
+
if (!e) return [U(e, 0, 0)];
|
|
1180
|
+
for (let [n, r] of [
|
|
1181
|
+
["(", ")"],
|
|
1182
|
+
["[", "]"],
|
|
1183
|
+
["{", "}"]
|
|
1184
|
+
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
1185
|
+
let i = e.slice(1, -1);
|
|
1186
|
+
if (H(i)) return [
|
|
1187
|
+
U(n, 0, 1),
|
|
1188
|
+
an(i, 1, 1 + i.length, t),
|
|
1189
|
+
U(r, 1 + i.length, e.length)
|
|
1190
|
+
];
|
|
1191
|
+
}
|
|
1192
|
+
if (e.endsWith(".") && e.length > 1) {
|
|
1193
|
+
let n = e.slice(0, -1);
|
|
1194
|
+
if (H(n)) return [an(n, 0, n.length, t), U(".", n.length, e.length)];
|
|
1195
|
+
}
|
|
1196
|
+
return H(e) ? [an(e, 0, e.length, t)] : [U(e, 0, e.length)];
|
|
1197
|
+
}
|
|
1198
|
+
function H(e) {
|
|
1199
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || Gt.has(e.toLowerCase())) return !0;
|
|
1200
|
+
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
1201
|
+
if (t) {
|
|
1202
|
+
let e = t[1].toLowerCase();
|
|
1203
|
+
if (Wt.has(e)) return !0;
|
|
1204
|
+
}
|
|
1205
|
+
return !1;
|
|
1206
|
+
}
|
|
1207
|
+
function an(e, t, n, r) {
|
|
1208
|
+
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
1209
|
+
return {
|
|
1210
|
+
type: i,
|
|
1211
|
+
value: e,
|
|
1212
|
+
isLink: !0,
|
|
1213
|
+
href: tn(e, i, r),
|
|
1214
|
+
start: t,
|
|
1215
|
+
end: n
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
function U(e, t, n) {
|
|
1219
|
+
return {
|
|
1220
|
+
type: "text",
|
|
1221
|
+
value: e,
|
|
1222
|
+
isLink: !1,
|
|
1223
|
+
href: e,
|
|
1224
|
+
start: t,
|
|
1225
|
+
end: n
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
// src/api/parsers/markdown/autolink.ts
|
|
1229
|
+
function on(e) {
|
|
1230
|
+
if (!/^(https?:\/\/|www\.)/i.test(e)) return;
|
|
1231
|
+
let t = nn(e.replace(/&[a-zA-Z0-9]+;$/, ""), { defaultProtocol: "http" })[0];
|
|
1232
|
+
if (t && t.start === 0) return {
|
|
1233
|
+
value: t.value,
|
|
1234
|
+
href: t.href
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
// src/api/exporters/markdown/wrapWithDelimiter.ts
|
|
1238
|
+
function sn(e, t) {
|
|
1239
|
+
let n = e.replace(/(?:\\\n|\s)+$/, "").trimStart();
|
|
1240
|
+
if (!n) return e;
|
|
1241
|
+
let r = e.indexOf(n);
|
|
1242
|
+
return `${e.slice(0, r)}${t}${n}${t}${e.slice(r + n.length)}`;
|
|
1243
|
+
}
|
|
1244
|
+
// src/api/exporters/markdown/htmlToMarkdown.ts
|
|
1245
|
+
function cn(e) {
|
|
1246
|
+
let t = document.createElement("div");
|
|
1247
|
+
return t.innerHTML = e, W(t, {
|
|
1248
|
+
indent: "",
|
|
1249
|
+
inListItem: !1
|
|
1250
|
+
}).trim() + "\n";
|
|
1251
|
+
}
|
|
1252
|
+
function W(e, t) {
|
|
1253
|
+
let n = "", r = Array.from(e.childNodes);
|
|
1254
|
+
for (let e = 0; e < r.length; e++) {
|
|
1255
|
+
let i = r[e];
|
|
1256
|
+
n += G(i, t);
|
|
1257
|
+
}
|
|
1258
|
+
return n;
|
|
1259
|
+
}
|
|
1260
|
+
function G(e, t) {
|
|
1261
|
+
if (e.nodeType === 3) return e.textContent || "";
|
|
1262
|
+
if (e.nodeType !== 1) return "";
|
|
1263
|
+
let n = e;
|
|
1264
|
+
switch (n.tagName.toLowerCase()) {
|
|
1265
|
+
case "p": return ln(n, t);
|
|
1266
|
+
case "h1":
|
|
1267
|
+
case "h2":
|
|
1268
|
+
case "h3":
|
|
1269
|
+
case "h4":
|
|
1270
|
+
case "h5":
|
|
1271
|
+
case "h6": return un(n, t);
|
|
1272
|
+
case "blockquote": return dn(n, t);
|
|
1273
|
+
case "pre": return fn(n, t);
|
|
1274
|
+
case "ul": return _n(n, t);
|
|
1275
|
+
case "ol": return vn(n, t);
|
|
1276
|
+
case "table": return xn(n, t);
|
|
1277
|
+
case "hr": return t.indent + "***\n\n";
|
|
1278
|
+
case "math": return mn(n, t);
|
|
1279
|
+
case "img": return wn(n, t);
|
|
1280
|
+
case "video": return Tn(n, t);
|
|
1281
|
+
case "audio": return En(n, t);
|
|
1282
|
+
case "embed": return Dn(n, t);
|
|
1283
|
+
case "figure": return On(n, t);
|
|
1284
|
+
case "a": return jn(n, t);
|
|
1285
|
+
case "details": return Pn(n, t);
|
|
1286
|
+
case "div": return W(n, t);
|
|
1287
|
+
case "br": return "";
|
|
1288
|
+
default: return W(n, t);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
function ln(e, t) {
|
|
1292
|
+
let n = In(J(e));
|
|
1293
|
+
return t.inListItem ? n : t.indent + n + "\n\n";
|
|
1294
|
+
}
|
|
1295
|
+
function un(e, t) {
|
|
1296
|
+
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = J(e);
|
|
1297
|
+
return t.indent + r + i + "\n\n";
|
|
1298
|
+
}
|
|
1299
|
+
function dn(e, t) {
|
|
1300
|
+
let n = Array.from(e.children).filter((e) => {
|
|
1301
|
+
let t = e.tagName.toLowerCase();
|
|
1302
|
+
return [
|
|
1303
|
+
"p",
|
|
1304
|
+
"ul",
|
|
1305
|
+
"ol",
|
|
1306
|
+
"pre",
|
|
1307
|
+
"blockquote",
|
|
1308
|
+
"table",
|
|
1309
|
+
"hr"
|
|
1310
|
+
].includes(t);
|
|
1311
|
+
}), r;
|
|
1312
|
+
if (n.length > 0) {
|
|
1313
|
+
let e = [];
|
|
1314
|
+
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(J(t)) : e.push(G(t, {
|
|
1315
|
+
indent: "",
|
|
1316
|
+
inListItem: !1
|
|
1317
|
+
}).trim());
|
|
1318
|
+
r = e.join("\n\n");
|
|
1319
|
+
} else r = J(e);
|
|
1320
|
+
return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
|
|
1321
|
+
}
|
|
1322
|
+
function fn(e, t) {
|
|
1323
|
+
let n = e.querySelector("code");
|
|
1324
|
+
if (!n) return "";
|
|
1325
|
+
let r = n.getAttribute("data-language") || gn(n.className) || "", i = hn(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
|
|
1326
|
+
return i ? [
|
|
1327
|
+
o + r,
|
|
1328
|
+
...(i.endsWith("\n") ? i.slice(0, -1) : i).split("\n"),
|
|
1329
|
+
o
|
|
1330
|
+
].map((e) => e && t.indent + e).join("\n") + "\n\n" : t.indent + o + r + "\n" + t.indent + o + "\n\n";
|
|
1331
|
+
}
|
|
1332
|
+
function pn(e) {
|
|
1333
|
+
return (e.querySelector("annotation[encoding=\"application/x-tex\"]")?.textContent ?? e.textContent ?? "").trim();
|
|
1334
|
+
}
|
|
1335
|
+
function mn(e, t) {
|
|
1336
|
+
return [
|
|
1337
|
+
"$$",
|
|
1338
|
+
...pn(e).split("\n"),
|
|
1339
|
+
"$$"
|
|
1340
|
+
].map((e) => e && t.indent + e).join("\n") + "\n\n";
|
|
1341
|
+
}
|
|
1342
|
+
function hn(e) {
|
|
1343
|
+
let t = "";
|
|
1344
|
+
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += hn(n));
|
|
1345
|
+
return t;
|
|
1346
|
+
}
|
|
1347
|
+
function gn(e) {
|
|
1348
|
+
let t = e.match(/language-(\S+)/);
|
|
1349
|
+
return t ? t[1] : "";
|
|
1350
|
+
}
|
|
1351
|
+
function _n(e, t) {
|
|
1352
|
+
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
|
|
1353
|
+
for (let e of r) n += yn(e, "bullet", t);
|
|
1354
|
+
return t.inListItem || (n += "\n"), n;
|
|
1355
|
+
}
|
|
1356
|
+
function vn(e, t) {
|
|
1357
|
+
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
|
|
1358
|
+
for (let e = 0; e < r.length; e++) {
|
|
1359
|
+
let a = i + e;
|
|
1360
|
+
n += yn(r[e], "ordered", t, a);
|
|
1361
|
+
}
|
|
1362
|
+
return t.inListItem || (n += "\n"), n;
|
|
1363
|
+
}
|
|
1364
|
+
function yn(e, t, n, r) {
|
|
1365
|
+
let i = null, a = null;
|
|
1366
|
+
for (let t of Array.from(e.children)) {
|
|
1367
|
+
let e = t.tagName.toLowerCase();
|
|
1368
|
+
e === "input" && t.type === "checkbox" && (i = t), e === "details" && (a = t);
|
|
1369
|
+
}
|
|
1370
|
+
let o, s;
|
|
1371
|
+
i ? (o = `* ${i.checked ? "[x]" : "[ ]"} `, s = 2) : t === "ordered" ? (o = `${r}. `, s = o.length) : (o = "* ", s = 2);
|
|
1372
|
+
let c, l;
|
|
1373
|
+
if (a) {
|
|
1374
|
+
let e = a.querySelector("summary")?.querySelector("p");
|
|
1375
|
+
l = a, c = e ? J(e) : "";
|
|
1376
|
+
} else l = bn(e, i), c = l ? J(l) : "";
|
|
1377
|
+
let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
|
|
1378
|
+
indent: d,
|
|
1379
|
+
inListItem: !0
|
|
1380
|
+
};
|
|
1381
|
+
if (a) {
|
|
1382
|
+
let e = a.querySelector("summary");
|
|
1383
|
+
for (let t of Array.from(a.children)) if (t !== e) {
|
|
1384
|
+
if (t.tagName.toLowerCase() === "p") {
|
|
1385
|
+
let e = J(t);
|
|
1386
|
+
u += "\n" + d + e + "\n";
|
|
1387
|
+
} else u += G(t, f);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
let p = Array.from(e.children);
|
|
1391
|
+
for (let e of p) {
|
|
1392
|
+
let t = e.tagName.toLowerCase();
|
|
1393
|
+
if (e !== l && e !== i && t !== "input") {
|
|
1394
|
+
if (t === "ul" || t === "ol") u += G(e, f);
|
|
1395
|
+
else if (t === "p") {
|
|
1396
|
+
let t = J(e);
|
|
1397
|
+
u += "\n" + d + t + "\n";
|
|
1398
|
+
} else u += "\n" + G(e, f);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return u;
|
|
1402
|
+
}
|
|
1403
|
+
function bn(e, t) {
|
|
1404
|
+
for (let n of Array.from(e.children)) {
|
|
1405
|
+
if (n === t || n.tagName.toLowerCase() === "input") continue;
|
|
1406
|
+
let e = n.tagName.toLowerCase();
|
|
1407
|
+
if (e === "p" || e === "span") return n;
|
|
1408
|
+
}
|
|
1409
|
+
return null;
|
|
1410
|
+
}
|
|
1411
|
+
function xn(e, t) {
|
|
1412
|
+
let n = e.querySelector("colgroup"), r = 0;
|
|
1413
|
+
n && (r = n.querySelectorAll("col").length);
|
|
1414
|
+
let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
|
|
1415
|
+
o.forEach((e, t) => {
|
|
1416
|
+
s[t] || (s[t] = []);
|
|
1417
|
+
let n = e.querySelectorAll("th, td"), i = 0;
|
|
1418
|
+
n.forEach((e) => {
|
|
1419
|
+
for (; s[t][i] !== void 0;) i++;
|
|
1420
|
+
t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
|
|
1421
|
+
let n = Sn(J(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
|
|
1422
|
+
for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
|
|
1423
|
+
let r = t + e;
|
|
1424
|
+
s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
|
|
1425
|
+
}
|
|
1426
|
+
i += r;
|
|
1427
|
+
}), s[t] && (r = Math.max(r, s[t].length));
|
|
1428
|
+
});
|
|
1429
|
+
for (let e of s) {
|
|
1430
|
+
let t = [];
|
|
1431
|
+
for (let n = 0; n < r; n++) t.push(e && e[n] !== void 0 ? e[n] ?? "" : "");
|
|
1432
|
+
i.push(t);
|
|
1433
|
+
}
|
|
1434
|
+
if (i.length === 0) return "";
|
|
1435
|
+
let c = [];
|
|
1436
|
+
for (let e = 0; e < r; e++) {
|
|
1437
|
+
let t = 3;
|
|
1438
|
+
for (let n of i) {
|
|
1439
|
+
let r = e < n.length ? n[e].length : 0;
|
|
1440
|
+
t = Math.max(t, r);
|
|
1441
|
+
}
|
|
1442
|
+
c.push(Math.max(t, 10));
|
|
1443
|
+
}
|
|
1444
|
+
let l = "";
|
|
1445
|
+
if (a) {
|
|
1446
|
+
l += t.indent + K(i[0], c, r) + "\n", l += t.indent + Cn(c, r) + "\n";
|
|
1447
|
+
for (let e = 1; e < i.length; e++) l += t.indent + K(i[e], c, r) + "\n";
|
|
1448
|
+
} else {
|
|
1449
|
+
let e = Array(r).fill("");
|
|
1450
|
+
l += t.indent + K(e, c, r) + "\n", l += t.indent + Cn(c, r) + "\n";
|
|
1451
|
+
for (let e of i) l += t.indent + K(e, c, r) + "\n";
|
|
1452
|
+
}
|
|
1453
|
+
return l += "\n", l;
|
|
1454
|
+
}
|
|
1455
|
+
function Sn(e) {
|
|
1456
|
+
return e.replace(/\|/g, "\\|");
|
|
1457
|
+
}
|
|
1458
|
+
function K(e, t, n) {
|
|
1459
|
+
let r = [];
|
|
1460
|
+
for (let i = 0; i < n; i++) {
|
|
1461
|
+
let n = i < e.length ? e[i] : "";
|
|
1462
|
+
r.push(" " + n.padEnd(t[i]) + " ");
|
|
1463
|
+
}
|
|
1464
|
+
return "|" + r.join("|") + "|";
|
|
1465
|
+
}
|
|
1466
|
+
function Cn(e, t) {
|
|
1467
|
+
let n = [];
|
|
1468
|
+
for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
|
|
1469
|
+
return "|" + n.join("|") + "|";
|
|
1470
|
+
}
|
|
1471
|
+
function wn(e, t) {
|
|
1472
|
+
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
1473
|
+
return n ? t.indent + `\n\n` : "\n\n";
|
|
1474
|
+
}
|
|
1475
|
+
function Tn(e, t) {
|
|
1476
|
+
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
1477
|
+
return n ? t.indent + `\n\n` : "\n\n";
|
|
1478
|
+
}
|
|
1479
|
+
function En(e, t) {
|
|
1480
|
+
let n = e.getAttribute("src") || "";
|
|
1481
|
+
return n ? t.indent + `<audio src="${q(n)}" controls></audio>\n\n` : "\n\n";
|
|
1482
|
+
}
|
|
1483
|
+
function Dn(e, t) {
|
|
1484
|
+
let n = e.getAttribute("src") || "";
|
|
1485
|
+
return n ? t.indent + `[](${n})\n\n` : "\n\n";
|
|
1486
|
+
}
|
|
1487
|
+
function On(e, t) {
|
|
1488
|
+
let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
|
|
1489
|
+
return n ? kn("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? kn("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? kn("audio", i.getAttribute("src") || "", "", o, t) : a ? jn(a, t) : "";
|
|
1490
|
+
}
|
|
1491
|
+
function kn(e, t, n, r, i) {
|
|
1492
|
+
if (!t) return "";
|
|
1493
|
+
if (!r && e !== "audio") return i.indent + `\n\n`;
|
|
1494
|
+
let a = n && n !== r ? e === "img" ? ` alt="${q(n)}"` : e === "video" ? ` data-name="${q(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${q(t)}">` : `<${e} src="${q(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${An(r)}</figcaption>` : "";
|
|
1495
|
+
return i.indent + `<figure>${o}${s}</figure>\n\n`;
|
|
1496
|
+
}
|
|
1497
|
+
function q(e) {
|
|
1498
|
+
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
1499
|
+
}
|
|
1500
|
+
function An(e) {
|
|
1501
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1502
|
+
}
|
|
1503
|
+
function jn(e, t) {
|
|
1504
|
+
let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
|
|
1505
|
+
return n ? t.indent + Mn(r, n) + "\n\n" : t.indent + r + "\n\n";
|
|
1506
|
+
}
|
|
1507
|
+
function Mn(e, t) {
|
|
1508
|
+
if (!e) return t;
|
|
1509
|
+
if (e === t) {
|
|
1510
|
+
let e = on(t);
|
|
1511
|
+
if (!/^(https?:\/\/|www\.)/i.test(t) || e?.href === t && e.value === t) return t;
|
|
1512
|
+
}
|
|
1513
|
+
return `[${e}](${Nn(t)})`;
|
|
1514
|
+
}
|
|
1515
|
+
function Nn(e) {
|
|
1516
|
+
return e.replace(/[\\()]/g, "\\$&");
|
|
1517
|
+
}
|
|
1518
|
+
function Pn(e, t) {
|
|
1519
|
+
let n = e.querySelector("summary");
|
|
1520
|
+
if (!n) return W(e, t);
|
|
1521
|
+
let r = n.querySelector("h1, h2, h3, h4, h5, h6");
|
|
1522
|
+
if (r) {
|
|
1523
|
+
let i = un(r, t);
|
|
1524
|
+
for (let r of Array.from(e.children)) r !== n && (i += G(r, t));
|
|
1525
|
+
return i;
|
|
1526
|
+
}
|
|
1527
|
+
return W(n, t);
|
|
1528
|
+
}
|
|
1529
|
+
function J(e) {
|
|
1530
|
+
let t = "";
|
|
1531
|
+
for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += Fn(n.textContent || "");
|
|
1532
|
+
else if (n.nodeType === 1) {
|
|
1533
|
+
let e = n;
|
|
1534
|
+
switch (e.tagName.toLowerCase()) {
|
|
1535
|
+
case "strong":
|
|
1536
|
+
case "b":
|
|
1537
|
+
t += sn(J(e), "**");
|
|
1538
|
+
break;
|
|
1539
|
+
case "em":
|
|
1540
|
+
case "i":
|
|
1541
|
+
t += sn(J(e), "*");
|
|
1542
|
+
break;
|
|
1543
|
+
case "s":
|
|
1544
|
+
case "del":
|
|
1545
|
+
t += sn(J(e), "~~");
|
|
1546
|
+
break;
|
|
1547
|
+
case "code": {
|
|
1548
|
+
let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
|
|
1549
|
+
t += i + (a ? ` ${n} ` : n) + i;
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
case "u":
|
|
1553
|
+
t += J(e);
|
|
1554
|
+
break;
|
|
1555
|
+
case "a": {
|
|
1556
|
+
let n = e.getAttribute("href") || "", r = J(e);
|
|
1557
|
+
t += Mn(r, n);
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
case "br":
|
|
1561
|
+
t += "\\\n";
|
|
1562
|
+
break;
|
|
1563
|
+
case "math": {
|
|
1564
|
+
let n = pn(e).split("\n").map((e) => e.trim()).join(" ");
|
|
1565
|
+
t += `$${n}$`;
|
|
1566
|
+
break;
|
|
1567
|
+
}
|
|
1568
|
+
case "span":
|
|
1569
|
+
t += J(e);
|
|
1570
|
+
break;
|
|
1571
|
+
case "img": {
|
|
1572
|
+
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
1573
|
+
t += ``;
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
case "video": {
|
|
1577
|
+
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
1578
|
+
t += ``;
|
|
1579
|
+
break;
|
|
1580
|
+
}
|
|
1581
|
+
case "p":
|
|
1582
|
+
t += J(e);
|
|
1583
|
+
break;
|
|
1584
|
+
case "input": break;
|
|
1585
|
+
default: t += J(e);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
return t;
|
|
1589
|
+
}
|
|
1590
|
+
function Fn(e) {
|
|
1591
|
+
return e.replace(/(\\*)<(?=[A-Za-z/!?])/g, (e, t) => `${t}${t}\\<`);
|
|
1592
|
+
}
|
|
1593
|
+
function In(e) {
|
|
1594
|
+
let t = e.replace(/^(\\\n)+/, "");
|
|
1595
|
+
return t = t.replace(/(\\\n)+$/, ""), t;
|
|
1596
|
+
}
|
|
1597
|
+
// src/api/exporters/markdown/markdownExporter.ts
|
|
1598
|
+
function Ln(e) {
|
|
1599
|
+
return cn(e.split("").join(""));
|
|
1600
|
+
}
|
|
1601
|
+
function Rn(e, t, n, r) {
|
|
1602
|
+
return Ln(Xe(t, n).exportBlocks(e, r));
|
|
1603
|
+
}
|
|
1604
|
+
// src/extensions/SideMenu/dragging.ts
|
|
1605
|
+
var Y;
|
|
1606
|
+
function zn(e, t) {
|
|
1607
|
+
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);
|
|
1608
|
+
if (i && a) {
|
|
1609
|
+
let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
|
|
1610
|
+
n = t.resolve(i - 1).pos, r = t.resolve(a + 1).pos;
|
|
1611
|
+
} else n = e.from, r = e.to;
|
|
1612
|
+
return {
|
|
1613
|
+
from: n,
|
|
1614
|
+
to: r
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
function Bn(e, t, n = t) {
|
|
1618
|
+
t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
|
|
1619
|
+
let r = e.domAtPos(t).node.cloneNode(!1);
|
|
1620
|
+
r.style.removeProperty("display");
|
|
1621
|
+
for (let i = t; i < n; i += e.state.doc.nodeAt(i).nodeSize) {
|
|
1622
|
+
let t = e.nodeDOM(i);
|
|
1623
|
+
if (!t) throw Error(`The dragged block at ${i} has no DOM.`);
|
|
1624
|
+
r.appendChild(t.cloneNode(!0));
|
|
1625
|
+
}
|
|
1626
|
+
r.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
|
|
1627
|
+
let i = (e.dom.parentElement?.closest(".bn-root"))?.cloneNode(!1) ?? document.createElement("div");
|
|
1628
|
+
i.removeAttribute("id"), i.classList.add("bn-drag-preview");
|
|
1629
|
+
let a = document.createElement("div");
|
|
1630
|
+
a.className = e.dom.className, a.appendChild(r), i.appendChild(a), Object.assign(i.style, {
|
|
1631
|
+
background: "transparent",
|
|
1632
|
+
position: "absolute",
|
|
1633
|
+
top: "-10000px",
|
|
1634
|
+
left: "0",
|
|
1635
|
+
margin: "0",
|
|
1636
|
+
padding: "10px",
|
|
1637
|
+
height: "auto",
|
|
1638
|
+
minHeight: "0",
|
|
1639
|
+
maxHeight: "75vh",
|
|
1640
|
+
overflow: "hidden"
|
|
1641
|
+
}), Object.assign(a.style, {
|
|
1642
|
+
background: "transparent",
|
|
1643
|
+
width: `${e.nodeDOM(t).offsetWidth}px`,
|
|
1644
|
+
height: "auto",
|
|
1645
|
+
minHeight: "0",
|
|
1646
|
+
maxHeight: "none",
|
|
1647
|
+
margin: "0",
|
|
1648
|
+
padding: "0",
|
|
1649
|
+
overflow: "visible"
|
|
1650
|
+
}), Vn(e.root), Y = i, e.root instanceof ShadowRoot ? e.root.appendChild(Y) : e.root.body.appendChild(Y);
|
|
1651
|
+
}
|
|
1652
|
+
function Vn(e) {
|
|
1653
|
+
Y !== void 0 && (e instanceof ShadowRoot ? e.removeChild(Y) : e.body.removeChild(Y), Y = void 0);
|
|
1654
|
+
}
|
|
1655
|
+
function Hn(e, t, n) {
|
|
1656
|
+
if (!e.dataTransfer || n.headless) return;
|
|
1657
|
+
let r = n.prosemirrorView, i = M(t.id, r.state.doc);
|
|
1658
|
+
if (!i) throw Error(`Block with ID ${t.id} not found`);
|
|
1659
|
+
let a = i.posBeforeNode;
|
|
1660
|
+
if (a != null) {
|
|
1661
|
+
let t = r.state.selection, o = r.state.doc, { from: s, to: c } = zn(t, o), l = s <= a && a < c, u = t.$anchor.node() !== t.$head.node() || t instanceof te && t.nodes.length > 1;
|
|
1662
|
+
l && u ? (r.dispatch(r.state.tr.setSelection(te.create(o, s, c))), Bn(r, s, c)) : (r.dispatch(r.state.tr.setSelection(te.create(o, a, a + i.node.nodeSize))), Bn(r, a));
|
|
1663
|
+
let d = r.state.selection.content(), f = n.pmSchema, p = r.serializeForClipboard(d).dom.innerHTML, m = Xe(f, n), h = F(d.content), g = m.exportBlocks(h, {}), _ = Ln(g);
|
|
1664
|
+
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", p), e.dataTransfer.setData("blocknote/parent", r.state.selection.$from.parent.type.name), e.dataTransfer.setData("text/html", g), e.dataTransfer.setData("text/plain", _), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(Y, 0, 0);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
// src/extensions/SideMenu/SideMenu.ts
|
|
1668
|
+
var Un = 350;
|
|
1669
|
+
function Wn(e) {
|
|
1670
|
+
if (!e || !("nodeType" in e)) return null;
|
|
1671
|
+
let t = e;
|
|
1672
|
+
return t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
1673
|
+
}
|
|
1674
|
+
var Gn = new je("SideMenuPlugin"), Kn = T(({ editor: e, options: t }) => {
|
|
1675
|
+
let n = w(void 0), r = t?.sideMenu?.hoverMargin ?? 0, i = !1, a = !1, o, s, c, l;
|
|
1676
|
+
function u(t) {
|
|
1677
|
+
return e.schema.blockSpecs[t].implementation.meta.draggable;
|
|
1678
|
+
}
|
|
1679
|
+
function d() {
|
|
1680
|
+
l &&= (clearTimeout(l.timer), void 0);
|
|
1681
|
+
}
|
|
1682
|
+
function f() {
|
|
1683
|
+
let e = n.state;
|
|
1684
|
+
e?.show && n.setState({
|
|
1685
|
+
...e,
|
|
1686
|
+
show: !1
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
function p(t) {
|
|
1690
|
+
let r = e.getBlock(t.id);
|
|
1691
|
+
r ? n.setState({
|
|
1692
|
+
show: !0,
|
|
1693
|
+
referencePos: t.node.getBoundingClientRect(),
|
|
1694
|
+
block: r
|
|
1695
|
+
}) : f();
|
|
1696
|
+
}
|
|
1697
|
+
function m(t, s, m) {
|
|
1698
|
+
if (i || a) return;
|
|
1699
|
+
if (s && o?.contains(s)) {
|
|
1700
|
+
d(), c = t;
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
if (!e.isEditable) {
|
|
1704
|
+
d(), f();
|
|
1705
|
+
return;
|
|
1706
|
+
}
|
|
1707
|
+
let h = Pt(e.prosemirrorView, s, t, u, e.isWithinEditor, r);
|
|
1708
|
+
if (h.kind === "editorUI") return;
|
|
1709
|
+
let _ = n.state, v = _?.show ? _.block.id : void 0;
|
|
1710
|
+
if (h.kind === "block" && h.block.id === v) d(), c = t;
|
|
1711
|
+
else {
|
|
1712
|
+
if (m && v !== void 0 && o?.isConnected) {
|
|
1713
|
+
let e = l?.exit ?? c ?? t;
|
|
1714
|
+
if (zt(t, e, o.getBoundingClientRect())) {
|
|
1715
|
+
d(), l = {
|
|
1716
|
+
exit: e,
|
|
1717
|
+
timer: setTimeout(g, Un)
|
|
1718
|
+
};
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
d(), h.kind === "block" ? (c = t, p(h.block)) : f();
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
function h() {
|
|
1726
|
+
Vn(e.prosemirrorView.root), a = !1;
|
|
1727
|
+
}
|
|
1728
|
+
function g() {
|
|
1729
|
+
l = void 0, _();
|
|
1730
|
+
}
|
|
1731
|
+
function _() {
|
|
1732
|
+
if (!s) return;
|
|
1733
|
+
let t = e.prosemirrorView, n = o?.isConnected ? o.getBoundingClientRect() : void 0, r = n !== void 0 && s.x >= n.left && s.x <= n.right && s.y >= n.top && s.y <= n.bottom ? {
|
|
1734
|
+
x: n.right + 1,
|
|
1735
|
+
y: s.y
|
|
1736
|
+
} : s;
|
|
1737
|
+
m(r, t.root.elementsFromPoint(r.x, r.y).find((n) => t.dom.contains(n) || !e.isWithinEditor(n)) ?? null, !1);
|
|
1738
|
+
}
|
|
1739
|
+
return {
|
|
1740
|
+
key: "sideMenu",
|
|
1741
|
+
store: n,
|
|
1742
|
+
prosemirrorPlugins: [new Ae({
|
|
1743
|
+
key: Gn,
|
|
1744
|
+
appendTransaction: (e, t, n) => e.some((e) => e.getMeta("uiEvent") === "drop") ? n.tr.scrollIntoView() : null
|
|
1745
|
+
})],
|
|
1746
|
+
mount({ root: r, signal: o }) {
|
|
1747
|
+
Vt(e.prosemirrorView, () => a, t?.sideMenu?.dropMargin ?? 250, o), r.addEventListener("mousemove", (e) => {
|
|
1748
|
+
let { clientX: t, clientY: n, buttons: r } = e;
|
|
1749
|
+
if (i || typeof t != "number" || typeof n != "number" || !Number.isFinite(t) || !Number.isFinite(n)) return;
|
|
1750
|
+
a && r === 0 && h();
|
|
1751
|
+
let o = {
|
|
1752
|
+
x: t,
|
|
1753
|
+
y: n
|
|
1754
|
+
};
|
|
1755
|
+
s = o, m(o, Wn(e.target), !0);
|
|
1756
|
+
}, {
|
|
1757
|
+
signal: o,
|
|
1758
|
+
capture: !0
|
|
1759
|
+
}), r.addEventListener("mouseout", (e) => {
|
|
1760
|
+
e.relatedTarget === null && !i && !a && (s = void 0, d(), f());
|
|
1761
|
+
}, {
|
|
1762
|
+
signal: o,
|
|
1763
|
+
capture: !0
|
|
1764
|
+
}), r.addEventListener("keydown", () => {
|
|
1765
|
+
n.state?.show && e.isFocused() && (d(), f());
|
|
1766
|
+
}, {
|
|
1767
|
+
signal: o,
|
|
1768
|
+
capture: !0
|
|
1769
|
+
});
|
|
1770
|
+
let c = e.onChange(() => {
|
|
1771
|
+
n.state?.show && (d(), _());
|
|
1772
|
+
});
|
|
1773
|
+
o.addEventListener("abort", () => {
|
|
1774
|
+
c(), d(), f();
|
|
1775
|
+
});
|
|
1776
|
+
},
|
|
1777
|
+
setMenuElement(e) {
|
|
1778
|
+
o = e;
|
|
1779
|
+
},
|
|
1780
|
+
blockDragStart(t, n) {
|
|
1781
|
+
a = !0, Hn(t, n, e);
|
|
1782
|
+
},
|
|
1783
|
+
blockDragEnd() {
|
|
1784
|
+
h(), f();
|
|
1785
|
+
},
|
|
1786
|
+
get menuFrozen() {
|
|
1787
|
+
return i;
|
|
1788
|
+
},
|
|
1789
|
+
freezeMenu() {
|
|
1790
|
+
i = !0, d();
|
|
1791
|
+
let e = n.state;
|
|
1792
|
+
e && n.setState({
|
|
1793
|
+
...e,
|
|
1794
|
+
show: !0
|
|
1795
|
+
});
|
|
1796
|
+
},
|
|
1797
|
+
unfreezeMenu() {
|
|
1798
|
+
i = !1, f();
|
|
1799
|
+
let t = e.prosemirrorView, n = t.dom.ownerDocument, r = t.root.activeElement ?? n.activeElement;
|
|
1800
|
+
(!r || r === n.body || e.isWithinEditor(r) && o?.contains(r)) && e.focus();
|
|
1801
|
+
},
|
|
1802
|
+
hideMenuIfNotFrozen() {
|
|
1803
|
+
!i && !a && (d(), f());
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
}), qn = T(({ editor: e }) => {
|
|
1807
|
+
let t = w({
|
|
1808
|
+
popupOpen: void 0,
|
|
1809
|
+
selected: void 0
|
|
1810
|
+
}), n = (t) => !!e.schema.blockSpecs[t.type]?.implementation.meta.hasPreview, r = (e) => ({ editor: r }) => {
|
|
1811
|
+
let { block: i, prevBlock: a, nextBlock: o } = r.getTextCursorPosition();
|
|
1812
|
+
if (!n(i) || t.state.popupOpen === i.id) return !1;
|
|
1813
|
+
let s = e === "prev" ? a : o;
|
|
1814
|
+
return s ? (r.setTextCursorPosition(s.id, e === "prev" ? "end" : "start"), !0) : !1;
|
|
1815
|
+
};
|
|
1816
|
+
return {
|
|
1817
|
+
key: "sourceBlockWithPreview",
|
|
1818
|
+
store: t,
|
|
1819
|
+
keyboardShortcuts: {
|
|
1820
|
+
Enter: ({ editor: e }) => {
|
|
1821
|
+
let { block: r } = e.getTextCursorPosition();
|
|
1822
|
+
if (!n(r)) return !1;
|
|
1823
|
+
if (t.state.popupOpen === r.id && e.schema.blockSpecs[r.type].implementation.keyboard(r).enter === "line-break") {
|
|
1824
|
+
let t = e.prosemirrorView;
|
|
1825
|
+
return t.dispatch(t.state.tr.insertText("\n")), !0;
|
|
1826
|
+
}
|
|
1827
|
+
return e.setTextCursorPosition(r.id, "end"), t.setState((e) => ({
|
|
1828
|
+
...e,
|
|
1829
|
+
popupOpen: t.state.popupOpen === r.id ? void 0 : r.id
|
|
1830
|
+
})), !0;
|
|
1831
|
+
},
|
|
1832
|
+
Escape: ({ editor: e }) => {
|
|
1833
|
+
let { block: r } = e.getTextCursorPosition();
|
|
1834
|
+
return !n(r) || t.state.popupOpen !== r.id ? !1 : (e.setTextCursorPosition(r.id, "end"), t.setState((e) => ({
|
|
1835
|
+
...e,
|
|
1836
|
+
popupOpen: void 0
|
|
1837
|
+
})), !0);
|
|
1838
|
+
},
|
|
1839
|
+
"Mod-a": ({ editor: e }) => {
|
|
1840
|
+
let { block: r } = e.getTextCursorPosition();
|
|
1841
|
+
if (!n(r) || t.state.popupOpen !== r.id) return !1;
|
|
1842
|
+
let i = e.prosemirrorView, { $from: a } = i.state.selection;
|
|
1843
|
+
return a.parent.type.name === r.type && (i.dispatch(i.state.tr.setSelection(k.create(i.state.doc, a.start(), a.end()))), !0);
|
|
1844
|
+
},
|
|
1845
|
+
ArrowUp: r("prev"),
|
|
1846
|
+
ArrowLeft: r("prev"),
|
|
1847
|
+
ArrowDown: r("next"),
|
|
1848
|
+
ArrowRight: r("next")
|
|
1849
|
+
},
|
|
1850
|
+
mount: ({ dom: r, signal: i }) => {
|
|
1851
|
+
let a = e.onSelectionChange(() => {
|
|
1852
|
+
let { block: r } = e.getTextCursorPosition(), i = n(r) ? r.id : void 0, a = t.state.popupOpen && t.state.popupOpen !== r.id ? void 0 : t.state.popupOpen;
|
|
1853
|
+
(i !== t.state.selected || a !== t.state.popupOpen) && t.setState((e) => ({
|
|
1854
|
+
...e,
|
|
1855
|
+
selected: i,
|
|
1856
|
+
popupOpen: a
|
|
1857
|
+
}));
|
|
1858
|
+
});
|
|
1859
|
+
i.addEventListener("abort", a), r.addEventListener("keydown", (r) => {
|
|
1860
|
+
if (!e.isEditable) return;
|
|
1861
|
+
let { block: i } = e.getTextCursorPosition();
|
|
1862
|
+
n(i) && t.state.popupOpen !== i.id && (r.key === "Backspace" || r.key === "Delete" ? (r.preventDefault(), r.stopImmediatePropagation(), e.removeBlocks([i.id])) : (r.key.length === 1 && !r.ctrlKey && !r.metaKey || r.key === "Tab") && (r.preventDefault(), r.stopImmediatePropagation()));
|
|
1863
|
+
}, {
|
|
1864
|
+
capture: !0,
|
|
1865
|
+
signal: i
|
|
1866
|
+
}), r.addEventListener("blur", () => t.setState((e) => ({
|
|
1867
|
+
...e,
|
|
1868
|
+
popupOpen: void 0
|
|
1869
|
+
})), {
|
|
1870
|
+
capture: !0,
|
|
1871
|
+
signal: i
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
}), Jn = T(({ editor: e }) => {
|
|
1876
|
+
let t = w({ selected: void 0 }), n = (t) => !!e.schema.inlineContentSpecs[t]?.implementation?.meta?.hasPreview, r = (e) => ({ editor: t }) => {
|
|
1877
|
+
let { $from: r } = t.prosemirrorState.selection, i = r.node();
|
|
1878
|
+
if (!n(i.type.name)) return !1;
|
|
1879
|
+
let a = t.prosemirrorView, o = O.near(a.state.doc.resolve(e === "before" ? r.before() : r.after()), e === "before" ? -1 : 1);
|
|
1880
|
+
return a.dispatch(a.state.tr.setSelection(o)), !0;
|
|
1881
|
+
};
|
|
1882
|
+
return {
|
|
1883
|
+
key: "sourceInlineContentWithPreview",
|
|
1884
|
+
store: t,
|
|
1885
|
+
keyboardShortcuts: {
|
|
1886
|
+
Enter: r("after"),
|
|
1887
|
+
"Shift-Enter": r("after"),
|
|
1888
|
+
Escape: r("after"),
|
|
1889
|
+
ArrowUp: r("before"),
|
|
1890
|
+
ArrowDown: r("after"),
|
|
1891
|
+
"Mod-a": ({ editor: e }) => {
|
|
1892
|
+
let { $from: t } = e.prosemirrorState.selection;
|
|
1893
|
+
if (!n(t.node().type.name)) return !1;
|
|
1894
|
+
let r = e.prosemirrorView;
|
|
1895
|
+
return r.dispatch(r.state.tr.setSelection(k.create(r.state.doc, t.start(), t.end()))), !0;
|
|
1896
|
+
}
|
|
1897
|
+
},
|
|
1898
|
+
mount: ({ dom: r, signal: i }) => {
|
|
1899
|
+
let a = e.onSelectionChange(() => {
|
|
1900
|
+
let { $from: r } = e.prosemirrorState.selection, i = r.node();
|
|
1901
|
+
t.setState({ selected: n(i.type.name) ? r.before() : void 0 });
|
|
1902
|
+
});
|
|
1903
|
+
i.addEventListener("abort", a), r.addEventListener("keydown", (t) => {
|
|
1904
|
+
if (t.key !== "ArrowUp" && t.key !== "ArrowDown") return;
|
|
1905
|
+
let { $from: i } = e.prosemirrorState.selection;
|
|
1906
|
+
n(i.node().type.name) || (r.classList.add("bn-suppress-source-popup-caret"), requestAnimationFrame(() => r.classList.remove("bn-suppress-source-popup-caret")));
|
|
1907
|
+
}, {
|
|
1908
|
+
capture: !0,
|
|
1909
|
+
signal: i
|
|
1910
|
+
}), r.addEventListener("blur", () => t.setState({ selected: void 0 }), {
|
|
1911
|
+
capture: !0,
|
|
1912
|
+
signal: i
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1916
|
+
}), Yn = Symbol.for("blocknote.shikiParser"), Xn = Symbol.for("blocknote.shikiHighlighterPromise"), Zn = [
|
|
1917
|
+
"text",
|
|
1918
|
+
"none",
|
|
1919
|
+
"plaintext",
|
|
1920
|
+
"txt"
|
|
1921
|
+
];
|
|
1922
|
+
function Qn(e, t, n) {
|
|
1923
|
+
let r = globalThis, i, a, o = /* @__PURE__ */ new Set();
|
|
1924
|
+
return Le({
|
|
1925
|
+
parser: (t) => {
|
|
1926
|
+
if (!e.createHighlighter) return [];
|
|
1927
|
+
if (!i) return r[Xn] = r[Xn] || e.createHighlighter(), r[Xn].then((e) => {
|
|
1928
|
+
i = e;
|
|
1929
|
+
});
|
|
1930
|
+
let n = t.language;
|
|
1931
|
+
return !n || Zn.includes(n) || o.has(n) ? [] : i.getLoadedLanguages().includes(n) ? (a || (a = r[Yn] || Re(i, $n(i)), r[Yn] = a), a(t)) : i.loadLanguage(n).catch(() => {
|
|
1932
|
+
o.add(n);
|
|
1933
|
+
});
|
|
1934
|
+
},
|
|
1935
|
+
languageExtractor: (e) => {
|
|
1936
|
+
let t = {
|
|
1937
|
+
type: e.type.name,
|
|
1938
|
+
props: e.attrs
|
|
1939
|
+
};
|
|
1940
|
+
return (n.blockSpecs[t.type] || n.inlineContentSpecs[t.type])?.implementation.meta.highlight?.(t) ?? void 0;
|
|
1941
|
+
},
|
|
1942
|
+
nodeTypes: t
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
function $n(e) {
|
|
1946
|
+
let t = e.getLoadedThemes(), n = t.find((e) => /light/i.test(e)), r = t.find((e) => /dark/i.test(e));
|
|
1947
|
+
if (n && r) return {
|
|
1948
|
+
themes: {
|
|
1949
|
+
light: n,
|
|
1950
|
+
dark: r
|
|
1951
|
+
},
|
|
1952
|
+
defaultColor: !1
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
// src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts
|
|
1956
|
+
function er(e) {
|
|
1957
|
+
let t = Object.values(e.blockSpecs).filter((e) => typeof e?.config == "object" && e.config.content === "plain" && !!e.implementation.meta.highlight).map((e) => e.config.type), n = Object.values(e.inlineContentSpecs).filter((e) => typeof e?.config == "object" && e.config.content === "plain" && !!e.implementation?.meta?.highlight).map((e) => e.config.type);
|
|
1958
|
+
return [...t, ...n];
|
|
1959
|
+
}
|
|
1960
|
+
var tr = T(({ editor: e, options: t }) => ({
|
|
1961
|
+
key: "syntaxHighlighting",
|
|
1962
|
+
prosemirrorPlugins: [Qn(t, er(e.schema), e.schema)]
|
|
1963
|
+
})), X;
|
|
1964
|
+
function nr(e) {
|
|
1965
|
+
X || (X = document.createElement("div"), X.innerHTML = "_", X.style.opacity = "0", X.style.height = "1px", X.style.width = "1px", e instanceof Document ? e.body.appendChild(X) : e.appendChild(X));
|
|
1966
|
+
}
|
|
1967
|
+
function rr(e) {
|
|
1968
|
+
X &&= (e instanceof Document ? e.body.removeChild(X) : e.removeChild(X), void 0);
|
|
1969
|
+
}
|
|
1970
|
+
function Z(e) {
|
|
1971
|
+
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
1972
|
+
}
|
|
1973
|
+
function ir(e) {
|
|
1974
|
+
let t = e;
|
|
1975
|
+
for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
|
|
1976
|
+
if (t.classList.contains("ProseMirror")) return;
|
|
1977
|
+
let e = t.parentNode;
|
|
1978
|
+
if (!e || !(e instanceof Element)) return;
|
|
1979
|
+
t = e;
|
|
1980
|
+
}
|
|
1981
|
+
return t.nodeName === "TD" || t.nodeName === "TH" ? {
|
|
1982
|
+
type: "cell",
|
|
1983
|
+
domNode: t,
|
|
1984
|
+
tbodyNode: t.closest("tbody")
|
|
1985
|
+
} : {
|
|
1986
|
+
type: "wrapper",
|
|
1987
|
+
domNode: t,
|
|
1988
|
+
tbodyNode: t.querySelector("tbody")
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
function ar(e, t) {
|
|
1992
|
+
let n = t.querySelectorAll(e);
|
|
1993
|
+
for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
|
|
1994
|
+
}
|
|
1995
|
+
var or = class {
|
|
1996
|
+
editor;
|
|
1997
|
+
pmView;
|
|
1998
|
+
state;
|
|
1999
|
+
emitUpdate;
|
|
2000
|
+
tableId;
|
|
2001
|
+
tablePos;
|
|
2002
|
+
tableElement;
|
|
2003
|
+
menuFrozen = !1;
|
|
2004
|
+
mouseState = "up";
|
|
2005
|
+
prevWasEditable = null;
|
|
2006
|
+
constructor(e, t, n) {
|
|
2007
|
+
this.editor = e, this.pmView = t, this.emitUpdate = () => {
|
|
2008
|
+
n(this.state);
|
|
2009
|
+
}, 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);
|
|
2010
|
+
}
|
|
2011
|
+
viewMousedownHandler = () => {
|
|
2012
|
+
this.mouseState = "down";
|
|
2013
|
+
};
|
|
2014
|
+
hideHandles = () => {
|
|
2015
|
+
this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
2016
|
+
};
|
|
2017
|
+
mouseUpHandler = (e) => {
|
|
2018
|
+
this.mouseState = "up", this.mouseMoveHandler(e);
|
|
2019
|
+
};
|
|
2020
|
+
mouseMoveHandler = (e) => {
|
|
2021
|
+
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
|
|
2022
|
+
let t = ir(e.target);
|
|
2023
|
+
if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
|
|
2024
|
+
this.mouseState = "selecting", this.hideHandles();
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
2027
|
+
if (!t || !this.editor.isEditable) {
|
|
2028
|
+
this.hideHandles();
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
if (!t.tbodyNode) return;
|
|
2032
|
+
let n = t.tbodyNode.getBoundingClientRect(), r = Ve(t.domNode, this.pmView);
|
|
2033
|
+
if (!r) {
|
|
2034
|
+
this.hideHandles();
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
let { pmNodeInfo: i, doc: a } = this.editor.transact((e) => ({
|
|
2038
|
+
pmNodeInfo: M(r.id, e.doc),
|
|
2039
|
+
doc: e.doc
|
|
2040
|
+
}));
|
|
2041
|
+
if (!i) {
|
|
2042
|
+
this.hideHandles();
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
let o = f(i.node, a);
|
|
2046
|
+
if (!S(o, this.editor, "table")) {
|
|
2047
|
+
this.hideHandles();
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
let s = o;
|
|
2051
|
+
this.tablePos = i.posBeforeNode + 1, this.tableElement = r.node, this.tableId = r.id;
|
|
2052
|
+
let c = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
|
|
2053
|
+
if (t?.type === "wrapper") {
|
|
2054
|
+
let t = e.clientY >= n.bottom - 1 && e.clientY < n.bottom + 20, r = e.clientX >= n.right - 1 && e.clientX < n.right + 20, i = this.state?.block?.id !== s.id || e.clientX > n.right || e.clientY > n.bottom;
|
|
2055
|
+
this.state = {
|
|
2056
|
+
...this.state,
|
|
2057
|
+
show: !0,
|
|
2058
|
+
showAddOrRemoveRowsButton: t,
|
|
2059
|
+
showAddOrRemoveColumnsButton: r,
|
|
2060
|
+
referencePosTable: n,
|
|
2061
|
+
block: s,
|
|
2062
|
+
widgetContainer: c,
|
|
2063
|
+
colIndex: i ? void 0 : this.state?.colIndex,
|
|
2064
|
+
rowIndex: i ? void 0 : this.state?.rowIndex,
|
|
2065
|
+
referencePosCell: i ? void 0 : this.state?.referencePosCell
|
|
2066
|
+
};
|
|
2067
|
+
} else {
|
|
2068
|
+
let e = Z(t.domNode), i = Z(t.domNode.parentElement), a = t.domNode.getBoundingClientRect();
|
|
2069
|
+
if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === i && this.state.colIndex === e) return;
|
|
2070
|
+
this.state = {
|
|
2071
|
+
show: !0,
|
|
2072
|
+
showAddOrRemoveColumnsButton: e === s.content.rows[0].cells.length - 1,
|
|
2073
|
+
showAddOrRemoveRowsButton: i === s.content.rows.length - 1,
|
|
2074
|
+
referencePosTable: n,
|
|
2075
|
+
block: s,
|
|
2076
|
+
draggingState: void 0,
|
|
2077
|
+
referencePosCell: a,
|
|
2078
|
+
colIndex: e,
|
|
2079
|
+
rowIndex: i,
|
|
2080
|
+
widgetContainer: c
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
return this.emitUpdate(), !1;
|
|
2084
|
+
};
|
|
2085
|
+
dragOverHandler = (e) => {
|
|
2086
|
+
if (this.state?.draggingState === void 0) return;
|
|
2087
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", ar(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
|
|
2088
|
+
let t = {
|
|
2089
|
+
left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
|
|
2090
|
+
top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
|
|
2091
|
+
}, n = this.pmView.root.elementsFromPoint(t.left, t.top).filter((e) => e.tagName === "TD" || e.tagName === "TH");
|
|
2092
|
+
if (n.length === 0) return;
|
|
2093
|
+
let r = n[0], i = !1, a = Z(r.parentElement), o = Z(r), s = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, c = (this.state.draggingState.draggedCellOrientation === "row" ? a : o) !== s;
|
|
2094
|
+
(this.state.rowIndex !== a || this.state.colIndex !== o) && (this.state.rowIndex = a, this.state.colIndex = o, this.state.referencePosCell = r.getBoundingClientRect(), i = !0);
|
|
2095
|
+
let l = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
|
|
2096
|
+
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(Q, !0));
|
|
2097
|
+
};
|
|
2098
|
+
dropHandler = (e) => {
|
|
2099
|
+
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
|
|
2100
|
+
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.");
|
|
2101
|
+
e.preventDefault();
|
|
2102
|
+
let { draggingState: i, colIndex: a, rowIndex: o } = this.state;
|
|
2103
|
+
this.state.draggingState = void 0;
|
|
2104
|
+
let s = this.state.block.content.columnWidths, l = u(this.state.block);
|
|
2105
|
+
if (i.draggedCellOrientation === "row") {
|
|
2106
|
+
if (!_(this.state.block, i.originalIndex, o, t(this.state.block, o, l))) return !1;
|
|
2107
|
+
let e = n(this.state.block, i.originalIndex, o, l);
|
|
2108
|
+
this.editor.updateBlock(this.state.block, {
|
|
2109
|
+
type: "table",
|
|
2110
|
+
content: {
|
|
2111
|
+
...this.state.block.content,
|
|
2112
|
+
rows: e
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2115
|
+
} else {
|
|
2116
|
+
if (!oe(this.state.block, i.originalIndex, a, c(this.state.block, a, l))) return !1;
|
|
2117
|
+
let e = r(this.state.block, i.originalIndex, a, l), [t] = s.splice(i.originalIndex, 1);
|
|
2118
|
+
s.splice(a, 0, t), this.editor.updateBlock(this.state.block, {
|
|
2119
|
+
type: "table",
|
|
2120
|
+
content: {
|
|
2121
|
+
...this.state.block.content,
|
|
2122
|
+
columnWidths: s,
|
|
2123
|
+
rows: e
|
|
2124
|
+
}
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
return this.editor.setTextCursorPosition(this.state.block.id), !0;
|
|
2128
|
+
};
|
|
2129
|
+
getTablePos(e) {
|
|
2130
|
+
if (this.tableId === void 0) return;
|
|
2131
|
+
let t = M(this.tableId, e);
|
|
2132
|
+
return t && t.posBeforeNode + 1;
|
|
2133
|
+
}
|
|
2134
|
+
update() {
|
|
2135
|
+
if (!this.state || !this.state.show) return;
|
|
2136
|
+
let e = this.editor.getBlock(this.state.block.id);
|
|
2137
|
+
if (!e || e.type !== "table" || !this.tableElement?.isConnected) {
|
|
2138
|
+
this.state = void 0, this.tableId = void 0, this.tablePos = void 0, this.tableElement = void 0, this.emitUpdate();
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
this.state.block = e, this.tablePos = this.getTablePos(this.pmView.state.doc);
|
|
2142
|
+
let { height: t, width: n } = ie(this.state.block);
|
|
2143
|
+
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= t && (this.state.rowIndex = t - 1), this.state.colIndex >= n && (this.state.colIndex = n - 1));
|
|
2144
|
+
let r = this.tableElement.querySelector("tbody");
|
|
2145
|
+
if (!r) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
|
|
2146
|
+
if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
|
|
2147
|
+
let e = r.children[this.state.rowIndex].children[this.state.colIndex];
|
|
2148
|
+
e ? this.state.referencePosCell = e.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);
|
|
2149
|
+
}
|
|
2150
|
+
this.state.referencePosTable = r.getBoundingClientRect(), this.emitUpdate();
|
|
2151
|
+
}
|
|
2152
|
+
destroy() {
|
|
2153
|
+
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);
|
|
2154
|
+
}
|
|
2155
|
+
}, Q = new D("TableHandlesPlugin"), sr = T(({ editor: e }) => {
|
|
2156
|
+
let n, r = w(void 0);
|
|
2157
|
+
return {
|
|
2158
|
+
key: "tableHandles",
|
|
2159
|
+
store: r,
|
|
2160
|
+
prosemirrorPlugins: [new E({
|
|
2161
|
+
key: Q,
|
|
2162
|
+
view: (t) => (n = new or(e, t, (e) => {
|
|
2163
|
+
r.setState(e?.block ? {
|
|
2164
|
+
...e,
|
|
2165
|
+
draggingState: e.draggingState ? { ...e.draggingState } : void 0
|
|
2166
|
+
} : void 0);
|
|
2167
|
+
}), n),
|
|
2168
|
+
props: { decorations: (e) => {
|
|
2169
|
+
if (n === void 0 || n.state === void 0 || n.state.draggingState === void 0) return;
|
|
2170
|
+
let r = n.getTablePos(e.doc);
|
|
2171
|
+
if (r === void 0) return;
|
|
2172
|
+
let i = n.state.draggingState.draggedCellOrientation === "row" ? n.state.rowIndex : n.state.colIndex;
|
|
2173
|
+
if (i === void 0) return;
|
|
2174
|
+
let a = [], { block: o, draggingState: s } = n.state, { originalIndex: l, draggedCellOrientation: u } = s, d = o && i !== l ? u === "row" ? t(o, i) : c(o, i) : [];
|
|
2175
|
+
if (i === l || !o || u === "row" && !_(o, l, i, d) || u === "col" && !oe(o, l, i, d)) return j.create(e.doc, a);
|
|
2176
|
+
let f = e.doc.resolve(r + 1);
|
|
2177
|
+
return n.state.draggingState.draggedCellOrientation === "row" ? d.forEach(({ row: t, col: n }) => {
|
|
2178
|
+
let r = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(r.posAtIndex(n) + 1), s = o.node(), c = o.pos + (i > l ? s.nodeSize - 2 : 0);
|
|
2179
|
+
a.push(A.widget(c, () => {
|
|
2180
|
+
let e = document.createElement("div");
|
|
2181
|
+
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", i > l ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
|
|
2182
|
+
}));
|
|
2183
|
+
}) : d.forEach(({ row: t, col: n }) => {
|
|
2184
|
+
let r = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(r.posAtIndex(n) + 1), s = o.node(), c = o.pos + (i > l ? s.nodeSize - 2 : 0);
|
|
2185
|
+
a.push(A.widget(c, () => {
|
|
2186
|
+
let e = document.createElement("div");
|
|
2187
|
+
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", i > l ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
|
|
2188
|
+
}));
|
|
2189
|
+
}), j.create(e.doc, a);
|
|
2190
|
+
} }
|
|
2191
|
+
})],
|
|
2192
|
+
colDragStart(t) {
|
|
2193
|
+
if (n === void 0 || n.state === void 0 || n.state.colIndex === void 0) throw Error("Attempted to drag table column, but no table block was hovered prior.");
|
|
2194
|
+
n.state.draggingState = {
|
|
2195
|
+
draggedCellOrientation: "col",
|
|
2196
|
+
originalIndex: n.state.colIndex,
|
|
2197
|
+
mousePos: t.clientX
|
|
2198
|
+
}, n.emitUpdate(), e.transact((e) => e.setMeta(Q, {
|
|
2199
|
+
draggedCellOrientation: n.state.draggingState.draggedCellOrientation,
|
|
2200
|
+
originalIndex: n.state.colIndex,
|
|
2201
|
+
newIndex: n.state.colIndex,
|
|
2202
|
+
tablePos: n.tablePos
|
|
2203
|
+
})), !e.headless && (nr(e.prosemirrorView.root), t.dataTransfer.setDragImage(X, 0, 0), t.dataTransfer.effectAllowed = "move");
|
|
2204
|
+
},
|
|
2205
|
+
rowDragStart(t) {
|
|
2206
|
+
if (n.state === void 0 || n.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
2207
|
+
n.state.draggingState = {
|
|
2208
|
+
draggedCellOrientation: "row",
|
|
2209
|
+
originalIndex: n.state.rowIndex,
|
|
2210
|
+
mousePos: t.clientY
|
|
2211
|
+
}, n.emitUpdate(), e.transact((e) => e.setMeta(Q, {
|
|
2212
|
+
draggedCellOrientation: n.state.draggingState.draggedCellOrientation,
|
|
2213
|
+
originalIndex: n.state.rowIndex,
|
|
2214
|
+
newIndex: n.state.rowIndex,
|
|
2215
|
+
tablePos: n.tablePos
|
|
2216
|
+
})), !e.headless && (nr(e.prosemirrorView.root), t.dataTransfer.setDragImage(X, 0, 0), t.dataTransfer.effectAllowed = "copyMove");
|
|
2217
|
+
},
|
|
2218
|
+
dragEnd() {
|
|
2219
|
+
if (n.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
2220
|
+
n.state.draggingState = void 0, n.emitUpdate(), e.transact((e) => e.setMeta(Q, null)), !e.headless && rr(e.prosemirrorView.root);
|
|
2221
|
+
},
|
|
2222
|
+
freezeHandles() {
|
|
2223
|
+
n.menuFrozen = !0;
|
|
2224
|
+
},
|
|
2225
|
+
unfreezeHandles() {
|
|
2226
|
+
n.menuFrozen = !1;
|
|
2227
|
+
},
|
|
2228
|
+
hideHandlesIfNotFrozen() {
|
|
2229
|
+
n.menuFrozen || n.hideHandles();
|
|
2230
|
+
},
|
|
2231
|
+
getCellsAtRowHandle(e, n) {
|
|
2232
|
+
return t(e, n);
|
|
2233
|
+
},
|
|
2234
|
+
getCellsAtColumnHandle(e, t) {
|
|
2235
|
+
return c(e, t);
|
|
2236
|
+
},
|
|
2237
|
+
setCellSelection(e, t, r = t) {
|
|
2238
|
+
if (!n) throw Error("Table handles view not initialized");
|
|
2239
|
+
let i = n.getTablePos(e.doc);
|
|
2240
|
+
if (i === void 0) throw Error("Attempted to select table cells, but the hovered table is no longer in the document.");
|
|
2241
|
+
let a = e.doc.resolve(i + 1), o = e.doc.resolve(a.posAtIndex(t.row) + 1), s = e.doc.resolve(o.posAtIndex(t.col)), c = e.doc.resolve(a.posAtIndex(r.row) + 1), l = e.doc.resolve(c.posAtIndex(r.col)), u = e.tr;
|
|
2242
|
+
return u.setSelection(new xe(s, l)), e.apply(u);
|
|
2243
|
+
},
|
|
2244
|
+
addRowOrColumn(t, n) {
|
|
2245
|
+
e.exec((e, r) => {
|
|
2246
|
+
let i = this.setCellSelection(e, n.orientation === "row" ? {
|
|
2247
|
+
row: t,
|
|
2248
|
+
col: 0
|
|
2249
|
+
} : {
|
|
2250
|
+
row: 0,
|
|
2251
|
+
col: t
|
|
2252
|
+
});
|
|
2253
|
+
return n.orientation === "row" ? n.side === "above" ? Te(i, r) : we(i, r) : n.side === "left" ? Ce(i, r) : Se(i, r);
|
|
2254
|
+
});
|
|
2255
|
+
},
|
|
2256
|
+
removeRowOrColumn(t, n) {
|
|
2257
|
+
return n === "row" ? e.exec((e, n) => {
|
|
2258
|
+
let r = this.setCellSelection(e, {
|
|
2259
|
+
row: t,
|
|
2260
|
+
col: 0
|
|
2261
|
+
});
|
|
2262
|
+
return De(r, n);
|
|
2263
|
+
}) : e.exec((e, n) => {
|
|
2264
|
+
let r = this.setCellSelection(e, {
|
|
2265
|
+
row: 0,
|
|
2266
|
+
col: t
|
|
2267
|
+
});
|
|
2268
|
+
return Ee(r, n);
|
|
2269
|
+
});
|
|
2270
|
+
},
|
|
2271
|
+
mergeCells(t) {
|
|
2272
|
+
return e.exec((e, n) => {
|
|
2273
|
+
let r = t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e;
|
|
2274
|
+
return Oe(r, n);
|
|
2275
|
+
});
|
|
2276
|
+
},
|
|
2277
|
+
splitCell(t) {
|
|
2278
|
+
return e.exec((e, n) => {
|
|
2279
|
+
let r = t ? this.setCellSelection(e, t) : e;
|
|
2280
|
+
return ke(r, n);
|
|
2281
|
+
});
|
|
2282
|
+
},
|
|
2283
|
+
getCellSelection() {
|
|
2284
|
+
return e.transact((e) => {
|
|
2285
|
+
let t = e.selection, n = t.$from, r = t.$to;
|
|
2286
|
+
if (y(t)) {
|
|
2287
|
+
let { ranges: e } = t;
|
|
2288
|
+
e.forEach((e) => {
|
|
2289
|
+
n = e.$from.min(n ?? e.$from), r = e.$to.max(r ?? e.$to);
|
|
2290
|
+
});
|
|
2291
|
+
} else {
|
|
2292
|
+
let i = t.$from.pos - t.$from.parentOffset - 1, a = t.$to.pos - t.$to.parentOffset - 1;
|
|
2293
|
+
if (i < 0 || a < 0 || (n = e.doc.resolve(i), r = e.doc.resolve(a), !v(n.parent) || !v(r.parent))) return;
|
|
2294
|
+
}
|
|
2295
|
+
let i = e.doc.resolve(n.pos - n.parentOffset - 1), a = e.doc.resolve(r.pos - r.parentOffset - 1), o = e.doc.resolve(i.pos - i.parentOffset - 1), s = n.index(i.depth), c = i.index(o.depth), l = r.index(a.depth), u = a.index(o.depth), d = [];
|
|
2296
|
+
for (let e = c; e <= u; e++) for (let t = s; t <= l; t++) d.push({
|
|
2297
|
+
row: e,
|
|
2298
|
+
col: t
|
|
2299
|
+
});
|
|
2300
|
+
return {
|
|
2301
|
+
from: {
|
|
2302
|
+
row: c,
|
|
2303
|
+
col: s
|
|
2304
|
+
},
|
|
2305
|
+
to: {
|
|
2306
|
+
row: u,
|
|
2307
|
+
col: l
|
|
2308
|
+
},
|
|
2309
|
+
cells: d
|
|
2310
|
+
};
|
|
2311
|
+
});
|
|
2312
|
+
},
|
|
2313
|
+
getMergeDirection(t) {
|
|
2314
|
+
return e.transact((e) => {
|
|
2315
|
+
let n = y(e.selection) ? e.selection : void 0;
|
|
2316
|
+
if (!n || !t || n.ranges.length <= 1) return;
|
|
2317
|
+
let r = this.getCellSelection();
|
|
2318
|
+
if (r) return re(r.from, r.to, t) ? "vertical" : "horizontal";
|
|
2319
|
+
});
|
|
2320
|
+
},
|
|
2321
|
+
cropEmptyRowsOrColumns(e, t) {
|
|
2322
|
+
return ae(e, t);
|
|
2323
|
+
},
|
|
2324
|
+
addRowsOrColumns(e, t, n) {
|
|
2325
|
+
return h(e, t, n);
|
|
2326
|
+
}
|
|
2327
|
+
};
|
|
2328
|
+
}), $ = new D("trailingNode");
|
|
2329
|
+
function cr(e) {
|
|
2330
|
+
let t = e.lastChild, n = t?.firstChild;
|
|
2331
|
+
return t?.type.name !== "blockContainer" || n?.type.name !== "paragraph" || n.content.size !== 0;
|
|
2332
|
+
}
|
|
2333
|
+
function lr(e) {
|
|
2334
|
+
if (!e.type.schema.nodes.column) {
|
|
2335
|
+
let t = e.lastChild;
|
|
2336
|
+
return t && cr(t) ? [e.content.size - 1] : [];
|
|
2337
|
+
}
|
|
2338
|
+
let t = [];
|
|
2339
|
+
return e.descendants((e, n, r) => !e.isTextblock && ((e.type.name === "column" || e.type.name === "blockGroup" && r?.type.name === "doc") && cr(e) && t.push(n + e.nodeSize - 1), !0)), t;
|
|
2340
|
+
}
|
|
2341
|
+
var ur = T(({ editor: e }) => {
|
|
2342
|
+
function t(t) {
|
|
2343
|
+
return A.widget(t, () => {
|
|
2344
|
+
let t = document.createElement("div");
|
|
2345
|
+
return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (n) => {
|
|
2346
|
+
n.preventDefault();
|
|
2347
|
+
let r = e.prosemirrorView;
|
|
2348
|
+
if (!r) return;
|
|
2349
|
+
let i = r.state.doc.resolve(r.posAtDOM(t, 0)).parent.lastChild?.attrs.id;
|
|
2350
|
+
i && (e.transact((t) => {
|
|
2351
|
+
let [n] = e.insertBlocks([{ type: "paragraph" }], i, "after");
|
|
2352
|
+
e.setTextCursorPosition(n, "start"), t.scrollIntoView();
|
|
2353
|
+
}), r.focus());
|
|
2354
|
+
}), t;
|
|
2355
|
+
}, { side: 1 });
|
|
2356
|
+
}
|
|
2357
|
+
function n(e, n, r) {
|
|
2358
|
+
let i = n.map(e.mapping, e.doc), a = new Set(r ? lr(e.doc) : []), o = /* @__PURE__ */ new Set(), s = [];
|
|
2359
|
+
for (let e of i.find()) a.has(e.from) && !o.has(e.from) ? o.add(e.from) : s.push(e);
|
|
2360
|
+
let c = [...a].filter((e) => !o.has(e)), l = i;
|
|
2361
|
+
return s.length > 0 && (l = l.remove(s)), c.length > 0 && (l = l.add(e.doc, c.map(t))), l;
|
|
2362
|
+
}
|
|
2363
|
+
return {
|
|
2364
|
+
key: "trailingNode",
|
|
2365
|
+
prosemirrorPlugins: [new E({
|
|
2366
|
+
key: $,
|
|
2367
|
+
state: {
|
|
2368
|
+
init: (t, r) => n(r.tr, j.empty, e.isEditable),
|
|
2369
|
+
apply: (t, r) => !t.docChanged && !t.getMeta($) ? r : n(t, r, e.isEditable)
|
|
2370
|
+
},
|
|
2371
|
+
view(e) {
|
|
2372
|
+
let t = e.editable;
|
|
2373
|
+
return { update(e) {
|
|
2374
|
+
e.editable !== t && (t = e.editable, e.dispatch(e.state.tr.setMeta($, !0)));
|
|
2375
|
+
} };
|
|
2376
|
+
},
|
|
2377
|
+
props: {
|
|
2378
|
+
decorations: (e) => $.getState(e),
|
|
2379
|
+
handleKeyDown: (t, n) => {
|
|
2380
|
+
if (n.key !== "ArrowRight" && n.key !== "ArrowDown") return !1;
|
|
2381
|
+
let { selection: r } = t.state;
|
|
2382
|
+
if (!r.empty) return !1;
|
|
2383
|
+
let i = O.atEnd(t.state.doc);
|
|
2384
|
+
if (r.$head.pos !== i.$head.pos) return !1;
|
|
2385
|
+
let a = t.state.doc.lastChild;
|
|
2386
|
+
return !e.isEditable || !a || !cr(a) ? !1 : (n.preventDefault(), !0);
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
})]
|
|
2390
|
+
};
|
|
2391
|
+
});
|
|
2392
|
+
// src/extensions/Versioning/versioningState.ts
|
|
2393
|
+
function dr(e) {
|
|
2394
|
+
return [...new Map(e.map((e) => [e.id, e])).values()].sort((e, t) => t.createdAt - e.createdAt);
|
|
2395
|
+
}
|
|
2396
|
+
function fr(e, t) {
|
|
2397
|
+
if (t.type === "opened") return {
|
|
2398
|
+
mode: "versions",
|
|
2399
|
+
capturedAt: t.capturedAt,
|
|
2400
|
+
showCurrentVersion: t.showCurrentVersion,
|
|
2401
|
+
restoring: t.restoring,
|
|
2402
|
+
displayed: { type: "current" },
|
|
2403
|
+
history: { status: "pending" }
|
|
2404
|
+
};
|
|
2405
|
+
if (t.type === "closed") return t.restoring ? {
|
|
2406
|
+
mode: "live",
|
|
2407
|
+
restoring: !0
|
|
2408
|
+
} : { mode: "live" };
|
|
2409
|
+
if (e.mode === "live") return t.type === "restoreChanged" ? t.restoring ? {
|
|
2410
|
+
mode: "live",
|
|
2411
|
+
restoring: !0
|
|
2412
|
+
} : { mode: "live" } : e;
|
|
2413
|
+
switch (t.type) {
|
|
2414
|
+
case "historyInvalidated": return {
|
|
2415
|
+
...e,
|
|
2416
|
+
mode: "versions",
|
|
2417
|
+
history: {
|
|
2418
|
+
status: "success",
|
|
2419
|
+
data: e.history.data ?? []
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2422
|
+
case "historyStarted": return {
|
|
2423
|
+
...e,
|
|
2424
|
+
mode: "versions",
|
|
2425
|
+
history: {
|
|
2426
|
+
status: "pending",
|
|
2427
|
+
operation: t.operation,
|
|
2428
|
+
data: e.history.data
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
case "historyFailed": return {
|
|
2432
|
+
...e,
|
|
2433
|
+
mode: "versions",
|
|
2434
|
+
history: {
|
|
2435
|
+
status: "error",
|
|
2436
|
+
operation: t.operation,
|
|
2437
|
+
error: t.error,
|
|
2438
|
+
data: e.history.data
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
case "historyLoaded": return {
|
|
2442
|
+
...e,
|
|
2443
|
+
mode: "versions",
|
|
2444
|
+
nextCursor: t.nextCursor,
|
|
2445
|
+
history: {
|
|
2446
|
+
status: "success",
|
|
2447
|
+
data: dr(t.operation === "refresh" ? t.snapshots : [...e.history.data ?? [], ...t.snapshots])
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
case "selectionStarted": return {
|
|
2451
|
+
...e,
|
|
2452
|
+
pending: {
|
|
2453
|
+
...t.target,
|
|
2454
|
+
compareTo: t.compareTo
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
case "selectionFailed": return {
|
|
2458
|
+
...e,
|
|
2459
|
+
pending: void 0
|
|
2460
|
+
};
|
|
2461
|
+
case "selectionShown": return {
|
|
2462
|
+
...e,
|
|
2463
|
+
displayed: t.target,
|
|
2464
|
+
compareTo: t.compareTo,
|
|
2465
|
+
pending: void 0
|
|
2466
|
+
};
|
|
2467
|
+
case "restoreChanged": return {
|
|
2468
|
+
...e,
|
|
2469
|
+
restoring: t.restoring,
|
|
2470
|
+
pending: t.restoring ? void 0 : e.pending
|
|
2471
|
+
};
|
|
2472
|
+
case "snapshotRenamed": return {
|
|
2473
|
+
...e,
|
|
2474
|
+
mode: "versions",
|
|
2475
|
+
history: {
|
|
2476
|
+
status: "success",
|
|
2477
|
+
data: (e.history.data ?? []).map((e) => e.id === t.id ? {
|
|
2478
|
+
...e,
|
|
2479
|
+
name: t.name
|
|
2480
|
+
} : e)
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
case "snapshotRemoved": return {
|
|
2484
|
+
...e,
|
|
2485
|
+
mode: "versions",
|
|
2486
|
+
history: {
|
|
2487
|
+
status: "success",
|
|
2488
|
+
data: (e.history.data ?? []).filter((e) => e.id !== t.id)
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
case "snapshotCreated": return {
|
|
2492
|
+
...e,
|
|
2493
|
+
mode: "versions",
|
|
2494
|
+
history: {
|
|
2495
|
+
status: "success",
|
|
2496
|
+
data: dr([t.snapshot, ...(e.history.data ?? []).filter((e) => e.id !== t.snapshot.id)])
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
default: return t;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
// src/extensions/Versioning/createVersioning.ts
|
|
2503
|
+
function pr(e) {
|
|
2504
|
+
let t;
|
|
2505
|
+
function n() {
|
|
2506
|
+
t?.abort();
|
|
2507
|
+
}
|
|
2508
|
+
function r() {
|
|
2509
|
+
let n = t, r = new AbortController();
|
|
2510
|
+
t = r;
|
|
2511
|
+
let i = AbortSignal.any([e, r.signal]);
|
|
2512
|
+
return n?.abort(), {
|
|
2513
|
+
signal: i,
|
|
2514
|
+
cancel() {
|
|
2515
|
+
r.abort();
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2519
|
+
return {
|
|
2520
|
+
start: r,
|
|
2521
|
+
cancel: n
|
|
2522
|
+
};
|
|
2523
|
+
}
|
|
2524
|
+
function mr(e) {
|
|
2525
|
+
let { adapter: t, setReadOnly: n } = e, r = new se({ mode: "live" }), i, a = !1, o = !1;
|
|
2526
|
+
function s(e) {
|
|
2527
|
+
let t = r.state, n = fr(t, e);
|
|
2528
|
+
return n !== t && r.setState(n), n;
|
|
2529
|
+
}
|
|
2530
|
+
function c(e, t) {
|
|
2531
|
+
if (!e.aborted) return s(t);
|
|
2532
|
+
}
|
|
2533
|
+
function l() {
|
|
2534
|
+
if (a) throw Error("Versioning has been disposed");
|
|
2535
|
+
if (o) return !1;
|
|
2536
|
+
if (i) return !0;
|
|
2537
|
+
try {
|
|
2538
|
+
n(!0);
|
|
2539
|
+
let r = t.open(), a = new AbortController();
|
|
2540
|
+
i = {
|
|
2541
|
+
view: r,
|
|
2542
|
+
lifetime: a,
|
|
2543
|
+
selection: pr(a.signal),
|
|
2544
|
+
history: pr(a.signal)
|
|
2545
|
+
}, s({
|
|
2546
|
+
type: "opened",
|
|
2547
|
+
capturedAt: i.view.current.capturedAt,
|
|
2548
|
+
showCurrentVersion: e.storage.showCurrentVersion ?? !0,
|
|
2549
|
+
restoring: o
|
|
2550
|
+
});
|
|
2551
|
+
} catch (e) {
|
|
2552
|
+
throw i || n(o), e;
|
|
2553
|
+
}
|
|
2554
|
+
return !0;
|
|
2555
|
+
}
|
|
2556
|
+
function u() {
|
|
2557
|
+
d("discard");
|
|
2558
|
+
}
|
|
2559
|
+
function d(e) {
|
|
2560
|
+
if (!i) return;
|
|
2561
|
+
let t = i;
|
|
2562
|
+
i = void 0, t.lifetime.abort(), t.view.close(e), s({
|
|
2563
|
+
type: "closed",
|
|
2564
|
+
restoring: o
|
|
2565
|
+
}), n(o);
|
|
2566
|
+
}
|
|
2567
|
+
function f() {
|
|
2568
|
+
let e = i;
|
|
2569
|
+
return !e || o ? Promise.resolve({ status: "unavailable" }) : (e.loadingMore = void 0, m(e, { operation: "refresh" }));
|
|
2570
|
+
}
|
|
2571
|
+
function p() {
|
|
2572
|
+
let e = i, t = r.state;
|
|
2573
|
+
return !e || o || t.mode !== "versions" ? Promise.resolve({ status: "unavailable" }) : e.loadingMore ? e.loadingMore : e.historyDirty ? m(e, {
|
|
2574
|
+
operation: "refresh",
|
|
2575
|
+
growPast: t.history.data?.length ?? 0
|
|
2576
|
+
}) : t.history.status === "error" && t.history.operation === "refresh" ? f() : t.nextCursor === void 0 || t.history.status === "pending" ? Promise.resolve({ status: "unavailable" }) : m(e, {
|
|
2577
|
+
operation: "loadMore",
|
|
2578
|
+
cursor: t.nextCursor
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
function m(t, n) {
|
|
2582
|
+
let { signal: r } = t.history.start();
|
|
2583
|
+
c(r, {
|
|
2584
|
+
type: "historyStarted",
|
|
2585
|
+
operation: n.operation
|
|
2586
|
+
});
|
|
2587
|
+
let i = (async () => {
|
|
2588
|
+
try {
|
|
2589
|
+
let i = /* @__PURE__ */ new Map(), a = n.operation === "loadMore" ? n.cursor : void 0;
|
|
2590
|
+
for (;;) {
|
|
2591
|
+
let t = await e.storage.list(r, a);
|
|
2592
|
+
if (r.aborted) return { status: "cancelled" };
|
|
2593
|
+
if (!t.ok) return c(r, {
|
|
2594
|
+
type: "historyFailed",
|
|
2595
|
+
operation: n.operation,
|
|
2596
|
+
error: t.error
|
|
2597
|
+
}), {
|
|
2598
|
+
status: "error",
|
|
2599
|
+
error: t.error
|
|
2600
|
+
};
|
|
2601
|
+
if (a !== void 0 && t.value.nextCursor === a) throw Error("Version history cursor did not advance");
|
|
2602
|
+
for (let e of t.value.snapshots) i.set(e.id, e);
|
|
2603
|
+
if (a = t.value.nextCursor, n.operation === "loadMore" || n.growPast === void 0 || i.size > n.growPast || a === void 0) break;
|
|
2604
|
+
}
|
|
2605
|
+
n.operation === "refresh" && (t.historyDirty = !1);
|
|
2606
|
+
let o = c(r, {
|
|
2607
|
+
type: "historyLoaded",
|
|
2608
|
+
operation: n.operation,
|
|
2609
|
+
snapshots: [...i.values()],
|
|
2610
|
+
nextCursor: a
|
|
2611
|
+
});
|
|
2612
|
+
return r.aborted ? { status: "cancelled" } : o?.mode === "versions" && o.showCurrentVersion === !1 && o.displayed.type === "current" && !o.pending && o.history.data?.[0] ? g({
|
|
2613
|
+
type: "snapshot",
|
|
2614
|
+
id: o.history.data[0].id
|
|
2615
|
+
}) : { status: "done" };
|
|
2616
|
+
} catch (e) {
|
|
2617
|
+
if (r.aborted) return { status: "cancelled" };
|
|
2618
|
+
throw e;
|
|
2619
|
+
} finally {
|
|
2620
|
+
r.aborted || (t.loadingMore = void 0);
|
|
2621
|
+
}
|
|
2622
|
+
})();
|
|
2623
|
+
return n.operation !== "loadMore" && n.growPast === void 0 || r.aborted || (t.loadingMore = i), i;
|
|
2624
|
+
}
|
|
2625
|
+
async function h(t, n, r, i) {
|
|
2626
|
+
let a = e.storage, [o, s] = await Promise.all([n.type === "current" ? {
|
|
2627
|
+
ok: !0,
|
|
2628
|
+
value: t.view.current.content
|
|
2629
|
+
} : a.getContent(n.id, i), r === void 0 ? void 0 : Promise.all([a.getContent(r, i), a.getAttributions?.(n, r, t.view.current.capturedAt, i)])]);
|
|
2630
|
+
if (!o.ok) return o;
|
|
2631
|
+
if (!s) return {
|
|
2632
|
+
ok: !0,
|
|
2633
|
+
value: {
|
|
2634
|
+
content: o.value,
|
|
2635
|
+
target: n
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
let [c, l] = s;
|
|
2639
|
+
return c.ok ? l && !l.ok ? l : {
|
|
2640
|
+
ok: !0,
|
|
2641
|
+
value: {
|
|
2642
|
+
content: o.value,
|
|
2643
|
+
target: n,
|
|
2644
|
+
comparison: {
|
|
2645
|
+
content: c.value,
|
|
2646
|
+
attributions: l?.value
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
} : c;
|
|
2650
|
+
}
|
|
2651
|
+
async function g(n, a) {
|
|
2652
|
+
let s = i;
|
|
2653
|
+
if (!s || o) return { status: "unavailable" };
|
|
2654
|
+
if (n.type === "current" && e.storage.showCurrentVersion === !1) {
|
|
2655
|
+
let e = r.state, t = e.mode === "versions" ? e.history.data?.[0] : void 0;
|
|
2656
|
+
t && (n = {
|
|
2657
|
+
type: "snapshot",
|
|
2658
|
+
id: t.id
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
if (a?.compareTo !== void 0 && !t.supportsComparison) return { status: "unavailable" };
|
|
2662
|
+
let l = s.selection.start(), { signal: u } = l;
|
|
2663
|
+
s.selectionBaseline = a?.compareTo;
|
|
2664
|
+
let d = a?.compareTo;
|
|
2665
|
+
c(u, {
|
|
2666
|
+
type: "selectionStarted",
|
|
2667
|
+
target: n,
|
|
2668
|
+
compareTo: d
|
|
2669
|
+
});
|
|
2670
|
+
try {
|
|
2671
|
+
let e = await h(s, n, d, u);
|
|
2672
|
+
return u.aborted ? { status: "cancelled" } : e.ok ? (s.view.show(e.value), c(u, {
|
|
2673
|
+
type: "selectionShown",
|
|
2674
|
+
target: n,
|
|
2675
|
+
compareTo: d
|
|
2676
|
+
}), { status: "done" }) : (c(u, { type: "selectionFailed" }), {
|
|
2677
|
+
status: "error",
|
|
2678
|
+
error: e.error
|
|
2679
|
+
});
|
|
2680
|
+
} catch (e) {
|
|
2681
|
+
if (u.aborted) return { status: "cancelled" };
|
|
2682
|
+
throw c(u, { type: "selectionFailed" }), l.cancel(), e;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
async function _(t) {
|
|
2686
|
+
let r = i;
|
|
2687
|
+
if (!r || o) return { status: "unavailable" };
|
|
2688
|
+
let a = e.storage;
|
|
2689
|
+
if (!a.restore) return { status: "unavailable" };
|
|
2690
|
+
o = !0;
|
|
2691
|
+
try {
|
|
2692
|
+
r.selection.cancel(), c(r.lifetime.signal, {
|
|
2693
|
+
type: "restoreChanged",
|
|
2694
|
+
restoring: !0
|
|
2695
|
+
});
|
|
2696
|
+
let e = await a.restore(t);
|
|
2697
|
+
return e.ok ? (d("restore"), { status: "done" }) : {
|
|
2698
|
+
status: "error",
|
|
2699
|
+
error: e.error
|
|
2700
|
+
};
|
|
2701
|
+
} finally {
|
|
2702
|
+
o = !1, s({
|
|
2703
|
+
type: "restoreChanged",
|
|
2704
|
+
restoring: !1
|
|
2705
|
+
}), i || n(!1);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
function v(e) {
|
|
2709
|
+
e.history.cancel(), e.loadingMore = void 0, e.historyDirty = !0, c(e.lifetime.signal, { type: "historyInvalidated" });
|
|
2710
|
+
}
|
|
2711
|
+
function y(e, t) {
|
|
2712
|
+
e.lifetime.signal.aborted || (v(e), c(e.lifetime.signal, t));
|
|
2713
|
+
}
|
|
2714
|
+
async function b(t, n) {
|
|
2715
|
+
let r = i, a = e.storage;
|
|
2716
|
+
if (o || !a.rename) return { status: "unavailable" };
|
|
2717
|
+
let s = await a.rename(t, n);
|
|
2718
|
+
return s.ok ? (r && y(r, {
|
|
2719
|
+
type: "snapshotRenamed",
|
|
2720
|
+
id: t,
|
|
2721
|
+
name: n
|
|
2722
|
+
}), { status: "done" }) : {
|
|
2723
|
+
status: "error",
|
|
2724
|
+
error: s.error
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
function x(e, t, n) {
|
|
2728
|
+
return t.displayed.type === "snapshot" && t.displayed.id === n || t.pending?.type === "snapshot" && t.pending.id === n || t.pending !== void 0 && e.selectionBaseline === n || t.compareTo === n;
|
|
2729
|
+
}
|
|
2730
|
+
return {
|
|
2731
|
+
store: r,
|
|
2732
|
+
open: l,
|
|
2733
|
+
close: u,
|
|
2734
|
+
list: f,
|
|
2735
|
+
loadMore: p,
|
|
2736
|
+
select: g,
|
|
2737
|
+
restore: _,
|
|
2738
|
+
rename: b,
|
|
2739
|
+
get canCompare() {
|
|
2740
|
+
return t.supportsComparison;
|
|
2741
|
+
},
|
|
2742
|
+
get historyIncludesBeginning() {
|
|
2743
|
+
return e.storage.historyIncludesBeginning === !0;
|
|
2744
|
+
},
|
|
2745
|
+
get canCreate() {
|
|
2746
|
+
return e.storage.create !== void 0;
|
|
2747
|
+
},
|
|
2748
|
+
get canRename() {
|
|
2749
|
+
return e.storage.rename !== void 0;
|
|
2750
|
+
},
|
|
2751
|
+
get canRestore() {
|
|
2752
|
+
return e.storage.restore !== void 0;
|
|
2753
|
+
},
|
|
2754
|
+
get canRemove() {
|
|
2755
|
+
return e.storage.remove !== void 0;
|
|
2756
|
+
},
|
|
2757
|
+
async create(t) {
|
|
2758
|
+
let n = i, r = e.storage;
|
|
2759
|
+
if (!n || o || !r.create) return { status: "unavailable" };
|
|
2760
|
+
let a = n.view.current, s = await r.create(a.content, t, a.capturedAt);
|
|
2761
|
+
return s.ok ? (y(n, {
|
|
2762
|
+
type: "snapshotCreated",
|
|
2763
|
+
snapshot: s.value
|
|
2764
|
+
}), { status: "done" }) : {
|
|
2765
|
+
status: "error",
|
|
2766
|
+
error: s.error
|
|
2767
|
+
};
|
|
2768
|
+
},
|
|
2769
|
+
async remove(t) {
|
|
2770
|
+
let n = i, a = e.storage;
|
|
2771
|
+
if (!n || o || !a.remove) return { status: "unavailable" };
|
|
2772
|
+
let s = await a.remove(t);
|
|
2773
|
+
if (!s.ok) return {
|
|
2774
|
+
status: "error",
|
|
2775
|
+
error: s.error
|
|
2776
|
+
};
|
|
2777
|
+
if (!n.lifetime.signal.aborted) {
|
|
2778
|
+
let e = r.state.mode === "versions" && r.state.history.data === void 0;
|
|
2779
|
+
y(n, {
|
|
2780
|
+
type: "snapshotRenamed",
|
|
2781
|
+
id: t
|
|
2782
|
+
});
|
|
2783
|
+
let i;
|
|
2784
|
+
try {
|
|
2785
|
+
i = await a.getContent(t, n.lifetime.signal);
|
|
2786
|
+
} catch (e) {
|
|
2787
|
+
let t = n.lifetime.signal;
|
|
2788
|
+
if (t.aborted && (e === t.reason || e instanceof DOMException && e.name === "AbortError")) return { status: "done" };
|
|
2789
|
+
throw e;
|
|
2790
|
+
}
|
|
2791
|
+
if (!n.lifetime.signal.aborted && !i.ok && i.error.type === "not-found") {
|
|
2792
|
+
v(n), c(n.lifetime.signal, {
|
|
2793
|
+
type: "snapshotRemoved",
|
|
2794
|
+
id: t
|
|
2795
|
+
});
|
|
2796
|
+
let e = r.state;
|
|
2797
|
+
e.mode === "versions" && x(n, e, t) && await g(e.displayed.type === "snapshot" && e.displayed.id === t || e.pending?.type === "snapshot" && e.pending.id === t ? { type: "current" } : e.displayed);
|
|
2798
|
+
}
|
|
2799
|
+
e && !n.lifetime.signal.aborted && await f();
|
|
2800
|
+
}
|
|
2801
|
+
return { status: "done" };
|
|
2802
|
+
},
|
|
2803
|
+
dispose() {
|
|
2804
|
+
a = !0, u();
|
|
2805
|
+
}
|
|
2806
|
+
};
|
|
2807
|
+
}
|
|
2808
|
+
// src/extensions/Versioning/scrollToFirstChange.ts
|
|
2809
|
+
var hr = 1500, gr = 200;
|
|
2810
|
+
function _r(e) {
|
|
2811
|
+
let { width: t, height: n } = e.getBoundingClientRect();
|
|
2812
|
+
return t !== 0 || n !== 0;
|
|
2813
|
+
}
|
|
2814
|
+
function vr(e) {
|
|
2815
|
+
for (let t = e; t; t = t.firstElementChild) if (_r(t)) return t;
|
|
2816
|
+
}
|
|
2817
|
+
function yr(e, t) {
|
|
2818
|
+
for (let n = e.parentElement; n && n !== t && t.contains(n); n = n.parentElement) if (_r(n)) return n;
|
|
2819
|
+
}
|
|
2820
|
+
var br;
|
|
2821
|
+
function xr(e) {
|
|
2822
|
+
br?.cancel(), br = e.animate?.([{
|
|
2823
|
+
backgroundColor: "color-mix(in srgb, #3e5de7 14%, transparent)",
|
|
2824
|
+
boxShadow: "0 0 0 1px color-mix(in srgb, #3e5de7 45%, transparent)",
|
|
2825
|
+
borderRadius: "4px",
|
|
2826
|
+
easing: "ease-out"
|
|
2827
|
+
}, {
|
|
2828
|
+
backgroundColor: "transparent",
|
|
2829
|
+
boxShadow: "0 0 0 1px transparent",
|
|
2830
|
+
borderRadius: "4px"
|
|
2831
|
+
}], {
|
|
2832
|
+
duration: hr,
|
|
2833
|
+
fill: "none"
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
function Sr() {
|
|
2837
|
+
return typeof window < "u" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1);
|
|
2838
|
+
}
|
|
2839
|
+
function Cr(e, t) {
|
|
2840
|
+
if (t?.enabled === !1) return;
|
|
2841
|
+
let n = setTimeout(() => {
|
|
2842
|
+
(!t?.isCurrent || t.isCurrent()) && wr(e());
|
|
2843
|
+
}, 200);
|
|
2844
|
+
return () => clearTimeout(n);
|
|
2845
|
+
}
|
|
2846
|
+
function wr(e) {
|
|
2847
|
+
if (!e) return !1;
|
|
2848
|
+
let t, n;
|
|
2849
|
+
for (let r of e.querySelectorAll("[data-user-ids]")) if (t ??= r, n = vr(r), n) break;
|
|
2850
|
+
return n ??= t ? yr(t, e) : void 0, n ? (n = n.querySelector(".bn-block-content") ?? n, n.scrollIntoView({
|
|
2851
|
+
block: "center",
|
|
2852
|
+
behavior: Sr() ? "auto" : "smooth"
|
|
2853
|
+
}), xr(n.closest(".bn-block-content") ?? n), !0) : !1;
|
|
2854
|
+
}
|
|
2855
|
+
// src/extensions/Versioning/Versioning.ts
|
|
2856
|
+
function Tr(e) {
|
|
2857
|
+
return T(({ editor: t }) => {
|
|
2858
|
+
let n;
|
|
2859
|
+
t.on("create", () => {
|
|
2860
|
+
let r = e(t);
|
|
2861
|
+
n = {
|
|
2862
|
+
...r,
|
|
2863
|
+
userStore: le(r.resolveUsers)
|
|
2864
|
+
};
|
|
2865
|
+
});
|
|
2866
|
+
function r() {
|
|
2867
|
+
if (!n) throw Error("Versioning must be installed during editor construction");
|
|
2868
|
+
return n;
|
|
2869
|
+
}
|
|
2870
|
+
let i = !1, a = mr({
|
|
2871
|
+
get storage() {
|
|
2872
|
+
return r().storage;
|
|
2873
|
+
},
|
|
2874
|
+
adapter: {
|
|
2875
|
+
get supportsComparison() {
|
|
2876
|
+
return r().adapter.supportsComparison;
|
|
2877
|
+
},
|
|
2878
|
+
open() {
|
|
2879
|
+
i = !0;
|
|
2880
|
+
try {
|
|
2881
|
+
let e = r(), n = t.unregisterExtension(["history", "yUndo"]), o;
|
|
2882
|
+
try {
|
|
2883
|
+
o = e.adapter.open();
|
|
2884
|
+
} catch (e) {
|
|
2885
|
+
throw t.registerExtension(n), e;
|
|
2886
|
+
}
|
|
2887
|
+
let s, c = !1;
|
|
2888
|
+
return {
|
|
2889
|
+
current: o.current,
|
|
2890
|
+
show(n) {
|
|
2891
|
+
s?.(), s = void 0, o.show(n), n.comparison && !c && (s = Cr(() => t.domElement, {
|
|
2892
|
+
enabled: e.scrollToFirstChange,
|
|
2893
|
+
isCurrent: () => a.store.state.mode === "versions" && a.store.state.pending === void 0 && !a.store.state.restoring
|
|
2894
|
+
}));
|
|
2895
|
+
},
|
|
2896
|
+
close(e = "discard") {
|
|
2897
|
+
if (!c) {
|
|
2898
|
+
c = !0, s?.(), s = void 0, e === "restore" && (i = !1);
|
|
2899
|
+
try {
|
|
2900
|
+
o.close(e), t.registerExtension(n);
|
|
2901
|
+
} finally {
|
|
2902
|
+
i = !1;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
} catch (e) {
|
|
2908
|
+
throw i = !1, e;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
},
|
|
2912
|
+
setReadOnly(e) {
|
|
2913
|
+
let n = t.getExtension(L);
|
|
2914
|
+
if (!n) throw Error("Versioning requires the ReadOnly extension");
|
|
2915
|
+
n.setReadOnly(e, "versioning");
|
|
2916
|
+
}
|
|
2917
|
+
});
|
|
2918
|
+
return Er(a, {
|
|
2919
|
+
key: "versioning",
|
|
2920
|
+
get isPreviewOpen() {
|
|
2921
|
+
return i;
|
|
2922
|
+
},
|
|
2923
|
+
get userStore() {
|
|
2924
|
+
return r().userStore;
|
|
2925
|
+
},
|
|
2926
|
+
mount() {
|
|
2927
|
+
let e = t.getExtension(bt), n, r = a.store.subscribe(({ currentVal: t }) => {
|
|
2928
|
+
t.mode === "versions" && t.pending !== void 0 ? n ??= e?.acquire() : (n?.(), n = void 0);
|
|
2929
|
+
});
|
|
2930
|
+
return () => {
|
|
2931
|
+
a.close(), r(), n?.();
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2937
|
+
function Er(e, t) {
|
|
2938
|
+
return Object.defineProperties(e, Object.getOwnPropertyDescriptors(t));
|
|
2939
|
+
}
|
|
2940
|
+
// src/extensions/Versioning/inMemoryVersioning.ts
|
|
2941
|
+
function Dr(e) {
|
|
2942
|
+
return function({ editor: t }) {
|
|
2943
|
+
let n = Tr(() => ({
|
|
2944
|
+
...Or(t, e),
|
|
2945
|
+
resolveUsers: e?.resolveUsers,
|
|
2946
|
+
scrollToFirstChange: e?.scrollToFirstChange
|
|
2947
|
+
}))()({ editor: t });
|
|
2948
|
+
return Object.assign(n, { [ce]: Dr }), n;
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
function Or(e, t) {
|
|
2952
|
+
let n, r, i = 0, a = /* @__PURE__ */ new Map();
|
|
2953
|
+
for (let n of t?.initialVersions ?? []) {
|
|
2954
|
+
let t = {
|
|
2955
|
+
id: String(++i),
|
|
2956
|
+
name: n.name,
|
|
2957
|
+
createdAt: n.createdAt
|
|
2958
|
+
}, r = n.content, o = Array.isArray(r) ? e.pmSchema.topNodeType.createChecked(null, e.pmSchema.nodes.blockGroup.createChecked(null, r.map((t) => C(t, e.pmSchema, e.schema.styleSchema)))) : e.pmSchema.nodeFromJSON(r);
|
|
2959
|
+
if (o.type !== e.pmSchema.topNodeType) throw Error("Version content must be a ProseMirror document");
|
|
2960
|
+
o.check(), a.set(t.id, {
|
|
2961
|
+
version: t,
|
|
2962
|
+
content: o
|
|
2963
|
+
});
|
|
2964
|
+
}
|
|
2965
|
+
function o(t) {
|
|
2966
|
+
return t.type.schema === e.pmSchema ? t : e.pmSchema.nodeFromJSON(t.toJSON());
|
|
2967
|
+
}
|
|
2968
|
+
return {
|
|
2969
|
+
adapter: {
|
|
2970
|
+
get supportsComparison() {
|
|
2971
|
+
return e.getExtension("diffVersioning") !== void 0;
|
|
2972
|
+
},
|
|
2973
|
+
open() {
|
|
2974
|
+
if (n || e.getExtension("ySync")) throw Error("Local version views require an unbound local editor");
|
|
2975
|
+
n = e.prosemirrorState;
|
|
2976
|
+
let t = {
|
|
2977
|
+
content: n.doc,
|
|
2978
|
+
capturedAt: Date.now()
|
|
2979
|
+
}, i = !1;
|
|
2980
|
+
try {
|
|
2981
|
+
e.prosemirrorView.updateState(me.create({
|
|
2982
|
+
doc: n.doc,
|
|
2983
|
+
selection: n.selection,
|
|
2984
|
+
plugins: n.plugins
|
|
2985
|
+
}));
|
|
2986
|
+
} catch (t) {
|
|
2987
|
+
throw e.prosemirrorView.updateState(n), n = void 0, t;
|
|
2988
|
+
}
|
|
2989
|
+
function a() {
|
|
2990
|
+
if (!i) {
|
|
2991
|
+
if (!n) throw Error("Missing live editor state");
|
|
2992
|
+
e.prosemirrorView.updateState(n.reconfigure({ plugins: e.prosemirrorState.plugins })), i = !0, n = void 0, r = void 0;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
return r = a, {
|
|
2996
|
+
current: t,
|
|
2997
|
+
show({ content: t, comparison: n }) {
|
|
2998
|
+
if (i) throw Error("Version view is closed");
|
|
2999
|
+
let r = e.getExtension("diffVersioning");
|
|
3000
|
+
if (n && r) {
|
|
3001
|
+
r.renderDiff(p(t), p(n.content));
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
let a = o(t);
|
|
3005
|
+
e.transact((e) => {
|
|
3006
|
+
e.replaceWith(0, e.doc.content.size, a.content), e.setMeta("addToHistory", !1);
|
|
3007
|
+
});
|
|
3008
|
+
},
|
|
3009
|
+
close: a
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
},
|
|
3013
|
+
storage: {
|
|
3014
|
+
historyIncludesBeginning: !0,
|
|
3015
|
+
async list(e) {
|
|
3016
|
+
return e.throwIfAborted(), {
|
|
3017
|
+
ok: !0,
|
|
3018
|
+
value: { snapshots: Array.from(a.values(), ({ version: e }) => ({ ...e })).sort((e, t) => t.createdAt - e.createdAt) }
|
|
3019
|
+
};
|
|
3020
|
+
},
|
|
3021
|
+
async getContent(e, t) {
|
|
3022
|
+
t.throwIfAborted();
|
|
3023
|
+
let n = a.get(e);
|
|
3024
|
+
return n ? {
|
|
3025
|
+
ok: !0,
|
|
3026
|
+
value: n.content
|
|
3027
|
+
} : {
|
|
3028
|
+
ok: !1,
|
|
3029
|
+
error: { type: "not-found" }
|
|
3030
|
+
};
|
|
3031
|
+
},
|
|
3032
|
+
async create(e, t) {
|
|
3033
|
+
let n = {
|
|
3034
|
+
id: String(++i),
|
|
3035
|
+
createdAt: Date.now(),
|
|
3036
|
+
name: t
|
|
3037
|
+
};
|
|
3038
|
+
return a.set(n.id, {
|
|
3039
|
+
version: n,
|
|
3040
|
+
content: e
|
|
3041
|
+
}), {
|
|
3042
|
+
ok: !0,
|
|
3043
|
+
value: { ...n }
|
|
3044
|
+
};
|
|
3045
|
+
},
|
|
3046
|
+
async restore(t) {
|
|
3047
|
+
let n = a.get(t);
|
|
3048
|
+
if (!n) return {
|
|
3049
|
+
ok: !1,
|
|
3050
|
+
error: { type: "not-found" }
|
|
3051
|
+
};
|
|
3052
|
+
let i = o(n.content), s = e.getExtension("versioning"), c = s?.isPreviewOpen === !0;
|
|
3053
|
+
return s?.close(), r?.(), e.transact((e) => {
|
|
3054
|
+
e.replaceWith(0, e.doc.content.size, i.content), c && e.setMeta("addToHistory", !1);
|
|
3055
|
+
}), {
|
|
3056
|
+
ok: !0,
|
|
3057
|
+
value: void 0
|
|
3058
|
+
};
|
|
3059
|
+
},
|
|
3060
|
+
async rename(e, t) {
|
|
3061
|
+
let n = a.get(e);
|
|
3062
|
+
return n ? (n.version.name = t, {
|
|
3063
|
+
ok: !0,
|
|
3064
|
+
value: void 0
|
|
3065
|
+
}) : {
|
|
3066
|
+
ok: !1,
|
|
3067
|
+
error: { type: "not-found" }
|
|
3068
|
+
};
|
|
3069
|
+
},
|
|
3070
|
+
async remove(e) {
|
|
3071
|
+
return a.delete(e), {
|
|
3072
|
+
ok: !0,
|
|
3073
|
+
value: void 0
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
}
|
|
3079
|
+
// src/extensions/Versioning/formatVersionDate.ts
|
|
3080
|
+
var kr = /* @__PURE__ */ new Map();
|
|
3081
|
+
function Ar(e, t) {
|
|
3082
|
+
let n = kr.get(t);
|
|
3083
|
+
return n || (n = new Intl.DateTimeFormat(t, {
|
|
3084
|
+
day: "numeric",
|
|
3085
|
+
month: "long",
|
|
3086
|
+
year: "numeric",
|
|
3087
|
+
hour: "numeric",
|
|
3088
|
+
minute: "2-digit"
|
|
3089
|
+
}), kr.set(t, n)), n.format(e);
|
|
3090
|
+
}
|
|
3091
|
+
export { vt as A, Ze as B, rn as C, St as D, wt as E, ut as F, Be as H, dt as I, F as L, gt as M, ht as N, bt as O, ft as P, rt as R, nn as S, Tt as T, M as U, Xe as V, N as W, Kn as _, gr as a, Ln as b, mr as c, or as d, Q as f, qn as g, Jn as h, Tr as i, _t as j, L as k, ur as l, er as m, Dr as n, Cr as o, tr as p, Or as r, wr as s, Ar as t, sr as u, Gn as v, Ot as w, on as x, Rn as y, nt as z };
|