@blocknote/core 0.41.1 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/BlockNoteSchema-Bi-eeHal.js +3288 -0
  2. package/dist/BlockNoteSchema-Bi-eeHal.js.map +1 -0
  3. package/dist/BlockNoteSchema-DjDaA2C3.cjs +6 -0
  4. package/dist/BlockNoteSchema-DjDaA2C3.cjs.map +1 -0
  5. package/dist/blockToNode-DIfPWLH8.js +1140 -0
  6. package/dist/blockToNode-DIfPWLH8.js.map +1 -0
  7. package/dist/blockToNode-w7H99R6p.cjs +7 -0
  8. package/dist/blockToNode-w7H99R6p.cjs.map +1 -0
  9. package/dist/blocknote.cjs +4 -4
  10. package/dist/blocknote.cjs.map +1 -1
  11. package/dist/blocknote.js +1413 -1366
  12. package/dist/blocknote.js.map +1 -1
  13. package/dist/blocks.cjs +1 -1
  14. package/dist/blocks.js +1 -1
  15. package/dist/comments.cjs +1 -1
  16. package/dist/comments.cjs.map +1 -1
  17. package/dist/comments.js +49 -49
  18. package/dist/comments.js.map +1 -1
  19. package/dist/en-Cl87Uuyf.cjs.map +1 -1
  20. package/dist/en-njEqD7AG.js.map +1 -1
  21. package/dist/locales.cjs.map +1 -1
  22. package/dist/locales.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -0
  24. package/dist/webpack-stats.json +1 -1
  25. package/dist/yjs.cjs +2 -0
  26. package/dist/yjs.cjs.map +1 -0
  27. package/dist/yjs.js +44 -0
  28. package/dist/yjs.js.map +1 -0
  29. package/package.json +30 -25
  30. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +19 -6
  31. package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +173 -0
  32. package/src/api/nodeConversions/nodeToBlock.ts +17 -14
  33. package/src/blocks/Code/block.ts +1 -0
  34. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +2 -1
  35. package/src/blocks/defaultBlockTypeGuards.ts +7 -18
  36. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +3 -1
  37. package/src/editor/BlockNoteEditor.test.ts +70 -1
  38. package/src/editor/BlockNoteEditor.ts +55 -4
  39. package/src/editor/managers/ExportManager.ts +1 -1
  40. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +2 -2
  41. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +2 -2
  42. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
  43. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
  44. package/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.ts +10 -3
  45. package/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.ts +130 -0
  46. package/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.ts +34 -21
  47. package/src/extensions/Comments/CommentsPlugin.ts +37 -7
  48. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +30 -128
  49. package/src/extensions/SideMenu/SideMenuPlugin.ts +2 -0
  50. package/src/index.ts +1 -0
  51. package/src/schema/inlineContent/createSpec.ts +3 -0
  52. package/src/schema/inlineContent/types.ts +1 -0
  53. package/src/schema/schema.ts +49 -6
  54. package/src/schema/styles/createSpec.ts +6 -0
  55. package/src/schema/styles/types.ts +1 -0
  56. package/src/yjs/index.ts +1 -0
  57. package/src/yjs/utils.test.ts +1023 -0
  58. package/src/yjs/utils.ts +150 -0
  59. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
  60. package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +32 -0
  61. package/types/src/api/nodeConversions/nodeToBlock.d.ts +1 -1
  62. package/types/src/editor/BlockNoteEditor.d.ts +6 -1
  63. package/types/src/editor/managers/ExportManager.d.ts +1 -1
  64. package/types/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
  65. package/types/src/extensions/Comments/CommentsPlugin.d.ts +1 -1
  66. package/types/src/index.d.ts +1 -0
  67. package/types/src/schema/inlineContent/createSpec.d.ts +1 -0
  68. package/types/src/schema/inlineContent/types.d.ts +1 -0
  69. package/types/src/schema/styles/createSpec.d.ts +1 -0
  70. package/types/src/schema/styles/types.d.ts +1 -0
  71. package/types/src/yjs/index.d.ts +1 -0
  72. package/types/src/yjs/utils.d.ts +55 -0
  73. package/types/src/yjs/utils.test.d.ts +1 -0
  74. package/dist/BlockNoteSchema-COA0fsXW.cjs +0 -11
  75. package/dist/BlockNoteSchema-COA0fsXW.cjs.map +0 -1
  76. package/dist/BlockNoteSchema-CYRHak18.js +0 -4375
  77. package/dist/BlockNoteSchema-CYRHak18.js.map +0 -1
  78. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +0 -46
  79. package/src/extensions/TextColor/TextColorMark.ts +0 -38
  80. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +0 -10
  81. package/types/src/extensions/TextColor/TextColorMark.d.ts +0 -10
@@ -0,0 +1,150 @@
1
+ import {
2
+ prosemirrorToYDoc,
3
+ prosemirrorToYXmlFragment,
4
+ yXmlFragmentToProseMirrorRootNode,
5
+ } from "y-prosemirror";
6
+ import * as Y from "yjs";
7
+
8
+ import {
9
+ type Block,
10
+ type BlockNoteEditor,
11
+ type BlockSchema,
12
+ type InlineContentSchema,
13
+ type PartialBlock,
14
+ type StyleSchema,
15
+ blockToNode,
16
+ docToBlocks,
17
+ } from "../index.js";
18
+
19
+ /**
20
+ * Turn Prosemirror JSON to BlockNote style JSON
21
+ * @param editor BlockNote editor
22
+ * @param json Prosemirror JSON
23
+ * @returns BlockNote style JSON
24
+ */
25
+ export function _prosemirrorJSONToBlocks<
26
+ BSchema extends BlockSchema,
27
+ ISchema extends InlineContentSchema,
28
+ SSchema extends StyleSchema,
29
+ >(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, json: any) {
30
+ // note: theoretically this should also be possible without creating prosemirror nodes,
31
+ // but this is definitely the easiest way
32
+ const doc = editor.pmSchema.nodeFromJSON(json);
33
+ return docToBlocks<BSchema, ISchema, SSchema>(doc);
34
+ }
35
+
36
+ /**
37
+ * Turn BlockNote JSON to Prosemirror node / state
38
+ * @param editor BlockNote editor
39
+ * @param blocks BlockNote blocks
40
+ * @returns Prosemirror root node
41
+ */
42
+ export function _blocksToProsemirrorNode<
43
+ BSchema extends BlockSchema,
44
+ ISchema extends InlineContentSchema,
45
+ SSchema extends StyleSchema,
46
+ >(
47
+ editor: BlockNoteEditor<BSchema, ISchema, SSchema>,
48
+ blocks: PartialBlock<BSchema, ISchema, SSchema>[],
49
+ ) {
50
+ const pmNodes = blocks.map((b) => blockToNode(b, editor.pmSchema));
51
+
52
+ const doc = editor.pmSchema.topNodeType.create(
53
+ null,
54
+ editor.pmSchema.nodes["blockGroup"].create(null, pmNodes),
55
+ );
56
+ return doc;
57
+ }
58
+
59
+ /** YJS / BLOCKNOTE conversions */
60
+
61
+ /**
62
+ * Turn a Y.XmlFragment collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
63
+ * @param editor BlockNote editor
64
+ * @param xmlFragment Y.XmlFragment
65
+ * @returns BlockNote document (BlockNote style JSON of all blocks)
66
+ */
67
+ export function yXmlFragmentToBlocks<
68
+ BSchema extends BlockSchema,
69
+ ISchema extends InlineContentSchema,
70
+ SSchema extends StyleSchema,
71
+ >(
72
+ editor: BlockNoteEditor<BSchema, ISchema, SSchema>,
73
+ xmlFragment: Y.XmlFragment,
74
+ ) {
75
+ const pmNode = yXmlFragmentToProseMirrorRootNode(
76
+ xmlFragment,
77
+ editor.pmSchema,
78
+ );
79
+ return docToBlocks<BSchema, ISchema, SSchema>(pmNode);
80
+ }
81
+
82
+ /**
83
+ * Convert blocks to a Y.XmlFragment
84
+ *
85
+ * This can be used when importing existing content to Y.Doc for the first time,
86
+ * note that this should not be used to rehydrate a Y.Doc from a database once
87
+ * collaboration has begun as all history will be lost
88
+ *
89
+ * @param editor BlockNote editor
90
+ * @param blocks the blocks to convert
91
+ * @param xmlFragment XML fragment name
92
+ * @returns Y.XmlFragment
93
+ */
94
+ export function blocksToYXmlFragment<
95
+ BSchema extends BlockSchema,
96
+ ISchema extends InlineContentSchema,
97
+ SSchema extends StyleSchema,
98
+ >(
99
+ editor: BlockNoteEditor<BSchema, ISchema, SSchema>,
100
+ blocks: Block<BSchema, ISchema, SSchema>[],
101
+ xmlFragment?: Y.XmlFragment,
102
+ ) {
103
+ return prosemirrorToYXmlFragment(
104
+ _blocksToProsemirrorNode(editor, blocks),
105
+ xmlFragment,
106
+ );
107
+ }
108
+
109
+ /**
110
+ * Turn a Y.Doc collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
111
+ * @param editor BlockNote editor
112
+ * @param ydoc Y.Doc
113
+ * @param xmlFragment XML fragment name
114
+ * @returns BlockNote document (BlockNote style JSON of all blocks)
115
+ */
116
+ export function yDocToBlocks<
117
+ BSchema extends BlockSchema,
118
+ ISchema extends InlineContentSchema,
119
+ SSchema extends StyleSchema,
120
+ >(
121
+ editor: BlockNoteEditor<BSchema, ISchema, SSchema>,
122
+ ydoc: Y.Doc,
123
+ xmlFragment = "prosemirror",
124
+ ) {
125
+ return yXmlFragmentToBlocks(editor, ydoc.getXmlFragment(xmlFragment));
126
+ }
127
+
128
+ /**
129
+ * This can be used when importing existing content to Y.Doc for the first time,
130
+ * note that this should not be used to rehydrate a Y.Doc from a database once
131
+ * collaboration has begun as all history will be lost
132
+ *
133
+ * @param editor BlockNote editor
134
+ * @param blocks the blocks to convert
135
+ * @param xmlFragment XML fragment name
136
+ */
137
+ export function blocksToYDoc<
138
+ BSchema extends BlockSchema,
139
+ ISchema extends InlineContentSchema,
140
+ SSchema extends StyleSchema,
141
+ >(
142
+ editor: BlockNoteEditor<BSchema, ISchema, SSchema>,
143
+ blocks: PartialBlock<BSchema, ISchema, SSchema>[],
144
+ xmlFragment = "prosemirror",
145
+ ) {
146
+ return prosemirrorToYDoc(
147
+ _blocksToProsemirrorNode(editor, blocks),
148
+ xmlFragment,
149
+ );
150
+ }
@@ -1,4 +1,4 @@
1
- import type { Transaction } from "prosemirror-state";
1
+ import { type Transaction } from "prosemirror-state";
2
2
  import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
3
3
  import type { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
4
4
  export declare function removeAndInsertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]): {
@@ -0,0 +1,32 @@
1
+ import { type Node } from "prosemirror-model";
2
+ import { type Transaction } from "prosemirror-state";
3
+ /**
4
+ * Checks if a `column` node is empty, i.e. if it has only a single empty
5
+ * paragraph.
6
+ * @param column The column to check.
7
+ * @returns Whether the column is empty.
8
+ */
9
+ export declare function isEmptyColumn(column: Node): boolean;
10
+ /**
11
+ * Removes all empty `column` nodes in a `columnList`. A `column` node is empty
12
+ * if it has only a single empty block. If, however, removing the `column`s
13
+ * leaves the `columnList` that has fewer than two, ProseMirror will re-add
14
+ * empty columns.
15
+ * @param tr The `Transaction` to add the changes to.
16
+ * @param columnListPos The position just before the `columnList` node.
17
+ */
18
+ export declare function removeEmptyColumns(tr: Transaction, columnListPos: number): void;
19
+ /**
20
+ * Fixes potential issues in a `columnList` node after a
21
+ * `blockContainer`/`column` node is (re)moved from it:
22
+ *
23
+ * - Removes all empty `column` nodes. A `column` node is empty if it has only
24
+ * a single empty block.
25
+ * - If all but one `column` nodes are empty, replaces the `columnList` with
26
+ * the content of the non-empty `column`.
27
+ * - If all `column` nodes are empty, removes the `columnList` entirely.
28
+ * @param tr The `Transaction` to add the changes to.
29
+ * @param columnListPos
30
+ * @returns The position just before the `columnList` node.
31
+ */
32
+ export declare function fixColumnList(tr: Transaction, columnListPos: number): void;
@@ -19,7 +19,7 @@ export declare function nodeToBlock<BSchema extends BlockSchema, I extends Inlin
19
19
  /**
20
20
  * Convert a Prosemirror document to a BlockNote document (array of blocks)
21
21
  */
22
- export declare function docToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node, schema: Schema, blockSchema?: BSchema, inlineContentSchema?: I, styleSchema?: S, blockCache?: import("../../index.js").BlockCache<any, any, any>): Block<BSchema, I, S>[];
22
+ export declare function docToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node, schema?: Schema, blockSchema?: BSchema, inlineContentSchema?: I, styleSchema?: S, blockCache?: import("../../index.js").BlockCache<any, any, any>): Block<BSchema, I, S>[];
23
23
  /**
24
24
  *
25
25
  * Parse a Prosemirror Slice into a BlockNote selection. The prosemirror schema looks like this:
@@ -443,6 +443,10 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
443
443
  * @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
444
444
  */
