@blocknote/core 0.53.0 → 0.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/BlockNoteExtension-BJCLnwrE.cjs +2 -0
  2. package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
  3. package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
  4. package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
  5. package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
  6. package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
  7. package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
  8. package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
  9. package/dist/blocknote.cjs +1 -1
  10. package/dist/blocknote.js +6 -6
  11. package/dist/blocks-CTB_5Vyj.cjs +12 -0
  12. package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
  13. package/dist/{blocks-BEJW9OM_.js → blocks-Dol85hpH.js} +680 -670
  14. package/dist/blocks-Dol85hpH.js.map +1 -0
  15. package/dist/blocks.cjs +1 -1
  16. package/dist/blocks.js +2 -2
  17. package/dist/comments.cjs +1 -1
  18. package/dist/comments.cjs.map +1 -1
  19. package/dist/comments.js +7 -7
  20. package/dist/comments.js.map +1 -1
  21. package/dist/en-BuzSuuTq.cjs +2 -0
  22. package/dist/en-BuzSuuTq.cjs.map +1 -0
  23. package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
  24. package/dist/en-uzHzj6eH.js.map +1 -0
  25. package/dist/extensions-B7Rsp_Ft.cjs +58 -0
  26. package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
  27. package/dist/{extensions-BR5hkAio.js → extensions-D6JcJCwd.js} +735 -457
  28. package/dist/extensions-D6JcJCwd.js.map +1 -0
  29. package/dist/extensions.cjs +1 -1
  30. package/dist/extensions.js +4 -4
  31. package/dist/locales.cjs +1 -1
  32. package/dist/locales.cjs.map +1 -1
  33. package/dist/locales.js +199 -1
  34. package/dist/locales.js.map +1 -1
  35. package/dist/{src-BUXut68d.js → src-Buuo5l7X.js} +924 -851
  36. package/dist/src-Buuo5l7X.js.map +1 -0
  37. package/dist/src-C54Ok9E0.cjs +23 -0
  38. package/dist/src-C54Ok9E0.cjs.map +1 -0
  39. package/dist/style.css +1 -1
  40. package/dist/webpack-stats.json +1 -1
  41. package/dist/y.cjs +1 -1
  42. package/dist/y.cjs.map +1 -1
  43. package/dist/y.js +245 -242
  44. package/dist/y.js.map +1 -1
  45. package/dist/yjs.cjs +1 -1
  46. package/dist/yjs.cjs.map +1 -1
  47. package/dist/yjs.js +79 -67
  48. package/dist/yjs.js.map +1 -1
  49. package/package.json +17 -18
  50. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
  51. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
  52. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
  53. package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
  54. package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
  55. package/src/api/getBlocksChangedByTransaction.ts +48 -12
  56. package/src/api/getChangedRange.ts +54 -0
  57. package/src/api/nodeConversions/blockToNode.ts +5 -1
  58. package/src/api/nodeConversions/nodeToBlock.ts +3 -0
  59. package/src/api/pmUtil.ts +16 -8
  60. package/src/blocks/Code/CodeBlockOptions.ts +83 -0
  61. package/src/blocks/Code/block.test.ts +1 -1
  62. package/src/blocks/Code/block.ts +29 -281
  63. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
  64. package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
  65. package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
  66. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
  67. package/src/blocks/index.ts +3 -1
  68. package/src/comments/extension.ts +2 -4
  69. package/src/editor/Block.css +273 -2
  70. package/src/editor/BlockNoteEditor.ts +25 -4
  71. package/src/editor/BlockNoteExtension.ts +1 -1
  72. package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
  73. package/src/editor/performance.test.ts +45 -0
  74. package/src/exporter/ExportImage.ts +50 -0
  75. package/src/exporter/Exporter.test.ts +186 -0
  76. package/src/exporter/Exporter.ts +66 -14
  77. package/src/exporter/index.ts +1 -0
  78. package/src/exporter/mapping.ts +4 -1
  79. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
  80. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
  81. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
  82. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
  83. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
  84. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
  85. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
  86. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
  87. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
  88. package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
  89. package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
  90. package/src/extensions/TableHandles/TableHandles.ts +82 -41
  91. package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
  92. package/src/extensions/index.ts +4 -0
  93. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
  94. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
  95. package/src/fonts/inter.css +9 -9
  96. package/src/i18n/locales/ar.ts +9 -0
  97. package/src/i18n/locales/de.ts +9 -0
  98. package/src/i18n/locales/en.ts +9 -0
  99. package/src/i18n/locales/es.ts +9 -0
  100. package/src/i18n/locales/fa.ts +9 -0
  101. package/src/i18n/locales/fr.ts +9 -0
  102. package/src/i18n/locales/he.ts +9 -0
  103. package/src/i18n/locales/hr.ts +9 -0
  104. package/src/i18n/locales/is.ts +9 -0
  105. package/src/i18n/locales/it.ts +9 -0
  106. package/src/i18n/locales/ja.ts +9 -0
  107. package/src/i18n/locales/ko.ts +9 -0
  108. package/src/i18n/locales/nl.ts +9 -0
  109. package/src/i18n/locales/no.ts +9 -0
  110. package/src/i18n/locales/pl.ts +9 -0
  111. package/src/i18n/locales/pt.ts +9 -0
  112. package/src/i18n/locales/ru.ts +9 -0
  113. package/src/i18n/locales/sk.ts +9 -0
  114. package/src/i18n/locales/uk.ts +9 -0
  115. package/src/i18n/locales/uz.ts +9 -0
  116. package/src/i18n/locales/vi.ts +9 -0
  117. package/src/i18n/locales/zh-tw.ts +9 -0
  118. package/src/i18n/locales/zh.ts +9 -0
  119. package/src/index.ts +5 -1
  120. package/src/schema/blocks/createSpec.ts +5 -7
  121. package/src/schema/blocks/types.ts +53 -3
  122. package/src/schema/contentTypePropagation.test.ts +1 -1
  123. package/src/schema/inlineContent/createSpec.test.ts +161 -0
  124. package/src/schema/inlineContent/createSpec.ts +175 -17
  125. package/src/schema/inlineContent/internal.ts +21 -2
  126. package/src/schema/inlineContent/types.ts +35 -5
  127. package/src/schema/nodeViewMutations.test.ts +81 -56
  128. package/src/schema/nodeViewMutations.ts +30 -27
  129. package/src/schema/schema.test.ts +110 -0
  130. package/src/schema/schema.ts +13 -4
  131. package/src/user/UserStore.ts +1 -1
  132. package/src/util/Store.test.ts +132 -0
  133. package/src/util/Store.ts +135 -0
  134. package/src/y/extensions/AttributionExtension.test.ts +18 -9
  135. package/src/y/extensions/Versioning.test.ts +20 -7
  136. package/src/y/versioning/__test__/yhub.test.ts +92 -59
  137. package/src/y/versioning/yhub.ts +35 -29
  138. package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
  139. package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
  140. package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
  141. package/src/yjs/extensions/ForkYDoc.ts +26 -1
  142. package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
  143. package/src/yjs/extensions/Versioning.test.ts +17 -5
  144. package/types/src/api/getChangedRange.d.ts +14 -0
  145. package/types/src/api/pmUtil.d.ts +7 -7
  146. package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
  147. package/types/src/blocks/Code/block.d.ts +3 -53
  148. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
  149. package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
  150. package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
  151. package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
  152. package/types/src/blocks/index.d.ts +3 -1
  153. package/types/src/comments/extension.d.ts +1 -15
  154. package/types/src/editor/BlockNoteEditor.d.ts +3 -3
  155. package/types/src/editor/BlockNoteExtension.d.ts +1 -1
  156. package/types/src/exporter/ExportImage.d.ts +36 -0
  157. package/types/src/exporter/Exporter.d.ts +30 -0
  158. package/types/src/exporter/Exporter.test.d.ts +1 -0
  159. package/types/src/exporter/index.d.ts +1 -0
  160. package/types/src/exporter/mapping.d.ts +1 -1
  161. package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
  162. package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
  163. package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
  164. package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
  165. package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
  166. package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
  167. package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
  168. package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
  169. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
  170. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
  171. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
  172. package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
  173. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
  174. package/types/src/extensions/TableHandles/TableHandles.d.ts +4 -1
  175. package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
  176. package/types/src/extensions/index.d.ts +4 -0
  177. package/types/src/i18n/locales/en.d.ts +9 -0
  178. package/types/src/i18n/locales/fa.d.ts +9 -0
  179. package/types/src/i18n/locales/sk.d.ts +9 -0
  180. package/types/src/index.d.ts +2 -1
  181. package/types/src/schema/blocks/types.d.ts +36 -3
  182. package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
  183. package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
  184. package/types/src/schema/inlineContent/internal.d.ts +3 -2
  185. package/types/src/schema/inlineContent/types.d.ts +22 -3
  186. package/types/src/schema/nodeViewMutations.d.ts +2 -2
  187. package/types/src/schema/schema.test.d.ts +1 -0
  188. package/types/src/user/UserStore.d.ts +1 -1
  189. package/types/src/util/Store.d.ts +45 -0
  190. package/types/src/util/Store.test.d.ts +1 -0
  191. package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
  192. package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
  193. package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
  194. package/types/src/y/extensions/index.d.ts +2 -10
  195. package/types/src/y/versioning/yhub.d.ts +3 -2
  196. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
  197. package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
  198. package/types/src/yjs/extensions/index.d.ts +1 -5
  199. package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
  200. package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
  201. package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
  202. package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
  203. package/dist/UserStore-QbbPFj0z.js.map +0 -1
  204. package/dist/blocks-BEJW9OM_.js.map +0 -1
  205. package/dist/blocks-BPmJglFo.cjs +0 -12
  206. package/dist/blocks-BPmJglFo.cjs.map +0 -1
  207. package/dist/en-C5Z4Ag9_.cjs +0 -2
  208. package/dist/en-C5Z4Ag9_.cjs.map +0 -1
  209. package/dist/en-CGKXfWma.js.map +0 -1
  210. package/dist/extensions-AitWbYdJ.cjs +0 -52
  211. package/dist/extensions-AitWbYdJ.cjs.map +0 -1
  212. package/dist/extensions-BR5hkAio.js.map +0 -1
  213. package/dist/src-BHPuOo7W.cjs +0 -21
  214. package/dist/src-BHPuOo7W.cjs.map +0 -1
  215. package/dist/src-BUXut68d.js.map +0 -1
  216. package/src/blocks/Code/shiki.ts +0 -73
  217. package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
  218. package/types/src/blocks/Code/shiki.d.ts +0 -4
  219. package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
