@blocknote/core 0.53.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) 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-BEJW9OM_.js → blocks-CzQLehlc.js} +571 -568
  12. package/dist/blocks-CzQLehlc.js.map +1 -0
  13. package/dist/blocks-CzkqclGj.cjs +12 -0
  14. package/dist/blocks-CzkqclGj.cjs.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-CSB9ZvuL.cjs +58 -0
  26. package/dist/extensions-CSB9ZvuL.cjs.map +1 -0
  27. package/dist/{extensions-BR5hkAio.js → extensions-DGuhtOgB.js} +662 -427
  28. package/dist/extensions-DGuhtOgB.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-BkfZVfaO.js} +967 -899
  36. package/dist/src-BkfZVfaO.js.map +1 -0
  37. package/dist/src-DM3syMdf.cjs +23 -0
  38. package/dist/src-DM3syMdf.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 +59 -56
  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 +88 -76
  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/nodeConversions/blockToNode.ts +5 -1
  55. package/src/api/nodeConversions/nodeToBlock.ts +3 -0
  56. package/src/api/pmUtil.ts +16 -8
  57. package/src/blocks/Code/CodeBlockOptions.ts +83 -0
  58. package/src/blocks/Code/block.test.ts +1 -1
  59. package/src/blocks/Code/block.ts +29 -281
  60. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
  61. package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
  62. package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
  63. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
  64. package/src/blocks/index.ts +3 -0
  65. package/src/comments/extension.ts +2 -4
  66. package/src/editor/Block.css +273 -2
  67. package/src/editor/BlockNoteEditor.ts +25 -4
  68. package/src/editor/BlockNoteExtension.ts +1 -1
  69. package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
  70. package/src/exporter/ExportImage.ts +50 -0
  71. package/src/exporter/Exporter.test.ts +48 -0
  72. package/src/exporter/Exporter.ts +46 -12
  73. package/src/exporter/index.ts +1 -0
  74. package/src/exporter/mapping.ts +4 -1
  75. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
  76. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
  77. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
  78. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
  79. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
  80. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
  81. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
  82. package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
  83. package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
  84. package/src/extensions/index.ts +4 -0
  85. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
  86. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
  87. package/src/i18n/locales/ar.ts +9 -0
  88. package/src/i18n/locales/de.ts +9 -0
  89. package/src/i18n/locales/en.ts +9 -0
  90. package/src/i18n/locales/es.ts +9 -0
  91. package/src/i18n/locales/fa.ts +9 -0
  92. package/src/i18n/locales/fr.ts +9 -0
  93. package/src/i18n/locales/he.ts +9 -0
  94. package/src/i18n/locales/hr.ts +9 -0
  95. package/src/i18n/locales/is.ts +9 -0
  96. package/src/i18n/locales/it.ts +9 -0
  97. package/src/i18n/locales/ja.ts +9 -0
  98. package/src/i18n/locales/ko.ts +9 -0
  99. package/src/i18n/locales/nl.ts +9 -0
  100. package/src/i18n/locales/no.ts +9 -0
  101. package/src/i18n/locales/pl.ts +9 -0
  102. package/src/i18n/locales/pt.ts +9 -0
  103. package/src/i18n/locales/ru.ts +9 -0
  104. package/src/i18n/locales/sk.ts +9 -0
  105. package/src/i18n/locales/uk.ts +9 -0
  106. package/src/i18n/locales/uz.ts +9 -0
  107. package/src/i18n/locales/vi.ts +9 -0
  108. package/src/i18n/locales/zh-tw.ts +9 -0
  109. package/src/i18n/locales/zh.ts +9 -0
  110. package/src/index.ts +5 -1
  111. package/src/schema/blocks/createSpec.ts +2 -3
  112. package/src/schema/blocks/types.ts +53 -3
  113. package/src/schema/contentTypePropagation.test.ts +1 -1
  114. package/src/schema/inlineContent/createSpec.test.ts +161 -0
  115. package/src/schema/inlineContent/createSpec.ts +171 -12
  116. package/src/schema/inlineContent/internal.ts +21 -2
  117. package/src/schema/inlineContent/types.ts +35 -5
  118. package/src/user/UserStore.ts +1 -1
  119. package/src/util/Store.test.ts +132 -0
  120. package/src/util/Store.ts +135 -0
  121. package/src/y/extensions/AttributionExtension.test.ts +10 -0
  122. package/src/y/extensions/Versioning.test.ts +20 -7
  123. package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
  124. package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
  125. package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
  126. package/src/yjs/extensions/ForkYDoc.ts +26 -1
  127. package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
  128. package/src/yjs/extensions/Versioning.test.ts +17 -5
  129. package/types/src/api/pmUtil.d.ts +7 -7
  130. package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
  131. package/types/src/blocks/Code/block.d.ts +3 -53
  132. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
  133. package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
  134. package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
  135. package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
  136. package/types/src/blocks/index.d.ts +3 -0
  137. package/types/src/comments/extension.d.ts +1 -15
  138. package/types/src/editor/BlockNoteEditor.d.ts +3 -3
  139. package/types/src/editor/BlockNoteExtension.d.ts +1 -1
  140. package/types/src/exporter/ExportImage.d.ts +36 -0
  141. package/types/src/exporter/Exporter.d.ts +21 -0
  142. package/types/src/exporter/Exporter.test.d.ts +1 -0
  143. package/types/src/exporter/index.d.ts +1 -0
  144. package/types/src/exporter/mapping.d.ts +1 -1
  145. package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
  146. package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
  147. package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
  148. package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
  149. package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
  150. package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
  151. package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
  152. package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
  153. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
  154. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
  155. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
  156. package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
  157. package/types/src/extensions/TableHandles/TableHandles.d.ts +1 -1
  158. package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
  159. package/types/src/extensions/index.d.ts +4 -0
  160. package/types/src/i18n/locales/en.d.ts +9 -0
  161. package/types/src/i18n/locales/fa.d.ts +9 -0
  162. package/types/src/i18n/locales/sk.d.ts +9 -0
  163. package/types/src/index.d.ts +2 -1
  164. package/types/src/schema/blocks/types.d.ts +36 -3
  165. package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
  166. package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
  167. package/types/src/schema/inlineContent/internal.d.ts +3 -2
  168. package/types/src/schema/inlineContent/types.d.ts +22 -3
  169. package/types/src/user/UserStore.d.ts +1 -1
  170. package/types/src/util/Store.d.ts +45 -0
  171. package/types/src/util/Store.test.d.ts +1 -0
  172. package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
  173. package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
  174. package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
  175. package/types/src/y/extensions/index.d.ts +2 -10
  176. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
  177. package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
  178. package/types/src/yjs/extensions/index.d.ts +1 -5
  179. package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
  180. package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
  181. package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
  182. package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
  183. package/dist/UserStore-QbbPFj0z.js.map +0 -1
  184. package/dist/blocks-BEJW9OM_.js.map +0 -1
  185. package/dist/blocks-BPmJglFo.cjs +0 -12
  186. package/dist/blocks-BPmJglFo.cjs.map +0 -1
  187. package/dist/en-C5Z4Ag9_.cjs +0 -2
  188. package/dist/en-C5Z4Ag9_.cjs.map +0 -1
  189. package/dist/en-CGKXfWma.js.map +0 -1
  190. package/dist/extensions-AitWbYdJ.cjs +0 -52
  191. package/dist/extensions-AitWbYdJ.cjs.map +0 -1
  192. package/dist/extensions-BR5hkAio.js.map +0 -1
  193. package/dist/src-BHPuOo7W.cjs +0 -21
  194. package/dist/src-BHPuOo7W.cjs.map +0 -1
  195. package/dist/src-BUXut68d.js.map +0 -1
  196. package/src/blocks/Code/shiki.ts +0 -73
  197. package/types/src/blocks/Code/shiki.d.ts +0 -4