445
445
  mount: (element: HTMLElement) => void;
446
+ /**
447
+ * Timeout to schedule the {@link unmount}ing of the editor.
448
+ */
449
+ private scheduledDestructionTimeout;
446
450
  /**
447
451
  * Unmount the editor from the DOM element it is bound to
448
452
  */
@@ -462,6 +466,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
462
466
  isFocused(): boolean;
463
467
  get headless(): boolean;
464
468
  focus(): void;
469
+ blur(): void;
465
470
  onUploadStart(callback: (blockId?: string) => void): () => void;
466
471
  onUploadEnd(callback: (blockId?: string) => void): () => void;
467
472
  /**
@@ -706,7 +711,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
706
711
  * @param blocks An array of blocks that should be serialized into HTML.
707
712
  * @returns The blocks, serialized as an HTML string.
708
713
  */
709
- blocksToFullHTML(blocks: PartialBlock<BSchema, ISchema, SSchema>[]): string;
714
+ blocksToFullHTML(blocks?: PartialBlock<BSchema, ISchema, SSchema>[]): string;
710
715
  /**
711
716
  * Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
712
717
  * `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
@@ -21,7 +21,7 @@ export declare class ExportManager<BSchema extends BlockSchema = DefaultBlockSch
21
21
  * @param blocks An array of blocks that should be serialized into HTML.
22
22
  * @returns The blocks, serialized as an HTML string.
23
23
  */
24
- blocksToFullHTML(blocks: PartialBlock<BSchema, ISchema, SSchema>[]): string;
24
+ blocksToFullHTML(blocks?: PartialBlock<BSchema, ISchema, SSchema>[]): string;
25
25
  /**
26
26
  * Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
27
27
  * `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
@@ -44,7 +44,7 @@ export declare class CommentsPlugin extends BlockNoteExtension {
44
44
  /**
45
45
  * Set the selected thread
46
46
  */
47
- selectThread(threadId: string | undefined, scrollToThread?: boolean): void;
47
+ selectThread(threadId: string | undefined): void;
48
48
  /**
49
49
  * Start a pending comment (e.g.: when clicking the "Add comment" button)
50
50
  */
@@ -1,6 +1,7 @@
1
1
  export * from "./api/blockManipulation/commands/insertBlocks/insertBlocks.js";
2
2
  export * from "./api/blockManipulation/commands/replaceBlocks/replaceBlocks.js";
3
3
  export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
4
+ export * from "./api/blockManipulation/commands/replaceBlocks/util/fixColumnList.js";
4
5
  export * from "./api/exporters/html/externalHTMLExporter.js";
5
6
  export * from "./api/exporters/html/internalHTMLSerializer.js";
6
7
  export * from "./api/getBlockInfoFromPos.js";
@@ -51,6 +51,7 @@ export type CustomInlineContentImplementation<T extends CustomInlineContentConfi
51
51
  dom: HTMLElement | DocumentFragment;
52
52
  contentDOM?: HTMLElement;
53
53
  } | undefined;
54
+ runsBefore?: string[];
54
55
  };
55
56
  export declare function getInlineContentParseRules<C extends CustomInlineContentConfig>(config: C, customParseFunction?: CustomInlineContentImplementation<C, any>["parse"]): TagParseRule[];
56
57
  export declare function createInlineContentSpec<T extends CustomInlineContentConfig, S extends StyleSchema>(inlineContentConfig: T, inlineContentImplementation: CustomInlineContentImplementation<T, S>): InlineContentSpec<T>;
@@ -24,6 +24,7 @@ export type InlineContentImplementation<T extends InlineContentConfig> = T exten
24
24
  ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
25
25
  destroy?: () => void;
26
26
  };
27
+ runsBefore?: string[];
27
28
  };
28
29
  export type InlineContentSchemaWithInlineContent<IType extends string, C extends InlineContentConfig> = {
29
30
  [k in IType]: C;
@@ -10,6 +10,7 @@ export type CustomStyleImplementation<T extends StyleConfig> = {
10
10
  contentDOM?: HTMLElement;
11
11
  };
12
12
  parse?: (element: HTMLElement) => (T["propSchema"] extends "boolean" ? true : string) | undefined;
13
+ runsBefore?: string[];
13
14
  };
14
15
  export declare function getStyleParseRules<T extends StyleConfig>(config: T, customParseFunction?: CustomStyleImplementation<T>["parse"]): ParseRule[];
15
16
  export declare function createStyleSpec<const T extends StyleConfig>(styleConfig: T, styleImplementation: CustomStyleImplementation<T>): StyleSpec<T>;
@@ -15,6 +15,7 @@ export type StyleImplementation<T extends StyleConfig> = {
15
15
  dom: HTMLElement;
16
16
  contentDOM?: HTMLElement;
17
17
  };
18
+ runsBefore?: string[];
18
19
  };