@@ -1,6 +1,6 @@
1
1
  /** Define the main block types **/
2
2
  import type { Node, NodeViewRendererProps } from "@tiptap/core";
3
- import type { Fragment, Schema } from "prosemirror-model";
3
+ import type { Fragment, Node as ProsemirrorNode, Schema } from "prosemirror-model";
4
4
  import type { ViewMutationRecord } from "prosemirror-view";
5
5
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
6
6
  import type { Extension, ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
@@ -11,7 +11,7 @@ export type BlockNoteDOMElement = "editor" | "block" | "blockGroup" | "blockCont
11
11
  export type BlockNoteDOMAttributes = Partial<{
12
12
  [DOMElement in BlockNoteDOMElement]: Record<string, string>;
13
13
  }>;
14
- export interface BlockConfigMeta {
14
+ export interface BlockConfigMeta<TName extends string = string, TProps extends PropSchema = PropSchema> {
15
15
  /**
16
16
  * Defines which keyboard shortcut should be used to insert a hard break into the block's inline content.
17
17
  * @default "shift+enter"
@@ -37,6 +37,19 @@ export interface BlockConfigMeta {
37
37
  * Whether the block is a {@link https://prosemirror.net/docs/ref/#model.NodeSpec.isolating} block
38
38
  */
39
39
  isolating?: boolean;
40
+ /**
41
+ * Enables syntax highlighting of the contents of the block with the result of this callback
42
+ */
43
+ highlight?(block: {
44
+ type: TName;
45
+ props: Props<TProps>;
46
+ }): string | undefined;
47
+ /**
48
+ * Marks the block as rendering a preview with an editable source popup, driven
49
+ * by the editor-wide `SourceBlockWithPreviewExtension`. When `true`, the
50
+ * block's source is hidden behind its preview and edited via the popup.
51
+ */
52
+ hasPreview?: boolean;
40
53
  }
41
54
  /**
42
55
  * BlockConfig contains the "schema" info about a Block type
@@ -102,6 +115,7 @@ export type LooseBlockSpec<T extends string = string, PS extends PropSchema = Pr
102
115
  dom: HTMLElement | DocumentFragment;
103
116
  contentDOM?: HTMLElement;
104
117
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
118
+ update?: (node: ProsemirrorNode) => boolean;
105
119
  destroy?: () => void;
106
120
  };
107
121
  toExternalHTML?: (block: any, editor: BlockNoteEditor<any>, context: {
@@ -137,6 +151,7 @@ export type BlockSpecs = {
137
151
  dom: HTMLElement | DocumentFragment;
138
152
  contentDOM?: HTMLElement;
139
153
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
154
+ update?: (node: ProsemirrorNode) => boolean;
140
155
  destroy?: () => void;
141
156
  };
142
157
  toExternalHTML?: (block: any, editor: BlockNoteEditor<any>, context: {
@@ -191,6 +206,13 @@ export type PlainContent = (StyledText<{}> & {
191
206
  export type PartialPlainContent = string | (string | (StyledText<{}> & {
192
207
  styles: Record<string, never>;
193
208
  }))[];
209
+ /**
210
+ * The text of a block's `"plain"` content (e.g. a code block's source code).
211
+ * Accepts the partial form too: block render/export paths can receive
212
+ * `PartialBlock`s (e.g. the HTML serializers take them directly), where
213
+ * plain content may still be the bare-string sugar.
214
+ */
215
+ export declare function plainContentToString(content: PlainContent | PartialPlainContent): string;
194
216
  export type BlockFromConfigNoChildren<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
195
217
  id: string;
196
218
  type: B["type"];
@@ -254,7 +276,7 @@ export type BlockImplementation<TName extends string = string, TProps extends Pr
254
276
  /**
255
277
  * Metadata
256
278
  */
257
- meta?: BlockConfigMeta;
279
+ meta?: BlockConfigMeta<TName, TProps>;
258
280
  /**
259
281
  * A function that converts the block into a DOM element
260
282
  */
@@ -279,6 +301,17 @@ export type BlockImplementation<TName extends string = string, TProps extends Pr
279
301
  dom: HTMLElement | DocumentFragment;
280
302
  contentDOM?: HTMLElement;
281
303
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
304
+ /**
305
+ * Called by ProseMirror when this block's node is updated (e.g. its content
306
+ * or props change). Return `true` to handle the update in place - keeping
307
+ * the existing DOM - or `false` to have the node view recreated via
308
+ * `render`. When omitted, ProseMirror keeps the node view and reconciles its
309
+ * `contentDOM` in place as long as the node type stays the same.
310
+ *
311
+ * Useful for blocks whose `render` builds custom DOM that needs to stay in
312
+ * sync with the node (e.g. a code block rendering a preview of its content).
313
+ */
314
+ update?: (node: ProsemirrorNode) => boolean;
282
315
  destroy?: () => void;
283
316
  };
284
317
  /**
@@ -1,4 +1,4 @@
1
- import { TagParseRule } from "@tiptap/pm/model";
1
+ import { Fragment, Node as ProsemirrorNode, Schema, TagParseRule } from "@tiptap/pm/model";
2
2
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
3
3
  import { Props } from "../propTypes.js";
4
4
  import { StyleSchema } from "../styles/types.js";
@@ -6,11 +6,33 @@ import { CustomInlineContentConfig, InlineContentFromConfig, InlineContentSpec,
6
6
  export type CustomInlineContentImplementation<T extends CustomInlineContentConfig, S extends StyleSchema> = {
7
7
  meta?: {
8
8
  draggable?: boolean;
9
+ code?: boolean;
10
+ /**
11
+ * When {@link code} is `true`, this can syntax highlight the contents of the
12
+ * inline content with the result of this callback.
13
+ */
14
+ highlight?(inlineContent: Pick<InlineContentFromConfig<T, S>, "type" | "props">): string | undefined;
15
+ /**
16
+ * Marks the inline content as rendering a preview with an editable source
17
+ * popup, driven by the editor-wide
18
+ * `SourceInlineContentWithPreviewExtension`.
19
+ */
20
+ hasPreview?: boolean;
9
21
  };
