@notectl/core 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{index-CPjf45-o.mjs → index-B-NSeaM4.mjs} +4 -4
- package/dist/chunks/{index-CPjf45-o.mjs.map → index-B-NSeaM4.mjs.map} +1 -1
- package/dist/chunks/{index-DRZwd-1W.mjs → index-B9GkDVsx.mjs} +4 -4
- package/dist/chunks/{index-DRZwd-1W.mjs.map → index-B9GkDVsx.mjs.map} +1 -1
- package/dist/chunks/{index-D67mP19g.mjs → index-C0cEs7Jc.mjs} +4 -4
- package/dist/chunks/{index-D67mP19g.mjs.map → index-C0cEs7Jc.mjs.map} +1 -1
- package/dist/chunks/{index-BDMP86F4.mjs → index-C9gc3Bws.mjs} +4 -4
- package/dist/chunks/{index-BDMP86F4.mjs.map → index-C9gc3Bws.mjs.map} +1 -1
- package/dist/chunks/{index-CPyHuEzh.mjs → index-CAV2N-fF.mjs} +5 -5
- package/dist/chunks/{index-CPyHuEzh.mjs.map → index-CAV2N-fF.mjs.map} +1 -1
- package/dist/chunks/{index-DUC1X43Z.mjs → index-CKPrAOr6.mjs} +4 -4
- package/dist/chunks/{index-DUC1X43Z.mjs.map → index-CKPrAOr6.mjs.map} +1 -1
- package/dist/chunks/{index-BWXkaC2Z.mjs → index-CNs4QQ8l.mjs} +4 -4
- package/dist/chunks/{index-BWXkaC2Z.mjs.map → index-CNs4QQ8l.mjs.map} +1 -1
- package/dist/chunks/{index-DIAXWwgJ.mjs → index-CflvcXSd.mjs} +4 -4
- package/dist/chunks/{index-DIAXWwgJ.mjs.map → index-CflvcXSd.mjs.map} +1 -1
- package/dist/chunks/{index-83QoUENW.mjs → index-CoeD4T9-.mjs} +4 -4
- package/dist/chunks/{index-83QoUENW.mjs.map → index-CoeD4T9-.mjs.map} +1 -1
- package/dist/chunks/{index-tBDVaSjG.mjs → index-D0s0Q8Wc.mjs} +4 -4
- package/dist/chunks/{index-tBDVaSjG.mjs.map → index-D0s0Q8Wc.mjs.map} +1 -1
- package/dist/chunks/{index-B0UFAfyb.mjs → index-DMt3ojrY.mjs} +4 -4
- package/dist/chunks/{index-B0UFAfyb.mjs.map → index-DMt3ojrY.mjs.map} +1 -1
- package/dist/chunks/{index-DipAT_Q9.mjs → index-DfzCof6H.mjs} +4 -4
- package/dist/chunks/{index-DipAT_Q9.mjs.map → index-DfzCof6H.mjs.map} +1 -1
- package/dist/chunks/{index-D4GKlc-A.mjs → index-DyIwN_67.mjs} +5 -5
- package/dist/chunks/{index-D4GKlc-A.mjs.map → index-DyIwN_67.mjs.map} +1 -1
- package/dist/chunks/{index-DQryjfJs.mjs → index-FlTg80Pk.mjs} +11 -11
- package/dist/chunks/{index-DQryjfJs.mjs.map → index-FlTg80Pk.mjs.map} +1 -1
- package/dist/chunks/{index-BigJ0z6n.mjs → index-pxbbDHVH.mjs} +6 -6
- package/dist/chunks/{index-BigJ0z6n.mjs.map → index-pxbbDHVH.mjs.map} +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/notectl-core.mjs +813 -790
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +4685 -4652
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/alignment.mjs +3 -3
- package/dist/plugins/blockquote.mjs +2 -2
- package/dist/plugins/code-block.mjs +3 -3
- package/dist/plugins/font-size.mjs +2 -2
- package/dist/plugins/font.mjs +2 -2
- package/dist/plugins/heading.mjs +2 -2
- package/dist/plugins/highlight.mjs +2 -2
- package/dist/plugins/horizontal-rule.mjs +2 -2
- package/dist/plugins/image.mjs +3 -3
- package/dist/plugins/link.mjs +2 -2
- package/dist/plugins/list.mjs +2 -2
- package/dist/plugins/strikethrough.mjs +2 -2
- package/dist/plugins/super-sub.mjs +2 -2
- package/dist/plugins/table.mjs +10 -10
- package/dist/plugins/text-color.mjs +2 -2
- package/dist/presets/FullPreset.d.ts +16 -0
- package/dist/presets/FullPreset.d.ts.map +1 -0
- package/dist/presets/MinimalPreset.d.ts +7 -0
- package/dist/presets/MinimalPreset.d.ts.map +1 -0
- package/dist/presets/PresetTypes.d.ts +50 -0
- package/dist/presets/PresetTypes.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/notectl-core.mjs
CHANGED
|
@@ -1,52 +1,67 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as S, n as T, b as C, f as R, a as L, i as I, j as M, d as N, m as O, r as _, o as P, p as H, g as $, l as K, q as U, s as W, e as V, t as J, u as Q } from "./chunks/Document-CuwE73FF.mjs";
|
|
2
2
|
import { v, k, w, h } from "./chunks/Document-CuwE73FF.mjs";
|
|
3
|
-
import { f as
|
|
3
|
+
import { f as X, a as Y, C as Z, b as ee } from "./chunks/index--z_Txzej.mjs";
|
|
4
4
|
import { e, c, d, g, h as h2, i, j, k as k2, l, m, n, o, p, q, r, s, t, u, v as v2, w as w2, x, y, z, A, B, D, E, F, G } from "./chunks/index--z_Txzej.mjs";
|
|
5
|
-
import { e as
|
|
5
|
+
import { e as te, c as ne, i as se, a as re, f as ie, g as oe, b as ae, h as ce, j as le, s as he } from "./chunks/Selection-DmFDwiPJ.mjs";
|
|
6
6
|
import { d as d2, k as k3 } from "./chunks/Selection-DmFDwiPJ.mjs";
|
|
7
|
-
import { d as
|
|
7
|
+
import { d as de, i as pe, a as ue, s as fe } from "./chunks/MarkCommands-CC37WA7Z.mjs";
|
|
8
8
|
import { b, t as t2, c as c2, e as e2, f } from "./chunks/MarkCommands-CC37WA7Z.mjs";
|
|
9
|
-
import { b as
|
|
9
|
+
import { b as ge, n as me, m as ye } from "./chunks/TypeBrands-C09nE2qO.mjs";
|
|
10
10
|
import { c as c3, i as i2, p as p2 } from "./chunks/TypeBrands-C09nE2qO.mjs";
|
|
11
|
-
import { a as
|
|
11
|
+
import { a as ke } from "./chunks/AttrRegistry-I-VdmRnN.mjs";
|
|
12
12
|
import { b as b2, i as i3 } from "./chunks/AttrRegistry-I-VdmRnN.mjs";
|
|
13
|
-
import { c as
|
|
14
|
-
import { e as
|
|
15
|
-
import { a as
|
|
13
|
+
import { c as be } from "./chunks/NodeSpec-NZVvcCuH.mjs";
|
|
14
|
+
import { e as ve, f as we } from "./chunks/HTMLUtils-DTqQzcKR.mjs";
|
|
15
|
+
import { a as Se, r as Ee, f as xe } from "./chunks/NodeResolver-B-wzthAQ.mjs";
|
|
16
16
|
import { b as b3, c as c4, w as w3 } from "./chunks/NodeResolver-B-wzthAQ.mjs";
|
|
17
|
-
import { n as
|
|
17
|
+
import { n as Te, g as Ce, s as Re, r as Ae, d as Le, a as Ie, b as Me, e as Ne, c as Be, f as Oe, h as _e } from "./chunks/CaretNavigation-CAJXoaae.mjs";
|
|
18
18
|
import { i as i4, m as m2, j as j2 } from "./chunks/CaretNavigation-CAJXoaae.mjs";
|
|
19
|
-
import { d as
|
|
19
|
+
import { d as Pe, a as De, m as He, b as ze, s as je, n as $e, c as Ke, e as Fe, g as Ue, i as We, h as Ve, j as Ge } from "./chunks/Commands-CicwYoTQ.mjs";
|
|
20
20
|
import { f as f2 } from "./chunks/Commands-CicwYoTQ.mjs";
|
|
21
|
-
import { g as
|
|
21
|
+
import { g as qe } from "./chunks/Platform-S_xqIqcM.mjs";
|
|
22
22
|
import { a, i as i5, b as b4 } from "./chunks/Platform-S_xqIqcM.mjs";
|
|
23
|
-
import { E as
|
|
24
|
-
import { D as
|
|
25
|
-
import {
|
|
26
|
-
import { T as
|
|
23
|
+
import { E as Je, S as Qe, r as Xe, L as Ye, a as Ze } from "./chunks/resolvePluginLocale-B4w1OkPy.mjs";
|
|
24
|
+
import { D as et, d as tt, C as nt } from "./chunks/index-CAV2N-fF.mjs";
|
|
25
|
+
import { a as a2, b as b5, c as c5, i as i6, n as n2, w as w4 } from "./chunks/index-CAV2N-fF.mjs";
|
|
26
|
+
import { T as st } from "./chunks/ToolbarPlugin-B6JETWaw.mjs";
|
|
27
27
|
import { b as b6, c as c6, d as d3, a as a3 } from "./chunks/ToolbarPlugin-B6JETWaw.mjs";
|
|
28
|
-
import { f as
|
|
29
|
-
import { T as
|
|
28
|
+
import { f as rt } from "./chunks/ToolbarItem-BpZggUGo.mjs";
|
|
29
|
+
import { T as it } from "./chunks/index-D8tbbW97.mjs";
|
|
30
30
|
import { a as a4, b as b7 } from "./chunks/index-D8tbbW97.mjs";
|
|
31
|
-
import { H
|
|
32
|
-
import {
|
|
33
|
-
import { L as
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import { T as
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import
|
|
31
|
+
import { H as ot } from "./chunks/index-B9GkDVsx.mjs";
|
|
32
|
+
import { a as a5, b as b8 } from "./chunks/index-B9GkDVsx.mjs";
|
|
33
|
+
import { L as at } from "./chunks/index-CNs4QQ8l.mjs";
|
|
34
|
+
import { a as a6, b as b9 } from "./chunks/index-CNs4QQ8l.mjs";
|
|
35
|
+
import { L as ct } from "./chunks/index-D0s0Q8Wc.mjs";
|
|
36
|
+
import { a as a7, b as b10 } from "./chunks/index-D0s0Q8Wc.mjs";
|
|
37
|
+
import { B as lt } from "./chunks/index-B-NSeaM4.mjs";
|
|
38
|
+
import { a as a8, b as b11 } from "./chunks/index-B-NSeaM4.mjs";
|
|
39
|
+
import { S as ht } from "./chunks/index-DMt3ojrY.mjs";
|
|
40
|
+
import { a as a9, b as b12 } from "./chunks/index-DMt3ojrY.mjs";
|
|
41
|
+
import { T as dt } from "./chunks/index-CflvcXSd.mjs";
|
|
42
|
+
import { a as a10, b as b13 } from "./chunks/index-CflvcXSd.mjs";
|
|
43
|
+
import { H as pt } from "./chunks/index-C0cEs7Jc.mjs";
|
|
44
|
+
import { a as a11, b as b14 } from "./chunks/index-C0cEs7Jc.mjs";
|
|
45
|
+
import { A as ut } from "./chunks/index-pxbbDHVH.mjs";
|
|
46
|
+
import { a as a12, b as b15, c as c7, d as d4 } from "./chunks/index-pxbbDHVH.mjs";
|
|
47
|
+
import { F as ft } from "./chunks/index-DfzCof6H.mjs";
|
|
48
|
+
import { a as a13, b as b16 } from "./chunks/index-DfzCof6H.mjs";
|
|
49
|
+
import { F as gt } from "./chunks/index-CKPrAOr6.mjs";
|
|
50
|
+
import { a as a14, b as b17 } from "./chunks/index-CKPrAOr6.mjs";
|
|
51
|
+
import { T as mt } from "./chunks/index-FlTg80Pk.mjs";
|
|
52
|
+
import { a as a15, b as b18, c as c8, d as d5, e as e3, f as f3, g as g2, h as h3, i as i7, j as j3, k as k4, l as l2 } from "./chunks/index-FlTg80Pk.mjs";
|
|
53
|
+
import { H as yt } from "./chunks/index-CoeD4T9-.mjs";
|
|
54
|
+
import { a as a16, b as b19 } from "./chunks/index-CoeD4T9-.mjs";
|
|
55
|
+
import { S as kt } from "./chunks/index-C9gc3Bws.mjs";
|
|
56
|
+
import { a as a17, b as b20 } from "./chunks/index-C9gc3Bws.mjs";
|
|
57
|
+
import { I as bt } from "./chunks/index-DyIwN_67.mjs";
|
|
58
|
+
import { D as D2, a as a18, b as b21, c as c9 } from "./chunks/index-DyIwN_67.mjs";
|
|
59
|
+
import { HardBreakPlugin as vt } from "./plugins/hard-break.mjs";
|
|
60
|
+
import { GapCursorPlugin as wt } from "./plugins/gap-cursor.mjs";
|
|
61
|
+
import St from "dompurify";
|
|
62
|
+
import { STARTER_FONTS as Et } from "./fonts.mjs";
|
|
48
63
|
import { c as c10, b as b22, a as a19, i as i8, s as s2 } from "./chunks/NavigationUtils-CyW0Vo8A.mjs";
|
|
49
|
-
class
|
|
64
|
+
class xt {
|
|
50
65
|
_nodeSpecs = /* @__PURE__ */ new Map();
|
|
51
66
|
_markSpecs = /* @__PURE__ */ new Map();
|
|
52
67
|
_inlineNodeSpecs = /* @__PURE__ */ new Map();
|
|
@@ -122,7 +137,7 @@ class pt {
|
|
|
122
137
|
this._nodeSpecs.clear(), this._markSpecs.clear(), this._inlineNodeSpecs.clear();
|
|
123
138
|
}
|
|
124
139
|
}
|
|
125
|
-
function
|
|
140
|
+
function Tt(e4, t3, n3) {
|
|
126
141
|
const s3 = e4.getNodeSpec(t3);
|
|
127
142
|
if (!s3?.content) return true;
|
|
128
143
|
const r2 = e4.getNodeSpec(n3), i9 = r2?.group;
|
|
@@ -132,29 +147,29 @@ function ft(e4, t3, n3) {
|
|
|
132
147
|
}
|
|
133
148
|
return false;
|
|
134
149
|
}
|
|
135
|
-
function
|
|
150
|
+
function Ct(e4, t3, n3) {
|
|
136
151
|
const s3 = e4.getNodeSpec(t3);
|
|
137
152
|
if (!s3?.content) return true;
|
|
138
153
|
const { min: r2 = 0, max: i9 = Number.POSITIVE_INFINITY } = s3.content, o2 = n3.filter((e5) => "text" !== e5);
|
|
139
154
|
if (o2.length < r2 || o2.length > i9) return false;
|
|
140
|
-
for (const n4 of o2) if (!
|
|
155
|
+
for (const n4 of o2) if (!Tt(e4, t3, n4)) return false;
|
|
141
156
|
return true;
|
|
142
157
|
}
|
|
143
|
-
function
|
|
144
|
-
e4.registerNodeSpec({ type: "paragraph", group: "block", content: { allow: ["text"] }, toDOM: (e5) =>
|
|
158
|
+
function Rt(e4) {
|
|
159
|
+
e4.registerNodeSpec({ type: "paragraph", group: "block", content: { allow: ["text"] }, toDOM: (e5) => be("p", e5.id), toHTML: (e5, t3) => `<p>${t3 || "<br>"}</p>`, parseHTML: [{ tag: "p" }, { tag: "div", priority: 10 }], sanitize: { tags: ["p"] } });
|
|
145
160
|
}
|
|
146
|
-
function
|
|
161
|
+
function At(e4, t3) {
|
|
147
162
|
switch (t3.type) {
|
|
148
163
|
case "insertText":
|
|
149
164
|
return (function(e5, t4) {
|
|
150
|
-
return
|
|
151
|
-
const n3 =
|
|
165
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
166
|
+
const n3 = S(e6), s3 = t4.segments ? (function(e7, t5, n4) {
|
|
152
167
|
const s4 = [];
|
|
153
168
|
let r2 = 0, i9 = false;
|
|
154
169
|
for (const o2 of e7) {
|
|
155
|
-
if (
|
|
170
|
+
if (I(o2)) {
|
|
156
171
|
if (!i9 && t5 === r2) {
|
|
157
|
-
for (const e9 of n4) s4.push(
|
|
172
|
+
for (const e9 of n4) s4.push(M(e9.text, e9.marks));
|
|
158
173
|
i9 = true;
|
|
159
174
|
}
|
|
160
175
|
s4.push(o2), r2 += 1;
|
|
@@ -163,42 +178,42 @@ function yt(e4, t3) {
|
|
|
163
178
|
const e8 = r2 + o2.text.length;
|
|
164
179
|
if (!i9 && t5 >= r2 && t5 <= e8) {
|
|
165
180
|
const e9 = t5 - r2, a20 = o2.text.slice(0, e9), c11 = o2.text.slice(e9);
|
|
166
|
-
a20 && s4.push(
|
|
167
|
-
for (const e10 of n4) s4.push(
|
|
168
|
-
c11 && s4.push(
|
|
181
|
+
a20 && s4.push(M(a20, o2.marks));
|
|
182
|
+
for (const e10 of n4) s4.push(M(e10.text, e10.marks));
|
|
183
|
+
c11 && s4.push(M(c11, o2.marks)), i9 = true;
|
|
169
184
|
} else s4.push(o2);
|
|
170
185
|
r2 = e8;
|
|
171
186
|
}
|
|
172
|
-
if (!i9) for (const e8 of n4) s4.push(
|
|
187
|
+
if (!i9) for (const e8 of n4) s4.push(M(e8.text, e8.marks));
|
|
173
188
|
return s4;
|
|
174
189
|
})(n3, t4.offset, t4.segments) : (function(e7, t5, n4, s4) {
|
|
175
190
|
const r2 = [];
|
|
176
191
|
let i9 = 0, o2 = false;
|
|
177
192
|
for (const a20 of e7) {
|
|
178
|
-
if (
|
|
179
|
-
o2 || t5 !== i9 || (r2.push(
|
|
193
|
+
if (I(a20)) {
|
|
194
|
+
o2 || t5 !== i9 || (r2.push(M(n4, s4)), o2 = true), r2.push(a20), i9 += 1;
|
|
180
195
|
continue;
|
|
181
196
|
}
|
|
182
197
|
const e8 = i9 + a20.text.length;
|
|
183
198
|
if (!o2 && t5 >= i9 && t5 <= e8) {
|
|
184
199
|
const e9 = t5 - i9, c11 = a20.text.slice(0, e9), l3 = a20.text.slice(e9);
|
|
185
|
-
c11 && r2.push(
|
|
200
|
+
c11 && r2.push(M(c11, a20.marks)), r2.push(M(n4, s4)), l3 && r2.push(M(l3, a20.marks)), o2 = true;
|
|
186
201
|
} else r2.push(a20);
|
|
187
202
|
i9 = e8;
|
|
188
203
|
}
|
|
189
|
-
return o2 || r2.push(
|
|
204
|
+
return o2 || r2.push(M(n4, s4)), r2;
|
|
190
205
|
})(n3, t4.offset, t4.text, t4.marks);
|
|
191
|
-
return { ...e6, children:
|
|
206
|
+
return { ...e6, children: Bt(e6.children, T(s3)) };
|
|
192
207
|
});
|
|
193
208
|
})(e4, t3);
|
|
194
209
|
case "deleteText":
|
|
195
210
|
return (function(e5, t4) {
|
|
196
|
-
return
|
|
211
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
197
212
|
const n3 = (function(e7, t5, n4) {
|
|
198
213
|
const s3 = [];
|
|
199
214
|
let r2 = 0;
|
|
200
215
|
for (const i9 of e7) {
|
|
201
|
-
if (
|
|
216
|
+
if (I(i9)) {
|
|
202
217
|
const e9 = r2 + 1;
|
|
203
218
|
(e9 <= t5 || r2 >= n4) && s3.push(i9), r2 = e9;
|
|
204
219
|
continue;
|
|
@@ -207,13 +222,13 @@ function yt(e4, t3) {
|
|
|
207
222
|
if (e8 <= t5 || r2 >= n4) s3.push(i9);
|
|
208
223
|
else {
|
|
209
224
|
const e9 = Math.max(0, t5 - r2), o2 = Math.min(i9.text.length, n4 - r2), a20 = i9.text.slice(0, e9) + i9.text.slice(o2);
|
|
210
|
-
a20.length > 0 && s3.push(
|
|
225
|
+
a20.length > 0 && s3.push(M(a20, i9.marks));
|
|
211
226
|
}
|
|
212
227
|
r2 = e8;
|
|
213
228
|
}
|
|
214
229
|
return s3;
|
|
215
|
-
})(
|
|
216
|
-
return { ...e6, children:
|
|
230
|
+
})(S(e6), t4.from, t4.to);
|
|
231
|
+
return { ...e6, children: Bt(e6.children, T(n3)) };
|
|
217
232
|
});
|
|
218
233
|
})(e4, t3);
|
|
219
234
|
case "splitBlock":
|
|
@@ -222,10 +237,10 @@ function yt(e4, t3) {
|
|
|
222
237
|
if (-1 !== n3) {
|
|
223
238
|
const s3 = e5.children[n3];
|
|
224
239
|
if (!s3) return e5;
|
|
225
|
-
const r2 =
|
|
240
|
+
const r2 = S(s3), i9 = C(s3), o2 = Ot(r2, 0, t4.offset), a20 = Ot(r2, t4.offset, i9), c11 = { ...s3, children: T(o2) }, l3 = R(s3.type, T(a20), t4.newBlockId, s3.attrs), h4 = [...e5.children];
|
|
226
241
|
return h4.splice(n3, 1, c11, l3), { children: h4 };
|
|
227
242
|
}
|
|
228
|
-
return { children: e5.children.map((e6) =>
|
|
243
|
+
return { children: e5.children.map((e6) => Lt(e6, t4) ?? e6) };
|
|
229
244
|
})(e4, t3);
|
|
230
245
|
case "mergeBlocks":
|
|
231
246
|
return (function(e5, t4) {
|
|
@@ -233,30 +248,30 @@ function yt(e4, t3) {
|
|
|
233
248
|
if (-1 !== n3 && -1 !== s3) {
|
|
234
249
|
const r2 = e5.children[n3], i9 = e5.children[s3];
|
|
235
250
|
if (!r2 || !i9) return e5;
|
|
236
|
-
const o2 =
|
|
251
|
+
const o2 = S(r2), a20 = S(i9), c11 = T([...o2, ...a20]), l3 = { ...r2, children: c11 };
|
|
237
252
|
return { children: e5.children.filter((e6) => e6.id !== t4.sourceBlockId).map((e6) => e6.id === t4.targetBlockId ? l3 : e6) };
|
|
238
253
|
}
|
|
239
|
-
return { children: e5.children.map((e6) =>
|
|
254
|
+
return { children: e5.children.map((e6) => It(e6, t4) ?? e6) };
|
|
240
255
|
})(e4, t3);
|
|
241
256
|
case "addMark":
|
|
242
257
|
return (function(e5, t4) {
|
|
243
|
-
return
|
|
244
|
-
const n3 =
|
|
245
|
-
return { ...e6, children:
|
|
258
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
259
|
+
const n3 = _t(S(e6), t4.from, t4.to, t4.mark, true);
|
|
260
|
+
return { ...e6, children: Bt(e6.children, T(n3)) };
|
|
246
261
|
});
|
|
247
262
|
})(e4, t3);
|
|
248
263
|
case "removeMark":
|
|
249
264
|
return (function(e5, t4) {
|
|
250
|
-
return
|
|
251
|
-
const n3 =
|
|
252
|
-
return { ...e6, children:
|
|
265
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
266
|
+
const n3 = _t(S(e6), t4.from, t4.to, t4.mark, false);
|
|
267
|
+
return { ...e6, children: Bt(e6.children, T(n3)) };
|
|
253
268
|
});
|
|
254
269
|
})(e4, t3);
|
|
255
270
|
case "setStoredMarks":
|
|
256
271
|
return e4;
|
|
257
272
|
case "setBlockType":
|
|
258
273
|
return (function(e5, t4) {
|
|
259
|
-
return
|
|
274
|
+
return Mt(e5, t4.blockId, (e6) => ({ ...e6, type: t4.nodeType, ...t4.attrs ? { attrs: t4.attrs } : { attrs: void 0 } }));
|
|
260
275
|
})(e4, t3);
|
|
261
276
|
case "insertNode":
|
|
262
277
|
return (function(e5, t4) {
|
|
@@ -264,7 +279,7 @@ function yt(e4, t3) {
|
|
|
264
279
|
const n3 = [...e5.children];
|
|
265
280
|
return n3.splice(t4.index, 0, t4.node), { children: n3 };
|
|
266
281
|
}
|
|
267
|
-
return
|
|
282
|
+
return Pt(e5, t4.parentPath, (e6) => {
|
|
268
283
|
const n3 = [...e6.children];
|
|
269
284
|
return n3.splice(t4.index, 0, t4.node), { ...e6, children: n3 };
|
|
270
285
|
});
|
|
@@ -275,7 +290,7 @@ function yt(e4, t3) {
|
|
|
275
290
|
const n3 = [...e5.children];
|
|
276
291
|
return n3.splice(t4.index, 1), { children: n3 };
|
|
277
292
|
}
|
|
278
|
-
return
|
|
293
|
+
return Pt(e5, t4.parentPath, (e6) => {
|
|
279
294
|
const n3 = [...e6.children];
|
|
280
295
|
return n3.splice(t4.index, 1), { ...e6, children: n3 };
|
|
281
296
|
});
|
|
@@ -283,106 +298,106 @@ function yt(e4, t3) {
|
|
|
283
298
|
case "setNodeAttr":
|
|
284
299
|
return (function(e5, t4) {
|
|
285
300
|
const n3 = t4.path[t4.path.length - 1];
|
|
286
|
-
return n3 ?
|
|
301
|
+
return n3 ? Mt(e5, n3, (e6) => ({ ...e6, attrs: t4.attrs })) : e5;
|
|
287
302
|
})(e4, t3);
|
|
288
303
|
case "insertInlineNode":
|
|
289
304
|
return (function(e5, t4) {
|
|
290
|
-
return
|
|
305
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
291
306
|
const n3 = (function(e7, t5, n4) {
|
|
292
307
|
const s3 = [];
|
|
293
308
|
let r2 = 0, i9 = false;
|
|
294
309
|
for (const o2 of e7) {
|
|
295
|
-
if (
|
|
310
|
+
if (I(o2)) {
|
|
296
311
|
i9 || t5 !== r2 || (s3.push(n4), i9 = true), s3.push(o2), r2 += 1;
|
|
297
312
|
continue;
|
|
298
313
|
}
|
|
299
314
|
const e8 = r2 + o2.text.length;
|
|
300
315
|
if (!i9 && t5 >= r2 && t5 <= e8) {
|
|
301
316
|
const e9 = t5 - r2, a20 = o2.text.slice(0, e9), c11 = o2.text.slice(e9);
|
|
302
|
-
a20 && s3.push(
|
|
317
|
+
a20 && s3.push(M(a20, o2.marks)), s3.push(n4), c11 && s3.push(M(c11, o2.marks)), i9 = true;
|
|
303
318
|
} else s3.push(o2);
|
|
304
319
|
r2 = e8;
|
|
305
320
|
}
|
|
306
321
|
return i9 || s3.push(n4), s3;
|
|
307
|
-
})(
|
|
308
|
-
return { ...e6, children:
|
|
322
|
+
})(S(e6), t4.offset, t4.node);
|
|
323
|
+
return { ...e6, children: Bt(e6.children, T(n3)) };
|
|
309
324
|
});
|
|
310
325
|
})(e4, t3);
|
|
311
326
|
case "removeInlineNode":
|
|
312
327
|
return (function(e5, t4) {
|
|
313
|
-
return
|
|
328
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
314
329
|
const n3 = (function(e7, t5) {
|
|
315
330
|
const n4 = [];
|
|
316
331
|
let s3 = 0;
|
|
317
|
-
for (const r2 of e7)
|
|
332
|
+
for (const r2 of e7) I(r2) ? (s3 !== t5 && n4.push(r2), s3 += 1) : (n4.push(r2), s3 += r2.text.length);
|
|
318
333
|
return n4;
|
|
319
|
-
})(
|
|
320
|
-
return { ...e6, children:
|
|
334
|
+
})(S(e6), t4.offset);
|
|
335
|
+
return { ...e6, children: Bt(e6.children, T(n3)) };
|
|
321
336
|
});
|
|
322
337
|
})(e4, t3);
|
|
323
338
|
case "setInlineNodeAttr":
|
|
324
339
|
return (function(e5, t4) {
|
|
325
|
-
return
|
|
340
|
+
return Mt(e5, t4.blockId, (e6) => {
|
|
326
341
|
const n3 = (function(e7, t5, n4) {
|
|
327
342
|
const s3 = [];
|
|
328
343
|
let r2 = 0;
|
|
329
|
-
for (const i9 of e7)
|
|
344
|
+
for (const i9 of e7) I(i9) ? (r2 === t5 ? s3.push({ ...i9, attrs: n4 }) : s3.push(i9), r2 += 1) : (s3.push(i9), r2 += i9.text.length);
|
|
330
345
|
return s3;
|
|
331
|
-
})(
|
|
332
|
-
return { ...e6, children:
|
|
346
|
+
})(S(e6), t4.offset, t4.attrs);
|
|
347
|
+
return { ...e6, children: Bt(e6.children, n3) };
|
|
333
348
|
});
|
|
334
349
|
})(e4, t3);
|
|
335
350
|
}
|
|
336
351
|
}
|
|
337
|
-
function
|
|
338
|
-
const n3 = e4.children.findIndex((e5) =>
|
|
352
|
+
function Lt(e4, t3) {
|
|
353
|
+
const n3 = e4.children.findIndex((e5) => L(e5) && e5.id === t3.blockId);
|
|
339
354
|
if (-1 !== n3) {
|
|
340
|
-
const s4 = e4.children[n3], r3 =
|
|
355
|
+
const s4 = e4.children[n3], r3 = S(s4), i9 = C(s4), o2 = Ot(r3, 0, t3.offset), a20 = Ot(r3, t3.offset, i9), c11 = { ...s4, children: T(o2) }, l3 = R(s4.type, T(a20), t3.newBlockId, s4.attrs), h4 = [...e4.children];
|
|
341
356
|
return h4.splice(n3, 1, c11, l3), { ...e4, children: h4 };
|
|
342
357
|
}
|
|
343
358
|
let s3 = false;
|
|
344
359
|
const r2 = e4.children.map((e5) => {
|
|
345
|
-
if (!
|
|
346
|
-
const n4 =
|
|
360
|
+
if (!L(e5)) return e5;
|
|
361
|
+
const n4 = Lt(e5, t3);
|
|
347
362
|
return n4 ? (s3 = true, n4) : e5;
|
|
348
363
|
});
|
|
349
364
|
return s3 ? { ...e4, children: r2 } : null;
|
|
350
365
|
}
|
|
351
|
-
function
|
|
352
|
-
const n3 = e4.children.findIndex((e5) =>
|
|
366
|
+
function It(e4, t3) {
|
|
367
|
+
const n3 = e4.children.findIndex((e5) => L(e5) && e5.id === t3.targetBlockId), s3 = e4.children.findIndex((e5) => L(e5) && e5.id === t3.sourceBlockId);
|
|
353
368
|
if (-1 !== n3 && -1 !== s3) {
|
|
354
|
-
const r3 = e4.children[n3], i10 = e4.children[s3], o2 =
|
|
369
|
+
const r3 = e4.children[n3], i10 = e4.children[s3], o2 = S(r3), a20 = S(i10), c11 = T([...o2, ...a20]), l3 = { ...r3, children: c11 }, h4 = e4.children.filter((e5) => !L(e5) || e5.id !== t3.sourceBlockId).map((e5) => L(e5) && e5.id === t3.targetBlockId ? l3 : e5);
|
|
355
370
|
return { ...e4, children: h4 };
|
|
356
371
|
}
|
|
357
372
|
let r2 = false;
|
|
358
373
|
const i9 = e4.children.map((e5) => {
|
|
359
|
-
if (!
|
|
360
|
-
const n4 =
|
|
374
|
+
if (!L(e5)) return e5;
|
|
375
|
+
const n4 = It(e5, t3);
|
|
361
376
|
return n4 ? (r2 = true, n4) : e5;
|
|
362
377
|
});
|
|
363
378
|
return r2 ? { ...e4, children: i9 } : null;
|
|
364
379
|
}
|
|
365
|
-
function
|
|
366
|
-
return { children:
|
|
380
|
+
function Mt(e4, t3, n3) {
|
|
381
|
+
return { children: Nt(e4.children, t3, n3) };
|
|
367
382
|
}
|
|
368
|
-
function
|
|
383
|
+
function Nt(e4, t3, n3) {
|
|
369
384
|
return e4.map((e5) => {
|
|
370
|
-
if (!
|
|
385
|
+
if (!L(e5)) return e5;
|
|
371
386
|
if (e5.id === t3) return n3(e5);
|
|
372
|
-
const s3 =
|
|
387
|
+
const s3 = Nt(e5.children, t3, n3);
|
|
373
388
|
return s3 === e5.children ? e5 : { ...e5, children: s3 };
|
|
374
389
|
});
|
|
375
390
|
}
|
|
376
|
-
function
|
|
377
|
-
if (e4.every((e5) =>
|
|
378
|
-
const n3 = e4.filter((e5) => !
|
|
391
|
+
function Bt(e4, t3) {
|
|
392
|
+
if (e4.every((e5) => N(e5) || I(e5))) return t3;
|
|
393
|
+
const n3 = e4.filter((e5) => !N(e5) && !I(e5));
|
|
379
394
|
return [...t3, ...n3];
|
|
380
395
|
}
|
|
381
|
-
function
|
|
396
|
+
function Ot(e4, t3, n3) {
|
|
382
397
|
const s3 = [];
|
|
383
398
|
let r2 = 0;
|
|
384
399
|
for (const i9 of e4) {
|
|
385
|
-
if (
|
|
400
|
+
if (I(i9)) {
|
|
386
401
|
const e6 = r2 + 1;
|
|
387
402
|
e6 > t3 && r2 < n3 && s3.push(i9), r2 = e6;
|
|
388
403
|
continue;
|
|
@@ -391,49 +406,49 @@ function Et(e4, t3, n3) {
|
|
|
391
406
|
if (e5 <= t3 || r2 >= n3) ;
|
|
392
407
|
else {
|
|
393
408
|
const e6 = Math.max(0, t3 - r2), o2 = Math.min(i9.text.length, n3 - r2), a20 = i9.text.slice(e6, o2);
|
|
394
|
-
a20.length > 0 && s3.push(
|
|
409
|
+
a20.length > 0 && s3.push(M(a20, i9.marks));
|
|
395
410
|
}
|
|
396
411
|
r2 = e5;
|
|
397
412
|
}
|
|
398
|
-
return 0 === s3.length && s3.push(
|
|
413
|
+
return 0 === s3.length && s3.push(M("")), s3;
|
|
399
414
|
}
|
|
400
|
-
function
|
|
415
|
+
function _t(e4, t3, n3, s3, r2) {
|
|
401
416
|
const i9 = [];
|
|
402
417
|
let o2 = 0;
|
|
403
418
|
for (const a20 of e4) {
|
|
404
|
-
if (
|
|
419
|
+
if (I(a20)) {
|
|
405
420
|
i9.push(a20), o2 += 1;
|
|
406
421
|
continue;
|
|
407
422
|
}
|
|
408
423
|
const e5 = o2 + a20.text.length;
|
|
409
424
|
if (e5 <= t3 || o2 >= n3) i9.push(a20);
|
|
410
425
|
else if (o2 >= t3 && e5 <= n3) {
|
|
411
|
-
const e6 = r2 ?
|
|
412
|
-
i9.push(
|
|
426
|
+
const e6 = r2 ? O(a20.marks, s3) : _(a20.marks, s3.type);
|
|
427
|
+
i9.push(M(a20.text, e6));
|
|
413
428
|
} else {
|
|
414
|
-
const e6 = Math.max(0, t3 - o2), c11 = Math.min(a20.text.length, n3 - o2), l3 = a20.text.slice(0, e6), h4 = a20.text.slice(e6, c11),
|
|
415
|
-
if (l3 && i9.push(
|
|
416
|
-
const e7 = r2 ?
|
|
417
|
-
i9.push(
|
|
429
|
+
const e6 = Math.max(0, t3 - o2), c11 = Math.min(a20.text.length, n3 - o2), l3 = a20.text.slice(0, e6), h4 = a20.text.slice(e6, c11), d6 = a20.text.slice(c11);
|
|
430
|
+
if (l3 && i9.push(M(l3, a20.marks)), h4) {
|
|
431
|
+
const e7 = r2 ? O(a20.marks, s3) : _(a20.marks, s3.type);
|
|
432
|
+
i9.push(M(h4, e7));
|
|
418
433
|
}
|
|
419
|
-
|
|
434
|
+
d6 && i9.push(M(d6, a20.marks));
|
|
420
435
|
}
|
|
421
436
|
o2 = e5;
|
|
422
437
|
}
|
|
423
438
|
return i9;
|
|
424
439
|
}
|
|
425
|
-
function
|
|
440
|
+
function Pt(e4, t3, n3) {
|
|
426
441
|
if (0 === t3.length) return e4;
|
|
427
442
|
const s3 = t3[0];
|
|
428
|
-
return s3 ? { children: e4.children.map((e5) =>
|
|
443
|
+
return s3 ? { children: e4.children.map((e5) => L(e5) && e5.id === s3 ? 1 === t3.length ? n3(e5) : Dt(e5, t3, 1, n3) : e5) } : e4;
|
|
429
444
|
}
|
|
430
|
-
function
|
|
445
|
+
function Dt(e4, t3, n3, s3) {
|
|
431
446
|
const r2 = t3[n3];
|
|
432
447
|
if (!r2) return e4;
|
|
433
|
-
const i9 = e4.children.map((e5) =>
|
|
448
|
+
const i9 = e4.children.map((e5) => L(e5) && e5.id === r2 ? n3 === t3.length - 1 ? s3(e5) : Dt(e5, t3, n3 + 1, s3) : e5);
|
|
434
449
|
return { ...e4, children: i9 };
|
|
435
450
|
}
|
|
436
|
-
function
|
|
451
|
+
function Ht(e4) {
|
|
437
452
|
switch (e4.type) {
|
|
438
453
|
case "insertText":
|
|
439
454
|
return { type: "deleteText", blockId: e4.blockId, from: e4.offset, to: e4.offset + e4.text.length, deletedText: e4.text, deletedMarks: e4.marks, deletedSegments: e4.segments ?? [{ text: e4.text, marks: [...e4.marks] }], ...e4.path ? { path: e4.path } : {} };
|
|
@@ -465,10 +480,10 @@ function Rt(e4) {
|
|
|
465
480
|
return { type: "setInlineNodeAttr", blockId: e4.blockId, offset: e4.offset, attrs: e4.previousAttrs, previousAttrs: e4.attrs, ...e4.path ? { path: e4.path } : {} };
|
|
466
481
|
}
|
|
467
482
|
}
|
|
468
|
-
function
|
|
469
|
-
return { steps: e4.steps.map(
|
|
483
|
+
function zt(e4) {
|
|
484
|
+
return { steps: e4.steps.map(Ht).reverse(), selectionBefore: e4.selectionAfter, selectionAfter: e4.selectionBefore, storedMarksAfter: null, metadata: { origin: "history", timestamp: Date.now() } };
|
|
470
485
|
}
|
|
471
|
-
class
|
|
486
|
+
class jt {
|
|
472
487
|
steps = [];
|
|
473
488
|
selection;
|
|
474
489
|
storedMarks;
|
|
@@ -487,8 +502,8 @@ class Lt {
|
|
|
487
502
|
let o2;
|
|
488
503
|
if (i9) o2 = i9;
|
|
489
504
|
else if (this.workingDoc) {
|
|
490
|
-
const i10 =
|
|
491
|
-
o2 = i10 ?
|
|
505
|
+
const i10 = Se(this.workingDoc, e4);
|
|
506
|
+
o2 = i10 ? P(i10, t3, n3) : [{ text: s3, marks: [...r2] }];
|
|
492
507
|
} else o2 = [{ text: s3, marks: [...r2] }];
|
|
493
508
|
const a20 = { type: "deleteText", blockId: e4, from: t3, to: n3, deletedText: s3, deletedMarks: r2, deletedSegments: o2 };
|
|
494
509
|
return this.steps.push(a20), this.advanceDoc(a20), this;
|
|
@@ -496,9 +511,9 @@ class Lt {
|
|
|
496
511
|
deleteTextAt(e4, t3, n3) {
|
|
497
512
|
const s3 = this.workingDoc;
|
|
498
513
|
if (!s3) throw new Error("deleteTextAt requires a document. Use state.transaction() or provide doc to constructor.");
|
|
499
|
-
const r2 =
|
|
514
|
+
const r2 = Se(s3, e4);
|
|
500
515
|
if (!r2) throw new Error(`Block "${e4}" not found in working document.`);
|
|
501
|
-
const i9 =
|
|
516
|
+
const i9 = H(r2).slice(t3, n3), o2 = $(r2, t3), a20 = P(r2, t3, n3);
|
|
502
517
|
return this.deleteText(e4, t3, n3, i9, o2, a20);
|
|
503
518
|
}
|
|
504
519
|
splitBlock(e4, t3, n3) {
|
|
@@ -512,9 +527,9 @@ class Lt {
|
|
|
512
527
|
mergeBlocksAt(e4, t3) {
|
|
513
528
|
const n3 = this.workingDoc;
|
|
514
529
|
if (!n3) throw new Error("mergeBlocksAt requires a document. Use state.transaction() or provide doc to constructor.");
|
|
515
|
-
const s3 =
|
|
530
|
+
const s3 = Se(n3, e4);
|
|
516
531
|
if (!s3) throw new Error(`Target block "${e4}" not found in working document.`);
|
|
517
|
-
const r2 =
|
|
532
|
+
const r2 = C(s3);
|
|
518
533
|
return this.mergeBlocks(e4, t3, r2);
|
|
519
534
|
}
|
|
520
535
|
addMark(e4, t3, n3, s3) {
|
|
@@ -528,7 +543,7 @@ class Lt {
|
|
|
528
543
|
setBlockType(e4, t3, n3) {
|
|
529
544
|
const s3 = this.workingDoc;
|
|
530
545
|
if (!s3) throw new Error("setBlockType requires a document. Use state.transaction() or provide doc to constructor.");
|
|
531
|
-
const r2 =
|
|
546
|
+
const r2 = Se(s3, e4);
|
|
532
547
|
if (!r2) throw new Error(`Block "${e4}" not found in working document.`);
|
|
533
548
|
const i9 = { type: "setBlockType", blockId: e4, nodeType: t3, ...n3 ? { attrs: n3 } : {}, previousNodeType: r2.type, ...r2.attrs ? { previousAttrs: r2.attrs } : {} };
|
|
534
549
|
return this.steps.push(i9), this.advanceDoc(i9), this;
|
|
@@ -543,12 +558,12 @@ class Lt {
|
|
|
543
558
|
const s3 = (function(e5, t4, n4) {
|
|
544
559
|
if (0 === t4.length) {
|
|
545
560
|
const t5 = e5.children[n4];
|
|
546
|
-
return t5 &&
|
|
561
|
+
return t5 && L(t5) ? t5 : void 0;
|
|
547
562
|
}
|
|
548
|
-
const s4 =
|
|
563
|
+
const s4 = Ee(e5, t4);
|
|
549
564
|
if (!s4) return;
|
|
550
565
|
const r3 = s4.children[n4];
|
|
551
|
-
return r3 &&
|
|
566
|
+
return r3 && L(r3) ? r3 : void 0;
|
|
552
567
|
})(n3, e4, t3);
|
|
553
568
|
if (!s3) throw new Error(`Node at index ${t3} not found under parent path [${e4.join(", ")}].`);
|
|
554
569
|
const r2 = { type: "removeNode", parentPath: e4, index: t3, removedNode: s3 };
|
|
@@ -557,7 +572,7 @@ class Lt {
|
|
|
557
572
|
setNodeAttr(e4, t3) {
|
|
558
573
|
const n3 = this.workingDoc;
|
|
559
574
|
if (!n3) throw new Error("setNodeAttr requires a document. Use state.transaction() or provide doc to constructor.");
|
|
560
|
-
const s3 =
|
|
575
|
+
const s3 = Ee(n3, e4);
|
|
561
576
|
if (!s3) throw new Error(`Node not found at path [${e4.join(", ")}].`);
|
|
562
577
|
const r2 = { type: "setNodeAttr", path: e4, attrs: t3, ...s3.attrs ? { previousAttrs: s3.attrs } : {} };
|
|
563
578
|
return this.steps.push(r2), this.advanceDoc(r2), this;
|
|
@@ -569,9 +584,9 @@ class Lt {
|
|
|
569
584
|
removeInlineNode(e4, t3) {
|
|
570
585
|
const n3 = this.workingDoc;
|
|
571
586
|
if (!n3) throw new Error("removeInlineNode requires a document. Use state.transaction() or provide doc.");
|
|
572
|
-
const s3 =
|
|
587
|
+
const s3 = Se(n3, e4);
|
|
573
588
|
if (!s3) throw new Error(`Block "${e4}" not found in working document.`);
|
|
574
|
-
const r2 =
|
|
589
|
+
const r2 = K(s3, t3);
|
|
575
590
|
if (!r2 || "inline" !== r2.kind) throw new Error(`No InlineNode at offset ${t3} in block "${e4}".`);
|
|
576
591
|
const i9 = { type: "removeInlineNode", blockId: e4, offset: t3, removedNode: r2.node };
|
|
577
592
|
return this.steps.push(i9), this.advanceDoc(i9), this;
|
|
@@ -579,16 +594,16 @@ class Lt {
|
|
|
579
594
|
setInlineNodeAttr(e4, t3, n3) {
|
|
580
595
|
const s3 = this.workingDoc;
|
|
581
596
|
if (!s3) throw new Error("setInlineNodeAttr requires a document. Use state.transaction() or provide doc.");
|
|
582
|
-
const r2 =
|
|
597
|
+
const r2 = Se(s3, e4);
|
|
583
598
|
if (!r2) throw new Error(`Block "${e4}" not found in working document.`);
|
|
584
|
-
const i9 =
|
|
599
|
+
const i9 = S(r2);
|
|
585
600
|
let o2 = 0;
|
|
586
601
|
for (const s4 of i9) {
|
|
587
|
-
if (
|
|
602
|
+
if (I(s4) && o2 === t3) {
|
|
588
603
|
const r3 = { type: "setInlineNodeAttr", blockId: e4, offset: t3, attrs: n3, previousAttrs: s4.attrs };
|
|
589
604
|
return this.steps.push(r3), this.advanceDoc(r3), this;
|
|
590
605
|
}
|
|
591
|
-
o2 +=
|
|
606
|
+
o2 += I(s4) ? 1 : s4.text.length;
|
|
592
607
|
}
|
|
593
608
|
throw new Error(`No InlineNode at offset ${t3} in block "${e4}".`);
|
|
594
609
|
}
|
|
@@ -599,7 +614,7 @@ class Lt {
|
|
|
599
614
|
return this.selection = e4, this;
|
|
600
615
|
}
|
|
601
616
|
setNodeSelection(e4, t3) {
|
|
602
|
-
return this.selection =
|
|
617
|
+
return this.selection = te(e4, t3), this;
|
|
603
618
|
}
|
|
604
619
|
setStoredMarks(e4, t3) {
|
|
605
620
|
return this.steps.push({ type: "setStoredMarks", marks: e4, previousMarks: t3 }), this.storedMarks = e4, this;
|
|
@@ -608,10 +623,10 @@ class Lt {
|
|
|
608
623
|
return { steps: [...this.steps], selectionBefore: this.selectionBefore, selectionAfter: this.selection, storedMarksAfter: this.storedMarks, metadata: { origin: this.origin, timestamp: Date.now(), ...this._readonlyAllowed ? { readonlyAllowed: true } : {} } };
|
|
609
624
|
}
|
|
610
625
|
advanceDoc(e4) {
|
|
611
|
-
this.workingDoc && (this.workingDoc =
|
|
626
|
+
this.workingDoc && (this.workingDoc = At(this.workingDoc, e4));
|
|
612
627
|
}
|
|
613
628
|
}
|
|
614
|
-
class
|
|
629
|
+
class $t {
|
|
615
630
|
doc;
|
|
616
631
|
selection;
|
|
617
632
|
storedMarks;
|
|
@@ -622,28 +637,28 @@ class It {
|
|
|
622
637
|
this.doc = e4, this.selection = t3, this.storedMarks = n3, this.schema = s3;
|
|
623
638
|
}
|
|
624
639
|
static create(e4) {
|
|
625
|
-
const t3 = e4?.schema ??
|
|
626
|
-
return new
|
|
640
|
+
const t3 = e4?.schema ?? de(), n3 = e4?.doc ?? U(), s3 = n3.children[0], r2 = e4?.selection ?? ne(s3 ? s3.id : ge(""), 0);
|
|
641
|
+
return new $t(n3, r2, null, t3);
|
|
627
642
|
}
|
|
628
643
|
transaction(e4 = "api") {
|
|
629
|
-
return new
|
|
644
|
+
return new jt(this.selection, this.storedMarks, e4, this.doc);
|
|
630
645
|
}
|
|
631
646
|
apply(e4) {
|
|
632
647
|
let t3 = this.doc;
|
|
633
|
-
for (const n4 of e4.steps) t3 =
|
|
648
|
+
for (const n4 of e4.steps) t3 = At(t3, n4);
|
|
634
649
|
const n3 = (function(e5, t4) {
|
|
635
|
-
if (
|
|
636
|
-
if (
|
|
637
|
-
const n4 =
|
|
638
|
-
return n4 === t4.anchor && s3 === t4.head ? t4 :
|
|
650
|
+
if (se(t4)) return Se(e5, t4.nodeId) ? t4 : Ft(e5, t4);
|
|
651
|
+
if (re(t4)) return Se(e5, t4.blockId) ? t4 : Ft(e5, t4);
|
|
652
|
+
const n4 = Kt(e5, t4.anchor), s3 = Kt(e5, t4.head);
|
|
653
|
+
return n4 === t4.anchor && s3 === t4.head ? t4 : ie(n4, s3);
|
|
639
654
|
})(t3, e4.selectionAfter);
|
|
640
|
-
return new
|
|
655
|
+
return new $t(t3, n3, e4.storedMarksAfter, this.schema);
|
|
641
656
|
}
|
|
642
657
|
getBlock(e4) {
|
|
643
658
|
return this._blockMap ??= (function(e5) {
|
|
644
659
|
const t3 = /* @__PURE__ */ new Map();
|
|
645
660
|
return (function e6(n3) {
|
|
646
|
-
for (const s3 of n3)
|
|
661
|
+
for (const s3 of n3) L(s3) && (t3.set(s3.id, s3), e6(s3.children));
|
|
647
662
|
})(e5.children), t3;
|
|
648
663
|
})(this.doc), this._blockMap.get(e4);
|
|
649
664
|
}
|
|
@@ -651,56 +666,56 @@ class It {
|
|
|
651
666
|
return this._blockOrder ??= (function(e4) {
|
|
652
667
|
const t3 = [];
|
|
653
668
|
return (function e5(n3) {
|
|
654
|
-
for (const s3 of n3)
|
|
669
|
+
for (const s3 of n3) L(s3) && (W(s3) ? t3.push(s3.id) : e5(s3.children));
|
|
655
670
|
})(e4.children), t3;
|
|
656
671
|
})(this.doc), this._blockOrder;
|
|
657
672
|
}
|
|
658
673
|
getNodePath(e4) {
|
|
659
|
-
return
|
|
674
|
+
return xe(this.doc, e4);
|
|
660
675
|
}
|
|
661
676
|
getParent(e4) {
|
|
662
|
-
const t3 =
|
|
677
|
+
const t3 = xe(this.doc, e4);
|
|
663
678
|
if (!t3 || t3.length <= 1) return;
|
|
664
679
|
const n3 = t3[t3.length - 2];
|
|
665
|
-
return n3 ?
|
|
680
|
+
return n3 ? Se(this.doc, n3) : void 0;
|
|
666
681
|
}
|
|
667
682
|
toJSON() {
|
|
668
683
|
return { doc: this.doc, selection: this.selection };
|
|
669
684
|
}
|
|
670
685
|
static fromJSON(e4, t3) {
|
|
671
|
-
return new
|
|
686
|
+
return new $t(e4.doc, e4.selection, null, t3 ?? de());
|
|
672
687
|
}
|
|
673
688
|
}
|
|
674
|
-
function
|
|
675
|
-
const n3 =
|
|
689
|
+
function Kt(e4, t3) {
|
|
690
|
+
const n3 = Se(e4, t3.blockId);
|
|
676
691
|
if (n3) {
|
|
677
|
-
const e5 =
|
|
678
|
-
return t3.offset > e5 ?
|
|
692
|
+
const e5 = C(n3);
|
|
693
|
+
return t3.offset > e5 ? oe(t3.blockId, e5, t3.path) : t3;
|
|
679
694
|
}
|
|
680
695
|
const s3 = e4.children[0];
|
|
681
|
-
return s3 ?
|
|
696
|
+
return s3 ? oe(s3.id, 0) : t3;
|
|
682
697
|
}
|
|
683
|
-
function
|
|
684
|
-
const n3 =
|
|
685
|
-
return n3 ?
|
|
698
|
+
function Ft(e4, t3) {
|
|
699
|
+
const n3 = Ut(e4.children);
|
|
700
|
+
return n3 ? ne(n3.id, 0) : t3;
|
|
686
701
|
}
|
|
687
|
-
function
|
|
702
|
+
function Ut(e4) {
|
|
688
703
|
for (const t3 of e4) {
|
|
689
|
-
if (!
|
|
690
|
-
if (
|
|
691
|
-
const e5 =
|
|
704
|
+
if (!L(t3)) continue;
|
|
705
|
+
if (W(t3)) return t3;
|
|
706
|
+
const e5 = Ut(t3.children);
|
|
692
707
|
if (e5) return e5;
|
|
693
708
|
}
|
|
694
709
|
return null;
|
|
695
710
|
}
|
|
696
|
-
function
|
|
711
|
+
function Wt(e4) {
|
|
697
712
|
for (const t3 of e4.steps) if ("setStoredMarks" !== t3.type) return false;
|
|
698
713
|
return true;
|
|
699
714
|
}
|
|
700
|
-
function
|
|
701
|
-
return !!e4.metadata.readonlyAllowed ||
|
|
715
|
+
function Vt(e4) {
|
|
716
|
+
return !!e4.metadata.readonlyAllowed || Wt(e4);
|
|
702
717
|
}
|
|
703
|
-
class
|
|
718
|
+
class Gt {
|
|
704
719
|
undoStack = [];
|
|
705
720
|
redoStack = [];
|
|
706
721
|
groupTimeoutMs;
|
|
@@ -723,7 +738,7 @@ class _t {
|
|
|
723
738
|
for (let e5 = t3.transactions.length - 1; e5 >= 0; e5--) {
|
|
724
739
|
const r2 = t3.transactions[e5];
|
|
725
740
|
if (!r2) continue;
|
|
726
|
-
const i9 =
|
|
741
|
+
const i9 = zt(r2);
|
|
727
742
|
n3 = n3.apply(i9), s3.push(...i9.steps);
|
|
728
743
|
}
|
|
729
744
|
return this.redoStack.push({ transactions: t3.transactions, timestamp: Date.now() }), this.lastOrigin = null, { state: n3, transaction: { steps: s3, selectionBefore: e4.selection, selectionAfter: n3.selection, storedMarksAfter: n3.storedMarks, metadata: { origin: "history", timestamp: Date.now(), historyDirection: "undo" } } };
|
|
@@ -752,25 +767,25 @@ class _t {
|
|
|
752
767
|
return s3 === r2;
|
|
753
768
|
}
|
|
754
769
|
}
|
|
755
|
-
function
|
|
770
|
+
function qt(e4) {
|
|
756
771
|
const t3 = e4.selection;
|
|
757
|
-
if (
|
|
758
|
-
if (
|
|
759
|
-
if (!
|
|
772
|
+
if (se(t3)) return Pe(e4, t3);
|
|
773
|
+
if (re(t3)) return null;
|
|
774
|
+
if (!ae(t3)) return De(e4);
|
|
760
775
|
const n3 = e4.getBlock(t3.anchor.blockId);
|
|
761
|
-
return n3 ? t3.anchor.offset > 0 ? e4.transaction("input").deleteTextAt(n3.id, t3.anchor.offset - 1, t3.anchor.offset).setSelection(
|
|
776
|
+
return n3 ? t3.anchor.offset > 0 ? e4.transaction("input").deleteTextAt(n3.id, t3.anchor.offset - 1, t3.anchor.offset).setSelection(ne(n3.id, t3.anchor.offset - 1)).build() : He(e4) : null;
|
|
762
777
|
}
|
|
763
|
-
function
|
|
778
|
+
function Jt(e4) {
|
|
764
779
|
const t3 = e4.selection;
|
|
765
|
-
if (
|
|
766
|
-
if (
|
|
767
|
-
if (!
|
|
780
|
+
if (se(t3)) return Pe(e4, t3);
|
|
781
|
+
if (re(t3)) return null;
|
|
782
|
+
if (!ae(t3)) return De(e4);
|
|
768
783
|
const n3 = e4.getBlock(t3.anchor.blockId);
|
|
769
784
|
if (!n3) return null;
|
|
770
|
-
const s3 =
|
|
771
|
-
return t3.anchor.offset < s3 ? e4.transaction("input").deleteTextAt(n3.id, t3.anchor.offset, t3.anchor.offset + 1).setSelection(
|
|
785
|
+
const s3 = C(n3);
|
|
786
|
+
return t3.anchor.offset < s3 ? e4.transaction("input").deleteTextAt(n3.id, t3.anchor.offset, t3.anchor.offset + 1).setSelection(ne(n3.id, t3.anchor.offset)).build() : ze(e4);
|
|
772
787
|
}
|
|
773
|
-
class
|
|
788
|
+
class Qt {
|
|
774
789
|
constructor(e4, t3) {
|
|
775
790
|
this.element = e4, this.getState = t3.getState, this.dispatch = t3.dispatch, this.undo = t3.undo, this.redo = t3.redo, this.keymapRegistry = t3.keymapRegistry, this.isReadOnly = t3.isReadOnly ?? (() => false), this.compositionTracker = t3.compositionTracker, this.handleKeydown = this.onKeydown.bind(this), e4.addEventListener("keydown", this.handleKeydown);
|
|
776
791
|
}
|
|
@@ -788,7 +803,7 @@ class zt {
|
|
|
788
803
|
if (this.handleGapCursorKeys(e4)) return;
|
|
789
804
|
if (this.isReadOnly()) {
|
|
790
805
|
if (this.keymapRegistry) {
|
|
791
|
-
const t4 =
|
|
806
|
+
const t4 = Xt(e4), n4 = this.keymapRegistry.getKeymapsByPriority().navigation;
|
|
792
807
|
for (let s4 = n4.length - 1; s4 >= 0; s4--) {
|
|
793
808
|
const r2 = n4[s4]?.[t4];
|
|
794
809
|
if (r2?.()) return void e4.preventDefault();
|
|
@@ -797,7 +812,7 @@ class zt {
|
|
|
797
812
|
return void this.handleEscape(e4);
|
|
798
813
|
}
|
|
799
814
|
if (this.keymapRegistry) {
|
|
800
|
-
const t4 =
|
|
815
|
+
const t4 = Xt(e4), n4 = this.keymapRegistry.getKeymapsByPriority();
|
|
801
816
|
for (const s4 of [n4.context, n4.navigation, n4.default]) for (let n5 = s4.length - 1; n5 >= 0; n5--) {
|
|
802
817
|
const r2 = s4[n5]?.[t4];
|
|
803
818
|
if (r2?.()) return void e4.preventDefault();
|
|
@@ -809,38 +824,38 @@ class zt {
|
|
|
809
824
|
if (!e4.metaKey && !e4.ctrlKey) return;
|
|
810
825
|
const t3 = e4.key.toLowerCase(), n3 = this.getState();
|
|
811
826
|
let s3 = null;
|
|
812
|
-
return "z" !== t3 || e4.shiftKey ? "z" === t3 && e4.shiftKey || "y" === t3 && !e4.shiftKey ? (e4.preventDefault(), void this.redo()) : ("a" !== t3 || e4.shiftKey || (e4.preventDefault(), s3 =
|
|
827
|
+
return "z" !== t3 || e4.shiftKey ? "z" === t3 && e4.shiftKey || "y" === t3 && !e4.shiftKey ? (e4.preventDefault(), void this.redo()) : ("a" !== t3 || e4.shiftKey || (e4.preventDefault(), s3 = je(n3)), void (s3 && this.dispatch(s3))) : (e4.preventDefault(), void this.undo());
|
|
813
828
|
}
|
|
814
829
|
handleNodeSelectionKeys(e4) {
|
|
815
830
|
const t3 = this.getState(), n3 = t3.selection;
|
|
816
|
-
if (!
|
|
831
|
+
if (!se(n3)) return false;
|
|
817
832
|
const s3 = e4.key;
|
|
818
833
|
if (!("ArrowLeft" !== s3 && "ArrowUp" !== s3 && "ArrowRight" !== s3 && "ArrowDown" !== s3 || e4.shiftKey || e4.metaKey || e4.ctrlKey || e4.altKey)) {
|
|
819
|
-
const n4 =
|
|
834
|
+
const n4 = $e(t3, "ArrowLeft" === s3 ? "left" : "ArrowRight" === s3 ? "right" : "ArrowUp" === s3 ? "up" : "down");
|
|
820
835
|
return !!n4 && (e4.preventDefault(), this.dispatch(n4), true);
|
|
821
836
|
}
|
|
822
837
|
if ("Backspace" === s3 || "Delete" === s3) {
|
|
823
838
|
if (this.isReadOnly()) return e4.preventDefault(), true;
|
|
824
839
|
e4.preventDefault();
|
|
825
|
-
const s4 =
|
|
840
|
+
const s4 = Pe(t3, n3);
|
|
826
841
|
return s4 && this.dispatch(s4), true;
|
|
827
842
|
}
|
|
828
843
|
if ("Enter" === s3) {
|
|
829
844
|
if (this.isReadOnly()) return e4.preventDefault(), true;
|
|
830
845
|
e4.preventDefault();
|
|
831
|
-
const n4 =
|
|
846
|
+
const n4 = Ke(t3);
|
|
832
847
|
return n4 && this.dispatch(n4), true;
|
|
833
848
|
}
|
|
834
849
|
if ("Escape" === s3) {
|
|
835
850
|
e4.preventDefault();
|
|
836
|
-
const n4 =
|
|
851
|
+
const n4 = $e(t3, "right");
|
|
837
852
|
return n4 && this.dispatch(n4), true;
|
|
838
853
|
}
|
|
839
854
|
return false;
|
|
840
855
|
}
|
|
841
856
|
handleGapCursorKeys(e4) {
|
|
842
857
|
const t3 = this.getState(), n3 = t3.selection;
|
|
843
|
-
if (!
|
|
858
|
+
if (!re(n3)) return false;
|
|
844
859
|
const s3 = e4.key;
|
|
845
860
|
if ("ArrowLeft" === s3 || "ArrowRight" === s3 || "ArrowUp" === s3 || "ArrowDown" === s3) return false;
|
|
846
861
|
if ("Escape" === s3 || "Tab" === s3) return false;
|
|
@@ -848,42 +863,42 @@ class zt {
|
|
|
848
863
|
if ("Enter" === s3) {
|
|
849
864
|
if (this.isReadOnly()) return e4.preventDefault(), true;
|
|
850
865
|
e4.preventDefault();
|
|
851
|
-
const n4 =
|
|
866
|
+
const n4 = Ke(t3);
|
|
852
867
|
return n4 && this.dispatch(n4), true;
|
|
853
868
|
}
|
|
854
869
|
if ("Backspace" === s3) {
|
|
855
870
|
if (this.isReadOnly()) return e4.preventDefault(), true;
|
|
856
871
|
e4.preventDefault();
|
|
857
|
-
const s4 =
|
|
872
|
+
const s4 = Fe(t3, n3);
|
|
858
873
|
return s4 && this.dispatch(s4), true;
|
|
859
874
|
}
|
|
860
875
|
if ("Delete" === s3) {
|
|
861
876
|
if (this.isReadOnly()) return e4.preventDefault(), true;
|
|
862
877
|
e4.preventDefault();
|
|
863
|
-
const s4 =
|
|
878
|
+
const s4 = Ue(t3, n3);
|
|
864
879
|
return s4 && this.dispatch(s4), true;
|
|
865
880
|
}
|
|
866
881
|
if (1 === s3.length) {
|
|
867
882
|
if (this.isReadOnly()) return e4.preventDefault(), true;
|
|
868
883
|
e4.preventDefault();
|
|
869
|
-
const n4 =
|
|
884
|
+
const n4 = We(t3, s3);
|
|
870
885
|
return this.dispatch(n4), true;
|
|
871
886
|
}
|
|
872
887
|
return false;
|
|
873
888
|
}
|
|
874
889
|
handleGapCursorArrowFallback(e4) {
|
|
875
890
|
const t3 = this.getState(), n3 = t3.selection;
|
|
876
|
-
if (!
|
|
891
|
+
if (!re(n3)) return false;
|
|
877
892
|
const s3 = e4.key;
|
|
878
893
|
if ("ArrowLeft" !== s3 && "ArrowRight" !== s3 && "ArrowUp" !== s3 && "ArrowDown" !== s3) return false;
|
|
879
|
-
const r2 =
|
|
880
|
-
return !(!r2 ||
|
|
894
|
+
const r2 = Te(t3, "ArrowLeft" === s3 ? "left" : "ArrowRight" === s3 ? "right" : "ArrowUp" === s3 ? "up" : "down");
|
|
895
|
+
return !(!r2 || ce(r2.selectionAfter, n3) || (e4.preventDefault(), this.dispatch(r2), 0));
|
|
881
896
|
}
|
|
882
897
|
handleTab(e4) {
|
|
883
898
|
if ("Tab" !== e4.key) return false;
|
|
884
899
|
if (e4.metaKey || e4.ctrlKey || e4.altKey) return false;
|
|
885
900
|
if (e4.preventDefault(), e4.shiftKey) return true;
|
|
886
|
-
const t3 = this.getState(), n3 =
|
|
901
|
+
const t3 = this.getState(), n3 = We(t3, " ");
|
|
887
902
|
return this.dispatch(n3), true;
|
|
888
903
|
}
|
|
889
904
|
handleEscape(e4) {
|
|
@@ -893,14 +908,14 @@ class zt {
|
|
|
893
908
|
this.element.removeEventListener("keydown", this.handleKeydown);
|
|
894
909
|
}
|
|
895
910
|
}
|
|
896
|
-
function
|
|
911
|
+
function Xt(e4) {
|
|
897
912
|
const t3 = [];
|
|
898
913
|
(e4.metaKey || e4.ctrlKey) && t3.push("Mod"), e4.shiftKey && t3.push("Shift"), e4.altKey && t3.push("Alt");
|
|
899
914
|
let n3 = e4.key;
|
|
900
915
|
return " " === n3 ? n3 = "Space" : 1 === n3.length && (n3 = n3.toUpperCase()), t3.push(n3), t3.join("-");
|
|
901
916
|
}
|
|
902
|
-
let
|
|
903
|
-
class
|
|
917
|
+
let Yt;
|
|
918
|
+
class Zt {
|
|
904
919
|
constructor(e4, t3) {
|
|
905
920
|
this.element = e4, this.getState = t3.getState, this.dispatch = t3.dispatch, this.schemaRegistry = t3.schemaRegistry, this.syncSelection = t3.syncSelection, this.isReadOnly = t3.isReadOnly ?? (() => false), this.handleCopy = this.onCopy.bind(this), this.handleCut = this.onCut.bind(this), e4.addEventListener("copy", this.handleCopy), e4.addEventListener("cut", this.handleCut);
|
|
906
921
|
}
|
|
@@ -914,33 +929,33 @@ class Kt {
|
|
|
914
929
|
onCopy(e4) {
|
|
915
930
|
this.syncSelection?.();
|
|
916
931
|
const t3 = this.getState(), n3 = t3.selection;
|
|
917
|
-
if (
|
|
918
|
-
if (
|
|
932
|
+
if (re(n3)) return;
|
|
933
|
+
if (le(n3) && ae(n3)) return;
|
|
919
934
|
e4.preventDefault();
|
|
920
935
|
const s3 = e4.clipboardData;
|
|
921
|
-
s3 && (
|
|
936
|
+
s3 && (se(n3) ? this.writeNodeSelectionToClipboard(s3, t3) : this.writeTextSelectionToClipboard(s3, t3));
|
|
922
937
|
}
|
|
923
938
|
onCut(e4) {
|
|
924
939
|
if (this.isReadOnly()) return;
|
|
925
940
|
this.syncSelection?.();
|
|
926
941
|
const t3 = this.getState(), n3 = t3.selection;
|
|
927
|
-
if (
|
|
928
|
-
if (
|
|
942
|
+
if (re(n3)) return;
|
|
943
|
+
if (le(n3) && ae(n3)) return;
|
|
929
944
|
e4.preventDefault();
|
|
930
945
|
const s3 = e4.clipboardData;
|
|
931
|
-
if (s3) if (
|
|
946
|
+
if (s3) if (se(n3)) {
|
|
932
947
|
this.writeNodeSelectionToClipboard(s3, t3);
|
|
933
|
-
const e5 =
|
|
948
|
+
const e5 = Pe(t3, n3);
|
|
934
949
|
e5 && this.dispatch(e5);
|
|
935
950
|
} else {
|
|
936
951
|
this.writeTextSelectionToClipboard(s3, t3);
|
|
937
|
-
const e5 =
|
|
952
|
+
const e5 = De(t3);
|
|
938
953
|
e5 && this.dispatch(e5);
|
|
939
954
|
}
|
|
940
955
|
}
|
|
941
956
|
writeNodeSelectionToClipboard(e4, t3) {
|
|
942
957
|
const n3 = t3.selection;
|
|
943
|
-
if (!
|
|
958
|
+
if (!se(n3)) return;
|
|
944
959
|
const s3 = t3.getBlock(n3.nodeId);
|
|
945
960
|
if (!s3) return;
|
|
946
961
|
const r2 = { type: s3.type, ...s3.attrs ? { attrs: { ...s3.attrs } } : {} };
|
|
@@ -952,16 +967,16 @@ class Kt {
|
|
|
952
967
|
}
|
|
953
968
|
writeTextSelectionToClipboard(e4, t3) {
|
|
954
969
|
const n3 = t3.selection;
|
|
955
|
-
if (
|
|
956
|
-
if (
|
|
957
|
-
if (
|
|
958
|
-
const s3 = t3.getBlockOrder(), r2 =
|
|
970
|
+
if (se(n3)) return;
|
|
971
|
+
if (re(n3)) return;
|
|
972
|
+
if (ae(n3)) return;
|
|
973
|
+
const s3 = t3.getBlockOrder(), r2 = he(n3, s3), i9 = s3.indexOf(r2.from.blockId), o2 = s3.indexOf(r2.to.blockId), a20 = [], c11 = [];
|
|
959
974
|
for (let e5 = i9; e5 <= o2; e5++) {
|
|
960
975
|
const n4 = s3[e5];
|
|
961
976
|
if (!n4) continue;
|
|
962
977
|
const l4 = t3.getBlock(n4);
|
|
963
978
|
if (!l4) continue;
|
|
964
|
-
const h4 =
|
|
979
|
+
const h4 = H(l4), d6 = C(l4), p3 = e5 === i9 ? r2.from.offset : 0, u2 = e5 === o2 ? r2.to.offset : d6, f4 = h4.slice(p3, u2);
|
|
965
980
|
a20.push(f4), c11.push({ type: l4.type, text: f4, ...l4.attrs ? { attrs: { ...l4.attrs } } : {} });
|
|
966
981
|
}
|
|
967
982
|
const l3 = a20.join("\n");
|
|
@@ -972,23 +987,23 @@ class Kt {
|
|
|
972
987
|
if (!a21) continue;
|
|
973
988
|
const c12 = t3.getBlock(a21);
|
|
974
989
|
if (!c12) continue;
|
|
975
|
-
const l4 = e5 === i9 ? r2.from.offset : 0, h4 = e5 === o2 ? r2.to.offset :
|
|
990
|
+
const l4 = e5 === i9 ? r2.from.offset : 0, h4 = e5 === o2 ? r2.to.offset : C(c12);
|
|
976
991
|
n4.push(this.serializeBlockRangeToHTML(c12, l4, h4));
|
|
977
992
|
}
|
|
978
993
|
e4.setData("text/html", n4.join(""));
|
|
979
994
|
}
|
|
980
995
|
!(function(e5, t4) {
|
|
981
|
-
|
|
996
|
+
Yt = { plainText: e5, blocks: t4 };
|
|
982
997
|
})(l3, c11);
|
|
983
998
|
}
|
|
984
999
|
serializeBlockRangeToHTML(e4, t3, n3) {
|
|
985
|
-
const s3 =
|
|
1000
|
+
const s3 = S(e4), r2 = [];
|
|
986
1001
|
let i9 = 0;
|
|
987
1002
|
for (const e5 of s3) {
|
|
988
|
-
const s4 = i9 + (
|
|
1003
|
+
const s4 = i9 + (I(e5) ? 1 : e5.text.length);
|
|
989
1004
|
if (s4 <= t3 || i9 >= n3) i9 = s4;
|
|
990
1005
|
else {
|
|
991
|
-
if (
|
|
1006
|
+
if (N(e5)) {
|
|
992
1007
|
const s5 = Math.max(0, t3 - i9), o2 = Math.min(e5.text.length, n3 - i9), a20 = e5.text.slice(s5, o2);
|
|
993
1008
|
a20.length > 0 && r2.push(this.serializeTextWithMarks(a20, e5.marks));
|
|
994
1009
|
}
|
|
@@ -998,12 +1013,12 @@ class Kt {
|
|
|
998
1013
|
return r2.join("");
|
|
999
1014
|
}
|
|
1000
1015
|
serializeTextWithMarks(e4, t3) {
|
|
1001
|
-
if (0 === t3.length || !this.schemaRegistry) return
|
|
1016
|
+
if (0 === t3.length || !this.schemaRegistry) return ve(e4);
|
|
1002
1017
|
const n3 = [...t3].sort((e5, t4) => {
|
|
1003
1018
|
const n4 = this.schemaRegistry?.getMarkSpec(e5.type), s4 = this.schemaRegistry?.getMarkSpec(t4.type);
|
|
1004
1019
|
return (n4?.rank ?? 100) - (s4?.rank ?? 100);
|
|
1005
1020
|
});
|
|
1006
|
-
let s3 =
|
|
1021
|
+
let s3 = ve(e4);
|
|
1007
1022
|
for (const e5 of n3) {
|
|
1008
1023
|
const t4 = this.schemaRegistry?.getMarkSpec(e5.type);
|
|
1009
1024
|
t4?.toHTMLString && (s3 = t4.toHTMLString(e5, s3));
|
|
@@ -1014,7 +1029,7 @@ class Kt {
|
|
|
1014
1029
|
this.element.removeEventListener("copy", this.handleCopy), this.element.removeEventListener("cut", this.handleCut);
|
|
1015
1030
|
}
|
|
1016
1031
|
}
|
|
1017
|
-
class
|
|
1032
|
+
class en {
|
|
1018
1033
|
_composing = false;
|
|
1019
1034
|
_activeBlockId = null;
|
|
1020
1035
|
get isComposing() {
|
|
@@ -1030,7 +1045,7 @@ class Ft {
|
|
|
1030
1045
|
this._composing = false, this._activeBlockId = null;
|
|
1031
1046
|
}
|
|
1032
1047
|
}
|
|
1033
|
-
class
|
|
1048
|
+
class tn {
|
|
1034
1049
|
_contextKeymaps = [];
|
|
1035
1050
|
_navigationKeymaps = [];
|
|
1036
1051
|
_defaultKeymaps = [];
|
|
@@ -1068,7 +1083,7 @@ class Ut {
|
|
|
1068
1083
|
}
|
|
1069
1084
|
}
|
|
1070
1085
|
}
|
|
1071
|
-
class
|
|
1086
|
+
class nn {
|
|
1072
1087
|
_inputRules = [];
|
|
1073
1088
|
registerInputRule(e4) {
|
|
1074
1089
|
this._inputRules.push(e4);
|
|
@@ -1084,7 +1099,7 @@ class Wt {
|
|
|
1084
1099
|
this._inputRules.length = 0;
|
|
1085
1100
|
}
|
|
1086
1101
|
}
|
|
1087
|
-
class
|
|
1102
|
+
class sn {
|
|
1088
1103
|
_fileHandlers = [];
|
|
1089
1104
|
registerFileHandler(e4, t3) {
|
|
1090
1105
|
this._fileHandlers.push({ pattern: e4, handler: t3 });
|
|
@@ -1094,7 +1109,7 @@ class Vt {
|
|
|
1094
1109
|
}
|
|
1095
1110
|
matchFileHandlers(e4) {
|
|
1096
1111
|
const t3 = [];
|
|
1097
|
-
for (const n3 of this._fileHandlers)
|
|
1112
|
+
for (const n3 of this._fileHandlers) rn(n3.pattern, e4) && t3.push(n3.handler);
|
|
1098
1113
|
return t3;
|
|
1099
1114
|
}
|
|
1100
1115
|
removeFileHandler(e4) {
|
|
@@ -1105,7 +1120,7 @@ class Vt {
|
|
|
1105
1120
|
this._fileHandlers.length = 0;
|
|
1106
1121
|
}
|
|
1107
1122
|
}
|
|
1108
|
-
function
|
|
1123
|
+
function rn(e4, t3) {
|
|
1109
1124
|
if ("*" === e4 || "*/*" === e4) return true;
|
|
1110
1125
|
if (e4 === t3) return true;
|
|
1111
1126
|
if (e4.endsWith("/*")) {
|
|
@@ -1114,7 +1129,7 @@ function Gt(e4, t3) {
|
|
|
1114
1129
|
}
|
|
1115
1130
|
return false;
|
|
1116
1131
|
}
|
|
1117
|
-
class
|
|
1132
|
+
class on {
|
|
1118
1133
|
_nodeViews = /* @__PURE__ */ new Map();
|
|
1119
1134
|
registerNodeView(e4, t3) {
|
|
1120
1135
|
if (this._nodeViews.has(e4)) throw new Error(`NodeView for type "${e4}" is already registered.`);
|
|
@@ -1130,7 +1145,7 @@ class qt {
|
|
|
1130
1145
|
this._nodeViews.clear();
|
|
1131
1146
|
}
|
|
1132
1147
|
}
|
|
1133
|
-
class
|
|
1148
|
+
class an {
|
|
1134
1149
|
_toolbarItems = /* @__PURE__ */ new Map();
|
|
1135
1150
|
_toolbarItemPluginMap = /* @__PURE__ */ new Map();
|
|
1136
1151
|
registerToolbarItem(e4, t3) {
|
|
@@ -1168,7 +1183,7 @@ class Jt {
|
|
|
1168
1183
|
this._toolbarItems.clear(), this._toolbarItemPluginMap.clear();
|
|
1169
1184
|
}
|
|
1170
1185
|
}
|
|
1171
|
-
class
|
|
1186
|
+
class cn {
|
|
1172
1187
|
_entries = /* @__PURE__ */ new Map();
|
|
1173
1188
|
registerBlockTypePickerEntry(e4) {
|
|
1174
1189
|
if (this._entries.has(e4.id)) throw new Error(`BlockTypePickerEntry with id "${e4.id}" is already registered.`);
|
|
@@ -1184,7 +1199,7 @@ class Qt {
|
|
|
1184
1199
|
this._entries.clear();
|
|
1185
1200
|
}
|
|
1186
1201
|
}
|
|
1187
|
-
function
|
|
1202
|
+
function ln(e4, t3) {
|
|
1188
1203
|
if (t3) {
|
|
1189
1204
|
const n3 = t3.getMarkSpec(e4.type);
|
|
1190
1205
|
if (n3) return n3.rank ?? 100;
|
|
@@ -1200,7 +1215,7 @@ function Xt(e4, t3) {
|
|
|
1200
1215
|
return 100;
|
|
1201
1216
|
}
|
|
1202
1217
|
}
|
|
1203
|
-
function
|
|
1218
|
+
function hn(e4, t3) {
|
|
1204
1219
|
if (t3) {
|
|
1205
1220
|
const n3 = t3.getMarkSpec(e4.type);
|
|
1206
1221
|
if (n3) return n3.toDOM(e4);
|
|
@@ -1216,7 +1231,7 @@ function Yt(e4, t3) {
|
|
|
1216
1231
|
return document.createElement("span");
|
|
1217
1232
|
}
|
|
1218
1233
|
}
|
|
1219
|
-
class
|
|
1234
|
+
class dn {
|
|
1220
1235
|
wrapperElement = null;
|
|
1221
1236
|
container;
|
|
1222
1237
|
registry;
|
|
@@ -1231,21 +1246,21 @@ class Zt {
|
|
|
1231
1246
|
const t3 = e4.storedMarks;
|
|
1232
1247
|
if (!t3 || 0 === t3.length) return;
|
|
1233
1248
|
const n3 = e4.selection;
|
|
1234
|
-
if (
|
|
1235
|
-
if (!
|
|
1249
|
+
if (se(n3) || re(n3)) return;
|
|
1250
|
+
if (!ae(n3)) return;
|
|
1236
1251
|
const s3 = document.createElement("span");
|
|
1237
1252
|
s3.setAttribute("data-cursor-wrapper", "");
|
|
1238
1253
|
const r2 = document.createTextNode("");
|
|
1239
1254
|
let i9 = r2;
|
|
1240
|
-
const o2 = [...t3].sort((e5, t4) =>
|
|
1255
|
+
const o2 = [...t3].sort((e5, t4) => ln(e5, this.registry) - ln(t4, this.registry));
|
|
1241
1256
|
for (let e5 = o2.length - 1; e5 >= 0; e5--) {
|
|
1242
1257
|
const t4 = o2[e5];
|
|
1243
1258
|
if (!t4) continue;
|
|
1244
|
-
const n4 =
|
|
1259
|
+
const n4 = hn(t4, this.registry);
|
|
1245
1260
|
n4.appendChild(i9), i9 = n4;
|
|
1246
1261
|
}
|
|
1247
1262
|
s3.appendChild(i9);
|
|
1248
|
-
const a20 =
|
|
1263
|
+
const a20 = Ce(this.container);
|
|
1249
1264
|
if (a20 && 0 !== a20.rangeCount) {
|
|
1250
1265
|
a20.getRangeAt(0).insertNode(s3);
|
|
1251
1266
|
try {
|
|
@@ -1259,7 +1274,7 @@ class Zt {
|
|
|
1259
1274
|
this.wrapperElement && (this.wrapperElement.remove(), this.wrapperElement = null);
|
|
1260
1275
|
}
|
|
1261
1276
|
}
|
|
1262
|
-
class
|
|
1277
|
+
class pn {
|
|
1263
1278
|
listeners = /* @__PURE__ */ new Map();
|
|
1264
1279
|
emit(e4, t3) {
|
|
1265
1280
|
const n3 = this.listeners.get(e4.id);
|
|
@@ -1285,21 +1300,21 @@ class en {
|
|
|
1285
1300
|
this.listeners.clear();
|
|
1286
1301
|
}
|
|
1287
1302
|
}
|
|
1288
|
-
class
|
|
1303
|
+
class un {
|
|
1289
1304
|
plugins = /* @__PURE__ */ new Map();
|
|
1290
1305
|
commands = /* @__PURE__ */ new Map();
|
|
1291
1306
|
services = /* @__PURE__ */ new Map();
|
|
1292
1307
|
middlewares = [];
|
|
1293
1308
|
registrations = /* @__PURE__ */ new Map();
|
|
1294
|
-
eventBus = new
|
|
1309
|
+
eventBus = new pn();
|
|
1295
1310
|
pluginStyleSheets = [];
|
|
1296
|
-
schemaRegistry = new
|
|
1297
|
-
keymapRegistry = new
|
|
1298
|
-
inputRuleRegistry = new
|
|
1299
|
-
fileHandlerRegistry = new
|
|
1300
|
-
nodeViewRegistry = new
|
|
1301
|
-
toolbarRegistry = new
|
|
1302
|
-
blockTypePickerRegistry = new
|
|
1311
|
+
schemaRegistry = new xt();
|
|
1312
|
+
keymapRegistry = new tn();
|
|
1313
|
+
inputRuleRegistry = new nn();
|
|
1314
|
+
fileHandlerRegistry = new sn();
|
|
1315
|
+
nodeViewRegistry = new on();
|
|
1316
|
+
toolbarRegistry = new an();
|
|
1317
|
+
blockTypePickerRegistry = new cn();
|
|
1303
1318
|
middlewareSorted = null;
|
|
1304
1319
|
initOrder = [];
|
|
1305
1320
|
initialized = false;
|
|
@@ -1351,7 +1366,7 @@ class tn {
|
|
|
1351
1366
|
}
|
|
1352
1367
|
}
|
|
1353
1368
|
collectDecorations(e4, t3) {
|
|
1354
|
-
let n3 =
|
|
1369
|
+
let n3 = et.empty;
|
|
1355
1370
|
for (const s3 of this.initOrder) {
|
|
1356
1371
|
const r2 = this.plugins.get(s3);
|
|
1357
1372
|
if (r2?.decorations) try {
|
|
@@ -1577,32 +1592,32 @@ class tn {
|
|
|
1577
1592
|
return r2;
|
|
1578
1593
|
}
|
|
1579
1594
|
}
|
|
1580
|
-
const
|
|
1581
|
-
function
|
|
1595
|
+
const fn = { label: "Print", tooltip: (e4) => `Print (${e4})`, printingAnnouncement: "Printing" }, gn = { en: fn, de: { label: "Drucken", tooltip: (e4) => `Drucken (${e4})`, printingAnnouncement: "Druckvorgang" }, es: { label: "Imprimir", tooltip: (e4) => `Imprimir (${e4})`, printingAnnouncement: "Imprimiendo" }, fr: { label: "Imprimer", tooltip: (e4) => `Imprimer (${e4})`, printingAnnouncement: "Impression" }, zh: { label: "打印", tooltip: (e4) => `打印 (${e4})`, printingAnnouncement: "正在打印" }, ru: { label: "Печать", tooltip: (e4) => `Печать (${e4})`, printingAnnouncement: "Печать" }, ar: { label: "طباعة", tooltip: (e4) => `طباعة (${e4})`, printingAnnouncement: "جارٍ الطباعة" }, hi: { label: "प्रिंट", tooltip: (e4) => `प्रिंट (${e4})`, printingAnnouncement: "प्रिंट हो रहा है" } };
|
|
1596
|
+
function mn(e4) {
|
|
1582
1597
|
return "function" == typeof e4 ? e4() : e4;
|
|
1583
1598
|
}
|
|
1584
|
-
const
|
|
1585
|
-
function
|
|
1586
|
-
return Math.round(e4 *
|
|
1599
|
+
const yn = 96 / 25.4, kn = { DINA4: "din-a4", DINA5: "din-a5", USLetter: "us-letter", USLegal: "us-legal" };
|
|
1600
|
+
function bn(e4) {
|
|
1601
|
+
return Math.round(e4 * yn);
|
|
1587
1602
|
}
|
|
1588
|
-
const
|
|
1589
|
-
function
|
|
1590
|
-
const t3 =
|
|
1603
|
+
const vn = /* @__PURE__ */ new Map([[kn.DINA4, { widthMm: 210, heightMm: 297, widthPx: bn(210), heightPx: bn(297) }], [kn.DINA5, { widthMm: 148, heightMm: 210, widthPx: bn(148), heightPx: bn(210) }], [kn.USLetter, { widthMm: 215.9, heightMm: 279.4, widthPx: bn(215.9), heightPx: bn(279.4) }], [kn.USLegal, { widthMm: 215.9, heightMm: 355.6, widthPx: bn(215.9), heightPx: bn(355.6) }]]), wn = /* @__PURE__ */ new Map([[kn.DINA4, "A4"], [kn.DINA5, "A5"], [kn.USLetter, "letter"], [kn.USLegal, "legal"]]);
|
|
1604
|
+
function Sn(e4) {
|
|
1605
|
+
const t3 = vn.get(e4);
|
|
1591
1606
|
if (!t3) throw new Error(`Unknown paper size: ${e4}`);
|
|
1592
1607
|
return t3;
|
|
1593
1608
|
}
|
|
1594
|
-
const
|
|
1595
|
-
function
|
|
1596
|
-
return Object.values(
|
|
1609
|
+
const En = 48, xn = 56, Tn = 24;
|
|
1610
|
+
function Cn(e4) {
|
|
1611
|
+
return Object.values(kn).includes(e4);
|
|
1597
1612
|
}
|
|
1598
|
-
function
|
|
1599
|
-
const t3 =
|
|
1613
|
+
function Rn(e4) {
|
|
1614
|
+
const t3 = wn.get(e4);
|
|
1600
1615
|
if (!t3) throw new Error(`Unknown paper size: ${e4}`);
|
|
1601
1616
|
return t3;
|
|
1602
1617
|
}
|
|
1603
|
-
const
|
|
1618
|
+
const An = new Qe("print"), Ln = new Je("print:before"), In = new Je("print:after"), Mn = { print() {
|
|
1604
1619
|
}, toHTML: () => "" };
|
|
1605
|
-
class
|
|
1620
|
+
class Nn {
|
|
1606
1621
|
id = "print";
|
|
1607
1622
|
name = "Print";
|
|
1608
1623
|
config;
|
|
@@ -1612,7 +1627,7 @@ class Sn {
|
|
|
1612
1627
|
this.config = e4 ?? {};
|
|
1613
1628
|
}
|
|
1614
1629
|
init(e4) {
|
|
1615
|
-
this.locale =
|
|
1630
|
+
this.locale = Xe(gn, e4, this.config.locale);
|
|
1616
1631
|
const t3 = e4.getContainer(), n3 = t3.getRootNode();
|
|
1617
1632
|
if (n3 instanceof ShadowRoot) {
|
|
1618
1633
|
const s4 = n3.host, r3 = e4.getEventBus();
|
|
@@ -1622,7 +1637,7 @@ class Sn {
|
|
|
1622
1637
|
}
|
|
1623
1638
|
function i10(r5) {
|
|
1624
1639
|
const i11 = { options: r5, cancelled: false };
|
|
1625
|
-
if (s5.emit(
|
|
1640
|
+
if (s5.emit(Ln, i11), i11.cancelled) return null;
|
|
1626
1641
|
const o3 = i11.options, a20 = (function(e6, t5, n5, s6 = "en") {
|
|
1627
1642
|
return ["<!DOCTYPE html>", `<html lang="${s6}">`, "<head>", '<meta charset="utf-8">', `<title>${n5.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</title>`, `<style>${e6}</style>`, "</head>", `<body>${t5}</body>`, "</html>"].join("\n");
|
|
1628
1643
|
})((function(e6, t5, n5) {
|
|
@@ -1658,7 +1673,7 @@ ${s7.join("\n")}
|
|
|
1658
1673
|
const o4 = (function(e7) {
|
|
1659
1674
|
const t6 = [], n6 = [];
|
|
1660
1675
|
if (e7.margin ? n6.push(` margin: ${e7.margin};`) : e7.paperSize && n6.push(" margin: 0;"), e7.paperSize || e7.orientation) {
|
|
1661
|
-
const t7 = [e7.paperSize ?
|
|
1676
|
+
const t7 = [e7.paperSize ? Rn(e7.paperSize) : "A4"];
|
|
1662
1677
|
e7.orientation && t7.push(e7.orientation), n6.push(` size: ${t7.join(" ")};`);
|
|
1663
1678
|
}
|
|
1664
1679
|
n6.length > 0 && t6.push(`@page {
|
|
@@ -1694,15 +1709,15 @@ ${n6.join("\n")}
|
|
|
1694
1709
|
})(n5, t5), (function(e7, t6) {
|
|
1695
1710
|
if (t6.header) {
|
|
1696
1711
|
const n6 = document.createElement("div");
|
|
1697
|
-
n6.className = "notectl-print-header", n6.innerHTML =
|
|
1712
|
+
n6.className = "notectl-print-header", n6.innerHTML = mn(t6.header), e7.insertBefore(n6, e7.firstChild);
|
|
1698
1713
|
}
|
|
1699
1714
|
if (t6.footer) {
|
|
1700
1715
|
const n6 = document.createElement("div");
|
|
1701
|
-
n6.className = "notectl-print-footer", n6.innerHTML =
|
|
1716
|
+
n6.className = "notectl-print-footer", n6.innerHTML = mn(t6.footer), e7.appendChild(n6);
|
|
1702
1717
|
}
|
|
1703
1718
|
})(n5, t5), n5;
|
|
1704
1719
|
})(n4, o3).outerHTML, o3.title ?? "", t4.closest("[lang]")?.getAttribute("lang") ?? (document.documentElement.lang || "en")), c11 = { html: a20 };
|
|
1705
|
-
return s5.emit(
|
|
1720
|
+
return s5.emit(In, c11), a20;
|
|
1706
1721
|
}
|
|
1707
1722
|
return { print(e6) {
|
|
1708
1723
|
const t5 = i10(r4(e6));
|
|
@@ -1718,13 +1733,13 @@ ${n6.join("\n")}
|
|
|
1718
1733
|
n5.contentWindow ? (n5.contentWindow.addEventListener("afterprint", o3, { once: true }), n5.contentWindow.print()) : o3();
|
|
1719
1734
|
}, toHTML: (e6) => i10(r4(e6)) ?? "" };
|
|
1720
1735
|
})(n3, s4, t3, r3);
|
|
1721
|
-
} else this.service =
|
|
1722
|
-
e4.registerService(
|
|
1736
|
+
} else this.service = Mn;
|
|
1737
|
+
e4.registerService(An, this.service);
|
|
1723
1738
|
const s3 = this.config.defaults ?? {}, r2 = this.service, i9 = this.locale;
|
|
1724
1739
|
e4.registerCommand("print", () => (e4.announce(i9.printingAnnouncement), r2.print(s3), true));
|
|
1725
1740
|
const o2 = this.config.keyBinding ?? "Mod-P";
|
|
1726
1741
|
if (e4.registerKeymap({ [o2]: () => (e4.executeCommand("print"), true) }), false !== this.config.showToolbarItem) {
|
|
1727
|
-
const t4 =
|
|
1742
|
+
const t4 = rt(o2);
|
|
1728
1743
|
e4.registerToolbarItem({ id: "print", group: "actions", label: this.locale.label, tooltip: this.locale.tooltip(t4), 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 });
|
|
1729
1744
|
}
|
|
1730
1745
|
}
|
|
@@ -1732,23 +1747,23 @@ ${n6.join("\n")}
|
|
|
1732
1747
|
this.service = null;
|
|
1733
1748
|
}
|
|
1734
1749
|
}
|
|
1735
|
-
const
|
|
1736
|
-
function
|
|
1750
|
+
const Bn = { Light: "light", Dark: "dark", System: "system" }, On = { 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" } }, _n = { 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" } };
|
|
1751
|
+
function Pn(e4, t3) {
|
|
1737
1752
|
return { name: t3.name, primitives: { ...e4.primitives, ...t3.primitives }, toolbar: t3.toolbar ? { ...e4.toolbar, ...t3.toolbar } : e4.toolbar, codeBlock: t3.codeBlock ? { ...e4.codeBlock, ...t3.codeBlock } : e4.codeBlock, tooltip: t3.tooltip ? { ...e4.tooltip, ...t3.tooltip } : e4.tooltip };
|
|
1738
1753
|
}
|
|
1739
|
-
function
|
|
1754
|
+
function Dn(e4) {
|
|
1740
1755
|
if ("object" == typeof e4) return e4;
|
|
1741
1756
|
switch (e4) {
|
|
1742
|
-
case
|
|
1743
|
-
return
|
|
1744
|
-
case
|
|
1745
|
-
return
|
|
1757
|
+
case Bn.Light:
|
|
1758
|
+
return On;
|
|
1759
|
+
case Bn.Dark:
|
|
1760
|
+
return _n;
|
|
1746
1761
|
default:
|
|
1747
|
-
return
|
|
1762
|
+
return On;
|
|
1748
1763
|
}
|
|
1749
1764
|
}
|
|
1750
|
-
const
|
|
1751
|
-
function
|
|
1765
|
+
const Hn = [["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"]], zn = /* @__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)"]]);
|
|
1766
|
+
function jn(e4, t3) {
|
|
1752
1767
|
const n3 = t3.split(".");
|
|
1753
1768
|
let s3 = e4;
|
|
1754
1769
|
for (const e5 of n3) {
|
|
@@ -1758,26 +1773,26 @@ function Ln(e4, t3) {
|
|
|
1758
1773
|
}
|
|
1759
1774
|
return "string" == typeof s3 ? s3 : void 0;
|
|
1760
1775
|
}
|
|
1761
|
-
function
|
|
1776
|
+
function $n(e4) {
|
|
1762
1777
|
const t3 = [":host {"];
|
|
1763
|
-
for (const [n3, s3] of
|
|
1764
|
-
const r2 =
|
|
1778
|
+
for (const [n3, s3] of Hn) {
|
|
1779
|
+
const r2 = jn(e4, n3);
|
|
1765
1780
|
if (void 0 !== r2) t3.push(` ${s3}: ${r2};`);
|
|
1766
1781
|
else {
|
|
1767
|
-
const e5 =
|
|
1782
|
+
const e5 = zn.get(s3);
|
|
1768
1783
|
e5 && t3.push(` ${s3}: ${e5};`);
|
|
1769
1784
|
}
|
|
1770
1785
|
}
|
|
1771
1786
|
return t3.push("}"), t3.join("\n");
|
|
1772
1787
|
}
|
|
1773
|
-
function
|
|
1788
|
+
function Kn(e4) {
|
|
1774
1789
|
const t3 = new CSSStyleSheet();
|
|
1775
|
-
return t3.replaceSync(
|
|
1790
|
+
return t3.replaceSync($n(e4)), t3;
|
|
1776
1791
|
}
|
|
1777
|
-
const
|
|
1778
|
-
class
|
|
1792
|
+
const Fn = { EN: "en", DE: "de", ES: "es", FR: "fr", ZH: "zh", RU: "ru", AR: "ar", HI: "hi", BROWSER: "browser" };
|
|
1793
|
+
class Un {
|
|
1779
1794
|
constructor(e4, t3) {
|
|
1780
|
-
this.element = e4, this.getState = t3.getState, this.dispatch = t3.dispatch, this.syncSelection = t3.syncSelection, this.inputRuleRegistry = t3.inputRuleRegistry, this.isReadOnly = t3.isReadOnly ?? (() => false), this.compositionTracker = t3.compositionTracker ?? new
|
|
1795
|
+
this.element = e4, this.getState = t3.getState, this.dispatch = t3.dispatch, this.syncSelection = t3.syncSelection, this.inputRuleRegistry = t3.inputRuleRegistry, this.isReadOnly = t3.isReadOnly ?? (() => false), this.compositionTracker = t3.compositionTracker ?? new en(), this.handleBeforeInput = this.onBeforeInput.bind(this), this.handleCompositionStart = this.onCompositionStart.bind(this), this.handleCompositionEnd = this.onCompositionEnd.bind(this), e4.addEventListener("beforeinput", this.handleBeforeInput), e4.addEventListener("compositionstart", this.handleCompositionStart), e4.addEventListener("compositionend", this.handleCompositionEnd);
|
|
1781
1796
|
}
|
|
1782
1797
|
getState;
|
|
1783
1798
|
dispatch;
|
|
@@ -1796,81 +1811,81 @@ class Nn {
|
|
|
1796
1811
|
let n3 = null;
|
|
1797
1812
|
switch (e4.inputType) {
|
|
1798
1813
|
case "insertText":
|
|
1799
|
-
e4.data && (n3 =
|
|
1814
|
+
e4.data && (n3 = We(t3, e4.data, "input"));
|
|
1800
1815
|
break;
|
|
1801
1816
|
case "insertParagraph":
|
|
1802
|
-
n3 =
|
|
1817
|
+
n3 = Ke(t3);
|
|
1803
1818
|
break;
|
|
1804
1819
|
case "insertLineBreak":
|
|
1805
|
-
n3 =
|
|
1820
|
+
n3 = Ve(t3);
|
|
1806
1821
|
break;
|
|
1807
1822
|
case "deleteContentBackward":
|
|
1808
1823
|
case "deleteByCut":
|
|
1809
|
-
n3 =
|
|
1824
|
+
n3 = qt(t3);
|
|
1810
1825
|
break;
|
|
1811
1826
|
case "deleteContentForward":
|
|
1812
|
-
n3 =
|
|
1827
|
+
n3 = Jt(t3);
|
|
1813
1828
|
break;
|
|
1814
1829
|
case "deleteWordBackward":
|
|
1815
1830
|
n3 = (function(e5) {
|
|
1816
1831
|
const t4 = e5.selection;
|
|
1817
|
-
if (
|
|
1818
|
-
if (
|
|
1819
|
-
if (!
|
|
1832
|
+
if (se(t4)) return Pe(e5, t4);
|
|
1833
|
+
if (re(t4)) return null;
|
|
1834
|
+
if (!ae(t4)) return De(e5);
|
|
1820
1835
|
const n4 = e5.getBlock(t4.anchor.blockId);
|
|
1821
1836
|
if (!n4) return null;
|
|
1822
|
-
if (0 === t4.anchor.offset) return
|
|
1823
|
-
const s3 =
|
|
1824
|
-
return e5.transaction("input").deleteTextAt(n4.id, s3, t4.anchor.offset).setSelection(
|
|
1837
|
+
if (0 === t4.anchor.offset) return He(e5);
|
|
1838
|
+
const s3 = Y(n4, t4.anchor.offset);
|
|
1839
|
+
return e5.transaction("input").deleteTextAt(n4.id, s3, t4.anchor.offset).setSelection(ne(n4.id, s3)).build();
|
|
1825
1840
|
})(t3);
|
|
1826
1841
|
break;
|
|
1827
1842
|
case "deleteWordForward":
|
|
1828
1843
|
n3 = (function(e5) {
|
|
1829
1844
|
const t4 = e5.selection;
|
|
1830
|
-
if (
|
|
1831
|
-
if (
|
|
1832
|
-
if (!
|
|
1845
|
+
if (se(t4)) return Pe(e5, t4);
|
|
1846
|
+
if (re(t4)) return null;
|
|
1847
|
+
if (!ae(t4)) return De(e5);
|
|
1833
1848
|
const n4 = e5.getBlock(t4.anchor.blockId);
|
|
1834
1849
|
if (!n4) return null;
|
|
1835
|
-
const s3 =
|
|
1836
|
-
if (t4.anchor.offset === s3) return
|
|
1837
|
-
const r2 =
|
|
1838
|
-
return e5.transaction("input").deleteTextAt(n4.id, t4.anchor.offset, r2).setSelection(
|
|
1850
|
+
const s3 = C(n4);
|
|
1851
|
+
if (t4.anchor.offset === s3) return ze(e5);
|
|
1852
|
+
const r2 = X(n4, t4.anchor.offset);
|
|
1853
|
+
return e5.transaction("input").deleteTextAt(n4.id, t4.anchor.offset, r2).setSelection(ne(n4.id, t4.anchor.offset)).build();
|
|
1839
1854
|
})(t3);
|
|
1840
1855
|
break;
|
|
1841
1856
|
case "deleteSoftLineBackward":
|
|
1842
1857
|
n3 = (function(e5) {
|
|
1843
1858
|
const t4 = e5.selection;
|
|
1844
|
-
if (
|
|
1845
|
-
if (
|
|
1846
|
-
if (!
|
|
1859
|
+
if (se(t4)) return Pe(e5, t4);
|
|
1860
|
+
if (re(t4)) return null;
|
|
1861
|
+
if (!ae(t4)) return De(e5);
|
|
1847
1862
|
const n4 = e5.getBlock(t4.anchor.blockId);
|
|
1848
|
-
return n4 ? 0 === t4.anchor.offset ?
|
|
1863
|
+
return n4 ? 0 === t4.anchor.offset ? He(e5) : e5.transaction("input").deleteTextAt(n4.id, 0, t4.anchor.offset).setSelection(ne(n4.id, 0)).build() : null;
|
|
1849
1864
|
})(t3);
|
|
1850
1865
|
break;
|
|
1851
1866
|
case "deleteSoftLineForward":
|
|
1852
1867
|
n3 = (function(e5) {
|
|
1853
1868
|
const t4 = e5.selection;
|
|
1854
|
-
if (
|
|
1855
|
-
if (
|
|
1856
|
-
if (!
|
|
1869
|
+
if (se(t4)) return Pe(e5, t4);
|
|
1870
|
+
if (re(t4)) return null;
|
|
1871
|
+
if (!ae(t4)) return De(e5);
|
|
1857
1872
|
const n4 = e5.getBlock(t4.anchor.blockId);
|
|
1858
1873
|
if (!n4) return null;
|
|
1859
|
-
const s3 =
|
|
1860
|
-
return t4.anchor.offset === s3 ?
|
|
1874
|
+
const s3 = C(n4);
|
|
1875
|
+
return t4.anchor.offset === s3 ? ze(e5) : e5.transaction("input").deleteTextAt(n4.id, t4.anchor.offset, s3).setSelection(ne(n4.id, t4.anchor.offset)).build();
|
|
1861
1876
|
})(t3);
|
|
1862
1877
|
}
|
|
1863
1878
|
n3 && (this.dispatch(n3), "insertText" === e4.inputType && this.checkInputRules());
|
|
1864
1879
|
}
|
|
1865
1880
|
onCompositionStart(e4) {
|
|
1866
1881
|
const t3 = this.getState();
|
|
1867
|
-
|
|
1882
|
+
se(t3.selection) || re(t3.selection) || this.compositionTracker.start(t3.selection.anchor.blockId);
|
|
1868
1883
|
}
|
|
1869
1884
|
onCompositionEnd(e4) {
|
|
1870
1885
|
if (this.compositionTracker.end(), this.isReadOnly()) return;
|
|
1871
1886
|
const t3 = e4.data;
|
|
1872
1887
|
if (!t3) return;
|
|
1873
|
-
const n3 = this.getState(), s3 =
|
|
1888
|
+
const n3 = this.getState(), s3 = We(n3, t3, "input");
|
|
1874
1889
|
this.dispatch(s3);
|
|
1875
1890
|
}
|
|
1876
1891
|
checkInputRules() {
|
|
@@ -1878,10 +1893,10 @@ class Nn {
|
|
|
1878
1893
|
const e4 = this.inputRuleRegistry.getInputRules();
|
|
1879
1894
|
if (0 === e4.length) return;
|
|
1880
1895
|
const t3 = this.getState();
|
|
1881
|
-
if (
|
|
1896
|
+
if (se(t3.selection) || re(t3.selection)) return;
|
|
1882
1897
|
const { anchor: n3 } = t3.selection, s3 = t3.getBlock(n3.blockId);
|
|
1883
1898
|
if (!s3) return;
|
|
1884
|
-
const r2 =
|
|
1899
|
+
const r2 = H(s3).slice(0, n3.offset);
|
|
1885
1900
|
for (const n4 of e4) {
|
|
1886
1901
|
const e5 = n4.pattern.exec(r2);
|
|
1887
1902
|
if (e5) {
|
|
@@ -1894,36 +1909,36 @@ class Nn {
|
|
|
1894
1909
|
this.element.removeEventListener("beforeinput", this.handleBeforeInput), this.element.removeEventListener("compositionstart", this.handleCompositionStart), this.element.removeEventListener("compositionend", this.handleCompositionEnd);
|
|
1895
1910
|
}
|
|
1896
1911
|
}
|
|
1897
|
-
function
|
|
1912
|
+
function Wn(e4) {
|
|
1898
1913
|
return e4.reduce((e5, t3) => e5 + t3.text, "");
|
|
1899
1914
|
}
|
|
1900
|
-
function
|
|
1915
|
+
function Vn(e4) {
|
|
1901
1916
|
return e4.reduce((e5, t3) => e5 + t3.text.length, 0);
|
|
1902
1917
|
}
|
|
1903
|
-
function
|
|
1904
|
-
const n3 =
|
|
1918
|
+
function Gn(e4, t3) {
|
|
1919
|
+
const n3 = xe(e4.doc, t3.blockId);
|
|
1905
1920
|
if (!n3) return null;
|
|
1906
1921
|
const s3 = n3.length > 1 ? n3.slice(0, -1) : [], r2 = (0 === s3.length ? e4.doc.children : (() => {
|
|
1907
1922
|
const t4 = e4.getBlock(s3[s3.length - 1]);
|
|
1908
1923
|
return t4 ? t4.children : [];
|
|
1909
|
-
})()).findIndex((e5) =>
|
|
1924
|
+
})()).findIndex((e5) => L(e5) && e5.id === t3.blockId);
|
|
1910
1925
|
if (r2 < 0) return null;
|
|
1911
1926
|
const i9 = "before" === t3.side ? r2 : r2 + 1;
|
|
1912
1927
|
return { parentPath: s3, insertIndex: i9 };
|
|
1913
1928
|
}
|
|
1914
|
-
function
|
|
1915
|
-
const s3 =
|
|
1929
|
+
function qn(e4, t3, n3) {
|
|
1930
|
+
const s3 = Gn(e4, t3);
|
|
1916
1931
|
if (!s3) return e4.transaction("paste").setSelection(t3).build();
|
|
1917
1932
|
const r2 = e4.transaction("paste");
|
|
1918
1933
|
let i9, o2 = s3.insertIndex, a20 = 0;
|
|
1919
1934
|
for (const e5 of n3) {
|
|
1920
|
-
const t4 =
|
|
1935
|
+
const t4 = V(), n4 = Wn(e5.segments), c11 = e5.segments.map((e6) => M(e6.text, [...e6.marks])), l3 = R(e5.type, c11.length > 0 ? c11 : [M("")], t4, e5.attrs);
|
|
1921
1936
|
r2.insertNode(s3.parentPath, o2, l3), o2++, i9 = t4, a20 = n4.length;
|
|
1922
1937
|
}
|
|
1923
|
-
return i9 && r2.setSelection(
|
|
1938
|
+
return i9 && r2.setSelection(ne(i9, a20)), r2.build();
|
|
1924
1939
|
}
|
|
1925
|
-
const
|
|
1926
|
-
class
|
|
1940
|
+
const Jn = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "BLOCKQUOTE", "UL", "OL", "LI", "HR", "PRE", "TABLE", "THEAD", "TBODY", "TR"]), Qn = /* @__PURE__ */ new Set(["STRONG", "B", "EM", "I", "U", "S", "STRIKE", "DEL", "A", "SPAN", "BR", "SUB", "SUP", "CODE"]);
|
|
1941
|
+
class Xn {
|
|
1927
1942
|
schema;
|
|
1928
1943
|
blockParseRules;
|
|
1929
1944
|
markParseRules;
|
|
@@ -1932,7 +1947,7 @@ class $n {
|
|
|
1932
1947
|
}
|
|
1933
1948
|
parse(e4) {
|
|
1934
1949
|
const t3 = this.parseContainer(e4);
|
|
1935
|
-
return 0 === t3.length ? { blocks: [{ type: this.resolveBlockType(
|
|
1950
|
+
return 0 === t3.length ? { blocks: [{ type: this.resolveBlockType(me("paragraph")), segments: [{ text: "", marks: [] }] }] } : { blocks: t3 };
|
|
1936
1951
|
}
|
|
1937
1952
|
parseContainer(e4) {
|
|
1938
1953
|
const t3 = [];
|
|
@@ -1949,13 +1964,13 @@ class $n {
|
|
|
1949
1964
|
parseBlockElement(e4) {
|
|
1950
1965
|
const t3 = e4.tagName, n3 = /^H([1-6])$/.exec(t3);
|
|
1951
1966
|
if (n3) {
|
|
1952
|
-
const t4 = Number(n3[1]), s3 = this.resolveBlockType(
|
|
1953
|
-
return [{ type: s3, ...s3 ===
|
|
1967
|
+
const t4 = Number(n3[1]), s3 = this.resolveBlockType(me("heading"));
|
|
1968
|
+
return [{ type: s3, ...s3 === me("heading") ? { attrs: { level: t4 } } : {}, segments: this.ensureSegments(this.parseInlineChildren(e4, [])) }];
|
|
1954
1969
|
}
|
|
1955
1970
|
switch (t3) {
|
|
1956
1971
|
case "P":
|
|
1957
1972
|
case "DIV":
|
|
1958
|
-
return this.parseBlockWithLineBreaks(e4, this.resolveBlockType(
|
|
1973
|
+
return this.parseBlockWithLineBreaks(e4, this.resolveBlockType(me("paragraph")));
|
|
1959
1974
|
case "BLOCKQUOTE":
|
|
1960
1975
|
return this.parseBlockquote(e4);
|
|
1961
1976
|
case "UL":
|
|
@@ -1965,9 +1980,9 @@ class $n {
|
|
|
1965
1980
|
case "LI":
|
|
1966
1981
|
return this.parseListItem(e4, "bullet", 0);
|
|
1967
1982
|
case "HR":
|
|
1968
|
-
return [{ type: this.resolveBlockType(
|
|
1983
|
+
return [{ type: this.resolveBlockType(me("horizontal_rule")), segments: [] }];
|
|
1969
1984
|
case "PRE":
|
|
1970
|
-
return [{ type: this.resolveBlockType(
|
|
1985
|
+
return [{ type: this.resolveBlockType(me("paragraph")), segments: this.ensureSegments(this.parsePreContent(e4)) }];
|
|
1971
1986
|
case "TABLE":
|
|
1972
1987
|
case "THEAD":
|
|
1973
1988
|
case "TBODY":
|
|
@@ -1975,12 +1990,12 @@ class $n {
|
|
|
1975
1990
|
return this.parseTableAsParagraphs(e4);
|
|
1976
1991
|
default: {
|
|
1977
1992
|
const t4 = this.matchBlockRule(e4);
|
|
1978
|
-
return t4 ? [{ type: t4.type, ...t4.attrs ? { attrs: t4.attrs } : {}, segments: this.ensureSegments(this.parseInlineChildren(e4, [])) }] : [{ type: this.resolveBlockType(
|
|
1993
|
+
return t4 ? [{ type: t4.type, ...t4.attrs ? { attrs: t4.attrs } : {}, segments: this.ensureSegments(this.parseInlineChildren(e4, [])) }] : [{ type: this.resolveBlockType(me("paragraph")), segments: this.ensureSegments(this.parseInlineChildren(e4, [])) }];
|
|
1979
1994
|
}
|
|
1980
1995
|
}
|
|
1981
1996
|
}
|
|
1982
1997
|
parseBlockquote(e4) {
|
|
1983
|
-
const t3 = this.resolveBlockType(
|
|
1998
|
+
const t3 = this.resolveBlockType(me("blockquote"));
|
|
1984
1999
|
return Array.from(e4.childNodes).some((e5) => e5.nodeType === Node.ELEMENT_NODE && this.isBlockElement(e5)) ? this.parseContainer(e4).map((e5) => ({ type: t3, segments: e5.segments })) : [{ type: t3, segments: this.ensureSegments(this.parseInlineChildren(e4, [])) }];
|
|
1985
2000
|
}
|
|
1986
2001
|
parseList(e4, t3, n3) {
|
|
@@ -1992,7 +2007,7 @@ class $n {
|
|
|
1992
2007
|
return s3;
|
|
1993
2008
|
}
|
|
1994
2009
|
parseListItem(e4, t3, n3) {
|
|
1995
|
-
const s3 = [], r2 = this.resolveBlockType(
|
|
2010
|
+
const s3 = [], r2 = this.resolveBlockType(me("list_item")), i9 = this.hasCheckbox(e4), o2 = i9 ? "checklist" : t3, a20 = !!i9 && this.isCheckboxChecked(e4), c11 = [], l3 = [];
|
|
1996
2011
|
for (const t4 of Array.from(e4.childNodes)) if (t4.nodeType === Node.ELEMENT_NODE) {
|
|
1997
2012
|
const e5 = t4;
|
|
1998
2013
|
"UL" === e5.tagName || "OL" === e5.tagName ? l3.push(e5) : "INPUT" === e5.tagName && "checkbox" === e5.getAttribute("type") || (this.isBlockElement(e5) ? c11.push(...this.parseInlineChildren(e5, [])) : c11.push(...this.parseInlineNode(t4, [])));
|
|
@@ -2020,7 +2035,7 @@ class $n {
|
|
|
2020
2035
|
if (e4.nodeType !== Node.ELEMENT_NODE) return [];
|
|
2021
2036
|
const n3 = e4, s3 = n3.tagName;
|
|
2022
2037
|
if ("BR" === s3) return [{ text: "\n", marks: this.resolveMarks(t3) }];
|
|
2023
|
-
if (this.isBlockElement(n3) && !
|
|
2038
|
+
if (this.isBlockElement(n3) && !Qn.has(s3)) return this.parseInlineChildren(n3, t3);
|
|
2024
2039
|
const r2 = this.mergeMarks(t3, this.marksFromElement(n3));
|
|
2025
2040
|
return this.parseInlineChildren(n3, r2);
|
|
2026
2041
|
}
|
|
@@ -2032,7 +2047,7 @@ class $n {
|
|
|
2032
2047
|
const t3 = [], n3 = e4.querySelectorAll("td, th");
|
|
2033
2048
|
for (const e5 of Array.from(n3)) {
|
|
2034
2049
|
const n4 = this.parseInlineChildren(e5, []);
|
|
2035
|
-
n4.length > 0 && n4.some((e6) => e6.text.length > 0) && t3.push({ type: this.resolveBlockType(
|
|
2050
|
+
n4.length > 0 && n4.some((e6) => e6.text.length > 0) && t3.push({ type: this.resolveBlockType(me("paragraph")), segments: this.ensureSegments(n4) });
|
|
2036
2051
|
}
|
|
2037
2052
|
return t3;
|
|
2038
2053
|
}
|
|
@@ -2043,18 +2058,18 @@ class $n {
|
|
|
2043
2058
|
for (const r2 of this.markParseRules) if (r2.rule.tag === n3 && !s4.has(r2.type)) if (r2.rule.getAttrs) {
|
|
2044
2059
|
const n4 = r2.rule.getAttrs(e4);
|
|
2045
2060
|
if (false === n4) continue;
|
|
2046
|
-
t3.push({ type:
|
|
2047
|
-
} else t3.push({ type:
|
|
2061
|
+
t3.push({ type: ye(r2.type), ...Object.keys(n4).length > 0 ? { attrs: n4 } : {} }), s4.add(r2.type);
|
|
2062
|
+
} else t3.push({ type: ye(r2.type) }), s4.add(r2.type);
|
|
2048
2063
|
if (s4.size > 0) return t3;
|
|
2049
2064
|
}
|
|
2050
2065
|
const s3 = e4.tagName;
|
|
2051
2066
|
if ("STRONG" === s3 || "B" === s3) {
|
|
2052
2067
|
const n4 = e4.style.fontWeight, s4 = Number.parseInt(n4, 10);
|
|
2053
|
-
"normal" === n4 || !Number.isNaN(s4) && s4 < 700 || t3.push({ type:
|
|
2068
|
+
"normal" === n4 || !Number.isNaN(s4) && s4 < 700 || t3.push({ type: ye("bold") });
|
|
2054
2069
|
}
|
|
2055
|
-
if ("EM" !== s3 && "I" !== s3 || t3.push({ type:
|
|
2070
|
+
if ("EM" !== s3 && "I" !== s3 || t3.push({ type: ye("italic") }), "U" === s3 && t3.push({ type: ye("underline") }), "S" !== s3 && "STRIKE" !== s3 && "DEL" !== s3 || t3.push({ type: ye("strikethrough") }), "A" === s3) {
|
|
2056
2071
|
const n4 = e4.getAttribute("href") ?? "";
|
|
2057
|
-
t3.push({ type:
|
|
2072
|
+
t3.push({ type: ye("link"), attrs: { href: n4 } });
|
|
2058
2073
|
}
|
|
2059
2074
|
return t3;
|
|
2060
2075
|
}
|
|
@@ -2064,17 +2079,17 @@ class $n {
|
|
|
2064
2079
|
return n3;
|
|
2065
2080
|
}
|
|
2066
2081
|
resolveMarks(e4) {
|
|
2067
|
-
return e4.filter((e5) =>
|
|
2082
|
+
return e4.filter((e5) => pe(this.schema, e5.type));
|
|
2068
2083
|
}
|
|
2069
2084
|
resolveBlockType(e4) {
|
|
2070
|
-
return
|
|
2085
|
+
return ue(this.schema, e4) ? e4 : me("paragraph");
|
|
2071
2086
|
}
|
|
2072
2087
|
normalizeSegments(e4) {
|
|
2073
2088
|
if (0 === e4.length) return [];
|
|
2074
2089
|
const t3 = [];
|
|
2075
2090
|
for (const n3 of e4) {
|
|
2076
2091
|
const e5 = t3[t3.length - 1];
|
|
2077
|
-
e5 &&
|
|
2092
|
+
e5 && J(e5.marks, n3.marks) ? t3[t3.length - 1] = { text: e5.text + n3.text, marks: e5.marks } : n3.text.length > 0 && t3.push(n3);
|
|
2078
2093
|
}
|
|
2079
2094
|
return t3;
|
|
2080
2095
|
}
|
|
@@ -2087,14 +2102,14 @@ class $n {
|
|
|
2087
2102
|
if (n3.rule.getAttrs) {
|
|
2088
2103
|
const t4 = n3.rule.getAttrs(e4);
|
|
2089
2104
|
if (false === t4) continue;
|
|
2090
|
-
return { type:
|
|
2105
|
+
return { type: me(n3.type), attrs: t4 };
|
|
2091
2106
|
}
|
|
2092
|
-
return { type:
|
|
2107
|
+
return { type: me(n3.type) };
|
|
2093
2108
|
}
|
|
2094
2109
|
return null;
|
|
2095
2110
|
}
|
|
2096
2111
|
isBlockElement(e4) {
|
|
2097
|
-
if (
|
|
2112
|
+
if (Jn.has(e4.tagName)) return true;
|
|
2098
2113
|
const t3 = e4.tagName.toLowerCase();
|
|
2099
2114
|
return this.blockParseRules.some((e5) => e5.rule.tag === t3);
|
|
2100
2115
|
}
|
|
@@ -2136,24 +2151,24 @@ class $n {
|
|
|
2136
2151
|
}
|
|
2137
2152
|
flushPendingSegments(e4, t3) {
|
|
2138
2153
|
const n3 = this.normalizeSegments(t3);
|
|
2139
|
-
0 !== n3.length && (n3.every((e5) => "" === e5.text.trim()) || e4.push({ type: this.resolveBlockType(
|
|
2154
|
+
0 !== n3.length && (n3.every((e5) => "" === e5.text.trim()) || e4.push({ type: this.resolveBlockType(me("paragraph")), segments: n3 }));
|
|
2140
2155
|
}
|
|
2141
2156
|
}
|
|
2142
|
-
const
|
|
2143
|
-
function
|
|
2157
|
+
const Yn = { 1: "x-small", 2: "small", 3: "medium", 4: "large", 5: "x-large", 6: "xx-large", 7: "xxx-large" };
|
|
2158
|
+
function Zn(e4) {
|
|
2144
2159
|
return e4.toLowerCase().includes("font-size");
|
|
2145
2160
|
}
|
|
2146
|
-
function
|
|
2161
|
+
function es(e4, t3) {
|
|
2147
2162
|
for (; e4.firstChild; ) t3.appendChild(e4.firstChild);
|
|
2148
2163
|
}
|
|
2149
|
-
function
|
|
2164
|
+
function ts(e4) {
|
|
2150
2165
|
const t3 = e4.parentNode;
|
|
2151
2166
|
if (t3) {
|
|
2152
2167
|
for (; e4.firstChild; ) t3.insertBefore(e4.firstChild, e4);
|
|
2153
2168
|
t3.removeChild(e4);
|
|
2154
2169
|
}
|
|
2155
2170
|
}
|
|
2156
|
-
function
|
|
2171
|
+
function ns(e4, t3) {
|
|
2157
2172
|
if (!t3) return;
|
|
2158
2173
|
const n3 = {};
|
|
2159
2174
|
let s3 = false;
|
|
@@ -2163,7 +2178,7 @@ function Wn(e4, t3) {
|
|
|
2163
2178
|
}
|
|
2164
2179
|
return s3 ? n3 : void 0;
|
|
2165
2180
|
}
|
|
2166
|
-
class
|
|
2181
|
+
class ss {
|
|
2167
2182
|
constructor(e4, t3) {
|
|
2168
2183
|
this.element = e4, this.getState = t3.getState, this.dispatch = t3.dispatch, this.schemaRegistry = t3.schemaRegistry, this.fileHandlerRegistry = t3.fileHandlerRegistry, this.isReadOnly = t3.isReadOnly ?? (() => false), this.handlePaste = this.onPaste.bind(this), e4.addEventListener("paste", this.handlePaste);
|
|
2169
2184
|
}
|
|
@@ -2183,7 +2198,7 @@ class Vn {
|
|
|
2183
2198
|
const s3 = t3.getData("text/plain");
|
|
2184
2199
|
if (s3) {
|
|
2185
2200
|
const e5 = (function(e6) {
|
|
2186
|
-
if (
|
|
2201
|
+
if (Yt && Yt.plainText === e6) return Yt.blocks;
|
|
2187
2202
|
})(s3);
|
|
2188
2203
|
if (e5 && this.handleRichPaste(e5)) return;
|
|
2189
2204
|
}
|
|
@@ -2197,78 +2212,78 @@ class Vn {
|
|
|
2197
2212
|
for (const e7 of t5) {
|
|
2198
2213
|
const t6 = e7.getAttribute("color"), n5 = e7.getAttribute("face"), s5 = e7.getAttribute("size"), r3 = e7.getAttribute("style") ?? "";
|
|
2199
2214
|
if (!(null !== t6 || null !== n5 || null !== s5 || r3.length > 0)) {
|
|
2200
|
-
|
|
2215
|
+
ts(e7);
|
|
2201
2216
|
continue;
|
|
2202
2217
|
}
|
|
2203
2218
|
const i10 = document.createElement("span"), o3 = [];
|
|
2204
|
-
if (r3 && o3.push(r3.endsWith(";") ? r3 : `${r3};`), t6 && o3.push(`color: ${t6};`), n5 && o3.push(`font-family: ${n5};`), s5 && !
|
|
2205
|
-
const e8 =
|
|
2219
|
+
if (r3 && o3.push(r3.endsWith(";") ? r3 : `${r3};`), t6 && o3.push(`color: ${t6};`), n5 && o3.push(`font-family: ${n5};`), s5 && !Zn(r3)) {
|
|
2220
|
+
const e8 = Yn[s5];
|
|
2206
2221
|
e8 && o3.push(`font-size: ${e8};`);
|
|
2207
2222
|
}
|
|
2208
|
-
i10.setAttribute("style", o3.join(" ")),
|
|
2223
|
+
i10.setAttribute("style", o3.join(" ")), es(e7, i10), e7.parentNode?.replaceChild(i10, e7);
|
|
2209
2224
|
}
|
|
2210
2225
|
})(t4.content);
|
|
2211
|
-
const n4 = t4.innerHTML, s4 = this.schemaRegistry ? this.schemaRegistry.getAllowedTags() : ["strong", "em", "u", "b", "i", "p", "br", "div", "span"], o2 = this.schemaRegistry ? this.schemaRegistry.getAllowedAttrs() : [], a20 =
|
|
2226
|
+
const n4 = t4.innerHTML, s4 = this.schemaRegistry ? this.schemaRegistry.getAllowedTags() : ["strong", "em", "u", "b", "i", "p", "br", "div", "span"], o2 = this.schemaRegistry ? this.schemaRegistry.getAllowedAttrs() : [], a20 = St.sanitize(n4, { ALLOWED_TAGS: s4, ALLOWED_ATTR: o2 });
|
|
2212
2227
|
if (this.schemaRegistry) {
|
|
2213
|
-
const e6 =
|
|
2228
|
+
const e6 = fe(this.schemaRegistry), t5 = new Xn({ schema: e6, schemaRegistry: this.schemaRegistry }), n5 = document.createElement("template");
|
|
2214
2229
|
n5.innerHTML = a20;
|
|
2215
2230
|
const s5 = (function(e7, t6) {
|
|
2216
2231
|
if (0 === t6.blocks.length) return e7.transaction("paste").setSelection(e7.selection).build();
|
|
2217
2232
|
const n6 = t6.blocks[0];
|
|
2218
|
-
return n6 ? 1 === t6.blocks.length && n6.type ===
|
|
2233
|
+
return n6 ? 1 === t6.blocks.length && n6.type === me("paragraph") ? (function(e8, t7) {
|
|
2219
2234
|
const n7 = e8.selection;
|
|
2220
|
-
if (
|
|
2221
|
-
if (
|
|
2222
|
-
const s7 =
|
|
2235
|
+
if (se(n7)) return e8.transaction("paste").setSelection(n7).build();
|
|
2236
|
+
if (re(n7)) return (function(e9, t8, n8) {
|
|
2237
|
+
const s7 = Gn(e9, t8);
|
|
2223
2238
|
if (!s7) return e9.transaction("paste").setSelection(t8).build();
|
|
2224
|
-
const r4 =
|
|
2225
|
-
return a22.insertNode(s7.parentPath, s7.insertIndex,
|
|
2239
|
+
const r4 = V(), i11 = Wn(n8), o4 = Vn(n8), a22 = e9.transaction("paste");
|
|
2240
|
+
return a22.insertNode(s7.parentPath, s7.insertIndex, R(me("paragraph"), [M("")], r4)), i11.length > 0 && a22.insertText(r4, 0, i11, [], n8), a22.setSelection(ne(r4, o4)), a22.build();
|
|
2226
2241
|
})(e8, n7, t7);
|
|
2227
|
-
const s6 = e8.transaction("paste"), r3 =
|
|
2228
|
-
|
|
2229
|
-
const i10 = r3 ? r3.from.blockId : n7.anchor.blockId, o3 = r3 ? r3.from.offset : n7.anchor.offset, a21 =
|
|
2230
|
-
return s6.insertText(i10, o3, c11, [], t7), s6.setSelection(
|
|
2242
|
+
const s6 = e8.transaction("paste"), r3 = ae(n7) ? null : he(n7, e8.getBlockOrder());
|
|
2243
|
+
ae(n7) || Ge(e8, s6);
|
|
2244
|
+
const i10 = r3 ? r3.from.blockId : n7.anchor.blockId, o3 = r3 ? r3.from.offset : n7.anchor.offset, a21 = Vn(t7), c11 = Wn(t7);
|
|
2245
|
+
return s6.insertText(i10, o3, c11, [], t7), s6.setSelection(ne(i10, o3 + a21)), s6.build();
|
|
2231
2246
|
})(e7, n6.segments) : 1 === t6.blocks.length ? (function(e8, t7) {
|
|
2232
2247
|
const n7 = e8.selection;
|
|
2233
|
-
if (
|
|
2234
|
-
if (
|
|
2235
|
-
const s6 = e8.transaction("paste"), r3 =
|
|
2236
|
-
|
|
2237
|
-
const i10 = r3 ? r3.from.blockId : n7.anchor.blockId, o3 = r3 ? r3.from.offset : n7.anchor.offset, a21 =
|
|
2238
|
-
return s6.setBlockType(i10, t7.type, t7.attrs), s6.insertText(i10, o3, c11, [], t7.segments), s6.setSelection(
|
|
2248
|
+
if (se(n7)) return e8.transaction("paste").setSelection(n7).build();
|
|
2249
|
+
if (re(n7)) return qn(e8, n7, [t7]);
|
|
2250
|
+
const s6 = e8.transaction("paste"), r3 = ae(n7) ? null : he(n7, e8.getBlockOrder());
|
|
2251
|
+
ae(n7) || Ge(e8, s6);
|
|
2252
|
+
const i10 = r3 ? r3.from.blockId : n7.anchor.blockId, o3 = r3 ? r3.from.offset : n7.anchor.offset, a21 = Vn(t7.segments), c11 = Wn(t7.segments);
|
|
2253
|
+
return s6.setBlockType(i10, t7.type, t7.attrs), s6.insertText(i10, o3, c11, [], t7.segments), s6.setSelection(ne(i10, o3 + a21)), s6.build();
|
|
2239
2254
|
})(e7, n6) : (function(e8, t7) {
|
|
2240
2255
|
const n7 = e8.selection;
|
|
2241
|
-
if (
|
|
2242
|
-
if (
|
|
2243
|
-
const s6 = e8.transaction("paste"), r3 =
|
|
2244
|
-
|
|
2256
|
+
if (se(n7)) return e8.transaction("paste").setSelection(n7).build();
|
|
2257
|
+
if (re(n7)) return qn(e8, n7, t7.blocks);
|
|
2258
|
+
const s6 = e8.transaction("paste"), r3 = ae(n7) ? null : he(n7, e8.getBlockOrder());
|
|
2259
|
+
ae(n7) || Ge(e8, s6);
|
|
2245
2260
|
const i10 = r3 ? r3.from.blockId : n7.anchor.blockId, o3 = r3 ? r3.from.offset : n7.anchor.offset, a21 = e8.getBlockOrder().indexOf(i10), c11 = t7.blocks[0], l3 = t7.blocks[t7.blocks.length - 1];
|
|
2246
2261
|
if (!c11 || !l3) return s6.build();
|
|
2247
|
-
const h4 = t7.blocks.slice(1, -1),
|
|
2248
|
-
c11.segments.length > 0 &&
|
|
2249
|
-
const
|
|
2250
|
-
s6.splitBlock(i10,
|
|
2262
|
+
const h4 = t7.blocks.slice(1, -1), d6 = Vn(c11.segments);
|
|
2263
|
+
c11.segments.length > 0 && d6 > 0 && s6.insertText(i10, o3, Wn(c11.segments), [], c11.segments), c11.type !== me("paragraph") && s6.setBlockType(i10, c11.type, c11.attrs);
|
|
2264
|
+
const p3 = o3 + d6, u2 = V();
|
|
2265
|
+
s6.splitBlock(i10, p3, u2);
|
|
2251
2266
|
let f4 = a21 + 1;
|
|
2252
2267
|
for (const e9 of h4) {
|
|
2253
|
-
const t8 = e9.segments.map((e10) =>
|
|
2268
|
+
const t8 = e9.segments.map((e10) => M(e10.text, [...e10.marks])), n8 = R(e9.type, t8.length > 0 ? t8 : void 0, V(), e9.attrs);
|
|
2254
2269
|
s6.insertNode([], f4, n8), f4++;
|
|
2255
2270
|
}
|
|
2256
|
-
const g3 =
|
|
2257
|
-
return l3.segments.length > 0 && g3 > 0 && s6.insertText(
|
|
2271
|
+
const g3 = Vn(l3.segments);
|
|
2272
|
+
return l3.segments.length > 0 && g3 > 0 && s6.insertText(u2, 0, Wn(l3.segments), [], l3.segments), l3.type !== me("paragraph") && s6.setBlockType(u2, l3.type, l3.attrs), s6.setSelection(ne(u2, g3)), s6.build();
|
|
2258
2273
|
})(e7, t6) : e7.transaction("paste").setSelection(e7.selection).build();
|
|
2259
2274
|
})(r2, t5.parse(n5.content));
|
|
2260
2275
|
this.dispatch(s5);
|
|
2261
2276
|
} else {
|
|
2262
2277
|
const e6 = this.extractTextFromHTML(a20);
|
|
2263
2278
|
if (e6) {
|
|
2264
|
-
const t5 =
|
|
2279
|
+
const t5 = We(r2, e6, "paste");
|
|
2265
2280
|
this.dispatch(t5);
|
|
2266
2281
|
}
|
|
2267
2282
|
}
|
|
2268
2283
|
return;
|
|
2269
2284
|
}
|
|
2270
2285
|
if (s3) {
|
|
2271
|
-
const e5 =
|
|
2286
|
+
const e5 = We(this.getState(), s3, "paste");
|
|
2272
2287
|
this.dispatch(e5);
|
|
2273
2288
|
}
|
|
2274
2289
|
}
|
|
@@ -2283,22 +2298,22 @@ class Vn {
|
|
|
2283
2298
|
if (!n3) return;
|
|
2284
2299
|
const s3 = this.schemaRegistry?.getNodeSpec(n3);
|
|
2285
2300
|
if (this.schemaRegistry && !s3) return;
|
|
2286
|
-
const r2 = this.getState(), i9 = r2.selection, o2 =
|
|
2301
|
+
const r2 = this.getState(), i9 = r2.selection, o2 = se(i9) ? i9.nodeId : re(i9) ? i9.blockId : i9.anchor.blockId, a20 = V(), c11 = ns(t3.attrs, s3?.attrs), l3 = R(me(n3), [], a20, c11), h4 = this.findTableCellAncestor(r2, o2);
|
|
2287
2302
|
if (h4) {
|
|
2288
|
-
const e5 =
|
|
2303
|
+
const e5 = xe(r2.doc, h4);
|
|
2289
2304
|
if (!e5) return;
|
|
2290
2305
|
const t4 = r2.getBlock(h4);
|
|
2291
2306
|
if (!t4) return;
|
|
2292
2307
|
const n4 = r2.transaction("paste");
|
|
2293
|
-
return n4.insertNode(e5, t4.children.length, l3), n4.setSelection(
|
|
2308
|
+
return n4.insertNode(e5, t4.children.length, l3), n4.setSelection(te(a20, [...e5, a20])), void this.dispatch(n4.build());
|
|
2294
2309
|
}
|
|
2295
|
-
const
|
|
2296
|
-
const e5 = r2.getBlock(
|
|
2310
|
+
const d6 = xe(r2.doc, o2), p3 = d6 && d6.length > 1 ? d6.slice(0, -1) : [], u2 = (0 === p3.length ? r2.doc.children : (() => {
|
|
2311
|
+
const e5 = r2.getBlock(p3[p3.length - 1]);
|
|
2297
2312
|
return e5 ? e5.children : [];
|
|
2298
|
-
})()).findIndex((e5) =>
|
|
2299
|
-
if (
|
|
2300
|
-
const f4 =
|
|
2301
|
-
g3.insertNode(
|
|
2313
|
+
})()).findIndex((e5) => L(e5) && e5.id === o2);
|
|
2314
|
+
if (u2 < 0) return;
|
|
2315
|
+
const f4 = re(i9) && "before" === i9.side ? 0 : 1, g3 = r2.transaction("paste");
|
|
2316
|
+
g3.insertNode(p3, u2 + f4, l3), g3.setSelection(te(a20, [...p3, a20])), this.dispatch(g3.build());
|
|
2302
2317
|
}
|
|
2303
2318
|
handleRichPasteFromJson(e4) {
|
|
2304
2319
|
let t3;
|
|
@@ -2312,56 +2327,56 @@ class Vn {
|
|
|
2312
2327
|
handleRichPaste(e4) {
|
|
2313
2328
|
if (0 === e4.length) return false;
|
|
2314
2329
|
if (!e4.some((e5) => void 0 !== e5.type && "paragraph" !== e5.type)) return false;
|
|
2315
|
-
const t3 = this.getState(), n3 = t3.selection, s3 =
|
|
2330
|
+
const t3 = this.getState(), n3 = t3.selection, s3 = se(n3) ? n3.nodeId : re(n3) ? n3.blockId : n3.anchor.blockId, r2 = this.findTableCellAncestor(t3, s3);
|
|
2316
2331
|
return r2 ? this.insertRichBlocksIntoCell(e4, t3, s3, r2) : this.insertRichBlocksAtRoot(e4, t3, s3);
|
|
2317
2332
|
}
|
|
2318
2333
|
insertRichBlocksIntoCell(e4, t3, n3, s3) {
|
|
2319
|
-
const r2 =
|
|
2334
|
+
const r2 = xe(t3.doc, s3);
|
|
2320
2335
|
if (!r2) return false;
|
|
2321
2336
|
const i9 = t3.getBlock(s3);
|
|
2322
2337
|
if (!i9) return false;
|
|
2323
|
-
const o2 = t3.getBlock(n3), a20 = i9.children.findIndex((e5) =>
|
|
2338
|
+
const o2 = t3.getBlock(n3), a20 = i9.children.findIndex((e5) => L(e5) && e5.id === n3), c11 = void 0 !== o2 && "paragraph" === o2.type && "" === H(o2);
|
|
2324
2339
|
let l3 = a20 >= 0 ? a20 + 1 : i9.children.length;
|
|
2325
2340
|
const h4 = t3.transaction("paste");
|
|
2326
|
-
let
|
|
2341
|
+
let d6, p3 = 0;
|
|
2327
2342
|
for (const t4 of e4) {
|
|
2328
2343
|
const e5 = this.validateRichBlockData(t4);
|
|
2329
2344
|
if (!e5) continue;
|
|
2330
|
-
const n4 =
|
|
2331
|
-
h4.insertNode(r2, l3, a21), l3++,
|
|
2345
|
+
const n4 = V(), s4 = e5.text ?? "", i10 = s4 ? [M(s4)] : void 0, o3 = e5.attrs ? e5.attrs : void 0, a21 = R(me(e5.type), i10, n4, o3);
|
|
2346
|
+
h4.insertNode(r2, l3, a21), l3++, d6 = n4, p3 = s4.length;
|
|
2332
2347
|
}
|
|
2333
|
-
return c11 && a20 >= 0 && h4.removeNode(r2, a20),
|
|
2348
|
+
return c11 && a20 >= 0 && h4.removeNode(r2, a20), d6 && h4.setSelection(ne(d6, p3)), this.dispatch(h4.build()), true;
|
|
2334
2349
|
}
|
|
2335
2350
|
insertRichBlocksAtRoot(e4, t3, n3) {
|
|
2336
|
-
const s3 =
|
|
2351
|
+
const s3 = xe(t3.doc, n3), r2 = s3 && s3.length > 1 ? s3.slice(0, -1) : [], i9 = (0 === r2.length ? t3.doc.children : (() => {
|
|
2337
2352
|
const e5 = t3.getBlock(r2[r2.length - 1]);
|
|
2338
2353
|
return e5 ? e5.children : [];
|
|
2339
|
-
})()).findIndex((e5) =>
|
|
2354
|
+
})()).findIndex((e5) => L(e5) && e5.id === n3);
|
|
2340
2355
|
if (i9 < 0) return false;
|
|
2341
|
-
const o2 = t3.getBlock(n3), a20 = void 0 !== o2 && "paragraph" === o2.type && "" ===
|
|
2342
|
-
let l3 = i9 + (
|
|
2356
|
+
const o2 = t3.getBlock(n3), a20 = void 0 !== o2 && "paragraph" === o2.type && "" === H(o2), c11 = t3.selection;
|
|
2357
|
+
let l3 = i9 + (re(c11) && "before" === c11.side ? 0 : 1);
|
|
2343
2358
|
const h4 = t3.transaction("paste");
|
|
2344
|
-
let
|
|
2359
|
+
let d6, p3 = 0;
|
|
2345
2360
|
for (const t4 of e4) {
|
|
2346
2361
|
const e5 = this.validateRichBlockData(t4);
|
|
2347
2362
|
if (!e5) continue;
|
|
2348
|
-
const n4 =
|
|
2349
|
-
h4.insertNode(r2, l3, a21), l3++,
|
|
2363
|
+
const n4 = V(), s4 = e5.text ?? "", i10 = s4 ? [M(s4)] : void 0, o3 = e5.attrs ? e5.attrs : void 0, a21 = R(me(e5.type), i10, n4, o3);
|
|
2364
|
+
h4.insertNode(r2, l3, a21), l3++, d6 = n4, p3 = s4.length;
|
|
2350
2365
|
}
|
|
2351
|
-
return a20 && !
|
|
2366
|
+
return a20 && !re(c11) && h4.removeNode(r2, i9), d6 && h4.setSelection(ne(d6, p3)), this.dispatch(h4.build()), true;
|
|
2352
2367
|
}
|
|
2353
2368
|
validateRichBlockData(e4) {
|
|
2354
2369
|
if (!e4.type) return;
|
|
2355
2370
|
if (!this.schemaRegistry) return e4;
|
|
2356
2371
|
const t3 = this.schemaRegistry.getNodeSpec(e4.type);
|
|
2357
2372
|
if (!t3) return;
|
|
2358
|
-
const n3 =
|
|
2373
|
+
const n3 = ns(e4.attrs, t3.attrs);
|
|
2359
2374
|
return { ...e4, attrs: n3 };
|
|
2360
2375
|
}
|
|
2361
2376
|
findTableCellAncestor(e4, t3) {
|
|
2362
2377
|
const n3 = e4.getBlock(t3);
|
|
2363
2378
|
if ("table_cell" === n3?.type) return t3;
|
|
2364
|
-
const s3 =
|
|
2379
|
+
const s3 = xe(e4.doc, t3);
|
|
2365
2380
|
if (s3) for (const t4 of s3) {
|
|
2366
2381
|
const n4 = e4.getBlock(t4);
|
|
2367
2382
|
if ("table_cell" === n4?.type) return t4;
|
|
@@ -2405,7 +2420,7 @@ class Vn {
|
|
|
2405
2420
|
this.element.removeEventListener("paste", this.handlePaste);
|
|
2406
2421
|
}
|
|
2407
2422
|
}
|
|
2408
|
-
function
|
|
2423
|
+
function rs(e4, t3, n3, s3) {
|
|
2409
2424
|
const r2 = t3?.doc.children ?? [], i9 = n3.doc.children, o2 = s3?.registry, a20 = s3?.nodeViews, c11 = null != s3?.compositionBlockId;
|
|
2410
2425
|
c11 || (function(e5) {
|
|
2411
2426
|
const t4 = Array.from(e5.querySelectorAll(":scope > [data-block-wrapper]"));
|
|
@@ -2424,73 +2439,73 @@ function Gn(e4, t3, n3, s3) {
|
|
|
2424
2439
|
return t5;
|
|
2425
2440
|
})(e4)) {
|
|
2426
2441
|
const e5 = t4.getAttribute("data-block-id");
|
|
2427
|
-
e5 && l3.set(
|
|
2442
|
+
e5 && l3.set(ge(e5), t4);
|
|
2428
2443
|
}
|
|
2429
2444
|
const h4 = new Set(i9.map((e5) => e5.id));
|
|
2430
2445
|
for (const [e5, t4] of l3) if (!h4.has(e5)) {
|
|
2431
|
-
|
|
2446
|
+
gs(t4), l3.delete(e5);
|
|
2432
2447
|
const n4 = a20?.get(e5);
|
|
2433
2448
|
n4 && (n4.destroy?.(), a20?.delete(e5));
|
|
2434
2449
|
}
|
|
2435
|
-
const
|
|
2436
|
-
for (const e5 of r2)
|
|
2437
|
-
let
|
|
2438
|
-
const
|
|
2450
|
+
const d6 = /* @__PURE__ */ new Map();
|
|
2451
|
+
for (const e5 of r2) d6.set(e5.id, e5);
|
|
2452
|
+
let p3 = null;
|
|
2453
|
+
const u2 = s3?.selectedNodeId, f4 = s3?.previousSelectedNodeId;
|
|
2439
2454
|
for (const t4 of i9) {
|
|
2440
|
-
const n4 = l3.get(t4.id), r3 =
|
|
2455
|
+
const n4 = l3.get(t4.id), r3 = d6.get(t4.id);
|
|
2441
2456
|
if (s3?.compositionBlockId === t4.id && n4) {
|
|
2442
|
-
|
|
2457
|
+
p3 = n4;
|
|
2443
2458
|
continue;
|
|
2444
2459
|
}
|
|
2445
2460
|
const i10 = s3?.oldDecorations?.find(t4.id), c12 = s3?.decorations?.find(t4.id);
|
|
2446
|
-
if (n4 && r3 && !
|
|
2461
|
+
if (n4 && r3 && !is(r3, t4, i10, c12)) p3 = n4;
|
|
2447
2462
|
else if (n4) {
|
|
2448
2463
|
const r4 = a20?.get(t4.id);
|
|
2449
2464
|
if (r4) {
|
|
2450
2465
|
if (r4.update?.(t4)) {
|
|
2451
|
-
if (
|
|
2466
|
+
if (W(t4) && r4.contentDOM) {
|
|
2452
2467
|
r4.contentDOM.textContent = "";
|
|
2453
2468
|
const e5 = s3?.decorations?.findInline(t4.id);
|
|
2454
|
-
|
|
2469
|
+
as(r4.contentDOM, t4, o2, e5);
|
|
2455
2470
|
}
|
|
2456
|
-
|
|
2471
|
+
p3 = r4.dom;
|
|
2457
2472
|
continue;
|
|
2458
2473
|
}
|
|
2459
2474
|
r4.destroy?.(), a20?.delete(t4.id);
|
|
2460
2475
|
}
|
|
2461
|
-
const i11 =
|
|
2462
|
-
|
|
2476
|
+
const i11 = os(t4, o2, a20, s3);
|
|
2477
|
+
ms(n4, i11, e4), p3 = i11;
|
|
2463
2478
|
} else {
|
|
2464
|
-
const n5 =
|
|
2465
|
-
|
|
2479
|
+
const n5 = os(t4, o2, a20, s3);
|
|
2480
|
+
ys(e4, p3, n5), p3 = n5;
|
|
2466
2481
|
}
|
|
2467
|
-
if (
|
|
2482
|
+
if (u2 === t4.id) {
|
|
2468
2483
|
const e5 = a20?.get(t4.id);
|
|
2469
2484
|
if (e5) e5.selectNode?.();
|
|
2470
2485
|
else {
|
|
2471
|
-
const e6 = l3.get(t4.id) ??
|
|
2486
|
+
const e6 = l3.get(t4.id) ?? p3;
|
|
2472
2487
|
e6 instanceof HTMLElement && e6.classList.add("notectl-node-selected");
|
|
2473
2488
|
}
|
|
2474
2489
|
} else if (f4 === t4.id) {
|
|
2475
2490
|
const e5 = a20?.get(t4.id);
|
|
2476
2491
|
if (e5) e5.deselectNode?.();
|
|
2477
2492
|
else {
|
|
2478
|
-
const e6 = l3.get(t4.id) ??
|
|
2493
|
+
const e6 = l3.get(t4.id) ?? p3;
|
|
2479
2494
|
e6 instanceof HTMLElement && e6.classList.remove("notectl-node-selected");
|
|
2480
2495
|
}
|
|
2481
2496
|
}
|
|
2482
2497
|
}
|
|
2483
|
-
if (f4 && f4 !==
|
|
2498
|
+
if (f4 && f4 !== u2) {
|
|
2484
2499
|
const e5 = a20?.get(f4);
|
|
2485
2500
|
e5 && !h4.has(f4) && e5.deselectNode?.();
|
|
2486
2501
|
}
|
|
2487
|
-
if (
|
|
2488
|
-
const e5 = a20?.get(
|
|
2502
|
+
if (u2 && !h4.has(u2)) {
|
|
2503
|
+
const e5 = a20?.get(u2);
|
|
2489
2504
|
e5 && e5.selectNode?.();
|
|
2490
2505
|
}
|
|
2491
|
-
c11 ||
|
|
2506
|
+
c11 || fs(e4, i9, o2);
|
|
2492
2507
|
}
|
|
2493
|
-
function
|
|
2508
|
+
function is(e4, t3, n3, s3) {
|
|
2494
2509
|
if (e4.type !== t3.type) return true;
|
|
2495
2510
|
if (e4.children.length !== t3.children.length) return true;
|
|
2496
2511
|
const r2 = e4.attrs, i9 = t3.attrs;
|
|
@@ -2503,21 +2518,21 @@ function qn(e4, t3, n3, s3) {
|
|
|
2503
2518
|
for (let n4 = 0; n4 < e4.children.length; n4++) {
|
|
2504
2519
|
const s4 = e4.children[n4], r3 = t3.children[n4];
|
|
2505
2520
|
if (!s4 || !r3) return true;
|
|
2506
|
-
if (
|
|
2521
|
+
if (N(s4) && N(r3)) {
|
|
2507
2522
|
if (s4.text !== r3.text) return true;
|
|
2508
|
-
if (!
|
|
2509
|
-
} else if (
|
|
2523
|
+
if (!J(s4.marks, r3.marks)) return true;
|
|
2524
|
+
} else if (I(s4) && I(r3)) {
|
|
2510
2525
|
if (s4.inlineType !== r3.inlineType) return true;
|
|
2511
|
-
if (!
|
|
2526
|
+
if (!ds(s4.attrs, r3.attrs)) return true;
|
|
2512
2527
|
} else {
|
|
2513
|
-
if (
|
|
2514
|
-
if (
|
|
2528
|
+
if (N(s4) || N(r3) || I(s4) || I(r3)) return true;
|
|
2529
|
+
if (is(s4, r3)) return true;
|
|
2515
2530
|
}
|
|
2516
2531
|
}
|
|
2517
2532
|
const o2 = n3 ?? [], a20 = s3 ?? [];
|
|
2518
|
-
return o2 !== a20 && !
|
|
2533
|
+
return o2 !== a20 && !tt(o2, a20);
|
|
2519
2534
|
}
|
|
2520
|
-
function
|
|
2535
|
+
function os(e4, t3, n3, s3) {
|
|
2521
2536
|
const r2 = s3?.decorations?.findInline(e4.id), i9 = s3?.nodeViewRegistry;
|
|
2522
2537
|
if (i9 && t3 && n3 && s3?.getState && s3?.dispatch) {
|
|
2523
2538
|
const o2 = i9.getNodeViewFactory(e4.type);
|
|
@@ -2525,53 +2540,53 @@ function Jn(e4, t3, n3, s3) {
|
|
|
2525
2540
|
const i10 = o2(e4, s3.getState, s3.dispatch);
|
|
2526
2541
|
n3.set(e4.id, i10);
|
|
2527
2542
|
const a20 = t3.getNodeSpec(e4.type);
|
|
2528
|
-
if (a20?.isVoid && i10.dom.setAttribute("data-void", "true"), a20?.selectable && i10.dom.setAttribute("data-selectable", "true"), i10.contentDOM && i10.contentDOM !== i10.dom && i10.contentDOM.setAttribute("data-content-dom", "true"),
|
|
2543
|
+
if (a20?.isVoid && i10.dom.setAttribute("data-void", "true"), a20?.selectable && i10.dom.setAttribute("data-selectable", "true"), i10.contentDOM && i10.contentDOM !== i10.dom && i10.contentDOM.setAttribute("data-content-dom", "true"), W(e4) && i10.contentDOM) as(i10.contentDOM, e4, t3, r2);
|
|
2529
2544
|
else {
|
|
2530
|
-
const r3 =
|
|
2545
|
+
const r3 = Q(e4), o3 = /* @__PURE__ */ new Map();
|
|
2531
2546
|
for (const e5 of r3) {
|
|
2532
2547
|
const r4 = i10.getContentDOM?.(e5.id) ?? i10.contentDOM;
|
|
2533
2548
|
if (r4) {
|
|
2534
|
-
const i11 =
|
|
2549
|
+
const i11 = os(e5, t3, n3, s3);
|
|
2535
2550
|
r4.appendChild(i11);
|
|
2536
2551
|
let a21 = o3.get(r4);
|
|
2537
2552
|
a21 || (a21 = [], o3.set(r4, a21)), a21.push(e5);
|
|
2538
2553
|
}
|
|
2539
2554
|
}
|
|
2540
|
-
for (const [e5, n4] of o3)
|
|
2555
|
+
for (const [e5, n4] of o3) fs(e5, n4, t3);
|
|
2541
2556
|
}
|
|
2542
|
-
return i10.dom.setAttribute("data-block-type", e4.type),
|
|
2557
|
+
return i10.dom.setAttribute("data-block-type", e4.type), us(i10.dom, e4.id, s3), i10.dom;
|
|
2543
2558
|
}
|
|
2544
2559
|
}
|
|
2545
2560
|
if (t3) {
|
|
2546
2561
|
const i10 = t3.getNodeSpec(e4.type);
|
|
2547
2562
|
if (i10) {
|
|
2548
2563
|
const o2 = i10.toDOM(e4);
|
|
2549
|
-
if (i10.isVoid && o2.setAttribute("data-void", "true"), i10.selectable && o2.setAttribute("data-selectable", "true"), !i10.isVoid) if (
|
|
2564
|
+
if (i10.isVoid && o2.setAttribute("data-void", "true"), i10.selectable && o2.setAttribute("data-selectable", "true"), !i10.isVoid) if (W(e4)) as(o2, e4, t3, r2);
|
|
2550
2565
|
else {
|
|
2551
|
-
const r3 =
|
|
2566
|
+
const r3 = Q(e4);
|
|
2552
2567
|
for (const e5 of r3) {
|
|
2553
|
-
const r4 =
|
|
2568
|
+
const r4 = os(e5, t3, n3, s3);
|
|
2554
2569
|
o2.appendChild(r4);
|
|
2555
2570
|
}
|
|
2556
|
-
|
|
2571
|
+
fs(o2, r3, t3);
|
|
2557
2572
|
}
|
|
2558
|
-
return o2.setAttribute("data-block-type", e4.type),
|
|
2573
|
+
return o2.setAttribute("data-block-type", e4.type), us(o2, e4.id, s3), o2;
|
|
2559
2574
|
}
|
|
2560
2575
|
}
|
|
2561
2576
|
return (function(e5, t4, n4) {
|
|
2562
|
-
const s4 =
|
|
2563
|
-
return s4.setAttribute("data-block-type", e5.type),
|
|
2577
|
+
const s4 = be("p", e5.id);
|
|
2578
|
+
return s4.setAttribute("data-block-type", e5.type), as(s4, e5, t4, n4), s4;
|
|
2564
2579
|
})(e4, t3, r2);
|
|
2565
2580
|
}
|
|
2566
|
-
function
|
|
2581
|
+
function as(e4, t3, n3, s3) {
|
|
2567
2582
|
for (const t4 of e4.querySelectorAll("[data-cursor-wrapper]")) t4.remove();
|
|
2568
|
-
const r2 =
|
|
2569
|
-
if (1 === r2.length &&
|
|
2583
|
+
const r2 = S(t3);
|
|
2584
|
+
if (1 === r2.length && N(r2[0]) && "" === r2[0].text) return void e4.appendChild(document.createElement("br"));
|
|
2570
2585
|
if (s3 && 0 !== s3.length) !(function(e5, t4, n4, s4) {
|
|
2571
2586
|
let r3 = 0;
|
|
2572
2587
|
for (const i10 of t4) {
|
|
2573
|
-
if (
|
|
2574
|
-
e5.appendChild(
|
|
2588
|
+
if (I(i10)) {
|
|
2589
|
+
e5.appendChild(hs(i10, s4)), r3 += 1;
|
|
2575
2590
|
continue;
|
|
2576
2591
|
}
|
|
2577
2592
|
const t5 = r3, o2 = r3 + i10.text.length;
|
|
@@ -2589,50 +2604,50 @@ function Qn(e4, t3, n3, s3) {
|
|
|
2589
2604
|
for (let r4 = 0; r4 < c11.length - 1; r4++) {
|
|
2590
2605
|
const o3 = c11[r4], a21 = c11[r4 + 1];
|
|
2591
2606
|
if (void 0 === o3 || void 0 === a21 || o3 >= a21) continue;
|
|
2592
|
-
const l3 = o3 - t5, h4 = a21 - t5,
|
|
2593
|
-
for (const e6 of n4) e6.from <= o3 && e6.to >= a21 &&
|
|
2594
|
-
let
|
|
2607
|
+
const l3 = o3 - t5, h4 = a21 - t5, d6 = i10.text.slice(l3, h4), p3 = [];
|
|
2608
|
+
for (const e6 of n4) e6.from <= o3 && e6.to >= a21 && p3.push(e6);
|
|
2609
|
+
let u2 = document.createTextNode(cs(d6));
|
|
2595
2610
|
if (i10.marks.length > 0) {
|
|
2596
|
-
const e6 = [...i10.marks].sort((e7, t6) =>
|
|
2611
|
+
const e6 = [...i10.marks].sort((e7, t6) => ln(e7, s4) - ln(t6, s4));
|
|
2597
2612
|
for (let t6 = e6.length - 1; t6 >= 0; t6--) {
|
|
2598
2613
|
const n5 = e6[t6];
|
|
2599
2614
|
if (!n5) continue;
|
|
2600
|
-
const r5 =
|
|
2601
|
-
r5.appendChild(
|
|
2615
|
+
const r5 = hn(n5, s4);
|
|
2616
|
+
r5.appendChild(u2), u2 = r5;
|
|
2602
2617
|
}
|
|
2603
2618
|
}
|
|
2604
|
-
for (const e6 of
|
|
2605
|
-
const t6 =
|
|
2606
|
-
t6.appendChild(
|
|
2619
|
+
for (const e6 of p3) {
|
|
2620
|
+
const t6 = ps(e6.attrs);
|
|
2621
|
+
t6.appendChild(u2), u2 = t6;
|
|
2607
2622
|
}
|
|
2608
|
-
e5.appendChild(
|
|
2623
|
+
e5.appendChild(u2);
|
|
2609
2624
|
}
|
|
2610
2625
|
r3 = o2;
|
|
2611
2626
|
}
|
|
2612
2627
|
})(e4, r2, s3, n3);
|
|
2613
|
-
else for (const t4 of r2)
|
|
2628
|
+
else for (const t4 of r2) N(t4) ? e4.appendChild(ls(t4, n3)) : e4.appendChild(hs(t4, n3));
|
|
2614
2629
|
const i9 = r2[r2.length - 1];
|
|
2615
|
-
i9 &&
|
|
2630
|
+
i9 && I(i9) && "hard_break" === i9.inlineType && e4.appendChild(document.createElement("br"));
|
|
2616
2631
|
}
|
|
2617
|
-
function
|
|
2632
|
+
function cs(e4) {
|
|
2618
2633
|
let t3 = e4.replace(/ {2}/g, " ");
|
|
2619
2634
|
return t3.endsWith(" ") && (t3 = `${t3.slice(0, -1)} `), t3.startsWith(" ") && (t3 = ` ${t3.slice(1)}`), t3;
|
|
2620
2635
|
}
|
|
2621
|
-
function
|
|
2636
|
+
function ls(e4, t3) {
|
|
2622
2637
|
if ("" === e4.text) return document.createTextNode("");
|
|
2623
|
-
const n3 = document.createTextNode(
|
|
2638
|
+
const n3 = document.createTextNode(cs(e4.text));
|
|
2624
2639
|
if (0 === e4.marks.length) return n3;
|
|
2625
|
-
const s3 = [...e4.marks].sort((e5, n4) =>
|
|
2640
|
+
const s3 = [...e4.marks].sort((e5, n4) => ln(e5, t3) - ln(n4, t3));
|
|
2626
2641
|
let r2 = n3;
|
|
2627
2642
|
for (let e5 = s3.length - 1; e5 >= 0; e5--) {
|
|
2628
2643
|
const n4 = s3[e5];
|
|
2629
2644
|
if (!n4) continue;
|
|
2630
|
-
const i9 =
|
|
2645
|
+
const i9 = hn(n4, t3);
|
|
2631
2646
|
i9.appendChild(r2), r2 = i9;
|
|
2632
2647
|
}
|
|
2633
2648
|
return r2;
|
|
2634
2649
|
}
|
|
2635
|
-
function
|
|
2650
|
+
function hs(e4, t3) {
|
|
2636
2651
|
if (t3) {
|
|
2637
2652
|
const n4 = t3.getInlineNodeSpec(e4.inlineType);
|
|
2638
2653
|
if (n4) {
|
|
@@ -2643,20 +2658,20 @@ function Zn(e4, t3) {
|
|
|
2643
2658
|
const n3 = document.createElement("span");
|
|
2644
2659
|
return n3.setAttribute("data-inline-type", e4.inlineType), n3.setAttribute("contenteditable", "false"), n3;
|
|
2645
2660
|
}
|
|
2646
|
-
function
|
|
2661
|
+
function ds(e4, t3) {
|
|
2647
2662
|
const n3 = Object.keys(e4), s3 = Object.keys(t3);
|
|
2648
2663
|
if (n3.length !== s3.length) return false;
|
|
2649
2664
|
for (const s4 of n3) if (e4[s4] !== t3[s4]) return false;
|
|
2650
2665
|
return true;
|
|
2651
2666
|
}
|
|
2652
|
-
function
|
|
2667
|
+
function ps(e4) {
|
|
2653
2668
|
const t3 = e4.nodeName ?? "span", n3 = document.createElement(t3);
|
|
2654
2669
|
if (n3.setAttribute("data-decoration", "true"), e4.class) for (const t4 of e4.class.split(" ")) t4 && n3.classList.add(t4);
|
|
2655
2670
|
e4.style && (n3.style.cssText = e4.style);
|
|
2656
2671
|
for (const [t4, s3] of Object.entries(e4)) "class" !== t4 && "style" !== t4 && "nodeName" !== t4 && void 0 !== s3 && n3.setAttribute(t4, s3);
|
|
2657
2672
|
return n3;
|
|
2658
2673
|
}
|
|
2659
|
-
function
|
|
2674
|
+
function us(e4, t3, n3) {
|
|
2660
2675
|
const s3 = n3?.decorations?.findNode(t3);
|
|
2661
2676
|
if (s3 && 0 !== s3.length) for (const t4 of s3) {
|
|
2662
2677
|
if (t4.attrs.class) for (const n4 of t4.attrs.class.split(" ")) n4 && e4.classList.add(n4);
|
|
@@ -2666,7 +2681,7 @@ function ns(e4, t3, n3) {
|
|
|
2666
2681
|
}
|
|
2667
2682
|
}
|
|
2668
2683
|
}
|
|
2669
|
-
function
|
|
2684
|
+
function fs(e4, t3, n3) {
|
|
2670
2685
|
if (!n3) return;
|
|
2671
2686
|
const s3 = [];
|
|
2672
2687
|
let r2 = null, i9 = [];
|
|
@@ -2687,21 +2702,21 @@ function ss(e4, t3, n3) {
|
|
|
2687
2702
|
}
|
|
2688
2703
|
}
|
|
2689
2704
|
}
|
|
2690
|
-
function
|
|
2705
|
+
function gs(e4) {
|
|
2691
2706
|
e4.parentElement?.removeChild(e4);
|
|
2692
2707
|
}
|
|
2693
|
-
function
|
|
2708
|
+
function ms(e4, t3, n3) {
|
|
2694
2709
|
const s3 = e4.parentElement;
|
|
2695
2710
|
s3 ? s3.replaceChild(t3, e4) : n3.replaceChild(t3, e4);
|
|
2696
2711
|
}
|
|
2697
|
-
function
|
|
2712
|
+
function ys(e4, t3, n3) {
|
|
2698
2713
|
if (t3?.parentElement) {
|
|
2699
2714
|
const e5 = t3.parentElement;
|
|
2700
2715
|
return void (t3.nextSibling ? e5.insertBefore(n3, t3.nextSibling) : e5.appendChild(n3));
|
|
2701
2716
|
}
|
|
2702
2717
|
e4.firstChild ? e4.insertBefore(n3, e4.firstChild) : e4.appendChild(n3);
|
|
2703
2718
|
}
|
|
2704
|
-
class
|
|
2719
|
+
class ks {
|
|
2705
2720
|
state;
|
|
2706
2721
|
contentElement;
|
|
2707
2722
|
inputHandler;
|
|
@@ -2724,20 +2739,20 @@ class as {
|
|
|
2724
2739
|
fileHandlerRegistry;
|
|
2725
2740
|
nodeViewRegistry;
|
|
2726
2741
|
nodeViews = /* @__PURE__ */ new Map();
|
|
2727
|
-
decorations =
|
|
2742
|
+
decorations = et.empty;
|
|
2728
2743
|
getDecorations;
|
|
2729
2744
|
isReadOnly;
|
|
2730
2745
|
navigationKeymap = null;
|
|
2731
|
-
compositionTracker = new
|
|
2746
|
+
compositionTracker = new en();
|
|
2732
2747
|
cursorWrapper;
|
|
2733
2748
|
goalColumn = null;
|
|
2734
2749
|
preserveGoalColumn = false;
|
|
2735
2750
|
constructor(e4, t3) {
|
|
2736
|
-
this.state = t3.state, this.contentElement = e4, this.schemaRegistry = t3.schemaRegistry, this.keymapRegistry = t3.keymapRegistry, this.fileHandlerRegistry = t3.fileHandlerRegistry, this.nodeViewRegistry = t3.nodeViewRegistry, this.getDecorations = t3.getDecorations, this.isReadOnly = t3.isReadOnly ?? (() => false), this.history = new
|
|
2751
|
+
this.state = t3.state, this.contentElement = e4, this.schemaRegistry = t3.schemaRegistry, this.keymapRegistry = t3.keymapRegistry, this.fileHandlerRegistry = t3.fileHandlerRegistry, this.nodeViewRegistry = t3.nodeViewRegistry, this.getDecorations = t3.getDecorations, this.isReadOnly = t3.isReadOnly ?? (() => false), this.history = new Gt({ maxDepth: t3.maxHistoryDepth ?? 100 }), t3.onStateChange && this.stateChangeCallbacks.push(t3.onStateChange), this.inputHandler = new Un(e4, { getState: () => this.state, dispatch: (e5) => this.dispatch(e5), syncSelection: () => this.syncSelectionFromDOM(), inputRuleRegistry: t3.inputRuleRegistry, isReadOnly: this.isReadOnly, compositionTracker: this.compositionTracker }), this.keyboardHandler = new Qt(e4, { getState: () => this.state, dispatch: (e5) => this.dispatch(e5), undo: () => this.undo(), redo: () => this.redo(), keymapRegistry: this.keymapRegistry, isReadOnly: this.isReadOnly, compositionTracker: this.compositionTracker }), this.pasteHandler = new ss(e4, { getState: () => this.state, dispatch: (e5) => this.dispatch(e5), schemaRegistry: this.schemaRegistry, fileHandlerRegistry: this.fileHandlerRegistry, isReadOnly: this.isReadOnly }), this.clipboardHandler = new Zt(e4, { getState: () => this.state, dispatch: (e5) => this.dispatch(e5), schemaRegistry: this.schemaRegistry, syncSelection: () => this.syncSelectionFromDOM(), isReadOnly: this.isReadOnly }), this.cursorWrapper = new dn(e4, this.schemaRegistry), this.handleCompositionStartForWrapper = () => {
|
|
2737
2752
|
this.cursorWrapper.onCompositionStart(this.state);
|
|
2738
2753
|
}, this.handleCompositionEndForWrapper = () => {
|
|
2739
2754
|
this.cursorWrapper.cleanup();
|
|
2740
|
-
}, e4.addEventListener("compositionstart", this.handleCompositionStartForWrapper), e4.addEventListener("compositionend", this.handleCompositionEndForWrapper), this.handleSelectionChange = this.onSelectionChange.bind(this), document.addEventListener("selectionchange", this.handleSelectionChange), this.handleMousedown = this.onMousedown.bind(this), e4.addEventListener("mousedown", this.handleMousedown), this.handleDragover = this.onDragover.bind(this), e4.addEventListener("dragover", this.handleDragover), this.handleDrop = this.onDrop.bind(this), e4.addEventListener("drop", this.handleDrop), this.decorations = this.getDecorations?.(this.state) ??
|
|
2755
|
+
}, e4.addEventListener("compositionstart", this.handleCompositionStartForWrapper), e4.addEventListener("compositionend", this.handleCompositionEndForWrapper), this.handleSelectionChange = this.onSelectionChange.bind(this), document.addEventListener("selectionchange", this.handleSelectionChange), this.handleMousedown = this.onMousedown.bind(this), e4.addEventListener("mousedown", this.handleMousedown), this.handleDragover = this.onDragover.bind(this), e4.addEventListener("dragover", this.handleDragover), this.handleDrop = this.onDrop.bind(this), e4.addEventListener("drop", this.handleDrop), this.decorations = this.getDecorations?.(this.state) ?? et.empty, rs(e4, null, this.state, { ...this.reconcileOptions(), decorations: this.decorations }), Re(e4, this.state.selection), this.registerNavigationKeymaps();
|
|
2741
2756
|
}
|
|
2742
2757
|
getState() {
|
|
2743
2758
|
return this.state;
|
|
@@ -2748,8 +2763,8 @@ class as {
|
|
|
2748
2763
|
try {
|
|
2749
2764
|
const s3 = this.state;
|
|
2750
2765
|
this.state = e4, this.cursorWrapper.isActive && !e4.storedMarks?.length && this.cursorWrapper.cleanup(), n3?.pushHistory && "history" !== t3.metadata.origin && this.history.push(t3);
|
|
2751
|
-
const r2 = this.decorations, i9 = this.getDecorations?.(e4, t3) ??
|
|
2752
|
-
this.decorations = i9,
|
|
2766
|
+
const r2 = this.decorations, i9 = this.getDecorations?.(e4, t3) ?? et.empty;
|
|
2767
|
+
this.decorations = i9, rs(this.contentElement, s3, e4, { ...this.reconcileOptions(s3.selection), decorations: i9, oldDecorations: r2, compositionBlockId: this.compositionTracker.isComposing ? this.compositionTracker.activeBlockId ?? void 0 : void 0 }), this.compositionTracker.isComposing || Re(this.contentElement, e4.selection);
|
|
2753
2768
|
for (const n4 of this.stateChangeCallbacks) n4(s3, e4, t3);
|
|
2754
2769
|
this.preserveGoalColumn || (this.goalColumn = null);
|
|
2755
2770
|
} finally {
|
|
@@ -2783,8 +2798,8 @@ class as {
|
|
|
2783
2798
|
try {
|
|
2784
2799
|
const t3 = this.state;
|
|
2785
2800
|
this.state = e4, this.history.clear();
|
|
2786
|
-
const n3 = this.decorations, s3 = this.getDecorations?.(e4) ??
|
|
2787
|
-
this.decorations = s3,
|
|
2801
|
+
const n3 = this.decorations, s3 = this.getDecorations?.(e4) ?? et.empty;
|
|
2802
|
+
this.decorations = s3, rs(this.contentElement, t3, e4, { ...this.reconcileOptions(t3.selection), decorations: s3, oldDecorations: n3, compositionBlockId: this.compositionTracker.isComposing ? this.compositionTracker.activeBlockId ?? void 0 : void 0 }), this.compositionTracker.isComposing || Re(this.contentElement, e4.selection);
|
|
2788
2803
|
} finally {
|
|
2789
2804
|
this.isUpdating = false;
|
|
2790
2805
|
}
|
|
@@ -2792,12 +2807,12 @@ class as {
|
|
|
2792
2807
|
}
|
|
2793
2808
|
syncSelectionFromDOM() {
|
|
2794
2809
|
if (this.compositionTracker.isComposing) return;
|
|
2795
|
-
if (this.cursorWrapper.isActive && this.cursorWrapper.cleanup(),
|
|
2796
|
-
if (
|
|
2810
|
+
if (this.cursorWrapper.isActive && this.cursorWrapper.cleanup(), se(this.state.selection) && !this.pendingNodeSelectionClear) return;
|
|
2811
|
+
if (re(this.state.selection) && !this.pendingGapCursorClear) return;
|
|
2797
2812
|
this.pendingNodeSelectionClear = false, this.pendingGapCursorClear = false;
|
|
2798
|
-
const e4 =
|
|
2813
|
+
const e4 = Ae(this.contentElement);
|
|
2799
2814
|
if (!e4) return;
|
|
2800
|
-
if (
|
|
2815
|
+
if (ce(e4, this.state.selection)) return;
|
|
2801
2816
|
const t3 = this.state.transaction("input").setSelection(e4).setStoredMarks(null, this.state.storedMarks).build(), n3 = this.state.apply(t3);
|
|
2802
2817
|
this.applyUpdate(n3, t3);
|
|
2803
2818
|
}
|
|
@@ -2808,11 +2823,11 @@ class as {
|
|
|
2808
2823
|
if (!(t3 instanceof HTMLElement)) return;
|
|
2809
2824
|
const n3 = t3.closest("[data-block-id]");
|
|
2810
2825
|
if (!(n3 instanceof HTMLElement && this.contentElement.contains(n3))) return void ((this.contentElement.contains(t3) || t3 === this.contentElement) && this.handleClickBelowContent(e4));
|
|
2811
|
-
if (!n3.hasAttribute("data-void") && !n3.hasAttribute("data-selectable")) return
|
|
2826
|
+
if (!n3.hasAttribute("data-void") && !n3.hasAttribute("data-selectable")) return se(this.state.selection) && (this.pendingNodeSelectionClear = true), void (re(this.state.selection) && (this.pendingGapCursorClear = true));
|
|
2812
2827
|
const s3 = n3.querySelector("[data-content-dom]");
|
|
2813
|
-
if (s3?.contains(t3)) return
|
|
2828
|
+
if (s3?.contains(t3)) return se(this.state.selection) && (this.pendingNodeSelectionClear = true), void (re(this.state.selection) && (this.pendingGapCursorClear = true));
|
|
2814
2829
|
e4.preventDefault(), this.contentElement.focus();
|
|
2815
|
-
const r2 =
|
|
2830
|
+
const r2 = ge(n3.getAttribute("data-block-id") ?? ""), i9 = this.buildBlockPath(n3), o2 = te(r2, i9), a20 = this.state.transaction("input").setSelection(o2).setStoredMarks(null, this.state.storedMarks).build(), c11 = this.state.apply(a20);
|
|
2816
2831
|
this.applyUpdate(c11, a20);
|
|
2817
2832
|
}
|
|
2818
2833
|
handleClickBelowContent(e4) {
|
|
@@ -2824,18 +2839,18 @@ class as {
|
|
|
2824
2839
|
const r2 = s3.getBoundingClientRect();
|
|
2825
2840
|
if (e4.clientY <= r2.bottom) return;
|
|
2826
2841
|
const i9 = this.state.getBlock(n3);
|
|
2827
|
-
if ("paragraph" === i9?.type && 0 ===
|
|
2828
|
-
const t4 = this.state.transaction("input").setSelection(
|
|
2842
|
+
if ("paragraph" === i9?.type && 0 === C(i9)) {
|
|
2843
|
+
const t4 = this.state.transaction("input").setSelection(ne(n3, 0)).build();
|
|
2829
2844
|
return this.dispatch(t4), void e4.preventDefault();
|
|
2830
2845
|
}
|
|
2831
2846
|
e4.preventDefault(), this.contentElement.focus();
|
|
2832
|
-
const o2 =
|
|
2847
|
+
const o2 = V(), a20 = i9 ? C(i9) : 0, c11 = this.state.transaction("input").splitBlock(n3, a20, o2).setBlockType(o2, me("paragraph")).setSelection(ne(o2, 0)).build();
|
|
2833
2848
|
this.dispatch(c11);
|
|
2834
2849
|
}
|
|
2835
2850
|
buildBlockPath(e4) {
|
|
2836
2851
|
const t3 = [];
|
|
2837
2852
|
let n3 = e4;
|
|
2838
|
-
for (; n3 && n3 !== this.contentElement; ) n3.hasAttribute("data-block-id") && t3.unshift(
|
|
2853
|
+
for (; n3 && n3 !== this.contentElement; ) n3.hasAttribute("data-block-id") && t3.unshift(ge(n3.getAttribute("data-block-id") ?? "")), n3 = n3.parentElement;
|
|
2839
2854
|
return t3;
|
|
2840
2855
|
}
|
|
2841
2856
|
onDragover(e4) {
|
|
@@ -2862,8 +2877,8 @@ class as {
|
|
|
2862
2877
|
s3 && e4.preventDefault();
|
|
2863
2878
|
}
|
|
2864
2879
|
getPositionFromPoint(e4, t3) {
|
|
2865
|
-
const n3 = this.contentElement.getRootNode(), s3 =
|
|
2866
|
-
return s3 && this.contentElement.contains(s3.node) ?
|
|
2880
|
+
const n3 = this.contentElement.getRootNode(), s3 = Le(n3, e4, t3);
|
|
2881
|
+
return s3 && this.contentElement.contains(s3.node) ? Ie(this.contentElement, s3.node, s3.offset) : null;
|
|
2867
2882
|
}
|
|
2868
2883
|
onSelectionChange() {
|
|
2869
2884
|
if (this.isUpdating) return;
|
|
@@ -2871,7 +2886,7 @@ class as {
|
|
|
2871
2886
|
(this.contentElement.contains(t3) || t3 === this.contentElement) && this.syncSelectionFromDOM();
|
|
2872
2887
|
}
|
|
2873
2888
|
reconcileOptions(e4) {
|
|
2874
|
-
const t3 =
|
|
2889
|
+
const t3 = se(this.state.selection) ? this.state.selection.nodeId : void 0, n3 = e4 && se(e4) ? e4.nodeId : void 0;
|
|
2875
2890
|
return { registry: this.schemaRegistry, nodeViewRegistry: this.nodeViewRegistry, nodeViews: this.nodeViews, getState: () => this.state, dispatch: (e5) => this.dispatch(e5), selectedNodeId: t3, previousSelectedNodeId: n3 };
|
|
2876
2891
|
}
|
|
2877
2892
|
registerNavigationKeymaps() {
|
|
@@ -2881,32 +2896,32 @@ class as {
|
|
|
2881
2896
|
this.navigationKeymap = t3, this.keymapRegistry.registerKeymap(t3, { priority: "navigation" });
|
|
2882
2897
|
}
|
|
2883
2898
|
handleNavigationArrow(e4) {
|
|
2884
|
-
return !
|
|
2899
|
+
return !se(this.state.selection) && !re(this.state.selection) && !!ae(this.state.selection) && ("left" === e4 || "right" === e4 ? this.handleHorizontalArrow(e4) : this.handleVerticalArrow(e4));
|
|
2885
2900
|
}
|
|
2886
2901
|
handleHorizontalArrow(e4) {
|
|
2887
2902
|
this.goalColumn = null;
|
|
2888
|
-
const t3 = this.resolveLogicalHorizontalDirection(e4), n3 =
|
|
2903
|
+
const t3 = this.resolveLogicalHorizontalDirection(e4), n3 = Me(this.state, t3);
|
|
2889
2904
|
if (n3) return this.dispatch(n3), this.validateSelectionAfterInlineSkip(), true;
|
|
2890
|
-
if (!
|
|
2891
|
-
const s3 =
|
|
2905
|
+
if (!Ne(this.contentElement, this.state, e4)) return false;
|
|
2906
|
+
const s3 = Be(this.state, t3);
|
|
2892
2907
|
return !!s3 && (this.dispatch(s3), true);
|
|
2893
2908
|
}
|
|
2894
2909
|
resolveLogicalHorizontalDirection(e4) {
|
|
2895
2910
|
const t3 = this.state.selection;
|
|
2896
|
-
if (
|
|
2911
|
+
if (se(t3) || re(t3)) return e4;
|
|
2897
2912
|
const n3 = this.contentElement.querySelector(`[data-block-id="${t3.anchor.blockId}"]`);
|
|
2898
|
-
return n3 instanceof HTMLElement && "rtl" ===
|
|
2913
|
+
return n3 instanceof HTMLElement && "rtl" === qe(n3) ? "left" === e4 ? "right" : "left" : e4;
|
|
2899
2914
|
}
|
|
2900
2915
|
handleVerticalArrow(e4) {
|
|
2901
|
-
const t3 = this.contentElement.ownerDocument.getSelection?.() ?? null, n3 = t3 ?
|
|
2902
|
-
if (!
|
|
2916
|
+
const t3 = this.contentElement.ownerDocument.getSelection?.() ?? null, n3 = t3 ? Oe(t3) : null;
|
|
2917
|
+
if (!Ne(this.contentElement, this.state, e4, n3)) return false;
|
|
2903
2918
|
null === this.goalColumn && n3 && (this.goalColumn = n3.left), this.preserveGoalColumn = true;
|
|
2904
|
-
const s3 =
|
|
2919
|
+
const s3 = _e(this.contentElement, this.state, e4, this.goalColumn);
|
|
2905
2920
|
return s3 ? (this.dispatch(s3), this.preserveGoalColumn = false, true) : (this.preserveGoalColumn = false, false);
|
|
2906
2921
|
}
|
|
2907
2922
|
validateSelectionAfterInlineSkip() {
|
|
2908
|
-
const e4 =
|
|
2909
|
-
e4 &&
|
|
2923
|
+
const e4 = Ae(this.contentElement);
|
|
2924
|
+
e4 && ce(e4, this.state.selection) || Re(this.contentElement, this.state.selection);
|
|
2910
2925
|
}
|
|
2911
2926
|
destroy() {
|
|
2912
2927
|
this.cursorWrapper.cleanup(), this.inputHandler.destroy(), this.keyboardHandler.destroy(), this.pasteHandler.destroy(), this.clipboardHandler.destroy(), this.contentElement.removeEventListener("compositionstart", this.handleCompositionStartForWrapper), this.contentElement.removeEventListener("compositionend", this.handleCompositionEndForWrapper), document.removeEventListener("selectionchange", this.handleSelectionChange), this.contentElement.removeEventListener("mousedown", this.handleMousedown), this.contentElement.removeEventListener("dragover", this.handleDragover), this.contentElement.removeEventListener("drop", this.handleDrop), this.navigationKeymap && this.keymapRegistry && (this.keymapRegistry.removeKeymap(this.navigationKeymap), this.navigationKeymap = null);
|
|
@@ -2914,25 +2929,25 @@ class as {
|
|
|
2914
2929
|
this.nodeViews.clear();
|
|
2915
2930
|
}
|
|
2916
2931
|
}
|
|
2917
|
-
function
|
|
2932
|
+
function bs(e4, t3) {
|
|
2918
2933
|
const n3 = [];
|
|
2919
|
-
return
|
|
2934
|
+
return vs(e4, [], n3, t3?.getMarkParseRules() ?? []), n3.length > 0 ? n3 : [M("")];
|
|
2920
2935
|
}
|
|
2921
|
-
function
|
|
2936
|
+
function vs(e4, t3, n3, s3) {
|
|
2922
2937
|
if (e4.nodeType === Node.TEXT_NODE) {
|
|
2923
2938
|
const s4 = e4.textContent ?? "";
|
|
2924
|
-
return void (s4 && n3.push(
|
|
2939
|
+
return void (s4 && n3.push(M(s4, [...t3])));
|
|
2925
2940
|
}
|
|
2926
2941
|
if (e4.nodeType !== Node.ELEMENT_NODE) return;
|
|
2927
2942
|
const r2 = e4, i9 = r2.tagName.toLowerCase(), o2 = [...t3], a20 = /* @__PURE__ */ new Set();
|
|
2928
2943
|
for (const e5 of s3) if (e5.rule.tag === i9 && !a20.has(e5.type)) if (e5.rule.getAttrs) {
|
|
2929
2944
|
const t4 = e5.rule.getAttrs(r2);
|
|
2930
2945
|
if (false === t4) continue;
|
|
2931
|
-
o2.some((t5) => t5.type === e5.type) || (o2.push({ type:
|
|
2932
|
-
} else o2.some((t4) => t4.type === e5.type) || (o2.push({ type:
|
|
2933
|
-
for (const e5 of Array.from(r2.childNodes))
|
|
2946
|
+
o2.some((t5) => t5.type === e5.type) || (o2.push({ type: ye(e5.type), ...Object.keys(t4).length > 0 ? { attrs: t4 } : {} }), a20.add(e5.type));
|
|
2947
|
+
} else o2.some((t4) => t4.type === e5.type) || (o2.push({ type: ye(e5.type) }), a20.add(e5.type));
|
|
2948
|
+
for (const e5 of Array.from(r2.childNodes)) vs(e5, o2, n3, s3);
|
|
2934
2949
|
}
|
|
2935
|
-
function
|
|
2950
|
+
function ws(e4, t3) {
|
|
2936
2951
|
const n3 = e4.tagName.toLowerCase();
|
|
2937
2952
|
for (const s3 of t3) if (s3.rule.tag === n3) {
|
|
2938
2953
|
if (s3.rule.getAttrs) {
|
|
@@ -2944,33 +2959,33 @@ function hs(e4, t3) {
|
|
|
2944
2959
|
}
|
|
2945
2960
|
return null;
|
|
2946
2961
|
}
|
|
2947
|
-
const
|
|
2948
|
-
function
|
|
2962
|
+
const Ss = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]);
|
|
2963
|
+
function Es(e4, t3) {
|
|
2949
2964
|
const n3 = [];
|
|
2950
2965
|
let s3 = null;
|
|
2951
|
-
for (const r2 of e4) if (
|
|
2966
|
+
for (const r2 of e4) if (ke(r2, "list_item")) {
|
|
2952
2967
|
const e5 = "ordered" === r2.attrs.listType ? "ol" : "ul";
|
|
2953
|
-
s3 !== e5 && (s3 && n3.push(`</${s3}>`), n3.push(`<${e5}>`), s3 = e5), n3.push(
|
|
2954
|
-
} else s3 && (n3.push(`</${s3}>`), s3 = null), n3.push(
|
|
2968
|
+
s3 !== e5 && (s3 && n3.push(`</${s3}>`), n3.push(`<${e5}>`), s3 = e5), n3.push(xs(r2, t3));
|
|
2969
|
+
} else s3 && (n3.push(`</${s3}>`), s3 = null), n3.push(xs(r2, t3));
|
|
2955
2970
|
return s3 && n3.push(`</${s3}>`), n3.join("");
|
|
2956
2971
|
}
|
|
2957
|
-
function
|
|
2958
|
-
const n3 =
|
|
2959
|
-
const n4 =
|
|
2960
|
-
for (const e6 of n4) if (
|
|
2972
|
+
function xs(e4, t3) {
|
|
2973
|
+
const n3 = W(e4) ? (function(e5, t4) {
|
|
2974
|
+
const n4 = S(e5), s4 = [];
|
|
2975
|
+
for (const e6 of n4) if (I(e6)) {
|
|
2961
2976
|
const n5 = t4?.getInlineNodeSpec(e6.inlineType);
|
|
2962
2977
|
n5?.toHTMLString && s4.push(n5.toHTMLString(e6));
|
|
2963
|
-
} else s4.push(
|
|
2978
|
+
} else s4.push(Ts(e6, t4));
|
|
2964
2979
|
return s4.join("");
|
|
2965
|
-
})(e4, t3) :
|
|
2980
|
+
})(e4, t3) : Es(Q(e4), t3), s3 = t3?.getNodeSpec(e4.type);
|
|
2966
2981
|
let r2;
|
|
2967
2982
|
r2 = s3?.toHTML ? s3.toHTML(e4, n3) : `<p>${n3 || "<br>"}</p>`;
|
|
2968
2983
|
const i9 = e4.attrs?.align;
|
|
2969
|
-
return i9 && "left" !== i9 &&
|
|
2984
|
+
return i9 && "left" !== i9 && Ss.has(i9) && (r2 = r2.replace(/>/, ` style="text-align: ${i9}">`)), r2;
|
|
2970
2985
|
}
|
|
2971
|
-
function
|
|
2986
|
+
function Ts(e4, t3) {
|
|
2972
2987
|
if ("" === e4.text) return "";
|
|
2973
|
-
let n3 =
|
|
2988
|
+
let n3 = ve(e4.text);
|
|
2974
2989
|
const s3 = (function(e5) {
|
|
2975
2990
|
if (!e5) return /* @__PURE__ */ new Map();
|
|
2976
2991
|
const t4 = e5.getMarkTypes(), n4 = /* @__PURE__ */ new Map();
|
|
@@ -2986,9 +3001,9 @@ function fs(e4, t3) {
|
|
|
2986
3001
|
}
|
|
2987
3002
|
return n3;
|
|
2988
3003
|
}
|
|
2989
|
-
const
|
|
2990
|
-
let
|
|
2991
|
-
class
|
|
3004
|
+
const Cs = ["\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", '\n/* Paper viewport: scroll container with centered gray background */\n.notectl-paper-viewport {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n background: var(--notectl-paper-viewport-bg, #e8e8e8);\n padding: 24px 0;\n}\n\n/* Paper surface: white page with shadow, centered */\n.notectl-paper-surface {\n margin: 0 auto;\n background: var(--notectl-bg);\n border-radius: 2px;\n box-shadow: 0 2px 8px var(--notectl-shadow, rgba(0, 0, 0, 0.15));\n transform-origin: top center;\n transition: transform 0.15s ease-out;\n}\n\n/* Content overrides in paper mode: wider document margins */\n.notectl-editor[data-paper-mode] .notectl-content {\n flex: none;\n padding: 48px 56px;\n min-height: auto;\n}\n\n/* Placeholder position override for paper mode */\n.notectl-editor[data-paper-mode] .notectl-content.notectl-content--empty::before {\n top: 48px;\n left: 56px;\n}\n\n/* Dark mode: darker viewport background */\n:host([theme="dark"]) .notectl-paper-viewport {\n --notectl-paper-viewport-bg: #181825;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .notectl-paper-surface {\n transition: none !important;\n }\n}\n'].join("\n");
|
|
3005
|
+
let Rs = null;
|
|
3006
|
+
class As {
|
|
2992
3007
|
themeStyleSheet = new CSSStyleSheet();
|
|
2993
3008
|
systemThemeQuery = null;
|
|
2994
3009
|
systemThemeHandler = null;
|
|
@@ -2998,11 +3013,11 @@ class ys {
|
|
|
2998
3013
|
this.shadow = e4;
|
|
2999
3014
|
}
|
|
3000
3015
|
apply(e4) {
|
|
3001
|
-
if (this.cleanupSystemThemeListener(), e4 ===
|
|
3016
|
+
if (this.cleanupSystemThemeListener(), e4 === Bn.System) {
|
|
3002
3017
|
this.setupSystemThemeListener();
|
|
3003
|
-
const e5 =
|
|
3018
|
+
const e5 = Dn(this.getSystemTheme());
|
|
3004
3019
|
this.setThemeStyleSheet(e5);
|
|
3005
|
-
} else this.setThemeStyleSheet(
|
|
3020
|
+
} else this.setThemeStyleSheet(Dn(e4));
|
|
3006
3021
|
}
|
|
3007
3022
|
setPluginStyleSheets(e4) {
|
|
3008
3023
|
this.pluginSheets = e4, this.refreshAdoptedStyleSheets();
|
|
@@ -3011,14 +3026,14 @@ class ys {
|
|
|
3011
3026
|
this.cleanupSystemThemeListener();
|
|
3012
3027
|
}
|
|
3013
3028
|
setThemeStyleSheet(e4) {
|
|
3014
|
-
this.themeStyleSheet.replaceSync(
|
|
3029
|
+
this.themeStyleSheet.replaceSync($n(e4)), this.refreshAdoptedStyleSheets();
|
|
3015
3030
|
}
|
|
3016
3031
|
refreshAdoptedStyleSheets() {
|
|
3017
|
-
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (
|
|
3032
|
+
this.shadow.adoptedStyleSheets = [this.themeStyleSheet, (Rs || (Rs = new CSSStyleSheet(), Rs.replaceSync(Cs)), Rs), ...this.pluginSheets];
|
|
3018
3033
|
}
|
|
3019
3034
|
setupSystemThemeListener() {
|
|
3020
3035
|
this.systemThemeQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.systemThemeHandler = (e4) => {
|
|
3021
|
-
const t3 =
|
|
3036
|
+
const t3 = Dn(this.getSystemTheme());
|
|
3022
3037
|
this.setThemeStyleSheet(t3);
|
|
3023
3038
|
}, this.systemThemeQuery.addEventListener("change", this.systemThemeHandler);
|
|
3024
3039
|
}
|
|
@@ -3026,10 +3041,10 @@ class ys {
|
|
|
3026
3041
|
this.systemThemeQuery && this.systemThemeHandler && this.systemThemeQuery.removeEventListener("change", this.systemThemeHandler), this.systemThemeQuery = null, this.systemThemeHandler = null;
|
|
3027
3042
|
}
|
|
3028
3043
|
getSystemTheme() {
|
|
3029
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ?
|
|
3044
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? Bn.Dark : Bn.Light;
|
|
3030
3045
|
}
|
|
3031
3046
|
}
|
|
3032
|
-
class
|
|
3047
|
+
class Ls {
|
|
3033
3048
|
wrapper;
|
|
3034
3049
|
content;
|
|
3035
3050
|
viewport = null;
|
|
@@ -3045,7 +3060,7 @@ class ks {
|
|
|
3045
3060
|
}
|
|
3046
3061
|
apply(e4) {
|
|
3047
3062
|
if (null === e4) return void this.disable();
|
|
3048
|
-
const t3 =
|
|
3063
|
+
const t3 = Sn(e4);
|
|
3049
3064
|
this.currentPaperWidthPx = t3.widthPx, this.currentPaperHeightPx = t3.heightPx, this.currentSize = e4, this.viewport || this.enable(), this.updateSurfaceDimensions(), this.wrapper.setAttribute("data-paper-mode", e4);
|
|
3050
3065
|
}
|
|
3051
3066
|
destroy() {
|
|
@@ -3089,7 +3104,7 @@ class ks {
|
|
|
3089
3104
|
this.surface.style.marginBottom = `${n3}px`;
|
|
3090
3105
|
}
|
|
3091
3106
|
}
|
|
3092
|
-
class
|
|
3107
|
+
class Is extends HTMLElement {
|
|
3093
3108
|
view = null;
|
|
3094
3109
|
pluginManager = null;
|
|
3095
3110
|
contentElement = null;
|
|
@@ -3126,7 +3141,7 @@ class bs extends HTMLElement {
|
|
|
3126
3141
|
const e5 = null !== n3;
|
|
3127
3142
|
this.contentElement.contentEditable = e5 ? "false" : "true", e5 ? this.contentElement.setAttribute("aria-readonly", "true") : this.contentElement.removeAttribute("aria-readonly"), this.config = { ...this.config, readonly: e5 }, this.pluginManager?.setReadOnly(e5);
|
|
3128
3143
|
}
|
|
3129
|
-
"theme" === e4 && this.themeController && this.themeController.apply(n3 ??
|
|
3144
|
+
"theme" === e4 && this.themeController && this.themeController.apply(n3 ?? Bn.Light), "paper-size" === e4 && (null === n3 ? this.configure({ paperSize: void 0 }) : Cn(n3) && this.configure({ paperSize: n3 }));
|
|
3130
3145
|
}
|
|
3131
3146
|
registerPlugin(e4) {
|
|
3132
3147
|
if (this.initialized) throw new Error("Cannot register plugins after initialization. Register before calling init() or adding to DOM.");
|
|
@@ -3137,7 +3152,7 @@ class bs extends HTMLElement {
|
|
|
3137
3152
|
this.initialized = true, e4 && (this.config = e4);
|
|
3138
3153
|
const t3 = this.shadowRoot;
|
|
3139
3154
|
if (!t3) return;
|
|
3140
|
-
this.themeController = new
|
|
3155
|
+
this.themeController = new As(t3), this.themeController.apply(this.config.theme ?? Bn.Light);
|
|
3141
3156
|
const n3 = (function(e5) {
|
|
3142
3157
|
const t4 = document.createElement("div");
|
|
3143
3158
|
t4.className = "notectl-editor";
|
|
@@ -3150,9 +3165,9 @@ class bs extends HTMLElement {
|
|
|
3150
3165
|
const i10 = document.createElement("div");
|
|
3151
3166
|
return i10.className = "notectl-sr-only", i10.setAttribute("data-notectl-no-print", ""), i10.setAttribute("aria-live", "polite"), i10.setAttribute("aria-atomic", "true"), t4.appendChild(n4), t4.appendChild(s4), t4.appendChild(r3), t4.appendChild(i10), { wrapper: t4, content: s4, topPluginContainer: n4, bottomPluginContainer: r3, announcer: i10 };
|
|
3152
3167
|
})({ readonly: this.config.readonly, placeholder: this.config.placeholder });
|
|
3153
|
-
this.editorWrapper = n3.wrapper, this.contentElement = n3.content, this.topPluginContainer = n3.topPluginContainer, this.bottomPluginContainer = n3.bottomPluginContainer, this.announcer = n3.announcer, t3.appendChild(this.editorWrapper), this.config.paperSize && (this.paperLayout = new
|
|
3154
|
-
const s3 = new
|
|
3155
|
-
this.pluginManager.registerService(
|
|
3168
|
+
this.editorWrapper = n3.wrapper, this.contentElement = n3.content, this.topPluginContainer = n3.topPluginContainer, this.bottomPluginContainer = n3.bottomPluginContainer, this.announcer = n3.announcer, t3.appendChild(this.editorWrapper), this.config.paperSize && (this.paperLayout = new Ls(this.editorWrapper, this.contentElement), this.paperLayout.apply(this.config.paperSize)), this.pluginManager = new un();
|
|
3169
|
+
const s3 = new Ye(this.config.locale ?? "browser");
|
|
3170
|
+
this.pluginManager.registerService(Ze, s3), Rt(this.pluginManager.schemaRegistry), this.processToolbarConfig();
|
|
3156
3171
|
for (const e5 of this.config.plugins ?? []) this.pluginManager.register(e5);
|
|
3157
3172
|
for (const e5 of this.preInitPlugins) this.pluginManager.register(e5);
|
|
3158
3173
|
this.preInitPlugins = [], this.ensureTextFormattingPlugin(), this.ensureCaretNavigationPlugin(), this.ensureGapCursorPlugin(), this.contentElement.addEventListener("focus", () => this.emit("focus", void 0)), this.contentElement.addEventListener("blur", () => this.emit("blur", void 0));
|
|
@@ -3165,13 +3180,13 @@ class bs extends HTMLElement {
|
|
|
3165
3180
|
}, dispatch: (e5) => this.dispatch(e5), getContainer: () => r2, getPluginContainer: (e5) => "top" === e5 ? o2 : a20, announce: (e5) => {
|
|
3166
3181
|
c11 && (c11.textContent = e5);
|
|
3167
3182
|
}, hasAnnouncement: () => !!c11?.textContent, onBeforeReady: () => {
|
|
3168
|
-
const e5 =
|
|
3169
|
-
this.view = new
|
|
3183
|
+
const e5 = fe(i9.schemaRegistry), t4 = $t.create({ schema: e5 });
|
|
3184
|
+
this.view = new ks(r2, { state: t4, schemaRegistry: i9.schemaRegistry, keymapRegistry: i9.keymapRegistry, inputRuleRegistry: i9.inputRuleRegistry, fileHandlerRegistry: i9.fileHandlerRegistry, nodeViewRegistry: i9.nodeViewRegistry, maxHistoryDepth: this.config.maxHistoryDepth, getDecorations: (e6, t5) => this.pluginManager?.collectDecorations(e6, t5) ?? et.empty, onStateChange: (e6, t5, n5) => {
|
|
3170
3185
|
this.onStateChange(e6, t5, n5);
|
|
3171
3186
|
}, isReadOnly: () => this.config.readonly ?? false }), this.updateEmptyState();
|
|
3172
3187
|
const n4 = i9.getPluginStyleSheets();
|
|
3173
3188
|
n4.length > 0 && this.themeController?.setPluginStyleSheets(n4);
|
|
3174
|
-
} }), this.pluginManager && (this.config.readonly && this.pluginManager.setReadOnly(true), this.pluginManager.onEvent(
|
|
3189
|
+
} }), this.pluginManager && (this.config.readonly && this.pluginManager.setReadOnly(true), this.pluginManager.onEvent(Ln, (e5) => {
|
|
3175
3190
|
!e5.options.paperSize && this.config.paperSize && (e5.options = { ...e5.options, paperSize: this.config.paperSize });
|
|
3176
3191
|
}), this.config.autofocus && requestAnimationFrame(() => this.contentElement?.focus()), this.readyPromiseResolve?.(), this.emit("ready", void 0));
|
|
3177
3192
|
}
|
|
@@ -3183,48 +3198,48 @@ class bs extends HTMLElement {
|
|
|
3183
3198
|
return this.view.getState().doc;
|
|
3184
3199
|
}
|
|
3185
3200
|
setJSON(e4) {
|
|
3186
|
-
const t3 = this.pluginManager ?
|
|
3201
|
+
const t3 = this.pluginManager ? fe(this.pluginManager.schemaRegistry) : void 0, n3 = $t.create({ doc: e4, schema: t3, selection: ne(e4.children[0]?.id ?? ge(""), 0) });
|
|
3187
3202
|
this.replaceState(n3);
|
|
3188
3203
|
}
|
|
3189
3204
|
getHTML(e4) {
|
|
3190
3205
|
if (!this.view) throw new Error("Editor not initialized");
|
|
3191
3206
|
const t3 = (function(e5, t4) {
|
|
3192
|
-
const n3 =
|
|
3193
|
-
return
|
|
3207
|
+
const n3 = Es(e5.children, t4), s3 = t4 ? t4.getAllowedTags() : ["p", "br", "div", "span"], r2 = t4 ? t4.getAllowedAttrs() : ["style"];
|
|
3208
|
+
return St.sanitize(n3, { ALLOWED_TAGS: s3, ALLOWED_ATTR: r2 });
|
|
3194
3209
|
})(this.view.getState().doc, this.pluginManager?.schemaRegistry);
|
|
3195
|
-
return e4?.pretty ?
|
|
3210
|
+
return e4?.pretty ? we(t3) : t3;
|
|
3196
3211
|
}
|
|
3197
3212
|
setHTML(e4) {
|
|
3198
3213
|
const t3 = (function(e5, t4) {
|
|
3199
3214
|
const n3 = t4 ? t4.getAllowedTags() : ["p", "br", "div", "span"], s3 = t4 ? t4.getAllowedAttrs() : ["style"], r2 = document.createElement("template");
|
|
3200
|
-
r2.innerHTML =
|
|
3215
|
+
r2.innerHTML = St.sanitize(e5, { ALLOWED_TAGS: n3, ALLOWED_ATTR: s3 });
|
|
3201
3216
|
const i9 = r2.content, o2 = t4?.getBlockParseRules() ?? [], a20 = [];
|
|
3202
3217
|
for (const e6 of Array.from(i9.childNodes)) if (e6.nodeType === Node.ELEMENT_NODE) {
|
|
3203
3218
|
const n4 = e6, s4 = n4.tagName.toLowerCase();
|
|
3204
3219
|
if ("ul" === s4 || "ol" === s4) {
|
|
3205
3220
|
const e7 = "ol" === s4 ? "ordered" : "bullet";
|
|
3206
3221
|
for (const s5 of Array.from(n4.querySelectorAll("li"))) {
|
|
3207
|
-
const n5 =
|
|
3208
|
-
a20.push(
|
|
3222
|
+
const n5 = bs(s5, t4);
|
|
3223
|
+
a20.push(R(me("list_item"), n5, void 0, { listType: e7, indent: 0, checked: false }));
|
|
3209
3224
|
}
|
|
3210
3225
|
continue;
|
|
3211
3226
|
}
|
|
3212
|
-
const r3 =
|
|
3227
|
+
const r3 = ws(n4, o2);
|
|
3213
3228
|
if (r3) {
|
|
3214
|
-
const e7 =
|
|
3215
|
-
a20.push(
|
|
3229
|
+
const e7 = bs(n4, t4);
|
|
3230
|
+
a20.push(R(me(r3.type), e7, void 0, r3.attrs));
|
|
3216
3231
|
continue;
|
|
3217
3232
|
}
|
|
3218
|
-
const i10 =
|
|
3219
|
-
a20.push(
|
|
3220
|
-
} else e6.nodeType === Node.TEXT_NODE && e6.textContent?.trim() && a20.push(
|
|
3221
|
-
return 0 === a20.length ?
|
|
3233
|
+
const i10 = bs(n4, t4);
|
|
3234
|
+
a20.push(R(me("paragraph"), i10));
|
|
3235
|
+
} else e6.nodeType === Node.TEXT_NODE && e6.textContent?.trim() && a20.push(R(me("paragraph"), [M(e6.textContent.trim())]));
|
|
3236
|
+
return 0 === a20.length ? U() : U(a20);
|
|
3222
3237
|
})(e4, this.pluginManager?.schemaRegistry);
|
|
3223
3238
|
this.setJSON(t3);
|
|
3224
3239
|
}
|
|
3225
3240
|
getText() {
|
|
3226
3241
|
if (!this.view) throw new Error("Editor not initialized");
|
|
3227
|
-
return this.view.getState().doc.children.map((e4) =>
|
|
3242
|
+
return this.view.getState().doc.children.map((e4) => H(e4)).join("\n");
|
|
3228
3243
|
}
|
|
3229
3244
|
isEmpty() {
|
|
3230
3245
|
if (!this.view) return true;
|
|
@@ -3232,7 +3247,7 @@ class bs extends HTMLElement {
|
|
|
3232
3247
|
if (0 === e4.children.length) return true;
|
|
3233
3248
|
if (e4.children.length > 1) return false;
|
|
3234
3249
|
const t3 = e4.children[0];
|
|
3235
|
-
return !t3 || "paragraph" === t3.type && "" ===
|
|
3250
|
+
return !t3 || "paragraph" === t3.type && "" === H(t3);
|
|
3236
3251
|
}
|
|
3237
3252
|
commands = { toggleBold: () => this.executeCommand("toggleBold"), toggleItalic: () => this.executeCommand("toggleItalic"), toggleUnderline: () => this.executeCommand("toggleUnderline"), undo: () => {
|
|
3238
3253
|
this.config.readonly || this.view?.undo();
|
|
@@ -3240,12 +3255,12 @@ class bs extends HTMLElement {
|
|
|
3240
3255
|
this.config.readonly || this.view?.redo();
|
|
3241
3256
|
}, selectAll: () => {
|
|
3242
3257
|
if (!this.view) return;
|
|
3243
|
-
const e4 =
|
|
3258
|
+
const e4 = je(this.view.getState());
|
|
3244
3259
|
this.dispatch(e4);
|
|
3245
3260
|
} };
|
|
3246
3261
|
can() {
|
|
3247
3262
|
const e4 = this.view?.getState().schema, t3 = this.config.readonly ?? false;
|
|
3248
|
-
return { toggleBold: () => !t3 && !!e4 &&
|
|
3263
|
+
return { toggleBold: () => !t3 && !!e4 && pe(e4, "bold"), toggleItalic: () => !t3 && !!e4 && pe(e4, "italic"), toggleUnderline: () => !t3 && !!e4 && pe(e4, "underline"), undo: () => !t3 && (this.view?.history.canUndo() ?? false), redo: () => !t3 && (this.view?.history.canRedo() ?? false) };
|
|
3249
3264
|
}
|
|
3250
3265
|
executeCommand(e4) {
|
|
3251
3266
|
return this.pluginManager?.executeCommand(e4) ?? false;
|
|
@@ -3265,7 +3280,7 @@ class bs extends HTMLElement {
|
|
|
3265
3280
|
return this.view.getState();
|
|
3266
3281
|
}
|
|
3267
3282
|
dispatch(e4) {
|
|
3268
|
-
this.view && this.pluginManager && (!this.config.readonly ||
|
|
3283
|
+
this.view && this.pluginManager && (!this.config.readonly || Vt(e4) || this.pluginManager.isReadonlyBypassed()) && this.pluginManager.dispatchWithMiddleware(e4, this.view.getState(), (e5) => this.view?.dispatch(e5));
|
|
3269
3284
|
}
|
|
3270
3285
|
on(e4, t3) {
|
|
3271
3286
|
this.eventListeners.has(e4) || this.eventListeners.set(e4, /* @__PURE__ */ new Set()), this.eventListeners.get(e4)?.add(t3);
|
|
@@ -3283,7 +3298,7 @@ class bs extends HTMLElement {
|
|
|
3283
3298
|
this.config = { ...this.config, theme: e4 }, this.themeController?.apply(e4);
|
|
3284
3299
|
}
|
|
3285
3300
|
getTheme() {
|
|
3286
|
-
return this.config.theme ??
|
|
3301
|
+
return this.config.theme ?? Bn.Light;
|
|
3287
3302
|
}
|
|
3288
3303
|
getPaperSize() {
|
|
3289
3304
|
return this.config.paperSize;
|
|
@@ -3302,30 +3317,30 @@ class bs extends HTMLElement {
|
|
|
3302
3317
|
r2.push(t4);
|
|
3303
3318
|
}
|
|
3304
3319
|
const i9 = { groups: r2, overflow: s3 };
|
|
3305
|
-
this.pluginManager.register(new
|
|
3320
|
+
this.pluginManager.register(new st(i9));
|
|
3306
3321
|
}
|
|
3307
3322
|
ensureTextFormattingPlugin() {
|
|
3308
3323
|
if (!this.pluginManager) return;
|
|
3309
3324
|
if (void 0 !== this.pluginManager.get("text-formatting")) return;
|
|
3310
3325
|
const e4 = { bold: this.config.features?.bold ?? true, italic: this.config.features?.italic ?? true, underline: this.config.features?.underline ?? true };
|
|
3311
|
-
this.pluginManager.register(new
|
|
3326
|
+
this.pluginManager.register(new it(e4));
|
|
3312
3327
|
}
|
|
3313
3328
|
ensureCaretNavigationPlugin() {
|
|
3314
|
-
this.pluginManager && void 0 === this.pluginManager.get("caret-navigation") && this.pluginManager.register(new
|
|
3329
|
+
this.pluginManager && void 0 === this.pluginManager.get("caret-navigation") && this.pluginManager.register(new Z());
|
|
3315
3330
|
}
|
|
3316
3331
|
ensureGapCursorPlugin() {
|
|
3317
|
-
this.pluginManager && void 0 === this.pluginManager.get("gap-cursor") && this.pluginManager.register(new
|
|
3332
|
+
this.pluginManager && void 0 === this.pluginManager.get("gap-cursor") && this.pluginManager.register(new wt());
|
|
3318
3333
|
}
|
|
3319
3334
|
applyPaperSize(e4) {
|
|
3320
|
-
this.editorWrapper && this.contentElement && (e4 ? (this.paperLayout || (this.paperLayout = new
|
|
3335
|
+
this.editorWrapper && this.contentElement && (e4 ? (this.paperLayout || (this.paperLayout = new Ls(this.editorWrapper, this.contentElement)), this.paperLayout.apply(e4)) : this.paperLayout?.apply(null));
|
|
3321
3336
|
}
|
|
3322
3337
|
emit(e4, t3) {
|
|
3323
3338
|
const n3 = this.eventListeners.get(e4);
|
|
3324
3339
|
if (n3) for (const e5 of n3) e5(t3);
|
|
3325
3340
|
}
|
|
3326
3341
|
onStateChange(e4, t3, n3) {
|
|
3327
|
-
if (this.announcer && (this.announcer.textContent = ""), this.pluginManager?.notifyStateChange(e4, t3, n3), this.updateEmptyState(), this.emit("stateChange", { oldState: e4, newState: t3, transaction: n3 }),
|
|
3328
|
-
const s3 =
|
|
3342
|
+
if (this.announcer && (this.announcer.textContent = ""), this.pluginManager?.notifyStateChange(e4, t3, n3), this.updateEmptyState(), this.emit("stateChange", { oldState: e4, newState: t3, transaction: n3 }), ce(e4.selection, t3.selection) || this.emit("selectionChange", { selection: t3.selection }), !this.announcer?.textContent) {
|
|
3343
|
+
const s3 = ee(e4, t3, n3);
|
|
3329
3344
|
s3 && this.announcer && (this.announcer.textContent = s3);
|
|
3330
3345
|
}
|
|
3331
3346
|
}
|
|
@@ -3336,145 +3351,153 @@ class bs extends HTMLElement {
|
|
|
3336
3351
|
this.view && (this.view.replaceState(e4), this.updateEmptyState());
|
|
3337
3352
|
}
|
|
3338
3353
|
}
|
|
3339
|
-
async function
|
|
3354
|
+
async function Ms(e4) {
|
|
3340
3355
|
const t3 = document.createElement("notectl-editor");
|
|
3341
3356
|
return await t3.init(e4), t3;
|
|
3342
3357
|
}
|
|
3343
|
-
|
|
3358
|
+
function Ns(e4) {
|
|
3359
|
+
return { toolbar: [[new ft({ fonts: Et, ...e4?.font })]], plugins: [] };
|
|
3360
|
+
}
|
|
3361
|
+
function Bs(e4) {
|
|
3362
|
+
return { toolbar: [[new ft({ fonts: Et, ...e4?.font }), new gt(e4?.fontSize)], [new it(e4?.textFormatting), new ht(e4?.strikethrough), new kt(e4?.superSub)], [new dt(e4?.textColor), new yt(e4?.highlight)], [new ot(e4?.heading), new lt(e4?.blockquote), new nt(e4?.codeBlock)], [new ut(e4?.alignment)], [new ct(e4?.list)], [new at(e4?.link), new mt(e4?.table), new pt(e4?.horizontalRule), new bt(e4?.image)], [new Nn(e4?.print)]], plugins: [new vt()] };
|
|
3363
|
+
}
|
|
3364
|
+
"undefined" == typeof customElements || customElements.get("notectl-editor") || customElements.define("notectl-editor", Is);
|
|
3344
3365
|
export {
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3366
|
+
In as AFTER_PRINT,
|
|
3367
|
+
a12 as ALIGNMENT_ICONS,
|
|
3368
|
+
b15 as ALIGNMENT_LOCALES,
|
|
3369
|
+
c7 as ALIGNMENT_LOCALE_DE,
|
|
3370
|
+
d4 as ALIGNMENT_LOCALE_EN,
|
|
3371
|
+
ut as AlignmentPlugin,
|
|
3372
|
+
Ln as BEFORE_PRINT,
|
|
3373
|
+
a8 as BLOCKQUOTE_LOCALES,
|
|
3374
|
+
b11 as BLOCKQUOTE_LOCALE_EN,
|
|
3375
|
+
cn as BlockTypePickerRegistry,
|
|
3376
|
+
lt as BlockquotePlugin,
|
|
3377
|
+
a2 as CODE_BLOCK_LOCALES,
|
|
3378
|
+
b5 as CODE_BLOCK_LOCALE_EN,
|
|
3379
|
+
c5 as CODE_BLOCK_SERVICE_KEY,
|
|
3380
|
+
Z as CaretNavigationPlugin,
|
|
3381
|
+
Zt as ClipboardHandler,
|
|
3382
|
+
nt as CodeBlockPlugin,
|
|
3383
|
+
en as CompositionTracker,
|
|
3384
|
+
dn as CursorWrapper,
|
|
3385
|
+
_n as DARK_THEME,
|
|
3365
3386
|
D2 as DEFAULT_IMAGE_KEYMAP,
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
HardBreakPlugin,
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3387
|
+
et as DecorationSet,
|
|
3388
|
+
$t as EditorState,
|
|
3389
|
+
pn as EventBus,
|
|
3390
|
+
Je as EventKey,
|
|
3391
|
+
a13 as FONT_LOCALES,
|
|
3392
|
+
b16 as FONT_LOCALE_EN,
|
|
3393
|
+
a14 as FONT_SIZE_LOCALES,
|
|
3394
|
+
b17 as FONT_SIZE_LOCALE_EN,
|
|
3395
|
+
sn as FileHandlerRegistry,
|
|
3396
|
+
ft as FontPlugin,
|
|
3397
|
+
gt as FontSizePlugin,
|
|
3398
|
+
wt as GapCursorPlugin,
|
|
3399
|
+
a5 as HEADING_LOCALES,
|
|
3400
|
+
b8 as HEADING_LOCALE_EN,
|
|
3401
|
+
a16 as HIGHLIGHT_LOCALES,
|
|
3402
|
+
b19 as HIGHLIGHT_LOCALE_EN,
|
|
3403
|
+
a11 as HORIZONTAL_RULE_LOCALES,
|
|
3404
|
+
b14 as HORIZONTAL_RULE_LOCALE_EN,
|
|
3405
|
+
vt as HardBreakPlugin,
|
|
3406
|
+
ot as HeadingPlugin,
|
|
3407
|
+
yt as HighlightPlugin,
|
|
3408
|
+
Gt as HistoryManager,
|
|
3409
|
+
pt as HorizontalRulePlugin,
|
|
3410
|
+
a18 as IMAGE_LOCALES,
|
|
3411
|
+
b21 as IMAGE_LOCALE_EN,
|
|
3412
|
+
c9 as IMAGE_UPLOAD_SERVICE,
|
|
3413
|
+
bt as ImagePlugin,
|
|
3414
|
+
nn as InputRuleRegistry,
|
|
3415
|
+
tn as KeymapRegistry,
|
|
3416
|
+
On as LIGHT_THEME,
|
|
3417
|
+
a6 as LINK_LOCALES,
|
|
3418
|
+
b9 as LINK_LOCALE_EN,
|
|
3419
|
+
a7 as LIST_LOCALES,
|
|
3420
|
+
b10 as LIST_LOCALE_EN,
|
|
3421
|
+
at as LinkPlugin,
|
|
3422
|
+
ct as ListPlugin,
|
|
3423
|
+
Fn as Locale,
|
|
3424
|
+
Ye as LocaleService,
|
|
3425
|
+
Ze as LocaleServiceKey,
|
|
3426
|
+
on as NodeViewRegistry,
|
|
3427
|
+
Is as NotectlEditor,
|
|
3428
|
+
xn as PAPER_MARGIN_HORIZONTAL_PX,
|
|
3429
|
+
En as PAPER_MARGIN_TOP_PX,
|
|
3430
|
+
Tn as PAPER_VIEWPORT_PADDING_PX,
|
|
3431
|
+
gn as PRINT_LOCALES,
|
|
3432
|
+
fn as PRINT_LOCALE_EN,
|
|
3433
|
+
An as PRINT_SERVICE_KEY,
|
|
3434
|
+
kn as PaperSize,
|
|
3435
|
+
un as PluginManager,
|
|
3436
|
+
Nn as PrintPlugin,
|
|
3437
|
+
a9 as STRIKETHROUGH_LOCALES,
|
|
3438
|
+
b12 as STRIKETHROUGH_LOCALE_EN,
|
|
3439
|
+
a17 as SUPER_SUB_LOCALES,
|
|
3440
|
+
b20 as SUPER_SUB_LOCALE_EN,
|
|
3441
|
+
xt as SchemaRegistry,
|
|
3442
|
+
Qe as ServiceKey,
|
|
3443
|
+
ht as StrikethroughPlugin,
|
|
3444
|
+
kt as SuperSubPlugin,
|
|
3445
|
+
a15 as TABLE_LOCALES,
|
|
3446
|
+
b18 as TABLE_LOCALE_AR,
|
|
3447
|
+
c8 as TABLE_LOCALE_DE,
|
|
3448
|
+
d5 as TABLE_LOCALE_EN,
|
|
3449
|
+
e3 as TABLE_LOCALE_ES,
|
|
3450
|
+
f3 as TABLE_LOCALE_FR,
|
|
3451
|
+
g2 as TABLE_LOCALE_HI,
|
|
3452
|
+
h3 as TABLE_LOCALE_RU,
|
|
3453
|
+
i7 as TABLE_LOCALE_ZH,
|
|
3454
|
+
a10 as TEXT_COLOR_LOCALES,
|
|
3455
|
+
b13 as TEXT_COLOR_LOCALE_EN,
|
|
3435
3456
|
a4 as TEXT_FORMATTING_LOCALES,
|
|
3436
3457
|
b7 as TEXT_FORMATTING_LOCALE_EN,
|
|
3437
3458
|
b6 as TOOLBAR_LOCALES,
|
|
3438
3459
|
c6 as TOOLBAR_LOCALE_EN,
|
|
3439
|
-
|
|
3460
|
+
mt as TablePlugin,
|
|
3440
3461
|
j3 as TableSelectionServiceKey,
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3462
|
+
ut as TextAlignmentPlugin,
|
|
3463
|
+
dt as TextColorPlugin,
|
|
3464
|
+
it as TextFormattingPlugin,
|
|
3465
|
+
Bn as ThemePreset,
|
|
3445
3466
|
d3 as ToolbarOverflowBehavior,
|
|
3446
|
-
|
|
3447
|
-
|
|
3467
|
+
st as ToolbarPlugin,
|
|
3468
|
+
an as ToolbarRegistry,
|
|
3448
3469
|
a3 as ToolbarServiceKey,
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3470
|
+
jt as TransactionBuilder,
|
|
3471
|
+
At as applyStep,
|
|
3472
|
+
ge as blockId,
|
|
3452
3473
|
v as blockOffsetToTextOffset,
|
|
3453
|
-
|
|
3474
|
+
Tt as canContain,
|
|
3454
3475
|
c10 as canCrossBlockBoundary,
|
|
3455
3476
|
c3 as commandName,
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3477
|
+
be as createBlockElement,
|
|
3478
|
+
R as createBlockNode,
|
|
3479
|
+
ne as createCollapsedSelection,
|
|
3480
|
+
U as createDocument,
|
|
3481
|
+
Ms as createEditor,
|
|
3482
|
+
Bs as createFullPreset,
|
|
3461
3483
|
d2 as createGapCursor,
|
|
3462
3484
|
k as createInlineNode,
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3485
|
+
Ns as createMinimalPreset,
|
|
3486
|
+
te as createNodeSelection,
|
|
3487
|
+
oe as createPosition,
|
|
3488
|
+
ie as createSelection,
|
|
3489
|
+
M as createTextNode,
|
|
3490
|
+
Pn as createTheme,
|
|
3491
|
+
Kn as createThemeStyleSheet,
|
|
3492
|
+
de as defaultSchema,
|
|
3493
|
+
qt as deleteBackward,
|
|
3494
|
+
Fe as deleteBackwardAtGap,
|
|
3495
|
+
Jt as deleteForward,
|
|
3496
|
+
Ue as deleteForwardAtGap,
|
|
3497
|
+
Pe as deleteNodeSelection,
|
|
3498
|
+
De as deleteSelectionCommand,
|
|
3499
|
+
Ne as endOfTextblock,
|
|
3500
|
+
ve as escapeHTML,
|
|
3478
3501
|
e as extendCharacterBackward,
|
|
3479
3502
|
c as extendCharacterForward,
|
|
3480
3503
|
d as extendLineDown,
|
|
@@ -3488,62 +3511,62 @@ export {
|
|
|
3488
3511
|
i4 as extendTx,
|
|
3489
3512
|
n as extendWordBackward,
|
|
3490
3513
|
o as extendWordForward,
|
|
3491
|
-
|
|
3492
|
-
|
|
3514
|
+
Se as findNode,
|
|
3515
|
+
xe as findNodePath,
|
|
3493
3516
|
b3 as findNodeWithPath,
|
|
3494
3517
|
k4 as findTableContext,
|
|
3495
|
-
|
|
3496
|
-
|
|
3518
|
+
Y as findWordBoundaryBackward,
|
|
3519
|
+
X as findWordBoundaryForward,
|
|
3497
3520
|
f2 as forEachBlockInRange,
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3521
|
+
we as formatHTML,
|
|
3522
|
+
rt as formatShortcut,
|
|
3523
|
+
$n as generateThemeCSS,
|
|
3524
|
+
Q as getBlockChildren,
|
|
3525
|
+
C as getBlockLength,
|
|
3526
|
+
$ as getBlockMarksAtOffset,
|
|
3527
|
+
H as getBlockText,
|
|
3505
3528
|
p as getBlockTypeLabel,
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3529
|
+
Oe as getCaretRectFromSelection,
|
|
3530
|
+
K as getContentAtOffset,
|
|
3531
|
+
S as getInlineChildren,
|
|
3532
|
+
Rn as getPaperCSSSize,
|
|
3533
|
+
Sn as getPaperDimensions,
|
|
3511
3534
|
w as getTextChildren,
|
|
3512
|
-
|
|
3535
|
+
qe as getTextDirection,
|
|
3513
3536
|
h as hasMark,
|
|
3514
3537
|
i6 as inlineDecoration,
|
|
3515
3538
|
i2 as inlineType,
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3539
|
+
Ve as insertHardBreakCommand,
|
|
3540
|
+
We as insertTextCommand,
|
|
3541
|
+
Ht as invertStep,
|
|
3542
|
+
zt as invertTransaction,
|
|
3543
|
+
Vt as isAllowedInReadonly,
|
|
3544
|
+
L as isBlockNode,
|
|
3545
|
+
ae as isCollapsed,
|
|
3523
3546
|
a as isFirefox,
|
|
3524
3547
|
k3 as isForward,
|
|
3525
|
-
|
|
3526
|
-
|
|
3548
|
+
re as isGapCursor,
|
|
3549
|
+
I as isInlineNode,
|
|
3527
3550
|
b2 as isInlineNodeOfType,
|
|
3528
3551
|
b22 as isInsideIsolating,
|
|
3529
3552
|
l2 as isInsideTable,
|
|
3530
3553
|
a19 as isIsolatingBlock,
|
|
3531
|
-
|
|
3554
|
+
W as isLeafBlock,
|
|
3532
3555
|
i5 as isMac,
|
|
3533
3556
|
b as isMarkActive,
|
|
3534
|
-
|
|
3557
|
+
pe as isMarkAllowed,
|
|
3535
3558
|
i3 as isMarkOfType,
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3559
|
+
ke as isNodeOfType,
|
|
3560
|
+
se as isNodeSelection,
|
|
3561
|
+
Wt as isSelectionOnlyTransaction,
|
|
3562
|
+
N as isTextNode,
|
|
3563
|
+
le as isTextSelection,
|
|
3564
|
+
Cn as isValidPaperSize,
|
|
3542
3565
|
i8 as isVoidBlock,
|
|
3543
3566
|
b4 as isWebKit,
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3567
|
+
J as markSetsEqual,
|
|
3568
|
+
ye as markType,
|
|
3569
|
+
He as mergeBlockBackward,
|
|
3547
3570
|
q as moveCharacterBackward,
|
|
3548
3571
|
r as moveCharacterForward,
|
|
3549
3572
|
s as moveLineDown,
|
|
@@ -3557,34 +3580,34 @@ export {
|
|
|
3557
3580
|
m2 as moveTx,
|
|
3558
3581
|
A as moveWordBackward,
|
|
3559
3582
|
B as moveWordForward,
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3583
|
+
Be as navigateAcrossBlocks,
|
|
3584
|
+
$e as navigateArrowIntoVoid,
|
|
3585
|
+
Te as navigateFromGapCursor,
|
|
3586
|
+
_e as navigateVerticalWithGoalColumn,
|
|
3564
3587
|
D as nextGraphemeSize,
|
|
3565
3588
|
n2 as nodeDecoration,
|
|
3566
3589
|
j2 as nodeSelTx,
|
|
3567
|
-
|
|
3568
|
-
|
|
3590
|
+
me as nodeType,
|
|
3591
|
+
Xt as normalizeKeyDescriptor,
|
|
3569
3592
|
p2 as pluginId,
|
|
3570
3593
|
E as prevGraphemeSize,
|
|
3571
|
-
|
|
3572
|
-
|
|
3594
|
+
Rt as registerBuiltinSpecs,
|
|
3595
|
+
Ee as resolveNodeByPath,
|
|
3573
3596
|
c4 as resolveParentByPath,
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3597
|
+
Xe as resolvePluginLocale,
|
|
3598
|
+
Dn as resolveTheme,
|
|
3599
|
+
fe as schemaFromRegistry,
|
|
3600
|
+
je as selectAll,
|
|
3601
|
+
he as selectionRange,
|
|
3602
|
+
ce as selectionsEqual,
|
|
3580
3603
|
s2 as sharesParent,
|
|
3581
|
-
|
|
3582
|
-
|
|
3604
|
+
Me as skipInlineNode,
|
|
3605
|
+
Ke as splitBlockCommand,
|
|
3583
3606
|
t2 as toggleBold,
|
|
3584
3607
|
c2 as toggleItalic,
|
|
3585
3608
|
e2 as toggleMark,
|
|
3586
3609
|
f as toggleUnderline,
|
|
3587
|
-
|
|
3610
|
+
Ct as validateContent,
|
|
3588
3611
|
F as viewExtend,
|
|
3589
3612
|
G as viewMove,
|
|
3590
3613
|
w3 as walkNodes,
|