19
20
  export type StyleSpec<T extends StyleConfig> = {
20
21
  config: T;
@@ -0,0 +1 @@
1
+ export * from "./utils.js";
@@ -0,0 +1,55 @@
1
+ import * as Y from "yjs";
2
+ import { type Block, type BlockNoteEditor, type BlockSchema, type InlineContentSchema, type PartialBlock, type StyleSchema } from "../index.js";
3
+ /**
4
+ * Turn Prosemirror JSON to BlockNote style JSON
5
+ * @param editor BlockNote editor
6
+ * @param json Prosemirror JSON
7
+ * @returns BlockNote style JSON
8
+ */
9
+ export declare function _prosemirrorJSONToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, json: any): Block<BSchema, ISchema, SSchema>[];
10
+ /**
11
+ * Turn BlockNote JSON to Prosemirror node / state
12
+ * @param editor BlockNote editor
13
+ * @param blocks BlockNote blocks
14
+ * @returns Prosemirror root node
15
+ */
16
+ export declare function _blocksToProsemirrorNode<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: PartialBlock<BSchema, ISchema, SSchema>[]): import("prosemirror-model").Node;
17
+ /** YJS / BLOCKNOTE conversions */
18
+ /**
19
+ * Turn a Y.XmlFragment collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
20
+ * @param editor BlockNote editor
21
+ * @param xmlFragment Y.XmlFragment
22
+ * @returns BlockNote document (BlockNote style JSON of all blocks)
23
+ */
24
+ export declare function yXmlFragmentToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, xmlFragment: Y.XmlFragment): Block<BSchema, ISchema, SSchema>[];
25
+ /**
26
+ * Convert blocks to a Y.XmlFragment
27
+ *
28
+ * This can be used when importing existing content to Y.Doc for the first time,
29
+ * note that this should not be used to rehydrate a Y.Doc from a database once
30
+ * collaboration has begun as all history will be lost
31
+ *
32
+ * @param editor BlockNote editor
33
+ * @param blocks the blocks to convert
34
+ * @param xmlFragment XML fragment name
35
+ * @returns Y.XmlFragment
36
+ */
37
+ export declare function blocksToYXmlFragment<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: Block<BSchema, ISchema, SSchema>[], xmlFragment?: Y.XmlFragment): Y.XmlFragment;
38
+ /**
39
+ * Turn a Y.Doc collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
40
+ * @param editor BlockNote editor
41
+ * @param ydoc Y.Doc
42
+ * @param xmlFragment XML fragment name
43
+ * @returns BlockNote document (BlockNote style JSON of all blocks)
44
+ */
45
+ export declare function yDocToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, ydoc: Y.Doc, xmlFragment?: string): Block<BSchema, ISchema, SSchema>[];
46
+ /**
47
+ * This can be used when importing existing content to Y.Doc for the first time,
48
+ * note that this should not be used to rehydrate a Y.Doc from a database once
49
+ * collaboration has begun as all history will be lost
50
+ *
51
+ * @param editor BlockNote editor
52
+ * @param blocks the blocks to convert
53
+ * @param xmlFragment XML fragment name
54
+ */
55
+ export declare function blocksToYDoc<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: PartialBlock<BSchema, ISchema, SSchema>[], xmlFragment?: string): Y.Doc;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +0,0 @@
1
- "use strict";var vn=Object.defineProperty;var Sn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>Sn(e,typeof t!="symbol"?t+"":t,n);const I=require("prosemirror-tables"),En=require("@tiptap/extension-bold"),Bn=require("@tiptap/extension-code"),xn=require("@tiptap/extension-italic"),Tn=require("@tiptap/extension-strike"),Mn=require("@tiptap/extension-underline"),E=require("@tiptap/core"),x=require("prosemirror-model"),W=require("prosemirror-state"),Ln=require("uuid"),Nn=require("prosemirror-highlight"),An=require("prosemirror-highlight/shiki"),In=require("prosemirror-transform"),Ce=require("prosemirror-view"),ee=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},Pn=ee(En),On=ee(Bn),Dn=ee(xn),Hn=ee(Tn),_n=ee(Mn);function Rn(e,t=JSON.stringify){const n={};return e.filter(o=>{const r=t(o);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Vn(e){const t=e.filter((o,r)=>e.indexOf(o)!==r);return Rn(t)}const Be=E.Extension.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){const e=window.__TEST_OPTIONS;return e.mockID===void 0?e.mockID=0:e.mockID++,e.mockID.toString()}return Ln.v4()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{const t={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...t,id:e[this.options.attributeName]}:t}}}}]},addProseMirrorPlugins(){let e=null,t=!1;return[new W.Plugin({key:new W.PluginKey("uniqueID"),appendTransaction:(n,o,r)=>{const s=n.some(h=>h.docChanged)&&!o.doc.eq(r.doc),i=this.options.filterTransaction&&n.some(h=>{var k,g;return!((g=(k=this.options).filterTransaction)!=null&&g.call(k,h))});if(!s||i)return;const{tr:a}=r,{types:c,attributeName:l,generateID:d}=this.options,u=E.combineTransactionSteps(o.doc,n),{mapping:p}=u;if(E.getChangedRanges(u).forEach(({newRange:h})=>{const k=E.findChildrenInRange(r.doc,h,y=>c.includes(y.type.name)),g=k.map(({node:y})=>y.attrs[l]).filter(y=>y!==null),b=Vn(g);k.forEach(({node:y,pos:m})=>{var X;const v=(X=a.doc.nodeAt(m))==null?void 0:X.attrs[l];if(v===null){const J=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(J)===null){const je=JSON.parse(JSON.stringify(r.doc.toJSON()));if(je.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(je.content)===JSON.stringify(J.toJSON())){a.setNodeMarkup(m,void 0,{...y.attrs,[l]:"initialBlockId"});return}}a.setNodeMarkup(m,void 0,{...y.attrs,[l]:d()});return}const{deleted:L}=p.invert().mapResult(m);L&&b.includes(v)&&a.setNodeMarkup(m,void 0,{...y.attrs,[l]:d()})})}),!!a.steps.length)return a.setMeta("uniqueID",!0),a},view(n){const o=r=>{let s;e=!((s=n.dom.parentElement)===null||s===void 0)&&s.contains(r.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(n,o)=>{let r;return e!==n.dom.parentElement||((r=o.dataTransfer)===null||r===void 0?void 0:r.effectAllowed)==="copy"?t=!0:t=!1,e=null,!1},paste:()=>(t=!0,!1)},transformPasted:n=>{if(!t)return n;const{types:o,attributeName:r}=this.options,s=i=>{const a=[];return i.forEach(c=>{if(c.isText){a.push(c);return}if(!o.includes(c.type.name)){a.push(c.copy(s(c.content)));return}const l=c.type.create({...c.attrs,[r]:null},s(c.content),c.marks);a.push(l)}),x.Fragment.from(a)};return t=!1,new x.Slice(s(n.content),n.openStart,n.openEnd)}}})]}});function ye(e){return e.type==="link"}function xe(e){return typeof e!="string"&&e.type==="link"}function O(e){return typeof e!="string"&&e.type==="text"}function ne(e){var t,n,o,r,s;return se(e)?{...e}:$(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:((t=e.props)==null?void 0:t.backgroundColor)??"default",textColor:((n=e.props)==null?void 0:n.textColor)??"default",textAlignment:((o=e.props)==null?void 0:o.textAlignment)??"left",colspan:((r=e.props)==null?void 0:r.colspan)??1,rowspan:((s=e.props)==null?void 0:s.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function $(e){return e!=null&&typeof e!="string"&&!Array.isArray(e)&&e.type==="tableCell"}function se(e){return $(e)&&e.props!==void 0&&e.content!==void 0}function j(e){return se(e)?e.props.colspan??1:1}function oe(e){return se(e)?e.props.rowspan??1:1}class z extends Error{constructor(t){super(`Unreachable case: ${t}`)}}function Fn(e,t=!0){const{"data-test":n,...o}=e;if(Object.keys(o).length>0&&t)throw new Error("Object must be empty "+JSON.stringify(e))}const Qe=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function A(e,t="Ctrl"){return Qe()?e.replace("Mod","⌘"):e.replace("Mod",t)}function U(...e){return[...new Set(e.filter(t=>t).join(" ").split(" "))].join(" ")}const Wn=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function et(e,t,n,o){const r=document.createElement("div");r.className=U("bn-block-content",n.class),r.setAttribute("data-content-type",e);for(const[i,a]of Object.entries(n))i!=="class"&&r.setAttribute(i,a);const s=document.createElement(t);s.className=U("bn-inline-content",o.class);for(const[i,a]of Object.entries(o))i!=="class"&&s.setAttribute(i,a);return r.appendChild(s),{dom:r,contentDOM:s}}const we=(e,t)=>{let n=te(e,t.pmSchema);n.type.name==="blockContainer"&&(n=n.firstChild);const o=t.pmSchema.nodes[n.type.name].spec.toDOM;if(o===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const r=o(n);if(typeof r!="object"||!("dom"in r))throw new Error("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.");return r};function tt(e,t="<br>"){const n=e.querySelectorAll("p");if(n.length>1){const o=n[0];for(let r=1;r<n.length;r++){const s=n[r];o.innerHTML+=t+s.innerHTML,s.remove()}}}function Y(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $n(e){const t=e.split("/");return!t.length||t[t.length-1]===""?e:t[t.length-1]}function jn(e){var n;const t=["mp4","webm","ogg","mov","mkv","flv","avi","wmv","m4v"];try{const r=((n=new URL(e).pathname.split(".").pop())==null?void 0:n.toLowerCase())||"";return t.includes(r)}catch{return!1}}function nt(e){const t={};return Object.entries(e).forEach(([n,o])=>{t[n]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const s=r.getAttribute(Y(n));if(s===null)return null;if(o.default===void 0&&o.type==="boolean"||o.default!==void 0&&typeof o.default=="boolean")return s==="true"?!0:s==="false"?!1:null;if(o.default===void 0&&o.type==="number"||o.default!==void 0&&typeof o.default=="number"){const i=parseFloat(s);return!Number.isNaN(i)&&Number.isFinite(i)?i:null}return s},renderHTML:r=>r[n]!==o.default?{[Y(n)]:r[n]}:{}}}),t}function ot(e,t,n,o){const r=e();if(r===void 0)throw new Error("Cannot find node position");const i=n.state.doc.resolve(r).node().attrs.id;if(!i)throw new Error("Block doesn't have id");const a=t.getBlock(i);if(a.type!==o)throw new Error("Block type does not match");return a}function re(e,t,n,o,r=!1,s){const i=document.createElement("div");if(s!==void 0)for(const[a,c]of Object.entries(s))a!=="class"&&i.setAttribute(a,c);i.className=U("bn-block-content",(s==null?void 0:s.class)||""),i.setAttribute("data-content-type",t);for(const[a,c]of Object.entries(n)){const d=o[a].default;c!==d&&i.setAttribute(Y(a),c)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM&&(e.contentDOM.className=U("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function rt(e,t,n){return{config:{type:e.type,content:e.content,propSchema:t},implementation:{node:e.node,render:we,toExternalHTML:we},extensions:n}}function st(e,t){e.stopEvent=n=>(n.type==="mousedown"&&setTimeout(()=>{t.view.dom.blur()},10),!0)}function it(e,t){const n=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return t.parse&&n.push({tag:"*",getAttrs(o){var s;if(typeof o=="string")return!1;const r=(s=t.parse)==null?void 0:s.call(t,o);return r===void 0?!1:r},getContent:e.content==="inline"||e.content==="none"?(o,r)=>{var s;if(t.parseContent)return t.parseContent({el:o,schema:r});if(e.content==="inline"){const a=o.cloneNode(!0);return tt(a,(s=t.meta)!=null&&s.code?`
2
- `:"<br>"),x.DOMParser.fromSchema(r).parse(a,{topNode:r.nodes.paragraph.create()}).content}return x.Fragment.empty}:void 0}),n}function at(e,t,n,o){var s,i,a,c;const r=t.node||E.Node.create({name:e.type,content:e.content==="inline"?"inline*":e.content==="none"?"":e.content,group:"blockContent",selectable:((s=t.meta)==null?void 0:s.selectable)??!0,isolating:((i=t.meta)==null?void 0:i.isolating)??!0,code:((a=t.meta)==null?void 0:a.code)??!1,defining:((c=t.meta)==null?void 0:c.defining)??!0,priority:o,addAttributes(){return nt(e.propSchema)},parseHTML(){return it(e,t)},renderHTML({HTMLAttributes:l}){var u;const d=document.createElement("div");return re({dom:d,contentDOM:e.content==="inline"?d:void 0},e.type,{},e.propSchema,((u=t.meta)==null?void 0:u.fileBlockAccept)!==void 0,l)},addNodeView(){return l=>{var h,k;const d=this.options.editor,u=ot(l.getPos,d,this.editor,e.type),p=((h=this.options.domAttributes)==null?void 0:h.blockContent)||{},f=t.render.call({blockContentDOMAttributes:p,props:l,renderType:"nodeView"},u,d);return((k=t.meta)==null?void 0:k.selectable)===!1&&st(f,this.editor),f}}});if(r.name!==e.type)throw new Error("Node name does not match block type. This is a bug in BlockNote.");return{config:e,implementation:{...t,node:r,render(l,d){var p;const u=((p=r.options.domAttributes)==null?void 0:p.blockContent)||{};return t.render.call({blockContentDOMAttributes:u,props:void 0,renderType:"dom"},l,d)},toExternalHTML:(l,d)=>{var p,f;const u=((p=r.options.domAttributes)==null?void 0:p.blockContent)||{};return((f=t.toExternalHTML)==null?void 0:f.call({blockContentDOMAttributes:u},l,d))??t.render.call({blockContentDOMAttributes:u,renderType:"dom",props:void 0},l,d)}},extensions:n}}function Un(e){return e}function M(e,t,n){return(o={})=>{const r=typeof e=="function"?e(o):e,s=typeof t=="function"?t(o):t,i=n?typeof n=="function"?n(o):n:void 0;return{config:r,implementation:{...s,toExternalHTML(a,c){var d,u;const l=(d=s.toExternalHTML)==null?void 0:d.call({blockContentDOMAttributes:this.blockContentDOMAttributes},a,c);if(l!==void 0)return re(l,a.type,a.props,r.propSchema,((u=s.meta)==null?void 0:u.fileBlockAccept)!==void 0)},render(a,c){var u;const l=s.render.call({blockContentDOMAttributes:this.blockContentDOMAttributes,renderType:this.renderType,props:this.props},a,c);return re(l,a.type,a.props,r.propSchema,((u=s.meta)==null?void 0:u.fileBlockAccept)!==void 0,this.blockContentDOMAttributes)}},extensions:i}}}function ie(e,t){const n=e.resolve(t);if(n.nodeAfter&&n.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:n.pos,node:n.nodeAfter};let o=n.depth,r=n.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:n.before(o),node:r};o--,r=n.node(o)}const s=[];e.descendants((a,c)=>{a.type.isInGroup("bnBlock")&&s.push(c)}),console.warn(`Position ${t} is not within a blockContainer node.`);const i=e.resolve(s.find(a=>a>=t)||s[s.length-1]);return{posBeforeNode:i.pos,node:i.nodeAfter}}function ae(e,t){if(!e.type.isInGroup("bnBlock"))throw new Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);const n=e,o=t,r=o+n.nodeSize,s={node:n,beforePos:o,afterPos:r};if(n.type.name==="blockContainer"){let i,a;if(n.forEach((c,l)=>{if(c.type.spec.group==="blockContent"){const d=c,u=o+l+1,p=u+c.nodeSize;i={node:d,beforePos:u,afterPos:p}}else if(c.type.name==="blockGroup"){const d=c,u=o+l+1,p=u+c.nodeSize;a={node:d,beforePos:u,afterPos:p}}}),!i)throw new Error(`blockContainer node does not contain a blockContent node in its children: ${n}`);return{isBlockContainer:!0,bnBlock:s,blockContent:i,childContainer:a,blockNoteType:i.node.type.name}}else{if(!s.node.type.isInGroup("childContainer"))throw new Error(`bnBlock node is not in the childContainer group: ${s.node}`);return{isBlockContainer:!1,bnBlock:s,childContainer:s,blockNoteType:s.node.type.name}}}function q(e){return ae(e.node,e.posBeforeNode)}function ct(e){if(!e.nodeAfter)throw new Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return ae(e.nodeAfter,e.pos)}function Te(e){const t=ie(e.doc,e.selection.anchor);return q(t)}function lt(e){const t=ie(e.doc,e.selection.anchor);return q(t)}function G(e){return"doc"in e?e.doc.type.schema:e.type.schema}function ut(e){return e.cached.blockNoteEditor}function ce(e){return ut(e).schema}function le(e){return ce(e).blockSchema}function ue(e){return ce(e).inlineContentSchema}function V(e){return ce(e).styleSchema}function de(e){return ut(e).blockCache}function dt(e,t,n){var s,i;const o={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},r=[];e.content.forEach((a,c,l)=>{const d={cells:[]};l===0&&a.content.forEach(u=>{let p=u.attrs.colwidth;p==null&&(p=new Array(u.attrs.colspan??1).fill(void 0)),o.columnWidths.push(...p)}),d.cells=a.content.content.map((u,p)=>(r[l]||(r[l]=[]),r[l][p]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(h=>pe(h,t,n)).reduce((h,k)=>{if(!h.length)return k;const g=h[h.length-1],b=k[0];return b&&O(g)&&O(b)&&JSON.stringify(g.styles)===JSON.stringify(b.styles)?(g.text+=`
3
- `+b.text,h.push(...k.slice(1)),h):(h.push(...k),h)},[]),props:{colspan:u.attrs.colspan,rowspan:u.attrs.rowspan,backgroundColor:u.attrs.backgroundColor,textColor:u.attrs.textColor,textAlignment:u.attrs.textAlignment}})),o.rows.push(d)});for(let a=0;a<r.length;a++)(s=r[a])!=null&&s.every(c=>c)&&(o.headerRows=(o.headerRows??0)+1);for(let a=0;a<((i=r[0])==null?void 0:i.length);a++)r!=null&&r.every(c=>c[a])&&(o.headerCols=(o.headerCols??0)+1);return o}function pe(e,t,n){const o=[];let r;return e.content.forEach(s=>{if(s.type.name==="hardBreak"){if(r)if(O(r))r.text+=`
4
- `;else if(ye(r))r.content[r.content.length-1].text+=`
5
- `;else throw new Error("unexpected");else r={type:"text",text:`
6
- `,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!t[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(pt(s,t,n));return}const i={};let a;for(const c of s.marks)if(c.type.name==="link")a=c;else{const l=n[c.type.name];if(!l){if(c.type.spec.blocknoteIgnore)continue;throw new Error(`style ${c.type.name} not found in styleSchema`)}if(l.propSchema==="boolean")i[l.type]=!0;else if(l.propSchema==="string")i[l.type]=c.attrs.stringValue;else throw new z(l.propSchema)}r?O(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):ye(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function pt(e,t,n){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=t[e.type.name];for(const[a,c]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const l=r.propSchema;a in l&&(o[a]=c)}let s;return r.content==="styled"?s=pe(e,t,n):s=void 0,{type:e.type.name,props:o,content:s}}function Z(e,t,n=le(t),o=ue(t),r=V(t),s=de(t)){var k;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=ae(e,0);let c=a.bnBlock.node.attrs.id;c===null&&(c=Be.options.generateID());const l=n[a.blockNoteType];if(!l)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[g,b]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const y=l.propSchema;g in y&&!(y[g].default===void 0&&b===void 0)&&(d[g]=b)}const u=n[a.blockNoteType],p=[];(k=a.childContainer)==null||k.node.forEach(g=>{p.push(Z(g,t,n,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=pe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=dt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new z(u.content);const h={id:c,type:u.type,props:d,content:f,children:p};return s==null||s.set(e,h),h}function qn(e,t,n=le(t),o=ue(t),r=V(t),s=de(t)){const i=[];return e.firstChild.descendants(a=>(i.push(Z(a,t,n,o,r,s)),!1)),i}function zn(e,t,n=le(t),o=ue(t),r=V(t),s=de(t)){function i(a,c,l){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,p;return a.forEach((f,h,k)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const g=k===0,b=k===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!g)throw new Error("unexpected");const L=i(f.firstChild,Math.max(0,c-1),b?Math.max(0,l-1):0);u=L.blockCutAtStart,b&&(p=L.blockCutAtEnd),d.push(...L.blocks);return}const y=Z(f,t,n,o,r,s),m=f.childCount>1?f.child(1):void 0;let v=[];if(m){const L=i(m,0,b?Math.max(0,l-1):0);v=L.blocks,b&&(p=L.blockCutAtEnd)}b&&!m&&l>1&&(p=y.id),g&&c>1&&(u=y.id),d.push({...y,children:v})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:p}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function Gn(e,t,n,o){return e.dom.setAttribute("data-inline-content-type",t),Object.entries(n).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[Y(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function Zn(e){return{Backspace:({editor:t})=>{const n=t.state.selection.$from;return t.state.selection.empty&&n.node().type.name===e.type&&n.parentOffset===0}}}function ft(e,t){return{config:e,implementation:t}}function Xn(e,t,n){return ft({type:e.name,propSchema:t,content:e.config.content==="inline*"?"styled":"none"},{...n,node:e})}function Me(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n.config]))}function ht(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:t=>t.getAttribute("data-value"),renderHTML:t=>t.stringValue!==void 0?{"data-value":t.stringValue}:{}}}}function K(e,t,n,o){return e.dom.setAttribute("data-style-type",t),o==="string"&&e.dom.setAttribute("data-value",n),e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function Le(e,t){return{config:e,implementation:t}}function F(e,t){return Le({type:e.name,propSchema:t},{mark:e,render(n,o){const r=o.pmSchema.marks[e.name].spec.toDOM;if(r===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const s=o.pmSchema.mark(e.name,{stringValue:n}),i=x.DOMSerializer.renderSpec(document,r(s,!0));if(typeof i!="object"||!("dom"in i))throw new Error("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.");return i},toExternalHTML(n,o){const r=o.pmSchema.marks[e.name].spec.toDOM;if(r===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const s=o.pmSchema.mark(e.name,{stringValue:n}),i=x.DOMSerializer.renderSpec(document,r(s,!0));if(typeof i!="object"||!("dom"in i))throw new Error("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.");return i}})}function Ne(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n.config]))}function gt(e,t){const n=[{tag:`[data-style-type="${e.type}"]`,contentElement:o=>{const r=o;return r.matches("[data-editable]")?r:r.querySelector("[data-editable]")||r}}];return t&&n.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=t==null?void 0:t(o);return r===void 0?!1:{stringValue:r}}}),n}function Ae(e,t){const n=E.Mark.create({name:e.type,addAttributes(){return ht(e.propSchema)},parseHTML(){return gt(e,t.parse)},renderHTML({mark:o}){const r=(t.toExternalHTML||t.render)(o.attrs.stringValue);return K(r,e.type,o.attrs.stringValue,e.propSchema)},addMarkView(){return({mark:o})=>{const r=t.render(o.attrs.stringValue);return K(r,e.type,o.attrs.stringValue,e.propSchema)}}});return Le(e,{mark:n,render:o=>{const r=t.render(o);return K(r,e.type,o,e.propSchema)},toExternalHTML:o=>{const r=(t.toExternalHTML||t.render)(o);return K(r,e.type,o,e.propSchema)}})}function Jn(e){const t=Yn(e);let{roots:n,nonRoots:o}=Ue(t);const r=[];for(;n.size;){r.push(n);const s=new Set;for(const i of n){const a=e.get(i);if(a)for(const c of a){const l=t.get(c);if(l===void 0)continue;const d=l-1;t.set(c,d),d===0&&s.add(c)}}n=s}if(o=Ue(t).nonRoots,o.size)throw new Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(o).join(", ")}`);return r}function Kn(e){const t=Qn(e);return Jn(t)}function Yn(e){const t=new Map;for(const[n,o]of e.entries()){t.has(n)||t.set(n,0);for(const r of o){const s=t.get(r)??0;t.set(r,s+1)}}return t}function Ue(e){const t=new Set,n=new Set;for(const[o,r]of e.entries())r===0?t.add(o):n.add(o);return{roots:t,nonRoots:n}}function Qn(e){const t=new Map;for(const[n,o]of e.entries()){t.has(n)||t.set(n,new Set);for(const r of o)t.has(r)||t.set(r,new Set),t.get(r).add(n)}return t}function eo(){return new Map}function qe(e){return e&&Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class mt{constructor(t){B(this,"BlockNoteEditor","only for types");B(this,"Block","only for types");B(this,"PartialBlock","only for types");B(this,"inlineContentSpecs");B(this,"styleSpecs");B(this,"blockSpecs");B(this,"blockSchema");B(this,"inlineContentSchema");B(this,"styleSchema");this.opts=t;const{blockSpecs:n,inlineContentSpecs:o,styleSpecs:r,blockSchema:s,inlineContentSchema:i,styleSchema:a}=this.init();this.blockSpecs=n,this.styleSpecs=r,this.styleSchema=a,this.inlineContentSpecs=o,this.blockSchema=s,this.inlineContentSchema=i}init(){const t=eo(),n=new Set;t.set("default",n);for(const[a,c]of Object.entries(this.opts.blockSpecs))c.implementation.runsBefore?t.set(a,new Set(c.implementation.runsBefore)):n.add(a);const o=Kn(t),r=o.findIndex(a=>a.has("default")),s=a=>91+(o.findIndex(l=>l.has(a))+r)*10,i=Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([a,c])=>[a,at(c.config,c.implementation,c.extensions,s(a))]));return{blockSpecs:i,blockSchema:Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.config])),inlineContentSpecs:qe(this.opts.inlineContentSpecs),styleSpecs:qe(this.opts.styleSpecs),inlineContentSchema:Me(this.opts.inlineContentSpecs),styleSchema:Ne(this.opts.styleSpecs)}}extend(t){Object.assign(this.opts.blockSpecs,t.blockSpecs),Object.assign(this.opts.inlineContentSpecs,t.inlineContentSpecs),Object.assign(this.opts.styleSpecs,t.styleSpecs);const{blockSpecs:n,inlineContentSpecs:o,styleSpecs:r,blockSchema:s,inlineContentSchema:i,styleSchema:a}=this.init();return this.blockSpecs=n,this.styleSpecs=r,this.styleSchema=a,this.inlineContentSpecs=o,this.blockSchema=s,this.inlineContentSchema=i,this}}function D(e){const{height:t,width:n}=Ie(e),o=new Array(t).fill(!1).map(()=>new Array(n).fill(null)),r=(s,i)=>{for(let a=s;a<t;a++)for(let c=i;c<n;c++)if(!o[a][c])return{row:a,col:c};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=ne(e.content.rows[s].cells[i]),c=oe(a),l=j(a),{row:d,col:u}=r(s,i);for(let p=d;p<d+c;p++)for(let f=u;f<u+l;f++){if(o[p][f])throw new Error(`Unable to create occupancy grid for table, cell at ${p},${f} is already occupied`);o[p][f]={row:s,col:i,rowspan:c,colspan:l,cell:a}}}return o}function Q(e){const t=new Set;return e.map(n=>({cells:n.map(o=>t.has(o.row+":"+o.col)?!1:(t.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function _(e,t,n=D(t)){for(let o=0;o<n.length;o++)for(let r=0;r<n[o].length;r++){const s=n[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function Ie(e){const t=e.content.rows.length;let n=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=j(s)}),n=Math.max(n,r)}),{height:t,width:n}}function bt(e,t,n=D(t)){var r;const o=(r=n[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function kt(e,t){var s;const n=D(e);if(t<0||t>=n.length)return[];let o=0;for(let i=0;i<t;i++){const a=(s=n[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(n[0].length).fill(!1).map((i,a)=>bt({row:o,col:a},e,n)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(c=>c.row===i.row&&c.col===i.col)===a)}function Ct(e,t){var s;const n=D(e);if(t<0||t>=n[0].length)return[];let o=0;for(let i=0;i<t;i++){const a=(s=n[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(n.length).fill(!1).map((i,a)=>bt({row:a,col:o},e,n)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(c=>c.row===i.row&&c.col===i.col)===a)}function to(e,t,n,o=D(e)){const{col:r}=_({row:0,col:t},e,o),{col:s}=_({row:0,col:n},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Q(o)}function no(e,t,n,o=D(e)){const{row:r}=_({row:t,col:0},e,o),{row:s}=_({row:n,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Q(o)}function ve(e){return e?$(e)?ve(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(t=>typeof t=="string"?t.length===0:O(t)?t.text.length===0:xe(t)?typeof t.content=="string"?t.content.length===0:t.content.every(n=>n.text.length===0):!1):!1:!0}function oo(e,t,n=D(e)){if(t==="columns"){let s=0;for(let i=n[0].length-1;i>=0&&n.every(c=>ve(c[i].cell)&&c[i].colspan===1);i--)s++;for(let i=n.length-1;i>=0;i--){const a=Math.max(n[i].length-s,1);n[i]=n[i].slice(0,a)}return Q(n)}let o=0;for(let s=n.length-1;s>=0&&n[s].every(a=>ve(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,n.length-1);return n.splice(n.length-r,r),Q(n)}function ro(e,t,n,o=D(e)){const{width:r,height:s}=Ie(e);if(t==="columns")o.forEach((i,a)=>{if(n>=0)for(let c=0;c<n;c++)i.push({row:a,col:Math.max(...i.map(l=>l.col))+1,rowspan:1,colspan:1,cell:ne("")});else i.splice(r+n,-1*n)});else if(n>0)for(let i=0;i<n;i++){const a=new Array(r).fill(null).map((c,l)=>({row:s+i,col:l,rowspan:1,colspan:1,cell:ne("")}));o.push(a)}else n<0&&o.splice(s+n,-1*n);return Q(o)}function so(e,t,n){const o=kt(e,n);if(!o.some(c=>oe(c.cell)>1))return!0;let s=n,i=n;return o.forEach(c=>{const l=oe(c.cell);s=Math.max(s,c.row+l-1),i=Math.min(i,c.row)}),t<n?n===s:n===i}function io(e,t,n){const o=Ct(e,n);if(!o.some(c=>j(c.cell)>1))return!0;let s=n,i=n;return o.forEach(c=>{const l=j(c.cell);s=Math.max(s,c.col+l-1),i=Math.min(i,c.col)}),t<n?n===s:n===i}function ao(e,t,n){const o=_(e,n),r=_(t,n);return o.col===r.col}function ze(e,t,n,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const c=n[i];if(!c)throw new Error(`style ${i} not found in styleSchema`);if(c.propSchema==="boolean")a&&r.push(t.mark(i));else if(c.propSchema==="string")a&&r.push(t.mark(i,{stringValue:a}));else throw new z(c.propSchema)}return!o||!t.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
7
- `?t.nodes.hardBreak.createChecked():t.text(i,r)):e.text.length>0?[t.text(e.text,r)]:[]}function co(e,t,n){const o=t.marks.link.create({href:e.href});return Se(e.content,t,n).map(r=>{if(r.type.name==="text")return r.mark([...r.marks,o]);if(r.type.name==="hardBreak")return r;throw new Error("unexpected node type")})}function Se(e,t,n,o){const r=[];if(typeof e=="string")return r.push(...ze({text:e,styles:{}},t,n,o)),r;for(const s of e)r.push(...ze(s,t,n,o));return r}function R(e,t,n,o=V(t)){const r=[];for(const s of e)typeof s=="string"?r.push(...Se(s,t,o,n)):xe(s)?r.push(...co(s,t,o)):O(s)?r.push(...Se([s],t,o,n)):r.push(yt(s,t,o));return r}function Pe(e,t,n=V(t)){const o=[],r=new Array(e.headerRows??0).fill(!0),s=new Array(e.headerCols??0).fill(!0),i=e.columnWidths??[];for(let a=0;a<e.rows.length;a++){const c=e.rows[a],l=[],d=r[a];for(let p=0;p<c.cells.length;p++){const f=c.cells[p],h=s[p],k=void 0;let g=null;const b=_({row:a,col:p},{content:e});let y=i[b.col]?[i[b.col]]:null;if(f)if(typeof f=="string")g=t.text(f);else if($(f)){f.content&&(g=R(f.content,t,"tableParagraph",n));const v=j(f);v>1&&(y=new Array(v).fill(!1).map((L,be)=>i[b.col+be]??void 0))}else g=R(f,t,"tableParagraph",n);const m=t.nodes[h||d?"tableHeader":"tableCell"].createChecked({...$(f)?f.props:{},colwidth:y},t.nodes.tableParagraph.createChecked(k,g));l.push(m)}const u=t.nodes.tableRow.createChecked({},l);o.push(u)}return o}function yt(e,t,n){let o,r=e.type;if(r===void 0&&(r="paragraph"),!t.nodes[r])throw new Error(`node type ${r} not found in schema`);if(!e.content)o=t.nodes[r].createChecked(e.props);else if(typeof e.content=="string"){const s=R([e.content],t,r,n);o=t.nodes[r].createChecked(e.props,s)}else if(Array.isArray(e.content)){const s=R(e.content,t,r,n);o=t.nodes[r].createChecked(e.props,s)}else if(e.content.type==="tableContent"){const s=Pe(e.content,t,n);o=t.nodes[r].createChecked(e.props,s)}else throw new z(e.content.type);return o}function te(e,t,n=V(t)){let o=e.id;o===void 0&&(o=Be.options.generateID());const r=[];if(e.children)for(const i of e.children)r.push(te(i,t,n));if(!e.type||t.nodes[e.type].isInGroup("blockContent")){const i=yt(e,t,n),a=r.length>0?t.nodes.blockGroup.createChecked({},r):void 0;return t.nodes.blockContainer.createChecked({id:o,...e.props},a?[i,a]:i)}else{if(t.nodes[e.type].isInGroup("bnBlock"))return t.nodes[e.type].createChecked({id:o,...e.props},r);throw new Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}}function wt(e,t){let n,o;if(t.firstChild.descendants((r,s)=>n?!1:!vt(r)||r.attrs.id!==e?!0:(n=r,o=s+1,!1)),!(n===void 0||o===void 0))return{node:n,posBeforeNode:o}}function vt(e){return e.type.isInGroup("bnBlock")}const lo=(e,t)=>({tr:n,dispatch:o})=>(o&&fe(n,e,t),!0);function fe(e,t,n,o,r){const s=ct(e.doc.resolve(t));let i=null;s.blockNoteType==="table"&&(i=St(e));const a=G(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const c=a.nodes[s.blockNoteType],l=a.nodes[n.type||s.blockNoteType],d=l.isInGroup("bnBlock")?l:a.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){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;Ge(n,e,s),uo(n,e,c,l,s,u,p)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))Ge(n,e,s);else{const u=Z(s.bnBlock.node,a);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,te({children:u.children,...n},a));return}e.setNodeMarkup(s.bnBlock.beforePos,d,{...s.bnBlock.node.attrs,...n.props}),i&&fo(e,s,i)}function uo(e,t,n,o,r,s,i){const a=G(t);let c="keep";if(e.content)if(typeof e.content=="string")c=R([e.content],a,o.name);else if(Array.isArray(e.content))c=R(e.content,a,o.name);else if(e.content.type==="tableContent")c=Pe(e.content,a);else throw new z(e.content.type);else n.spec.content===""||o.spec.content!==n.spec.content&&(c=[]);if(c==="keep")t.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){t.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const l=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??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;t.replace(l,d,new x.Slice(x.Fragment.from(c),p-u-1,f-u-1))}else t.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},c))}function Ge(e,t,n){const o=G(t);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>te(s,o));if(n.childContainer)t.step(new In.ReplaceStep(n.childContainer.beforePos+1,n.childContainer.afterPos-1,new x.Slice(x.Fragment.from(r),0,0)));else{if(!n.isBlockContainer)throw new Error("impossible");t.insert(n.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function po(e,t,n,o,r){const s=typeof t=="string"?t:t.id,i=wt(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);fe(e,i.posBeforeNode,n,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),c=G(e);return Z(a,c)}function St(e){const t="selection"in e?e.selection:null;if(!(t instanceof W.TextSelection))return null;const n=e.doc.resolve(t.head);let o=-1,r=-1;for(let g=n.depth;g>=0;g--){const b=n.node(g).type.name;if(o<0&&(b==="tableCell"||b==="tableHeader")&&(o=g),b==="table"){r=g;break}}if(o<0||r<0)return null;const s=n.before(o),i=n.before(r),a=e.doc.nodeAt(i);if(!a||a.type.name!=="table")return null;const c=I.TableMap.get(a),l=s-(i+1),d=c.map.indexOf(l);if(d<0)return null;const u=Math.floor(d/c.width),p=d%c.width,h=s+1+1,k=Math.max(0,t.head-h);return{row:u,col:p,offset:k}}function fo(e,t,n){var g;if(t.blockNoteType!=="table")return!1;let o=-1;if(t.isBlockContainer)o=e.mapping.map(t.blockContent.beforePos);else{const b=e.mapping.map(t.bnBlock.beforePos),y=b+(((g=e.doc.nodeAt(b))==null?void 0:g.nodeSize)||0);e.doc.nodesBetween(b,y,(m,v)=>m.type.name==="table"?(o=v,!1):!0)}const r=o>=0?e.doc.nodeAt(o):null;if(!r||r.type.name!=="table")return!1;const s=I.TableMap.get(r),i=Math.max(0,Math.min(n.row,s.height-1)),a=Math.max(0,Math.min(n.col,s.width-1)),c=i*s.width+a,l=s.map[c];if(l==null)return!1;const u=o+1+l+1,p=e.doc.nodeAt(u),f=u+1,h=p?p.content.size:0,k=f+Math.max(0,Math.min(n.offset,h));return"selection"in e&&e.setSelection(W.TextSelection.create(e.doc,k)),!0}const P={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},ho={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}},C={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},T=e=>{const t={};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=C.textAlignment.values.includes(e.style.textAlign)?e.style.textAlign:void 0,t},H=(e,t)=>{e.backgroundColor&&e.backgroundColor!==C.backgroundColor.default&&(t.style.backgroundColor=e.backgroundColor in P?P[e.backgroundColor].background:e.backgroundColor),e.textColor&&e.textColor!==C.textColor.default&&(t.style.color=e.textColor in P?P[e.textColor].text:e.textColor),e.textAlignment&&e.textAlignment!==C.textAlignment.default&&(t.style.textAlign=e.textAlignment)},go=(e="backgroundColor")=>({default:C.backgroundColor.default,parseHTML:t=>t.hasAttribute("data-background-color")?t.getAttribute("data-background-color"):t.style.backgroundColor?t.style.backgroundColor:C.backgroundColor.default,renderHTML:t=>t[e]===C.backgroundColor.default?{}:{"data-background-color":t[e]}}),mo=(e="textColor")=>({default:C.textColor.default,parseHTML:t=>t.hasAttribute("data-text-color")?t.getAttribute("data-text-color"):t.style.color?t.style.color:C.textColor.default,renderHTML:t=>t[e]===C.textColor.default?{}:{"data-text-color":t[e]}}),bo=(e="textAlignment")=>({default:C.textAlignment.default,parseHTML:t=>t.hasAttribute("data-text-alignment")?t.getAttribute("data-text-alignment"):t.style.textAlign?t.style.textAlign:C.textAlignment.default,renderHTML:t=>t[e]===C.textAlignment.default?{}:{"data-text-alignment":t[e]}}),he=(e,t)=>{const n=e.querySelector(t);if(!n)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:n,caption:r}},ko=(e,t,n)=>{const o=document.createElement("div");o.className="bn-add-file-button";const r=document.createElement("div");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);const s=document.createElement("p");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);const i=c=>{c.preventDefault()},a=()=>{t.transact(c=>c.setMeta(t.filePanel.plugins[0],{block:e}))};return o.addEventListener("mousedown",i,!0),o.addEventListener("click",a,!0),{dom:o,destroy:()=>{o.removeEventListener("mousedown",i,!0),o.removeEventListener("click",a,!0)}}},Co='<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>',yo=e=>{const t=document.createElement("div");t.className="bn-file-name-with-icon";const n=document.createElement("div");n.className="bn-file-icon",n.innerHTML=Co,t.appendChild(n);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,t.appendChild(o),{dom:t}},Oe=(e,t,n,o)=>{const r=document.createElement("div");if(r.className="bn-file-block-content-wrapper",e.props.url===""){const i=ko(e,t,o);r.appendChild(i.dom);const a=t.onUploadStart(c=>{if(c===e.id){r.removeChild(i.dom);const l=document.createElement("div");l.className="bn-file-loading-preview",l.textContent="Loading...",r.appendChild(l)}});return{dom:r,destroy:()=>{a(),i.destroy()}}}const s={dom:r};if(e.props.showPreview===!1||!n){const i=yo(e);r.appendChild(i.dom),s.destroy=()=>{var a;(a=i.destroy)==null||a.call(i)}}else r.appendChild(n.dom);if(e.props.caption){const i=document.createElement("p");i.className="bn-file-caption",i.textContent=e.props.caption,r.appendChild(i)}return s},De=(e,t)=>{const n=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},ge=(e,t)=>{const n=document.createElement("div"),o=document.createElement("p");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},Ee=e=>({url:e.src||void 0}),Et='<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>',Bt=e=>({type:"audio",propSchema:{backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none"}),xt=(e={})=>t=>{if(t.tagName==="AUDIO"){if(t.closest("figure"))return;const{backgroundColor:n}=T(t);return{...Ee(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=he(t,"audio");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:s}=T(t);return{...Ee(o),backgroundColor:s,caption:r}}},Tt=(e={})=>(t,n)=>{const o=document.createElement("div");o.innerHTML=e.icon??Et;const r=document.createElement("audio");return r.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(s=>{r.src=s}):r.src=t.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,Oe(t,n,{dom:r},o.firstElementChild)},Mt=(e={})=>(t,n)=>{if(!t.props.url){const r=document.createElement("p");return r.textContent="Add audio",{dom:r}}let o;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?De(o,t.props.caption):ge(o,t.props.caption):{dom:o}},Lt=M(Bt,e=>({meta:{fileBlockAccept:["audio/*"]},parse:xt(e),render:Tt(e),toExternalHTML:Mt(e),runsBefore:["file"]}));class Nt{constructor(){B(this,"callbacks",{})}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),()=>this.off(t,n)}emit(t,...n){const o=this.callbacks[t];o&&o.forEach(r=>r.apply(this,n))}off(t,n){const o=this.callbacks[t];o&&(n?this.callbacks[t]=o.filter(r=>r!==n):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}class At extends Nt{constructor(...n){super();B(this,"plugins",[]);B(this,"inputRules");B(this,"keyboardShortcuts");B(this,"tiptapExtensions")}static key(){throw new Error("You must implement the key method in your extension")}addProsemirrorPlugin(n){this.plugins.push(n)}get priority(){}}function N(e){const t=Object.create(At.prototype);return t.key=e.key,t.inputRules=e.inputRules,t.keyboardShortcuts=e.keyboardShortcuts,t.plugins=e.plugins??[],t.tiptapExtensions=e.tiptapExtensions,t}const Ze=Symbol.for("blocknote.shikiParser"),ke=Symbol.for("blocknote.shikiHighlighterPromise");function wo(e){const t=globalThis;let n,o,r=!1;const s=i=>{if(!e.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function"),r=!0),[];if(!n)return t[ke]=t[ke]||e.createHighlighter(),t[ke].then(c=>{n=c});const a=He(e,i.language);return!a||a==="text"||a==="none"||a==="plaintext"||a==="txt"?[]:n.getLoadedLanguages().includes(a)?(o||(o=t[Ze]||An.createParser(n),t[Ze]=o),o(i)):n.loadLanguage(a)};return Nn.createHighlightPlugin({parser:s,languageExtractor:i=>i.attrs.language,nodeTypes:["codeBlock"]})}const It=({defaultLanguage:e="text"})=>({type:"codeBlock",propSchema:{language:{default:e}},content:"inline"}),Pt=M(It,e=>({meta:{code:!0,defining:!0,isolating:!1},parse:t=>{var r,s;if(t.tagName!=="PRE"||t.childElementCount!==1||((r=t.firstElementChild)==null?void 0:r.tagName)!=="CODE")return;const n=t.firstElementChild;return{language:n.getAttribute("data-language")||((s=n.className.split(" ").find(i=>i.includes("language-")))==null?void 0:s.replace("language-",""))}},parseContent:({el:t,schema:n})=>{const o=x.DOMParser.fromSchema(n),r=t.firstElementChild;return o.parse(r,{topNode:n.nodes.codeBlock.create()}).content},render(t,n){const o=document.createDocumentFragment(),r=document.createElement("pre"),s=document.createElement("code");r.appendChild(s);let i;if(e.supportedLanguages){const a=document.createElement("select");Object.entries(e.supportedLanguages??{}).forEach(([d,{name:u}])=>{const p=document.createElement("option");p.value=d,p.text=u,a.appendChild(p)}),a.value=t.props.language||e.defaultLanguage||"text";const c=d=>{const u=d.target.value;n.updateBlock(t.id,{props:{language:u}})};a.addEventListener("change",c),i=()=>a.removeEventListener("change",c);const l=document.createElement("div");l.contentEditable="false",l.appendChild(a),o.appendChild(l)}return o.appendChild(r),{dom:o,contentDOM:s,destroy:()=>{i==null||i()}}},toExternalHTML(t){const n=document.createElement("pre"),o=document.createElement("code");return o.className=`language-${t.props.language}`,o.dataset.language=t.props.language,n.appendChild(o),{dom:n,contentDOM:o}}}),e=>[N({key:"code-block-highlighter",plugins:[wo(e)]}),N({key:"code-block-keyboard-shortcuts",keyboardShortcuts:{Delete:({editor:t})=>t.transact(n=>{const{block:o}=t.getTextCursorPosition();if(o.type!=="codeBlock")return!1;const{$from:r}=n.selection;return r.parent.textContent?!1:(t.removeBlocks([o]),!0)}),Tab:({editor:t})=>e.indentLineWithTab===!1?!1:t.transact(n=>{const{block:o}=t.getTextCursorPosition();return o.type==="codeBlock"?(n.insertText(" "),!0):!1}),Enter:({editor:t})=>t.transact(n=>{const{block:o,nextBlock:r}=t.getTextCursorPosition();if(o.type!=="codeBlock")return!1;const{$from:s}=n.selection,i=s.parentOffset===s.parent.nodeSize-2,a=s.parent.textContent.endsWith(`
8
-
9
- `);if(i&&a){if(n.delete(s.pos-2,s.pos),r)return t.setTextCursorPosition(r,"start"),!0;const[c]=t.insertBlocks([{type:"paragraph"}],o,"after");return t.setTextCursorPosition(c,"start"),!0}return n.insertText(`
10
- `),!0}),"Shift-Enter":({editor:t})=>t.transact(()=>{const{block:n}=t.getTextCursorPosition();if(n.type!=="codeBlock")return!1;const[o]=t.insertBlocks([{type:"paragraph"}],n,"after");return t.setTextCursorPosition(o,"start"),!0})},inputRules:[{find:/^```(.*?)\s$/,replace:({match:t})=>{const n=t[1].trim();return{type:"codeBlock",props:{language:{language:He(e,n)??n}.language},content:[]}}}]})]);function He(e,t){var n;return(n=Object.entries(e.supportedLanguages??{}).find(([o,{aliases:r}])=>(r==null?void 0:r.includes(t))||o===t))==null?void 0:n[0]}const Ot=()=>({type:"divider",propSchema:{},content:"none"}),Dt=M(Ot,{meta:{isolating:!1},parse(e){if(e.tagName==="HR")return{}},render(){return{dom:document.createElement("hr")}}},[N({key:"divider-block-shortcuts",inputRules:[{find:new RegExp("^---$"),replace(){return{type:"divider",props:{},content:[]}}}]})]),Xe=e=>({url:e.src||void 0}),Ht=()=>({type:"file",propSchema:{backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none"}),_t=()=>e=>{if(e.tagName==="EMBED"){if(e.closest("figure"))return;const{backgroundColor:t}=T(e);return{...Xe(e),backgroundColor:t}}if(e.tagName==="FIGURE"){const t=he(e,"embed");if(!t)return;const{targetElement:n,caption:o}=t,{backgroundColor:r}=T(e);return{...Xe(n),backgroundColor:r,caption:o}}},Rt=M(Ht,{meta:{fileBlockAccept:["*/*"]},parse:_t(),render(e,t){return Oe(e,t)},toExternalHTML(e){if(!e.props.url){const n=document.createElement("p");return n.textContent="Add file",{dom:n}}const t=document.createElement("a");return t.href=e.props.url,t.textContent=e.props.name||e.props.url,e.props.caption?ge(t,e.props.caption):{dom:t}}}),Vt={set:(e,t)=>window.localStorage.setItem(`toggle-${e.id}`,t?"true":"false"),get:e=>window.localStorage.getItem(`toggle-${e.id}`)==="true"},_e=(e,t,n,o=Vt)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:n};const r=document.createElement("div"),s=document.createElement("div");s.className="bn-toggle-wrapper";const i=document.createElement("button");i.className="bn-toggle-button",i.type="button",i.innerHTML='<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>';const a=h=>h.preventDefault();i.addEventListener("mousedown",a);const c=()=>{var h;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))};i.addEventListener("click",c),s.appendChild(i),s.appendChild(n);const l=document.createElement("button");l.className="bn-toggle-add-block-button",l.type="button",l.textContent=t.dictionary.toggle_blocks.add_block_button;const d=h=>h.preventDefault();l.addEventListener("mousedown",d);const u=()=>{t.transact(()=>{const h=t.updateBlock(e,{children:[{}]});t.setTextCursorPosition(h.children[0].id,"end"),t.focus()})};l.addEventListener("click",u),r.appendChild(s);let p=e.children.length;const f=t.onChange(()=>{var k;const h=((k=t.getBlock(e))==null?void 0:k.children.length)??0;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});return o.get(e)?(s.setAttribute("data-show-children","true"),e.children.length===0&&r.appendChild(l)):s.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:h=>h instanceof MutationRecord&&(h.type==="attributes"&&h.target===s&&h.attributeName==="data-show-children"||h.type==="childList"&&(h.addedNodes[0]===l||h.removedNodes[0]===l)),destroy:()=>{i.removeEventListener("mousedown",a),i.removeEventListener("click",c),l.removeEventListener("mousedown",d),l.removeEventListener("click",u),f==null||f()}}},Ft=[1,2,3,4,5,6],Wt=({defaultLevel:e=1,levels:t=Ft,allowToggleHeadings:n=!0}={})=>({type:"heading",propSchema:{...C,level:{default:e,values:t},...n?{isToggleable:{default:!1,optional:!0}}:{}},content:"inline"}),$t=M(Wt,({allowToggleHeadings:e=!0}={})=>({meta:{isolating:!1},parse(t){let n;switch(t.tagName){case"H1":n=1;break;case"H2":n=2;break;case"H3":n=3;break;case"H4":n=4;break;case"H5":n=5;break;case"H6":n=6;break;default:return}return{...T(t),level:n}},render(t,n){const o=document.createElement(`h${t.props.level}`);return e?{..._e(t,n,o),contentDOM:o}:{dom:o,contentDOM:o}},toExternalHTML(t){const n=document.createElement(`h${t.props.level}`);return H(t.props,n),{dom:n,contentDOM:n}}}),({levels:e=Ft}={})=>[N({key:"heading-shortcuts",keyboardShortcuts:Object.fromEntries(e.map(t=>[`Mod-Alt-${t}`,({editor:n})=>{const o=n.getTextCursorPosition();return n.schema.blockSchema[o.block.type].content!=="inline"?!1:(n.updateBlock(o.block,{type:"heading",props:{level:t}}),!0)}])??[]),inputRules:e.map(t=>({find:new RegExp(`^(#{${t}})\\s$`),replace({match:n}){return{type:"heading",props:{level:n[1].length}}}}))})]),jt=(e,t,n,o,r)=>{const{dom:s,destroy:i}=Oe(e,t,n,r),a=s;a.style.position="relative",e.props.url&&e.props.showPreview&&(e.props.previewWidth?a.style.width=`${e.props.previewWidth}px`:a.style.width="fit-content");const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const l=document.createElement("div");l.className="bn-resize-handle",l.style.right="4px";const d=document.createElement("div");d.style.position="absolute",d.style.height="100%",d.style.width="100%";let u,p=e.props.previewWidth;const f=m=>{var X,J;if(!u){!t.isEditable&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l));return}let v;const L="touches"in m?m.touches[0].clientX:m.clientX;e.props.textAlignment==="center"?u.handleUsed==="left"?v=u.initialWidth+(u.initialClientX-L)*2:v=u.initialWidth+(L-u.initialClientX)*2:u.handleUsed==="left"?v=u.initialWidth+u.initialClientX-L:v=u.initialWidth+L-u.initialClientX,p=Math.min(Math.max(v,64),((J=(X=t.domElement)==null?void 0:X.firstElementChild)==null?void 0:J.clientWidth)||Number.MAX_VALUE),a.style.width=`${p}px`},h=m=>{(!m.target||!a.contains(m.target)||!t.isEditable)&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l)),u&&(u=void 0,a.contains(d)&&a.removeChild(d),t.updateBlock(e,{props:{previewWidth:p}}))},k=()=>{t.isEditable&&(o.appendChild(c),o.appendChild(l))},g=m=>{m.relatedTarget===c||m.relatedTarget===l||u||t.isEditable&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l))},b=m=>{m.preventDefault(),a.contains(d)||a.appendChild(d);const v="touches"in m?m.touches[0].clientX:m.clientX;u={handleUsed:"left",initialWidth:a.clientWidth,initialClientX:v}},y=m=>{m.preventDefault(),a.contains(d)||a.appendChild(d);const v="touches"in m?m.touches[0].clientX:m.clientX;u={handleUsed:"right",initialWidth:a.clientWidth,initialClientX:v}};return window.addEventListener("mousemove",f),window.addEventListener("touchmove",f),window.addEventListener("mouseup",h),window.addEventListener("touchend",h),a.addEventListener("mouseenter",k),a.addEventListener("mouseleave",g),c.addEventListener("mousedown",b),c.addEventListener("touchstart",b),l.addEventListener("mousedown",y),l.addEventListener("touchstart",y),{dom:a,destroy:()=>{i==null||i(),window.removeEventListener("mousemove",f),window.removeEventListener("touchmove",f),window.removeEventListener("mouseup",h),window.removeEventListener("touchend",h),a.removeEventListener("mouseenter",k),a.removeEventListener("mouseleave",g),c.removeEventListener("mousedown",b),c.removeEventListener("touchstart",b),l.removeEventListener("mousedown",y),l.removeEventListener("touchstart",y)}}},Je=e=>{const t=e.src||void 0,n=e.width||void 0,o=e.alt||void 0;return{url:t,previewWidth:n,name:o}},Ut='<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>',qt=(e={})=>({type:"image",propSchema:{textAlignment:C.textAlignment,backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),zt=(e={})=>t=>{if(t.tagName==="IMG"){if(t.closest("figure"))return;const{backgroundColor:n}=T(t);return{...Je(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=he(t,"img");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:s}=T(t);return{...Je(o),backgroundColor:s,caption:r}}},Gt=(e={})=>(t,n)=>{const o=document.createElement("div");o.innerHTML=e.icon??Ut;const r=document.createElement("div");r.className="bn-visual-media-wrapper";const s=document.createElement("img");return s.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(i=>{s.src=i}):s.src=t.props.url,s.alt=t.props.name||t.props.caption||"BlockNote image",s.contentEditable="false",s.draggable=!1,r.appendChild(s),jt(t,n,{dom:r},r,o.firstElementChild)},Zt=(e={})=>(t,n)=>{if(!t.props.url){const r=document.createElement("p");return r.textContent="Add image",{dom:r}}let o;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?De(o,t.props.caption):ge(o,t.props.caption):{dom:o}},Xt=M(qt,e=>({meta:{fileBlockAccept:["image/*"]},parse:zt(e),render:Gt(e),toExternalHTML:Zt(e),runsBefore:["file"]})),vo=(e,t,n)=>({state:o,dispatch:r})=>r?Jt(o.tr,e,t,n):!0,Jt=(e,t,n,o)=>{const r=ie(e.doc,t),s=q(r);if(!s.isBlockContainer)return!1;const i=G(e),a=[{type:s.bnBlock.node.type,attrs:o?{...s.bnBlock.node.attrs,id:void 0}:{}},{type:n?s.blockContent.node.type:i.nodes.paragraph,attrs:o?{...s.blockContent.node.attrs}:{}}];return e.split(t,2,a),!0},me=(e,t)=>{const{blockInfo:n,selectionEmpty:o}=e.transact(i=>({blockInfo:lt(i),selectionEmpty:i.selection.anchor===i.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:r,blockContent:s}=n;return s.node.type.name!==t||!o?!1:s.node.childCount===0?(e.transact(i=>{fe(i,r.beforePos,{type:"paragraph",props:{}})}),!0):s.node.childCount>0?e.transact(i=>(i.deleteSelection(),Jt(i,i.selection.from,!0))):!1};function Re(e,t,n){var u,p,f;const o=x.DOMParser.fromSchema(t),r=e,s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");for(const h of Array.from(r.childNodes))s.appendChild(h.cloneNode(!0));let i=o.parse(s,{topNode:t.nodes.blockGroup.create()});((p=(u=i.firstChild)==null?void 0:u.firstChild)==null?void 0:p.type.name)==="checkListItem"&&(i=i.copy(i.content.cut(i.firstChild.firstChild.nodeSize+2)));const a=(f=i.firstChild)==null?void 0:f.firstChild;if(!(a!=null&&a.isTextblock))return x.Fragment.from(i);const c=t.nodes[n].create({},a.content),l=i.content.cut(a.nodeSize+2);if(l.size>0){const h=i.copy(l);return c.content.addToEnd(h)}return c.content}const Kt=()=>({type:"bulletListItem",propSchema:{...C},content:"inline"}),Yt=M(Kt,{meta:{isolating:!1},parse(e){var n;if(e.tagName!=="LI")return;const t=e.parentElement;if(t!==null&&(t.tagName==="UL"||t.tagName==="DIV"&&((n=t.parentElement)==null?void 0:n.tagName)==="UL"))return T(e)},parseContent:({el:e,schema:t})=>Re(e,t,"bulletListItem"),render(){const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return H(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[N({key:"bullet-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>me(e,"bulletListItem"),"Mod-Shift-8":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"bulletListItem",props:{}}),!0)}},inputRules:[{find:new RegExp("^[-+*]\\s$"),replace({editor:e}){if(Te(e.prosemirrorState).blockNoteType!=="heading")return{type:"bulletListItem",props:{}}}}]})]),Qt=()=>({type:"checkListItem",propSchema:{...C,checked:{default:!1,type:"boolean"}},content:"inline"}),en=M(Qt,{meta:{isolating:!1},parse(e){var n;if(e.tagName==="input")return e.closest("[data-content-type]")||e.closest("li")?void 0:e.type==="checkbox"?{checked:e.checked}:void 0;if(e.tagName!=="LI")return;const t=e.parentElement;if(t!==null&&(t.tagName==="UL"||t.tagName==="DIV"&&((n=t.parentElement)==null?void 0:n.tagName)==="UL")){const o=e.querySelector("input[type=checkbox]")||null;return o===null?void 0:{...T(e),checked:o.checked}}},parseContent:({el:e,schema:t})=>Re(e,t,"checkListItem"),render(e,t){const n=document.createDocumentFragment(),o=document.createElement("input");o.type="checkbox",o.checked=e.props.checked,e.props.checked&&o.setAttribute("checked",""),o.addEventListener("change",()=>{t.updateBlock(e,{props:{checked:!e.props.checked}})});const r=document.createElement("p");return n.appendChild(o),n.appendChild(r),{dom:n,contentDOM:r}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("input");n.type="checkbox",n.checked=e.props.checked,e.props.checked&&n.setAttribute("checked","");const o=document.createElement("p");return H(e.props,t),t.appendChild(n),t.appendChild(o),{dom:t,contentDOM:o}},runsBefore:["bulletListItem"]},[N({key:"check-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>me(e,"checkListItem"),"Mod-Shift-9":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"checkListItem",props:{}}),!0)}},inputRules:[{find:new RegExp("\\[\\s*\\]\\s$"),replace(){return{type:"checkListItem",props:{checked:!1},content:[]}}},{find:new RegExp("\\[[Xx]\\]\\s$"),replace(){return{type:"checkListItem",props:{checked:!0}}}}]})]);function tn(e,t,n,o){let r=e.firstChild.attrs.start||1,s=!0;const i=!!e.firstChild.attrs.start,a=q({posBeforeNode:t,node:e});if(!a.isBlockContainer)throw new Error("impossible");const c=n.doc.resolve(a.bnBlock.beforePos).nodeBefore,l=c?o.get(c):void 0;return l!==void 0?(r=l+1,s=!1):c&&q({posBeforeNode:a.bnBlock.beforePos-c.nodeSize,node:c}).blockNoteType==="numberedListItem"&&(r=tn(c,a.bnBlock.beforePos-c.nodeSize,n,o).index+1,s=!1),o.set(e,r),{index:r,isFirst:s,hasStart:i}}function Ke(e,t){const n=new Map,o=t.decorations.map(e.mapping,e.doc),r=[];e.doc.nodesBetween(0,e.doc.nodeSize-2,(i,a)=>{if(i.type.name==="blockContainer"&&i.firstChild.type.name==="numberedListItem"){const{index:c,isFirst:l,hasStart:d}=tn(i,a,e,n);o.find(a,a+i.nodeSize,p=>p.index===c&&p.isFirst===l&&p.hasStart===d).length===0&&r.push(Ce.Decoration.node(a+1,a+i.nodeSize-1,{"data-index":c.toString()}))}});const s=r.flatMap(i=>o.find(i.from,i.to));return{decorations:o.remove(s).add(e.doc,r)}}const So=()=>new W.Plugin({key:new W.PluginKey("numbered-list-indexing-decorations"),state:{init(e,t){return Ke(t.tr,{decorations:Ce.DecorationSet.empty})},apply(e,t){return!e.docChanged&&!e.selectionSet&&t.decorations?t:Ke(e,t)}},props:{decorations(e){var t;return((t=this.getState(e))==null?void 0:t.decorations)??Ce.DecorationSet.empty}}}),nn=()=>({type:"numberedListItem",propSchema:{...C,start:{default:void 0,type:"number"}},content:"inline"}),on=M(nn,{meta:{isolating:!1},parse(e){var n;if(e.tagName!=="LI")return;const t=e.parentElement;if(t!==null&&(t.tagName==="OL"||t.tagName==="DIV"&&((n=t.parentElement)==null?void 0:n.tagName)==="OL")){const o=parseInt(t.getAttribute("start")||"1"),r=T(e);return e.previousElementSibling||o===1?r:{...r,start:o}}},parseContent:({el:e,schema:t})=>Re(e,t,"numberedListItem"),render(){const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return H(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[N({key:"numbered-list-item-shortcuts",inputRules:[{find:new RegExp("^(\\d+)\\.\\s$"),replace({match:e,editor:t}){if(Te(t.prosemirrorState).blockNoteType==="heading")return;const o=parseInt(e[1]);return{type:"numberedListItem",props:{start:o!==1?o:void 0}}}}],keyboardShortcuts:{Enter:({editor:e})=>me(e,"numberedListItem"),"Mod-Shift-7":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"numberedListItem",props:{}}),!0)}},plugins:[So()]})]),rn=()=>({type:"toggleListItem",propSchema:{...C},content:"inline"}),sn=M(rn,{meta:{isolating:!1},render(e,t){const n=document.createElement("p");return{..._e(e,t,n),contentDOM:n}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return H(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[N({key:"toggle-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>me(e,"toggleListItem"),"Mod-Shift-6":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"toggleListItem",props:{}}),!0)}}})]),an=()=>({type:"pageBreak",propSchema:{},content:"none"}),cn=M(an,{parse(e){if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{}},render(){const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},toExternalHTML(){const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}}}),Eo=e=>e.extend({blockSpecs:{pageBreak:cn()}}),ln=()=>({type:"paragraph",propSchema:C,content:"inline"}),un=M(ln,{meta:{isolating:!1},parse:e=>{var t;if(e.tagName==="P"&&(t=e.textContent)!=null&&t.trim())return T(e)},render:()=>{const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("p");return H(e.props,t),{dom:t,contentDOM:t}},runsBefore:["default"]},[N({key:"paragraph-shortcuts",keyboardShortcuts:{"Mod-Alt-0":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"paragraph",props:{}}),!0)}}})]),dn=()=>({type:"quote",propSchema:{backgroundColor:C.backgroundColor,textColor:C.textColor},content:"inline"}),pn=M(dn,{meta:{isolating:!1},parse(e){if(e.tagName==="BLOCKQUOTE"){const{backgroundColor:t,textColor:n}=T(e);return{backgroundColor:t,textColor:n}}},render(){const e=document.createElement("blockquote");return{dom:e,contentDOM:e}},toExternalHTML(e){const t=document.createElement("blockquote");return H(e.props,t),{dom:t,contentDOM:t}}},[N({key:"quote-block-shortcuts",keyboardShortcuts:{"Mod-Alt-q":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"quote",props:{}}),!0)}},inputRules:[{find:new RegExp("^>\\s$"),replace(){return{type:"quote",props:{}}}}]})]),Bo=35,Ve=120,xo=31,To=E.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[I.columnResizing({cellMinWidth:Bo,defaultCellMinWidth:Ve,View:null}),I.tableEditing()],addKeyboardShortcuts(){return{Enter:()=>this.editor.state.selection.empty&&this.editor.state.selection.$head.parent.type.name==="tableParagraph"?(this.editor.commands.insertContent({type:"hardBreak"}),!0):!1,Backspace:()=>{const e=this.editor.state.selection,t=e.empty,n=e.$head.parentOffset===0,o=e.$head.node().type.name==="tableParagraph";return t&&n&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>I.goToNextCell(1)(e,t,n)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>I.goToNextCell(-1)(e,t,n))}},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:E.callOrReturn(E.getExtensionField(e,"tableRole",t))}}}),fn={textColor:C.textColor},Mo=E.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"tableContent+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getContent:(e,t)=>hn(e,t)}]},renderHTML({HTMLAttributes:e}){return["th",E.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Lo=E.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"tableContent+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getContent:(e,t)=>hn(e,t)}]},renderHTML({HTMLAttributes:e}){return["td",E.mergeAttributes(this.options.HTMLAttributes,e),0]}}),No=E.Node.create({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){var r,s,i;const n=et(this.name,"table",{...((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},...t},((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{}),o=document.createElement("colgroup");for(const a of e.children[0].children)if(a.attrs.colwidth)for(const l of a.attrs.colwidth){const d=document.createElement("col");l&&(d.style=`width: ${l}px`),o.appendChild(d)}else o.appendChild(document.createElement("col"));return(i=n.dom.firstChild)==null||i.appendChild(o),n},addNodeView(){return({node:e,HTMLAttributes:t})=>{var o;class n extends I.TableView{constructor(s,i,a){super(s,i),this.node=s,this.cellMinWidth=i,this.blockContentHTMLAttributes=a;const c=document.createElement("div");c.className=U("bn-block-content",a.class),c.setAttribute("data-content-type","table");for(const[p,f]of Object.entries(a))p!=="class"&&c.setAttribute(p,f);const l=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(l.firstChild),l.appendChild(d),c.appendChild(l);const u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",l.appendChild(u),this.dom=c}ignoreMutation(s){return!s.target.closest(".tableWrapper-inner")||super.ignoreMutation(s)}}return new n(e,Ve,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...t})}}}),Ao=E.Node.create({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{tag:"p",getAttrs:e=>{if(typeof e=="string"||!e.textContent||!e.closest("[data-content-type]"))return!1;const t=e.parentElement;return t===null?!1:t.tagName==="TD"||t.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),Io=E.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",E.mergeAttributes(this.options.HTMLAttributes,e),0]}});function hn(e,t){const o=x.DOMParser.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),r=[];return o.content.descendants(s=>{if(s.isInline)return r.push(s),!1}),x.Fragment.fromArray(r)}const gn=()=>rt({node:No,type:"table",content:"table"},fn,[N({key:"table-extensions",tiptapExtensions:[To,Ao,Mo,Lo,Io]}),N({key:"table-keyboard-delete",keyboardShortcuts:{Backspace:({editor:e})=>{if(!(e.prosemirrorState.selection instanceof I.CellSelection))return!1;const t=e.getTextCursorPosition().block,n=t.content;let o=0;for(const s of n.rows)for(const i of s.cells){if("type"in i&&i.content.length>0||!("type"in i)&&i.length>0)return!1;o++}let r=0;return e.prosemirrorState.selection.forEachCell(()=>{r++}),r<o?!1:(e.transact(()=>{(e.getPrevBlock(t)||e.getNextBlock(t))&&e.setTextCursorPosition(t),e.removeBlocks([t])}),!0)}}})]),Ye=e=>{const t=e.src||void 0,n=e.width||void 0;return{url:t,previewWidth:n}},mn='<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>',bn=e=>({type:"video",propSchema:{textAlignment:C.textAlignment,backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),kn=e=>t=>{if(t.tagName==="VIDEO"){if(t.closest("figure"))return;const{backgroundColor:n}=T(t);return{...Ye(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=he(t,"video");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:s}=T(t);return{...Ye(o),backgroundColor:s,caption:r}}},Cn=M(bn,e=>({meta:{fileBlockAccept:["video/*"]},parse:kn(),render(t,n){const o=document.createElement("div");o.innerHTML=e.icon??mn;const r=document.createElement("div");r.className="bn-visual-media-wrapper";const s=document.createElement("video");return s.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(i=>{s.src=i}):s.src=t.props.url,s.controls=!0,s.contentEditable="false",s.draggable=!1,s.width=t.props.previewWidth,r.appendChild(s),jt(t,n,{dom:r},r,o.firstElementChild)},toExternalHTML(t){if(!t.props.url){const o=document.createElement("p");return o.textContent="Add video",{dom:o}}let n;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?De(n,t.props.caption):ge(n,t.props.caption):{dom:n}},runsBefore:["file"]})),Po=async e=>{const t=new FormData;return t.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:t})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function S(e,t,n){if(!(t in e.schema.blockSpecs))return!1;if(!n)return!0;for(const[o,r]of Object.entries(n)){if(!(o in e.schema.blockSpecs[t].config.propSchema))return!1;if(typeof r=="string"){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)return!1}else{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)return!1;if(typeof e.schema.blockSpecs[t].config.propSchema[o].values=="object"&&typeof r.values=="object"){if(e.schema.blockSpecs[t].config.propSchema[o].values.length!==r.values.length)return!1;for(let s=0;s<e.schema.blockSpecs[t].config.propSchema[o].values.length;s++)if(e.schema.blockSpecs[t].config.propSchema[o].values[s]!==r.values[s])return!1}}}return!0}function Oo(e,t,n,o){return S(t,n,o)&&e.type===n}function Do(e){return e instanceof I.CellSelection}function Ho(e){let t=e.getTextCursorPosition().block,n=e.schema.blockSchema[t.type].content;for(;n==="none";){if(t=e.getTextCursorPosition().nextBlock,t===void 0)return;n=e.schema.blockSchema[t.type].content,e.setTextCursorPosition(t,"end")}}function w(e,t){const n=e.getTextCursorPosition().block;if(n.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let o;return Array.isArray(n.content)&&(n.content.length===1&&O(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)),Ho(e),o}function _o(e){const t=[];return S(e,"heading",{level:"number"})&&t.push({onItemClick:()=>{w(e,{type:"heading",props:{level:1}})},badge:A("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{w(e,{type:"heading",props:{level:2}})},badge:A("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{w(e,{type:"heading",props:{level:3}})},badge:A("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),S(e,"quote")&&t.push({onItemClick:()=>{w(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),S(e,"toggleListItem")&&t.push({onItemClick:()=>{w(e,{type:"toggleListItem"})},badge:A("Mod-Shift-6"),key:"toggle_list",...e.dictionary.slash_menu.toggle_list}),S(e,"numberedListItem")&&t.push({onItemClick:()=>{w(e,{type:"numberedListItem"})},badge:A("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),S(e,"bulletListItem")&&t.push({onItemClick:()=>{w(e,{type:"bulletListItem"})},badge:A("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),S(e,"checkListItem")&&t.push({onItemClick:()=>{w(e,{type:"checkListItem"})},badge:A("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),S(e,"paragraph")&&t.push({onItemClick:()=>{w(e,{type:"paragraph"})},badge:A("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),S(e,"codeBlock")&&t.push({onItemClick:()=>{w(e,{type:"codeBlock"})},badge:A("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),S(e,"divider")&&t.push({onItemClick:()=>{w(e,{type:"divider"})},key:"divider",...e.dictionary.slash_menu.divider}),S(e,"table")&&t.push({onItemClick:()=>{w(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),S(e,"image",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"image",...e.dictionary.slash_menu.image}),S(e,"video",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"video",...e.dictionary.slash_menu.video}),S(e,"audio",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"audio",...e.dictionary.slash_menu.audio}),S(e,"file",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"file",...e.dictionary.slash_menu.file}),S(e,"heading",{level:"number",isToggleable:"boolean"})&&t.push({onItemClick:()=>{w(e,{type:"heading",props:{level:1,isToggleable:!0}})},key:"toggle_heading",...e.dictionary.slash_menu.toggle_heading},{onItemClick:()=>{w(e,{type:"heading",props:{level:2,isToggleable:!0}})},key:"toggle_heading_2",...e.dictionary.slash_menu.toggle_heading_2},{onItemClick:()=>{w(e,{type:"heading",props:{level:3,isToggleable:!0}})},key:"toggle_heading_3",...e.dictionary.slash_menu.toggle_heading_3}),S(e,"heading",{level:"number"})&&(e.schema.blockSchema.heading.propSchema.level.values||[]).filter(n=>n>3).forEach(n=>{t.push({onItemClick:()=>{w(e,{type:"heading",props:{level:n}})},key:`heading_${n}`,...e.dictionary.slash_menu[`heading_${n}`]})}),t.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),t}function Ro(e,t){return e.filter(({title:n,aliases:o})=>n.toLowerCase().includes(t.toLowerCase())||o&&o.filter(r=>r.toLowerCase().includes(t.toLowerCase())).length!==0)}function yn(e){return"pageBreak"in e.schema.blockSchema}function Vo(e){const t=[];return yn(e)&&t.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{w(e,{type:"pageBreak"})},key:"page_break"}),t}const wn={audio:Lt(),bulletListItem:Yt(),checkListItem:en(),codeBlock:Pt(),divider:Dt(),file:Rt(),heading:$t(),image:Xt(),numberedListItem:on(),paragraph:un(),quote:pn(),table:gn(),toggleListItem:sn(),video:Cn()},Fo=Ae({type:"textColor",propSchema:"string"},{render:()=>{const e=document.createElement("span");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("span");return e!==C.textColor.default&&(t.style.color=e in P?P[e].text:e),{dom:t,contentDOM:t}},parse:e=>{if(e.tagName==="SPAN"&&e.style.color)return e.style.color}}),Wo=Ae({type:"backgroundColor",propSchema:"string"},{render:()=>{const e=document.createElement("span");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("span");return e!==C.backgroundColor.default&&(t.style.backgroundColor=e in P?P[e].background:e),{dom:t,contentDOM:t}},parse:e=>{if(e.tagName==="SPAN"&&e.style.backgroundColor)return e.style.backgroundColor}}),Fe={bold:F(Pn.default,"boolean"),italic:F(Dn.default,"boolean"),underline:F(_n.default,"boolean"),strike:F(Hn.default,"boolean"),code:F(On.default,"boolean"),textColor:Fo,backgroundColor:Wo},$o=Ne(Fe),We={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},jo=Me(We);class $e extends mt{static create(t){return new $e({blockSpecs:(t==null?void 0:t.blockSpecs)??wn,inlineContentSpecs:(t==null?void 0:t.inlineContentSpecs)??We,styleSpecs:(t==null?void 0:t.styleSpecs)??Fe})}}exports.BlockNoteExtension=At;exports.BlockNoteSchema=$e;exports.COLORS_DARK_MODE_DEFAULT=ho;exports.COLORS_DEFAULT=P;exports.CustomBlockNoteSchema=mt;exports.EMPTY_CELL_HEIGHT=xo;exports.EMPTY_CELL_WIDTH=Ve;exports.EventEmitter=Nt;exports.FILE_AUDIO_ICON_SVG=Et;exports.FILE_IMAGE_ICON_SVG=Ut;exports.FILE_VIDEO_ICON_SVG=mn;exports.UniqueID=Be;exports.UnreachableCaseError=z;exports.addDefaultPropsExternalHTML=H;exports.addInlineContentAttributes=Gn;exports.addInlineContentKeyboardShortcuts=Zn;exports.addNodeAndExtensionsToSpec=at;exports.addRowsOrColumns=ro;exports.addStyleAttributes=K;exports.applyNonSelectableBlockFix=st;exports.areInSameColumn=ao;exports.assertEmpty=Fn;exports.audioParse=xt;exports.audioRender=Tt;exports.audioToExternalHTML=Mt;exports.blockHasType=Oo;exports.blockToNode=te;exports.camelToDataKebab=Y;exports.canColumnBeDraggedInto=io;exports.canRowBeDraggedInto=so;exports.captureCellAnchor=St;exports.checkPageBreakBlocksInSchema=yn;exports.contentNodeToInlineContent=pe;exports.contentNodeToTableContent=dt;exports.createAudioBlockConfig=Bt;exports.createAudioBlockSpec=Lt;exports.createBlockConfig=Un;exports.createBlockNoteExtension=N;exports.createBlockSpec=M;exports.createBlockSpecFromTiptapNode=rt;exports.createBulletListItemBlockConfig=Kt;exports.createBulletListItemBlockSpec=Yt;exports.createCheckListItemBlockSpec=en;exports.createCheckListItemConfig=Qt;exports.createCodeBlockConfig=It;exports.createCodeBlockSpec=Pt;exports.createDefaultBlockDOMOutputSpec=et;exports.createDividerBlockConfig=Ot;exports.createDividerBlockSpec=Dt;exports.createFileBlockConfig=Ht;exports.createFileBlockSpec=Rt;exports.createHeadingBlockConfig=Wt;exports.createHeadingBlockSpec=$t;exports.createImageBlockConfig=qt;exports.createImageBlockSpec=Xt;exports.createInlineContentSpecFromTipTapNode=Xn;exports.createInternalInlineContentSpec=ft;exports.createInternalStyleSpec=Le;exports.createNumberedListItemBlockConfig=nn;exports.createNumberedListItemBlockSpec=on;exports.createPageBreakBlockConfig=an;exports.createPageBreakBlockSpec=cn;exports.createParagraphBlockConfig=ln;exports.createParagraphBlockSpec=un;exports.createQuoteBlockConfig=dn;exports.createQuoteBlockSpec=pn;exports.createStyleSpec=Ae;exports.createStyleSpecFromTipTapMark=F;exports.createTableBlockSpec=gn;exports.createToggleListItemBlockConfig=rn;exports.createToggleListItemBlockSpec=sn;exports.createToggleWrapper=_e;exports.createVideoBlockConfig=bn;exports.createVideoBlockSpec=Cn;exports.cropEmptyRowsOrColumns=oo;exports.defaultBlockSpecs=wn;exports.defaultBlockToHTML=we;exports.defaultInlineContentSchema=jo;exports.defaultInlineContentSpecs=We;exports.defaultProps=C;exports.defaultStyleSchema=$o;exports.defaultStyleSpecs=Fe;exports.defaultToggledState=Vt;exports.docToBlocks=qn;exports.editorHasBlockWithType=S;exports.fileParse=_t;exports.filenameFromURL=$n;exports.filterSuggestionItems=Ro;exports.formatKeyboardShortcut=A;exports.getBackgroundColorAttribute=go;exports.getBlockCache=de;exports.getBlockFromPos=ot;exports.getBlockInfo=q;exports.getBlockInfoFromResolvedPos=ct;exports.getBlockInfoFromSelection=Te;exports.getBlockInfoFromTransaction=lt;exports.getBlockInfoWithManualOffset=ae;exports.getBlockNoteSchema=ce;exports.getBlockSchema=le;exports.getCellsAtColumnHandle=Ct;exports.getCellsAtRowHandle=kt;exports.getColspan=j;exports.getDefaultSlashMenuItems=_o;exports.getDimensionsOfTable=Ie;exports.getInlineContentSchema=ue;exports.getInlineContentSchemaFromSpecs=Me;exports.getLanguageId=He;exports.getNearestBlockPos=ie;exports.getNodeById=wt;exports.getPageBreakSlashMenuItems=Vo;exports.getParseRules=it;exports.getPmSchema=G;exports.getRowspan=oe;exports.getStyleParseRules=gt;exports.getStyleSchema=V;exports.getStyleSchemaFromSpecs=Ne;exports.getTextAlignmentAttribute=bo;exports.getTextColorAttribute=mo;exports.imageParse=zt;exports.imageRender=Gt;exports.imageToExternalHTML=Zt;exports.inlineContentToNodes=R;exports.insertOrUpdateBlock=w;exports.isAppleOS=Qe;exports.isLinkInlineContent=ye;exports.isNodeBlock=vt;exports.isPartialLinkInlineContent=xe;exports.isPartialTableCell=$;exports.isSafari=Wn;exports.isStyledTextInlineContent=O;exports.isTableCell=se;exports.isTableCellSelection=Do;exports.isVideoUrl=jn;exports.mapTableCell=ne;exports.mergeCSSClasses=U;exports.mergeParagraphs=tt;exports.moveColumn=to;exports.moveRow=no;exports.nodeToBlock=Z;exports.nodeToCustomInlineContent=pt;exports.parseAudioElement=Ee;exports.parseDefaultProps=T;exports.propsToAttributes=nt;exports.prosemirrorSliceToSlicedBlocks=zn;exports.splitBlockCommand=vo;exports.stylePropsToAttributes=ht;exports.tableContentToNodes=Pe;exports.tablePropSchema=fn;exports.updateBlock=po;exports.updateBlockCommand=lo;exports.updateBlockTr=fe;exports.uploadToTmpFilesDotOrg_DEV_ONLY=Po;exports.videoParse=kn;exports.withPageBreak=Eo;exports.wrapInBlockStructure=re;
11
- //# sourceMappingURL=BlockNoteSchema-COA0fsXW.cjs.map