10
22
  /**
11
23
  * Parses an external HTML element into a inline content of this type when it returns the block props object, otherwise undefined
12
24
  */
13
25
  parse?: (el: HTMLElement) => Partial<Props<T["propSchema"]>> | undefined;
26
+ /**
27
+ * Advanced parsing function that controls how the content within the inline
28
+ * content is parsed. This is not recommended to use, and is only useful for
29
+ * advanced use cases. Only applies to inline content with `content: "styled"`.
30
+ * Return `undefined` to fall through to the default inline content parsing.
31
+ */
32
+ parseContent?: (options: {
33
+ el: HTMLElement;
34
+ schema: Schema;
35
+ }) => Fragment | undefined;
14
36
  /**
15
37
  * Renders an inline content to DOM elements
16
38
  */
@@ -28,7 +50,17 @@ export type CustomInlineContentImplementation<T extends CustomInlineContentConfi
28
50
  * This is typed generically. If you want an editor with your custom schema, you need to
29
51
  * cast it manually, e.g.: `const e = editor as BlockNoteEditor<typeof mySchema>;`
30
52
  */
31
- editor: BlockNoteEditor<any, any, S>) => {
53
+ editor: BlockNoteEditor<any, any, S>,
54
+ /**
55
+ * The ProseMirror node backing this inline content.
56
+ */
57
+ node: ProsemirrorNode,
58
+ /**
59
+ * Returns this inline content's position in the document. When rendered
60
+ * outside the editor (i.e. serialized to HTML), this is a no-op that returns
61
+ * `undefined`.
62
+ */
63
+ getPos: () => number | undefined) => {
32
64
  dom: HTMLElement;
33
65
  contentDOM?: HTMLElement;
34
66
  destroy?: () => void;
@@ -53,5 +85,5 @@ export type CustomInlineContentImplementation<T extends CustomInlineContentConfi
53
85
  } | undefined;
