@blocknote/core 0.38.0 → 0.39.1-capitol

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 (239) hide show
  1. package/dist/BlockNoteSchema-Bsa_tSAC.cjs +11 -0
  2. package/dist/BlockNoteSchema-Bsa_tSAC.cjs.map +1 -0
  3. package/dist/BlockNoteSchema-CZez1nQf.js +4244 -0
  4. package/dist/BlockNoteSchema-CZez1nQf.js.map +1 -0
  5. package/dist/blocknote.cjs +4 -12
  6. package/dist/blocknote.cjs.map +1 -1
  7. package/dist/blocknote.js +3401 -7305
  8. package/dist/blocknote.js.map +1 -1
  9. package/dist/blocks.cjs +2 -0
  10. package/dist/blocks.cjs.map +1 -0
  11. package/dist/blocks.js +71 -0
  12. package/dist/blocks.js.map +1 -0
  13. package/dist/style.css +1 -1
  14. package/dist/webpack-stats.json +1 -1
  15. package/package.json +19 -17
  16. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
  17. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +2 -2
  18. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +34 -25
  19. package/src/api/blockManipulation/setupTestEnv.ts +0 -1
  20. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +6 -10
  21. package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
  22. package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
  23. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +128 -28
  24. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +101 -41
  25. package/src/api/pmUtil.ts +1 -1
  26. package/src/api/positionMapping.test.ts +58 -15
  27. package/src/api/positionMapping.ts +2 -4
  28. package/src/blocks/Audio/block.ts +174 -0
  29. package/src/blocks/BlockNoteSchema.ts +59 -0
  30. package/src/blocks/Code/block.ts +299 -0
  31. package/src/blocks/File/block.ts +98 -0
  32. package/src/blocks/{FileBlockContent → File}/helpers/render/createAddFileButton.ts +5 -2
  33. package/src/blocks/{FileBlockContent → File}/helpers/render/createFileBlockWrapper.ts +15 -6
  34. package/src/blocks/{FileBlockContent → File}/helpers/render/createFileNameWithIcon.ts +15 -2
  35. package/src/blocks/{FileBlockContent → File}/helpers/render/createResizableFileBlockWrapper.ts +21 -2
  36. package/src/blocks/Heading/block.ts +138 -0
  37. package/src/blocks/Image/block.ts +190 -0
  38. package/src/blocks/ListItem/BulletListItem/block.ts +116 -0
  39. package/src/blocks/ListItem/CheckListItem/block.ts +175 -0
  40. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +173 -0
  41. package/src/blocks/ListItem/NumberedListItem/block.ts +133 -0
  42. package/src/blocks/ListItem/ToggleListItem/block.ts +78 -0
  43. package/src/blocks/PageBreak/block.ts +72 -0
  44. package/src/blocks/{PageBreakBlockContent → PageBreak}/getPageBreakSlashMenuItems.ts +9 -7
  45. package/src/blocks/Paragraph/block.ts +80 -0
  46. package/src/blocks/Quote/block.ts +90 -0
  47. package/src/blocks/{TableBlockContent/TableBlockContent.ts → Table/block.ts} +169 -51
  48. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +1 -1
  49. package/src/blocks/Video/block.ts +143 -0
  50. package/src/blocks/defaultBlockHelpers.ts +2 -2
  51. package/src/blocks/defaultBlockTypeGuards.ts +143 -174
  52. package/src/blocks/defaultBlocks.ts +107 -35
  53. package/src/blocks/defaultProps.ts +145 -4
  54. package/src/blocks/index.ts +26 -0
  55. package/src/blocks/utils/listItemEnterHandler.ts +42 -0
  56. package/src/editor/Block.css +54 -18
  57. package/src/editor/BlockNoteEditor.ts +256 -211
  58. package/src/editor/BlockNoteExtension.ts +92 -0
  59. package/src/editor/BlockNoteExtensions.ts +18 -17
  60. package/src/editor/defaultColors.ts +2 -2
  61. package/src/exporter/Exporter.ts +1 -1
  62. package/src/exporter/mapping.ts +1 -1
  63. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +3 -20
  64. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +6 -8
  65. package/src/extensions/BlockChange/BlockChangePlugin.ts +2 -1
  66. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +2 -2
  67. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +2 -2
  68. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
  69. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
  70. package/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.ts +52 -0
  71. package/src/extensions/Collaboration/schemaMigration/migrationRules/index.ts +4 -0
  72. package/src/extensions/Collaboration/schemaMigration/migrationRules/migrationRule.ts +4 -0
  73. package/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.ts +78 -0
  74. package/src/extensions/Comments/CommentsPlugin.ts +1 -1
  75. package/src/extensions/FilePanel/FilePanelPlugin.ts +5 -10
  76. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +1 -1
  77. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +4 -3
  78. package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
  79. package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +1 -23
  80. package/src/extensions/SideMenu/SideMenuPlugin.ts +1 -3
  81. package/src/extensions/SideMenu/dragging.ts +2 -2
  82. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +4 -7
  83. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +6 -2
  84. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +24 -17
  85. package/src/extensions/TableHandles/TableHandlesPlugin.ts +8 -8
  86. package/src/extensions/TextAlignment/TextAlignmentExtension.ts +5 -11
  87. package/src/extensions/TextColor/TextColorExtension.ts +3 -17
  88. package/src/extensions/TextColor/TextColorMark.ts +4 -9
  89. package/src/extensions/UniqueID/UniqueID.ts +6 -13
  90. package/src/index.ts +2 -28
  91. package/src/schema/blocks/createSpec.ts +342 -169
  92. package/src/schema/blocks/internal.ts +77 -138
  93. package/src/schema/blocks/types.ts +264 -94
  94. package/src/schema/index.ts +1 -0
  95. package/src/schema/inlineContent/createSpec.ts +99 -21
  96. package/src/schema/inlineContent/internal.ts +16 -7
  97. package/src/schema/inlineContent/types.ts +24 -2
  98. package/src/schema/propTypes.ts +15 -9
  99. package/src/schema/schema.ts +209 -0
  100. package/src/schema/styles/createSpec.ts +79 -31
  101. package/src/schema/styles/internal.ts +61 -2
  102. package/src/schema/styles/types.ts +17 -3
  103. package/src/util/topo-sort.test.ts +125 -0
  104. package/src/util/topo-sort.ts +160 -0
  105. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -1
  106. package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
  107. package/types/src/api/blockManipulation/setupTestEnv.d.ts +29 -543
  108. package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +1 -1
  109. package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +1 -1
  110. package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +2 -0
  111. package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +6 -0
  112. package/types/src/api/pmUtil.d.ts +1 -1
  113. package/types/src/blocks/Audio/block.d.ts +58 -0
  114. package/types/src/blocks/BlockNoteSchema.d.ts +18 -0
  115. package/types/src/blocks/{CodeBlockContent/CodeBlockContent.d.ts → Code/block.d.ts} +25 -26
  116. package/types/src/blocks/Code/shiki.d.ts +4 -0
  117. package/types/src/blocks/Divider/block.d.ts +3 -0
  118. package/types/src/blocks/File/block.d.ts +37 -0
  119. package/types/src/blocks/File/helpers/render/createAddFileButton.d.ts +6 -0
  120. package/types/src/blocks/File/helpers/render/createFileBlockWrapper.d.ts +25 -0
  121. package/types/src/blocks/{FileBlockContent → File}/helpers/render/createFileNameWithIcon.d.ts +6 -2
  122. package/types/src/blocks/File/helpers/render/createResizableFileBlockWrapper.d.ts +31 -0
  123. package/types/src/blocks/Heading/block.d.ts +71 -0
  124. package/types/src/blocks/Image/block.d.ts +102 -0
  125. package/types/src/blocks/ListItem/BulletListItem/block.d.ts +25 -0
  126. package/types/src/blocks/ListItem/CheckListItem/block.d.ts +33 -0
  127. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.d.ts +8 -0
  128. package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +33 -0
  129. package/types/src/blocks/ListItem/ToggleListItem/block.d.ts +25 -0
  130. package/types/src/blocks/PageBreak/block.d.ts +11 -0
  131. package/types/src/blocks/{PageBreakBlockContent → PageBreak}/getPageBreakSlashMenuItems.d.ts +4 -2
  132. package/types/src/blocks/Paragraph/block.d.ts +25 -0
  133. package/types/src/blocks/Quote/block.d.ts +17 -0
  134. package/types/src/blocks/Table/block.d.ts +21 -0
  135. package/types/src/blocks/Video/block.d.ts +67 -0
  136. package/types/src/blocks/defaultBlockHelpers.d.ts +1 -1
  137. package/types/src/blocks/defaultBlockTypeGuards.d.ts +15 -36
  138. package/types/src/blocks/defaultBlocks.d.ts +221 -1060
  139. package/types/src/blocks/defaultProps.d.ts +17 -1
  140. package/types/src/blocks/index.d.ts +24 -0
  141. package/types/src/blocks/utils/listItemEnterHandler.d.ts +2 -0
  142. package/types/src/editor/BlockNoteEditor.d.ts +36 -67
  143. package/types/src/editor/BlockNoteExtension.d.ts +67 -0
  144. package/types/src/editor/BlockNoteExtensions.d.ts +1 -1
  145. package/types/src/editor/defaultColors.d.ts +8 -76
  146. package/types/src/editor/managers/BlockManager.d.ts +114 -0
  147. package/types/src/editor/managers/CollaborationManager.d.ts +115 -0
  148. package/types/src/editor/managers/EventManager.d.ts +58 -0
  149. package/types/src/editor/managers/ExportManager.d.ts +64 -0
  150. package/types/src/editor/managers/ExtensionManager.d.ts +68 -0
  151. package/types/src/editor/managers/SelectionManager.d.ts +54 -0
  152. package/types/src/editor/managers/StateManager.d.ts +115 -0
  153. package/types/src/editor/managers/StyleManager.d.ts +48 -0
  154. package/types/src/editor/managers/index.d.ts +8 -0
  155. package/types/src/exporter/Exporter.d.ts +1 -1
  156. package/types/src/exporter/mapping.d.ts +1 -1
  157. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +4 -1
  158. package/types/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.d.ts +7 -0
  159. package/types/src/extensions/Collaboration/schemaMigration/migrationRules/index.d.ts +3 -0
  160. package/types/src/extensions/Collaboration/schemaMigration/migrationRules/migrationRule.d.ts +3 -0
  161. package/types/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.d.ts +2 -0
  162. package/types/src/extensions/Comments/CommentsPlugin.d.ts +1 -1
  163. package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +4 -4
  164. package/types/src/extensions/TextColor/TextColorMark.d.ts +4 -1
  165. package/types/src/index.d.ts +2 -25
  166. package/types/src/schema/blocks/createSpec.d.ts +16 -36
  167. package/types/src/schema/blocks/internal.d.ts +11 -33
  168. package/types/src/schema/blocks/types.d.ts +181 -57
  169. package/types/src/schema/index.d.ts +1 -0
  170. package/types/src/schema/inlineContent/createSpec.d.ts +36 -2
  171. package/types/src/schema/inlineContent/internal.d.ts +7 -15
  172. package/types/src/schema/inlineContent/types.d.ts +15 -1
  173. package/types/src/schema/propTypes.d.ts +4 -4
  174. package/types/src/schema/schema.d.ts +40 -0
  175. package/types/src/schema/styles/createSpec.d.ts +6 -4
  176. package/types/src/schema/styles/internal.d.ts +6 -3
  177. package/types/src/schema/styles/types.d.ts +11 -2
  178. package/types/src/util/topo-sort.d.ts +18 -0
  179. package/types/src/util/topo-sort.test.d.ts +1 -0
  180. package/dist/tsconfig.tsbuildinfo +0 -1
  181. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +0 -144
  182. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +0 -445
  183. package/src/blocks/FileBlockContent/FileBlockContent.ts +0 -100
  184. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +0 -159
  185. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +0 -159
  186. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +0 -134
  187. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +0 -299
  188. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +0 -86
  189. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +0 -172
  190. package/src/blocks/ListItemBlockContent/ToggleListItemBlockContent/ToggleListItemBlockContent.ts +0 -104
  191. package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +0 -49
  192. package/src/blocks/PageBreakBlockContent/schema.ts +0 -40
  193. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +0 -78
  194. package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +0 -121
  195. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +0 -158
  196. package/src/editor/BlockNoteSchema.ts +0 -107
  197. package/src/editor/BlockNoteTipTapEditor.ts +0 -335
  198. package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +0 -99
  199. package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +0 -90
  200. package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +0 -6
  201. package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +0 -9
  202. package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +0 -9
  203. package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +0 -67
  204. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +0 -131
  205. package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +0 -46
  206. package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +0 -55
  207. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +0 -2
  208. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +0 -58
  209. package/types/src/blocks/ListItemBlockContent/ToggleListItemBlockContent/ToggleListItemBlockContent.d.ts +0 -46
  210. package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +0 -31
  211. package/types/src/blocks/PageBreakBlockContent/schema.d.ts +0 -86
  212. package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +0 -52
  213. package/types/src/blocks/QuoteBlockContent/QuoteBlockContent.d.ts +0 -52
  214. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -39
  215. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +0 -131
  216. package/types/src/editor/BlockNoteSchema.d.ts +0 -34
  217. package/types/src/editor/BlockNoteTipTapEditor.d.ts +0 -43
  218. /package/src/blocks/{AudioBlockContent → Audio}/parseAudioElement.ts +0 -0
  219. /package/src/blocks/{FileBlockContent → File}/helpers/parse/parseEmbedElement.ts +0 -0
  220. /package/src/blocks/{FileBlockContent → File}/helpers/parse/parseFigureElement.ts +0 -0
  221. /package/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createFigureWithCaption.ts +0 -0
  222. /package/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createLinkWithCaption.ts +0 -0
  223. /package/src/blocks/{FileBlockContent → File/helpers}/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -0
  224. /package/src/blocks/{ImageBlockContent → Image}/parseImageElement.ts +0 -0
  225. /package/src/blocks/{ListItemBlockContent → ListItem}/ListItemKeyboardShortcuts.ts +0 -0
  226. /package/src/blocks/{ListItemBlockContent → ListItem}/getListItemContent.ts +0 -0
  227. /package/src/blocks/{TableBlockContent → Table}/TableExtension.ts +0 -0
  228. /package/src/blocks/{VideoBlockContent → Video}/parseVideoElement.ts +0 -0
  229. /package/types/src/blocks/{AudioBlockContent → Audio}/parseAudioElement.d.ts +0 -0
  230. /package/types/src/blocks/{FileBlockContent → File}/helpers/parse/parseEmbedElement.d.ts +0 -0
  231. /package/types/src/blocks/{FileBlockContent → File}/helpers/parse/parseFigureElement.d.ts +0 -0
  232. /package/types/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createFigureWithCaption.d.ts +0 -0
  233. /package/types/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createLinkWithCaption.d.ts +0 -0
  234. /package/types/src/blocks/{FileBlockContent → File/helpers}/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -0
  235. /package/types/src/blocks/{ImageBlockContent → Image}/parseImageElement.d.ts +0 -0
  236. /package/types/src/blocks/{ListItemBlockContent → ListItem}/ListItemKeyboardShortcuts.d.ts +0 -0
  237. /package/types/src/blocks/{ListItemBlockContent → ListItem}/getListItemContent.d.ts +0 -0
  238. /package/types/src/blocks/{TableBlockContent → Table}/TableExtension.d.ts +0 -0
  239. /package/types/src/blocks/{VideoBlockContent → Video}/parseVideoElement.d.ts +0 -0
