@blocknote/core 0.52.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +2 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
- package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
- package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
- package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
- package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/{blocks-CiuUGa1E.js → blocks-CzQLehlc.js} +695 -652
- package/dist/blocks-CzQLehlc.js.map +1 -0
- package/dist/blocks-CzkqclGj.cjs +12 -0
- package/dist/blocks-CzkqclGj.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +7 -7
- package/dist/comments.js.map +1 -1
- package/dist/en-BuzSuuTq.cjs +2 -0
- package/dist/en-BuzSuuTq.cjs.map +1 -0
- package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
- package/dist/en-uzHzj6eH.js.map +1 -0
- package/dist/extensions-CSB9ZvuL.cjs +58 -0
- package/dist/extensions-CSB9ZvuL.cjs.map +1 -0
- package/dist/{extensions-CrUGDOks.js → extensions-DGuhtOgB.js} +717 -452
- package/dist/extensions-DGuhtOgB.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +199 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-DTF83Cl9.js → src-BkfZVfaO.js} +921 -835
- package/dist/src-BkfZVfaO.js.map +1 -0
- package/dist/src-DM3syMdf.cjs +23 -0
- package/dist/src-DM3syMdf.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +65 -62
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +88 -76
- package/dist/yjs.js.map +1 -1
- package/package.json +29 -30
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +10 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +42 -8
- package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
- package/src/api/exporters/markdown/markdownExporter.ts +10 -1
- package/src/api/nodeConversions/blockToNode.ts +5 -1
- package/src/api/nodeConversions/nodeToBlock.ts +3 -0
- package/src/api/parsers/html/parseHTML.ts +43 -0
- package/src/api/pmUtil.ts +16 -8
- package/src/blocks/Code/CodeBlockOptions.ts +83 -0
- package/src/blocks/Code/block.test.ts +1 -1
- package/src/blocks/Code/block.ts +29 -281
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
- package/src/blocks/Table/TableExtension.test.ts +102 -0
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +16 -5
- package/src/blocks/defaultBlockTypeGuards.ts +6 -0
- package/src/blocks/index.ts +3 -0
- package/src/comments/extension.ts +2 -4
- package/src/editor/Block.css +324 -3
- package/src/editor/BlockNoteEditor.ts +25 -4
- package/src/editor/BlockNoteExtension.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
- package/src/exporter/ExportImage.ts +50 -0
- package/src/exporter/Exporter.test.ts +48 -0
- package/src/exporter/Exporter.ts +46 -12
- package/src/exporter/index.ts +1 -0
- package/src/exporter/mapping.ts +4 -1
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
- package/src/extensions/SideMenu/SideMenu.ts +20 -3
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +118 -0
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +40 -27
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +13 -3
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
- package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
- package/src/extensions/TableHandles/TableHandles.ts +25 -12
- package/src/extensions/TrailingNode/TrailingNode.ts +98 -32
- package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
- package/src/extensions/index.ts +4 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +9 -0
- package/src/i18n/locales/hr.ts +9 -0
- package/src/i18n/locales/is.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +9 -0
- package/src/i18n/locales/no.ts +9 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +9 -0
- package/src/i18n/locales/ru.ts +9 -0
- package/src/i18n/locales/sk.ts +9 -0
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +6 -1
- package/src/schema/blocks/createSpec.ts +17 -5
- package/src/schema/blocks/internal.test.ts +86 -0
- package/src/schema/blocks/internal.ts +64 -0
- package/src/schema/blocks/types.ts +53 -3
- package/src/schema/contentTypePropagation.test.ts +1 -1
- package/src/schema/inlineContent/createSpec.test.ts +161 -0
- package/src/schema/inlineContent/createSpec.ts +180 -13
- package/src/schema/inlineContent/internal.ts +21 -2
- package/src/schema/inlineContent/types.ts +35 -5
- package/src/schema/nodeViewMutations.test.ts +121 -0
- package/src/schema/nodeViewMutations.ts +46 -0
- package/src/user/UserStore.ts +1 -1
- package/src/util/Store.test.ts +132 -0
- package/src/util/Store.ts +135 -0
- package/src/y/extensions/AttributionExtension.test.ts +10 -0
- package/src/y/extensions/Versioning.test.ts +20 -7
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
- package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
- package/src/yjs/extensions/ForkYDoc.ts +26 -1
- package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
- package/src/yjs/extensions/Versioning.test.ts +17 -5
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +13 -0
- package/types/src/api/pmUtil.d.ts +7 -7
- package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
- package/types/src/blocks/Code/block.d.ts +3 -53
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
- package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
- package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
- package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +2 -0
- package/types/src/blocks/index.d.ts +3 -0
- package/types/src/comments/extension.d.ts +1 -15
- package/types/src/editor/BlockNoteEditor.d.ts +3 -3
- package/types/src/editor/BlockNoteExtension.d.ts +1 -1
- package/types/src/exporter/ExportImage.d.ts +36 -0
- package/types/src/exporter/Exporter.d.ts +21 -0
- package/types/src/exporter/Exporter.test.d.ts +1 -0
- package/types/src/exporter/index.d.ts +1 -0
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
- package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
- package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -1
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +7 -11
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +1 -1
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +5 -4
- package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
- package/types/src/extensions/index.d.ts +4 -0
- package/types/src/i18n/locales/en.d.ts +9 -0
- package/types/src/i18n/locales/fa.d.ts +9 -0
- package/types/src/i18n/locales/sk.d.ts +9 -0
- package/types/src/index.d.ts +3 -1
- package/types/src/schema/blocks/internal.d.ts +21 -0
- package/types/src/schema/blocks/internal.test.d.ts +1 -0
- package/types/src/schema/blocks/types.d.ts +36 -3
- package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
- package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +3 -2
- package/types/src/schema/inlineContent/types.d.ts +22 -3
- package/types/src/schema/nodeViewMutations.d.ts +3 -0
- package/types/src/schema/nodeViewMutations.test.d.ts +1 -0
- package/types/src/user/UserStore.d.ts +1 -1
- package/types/src/util/Store.d.ts +45 -0
- package/types/src/util/Store.test.d.ts +1 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
- package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/y/extensions/index.d.ts +2 -10
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/yjs/extensions/index.d.ts +1 -5
- package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
- package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
- package/dist/UserStore-QbbPFj0z.js.map +0 -1
- package/dist/blocks-BqHv0xhc.cjs +0 -12
- package/dist/blocks-BqHv0xhc.cjs.map +0 -1
- package/dist/blocks-CiuUGa1E.js.map +0 -1
- package/dist/en-C5Z4Ag9_.cjs +0 -2
- package/dist/en-C5Z4Ag9_.cjs.map +0 -1
- package/dist/en-CGKXfWma.js.map +0 -1
- package/dist/extensions-CrUGDOks.js.map +0 -1
- package/dist/extensions-Ghr9QqqR.cjs +0 -52
- package/dist/extensions-Ghr9QqqR.cjs.map +0 -1
- package/dist/src-DTF83Cl9.js.map +0 -1
- package/dist/src-OfbaVbMw.cjs +0 -21
- package/dist/src-OfbaVbMw.cjs.map +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
- package/types/src/blocks/Code/shiki.d.ts +0 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("@tiptap/core");var t=`annotation`;function n(n){return n&&n.options.extensions.some(t=>{if(t.type!==`mark`)return!1;let n=(0,e.getExtensionField)(t,`group`);return typeof n==`string`&&n.split(` `).includes(`annotation`)})?t:``}var r=class{listeners=new Set;state;prevState;options;constructor(e,t){this.prevState=e,this.state=e,this.options=t}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});setState(e){this.prevState=this.state,this.state=i(e)?e(this.prevState):e,s(this)}_notify(){let e={prevVal:this.prevState,currentVal:this.state};for(let t of this.listeners)t(e)}};function i(e){return typeof e==`function`}var a=!1,o=new Set;function s(e){o.add(e);let t=!a;a=!0;try{if(e.options?.onUpdate?.(e.state,e.prevState),!t)return;for(;o.size>0;){let e=Array.from(o);o.clear();for(let t of e)t._notify()}}finally{t&&(a=!1,o.clear())}}var c=Symbol(`originalFactory`);function l(e){if(typeof e==`object`&&`key`in e)return function t(){return e[c]=t,e};if(typeof e!=`function`)throw Error(`factory must be a function`);return function t(n){return r=>{let i=e({editor:r.editor,options:n});return i[c]=t,i}}}function u(e,t){return new r(e,t)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
2
|
+
//# sourceMappingURL=BlockNoteExtension-BJCLnwrE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockNoteExtension-BJCLnwrE.cjs","names":[],"sources":["../src/schema/markGroups.ts","../src/util/Store.ts","../src/editor/managers/ExtensionManager/symbol.ts","../src/editor/BlockNoteExtension.ts"],"sourcesContent":["import { Editor, getExtensionField } from \"@tiptap/core\";\n\n/**\n * ProseMirror mark group for \"non-formatting\" marks: comments and the\n * suggestion/diff marks (the AI `insertion`/`deletion`/`modification` marks and\n * the Yjs `y-attributed-*` marks). These annotate content without representing\n * inline formatting and are ignored by BlockNote's content model\n * (`blocknoteIgnore`).\n *\n * They are the only marks allowed on `\"plain\"` blocks (e.g. code blocks), which\n * otherwise disallow all formatting marks. A block references this group rather\n * than the individual marks because each of them comes from an optional\n * extension (comments, AI suggestions, Yjs attribution) and so is only present\n * when that extension is configured.\n */\nexport const NON_FORMATTING_MARK_GROUP = \"annotation\";\n\n/**\n * The `marks` field value for `\"plain\"` blocks (e.g. code blocks), which hold\n * unstyled text and so disallow formatting marks but still allow the\n * non-formatting ones.\n *\n * Every mark in {@link NON_FORMATTING_MARK_GROUP} comes from an optional\n * extension, so a node spec that referenced the group unconditionally would make\n * ProseMirror throw \"Unknown mark type: 'annotation'\" while building the schema\n * of an editor that has none of them registered — an empty mark group is an\n * unknown reference just like a missing mark is. (This mirrors `suggestionMarks`\n * for the block-level suggestion group.)\n *\n * Returns the group name (which ProseMirror expands to every mark in it) when at\n * least one such mark is registered, or `\"\"` otherwise. Evaluated at\n * schema-build time, where the tiptap editor's fully-flattened extension list is\n * available on `this.editor`.\n */\nexport function nonFormattingMarks(editor: Editor | undefined): string {\n if (!editor) {\n return \"\";\n }\n const hasNonFormattingMark = editor.options.extensions.some((extension) => {\n if (extension.type !== \"mark\") {\n return false;\n }\n const group = getExtensionField(extension, \"group\") as string | undefined;\n return (\n typeof group === \"string\" &&\n group.split(\" \").includes(NON_FORMATTING_MARK_GROUP)\n );\n });\n return hasNonFormattingMark ? NON_FORMATTING_MARK_GROUP : \"\";\n}\n","// Vendored from https://github.com/TanStack/store/blob/main/packages/store/src/store.ts (MIT)\n//\n// BlockNote only ever used `Store` — never the `Derived`/`Effect` reactive graph that\n// makes up the rest of `@tanstack/store`, and that graph isn't tree-shakeable because\n// `setState` reaches into the scheduler. Since the `Store` type is part of BlockNote's\n// public API (every extension exposes one), owning these ~40 lines lets us keep that\n// surface stable instead of tracking a 0.x dependency's breaking changes.\n//\n// Behaviour matches `@tanstack/store@0.7.7`, minus the dependency graph and the\n// `updateFn`/`onSubscribe` options, which nothing used. `onUpdate` additionally receives\n// the new and previous state rather than requiring callers to close over the store.\n\n/**\n * The value a {@link Listener} is called with when a {@link Store} updates.\n */\nexport interface ListenerValue<T> {\n readonly prevVal: T;\n readonly currentVal: T;\n}\n\n/**\n * A callback invoked when a {@link Store}'s state changes.\n */\nexport type Listener<T> = (value: ListenerValue<T>) => void;\n\n/**\n * A new state, or a function deriving it from the previous state.\n */\nexport type Updater<T> = T | ((prev: T) => T);\n\nexport interface StoreOptions<TState> {\n /**\n * Called after the state has been updated, before listeners are notified.\n */\n onUpdate?: (state: TState, prevState: TState) => void;\n}\n\n/**\n * A minimal observable state container.\n *\n * Extensions expose one of these as their `store` so that both React (via\n * `useExtensionState`) and vanilla consumers can read and subscribe to their state.\n */\nexport class Store<TState> {\n listeners = new Set<Listener<TState>>();\n state: TState;\n prevState: TState;\n options?: StoreOptions<TState>;\n\n constructor(initialState: TState, options?: StoreOptions<TState>) {\n this.prevState = initialState;\n this.state = initialState;\n this.options = options;\n }\n\n subscribe = (listener: Listener<TState>) => {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /**\n * Update the store state, either with a new state or a function deriving it from the\n * previous one.\n */\n setState(updater: (prevState: TState) => TState): void;\n setState(updater: TState): void;\n setState(updater: Updater<TState>): void {\n this.prevState = this.state;\n this.state = isUpdaterFunction(updater) ? updater(this.prevState) : updater;\n\n flush(this);\n }\n\n /**\n * @internal Only to be called by {@link flush}.\n */\n _notify() {\n const value: ListenerValue<TState> = {\n prevVal: this.prevState,\n currentVal: this.state,\n };\n for (const listener of this.listeners) {\n listener(value);\n }\n }\n}\n\nfunction isUpdaterFunction<T>(updater: Updater<T>): updater is (prev: T) => T {\n return typeof updater === \"function\";\n}\n\n// Both `onUpdate` and listener notification can synchronously trigger further `setState`\n// calls — a callback that dispatches a ProseMirror transaction, for example. Rather than\n// recursing, re-entrant writes are queued and drained by the outermost flush, so a write\n// made during a callback still reaches every listener but the stack stays flat and\n// subscribers see the settled state once.\n//\n// `onUpdate` therefore runs *inside* the flush transaction: the store is queued and the\n// flush is marked in progress before the callback fires, so a nested write it makes is\n// coalesced into this drain rather than starting its own.\nlet isFlushing = false;\nconst pendingUpdates = new Set<Store<any>>();\n\nfunction flush(store: Store<any>) {\n pendingUpdates.add(store);\n\n const isOutermost = !isFlushing;\n isFlushing = true;\n\n try {\n store.options?.onUpdate?.(store.state, store.prevState);\n\n if (!isOutermost) {\n return;\n }\n\n while (pendingUpdates.size > 0) {\n const stores = Array.from(pendingUpdates);\n pendingUpdates.clear();\n for (const pendingStore of stores) {\n pendingStore._notify();\n }\n }\n } finally {\n if (isOutermost) {\n isFlushing = false;\n // A throwing callback would otherwise strand queued stores, letting them notify\n // during an unrelated store's next flush.\n pendingUpdates.clear();\n }\n }\n}\n","/**\n * Symbol used to track the original factory function for extensions.\n * This allows us to retrieve the original factory for comparison and other operations.\n */\nexport const originalFactorySymbol = Symbol(\"originalFactory\");\n","import { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.js\";\nimport { Store, StoreOptions } from \"../util/Store.js\";\nimport type { BlockNoteEditor } from \"./BlockNoteEditor.js\";\nimport { originalFactorySymbol } from \"./managers/ExtensionManager/symbol.js\";\n\n/**\n * This function is called when the extension is destroyed.\n */\ntype OnDestroy = () => void;\n\n/**\n * Describes a BlockNote extension.\n */\nexport interface Extension<State = any, Key extends string = string> {\n /**\n * The unique identifier for the extension.\n */\n readonly key: Key;\n\n /**\n * Triggered when the extension is mounted to the editor.\n */\n readonly mount?: (ctx: {\n /**\n * The DOM element that the editor is mounted to.\n */\n dom: HTMLElement;\n /**\n * The root document of the {@link document} that the editor is mounted to.\n */\n root: Document | ShadowRoot;\n /**\n * An {@link AbortSignal} that will be aborted when the extension is destroyed.\n */\n signal: AbortSignal;\n }) => void | OnDestroy;\n\n /**\n * The store for the extension.\n */\n readonly store?: Store<State>;\n\n /**\n * Declares what {@link Extension}s that this extension depends on.\n */\n readonly runsBefore?: ReadonlyArray<string>;\n\n /**\n * Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\n readonly inputRules?: ReadonlyArray<InputRule>;\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n readonly keyboardShortcuts?: Record<\n string,\n (ctx: { editor: BlockNoteEditor<any, any, any> }) => boolean\n >;\n\n /**\n * Add additional prosemirror plugins to the editor.\n */\n readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;\n\n /**\n * Add additional tiptap extensions to the editor.\n */\n readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;\n\n /**\n * Add additional BlockNote extensions to the editor.\n */\n readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;\n}\n\n/**\n * An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\ntype InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * These are the arguments that are passed to an {@link ExtensionFactoryInstance}.\n */\nexport interface ExtensionOptions<\n Options extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n> {\n options: Options;\n editor: BlockNoteEditor<any, any, any>;\n}\n\n// a type that maps the extension key to the return type of the extension factory\nexport type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {\n [K in T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext[\"key\"]\n : never]: T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext\n : never;\n};\n\n/**\n * This is a type that represents the function which will actually create the extension.\n * It requires the editor instance to be passed in, but will already have the options applied automatically.\n *\n * @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.\n */\nexport type ExtensionFactoryInstance<\n Ext extends Extension<any, any> = Extension<any, any>,\n> = (ctx: Omit<ExtensionOptions<any>, \"options\">) => Ext;\n\n/**\n * This is the return type of the {@link createExtension} function.\n * It is a function that can be invoked with the extension's options to create a new extension factory.\n */\nexport type ExtensionFactory<\n State = any,\n Key extends string = string,\n Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<any>,\n ) => Extension<State, Key>,\n> =\n Parameters<Factory>[0] extends ExtensionOptions<infer Options>\n ? undefined extends Options\n ? (\n options?: Exclude<Options, undefined>,\n ) => ExtensionFactoryInstance<ReturnType<Factory>>\n : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>>\n : () => ExtensionFactoryInstance<ReturnType<Factory>>;\n\n/**\n * Constructs a BlockNote {@link ExtensionFactory} from a factory function or object\n */\n// This overload is for `createExtension({ key: \"test\", ... })`\nexport function createExtension<\n const State = any,\n const Key extends string = string,\n const Ext extends Extension<State, Key> = Extension<State, Key>,\n>(factory: Ext): ExtensionFactoryInstance<Ext>;\n// This overload is for `createExtension(({editor, options}) => ({ key: \"test\", ... }))`\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(factory: Factory): ExtensionFactory<State, Key, Factory>;\n// This overload is for both of the above overloads as it is the implementation of the function\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends\n | Extension<State, Key>\n | ((ctx: any) => Extension<State, Key>) = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(\n factory: Factory,\n): Factory extends Extension<State, Key>\n ? ExtensionFactoryInstance<Factory>\n : Factory extends (ctx: any) => Extension<State, Key>\n ? ExtensionFactory<State, Key, Factory>\n : never {\n if (typeof factory === \"object\" && \"key\" in factory) {\n return function factoryFn() {\n (factory as any)[originalFactorySymbol] = factoryFn;\n return factory;\n } as any;\n }\n\n if (typeof factory !== \"function\") {\n throw new Error(\"factory must be a function\");\n }\n\n return function factoryFn(options: Options) {\n return (ctx: { editor: BlockNoteEditor<any, any, any> }) => {\n const extension = factory({ editor: ctx.editor, options });\n // We stick a symbol onto the extension to allow us to retrieve the original factory for comparison later.\n // This enables us to do things like: `editor.getExtension(YSync).prosemirrorPlugins`\n (extension as any)[originalFactorySymbol] = factoryFn;\n return extension;\n };\n } as any;\n}\n\nexport function createStore<T = any>(\n initialState: T,\n options?: StoreOptions<T>,\n): Store<T> {\n return new Store(initialState, options);\n}\n"],"mappings":"8BAeA,IAAa,EAA4B,aAmBzC,SAAgB,EAAmB,EAAoC,CAcrE,OAbK,GAGwB,EAAO,QAAQ,WAAW,KAAM,GAAc,CACzE,GAAI,EAAU,OAAS,OACrB,MAAO,GAET,IAAM,GAAA,EAAQ,EAAA,kBAAA,CAAkB,EAAW,OAAO,EAClD,OACE,OAAO,GAAU,UACjB,EAAM,MAAM,GAAG,CAAC,CAAC,SAAA,YAAkC,CAEvD,CACO,EAAuB,EAA4B,EAC5D,CCNA,IAAa,EAAb,KAA2B,CACzB,UAAY,IAAI,IAChB,MACA,UACA,QAEA,YAAY,EAAsB,EAAgC,CAChE,KAAK,UAAY,EACjB,KAAK,MAAQ,EACb,KAAK,QAAU,CACjB,CAEA,UAAa,IACX,KAAK,UAAU,IAAI,CAAQ,MAEd,CACX,KAAK,UAAU,OAAO,CAAQ,CAChC,GASF,SAAS,EAAgC,CACvC,KAAK,UAAY,KAAK,MACtB,KAAK,MAAQ,EAAkB,CAAO,EAAI,EAAQ,KAAK,SAAS,EAAI,EAEpE,EAAM,IAAI,CACZ,CAKA,SAAU,CACR,IAAM,EAA+B,CACnC,QAAS,KAAK,UACd,WAAY,KAAK,KACnB,EACA,IAAK,IAAM,KAAY,KAAK,UAC1B,EAAS,CAAK,CAElB,CACF,EAEA,SAAS,EAAqB,EAAgD,CAC5E,OAAO,OAAO,GAAY,UAC5B,CAWA,IAAI,EAAa,GACX,EAAiB,IAAI,IAE3B,SAAS,EAAM,EAAmB,CAChC,EAAe,IAAI,CAAK,EAExB,IAAM,EAAc,CAAC,EACrB,EAAa,GAEb,GAAI,CAGF,GAFA,EAAM,SAAS,WAAW,EAAM,MAAO,EAAM,SAAS,EAElD,CAAC,EACH,OAGF,KAAO,EAAe,KAAO,GAAG,CAC9B,IAAM,EAAS,MAAM,KAAK,CAAc,EACxC,EAAe,MAAM,EACrB,IAAK,IAAM,KAAgB,EACzB,EAAa,QAAQ,CAEzB,CACF,QAAU,CACJ,IACF,EAAa,GAGb,EAAe,MAAM,EAEzB,CACF,CClIA,IAAa,EAAwB,OAAO,iBAAiB,ECiM7D,SAAgB,EAUd,EAKU,CACV,GAAI,OAAO,GAAY,UAAY,QAAS,EAC1C,OAAO,SAAS,GAAY,CAE1B,MADA,GAAiB,GAAyB,EACnC,CACT,EAGF,GAAI,OAAO,GAAY,WACrB,MAAU,MAAM,4BAA4B,EAG9C,OAAO,SAAS,EAAU,EAAkB,CAC1C,MAAQ,IAAoD,CAC1D,IAAM,EAAY,EAAQ,CAAE,OAAQ,EAAI,OAAQ,SAAQ,CAAC,EAIzD,MADA,GAAmB,GAAyB,EACrC,CACT,CACF,CACF,CAEA,SAAgB,EACd,EACA,EACU,CACV,OAAO,IAAI,EAAM,EAAc,CAAO,CACxC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getExtensionField as e } from "@tiptap/core";
|
|
2
|
+
//#region src/schema/markGroups.ts
|
|
3
|
+
var t = "annotation";
|
|
4
|
+
function n(n) {
|
|
5
|
+
return n && n.options.extensions.some((t) => {
|
|
6
|
+
if (t.type !== "mark") return !1;
|
|
7
|
+
let n = e(t, "group");
|
|
8
|
+
return typeof n == "string" && n.split(" ").includes("annotation");
|
|
9
|
+
}) ? t : "";
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/util/Store.ts
|
|
13
|
+
var r = class {
|
|
14
|
+
listeners = /* @__PURE__ */ new Set();
|
|
15
|
+
state;
|
|
16
|
+
prevState;
|
|
17
|
+
options;
|
|
18
|
+
constructor(e, t) {
|
|
19
|
+
this.prevState = e, this.state = e, this.options = t;
|
|
20
|
+
}
|
|
21
|
+
subscribe = (e) => (this.listeners.add(e), () => {
|
|
22
|
+
this.listeners.delete(e);
|
|
23
|
+
});
|
|
24
|
+
setState(e) {
|
|
25
|
+
this.prevState = this.state, this.state = i(e) ? e(this.prevState) : e, s(this);
|
|
26
|
+
}
|
|
27
|
+
_notify() {
|
|
28
|
+
let e = {
|
|
29
|
+
prevVal: this.prevState,
|
|
30
|
+
currentVal: this.state
|
|
31
|
+
};
|
|
32
|
+
for (let t of this.listeners) t(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function i(e) {
|
|
36
|
+
return typeof e == "function";
|
|
37
|
+
}
|
|
38
|
+
var a = !1, o = /* @__PURE__ */ new Set();
|
|
39
|
+
function s(e) {
|
|
40
|
+
o.add(e);
|
|
41
|
+
let t = !a;
|
|
42
|
+
a = !0;
|
|
43
|
+
try {
|
|
44
|
+
if (e.options?.onUpdate?.(e.state, e.prevState), !t) return;
|
|
45
|
+
for (; o.size > 0;) {
|
|
46
|
+
let e = Array.from(o);
|
|
47
|
+
o.clear();
|
|
48
|
+
for (let t of e) t._notify();
|
|
49
|
+
}
|
|
50
|
+
} finally {
|
|
51
|
+
t && (a = !1, o.clear());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/editor/managers/ExtensionManager/symbol.ts
|
|
56
|
+
var c = Symbol("originalFactory");
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/editor/BlockNoteExtension.ts
|
|
59
|
+
function l(e) {
|
|
60
|
+
if (typeof e == "object" && "key" in e) return function t() {
|
|
61
|
+
return e[c] = t, e;
|
|
62
|
+
};
|
|
63
|
+
if (typeof e != "function") throw Error("factory must be a function");
|
|
64
|
+
return function t(n) {
|
|
65
|
+
return (r) => {
|
|
66
|
+
let i = e({
|
|
67
|
+
editor: r.editor,
|
|
68
|
+
options: n
|
|
69
|
+
});
|
|
70
|
+
return i[c] = t, i;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function u(e, t) {
|
|
75
|
+
return new r(e, t);
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { t as a, r as i, u as n, n as o, c as r, l as t };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=BlockNoteExtension-CbvDA0F7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockNoteExtension-CbvDA0F7.js","names":[],"sources":["../src/schema/markGroups.ts","../src/util/Store.ts","../src/editor/managers/ExtensionManager/symbol.ts","../src/editor/BlockNoteExtension.ts"],"sourcesContent":["import { Editor, getExtensionField } from \"@tiptap/core\";\n\n/**\n * ProseMirror mark group for \"non-formatting\" marks: comments and the\n * suggestion/diff marks (the AI `insertion`/`deletion`/`modification` marks and\n * the Yjs `y-attributed-*` marks). These annotate content without representing\n * inline formatting and are ignored by BlockNote's content model\n * (`blocknoteIgnore`).\n *\n * They are the only marks allowed on `\"plain\"` blocks (e.g. code blocks), which\n * otherwise disallow all formatting marks. A block references this group rather\n * than the individual marks because each of them comes from an optional\n * extension (comments, AI suggestions, Yjs attribution) and so is only present\n * when that extension is configured.\n */\nexport const NON_FORMATTING_MARK_GROUP = \"annotation\";\n\n/**\n * The `marks` field value for `\"plain\"` blocks (e.g. code blocks), which hold\n * unstyled text and so disallow formatting marks but still allow the\n * non-formatting ones.\n *\n * Every mark in {@link NON_FORMATTING_MARK_GROUP} comes from an optional\n * extension, so a node spec that referenced the group unconditionally would make\n * ProseMirror throw \"Unknown mark type: 'annotation'\" while building the schema\n * of an editor that has none of them registered — an empty mark group is an\n * unknown reference just like a missing mark is. (This mirrors `suggestionMarks`\n * for the block-level suggestion group.)\n *\n * Returns the group name (which ProseMirror expands to every mark in it) when at\n * least one such mark is registered, or `\"\"` otherwise. Evaluated at\n * schema-build time, where the tiptap editor's fully-flattened extension list is\n * available on `this.editor`.\n */\nexport function nonFormattingMarks(editor: Editor | undefined): string {\n if (!editor) {\n return \"\";\n }\n const hasNonFormattingMark = editor.options.extensions.some((extension) => {\n if (extension.type !== \"mark\") {\n return false;\n }\n const group = getExtensionField(extension, \"group\") as string | undefined;\n return (\n typeof group === \"string\" &&\n group.split(\" \").includes(NON_FORMATTING_MARK_GROUP)\n );\n });\n return hasNonFormattingMark ? NON_FORMATTING_MARK_GROUP : \"\";\n}\n","// Vendored from https://github.com/TanStack/store/blob/main/packages/store/src/store.ts (MIT)\n//\n// BlockNote only ever used `Store` — never the `Derived`/`Effect` reactive graph that\n// makes up the rest of `@tanstack/store`, and that graph isn't tree-shakeable because\n// `setState` reaches into the scheduler. Since the `Store` type is part of BlockNote's\n// public API (every extension exposes one), owning these ~40 lines lets us keep that\n// surface stable instead of tracking a 0.x dependency's breaking changes.\n//\n// Behaviour matches `@tanstack/store@0.7.7`, minus the dependency graph and the\n// `updateFn`/`onSubscribe` options, which nothing used. `onUpdate` additionally receives\n// the new and previous state rather than requiring callers to close over the store.\n\n/**\n * The value a {@link Listener} is called with when a {@link Store} updates.\n */\nexport interface ListenerValue<T> {\n readonly prevVal: T;\n readonly currentVal: T;\n}\n\n/**\n * A callback invoked when a {@link Store}'s state changes.\n */\nexport type Listener<T> = (value: ListenerValue<T>) => void;\n\n/**\n * A new state, or a function deriving it from the previous state.\n */\nexport type Updater<T> = T | ((prev: T) => T);\n\nexport interface StoreOptions<TState> {\n /**\n * Called after the state has been updated, before listeners are notified.\n */\n onUpdate?: (state: TState, prevState: TState) => void;\n}\n\n/**\n * A minimal observable state container.\n *\n * Extensions expose one of these as their `store` so that both React (via\n * `useExtensionState`) and vanilla consumers can read and subscribe to their state.\n */\nexport class Store<TState> {\n listeners = new Set<Listener<TState>>();\n state: TState;\n prevState: TState;\n options?: StoreOptions<TState>;\n\n constructor(initialState: TState, options?: StoreOptions<TState>) {\n this.prevState = initialState;\n this.state = initialState;\n this.options = options;\n }\n\n subscribe = (listener: Listener<TState>) => {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /**\n * Update the store state, either with a new state or a function deriving it from the\n * previous one.\n */\n setState(updater: (prevState: TState) => TState): void;\n setState(updater: TState): void;\n setState(updater: Updater<TState>): void {\n this.prevState = this.state;\n this.state = isUpdaterFunction(updater) ? updater(this.prevState) : updater;\n\n flush(this);\n }\n\n /**\n * @internal Only to be called by {@link flush}.\n */\n _notify() {\n const value: ListenerValue<TState> = {\n prevVal: this.prevState,\n currentVal: this.state,\n };\n for (const listener of this.listeners) {\n listener(value);\n }\n }\n}\n\nfunction isUpdaterFunction<T>(updater: Updater<T>): updater is (prev: T) => T {\n return typeof updater === \"function\";\n}\n\n// Both `onUpdate` and listener notification can synchronously trigger further `setState`\n// calls — a callback that dispatches a ProseMirror transaction, for example. Rather than\n// recursing, re-entrant writes are queued and drained by the outermost flush, so a write\n// made during a callback still reaches every listener but the stack stays flat and\n// subscribers see the settled state once.\n//\n// `onUpdate` therefore runs *inside* the flush transaction: the store is queued and the\n// flush is marked in progress before the callback fires, so a nested write it makes is\n// coalesced into this drain rather than starting its own.\nlet isFlushing = false;\nconst pendingUpdates = new Set<Store<any>>();\n\nfunction flush(store: Store<any>) {\n pendingUpdates.add(store);\n\n const isOutermost = !isFlushing;\n isFlushing = true;\n\n try {\n store.options?.onUpdate?.(store.state, store.prevState);\n\n if (!isOutermost) {\n return;\n }\n\n while (pendingUpdates.size > 0) {\n const stores = Array.from(pendingUpdates);\n pendingUpdates.clear();\n for (const pendingStore of stores) {\n pendingStore._notify();\n }\n }\n } finally {\n if (isOutermost) {\n isFlushing = false;\n // A throwing callback would otherwise strand queued stores, letting them notify\n // during an unrelated store's next flush.\n pendingUpdates.clear();\n }\n }\n}\n","/**\n * Symbol used to track the original factory function for extensions.\n * This allows us to retrieve the original factory for comparison and other operations.\n */\nexport const originalFactorySymbol = Symbol(\"originalFactory\");\n","import { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.js\";\nimport { Store, StoreOptions } from \"../util/Store.js\";\nimport type { BlockNoteEditor } from \"./BlockNoteEditor.js\";\nimport { originalFactorySymbol } from \"./managers/ExtensionManager/symbol.js\";\n\n/**\n * This function is called when the extension is destroyed.\n */\ntype OnDestroy = () => void;\n\n/**\n * Describes a BlockNote extension.\n */\nexport interface Extension<State = any, Key extends string = string> {\n /**\n * The unique identifier for the extension.\n */\n readonly key: Key;\n\n /**\n * Triggered when the extension is mounted to the editor.\n */\n readonly mount?: (ctx: {\n /**\n * The DOM element that the editor is mounted to.\n */\n dom: HTMLElement;\n /**\n * The root document of the {@link document} that the editor is mounted to.\n */\n root: Document | ShadowRoot;\n /**\n * An {@link AbortSignal} that will be aborted when the extension is destroyed.\n */\n signal: AbortSignal;\n }) => void | OnDestroy;\n\n /**\n * The store for the extension.\n */\n readonly store?: Store<State>;\n\n /**\n * Declares what {@link Extension}s that this extension depends on.\n */\n readonly runsBefore?: ReadonlyArray<string>;\n\n /**\n * Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\n readonly inputRules?: ReadonlyArray<InputRule>;\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n readonly keyboardShortcuts?: Record<\n string,\n (ctx: { editor: BlockNoteEditor<any, any, any> }) => boolean\n >;\n\n /**\n * Add additional prosemirror plugins to the editor.\n */\n readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;\n\n /**\n * Add additional tiptap extensions to the editor.\n */\n readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;\n\n /**\n * Add additional BlockNote extensions to the editor.\n */\n readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;\n}\n\n/**\n * An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\ntype InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * These are the arguments that are passed to an {@link ExtensionFactoryInstance}.\n */\nexport interface ExtensionOptions<\n Options extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n> {\n options: Options;\n editor: BlockNoteEditor<any, any, any>;\n}\n\n// a type that maps the extension key to the return type of the extension factory\nexport type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {\n [K in T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext[\"key\"]\n : never]: T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext\n : never;\n};\n\n/**\n * This is a type that represents the function which will actually create the extension.\n * It requires the editor instance to be passed in, but will already have the options applied automatically.\n *\n * @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.\n */\nexport type ExtensionFactoryInstance<\n Ext extends Extension<any, any> = Extension<any, any>,\n> = (ctx: Omit<ExtensionOptions<any>, \"options\">) => Ext;\n\n/**\n * This is the return type of the {@link createExtension} function.\n * It is a function that can be invoked with the extension's options to create a new extension factory.\n */\nexport type ExtensionFactory<\n State = any,\n Key extends string = string,\n Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<any>,\n ) => Extension<State, Key>,\n> =\n Parameters<Factory>[0] extends ExtensionOptions<infer Options>\n ? undefined extends Options\n ? (\n options?: Exclude<Options, undefined>,\n ) => ExtensionFactoryInstance<ReturnType<Factory>>\n : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>>\n : () => ExtensionFactoryInstance<ReturnType<Factory>>;\n\n/**\n * Constructs a BlockNote {@link ExtensionFactory} from a factory function or object\n */\n// This overload is for `createExtension({ key: \"test\", ... })`\nexport function createExtension<\n const State = any,\n const Key extends string = string,\n const Ext extends Extension<State, Key> = Extension<State, Key>,\n>(factory: Ext): ExtensionFactoryInstance<Ext>;\n// This overload is for `createExtension(({editor, options}) => ({ key: \"test\", ... }))`\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(factory: Factory): ExtensionFactory<State, Key, Factory>;\n// This overload is for both of the above overloads as it is the implementation of the function\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends\n | Extension<State, Key>\n | ((ctx: any) => Extension<State, Key>) = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(\n factory: Factory,\n): Factory extends Extension<State, Key>\n ? ExtensionFactoryInstance<Factory>\n : Factory extends (ctx: any) => Extension<State, Key>\n ? ExtensionFactory<State, Key, Factory>\n : never {\n if (typeof factory === \"object\" && \"key\" in factory) {\n return function factoryFn() {\n (factory as any)[originalFactorySymbol] = factoryFn;\n return factory;\n } as any;\n }\n\n if (typeof factory !== \"function\") {\n throw new Error(\"factory must be a function\");\n }\n\n return function factoryFn(options: Options) {\n return (ctx: { editor: BlockNoteEditor<any, any, any> }) => {\n const extension = factory({ editor: ctx.editor, options });\n // We stick a symbol onto the extension to allow us to retrieve the original factory for comparison later.\n // This enables us to do things like: `editor.getExtension(YSync).prosemirrorPlugins`\n (extension as any)[originalFactorySymbol] = factoryFn;\n return extension;\n };\n } as any;\n}\n\nexport function createStore<T = any>(\n initialState: T,\n options?: StoreOptions<T>,\n): Store<T> {\n return new Store(initialState, options);\n}\n"],"mappings":";;AAeA,IAAa,IAA4B;AAmBzC,SAAgB,EAAmB,GAAoC;CAcrE,OAbK,KAGwB,EAAO,QAAQ,WAAW,MAAM,MAAc;EACzE,IAAI,EAAU,SAAS,QACrB,OAAO;EAET,IAAM,IAAQ,EAAkB,GAAW,OAAO;EAClD,OACE,OAAO,KAAU,YACjB,EAAM,MAAM,GAAG,CAAC,CAAC,SAAA,YAAkC;CAEvD,CACO,IAAuB,IAA4B;AAC5D;;;ACNA,IAAa,IAAb,MAA2B;CACzB,4BAAY,IAAI,IAAsB;CACtC;CACA;CACA;CAEA,YAAY,GAAsB,GAAgC;EAGhE,AAFA,KAAK,YAAY,GACjB,KAAK,QAAQ,GACb,KAAK,UAAU;CACjB;CAEA,aAAa,OACX,KAAK,UAAU,IAAI,CAAQ,SAEd;EACX,KAAK,UAAU,OAAO,CAAQ;CAChC;CASF,SAAS,GAAgC;EAIvC,AAHA,KAAK,YAAY,KAAK,OACtB,KAAK,QAAQ,EAAkB,CAAO,IAAI,EAAQ,KAAK,SAAS,IAAI,GAEpE,EAAM,IAAI;CACZ;CAKA,UAAU;EACR,IAAM,IAA+B;GACnC,SAAS,KAAK;GACd,YAAY,KAAK;EACnB;EACA,KAAK,IAAM,KAAY,KAAK,WAC1B,EAAS,CAAK;CAElB;AACF;AAEA,SAAS,EAAqB,GAAgD;CAC5E,OAAO,OAAO,KAAY;AAC5B;AAWA,IAAI,IAAa,IACX,oBAAiB,IAAI,IAAgB;AAE3C,SAAS,EAAM,GAAmB;CAChC,EAAe,IAAI,CAAK;CAExB,IAAM,IAAc,CAAC;CACrB,IAAa;CAEb,IAAI;EAGF,IAFA,EAAM,SAAS,WAAW,EAAM,OAAO,EAAM,SAAS,GAElD,CAAC,GACH;EAGF,OAAO,EAAe,OAAO,IAAG;GAC9B,IAAM,IAAS,MAAM,KAAK,CAAc;GACxC,EAAe,MAAM;GACrB,KAAK,IAAM,KAAgB,GACzB,EAAa,QAAQ;EAEzB;CACF,UAAU;EACR,AAAI,MACF,IAAa,IAGb,EAAe,MAAM;CAEzB;AACF;;;AClIA,IAAa,IAAwB,OAAO,iBAAiB;;;ACiM7D,SAAgB,EAUd,GAKU;CACV,IAAI,OAAO,KAAY,YAAY,SAAS,GAC1C,OAAO,SAAS,IAAY;EAE1B,OADA,EAAiB,KAAyB,GACnC;CACT;CAGF,IAAI,OAAO,KAAY,YACrB,MAAU,MAAM,4BAA4B;CAG9C,OAAO,SAAS,EAAU,GAAkB;EAC1C,QAAQ,MAAoD;GAC1D,IAAM,IAAY,EAAQ;IAAE,QAAQ,EAAI;IAAQ;GAAQ,CAAC;GAIzD,OADA,EAAmB,KAAyB,GACrC;EACT;CACF;AACF;AAEA,SAAgB,EACd,GACA,GACU;CACV,OAAO,IAAI,EAAM,GAAc,CAAO;AACxC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, t } from "./BlockNoteExtension-
|
|
1
|
+
import { n as e, t } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
2
2
|
import { Plugin as n, PluginKey as r } from "prosemirror-state";
|
|
3
3
|
import { Decoration as i, DecorationSet as a } from "prosemirror-view";
|
|
4
4
|
//#region src/extensions/ShowSelection/ShowSelection.ts
|
|
@@ -19,7 +19,7 @@ var o = new r("blocknote-show-selection"), s = t(({ editor: t }) => {
|
|
|
19
19
|
} }
|
|
20
20
|
})],
|
|
21
21
|
showSelection(e, t) {
|
|
22
|
-
r.setState({ enabledSet: e ? new Set([...r.state.enabledSet, t]) : new Set([...r.state.enabledSet].filter((e) => e !== t)) });
|
|
22
|
+
r.setState({ enabledSet: e ? /* @__PURE__ */ new Set([...r.state.enabledSet, t]) : new Set([...r.state.enabledSet].filter((e) => e !== t)) });
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
});
|
|
@@ -70,4 +70,4 @@ function l(e) {
|
|
|
70
70
|
//#endregion
|
|
71
71
|
export { l as n, s as r, c as t };
|
|
72
72
|
|
|
73
|
-
//# sourceMappingURL=UserStore-
|
|
73
|
+
//# sourceMappingURL=UserStore-C4TzkGEn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserStore-DCG6lsla.cjs","names":[],"sources":["../src/extensions/ShowSelection/ShowSelection.ts","../src/user/UserStore.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabledSet: new Set<string>() },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (store.state.enabledSet.size === 0) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n *\n * @param shouldShow - Whether to show the selection decoration\n * @param key - The key of the selection to show or hide,\n * this is necessary to prevent disabling ShowSelection from one place\n * will interfere with other parts of the code that need to show the selection decoration\n * (e.g.: CreateLinkButton and AIExtension)\n */\n showSelection(shouldShow: boolean, key: string) {\n store.setState({\n enabledSet: shouldShow\n ? new Set([...store.state.enabledSet, key])\n : new Set([...store.state.enabledSet].filter((k) => k !== key)),\n });\n },\n } as const;\n});\n","import { Store } from \"@tanstack/store\";\nimport { createStore } from \"../editor/BlockNoteExtension.js\";\n\n/**\n * A collaborator of the document.\n */\nexport type User = {\n /**\n * The {@link User}'s unique identifier\n */\n id: string;\n /**\n * The {@link User}'s name/label\n */\n username: string;\n /**\n * The {@link User}'s profile image\n */\n avatarUrl: string;\n /**\n * The color used to represent the user (e.g. for collaboration cursors).\n */\n color?: string;\n /**\n * A lighter variant of {@link color}.\n */\n colorLight?: string;\n};\n\n/**\n * A store that retrieves and caches information about users, generic over the\n * resolved user type `U`.\n *\n * Created via {@link createUserStore}. Features that need to resolve user ids to\n * user information (comments, suggestions, versions) build one internally and\n * expose it on their extension instance so their UI can read from it.\n */\nexport type UserStore<U extends User = User> = {\n /**\n * A store mapping user ids to the resolved {@link User} information.\n */\n store: Store<Map<User[\"id\"], U>>;\n /**\n * Load information about users based on an array of user ids.\n *\n * Users that are already cached or currently being loaded are skipped, so\n * it is safe to call this often (e.g. on every render).\n */\n loadUsers: (userIds: User[\"id\"][]) => Promise<void>;\n /**\n * Re-fetch information about users, ignoring the cache. Users that are\n * currently being loaded are still skipped to avoid duplicate requests.\n */\n refetchUsers: (userIds: User[\"id\"][]) => Promise<void>;\n /**\n * Retrieve information about a user based on their id, if cached.\n *\n * The user has to be loaded via `loadUsers` first.\n */\n getUser: (userId: User[\"id\"]) => U | undefined;\n /**\n * Manually set information about a user. This is useful if you have a\n * resolver that returns partial information (e.g. just the username) and you\n * want to fill in the rest later (e.g. avatarUrl).\n */\n setUser: (user: U | U[]) => void;\n};\n\nexport type UserStoreResolver<U extends User = User> = (\n /**\n * The user ids to resolve. The resolver should return information for all of\n * these users, or an empty array if none could be resolved.\n */\n userIds: User[\"id\"][],\n /**\n * The {@link UserStore} that is calling this resolver. This allows you to return a user synchronously, and update the store later if you need to fetch additional information asynchronously.\n */\n store: UserStore<any>,\n) => Promise<U[]>;\n\n/**\n * A resolver callback or an already-built {@link UserStore} — the shape that\n * user-facing options (comments, collaboration) accept so callers can either let\n * the extension build a store or pass a shared one.\n */\nexport type UserStoreOrResolver<U extends User = User> =\n | ((userIds: User[\"id\"][], store: UserStore<any>) => Promise<U[]>)\n | UserStore<any>;\n\n/**\n * Creates a {@link UserStore} that retrieves and caches information about users.\n *\n * It does this by calling `resolveUsers` for users that are not yet cached, and\n * stores the results in a BlockNote store so they can be subscribed to (e.g. via\n * `useStore` in React).\n *\n * `resolveUsers` is called with the ids of users that are not yet cached, and\n * should return the information for those users. The type of the returned users\n * is inferred and flows through to {@link UserStore.getUser} and the store, so\n * you can return a type with additional properties and have them be reported\n * back.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\nexport function createUserStore<U extends User = User>(\n resolveUsers: (userIds: User[\"id\"][], store: UserStore<any>) => Promise<U[]>,\n): UserStore<U> {\n if (!resolveUsers) {\n throw new Error(\"resolveUsers is required to create a user store\");\n }\n\n const store = createStore(new Map<User[\"id\"], U>());\n\n // Tracks users that are currently being fetched, to avoid duplicate\n // in-flight requests. This is intentionally kept out of the store as it is\n // not state that consumers need to subscribe to.\n const loadingUsers = new Set<User[\"id\"]>();\n\n const userStore: UserStore<U> = {\n store,\n async loadUsers(userIds) {\n const missingUsers = userIds.filter(\n (id) => !store.state.has(id) && !loadingUsers.has(id),\n );\n await fetchUsers(missingUsers);\n },\n async refetchUsers(userIds) {\n const usersToFetch = userIds.filter((id) => !loadingUsers.has(id));\n await fetchUsers(usersToFetch);\n },\n getUser(userId) {\n return store.state.get(userId);\n },\n setUser(users) {\n const usersArray = Array.isArray(users) ? users : [users];\n store.setState((prevState) => {\n const nextState = new Map(prevState);\n for (const user of usersArray) {\n nextState.set(user.id, user);\n }\n return nextState;\n });\n },\n };\n\n async function fetchUsers(userIds: User[\"id\"][]) {\n if (userIds.length === 0) {\n return;\n }\n\n for (const id of userIds) {\n loadingUsers.add(id);\n }\n\n try {\n const users = await resolveUsers(userIds, userStore);\n // Only update the store if any users were actually resolved. Emitting\n // an update when nothing changed (e.g. when the resolver can't find a\n // user) would needlessly notify subscribers and, combined with a\n // subscriber that re-triggers loading, could cause an infinite loop.\n // See https://github.com/TypeCellOS/BlockNote/issues/1548\n if (users.length > 0) {\n store.setState((prevState) => {\n const nextState = new Map(prevState);\n for (const user of users) {\n nextState.set(user.id, user);\n }\n return nextState;\n });\n }\n } finally {\n for (const id of userIds) {\n // Remove the users from the loading set. On a next call to `loadUsers`\n // we will either return the cached user, or retry loading the user if\n // the request failed.\n loadingUsers.delete(id);\n }\n }\n }\n\n return userStore;\n}\n\n/**\n * Normalize a {@link UserStoreOrResolver} to a {@link UserStore}:\n * - an existing store is returned as-is (so a single de-duped cache can be\n * shared across extensions),\n * - a resolver function is wrapped with {@link createUserStore},\n * - `undefined` yields an empty store that resolves nothing (consumers then fall\n * back to showing raw user ids).\n */\nexport function normalizeToUserStore<U extends User = User>(\n resolveUsersOrStore?: UserStoreOrResolver<U>,\n): UserStore<U> {\n if (typeof resolveUsersOrStore === \"function\") {\n return createUserStore(resolveUsersOrStore);\n }\n return resolveUsersOrStore ?? createUserStore<U>(async () => []);\n}\n"],"mappings":"sHAOA,IAAM,EAAa,IAAI,EAAA,UAAU,0BAA0B,EAO9C,EAAyB,EAAA,GAAiB,CAAE,YAAa,CACpE,IAAM,EAAQ,EAAA,EACZ,CAAE,WAAY,IAAI,GAAc,EAChC,CACE,UAAW,CACT,EAAO,SAAU,GAAO,EAAG,QAAQ,EAAY,CAAC,CAAC,CAAC,CACpD,CACF,CACF,EACA,MAAO,CACL,IAAK,gBACL,QACA,mBAAoB,CAClB,IAAI,EAAA,OAAO,CACT,IAAK,EACL,MAAO,CACL,YAAc,GAAU,CACtB,GAAM,CAAE,MAAK,aAAc,EAC3B,GAAI,EAAM,MAAM,WAAW,OAAS,EAClC,OAAO,EAAA,cAAc,MAEvB,IAAM,EAAM,EAAA,WAAW,OAAO,EAAU,KAAM,EAAU,GAAI,CAC1D,sBAAuB,MACzB,CAAC,EACD,OAAO,EAAA,cAAc,OAAO,EAAK,CAAC,CAAG,CAAC,CACxC,CACF,CACF,CAAC,CACH,EAUA,cAAc,EAAqB,EAAa,CAC9C,EAAM,SAAS,CACb,WAAY,EACR,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,WAAY,CAAG,CAAC,EACxC,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,UAAU,EAAE,OAAQ,GAAM,IAAM,CAAG,CAAC,CAClE,CAAC,CACH,CACF,CACF,CAAC,EC4CD,SAAgB,EACd,EACc,CACd,GAAI,CAAC,EACH,MAAU,MAAM,iDAAiD,EAGnE,IAAM,EAAQ,EAAA,EAAY,IAAI,GAAoB,EAK5C,EAAe,IAAI,IAEnB,EAA0B,CAC9B,QACA,MAAM,UAAU,EAAS,CAIvB,MAAM,EAHe,EAAQ,OAC1B,GAAO,CAAC,EAAM,MAAM,IAAI,CAAE,GAAK,CAAC,EAAa,IAAI,CAAE,CAErC,CAAY,CAC/B,EACA,MAAM,aAAa,EAAS,CAE1B,MAAM,EADe,EAAQ,OAAQ,GAAO,CAAC,EAAa,IAAI,CAAE,CAC/C,CAAY,CAC/B,EACA,QAAQ,EAAQ,CACd,OAAO,EAAM,MAAM,IAAI,CAAM,CAC/B,EACA,QAAQ,EAAO,CACb,IAAM,EAAa,MAAM,QAAQ,CAAK,EAAI,EAAQ,CAAC,CAAK,EACxD,EAAM,SAAU,GAAc,CAC5B,IAAM,EAAY,IAAI,IAAI,CAAS,EACnC,IAAK,IAAM,KAAQ,EACjB,EAAU,IAAI,EAAK,GAAI,CAAI,EAE7B,OAAO,CACT,CAAC,CACH,CACF,EAEA,eAAe,EAAW,EAAuB,CAC3C,KAAQ,SAAW,EAIvB,KAAK,IAAM,KAAM,EACf,EAAa,IAAI,CAAE,EAGrB,GAAI,CACF,IAAM,EAAQ,MAAM,EAAa,EAAS,CAAS,EAM/C,EAAM,OAAS,GACjB,EAAM,SAAU,GAAc,CAC5B,IAAM,EAAY,IAAI,IAAI,CAAS,EACnC,IAAK,IAAM,KAAQ,EACjB,EAAU,IAAI,EAAK,GAAI,CAAI,EAE7B,OAAO,CACT,CAAC,CAEL,QAAU,CACR,IAAK,IAAM,KAAM,EAIf,EAAa,OAAO,CAAE,CAE1B,CA1BqB,CA2BvB,CAEA,OAAO,CACT,CAUA,SAAgB,EACd,EACc,CAId,OAHI,OAAO,GAAwB,WAC1B,EAAgB,CAAmB,EAErC,GAAuB,EAAmB,SAAY,CAAC,CAAC,CACjE"}
|
|
1
|
+
{"version":3,"file":"UserStore-C4TzkGEn.js","names":[],"sources":["../src/extensions/ShowSelection/ShowSelection.ts","../src/user/UserStore.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabledSet: new Set<string>() },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (store.state.enabledSet.size === 0) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n *\n * @param shouldShow - Whether to show the selection decoration\n * @param key - The key of the selection to show or hide,\n * this is necessary to prevent disabling ShowSelection from one place\n * will interfere with other parts of the code that need to show the selection decoration\n * (e.g.: CreateLinkButton and AIExtension)\n */\n showSelection(shouldShow: boolean, key: string) {\n store.setState({\n enabledSet: shouldShow\n ? new Set([...store.state.enabledSet, key])\n : new Set([...store.state.enabledSet].filter((k) => k !== key)),\n });\n },\n } as const;\n});\n","import { createStore } from \"../editor/BlockNoteExtension.js\";\nimport { Store } from \"../util/Store.js\";\n\n/**\n * A collaborator of the document.\n */\nexport type User = {\n /**\n * The {@link User}'s unique identifier\n */\n id: string;\n /**\n * The {@link User}'s name/label\n */\n username: string;\n /**\n * The {@link User}'s profile image\n */\n avatarUrl: string;\n /**\n * The color used to represent the user (e.g. for collaboration cursors).\n */\n color?: string;\n /**\n * A lighter variant of {@link color}.\n */\n colorLight?: string;\n};\n\n/**\n * A store that retrieves and caches information about users, generic over the\n * resolved user type `U`.\n *\n * Created via {@link createUserStore}. Features that need to resolve user ids to\n * user information (comments, suggestions, versions) build one internally and\n * expose it on their extension instance so their UI can read from it.\n */\nexport type UserStore<U extends User = User> = {\n /**\n * A store mapping user ids to the resolved {@link User} information.\n */\n store: Store<Map<User[\"id\"], U>>;\n /**\n * Load information about users based on an array of user ids.\n *\n * Users that are already cached or currently being loaded are skipped, so\n * it is safe to call this often (e.g. on every render).\n */\n loadUsers: (userIds: User[\"id\"][]) => Promise<void>;\n /**\n * Re-fetch information about users, ignoring the cache. Users that are\n * currently being loaded are still skipped to avoid duplicate requests.\n */\n refetchUsers: (userIds: User[\"id\"][]) => Promise<void>;\n /**\n * Retrieve information about a user based on their id, if cached.\n *\n * The user has to be loaded via `loadUsers` first.\n */\n getUser: (userId: User[\"id\"]) => U | undefined;\n /**\n * Manually set information about a user. This is useful if you have a\n * resolver that returns partial information (e.g. just the username) and you\n * want to fill in the rest later (e.g. avatarUrl).\n */\n setUser: (user: U | U[]) => void;\n};\n\nexport type UserStoreResolver<U extends User = User> = (\n /**\n * The user ids to resolve. The resolver should return information for all of\n * these users, or an empty array if none could be resolved.\n */\n userIds: User[\"id\"][],\n /**\n * The {@link UserStore} that is calling this resolver. This allows you to return a user synchronously, and update the store later if you need to fetch additional information asynchronously.\n */\n store: UserStore<any>,\n) => Promise<U[]>;\n\n/**\n * A resolver callback or an already-built {@link UserStore} — the shape that\n * user-facing options (comments, collaboration) accept so callers can either let\n * the extension build a store or pass a shared one.\n */\nexport type UserStoreOrResolver<U extends User = User> =\n | ((userIds: User[\"id\"][], store: UserStore<any>) => Promise<U[]>)\n | UserStore<any>;\n\n/**\n * Creates a {@link UserStore} that retrieves and caches information about users.\n *\n * It does this by calling `resolveUsers` for users that are not yet cached, and\n * stores the results in a BlockNote store so they can be subscribed to (e.g. via\n * `useStore` in React).\n *\n * `resolveUsers` is called with the ids of users that are not yet cached, and\n * should return the information for those users. The type of the returned users\n * is inferred and flows through to {@link UserStore.getUser} and the store, so\n * you can return a type with additional properties and have them be reported\n * back.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\nexport function createUserStore<U extends User = User>(\n resolveUsers: (userIds: User[\"id\"][], store: UserStore<any>) => Promise<U[]>,\n): UserStore<U> {\n if (!resolveUsers) {\n throw new Error(\"resolveUsers is required to create a user store\");\n }\n\n const store = createStore(new Map<User[\"id\"], U>());\n\n // Tracks users that are currently being fetched, to avoid duplicate\n // in-flight requests. This is intentionally kept out of the store as it is\n // not state that consumers need to subscribe to.\n const loadingUsers = new Set<User[\"id\"]>();\n\n const userStore: UserStore<U> = {\n store,\n async loadUsers(userIds) {\n const missingUsers = userIds.filter(\n (id) => !store.state.has(id) && !loadingUsers.has(id),\n );\n await fetchUsers(missingUsers);\n },\n async refetchUsers(userIds) {\n const usersToFetch = userIds.filter((id) => !loadingUsers.has(id));\n await fetchUsers(usersToFetch);\n },\n getUser(userId) {\n return store.state.get(userId);\n },\n setUser(users) {\n const usersArray = Array.isArray(users) ? users : [users];\n store.setState((prevState) => {\n const nextState = new Map(prevState);\n for (const user of usersArray) {\n nextState.set(user.id, user);\n }\n return nextState;\n });\n },\n };\n\n async function fetchUsers(userIds: User[\"id\"][]) {\n if (userIds.length === 0) {\n return;\n }\n\n for (const id of userIds) {\n loadingUsers.add(id);\n }\n\n try {\n const users = await resolveUsers(userIds, userStore);\n // Only update the store if any users were actually resolved. Emitting\n // an update when nothing changed (e.g. when the resolver can't find a\n // user) would needlessly notify subscribers and, combined with a\n // subscriber that re-triggers loading, could cause an infinite loop.\n // See https://github.com/TypeCellOS/BlockNote/issues/1548\n if (users.length > 0) {\n store.setState((prevState) => {\n const nextState = new Map(prevState);\n for (const user of users) {\n nextState.set(user.id, user);\n }\n return nextState;\n });\n }\n } finally {\n for (const id of userIds) {\n // Remove the users from the loading set. On a next call to `loadUsers`\n // we will either return the cached user, or retry loading the user if\n // the request failed.\n loadingUsers.delete(id);\n }\n }\n }\n\n return userStore;\n}\n\n/**\n * Normalize a {@link UserStoreOrResolver} to a {@link UserStore}:\n * - an existing store is returned as-is (so a single de-duped cache can be\n * shared across extensions),\n * - a resolver function is wrapped with {@link createUserStore},\n * - `undefined` yields an empty store that resolves nothing (consumers then fall\n * back to showing raw user ids).\n */\nexport function normalizeToUserStore<U extends User = User>(\n resolveUsersOrStore?: UserStoreOrResolver<U>,\n): UserStore<U> {\n if (typeof resolveUsersOrStore === \"function\") {\n return createUserStore(resolveUsersOrStore);\n }\n return resolveUsersOrStore ?? createUserStore<U>(async () => []);\n}\n"],"mappings":";;;;AAOA,IAAM,IAAa,IAAI,EAAU,0BAA0B,GAO9C,IAAyB,GAAiB,EAAE,gBAAa;CACpE,IAAM,IAAQ,EACZ,EAAE,4BAAY,IAAI,IAAY,EAAE,GAChC,EACE,WAAW;EACT,EAAO,UAAU,MAAO,EAAG,QAAQ,GAAY,CAAC,CAAC,CAAC;CACpD,EACF,CACF;CACA,OAAO;EACL,KAAK;EACL;EACA,oBAAoB,CAClB,IAAI,EAAO;GACT,KAAK;GACL,OAAO,EACL,cAAc,MAAU;IACtB,IAAM,EAAE,QAAK,iBAAc;IAC3B,IAAI,EAAM,MAAM,WAAW,SAAS,GAClC,OAAO,EAAc;IAEvB,IAAM,IAAM,EAAW,OAAO,EAAU,MAAM,EAAU,IAAI,EAC1D,uBAAuB,OACzB,CAAC;IACD,OAAO,EAAc,OAAO,GAAK,CAAC,CAAG,CAAC;GACxC,EACF;EACF,CAAC,CACH;EAUA,cAAc,GAAqB,GAAa;GAC9C,EAAM,SAAS,EACb,YAAY,oBACR,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,YAAY,CAAG,CAAC,IACxC,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,UAAU,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAG,CAAC,EAClE,CAAC;EACH;CACF;AACF,CAAC;;;AC4CD,SAAgB,EACd,GACc;CACd,IAAI,CAAC,GACH,MAAU,MAAM,iDAAiD;CAGnE,IAAM,IAAQ,kBAAY,IAAI,IAAmB,CAAC,GAK5C,oBAAe,IAAI,IAAgB,GAEnC,IAA0B;EAC9B;EACA,MAAM,UAAU,GAAS;GAIvB,MAAM,EAHe,EAAQ,QAC1B,MAAO,CAAC,EAAM,MAAM,IAAI,CAAE,KAAK,CAAC,EAAa,IAAI,CAAE,CAErC,CAAY;EAC/B;EACA,MAAM,aAAa,GAAS;GAE1B,MAAM,EADe,EAAQ,QAAQ,MAAO,CAAC,EAAa,IAAI,CAAE,CAC/C,CAAY;EAC/B;EACA,QAAQ,GAAQ;GACd,OAAO,EAAM,MAAM,IAAI,CAAM;EAC/B;EACA,QAAQ,GAAO;GACb,IAAM,IAAa,MAAM,QAAQ,CAAK,IAAI,IAAQ,CAAC,CAAK;GACxD,EAAM,UAAU,MAAc;IAC5B,IAAM,IAAY,IAAI,IAAI,CAAS;IACnC,KAAK,IAAM,KAAQ,GACjB,EAAU,IAAI,EAAK,IAAI,CAAI;IAE7B,OAAO;GACT,CAAC;EACH;CACF;CAEA,eAAe,EAAW,GAAuB;EAC3C,MAAQ,WAAW,GAIvB;QAAK,IAAM,KAAM,GACf,EAAa,IAAI,CAAE;GAGrB,IAAI;IACF,IAAM,IAAQ,MAAM,EAAa,GAAS,CAAS;IAMnD,AAAI,EAAM,SAAS,KACjB,EAAM,UAAU,MAAc;KAC5B,IAAM,IAAY,IAAI,IAAI,CAAS;KACnC,KAAK,IAAM,KAAQ,GACjB,EAAU,IAAI,EAAK,IAAI,CAAI;KAE7B,OAAO;IACT,CAAC;GAEL,UAAU;IACR,KAAK,IAAM,KAAM,GAIf,EAAa,OAAO,CAAE;GAE1B;EA1BqB;CA2BvB;CAEA,OAAO;AACT;AAUA,SAAgB,EACd,GACc;CAId,OAHI,OAAO,KAAwB,aAC1B,EAAgB,CAAmB,IAErC,KAAuB,EAAmB,YAAY,CAAC,CAAC;AACjE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./BlockNoteExtension-
|
|
2
|
-
//# sourceMappingURL=UserStore-
|
|
1
|
+
const e=require("./BlockNoteExtension-BJCLnwrE.cjs");let t=require("prosemirror-state"),n=require("prosemirror-view");var r=new t.PluginKey(`blocknote-show-selection`),i=e.t(({editor:i})=>{let a=e.n({enabledSet:new Set},{onUpdate(){i.transact(e=>e.setMeta(r,{}))}});return{key:`showSelection`,store:a,prosemirrorPlugins:[new t.Plugin({key:r,props:{decorations:e=>{let{doc:t,selection:r}=e;if(a.state.enabledSet.size===0)return n.DecorationSet.empty;let i=n.Decoration.inline(r.from,r.to,{"data-show-selection":`true`});return n.DecorationSet.create(t,[i])}}})],showSelection(e,t){a.setState({enabledSet:e?new Set([...a.state.enabledSet,t]):new Set([...a.state.enabledSet].filter(e=>e!==t))})}}});function a(t){if(!t)throw Error(`resolveUsers is required to create a user store`);let n=e.n(new Map),r=new Set,i={store:n,async loadUsers(e){await a(e.filter(e=>!n.state.has(e)&&!r.has(e)))},async refetchUsers(e){await a(e.filter(e=>!r.has(e)))},getUser(e){return n.state.get(e)},setUser(e){let t=Array.isArray(e)?e:[e];n.setState(e=>{let n=new Map(e);for(let e of t)n.set(e.id,e);return n})}};async function a(e){if(e.length!==0){for(let t of e)r.add(t);try{let r=await t(e,i);r.length>0&&n.setState(e=>{let t=new Map(e);for(let e of r)t.set(e.id,e);return t})}finally{for(let t of e)r.delete(t)}}}return i}function o(e){return typeof e==`function`?a(e):e??a(async()=>[])}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
+
//# sourceMappingURL=UserStore-mj3fXW4D.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserStore-mj3fXW4D.cjs","names":[],"sources":["../src/extensions/ShowSelection/ShowSelection.ts","../src/user/UserStore.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabledSet: new Set<string>() },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (store.state.enabledSet.size === 0) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n *\n * @param shouldShow - Whether to show the selection decoration\n * @param key - The key of the selection to show or hide,\n * this is necessary to prevent disabling ShowSelection from one place\n * will interfere with other parts of the code that need to show the selection decoration\n * (e.g.: CreateLinkButton and AIExtension)\n */\n showSelection(shouldShow: boolean, key: string) {\n store.setState({\n enabledSet: shouldShow\n ? new Set([...store.state.enabledSet, key])\n : new Set([...store.state.enabledSet].filter((k) => k !== key)),\n });\n },\n } as const;\n});\n","import { createStore } from \"../editor/BlockNoteExtension.js\";\nimport { Store } from \"../util/Store.js\";\n\n/**\n * A collaborator of the document.\n */\nexport type User = {\n /**\n * The {@link User}'s unique identifier\n */\n id: string;\n /**\n * The {@link User}'s name/label\n */\n username: string;\n /**\n * The {@link User}'s profile image\n */\n avatarUrl: string;\n /**\n * The color used to represent the user (e.g. for collaboration cursors).\n */\n color?: string;\n /**\n * A lighter variant of {@link color}.\n */\n colorLight?: string;\n};\n\n/**\n * A store that retrieves and caches information about users, generic over the\n * resolved user type `U`.\n *\n * Created via {@link createUserStore}. Features that need to resolve user ids to\n * user information (comments, suggestions, versions) build one internally and\n * expose it on their extension instance so their UI can read from it.\n */\nexport type UserStore<U extends User = User> = {\n /**\n * A store mapping user ids to the resolved {@link User} information.\n */\n store: Store<Map<User[\"id\"], U>>;\n /**\n * Load information about users based on an array of user ids.\n *\n * Users that are already cached or currently being loaded are skipped, so\n * it is safe to call this often (e.g. on every render).\n */\n loadUsers: (userIds: User[\"id\"][]) => Promise<void>;\n /**\n * Re-fetch information about users, ignoring the cache. Users that are\n * currently being loaded are still skipped to avoid duplicate requests.\n */\n refetchUsers: (userIds: User[\"id\"][]) => Promise<void>;\n /**\n * Retrieve information about a user based on their id, if cached.\n *\n * The user has to be loaded via `loadUsers` first.\n */\n getUser: (userId: User[\"id\"]) => U | undefined;\n /**\n * Manually set information about a user. This is useful if you have a\n * resolver that returns partial information (e.g. just the username) and you\n * want to fill in the rest later (e.g. avatarUrl).\n */\n setUser: (user: U | U[]) => void;\n};\n\nexport type UserStoreResolver<U extends User = User> = (\n /**\n * The user ids to resolve. The resolver should return information for all of\n * these users, or an empty array if none could be resolved.\n */\n userIds: User[\"id\"][],\n /**\n * The {@link UserStore} that is calling this resolver. This allows you to return a user synchronously, and update the store later if you need to fetch additional information asynchronously.\n */\n store: UserStore<any>,\n) => Promise<U[]>;\n\n/**\n * A resolver callback or an already-built {@link UserStore} — the shape that\n * user-facing options (comments, collaboration) accept so callers can either let\n * the extension build a store or pass a shared one.\n */\nexport type UserStoreOrResolver<U extends User = User> =\n | ((userIds: User[\"id\"][], store: UserStore<any>) => Promise<U[]>)\n | UserStore<any>;\n\n/**\n * Creates a {@link UserStore} that retrieves and caches information about users.\n *\n * It does this by calling `resolveUsers` for users that are not yet cached, and\n * stores the results in a BlockNote store so they can be subscribed to (e.g. via\n * `useStore` in React).\n *\n * `resolveUsers` is called with the ids of users that are not yet cached, and\n * should return the information for those users. The type of the returned users\n * is inferred and flows through to {@link UserStore.getUser} and the store, so\n * you can return a type with additional properties and have them be reported\n * back.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\nexport function createUserStore<U extends User = User>(\n resolveUsers: (userIds: User[\"id\"][], store: UserStore<any>) => Promise<U[]>,\n): UserStore<U> {\n if (!resolveUsers) {\n throw new Error(\"resolveUsers is required to create a user store\");\n }\n\n const store = createStore(new Map<User[\"id\"], U>());\n\n // Tracks users that are currently being fetched, to avoid duplicate\n // in-flight requests. This is intentionally kept out of the store as it is\n // not state that consumers need to subscribe to.\n const loadingUsers = new Set<User[\"id\"]>();\n\n const userStore: UserStore<U> = {\n store,\n async loadUsers(userIds) {\n const missingUsers = userIds.filter(\n (id) => !store.state.has(id) && !loadingUsers.has(id),\n );\n await fetchUsers(missingUsers);\n },\n async refetchUsers(userIds) {\n const usersToFetch = userIds.filter((id) => !loadingUsers.has(id));\n await fetchUsers(usersToFetch);\n },\n getUser(userId) {\n return store.state.get(userId);\n },\n setUser(users) {\n const usersArray = Array.isArray(users) ? users : [users];\n store.setState((prevState) => {\n const nextState = new Map(prevState);\n for (const user of usersArray) {\n nextState.set(user.id, user);\n }\n return nextState;\n });\n },\n };\n\n async function fetchUsers(userIds: User[\"id\"][]) {\n if (userIds.length === 0) {\n return;\n }\n\n for (const id of userIds) {\n loadingUsers.add(id);\n }\n\n try {\n const users = await resolveUsers(userIds, userStore);\n // Only update the store if any users were actually resolved. Emitting\n // an update when nothing changed (e.g. when the resolver can't find a\n // user) would needlessly notify subscribers and, combined with a\n // subscriber that re-triggers loading, could cause an infinite loop.\n // See https://github.com/TypeCellOS/BlockNote/issues/1548\n if (users.length > 0) {\n store.setState((prevState) => {\n const nextState = new Map(prevState);\n for (const user of users) {\n nextState.set(user.id, user);\n }\n return nextState;\n });\n }\n } finally {\n for (const id of userIds) {\n // Remove the users from the loading set. On a next call to `loadUsers`\n // we will either return the cached user, or retry loading the user if\n // the request failed.\n loadingUsers.delete(id);\n }\n }\n }\n\n return userStore;\n}\n\n/**\n * Normalize a {@link UserStoreOrResolver} to a {@link UserStore}:\n * - an existing store is returned as-is (so a single de-duped cache can be\n * shared across extensions),\n * - a resolver function is wrapped with {@link createUserStore},\n * - `undefined` yields an empty store that resolves nothing (consumers then fall\n * back to showing raw user ids).\n */\nexport function normalizeToUserStore<U extends User = User>(\n resolveUsersOrStore?: UserStoreOrResolver<U>,\n): UserStore<U> {\n if (typeof resolveUsersOrStore === \"function\") {\n return createUserStore(resolveUsersOrStore);\n }\n return resolveUsersOrStore ?? createUserStore<U>(async () => []);\n}\n"],"mappings":"sHAOA,IAAM,EAAa,IAAI,EAAA,UAAU,0BAA0B,EAO9C,EAAyB,EAAA,GAAiB,CAAE,YAAa,CACpE,IAAM,EAAQ,EAAA,EACZ,CAAE,WAAY,IAAI,GAAc,EAChC,CACE,UAAW,CACT,EAAO,SAAU,GAAO,EAAG,QAAQ,EAAY,CAAC,CAAC,CAAC,CACpD,CACF,CACF,EACA,MAAO,CACL,IAAK,gBACL,QACA,mBAAoB,CAClB,IAAI,EAAA,OAAO,CACT,IAAK,EACL,MAAO,CACL,YAAc,GAAU,CACtB,GAAM,CAAE,MAAK,aAAc,EAC3B,GAAI,EAAM,MAAM,WAAW,OAAS,EAClC,OAAO,EAAA,cAAc,MAEvB,IAAM,EAAM,EAAA,WAAW,OAAO,EAAU,KAAM,EAAU,GAAI,CAC1D,sBAAuB,MACzB,CAAC,EACD,OAAO,EAAA,cAAc,OAAO,EAAK,CAAC,CAAG,CAAC,CACxC,CACF,CACF,CAAC,CACH,EAUA,cAAc,EAAqB,EAAa,CAC9C,EAAM,SAAS,CACb,WAAY,EACR,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,WAAY,CAAG,CAAC,EACxC,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,UAAU,CAAC,CAAC,OAAQ,GAAM,IAAM,CAAG,CAAC,CAClE,CAAC,CACH,CACF,CACF,CAAC,EC4CD,SAAgB,EACd,EACc,CACd,GAAI,CAAC,EACH,MAAU,MAAM,iDAAiD,EAGnE,IAAM,EAAQ,EAAA,EAAY,IAAI,GAAoB,EAK5C,EAAe,IAAI,IAEnB,EAA0B,CAC9B,QACA,MAAM,UAAU,EAAS,CAIvB,MAAM,EAHe,EAAQ,OAC1B,GAAO,CAAC,EAAM,MAAM,IAAI,CAAE,GAAK,CAAC,EAAa,IAAI,CAAE,CAErC,CAAY,CAC/B,EACA,MAAM,aAAa,EAAS,CAE1B,MAAM,EADe,EAAQ,OAAQ,GAAO,CAAC,EAAa,IAAI,CAAE,CAC/C,CAAY,CAC/B,EACA,QAAQ,EAAQ,CACd,OAAO,EAAM,MAAM,IAAI,CAAM,CAC/B,EACA,QAAQ,EAAO,CACb,IAAM,EAAa,MAAM,QAAQ,CAAK,EAAI,EAAQ,CAAC,CAAK,EACxD,EAAM,SAAU,GAAc,CAC5B,IAAM,EAAY,IAAI,IAAI,CAAS,EACnC,IAAK,IAAM,KAAQ,EACjB,EAAU,IAAI,EAAK,GAAI,CAAI,EAE7B,OAAO,CACT,CAAC,CACH,CACF,EAEA,eAAe,EAAW,EAAuB,CAC3C,KAAQ,SAAW,EAIvB,KAAK,IAAM,KAAM,EACf,EAAa,IAAI,CAAE,EAGrB,GAAI,CACF,IAAM,EAAQ,MAAM,EAAa,EAAS,CAAS,EAM/C,EAAM,OAAS,GACjB,EAAM,SAAU,GAAc,CAC5B,IAAM,EAAY,IAAI,IAAI,CAAS,EACnC,IAAK,IAAM,KAAQ,EACjB,EAAU,IAAI,EAAK,GAAI,CAAI,EAE7B,OAAO,CACT,CAAC,CAEL,QAAU,CACR,IAAK,IAAM,KAAM,EAIf,EAAa,OAAO,CAAE,CAE1B,CA1BqB,CA2BvB,CAEA,OAAO,CACT,CAUA,SAAgB,EACd,EACc,CAId,OAHI,OAAO,GAAwB,WAC1B,EAAgB,CAAmB,EAErC,GAAuB,EAAmB,SAAY,CAAC,CAAC,CACjE"}
|
package/dist/blocknote.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./blocks-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./blocks-CzkqclGj.cjs"),t=require("./BlockNoteExtension-BJCLnwrE.cjs"),n=require("./src-DM3syMdf.cjs"),r=require("./extensions-CSB9ZvuL.cjs"),i=require("./UserStore-mj3fXW4D.cjs");exports.BLOCK_LEVEL_SUGGESTION_GROUP=e.O,exports.BlockChangeExtension=r.N,exports.BlockNoteEditor=n.o,exports.BlockNoteSchema=e.t,exports.COLORS_DARK_MODE_DEFAULT=e.Ot,exports.COLORS_DEFAULT=e.kt,exports.CURRENT_VERSION_ID=r.i,exports.CustomBlockNoteSchema=e.Yt,exports.DEFAULT_LINK_PROTOCOL=r.E,exports.DRAG_EXCLUSION_CLASSNAME=r.j,exports.DropCursorExtension=r.M,exports.EMPTY_CELL_HEIGHT=e.E,exports.EMPTY_CELL_WIDTH=e.D,exports.EventEmitter=n.g,exports.Exporter=n.a,exports.FILE_AUDIO_ICON_SVG=e.mt,exports.FILE_IMAGE_ICON_SVG=e.K,exports.FILE_VIDEO_ICON_SVG=e.b,exports.FilePanelExtension=e.xt,exports.FormattingToolbarExtension=e.m,exports.HTMLToBlocks=n.d,exports.HistoryExtension=r.A,exports.InlineContentBoundaryEditExtension=r.k,exports.LinkToolbarExtension=r.O,exports.NON_FORMATTING_MARK_GROUP=t.a,exports.NodeSelectionKeyboardExtension=r.T,exports.PlaceholderExtension=r.w,exports.PositionMappingExtension=r.C,exports.PreviousBlockTypeExtension=r.S,exports.ShowSelectionExtension=i.r,exports.SideMenuExtension=r.g,exports.SideMenuView=r._,exports.SourceBlockWithPreviewExtension=r.h,exports.SourceInlineContentWithPreviewExtension=r.m,exports.Store=t.i,exports.SuggestionMenu=e.f,exports.SyntaxHighlightingExtension=r.f,exports.TableHandlesExtension=r.c,exports.TableHandlesView=r.l,exports.TrailingNodeExtension=r.s,exports.UniqueID=e.$n,exports.UnreachableCaseError=e.Un,exports.VALID_LINK_PROTOCOLS=r.D,exports.VersioningExtension=r.a,exports.addDefaultPropsExternalHTML=e.St,exports.addInlineContentAttributes=e.in,exports.addInlineContentKeyboardShortcuts=e.an,exports.addNodeAndExtensionsToSpec=e.ln,exports.addStyleAttributes=e.$t,exports.applyNonSelectableBlockFix=e.un,exports.assertEmpty=e.Wn,exports.audioParse=e.ht,exports.audioRender=e.gt,exports.audioToExternalHTML=e._t,exports.blockHasType=e.h,exports.blockToNode=e.It,exports.blocksToMarkdown=r.b,exports.bytesToBase64=n.r,exports.camelToDataKebab=e.yn,exports.captureCellAnchor=e.At,exports.checkPageBreakBlocksInSchema=e.s,exports.cleanHTMLToMarkdown=r.x,exports.collectHighlightNodeTypes=r.p,exports.colorsForUserIds=n._,exports.combineByGroup=n.t,exports.contentNodeToInlineContent=e.Sn,exports.contentNodeToTableContent=e.Cn,exports.createAudioBlockConfig=e.vt,exports.createAudioBlockSpec=e.yt,exports.createBlockConfig=e.dn,exports.createBlockSpec=e.fn,exports.createBlockSpecFromTiptapNode=e.mn,exports.createBulletListItemBlockConfig=e.U,exports.createBulletListItemBlockSpec=e.W,exports.createCheckListItemBlockSpec=e.V,exports.createCheckListItemConfig=e.H,exports.createCodeBlock=e.lt,exports.createCodeBlockConfig=e.st,exports.createCodeBlockSpec=e.ct,exports.createDefaultBlockDOMOutputSpec=e.In,exports.createDividerBlockConfig=e.at,exports.createDividerBlockSpec=e.ot,exports.createExtension=t.t,exports.createExternalHTMLExporter=r.F,exports.createFileBlockConfig=e.nt,exports.createFileBlockSpec=e.rt,exports.createHeadingBlockConfig=e.Q,exports.createHeadingBlockSpec=e.$,exports.createImageBlockConfig=e.q,exports.createImageBlockSpec=e.J,exports.createInMemoryPreviewController=r.t,exports.createInMemoryVersioningAdapter=r.n,exports.createInMemoryVersioningEndpoints=r.r,exports.createInlineContentSpec=n.O,exports.createInlineContentSpecFromTipTapNode=e.on,exports.createInternalHTMLSerializer=n.S,exports.createInternalInlineContentSpec=e.sn,exports.createInternalStyleSpec=e.en,exports.createLanguageSelect=e.ut,exports.createNumberedListItemBlockConfig=e.z,exports.createNumberedListItemBlockSpec=e.B,exports.createPageBreakBlockConfig=e.P,exports.createPageBreakBlockSpec=e.F,exports.createParagraphBlockConfig=e.M,exports.createParagraphBlockSpec=e.N,exports.createPreCode=e.dt,exports.createQuoteBlockConfig=e.A,exports.createQuoteBlockSpec=e.j,exports.createStore=t.n,exports.createStyleSpec=e.Zt,exports.createStyleSpecFromTipTapMark=e.tn,exports.createTableBlockSpec=e.w,exports.createToggleListItemBlockConfig=e.L,exports.createToggleListItemBlockSpec=e.R,exports.createToggleWrapper=e.et,exports.createUserStore=i.t,exports.createVideoBlockConfig=e.x,exports.createVideoBlockSpec=e.S,exports.cssVarUserId=n.v,exports.defaultBlockSpecs=e.n,exports.defaultBlockToHTML=e.Ln,exports.defaultInlineContentSchema=e.r,exports.defaultInlineContentSpecs=e.i,exports.defaultProps=e.Ct,exports.defaultStyleSchema=e.a,exports.defaultStyleSpecs=e.o,exports.defaultToggledState=e.tt,exports.docToBlocks=e.wn,exports.editorHasBlockWithType=e.g,exports.expandPMRangeToWords=n.s,exports.exportImageToDataURL=n.i,exports.fallbackColorForUserId=n.y,exports.fileParse=e.it,exports.filenameFromURL=e.bn,exports.filterSuggestionItems=e.l,exports.fixColumnList=n.w,exports.formatKeyboardShortcut=e.zn,exports.fragmentToBlocks=r.y,exports.getBackgroundColorAttribute=e.wt,exports.getBlock=n.f,exports.getBlockCache=e.On,exports.getBlockFromNodeView=e.hn,exports.getBlockFromPos=e.gn,exports.getBlockInfo=e.er,exports.getBlockInfoAtNearest=e.tr,exports.getBlockInfoFromResolvedPos=e.nr,exports.getBlockInfoFromSelection=e.rr,exports.getBlockInfoWithManualOffset=e.ir,exports.getBlockNoteSchema=e.kn,exports.getBlockSchema=e.An,exports.getBlocksChangedByTransaction=r.P,exports.getColspan=e.Gn,exports.getDefaultEmojiPickerItems=r.d,exports.getDefaultSlashMenuItems=e.u,exports.getInlineContentParseRules=n.k,exports.getInlineContentSchema=e.jn,exports.getInlineContentSchemaFromSpecs=e.cn,exports.getNearestBlockPos=e.ar,exports.getNextBlock=n.p,exports.getNodeById=e.Pt,exports.getNodeId=e.or,exports.getPageBreakSlashMenuItems=e.c,exports.getParentBlock=n.m,exports.getParseRules=e.pn,exports.getPmSchema=e.Mn,exports.getPrevBlock=n.h,exports.getRowspan=e.Kn,exports.getStyleParseRules=e.Qt,exports.getStyleSchema=e.Nn,exports.getStyleSchemaFromSpecs=e.nn,exports.getTextAlignmentAttribute=e.Tt,exports.getTextColorAttribute=e.Et,exports.imageParse=e.Y,exports.imageRender=e.X,exports.imageToExternalHTML=e.Z,exports.inlineContentToNodes=e.Lt,exports.insertBlocks=n.D,exports.insertOrUpdateBlockForSlashMenu=e.d,exports.isAppleOS=e.Bn,exports.isEmptyColumn=n.T,exports.isLinkInlineContent=e.Xn,exports.isNodeBlock=e.Ft,exports.isPartialLinkInlineContent=e.Zn,exports.isPartialTableCell=e.qn,exports.isPlainContentNodeType=e.Pn,exports.isSafari=e.Vn,exports.isStyledTextInlineContent=e.Qn,exports.isSuggestedDeletionNode=e.sr,exports.isTableCell=e.Jn,exports.isTableCellNode=e._,exports.isTableCellSelection=e.v,exports.isVideoUrl=e.xn,exports.mapTableCell=e.Yn,exports.mappingFactory=n.n,exports.markdownToBlocks=n.l,exports.markdownToHTML=n.u,exports.mergeCSSClasses=e.Hn,exports.mergeParagraphs=e.Rn,exports.nodeToBlock=e.Tn,exports.nodeToCustomInlineContent=e.En,exports.nonFormattingMarks=t.o,exports.normalizeToUserStore=i.n,exports.parseAudioElement=e.bt,exports.parseDefaultProps=e.Dt,exports.parsePreCode=e.ft,exports.parsePreCodeContent=e.pt,exports.plainContentToString=n.A,exports.propsToAttributes=e._n,exports.prosemirrorSliceToSlicedBlocks=e.Dn,exports.removeAndInsertBlocks=n.C,exports.removeEmptyColumns=n.E,exports.selectedFragmentToHTML=n.c,exports.sideMenuPluginKey=r.v,exports.sortSnapshotsNewestFirst=r.o,exports.stylePropsToAttributes=e.rn,exports.suggestionMarks=e.k,exports.tableContentToNodes=e.Rt,exports.tableHandlesPluginKey=r.u,exports.tablePropSchema=e.T,exports.trackPosition=e.p,exports.updateBlock=e.jt,exports.updateBlockCommand=e.Mt,exports.updateBlockTr=e.Nt,exports.uploadToTmpFilesDotOrg_DEV_ONLY=e.y,exports.userColorPalette=n.b,exports.userColorVarNames=n.x,exports.videoParse=e.C,exports.withPageBreak=e.I,exports.wrapInBlockStructure=e.vn;
|
package/dist/blocknote.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as e, $n as t, $t as n, A as r, An as i, At as a, B as o, Bn as s, C as c, Cn as l, Ct as u, D as d, Dn as f, Dt as p, E as m, En as h, Et as g, F as _,
|
|
2
|
-
import { a as
|
|
3
|
-
import { C as
|
|
4
|
-
import { A as
|
|
5
|
-
import { n as
|
|
6
|
-
export {
|
|
1
|
+
import { $ as e, $n as t, $t as n, A as r, An as i, At as a, B as o, Bn as s, C as c, Cn as l, Ct as u, D as d, Dn as f, Dt as p, E as m, En as h, Et as g, F as _, Ft as v, Gn as y, H as b, Hn as x, I as S, In as C, It as w, J as T, Jn as E, K as D, Kn as O, L as k, Ln as A, Lt as j, M, Mn as N, Mt as P, N as F, Nn as I, Nt as L, O as R, On as z, Ot as B, P as V, Pn as H, Pt as U, Q as W, Qn as G, Qt as K, R as q, Rn as J, Rt as Y, S as X, Sn as Z, St as Q, T as $, Tn as ee, Tt as te, U as ne, Un as re, V as ie, Vn as ae, W as oe, Wn as se, X as ce, Xn as le, Y as ue, Yn as de, Yt as fe, Z as pe, Zn as me, Zt as he, _ as ge, _n as _e, _t as ve, a as ye, an as be, ar as xe, at as Se, b as Ce, bn as we, bt as Te, c as Ee, cn as De, ct as Oe, d as ke, dn as Ae, dt as je, en as Me, er as Ne, et as Pe, f as Fe, fn as Ie, ft as Le, g as Re, gn as ze, gt as Be, h as Ve, hn as He, ht as Ue, i as We, in as Ge, ir as Ke, it as qe, j as Je, jn as Ye, jt as Xe, k as Ze, kn as Qe, kt as $e, l as et, ln as tt, lt as nt, m as rt, mn as it, mt as at, n as ot, nn as st, nr as ct, nt as lt, o as ut, on as dt, or as ft, ot as pt, p as mt, pn as ht, pt as gt, q as _t, qn as vt, r as yt, rn as bt, rr as xt, rt as St, s as Ct, sn as wt, sr as Tt, st as Et, t as Dt, tn as Ot, tr as kt, tt as At, u as jt, un as Mt, ut as Nt, v as Pt, vn as Ft, vt as It, w as Lt, wn as Rt, wt as zt, x as Bt, xn as Vt, xt as Ht, y as Ut, yn as Wt, yt as Gt, z as Kt, zn as qt } from "./blocks-CzQLehlc.js";
|
|
2
|
+
import { a as Jt, i as Yt, n as Xt, o as Zt, t as Qt } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
+
import { A as $t, C as en, D as tn, E as nn, O as rn, S as an, T as on, _ as sn, a as cn, b as ln, c as un, d as dn, f as fn, g as pn, h as mn, i as hn, k as gn, l as _n, m as vn, n as yn, o as bn, p as xn, r as Sn, s as Cn, t as wn, u as Tn, v as En, w as Dn, x as On, y as kn } from "./src-BkfZVfaO.js";
|
|
4
|
+
import { A as An, C as jn, D as Mn, E as Nn, F as Pn, M as Fn, N as In, O as Ln, P as Rn, S as zn, T as Bn, _ as Vn, a as Hn, b as Un, c as Wn, d as Gn, f as Kn, g as qn, h as Jn, i as Yn, j as Xn, k as Zn, l as Qn, m as $n, n as er, o as tr, p as nr, r as rr, s as ir, t as ar, u as or, v as sr, w as cr, x as lr, y as ur } from "./extensions-DGuhtOgB.js";
|
|
5
|
+
import { n as dr, r as fr, t as pr } from "./UserStore-C4TzkGEn.js";
|
|
6
|
+
export { R as BLOCK_LEVEL_SUGGESTION_GROUP, In as BlockChangeExtension, bn as BlockNoteEditor, Dt as BlockNoteSchema, B as COLORS_DARK_MODE_DEFAULT, $e as COLORS_DEFAULT, Yn as CURRENT_VERSION_ID, fe as CustomBlockNoteSchema, Nn as DEFAULT_LINK_PROTOCOL, Xn as DRAG_EXCLUSION_CLASSNAME, Fn as DropCursorExtension, m as EMPTY_CELL_HEIGHT, d as EMPTY_CELL_WIDTH, pn as EventEmitter, cn as Exporter, at as FILE_AUDIO_ICON_SVG, D as FILE_IMAGE_ICON_SVG, Ce as FILE_VIDEO_ICON_SVG, Ht as FilePanelExtension, rt as FormattingToolbarExtension, dn as HTMLToBlocks, An as HistoryExtension, Zn as InlineContentBoundaryEditExtension, Ln as LinkToolbarExtension, Jt as NON_FORMATTING_MARK_GROUP, Bn as NodeSelectionKeyboardExtension, cr as PlaceholderExtension, jn as PositionMappingExtension, zn as PreviousBlockTypeExtension, fr as ShowSelectionExtension, qn as SideMenuExtension, Vn as SideMenuView, Jn as SourceBlockWithPreviewExtension, $n as SourceInlineContentWithPreviewExtension, Yt as Store, Fe as SuggestionMenu, Kn as SyntaxHighlightingExtension, Wn as TableHandlesExtension, Qn as TableHandlesView, ir as TrailingNodeExtension, t as UniqueID, re as UnreachableCaseError, Mn as VALID_LINK_PROTOCOLS, Hn as VersioningExtension, Q as addDefaultPropsExternalHTML, Ge as addInlineContentAttributes, be as addInlineContentKeyboardShortcuts, tt as addNodeAndExtensionsToSpec, n as addStyleAttributes, Mt as applyNonSelectableBlockFix, se as assertEmpty, Ue as audioParse, Be as audioRender, ve as audioToExternalHTML, Ve as blockHasType, w as blockToNode, Un as blocksToMarkdown, Sn as bytesToBase64, Wt as camelToDataKebab, a as captureCellAnchor, Ct as checkPageBreakBlocksInSchema, lr as cleanHTMLToMarkdown, nr as collectHighlightNodeTypes, sn as colorsForUserIds, wn as combineByGroup, Z as contentNodeToInlineContent, l as contentNodeToTableContent, It as createAudioBlockConfig, Gt as createAudioBlockSpec, Ae as createBlockConfig, Ie as createBlockSpec, it as createBlockSpecFromTiptapNode, ne as createBulletListItemBlockConfig, oe as createBulletListItemBlockSpec, ie as createCheckListItemBlockSpec, b as createCheckListItemConfig, nt as createCodeBlock, Et as createCodeBlockConfig, Oe as createCodeBlockSpec, C as createDefaultBlockDOMOutputSpec, Se as createDividerBlockConfig, pt as createDividerBlockSpec, Qt as createExtension, Pn as createExternalHTMLExporter, lt as createFileBlockConfig, St as createFileBlockSpec, W as createHeadingBlockConfig, e as createHeadingBlockSpec, _t as createImageBlockConfig, T as createImageBlockSpec, ar as createInMemoryPreviewController, er as createInMemoryVersioningAdapter, rr as createInMemoryVersioningEndpoints, rn as createInlineContentSpec, dt as createInlineContentSpecFromTipTapNode, an as createInternalHTMLSerializer, wt as createInternalInlineContentSpec, Me as createInternalStyleSpec, Nt as createLanguageSelect, Kt as createNumberedListItemBlockConfig, o as createNumberedListItemBlockSpec, V as createPageBreakBlockConfig, _ as createPageBreakBlockSpec, M as createParagraphBlockConfig, F as createParagraphBlockSpec, je as createPreCode, r as createQuoteBlockConfig, Je as createQuoteBlockSpec, Xt as createStore, he as createStyleSpec, Ot as createStyleSpecFromTipTapMark, Lt as createTableBlockSpec, k as createToggleListItemBlockConfig, q as createToggleListItemBlockSpec, Pe as createToggleWrapper, pr as createUserStore, Bt as createVideoBlockConfig, X as createVideoBlockSpec, En as cssVarUserId, ot as defaultBlockSpecs, A as defaultBlockToHTML, yt as defaultInlineContentSchema, We as defaultInlineContentSpecs, u as defaultProps, ye as defaultStyleSchema, ut as defaultStyleSpecs, At as defaultToggledState, Rt as docToBlocks, Re as editorHasBlockWithType, Cn as expandPMRangeToWords, hn as exportImageToDataURL, kn as fallbackColorForUserId, qe as fileParse, we as filenameFromURL, et as filterSuggestionItems, Dn as fixColumnList, qt as formatKeyboardShortcut, ur as fragmentToBlocks, zt as getBackgroundColorAttribute, fn as getBlock, z as getBlockCache, He as getBlockFromNodeView, ze as getBlockFromPos, Ne as getBlockInfo, kt as getBlockInfoAtNearest, ct as getBlockInfoFromResolvedPos, xt as getBlockInfoFromSelection, Ke as getBlockInfoWithManualOffset, Qe as getBlockNoteSchema, i as getBlockSchema, Rn as getBlocksChangedByTransaction, y as getColspan, Gn as getDefaultEmojiPickerItems, jt as getDefaultSlashMenuItems, gn as getInlineContentParseRules, Ye as getInlineContentSchema, De as getInlineContentSchemaFromSpecs, xe as getNearestBlockPos, xn as getNextBlock, U as getNodeById, ft as getNodeId, Ee as getPageBreakSlashMenuItems, vn as getParentBlock, ht as getParseRules, N as getPmSchema, mn as getPrevBlock, O as getRowspan, K as getStyleParseRules, I as getStyleSchema, st as getStyleSchemaFromSpecs, te as getTextAlignmentAttribute, g as getTextColorAttribute, ue as imageParse, ce as imageRender, pe as imageToExternalHTML, j as inlineContentToNodes, tn as insertBlocks, ke as insertOrUpdateBlockForSlashMenu, s as isAppleOS, on as isEmptyColumn, le as isLinkInlineContent, v as isNodeBlock, me as isPartialLinkInlineContent, vt as isPartialTableCell, H as isPlainContentNodeType, ae as isSafari, G as isStyledTextInlineContent, Tt as isSuggestedDeletionNode, E as isTableCell, ge as isTableCellNode, Pt as isTableCellSelection, Vt as isVideoUrl, de as mapTableCell, yn as mappingFactory, _n as markdownToBlocks, Tn as markdownToHTML, x as mergeCSSClasses, J as mergeParagraphs, ee as nodeToBlock, h as nodeToCustomInlineContent, Zt as nonFormattingMarks, dr as normalizeToUserStore, Te as parseAudioElement, p as parseDefaultProps, Le as parsePreCode, gt as parsePreCodeContent, $t as plainContentToString, _e as propsToAttributes, f as prosemirrorSliceToSlicedBlocks, en as removeAndInsertBlocks, nn as removeEmptyColumns, un as selectedFragmentToHTML, sr as sideMenuPluginKey, tr as sortSnapshotsNewestFirst, bt as stylePropsToAttributes, Ze as suggestionMarks, Y as tableContentToNodes, or as tableHandlesPluginKey, $ as tablePropSchema, mt as trackPosition, Xe as updateBlock, P as updateBlockCommand, L as updateBlockTr, Ut as uploadToTmpFilesDotOrg_DEV_ONLY, ln as userColorPalette, On as userColorVarNames, c as videoParse, S as withPageBreak, Ft as wrapInBlockStructure };
|