@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
package/dist/blocks.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./blocks-BPmJglFo.cjs");exports.BlockNoteSchema=e.t,exports.EMPTY_CELL_HEIGHT=e.E,exports.EMPTY_CELL_WIDTH=e.D,exports.FILE_AUDIO_ICON_SVG=e.ut,exports.FILE_IMAGE_ICON_SVG=e.K,exports.FILE_VIDEO_ICON_SVG=e.b,exports.addDefaultPropsExternalHTML=e.vt,exports.audioParse=e.dt,exports.audioRender=e.ft,exports.audioToExternalHTML=e.pt,exports.blockHasType=e.h,exports.checkPageBreakBlocksInSchema=e.s,exports.createAudioBlockConfig=e.mt,exports.createAudioBlockSpec=e.ht,exports.createBulletListItemBlockConfig=e.U,exports.createBulletListItemBlockSpec=e.W,exports.createCheckListItemBlockSpec=e.V,exports.createCheckListItemConfig=e.H,exports.createCodeBlockConfig=e.st,exports.createCodeBlockSpec=e.ct,exports.createDefaultBlockDOMOutputSpec=e.Mn,exports.createDividerBlockConfig=e.at,exports.createDividerBlockSpec=e.ot,exports.createFileBlockConfig=e.nt,exports.createFileBlockSpec=e.rt,exports.createHeadingBlockConfig=e.Q,exports.createHeadingBlockSpec=e.$,exports.createImageBlockConfig=e.q,exports.createImageBlockSpec=e.J,exports.createNumberedListItemBlockConfig=e.z,exports.createNumberedListItemBlockSpec=e.B,exports.createPageBreakBlockConfig=e.P,exports.createPageBreakBlockSpec=e.F,exports.createParagraphBlockConfig=e.M,exports.createParagraphBlockSpec=e.N,exports.createQuoteBlockConfig=e.A,exports.createQuoteBlockSpec=e.j,exports.createTableBlockSpec=e.w,exports.createToggleListItemBlockConfig=e.L,exports.createToggleListItemBlockSpec=e.R,exports.createToggleWrapper=e.et,exports.createVideoBlockConfig=e.x,exports.createVideoBlockSpec=e.S,exports.defaultBlockSpecs=e.n,exports.defaultBlockToHTML=e.Nn,exports.defaultInlineContentSchema=e.r,exports.defaultInlineContentSpecs=e.i,exports.defaultProps=e.yt,exports.defaultStyleSchema=e.a,exports.defaultStyleSpecs=e.o,exports.defaultToggledState=e.tt,exports.editorHasBlockWithType=e.g,exports.fileParse=e.it,exports.getBackgroundColorAttribute=e.bt,exports.getLanguageId=e.lt,exports.getPageBreakSlashMenuItems=e.c,exports.getTextAlignmentAttribute=e.xt,exports.getTextColorAttribute=e.St,exports.imageParse=e.Y,exports.imageRender=e.X,exports.imageToExternalHTML=e.Z,exports.isTableCellNode=e._,exports.isTableCellSelection=e.v,exports.mergeParagraphs=e.Pn,exports.parseAudioElement=e.gt,exports.parseDefaultProps=e.Ct,exports.tablePropSchema=e.T,exports.uploadToTmpFilesDotOrg_DEV_ONLY=e.y,exports.videoParse=e.C,exports.withPageBreak=e.I;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./blocks-CTB_5Vyj.cjs");exports.BlockNoteSchema=e.t,exports.EMPTY_CELL_HEIGHT=e.T,exports.EMPTY_CELL_WIDTH=e.E,exports.FILE_AUDIO_ICON_SVG=e.pt,exports.FILE_IMAGE_ICON_SVG=e.G,exports.FILE_VIDEO_ICON_SVG=e.y,exports.addDefaultPropsExternalHTML=e.xt,exports.audioParse=e.mt,exports.audioRender=e.ht,exports.audioToExternalHTML=e.gt,exports.blockHasType=e.h,exports.checkPageBreakBlocksInSchema=e.s,exports.createAudioBlockConfig=e._t,exports.createAudioBlockSpec=e.vt,exports.createBulletListItemBlockConfig=e.H,exports.createBulletListItemBlockSpec=e.U,exports.createCheckListItemBlockSpec=e.B,exports.createCheckListItemConfig=e.V,exports.createCodeBlock=e.ct,exports.createCodeBlockConfig=e.ot,exports.createCodeBlockSpec=e.st,exports.createDefaultBlockDOMOutputSpec=e.Fn,exports.createDividerBlockConfig=e.it,exports.createDividerBlockSpec=e.at,exports.createFileBlockConfig=e.tt,exports.createFileBlockSpec=e.nt,exports.createHeadingBlockConfig=e.Z,exports.createHeadingBlockSpec=e.Q,exports.createImageBlockConfig=e.K,exports.createImageBlockSpec=e.q,exports.createLanguageSelect=e.lt,exports.createNumberedListItemBlockConfig=e.R,exports.createNumberedListItemBlockSpec=e.z,exports.createPageBreakBlockConfig=e.N,exports.createPageBreakBlockSpec=e.P,exports.createParagraphBlockConfig=e.j,exports.createParagraphBlockSpec=e.M,exports.createPreCode=e.ut,exports.createQuoteBlockConfig=e.k,exports.createQuoteBlockSpec=e.A,exports.createTableBlockSpec=e.C,exports.createToggleListItemBlockConfig=e.I,exports.createToggleListItemBlockSpec=e.L,exports.createToggleWrapper=e.$,exports.createVideoBlockConfig=e.b,exports.createVideoBlockSpec=e.x,exports.defaultBlockSpecs=e.n,exports.defaultBlockToHTML=e.In,exports.defaultInlineContentSchema=e.r,exports.defaultInlineContentSpecs=e.i,exports.defaultProps=e.St,exports.defaultStyleSchema=e.a,exports.defaultStyleSpecs=e.o,exports.defaultToggledState=e.et,exports.editorHasBlockWithType=e.g,exports.fileParse=e.rt,exports.getBackgroundColorAttribute=e.Ct,exports.getPageBreakSlashMenuItems=e.c,exports.getTextAlignmentAttribute=e.wt,exports.getTextColorAttribute=e.Tt,exports.imageParse=e.J,exports.imageRender=e.Y,exports.imageToExternalHTML=e.X,exports.isTableCellNode=e._,exports.isTableCellSelection=e.v,exports.mergeParagraphs=e.Ln,exports.parseAudioElement=e.yt,exports.parseDefaultProps=e.Et,exports.parsePreCode=e.dt,exports.parsePreCodeContent=e.ft,exports.tablePropSchema=e.w,exports.videoParse=e.S,exports.withPageBreak=e.F;
package/dist/blocks.js CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as e, A as t, B as n, C as r, Ct as i, D as a, E as o, F as s, H as c, I as l, J as u, K as d, L as f, M as p, Mn as m, N as h, Nn as g, P as _, Pn as v, Q as y, R as b, S as x, St as S, T as C, U as w, V as T, W as E, X as D, Y as O, Z as k, _ as A, a as j, at as M, b as N, bt as P, c as F, ct as I, dt as L, et as R, ft as z, g as B, gt as V, h as H, ht as U, i as W, it as G, j as K, lt as q, mt as J, n as Y, nt as X, o as Z, ot as Q, pt as $, q as ee, r as te, rt as ne, s as re, st as ie, t as ae, tt as oe, ut as se, v as ce, vt as le, w as ue, x as de, xt as fe, y as pe, yt as me, z as he } from "./blocks-BEJW9OM_.js";
2
- export { ae as BlockNoteSchema, o as EMPTY_CELL_HEIGHT, a as EMPTY_CELL_WIDTH, se as FILE_AUDIO_ICON_SVG, d as FILE_IMAGE_ICON_SVG, N as FILE_VIDEO_ICON_SVG, le as addDefaultPropsExternalHTML, L as audioParse, z as audioRender, $ as audioToExternalHTML, H as blockHasType, re as checkPageBreakBlocksInSchema, J as createAudioBlockConfig, U as createAudioBlockSpec, w as createBulletListItemBlockConfig, E as createBulletListItemBlockSpec, T as createCheckListItemBlockSpec, c as createCheckListItemConfig, ie as createCodeBlockConfig, I as createCodeBlockSpec, m as createDefaultBlockDOMOutputSpec, M as createDividerBlockConfig, Q as createDividerBlockSpec, X as createFileBlockConfig, ne as createFileBlockSpec, y as createHeadingBlockConfig, e as createHeadingBlockSpec, ee as createImageBlockConfig, u as createImageBlockSpec, he as createNumberedListItemBlockConfig, n as createNumberedListItemBlockSpec, _ as createPageBreakBlockConfig, s as createPageBreakBlockSpec, p as createParagraphBlockConfig, h as createParagraphBlockSpec, t as createQuoteBlockConfig, K as createQuoteBlockSpec, ue as createTableBlockSpec, f as createToggleListItemBlockConfig, b as createToggleListItemBlockSpec, R as createToggleWrapper, de as createVideoBlockConfig, x as createVideoBlockSpec, Y as defaultBlockSpecs, g as defaultBlockToHTML, te as defaultInlineContentSchema, W as defaultInlineContentSpecs, me as defaultProps, j as defaultStyleSchema, Z as defaultStyleSpecs, oe as defaultToggledState, B as editorHasBlockWithType, G as fileParse, P as getBackgroundColorAttribute, q as getLanguageId, F as getPageBreakSlashMenuItems, fe as getTextAlignmentAttribute, S as getTextColorAttribute, O as imageParse, D as imageRender, k as imageToExternalHTML, A as isTableCellNode, ce as isTableCellSelection, v as mergeParagraphs, V as parseAudioElement, i as parseDefaultProps, C as tablePropSchema, pe as uploadToTmpFilesDotOrg_DEV_ONLY, r as videoParse, l as withPageBreak };
1
+ import { $ as e, A as t, B as n, C as r, Ct as i, E as a, Et as o, F as s, Fn as c, G as l, H as u, I as d, In as f, J as p, K as m, L as h, Ln as g, M as _, N as v, P as y, Q as b, R as x, S, St as C, T as w, Tt as T, U as E, V as D, X as O, Y as k, Z as A, _ as j, _t as M, a as N, at as P, b as F, c as I, ct as L, dt as R, et as z, ft as B, g as V, gt as H, h as U, ht as W, i as G, it as K, j as q, k as J, lt as Y, mt as X, n as Z, nt as Q, o as $, ot as ee, pt as te, q as ne, r as re, rt as ie, s as ae, st as oe, t as se, tt as ce, ut as le, v as ue, vt as de, w as fe, wt as pe, x as me, xt as he, y as ge, yt as _e, z as ve } from "./blocks-Dol85hpH.js";
2
+ export { se as BlockNoteSchema, w as EMPTY_CELL_HEIGHT, a as EMPTY_CELL_WIDTH, te as FILE_AUDIO_ICON_SVG, l as FILE_IMAGE_ICON_SVG, ge as FILE_VIDEO_ICON_SVG, he as addDefaultPropsExternalHTML, X as audioParse, W as audioRender, H as audioToExternalHTML, U as blockHasType, ae as checkPageBreakBlocksInSchema, M as createAudioBlockConfig, de as createAudioBlockSpec, u as createBulletListItemBlockConfig, E as createBulletListItemBlockSpec, n as createCheckListItemBlockSpec, D as createCheckListItemConfig, L as createCodeBlock, ee as createCodeBlockConfig, oe as createCodeBlockSpec, c as createDefaultBlockDOMOutputSpec, K as createDividerBlockConfig, P as createDividerBlockSpec, ce as createFileBlockConfig, Q as createFileBlockSpec, A as createHeadingBlockConfig, b as createHeadingBlockSpec, m as createImageBlockConfig, ne as createImageBlockSpec, Y as createLanguageSelect, x as createNumberedListItemBlockConfig, ve as createNumberedListItemBlockSpec, v as createPageBreakBlockConfig, y as createPageBreakBlockSpec, q as createParagraphBlockConfig, _ as createParagraphBlockSpec, le as createPreCode, J as createQuoteBlockConfig, t as createQuoteBlockSpec, r as createTableBlockSpec, d as createToggleListItemBlockConfig, h as createToggleListItemBlockSpec, e as createToggleWrapper, F as createVideoBlockConfig, me as createVideoBlockSpec, Z as defaultBlockSpecs, f as defaultBlockToHTML, re as defaultInlineContentSchema, G as defaultInlineContentSpecs, C as defaultProps, N as defaultStyleSchema, $ as defaultStyleSpecs, z as defaultToggledState, V as editorHasBlockWithType, ie as fileParse, i as getBackgroundColorAttribute, I as getPageBreakSlashMenuItems, pe as getTextAlignmentAttribute, T as getTextColorAttribute, p as imageParse, k as imageRender, O as imageToExternalHTML, j as isTableCellNode, ue as isTableCellSelection, g as mergeParagraphs, _e as parseAudioElement, o as parseDefaultProps, R as parsePreCode, B as parsePreCodeContent, fe as tablePropSchema, S as videoParse, s as withPageBreak };
package/dist/comments.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./BlockNoteExtension-M0znTzxP.cjs"),t=require("./UserStore-DCG6lsla.cjs"),n=require("./ThreadStore-Bx-gSEh1.cjs");let r=require("@tiptap/core"),i=require("prosemirror-state"),a=require("prosemirror-view");var o=r.Mark.create({name:`comment`,excludes:``,inclusive:!1,keepOnSplit:!0,group:e.i,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute(`data-orphan`),renderHTML:e=>e.orphan?{"data-orphan":`true`}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute(`data-bn-thread-id`),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:``}}},renderHTML({HTMLAttributes:e}){return[`span`,(0,r.mergeAttributes)(e,{class:`bn-thread-mark`})]},parseHTML(){return[{tag:`span.bn-thread-mark`}]},extendMarkSchema(e){return e.name===`comment`?{blocknoteIgnore:!0}:{}}}),s=new i.PluginKey(`blocknote-comments`);function c(e,t){let n=new Map;return e.descendants((e,r)=>{e.marks.forEach(i=>{if(i.type.name===t){let t=i.attrs.threadId;if(!t)return;let a=r,o=a+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(a,s.from),to:Math.max(o,s.to)})}})}),n}var l=e.t(({editor:n,options:{schema:r,threadStore:l,resolveUsers:u,confirmBeforeDiscard:d=!0}})=>{if(!u)throw Error(`resolveUsers is required to be defined when using comments`);if(!l)throw Error(`threadStore is required to be defined when using comments`);let f=t.n(u),p=o.name,m=e.n({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(){m.state.selectedThreadId!==m.prevState.selectedThreadId&&n.transact(e=>e.setMeta(s,!0))}}),h=e=>{n.transact(t=>{t.doc.descendants((n,r)=>{n.marks.forEach(i=>{if(i.type.name===p){let a=i.type,o=i.attrs.threadId,s=e.get(o),c=!!(!s||s.resolved||s.deletedAt);if(c!==i.attrs.orphan){let e=Math.max(r,0),s=Math.min(r+n.nodeSize,t.doc.content.size-1,t.doc.content.size-1);t.removeMark(e,s,i),t.addMark(e,s,a.create({...i.attrs,orphan:c})),c&&m.state.selectedThreadId===o&&m.setState(e=>({...e,selectedThreadId:void 0}))}}})})})};return{key:`comments`,store:m,userStore:f,runsBefore:[`link`],tiptapExtensions:[o],prosemirrorPlugins:[new i.Plugin({key:s,state:{init(){return{decorations:a.DecorationSet.empty}},apply(e,t){let n=e.getMeta(s);if(!e.docChanged&&!n)return t;let r=e.docChanged?c(e.doc,p):m.state.threadPositions;(r.size>0||m.state.threadPositions.size>0)&&m.setState(e=>({...e,threadPositions:r}));let i=[];if(m.state.selectedThreadId){let e=r.get(m.state.selectedThreadId);e&&i.push(a.Decoration.inline(e.from,e.to,{class:`bn-thread-mark-selected`}))}return{decorations:a.DecorationSet.create(e.doc,i)}}},props:{decorations(e){return s.getState(e)?.decorations??a.DecorationSet.empty},handleClick:(e,t,n)=>{if(n.button!==0)return!1;let r=e.state.doc.nodeAt(t);if(!r)return m.setState(e=>({...e,selectedThreadId:void 0})),!1;let i=r.marks.find(e=>e.type.name===p&&e.attrs.orphan!==!0);if(!i)return m.state.selectedThreadId!==void 0&&m.setState(e=>({...e,selectedThreadId:void 0})),!1;let a=i.attrs.threadId;return a===m.state.selectedThreadId?!1:(m.setState(e=>({...e,selectedThreadId:a})),!0)}}})],threadStore:l,mount(){let e=l.subscribe(h);h(l.getThreads());let t=n.onSelectionChange(()=>{m.state.pendingComment&&m.setState(e=>({...e,pendingComment:!1}))});return()=>{e(),t()}},selectThread(e,t=!0){if(m.state.selectedThreadId!==e&&(m.setState(t=>({...t,pendingComment:!1,selectedThreadId:e})),e&&t)){let t=m.state.threadPositions.get(e);if(!t)return;(n.prosemirrorView?.domAtPos(t.from).node)?.scrollIntoView({behavior:`smooth`,block:`center`})}},startPendingComment(){m.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!0})),n.domElement?.focus(),n.getExtension(t.r)?.showSelection(!0,`comments`)},stopPendingComment(){m.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!1})),n.getExtension(t.r)?.showSelection(!1,`comments`)},async createThread(e){let t=await l.createThread(e);l.addThreadToDocument?await l.addThreadToDocument({threadId:t.id,selection:n.transact(e=>e.selection),editor:n}):n._tiptapEditor.commands.setMark(p,{orphan:!1,threadId:t.id})},commentEditorSchema:r,confirmBeforeDiscard:d}}),u=class{},d=class extends u{userId;role;constructor(e,t){super(),this.userId=e,this.role=t}canCreateThread(){return!0}canAddComment(e){return!0}canUpdateComment(e){return e.userId===this.userId}canDeleteComment(e){return e.userId===this.userId||this.role===`editor`}canDeleteThread(e){return this.role===`editor`}canResolveThread(e){return!0}canUnresolveThread(e){return!0}canAddReaction(e,t){return t?!e.reactions.some(e=>e.emoji===t&&e.userIds.includes(this.userId)):!0}canDeleteReaction(e,t){return t?e.reactions.some(e=>e.emoji===t&&e.userIds.includes(this.userId)):!0}},f=class extends n.t{userId;provider;constructor(e,t,n){super(n),this.userId=e,this.provider=t}async createThread(e){let t=this.provider.createThread({data:e.metadata});return t=this.provider.addComment(t.id,{content:e.initialComment.body,data:{metadata:e.initialComment.metadata,userId:this.userId}}),this.tiptapThreadToThreadData(t)}addThreadToDocument=void 0;async addComment(e){let t=this.provider.addComment(e.threadId,{content:e.comment.body,data:{metadata:e.comment.metadata,userId:this.userId}});return this.tiptapCommentToCommentData(t.comments[t.comments.length-1])}async updateComment(e){let t=this.provider.getThreadComment(e.threadId,e.commentId,!0);if(!t)throw Error(`Comment not found`);this.provider.updateComment(e.threadId,e.commentId,{content:e.comment.body,data:{...t.data,metadata:e.comment.metadata}})}tiptapCommentToCommentData(e){let t=[];for(let n of e.data?.reactions||[]){let e=t.find(e=>e.emoji===n.emoji);e?(e.userIds.push(n.userId),e.createdAt=new Date(Math.min(e.createdAt.getTime(),n.createdAt))):t.push({emoji:n.emoji,createdAt:new Date(n.createdAt),userIds:[n.userId]})}return{type:`comment`,id:e.id,body:e.content,metadata:e.data?.metadata,userId:e.data?.userId,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),reactions:t}}tiptapThreadToThreadData(e){return{type:`thread`,id:e.id,comments:e.comments.map(e=>this.tiptapCommentToCommentData(e)),resolved:!!e.resolvedAt,metadata:e.data?.metadata,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt)}}async deleteComment(e){this.provider.deleteComment(e.threadId,e.commentId)}async deleteThread(e){this.provider.deleteThread(e.threadId)}async resolveThread(e){this.provider.updateThread(e.threadId,{resolvedAt:new Date().toISOString()})}async unresolveThread(e){this.provider.updateThread(e.threadId,{resolvedAt:null})}async addReaction(e){let t=this.provider.getThreadComment(e.threadId,e.commentId,!0);if(!t)throw Error(`Comment not found`);this.provider.updateComment(e.threadId,e.commentId,{data:{...t.data,reactions:[...t.data?.reactions||[],{emoji:e.emoji,createdAt:Date.now(),userId:this.userId}]}})}async deleteReaction(e){let t=this.provider.getThreadComment(e.threadId,e.commentId,!0);if(!t)throw Error(`Comment not found`);this.provider.updateComment(e.threadId,e.commentId,{data:{...t.data,reactions:(t.data?.reactions||[]).filter(t=>t.emoji!==e.emoji&&t.userId!==this.userId)}})}getThread(e){let t=this.provider.getThread(e);if(!t)throw Error(`Thread not found`);return this.tiptapThreadToThreadData(t)}getThreads(){return new Map(this.provider.getThreads().map(e=>[e.id,this.tiptapThreadToThreadData(e)]))}subscribe(e){let t=()=>{e(this.getThreads())};return this.provider.watchThreads(t),()=>{this.provider.unwatchThreads(t)}}};exports.CommentMark=o,exports.CommentsExtension=l,exports.DefaultThreadStoreAuth=d,exports.ThreadStore=n.t,exports.ThreadStoreAuth=u,exports.TiptapThreadStore=f;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./BlockNoteExtension-BJCLnwrE.cjs"),t=require("./UserStore-mj3fXW4D.cjs"),n=require("./ThreadStore-Bx-gSEh1.cjs");let r=require("@tiptap/core"),i=require("prosemirror-state"),a=require("prosemirror-view");var o=r.Mark.create({name:`comment`,excludes:``,inclusive:!1,keepOnSplit:!0,group:e.a,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute(`data-orphan`),renderHTML:e=>e.orphan?{"data-orphan":`true`}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute(`data-bn-thread-id`),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:``}}},renderHTML({HTMLAttributes:e}){return[`span`,(0,r.mergeAttributes)(e,{class:`bn-thread-mark`})]},parseHTML(){return[{tag:`span.bn-thread-mark`}]},extendMarkSchema(e){return e.name===`comment`?{blocknoteIgnore:!0}:{}}}),s=new i.PluginKey(`blocknote-comments`);function c(e,t){let n=new Map;return e.descendants((e,r)=>{e.marks.forEach(i=>{if(i.type.name===t){let t=i.attrs.threadId;if(!t)return;let a=r,o=a+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(a,s.from),to:Math.max(o,s.to)})}})}),n}var l=e.t(({editor:n,options:{schema:r,threadStore:l,resolveUsers:u,confirmBeforeDiscard:d=!0}})=>{if(!u)throw Error(`resolveUsers is required to be defined when using comments`);if(!l)throw Error(`threadStore is required to be defined when using comments`);let f=t.n(u),p=o.name,m=e.n({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(e,t){e.selectedThreadId!==t.selectedThreadId&&n.transact(e=>e.setMeta(s,!0))}}),h=e=>{n.transact(t=>{t.doc.descendants((n,r)=>{n.marks.forEach(i=>{if(i.type.name===p){let a=i.type,o=i.attrs.threadId,s=e.get(o),c=!!(!s||s.resolved||s.deletedAt);if(c!==i.attrs.orphan){let e=Math.max(r,0),s=Math.min(r+n.nodeSize,t.doc.content.size-1,t.doc.content.size-1);t.removeMark(e,s,i),t.addMark(e,s,a.create({...i.attrs,orphan:c})),c&&m.state.selectedThreadId===o&&m.setState(e=>({...e,selectedThreadId:void 0}))}}})})})};return{key:`comments`,store:m,userStore:f,runsBefore:[`link`],tiptapExtensions:[o],prosemirrorPlugins:[new i.Plugin({key:s,state:{init(){return{decorations:a.DecorationSet.empty}},apply(e,t){let n=e.getMeta(s);if(!e.docChanged&&!n)return t;let r=e.docChanged?c(e.doc,p):m.state.threadPositions;(r.size>0||m.state.threadPositions.size>0)&&m.setState(e=>({...e,threadPositions:r}));let i=[];if(m.state.selectedThreadId){let e=r.get(m.state.selectedThreadId);e&&i.push(a.Decoration.inline(e.from,e.to,{class:`bn-thread-mark-selected`}))}return{decorations:a.DecorationSet.create(e.doc,i)}}},props:{decorations(e){return s.getState(e)?.decorations??a.DecorationSet.empty},handleClick:(e,t,n)=>{if(n.button!==0)return!1;let r=e.state.doc.nodeAt(t);if(!r)return m.setState(e=>({...e,selectedThreadId:void 0})),!1;let i=r.marks.find(e=>e.type.name===p&&e.attrs.orphan!==!0);if(!i)return m.state.selectedThreadId!==void 0&&m.setState(e=>({...e,selectedThreadId:void 0})),!1;let a=i.attrs.threadId;return a!==m.state.selectedThreadId&&(m.setState(e=>({...e,selectedThreadId:a})),!0)}}})],threadStore:l,mount(){let e=l.subscribe(h);h(l.getThreads());let t=n.onSelectionChange(()=>{m.state.pendingComment&&m.setState(e=>({...e,pendingComment:!1}))});return()=>{e(),t()}},selectThread(e,t=!0){if(m.state.selectedThreadId!==e&&(m.setState(t=>({...t,pendingComment:!1,selectedThreadId:e})),e&&t)){let t=m.state.threadPositions.get(e);if(!t)return;(n.prosemirrorView?.domAtPos(t.from).node)?.scrollIntoView({behavior:`smooth`,block:`center`})}},startPendingComment(){m.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!0})),n.domElement?.focus(),n.getExtension(t.r)?.showSelection(!0,`comments`)},stopPendingComment(){m.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!1})),n.getExtension(t.r)?.showSelection(!1,`comments`)},async createThread(e){let t=await l.createThread(e);l.addThreadToDocument?await l.addThreadToDocument({threadId:t.id,selection:n.transact(e=>e.selection),editor:n}):n._tiptapEditor.commands.setMark(p,{orphan:!1,threadId:t.id})},commentEditorSchema:r,confirmBeforeDiscard:d}}),u=class{},d=class extends u{userId;role;constructor(e,t){super(),this.userId=e,this.role=t}canCreateThread(){return!0}canAddComment(e){return!0}canUpdateComment(e){return e.userId===this.userId}canDeleteComment(e){return e.userId===this.userId||this.role===`editor`}canDeleteThread(e){return this.role===`editor`}canResolveThread(e){return!0}canUnresolveThread(e){return!0}canAddReaction(e,t){return!t||!e.reactions.some(e=>e.emoji===t&&e.userIds.includes(this.userId))}canDeleteReaction(e,t){return!t||e.reactions.some(e=>e.emoji===t&&e.userIds.includes(this.userId))}},f=class extends n.t{userId;provider;constructor(e,t,n){super(n),this.userId=e,this.provider=t}async createThread(e){let t=this.provider.createThread({data:e.metadata});return t=this.provider.addComment(t.id,{content:e.initialComment.body,data:{metadata:e.initialComment.metadata,userId:this.userId}}),this.tiptapThreadToThreadData(t)}addThreadToDocument=void 0;async addComment(e){let t=this.provider.addComment(e.threadId,{content:e.comment.body,data:{metadata:e.comment.metadata,userId:this.userId}});return this.tiptapCommentToCommentData(t.comments[t.comments.length-1])}async updateComment(e){let t=this.provider.getThreadComment(e.threadId,e.commentId,!0);if(!t)throw Error(`Comment not found`);this.provider.updateComment(e.threadId,e.commentId,{content:e.comment.body,data:{...t.data,metadata:e.comment.metadata}})}tiptapCommentToCommentData(e){let t=[];for(let n of e.data?.reactions||[]){let e=t.find(e=>e.emoji===n.emoji);e?(e.userIds.push(n.userId),e.createdAt=new Date(Math.min(e.createdAt.getTime(),n.createdAt))):t.push({emoji:n.emoji,createdAt:new Date(n.createdAt),userIds:[n.userId]})}return{type:`comment`,id:e.id,body:e.content,metadata:e.data?.metadata,userId:e.data?.userId,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),reactions:t}}tiptapThreadToThreadData(e){return{type:`thread`,id:e.id,comments:e.comments.map(e=>this.tiptapCommentToCommentData(e)),resolved:!!e.resolvedAt,metadata:e.data?.metadata,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt)}}async deleteComment(e){this.provider.deleteComment(e.threadId,e.commentId)}async deleteThread(e){this.provider.deleteThread(e.threadId)}async resolveThread(e){this.provider.updateThread(e.threadId,{resolvedAt:new Date().toISOString()})}async unresolveThread(e){this.provider.updateThread(e.threadId,{resolvedAt:null})}async addReaction(e){let t=this.provider.getThreadComment(e.threadId,e.commentId,!0);if(!t)throw Error(`Comment not found`);this.provider.updateComment(e.threadId,e.commentId,{data:{...t.data,reactions:[...t.data?.reactions||[],{emoji:e.emoji,createdAt:Date.now(),userId:this.userId}]}})}async deleteReaction(e){let t=this.provider.getThreadComment(e.threadId,e.commentId,!0);if(!t)throw Error(`Comment not found`);this.provider.updateComment(e.threadId,e.commentId,{data:{...t.data,reactions:(t.data?.reactions||[]).filter(t=>t.emoji!==e.emoji&&t.userId!==this.userId)}})}getThread(e){let t=this.provider.getThread(e);if(!t)throw Error(`Thread not found`);return this.tiptapThreadToThreadData(t)}getThreads(){return new Map(this.provider.getThreads().map(e=>[e.id,this.tiptapThreadToThreadData(e)]))}subscribe(e){let t=()=>{e(this.getThreads())};return this.provider.watchThreads(t),()=>{this.provider.unwatchThreads(t)}}};exports.CommentMark=o,exports.CommentsExtension=l,exports.DefaultThreadStoreAuth=d,exports.ThreadStore=n.t,exports.ThreadStoreAuth=u,exports.TiptapThreadStore=f;
2
2
  //# sourceMappingURL=comments.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"comments.cjs","names":[],"sources":["../src/comments/mark.ts","../src/comments/extension.ts","../src/comments/threadstore/ThreadStoreAuth.ts","../src/comments/threadstore/DefaultThreadStoreAuth.ts","../src/comments/threadstore/TipTapThreadStore.ts"],"sourcesContent":["import { Mark, mergeAttributes } from \"@tiptap/core\";\n\nimport { NON_FORMATTING_MARK_GROUP } from \"../schema/markGroups.js\";\n\nexport const CommentMark = Mark.create({\n name: \"comment\",\n excludes: \"\",\n inclusive: false,\n keepOnSplit: true,\n // Allowed on \"plain\" blocks (e.g. code blocks) via this group.\n group: NON_FORMATTING_MARK_GROUP,\n\n addAttributes() {\n // Return an object with attribute configuration\n return {\n // orphans are marks that currently don't have an active thread. It could be\n // that users have resolved the thread. Resolved threads by default are not shown in the document,\n // but we need to keep the mark (positioning) data so we can still \"revive\" it when the thread is unresolved\n // or we enter a \"comments\" view that includes resolved threads.\n orphan: {\n parseHTML: (element) => !!element.getAttribute(\"data-orphan\"),\n renderHTML: (attributes) => {\n return (attributes as { orphan: boolean }).orphan\n ? {\n \"data-orphan\": \"true\",\n }\n : {};\n },\n default: false,\n },\n threadId: {\n parseHTML: (element) => element.getAttribute(\"data-bn-thread-id\"),\n renderHTML: (attributes) => {\n return {\n \"data-bn-thread-id\": (attributes as { threadId: string }).threadId,\n };\n },\n default: \"\",\n },\n };\n },\n\n renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, any> }) {\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n class: \"bn-thread-mark\",\n }),\n ];\n },\n\n parseHTML() {\n return [{ tag: \"span.bn-thread-mark\" }];\n },\n\n extendMarkSchema(extension) {\n if (extension.name === \"comment\") {\n return {\n blocknoteIgnore: true,\n };\n }\n return {};\n },\n});\n","import { Node } from \"prosemirror-model\";\nimport { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n ExtensionOptions,\n} from \"../editor/BlockNoteExtension.js\";\nimport { ShowSelectionExtension } from \"../extensions/ShowSelection/ShowSelection.js\";\nimport { normalizeToUserStore, UserStoreOrResolver } from \"../user/index.js\";\nimport { CustomBlockNoteSchema } from \"../schema/schema.js\";\nimport { CommentMark } from \"./mark.js\";\nimport type { ThreadStore } from \"./threadstore/ThreadStore.js\";\nimport type { CommentBody, ThreadData } from \"./types.js\";\n\nconst PLUGIN_KEY = new PluginKey(\"blocknote-comments\");\n\ntype CommentsPluginState = {\n /**\n * Decorations to be rendered, specifically to indicate the selected thread\n */\n decorations: DecorationSet;\n};\n\n/**\n * Calculate the thread positions from the current document state\n */\nfunction getUpdatedThreadPositions(doc: Node, markType: string) {\n const threadPositions = new Map<string, { from: number; to: number }>();\n\n // find all thread marks and store their position + create decoration for selected thread\n doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const thisThreadId = (mark.attrs as { threadId: string | undefined })\n .threadId;\n if (!thisThreadId) {\n return;\n }\n const from = pos;\n const to = from + node.nodeSize;\n\n // FloatingThreads component uses \"to\" as the position, so always store the largest \"to\" found\n // AnchoredThreads component uses \"from\" as the position, so always store the smallest \"from\" found\n const currentPosition = threadPositions.get(thisThreadId) ?? {\n from: Infinity,\n to: 0,\n };\n threadPositions.set(thisThreadId, {\n from: Math.min(from, currentPosition.from),\n to: Math.max(to, currentPosition.to),\n });\n }\n });\n });\n return threadPositions;\n}\n\nexport const CommentsExtension = createExtension(\n ({\n editor,\n options: {\n schema: commentEditorSchema,\n threadStore,\n resolveUsers,\n confirmBeforeDiscard = true,\n },\n }: ExtensionOptions<{\n /**\n * The thread store implementation to use for storing and retrieving comment threads\n */\n threadStore: ThreadStore;\n /**\n * Resolve user information (names, avatars) for comment authors.\n *\n * Either a resolver function (called with the ids of users that are not yet\n * cached, returning their information) or a pre-built user store (see\n * `createUserStore`). Pass the same store to the collaboration options so a\n * single de-duped user cache is shared across comments and collaboration.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\n resolveUsers: UserStoreOrResolver;\n /**\n * A schema to use for the comment editor (which allows you to customize the blocks and styles that are available in the comment editor)\n */\n schema?: CustomBlockNoteSchema<any, any, any>;\n /**\n * Whether to ask the user for confirmation before discarding unsaved text\n * in a comment composer (a new comment, a reply, or an in-progress edit)\n * when it's dismissed (e.g. by clicking outside or pressing Escape).\n *\n * @default true\n */\n confirmBeforeDiscard?: boolean;\n }>) => {\n if (!resolveUsers) {\n throw new Error(\n \"resolveUsers is required to be defined when using comments\",\n );\n }\n if (!threadStore) {\n throw new Error(\n \"threadStore is required to be defined when using comments\",\n );\n }\n // Resolve users through this store, exposed on the extension instance so the\n // comments UI can read from it directly. Accepts a resolver callback or a\n // shared store (see the option docs above).\n const userStore = normalizeToUserStore(resolveUsers);\n const markType = CommentMark.name;\n\n const store = createStore(\n {\n pendingComment: false,\n selectedThreadId: undefined as string | undefined,\n threadPositions: new Map<string, { from: number; to: number }>(),\n },\n {\n onUpdate() {\n // If the selected thread id changed, we need to update the decorations\n if (\n store.state.selectedThreadId !== store.prevState.selectedThreadId\n ) {\n // So, we issue a transaction to update the decorations\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, true));\n }\n },\n },\n );\n\n const updateMarksFromThreads = (threads: Map<string, ThreadData>) => {\n editor.transact((tr) => {\n tr.doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const markTypeInstance = mark.type;\n const markThreadId = mark.attrs.threadId as string;\n const thread = threads.get(markThreadId);\n const isOrphan = !!(\n !thread ||\n thread.resolved ||\n thread.deletedAt\n );\n\n if (isOrphan !== mark.attrs.orphan) {\n const trimmedFrom = Math.max(pos, 0);\n const trimmedTo = Math.min(\n pos + node.nodeSize,\n tr.doc.content.size - 1,\n tr.doc.content.size - 1,\n );\n tr.removeMark(trimmedFrom, trimmedTo, mark);\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n markTypeInstance.create({\n ...mark.attrs,\n orphan: isOrphan,\n }),\n );\n\n if (isOrphan && store.state.selectedThreadId === markThreadId) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n }\n }\n });\n });\n });\n };\n\n return {\n key: \"comments\",\n store,\n userStore,\n runsBefore: [\"link\"],\n tiptapExtensions: [CommentMark],\n prosemirrorPlugins: [\n new Plugin<CommentsPluginState>({\n key: PLUGIN_KEY,\n state: {\n init() {\n return {\n decorations: DecorationSet.empty,\n };\n },\n apply(tr, state) {\n const action = tr.getMeta(PLUGIN_KEY);\n\n if (!tr.docChanged && !action) {\n return state;\n }\n\n // only update threadPositions if the doc changed\n const newThreadPositions = tr.docChanged\n ? getUpdatedThreadPositions(tr.doc, markType)\n : store.state.threadPositions;\n\n if (\n newThreadPositions.size > 0 ||\n store.state.threadPositions.size > 0\n ) {\n // small optimization; don't emit event if threadPositions before / after were both empty\n store.setState((prev) => ({\n ...prev,\n threadPositions: newThreadPositions,\n }));\n }\n\n // update decorations if doc or selected thread changed\n const decorations = [] as any[];\n\n if (store.state.selectedThreadId) {\n const selectedThreadPosition = newThreadPositions.get(\n store.state.selectedThreadId,\n );\n\n if (selectedThreadPosition) {\n decorations.push(\n Decoration.inline(\n selectedThreadPosition.from,\n selectedThreadPosition.to,\n {\n class: \"bn-thread-mark-selected\",\n },\n ),\n );\n }\n }\n\n return {\n decorations: DecorationSet.create(tr.doc, decorations),\n };\n },\n },\n props: {\n decorations(state) {\n return (\n PLUGIN_KEY.getState(state)?.decorations ?? DecorationSet.empty\n );\n },\n handleClick: (view, pos, event) => {\n if (event.button !== 0) {\n return false;\n }\n\n const node = view.state.doc.nodeAt(pos);\n\n if (!node) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n return false;\n }\n\n const commentMark = node.marks.find(\n (mark) =>\n mark.type.name === markType && mark.attrs.orphan !== true,\n );\n\n if (!commentMark) {\n // Clicked outside any comment thread. Deselect if needed but\n // don't consume the event so other handlers (e.g. link\n // navigation) can process it.\n if (store.state.selectedThreadId !== undefined) {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n return false;\n }\n\n const threadId = commentMark.attrs.threadId as string;\n\n // If the clicked thread is already selected, do nothing and let\n // other handlers process the event (e.g. navigating a link).\n if (threadId === store.state.selectedThreadId) {\n return false;\n }\n\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: threadId,\n }));\n\n return true;\n },\n },\n }),\n ],\n threadStore: threadStore,\n mount() {\n const unsubscribe = threadStore.subscribe(updateMarksFromThreads);\n updateMarksFromThreads(threadStore.getThreads());\n\n const unsubscribeOnSelectionChange = editor.onSelectionChange(() => {\n if (store.state.pendingComment) {\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n }));\n }\n });\n\n return () => {\n unsubscribe();\n unsubscribeOnSelectionChange();\n };\n },\n selectThread(threadId: string | undefined, scrollToThread = true) {\n if (store.state.selectedThreadId === threadId) {\n return;\n }\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n selectedThreadId: threadId,\n }));\n\n if (threadId && scrollToThread) {\n const selectedThreadPosition =\n store.state.threadPositions.get(threadId);\n if (!selectedThreadPosition) {\n return;\n }\n (\n editor.prosemirrorView?.domAtPos(selectedThreadPosition.from)\n .node as Element | undefined\n )?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n });\n }\n },\n startPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: true,\n }));\n // Use `editor.domElement` as `editor.focus()` doesn't do anything if\n // the editor is non-editable. Editor needs to be focused as\n // `showSelection` will otherwise trigger a selection update which\n // triggers `stopPendingComment`.\n editor.domElement?.focus();\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(true, \"comments\");\n },\n stopPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: false,\n }));\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(false, \"comments\");\n },\n async createThread(options: {\n initialComment: { body: CommentBody; metadata?: any };\n metadata?: any;\n }) {\n const thread = await threadStore.createThread(options);\n if (threadStore.addThreadToDocument) {\n await threadStore.addThreadToDocument({\n threadId: thread.id,\n selection: editor.transact((tr) => tr.selection),\n editor,\n });\n } else {\n (editor as any)._tiptapEditor.commands.setMark(markType, {\n orphan: false,\n threadId: thread.id,\n });\n }\n },\n commentEditorSchema,\n confirmBeforeDiscard,\n } as const;\n },\n);\n","import { CommentData, ThreadData } from \"../types.js\";\n\nexport abstract class ThreadStoreAuth {\n abstract canCreateThread(): boolean;\n abstract canAddComment(thread: ThreadData): boolean;\n abstract canUpdateComment(comment: CommentData): boolean;\n abstract canDeleteComment(comment: CommentData): boolean;\n abstract canDeleteThread(thread: ThreadData): boolean;\n abstract canResolveThread(thread: ThreadData): boolean;\n abstract canUnresolveThread(thread: ThreadData): boolean;\n abstract canAddReaction(comment: CommentData, emoji?: string): boolean;\n abstract canDeleteReaction(comment: CommentData, emoji?: string): boolean;\n}\n","import { CommentData, ThreadData } from \"../types.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\n\n/*\n * The DefaultThreadStoreAuth class defines the authorization rules for interacting with comments.\n * We take a role (\"comment\" or \"editor\") and implement the rules.\n *\n * This class is then used in the UI to show / hide specific interactions.\n *\n * Rules:\n * - View-only users should not be able to see any comments\n * - Comment-only users and editors can:\n * - - create new comments / replies / reactions\n * - - edit / delete their own comments / reactions\n * - - resolve / unresolve threads\n * - Editors can also delete any comment or thread\n */\nexport class DefaultThreadStoreAuth extends ThreadStoreAuth {\n constructor(\n private readonly userId: string,\n private readonly role: \"comment\" | \"editor\",\n ) {\n super();\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canCreateThread(): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canAddComment(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should only be possible by the comment author\n */\n canUpdateComment(comment: CommentData): boolean {\n return comment.userId === this.userId;\n }\n\n /**\n * Auth: should be possible by the comment author OR an editor of the document\n */\n canDeleteComment(comment: CommentData): boolean {\n return comment.userId === this.userId || this.role === \"editor\";\n }\n\n /**\n * Auth: should only be possible by an editor of the document\n */\n canDeleteThread(_thread: ThreadData): boolean {\n return this.role === \"editor\";\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canResolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canUnresolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canAddReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return !comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canDeleteReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n}\n","import {\n CommentBody,\n CommentData,\n CommentReactionData,\n ThreadData,\n} from \"../types.js\";\nimport { ThreadStore } from \"./ThreadStore.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\nimport type {\n TCollabComment,\n TCollabThread,\n TiptapCollabProvider,\n} from \"./tiptap/types.js\";\n\ntype ReactionAsTiptapData = {\n emoji: string;\n createdAt: number;\n userId: string;\n};\n\n/**\n * The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.\n * You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.\n *\n * Under the hood, this actually works similarly to the `YjsThreadStore` implementation. (comments are stored in the Yjs document)\n */\nexport class TiptapThreadStore extends ThreadStore {\n constructor(\n private readonly userId: string,\n private readonly provider: TiptapCollabProvider,\n auth: ThreadStoreAuth, // TODO: use?\n ) {\n super(auth);\n }\n\n /**\n * Creates a new thread with an initial comment.\n */\n public async createThread(options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }): Promise<ThreadData> {\n let thread = this.provider.createThread({\n data: options.metadata,\n });\n\n thread = this.provider.addComment(thread.id, {\n content: options.initialComment.body,\n data: {\n metadata: options.initialComment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n // TipTapThreadStore does not support addThreadToDocument\n public addThreadToDocument = undefined;\n\n /**\n * Adds a comment to a thread.\n */\n public async addComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }): Promise<CommentBody> {\n const thread = this.provider.addComment(options.threadId, {\n content: options.comment.body,\n data: {\n metadata: options.comment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapCommentToCommentData(\n thread.comments[thread.comments.length - 1],\n );\n }\n\n /**\n * Updates a comment in a thread.\n */\n public async updateComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n content: options.comment.body,\n data: {\n ...comment.data,\n metadata: options.comment.metadata,\n },\n });\n }\n\n private tiptapCommentToCommentData(comment: TCollabComment): CommentData {\n const reactions: CommentReactionData[] = [];\n\n for (const reaction of (comment.data?.reactions ||\n []) as ReactionAsTiptapData[]) {\n const existingReaction = reactions.find(\n (r) => r.emoji === reaction.emoji,\n );\n if (existingReaction) {\n existingReaction.userIds.push(reaction.userId);\n existingReaction.createdAt = new Date(\n Math.min(existingReaction.createdAt.getTime(), reaction.createdAt),\n );\n } else {\n reactions.push({\n emoji: reaction.emoji,\n createdAt: new Date(reaction.createdAt),\n userIds: [reaction.userId],\n });\n }\n }\n\n return {\n type: \"comment\",\n id: comment.id,\n body: comment.content,\n metadata: comment.data?.metadata,\n userId: comment.data?.userId,\n createdAt: new Date(comment.createdAt),\n updatedAt: new Date(comment.updatedAt),\n reactions,\n };\n }\n\n private tiptapThreadToThreadData(thread: TCollabThread): ThreadData {\n return {\n type: \"thread\",\n id: thread.id,\n comments: thread.comments.map((comment) =>\n this.tiptapCommentToCommentData(comment),\n ),\n resolved: !!thread.resolvedAt,\n metadata: thread.data?.metadata,\n createdAt: new Date(thread.createdAt),\n updatedAt: new Date(thread.updatedAt),\n };\n }\n\n /**\n * Deletes a comment from a thread.\n */\n public async deleteComment(options: { threadId: string; commentId: string }) {\n this.provider.deleteComment(options.threadId, options.commentId);\n }\n\n /**\n * Deletes a thread.\n */\n public async deleteThread(options: { threadId: string }) {\n this.provider.deleteThread(options.threadId);\n }\n\n /**\n * Marks a thread as resolved.\n */\n public async resolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: new Date().toISOString(),\n });\n }\n\n /**\n * Marks a thread as unresolved.\n */\n public async unresolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: null,\n });\n }\n\n /**\n * Adds a reaction to a comment.\n *\n * Auth: should be possible by anyone with comment access\n */\n public async addReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: [\n ...((comment.data?.reactions || []) as ReactionAsTiptapData[]),\n {\n emoji: options.emoji,\n createdAt: Date.now(),\n userId: this.userId,\n },\n ],\n },\n });\n }\n\n /**\n * Deletes a reaction from a comment.\n *\n * Auth: should be possible by the reaction author\n */\n public async deleteReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: (\n (comment.data?.reactions || []) as ReactionAsTiptapData[]\n ).filter(\n (reaction) =>\n reaction.emoji !== options.emoji && reaction.userId !== this.userId,\n ),\n },\n });\n }\n\n public getThread(threadId: string): ThreadData {\n const thread = this.provider.getThread(threadId);\n\n if (!thread) {\n throw new Error(\"Thread not found\");\n }\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n public getThreads(): Map<string, ThreadData> {\n return new Map(\n this.provider\n .getThreads()\n .map((thread) => [thread.id, this.tiptapThreadToThreadData(thread)]),\n );\n }\n\n public subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void {\n const newCb = () => {\n cb(this.getThreads());\n };\n this.provider.watchThreads(newCb);\n return () => {\n this.provider.unwatchThreads(newCb);\n };\n }\n}\n"],"mappings":"iSAIA,IAAa,EAAc,EAAA,KAAK,OAAO,CACrC,KAAM,UACN,SAAU,GACV,UAAW,GACX,YAAa,GAEb,MAAO,EAAA,EAEP,eAAgB,CAEd,MAAO,CAKL,OAAQ,CACN,UAAY,GAAY,CAAC,CAAC,EAAQ,aAAa,aAAa,EAC5D,WAAa,GACH,EAAmC,OACvC,CACE,cAAe,MACjB,EACA,CAAC,EAEP,QAAS,EACX,EACA,SAAU,CACR,UAAY,GAAY,EAAQ,aAAa,mBAAmB,EAChE,WAAa,IACJ,CACL,oBAAsB,EAAoC,QAC5D,GAEF,QAAS,EACX,CACF,CACF,EAEA,WAAW,CAAE,kBAA2D,CACtE,MAAO,CACL,QAAA,EAAA,EAAA,iBACgB,EAAgB,CAC9B,MAAO,gBACT,CAAC,CACH,CACF,EAEA,WAAY,CACV,MAAO,CAAC,CAAE,IAAK,qBAAsB,CAAC,CACxC,EAEA,iBAAiB,EAAW,CAM1B,OALI,EAAU,OAAS,UACd,CACL,gBAAiB,EACnB,EAEK,CAAC,CACV,CACF,CAAC,EChDK,EAAa,IAAI,EAAA,UAAU,oBAAoB,EAYrD,SAAS,EAA0B,EAAW,EAAkB,CAC9D,IAAM,EAAkB,IAAI,IA2B5B,OAxBA,EAAI,aAAa,EAAM,IAAQ,CAC7B,EAAK,MAAM,QAAS,GAAS,CAC3B,GAAI,EAAK,KAAK,OAAS,EAAU,CAC/B,IAAM,EAAgB,EAAK,MACxB,SACH,GAAI,CAAC,EACH,OAEF,IAAM,EAAO,EACP,EAAK,EAAO,EAAK,SAIjB,EAAkB,EAAgB,IAAI,CAAY,GAAK,CAC3D,KAAM,IACN,GAAI,CACN,EACA,EAAgB,IAAI,EAAc,CAChC,KAAM,KAAK,IAAI,EAAM,EAAgB,IAAI,EACzC,GAAI,KAAK,IAAI,EAAI,EAA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SAAS,cAAc,EAAQ,SAAU,EAAQ,UAAW,CAC/D,KAAM,CACJ,GAAG,EAAQ,KACX,WACG,EAAQ,MAAM,WAAa,CAAC,GAC7B,OACC,GACC,EAAS,QAAU,EAAQ,OAAS,EAAS,SAAW,KAAK,MACjE,CACF,CACF,CAAC,CACH,CAEA,UAAiB,EAA8B,CAC7C,IAAM,EAAS,KAAK,SAAS,UAAU,CAAQ,EAE/C,GAAI,CAAC,EACH,MAAU,MAAM,kBAAkB,EAGpC,OAAO,KAAK,yBAAyB,CAAM,CAC7C,CAEA,YAA6C,CAC3C,OAAO,IAAI,IACT,KAAK,SACF,WAAW,EACX,IAAK,GAAW,CAAC,EAAO,GAAI,KAAK,yBAAyB,CAAM,CAAC,CAAC,CACvE,CACF,CAEA,UAAiB,EAA4D,CAC3E,IAAM,MAAc,CAClB,EAAG,KAAK,WAAW,CAAC,CACtB,EAEA,OADA,KAAK,SAAS,aAAa,CAAK,MACnB,CACX,KAAK,SAAS,eAAe,CAAK,CACpC,CACF,CACF"}