@@ -0,0 +1,4244 @@
1
+ var ut = Object.defineProperty;
2
+ var dt = (e, t, n) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var x = (e, t, n) => dt(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { TableMap as Re, goToNextCell as xe, columnResizing as pt, tableEditing as ft, TableView as ht, CellSelection as mt } from "prosemirror-tables";
5
+ import gt from "@tiptap/extension-bold";
6
+ import bt from "@tiptap/extension-code";
7
+ import Ct from "@tiptap/extension-italic";
8
+ import kt from "@tiptap/extension-strike";
9
+ import yt from "@tiptap/extension-underline";
10
+ import { Extension as Ve, combineTransactionSteps as wt, getChangedRanges as vt, findChildrenInRange as Et, Node as D, Mark as xt, callOrReturn as St, getExtensionField as Bt, mergeAttributes as le } from "@tiptap/core";
11
+ import { Slice as ue, Fragment as _, DOMParser as Q, DOMSerializer as Se } from "prosemirror-model";
12
+ import { Plugin as We, PluginKey as Fe, TextSelection as je } from "prosemirror-state";
13
+ import { v4 as Mt } from "uuid";
14
+ import { ReplaceStep as Lt } from "prosemirror-transform";
15
+ import { DecorationSet as Be, Decoration as Tt } from "prosemirror-view";
16
+ function At(e, t = JSON.stringify) {
17
+ const n = {};
18
+ return e.filter((o) => {
19
+ const r = t(o);
20
+ return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
21
+ });
22
+ }
23
+ function Nt(e) {
24
+ const t = e.filter(
25
+ (o, r) => e.indexOf(o) !== r
26
+ );
27
+ return At(t);
28
+ }
29
+ const $e = Ve.create({
30
+ name: "uniqueID",
31
+ // we’ll set a very high priority to make sure this runs first
32
+ // and is compatible with `appendTransaction` hooks of other extensions
33
+ priority: 1e4,
34
+ addOptions() {
35
+ return {
36
+ attributeName: "id",
37
+ types: [],
38
+ setIdAttribute: !1,
39
+ generateID: () => {
40
+ if (typeof window < "u" && window.__TEST_OPTIONS) {
41
+ const e = window.__TEST_OPTIONS;
42
+ return e.mockID === void 0 ? e.mockID = 0 : e.mockID++, e.mockID.toString();
43
+ }
44
+ return Mt();
45
+ },
46
+ filterTransaction: null
47
+ };
48
+ },
49
+ addGlobalAttributes() {
50
+ return [
51
+ {
52
+ types: this.options.types,
53
+ attributes: {
54
+ [this.options.attributeName]: {
55
+ default: null,
56
+ parseHTML: (e) => e.getAttribute(`data-${this.options.attributeName}`),
57
+ renderHTML: (e) => {
58
+ const t = {
59
+ [`data-${this.options.attributeName}`]: e[this.options.attributeName]
60
+ };
61
+ return this.options.setIdAttribute ? {
62
+ ...t,
63
+ id: e[this.options.attributeName]
64
+ } : t;
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ];
70
+ },
71
+ // check initial content for missing ids
72
+ // onCreate() {
73
+ // // Don’t do this when the collaboration extension is active
74
+ // // because this may update the content, so Y.js tries to merge these changes.
75
+ // // This leads to empty block nodes.
76
+ // // See: https://github.com/ueberdosis/tiptap/issues/2400
77
+ // if (
78
+ // this.editor.extensionManager.extensions.find(
79
+ // (extension) => extension.name === "collaboration"
80
+ // )
81
+ // ) {
82
+ // return;
83
+ // }
84
+ // const { view, state } = this.editor;
85
+ // const { tr, doc } = state;
86
+ // const { types, attributeName, generateID } = this.options;
87
+ // const nodesWithoutId = findChildren(doc, (node) => {
88
+ // return (
89
+ // types.includes(node.type.name) && node.attrs[attributeName] === null
90
+ // );
91
+ // });
92
+ // nodesWithoutId.forEach(({ node, pos }) => {
93
+ // tr.setNodeMarkup(pos, undefined, {
94
+ // ...node.attrs,
95
+ // [attributeName]: generateID(),
96
+ // });
97
+ // });
98
+ // tr.setMeta("addToHistory", false);
99
+ // view.dispatch(tr);
100
+ // },
101
+ addProseMirrorPlugins() {
102
+ let e = null, t = !1;
103
+ return [
104
+ new We({
105
+ key: new Fe("uniqueID"),
106
+ appendTransaction: (n, o, r) => {
107
+ const s = n.some((h) => h.docChanged) && !o.doc.eq(r.doc), a = this.options.filterTransaction && n.some((h) => {
108
+ var C, m;
109
+ return !((m = (C = this.options).filterTransaction) != null && m.call(C, h));
110
+ });
111
+ if (!s || a)
112
+ return;
113
+ const { tr: i } = r, { types: c, attributeName: l, generateID: d } = this.options, u = wt(
114
+ o.doc,
115
+ n
116
+ ), { mapping: p } = u;
117
+ if (vt(u).forEach(({ newRange: h }) => {
118
+ const C = Et(
119
+ r.doc,
120
+ h,
121
+ (y) => c.includes(y.type.name)
122
+ ), m = C.map(({ node: y }) => y.attrs[l]).filter((y) => y !== null), b = Nt(m);
123
+ C.forEach(({ node: y, pos: g }) => {
124
+ var V;
125
+ const w = (V = i.doc.nodeAt(g)) == null ? void 0 : V.attrs[l];
126
+ if (w === null) {
127
+ const W = o.doc.type.createAndFill().content;
128
+ if (o.doc.content.findDiffStart(W) === null) {
129
+ const Ee = JSON.parse(
130
+ JSON.stringify(r.doc.toJSON())
131
+ );
132
+ if (Ee.content[0].content[0].attrs.id = "initialBlockId", JSON.stringify(Ee.content) === JSON.stringify(W.toJSON())) {
133
+ i.setNodeMarkup(g, void 0, {
134
+ ...y.attrs,
135
+ [l]: "initialBlockId"
136
+ });
137
+ return;
138
+ }
139
+ }
140
+ i.setNodeMarkup(g, void 0, {
141
+ ...y.attrs,
142
+ [l]: d()
143
+ });
144
+ return;
145
+ }
146
+ const { deleted: S } = p.invert().mapResult(g);
147
+ S && b.includes(w) && i.setNodeMarkup(g, void 0, {
148
+ ...y.attrs,
149
+ [l]: d()
150
+ });
151
+ });
152
+ }), !!i.steps.length)
153
+ return i.setMeta("uniqueID", !0), i;
154
+ },
155
+ // we register a global drag handler to track the current drag source element
156
+ view(n) {
157
+ const o = (r) => {
158
+ let s;
159
+ e = !((s = n.dom.parentElement) === null || s === void 0) && s.contains(r.target) ? n.dom.parentElement : null;
160
+ };
161
+ return window.addEventListener("dragstart", o), {
162
+ destroy() {
163
+ window.removeEventListener("dragstart", o);
164
+ }
165
+ };
166
+ },
167
+ props: {
168
+ // `handleDOMEvents` is called before `transformPasted` so we can do
169
+ // some checks before. However, `transformPasted` only runs when
170
+ // editor content is pasted - not external content.
171
+ handleDOMEvents: {
172
+ // only create new ids for dropped content while holding `alt`
173
+ // or content is dragged from another editor
174
+ drop: (n, o) => {
175
+ let r;
176
+ return e !== n.dom.parentElement || ((r = o.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy" ? t = !0 : t = !1, e = null, !1;
177
+ },
178
+ // always create new ids on pasted content
179
+ paste: () => (t = !0, !1)
180
+ },
181
+ // we’ll remove ids for every pasted node
182
+ // so we can create a new one within `appendTransaction`
183
+ transformPasted: (n) => {
184
+ if (!t)
185
+ return n;
186
+ const { types: o, attributeName: r } = this.options, s = (a) => {
187
+ const i = [];
188
+ return a.forEach((c) => {
189
+ if (c.isText) {
190
+ i.push(c);
191
+ return;
192
+ }
193
+ if (!o.includes(c.type.name)) {
194
+ i.push(c.copy(s(c.content)));
195
+ return;
196
+ }
197
+ const l = c.type.create(
198
+ {
199
+ ...c.attrs,
200
+ [r]: null
201
+ },
202
+ s(c.content),
203
+ c.marks
204
+ );
205
+ i.push(l);
206
+ }), _.from(i);
207
+ };
208
+ return t = !1, new ue(
209
+ s(n.content),
210
+ n.openStart,
211
+ n.openEnd
212
+ );
213
+ }
214
+ }
215
+ })
216
+ ];
217
+ }
218
+ });
219
+ function Me(e) {
220
+ return e.type === "link";
221
+ }
222
+ function Ue(e) {
223
+ return typeof e != "string" && e.type === "link";
224
+ }
225
+ function I(e) {
226
+ return typeof e != "string" && e.type === "text";
227
+ }
228
+ function re(e) {
229
+ var t, n, o, r, s;
230
+ return de(e) ? { ...e } : j(e) ? {
231
+ type: "tableCell",
232
+ content: [].concat(e.content),
233
+ props: {
234
+ backgroundColor: ((t = e.props) == null ? void 0 : t.backgroundColor) ?? "default",
235
+ textColor: ((n = e.props) == null ? void 0 : n.textColor) ?? "default",
236
+ textAlignment: ((o = e.props) == null ? void 0 : o.textAlignment) ?? "left",
237
+ colspan: ((r = e.props) == null ? void 0 : r.colspan) ?? 1,
238
+ rowspan: ((s = e.props) == null ? void 0 : s.rowspan) ?? 1
239
+ }
240
+ } : {
241
+ type: "tableCell",
242
+ content: [].concat(e),
243
+ props: {
244
+ backgroundColor: "default",
245
+ textColor: "default",
246
+ textAlignment: "left",
247
+ colspan: 1,
248
+ rowspan: 1
249
+ }
250
+ };
251
+ }
252
+ function j(e) {
253
+ return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
254
+ }
255
+ function de(e) {
256
+ return j(e) && e.props !== void 0 && e.content !== void 0;
257
+ }
258
+ function $(e) {
259
+ return de(e) ? e.props.colspan ?? 1 : 1;
260
+ }
261
+ function se(e) {
262
+ return de(e) ? e.props.rowspan ?? 1 : 1;
263
+ }
264
+ class Z extends Error {
265
+ constructor(t) {
266
+ super(`Unreachable case: ${t}`);
267
+ }
268
+ }
269
+ function To(e, t = !0) {
270
+ const { "data-test": n, ...o } = e;
271
+ if (Object.keys(o).length > 0 && t)
272
+ throw new Error("Object must be empty " + JSON.stringify(e));
273
+ }
274
+ const It = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
275
+ function L(e, t = "Ctrl") {
276
+ return It() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
277
+ }
278
+ function U(...e) {
279
+ return [
280
+ // Converts to & from set to remove duplicates.
281
+ ...new Set(
282
+ e.filter((t) => t).join(" ").split(" ")
283
+ )
284
+ ].join(" ");
285
+ }
286
+ const Ao = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
287
+ function Ot(e, t, n, o) {
288
+ const r = document.createElement("div");
289
+ r.className = U(
290
+ "bn-block-content",
291
+ n.class
292
+ ), r.setAttribute("data-content-type", e);
293
+ for (const [a, i] of Object.entries(n))
294
+ a !== "class" && r.setAttribute(a, i);
295
+ const s = document.createElement(t);
296
+ s.className = U(
297
+ "bn-inline-content",
298
+ o.class
299
+ );
300
+ for (const [a, i] of Object.entries(
301
+ o
302
+ ))
303
+ a !== "class" && s.setAttribute(a, i);
304
+ return r.appendChild(s), {
305
+ dom: r,
306
+ contentDOM: s
307
+ };
308
+ }
309
+ const Le = (e, t) => {
310
+ let n = Y(e, t.pmSchema);
311
+ n.type.name === "blockContainer" && (n = n.firstChild);
312
+ const o = t.pmSchema.nodes[n.type.name].spec.toDOM;
313
+ if (o === void 0)
314
+ throw new Error(
315
+ "This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
316
+ );
317
+ const r = o(n);
318
+ if (typeof r != "object" || !("dom" in r))
319
+ throw new Error(
320
+ "Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property."
321
+ );
322
+ return r;
323
+ };
324
+ function Ht(e, t = "<br>") {
325
+ const n = e.querySelectorAll("p");
326
+ if (n.length > 1) {
327
+ const o = n[0];
328
+ for (let r = 1; r < n.length; r++) {
329
+ const s = n[r];
330
+ o.innerHTML += t + s.innerHTML, s.remove();
331
+ }
332
+ }
333
+ }
334
+ function K(e) {
335
+ return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
336
+ }
337
+ function No(e) {
338
+ const t = e.split("/");
339
+ return !t.length || // invalid?
340
+ t[t.length - 1] === "" ? e : t[t.length - 1];
341
+ }
342
+ function Pt(e) {
343
+ const t = {};
344
+ return Object.entries(e).forEach(([n, o]) => {
345
+ t[n] = {
346
+ default: o.default,
347
+ keepOnSplit: !0,
348
+ // Props are displayed in kebab-case as HTML attributes. If a prop's
349
+ // value is the same as its default, we don't display an HTML
350
+ // attribute for it.
351
+ parseHTML: (r) => {
352
+ const s = r.getAttribute(K(n));
353
+ if (s === null)
354
+ return null;
355
+ if (o.default === void 0 && o.type === "boolean" || o.default !== void 0 && typeof o.default == "boolean")
356
+ return s === "true" ? !0 : s === "false" ? !1 : null;
357
+ if (o.default === void 0 && o.type === "number" || o.default !== void 0 && typeof o.default == "number") {
358
+ const a = parseFloat(s);
359
+ return !Number.isNaN(a) && Number.isFinite(a) ? a : null;
360
+ }
361
+ return s;
362
+ },
363
+ renderHTML: (r) => r[n] !== o.default ? {
364
+ [K(n)]: r[n]
365
+ } : {}
366
+ };
367
+ }), t;
368
+ }
369
+ function Dt(e, t, n, o) {
370
+ const r = e();
371
+ if (r === void 0)
372
+ throw new Error("Cannot find node position");
373
+ const a = n.state.doc.resolve(r).node().attrs.id;
374
+ if (!a)
375
+ throw new Error("Block doesn't have id");
376
+ const i = t.getBlock(a);
377
+ if (i.type !== o)
378
+ throw new Error("Block type does not match");
379
+ return i;
380
+ }
381
+ function ae(e, t, n, o, r = !1, s) {
382
+ const a = document.createElement("div");
383
+ if (s !== void 0)
384
+ for (const [i, c] of Object.entries(s))
385
+ i !== "class" && a.setAttribute(i, c);
386
+ a.className = U(
387
+ "bn-block-content",
388
+ (s == null ? void 0 : s.class) || ""
389
+ ), a.setAttribute("data-content-type", t);
390
+ for (const [i, c] of Object.entries(n)) {
391
+ const d = o[i].default;
392
+ c !== d && a.setAttribute(K(i), c);
393
+ }
394
+ return r && a.setAttribute("data-file-block", ""), a.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = U(
395
+ "bn-inline-content",
396
+ e.contentDOM.className
397
+ )), {
398
+ ...e,
399
+ dom: a
400
+ };
401
+ }
402
+ function _t(e, t, n) {
403
+ return {
404
+ config: {
405
+ type: e.type,
406
+ content: e.content,
407
+ propSchema: t
408
+ },
409
+ implementation: {
410
+ node: e.node,
411
+ render: Le,
412
+ toExternalHTML: Le
413
+ },
414
+ extensions: n
415
+ };
416
+ }
417
+ function Rt(e, t) {
418
+ e.stopEvent = (n) => (n.type === "mousedown" && setTimeout(() => {
419
+ t.view.dom.blur();
420
+ }, 10), !0);
421
+ }
422
+ function Vt(e, t) {
423
+ const n = [
424
+ {
425
+ tag: "[data-content-type=" + e.type + "]",
426
+ contentElement: ".bn-inline-content"
427
+ }
428
+ ];
429
+ return t.parse && n.push({
430
+ tag: "*",
431
+ getAttrs(o) {
432
+ var s;
433
+ if (typeof o == "string")
434
+ return !1;
435
+ const r = (s = t.parse) == null ? void 0 : s.call(t, o);
436
+ return r === void 0 ? !1 : r;
437
+ },
438
+ getContent: e.content === "inline" || e.content === "none" ? (o, r) => {
439
+ var s;
440
+ if (t.parseContent)
441
+ return t.parseContent({
442
+ el: o,
443
+ schema: r
444
+ });
445
+ if (e.content === "inline") {
446
+ const i = o.cloneNode(!0);
447
+ return Ht(
448
+ i,
449
+ (s = t.meta) != null && s.code ? `
450
+ ` : "<br>"
451
+ ), Q.fromSchema(r).parse(i, {
452
+ topNode: r.nodes.paragraph.create()
453
+ }).content;
454
+ }
455
+ return _.empty;
456
+ } : void 0
457
+ }), n;
458
+ }
459
+ function Wt(e, t, n, o) {
460
+ var s, a, i, c;
461
+ const r = t.node || D.create({
462
+ name: e.type,
463
+ content: e.content === "inline" ? "inline*" : e.content === "none" ? "" : e.content,
464
+ group: "blockContent",
465
+ selectable: ((s = t.meta) == null ? void 0 : s.selectable) ?? !0,
466
+ isolating: ((a = t.meta) == null ? void 0 : a.isolating) ?? !0,
467
+ code: ((i = t.meta) == null ? void 0 : i.code) ?? !1,
468
+ defining: ((c = t.meta) == null ? void 0 : c.defining) ?? !0,
469
+ priority: o,
470
+ addAttributes() {
471
+ return Pt(e.propSchema);
472
+ },
473
+ parseHTML() {
474
+ return Vt(e, t);
475
+ },
476
+ renderHTML({ HTMLAttributes: l }) {
477
+ var u;
478
+ const d = document.createElement("div");
479
+ return ae(
480
+ {
481
+ dom: d,
482
+ contentDOM: e.content === "inline" ? d : void 0
483
+ },
484
+ e.type,
485
+ {},
486
+ e.propSchema,
487
+ ((u = t.meta) == null ? void 0 : u.fileBlockAccept) !== void 0,
488
+ l
489
+ );
490
+ },
491
+ addNodeView() {
492
+ return (l) => {
493
+ var h, C;
494
+ const d = this.options.editor, u = Dt(
495
+ l.getPos,
496
+ d,
497
+ this.editor,
498
+ e.type
499
+ ), p = ((h = this.options.domAttributes) == null ? void 0 : h.blockContent) || {}, f = t.render.call(
500
+ { blockContentDOMAttributes: p, props: l, renderType: "nodeView" },
501
+ u,
502
+ d
503
+ );
504
+ return ((C = t.meta) == null ? void 0 : C.selectable) === !1 && Rt(f, this.editor), f;
505
+ };
506
+ }
507
+ });
508
+ if (r.name !== e.type)
509
+ throw new Error(
510
+ "Node name does not match block type. This is a bug in BlockNote."
511
+ );
512
+ return {
513
+ config: e,
514
+ implementation: {
515
+ node: r,
516
+ render(l, d) {
517
+ var p;
518
+ const u = ((p = r.options.domAttributes) == null ? void 0 : p.blockContent) || {};
519
+ return t.render.call(
520
+ {
521
+ blockContentDOMAttributes: u,
522
+ props: void 0,
523
+ renderType: "dom"
524
+ },
525
+ l,
526
+ d
527
+ );
528
+ },
529
+ // TODO: this should not have wrapInBlockStructure and generally be a lot simpler
530
+ // post-processing in externalHTMLExporter should not be necessary
531
+ toExternalHTML: (l, d) => {
532
+ var p, f;
533
+ const u = ((p = r.options.domAttributes) == null ? void 0 : p.blockContent) || {};
534
+ return ((f = t.toExternalHTML) == null ? void 0 : f.call(
535
+ { blockContentDOMAttributes: u },
536
+ l,
537
+ d
538
+ )) ?? t.render.call(
539
+ { blockContentDOMAttributes: u, renderType: "dom", props: void 0 },
540
+ l,
541
+ d
542
+ );
543
+ }
544
+ },
545
+ extensions: n
546
+ };
547
+ }
548
+ function Io(e) {
549
+ return e;
550
+ }
551
+ function M(e, t, n) {
552
+ return (o = {}) => {
553
+ const r = typeof e == "function" ? e(o) : e, s = typeof t == "function" ? t(o) : t, a = n ? typeof n == "function" ? n(o) : n : void 0;
554
+ return {
555
+ config: r,
556
+ implementation: {
557
+ ...s,
558
+ // TODO: this should not have wrapInBlockStructure and generally be a lot simpler
559
+ // post-processing in externalHTMLExporter should not be necessary
560
+ toExternalHTML(i, c) {
561
+ var d, u;
562
+ const l = (d = s.toExternalHTML) == null ? void 0 : d.call(
563
+ { blockContentDOMAttributes: this.blockContentDOMAttributes },
564
+ i,
565
+ c
566
+ );
567
+ if (l !== void 0)
568
+ return ae(
569
+ l,
570
+ i.type,
571
+ i.props,
572
+ r.propSchema,
573
+ ((u = s.meta) == null ? void 0 : u.fileBlockAccept) !== void 0
574
+ );
575
+ },
576
+ render(i, c) {
577
+ var u;
578
+ const l = s.render.call(
579
+ {
580
+ blockContentDOMAttributes: this.blockContentDOMAttributes,
581
+ renderType: this.renderType,
582
+ props: this.props
583
+ },
584
+ i,
585
+ c
586
+ );
587
+ return ae(
588
+ l,
589
+ i.type,
590
+ i.props,
591
+ r.propSchema,
592
+ ((u = s.meta) == null ? void 0 : u.fileBlockAccept) !== void 0,
593
+ this.blockContentDOMAttributes
594
+ );
595
+ }
596
+ },
597
+ extensions: a
598
+ };
599
+ };
600
+ }
601
+ function pe(e, t) {
602
+ const n = e.resolve(t);
603
+ if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock"))
604
+ return {
605
+ posBeforeNode: n.pos,
606
+ node: n.nodeAfter
607
+ };
608
+ let o = n.depth, r = n.node(o);
609
+ for (; o > 0; ) {
610
+ if (r.type.isInGroup("bnBlock"))
611
+ return {
612
+ posBeforeNode: n.before(o),
613
+ node: r
614
+ };
615
+ o--, r = n.node(o);
616
+ }
617
+ const s = [];
618
+ e.descendants((i, c) => {
619
+ i.type.isInGroup("bnBlock") && s.push(c);
620
+ }), console.warn(`Position ${t} is not within a blockContainer node.`);
621
+ const a = e.resolve(
622
+ s.find((i) => i >= t) || s[s.length - 1]
623
+ );
624
+ return {
625
+ posBeforeNode: a.pos,
626
+ node: a.nodeAfter
627
+ };
628
+ }
629
+ function fe(e, t) {
630
+ if (!e.type.isInGroup("bnBlock"))
631
+ throw new Error(
632
+ `Attempted to get bnBlock node at position but found node of different type ${e.type.name}`
633
+ );
634
+ const n = e, o = t, r = o + n.nodeSize, s = {
635
+ node: n,
636
+ beforePos: o,
637
+ afterPos: r
638
+ };
639
+ if (n.type.name === "blockContainer") {
640
+ let a, i;
641
+ if (n.forEach((c, l) => {
642
+ if (c.type.spec.group === "blockContent") {
643
+ const d = c, u = o + l + 1, p = u + c.nodeSize;
644
+ a = {
645
+ node: d,
646
+ beforePos: u,
647
+ afterPos: p
648
+ };
649
+ } else if (c.type.name === "blockGroup") {
650
+ const d = c, u = o + l + 1, p = u + c.nodeSize;
651
+ i = {
652
+ node: d,
653
+ beforePos: u,
654
+ afterPos: p
655
+ };
656
+ }
657
+ }), !a)
658
+ throw new Error(
659
+ `blockContainer node does not contain a blockContent node in its children: ${n}`
660
+ );
661
+ return {
662
+ isBlockContainer: !0,
663
+ bnBlock: s,
664
+ blockContent: a,
665
+ childContainer: i,
666
+ blockNoteType: a.node.type.name
667
+ };
668
+ } else {
669
+ if (!s.node.type.isInGroup("childContainer"))
670
+ throw new Error(
671
+ `bnBlock node is not in the childContainer group: ${s.node}`
672
+ );
673
+ return {
674
+ isBlockContainer: !1,
675
+ bnBlock: s,
676
+ childContainer: s,
677
+ blockNoteType: s.node.type.name
678
+ };
679
+ }
680
+ }
681
+ function q(e) {
682
+ return fe(e.node, e.posBeforeNode);
683
+ }
684
+ function Ft(e) {
685
+ if (!e.nodeAfter)
686
+ throw new Error(
687
+ `Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`
688
+ );
689
+ return fe(e.nodeAfter, e.pos);
690
+ }
691
+ function Oo(e) {
692
+ const t = pe(e.doc, e.selection.anchor);
693
+ return q(t);
694
+ }
695
+ function jt(e) {
696
+ const t = pe(e.doc, e.selection.anchor);
697
+ return q(t);
698
+ }
699
+ function G(e) {
700
+ return "doc" in e ? e.doc.type.schema : e.type.schema;
701
+ }
702
+ function qe(e) {
703
+ return e.cached.blockNoteEditor;
704
+ }
705
+ function he(e) {
706
+ return qe(e).schema;
707
+ }
708
+ function me(e) {
709
+ return he(e).blockSchema;
710
+ }
711
+ function ge(e) {
712
+ return he(e).inlineContentSchema;
713
+ }
714
+ function R(e) {
715
+ return he(e).styleSchema;
716
+ }
717
+ function be(e) {
718
+ return qe(e).blockCache;
719
+ }
720
+ function $t(e, t, n) {
721
+ var s, a;
722
+ const o = {
723
+ type: "tableContent",
724
+ columnWidths: [],
725
+ headerRows: void 0,
726
+ headerCols: void 0,
727
+ rows: []
728
+ }, r = [];
729
+ e.content.forEach((i, c, l) => {
730
+ const d = {
731
+ cells: []
732
+ };
733
+ l === 0 && i.content.forEach((u) => {
734
+ let p = u.attrs.colwidth;
735
+ p == null && (p = new Array(u.attrs.colspan ?? 1).fill(void 0)), o.columnWidths.push(...p);
736
+ }), d.cells = i.content.content.map((u, p) => (r[l] || (r[l] = []), r[l][p] = u.type.name === "tableHeader", {
737
+ type: "tableCell",
738
+ content: u.content.content.map(
739
+ (h) => Ce(h, t, n)
740
+ ).reduce(
741
+ (h, C) => {
742
+ if (!h.length)
743
+ return C;
744
+ const m = h[h.length - 1], b = C[0];
745
+ return b && I(m) && I(b) && JSON.stringify(m.styles) === JSON.stringify(b.styles) ? (m.text += `
746
+ ` + b.text, h.push(...C.slice(1)), h) : (h.push(...C), h);
747
+ },
748
+ []
749
+ ),
750
+ props: {
751
+ colspan: u.attrs.colspan,
752
+ rowspan: u.attrs.rowspan,
753
+ backgroundColor: u.attrs.backgroundColor,
754
+ textColor: u.attrs.textColor,
755
+ textAlignment: u.attrs.textAlignment
756
+ }
757
+ })), o.rows.push(d);
758
+ });
759
+ for (let i = 0; i < r.length; i++)
760
+ (s = r[i]) != null && s.every((c) => c) && (o.headerRows = (o.headerRows ?? 0) + 1);
761
+ for (let i = 0; i < ((a = r[0]) == null ? void 0 : a.length); i++)
762
+ r != null && r.every((c) => c[i]) && (o.headerCols = (o.headerCols ?? 0) + 1);
763
+ return o;
764
+ }
765
+ function Ce(e, t, n) {
766
+ const o = [];
767
+ let r;
768
+ return e.content.forEach((s) => {
769
+ if (s.type.name === "hardBreak") {
770
+ if (r)
771
+ if (I(r))
772
+ r.text += `
773
+ `;
774
+ else if (Me(r))
775
+ r.content[r.content.length - 1].text += `
776
+ `;
777
+ else
778
+ throw new Error("unexpected");
779
+ else
780
+ r = {
781
+ type: "text",
782
+ text: `
783
+ `,
784
+ styles: {}
785
+ };
786
+ return;
787
+ }
788
+ if (s.type.name !== "link" && s.type.name !== "text") {
789
+ if (!t[s.type.name]) {
790
+ console.warn("unrecognized inline content type", s.type.name);
791
+ return;
792
+ }
793
+ r && (o.push(r), r = void 0), o.push(
794
+ Ut(s, t, n)
795
+ );
796
+ return;
797
+ }
798
+ const a = {};
799
+ let i;
800
+ for (const c of s.marks)
801
+ if (c.type.name === "link")
802
+ i = c;
803
+ else {
804
+ const l = n[c.type.name];
805
+ if (!l) {
806
+ if (c.type.spec.blocknoteIgnore)
807
+ continue;
808
+ throw new Error(`style ${c.type.name} not found in styleSchema`);
809
+ }
810
+ if (l.propSchema === "boolean")
811
+ a[l.type] = !0;
812
+ else if (l.propSchema === "string")
813
+ a[l.type] = c.attrs.stringValue;
814
+ else
815
+ throw new Z(l.propSchema);
816
+ }
817
+ r ? I(r) ? i ? (o.push(r), r = {
818
+ type: "link",
819
+ href: i.attrs.href,
820
+ content: [
821
+ {
822
+ type: "text",
823
+ text: s.textContent,
824
+ styles: a
825
+ }
826
+ ]
827
+ }) : JSON.stringify(r.styles) === JSON.stringify(a) ? r.text += s.textContent : (o.push(r), r = {
828
+ type: "text",
829
+ text: s.textContent,
830
+ styles: a
831
+ }) : Me(r) && (i ? r.href === i.attrs.href ? JSON.stringify(
832
+ r.content[r.content.length - 1].styles
833
+ ) === JSON.stringify(a) ? r.content[r.content.length - 1].text += s.textContent : r.content.push({
834
+ type: "text",
835
+ text: s.textContent,
836
+ styles: a
837
+ }) : (o.push(r), r = {
838
+ type: "link",
839
+ href: i.attrs.href,
840
+ content: [
841
+ {
842
+ type: "text",
843
+ text: s.textContent,
844
+ styles: a
845
+ }
846
+ ]
847
+ }) : (o.push(r), r = {
848
+ type: "text",
849
+ text: s.textContent,
850
+ styles: a
851
+ })) : i ? r = {
852
+ type: "link",
853
+ href: i.attrs.href,
854
+ content: [
855
+ {
856
+ type: "text",
857
+ text: s.textContent,
858
+ styles: a
859
+ }
860
+ ]
861
+ } : r = {
862
+ type: "text",
863
+ text: s.textContent,
864
+ styles: a
865
+ };
866
+ }), r && o.push(r), o;
867
+ }
868
+ function Ut(e, t, n) {
869
+ if (e.type.name === "text" || e.type.name === "link")
870
+ throw new Error("unexpected");
871
+ const o = {}, r = t[e.type.name];
872
+ for (const [i, c] of Object.entries(e.attrs)) {
873
+ if (!r)
874
+ throw Error("ic node is of an unrecognized type: " + e.type.name);
875
+ const l = r.propSchema;
876
+ i in l && (o[i] = c);
877
+ }
878
+ let s;
879
+ return r.content === "styled" ? s = Ce(
880
+ e,
881
+ t,
882
+ n
883
+ ) : s = void 0, {
884
+ type: e.type.name,
885
+ props: o,
886
+ content: s
887
+ };
888
+ }
889
+ function X(e, t, n = me(t), o = ge(t), r = R(t), s = be(t)) {
890
+ var C;
891
+ if (!e.type.isInGroup("bnBlock"))
892
+ throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
893
+ const a = s == null ? void 0 : s.get(e);
894
+ if (a)
895
+ return a;
896
+ const i = fe(e, 0);
897
+ let c = i.bnBlock.node.attrs.id;
898
+ c === null && (c = $e.options.generateID());
899
+ const l = n[i.blockNoteType];
900
+ if (!l)
901
+ throw Error("Block is of an unrecognized type: " + i.blockNoteType);
902
+ const d = {};
903
+ for (const [m, b] of Object.entries({
904
+ ...e.attrs,
905
+ ...i.isBlockContainer ? i.blockContent.node.attrs : {}
906
+ })) {
907
+ const y = l.propSchema;
908
+ m in y && !(y[m].default === void 0 && b === void 0) && (d[m] = b);
909
+ }
910
+ const u = n[i.blockNoteType], p = [];
911
+ (C = i.childContainer) == null || C.node.forEach((m) => {
912
+ p.push(
913
+ X(
914
+ m,
915
+ t,
916
+ n,
917
+ o,
918
+ r,
919
+ s
920
+ )
921
+ );
922
+ });
923
+ let f;
924
+ if (u.content === "inline") {
925
+ if (!i.isBlockContainer)
926
+ throw new Error("impossible");
927
+ f = Ce(
928
+ i.blockContent.node,
929
+ o,
930
+ r
931
+ );
932
+ } else if (u.content === "table") {
933
+ if (!i.isBlockContainer)
934
+ throw new Error("impossible");
935
+ f = $t(
936
+ i.blockContent.node,
937
+ o,
938
+ r
939
+ );
940
+ } else if (u.content === "none")
941
+ f = void 0;
942
+ else
943
+ throw new Z(u.content);
944
+ const h = {
945
+ id: c,
946
+ type: u.type,
947
+ props: d,
948
+ content: f,
949
+ children: p
950
+ };
951
+ return s == null || s.set(e, h), h;
952
+ }
953
+ function Ho(e, t, n = me(t), o = ge(t), r = R(t), s = be(t)) {
954
+ const a = [];
955
+ return e.firstChild.descendants((i) => (a.push(
956
+ X(
957
+ i,
958
+ t,
959
+ n,
960
+ o,
961
+ r,
962
+ s
963
+ )
964
+ ), !1)), a;
965
+ }
966
+ function Po(e, t, n = me(t), o = ge(t), r = R(t), s = be(t)) {
967
+ function a(i, c, l) {
968
+ if (i.type.name !== "blockGroup")
969
+ throw new Error("unexpected");
970
+ const d = [];
971
+ let u, p;
972
+ return i.forEach((f, h, C) => {
973
+ if (f.type.name !== "blockContainer")
974
+ throw new Error("unexpected");
975
+ if (f.childCount === 0)
976
+ return;
977
+ if (f.childCount === 0 || f.childCount > 2)
978
+ throw new Error(
979
+ "unexpected, blockContainer.childCount: " + f.childCount
980
+ );
981
+ const m = C === 0, b = C === i.childCount - 1;
982
+ if (f.firstChild.type.name === "blockGroup") {
983
+ if (!m)
984
+ throw new Error("unexpected");
985
+ const S = a(
986
+ f.firstChild,
987
+ Math.max(0, c - 1),
988
+ b ? Math.max(0, l - 1) : 0
989
+ );
990
+ u = S.blockCutAtStart, b && (p = S.blockCutAtEnd), d.push(...S.blocks);
991
+ return;
992
+ }
993
+ const y = X(
994
+ f,
995
+ t,
996
+ n,
997
+ o,
998
+ r,
999
+ s
1000
+ ), g = f.childCount > 1 ? f.child(1) : void 0;
1001
+ let w = [];
1002
+ if (g) {
1003
+ const S = a(
1004
+ g,
1005
+ 0,
1006
+ // TODO: can this be anything other than 0?
1007
+ b ? Math.max(0, l - 1) : 0
1008
+ );
1009
+ w = S.blocks, b && (p = S.blockCutAtEnd);
1010
+ }
1011
+ b && !g && l > 1 && (p = y.id), m && c > 1 && (u = y.id), d.push({
1012
+ ...y,
1013
+ children: w
1014
+ });
1015
+ }), { blocks: d, blockCutAtStart: u, blockCutAtEnd: p };
1016
+ }
1017
+ if (e.content.childCount === 0)
1018
+ return {
1019
+ blocks: [],
1020
+ blockCutAtStart: void 0,
1021
+ blockCutAtEnd: void 0
1022
+ };
1023
+ if (e.content.childCount !== 1)
1024
+ throw new Error(
1025
+ "slice must be a single block, did you forget includeParents=true?"
1026
+ );
1027
+ return a(
1028
+ e.content.firstChild,
1029
+ Math.max(e.openStart - 1, 0),
1030
+ Math.max(e.openEnd - 1, 0)
1031
+ );
1032
+ }
1033
+ function Do(e, t, n, o) {
1034
+ return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([r, s]) => {
1035
+ const a = o[r];
1036
+ return s !== a.default;
1037
+ }).map(([r, s]) => [K(r), s]).forEach(([r, s]) => e.dom.setAttribute(r, s)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
1038
+ }
1039
+ function _o(e) {
1040
+ return {
1041
+ Backspace: ({ editor: t }) => {
1042
+ const n = t.state.selection.$from;
1043
+ return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
1044
+ }
1045
+ };
1046
+ }
1047
+ function qt(e, t) {
1048
+ return {
1049
+ config: e,
1050
+ implementation: t
1051
+ };
1052
+ }
1053
+ function Ro(e, t, n) {
1054
+ return qt(
1055
+ {
1056
+ type: e.name,
1057
+ propSchema: t,
1058
+ content: e.config.content === "inline*" ? "styled" : "none"
1059
+ },
1060
+ {
1061
+ ...n,
1062
+ node: e
1063
+ }
1064
+ );
1065
+ }
1066
+ function ze(e) {
1067
+ return Object.fromEntries(
1068
+ Object.entries(e).map(([t, n]) => [t, n.config])
1069
+ );
1070
+ }
1071
+ function zt(e) {
1072
+ return e === "boolean" ? {} : {
1073
+ stringValue: {
1074
+ default: void 0,
1075
+ keepOnSplit: !0,
1076
+ parseHTML: (t) => t.getAttribute("data-value"),
1077
+ renderHTML: (t) => t.stringValue !== void 0 ? {
1078
+ "data-value": t.stringValue
1079
+ } : {}
1080
+ }
1081
+ };
1082
+ }
1083
+ function J(e, t, n, o) {
1084
+ return e.dom.setAttribute("data-style-type", t), o === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
1085
+ }
1086
+ function Ze(e, t) {
1087
+ return {
1088
+ config: e,
1089
+ implementation: t
1090
+ };
1091
+ }
1092
+ function F(e, t) {
1093
+ return Ze(
1094
+ {
1095
+ type: e.name,
1096
+ propSchema: t
1097
+ },
1098
+ {
1099
+ mark: e,
1100
+ render(n, o) {
1101
+ const r = o.pmSchema.marks[e.name].spec.toDOM;
1102
+ if (r === void 0)
1103
+ throw new Error(
1104
+ "This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
1105
+ );
1106
+ const s = o.pmSchema.mark(e.name, {
1107
+ stringValue: n
1108
+ }), a = Se.renderSpec(
1109
+ document,
1110
+ r(s, !0)
1111
+ );
1112
+ if (typeof a != "object" || !("dom" in a))
1113
+ throw new Error(
1114
+ "Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property."
1115
+ );
1116
+ return a;
1117
+ },
1118
+ toExternalHTML(n, o) {
1119
+ const r = o.pmSchema.marks[e.name].spec.toDOM;
1120
+ if (r === void 0)
1121
+ throw new Error(
1122
+ "This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
1123
+ );
1124
+ const s = o.pmSchema.mark(e.name, {
1125
+ stringValue: n
1126
+ }), a = Se.renderSpec(
1127
+ document,
1128
+ r(s, !0)
1129
+ );
1130
+ if (typeof a != "object" || !("dom" in a))
1131
+ throw new Error(
1132
+ "Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property."
1133
+ );
1134
+ return a;
1135
+ }
1136
+ }
1137
+ );
1138
+ }
1139
+ function Ge(e) {
1140
+ return Object.fromEntries(
1141
+ Object.entries(e).map(([t, n]) => [t, n.config])
1142
+ );
1143
+ }
1144
+ function Zt(e, t) {
1145
+ const n = [
1146
+ {
1147
+ tag: `[data-style-type="${e.type}"]`,
1148
+ contentElement: (o) => {
1149
+ const r = o;
1150
+ return r.matches("[data-editable]") ? r : r.querySelector("[data-editable]") || r;
1151
+ }
1152
+ }
1153
+ ];
1154
+ return t && n.push({
1155
+ tag: "*",
1156
+ getAttrs(o) {
1157
+ if (typeof o == "string")
1158
+ return !1;
1159
+ const r = t == null ? void 0 : t(o);
1160
+ return r === void 0 ? !1 : { stringValue: r };
1161
+ }
1162
+ }), n;
1163
+ }
1164
+ function Xe(e, t) {
1165
+ const n = xt.create({
1166
+ name: e.type,
1167
+ addAttributes() {
1168
+ return zt(e.propSchema);
1169
+ },
1170
+ parseHTML() {
1171
+ return Zt(e, t.parse);
1172
+ },
1173
+ renderHTML({ mark: o }) {
1174
+ const r = (t.toExternalHTML || t.render)(o.attrs.stringValue);
1175
+ return J(
1176
+ r,
1177
+ e.type,
1178
+ o.attrs.stringValue,
1179
+ e.propSchema
1180
+ );
1181
+ },
1182
+ addMarkView() {
1183
+ return ({ mark: o }) => {
1184
+ const r = t.render(o.attrs.stringValue);
1185
+ return J(
1186
+ r,
1187
+ e.type,
1188
+ o.attrs.stringValue,
1189
+ e.propSchema
1190
+ );
1191
+ };
1192
+ }
1193
+ });
1194
+ return Ze(e, {
1195
+ mark: n,
1196
+ render: (o) => {
1197
+ const r = t.render(o);
1198
+ return J(
1199
+ r,
1200
+ e.type,
1201
+ o,
1202
+ e.propSchema
1203
+ );
1204
+ },
1205
+ toExternalHTML: (o) => {
1206
+ const r = (t.toExternalHTML || t.render)(o);
1207
+ return J(
1208
+ r,
1209
+ e.type,
1210
+ o,
1211
+ e.propSchema
1212
+ );
1213
+ }
1214
+ });
1215
+ }
1216
+ function Gt(e) {
1217
+ const t = Jt(e);
1218
+ let { roots: n, nonRoots: o } = Te(t);
1219
+ const r = [];
1220
+ for (; n.size; ) {
1221
+ r.push(n);
1222
+ const s = /* @__PURE__ */ new Set();
1223
+ for (const a of n) {
1224
+ const i = e.get(a);
1225
+ if (i)
1226
+ for (const c of i) {
1227
+ const l = t.get(c);
1228
+ if (l === void 0)
1229
+ continue;
1230
+ const d = l - 1;
1231
+ t.set(c, d), d === 0 && s.add(c);
1232
+ }
1233
+ }
1234
+ n = s;
1235
+ }
1236
+ if (o = Te(t).nonRoots, o.size)
1237
+ throw new Error(
1238
+ `Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(o).join(", ")}`
1239
+ );
1240
+ return r;
1241
+ }
1242
+ function Xt(e) {
1243
+ const t = Kt(e);
1244
+ return Gt(t);
1245
+ }
1246
+ function Jt(e) {
1247
+ const t = /* @__PURE__ */ new Map();
1248
+ for (const [n, o] of e.entries()) {
1249
+ t.has(n) || t.set(n, 0);
1250
+ for (const r of o) {
1251
+ const s = t.get(r) ?? 0;
1252
+ t.set(r, s + 1);
1253
+ }
1254
+ }
1255
+ return t;
1256
+ }
1257
+ function Te(e) {
1258
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
1259
+ for (const [o, r] of e.entries())
1260
+ r === 0 ? t.add(o) : n.add(o);
1261
+ return { roots: t, nonRoots: n };
1262
+ }
1263
+ function Kt(e) {
1264
+ const t = /* @__PURE__ */ new Map();
1265
+ for (const [n, o] of e.entries()) {
1266
+ t.has(n) || t.set(n, /* @__PURE__ */ new Set());
1267
+ for (const r of o)
1268
+ t.has(r) || t.set(r, /* @__PURE__ */ new Set()), t.get(r).add(n);
1269
+ }
1270
+ return t;
1271
+ }
1272
+ function Qt() {
1273
+ return /* @__PURE__ */ new Map();
1274
+ }
1275
+ function Ae(e) {
1276
+ return e && Object.fromEntries(
1277
+ Object.entries(e).filter(([, t]) => t !== void 0)
1278
+ );
1279
+ }
1280
+ class Yt {
1281
+ constructor(t) {
1282
+ // Helper so that you can use typeof schema.BlockNoteEditor
1283
+ x(this, "BlockNoteEditor", "only for types");
1284
+ x(this, "Block", "only for types");
1285
+ x(this, "PartialBlock", "only for types");
1286
+ x(this, "inlineContentSpecs");
1287
+ x(this, "styleSpecs");
1288
+ x(this, "blockSpecs");
1289
+ x(this, "blockSchema");
1290
+ x(this, "inlineContentSchema");
1291
+ x(this, "styleSchema");
1292
+ this.opts = t;
1293
+ const {
1294
+ blockSpecs: n,
1295
+ inlineContentSpecs: o,
1296
+ styleSpecs: r,
1297
+ blockSchema: s,
1298
+ inlineContentSchema: a,
1299
+ styleSchema: i
1300
+ } = this.init();
1301
+ this.blockSpecs = n, this.styleSpecs = r, this.styleSchema = i, this.inlineContentSpecs = o, this.blockSchema = s, this.inlineContentSchema = a;
1302
+ }
1303
+ init() {
1304
+ const t = Qt(), n = /* @__PURE__ */ new Set();
1305
+ t.set("default", n);
1306
+ for (const [i, c] of Object.entries(this.opts.blockSpecs))
1307
+ c.implementation.runsBefore ? t.set(i, new Set(c.implementation.runsBefore)) : n.add(i);
1308
+ const o = Xt(t), r = o.findIndex((i) => i.has("default")), s = (i) => 91 + (o.findIndex((l) => l.has(i)) + r) * 10, a = Object.fromEntries(
1309
+ Object.entries(this.opts.blockSpecs).map(([i, c]) => [
1310
+ i,
1311
+ Wt(
1312
+ c.config,
1313
+ c.implementation,
1314
+ c.extensions,
1315
+ s(i)
1316
+ )
1317
+ ])
1318
+ );
1319
+ return {
1320
+ blockSpecs: a,
1321
+ blockSchema: Object.fromEntries(
1322
+ Object.entries(a).map(([i, c]) => [i, c.config])
1323
+ ),
1324
+ inlineContentSpecs: Ae(this.opts.inlineContentSpecs),
1325
+ styleSpecs: Ae(this.opts.styleSpecs),
1326
+ inlineContentSchema: ze(
1327
+ this.opts.inlineContentSpecs
1328
+ ),
1329
+ styleSchema: Ge(this.opts.styleSpecs)
1330
+ };
1331
+ }
1332
+ /**
1333
+ * Adds additional block specs to the current schema in a builder pattern.
1334
+ * This method allows extending the schema after it has been created.
1335
+ *
1336
+ * @param additionalBlockSpecs - Additional block specs to add to the schema
1337
+ * @returns The current schema instance for chaining
1338
+ */
1339
+ extend(t) {
1340
+ Object.assign(this.opts.blockSpecs, t.blockSpecs), Object.assign(this.opts.inlineContentSpecs, t.inlineContentSpecs), Object.assign(this.opts.styleSpecs, t.styleSpecs);
1341
+ const {
1342
+ blockSpecs: n,
1343
+ inlineContentSpecs: o,
1344
+ styleSpecs: r,
1345
+ blockSchema: s,
1346
+ inlineContentSchema: a,
1347
+ styleSchema: i
1348
+ } = this.init();
1349
+ return this.blockSpecs = n, this.styleSpecs = r, this.styleSchema = i, this.inlineContentSpecs = o, this.blockSchema = s, this.inlineContentSchema = a, this;
1350
+ }
1351
+ }
1352
+ function N(e) {
1353
+ const { height: t, width: n } = Je(e), o = new Array(t).fill(!1).map(() => new Array(n).fill(null)), r = (s, a) => {
1354
+ for (let i = s; i < t; i++)
1355
+ for (let c = a; c < n; c++)
1356
+ if (!o[i][c])
1357
+ return { row: i, col: c };
1358
+ throw new Error(
1359
+ "Unable to create occupancy grid for table, no more available cells"
1360
+ );
1361
+ };
1362
+ for (let s = 0; s < e.content.rows.length; s++)
1363
+ for (let a = 0; a < e.content.rows[s].cells.length; a++) {
1364
+ const i = re(e.content.rows[s].cells[a]), c = se(i), l = $(i), { row: d, col: u } = r(s, a);
1365
+ for (let p = d; p < d + c; p++)
1366
+ for (let f = u; f < u + l; f++) {
1367
+ if (o[p][f])
1368
+ throw new Error(
1369
+ `Unable to create occupancy grid for table, cell at ${p},${f} is already occupied`
1370
+ );
1371
+ o[p][f] = {
1372
+ row: s,
1373
+ col: a,
1374
+ rowspan: c,
1375
+ colspan: l,
1376
+ cell: i
1377
+ };
1378
+ }
1379
+ }
1380
+ return o;
1381
+ }
1382
+ function z(e) {
1383
+ const t = /* @__PURE__ */ new Set();
1384
+ return e.map((n) => ({
1385
+ cells: n.map((o) => t.has(o.row + ":" + o.col) ? !1 : (t.add(o.row + ":" + o.col), o.cell)).filter((o) => o !== !1)
1386
+ }));
1387
+ }
1388
+ function O(e, t, n = N(t)) {
1389
+ for (let o = 0; o < n.length; o++)
1390
+ for (let r = 0; r < n[o].length; r++) {
1391
+ const s = n[o][r];
1392
+ if (s.row === e.row && s.col === e.col)
1393
+ return { row: o, col: r, cell: s.cell };
1394
+ }
1395
+ throw new Error(
1396
+ `Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`
1397
+ );
1398
+ }
1399
+ function Je(e) {
1400
+ const t = e.content.rows.length;
1401
+ let n = 0;
1402
+ return e.content.rows.forEach((o) => {
1403
+ let r = 0;
1404
+ o.cells.forEach((s) => {
1405
+ r += $(s);
1406
+ }), n = Math.max(n, r);
1407
+ }), { height: t, width: n };
1408
+ }
1409
+ function Ke(e, t, n = N(t)) {
1410
+ var r;
1411
+ const o = (r = n[e.row]) == null ? void 0 : r[e.col];
1412
+ if (o)
1413
+ return {
1414
+ row: o.row,
1415
+ col: o.col,
1416
+ cell: o.cell
1417
+ };
1418
+ }
1419
+ function en(e, t) {
1420
+ var s;
1421
+ const n = N(e);
1422
+ if (t < 0 || t >= n.length)
1423
+ return [];
1424
+ let o = 0;
1425
+ for (let a = 0; a < t; a++) {
1426
+ const i = (s = n[o]) == null ? void 0 : s[0];
1427
+ if (!i)
1428
+ return [];
1429
+ o += i.rowspan;
1430
+ }
1431
+ const r = new Array(n[0].length).fill(!1).map((a, i) => Ke(
1432
+ { row: o, col: i },
1433
+ e,
1434
+ n
1435
+ )).filter(
1436
+ (a) => a !== void 0
1437
+ );
1438
+ return r.filter((a, i) => r.findIndex((c) => c.row === a.row && c.col === a.col) === i);
1439
+ }
1440
+ function tn(e, t) {
1441
+ var s;
1442
+ const n = N(e);
1443
+ if (t < 0 || t >= n[0].length)
1444
+ return [];
1445
+ let o = 0;
1446
+ for (let a = 0; a < t; a++) {
1447
+ const i = (s = n[0]) == null ? void 0 : s[o];
1448
+ if (!i)
1449
+ return [];
1450
+ o += i.colspan;
1451
+ }
1452
+ const r = new Array(n.length).fill(!1).map((a, i) => Ke(
1453
+ { row: i, col: o },
1454
+ e,
1455
+ n
1456
+ )).filter(
1457
+ (a) => a !== void 0
1458
+ );
1459
+ return r.filter((a, i) => r.findIndex((c) => c.row === a.row && c.col === a.col) === i);
1460
+ }
1461
+ function Vo(e, t, n, o = N(e)) {
1462
+ const { col: r } = O(
1463
+ {
1464
+ row: 0,
1465
+ col: t
1466
+ },
1467
+ e,
1468
+ o
1469
+ ), { col: s } = O(
1470
+ {
1471
+ row: 0,
1472
+ col: n
1473
+ },
1474
+ e,
1475
+ o
1476
+ );
1477
+ return o.forEach((a) => {
1478
+ const [i] = a.splice(r, 1);
1479
+ a.splice(s, 0, i);
1480
+ }), z(o);
1481
+ }
1482
+ function Wo(e, t, n, o = N(e)) {
1483
+ const { row: r } = O(
1484
+ {
1485
+ row: t,
1486
+ col: 0
1487
+ },
1488
+ e,
1489
+ o
1490
+ ), { row: s } = O(
1491
+ {
1492
+ row: n,
1493
+ col: 0
1494
+ },
1495
+ e,
1496
+ o
1497
+ ), [a] = o.splice(r, 1);
1498
+ return o.splice(s, 0, a), z(o);
1499
+ }
1500
+ function ie(e) {
1501
+ return e ? j(e) ? ie(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every(
1502
+ (t) => typeof t == "string" ? t.length === 0 : I(t) ? t.text.length === 0 : Ue(t) ? typeof t.content == "string" ? t.content.length === 0 : t.content.every((n) => n.text.length === 0) : !1
1503
+ ) : !1 : !0;
1504
+ }
1505
+ function Fo(e, t, n = N(e)) {
1506
+ if (t === "columns") {
1507
+ let s = 0;
1508
+ for (let a = n[0].length - 1; a >= 0 && n.every(
1509
+ (c) => ie(c[a].cell) && c[a].colspan === 1
1510
+ ); a--)
1511
+ s++;
1512
+ for (let a = n.length - 1; a >= 0; a--) {
1513
+ const i = Math.max(
1514
+ n[a].length - s,
1515
+ 1
1516
+ );
1517
+ n[a] = n[a].slice(0, i);
1518
+ }
1519
+ return z(n);
1520
+ }
1521
+ let o = 0;
1522
+ for (let s = n.length - 1; s >= 0 && n[s].every(
1523
+ (i) => ie(i.cell) && i.rowspan === 1
1524
+ ); s--)
1525
+ o++;
1526
+ const r = Math.min(o, n.length - 1);
1527
+ return n.splice(n.length - r, r), z(n);
1528
+ }
1529
+ function jo(e, t, n, o = N(e)) {
1530
+ const { width: r, height: s } = Je(e);
1531
+ if (t === "columns")
1532
+ o.forEach((a, i) => {
1533
+ if (n >= 0)
1534
+ for (let c = 0; c < n; c++)
1535
+ a.push({
1536
+ row: i,
1537
+ col: Math.max(...a.map((l) => l.col)) + 1,
1538
+ rowspan: 1,
1539
+ colspan: 1,
1540
+ cell: re("")
1541
+ });
1542
+ else
1543
+ a.splice(r + n, -1 * n);
1544
+ });
1545
+ else if (n > 0)
1546
+ for (let a = 0; a < n; a++) {
1547
+ const i = new Array(r).fill(null).map((c, l) => ({
1548
+ row: s + a,
1549
+ col: l,
1550
+ rowspan: 1,
1551
+ colspan: 1,
1552
+ cell: re("")
1553
+ }));
1554
+ o.push(i);
1555
+ }
1556
+ else n < 0 && o.splice(s + n, -1 * n);
1557
+ return z(o);
1558
+ }
1559
+ function $o(e, t, n) {
1560
+ const o = en(e, n);
1561
+ if (!o.some((c) => se(c.cell) > 1))
1562
+ return !0;
1563
+ let s = n, a = n;
1564
+ return o.forEach((c) => {
1565
+ const l = se(c.cell);
1566
+ s = Math.max(s, c.row + l - 1), a = Math.min(a, c.row);
1567
+ }), t < n ? n === s : n === a;
1568
+ }
1569
+ function Uo(e, t, n) {
1570
+ const o = tn(e, n);
1571
+ if (!o.some((c) => $(c.cell) > 1))
1572
+ return !0;
1573
+ let s = n, a = n;
1574
+ return o.forEach((c) => {
1575
+ const l = $(c.cell);
1576
+ s = Math.max(s, c.col + l - 1), a = Math.min(a, c.col);
1577
+ }), t < n ? n === s : n === a;
1578
+ }
1579
+ function qo(e, t, n) {
1580
+ const o = O(e, n), r = O(t, n);
1581
+ return o.col === r.col;
1582
+ }
1583
+ function Ne(e, t, n, o) {
1584
+ const r = [];
1585
+ for (const [a, i] of Object.entries(e.styles || {})) {
1586
+ const c = n[a];
1587
+ if (!c)
1588
+ throw new Error(`style ${a} not found in styleSchema`);
1589
+ if (c.propSchema === "boolean")
1590
+ i && r.push(t.mark(a));
1591
+ else if (c.propSchema === "string")
1592
+ i && r.push(t.mark(a, { stringValue: i }));
1593
+ else
1594
+ throw new Z(c.propSchema);
1595
+ }
1596
+ return !o || !t.nodes[o].spec.code ? e.text.split(/(\n)/g).filter((a) => a.length > 0).map((a) => a === `
1597
+ ` ? t.nodes.hardBreak.createChecked() : t.text(a, r)) : e.text.length > 0 ? [t.text(e.text, r)] : [];
1598
+ }
1599
+ function nn(e, t, n) {
1600
+ const o = t.marks.link.create({
1601
+ href: e.href
1602
+ });
1603
+ return ce(e.content, t, n).map(
1604
+ (r) => {
1605
+ if (r.type.name === "text")
1606
+ return r.mark([...r.marks, o]);
1607
+ if (r.type.name === "hardBreak")
1608
+ return r;
1609
+ throw new Error("unexpected node type");
1610
+ }
1611
+ );
1612
+ }
1613
+ function ce(e, t, n, o) {
1614
+ const r = [];
1615
+ if (typeof e == "string")
1616
+ return r.push(
1617
+ ...Ne(
1618
+ { text: e, styles: {} },
1619
+ t,
1620
+ n,
1621
+ o
1622
+ )
1623
+ ), r;
1624
+ for (const s of e)
1625
+ r.push(
1626
+ ...Ne(s, t, n, o)
1627
+ );
1628
+ return r;
1629
+ }
1630
+ function P(e, t, n, o = R(t)) {
1631
+ const r = [];
1632
+ for (const s of e)
1633
+ typeof s == "string" ? r.push(
1634
+ ...ce(s, t, o, n)
1635
+ ) : Ue(s) ? r.push(...nn(s, t, o)) : I(s) ? r.push(
1636
+ ...ce([s], t, o, n)
1637
+ ) : r.push(
1638
+ Ye(s, t, o)
1639
+ );
1640
+ return r;
1641
+ }
1642
+ function Qe(e, t, n = R(t)) {
1643
+ const o = [], r = new Array(e.headerRows ?? 0).fill(!0), s = new Array(e.headerCols ?? 0).fill(!0), a = e.columnWidths ?? [];
1644
+ for (let i = 0; i < e.rows.length; i++) {
1645
+ const c = e.rows[i], l = [], d = r[i];
1646
+ for (let p = 0; p < c.cells.length; p++) {
1647
+ const f = c.cells[p], h = s[p], C = void 0;
1648
+ let m = null;
1649
+ const b = O(
1650
+ {
1651
+ row: i,
1652
+ col: p
1653
+ },
1654
+ { content: e }
1655
+ );
1656
+ let y = a[b.col] ? [a[b.col]] : null;
1657
+ if (f) if (typeof f == "string")
1658
+ m = t.text(f);
1659
+ else if (j(f)) {
1660
+ f.content && (m = P(
1661
+ f.content,
1662
+ t,
1663
+ "tableParagraph",
1664
+ n
1665
+ ));
1666
+ const w = $(f);
1667
+ w > 1 && (y = new Array(w).fill(!1).map((S, oe) => a[b.col + oe] ?? void 0));
1668
+ } else
1669
+ m = P(
1670
+ f,
1671
+ t,
1672
+ "tableParagraph",
1673
+ n
1674
+ );
1675
+ const g = t.nodes[h || d ? "tableHeader" : "tableCell"].createChecked(
1676
+ {
1677
+ ...j(f) ? f.props : {},
1678
+ colwidth: y
1679
+ },
1680
+ t.nodes.tableParagraph.createChecked(C, m)
1681
+ );
1682
+ l.push(g);
1683
+ }
1684
+ const u = t.nodes.tableRow.createChecked({}, l);
1685
+ o.push(u);
1686
+ }
1687
+ return o;
1688
+ }
1689
+ function Ye(e, t, n) {
1690
+ let o, r = e.type;
1691
+ if (r === void 0 && (r = "paragraph"), !t.nodes[r])
1692
+ throw new Error(`node type ${r} not found in schema`);
1693
+ if (!e.content)
1694
+ o = t.nodes[r].createChecked(e.props);
1695
+ else if (typeof e.content == "string") {
1696
+ const s = P(
1697
+ [e.content],
1698
+ t,
1699
+ r,
1700
+ n
1701
+ );
1702
+ o = t.nodes[r].createChecked(e.props, s);
1703
+ } else if (Array.isArray(e.content)) {
1704
+ const s = P(
1705
+ e.content,
1706
+ t,
1707
+ r,
1708
+ n
1709
+ );
1710
+ o = t.nodes[r].createChecked(e.props, s);
1711
+ } else if (e.content.type === "tableContent") {
1712
+ const s = Qe(e.content, t, n);
1713
+ o = t.nodes[r].createChecked(e.props, s);
1714
+ } else
1715
+ throw new Z(e.content.type);
1716
+ return o;
1717
+ }
1718
+ function Y(e, t, n = R(t)) {
1719
+ let o = e.id;
1720
+ o === void 0 && (o = $e.options.generateID());
1721
+ const r = [];
1722
+ if (e.children)
1723
+ for (const a of e.children)
1724
+ r.push(Y(a, t, n));
1725
+ if (!e.type || // can happen if block.type is not defined (this should create the default node)
1726
+ t.nodes[e.type].isInGroup("blockContent")) {
1727
+ const a = Ye(
1728
+ e,
1729
+ t,
1730
+ n
1731
+ ), i = r.length > 0 ? t.nodes.blockGroup.createChecked({}, r) : void 0;
1732
+ return t.nodes.blockContainer.createChecked(
1733
+ {
1734
+ id: o,
1735
+ ...e.props
1736
+ },
1737
+ i ? [a, i] : a
1738
+ );
1739
+ } else {
1740
+ if (t.nodes[e.type].isInGroup("bnBlock"))
1741
+ return t.nodes[e.type].createChecked(
1742
+ {
1743
+ id: o,
1744
+ ...e.props
1745
+ },
1746
+ r
1747
+ );
1748
+ throw new Error(
1749
+ `block type ${e.type} doesn't match blockContent or bnBlock group`
1750
+ );
1751
+ }
1752
+ }
1753
+ function on(e, t) {
1754
+ let n, o;
1755
+ if (t.firstChild.descendants((r, s) => n ? !1 : !rn(r) || r.attrs.id !== e ? !0 : (n = r, o = s + 1, !1)), !(n === void 0 || o === void 0))
1756
+ return {
1757
+ node: n,
1758
+ posBeforeNode: o
1759
+ };
1760
+ }
1761
+ function rn(e) {
1762
+ return e.type.isInGroup("bnBlock");
1763
+ }
1764
+ const zo = (e, t) => ({
1765
+ tr: n,
1766
+ dispatch: o
1767
+ }) => (o && ke(n, e, t), !0);
1768
+ function ke(e, t, n, o, r) {
1769
+ const s = Ft(e.doc.resolve(t));
1770
+ let a = null;
1771
+ s.blockNoteType === "table" && (a = an(e));
1772
+ const i = G(e);
1773
+ if (o !== void 0 && r !== void 0 && o > r)
1774
+ throw new Error("Invalid replaceFromPos or replaceToPos");
1775
+ const c = i.nodes[s.blockNoteType], l = i.nodes[n.type || s.blockNoteType], d = l.isInGroup("bnBlock") ? l : i.nodes.blockContainer;
1776
+ if (s.isBlockContainer && l.isInGroup("blockContent")) {
1777
+ const u = o !== void 0 && o > s.blockContent.beforePos && o < s.blockContent.afterPos ? o - s.blockContent.beforePos - 1 : void 0, p = r !== void 0 && r > s.blockContent.beforePos && r < s.blockContent.afterPos ? r - s.blockContent.beforePos - 1 : void 0;
1778
+ Ie(n, e, s), sn(
1779
+ n,
1780
+ e,
1781
+ c,
1782
+ l,
1783
+ s,
1784
+ u,
1785
+ p
1786
+ );
1787
+ } else if (!s.isBlockContainer && l.isInGroup("bnBlock"))
1788
+ Ie(n, e, s);
1789
+ else {
1790
+ const u = X(s.bnBlock.node, i);
1791
+ e.replaceWith(
1792
+ s.bnBlock.beforePos,
1793
+ s.bnBlock.afterPos,
1794
+ Y(
1795
+ {
1796
+ children: u.children,
1797
+ // if no children are passed in, use existing children
1798
+ ...n
1799
+ },
1800
+ i
1801
+ )
1802
+ );
1803
+ return;
1804
+ }
1805
+ e.setNodeMarkup(s.bnBlock.beforePos, d, {
1806
+ ...s.bnBlock.node.attrs,
1807
+ ...n.props
1808
+ }), a && cn(e, s, a);
1809
+ }
1810
+ function sn(e, t, n, o, r, s, a) {
1811
+ const i = G(t);
1812
+ let c = "keep";
1813
+ if (e.content)
1814
+ if (typeof e.content == "string")
1815
+ c = P(
1816
+ [e.content],
1817
+ i,
1818
+ o.name
1819
+ );
1820
+ else if (Array.isArray(e.content))
1821
+ c = P(e.content, i, o.name);
1822
+ else if (e.content.type === "tableContent")
1823
+ c = Qe(e.content, i);
1824
+ else
1825
+ throw new Z(e.content.type);
1826
+ else
1827
+ n.spec.content === "" || o.spec.content !== n.spec.content && (c = []);
1828
+ if (c === "keep")
1829
+ t.setNodeMarkup(r.blockContent.beforePos, o, {
1830
+ ...r.blockContent.node.attrs,
1831
+ ...e.props
1832
+ });
1833
+ else if (s !== void 0 || a !== void 0) {
1834
+ t.setNodeMarkup(r.blockContent.beforePos, o, {
1835
+ ...r.blockContent.node.attrs,
1836
+ ...e.props
1837
+ });
1838
+ const l = r.blockContent.beforePos + 1 + (s ?? 0), d = r.blockContent.beforePos + 1 + (a ?? r.blockContent.node.content.size), u = t.doc.resolve(r.blockContent.beforePos).depth, p = t.doc.resolve(l).depth, f = t.doc.resolve(d).depth;
1839
+ t.replace(
1840
+ l,
1841
+ d,
1842
+ new ue(
1843
+ _.from(c),
1844
+ p - u - 1,
1845
+ f - u - 1
1846
+ )
1847
+ );
1848
+ } else
1849
+ t.replaceWith(
1850
+ r.blockContent.beforePos,
1851
+ r.blockContent.afterPos,
1852
+ o.createChecked(
1853
+ {
1854
+ ...r.blockContent.node.attrs,
1855
+ ...e.props
1856
+ },
1857
+ c
1858
+ )
1859
+ );
1860
+ }
1861
+ function Ie(e, t, n) {
1862
+ const o = G(t);
1863
+ if (e.children !== void 0 && e.children.length > 0) {
1864
+ const r = e.children.map((s) => Y(s, o));
1865
+ if (n.childContainer)
1866
+ t.step(
1867
+ new Lt(
1868
+ n.childContainer.beforePos + 1,
1869
+ n.childContainer.afterPos - 1,
1870
+ new ue(_.from(r), 0, 0)
1871
+ )
1872
+ );
1873
+ else {
1874
+ if (!n.isBlockContainer)
1875
+ throw new Error("impossible");
1876
+ t.insert(
1877
+ n.blockContent.afterPos,
1878
+ o.nodes.blockGroup.createChecked({}, r)
1879
+ );
1880
+ }
1881
+ }
1882
+ }
1883
+ function Zo(e, t, n, o, r) {
1884
+ const s = typeof t == "string" ? t : t.id, a = on(s, e.doc);
1885
+ if (!a)
1886
+ throw new Error(`Block with ID ${s} not found`);
1887
+ ke(
1888
+ e,
1889
+ a.posBeforeNode,
1890
+ n,
1891
+ o,
1892
+ r
1893
+ );
1894
+ const i = e.doc.resolve(a.posBeforeNode + 1).node(), c = G(e);
1895
+ return X(i, c);
1896
+ }
1897
+ function an(e) {
1898
+ const t = "selection" in e ? e.selection : null;
1899
+ if (!(t instanceof je))
1900
+ return null;
1901
+ const n = e.doc.resolve(t.head);
1902
+ let o = -1, r = -1;
1903
+ for (let m = n.depth; m >= 0; m--) {
1904
+ const b = n.node(m).type.name;
1905
+ if (o < 0 && (b === "tableCell" || b === "tableHeader") && (o = m), b === "table") {
1906
+ r = m;
1907
+ break;
1908
+ }
1909
+ }
1910
+ if (o < 0 || r < 0)
1911
+ return null;
1912
+ const s = n.before(o), a = n.before(r), i = e.doc.nodeAt(a);
1913
+ if (!i || i.type.name !== "table")
1914
+ return null;
1915
+ const c = Re.get(i), l = s - (a + 1), d = c.map.indexOf(l);
1916
+ if (d < 0)
1917
+ return null;
1918
+ const u = Math.floor(d / c.width), p = d % c.width, h = s + 1 + 1, C = Math.max(0, t.head - h);
1919
+ return { row: u, col: p, offset: C };
1920
+ }
1921
+ function cn(e, t, n) {
1922
+ var m;
1923
+ if (t.blockNoteType !== "table")
1924
+ return !1;
1925
+ let o = -1;
1926
+ if (t.isBlockContainer)
1927
+ o = e.mapping.map(t.blockContent.beforePos);
1928
+ else {
1929
+ const b = e.mapping.map(t.bnBlock.beforePos), y = b + (((m = e.doc.nodeAt(b)) == null ? void 0 : m.nodeSize) || 0);
1930
+ e.doc.nodesBetween(b, y, (g, w) => g.type.name === "table" ? (o = w, !1) : !0);
1931
+ }
1932
+ const r = o >= 0 ? e.doc.nodeAt(o) : null;
1933
+ if (!r || r.type.name !== "table")
1934
+ return !1;
1935
+ const s = Re.get(r), a = Math.max(0, Math.min(n.row, s.height - 1)), i = Math.max(0, Math.min(n.col, s.width - 1)), c = a * s.width + i, l = s.map[c];
1936
+ if (l == null)
1937
+ return !1;
1938
+ const u = o + 1 + l + 1, p = e.doc.nodeAt(u), f = u + 1, h = p ? p.content.size : 0, C = f + Math.max(0, Math.min(n.offset, h));
1939
+ return "selection" in e && e.setSelection(je.create(e.doc, C)), !0;
1940
+ }
1941
+ const A = {
1942
+ gray: {
1943
+ text: "#9b9a97",
1944
+ background: "#ebeced"
1945
+ },
1946
+ brown: {
1947
+ text: "#64473a",
1948
+ background: "#e9e5e3"
1949
+ },
1950
+ red: {
1951
+ text: "#e03e3e",
1952
+ background: "#fbe4e4"
1953
+ },
1954
+ orange: {
1955
+ text: "#d9730d",
1956
+ background: "#f6e9d9"
1957
+ },
1958
+ yellow: {
1959
+ text: "#dfab01",
1960
+ background: "#fbf3db"
1961
+ },
1962
+ green: {
1963
+ text: "#4d6461",
1964
+ background: "#ddedea"
1965
+ },
1966
+ blue: {
1967
+ text: "#0b6e99",
1968
+ background: "#ddebf1"
1969
+ },
1970
+ purple: {
1971
+ text: "#6940a5",
1972
+ background: "#eae4f2"
1973
+ },
1974
+ pink: {
1975
+ text: "#ad1a72",
1976
+ background: "#f4dfeb"
1977
+ }
1978
+ }, Go = {
1979
+ gray: {
1980
+ text: "#bebdb8",
1981
+ background: "#9b9a97"
1982
+ },
1983
+ brown: {
1984
+ text: "#8e6552",
1985
+ background: "#64473a"
1986
+ },
1987
+ red: {
1988
+ text: "#ec4040",
1989
+ background: "#be3434"
1990
+ },
1991
+ orange: {
1992
+ text: "#e3790d",
1993
+ background: "#b7600a"
1994
+ },
1995
+ yellow: {
1996
+ text: "#dfab01",
1997
+ background: "#b58b00"
1998
+ },
1999
+ green: {
2000
+ text: "#6b8b87",
2001
+ background: "#4d6461"
2002
+ },
2003
+ blue: {
2004
+ text: "#0e87bc",
2005
+ background: "#0b6e99"
2006
+ },
2007
+ purple: {
2008
+ text: "#8552d7",
2009
+ background: "#6940a5"
2010
+ },
2011
+ pink: {
2012
+ text: "#da208f",
2013
+ background: "#ad1a72"
2014
+ }
2015
+ }, k = {
2016
+ backgroundColor: {
2017
+ default: "default"
2018
+ },
2019
+ textColor: {
2020
+ default: "default"
2021
+ },
2022
+ textAlignment: {
2023
+ default: "left",
2024
+ values: ["left", "center", "right", "justify"]
2025
+ }
2026
+ }, B = (e) => {
2027
+ const t = {};
2028
+ return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment = k.textAlignment.values.includes(
2029
+ e.style.textAlign
2030
+ ) ? e.style.textAlign : void 0, t;
2031
+ }, H = (e, t) => {
2032
+ e.backgroundColor && e.backgroundColor !== k.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in A ? A[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== k.textColor.default && (t.style.color = e.textColor in A ? A[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== k.textAlignment.default && (t.style.textAlign = e.textAlignment);
2033
+ }, Xo = (e = "backgroundColor") => ({
2034
+ default: k.backgroundColor.default,
2035
+ parseHTML: (t) => t.hasAttribute("data-background-color") ? t.getAttribute("data-background-color") : t.style.backgroundColor ? t.style.backgroundColor : k.backgroundColor.default,
2036
+ renderHTML: (t) => t[e] === k.backgroundColor.default ? {} : {
2037
+ "data-background-color": t[e]
2038
+ }
2039
+ }), Jo = (e = "textColor") => ({
2040
+ default: k.textColor.default,
2041
+ parseHTML: (t) => t.hasAttribute("data-text-color") ? t.getAttribute("data-text-color") : t.style.color ? t.style.color : k.textColor.default,
2042
+ renderHTML: (t) => t[e] === k.textColor.default ? {} : {
2043
+ "data-text-color": t[e]
2044
+ }
2045
+ }), Ko = (e = "textAlignment") => ({
2046
+ default: k.textAlignment.default,
2047
+ parseHTML: (t) => t.hasAttribute("data-text-alignment") ? t.getAttribute("data-text-alignment") : t.style.textAlign ? t.style.textAlign : k.textAlignment.default,
2048
+ renderHTML: (t) => t[e] === k.textAlignment.default ? {} : {
2049
+ "data-text-alignment": t[e]
2050
+ }
2051
+ }), ee = (e, t) => {
2052
+ const n = e.querySelector(
2053
+ t
2054
+ );
2055
+ if (!n)
2056
+ return;
2057
+ const o = e.querySelector("figcaption"), r = (o == null ? void 0 : o.textContent) ?? void 0;
2058
+ return { targetElement: n, caption: r };
2059
+ }, ln = (e, t, n) => {
2060
+ const o = document.createElement("div");
2061
+ o.className = "bn-add-file-button";
2062
+ const r = document.createElement("div");
2063
+ r.className = "bn-add-file-button-icon", n ? r.appendChild(n) : r.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>', o.appendChild(r);
2064
+ const s = document.createElement("p");
2065
+ s.className = "bn-add-file-button-text", s.innerHTML = e.type in t.dictionary.file_blocks.add_button_text ? t.dictionary.file_blocks.add_button_text[e.type] : t.dictionary.file_blocks.add_button_text.file, o.appendChild(s);
2066
+ const a = (c) => {
2067
+ c.preventDefault();
2068
+ }, i = () => {
2069
+ t.transact(
2070
+ (c) => c.setMeta(t.filePanel.plugins[0], {
2071
+ block: e
2072
+ })
2073
+ );
2074
+ };
2075
+ return o.addEventListener(
2076
+ "mousedown",
2077
+ a,
2078
+ !0
2079
+ ), o.addEventListener("click", i, !0), {
2080
+ dom: o,
2081
+ destroy: () => {
2082
+ o.removeEventListener(
2083
+ "mousedown",
2084
+ a,
2085
+ !0
2086
+ ), o.removeEventListener(
2087
+ "click",
2088
+ i,
2089
+ !0
2090
+ );
2091
+ }
2092
+ };
2093
+ }, un = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>', dn = (e) => {
2094
+ const t = document.createElement("div");
2095
+ t.className = "bn-file-name-with-icon";
2096
+ const n = document.createElement("div");
2097
+ n.className = "bn-file-icon", n.innerHTML = un, t.appendChild(n);
2098
+ const o = document.createElement("p");
2099
+ return o.className = "bn-file-name", o.textContent = e.props.name, t.appendChild(o), {
2100
+ dom: t
2101
+ };
2102
+ }, ye = (e, t, n, o) => {
2103
+ const r = document.createElement("div");
2104
+ if (r.className = "bn-file-block-content-wrapper", e.props.url === "") {
2105
+ const a = ln(e, t, o);
2106
+ r.appendChild(a.dom);
2107
+ const i = t.onUploadStart((c) => {
2108
+ if (c === e.id) {
2109
+ r.removeChild(a.dom);
2110
+ const l = document.createElement("div");
2111
+ l.className = "bn-file-loading-preview", l.textContent = "Loading...", r.appendChild(l);
2112
+ }
2113
+ });
2114
+ return {
2115
+ dom: r,
2116
+ destroy: () => {
2117
+ i(), a.destroy();
2118
+ }
2119
+ };
2120
+ }
2121
+ const s = { dom: r };
2122
+ if (e.props.showPreview === !1 || !n) {
2123
+ const a = dn(e);
2124
+ r.appendChild(a.dom), s.destroy = () => {
2125
+ var i;
2126
+ (i = a.destroy) == null || i.call(a);
2127
+ };
2128
+ } else
2129
+ r.appendChild(n.dom);
2130
+ if (e.props.caption) {
2131
+ const a = document.createElement("p");
2132
+ a.className = "bn-file-caption", a.textContent = e.props.caption, r.appendChild(a);
2133
+ }
2134
+ return s;
2135
+ }, we = (e, t) => {
2136
+ const n = document.createElement("figure"), o = document.createElement("figcaption");
2137
+ return o.textContent = t, n.appendChild(e), n.appendChild(o), { dom: n };
2138
+ }, te = (e, t) => {
2139
+ const n = document.createElement("div"), o = document.createElement("p");
2140
+ return o.textContent = t, n.appendChild(e), n.appendChild(o), {
2141
+ dom: n
2142
+ };
2143
+ }, Oe = (e) => ({ url: e.src || void 0 }), pn = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>', fn = (e) => ({
2144
+ type: "audio",
2145
+ propSchema: {
2146
+ backgroundColor: k.backgroundColor,
2147
+ // File name.
2148
+ name: {
2149
+ default: ""
2150
+ },
2151
+ // File url.
2152
+ url: {
2153
+ default: ""
2154
+ },
2155
+ // File caption.
2156
+ caption: {
2157
+ default: ""
2158
+ },
2159
+ showPreview: {
2160
+ default: !0
2161
+ }
2162
+ },
2163
+ content: "none"
2164
+ }), hn = (e = {}) => (t) => {
2165
+ if (t.tagName === "AUDIO") {
2166
+ if (t.closest("figure"))
2167
+ return;
2168
+ const { backgroundColor: n } = B(t);
2169
+ return {
2170
+ ...Oe(t),
2171
+ backgroundColor: n
2172
+ };
2173
+ }
2174
+ if (t.tagName === "FIGURE") {
2175
+ const n = ee(t, "audio");
2176
+ if (!n)
2177
+ return;
2178
+ const { targetElement: o, caption: r } = n, { backgroundColor: s } = B(t);
2179
+ return {
2180
+ ...Oe(o),
2181
+ backgroundColor: s,
2182
+ caption: r
2183
+ };
2184
+ }
2185
+ }, mn = (e = {}) => (t, n) => {
2186
+ const o = document.createElement("div");
2187
+ o.innerHTML = e.icon ?? pn;
2188
+ const r = document.createElement("audio");
2189
+ return r.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((s) => {
2190
+ r.src = s;
2191
+ }) : r.src = t.props.url, r.controls = !0, r.contentEditable = "false", r.draggable = !1, ye(
2192
+ t,
2193
+ n,
2194
+ { dom: r },
2195
+ o.firstElementChild
2196
+ );
2197
+ }, gn = (e = {}) => (t, n) => {
2198
+ if (!t.props.url) {
2199
+ const r = document.createElement("p");
2200
+ return r.textContent = "Add audio", {
2201
+ dom: r
2202
+ };
2203
+ }
2204
+ let o;
2205
+ return t.props.showPreview ? (o = document.createElement("audio"), o.src = t.props.url) : (o = document.createElement("a"), o.href = t.props.url, o.textContent = t.props.name || t.props.url), t.props.caption ? t.props.showPreview ? we(o, t.props.caption) : te(o, t.props.caption) : {
2206
+ dom: o
2207
+ };
2208
+ }, bn = M(
2209
+ fn,
2210
+ (e) => ({
2211
+ meta: {
2212
+ fileBlockAccept: ["audio/*"]
2213
+ },
2214
+ parse: hn(e),
2215
+ render: mn(e),
2216
+ toExternalHTML: gn(e),
2217
+ runsBefore: ["file"]
2218
+ })
2219
+ );
2220
+ class Cn {
2221
+ constructor() {
2222
+ // eslint-disable-next-line @typescript-eslint/ban-types
2223
+ x(this, "callbacks", {});
2224
+ }
2225
+ on(t, n) {
2226
+ return this.callbacks[t] || (this.callbacks[t] = []), this.callbacks[t].push(n), () => this.off(t, n);
2227
+ }
2228
+ emit(t, ...n) {
2229
+ const o = this.callbacks[t];
2230
+ o && o.forEach((r) => r.apply(this, n));
2231
+ }
2232
+ off(t, n) {
2233
+ const o = this.callbacks[t];
2234
+ o && (n ? this.callbacks[t] = o.filter((r) => r !== n) : delete this.callbacks[t]);
2235
+ }
2236
+ removeAllListeners() {
2237
+ this.callbacks = {};
2238
+ }
2239
+ }
2240
+ class kn extends Cn {
2241
+ // eslint-disable-next-line
2242
+ constructor(...n) {
2243
+ super();
2244
+ x(this, "plugins", []);
2245
+ /**
2246
+ * Input rules for the block
2247
+ */
2248
+ x(this, "inputRules");
2249
+ /**
2250
+ * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed
2251
+ *
2252
+ * The keys are in the format:
2253
+ * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers
2254
+ * - Key identifiers are based on the strings that can appear in KeyEvent.key
2255
+ * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)
2256
+ * - You may use `Space` as an alias for the " " name
2257
+ * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)
2258
+ * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly
2259
+ * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms
2260
+ *
2261
+ * @example
2262
+ * ```typescript
2263
+ * keyboardShortcuts: {
2264
+ * "Mod-Enter": (ctx) => { return true; },
2265
+ * "Shift-Ctrl-Space": (ctx) => { return true; },
2266
+ * "a": (ctx) => { return true; },
2267
+ * "Space": (ctx) => { return true; }
2268
+ * }
2269
+ * ```
2270
+ */
2271
+ x(this, "keyboardShortcuts");
2272
+ x(this, "tiptapExtensions");
2273
+ }
2274
+ static key() {
2275
+ throw new Error("You must implement the key method in your extension");
2276
+ }
2277
+ addProsemirrorPlugin(n) {
2278
+ this.plugins.push(n);
2279
+ }
2280
+ get priority() {
2281
+ }
2282
+ }
2283
+ function T(e) {
2284
+ const t = Object.create(kn.prototype);
2285
+ return t.key = e.key, t.inputRules = e.inputRules, t.keyboardShortcuts = e.keyboardShortcuts, t.plugins = e.plugins ?? [], t.tiptapExtensions = e.tiptapExtensions, t;
2286
+ }
2287
+ const yn = ({ defaultLanguage: e = "text" }) => ({
2288
+ type: "codeBlock",
2289
+ propSchema: {
2290
+ language: {
2291
+ default: e
2292
+ }
2293
+ },
2294
+ content: "inline"
2295
+ }), wn = M(
2296
+ yn,
2297
+ (e) => ({
2298
+ meta: {
2299
+ code: !0,
2300
+ defining: !0,
2301
+ isolating: !1
2302
+ },
2303
+ parse: (t) => {
2304
+ var r, s;
2305
+ if (t.tagName !== "PRE" || t.childElementCount !== 1 || ((r = t.firstElementChild) == null ? void 0 : r.tagName) !== "CODE")
2306
+ return;
2307
+ const n = t.firstElementChild;
2308
+ return { language: n.getAttribute("data-language") || ((s = n.className.split(" ").find((a) => a.includes("language-"))) == null ? void 0 : s.replace("language-", "")) };
2309
+ },
2310
+ parseContent: ({ el: t, schema: n }) => {
2311
+ const o = Q.fromSchema(n), r = t.firstElementChild;
2312
+ return o.parse(r, {
2313
+ topNode: n.nodes.codeBlock.create()
2314
+ }).content;
2315
+ },
2316
+ render(t, n) {
2317
+ const o = document.createDocumentFragment(), r = document.createElement("pre"), s = document.createElement("code");
2318
+ r.appendChild(s);
2319
+ let a;
2320
+ if (e.supportedLanguages) {
2321
+ const i = document.createElement("select"), c = (d) => {
2322
+ const u = d.target.value;
2323
+ n.updateBlock(t.id, { props: { language: u } });
2324
+ };
2325
+ i.addEventListener("change", c);
2326
+ const l = document.createElement("div");
2327
+ l.contentEditable = "false", i.value = t.props.language || e.defaultLanguage || "text", Object.entries(e.supportedLanguages ?? {}).forEach(
2328
+ ([d, { name: u }]) => {
2329
+ const p = document.createElement("option");
2330
+ p.value = d, p.text = u, i.appendChild(p);
2331
+ }
2332
+ ), l.appendChild(i), o.appendChild(l), a = () => i.removeEventListener("change", c);
2333
+ }
2334
+ return o.appendChild(r), {
2335
+ dom: o,
2336
+ contentDOM: s,
2337
+ destroy: () => {
2338
+ a == null || a();
2339
+ }
2340
+ };
2341
+ },
2342
+ toExternalHTML(t) {
2343
+ const n = document.createElement("pre"), o = document.createElement("code");
2344
+ return o.className = `language-${t.props.language}`, o.dataset.language = t.props.language, n.appendChild(o), {
2345
+ dom: n,
2346
+ contentDOM: o
2347
+ };
2348
+ }
2349
+ }),
2350
+ (e) => [
2351
+ T({
2352
+ key: "code-block-keyboard-shortcuts",
2353
+ keyboardShortcuts: {
2354
+ Delete: ({ editor: t }) => t.transact((n) => {
2355
+ const { block: o } = t.getTextCursorPosition();
2356
+ if (o.type !== "codeBlock")
2357
+ return !1;
2358
+ const { $from: r } = n.selection;
2359
+ return r.parent.textContent ? !1 : (t.removeBlocks([o]), !0);
2360
+ }),
2361
+ Tab: ({ editor: t }) => e.indentLineWithTab === !1 ? !1 : t.transact((n) => {
2362
+ const { block: o } = t.getTextCursorPosition();
2363
+ return o.type === "codeBlock" ? (n.insertText(" "), !0) : !1;
2364
+ }),
2365
+ Enter: ({ editor: t }) => t.transact((n) => {
2366
+ const { block: o, nextBlock: r } = t.getTextCursorPosition();
2367
+ if (o.type !== "codeBlock")
2368
+ return !1;
2369
+ const { $from: s } = n.selection, a = s.parentOffset === s.parent.nodeSize - 2, i = s.parent.textContent.endsWith(`
2370
+
2371
+ `);
2372
+ if (a && i) {
2373
+ if (n.delete(s.pos - 2, s.pos), r)
2374
+ return t.setTextCursorPosition(r, "start"), !0;
2375
+ const [c] = t.insertBlocks(
2376
+ [{ type: "paragraph" }],
2377
+ o,
2378
+ "after"
2379
+ );
2380
+ return t.setTextCursorPosition(c, "start"), !0;
2381
+ }
2382
+ return n.insertText(`
2383
+ `), !0;
2384
+ }),
2385
+ "Shift-Enter": ({ editor: t }) => t.transact(() => {
2386
+ const { block: n } = t.getTextCursorPosition();
2387
+ if (n.type !== "codeBlock")
2388
+ return !1;
2389
+ const [o] = t.insertBlocks(
2390
+ // insert a new paragraph
2391
+ [{ type: "paragraph" }],
2392
+ n,
2393
+ "after"
2394
+ );
2395
+ return t.setTextCursorPosition(o, "start"), !0;
2396
+ })
2397
+ },
2398
+ inputRules: [
2399
+ {
2400
+ find: /^```(.*?)\s$/,
2401
+ replace: ({ match: t }) => {
2402
+ const n = t[1].trim();
2403
+ return {
2404
+ type: "codeBlock",
2405
+ props: {
2406
+ language: {
2407
+ language: vn(e, n) ?? n
2408
+ }.language
2409
+ },
2410
+ content: []
2411
+ };
2412
+ }
2413
+ }
2414
+ ]
2415
+ })
2416
+ ]
2417
+ );
2418
+ function vn(e, t) {
2419
+ var n;
2420
+ return (n = Object.entries(e.supportedLanguages ?? {}).find(
2421
+ ([o, { aliases: r }]) => (r == null ? void 0 : r.includes(t)) || o === t
2422
+ )) == null ? void 0 : n[0];
2423
+ }
2424
+ const He = (e) => ({ url: e.src || void 0 }), En = () => ({
2425
+ type: "file",
2426
+ propSchema: {
2427
+ backgroundColor: k.backgroundColor,
2428
+ // File name.
2429
+ name: {
2430
+ default: ""
2431
+ },
2432
+ // File url.
2433
+ url: {
2434
+ default: ""
2435
+ },
2436
+ // File caption.
2437
+ caption: {
2438
+ default: ""
2439
+ }
2440
+ },
2441
+ content: "none"
2442
+ }), xn = () => (e) => {
2443
+ if (e.tagName === "EMBED") {
2444
+ if (e.closest("figure"))
2445
+ return;
2446
+ const { backgroundColor: t } = B(e);
2447
+ return {
2448
+ ...He(e),
2449
+ backgroundColor: t
2450
+ };
2451
+ }
2452
+ if (e.tagName === "FIGURE") {
2453
+ const t = ee(e, "embed");
2454
+ if (!t)
2455
+ return;
2456
+ const { targetElement: n, caption: o } = t, { backgroundColor: r } = B(e);
2457
+ return {
2458
+ ...He(n),
2459
+ backgroundColor: r,
2460
+ caption: o
2461
+ };
2462
+ }
2463
+ }, Sn = M(En, {
2464
+ meta: {
2465
+ fileBlockAccept: ["*/*"]
2466
+ },
2467
+ parse: xn(),
2468
+ render(e, t) {
2469
+ return ye(e, t);
2470
+ },
2471
+ toExternalHTML(e) {
2472
+ if (!e.props.url) {
2473
+ const n = document.createElement("p");
2474
+ return n.textContent = "Add file", {
2475
+ dom: n
2476
+ };
2477
+ }
2478
+ const t = document.createElement("a");
2479
+ return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? te(t, e.props.caption) : {
2480
+ dom: t
2481
+ };
2482
+ }
2483
+ }), Bn = {
2484
+ set: (e, t) => window.localStorage.setItem(
2485
+ `toggle-${e.id}`,
2486
+ t ? "true" : "false"
2487
+ ),
2488
+ get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
2489
+ }, et = (e, t, n, o = Bn) => {
2490
+ if (!("isToggleable" in e.props) || !e.props.isToggleable)
2491
+ return {
2492
+ dom: n
2493
+ };
2494
+ const r = document.createElement("div"), s = document.createElement("div");
2495
+ s.className = "bn-toggle-wrapper";
2496
+ const a = document.createElement("button");
2497
+ a.className = "bn-toggle-button", a.type = "button", a.innerHTML = // https://fonts.google.com/icons?selected=Material+Symbols+Rounded:chevron_right:FILL@0;wght@700;GRAD@0;opsz@24&icon.query=chevron&icon.style=Rounded&icon.size=24&icon.color=%23e8eaed
2498
+ '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';
2499
+ const i = (h) => h.preventDefault();
2500
+ a.addEventListener("mousedown", i);
2501
+ const c = () => {
2502
+ var h;
2503
+ s.getAttribute("data-show-children") === "true" ? (s.setAttribute("data-show-children", "false"), o.set(t.getBlock(e), !1), r.contains(l) && r.removeChild(l)) : (s.setAttribute("data-show-children", "true"), o.set(t.getBlock(e), !0), ((h = t.getBlock(e)) == null ? void 0 : h.children.length) === 0 && !r.contains(l) && r.appendChild(l));
2504
+ };
2505
+ a.addEventListener("click", c), s.appendChild(a), s.appendChild(n);
2506
+ const l = document.createElement("button");
2507
+ l.className = "bn-toggle-add-block-button", l.type = "button", l.textContent = t.dictionary.toggle_blocks.add_block_button;
2508
+ const d = (h) => h.preventDefault();
2509
+ l.addEventListener(
2510
+ "mousedown",
2511
+ d
2512
+ );
2513
+ const u = () => {
2514
+ t.transact(() => {
2515
+ const h = t.updateBlock(e, {
2516
+ // Single empty block with default type.
2517
+ children: [{}]
2518
+ });
2519
+ t.setTextCursorPosition(h.children[0].id, "end"), t.focus();
2520
+ });
2521
+ };
2522
+ l.addEventListener("click", u), r.appendChild(s);
2523
+ let p = e.children.length;
2524
+ const f = t.onChange(() => {
2525
+ var C;
2526
+ const h = ((C = t.getBlock(e)) == null ? void 0 : C.children.length) ?? 0;
2527
+ h > p ? (s.getAttribute("data-show-children") === "false" && (s.setAttribute("data-show-children", "true"), o.set(t.getBlock(e), !0)), r.contains(l) && r.removeChild(l)) : h === 0 && h < p && (s.getAttribute("data-show-children") === "true" && (s.setAttribute("data-show-children", "false"), o.set(t.getBlock(e), !1)), r.contains(l) && r.removeChild(l)), p = h;
2528
+ });
2529
+ return o.get(e) ? (s.setAttribute("data-show-children", "true"), e.children.length === 0 && r.appendChild(l)) : s.setAttribute("data-show-children", "false"), {
2530
+ dom: r,
2531
+ // Prevents re-renders when the toggle button is clicked.
2532
+ ignoreMutation: (h) => h instanceof MutationRecord && // We want to prevent re-renders when the view changes, so we ignore
2533
+ // all mutations where the `data-show-children` attribute is changed
2534
+ // or the "add block" button is added/removed.
2535
+ (h.type === "attributes" && h.target === s && h.attributeName === "data-show-children" || h.type === "childList" && (h.addedNodes[0] === l || h.removedNodes[0] === l)),
2536
+ destroy: () => {
2537
+ a.removeEventListener("mousedown", i), a.removeEventListener("click", c), l.removeEventListener(
2538
+ "mousedown",
2539
+ d
2540
+ ), l.removeEventListener(
2541
+ "click",
2542
+ u
2543
+ ), f == null || f();
2544
+ }
2545
+ };
2546
+ }, tt = [1, 2, 3, 4, 5, 6], Mn = ({
2547
+ defaultLevel: e = 1,
2548
+ levels: t = tt,
2549
+ allowToggleHeadings: n = !0
2550
+ } = {}) => ({
2551
+ type: "heading",
2552
+ propSchema: {
2553
+ ...k,
2554
+ level: { default: e, values: t },
2555
+ ...n ? { isToggleable: { default: !1, optional: !0 } } : {}
2556
+ },
2557
+ content: "inline"
2558
+ }), Ln = M(
2559
+ Mn,
2560
+ ({ allowToggleHeadings: e = !0 } = {}) => ({
2561
+ meta: {
2562
+ isolating: !1
2563
+ },
2564
+ parse(t) {
2565
+ let n;
2566
+ switch (t.tagName) {
2567
+ case "H1":
2568
+ n = 1;
2569
+ break;
2570
+ case "H2":
2571
+ n = 2;
2572
+ break;
2573
+ case "H3":
2574
+ n = 3;
2575
+ break;
2576
+ case "H4":
2577
+ n = 4;
2578
+ break;
2579
+ case "H5":
2580
+ n = 5;
2581
+ break;
2582
+ case "H6":
2583
+ n = 6;
2584
+ break;
2585
+ default:
2586
+ return;
2587
+ }
2588
+ return {
2589
+ ...B(t),
2590
+ level: n
2591
+ };
2592
+ },
2593
+ render(t, n) {
2594
+ const o = document.createElement(`h${t.props.level}`);
2595
+ return e ? { ...et(t, n, o), contentDOM: o } : {
2596
+ dom: o,
2597
+ contentDOM: o
2598
+ };
2599
+ },
2600
+ toExternalHTML(t) {
2601
+ const n = document.createElement(`h${t.props.level}`);
2602
+ return H(t.props, n), {
2603
+ dom: n,
2604
+ contentDOM: n
2605
+ };
2606
+ }
2607
+ }),
2608
+ ({ levels: e = tt } = {}) => [
2609
+ T({
2610
+ key: "heading-shortcuts",
2611
+ keyboardShortcuts: Object.fromEntries(
2612
+ e.map((t) => [
2613
+ `Mod-Alt-${t}`,
2614
+ ({ editor: n }) => {
2615
+ const o = n.getTextCursorPosition();
2616
+ return n.schema.blockSchema[o.block.type].content !== "inline" ? !1 : (n.updateBlock(o.block, {
2617
+ type: "heading",
2618
+ props: {
2619
+ level: t
2620
+ }
2621
+ }), !0);
2622
+ }
2623
+ ]) ?? []
2624
+ ),
2625
+ inputRules: e.map((t) => ({
2626
+ find: new RegExp(`^(#{${t}})\\s$`),
2627
+ replace({ match: n }) {
2628
+ return {
2629
+ type: "heading",
2630
+ props: {
2631
+ level: n[1].length
2632
+ }
2633
+ };
2634
+ }
2635
+ }))
2636
+ })
2637
+ ]
2638
+ ), nt = (e, t, n, o, r) => {
2639
+ const { dom: s, destroy: a } = ye(
2640
+ e,
2641
+ t,
2642
+ n,
2643
+ r
2644
+ ), i = s;
2645
+ i.style.position = "relative", e.props.url && e.props.showPreview && (e.props.previewWidth ? i.style.width = `${e.props.previewWidth}px` : i.style.width = "fit-content");
2646
+ const c = document.createElement("div");
2647
+ c.className = "bn-resize-handle", c.style.left = "4px";
2648
+ const l = document.createElement("div");
2649
+ l.className = "bn-resize-handle", l.style.right = "4px";
2650
+ const d = document.createElement("div");
2651
+ d.style.position = "absolute", d.style.height = "100%", d.style.width = "100%";
2652
+ let u, p = e.props.previewWidth;
2653
+ const f = (g) => {
2654
+ var V, W;
2655
+ if (!u) {
2656
+ !t.isEditable && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l));
2657
+ return;
2658
+ }
2659
+ let w;
2660
+ const S = "touches" in g ? g.touches[0].clientX : g.clientX;
2661
+ e.props.textAlignment === "center" ? u.handleUsed === "left" ? w = u.initialWidth + (u.initialClientX - S) * 2 : w = u.initialWidth + (S - u.initialClientX) * 2 : u.handleUsed === "left" ? w = u.initialWidth + u.initialClientX - S : w = u.initialWidth + S - u.initialClientX, p = Math.min(
2662
+ Math.max(w, 64),
2663
+ ((W = (V = t.domElement) == null ? void 0 : V.firstElementChild) == null ? void 0 : W.clientWidth) || Number.MAX_VALUE
2664
+ ), i.style.width = `${p}px`;
2665
+ }, h = (g) => {
2666
+ (!g.target || !i.contains(g.target) || !t.isEditable) && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l)), u && (u = void 0, i.contains(d) && i.removeChild(d), t.updateBlock(e, {
2667
+ props: {
2668
+ previewWidth: p
2669
+ }
2670
+ }));
2671
+ }, C = () => {
2672
+ t.isEditable && (o.appendChild(c), o.appendChild(l));
2673
+ }, m = (g) => {
2674
+ g.relatedTarget === c || g.relatedTarget === l || u || t.isEditable && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l));
2675
+ }, b = (g) => {
2676
+ g.preventDefault(), i.contains(d) || i.appendChild(d);
2677
+ const w = "touches" in g ? g.touches[0].clientX : g.clientX;
2678
+ u = {
2679
+ handleUsed: "left",
2680
+ initialWidth: i.clientWidth,
2681
+ initialClientX: w
2682
+ };
2683
+ }, y = (g) => {
2684
+ g.preventDefault(), i.contains(d) || i.appendChild(d);
2685
+ const w = "touches" in g ? g.touches[0].clientX : g.clientX;
2686
+ u = {
2687
+ handleUsed: "right",
2688
+ initialWidth: i.clientWidth,
2689
+ initialClientX: w
2690
+ };
2691
+ };
2692
+ return window.addEventListener("mousemove", f), window.addEventListener("touchmove", f), window.addEventListener("mouseup", h), window.addEventListener("touchend", h), i.addEventListener("mouseenter", C), i.addEventListener("mouseleave", m), c.addEventListener(
2693
+ "mousedown",
2694
+ b
2695
+ ), c.addEventListener(
2696
+ "touchstart",
2697
+ b
2698
+ ), l.addEventListener(
2699
+ "mousedown",
2700
+ y
2701
+ ), l.addEventListener(
2702
+ "touchstart",
2703
+ y
2704
+ ), {
2705
+ dom: i,
2706
+ destroy: () => {
2707
+ a == null || a(), window.removeEventListener("mousemove", f), window.removeEventListener("touchmove", f), window.removeEventListener("mouseup", h), window.removeEventListener("touchend", h), i.removeEventListener("mouseenter", C), i.removeEventListener("mouseleave", m), c.removeEventListener(
2708
+ "mousedown",
2709
+ b
2710
+ ), c.removeEventListener(
2711
+ "touchstart",
2712
+ b
2713
+ ), l.removeEventListener(
2714
+ "mousedown",
2715
+ y
2716
+ ), l.removeEventListener(
2717
+ "touchstart",
2718
+ y
2719
+ );
2720
+ }
2721
+ };
2722
+ }, Pe = (e) => {
2723
+ const t = e.src || void 0, n = e.width || void 0, o = e.alt || void 0;
2724
+ return { url: t, previewWidth: n, name: o };
2725
+ }, Tn = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>', An = (e = {}) => ({
2726
+ type: "image",
2727
+ propSchema: {
2728
+ textAlignment: k.textAlignment,
2729
+ backgroundColor: k.backgroundColor,
2730
+ // File name.
2731
+ name: {
2732
+ default: ""
2733
+ },
2734
+ // File url.
2735
+ url: {
2736
+ default: ""
2737
+ },
2738
+ // File caption.
2739
+ caption: {
2740
+ default: ""
2741
+ },
2742
+ showPreview: {
2743
+ default: !0
2744
+ },
2745
+ // File preview width in px.
2746
+ previewWidth: {
2747
+ default: void 0,
2748
+ type: "number"
2749
+ }
2750
+ },
2751
+ content: "none"
2752
+ }), Nn = (e = {}) => (t) => {
2753
+ if (t.tagName === "IMG") {
2754
+ if (t.closest("figure"))
2755
+ return;
2756
+ const { backgroundColor: n } = B(t);
2757
+ return {
2758
+ ...Pe(t),
2759
+ backgroundColor: n
2760
+ };
2761
+ }
2762
+ if (t.tagName === "FIGURE") {
2763
+ const n = ee(t, "img");
2764
+ if (!n)
2765
+ return;
2766
+ const { targetElement: o, caption: r } = n, { backgroundColor: s } = B(t);
2767
+ return {
2768
+ ...Pe(o),
2769
+ backgroundColor: s,
2770
+ caption: r
2771
+ };
2772
+ }
2773
+ }, In = (e = {}) => (t, n) => {
2774
+ const o = document.createElement("div");
2775
+ o.innerHTML = e.icon ?? Tn;
2776
+ const r = document.createElement("div");
2777
+ r.className = "bn-visual-media-wrapper";
2778
+ const s = document.createElement("img");
2779
+ return s.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((a) => {
2780
+ s.src = a;
2781
+ }) : s.src = t.props.url, s.alt = t.props.name || t.props.caption || "BlockNote image", s.contentEditable = "false", s.draggable = !1, r.appendChild(s), nt(
2782
+ t,
2783
+ n,
2784
+ { dom: r },
2785
+ r,
2786
+ o.firstElementChild
2787
+ );
2788
+ }, On = (e = {}) => (t, n) => {
2789
+ if (!t.props.url) {
2790
+ const r = document.createElement("p");
2791
+ return r.textContent = "Add image", {
2792
+ dom: r
2793
+ };
2794
+ }
2795
+ let o;
2796
+ return t.props.showPreview ? (o = document.createElement("img"), o.src = t.props.url, o.alt = t.props.name || t.props.caption || "BlockNote image", t.props.previewWidth && (o.width = t.props.previewWidth)) : (o = document.createElement("a"), o.href = t.props.url, o.textContent = t.props.name || t.props.url), t.props.caption ? t.props.showPreview ? we(o, t.props.caption) : te(o, t.props.caption) : {
2797
+ dom: o
2798
+ };
2799
+ }, Hn = M(
2800
+ An,
2801
+ (e) => ({
2802
+ meta: {
2803
+ fileBlockAccept: ["image/*"]
2804
+ },
2805
+ parse: Nn(e),
2806
+ render: In(e),
2807
+ toExternalHTML: On(e),
2808
+ runsBefore: ["file"]
2809
+ })
2810
+ ), Qo = (e, t, n) => ({
2811
+ state: o,
2812
+ dispatch: r
2813
+ }) => r ? ot(o.tr, e, t, n) : !0, ot = (e, t, n, o) => {
2814
+ const r = pe(e.doc, t), s = q(r);
2815
+ if (!s.isBlockContainer)
2816
+ return !1;
2817
+ const a = G(e), i = [
2818
+ {
2819
+ type: s.bnBlock.node.type,
2820
+ // always keep blockcontainer type
2821
+ attrs: o ? { ...s.bnBlock.node.attrs, id: void 0 } : {}
2822
+ },
2823
+ {
2824
+ type: n ? s.blockContent.node.type : a.nodes.paragraph,
2825
+ attrs: o ? { ...s.blockContent.node.attrs } : {}
2826
+ }
2827
+ ];
2828
+ return e.split(t, 2, i), !0;
2829
+ }, ne = (e, t) => {
2830
+ const { blockInfo: n, selectionEmpty: o } = e.transact((a) => ({
2831
+ blockInfo: jt(a),
2832
+ selectionEmpty: a.selection.anchor === a.selection.head
2833
+ }));
2834
+ if (!n.isBlockContainer)
2835
+ return !1;
2836
+ const { bnBlock: r, blockContent: s } = n;
2837
+ return s.node.type.name !== t || !o ? !1 : s.node.childCount === 0 ? (e.transact((a) => {
2838
+ ke(a, r.beforePos, {
2839
+ type: "paragraph",
2840
+ props: {}
2841
+ });
2842
+ }), !0) : s.node.childCount > 0 ? e.transact((a) => (a.deleteSelection(), ot(a, a.selection.from, !0))) : !1;
2843
+ };
2844
+ function ve(e, t, n) {
2845
+ var u, p, f;
2846
+ const o = Q.fromSchema(t), r = e, s = document.createElement("div");
2847
+ s.setAttribute("data-node-type", "blockGroup");
2848
+ for (const h of Array.from(r.childNodes))
2849
+ s.appendChild(h.cloneNode(!0));
2850
+ let a = o.parse(s, {
2851
+ topNode: t.nodes.blockGroup.create()
2852
+ });
2853
+ ((p = (u = a.firstChild) == null ? void 0 : u.firstChild) == null ? void 0 : p.type.name) === "checkListItem" && (a = a.copy(
2854
+ a.content.cut(
2855
+ a.firstChild.firstChild.nodeSize + 2
2856
+ )
2857
+ ));
2858
+ const i = (f = a.firstChild) == null ? void 0 : f.firstChild;
2859
+ if (!(i != null && i.isTextblock))
2860
+ return _.from(a);
2861
+ const c = t.nodes[n].create(
2862
+ {},
2863
+ i.content
2864
+ ), l = a.content.cut(
2865
+ // +2 for the `blockGroup` node's start and end markers
2866
+ i.nodeSize + 2
2867
+ );
2868
+ if (l.size > 0) {
2869
+ const h = a.copy(l);
2870
+ return c.content.addToEnd(h);
2871
+ }
2872
+ return c.content;
2873
+ }
2874
+ const Pn = () => ({
2875
+ type: "bulletListItem",
2876
+ propSchema: {
2877
+ ...k
2878
+ },
2879
+ content: "inline"
2880
+ }), Dn = M(
2881
+ Pn,
2882
+ {
2883
+ meta: {
2884
+ isolating: !1
2885
+ },
2886
+ parse(e) {
2887
+ var n;
2888
+ if (e.tagName !== "LI")
2889
+ return;
2890
+ const t = e.parentElement;
2891
+ if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && ((n = t.parentElement) == null ? void 0 : n.tagName) === "UL"))
2892
+ return B(e);
2893
+ },
2894
+ // As `li` elements can contain multiple paragraphs, we need to merge their contents
2895
+ // into a single one so that ProseMirror can parse everything correctly.
2896
+ parseContent: ({ el: e, schema: t }) => ve(e, t, "bulletListItem"),
2897
+ render() {
2898
+ const e = document.createElement("p");
2899
+ return {
2900
+ dom: e,
2901
+ contentDOM: e
2902
+ };
2903
+ },
2904
+ toExternalHTML(e) {
2905
+ const t = document.createElement("li"), n = document.createElement("p");
2906
+ return H(e.props, t), t.appendChild(n), {
2907
+ dom: t,
2908
+ contentDOM: n
2909
+ };
2910
+ }
2911
+ },
2912
+ [
2913
+ T({
2914
+ key: "bullet-list-item-shortcuts",
2915
+ keyboardShortcuts: {
2916
+ Enter: ({ editor: e }) => ne(e, "bulletListItem"),
2917
+ "Mod-Shift-8": ({ editor: e }) => {
2918
+ const t = e.getTextCursorPosition();
2919
+ return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
2920
+ type: "bulletListItem",
2921
+ props: {}
2922
+ }), !0);
2923
+ }
2924
+ },
2925
+ inputRules: [
2926
+ {
2927
+ find: new RegExp("^[-+*]\\s$"),
2928
+ replace() {
2929
+ return {
2930
+ type: "bulletListItem",
2931
+ props: {}
2932
+ };
2933
+ }
2934
+ }
2935
+ ]
2936
+ })
2937
+ ]
2938
+ ), _n = () => ({
2939
+ type: "checkListItem",
2940
+ propSchema: {
2941
+ ...k,
2942
+ checked: { default: !1, type: "boolean" }
2943
+ },
2944
+ content: "inline"
2945
+ }), Rn = M(
2946
+ _n,
2947
+ {
2948
+ meta: {
2949
+ isolating: !1
2950
+ },
2951
+ parse(e) {
2952
+ var n;
2953
+ if (e.tagName === "input")
2954
+ return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
2955
+ if (e.tagName !== "LI")
2956
+ return;
2957
+ const t = e.parentElement;
2958
+ if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && ((n = t.parentElement) == null ? void 0 : n.tagName) === "UL")) {
2959
+ const o = e.querySelector("input[type=checkbox]") || null;
2960
+ return o === null ? void 0 : { ...B(e), checked: o.checked };
2961
+ }
2962
+ },
2963
+ // As `li` elements can contain multiple paragraphs, we need to merge their contents
2964
+ // into a single one so that ProseMirror can parse everything correctly.
2965
+ parseContent: ({ el: e, schema: t }) => ve(e, t, "checkListItem"),
2966
+ render(e, t) {
2967
+ const n = document.createDocumentFragment(), o = document.createElement("input");
2968
+ o.type = "checkbox", o.checked = e.props.checked, e.props.checked && o.setAttribute("checked", ""), o.addEventListener("change", () => {
2969
+ t.updateBlock(e, { props: { checked: !e.props.checked } });
2970
+ });
2971
+ const r = document.createElement("p");
2972
+ return n.appendChild(o), n.appendChild(r), {
2973
+ dom: n,
2974
+ contentDOM: r
2975
+ };
2976
+ },
2977
+ toExternalHTML(e) {
2978
+ const t = document.createElement("li"), n = document.createElement("input");
2979
+ n.type = "checkbox", n.checked = e.props.checked, e.props.checked && n.setAttribute("checked", "");
2980
+ const o = document.createElement("p");
2981
+ return H(e.props, t), t.appendChild(n), t.appendChild(o), {
2982
+ dom: t,
2983
+ contentDOM: o
2984
+ };
2985
+ },
2986
+ runsBefore: ["bulletListItem"]
2987
+ },
2988
+ [
2989
+ T({
2990
+ key: "check-list-item-shortcuts",
2991
+ keyboardShortcuts: {
2992
+ Enter: ({ editor: e }) => ne(e, "checkListItem"),
2993
+ "Mod-Shift-9": ({ editor: e }) => {
2994
+ const t = e.getTextCursorPosition();
2995
+ return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
2996
+ type: "checkListItem",
2997
+ props: {}
2998
+ }), !0);
2999
+ }
3000
+ },
3001
+ inputRules: [
3002
+ {
3003
+ find: new RegExp("\\[\\s*\\]\\s$"),
3004
+ replace() {
3005
+ return {
3006
+ type: "checkListItem",
3007
+ props: {
3008
+ checked: !1
3009
+ },
3010
+ content: []
3011
+ };
3012
+ }
3013
+ },
3014
+ {
3015
+ find: new RegExp("\\[[Xx]\\]\\s$"),
3016
+ replace() {
3017
+ return {
3018
+ type: "checkListItem",
3019
+ props: {
3020
+ checked: !0
3021
+ }
3022
+ };
3023
+ }
3024
+ }
3025
+ ]
3026
+ })
3027
+ ]
3028
+ );
3029
+ function rt(e, t, n, o) {
3030
+ let r = e.firstChild.attrs.start || 1, s = !0;
3031
+ const a = !!e.firstChild.attrs.start, i = q({
3032
+ posBeforeNode: t,
3033
+ node: e
3034
+ });
3035
+ if (!i.isBlockContainer)
3036
+ throw new Error("impossible");
3037
+ const c = n.doc.resolve(i.bnBlock.beforePos).nodeBefore, l = c ? o.get(c) : void 0;
3038
+ return l !== void 0 ? (r = l + 1, s = !1) : c && q({
3039
+ posBeforeNode: i.bnBlock.beforePos - c.nodeSize,
3040
+ node: c
3041
+ }).blockNoteType === "numberedListItem" && (r = rt(
3042
+ c,
3043
+ i.bnBlock.beforePos - c.nodeSize,
3044
+ n,
3045
+ o
3046
+ ).index + 1, s = !1), o.set(e, r), { index: r, isFirst: s, hasStart: a };
3047
+ }
3048
+ function De(e, t) {
3049
+ const n = /* @__PURE__ */ new Map(), o = t.decorations.map(
3050
+ e.mapping,
3051
+ e.doc
3052
+ ), r = [];
3053
+ e.doc.nodesBetween(0, e.doc.nodeSize - 2, (a, i) => {
3054
+ if (a.type.name === "blockContainer" && a.firstChild.type.name === "numberedListItem") {
3055
+ const { index: c, isFirst: l, hasStart: d } = rt(
3056
+ a,
3057
+ i,
3058
+ e,
3059
+ n
3060
+ );
3061
+ o.find(
3062
+ i,
3063
+ i + a.nodeSize,
3064
+ (p) => p.index === c && p.isFirst === l && p.hasStart === d
3065
+ ).length === 0 && r.push(
3066
+ // move in by 1 to account for the block container
3067
+ Tt.node(i + 1, i + a.nodeSize - 1, {
3068
+ "data-index": c.toString()
3069
+ })
3070
+ );
3071
+ }
3072
+ });
3073
+ const s = r.flatMap(
3074
+ (a) => o.find(a.from, a.to)
3075
+ );
3076
+ return {
3077
+ decorations: o.remove(s).add(e.doc, r)
3078
+ };
3079
+ }
3080
+ const Vn = () => new We({
3081
+ key: new Fe("numbered-list-indexing-decorations"),
3082
+ state: {
3083
+ init(e, t) {
3084
+ return De(t.tr, {
3085
+ decorations: Be.empty
3086
+ });
3087
+ },
3088
+ apply(e, t) {
3089
+ return !e.docChanged && !e.selectionSet && t.decorations ? t : De(e, t);
3090
+ }
3091
+ },
3092
+ props: {
3093
+ decorations(e) {
3094
+ var t;
3095
+ return ((t = this.getState(e)) == null ? void 0 : t.decorations) ?? Be.empty;
3096
+ }
3097
+ }
3098
+ }), Wn = () => ({
3099
+ type: "numberedListItem",
3100
+ propSchema: {
3101
+ ...k,
3102
+ start: { default: void 0, type: "number" }
3103
+ },
3104
+ content: "inline"
3105
+ }), Fn = M(
3106
+ Wn,
3107
+ {
3108
+ meta: {
3109
+ isolating: !1
3110
+ },
3111
+ parse(e) {
3112
+ var n;
3113
+ if (e.tagName !== "LI")
3114
+ return;
3115
+ const t = e.parentElement;
3116
+ if (t !== null && (t.tagName === "OL" || t.tagName === "DIV" && ((n = t.parentElement) == null ? void 0 : n.tagName) === "OL")) {
3117
+ const o = parseInt(t.getAttribute("start") || "1"), r = B(e);
3118
+ return e.previousElementSibling || o === 1 ? r : {
3119
+ ...r,
3120
+ start: o
3121
+ };
3122
+ }
3123
+ },
3124
+ // As `li` elements can contain multiple paragraphs, we need to merge their contents
3125
+ // into a single one so that ProseMirror can parse everything correctly.
3126
+ parseContent: ({ el: e, schema: t }) => ve(e, t, "numberedListItem"),
3127
+ render() {
3128
+ const e = document.createElement("p");
3129
+ return {
3130
+ dom: e,
3131
+ contentDOM: e
3132
+ };
3133
+ },
3134
+ toExternalHTML(e) {
3135
+ const t = document.createElement("li"), n = document.createElement("p");
3136
+ return H(e.props, t), t.appendChild(n), {
3137
+ dom: t,
3138
+ contentDOM: n
3139
+ };
3140
+ }
3141
+ },
3142
+ [
3143
+ T({
3144
+ key: "numbered-list-item-shortcuts",
3145
+ inputRules: [
3146
+ {
3147
+ find: new RegExp("^(\\d+)\\.\\s$"),
3148
+ replace({ match: e }) {
3149
+ const t = parseInt(e[1]);
3150
+ return {
3151
+ type: "numberedListItem",
3152
+ props: {
3153
+ start: t !== 1 ? t : void 0
3154
+ }
3155
+ };
3156
+ }
3157
+ }
3158
+ ],
3159
+ keyboardShortcuts: {
3160
+ Enter: ({ editor: e }) => ne(e, "numberedListItem"),
3161
+ "Mod-Shift-7": ({ editor: e }) => {
3162
+ const t = e.getTextCursorPosition();
3163
+ return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
3164
+ type: "numberedListItem",
3165
+ props: {}
3166
+ }), !0);
3167
+ }
3168
+ },
3169
+ plugins: [Vn()]
3170
+ })
3171
+ ]
3172
+ ), jn = () => ({
3173
+ type: "toggleListItem",
3174
+ propSchema: {
3175
+ ...k
3176
+ },
3177
+ content: "inline"
3178
+ }), $n = M(
3179
+ jn,
3180
+ {
3181
+ meta: {
3182
+ isolating: !1
3183
+ },
3184
+ render(e, t) {
3185
+ const n = document.createElement("p");
3186
+ return { ...et(
3187
+ e,
3188
+ t,
3189
+ n
3190
+ ), contentDOM: n };
3191
+ },
3192
+ toExternalHTML(e) {
3193
+ const t = document.createElement("li"), n = document.createElement("p");
3194
+ return H(e.props, t), t.appendChild(n), {
3195
+ dom: t,
3196
+ contentDOM: n
3197
+ };
3198
+ }
3199
+ },
3200
+ [
3201
+ T({
3202
+ key: "toggle-list-item-shortcuts",
3203
+ keyboardShortcuts: {
3204
+ Enter: ({ editor: e }) => ne(e, "toggleListItem"),
3205
+ "Mod-Shift-6": ({ editor: e }) => {
3206
+ const t = e.getTextCursorPosition();
3207
+ return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
3208
+ type: "toggleListItem",
3209
+ props: {}
3210
+ }), !0);
3211
+ }
3212
+ }
3213
+ })
3214
+ ]
3215
+ ), Un = () => ({
3216
+ type: "pageBreak",
3217
+ propSchema: {},
3218
+ content: "none"
3219
+ }), qn = M(
3220
+ Un,
3221
+ {
3222
+ parse(e) {
3223
+ if (e.tagName === "DIV" && e.hasAttribute("data-page-break"))
3224
+ return {};
3225
+ },
3226
+ render() {
3227
+ const e = document.createElement("div");
3228
+ return e.setAttribute("data-page-break", ""), {
3229
+ dom: e
3230
+ };
3231
+ },
3232
+ toExternalHTML() {
3233
+ const e = document.createElement("div");
3234
+ return e.setAttribute("data-page-break", ""), {
3235
+ dom: e
3236
+ };
3237
+ }
3238
+ }
3239
+ ), Yo = (e) => e.extend({
3240
+ blockSpecs: {
3241
+ pageBreak: qn()
3242
+ }
3243
+ }), zn = () => ({
3244
+ type: "paragraph",
3245
+ propSchema: k,
3246
+ content: "inline"
3247
+ }), Zn = M(
3248
+ zn,
3249
+ {
3250
+ meta: {
3251
+ isolating: !1
3252
+ },
3253
+ parse: (e) => {
3254
+ var t;
3255
+ if (e.tagName === "P" && (t = e.textContent) != null && t.trim())
3256
+ return B(e);
3257
+ },
3258
+ render: () => {
3259
+ const e = document.createElement("p");
3260
+ return {
3261
+ dom: e,
3262
+ contentDOM: e
3263
+ };
3264
+ },
3265
+ toExternalHTML: (e) => {
3266
+ const t = document.createElement("p");
3267
+ return H(e.props, t), {
3268
+ dom: t,
3269
+ contentDOM: t
3270
+ };
3271
+ },
3272
+ runsBefore: ["default"]
3273
+ },
3274
+ [
3275
+ T({
3276
+ key: "paragraph-shortcuts",
3277
+ keyboardShortcuts: {
3278
+ "Mod-Alt-0": ({ editor: e }) => {
3279
+ const t = e.getTextCursorPosition();
3280
+ return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
3281
+ type: "paragraph",
3282
+ props: {}
3283
+ }), !0);
3284
+ }
3285
+ }
3286
+ })
3287
+ ]
3288
+ ), Gn = () => ({
3289
+ type: "quote",
3290
+ propSchema: {
3291
+ backgroundColor: k.backgroundColor,
3292
+ textColor: k.textColor
3293
+ },
3294
+ content: "inline"
3295
+ }), Xn = M(
3296
+ Gn,
3297
+ {
3298
+ meta: {
3299
+ isolating: !1
3300
+ },
3301
+ parse(e) {
3302
+ if (e.tagName === "BLOCKQUOTE") {
3303
+ const { backgroundColor: t, textColor: n } = B(e);
3304
+ return { backgroundColor: t, textColor: n };
3305
+ }
3306
+ },
3307
+ render() {
3308
+ const e = document.createElement("blockquote");
3309
+ return {
3310
+ dom: e,
3311
+ contentDOM: e
3312
+ };
3313
+ },
3314
+ toExternalHTML(e) {
3315
+ const t = document.createElement("blockquote");
3316
+ return H(e.props, t), {
3317
+ dom: t,
3318
+ contentDOM: t
3319
+ };
3320
+ }
3321
+ },
3322
+ [
3323
+ T({
3324
+ key: "quote-block-shortcuts",
3325
+ keyboardShortcuts: {
3326
+ "Mod-Alt-q": ({ editor: e }) => {
3327
+ const t = e.getTextCursorPosition();
3328
+ return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
3329
+ type: "quote",
3330
+ props: {}
3331
+ }), !0);
3332
+ }
3333
+ },
3334
+ inputRules: [
3335
+ {
3336
+ find: new RegExp("^>\\s$"),
3337
+ replace() {
3338
+ return {
3339
+ type: "quote",
3340
+ props: {}
3341
+ };
3342
+ }
3343
+ }
3344
+ ]
3345
+ })
3346
+ ]
3347
+ ), Jn = 35, st = 120, er = 31, Kn = Ve.create({
3348
+ name: "BlockNoteTableExtension",
3349
+ addProseMirrorPlugins: () => [
3350
+ pt({
3351
+ cellMinWidth: Jn,
3352
+ defaultCellMinWidth: st,
3353
+ // We set this to null as we implement our own node view in the table
3354
+ // block content. This node view is the same as what's used by default,
3355
+ // but is wrapped in a `blockContent` HTML element.
3356
+ View: null
3357
+ }),
3358
+ ft()
3359
+ ],
3360
+ addKeyboardShortcuts() {
3361
+ return {
3362
+ // Makes enter create a new line within the cell.
3363
+ Enter: () => this.editor.state.selection.empty && this.editor.state.selection.$head.parent.type.name === "tableParagraph" ? (this.editor.commands.insertContent({ type: "hardBreak" }), !0) : !1,
3364
+ // Ensures that backspace won't delete the table if the text cursor is at
3365
+ // the start of a cell and the selection is empty.
3366
+ Backspace: () => {
3367
+ const e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, o = e.$head.node().type.name === "tableParagraph";
3368
+ return t && n && o;
3369
+ },
3370
+ // Enables navigating cells using the tab key.
3371
+ Tab: () => this.editor.commands.command(
3372
+ ({ state: e, dispatch: t, view: n }) => xe(1)(e, t, n)
3373
+ ),
3374
+ "Shift-Tab": () => this.editor.commands.command(
3375
+ ({ state: e, dispatch: t, view: n }) => xe(-1)(e, t, n)
3376
+ )
3377
+ };
3378
+ },
3379
+ extendNodeSchema(e) {
3380
+ const t = {
3381
+ name: e.name,
3382
+ options: e.options,
3383
+ storage: e.storage
3384
+ };
3385
+ return {
3386
+ tableRole: St(
3387
+ Bt(e, "tableRole", t)
3388
+ )
3389
+ };
3390
+ }
3391
+ }), Qn = {
3392
+ textColor: k.textColor
3393
+ }, Yn = D.create({
3394
+ name: "tableHeader",
3395
+ addOptions() {
3396
+ return {
3397
+ HTMLAttributes: {}
3398
+ };
3399
+ },
3400
+ /**
3401
+ * We allow table headers and cells to have multiple tableContent nodes because
3402
+ * when merging cells, prosemirror-tables will concat the contents of the cells naively.
3403
+ * This would cause that content to overflow into other cells when prosemirror tries to enforce the cell structure.
3404
+ *
3405
+ * So, we manually fix this up when reading back in the `nodeToBlock` and only ever place a single tableContent back into the cell.
3406
+ */
3407
+ content: "tableContent+",
3408
+ addAttributes() {
3409
+ return {
3410
+ colspan: {
3411
+ default: 1
3412
+ },
3413
+ rowspan: {
3414
+ default: 1
3415
+ },
3416
+ colwidth: {
3417
+ default: null,
3418
+ parseHTML: (e) => {
3419
+ const t = e.getAttribute("colwidth");
3420
+ return t ? t.split(",").map((o) => parseInt(o, 10)) : null;
3421
+ }
3422
+ }
3423
+ };
3424
+ },
3425
+ tableRole: "header_cell",
3426
+ isolating: !0,
3427
+ parseHTML() {
3428
+ return [
3429
+ {
3430
+ tag: "th",
3431
+ // As `th` elements can contain multiple paragraphs, we need to merge their contents
3432
+ // into a single one so that ProseMirror can parse everything correctly.
3433
+ getContent: (e, t) => at(e, t)
3434
+ }
3435
+ ];
3436
+ },
3437
+ renderHTML({ HTMLAttributes: e }) {
3438
+ return [
3439
+ "th",
3440
+ le(this.options.HTMLAttributes, e),
3441
+ 0
3442
+ ];
3443
+ }
3444
+ }), eo = D.create({
3445
+ name: "tableCell",
3446
+ addOptions() {
3447
+ return {
3448
+ HTMLAttributes: {}
3449
+ };
3450
+ },
3451
+ content: "tableContent+",
3452
+ addAttributes() {
3453
+ return {
3454
+ colspan: {
3455
+ default: 1
3456
+ },
3457
+ rowspan: {
3458
+ default: 1
3459
+ },
3460
+ colwidth: {
3461
+ default: null,
3462
+ parseHTML: (e) => {
3463
+ const t = e.getAttribute("colwidth");
3464
+ return t ? t.split(",").map((o) => parseInt(o, 10)) : null;
3465
+ }
3466
+ }
3467
+ };
3468
+ },
3469
+ tableRole: "cell",
3470
+ isolating: !0,
3471
+ parseHTML() {
3472
+ return [
3473
+ {
3474
+ tag: "td",
3475
+ // As `td` elements can contain multiple paragraphs, we need to merge their contents
3476
+ // into a single one so that ProseMirror can parse everything correctly.
3477
+ getContent: (e, t) => at(e, t)
3478
+ }
3479
+ ];
3480
+ },
3481
+ renderHTML({ HTMLAttributes: e }) {
3482
+ return [
3483
+ "td",
3484
+ le(this.options.HTMLAttributes, e),
3485
+ 0
3486
+ ];
3487
+ }
3488
+ }), to = D.create({
3489
+ name: "table",
3490
+ content: "tableRow+",
3491
+ group: "blockContent",
3492
+ tableRole: "table",
3493
+ marks: "deletion insertion modification",
3494
+ isolating: !0,
3495
+ parseHTML() {
3496
+ return [
3497
+ {
3498
+ tag: "table"
3499
+ }
3500
+ ];
3501
+ },
3502
+ renderHTML({ node: e, HTMLAttributes: t }) {
3503
+ var r, s, a;
3504
+ const n = Ot(
3505
+ this.name,
3506
+ "table",
3507
+ {
3508
+ ...((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {},
3509
+ ...t
3510
+ },
3511
+ ((s = this.options.domAttributes) == null ? void 0 : s.inlineContent) || {}
3512
+ ), o = document.createElement("colgroup");
3513
+ for (const i of e.children[0].children)
3514
+ if (i.attrs.colwidth)
3515
+ for (const l of i.attrs.colwidth) {
3516
+ const d = document.createElement("col");
3517
+ l && (d.style = `width: ${l}px`), o.appendChild(d);
3518
+ }
3519
+ else
3520
+ o.appendChild(document.createElement("col"));
3521
+ return (a = n.dom.firstChild) == null || a.appendChild(o), n;
3522
+ },
3523
+ // This node view is needed for the `columnResizing` plugin. By default, the
3524
+ // plugin adds its own node view, which overrides how the node is rendered vs
3525
+ // `renderHTML`. This means that the wrapping `blockContent` HTML element is
3526
+ // no longer rendered. The `columnResizing` plugin uses the `TableView` as its
3527
+ // default node view. `BlockNoteTableView` extends it by wrapping it in a
3528
+ // `blockContent` element, so the DOM structure is consistent with other block
3529
+ // types.
3530
+ addNodeView() {
3531
+ return ({ node: e, HTMLAttributes: t }) => {
3532
+ var o;
3533
+ class n extends ht {
3534
+ constructor(s, a, i) {
3535
+ super(s, a), this.node = s, this.cellMinWidth = a, this.blockContentHTMLAttributes = i;
3536
+ const c = document.createElement("div");
3537
+ c.className = U(
3538
+ "bn-block-content",
3539
+ i.class
3540
+ ), c.setAttribute("data-content-type", "table");
3541
+ for (const [p, f] of Object.entries(
3542
+ i
3543
+ ))
3544
+ p !== "class" && c.setAttribute(p, f);
3545
+ const l = this.dom, d = document.createElement("div");
3546
+ d.className = "tableWrapper-inner", d.appendChild(l.firstChild), l.appendChild(d), c.appendChild(l);
3547
+ const u = document.createElement("div");
3548
+ u.className = "table-widgets-container", u.style.position = "relative", l.appendChild(u), this.dom = c;
3549
+ }
3550
+ ignoreMutation(s) {
3551
+ return !s.target.closest(".tableWrapper-inner") || super.ignoreMutation(s);
3552
+ }
3553
+ }
3554
+ return new n(e, st, {
3555
+ ...((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {},
3556
+ ...t
3557
+ });
3558
+ };
3559
+ }
3560
+ }), no = D.create({
3561
+ name: "tableParagraph",
3562
+ group: "tableContent",
3563
+ content: "inline*",
3564
+ parseHTML() {
3565
+ return [
3566
+ {
3567
+ tag: "p",
3568
+ getAttrs: (e) => {
3569
+ if (typeof e == "string" || !e.textContent || !e.closest("[data-content-type]"))
3570
+ return !1;
3571
+ const t = e.parentElement;
3572
+ return t === null ? !1 : t.tagName === "TD" || t.tagName === "TH" ? {} : !1;
3573
+ },
3574
+ node: "tableParagraph"
3575
+ }
3576
+ ];
3577
+ },
3578
+ renderHTML({ HTMLAttributes: e }) {
3579
+ return ["p", e, 0];
3580
+ }
3581
+ }), oo = D.create({
3582
+ name: "tableRow",
3583
+ addOptions() {
3584
+ return {
3585
+ HTMLAttributes: {}
3586
+ };
3587
+ },
3588
+ content: "(tableCell | tableHeader)+",
3589
+ tableRole: "row",
3590
+ marks: "deletion insertion modification",
3591
+ parseHTML() {
3592
+ return [{ tag: "tr" }];
3593
+ },
3594
+ renderHTML({ HTMLAttributes: e }) {
3595
+ return [
3596
+ "tr",
3597
+ le(this.options.HTMLAttributes, e),
3598
+ 0
3599
+ ];
3600
+ }
3601
+ });
3602
+ function at(e, t) {
3603
+ const o = Q.fromSchema(t).parse(e, {
3604
+ topNode: t.nodes.blockGroup.create()
3605
+ }), r = [];
3606
+ return o.content.descendants((s) => {
3607
+ if (s.isInline)
3608
+ return r.push(s), !1;
3609
+ }), _.fromArray(r);
3610
+ }
3611
+ const ro = () => _t(
3612
+ { node: to, type: "table", content: "table" },
3613
+ Qn,
3614
+ [
3615
+ T({
3616
+ key: "table-extensions",
3617
+ tiptapExtensions: [
3618
+ Kn,
3619
+ no,
3620
+ Yn,
3621
+ eo,
3622
+ oo
3623
+ ]
3624
+ })
3625
+ ]
3626
+ ), _e = (e) => {
3627
+ const t = e.src || void 0, n = e.width || void 0;
3628
+ return { url: t, previewWidth: n };
3629
+ }, so = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>', ao = (e) => ({
3630
+ type: "video",
3631
+ propSchema: {
3632
+ textAlignment: k.textAlignment,
3633
+ backgroundColor: k.backgroundColor,
3634
+ name: { default: "" },
3635
+ url: { default: "" },
3636
+ caption: { default: "" },
3637
+ showPreview: { default: !0 },
3638
+ previewWidth: { default: void 0, type: "number" }
3639
+ },
3640
+ content: "none"
3641
+ }), io = (e) => (t) => {
3642
+ if (t.tagName === "VIDEO") {
3643
+ if (t.closest("figure"))
3644
+ return;
3645
+ const { backgroundColor: n } = B(t);
3646
+ return {
3647
+ ..._e(t),
3648
+ backgroundColor: n
3649
+ };
3650
+ }
3651
+ if (t.tagName === "FIGURE") {
3652
+ const n = ee(t, "video");
3653
+ if (!n)
3654
+ return;
3655
+ const { targetElement: o, caption: r } = n, { backgroundColor: s } = B(t);
3656
+ return {
3657
+ ..._e(o),
3658
+ backgroundColor: s,
3659
+ caption: r
3660
+ };
3661
+ }
3662
+ }, co = M(
3663
+ ao,
3664
+ (e) => ({
3665
+ meta: {
3666
+ fileBlockAccept: ["video/*"]
3667
+ },
3668
+ parse: io(),
3669
+ render(t, n) {
3670
+ const o = document.createElement("div");
3671
+ o.innerHTML = e.icon ?? so;
3672
+ const r = document.createElement("div");
3673
+ r.className = "bn-visual-media-wrapper";
3674
+ const s = document.createElement("video");
3675
+ return s.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((a) => {
3676
+ s.src = a;
3677
+ }) : s.src = t.props.url, s.controls = !0, s.contentEditable = "false", s.draggable = !1, s.width = t.props.previewWidth, r.appendChild(s), nt(
3678
+ t,
3679
+ n,
3680
+ { dom: r },
3681
+ r,
3682
+ o.firstElementChild
3683
+ );
3684
+ },
3685
+ toExternalHTML(t) {
3686
+ if (!t.props.url) {
3687
+ const o = document.createElement("p");
3688
+ return o.textContent = "Add video", {
3689
+ dom: o
3690
+ };
3691
+ }
3692
+ let n;
3693
+ return t.props.showPreview ? (n = document.createElement("video"), n.src = t.props.url, t.props.previewWidth && (n.width = t.props.previewWidth)) : (n = document.createElement("a"), n.href = t.props.url, n.textContent = t.props.name || t.props.url), t.props.caption ? t.props.showPreview ? we(n, t.props.caption) : te(n, t.props.caption) : {
3694
+ dom: n
3695
+ };
3696
+ },
3697
+ runsBefore: ["file"]
3698
+ })
3699
+ ), tr = async (e) => {
3700
+ const t = new FormData();
3701
+ return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
3702
+ method: "POST",
3703
+ body: t
3704
+ })).json()).data.url.replace(
3705
+ "tmpfiles.org/",
3706
+ "tmpfiles.org/dl/"
3707
+ );
3708
+ };
3709
+ function E(e, t, n) {
3710
+ if (!(t in e.schema.blockSpecs))
3711
+ return !1;
3712
+ if (!n)
3713
+ return !0;
3714
+ for (const [o, r] of Object.entries(n)) {
3715
+ if (!(o in e.schema.blockSpecs[t].config.propSchema))
3716
+ return !1;
3717
+ if (typeof r == "string") {
3718
+ if (e.schema.blockSpecs[t].config.propSchema[o].default && typeof e.schema.blockSpecs[t].config.propSchema[o].default !== r || e.schema.blockSpecs[t].config.propSchema[o].type && e.schema.blockSpecs[t].config.propSchema[o].type !== r)
3719
+ return !1;
3720
+ } else {
3721
+ if (e.schema.blockSpecs[t].config.propSchema[o].default !== r.default || e.schema.blockSpecs[t].config.propSchema[o].default === void 0 && r.default === void 0 && e.schema.blockSpecs[t].config.propSchema[o].type !== r.type || typeof e.schema.blockSpecs[t].config.propSchema[o].values != typeof r.values)
3722
+ return !1;
3723
+ if (typeof e.schema.blockSpecs[t].config.propSchema[o].values == "object" && typeof r.values == "object") {
3724
+ if (e.schema.blockSpecs[t].config.propSchema[o].values.length !== r.values.length)
3725
+ return !1;
3726
+ for (let s = 0; s < e.schema.blockSpecs[t].config.propSchema[o].values.length; s++)
3727
+ if (e.schema.blockSpecs[t].config.propSchema[o].values[s] !== r.values[s])
3728
+ return !1;
3729
+ }
3730
+ }
3731
+ }
3732
+ return !0;
3733
+ }
3734
+ function nr(e, t, n, o) {
3735
+ return E(t, n, o) && e.type === n;
3736
+ }
3737
+ function or(e) {
3738
+ return e instanceof mt;
3739
+ }
3740
+ function lo(e) {
3741
+ let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
3742
+ for (; n === "none"; ) {
3743
+ if (t = e.getTextCursorPosition().nextBlock, t === void 0)
3744
+ return;
3745
+ n = e.schema.blockSchema[t.type].content, e.setTextCursorPosition(t, "end");
3746
+ }
3747
+ }
3748
+ function v(e, t) {
3749
+ const n = e.getTextCursorPosition().block;
3750
+ if (n.content === void 0)
3751
+ throw new Error("Slash Menu open in a block that doesn't contain content.");
3752
+ let o;
3753
+ return Array.isArray(n.content) && (n.content.length === 1 && I(n.content[0]) && n.content[0].type === "text" && n.content[0].text === "/" || n.content.length === 0) ? (o = e.updateBlock(n, t), e.setTextCursorPosition(o)) : (o = e.insertBlocks([t], n, "after")[0], e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)), lo(e), o;
3754
+ }
3755
+ function rr(e) {
3756
+ const t = [];
3757
+ return E(e, "heading", { level: "number" }) && t.push(
3758
+ {
3759
+ onItemClick: () => {
3760
+ v(e, {
3761
+ type: "heading",
3762
+ props: { level: 1 }
3763
+ });
3764
+ },
3765
+ badge: L("Mod-Alt-1"),
3766
+ key: "heading",
3767
+ ...e.dictionary.slash_menu.heading
3768
+ },
3769
+ {
3770
+ onItemClick: () => {
3771
+ v(e, {
3772
+ type: "heading",
3773
+ props: { level: 2 }
3774
+ });
3775
+ },
3776
+ badge: L("Mod-Alt-2"),
3777
+ key: "heading_2",
3778
+ ...e.dictionary.slash_menu.heading_2
3779
+ },
3780
+ {
3781
+ onItemClick: () => {
3782
+ v(e, {
3783
+ type: "heading",
3784
+ props: { level: 3 }
3785
+ });
3786
+ },
3787
+ badge: L("Mod-Alt-3"),
3788
+ key: "heading_3",
3789
+ ...e.dictionary.slash_menu.heading_3
3790
+ }
3791
+ ), E(e, "quote") && t.push({
3792
+ onItemClick: () => {
3793
+ v(e, {
3794
+ type: "quote"
3795
+ });
3796
+ },
3797
+ key: "quote",
3798
+ ...e.dictionary.slash_menu.quote
3799
+ }), E(e, "toggleListItem") && t.push({
3800
+ onItemClick: () => {
3801
+ v(e, {
3802
+ type: "toggleListItem"
3803
+ });
3804
+ },
3805
+ badge: L("Mod-Shift-6"),
3806
+ key: "toggle_list",
3807
+ ...e.dictionary.slash_menu.toggle_list
3808
+ }), E(e, "numberedListItem") && t.push({
3809
+ onItemClick: () => {
3810
+ v(e, {
3811
+ type: "numberedListItem"
3812
+ });
3813
+ },
3814
+ badge: L("Mod-Shift-7"),
3815
+ key: "numbered_list",
3816
+ ...e.dictionary.slash_menu.numbered_list
3817
+ }), E(e, "bulletListItem") && t.push({
3818
+ onItemClick: () => {
3819
+ v(e, {
3820
+ type: "bulletListItem"
3821
+ });
3822
+ },
3823
+ badge: L("Mod-Shift-8"),
3824
+ key: "bullet_list",
3825
+ ...e.dictionary.slash_menu.bullet_list
3826
+ }), E(e, "checkListItem") && t.push({
3827
+ onItemClick: () => {
3828
+ v(e, {
3829
+ type: "checkListItem"
3830
+ });
3831
+ },
3832
+ badge: L("Mod-Shift-9"),
3833
+ key: "check_list",
3834
+ ...e.dictionary.slash_menu.check_list
3835
+ }), E(e, "paragraph") && t.push({
3836
+ onItemClick: () => {
3837
+ v(e, {
3838
+ type: "paragraph"
3839
+ });
3840
+ },
3841
+ badge: L("Mod-Alt-0"),
3842
+ key: "paragraph",
3843
+ ...e.dictionary.slash_menu.paragraph
3844
+ }), E(e, "codeBlock") && t.push({
3845
+ onItemClick: () => {
3846
+ v(e, {
3847
+ type: "codeBlock"
3848
+ });
3849
+ },
3850
+ badge: L("Mod-Alt-c"),
3851
+ key: "code_block",
3852
+ ...e.dictionary.slash_menu.code_block
3853
+ }), E(e, "table") && t.push({
3854
+ onItemClick: () => {
3855
+ v(e, {
3856
+ type: "table",
3857
+ content: {
3858
+ type: "tableContent",
3859
+ rows: [
3860
+ {
3861
+ cells: ["", "", ""]
3862
+ },
3863
+ {
3864
+ cells: ["", "", ""]
3865
+ }
3866
+ ]
3867
+ }
3868
+ });
3869
+ },
3870
+ badge: void 0,
3871
+ key: "table",
3872
+ ...e.dictionary.slash_menu.table
3873
+ }), E(e, "image", { url: "string" }) && t.push({
3874
+ onItemClick: () => {
3875
+ const n = v(e, {
3876
+ type: "image"
3877
+ });
3878
+ e.transact(
3879
+ (o) => o.setMeta(e.filePanel.plugins[0], {
3880
+ block: n
3881
+ })
3882
+ );
3883
+ },
3884
+ key: "image",
3885
+ ...e.dictionary.slash_menu.image
3886
+ }), E(e, "video", { url: "string" }) && t.push({
3887
+ onItemClick: () => {
3888
+ const n = v(e, {
3889
+ type: "video"
3890
+ });
3891
+ e.transact(
3892
+ (o) => o.setMeta(e.filePanel.plugins[0], {
3893
+ block: n
3894
+ })
3895
+ );
3896
+ },
3897
+ key: "video",
3898
+ ...e.dictionary.slash_menu.video
3899
+ }), E(e, "audio", { url: "string" }) && t.push({
3900
+ onItemClick: () => {
3901
+ const n = v(e, {
3902
+ type: "audio"
3903
+ });
3904
+ e.transact(
3905
+ (o) => o.setMeta(e.filePanel.plugins[0], {
3906
+ block: n
3907
+ })
3908
+ );
3909
+ },
3910
+ key: "audio",
3911
+ ...e.dictionary.slash_menu.audio
3912
+ }), E(e, "file", { url: "string" }) && t.push({
3913
+ onItemClick: () => {
3914
+ const n = v(e, {
3915
+ type: "file"
3916
+ });
3917
+ e.transact(
3918
+ (o) => o.setMeta(e.filePanel.plugins[0], {
3919
+ block: n
3920
+ })
3921
+ );
3922
+ },
3923
+ key: "file",
3924
+ ...e.dictionary.slash_menu.file
3925
+ }), E(e, "heading", {
3926
+ level: "number",
3927
+ isToggleable: "boolean"
3928
+ }) && t.push(
3929
+ {
3930
+ onItemClick: () => {
3931
+ v(e, {
3932
+ type: "heading",
3933
+ props: { level: 1, isToggleable: !0 }
3934
+ });
3935
+ },
3936
+ key: "toggle_heading",
3937
+ ...e.dictionary.slash_menu.toggle_heading
3938
+ },
3939
+ {
3940
+ onItemClick: () => {
3941
+ v(e, {
3942
+ type: "heading",
3943
+ props: { level: 2, isToggleable: !0 }
3944
+ });
3945
+ },
3946
+ key: "toggle_heading_2",
3947
+ ...e.dictionary.slash_menu.toggle_heading_2
3948
+ },
3949
+ {
3950
+ onItemClick: () => {
3951
+ v(e, {
3952
+ type: "heading",
3953
+ props: { level: 3, isToggleable: !0 }
3954
+ });
3955
+ },
3956
+ key: "toggle_heading_3",
3957
+ ...e.dictionary.slash_menu.toggle_heading_3
3958
+ }
3959
+ ), E(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((n) => n > 3).forEach((n) => {
3960
+ t.push({
3961
+ onItemClick: () => {
3962
+ v(e, {
3963
+ type: "heading",
3964
+ props: { level: n }
3965
+ });
3966
+ },
3967
+ key: `heading_${n}`,
3968
+ ...e.dictionary.slash_menu[`heading_${n}`]
3969
+ });
3970
+ }), t.push({
3971
+ onItemClick: () => {
3972
+ e.openSuggestionMenu(":", {
3973
+ deleteTriggerCharacter: !0,
3974
+ ignoreQueryLength: !0
3975
+ });
3976
+ },
3977
+ key: "emoji",
3978
+ ...e.dictionary.slash_menu.emoji
3979
+ }), t;
3980
+ }
3981
+ function sr(e, t) {
3982
+ return e.filter(
3983
+ ({ title: n, aliases: o }) => n.toLowerCase().includes(t.toLowerCase()) || o && o.filter(
3984
+ (r) => r.toLowerCase().includes(t.toLowerCase())
3985
+ ).length !== 0
3986
+ );
3987
+ }
3988
+ function uo(e) {
3989
+ return "pageBreak" in e.schema.blockSchema;
3990
+ }
3991
+ function ar(e) {
3992
+ const t = [];
3993
+ return uo(e) && t.push({
3994
+ ...e.dictionary.slash_menu.page_break,
3995
+ onItemClick: () => {
3996
+ v(e, {
3997
+ type: "pageBreak"
3998
+ });
3999
+ },
4000
+ key: "page_break"
4001
+ }), t;
4002
+ }
4003
+ const po = {
4004
+ audio: bn(),
4005
+ bulletListItem: Dn(),
4006
+ checkListItem: Rn(),
4007
+ codeBlock: wn(),
4008
+ file: Sn(),
4009
+ heading: Ln(),
4010
+ image: Hn(),
4011
+ numberedListItem: Fn(),
4012
+ paragraph: Zn(),
4013
+ quote: Xn(),
4014
+ table: ro(),
4015
+ toggleListItem: $n(),
4016
+ video: co()
4017
+ }, fo = Xe(
4018
+ {
4019
+ type: "textColor",
4020
+ propSchema: "string"
4021
+ },
4022
+ {
4023
+ render: () => {
4024
+ const e = document.createElement("span");
4025
+ return {
4026
+ dom: e,
4027
+ contentDOM: e
4028
+ };
4029
+ },
4030
+ toExternalHTML: (e) => {
4031
+ const t = document.createElement("span");
4032
+ return e !== k.textColor.default && (t.style.color = e in A ? A[e].text : e), {
4033
+ dom: t,
4034
+ contentDOM: t
4035
+ };
4036
+ },
4037
+ parse: (e) => {
4038
+ if (e.tagName === "SPAN" && e.style.color)
4039
+ return e.style.color;
4040
+ }
4041
+ }
4042
+ ), ho = Xe(
4043
+ {
4044
+ type: "backgroundColor",
4045
+ propSchema: "string"
4046
+ },
4047
+ {
4048
+ render: () => {
4049
+ const e = document.createElement("span");
4050
+ return {
4051
+ dom: e,
4052
+ contentDOM: e
4053
+ };
4054
+ },
4055
+ toExternalHTML: (e) => {
4056
+ const t = document.createElement("span");
4057
+ return e !== k.backgroundColor.default && (t.style.backgroundColor = e in A ? A[e].background : e), {
4058
+ dom: t,
4059
+ contentDOM: t
4060
+ };
4061
+ },
4062
+ parse: (e) => {
4063
+ if (e.tagName === "SPAN" && e.style.backgroundColor)
4064
+ return e.style.backgroundColor;
4065
+ }
4066
+ }
4067
+ ), it = {
4068
+ bold: F(gt, "boolean"),
4069
+ italic: F(Ct, "boolean"),
4070
+ underline: F(yt, "boolean"),
4071
+ strike: F(kt, "boolean"),
4072
+ code: F(bt, "boolean"),
4073
+ textColor: fo,
4074
+ backgroundColor: ho
4075
+ }, ir = Ge(it), ct = {
4076
+ text: { config: "text", implementation: {} },
4077
+ link: { config: "link", implementation: {} }
4078
+ }, cr = ze(
4079
+ ct
4080
+ );
4081
+ class lt extends Yt {
4082
+ static create(t) {
4083
+ return new lt({
4084
+ blockSpecs: (t == null ? void 0 : t.blockSpecs) ?? po,
4085
+ inlineContentSpecs: (t == null ? void 0 : t.inlineContentSpecs) ?? ct,
4086
+ styleSpecs: (t == null ? void 0 : t.styleSpecs) ?? it
4087
+ });
4088
+ }
4089
+ }
4090
+ export {
4091
+ po as $,
4092
+ Fn as A,
4093
+ jn as B,
4094
+ $n as C,
4095
+ Un as D,
4096
+ er as E,
4097
+ pn as F,
4098
+ qn as G,
4099
+ Yo as H,
4100
+ zn as I,
4101
+ Zn as J,
4102
+ Gn as K,
4103
+ Xn as L,
4104
+ Qn as M,
4105
+ ro as N,
4106
+ so as O,
4107
+ ao as P,
4108
+ io as Q,
4109
+ co as R,
4110
+ Bn as S,
4111
+ et as T,
4112
+ tr as U,
4113
+ uo as V,
4114
+ ar as W,
4115
+ lt as X,
4116
+ Ot as Y,
4117
+ Le as Z,
4118
+ Ht as _,
4119
+ st as a,
4120
+ Go as a$,
4121
+ it as a0,
4122
+ ir as a1,
4123
+ ct as a2,
4124
+ cr as a3,
4125
+ E as a4,
4126
+ nr as a5,
4127
+ or as a6,
4128
+ k as a7,
4129
+ B as a8,
4130
+ H as a9,
4131
+ Oo as aA,
4132
+ Qo as aB,
4133
+ zo as aC,
4134
+ $o as aD,
4135
+ Wo as aE,
4136
+ Uo as aF,
4137
+ Vo as aG,
4138
+ Je as aH,
4139
+ en as aI,
4140
+ tn as aJ,
4141
+ qo as aK,
4142
+ Fo as aL,
4143
+ jo as aM,
4144
+ U as aN,
4145
+ $e as aO,
4146
+ ke as aP,
4147
+ Ho as aQ,
4148
+ Zo as aR,
4149
+ To as aS,
4150
+ an as aT,
4151
+ fe as aU,
4152
+ me as aV,
4153
+ ge as aW,
4154
+ R as aX,
4155
+ be as aY,
4156
+ T as aZ,
4157
+ A as a_,
4158
+ Xo as aa,
4159
+ Jo as ab,
4160
+ Ko as ac,
4161
+ Ut as ad,
4162
+ P as ae,
4163
+ Do as af,
4164
+ _o as ag,
4165
+ Pt as ah,
4166
+ Ro as ai,
4167
+ G as aj,
4168
+ Y as ak,
4169
+ on as al,
4170
+ X as am,
4171
+ Qe as an,
4172
+ Z as ao,
4173
+ rn as ap,
4174
+ pe as aq,
4175
+ jt as ar,
4176
+ Po as as,
4177
+ he as at,
4178
+ q as au,
4179
+ $t as av,
4180
+ Ce as aw,
4181
+ kn as ax,
4182
+ Cn as ay,
4183
+ Ft as az,
4184
+ hn as b,
4185
+ v as b0,
4186
+ rr as b1,
4187
+ sr as b2,
4188
+ Rt as b3,
4189
+ Vt as b4,
4190
+ Wt as b5,
4191
+ Io as b6,
4192
+ M as b7,
4193
+ Dt as b8,
4194
+ ae as b9,
4195
+ _t as ba,
4196
+ qt as bb,
4197
+ ze as bc,
4198
+ Me as bd,
4199
+ Ue as be,
4200
+ I as bf,
4201
+ Zt as bg,
4202
+ Xe as bh,
4203
+ zt as bi,
4204
+ J as bj,
4205
+ Ze as bk,
4206
+ F as bl,
4207
+ Ge as bm,
4208
+ Yt as bn,
4209
+ It as bo,
4210
+ L as bp,
4211
+ Ao as bq,
4212
+ K as br,
4213
+ No as bs,
4214
+ re as bt,
4215
+ j as bu,
4216
+ de as bv,
4217
+ $ as bw,
4218
+ se as bx,
4219
+ fn as c,
4220
+ mn as d,
4221
+ gn as e,
4222
+ bn as f,
4223
+ yn as g,
4224
+ wn as h,
4225
+ vn as i,
4226
+ En as j,
4227
+ xn as k,
4228
+ Sn as l,
4229
+ Mn as m,
4230
+ Ln as n,
4231
+ Tn as o,
4232
+ Oe as p,
4233
+ An as q,
4234
+ Nn as r,
4235
+ In as s,
4236
+ On as t,
4237
+ Hn as u,
4238
+ Pn as v,
4239
+ Dn as w,
4240
+ _n as x,
4241
+ Rn as y,
4242
+ Wn as z
4243
+ };
4244
+ //# sourceMappingURL=BlockNoteSchema-CZez1nQf.js.map