54
86
  runsBefore?: string[];
55
87
  };
56
- export declare function getInlineContentParseRules<C extends CustomInlineContentConfig>(config: C, customParseFunction?: CustomInlineContentImplementation<C, any>["parse"]): TagParseRule[];
88
+ export declare function getInlineContentParseRules<C extends CustomInlineContentConfig>(config: C, customParseFunction?: CustomInlineContentImplementation<C, any>["parse"], customParseContentFunction?: CustomInlineContentImplementation<C, any>["parseContent"]): TagParseRule[];
57
89
  export declare function createInlineContentSpec<T extends CustomInlineContentConfig, S extends StyleSchema>(inlineContentConfig: T, inlineContentImplementation: CustomInlineContentImplementation<T, S>): InlineContentSpec<T>;
@@ -1,4 +1,5 @@
1
1
  import { KeyboardShortcutCommand, Node } from "@tiptap/core";
2
+ import { Extension, ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
2
3
  import { PropSchema, Props } from "../propTypes.js";
3
4
  import { CustomInlineContentConfig, InlineContentImplementation, InlineContentSchemaFromSpecs, InlineContentSpec, InlineContentSpecs } from "./types.js";
4
5
  export declare function addInlineContentAttributes<IType extends string, PSchema extends PropSchema>(element: {
@@ -11,10 +12,10 @@ export declare function addInlineContentAttributes<IType extends string, PSchema
11
12
  export declare function addInlineContentKeyboardShortcuts<T extends CustomInlineContentConfig>(config: T): {
12
13
  [p: string]: KeyboardShortcutCommand;
13
14
  };
14
- export declare function createInternalInlineContentSpec<const T extends CustomInlineContentConfig>(config: T, implementation: InlineContentImplementation<NoInfer<T>>): InlineContentSpec<T>;
15
+ export declare function createInternalInlineContentSpec<const T extends CustomInlineContentConfig>(config: T, implementation: InlineContentImplementation<NoInfer<T>>, extensions?: (Extension | ExtensionFactoryInstance)[]): InlineContentSpec<T>;
15
16
  export declare function createInlineContentSpecFromTipTapNode<T extends Node, P extends PropSchema>(node: T, propSchema: P, implementation: Omit<InlineContentImplementation<CustomInlineContentConfig>, "node">): InlineContentSpec<{
16
17
  readonly type: T["name"];
17
18
  readonly propSchema: P;
18
- readonly content: "none" | "styled";
19
+ readonly content: "none" | "plain" | "styled";
19
20
  }>;
20
21
  export declare function getInlineContentSchemaFromSpecs<T extends InlineContentSpecs>(specs: T): InlineContentSchemaFromSpecs<T>;
@@ -1,17 +1,35 @@
1
1
  import { Node } from "@tiptap/core";
2
2
  import { ViewMutationRecord } from "prosemirror-view";
3
- import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
4
3
  import { PropSchema, Props } from "../propTypes.js";
5
4
  import { StyleSchema, Styles } from "../styles/types.js";
5
+ import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
6
+ import { Extension, ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
6
7
  export type CustomInlineContentConfig = {
7
8
  type: string;
8
9
  content: "styled" | "none" | "plain";
9
10
  readonly propSchema: PropSchema;
10
11
  };
11
12
  export type InlineContentConfig = CustomInlineContentConfig | "text" | "link";
12
- export type InlineContentImplementation<T extends InlineContentConfig> = T extends "link" | "text" ? undefined : {
13
+ export type InlineContentImplementation<T extends InlineContentConfig> = T extends CustomInlineContentConfig ? {
13
14
  meta?: {
15
+ /**
16
+ * Whether the inline content is a {@link https://prosemirror.net/docs/ref/#model.NodeSpec.code} block
17
+ */
18
+ code?: boolean;
19
+ /**
20
+ * When {@link code} is `true`, this can syntax highlight the contents of the block with the result of this callback
21
+ */
22
+ highlight?(inlineContent: Pick<CustomInlineContentFromConfig<T, any>, "type" | "props">): string | undefined;
23
+ /**
24
+ * Whether the inline content is draggable
25
+ */
14
26
  draggable?: boolean;
27
+ /**
28
+ * Marks the inline content as rendering a preview with an editable
29
+ * source popup, driven by the editor-wide
30
+ * `SourceInlineContentWithPreviewExtension`.
31
+ */
32
+ hasPreview?: boolean;
15
33
  };
16
34
  node: Node;
17
35
  toExternalHTML?: (inlineContent: any, editor: BlockNoteEditor<any, any, any>) => {
@@ -25,13 +43,14 @@ export type InlineContentImplementation<T extends InlineContentConfig> = T exten
25
43
  destroy?: () => void;
26
44
  };
27
45
  runsBefore?: string[];
28
- };
46
+ } : undefined;
29
47
  export type InlineContentSchemaWithInlineContent<IType extends string, C extends InlineContentConfig> = {
30
48
  [k in IType]: C;
31
49
  };
32
50
  export type InlineContentSpec<T extends InlineContentConfig> = {
33
51
  config: T;
34
52
  implementation: InlineContentImplementation<T>;
53
+ extensions?: (Extension | ExtensionFactoryInstance)[];
35
54
  };
36
55
  export type InlineContentSchema = Record<string, InlineContentConfig>;
37
56
  export type InlineContentSpecs = {
@@ -1,3 +1,3 @@
1
1
  import { NodeView, ViewMutationRecord } from "@tiptap/pm/view";
2
- export declare function isNonContentMutation(mutation: ViewMutationRecord, contentDOM: HTMLElement | null | undefined): boolean;
3
- export declare function ignoreNonContentMutations(nodeView: NodeView): void;
2
+ export declare function isDarkReaderMutation(mutation: ViewMutationRecord): boolean;
3
+ export declare function ignoreDarkReaderMutations(nodeView: NodeView): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { Store } from "@tanstack/store";
1
+ import { Store } from "../util/Store.js";
2
2
  /**
3
3
  * A collaborator of the document.
4
4
  */
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The value a {@link Listener} is called with when a {@link Store} updates.
3
+ */
4
+ export interface ListenerValue<T> {
5
+ readonly prevVal: T;
6
+ readonly currentVal: T;
7
+ }
8
+ /**
9
+ * A callback invoked when a {@link Store}'s state changes.
10
+ */
11
+ export type Listener<T> = (value: ListenerValue<T>) => void;
12
+ /**
13
+ * A new state, or a function deriving it from the previous state.
14
+ */
15
+ export type Updater<T> = T | ((prev: T) => T);
16
+ export interface StoreOptions<TState> {
17
+ /**
18
+ * Called after the state has been updated, before listeners are notified.
19
+ */
20
+ onUpdate?: (state: TState, prevState: TState) => void;
21
+ }
22
+ /**
23
+ * A minimal observable state container.
24
+ *
25
+ * Extensions expose one of these as their `store` so that both React (via
26
+ * `useExtensionState`) and vanilla consumers can read and subscribe to their state.
27
+ */
28
+ export declare class Store<TState> {
29
+ listeners: Set<Listener<TState>>;
30
+ state: TState;
31
+ prevState: TState;
32
+ options?: StoreOptions<TState>;
33
+ constructor(initialState: TState, options?: StoreOptions<TState>);
34
+ subscribe: (listener: Listener<TState>) => () => void;
35
+ /**
36
+ * Update the store state, either with a new state or a function deriving it from the
37
+ * previous one.
38
+ */
39
+ setState(updater: (prevState: TState) => TState): void;
40
+ setState(updater: TState): void;
41
+ /**
42
+ * @internal Only to be called by {@link flush}.
43
+ */
44
+ _notify(): void;
45
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -55,7 +55,7 @@ export declare const AttributionExtension: (options?: {
55
55
  } | undefined) => import("../../index.js").ExtensionFactoryInstance<{
56
56
  key: string;
57
57
  userStore: import("../../index.js").UserStore<import("../../index.js").User>;
58
- store: import("@tanstack/store").Store<AttributionTooltipState | undefined, (cb: AttributionTooltipState | undefined) => AttributionTooltipState | undefined>;
58
+ store: import("../../index.js").Store<AttributionTooltipState | undefined>;
59
59
  prosemirrorPlugins: Plugin<null>[];
60
60
  mount({ dom, root, signal }: {
61
61
  dom: HTMLElement;
@@ -47,7 +47,7 @@ export declare const DiffVersioningExtension: (options?: DiffVersioningExtension
47
47
  blockNoteExtensions: import("../../index.js").ExtensionFactoryInstance<{
48
48
  key: string;
49
49
  userStore: import("../../index.js").UserStore<User>;
50
- store: import("@tanstack/store").Store<import("./AttributionExtension.js").AttributionTooltipState | undefined, (cb: import("./AttributionExtension.js").AttributionTooltipState | undefined) => import("./AttributionExtension.js").AttributionTooltipState | undefined>;
50
+ store: import("../../index.js").Store<import("./AttributionExtension.js").AttributionTooltipState | undefined>;
51
51
  prosemirrorPlugins: import("prosemirror-state").Plugin<null>[];
52
52
  mount({ dom, root, signal }: {
53
53
  dom: HTMLElement;
@@ -1,11 +1,7 @@
1
1
  import { CollaborationOptions } from "./index.js";
2
2
  export declare const ForkYDocExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
3
3
  readonly key: "yForkDoc";
4
- readonly store: import("@tanstack/store").Store<{
5
- isForked: boolean;
6
- }, (cb: {
7
- isForked: boolean;
8
- }) => {
4
+ readonly store: import("../../index.js").Store<{
9
5
  isForked: boolean;
10
6
  }>;
11
7
  /**
@@ -68,15 +68,7 @@ export declare const CollaborationExtension: (options: CollaborationOptions) =>
68
68
  readonly userStore: import("../../index.js").UserStore<import("../../index.js").User>;
69
69
  readonly blockNoteExtensions: (import("../../index.js").ExtensionFactoryInstance<{
70
70
  readonly key: "versioning";
71
- readonly store: import("@tanstack/store").Store<{
72
- snapshots: import("../../index.js").VersionSnapshot[];
73
- previewedSnapshotId?: string | typeof import("../../index.js").CURRENT_VERSION_ID;
74
- compareToSnapshotId?: string | typeof import("../../index.js").CURRENT_VERSION_ID;
75
- }, (cb: {
76
- snapshots: import("../../index.js").VersionSnapshot[];
77
- previewedSnapshotId?: string | typeof import("../../index.js").CURRENT_VERSION_ID;
78
- compareToSnapshotId?: string | typeof import("../../index.js").CURRENT_VERSION_ID;
79
- }) => {
71
+ readonly store: import("../../index.js").Store<{
80
72
  snapshots: import("../../index.js").VersionSnapshot[];
81
73
  previewedSnapshotId?: string | typeof import("../../index.js").CURRENT_VERSION_ID;
82
74
  compareToSnapshotId?: string | typeof import("../../index.js").CURRENT_VERSION_ID;
@@ -106,7 +98,7 @@ export declare const CollaborationExtension: (options: CollaborationOptions) =>
106
98
  }> | import("../../index.js").ExtensionFactoryInstance<{
107
99
  key: string;
108
100
  userStore: import("../../index.js").UserStore<import("../../index.js").User>;
109
- store: import("@tanstack/store").Store<import("./AttributionExtension.js").AttributionTooltipState | undefined, (cb: import("./AttributionExtension.js").AttributionTooltipState | undefined) => import("./AttributionExtension.js").AttributionTooltipState | undefined>;
101
+ store: import("../../index.js").Store<import("./AttributionExtension.js").AttributionTooltipState | undefined>;
110
102
  prosemirrorPlugins: import("prosemirror-state").Plugin<null>[];
111
103
  mount({ dom, root, signal }: {
112
104
  dom: HTMLElement;
@@ -5,7 +5,8 @@ import { VersioningEndpointsFactory } from "../../extensions/Versioning/index.js
5
5
  */
6
6
  export interface YHubVersioningOptions {
7
7
  /**
8
- * Base URL of the YHub API (e.g. `"https://yhub.example.com"`).
8
+ * Base URL of the YHub API, including the API prefix
9
+ * (e.g. `"https://yhub.example.com/api"`).
9
10
  * Must **not** include a trailing slash.
10
11
  */
11
12
  baseUrl: string;
@@ -75,7 +76,7 @@ export interface YHubVersioningOptions {
75
76
  * user: { name: "Alice", color: "#ff0" },
76
77
  * provider,
77
78
  * versioningEndpoints: createYHubVersioningEndpoints({
78
- * baseUrl: "https://yhub.example.com",
79
+ * baseUrl: "https://yhub.example.com/api",
79
80
  * org: "my-org",
80
81
  * docId: "my-doc",
81
82
  * }),
@@ -1,11 +1,7 @@
1
1
  import type { CollaborationOptions } from "./index.js";
2
2
  export declare const ForkYDocExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
3
3
  readonly key: "yForkDoc";
4
- readonly store: import("@tanstack/store").Store<{
5
- isForked: boolean;
6
- }, (cb: {
7
- isForked: boolean;
8
- }) => {
4
+ readonly store: import("../../index.js").Store<{
9
5
  isForked: boolean;
10
6
  }>;
11
7
  /**
@@ -35,11 +35,7 @@ export declare const CollaborationExtension: (options: CollaborationOptions) =>
35
35
  readonly key: "fixUpSchema";
36
36
  }>, import("../..").ExtensionFactoryInstance<{
37
37
  readonly key: "yForkDoc";
38
- readonly store: import("@tanstack/store").Store<{
39
- isForked: boolean;
40
- }, (cb: {
41
- isForked: boolean;
42
- }) => {
38
+ readonly store: import("../..").Store<{
43
39
  isForked: boolean;
44
40
  }>;
45
41
  readonly fork: ({ initialUpdate, }?: {
@@ -1,38 +0,0 @@
1
- import { getExtensionField as e } from "@tiptap/core";
2
- import { Store as t } from "@tanstack/store";
3
- //#region src/schema/markGroups.ts
4
- var n = "annotation";
5
- function r(t) {
6
- return t && t.options.extensions.some((t) => {
7
- if (t.type !== "mark") return !1;
8
- let n = e(t, "group");
9
- return typeof n == "string" && n.split(" ").includes("annotation");
10
- }) ? n : "";
11
- }
12
- //#endregion
13
- //#region src/editor/managers/ExtensionManager/symbol.ts
14
- var i = Symbol("originalFactory");
15
- //#endregion
16
- //#region src/editor/BlockNoteExtension.ts
17
- function a(e) {
18
- if (typeof e == "object" && "key" in e) return function t() {
19
- return e[i] = t, e;
20
- };
21
- if (typeof e != "function") throw Error("factory must be a function");
22
- return function t(n) {
23
- return (r) => {
24
- let a = e({
25
- editor: r.editor,
26
- options: n
27
- });
28
- return a[i] = t, a;
29
- };
30
- };
31
- }
32
- function o(e, n) {
33
- return new t(e, n);
34
- }
35
- //#endregion
36
- export { r as a, n as i, o as n, i as r, a as t };
37
-
38
- //# sourceMappingURL=BlockNoteExtension-B_IEJHS8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteExtension-B_IEJHS8.js","names":[],"sources":["../src/schema/markGroups.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","/**\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 { Store, StoreOptions } from \"@tanstack/store\";\nimport { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.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,EAAE,SAAA,YAAkC;CAEvD,CACO,IAAuB,IAA4B;AAC5D;;;AC7CA,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,2 +0,0 @@
1
- let e=require("@tiptap/core"),t=require("@tanstack/store");var n=`annotation`;function r(t){return t&&t.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`)})?n:``}var i=Symbol(`originalFactory`);function a(e){if(typeof e==`object`&&`key`in e)return function t(){return e[i]=t,e};if(typeof e!=`function`)throw Error(`factory must be a function`);return function t(n){return r=>{let a=e({editor:r.editor,options:n});return a[i]=t,a}}}function o(e,n){return new t.Store(e,n)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),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=BlockNoteExtension-M0znTzxP.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteExtension-M0znTzxP.cjs","names":[],"sources":["../src/schema/markGroups.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","/**\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 { Store, StoreOptions } from \"@tanstack/store\";\nimport { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.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":"2DAeA,IAAa,EAA4B,aAmBzC,SAAgB,EAAmB,EAAoC,CAcrE,OAbK,GAGwB,EAAO,QAAQ,WAAW,KAAM,GAAc,CACzE,GAAI,EAAU,OAAS,OACrB,MAAO,GAET,IAAM,GAAA,EAAA,EAAA,mBAA0B,EAAW,OAAO,EAClD,OACE,OAAO,GAAU,UACjB,EAAM,MAAM,GAAG,EAAE,SAAA,YAAkC,CAEvD,CACO,EAAuB,EAA4B,EAC5D,CC7CA,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,EAAA,MAAM,EAAc,CAAO,CACxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserStore-QbbPFj0z.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 { 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":";;;;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,IACR,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,YAAY,CAAG,CAAC,IACxC,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,UAAU,EAAE,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"}