@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
@@ -15,8 +15,10 @@ export * from "./Quote/block.js";
15
15
  export * from "./Table/block.js";
16
16
  export * from "./Video/block.js";
17
17
  export { EMPTY_CELL_HEIGHT, EMPTY_CELL_WIDTH } from "./Table/TableExtension.js";
18
+ export * from "./Code/helpers/parse/parsePreCode.js";
19
+ export * from "./Code/helpers/render/createCodeBlock.js";
20
+ export * from "./Code/helpers/toExternalHTML/createPreCode.js";
18
21
  export * from "./ToggleWrapper/createToggleWrapper.js";
19
- export * from "./File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.js";
20
22
  export * from "./PageBreak/getPageBreakSlashMenuItems.js";
21
23
  export * from "./BlockNoteSchema.js";
22
24
  export * from "./defaultBlockHelpers.js";
@@ -40,21 +40,7 @@ export declare const CommentsExtension: (options: {
40
40
  confirmBeforeDiscard?: boolean;
41
41
  }) => import("../index.js").ExtensionFactoryInstance<{
42
42
  readonly key: "comments";
43
- readonly store: import("@tanstack/store").Store<{
44
- pendingComment: boolean;
45
- selectedThreadId: string | undefined;
46
- threadPositions: Map<string, {
47
- from: number;
48
- to: number;
49
- }>;
50
- }, (cb: {
51
- pendingComment: boolean;
52
- selectedThreadId: string | undefined;
53
- threadPositions: Map<string, {
54
- from: number;
55
- to: number;
56
- }>;
57
- }) => {
43
+ readonly store: import("../index.js").Store<{
58
44
  pendingComment: boolean;
59
45
  selectedThreadId: string | undefined;
60
46
  threadPositions: Map<string, {
@@ -9,7 +9,7 @@ import type { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs,
9
9
  import "../style.css";
10
10
  import { EventEmitter } from "../util/EventEmitter.js";
11
11
  import type { NoInfer } from "../util/typescript.js";
12
- import { ExtensionFactoryInstance } from "./BlockNoteExtension.js";
12
+ import { Extension, ExtensionFactory, ExtensionFactoryInstance } from "./BlockNoteExtension.js";
13
13
  import type { TextCursorPosition } from "./cursorPositionTypes.js";
14
14
  import { ExtensionManager } from "./managers/index.js";
15
15
  import type { Selection } from "./selectionTypes.js";
@@ -320,7 +320,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
320
320
  /**
321
321
  * BlockNote extensions that are added to the editor, keyed by the extension key
322
322
  */
323
- get extensions(): Map<string, import("./BlockNoteExtension.js").Extension<any, string>>;
323
+ get extensions(): Map<string, Extension<any, string>>;
324
324
  /**
325
325
  * Execute a prosemirror command. This is mostly for backwards compatibility with older code.
326
326
  *
@@ -388,7 +388,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
388
388
  /**
389
389
  * Get an extension from the editor
390
390
  */
391
- getExtension: ExtensionManager["getExtension"];
391
+ getExtension: (<const Ext extends Extension | ExtensionFactory = Extension>(extension: string) => (Ext extends Extension ? Ext : Ext extends ExtensionFactory ? ReturnType<ReturnType<Ext>> : never) | undefined) & (<const T extends ExtensionFactory>(extension: T) => ReturnType<ReturnType<T>> | undefined);
392
392
  /**
393
393
  * Mount the editor to a DOM element.
394
394
  *
@@ -1,7 +1,7 @@
1
- import { Store, StoreOptions } from "@tanstack/store";
2
1
  import { type AnyExtension } from "@tiptap/core";
3
2
  import type { Plugin as ProsemirrorPlugin } from "prosemirror-state";
4
3
  import type { PartialBlockNoDefaults } from "../schema/index.js";
4
+ import { Store, StoreOptions } from "../util/Store.js";
5
5
  import type { BlockNoteEditor } from "./BlockNoteEditor.js";
6
6
  /**
7
7
  * This function is called when the extension is destroyed.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * An image generated during export (e.g. a rendered formula or diagram): the
3
+ * encoded image bytes plus the dimensions to display it at.
4
+ *
5
+ * The bytes (rather than e.g. a data URL string or a `Blob`) are the source
6
+ * of truth: they carry no encoding ambiguity, work in every environment, and
7
+ * are readable synchronously - each output format converts them at its own
8
+ * boundary (data URL for HTML-based targets, raw bytes for DOCX, base64 for
9
+ * email attachments).
10
+ */
11
+ export type ExportImage = {
12
+ /** MIME type of `data`, e.g. `"image/png"` or `"image/svg+xml"`. */
13
+ mimeType: string;
14
+ /** The encoded image bytes. */
15
+ data: Uint8Array;
16
+ /**
17
+ * Dimensions to display the image at, in the target format's units (CSS
18
+ * pixels, points, ...). For raster images, `data`'s own pixel dimensions
19
+ * may be larger - images are often rendered at 2-4x for sharpness.
20
+ */
21
+ width: number;
22
+ height: number;
23
+ };
24
+ /**
25
+ * Encodes bytes as base64. This papers over a platform gap: until
26
+ * `Uint8Array.prototype.toBase64()` (ES2026) is available in every runtime
27
+ * BlockNote supports, the only universal built-in is `btoa`, which takes
28
+ * binary *strings*. Uses `toBase64` when the runtime has it.
29
+ */
30
+ export declare function bytesToBase64(bytes: Uint8Array): string;
31
+ /**
32
+ * Encodes an {@link ExportImage}'s bytes as a base64 data URL, for targets
33
+ * that take image sources as URLs (HTML `src` attributes, react-pdf image
34
+ * sources, ...).
35
+ */
36
+ export declare function exportImageToDataURL(image: ExportImage): string;
@@ -1,5 +1,6 @@
1
1
  import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
2
2
  import { COLORS_DEFAULT } from "../editor/defaultColors.js";
3
+ import type { Dictionary } from "../i18n/dictionary.js";
3
4
  import { BlockFromConfig, BlockSchema, InlineContent, InlineContentSchema, StyleSchema, StyledText, Styles } from "../schema/index.js";
4
5
  import type { BlockMapping, InlineContentMapping, StyleMapping } from "./mapping.js";
5
6
  export type ExporterOptions = {
@@ -20,6 +21,20 @@ export type ExporterOptions = {
20
21
  * Colors to use for background of blocks, font colors, and highlight colors
21
22
  */
22
23
  colors: typeof COLORS_DEFAULT;
24
+ /**
25
+ * The strings an exporter renders into the produced document (file link
26
+ * texts, error placeholders). Accepts a locale from
27
+ * `@blocknote/core/locales` or an editor dictionary; block packages that
28
+ * ship their own exporter strings (e.g. math, diagram) read their sections
29
+ * from this same object, exactly as they do from an editor dictionary.
30
+ *
31
+ * @default the English strings
32
+ */
33
+ dictionary?: {
34
+ exporter: Dictionary["exporter"];
35
+ } & {
36
+ [blockDictionary: string]: unknown;
37
+ };
23
38
  };
24
39
  export declare abstract class Exporter<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema, RB, RI, RS, TS> {
25
40
  protected readonly mappings: {
@@ -34,7 +49,22 @@ export declare abstract class Exporter<B extends BlockSchema, I extends InlineCo
34
49
  inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
35
50
  styleMapping: StyleMapping<S, RS>;
36
51
  }, options: ExporterOptions);
52
+ /**
53
+ * The strings this exporter renders into the produced document - the
54
+ * `exporter` section of the configured dictionary (the `dictionary`
55
+ * option of {@link ExporterOptions}), or the English defaults.
56
+ */
57
+ get dictionary(): Dictionary["exporter"];
37
58
  resolveFile(url: string): Promise<Blob>;
59
+ /**
60
+ * Fetch a URL as a Blob, throwing a clear error on a non-OK response. Without
61
+ * this an error page (404 / rate-limit / proxy failure) would be returned as
62
+ * the file's bytes and silently embedded as a corrupt image. An unreachable
63
+ * file is an environment failure, not expected input, so it fails the export
64
+ * loudly (see the error-handling conventions in AGENTS.md) rather than
65
+ * degrading the document silently.
66
+ */
67
+ private fetchBlob;
38
68
  mapStyles(styles: Styles<S>): RS[];
39
69
  mapInlineContent(inlineContent: InlineContent<I, S>): RI;
40
70
  transformInlineContent(inlineContentArray: InlineContent<I, S>[]): RI[];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from "./Exporter.js";
2
+ export * from "./ExportImage.js";
2
3
  export * from "./mapping.js";
@@ -11,7 +11,7 @@ export type BlockMapping<B extends BlockSchema, I extends InlineContentSchema, S
11
11
  * Defines a mapping from all inline content types with a schema to a result type R.
12
12
  */
13
13
  export type InlineContentMapping<I extends InlineContentSchema, S extends StyleSchema, RI, TS> = {
14
- [K in keyof I]: (inlineContent: InlineContentFromConfig<I[K], S>, exporter: Exporter<any, I, S, any, RI, any, TS>) => RI;
14
+ [K in keyof I]: (inlineContent: InlineContentFromConfig<I[K], S>, exporter: Exporter<any, any, any, any, RI, any, TS>) => RI;
15
15
  };
16
16
  /**
17
17
  * Defines a mapping from all style types with a schema to a result type R.
@@ -1,6 +1,6 @@
1
1
  export declare const FilePanelExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
2
2
  readonly key: "filePanel";
3
- readonly store: import("@tanstack/store").Store<string | undefined, (cb: string | undefined) => string | undefined>;
3
+ readonly store: import("../../index.js").Store<string | undefined>;
4
4
  readonly mount: ({ signal }: {
5
5
  dom: HTMLElement;
6
6
  root: Document | ShadowRoot;
@@ -1,6 +1,6 @@
1
1
  export declare const FormattingToolbarExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
2
2
  readonly key: "formattingToolbar";
3
- readonly store: import("@tanstack/store").Store<boolean, (cb: boolean) => boolean>;
3
+ readonly store: import("../../index.js").Store<boolean>;
4
4
  readonly mount: ({ dom, signal }: {
5
5
  dom: HTMLElement;
6
6
  root: Document | ShadowRoot;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ export declare const InlineContentBoundaryEditExtension: () => import("../../index.js").ExtensionFactoryInstance<{
3
+ readonly key: "inlineContentBoundaryEdit";
4
+ readonly prosemirrorPlugins: readonly [Plugin<any>];
5
+ }>;
@@ -6,11 +6,7 @@ import { Plugin } from "prosemirror-state";
6
6
  */
7
7
  export declare const ShowSelectionExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
8
8
  readonly key: "showSelection";
9
- readonly store: import("@tanstack/store").Store<{
10
- enabledSet: Set<string>;
11
- }, (cb: {
12
- enabledSet: Set<string>;
13
- }) => {
9
+ readonly store: import("../../index.js").Store<{
14
10
  enabledSet: Set<string>;
15
11
  }>;
16
12
  readonly prosemirrorPlugins: readonly [Plugin<any>];
@@ -100,7 +100,7 @@ export declare class SideMenuView<BSchema extends BlockSchema, I extends InlineC
100
100
  export declare const sideMenuPluginKey: PluginKey<any>;
101
101
  export declare const SideMenuExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
102
102
  readonly key: "sideMenu";
103
- readonly store: import("@tanstack/store").Store<SideMenuState<any, any, any> | undefined, (cb: SideMenuState<any, any, any> | undefined) => SideMenuState<any, any, any> | undefined>;
103
+ readonly store: import("../../index.js").Store<SideMenuState<any, any, any> | undefined>;
104
104
  readonly prosemirrorPlugins: readonly [Plugin<any>];
105
105
  /**
106
106
  * Handles drag & drop events for blocks.
@@ -0,0 +1,45 @@
1
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
2
+ /**
3
+ * A single editor-wide extension that drives the source popup for blocks that
4
+ * render a preview. Which blocks it activates on is decided by each spec's
5
+ * `meta.hasPreview` flag, so individual blocks opt in rather than the extension
6
+ * being configured with a block type.
7
+ *
8
+ * The extension is registered once (it's a default extension) and is a no-op
9
+ * when no block declares `meta.hasPreview`.
10
+ */
11
+ export declare const SourceBlockWithPreviewExtension: () => import("../..").ExtensionFactoryInstance<{
12
+ key: string;
13
+ store: import("../..").Store<{
14
+ popupOpen: string | undefined;
15
+ selected: string | undefined;
16
+ }>;
17
+ keyboardShortcuts: {
18
+ Enter: ({ editor }: {
19
+ editor: BlockNoteEditor<any, any, any>;
20
+ }) => boolean;
21
+ Escape: ({ editor }: {
22
+ editor: BlockNoteEditor<any, any, any>;
23
+ }) => boolean;
24
+ "Mod-a": ({ editor }: {
25
+ editor: BlockNoteEditor<any, any, any>;
26
+ }) => boolean;
27
+ ArrowUp: ({ editor }: {
28
+ editor: BlockNoteEditor<any>;
29
+ }) => boolean;
30
+ ArrowLeft: ({ editor }: {
31
+ editor: BlockNoteEditor<any>;
32
+ }) => boolean;
33
+ ArrowDown: ({ editor }: {
34
+ editor: BlockNoteEditor<any>;
35
+ }) => boolean;
36
+ ArrowRight: ({ editor }: {
37
+ editor: BlockNoteEditor<any>;
38
+ }) => boolean;
39
+ };
40
+ mount: ({ dom, signal }: {
41
+ dom: HTMLElement;
42
+ root: Document | ShadowRoot;
43
+ signal: AbortSignal;
44
+ }) => void;
45
+ }>;
@@ -0,0 +1,49 @@
1
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
2
+ /**
3
+ * Inline-content counterpart of {@link SourceBlockWithPreviewExtension}. A
4
+ * single editor-wide extension that drives the source popup for inline content
5
+ * that renders a preview. Which inline content it activates on is decided by
6
+ * each spec's `meta.hasPreview` flag, so individual inline content opts in
7
+ * rather than the extension being configured with a type.
8
+ *
9
+ * Unlike the block version, the popup isn't toggled with a separate state flag:
10
+ * it's open exactly when the selection is inside the inline content's source.
11
+ * The store therefore only tracks which inline content (by its position) holds
12
+ * the selection - moving the selection in opens its popup, moving it out closes
13
+ * it. Since the source popup is always laid out (just hidden via opacity), the
14
+ * cursor can navigate into and out of it with the arrow keys as usual.
15
+ *
16
+ * The extension is registered once (it's a default extension) and is a no-op
17
+ * when no inline content declares `meta.hasPreview`.
18
+ */
19
+ export declare const SourceInlineContentWithPreviewExtension: () => import("../..").ExtensionFactoryInstance<{
20
+ key: string;
21
+ store: import("../..").Store<{
22
+ selected: number | undefined;
23
+ }>;
24
+ keyboardShortcuts: {
25
+ Enter: ({ editor }: {
26
+ editor: BlockNoteEditor<any, any, any>;
27
+ }) => boolean;
28
+ "Shift-Enter": ({ editor }: {
29
+ editor: BlockNoteEditor<any, any, any>;
30
+ }) => boolean;
31
+ Escape: ({ editor }: {
32
+ editor: BlockNoteEditor<any, any, any>;
33
+ }) => boolean;
34
+ ArrowUp: ({ editor }: {
35
+ editor: BlockNoteEditor<any, any, any>;
36
+ }) => boolean;
37
+ ArrowDown: ({ editor }: {
38
+ editor: BlockNoteEditor<any, any, any>;
39
+ }) => boolean;
40
+ "Mod-a": ({ editor }: {
41
+ editor: BlockNoteEditor<any, any, any>;
42
+ }) => boolean;
43
+ };
44
+ mount: ({ dom, signal }: {
45
+ dom: HTMLElement;
46
+ root: Document | ShadowRoot;
47
+ signal: AbortSignal;
48
+ }) => void;
49
+ }>;
@@ -39,17 +39,7 @@ export type SuggestionMenuOptions = {
39
39
  */
40
40
  export declare const SuggestionMenu: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
41
41
  readonly key: "suggestionMenu";
42
- readonly store: import("@tanstack/store").Store<(UiElementPosition & {
43
- query: string;
44
- ignoreQueryLength?: boolean;
45
- } & {
46
- triggerCharacter: string;
47
- }) | undefined, (cb: (UiElementPosition & {
48
- query: string;
49
- ignoreQueryLength?: boolean;
50
- } & {
51
- triggerCharacter: string;
52
- }) | undefined) => (UiElementPosition & {
42
+ readonly store: import("../../index.js").Store<(UiElementPosition & {
53
43
  query: string;
54
44
  ignoreQueryLength?: boolean;
55
45
  } & {
@@ -0,0 +1,44 @@
1
+ import type { HighlighterGeneric } from "@shikijs/types";
2
+ export type SyntaxHighlightingOptions = {
3
+ /**
4
+ * Creates the Shiki highlighter used for syntax highlighting. Can be
5
+ * asynchronous, so the highlighter is only loaded once it's first needed.
6
+ *
7
+ * When omitted, content renders without syntax highlighting.
8
+ */
9
+ createHighlighter: () => Promise<HighlighterGeneric<any, any>>;
10
+ };
11
+ /**
12
+ * Collects the node type names that should be syntax-highlighted from a schema's
13
+ * block and inline-content specs.
14
+ *
15
+ * A spec is a candidate when it has a `meta.highlight` callback (which decides
16
+ * the language) AND the node actually holds editable text. Block and
17
+ * inline-content specs use different `content` value spaces, so "editable text"
18
+ * means `content === "plain"` for both blocks (code/math blocks) and inline
19
+ * content (inline math) - both hold plain text - hence the two are filtered
20
+ * separately.
21
+ *
22
+ * Inline content (e.g. inline math) is highlighted too: `prosemirror-highlight`
23
+ * collects nodes by `node.inlineContent` since v0.15.3
24
+ * (https://github.com/ocavue/prosemirror-highlight/pull/137), so inline nodes
25
+ * holding inline content are visited alongside text blocks.
26
+ */
27
+ export declare function collectHighlightNodeTypes(schema: {
28
+ blockSpecs: Record<string, unknown>;
29
+ inlineContentSpecs: Record<string, unknown>;
30
+ }): string[];
31
+ /**
32
+ * A single editor-wide extension that syntax-highlights block and inline-content
33
+ * content. Which nodes get highlighted (and as which language) is decided by
34
+ * each spec's `meta.highlight` callback, so individual specs declare their own
35
+ * language rather than the extension configuring them.
36
+ *
37
+ * Highlighting is opt-in: the user adds this extension to the editor's
38
+ * `extensions` (configured with a `createHighlighter`) to enable it. When it's
39
+ * absent, content renders as plain text.
40
+ */
41
+ export declare const SyntaxHighlightingExtension: (options: SyntaxHighlightingOptions) => import("../../index.js").ExtensionFactoryInstance<{
42
+ key: string;
43
+ prosemirrorPlugins: import("prosemirror-state").Plugin<import("prosemirror-highlight").HighlightPluginState>[];
44
+ }>;
@@ -0,0 +1,13 @@
1
+ import type { SyntaxHighlightingOptions } from "./SyntaxHighlighting.js";
2
+ import { CustomBlockNoteSchema } from "../../schema/schema.js";
3
+ export declare const shikiParserSymbol: unique symbol;
4
+ export declare const shikiHighlighterPromiseSymbol: unique symbol;
5
+ /**
6
+ * Creates the syntax highlighting plugin for the given block types, lazily
7
+ * loading the highlighter on first use.
8
+ *
9
+ * Each spec's `meta.highlight` callback resolves a node to a language, which is
10
+ * passed straight to Shiki - it resolves aliases and loads the grammar from its
11
+ * bundle, so any language the provided highlighter bundles can be highlighted.
12
+ */
13
+ export declare function lazyShikiPlugin(options: SyntaxHighlightingOptions, nodeTypes: string[], schema: CustomBlockNoteSchema<any, any, any>): import("prosemirror-state").Plugin<import("prosemirror-highlight").HighlightPluginState>;
@@ -1,3 +1,4 @@
1
+ import type { Node } from "prosemirror-model";
1
2
  import { EditorState, Plugin, PluginKey, PluginView } from "prosemirror-state";
2
3
  import { EditorView } from "prosemirror-view";
3
4
  import { RelativeCellIndices } from "../../api/blockManipulation/tables/tables.js";
@@ -33,17 +34,19 @@ export declare class TableHandlesView implements PluginView {
33
34
  prevWasEditable: boolean | null;
34
35
  constructor(editor: BlockNoteEditor<BlockSchemaWithBlock<"table", DefaultBlockSchema["table"]>, any, any>, pmView: EditorView, emitUpdate: (state: TableHandlesState | undefined) => void);
35
36
  viewMousedownHandler: () => void;
37
+ hideHandles: () => void;
36
38
  mouseUpHandler: (event: MouseEvent) => void;
37
39
  mouseMoveHandler: (event: MouseEvent) => false | undefined;
38
40
  dragOverHandler: (event: DragEvent) => void;
39
41
  dropHandler: (event: DragEvent) => boolean;
42
+ getTablePos(doc: Node): number | undefined;
40
43
  update(): void;
41
44
  destroy(): void;
42
45
  }
43
46
  export declare const tableHandlesPluginKey: PluginKey<any>;
44
47
  export declare const TableHandlesExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
45
48
  readonly key: "tableHandles";
46
- readonly store: import("@tanstack/store").Store<TableHandlesState | undefined, (cb: TableHandlesState | undefined) => TableHandlesState | undefined>;
49
+ readonly store: import("../../index.js").Store<TableHandlesState | undefined>;
47
50
  readonly prosemirrorPlugins: readonly [Plugin<any>];
48
51
  /**
49
52
  * Callback that should be set on the `dragStart` event for whichever element
@@ -261,41 +261,7 @@ export type VersioningExtensionOptions<Input = any, Output = any, Attributions =
261
261
  };
262
262
  export declare const VersioningExtension: (options: VersioningExtensionOptions<any, any, any> | ((editor: BlockNoteEditor<any, any, any>) => VersioningExtensionOptions)) => import("../../index.js").ExtensionFactoryInstance<{
263
263
  readonly key: "versioning";
264
- readonly store: import("@tanstack/store").Store<{
265
- snapshots: VersionSnapshot[];
266
- /**
267
- * The id of the version currently shown in the editor (the "new" side of
268
- * a diff). `undefined` means the live, editable document. Is the
269
- * {@link CURRENT_VERSION_ID} symbol when previewing the live document as a
270
- * read-only diff against a snapshot.
271
- */
272
- previewedSnapshotId?: string | typeof CURRENT_VERSION_ID;
273
- /**
274
- * The id of the snapshot the preview is being diffed against (the
275
- * "baseline" / old side). `undefined` when not showing a diff. Always a
276
- * real snapshot id (never the current entry), but typed as the same union
277
- * as {@link VersionSnapshot.id} since it's copied from one. Used to render
278
- * the "Comparing to" indicator in the sidebar.
279
- */
280
- compareToSnapshotId?: string | typeof CURRENT_VERSION_ID;
281
- }, (cb: {
282
- snapshots: VersionSnapshot[];
283
- /**
284
- * The id of the version currently shown in the editor (the "new" side of
285
- * a diff). `undefined` means the live, editable document. Is the
286
- * {@link CURRENT_VERSION_ID} symbol when previewing the live document as a
287
- * read-only diff against a snapshot.
288
- */
289
- previewedSnapshotId?: string | typeof CURRENT_VERSION_ID;
290
- /**
291
- * The id of the snapshot the preview is being diffed against (the
292
- * "baseline" / old side). `undefined` when not showing a diff. Always a
293
- * real snapshot id (never the current entry), but typed as the same union
294
- * as {@link VersionSnapshot.id} since it's copied from one. Used to render
295
- * the "Comparing to" indicator in the sidebar.
296
- */
297
- compareToSnapshotId?: string | typeof CURRENT_VERSION_ID;
298
- }) => {
264
+ readonly store: import("../../index.js").Store<{
299
265
  snapshots: VersionSnapshot[];
300
266
  /**
301
267
  * The id of the version currently shown in the editor (the "new" side of
@@ -3,6 +3,7 @@ export * from "./DropCursor/DropCursor.js";
3
3
  export * from "./FilePanel/FilePanel.js";
4
4
  export * from "./FormattingToolbar/FormattingToolbar.js";
5
5
  export * from "./History/History.js";
6
+ export * from "./InlineContentBoundaryEdit/InlineContentBoundaryEdit.js";
6
7
  export * from "./LinkToolbar/LinkToolbar.js";
7
8
  export * from "./LinkToolbar/protocols.js";
8
9
  export * from "./NodeSelectionKeyboard/NodeSelectionKeyboard.js";
@@ -11,7 +12,10 @@ export * from "./PositionMapping/PositionMapping.js";
11
12
  export * from "./PreviousBlockType/PreviousBlockType.js";
12
13
  export * from "./ShowSelection/ShowSelection.js";
13
14
  export * from "./SideMenu/SideMenu.js";
15
+ export * from "./SourceBlockWithPreview/SourceBlockWithPreview.js";
16
+ export * from "./SourceInlineContentWithPreview/SourceInlineContentWithPreview.js";
14
17
  export * from "./SuggestionMenu/DefaultGridSuggestionItem.js";
18
+ export * from "./SyntaxHighlighting/SyntaxHighlighting.js";
15
19
  export * from "./SuggestionMenu/DefaultSuggestionItem.js";
16
20
  export * from "./SuggestionMenu/getDefaultEmojiPickerItems.js";
17
21
  export * from "./SuggestionMenu/getDefaultSlashMenuItems.js";
@@ -152,6 +152,10 @@ export declare const en: {
152
152
  toggle_blocks: {
153
153
  add_block_button: string;
154
154
  };
155
+ code_block: {
156
+ add_source_button_text: string;
157
+ ok_button_text: string;
158
+ };
155
159
  side_menu: {
156
160
  add_block_label: string;
157
161
  drag_handle_label: string;
@@ -324,6 +328,11 @@ export declare const en: {
324
328
  deleted_by: (users: string) => string;
325
329
  formatting_change_by: (formats: string, users: string) => string;
326
330
  };
331
+ exporter: {
332
+ open_file: string;
333
+ open_video_file: string;
334
+ open_audio_file: string;
335
+ };
327
336
  generic: {
328
337
  ctrl_shortcut: string;
329
338
  };
@@ -152,6 +152,10 @@ export declare const fa: {
152
152
  toggle_blocks: {
153
153
  add_block_button: string;
154
154
  };
155
+ code_block: {
156
+ add_source_button_text: string;
157
+ ok_button_text: string;
158
+ };
155
159
  side_menu: {
156
160
  add_block_label: string;
157
161
  drag_handle_label: string;
@@ -324,6 +328,11 @@ export declare const fa: {
324
328
  deleted_by: (users: string) => string;
325
329
  formatting_change_by: (formats: string, users: string) => string;
326
330
  };
331
+ exporter: {
332
+ open_file: string;
333
+ open_video_file: string;
334
+ open_audio_file: string;
335
+ };
327
336
  generic: {
328
337
  ctrl_shortcut: string;
329
338
  };
@@ -152,6 +152,10 @@ export declare const sk: {
152
152
  toggle_blocks: {
153
153
  add_block_button: string;
154
154
  };
155
+ code_block: {
156
+ add_source_button_text: string;
157
+ ok_button_text: string;
158
+ };
155
159
  side_menu: {
156
160
  add_block_label: string;
157
161
  drag_handle_label: string;
@@ -359,6 +363,11 @@ export declare const sk: {
359
363
  deleted_by: (users: string) => string;
360
364
  formatting_change_by: (formats: string, users: string) => string;
361
365
  };
366
+ exporter: {
367
+ open_file: string;
368
+ open_video_file: string;
369
+ open_audio_file: string;
370
+ };
362
371
  generic: {
363
372
  ctrl_shortcut: string;
364
373
  };
@@ -23,10 +23,11 @@ export * from "./user/index.js";
23
23
  export * from "./util/browser.js";
24
24
  export * from "./util/combineByGroup.js";
25
25
  export * from "./util/expandToWords.js";
26
+ export * from "./util/Store.js";
26
27
  export * from "./util/string.js";
27
28
  export * from "./util/table.js";
28
29
  export * from "./util/typescript.js";
29
- export type { CodeBlockOptions } from "./blocks/Code/block.js";
30
+ export type { CodeBlockOptions, CodeBlockPreview, } from "./blocks/Code/CodeBlockOptions.js";
30
31
  export { assertEmpty, UnreachableCaseError } from "./util/typescript.js";
31
32
  export * from "./util/EventEmitter.js";
32
33
  export { selectedFragmentToHTML } from "./api/clipboard/toClipboard/copyExtension.js";