1
+ {"version":3,"file":"comments.cjs","names":[],"sources":["../src/comments/mark.ts","../src/comments/extension.ts","../src/comments/threadstore/ThreadStoreAuth.ts","../src/comments/threadstore/DefaultThreadStoreAuth.ts","../src/comments/threadstore/TipTapThreadStore.ts"],"sourcesContent":["import { Mark, mergeAttributes } from \"@tiptap/core\";\n\nimport { NON_FORMATTING_MARK_GROUP } from \"../schema/markGroups.js\";\n\nexport const CommentMark = Mark.create({\n name: \"comment\",\n excludes: \"\",\n inclusive: false,\n keepOnSplit: true,\n // Allowed on \"plain\" blocks (e.g. code blocks) via this group.\n group: NON_FORMATTING_MARK_GROUP,\n\n addAttributes() {\n // Return an object with attribute configuration\n return {\n // orphans are marks that currently don't have an active thread. It could be\n // that users have resolved the thread. Resolved threads by default are not shown in the document,\n // but we need to keep the mark (positioning) data so we can still \"revive\" it when the thread is unresolved\n // or we enter a \"comments\" view that includes resolved threads.\n orphan: {\n parseHTML: (element) => !!element.getAttribute(\"data-orphan\"),\n renderHTML: (attributes) => {\n return (attributes as { orphan: boolean }).orphan\n ? {\n \"data-orphan\": \"true\",\n }\n : {};\n },\n default: false,\n },\n threadId: {\n parseHTML: (element) => element.getAttribute(\"data-bn-thread-id\"),\n renderHTML: (attributes) => {\n return {\n \"data-bn-thread-id\": (attributes as { threadId: string }).threadId,\n };\n },\n default: \"\",\n },\n };\n },\n\n renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, any> }) {\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n class: \"bn-thread-mark\",\n }),\n ];\n },\n\n parseHTML() {\n return [{ tag: \"span.bn-thread-mark\" }];\n },\n\n extendMarkSchema(extension) {\n if (extension.name === \"comment\") {\n return {\n blocknoteIgnore: true,\n };\n }\n return {};\n },\n});\n","import { Node } from \"prosemirror-model\";\nimport { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n ExtensionOptions,\n} from \"../editor/BlockNoteExtension.js\";\nimport { ShowSelectionExtension } from \"../extensions/ShowSelection/ShowSelection.js\";\nimport { normalizeToUserStore, UserStoreOrResolver } from \"../user/index.js\";\nimport { CustomBlockNoteSchema } from \"../schema/schema.js\";\nimport { CommentMark } from \"./mark.js\";\nimport type { ThreadStore } from \"./threadstore/ThreadStore.js\";\nimport type { CommentBody, ThreadData } from \"./types.js\";\n\nconst PLUGIN_KEY = new PluginKey(\"blocknote-comments\");\n\ntype CommentsPluginState = {\n /**\n * Decorations to be rendered, specifically to indicate the selected thread\n */\n decorations: DecorationSet;\n};\n\n/**\n * Calculate the thread positions from the current document state\n */\nfunction getUpdatedThreadPositions(doc: Node, markType: string) {\n const threadPositions = new Map<string, { from: number; to: number }>();\n\n // find all thread marks and store their position + create decoration for selected thread\n doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const thisThreadId = (mark.attrs as { threadId: string | undefined })\n .threadId;\n if (!thisThreadId) {\n return;\n }\n const from = pos;\n const to = from + node.nodeSize;\n\n // FloatingThreads component uses \"to\" as the position, so always store the largest \"to\" found\n // AnchoredThreads component uses \"from\" as the position, so always store the smallest \"from\" found\n const currentPosition = threadPositions.get(thisThreadId) ?? {\n from: Infinity,\n to: 0,\n };\n threadPositions.set(thisThreadId, {\n from: Math.min(from, currentPosition.from),\n to: Math.max(to, currentPosition.to),\n });\n }\n });\n });\n return threadPositions;\n}\n\nexport const CommentsExtension = createExtension(\n ({\n editor,\n options: {\n schema: commentEditorSchema,\n threadStore,\n resolveUsers,\n confirmBeforeDiscard = true,\n },\n }: ExtensionOptions<{\n /**\n * The thread store implementation to use for storing and retrieving comment threads\n */\n threadStore: ThreadStore;\n /**\n * Resolve user information (names, avatars) for comment authors.\n *\n * Either a resolver function (called with the ids of users that are not yet\n * cached, returning their information) or a pre-built user store (see\n * `createUserStore`). Pass the same store to the collaboration options so a\n * single de-duped user cache is shared across comments and collaboration.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\n resolveUsers: UserStoreOrResolver;\n /**\n * A schema to use for the comment editor (which allows you to customize the blocks and styles that are available in the comment editor)\n */\n schema?: CustomBlockNoteSchema<any, any, any>;\n /**\n * Whether to ask the user for confirmation before discarding unsaved text\n * in a comment composer (a new comment, a reply, or an in-progress edit)\n * when it's dismissed (e.g. by clicking outside or pressing Escape).\n *\n * @default true\n */\n confirmBeforeDiscard?: boolean;\n }>) => {\n if (!resolveUsers) {\n throw new Error(\n \"resolveUsers is required to be defined when using comments\",\n );\n }\n if (!threadStore) {\n throw new Error(\n \"threadStore is required to be defined when using comments\",\n );\n }\n // Resolve users through this store, exposed on the extension instance so the\n // comments UI can read from it directly. Accepts a resolver callback or a\n // shared store (see the option docs above).\n const userStore = normalizeToUserStore(resolveUsers);\n const markType = CommentMark.name;\n\n const store = createStore(\n {\n pendingComment: false,\n selectedThreadId: undefined as string | undefined,\n threadPositions: new Map<string, { from: number; to: number }>(),\n },\n {\n onUpdate(state, prevState) {\n // If the selected thread id changed, we need to update the decorations\n if (state.selectedThreadId !== prevState.selectedThreadId) {\n // So, we issue a transaction to update the decorations\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, true));\n }\n },\n },\n );\n\n const updateMarksFromThreads = (threads: Map<string, ThreadData>) => {\n editor.transact((tr) => {\n tr.doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const markTypeInstance = mark.type;\n const markThreadId = mark.attrs.threadId as string;\n const thread = threads.get(markThreadId);\n const isOrphan = !!(\n !thread ||\n thread.resolved ||\n thread.deletedAt\n );\n\n if (isOrphan !== mark.attrs.orphan) {\n const trimmedFrom = Math.max(pos, 0);\n const trimmedTo = Math.min(\n pos + node.nodeSize,\n tr.doc.content.size - 1,\n tr.doc.content.size - 1,\n );\n tr.removeMark(trimmedFrom, trimmedTo, mark);\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n markTypeInstance.create({\n ...mark.attrs,\n orphan: isOrphan,\n }),\n );\n\n if (isOrphan && store.state.selectedThreadId === markThreadId) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n }\n }\n });\n });\n });\n };\n\n return {\n key: \"comments\",\n store,\n userStore,\n runsBefore: [\"link\"],\n tiptapExtensions: [CommentMark],\n prosemirrorPlugins: [\n new Plugin<CommentsPluginState>({\n key: PLUGIN_KEY,\n state: {\n init() {\n return {\n decorations: DecorationSet.empty,\n };\n },\n apply(tr, state) {\n const action = tr.getMeta(PLUGIN_KEY);\n\n if (!tr.docChanged && !action) {\n return state;\n }\n\n // only update threadPositions if the doc changed\n const newThreadPositions = tr.docChanged\n ? getUpdatedThreadPositions(tr.doc, markType)\n : store.state.threadPositions;\n\n if (\n newThreadPositions.size > 0 ||\n store.state.threadPositions.size > 0\n ) {\n // small optimization; don't emit event if threadPositions before / after were both empty\n store.setState((prev) => ({\n ...prev,\n threadPositions: newThreadPositions,\n }));\n }\n\n // update decorations if doc or selected thread changed\n const decorations = [] as any[];\n\n if (store.state.selectedThreadId) {\n const selectedThreadPosition = newThreadPositions.get(\n store.state.selectedThreadId,\n );\n\n if (selectedThreadPosition) {\n decorations.push(\n Decoration.inline(\n selectedThreadPosition.from,\n selectedThreadPosition.to,\n {\n class: \"bn-thread-mark-selected\",\n },\n ),\n );\n }\n }\n\n return {\n decorations: DecorationSet.create(tr.doc, decorations),\n };\n },\n },\n props: {\n decorations(state) {\n return (\n PLUGIN_KEY.getState(state)?.decorations ?? DecorationSet.empty\n );\n },\n handleClick: (view, pos, event) => {\n if (event.button !== 0) {\n return false;\n }\n\n const node = view.state.doc.nodeAt(pos);\n\n if (!node) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n return false;\n }\n\n const commentMark = node.marks.find(\n (mark) =>\n mark.type.name === markType && mark.attrs.orphan !== true,\n );\n\n if (!commentMark) {\n // Clicked outside any comment thread. Deselect if needed but\n // don't consume the event so other handlers (e.g. link\n // navigation) can process it.\n if (store.state.selectedThreadId !== undefined) {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n return false;\n }\n\n const threadId = commentMark.attrs.threadId as string;\n\n // If the clicked thread is already selected, do nothing and let\n // other handlers process the event (e.g. navigating a link).\n if (threadId === store.state.selectedThreadId) {\n return false;\n }\n\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: threadId,\n }));\n\n return true;\n },\n },\n }),\n ],\n threadStore: threadStore,\n mount() {\n const unsubscribe = threadStore.subscribe(updateMarksFromThreads);\n updateMarksFromThreads(threadStore.getThreads());\n\n const unsubscribeOnSelectionChange = editor.onSelectionChange(() => {\n if (store.state.pendingComment) {\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n }));\n }\n });\n\n return () => {\n unsubscribe();\n unsubscribeOnSelectionChange();\n };\n },\n selectThread(threadId: string | undefined, scrollToThread = true) {\n if (store.state.selectedThreadId === threadId) {\n return;\n }\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n selectedThreadId: threadId,\n }));\n\n if (threadId && scrollToThread) {\n const selectedThreadPosition =\n store.state.threadPositions.get(threadId);\n if (!selectedThreadPosition) {\n return;\n }\n (\n editor.prosemirrorView?.domAtPos(selectedThreadPosition.from)\n .node as Element | undefined\n )?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n });\n }\n },\n startPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: true,\n }));\n // Use `editor.domElement` as `editor.focus()` doesn't do anything if\n // the editor is non-editable. Editor needs to be focused as\n // `showSelection` will otherwise trigger a selection update which\n // triggers `stopPendingComment`.\n editor.domElement?.focus();\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(true, \"comments\");\n },\n stopPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: false,\n }));\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(false, \"comments\");\n },\n async createThread(options: {\n initialComment: { body: CommentBody; metadata?: any };\n metadata?: any;\n }) {\n const thread = await threadStore.createThread(options);\n if (threadStore.addThreadToDocument) {\n await threadStore.addThreadToDocument({\n threadId: thread.id,\n selection: editor.transact((tr) => tr.selection),\n editor,\n });\n } else {\n (editor as any)._tiptapEditor.commands.setMark(markType, {\n orphan: false,\n threadId: thread.id,\n });\n }\n },\n commentEditorSchema,\n confirmBeforeDiscard,\n } as const;\n },\n);\n","import { CommentData, ThreadData } from \"../types.js\";\n\nexport abstract class ThreadStoreAuth {\n abstract canCreateThread(): boolean;\n abstract canAddComment(thread: ThreadData): boolean;\n abstract canUpdateComment(comment: CommentData): boolean;\n abstract canDeleteComment(comment: CommentData): boolean;\n abstract canDeleteThread(thread: ThreadData): boolean;\n abstract canResolveThread(thread: ThreadData): boolean;\n abstract canUnresolveThread(thread: ThreadData): boolean;\n abstract canAddReaction(comment: CommentData, emoji?: string): boolean;\n abstract canDeleteReaction(comment: CommentData, emoji?: string): boolean;\n}\n","import { CommentData, ThreadData } from \"../types.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\n\n/*\n * The DefaultThreadStoreAuth class defines the authorization rules for interacting with comments.\n * We take a role (\"comment\" or \"editor\") and implement the rules.\n *\n * This class is then used in the UI to show / hide specific interactions.\n *\n * Rules:\n * - View-only users should not be able to see any comments\n * - Comment-only users and editors can:\n * - - create new comments / replies / reactions\n * - - edit / delete their own comments / reactions\n * - - resolve / unresolve threads\n * - Editors can also delete any comment or thread\n */\nexport class DefaultThreadStoreAuth extends ThreadStoreAuth {\n constructor(\n private readonly userId: string,\n private readonly role: \"comment\" | \"editor\",\n ) {\n super();\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canCreateThread(): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canAddComment(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should only be possible by the comment author\n */\n canUpdateComment(comment: CommentData): boolean {\n return comment.userId === this.userId;\n }\n\n /**\n * Auth: should be possible by the comment author OR an editor of the document\n */\n canDeleteComment(comment: CommentData): boolean {\n return comment.userId === this.userId || this.role === \"editor\";\n }\n\n /**\n * Auth: should only be possible by an editor of the document\n */\n canDeleteThread(_thread: ThreadData): boolean {\n return this.role === \"editor\";\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canResolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canUnresolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canAddReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return !comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canDeleteReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n}\n","import {\n CommentBody,\n CommentData,\n CommentReactionData,\n ThreadData,\n} from \"../types.js\";\nimport { ThreadStore } from \"./ThreadStore.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\nimport type {\n TCollabComment,\n TCollabThread,\n TiptapCollabProvider,\n} from \"./tiptap/types.js\";\n\ntype ReactionAsTiptapData = {\n emoji: string;\n createdAt: number;\n userId: string;\n};\n\n/**\n * The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.\n * You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.\n *\n * Under the hood, this actually works similarly to the `YjsThreadStore` implementation. (comments are stored in the Yjs document)\n */\nexport class TiptapThreadStore extends ThreadStore {\n constructor(\n private readonly userId: string,\n private readonly provider: TiptapCollabProvider,\n auth: ThreadStoreAuth, // TODO: use?\n ) {\n super(auth);\n }\n\n /**\n * Creates a new thread with an initial comment.\n */\n public async createThread(options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }): Promise<ThreadData> {\n let thread = this.provider.createThread({\n data: options.metadata,\n });\n\n thread = this.provider.addComment(thread.id, {\n content: options.initialComment.body,\n data: {\n metadata: options.initialComment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n // TipTapThreadStore does not support addThreadToDocument\n public addThreadToDocument = undefined;\n\n /**\n * Adds a comment to a thread.\n */\n public async addComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }): Promise<CommentBody> {\n const thread = this.provider.addComment(options.threadId, {\n content: options.comment.body,\n data: {\n metadata: options.comment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapCommentToCommentData(\n thread.comments[thread.comments.length - 1],\n );\n }\n\n /**\n * Updates a comment in a thread.\n */\n public async updateComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n content: options.comment.body,\n data: {\n ...comment.data,\n metadata: options.comment.metadata,\n },\n });\n }\n\n private tiptapCommentToCommentData(comment: TCollabComment): CommentData {\n const reactions: CommentReactionData[] = [];\n\n for (const reaction of (comment.data?.reactions ||\n []) as ReactionAsTiptapData[]) {\n const existingReaction = reactions.find(\n (r) => r.emoji === reaction.emoji,\n );\n if (existingReaction) {\n existingReaction.userIds.push(reaction.userId);\n existingReaction.createdAt = new Date(\n Math.min(existingReaction.createdAt.getTime(), reaction.createdAt),\n );\n } else {\n reactions.push({\n emoji: reaction.emoji,\n createdAt: new Date(reaction.createdAt),\n userIds: [reaction.userId],\n });\n }\n }\n\n return {\n type: \"comment\",\n id: comment.id,\n body: comment.content,\n metadata: comment.data?.metadata,\n userId: comment.data?.userId,\n createdAt: new Date(comment.createdAt),\n updatedAt: new Date(comment.updatedAt),\n reactions,\n };\n }\n\n private tiptapThreadToThreadData(thread: TCollabThread): ThreadData {\n return {\n type: \"thread\",\n id: thread.id,\n comments: thread.comments.map((comment) =>\n this.tiptapCommentToCommentData(comment),\n ),\n resolved: !!thread.resolvedAt,\n metadata: thread.data?.metadata,\n createdAt: new Date(thread.createdAt),\n updatedAt: new Date(thread.updatedAt),\n };\n }\n\n /**\n * Deletes a comment from a thread.\n */\n public async deleteComment(options: { threadId: string; commentId: string }) {\n this.provider.deleteComment(options.threadId, options.commentId);\n }\n\n /**\n * Deletes a thread.\n */\n public async deleteThread(options: { threadId: string }) {\n this.provider.deleteThread(options.threadId);\n }\n\n /**\n * Marks a thread as resolved.\n */\n public async resolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: new Date().toISOString(),\n });\n }\n\n /**\n * Marks a thread as unresolved.\n */\n public async unresolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: null,\n });\n }\n\n /**\n * Adds a reaction to a comment.\n *\n * Auth: should be possible by anyone with comment access\n */\n public async addReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: [\n ...((comment.data?.reactions || []) as ReactionAsTiptapData[]),\n {\n emoji: options.emoji,\n createdAt: Date.now(),\n userId: this.userId,\n },\n ],\n },\n });\n }\n\n /**\n * Deletes a reaction from a comment.\n *\n * Auth: should be possible by the reaction author\n */\n public async deleteReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: (\n (comment.data?.reactions || []) as ReactionAsTiptapData[]\n ).filter(\n (reaction) =>\n reaction.emoji !== options.emoji && reaction.userId !== this.userId,\n ),\n },\n });\n }\n\n public getThread(threadId: string): ThreadData {\n const thread = this.provider.getThread(threadId);\n\n if (!thread) {\n throw new Error(\"Thread not found\");\n }\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n public getThreads(): Map<string, ThreadData> {\n return new Map(\n this.provider\n .getThreads()\n .map((thread) => [thread.id, this.tiptapThreadToThreadData(thread)]),\n );\n }\n\n public subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void {\n const newCb = () => {\n cb(this.getThreads());\n };\n this.provider.watchThreads(newCb);\n return () => {\n this.provider.unwatchThreads(newCb);\n };\n }\n}\n"],"mappings":"iSAIA,IAAa,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AAQ,MAAM,WAAa,CAAC,EAAA,CAC7B,OACC,GACC,EAAS,QAAU,EAAQ,OAAS,EAAS,SAAW,KAAK,MACjE,CACF,CACF,CAAC,CACH,CAEA,UAAiB,EAA8B,CAC7C,IAAM,EAAS,KAAK,SAAS,UAAU,CAAQ,EAE/C,GAAI,CAAC,EACH,MAAU,MAAM,kBAAkB,EAGpC,OAAO,KAAK,yBAAyB,CAAM,CAC7C,CAEA,YAA6C,CAC3C,OAAO,IAAI,IACT,KAAK,SACF,WAAW,CAAC,CACZ,IAAK,GAAW,CAAC,EAAO,GAAI,KAAK,yBAAyB,CAAM,CAAC,CAAC,CACvE,CACF,CAEA,UAAiB,EAA4D,CAC3E,IAAM,MAAc,CAClB,EAAG,KAAK,WAAW,CAAC,CACtB,EAEA,OADA,KAAK,SAAS,aAAa,CAAK,MACnB,CACX,KAAK,SAAS,eAAe,CAAK,CACpC,CACF,CACF"}
package/dist/comments.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as e, n as t, t as n } from "./BlockNoteExtension-B_IEJHS8.js";
2
- import { n as r, r as i } from "./UserStore-QbbPFj0z.js";
1
+ import { a as e, n as t, t as n } from "./BlockNoteExtension-CbvDA0F7.js";
2
+ import { n as r, r as i } from "./UserStore-C4TzkGEn.js";
3
3
  import { t as a } from "./ThreadStore-et9wB5Xt.js";
