@notectl/core 1.0.5 → 1.0.6

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 (63) hide show
  1. package/README.md +2 -1
  2. package/dist/chunks/{ToolbarPlugin-D5VqeBPT.mjs → ToolbarPlugin-sJTiZr-S.mjs} +2 -2
  3. package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +1 -0
  4. package/dist/chunks/index-QvKiO9_4.mjs +538 -0
  5. package/dist/chunks/index-QvKiO9_4.mjs.map +1 -0
  6. package/dist/editor/EditorDOM.d.ts.map +1 -1
  7. package/dist/editor/NotectlEditor.d.ts +5 -1
  8. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/notectl-core.mjs +1846 -1712
  12. package/dist/notectl-core.mjs.map +1 -1
  13. package/dist/notectl-core.umd.js +1050 -966
  14. package/dist/notectl-core.umd.js.map +1 -1
  15. package/dist/plugins/PluginManager.d.ts +3 -1
  16. package/dist/plugins/PluginManager.d.ts.map +1 -1
  17. package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
  18. package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
  19. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
  20. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
  21. package/dist/plugins/code-block/CodeBlockNodeView.d.ts +1 -1
  22. package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
  23. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +3 -111
  24. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  25. package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
  26. package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
  27. package/dist/plugins/code-block/CodeBlockTypes.d.ts +69 -0
  28. package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
  29. package/dist/plugins/code-block.mjs +1 -1
  30. package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
  31. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
  32. package/dist/plugins/font-size/FontSizePlugin.d.ts +1 -10
  33. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  34. package/dist/plugins/font-size/FontSizePopup.d.ts +9 -0
  35. package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
  36. package/dist/plugins/font-size.mjs +146 -162
  37. package/dist/plugins/font-size.mjs.map +1 -1
  38. package/dist/plugins/font.mjs +1 -1
  39. package/dist/plugins/heading.mjs +1 -1
  40. package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
  41. package/dist/plugins/image.mjs +1 -1
  42. package/dist/plugins/image.mjs.map +1 -1
  43. package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
  44. package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
  45. package/dist/plugins/print/PrintPlugin.d.ts +12 -0
  46. package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
  47. package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
  48. package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
  49. package/dist/plugins/print/PrintStyleCollector.d.ts +10 -0
  50. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
  51. package/dist/plugins/print/PrintTypes.d.ts +56 -0
  52. package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
  53. package/dist/plugins/table/TableControls.d.ts.map +1 -1
  54. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
  55. package/dist/plugins/table.mjs +13 -13
  56. package/dist/plugins/table.mjs.map +1 -1
  57. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  58. package/dist/plugins/toolbar.mjs +1 -1
  59. package/dist/view/Reconciler.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +0 -1
  62. package/dist/chunks/index-CPPb-Jah.mjs +0 -569
  63. package/dist/chunks/index-CPPb-Jah.mjs.map +0 -1
@@ -1,24 +1,24 @@
1
- import { j as e, n as s, g as r, c as o, a as l, i as d, d as g, k as m, m as k, r as T, o as N, p as M, e as I, l as R, q as P, s as D, b as L, t as _, u as O } from "./chunks/Document-CI3iCwEP.mjs";
1
+ import { j as e, n as s, g as o, c as r, a as l, i as d, d as g, k as m, m as k, r as S, o as T, p as E, e as N, l as M, q as I, s as R, b as P, t as L, u as D } from "./chunks/Document-CI3iCwEP.mjs";
2
2
  import { f, v, h } from "./chunks/Document-CI3iCwEP.mjs";
3
- import { b as H, c as F, i as $, d as j, e as U, f as K, a as V, s as q, g as W } from "./chunks/Selection-D5ZjXoB7.mjs";
3
+ import { b as _, c as O, i as H, d as $, e as j, f as F, a as U, s as K, g as V } from "./chunks/Selection-D5ZjXoB7.mjs";
4
4
  import { h as h2 } from "./chunks/Selection-D5ZjXoB7.mjs";
5
- import { d as X, s as J, n as Q, a as G, b as Y, i as Z, c as ee, e as te, f as ne, g as se, h as re, j as oe, k as ie, l as ae, m as ce, o as le, p as he, q as de, r as ue } from "./chunks/Commands-DLP85Mp5.mjs";
5
+ import { d as q, s as W, n as X, a as J, b as Q, i as G, c as Y, e as Z, f as tt, g as et, h as nt, j as st, k as ot, l as rt, m as it, o as at, p as ct, q as lt, r as dt } from "./chunks/Commands-DLP85Mp5.mjs";
6
6
  import { t, u, v as v2, w, x, y, z, A, B } from "./chunks/Commands-DLP85Mp5.mjs";
7
- import { b as pe, n as fe, m as ge } from "./chunks/TypeBrands-C09nE2qO.mjs";
7
+ import { b as ht, n as ut, m as pt } from "./chunks/TypeBrands-C09nE2qO.mjs";
8
8
  import { c, i, p } from "./chunks/TypeBrands-C09nE2qO.mjs";
9
- import { i as me } from "./chunks/AttrRegistry-DTsHyDVA.mjs";
9
+ import { i as ft } from "./chunks/AttrRegistry-DTsHyDVA.mjs";
10
10
  import { a, b } from "./chunks/AttrRegistry-DTsHyDVA.mjs";
11
- import { c as ye } from "./chunks/NodeSpec-NZVvcCuH.mjs";
12
- import { e as ke } from "./chunks/HTMLUtils-0wvCRvJc.mjs";
13
- import { a as be, r as Se, f as ve } from "./chunks/NodeResolver-D68ZLXti.mjs";
11
+ import { c as gt } from "./chunks/NodeSpec-NZVvcCuH.mjs";
12
+ import { e as mt } from "./chunks/HTMLUtils-0wvCRvJc.mjs";
13
+ import { a as yt, r as kt, f as bt } from "./chunks/NodeResolver-D68ZLXti.mjs";
14
14
  import { b as b2, c as c2, w as w2 } from "./chunks/NodeResolver-D68ZLXti.mjs";
15
- import { E, S } from "./chunks/Plugin-B9OZ6Y4c.mjs";
16
- import { D as we, d as Te } from "./chunks/index-CPPb-Jah.mjs";
17
- import { C, a as a2, i as i2, n, w as w3 } from "./chunks/index-CPPb-Jah.mjs";
18
- import { T as Ee } from "./chunks/ToolbarPlugin-D5VqeBPT.mjs";
19
- import { a as a3 } from "./chunks/ToolbarPlugin-D5VqeBPT.mjs";
20
- import { f as f2 } from "./chunks/ToolbarItem-ugDymuXi.mjs";
21
- import { TextFormattingPlugin as xe } from "./plugins/text-formatting.mjs";
15
+ import { E as St, S as vt } from "./chunks/Plugin-B9OZ6Y4c.mjs";
16
+ import { D as wt, d as Tt } from "./chunks/index-QvKiO9_4.mjs";
17
+ import { C, a as a2, i as i2, n, w as w3 } from "./chunks/index-QvKiO9_4.mjs";
18
+ import { T as Et } from "./chunks/ToolbarPlugin-sJTiZr-S.mjs";
19
+ import { a as a3 } from "./chunks/ToolbarPlugin-sJTiZr-S.mjs";
20
+ import { f as xt } from "./chunks/ToolbarItem-ugDymuXi.mjs";
21
+ import { TextFormattingPlugin as Nt } from "./plugins/text-formatting.mjs";
22
22
  import { HeadingPlugin } from "./plugins/heading.mjs";
23
23
  import { LinkPlugin } from "./plugins/link.mjs";
24
24
  import { ListPlugin } from "./plugins/list.mjs";
@@ -34,8 +34,8 @@ import { HighlightPlugin } from "./plugins/highlight.mjs";
34
34
  import { SuperSubPlugin } from "./plugins/super-sub.mjs";
35
35
  import { DEFAULT_IMAGE_KEYMAP, IMAGE_UPLOAD_SERVICE, ImagePlugin } from "./plugins/image.mjs";
36
36
  import { HardBreakPlugin } from "./plugins/hard-break.mjs";
37
- import Ne from "dompurify";
38
- class Me {
37
+ import Mt from "dompurify";
38
+ class Ct {
39
39
  _nodeSpecs = /* @__PURE__ */ new Map();
40
40
  _markSpecs = /* @__PURE__ */ new Map();
41
41
  _inlineNodeSpecs = /* @__PURE__ */ new Map();
@@ -46,768 +46,768 @@ class Me {
46
46
  _toolbarItemPluginMap = /* @__PURE__ */ new Map();
47
47
  _fileHandlers = [];
48
48
  _blockTypePickerEntries = /* @__PURE__ */ new Map();
49
- registerNodeSpec(e2) {
50
- if (this._nodeSpecs.has(e2.type)) throw new Error(`NodeSpec for type "${e2.type}" is already registered.`);
51
- this._nodeSpecs.set(e2.type, e2);
49
+ registerNodeSpec(t2) {
50
+ if (this._nodeSpecs.has(t2.type)) throw new Error(`NodeSpec for type "${t2.type}" is already registered.`);
51
+ this._nodeSpecs.set(t2.type, t2);
52
52
  }
53
- getNodeSpec(e2) {
54
- return this._nodeSpecs.get(e2);
53
+ getNodeSpec(t2) {
54
+ return this._nodeSpecs.get(t2);
55
55
  }
56
- removeNodeSpec(e2) {
57
- this._nodeSpecs.delete(e2);
56
+ removeNodeSpec(t2) {
57
+ this._nodeSpecs.delete(t2);
58
58
  }
59
59
  getNodeTypes() {
60
60
  return [...this._nodeSpecs.keys()];
61
61
  }
62
- registerMarkSpec(e2) {
63
- if (this._markSpecs.has(e2.type)) throw new Error(`MarkSpec for type "${e2.type}" is already registered.`);
64
- this._markSpecs.set(e2.type, e2);
62
+ registerMarkSpec(t2) {
63
+ if (this._markSpecs.has(t2.type)) throw new Error(`MarkSpec for type "${t2.type}" is already registered.`);
64
+ this._markSpecs.set(t2.type, t2);
65
65
  }
66
- getMarkSpec(e2) {
67
- return this._markSpecs.get(e2);
66
+ getMarkSpec(t2) {
67
+ return this._markSpecs.get(t2);
68
68
  }
69
- removeMarkSpec(e2) {
70
- this._markSpecs.delete(e2);
69
+ removeMarkSpec(t2) {
70
+ this._markSpecs.delete(t2);
71
71
  }
72
72
  getMarkTypes() {
73
73
  return [...this._markSpecs.keys()];
74
74
  }
75
- registerInlineNodeSpec(e2) {
76
- if (this._inlineNodeSpecs.has(e2.type)) throw new Error(`InlineNodeSpec for type "${e2.type}" is already registered.`);
77
- this._inlineNodeSpecs.set(e2.type, e2);
75
+ registerInlineNodeSpec(t2) {
76
+ if (this._inlineNodeSpecs.has(t2.type)) throw new Error(`InlineNodeSpec for type "${t2.type}" is already registered.`);
77
+ this._inlineNodeSpecs.set(t2.type, t2);
78
78
  }
79
- getInlineNodeSpec(e2) {
80
- return this._inlineNodeSpecs.get(e2);
79
+ getInlineNodeSpec(t2) {
80
+ return this._inlineNodeSpecs.get(t2);
81
81
  }
82
- removeInlineNodeSpec(e2) {
83
- this._inlineNodeSpecs.delete(e2);
82
+ removeInlineNodeSpec(t2) {
83
+ this._inlineNodeSpecs.delete(t2);
84
84
  }
85
85
  getInlineNodeTypes() {
86
86
  return [...this._inlineNodeSpecs.keys()];
87
87
  }
88
- registerNodeView(e2, t2) {
89
- if (this._nodeViews.has(e2)) throw new Error(`NodeView for type "${e2}" is already registered.`);
90
- this._nodeViews.set(e2, t2);
88
+ registerNodeView(t2, e2) {
89
+ if (this._nodeViews.has(t2)) throw new Error(`NodeView for type "${t2}" is already registered.`);
90
+ this._nodeViews.set(t2, e2);
91
91
  }
92
- getNodeViewFactory(e2) {
93
- return this._nodeViews.get(e2);
92
+ getNodeViewFactory(t2) {
93
+ return this._nodeViews.get(t2);
94
94
  }
95
- removeNodeView(e2) {
96
- this._nodeViews.delete(e2);
95
+ removeNodeView(t2) {
96
+ this._nodeViews.delete(t2);
97
97
  }
98
- registerKeymap(e2) {
99
- for (const t2 of Object.keys(e2)) for (const e3 of this._keymaps) if (t2 in e3) {
100
- console.debug(`[notectl] Keymap shortcut "${t2}" is already registered and will be overridden.`);
98
+ registerKeymap(t2) {
99
+ for (const e2 of Object.keys(t2)) for (const t3 of this._keymaps) if (e2 in t3) {
100
+ console.debug(`[notectl] Keymap shortcut "${e2}" is already registered and will be overridden.`);
101
101
  break;
102
102
  }
103
- this._keymaps.push(e2);
103
+ this._keymaps.push(t2);
104
104
  }
105
105
  getKeymaps() {
106
106
  return this._keymaps;
107
107
  }
108
- removeKeymap(e2) {
109
- const t2 = this._keymaps.indexOf(e2);
110
- -1 !== t2 && this._keymaps.splice(t2, 1);
108
+ removeKeymap(t2) {
109
+ const e2 = this._keymaps.indexOf(t2);
110
+ -1 !== e2 && this._keymaps.splice(e2, 1);
111
111
  }
112
- registerInputRule(e2) {
113
- this._inputRules.push(e2);
112
+ registerInputRule(t2) {
113
+ this._inputRules.push(t2);
114
114
  }
115
115
  getInputRules() {
116
116
  return this._inputRules;
117
117
  }
118
- removeInputRule(e2) {
119
- const t2 = this._inputRules.indexOf(e2);
120
- -1 !== t2 && this._inputRules.splice(t2, 1);
118
+ removeInputRule(t2) {
119
+ const e2 = this._inputRules.indexOf(t2);
120
+ -1 !== e2 && this._inputRules.splice(e2, 1);
121
121
  }
122
- registerToolbarItem(e2, t2) {
123
- if (this._toolbarItems.has(e2.id)) throw new Error(`ToolbarItem with id "${e2.id}" is already registered.`);
124
- if (this._toolbarItems.set(e2.id, e2), t2) {
125
- const n2 = this._toolbarItemPluginMap.get(t2) ?? [];
126
- n2.push(e2.id), this._toolbarItemPluginMap.set(t2, n2);
122
+ registerToolbarItem(t2, e2) {
123
+ if (this._toolbarItems.has(t2.id)) throw new Error(`ToolbarItem with id "${t2.id}" is already registered.`);
124
+ if (this._toolbarItems.set(t2.id, t2), e2) {
125
+ const n2 = this._toolbarItemPluginMap.get(e2) ?? [];
126
+ n2.push(t2.id), this._toolbarItemPluginMap.set(e2, n2);
127
127
  }
128
128
  }
129
- getToolbarItemsByPlugin(e2) {
130
- const t2 = this._toolbarItemPluginMap.get(e2) ?? [], n2 = [];
131
- for (const e3 of t2) {
132
- const t3 = this._toolbarItems.get(e3);
133
- t3 && n2.push(t3);
129
+ getToolbarItemsByPlugin(t2) {
130
+ const e2 = this._toolbarItemPluginMap.get(t2) ?? [], n2 = [];
131
+ for (const t3 of e2) {
132
+ const e3 = this._toolbarItems.get(t3);
133
+ e3 && n2.push(e3);
134
134
  }
135
135
  return n2;
136
136
  }
137
- getToolbarItem(e2) {
138
- return this._toolbarItems.get(e2);
137
+ getToolbarItem(t2) {
138
+ return this._toolbarItems.get(t2);
139
139
  }
140
140
  getToolbarItems() {
141
141
  return [...this._toolbarItems.values()];
142
142
  }
143
- removeToolbarItem(e2) {
144
- this._toolbarItems.delete(e2);
145
- for (const [t2, n2] of this._toolbarItemPluginMap) {
146
- const s2 = n2.indexOf(e2);
143
+ removeToolbarItem(t2) {
144
+ this._toolbarItems.delete(t2);
145
+ for (const [e2, n2] of this._toolbarItemPluginMap) {
146
+ const s2 = n2.indexOf(t2);
147
147
  if (-1 !== s2) {
148
- n2.splice(s2, 1), 0 === n2.length && this._toolbarItemPluginMap.delete(t2);
148
+ n2.splice(s2, 1), 0 === n2.length && this._toolbarItemPluginMap.delete(e2);
149
149
  break;
150
150
  }
151
151
  }
152
152
  }
153
- registerFileHandler(e2, t2) {
154
- this._fileHandlers.push({ pattern: e2, handler: t2 });
153
+ registerFileHandler(t2, e2) {
154
+ this._fileHandlers.push({ pattern: t2, handler: e2 });
155
155
  }
156
156
  getFileHandlers() {
157
157
  return this._fileHandlers;
158
158
  }
159
- matchFileHandlers(e2) {
160
- const t2 = [];
161
- for (const n2 of this._fileHandlers) Ie(n2.pattern, e2) && t2.push(n2.handler);
162
- return t2;
159
+ matchFileHandlers(t2) {
160
+ const e2 = [];
161
+ for (const n2 of this._fileHandlers) It(n2.pattern, t2) && e2.push(n2.handler);
162
+ return e2;
163
163
  }
164
- removeFileHandler(e2) {
165
- const t2 = this._fileHandlers.findIndex((t3) => t3.handler === e2);
166
- -1 !== t2 && this._fileHandlers.splice(t2, 1);
164
+ removeFileHandler(t2) {
165
+ const e2 = this._fileHandlers.findIndex((e3) => e3.handler === t2);
166
+ -1 !== e2 && this._fileHandlers.splice(e2, 1);
167
167
  }
168
- registerBlockTypePickerEntry(e2) {
169
- if (this._blockTypePickerEntries.has(e2.id)) throw new Error(`BlockTypePickerEntry with id "${e2.id}" is already registered.`);
170
- this._blockTypePickerEntries.set(e2.id, e2);
168
+ registerBlockTypePickerEntry(t2) {
169
+ if (this._blockTypePickerEntries.has(t2.id)) throw new Error(`BlockTypePickerEntry with id "${t2.id}" is already registered.`);
170
+ this._blockTypePickerEntries.set(t2.id, t2);
171
171
  }
172
172
  getBlockTypePickerEntries() {
173
- return [...this._blockTypePickerEntries.values()].sort((e2, t2) => e2.priority - t2.priority);
173
+ return [...this._blockTypePickerEntries.values()].sort((t2, e2) => t2.priority - e2.priority);
174
174
  }
175
- removeBlockTypePickerEntry(e2) {
176
- this._blockTypePickerEntries.delete(e2);
175
+ removeBlockTypePickerEntry(t2) {
176
+ this._blockTypePickerEntries.delete(t2);
177
177
  }
178
178
  getBlockParseRules() {
179
- const e2 = [];
180
- for (const [t2, n2] of this._nodeSpecs) if (n2.parseHTML) for (const s2 of n2.parseHTML) e2.push({ rule: s2, type: t2 });
181
- return e2.sort((e3, t2) => (t2.rule.priority ?? 50) - (e3.rule.priority ?? 50));
179
+ const t2 = [];
180
+ for (const [e2, n2] of this._nodeSpecs) if (n2.parseHTML) for (const s2 of n2.parseHTML) t2.push({ rule: s2, type: e2 });
181
+ return t2.sort((t3, e2) => (e2.rule.priority ?? 50) - (t3.rule.priority ?? 50));
182
182
  }
183
183
  getInlineParseRules() {
184
- const e2 = [];
185
- for (const [t2, n2] of this._inlineNodeSpecs) if (n2.parseHTML) for (const s2 of n2.parseHTML) e2.push({ rule: s2, type: t2 });
186
- return e2.sort((e3, t2) => (t2.rule.priority ?? 50) - (e3.rule.priority ?? 50));
184
+ const t2 = [];
185
+ for (const [e2, n2] of this._inlineNodeSpecs) if (n2.parseHTML) for (const s2 of n2.parseHTML) t2.push({ rule: s2, type: e2 });
186
+ return t2.sort((t3, e2) => (e2.rule.priority ?? 50) - (t3.rule.priority ?? 50));
187
187
  }
188
188
  getMarkParseRules() {
189
- const e2 = [];
190
- for (const [t2, n2] of this._markSpecs) if (n2.parseHTML) for (const s2 of n2.parseHTML) e2.push({ rule: s2, type: t2 });
191
- return e2.sort((e3, t2) => (t2.rule.priority ?? 50) - (e3.rule.priority ?? 50));
189
+ const t2 = [];
190
+ for (const [e2, n2] of this._markSpecs) if (n2.parseHTML) for (const s2 of n2.parseHTML) t2.push({ rule: s2, type: e2 });
191
+ return t2.sort((t3, e2) => (e2.rule.priority ?? 50) - (t3.rule.priority ?? 50));
192
192
  }
193
193
  getAllowedTags() {
194
- const e2 = /* @__PURE__ */ new Set(["p", "br", "div", "span"]);
195
- for (const t2 of this._nodeSpecs.values()) if (t2.sanitize?.tags) for (const n2 of t2.sanitize.tags) e2.add(n2);
196
- for (const t2 of this._inlineNodeSpecs.values()) if (t2.sanitize?.tags) for (const n2 of t2.sanitize.tags) e2.add(n2);
197
- for (const t2 of this._markSpecs.values()) if (t2.sanitize?.tags) for (const n2 of t2.sanitize.tags) e2.add(n2);
198
- return [...e2];
194
+ const t2 = /* @__PURE__ */ new Set(["p", "br", "div", "span"]);
195
+ for (const e2 of this._nodeSpecs.values()) if (e2.sanitize?.tags) for (const n2 of e2.sanitize.tags) t2.add(n2);
196
+ for (const e2 of this._inlineNodeSpecs.values()) if (e2.sanitize?.tags) for (const n2 of e2.sanitize.tags) t2.add(n2);
197
+ for (const e2 of this._markSpecs.values()) if (e2.sanitize?.tags) for (const n2 of e2.sanitize.tags) t2.add(n2);
198
+ return [...t2];
199
199
  }
200
200
  getAllowedAttrs() {
201
- const e2 = /* @__PURE__ */ new Set(["style"]);
202
- for (const t2 of this._nodeSpecs.values()) if (t2.sanitize?.attrs) for (const n2 of t2.sanitize.attrs) e2.add(n2);
203
- for (const t2 of this._inlineNodeSpecs.values()) if (t2.sanitize?.attrs) for (const n2 of t2.sanitize.attrs) e2.add(n2);
204
- for (const t2 of this._markSpecs.values()) if (t2.sanitize?.attrs) for (const n2 of t2.sanitize.attrs) e2.add(n2);
205
- return [...e2];
201
+ const t2 = /* @__PURE__ */ new Set(["style"]);
202
+ for (const e2 of this._nodeSpecs.values()) if (e2.sanitize?.attrs) for (const n2 of e2.sanitize.attrs) t2.add(n2);
203
+ for (const e2 of this._inlineNodeSpecs.values()) if (e2.sanitize?.attrs) for (const n2 of e2.sanitize.attrs) t2.add(n2);
204
+ for (const e2 of this._markSpecs.values()) if (e2.sanitize?.attrs) for (const n2 of e2.sanitize.attrs) t2.add(n2);
205
+ return [...t2];
206
206
  }
207
207
  clear() {
208
208
  this._nodeSpecs.clear(), this._markSpecs.clear(), this._inlineNodeSpecs.clear(), this._nodeViews.clear(), this._keymaps.length = 0, this._inputRules.length = 0, this._toolbarItems.clear(), this._toolbarItemPluginMap.clear(), this._fileHandlers.length = 0, this._blockTypePickerEntries.clear();
209
209
  }
210
210
  }
211
- function Ie(e2, t2) {
212
- if ("*" === e2 || "*/*" === e2) return true;
213
- if (e2 === t2) return true;
214
- if (e2.endsWith("/*")) {
215
- const n2 = e2.slice(0, -1);
216
- return t2.startsWith(n2);
211
+ function It(t2, e2) {
212
+ if ("*" === t2 || "*/*" === t2) return true;
213
+ if (t2 === e2) return true;
214
+ if (t2.endsWith("/*")) {
215
+ const n2 = t2.slice(0, -1);
216
+ return e2.startsWith(n2);
217
217
  }
218
218
  return false;
219
219
  }
220
- function Ce(e2, t2, n2) {
221
- const s2 = e2.getNodeSpec(t2);
220
+ function Bt(t2, e2, n2) {
221
+ const s2 = t2.getNodeSpec(e2);
222
222
  if (!s2?.content) return true;
223
- const r2 = e2.getNodeSpec(n2), o2 = r2?.group;
224
- for (const e3 of s2.content.allow) {
225
- if (e3 === n2) return true;
226
- if ("text" !== e3 && o2 && e3 === o2) return true;
223
+ const o2 = t2.getNodeSpec(n2), r2 = o2?.group;
224
+ for (const t3 of s2.content.allow) {
225
+ if (t3 === n2) return true;
226
+ if ("text" !== t3 && r2 && t3 === r2) return true;
227
227
  }
228
228
  return false;
229
229
  }
230
- function Be(e2, t2, n2) {
231
- const s2 = e2.getNodeSpec(t2);
230
+ function At(t2, e2, n2) {
231
+ const s2 = t2.getNodeSpec(e2);
232
232
  if (!s2?.content) return true;
233
- const { min: r2 = 0, max: o2 = Number.POSITIVE_INFINITY } = s2.content, i3 = n2.filter((e3) => "text" !== e3);
234
- if (i3.length < r2 || i3.length > o2) return false;
235
- for (const n3 of i3) if (!Ce(e2, t2, n3)) return false;
233
+ const { min: o2 = 0, max: r2 = Number.POSITIVE_INFINITY } = s2.content, i3 = n2.filter((t3) => "text" !== t3);
234
+ if (i3.length < o2 || i3.length > r2) return false;
235
+ for (const n3 of i3) if (!Bt(t2, e2, n3)) return false;
236
236
  return true;
237
237
  }
238
- function Re(e2) {
239
- e2.registerNodeSpec({ type: "paragraph", group: "block", content: { allow: ["text"] }, toDOM: (e3) => ye("p", e3.id), toHTML: (e3, t2) => `<p>${t2 || "<br>"}</p>`, parseHTML: [{ tag: "p" }, { tag: "div", priority: 10 }], sanitize: { tags: ["p"] } });
238
+ function Rt(t2) {
239
+ t2.registerNodeSpec({ type: "paragraph", group: "block", content: { allow: ["text"] }, toDOM: (t3) => gt("p", t3.id), toHTML: (t3, e2) => `<p>${e2 || "<br>"}</p>`, parseHTML: [{ tag: "p" }, { tag: "div", priority: 10 }], sanitize: { tags: ["p"] } });
240
240
  }
241
- function Ae(t2, n2) {
241
+ function Pt(t2, n2) {
242
242
  switch (n2.type) {
243
243
  case "insertText":
244
244
  return (function(t3, n3) {
245
- return Le(t3, n3.blockId, (t4) => {
246
- const r2 = e(t4), o2 = n3.segments ? (function(e2, t5, n4) {
245
+ return _t(t3, n3.blockId, (t4) => {
246
+ const o2 = e(t4), r2 = n3.segments ? (function(t5, e2, n4) {
247
247
  const s2 = [];
248
- let r3 = 0, o3 = false;
249
- for (const i3 of e2) {
248
+ let o3 = 0, r3 = false;
249
+ for (const i3 of t5) {
250
250
  if (d(i3)) {
251
- if (!o3 && t5 === r3) {
252
- for (const e4 of n4) s2.push(g(e4.text, e4.marks));
253
- o3 = true;
251
+ if (!r3 && e2 === o3) {
252
+ for (const t7 of n4) s2.push(g(t7.text, t7.marks));
253
+ r3 = true;
254
254
  }
255
- s2.push(i3), r3 += 1;
255
+ s2.push(i3), o3 += 1;
256
256
  continue;
257
257
  }
258
- const e3 = r3 + i3.text.length;
259
- if (!o3 && t5 >= r3 && t5 <= e3) {
260
- const e4 = t5 - r3, a4 = i3.text.slice(0, e4), c3 = i3.text.slice(e4);
258
+ const t6 = o3 + i3.text.length;
259
+ if (!r3 && e2 >= o3 && e2 <= t6) {
260
+ const t7 = e2 - o3, a4 = i3.text.slice(0, t7), c3 = i3.text.slice(t7);
261
261
  a4 && s2.push(g(a4, i3.marks));
262
- for (const e5 of n4) s2.push(g(e5.text, e5.marks));
263
- c3 && s2.push(g(c3, i3.marks)), o3 = true;
262
+ for (const t8 of n4) s2.push(g(t8.text, t8.marks));
263
+ c3 && s2.push(g(c3, i3.marks)), r3 = true;
264
264
  } else s2.push(i3);
265
- r3 = e3;
265
+ o3 = t6;
266
266
  }
267
- if (!o3) for (const e3 of n4) s2.push(g(e3.text, e3.marks));
267
+ if (!r3) for (const t6 of n4) s2.push(g(t6.text, t6.marks));
268
268
  return s2;
269
- })(r2, n3.offset, n3.segments) : (function(e2, t5, n4, s2) {
270
- const r3 = [];
271
- let o3 = 0, i3 = false;
272
- for (const a4 of e2) {
269
+ })(o2, n3.offset, n3.segments) : (function(t5, e2, n4, s2) {
270
+ const o3 = [];
271
+ let r3 = 0, i3 = false;
272
+ for (const a4 of t5) {
273
273
  if (d(a4)) {
274
- i3 || t5 !== o3 || (r3.push(g(n4, s2)), i3 = true), r3.push(a4), o3 += 1;
274
+ i3 || e2 !== r3 || (o3.push(g(n4, s2)), i3 = true), o3.push(a4), r3 += 1;
275
275
  continue;
276
276
  }
277
- const e3 = o3 + a4.text.length;
278
- if (!i3 && t5 >= o3 && t5 <= e3) {
279
- const e4 = t5 - o3, c3 = a4.text.slice(0, e4), l2 = a4.text.slice(e4);
280
- c3 && r3.push(g(c3, a4.marks)), r3.push(g(n4, s2)), l2 && r3.push(g(l2, a4.marks)), i3 = true;
281
- } else r3.push(a4);
282
- o3 = e3;
277
+ const t6 = r3 + a4.text.length;
278
+ if (!i3 && e2 >= r3 && e2 <= t6) {
279
+ const t7 = e2 - r3, c3 = a4.text.slice(0, t7), l2 = a4.text.slice(t7);
280
+ c3 && o3.push(g(c3, a4.marks)), o3.push(g(n4, s2)), l2 && o3.push(g(l2, a4.marks)), i3 = true;
281
+ } else o3.push(a4);
282
+ r3 = t6;
283
283
  }
284
- return i3 || r3.push(g(n4, s2)), r3;
285
- })(r2, n3.offset, n3.text, n3.marks);
286
- return { ...t4, children: Oe(t4.children, s(o2)) };
284
+ return i3 || o3.push(g(n4, s2)), o3;
285
+ })(o2, n3.offset, n3.text, n3.marks);
286
+ return { ...t4, children: Ht(t4.children, s(r2)) };
287
287
  });
288
288
  })(t2, n2);
289
289
  case "deleteText":
290
290
  return (function(t3, n3) {
291
- return Le(t3, n3.blockId, (t4) => {
292
- const r2 = (function(e2, t5, n4) {
291
+ return _t(t3, n3.blockId, (t4) => {
292
+ const o2 = (function(t5, e2, n4) {
293
293
  const s2 = [];
294
- let r3 = 0;
295
- for (const o2 of e2) {
296
- if (d(o2)) {
297
- const e4 = r3 + 1;
298
- (e4 <= t5 || r3 >= n4) && s2.push(o2), r3 = e4;
294
+ let o3 = 0;
295
+ for (const r2 of t5) {
296
+ if (d(r2)) {
297
+ const t7 = o3 + 1;
298
+ (t7 <= e2 || o3 >= n4) && s2.push(r2), o3 = t7;
299
299
  continue;
300
300
  }
301
- const e3 = r3 + o2.text.length;
302
- if (e3 <= t5 || r3 >= n4) s2.push(o2);
301
+ const t6 = o3 + r2.text.length;
302
+ if (t6 <= e2 || o3 >= n4) s2.push(r2);
303
303
  else {
304
- const e4 = Math.max(0, t5 - r3), i3 = Math.min(o2.text.length, n4 - r3), a4 = o2.text.slice(0, e4) + o2.text.slice(i3);
305
- a4.length > 0 && s2.push(g(a4, o2.marks));
304
+ const t7 = Math.max(0, e2 - o3), i3 = Math.min(r2.text.length, n4 - o3), a4 = r2.text.slice(0, t7) + r2.text.slice(i3);
305
+ a4.length > 0 && s2.push(g(a4, r2.marks));
306
306
  }
307
- r3 = e3;
307
+ o3 = t6;
308
308
  }
309
309
  return s2;
310
310
  })(e(t4), n3.from, n3.to);
311
- return { ...t4, children: Oe(t4.children, s(r2)) };
311
+ return { ...t4, children: Ht(t4.children, s(o2)) };
312
312
  });
313
313
  })(t2, n2);
314
314
  case "splitBlock":
315
315
  return (function(t3, n3) {
316
- const i3 = t3.children.findIndex((e2) => e2.id === n3.blockId);
316
+ const i3 = t3.children.findIndex((t4) => t4.id === n3.blockId);
317
317
  if (-1 !== i3) {
318
318
  const a4 = t3.children[i3];
319
319
  if (!a4) return t3;
320
- const c3 = e(a4), l2 = r(a4), h3 = He(c3, 0, n3.offset), d2 = He(c3, n3.offset, l2), u2 = { ...a4, children: s(h3) }, p2 = o(a4.type, s(d2), n3.newBlockId, a4.attrs), f3 = [...t3.children];
321
- return f3.splice(i3, 1, u2, p2), { children: f3 };
320
+ const c3 = e(a4), l2 = o(a4), d2 = $t(c3, 0, n3.offset), h3 = $t(c3, n3.offset, l2), u2 = { ...a4, children: s(d2) }, p2 = r(a4.type, s(h3), n3.newBlockId, a4.attrs), f2 = [...t3.children];
321
+ return f2.splice(i3, 1, u2, p2), { children: f2 };
322
322
  }
323
- return { children: t3.children.map((e2) => Pe(e2, n3) ?? e2) };
323
+ return { children: t3.children.map((t4) => Lt(t4, n3) ?? t4) };
324
324
  })(t2, n2);
325
325
  case "mergeBlocks":
326
326
  return (function(t3, n3) {
327
- const r2 = t3.children.findIndex((e2) => e2.id === n3.targetBlockId), o2 = t3.children.findIndex((e2) => e2.id === n3.sourceBlockId);
328
- if (-1 !== r2 && -1 !== o2) {
329
- const i3 = t3.children[r2], a4 = t3.children[o2];
327
+ const o2 = t3.children.findIndex((t4) => t4.id === n3.targetBlockId), r2 = t3.children.findIndex((t4) => t4.id === n3.sourceBlockId);
328
+ if (-1 !== o2 && -1 !== r2) {
329
+ const i3 = t3.children[o2], a4 = t3.children[r2];
330
330
  if (!i3 || !a4) return t3;
331
- const c3 = e(i3), l2 = e(a4), h3 = s([...c3, ...l2]), d2 = { ...i3, children: h3 };
332
- return { children: t3.children.filter((e2) => e2.id !== n3.sourceBlockId).map((e2) => e2.id === n3.targetBlockId ? d2 : e2) };
331
+ const c3 = e(i3), l2 = e(a4), d2 = s([...c3, ...l2]), h3 = { ...i3, children: d2 };
332
+ return { children: t3.children.filter((t4) => t4.id !== n3.sourceBlockId).map((t4) => t4.id === n3.targetBlockId ? h3 : t4) };
333
333
  }
334
- return { children: t3.children.map((e2) => De(e2, n3) ?? e2) };
334
+ return { children: t3.children.map((t4) => Dt(t4, n3) ?? t4) };
335
335
  })(t2, n2);
336
336
  case "addMark":
337
337
  return (function(t3, n3) {
338
- return Le(t3, n3.blockId, (t4) => {
339
- const r2 = ze(e(t4), n3.from, n3.to, n3.mark, true);
340
- return { ...t4, children: Oe(t4.children, s(r2)) };
338
+ return _t(t3, n3.blockId, (t4) => {
339
+ const o2 = zt(e(t4), n3.from, n3.to, n3.mark, true);
340
+ return { ...t4, children: Ht(t4.children, s(o2)) };
341
341
  });
342
342
  })(t2, n2);
343
343
  case "removeMark":
344
344
  return (function(t3, n3) {
345
- return Le(t3, n3.blockId, (t4) => {
346
- const r2 = ze(e(t4), n3.from, n3.to, n3.mark, false);
347
- return { ...t4, children: Oe(t4.children, s(r2)) };
345
+ return _t(t3, n3.blockId, (t4) => {
346
+ const o2 = zt(e(t4), n3.from, n3.to, n3.mark, false);
347
+ return { ...t4, children: Ht(t4.children, s(o2)) };
348
348
  });
349
349
  })(t2, n2);
350
350
  case "setStoredMarks":
351
351
  return t2;
352
352
  case "setBlockType":
353
- return (function(e2, t3) {
354
- return Le(e2, t3.blockId, (e3) => ({ ...e3, type: t3.nodeType, ...t3.attrs ? { attrs: t3.attrs } : { attrs: void 0 } }));
353
+ return (function(t3, e2) {
354
+ return _t(t3, e2.blockId, (t4) => ({ ...t4, type: e2.nodeType, ...e2.attrs ? { attrs: e2.attrs } : { attrs: void 0 } }));
355
355
  })(t2, n2);
356
356
  case "insertNode":
357
- return (function(e2, t3) {
358
- if (0 === t3.parentPath.length) {
359
- const n3 = [...e2.children];
360
- return n3.splice(t3.index, 0, t3.node), { children: n3 };
357
+ return (function(t3, e2) {
358
+ if (0 === e2.parentPath.length) {
359
+ const n3 = [...t3.children];
360
+ return n3.splice(e2.index, 0, e2.node), { children: n3 };
361
361
  }
362
- return Fe(e2, t3.parentPath, (e3) => {
363
- const n3 = [...e3.children];
364
- return n3.splice(t3.index, 0, t3.node), { ...e3, children: n3 };
362
+ return jt(t3, e2.parentPath, (t4) => {
363
+ const n3 = [...t4.children];
364
+ return n3.splice(e2.index, 0, e2.node), { ...t4, children: n3 };
365
365
  });
366
366
  })(t2, n2);
367
367
  case "removeNode":
368
- return (function(e2, t3) {
369
- if (0 === t3.parentPath.length) {
370
- const n3 = [...e2.children];
371
- return n3.splice(t3.index, 1), { children: n3 };
368
+ return (function(t3, e2) {
369
+ if (0 === e2.parentPath.length) {
370
+ const n3 = [...t3.children];
371
+ return n3.splice(e2.index, 1), { children: n3 };
372
372
  }
373
- return Fe(e2, t3.parentPath, (e3) => {
374
- const n3 = [...e3.children];
375
- return n3.splice(t3.index, 1), { ...e3, children: n3 };
373
+ return jt(t3, e2.parentPath, (t4) => {
374
+ const n3 = [...t4.children];
375
+ return n3.splice(e2.index, 1), { ...t4, children: n3 };
376
376
  });
377
377
  })(t2, n2);
378
378
  case "setNodeAttr":
379
- return (function(e2, t3) {
380
- const n3 = t3.path[t3.path.length - 1];
381
- return n3 ? Le(e2, n3, (e3) => ({ ...e3, attrs: t3.attrs })) : e2;
379
+ return (function(t3, e2) {
380
+ const n3 = e2.path[e2.path.length - 1];
381
+ return n3 ? _t(t3, n3, (t4) => ({ ...t4, attrs: e2.attrs })) : t3;
382
382
  })(t2, n2);
383
383
  case "insertInlineNode":
384
384
  return (function(t3, n3) {
385
- return Le(t3, n3.blockId, (t4) => {
386
- const r2 = (function(e2, t5, n4) {
385
+ return _t(t3, n3.blockId, (t4) => {
386
+ const o2 = (function(t5, e2, n4) {
387
387
  const s2 = [];
388
- let r3 = 0, o2 = false;
389
- for (const i3 of e2) {
388
+ let o3 = 0, r2 = false;
389
+ for (const i3 of t5) {
390
390
  if (d(i3)) {
391
- o2 || t5 !== r3 || (s2.push(n4), o2 = true), s2.push(i3), r3 += 1;
391
+ r2 || e2 !== o3 || (s2.push(n4), r2 = true), s2.push(i3), o3 += 1;
392
392
  continue;
393
393
  }
394
- const e3 = r3 + i3.text.length;
395
- if (!o2 && t5 >= r3 && t5 <= e3) {
396
- const e4 = t5 - r3, a4 = i3.text.slice(0, e4), c3 = i3.text.slice(e4);
397
- a4 && s2.push(g(a4, i3.marks)), s2.push(n4), c3 && s2.push(g(c3, i3.marks)), o2 = true;
394
+ const t6 = o3 + i3.text.length;
395
+ if (!r2 && e2 >= o3 && e2 <= t6) {
396
+ const t7 = e2 - o3, a4 = i3.text.slice(0, t7), c3 = i3.text.slice(t7);
397
+ a4 && s2.push(g(a4, i3.marks)), s2.push(n4), c3 && s2.push(g(c3, i3.marks)), r2 = true;
398
398
  } else s2.push(i3);
399
- r3 = e3;
399
+ o3 = t6;
400
400
  }
401
- return o2 || s2.push(n4), s2;
401
+ return r2 || s2.push(n4), s2;
402
402
  })(e(t4), n3.offset, n3.node);
403
- return { ...t4, children: Oe(t4.children, s(r2)) };
403
+ return { ...t4, children: Ht(t4.children, s(o2)) };
404
404
  });
405
405
  })(t2, n2);
406
406
  case "removeInlineNode":
407
407
  return (function(t3, n3) {
408
- return Le(t3, n3.blockId, (t4) => {
409
- const r2 = (function(e2, t5) {
408
+ return _t(t3, n3.blockId, (t4) => {
409
+ const o2 = (function(t5, e2) {
410
410
  const n4 = [];
411
411
  let s2 = 0;
412
- for (const r3 of e2) d(r3) ? (s2 !== t5 && n4.push(r3), s2 += 1) : (n4.push(r3), s2 += r3.text.length);
412
+ for (const o3 of t5) d(o3) ? (s2 !== e2 && n4.push(o3), s2 += 1) : (n4.push(o3), s2 += o3.text.length);
413
413
  return n4;
414
414
  })(e(t4), n3.offset);
415
- return { ...t4, children: Oe(t4.children, s(r2)) };
415
+ return { ...t4, children: Ht(t4.children, s(o2)) };
416
416
  });
417
417
  })(t2, n2);
418
418
  case "setInlineNodeAttr":
419
419
  return (function(t3, n3) {
420
- return Le(t3, n3.blockId, (t4) => {
421
- const s2 = (function(e2, t5, n4) {
420
+ return _t(t3, n3.blockId, (t4) => {
421
+ const s2 = (function(t5, e2, n4) {
422
422
  const s3 = [];
423
- let r2 = 0;
424
- for (const o2 of e2) d(o2) ? (r2 === t5 ? s3.push({ ...o2, attrs: n4 }) : s3.push(o2), r2 += 1) : (s3.push(o2), r2 += o2.text.length);
423
+ let o2 = 0;
424
+ for (const r2 of t5) d(r2) ? (o2 === e2 ? s3.push({ ...r2, attrs: n4 }) : s3.push(r2), o2 += 1) : (s3.push(r2), o2 += r2.text.length);
425
425
  return s3;
426
426
  })(e(t4), n3.offset, n3.attrs);
427
- return { ...t4, children: Oe(t4.children, s2) };
427
+ return { ...t4, children: Ht(t4.children, s2) };
428
428
  });
429
429
  })(t2, n2);
430
430
  }
431
431
  }
432
- function Pe(t2, n2) {
433
- const i3 = t2.children.findIndex((e2) => l(e2) && e2.id === n2.blockId);
432
+ function Lt(t2, n2) {
433
+ const i3 = t2.children.findIndex((t3) => l(t3) && t3.id === n2.blockId);
434
434
  if (-1 !== i3) {
435
- const a5 = t2.children[i3], c4 = e(a5), l2 = r(a5), h3 = He(c4, 0, n2.offset), d2 = He(c4, n2.offset, l2), u2 = { ...a5, children: s(h3) }, p2 = o(a5.type, s(d2), n2.newBlockId, a5.attrs), f3 = [...t2.children];
436
- return f3.splice(i3, 1, u2, p2), { ...t2, children: f3 };
435
+ const a5 = t2.children[i3], c4 = e(a5), l2 = o(a5), d2 = $t(c4, 0, n2.offset), h3 = $t(c4, n2.offset, l2), u2 = { ...a5, children: s(d2) }, p2 = r(a5.type, s(h3), n2.newBlockId, a5.attrs), f2 = [...t2.children];
436
+ return f2.splice(i3, 1, u2, p2), { ...t2, children: f2 };
437
437
  }
438
438
  let a4 = false;
439
- const c3 = t2.children.map((e2) => {
440
- if (!l(e2)) return e2;
441
- const t3 = Pe(e2, n2);
442
- return t3 ? (a4 = true, t3) : e2;
439
+ const c3 = t2.children.map((t3) => {
440
+ if (!l(t3)) return t3;
441
+ const e2 = Lt(t3, n2);
442
+ return e2 ? (a4 = true, e2) : t3;
443
443
  });
444
444
  return a4 ? { ...t2, children: c3 } : null;
445
445
  }
446
- function De(t2, n2) {
447
- const r2 = t2.children.findIndex((e2) => l(e2) && e2.id === n2.targetBlockId), o2 = t2.children.findIndex((e2) => l(e2) && e2.id === n2.sourceBlockId);
448
- if (-1 !== r2 && -1 !== o2) {
449
- const i4 = t2.children[r2], a5 = t2.children[o2], c3 = e(i4), h3 = e(a5), d2 = s([...c3, ...h3]), u2 = { ...i4, children: d2 }, p2 = t2.children.filter((e2) => !l(e2) || e2.id !== n2.sourceBlockId).map((e2) => l(e2) && e2.id === n2.targetBlockId ? u2 : e2);
446
+ function Dt(t2, n2) {
447
+ const o2 = t2.children.findIndex((t3) => l(t3) && t3.id === n2.targetBlockId), r2 = t2.children.findIndex((t3) => l(t3) && t3.id === n2.sourceBlockId);
448
+ if (-1 !== o2 && -1 !== r2) {
449
+ const i4 = t2.children[o2], a5 = t2.children[r2], c3 = e(i4), d2 = e(a5), h3 = s([...c3, ...d2]), u2 = { ...i4, children: h3 }, p2 = t2.children.filter((t3) => !l(t3) || t3.id !== n2.sourceBlockId).map((t3) => l(t3) && t3.id === n2.targetBlockId ? u2 : t3);
450
450
  return { ...t2, children: p2 };
451
451
  }
452
452
  let i3 = false;
453
- const a4 = t2.children.map((e2) => {
454
- if (!l(e2)) return e2;
455
- const t3 = De(e2, n2);
456
- return t3 ? (i3 = true, t3) : e2;
453
+ const a4 = t2.children.map((t3) => {
454
+ if (!l(t3)) return t3;
455
+ const e2 = Dt(t3, n2);
456
+ return e2 ? (i3 = true, e2) : t3;
457
457
  });
458
458
  return i3 ? { ...t2, children: a4 } : null;
459
459
  }
460
- function Le(e2, t2, n2) {
461
- return { children: _e(e2.children, t2, n2) };
460
+ function _t(t2, e2, n2) {
461
+ return { children: Ot(t2.children, e2, n2) };
462
462
  }
463
- function _e(e2, t2, n2) {
464
- return e2.map((e3) => {
465
- if (!l(e3)) return e3;
466
- if (e3.id === t2) return n2(e3);
467
- const s2 = _e(e3.children, t2, n2);
468
- return s2 === e3.children ? e3 : { ...e3, children: s2 };
463
+ function Ot(t2, e2, n2) {
464
+ return t2.map((t3) => {
465
+ if (!l(t3)) return t3;
466
+ if (t3.id === e2) return n2(t3);
467
+ const s2 = Ot(t3.children, e2, n2);
468
+ return s2 === t3.children ? t3 : { ...t3, children: s2 };
469
469
  });
470
470
  }
471
- function Oe(e2, t2) {
472
- if (e2.every((e3) => m(e3) || d(e3))) return t2;
473
- const n2 = e2.filter((e3) => !m(e3) && !d(e3));
474
- return [...t2, ...n2];
471
+ function Ht(t2, e2) {
472
+ if (t2.every((t3) => m(t3) || d(t3))) return e2;
473
+ const n2 = t2.filter((t3) => !m(t3) && !d(t3));
474
+ return [...e2, ...n2];
475
475
  }
476
- function He(e2, t2, n2) {
476
+ function $t(t2, e2, n2) {
477
477
  const s2 = [];
478
- let r2 = 0;
479
- for (const o2 of e2) {
480
- if (d(o2)) {
481
- const e4 = r2 + 1;
482
- e4 > t2 && r2 < n2 && s2.push(o2), r2 = e4;
478
+ let o2 = 0;
479
+ for (const r2 of t2) {
480
+ if (d(r2)) {
481
+ const t4 = o2 + 1;
482
+ t4 > e2 && o2 < n2 && s2.push(r2), o2 = t4;
483
483
  continue;
484
484
  }
485
- const e3 = r2 + o2.text.length;
486
- if (e3 <= t2 || r2 >= n2) ;
485
+ const t3 = o2 + r2.text.length;
486
+ if (t3 <= e2 || o2 >= n2) ;
487
487
  else {
488
- const e4 = Math.max(0, t2 - r2), i3 = Math.min(o2.text.length, n2 - r2), a4 = o2.text.slice(e4, i3);
489
- a4.length > 0 && s2.push(g(a4, o2.marks));
488
+ const t4 = Math.max(0, e2 - o2), i3 = Math.min(r2.text.length, n2 - o2), a4 = r2.text.slice(t4, i3);
489
+ a4.length > 0 && s2.push(g(a4, r2.marks));
490
490
  }
491
- r2 = e3;
491
+ o2 = t3;
492
492
  }
493
493
  return 0 === s2.length && s2.push(g("")), s2;
494
494
  }
495
- function ze(e2, t2, n2, s2, r2) {
496
- const o2 = [];
495
+ function zt(t2, e2, n2, s2, o2) {
496
+ const r2 = [];
497
497
  let i3 = 0;
498
- for (const a4 of e2) {
498
+ for (const a4 of t2) {
499
499
  if (d(a4)) {
500
- o2.push(a4), i3 += 1;
500
+ r2.push(a4), i3 += 1;
501
501
  continue;
502
502
  }
503
- const e3 = i3 + a4.text.length;
504
- if (e3 <= t2 || i3 >= n2) o2.push(a4);
505
- else if (i3 >= t2 && e3 <= n2) {
506
- const e4 = r2 ? k(a4.marks, s2) : T(a4.marks, s2.type);
507
- o2.push(g(a4.text, e4));
503
+ const t3 = i3 + a4.text.length;
504
+ if (t3 <= e2 || i3 >= n2) r2.push(a4);
505
+ else if (i3 >= e2 && t3 <= n2) {
506
+ const t4 = o2 ? k(a4.marks, s2) : S(a4.marks, s2.type);
507
+ r2.push(g(a4.text, t4));
508
508
  } else {
509
- const e4 = Math.max(0, t2 - i3), c3 = Math.min(a4.text.length, n2 - i3), l2 = a4.text.slice(0, e4), h3 = a4.text.slice(e4, c3), d2 = a4.text.slice(c3);
510
- if (l2 && o2.push(g(l2, a4.marks)), h3) {
511
- const e5 = r2 ? k(a4.marks, s2) : T(a4.marks, s2.type);
512
- o2.push(g(h3, e5));
509
+ const t4 = Math.max(0, e2 - i3), c3 = Math.min(a4.text.length, n2 - i3), l2 = a4.text.slice(0, t4), d2 = a4.text.slice(t4, c3), h3 = a4.text.slice(c3);
510
+ if (l2 && r2.push(g(l2, a4.marks)), d2) {
511
+ const t5 = o2 ? k(a4.marks, s2) : S(a4.marks, s2.type);
512
+ r2.push(g(d2, t5));
513
513
  }
514
- d2 && o2.push(g(d2, a4.marks));
514
+ h3 && r2.push(g(h3, a4.marks));
515
515
  }
516
- i3 = e3;
516
+ i3 = t3;
517
517
  }
518
- return o2;
518
+ return r2;
519
519
  }
520
- function Fe(e2, t2, n2) {
521
- if (0 === t2.length) return e2;
522
- const s2 = t2[0];
523
- return s2 ? { children: e2.children.map((e3) => l(e3) && e3.id === s2 ? 1 === t2.length ? n2(e3) : $e(e3, t2, 1, n2) : e3) } : e2;
520
+ function jt(t2, e2, n2) {
521
+ if (0 === e2.length) return t2;
522
+ const s2 = e2[0];
523
+ return s2 ? { children: t2.children.map((t3) => l(t3) && t3.id === s2 ? 1 === e2.length ? n2(t3) : Ft(t3, e2, 1, n2) : t3) } : t2;
524
524
  }
525
- function $e(e2, t2, n2, s2) {
526
- const r2 = t2[n2];
527
- if (!r2) return e2;
528
- const o2 = e2.children.map((e3) => l(e3) && e3.id === r2 ? n2 === t2.length - 1 ? s2(e3) : $e(e3, t2, n2 + 1, s2) : e3);
529
- return { ...e2, children: o2 };
525
+ function Ft(t2, e2, n2, s2) {
526
+ const o2 = e2[n2];
527
+ if (!o2) return t2;
528
+ const r2 = t2.children.map((t3) => l(t3) && t3.id === o2 ? n2 === e2.length - 1 ? s2(t3) : Ft(t3, e2, n2 + 1, s2) : t3);
529
+ return { ...t2, children: r2 };
530
530
  }
531
- function je(e2) {
532
- switch (e2.type) {
531
+ function Ut(t2) {
532
+ switch (t2.type) {
533
533
  case "insertText":
534
- return { type: "deleteText", blockId: e2.blockId, from: e2.offset, to: e2.offset + e2.text.length, deletedText: e2.text, deletedMarks: e2.marks, deletedSegments: e2.segments ?? [{ text: e2.text, marks: [...e2.marks] }], ...e2.path ? { path: e2.path } : {} };
534
+ return { type: "deleteText", blockId: t2.blockId, from: t2.offset, to: t2.offset + t2.text.length, deletedText: t2.text, deletedMarks: t2.marks, deletedSegments: t2.segments ?? [{ text: t2.text, marks: [...t2.marks] }], ...t2.path ? { path: t2.path } : {} };
535
535
  case "deleteText":
536
- return { type: "insertText", blockId: e2.blockId, offset: e2.from, text: e2.deletedText, marks: e2.deletedMarks, segments: e2.deletedSegments, ...e2.path ? { path: e2.path } : {} };
536
+ return { type: "insertText", blockId: t2.blockId, offset: t2.from, text: t2.deletedText, marks: t2.deletedMarks, segments: t2.deletedSegments, ...t2.path ? { path: t2.path } : {} };
537
537
  case "splitBlock":
538
- return { type: "mergeBlocks", targetBlockId: e2.blockId, sourceBlockId: e2.newBlockId, targetLengthBefore: e2.offset, ...e2.path ? { path: e2.path } : {} };
538
+ return { type: "mergeBlocks", targetBlockId: t2.blockId, sourceBlockId: t2.newBlockId, targetLengthBefore: t2.offset, ...t2.path ? { path: t2.path } : {} };
539
539
  case "mergeBlocks":
540
- return { type: "splitBlock", blockId: e2.targetBlockId, offset: e2.targetLengthBefore, newBlockId: e2.sourceBlockId, ...e2.path ? { path: e2.path } : {} };
540
+ return { type: "splitBlock", blockId: t2.targetBlockId, offset: t2.targetLengthBefore, newBlockId: t2.sourceBlockId, ...t2.path ? { path: t2.path } : {} };
541
541
  case "addMark":
542
- return { type: "removeMark", blockId: e2.blockId, from: e2.from, to: e2.to, mark: e2.mark, ...e2.path ? { path: e2.path } : {} };
542
+ return { type: "removeMark", blockId: t2.blockId, from: t2.from, to: t2.to, mark: t2.mark, ...t2.path ? { path: t2.path } : {} };
543
543
  case "removeMark":
544
- return { type: "addMark", blockId: e2.blockId, from: e2.from, to: e2.to, mark: e2.mark, ...e2.path ? { path: e2.path } : {} };
544
+ return { type: "addMark", blockId: t2.blockId, from: t2.from, to: t2.to, mark: t2.mark, ...t2.path ? { path: t2.path } : {} };
545
545
  case "setStoredMarks":
546
- return { type: "setStoredMarks", marks: e2.previousMarks, previousMarks: e2.marks };
546
+ return { type: "setStoredMarks", marks: t2.previousMarks, previousMarks: t2.marks };
547
547
  case "setBlockType":
548
- return { type: "setBlockType", blockId: e2.blockId, nodeType: e2.previousNodeType, attrs: e2.previousAttrs, previousNodeType: e2.nodeType, previousAttrs: e2.attrs, ...e2.path ? { path: e2.path } : {} };
548
+ return { type: "setBlockType", blockId: t2.blockId, nodeType: t2.previousNodeType, attrs: t2.previousAttrs, previousNodeType: t2.nodeType, previousAttrs: t2.attrs, ...t2.path ? { path: t2.path } : {} };
549
549
  case "insertNode":
550
- return { type: "removeNode", parentPath: e2.parentPath, index: e2.index, removedNode: e2.node };
550
+ return { type: "removeNode", parentPath: t2.parentPath, index: t2.index, removedNode: t2.node };
551
551
  case "removeNode":
552
- return { type: "insertNode", parentPath: e2.parentPath, index: e2.index, node: e2.removedNode };
552
+ return { type: "insertNode", parentPath: t2.parentPath, index: t2.index, node: t2.removedNode };
553
553
  case "setNodeAttr":
554
- return { type: "setNodeAttr", path: e2.path, attrs: e2.previousAttrs, previousAttrs: e2.attrs };
554
+ return { type: "setNodeAttr", path: t2.path, attrs: t2.previousAttrs, previousAttrs: t2.attrs };
555
555
  case "insertInlineNode":
556
- return { type: "removeInlineNode", blockId: e2.blockId, offset: e2.offset, removedNode: e2.node, ...e2.path ? { path: e2.path } : {} };
556
+ return { type: "removeInlineNode", blockId: t2.blockId, offset: t2.offset, removedNode: t2.node, ...t2.path ? { path: t2.path } : {} };
557
557
  case "removeInlineNode":
558
- return { type: "insertInlineNode", blockId: e2.blockId, offset: e2.offset, node: e2.removedNode, ...e2.path ? { path: e2.path } : {} };
558
+ return { type: "insertInlineNode", blockId: t2.blockId, offset: t2.offset, node: t2.removedNode, ...t2.path ? { path: t2.path } : {} };
559
559
  case "setInlineNodeAttr":
560
- return { type: "setInlineNodeAttr", blockId: e2.blockId, offset: e2.offset, attrs: e2.previousAttrs, previousAttrs: e2.attrs, ...e2.path ? { path: e2.path } : {} };
560
+ return { type: "setInlineNodeAttr", blockId: t2.blockId, offset: t2.offset, attrs: t2.previousAttrs, previousAttrs: t2.attrs, ...t2.path ? { path: t2.path } : {} };
561
561
  }
562
562
  }
563
- function Ue(e2) {
564
- return { steps: e2.steps.map(je).reverse(), selectionBefore: e2.selectionAfter, selectionAfter: e2.selectionBefore, storedMarksAfter: null, metadata: { origin: "history", timestamp: Date.now() } };
563
+ function Kt(t2) {
564
+ return { steps: t2.steps.map(Ut).reverse(), selectionBefore: t2.selectionAfter, selectionAfter: t2.selectionBefore, storedMarksAfter: null, metadata: { origin: "history", timestamp: Date.now() } };
565
565
  }
566
- class Ke {
566
+ class Vt {
567
567
  steps = [];
568
568
  selection;
569
569
  storedMarks;
570
570
  selectionBefore;
571
571
  origin;
572
572
  workingDoc;
573
- constructor(e2, t2, n2 = "api", s2) {
574
- this.selection = e2, this.selectionBefore = e2, this.storedMarks = t2, this.origin = n2, this.workingDoc = s2 ?? null;
573
+ constructor(t2, e2, n2 = "api", s2) {
574
+ this.selection = t2, this.selectionBefore = t2, this.storedMarks = e2, this.origin = n2, this.workingDoc = s2 ?? null;
575
575
  }
576
- insertText(e2, t2, n2, s2, r2) {
577
- const o2 = { type: "insertText", blockId: e2, offset: t2, text: n2, marks: s2, ...r2 ? { segments: r2 } : {} };
578
- return this.steps.push(o2), this.advanceDoc(o2), this;
576
+ insertText(t2, e2, n2, s2, o2) {
577
+ const r2 = { type: "insertText", blockId: t2, offset: e2, text: n2, marks: s2, ...o2 ? { segments: o2 } : {} };
578
+ return this.steps.push(r2), this.advanceDoc(r2), this;
579
579
  }
580
- deleteText(e2, t2, n2, s2, r2, o2) {
580
+ deleteText(t2, e2, n2, s2, o2, r2) {
581
581
  let i3;
582
- if (o2) i3 = o2;
582
+ if (r2) i3 = r2;
583
583
  else if (this.workingDoc) {
584
- const o3 = be(this.workingDoc, e2);
585
- i3 = o3 ? N(o3, t2, n2) : [{ text: s2, marks: [...r2] }];
586
- } else i3 = [{ text: s2, marks: [...r2] }];
587
- const a4 = { type: "deleteText", blockId: e2, from: t2, to: n2, deletedText: s2, deletedMarks: r2, deletedSegments: i3 };
584
+ const r3 = yt(this.workingDoc, t2);
585
+ i3 = r3 ? T(r3, e2, n2) : [{ text: s2, marks: [...o2] }];
586
+ } else i3 = [{ text: s2, marks: [...o2] }];
587
+ const a4 = { type: "deleteText", blockId: t2, from: e2, to: n2, deletedText: s2, deletedMarks: o2, deletedSegments: i3 };
588
588
  return this.steps.push(a4), this.advanceDoc(a4), this;
589
589
  }
590
- deleteTextAt(e2, t2, n2) {
590
+ deleteTextAt(t2, e2, n2) {
591
591
  const s2 = this.workingDoc;
592
592
  if (!s2) throw new Error("deleteTextAt requires a document. Use state.transaction() or provide doc to constructor.");
593
- const r2 = be(s2, e2);
594
- if (!r2) throw new Error(`Block "${e2}" not found in working document.`);
595
- const o2 = M(r2).slice(t2, n2), i3 = I(r2, t2), a4 = N(r2, t2, n2);
596
- return this.deleteText(e2, t2, n2, o2, i3, a4);
593
+ const o2 = yt(s2, t2);
594
+ if (!o2) throw new Error(`Block "${t2}" not found in working document.`);
595
+ const r2 = E(o2).slice(e2, n2), i3 = N(o2, e2), a4 = T(o2, e2, n2);
596
+ return this.deleteText(t2, e2, n2, r2, i3, a4);
597
597
  }
598
- splitBlock(e2, t2, n2) {
599
- const s2 = { type: "splitBlock", blockId: e2, offset: t2, newBlockId: n2 };
598
+ splitBlock(t2, e2, n2) {
599
+ const s2 = { type: "splitBlock", blockId: t2, offset: e2, newBlockId: n2 };
600
600
  return this.steps.push(s2), this.advanceDoc(s2), this;
601
601
  }
602
- mergeBlocks(e2, t2, n2) {
603
- const s2 = { type: "mergeBlocks", targetBlockId: e2, sourceBlockId: t2, targetLengthBefore: n2 };
602
+ mergeBlocks(t2, e2, n2) {
603
+ const s2 = { type: "mergeBlocks", targetBlockId: t2, sourceBlockId: e2, targetLengthBefore: n2 };
604
604
  return this.steps.push(s2), this.advanceDoc(s2), this;
605
605
  }
606
- mergeBlocksAt(e2, t2) {
606
+ mergeBlocksAt(t2, e2) {
607
607
  const n2 = this.workingDoc;
608
608
  if (!n2) throw new Error("mergeBlocksAt requires a document. Use state.transaction() or provide doc to constructor.");
609
- const s2 = be(n2, e2);
610
- if (!s2) throw new Error(`Target block "${e2}" not found in working document.`);
611
- const o2 = r(s2);
612
- return this.mergeBlocks(e2, t2, o2);
609
+ const s2 = yt(n2, t2);
610
+ if (!s2) throw new Error(`Target block "${t2}" not found in working document.`);
611
+ const r2 = o(s2);
612
+ return this.mergeBlocks(t2, e2, r2);
613
613
  }
614
- addMark(e2, t2, n2, s2) {
615
- const r2 = { type: "addMark", blockId: e2, from: t2, to: n2, mark: s2 };
616
- return this.steps.push(r2), this.advanceDoc(r2), this;
614
+ addMark(t2, e2, n2, s2) {
615
+ const o2 = { type: "addMark", blockId: t2, from: e2, to: n2, mark: s2 };
616
+ return this.steps.push(o2), this.advanceDoc(o2), this;
617
617
  }
618
- removeMark(e2, t2, n2, s2) {
619
- const r2 = { type: "removeMark", blockId: e2, from: t2, to: n2, mark: s2 };
620
- return this.steps.push(r2), this.advanceDoc(r2), this;
618
+ removeMark(t2, e2, n2, s2) {
619
+ const o2 = { type: "removeMark", blockId: t2, from: e2, to: n2, mark: s2 };
620
+ return this.steps.push(o2), this.advanceDoc(o2), this;
621
621
  }
622
- setBlockType(e2, t2, n2) {
622
+ setBlockType(t2, e2, n2) {
623
623
  const s2 = this.workingDoc;
624
624
  if (!s2) throw new Error("setBlockType requires a document. Use state.transaction() or provide doc to constructor.");
625
- const r2 = be(s2, e2);
626
- if (!r2) throw new Error(`Block "${e2}" not found in working document.`);
627
- const o2 = { type: "setBlockType", blockId: e2, nodeType: t2, ...n2 ? { attrs: n2 } : {}, previousNodeType: r2.type, ...r2.attrs ? { previousAttrs: r2.attrs } : {} };
628
- return this.steps.push(o2), this.advanceDoc(o2), this;
625
+ const o2 = yt(s2, t2);
626
+ if (!o2) throw new Error(`Block "${t2}" not found in working document.`);
627
+ const r2 = { type: "setBlockType", blockId: t2, nodeType: e2, ...n2 ? { attrs: n2 } : {}, previousNodeType: o2.type, ...o2.attrs ? { previousAttrs: o2.attrs } : {} };
628
+ return this.steps.push(r2), this.advanceDoc(r2), this;
629
629
  }
630
- insertNode(e2, t2, n2) {
631
- const s2 = { type: "insertNode", parentPath: e2, index: t2, node: n2 };
630
+ insertNode(t2, e2, n2) {
631
+ const s2 = { type: "insertNode", parentPath: t2, index: e2, node: n2 };
632
632
  return this.steps.push(s2), this.advanceDoc(s2), this;
633
633
  }
634
- removeNode(e2, t2) {
634
+ removeNode(t2, e2) {
635
635
  const n2 = this.workingDoc;
636
636
  if (!n2) throw new Error("removeNode requires a document. Use state.transaction() or provide doc to constructor.");
637
- const s2 = (function(e3, t3, n3) {
638
- if (0 === t3.length) {
639
- const t4 = e3.children[n3];
640
- return t4 && l(t4) ? t4 : void 0;
637
+ const s2 = (function(t3, e3, n3) {
638
+ if (0 === e3.length) {
639
+ const e4 = t3.children[n3];
640
+ return e4 && l(e4) ? e4 : void 0;
641
641
  }
642
- const s3 = Se(e3, t3);
642
+ const s3 = kt(t3, e3);
643
643
  if (!s3) return;
644
- const r3 = s3.children[n3];
645
- return r3 && l(r3) ? r3 : void 0;
646
- })(n2, e2, t2);
647
- if (!s2) throw new Error(`Node at index ${t2} not found under parent path [${e2.join(", ")}].`);
648
- const r2 = { type: "removeNode", parentPath: e2, index: t2, removedNode: s2 };
649
- return this.steps.push(r2), this.advanceDoc(r2), this;
644
+ const o3 = s3.children[n3];
645
+ return o3 && l(o3) ? o3 : void 0;
646
+ })(n2, t2, e2);
647
+ if (!s2) throw new Error(`Node at index ${e2} not found under parent path [${t2.join(", ")}].`);
648
+ const o2 = { type: "removeNode", parentPath: t2, index: e2, removedNode: s2 };
649
+ return this.steps.push(o2), this.advanceDoc(o2), this;
650
650
  }
651
- setNodeAttr(e2, t2) {
651
+ setNodeAttr(t2, e2) {
652
652
  const n2 = this.workingDoc;
653
653
  if (!n2) throw new Error("setNodeAttr requires a document. Use state.transaction() or provide doc to constructor.");
654
- const s2 = Se(n2, e2);
655
- if (!s2) throw new Error(`Node not found at path [${e2.join(", ")}].`);
656
- const r2 = { type: "setNodeAttr", path: e2, attrs: t2, ...s2.attrs ? { previousAttrs: s2.attrs } : {} };
657
- return this.steps.push(r2), this.advanceDoc(r2), this;
654
+ const s2 = kt(n2, t2);
655
+ if (!s2) throw new Error(`Node not found at path [${t2.join(", ")}].`);
656
+ const o2 = { type: "setNodeAttr", path: t2, attrs: e2, ...s2.attrs ? { previousAttrs: s2.attrs } : {} };
657
+ return this.steps.push(o2), this.advanceDoc(o2), this;
658
658
  }
659
- insertInlineNode(e2, t2, n2) {
660
- const s2 = { type: "insertInlineNode", blockId: e2, offset: t2, node: n2 };
659
+ insertInlineNode(t2, e2, n2) {
660
+ const s2 = { type: "insertInlineNode", blockId: t2, offset: e2, node: n2 };
661
661
  return this.steps.push(s2), this.advanceDoc(s2), this;
662
662
  }
663
- removeInlineNode(e2, t2) {
663
+ removeInlineNode(t2, e2) {
664
664
  const n2 = this.workingDoc;
665
665
  if (!n2) throw new Error("removeInlineNode requires a document. Use state.transaction() or provide doc.");
666
- const s2 = be(n2, e2);
667
- if (!s2) throw new Error(`Block "${e2}" not found in working document.`);
668
- const r2 = R(s2, t2);
669
- if (!r2 || "inline" !== r2.kind) throw new Error(`No InlineNode at offset ${t2} in block "${e2}".`);
670
- const o2 = { type: "removeInlineNode", blockId: e2, offset: t2, removedNode: r2.node };
671
- return this.steps.push(o2), this.advanceDoc(o2), this;
666
+ const s2 = yt(n2, t2);
667
+ if (!s2) throw new Error(`Block "${t2}" not found in working document.`);
668
+ const o2 = M(s2, e2);
669
+ if (!o2 || "inline" !== o2.kind) throw new Error(`No InlineNode at offset ${e2} in block "${t2}".`);
670
+ const r2 = { type: "removeInlineNode", blockId: t2, offset: e2, removedNode: o2.node };
671
+ return this.steps.push(r2), this.advanceDoc(r2), this;
672
672
  }
673
673
  setInlineNodeAttr(t2, n2, s2) {
674
- const r2 = this.workingDoc;
675
- if (!r2) throw new Error("setInlineNodeAttr requires a document. Use state.transaction() or provide doc.");
676
- const o2 = be(r2, t2);
677
- if (!o2) throw new Error(`Block "${t2}" not found in working document.`);
678
- const i3 = e(o2);
674
+ const o2 = this.workingDoc;
675
+ if (!o2) throw new Error("setInlineNodeAttr requires a document. Use state.transaction() or provide doc.");
676
+ const r2 = yt(o2, t2);
677
+ if (!r2) throw new Error(`Block "${t2}" not found in working document.`);
678
+ const i3 = e(r2);
679
679
  let a4 = 0;
680
680
  for (const e2 of i3) {
681
681
  if (d(e2) && a4 === n2) {
682
- const r3 = { type: "setInlineNodeAttr", blockId: t2, offset: n2, attrs: s2, previousAttrs: e2.attrs };
683
- return this.steps.push(r3), this.advanceDoc(r3), this;
682
+ const o3 = { type: "setInlineNodeAttr", blockId: t2, offset: n2, attrs: s2, previousAttrs: e2.attrs };
683
+ return this.steps.push(o3), this.advanceDoc(o3), this;
684
684
  }
685
685
  a4 += d(e2) ? 1 : e2.text.length;
686
686
  }
687
687
  throw new Error(`No InlineNode at offset ${n2} in block "${t2}".`);
688
688
  }
689
- setSelection(e2) {
690
- return this.selection = e2, this;
689
+ setSelection(t2) {
690
+ return this.selection = t2, this;
691
691
  }
692
- setNodeSelection(e2, t2) {
693
- return this.selection = H(e2, t2), this;
692
+ setNodeSelection(t2, e2) {
693
+ return this.selection = _(t2, e2), this;
694
694
  }
695
- setStoredMarks(e2, t2) {
696
- return this.steps.push({ type: "setStoredMarks", marks: e2, previousMarks: t2 }), this.storedMarks = e2, this;
695
+ setStoredMarks(t2, e2) {
696
+ return this.steps.push({ type: "setStoredMarks", marks: t2, previousMarks: e2 }), this.storedMarks = t2, this;
697
697
  }
698
698
  build() {
699
699
  return { steps: [...this.steps], selectionBefore: this.selectionBefore, selectionAfter: this.selection, storedMarksAfter: this.storedMarks, metadata: { origin: this.origin, timestamp: Date.now() } };
700
700
  }
701
- advanceDoc(e2) {
702
- this.workingDoc && (this.workingDoc = Ae(this.workingDoc, e2));
701
+ advanceDoc(t2) {
702
+ this.workingDoc && (this.workingDoc = Pt(this.workingDoc, t2));
703
703
  }
704
704
  }
705
- class Ve {
705
+ class qt {
706
706
  doc;
707
707
  selection;
708
708
  storedMarks;
709
709
  schema;
710
710
  _blockMap = null;
711
711
  _blockOrder = null;
712
- constructor(e2, t2, n2, s2) {
713
- this.doc = e2, this.selection = t2, this.storedMarks = n2, this.schema = s2;
714
- }
715
- static create(e2) {
716
- const t2 = e2?.schema ?? X(), n2 = e2?.doc ?? P(), s2 = n2.children[0], r2 = e2?.selection ?? F(s2 ? s2.id : pe(""), 0);
717
- return new Ve(n2, r2, null, t2);
718
- }
719
- transaction(e2 = "api") {
720
- return new Ke(this.selection, this.storedMarks, e2, this.doc);
721
- }
722
- apply(e2) {
723
- let t2 = this.doc;
724
- for (const n3 of e2.steps) t2 = Ae(t2, n3);
725
- const n2 = (function(e3, t3) {
726
- if ($(t3)) {
727
- if (be(e3, t3.nodeId)) return t3;
728
- const n4 = e3.children[0];
729
- return n4 ? F(n4.id, 0) : t3;
712
+ constructor(t2, e2, n2, s2) {
713
+ this.doc = t2, this.selection = e2, this.storedMarks = n2, this.schema = s2;
714
+ }
715
+ static create(t2) {
716
+ const e2 = t2?.schema ?? q(), n2 = t2?.doc ?? I(), s2 = n2.children[0], o2 = t2?.selection ?? O(s2 ? s2.id : ht(""), 0);
717
+ return new qt(n2, o2, null, e2);
718
+ }
719
+ transaction(t2 = "api") {
720
+ return new Vt(this.selection, this.storedMarks, t2, this.doc);
721
+ }
722
+ apply(t2) {
723
+ let e2 = this.doc;
724
+ for (const n3 of t2.steps) e2 = Pt(e2, n3);
725
+ const n2 = (function(t3, e3) {
726
+ if (H(e3)) {
727
+ if (yt(t3, e3.nodeId)) return e3;
728
+ const n4 = t3.children[0];
729
+ return n4 ? O(n4.id, 0) : e3;
730
730
  }
731
- const n3 = qe(e3, t3.anchor), s2 = qe(e3, t3.head);
732
- return n3 === t3.anchor && s2 === t3.head ? t3 : j(n3, s2);
733
- })(t2, e2.selectionAfter);
734
- return new Ve(t2, n2, e2.storedMarksAfter, this.schema);
735
- }
736
- getBlock(e2) {
737
- return this._blockMap ??= (function(e3) {
738
- const t2 = /* @__PURE__ */ new Map();
739
- return (function e4(n2) {
740
- for (const s2 of n2) l(s2) && (t2.set(s2.id, s2), e4(s2.children));
741
- })(e3.children), t2;
742
- })(this.doc), this._blockMap.get(e2);
731
+ const n3 = Wt(t3, e3.anchor), s2 = Wt(t3, e3.head);
732
+ return n3 === e3.anchor && s2 === e3.head ? e3 : $(n3, s2);
733
+ })(e2, t2.selectionAfter);
734
+ return new qt(e2, n2, t2.storedMarksAfter, this.schema);
735
+ }
736
+ getBlock(t2) {
737
+ return this._blockMap ??= (function(t3) {
738
+ const e2 = /* @__PURE__ */ new Map();
739
+ return (function t4(n2) {
740
+ for (const s2 of n2) l(s2) && (e2.set(s2.id, s2), t4(s2.children));
741
+ })(t3.children), e2;
742
+ })(this.doc), this._blockMap.get(t2);
743
743
  }
744
744
  getBlockOrder() {
745
- return this._blockOrder ??= (function(e2) {
746
- const t2 = [];
747
- return (function e3(n2) {
748
- for (const s2 of n2) l(s2) && (D(s2) ? t2.push(s2.id) : e3(s2.children));
749
- })(e2.children), t2;
745
+ return this._blockOrder ??= (function(t2) {
746
+ const e2 = [];
747
+ return (function t3(n2) {
748
+ for (const s2 of n2) l(s2) && (R(s2) ? e2.push(s2.id) : t3(s2.children));
749
+ })(t2.children), e2;
750
750
  })(this.doc), this._blockOrder;
751
751
  }
752
- getNodePath(e2) {
753
- return ve(this.doc, e2);
752
+ getNodePath(t2) {
753
+ return bt(this.doc, t2);
754
754
  }
755
- getParent(e2) {
756
- const t2 = ve(this.doc, e2);
757
- if (!t2 || t2.length <= 1) return;
758
- const n2 = t2[t2.length - 2];
759
- return n2 ? be(this.doc, n2) : void 0;
755
+ getParent(t2) {
756
+ const e2 = bt(this.doc, t2);
757
+ if (!e2 || e2.length <= 1) return;
758
+ const n2 = e2[e2.length - 2];
759
+ return n2 ? yt(this.doc, n2) : void 0;
760
760
  }
761
761
  toJSON() {
762
762
  return { doc: this.doc, selection: this.selection };
763
763
  }
764
- static fromJSON(e2, t2) {
765
- return new Ve(e2.doc, e2.selection, null, t2 ?? X());
764
+ static fromJSON(t2, e2) {
765
+ return new qt(t2.doc, t2.selection, null, e2 ?? q());
766
766
  }
767
767
  }
768
- function qe(e2, t2) {
769
- const n2 = be(e2, t2.blockId);
768
+ function Wt(t2, e2) {
769
+ const n2 = yt(t2, e2.blockId);
770
770
  if (n2) {
771
- const e3 = r(n2);
772
- return t2.offset > e3 ? U(t2.blockId, e3, t2.path) : t2;
771
+ const t3 = o(n2);
772
+ return e2.offset > t3 ? j(e2.blockId, t3, e2.path) : e2;
773
773
  }
774
- const s2 = e2.children[0];
775
- return s2 ? U(s2.id, 0) : t2;
774
+ const s2 = t2.children[0];
775
+ return s2 ? j(s2.id, 0) : e2;
776
776
  }
777
- class We {
777
+ class Xt {
778
778
  undoStack = [];
779
779
  redoStack = [];
780
780
  groupTimeoutMs;
781
781
  maxDepth;
782
782
  lastOrigin = null;
783
- constructor(e2) {
784
- this.groupTimeoutMs = e2?.groupTimeoutMs ?? 500, this.maxDepth = e2?.maxDepth ?? 100;
785
- }
786
- push(e2) {
787
- if ("history" === e2.metadata.origin) return;
788
- const t2 = e2.metadata.timestamp, n2 = this.undoStack[this.undoStack.length - 1];
789
- for (n2 && "input" === e2.metadata.origin && "input" === this.lastOrigin && t2 - n2.timestamp < this.groupTimeoutMs && this.isSameInputType(n2.transactions, e2) && n2 ? this.undoStack[this.undoStack.length - 1] = { transactions: [...n2.transactions, e2], timestamp: t2 } : this.undoStack.push({ transactions: [e2], timestamp: t2 }), this.lastOrigin = e2.metadata.origin, this.redoStack = []; this.undoStack.length > this.maxDepth; ) this.undoStack.shift();
790
- }
791
- undo(e2) {
792
- const t2 = this.undoStack.pop();
793
- if (!t2) return null;
794
- let n2 = e2;
783
+ constructor(t2) {
784
+ this.groupTimeoutMs = t2?.groupTimeoutMs ?? 500, this.maxDepth = t2?.maxDepth ?? 100;
785
+ }
786
+ push(t2) {
787
+ if ("history" === t2.metadata.origin) return;
788
+ const e2 = t2.metadata.timestamp, n2 = this.undoStack[this.undoStack.length - 1];
789
+ for (n2 && "input" === t2.metadata.origin && "input" === this.lastOrigin && e2 - n2.timestamp < this.groupTimeoutMs && this.isSameInputType(n2.transactions, t2) && n2 ? this.undoStack[this.undoStack.length - 1] = { transactions: [...n2.transactions, t2], timestamp: e2 } : this.undoStack.push({ transactions: [t2], timestamp: e2 }), this.lastOrigin = t2.metadata.origin, this.redoStack = []; this.undoStack.length > this.maxDepth; ) this.undoStack.shift();
790
+ }
791
+ undo(t2) {
792
+ const e2 = this.undoStack.pop();
793
+ if (!e2) return null;
794
+ let n2 = t2;
795
795
  const s2 = [];
796
- for (let e3 = t2.transactions.length - 1; e3 >= 0; e3--) {
797
- const r2 = t2.transactions[e3];
798
- if (!r2) continue;
799
- const o2 = Ue(r2);
800
- n2 = n2.apply(o2), s2.push(...o2.steps);
801
- }
802
- return this.redoStack.push({ transactions: t2.transactions, timestamp: Date.now() }), this.lastOrigin = null, { state: n2, transaction: { steps: s2, selectionBefore: e2.selection, selectionAfter: n2.selection, storedMarksAfter: n2.storedMarks, metadata: { origin: "history", timestamp: Date.now(), historyDirection: "undo" } } };
803
- }
804
- redo(e2) {
805
- const t2 = this.redoStack.pop();
806
- if (!t2) return null;
807
- let n2 = e2;
796
+ for (let t3 = e2.transactions.length - 1; t3 >= 0; t3--) {
797
+ const o2 = e2.transactions[t3];
798
+ if (!o2) continue;
799
+ const r2 = Kt(o2);
800
+ n2 = n2.apply(r2), s2.push(...r2.steps);
801
+ }
802
+ return this.redoStack.push({ transactions: e2.transactions, timestamp: Date.now() }), this.lastOrigin = null, { state: n2, transaction: { steps: s2, selectionBefore: t2.selection, selectionAfter: n2.selection, storedMarksAfter: n2.storedMarks, metadata: { origin: "history", timestamp: Date.now(), historyDirection: "undo" } } };
803
+ }
804
+ redo(t2) {
805
+ const e2 = this.redoStack.pop();
806
+ if (!e2) return null;
807
+ let n2 = t2;
808
808
  const s2 = [];
809
- for (const e3 of t2.transactions) n2 = n2.apply(e3), s2.push(...e3.steps);
810
- return this.undoStack.push({ transactions: t2.transactions, timestamp: Date.now() }), this.lastOrigin = null, { state: n2, transaction: { steps: s2, selectionBefore: e2.selection, selectionAfter: n2.selection, storedMarksAfter: n2.storedMarks, metadata: { origin: "history", timestamp: Date.now(), historyDirection: "redo" } } };
809
+ for (const t3 of e2.transactions) n2 = n2.apply(t3), s2.push(...t3.steps);
810
+ return this.undoStack.push({ transactions: e2.transactions, timestamp: Date.now() }), this.lastOrigin = null, { state: n2, transaction: { steps: s2, selectionBefore: t2.selection, selectionAfter: n2.selection, storedMarksAfter: n2.storedMarks, metadata: { origin: "history", timestamp: Date.now(), historyDirection: "redo" } } };
811
811
  }
812
812
  canUndo() {
813
813
  return this.undoStack.length > 0;
@@ -818,16 +818,16 @@ class We {
818
818
  clear() {
819
819
  this.undoStack = [], this.redoStack = [], this.lastOrigin = null;
820
820
  }
821
- isSameInputType(e2, t2) {
822
- const n2 = e2[e2.length - 1];
821
+ isSameInputType(t2, e2) {
822
+ const n2 = t2[t2.length - 1];
823
823
  if (!n2) return false;
824
- const s2 = n2.steps[0]?.type, r2 = t2.steps[0]?.type;
825
- return s2 === r2;
824
+ const s2 = n2.steps[0]?.type, o2 = e2.steps[0]?.type;
825
+ return s2 === o2;
826
826
  }
827
827
  }
828
- class Xe {
829
- constructor(e2, t2) {
830
- this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.undo = t2.undo, this.redo = t2.redo, this.schemaRegistry = t2.schemaRegistry, this.handleKeydown = this.onKeydown.bind(this), e2.addEventListener("keydown", this.handleKeydown);
828
+ class Jt {
829
+ constructor(t2, e2) {
830
+ this.element = t2, this.getState = e2.getState, this.dispatch = e2.dispatch, this.undo = e2.undo, this.redo = e2.redo, this.schemaRegistry = e2.schemaRegistry, this.handleKeydown = this.onKeydown.bind(this), t2.addEventListener("keydown", this.handleKeydown);
831
831
  }
832
832
  getState;
833
833
  dispatch;
@@ -835,79 +835,79 @@ class Xe {
835
835
  redo;
836
836
  schemaRegistry;
837
837
  handleKeydown;
838
- onKeydown(e2) {
839
- if (this.handleNodeSelectionKeys(e2)) return;
840
- if (this.handleArrowIntoVoid(e2)) return;
838
+ onKeydown(t2) {
839
+ if (this.handleNodeSelectionKeys(t2)) return;
840
+ if (this.handleArrowIntoVoid(t2)) return;
841
841
  if (this.schemaRegistry) {
842
- const t3 = Je(e2), n3 = this.schemaRegistry.getKeymaps();
842
+ const e3 = Qt(t2), n3 = this.schemaRegistry.getKeymaps();
843
843
  for (let s3 = n3.length - 1; s3 >= 0; s3--) {
844
- const r2 = n3[s3]?.[t3];
845
- if (r2?.()) return void e2.preventDefault();
844
+ const o2 = n3[s3]?.[e3];
845
+ if (o2?.()) return void t2.preventDefault();
846
846
  }
847
847
  }
848
- if (this.handleTab(e2)) return;
849
- if (this.handleEscape(e2)) return;
850
- if (!e2.metaKey && !e2.ctrlKey) return;
851
- const t2 = e2.key.toLowerCase(), n2 = this.getState();
848
+ if (this.handleTab(t2)) return;
849
+ if (this.handleEscape(t2)) return;
850
+ if (!t2.metaKey && !t2.ctrlKey) return;
851
+ const e2 = t2.key.toLowerCase(), n2 = this.getState();
852
852
  let s2 = null;
853
- return "z" !== t2 || e2.shiftKey ? "z" === t2 && e2.shiftKey || "y" === t2 && !e2.shiftKey ? (e2.preventDefault(), void this.redo()) : ("a" !== t2 || e2.shiftKey || (e2.preventDefault(), s2 = J(n2)), void (s2 && this.dispatch(s2))) : (e2.preventDefault(), void this.undo());
853
+ return "z" !== e2 || t2.shiftKey ? "z" === e2 && t2.shiftKey || "y" === e2 && !t2.shiftKey ? (t2.preventDefault(), void this.redo()) : ("a" !== e2 || t2.shiftKey || (t2.preventDefault(), s2 = W(n2)), void (s2 && this.dispatch(s2))) : (t2.preventDefault(), void this.undo());
854
854
  }
855
- handleNodeSelectionKeys(e2) {
856
- const t2 = this.getState(), n2 = t2.selection;
857
- if (!$(n2)) return false;
858
- const s2 = e2.key;
859
- if (!("ArrowLeft" !== s2 && "ArrowUp" !== s2 && "ArrowRight" !== s2 && "ArrowDown" !== s2 || e2.shiftKey || e2.metaKey || e2.ctrlKey || e2.altKey)) {
860
- const n3 = Q(t2, "ArrowLeft" === s2 ? "left" : "ArrowRight" === s2 ? "right" : "ArrowUp" === s2 ? "up" : "down");
861
- return !!n3 && (e2.preventDefault(), this.dispatch(n3), true);
855
+ handleNodeSelectionKeys(t2) {
856
+ const e2 = this.getState(), n2 = e2.selection;
857
+ if (!H(n2)) return false;
858
+ const s2 = t2.key;
859
+ if (!("ArrowLeft" !== s2 && "ArrowUp" !== s2 && "ArrowRight" !== s2 && "ArrowDown" !== s2 || t2.shiftKey || t2.metaKey || t2.ctrlKey || t2.altKey)) {
860
+ const n3 = X(e2, "ArrowLeft" === s2 ? "left" : "ArrowRight" === s2 ? "right" : "ArrowUp" === s2 ? "up" : "down");
861
+ return !!n3 && (t2.preventDefault(), this.dispatch(n3), true);
862
862
  }
863
863
  if ("Backspace" === s2 || "Delete" === s2) {
864
- e2.preventDefault();
865
- const s3 = G(t2, n2);
864
+ t2.preventDefault();
865
+ const s3 = J(e2, n2);
866
866
  return s3 && this.dispatch(s3), true;
867
867
  }
868
868
  if ("Enter" === s2) {
869
- e2.preventDefault();
870
- const n3 = Y(t2);
869
+ t2.preventDefault();
870
+ const n3 = Q(e2);
871
871
  return n3 && this.dispatch(n3), true;
872
872
  }
873
873
  if ("Escape" === s2) {
874
- e2.preventDefault();
875
- const n3 = Q(t2, "right");
874
+ t2.preventDefault();
875
+ const n3 = X(e2, "right");
876
876
  return n3 && this.dispatch(n3), true;
877
877
  }
878
878
  return false;
879
879
  }
880
- handleTab(e2) {
881
- if ("Tab" !== e2.key) return false;
882
- if (e2.metaKey || e2.ctrlKey || e2.altKey) return false;
883
- if (e2.preventDefault(), e2.shiftKey) return true;
884
- const t2 = this.getState(), n2 = Z(t2, " ");
880
+ handleTab(t2) {
881
+ if ("Tab" !== t2.key) return false;
882
+ if (t2.metaKey || t2.ctrlKey || t2.altKey) return false;
883
+ if (t2.preventDefault(), t2.shiftKey) return true;
884
+ const e2 = this.getState(), n2 = G(e2, " ");
885
885
  return this.dispatch(n2), true;
886
886
  }
887
- handleEscape(e2) {
888
- return "Escape" === e2.key && (this.element.blur(), true);
887
+ handleEscape(t2) {
888
+ return "Escape" === t2.key && (this.element.blur(), true);
889
889
  }
890
- handleArrowIntoVoid(e2) {
891
- const t2 = e2.key;
892
- if ("ArrowLeft" !== t2 && "ArrowRight" !== t2 && "ArrowUp" !== t2 && "ArrowDown" !== t2) return false;
893
- if (e2.shiftKey || e2.metaKey || e2.ctrlKey || e2.altKey) return false;
894
- const n2 = this.getState(), s2 = Q(n2, "ArrowLeft" === t2 ? "left" : "ArrowRight" === t2 ? "right" : "ArrowUp" === t2 ? "up" : "down");
895
- return !!s2 && (e2.preventDefault(), this.dispatch(s2), true);
890
+ handleArrowIntoVoid(t2) {
891
+ const e2 = t2.key;
892
+ if ("ArrowLeft" !== e2 && "ArrowRight" !== e2 && "ArrowUp" !== e2 && "ArrowDown" !== e2) return false;
893
+ if (t2.shiftKey || t2.metaKey || t2.ctrlKey || t2.altKey) return false;
894
+ const n2 = this.getState(), s2 = X(n2, "ArrowLeft" === e2 ? "left" : "ArrowRight" === e2 ? "right" : "ArrowUp" === e2 ? "up" : "down");
895
+ return !!s2 && (t2.preventDefault(), this.dispatch(s2), true);
896
896
  }
897
897
  destroy() {
898
898
  this.element.removeEventListener("keydown", this.handleKeydown);
899
899
  }
900
900
  }
901
- function Je(e2) {
902
- const t2 = [];
903
- (e2.metaKey || e2.ctrlKey) && t2.push("Mod"), e2.shiftKey && t2.push("Shift"), e2.altKey && t2.push("Alt");
904
- let n2 = e2.key;
905
- return " " === n2 ? n2 = "Space" : 1 === n2.length && (n2 = n2.toUpperCase()), t2.push(n2), t2.join("-");
901
+ function Qt(t2) {
902
+ const e2 = [];
903
+ (t2.metaKey || t2.ctrlKey) && e2.push("Mod"), t2.shiftKey && e2.push("Shift"), t2.altKey && e2.push("Alt");
904
+ let n2 = t2.key;
905
+ return " " === n2 ? n2 = "Space" : 1 === n2.length && (n2 = n2.toUpperCase()), e2.push(n2), e2.join("-");
906
906
  }
907
- let Qe;
908
- class Ge {
909
- constructor(e2, t2) {
910
- this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.schemaRegistry = t2.schemaRegistry, this.syncSelection = t2.syncSelection, this.handleCopy = this.onCopy.bind(this), this.handleCut = this.onCut.bind(this), e2.addEventListener("copy", this.handleCopy), e2.addEventListener("cut", this.handleCut);
907
+ let Gt;
908
+ class Yt {
909
+ constructor(t2, e2) {
910
+ this.element = t2, this.getState = e2.getState, this.dispatch = e2.dispatch, this.schemaRegistry = e2.schemaRegistry, this.syncSelection = e2.syncSelection, this.handleCopy = this.onCopy.bind(this), this.handleCut = this.onCut.bind(this), t2.addEventListener("copy", this.handleCopy), t2.addEventListener("cut", this.handleCut);
911
911
  }
912
912
  getState;
913
913
  dispatch;
@@ -915,98 +915,98 @@ class Ge {
915
915
  syncSelection;
916
916
  handleCopy;
917
917
  handleCut;
918
- onCopy(e2) {
918
+ onCopy(t2) {
919
919
  this.syncSelection?.();
920
- const t2 = this.getState(), n2 = t2.selection;
921
- if (K(n2) && V(n2)) return;
922
- e2.preventDefault();
923
- const s2 = e2.clipboardData;
924
- s2 && ($(n2) ? this.writeNodeSelectionToClipboard(s2, t2) : this.writeTextSelectionToClipboard(s2, t2));
920
+ const e2 = this.getState(), n2 = e2.selection;
921
+ if (F(n2) && U(n2)) return;
922
+ t2.preventDefault();
923
+ const s2 = t2.clipboardData;
924
+ s2 && (H(n2) ? this.writeNodeSelectionToClipboard(s2, e2) : this.writeTextSelectionToClipboard(s2, e2));
925
925
  }
926
- onCut(e2) {
926
+ onCut(t2) {
927
927
  this.syncSelection?.();
928
- const t2 = this.getState(), n2 = t2.selection;
929
- if (K(n2) && V(n2)) return;
930
- e2.preventDefault();
931
- const s2 = e2.clipboardData;
932
- if (s2) if ($(n2)) {
933
- this.writeNodeSelectionToClipboard(s2, t2);
934
- const e3 = G(t2, n2);
935
- e3 && this.dispatch(e3);
928
+ const e2 = this.getState(), n2 = e2.selection;
929
+ if (F(n2) && U(n2)) return;
930
+ t2.preventDefault();
931
+ const s2 = t2.clipboardData;
932
+ if (s2) if (H(n2)) {
933
+ this.writeNodeSelectionToClipboard(s2, e2);
934
+ const t3 = J(e2, n2);
935
+ t3 && this.dispatch(t3);
936
936
  } else {
937
- this.writeTextSelectionToClipboard(s2, t2);
938
- const e3 = ee(t2);
939
- e3 && this.dispatch(e3);
937
+ this.writeTextSelectionToClipboard(s2, e2);
938
+ const t3 = Y(e2);
939
+ t3 && this.dispatch(t3);
940
940
  }
941
941
  }
942
- writeNodeSelectionToClipboard(e2, t2) {
943
- const n2 = t2.selection;
944
- if (!$(n2)) return;
945
- const s2 = t2.getBlock(n2.nodeId);
942
+ writeNodeSelectionToClipboard(t2, e2) {
943
+ const n2 = e2.selection;
944
+ if (!H(n2)) return;
945
+ const s2 = e2.getBlock(n2.nodeId);
946
946
  if (!s2) return;
947
- const r2 = { type: s2.type, ...s2.attrs ? { attrs: { ...s2.attrs } } : {} };
948
- e2.setData("application/x-notectl-block", JSON.stringify(r2));
949
- const o2 = this.schemaRegistry?.getNodeSpec(s2.type);
950
- o2?.toHTML && e2.setData("text/html", o2.toHTML(s2, ""));
947
+ const o2 = { type: s2.type, ...s2.attrs ? { attrs: { ...s2.attrs } } : {} };
948
+ t2.setData("application/x-notectl-block", JSON.stringify(o2));
949
+ const r2 = this.schemaRegistry?.getNodeSpec(s2.type);
950
+ r2?.toHTML && t2.setData("text/html", r2.toHTML(s2, ""));
951
951
  const i3 = s2.attrs, a4 = "string" == typeof i3?.alt ? i3.alt : "";
952
- e2.setData("text/plain", a4);
953
- }
954
- writeTextSelectionToClipboard(e2, t2) {
955
- const n2 = t2.selection;
956
- if ($(n2)) return;
957
- if (V(n2)) return;
958
- const s2 = t2.getBlockOrder(), o2 = q(n2, s2), i3 = s2.indexOf(o2.from.blockId), a4 = s2.indexOf(o2.to.blockId), c3 = [], l2 = [];
959
- for (let e3 = i3; e3 <= a4; e3++) {
960
- const n3 = s2[e3];
952
+ t2.setData("text/plain", a4);
953
+ }
954
+ writeTextSelectionToClipboard(t2, e2) {
955
+ const n2 = e2.selection;
956
+ if (H(n2)) return;
957
+ if (U(n2)) return;
958
+ const s2 = e2.getBlockOrder(), r2 = K(n2, s2), i3 = s2.indexOf(r2.from.blockId), a4 = s2.indexOf(r2.to.blockId), c3 = [], l2 = [];
959
+ for (let t3 = i3; t3 <= a4; t3++) {
960
+ const n3 = s2[t3];
961
961
  if (!n3) continue;
962
- const h4 = t2.getBlock(n3);
963
- if (!h4) continue;
964
- const d2 = M(h4), u2 = r(h4), p2 = e3 === i3 ? o2.from.offset : 0, f3 = e3 === a4 ? o2.to.offset : u2, g2 = d2.slice(p2, f3);
965
- c3.push(g2), l2.push({ type: h4.type, text: g2, ...h4.attrs ? { attrs: { ...h4.attrs } } : {} });
962
+ const d3 = e2.getBlock(n3);
963
+ if (!d3) continue;
964
+ const h3 = E(d3), u2 = o(d3), p2 = t3 === i3 ? r2.from.offset : 0, f2 = t3 === a4 ? r2.to.offset : u2, g2 = h3.slice(p2, f2);
965
+ c3.push(g2), l2.push({ type: d3.type, text: g2, ...d3.attrs ? { attrs: { ...d3.attrs } } : {} });
966
966
  }
967
- const h3 = c3.join("\n");
968
- if (e2.setData("text/plain", h3), this.schemaRegistry) {
967
+ const d2 = c3.join("\n");
968
+ if (t2.setData("text/plain", d2), this.schemaRegistry) {
969
969
  const n3 = [];
970
- for (let e3 = i3; e3 <= a4; e3++) {
971
- const c4 = s2[e3];
970
+ for (let t3 = i3; t3 <= a4; t3++) {
971
+ const c4 = s2[t3];
972
972
  if (!c4) continue;
973
- const l3 = t2.getBlock(c4);
973
+ const l3 = e2.getBlock(c4);
974
974
  if (!l3) continue;
975
- const h4 = e3 === i3 ? o2.from.offset : 0, d2 = e3 === a4 ? o2.to.offset : r(l3);
976
- n3.push(this.serializeBlockRangeToHTML(l3, h4, d2));
975
+ const d3 = t3 === i3 ? r2.from.offset : 0, h3 = t3 === a4 ? r2.to.offset : o(l3);
976
+ n3.push(this.serializeBlockRangeToHTML(l3, d3, h3));
977
977
  }
978
- e2.setData("text/html", n3.join(""));
978
+ t2.setData("text/html", n3.join(""));
979
979
  }
980
- !(function(e3, t3) {
981
- Qe = { plainText: e3, blocks: t3 };
982
- })(h3, l2);
980
+ !(function(t3, e3) {
981
+ Gt = { plainText: t3, blocks: e3 };
982
+ })(d2, l2);
983
983
  }
984
984
  serializeBlockRangeToHTML(t2, n2, s2) {
985
- const r2 = e(t2), o2 = [];
985
+ const o2 = e(t2), r2 = [];
986
986
  let i3 = 0;
987
- for (const e2 of r2) {
988
- const t3 = i3 + (d(e2) ? 1 : e2.text.length);
989
- if (t3 <= n2 || i3 >= s2) i3 = t3;
987
+ for (const t3 of o2) {
988
+ const e2 = i3 + (d(t3) ? 1 : t3.text.length);
989
+ if (e2 <= n2 || i3 >= s2) i3 = e2;
990
990
  else {
991
- if (m(e2)) {
992
- const t4 = Math.max(0, n2 - i3), r3 = Math.min(e2.text.length, s2 - i3), a4 = e2.text.slice(t4, r3);
993
- a4.length > 0 && o2.push(this.serializeTextWithMarks(a4, e2.marks));
991
+ if (m(t3)) {
992
+ const e3 = Math.max(0, n2 - i3), o3 = Math.min(t3.text.length, s2 - i3), a4 = t3.text.slice(e3, o3);
993
+ a4.length > 0 && r2.push(this.serializeTextWithMarks(a4, t3.marks));
994
994
  }
995
- i3 = t3;
995
+ i3 = e2;
996
996
  }
997
997
  }
998
- return o2.join("");
998
+ return r2.join("");
999
999
  }
1000
- serializeTextWithMarks(e2, t2) {
1001
- if (0 === t2.length || !this.schemaRegistry) return ke(e2);
1002
- const n2 = [...t2].sort((e3, t3) => {
1003
- const n3 = this.schemaRegistry?.getMarkSpec(e3.type), s3 = this.schemaRegistry?.getMarkSpec(t3.type);
1000
+ serializeTextWithMarks(t2, e2) {
1001
+ if (0 === e2.length || !this.schemaRegistry) return mt(t2);
1002
+ const n2 = [...e2].sort((t3, e3) => {
1003
+ const n3 = this.schemaRegistry?.getMarkSpec(t3.type), s3 = this.schemaRegistry?.getMarkSpec(e3.type);
1004
1004
  return (n3?.rank ?? 100) - (s3?.rank ?? 100);
1005
1005
  });
1006
- let s2 = ke(e2);
1007
- for (const e3 of n2) {
1008
- const t3 = this.schemaRegistry?.getMarkSpec(e3.type);
1009
- t3?.toHTMLString && (s2 = t3.toHTMLString(e3, s2));
1006
+ let s2 = mt(t2);
1007
+ for (const t3 of n2) {
1008
+ const e3 = this.schemaRegistry?.getMarkSpec(t3.type);
1009
+ e3?.toHTMLString && (s2 = e3.toHTMLString(t3, s2));
1010
1010
  }
1011
1011
  return s2;
1012
1012
  }
@@ -1014,325 +1014,448 @@ class Ge {
1014
1014
  this.element.removeEventListener("copy", this.handleCopy), this.element.removeEventListener("cut", this.handleCut);
1015
1015
  }
1016
1016
  }
1017
- class Ye {
1017
+ class Zt {
1018
1018
  listeners = /* @__PURE__ */ new Map();
1019
- emit(e2, t2) {
1020
- const n2 = this.listeners.get(e2.id);
1019
+ emit(t2, e2) {
1020
+ const n2 = this.listeners.get(t2.id);
1021
1021
  if (n2) for (const s2 of n2) try {
1022
- s2(t2);
1023
- } catch (t3) {
1024
- console.error(`[EventBus] Listener error on "${e2.id}":`, t3);
1022
+ s2(e2);
1023
+ } catch (e3) {
1024
+ console.error(`[EventBus] Listener error on "${t2.id}":`, e3);
1025
1025
  }
1026
1026
  }
1027
- on(e2, t2) {
1028
- const n2 = e2.id;
1027
+ on(t2, e2) {
1028
+ const n2 = t2.id;
1029
1029
  this.listeners.has(n2) || this.listeners.set(n2, /* @__PURE__ */ new Set());
1030
1030
  const s2 = this.listeners.get(n2) ?? /* @__PURE__ */ new Set();
1031
- return s2.add(t2), () => {
1032
- s2.delete(t2), 0 === s2.size && this.listeners.delete(n2);
1031
+ return s2.add(e2), () => {
1032
+ s2.delete(e2), 0 === s2.size && this.listeners.delete(n2);
1033
1033
  };
1034
1034
  }
1035
- off(e2, t2) {
1036
- const n2 = this.listeners.get(e2.id);
1037
- n2 && (n2.delete(t2), 0 === n2.size && this.listeners.delete(e2.id));
1035
+ off(t2, e2) {
1036
+ const n2 = this.listeners.get(t2.id);
1037
+ n2 && (n2.delete(e2), 0 === n2.size && this.listeners.delete(t2.id));
1038
1038
  }
1039
1039
  clear() {
1040
1040
  this.listeners.clear();
1041
1041
  }
1042
1042
  }
1043
- class Ze {
1043
+ class te {
1044
1044
  plugins = /* @__PURE__ */ new Map();
1045
1045
  commands = /* @__PURE__ */ new Map();
1046
1046
  services = /* @__PURE__ */ new Map();
1047
1047
  middlewares = [];
1048
1048
  registrations = /* @__PURE__ */ new Map();
1049
- eventBus = new Ye();
1049
+ eventBus = new Zt();
1050
1050
  pluginStyleSheets = [];
1051
- schemaRegistry = new Me();
1051
+ schemaRegistry = new Ct();
1052
1052
  middlewareSorted = null;
1053
1053
  initOrder = [];
1054
1054
  initialized = false;
1055
1055
  initializing = false;
1056
- register(e2) {
1057
- if (this.initialized || this.initializing) throw new Error(`Cannot register plugin "${e2.id}" after initialization.`);
1058
- if (this.plugins.has(e2.id)) throw new Error(`Plugin "${e2.id}" is already registered.`);
1059
- this.plugins.set(e2.id, e2);
1056
+ register(t2) {
1057
+ if (this.initialized || this.initializing) throw new Error(`Cannot register plugin "${t2.id}" after initialization.`);
1058
+ if (this.plugins.has(t2.id)) throw new Error(`Plugin "${t2.id}" is already registered.`);
1059
+ this.plugins.set(t2.id, t2);
1060
1060
  }
1061
- async init(e2) {
1061
+ async init(t2) {
1062
1062
  if (!this.initialized && !this.initializing) {
1063
1063
  this.initializing = true, this.initOrder = this.resolveOrder();
1064
- for (const t2 of this.initOrder) {
1065
- const n2 = this.plugins.get(t2);
1064
+ for (const e2 of this.initOrder) {
1065
+ const n2 = this.plugins.get(e2);
1066
1066
  if (!n2) continue;
1067
- const s2 = this.createContext(t2, e2);
1067
+ const s2 = this.createContext(e2, t2);
1068
1068
  try {
1069
1069
  await n2.init(s2);
1070
- } catch (e3) {
1071
- console.error(`[PluginManager] Plugin "${t2}" failed to initialize:`, e3);
1070
+ } catch (t3) {
1071
+ console.error(`[PluginManager] Plugin "${e2}" failed to initialize:`, t3);
1072
1072
  }
1073
1073
  }
1074
- e2.onBeforeReady && await e2.onBeforeReady();
1075
- for (const e3 of this.initOrder) {
1076
- const t2 = this.plugins.get(e3);
1077
- if (t2?.onReady) try {
1078
- await t2.onReady();
1079
- } catch (t3) {
1080
- console.error(`[PluginManager] Plugin "${e3}" error in onReady:`, t3);
1074
+ t2.onBeforeReady && await t2.onBeforeReady();
1075
+ for (const t3 of this.initOrder) {
1076
+ const e2 = this.plugins.get(t3);
1077
+ if (e2?.onReady) try {
1078
+ await e2.onReady();
1079
+ } catch (e3) {
1080
+ console.error(`[PluginManager] Plugin "${t3}" error in onReady:`, e3);
1081
1081
  }
1082
1082
  }
1083
1083
  this.initialized = true, this.initializing = false;
1084
1084
  }
1085
1085
  }
1086
- notifyStateChange(e2, t2, n2) {
1086
+ notifyStateChange(t2, e2, n2) {
1087
1087
  for (const s2 of this.initOrder) {
1088
- const r2 = this.plugins.get(s2);
1089
- if (r2?.onStateChange) try {
1090
- r2.onStateChange(e2, t2, n2);
1091
- } catch (e3) {
1092
- console.error(`[PluginManager] Plugin "${s2}" error in onStateChange:`, e3);
1088
+ const o2 = this.plugins.get(s2);
1089
+ if (o2?.onStateChange) try {
1090
+ o2.onStateChange(t2, e2, n2);
1091
+ } catch (t3) {
1092
+ console.error(`[PluginManager] Plugin "${s2}" error in onStateChange:`, t3);
1093
1093
  }
1094
1094
  }
1095
1095
  }
1096
- collectDecorations(e2, t2) {
1097
- let n2 = we.empty;
1096
+ collectDecorations(t2, e2) {
1097
+ let n2 = wt.empty;
1098
1098
  for (const s2 of this.initOrder) {
1099
- const r2 = this.plugins.get(s2);
1100
- if (r2?.decorations) try {
1101
- const s3 = r2.decorations(e2, t2);
1099
+ const o2 = this.plugins.get(s2);
1100
+ if (o2?.decorations) try {
1101
+ const s3 = o2.decorations(t2, e2);
1102
1102
  s3.isEmpty || (n2 = n2.merge(s3));
1103
- } catch (e3) {
1104
- console.error(`[PluginManager] Plugin "${s2}" error in decorations():`, e3);
1103
+ } catch (t3) {
1104
+ console.error(`[PluginManager] Plugin "${s2}" error in decorations():`, t3);
1105
1105
  }
1106
1106
  }
1107
1107
  return n2;
1108
1108
  }
1109
- dispatchWithMiddleware(e2, t2, n2) {
1110
- if (0 === this.middlewares.length) return void n2(e2);
1109
+ dispatchWithMiddleware(t2, e2, n2) {
1110
+ if (0 === this.middlewares.length) return void n2(t2);
1111
1111
  const s2 = this.getSortedMiddleware();
1112
- let r2 = 0, o2 = false;
1113
- const i3 = (e3) => {
1114
- if (r2 < s2.length) {
1115
- const n3 = s2[r2++];
1112
+ let o2 = 0, r2 = false;
1113
+ const i3 = (t3) => {
1114
+ if (o2 < s2.length) {
1115
+ const n3 = s2[o2++];
1116
1116
  if (!n3) return;
1117
- let o3 = false;
1118
- const a4 = (e4) => {
1119
- o3 || (o3 = true, i3(e4));
1117
+ let r3 = false;
1118
+ const a4 = (t4) => {
1119
+ r3 || (r3 = true, i3(t4));
1120
1120
  };
1121
1121
  try {
1122
- n3.middleware(e3, t2, a4);
1123
- } catch (t3) {
1124
- console.error("[PluginManager] Middleware error:", t3), a4(e3);
1122
+ n3.middleware(t3, e2, a4);
1123
+ } catch (e3) {
1124
+ console.error("[PluginManager] Middleware error:", e3), a4(t3);
1125
1125
  }
1126
- } else o2 || (o2 = true, n2(e3));
1126
+ } else r2 || (r2 = true, n2(t3));
1127
1127
  };
1128
- i3(e2);
1128
+ i3(t2);
1129
1129
  }
1130
- executeCommand(e2) {
1131
- const t2 = this.commands.get(e2);
1132
- if (!t2) return false;
1130
+ executeCommand(t2) {
1131
+ const e2 = this.commands.get(t2);
1132
+ if (!e2) return false;
1133
1133
  try {
1134
- return t2.handler();
1135
- } catch (t3) {
1136
- return console.error(`[PluginManager] Command "${e2}" error:`, t3), false;
1134
+ return e2.handler();
1135
+ } catch (e3) {
1136
+ return console.error(`[PluginManager] Command "${t2}" error:`, e3), false;
1137
1137
  }
1138
1138
  }
1139
- configurePlugin(e2, t2) {
1140
- const n2 = this.plugins.get(e2);
1141
- if (!n2) throw new Error(`Plugin "${e2}" not found.`);
1139
+ configurePlugin(t2, e2) {
1140
+ const n2 = this.plugins.get(t2);
1141
+ if (!n2) throw new Error(`Plugin "${t2}" not found.`);
1142
1142
  if (n2.onConfigure) try {
1143
- n2.onConfigure(t2);
1144
- } catch (t3) {
1145
- console.error(`[PluginManager] Plugin "${e2}" error in onConfigure:`, t3);
1143
+ n2.onConfigure(e2);
1144
+ } catch (e3) {
1145
+ console.error(`[PluginManager] Plugin "${t2}" error in onConfigure:`, e3);
1146
1146
  }
1147
1147
  }
1148
1148
  getPluginIds() {
1149
1149
  return [...this.plugins.keys()];
1150
1150
  }
1151
- get(e2) {
1152
- return this.plugins.get(e2);
1151
+ get(t2) {
1152
+ return this.plugins.get(t2);
1153
+ }
1154
+ getService(t2) {
1155
+ return this.services.get(t2.id);
1153
1156
  }
1154
- getService(e2) {
1155
- return this.services.get(e2.id);
1157
+ onEvent(t2, e2) {
1158
+ return this.eventBus.on(t2, e2);
1156
1159
  }
1157
1160
  getPluginStyleSheets() {
1158
1161
  return this.pluginStyleSheets;
1159
1162
  }
1160
1163
  async destroy() {
1161
- const e2 = [...this.initOrder].reverse();
1162
- for (const t2 of e2) await this.destroyPlugin(t2);
1164
+ const t2 = [...this.initOrder].reverse();
1165
+ for (const e2 of t2) await this.destroyPlugin(e2);
1163
1166
  this.plugins.clear(), this.commands.clear(), this.services.clear(), this.middlewares.length = 0, this.middlewareSorted = null, this.pluginStyleSheets.length = 0, this.eventBus.clear(), this.registrations.clear(), this.schemaRegistry.clear(), this.initOrder = [], this.initialized = false;
1164
1167
  }
1165
- async destroyPlugin(e2) {
1166
- const t2 = this.plugins.get(e2);
1167
- if (t2?.destroy) try {
1168
- await t2.destroy();
1169
- } catch (t3) {
1170
- console.error(`[PluginManager] Plugin "${e2}" error in destroy:`, t3);
1171
- }
1172
- this.cleanupRegistrations(e2);
1173
- }
1174
- cleanupRegistrations(e2) {
1175
- const t2 = this.registrations.get(e2);
1176
- if (t2) {
1177
- for (const e3 of t2.commands) this.commands.delete(e3);
1178
- for (const e3 of t2.services) this.services.delete(e3);
1179
- for (const e3 of t2.middlewares) {
1180
- const t3 = this.middlewares.indexOf(e3);
1181
- -1 !== t3 && this.middlewares.splice(t3, 1);
1168
+ async destroyPlugin(t2) {
1169
+ const e2 = this.plugins.get(t2);
1170
+ if (e2?.destroy) try {
1171
+ await e2.destroy();
1172
+ } catch (e3) {
1173
+ console.error(`[PluginManager] Plugin "${t2}" error in destroy:`, e3);
1174
+ }
1175
+ this.cleanupRegistrations(t2);
1176
+ }
1177
+ cleanupRegistrations(t2) {
1178
+ const e2 = this.registrations.get(t2);
1179
+ if (e2) {
1180
+ for (const t3 of e2.commands) this.commands.delete(t3);
1181
+ for (const t3 of e2.services) this.services.delete(t3);
1182
+ for (const t3 of e2.middlewares) {
1183
+ const e3 = this.middlewares.indexOf(t3);
1184
+ -1 !== e3 && this.middlewares.splice(e3, 1);
1182
1185
  }
1183
- for (const e3 of t2.unsubscribers) e3();
1184
- for (const e3 of t2.nodeSpecs) this.schemaRegistry.removeNodeSpec(e3);
1185
- for (const e3 of t2.markSpecs) this.schemaRegistry.removeMarkSpec(e3);
1186
- for (const e3 of t2.inlineNodeSpecs) this.schemaRegistry.removeInlineNodeSpec(e3);
1187
- for (const e3 of t2.nodeViews) this.schemaRegistry.removeNodeView(e3);
1188
- for (const e3 of t2.keymaps) this.schemaRegistry.removeKeymap(e3);
1189
- for (const e3 of t2.inputRules) this.schemaRegistry.removeInputRule(e3);
1190
- for (const e3 of t2.toolbarItems) this.schemaRegistry.removeToolbarItem(e3);
1191
- for (const e3 of t2.fileHandlers) this.schemaRegistry.removeFileHandler(e3);
1192
- for (const e3 of t2.blockTypePickerEntries) this.schemaRegistry.removeBlockTypePickerEntry(e3);
1193
- for (const e3 of t2.stylesheets) {
1194
- const t3 = this.pluginStyleSheets.indexOf(e3);
1195
- -1 !== t3 && this.pluginStyleSheets.splice(t3, 1);
1186
+ for (const t3 of e2.unsubscribers) t3();
1187
+ for (const t3 of e2.nodeSpecs) this.schemaRegistry.removeNodeSpec(t3);
1188
+ for (const t3 of e2.markSpecs) this.schemaRegistry.removeMarkSpec(t3);
1189
+ for (const t3 of e2.inlineNodeSpecs) this.schemaRegistry.removeInlineNodeSpec(t3);
1190
+ for (const t3 of e2.nodeViews) this.schemaRegistry.removeNodeView(t3);
1191
+ for (const t3 of e2.keymaps) this.schemaRegistry.removeKeymap(t3);
1192
+ for (const t3 of e2.inputRules) this.schemaRegistry.removeInputRule(t3);
1193
+ for (const t3 of e2.toolbarItems) this.schemaRegistry.removeToolbarItem(t3);
1194
+ for (const t3 of e2.fileHandlers) this.schemaRegistry.removeFileHandler(t3);
1195
+ for (const t3 of e2.blockTypePickerEntries) this.schemaRegistry.removeBlockTypePickerEntry(t3);
1196
+ for (const t3 of e2.stylesheets) {
1197
+ const e3 = this.pluginStyleSheets.indexOf(t3);
1198
+ -1 !== e3 && this.pluginStyleSheets.splice(e3, 1);
1196
1199
  }
1197
- this.middlewareSorted = null, this.registrations.delete(e2);
1200
+ this.middlewareSorted = null, this.registrations.delete(t2);
1198
1201
  }
1199
1202
  }
1200
1203
  getSortedMiddleware() {
1201
- return this.middlewareSorted || (this.middlewareSorted = [...this.middlewares].sort((e2, t2) => e2.priority - t2.priority)), this.middlewareSorted;
1204
+ return this.middlewareSorted || (this.middlewareSorted = [...this.middlewares].sort((t2, e2) => t2.priority - e2.priority)), this.middlewareSorted;
1202
1205
  }
1203
- createContext(e2, t2) {
1206
+ createContext(t2, e2) {
1204
1207
  const n2 = { commands: [], services: [], middlewares: [], unsubscribers: [], nodeSpecs: [], markSpecs: [], inlineNodeSpecs: [], nodeViews: [], keymaps: [], inputRules: [], toolbarItems: [], fileHandlers: [], blockTypePickerEntries: [], stylesheets: [] };
1205
- this.registrations.set(e2, n2);
1206
- const s2 = { emit: (e3, t3) => this.eventBus.emit(e3, t3), on: (e3, t3) => {
1207
- const s3 = this.eventBus.on(e3, t3);
1208
+ this.registrations.set(t2, n2);
1209
+ const s2 = { emit: (t3, e3) => this.eventBus.emit(t3, e3), on: (t3, e3) => {
1210
+ const s3 = this.eventBus.on(t3, e3);
1208
1211
  return n2.unsubscribers.push(s3), s3;
1209
- }, off: (e3, t3) => this.eventBus.off(e3, t3) };
1210
- return { getState: t2.getState, dispatch: t2.dispatch, getContainer: t2.getContainer, getPluginContainer: t2.getPluginContainer, registerCommand: (t3, s3) => {
1211
- if (this.commands.has(t3)) {
1212
- const e3 = this.commands.get(t3);
1213
- throw new Error(`Command "${t3}" is already registered by plugin "${e3?.pluginId}".`);
1212
+ }, off: (t3, e3) => this.eventBus.off(t3, e3) };
1213
+ return { getState: e2.getState, dispatch: e2.dispatch, getContainer: e2.getContainer, getPluginContainer: e2.getPluginContainer, registerCommand: (e3, s3) => {
1214
+ if (this.commands.has(e3)) {
1215
+ const t3 = this.commands.get(e3);
1216
+ throw new Error(`Command "${e3}" is already registered by plugin "${t3?.pluginId}".`);
1214
1217
  }
1215
- this.commands.set(t3, { name: t3, handler: s3, pluginId: e2 }), n2.commands.push(t3);
1216
- }, executeCommand: (e3) => this.executeCommand(e3), getEventBus: () => s2, registerMiddleware: (e3, t3 = 100) => {
1217
- const s3 = { middleware: e3, priority: t3 };
1218
+ this.commands.set(e3, { name: e3, handler: s3, pluginId: t2 }), n2.commands.push(e3);
1219
+ }, executeCommand: (t3) => this.executeCommand(t3), getEventBus: () => s2, registerMiddleware: (t3, e3 = 100) => {
1220
+ const s3 = { middleware: t3, priority: e3 };
1218
1221
  this.middlewares.push(s3), n2.middlewares.push(s3), this.middlewareSorted = null;
1219
- }, registerService: (e3, t3) => {
1220
- if (this.services.has(e3.id)) throw new Error(`Service "${e3.id}" is already registered by another plugin.`);
1221
- this.services.set(e3.id, t3), n2.services.push(e3.id);
1222
- }, getService: (e3) => this.services.get(e3.id), updateConfig: (t3) => {
1223
- const n3 = this.plugins.get(e2);
1222
+ }, registerService: (t3, e3) => {
1223
+ if (this.services.has(t3.id)) throw new Error(`Service "${t3.id}" is already registered by another plugin.`);
1224
+ this.services.set(t3.id, e3), n2.services.push(t3.id);
1225
+ }, getService: (t3) => this.services.get(t3.id), updateConfig: (e3) => {
1226
+ const n3 = this.plugins.get(t2);
1224
1227
  if (n3?.onConfigure) try {
1225
- n3.onConfigure(t3);
1226
- } catch (t4) {
1227
- console.error(`[PluginManager] Plugin "${e2}" error in onConfigure:`, t4);
1228
+ n3.onConfigure(e3);
1229
+ } catch (e4) {
1230
+ console.error(`[PluginManager] Plugin "${t2}" error in onConfigure:`, e4);
1228
1231
  }
1229
- }, registerNodeSpec: (e3) => {
1230
- this.schemaRegistry.registerNodeSpec(e3), n2.nodeSpecs.push(e3.type);
1231
- }, registerMarkSpec: (e3) => {
1232
- this.schemaRegistry.registerMarkSpec(e3), n2.markSpecs.push(e3.type);
1233
- }, registerNodeView: (e3, t3) => {
1234
- this.schemaRegistry.registerNodeView(e3, t3), n2.nodeViews.push(e3);
1235
- }, registerKeymap: (e3) => {
1236
- this.schemaRegistry.registerKeymap(e3), n2.keymaps.push(e3);
1237
- }, registerInputRule: (e3) => {
1238
- this.schemaRegistry.registerInputRule(e3), n2.inputRules.push(e3);
1239
- }, registerToolbarItem: (t3) => {
1240
- this.schemaRegistry.registerToolbarItem(t3, e2), n2.toolbarItems.push(t3.id);
1241
- }, registerInlineNodeSpec: (e3) => {
1242
- this.schemaRegistry.registerInlineNodeSpec(e3), n2.inlineNodeSpecs.push(e3.type);
1243
- }, registerFileHandler: (e3, t3) => {
1244
- this.schemaRegistry.registerFileHandler(e3, t3), n2.fileHandlers.push(t3);
1245
- }, registerBlockTypePickerEntry: (e3) => {
1246
- this.schemaRegistry.registerBlockTypePickerEntry(e3), n2.blockTypePickerEntries.push(e3.id);
1247
- }, getSchemaRegistry: () => this.schemaRegistry, registerStyleSheet: (e3) => {
1248
- const t3 = new CSSStyleSheet();
1249
- t3.replaceSync(e3), this.pluginStyleSheets.push(t3), n2.stylesheets.push(t3);
1250
- }, announce: (e3) => {
1251
- t2.announce?.(e3);
1232
+ }, registerNodeSpec: (t3) => {
1233
+ this.schemaRegistry.registerNodeSpec(t3), n2.nodeSpecs.push(t3.type);
1234
+ }, registerMarkSpec: (t3) => {
1235
+ this.schemaRegistry.registerMarkSpec(t3), n2.markSpecs.push(t3.type);
1236
+ }, registerNodeView: (t3, e3) => {
1237
+ this.schemaRegistry.registerNodeView(t3, e3), n2.nodeViews.push(t3);
1238
+ }, registerKeymap: (t3) => {
1239
+ this.schemaRegistry.registerKeymap(t3), n2.keymaps.push(t3);
1240
+ }, registerInputRule: (t3) => {
1241
+ this.schemaRegistry.registerInputRule(t3), n2.inputRules.push(t3);
1242
+ }, registerToolbarItem: (e3) => {
1243
+ this.schemaRegistry.registerToolbarItem(e3, t2), n2.toolbarItems.push(e3.id);
1244
+ }, registerInlineNodeSpec: (t3) => {
1245
+ this.schemaRegistry.registerInlineNodeSpec(t3), n2.inlineNodeSpecs.push(t3.type);
1246
+ }, registerFileHandler: (t3, e3) => {
1247
+ this.schemaRegistry.registerFileHandler(t3, e3), n2.fileHandlers.push(e3);
1248
+ }, registerBlockTypePickerEntry: (t3) => {
1249
+ this.schemaRegistry.registerBlockTypePickerEntry(t3), n2.blockTypePickerEntries.push(t3.id);
1250
+ }, getSchemaRegistry: () => this.schemaRegistry, registerStyleSheet: (t3) => {
1251
+ const e3 = new CSSStyleSheet();
1252
+ e3.replaceSync(t3), this.pluginStyleSheets.push(e3), n2.stylesheets.push(e3);
1253
+ }, announce: (t3) => {
1254
+ e2.announce?.(t3);
1252
1255
  } };
1253
1256
  }
1254
1257
  resolveOrder() {
1255
- const e2 = [...this.plugins.keys()];
1256
- for (const t3 of e2) {
1257
- const e3 = this.plugins.get(t3);
1258
- if (e3) {
1259
- for (const n3 of e3.dependencies ?? []) if (!this.plugins.has(n3)) throw new Error(`Plugin "${t3}" depends on "${n3}", which is not registered.`);
1258
+ const t2 = [...this.plugins.keys()];
1259
+ for (const e3 of t2) {
1260
+ const t3 = this.plugins.get(e3);
1261
+ if (t3) {
1262
+ for (const n3 of t3.dependencies ?? []) if (!this.plugins.has(n3)) throw new Error(`Plugin "${e3}" depends on "${n3}", which is not registered.`);
1260
1263
  }
1261
1264
  }
1262
- const t2 = /* @__PURE__ */ new Map(), n2 = /* @__PURE__ */ new Map();
1263
- for (const s3 of e2) t2.set(s3, 0), n2.set(s3, []);
1264
- for (const s3 of e2) {
1265
- const e3 = this.plugins.get(s3), r3 = e3?.dependencies ?? [];
1266
- t2.set(s3, r3.length);
1267
- for (const e4 of r3) {
1268
- const t3 = n2.get(e4);
1269
- t3 && t3.push(s3);
1265
+ const e2 = /* @__PURE__ */ new Map(), n2 = /* @__PURE__ */ new Map();
1266
+ for (const s3 of t2) e2.set(s3, 0), n2.set(s3, []);
1267
+ for (const s3 of t2) {
1268
+ const t3 = this.plugins.get(s3), o3 = t3?.dependencies ?? [];
1269
+ e2.set(s3, o3.length);
1270
+ for (const t4 of o3) {
1271
+ const e3 = n2.get(t4);
1272
+ e3 && e3.push(s3);
1270
1273
  }
1271
1274
  }
1272
1275
  const s2 = [];
1273
- for (const [e3, n3] of t2) 0 === n3 && s2.push(e3);
1274
- const r2 = [];
1276
+ for (const [t3, n3] of e2) 0 === n3 && s2.push(t3);
1277
+ const o2 = [];
1275
1278
  for (; s2.length > 0; ) {
1276
- s2.sort((e4, t3) => (this.plugins.get(e4)?.priority ?? 100) - (this.plugins.get(t3)?.priority ?? 100));
1277
- const e3 = s2.shift();
1278
- if (!e3) break;
1279
- r2.push(e3);
1280
- for (const r3 of n2.get(e3) ?? []) {
1281
- const e4 = (t2.get(r3) ?? 0) - 1;
1282
- t2.set(r3, e4), 0 === e4 && s2.push(r3);
1279
+ s2.sort((t4, e3) => (this.plugins.get(t4)?.priority ?? 100) - (this.plugins.get(e3)?.priority ?? 100));
1280
+ const t3 = s2.shift();
1281
+ if (!t3) break;
1282
+ o2.push(t3);
1283
+ for (const o3 of n2.get(t3) ?? []) {
1284
+ const t4 = (e2.get(o3) ?? 0) - 1;
1285
+ e2.set(o3, t4), 0 === t4 && s2.push(o3);
1283
1286
  }
1284
1287
  }
1285
- if (r2.length !== e2.length) {
1286
- const t3 = e2.filter((e3) => !r2.includes(e3));
1287
- throw new Error(`Circular dependency detected among plugins: ${t3.join(", ")}`);
1288
+ if (o2.length !== t2.length) {
1289
+ const e3 = t2.filter((t3) => !o2.includes(t3));
1290
+ throw new Error(`Circular dependency detected among plugins: ${e3.join(", ")}`);
1291
+ }
1292
+ return o2;
1293
+ }
1294
+ }
1295
+ function ee(t2) {
1296
+ return "function" == typeof t2 ? t2() : t2;
1297
+ }
1298
+ const ne = new vt("print"), se = new St("print:before"), oe = new St("print:after"), re = { print() {
1299
+ }, toHTML: () => "" };
1300
+ class ie {
1301
+ id = "print";
1302
+ name = "Print";
1303
+ config;
1304
+ service = null;
1305
+ constructor(t2) {
1306
+ this.config = t2 ?? {};
1307
+ }
1308
+ init(t2) {
1309
+ const e2 = t2.getContainer(), n2 = e2.getRootNode();
1310
+ if (n2 instanceof ShadowRoot) {
1311
+ const s3 = n2.host, o3 = t2.getEventBus();
1312
+ this.service = /* @__PURE__ */ (function(t3, e3, n3, s4) {
1313
+ function o4(t4) {
1314
+ return t4 ?? {};
1315
+ }
1316
+ function r3(o5) {
1317
+ const r4 = { options: o5, cancelled: false };
1318
+ if (s4.emit(se, r4), r4.cancelled) return null;
1319
+ const i3 = r4.options, a4 = (function(t4, e4, n4, s5 = "en") {
1320
+ return ["<!DOCTYPE html>", `<html lang="${s5}">`, "<head>", '<meta charset="utf-8">', `<title>${n4.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</title>`, `<style>${t4}</style>`, "</head>", `<body>${e4}</body>`, "</html>"].join("\n");
1321
+ })((function(t4, e4, n4) {
1322
+ const s5 = [], o6 = (function(t5) {
1323
+ const e5 = [];
1324
+ for (const n5 of t5.adoptedStyleSheets) for (const t6 of n5.cssRules) e5.push(t6.cssText);
1325
+ return e5.join("\n");
1326
+ })(t4);
1327
+ o6 && s5.push(o6);
1328
+ const r5 = (function(t5) {
1329
+ const e5 = getComputedStyle(t5), n5 = [];
1330
+ for (let t6 = 0; t6 < e5.length; t6++) {
1331
+ const s6 = e5[t6] ?? "";
1332
+ if (s6.startsWith("--notectl-")) {
1333
+ const t7 = e5.getPropertyValue(s6).trim();
1334
+ t7 && n5.push(` ${s6}: ${t7};`);
1335
+ }
1336
+ }
1337
+ return 0 === n5.length ? "" : `:root {
1338
+ ${n5.join("\n")}
1339
+ }`;
1340
+ })(e4);
1341
+ r5 && s5.push(r5);
1342
+ const i4 = (function(t5) {
1343
+ const e5 = [], n5 = [];
1344
+ t5.margin && n5.push(` margin: ${t5.margin};`), t5.orientation && n5.push(` size: A4 ${t5.orientation};`), n5.length > 0 && e5.push(`@page {
1345
+ ${n5.join("\n")}
1346
+ }`);
1347
+ const s6 = [];
1348
+ return s6.push("[data-notectl-no-print] { display: none !important; }"), s6.push(".notectl-code-block { white-space: pre-wrap !important; word-break: break-all !important; page-break-inside: avoid; }"), s6.push("img { page-break-inside: avoid; }"), s6.push(".notectl-table { break-inside: avoid; }"), t5.printBackground && s6.push("* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }"), e5.push(`@media print {
1349
+ ${s6.join("\n ")}
1350
+ }`), e5.join("\n\n");
1351
+ })(n4);
1352
+ return i4 && s5.push(i4), n4.customCSS && s5.push(n4.customCSS), s5.join("\n\n");
1353
+ })(t3, e3, i3), (function(t4, e4) {
1354
+ const n4 = (function(t5) {
1355
+ return (t5.querySelector(".notectl-content") ?? t5).cloneNode(true);
1356
+ })(t4);
1357
+ return (function(t5) {
1358
+ t5.removeAttribute("contenteditable");
1359
+ const e5 = ["notectl-node-selected", "notectl-content--empty"];
1360
+ for (const n5 of e5) {
1361
+ t5.classList.remove(n5);
1362
+ for (const e6 of t5.querySelectorAll(`.${n5}`)) e6.classList.remove(n5);
1363
+ }
1364
+ t5.removeAttribute("data-placeholder");
1365
+ })(n4), (function(t5, e5) {
1366
+ if (e5.excludeBlockTypes) for (const n5 of e5.excludeBlockTypes) {
1367
+ const e6 = t5.querySelectorAll(`[data-block-type="${n5}"]`);
1368
+ for (const t6 of e6) t6.remove();
1369
+ }
1370
+ if (e5.pageBreakBefore) for (const n5 of e5.pageBreakBefore) {
1371
+ const e6 = t5.querySelectorAll(`[data-block-type="${n5}"]`);
1372
+ for (const t6 of e6) t6.style.breakBefore = "page", t6.style.pageBreakBefore = "always";
1373
+ }
1374
+ })(n4, e4), (function(t5, e5) {
1375
+ if (e5.header) {
1376
+ const n5 = document.createElement("div");
1377
+ n5.className = "notectl-print-header", n5.innerHTML = ee(e5.header), t5.insertBefore(n5, t5.firstChild);
1378
+ }
1379
+ if (e5.footer) {
1380
+ const n5 = document.createElement("div");
1381
+ n5.className = "notectl-print-footer", n5.innerHTML = ee(e5.footer), t5.appendChild(n5);
1382
+ }
1383
+ })(n4, e4), n4;
1384
+ })(n3, i3).outerHTML, i3.title ?? "", e3.closest("[lang]")?.getAttribute("lang") ?? (document.documentElement.lang || "en")), c3 = { html: a4 };
1385
+ return s4.emit(oe, c3), a4;
1386
+ }
1387
+ return { print(t4) {
1388
+ const e4 = r3(o4(t4));
1389
+ if (!e4) return;
1390
+ const n4 = document.createElement("iframe");
1391
+ n4.style.cssText = "position:fixed;left:-9999px;width:0;height:0;border:none;", document.body.appendChild(n4);
1392
+ const s5 = n4.contentDocument;
1393
+ if (!s5) return void document.body.removeChild(n4);
1394
+ s5.open(), s5.write(e4), s5.close();
1395
+ const i3 = () => {
1396
+ n4.remove();
1397
+ };
1398
+ n4.contentWindow ? (n4.contentWindow.addEventListener("afterprint", i3, { once: true }), n4.contentWindow.print()) : i3();
1399
+ }, toHTML: (t4) => r3(o4(t4)) ?? "" };
1400
+ })(n2, s3, e2, o3);
1401
+ } else this.service = re;
1402
+ t2.registerService(ne, this.service);
1403
+ const s2 = this.config.defaults ?? {}, o2 = this.service;
1404
+ t2.registerCommand("print", () => (t2.announce("Printing"), o2.print(s2), true));
1405
+ const r2 = this.config.keyBinding ?? "Mod-P";
1406
+ if (t2.registerKeymap({ [r2]: () => (t2.executeCommand("print"), true) }), false !== this.config.showToolbarItem) {
1407
+ const e3 = xt(r2);
1408
+ t2.registerToolbarItem({ id: "print", group: "actions", label: "Print", tooltip: `Print (${e3})`, icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/></svg>', command: "print", priority: 900 });
1288
1409
  }
1289
- return r2;
1410
+ }
1411
+ destroy() {
1412
+ this.service = null;
1290
1413
  }
1291
1414
  }
1292
- const et = { Light: "light", Dark: "dark", System: "system" }, tt = { name: "light", primitives: { background: "#ffffff", foreground: "#1a1a1a", mutedForeground: "#666666", border: "#d0d0d0", borderFocus: "#4a90d9", primary: "#4a90d9", primaryForeground: "#1a5fa0", primaryMuted: "#d0e0f0", surfaceRaised: "#f8f8f8", surfaceOverlay: "#ffffff", hoverBackground: "#e8e8e8", activeBackground: "#d0e0f0", danger: "#dc2626", dangerMuted: "#fee2e2", success: "#1a8c1a", shadow: "rgba(0, 0, 0, 0.15)", focusRing: "rgba(74, 144, 217, 0.2)" }, codeBlock: { background: "#f8fafc", foreground: "#334155", headerBackground: "#f1f5f9", headerForeground: "#64748b", headerBorder: "#e2e8f0" }, tooltip: { background: "#1a1a1a", foreground: "#ffffff" } }, nt = { name: "dark", primitives: { background: "#1e1e2e", foreground: "#cdd6f4", mutedForeground: "#7f849c", border: "#45475a", borderFocus: "#89b4fa", primary: "#89b4fa", primaryForeground: "#89b4fa", primaryMuted: "rgba(137, 180, 250, 0.15)", surfaceRaised: "#313244", surfaceOverlay: "#313244", hoverBackground: "#45475a", activeBackground: "rgba(137, 180, 250, 0.15)", danger: "#f38ba8", dangerMuted: "rgba(243, 139, 168, 0.15)", success: "#a6e3a1", shadow: "rgba(0, 0, 0, 0.4)", focusRing: "rgba(137, 180, 250, 0.25)" }, codeBlock: { background: "#11111b", foreground: "#cdd6f4", headerBackground: "#181825", headerForeground: "#7f849c", headerBorder: "rgba(205, 214, 244, 0.08)" }, tooltip: { background: "#585b70", foreground: "#cdd6f4" } };
1293
- function st(e2, t2) {
1294
- return { name: t2.name, primitives: { ...e2.primitives, ...t2.primitives }, toolbar: t2.toolbar ? { ...e2.toolbar, ...t2.toolbar } : e2.toolbar, codeBlock: t2.codeBlock ? { ...e2.codeBlock, ...t2.codeBlock } : e2.codeBlock, tooltip: t2.tooltip ? { ...e2.tooltip, ...t2.tooltip } : e2.tooltip };
1415
+ const ae = { Light: "light", Dark: "dark", System: "system" }, ce = { name: "light", primitives: { background: "#ffffff", foreground: "#1a1a1a", mutedForeground: "#666666", border: "#d0d0d0", borderFocus: "#4a90d9", primary: "#4a90d9", primaryForeground: "#1a5fa0", primaryMuted: "#d0e0f0", surfaceRaised: "#f8f8f8", surfaceOverlay: "#ffffff", hoverBackground: "#e8e8e8", activeBackground: "#d0e0f0", danger: "#dc2626", dangerMuted: "#fee2e2", success: "#1a8c1a", shadow: "rgba(0, 0, 0, 0.15)", focusRing: "rgba(74, 144, 217, 0.2)" }, codeBlock: { background: "#f8fafc", foreground: "#334155", headerBackground: "#f1f5f9", headerForeground: "#64748b", headerBorder: "#e2e8f0" }, tooltip: { background: "#1a1a1a", foreground: "#ffffff" } }, le = { name: "dark", primitives: { background: "#1e1e2e", foreground: "#cdd6f4", mutedForeground: "#7f849c", border: "#45475a", borderFocus: "#89b4fa", primary: "#89b4fa", primaryForeground: "#89b4fa", primaryMuted: "rgba(137, 180, 250, 0.15)", surfaceRaised: "#313244", surfaceOverlay: "#313244", hoverBackground: "#45475a", activeBackground: "rgba(137, 180, 250, 0.15)", danger: "#f38ba8", dangerMuted: "rgba(243, 139, 168, 0.15)", success: "#a6e3a1", shadow: "rgba(0, 0, 0, 0.4)", focusRing: "rgba(137, 180, 250, 0.25)" }, codeBlock: { background: "#11111b", foreground: "#cdd6f4", headerBackground: "#181825", headerForeground: "#7f849c", headerBorder: "rgba(205, 214, 244, 0.08)" }, tooltip: { background: "#585b70", foreground: "#cdd6f4" } };
1416
+ function de(t2, e2) {
1417
+ return { name: e2.name, primitives: { ...t2.primitives, ...e2.primitives }, toolbar: e2.toolbar ? { ...t2.toolbar, ...e2.toolbar } : t2.toolbar, codeBlock: e2.codeBlock ? { ...t2.codeBlock, ...e2.codeBlock } : t2.codeBlock, tooltip: e2.tooltip ? { ...t2.tooltip, ...e2.tooltip } : t2.tooltip };
1295
1418
  }
1296
- function rt(e2) {
1297
- if ("object" == typeof e2) return e2;
1298
- switch (e2) {
1299
- case et.Light:
1300
- return tt;
1301
- case et.Dark:
1302
- return nt;
1419
+ function he(t2) {
1420
+ if ("object" == typeof t2) return t2;
1421
+ switch (t2) {
1422
+ case ae.Light:
1423
+ return ce;
1424
+ case ae.Dark:
1425
+ return le;
1303
1426
  default:
1304
- return tt;
1427
+ return ce;
1305
1428
  }
1306
1429
  }
1307
- const ot = [["primitives.background", "--notectl-bg"], ["primitives.foreground", "--notectl-fg"], ["primitives.mutedForeground", "--notectl-fg-muted"], ["primitives.border", "--notectl-border"], ["primitives.borderFocus", "--notectl-border-focus"], ["primitives.primary", "--notectl-primary"], ["primitives.primaryForeground", "--notectl-primary-fg"], ["primitives.primaryMuted", "--notectl-primary-muted"], ["primitives.surfaceRaised", "--notectl-surface-raised"], ["primitives.surfaceOverlay", "--notectl-surface-overlay"], ["primitives.hoverBackground", "--notectl-hover-bg"], ["primitives.activeBackground", "--notectl-active-bg"], ["primitives.danger", "--notectl-danger"], ["primitives.dangerMuted", "--notectl-danger-muted"], ["primitives.success", "--notectl-success"], ["primitives.shadow", "--notectl-shadow"], ["primitives.focusRing", "--notectl-focus-ring"], ["toolbar.background", "--notectl-toolbar-bg"], ["toolbar.borderColor", "--notectl-toolbar-border"], ["codeBlock.background", "--notectl-code-block-bg"], ["codeBlock.foreground", "--notectl-code-block-color"], ["codeBlock.headerBackground", "--notectl-code-block-header-bg"], ["codeBlock.headerForeground", "--notectl-code-block-header-color"], ["codeBlock.headerBorder", "--notectl-code-block-header-border"], ["tooltip.background", "--notectl-tooltip-bg"], ["tooltip.foreground", "--notectl-tooltip-fg"]], it = /* @__PURE__ */ new Map([["--notectl-toolbar-bg", "var(--notectl-surface-raised)"], ["--notectl-toolbar-border", "var(--notectl-border)"], ["--notectl-code-block-bg", "var(--notectl-surface-raised)"], ["--notectl-code-block-color", "var(--notectl-fg)"], ["--notectl-code-block-header-bg", "var(--notectl-surface-raised)"], ["--notectl-code-block-header-color", "var(--notectl-fg-muted)"], ["--notectl-code-block-header-border", "var(--notectl-border)"], ["--notectl-tooltip-bg", "var(--notectl-fg)"], ["--notectl-tooltip-fg", "var(--notectl-bg)"]]);
1308
- function at(e2, t2) {
1309
- const n2 = t2.split(".");
1310
- let s2 = e2;
1311
- for (const e3 of n2) {
1430
+ const ue = [["primitives.background", "--notectl-bg"], ["primitives.foreground", "--notectl-fg"], ["primitives.mutedForeground", "--notectl-fg-muted"], ["primitives.border", "--notectl-border"], ["primitives.borderFocus", "--notectl-border-focus"], ["primitives.primary", "--notectl-primary"], ["primitives.primaryForeground", "--notectl-primary-fg"], ["primitives.primaryMuted", "--notectl-primary-muted"], ["primitives.surfaceRaised", "--notectl-surface-raised"], ["primitives.surfaceOverlay", "--notectl-surface-overlay"], ["primitives.hoverBackground", "--notectl-hover-bg"], ["primitives.activeBackground", "--notectl-active-bg"], ["primitives.danger", "--notectl-danger"], ["primitives.dangerMuted", "--notectl-danger-muted"], ["primitives.success", "--notectl-success"], ["primitives.shadow", "--notectl-shadow"], ["primitives.focusRing", "--notectl-focus-ring"], ["toolbar.background", "--notectl-toolbar-bg"], ["toolbar.borderColor", "--notectl-toolbar-border"], ["codeBlock.background", "--notectl-code-block-bg"], ["codeBlock.foreground", "--notectl-code-block-color"], ["codeBlock.headerBackground", "--notectl-code-block-header-bg"], ["codeBlock.headerForeground", "--notectl-code-block-header-color"], ["codeBlock.headerBorder", "--notectl-code-block-header-border"], ["tooltip.background", "--notectl-tooltip-bg"], ["tooltip.foreground", "--notectl-tooltip-fg"]], pe = /* @__PURE__ */ new Map([["--notectl-toolbar-bg", "var(--notectl-surface-raised)"], ["--notectl-toolbar-border", "var(--notectl-border)"], ["--notectl-code-block-bg", "var(--notectl-surface-raised)"], ["--notectl-code-block-color", "var(--notectl-fg)"], ["--notectl-code-block-header-bg", "var(--notectl-surface-raised)"], ["--notectl-code-block-header-color", "var(--notectl-fg-muted)"], ["--notectl-code-block-header-border", "var(--notectl-border)"], ["--notectl-tooltip-bg", "var(--notectl-fg)"], ["--notectl-tooltip-fg", "var(--notectl-bg)"]]);
1431
+ function fe(t2, e2) {
1432
+ const n2 = e2.split(".");
1433
+ let s2 = t2;
1434
+ for (const t3 of n2) {
1312
1435
  if (null == s2) return;
1313
- s2 = s2[e3];
1436
+ s2 = s2[t3];
1314
1437
  }
1315
1438
  return "string" == typeof s2 ? s2 : void 0;
1316
1439
  }
1317
- function ct(e2) {
1318
- const t2 = [":host {"];
1319
- for (const [n2, s2] of ot) {
1320
- const r2 = at(e2, n2);
1321
- if (void 0 !== r2) t2.push(` ${s2}: ${r2};`);
1440
+ function ge(t2) {
1441
+ const e2 = [":host {"];
1442
+ for (const [n2, s2] of ue) {
1443
+ const o2 = fe(t2, n2);
1444
+ if (void 0 !== o2) e2.push(` ${s2}: ${o2};`);
1322
1445
  else {
1323
- const e3 = it.get(s2);
1324
- e3 && t2.push(` ${s2}: ${e3};`);
1446
+ const t3 = pe.get(s2);
1447
+ t3 && e2.push(` ${s2}: ${t3};`);
1325
1448
  }
1326
1449
  }
1327
- return t2.push("}"), t2.join("\n");
1450
+ return e2.push("}"), e2.join("\n");
1328
1451
  }
1329
- function lt(e2) {
1330
- const t2 = new CSSStyleSheet();
1331
- return t2.replaceSync(ct(e2)), t2;
1452
+ function me(t2) {
1453
+ const e2 = new CSSStyleSheet();
1454
+ return e2.replaceSync(ge(t2)), e2;
1332
1455
  }
1333
- class ht {
1334
- constructor(e2, t2) {
1335
- this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.syncSelection = t2.syncSelection, this.schemaRegistry = t2.schemaRegistry, this.handleBeforeInput = this.onBeforeInput.bind(this), this.handleCompositionStart = this.onCompositionStart.bind(this), this.handleCompositionEnd = this.onCompositionEnd.bind(this), e2.addEventListener("beforeinput", this.handleBeforeInput), e2.addEventListener("compositionstart", this.handleCompositionStart), e2.addEventListener("compositionend", this.handleCompositionEnd);
1456
+ class ye {
1457
+ constructor(t2, e2) {
1458
+ this.element = t2, this.getState = e2.getState, this.dispatch = e2.dispatch, this.syncSelection = e2.syncSelection, this.schemaRegistry = e2.schemaRegistry, this.handleBeforeInput = this.onBeforeInput.bind(this), this.handleCompositionStart = this.onCompositionStart.bind(this), this.handleCompositionEnd = this.onCompositionEnd.bind(this), t2.addEventListener("beforeinput", this.handleBeforeInput), t2.addEventListener("compositionstart", this.handleCompositionStart), t2.addEventListener("compositionend", this.handleCompositionEnd);
1336
1459
  }
1337
1460
  getState;
1338
1461
  dispatch;
@@ -1342,66 +1465,66 @@ class ht {
1342
1465
  handleBeforeInput;
1343
1466
  handleCompositionStart;
1344
1467
  handleCompositionEnd;
1345
- onBeforeInput(e2) {
1346
- if (this.composing && "insertCompositionText" === e2.inputType) return;
1347
- e2.preventDefault(), "insertText" !== e2.inputType && "insertCompositionText" !== e2.inputType && this.syncSelection();
1348
- const t2 = this.getState();
1468
+ onBeforeInput(t2) {
1469
+ if (this.composing && "insertCompositionText" === t2.inputType) return;
1470
+ t2.preventDefault(), "insertText" !== t2.inputType && "insertCompositionText" !== t2.inputType && this.syncSelection();
1471
+ const e2 = this.getState();
1349
1472
  let n2 = null;
1350
- switch (e2.inputType) {
1473
+ switch (t2.inputType) {
1351
1474
  case "insertText":
1352
- e2.data && (n2 = Z(t2, e2.data, "input"));
1475
+ t2.data && (n2 = G(e2, t2.data, "input"));
1353
1476
  break;
1354
1477
  case "insertParagraph":
1355
- n2 = Y(t2);
1478
+ n2 = Q(e2);
1356
1479
  break;
1357
1480
  case "insertLineBreak":
1358
- n2 = ae(t2);
1481
+ n2 = rt(e2);
1359
1482
  break;
1360
1483
  case "deleteContentBackward":
1361
1484
  case "deleteByCut":
1362
- n2 = te(t2);
1485
+ n2 = Z(e2);
1363
1486
  break;
1364
1487
  case "deleteContentForward":
1365
- n2 = ie(t2);
1488
+ n2 = ot(e2);
1366
1489
  break;
1367
1490
  case "deleteWordBackward":
1368
- n2 = oe(t2);
1491
+ n2 = st(e2);
1369
1492
  break;
1370
1493
  case "deleteWordForward":
1371
- n2 = re(t2);
1494
+ n2 = nt(e2);
1372
1495
  break;
1373
1496
  case "deleteSoftLineBackward":
1374
- n2 = se(t2);
1497
+ n2 = et(e2);
1375
1498
  break;
1376
1499
  case "deleteSoftLineForward":
1377
- n2 = ne(t2);
1500
+ n2 = tt(e2);
1378
1501
  }
1379
- n2 && (this.dispatch(n2), "insertText" === e2.inputType && this.checkInputRules());
1502
+ n2 && (this.dispatch(n2), "insertText" === t2.inputType && this.checkInputRules());
1380
1503
  }
1381
- onCompositionStart(e2) {
1504
+ onCompositionStart(t2) {
1382
1505
  this.composing = true;
1383
1506
  }
1384
- onCompositionEnd(e2) {
1507
+ onCompositionEnd(t2) {
1385
1508
  this.composing = false;
1386
- const t2 = e2.data;
1387
- if (!t2) return;
1388
- const n2 = this.getState(), s2 = Z(n2, t2, "input");
1509
+ const e2 = t2.data;
1510
+ if (!e2) return;
1511
+ const n2 = this.getState(), s2 = G(n2, e2, "input");
1389
1512
  this.dispatch(s2);
1390
1513
  }
1391
1514
  checkInputRules() {
1392
1515
  if (!this.schemaRegistry) return;
1393
- const e2 = this.schemaRegistry.getInputRules();
1394
- if (0 === e2.length) return;
1395
- const t2 = this.getState();
1396
- if ($(t2.selection)) return;
1397
- const { anchor: n2 } = t2.selection, s2 = t2.getBlock(n2.blockId);
1516
+ const t2 = this.schemaRegistry.getInputRules();
1517
+ if (0 === t2.length) return;
1518
+ const e2 = this.getState();
1519
+ if (H(e2.selection)) return;
1520
+ const { anchor: n2 } = e2.selection, s2 = e2.getBlock(n2.blockId);
1398
1521
  if (!s2) return;
1399
- const r2 = M(s2).slice(0, n2.offset);
1400
- for (const n3 of e2) {
1401
- const e3 = n3.pattern.exec(r2);
1402
- if (e3) {
1403
- const s3 = e3.index, r3 = s3 + e3[0].length, o2 = n3.handler(t2, e3, s3, r3);
1404
- if (o2) return void this.dispatch(o2);
1522
+ const o2 = E(s2).slice(0, n2.offset);
1523
+ for (const n3 of t2) {
1524
+ const t3 = n3.pattern.exec(o2);
1525
+ if (t3) {
1526
+ const s3 = t3.index, o3 = s3 + t3[0].length, r2 = n3.handler(e2, t3, s3, o3);
1527
+ if (r2) return void this.dispatch(r2);
1405
1528
  }
1406
1529
  }
1407
1530
  }
@@ -1409,634 +1532,634 @@ class ht {
1409
1532
  this.element.removeEventListener("beforeinput", this.handleBeforeInput), this.element.removeEventListener("compositionstart", this.handleCompositionStart), this.element.removeEventListener("compositionend", this.handleCompositionEnd);
1410
1533
  }
1411
1534
  }
1412
- function dt(e2) {
1413
- return e2.reduce((e3, t2) => e3 + t2.text, "");
1535
+ function ke(t2) {
1536
+ return t2.reduce((t3, e2) => t3 + e2.text, "");
1414
1537
  }
1415
- function ut(e2) {
1416
- return e2.reduce((e3, t2) => e3 + t2.text.length, 0);
1538
+ function be(t2) {
1539
+ return t2.reduce((t3, e2) => t3 + e2.text.length, 0);
1417
1540
  }
1418
- const pt = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "BLOCKQUOTE", "UL", "OL", "LI", "HR", "PRE", "TABLE", "THEAD", "TBODY", "TR"]), ft = /* @__PURE__ */ new Set(["STRONG", "B", "EM", "I", "U", "S", "STRIKE", "DEL", "A", "SPAN", "BR", "SUB", "SUP", "CODE"]);
1419
- class gt {
1541
+ const Se = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "BLOCKQUOTE", "UL", "OL", "LI", "HR", "PRE", "TABLE", "THEAD", "TBODY", "TR"]), ve = /* @__PURE__ */ new Set(["STRONG", "B", "EM", "I", "U", "S", "STRIKE", "DEL", "A", "SPAN", "BR", "SUB", "SUP", "CODE"]);
1542
+ class we {
1420
1543
  schema;
1421
1544
  blockParseRules;
1422
1545
  markParseRules;
1423
- constructor(e2) {
1424
- this.schema = e2.schema, this.blockParseRules = e2.schemaRegistry?.getBlockParseRules() ?? [], this.markParseRules = e2.schemaRegistry?.getMarkParseRules() ?? [];
1546
+ constructor(t2) {
1547
+ this.schema = t2.schema, this.blockParseRules = t2.schemaRegistry?.getBlockParseRules() ?? [], this.markParseRules = t2.schemaRegistry?.getMarkParseRules() ?? [];
1425
1548
  }
1426
- parse(e2) {
1427
- const t2 = this.parseContainer(e2);
1428
- return 0 === t2.length ? { blocks: [{ type: this.resolveBlockType(fe("paragraph")), segments: [{ text: "", marks: [] }] }] } : { blocks: t2 };
1549
+ parse(t2) {
1550
+ const e2 = this.parseContainer(t2);
1551
+ return 0 === e2.length ? { blocks: [{ type: this.resolveBlockType(ut("paragraph")), segments: [{ text: "", marks: [] }] }] } : { blocks: e2 };
1429
1552
  }
1430
- parseContainer(e2) {
1431
- const t2 = [];
1553
+ parseContainer(t2) {
1554
+ const e2 = [];
1432
1555
  let n2 = [];
1433
- for (const s2 of Array.from(e2.childNodes)) if (s2.nodeType === Node.ELEMENT_NODE) {
1434
- const e3 = s2;
1435
- this.isBlockElement(e3) ? (this.flushPendingSegments(t2, n2), n2 = [], t2.push(...this.parseBlockElement(e3))) : n2.push(...this.parseInlineNode(s2, []));
1556
+ for (const s2 of Array.from(t2.childNodes)) if (s2.nodeType === Node.ELEMENT_NODE) {
1557
+ const t3 = s2;
1558
+ this.isBlockElement(t3) ? (this.flushPendingSegments(e2, n2), n2 = [], e2.push(...this.parseBlockElement(t3))) : n2.push(...this.parseInlineNode(s2, []));
1436
1559
  } else if (s2.nodeType === Node.TEXT_NODE) {
1437
- const e3 = s2.textContent ?? "";
1438
- e3 && n2.push({ text: e3, marks: [] });
1560
+ const t3 = s2.textContent ?? "";
1561
+ t3 && n2.push({ text: t3, marks: [] });
1439
1562
  }
1440
- return this.flushPendingSegments(t2, n2), t2;
1563
+ return this.flushPendingSegments(e2, n2), e2;
1441
1564
  }
1442
- parseBlockElement(e2) {
1443
- const t2 = e2.tagName, n2 = /^H([1-6])$/.exec(t2);
1565
+ parseBlockElement(t2) {
1566
+ const e2 = t2.tagName, n2 = /^H([1-6])$/.exec(e2);
1444
1567
  if (n2) {
1445
- const t3 = Number(n2[1]), s2 = this.resolveBlockType(fe("heading"));
1446
- return [{ type: s2, ...s2 === fe("heading") ? { attrs: { level: t3 } } : {}, segments: this.ensureSegments(this.parseInlineChildren(e2, [])) }];
1568
+ const e3 = Number(n2[1]), s2 = this.resolveBlockType(ut("heading"));
1569
+ return [{ type: s2, ...s2 === ut("heading") ? { attrs: { level: e3 } } : {}, segments: this.ensureSegments(this.parseInlineChildren(t2, [])) }];
1447
1570
  }
1448
- switch (t2) {
1571
+ switch (e2) {
1449
1572
  case "P":
1450
1573
  case "DIV":
1451
- return [{ type: this.resolveBlockType(fe("paragraph")), segments: this.ensureSegments(this.parseInlineChildren(e2, [])) }];
1574
+ return [{ type: this.resolveBlockType(ut("paragraph")), segments: this.ensureSegments(this.parseInlineChildren(t2, [])) }];
1452
1575
  case "BLOCKQUOTE":
1453
- return this.parseBlockquote(e2);
1576
+ return this.parseBlockquote(t2);
1454
1577
  case "UL":
1455
- return this.parseList(e2, "bullet", 0);
1578
+ return this.parseList(t2, "bullet", 0);
1456
1579
  case "OL":
1457
- return this.parseList(e2, "ordered", 0);
1580
+ return this.parseList(t2, "ordered", 0);
1458
1581
  case "LI":
1459
- return this.parseListItem(e2, "bullet", 0);
1582
+ return this.parseListItem(t2, "bullet", 0);
1460
1583
  case "HR":
1461
- return [{ type: this.resolveBlockType(fe("horizontal_rule")), segments: [] }];
1584
+ return [{ type: this.resolveBlockType(ut("horizontal_rule")), segments: [] }];
1462
1585
  case "PRE":
1463
- return [{ type: this.resolveBlockType(fe("paragraph")), segments: this.ensureSegments(this.parsePreContent(e2)) }];
1586
+ return [{ type: this.resolveBlockType(ut("paragraph")), segments: this.ensureSegments(this.parsePreContent(t2)) }];
1464
1587
  case "TABLE":
1465
1588
  case "THEAD":
1466
1589
  case "TBODY":
1467
1590
  case "TR":
1468
- return this.parseTableAsParagraphs(e2);
1591
+ return this.parseTableAsParagraphs(t2);
1469
1592
  default: {
1470
- const t3 = this.matchBlockRule(e2);
1471
- return t3 ? [{ type: t3.type, ...t3.attrs ? { attrs: t3.attrs } : {}, segments: this.ensureSegments(this.parseInlineChildren(e2, [])) }] : [{ type: this.resolveBlockType(fe("paragraph")), segments: this.ensureSegments(this.parseInlineChildren(e2, [])) }];
1593
+ const e3 = this.matchBlockRule(t2);
1594
+ return e3 ? [{ type: e3.type, ...e3.attrs ? { attrs: e3.attrs } : {}, segments: this.ensureSegments(this.parseInlineChildren(t2, [])) }] : [{ type: this.resolveBlockType(ut("paragraph")), segments: this.ensureSegments(this.parseInlineChildren(t2, [])) }];
1472
1595
  }
1473
1596
  }
1474
1597
  }
1475
- parseBlockquote(e2) {
1476
- const t2 = this.resolveBlockType(fe("blockquote"));
1477
- return Array.from(e2.childNodes).some((e3) => e3.nodeType === Node.ELEMENT_NODE && this.isBlockElement(e3)) ? this.parseContainer(e2).map((e3) => ({ type: t2, segments: e3.segments })) : [{ type: t2, segments: this.ensureSegments(this.parseInlineChildren(e2, [])) }];
1598
+ parseBlockquote(t2) {
1599
+ const e2 = this.resolveBlockType(ut("blockquote"));
1600
+ return Array.from(t2.childNodes).some((t3) => t3.nodeType === Node.ELEMENT_NODE && this.isBlockElement(t3)) ? this.parseContainer(t2).map((t3) => ({ type: e2, segments: t3.segments })) : [{ type: e2, segments: this.ensureSegments(this.parseInlineChildren(t2, [])) }];
1478
1601
  }
1479
- parseList(e2, t2, n2) {
1602
+ parseList(t2, e2, n2) {
1480
1603
  const s2 = [];
1481
- for (const r2 of Array.from(e2.children)) {
1482
- const e3 = r2;
1483
- "LI" === e3.tagName ? s2.push(...this.parseListItem(e3, t2, n2)) : "UL" === e3.tagName ? s2.push(...this.parseList(e3, "bullet", n2 + 1)) : "OL" === e3.tagName && s2.push(...this.parseList(e3, "ordered", n2 + 1));
1604
+ for (const o2 of Array.from(t2.children)) {
1605
+ const t3 = o2;
1606
+ "LI" === t3.tagName ? s2.push(...this.parseListItem(t3, e2, n2)) : "UL" === t3.tagName ? s2.push(...this.parseList(t3, "bullet", n2 + 1)) : "OL" === t3.tagName && s2.push(...this.parseList(t3, "ordered", n2 + 1));
1484
1607
  }
1485
1608
  return s2;
1486
1609
  }
1487
- parseListItem(e2, t2, n2) {
1488
- const s2 = [], r2 = this.resolveBlockType(fe("list_item")), o2 = this.hasCheckbox(e2), i3 = o2 ? "checklist" : t2, a4 = !!o2 && this.isCheckboxChecked(e2), c3 = [], l2 = [];
1489
- for (const t3 of Array.from(e2.childNodes)) if (t3.nodeType === Node.ELEMENT_NODE) {
1490
- const e3 = t3;
1491
- "UL" === e3.tagName || "OL" === e3.tagName ? l2.push(e3) : "INPUT" === e3.tagName && "checkbox" === e3.getAttribute("type") || (this.isBlockElement(e3) ? c3.push(...this.parseInlineChildren(e3, [])) : c3.push(...this.parseInlineNode(t3, [])));
1492
- } else if (t3.nodeType === Node.TEXT_NODE) {
1493
- const e3 = t3.textContent ?? "";
1494
- e3 && c3.push({ text: e3, marks: [] });
1610
+ parseListItem(t2, e2, n2) {
1611
+ const s2 = [], o2 = this.resolveBlockType(ut("list_item")), r2 = this.hasCheckbox(t2), i3 = r2 ? "checklist" : e2, a4 = !!r2 && this.isCheckboxChecked(t2), c3 = [], l2 = [];
1612
+ for (const e3 of Array.from(t2.childNodes)) if (e3.nodeType === Node.ELEMENT_NODE) {
1613
+ const t3 = e3;
1614
+ "UL" === t3.tagName || "OL" === t3.tagName ? l2.push(t3) : "INPUT" === t3.tagName && "checkbox" === t3.getAttribute("type") || (this.isBlockElement(t3) ? c3.push(...this.parseInlineChildren(t3, [])) : c3.push(...this.parseInlineNode(e3, [])));
1615
+ } else if (e3.nodeType === Node.TEXT_NODE) {
1616
+ const t3 = e3.textContent ?? "";
1617
+ t3 && c3.push({ text: t3, marks: [] });
1495
1618
  }
1496
- s2.push({ type: r2, attrs: { listType: i3, indent: n2, ..."checklist" === i3 ? { checked: a4 } : {} }, segments: this.ensureSegments(this.normalizeSegments(c3)) });
1497
- for (const e3 of l2) {
1498
- const t3 = "OL" === e3.tagName ? "ordered" : "bullet";
1499
- s2.push(...this.parseList(e3, t3, n2 + 1));
1619
+ s2.push({ type: o2, attrs: { listType: i3, indent: n2, ..."checklist" === i3 ? { checked: a4 } : {} }, segments: this.ensureSegments(this.normalizeSegments(c3)) });
1620
+ for (const t3 of l2) {
1621
+ const e3 = "OL" === t3.tagName ? "ordered" : "bullet";
1622
+ s2.push(...this.parseList(t3, e3, n2 + 1));
1500
1623
  }
1501
1624
  return s2;
1502
1625
  }
1503
- parseInlineChildren(e2, t2) {
1626
+ parseInlineChildren(t2, e2) {
1504
1627
  const n2 = [];
1505
- for (const s2 of Array.from(e2.childNodes)) n2.push(...this.parseInlineNode(s2, t2));
1628
+ for (const s2 of Array.from(t2.childNodes)) n2.push(...this.parseInlineNode(s2, e2));
1506
1629
  return this.normalizeSegments(n2);
1507
1630
  }
1508
- parseInlineNode(e2, t2) {
1509
- if (e2.nodeType === Node.TEXT_NODE) {
1510
- const n3 = e2.textContent ?? "";
1511
- return n3 ? [{ text: n3, marks: this.resolveMarks(t2) }] : [];
1631
+ parseInlineNode(t2, e2) {
1632
+ if (t2.nodeType === Node.TEXT_NODE) {
1633
+ const n3 = t2.textContent ?? "";
1634
+ return n3 ? [{ text: n3, marks: this.resolveMarks(e2) }] : [];
1512
1635
  }
1513
- if (e2.nodeType !== Node.ELEMENT_NODE) return [];
1514
- const n2 = e2, s2 = n2.tagName;
1515
- if ("BR" === s2) return [{ text: "\n", marks: this.resolveMarks(t2) }];
1516
- if (this.isBlockElement(n2) && !ft.has(s2)) return this.parseInlineChildren(n2, t2);
1517
- const r2 = this.mergeMarks(t2, this.marksFromElement(n2));
1518
- return this.parseInlineChildren(n2, r2);
1636
+ if (t2.nodeType !== Node.ELEMENT_NODE) return [];
1637
+ const n2 = t2, s2 = n2.tagName;
1638
+ if ("BR" === s2) return [{ text: "\n", marks: this.resolveMarks(e2) }];
1639
+ if (this.isBlockElement(n2) && !ve.has(s2)) return this.parseInlineChildren(n2, e2);
1640
+ const o2 = this.mergeMarks(e2, this.marksFromElement(n2));
1641
+ return this.parseInlineChildren(n2, o2);
1519
1642
  }
1520
- parsePreContent(e2) {
1521
- const t2 = e2.textContent ?? "";
1522
- return t2 ? [{ text: t2, marks: [] }] : [];
1643
+ parsePreContent(t2) {
1644
+ const e2 = t2.textContent ?? "";
1645
+ return e2 ? [{ text: e2, marks: [] }] : [];
1523
1646
  }
1524
- parseTableAsParagraphs(e2) {
1525
- const t2 = [], n2 = e2.querySelectorAll("td, th");
1526
- for (const e3 of Array.from(n2)) {
1527
- const n3 = this.parseInlineChildren(e3, []);
1528
- n3.length > 0 && n3.some((e4) => e4.text.length > 0) && t2.push({ type: this.resolveBlockType(fe("paragraph")), segments: this.ensureSegments(n3) });
1647
+ parseTableAsParagraphs(t2) {
1648
+ const e2 = [], n2 = t2.querySelectorAll("td, th");
1649
+ for (const t3 of Array.from(n2)) {
1650
+ const n3 = this.parseInlineChildren(t3, []);
1651
+ n3.length > 0 && n3.some((t4) => t4.text.length > 0) && e2.push({ type: this.resolveBlockType(ut("paragraph")), segments: this.ensureSegments(n3) });
1529
1652
  }
1530
- return t2;
1653
+ return e2;
1531
1654
  }
1532
- marksFromElement(e2) {
1533
- const t2 = [], n2 = e2.tagName.toLowerCase();
1655
+ marksFromElement(t2) {
1656
+ const e2 = [], n2 = t2.tagName.toLowerCase();
1534
1657
  if (this.markParseRules.length > 0) {
1535
1658
  const s3 = /* @__PURE__ */ new Set();
1536
- for (const r2 of this.markParseRules) if (r2.rule.tag === n2 && !s3.has(r2.type)) if (r2.rule.getAttrs) {
1537
- const n3 = r2.rule.getAttrs(e2);
1659
+ for (const o2 of this.markParseRules) if (o2.rule.tag === n2 && !s3.has(o2.type)) if (o2.rule.getAttrs) {
1660
+ const n3 = o2.rule.getAttrs(t2);
1538
1661
  if (false === n3) continue;
1539
- t2.push({ type: ge(r2.type), ...Object.keys(n3).length > 0 ? { attrs: n3 } : {} }), s3.add(r2.type);
1540
- } else t2.push({ type: ge(r2.type) }), s3.add(r2.type);
1541
- if (s3.size > 0) return t2;
1662
+ e2.push({ type: pt(o2.type), ...Object.keys(n3).length > 0 ? { attrs: n3 } : {} }), s3.add(o2.type);
1663
+ } else e2.push({ type: pt(o2.type) }), s3.add(o2.type);
1664
+ if (s3.size > 0) return e2;
1542
1665
  }
1543
- const s2 = e2.tagName;
1544
- if ("STRONG" !== s2 && "B" !== s2 || t2.push({ type: ge("bold") }), "EM" !== s2 && "I" !== s2 || t2.push({ type: ge("italic") }), "U" === s2 && t2.push({ type: ge("underline") }), "S" !== s2 && "STRIKE" !== s2 && "DEL" !== s2 || t2.push({ type: ge("strikethrough") }), "A" === s2) {
1545
- const n3 = e2.getAttribute("href") ?? "";
1546
- t2.push({ type: ge("link"), attrs: { href: n3 } });
1666
+ const s2 = t2.tagName;
1667
+ if ("STRONG" !== s2 && "B" !== s2 || e2.push({ type: pt("bold") }), "EM" !== s2 && "I" !== s2 || e2.push({ type: pt("italic") }), "U" === s2 && e2.push({ type: pt("underline") }), "S" !== s2 && "STRIKE" !== s2 && "DEL" !== s2 || e2.push({ type: pt("strikethrough") }), "A" === s2) {
1668
+ const n3 = t2.getAttribute("href") ?? "";
1669
+ e2.push({ type: pt("link"), attrs: { href: n3 } });
1547
1670
  }
1548
- return t2;
1671
+ return e2;
1549
1672
  }
1550
- mergeMarks(e2, t2) {
1551
- const n2 = [...e2];
1552
- for (const e3 of t2) n2.some((t3) => t3.type === e3.type) || n2.push(e3);
1673
+ mergeMarks(t2, e2) {
1674
+ const n2 = [...t2];
1675
+ for (const t3 of e2) n2.some((e3) => e3.type === t3.type) || n2.push(t3);
1553
1676
  return n2;
1554
1677
  }
1555
- resolveMarks(e2) {
1556
- return e2.filter((e3) => le(this.schema, e3.type));
1678
+ resolveMarks(t2) {
1679
+ return t2.filter((t3) => at(this.schema, t3.type));
1557
1680
  }
1558
- resolveBlockType(e2) {
1559
- return he(this.schema, e2) ? e2 : fe("paragraph");
1681
+ resolveBlockType(t2) {
1682
+ return ct(this.schema, t2) ? t2 : ut("paragraph");
1560
1683
  }
1561
- normalizeSegments(e2) {
1562
- if (0 === e2.length) return [];
1563
- const t2 = [];
1564
- for (const n2 of e2) {
1565
- const e3 = t2[t2.length - 1];
1566
- e3 && _(e3.marks, n2.marks) ? t2[t2.length - 1] = { text: e3.text + n2.text, marks: e3.marks } : n2.text.length > 0 && t2.push(n2);
1684
+ normalizeSegments(t2) {
1685
+ if (0 === t2.length) return [];
1686
+ const e2 = [];
1687
+ for (const n2 of t2) {
1688
+ const t3 = e2[e2.length - 1];
1689
+ t3 && L(t3.marks, n2.marks) ? e2[e2.length - 1] = { text: t3.text + n2.text, marks: t3.marks } : n2.text.length > 0 && e2.push(n2);
1567
1690
  }
1568
- return t2;
1691
+ return e2;
1569
1692
  }
1570
- ensureSegments(e2) {
1571
- return 0 === e2.length ? [{ text: "", marks: [] }] : e2;
1693
+ ensureSegments(t2) {
1694
+ return 0 === t2.length ? [{ text: "", marks: [] }] : t2;
1572
1695
  }
1573
- matchBlockRule(e2) {
1574
- const t2 = e2.tagName.toLowerCase();
1575
- for (const n2 of this.blockParseRules) if (n2.rule.tag === t2) {
1696
+ matchBlockRule(t2) {
1697
+ const e2 = t2.tagName.toLowerCase();
1698
+ for (const n2 of this.blockParseRules) if (n2.rule.tag === e2) {
1576
1699
  if (n2.rule.getAttrs) {
1577
- const t3 = n2.rule.getAttrs(e2);
1578
- if (false === t3) continue;
1579
- return { type: fe(n2.type), attrs: t3 };
1700
+ const e3 = n2.rule.getAttrs(t2);
1701
+ if (false === e3) continue;
1702
+ return { type: ut(n2.type), attrs: e3 };
1580
1703
  }
1581
- return { type: fe(n2.type) };
1704
+ return { type: ut(n2.type) };
1582
1705
  }
1583
1706
  return null;
1584
1707
  }
1585
- isBlockElement(e2) {
1586
- if (pt.has(e2.tagName)) return true;
1587
- const t2 = e2.tagName.toLowerCase();
1588
- return this.blockParseRules.some((e3) => e3.rule.tag === t2);
1708
+ isBlockElement(t2) {
1709
+ if (Se.has(t2.tagName)) return true;
1710
+ const e2 = t2.tagName.toLowerCase();
1711
+ return this.blockParseRules.some((t3) => t3.rule.tag === e2);
1589
1712
  }
1590
- hasCheckbox(e2) {
1591
- return null !== e2.querySelector('input[type="checkbox"]');
1713
+ hasCheckbox(t2) {
1714
+ return null !== t2.querySelector('input[type="checkbox"]');
1592
1715
  }
1593
- isCheckboxChecked(e2) {
1594
- const t2 = e2.querySelector('input[type="checkbox"]');
1595
- return t2?.hasAttribute("checked") ?? false;
1716
+ isCheckboxChecked(t2) {
1717
+ const e2 = t2.querySelector('input[type="checkbox"]');
1718
+ return e2?.hasAttribute("checked") ?? false;
1596
1719
  }
1597
- flushPendingSegments(e2, t2) {
1598
- const n2 = this.normalizeSegments(t2);
1599
- 0 !== n2.length && (n2.every((e3) => "" === e3.text.trim()) || e2.push({ type: this.resolveBlockType(fe("paragraph")), segments: n2 }));
1720
+ flushPendingSegments(t2, e2) {
1721
+ const n2 = this.normalizeSegments(e2);
1722
+ 0 !== n2.length && (n2.every((t3) => "" === t3.text.trim()) || t2.push({ type: this.resolveBlockType(ut("paragraph")), segments: n2 }));
1600
1723
  }
1601
1724
  }
1602
- class mt {
1603
- constructor(e2, t2) {
1604
- this.element = e2, this.getState = t2.getState, this.dispatch = t2.dispatch, this.schemaRegistry = t2.schemaRegistry, this.handlePaste = this.onPaste.bind(this), e2.addEventListener("paste", this.handlePaste);
1725
+ class Te {
1726
+ constructor(t2, e2) {
1727
+ this.element = t2, this.getState = e2.getState, this.dispatch = e2.dispatch, this.schemaRegistry = e2.schemaRegistry, this.handlePaste = this.onPaste.bind(this), t2.addEventListener("paste", this.handlePaste);
1605
1728
  }
1606
1729
  getState;
1607
1730
  dispatch;
1608
1731
  schemaRegistry;
1609
1732
  handlePaste;
1610
- onPaste(e2) {
1611
- e2.preventDefault();
1612
- const t2 = e2.clipboardData;
1613
- if (!t2) return;
1614
- const n2 = t2.getData("application/x-notectl-block");
1733
+ onPaste(t2) {
1734
+ t2.preventDefault();
1735
+ const e2 = t2.clipboardData;
1736
+ if (!e2) return;
1737
+ const n2 = e2.getData("application/x-notectl-block");
1615
1738
  if (n2) return void this.handleBlockPaste(n2);
1616
- if (this.handleFilePaste(t2)) return;
1617
- const s2 = t2.getData("text/plain");
1739
+ if (this.handleFilePaste(e2)) return;
1740
+ const s2 = e2.getData("text/plain");
1618
1741
  if (s2) {
1619
- const e3 = (function(e4) {
1620
- if (Qe && Qe.plainText === e4) return Qe.blocks;
1742
+ const t3 = (function(t4) {
1743
+ if (Gt && Gt.plainText === t4) return Gt.blocks;
1621
1744
  })(s2);
1622
- if (e3 && this.handleRichPaste(e3)) return;
1745
+ if (t3 && this.handleRichPaste(t3)) return;
1623
1746
  }
1624
- const r2 = this.getState(), i3 = t2.getData("text/html");
1747
+ const o2 = this.getState(), i3 = e2.getData("text/html");
1625
1748
  if (i3) {
1626
- const e3 = this.extractRichData(i3);
1627
- if (e3 && this.handleRichPasteFromJson(e3)) return;
1628
- const t3 = this.schemaRegistry ? this.schemaRegistry.getAllowedTags() : ["strong", "em", "u", "b", "i", "p", "br", "div", "span"], n3 = this.schemaRegistry ? this.schemaRegistry.getAllowedAttrs() : [], s3 = Ne.sanitize(i3, { ALLOWED_TAGS: t3, ALLOWED_ATTR: n3 });
1749
+ const t3 = this.extractRichData(i3);
1750
+ if (t3 && this.handleRichPasteFromJson(t3)) return;
1751
+ const e3 = this.schemaRegistry ? this.schemaRegistry.getAllowedTags() : ["strong", "em", "u", "b", "i", "p", "br", "div", "span"], n3 = this.schemaRegistry ? this.schemaRegistry.getAllowedAttrs() : [], s3 = Mt.sanitize(i3, { ALLOWED_TAGS: e3, ALLOWED_ATTR: n3 });
1629
1752
  if (this.schemaRegistry) {
1630
- const e4 = de(this.schemaRegistry), t4 = new gt({ schema: e4, schemaRegistry: this.schemaRegistry }), n4 = document.createElement("template");
1753
+ const t4 = lt(this.schemaRegistry), e4 = new we({ schema: t4, schemaRegistry: this.schemaRegistry }), n4 = document.createElement("template");
1631
1754
  n4.innerHTML = s3;
1632
- const i4 = (function(e5, t5) {
1633
- if (0 === t5.blocks.length) return e5.transaction("paste").setSelection(e5.selection).build();
1634
- const n5 = t5.blocks[0];
1635
- return n5 ? 1 === t5.blocks.length && n5.type === fe("paragraph") ? (function(e6, t6) {
1636
- const n6 = e6.selection;
1637
- if ($(n6)) return e6.transaction("paste").setSelection(n6).build();
1638
- const s4 = e6.transaction("paste"), r3 = V(n6) ? null : q(n6, e6.getBlockOrder());
1639
- V(n6) || ce(e6, s4);
1640
- const o2 = r3 ? r3.from.blockId : n6.anchor.blockId, i5 = r3 ? r3.from.offset : n6.anchor.offset, a4 = ut(t6), c3 = dt(t6);
1641
- return s4.insertText(o2, i5, c3, [], t6), s4.setSelection(F(o2, i5 + a4)), s4.build();
1642
- })(e5, n5.segments) : 1 === t5.blocks.length ? (function(e6, t6) {
1643
- const n6 = e6.selection;
1644
- if ($(n6)) return e6.transaction("paste").setSelection(n6).build();
1645
- const s4 = e6.transaction("paste"), r3 = V(n6) ? null : q(n6, e6.getBlockOrder());
1646
- V(n6) || ce(e6, s4);
1647
- const o2 = r3 ? r3.from.blockId : n6.anchor.blockId, i5 = r3 ? r3.from.offset : n6.anchor.offset, a4 = ut(t6.segments), c3 = dt(t6.segments);
1648
- return s4.setBlockType(o2, t6.type, t6.attrs), s4.insertText(o2, i5, c3, [], t6.segments), s4.setSelection(F(o2, i5 + a4)), s4.build();
1649
- })(e5, n5) : (function(e6, t6) {
1650
- const n6 = e6.selection;
1651
- if ($(n6)) return e6.transaction("paste").setSelection(n6).build();
1652
- const s4 = e6.transaction("paste"), r3 = V(n6) ? null : q(n6, e6.getBlockOrder());
1653
- V(n6) || ce(e6, s4);
1654
- const i5 = r3 ? r3.from.blockId : n6.anchor.blockId, a4 = r3 ? r3.from.offset : n6.anchor.offset, c3 = e6.getBlockOrder().indexOf(i5), l2 = t6.blocks[0], h3 = t6.blocks[t6.blocks.length - 1];
1655
- if (!l2 || !h3) return s4.build();
1656
- const d2 = t6.blocks.slice(1, -1), u2 = ut(l2.segments);
1657
- l2.segments.length > 0 && u2 > 0 && s4.insertText(i5, a4, dt(l2.segments), [], l2.segments), l2.type !== fe("paragraph") && s4.setBlockType(i5, l2.type, l2.attrs);
1658
- const p2 = a4 + u2, f3 = L();
1659
- s4.splitBlock(i5, p2, f3);
1755
+ const i4 = (function(t5, e5) {
1756
+ if (0 === e5.blocks.length) return t5.transaction("paste").setSelection(t5.selection).build();
1757
+ const n5 = e5.blocks[0];
1758
+ return n5 ? 1 === e5.blocks.length && n5.type === ut("paragraph") ? (function(t6, e6) {
1759
+ const n6 = t6.selection;
1760
+ if (H(n6)) return t6.transaction("paste").setSelection(n6).build();
1761
+ const s4 = t6.transaction("paste"), o3 = U(n6) ? null : K(n6, t6.getBlockOrder());
1762
+ U(n6) || it(t6, s4);
1763
+ const r2 = o3 ? o3.from.blockId : n6.anchor.blockId, i5 = o3 ? o3.from.offset : n6.anchor.offset, a4 = be(e6), c3 = ke(e6);
1764
+ return s4.insertText(r2, i5, c3, [], e6), s4.setSelection(O(r2, i5 + a4)), s4.build();
1765
+ })(t5, n5.segments) : 1 === e5.blocks.length ? (function(t6, e6) {
1766
+ const n6 = t6.selection;
1767
+ if (H(n6)) return t6.transaction("paste").setSelection(n6).build();
1768
+ const s4 = t6.transaction("paste"), o3 = U(n6) ? null : K(n6, t6.getBlockOrder());
1769
+ U(n6) || it(t6, s4);
1770
+ const r2 = o3 ? o3.from.blockId : n6.anchor.blockId, i5 = o3 ? o3.from.offset : n6.anchor.offset, a4 = be(e6.segments), c3 = ke(e6.segments);
1771
+ return s4.setBlockType(r2, e6.type, e6.attrs), s4.insertText(r2, i5, c3, [], e6.segments), s4.setSelection(O(r2, i5 + a4)), s4.build();
1772
+ })(t5, n5) : (function(t6, e6) {
1773
+ const n6 = t6.selection;
1774
+ if (H(n6)) return t6.transaction("paste").setSelection(n6).build();
1775
+ const s4 = t6.transaction("paste"), o3 = U(n6) ? null : K(n6, t6.getBlockOrder());
1776
+ U(n6) || it(t6, s4);
1777
+ const i5 = o3 ? o3.from.blockId : n6.anchor.blockId, a4 = o3 ? o3.from.offset : n6.anchor.offset, c3 = t6.getBlockOrder().indexOf(i5), l2 = e6.blocks[0], d2 = e6.blocks[e6.blocks.length - 1];
1778
+ if (!l2 || !d2) return s4.build();
1779
+ const h3 = e6.blocks.slice(1, -1), u2 = be(l2.segments);
1780
+ l2.segments.length > 0 && u2 > 0 && s4.insertText(i5, a4, ke(l2.segments), [], l2.segments), l2.type !== ut("paragraph") && s4.setBlockType(i5, l2.type, l2.attrs);
1781
+ const p2 = a4 + u2, f2 = P();
1782
+ s4.splitBlock(i5, p2, f2);
1660
1783
  let m2 = c3 + 1;
1661
- for (const e7 of d2) {
1662
- const t7 = e7.segments.map((e8) => g(e8.text, [...e8.marks])), n7 = o(e7.type, t7.length > 0 ? t7 : void 0, L(), e7.attrs);
1784
+ for (const t7 of h3) {
1785
+ const e7 = t7.segments.map((t8) => g(t8.text, [...t8.marks])), n7 = r(t7.type, e7.length > 0 ? e7 : void 0, P(), t7.attrs);
1663
1786
  s4.insertNode([], m2, n7), m2++;
1664
1787
  }
1665
- const y2 = ut(h3.segments);
1666
- return h3.segments.length > 0 && y2 > 0 && s4.insertText(f3, 0, dt(h3.segments), [], h3.segments), h3.type !== fe("paragraph") && s4.setBlockType(f3, h3.type, h3.attrs), s4.setSelection(F(f3, y2)), s4.build();
1667
- })(e5, t5) : e5.transaction("paste").setSelection(e5.selection).build();
1668
- })(r2, t4.parse(n4.content));
1788
+ const y2 = be(d2.segments);
1789
+ return d2.segments.length > 0 && y2 > 0 && s4.insertText(f2, 0, ke(d2.segments), [], d2.segments), d2.type !== ut("paragraph") && s4.setBlockType(f2, d2.type, d2.attrs), s4.setSelection(O(f2, y2)), s4.build();
1790
+ })(t5, e5) : t5.transaction("paste").setSelection(t5.selection).build();
1791
+ })(o2, e4.parse(n4.content));
1669
1792
  this.dispatch(i4);
1670
1793
  } else {
1671
- const e4 = this.extractTextFromHTML(s3);
1672
- if (e4) {
1673
- const t4 = Z(r2, e4, "paste");
1674
- this.dispatch(t4);
1794
+ const t4 = this.extractTextFromHTML(s3);
1795
+ if (t4) {
1796
+ const e4 = G(o2, t4, "paste");
1797
+ this.dispatch(e4);
1675
1798
  }
1676
1799
  }
1677
1800
  return;
1678
1801
  }
1679
1802
  if (s2) {
1680
- const e3 = Z(this.getState(), s2, "paste");
1681
- this.dispatch(e3);
1803
+ const t3 = G(this.getState(), s2, "paste");
1804
+ this.dispatch(t3);
1682
1805
  }
1683
1806
  }
1684
- handleBlockPaste(e2) {
1685
- let t2;
1807
+ handleBlockPaste(t2) {
1808
+ let e2;
1686
1809
  try {
1687
- t2 = JSON.parse(e2);
1810
+ e2 = JSON.parse(t2);
1688
1811
  } catch {
1689
1812
  return;
1690
1813
  }
1691
- const n2 = t2.type;
1814
+ const n2 = e2.type;
1692
1815
  if (!n2) return;
1693
1816
  if (this.schemaRegistry && !this.schemaRegistry.getNodeSpec(n2)) return;
1694
- const s2 = this.getState(), r2 = s2.selection, i3 = $(r2) ? r2.nodeId : r2.anchor.blockId, a4 = L(), c3 = t2.attrs ? t2.attrs : void 0, h3 = o(fe(n2), [], a4, c3), d2 = this.findTableCellAncestor(s2, i3);
1695
- if (d2) {
1696
- const e3 = ve(s2.doc, d2);
1697
- if (!e3) return;
1698
- const t3 = s2.getBlock(d2);
1817
+ const s2 = this.getState(), o2 = s2.selection, i3 = H(o2) ? o2.nodeId : o2.anchor.blockId, a4 = P(), c3 = e2.attrs ? e2.attrs : void 0, d2 = r(ut(n2), [], a4, c3), h3 = this.findTableCellAncestor(s2, i3);
1818
+ if (h3) {
1819
+ const t3 = bt(s2.doc, h3);
1699
1820
  if (!t3) return;
1821
+ const e3 = s2.getBlock(h3);
1822
+ if (!e3) return;
1700
1823
  const n3 = s2.transaction("paste");
1701
- return n3.insertNode(e3, t3.children.length, h3), n3.setSelection(H(a4, [...e3, a4])), void this.dispatch(n3.build());
1824
+ return n3.insertNode(t3, e3.children.length, d2), n3.setSelection(_(a4, [...t3, a4])), void this.dispatch(n3.build());
1702
1825
  }
1703
- const u2 = ve(s2.doc, i3), p2 = u2 && u2.length > 1 ? u2.slice(0, -1) : [], f3 = (0 === p2.length ? s2.doc.children : (() => {
1704
- const e3 = s2.getBlock(p2[p2.length - 1]);
1705
- return e3 ? e3.children : [];
1706
- })()).findIndex((e3) => l(e3) && e3.id === i3);
1707
- if (f3 < 0) return;
1826
+ const u2 = bt(s2.doc, i3), p2 = u2 && u2.length > 1 ? u2.slice(0, -1) : [], f2 = (0 === p2.length ? s2.doc.children : (() => {
1827
+ const t3 = s2.getBlock(p2[p2.length - 1]);
1828
+ return t3 ? t3.children : [];
1829
+ })()).findIndex((t3) => l(t3) && t3.id === i3);
1830
+ if (f2 < 0) return;
1708
1831
  const g2 = s2.transaction("paste");
1709
- g2.insertNode(p2, f3 + 1, h3), g2.setSelection(H(a4, [...p2, a4])), this.dispatch(g2.build());
1832
+ g2.insertNode(p2, f2 + 1, d2), g2.setSelection(_(a4, [...p2, a4])), this.dispatch(g2.build());
1710
1833
  }
1711
- handleRichPasteFromJson(e2) {
1712
- let t2;
1834
+ handleRichPasteFromJson(t2) {
1835
+ let e2;
1713
1836
  try {
1714
- t2 = JSON.parse(e2);
1837
+ e2 = JSON.parse(t2);
1715
1838
  } catch {
1716
1839
  return false;
1717
1840
  }
1718
- return !(!Array.isArray(t2) || 0 === t2.length) && this.handleRichPaste(t2);
1841
+ return !(!Array.isArray(e2) || 0 === e2.length) && this.handleRichPaste(e2);
1719
1842
  }
1720
- handleRichPaste(e2) {
1721
- if (0 === e2.length) return false;
1722
- if (!e2.some((e3) => void 0 !== e3.type && "paragraph" !== e3.type)) return false;
1723
- const t2 = this.getState(), n2 = t2.selection, s2 = $(n2) ? n2.nodeId : n2.anchor.blockId, r2 = this.findTableCellAncestor(t2, s2);
1724
- return r2 ? this.insertRichBlocksIntoCell(e2, t2, s2, r2) : this.insertRichBlocksAtRoot(e2, t2, s2);
1725
- }
1726
- insertRichBlocksIntoCell(e2, t2, n2, s2) {
1727
- const r2 = ve(t2.doc, s2);
1728
- if (!r2) return false;
1729
- const i3 = t2.getBlock(s2);
1843
+ handleRichPaste(t2) {
1844
+ if (0 === t2.length) return false;
1845
+ if (!t2.some((t3) => void 0 !== t3.type && "paragraph" !== t3.type)) return false;
1846
+ const e2 = this.getState(), n2 = e2.selection, s2 = H(n2) ? n2.nodeId : n2.anchor.blockId, o2 = this.findTableCellAncestor(e2, s2);
1847
+ return o2 ? this.insertRichBlocksIntoCell(t2, e2, s2, o2) : this.insertRichBlocksAtRoot(t2, e2, s2);
1848
+ }
1849
+ insertRichBlocksIntoCell(t2, e2, n2, s2) {
1850
+ const o2 = bt(e2.doc, s2);
1851
+ if (!o2) return false;
1852
+ const i3 = e2.getBlock(s2);
1730
1853
  if (!i3) return false;
1731
- const a4 = t2.getBlock(n2), c3 = i3.children.findIndex((e3) => l(e3) && e3.id === n2), h3 = void 0 !== a4 && "paragraph" === a4.type && "" === M(a4);
1732
- let d2 = c3 >= 0 ? c3 + 1 : i3.children.length;
1733
- const u2 = t2.transaction("paste");
1734
- let p2, f3 = 0;
1735
- for (const t3 of e2) {
1736
- if (!t3.type) continue;
1737
- const e3 = L(), n3 = t3.text ?? "", s3 = n3 ? [g(n3)] : void 0, i4 = t3.attrs ? t3.attrs : void 0, a5 = o(fe(t3.type), s3, e3, i4);
1738
- u2.insertNode(r2, d2, a5), d2++, p2 = e3, f3 = n3.length;
1854
+ const a4 = e2.getBlock(n2), c3 = i3.children.findIndex((t3) => l(t3) && t3.id === n2), d2 = void 0 !== a4 && "paragraph" === a4.type && "" === E(a4);
1855
+ let h3 = c3 >= 0 ? c3 + 1 : i3.children.length;
1856
+ const u2 = e2.transaction("paste");
1857
+ let p2, f2 = 0;
1858
+ for (const e3 of t2) {
1859
+ if (!e3.type) continue;
1860
+ const t3 = P(), n3 = e3.text ?? "", s3 = n3 ? [g(n3)] : void 0, i4 = e3.attrs ? e3.attrs : void 0, a5 = r(ut(e3.type), s3, t3, i4);
1861
+ u2.insertNode(o2, h3, a5), h3++, p2 = t3, f2 = n3.length;
1739
1862
  }
1740
- return h3 && c3 >= 0 && u2.removeNode(r2, c3), p2 && u2.setSelection(F(p2, f3)), this.dispatch(u2.build()), true;
1863
+ return d2 && c3 >= 0 && u2.removeNode(o2, c3), p2 && u2.setSelection(O(p2, f2)), this.dispatch(u2.build()), true;
1741
1864
  }
1742
- insertRichBlocksAtRoot(e2, t2, n2) {
1743
- const s2 = ve(t2.doc, n2), r2 = s2 && s2.length > 1 ? s2.slice(0, -1) : [], i3 = (0 === r2.length ? t2.doc.children : (() => {
1744
- const e3 = t2.getBlock(r2[r2.length - 1]);
1745
- return e3 ? e3.children : [];
1746
- })()).findIndex((e3) => l(e3) && e3.id === n2);
1865
+ insertRichBlocksAtRoot(t2, e2, n2) {
1866
+ const s2 = bt(e2.doc, n2), o2 = s2 && s2.length > 1 ? s2.slice(0, -1) : [], i3 = (0 === o2.length ? e2.doc.children : (() => {
1867
+ const t3 = e2.getBlock(o2[o2.length - 1]);
1868
+ return t3 ? t3.children : [];
1869
+ })()).findIndex((t3) => l(t3) && t3.id === n2);
1747
1870
  if (i3 < 0) return false;
1748
- const a4 = t2.getBlock(n2), c3 = void 0 !== a4 && "paragraph" === a4.type && "" === M(a4);
1749
- let h3 = i3 + 1;
1750
- const d2 = t2.transaction("paste");
1871
+ const a4 = e2.getBlock(n2), c3 = void 0 !== a4 && "paragraph" === a4.type && "" === E(a4);
1872
+ let d2 = i3 + 1;
1873
+ const h3 = e2.transaction("paste");
1751
1874
  let u2, p2 = 0;
1752
- for (const t3 of e2) {
1753
- if (!t3.type) continue;
1754
- const e3 = L(), n3 = t3.text ?? "", s3 = n3 ? [g(n3)] : void 0, i4 = t3.attrs ? t3.attrs : void 0, a5 = o(fe(t3.type), s3, e3, i4);
1755
- d2.insertNode(r2, h3, a5), h3++, u2 = e3, p2 = n3.length;
1875
+ for (const e3 of t2) {
1876
+ if (!e3.type) continue;
1877
+ const t3 = P(), n3 = e3.text ?? "", s3 = n3 ? [g(n3)] : void 0, i4 = e3.attrs ? e3.attrs : void 0, a5 = r(ut(e3.type), s3, t3, i4);
1878
+ h3.insertNode(o2, d2, a5), d2++, u2 = t3, p2 = n3.length;
1756
1879
  }
1757
- return c3 && d2.removeNode(r2, i3), u2 && d2.setSelection(F(u2, p2)), this.dispatch(d2.build()), true;
1880
+ return c3 && h3.removeNode(o2, i3), u2 && h3.setSelection(O(u2, p2)), this.dispatch(h3.build()), true;
1758
1881
  }
1759
- findTableCellAncestor(e2, t2) {
1760
- const n2 = e2.getBlock(t2);
1761
- if ("table_cell" === n2?.type) return t2;
1762
- const s2 = ve(e2.doc, t2);
1763
- if (s2) for (const t3 of s2) {
1764
- const n3 = e2.getBlock(t3);
1765
- if ("table_cell" === n3?.type) return t3;
1882
+ findTableCellAncestor(t2, e2) {
1883
+ const n2 = t2.getBlock(e2);
1884
+ if ("table_cell" === n2?.type) return e2;
1885
+ const s2 = bt(t2.doc, e2);
1886
+ if (s2) for (const e3 of s2) {
1887
+ const n3 = t2.getBlock(e3);
1888
+ if ("table_cell" === n3?.type) return e3;
1766
1889
  }
1767
1890
  }
1768
- handleFilePaste(e2) {
1891
+ handleFilePaste(t2) {
1769
1892
  if (!this.schemaRegistry) return false;
1770
- const t2 = Array.from(e2.files);
1771
- if (0 === t2.length) for (let n2 = 0; n2 < e2.items.length; n2++) {
1772
- const s2 = e2.items[n2];
1893
+ const e2 = Array.from(t2.files);
1894
+ if (0 === e2.length) for (let n2 = 0; n2 < t2.items.length; n2++) {
1895
+ const s2 = t2.items[n2];
1773
1896
  if (s2 && "file" === s2.kind) {
1774
- const e3 = s2.getAsFile();
1775
- e3 && t2.push(e3);
1897
+ const t3 = s2.getAsFile();
1898
+ t3 && e2.push(t3);
1776
1899
  }
1777
1900
  }
1778
- if (0 === t2.length) return false;
1779
- for (const e3 of t2) {
1780
- const n2 = this.schemaRegistry.matchFileHandlers(e3.type);
1781
- for (const e4 of n2) {
1782
- const n3 = e4(t2, null);
1901
+ if (0 === e2.length) return false;
1902
+ for (const t3 of e2) {
1903
+ const n2 = this.schemaRegistry.matchFileHandlers(t3.type);
1904
+ for (const t4 of n2) {
1905
+ const n3 = t4(e2, null);
1783
1906
  if (true === n3) return true;
1784
1907
  if (n3 instanceof Promise) return true;
1785
1908
  }
1786
1909
  }
1787
1910
  return false;
1788
1911
  }
1789
- extractRichData(e2) {
1790
- const t2 = document.createElement("template");
1791
- t2.innerHTML = e2;
1792
- const n2 = t2.content.querySelector("[data-notectl-rich]");
1912
+ extractRichData(t2) {
1913
+ const e2 = document.createElement("template");
1914
+ e2.innerHTML = t2;
1915
+ const n2 = e2.content.querySelector("[data-notectl-rich]");
1793
1916
  if (n2) return n2.getAttribute("data-notectl-rich") ?? void 0;
1794
1917
  }
1795
- extractTextFromHTML(e2) {
1796
- const t2 = document.createElement("template");
1797
- return t2.innerHTML = e2, t2.content.textContent ?? "";
1918
+ extractTextFromHTML(t2) {
1919
+ const e2 = document.createElement("template");
1920
+ return e2.innerHTML = t2, e2.content.textContent ?? "";
1798
1921
  }
1799
1922
  destroy() {
1800
1923
  this.element.removeEventListener("paste", this.handlePaste);
1801
1924
  }
1802
1925
  }
1803
- function yt(e2, t2, n2, s2) {
1804
- const r2 = t2?.doc.children ?? [], o2 = n2.doc.children, i3 = s2?.registry, a4 = s2?.nodeViews;
1805
- !(function(e3) {
1806
- const t3 = Array.from(e3.querySelectorAll(":scope > [data-block-wrapper]"));
1807
- for (const n3 of t3) {
1808
- for (; n3.firstChild; ) e3.insertBefore(n3.firstChild, n3);
1926
+ function Ee(t2, e2, n2, s2) {
1927
+ const o2 = e2?.doc.children ?? [], r2 = n2.doc.children, i3 = s2?.registry, a4 = s2?.nodeViews;
1928
+ !(function(t3) {
1929
+ const e3 = Array.from(t3.querySelectorAll(":scope > [data-block-wrapper]"));
1930
+ for (const n3 of e3) {
1931
+ for (; n3.firstChild; ) t3.insertBefore(n3.firstChild, n3);
1809
1932
  n3.remove();
1810
1933
  }
1811
- })(e2);
1934
+ })(t2);
1812
1935
  const c3 = /* @__PURE__ */ new Map();
1813
- for (const t3 of Array.from(e2.children)) {
1814
- const e3 = t3, n3 = e3.getAttribute("data-block-id");
1815
- n3 && c3.set(pe(n3), e3);
1816
- }
1817
- const l2 = new Set(o2.map((e3) => e3.id));
1818
- for (const [t3, n3] of c3) if (!l2.has(t3)) {
1819
- e2.removeChild(n3), c3.delete(t3);
1820
- const s3 = a4?.get(t3);
1821
- s3 && (s3.destroy?.(), a4?.delete(t3));
1822
- }
1823
- const h3 = /* @__PURE__ */ new Map();
1824
- for (const e3 of r2) h3.set(e3.id, e3);
1825
- let d2 = null;
1936
+ for (const e3 of Array.from(t2.children)) {
1937
+ const t3 = e3, n3 = t3.getAttribute("data-block-id");
1938
+ n3 && c3.set(ht(n3), t3);
1939
+ }
1940
+ const l2 = new Set(r2.map((t3) => t3.id));
1941
+ for (const [e3, n3] of c3) if (!l2.has(e3)) {
1942
+ t2.removeChild(n3), c3.delete(e3);
1943
+ const s3 = a4?.get(e3);
1944
+ s3 && (s3.destroy?.(), a4?.delete(e3));
1945
+ }
1946
+ const d2 = /* @__PURE__ */ new Map();
1947
+ for (const t3 of o2) d2.set(t3.id, t3);
1948
+ let h3 = null;
1826
1949
  const u2 = s2?.selectedNodeId, p2 = s2?.previousSelectedNodeId;
1827
- for (const t3 of o2) {
1828
- const n3 = c3.get(t3.id), r3 = h3.get(t3.id), o3 = s2?.oldDecorations?.find(t3.id), l3 = s2?.decorations?.find(t3.id);
1829
- if (n3 && r3 && !kt(r3, t3, o3, l3)) d2 = n3;
1950
+ for (const e3 of r2) {
1951
+ const n3 = c3.get(e3.id), o3 = d2.get(e3.id), r3 = s2?.oldDecorations?.find(e3.id), l3 = s2?.decorations?.find(e3.id);
1952
+ if (n3 && o3 && !xe(o3, e3, r3, l3)) h3 = n3;
1830
1953
  else if (n3) {
1831
- const r4 = a4?.get(t3.id);
1832
- if (r4) {
1833
- if (r4.update?.(t3)) {
1834
- if (D(t3) && r4.contentDOM) {
1835
- r4.contentDOM.textContent = "";
1836
- const e3 = s2?.decorations?.findInline(t3.id);
1837
- St(r4.contentDOM, t3, i3, e3);
1954
+ const o4 = a4?.get(e3.id);
1955
+ if (o4) {
1956
+ if (o4.update?.(e3)) {
1957
+ if (R(e3) && o4.contentDOM) {
1958
+ o4.contentDOM.textContent = "";
1959
+ const t3 = s2?.decorations?.findInline(e3.id);
1960
+ Me(o4.contentDOM, e3, i3, t3);
1838
1961
  }
1839
- d2 = r4.dom;
1962
+ h3 = o4.dom;
1840
1963
  continue;
1841
1964
  }
1842
- r4.destroy?.(), a4?.delete(t3.id);
1965
+ o4.destroy?.(), a4?.delete(e3.id);
1843
1966
  }
1844
- const o4 = bt(t3, i3, a4, s2);
1845
- e2.replaceChild(o4, n3), d2 = o4;
1967
+ const r4 = Ne(e3, i3, a4, s2);
1968
+ t2.replaceChild(r4, n3), h3 = r4;
1846
1969
  } else {
1847
- const n4 = bt(t3, i3, a4, s2);
1848
- d2?.nextSibling ? e2.insertBefore(n4, d2.nextSibling) : !d2 && e2.firstChild ? e2.insertBefore(n4, e2.firstChild) : e2.appendChild(n4), d2 = n4;
1970
+ const n4 = Ne(e3, i3, a4, s2);
1971
+ h3?.nextSibling ? t2.insertBefore(n4, h3.nextSibling) : !h3 && t2.firstChild ? t2.insertBefore(n4, t2.firstChild) : t2.appendChild(n4), h3 = n4;
1849
1972
  }
1850
- if (u2 === t3.id) {
1851
- const e3 = a4?.get(t3.id);
1852
- if (e3) e3.selectNode?.();
1973
+ if (u2 === e3.id) {
1974
+ const t3 = a4?.get(e3.id);
1975
+ if (t3) t3.selectNode?.();
1853
1976
  else {
1854
- const e4 = c3.get(t3.id) ?? d2;
1855
- e4 instanceof HTMLElement && e4.classList.add("notectl-node-selected");
1977
+ const t4 = c3.get(e3.id) ?? h3;
1978
+ t4 instanceof HTMLElement && t4.classList.add("notectl-node-selected");
1856
1979
  }
1857
- } else if (p2 === t3.id) {
1858
- const e3 = a4?.get(t3.id);
1859
- if (e3) e3.deselectNode?.();
1980
+ } else if (p2 === e3.id) {
1981
+ const t3 = a4?.get(e3.id);
1982
+ if (t3) t3.deselectNode?.();
1860
1983
  else {
1861
- const e4 = c3.get(t3.id) ?? d2;
1862
- e4 instanceof HTMLElement && e4.classList.remove("notectl-node-selected");
1984
+ const t4 = c3.get(e3.id) ?? h3;
1985
+ t4 instanceof HTMLElement && t4.classList.remove("notectl-node-selected");
1863
1986
  }
1864
1987
  }
1865
1988
  }
1866
1989
  if (p2 && p2 !== u2) {
1867
- const e3 = a4?.get(p2);
1868
- e3 && !l2.has(p2) && e3.deselectNode?.();
1990
+ const t3 = a4?.get(p2);
1991
+ t3 && !l2.has(p2) && t3.deselectNode?.();
1869
1992
  }
1870
1993
  if (u2 && !l2.has(u2)) {
1871
- const e3 = a4?.get(u2);
1872
- e3 && e3.selectNode?.();
1873
- }
1874
- Ct(e2, o2, i3);
1875
- }
1876
- function kt(e2, t2, n2, s2) {
1877
- if (e2.type !== t2.type) return true;
1878
- if (e2.children.length !== t2.children.length) return true;
1879
- const r2 = e2.attrs, o2 = t2.attrs;
1880
- if (r2 !== o2) {
1881
- if (!r2 || !o2) return true;
1882
- const e3 = Object.keys(r2), t3 = Object.keys(o2);
1883
- if (e3.length !== t3.length) return true;
1884
- for (const t4 of e3) if (r2[t4] !== o2[t4]) return true;
1885
- }
1886
- for (let n3 = 0; n3 < e2.children.length; n3++) {
1887
- const s3 = e2.children[n3], r3 = t2.children[n3];
1888
- if (!s3 || !r3) return true;
1889
- if (m(s3) && m(r3)) {
1890
- if (s3.text !== r3.text) return true;
1891
- if (!_(s3.marks, r3.marks)) return true;
1892
- } else if (d(s3) && d(r3)) {
1893
- if (s3.inlineType !== r3.inlineType) return true;
1894
- if (!Et(s3.attrs, r3.attrs)) return true;
1994
+ const t3 = a4?.get(u2);
1995
+ t3 && t3.selectNode?.();
1996
+ }
1997
+ _e(t2, r2, i3);
1998
+ }
1999
+ function xe(t2, e2, n2, s2) {
2000
+ if (t2.type !== e2.type) return true;
2001
+ if (t2.children.length !== e2.children.length) return true;
2002
+ const o2 = t2.attrs, r2 = e2.attrs;
2003
+ if (o2 !== r2) {
2004
+ if (!o2 || !r2) return true;
2005
+ const t3 = Object.keys(o2), e3 = Object.keys(r2);
2006
+ if (t3.length !== e3.length) return true;
2007
+ for (const e4 of t3) if (o2[e4] !== r2[e4]) return true;
2008
+ }
2009
+ for (let n3 = 0; n3 < t2.children.length; n3++) {
2010
+ const s3 = t2.children[n3], o3 = e2.children[n3];
2011
+ if (!s3 || !o3) return true;
2012
+ if (m(s3) && m(o3)) {
2013
+ if (s3.text !== o3.text) return true;
2014
+ if (!L(s3.marks, o3.marks)) return true;
2015
+ } else if (d(s3) && d(o3)) {
2016
+ if (s3.inlineType !== o3.inlineType) return true;
2017
+ if (!Ae(s3.attrs, o3.attrs)) return true;
1895
2018
  } else {
1896
- if (m(s3) || m(r3) || d(s3) || d(r3)) return true;
1897
- if (kt(s3, r3)) return true;
2019
+ if (m(s3) || m(o3) || d(s3) || d(o3)) return true;
2020
+ if (xe(s3, o3)) return true;
1898
2021
  }
1899
2022
  }
1900
2023
  const i3 = n2 ?? [], a4 = s2 ?? [];
1901
- return i3 !== a4 && !Te(i3, a4);
1902
- }
1903
- function bt(e2, t2, n2, s2) {
1904
- const r2 = s2?.decorations?.findInline(e2.id);
1905
- if (t2 && n2 && s2?.getState && s2?.dispatch) {
1906
- const o2 = t2.getNodeViewFactory(e2.type);
1907
- if (o2) {
1908
- const i3 = o2(e2, s2.getState, s2.dispatch);
1909
- n2.set(e2.id, i3);
1910
- const a4 = t2.getNodeSpec(e2.type);
1911
- if (a4?.isVoid && i3.dom.setAttribute("data-void", "true"), a4?.selectable && i3.dom.setAttribute("data-selectable", "true"), i3.contentDOM && i3.contentDOM !== i3.dom && i3.contentDOM.setAttribute("data-content-dom", "true"), D(e2) && i3.contentDOM) St(i3.contentDOM, e2, t2, r2);
2024
+ return i3 !== a4 && !Tt(i3, a4);
2025
+ }
2026
+ function Ne(t2, e2, n2, s2) {
2027
+ const o2 = s2?.decorations?.findInline(t2.id);
2028
+ if (e2 && n2 && s2?.getState && s2?.dispatch) {
2029
+ const r2 = e2.getNodeViewFactory(t2.type);
2030
+ if (r2) {
2031
+ const i3 = r2(t2, s2.getState, s2.dispatch);
2032
+ n2.set(t2.id, i3);
2033
+ const a4 = e2.getNodeSpec(t2.type);
2034
+ if (a4?.isVoid && i3.dom.setAttribute("data-void", "true"), a4?.selectable && i3.dom.setAttribute("data-selectable", "true"), i3.contentDOM && i3.contentDOM !== i3.dom && i3.contentDOM.setAttribute("data-content-dom", "true"), R(t2) && i3.contentDOM) Me(i3.contentDOM, t2, e2, o2);
1912
2035
  else {
1913
- const r3 = O(e2), o3 = /* @__PURE__ */ new Map();
1914
- for (const e3 of r3) {
1915
- const r4 = i3.getContentDOM?.(e3.id) ?? i3.contentDOM;
1916
- if (r4) {
1917
- const i4 = bt(e3, t2, n2, s2);
1918
- r4.appendChild(i4);
1919
- let a5 = o3.get(r4);
1920
- a5 || (a5 = [], o3.set(r4, a5)), a5.push(e3);
2036
+ const o3 = D(t2), r3 = /* @__PURE__ */ new Map();
2037
+ for (const t3 of o3) {
2038
+ const o4 = i3.getContentDOM?.(t3.id) ?? i3.contentDOM;
2039
+ if (o4) {
2040
+ const i4 = Ne(t3, e2, n2, s2);
2041
+ o4.appendChild(i4);
2042
+ let a5 = r3.get(o4);
2043
+ a5 || (a5 = [], r3.set(o4, a5)), a5.push(t3);
1921
2044
  }
1922
2045
  }
1923
- for (const [e3, n3] of o3) Ct(e3, n3, t2);
2046
+ for (const [t3, n3] of r3) _e(t3, n3, e2);
1924
2047
  }
1925
- return It(i3.dom, e2.id, s2), i3.dom;
2048
+ return i3.dom.setAttribute("data-block-type", t2.type), De(i3.dom, t2.id, s2), i3.dom;
1926
2049
  }
1927
2050
  }
1928
- if (t2) {
1929
- const o2 = t2.getNodeSpec(e2.type);
1930
- if (o2) {
1931
- const i3 = o2.toDOM(e2);
1932
- if (o2.isVoid && i3.setAttribute("data-void", "true"), o2.selectable && i3.setAttribute("data-selectable", "true"), !o2.isVoid) if (D(e2)) St(i3, e2, t2, r2);
2051
+ if (e2) {
2052
+ const r2 = e2.getNodeSpec(t2.type);
2053
+ if (r2) {
2054
+ const i3 = r2.toDOM(t2);
2055
+ if (r2.isVoid && i3.setAttribute("data-void", "true"), r2.selectable && i3.setAttribute("data-selectable", "true"), !r2.isVoid) if (R(t2)) Me(i3, t2, e2, o2);
1933
2056
  else {
1934
- const r3 = O(e2);
1935
- for (const e3 of r3) {
1936
- const r4 = bt(e3, t2, n2, s2);
1937
- i3.appendChild(r4);
2057
+ const o3 = D(t2);
2058
+ for (const t3 of o3) {
2059
+ const o4 = Ne(t3, e2, n2, s2);
2060
+ i3.appendChild(o4);
1938
2061
  }
1939
- Ct(i3, r3, t2);
2062
+ _e(i3, o3, e2);
1940
2063
  }
1941
- return It(i3, e2.id, s2), i3;
1942
- }
1943
- }
1944
- return (function(e3, t3, n3) {
1945
- const s3 = ye("p", e3.id);
1946
- return St(s3, e3, t3, n3), s3;
1947
- })(e2, t2, r2);
1948
- }
1949
- function St(t2, n2, s2, r2) {
1950
- const o2 = e(n2);
1951
- if (1 === o2.length && m(o2[0]) && "" === o2[0].text) return void t2.appendChild(document.createElement("br"));
1952
- if (r2 && 0 !== r2.length) !(function(e2, t3, n3, s3) {
1953
- let r3 = 0;
1954
- for (const o3 of t3) {
1955
- if (d(o3)) {
1956
- e2.appendChild(Tt(o3, s3)), r3 += 1;
2064
+ return i3.setAttribute("data-block-type", t2.type), De(i3, t2.id, s2), i3;
2065
+ }
2066
+ }
2067
+ return (function(t3, e3, n3) {
2068
+ const s3 = gt("p", t3.id);
2069
+ return s3.setAttribute("data-block-type", t3.type), Me(s3, t3, e3, n3), s3;
2070
+ })(t2, e2, o2);
2071
+ }
2072
+ function Me(t2, n2, s2, o2) {
2073
+ const r2 = e(n2);
2074
+ if (1 === r2.length && m(r2[0]) && "" === r2[0].text) return void t2.appendChild(document.createElement("br"));
2075
+ if (o2 && 0 !== o2.length) !(function(t3, e2, n3, s3) {
2076
+ let o3 = 0;
2077
+ for (const r3 of e2) {
2078
+ if (d(r3)) {
2079
+ t3.appendChild(Be(r3, s3)), o3 += 1;
1957
2080
  continue;
1958
2081
  }
1959
- const t4 = r3, i4 = r3 + o3.text.length;
1960
- if (0 === o3.text.length) {
1961
- r3 = i4;
2082
+ const e3 = o3, i4 = o3 + r3.text.length;
2083
+ if (0 === r3.text.length) {
2084
+ o3 = i4;
1962
2085
  continue;
1963
2086
  }
1964
2087
  const a4 = /* @__PURE__ */ new Set();
1965
- a4.add(t4), a4.add(i4);
1966
- for (const e3 of n3) {
1967
- const n4 = Math.max(t4, e3.from), s4 = Math.min(i4, e3.to);
1968
- n4 > t4 && n4 < i4 && a4.add(n4), s4 > t4 && s4 < i4 && a4.add(s4);
2088
+ a4.add(e3), a4.add(i4);
2089
+ for (const t4 of n3) {
2090
+ const n4 = Math.max(e3, t4.from), s4 = Math.min(i4, t4.to);
2091
+ n4 > e3 && n4 < i4 && a4.add(n4), s4 > e3 && s4 < i4 && a4.add(s4);
1969
2092
  }
1970
- const c3 = [...a4].sort((e3, t5) => e3 - t5);
1971
- for (let r4 = 0; r4 < c3.length - 1; r4++) {
1972
- const i5 = c3[r4], a5 = c3[r4 + 1];
2093
+ const c3 = [...a4].sort((t4, e4) => t4 - e4);
2094
+ for (let o4 = 0; o4 < c3.length - 1; o4++) {
2095
+ const i5 = c3[o4], a5 = c3[o4 + 1];
1973
2096
  if (void 0 === i5 || void 0 === a5 || i5 >= a5) continue;
1974
- const l2 = i5 - t4, h3 = a5 - t4, d2 = o3.text.slice(l2, h3), u2 = [];
1975
- for (const e3 of n3) e3.from <= i5 && e3.to >= a5 && u2.push(e3);
1976
- let p2 = document.createTextNode(vt(d2));
1977
- if (o3.marks.length > 0) {
1978
- const e3 = [...o3.marks].sort((e4, t5) => xt(e4, s3) - xt(t5, s3));
1979
- for (let t5 = e3.length - 1; t5 >= 0; t5--) {
1980
- const n4 = e3[t5];
2097
+ const l2 = i5 - e3, d2 = a5 - e3, h3 = r3.text.slice(l2, d2), u2 = [];
2098
+ for (const t4 of n3) t4.from <= i5 && t4.to >= a5 && u2.push(t4);
2099
+ let p2 = document.createTextNode(Ce(h3));
2100
+ if (r3.marks.length > 0) {
2101
+ const t4 = [...r3.marks].sort((t5, e4) => Re(t5, s3) - Re(e4, s3));
2102
+ for (let e4 = t4.length - 1; e4 >= 0; e4--) {
2103
+ const n4 = t4[e4];
1981
2104
  if (!n4) continue;
1982
- const r5 = Nt(n4, s3);
1983
- r5.appendChild(p2), p2 = r5;
2105
+ const o5 = Pe(n4, s3);
2106
+ o5.appendChild(p2), p2 = o5;
1984
2107
  }
1985
2108
  }
1986
- for (const e3 of u2) {
1987
- const t5 = Mt(e3.attrs);
1988
- t5.appendChild(p2), p2 = t5;
2109
+ for (const t4 of u2) {
2110
+ const e4 = Le(t4.attrs);
2111
+ e4.appendChild(p2), p2 = e4;
1989
2112
  }
1990
- e2.appendChild(p2);
2113
+ t3.appendChild(p2);
1991
2114
  }
1992
- r3 = i4;
2115
+ o3 = i4;
1993
2116
  }
1994
- })(t2, o2, r2, s2);
1995
- else for (const e2 of o2) m(e2) ? t2.appendChild(wt(e2, s2)) : t2.appendChild(Tt(e2, s2));
1996
- const i3 = o2[o2.length - 1];
2117
+ })(t2, r2, o2, s2);
2118
+ else for (const e2 of r2) m(e2) ? t2.appendChild(Ie(e2, s2)) : t2.appendChild(Be(e2, s2));
2119
+ const i3 = r2[r2.length - 1];
1997
2120
  i3 && d(i3) && "hard_break" === i3.inlineType && t2.appendChild(document.createElement("br"));
1998
2121
  }
1999
- function vt(e2) {
2000
- let t2 = e2.replace(/ {2}/g, "  ");
2001
- return t2.endsWith(" ") && (t2 = `${t2.slice(0, -1)} `), t2.startsWith(" ") && (t2 = ` ${t2.slice(1)}`), t2;
2002
- }
2003
- function wt(e2, t2) {
2004
- if ("" === e2.text) return document.createTextNode("");
2005
- const n2 = document.createTextNode(vt(e2.text));
2006
- if (0 === e2.marks.length) return n2;
2007
- const s2 = [...e2.marks].sort((e3, n3) => xt(e3, t2) - xt(n3, t2));
2008
- let r2 = n2;
2009
- for (let e3 = s2.length - 1; e3 >= 0; e3--) {
2010
- const n3 = s2[e3];
2122
+ function Ce(t2) {
2123
+ let e2 = t2.replace(/ {2}/g, "  ");
2124
+ return e2.endsWith(" ") && (e2 = `${e2.slice(0, -1)} `), e2.startsWith(" ") && (e2 = ` ${e2.slice(1)}`), e2;
2125
+ }
2126
+ function Ie(t2, e2) {
2127
+ if ("" === t2.text) return document.createTextNode("");
2128
+ const n2 = document.createTextNode(Ce(t2.text));
2129
+ if (0 === t2.marks.length) return n2;
2130
+ const s2 = [...t2.marks].sort((t3, n3) => Re(t3, e2) - Re(n3, e2));
2131
+ let o2 = n2;
2132
+ for (let t3 = s2.length - 1; t3 >= 0; t3--) {
2133
+ const n3 = s2[t3];
2011
2134
  if (!n3) continue;
2012
- const o2 = Nt(n3, t2);
2013
- o2.appendChild(r2), r2 = o2;
2135
+ const r2 = Pe(n3, e2);
2136
+ r2.appendChild(o2), o2 = r2;
2014
2137
  }
2015
- return r2;
2138
+ return o2;
2016
2139
  }
2017
- function Tt(e2, t2) {
2018
- if (t2) {
2019
- const n3 = t2.getInlineNodeSpec(e2.inlineType);
2140
+ function Be(t2, e2) {
2141
+ if (e2) {
2142
+ const n3 = e2.getInlineNodeSpec(t2.inlineType);
2020
2143
  if (n3) {
2021
- const t3 = n3.toDOM(e2);
2022
- return t3.setAttribute("contenteditable", "false"), t3;
2144
+ const e3 = n3.toDOM(t2);
2145
+ return e3.setAttribute("contenteditable", "false"), e3;
2023
2146
  }
2024
2147
  }
2025
2148
  const n2 = document.createElement("span");
2026
- return n2.setAttribute("data-inline-type", e2.inlineType), n2.setAttribute("contenteditable", "false"), n2;
2149
+ return n2.setAttribute("data-inline-type", t2.inlineType), n2.setAttribute("contenteditable", "false"), n2;
2027
2150
  }
2028
- function Et(e2, t2) {
2029
- const n2 = Object.keys(e2), s2 = Object.keys(t2);
2151
+ function Ae(t2, e2) {
2152
+ const n2 = Object.keys(t2), s2 = Object.keys(e2);
2030
2153
  if (n2.length !== s2.length) return false;
2031
- for (const s3 of n2) if (e2[s3] !== t2[s3]) return false;
2154
+ for (const s3 of n2) if (t2[s3] !== e2[s3]) return false;
2032
2155
  return true;
2033
2156
  }
2034
- function xt(e2, t2) {
2035
- if (t2) {
2036
- const n2 = t2.getMarkSpec(e2.type);
2157
+ function Re(t2, e2) {
2158
+ if (e2) {
2159
+ const n2 = e2.getMarkSpec(t2.type);
2037
2160
  if (n2) return n2.rank ?? 100;
2038
2161
  }
2039
- switch (e2.type) {
2162
+ switch (t2.type) {
2040
2163
  case "bold":
2041
2164
  return 0;
2042
2165
  case "italic":
@@ -2047,12 +2170,12 @@ function xt(e2, t2) {
2047
2170
  return 100;
2048
2171
  }
2049
2172
  }
2050
- function Nt(e2, t2) {
2051
- if (t2) {
2052
- const n2 = t2.getMarkSpec(e2.type);
2053
- if (n2) return n2.toDOM(e2);
2173
+ function Pe(t2, e2) {
2174
+ if (e2) {
2175
+ const n2 = e2.getMarkSpec(t2.type);
2176
+ if (n2) return n2.toDOM(t2);
2054
2177
  }
2055
- switch (e2.type) {
2178
+ switch (t2.type) {
2056
2179
  case "bold":
2057
2180
  return document.createElement("strong");
2058
2181
  case "italic":
@@ -2063,177 +2186,177 @@ function Nt(e2, t2) {
2063
2186
  return document.createElement("span");
2064
2187
  }
2065
2188
  }
2066
- function Mt(e2) {
2067
- const t2 = e2.nodeName ?? "span", n2 = document.createElement(t2);
2068
- if (n2.setAttribute("data-decoration", "true"), e2.class) for (const t3 of e2.class.split(" ")) t3 && n2.classList.add(t3);
2069
- e2.style && (n2.style.cssText = e2.style);
2070
- for (const [t3, s2] of Object.entries(e2)) "class" !== t3 && "style" !== t3 && "nodeName" !== t3 && void 0 !== s2 && n2.setAttribute(t3, s2);
2189
+ function Le(t2) {
2190
+ const e2 = t2.nodeName ?? "span", n2 = document.createElement(e2);
2191
+ if (n2.setAttribute("data-decoration", "true"), t2.class) for (const e3 of t2.class.split(" ")) e3 && n2.classList.add(e3);
2192
+ t2.style && (n2.style.cssText = t2.style);
2193
+ for (const [e3, s2] of Object.entries(t2)) "class" !== e3 && "style" !== e3 && "nodeName" !== e3 && void 0 !== s2 && n2.setAttribute(e3, s2);
2071
2194
  return n2;
2072
2195
  }
2073
- function It(e2, t2, n2) {
2074
- const s2 = n2?.decorations?.findNode(t2);
2075
- if (s2 && 0 !== s2.length) for (const t3 of s2) {
2076
- if (t3.attrs.class) for (const n3 of t3.attrs.class.split(" ")) n3 && e2.classList.add(n3);
2077
- if (t3.attrs.style) {
2078
- const n3 = e2.style.cssText;
2079
- e2.style.cssText = n3 ? `${n3}; ${t3.attrs.style}` : t3.attrs.style;
2196
+ function De(t2, e2, n2) {
2197
+ const s2 = n2?.decorations?.findNode(e2);
2198
+ if (s2 && 0 !== s2.length) for (const e3 of s2) {
2199
+ if (e3.attrs.class) for (const n3 of e3.attrs.class.split(" ")) n3 && t2.classList.add(n3);
2200
+ if (e3.attrs.style) {
2201
+ const n3 = t2.style.cssText;
2202
+ t2.style.cssText = n3 ? `${n3}; ${e3.attrs.style}` : e3.attrs.style;
2080
2203
  }
2081
2204
  }
2082
2205
  }
2083
- function Ct(e2, t2, n2) {
2206
+ function _e(t2, e2, n2) {
2084
2207
  if (!n2) return;
2085
2208
  const s2 = [];
2086
- let r2 = null, o2 = [];
2087
- for (const e3 of t2) {
2088
- const t3 = n2.getNodeSpec(e3.type), i3 = t3?.wrapper?.(e3);
2089
- i3 && r2 && i3.key === r2.key ? o2.push(e3.id) : i3 ? (r2 && o2.length > 0 && s2.push({ spec: r2, blockIds: o2 }), r2 = i3, o2 = [e3.id]) : (r2 && o2.length > 0 && s2.push({ spec: r2, blockIds: o2 }), r2 = null, o2 = []);
2090
- }
2091
- r2 && o2.length > 0 && s2.push({ spec: r2, blockIds: o2 });
2092
- for (const t3 of s2) {
2093
- const n3 = e2.querySelector(`[data-block-id="${t3.blockIds[0]}"]`);
2209
+ let o2 = null, r2 = [];
2210
+ for (const t3 of e2) {
2211
+ const e3 = n2.getNodeSpec(t3.type), i3 = e3?.wrapper?.(t3);
2212
+ i3 && o2 && i3.key === o2.key ? r2.push(t3.id) : i3 ? (o2 && r2.length > 0 && s2.push({ spec: o2, blockIds: r2 }), o2 = i3, r2 = [t3.id]) : (o2 && r2.length > 0 && s2.push({ spec: o2, blockIds: r2 }), o2 = null, r2 = []);
2213
+ }
2214
+ o2 && r2.length > 0 && s2.push({ spec: o2, blockIds: r2 });
2215
+ for (const e3 of s2) {
2216
+ const n3 = t2.querySelector(`[data-block-id="${e3.blockIds[0]}"]`);
2094
2217
  if (!n3) continue;
2095
- const s3 = document.createElement(t3.spec.tag);
2096
- if (s3.setAttribute("data-block-wrapper", t3.spec.key), t3.spec.className && (s3.className = t3.spec.className), t3.spec.attrs) for (const [e3, n4] of Object.entries(t3.spec.attrs)) s3.setAttribute(e3, n4);
2218
+ const s3 = document.createElement(e3.spec.tag);
2219
+ if (s3.setAttribute("data-block-wrapper", e3.spec.key), e3.spec.className && (s3.className = e3.spec.className), e3.spec.attrs) for (const [t3, n4] of Object.entries(e3.spec.attrs)) s3.setAttribute(t3, n4);
2097
2220
  n3.before(s3);
2098
- for (const n4 of t3.blockIds) {
2099
- const t4 = e2.querySelector(`[data-block-id="${n4}"]`);
2100
- t4 && s3.appendChild(t4);
2221
+ for (const n4 of e3.blockIds) {
2222
+ const e4 = t2.querySelector(`[data-block-id="${n4}"]`);
2223
+ e4 && s3.appendChild(e4);
2101
2224
  }
2102
2225
  }
2103
2226
  }
2104
- function Bt(e2) {
2105
- const t2 = e2.getRootNode();
2106
- return t2 instanceof ShadowRoot && "getSelection" in t2 ? t2.getSelection() : window.getSelection();
2227
+ function Oe(t2) {
2228
+ const e2 = t2.getRootNode();
2229
+ return e2 instanceof ShadowRoot && "getSelection" in e2 ? e2.getSelection() : window.getSelection();
2107
2230
  }
2108
- function Rt(e2, t2) {
2109
- const n2 = Bt(e2);
2231
+ function He(t2, e2) {
2232
+ const n2 = Oe(t2);
2110
2233
  if (!n2) return;
2111
- if ($(t2)) {
2112
- const s3 = e2.querySelector(`[data-block-id="${t2.nodeId}"]`);
2234
+ if (H(e2)) {
2235
+ const s3 = t2.querySelector(`[data-block-id="${e2.nodeId}"]`);
2113
2236
  if (!s3) return;
2114
- const r3 = s3.parentNode;
2115
- if (!r3) return;
2116
- const o2 = Lt(r3, s3);
2237
+ const o3 = s3.parentNode;
2238
+ if (!o3) return;
2239
+ const r2 = Fe(o3, s3);
2117
2240
  try {
2118
- n2.setBaseAndExtent(r3, o2, r3, o2 + 1);
2241
+ n2.setBaseAndExtent(o3, r2, o3, r2 + 1);
2119
2242
  } catch {
2120
2243
  }
2121
2244
  return;
2122
2245
  }
2123
- const s2 = At(e2, t2.anchor), r2 = At(e2, t2.head);
2124
- if (s2 && r2) try {
2125
- n2.setBaseAndExtent(s2.node, s2.offset, r2.node, r2.offset);
2246
+ const s2 = $e(t2, e2.anchor), o2 = $e(t2, e2.head);
2247
+ if (s2 && o2) try {
2248
+ n2.setBaseAndExtent(s2.node, s2.offset, o2.node, o2.offset);
2126
2249
  } catch {
2127
2250
  }
2128
2251
  }
2129
- function At(e2, t2) {
2252
+ function $e(t2, e2) {
2130
2253
  let n2 = null;
2131
- if (t2.path && t2.path.length > 0) {
2132
- let s3 = e2;
2133
- for (const e3 of t2.path) {
2134
- const t3 = s3.querySelector(`:scope [data-block-id="${e3}"]`);
2135
- if (!t3) break;
2136
- s3 = t3;
2254
+ if (e2.path && e2.path.length > 0) {
2255
+ let s3 = t2;
2256
+ for (const t3 of e2.path) {
2257
+ const e3 = s3.querySelector(`:scope [data-block-id="${t3}"]`);
2258
+ if (!e3) break;
2259
+ s3 = e3;
2137
2260
  }
2138
- s3 !== e2 && s3.getAttribute("data-block-id") === t2.blockId && (n2 = s3);
2261
+ s3 !== t2 && s3.getAttribute("data-block-id") === e2.blockId && (n2 = s3);
2139
2262
  }
2140
- if (n2 ??= e2.querySelector(`[data-block-id="${t2.blockId}"]`), !n2) return null;
2141
- const s2 = _t(n2);
2263
+ if (n2 ??= t2.querySelector(`[data-block-id="${e2.blockId}"]`), !n2) return null;
2264
+ const s2 = Ue(n2);
2142
2265
  if (1 === s2.childNodes.length && "BR" === s2.firstChild?.nodeName) return { node: s2, offset: 0 };
2143
- let r2 = t2.offset;
2144
- const o2 = Dt(s2);
2145
- let i3 = o2.nextNode();
2266
+ let o2 = e2.offset;
2267
+ const r2 = je(s2);
2268
+ let i3 = r2.nextNode();
2146
2269
  for (; i3; ) {
2147
2270
  if (i3.nodeType === Node.TEXT_NODE) {
2148
- const e3 = i3.textContent?.length ?? 0;
2149
- if (r2 <= e3) return { node: i3, offset: r2 };
2150
- r2 -= e3;
2271
+ const t3 = i3.textContent?.length ?? 0;
2272
+ if (o2 <= t3) return { node: i3, offset: o2 };
2273
+ o2 -= t3;
2151
2274
  } else if (i3 instanceof HTMLElement && "false" === i3.getAttribute("contenteditable")) {
2152
- if (0 === r2) {
2153
- const e3 = i3.parentNode;
2154
- if (e3) return { node: e3, offset: Lt(e3, i3) };
2275
+ if (0 === o2) {
2276
+ const t3 = i3.parentNode;
2277
+ if (t3) return { node: t3, offset: Fe(t3, i3) };
2155
2278
  }
2156
- r2 -= 1;
2279
+ o2 -= 1;
2157
2280
  }
2158
- i3 = o2.nextNode();
2281
+ i3 = r2.nextNode();
2159
2282
  }
2160
2283
  const a4 = s2.lastChild;
2161
2284
  return a4 ? a4.nodeType === Node.TEXT_NODE ? { node: a4, offset: a4.textContent?.length ?? 0 } : { node: s2, offset: s2.childNodes.length } : { node: s2, offset: 0 };
2162
2285
  }
2163
- function Pt(e2, t2, n2) {
2164
- const s2 = (function(e3, t3) {
2165
- let n3 = t3;
2166
- for (; n3 && n3 !== e3; ) {
2286
+ function ze(t2, e2, n2) {
2287
+ const s2 = (function(t3, e3) {
2288
+ let n3 = e3;
2289
+ for (; n3 && n3 !== t3; ) {
2167
2290
  if (n3 instanceof HTMLElement && n3.hasAttribute("data-block-id")) return n3;
2168
2291
  n3 = n3.parentNode;
2169
2292
  }
2170
2293
  return null;
2171
- })(e2, t2);
2294
+ })(t2, e2);
2172
2295
  if (!s2) return null;
2173
- const r2 = s2.getAttribute("data-block-id");
2174
- if (!r2) return null;
2175
- const o2 = pe(r2), i3 = (function(e3, t3) {
2296
+ const o2 = s2.getAttribute("data-block-id");
2297
+ if (!o2) return null;
2298
+ const r2 = ht(o2), i3 = (function(t3, e3) {
2176
2299
  const n3 = [];
2177
- let s3 = t3;
2178
- for (; s3 && s3 !== e3; ) s3.hasAttribute("data-block-id") && n3.unshift(pe(s3.getAttribute("data-block-id") ?? "")), s3 = s3.parentElement;
2300
+ let s3 = e3;
2301
+ for (; s3 && s3 !== t3; ) s3.hasAttribute("data-block-id") && n3.unshift(ht(s3.getAttribute("data-block-id") ?? "")), s3 = s3.parentElement;
2179
2302
  return n3;
2180
- })(e2, s2), a4 = _t(s2);
2181
- if (t2 === s2 || t2 === a4) {
2182
- const e3 = t2 === a4 ? a4 : s2;
2183
- let r3 = 0, c4 = 0;
2184
- for (const t3 of Array.from(e3.childNodes)) {
2303
+ })(t2, s2), a4 = Ue(s2);
2304
+ if (e2 === s2 || e2 === a4) {
2305
+ const t3 = e2 === a4 ? a4 : s2;
2306
+ let o3 = 0, c4 = 0;
2307
+ for (const e3 of Array.from(t3.childNodes)) {
2185
2308
  if (c4 >= n2) break;
2186
- r3 += Ot(t3), c4++;
2309
+ o3 += Ke(e3), c4++;
2187
2310
  }
2188
- return U(o2, r3, i3.length > 1 ? i3 : void 0);
2311
+ return j(r2, o3, i3.length > 1 ? i3 : void 0);
2189
2312
  }
2190
- if (a4 !== s2 && !a4.contains(t2)) return U(o2, 0, i3.length > 1 ? i3 : void 0);
2313
+ if (a4 !== s2 && !a4.contains(e2)) return j(r2, 0, i3.length > 1 ? i3 : void 0);
2191
2314
  let c3 = 0;
2192
- const l2 = Dt(a4);
2193
- let h3 = l2.nextNode();
2194
- for (; h3; ) {
2195
- if (h3 === t2) return h3.nodeType === Node.TEXT_NODE ? U(o2, c3 + n2, i3.length > 1 ? i3 : void 0) : U(o2, c3, i3.length > 1 ? i3 : void 0);
2196
- h3.nodeType === Node.TEXT_NODE ? c3 += h3.textContent?.length ?? 0 : h3 instanceof HTMLElement && "false" === h3.getAttribute("contenteditable") && (c3 += 1), h3 = l2.nextNode();
2197
- }
2198
- if (t2.nodeType === Node.ELEMENT_NODE) {
2199
- let e3 = 0, s3 = 0;
2200
- for (const r3 of Array.from(t2.childNodes)) {
2315
+ const l2 = je(a4);
2316
+ let d2 = l2.nextNode();
2317
+ for (; d2; ) {
2318
+ if (d2 === e2) return d2.nodeType === Node.TEXT_NODE ? j(r2, c3 + n2, i3.length > 1 ? i3 : void 0) : j(r2, c3, i3.length > 1 ? i3 : void 0);
2319
+ d2.nodeType === Node.TEXT_NODE ? c3 += d2.textContent?.length ?? 0 : d2 instanceof HTMLElement && "false" === d2.getAttribute("contenteditable") && (c3 += 1), d2 = l2.nextNode();
2320
+ }
2321
+ if (e2.nodeType === Node.ELEMENT_NODE) {
2322
+ let t3 = 0, s3 = 0;
2323
+ for (const o3 of Array.from(e2.childNodes)) {
2201
2324
  if (s3 >= n2) break;
2202
- e3 += Ot(r3), s3++;
2325
+ t3 += Ke(o3), s3++;
2203
2326
  }
2204
- return U(o2, e3, i3.length > 1 ? i3 : void 0);
2327
+ return j(r2, t3, i3.length > 1 ? i3 : void 0);
2205
2328
  }
2206
- return U(o2, 0, i3.length > 1 ? i3 : void 0);
2329
+ return j(r2, 0, i3.length > 1 ? i3 : void 0);
2207
2330
  }
2208
- function Dt(e2) {
2209
- return document.createTreeWalker(e2, NodeFilter.SHOW_ALL, { acceptNode: (t2) => (function(e3, t3) {
2210
- let n2 = e3.parentNode;
2211
- for (; n2 && n2 !== t3; ) {
2331
+ function je(t2) {
2332
+ return document.createTreeWalker(t2, NodeFilter.SHOW_ALL, { acceptNode: (e2) => (function(t3, e3) {
2333
+ let n2 = t3.parentNode;
2334
+ for (; n2 && n2 !== e3; ) {
2212
2335
  if (n2 instanceof HTMLElement && "false" === n2.getAttribute("contenteditable")) return true;
2213
2336
  n2 = n2.parentNode;
2214
2337
  }
2215
2338
  return false;
2216
- })(t2, e2) || t2 instanceof HTMLElement && t2.hasAttribute("data-block-id") && t2 !== e2 ? NodeFilter.FILTER_REJECT : t2.nodeType === Node.TEXT_NODE || t2 instanceof HTMLElement && "false" === t2.getAttribute("contenteditable") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP });
2339
+ })(e2, t2) || e2 instanceof HTMLElement && e2.hasAttribute("data-block-id") && e2 !== t2 ? NodeFilter.FILTER_REJECT : e2.nodeType === Node.TEXT_NODE || e2 instanceof HTMLElement && "false" === e2.getAttribute("contenteditable") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP });
2217
2340
  }
2218
- function Lt(e2, t2) {
2341
+ function Fe(t2, e2) {
2219
2342
  let n2 = 0;
2220
- for (const s2 of Array.from(e2.childNodes)) {
2221
- if (s2 === t2) return n2;
2343
+ for (const s2 of Array.from(t2.childNodes)) {
2344
+ if (s2 === e2) return n2;
2222
2345
  n2++;
2223
2346
  }
2224
2347
  return n2;
2225
2348
  }
2226
- function _t(e2) {
2227
- return e2.querySelector("[data-content-dom]") ?? e2;
2349
+ function Ue(t2) {
2350
+ return t2.querySelector("[data-content-dom]") ?? t2;
2228
2351
  }
2229
- function Ot(e2) {
2230
- if (e2.nodeType === Node.TEXT_NODE) return e2.textContent?.length ?? 0;
2231
- if (e2 instanceof HTMLElement && "false" === e2.getAttribute("contenteditable")) return 1;
2232
- let t2 = 0;
2233
- for (const n2 of Array.from(e2.childNodes)) t2 += Ot(n2);
2234
- return t2;
2352
+ function Ke(t2) {
2353
+ if (t2.nodeType === Node.TEXT_NODE) return t2.textContent?.length ?? 0;
2354
+ if (t2 instanceof HTMLElement && "false" === t2.getAttribute("contenteditable")) return 1;
2355
+ let e2 = 0;
2356
+ for (const n2 of Array.from(t2.childNodes)) e2 += Ke(n2);
2357
+ return e2;
2235
2358
  }
2236
- class Ht {
2359
+ class Ve {
2237
2360
  state;
2238
2361
  contentElement;
2239
2362
  inputHandler;
@@ -2250,269 +2373,269 @@ class Ht {
2250
2373
  pendingNodeSelectionClear = false;
2251
2374
  schemaRegistry;
2252
2375
  nodeViews = /* @__PURE__ */ new Map();
2253
- decorations = we.empty;
2376
+ decorations = wt.empty;
2254
2377
  getDecorations;
2255
- constructor(e2, t2) {
2256
- this.state = t2.state, this.contentElement = e2, this.schemaRegistry = t2.schemaRegistry, this.getDecorations = t2.getDecorations, this.history = new We({ maxDepth: t2.maxHistoryDepth ?? 100 }), t2.onStateChange && this.stateChangeCallbacks.push(t2.onStateChange), this.inputHandler = new ht(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), syncSelection: () => this.syncSelectionFromDOM(), schemaRegistry: this.schemaRegistry }), this.keyboardHandler = new Xe(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), undo: () => this.undo(), redo: () => this.redo(), schemaRegistry: this.schemaRegistry }), this.pasteHandler = new mt(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), schemaRegistry: this.schemaRegistry }), this.clipboardHandler = new Ge(e2, { getState: () => this.state, dispatch: (e3) => this.dispatch(e3), schemaRegistry: this.schemaRegistry, syncSelection: () => this.syncSelectionFromDOM() }), this.handleSelectionChange = this.onSelectionChange.bind(this), document.addEventListener("selectionchange", this.handleSelectionChange), this.handleMousedown = this.onMousedown.bind(this), e2.addEventListener("mousedown", this.handleMousedown), this.handleDragover = this.onDragover.bind(this), e2.addEventListener("dragover", this.handleDragover), this.handleDrop = this.onDrop.bind(this), e2.addEventListener("drop", this.handleDrop), this.decorations = this.getDecorations?.(this.state) ?? we.empty, yt(e2, null, this.state, { ...this.reconcileOptions(), decorations: this.decorations }), Rt(e2, this.state.selection);
2378
+ constructor(t2, e2) {
2379
+ this.state = e2.state, this.contentElement = t2, this.schemaRegistry = e2.schemaRegistry, this.getDecorations = e2.getDecorations, this.history = new Xt({ maxDepth: e2.maxHistoryDepth ?? 100 }), e2.onStateChange && this.stateChangeCallbacks.push(e2.onStateChange), this.inputHandler = new ye(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), syncSelection: () => this.syncSelectionFromDOM(), schemaRegistry: this.schemaRegistry }), this.keyboardHandler = new Jt(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), undo: () => this.undo(), redo: () => this.redo(), schemaRegistry: this.schemaRegistry }), this.pasteHandler = new Te(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), schemaRegistry: this.schemaRegistry }), this.clipboardHandler = new Yt(t2, { getState: () => this.state, dispatch: (t3) => this.dispatch(t3), schemaRegistry: this.schemaRegistry, syncSelection: () => this.syncSelectionFromDOM() }), this.handleSelectionChange = this.onSelectionChange.bind(this), document.addEventListener("selectionchange", this.handleSelectionChange), this.handleMousedown = this.onMousedown.bind(this), t2.addEventListener("mousedown", this.handleMousedown), this.handleDragover = this.onDragover.bind(this), t2.addEventListener("dragover", this.handleDragover), this.handleDrop = this.onDrop.bind(this), t2.addEventListener("drop", this.handleDrop), this.decorations = this.getDecorations?.(this.state) ?? wt.empty, Ee(t2, null, this.state, { ...this.reconcileOptions(), decorations: this.decorations }), He(t2, this.state.selection);
2257
2380
  }
2258
2381
  getState() {
2259
2382
  return this.state;
2260
2383
  }
2261
- applyUpdate(e2, t2, n2) {
2384
+ applyUpdate(t2, e2, n2) {
2262
2385
  if (!this.isUpdating) {
2263
2386
  this.isUpdating = true;
2264
2387
  try {
2265
2388
  const s2 = this.state;
2266
- this.state = e2, n2?.pushHistory && "history" !== t2.metadata.origin && this.history.push(t2);
2267
- const r2 = this.decorations, o2 = this.getDecorations?.(e2, t2) ?? we.empty;
2268
- this.decorations = o2, yt(this.contentElement, s2, e2, { ...this.reconcileOptions(s2.selection), decorations: o2, oldDecorations: r2 }), Rt(this.contentElement, e2.selection);
2269
- for (const n3 of this.stateChangeCallbacks) n3(s2, e2, t2);
2389
+ this.state = t2, n2?.pushHistory && "history" !== e2.metadata.origin && this.history.push(e2);
2390
+ const o2 = this.decorations, r2 = this.getDecorations?.(t2, e2) ?? wt.empty;
2391
+ this.decorations = r2, Ee(this.contentElement, s2, t2, { ...this.reconcileOptions(s2.selection), decorations: r2, oldDecorations: o2 }), He(this.contentElement, t2.selection);
2392
+ for (const n3 of this.stateChangeCallbacks) n3(s2, t2, e2);
2270
2393
  } finally {
2271
2394
  this.isUpdating = false;
2272
2395
  }
2273
2396
  }
2274
2397
  }
2275
- dispatch(e2) {
2276
- const t2 = this.state.apply(e2);
2277
- this.applyUpdate(t2, e2, { pushHistory: true });
2398
+ dispatch(t2) {
2399
+ const e2 = this.state.apply(t2);
2400
+ this.applyUpdate(e2, t2, { pushHistory: true });
2278
2401
  }
2279
2402
  undo() {
2280
2403
  if (this.isUpdating) return;
2281
- const e2 = this.history.undo(this.state);
2282
- e2 && this.applyUpdate(e2.state, e2.transaction);
2404
+ const t2 = this.history.undo(this.state);
2405
+ t2 && this.applyUpdate(t2.state, t2.transaction);
2283
2406
  }
2284
2407
  redo() {
2285
2408
  if (this.isUpdating) return;
2286
- const e2 = this.history.redo(this.state);
2287
- e2 && this.applyUpdate(e2.state, e2.transaction);
2409
+ const t2 = this.history.redo(this.state);
2410
+ t2 && this.applyUpdate(t2.state, t2.transaction);
2288
2411
  }
2289
- onStateChange(e2) {
2290
- return this.stateChangeCallbacks.push(e2), () => {
2291
- const t2 = this.stateChangeCallbacks.indexOf(e2);
2292
- -1 !== t2 && this.stateChangeCallbacks.splice(t2, 1);
2412
+ onStateChange(t2) {
2413
+ return this.stateChangeCallbacks.push(t2), () => {
2414
+ const e2 = this.stateChangeCallbacks.indexOf(t2);
2415
+ -1 !== e2 && this.stateChangeCallbacks.splice(e2, 1);
2293
2416
  };
2294
2417
  }
2295
- replaceState(e2) {
2418
+ replaceState(t2) {
2296
2419
  if (!this.isUpdating) {
2297
2420
  this.isUpdating = true;
2298
2421
  try {
2299
- const t2 = this.state;
2300
- this.state = e2, this.history.clear();
2301
- const n2 = this.decorations, s2 = this.getDecorations?.(e2) ?? we.empty;
2302
- this.decorations = s2, yt(this.contentElement, t2, e2, { ...this.reconcileOptions(t2.selection), decorations: s2, oldDecorations: n2 }), Rt(this.contentElement, e2.selection);
2422
+ const e2 = this.state;
2423
+ this.state = t2, this.history.clear();
2424
+ const n2 = this.decorations, s2 = this.getDecorations?.(t2) ?? wt.empty;
2425
+ this.decorations = s2, Ee(this.contentElement, e2, t2, { ...this.reconcileOptions(e2.selection), decorations: s2, oldDecorations: n2 }), He(this.contentElement, t2.selection);
2303
2426
  } finally {
2304
2427
  this.isUpdating = false;
2305
2428
  }
2306
2429
  }
2307
2430
  }
2308
2431
  syncSelectionFromDOM() {
2309
- if ($(this.state.selection) && !this.pendingNodeSelectionClear) return;
2432
+ if (H(this.state.selection) && !this.pendingNodeSelectionClear) return;
2310
2433
  this.pendingNodeSelectionClear = false;
2311
- const e2 = (function(e3) {
2312
- const t3 = Bt(e3);
2313
- if (!t3 || 0 === t3.rangeCount) return null;
2314
- const n3 = t3.anchorNode, s2 = t3.focusNode;
2434
+ const t2 = (function(t3) {
2435
+ const e3 = Oe(t3);
2436
+ if (!e3 || 0 === e3.rangeCount) return null;
2437
+ const n3 = e3.anchorNode, s2 = e3.focusNode;
2315
2438
  if (!n3 || !s2) return null;
2316
- if (!e3.contains(n3) || !e3.contains(s2)) return null;
2317
- const r2 = Pt(e3, n3, t3.anchorOffset), o2 = Pt(e3, s2, t3.focusOffset);
2318
- return r2 && o2 ? j(r2, o2) : null;
2439
+ if (!t3.contains(n3) || !t3.contains(s2)) return null;
2440
+ const o2 = ze(t3, n3, e3.anchorOffset), r2 = ze(t3, s2, e3.focusOffset);
2441
+ return o2 && r2 ? $(o2, r2) : null;
2319
2442
  })(this.contentElement);
2320
- if (!e2) return;
2321
- if (W(e2, this.state.selection)) return;
2322
- const t2 = this.state.transaction("input").setSelection(e2).setStoredMarks(null, this.state.storedMarks).build(), n2 = this.state.apply(t2);
2323
- this.applyUpdate(n2, t2);
2443
+ if (!t2) return;
2444
+ if (V(t2, this.state.selection)) return;
2445
+ const e2 = this.state.transaction("input").setSelection(t2).setStoredMarks(null, this.state.storedMarks).build(), n2 = this.state.apply(e2);
2446
+ this.applyUpdate(n2, e2);
2324
2447
  }
2325
- onMousedown(e2) {
2448
+ onMousedown(t2) {
2326
2449
  if (this.isUpdating) return;
2327
- const t2 = e2.target;
2328
- if (!(t2 instanceof HTMLElement)) return;
2329
- const n2 = t2.closest("[data-block-id]");
2330
- if (!(n2 instanceof HTMLElement && this.contentElement.contains(n2))) return void ((this.contentElement.contains(t2) || t2 === this.contentElement) && this.handleClickBelowContent(e2));
2331
- if (!n2.hasAttribute("data-void") && !n2.hasAttribute("data-selectable")) return void ($(this.state.selection) && (this.pendingNodeSelectionClear = true));
2450
+ const e2 = t2.target;
2451
+ if (!(e2 instanceof HTMLElement)) return;
2452
+ const n2 = e2.closest("[data-block-id]");
2453
+ if (!(n2 instanceof HTMLElement && this.contentElement.contains(n2))) return void ((this.contentElement.contains(e2) || e2 === this.contentElement) && this.handleClickBelowContent(t2));
2454
+ if (!n2.hasAttribute("data-void") && !n2.hasAttribute("data-selectable")) return void (H(this.state.selection) && (this.pendingNodeSelectionClear = true));
2332
2455
  const s2 = n2.querySelector("[data-content-dom]");
2333
- if (s2?.contains(t2)) return void ($(this.state.selection) && (this.pendingNodeSelectionClear = true));
2334
- e2.preventDefault(), this.contentElement.focus();
2335
- const r2 = pe(n2.getAttribute("data-block-id") ?? ""), o2 = this.buildBlockPath(n2), i3 = H(r2, o2), a4 = this.state.transaction("input").setSelection(i3).setStoredMarks(null, this.state.storedMarks).build(), c3 = this.state.apply(a4);
2456
+ if (s2?.contains(e2)) return void (H(this.state.selection) && (this.pendingNodeSelectionClear = true));
2457
+ t2.preventDefault(), this.contentElement.focus();
2458
+ const o2 = ht(n2.getAttribute("data-block-id") ?? ""), r2 = this.buildBlockPath(n2), i3 = _(o2, r2), a4 = this.state.transaction("input").setSelection(i3).setStoredMarks(null, this.state.storedMarks).build(), c3 = this.state.apply(a4);
2336
2459
  this.applyUpdate(c3, a4);
2337
2460
  }
2338
- handleClickBelowContent(e2) {
2339
- const t2 = this.state.getBlockOrder(), n2 = t2[t2.length - 1];
2461
+ handleClickBelowContent(t2) {
2462
+ const e2 = this.state.getBlockOrder(), n2 = e2[e2.length - 1];
2340
2463
  if (!n2) return;
2341
2464
  const s2 = this.contentElement.querySelector(`[data-block-id="${n2}"]`);
2342
2465
  if (!s2) return;
2343
- const o2 = s2.getBoundingClientRect();
2344
- if (e2.clientY <= o2.bottom) return;
2466
+ const r2 = s2.getBoundingClientRect();
2467
+ if (t2.clientY <= r2.bottom) return;
2345
2468
  const i3 = this.state.getBlock(n2);
2346
- if ("paragraph" === i3?.type && 0 === r(i3)) {
2347
- const t3 = this.state.transaction("input").setSelection(F(n2, 0)).build();
2348
- return this.dispatch(t3), void e2.preventDefault();
2469
+ if ("paragraph" === i3?.type && 0 === o(i3)) {
2470
+ const e3 = this.state.transaction("input").setSelection(O(n2, 0)).build();
2471
+ return this.dispatch(e3), void t2.preventDefault();
2349
2472
  }
2350
- e2.preventDefault(), this.contentElement.focus();
2351
- const a4 = L(), c3 = i3 ? r(i3) : 0, l2 = this.state.transaction("input").splitBlock(n2, c3, a4).setBlockType(a4, fe("paragraph")).setSelection(F(a4, 0)).build();
2473
+ t2.preventDefault(), this.contentElement.focus();
2474
+ const a4 = P(), c3 = i3 ? o(i3) : 0, l2 = this.state.transaction("input").splitBlock(n2, c3, a4).setBlockType(a4, ut("paragraph")).setSelection(O(a4, 0)).build();
2352
2475
  this.dispatch(l2);
2353
2476
  }
2354
- buildBlockPath(e2) {
2355
- const t2 = [];
2356
- let n2 = e2;
2357
- for (; n2 && n2 !== this.contentElement; ) n2.hasAttribute("data-block-id") && t2.unshift(pe(n2.getAttribute("data-block-id") ?? "")), n2 = n2.parentElement;
2358
- return t2;
2477
+ buildBlockPath(t2) {
2478
+ const e2 = [];
2479
+ let n2 = t2;
2480
+ for (; n2 && n2 !== this.contentElement; ) n2.hasAttribute("data-block-id") && e2.unshift(ht(n2.getAttribute("data-block-id") ?? "")), n2 = n2.parentElement;
2481
+ return e2;
2359
2482
  }
2360
- onDragover(e2) {
2361
- this.schemaRegistry && e2.dataTransfer && e2.dataTransfer.types.includes("Files") && e2.preventDefault();
2483
+ onDragover(t2) {
2484
+ this.schemaRegistry && t2.dataTransfer && t2.dataTransfer.types.includes("Files") && t2.preventDefault();
2362
2485
  }
2363
- onDrop(e2) {
2486
+ onDrop(t2) {
2364
2487
  if (!this.schemaRegistry) return;
2365
- if (!e2.dataTransfer) return;
2366
- const t2 = Array.from(e2.dataTransfer.files);
2367
- if (0 === t2.length) return;
2368
- const n2 = this.getPositionFromPoint(e2.clientX, e2.clientY);
2369
- for (const s2 of t2) {
2370
- const r2 = this.schemaRegistry.matchFileHandlers(s2.type);
2371
- for (const s3 of r2) {
2372
- const r3 = s3(t2, n2);
2373
- if (true === r3) return void e2.preventDefault();
2374
- if (r3 instanceof Promise) return void e2.preventDefault();
2488
+ if (!t2.dataTransfer) return;
2489
+ const e2 = Array.from(t2.dataTransfer.files);
2490
+ if (0 === e2.length) return;
2491
+ const n2 = this.getPositionFromPoint(t2.clientX, t2.clientY);
2492
+ for (const s2 of e2) {
2493
+ const o2 = this.schemaRegistry.matchFileHandlers(s2.type);
2494
+ for (const s3 of o2) {
2495
+ const o3 = s3(e2, n2);
2496
+ if (true === o3) return void t2.preventDefault();
2497
+ if (o3 instanceof Promise) return void t2.preventDefault();
2375
2498
  }
2376
2499
  }
2377
2500
  }
2378
- getPositionFromPoint(e2, t2) {
2501
+ getPositionFromPoint(t2, e2) {
2379
2502
  const n2 = this.contentElement.getRootNode();
2380
- let s2 = null, r2 = 0;
2503
+ let s2 = null, o2 = 0;
2381
2504
  if ("caretPositionFromPoint" in n2) {
2382
- const o2 = n2.caretPositionFromPoint(e2, t2);
2383
- o2 && (s2 = o2.offsetNode, r2 = o2.offset);
2505
+ const r2 = n2.caretPositionFromPoint(t2, e2);
2506
+ r2 && (s2 = r2.offsetNode, o2 = r2.offset);
2384
2507
  }
2385
2508
  if (!s2 && "caretRangeFromPoint" in n2) {
2386
- const o2 = n2.caretRangeFromPoint(e2, t2);
2387
- o2 && (s2 = o2.startContainer, r2 = o2.startOffset);
2509
+ const r2 = n2.caretRangeFromPoint(t2, e2);
2510
+ r2 && (s2 = r2.startContainer, o2 = r2.startOffset);
2388
2511
  }
2389
- return s2 && this.contentElement.contains(s2) ? Pt(this.contentElement, s2, r2) : null;
2512
+ return s2 && this.contentElement.contains(s2) ? ze(this.contentElement, s2, o2) : null;
2390
2513
  }
2391
2514
  onSelectionChange() {
2392
2515
  if (this.isUpdating) return;
2393
- const e2 = this.contentElement.getRootNode(), t2 = "activeElement" in e2 ? e2.activeElement : document.activeElement;
2394
- (this.contentElement.contains(t2) || t2 === this.contentElement) && this.syncSelectionFromDOM();
2516
+ const t2 = this.contentElement.getRootNode(), e2 = "activeElement" in t2 ? t2.activeElement : document.activeElement;
2517
+ (this.contentElement.contains(e2) || e2 === this.contentElement) && this.syncSelectionFromDOM();
2395
2518
  }
2396
- reconcileOptions(e2) {
2397
- const t2 = $(this.state.selection) ? this.state.selection.nodeId : void 0, n2 = e2 && $(e2) ? e2.nodeId : void 0;
2398
- return { registry: this.schemaRegistry, nodeViews: this.nodeViews, getState: () => this.state, dispatch: (e3) => this.dispatch(e3), selectedNodeId: t2, previousSelectedNodeId: n2 };
2519
+ reconcileOptions(t2) {
2520
+ const e2 = H(this.state.selection) ? this.state.selection.nodeId : void 0, n2 = t2 && H(t2) ? t2.nodeId : void 0;
2521
+ return { registry: this.schemaRegistry, nodeViews: this.nodeViews, getState: () => this.state, dispatch: (t3) => this.dispatch(t3), selectedNodeId: e2, previousSelectedNodeId: n2 };
2399
2522
  }
2400
2523
  destroy() {
2401
2524
  this.inputHandler.destroy(), this.keyboardHandler.destroy(), this.pasteHandler.destroy(), this.clipboardHandler.destroy(), document.removeEventListener("selectionchange", this.handleSelectionChange), this.contentElement.removeEventListener("mousedown", this.handleMousedown), this.contentElement.removeEventListener("dragover", this.handleDragover), this.contentElement.removeEventListener("drop", this.handleDrop);
2402
- for (const e2 of this.nodeViews.values()) e2.destroy?.();
2525
+ for (const t2 of this.nodeViews.values()) t2.destroy?.();
2403
2526
  this.nodeViews.clear();
2404
2527
  }
2405
2528
  }
2406
- const zt = { paragraph: "Paragraph", heading: "Heading", code_block: "Code Block", blockquote: "Block Quote", list_item: "List Item", horizontal_rule: "Horizontal Rule", image: "Image", table: "Table" };
2407
- function Ft(e2, t2) {
2408
- return "heading" === e2 && t2?.level ? `Heading ${t2.level}` : zt[e2] ?? e2;
2529
+ const qe = { paragraph: "Paragraph", heading: "Heading", code_block: "Code Block", blockquote: "Block Quote", list_item: "List Item", horizontal_rule: "Horizontal Rule", image: "Image", table: "Table" };
2530
+ function We(t2, e2) {
2531
+ return "heading" === t2 && e2?.level ? `Heading ${e2.level}` : qe[t2] ?? t2;
2409
2532
  }
2410
- function $t(e2, t2) {
2533
+ function Xe(t2, e2) {
2411
2534
  const n2 = [];
2412
- return jt(e2, [], n2, t2?.getMarkParseRules() ?? []), n2.length > 0 ? n2 : [g("")];
2413
- }
2414
- function jt(e2, t2, n2, s2) {
2415
- if (e2.nodeType === Node.TEXT_NODE) {
2416
- const s3 = e2.textContent ?? "";
2417
- return void (s3 && n2.push(g(s3, [...t2])));
2418
- }
2419
- if (e2.nodeType !== Node.ELEMENT_NODE) return;
2420
- const r2 = e2, o2 = r2.tagName.toLowerCase(), i3 = [...t2], a4 = /* @__PURE__ */ new Set();
2421
- for (const e3 of s2) if (e3.rule.tag === o2 && !a4.has(e3.type)) if (e3.rule.getAttrs) {
2422
- const t3 = e3.rule.getAttrs(r2);
2423
- if (false === t3) continue;
2424
- i3.some((t4) => t4.type === e3.type) || (i3.push({ type: ge(e3.type), ...Object.keys(t3).length > 0 ? { attrs: t3 } : {} }), a4.add(e3.type));
2425
- } else i3.some((t3) => t3.type === e3.type) || (i3.push({ type: ge(e3.type) }), a4.add(e3.type));
2426
- for (const e3 of Array.from(r2.childNodes)) jt(e3, i3, n2, s2);
2427
- }
2428
- function Ut(e2, t2) {
2429
- const n2 = e2.tagName.toLowerCase();
2430
- for (const s2 of t2) if (s2.rule.tag === n2) {
2535
+ return Je(t2, [], n2, e2?.getMarkParseRules() ?? []), n2.length > 0 ? n2 : [g("")];
2536
+ }
2537
+ function Je(t2, e2, n2, s2) {
2538
+ if (t2.nodeType === Node.TEXT_NODE) {
2539
+ const s3 = t2.textContent ?? "";
2540
+ return void (s3 && n2.push(g(s3, [...e2])));
2541
+ }
2542
+ if (t2.nodeType !== Node.ELEMENT_NODE) return;
2543
+ const o2 = t2, r2 = o2.tagName.toLowerCase(), i3 = [...e2], a4 = /* @__PURE__ */ new Set();
2544
+ for (const t3 of s2) if (t3.rule.tag === r2 && !a4.has(t3.type)) if (t3.rule.getAttrs) {
2545
+ const e3 = t3.rule.getAttrs(o2);
2546
+ if (false === e3) continue;
2547
+ i3.some((e4) => e4.type === t3.type) || (i3.push({ type: pt(t3.type), ...Object.keys(e3).length > 0 ? { attrs: e3 } : {} }), a4.add(t3.type));
2548
+ } else i3.some((e3) => e3.type === t3.type) || (i3.push({ type: pt(t3.type) }), a4.add(t3.type));
2549
+ for (const t3 of Array.from(o2.childNodes)) Je(t3, i3, n2, s2);
2550
+ }
2551
+ function Qe(t2, e2) {
2552
+ const n2 = t2.tagName.toLowerCase();
2553
+ for (const s2 of e2) if (s2.rule.tag === n2) {
2431
2554
  if (s2.rule.getAttrs) {
2432
- const t3 = s2.rule.getAttrs(e2);
2433
- if (false === t3) continue;
2434
- return { type: s2.type, attrs: t3 };
2555
+ const e3 = s2.rule.getAttrs(t2);
2556
+ if (false === e3) continue;
2557
+ return { type: s2.type, attrs: e3 };
2435
2558
  }
2436
2559
  return { type: s2.type };
2437
2560
  }
2438
2561
  return null;
2439
2562
  }
2440
- function Kt(t2, n2) {
2563
+ function Ge(t2, n2) {
2441
2564
  const s2 = (function(t3, n3) {
2442
- const s3 = e(t3), r3 = [];
2443
- for (const e2 of s3) if (d(e2)) {
2444
- const t4 = n3?.getInlineNodeSpec(e2.inlineType);
2445
- t4?.toHTMLString && r3.push(t4.toHTMLString(e2));
2446
- } else r3.push(Vt(e2, n3));
2447
- return r3.join("");
2448
- })(t2, n2), r2 = n2?.getNodeSpec(t2.type);
2449
- let o2;
2450
- o2 = r2?.toHTML ? r2.toHTML(t2, s2) : `<p>${s2 || "<br>"}</p>`;
2565
+ const s3 = e(t3), o3 = [];
2566
+ for (const t4 of s3) if (d(t4)) {
2567
+ const e2 = n3?.getInlineNodeSpec(t4.inlineType);
2568
+ e2?.toHTMLString && o3.push(e2.toHTMLString(t4));
2569
+ } else o3.push(Ye(t4, n3));
2570
+ return o3.join("");
2571
+ })(t2, n2), o2 = n2?.getNodeSpec(t2.type);
2572
+ let r2;
2573
+ r2 = o2?.toHTML ? o2.toHTML(t2, s2) : `<p>${s2 || "<br>"}</p>`;
2451
2574
  const i3 = t2.attrs?.align;
2452
- return i3 && "left" !== i3 && (o2 = o2.replace(/>/, ` style="text-align: ${i3}">`)), o2;
2453
- }
2454
- function Vt(e2, t2) {
2455
- if ("" === e2.text) return "";
2456
- let n2 = ke(e2.text);
2457
- const s2 = (function(e3) {
2458
- if (!e3) return /* @__PURE__ */ new Map();
2459
- const t3 = e3.getMarkTypes(), n3 = /* @__PURE__ */ new Map();
2460
- for (const s3 of t3) {
2461
- const t4 = e3.getMarkSpec(s3);
2462
- t4 && n3.set(s3, t4.rank ?? 99);
2575
+ return i3 && "left" !== i3 && (r2 = r2.replace(/>/, ` style="text-align: ${i3}">`)), r2;
2576
+ }
2577
+ function Ye(t2, e2) {
2578
+ if ("" === t2.text) return "";
2579
+ let n2 = mt(t2.text);
2580
+ const s2 = (function(t3) {
2581
+ if (!t3) return /* @__PURE__ */ new Map();
2582
+ const e3 = t3.getMarkTypes(), n3 = /* @__PURE__ */ new Map();
2583
+ for (const s3 of e3) {
2584
+ const e4 = t3.getMarkSpec(s3);
2585
+ e4 && n3.set(s3, e4.rank ?? 99);
2463
2586
  }
2464
2587
  return n3;
2465
- })(t2), r2 = [...e2.marks].sort((e3, t3) => (s2.get(e3.type) ?? 99) - (s2.get(t3.type) ?? 99));
2466
- for (const e3 of r2) {
2467
- const s3 = t2?.getMarkSpec(e3.type);
2468
- s3?.toHTMLString && (n2 = s3.toHTMLString(e3, n2));
2588
+ })(e2), o2 = [...t2.marks].sort((t3, e3) => (s2.get(t3.type) ?? 99) - (s2.get(e3.type) ?? 99));
2589
+ for (const t3 of o2) {
2590
+ const s3 = e2?.getMarkSpec(t3.type);
2591
+ s3?.toHTMLString && (n2 = s3.toHTMLString(t3, n2));
2469
2592
  }
2470
2593
  return n2;
2471
2594
  }
2472
- const qt = ["\n:host {\n display: block;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n color: var(--notectl-fg);\n}\n\n.notectl-editor {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--notectl-bg);\n}\n\n.notectl-editor:focus-within {\n border-color: var(--notectl-border-focus);\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* Content Area */\n.notectl-content {\n flex: 1;\n padding: 12px 16px;\n outline: none;\n min-height: var(--notectl-content-min-height, 400px);\n cursor: text;\n position: relative;\n white-space: pre-wrap;\n word-wrap: break-word;\n -moz-tab-size: 4;\n tab-size: 4;\n}\n\n.notectl-content p {\n margin: 0;\n padding: 2px 0;\n min-height: 1.6em;\n}\n\n.notectl-content p + p {\n margin-top: 0;\n}\n\n/* Horizontal Rule */\n.notectl-content hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 8px 0;\n padding: 0;\n cursor: default;\n user-select: none;\n}\n\n/* Placeholder */\n.notectl-content.notectl-content--empty::before {\n content: attr(data-placeholder);\n color: var(--notectl-fg-muted);\n pointer-events: none;\n position: absolute;\n top: 12px;\n left: 16px;\n}\n\n/* Plugin container bottom */\n.notectl-plugin-container--bottom {\n border-top: 1px solid var(--notectl-border);\n}\n\n/* Screen reader announcements */\n.notectl-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n/* Node selection */\n.notectl-node-selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n", "\n@media (prefers-reduced-motion: reduce) {\n .notectl-toolbar-btn,\n .notectl-image__resize-handle,\n .notectl-image__size-indicator,\n .notectl-color-picker__swatch,\n .notectl-font-picker__item,\n .notectl-heading-picker__item,\n .notectl-font-size-picker__item,\n .ntbl-handle,\n .ntbl-handle-delete,\n .ntbl-insert-line,\n .ntbl-insert-btn,\n .ntbl-add-zone,\n .ntbl-add-icon,\n .ntbl-col-bar,\n .ntbl-row-bar,\n .ntbl-delete-table-btn,\n .notectl-code-block__copy {\n transition: none !important;\n }\n}\n"].join("\n");
2473
- let Wt = null;
2474
- class Xt {
2595
+ const Ze = ["\n:host {\n display: block;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n color: var(--notectl-fg);\n}\n\n.notectl-editor {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--notectl-bg);\n}\n\n.notectl-editor:focus-within {\n border-color: var(--notectl-border-focus);\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* Content Area */\n.notectl-content {\n flex: 1;\n padding: 12px 16px;\n outline: none;\n min-height: var(--notectl-content-min-height, 400px);\n cursor: text;\n position: relative;\n white-space: pre-wrap;\n word-wrap: break-word;\n -moz-tab-size: 4;\n tab-size: 4;\n}\n\n.notectl-content p {\n margin: 0;\n padding: 2px 0;\n min-height: 1.6em;\n}\n\n.notectl-content p + p {\n margin-top: 0;\n}\n\n/* Horizontal Rule */\n.notectl-content hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 8px 0;\n padding: 0;\n cursor: default;\n user-select: none;\n}\n\n/* Placeholder */\n.notectl-content.notectl-content--empty::before {\n content: attr(data-placeholder);\n color: var(--notectl-fg-muted);\n pointer-events: none;\n position: absolute;\n top: 12px;\n left: 16px;\n}\n\n/* Plugin container bottom */\n.notectl-plugin-container--bottom {\n border-top: 1px solid var(--notectl-border);\n}\n\n/* Screen reader announcements */\n.notectl-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n/* Node selection */\n.notectl-node-selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n", "\n@media (prefers-reduced-motion: reduce) {\n .notectl-toolbar-btn,\n .notectl-image__resize-handle,\n .notectl-image__size-indicator,\n .notectl-color-picker__swatch,\n .notectl-font-picker__item,\n .notectl-heading-picker__item,\n .notectl-font-size-picker__item,\n .ntbl-handle,\n .ntbl-handle-delete,\n .ntbl-insert-line,\n .ntbl-insert-btn,\n .ntbl-add-zone,\n .ntbl-add-icon,\n .ntbl-col-bar,\n .ntbl-row-bar,\n .ntbl-delete-table-btn,\n .notectl-code-block__copy {\n transition: none !important;\n }\n}\n"].join("\n");
2596
+ let tn = null;
2597
+ class en {
2475
2598
  themeStyleSheet = new CSSStyleSheet();
2476
2599
  systemThemeQuery = null;
2477
2600
  systemThemeHandler = null;
2478
2601
  pluginSheets = [];
2479
2602
  shadow;
2480
- constructor(e2) {
2481
- this.shadow = e2;
2603
+ constructor(t2) {
2604
+ this.shadow = t2;
2482
2605
  }
2483
- apply(e2) {
2484
- if (this.cleanupSystemThemeListener(), e2 === et.System) {
2606
+ apply(t2) {
2607
+ if (this.cleanupSystemThemeListener(), t2 === ae.System) {
2485
2608
  this.setupSystemThemeListener();
2486
- const e3 = rt(this.getSystemTheme());
2487
- this.setThemeStyleSheet(e3);
2488
- } else this.setThemeStyleSheet(rt(e2));
2609
+ const t3 = he(this.getSystemTheme());
2610
+ this.setThemeStyleSheet(t3);
2611
+ } else this.setThemeStyleSheet(he(t2));
2489
2612
  }
2490
- setPluginStyleSheets(e2) {
2491
- this.pluginSheets = e2, this.refreshAdoptedStyleSheets();
2613
+ setPluginStyleSheets(t2) {
2614
+ this.pluginSheets = t2, this.refreshAdoptedStyleSheets();
2492
2615
  }
2493
2616
  destroy() {
2494
2617
  this.cleanupSystemThemeListener();
2495
2618
  }
2496
- setThemeStyleSheet(e2) {
2497
- this.themeStyleSheet.replaceSync(ct(e2)), this.refreshAdoptedStyleSheets();
2619
+ setThemeStyleSheet(t2) {
2620
+ this.themeStyleSheet.replaceSync(ge(t2)), this.refreshAdoptedStyleSheets();
2498
2621
  }
2499
2622
  refreshAdoptedStyleSheets() {
2500
- this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (Wt || (Wt = new CSSStyleSheet(), Wt.replaceSync(qt)), Wt), ...this.pluginSheets];
2623
+ this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (tn || (tn = new CSSStyleSheet(), tn.replaceSync(Ze)), tn), ...this.pluginSheets];
2501
2624
  }
2502
2625
  setupSystemThemeListener() {
2503
- this.systemThemeQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.systemThemeHandler = (e2) => {
2504
- const t2 = rt(this.getSystemTheme());
2505
- this.setThemeStyleSheet(t2);
2626
+ this.systemThemeQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.systemThemeHandler = (t2) => {
2627
+ const e2 = he(this.getSystemTheme());
2628
+ this.setThemeStyleSheet(e2);
2506
2629
  }, this.systemThemeQuery.addEventListener("change", this.systemThemeHandler);
2507
2630
  }
2508
2631
  cleanupSystemThemeListener() {
2509
2632
  this.systemThemeQuery && this.systemThemeHandler && this.systemThemeQuery.removeEventListener("change", this.systemThemeHandler), this.systemThemeQuery = null, this.systemThemeHandler = null;
2510
2633
  }
2511
2634
  getSystemTheme() {
2512
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? et.Dark : et.Light;
2635
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? ae.Dark : ae.Light;
2513
2636
  }
2514
2637
  }
2515
- class Jt extends HTMLElement {
2638
+ class nn extends HTMLElement {
2516
2639
  view = null;
2517
2640
  pluginManager = null;
2518
2641
  contentElement = null;
@@ -2528,8 +2651,8 @@ class Jt extends HTMLElement {
2528
2651
  preInitPlugins = [];
2529
2652
  themeController = null;
2530
2653
  constructor() {
2531
- super(), this.readyPromise = new Promise((e2) => {
2532
- this.readyPromiseResolve = e2;
2654
+ super(), this.readyPromise = new Promise((t2) => {
2655
+ this.readyPromiseResolve = t2;
2533
2656
  }), this.attachShadow({ mode: "open" });
2534
2657
  }
2535
2658
  static get observedAttributes() {
@@ -2541,53 +2664,53 @@ class Jt extends HTMLElement {
2541
2664
  disconnectedCallback() {
2542
2665
  this.destroy();
2543
2666
  }
2544
- attributeChangedCallback(e2, t2, n2) {
2545
- if ("placeholder" === e2 && this.contentElement && this.contentElement.setAttribute("data-placeholder", n2 ?? ""), "readonly" === e2 && this.contentElement) {
2546
- const e3 = null !== n2;
2547
- this.contentElement.contentEditable = e3 ? "false" : "true", e3 ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly");
2667
+ attributeChangedCallback(t2, e2, n2) {
2668
+ if ("placeholder" === t2 && this.contentElement && this.contentElement.setAttribute("data-placeholder", n2 ?? ""), "readonly" === t2 && this.contentElement) {
2669
+ const t3 = null !== n2;
2670
+ this.contentElement.contentEditable = t3 ? "false" : "true", t3 ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly");
2548
2671
  }
2549
- "theme" === e2 && this.themeController && this.themeController.apply(n2 ?? et.Light);
2672
+ "theme" === t2 && this.themeController && this.themeController.apply(n2 ?? ae.Light);
2550
2673
  }
2551
- registerPlugin(e2) {
2674
+ registerPlugin(t2) {
2552
2675
  if (this.initialized) throw new Error("Cannot register plugins after initialization. Register before calling init() or adding to DOM.");
2553
- this.preInitPlugins.push(e2);
2676
+ this.preInitPlugins.push(t2);
2554
2677
  }
2555
- async init(e2) {
2678
+ async init(t2) {
2556
2679
  if (this.initialized) return;
2557
- this.initialized = true, e2 && (this.config = e2);
2558
- const t2 = this.shadowRoot;
2559
- if (!t2) return;
2560
- this.themeController = new Xt(t2), this.themeController.apply(this.config.theme ?? et.Light);
2561
- const n2 = (function(e3) {
2562
- const t3 = document.createElement("div");
2563
- t3.className = "notectl-editor";
2680
+ this.initialized = true, t2 && (this.config = t2);
2681
+ const e2 = this.shadowRoot;
2682
+ if (!e2) return;
2683
+ this.themeController = new en(e2), this.themeController.apply(this.config.theme ?? ae.Light);
2684
+ const n2 = (function(t3) {
2685
+ const e3 = document.createElement("div");
2686
+ e3.className = "notectl-editor";
2564
2687
  const n3 = document.createElement("div");
2565
- n3.className = "notectl-plugin-container--top";
2688
+ n3.className = "notectl-plugin-container--top", n3.setAttribute("data-notectl-no-print", "");
2566
2689
  const s3 = document.createElement("div");
2567
- s3.className = "notectl-content", s3.contentEditable = e3.readonly ? "false" : "true", s3.setAttribute("role", "textbox"), s3.setAttribute("aria-multiline", "true"), s3.setAttribute("aria-label", "Rich text editor"), e3.readonly && s3.setAttribute("aria-readonly", "true"), s3.setAttribute("aria-description", "Press Escape to exit the editor"), s3.setAttribute("data-placeholder", e3.placeholder ?? "Start typing...");
2568
- const r3 = document.createElement("div");
2569
- r3.className = "notectl-plugin-container--bottom";
2690
+ s3.className = "notectl-content", s3.contentEditable = t3.readonly ? "false" : "true", s3.setAttribute("role", "textbox"), s3.setAttribute("aria-multiline", "true"), s3.setAttribute("aria-label", "Rich text editor"), t3.readonly && s3.setAttribute("aria-readonly", "true"), s3.setAttribute("aria-description", "Press Escape to exit the editor"), s3.setAttribute("data-placeholder", t3.placeholder ?? "Start typing...");
2570
2691
  const o3 = document.createElement("div");
2571
- return o3.className = "notectl-sr-only", o3.setAttribute("aria-live", "polite"), o3.setAttribute("aria-atomic", "true"), t3.appendChild(n3), t3.appendChild(s3), t3.appendChild(r3), t3.appendChild(o3), { wrapper: t3, content: s3, topPluginContainer: n3, bottomPluginContainer: r3, announcer: o3 };
2692
+ o3.className = "notectl-plugin-container--bottom", o3.setAttribute("data-notectl-no-print", "");
2693
+ const r3 = document.createElement("div");
2694
+ return r3.className = "notectl-sr-only", r3.setAttribute("data-notectl-no-print", ""), r3.setAttribute("aria-live", "polite"), r3.setAttribute("aria-atomic", "true"), e3.appendChild(n3), e3.appendChild(s3), e3.appendChild(o3), e3.appendChild(r3), { wrapper: e3, content: s3, topPluginContainer: n3, bottomPluginContainer: o3, announcer: r3 };
2572
2695
  })({ readonly: this.config.readonly, placeholder: this.config.placeholder });
2573
- this.editorWrapper = n2.wrapper, this.contentElement = n2.content, this.topPluginContainer = n2.topPluginContainer, this.bottomPluginContainer = n2.bottomPluginContainer, this.announcer = n2.announcer, t2.appendChild(this.editorWrapper), this.pluginManager = new Ze(), Re(this.pluginManager.schemaRegistry), this.processToolbarConfig();
2574
- for (const e3 of this.config.plugins ?? []) this.pluginManager.register(e3);
2575
- for (const e3 of this.preInitPlugins) this.pluginManager.register(e3);
2696
+ this.editorWrapper = n2.wrapper, this.contentElement = n2.content, this.topPluginContainer = n2.topPluginContainer, this.bottomPluginContainer = n2.bottomPluginContainer, this.announcer = n2.announcer, e2.appendChild(this.editorWrapper), this.pluginManager = new te(), Rt(this.pluginManager.schemaRegistry), this.processToolbarConfig();
2697
+ for (const t3 of this.config.plugins ?? []) this.pluginManager.register(t3);
2698
+ for (const t3 of this.preInitPlugins) this.pluginManager.register(t3);
2576
2699
  this.preInitPlugins = [], this.ensureTextFormattingPlugin(), this.contentElement.addEventListener("focus", () => this.emit("focus", void 0)), this.contentElement.addEventListener("blur", () => this.emit("blur", void 0));
2577
- const s2 = this.contentElement, r2 = this.pluginManager, o2 = this.topPluginContainer, i3 = this.bottomPluginContainer;
2578
- if (!(s2 && r2 && o2 && i3)) return;
2700
+ const s2 = this.contentElement, o2 = this.pluginManager, r2 = this.topPluginContainer, i3 = this.bottomPluginContainer;
2701
+ if (!(s2 && o2 && r2 && i3)) return;
2579
2702
  const a4 = this.announcer;
2580
- await r2.init({ getState: () => {
2703
+ await o2.init({ getState: () => {
2581
2704
  if (!this.view) throw new Error("View not initialized");
2582
2705
  return this.view.getState();
2583
- }, dispatch: (e3) => this.dispatch(e3), getContainer: () => s2, getPluginContainer: (e3) => "top" === e3 ? o2 : i3, announce: (e3) => {
2584
- a4 && (a4.textContent = e3);
2706
+ }, dispatch: (t3) => this.dispatch(t3), getContainer: () => s2, getPluginContainer: (t3) => "top" === t3 ? r2 : i3, announce: (t3) => {
2707
+ a4 && (a4.textContent = t3);
2585
2708
  }, onBeforeReady: () => {
2586
- const e3 = de(r2.schemaRegistry), t3 = Ve.create({ schema: e3 });
2587
- this.view = new Ht(s2, { state: t3, schemaRegistry: r2.schemaRegistry, maxHistoryDepth: this.config.maxHistoryDepth, getDecorations: (e4, t4) => this.pluginManager?.collectDecorations(e4, t4) ?? we.empty, onStateChange: (e4, t4, n4) => {
2588
- this.onStateChange(e4, t4, n4);
2709
+ const t3 = lt(o2.schemaRegistry), e3 = qt.create({ schema: t3 });
2710
+ this.view = new Ve(s2, { state: e3, schemaRegistry: o2.schemaRegistry, maxHistoryDepth: this.config.maxHistoryDepth, getDecorations: (t4, e4) => this.pluginManager?.collectDecorations(t4, e4) ?? wt.empty, onStateChange: (t4, e4, n4) => {
2711
+ this.onStateChange(t4, e4, n4);
2589
2712
  } }), this.updateEmptyState();
2590
- const n3 = r2.getPluginStyleSheets();
2713
+ const n3 = o2.getPluginStyleSheets();
2591
2714
  n3.length > 0 && this.themeController?.setPluginStyleSheets(n3);
2592
2715
  } }), this.config.autofocus && requestAnimationFrame(() => this.contentElement?.focus()), this.readyPromiseResolve?.(), this.emit("ready", void 0);
2593
2716
  }
@@ -2595,279 +2718,290 @@ class Jt extends HTMLElement {
2595
2718
  if (!this.view) throw new Error("Editor not initialized");
2596
2719
  return this.view.getState().doc;
2597
2720
  }
2598
- setJSON(e2) {
2599
- const t2 = this.pluginManager ? de(this.pluginManager.schemaRegistry) : void 0, n2 = Ve.create({ doc: e2, schema: t2, selection: F(e2.children[0]?.id ?? pe(""), 0) });
2721
+ setJSON(t2) {
2722
+ const e2 = this.pluginManager ? lt(this.pluginManager.schemaRegistry) : void 0, n2 = qt.create({ doc: t2, schema: e2, selection: O(t2.children[0]?.id ?? ht(""), 0) });
2600
2723
  this.replaceState(n2);
2601
2724
  }
2602
2725
  getHTML() {
2603
2726
  if (!this.view) throw new Error("Editor not initialized");
2604
- return (function(e2, t2) {
2727
+ return (function(t2, e2) {
2605
2728
  const n2 = [];
2606
2729
  let s2 = null;
2607
- for (const r3 of e2.children) if (me(r3, "list_item")) {
2608
- const e3 = "ordered" === r3.attrs.listType ? "ol" : "ul";
2609
- s2 !== e3 && (s2 && n2.push(`</${s2}>`), n2.push(`<${e3}>`), s2 = e3), n2.push(Kt(r3, t2));
2610
- } else s2 && (n2.push(`</${s2}>`), s2 = null), n2.push(Kt(r3, t2));
2730
+ for (const o3 of t2.children) if (ft(o3, "list_item")) {
2731
+ const t3 = "ordered" === o3.attrs.listType ? "ol" : "ul";
2732
+ s2 !== t3 && (s2 && n2.push(`</${s2}>`), n2.push(`<${t3}>`), s2 = t3), n2.push(Ge(o3, e2));
2733
+ } else s2 && (n2.push(`</${s2}>`), s2 = null), n2.push(Ge(o3, e2));
2611
2734
  s2 && n2.push(`</${s2}>`);
2612
- const r2 = t2 ? t2.getAllowedTags() : ["p", "br", "div", "span"], o2 = t2 ? t2.getAllowedAttrs() : ["style"];
2613
- return Ne.sanitize(n2.join(""), { ALLOWED_TAGS: r2, ALLOWED_ATTR: o2 });
2735
+ const o2 = e2 ? e2.getAllowedTags() : ["p", "br", "div", "span"], r2 = e2 ? e2.getAllowedAttrs() : ["style"];
2736
+ return Mt.sanitize(n2.join(""), { ALLOWED_TAGS: o2, ALLOWED_ATTR: r2 });
2614
2737
  })(this.view.getState().doc, this.pluginManager?.schemaRegistry);
2615
2738
  }
2616
- setHTML(e2) {
2617
- const t2 = (function(e3, t3) {
2618
- const n2 = t3 ? t3.getAllowedTags() : ["p", "br", "div", "span"], s2 = t3 ? t3.getAllowedAttrs() : ["style"], r2 = document.createElement("template");
2619
- r2.innerHTML = Ne.sanitize(e3, { ALLOWED_TAGS: n2, ALLOWED_ATTR: s2 });
2620
- const i3 = r2.content, a4 = t3?.getBlockParseRules() ?? [], c3 = [];
2621
- for (const e4 of Array.from(i3.childNodes)) if (e4.nodeType === Node.ELEMENT_NODE) {
2622
- const n3 = e4, s3 = n3.tagName.toLowerCase();
2739
+ setHTML(t2) {
2740
+ const e2 = (function(t3, e3) {
2741
+ const n2 = e3 ? e3.getAllowedTags() : ["p", "br", "div", "span"], s2 = e3 ? e3.getAllowedAttrs() : ["style"], o2 = document.createElement("template");
2742
+ o2.innerHTML = Mt.sanitize(t3, { ALLOWED_TAGS: n2, ALLOWED_ATTR: s2 });
2743
+ const i3 = o2.content, a4 = e3?.getBlockParseRules() ?? [], c3 = [];
2744
+ for (const t4 of Array.from(i3.childNodes)) if (t4.nodeType === Node.ELEMENT_NODE) {
2745
+ const n3 = t4, s3 = n3.tagName.toLowerCase();
2623
2746
  if ("ul" === s3 || "ol" === s3) {
2624
- const e5 = "ol" === s3 ? "ordered" : "bullet";
2747
+ const t5 = "ol" === s3 ? "ordered" : "bullet";
2625
2748
  for (const s4 of Array.from(n3.querySelectorAll("li"))) {
2626
- const n4 = $t(s4, t3);
2627
- c3.push(o(fe("list_item"), n4, void 0, { listType: e5, indent: 0, checked: false }));
2749
+ const n4 = Xe(s4, e3);
2750
+ c3.push(r(ut("list_item"), n4, void 0, { listType: t5, indent: 0, checked: false }));
2628
2751
  }
2629
2752
  continue;
2630
2753
  }
2631
- const r3 = Ut(n3, a4);
2632
- if (r3) {
2633
- const e5 = $t(n3, t3);
2634
- c3.push(o(fe(r3.type), e5, void 0, r3.attrs));
2754
+ const o3 = Qe(n3, a4);
2755
+ if (o3) {
2756
+ const t5 = Xe(n3, e3);
2757
+ c3.push(r(ut(o3.type), t5, void 0, o3.attrs));
2635
2758
  continue;
2636
2759
  }
2637
- const i4 = $t(n3, t3);
2638
- c3.push(o(fe("paragraph"), i4));
2639
- } else e4.nodeType === Node.TEXT_NODE && e4.textContent?.trim() && c3.push(o(fe("paragraph"), [g(e4.textContent.trim())]));
2640
- return 0 === c3.length ? P() : P(c3);
2641
- })(e2, this.pluginManager?.schemaRegistry);
2642
- this.setJSON(t2);
2760
+ const i4 = Xe(n3, e3);
2761
+ c3.push(r(ut("paragraph"), i4));
2762
+ } else t4.nodeType === Node.TEXT_NODE && t4.textContent?.trim() && c3.push(r(ut("paragraph"), [g(t4.textContent.trim())]));
2763
+ return 0 === c3.length ? I() : I(c3);
2764
+ })(t2, this.pluginManager?.schemaRegistry);
2765
+ this.setJSON(e2);
2643
2766
  }
2644
2767
  getText() {
2645
2768
  if (!this.view) throw new Error("Editor not initialized");
2646
- return this.view.getState().doc.children.map((e2) => M(e2)).join("\n");
2769
+ return this.view.getState().doc.children.map((t2) => E(t2)).join("\n");
2647
2770
  }
2648
2771
  isEmpty() {
2649
2772
  if (!this.view) return true;
2650
- const e2 = this.view.getState().doc;
2651
- if (0 === e2.children.length) return true;
2652
- if (e2.children.length > 1) return false;
2653
- const t2 = e2.children[0];
2654
- return !t2 || "paragraph" === t2.type && "" === M(t2);
2773
+ const t2 = this.view.getState().doc;
2774
+ if (0 === t2.children.length) return true;
2775
+ if (t2.children.length > 1) return false;
2776
+ const e2 = t2.children[0];
2777
+ return !e2 || "paragraph" === e2.type && "" === E(e2);
2655
2778
  }
2656
2779
  commands = { toggleBold: () => this.executeCommand("toggleBold"), toggleItalic: () => this.executeCommand("toggleItalic"), toggleUnderline: () => this.executeCommand("toggleUnderline"), undo: () => this.view?.undo(), redo: () => this.view?.redo(), selectAll: () => {
2657
2780
  if (!this.view) return;
2658
- const e2 = J(this.view.getState());
2659
- this.dispatch(e2);
2781
+ const t2 = W(this.view.getState());
2782
+ this.dispatch(t2);
2660
2783
  } };
2661
2784
  can() {
2662
- const e2 = this.view?.getState().schema;
2663
- return { toggleBold: () => !!e2 && le(e2, "bold"), toggleItalic: () => !!e2 && le(e2, "italic"), toggleUnderline: () => !!e2 && le(e2, "underline"), undo: () => this.view?.history.canUndo() ?? false, redo: () => this.view?.history.canRedo() ?? false };
2785
+ const t2 = this.view?.getState().schema;
2786
+ return { toggleBold: () => !!t2 && at(t2, "bold"), toggleItalic: () => !!t2 && at(t2, "italic"), toggleUnderline: () => !!t2 && at(t2, "underline"), undo: () => this.view?.history.canUndo() ?? false, redo: () => this.view?.history.canRedo() ?? false };
2787
+ }
2788
+ executeCommand(t2) {
2789
+ return this.pluginManager?.executeCommand(t2) ?? false;
2790
+ }
2791
+ configurePlugin(t2, e2) {
2792
+ this.pluginManager?.configurePlugin(t2, e2);
2664
2793
  }
2665
- executeCommand(e2) {
2666
- return this.pluginManager?.executeCommand(e2) ?? false;
2794
+ getService(t2) {
2795
+ return this.pluginManager?.getService(t2);
2667
2796
  }
2668
- configurePlugin(e2, t2) {
2669
- this.pluginManager?.configurePlugin(e2, t2);
2797
+ onPluginEvent(t2, e2) {
2798
+ return this.pluginManager?.onEvent(t2, e2) ?? (() => {
2799
+ });
2670
2800
  }
2671
2801
  getState() {
2672
2802
  if (!this.view) throw new Error("Editor not initialized");
2673
2803
  return this.view.getState();
2674
2804
  }
2675
- dispatch(e2) {
2676
- this.view && this.pluginManager && this.pluginManager.dispatchWithMiddleware(e2, this.view.getState(), (e3) => this.view?.dispatch(e3));
2805
+ dispatch(t2) {
2806
+ this.view && this.pluginManager && this.pluginManager.dispatchWithMiddleware(t2, this.view.getState(), (t3) => this.view?.dispatch(t3));
2677
2807
  }
2678
- on(e2, t2) {
2679
- this.eventListeners.has(e2) || this.eventListeners.set(e2, /* @__PURE__ */ new Set()), this.eventListeners.get(e2)?.add(t2);
2808
+ on(t2, e2) {
2809
+ this.eventListeners.has(t2) || this.eventListeners.set(t2, /* @__PURE__ */ new Set()), this.eventListeners.get(t2)?.add(e2);
2680
2810
  }
2681
- off(e2, t2) {
2682
- this.eventListeners.get(e2)?.delete(t2);
2811
+ off(t2, e2) {
2812
+ this.eventListeners.get(t2)?.delete(e2);
2683
2813
  }
2684
2814
  whenReady() {
2685
2815
  return this.readyPromise;
2686
2816
  }
2687
- configure(e2) {
2688
- void 0 !== e2.placeholder && this.contentElement && this.contentElement.setAttribute("data-placeholder", e2.placeholder), void 0 !== e2.readonly && this.contentElement && (this.contentElement.contentEditable = e2.readonly ? "false" : "true", e2.readonly ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly")), this.config = { ...this.config, ...e2 };
2817
+ configure(t2) {
2818
+ void 0 !== t2.placeholder && this.contentElement && this.contentElement.setAttribute("data-placeholder", t2.placeholder), void 0 !== t2.readonly && this.contentElement && (this.contentElement.contentEditable = t2.readonly ? "false" : "true", t2.readonly ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly")), this.config = { ...this.config, ...t2 };
2689
2819
  }
2690
- setTheme(e2) {
2691
- this.config = { ...this.config, theme: e2 }, this.themeController?.apply(e2);
2820
+ setTheme(t2) {
2821
+ this.config = { ...this.config, theme: t2 }, this.themeController?.apply(t2);
2692
2822
  }
2693
2823
  getTheme() {
2694
- return this.config.theme ?? et.Light;
2824
+ return this.config.theme ?? ae.Light;
2695
2825
  }
2696
2826
  destroy() {
2697
2827
  this.themeController?.destroy(), this.themeController = null, this.view?.destroy();
2698
- const e2 = this.pluginManager?.destroy() ?? Promise.resolve();
2699
- return this.view = null, this.pluginManager = null, this.initialized = false, e2;
2828
+ const t2 = this.pluginManager?.destroy() ?? Promise.resolve();
2829
+ return this.view = null, this.pluginManager = null, this.initialized = false, t2;
2700
2830
  }
2701
2831
  processToolbarConfig() {
2702
2832
  if (!this.pluginManager || !this.config.toolbar) return;
2703
- const e2 = [];
2704
- for (const t3 of this.config.toolbar) {
2833
+ const t2 = [];
2834
+ for (const e3 of this.config.toolbar) {
2705
2835
  const n2 = [];
2706
- for (const e3 of t3) n2.push(e3.id), this.pluginManager.register(e3);
2707
- e2.push(n2);
2836
+ for (const t3 of e3) n2.push(t3.id), this.pluginManager.register(t3);
2837
+ t2.push(n2);
2708
2838
  }
2709
- const t2 = { groups: e2 };
2710
- this.pluginManager.register(new Ee(t2));
2839
+ const e2 = { groups: t2 };
2840
+ this.pluginManager.register(new Et(e2));
2711
2841
  }
2712
2842
  ensureTextFormattingPlugin() {
2713
2843
  if (!this.pluginManager) return;
2714
2844
  if (void 0 !== this.pluginManager.get("text-formatting")) return;
2715
- const e2 = { bold: this.config.features?.bold ?? true, italic: this.config.features?.italic ?? true, underline: this.config.features?.underline ?? true };
2716
- this.pluginManager.register(new xe(e2));
2845
+ const t2 = { bold: this.config.features?.bold ?? true, italic: this.config.features?.italic ?? true, underline: this.config.features?.underline ?? true };
2846
+ this.pluginManager.register(new Nt(t2));
2717
2847
  }
2718
- emit(e2, t2) {
2719
- const n2 = this.eventListeners.get(e2);
2720
- if (n2) for (const e3 of n2) e3(t2);
2848
+ emit(t2, e2) {
2849
+ const n2 = this.eventListeners.get(t2);
2850
+ if (n2) for (const t3 of n2) t3(e2);
2721
2851
  }
2722
- onStateChange(e2, t2, n2) {
2723
- if (this.announcer && (this.announcer.textContent = ""), this.pluginManager?.notifyStateChange(e2, t2, n2), this.updateEmptyState(), this.emit("stateChange", { oldState: e2, newState: t2, transaction: n2 }), W(e2.selection, t2.selection) || this.emit("selectionChange", { selection: t2.selection }), !this.announcer?.textContent) {
2724
- const s2 = (function(e3, t3, n3) {
2852
+ onStateChange(t2, e2, n2) {
2853
+ if (this.announcer && (this.announcer.textContent = ""), this.pluginManager?.notifyStateChange(t2, e2, n2), this.updateEmptyState(), this.emit("stateChange", { oldState: t2, newState: e2, transaction: n2 }), V(t2.selection, e2.selection) || this.emit("selectionChange", { selection: e2.selection }), !this.announcer?.textContent) {
2854
+ const s2 = (function(t3, e3, n3) {
2725
2855
  if ("undo" === n3.metadata.historyDirection) return "Undo";
2726
2856
  if ("redo" === n3.metadata.historyDirection) return "Redo";
2727
- for (const e4 of n3.steps) if ("setBlockType" === e4.type) return Ft(e4.nodeType, e4.attrs);
2728
- for (const n4 of t3.schema.markTypes) {
2729
- const s3 = ge(n4), r2 = ue(e3, s3), o2 = ue(t3, s3);
2730
- if (r2 !== o2) return `${n4} ${o2 ? "on" : "off"}`;
2857
+ for (const t4 of n3.steps) if ("setBlockType" === t4.type) return We(t4.nodeType, t4.attrs);
2858
+ for (const n4 of e3.schema.markTypes) {
2859
+ const s3 = pt(n4), o2 = dt(t3, s3), r2 = dt(e3, s3);
2860
+ if (o2 !== r2) return `${n4} ${r2 ? "on" : "off"}`;
2731
2861
  }
2732
2862
  return null;
2733
- })(e2, t2, n2);
2863
+ })(t2, e2, n2);
2734
2864
  s2 && this.announcer && (this.announcer.textContent = s2);
2735
2865
  }
2736
2866
  }
2737
2867
  updateEmptyState() {
2738
2868
  this.contentElement && this.contentElement.classList.toggle("notectl-content--empty", this.isEmpty());
2739
2869
  }
2740
- replaceState(e2) {
2741
- this.view && (this.view.replaceState(e2), this.updateEmptyState());
2870
+ replaceState(t2) {
2871
+ this.view && (this.view.replaceState(t2), this.updateEmptyState());
2742
2872
  }
2743
2873
  }
2744
- async function Qt(e2) {
2745
- const t2 = document.createElement("notectl-editor");
2746
- return await t2.init(e2), t2;
2874
+ async function sn(t2) {
2875
+ const e2 = document.createElement("notectl-editor");
2876
+ return await e2.init(t2), e2;
2747
2877
  }
2748
- "undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor", Jt);
2878
+ "undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor", nn);
2749
2879
  export {
2880
+ oe as AFTER_PRINT,
2750
2881
  ALIGNMENT_ICONS,
2751
2882
  AlignmentPlugin,
2883
+ se as BEFORE_PRINT,
2752
2884
  BlockquotePlugin,
2753
2885
  C as CODE_BLOCK_SERVICE_KEY,
2754
- Ge as ClipboardHandler,
2886
+ Yt as ClipboardHandler,
2755
2887
  a2 as CodeBlockPlugin,
2756
- nt as DARK_THEME,
2888
+ le as DARK_THEME,
2757
2889
  DEFAULT_IMAGE_KEYMAP,
2758
- we as DecorationSet,
2759
- Ve as EditorState,
2760
- Ye as EventBus,
2761
- E as EventKey,
2890
+ wt as DecorationSet,
2891
+ qt as EditorState,
2892
+ Zt as EventBus,
2893
+ St as EventKey,
2762
2894
  FontPlugin,
2763
2895
  FontSizePlugin,
2764
2896
  HardBreakPlugin,
2765
2897
  HeadingPlugin,
2766
2898
  HighlightPlugin,
2767
- We as HistoryManager,
2899
+ Xt as HistoryManager,
2768
2900
  HorizontalRulePlugin,
2769
2901
  IMAGE_UPLOAD_SERVICE,
2770
2902
  ImagePlugin,
2771
- tt as LIGHT_THEME,
2903
+ ce as LIGHT_THEME,
2772
2904
  LinkPlugin,
2773
2905
  ListPlugin,
2774
- Jt as NotectlEditor,
2775
- Ze as PluginManager,
2776
- Me as SchemaRegistry,
2777
- S as ServiceKey,
2906
+ nn as NotectlEditor,
2907
+ ne as PRINT_SERVICE_KEY,
2908
+ te as PluginManager,
2909
+ ie as PrintPlugin,
2910
+ Ct as SchemaRegistry,
2911
+ vt as ServiceKey,
2778
2912
  StrikethroughPlugin,
2779
2913
  SuperSubPlugin,
2780
2914
  TablePlugin,
2781
2915
  TableSelectionServiceKey,
2782
2916
  AlignmentPlugin2 as TextAlignmentPlugin,
2783
2917
  TextColorPlugin,
2784
- xe as TextFormattingPlugin,
2785
- et as ThemePreset,
2786
- Ee as ToolbarPlugin,
2918
+ Nt as TextFormattingPlugin,
2919
+ ae as ThemePreset,
2920
+ Et as ToolbarPlugin,
2787
2921
  a3 as ToolbarServiceKey,
2788
- Ke as TransactionBuilder,
2789
- Ae as applyStep,
2790
- pe as blockId,
2791
- Ce as canContain,
2922
+ Vt as TransactionBuilder,
2923
+ Pt as applyStep,
2924
+ ht as blockId,
2925
+ Bt as canContain,
2792
2926
  c as commandName,
2793
- ye as createBlockElement,
2794
- o as createBlockNode,
2795
- F as createCollapsedSelection,
2796
- P as createDocument,
2797
- Qt as createEditor,
2927
+ gt as createBlockElement,
2928
+ r as createBlockNode,
2929
+ O as createCollapsedSelection,
2930
+ I as createDocument,
2931
+ sn as createEditor,
2798
2932
  f as createInlineNode,
2799
- H as createNodeSelection,
2800
- U as createPosition,
2801
- j as createSelection,
2933
+ _ as createNodeSelection,
2934
+ j as createPosition,
2935
+ $ as createSelection,
2802
2936
  g as createTextNode,
2803
- st as createTheme,
2804
- lt as createThemeStyleSheet,
2805
- X as defaultSchema,
2806
- te as deleteBackward,
2807
- ie as deleteForward,
2808
- G as deleteNodeSelection,
2809
- ee as deleteSelectionCommand,
2810
- ke as escapeHTML,
2811
- be as findNode,
2812
- ve as findNodePath,
2937
+ de as createTheme,
2938
+ me as createThemeStyleSheet,
2939
+ q as defaultSchema,
2940
+ Z as deleteBackward,
2941
+ ot as deleteForward,
2942
+ J as deleteNodeSelection,
2943
+ Y as deleteSelectionCommand,
2944
+ mt as escapeHTML,
2945
+ yt as findNode,
2946
+ bt as findNodePath,
2813
2947
  b2 as findNodeWithPath,
2814
2948
  findTableContext,
2815
2949
  t as forEachBlockInRange,
2816
- f2 as formatShortcut,
2817
- ct as generateThemeCSS,
2818
- O as getBlockChildren,
2819
- r as getBlockLength,
2820
- I as getBlockMarksAtOffset,
2821
- M as getBlockText,
2822
- R as getContentAtOffset,
2950
+ xt as formatShortcut,
2951
+ ge as generateThemeCSS,
2952
+ D as getBlockChildren,
2953
+ o as getBlockLength,
2954
+ N as getBlockMarksAtOffset,
2955
+ E as getBlockText,
2956
+ M as getContentAtOffset,
2823
2957
  e as getInlineChildren,
2824
2958
  v as getTextChildren,
2825
2959
  h as hasMark,
2826
2960
  i2 as inlineDecoration,
2827
2961
  i as inlineType,
2828
- ae as insertHardBreakCommand,
2829
- Z as insertTextCommand,
2830
- je as invertStep,
2831
- Ue as invertTransaction,
2962
+ rt as insertHardBreakCommand,
2963
+ G as insertTextCommand,
2964
+ Ut as invertStep,
2965
+ Kt as invertTransaction,
2832
2966
  l as isBlockNode,
2833
- V as isCollapsed,
2967
+ U as isCollapsed,
2834
2968
  h2 as isForward,
2835
2969
  d as isInlineNode,
2836
2970
  a as isInlineNodeOfType,
2837
2971
  u as isInsideIsolating,
2838
2972
  isInsideTable,
2839
- D as isLeafBlock,
2840
- ue as isMarkActive,
2841
- le as isMarkAllowed,
2973
+ R as isLeafBlock,
2974
+ dt as isMarkActive,
2975
+ at as isMarkAllowed,
2842
2976
  b as isMarkOfType,
2843
- me as isNodeOfType,
2844
- $ as isNodeSelection,
2977
+ ft as isNodeOfType,
2978
+ H as isNodeSelection,
2845
2979
  m as isTextNode,
2846
- K as isTextSelection,
2980
+ F as isTextSelection,
2847
2981
  v2 as isVoidBlock,
2848
- _ as markSetsEqual,
2849
- ge as markType,
2982
+ L as markSetsEqual,
2983
+ pt as markType,
2850
2984
  w as mergeBlockBackward,
2851
- Q as navigateArrowIntoVoid,
2985
+ X as navigateArrowIntoVoid,
2852
2986
  n as nodeDecoration,
2853
- fe as nodeType,
2854
- Je as normalizeKeyDescriptor,
2987
+ ut as nodeType,
2988
+ Qt as normalizeKeyDescriptor,
2855
2989
  p as pluginId,
2856
- Re as registerBuiltinSpecs,
2857
- Se as resolveNodeByPath,
2990
+ Rt as registerBuiltinSpecs,
2991
+ kt as resolveNodeByPath,
2858
2992
  c2 as resolveParentByPath,
2859
- rt as resolveTheme,
2860
- de as schemaFromRegistry,
2861
- J as selectAll,
2862
- q as selectionRange,
2863
- W as selectionsEqual,
2993
+ he as resolveTheme,
2994
+ lt as schemaFromRegistry,
2995
+ W as selectAll,
2996
+ K as selectionRange,
2997
+ V as selectionsEqual,
2864
2998
  x as sharesParent,
2865
- Y as splitBlockCommand,
2999
+ Q as splitBlockCommand,
2866
3000
  y as toggleBold,
2867
3001
  z as toggleItalic,
2868
3002
  A as toggleMark,
2869
3003
  B as toggleUnderline,
2870
- Be as validateContent,
3004
+ At as validateContent,
2871
3005
  w2 as walkNodes,
2872
3006
  w3 as widgetDecoration
2873
3007
  };