@@ -221,6 +221,10 @@ export const de: Dictionary = {
221
221
  add_block_button:
222
222
  "Leerer aufklappbarer Bereich. Klicken, um einen Block hinzuzufügen.",
223
223
  },
224
+ code_block: {
225
+ add_source_button_text: "Quellcode hinzufügen",
226
+ ok_button_text: "OK",
227
+ },
224
228
  side_menu: {
225
229
  add_block_label: "Block hinzufügen",
226
230
  drag_handle_label: "Blockmenü öffnen",
@@ -429,6 +433,11 @@ export const de: Dictionary = {
429
433
  formatting_change_by: (formats: string, users: string) =>
430
434
  `Formatierungsänderung (${formats}) von: ${users}`,
431
435
  },
436
+ exporter: {
437
+ open_file: "Datei öffnen",
438
+ open_video_file: "Video öffnen",
439
+ open_audio_file: "Audio öffnen",
440
+ },
432
441
  generic: {
433
442
  ctrl_shortcut: "Strg",
434
443
  },
@@ -200,6 +200,10 @@ export const en = {
200
200
  toggle_blocks: {
201
201
  add_block_button: "Empty toggle. Click to add a block.",
202
202
  },
203
+ code_block: {
204
+ add_source_button_text: "Add source code",
205
+ ok_button_text: "OK",
206
+ },
203
207
  // from react package:
204
208
  side_menu: {
205
209
  add_block_label: "Add block",
@@ -410,6 +414,11 @@ export const en = {
410
414
  formatting_change_by: (formats: string, users: string) =>
411
415
  `Formatting change (${formats}) by: ${users}`,
412
416
  },
417
+ exporter: {
418
+ open_file: "Open file",
419
+ open_video_file: "Open video",
420
+ open_audio_file: "Open audio",
421
+ },
413
422
  generic: {
414
423
  ctrl_shortcut: "Ctrl",
415
424
  },
@@ -200,6 +200,10 @@ export const es: Dictionary = {
200
200
  toggle_blocks: {
201
201
  add_block_button: "Toggle vacío. Haz clic para añadir un bloque.",
202
202
  },
203
+ code_block: {
204
+ add_source_button_text: "Agregar código fuente",
205
+ ok_button_text: "Aceptar",
206
+ },
203
207
  side_menu: {
204
208
  add_block_label: "Agregar bloque",
205
209
  drag_handle_label: "Abrir menú de bloque",
@@ -408,6 +412,11 @@ export const es: Dictionary = {
408
412
  formatting_change_by: (formats: string, users: string) =>
409
413
  `Cambio de formato (${formats}) por: ${users}`,
410
414
  },
415
+ exporter: {
416
+ open_file: "Abrir archivo",
417
+ open_video_file: "Abrir vídeo",
418
+ open_audio_file: "Abrir audio",
419
+ },
411
420
  generic: {
412
421
  ctrl_shortcut: "Ctrl",
413
422
  },
@@ -168,6 +168,10 @@ export const fa = {
168
168
  toggle_blocks: {
169
169
  add_block_button: "تاشوی خالی. برای افزودن بلوک کلیک کنید.",
170
170
  },
171
+ code_block: {
172
+ add_source_button_text: "افزودن کد منبع",
173
+ ok_button_text: "تأیید",
174
+ },
171
175
  // from react package:
172
176
  side_menu: {
173
177
  add_block_label: "افزودن بلوک",
@@ -379,6 +383,11 @@ export const fa = {
379
383
  formatting_change_by: (formats: string, users: string) =>
380
384
  `تغییر قالب‌بندی (${formats}) توسط: ${users}`,
381
385
  },
386
+ exporter: {
387
+ open_file: "باز کردن فایل",
388
+ open_video_file: "باز کردن ویدیو",
389
+ open_audio_file: "باز کردن صدا",
390
+ },
382
391
  generic: {
383
392
  ctrl_shortcut: "Ctrl",
384
393
  },
@@ -246,6 +246,10 @@ export const fr: Dictionary = {
246
246
  toggle_blocks: {
247
247
  add_block_button: "Liste repliable vide. Cliquez pour ajouter un bloc.",
248
248
  },
249
+ code_block: {
250
+ add_source_button_text: "Ajouter le code source",
251
+ ok_button_text: "OK",
252
+ },
249
253
  // from react package:
250
254
  side_menu: {
251
255
  add_block_label: "Ajouter un bloc",
@@ -456,6 +460,11 @@ export const fr: Dictionary = {
456
460
  formatting_change_by: (formats: string, users: string) =>
457
461
  `Modification de mise en forme (${formats}) par : ${users}`,
458
462
  },
463
+ exporter: {
464
+ open_file: "Ouvrir le fichier",
465
+ open_video_file: "Ouvrir la vidéo",
466
+ open_audio_file: "Ouvrir l'audio",
467
+ },
459
468
  generic: {
460
469
  ctrl_shortcut: "Ctrl",
461
470
  },
@@ -202,6 +202,10 @@ export const he: Dictionary = {
202
202
  toggle_blocks: {
203
203
  add_block_button: "מתג ריק. לחץ כדי להוסיף בלוק.",
204
204
  },
205
+ code_block: {
206
+ add_source_button_text: "הוסף קוד מקור",
207
+ ok_button_text: "אישור",
208
+ },
205
209
  side_menu: {
206
210
  add_block_label: "הוסף בלוק",
207
211
  drag_handle_label: "פתח תפריט בלוק",
@@ -410,6 +414,11 @@ export const he: Dictionary = {
410
414
  formatting_change_by: (formats: string, users: string) =>
411
415
  `שינוי עיצוב (${formats}) על ידי: ${users}`,
412
416
  },
417
+ exporter: {
418
+ open_file: "פתח קובץ",
419
+ open_video_file: "פתח וידאו",
420
+ open_audio_file: "פתח שמע",
421
+ },
413
422
  generic: {
414
423
  ctrl_shortcut: "Ctrl",
415
424
  },
@@ -213,6 +213,10 @@ export const hr: Dictionary = {
213
213
  toggle_blocks: {
214
214
  add_block_button: "Prazan sklopivi blok. Klikni da dodaš sadržaj.",
215
215
  },
216
+ code_block: {
217
+ add_source_button_text: "Dodaj izvorni kôd",
218
+ ok_button_text: "U redu",
219
+ },
216
220
  // from react package:
217
221
  side_menu: {
218
222
  add_block_label: "Dodaj blok",
@@ -424,6 +428,11 @@ export const hr: Dictionary = {
424
428
  formatting_change_by: (formats: string, users: string) =>
425
429
  `Promjena oblikovanja (${formats}) od: ${users}`,
426
430
  },
431
+ exporter: {
432
+ open_file: "Otvori datoteku",
433
+ open_video_file: "Otvori videozapis",
434
+ open_audio_file: "Otvori audiozapis",
435
+ },
427
436
  generic: {
428
437
  ctrl_shortcut: "Ctrl",
429
438
  },
@@ -214,6 +214,10 @@ export const is: Dictionary = {
214
214
  toggle_blocks: {
215
215
  add_block_button: "Tóm fellilína. Smelltu til að bæta við blokk.",
216
216
  },
217
+ code_block: {
218
+ add_source_button_text: "Bæta við frumkóða",
219
+ ok_button_text: "Í lagi",
220
+ },
217
221
  side_menu: {
218
222
  add_block_label: "Bæta við blokki",
219
223
  drag_handle_label: "Opna blokkarvalmynd",
@@ -424,6 +428,11 @@ export const is: Dictionary = {
424
428
  formatting_change_by: (formats: string, users: string) =>
425
429
  `Sniðbreyting (${formats}) af: ${users}`,
426
430
  },
431
+ exporter: {
432
+ open_file: "Opna skrá",
433
+ open_video_file: "Opna myndband",
434
+ open_audio_file: "Opna hljóð",
435
+ },
427
436
  generic: {
428
437
  ctrl_shortcut: "Ctrl",
429
438
  },
@@ -222,6 +222,10 @@ export const it: Dictionary = {
222
222
  toggle_blocks: {
223
223
  add_block_button: "Toggle vuoto. Clicca per aggiungere un blocco.",
224
224
  },
225
+ code_block: {
226
+ add_source_button_text: "Aggiungi codice sorgente",
227
+ ok_button_text: "OK",
228
+ },
225
229
  // from react package:
226
230
  side_menu: {
227
231
  add_block_label: "Aggiungi blocco",
@@ -432,6 +436,11 @@ export const it: Dictionary = {
432
436
  formatting_change_by: (formats: string, users: string) =>
433
437
  `Modifica formattazione (${formats}) da: ${users}`,
434
438
  },
439
+ exporter: {
440
+ open_file: "Apri file",
441
+ open_video_file: "Apri video",
442
+ open_audio_file: "Apri audio",
443
+ },
435
444
  generic: {
436
445
  ctrl_shortcut: "Ctrl",
437
446
  },
@@ -240,6 +240,10 @@ export const ja: Dictionary = {
240
240
  toggle_blocks: {
241
241
  add_block_button: "空のトグルです。クリックしてブロックを追加。",
242
242
  },
243
+ code_block: {
244
+ add_source_button_text: "ソースコードを追加",
245
+ ok_button_text: "OK",
246
+ },
243
247
  // from react package:
244
248
  side_menu: {
245
249
  add_block_label: "ブロックを追加",
@@ -450,6 +454,11 @@ export const ja: Dictionary = {
450
454
  formatting_change_by: (formats: string, users: string) =>
451
455
  `書式の変更 (${formats}) 変更者: ${users}`,
452
456
  },
457
+ exporter: {
458
+ open_file: "ファイルを開く",
459
+ open_video_file: "動画を開く",
460
+ open_audio_file: "音声を開く",
461
+ },
453
462
  generic: {
454
463
  ctrl_shortcut: "Ctrl",
455
464
  },
@@ -213,6 +213,10 @@ export const ko: Dictionary = {
213
213
  toggle_blocks: {
214
214
  add_block_button: "비어 있는 토글입니다. 클릭하여 블록을 추가하세요.",
215
215
  },
216
+ code_block: {
217
+ add_source_button_text: "소스 코드 추가",
218
+ ok_button_text: "확인",
219
+ },
216
220
  // from react package:
217
221
  side_menu: {
218
222
  add_block_label: "블록 추가",
@@ -423,6 +427,11 @@ export const ko: Dictionary = {
423
427
  formatting_change_by: (formats: string, users: string) =>
424
428
  `서식 변경 (${formats}) 변경한 사람: ${users}`,
425
429
  },
430
+ exporter: {
431
+ open_file: "파일 열기",
432
+ open_video_file: "동영상 열기",
433
+ open_audio_file: "오디오 열기",
434
+ },
426
435
  generic: {
427
436
  ctrl_shortcut: "Ctrl",
428
437
  },
@@ -201,6 +201,10 @@ export const nl: Dictionary = {
201
201
  toggle_blocks: {
202
202
  add_block_button: "Lege uitklapper. Klik om een blok toe te voegen.",
203
203
  },
204
+ code_block: {
205
+ add_source_button_text: "Broncode toevoegen",
206
+ ok_button_text: "OK",
207
+ },
204
208
  // from react package:
205
209
  side_menu: {
206
210
  add_block_label: "Nieuw blok",
@@ -411,6 +415,11 @@ export const nl: Dictionary = {
411
415
  formatting_change_by: (formats: string, users: string) =>
412
416
  `Opmaakwijziging (${formats}) door: ${users}`,
413
417
  },
418
+ exporter: {
419
+ open_file: "Bestand openen",
420
+ open_video_file: "Video openen",
421
+ open_audio_file: "Audio openen",
422
+ },
414
423
  generic: {
415
424
  ctrl_shortcut: "Ctrl",
416
425
  },
@@ -219,6 +219,10 @@ export const no: Dictionary = {
219
219
  toggle_blocks: {
220
220
  add_block_button: "Tomt toggle. Klikk for å legge til en blokk.",
221
221
  },
222
+ code_block: {
223
+ add_source_button_text: "Legg til kildekode",
224
+ ok_button_text: "OK",
225
+ },
222
226
  side_menu: {
223
227
  add_block_label: "Legg til blokk",
224
228
  drag_handle_label: "Åpne blokkmeny",
@@ -428,6 +432,11 @@ export const no: Dictionary = {
428
432
  formatting_change_by: (formats: string, users: string) =>
429
433
  `Formateringsendring (${formats}) av: ${users}`,
430
434
  },
435
+ exporter: {
436
+ open_file: "Åpne fil",
437
+ open_video_file: "Åpne video",
438
+ open_audio_file: "Åpne lyd",
439
+ },
431
440
  generic: {
432
441
  ctrl_shortcut: "Ctrl",
433
442
  },
@@ -192,6 +192,10 @@ export const pl: Dictionary = {
192
192
  add_block_button:
193
193
  "Brak bloków do rozwinięcia. Kliknij, aby dodać pierwszego.",
194
194
  },
195
+ code_block: {
196
+ add_source_button_text: "Dodaj kod źródłowy",
197
+ ok_button_text: "OK",
198
+ },
195
199
  side_menu: {
196
200
  add_block_label: "Dodaj blok",
197
201
  drag_handle_label: "Otwórz menu bloków",
@@ -401,6 +405,11 @@ export const pl: Dictionary = {
401
405
  formatting_change_by: (formats: string, users: string) =>
402
406
  `Zmiana formatowania (${formats}) przez: ${users}`,
403
407
  },
408
+ exporter: {
409
+ open_file: "Otwórz plik",
410
+ open_video_file: "Otwórz wideo",
411
+ open_audio_file: "Otwórz audio",
412
+ },
404
413
  generic: {
405
414
  ctrl_shortcut: "Ctrl",
406
415
  },
@@ -192,6 +192,10 @@ export const pt: Dictionary = {
192
192
  toggle_blocks: {
193
193
  add_block_button: "Toggle vazio. Clique para adicionar um bloco.",
194
194
  },
195
+ code_block: {
196
+ add_source_button_text: "Adicionar código-fonte",
197
+ ok_button_text: "OK",
198
+ },
195
199
  // from react package:
196
200
  side_menu: {
197
201
  add_block_label: "Adicionar bloco",
@@ -403,6 +407,11 @@ export const pt: Dictionary = {
403
407
  formatting_change_by: (formats: string, users: string) =>
404
408
  `Alteração de formatação (${formats}) por: ${users}`,
405
409
  },
410
+ exporter: {
411
+ open_file: "Abrir arquivo",
412
+ open_video_file: "Abrir vídeo",
413
+ open_audio_file: "Abrir áudio",
414
+ },
406
415
  generic: {
407
416
  ctrl_shortcut: "Ctrl",
408
417
  },
@@ -243,6 +243,10 @@ export const ru: Dictionary = {
243
243
  toggle_blocks: {
244
244
  add_block_button: "Пустой переключатель. Нажмите, чтобы добавить блок.",
245
245
  },
246
+ code_block: {
247
+ add_source_button_text: "Добавить исходный код",
248
+ ok_button_text: "ОК",
249
+ },
246
250
  // from react package:
247
251
  side_menu: {
248
252
  add_block_label: "Добавить блок",
@@ -454,6 +458,11 @@ export const ru: Dictionary = {
454
458
  formatting_change_by: (formats: string, users: string) =>
455
459
  `Изменение форматирования (${formats}): ${users}`,
456
460
  },
461
+ exporter: {
462
+ open_file: "Открыть файл",
463
+ open_video_file: "Открыть видео",
464
+ open_audio_file: "Открыть аудио",
465
+ },
457
466
  generic: {
458
467
  ctrl_shortcut: "Ctrl",
459
468
  },
@@ -200,6 +200,10 @@ export const sk = {
200
200
  toggle_blocks: {
201
201
  add_block_button: "Prázdne prepínanie. Kliknite pre pridanie bloku.",
202
202
  },
203
+ code_block: {
204
+ add_source_button_text: "Pridať zdrojový kód",
205
+ ok_button_text: "OK",
206
+ },
203
207
  side_menu: {
204
208
  add_block_label: "Pridať blok",
205
209
  drag_handle_label: "Otvoriť menu bloku",
@@ -408,6 +412,11 @@ export const sk = {
408
412
  formatting_change_by: (formats: string, users: string) =>
409
413
  `Zmena formátovania (${formats}) od: ${users}`,
410
414
  },
415
+ exporter: {
416
+ open_file: "Otvoriť súbor",
417
+ open_video_file: "Otvoriť video",
418
+ open_audio_file: "Otvoriť zvuk",
419
+ },
411
420
  generic: {
412
421
  ctrl_shortcut: "Ctrl",
413
422
  },
@@ -225,6 +225,10 @@ export const uk: Dictionary = {
225
225
  toggle_blocks: {
226
226
  add_block_button: "Порожній перемикач. Натисніть, щоб додати блок.",
227
227
  },
228
+ code_block: {
229
+ add_source_button_text: "Додати вихідний код",
230
+ ok_button_text: "ОК",
231
+ },
228
232
  // from react package:
229
233
  side_menu: {
230
234
  add_block_label: "Додати блок",
@@ -434,6 +438,11 @@ export const uk: Dictionary = {
434
438
  formatting_change_by: (formats: string, users: string) =>
435
439
  `Зміна форматування (${formats}) користувачем: ${users}`,
436
440
  },
441
+ exporter: {
442
+ open_file: "Відкрити файл",
443
+ open_video_file: "Відкрити відео",
444
+ open_audio_file: "Відкрити аудіо",
445
+ },
437
446
  generic: {
438
447
  ctrl_shortcut: "Ctrl",
439
448
  },
@@ -262,6 +262,10 @@ export const uz: Dictionary = {
262
262
  add_block_button: "Bo‘sh toggle. Blok qo‘shish uchun bosing.",
263
263
  },
264
264
 
265
+ code_block: {
266
+ add_source_button_text: "Manba kodini qoʻshish",
267
+ ok_button_text: "OK",
268
+ },
265
269
  side_menu: {
266
270
  add_block_label: "Blok qo‘shish",
267
271
  drag_handle_label: "Blok menyusini ochish",
@@ -444,6 +448,11 @@ export const uz: Dictionary = {
444
448
  formatting_change_by: (formats: string, users: string) =>
445
449
  `Formatlash o'zgarishi (${formats}), o'zgartirgan: ${users}`,
446
450
  },
451
+ exporter: {
452
+ open_file: "Faylni ochish",
453
+ open_video_file: "Videoni ochish",
454
+ open_audio_file: "Audioni ochish",
455
+ },
447
456
  generic: {
448
457
  ctrl_shortcut: "Ctrl",
449
458
  },
@@ -199,6 +199,10 @@ export const vi: Dictionary = {
199
199
  toggle_blocks: {
200
200
  add_block_button: "Toggle trống. Nhấp để thêm khối.",
201
201
  },
202
+ code_block: {
203
+ add_source_button_text: "Thêm mã nguồn",
204
+ ok_button_text: "OK",
205
+ },
202
206
  // từ gói phản ứng:
203
207
  side_menu: {
204
208
  add_block_label: "Thêm khối",
@@ -409,6 +413,11 @@ export const vi: Dictionary = {
409
413
  formatting_change_by: (formats: string, users: string) =>
410
414
  `Thay đổi định dạng (${formats}) bởi: ${users}`,
411
415
  },
416
+ exporter: {
417
+ open_file: "Mở tệp",
418
+ open_video_file: "Mở video",
419
+ open_audio_file: "Mở âm thanh",
420
+ },
412
421
  generic: {
413
422
  ctrl_shortcut: "Ctrl",
414
423
  },
@@ -241,6 +241,10 @@ export const zhTW: Dictionary = {
241
241
  toggle_blocks: {
242
242
  add_block_button: "空的切換區。點擊新增區塊。",
243
243
  },
244
+ code_block: {
245
+ add_source_button_text: "新增原始碼",
246
+ ok_button_text: "確定",
247
+ },
244
248
  // from react package:
245
249
  side_menu: {
246
250
  add_block_label: "新增區塊",
@@ -451,6 +455,11 @@ export const zhTW: Dictionary = {
451
455
  formatting_change_by: (formats: string, users: string) =>
452
456
  `格式變更(${formats}),變更者:${users}`,
453
457
  },
458
+ exporter: {
459
+ open_file: "開啟檔案",
460
+ open_video_file: "開啟影片",
461
+ open_audio_file: "開啟音訊",
462
+ },
454
463
  generic: {
455
464
  ctrl_shortcut: "Ctrl",
456
465
  },
@@ -241,6 +241,10 @@ export const zh: Dictionary = {
241
241
  toggle_blocks: {
242
242
  add_block_button: "空的切换区。点击添加区块。",
243
243
  },
244
+ code_block: {
245
+ add_source_button_text: "添加源代码",
246
+ ok_button_text: "确定",
247
+ },
244
248
  // from react package:
245
249
  side_menu: {
246
250
  add_block_label: "添加块",
@@ -451,6 +455,11 @@ export const zh: Dictionary = {
451
455
  formatting_change_by: (formats: string, users: string) =>
452
456
  `格式更改(${formats}),更改者:${users}`,
453
457
  },
458
+ exporter: {
459
+ open_file: "打开文件",
460
+ open_video_file: "打开视频",
461
+ open_audio_file: "打开音频",
462
+ },
454
463
  generic: {
455
464
  ctrl_shortcut: "Ctrl",
456
465
  },
package/src/index.ts CHANGED
@@ -23,11 +23,15 @@ 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
30
 
30
- export type { CodeBlockOptions } from "./blocks/Code/block.js";
31
+ export type {
32
+ CodeBlockOptions,
33
+ CodeBlockPreview,
34
+ } from "./blocks/Code/CodeBlockOptions.js";
31
35
  export { assertEmpty, UnreachableCaseError } from "./util/typescript.js";
32
36
 
33
37
  export * from "./util/EventEmitter.js";
@@ -7,12 +7,12 @@ import {
7
7
  } from "@tiptap/pm/model";
8
8
  import { NodeView } from "@tiptap/pm/view";
9
9
  import { mergeParagraphs } from "../../blocks/defaultBlockHelpers.js";
10
- import { ignoreNonContentMutations } from "../nodeViewMutations.js";
11
10
  import {
12
11
  Extension,
13
12
  ExtensionFactoryInstance,
14
13
  } from "../../editor/BlockNoteExtension.js";
15
14
  import { nonFormattingMarks } from "../markGroups.js";
15
+ import { ignoreNonContentMutations } from "../nodeViewMutations.js";
16
16
  import { PropSchema } from "../propTypes.js";
17
17
  import {
18
18
  getBlockFromNodeView,
@@ -286,8 +286,7 @@ export function addNodeAndExtensionsToSpec<
286
286
 
287
287
  // See explanation for why `update` is not implemented for NodeViews
288
288
  // https://github.com/TypeCellOS/BlockNote/pull/1904#discussion_r2313461464
289
- // TODO: in a future version, we might want to implement updates so that
290
- // vanilla blocks don't always re-render entirely (https://github.com/TypeCellOS/BlockNote/issues/220)
289
+ // https://github.com/TypeCellOS/BlockNote/issues/220
291
290
  return typedNodeView;
292
291
  };
293
292
  },
@@ -1,7 +1,11 @@
1
1
  /** Define the main block types **/
2
2
  // import { Extension, Node } from "@tiptap/core";
3
3
  import type { Node, NodeViewRendererProps } from "@tiptap/core";
4
- import type { Fragment, Schema } from "prosemirror-model";
4
+ import type {
5
+ Fragment,
6
+ Node as ProsemirrorNode,
7
+ Schema,
8
+ } from "prosemirror-model";
5
9
  import type { ViewMutationRecord } from "prosemirror-view";
6
10
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
7
11
  import type {
@@ -28,7 +32,10 @@ export type BlockNoteDOMAttributes = Partial<{
28
32
  [DOMElement in BlockNoteDOMElement]: Record<string, string>;
29
33
  }>;
30
34
 
31
- export interface BlockConfigMeta {
35
+ export interface BlockConfigMeta<
36
+ TName extends string = string,
37
+ TProps extends PropSchema = PropSchema,
38
+ > {
32
39
  /**
33
40
  * Defines which keyboard shortcut should be used to insert a hard break into the block's inline content.
34
41
  * @default "shift+enter"
@@ -59,6 +66,18 @@ export interface BlockConfigMeta {
59
66
  * Whether the block is a {@link https://prosemirror.net/docs/ref/#model.NodeSpec.isolating} block
60
67
  */
61
68
  isolating?: boolean;
69
+
70
+ /**
71
+ * Enables syntax highlighting of the contents of the block with the result of this callback
72
+ */
73
+ highlight?(block: { type: TName; props: Props<TProps> }): string | undefined;
74
+
75
+ /**
76
+ * Marks the block as rendering a preview with an editable source popup, driven
77
+ * by the editor-wide `SourceBlockWithPreviewExtension`. When `true`, the
78
+ * block's source is hidden behind its preview and edited via the popup.
79
+ */
80
+ hasPreview?: boolean;
62
81
  }
63
82
 
64
83
  /**
@@ -209,6 +228,7 @@ export type LooseBlockSpec<
209
228
  dom: HTMLElement | DocumentFragment;
210
229
  contentDOM?: HTMLElement;
211
230
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
231
+ update?: (node: ProsemirrorNode) => boolean;
212
232
  destroy?: () => void;
213
233
  };
214
234
  toExternalHTML?: (
@@ -267,6 +287,7 @@ export type BlockSpecs = {
267
287
  dom: HTMLElement | DocumentFragment;
268
288
  contentDOM?: HTMLElement;
269
289
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
290
+ update?: (node: ProsemirrorNode) => boolean;
270
291
  destroy?: () => void;
271
292
  };
272
293
  toExternalHTML?: (
@@ -354,6 +375,24 @@ export type PartialPlainContent =
354
375
  | string
355
376
  | (string | (StyledText<{}> & { styles: Record<string, never> }))[];
356
377
 
378
+ /**
379
+ * The text of a block's `"plain"` content (e.g. a code block's source code).
380
+ * Accepts the partial form too: block render/export paths can receive
381
+ * `PartialBlock`s (e.g. the HTML serializers take them directly), where
382
+ * plain content may still be the bare-string sugar.
383
+ */
384
+ export function plainContentToString(
385
+ content: PlainContent | PartialPlainContent,
386
+ ): string {
387
+ if (typeof content === "string") {
388
+ return content;
389
+ }
390
+
391
+ return content
392
+ .map((item) => (typeof item === "string" ? item : item.text))
393
+ .join("");
394
+ }
395
+
357
396
  // A BlockConfig has all the information to get the type of a Block (which is a specific instance of the BlockConfig.
358
397
  // i.e.: paragraphConfig: BlockConfig defines what a "paragraph" is / supports, and BlockFromConfigNoChildren<paragraphConfig> is the shape of a specific paragraph block.
359
398
  // (for internal use)
@@ -518,7 +557,7 @@ export type BlockImplementation<
518
557
  /**
519
558
  * Metadata
520
559
  */
521
- meta?: BlockConfigMeta;
560
+ meta?: BlockConfigMeta<TName, TProps>;
522
561
  /**
523
562
  * A function that converts the block into a DOM element
524
563
  */
@@ -552,6 +591,17 @@ export type BlockImplementation<
552
591
  dom: HTMLElement | DocumentFragment;
553
592
  contentDOM?: HTMLElement;
554
593
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
594
+ /**
595
+ * Called by ProseMirror when this block's node is updated (e.g. its content
596
+ * or props change). Return `true` to handle the update in place - keeping
597
+ * the existing DOM - or `false` to have the node view recreated via
598
+ * `render`. When omitted, ProseMirror keeps the node view and reconciles its
599
+ * `contentDOM` in place as long as the node type stays the same.
600
+ *
601
+ * Useful for blocks whose `render` builds custom DOM that needs to stay in
602
+ * sync with the node (e.g. a code block rendering a preview of its content).
603
+ */
604
+ update?: (node: ProsemirrorNode) => boolean;
555
605
  destroy?: () => void;
556
606
  };
557
607