4
4
  import { Mark as o, mergeAttributes as s } from "@tiptap/core";
5
5
  import { Plugin as c, PluginKey as l } from "prosemirror-state";
@@ -61,8 +61,8 @@ var h = n(({ editor: e, options: { schema: n, threadStore: a, resolveUsers: o, c
61
61
  pendingComment: !1,
62
62
  selectedThreadId: void 0,
63
63
  threadPositions: /* @__PURE__ */ new Map()
64
- }, { onUpdate() {
65
- g.state.selectedThreadId !== g.prevState.selectedThreadId && e.transact((e) => e.setMeta(p, !0));
64
+ }, { onUpdate(t, n) {
65
+ t.selectedThreadId !== n.selectedThreadId && e.transact((e) => e.setMeta(p, !0));
66
66
  } }), _ = (t) => {
67
67
  e.transact((e) => {
68
68
  e.doc.descendants((n, r) => {
@@ -129,7 +129,7 @@ var h = n(({ editor: e, options: { schema: n, threadStore: a, resolveUsers: o, c
129
129
  selectedThreadId: void 0
130
130
  })), !1;
131
131
  let a = i.attrs.threadId;
132
- return a === g.state.selectedThreadId ? !1 : (g.setState((e) => ({
132
+ return a !== g.state.selectedThreadId && (g.setState((e) => ({
133
133
  ...e,
134
134
  selectedThreadId: a
135
135
  })), !0);
@@ -220,10 +220,10 @@ var h = n(({ editor: e, options: { schema: n, threadStore: a, resolveUsers: o, c
220
220
  return !0;
221
221
  }
222
222
  canAddReaction(e, t) {
223
- return t ? !e.reactions.some((e) => e.emoji === t && e.userIds.includes(this.userId)) : !0;
223
+ return !t || !e.reactions.some((e) => e.emoji === t && e.userIds.includes(this.userId));
224
224
  }
225
225
  canDeleteReaction(e, t) {
226
- return t ? e.reactions.some((e) => e.emoji === t && e.userIds.includes(this.userId)) : !0;
226
+ return !t || e.reactions.some((e) => e.emoji === t && e.userIds.includes(this.userId));
227
227
  }
228
228
  }, v = class extends a {
229
229
  userId;
@@ -1 +1 @@
1
- {"version":3,"file":"comments.js","names":[],"sources":["../src/comments/mark.ts","../src/comments/extension.ts","../src/comments/threadstore/ThreadStoreAuth.ts","../src/comments/threadstore/DefaultThreadStoreAuth.ts","../src/comments/threadstore/TipTapThreadStore.ts"],"sourcesContent":["import { Mark, mergeAttributes } from \"@tiptap/core\";\n\nimport { NON_FORMATTING_MARK_GROUP } from \"../schema/markGroups.js\";\n\nexport const CommentMark = Mark.create({\n name: \"comment\",\n excludes: \"\",\n inclusive: false,\n keepOnSplit: true,\n // Allowed on \"plain\" blocks (e.g. code blocks) via this group.\n group: NON_FORMATTING_MARK_GROUP,\n\n addAttributes() {\n // Return an object with attribute configuration\n return {\n // orphans are marks that currently don't have an active thread. It could be\n // that users have resolved the thread. Resolved threads by default are not shown in the document,\n // but we need to keep the mark (positioning) data so we can still \"revive\" it when the thread is unresolved\n // or we enter a \"comments\" view that includes resolved threads.\n orphan: {\n parseHTML: (element) => !!element.getAttribute(\"data-orphan\"),\n renderHTML: (attributes) => {\n return (attributes as { orphan: boolean }).orphan\n ? {\n \"data-orphan\": \"true\",\n }\n : {};\n },\n default: false,\n },\n threadId: {\n parseHTML: (element) => element.getAttribute(\"data-bn-thread-id\"),\n renderHTML: (attributes) => {\n return {\n \"data-bn-thread-id\": (attributes as { threadId: string }).threadId,\n };\n },\n default: \"\",\n },\n };\n },\n\n renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, any> }) {\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n class: \"bn-thread-mark\",\n }),\n ];\n },\n\n parseHTML() {\n return [{ tag: \"span.bn-thread-mark\" }];\n },\n\n extendMarkSchema(extension) {\n if (extension.name === \"comment\") {\n return {\n blocknoteIgnore: true,\n };\n }\n return {};\n },\n});\n","import { Node } from \"prosemirror-model\";\nimport { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n ExtensionOptions,\n} from \"../editor/BlockNoteExtension.js\";\nimport { ShowSelectionExtension } from \"../extensions/ShowSelection/ShowSelection.js\";\nimport { normalizeToUserStore, UserStoreOrResolver } from \"../user/index.js\";\nimport { CustomBlockNoteSchema } from \"../schema/schema.js\";\nimport { CommentMark } from \"./mark.js\";\nimport type { ThreadStore } from \"./threadstore/ThreadStore.js\";\nimport type { CommentBody, ThreadData } from \"./types.js\";\n\nconst PLUGIN_KEY = new PluginKey(\"blocknote-comments\");\n\ntype CommentsPluginState = {\n /**\n * Decorations to be rendered, specifically to indicate the selected thread\n */\n decorations: DecorationSet;\n};\n\n/**\n * Calculate the thread positions from the current document state\n */\nfunction getUpdatedThreadPositions(doc: Node, markType: string) {\n const threadPositions = new Map<string, { from: number; to: number }>();\n\n // find all thread marks and store their position + create decoration for selected thread\n doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const thisThreadId = (mark.attrs as { threadId: string | undefined })\n .threadId;\n if (!thisThreadId) {\n return;\n }\n const from = pos;\n const to = from + node.nodeSize;\n\n // FloatingThreads component uses \"to\" as the position, so always store the largest \"to\" found\n // AnchoredThreads component uses \"from\" as the position, so always store the smallest \"from\" found\n const currentPosition = threadPositions.get(thisThreadId) ?? {\n from: Infinity,\n to: 0,\n };\n threadPositions.set(thisThreadId, {\n from: Math.min(from, currentPosition.from),\n to: Math.max(to, currentPosition.to),\n });\n }\n });\n });\n return threadPositions;\n}\n\nexport const CommentsExtension = createExtension(\n ({\n editor,\n options: {\n schema: commentEditorSchema,\n threadStore,\n resolveUsers,\n confirmBeforeDiscard = true,\n },\n }: ExtensionOptions<{\n /**\n * The thread store implementation to use for storing and retrieving comment threads\n */\n threadStore: ThreadStore;\n /**\n * Resolve user information (names, avatars) for comment authors.\n *\n * Either a resolver function (called with the ids of users that are not yet\n * cached, returning their information) or a pre-built user store (see\n * `createUserStore`). Pass the same store to the collaboration options so a\n * single de-duped user cache is shared across comments and collaboration.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\n resolveUsers: UserStoreOrResolver;\n /**\n * A schema to use for the comment editor (which allows you to customize the blocks and styles that are available in the comment editor)\n */\n schema?: CustomBlockNoteSchema<any, any, any>;\n /**\n * Whether to ask the user for confirmation before discarding unsaved text\n * in a comment composer (a new comment, a reply, or an in-progress edit)\n * when it's dismissed (e.g. by clicking outside or pressing Escape).\n *\n * @default true\n */\n confirmBeforeDiscard?: boolean;\n }>) => {\n if (!resolveUsers) {\n throw new Error(\n \"resolveUsers is required to be defined when using comments\",\n );\n }\n if (!threadStore) {\n throw new Error(\n \"threadStore is required to be defined when using comments\",\n );\n }\n // Resolve users through this store, exposed on the extension instance so the\n // comments UI can read from it directly. Accepts a resolver callback or a\n // shared store (see the option docs above).\n const userStore = normalizeToUserStore(resolveUsers);\n const markType = CommentMark.name;\n\n const store = createStore(\n {\n pendingComment: false,\n selectedThreadId: undefined as string | undefined,\n threadPositions: new Map<string, { from: number; to: number }>(),\n },\n {\n onUpdate() {\n // If the selected thread id changed, we need to update the decorations\n if (\n store.state.selectedThreadId !== store.prevState.selectedThreadId\n ) {\n // So, we issue a transaction to update the decorations\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, true));\n }\n },\n },\n );\n\n const updateMarksFromThreads = (threads: Map<string, ThreadData>) => {\n editor.transact((tr) => {\n tr.doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const markTypeInstance = mark.type;\n const markThreadId = mark.attrs.threadId as string;\n const thread = threads.get(markThreadId);\n const isOrphan = !!(\n !thread ||\n thread.resolved ||\n thread.deletedAt\n );\n\n if (isOrphan !== mark.attrs.orphan) {\n const trimmedFrom = Math.max(pos, 0);\n const trimmedTo = Math.min(\n pos + node.nodeSize,\n tr.doc.content.size - 1,\n tr.doc.content.size - 1,\n );\n tr.removeMark(trimmedFrom, trimmedTo, mark);\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n markTypeInstance.create({\n ...mark.attrs,\n orphan: isOrphan,\n }),\n );\n\n if (isOrphan && store.state.selectedThreadId === markThreadId) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n }\n }\n });\n });\n });\n };\n\n return {\n key: \"comments\",\n store,\n userStore,\n runsBefore: [\"link\"],\n tiptapExtensions: [CommentMark],\n prosemirrorPlugins: [\n new Plugin<CommentsPluginState>({\n key: PLUGIN_KEY,\n state: {\n init() {\n return {\n decorations: DecorationSet.empty,\n };\n },\n apply(tr, state) {\n const action = tr.getMeta(PLUGIN_KEY);\n\n if (!tr.docChanged && !action) {\n return state;\n }\n\n // only update threadPositions if the doc changed\n const newThreadPositions = tr.docChanged\n ? getUpdatedThreadPositions(tr.doc, markType)\n : store.state.threadPositions;\n\n if (\n newThreadPositions.size > 0 ||\n store.state.threadPositions.size > 0\n ) {\n // small optimization; don't emit event if threadPositions before / after were both empty\n store.setState((prev) => ({\n ...prev,\n threadPositions: newThreadPositions,\n }));\n }\n\n // update decorations if doc or selected thread changed\n const decorations = [] as any[];\n\n if (store.state.selectedThreadId) {\n const selectedThreadPosition = newThreadPositions.get(\n store.state.selectedThreadId,\n );\n\n if (selectedThreadPosition) {\n decorations.push(\n Decoration.inline(\n selectedThreadPosition.from,\n selectedThreadPosition.to,\n {\n class: \"bn-thread-mark-selected\",\n },\n ),\n );\n }\n }\n\n return {\n decorations: DecorationSet.create(tr.doc, decorations),\n };\n },\n },\n props: {\n decorations(state) {\n return (\n PLUGIN_KEY.getState(state)?.decorations ?? DecorationSet.empty\n );\n },\n handleClick: (view, pos, event) => {\n if (event.button !== 0) {\n return false;\n }\n\n const node = view.state.doc.nodeAt(pos);\n\n if (!node) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n return false;\n }\n\n const commentMark = node.marks.find(\n (mark) =>\n mark.type.name === markType && mark.attrs.orphan !== true,\n );\n\n if (!commentMark) {\n // Clicked outside any comment thread. Deselect if needed but\n // don't consume the event so other handlers (e.g. link\n // navigation) can process it.\n if (store.state.selectedThreadId !== undefined) {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n return false;\n }\n\n const threadId = commentMark.attrs.threadId as string;\n\n // If the clicked thread is already selected, do nothing and let\n // other handlers process the event (e.g. navigating a link).\n if (threadId === store.state.selectedThreadId) {\n return false;\n }\n\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: threadId,\n }));\n\n return true;\n },\n },\n }),\n ],\n threadStore: threadStore,\n mount() {\n const unsubscribe = threadStore.subscribe(updateMarksFromThreads);\n updateMarksFromThreads(threadStore.getThreads());\n\n const unsubscribeOnSelectionChange = editor.onSelectionChange(() => {\n if (store.state.pendingComment) {\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n }));\n }\n });\n\n return () => {\n unsubscribe();\n unsubscribeOnSelectionChange();\n };\n },\n selectThread(threadId: string | undefined, scrollToThread = true) {\n if (store.state.selectedThreadId === threadId) {\n return;\n }\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n selectedThreadId: threadId,\n }));\n\n if (threadId && scrollToThread) {\n const selectedThreadPosition =\n store.state.threadPositions.get(threadId);\n if (!selectedThreadPosition) {\n return;\n }\n (\n editor.prosemirrorView?.domAtPos(selectedThreadPosition.from)\n .node as Element | undefined\n )?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n });\n }\n },\n startPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: true,\n }));\n // Use `editor.domElement` as `editor.focus()` doesn't do anything if\n // the editor is non-editable. Editor needs to be focused as\n // `showSelection` will otherwise trigger a selection update which\n // triggers `stopPendingComment`.\n editor.domElement?.focus();\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(true, \"comments\");\n },\n stopPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: false,\n }));\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(false, \"comments\");\n },\n async createThread(options: {\n initialComment: { body: CommentBody; metadata?: any };\n metadata?: any;\n }) {\n const thread = await threadStore.createThread(options);\n if (threadStore.addThreadToDocument) {\n await threadStore.addThreadToDocument({\n threadId: thread.id,\n selection: editor.transact((tr) => tr.selection),\n editor,\n });\n } else {\n (editor as any)._tiptapEditor.commands.setMark(markType, {\n orphan: false,\n threadId: thread.id,\n });\n }\n },\n commentEditorSchema,\n confirmBeforeDiscard,\n } as const;\n },\n);\n","import { CommentData, ThreadData } from \"../types.js\";\n\nexport abstract class ThreadStoreAuth {\n abstract canCreateThread(): boolean;\n abstract canAddComment(thread: ThreadData): boolean;\n abstract canUpdateComment(comment: CommentData): boolean;\n abstract canDeleteComment(comment: CommentData): boolean;\n abstract canDeleteThread(thread: ThreadData): boolean;\n abstract canResolveThread(thread: ThreadData): boolean;\n abstract canUnresolveThread(thread: ThreadData): boolean;\n abstract canAddReaction(comment: CommentData, emoji?: string): boolean;\n abstract canDeleteReaction(comment: CommentData, emoji?: string): boolean;\n}\n","import { CommentData, ThreadData } from \"../types.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\n\n/*\n * The DefaultThreadStoreAuth class defines the authorization rules for interacting with comments.\n * We take a role (\"comment\" or \"editor\") and implement the rules.\n *\n * This class is then used in the UI to show / hide specific interactions.\n *\n * Rules:\n * - View-only users should not be able to see any comments\n * - Comment-only users and editors can:\n * - - create new comments / replies / reactions\n * - - edit / delete their own comments / reactions\n * - - resolve / unresolve threads\n * - Editors can also delete any comment or thread\n */\nexport class DefaultThreadStoreAuth extends ThreadStoreAuth {\n constructor(\n private readonly userId: string,\n private readonly role: \"comment\" | \"editor\",\n ) {\n super();\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canCreateThread(): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canAddComment(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should only be possible by the comment author\n */\n canUpdateComment(comment: CommentData): boolean {\n return comment.userId === this.userId;\n }\n\n /**\n * Auth: should be possible by the comment author OR an editor of the document\n */\n canDeleteComment(comment: CommentData): boolean {\n return comment.userId === this.userId || this.role === \"editor\";\n }\n\n /**\n * Auth: should only be possible by an editor of the document\n */\n canDeleteThread(_thread: ThreadData): boolean {\n return this.role === \"editor\";\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canResolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canUnresolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canAddReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return !comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canDeleteReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n}\n","import {\n CommentBody,\n CommentData,\n CommentReactionData,\n ThreadData,\n} from \"../types.js\";\nimport { ThreadStore } from \"./ThreadStore.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\nimport type {\n TCollabComment,\n TCollabThread,\n TiptapCollabProvider,\n} from \"./tiptap/types.js\";\n\ntype ReactionAsTiptapData = {\n emoji: string;\n createdAt: number;\n userId: string;\n};\n\n/**\n * The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.\n * You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.\n *\n * Under the hood, this actually works similarly to the `YjsThreadStore` implementation. (comments are stored in the Yjs document)\n */\nexport class TiptapThreadStore extends ThreadStore {\n constructor(\n private readonly userId: string,\n private readonly provider: TiptapCollabProvider,\n auth: ThreadStoreAuth, // TODO: use?\n ) {\n super(auth);\n }\n\n /**\n * Creates a new thread with an initial comment.\n */\n public async createThread(options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }): Promise<ThreadData> {\n let thread = this.provider.createThread({\n data: options.metadata,\n });\n\n thread = this.provider.addComment(thread.id, {\n content: options.initialComment.body,\n data: {\n metadata: options.initialComment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n // TipTapThreadStore does not support addThreadToDocument\n public addThreadToDocument = undefined;\n\n /**\n * Adds a comment to a thread.\n */\n public async addComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }): Promise<CommentBody> {\n const thread = this.provider.addComment(options.threadId, {\n content: options.comment.body,\n data: {\n metadata: options.comment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapCommentToCommentData(\n thread.comments[thread.comments.length - 1],\n );\n }\n\n /**\n * Updates a comment in a thread.\n */\n public async updateComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n content: options.comment.body,\n data: {\n ...comment.data,\n metadata: options.comment.metadata,\n },\n });\n }\n\n private tiptapCommentToCommentData(comment: TCollabComment): CommentData {\n const reactions: CommentReactionData[] = [];\n\n for (const reaction of (comment.data?.reactions ||\n []) as ReactionAsTiptapData[]) {\n const existingReaction = reactions.find(\n (r) => r.emoji === reaction.emoji,\n );\n if (existingReaction) {\n existingReaction.userIds.push(reaction.userId);\n existingReaction.createdAt = new Date(\n Math.min(existingReaction.createdAt.getTime(), reaction.createdAt),\n );\n } else {\n reactions.push({\n emoji: reaction.emoji,\n createdAt: new Date(reaction.createdAt),\n userIds: [reaction.userId],\n });\n }\n }\n\n return {\n type: \"comment\",\n id: comment.id,\n body: comment.content,\n metadata: comment.data?.metadata,\n userId: comment.data?.userId,\n createdAt: new Date(comment.createdAt),\n updatedAt: new Date(comment.updatedAt),\n reactions,\n };\n }\n\n private tiptapThreadToThreadData(thread: TCollabThread): ThreadData {\n return {\n type: \"thread\",\n id: thread.id,\n comments: thread.comments.map((comment) =>\n this.tiptapCommentToCommentData(comment),\n ),\n resolved: !!thread.resolvedAt,\n metadata: thread.data?.metadata,\n createdAt: new Date(thread.createdAt),\n updatedAt: new Date(thread.updatedAt),\n };\n }\n\n /**\n * Deletes a comment from a thread.\n */\n public async deleteComment(options: { threadId: string; commentId: string }) {\n this.provider.deleteComment(options.threadId, options.commentId);\n }\n\n /**\n * Deletes a thread.\n */\n public async deleteThread(options: { threadId: string }) {\n this.provider.deleteThread(options.threadId);\n }\n\n /**\n * Marks a thread as resolved.\n */\n public async resolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: new Date().toISOString(),\n });\n }\n\n /**\n * Marks a thread as unresolved.\n */\n public async unresolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: null,\n });\n }\n\n /**\n * Adds a reaction to a comment.\n *\n * Auth: should be possible by anyone with comment access\n */\n public async addReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: [\n ...((comment.data?.reactions || []) as ReactionAsTiptapData[]),\n {\n emoji: options.emoji,\n createdAt: Date.now(),\n userId: this.userId,\n },\n ],\n },\n });\n }\n\n /**\n * Deletes a reaction from a comment.\n *\n * Auth: should be possible by the reaction author\n */\n public async deleteReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: (\n (comment.data?.reactions || []) as ReactionAsTiptapData[]\n ).filter(\n (reaction) =>\n reaction.emoji !== options.emoji && reaction.userId !== this.userId,\n ),\n },\n });\n }\n\n public getThread(threadId: string): ThreadData {\n const thread = this.provider.getThread(threadId);\n\n if (!thread) {\n throw new Error(\"Thread not found\");\n }\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n public getThreads(): Map<string, ThreadData> {\n return new Map(\n this.provider\n .getThreads()\n .map((thread) => [thread.id, this.tiptapThreadToThreadData(thread)]),\n );\n }\n\n public subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void {\n const newCb = () => {\n cb(this.getThreads());\n };\n this.provider.watchThreads(newCb);\n return () => {\n this.provider.unw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AAG,EAAQ;GACX,YACG,EAAQ,MAAM,aAAa,CAAC,GAC7B,QACC,MACC,EAAS,UAAU,EAAQ,SAAS,EAAS,WAAW,KAAK,MACjE;EACF,EACF,CAAC;CACH;CAEA,UAAiB,GAA8B;EAC7C,IAAM,IAAS,KAAK,SAAS,UAAU,CAAQ;EAE/C,IAAI,CAAC,GACH,MAAU,MAAM,kBAAkB;EAGpC,OAAO,KAAK,yBAAyB,CAAM;CAC7C;CAEA,aAA6C;EAC3C,OAAO,IAAI,IACT,KAAK,SACF,WAAW,EACX,KAAK,MAAW,CAAC,EAAO,IAAI,KAAK,yBAAyB,CAAM,CAAC,CAAC,CACvE;CACF;CAEA,UAAiB,GAA4D;EAC3E,IAAM,UAAc;GAClB,EAAG,KAAK,WAAW,CAAC;EACtB;EAEA,OADA,KAAK,SAAS,aAAa,CAAK,SACnB;GACX,KAAK,SAAS,eAAe,CAAK;EACpC;CACF;AACF"}
1
+ {"version":3,"file":"comments.js","names":[],"sources":["../src/comments/mark.ts","../src/comments/extension.ts","../src/comments/threadstore/ThreadStoreAuth.ts","../src/comments/threadstore/DefaultThreadStoreAuth.ts","../src/comments/threadstore/TipTapThreadStore.ts"],"sourcesContent":["import { Mark, mergeAttributes } from \"@tiptap/core\";\n\nimport { NON_FORMATTING_MARK_GROUP } from \"../schema/markGroups.js\";\n\nexport const CommentMark = Mark.create({\n name: \"comment\",\n excludes: \"\",\n inclusive: false,\n keepOnSplit: true,\n // Allowed on \"plain\" blocks (e.g. code blocks) via this group.\n group: NON_FORMATTING_MARK_GROUP,\n\n addAttributes() {\n // Return an object with attribute configuration\n return {\n // orphans are marks that currently don't have an active thread. It could be\n // that users have resolved the thread. Resolved threads by default are not shown in the document,\n // but we need to keep the mark (positioning) data so we can still \"revive\" it when the thread is unresolved\n // or we enter a \"comments\" view that includes resolved threads.\n orphan: {\n parseHTML: (element) => !!element.getAttribute(\"data-orphan\"),\n renderHTML: (attributes) => {\n return (attributes as { orphan: boolean }).orphan\n ? {\n \"data-orphan\": \"true\",\n }\n : {};\n },\n default: false,\n },\n threadId: {\n parseHTML: (element) => element.getAttribute(\"data-bn-thread-id\"),\n renderHTML: (attributes) => {\n return {\n \"data-bn-thread-id\": (attributes as { threadId: string }).threadId,\n };\n },\n default: \"\",\n },\n };\n },\n\n renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, any> }) {\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n class: \"bn-thread-mark\",\n }),\n ];\n },\n\n parseHTML() {\n return [{ tag: \"span.bn-thread-mark\" }];\n },\n\n extendMarkSchema(extension) {\n if (extension.name === \"comment\") {\n return {\n blocknoteIgnore: true,\n };\n }\n return {};\n },\n});\n","import { Node } from \"prosemirror-model\";\nimport { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n ExtensionOptions,\n} from \"../editor/BlockNoteExtension.js\";\nimport { ShowSelectionExtension } from \"../extensions/ShowSelection/ShowSelection.js\";\nimport { normalizeToUserStore, UserStoreOrResolver } from \"../user/index.js\";\nimport { CustomBlockNoteSchema } from \"../schema/schema.js\";\nimport { CommentMark } from \"./mark.js\";\nimport type { ThreadStore } from \"./threadstore/ThreadStore.js\";\nimport type { CommentBody, ThreadData } from \"./types.js\";\n\nconst PLUGIN_KEY = new PluginKey(\"blocknote-comments\");\n\ntype CommentsPluginState = {\n /**\n * Decorations to be rendered, specifically to indicate the selected thread\n */\n decorations: DecorationSet;\n};\n\n/**\n * Calculate the thread positions from the current document state\n */\nfunction getUpdatedThreadPositions(doc: Node, markType: string) {\n const threadPositions = new Map<string, { from: number; to: number }>();\n\n // find all thread marks and store their position + create decoration for selected thread\n doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const thisThreadId = (mark.attrs as { threadId: string | undefined })\n .threadId;\n if (!thisThreadId) {\n return;\n }\n const from = pos;\n const to = from + node.nodeSize;\n\n // FloatingThreads component uses \"to\" as the position, so always store the largest \"to\" found\n // AnchoredThreads component uses \"from\" as the position, so always store the smallest \"from\" found\n const currentPosition = threadPositions.get(thisThreadId) ?? {\n from: Infinity,\n to: 0,\n };\n threadPositions.set(thisThreadId, {\n from: Math.min(from, currentPosition.from),\n to: Math.max(to, currentPosition.to),\n });\n }\n });\n });\n return threadPositions;\n}\n\nexport const CommentsExtension = createExtension(\n ({\n editor,\n options: {\n schema: commentEditorSchema,\n threadStore,\n resolveUsers,\n confirmBeforeDiscard = true,\n },\n }: ExtensionOptions<{\n /**\n * The thread store implementation to use for storing and retrieving comment threads\n */\n threadStore: ThreadStore;\n /**\n * Resolve user information (names, avatars) for comment authors.\n *\n * Either a resolver function (called with the ids of users that are not yet\n * cached, returning their information) or a pre-built user store (see\n * `createUserStore`). Pass the same store to the collaboration options so a\n * single de-duped user cache is shared across comments and collaboration.\n *\n * See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.\n */\n resolveUsers: UserStoreOrResolver;\n /**\n * A schema to use for the comment editor (which allows you to customize the blocks and styles that are available in the comment editor)\n */\n schema?: CustomBlockNoteSchema<any, any, any>;\n /**\n * Whether to ask the user for confirmation before discarding unsaved text\n * in a comment composer (a new comment, a reply, or an in-progress edit)\n * when it's dismissed (e.g. by clicking outside or pressing Escape).\n *\n * @default true\n */\n confirmBeforeDiscard?: boolean;\n }>) => {\n if (!resolveUsers) {\n throw new Error(\n \"resolveUsers is required to be defined when using comments\",\n );\n }\n if (!threadStore) {\n throw new Error(\n \"threadStore is required to be defined when using comments\",\n );\n }\n // Resolve users through this store, exposed on the extension instance so the\n // comments UI can read from it directly. Accepts a resolver callback or a\n // shared store (see the option docs above).\n const userStore = normalizeToUserStore(resolveUsers);\n const markType = CommentMark.name;\n\n const store = createStore(\n {\n pendingComment: false,\n selectedThreadId: undefined as string | undefined,\n threadPositions: new Map<string, { from: number; to: number }>(),\n },\n {\n onUpdate(state, prevState) {\n // If the selected thread id changed, we need to update the decorations\n if (state.selectedThreadId !== prevState.selectedThreadId) {\n // So, we issue a transaction to update the decorations\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, true));\n }\n },\n },\n );\n\n const updateMarksFromThreads = (threads: Map<string, ThreadData>) => {\n editor.transact((tr) => {\n tr.doc.descendants((node, pos) => {\n node.marks.forEach((mark) => {\n if (mark.type.name === markType) {\n const markTypeInstance = mark.type;\n const markThreadId = mark.attrs.threadId as string;\n const thread = threads.get(markThreadId);\n const isOrphan = !!(\n !thread ||\n thread.resolved ||\n thread.deletedAt\n );\n\n if (isOrphan !== mark.attrs.orphan) {\n const trimmedFrom = Math.max(pos, 0);\n const trimmedTo = Math.min(\n pos + node.nodeSize,\n tr.doc.content.size - 1,\n tr.doc.content.size - 1,\n );\n tr.removeMark(trimmedFrom, trimmedTo, mark);\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n markTypeInstance.create({\n ...mark.attrs,\n orphan: isOrphan,\n }),\n );\n\n if (isOrphan && store.state.selectedThreadId === markThreadId) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n }\n }\n });\n });\n });\n };\n\n return {\n key: \"comments\",\n store,\n userStore,\n runsBefore: [\"link\"],\n tiptapExtensions: [CommentMark],\n prosemirrorPlugins: [\n new Plugin<CommentsPluginState>({\n key: PLUGIN_KEY,\n state: {\n init() {\n return {\n decorations: DecorationSet.empty,\n };\n },\n apply(tr, state) {\n const action = tr.getMeta(PLUGIN_KEY);\n\n if (!tr.docChanged && !action) {\n return state;\n }\n\n // only update threadPositions if the doc changed\n const newThreadPositions = tr.docChanged\n ? getUpdatedThreadPositions(tr.doc, markType)\n : store.state.threadPositions;\n\n if (\n newThreadPositions.size > 0 ||\n store.state.threadPositions.size > 0\n ) {\n // small optimization; don't emit event if threadPositions before / after were both empty\n store.setState((prev) => ({\n ...prev,\n threadPositions: newThreadPositions,\n }));\n }\n\n // update decorations if doc or selected thread changed\n const decorations = [] as any[];\n\n if (store.state.selectedThreadId) {\n const selectedThreadPosition = newThreadPositions.get(\n store.state.selectedThreadId,\n );\n\n if (selectedThreadPosition) {\n decorations.push(\n Decoration.inline(\n selectedThreadPosition.from,\n selectedThreadPosition.to,\n {\n class: \"bn-thread-mark-selected\",\n },\n ),\n );\n }\n }\n\n return {\n decorations: DecorationSet.create(tr.doc, decorations),\n };\n },\n },\n props: {\n decorations(state) {\n return (\n PLUGIN_KEY.getState(state)?.decorations ?? DecorationSet.empty\n );\n },\n handleClick: (view, pos, event) => {\n if (event.button !== 0) {\n return false;\n }\n\n const node = view.state.doc.nodeAt(pos);\n\n if (!node) {\n // unselect\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n return false;\n }\n\n const commentMark = node.marks.find(\n (mark) =>\n mark.type.name === markType && mark.attrs.orphan !== true,\n );\n\n if (!commentMark) {\n // Clicked outside any comment thread. Deselect if needed but\n // don't consume the event so other handlers (e.g. link\n // navigation) can process it.\n if (store.state.selectedThreadId !== undefined) {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n }));\n }\n return false;\n }\n\n const threadId = commentMark.attrs.threadId as string;\n\n // If the clicked thread is already selected, do nothing and let\n // other handlers process the event (e.g. navigating a link).\n if (threadId === store.state.selectedThreadId) {\n return false;\n }\n\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: threadId,\n }));\n\n return true;\n },\n },\n }),\n ],\n threadStore: threadStore,\n mount() {\n const unsubscribe = threadStore.subscribe(updateMarksFromThreads);\n updateMarksFromThreads(threadStore.getThreads());\n\n const unsubscribeOnSelectionChange = editor.onSelectionChange(() => {\n if (store.state.pendingComment) {\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n }));\n }\n });\n\n return () => {\n unsubscribe();\n unsubscribeOnSelectionChange();\n };\n },\n selectThread(threadId: string | undefined, scrollToThread = true) {\n if (store.state.selectedThreadId === threadId) {\n return;\n }\n store.setState((prev) => ({\n ...prev,\n pendingComment: false,\n selectedThreadId: threadId,\n }));\n\n if (threadId && scrollToThread) {\n const selectedThreadPosition =\n store.state.threadPositions.get(threadId);\n if (!selectedThreadPosition) {\n return;\n }\n (\n editor.prosemirrorView?.domAtPos(selectedThreadPosition.from)\n .node as Element | undefined\n )?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n });\n }\n },\n startPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: true,\n }));\n // Use `editor.domElement` as `editor.focus()` doesn't do anything if\n // the editor is non-editable. Editor needs to be focused as\n // `showSelection` will otherwise trigger a selection update which\n // triggers `stopPendingComment`.\n editor.domElement?.focus();\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(true, \"comments\");\n },\n stopPendingComment() {\n store.setState((prev) => ({\n ...prev,\n selectedThreadId: undefined,\n pendingComment: false,\n }));\n editor\n .getExtension(ShowSelectionExtension)\n ?.showSelection(false, \"comments\");\n },\n async createThread(options: {\n initialComment: { body: CommentBody; metadata?: any };\n metadata?: any;\n }) {\n const thread = await threadStore.createThread(options);\n if (threadStore.addThreadToDocument) {\n await threadStore.addThreadToDocument({\n threadId: thread.id,\n selection: editor.transact((tr) => tr.selection),\n editor,\n });\n } else {\n (editor as any)._tiptapEditor.commands.setMark(markType, {\n orphan: false,\n threadId: thread.id,\n });\n }\n },\n commentEditorSchema,\n confirmBeforeDiscard,\n } as const;\n },\n);\n","import { CommentData, ThreadData } from \"../types.js\";\n\nexport abstract class ThreadStoreAuth {\n abstract canCreateThread(): boolean;\n abstract canAddComment(thread: ThreadData): boolean;\n abstract canUpdateComment(comment: CommentData): boolean;\n abstract canDeleteComment(comment: CommentData): boolean;\n abstract canDeleteThread(thread: ThreadData): boolean;\n abstract canResolveThread(thread: ThreadData): boolean;\n abstract canUnresolveThread(thread: ThreadData): boolean;\n abstract canAddReaction(comment: CommentData, emoji?: string): boolean;\n abstract canDeleteReaction(comment: CommentData, emoji?: string): boolean;\n}\n","import { CommentData, ThreadData } from \"../types.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\n\n/*\n * The DefaultThreadStoreAuth class defines the authorization rules for interacting with comments.\n * We take a role (\"comment\" or \"editor\") and implement the rules.\n *\n * This class is then used in the UI to show / hide specific interactions.\n *\n * Rules:\n * - View-only users should not be able to see any comments\n * - Comment-only users and editors can:\n * - - create new comments / replies / reactions\n * - - edit / delete their own comments / reactions\n * - - resolve / unresolve threads\n * - Editors can also delete any comment or thread\n */\nexport class DefaultThreadStoreAuth extends ThreadStoreAuth {\n constructor(\n private readonly userId: string,\n private readonly role: \"comment\" | \"editor\",\n ) {\n super();\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canCreateThread(): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canAddComment(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should only be possible by the comment author\n */\n canUpdateComment(comment: CommentData): boolean {\n return comment.userId === this.userId;\n }\n\n /**\n * Auth: should be possible by the comment author OR an editor of the document\n */\n canDeleteComment(comment: CommentData): boolean {\n return comment.userId === this.userId || this.role === \"editor\";\n }\n\n /**\n * Auth: should only be possible by an editor of the document\n */\n canDeleteThread(_thread: ThreadData): boolean {\n return this.role === \"editor\";\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canResolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n */\n canUnresolveThread(_thread: ThreadData): boolean {\n return true;\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canAddReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return !comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n\n /**\n * Auth: should be possible by anyone with comment access\n *\n * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?\n */\n canDeleteReaction(comment: CommentData, emoji?: string): boolean {\n if (!emoji) {\n return true;\n }\n\n return comment.reactions.some(\n (reaction) =>\n reaction.emoji === emoji && reaction.userIds.includes(this.userId),\n );\n }\n}\n","import {\n CommentBody,\n CommentData,\n CommentReactionData,\n ThreadData,\n} from \"../types.js\";\nimport { ThreadStore } from \"./ThreadStore.js\";\nimport { ThreadStoreAuth } from \"./ThreadStoreAuth.js\";\nimport type {\n TCollabComment,\n TCollabThread,\n TiptapCollabProvider,\n} from \"./tiptap/types.js\";\n\ntype ReactionAsTiptapData = {\n emoji: string;\n createdAt: number;\n userId: string;\n};\n\n/**\n * The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.\n * You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.\n *\n * Under the hood, this actually works similarly to the `YjsThreadStore` implementation. (comments are stored in the Yjs document)\n */\nexport class TiptapThreadStore extends ThreadStore {\n constructor(\n private readonly userId: string,\n private readonly provider: TiptapCollabProvider,\n auth: ThreadStoreAuth, // TODO: use?\n ) {\n super(auth);\n }\n\n /**\n * Creates a new thread with an initial comment.\n */\n public async createThread(options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }): Promise<ThreadData> {\n let thread = this.provider.createThread({\n data: options.metadata,\n });\n\n thread = this.provider.addComment(thread.id, {\n content: options.initialComment.body,\n data: {\n metadata: options.initialComment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n // TipTapThreadStore does not support addThreadToDocument\n public addThreadToDocument = undefined;\n\n /**\n * Adds a comment to a thread.\n */\n public async addComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }): Promise<CommentBody> {\n const thread = this.provider.addComment(options.threadId, {\n content: options.comment.body,\n data: {\n metadata: options.comment.metadata,\n userId: this.userId,\n },\n });\n\n return this.tiptapCommentToCommentData(\n thread.comments[thread.comments.length - 1],\n );\n }\n\n /**\n * Updates a comment in a thread.\n */\n public async updateComment(options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n content: options.comment.body,\n data: {\n ...comment.data,\n metadata: options.comment.metadata,\n },\n });\n }\n\n private tiptapCommentToCommentData(comment: TCollabComment): CommentData {\n const reactions: CommentReactionData[] = [];\n\n for (const reaction of (comment.data?.reactions ||\n []) as ReactionAsTiptapData[]) {\n const existingReaction = reactions.find(\n (r) => r.emoji === reaction.emoji,\n );\n if (existingReaction) {\n existingReaction.userIds.push(reaction.userId);\n existingReaction.createdAt = new Date(\n Math.min(existingReaction.createdAt.getTime(), reaction.createdAt),\n );\n } else {\n reactions.push({\n emoji: reaction.emoji,\n createdAt: new Date(reaction.createdAt),\n userIds: [reaction.userId],\n });\n }\n }\n\n return {\n type: \"comment\",\n id: comment.id,\n body: comment.content,\n metadata: comment.data?.metadata,\n userId: comment.data?.userId,\n createdAt: new Date(comment.createdAt),\n updatedAt: new Date(comment.updatedAt),\n reactions,\n };\n }\n\n private tiptapThreadToThreadData(thread: TCollabThread): ThreadData {\n return {\n type: \"thread\",\n id: thread.id,\n comments: thread.comments.map((comment) =>\n this.tiptapCommentToCommentData(comment),\n ),\n resolved: !!thread.resolvedAt,\n metadata: thread.data?.metadata,\n createdAt: new Date(thread.createdAt),\n updatedAt: new Date(thread.updatedAt),\n };\n }\n\n /**\n * Deletes a comment from a thread.\n */\n public async deleteComment(options: { threadId: string; commentId: string }) {\n this.provider.deleteComment(options.threadId, options.commentId);\n }\n\n /**\n * Deletes a thread.\n */\n public async deleteThread(options: { threadId: string }) {\n this.provider.deleteThread(options.threadId);\n }\n\n /**\n * Marks a thread as resolved.\n */\n public async resolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: new Date().toISOString(),\n });\n }\n\n /**\n * Marks a thread as unresolved.\n */\n public async unresolveThread(options: { threadId: string }) {\n this.provider.updateThread(options.threadId, {\n resolvedAt: null,\n });\n }\n\n /**\n * Adds a reaction to a comment.\n *\n * Auth: should be possible by anyone with comment access\n */\n public async addReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: [\n ...((comment.data?.reactions || []) as ReactionAsTiptapData[]),\n {\n emoji: options.emoji,\n createdAt: Date.now(),\n userId: this.userId,\n },\n ],\n },\n });\n }\n\n /**\n * Deletes a reaction from a comment.\n *\n * Auth: should be possible by the reaction author\n */\n public async deleteReaction(options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) {\n const comment = this.provider.getThreadComment(\n options.threadId,\n options.commentId,\n true,\n );\n\n if (!comment) {\n throw new Error(\"Comment not found\");\n }\n\n this.provider.updateComment(options.threadId, options.commentId, {\n data: {\n ...comment.data,\n reactions: (\n (comment.data?.reactions || []) as ReactionAsTiptapData[]\n ).filter(\n (reaction) =>\n reaction.emoji !== options.emoji && reaction.userId !== this.userId,\n ),\n },\n });\n }\n\n public getThread(threadId: string): ThreadData {\n const thread = this.provider.getThread(threadId);\n\n if (!thread) {\n throw new Error(\"Thread not found\");\n }\n\n return this.tiptapThreadToThreadData(thread);\n }\n\n public getThreads(): Map<string, ThreadData> {\n return new Map(\n this.provider\n .getThreads()\n .map((thread) => [thread.id, this.tiptapThreadToThreadData(thread)]),\n );\n }\n\n public subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void {\n const newCb = () => {\n cb(this.getThreads());\n };\n this.provider.watchThreads(newCb);\n return () => {\n this.provider.unwatchThreads(newCb);\n };\n }\n}\n"],"mappings":";;;;;;;AAIA,IAAa,IAAc,EAAK,OAAO;CACrC,MAAM;CACN,UAAU;CACV,WAAW;CACX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S,UAAU,EAAQ,SAAS,EAAS,WAAW,KAAK,MACjE;EACF,EACF,CAAC;CACH;CAEA,UAAiB,GAA8B;EAC7C,IAAM,IAAS,KAAK,SAAS,UAAU,CAAQ;EAE/C,IAAI,CAAC,GACH,MAAU,MAAM,kBAAkB;EAGpC,OAAO,KAAK,yBAAyB,CAAM;CAC7C;CAEA,aAA6C;EAC3C,OAAO,IAAI,IACT,KAAK,SACF,WAAW,CAAC,CACZ,KAAK,MAAW,CAAC,EAAO,IAAI,KAAK,yBAAyB,CAAM,CAAC,CAAC,CACvE;CACF;CAEA,UAAiB,GAA4D;EAC3E,IAAM,UAAc;GAClB,EAAG,KAAK,WAAW,CAAC;EACtB;EAEA,OADA,KAAK,SAAS,aAAa,CAAK,SACnB;GACX,KAAK,SAAS,eAAe,CAAK;EACpC;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ var e={slash_menu:{heading:{title:`Heading 1`,subtext:`Top-level heading`,aliases:[`h`,`heading1`,`h1`],group:`Headings`},heading_2:{title:`Heading 2`,subtext:`Key section heading`,aliases:[`h2`,`heading2`,`subheading`],group:`Headings`},heading_3:{title:`Heading 3`,subtext:`Subsection and group heading`,aliases:[`h3`,`heading3`,`subheading`],group:`Headings`},heading_4:{title:`Heading 4`,subtext:`Minor subsection heading`,aliases:[`h4`,`heading4`,`subheading4`],group:`Subheadings`},heading_5:{title:`Heading 5`,subtext:`Small subsection heading`,aliases:[`h5`,`heading5`,`subheading5`],group:`Subheadings`},heading_6:{title:`Heading 6`,subtext:`Lowest-level heading`,aliases:[`h6`,`heading6`,`subheading6`],group:`Subheadings`},toggle_heading:{title:`Toggle Heading 1`,subtext:`Toggleable top-level heading`,aliases:[`h`,`heading1`,`h1`,`collapsable`],group:`Subheadings`},toggle_heading_2:{title:`Toggle Heading 2`,subtext:`Toggleable key section heading`,aliases:[`h2`,`heading2`,`subheading`,`collapsable`],group:`Subheadings`},toggle_heading_3:{title:`Toggle Heading 3`,subtext:`Toggleable subsection and group heading`,aliases:[`h3`,`heading3`,`subheading`,`collapsable`],group:`Subheadings`},quote:{title:`Quote`,subtext:`Quote or excerpt`,aliases:[`quotation`,`blockquote`,`bq`],group:`Basic blocks`},toggle_list:{title:`Toggle List`,subtext:`List with hideable sub-items`,aliases:[`li`,`list`,`toggleList`,`toggle list`,`collapsable list`],group:`Basic blocks`},numbered_list:{title:`Numbered List`,subtext:`List with ordered items`,aliases:[`ol`,`li`,`list`,`numberedlist`,`numbered list`],group:`Basic blocks`},bullet_list:{title:`Bullet List`,subtext:`List with unordered items`,aliases:[`ul`,`li`,`list`,`bulletlist`,`bullet list`],group:`Basic blocks`},check_list:{title:`Check List`,subtext:`List with checkboxes`,aliases:[`ul`,`li`,`list`,`checklist`,`check list`,`checked list`,`checkbox`],group:`Basic blocks`},paragraph:{title:`Paragraph`,subtext:`The body of your document`,aliases:[`p`,`paragraph`],group:`Basic blocks`},code_block:{title:`Code Block`,subtext:`Code block with syntax highlighting`,aliases:[`code`,`pre`],group:`Basic blocks`},page_break:{title:`Page Break`,subtext:`Page separator`,aliases:[`page`,`break`,`separator`],group:`Basic blocks`},table:{title:`Table`,subtext:`Table with editable cells`,aliases:[`table`],group:`Advanced`},image:{title:`Image`,subtext:`Resizable image with caption`,aliases:[`image`,`imageUpload`,`upload`,`img`,`picture`,`media`,`url`],group:`Media`},video:{title:`Video`,subtext:`Resizable video with caption`,aliases:[`video`,`videoUpload`,`upload`,`mp4`,`film`,`media`,`url`],group:`Media`},audio:{title:`Audio`,subtext:`Embedded audio with caption`,aliases:[`audio`,`audioUpload`,`upload`,`mp3`,`sound`,`media`,`url`],group:`Media`},file:{title:`File`,subtext:`Embedded file`,aliases:[`file`,`upload`,`embed`,`media`,`url`],group:`Media`},emoji:{title:`Emoji`,subtext:`Search for and insert an emoji`,aliases:[`emoji`,`emote`,`emotion`,`face`],group:`Others`},divider:{title:`Divider`,subtext:`Visually divide blocks`,aliases:[`divider`,`hr`,`line`,`horizontal rule`],group:`Basic blocks`}},placeholders:{default:`Enter text or type '/' for commands`,heading:`Heading`,toggleListItem:`Toggle`,bulletListItem:`List`,numberedListItem:`List`,checkListItem:`List`,emptyDocument:void 0,new_comment:`Write a comment...`,edit_comment:`Edit comment...`,comment_reply:`Add comment...`},file_blocks:{add_button_text:{image:`Add image`,video:`Add video`,audio:`Add audio`,file:`Add file`}},toggle_blocks:{add_block_button:`Empty toggle. Click to add a block.`},code_block:{add_source_button_text:`Add source code`,ok_button_text:`OK`},side_menu:{add_block_label:`Add block`,drag_handle_label:`Open block menu`},drag_handle:{delete_menuitem:`Delete`,colors_menuitem:`Colors`,header_row_menuitem:`Header row`,header_column_menuitem:`Header column`},table_handle:{delete_column_menuitem:`Delete column`,delete_row_menuitem:`Delete row`,add_left_menuitem:`Add column left`,add_right_menuitem:`Add column right`,add_above_menuitem:`Add row above`,add_below_menuitem:`Add row below`,split_cell_menuitem:`Split cell`,merge_cells_menuitem:`Merge cells`,background_color_menuitem:`Background color`},suggestion_menu:{no_items_title:`No items found`},color_picker:{text_title:`Text`,background_title:`Background`,colors:{default:`Auto`,gray:`Gray`,brown:`Brown`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,blue:`Blue`,purple:`Purple`,pink:`Pink`}},formatting_toolbar:{bold:{tooltip:`Bold`,secondary_tooltip:`Mod+B`},italic:{tooltip:`Italic`,secondary_tooltip:`Mod+I`},underline:{tooltip:`Underline`,secondary_tooltip:`Mod+U`},strike:{tooltip:`Strike`,secondary_tooltip:`Mod+Shift+S`},code:{tooltip:`Code`,secondary_tooltip:``},colors:{tooltip:`Colors`},link:{tooltip:`Create link`,secondary_tooltip:`Mod+K`},file_caption:{tooltip:`Edit caption`,input_placeholder:`Edit caption`},file_replace:{tooltip:{image:`Replace image`,video:`Replace video`,audio:`Replace audio`,file:`Replace file`}},file_rename:{tooltip:{image:`Rename image`,video:`Rename video`,audio:`Rename audio`,file:`Rename file`},input_placeholder:{image:`Rename image`,video:`Rename video`,audio:`Rename audio`,file:`Rename file`}},file_download:{tooltip:{image:`Download image`,video:`Download video`,audio:`Download audio`,file:`Download file`}},file_delete:{tooltip:{image:`Delete image`,video:`Delete video`,audio:`Delete audio`,file:`Delete file`}},file_preview_toggle:{tooltip:`Toggle preview`},nest:{tooltip:`Nest block`,secondary_tooltip:`Tab`},unnest:{tooltip:`Unnest block`,secondary_tooltip:`Shift+Tab`},align_left:{tooltip:`Align text left`},align_center:{tooltip:`Align text center`},align_right:{tooltip:`Align text right`},align_justify:{tooltip:`Justify text`},table_cell_merge:{tooltip:`Merge cells`},comment:{tooltip:`Add comment`}},file_panel:{upload:{title:`Upload`,file_placeholder:{image:`Upload image`,video:`Upload video`,audio:`Upload audio`,file:`Upload file`},upload_error:`Error: Upload failed`},embed:{title:`Embed`,embed_button:{image:`Embed image`,video:`Embed video`,audio:`Embed audio`,file:`Embed file`},url_placeholder:`Enter URL`}},link_toolbar:{delete:{tooltip:`Remove link`},edit:{text:`Edit link`,tooltip:`Edit`},open:{tooltip:`Open in new tab`},form:{title_placeholder:`Edit title`,url_placeholder:`Edit URL`}},comments:{edited:`edited`,save_button_text:`Save`,cancel_button_text:`Cancel`,deleted_reference_text:`Original content deleted`,discard_pending_comment:`Are you sure you want to discard this comment?`,actions:{add_reaction:`Add reaction`,resolve:`Resolve`,reopen:`Re-open`,edit_comment:`Edit comment`,delete_comment:`Delete comment`,more_actions:`More actions`},reactions:{reacted_by:`Reacted by`},sidebar:{marked_as_resolved:`Marked as resolved`,more_replies:e=>`${e} more replies`}},suggestion_changes:{formatting_change:`Formatting Change`,deleted:`Deleted`,inserted_by:e=>`Inserted by: ${e}`,deleted_by:e=>`Deleted by: ${e}`,formatting_change_by:(e,t)=>`Formatting change (${e}) by: ${t}`},exporter:{open_file:`Open file`,open_video_file:`Open video`,open_audio_file:`Open audio`},generic:{ctrl_shortcut:`Ctrl`}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
2
+ //# sourceMappingURL=en-BuzSuuTq.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-BuzSuuTq.cjs","names":[],"sources":["../src/i18n/locales/en.ts"],"sourcesContent":["export const en = {\n slash_menu: {\n heading: {\n title: \"Heading 1\",\n subtext: \"Top-level heading\",\n aliases: [\"h\", \"heading1\", \"h1\"],\n group: \"Headings\",\n },\n heading_2: {\n title: \"Heading 2\",\n subtext: \"Key section heading\",\n aliases: [\"h2\", \"heading2\", \"subheading\"],\n group: \"Headings\",\n },\n heading_3: {\n title: \"Heading 3\",\n subtext: \"Subsection and group heading\",\n aliases: [\"h3\", \"heading3\", \"subheading\"],\n group: \"Headings\",\n },\n heading_4: {\n title: \"Heading 4\",\n subtext: \"Minor subsection heading\",\n aliases: [\"h4\", \"heading4\", \"subheading4\"],\n group: \"Subheadings\",\n },\n heading_5: {\n title: \"Heading 5\",\n subtext: \"Small subsection heading\",\n aliases: [\"h5\", \"heading5\", \"subheading5\"],\n group: \"Subheadings\",\n },\n heading_6: {\n title: \"Heading 6\",\n subtext: \"Lowest-level heading\",\n aliases: [\"h6\", \"heading6\", \"subheading6\"],\n group: \"Subheadings\",\n },\n toggle_heading: {\n title: \"Toggle Heading 1\",\n subtext: \"Toggleable top-level heading\",\n aliases: [\"h\", \"heading1\", \"h1\", \"collapsable\"],\n group: \"Subheadings\",\n },\n toggle_heading_2: {\n title: \"Toggle Heading 2\",\n subtext: \"Toggleable key section heading\",\n aliases: [\"h2\", \"heading2\", \"subheading\", \"collapsable\"],\n group: \"Subheadings\",\n },\n toggle_heading_3: {\n title: \"Toggle Heading 3\",\n subtext: \"Toggleable subsection and group heading\",\n aliases: [\"h3\", \"heading3\", \"subheading\", \"collapsable\"],\n group: \"Subheadings\",\n },\n quote: {\n title: \"Quote\",\n subtext: \"Quote or excerpt\",\n aliases: [\"quotation\", \"blockquote\", \"bq\"],\n group: \"Basic blocks\",\n },\n toggle_list: {\n title: \"Toggle List\",\n subtext: \"List with hideable sub-items\",\n aliases: [\"li\", \"list\", \"toggleList\", \"toggle list\", \"collapsable list\"],\n group: \"Basic blocks\",\n },\n numbered_list: {\n title: \"Numbered List\",\n subtext: \"List with ordered items\",\n aliases: [\"ol\", \"li\", \"list\", \"numberedlist\", \"numbered list\"],\n group: \"Basic blocks\",\n },\n bullet_list: {\n title: \"Bullet List\",\n subtext: \"List with unordered items\",\n aliases: [\"ul\", \"li\", \"list\", \"bulletlist\", \"bullet list\"],\n group: \"Basic blocks\",\n },\n check_list: {\n title: \"Check List\",\n subtext: \"List with checkboxes\",\n aliases: [\n \"ul\",\n \"li\",\n \"list\",\n \"checklist\",\n \"check list\",\n \"checked list\",\n \"checkbox\",\n ],\n group: \"Basic blocks\",\n },\n paragraph: {\n title: \"Paragraph\",\n subtext: \"The body of your document\",\n aliases: [\"p\", \"paragraph\"],\n group: \"Basic blocks\",\n },\n code_block: {\n title: \"Code Block\",\n subtext: \"Code block with syntax highlighting\",\n aliases: [\"code\", \"pre\"],\n group: \"Basic blocks\",\n },\n page_break: {\n title: \"Page Break\",\n subtext: \"Page separator\",\n aliases: [\"page\", \"break\", \"separator\"],\n group: \"Basic blocks\",\n },\n table: {\n title: \"Table\",\n subtext: \"Table with editable cells\",\n aliases: [\"table\"],\n group: \"Advanced\",\n },\n image: {\n title: \"Image\",\n subtext: \"Resizable image with caption\",\n aliases: [\n \"image\",\n \"imageUpload\",\n \"upload\",\n \"img\",\n \"picture\",\n \"media\",\n \"url\",\n ],\n group: \"Media\",\n },\n video: {\n title: \"Video\",\n subtext: \"Resizable video with caption\",\n aliases: [\n \"video\",\n \"videoUpload\",\n \"upload\",\n \"mp4\",\n \"film\",\n \"media\",\n \"url\",\n ],\n group: \"Media\",\n },\n audio: {\n title: \"Audio\",\n subtext: \"Embedded audio with caption\",\n aliases: [\n \"audio\",\n \"audioUpload\",\n \"upload\",\n \"mp3\",\n \"sound\",\n \"media\",\n \"url\",\n ],\n group: \"Media\",\n },\n file: {\n title: \"File\",\n subtext: \"Embedded file\",\n aliases: [\"file\", \"upload\", \"embed\", \"media\", \"url\"],\n group: \"Media\",\n },\n emoji: {\n title: \"Emoji\",\n subtext: \"Search for and insert an emoji\",\n aliases: [\"emoji\", \"emote\", \"emotion\", \"face\"],\n group: \"Others\",\n },\n divider: {\n title: \"Divider\",\n subtext: \"Visually divide blocks\",\n aliases: [\"divider\", \"hr\", \"line\", \"horizontal rule\"],\n group: \"Basic blocks\",\n },\n },\n placeholders: {\n default: \"Enter text or type '/' for commands\",\n heading: \"Heading\",\n toggleListItem: \"Toggle\",\n bulletListItem: \"List\",\n numberedListItem: \"List\",\n checkListItem: \"List\",\n emptyDocument: undefined,\n new_comment: \"Write a comment...\",\n edit_comment: \"Edit comment...\",\n comment_reply: \"Add comment...\",\n } as Record<string, string | undefined>,\n file_blocks: {\n add_button_text: {\n image: \"Add image\",\n video: \"Add video\",\n audio: \"Add audio\",\n file: \"Add file\",\n } as Record<string, string>,\n },\n toggle_blocks: {\n add_block_button: \"Empty toggle. Click to add a block.\",\n },\n code_block: {\n add_source_button_text: \"Add source code\",\n ok_button_text: \"OK\",\n },\n // from react package:\n side_menu: {\n add_block_label: \"Add block\",\n drag_handle_label: \"Open block menu\",\n },\n drag_handle: {\n delete_menuitem: \"Delete\",\n colors_menuitem: \"Colors\",\n header_row_menuitem: \"Header row\",\n header_column_menuitem: \"Header column\",\n },\n table_handle: {\n delete_column_menuitem: \"Delete column\",\n delete_row_menuitem: \"Delete row\",\n add_left_menuitem: \"Add column left\",\n add_right_menuitem: \"Add column right\",\n add_above_menuitem: \"Add row above\",\n add_below_menuitem: \"Add row below\",\n split_cell_menuitem: \"Split cell\",\n merge_cells_menuitem: \"Merge cells\",\n background_color_menuitem: \"Background color\",\n },\n suggestion_menu: {\n no_items_title: \"No items found\",\n },\n color_picker: {\n text_title: \"Text\",\n background_title: \"Background\",\n colors: {\n default: \"Auto\",\n gray: \"Gray\",\n brown: \"Brown\",\n red: \"Red\",\n orange: \"Orange\",\n yellow: \"Yellow\",\n green: \"Green\",\n blue: \"Blue\",\n purple: \"Purple\",\n pink: \"Pink\",\n },\n },\n\n formatting_toolbar: {\n bold: {\n tooltip: \"Bold\",\n secondary_tooltip: \"Mod+B\",\n },\n italic: {\n tooltip: \"Italic\",\n secondary_tooltip: \"Mod+I\",\n },\n underline: {\n tooltip: \"Underline\",\n secondary_tooltip: \"Mod+U\",\n },\n strike: {\n tooltip: \"Strike\",\n secondary_tooltip: \"Mod+Shift+S\",\n },\n code: {\n tooltip: \"Code\",\n secondary_tooltip: \"\",\n },\n colors: {\n tooltip: \"Colors\",\n },\n link: {\n tooltip: \"Create link\",\n secondary_tooltip: \"Mod+K\",\n },\n file_caption: {\n tooltip: \"Edit caption\",\n input_placeholder: \"Edit caption\",\n },\n file_replace: {\n tooltip: {\n image: \"Replace image\",\n video: \"Replace video\",\n audio: \"Replace audio\",\n file: \"Replace file\",\n } as Record<string, string>,\n },\n file_rename: {\n tooltip: {\n image: \"Rename image\",\n video: \"Rename video\",\n audio: \"Rename audio\",\n file: \"Rename file\",\n } as Record<string, string>,\n input_placeholder: {\n image: \"Rename image\",\n video: \"Rename video\",\n audio: \"Rename audio\",\n file: \"Rename file\",\n } as Record<string, string>,\n },\n file_download: {\n tooltip: {\n image: \"Download image\",\n video: \"Download video\",\n audio: \"Download audio\",\n file: \"Download file\",\n } as Record<string, string>,\n },\n file_delete: {\n tooltip: {\n image: \"Delete image\",\n video: \"Delete video\",\n audio: \"Delete audio\",\n file: \"Delete file\",\n } as Record<string, string>,\n },\n file_preview_toggle: {\n tooltip: \"Toggle preview\",\n },\n nest: {\n tooltip: \"Nest block\",\n secondary_tooltip: \"Tab\",\n },\n unnest: {\n tooltip: \"Unnest block\",\n secondary_tooltip: \"Shift+Tab\",\n },\n align_left: {\n tooltip: \"Align text left\",\n },\n align_center: {\n tooltip: \"Align text center\",\n },\n align_right: {\n tooltip: \"Align text right\",\n },\n align_justify: {\n tooltip: \"Justify text\",\n },\n table_cell_merge: {\n tooltip: \"Merge cells\",\n },\n comment: {\n tooltip: \"Add comment\",\n },\n },\n file_panel: {\n upload: {\n title: \"Upload\",\n file_placeholder: {\n image: \"Upload image\",\n video: \"Upload video\",\n audio: \"Upload audio\",\n file: \"Upload file\",\n } as Record<string, string>,\n upload_error: \"Error: Upload failed\",\n },\n embed: {\n title: \"Embed\",\n embed_button: {\n image: \"Embed image\",\n video: \"Embed video\",\n audio: \"Embed audio\",\n file: \"Embed file\",\n } as Record<string, string>,\n url_placeholder: \"Enter URL\",\n },\n },\n link_toolbar: {\n delete: {\n tooltip: \"Remove link\",\n },\n edit: {\n text: \"Edit link\",\n tooltip: \"Edit\",\n },\n open: {\n tooltip: \"Open in new tab\",\n },\n form: {\n title_placeholder: \"Edit title\",\n url_placeholder: \"Edit URL\",\n },\n },\n comments: {\n edited: \"edited\",\n save_button_text: \"Save\",\n cancel_button_text: \"Cancel\",\n deleted_reference_text: \"Original content deleted\",\n discard_pending_comment: \"Are you sure you want to discard this comment?\",\n actions: {\n add_reaction: \"Add reaction\",\n resolve: \"Resolve\",\n reopen: \"Re-open\",\n edit_comment: \"Edit comment\",\n delete_comment: \"Delete comment\",\n more_actions: \"More actions\",\n },\n reactions: {\n reacted_by: \"Reacted by\",\n },\n sidebar: {\n marked_as_resolved: \"Marked as resolved\",\n more_replies: (count: number) => `${count} more replies`,\n },\n },\n suggestion_changes: {\n formatting_change: \"Formatting Change\",\n deleted: \"Deleted\",\n inserted_by: (users: string) => `Inserted by: ${users}`,\n deleted_by: (users: string) => `Deleted by: ${users}`,\n formatting_change_by: (formats: string, users: string) =>\n `Formatting change (${formats}) by: ${users}`,\n },\n exporter: {\n open_file: \"Open file\",\n open_video_file: \"Open video\",\n open_audio_file: \"Open audio\",\n },\n generic: {\n ctrl_shortcut: \"Ctrl\",\n },\n};\n"],"mappings":"AAAA,IAAa,EAAK,CAChB,WAAY,CACV,QAAS,CACP,MAAO,YACP,QAAS,oBACT,QAAS,CAAC,IAAK,WAAY,IAAI,EAC/B,MAAO,UACT,EACA,UAAW,CACT,MAAO,YACP,Q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AW,EAC1B,MAAO,cACT,EACA,WAAY,CACV,MAAO,aACP,QAAS,sCACT,QAAS,CAAC,OAAQ,KAAK,EACvB,MAAO,cACT,EACA,WAAY,CACV,MAAO,aACP,QAAS,iBACT,QAAS,CAAC,OAAQ,QAAS,WAAW,EACtC,MAAO,cACT,EACA,MAAO,CACL,MAAO,QACP,QAAS,4BACT,QAAS,CAAC,OAAO,EACjB,MAAO,UACT,EACA,MAAO,CACL,MAAO,QACP,QAAS,+BACT,QAAS,CACP,QACA,cACA,SACA,MACA,UACA,QACA,KACF,EACA,MAAO,OACT,EACA,MAAO,CACL,MAAO,QACP,QAAS,+BACT,QAAS,CACP,QACA,cACA,SACA,MACA,OACA,QACA,KACF,EACA,MAAO,OACT,EACA,MAAO,CACL,MAAO,QACP,QAAS,8BACT,QAAS,CACP,QACA,cACA,SACA,MACA,QACA,QACA,KACF,EACA,MAAO,OACT,EACA,KAAM,CACJ,MAAO,OACP,QAAS,gBACT,QAAS,CAAC,OAAQ,SAAU,QAAS,QAAS,KAAK,EACnD,MAAO,OACT,EACA,MAAO,CACL,MAAO,QACP,QAAS,iCACT,QAAS,CAAC,QAAS,QAAS,UAAW,MAAM,EAC7C,MAAO,QACT,EACA,QAAS,CACP,MAAO,UACP,QAAS,yBACT,QAAS,CAAC,UAAW,KAAM,OAAQ,iBAAiB,EACpD,MAAO,cACT,CACF,EACA,aAAc,CACZ,QAAS,sCACT,QAAS,UACT,eAAgB,SAChB,eAAgB,OAChB,iBAAkB,OAClB,cAAe,OACf,cAAe,IAAA,GACf,YAAa,qBACb,aAAc,kBACd,cAAe,gBACjB,EACA,YAAa,CACX,gBAAiB,CACf,MAAO,YACP,MAAO,YACP,MAAO,YACP,KAAM,UACR,CACF,EACA,cAAe,CACb,iBAAkB,qCACpB,EACA,WAAY,CACV,uBAAwB,kBACxB,eAAgB,IAClB,EAEA,UAAW,CACT,gBAAiB,YACjB,kBAAmB,iBACrB,EACA,YAAa,CACX,gBAAiB,SACjB,gBAAi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ACV,QAAS,iBACX,EACA,aAAc,CACZ,QAAS,mBACX,EACA,YAAa,CACX,QAAS,kBACX,EACA,cAAe,CACb,QAAS,cACX,EACA,iBAAkB,CAChB,QAAS,aACX,EACA,QAAS,CACP,QAAS,aACX,CACF,EACA,WAAY,CACV,OAAQ,CACN,MAAO,SACP,iBAAkB,CAChB,MAAO,eACP,MAAO,eACP,MAAO,eACP,KAAM,aACR,EACA,aAAc,sBAChB,EACA,MAAO,CACL,MAAO,QACP,aAAc,CACZ,MAAO,cACP,MAAO,cACP,MAAO,cACP,KAAM,YACR,EACA,gBAAiB,WACnB,CACF,EACA,aAAc,CACZ,OAAQ,CACN,QAAS,aACX,EACA,KAAM,CACJ,KAAM,YACN,QAAS,MACX,EACA,KAAM,CACJ,QAAS,iBACX,EACA,KAAM,CACJ,kBAAmB,aACnB,gBAAiB,UACnB,CACF,EACA,SAAU,CACR,OAAQ,SACR,iBAAkB,OAClB,mBAAoB,SACpB,uBAAwB,2BACxB,wBAAyB,iDACzB,QAAS,CACP,aAAc,eACd,QAAS,UACT,OAAQ,UACR,aAAc,eACd,eAAgB,iBAChB,aAAc,cAChB,EACA,UAAW,CACT,WAAY,YACd,EACA,QAAS,CACP,mBAAoB,qBACpB,aAAe,GAAkB,GAAG,EAAM,cAC5C,CACF,EACA,mBAAoB,CAClB,kBAAmB,oBACnB,QAAS,UACT,YAAc,GAAkB,gBAAgB,IAChD,WAAa,GAAkB,eAAe,IAC9C,sBAAuB,EAAiB,IACtC,sBAAsB,EAAQ,QAAQ,GAC1C,EACA,SAAU,CACR,UAAW,YACX,gBAAiB,aACjB,gBAAiB,YACnB,EACA,QAAS,CACP,cAAe,MACjB,CACF"}
@@ -278,6 +278,10 @@ var e = {
278
278
  file: "Add file"
279
279
  } },
280
280
  toggle_blocks: { add_block_button: "Empty toggle. Click to add a block." },
281
+ code_block: {
282
+ add_source_button_text: "Add source code",
283
+ ok_button_text: "OK"
284
+ },
281
285
  side_menu: {
282
286
  add_block_label: "Add block",
283
287
  drag_handle_label: "Open block menu"
@@ -455,9 +459,14 @@ var e = {
455
459
  deleted_by: (e) => `Deleted by: ${e}`,
456
460
  formatting_change_by: (e, t) => `Formatting change (${e}) by: ${t}`
457
461
  },
462
+ exporter: {
463
+ open_file: "Open file",
464
+ open_video_file: "Open video",
465
+ open_audio_file: "Open audio"
466
+ },
458
467
  generic: { ctrl_shortcut: "Ctrl" }
459
468
  };
460
469
  //#endregion
461
470
  export { e as t };
462
471
 
463
- //# sourceMappingURL=en-CGKXfWma.js.map
472
+ //# sourceMappingURL=en-uzHzj6eH.js.map