@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.
- package/README.md +2 -1
- package/dist/chunks/{ToolbarPlugin-D5VqeBPT.mjs → ToolbarPlugin-sJTiZr-S.mjs} +2 -2
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +1 -0
- package/dist/chunks/index-QvKiO9_4.mjs +538 -0
- package/dist/chunks/index-QvKiO9_4.mjs.map +1 -0
- package/dist/editor/EditorDOM.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +5 -1
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/notectl-core.mjs +1846 -1712
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +1050 -966
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +3 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +3 -111
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +69 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +1 -10
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +9 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +146 -162
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +12 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts +10 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
- package/dist/plugins/print/PrintTypes.d.ts +56 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table.mjs +13 -13
- package/dist/plugins/table.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +0 -1
- package/dist/chunks/index-CPPb-Jah.mjs +0 -569
- package/dist/chunks/index-CPPb-Jah.mjs.map +0 -1
package/dist/notectl-core.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { j as e, n as s, g as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
9
|
+
import { i as ft } from "./chunks/AttrRegistry-DTsHyDVA.mjs";
|
|
10
10
|
import { a, b } from "./chunks/AttrRegistry-DTsHyDVA.mjs";
|
|
11
|
-
import { c as
|
|
12
|
-
import { e as
|
|
13
|
-
import { a as
|
|
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
|
|
17
|
-
import { C, a as a2, i as i2, n, w as w3 } from "./chunks/index-
|
|
18
|
-
import { T as
|
|
19
|
-
import { a as a3 } from "./chunks/ToolbarPlugin-
|
|
20
|
-
import { f as
|
|
21
|
-
import { TextFormattingPlugin as
|
|
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
|
|
38
|
-
class
|
|
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(
|
|
50
|
-
if (this._nodeSpecs.has(
|
|
51
|
-
this._nodeSpecs.set(
|
|
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(
|
|
54
|
-
return this._nodeSpecs.get(
|
|
53
|
+
getNodeSpec(t2) {
|
|
54
|
+
return this._nodeSpecs.get(t2);
|
|
55
55
|
}
|
|
56
|
-
removeNodeSpec(
|
|
57
|
-
this._nodeSpecs.delete(
|
|
56
|
+
removeNodeSpec(t2) {
|
|
57
|
+
this._nodeSpecs.delete(t2);
|
|
58
58
|
}
|
|
59
59
|
getNodeTypes() {
|
|
60
60
|
return [...this._nodeSpecs.keys()];
|
|
61
61
|
}
|
|
62
|
-
registerMarkSpec(
|
|
63
|
-
if (this._markSpecs.has(
|
|
64
|
-
this._markSpecs.set(
|
|
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(
|
|
67
|
-
return this._markSpecs.get(
|
|
66
|
+
getMarkSpec(t2) {
|
|
67
|
+
return this._markSpecs.get(t2);
|
|
68
68
|
}
|
|
69
|
-
removeMarkSpec(
|
|
70
|
-
this._markSpecs.delete(
|
|
69
|
+
removeMarkSpec(t2) {
|
|
70
|
+
this._markSpecs.delete(t2);
|
|
71
71
|
}
|
|
72
72
|
getMarkTypes() {
|
|
73
73
|
return [...this._markSpecs.keys()];
|
|
74
74
|
}
|
|
75
|
-
registerInlineNodeSpec(
|
|
76
|
-
if (this._inlineNodeSpecs.has(
|
|
77
|
-
this._inlineNodeSpecs.set(
|
|
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(
|
|
80
|
-
return this._inlineNodeSpecs.get(
|
|
79
|
+
getInlineNodeSpec(t2) {
|
|
80
|
+
return this._inlineNodeSpecs.get(t2);
|
|
81
81
|
}
|
|
82
|
-
removeInlineNodeSpec(
|
|
83
|
-
this._inlineNodeSpecs.delete(
|
|
82
|
+
removeInlineNodeSpec(t2) {
|
|
83
|
+
this._inlineNodeSpecs.delete(t2);
|
|
84
84
|
}
|
|
85
85
|
getInlineNodeTypes() {
|
|
86
86
|
return [...this._inlineNodeSpecs.keys()];
|
|
87
87
|
}
|
|
88
|
-
registerNodeView(
|
|
89
|
-
if (this._nodeViews.has(
|
|
90
|
-
this._nodeViews.set(
|
|
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(
|
|
93
|
-
return this._nodeViews.get(
|
|
92
|
+
getNodeViewFactory(t2) {
|
|
93
|
+
return this._nodeViews.get(t2);
|
|
94
94
|
}
|
|
95
|
-
removeNodeView(
|
|
96
|
-
this._nodeViews.delete(
|
|
95
|
+
removeNodeView(t2) {
|
|
96
|
+
this._nodeViews.delete(t2);
|
|
97
97
|
}
|
|
98
|
-
registerKeymap(
|
|
99
|
-
for (const
|
|
100
|
-
console.debug(`[notectl] Keymap shortcut "${
|
|
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(
|
|
103
|
+
this._keymaps.push(t2);
|
|
104
104
|
}
|
|
105
105
|
getKeymaps() {
|
|
106
106
|
return this._keymaps;
|
|
107
107
|
}
|
|
108
|
-
removeKeymap(
|
|
109
|
-
const
|
|
110
|
-
-1 !==
|
|
108
|
+
removeKeymap(t2) {
|
|
109
|
+
const e2 = this._keymaps.indexOf(t2);
|
|
110
|
+
-1 !== e2 && this._keymaps.splice(e2, 1);
|
|
111
111
|
}
|
|
112
|
-
registerInputRule(
|
|
113
|
-
this._inputRules.push(
|
|
112
|
+
registerInputRule(t2) {
|
|
113
|
+
this._inputRules.push(t2);
|
|
114
114
|
}
|
|
115
115
|
getInputRules() {
|
|
116
116
|
return this._inputRules;
|
|
117
117
|
}
|
|
118
|
-
removeInputRule(
|
|
119
|
-
const
|
|
120
|
-
-1 !==
|
|
118
|
+
removeInputRule(t2) {
|
|
119
|
+
const e2 = this._inputRules.indexOf(t2);
|
|
120
|
+
-1 !== e2 && this._inputRules.splice(e2, 1);
|
|
121
121
|
}
|
|
122
|
-
registerToolbarItem(
|
|
123
|
-
if (this._toolbarItems.has(
|
|
124
|
-
if (this._toolbarItems.set(
|
|
125
|
-
const n2 = this._toolbarItemPluginMap.get(
|
|
126
|
-
n2.push(
|
|
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(
|
|
130
|
-
const
|
|
131
|
-
for (const
|
|
132
|
-
const
|
|
133
|
-
|
|
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(
|
|
138
|
-
return this._toolbarItems.get(
|
|
137
|
+
getToolbarItem(t2) {
|
|
138
|
+
return this._toolbarItems.get(t2);
|
|
139
139
|
}
|
|
140
140
|
getToolbarItems() {
|
|
141
141
|
return [...this._toolbarItems.values()];
|
|
142
142
|
}
|
|
143
|
-
removeToolbarItem(
|
|
144
|
-
this._toolbarItems.delete(
|
|
145
|
-
for (const [
|
|
146
|
-
const s2 = n2.indexOf(
|
|
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(
|
|
148
|
+
n2.splice(s2, 1), 0 === n2.length && this._toolbarItemPluginMap.delete(e2);
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
registerFileHandler(
|
|
154
|
-
this._fileHandlers.push({ pattern:
|
|
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(
|
|
160
|
-
const
|
|
161
|
-
for (const n2 of this._fileHandlers)
|
|
162
|
-
return
|
|
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(
|
|
165
|
-
const
|
|
166
|
-
-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(
|
|
169
|
-
if (this._blockTypePickerEntries.has(
|
|
170
|
-
this._blockTypePickerEntries.set(
|
|
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((
|
|
173
|
+
return [...this._blockTypePickerEntries.values()].sort((t2, e2) => t2.priority - e2.priority);
|
|
174
174
|
}
|
|
175
|
-
removeBlockTypePickerEntry(
|
|
176
|
-
this._blockTypePickerEntries.delete(
|
|
175
|
+
removeBlockTypePickerEntry(t2) {
|
|
176
|
+
this._blockTypePickerEntries.delete(t2);
|
|
177
177
|
}
|
|
178
178
|
getBlockParseRules() {
|
|
179
|
-
const
|
|
180
|
-
for (const [
|
|
181
|
-
return
|
|
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
|
|
185
|
-
for (const [
|
|
186
|
-
return
|
|
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
|
|
190
|
-
for (const [
|
|
191
|
-
return
|
|
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
|
|
195
|
-
for (const
|
|
196
|
-
for (const
|
|
197
|
-
for (const
|
|
198
|
-
return [...
|
|
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
|
|
202
|
-
for (const
|
|
203
|
-
for (const
|
|
204
|
-
for (const
|
|
205
|
-
return [...
|
|
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
|
|
212
|
-
if ("*" ===
|
|
213
|
-
if (
|
|
214
|
-
if (
|
|
215
|
-
const n2 =
|
|
216
|
-
return
|
|
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
|
|
221
|
-
const s2 =
|
|
220
|
+
function Bt(t2, e2, n2) {
|
|
221
|
+
const s2 = t2.getNodeSpec(e2);
|
|
222
222
|
if (!s2?.content) return true;
|
|
223
|
-
const
|
|
224
|
-
for (const
|
|
225
|
-
if (
|
|
226
|
-
if ("text" !==
|
|
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
|
|
231
|
-
const s2 =
|
|
230
|
+
function At(t2, e2, n2) {
|
|
231
|
+
const s2 = t2.getNodeSpec(e2);
|
|
232
232
|
if (!s2?.content) return true;
|
|
233
|
-
const { min:
|
|
234
|
-
if (i3.length <
|
|
235
|
-
for (const n3 of i3) if (!
|
|
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
|
|
239
|
-
|
|
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
|
|
241
|
+
function Pt(t2, n2) {
|
|
242
242
|
switch (n2.type) {
|
|
243
243
|
case "insertText":
|
|
244
244
|
return (function(t3, n3) {
|
|
245
|
-
return
|
|
246
|
-
const
|
|
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
|
|
249
|
-
for (const i3 of
|
|
248
|
+
let o3 = 0, r3 = false;
|
|
249
|
+
for (const i3 of t5) {
|
|
250
250
|
if (d(i3)) {
|
|
251
|
-
if (!
|
|
252
|
-
for (const
|
|
253
|
-
|
|
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),
|
|
255
|
+
s2.push(i3), o3 += 1;
|
|
256
256
|
continue;
|
|
257
257
|
}
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
260
|
-
const
|
|
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
|
|
263
|
-
c3 && s2.push(g(c3, i3.marks)),
|
|
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
|
-
|
|
265
|
+
o3 = t6;
|
|
266
266
|
}
|
|
267
|
-
if (!
|
|
267
|
+
if (!r3) for (const t6 of n4) s2.push(g(t6.text, t6.marks));
|
|
268
268
|
return s2;
|
|
269
|
-
})(
|
|
270
|
-
const
|
|
271
|
-
let
|
|
272
|
-
for (const a4 of
|
|
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 ||
|
|
274
|
+
i3 || e2 !== r3 || (o3.push(g(n4, s2)), i3 = true), o3.push(a4), r3 += 1;
|
|
275
275
|
continue;
|
|
276
276
|
}
|
|
277
|
-
const
|
|
278
|
-
if (!i3 &&
|
|
279
|
-
const
|
|
280
|
-
c3 &&
|
|
281
|
-
} else
|
|
282
|
-
|
|
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 ||
|
|
285
|
-
})(
|
|
286
|
-
return { ...t4, children:
|
|
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
|
|
292
|
-
const
|
|
291
|
+
return _t(t3, n3.blockId, (t4) => {
|
|
292
|
+
const o2 = (function(t5, e2, n4) {
|
|
293
293
|
const s2 = [];
|
|
294
|
-
let
|
|
295
|
-
for (const
|
|
296
|
-
if (d(
|
|
297
|
-
const
|
|
298
|
-
(
|
|
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
|
|
302
|
-
if (
|
|
301
|
+
const t6 = o3 + r2.text.length;
|
|
302
|
+
if (t6 <= e2 || o3 >= n4) s2.push(r2);
|
|
303
303
|
else {
|
|
304
|
-
const
|
|
305
|
-
a4.length > 0 && s2.push(g(a4,
|
|
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
|
-
|
|
307
|
+
o3 = t6;
|
|
308
308
|
}
|
|
309
309
|
return s2;
|
|
310
310
|
})(e(t4), n3.from, n3.to);
|
|
311
|
-
return { ...t4, children:
|
|
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((
|
|
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 =
|
|
321
|
-
return
|
|
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((
|
|
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
|
|
328
|
-
if (-1 !==
|
|
329
|
-
const i3 = t3.children[
|
|
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),
|
|
332
|
-
return { children: t3.children.filter((
|
|
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((
|
|
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
|
|
339
|
-
const
|
|
340
|
-
return { ...t4, children:
|
|
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
|
|
346
|
-
const
|
|
347
|
-
return { ...t4, children:
|
|
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(
|
|
354
|
-
return
|
|
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(
|
|
358
|
-
if (0 ===
|
|
359
|
-
const n3 = [...
|
|
360
|
-
return n3.splice(
|
|
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
|
|
363
|
-
const n3 = [...
|
|
364
|
-
return n3.splice(
|
|
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(
|
|
369
|
-
if (0 ===
|
|
370
|
-
const n3 = [...
|
|
371
|
-
return n3.splice(
|
|
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
|
|
374
|
-
const n3 = [...
|
|
375
|
-
return n3.splice(
|
|
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(
|
|
380
|
-
const n3 =
|
|
381
|
-
return n3 ?
|
|
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
|
|
386
|
-
const
|
|
385
|
+
return _t(t3, n3.blockId, (t4) => {
|
|
386
|
+
const o2 = (function(t5, e2, n4) {
|
|
387
387
|
const s2 = [];
|
|
388
|
-
let
|
|
389
|
-
for (const i3 of
|
|
388
|
+
let o3 = 0, r2 = false;
|
|
389
|
+
for (const i3 of t5) {
|
|
390
390
|
if (d(i3)) {
|
|
391
|
-
|
|
391
|
+
r2 || e2 !== o3 || (s2.push(n4), r2 = true), s2.push(i3), o3 += 1;
|
|
392
392
|
continue;
|
|
393
393
|
}
|
|
394
|
-
const
|
|
395
|
-
if (!
|
|
396
|
-
const
|
|
397
|
-
a4 && s2.push(g(a4, i3.marks)), s2.push(n4), c3 && s2.push(g(c3, i3.marks)),
|
|
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
|
-
|
|
399
|
+
o3 = t6;
|
|
400
400
|
}
|
|
401
|
-
return
|
|
401
|
+
return r2 || s2.push(n4), s2;
|
|
402
402
|
})(e(t4), n3.offset, n3.node);
|
|
403
|
-
return { ...t4, children:
|
|
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
|
|
409
|
-
const
|
|
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
|
|
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:
|
|
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
|
|
421
|
-
const s2 = (function(
|
|
420
|
+
return _t(t3, n3.blockId, (t4) => {
|
|
421
|
+
const s2 = (function(t5, e2, n4) {
|
|
422
422
|
const s3 = [];
|
|
423
|
-
let
|
|
424
|
-
for (const
|
|
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:
|
|
427
|
+
return { ...t4, children: Ht(t4.children, s2) };
|
|
428
428
|
});
|
|
429
429
|
})(t2, n2);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
function
|
|
433
|
-
const i3 = t2.children.findIndex((
|
|
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 =
|
|
436
|
-
return
|
|
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((
|
|
440
|
-
if (!l(
|
|
441
|
-
const
|
|
442
|
-
return
|
|
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
|
|
447
|
-
const
|
|
448
|
-
if (-1 !==
|
|
449
|
-
const i4 = t2.children[
|
|
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((
|
|
454
|
-
if (!l(
|
|
455
|
-
const
|
|
456
|
-
return
|
|
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
|
|
461
|
-
return { children:
|
|
460
|
+
function _t(t2, e2, n2) {
|
|
461
|
+
return { children: Ot(t2.children, e2, n2) };
|
|
462
462
|
}
|
|
463
|
-
function
|
|
464
|
-
return
|
|
465
|
-
if (!l(
|
|
466
|
-
if (
|
|
467
|
-
const s2 =
|
|
468
|
-
return 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
|
|
472
|
-
if (
|
|
473
|
-
const n2 =
|
|
474
|
-
return [...
|
|
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
|
|
476
|
+
function $t(t2, e2, n2) {
|
|
477
477
|
const s2 = [];
|
|
478
|
-
let
|
|
479
|
-
for (const
|
|
480
|
-
if (d(
|
|
481
|
-
const
|
|
482
|
-
|
|
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
|
|
486
|
-
if (
|
|
485
|
+
const t3 = o2 + r2.text.length;
|
|
486
|
+
if (t3 <= e2 || o2 >= n2) ;
|
|
487
487
|
else {
|
|
488
|
-
const
|
|
489
|
-
a4.length > 0 && s2.push(g(a4,
|
|
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
|
-
|
|
491
|
+
o2 = t3;
|
|
492
492
|
}
|
|
493
493
|
return 0 === s2.length && s2.push(g("")), s2;
|
|
494
494
|
}
|
|
495
|
-
function
|
|
496
|
-
const
|
|
495
|
+
function zt(t2, e2, n2, s2, o2) {
|
|
496
|
+
const r2 = [];
|
|
497
497
|
let i3 = 0;
|
|
498
|
-
for (const a4 of
|
|
498
|
+
for (const a4 of t2) {
|
|
499
499
|
if (d(a4)) {
|
|
500
|
-
|
|
500
|
+
r2.push(a4), i3 += 1;
|
|
501
501
|
continue;
|
|
502
502
|
}
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
505
|
-
else if (i3 >=
|
|
506
|
-
const
|
|
507
|
-
|
|
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
|
|
510
|
-
if (l2 &&
|
|
511
|
-
const
|
|
512
|
-
|
|
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
|
-
|
|
514
|
+
h3 && r2.push(g(h3, a4.marks));
|
|
515
515
|
}
|
|
516
|
-
i3 =
|
|
516
|
+
i3 = t3;
|
|
517
517
|
}
|
|
518
|
-
return
|
|
518
|
+
return r2;
|
|
519
519
|
}
|
|
520
|
-
function
|
|
521
|
-
if (0 ===
|
|
522
|
-
const s2 =
|
|
523
|
-
return s2 ? { children:
|
|
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
|
|
526
|
-
const
|
|
527
|
-
if (!
|
|
528
|
-
const
|
|
529
|
-
return { ...
|
|
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
|
|
532
|
-
switch (
|
|
531
|
+
function Ut(t2) {
|
|
532
|
+
switch (t2.type) {
|
|
533
533
|
case "insertText":
|
|
534
|
-
return { type: "deleteText", blockId:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
546
|
+
return { type: "setStoredMarks", marks: t2.previousMarks, previousMarks: t2.marks };
|
|
547
547
|
case "setBlockType":
|
|
548
|
-
return { type: "setBlockType", blockId:
|
|
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:
|
|
550
|
+
return { type: "removeNode", parentPath: t2.parentPath, index: t2.index, removedNode: t2.node };
|
|
551
551
|
case "removeNode":
|
|
552
|
-
return { type: "insertNode", parentPath:
|
|
552
|
+
return { type: "insertNode", parentPath: t2.parentPath, index: t2.index, node: t2.removedNode };
|
|
553
553
|
case "setNodeAttr":
|
|
554
|
-
return { type: "setNodeAttr", path:
|
|
554
|
+
return { type: "setNodeAttr", path: t2.path, attrs: t2.previousAttrs, previousAttrs: t2.attrs };
|
|
555
555
|
case "insertInlineNode":
|
|
556
|
-
return { type: "removeInlineNode", blockId:
|
|
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:
|
|
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:
|
|
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
|
|
564
|
-
return { steps:
|
|
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
|
|
566
|
+
class Vt {
|
|
567
567
|
steps = [];
|
|
568
568
|
selection;
|
|
569
569
|
storedMarks;
|
|
570
570
|
selectionBefore;
|
|
571
571
|
origin;
|
|
572
572
|
workingDoc;
|
|
573
|
-
constructor(
|
|
574
|
-
this.selection =
|
|
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(
|
|
577
|
-
const
|
|
578
|
-
return this.steps.push(
|
|
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(
|
|
580
|
+
deleteText(t2, e2, n2, s2, o2, r2) {
|
|
581
581
|
let i3;
|
|
582
|
-
if (
|
|
582
|
+
if (r2) i3 = r2;
|
|
583
583
|
else if (this.workingDoc) {
|
|
584
|
-
const
|
|
585
|
-
i3 =
|
|
586
|
-
} else i3 = [{ text: s2, marks: [...
|
|
587
|
-
const a4 = { type: "deleteText", blockId:
|
|
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(
|
|
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
|
|
594
|
-
if (!
|
|
595
|
-
const
|
|
596
|
-
return this.deleteText(
|
|
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(
|
|
599
|
-
const s2 = { type: "splitBlock", blockId:
|
|
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(
|
|
603
|
-
const s2 = { type: "mergeBlocks", targetBlockId:
|
|
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(
|
|
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 =
|
|
610
|
-
if (!s2) throw new Error(`Target block "${
|
|
611
|
-
const
|
|
612
|
-
return this.mergeBlocks(
|
|
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(
|
|
615
|
-
const
|
|
616
|
-
return this.steps.push(
|
|
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(
|
|
619
|
-
const
|
|
620
|
-
return this.steps.push(
|
|
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(
|
|
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
|
|
626
|
-
if (!
|
|
627
|
-
const
|
|
628
|
-
return this.steps.push(
|
|
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(
|
|
631
|
-
const s2 = { type: "insertNode", parentPath:
|
|
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(
|
|
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(
|
|
638
|
-
if (0 ===
|
|
639
|
-
const
|
|
640
|
-
return
|
|
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 =
|
|
642
|
+
const s3 = kt(t3, e3);
|
|
643
643
|
if (!s3) return;
|
|
644
|
-
const
|
|
645
|
-
return
|
|
646
|
-
})(n2,
|
|
647
|
-
if (!s2) throw new Error(`Node at index ${
|
|
648
|
-
const
|
|
649
|
-
return this.steps.push(
|
|
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(
|
|
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 =
|
|
655
|
-
if (!s2) throw new Error(`Node not found at path [${
|
|
656
|
-
const
|
|
657
|
-
return this.steps.push(
|
|
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(
|
|
660
|
-
const s2 = { type: "insertInlineNode", blockId:
|
|
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(
|
|
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 =
|
|
667
|
-
if (!s2) throw new Error(`Block "${
|
|
668
|
-
const
|
|
669
|
-
if (!
|
|
670
|
-
const
|
|
671
|
-
return this.steps.push(
|
|
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
|
|
675
|
-
if (!
|
|
676
|
-
const
|
|
677
|
-
if (!
|
|
678
|
-
const i3 = e(
|
|
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
|
|
683
|
-
return this.steps.push(
|
|
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(
|
|
690
|
-
return this.selection =
|
|
689
|
+
setSelection(t2) {
|
|
690
|
+
return this.selection = t2, this;
|
|
691
691
|
}
|
|
692
|
-
setNodeSelection(
|
|
693
|
-
return this.selection =
|
|
692
|
+
setNodeSelection(t2, e2) {
|
|
693
|
+
return this.selection = _(t2, e2), this;
|
|
694
694
|
}
|
|
695
|
-
setStoredMarks(
|
|
696
|
-
return this.steps.push({ type: "setStoredMarks", marks:
|
|
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(
|
|
702
|
-
this.workingDoc && (this.workingDoc =
|
|
701
|
+
advanceDoc(t2) {
|
|
702
|
+
this.workingDoc && (this.workingDoc = Pt(this.workingDoc, t2));
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
class
|
|
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(
|
|
713
|
-
this.doc =
|
|
714
|
-
}
|
|
715
|
-
static create(
|
|
716
|
-
const
|
|
717
|
-
return new
|
|
718
|
-
}
|
|
719
|
-
transaction(
|
|
720
|
-
return new
|
|
721
|
-
}
|
|
722
|
-
apply(
|
|
723
|
-
let
|
|
724
|
-
for (const n3 of
|
|
725
|
-
const n2 = (function(
|
|
726
|
-
if (
|
|
727
|
-
if (
|
|
728
|
-
const n4 =
|
|
729
|
-
return n4 ?
|
|
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 =
|
|
732
|
-
return n3 ===
|
|
733
|
-
})(
|
|
734
|
-
return new
|
|
735
|
-
}
|
|
736
|
-
getBlock(
|
|
737
|
-
return this._blockMap ??= (function(
|
|
738
|
-
const
|
|
739
|
-
return (function
|
|
740
|
-
for (const s2 of n2) l(s2) && (
|
|
741
|
-
})(
|
|
742
|
-
})(this.doc), this._blockMap.get(
|
|
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(
|
|
746
|
-
const
|
|
747
|
-
return (function
|
|
748
|
-
for (const s2 of n2) l(s2) && (
|
|
749
|
-
})(
|
|
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(
|
|
753
|
-
return
|
|
752
|
+
getNodePath(t2) {
|
|
753
|
+
return bt(this.doc, t2);
|
|
754
754
|
}
|
|
755
|
-
getParent(
|
|
756
|
-
const
|
|
757
|
-
if (!
|
|
758
|
-
const n2 =
|
|
759
|
-
return n2 ?
|
|
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(
|
|
765
|
-
return new
|
|
764
|
+
static fromJSON(t2, e2) {
|
|
765
|
+
return new qt(t2.doc, t2.selection, null, e2 ?? q());
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
|
-
function
|
|
769
|
-
const n2 =
|
|
768
|
+
function Wt(t2, e2) {
|
|
769
|
+
const n2 = yt(t2, e2.blockId);
|
|
770
770
|
if (n2) {
|
|
771
|
-
const
|
|
772
|
-
return
|
|
771
|
+
const t3 = o(n2);
|
|
772
|
+
return e2.offset > t3 ? j(e2.blockId, t3, e2.path) : e2;
|
|
773
773
|
}
|
|
774
|
-
const s2 =
|
|
775
|
-
return s2 ?
|
|
774
|
+
const s2 = t2.children[0];
|
|
775
|
+
return s2 ? j(s2.id, 0) : e2;
|
|
776
776
|
}
|
|
777
|
-
class
|
|
777
|
+
class Xt {
|
|
778
778
|
undoStack = [];
|
|
779
779
|
redoStack = [];
|
|
780
780
|
groupTimeoutMs;
|
|
781
781
|
maxDepth;
|
|
782
782
|
lastOrigin = null;
|
|
783
|
-
constructor(
|
|
784
|
-
this.groupTimeoutMs =
|
|
785
|
-
}
|
|
786
|
-
push(
|
|
787
|
-
if ("history" ===
|
|
788
|
-
const
|
|
789
|
-
for (n2 && "input" ===
|
|
790
|
-
}
|
|
791
|
-
undo(
|
|
792
|
-
const
|
|
793
|
-
if (!
|
|
794
|
-
let n2 =
|
|
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
|
|
797
|
-
const
|
|
798
|
-
if (!
|
|
799
|
-
const
|
|
800
|
-
n2 = n2.apply(
|
|
801
|
-
}
|
|
802
|
-
return this.redoStack.push({ transactions:
|
|
803
|
-
}
|
|
804
|
-
redo(
|
|
805
|
-
const
|
|
806
|
-
if (!
|
|
807
|
-
let n2 =
|
|
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
|
|
810
|
-
return this.undoStack.push({ transactions:
|
|
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(
|
|
822
|
-
const n2 =
|
|
821
|
+
isSameInputType(t2, e2) {
|
|
822
|
+
const n2 = t2[t2.length - 1];
|
|
823
823
|
if (!n2) return false;
|
|
824
|
-
const s2 = n2.steps[0]?.type,
|
|
825
|
-
return s2 ===
|
|
824
|
+
const s2 = n2.steps[0]?.type, o2 = e2.steps[0]?.type;
|
|
825
|
+
return s2 === o2;
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
|
-
class
|
|
829
|
-
constructor(
|
|
830
|
-
this.element =
|
|
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(
|
|
839
|
-
if (this.handleNodeSelectionKeys(
|
|
840
|
-
if (this.handleArrowIntoVoid(
|
|
838
|
+
onKeydown(t2) {
|
|
839
|
+
if (this.handleNodeSelectionKeys(t2)) return;
|
|
840
|
+
if (this.handleArrowIntoVoid(t2)) return;
|
|
841
841
|
if (this.schemaRegistry) {
|
|
842
|
-
const
|
|
842
|
+
const e3 = Qt(t2), n3 = this.schemaRegistry.getKeymaps();
|
|
843
843
|
for (let s3 = n3.length - 1; s3 >= 0; s3--) {
|
|
844
|
-
const
|
|
845
|
-
if (
|
|
844
|
+
const o2 = n3[s3]?.[e3];
|
|
845
|
+
if (o2?.()) return void t2.preventDefault();
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
if (this.handleTab(
|
|
849
|
-
if (this.handleEscape(
|
|
850
|
-
if (!
|
|
851
|
-
const
|
|
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" !==
|
|
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(
|
|
856
|
-
const
|
|
857
|
-
if (
|
|
858
|
-
const s2 =
|
|
859
|
-
if (!("ArrowLeft" !== s2 && "ArrowUp" !== s2 && "ArrowRight" !== s2 && "ArrowDown" !== s2 ||
|
|
860
|
-
const n3 =
|
|
861
|
-
return !!n3 && (
|
|
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
|
-
|
|
865
|
-
const s3 =
|
|
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
|
-
|
|
870
|
-
const n3 =
|
|
869
|
+
t2.preventDefault();
|
|
870
|
+
const n3 = Q(e2);
|
|
871
871
|
return n3 && this.dispatch(n3), true;
|
|
872
872
|
}
|
|
873
873
|
if ("Escape" === s2) {
|
|
874
|
-
|
|
875
|
-
const n3 =
|
|
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(
|
|
881
|
-
if ("Tab" !==
|
|
882
|
-
if (
|
|
883
|
-
if (
|
|
884
|
-
const
|
|
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(
|
|
888
|
-
return "Escape" ===
|
|
887
|
+
handleEscape(t2) {
|
|
888
|
+
return "Escape" === t2.key && (this.element.blur(), true);
|
|
889
889
|
}
|
|
890
|
-
handleArrowIntoVoid(
|
|
891
|
-
const
|
|
892
|
-
if ("ArrowLeft" !==
|
|
893
|
-
if (
|
|
894
|
-
const n2 = this.getState(), s2 =
|
|
895
|
-
return !!s2 && (
|
|
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
|
|
902
|
-
const
|
|
903
|
-
(
|
|
904
|
-
let n2 =
|
|
905
|
-
return " " === n2 ? n2 = "Space" : 1 === n2.length && (n2 = n2.toUpperCase()),
|
|
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
|
|
908
|
-
class
|
|
909
|
-
constructor(
|
|
910
|
-
this.element =
|
|
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(
|
|
918
|
+
onCopy(t2) {
|
|
919
919
|
this.syncSelection?.();
|
|
920
|
-
const
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
const s2 =
|
|
924
|
-
s2 && (
|
|
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(
|
|
926
|
+
onCut(t2) {
|
|
927
927
|
this.syncSelection?.();
|
|
928
|
-
const
|
|
929
|
-
if (
|
|
930
|
-
|
|
931
|
-
const s2 =
|
|
932
|
-
if (s2) if (
|
|
933
|
-
this.writeNodeSelectionToClipboard(s2,
|
|
934
|
-
const
|
|
935
|
-
|
|
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,
|
|
938
|
-
const
|
|
939
|
-
|
|
937
|
+
this.writeTextSelectionToClipboard(s2, e2);
|
|
938
|
+
const t3 = Y(e2);
|
|
939
|
+
t3 && this.dispatch(t3);
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
|
-
writeNodeSelectionToClipboard(
|
|
943
|
-
const n2 =
|
|
944
|
-
if (
|
|
945
|
-
const s2 =
|
|
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
|
|
948
|
-
|
|
949
|
-
const
|
|
950
|
-
|
|
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
|
-
|
|
953
|
-
}
|
|
954
|
-
writeTextSelectionToClipboard(
|
|
955
|
-
const n2 =
|
|
956
|
-
if (
|
|
957
|
-
if (
|
|
958
|
-
const s2 =
|
|
959
|
-
for (let
|
|
960
|
-
const n3 = s2[
|
|
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
|
|
963
|
-
if (!
|
|
964
|
-
const
|
|
965
|
-
c3.push(g2), l2.push({ type:
|
|
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
|
|
968
|
-
if (
|
|
967
|
+
const d2 = c3.join("\n");
|
|
968
|
+
if (t2.setData("text/plain", d2), this.schemaRegistry) {
|
|
969
969
|
const n3 = [];
|
|
970
|
-
for (let
|
|
971
|
-
const c4 = s2[
|
|
970
|
+
for (let t3 = i3; t3 <= a4; t3++) {
|
|
971
|
+
const c4 = s2[t3];
|
|
972
972
|
if (!c4) continue;
|
|
973
|
-
const l3 =
|
|
973
|
+
const l3 = e2.getBlock(c4);
|
|
974
974
|
if (!l3) continue;
|
|
975
|
-
const
|
|
976
|
-
n3.push(this.serializeBlockRangeToHTML(l3,
|
|
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
|
-
|
|
978
|
+
t2.setData("text/html", n3.join(""));
|
|
979
979
|
}
|
|
980
|
-
!(function(
|
|
981
|
-
|
|
982
|
-
})(
|
|
980
|
+
!(function(t3, e3) {
|
|
981
|
+
Gt = { plainText: t3, blocks: e3 };
|
|
982
|
+
})(d2, l2);
|
|
983
983
|
}
|
|
984
984
|
serializeBlockRangeToHTML(t2, n2, s2) {
|
|
985
|
-
const
|
|
985
|
+
const o2 = e(t2), r2 = [];
|
|
986
986
|
let i3 = 0;
|
|
987
|
-
for (const
|
|
988
|
-
const
|
|
989
|
-
if (
|
|
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(
|
|
992
|
-
const
|
|
993
|
-
a4.length > 0 &&
|
|
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 =
|
|
995
|
+
i3 = e2;
|
|
996
996
|
}
|
|
997
997
|
}
|
|
998
|
-
return
|
|
998
|
+
return r2.join("");
|
|
999
999
|
}
|
|
1000
|
-
serializeTextWithMarks(
|
|
1001
|
-
if (0 ===
|
|
1002
|
-
const n2 = [...
|
|
1003
|
-
const n3 = this.schemaRegistry?.getMarkSpec(
|
|
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 =
|
|
1007
|
-
for (const
|
|
1008
|
-
const
|
|
1009
|
-
|
|
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
|
|
1017
|
+
class Zt {
|
|
1018
1018
|
listeners = /* @__PURE__ */ new Map();
|
|
1019
|
-
emit(
|
|
1020
|
-
const n2 = this.listeners.get(
|
|
1019
|
+
emit(t2, e2) {
|
|
1020
|
+
const n2 = this.listeners.get(t2.id);
|
|
1021
1021
|
if (n2) for (const s2 of n2) try {
|
|
1022
|
-
s2(
|
|
1023
|
-
} catch (
|
|
1024
|
-
console.error(`[EventBus] Listener error on "${
|
|
1022
|
+
s2(e2);
|
|
1023
|
+
} catch (e3) {
|
|
1024
|
+
console.error(`[EventBus] Listener error on "${t2.id}":`, e3);
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
|
-
on(
|
|
1028
|
-
const n2 =
|
|
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(
|
|
1032
|
-
s2.delete(
|
|
1031
|
+
return s2.add(e2), () => {
|
|
1032
|
+
s2.delete(e2), 0 === s2.size && this.listeners.delete(n2);
|
|
1033
1033
|
};
|
|
1034
1034
|
}
|
|
1035
|
-
off(
|
|
1036
|
-
const n2 = this.listeners.get(
|
|
1037
|
-
n2 && (n2.delete(
|
|
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
|
|
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
|
|
1049
|
+
eventBus = new Zt();
|
|
1050
1050
|
pluginStyleSheets = [];
|
|
1051
|
-
schemaRegistry = new
|
|
1051
|
+
schemaRegistry = new Ct();
|
|
1052
1052
|
middlewareSorted = null;
|
|
1053
1053
|
initOrder = [];
|
|
1054
1054
|
initialized = false;
|
|
1055
1055
|
initializing = false;
|
|
1056
|
-
register(
|
|
1057
|
-
if (this.initialized || this.initializing) throw new Error(`Cannot register plugin "${
|
|
1058
|
-
if (this.plugins.has(
|
|
1059
|
-
this.plugins.set(
|
|
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(
|
|
1061
|
+
async init(t2) {
|
|
1062
1062
|
if (!this.initialized && !this.initializing) {
|
|
1063
1063
|
this.initializing = true, this.initOrder = this.resolveOrder();
|
|
1064
|
-
for (const
|
|
1065
|
-
const n2 = this.plugins.get(
|
|
1064
|
+
for (const e2 of this.initOrder) {
|
|
1065
|
+
const n2 = this.plugins.get(e2);
|
|
1066
1066
|
if (!n2) continue;
|
|
1067
|
-
const s2 = this.createContext(
|
|
1067
|
+
const s2 = this.createContext(e2, t2);
|
|
1068
1068
|
try {
|
|
1069
1069
|
await n2.init(s2);
|
|
1070
|
-
} catch (
|
|
1071
|
-
console.error(`[PluginManager] Plugin "${
|
|
1070
|
+
} catch (t3) {
|
|
1071
|
+
console.error(`[PluginManager] Plugin "${e2}" failed to initialize:`, t3);
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
|
-
|
|
1075
|
-
for (const
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
await
|
|
1079
|
-
} catch (
|
|
1080
|
-
console.error(`[PluginManager] Plugin "${
|
|
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(
|
|
1086
|
+
notifyStateChange(t2, e2, n2) {
|
|
1087
1087
|
for (const s2 of this.initOrder) {
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1091
|
-
} catch (
|
|
1092
|
-
console.error(`[PluginManager] Plugin "${s2}" error in onStateChange:`,
|
|
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(
|
|
1097
|
-
let n2 =
|
|
1096
|
+
collectDecorations(t2, e2) {
|
|
1097
|
+
let n2 = wt.empty;
|
|
1098
1098
|
for (const s2 of this.initOrder) {
|
|
1099
|
-
const
|
|
1100
|
-
if (
|
|
1101
|
-
const s3 =
|
|
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 (
|
|
1104
|
-
console.error(`[PluginManager] Plugin "${s2}" error in decorations():`,
|
|
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(
|
|
1110
|
-
if (0 === this.middlewares.length) return void n2(
|
|
1109
|
+
dispatchWithMiddleware(t2, e2, n2) {
|
|
1110
|
+
if (0 === this.middlewares.length) return void n2(t2);
|
|
1111
1111
|
const s2 = this.getSortedMiddleware();
|
|
1112
|
-
let
|
|
1113
|
-
const i3 = (
|
|
1114
|
-
if (
|
|
1115
|
-
const n3 = s2[
|
|
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
|
|
1118
|
-
const a4 = (
|
|
1119
|
-
|
|
1117
|
+
let r3 = false;
|
|
1118
|
+
const a4 = (t4) => {
|
|
1119
|
+
r3 || (r3 = true, i3(t4));
|
|
1120
1120
|
};
|
|
1121
1121
|
try {
|
|
1122
|
-
n3.middleware(
|
|
1123
|
-
} catch (
|
|
1124
|
-
console.error("[PluginManager] Middleware error:",
|
|
1122
|
+
n3.middleware(t3, e2, a4);
|
|
1123
|
+
} catch (e3) {
|
|
1124
|
+
console.error("[PluginManager] Middleware error:", e3), a4(t3);
|
|
1125
1125
|
}
|
|
1126
|
-
} else
|
|
1126
|
+
} else r2 || (r2 = true, n2(t3));
|
|
1127
1127
|
};
|
|
1128
|
-
i3(
|
|
1128
|
+
i3(t2);
|
|
1129
1129
|
}
|
|
1130
|
-
executeCommand(
|
|
1131
|
-
const
|
|
1132
|
-
if (!
|
|
1130
|
+
executeCommand(t2) {
|
|
1131
|
+
const e2 = this.commands.get(t2);
|
|
1132
|
+
if (!e2) return false;
|
|
1133
1133
|
try {
|
|
1134
|
-
return
|
|
1135
|
-
} catch (
|
|
1136
|
-
return console.error(`[PluginManager] Command "${
|
|
1134
|
+
return e2.handler();
|
|
1135
|
+
} catch (e3) {
|
|
1136
|
+
return console.error(`[PluginManager] Command "${t2}" error:`, e3), false;
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
|
-
configurePlugin(
|
|
1140
|
-
const n2 = this.plugins.get(
|
|
1141
|
-
if (!n2) throw new Error(`Plugin "${
|
|
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(
|
|
1144
|
-
} catch (
|
|
1145
|
-
console.error(`[PluginManager] Plugin "${
|
|
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(
|
|
1152
|
-
return this.plugins.get(
|
|
1151
|
+
get(t2) {
|
|
1152
|
+
return this.plugins.get(t2);
|
|
1153
|
+
}
|
|
1154
|
+
getService(t2) {
|
|
1155
|
+
return this.services.get(t2.id);
|
|
1153
1156
|
}
|
|
1154
|
-
|
|
1155
|
-
return this.
|
|
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
|
|
1162
|
-
for (const
|
|
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(
|
|
1166
|
-
const
|
|
1167
|
-
if (
|
|
1168
|
-
await
|
|
1169
|
-
} catch (
|
|
1170
|
-
console.error(`[PluginManager] Plugin "${
|
|
1171
|
-
}
|
|
1172
|
-
this.cleanupRegistrations(
|
|
1173
|
-
}
|
|
1174
|
-
cleanupRegistrations(
|
|
1175
|
-
const
|
|
1176
|
-
if (
|
|
1177
|
-
for (const
|
|
1178
|
-
for (const
|
|
1179
|
-
for (const
|
|
1180
|
-
const
|
|
1181
|
-
-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
|
|
1184
|
-
for (const
|
|
1185
|
-
for (const
|
|
1186
|
-
for (const
|
|
1187
|
-
for (const
|
|
1188
|
-
for (const
|
|
1189
|
-
for (const
|
|
1190
|
-
for (const
|
|
1191
|
-
for (const
|
|
1192
|
-
for (const
|
|
1193
|
-
for (const
|
|
1194
|
-
const
|
|
1195
|
-
-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(
|
|
1200
|
+
this.middlewareSorted = null, this.registrations.delete(t2);
|
|
1198
1201
|
}
|
|
1199
1202
|
}
|
|
1200
1203
|
getSortedMiddleware() {
|
|
1201
|
-
return this.middlewareSorted || (this.middlewareSorted = [...this.middlewares].sort((
|
|
1204
|
+
return this.middlewareSorted || (this.middlewareSorted = [...this.middlewares].sort((t2, e2) => t2.priority - e2.priority)), this.middlewareSorted;
|
|
1202
1205
|
}
|
|
1203
|
-
createContext(
|
|
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(
|
|
1206
|
-
const s2 = { emit: (
|
|
1207
|
-
const s3 = this.eventBus.on(
|
|
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: (
|
|
1210
|
-
return { getState:
|
|
1211
|
-
if (this.commands.has(
|
|
1212
|
-
const
|
|
1213
|
-
throw new Error(`Command "${
|
|
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(
|
|
1216
|
-
}, executeCommand: (
|
|
1217
|
-
const s3 = { middleware:
|
|
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: (
|
|
1220
|
-
if (this.services.has(
|
|
1221
|
-
this.services.set(
|
|
1222
|
-
}, getService: (
|
|
1223
|
-
const n3 = this.plugins.get(
|
|
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(
|
|
1226
|
-
} catch (
|
|
1227
|
-
console.error(`[PluginManager] Plugin "${
|
|
1228
|
+
n3.onConfigure(e3);
|
|
1229
|
+
} catch (e4) {
|
|
1230
|
+
console.error(`[PluginManager] Plugin "${t2}" error in onConfigure:`, e4);
|
|
1228
1231
|
}
|
|
1229
|
-
}, registerNodeSpec: (
|
|
1230
|
-
this.schemaRegistry.registerNodeSpec(
|
|
1231
|
-
}, registerMarkSpec: (
|
|
1232
|
-
this.schemaRegistry.registerMarkSpec(
|
|
1233
|
-
}, registerNodeView: (
|
|
1234
|
-
this.schemaRegistry.registerNodeView(
|
|
1235
|
-
}, registerKeymap: (
|
|
1236
|
-
this.schemaRegistry.registerKeymap(
|
|
1237
|
-
}, registerInputRule: (
|
|
1238
|
-
this.schemaRegistry.registerInputRule(
|
|
1239
|
-
}, registerToolbarItem: (
|
|
1240
|
-
this.schemaRegistry.registerToolbarItem(
|
|
1241
|
-
}, registerInlineNodeSpec: (
|
|
1242
|
-
this.schemaRegistry.registerInlineNodeSpec(
|
|
1243
|
-
}, registerFileHandler: (
|
|
1244
|
-
this.schemaRegistry.registerFileHandler(
|
|
1245
|
-
}, registerBlockTypePickerEntry: (
|
|
1246
|
-
this.schemaRegistry.registerBlockTypePickerEntry(
|
|
1247
|
-
}, getSchemaRegistry: () => this.schemaRegistry, registerStyleSheet: (
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
}, announce: (
|
|
1251
|
-
|
|
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
|
|
1256
|
-
for (const
|
|
1257
|
-
const
|
|
1258
|
-
if (
|
|
1259
|
-
for (const n3 of
|
|
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
|
|
1263
|
-
for (const s3 of
|
|
1264
|
-
for (const s3 of
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
for (const
|
|
1268
|
-
const
|
|
1269
|
-
|
|
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 [
|
|
1274
|
-
const
|
|
1276
|
+
for (const [t3, n3] of e2) 0 === n3 && s2.push(t3);
|
|
1277
|
+
const o2 = [];
|
|
1275
1278
|
for (; s2.length > 0; ) {
|
|
1276
|
-
s2.sort((
|
|
1277
|
-
const
|
|
1278
|
-
if (!
|
|
1279
|
-
|
|
1280
|
-
for (const
|
|
1281
|
-
const
|
|
1282
|
-
|
|
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 (
|
|
1286
|
-
const
|
|
1287
|
-
throw new Error(`Circular dependency detected among plugins: ${
|
|
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, "&").replace(/</g, "<").replace(/>/g, ">")}</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
|
-
|
|
1410
|
+
}
|
|
1411
|
+
destroy() {
|
|
1412
|
+
this.service = null;
|
|
1290
1413
|
}
|
|
1291
1414
|
}
|
|
1292
|
-
const
|
|
1293
|
-
function
|
|
1294
|
-
return { name:
|
|
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
|
|
1297
|
-
if ("object" == typeof
|
|
1298
|
-
switch (
|
|
1299
|
-
case
|
|
1300
|
-
return
|
|
1301
|
-
case
|
|
1302
|
-
return
|
|
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
|
|
1427
|
+
return ce;
|
|
1305
1428
|
}
|
|
1306
1429
|
}
|
|
1307
|
-
const
|
|
1308
|
-
function
|
|
1309
|
-
const n2 =
|
|
1310
|
-
let s2 =
|
|
1311
|
-
for (const
|
|
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[
|
|
1436
|
+
s2 = s2[t3];
|
|
1314
1437
|
}
|
|
1315
1438
|
return "string" == typeof s2 ? s2 : void 0;
|
|
1316
1439
|
}
|
|
1317
|
-
function
|
|
1318
|
-
const
|
|
1319
|
-
for (const [n2, s2] of
|
|
1320
|
-
const
|
|
1321
|
-
if (void 0 !==
|
|
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
|
|
1324
|
-
|
|
1446
|
+
const t3 = pe.get(s2);
|
|
1447
|
+
t3 && e2.push(` ${s2}: ${t3};`);
|
|
1325
1448
|
}
|
|
1326
1449
|
}
|
|
1327
|
-
return
|
|
1450
|
+
return e2.push("}"), e2.join("\n");
|
|
1328
1451
|
}
|
|
1329
|
-
function
|
|
1330
|
-
const
|
|
1331
|
-
return
|
|
1452
|
+
function me(t2) {
|
|
1453
|
+
const e2 = new CSSStyleSheet();
|
|
1454
|
+
return e2.replaceSync(ge(t2)), e2;
|
|
1332
1455
|
}
|
|
1333
|
-
class
|
|
1334
|
-
constructor(
|
|
1335
|
-
this.element =
|
|
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(
|
|
1346
|
-
if (this.composing && "insertCompositionText" ===
|
|
1347
|
-
|
|
1348
|
-
const
|
|
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 (
|
|
1473
|
+
switch (t2.inputType) {
|
|
1351
1474
|
case "insertText":
|
|
1352
|
-
|
|
1475
|
+
t2.data && (n2 = G(e2, t2.data, "input"));
|
|
1353
1476
|
break;
|
|
1354
1477
|
case "insertParagraph":
|
|
1355
|
-
n2 =
|
|
1478
|
+
n2 = Q(e2);
|
|
1356
1479
|
break;
|
|
1357
1480
|
case "insertLineBreak":
|
|
1358
|
-
n2 =
|
|
1481
|
+
n2 = rt(e2);
|
|
1359
1482
|
break;
|
|
1360
1483
|
case "deleteContentBackward":
|
|
1361
1484
|
case "deleteByCut":
|
|
1362
|
-
n2 =
|
|
1485
|
+
n2 = Z(e2);
|
|
1363
1486
|
break;
|
|
1364
1487
|
case "deleteContentForward":
|
|
1365
|
-
n2 =
|
|
1488
|
+
n2 = ot(e2);
|
|
1366
1489
|
break;
|
|
1367
1490
|
case "deleteWordBackward":
|
|
1368
|
-
n2 =
|
|
1491
|
+
n2 = st(e2);
|
|
1369
1492
|
break;
|
|
1370
1493
|
case "deleteWordForward":
|
|
1371
|
-
n2 =
|
|
1494
|
+
n2 = nt(e2);
|
|
1372
1495
|
break;
|
|
1373
1496
|
case "deleteSoftLineBackward":
|
|
1374
|
-
n2 =
|
|
1497
|
+
n2 = et(e2);
|
|
1375
1498
|
break;
|
|
1376
1499
|
case "deleteSoftLineForward":
|
|
1377
|
-
n2 =
|
|
1500
|
+
n2 = tt(e2);
|
|
1378
1501
|
}
|
|
1379
|
-
n2 && (this.dispatch(n2), "insertText" ===
|
|
1502
|
+
n2 && (this.dispatch(n2), "insertText" === t2.inputType && this.checkInputRules());
|
|
1380
1503
|
}
|
|
1381
|
-
onCompositionStart(
|
|
1504
|
+
onCompositionStart(t2) {
|
|
1382
1505
|
this.composing = true;
|
|
1383
1506
|
}
|
|
1384
|
-
onCompositionEnd(
|
|
1507
|
+
onCompositionEnd(t2) {
|
|
1385
1508
|
this.composing = false;
|
|
1386
|
-
const
|
|
1387
|
-
if (!
|
|
1388
|
-
const n2 = this.getState(), s2 =
|
|
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
|
|
1394
|
-
if (0 ===
|
|
1395
|
-
const
|
|
1396
|
-
if (
|
|
1397
|
-
const { anchor: n2 } =
|
|
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
|
|
1400
|
-
for (const n3 of
|
|
1401
|
-
const
|
|
1402
|
-
if (
|
|
1403
|
-
const s3 =
|
|
1404
|
-
if (
|
|
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
|
|
1413
|
-
return
|
|
1535
|
+
function ke(t2) {
|
|
1536
|
+
return t2.reduce((t3, e2) => t3 + e2.text, "");
|
|
1414
1537
|
}
|
|
1415
|
-
function
|
|
1416
|
-
return
|
|
1538
|
+
function be(t2) {
|
|
1539
|
+
return t2.reduce((t3, e2) => t3 + e2.text.length, 0);
|
|
1417
1540
|
}
|
|
1418
|
-
const
|
|
1419
|
-
class
|
|
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(
|
|
1424
|
-
this.schema =
|
|
1546
|
+
constructor(t2) {
|
|
1547
|
+
this.schema = t2.schema, this.blockParseRules = t2.schemaRegistry?.getBlockParseRules() ?? [], this.markParseRules = t2.schemaRegistry?.getMarkParseRules() ?? [];
|
|
1425
1548
|
}
|
|
1426
|
-
parse(
|
|
1427
|
-
const
|
|
1428
|
-
return 0 ===
|
|
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(
|
|
1431
|
-
const
|
|
1553
|
+
parseContainer(t2) {
|
|
1554
|
+
const e2 = [];
|
|
1432
1555
|
let n2 = [];
|
|
1433
|
-
for (const s2 of Array.from(
|
|
1434
|
-
const
|
|
1435
|
-
this.isBlockElement(
|
|
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
|
|
1438
|
-
|
|
1560
|
+
const t3 = s2.textContent ?? "";
|
|
1561
|
+
t3 && n2.push({ text: t3, marks: [] });
|
|
1439
1562
|
}
|
|
1440
|
-
return this.flushPendingSegments(
|
|
1563
|
+
return this.flushPendingSegments(e2, n2), e2;
|
|
1441
1564
|
}
|
|
1442
|
-
parseBlockElement(
|
|
1443
|
-
const
|
|
1565
|
+
parseBlockElement(t2) {
|
|
1566
|
+
const e2 = t2.tagName, n2 = /^H([1-6])$/.exec(e2);
|
|
1444
1567
|
if (n2) {
|
|
1445
|
-
const
|
|
1446
|
-
return [{ type: s2, ...s2 ===
|
|
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 (
|
|
1571
|
+
switch (e2) {
|
|
1449
1572
|
case "P":
|
|
1450
1573
|
case "DIV":
|
|
1451
|
-
return [{ type: this.resolveBlockType(
|
|
1574
|
+
return [{ type: this.resolveBlockType(ut("paragraph")), segments: this.ensureSegments(this.parseInlineChildren(t2, [])) }];
|
|
1452
1575
|
case "BLOCKQUOTE":
|
|
1453
|
-
return this.parseBlockquote(
|
|
1576
|
+
return this.parseBlockquote(t2);
|
|
1454
1577
|
case "UL":
|
|
1455
|
-
return this.parseList(
|
|
1578
|
+
return this.parseList(t2, "bullet", 0);
|
|
1456
1579
|
case "OL":
|
|
1457
|
-
return this.parseList(
|
|
1580
|
+
return this.parseList(t2, "ordered", 0);
|
|
1458
1581
|
case "LI":
|
|
1459
|
-
return this.parseListItem(
|
|
1582
|
+
return this.parseListItem(t2, "bullet", 0);
|
|
1460
1583
|
case "HR":
|
|
1461
|
-
return [{ type: this.resolveBlockType(
|
|
1584
|
+
return [{ type: this.resolveBlockType(ut("horizontal_rule")), segments: [] }];
|
|
1462
1585
|
case "PRE":
|
|
1463
|
-
return [{ type: this.resolveBlockType(
|
|
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(
|
|
1591
|
+
return this.parseTableAsParagraphs(t2);
|
|
1469
1592
|
default: {
|
|
1470
|
-
const
|
|
1471
|
-
return
|
|
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(
|
|
1476
|
-
const
|
|
1477
|
-
return Array.from(
|
|
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(
|
|
1602
|
+
parseList(t2, e2, n2) {
|
|
1480
1603
|
const s2 = [];
|
|
1481
|
-
for (const
|
|
1482
|
-
const
|
|
1483
|
-
"LI" ===
|
|
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(
|
|
1488
|
-
const s2 = [],
|
|
1489
|
-
for (const
|
|
1490
|
-
const
|
|
1491
|
-
"UL" ===
|
|
1492
|
-
} else if (
|
|
1493
|
-
const
|
|
1494
|
-
|
|
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:
|
|
1497
|
-
for (const
|
|
1498
|
-
const
|
|
1499
|
-
s2.push(...this.parseList(
|
|
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(
|
|
1626
|
+
parseInlineChildren(t2, e2) {
|
|
1504
1627
|
const n2 = [];
|
|
1505
|
-
for (const s2 of Array.from(
|
|
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(
|
|
1509
|
-
if (
|
|
1510
|
-
const n3 =
|
|
1511
|
-
return n3 ? [{ text: n3, marks: this.resolveMarks(
|
|
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 (
|
|
1514
|
-
const n2 =
|
|
1515
|
-
if ("BR" === s2) return [{ text: "\n", marks: this.resolveMarks(
|
|
1516
|
-
if (this.isBlockElement(n2) && !
|
|
1517
|
-
const
|
|
1518
|
-
return this.parseInlineChildren(n2,
|
|
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(
|
|
1521
|
-
const
|
|
1522
|
-
return
|
|
1643
|
+
parsePreContent(t2) {
|
|
1644
|
+
const e2 = t2.textContent ?? "";
|
|
1645
|
+
return e2 ? [{ text: e2, marks: [] }] : [];
|
|
1523
1646
|
}
|
|
1524
|
-
parseTableAsParagraphs(
|
|
1525
|
-
const
|
|
1526
|
-
for (const
|
|
1527
|
-
const n3 = this.parseInlineChildren(
|
|
1528
|
-
n3.length > 0 && n3.some((
|
|
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
|
|
1653
|
+
return e2;
|
|
1531
1654
|
}
|
|
1532
|
-
marksFromElement(
|
|
1533
|
-
const
|
|
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
|
|
1537
|
-
const n3 =
|
|
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
|
-
|
|
1540
|
-
} else
|
|
1541
|
-
if (s3.size > 0) return
|
|
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 =
|
|
1544
|
-
if ("STRONG" !== s2 && "B" !== s2 ||
|
|
1545
|
-
const n3 =
|
|
1546
|
-
|
|
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
|
|
1671
|
+
return e2;
|
|
1549
1672
|
}
|
|
1550
|
-
mergeMarks(
|
|
1551
|
-
const n2 = [...
|
|
1552
|
-
for (const
|
|
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(
|
|
1556
|
-
return
|
|
1678
|
+
resolveMarks(t2) {
|
|
1679
|
+
return t2.filter((t3) => at(this.schema, t3.type));
|
|
1557
1680
|
}
|
|
1558
|
-
resolveBlockType(
|
|
1559
|
-
return
|
|
1681
|
+
resolveBlockType(t2) {
|
|
1682
|
+
return ct(this.schema, t2) ? t2 : ut("paragraph");
|
|
1560
1683
|
}
|
|
1561
|
-
normalizeSegments(
|
|
1562
|
-
if (0 ===
|
|
1563
|
-
const
|
|
1564
|
-
for (const n2 of
|
|
1565
|
-
const
|
|
1566
|
-
|
|
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
|
|
1691
|
+
return e2;
|
|
1569
1692
|
}
|
|
1570
|
-
ensureSegments(
|
|
1571
|
-
return 0 ===
|
|
1693
|
+
ensureSegments(t2) {
|
|
1694
|
+
return 0 === t2.length ? [{ text: "", marks: [] }] : t2;
|
|
1572
1695
|
}
|
|
1573
|
-
matchBlockRule(
|
|
1574
|
-
const
|
|
1575
|
-
for (const n2 of this.blockParseRules) if (n2.rule.tag ===
|
|
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
|
|
1578
|
-
if (false ===
|
|
1579
|
-
return { type:
|
|
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:
|
|
1704
|
+
return { type: ut(n2.type) };
|
|
1582
1705
|
}
|
|
1583
1706
|
return null;
|
|
1584
1707
|
}
|
|
1585
|
-
isBlockElement(
|
|
1586
|
-
if (
|
|
1587
|
-
const
|
|
1588
|
-
return this.blockParseRules.some((
|
|
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(
|
|
1591
|
-
return null !==
|
|
1713
|
+
hasCheckbox(t2) {
|
|
1714
|
+
return null !== t2.querySelector('input[type="checkbox"]');
|
|
1592
1715
|
}
|
|
1593
|
-
isCheckboxChecked(
|
|
1594
|
-
const
|
|
1595
|
-
return
|
|
1716
|
+
isCheckboxChecked(t2) {
|
|
1717
|
+
const e2 = t2.querySelector('input[type="checkbox"]');
|
|
1718
|
+
return e2?.hasAttribute("checked") ?? false;
|
|
1596
1719
|
}
|
|
1597
|
-
flushPendingSegments(
|
|
1598
|
-
const n2 = this.normalizeSegments(
|
|
1599
|
-
0 !== n2.length && (n2.every((
|
|
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
|
|
1603
|
-
constructor(
|
|
1604
|
-
this.element =
|
|
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(
|
|
1611
|
-
|
|
1612
|
-
const
|
|
1613
|
-
if (!
|
|
1614
|
-
const n2 =
|
|
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(
|
|
1617
|
-
const s2 =
|
|
1739
|
+
if (this.handleFilePaste(e2)) return;
|
|
1740
|
+
const s2 = e2.getData("text/plain");
|
|
1618
1741
|
if (s2) {
|
|
1619
|
-
const
|
|
1620
|
-
if (
|
|
1742
|
+
const t3 = (function(t4) {
|
|
1743
|
+
if (Gt && Gt.plainText === t4) return Gt.blocks;
|
|
1621
1744
|
})(s2);
|
|
1622
|
-
if (
|
|
1745
|
+
if (t3 && this.handleRichPaste(t3)) return;
|
|
1623
1746
|
}
|
|
1624
|
-
const
|
|
1747
|
+
const o2 = this.getState(), i3 = e2.getData("text/html");
|
|
1625
1748
|
if (i3) {
|
|
1626
|
-
const
|
|
1627
|
-
if (
|
|
1628
|
-
const
|
|
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
|
|
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(
|
|
1633
|
-
if (0 ===
|
|
1634
|
-
const n5 =
|
|
1635
|
-
return n5 ? 1 ===
|
|
1636
|
-
const n6 =
|
|
1637
|
-
if (
|
|
1638
|
-
const s4 =
|
|
1639
|
-
|
|
1640
|
-
const
|
|
1641
|
-
return s4.insertText(
|
|
1642
|
-
})(
|
|
1643
|
-
const n6 =
|
|
1644
|
-
if (
|
|
1645
|
-
const s4 =
|
|
1646
|
-
|
|
1647
|
-
const
|
|
1648
|
-
return s4.setBlockType(
|
|
1649
|
-
})(
|
|
1650
|
-
const n6 =
|
|
1651
|
-
if (
|
|
1652
|
-
const s4 =
|
|
1653
|
-
|
|
1654
|
-
const i5 =
|
|
1655
|
-
if (!l2 || !
|
|
1656
|
-
const
|
|
1657
|
-
l2.segments.length > 0 && u2 > 0 && s4.insertText(i5, a4,
|
|
1658
|
-
const p2 = a4 + u2,
|
|
1659
|
-
s4.splitBlock(i5, p2,
|
|
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
|
|
1662
|
-
const
|
|
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 =
|
|
1666
|
-
return
|
|
1667
|
-
})(
|
|
1668
|
-
})(
|
|
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
|
|
1672
|
-
if (
|
|
1673
|
-
const
|
|
1674
|
-
this.dispatch(
|
|
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
|
|
1681
|
-
this.dispatch(
|
|
1803
|
+
const t3 = G(this.getState(), s2, "paste");
|
|
1804
|
+
this.dispatch(t3);
|
|
1682
1805
|
}
|
|
1683
1806
|
}
|
|
1684
|
-
handleBlockPaste(
|
|
1685
|
-
let
|
|
1807
|
+
handleBlockPaste(t2) {
|
|
1808
|
+
let e2;
|
|
1686
1809
|
try {
|
|
1687
|
-
|
|
1810
|
+
e2 = JSON.parse(t2);
|
|
1688
1811
|
} catch {
|
|
1689
1812
|
return;
|
|
1690
1813
|
}
|
|
1691
|
-
const n2 =
|
|
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(),
|
|
1695
|
-
if (
|
|
1696
|
-
const
|
|
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(
|
|
1824
|
+
return n3.insertNode(t3, e3.children.length, d2), n3.setSelection(_(a4, [...t3, a4])), void this.dispatch(n3.build());
|
|
1702
1825
|
}
|
|
1703
|
-
const u2 =
|
|
1704
|
-
const
|
|
1705
|
-
return
|
|
1706
|
-
})()).findIndex((
|
|
1707
|
-
if (
|
|
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,
|
|
1832
|
+
g2.insertNode(p2, f2 + 1, d2), g2.setSelection(_(a4, [...p2, a4])), this.dispatch(g2.build());
|
|
1710
1833
|
}
|
|
1711
|
-
handleRichPasteFromJson(
|
|
1712
|
-
let
|
|
1834
|
+
handleRichPasteFromJson(t2) {
|
|
1835
|
+
let e2;
|
|
1713
1836
|
try {
|
|
1714
|
-
|
|
1837
|
+
e2 = JSON.parse(t2);
|
|
1715
1838
|
} catch {
|
|
1716
1839
|
return false;
|
|
1717
1840
|
}
|
|
1718
|
-
return !(!Array.isArray(
|
|
1841
|
+
return !(!Array.isArray(e2) || 0 === e2.length) && this.handleRichPaste(e2);
|
|
1719
1842
|
}
|
|
1720
|
-
handleRichPaste(
|
|
1721
|
-
if (0 ===
|
|
1722
|
-
if (!
|
|
1723
|
-
const
|
|
1724
|
-
return
|
|
1725
|
-
}
|
|
1726
|
-
insertRichBlocksIntoCell(
|
|
1727
|
-
const
|
|
1728
|
-
if (!
|
|
1729
|
-
const i3 =
|
|
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 =
|
|
1732
|
-
let
|
|
1733
|
-
const u2 =
|
|
1734
|
-
let p2,
|
|
1735
|
-
for (const
|
|
1736
|
-
if (!
|
|
1737
|
-
const
|
|
1738
|
-
u2.insertNode(
|
|
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
|
|
1863
|
+
return d2 && c3 >= 0 && u2.removeNode(o2, c3), p2 && u2.setSelection(O(p2, f2)), this.dispatch(u2.build()), true;
|
|
1741
1864
|
}
|
|
1742
|
-
insertRichBlocksAtRoot(
|
|
1743
|
-
const s2 =
|
|
1744
|
-
const
|
|
1745
|
-
return
|
|
1746
|
-
})()).findIndex((
|
|
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 =
|
|
1749
|
-
let
|
|
1750
|
-
const
|
|
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
|
|
1753
|
-
if (!
|
|
1754
|
-
const
|
|
1755
|
-
|
|
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 &&
|
|
1880
|
+
return c3 && h3.removeNode(o2, i3), u2 && h3.setSelection(O(u2, p2)), this.dispatch(h3.build()), true;
|
|
1758
1881
|
}
|
|
1759
|
-
findTableCellAncestor(
|
|
1760
|
-
const n2 =
|
|
1761
|
-
if ("table_cell" === n2?.type) return
|
|
1762
|
-
const s2 =
|
|
1763
|
-
if (s2) for (const
|
|
1764
|
-
const n3 =
|
|
1765
|
-
if ("table_cell" === n3?.type) return
|
|
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(
|
|
1891
|
+
handleFilePaste(t2) {
|
|
1769
1892
|
if (!this.schemaRegistry) return false;
|
|
1770
|
-
const
|
|
1771
|
-
if (0 ===
|
|
1772
|
-
const s2 =
|
|
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
|
|
1775
|
-
|
|
1897
|
+
const t3 = s2.getAsFile();
|
|
1898
|
+
t3 && e2.push(t3);
|
|
1776
1899
|
}
|
|
1777
1900
|
}
|
|
1778
|
-
if (0 ===
|
|
1779
|
-
for (const
|
|
1780
|
-
const n2 = this.schemaRegistry.matchFileHandlers(
|
|
1781
|
-
for (const
|
|
1782
|
-
const n3 =
|
|
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(
|
|
1790
|
-
const
|
|
1791
|
-
|
|
1792
|
-
const n2 =
|
|
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(
|
|
1796
|
-
const
|
|
1797
|
-
return
|
|
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
|
|
1804
|
-
const
|
|
1805
|
-
!(function(
|
|
1806
|
-
const
|
|
1807
|
-
for (const n3 of
|
|
1808
|
-
for (; n3.firstChild; )
|
|
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
|
-
})(
|
|
1934
|
+
})(t2);
|
|
1812
1935
|
const c3 = /* @__PURE__ */ new Map();
|
|
1813
|
-
for (const
|
|
1814
|
-
const
|
|
1815
|
-
n3 && c3.set(
|
|
1816
|
-
}
|
|
1817
|
-
const l2 = new Set(
|
|
1818
|
-
for (const [
|
|
1819
|
-
|
|
1820
|
-
const s3 = a4?.get(
|
|
1821
|
-
s3 && (s3.destroy?.(), a4?.delete(
|
|
1822
|
-
}
|
|
1823
|
-
const
|
|
1824
|
-
for (const
|
|
1825
|
-
let
|
|
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
|
|
1828
|
-
const n3 = c3.get(
|
|
1829
|
-
if (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
|
|
1832
|
-
if (
|
|
1833
|
-
if (
|
|
1834
|
-
if (
|
|
1835
|
-
|
|
1836
|
-
const
|
|
1837
|
-
|
|
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
|
-
|
|
1962
|
+
h3 = o4.dom;
|
|
1840
1963
|
continue;
|
|
1841
1964
|
}
|
|
1842
|
-
|
|
1965
|
+
o4.destroy?.(), a4?.delete(e3.id);
|
|
1843
1966
|
}
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1967
|
+
const r4 = Ne(e3, i3, a4, s2);
|
|
1968
|
+
t2.replaceChild(r4, n3), h3 = r4;
|
|
1846
1969
|
} else {
|
|
1847
|
-
const n4 =
|
|
1848
|
-
|
|
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 ===
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1973
|
+
if (u2 === e3.id) {
|
|
1974
|
+
const t3 = a4?.get(e3.id);
|
|
1975
|
+
if (t3) t3.selectNode?.();
|
|
1853
1976
|
else {
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1977
|
+
const t4 = c3.get(e3.id) ?? h3;
|
|
1978
|
+
t4 instanceof HTMLElement && t4.classList.add("notectl-node-selected");
|
|
1856
1979
|
}
|
|
1857
|
-
} else if (p2 ===
|
|
1858
|
-
const
|
|
1859
|
-
if (
|
|
1980
|
+
} else if (p2 === e3.id) {
|
|
1981
|
+
const t3 = a4?.get(e3.id);
|
|
1982
|
+
if (t3) t3.deselectNode?.();
|
|
1860
1983
|
else {
|
|
1861
|
-
const
|
|
1862
|
-
|
|
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
|
|
1868
|
-
|
|
1990
|
+
const t3 = a4?.get(p2);
|
|
1991
|
+
t3 && !l2.has(p2) && t3.deselectNode?.();
|
|
1869
1992
|
}
|
|
1870
1993
|
if (u2 && !l2.has(u2)) {
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
}
|
|
1876
|
-
function
|
|
1877
|
-
if (
|
|
1878
|
-
if (
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1881
|
-
if (!
|
|
1882
|
-
const
|
|
1883
|
-
if (
|
|
1884
|
-
for (const
|
|
1885
|
-
}
|
|
1886
|
-
for (let n3 = 0; n3 <
|
|
1887
|
-
const s3 =
|
|
1888
|
-
if (!s3 || !
|
|
1889
|
-
if (m(s3) && m(
|
|
1890
|
-
if (s3.text !==
|
|
1891
|
-
if (!
|
|
1892
|
-
} else if (d(s3) && d(
|
|
1893
|
-
if (s3.inlineType !==
|
|
1894
|
-
if (!
|
|
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(
|
|
1897
|
-
if (
|
|
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 && !
|
|
1902
|
-
}
|
|
1903
|
-
function
|
|
1904
|
-
const
|
|
1905
|
-
if (
|
|
1906
|
-
const
|
|
1907
|
-
if (
|
|
1908
|
-
const i3 =
|
|
1909
|
-
n2.set(
|
|
1910
|
-
const a4 =
|
|
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"),
|
|
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
|
|
1914
|
-
for (const
|
|
1915
|
-
const
|
|
1916
|
-
if (
|
|
1917
|
-
const i4 =
|
|
1918
|
-
|
|
1919
|
-
let a5 =
|
|
1920
|
-
a5 || (a5 = [],
|
|
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 [
|
|
2046
|
+
for (const [t3, n3] of r3) _e(t3, n3, e2);
|
|
1924
2047
|
}
|
|
1925
|
-
return
|
|
2048
|
+
return i3.dom.setAttribute("data-block-type", t2.type), De(i3.dom, t2.id, s2), i3.dom;
|
|
1926
2049
|
}
|
|
1927
2050
|
}
|
|
1928
|
-
if (
|
|
1929
|
-
const
|
|
1930
|
-
if (
|
|
1931
|
-
const i3 =
|
|
1932
|
-
if (
|
|
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
|
|
1935
|
-
for (const
|
|
1936
|
-
const
|
|
1937
|
-
i3.appendChild(
|
|
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
|
-
|
|
2062
|
+
_e(i3, o3, e2);
|
|
1940
2063
|
}
|
|
1941
|
-
return
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
return (function(
|
|
1945
|
-
const s3 =
|
|
1946
|
-
return
|
|
1947
|
-
})(
|
|
1948
|
-
}
|
|
1949
|
-
function
|
|
1950
|
-
const
|
|
1951
|
-
if (1 ===
|
|
1952
|
-
if (
|
|
1953
|
-
let
|
|
1954
|
-
for (const
|
|
1955
|
-
if (d(
|
|
1956
|
-
|
|
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
|
|
1960
|
-
if (0 ===
|
|
1961
|
-
|
|
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(
|
|
1966
|
-
for (const
|
|
1967
|
-
const n4 = Math.max(
|
|
1968
|
-
n4 >
|
|
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((
|
|
1971
|
-
for (let
|
|
1972
|
-
const i5 = c3[
|
|
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 -
|
|
1975
|
-
for (const
|
|
1976
|
-
let p2 = document.createTextNode(
|
|
1977
|
-
if (
|
|
1978
|
-
const
|
|
1979
|
-
for (let
|
|
1980
|
-
const n4 =
|
|
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
|
|
1983
|
-
|
|
2105
|
+
const o5 = Pe(n4, s3);
|
|
2106
|
+
o5.appendChild(p2), p2 = o5;
|
|
1984
2107
|
}
|
|
1985
2108
|
}
|
|
1986
|
-
for (const
|
|
1987
|
-
const
|
|
1988
|
-
|
|
2109
|
+
for (const t4 of u2) {
|
|
2110
|
+
const e4 = Le(t4.attrs);
|
|
2111
|
+
e4.appendChild(p2), p2 = e4;
|
|
1989
2112
|
}
|
|
1990
|
-
|
|
2113
|
+
t3.appendChild(p2);
|
|
1991
2114
|
}
|
|
1992
|
-
|
|
2115
|
+
o3 = i4;
|
|
1993
2116
|
}
|
|
1994
|
-
})(t2,
|
|
1995
|
-
else for (const e2 of
|
|
1996
|
-
const i3 =
|
|
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
|
|
2000
|
-
let
|
|
2001
|
-
return
|
|
2002
|
-
}
|
|
2003
|
-
function
|
|
2004
|
-
if ("" ===
|
|
2005
|
-
const n2 = document.createTextNode(
|
|
2006
|
-
if (0 ===
|
|
2007
|
-
const s2 = [...
|
|
2008
|
-
let
|
|
2009
|
-
for (let
|
|
2010
|
-
const n3 = s2[
|
|
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
|
|
2013
|
-
|
|
2135
|
+
const r2 = Pe(n3, e2);
|
|
2136
|
+
r2.appendChild(o2), o2 = r2;
|
|
2014
2137
|
}
|
|
2015
|
-
return
|
|
2138
|
+
return o2;
|
|
2016
2139
|
}
|
|
2017
|
-
function
|
|
2018
|
-
if (
|
|
2019
|
-
const n3 =
|
|
2140
|
+
function Be(t2, e2) {
|
|
2141
|
+
if (e2) {
|
|
2142
|
+
const n3 = e2.getInlineNodeSpec(t2.inlineType);
|
|
2020
2143
|
if (n3) {
|
|
2021
|
-
const
|
|
2022
|
-
return
|
|
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",
|
|
2149
|
+
return n2.setAttribute("data-inline-type", t2.inlineType), n2.setAttribute("contenteditable", "false"), n2;
|
|
2027
2150
|
}
|
|
2028
|
-
function
|
|
2029
|
-
const n2 = Object.keys(
|
|
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 (
|
|
2154
|
+
for (const s3 of n2) if (t2[s3] !== e2[s3]) return false;
|
|
2032
2155
|
return true;
|
|
2033
2156
|
}
|
|
2034
|
-
function
|
|
2035
|
-
if (
|
|
2036
|
-
const n2 =
|
|
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 (
|
|
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
|
|
2051
|
-
if (
|
|
2052
|
-
const n2 =
|
|
2053
|
-
if (n2) return n2.toDOM(
|
|
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 (
|
|
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
|
|
2067
|
-
const
|
|
2068
|
-
if (n2.setAttribute("data-decoration", "true"),
|
|
2069
|
-
|
|
2070
|
-
for (const [
|
|
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
|
|
2074
|
-
const s2 = n2?.decorations?.findNode(
|
|
2075
|
-
if (s2 && 0 !== s2.length) for (const
|
|
2076
|
-
if (
|
|
2077
|
-
if (
|
|
2078
|
-
const n3 =
|
|
2079
|
-
|
|
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
|
|
2206
|
+
function _e(t2, e2, n2) {
|
|
2084
2207
|
if (!n2) return;
|
|
2085
2208
|
const s2 = [];
|
|
2086
|
-
let
|
|
2087
|
-
for (const
|
|
2088
|
-
const
|
|
2089
|
-
i3 &&
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
for (const
|
|
2093
|
-
const n3 =
|
|
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(
|
|
2096
|
-
if (s3.setAttribute("data-block-wrapper",
|
|
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
|
|
2099
|
-
const
|
|
2100
|
-
|
|
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
|
|
2105
|
-
const
|
|
2106
|
-
return
|
|
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
|
|
2109
|
-
const n2 =
|
|
2231
|
+
function He(t2, e2) {
|
|
2232
|
+
const n2 = Oe(t2);
|
|
2110
2233
|
if (!n2) return;
|
|
2111
|
-
if (
|
|
2112
|
-
const s3 =
|
|
2234
|
+
if (H(e2)) {
|
|
2235
|
+
const s3 = t2.querySelector(`[data-block-id="${e2.nodeId}"]`);
|
|
2113
2236
|
if (!s3) return;
|
|
2114
|
-
const
|
|
2115
|
-
if (!
|
|
2116
|
-
const
|
|
2237
|
+
const o3 = s3.parentNode;
|
|
2238
|
+
if (!o3) return;
|
|
2239
|
+
const r2 = Fe(o3, s3);
|
|
2117
2240
|
try {
|
|
2118
|
-
n2.setBaseAndExtent(
|
|
2241
|
+
n2.setBaseAndExtent(o3, r2, o3, r2 + 1);
|
|
2119
2242
|
} catch {
|
|
2120
2243
|
}
|
|
2121
2244
|
return;
|
|
2122
2245
|
}
|
|
2123
|
-
const s2 =
|
|
2124
|
-
if (s2 &&
|
|
2125
|
-
n2.setBaseAndExtent(s2.node, s2.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
|
|
2252
|
+
function $e(t2, e2) {
|
|
2130
2253
|
let n2 = null;
|
|
2131
|
-
if (
|
|
2132
|
-
let s3 =
|
|
2133
|
-
for (const
|
|
2134
|
-
const
|
|
2135
|
-
if (!
|
|
2136
|
-
s3 =
|
|
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 !==
|
|
2261
|
+
s3 !== t2 && s3.getAttribute("data-block-id") === e2.blockId && (n2 = s3);
|
|
2139
2262
|
}
|
|
2140
|
-
if (n2 ??=
|
|
2141
|
-
const s2 =
|
|
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
|
|
2144
|
-
const
|
|
2145
|
-
let i3 =
|
|
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
|
|
2149
|
-
if (
|
|
2150
|
-
|
|
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 ===
|
|
2153
|
-
const
|
|
2154
|
-
if (
|
|
2275
|
+
if (0 === o2) {
|
|
2276
|
+
const t3 = i3.parentNode;
|
|
2277
|
+
if (t3) return { node: t3, offset: Fe(t3, i3) };
|
|
2155
2278
|
}
|
|
2156
|
-
|
|
2279
|
+
o2 -= 1;
|
|
2157
2280
|
}
|
|
2158
|
-
i3 =
|
|
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
|
|
2164
|
-
const s2 = (function(
|
|
2165
|
-
let n3 =
|
|
2166
|
-
for (; n3 && n3 !==
|
|
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
|
-
})(
|
|
2294
|
+
})(t2, e2);
|
|
2172
2295
|
if (!s2) return null;
|
|
2173
|
-
const
|
|
2174
|
-
if (!
|
|
2175
|
-
const
|
|
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 =
|
|
2178
|
-
for (; s3 && s3 !==
|
|
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
|
-
})(
|
|
2181
|
-
if (
|
|
2182
|
-
const
|
|
2183
|
-
let
|
|
2184
|
-
for (const
|
|
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
|
-
|
|
2309
|
+
o3 += Ke(e3), c4++;
|
|
2187
2310
|
}
|
|
2188
|
-
return
|
|
2311
|
+
return j(r2, o3, i3.length > 1 ? i3 : void 0);
|
|
2189
2312
|
}
|
|
2190
|
-
if (a4 !== s2 && !a4.contains(
|
|
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 =
|
|
2193
|
-
let
|
|
2194
|
-
for (;
|
|
2195
|
-
if (
|
|
2196
|
-
|
|
2197
|
-
}
|
|
2198
|
-
if (
|
|
2199
|
-
let
|
|
2200
|
-
for (const
|
|
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
|
-
|
|
2325
|
+
t3 += Ke(o3), s3++;
|
|
2203
2326
|
}
|
|
2204
|
-
return
|
|
2327
|
+
return j(r2, t3, i3.length > 1 ? i3 : void 0);
|
|
2205
2328
|
}
|
|
2206
|
-
return
|
|
2329
|
+
return j(r2, 0, i3.length > 1 ? i3 : void 0);
|
|
2207
2330
|
}
|
|
2208
|
-
function
|
|
2209
|
-
return document.createTreeWalker(
|
|
2210
|
-
let n2 =
|
|
2211
|
-
for (; n2 && n2 !==
|
|
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
|
-
})(
|
|
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
|
|
2341
|
+
function Fe(t2, e2) {
|
|
2219
2342
|
let n2 = 0;
|
|
2220
|
-
for (const s2 of Array.from(
|
|
2221
|
-
if (s2 ===
|
|
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
|
|
2227
|
-
return
|
|
2349
|
+
function Ue(t2) {
|
|
2350
|
+
return t2.querySelector("[data-content-dom]") ?? t2;
|
|
2228
2351
|
}
|
|
2229
|
-
function
|
|
2230
|
-
if (
|
|
2231
|
-
if (
|
|
2232
|
-
let
|
|
2233
|
-
for (const n2 of Array.from(
|
|
2234
|
-
return
|
|
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
|
|
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 =
|
|
2376
|
+
decorations = wt.empty;
|
|
2254
2377
|
getDecorations;
|
|
2255
|
-
constructor(
|
|
2256
|
-
this.state =
|
|
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(
|
|
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 =
|
|
2267
|
-
const
|
|
2268
|
-
this.decorations =
|
|
2269
|
-
for (const n3 of this.stateChangeCallbacks) n3(s2,
|
|
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(
|
|
2276
|
-
const
|
|
2277
|
-
this.applyUpdate(
|
|
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
|
|
2282
|
-
|
|
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
|
|
2287
|
-
|
|
2409
|
+
const t2 = this.history.redo(this.state);
|
|
2410
|
+
t2 && this.applyUpdate(t2.state, t2.transaction);
|
|
2288
2411
|
}
|
|
2289
|
-
onStateChange(
|
|
2290
|
-
return this.stateChangeCallbacks.push(
|
|
2291
|
-
const
|
|
2292
|
-
-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(
|
|
2418
|
+
replaceState(t2) {
|
|
2296
2419
|
if (!this.isUpdating) {
|
|
2297
2420
|
this.isUpdating = true;
|
|
2298
2421
|
try {
|
|
2299
|
-
const
|
|
2300
|
-
this.state =
|
|
2301
|
-
const n2 = this.decorations, s2 = this.getDecorations?.(
|
|
2302
|
-
this.decorations = s2,
|
|
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 (
|
|
2432
|
+
if (H(this.state.selection) && !this.pendingNodeSelectionClear) return;
|
|
2310
2433
|
this.pendingNodeSelectionClear = false;
|
|
2311
|
-
const
|
|
2312
|
-
const
|
|
2313
|
-
if (!
|
|
2314
|
-
const n3 =
|
|
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 (!
|
|
2317
|
-
const
|
|
2318
|
-
return
|
|
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 (!
|
|
2321
|
-
if (
|
|
2322
|
-
const
|
|
2323
|
-
this.applyUpdate(n2,
|
|
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(
|
|
2448
|
+
onMousedown(t2) {
|
|
2326
2449
|
if (this.isUpdating) return;
|
|
2327
|
-
const
|
|
2328
|
-
if (!(
|
|
2329
|
-
const n2 =
|
|
2330
|
-
if (!(n2 instanceof HTMLElement && this.contentElement.contains(n2))) return void ((this.contentElement.contains(
|
|
2331
|
-
if (!n2.hasAttribute("data-void") && !n2.hasAttribute("data-selectable")) return void (
|
|
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(
|
|
2334
|
-
|
|
2335
|
-
const
|
|
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(
|
|
2339
|
-
const
|
|
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
|
|
2344
|
-
if (
|
|
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 ===
|
|
2347
|
-
const
|
|
2348
|
-
return this.dispatch(
|
|
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
|
-
|
|
2351
|
-
const a4 =
|
|
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(
|
|
2355
|
-
const
|
|
2356
|
-
let n2 =
|
|
2357
|
-
for (; n2 && n2 !== this.contentElement; ) n2.hasAttribute("data-block-id") &&
|
|
2358
|
-
return
|
|
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(
|
|
2361
|
-
this.schemaRegistry &&
|
|
2483
|
+
onDragover(t2) {
|
|
2484
|
+
this.schemaRegistry && t2.dataTransfer && t2.dataTransfer.types.includes("Files") && t2.preventDefault();
|
|
2362
2485
|
}
|
|
2363
|
-
onDrop(
|
|
2486
|
+
onDrop(t2) {
|
|
2364
2487
|
if (!this.schemaRegistry) return;
|
|
2365
|
-
if (!
|
|
2366
|
-
const
|
|
2367
|
-
if (0 ===
|
|
2368
|
-
const n2 = this.getPositionFromPoint(
|
|
2369
|
-
for (const s2 of
|
|
2370
|
-
const
|
|
2371
|
-
for (const s3 of
|
|
2372
|
-
const
|
|
2373
|
-
if (true ===
|
|
2374
|
-
if (
|
|
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(
|
|
2501
|
+
getPositionFromPoint(t2, e2) {
|
|
2379
2502
|
const n2 = this.contentElement.getRootNode();
|
|
2380
|
-
let s2 = null,
|
|
2503
|
+
let s2 = null, o2 = 0;
|
|
2381
2504
|
if ("caretPositionFromPoint" in n2) {
|
|
2382
|
-
const
|
|
2383
|
-
|
|
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
|
|
2387
|
-
|
|
2509
|
+
const r2 = n2.caretRangeFromPoint(t2, e2);
|
|
2510
|
+
r2 && (s2 = r2.startContainer, o2 = r2.startOffset);
|
|
2388
2511
|
}
|
|
2389
|
-
return s2 && this.contentElement.contains(s2) ?
|
|
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
|
|
2394
|
-
(this.contentElement.contains(
|
|
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(
|
|
2397
|
-
const
|
|
2398
|
-
return { registry: this.schemaRegistry, nodeViews: this.nodeViews, getState: () => this.state, dispatch: (
|
|
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
|
|
2525
|
+
for (const t2 of this.nodeViews.values()) t2.destroy?.();
|
|
2403
2526
|
this.nodeViews.clear();
|
|
2404
2527
|
}
|
|
2405
2528
|
}
|
|
2406
|
-
const
|
|
2407
|
-
function
|
|
2408
|
-
return "heading" ===
|
|
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
|
|
2533
|
+
function Xe(t2, e2) {
|
|
2411
2534
|
const n2 = [];
|
|
2412
|
-
return
|
|
2413
|
-
}
|
|
2414
|
-
function
|
|
2415
|
-
if (
|
|
2416
|
-
const s3 =
|
|
2417
|
-
return void (s3 && n2.push(g(s3, [...
|
|
2418
|
-
}
|
|
2419
|
-
if (
|
|
2420
|
-
const
|
|
2421
|
-
for (const
|
|
2422
|
-
const
|
|
2423
|
-
if (false ===
|
|
2424
|
-
i3.some((
|
|
2425
|
-
} else i3.some((
|
|
2426
|
-
for (const
|
|
2427
|
-
}
|
|
2428
|
-
function
|
|
2429
|
-
const n2 =
|
|
2430
|
-
for (const s2 of
|
|
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
|
|
2433
|
-
if (false ===
|
|
2434
|
-
return { type: s2.type, attrs:
|
|
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
|
|
2563
|
+
function Ge(t2, n2) {
|
|
2441
2564
|
const s2 = (function(t3, n3) {
|
|
2442
|
-
const s3 = e(t3),
|
|
2443
|
-
for (const
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2446
|
-
} else
|
|
2447
|
-
return
|
|
2448
|
-
})(t2, n2),
|
|
2449
|
-
let
|
|
2450
|
-
|
|
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 && (
|
|
2453
|
-
}
|
|
2454
|
-
function
|
|
2455
|
-
if ("" ===
|
|
2456
|
-
let n2 =
|
|
2457
|
-
const s2 = (function(
|
|
2458
|
-
if (!
|
|
2459
|
-
const
|
|
2460
|
-
for (const s3 of
|
|
2461
|
-
const
|
|
2462
|
-
|
|
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
|
-
})(
|
|
2466
|
-
for (const
|
|
2467
|
-
const s3 =
|
|
2468
|
-
s3?.toHTMLString && (n2 = s3.toHTMLString(
|
|
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
|
|
2473
|
-
let
|
|
2474
|
-
class
|
|
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(
|
|
2481
|
-
this.shadow =
|
|
2603
|
+
constructor(t2) {
|
|
2604
|
+
this.shadow = t2;
|
|
2482
2605
|
}
|
|
2483
|
-
apply(
|
|
2484
|
-
if (this.cleanupSystemThemeListener(),
|
|
2606
|
+
apply(t2) {
|
|
2607
|
+
if (this.cleanupSystemThemeListener(), t2 === ae.System) {
|
|
2485
2608
|
this.setupSystemThemeListener();
|
|
2486
|
-
const
|
|
2487
|
-
this.setThemeStyleSheet(
|
|
2488
|
-
} else this.setThemeStyleSheet(
|
|
2609
|
+
const t3 = he(this.getSystemTheme());
|
|
2610
|
+
this.setThemeStyleSheet(t3);
|
|
2611
|
+
} else this.setThemeStyleSheet(he(t2));
|
|
2489
2612
|
}
|
|
2490
|
-
setPluginStyleSheets(
|
|
2491
|
-
this.pluginSheets =
|
|
2613
|
+
setPluginStyleSheets(t2) {
|
|
2614
|
+
this.pluginSheets = t2, this.refreshAdoptedStyleSheets();
|
|
2492
2615
|
}
|
|
2493
2616
|
destroy() {
|
|
2494
2617
|
this.cleanupSystemThemeListener();
|
|
2495
2618
|
}
|
|
2496
|
-
setThemeStyleSheet(
|
|
2497
|
-
this.themeStyleSheet.replaceSync(
|
|
2619
|
+
setThemeStyleSheet(t2) {
|
|
2620
|
+
this.themeStyleSheet.replaceSync(ge(t2)), this.refreshAdoptedStyleSheets();
|
|
2498
2621
|
}
|
|
2499
2622
|
refreshAdoptedStyleSheets() {
|
|
2500
|
-
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (
|
|
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 = (
|
|
2504
|
-
const
|
|
2505
|
-
this.setThemeStyleSheet(
|
|
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 ?
|
|
2635
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? ae.Dark : ae.Light;
|
|
2513
2636
|
}
|
|
2514
2637
|
}
|
|
2515
|
-
class
|
|
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((
|
|
2532
|
-
this.readyPromiseResolve =
|
|
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(
|
|
2545
|
-
if ("placeholder" ===
|
|
2546
|
-
const
|
|
2547
|
-
this.contentElement.contentEditable =
|
|
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" ===
|
|
2672
|
+
"theme" === t2 && this.themeController && this.themeController.apply(n2 ?? ae.Light);
|
|
2550
2673
|
}
|
|
2551
|
-
registerPlugin(
|
|
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(
|
|
2676
|
+
this.preInitPlugins.push(t2);
|
|
2554
2677
|
}
|
|
2555
|
-
async init(
|
|
2678
|
+
async init(t2) {
|
|
2556
2679
|
if (this.initialized) return;
|
|
2557
|
-
this.initialized = true,
|
|
2558
|
-
const
|
|
2559
|
-
if (!
|
|
2560
|
-
this.themeController = new
|
|
2561
|
-
const n2 = (function(
|
|
2562
|
-
const
|
|
2563
|
-
|
|
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 =
|
|
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
|
-
|
|
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,
|
|
2574
|
-
for (const
|
|
2575
|
-
for (const
|
|
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,
|
|
2578
|
-
if (!(s2 &&
|
|
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
|
|
2703
|
+
await o2.init({ getState: () => {
|
|
2581
2704
|
if (!this.view) throw new Error("View not initialized");
|
|
2582
2705
|
return this.view.getState();
|
|
2583
|
-
}, dispatch: (
|
|
2584
|
-
a4 && (a4.textContent =
|
|
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
|
|
2587
|
-
this.view = new
|
|
2588
|
-
this.onStateChange(
|
|
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 =
|
|
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(
|
|
2599
|
-
const
|
|
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(
|
|
2727
|
+
return (function(t2, e2) {
|
|
2605
2728
|
const n2 = [];
|
|
2606
2729
|
let s2 = null;
|
|
2607
|
-
for (const
|
|
2608
|
-
const
|
|
2609
|
-
s2 !==
|
|
2610
|
-
} else s2 && (n2.push(`</${s2}>`), s2 = null), n2.push(
|
|
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
|
|
2613
|
-
return
|
|
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(
|
|
2617
|
-
const
|
|
2618
|
-
const n2 =
|
|
2619
|
-
|
|
2620
|
-
const i3 =
|
|
2621
|
-
for (const
|
|
2622
|
-
const n3 =
|
|
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
|
|
2747
|
+
const t5 = "ol" === s3 ? "ordered" : "bullet";
|
|
2625
2748
|
for (const s4 of Array.from(n3.querySelectorAll("li"))) {
|
|
2626
|
-
const n4 =
|
|
2627
|
-
c3.push(
|
|
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
|
|
2632
|
-
if (
|
|
2633
|
-
const
|
|
2634
|
-
c3.push(
|
|
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 =
|
|
2638
|
-
c3.push(
|
|
2639
|
-
} else
|
|
2640
|
-
return 0 === c3.length ?
|
|
2641
|
-
})(
|
|
2642
|
-
this.setJSON(
|
|
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((
|
|
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
|
|
2651
|
-
if (0 ===
|
|
2652
|
-
if (
|
|
2653
|
-
const
|
|
2654
|
-
return !
|
|
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
|
|
2659
|
-
this.dispatch(
|
|
2781
|
+
const t2 = W(this.view.getState());
|
|
2782
|
+
this.dispatch(t2);
|
|
2660
2783
|
} };
|
|
2661
2784
|
can() {
|
|
2662
|
-
const
|
|
2663
|
-
return { toggleBold: () => !!
|
|
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
|
-
|
|
2666
|
-
return this.pluginManager?.
|
|
2794
|
+
getService(t2) {
|
|
2795
|
+
return this.pluginManager?.getService(t2);
|
|
2667
2796
|
}
|
|
2668
|
-
|
|
2669
|
-
this.pluginManager?.
|
|
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(
|
|
2676
|
-
this.view && this.pluginManager && this.pluginManager.dispatchWithMiddleware(
|
|
2805
|
+
dispatch(t2) {
|
|
2806
|
+
this.view && this.pluginManager && this.pluginManager.dispatchWithMiddleware(t2, this.view.getState(), (t3) => this.view?.dispatch(t3));
|
|
2677
2807
|
}
|
|
2678
|
-
on(
|
|
2679
|
-
this.eventListeners.has(
|
|
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(
|
|
2682
|
-
this.eventListeners.get(
|
|
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(
|
|
2688
|
-
void 0 !==
|
|
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(
|
|
2691
|
-
this.config = { ...this.config, theme:
|
|
2820
|
+
setTheme(t2) {
|
|
2821
|
+
this.config = { ...this.config, theme: t2 }, this.themeController?.apply(t2);
|
|
2692
2822
|
}
|
|
2693
2823
|
getTheme() {
|
|
2694
|
-
return this.config.theme ??
|
|
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
|
|
2699
|
-
return this.view = null, this.pluginManager = null, this.initialized = false,
|
|
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
|
|
2704
|
-
for (const
|
|
2833
|
+
const t2 = [];
|
|
2834
|
+
for (const e3 of this.config.toolbar) {
|
|
2705
2835
|
const n2 = [];
|
|
2706
|
-
for (const
|
|
2707
|
-
|
|
2836
|
+
for (const t3 of e3) n2.push(t3.id), this.pluginManager.register(t3);
|
|
2837
|
+
t2.push(n2);
|
|
2708
2838
|
}
|
|
2709
|
-
const
|
|
2710
|
-
this.pluginManager.register(new
|
|
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
|
|
2716
|
-
this.pluginManager.register(new
|
|
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(
|
|
2719
|
-
const n2 = this.eventListeners.get(
|
|
2720
|
-
if (n2) for (const
|
|
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(
|
|
2723
|
-
if (this.announcer && (this.announcer.textContent = ""), this.pluginManager?.notifyStateChange(
|
|
2724
|
-
const s2 = (function(
|
|
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
|
|
2728
|
-
for (const n4 of
|
|
2729
|
-
const s3 =
|
|
2730
|
-
if (
|
|
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
|
-
})(
|
|
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(
|
|
2741
|
-
this.view && (this.view.replaceState(
|
|
2870
|
+
replaceState(t2) {
|
|
2871
|
+
this.view && (this.view.replaceState(t2), this.updateEmptyState());
|
|
2742
2872
|
}
|
|
2743
2873
|
}
|
|
2744
|
-
async function
|
|
2745
|
-
const
|
|
2746
|
-
return await
|
|
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",
|
|
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
|
-
|
|
2886
|
+
Yt as ClipboardHandler,
|
|
2755
2887
|
a2 as CodeBlockPlugin,
|
|
2756
|
-
|
|
2888
|
+
le as DARK_THEME,
|
|
2757
2889
|
DEFAULT_IMAGE_KEYMAP,
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
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
|
-
|
|
2899
|
+
Xt as HistoryManager,
|
|
2768
2900
|
HorizontalRulePlugin,
|
|
2769
2901
|
IMAGE_UPLOAD_SERVICE,
|
|
2770
2902
|
ImagePlugin,
|
|
2771
|
-
|
|
2903
|
+
ce as LIGHT_THEME,
|
|
2772
2904
|
LinkPlugin,
|
|
2773
2905
|
ListPlugin,
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
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
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2918
|
+
Nt as TextFormattingPlugin,
|
|
2919
|
+
ae as ThemePreset,
|
|
2920
|
+
Et as ToolbarPlugin,
|
|
2787
2921
|
a3 as ToolbarServiceKey,
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2922
|
+
Vt as TransactionBuilder,
|
|
2923
|
+
Pt as applyStep,
|
|
2924
|
+
ht as blockId,
|
|
2925
|
+
Bt as canContain,
|
|
2792
2926
|
c as commandName,
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
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
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2933
|
+
_ as createNodeSelection,
|
|
2934
|
+
j as createPosition,
|
|
2935
|
+
$ as createSelection,
|
|
2802
2936
|
g as createTextNode,
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
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
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
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
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2962
|
+
rt as insertHardBreakCommand,
|
|
2963
|
+
G as insertTextCommand,
|
|
2964
|
+
Ut as invertStep,
|
|
2965
|
+
Kt as invertTransaction,
|
|
2832
2966
|
l as isBlockNode,
|
|
2833
|
-
|
|
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
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2973
|
+
R as isLeafBlock,
|
|
2974
|
+
dt as isMarkActive,
|
|
2975
|
+
at as isMarkAllowed,
|
|
2842
2976
|
b as isMarkOfType,
|
|
2843
|
-
|
|
2844
|
-
|
|
2977
|
+
ft as isNodeOfType,
|
|
2978
|
+
H as isNodeSelection,
|
|
2845
2979
|
m as isTextNode,
|
|
2846
|
-
|
|
2980
|
+
F as isTextSelection,
|
|
2847
2981
|
v2 as isVoidBlock,
|
|
2848
|
-
|
|
2849
|
-
|
|
2982
|
+
L as markSetsEqual,
|
|
2983
|
+
pt as markType,
|
|
2850
2984
|
w as mergeBlockBackward,
|
|
2851
|
-
|
|
2985
|
+
X as navigateArrowIntoVoid,
|
|
2852
2986
|
n as nodeDecoration,
|
|
2853
|
-
|
|
2854
|
-
|
|
2987
|
+
ut as nodeType,
|
|
2988
|
+
Qt as normalizeKeyDescriptor,
|
|
2855
2989
|
p as pluginId,
|
|
2856
|
-
|
|
2857
|
-
|
|
2990
|
+
Rt as registerBuiltinSpecs,
|
|
2991
|
+
kt as resolveNodeByPath,
|
|
2858
2992
|
c2 as resolveParentByPath,
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3004
|
+
At as validateContent,
|
|
2871
3005
|
w2 as walkNodes,
|
|
2872
3006
|
w3 as widgetDecoration
|
|
2873
3007
|
};
|