@blocknote/core 0.47.1 → 0.47.3
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.
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
- package/dist/{BlockNoteSchema-CwhtPpVC.cjs → BlockNoteSchema-CCs_V3lo.cjs} +2 -2
- package/dist/{BlockNoteSchema-CwhtPpVC.cjs.map → BlockNoteSchema-CCs_V3lo.cjs.map} +1 -1
- package/dist/{BlockNoteSchema-dmbNkHA-.js → BlockNoteSchema-ooiKsd5B.js} +2 -2
- package/dist/{BlockNoteSchema-dmbNkHA-.js.map → BlockNoteSchema-ooiKsd5B.js.map} +1 -1
- package/dist/{TrailingNode-F9hX_UlQ.js → TrailingNode-GzE59m_7.js} +585 -415
- package/dist/TrailingNode-GzE59m_7.js.map +1 -0
- package/dist/TrailingNode-n0WdMPUl.cjs +2 -0
- package/dist/TrailingNode-n0WdMPUl.cjs.map +1 -0
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +938 -862
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/defaultBlocks-Dg9kQWXm.cjs +6 -0
- package/dist/defaultBlocks-Dg9kQWXm.cjs.map +1 -0
- package/dist/{defaultBlocks-Caw1U1oV.js → defaultBlocks-ZzGbYgQn.js} +611 -530
- package/dist/defaultBlocks-ZzGbYgQn.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.cjs.map +1 -1
- package/dist/extensions.js +33 -54
- package/dist/extensions.js.map +1 -1
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +25 -24
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +1 -10
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +4 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/parsers/html/parseHTML.ts +2 -0
- package/src/api/parsers/html/util/normalizeWhitespace.ts +87 -0
- package/src/blocks/Heading/block.ts +48 -1
- package/src/blocks/ListItem/ToggleListItem/block.ts +51 -1
- package/src/blocks/Paragraph/block.ts +1 -1
- package/src/blocks/getDetailsContent.ts +77 -0
- package/src/comments/threadstore/TipTapThreadStore.ts +5 -5
- package/src/comments/threadstore/tiptap/types.ts +131 -0
- package/src/editor/Block.css +6 -0
- package/src/editor/BlockNoteEditor.ts +9 -14
- package/src/editor/managers/ExtensionManager/symbol.ts +0 -1
- package/src/editor/managers/SelectionManager.ts +3 -1
- package/src/extensions/DropCursor/DropCursor.ts +262 -25
- package/src/extensions/DropCursor/utils.ts +195 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +15 -10
- package/src/i18n/locales/fa.ts +4 -21
- package/src/i18n/locales/index.ts +1 -1
- package/src/i18n/locales/ru.ts +1 -1
- package/src/i18n/locales/uz.ts +22 -4
- package/src/index.ts +1 -0
- package/src/schema/blocks/createSpec.ts +33 -45
- package/src/schema/blocks/types.ts +101 -1
- package/types/src/api/parsers/html/util/normalizeWhitespace.d.ts +6 -0
- package/types/src/blocks/getDetailsContent.d.ts +19 -0
- package/types/src/comments/threadstore/TipTapThreadStore.d.ts +1 -1
- package/types/src/comments/threadstore/tiptap/types.d.ts +73 -0
- package/types/src/editor/BlockNoteEditor.d.ts +6 -9
- package/types/src/extensions/DropCursor/DropCursor.d.ts +42 -5
- package/types/src/extensions/DropCursor/utils.d.ts +48 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/schema/blocks/createSpec.d.ts +3 -3
- package/types/src/schema/blocks/types.d.ts +31 -1
- package/dist/TrailingNode-DHOdUVUO.cjs +0 -2
- package/dist/TrailingNode-DHOdUVUO.cjs.map +0 -1
- package/dist/TrailingNode-F9hX_UlQ.js.map +0 -1
- package/dist/defaultBlocks-CSB5GiAu.cjs +0 -6
- package/dist/defaultBlocks-CSB5GiAu.cjs.map +0 -1
- package/dist/defaultBlocks-Caw1U1oV.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { EditorView } from "prosemirror-view";
|
|
2
|
+
/**
|
|
3
|
+
* The orientation of the drop cursor.
|
|
4
|
+
*/
|
|
5
|
+
export type DropCursorOrientation = "inline" | "block-horizontal" | "block-vertical-left" | "block-vertical-right";
|
|
6
|
+
/**
|
|
7
|
+
* The position and orientation of the drop cursor.
|
|
8
|
+
*/
|
|
9
|
+
export type DropCursorPosition = {
|
|
10
|
+
pos: number;
|
|
11
|
+
orientation: DropCursorOrientation;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Bounding rectangle in viewport coordinates (e.g. from getBoundingClientRect).
|
|
15
|
+
*/
|
|
16
|
+
export type Rect = {
|
|
17
|
+
left: number;
|
|
18
|
+
right: number;
|
|
19
|
+
top: number;
|
|
20
|
+
bottom: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Returns true if the element or any ancestor has the given CSS class.
|
|
24
|
+
* Used to skip drop cursor for elements marked with the exclusion class (e.g. drag handles).
|
|
25
|
+
*/
|
|
26
|
+
export declare function hasExclusionClassname(element: Element | null, exclude: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Computes the viewport rect for a block-level drop cursor (horizontal line between blocks
|
|
29
|
+
* or vertical line on left/right edge). Returns null for inline positions or when no DOM node exists.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getBlockDropRect(view: EditorView, cursorPos: DropCursorPosition, width: number, scaleX: number, scaleY: number): Rect | null;
|
|
32
|
+
/**
|
|
33
|
+
* Computes the viewport rect for an inline drop cursor (vertical line within text).
|
|
34
|
+
*/
|
|
35
|
+
export declare function getInlineDropRect(view: EditorView, cursorPos: DropCursorPosition, width: number, scaleX: number): Rect;
|
|
36
|
+
/**
|
|
37
|
+
* Applies orientation-specific CSS classes to the drop cursor element so it can be
|
|
38
|
+
* styled correctly (e.g. horizontal vs vertical line, inline vs block).
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyOrientationClasses(el: HTMLElement, orientation: DropCursorOrientation): void;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the offset of the parent element for converting viewport coordinates to
|
|
43
|
+
* parent-relative coordinates. Handles document.body and static positioning.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getParentOffsets(parent: HTMLElement | null): {
|
|
46
|
+
parentLeft: number;
|
|
47
|
+
parentTop: number;
|
|
48
|
+
};
|
package/types/src/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./editor/BlockNoteExtension.js";
|
|
|
14
14
|
export * from "./editor/defaultColors.js";
|
|
15
15
|
export * from "./editor/selectionTypes.js";
|
|
16
16
|
export * from "./exporter/index.js";
|
|
17
|
+
export * from "./extensions/index.js";
|
|
17
18
|
export * from "./extensions-shared/UiElementPosition.js";
|
|
18
19
|
export * from "./i18n/dictionary.js";
|
|
19
20
|
export * from "./schema/index.js";
|
|
@@ -3,7 +3,7 @@ import { TagParseRule } from "@tiptap/pm/model";
|
|
|
3
3
|
import { NodeView } from "@tiptap/pm/view";
|
|
4
4
|
import { Extension, ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
|
|
5
5
|
import { PropSchema } from "../propTypes.js";
|
|
6
|
-
import { BlockConfig, BlockImplementation, BlockSpec, LooseBlockSpec } from "./types.js";
|
|
6
|
+
import { BlockConfig, BlockImplementation, BlockImplementationOrCreator, BlockSpec, LooseBlockSpec } from "./types.js";
|
|
7
7
|
export declare function applyNonSelectableBlockFix(nodeView: NodeView, editor: Editor): void;
|
|
8
8
|
export declare function getParseRules<TName extends string, TProps extends PropSchema, TContent extends "inline" | "none" | "table">(config: BlockConfig<TName, TProps, TContent>, implementation: BlockImplementation<TName, TProps, TContent>): TagParseRule[];
|
|
9
9
|
export declare function addNodeAndExtensionsToSpec<TName extends string, TProps extends PropSchema, TContent extends "inline" | "none" | "table">(blockConfig: BlockConfig<TName, TProps, TContent>, blockImplementation: BlockImplementation<TName, TProps, TContent>, extensions?: (ExtensionFactoryInstance | Extension)[], priority?: number): LooseBlockSpec<TName, TProps, TContent>;
|
|
@@ -15,5 +15,5 @@ export declare function createBlockConfig<TCallback extends (options: Partial<Re
|
|
|
15
15
|
* Helper function to create a block definition.
|
|
16
16
|
* Can accept either functions that return the required objects, or the objects directly.
|
|
17
17
|
*/
|
|
18
|
-
export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const TOptions extends Partial<Record<string, any>> | undefined = undefined>(blockConfigOrCreator: BlockConfig<TName, TProps, TContent>, blockImplementationOrCreator:
|
|
19
|
-
export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const BlockConf extends BlockConfig<TName, TProps, TContent>, const TOptions extends Partial<Record<string, any>>>(blockCreator: (options: Partial<TOptions>) => BlockConf, blockImplementationOrCreator:
|
|
18
|
+
export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const TOptions extends Partial<Record<string, any>> | undefined = undefined>(blockConfigOrCreator: BlockConfig<TName, TProps, TContent>, blockImplementationOrCreator: BlockImplementationOrCreator<BlockConfig<TName, TProps, TContent>, TOptions>, extensionsOrCreator?: (ExtensionFactoryInstance | Extension)[] | (TOptions extends undefined ? () => (ExtensionFactoryInstance | Extension)[] : (options: Partial<TOptions>) => (ExtensionFactoryInstance | Extension)[])): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;
|
|
19
|
+
export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const BlockConf extends BlockConfig<TName, TProps, TContent>, const TOptions extends Partial<Record<string, any>>>(blockCreator: (options: Partial<TOptions>) => BlockConf, blockImplementationOrCreator: BlockImplementationOrCreator<BlockConf, TOptions>, extensionsOrCreator?: (ExtensionFactoryInstance | Extension)[] | (TOptions extends undefined ? () => (ExtensionFactoryInstance | Extension)[] : (options: Partial<TOptions>) => (ExtensionFactoryInstance | Extension)[])): (options?: Partial<TOptions>) => BlockSpec<BlockConf["type"], BlockConf["propSchema"], BlockConf["content"]>;
|
|
@@ -57,12 +57,30 @@ export interface BlockConfig<T extends string = string, PS extends PropSchema =
|
|
|
57
57
|
*/
|
|
58
58
|
content: C;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* BlockConfigOrCreator is a union type of BlockConfig and a function that returns a BlockConfig.
|
|
62
|
+
* This is used to create block configs that can be passed to the createBlockSpec function.
|
|
63
|
+
*/
|
|
64
|
+
export type BlockConfigOrCreator<TName extends string = string, TProps extends PropSchema = PropSchema, TContent extends "inline" | "none" = "inline" | "none", TOptions extends Record<string, any> | undefined = Record<string, any> | undefined> = BlockConfig<TName, TProps, TContent> | (TOptions extends undefined ? () => BlockConfig<TName, TProps, TContent> : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>);
|
|
65
|
+
/**
|
|
66
|
+
* ExtractBlockConfigFromConfigOrCreator is a helper type that extracts the BlockConfig type from a BlockConfigOrCreator.
|
|
67
|
+
*/
|
|
68
|
+
export type ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator extends BlockConfig<string, PropSchema, "inline" | "none"> | ((...args: any[]) => BlockConfig<string, PropSchema, "inline" | "none">)> = ConfigOrCreator extends (...args: any[]) => infer Config ? Config : ConfigOrCreator;
|
|
60
69
|
export type CustomBlockConfig<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" = "inline" | "none"> = BlockConfig<T, PS, C>;
|
|
61
70
|
export type BlockSpec<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" = "inline" | "none" | "table"> = {
|
|
62
71
|
config: BlockConfig<T, PS, C>;
|
|
63
72
|
implementation: BlockImplementation<T, PS, C>;
|
|
64
73
|
extensions?: (Extension | ExtensionFactoryInstance)[];
|
|
65
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* BlockSpecOrCreator is a union type of BlockSpec and a function that returns a BlockSpec.
|
|
77
|
+
* This is used to create block specs that can be passed to the createBlockSpec function.
|
|
78
|
+
*/
|
|
79
|
+
export type BlockSpecOrCreator<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" = "inline" | "none" | "table", TOptions extends Record<string, any> | undefined = Record<string, any> | undefined> = BlockSpec<T, PS, C> | (TOptions extends undefined ? () => BlockSpec<T, PS, C> : (options: Partial<TOptions>) => BlockSpec<T, PS, C>);
|
|
80
|
+
/**
|
|
81
|
+
* ExtractBlockSpecFromSpecOrCreator is a helper type that extracts the BlockSpec type from a BlockSpecOrCreator.
|
|
82
|
+
*/
|
|
83
|
+
export type ExtractBlockSpecFromSpecOrCreator<SpecOrCreator extends BlockSpec<string, PropSchema, "inline" | "none"> | ((...args: any[]) => BlockSpec<string, PropSchema, "inline" | "none">)> = SpecOrCreator extends (...args: any[]) => infer Spec ? Spec : SpecOrCreator;
|
|
66
84
|
/**
|
|
67
85
|
* This allows de-coupling the types that we display to users versus the types we expose internally.
|
|
68
86
|
*
|
|
@@ -91,6 +109,7 @@ export type LooseBlockSpec<T extends string = string, PS extends PropSchema = Pr
|
|
|
91
109
|
}) => {
|
|
92
110
|
dom: HTMLElement | DocumentFragment;
|
|
93
111
|
contentDOM?: HTMLElement;
|
|
112
|
+
childrenDOM?: HTMLElement;
|
|
94
113
|
} | undefined;
|
|
95
114
|
node: Node;
|
|
96
115
|
};
|
|
@@ -125,6 +144,7 @@ export type BlockSpecs = {
|
|
|
125
144
|
}) => {
|
|
126
145
|
dom: HTMLElement | DocumentFragment;
|
|
127
146
|
contentDOM?: HTMLElement;
|
|
147
|
+
childrenDOM?: HTMLElement;
|
|
128
148
|
} | undefined;
|
|
129
149
|
};
|
|
130
150
|
extensions?: BlockSpec<k>["extensions"];
|
|
@@ -265,6 +285,7 @@ export type BlockImplementation<TName extends string = string, TProps extends Pr
|
|
|
265
285
|
}) => {
|
|
266
286
|
dom: HTMLElement | DocumentFragment;
|
|
267
287
|
contentDOM?: HTMLElement;
|
|
288
|
+
childrenDOM?: HTMLElement;
|
|
268
289
|
} | undefined;
|
|
269
290
|
/**
|
|
270
291
|
* Parses an external HTML element into a block of this type when it returns the block props object, otherwise undefined
|
|
@@ -282,7 +303,16 @@ export type BlockImplementation<TName extends string = string, TProps extends Pr
|
|
|
282
303
|
parseContent?: (options: {
|
|
283
304
|
el: HTMLElement;
|
|
284
305
|
schema: Schema;
|
|
285
|
-
}) => Fragment;
|
|
306
|
+
}) => Fragment | undefined;
|
|
286
307
|
};
|
|
308
|
+
/**
|
|
309
|
+
* BlockImplementationOrCreator is a union type of BlockImplementation and a function that returns a BlockImplementation.
|
|
310
|
+
* This is used to create block implementations that can be passed to the createBlockSpec function.
|
|
311
|
+
*/
|
|
312
|
+
export type BlockImplementationOrCreator<ConfigOrCreator extends BlockConfigOrCreator = BlockConfigOrCreator, TOptions extends Record<string, any> | undefined = Record<string, any> | undefined, Config extends ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator> = ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator>> = BlockImplementation<Config["type"], Config["propSchema"], Config["content"]> | (TOptions extends undefined ? () => BlockImplementation<Config["type"], Config["propSchema"], Config["content"]> : (options: Partial<TOptions>) => BlockImplementation<Config["type"], Config["propSchema"], Config["content"]>);
|
|
313
|
+
/**
|
|
314
|
+
* ExtractBlockImplementationFromImplementationOrCreator is a helper type that extracts the BlockImplementation type from a BlockImplementationOrCreator.
|
|
315
|
+
*/
|
|
316
|
+
export type ExtractBlockImplementationFromImplementationOrCreator<ImplementationOrCreator extends BlockImplementation<string, PropSchema, "inline" | "none"> | ((...args: any[]) => BlockImplementation<string, PropSchema, "inline" | "none">)> = ImplementationOrCreator extends (...args: any[]) => infer Implementation ? Implementation : ImplementationOrCreator;
|
|
287
317
|
export type CustomBlockImplementation<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" = "inline" | "none"> = BlockImplementation<T, PS, C>;
|
|
288
318
|
export {};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var we=Object.defineProperty;var be=(n,e,o)=>e in n?we(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o;var b=(n,e,o)=>be(n,typeof e!="symbol"?e+"":e,o);const C=require("prosemirror-state"),R=require("@tiptap/core"),ke=require("fast-deep-equal"),k=require("./blockToNode-CumVjgem.cjs"),O=require("./defaultBlocks-CSB5GiAu.cjs"),v=require("./BlockNoteExtension-BWw0r8Gy.cjs"),M=require("y-prosemirror"),Ce=require("yjs"),V=require("@tiptap/pm/state"),ve=require("prosemirror-dropcursor"),q=require("@tiptap/pm/history"),D=require("prosemirror-view"),Se=require("uuid"),Z=require("@tiptap/pm/model"),H=require("prosemirror-model"),xe=require("rehype-parse"),Ee=require("rehype-remark"),Ie=require("remark-gfm"),Te=require("remark-stringify"),Pe=require("unified"),Be=require("hast-util-from-dom"),De=require("unist-util-visit"),P=require("prosemirror-tables"),F=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function Oe(n){if(n&&typeof n=="object"&&"default"in n)return n;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const t=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(e,o,t.get?t:{enumerable:!0,get:()=>n[o]})}}return e.default=n,Object.freeze(e)}const Me=F(ke),B=Oe(Ce),Ae=F(xe),Ne=F(Ee),Le=F(Ie),Re=F(Te);function ae(n){const e=Array.from(n.classList).filter(o=>!o.startsWith("bn-"))||[];e.length>0?n.className=e.join(" "):n.removeAttribute("class")}function le(n,e,o,t){var a;let r;if(e)if(typeof e=="string")r=k.inlineContentToNodes([e],n.pmSchema);else if(Array.isArray(e))r=k.inlineContentToNodes(e,n.pmSchema);else if(e.type==="tableContent")r=k.tableContentToNodes(e,n.pmSchema);else throw new k.UnreachableCaseError(e.type);else throw new Error("blockContent is required");const i=((t==null?void 0:t.document)??document).createDocumentFragment();for(const c of r)if(c.type.name!=="text"&&n.schema.inlineContentSchema[c.type.name]){const l=n.schema.inlineContentSpecs[c.type.name].implementation;if(l){const u=k.nodeToCustomInlineContent(c,n.schema.inlineContentSchema,n.schema.styleSchema),h=l.toExternalHTML?l.toExternalHTML(u,n):l.render.call({renderType:"dom",props:void 0},u,()=>{},n);if(h){if(i.appendChild(h.dom),h.contentDOM){const g=o.serializeFragment(c.content,t);h.contentDOM.dataset.editable="",h.contentDOM.appendChild(g)}continue}}}else if(c.type.name==="text"){let l=document.createTextNode(c.textContent);for(const u of c.marks.toReversed())if(u.type.name in n.schema.styleSpecs){const h=(n.schema.styleSpecs[u.type.name].implementation.toExternalHTML??n.schema.styleSpecs[u.type.name].implementation.render)(u.attrs.stringValue,n);h.contentDOM.appendChild(l),l=h.dom}else{const h=u.type.spec.toDOM(u,!0),g=H.DOMSerializer.renderSpec(document,h);g.contentDOM.appendChild(l),l=g.dom}i.appendChild(l)}else{const l=o.serializeFragment(H.Fragment.from([c]),t);i.appendChild(l)}return i.childNodes.length===1&&((a=i.firstChild)==null?void 0:a.nodeType)===1&&ae(i.firstChild),i}function Ve(n,e,o,t,r,s,i,a){var y,w,x,L,X,W,G,J,Q;const c=(a==null?void 0:a.document)??document,l=e.pmSchema.nodes.blockContainer,u=o.props||{};for(const[S,I]of Object.entries(e.schema.blockSchema[o.type].propSchema))!(S in u)&&I.default!==void 0&&(u[S]=I.default);const h=(w=(y=l.spec)==null?void 0:y.toDOM)==null?void 0:w.call(y,l.create({id:o.id,...u})),g=Array.from(h.dom.attributes),m=e.blockImplementations[o.type].implementation,p=((x=m.toExternalHTML)==null?void 0:x.call({},{...o,props:u},e,{nestingLevel:i}))||m.render.call({},{...o,props:u},e),d=c.createDocumentFragment();if(p.dom.classList.contains("bn-block-content")){const S=[...g,...Array.from(p.dom.attributes)].filter(I=>I.name.startsWith("data")&&I.name!=="data-content-type"&&I.name!=="data-file-block"&&I.name!=="data-node-view-wrapper"&&I.name!=="data-node-type"&&I.name!=="data-id"&&I.name!=="data-editable");for(const I of S)p.dom.firstChild.setAttribute(I.name,I.value);ae(p.dom.firstChild),i>0&&p.dom.firstChild.setAttribute("data-nesting-level",i.toString()),d.append(...Array.from(p.dom.childNodes))}else d.append(p.dom),i>0&&p.dom.setAttribute("data-nesting-level",i.toString());if(p.contentDOM&&o.content){const S=le(e,o.content,t,a);p.contentDOM.appendChild(S)}let f;if(r.has(o.type)?f="OL":s.has(o.type)&&(f="UL"),f){if(((L=n.lastChild)==null?void 0:L.nodeName)!==f){const S=c.createElement(f);f==="OL"&&"start"in u&&u.start&&(u==null?void 0:u.start)!==1&&S.setAttribute("start",u.start+""),n.append(S)}n.lastChild.appendChild(d)}else n.append(d);if(o.children&&o.children.length>0){const S=c.createDocumentFragment();if(ce(S,e,o.children,t,r,s,i+1,a),((X=n.lastChild)==null?void 0:X.nodeName)==="UL"||((W=n.lastChild)==null?void 0:W.nodeName)==="OL")for(;((G=S.firstChild)==null?void 0:G.nodeName)==="UL"||((J=S.firstChild)==null?void 0:J.nodeName)==="OL";)n.lastChild.lastChild.appendChild(S.firstChild);e.pmSchema.nodes[o.type].isInGroup("blockContent")?n.append(S):(Q=p.contentDOM)==null||Q.append(S)}}const ce=(n,e,o,t,r,s,i=0,a)=>{for(const c of o)Ve(n,e,c,t,r,s,i,a)},He=(n,e,o,t,r,s)=>{const a=((s==null?void 0:s.document)??document).createDocumentFragment();return ce(a,n,e,o,t,r,0,s),a},Y=(n,e)=>{const o=H.DOMSerializer.fromSchema(n);return{exportBlocks:(t,r)=>{const s=He(e,t,o,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem","toggleListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(t,r)=>{const s=le(e,t,o,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function Fe(n,e){if(e===0)return;const o=n.resolve(e);for(let t=o.depth;t>0;t--){const r=o.node(t);if(O.isNodeBlock(r))return r.attrs.id}}function _e(n){return n.getMeta("paste")?{type:"paste"}:n.getMeta("uiEvent")==="drop"?{type:"drop"}:n.getMeta("history$")?{type:n.getMeta("history$").redo?"redo":"undo"}:n.getMeta("y-sync$")?n.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"}:{type:"local"}}function ee(n){const e="__root__",o={},t={},r=k.getPmSchema(n);return n.descendants((s,i)=>{if(!O.isNodeBlock(s))return!0;const a=Fe(n,i),c=a??e;t[c]||(t[c]=[]);const l=k.nodeToBlock(s,r);return o[s.attrs.id]={block:l,parentId:a},t[c].push(s.attrs.id),!0}),{byId:o,childrenByParent:t}}function Ue(n,e){const o=new Set;if(!n||!e)return o;const t=new Set(n),r=e.filter(d=>t.has(d)),s=n.filter(d=>r.includes(d));if(s.length<=1||r.length<=1)return o;const i={};for(let d=0;d<s.length;d++)i[s[d]]=d;const a=r.map(d=>i[d]),c=a.length,l=[],u=[],h=new Array(c).fill(-1),g=(d,f)=>{let y=0,w=d.length;for(;y<w;){const x=y+w>>>1;d[x]<f?y=x+1:w=x}return y};for(let d=0;d<c;d++){const f=a[d],y=g(l,f);y>0&&(h[d]=u[y-1]),y===l.length?(l.push(f),u.push(d)):(l[y]=f,u[y]=d)}const m=new Set;let p=u[u.length-1]??-1;for(;p!==-1;)m.add(p),p=h[p];for(let d=0;d<r.length;d++)m.has(d)||o.add(r[d]);return o}function de(n,e=[]){const o=_e(n),t=R.combineTransactionSteps(n.before,[n,...e]),r=ee(t.before),s=ee(t.doc),i=[],a=new Set;Object.keys(s.byId).filter(m=>!(m in r.byId)).forEach(m=>{i.push({type:"insert",block:s.byId[m].block,source:o,prevBlock:void 0}),a.add(m)}),Object.keys(r.byId).filter(m=>!(m in s.byId)).forEach(m=>{i.push({type:"delete",block:r.byId[m].block,source:o,prevBlock:void 0}),a.add(m)}),Object.keys(s.byId).filter(m=>m in r.byId).forEach(m=>{var y,w;const p=r.byId[m],d=s.byId[m];p.parentId!==d.parentId?(i.push({type:"move",block:d.block,prevBlock:p.block,source:o,prevParent:p.parentId?(y=r.byId[p.parentId])==null?void 0:y.block:void 0,currentParent:d.parentId?(w=s.byId[d.parentId])==null?void 0:w.block:void 0}),a.add(m)):Me.default({...p.block,children:void 0},{...d.block,children:void 0})||(i.push({type:"update",block:d.block,prevBlock:p.block,source:o}),a.add(m))});const c=r.childrenByParent,l=s.childrenByParent,u="__root__",h=new Set([...Object.keys(c),...Object.keys(l)]),g=new Set;return h.forEach(m=>{const p=Ue(c[m],l[m]);p.size!==0&&p.forEach(d=>{var x,L;const f=r.byId[d],y=s.byId[d];!f||!y||f.parentId!==y.parentId||a.has(d)||(f.parentId??u)!==m||g.has(d)||(g.add(d),i.push({type:"move",block:y.block,prevBlock:f.block,source:o,prevParent:f.parentId?(x=r.byId[f.parentId])==null?void 0:x.block:void 0,currentParent:y.parentId?(L=s.byId[y.parentId])==null?void 0:L.block:void 0}),a.add(d))})}),i}const $e=v.createExtension(()=>{const n=[];return{key:"blockChange",prosemirrorPlugins:[new C.Plugin({key:new C.PluginKey("blockChange"),filterTransaction:e=>{let o;return n.reduce((t,r)=>t===!1?t:r({getChanges(){return o||(o=de(e),o)},tr:e})!==!1,!0)}})],subscribe(e){return n.push(e),()=>{n.splice(n.indexOf(e),1)}}}});function te(n){const e=n.charAt(0)==="#"?n.substring(1,7):n,o=parseInt(e.substring(0,2),16),t=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16),i=[o/255,t/255,r/255].map(c=>c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4));return .2126*i[0]+.7152*i[1]+.0722*i[2]<=.179}function qe(n){const e=document.createElement("span");e.classList.add("bn-collaboration-cursor__base");const o=document.createElement("span");o.setAttribute("contentedEditable","false"),o.classList.add("bn-collaboration-cursor__caret"),o.setAttribute("style",`background-color: ${n.color}; color: ${te(n.color)?"white":"black"}`);const t=document.createElement("span");return t.classList.add("bn-collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}; color: ${te(n.color)?"white":"black"}`),t.insertBefore(document.createTextNode(n.name),null),o.insertBefore(t,null),e.insertBefore(document.createTextNode(""),null),e.insertBefore(o,null),e.insertBefore(document.createTextNode(""),null),e}const z=v.createExtension(({options:n})=>{const e=new Map,o=n.provider&&"awareness"in n.provider&&typeof n.provider.awareness=="object"?n.provider.awareness:void 0;return o&&("setLocalStateField"in o&&typeof o.setLocalStateField=="function"&&o.setLocalStateField("user",n.user),"on"in o&&typeof o.on=="function"&&n.showCursorLabels!=="always"&&o.on("change",({updated:t})=>{for(const r of t){const s=e.get(r);s&&(setTimeout(()=>{s.element.setAttribute("data-active","")},10),s.hideTimeout&&clearTimeout(s.hideTimeout),e.set(r,{element:s.element,hideTimeout:setTimeout(()=>{s.element.removeAttribute("data-active")},2e3)}))}})),{key:"yCursor",prosemirrorPlugins:[o?M.yCursorPlugin(o,{selectionBuilder:M.defaultSelectionBuilder,cursorBuilder(t,r){let s=e.get(r);if(!s){const i=(n.renderCursor??qe)(t);n.showCursorLabels!=="always"&&(i.addEventListener("mouseenter",()=>{const a=e.get(r);a.element.setAttribute("data-active",""),a.hideTimeout&&(clearTimeout(a.hideTimeout),e.set(r,{element:a.element,hideTimeout:void 0}))}),i.addEventListener("mouseleave",()=>{const a=e.get(r);e.set(r,{element:a.element,hideTimeout:setTimeout(()=>{a.element.removeAttribute("data-active")},2e3)})})),s={element:i,hideTimeout:void 0},e.set(r,s)}return s.element}}):void 0].filter(Boolean),dependsOn:["ySync"],updateUser(t){o==null||o.setLocalStateField("user",t)}}}),U=v.createExtension(({options:n})=>({key:"ySync",prosemirrorPlugins:[M.ySyncPlugin(n.fragment)],runsBefore:["default"]})),$=v.createExtension(()=>({key:"yUndo",prosemirrorPlugins:[M.yUndoPlugin()],dependsOn:["yCursor","ySync"],undoCommand:M.undoCommand,redoCommand:M.redoCommand}));function ze(n,e){const o=n.doc;if(n._item===null){const t=Array.from(o.share.keys()).find(r=>o.share.get(r)===n);if(t==null)throw new Error("type does not exist in other ydoc");return e.get(t,n.constructor)}else{const t=n._item,r=e.store.clients.get(t.id.client)??[],s=B.findIndexSS(r,t.id.clock);return r[s].content.type}}const Ke=v.createExtension(({editor:n,options:e})=>{let o;const t=v.createStore({isForked:!1});return{key:"yForkDoc",store:t,fork(){if(o)return;const r=e.fragment;if(!r)throw new Error("No fragment to fork from");const s=new B.Doc;B.applyUpdate(s,B.encodeStateAsUpdate(r.doc));const i=ze(r,s);o={undoStack:M.yUndoPluginKey.getState(n.prosemirrorState).undoManager.undoStack,originalFragment:r,forkedFragment:i},n.unregisterExtension([$,z,U]);const a={...e,fragment:i};n.registerExtension([U(a),$()]),t.setState({isForked:!0})},merge({keepChanges:r}){if(!o)return;n.unregisterExtension(["ySync","yCursor","yUndo"]);const{originalFragment:s,forkedFragment:i,undoStack:a}=o;if(n.registerExtension([U(e),z(e),$()]),M.yUndoPluginKey.getState(n.prosemirrorState).undoManager.undoStack=a,r){const c=B.encodeStateAsUpdate(i.doc,B.encodeStateVector(s.doc));B.applyUpdate(s.doc,c,n)}o=void 0,t.setState({isForked:!1})}}}),ue=(n,e)=>{e(n),n.forEach(o=>{o instanceof B.XmlElement&&ue(o,e)})},Ye=(n,e)=>{const o=new Map;return n.forEach(t=>{t instanceof B.XmlElement&&ue(t,r=>{if(r.nodeName==="blockContainer"&&r.hasAttribute("id")){const s=r.getAttribute("textColor"),i=r.getAttribute("backgroundColor"),a={textColor:s===O.defaultProps.textColor.default?void 0:s,backgroundColor:i===O.defaultProps.backgroundColor.default?void 0:i};(a.textColor||a.backgroundColor)&&o.set(r.getAttribute("id"),a)}})}),o.size===0?!1:(e.doc.descendants((t,r)=>{if(t.type.name==="blockContainer"&&o.has(t.attrs.id)){const s=e.doc.nodeAt(r+1);if(!s)throw new Error("No element found");e.setNodeMarkup(r+1,void 0,{...s.attrs,...o.get(t.attrs.id)})}}),!0)},je=[Ye],Xe=v.createExtension(({options:n})=>{let e=!1;const o=new V.PluginKey("schemaMigration");return{key:"schemaMigration",prosemirrorPlugins:[new V.Plugin({key:o,appendTransaction:(t,r,s)=>{if(e||!t.some(a=>a.getMeta("y-sync$"))||t.every(a=>!a.docChanged)||!n.fragment.firstChild)return;const i=s.tr;for(const a of je)a(n.fragment,i);if(e=!0,!!i.docChanged)return i}})]}}),We=v.createExtension(({editor:n,options:e})=>({key:"dropCursor",prosemirrorPlugins:[(e.dropCursor??ve.dropCursor)({width:5,color:"#ddeeff",editor:n})]})),Ge=v.createExtension(({editor:n})=>{const e=v.createStore(!1),o=()=>n.transact(t=>{var s;if(t.selection.empty||t.selection instanceof C.NodeSelection&&(t.selection.node.type.spec.content==="inline*"||((s=t.selection.node.firstChild)==null?void 0:s.type.spec.content)==="inline*")||t.selection instanceof C.TextSelection&&t.doc.textBetween(t.selection.from,t.selection.to).length===0)return!1;let r=!1;return t.selection.content().content.descendants(i=>(i.type.spec.code&&(r=!0),!r)),!r});return{key:"formattingToolbar",store:e,mount({dom:t,signal:r}){let s=!1;const i=n.onChange(()=>{s||e.setState(o())}),a=n.onSelectionChange(()=>{s||e.setState(o())});t.addEventListener("pointerdown",()=>{s=!0,e.setState(!1)},{signal:r}),n.prosemirrorView.root.addEventListener("pointerup",()=>{s=!1,n.isFocused()&&e.setState(o())},{signal:r,capture:!0}),t.addEventListener("pointercancel",()=>{s=!1},{signal:r,capture:!0}),r.addEventListener("abort",()=>{i(),a()})}}}),Je=v.createExtension(()=>({key:"history",prosemirrorPlugins:[q.history()],undoCommand:q.undo,redoCommand:q.redo})),Qe=v.createExtension(({editor:n})=>{function e(r){let s=n.prosemirrorView.nodeDOM(r);for(;s&&s.parentElement;){if(s.nodeName==="A")return s;s=s.parentElement}return null}function o(r,s){return n.transact(i=>{const a=i.doc.resolve(r),c=a.marks().find(u=>u.type.name===s);if(!c)return;const l=R.getMarkRange(a,c.type);if(l)return{range:l,mark:c,get text(){return i.doc.textBetween(l.from,l.to)},get position(){return R.posToDOMRect(n.prosemirrorView,l.from,l.to).toJSON()}}})}function t(){return n.transact(r=>{const s=r.selection;if(s.empty)return o(s.anchor,"link")})}return{key:"linkToolbar",getLinkAtSelection:t,getLinkElementAtPos:e,getMarkAtPos:o,getLinkAtElement(r){return n.transact(()=>{const s=n.prosemirrorView.posAtDOM(r,0)+1;return o(s,"link")})},editLink(r,s,i=n.transact(a=>a.selection.anchor)){n.transact(a=>{const c=k.getPmSchema(a),{range:l}=o(i+1,"link")||{range:{from:a.selection.from,to:a.selection.to}};l&&(a.insertText(s,l.from,l.to),a.addMark(l.from,l.from+s.length,c.mark("link",{href:r})))}),n.prosemirrorView.focus()},deleteLink(r=n.transact(s=>s.selection.anchor)){n.transact(s=>{const i=k.getPmSchema(s),{range:a}=o(r+1,"link")||{range:{from:s.selection.from,to:s.selection.to}};a&&s.removeMark(a.from,a.to,i.marks.link).setMeta("preventAutolink",!0)}),n.prosemirrorView.focus()}}}),Ze=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],et="https",tt=new C.PluginKey("node-selection-keyboard"),ot=v.createExtension(()=>({key:"nodeSelectionKeyboard",prosemirrorPlugins:[new C.Plugin({key:tt,props:{handleKeyDown:(n,e)=>{if("node"in n.state.selection){if(e.ctrlKey||e.metaKey)return!1;if(e.key.length===1)return e.preventDefault(),!0;if(e.key==="Enter"&&!e.isComposing&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const o=n.state.tr;return n.dispatch(o.insert(n.state.tr.selection.$to.after(),n.state.schema.nodes.paragraph.createChecked()).setSelection(new C.TextSelection(o.doc.resolve(n.state.tr.selection.$to.after()+1)))),!0}}return!1}}})]})),nt=new C.PluginKey("blocknote-placeholder"),rt=v.createExtension(({editor:n,options:e})=>{const o=e.placeholders;return{key:"placeholder",prosemirrorPlugins:[new C.Plugin({key:nt,view:t=>{const r=`placeholder-selector-${Se.v4()}`;t.dom.classList.add(r);const s=document.createElement("style"),i=n._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),t.root instanceof window.ShadowRoot?t.root.append(s):t.root.head.appendChild(s);const a=s.sheet,c=(l="")=>`.${r} .bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:l,emptyDocument:u,...h}=o||{};for(const[p,d]of Object.entries(h)){const f=`[data-content-type="${p}"]`;a.insertRule(`${c(f)} { content: ${JSON.stringify(d)}; }`)}const g="[data-is-only-empty-block]",m="[data-is-empty-and-focused]";a.insertRule(`${c(g)} { content: ${JSON.stringify(u)}; }`),a.insertRule(`${c(m)} { content: ${JSON.stringify(l)}; }`)}catch(l){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",l)}return{destroy:()=>{t.root instanceof window.ShadowRoot?t.root.removeChild(s):t.root.head.removeChild(s)}}},props:{decorations:t=>{const{doc:r,selection:s}=t;if(!n.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];t.doc.content.size===6&&i.push(D.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const a=s.$anchor,c=a.parent;if(c.content.size===0){const l=a.before();i.push(D.Decoration.node(l,l+c.nodeSize,{"data-is-empty-and-focused":"true"}))}return D.DecorationSet.create(r,i)}}})]}}),oe=new C.PluginKey("previous-blocks"),st={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},it=v.createExtension(()=>{let n;return{key:"previousBlockType",prosemirrorPlugins:[new C.Plugin({key:oe,view(e){return{update:async(o,t)=>{var r;((r=this.key)==null?void 0:r.getState(o.state).updatedBlocks.size)>0&&(n=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(oe,{clearUpdate:!0}))},0))},destroy:()=>{n&&clearTimeout(n)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(e,o,t,r){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!e.docChanged||t.doc.eq(r.doc))return o;const s={},i=R.findChildren(t.doc,l=>l.attrs.id),a=new Map(i.map(l=>[l.node.attrs.id,l])),c=R.findChildren(r.doc,l=>l.attrs.id);for(const l of c){const u=a.get(l.node.attrs.id),h=u==null?void 0:u.node.firstChild,g=l.node.firstChild;if(u&&h&&g){const m={index:g.attrs.index,level:g.attrs.level,type:g.type.name,depth:r.doc.resolve(l.pos).depth},p={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:t.doc.resolve(u.pos).depth};s[l.node.attrs.id]=p,o.currentTransactionOldBlockAttrs[l.node.attrs.id]=p,JSON.stringify(p)!==JSON.stringify(m)&&(p["depth-change"]=p.depth-m.depth,o.updatedBlocks.add(l.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=s,o}},props:{decorations(e){const o=this.getState(e);if(o.updatedBlocks.size===0)return;const t=[];return e.doc.descendants((r,s)=>{if(!r.attrs.id||!o.updatedBlocks.has(r.attrs.id))return;const i=o.currentTransactionOldBlockAttrs[r.attrs.id],a={};for(const[l,u]of Object.entries(i))a["data-prev-"+st[l]]=u||"none";const c=D.Decoration.node(s,s+r.nodeSize,{...a});t.push(c)}),D.DecorationSet.create(e.doc,t)}}})]}});function he(n,e){var o,t;for(;n&&n.parentElement&&n.parentElement!==e.dom&&((o=n.getAttribute)==null?void 0:o.call(n,"data-node-type"))!=="blockContainer";)n=n.parentElement;if(((t=n.getAttribute)==null?void 0:t.call(n,"data-node-type"))==="blockContainer")return{node:n,id:n.getAttribute("data-id")}}function at(){const n=e=>{let o=e.children.length;for(let t=0;t<o;t++){const r=e.children[t];if(r.type==="element"&&(n(r),r.tagName==="u"))if(r.children.length>0){e.children.splice(t,1,...r.children);const s=r.children.length-1;o+=s,t+=s}else e.children.splice(t,1),o--,t--}};return n}function lt(){const n=e=>{var o;if(e.children&&"length"in e.children&&e.children.length)for(let t=e.children.length-1;t>=0;t--){const r=e.children[t],s=t+1<e.children.length?e.children[t+1]:void 0;r.type==="element"&&r.tagName==="input"&&((o=r.properties)==null?void 0:o.type)==="checkbox"&&(s==null?void 0:s.type)==="element"&&s.tagName==="p"?(s.tagName="span",s.children.splice(0,0,Be.fromDom(document.createTextNode(" ")))):n(r)}};return n}function ct(){return n=>{De.visit(n,"element",(e,o,t)=>{var r,s,i,a;if(t&&e.tagName==="video"){const c=((r=e.properties)==null?void 0:r.src)||((s=e.properties)==null?void 0:s["data-url"])||"",l=((i=e.properties)==null?void 0:i.title)||((a=e.properties)==null?void 0:a["data-name"])||"";t.children[o]={type:"text",value:``}}})}}function j(n){return Pe.unified().use(Ae.default,{fragment:!0}).use(ct).use(at).use(lt).use(Ne.default).use(Le.default).use(Re.default,{handlers:{text:o=>o.value}}).processSync(n).value}function dt(n,e,o,t){const s=Y(e,o).exportBlocks(n,t);return j(s)}function me(n){const e=[];return n.descendants(o=>{var r,s;const t=k.getPmSchema(o);return o.type.name==="blockContainer"&&((r=o.firstChild)==null?void 0:r.type.name)==="blockGroup"?!0:o.type.name==="columnList"&&o.childCount===1?((s=o.firstChild)==null||s.forEach(i=>{e.push(k.nodeToBlock(i,t))}),!1):o.type.isInGroup("bnBlock")?(e.push(k.nodeToBlock(o,t)),!1):!0}),e}class A extends C.Selection{constructor(o,t){super(o,t);b(this,"nodes");const r=o.node();this.nodes=[],o.doc.nodesBetween(o.pos,t.pos,(s,i,a)=>{if(a!==null&&a.eq(r))return this.nodes.push(s),!1})}static create(o,t,r=t){return new A(o.resolve(t),o.resolve(r))}content(){return new H.Slice(H.Fragment.from(this.nodes),0,0)}eq(o){if(!(o instanceof A)||this.nodes.length!==o.nodes.length||this.from!==o.from||this.to!==o.to)return!1;for(let t=0;t<this.nodes.length;t++)if(!this.nodes[t].eq(o.nodes[t]))return!1;return!0}map(o,t){const r=t.mapResult(this.from),s=t.mapResult(this.to);return s.deleted?C.Selection.near(o.resolve(r.pos)):r.deleted?C.Selection.near(o.resolve(s.pos)):new A(o.resolve(r.pos),o.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}C.Selection.jsonID("multiple-node",A);let T;function ut(n,e){let o,t;const r=e.resolve(n.from).node().type.spec.group==="blockContent",s=e.resolve(n.to).node().type.spec.group==="blockContent",i=Math.min(n.$anchor.depth,n.$head.depth);if(r&&s){const a=n.$from.start(i-1),c=n.$to.end(i-1);o=e.resolve(a-1).pos,t=e.resolve(c+1).pos}else o=n.from,t=n.to;return{from:o,to:t}}function ne(n,e,o=e){e===o&&(o+=n.state.doc.resolve(e+1).node().nodeSize);const t=n.domAtPos(e).node.cloneNode(!0),r=n.domAtPos(e).node,s=(h,g)=>Array.prototype.indexOf.call(h.children,g),i=s(r,n.domAtPos(e+1).node.parentElement),a=s(r,n.domAtPos(o-1).node.parentElement);for(let h=r.childElementCount-1;h>=0;h--)(h>a||h<i)&&t.removeChild(t.children[h]);pe(n.root),T=t;const c=T.getElementsByTagName("iframe");for(let h=0;h<c.length;h++){const g=c[h],m=g.parentElement;m&&m.removeChild(g)}const u=n.dom.className.split(" ").filter(h=>h!=="ProseMirror"&&h!=="bn-root"&&h!=="bn-editor").join(" ");T.className=T.className+" bn-drag-preview "+u,n.root instanceof ShadowRoot?n.root.appendChild(T):n.root.body.appendChild(T)}function pe(n){T!==void 0&&(n instanceof ShadowRoot?n.removeChild(T):n.body.removeChild(T),T=void 0)}function ht(n,e,o){if(!n.dataTransfer||o.headless)return;const t=o.prosemirrorView,r=O.getNodeById(e.id,t.state.doc);if(!r)throw new Error(`Block with ID ${e.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=t.state.selection,a=t.state.doc,{from:c,to:l}=ut(i,a),u=c<=s&&s<l,h=i.$anchor.node()!==i.$head.node()||i instanceof A;u&&h?(t.dispatch(t.state.tr.setSelection(A.create(a,c,l))),ne(t,c,l)):(t.dispatch(t.state.tr.setSelection(C.NodeSelection.create(t.state.doc,s))),ne(t,s));const g=t.state.selection.content(),m=o.pmSchema,p=t.serializeForClipboard(g).dom.innerHTML,d=Y(m,o),f=me(g.content),y=d.exportBlocks(f,{}),w=j(y);n.dataTransfer.clearData(),n.dataTransfer.setData("blocknote/html",p),n.dataTransfer.setData("text/html",y),n.dataTransfer.setData("text/plain",w),n.dataTransfer.effectAllowed="move",n.dataTransfer.setDragImage(T,0,0)}}const re=250;function K(n,e,o=!0){const t=n.root.elementsFromPoint(e.left,e.top);for(const r of t)if(n.dom.contains(r))return o&&r.closest("[data-node-type=columnList]")?K(n,{left:e.left+50,top:e.top},!1):he(r,n)}function mt(n,e){if(!e.dom.firstChild)return;const o=e.dom.firstChild.getBoundingClientRect(),t={left:Math.min(Math.max(o.left+10,n.x),o.right-10),top:n.y},r=K(e,t);if(!r)return;const s=r.node.getBoundingClientRect();return K(e,{left:s.right-10,top:n.y},!1)}class fe{constructor(e,o,t){b(this,"state");b(this,"emitUpdate");b(this,"mousePos");b(this,"hoveredBlock");b(this,"menuFrozen",!1);b(this,"isDragOrigin",!1);b(this,"updateState",e=>{this.state=e,this.emitUpdate(this.state)});b(this,"updateStateFromMousePos",()=>{var t,r,s,i,a;if(this.menuFrozen||!this.mousePos)return;const e=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if((e==null?void 0:e.element)!==this.pmView.dom||e.distance>re){(t=this.state)!=null&&t.show&&(this.state.show=!1,this.updateState(this.state));return}const o=mt(this.mousePos,this.pmView);if(!o||!this.editor.isEditable){(r=this.state)!=null&&r.show&&(this.state.show=!1,this.updateState(this.state));return}if(!((s=this.state)!=null&&s.show&&((i=this.hoveredBlock)!=null&&i.hasAttribute("data-id"))&&((a=this.hoveredBlock)==null?void 0:a.getAttribute("data-id"))===o.id)&&(this.hoveredBlock=o.node,this.editor.isEditable)){const c=o.node.getBoundingClientRect(),l=o.node.closest("[data-node-type=column]");this.state={show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,c.y,c.width,c.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateState(this.state)}});b(this,"onDragStart",e=>{var i;const o=(i=e.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!o||this.pmView.dragging)return;const t=document.createElement("div");t.innerHTML=o;const s=Z.DOMParser.fromSchema(this.pmView.state.schema).parse(t,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new Z.Slice(s.content,0,0),move:!0}});b(this,"findClosestEditorElement",e=>{const o=Array.from(this.pmView.root.querySelectorAll(".bn-editor"));if(o.length===0)return null;let t=o[0],r=Number.MAX_VALUE;return o.forEach(s=>{const i=s.querySelector(".bn-block-group").getBoundingClientRect(),a=e.clientX<i.left?i.left-e.clientX:e.clientX>i.right?e.clientX-i.right:0,c=e.clientY<i.top?i.top-e.clientY:e.clientY>i.bottom?e.clientY-i.bottom:0,l=Math.sqrt(Math.pow(a,2)+Math.pow(c,2));l<r&&(r=l,t=s)}),{element:t,distance:r}});b(this,"onDragOver",e=>{var r;if(e.synthetic||!(this.pmView.dragging!==null||this.isDragOrigin||((r=e.dataTransfer)==null?void 0:r.types.includes("blocknote/html"))||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;const t=this.getDragEventContext(e);if(!t||!t.isDropPoint){this.closeDropCursor();return}t.isDropPoint&&!t.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(e)});b(this,"closeDropCursor",()=>{const e=new Event("dragleave",{bubbles:!1});e.synthetic=!0,this.pmView.dom.dispatchEvent(e)});b(this,"getDragEventContext",e=>{var l,u;if(!(this.pmView.dragging!==null||this.isDragOrigin||((l=e.dataTransfer)==null?void 0:l.types.includes("blocknote/html"))||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;const t=!((u=e.dataTransfer)!=null&&u.types.includes("blocknote/html"))&&!!this.pmView.dragging,r=!!this.isDragOrigin,s=t||r,i=this.findClosestEditorElement(e);if(!i||i.distance>re)return;const a=i.element===this.pmView.dom,c=a&&i.distance===0;if(!(!a&&!s))return{isDropPoint:a,isDropWithinEditorBounds:c,isDragOrigin:s}});b(this,"onDrop",e=>{var a;if(e.synthetic||!(this.pmView.dragging!==null||this.isDragOrigin||((a=e.dataTransfer)==null?void 0:a.types.includes("blocknote/html"))||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;const t=this.getDragEventContext(e);if(!t){this.closeDropCursor();return}const{isDropPoint:r,isDropWithinEditorBounds:s,isDragOrigin:i}=t;if(!s&&r&&this.dispatchSyntheticEvent(e),r){if(this.pmView.dragging)return;this.pmView.dispatch(this.pmView.state.tr.setSelection(V.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)));return}else if(i){setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0);return}});b(this,"onDragEnd",e=>{e.synthetic||(this.pmView.dragging=null)});b(this,"onKeyDown",e=>{var o;(o=this.state)!=null&&o.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});b(this,"onMouseMove",e=>{var s;if(this.menuFrozen)return;this.mousePos={x:e.clientX,y:e.clientY};const o=this.pmView.dom.getBoundingClientRect(),t=this.mousePos.x>o.left&&this.mousePos.x<o.right&&this.mousePos.y>o.top&&this.mousePos.y<o.bottom,r=this.pmView.dom.parentElement;if(t&&e&&e.target&&!(r===e.target||r.contains(e.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});this.editor=e,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");t(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0)}dispatchSyntheticEvent(e){const o=new Event(e.type,e),t=this.pmView.dom.firstChild.getBoundingClientRect();o.clientX=e.clientX,o.clientY=e.clientY,o.clientX=Math.min(Math.max(e.clientX,t.left),t.left+t.width),o.clientY=Math.min(Math.max(e.clientY,t.top),t.top+t.height),o.dataTransfer=e.dataTransfer,o.preventDefault=()=>e.preventDefault(),o.synthetic=!0,this.pmView.dom.dispatchEvent(o)}update(e,o){var r;!o.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var e;(e=this.state)!=null&&e.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0)}}const ge=new V.PluginKey("SideMenuPlugin"),pt=v.createExtension(({editor:n})=>{let e;const o=v.createStore(void 0);return{key:"sideMenu",store:o,prosemirrorPlugins:[new V.Plugin({key:ge,view:t=>(e=new fe(n,t,r=>{o.setState({...r})}),e)})],blockDragStart(t,r){e&&(e.isDragOrigin=!0),ht(t,r,n)},blockDragEnd(){pe(n.prosemirrorView.root),e&&(e.isDragOrigin=!1),n.blur()},freezeMenu(){e.menuFrozen=!0,e.state.show=!0,e.emitUpdate(e.state)},unfreezeMenu(){e.menuFrozen=!1,e.state.show=!1,e.emitUpdate(e.state)}}});let E;function se(n){E||(E=document.createElement("div"),E.innerHTML="_",E.style.opacity="0",E.style.height="1px",E.style.width="1px",n instanceof Document?n.body.appendChild(E):n.appendChild(E))}function ft(n){E&&(n instanceof Document?n.body.removeChild(E):n.removeChild(E),E=void 0)}function _(n){return Array.prototype.indexOf.call(n.parentElement.childNodes,n)}function gt(n){let e=n;for(;e&&e.nodeName!=="TD"&&e.nodeName!=="TH"&&!e.classList.contains("tableWrapper");){if(e.classList.contains("ProseMirror"))return;const o=e.parentNode;if(!o||!(o instanceof Element))return;e=o}return e.nodeName==="TD"||e.nodeName==="TH"?{type:"cell",domNode:e,tbodyNode:e.closest("tbody")}:{type:"wrapper",domNode:e,tbodyNode:e.querySelector("tbody")}}function yt(n,e){const o=e.querySelectorAll(n);for(let t=0;t<o.length;t++)o[t].style.visibility="hidden"}class ye{constructor(e,o,t){b(this,"state");b(this,"emitUpdate");b(this,"tableId");b(this,"tablePos");b(this,"tableElement");b(this,"menuFrozen",!1);b(this,"mouseState","up");b(this,"prevWasEditable",null);b(this,"viewMousedownHandler",()=>{this.mouseState="down"});b(this,"mouseUpHandler",e=>{this.mouseState="up",this.mouseMoveHandler(e)});b(this,"mouseMoveHandler",e=>{var l,u,h,g,m,p,d,f;if(this.menuFrozen||this.mouseState==="selecting"||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;const o=gt(e.target);if((o==null?void 0:o.type)==="cell"&&this.mouseState==="down"&&!((l=this.state)!=null&&l.draggingState)){this.mouseState="selecting",(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!o||!this.editor.isEditable){(h=this.state)!=null&&h.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!o.tbodyNode)return;const t=o.tbodyNode.getBoundingClientRect(),r=he(o.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(y=>O.getNodeById(r.id,y.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const a=k.nodeToBlock(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(O.editorHasBlockWithType(this.editor,"table")&&(this.tablePos=i.posBeforeNode+1,s=a),!s)return;this.tableId=r.id;const c=(g=o.domNode.closest(".tableWrapper"))==null?void 0:g.querySelector(".table-widgets-container");if((o==null?void 0:o.type)==="wrapper"){const y=e.clientY>=t.bottom-1&&e.clientY<t.bottom+20,w=e.clientX>=t.right-1&&e.clientX<t.right+20,x=((m=this.state)==null?void 0:m.block.id)!==s.id||e.clientX>t.right||e.clientY>t.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:y,showAddOrRemoveColumnsButton:w,referencePosTable:t,block:s,widgetContainer:c,colIndex:x||(p=this.state)==null?void 0:p.colIndex,rowIndex:x||(d=this.state)==null?void 0:d.rowIndex,referencePosCell:x||(f=this.state)==null?void 0:f.referencePosCell}}else{const y=_(o.domNode),w=_(o.domNode.parentElement),x=o.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===y)return;this.state={show:!0,showAddOrRemoveColumnsButton:y===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:t,block:s,draggingState:void 0,referencePosCell:x,colIndex:y,rowIndex:w,widgetContainer:c}}return this.emitUpdate(),!1});b(this,"dragOverHandler",e=>{var g;if(((g=this.state)==null?void 0:g.draggingState)===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect="move",yt(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const o={left:Math.min(Math.max(e.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(e.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},t=this.pmView.root.elementsFromPoint(o.left,o.top).filter(m=>m.tagName==="TD"||m.tagName==="TH");if(t.length===0)return;const r=t[0];let s=!1;const i=_(r.parentElement),a=_(r),c=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,u=(this.state.draggingState.draggedCellOrientation==="row"?i:a)!==c;(this.state.rowIndex!==i||this.state.colIndex!==a)&&(this.state.rowIndex=i,this.state.colIndex=a,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const h=this.state.draggingState.draggedCellOrientation==="row"?o.top:o.left;this.state.draggingState.mousePos!==h&&(this.state.draggingState.mousePos=h,s=!0),s&&this.emitUpdate(),u&&this.editor.transact(m=>m.setMeta(N,!0))});b(this,"dropHandler",e=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");e.preventDefault();const{draggingState:o,colIndex:t,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(o.draggedCellOrientation==="row"){if(!k.canRowBeDraggedInto(this.state.block,o.originalIndex,r))return!1;const i=k.moveRow(this.state.block,o.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!k.canColumnBeDraggedInto(this.state.block,o.originalIndex,t))return!1;const i=k.moveColumn(this.state.block,o.originalIndex,t),[a]=s.splice(o.originalIndex,1);s.splice(t,0,a),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=e,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");t(this.state)},o.dom.addEventListener("mousemove",this.mouseMoveHandler),o.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),o.root.addEventListener("dragover",this.dragOverHandler),o.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:e,width:o}=k.getDimensionsOfTable(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=e&&(this.state.rowIndex=e-1),this.state.colIndex>=o&&(this.state.colIndex=o-1));const t=this.tableElement.querySelector("tbody");if(!t)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=t.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=t.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const N=new C.PluginKey("TableHandlesPlugin"),wt=v.createExtension(({editor:n})=>{let e;const o=v.createStore(void 0);return{key:"tableHandles",store:o,prosemirrorPlugins:[new C.Plugin({key:N,view:t=>(e=new ye(n,t,r=>{o.setState(r.block?{...r,draggingState:r.draggingState?{...r.draggingState}:void 0}:void 0)}),e),props:{decorations:t=>{if(e===void 0||e.state===void 0||e.state.draggingState===void 0||e.tablePos===void 0)return;const r=e.state.draggingState.draggedCellOrientation==="row"?e.state.rowIndex:e.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:a}=e.state,{originalIndex:c,draggedCellOrientation:l}=a;if(r===c||!i||l==="row"&&!k.canRowBeDraggedInto(i,c,r)||l==="col"&&!k.canColumnBeDraggedInto(i,c,r))return D.DecorationSet.create(t.doc,s);const u=t.doc.resolve(e.tablePos+1);return e.state.draggingState.draggedCellOrientation==="row"?k.getCellsAtRowHandle(e.state.block,r).forEach(({row:g,col:m})=>{const p=t.doc.resolve(u.posAtIndex(g)+1),d=t.doc.resolve(p.posAtIndex(m)+1),f=d.node(),y=d.pos+(r>c?f.nodeSize-2:0);s.push(D.Decoration.widget(y,()=>{const w=document.createElement("div");return w.className="bn-table-drop-cursor",w.style.left="0",w.style.right="0",r>c?w.style.bottom="-2px":w.style.top="-3px",w.style.height="4px",w}))}):k.getCellsAtColumnHandle(e.state.block,r).forEach(({row:g,col:m})=>{const p=t.doc.resolve(u.posAtIndex(g)+1),d=t.doc.resolve(p.posAtIndex(m)+1),f=d.node(),y=d.pos+(r>c?f.nodeSize-2:0);s.push(D.Decoration.widget(y,()=>{const w=document.createElement("div");return w.className="bn-table-drop-cursor",w.style.top="0",w.style.bottom="0",r>c?w.style.right="-2px":w.style.left="-3px",w.style.width="4px",w}))}),D.DecorationSet.create(t.doc,s)}}})],colDragStart(t){if(e===void 0||e.state===void 0||e.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");e.state.draggingState={draggedCellOrientation:"col",originalIndex:e.state.colIndex,mousePos:t.clientX},e.emitUpdate(),n.transact(r=>r.setMeta(N,{draggedCellOrientation:e.state.draggingState.draggedCellOrientation,originalIndex:e.state.colIndex,newIndex:e.state.colIndex,tablePos:e.tablePos})),!n.headless&&(se(n.prosemirrorView.root),t.dataTransfer.setDragImage(E,0,0),t.dataTransfer.effectAllowed="move")},rowDragStart(t){if(e.state===void 0||e.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");e.state.draggingState={draggedCellOrientation:"row",originalIndex:e.state.rowIndex,mousePos:t.clientY},e.emitUpdate(),n.transact(r=>r.setMeta(N,{draggedCellOrientation:e.state.draggingState.draggedCellOrientation,originalIndex:e.state.rowIndex,newIndex:e.state.rowIndex,tablePos:e.tablePos})),!n.headless&&(se(n.prosemirrorView.root),t.dataTransfer.setDragImage(E,0,0),t.dataTransfer.effectAllowed="copyMove")},dragEnd(){if(e.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");e.state.draggingState=void 0,e.emitUpdate(),n.transact(t=>t.setMeta(N,null)),!n.headless&&ft(n.prosemirrorView.root)},freezeHandles(){e.menuFrozen=!0},unfreezeHandles(){e.menuFrozen=!1},getCellsAtRowHandle(t,r){return k.getCellsAtRowHandle(t,r)},getCellsAtColumnHandle(t,r){return k.getCellsAtColumnHandle(t,r)},setCellSelection(t,r,s=r){if(!e)throw new Error("Table handles view not initialized");const i=t.doc.resolve(e.tablePos+1),a=t.doc.resolve(i.posAtIndex(r.row)+1),c=t.doc.resolve(a.posAtIndex(r.col)),l=t.doc.resolve(i.posAtIndex(s.row)+1),u=t.doc.resolve(l.posAtIndex(s.col)),h=t.tr;return h.setSelection(new P.CellSelection(c,u)),t.apply(h)},addRowOrColumn(t,r){n.exec((s,i)=>{const a=this.setCellSelection(s,r.orientation==="row"?{row:t,col:0}:{row:0,col:t});return r.orientation==="row"?r.side==="above"?P.addRowBefore(a,i):P.addRowAfter(a,i):r.side==="left"?P.addColumnBefore(a,i):P.addColumnAfter(a,i)})},removeRowOrColumn(t,r){return r==="row"?n.exec((s,i)=>{const a=this.setCellSelection(s,{row:t,col:0});return P.deleteRow(a,i)}):n.exec((s,i)=>{const a=this.setCellSelection(s,{row:0,col:t});return P.deleteColumn(a,i)})},mergeCells(t){return n.exec((r,s)=>{const i=t?this.setCellSelection(r,t.relativeStartCell,t.relativeEndCell):r;return P.mergeCells(i,s)})},splitCell(t){return n.exec((r,s)=>{const i=t?this.setCellSelection(r,t):r;return P.splitCell(i,s)})},getCellSelection(){return n.transact(t=>{const r=t.selection;let s=r.$from,i=r.$to;if(O.isTableCellSelection(r)){const{ranges:d}=r;d.forEach(f=>{s=f.$from.min(s??f.$from),i=f.$to.max(i??f.$to)})}else if(s=t.doc.resolve(r.$from.pos-r.$from.parentOffset-1),i=t.doc.resolve(r.$to.pos-r.$to.parentOffset-1),s.pos===0||i.pos===0)return;const a=t.doc.resolve(s.pos-s.parentOffset-1),c=t.doc.resolve(i.pos-i.parentOffset-1),l=t.doc.resolve(a.pos-a.parentOffset-1),u=s.index(a.depth),h=a.index(l.depth),g=i.index(c.depth),m=c.index(l.depth),p=[];for(let d=h;d<=m;d++)for(let f=u;f<=g;f++)p.push({row:d,col:f});return{from:{row:h,col:u},to:{row:m,col:g},cells:p}})},getMergeDirection(t){return n.transact(r=>{const s=O.isTableCellSelection(r.selection)?r.selection:void 0;if(!s||!t||s.ranges.length<=1)return;const i=this.getCellSelection();if(i)return k.areInSameColumn(i.from,i.to,t)?"vertical":"horizontal"})},cropEmptyRowsOrColumns(t,r){return k.cropEmptyRowsOrColumns(t,r)},addRowsOrColumns(t,r,s){return k.addRowsOrColumns(t,r,s)}}}),ie=new C.PluginKey("trailingNode"),bt=v.createExtension(()=>({key:"trailingNode",prosemirrorPlugins:[new C.Plugin({key:ie,appendTransaction:(n,e,o)=>{const{doc:t,tr:r,schema:s}=o,i=ie.getState(o),a=t.content.size-2,c=s.nodes.blockContainer,l=s.nodes.paragraph;if(i)return r.insert(a,c.create(void 0,l.create()))},state:{init:(n,e)=>{},apply:(n,e)=>{if(!n.docChanged)return e;let o=n.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const t=o.firstChild;if(!t)throw new Error("Expected blockContent");return o.nodeSize>4||t.type.spec.content!=="inline*"}}})]}));exports.BlockChangeExtension=$e;exports.DEFAULT_LINK_PROTOCOL=et;exports.DropCursorExtension=We;exports.ForkYDocExtension=Ke;exports.FormattingToolbarExtension=Ge;exports.HistoryExtension=Je;exports.LinkToolbarExtension=Qe;exports.NodeSelectionKeyboardExtension=ot;exports.PlaceholderExtension=rt;exports.PreviousBlockTypeExtension=it;exports.SchemaMigration=Xe;exports.SideMenuExtension=pt;exports.SideMenuView=fe;exports.TableHandlesExtension=wt;exports.TableHandlesView=ye;exports.TrailingNodeExtension=bt;exports.VALID_LINK_PROTOCOLS=Ze;exports.YCursorExtension=z;exports.YSyncExtension=U;exports.YUndoExtension=$;exports.blocksToMarkdown=dt;exports.cleanHTMLToMarkdown=j;exports.createExternalHTMLExporter=Y;exports.fragmentToBlocks=me;exports.getBlocksChangedByTransaction=de;exports.sideMenuPluginKey=ge;exports.tableHandlesPluginKey=N;
|
|
2
|
-
//# sourceMappingURL=TrailingNode-DHOdUVUO.cjs.map
|