@one2x/medeo-rte 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +99 -100
- package/dist/index.js.map +1 -1
- package/dist/types/editor/markNav.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -111,7 +111,7 @@ function rt(n) {
|
|
|
111
111
|
function F(n) {
|
|
112
112
|
return n.anchor === n.focus;
|
|
113
113
|
}
|
|
114
|
-
const
|
|
114
|
+
const Le = {
|
|
115
115
|
fontSize: 16,
|
|
116
116
|
color: "#1f2329"
|
|
117
117
|
}, V = {
|
|
@@ -148,7 +148,7 @@ const qa = 4, Ar = "#c5ccd6";
|
|
|
148
148
|
function le(n) {
|
|
149
149
|
return n.chrome.paddingX ?? (n.kind === "mark" ? qa : 0);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Re(n) {
|
|
152
152
|
if (n.kind !== "mark") return 0;
|
|
153
153
|
const t = n.chrome.marginX;
|
|
154
154
|
return t != null && t > 0 ? t : 0;
|
|
@@ -317,14 +317,14 @@ function xe(n, t) {
|
|
|
317
317
|
function Cr(n) {
|
|
318
318
|
return n >= 19968 && n <= 40959 || n >= 13312 && n <= 19903 || n >= 12352 && n <= 12543 || n >= 44032 && n <= 55215 || n >= 63744 && n <= 64255;
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function $e(n) {
|
|
321
321
|
const t = n.codePointAt(0) ?? 0, e = t > 65535 ? 2 : 1;
|
|
322
322
|
return n.length === e && Cr(t);
|
|
323
323
|
}
|
|
324
324
|
function sl(n) {
|
|
325
325
|
return n >= 48 && n <= 57 || n >= 65 && n <= 90 || n >= 97 && n <= 122;
|
|
326
326
|
}
|
|
327
|
-
function
|
|
327
|
+
function Ce(n) {
|
|
328
328
|
if (!n) return !1;
|
|
329
329
|
for (let t = 0; t < n.length; ) {
|
|
330
330
|
const e = n.codePointAt(t) ?? 0;
|
|
@@ -376,7 +376,7 @@ function Br(n, t, e) {
|
|
|
376
376
|
const i = (n.codePointAt(0) ?? 0) > 65535 ? 2 : 1;
|
|
377
377
|
if (n.length === i) {
|
|
378
378
|
const o = t + Ot(e), a = n.length === 1 ? [o] : [o, 0];
|
|
379
|
-
return
|
|
379
|
+
return $e(n) && _n.set(xe(e, n), a), a;
|
|
380
380
|
}
|
|
381
381
|
const r = ge(n, e);
|
|
382
382
|
return r.length !== n.length ? null : r;
|
|
@@ -384,7 +384,7 @@ function Br(n, t, e) {
|
|
|
384
384
|
function Ti(n, t) {
|
|
385
385
|
const e = _n.get(xe(t, n));
|
|
386
386
|
if (e) return e;
|
|
387
|
-
if (
|
|
387
|
+
if (!$e(n)) return null;
|
|
388
388
|
const s = ut(n, t), i = n.length === 1 ? [s] : [s, 0];
|
|
389
389
|
return _n.set(xe(t, n), i), i;
|
|
390
390
|
}
|
|
@@ -560,7 +560,7 @@ function yl(n, t, e) {
|
|
|
560
560
|
}
|
|
561
561
|
s.sort((i, r) => i.size - r.size);
|
|
562
562
|
for (const { prev: i, edit: r } of s) {
|
|
563
|
-
const o = hl(i, r.at), a = !!(r.insert && r.remove), l = a && !!(o != null && o.boundary) &&
|
|
563
|
+
const o = hl(i, r.at), a = !!(r.insert && r.remove), l = a && !!(o != null && o.boundary) && $e(r.insert) && $e(r.remove);
|
|
564
564
|
let c = null, h;
|
|
565
565
|
if (o && (!a || l) && (c = kl(i, pl(i.segs), o, r, e)), !c) {
|
|
566
566
|
const d = gl(i, r, e);
|
|
@@ -579,7 +579,7 @@ function kl(n, t, e, s, i) {
|
|
|
579
579
|
if (r != null)
|
|
580
580
|
return t.splice(e.index, r - e.index), t;
|
|
581
581
|
const o = t[e.index];
|
|
582
|
-
if (o &&
|
|
582
|
+
if (o && Ce(o.text) && o.text.startsWith(s.remove) && s.remove.length < o.text.length) {
|
|
583
583
|
const a = o.text.slice(s.remove.length), l = ge(a, i);
|
|
584
584
|
return l.length !== a.length ? null : (t[e.index] = { text: a, widths: l, space: !1 }, t);
|
|
585
585
|
}
|
|
@@ -596,8 +596,8 @@ function kl(n, t, e, s, i) {
|
|
|
596
596
|
}
|
|
597
597
|
return t.splice(e.index, 0, ...a), t;
|
|
598
598
|
}
|
|
599
|
-
if (s.insert &&
|
|
600
|
-
const r = e.boundary && e.index < t.length &&
|
|
599
|
+
if (s.insert && Ce(s.insert) && !s.remove) {
|
|
600
|
+
const r = e.boundary && e.index < t.length && Ce(t[e.index].text), o = e.boundary && e.index > 0 && Ce(t[e.index - 1].text);
|
|
601
601
|
if (r && o) return null;
|
|
602
602
|
if (e.boundary && !r && !o) {
|
|
603
603
|
const a = t[e.index], l = e.index > 0 ? t[e.index - 1] : null;
|
|
@@ -616,17 +616,17 @@ function kl(n, t, e, s, i) {
|
|
|
616
616
|
}
|
|
617
617
|
if (!e.boundary) {
|
|
618
618
|
const r = t[e.index], o = kt(n, e.index) + r.text.length;
|
|
619
|
-
if (s.at + s.remove.length > o || !
|
|
619
|
+
if (s.at + s.remove.length > o || !Ce(r.text)) return null;
|
|
620
620
|
const a = r.text.slice(0, e.local) + s.insert + r.text.slice(e.local + s.remove.length);
|
|
621
621
|
if (!a)
|
|
622
622
|
return t.splice(e.index, 1), t;
|
|
623
|
-
if (!
|
|
623
|
+
if (!Ce(a)) return null;
|
|
624
624
|
const l = ge(a, i);
|
|
625
625
|
return l.length !== a.length ? null : (t[e.index] = { text: a, widths: l, space: !1 }, t);
|
|
626
626
|
}
|
|
627
627
|
if (s.insert && s.remove && e.boundary) {
|
|
628
628
|
const r = t[e.index];
|
|
629
|
-
if (!r || r.text !== s.remove ||
|
|
629
|
+
if (!r || r.text !== s.remove || !$e(s.remove) || !$e(s.insert)) return null;
|
|
630
630
|
const o = Ti(s.insert, i);
|
|
631
631
|
return o ? (t[e.index] = { text: s.insert, widths: o, space: !1 }, t) : null;
|
|
632
632
|
}
|
|
@@ -860,7 +860,7 @@ function Cl(n) {
|
|
|
860
860
|
}
|
|
861
861
|
function Il(n) {
|
|
862
862
|
return {
|
|
863
|
-
size: n.fontSize ??
|
|
863
|
+
size: n.fontSize ?? Le.fontSize,
|
|
864
864
|
weight: n.bold ? "700" : String(n.fontWeight ?? 400),
|
|
865
865
|
style: n.italic ? "italic" : "normal",
|
|
866
866
|
family: Cl(n)
|
|
@@ -937,7 +937,7 @@ function ge(n, t) {
|
|
|
937
937
|
return wn.size >= Pl && wn.clear(), wn.set(i, a), a;
|
|
938
938
|
}
|
|
939
939
|
function qt(n) {
|
|
940
|
-
const t = n.fontSize ??
|
|
940
|
+
const t = n.fontSize ?? Le.fontSize, e = n.lineHeight;
|
|
941
941
|
if (typeof e == "number") {
|
|
942
942
|
if (Number.isFinite(e) && e > 0) return Math.round(t * e);
|
|
943
943
|
} else if (typeof e == "string") {
|
|
@@ -979,10 +979,10 @@ function Yt(n, t, e) {
|
|
|
979
979
|
underline: o.underline ?? !!l,
|
|
980
980
|
underlineStyle: o.underlineStyle,
|
|
981
981
|
strikethrough: o.strikethrough ?? !1,
|
|
982
|
-
fontSize: o.fontSize ?? ((e.heading ?? 0) > 0 ? s.fontSize : void 0) ?? ((h = n.textDefaults) == null ? void 0 : h.fontSize) ??
|
|
982
|
+
fontSize: o.fontSize ?? ((e.heading ?? 0) > 0 ? s.fontSize : void 0) ?? ((h = n.textDefaults) == null ? void 0 : h.fontSize) ?? Le.fontSize,
|
|
983
983
|
fontFamily: o.fontFamily ?? ((u = n.textDefaults) == null ? void 0 : u.fontFamily),
|
|
984
984
|
fontWeight: o.fontWeight ?? ((d = n.textDefaults) == null ? void 0 : d.fontWeight),
|
|
985
|
-
color: o.color ?? a.color ?? (l ? si : ((f = n.textDefaults) == null ? void 0 : f.color) ??
|
|
985
|
+
color: o.color ?? a.color ?? (l ? si : ((f = n.textDefaults) == null ? void 0 : f.color) ?? Le.color),
|
|
986
986
|
fill: o.fill,
|
|
987
987
|
// 行高只认 textDefaults(整篇统一);不传时不写这个键,保持旧的样式对象形状
|
|
988
988
|
...((g = n.textDefaults) == null ? void 0 : g.lineHeight) != null ? { lineHeight: n.textDefaults.lineHeight } : {},
|
|
@@ -1021,7 +1021,7 @@ const Di = 8;
|
|
|
1021
1021
|
function zr(n, t, e, s) {
|
|
1022
1022
|
const i = Hs(n, t, e, s);
|
|
1023
1023
|
if (i != null) return i;
|
|
1024
|
-
const r = n.length - t, o = e.fontSize ??
|
|
1024
|
+
const r = n.length - t, o = e.fontSize ?? Le.fontSize;
|
|
1025
1025
|
let a = Math.max(64, Math.ceil(s / (o * 0.25)) + Di * 2);
|
|
1026
1026
|
for (; ; ) {
|
|
1027
1027
|
const l = a >= r, c = n.slice(t, t + (l ? r : a)), h = Ol(c, e), u = Fa(h, { segmentIndex: 0, graphemeIndex: 0 }, s), d = u != null && u.text ? Math.min(u.text.length, c.length) : c.length;
|
|
@@ -1046,7 +1046,7 @@ function Hl(n, t, e, s) {
|
|
|
1046
1046
|
};
|
|
1047
1047
|
for (const a of n.virtualBlocksOverlapping(t, e)) {
|
|
1048
1048
|
if (a.kind !== "mark" || _r(s, a)) continue;
|
|
1049
|
-
const l = le(a), c =
|
|
1049
|
+
const l = le(a), c = Re(a);
|
|
1050
1050
|
if (!(l + c <= 0)) {
|
|
1051
1051
|
if (s.some((h) => h.block.id === a.id)) {
|
|
1052
1052
|
a.start >= t && a.start < e && o(a.start, "start", l, c);
|
|
@@ -1092,7 +1092,7 @@ function zl(n, t, e, s, i) {
|
|
|
1092
1092
|
if (a.kind !== "mark" || a.start !== a.end || _r(i, a)) continue;
|
|
1093
1093
|
const l = ((o = ht == null ? void 0 : ht.get(a.id)) == null ? void 0 : o.label) || a.placeholder;
|
|
1094
1094
|
if (!l || a.start < t || a.start >= e) continue;
|
|
1095
|
-
const c = a.start > 0 ? a.start - 1 : Math.min(Math.max(a.start, t), e - 1), h = ds(Yt(n, c, s), a.chrome), u = It(l, h), d = le(a) +
|
|
1095
|
+
const c = a.start > 0 ? a.start - 1 : Math.min(Math.max(a.start, t), e - 1), h = ds(Yt(n, c, s), a.chrome), u = It(l, h), d = le(a) + Re(a);
|
|
1096
1096
|
if (u > 0.5 || d > 0) {
|
|
1097
1097
|
const f = r.get(a.start) ?? [];
|
|
1098
1098
|
f.push({
|
|
@@ -1102,7 +1102,7 @@ function zl(n, t, e, s, i) {
|
|
|
1102
1102
|
text: l,
|
|
1103
1103
|
style: h,
|
|
1104
1104
|
pad: d,
|
|
1105
|
-
margin:
|
|
1105
|
+
margin: Re(a)
|
|
1106
1106
|
}), r.set(a.start, f);
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
@@ -1180,7 +1180,7 @@ function Kr(n, t, e, s) {
|
|
|
1180
1180
|
const d = c.get(u);
|
|
1181
1181
|
if (d) {
|
|
1182
1182
|
if (d.head) {
|
|
1183
|
-
const k = d.block, w = ds(Yt(n, d.s, s), k.chrome), b = le(k) +
|
|
1183
|
+
const k = d.block, w = ds(Yt(n, d.s, s), k.chrome), b = le(k) + Re(k);
|
|
1184
1184
|
r.push({
|
|
1185
1185
|
kind: "hold",
|
|
1186
1186
|
index: d.s,
|
|
@@ -1192,7 +1192,7 @@ function Kr(n, t, e, s) {
|
|
|
1192
1192
|
style: w,
|
|
1193
1193
|
lock: !0,
|
|
1194
1194
|
span: k.end <= e ? k.end - k.start : e - k.start,
|
|
1195
|
-
margin:
|
|
1195
|
+
margin: Re(k)
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
1198
1198
|
u = d.e;
|
|
@@ -2081,7 +2081,7 @@ function uc(n, t, e, s, i, r, o, a, l) {
|
|
|
2081
2081
|
if (!ct || ct.kind !== "mark") continue;
|
|
2082
2082
|
const Z = le(ct), K = le(d);
|
|
2083
2083
|
if (dt) {
|
|
2084
|
-
const Lt =
|
|
2084
|
+
const Lt = Re(ct);
|
|
2085
2085
|
f.push({ x: P.x - Z, y: P.y, w: P.w + Z * 2 + Lt, h: P.h });
|
|
2086
2086
|
} else
|
|
2087
2087
|
f.push({ x: P.x - Z + K, y: P.y, w: P.w + Z * 2 - K * 2, h: P.h });
|
|
@@ -3253,7 +3253,7 @@ const Qn = /* @__PURE__ */ new Map();
|
|
|
3253
3253
|
function sr(n) {
|
|
3254
3254
|
Qn.set(n.kind, n);
|
|
3255
3255
|
}
|
|
3256
|
-
function
|
|
3256
|
+
function Pe(n) {
|
|
3257
3257
|
const t = Qn.get(n ?? "image") ?? Qn.get("image");
|
|
3258
3258
|
if (!t)
|
|
3259
3259
|
throw new Error(
|
|
@@ -3265,7 +3265,7 @@ function po(n, t, e, s) {
|
|
|
3265
3265
|
var r, o;
|
|
3266
3266
|
const i = /* @__PURE__ */ new Set();
|
|
3267
3267
|
for (const a of e) {
|
|
3268
|
-
const l =
|
|
3268
|
+
const l = Pe(a.entity.kind);
|
|
3269
3269
|
if (s && !l.overlayOnCanvas) continue;
|
|
3270
3270
|
i.add(a.entity.id);
|
|
3271
3271
|
let c = t.get(a.entity.id);
|
|
@@ -3311,7 +3311,7 @@ function Ye(n) {
|
|
|
3311
3311
|
function ps(n) {
|
|
3312
3312
|
return { type: "deleteVirtualBlock", blockId: n };
|
|
3313
3313
|
}
|
|
3314
|
-
function
|
|
3314
|
+
function be(n, t) {
|
|
3315
3315
|
return { type: "updateVirtualBlock", blockId: n, block: { ...t, id: n } };
|
|
3316
3316
|
}
|
|
3317
3317
|
const X = { type: "null" };
|
|
@@ -3439,7 +3439,7 @@ function dh(n, t) {
|
|
|
3439
3439
|
let i = e;
|
|
3440
3440
|
return e < n.length && n[e] === x.TABLE_END && (i = e + 1), { kind: "table", start: t, end: i, rows: s };
|
|
3441
3441
|
}
|
|
3442
|
-
function
|
|
3442
|
+
function Ee(n, t) {
|
|
3443
3443
|
for (const e of wt(n))
|
|
3444
3444
|
if (e.kind === "table" && t >= e.start && t < e.end)
|
|
3445
3445
|
return e;
|
|
@@ -3509,7 +3509,7 @@ function gh(n) {
|
|
|
3509
3509
|
return e;
|
|
3510
3510
|
}
|
|
3511
3511
|
function gt(n, t) {
|
|
3512
|
-
const e =
|
|
3512
|
+
const e = Ee(n, t);
|
|
3513
3513
|
if (!e) return null;
|
|
3514
3514
|
for (let s = 0; s < e.rows.length; s++) {
|
|
3515
3515
|
const i = e.rows[s];
|
|
@@ -3954,7 +3954,7 @@ class vo {
|
|
|
3954
3954
|
return e ? e.props.url : null;
|
|
3955
3955
|
}
|
|
3956
3956
|
tablePropsAt(t) {
|
|
3957
|
-
const e =
|
|
3957
|
+
const e = Ee(this.spacers, t);
|
|
3958
3958
|
if (!e) return {};
|
|
3959
3959
|
const s = this.styles.find((i) => i.type === "table" && i.start <= e.start && i.end >= e.end);
|
|
3960
3960
|
return { ...s == null ? void 0 : s.props };
|
|
@@ -4255,7 +4255,7 @@ const Ph = {
|
|
|
4255
4255
|
},
|
|
4256
4256
|
updateVirtualBlock: (n, t) => {
|
|
4257
4257
|
const e = n.blockById(t.blockId);
|
|
4258
|
-
return e ?
|
|
4258
|
+
return e ? be(t.blockId, e) : X;
|
|
4259
4259
|
},
|
|
4260
4260
|
deleteVirtualBlock: (n, t) => {
|
|
4261
4261
|
const e = n.blockById(t.blockId);
|
|
@@ -4279,16 +4279,16 @@ function Th(n, t) {
|
|
|
4279
4279
|
function Eo(n, t) {
|
|
4280
4280
|
return !n || !t ? n === t : n.min === t.min && n.max === t.max;
|
|
4281
4281
|
}
|
|
4282
|
-
function
|
|
4282
|
+
function Fe(n, t, e) {
|
|
4283
4283
|
return n >= t ? n + e : n;
|
|
4284
4284
|
}
|
|
4285
4285
|
function Lh(n, t, e) {
|
|
4286
|
-
return n === t ? n :
|
|
4286
|
+
return n === t ? n : Fe(n, t, e);
|
|
4287
4287
|
}
|
|
4288
4288
|
function Ao(n, t, e) {
|
|
4289
4289
|
return n ? ue(
|
|
4290
|
-
|
|
4291
|
-
|
|
4290
|
+
Fe(n.min, t, e),
|
|
4291
|
+
Fe(n.max, t, e)
|
|
4292
4292
|
) : null;
|
|
4293
4293
|
}
|
|
4294
4294
|
function Rh(n, t) {
|
|
@@ -4306,7 +4306,7 @@ function Co(n, t) {
|
|
|
4306
4306
|
function $h(n, t, e) {
|
|
4307
4307
|
return t.insertBeforeIndex === n.insertBeforeIndex && e ? n : {
|
|
4308
4308
|
...n,
|
|
4309
|
-
insertBeforeIndex:
|
|
4309
|
+
insertBeforeIndex: Fe(n.insertBeforeIndex, t.insertBeforeIndex, t.spacers.length)
|
|
4310
4310
|
};
|
|
4311
4311
|
}
|
|
4312
4312
|
function Fh(n, t) {
|
|
@@ -4315,7 +4315,7 @@ function Fh(n, t) {
|
|
|
4315
4315
|
const e = t.endIndex - t.startIndex + 1;
|
|
4316
4316
|
return {
|
|
4317
4317
|
...n,
|
|
4318
|
-
insertBeforeIndex:
|
|
4318
|
+
insertBeforeIndex: Fe(n.insertBeforeIndex, t.startIndex + 1, -e)
|
|
4319
4319
|
};
|
|
4320
4320
|
}
|
|
4321
4321
|
function Dh(n, t) {
|
|
@@ -4426,7 +4426,7 @@ function pe(n, t, e = !0) {
|
|
|
4426
4426
|
function Zs(n, t, e = !1) {
|
|
4427
4427
|
let s = n;
|
|
4428
4428
|
for (const i of t)
|
|
4429
|
-
i.type === "insertSpacers" ? s = e ?
|
|
4429
|
+
i.type === "insertSpacers" ? s = e ? Fe(s, i.insertBeforeIndex, i.spacers.length) : Lh(s, i.insertBeforeIndex, i.spacers.length) : i.type === "deleteSpacers" ? s = Js(s, { min: i.startIndex, max: i.endIndex }) : i.type === "multi" && (s = Zs(s, Tt(i), e));
|
|
4430
4430
|
return s;
|
|
4431
4431
|
}
|
|
4432
4432
|
function Cn(n, t, e = !1) {
|
|
@@ -4717,7 +4717,7 @@ function Qs(n) {
|
|
|
4717
4717
|
const e = t.doc.linkSpanAt(n);
|
|
4718
4718
|
if (!e) return;
|
|
4719
4719
|
const { start: s, end: i } = e;
|
|
4720
|
-
Qt(t, "link", s, i, null), fn(t, s, i, { color:
|
|
4720
|
+
Qt(t, "link", s, i, null), fn(t, s, i, { color: Le.color, underline: !1 });
|
|
4721
4721
|
};
|
|
4722
4722
|
}
|
|
4723
4723
|
function jt(n, t, e) {
|
|
@@ -4785,7 +4785,7 @@ function No(n) {
|
|
|
4785
4785
|
const t = n[n.length - 1];
|
|
4786
4786
|
return t === " " || t === "-" || t === "*" || t === "`" || t === "$";
|
|
4787
4787
|
}
|
|
4788
|
-
function
|
|
4788
|
+
function De(n, t) {
|
|
4789
4789
|
return (e) => {
|
|
4790
4790
|
const s = e.doc.clamp(n), i = J({
|
|
4791
4791
|
...t,
|
|
@@ -4841,7 +4841,7 @@ function Hn(n) {
|
|
|
4841
4841
|
function Wo(n, t) {
|
|
4842
4842
|
return (e) => {
|
|
4843
4843
|
const s = e.doc.blockById(n);
|
|
4844
|
-
return s ? (e.emit(
|
|
4844
|
+
return s ? (e.emit(be(n, { ...s, chrome: { ...s.chrome, ...t } })), !0) : !1;
|
|
4845
4845
|
};
|
|
4846
4846
|
}
|
|
4847
4847
|
function iu(n, t, e) {
|
|
@@ -4867,7 +4867,7 @@ function zo(n, t, e) {
|
|
|
4867
4867
|
end: Math.max(o.end, e),
|
|
4868
4868
|
empty: o.empty
|
|
4869
4869
|
};
|
|
4870
|
-
(a.start !== o.start || a.end !== o.end || a.empty !== o.empty) && s.emit(
|
|
4870
|
+
(a.start !== o.start || a.end !== o.end || a.empty !== o.empty) && s.emit(be(o.id, a));
|
|
4871
4871
|
}
|
|
4872
4872
|
};
|
|
4873
4873
|
}
|
|
@@ -4903,7 +4903,7 @@ function au(n, t) {
|
|
|
4903
4903
|
const s = t.indexOf(`
|
|
4904
4904
|
`), i = s === -1 ? t.length : s;
|
|
4905
4905
|
for (const r of e.doc.listVirtualBlocks())
|
|
4906
|
-
r.kind !== "mark" || !r.placeholder || r.start !== n || r.end !== n || U(r.chrome) || e.emit(
|
|
4906
|
+
r.kind !== "mark" || !r.placeholder || r.start !== n || r.end !== n || U(r.chrome) || e.emit(be(r.id, { ...r, end: n + i, empty: !1 }));
|
|
4907
4907
|
};
|
|
4908
4908
|
}
|
|
4909
4909
|
function lu(n, t) {
|
|
@@ -4913,7 +4913,7 @@ function lu(n, t) {
|
|
|
4913
4913
|
const s = n + t.length, i = n + t.lastIndexOf(`
|
|
4914
4914
|
`) + 1;
|
|
4915
4915
|
for (const r of e.doc.listVirtualBlocks())
|
|
4916
|
-
r.kind !== "mark" || r.start !== s || U(r.chrome) || e.emit(
|
|
4916
|
+
r.kind !== "mark" || r.start !== s || U(r.chrome) || e.emit(be(r.id, { ...r, start: i }));
|
|
4917
4917
|
};
|
|
4918
4918
|
}
|
|
4919
4919
|
function cu(n, t) {
|
|
@@ -4923,7 +4923,7 @@ function cu(n, t) {
|
|
|
4923
4923
|
const s = t.indexOf(`
|
|
4924
4924
|
`), i = s === -1 ? t.length : s;
|
|
4925
4925
|
for (const r of e.doc.listVirtualBlocks())
|
|
4926
|
-
r.kind !== "mark" || r.end !== n || U(r.chrome) || e.emit(
|
|
4926
|
+
r.kind !== "mark" || r.end !== n || U(r.chrome) || e.emit(be(r.id, { ...r, end: r.end + i, empty: !1 }));
|
|
4927
4927
|
};
|
|
4928
4928
|
}
|
|
4929
4929
|
const _o = { text: "", styles: [], entities: [] };
|
|
@@ -4956,7 +4956,7 @@ function uu(n, t, e) {
|
|
|
4956
4956
|
s += i.length;
|
|
4957
4957
|
}
|
|
4958
4958
|
}
|
|
4959
|
-
function
|
|
4959
|
+
function Te(n, t, e, s = "backward") {
|
|
4960
4960
|
return (i) => {
|
|
4961
4961
|
if (!t) return i.doc.clamp(n);
|
|
4962
4962
|
const r = t.replace(/\r\n/g, `
|
|
@@ -4978,8 +4978,8 @@ function Vo(n, t) {
|
|
|
4978
4978
|
`);
|
|
4979
4979
|
if (!a && !r)
|
|
4980
4980
|
return e.doc.blockById(n) && e.emit(ps(n)), i;
|
|
4981
|
-
const l = a ?
|
|
4982
|
-
return c ? (c.start !== i || c.end !== h || !!c.empty == !!a) && e.emit(
|
|
4981
|
+
const l = a ? Te(i, a)(e) : i, c = e.doc.blockById(n), h = a ? l : i;
|
|
4982
|
+
return c ? (c.start !== i || c.end !== h || !!c.empty == !!a) && e.emit(be(n, { ...c, start: i, end: h, empty: !a })) : e.emit(
|
|
4983
4983
|
Ye({
|
|
4984
4984
|
id: n,
|
|
4985
4985
|
parentId: null,
|
|
@@ -5051,7 +5051,7 @@ function Uo(n) {
|
|
|
5051
5051
|
if (s >= e.length) return null;
|
|
5052
5052
|
const i = e.charAt(s);
|
|
5053
5053
|
if (i === x.TABLE_START) {
|
|
5054
|
-
const a =
|
|
5054
|
+
const a = Ee(e.spacers, s);
|
|
5055
5055
|
if (a) {
|
|
5056
5056
|
const l = ot(t, a.start, a.end);
|
|
5057
5057
|
return z(t), { start: a.start, end: a.end, slice: l };
|
|
@@ -5078,7 +5078,7 @@ function Xo(n) {
|
|
|
5078
5078
|
if (r.kind === "list")
|
|
5079
5079
|
return Se(e, i.start).list === r.list ? s : o(r.consume, { list: r.list, heading: 0 });
|
|
5080
5080
|
if (r.kind === "code-block")
|
|
5081
|
-
return ot(t, i.start, i.start + r.consume), z(t),
|
|
5081
|
+
return ot(t, i.start, i.start + r.consume), z(t), De(i.start, {
|
|
5082
5082
|
kind: "code",
|
|
5083
5083
|
width: 680,
|
|
5084
5084
|
height: 80,
|
|
@@ -5087,7 +5087,7 @@ function Xo(n) {
|
|
|
5087
5087
|
})(t);
|
|
5088
5088
|
if (r.kind === "formula") {
|
|
5089
5089
|
const l = i.start + r.matchStart;
|
|
5090
|
-
return ot(t, l, i.start + r.matchEnd), z(t),
|
|
5090
|
+
return ot(t, l, i.start + r.matchEnd), z(t), De(l, {
|
|
5091
5091
|
kind: "formula",
|
|
5092
5092
|
width: 200,
|
|
5093
5093
|
height: 48,
|
|
@@ -5137,7 +5137,7 @@ function qo(n) {
|
|
|
5137
5137
|
for (const o of [...e.table.rows].reverse())
|
|
5138
5138
|
s.push(o.cells[Math.min(e.col, o.cells.length - 1)].end);
|
|
5139
5139
|
for (const o of s) xt(t, o, x.TABLE_CELL + x.PARAGRAPH);
|
|
5140
|
-
const i =
|
|
5140
|
+
const i = Ee(t.doc.spacers, n);
|
|
5141
5141
|
if (i) {
|
|
5142
5142
|
const o = di(t, i.start, i.end), a = [...((r = o == null ? void 0 : o.props) == null ? void 0 : r.colWidths) ?? []];
|
|
5143
5143
|
a.splice(e.col + 1, 0, 0), fi(t, i.start, i.end, a);
|
|
@@ -5162,7 +5162,7 @@ function Jo(n) {
|
|
|
5162
5162
|
const o = r.cells[e.col];
|
|
5163
5163
|
o && ot(t, o.start, o.end);
|
|
5164
5164
|
}
|
|
5165
|
-
const s =
|
|
5165
|
+
const s = Ee(t.doc.spacers, e.table.start);
|
|
5166
5166
|
if (s) {
|
|
5167
5167
|
const r = di(t, s.start, s.end), o = (i = r == null ? void 0 : r.props) == null ? void 0 : i.colWidths;
|
|
5168
5168
|
if (o && o.length > e.col) {
|
|
@@ -5175,7 +5175,7 @@ function Jo(n) {
|
|
|
5175
5175
|
}
|
|
5176
5176
|
function Wn(n, t) {
|
|
5177
5177
|
return (e) => {
|
|
5178
|
-
const s =
|
|
5178
|
+
const s = Ee(e.doc.spacers, n);
|
|
5179
5179
|
s && fi(e, s.start, s.end, t);
|
|
5180
5180
|
};
|
|
5181
5181
|
}
|
|
@@ -5291,12 +5291,12 @@ function yu(n, t) {
|
|
|
5291
5291
|
if ((r == null ? void 0 : r.kind) !== "ref" || !r.fragmentId) continue;
|
|
5292
5292
|
const o = e.get(r.fragmentId);
|
|
5293
5293
|
ci(s, R(i), (a) => {
|
|
5294
|
-
ot(a, i, i + 1), z(a), o &&
|
|
5294
|
+
ot(a, i, i + 1), z(a), o && Oe(i, nn(o.slice), !1)(a);
|
|
5295
5295
|
});
|
|
5296
5296
|
}
|
|
5297
5297
|
return So(s);
|
|
5298
5298
|
}
|
|
5299
|
-
function
|
|
5299
|
+
function Oe(n, t, e = !0, s = "backward") {
|
|
5300
5300
|
return (i) => {
|
|
5301
5301
|
const r = i.doc, o = e ? yu(r, t) : nn(t), a = r.clamp(n), l = /* @__PURE__ */ new Map(), c = o.entities.map((u) => {
|
|
5302
5302
|
if (!r.entities.has(u.id)) return J(u);
|
|
@@ -5336,11 +5336,11 @@ function Zo(n, t, e = "backward") {
|
|
|
5336
5336
|
const d = h.length - 1;
|
|
5337
5337
|
h = h.slice(0, d), u = u.map((f) => ({ ...f, start: Math.min(f.start, d), end: Math.min(f.end, d) })).filter((f) => f.end > f.start);
|
|
5338
5338
|
}
|
|
5339
|
-
return
|
|
5339
|
+
return Oe(l, { text: h, styles: u, entities: c.entities }, !0, e)(s), l + h.length;
|
|
5340
5340
|
};
|
|
5341
5341
|
}
|
|
5342
5342
|
function Qo(n, t, e, s = "backward") {
|
|
5343
|
-
return (i) => fu(t) ? Zo(n, t, s)(i) :
|
|
5343
|
+
return (i) => fu(t) ? Zo(n, t, s)(i) : Te(n, t, e, s)(i);
|
|
5344
5344
|
}
|
|
5345
5345
|
function ta(n, t) {
|
|
5346
5346
|
return (e) => {
|
|
@@ -5355,7 +5355,7 @@ function ta(n, t) {
|
|
|
5355
5355
|
};
|
|
5356
5356
|
}
|
|
5357
5357
|
function pi(n, t) {
|
|
5358
|
-
return (e) => e.doc.fragments.has(t) ?
|
|
5358
|
+
return (e) => e.doc.fragments.has(t) ? De(n, {
|
|
5359
5359
|
kind: "ref",
|
|
5360
5360
|
fragmentId: t,
|
|
5361
5361
|
width: 680,
|
|
@@ -5367,7 +5367,7 @@ function ea(n) {
|
|
|
5367
5367
|
const e = t.doc, s = e.clamp(n), i = e.imageAt(s);
|
|
5368
5368
|
if ((i == null ? void 0 : i.kind) !== "ref" || !i.fragmentId) return null;
|
|
5369
5369
|
const r = e.fragments.get(i.fragmentId);
|
|
5370
|
-
return r ? (ot(t, s, s + 1), z(t),
|
|
5370
|
+
return r ? (ot(t, s, s + 1), z(t), Oe(s, nn(r.slice), !0)(t)) : null;
|
|
5371
5371
|
};
|
|
5372
5372
|
}
|
|
5373
5373
|
const Jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -5391,15 +5391,15 @@ const Jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5391
5391
|
emitTextStyle: fn,
|
|
5392
5392
|
ensureParagraphAfter: Oo,
|
|
5393
5393
|
expectedParagraphSpans: Do,
|
|
5394
|
-
insertImage:
|
|
5394
|
+
insertImage: De,
|
|
5395
5395
|
insertMarkdown: Zo,
|
|
5396
5396
|
insertParagraph: rn,
|
|
5397
5397
|
insertRef: pi,
|
|
5398
|
-
insertSlice:
|
|
5398
|
+
insertSlice: Oe,
|
|
5399
5399
|
insertTable: jo,
|
|
5400
5400
|
insertTableCol: qo,
|
|
5401
5401
|
insertTableRow: ti,
|
|
5402
|
-
insertText:
|
|
5402
|
+
insertText: Te,
|
|
5403
5403
|
insertVirtualBlock: ui,
|
|
5404
5404
|
normalizeParagraphs: z,
|
|
5405
5405
|
pasteText: Qo,
|
|
@@ -6547,10 +6547,10 @@ class Uu {
|
|
|
6547
6547
|
for (const f of u.vblocks ?? []) this.paintVBlock(s, f);
|
|
6548
6548
|
this.paintGlyphs(s, u.glyphs, u.paragraphStart), this.paintLineDeco(s, u.glyphs, u.paragraphStart);
|
|
6549
6549
|
for (const f of u.images)
|
|
6550
|
-
|
|
6550
|
+
Pe(f.entity.kind).paintCanvasBackdrop(s, f, (g) => this.imageOf(g));
|
|
6551
6551
|
}
|
|
6552
6552
|
for (const h of i.images)
|
|
6553
|
-
!h.entity.float || !a(h.y, h.h) ||
|
|
6553
|
+
!h.entity.float || !a(h.y, h.h) || Pe(h.entity.kind).paintCanvasBackdrop(s, h, (u) => this.imageOf(u));
|
|
6554
6554
|
s.restore(), this.hasContent = !0;
|
|
6555
6555
|
}
|
|
6556
6556
|
redrawChrome() {
|
|
@@ -6819,7 +6819,7 @@ class Zu {
|
|
|
6819
6819
|
const k = a ? "hover" : o ? "selected" : "base", w = Array.from(c).some((b) => b.dataset.skin === k);
|
|
6820
6820
|
for (const b of c) b.style.display = b.dataset.skin === (w ? k : "base") ? "" : "none";
|
|
6821
6821
|
}
|
|
6822
|
-
const h =
|
|
6822
|
+
const h = Be(this.host, "--mini-sel-focus-gap"), u = { x: parseFloat(t.style.left), y: parseFloat(t.style.top), w: parseFloat(t.style.width), h: parseFloat(t.style.height) }, d = o && this.focusGeometry ? mi(this.focusGeometry, Be(this.host, "--mini-sel-height"), h, u, parseFloat(t.dataset.selectedBorderWidth ?? "1") || 1) : null, f = t.querySelector('.mini-vblock-frame path[data-skin="selected"]');
|
|
6823
6823
|
let g = t.querySelector(":scope > .mini-selected-frame");
|
|
6824
6824
|
if (d && t.dataset.selectedBorderColor && t.dataset.selectedFrameGeometry) {
|
|
6825
6825
|
g || (g = document.createElementNS("http://www.w3.org/2000/svg", "svg"), g.setAttribute("class", "mini-selected-frame"), t.appendChild(g));
|
|
@@ -6833,7 +6833,7 @@ class Zu {
|
|
|
6833
6833
|
paintSelection(t) {
|
|
6834
6834
|
if (!this.selection) return;
|
|
6835
6835
|
this.selection.replaceChildren();
|
|
6836
|
-
const e =
|
|
6836
|
+
const e = Be(this.host, "--mini-sel-height");
|
|
6837
6837
|
for (const s of t) {
|
|
6838
6838
|
const i = document.createElement("div");
|
|
6839
6839
|
i.className = s.outline ? "mini-vblock-outline" : "mini-sel-rect";
|
|
@@ -6852,7 +6852,7 @@ class Zu {
|
|
|
6852
6852
|
s.style.display !== "none" && (s.style.display = "none");
|
|
6853
6853
|
return;
|
|
6854
6854
|
}
|
|
6855
|
-
const i = gs(t,
|
|
6855
|
+
const i = gs(t, Be(this.host, "--mini-sel-height"), this.selectedId && Be(this.host, "--mini-sel-focus-gap") || 0), r = `left:${t.x}px;top:${i.y}px;height:${i.h}px;${e ? "border-radius:999px;" : ""}`;
|
|
6856
6856
|
s.style.cssText !== r && (s.style.cssText = r);
|
|
6857
6857
|
}
|
|
6858
6858
|
destroy() {
|
|
@@ -6860,7 +6860,7 @@ class Zu {
|
|
|
6860
6860
|
(t = this.surface) == null || t.remove(), this.host = null, this.surface = null, this.content = null, this.selection = null, this.caret = null, this.focusMark = null, this.trails = [], this.embeds = null, this.embedCache.clear();
|
|
6861
6861
|
}
|
|
6862
6862
|
}
|
|
6863
|
-
function
|
|
6863
|
+
function Be(n, t) {
|
|
6864
6864
|
return n ? parseFloat(getComputedStyle(n).getPropertyValue(t)) : NaN;
|
|
6865
6865
|
}
|
|
6866
6866
|
function ma(n, t, e) {
|
|
@@ -6873,7 +6873,7 @@ function yr(n, t, e) {
|
|
|
6873
6873
|
}
|
|
6874
6874
|
const s = t.bold ? 4.5 : "";
|
|
6875
6875
|
n.style.display !== "block" && (n.style.display = "block");
|
|
6876
|
-
const i = n.closest(".mini-editor"), r = (i == null ? void 0 : i.dataset.caret) !== "rainbow", o = ma(t.y, t.h, r ?
|
|
6876
|
+
const i = n.closest(".mini-editor"), r = (i == null ? void 0 : i.dataset.caret) !== "rainbow", o = ma(t.y, t.h, r ? Be(i, "--mini-caret-height") : NaN);
|
|
6877
6877
|
if (n.style.left !== `${t.x}px` || n.style.top !== `${o.y}px`)
|
|
6878
6878
|
for (const a of n.getAnimations()) a.currentTime = 0;
|
|
6879
6879
|
n.style.left = `${t.x}px`, n.style.top = `${o.y}px`, n.style.height = `${o.h}px`, n.style.width = s === "" ? "" : `${s}px`, t.opacity != null ? n.style.opacity = String(t.opacity * e) : n.style.opacity && (n.style.opacity = ""), n.style.transform = t.italic ? "skewX(-14deg)" : "none", n.classList.toggle("is-italic", !!t.italic);
|
|
@@ -6906,7 +6906,7 @@ function Qu(n) {
|
|
|
6906
6906
|
}
|
|
6907
6907
|
return t;
|
|
6908
6908
|
}
|
|
6909
|
-
function
|
|
6909
|
+
function Ie(n, t) {
|
|
6910
6910
|
const e = (s) => s ? `${n}px` : "0";
|
|
6911
6911
|
return `${e(t.top)} ${e(t.right)} ${e(t.bottom)} ${e(t.left)}`;
|
|
6912
6912
|
}
|
|
@@ -6915,7 +6915,7 @@ function td(n) {
|
|
|
6915
6915
|
const t = document.createElement("span");
|
|
6916
6916
|
t.className = `mini-vblock${n.pulse ? " is-pulse" : ""}`, t.dataset.id = n.id;
|
|
6917
6917
|
const e = n.chrome, s = ca(n), i = s ? ua(n) : aa(n), r = la(n), o = Je(e, null), a = Je(e, "hover"), l = (h = e.selectedBorder) != null && h.color ? Je(e, "selected") : null;
|
|
6918
|
-
(e.hoverBackground || e.selectedBackground) && (e.hoverBackground && (t.dataset.hoverBg = e.hoverBackground), e.selectedBackground && (t.dataset.selectedBg = e.selectedBackground), t.dataset.bg = e.background ?? "transparent"), !s && a && (a.color !== (o == null ? void 0 : o.color) || a.width !== (o == null ? void 0 : o.width)) && (t.dataset.hoverBorderColor = a.color, t.dataset.hoverBorderWidth =
|
|
6918
|
+
(e.hoverBackground || e.selectedBackground) && (e.hoverBackground && (t.dataset.hoverBg = e.hoverBackground), e.selectedBackground && (t.dataset.selectedBg = e.selectedBackground), t.dataset.bg = e.background ?? "transparent"), !s && a && (a.color !== (o == null ? void 0 : o.color) || a.width !== (o == null ? void 0 : o.width)) && (t.dataset.hoverBorderColor = a.color, t.dataset.hoverBorderWidth = Ie(a.width, r), t.dataset.borderColor = (o == null ? void 0 : o.color) ?? "transparent", t.dataset.borderWidth = Ie(o ? o.width : 0, r)), !s && l && (l.color !== (o == null ? void 0 : o.color) || l.width !== (o == null ? void 0 : o.width)) && (t.dataset.selectedBorderColor = l.color, t.dataset.selectedBorderWidth = Ie(l.width, r), t.dataset.borderColor = (o == null ? void 0 : o.color) ?? "transparent", t.dataset.borderWidth = Ie(o ? o.width : 0, r));
|
|
6919
6919
|
const c = s ? `border:none;border-radius:${i.map((u) => `${u}px`).join(" ")}` : o || a ? Vu((o == null ? void 0 : o.color) ?? "transparent", (o == null ? void 0 : o.width) ?? 0, i, r) : `border:none;border-radius:${i.map((u) => `${u}px`).join(" ")}`;
|
|
6920
6920
|
return t.style.cssText = [
|
|
6921
6921
|
`left:${n.x}px`,
|
|
@@ -7185,7 +7185,7 @@ function pn(n) {
|
|
|
7185
7185
|
function Ge(n, t) {
|
|
7186
7186
|
return cs(t.chrome) && !(t.end > t.start && n.locked(t.id));
|
|
7187
7187
|
}
|
|
7188
|
-
function
|
|
7188
|
+
function Ne(n, t) {
|
|
7189
7189
|
const e = n.doc.imageAt(t);
|
|
7190
7190
|
return !!e && !cs(e.chrome);
|
|
7191
7191
|
}
|
|
@@ -7209,7 +7209,7 @@ function we(n, t) {
|
|
|
7209
7209
|
const e = t.sel.focus;
|
|
7210
7210
|
return F(t.sel) && ((i = t.affinity) == null ? void 0 : i.index) === e && t.affinity.dir === "forward" && ka(n, t, e) ? "forward" : "backward";
|
|
7211
7211
|
}
|
|
7212
|
-
function
|
|
7212
|
+
function Ae(n, t, e, s) {
|
|
7213
7213
|
return e.kind !== "mark" || !Ge(n, e) || U(e.chrome) ? !1 : e.start === e.end ? t.armedId === e.id || !e.placeholder || e.start !== s ? !1 : !(we(n, t) === "forward" && wi(n, s)) : s > e.start && s < e.end ? !0 : s === e.end ? we(n, t) !== "forward" : s === e.start ? we(n, t) === "forward" : !1;
|
|
7214
7214
|
}
|
|
7215
7215
|
function Md(n, t) {
|
|
@@ -7224,7 +7224,7 @@ function Mi(n, t) {
|
|
|
7224
7224
|
function vd(n, t) {
|
|
7225
7225
|
if (!F(t.sel) || t.armedId) return null;
|
|
7226
7226
|
const e = Mi(n, t.sel.focus);
|
|
7227
|
-
return e &&
|
|
7227
|
+
return e && Ae(n, t, e, t.sel.focus) ? e : null;
|
|
7228
7228
|
}
|
|
7229
7229
|
function ce(n, t) {
|
|
7230
7230
|
if (!t.armedId || !F(t.sel)) return null;
|
|
@@ -7257,7 +7257,7 @@ function os(n, t, e) {
|
|
|
7257
7257
|
const s = t.sel.focus;
|
|
7258
7258
|
let i = null;
|
|
7259
7259
|
for (const r of Ms(n))
|
|
7260
|
-
!(e > 0 ? r.start === s : r.end === s) ||
|
|
7260
|
+
!(e > 0 ? r.start === s : r.end === s) || Ae(n, t, r, s) || Sd(r, i) && (i = r);
|
|
7261
7261
|
return i;
|
|
7262
7262
|
}
|
|
7263
7263
|
function as(n, t, e) {
|
|
@@ -7265,7 +7265,7 @@ function as(n, t, e) {
|
|
|
7265
7265
|
const s = t.sel.focus;
|
|
7266
7266
|
let i = null;
|
|
7267
7267
|
for (const r of Ms(n))
|
|
7268
|
-
!(e > 0 ? r.end === s : r.start === s) || !
|
|
7268
|
+
!(e > 0 ? r.end === s : r.start === s) || !Ae(n, t, r, s) || vs(r, i) && (i = r);
|
|
7269
7269
|
return i;
|
|
7270
7270
|
}
|
|
7271
7271
|
function bd(n, t, e) {
|
|
@@ -7277,10 +7277,10 @@ function bd(n, t, e) {
|
|
|
7277
7277
|
function Ed(n, t, e) {
|
|
7278
7278
|
if (!F(t.sel)) return null;
|
|
7279
7279
|
const s = t.sel.focus, i = e > 0 ? s : s - 1;
|
|
7280
|
-
if (i < 0 || n.doc.spacers[i] !== x.IMAGE || !
|
|
7280
|
+
if (i < 0 || n.doc.spacers[i] !== x.IMAGE || !Ne(n, i)) return null;
|
|
7281
7281
|
let r = null;
|
|
7282
7282
|
for (const o of Ms(n))
|
|
7283
|
-
!(e > 0 ? o.end === i + 1 : o.start === i) || !
|
|
7283
|
+
!(e > 0 ? o.end === i + 1 : o.start === i) || !Ae(n, t, o, s) || vs(o, r) && (r = o);
|
|
7284
7284
|
return r;
|
|
7285
7285
|
}
|
|
7286
7286
|
function Ad(n, t) {
|
|
@@ -7296,12 +7296,12 @@ function Ad(n, t) {
|
|
|
7296
7296
|
function Cd(n, t) {
|
|
7297
7297
|
if (!F(t.sel)) return !1;
|
|
7298
7298
|
const e = t.sel.focus;
|
|
7299
|
-
return n.doc.listVirtualBlocks().some((s) => !U(s.chrome) &&
|
|
7299
|
+
return n.doc.listVirtualBlocks().some((s) => !U(s.chrome) && Ae(n, t, s, e));
|
|
7300
7300
|
}
|
|
7301
7301
|
function Ma(n, t) {
|
|
7302
7302
|
if (rt(t.sel) - Y(t.sel) !== 1) return null;
|
|
7303
7303
|
const e = Y(t.sel);
|
|
7304
|
-
return n.doc.spacers[e] !== x.IMAGE ||
|
|
7304
|
+
return n.doc.spacers[e] !== x.IMAGE || Ne(n, e) || n.embedLaidOut && !n.embedLaidOut(e) ? null : e;
|
|
7305
7305
|
}
|
|
7306
7306
|
function Id(n) {
|
|
7307
7307
|
return n.doc.listVirtualBlocks().map((t) => t.end > t.start && n.locked(t.id) ? { ...t, chrome: { ...t.chrome, selectable: !1 } } : t);
|
|
@@ -7361,7 +7361,7 @@ function Ea(n, t, e, s) {
|
|
|
7361
7361
|
if (i) {
|
|
7362
7362
|
let o = e.start, a = r ? "forward" : "backward";
|
|
7363
7363
|
if (r) {
|
|
7364
|
-
for (; o < e.end &&
|
|
7364
|
+
for (; o < e.end && Ne(n, o); ) o += 1;
|
|
7365
7365
|
o === e.end && (a = "backward");
|
|
7366
7366
|
}
|
|
7367
7367
|
return Bt(R(o), { index: o, dir: a });
|
|
@@ -7386,7 +7386,7 @@ function Pd(n, t, e) {
|
|
|
7386
7386
|
if (s != null) return R(e < 0 ? s : s + 1);
|
|
7387
7387
|
if (!F(t.sel)) return null;
|
|
7388
7388
|
const i = t.sel.focus;
|
|
7389
|
-
return e > 0 && n.doc.spacers[i] === x.IMAGE ?
|
|
7389
|
+
return e > 0 && n.doc.spacers[i] === x.IMAGE ? Ne(n, i) ? os(n, t, e) || as(n, t, e) ? null : R(i + 1) : { anchor: i, focus: i + 1 } : e < 0 && i > 0 && n.doc.spacers[i - 1] === x.IMAGE ? Ne(n, i - 1) ? os(n, t, e) || as(n, t, e) ? null : R(i - 1) : { anchor: i, focus: i - 1 } : null;
|
|
7390
7390
|
}
|
|
7391
7391
|
function kr(n, t, e) {
|
|
7392
7392
|
const s = we(n, t);
|
|
@@ -7429,8 +7429,7 @@ function Ld(n, t, e, s) {
|
|
|
7429
7429
|
const h = Mi(n, o);
|
|
7430
7430
|
if (h) return Ss(h, e > 0 ? "left" : "right");
|
|
7431
7431
|
}
|
|
7432
|
-
|
|
7433
|
-
!s && n.doc.spacers[o] === x.IMAGE && !be(n, o) ? l = { anchor: o, focus: o + 1 } : s ? l = { ...t.sel, focus: o } : l = R(o);
|
|
7432
|
+
const l = s ? { ...t.sel, focus: o } : R(o);
|
|
7434
7433
|
let c;
|
|
7435
7434
|
return s || !F(l) ? c = null : a.affinity ? c = { index: o, dir: a.affinity } : i ? c = null : c = { index: o, dir: e < 0 ? "forward" : "backward" }, Bt(l, c);
|
|
7436
7435
|
}
|
|
@@ -7692,7 +7691,7 @@ function Wd(n, t, e) {
|
|
|
7692
7691
|
const s = [];
|
|
7693
7692
|
if (!e.refEdit && F(e.sel))
|
|
7694
7693
|
for (const c of t.doc.listVirtualBlocks())
|
|
7695
|
-
|
|
7694
|
+
Ae(t, e, c, e.sel.focus) && s.push(c.id);
|
|
7696
7695
|
if (e.refEdit) return { mark: null, slot: null, caretMarks: s };
|
|
7697
7696
|
const i = bs(n, t, e);
|
|
7698
7697
|
return { mark: i ? null : ((o = vi(t, e)) == null ? void 0 : o.id) ?? ((a = _e(t, e)) == null ? void 0 : a.id) ?? ((l = ce(t, e)) == null ? void 0 : l.id) ?? null, slot: i, caretMarks: s };
|
|
@@ -8012,7 +8011,7 @@ class Qd {
|
|
|
8012
8011
|
return;
|
|
8013
8012
|
}
|
|
8014
8013
|
if ((i == null ? void 0 : i.kind) === "embedResize") {
|
|
8015
|
-
const r = this.doc.entities.get(i.id), o =
|
|
8014
|
+
const r = this.doc.entities.get(i.id), o = Pe(r == null ? void 0 : r.kind), a = gd(i, t.clientX, o.keepAspectRatio);
|
|
8016
8015
|
this.applyNow(At(i.id, a)), !o.keepAspectRatio && r && this.applyNow(At(i.id, o.measure({ ...r, width: a.width }, this.layout.contentWidth))), this.layout = this.layoutMain(this.layout), this.painter.paintDoc(this.layout), this.paintChrome();
|
|
8017
8016
|
return;
|
|
8018
8017
|
}
|
|
@@ -8268,7 +8267,7 @@ class Qd {
|
|
|
8268
8267
|
*/
|
|
8269
8268
|
insertSlice(t, e) {
|
|
8270
8269
|
this.runEdit("insert.paste", (s) => {
|
|
8271
|
-
this.deleteSelectionIfNeeded(s), s.select(R(
|
|
8270
|
+
this.deleteSelectionIfNeeded(s), s.select(R(Oe(e ?? s.selection().focus, t)(s)));
|
|
8272
8271
|
});
|
|
8273
8272
|
}
|
|
8274
8273
|
/** 把指定范围(默认当前选区)包成一层虚拟块。 */
|
|
@@ -8774,7 +8773,7 @@ class Qd {
|
|
|
8774
8773
|
}
|
|
8775
8774
|
if (s.insert = null, e) {
|
|
8776
8775
|
const a = this.applyNowRun((l) => {
|
|
8777
|
-
const c =
|
|
8776
|
+
const c = Te(r, e, o, s.affinity)(l);
|
|
8778
8777
|
return l.select(R(c)), c;
|
|
8779
8778
|
});
|
|
8780
8779
|
a.run.forward.length && (s.insert = a.run);
|
|
@@ -8819,7 +8818,7 @@ class Qd {
|
|
|
8819
8818
|
this.runEdit("insert.text", (s) => {
|
|
8820
8819
|
this.deleteSelectionIfNeeded(s);
|
|
8821
8820
|
const i = this.typingStyle ?? s.doc.textPropsAt(s.selection().focus), r = s.selection().focus;
|
|
8822
|
-
let o =
|
|
8821
|
+
let o = Te(r, t, i, e)(s);
|
|
8823
8822
|
!this.caret.refEdit && No(t) && (o = Xo(o)(s)), s.select(R(o));
|
|
8824
8823
|
});
|
|
8825
8824
|
}
|
|
@@ -8833,7 +8832,7 @@ class Qd {
|
|
|
8833
8832
|
const i = this.armedEmptyMark() ? "backward" : this.caretAffinity();
|
|
8834
8833
|
this.runEdit("insert.paste", (r) => {
|
|
8835
8834
|
if (this.deleteSelectionIfNeeded(r), e) {
|
|
8836
|
-
r.select(R(
|
|
8835
|
+
r.select(R(Oe(r.selection().focus, e, !0, i)(r)));
|
|
8837
8836
|
return;
|
|
8838
8837
|
}
|
|
8839
8838
|
const o = this.typingStyle ?? r.doc.textPropsAt(r.selection().focus), a = Qo(r.selection().focus, s, o, i)(r);
|
|
@@ -8884,7 +8883,7 @@ class Qd {
|
|
|
8884
8883
|
if (this.targetDoc(), F(t)) {
|
|
8885
8884
|
const s = t.focus;
|
|
8886
8885
|
if (!this.caret.refEdit && s > 0 && this.doc.spacers[s - 1] === x.TABLE_END) {
|
|
8887
|
-
const i =
|
|
8886
|
+
const i = Ee(this.doc.spacers, s - 1);
|
|
8888
8887
|
if (i) {
|
|
8889
8888
|
this.caret.sel = { anchor: i.start, focus: i.end }, this.refreshChrome();
|
|
8890
8889
|
return;
|
|
@@ -8957,7 +8956,7 @@ class Qd {
|
|
|
8957
8956
|
}
|
|
8958
8957
|
this.runEdit("style.link", (l) => {
|
|
8959
8958
|
if (s === i) {
|
|
8960
|
-
const c =
|
|
8959
|
+
const c = Te(s, a)(l);
|
|
8961
8960
|
Nn(s, c, a)(l), l.select({ anchor: s, focus: c });
|
|
8962
8961
|
} else
|
|
8963
8962
|
Nn(s, i, a)(l);
|
|
@@ -8973,10 +8972,10 @@ class Qd {
|
|
|
8973
8972
|
}
|
|
8974
8973
|
insertEmbed(t, e = "cursor") {
|
|
8975
8974
|
if (this.caret.refEdit && t.kind === "ref") return;
|
|
8976
|
-
const s = this.targetDoc(), i = { ...t, ...
|
|
8975
|
+
const s = this.targetDoc(), i = { ...t, ...Pe(t.kind).measure(t, this.innerContentWidth(), s) };
|
|
8977
8976
|
this.runEdit("embed.insert", (r) => {
|
|
8978
8977
|
e === "cursor" ? this.deleteSelectionIfNeeded(r) : r.select(R(this.resolveInsertIndex(e, r.doc)));
|
|
8979
|
-
const o =
|
|
8978
|
+
const o = De(r.selection().focus, i)(r);
|
|
8980
8979
|
r.select({ anchor: o - 1, focus: o });
|
|
8981
8980
|
});
|
|
8982
8981
|
}
|
|
@@ -9113,7 +9112,7 @@ class Qd {
|
|
|
9113
9112
|
this.applyNow(At(t, e), !0);
|
|
9114
9113
|
const s = this.doc.entities.get(t);
|
|
9115
9114
|
if (!s) return;
|
|
9116
|
-
const i =
|
|
9115
|
+
const i = Pe(s.kind).measure(s, this.layout.contentWidth);
|
|
9117
9116
|
this.applyNow(At(t, i), !0), this.layout = this.layoutMain(this.layout), this.painter.paintDoc(this.layout), this.paintChrome();
|
|
9118
9117
|
}
|
|
9119
9118
|
insertMediaFile(t, e) {
|
|
@@ -9127,7 +9126,7 @@ class Qd {
|
|
|
9127
9126
|
};
|
|
9128
9127
|
this.runEdit("embed.insert", (f) => {
|
|
9129
9128
|
this.deleteSelectionIfNeeded(f);
|
|
9130
|
-
const g =
|
|
9129
|
+
const g = De(f.selection().focus, d)(f);
|
|
9131
9130
|
f.select({ anchor: g - 1, focus: g });
|
|
9132
9131
|
});
|
|
9133
9132
|
};
|
|
@@ -9396,7 +9395,7 @@ class Qd {
|
|
|
9396
9395
|
}
|
|
9397
9396
|
/** 光标算在这块 mark 里面:空 mark 的落点、区间内部、以及左右内侧边界。不可选中的块永远不算在里面。按钮没有内部。 */
|
|
9398
9397
|
caretInsideMark(t, e) {
|
|
9399
|
-
return
|
|
9398
|
+
return Ae(this.navEnv, this.caret, t, e);
|
|
9400
9399
|
}
|
|
9401
9400
|
/** 有 label 就是锁定,不看业务传的 `locked`。 */
|
|
9402
9401
|
markLocked(t) {
|
|
@@ -9834,7 +9833,7 @@ class Qd {
|
|
|
9834
9833
|
}
|
|
9835
9834
|
/** `chrome.selectable === false` 的芯片或其它嵌入。光标不选中它。 */
|
|
9836
9835
|
embedSkipped(t) {
|
|
9837
|
-
return
|
|
9836
|
+
return Ne(this.navEnv, t);
|
|
9838
9837
|
}
|
|
9839
9838
|
/**
|
|
9840
9839
|
* 把落点挪出不可选中的 mark 和芯片。
|
|
@@ -9919,7 +9918,7 @@ export {
|
|
|
9919
9918
|
R as collapsedSel,
|
|
9920
9919
|
Yd as destroyHostEmbed,
|
|
9921
9920
|
li as documentFromSlice,
|
|
9922
|
-
|
|
9921
|
+
Pe as embedPlugin,
|
|
9923
9922
|
Cl as fontFamilyOf,
|
|
9924
9923
|
qe as hitTestIndex,
|
|
9925
9924
|
nh as hostEmbedPlugin,
|