markloom 0.3.0 → 0.5.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/README.md +29 -16
- package/ai.md +160 -0
- package/collab.md +68 -0
- package/dist/ai/index.cjs +4 -3
- package/dist/ai/index.d.cts +4 -2
- package/dist/ai/index.d.ts +4 -2
- package/dist/ai/index.js +5 -4
- package/dist/ai/theme.css +63 -63
- package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
- package/dist/chunk-6DCI7AL3.js +208 -0
- package/dist/chunk-AC5E42NH.cjs +208 -0
- package/dist/chunk-GQ2HHRGI.cjs +16 -0
- package/dist/{chunk-GUPMZI6Q.js → chunk-JMOJU5EU.js} +7 -5
- package/dist/chunk-JS527FDV.cjs +294 -0
- package/dist/chunk-LA5SBCGQ.js +16 -0
- package/dist/{chunk-ITVAR2UM.js → chunk-LEYAQNJA.js} +5 -3
- package/dist/{chunk-J3QWW6CN.js → chunk-MFYF2A6U.js} +5 -13
- package/dist/chunk-RLTHVQNQ.js +294 -0
- package/dist/{chunk-7Q6AXLF2.cjs → chunk-SLRD6FMP.cjs} +30 -28
- package/dist/{chunk-UCNEQGMY.js → chunk-WUHTCCAE.js} +391 -332
- package/dist/{chunk-2X6AF7XH.cjs → chunk-YJAWPRJW.cjs} +722 -663
- package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
- package/dist/client-A0ZQJnyR.d.ts +137 -0
- package/dist/client-BNams4wv.d.cts +137 -0
- package/dist/collab/index.cjs +19 -0
- package/dist/collab/index.d.cts +3 -0
- package/dist/collab/index.d.ts +3 -0
- package/dist/collab/index.js +19 -0
- package/dist/comments-DlExS6f-.d.cts +43 -0
- package/dist/comments-PhnR7Gkn.d.ts +43 -0
- package/dist/{controller-Dm4uLD3I.d.ts → controller-BkY1VPzc.d.ts} +24 -8
- package/dist/{controller-cE9iEYp3.d.cts → controller-CVIZI--A.d.cts} +24 -8
- package/dist/index.cjs +21 -243
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +22 -244
- package/dist/react/index.cjs +12 -9
- package/dist/react/index.d.cts +7 -5
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +12 -9
- package/dist/rebase-batch-8rL_aXEE.d.ts +38 -0
- package/dist/rebase-batch-bYnBJpRO.d.cts +38 -0
- package/dist/step-BrvHIK7O.d.cts +65 -0
- package/dist/step-BrvHIK7O.d.ts +65 -0
- package/dist/view/index.cjs +11 -8
- package/dist/view/index.d.cts +7 -5
- package/dist/view/index.d.ts +7 -5
- package/dist/view/index.js +9 -6
- package/dist/view/theme.css +507 -507
- package/package.json +10 -3
- package/dist/comments-USjT1wYN.d.cts +0 -105
- package/dist/comments-USjT1wYN.d.ts +0 -105
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ var _chunkHA6XHJUDcjs = require('./chunk-HA6XHJUD.cjs');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkSLRD6FMPcjs = require('./chunk-SLRD6FMP.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -53,10 +53,15 @@ var _chunk7Q6AXLF2cjs = require('./chunk-7Q6AXLF2.cjs');
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
|
|
56
57
|
|
|
57
58
|
|
|
59
|
+
var _chunkAC5E42NHcjs = require('./chunk-AC5E42NH.cjs');
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
|
|
60
65
|
|
|
61
66
|
// src/view/render.ts
|
|
62
67
|
var _preact = require('preact');
|
|
@@ -208,7 +213,7 @@ var ICONS = {
|
|
|
208
213
|
["path", { d: "M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z" }]
|
|
209
214
|
]
|
|
210
215
|
};
|
|
211
|
-
function icon(name, size2 = 16, className = "
|
|
216
|
+
function icon(name, size2 = 16, className = "markloom-icon") {
|
|
212
217
|
const nodes = ICONS[name];
|
|
213
218
|
if (!nodes)
|
|
214
219
|
return null;
|
|
@@ -273,13 +278,13 @@ function paintInvisibles(text) {
|
|
|
273
278
|
const ch = text[i];
|
|
274
279
|
if (ch === " ") {
|
|
275
280
|
flush();
|
|
276
|
-
out.push(_preact.h.call(void 0, "span", { key: k++, class: "
|
|
281
|
+
out.push(_preact.h.call(void 0, "span", { key: k++, class: "markloom-inv-space" }, " "));
|
|
277
282
|
} else if (ch === "\xA0") {
|
|
278
283
|
flush();
|
|
279
|
-
out.push(_preact.h.call(void 0, "span", { key: k++, class: "
|
|
284
|
+
out.push(_preact.h.call(void 0, "span", { key: k++, class: "markloom-inv-nbsp" }, "\xA0"));
|
|
280
285
|
} else if (ch === " ") {
|
|
281
286
|
flush();
|
|
282
|
-
out.push(_preact.h.call(void 0, "span", { key: k++, class: "
|
|
287
|
+
out.push(_preact.h.call(void 0, "span", { key: k++, class: "markloom-inv-tab" }, " "));
|
|
283
288
|
} else {
|
|
284
289
|
buf += ch;
|
|
285
290
|
}
|
|
@@ -323,7 +328,7 @@ function renderImage(spec, key, atomSelect) {
|
|
|
323
328
|
"data-atom": "image",
|
|
324
329
|
"data-selected": selected ? "" : void 0,
|
|
325
330
|
"contentEditable": "false",
|
|
326
|
-
"class": "
|
|
331
|
+
"class": "markloom-figure",
|
|
327
332
|
"style": figAlign
|
|
328
333
|
}, [_preact.h.call(void 0, "img", { key: "img", ...innerImg }), _preact.h.call(void 0, "figcaption", { key: "cap", "data-caption": "" }, caption)]);
|
|
329
334
|
}
|
|
@@ -365,7 +370,7 @@ function markProps(mark, commentState) {
|
|
|
365
370
|
return {
|
|
366
371
|
"href": url,
|
|
367
372
|
"data-mark": "link",
|
|
368
|
-
"class": "
|
|
373
|
+
"class": "markloom-link",
|
|
369
374
|
"rel": "noopener noreferrer",
|
|
370
375
|
"title": url
|
|
371
376
|
};
|
|
@@ -377,9 +382,9 @@ function markProps(mark, commentState) {
|
|
|
377
382
|
if (mark.name === "comment") {
|
|
378
383
|
const id = String(_nullishCoalesce(_optionalChain([mark, 'access', _6 => _6.attrs, 'optionalAccess', _7 => _7.id]), () => ( "")));
|
|
379
384
|
const cls = [
|
|
380
|
-
"
|
|
381
|
-
_optionalChain([commentState, 'optionalAccess', _8 => _8.resolved, 'access', _9 => _9.has, 'call', _10 => _10(id)]) ? "
|
|
382
|
-
_optionalChain([commentState, 'optionalAccess', _11 => _11.activeId]) === id ? "
|
|
385
|
+
"markloom-comment",
|
|
386
|
+
_optionalChain([commentState, 'optionalAccess', _8 => _8.resolved, 'access', _9 => _9.has, 'call', _10 => _10(id)]) ? "markloom-comment-resolved" : "",
|
|
387
|
+
_optionalChain([commentState, 'optionalAccess', _11 => _11.activeId]) === id ? "markloom-comment-active" : ""
|
|
383
388
|
].filter(Boolean).join(" ");
|
|
384
389
|
return { "data-mark": "comment", "data-comment-id": id, class: cls };
|
|
385
390
|
}
|
|
@@ -390,7 +395,7 @@ function renderInlineAtom(spec, key, opts) {
|
|
|
390
395
|
const br = _preact.h.call(void 0, "br", { "key": key, "data-leaf": key, "data-atom": "hard_break" });
|
|
391
396
|
if (!opts.invisibleCharacters)
|
|
392
397
|
return br;
|
|
393
|
-
return [br, _preact.h.call(void 0, "span", { "key": `${key}-inv`, "class": "
|
|
398
|
+
return [br, _preact.h.call(void 0, "span", { "key": `${key}-inv`, "class": "markloom-inv-break", "aria-hidden": "true", "contentEditable": "false" }, "\u21B5")];
|
|
394
399
|
}
|
|
395
400
|
if (spec.type === "math") {
|
|
396
401
|
const latex = String(_nullishCoalesce(_optionalChain([spec, 'access', _12 => _12.attrs, 'optionalAccess', _13 => _13.latex]), () => ( "")));
|
|
@@ -404,7 +409,7 @@ function renderInlineAtom(spec, key, opts) {
|
|
|
404
409
|
"data-latex": latex,
|
|
405
410
|
"data-display": display ? "block" : "inline",
|
|
406
411
|
"contentEditable": "false",
|
|
407
|
-
"class": display ? "
|
|
412
|
+
"class": display ? "markloom-math markloom-math-block" : "markloom-math",
|
|
408
413
|
"title": "\u70B9\u51FB\u7F16\u8F91\u516C\u5F0F"
|
|
409
414
|
};
|
|
410
415
|
if (html)
|
|
@@ -421,8 +426,8 @@ function renderInlineAtom(spec, key, opts) {
|
|
|
421
426
|
"data-mention-id": String(_nullishCoalesce(a.id, () => ( ""))),
|
|
422
427
|
"data-kind": isDate ? "date" : void 0,
|
|
423
428
|
"contentEditable": "false",
|
|
424
|
-
"class": isDate ? "
|
|
425
|
-
}, isDate ? [icon("calendar", 12, "
|
|
429
|
+
"class": isDate ? "markloom-mention markloom-mention-date" : "markloom-mention"
|
|
430
|
+
}, isDate ? [icon("calendar", 12, "markloom-mention-ico"), label] : ["@", label]);
|
|
426
431
|
}
|
|
427
432
|
function renderEmbed(spec, key, atomSelect) {
|
|
428
433
|
const a = _nullishCoalesce(spec.attrs, () => ( {}));
|
|
@@ -437,7 +442,7 @@ function renderEmbed(spec, key, atomSelect) {
|
|
|
437
442
|
"data-embed-kind": kind,
|
|
438
443
|
"data-selected": atomIsSelected(spec.id, atomSelect) ? "" : void 0,
|
|
439
444
|
"contentEditable": "false",
|
|
440
|
-
"class": "
|
|
445
|
+
"class": "markloom-embed"
|
|
441
446
|
};
|
|
442
447
|
if (kind === "youtube") {
|
|
443
448
|
const id = youtubeId(src);
|
|
@@ -449,7 +454,7 @@ function renderEmbed(spec, key, atomSelect) {
|
|
|
449
454
|
"allow": "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
|
450
455
|
"allowFullScreen": true,
|
|
451
456
|
"frameBorder": "0",
|
|
452
|
-
"class": "
|
|
457
|
+
"class": "markloom-embed-frame"
|
|
453
458
|
}));
|
|
454
459
|
}
|
|
455
460
|
if (kind === "twitch") {
|
|
@@ -462,7 +467,7 @@ function renderEmbed(spec, key, atomSelect) {
|
|
|
462
467
|
"title": title || "Twitch",
|
|
463
468
|
"allowFullScreen": true,
|
|
464
469
|
"frameBorder": "0",
|
|
465
|
-
"class": "
|
|
470
|
+
"class": "markloom-embed-frame"
|
|
466
471
|
}));
|
|
467
472
|
}
|
|
468
473
|
if (kind === "audio") {
|
|
@@ -471,17 +476,17 @@ function renderEmbed(spec, key, atomSelect) {
|
|
|
471
476
|
"src": src,
|
|
472
477
|
"controls": true,
|
|
473
478
|
"preload": "metadata",
|
|
474
|
-
"class": "
|
|
479
|
+
"class": "markloom-embed-audio"
|
|
475
480
|
}, title || name));
|
|
476
481
|
}
|
|
477
|
-
return _preact.h.call(void 0, "div", { ...base, class: "
|
|
482
|
+
return _preact.h.call(void 0, "div", { ...base, class: "markloom-embed markloom-embed-file" }, _preact.h.call(void 0, "a", {
|
|
478
483
|
"key": "l",
|
|
479
484
|
"href": src,
|
|
480
485
|
"download": name || void 0,
|
|
481
486
|
"target": "_blank",
|
|
482
487
|
"rel": "noopener noreferrer",
|
|
483
|
-
"class": "
|
|
484
|
-
}, [icon("paperclip", 14, "
|
|
488
|
+
"class": "markloom-embed-file-link"
|
|
489
|
+
}, [icon("paperclip", 14, "markloom-embed-file-ico"), " ", name || src]));
|
|
485
490
|
}
|
|
486
491
|
function youtubeId(url) {
|
|
487
492
|
try {
|
|
@@ -518,13 +523,13 @@ function twitchChannel(url) {
|
|
|
518
523
|
}
|
|
519
524
|
}
|
|
520
525
|
function leafText(spec) {
|
|
521
|
-
return spec.children.map((c) =>
|
|
526
|
+
return spec.children.map((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text : _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c) ? "" : leafText(c)).join("");
|
|
522
527
|
}
|
|
523
528
|
function aiBtn(act, label, cls, extra) {
|
|
524
529
|
return _preact.h.call(void 0, "button", {
|
|
525
530
|
key: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _18 => _18.key]), () => ( act)),
|
|
526
531
|
type: "button",
|
|
527
|
-
class: `
|
|
532
|
+
class: `markloom-ai-block-btn ${cls}`,
|
|
528
533
|
"data-ai-act": act,
|
|
529
534
|
contentEditable: "false",
|
|
530
535
|
title: _optionalChain([extra, 'optionalAccess', _19 => _19.title]),
|
|
@@ -534,7 +539,7 @@ function aiBtn(act, label, cls, extra) {
|
|
|
534
539
|
}, label);
|
|
535
540
|
}
|
|
536
541
|
function aiKbd(label) {
|
|
537
|
-
return _preact.h.call(void 0, "kbd", { class: "
|
|
542
|
+
return _preact.h.call(void 0, "kbd", { class: "markloom-ai-kbd" }, label);
|
|
538
543
|
}
|
|
539
544
|
function renderAiBlock(spec, tag, props, opts) {
|
|
540
545
|
const status = typeof _optionalChain([spec, 'access', _20 => _20.attrs, 'optionalAccess', _21 => _21.status]) === "string" ? spec.attrs.status : "compose";
|
|
@@ -542,41 +547,41 @@ function renderAiBlock(spec, tag, props, opts) {
|
|
|
542
547
|
const mode = _optionalChain([spec, 'access', _24 => _24.attrs, 'optionalAccess', _25 => _25.mode]) === "rewrite" ? "rewrite" : "continue";
|
|
543
548
|
const seed = typeof _optionalChain([spec, 'access', _26 => _26.attrs, 'optionalAccess', _27 => _27.seed]) === "string" ? spec.attrs.seed : "";
|
|
544
549
|
const draftChars = typeof _optionalChain([spec, 'access', _28 => _28.attrs, 'optionalAccess', _29 => _29.draftChars]) === "number" ? spec.attrs.draftChars : 0;
|
|
545
|
-
props.class = "
|
|
550
|
+
props.class = "markloom-ai-block";
|
|
546
551
|
props["data-ai-block"] = "";
|
|
547
552
|
props["data-status"] = status;
|
|
548
553
|
props["data-mode"] = mode;
|
|
549
554
|
const title = mode === "rewrite" ? "AI \u6539\u5199" : "AI \u5199\u4F5C";
|
|
550
|
-
const statusHint = status === "loading" ? [_preact.h.call(void 0, "span", { key: "sp", class: "
|
|
555
|
+
const statusHint = status === "loading" ? [_preact.h.call(void 0, "span", { key: "sp", class: "markloom-ai-spin", "aria-hidden": "true" }), "\u751F\u6210\u4E2D"] : status === "preview" ? "\u5F85\u786E\u8BA4" : status === "error" ? "\u5931\u8D25" : null;
|
|
551
556
|
const hd = _preact.h.call(void 0, "div", {
|
|
552
557
|
key: "hd",
|
|
553
|
-
class: "
|
|
558
|
+
class: "markloom-ai-block-hd",
|
|
554
559
|
contentEditable: "false"
|
|
555
560
|
}, [
|
|
556
|
-
_preact.h.call(void 0, "div", { key: "l", class: "
|
|
561
|
+
_preact.h.call(void 0, "div", { key: "l", class: "markloom-ai-block-brand" }, [
|
|
557
562
|
_preact.h.call(void 0,
|
|
558
563
|
"span",
|
|
559
|
-
{ key: "ico", class: "
|
|
560
|
-
icon(mode === "rewrite" ? "pen-line" : "sparkles", 15, "
|
|
564
|
+
{ key: "ico", class: "markloom-ai-block-ico" },
|
|
565
|
+
icon(mode === "rewrite" ? "pen-line" : "sparkles", 15, "markloom-ai-block-svg")
|
|
561
566
|
),
|
|
562
|
-
_preact.h.call(void 0, "span", { key: "t", class: "
|
|
567
|
+
_preact.h.call(void 0, "span", { key: "t", class: "markloom-ai-block-title" }, title),
|
|
563
568
|
statusHint ? _preact.h.call(void 0, "span", {
|
|
564
569
|
key: "b",
|
|
565
|
-
class: `
|
|
570
|
+
class: `markloom-ai-block-badge markloom-ai-block-badge-${status}`
|
|
566
571
|
}, statusHint) : null
|
|
567
572
|
]),
|
|
568
|
-
status === "loading" ? aiBtn("stop", "\u505C\u6B62", "
|
|
573
|
+
status === "loading" ? aiBtn("stop", "\u505C\u6B62", "markloom-ai-block-btn-ghost", { title: "\u505C\u6B62\u751F\u6210", key: "stop" }) : aiBtn("discard", "\xD7", "markloom-ai-block-btn-icon", { title: "\u53D6\u6D88", key: "x" })
|
|
569
574
|
]);
|
|
570
575
|
const seedStrip = mode === "rewrite" && seed.trim() ? _preact.h.call(void 0, "div", {
|
|
571
576
|
key: "seed",
|
|
572
|
-
class: "
|
|
577
|
+
class: "markloom-ai-block-seed",
|
|
573
578
|
contentEditable: "false",
|
|
574
579
|
title: seed
|
|
575
580
|
}, [
|
|
576
|
-
_preact.h.call(void 0, "span", { key: "l", class: "
|
|
581
|
+
_preact.h.call(void 0, "span", { key: "l", class: "markloom-ai-block-seed-lab" }, "\u539F\u6587"),
|
|
577
582
|
_preact.h.call(void 0,
|
|
578
583
|
"span",
|
|
579
|
-
{ key: "t", class: "
|
|
584
|
+
{ key: "t", class: "markloom-ai-block-seed-txt" },
|
|
580
585
|
seed.length > 120 ? `${seed.slice(0, 120)}\u2026` : seed
|
|
581
586
|
)
|
|
582
587
|
]) : null;
|
|
@@ -585,8 +590,8 @@ function renderAiBlock(spec, tag, props, opts) {
|
|
|
585
590
|
if (!(vn && typeof vn === "object" && "props" in vn))
|
|
586
591
|
return vn;
|
|
587
592
|
const p = vn.props;
|
|
588
|
-
p.class = [p.class, "
|
|
589
|
-
if (i === 0 && !
|
|
593
|
+
p.class = [p.class, "markloom-ai-prompt"].filter(Boolean).join(" ");
|
|
594
|
+
if (i === 0 && !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "paragraph" && leafText(c) === "") {
|
|
590
595
|
p["data-placeholder"] = mode === "rewrite" ? "\u63CF\u8FF0\u600E\u4E48\u6539\u2026\uFF08\u56DE\u8F66\u751F\u6210\uFF09" : "\u8F93\u5165\u6307\u4EE4\uFF0C\u56DE\u8F66\u751F\u6210\u2026";
|
|
591
596
|
}
|
|
592
597
|
return vn;
|
|
@@ -598,50 +603,50 @@ function renderAiBlock(spec, tag, props, opts) {
|
|
|
598
603
|
if (status === "error" && err) {
|
|
599
604
|
outKids.push(_preact.h.call(void 0, "div", {
|
|
600
605
|
key: "err",
|
|
601
|
-
class: "
|
|
606
|
+
class: "markloom-ai-block-err",
|
|
602
607
|
contentEditable: "false"
|
|
603
608
|
}, err));
|
|
604
609
|
}
|
|
605
610
|
let ft = null;
|
|
606
611
|
if (status === "compose") {
|
|
607
|
-
ft = _preact.h.call(void 0, "div", { key: "ft", class: "
|
|
608
|
-
_preact.h.call(void 0, "span", { key: "h", class: "
|
|
612
|
+
ft = _preact.h.call(void 0, "div", { key: "ft", class: "markloom-ai-block-ft", contentEditable: "false" }, [
|
|
613
|
+
_preact.h.call(void 0, "span", { key: "h", class: "markloom-ai-block-hint" }, [
|
|
609
614
|
aiKbd("Enter"),
|
|
610
615
|
" \u751F\u6210",
|
|
611
|
-
_preact.h.call(void 0, "span", { key: "dot", class: "
|
|
616
|
+
_preact.h.call(void 0, "span", { key: "dot", class: "markloom-ai-dot" }, "\xB7"),
|
|
612
617
|
aiKbd("\u21E7Enter"),
|
|
613
618
|
" \u6362\u884C"
|
|
614
619
|
]),
|
|
615
|
-
aiBtn("run", "\u751F\u6210", "
|
|
620
|
+
aiBtn("run", "\u751F\u6210", "markloom-ai-block-btn-primary", { title: "\u5F00\u59CB\u751F\u6210", key: "run" })
|
|
616
621
|
]);
|
|
617
622
|
} else if (status === "loading") {
|
|
618
|
-
ft = _preact.h.call(void 0, "div", { key: "ft", class: "
|
|
623
|
+
ft = _preact.h.call(void 0, "div", { key: "ft", class: "markloom-ai-block-ft", contentEditable: "false" }, [
|
|
619
624
|
_preact.h.call(void 0,
|
|
620
625
|
"span",
|
|
621
|
-
{ key: "h", class: "
|
|
626
|
+
{ key: "h", class: "markloom-ai-block-hint markloom-ai-block-loading" },
|
|
622
627
|
draftChars ? `\u6B63\u6587\u5DF2\u5199\u5165 ${draftChars} \u5B57\u2026` : "\u6B63\u5728\u5199\u5165\u6B63\u6587\u2026"
|
|
623
628
|
),
|
|
624
|
-
aiBtn("stop", "\u505C\u6B62", "
|
|
629
|
+
aiBtn("stop", "\u505C\u6B62", "markloom-ai-block-btn-ghost", { title: "\u505C\u6B62\u751F\u6210", key: "stop2" })
|
|
625
630
|
]);
|
|
626
631
|
} else if (status === "preview") {
|
|
627
|
-
ft = _preact.h.call(void 0, "div", { key: "ft", class: "
|
|
632
|
+
ft = _preact.h.call(void 0, "div", { key: "ft", class: "markloom-ai-block-ft", contentEditable: "false" }, [
|
|
628
633
|
_preact.h.call(void 0,
|
|
629
634
|
"span",
|
|
630
|
-
{ key: "h", class: "
|
|
635
|
+
{ key: "h", class: "markloom-ai-block-hint" },
|
|
631
636
|
draftChars ? `${draftChars} \u5B57\u5DF2\u5199\u5165 \xB7 \u786E\u8BA4\u63D0\u4EA4 / \u4E22\u5F03\u64A4\u56DE` : "\u4E0B\u65B9\u6DE1\u5316\u6587\u5B57\u5DF2\u5728\u6587\u6863\u4E2D"
|
|
632
637
|
),
|
|
633
|
-
_preact.h.call(void 0, "div", { key: "acts", class: "
|
|
634
|
-
aiBtn("retry", "\u91CD\u8BD5", "
|
|
635
|
-
aiBtn("discard", "\u64A4\u56DE", "
|
|
636
|
-
aiBtn("accept", "\u786E\u8BA4", "
|
|
638
|
+
_preact.h.call(void 0, "div", { key: "acts", class: "markloom-ai-block-acts" }, [
|
|
639
|
+
aiBtn("retry", "\u91CD\u8BD5", "markloom-ai-block-btn-ghost", { title: "\u64A4\u56DE\u5E76\u91CD\u65B0\u751F\u6210" }),
|
|
640
|
+
aiBtn("discard", "\u64A4\u56DE", "markloom-ai-block-btn-ghost", { title: "\u6574\u7B14\u64A4\u56DE(undo)" }),
|
|
641
|
+
aiBtn("accept", "\u786E\u8BA4", "markloom-ai-block-btn-primary", { title: "\u63D0\u4EA4\u4E8B\u52A1" })
|
|
637
642
|
])
|
|
638
643
|
]);
|
|
639
644
|
} else if (status === "error") {
|
|
640
|
-
ft = _preact.h.call(void 0, "div", { key: "ft", class: "
|
|
641
|
-
_preact.h.call(void 0, "span", { key: "h", class: "
|
|
642
|
-
_preact.h.call(void 0, "div", { key: "acts", class: "
|
|
643
|
-
aiBtn("retry", "\u91CD\u8BD5", "
|
|
644
|
-
aiBtn("discard", "\u4E22\u5F03", "
|
|
645
|
+
ft = _preact.h.call(void 0, "div", { key: "ft", class: "markloom-ai-block-ft", contentEditable: "false" }, [
|
|
646
|
+
_preact.h.call(void 0, "span", { key: "h", class: "markloom-ai-block-hint is-error" }, "\u751F\u6210\u5931\u8D25"),
|
|
647
|
+
_preact.h.call(void 0, "div", { key: "acts", class: "markloom-ai-block-acts" }, [
|
|
648
|
+
aiBtn("retry", "\u91CD\u8BD5", "markloom-ai-block-btn-primary", { title: "\u91CD\u65B0\u751F\u6210" }),
|
|
649
|
+
aiBtn("discard", "\u4E22\u5F03", "markloom-ai-block-btn-ghost")
|
|
645
650
|
])
|
|
646
651
|
]);
|
|
647
652
|
}
|
|
@@ -658,9 +663,9 @@ function blockCtx(opts) {
|
|
|
658
663
|
};
|
|
659
664
|
}
|
|
660
665
|
function renderNode(node, key, opts) {
|
|
661
|
-
if (
|
|
666
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
662
667
|
return renderText(node, key, opts);
|
|
663
|
-
if (
|
|
668
|
+
if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, node))
|
|
664
669
|
return renderInlineAtom(node, key, opts);
|
|
665
670
|
const spec = node;
|
|
666
671
|
const renderer = opts.blockRenderers[spec.type];
|
|
@@ -671,19 +676,19 @@ function renderNode(node, key, opts) {
|
|
|
671
676
|
if (_optionalChain([spec, 'access', _30 => _30.attrs, 'optionalAccess', _31 => _31.align]) && spec.attrs.align !== "left")
|
|
672
677
|
props.style = `text-align:${spec.attrs.align}`;
|
|
673
678
|
if (_optionalChain([spec, 'access', _32 => _32.attrs, 'optionalAccess', _33 => _33.aiDraft])) {
|
|
674
|
-
props.class = [props.class, "
|
|
679
|
+
props.class = [props.class, "markloom-ai-draft"].filter(Boolean).join(" ");
|
|
675
680
|
props["data-ai-draft"] = "";
|
|
676
681
|
if (spec.attrs.aiStream)
|
|
677
682
|
props["data-ai-stream"] = "";
|
|
678
683
|
}
|
|
679
684
|
if (spec.type === "callout") {
|
|
680
|
-
props.class = "
|
|
685
|
+
props.class = "markloom-callout";
|
|
681
686
|
const variant = typeof _optionalChain([spec, 'access', _34 => _34.attrs, 'optionalAccess', _35 => _35.variant]) === "string" ? spec.attrs.variant : "info";
|
|
682
687
|
props["data-variant"] = variant;
|
|
683
688
|
const chip = _preact.h.call(void 0, "button", {
|
|
684
689
|
"key": "v",
|
|
685
690
|
"type": "button",
|
|
686
|
-
"class": "
|
|
691
|
+
"class": "markloom-callout-chip",
|
|
687
692
|
"contentEditable": "false",
|
|
688
693
|
"data-callout-variant": "",
|
|
689
694
|
"tabIndex": -1
|
|
@@ -697,7 +702,7 @@ function renderNode(node, key, opts) {
|
|
|
697
702
|
const depth = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([spec, 'access', _36 => _36.attrs, 'optionalAccess', _37 => _37.depth]), () => ( 2))), 1), 6);
|
|
698
703
|
tag = `h${depth}`;
|
|
699
704
|
const collapsed = !!_optionalChain([spec, 'access', _38 => _38.attrs, 'optionalAccess', _39 => _39.collapsed]);
|
|
700
|
-
props.class = "
|
|
705
|
+
props.class = "markloom-heading";
|
|
701
706
|
props["data-heading-depth"] = String(depth);
|
|
702
707
|
props["data-collapsed"] = collapsed ? "true" : "false";
|
|
703
708
|
if (opts.slug)
|
|
@@ -743,7 +748,7 @@ function renderCode(spec, key, ctx) {
|
|
|
743
748
|
}
|
|
744
749
|
function renderTable(spec, key, ctx) {
|
|
745
750
|
const align = Array.isArray(_optionalChain([spec, 'access', _46 => _46.attrs, 'optionalAccess', _47 => _47.align])) ? spec.attrs.align : null;
|
|
746
|
-
const grid =
|
|
751
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, spec);
|
|
747
752
|
const freezeRows = Number(_nullishCoalesce(_optionalChain([spec, 'access', _48 => _48.attrs, 'optionalAccess', _49 => _49.freezeRows]), () => ( 0)));
|
|
748
753
|
const freezeCols = Number(_nullishCoalesce(_optionalChain([spec, 'access', _50 => _50.attrs, 'optionalAccess', _51 => _51.freezeCols]), () => ( 0)));
|
|
749
754
|
const cell = (cellNode, idx, tag) => {
|
|
@@ -756,7 +761,7 @@ function renderTable(spec, key, ctx) {
|
|
|
756
761
|
"key": idx,
|
|
757
762
|
"data-block-id": _nullishCoalesce(cellNode.id, () => ( "")),
|
|
758
763
|
"contentEditable": true,
|
|
759
|
-
"class": "
|
|
764
|
+
"class": "markloom-cell",
|
|
760
765
|
"scope": tag === "th" ? "col" : void 0,
|
|
761
766
|
"colSpan": m.colspan > 1 ? m.colspan : void 0,
|
|
762
767
|
"rowSpan": m.rowspan > 1 ? m.rowspan : void 0,
|
|
@@ -783,7 +788,7 @@ function renderTable(spec, key, ctx) {
|
|
|
783
788
|
for (const r of Array.from(bodyRowsMap.keys()).sort((a, b) => a - b))
|
|
784
789
|
bodyRows.push(_preact.h.call(void 0, "tr", { key: r }, bodyRowsMap.get(r)));
|
|
785
790
|
const body = _preact.h.call(void 0, "tbody", { key: "tb" }, bodyRows);
|
|
786
|
-
const widths =
|
|
791
|
+
const widths = _chunk4TMHVNL6cjs.tableColWidths.call(void 0, spec);
|
|
787
792
|
const children = widths ? [_preact.h.call(void 0, "colgroup", { key: "cg" }, widths.map((w, i) => _preact.h.call(void 0, "col", { key: i, style: `width:${w}px` }))), head, body] : [head, body];
|
|
788
793
|
const table = _preact.h.call(void 0, "table", {
|
|
789
794
|
"key": _nullishCoalesce(spec.id, () => ( key)),
|
|
@@ -791,10 +796,10 @@ function renderTable(spec, key, ctx) {
|
|
|
791
796
|
"data-atom": spec.type,
|
|
792
797
|
"contentEditable": "false",
|
|
793
798
|
// 字符串 'false':Preact 对布尔 false 会删属性,正文选区就跨得进来了
|
|
794
|
-
"class": "
|
|
799
|
+
"class": "markloom-table",
|
|
795
800
|
"style": widths ? `width:${widths.reduce((a, b) => a + b, 0)}px` : "width:100%"
|
|
796
801
|
}, children);
|
|
797
|
-
return _preact.h.call(void 0, "div", { "key": `w${_nullishCoalesce(spec.id, () => ( key))}`, "data-pass": "", "class": "
|
|
802
|
+
return _preact.h.call(void 0, "div", { "key": `w${_nullishCoalesce(spec.id, () => ( key))}`, "data-pass": "", "class": "markloom-table-scroll" }, [table]);
|
|
798
803
|
}
|
|
799
804
|
function renderHr(spec, key, ctx) {
|
|
800
805
|
if (_optionalChain([spec, 'access', _57 => _57.attrs, 'optionalAccess', _58 => _58.mdType]) === "thematicBreak")
|
|
@@ -822,9 +827,9 @@ function renderDoc(doc, opts = {}) {
|
|
|
822
827
|
atomSelect: opts.atomSelect
|
|
823
828
|
};
|
|
824
829
|
const first = doc.children[0];
|
|
825
|
-
const emptyLeaf = (n) => leafText(n) === "" && n.children.every((c) =>
|
|
830
|
+
const emptyLeaf = (n) => leafText(n) === "" && n.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
826
831
|
let emptyDocPh;
|
|
827
|
-
if (doc.children.length === 1 && first && !
|
|
832
|
+
if (doc.children.length === 1 && first && !_chunkGQ2HHRGIcjs.isText.call(void 0, first) && emptyLeaf(first)) {
|
|
828
833
|
if (first.type === "paragraph" && opts.placeholder)
|
|
829
834
|
emptyDocPh = opts.placeholder;
|
|
830
835
|
else if (first.type === "heading")
|
|
@@ -833,7 +838,7 @@ function renderDoc(doc, opts = {}) {
|
|
|
833
838
|
let foldDepth = null;
|
|
834
839
|
const kids = doc.children.map((c, i) => {
|
|
835
840
|
let foldHidden = false;
|
|
836
|
-
if (!
|
|
841
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "heading") {
|
|
837
842
|
const depth = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([c, 'access', _65 => _65.attrs, 'optionalAccess', _66 => _66.depth]), () => ( 2))), 1), 6);
|
|
838
843
|
if (foldDepth != null && depth <= foldDepth)
|
|
839
844
|
foldDepth = null;
|
|
@@ -854,8 +859,8 @@ function renderDoc(doc, opts = {}) {
|
|
|
854
859
|
}
|
|
855
860
|
return vnode;
|
|
856
861
|
});
|
|
857
|
-
const cls = opts.invisibleCharacters ? "
|
|
858
|
-
return _preact.h.call(void 0, "div", { "class": cls, "data-
|
|
862
|
+
const cls = opts.invisibleCharacters ? "markloom-doc markloom-invisible" : "markloom-doc";
|
|
863
|
+
return _preact.h.call(void 0, "div", { "class": cls, "data-markloom": true }, kids);
|
|
859
864
|
}
|
|
860
865
|
function renderToHtml(doc, opts = {}) {
|
|
861
866
|
return _preactrendertostring.renderToString.call(void 0, renderDoc(doc, opts));
|
|
@@ -873,8 +878,8 @@ function sameLeaf(a, b) {
|
|
|
873
878
|
return a.length === b.length && a.slice(0, -1).every((s, i) => s === b[i]);
|
|
874
879
|
}
|
|
875
880
|
function leafText2(doc, leafPath) {
|
|
876
|
-
const leaf =
|
|
877
|
-
return
|
|
881
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, leafPath);
|
|
882
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
878
883
|
}
|
|
879
884
|
function catOf(cp) {
|
|
880
885
|
if (cp === 32 || cp === 9 || cp === 10 || cp === 12 || cp === 13 || cp === 160)
|
|
@@ -930,8 +935,8 @@ function lineBoundaryFwd(text, offset3) {
|
|
|
930
935
|
function inTableCell(doc, blockPath) {
|
|
931
936
|
if (blockPath.length < 2)
|
|
932
937
|
return false;
|
|
933
|
-
const parent =
|
|
934
|
-
return !
|
|
938
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath.slice(0, -1));
|
|
939
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, parent) && parent.type === "table_cell";
|
|
935
940
|
}
|
|
936
941
|
function cmpPath(a, b) {
|
|
937
942
|
const n = Math.min(a.length, b.length);
|
|
@@ -949,7 +954,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
949
954
|
return { steps: [{ kind: "deleteText", path: a.leafPath, offset: a.char, length: b.char - a.char }], caret: lo };
|
|
950
955
|
const sameBlock = a.blockPath.length === b.blockPath.length && a.blockPath.every((s, i) => s === b.blockPath[i]);
|
|
951
956
|
if (sameBlock) {
|
|
952
|
-
const block =
|
|
957
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
953
958
|
const head2 = block.children.slice(0, a.leafIdx);
|
|
954
959
|
const fromLeaf = trimTail(block.children[a.leafIdx], a.char);
|
|
955
960
|
const toLeaf = trimHead(block.children[b.leafIdx], b.char);
|
|
@@ -971,7 +976,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
971
976
|
const loCell = loRel[0];
|
|
972
977
|
const hiCell = hiRel[0];
|
|
973
978
|
const children = fromTop.children.map((cell, i) => {
|
|
974
|
-
if (i < loCell || i > hiCell ||
|
|
979
|
+
if (i < loCell || i > hiCell || _chunkGQ2HHRGIcjs.isText.call(void 0, cell))
|
|
975
980
|
return cell;
|
|
976
981
|
if (i === loCell)
|
|
977
982
|
return keepBefore(cell, loRel.slice(1));
|
|
@@ -1003,7 +1008,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
1003
1008
|
insert.push(prunedHead);
|
|
1004
1009
|
if (prunedTail !== null && !isEmptyBlock(tail))
|
|
1005
1010
|
insert.push(prunedTail);
|
|
1006
|
-
caret3 = headLives ? lo : insert.length ? [loTop, ...
|
|
1011
|
+
caret3 = headLives ? lo : insert.length ? [loTop, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, insert[0]), 0] : [loTop, 0, 0];
|
|
1007
1012
|
}
|
|
1008
1013
|
return {
|
|
1009
1014
|
steps: [{ kind: "spliceChildren", path: [], at: loTop, remove: hiTop - loTop + 1, insert }],
|
|
@@ -1011,11 +1016,11 @@ function deleteRange(doc, p1, p2) {
|
|
|
1011
1016
|
};
|
|
1012
1017
|
}
|
|
1013
1018
|
function isEmptyBlock(block) {
|
|
1014
|
-
const text = (n) =>
|
|
1019
|
+
const text = (n) => _chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n.text : n.children.map(text).join("");
|
|
1015
1020
|
return text(block) === "";
|
|
1016
1021
|
}
|
|
1017
1022
|
function pruneEmpty(node) {
|
|
1018
|
-
if (
|
|
1023
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
1019
1024
|
return node;
|
|
1020
1025
|
const kids = node.children.map(pruneEmpty).filter((n) => n !== null);
|
|
1021
1026
|
if ((node.type === "list" || node.type === "list_item" || node.type === "quote") && kids.length === 0)
|
|
@@ -1024,7 +1029,7 @@ function pruneEmpty(node) {
|
|
|
1024
1029
|
}
|
|
1025
1030
|
function pruneBlock(node) {
|
|
1026
1031
|
const p = pruneEmpty(node);
|
|
1027
|
-
return p && !
|
|
1032
|
+
return p && !_chunkGQ2HHRGIcjs.isText.call(void 0, p) ? p : { type: "paragraph", id: node.id, children: [{ text: "" }] };
|
|
1028
1033
|
}
|
|
1029
1034
|
function keepBefore(node, rel) {
|
|
1030
1035
|
const idx = rel[0];
|
|
@@ -1066,16 +1071,16 @@ function appendLeavesAt(node, parentRel, leaves) {
|
|
|
1066
1071
|
return { ...node, children };
|
|
1067
1072
|
}
|
|
1068
1073
|
function trimTail(leaf, at) {
|
|
1069
|
-
return
|
|
1074
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(0, at) } : leaf;
|
|
1070
1075
|
}
|
|
1071
1076
|
function trimHead(leaf, at) {
|
|
1072
|
-
return
|
|
1077
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(at) } : leaf;
|
|
1073
1078
|
}
|
|
1074
1079
|
function isAtom(block) {
|
|
1075
|
-
return !
|
|
1080
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, block) && (block.type === "code" || block.type === "table" || block.type === "image" || block.type === "embed");
|
|
1076
1081
|
}
|
|
1077
1082
|
function isOpaque(block) {
|
|
1078
|
-
if (
|
|
1083
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
1079
1084
|
return false;
|
|
1080
1085
|
if (block.type === "table" || block.type === "image" || block.type === "embed")
|
|
1081
1086
|
return true;
|
|
@@ -1092,7 +1097,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1092
1097
|
const collapsed = from === to;
|
|
1093
1098
|
const parentPath = blockPath.slice(0, -1);
|
|
1094
1099
|
const blockIdx = blockPath[blockPath.length - 1];
|
|
1095
|
-
const block =
|
|
1100
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath);
|
|
1096
1101
|
if (intent === "insertLineBreak") {
|
|
1097
1102
|
if (block.type === "code" || block.type === "raw")
|
|
1098
1103
|
return mapInput(doc, "insertText", "\n", sel, newId4, rules, pendingMarks);
|
|
@@ -1104,7 +1109,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1104
1109
|
return null;
|
|
1105
1110
|
if (collapsed && rules.length) {
|
|
1106
1111
|
const leaf = block.children[leafIdx];
|
|
1107
|
-
const leafText3 =
|
|
1112
|
+
const leafText3 = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
1108
1113
|
const ctx = { doc, block, blockPath, parentPath, leafPath, leafIdx, leafText: leafText3, offset: from, marker: leafText3.slice(0, from), trigger: data, rest: leafText3.slice(from), newId: newId4 };
|
|
1109
1114
|
for (const rule of rules) {
|
|
1110
1115
|
const hit = rule.match(ctx);
|
|
@@ -1124,18 +1129,18 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1124
1129
|
}
|
|
1125
1130
|
case "insertParagraph": {
|
|
1126
1131
|
{
|
|
1127
|
-
const aiParent = parentPath.length ?
|
|
1132
|
+
const aiParent = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1128
1133
|
if (aiParent && aiParent.type === "ai")
|
|
1129
1134
|
return null;
|
|
1130
1135
|
}
|
|
1131
1136
|
if (block.type === "code") {
|
|
1132
1137
|
const codeLeaf = block.children[leafIdx];
|
|
1133
|
-
const codeText =
|
|
1138
|
+
const codeText = _chunkGQ2HHRGIcjs.isText.call(void 0, codeLeaf) ? codeLeaf.text : "";
|
|
1134
1139
|
if (collapsed && from === codeText.length && codeText.endsWith("\n")) {
|
|
1135
1140
|
const trimmed = codeText.slice(0, -1);
|
|
1136
1141
|
const kept = {
|
|
1137
1142
|
...block,
|
|
1138
|
-
children: [{ ...
|
|
1143
|
+
children: [{ ..._chunkGQ2HHRGIcjs.isText.call(void 0, codeLeaf) ? codeLeaf : { text: "" }, text: trimmed }]
|
|
1139
1144
|
};
|
|
1140
1145
|
const after = { type: "paragraph", id: newId4(), children: [{ text: "" }] };
|
|
1141
1146
|
return {
|
|
@@ -1152,22 +1157,22 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1152
1157
|
};
|
|
1153
1158
|
}
|
|
1154
1159
|
const splitLeaf = block.children[leafIdx];
|
|
1155
|
-
const splitText =
|
|
1160
|
+
const splitText = _chunkGQ2HHRGIcjs.isText.call(void 0, splitLeaf) ? splitLeaf.text : "";
|
|
1156
1161
|
const keepChildren = [...block.children.slice(0, leafIdx), { ...splitLeaf, text: splitText.slice(0, from) }];
|
|
1157
1162
|
const freshChildren = [{ ...splitLeaf, text: splitText.slice(to) }, ...block.children.slice(leafIdx + 1)];
|
|
1158
1163
|
const keep = { ...block, children: keepChildren };
|
|
1159
1164
|
const fresh = { type: "paragraph", id: newId4(), children: freshChildren };
|
|
1160
|
-
const itemNode = parentPath.length ?
|
|
1165
|
+
const itemNode = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1161
1166
|
if (itemNode && itemNode.type === "list_item") {
|
|
1162
1167
|
const itemIdx = parentPath[parentPath.length - 1];
|
|
1163
1168
|
const listPath = parentPath.slice(0, -1);
|
|
1164
|
-
const isLastItem = itemIdx ===
|
|
1169
|
+
const isLastItem = itemIdx === _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath).children.length - 1;
|
|
1165
1170
|
if (itemNode.children.length === 1 && isEmptyBlock(itemNode) && isLastItem) {
|
|
1166
1171
|
const listParentPath = listPath.slice(0, -1);
|
|
1167
|
-
const listParent =
|
|
1172
|
+
const listParent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listParentPath);
|
|
1168
1173
|
if (listParent.type === "list_item")
|
|
1169
1174
|
return outdentItem(doc, sel, newId4);
|
|
1170
|
-
const list =
|
|
1175
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
1171
1176
|
const before = list.children.slice(0, itemIdx);
|
|
1172
1177
|
const after = list.children.slice(itemIdx + 1);
|
|
1173
1178
|
const lifted = { type: "paragraph", id: itemNode.id, children: [{ text: "" }] };
|
|
@@ -1222,7 +1227,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1222
1227
|
if (from > 0)
|
|
1223
1228
|
return { steps: [{ kind: "deleteText", path: leafPath, offset: from - 1, length: 1 }], selection: caret(leafPath.concat(from - 1)) };
|
|
1224
1229
|
{
|
|
1225
|
-
const aiParent = parentPath.length ?
|
|
1230
|
+
const aiParent = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1226
1231
|
if (aiParent && aiParent.type === "ai" && isEmptyBlock(block) && leafIdx === 0) {
|
|
1227
1232
|
const node = { type: "paragraph", id: aiParent.id, children: [{ text: "" }] };
|
|
1228
1233
|
return {
|
|
@@ -1232,9 +1237,9 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1232
1237
|
}
|
|
1233
1238
|
}
|
|
1234
1239
|
const prevInBlock = block.children[leafIdx - 1];
|
|
1235
|
-
if (leafIdx > 0 && prevInBlock &&
|
|
1240
|
+
if (leafIdx > 0 && prevInBlock && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, prevInBlock)) {
|
|
1236
1241
|
const before = block.children[leafIdx - 2];
|
|
1237
|
-
const landing = before &&
|
|
1242
|
+
const landing = before && _chunkGQ2HHRGIcjs.isText.call(void 0, before) ? [...blockPath, leafIdx - 2, before.text.length] : [...blockPath, leafIdx - 1, 0];
|
|
1238
1243
|
return { steps: [{ kind: "spliceChildren", path: blockPath, at: leafIdx - 1, remove: 1, insert: [] }], selection: caret(landing) };
|
|
1239
1244
|
}
|
|
1240
1245
|
if (blockIdx <= 0) {
|
|
@@ -1244,10 +1249,10 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1244
1249
|
const idx = cp[cp.length - 1];
|
|
1245
1250
|
if (idx < 1)
|
|
1246
1251
|
continue;
|
|
1247
|
-
const prevSib =
|
|
1248
|
-
if (
|
|
1252
|
+
const prevSib = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, cp.slice(0, -1)).children[idx - 1];
|
|
1253
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, prevSib))
|
|
1249
1254
|
break;
|
|
1250
|
-
const endOfPrev2 = [...cp.slice(0, -1), idx - 1, ...
|
|
1255
|
+
const endOfPrev2 = [...cp.slice(0, -1), idx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prevSib)];
|
|
1251
1256
|
const del2 = deleteRange(doc, endOfPrev2, sel.head.path);
|
|
1252
1257
|
return { steps: del2.steps, selection: caret(del2.caret) };
|
|
1253
1258
|
}
|
|
@@ -1257,11 +1262,11 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1257
1262
|
}
|
|
1258
1263
|
return null;
|
|
1259
1264
|
}
|
|
1260
|
-
const parent =
|
|
1265
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
1261
1266
|
const prev = parent.children[blockIdx - 1];
|
|
1262
|
-
if (!prev ||
|
|
1267
|
+
if (!prev || _chunkGQ2HHRGIcjs.isText.call(void 0, prev))
|
|
1263
1268
|
return null;
|
|
1264
|
-
const endOfPrev = [...parentPath, blockIdx - 1, ...
|
|
1269
|
+
const endOfPrev = [...parentPath, blockIdx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prev)];
|
|
1265
1270
|
const del = deleteRange(doc, endOfPrev, sel.head.path);
|
|
1266
1271
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1267
1272
|
}
|
|
@@ -1272,28 +1277,28 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1272
1277
|
if (from < text.length)
|
|
1273
1278
|
return { steps: [{ kind: "deleteText", path: leafPath, offset: from, length: 1 }], selection: caret(leafPath.concat(from)) };
|
|
1274
1279
|
const nextInBlock = block.children[leafIdx + 1];
|
|
1275
|
-
if (nextInBlock &&
|
|
1280
|
+
if (nextInBlock && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, nextInBlock))
|
|
1276
1281
|
return { steps: [{ kind: "spliceChildren", path: blockPath, at: leafIdx + 1, remove: 1, insert: [] }], selection: caret(leafPath.concat(from)) };
|
|
1277
|
-
const parent =
|
|
1282
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
1278
1283
|
const next = parent.children[blockIdx + 1];
|
|
1279
|
-
if (!next ||
|
|
1284
|
+
if (!next || _chunkGQ2HHRGIcjs.isText.call(void 0, next)) {
|
|
1280
1285
|
if (inTableCell(doc, blockPath))
|
|
1281
1286
|
return null;
|
|
1282
1287
|
for (let cp = parentPath; cp.length > 0; cp = cp.slice(0, -1)) {
|
|
1283
1288
|
const idx = cp[cp.length - 1];
|
|
1284
|
-
const sibs =
|
|
1289
|
+
const sibs = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, cp.slice(0, -1)).children;
|
|
1285
1290
|
const nextSib = sibs[idx + 1];
|
|
1286
1291
|
if (!nextSib)
|
|
1287
1292
|
continue;
|
|
1288
|
-
if (
|
|
1293
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, nextSib))
|
|
1289
1294
|
break;
|
|
1290
|
-
const startOfNext2 = [...cp.slice(0, -1), idx + 1, ...
|
|
1295
|
+
const startOfNext2 = [...cp.slice(0, -1), idx + 1, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, nextSib), 0];
|
|
1291
1296
|
const del2 = deleteRange(doc, sel.head.path, startOfNext2);
|
|
1292
1297
|
return { steps: del2.steps, selection: caret(del2.caret) };
|
|
1293
1298
|
}
|
|
1294
1299
|
return null;
|
|
1295
1300
|
}
|
|
1296
|
-
const startOfNext = [...parentPath, blockIdx + 1, ...
|
|
1301
|
+
const startOfNext = [...parentPath, blockIdx + 1, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, next), 0];
|
|
1297
1302
|
const del = deleteRange(doc, sel.head.path, startOfNext);
|
|
1298
1303
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1299
1304
|
}
|
|
@@ -1354,8 +1359,8 @@ function blockTransform(block, blockIdx, kind, newId4, extra) {
|
|
|
1354
1359
|
}
|
|
1355
1360
|
}
|
|
1356
1361
|
function setCalloutVariant(doc, path, variant) {
|
|
1357
|
-
const node =
|
|
1358
|
-
if (!node ||
|
|
1362
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
1363
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "callout")
|
|
1359
1364
|
return null;
|
|
1360
1365
|
if (_optionalChain([node, 'access', _78 => _78.attrs, 'optionalAccess', _79 => _79.variant]) === variant)
|
|
1361
1366
|
return null;
|
|
@@ -1365,8 +1370,8 @@ function setCalloutVariant(doc, path, variant) {
|
|
|
1365
1370
|
};
|
|
1366
1371
|
}
|
|
1367
1372
|
function cycleCalloutVariant(doc, path) {
|
|
1368
|
-
const node =
|
|
1369
|
-
if (!node ||
|
|
1373
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
1374
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "callout")
|
|
1370
1375
|
return null;
|
|
1371
1376
|
const cur = String(_nullishCoalesce(_optionalChain([node, 'access', _80 => _80.attrs, 'optionalAccess', _81 => _81.variant]), () => ( "info")));
|
|
1372
1377
|
const i = CALLOUT_VARIANTS.indexOf(cur);
|
|
@@ -1396,7 +1401,7 @@ function mapCrossInput(doc, intent, data, sel, newId4) {
|
|
|
1396
1401
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1397
1402
|
if (intent === "insertText" && !data)
|
|
1398
1403
|
return null;
|
|
1399
|
-
const doc2 =
|
|
1404
|
+
const doc2 = _chunk4TMHVNL6cjs.applyAll.call(void 0, doc, del.steps);
|
|
1400
1405
|
const at = caret(del.caret);
|
|
1401
1406
|
const tail = mapInput(doc2, intent, data, at, newId4);
|
|
1402
1407
|
if (!tail)
|
|
@@ -1405,8 +1410,8 @@ function mapCrossInput(doc, intent, data, sel, newId4) {
|
|
|
1405
1410
|
}
|
|
1406
1411
|
var markable = (n) => n.type !== "code" && n.type !== "raw";
|
|
1407
1412
|
function marksAtCaret(doc, path) {
|
|
1408
|
-
const leaf =
|
|
1409
|
-
return
|
|
1413
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path.slice(0, -1));
|
|
1414
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? [..._nullishCoalesce(leaf.marks, () => ( []))] : [];
|
|
1410
1415
|
}
|
|
1411
1416
|
function toggleMarkList(marks, name, attrs) {
|
|
1412
1417
|
const on = attrs !== void 0 ? hasMarkEq(marks, name, attrs) : hasMark(marks, name);
|
|
@@ -1417,9 +1422,9 @@ function toggleMarkList(marks, name, attrs) {
|
|
|
1417
1422
|
function leafBlocksBetween(doc, fromBlock, toBlock) {
|
|
1418
1423
|
const all = [];
|
|
1419
1424
|
const walk = (node, path) => {
|
|
1420
|
-
if (!
|
|
1425
|
+
if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, node))
|
|
1421
1426
|
return;
|
|
1422
|
-
if (node.children.every((c) =>
|
|
1427
|
+
if (node.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) || _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c)))
|
|
1423
1428
|
all.push({ path, node });
|
|
1424
1429
|
else
|
|
1425
1430
|
node.children.forEach((c, i) => walk(c, [...path, i]));
|
|
@@ -1430,14 +1435,14 @@ function leafBlocksBetween(doc, fromBlock, toBlock) {
|
|
|
1430
1435
|
return fi < 0 || ti < 0 ? [] : all.slice(fi, ti + 1);
|
|
1431
1436
|
}
|
|
1432
1437
|
function totalChars(children) {
|
|
1433
|
-
return children.reduce((a, c) => a + (
|
|
1438
|
+
return children.reduce((a, c) => a + (_chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1), 0);
|
|
1434
1439
|
}
|
|
1435
1440
|
function spannedSegs(block, from, to) {
|
|
1436
1441
|
const out = [];
|
|
1437
1442
|
let pos = 0;
|
|
1438
1443
|
for (const leaf of block.children) {
|
|
1439
|
-
const len =
|
|
1440
|
-
if (
|
|
1444
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 1;
|
|
1445
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1441
1446
|
const lo = Math.max(from, pos);
|
|
1442
1447
|
const hi = Math.min(to, pos + len);
|
|
1443
1448
|
if (lo < hi)
|
|
@@ -1451,7 +1456,7 @@ function markChars(block, from, to, name, on, attrs) {
|
|
|
1451
1456
|
const out = [];
|
|
1452
1457
|
let pos = 0;
|
|
1453
1458
|
for (const leaf of block.children) {
|
|
1454
|
-
if (!
|
|
1459
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1455
1460
|
out.push(leaf);
|
|
1456
1461
|
pos += 1;
|
|
1457
1462
|
continue;
|
|
@@ -1532,7 +1537,7 @@ function textStyleChars(block, from, to, patch) {
|
|
|
1532
1537
|
const out = [];
|
|
1533
1538
|
let pos = 0;
|
|
1534
1539
|
for (const leaf of block.children) {
|
|
1535
|
-
if (!
|
|
1540
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1536
1541
|
out.push(leaf);
|
|
1537
1542
|
pos += 1;
|
|
1538
1543
|
continue;
|
|
@@ -1578,11 +1583,11 @@ function setTextStyle(doc, sel, patch) {
|
|
|
1578
1583
|
};
|
|
1579
1584
|
}
|
|
1580
1585
|
function sliceLeaf(leaf, from, to) {
|
|
1581
|
-
return
|
|
1586
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(from, to) } : leaf;
|
|
1582
1587
|
}
|
|
1583
1588
|
function insertMarked(block, blockPath, leafIdx, from, to, text, marks) {
|
|
1584
1589
|
const leaf = block.children[leafIdx];
|
|
1585
|
-
if (!
|
|
1590
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
1586
1591
|
return null;
|
|
1587
1592
|
const markList = marks.length ? marks : void 0;
|
|
1588
1593
|
if (from === to && marksEq(leaf.marks, markList)) {
|
|
@@ -1627,7 +1632,7 @@ function insertHardBreak(block, blockPath, leafIdx, from, to) {
|
|
|
1627
1632
|
if (block.type !== "paragraph" && block.type !== "heading")
|
|
1628
1633
|
return null;
|
|
1629
1634
|
const leaf = block.children[leafIdx];
|
|
1630
|
-
if (!
|
|
1635
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
1631
1636
|
return null;
|
|
1632
1637
|
const before = leaf.text.slice(0, from);
|
|
1633
1638
|
const after = leaf.text.slice(to);
|
|
@@ -1644,7 +1649,7 @@ function insertHardBreak(block, blockPath, leafIdx, from, to) {
|
|
|
1644
1649
|
]);
|
|
1645
1650
|
const brAt = leafIdx + (before ? 1 : 0);
|
|
1646
1651
|
const afterIdx = brAt + 1;
|
|
1647
|
-
const landIdx = afterIdx < children.length &&
|
|
1652
|
+
const landIdx = afterIdx < children.length && _chunkGQ2HHRGIcjs.isText.call(void 0, children[afterIdx]) ? afterIdx : brAt;
|
|
1648
1653
|
return {
|
|
1649
1654
|
steps: [{ kind: "replaceNode", path: blockPath, node: { ...block, children } }],
|
|
1650
1655
|
selection: caret([...blockPath, landIdx, 0])
|
|
@@ -1654,21 +1659,21 @@ function coalesceLeaves(children) {
|
|
|
1654
1659
|
const out = [];
|
|
1655
1660
|
for (let i = 0; i < children.length; i++) {
|
|
1656
1661
|
const n = children[i];
|
|
1657
|
-
if (
|
|
1662
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.text === "" && children.length > 1) {
|
|
1658
1663
|
const prev2 = out[out.length - 1];
|
|
1659
1664
|
const next = children[i + 1];
|
|
1660
|
-
if (prev2 &&
|
|
1665
|
+
if (prev2 && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, prev2)) {
|
|
1661
1666
|
out.push(n);
|
|
1662
1667
|
continue;
|
|
1663
1668
|
}
|
|
1664
|
-
if (next &&
|
|
1669
|
+
if (next && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, next)) {
|
|
1665
1670
|
out.push(n);
|
|
1666
1671
|
continue;
|
|
1667
1672
|
}
|
|
1668
1673
|
continue;
|
|
1669
1674
|
}
|
|
1670
1675
|
const prev = out[out.length - 1];
|
|
1671
|
-
if (prev &&
|
|
1676
|
+
if (prev && _chunkGQ2HHRGIcjs.isText.call(void 0, prev) && _chunkGQ2HHRGIcjs.isText.call(void 0, n) && marksEq(prev.marks, n.marks))
|
|
1672
1677
|
out[out.length - 1] = { ...prev, text: prev.text + n.text };
|
|
1673
1678
|
else
|
|
1674
1679
|
out.push(n);
|
|
@@ -1689,7 +1694,7 @@ function blockChar(children, leafIdx, char) {
|
|
|
1689
1694
|
let acc = 0;
|
|
1690
1695
|
for (let i = 0; i < leafIdx; i++) {
|
|
1691
1696
|
const c = children[i];
|
|
1692
|
-
acc +=
|
|
1697
|
+
acc += _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1;
|
|
1693
1698
|
}
|
|
1694
1699
|
return acc + char;
|
|
1695
1700
|
}
|
|
@@ -1697,17 +1702,17 @@ function locate(children, target) {
|
|
|
1697
1702
|
let acc = 0;
|
|
1698
1703
|
for (let i = 0; i < children.length; i++) {
|
|
1699
1704
|
const c = children[i];
|
|
1700
|
-
const len =
|
|
1705
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1;
|
|
1701
1706
|
if (target <= acc + len)
|
|
1702
1707
|
return [i, target - acc];
|
|
1703
1708
|
acc += len;
|
|
1704
1709
|
}
|
|
1705
1710
|
const last = children.length - 1;
|
|
1706
1711
|
const lc = children[last];
|
|
1707
|
-
return [last,
|
|
1712
|
+
return [last, _chunkGQ2HHRGIcjs.isText.call(void 0, lc) ? lc.text.length : 1];
|
|
1708
1713
|
}
|
|
1709
1714
|
function textLen(ns) {
|
|
1710
|
-
return ns.reduce((a, n) => a + (
|
|
1715
|
+
return ns.reduce((a, n) => a + (_chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n.text.length : 1), 0);
|
|
1711
1716
|
}
|
|
1712
1717
|
function stripSpan(b) {
|
|
1713
1718
|
return _optionalChain([b, 'access', _90 => _90.attrs, 'optionalAccess', _91 => _91.span]) ? { ...b, attrs: { ...b.attrs, span: void 0 } } : b;
|
|
@@ -1717,12 +1722,12 @@ function sliceDoc(doc, p1, p2) {
|
|
|
1717
1722
|
const a = split(lo);
|
|
1718
1723
|
const b = split(hi);
|
|
1719
1724
|
if (sameLeaf(lo, hi)) {
|
|
1720
|
-
const block =
|
|
1725
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
1721
1726
|
return { type: "doc", children: [stripSpan({ ...block, children: [sliceLeaf(block.children[a.leafIdx], a.char, b.char)] })] };
|
|
1722
1727
|
}
|
|
1723
1728
|
const sameBlock = a.blockPath.length === b.blockPath.length && a.blockPath.every((s, i) => s === b.blockPath[i]);
|
|
1724
1729
|
if (sameBlock) {
|
|
1725
|
-
const block =
|
|
1730
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
1726
1731
|
const mid = [trimHead(block.children[a.leafIdx], a.char), ...block.children.slice(a.leafIdx + 1, b.leafIdx), trimTail(block.children[b.leafIdx], b.char)];
|
|
1727
1732
|
return { type: "doc", children: [stripSpan({ ...block, children: coalesceLeaves(mid) })] };
|
|
1728
1733
|
}
|
|
@@ -1731,7 +1736,7 @@ function sliceDoc(doc, p1, p2) {
|
|
|
1731
1736
|
if (loTop === hiTop && doc.children[loTop].type === "table")
|
|
1732
1737
|
return { type: "doc", children: [stripSpan(doc.children[loTop])] };
|
|
1733
1738
|
const first = doc.children[loTop].type === "table" ? stripSpan(doc.children[loTop]) : stripSpan(keepAfter(doc.children[loTop], lo.slice(1)));
|
|
1734
|
-
const middle = doc.children.slice(loTop + 1, hiTop).map((n) =>
|
|
1739
|
+
const middle = doc.children.slice(loTop + 1, hiTop).map((n) => _chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n : stripSpan(n));
|
|
1735
1740
|
const last = doc.children[hiTop].type === "table" ? stripSpan(doc.children[hiTop]) : stripSpan(keepBefore(doc.children[hiTop], hi.slice(1)));
|
|
1736
1741
|
return { type: "doc", children: [first, ...middle, last] };
|
|
1737
1742
|
}
|
|
@@ -1745,10 +1750,10 @@ function keepAfter(node, rel) {
|
|
|
1745
1750
|
function serializeSelection(doc, sel) {
|
|
1746
1751
|
if (cmpPath(sel.anchor.path, sel.head.path) === 0)
|
|
1747
1752
|
return "";
|
|
1748
|
-
return
|
|
1753
|
+
return _chunk4TMHVNL6cjs.docToMd.call(void 0, sliceDoc(doc, sel.anchor.path, sel.head.path), "");
|
|
1749
1754
|
}
|
|
1750
1755
|
function mapPaste(doc, sel, md, newId4) {
|
|
1751
|
-
const frag =
|
|
1756
|
+
const frag = _chunk4TMHVNL6cjs.mdToDoc.call(void 0, md).children.filter((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
1752
1757
|
return mapPasteBlocks(doc, sel, frag, newId4);
|
|
1753
1758
|
}
|
|
1754
1759
|
function mapPasteBlocks(doc, sel, frag, newId4) {
|
|
@@ -1756,7 +1761,7 @@ function mapPasteBlocks(doc, sel, frag, newId4) {
|
|
|
1756
1761
|
return null;
|
|
1757
1762
|
if (cmpPath(sel.anchor.path, sel.head.path) !== 0) {
|
|
1758
1763
|
const del = deleteRange(doc, sel.anchor.path, sel.head.path);
|
|
1759
|
-
const r = pasteAt(
|
|
1764
|
+
const r = pasteAt(_chunk4TMHVNL6cjs.applyAll.call(void 0, doc, del.steps), del.caret, frag, newId4);
|
|
1760
1765
|
return { steps: [...del.steps, ...r.steps], selection: r.selection };
|
|
1761
1766
|
}
|
|
1762
1767
|
return pasteAt(doc, sel.head.path, frag, newId4);
|
|
@@ -1767,13 +1772,13 @@ function indentItem(doc, sel, newId4) {
|
|
|
1767
1772
|
const itemIdx = itemPath[itemPath.length - 1];
|
|
1768
1773
|
if (itemIdx === 0)
|
|
1769
1774
|
return null;
|
|
1770
|
-
const list =
|
|
1771
|
-
if (!list ||
|
|
1775
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
1776
|
+
if (!list || _chunkGQ2HHRGIcjs.isText.call(void 0, list) || list.type !== "list")
|
|
1772
1777
|
return null;
|
|
1773
1778
|
const item = list.children[itemIdx];
|
|
1774
1779
|
const prev = list.children[itemIdx - 1];
|
|
1775
1780
|
const prevLast = prev.children[prev.children.length - 1];
|
|
1776
|
-
const intoExisting = !
|
|
1781
|
+
const intoExisting = !_chunkGQ2HHRGIcjs.isText.call(void 0, prevLast) && prevLast.type === "list";
|
|
1777
1782
|
const sublist = intoExisting ? { ...prevLast, children: [...prevLast.children, item] } : { ...list, id: newId4(), children: [item] };
|
|
1778
1783
|
const subIdx = intoExisting ? prev.children.length - 1 : prev.children.length;
|
|
1779
1784
|
const newPrev = { ...prev, children: intoExisting ? [...prev.children.slice(0, -1), sublist] : [...prev.children, sublist] };
|
|
@@ -1787,17 +1792,17 @@ function outdentItem(doc, sel, newId4) {
|
|
|
1787
1792
|
const itemPath = sel.head.path.slice(0, -3);
|
|
1788
1793
|
const sublistPath = itemPath.slice(0, -1);
|
|
1789
1794
|
const parentItemPath = sublistPath.slice(0, -1);
|
|
1790
|
-
const parentItem =
|
|
1795
|
+
const parentItem = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentItemPath);
|
|
1791
1796
|
if (!parentItem || parentItem.type !== "list_item")
|
|
1792
1797
|
return null;
|
|
1793
|
-
const sublist =
|
|
1794
|
-
if (!sublist ||
|
|
1798
|
+
const sublist = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, sublistPath);
|
|
1799
|
+
if (!sublist || _chunkGQ2HHRGIcjs.isText.call(void 0, sublist) || sublist.type !== "list")
|
|
1795
1800
|
return null;
|
|
1796
1801
|
const subItemIdx = itemPath[itemPath.length - 1];
|
|
1797
1802
|
const item = sublist.children[subItemIdx];
|
|
1798
1803
|
const following = sublist.children.slice(subItemIdx + 1);
|
|
1799
1804
|
const itemLast = item.children[item.children.length - 1];
|
|
1800
|
-
const newItem = following.length ? !
|
|
1805
|
+
const newItem = following.length ? !_chunkGQ2HHRGIcjs.isText.call(void 0, itemLast) && itemLast.type === "list" ? { ...item, children: [...item.children.slice(0, -1), { ...itemLast, children: [...itemLast.children, ...following] }] } : { ...item, children: [...item.children, { ...sublist, id: newId4(), children: following }] } : item;
|
|
1801
1806
|
const subIdxInParent = sublistPath[sublistPath.length - 1];
|
|
1802
1807
|
const preceding = sublist.children.slice(0, subItemIdx);
|
|
1803
1808
|
const newParentChildren = preceding.length ? [...parentItem.children.slice(0, subIdxInParent), { ...sublist, children: preceding }, ...parentItem.children.slice(subIdxInParent + 1)] : [...parentItem.children.slice(0, subIdxInParent), ...parentItem.children.slice(subIdxInParent + 1)];
|
|
@@ -1810,7 +1815,7 @@ function outdentItem(doc, sel, newId4) {
|
|
|
1810
1815
|
};
|
|
1811
1816
|
}
|
|
1812
1817
|
function isInline(b) {
|
|
1813
|
-
return !isAtom(b) && b.children.every(
|
|
1818
|
+
return !isAtom(b) && b.children.every(_chunkGQ2HHRGIcjs.isText);
|
|
1814
1819
|
}
|
|
1815
1820
|
function splitDeep(block, path, newId4) {
|
|
1816
1821
|
if (path.length === 2) {
|
|
@@ -1827,7 +1832,7 @@ function splitDeep(block, path, newId4) {
|
|
|
1827
1832
|
return [head, tail];
|
|
1828
1833
|
}
|
|
1829
1834
|
function emptyInline(b) {
|
|
1830
|
-
return isInline(b) && b.children.every((c) =>
|
|
1835
|
+
return isInline(b) && b.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text === "");
|
|
1831
1836
|
}
|
|
1832
1837
|
function lastInlinePath(b) {
|
|
1833
1838
|
if (isInline(b))
|
|
@@ -1850,7 +1855,7 @@ function spliceInline(block, path, leaves, atTail) {
|
|
|
1850
1855
|
return { ...block, children: [...block.children.slice(0, i), child, ...block.children.slice(i + 1)] };
|
|
1851
1856
|
}
|
|
1852
1857
|
function inlineLeaves(b) {
|
|
1853
|
-
return b.children.flatMap((c) =>
|
|
1858
|
+
return b.children.flatMap((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? [c] : inlineLeaves(c));
|
|
1854
1859
|
}
|
|
1855
1860
|
function flattenInline(frag) {
|
|
1856
1861
|
const out = [];
|
|
@@ -1862,8 +1867,8 @@ function flattenInline(frag) {
|
|
|
1862
1867
|
return coalesceLeaves(out);
|
|
1863
1868
|
}
|
|
1864
1869
|
function pasteTableInto(caretPath, target, src) {
|
|
1865
|
-
const tGrid =
|
|
1866
|
-
const sGrid =
|
|
1870
|
+
const tGrid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, target);
|
|
1871
|
+
const sGrid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, src);
|
|
1867
1872
|
const cellIdx = _nullishCoalesce(caretPath[1], () => ( 0));
|
|
1868
1873
|
const anchor = tGrid.cellOf(cellIdx);
|
|
1869
1874
|
const r0 = anchor.r;
|
|
@@ -1895,9 +1900,9 @@ function pasteTableInto(caretPath, target, src) {
|
|
|
1895
1900
|
}
|
|
1896
1901
|
function pasteAt(doc, caretPath, frag, newId4) {
|
|
1897
1902
|
const { blockPath, leafIdx, char } = split(caretPath);
|
|
1898
|
-
const block =
|
|
1903
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath);
|
|
1899
1904
|
const topBlock = doc.children[caretPath[0]];
|
|
1900
|
-
const inAtom = !
|
|
1905
|
+
const inAtom = !_chunkGQ2HHRGIcjs.isText.call(void 0, topBlock) && topBlock.type === "table";
|
|
1901
1906
|
if (inAtom && frag.length === 1 && frag[0].type === "table") {
|
|
1902
1907
|
return pasteTableInto(caretPath, topBlock, frag[0]);
|
|
1903
1908
|
}
|
|
@@ -3227,7 +3232,7 @@ function askInput(opts) {
|
|
|
3227
3232
|
dismissActive(null);
|
|
3228
3233
|
return new Promise((resolve2) => {
|
|
3229
3234
|
const root = document.createElement("div");
|
|
3230
|
-
root.className = "
|
|
3235
|
+
root.className = "markloom-prompt-host";
|
|
3231
3236
|
document.body.appendChild(root);
|
|
3232
3237
|
let value = _nullishCoalesce(opts.defaultValue, () => ( ""));
|
|
3233
3238
|
let error = null;
|
|
@@ -3258,7 +3263,7 @@ function askInput(opts) {
|
|
|
3258
3263
|
document.addEventListener("keydown", onKey, true);
|
|
3259
3264
|
const paint = () => {
|
|
3260
3265
|
const inputProps = {
|
|
3261
|
-
class: "
|
|
3266
|
+
class: "markloom-prompt-input" + (error ? " markloom-prompt-input-err" : ""),
|
|
3262
3267
|
value,
|
|
3263
3268
|
placeholder: _nullishCoalesce(opts.placeholder, () => ( "")),
|
|
3264
3269
|
autofocus: true,
|
|
@@ -3282,27 +3287,27 @@ function askInput(opts) {
|
|
|
3282
3287
|
};
|
|
3283
3288
|
_preact.render.call(void 0,
|
|
3284
3289
|
_preact.h.call(void 0, "div", {
|
|
3285
|
-
class: "
|
|
3286
|
-
"data-
|
|
3290
|
+
class: "markloom-prompt-mask",
|
|
3291
|
+
"data-markloom-prompt": "",
|
|
3287
3292
|
onMouseDown: (e) => {
|
|
3288
3293
|
if (e.target === e.currentTarget)
|
|
3289
3294
|
finish(null);
|
|
3290
3295
|
}
|
|
3291
3296
|
}, _preact.h.call(void 0, "div", {
|
|
3292
|
-
class: "
|
|
3297
|
+
class: "markloom-prompt-card",
|
|
3293
3298
|
role: "dialog",
|
|
3294
3299
|
"aria-modal": "true",
|
|
3295
3300
|
"aria-label": opts.title,
|
|
3296
3301
|
onMouseDown: (e) => e.stopPropagation()
|
|
3297
3302
|
}, [
|
|
3298
|
-
_preact.h.call(void 0, "div", { class: "
|
|
3299
|
-
opts.description ? _preact.h.call(void 0, "div", { class: "
|
|
3303
|
+
_preact.h.call(void 0, "div", { class: "markloom-prompt-title", key: "t" }, opts.title),
|
|
3304
|
+
opts.description ? _preact.h.call(void 0, "div", { class: "markloom-prompt-desc", key: "d" }, opts.description) : null,
|
|
3300
3305
|
opts.multiline ? _preact.h.call(void 0, "textarea", { ...inputProps, key: "i", rows: 4 }) : _preact.h.call(void 0, "input", { ...inputProps, key: "i", type: "text" }),
|
|
3301
|
-
error ? _preact.h.call(void 0, "div", { class: "
|
|
3302
|
-
_preact.h.call(void 0, "div", { class: "
|
|
3306
|
+
error ? _preact.h.call(void 0, "div", { class: "markloom-prompt-err", key: "e" }, error) : null,
|
|
3307
|
+
_preact.h.call(void 0, "div", { class: "markloom-prompt-ft", key: "f" }, [
|
|
3303
3308
|
_preact.h.call(void 0, "button", {
|
|
3304
3309
|
type: "button",
|
|
3305
|
-
class: "
|
|
3310
|
+
class: "markloom-prompt-btn markloom-prompt-btn-ghost",
|
|
3306
3311
|
"data-act": "cancel",
|
|
3307
3312
|
onMouseDown: (e) => {
|
|
3308
3313
|
e.preventDefault();
|
|
@@ -3311,7 +3316,7 @@ function askInput(opts) {
|
|
|
3311
3316
|
}, _nullishCoalesce(opts.cancelLabel, () => ( "\u53D6\u6D88"))),
|
|
3312
3317
|
_preact.h.call(void 0, "button", {
|
|
3313
3318
|
type: "button",
|
|
3314
|
-
class: "
|
|
3319
|
+
class: "markloom-prompt-btn markloom-prompt-btn-primary",
|
|
3315
3320
|
"data-act": "confirm",
|
|
3316
3321
|
onMouseDown: (e) => {
|
|
3317
3322
|
e.preventDefault();
|
|
@@ -3348,7 +3353,7 @@ function askLinkPopover(opts) {
|
|
|
3348
3353
|
dismissActive(null);
|
|
3349
3354
|
return new Promise((resolve2) => {
|
|
3350
3355
|
const root = document.createElement("div");
|
|
3351
|
-
root.className = "
|
|
3356
|
+
root.className = "markloom-link-pop-host";
|
|
3352
3357
|
document.body.appendChild(root);
|
|
3353
3358
|
let value = _nullishCoalesce(opts.defaultValue, () => ( ""));
|
|
3354
3359
|
let placed = false;
|
|
@@ -3384,8 +3389,8 @@ function askLinkPopover(opts) {
|
|
|
3384
3389
|
const can = value.trim().length > 0;
|
|
3385
3390
|
_preact.render.call(void 0,
|
|
3386
3391
|
_preact.h.call(void 0, "div", {
|
|
3387
|
-
class: "
|
|
3388
|
-
"data-
|
|
3392
|
+
class: "markloom-link-pop",
|
|
3393
|
+
"data-markloom-link-pop": "",
|
|
3389
3394
|
role: "dialog",
|
|
3390
3395
|
"aria-label": "\u6DFB\u52A0\u94FE\u63A5",
|
|
3391
3396
|
onMouseDown: (e) => {
|
|
@@ -3397,7 +3402,7 @@ function askLinkPopover(opts) {
|
|
|
3397
3402
|
}, [
|
|
3398
3403
|
_preact.h.call(void 0, "input", {
|
|
3399
3404
|
key: "i",
|
|
3400
|
-
class: "
|
|
3405
|
+
class: "markloom-link-pop-input",
|
|
3401
3406
|
type: "text",
|
|
3402
3407
|
value,
|
|
3403
3408
|
placeholder: _nullishCoalesce(opts.placeholder, () => ( "\u7C98\u8D34\u6216\u8F93\u5165\u94FE\u63A5")),
|
|
@@ -3415,7 +3420,7 @@ function askLinkPopover(opts) {
|
|
|
3415
3420
|
_preact.h.call(void 0, "button", {
|
|
3416
3421
|
key: "ok",
|
|
3417
3422
|
type: "button",
|
|
3418
|
-
class: "
|
|
3423
|
+
class: "markloom-link-pop-ok" + (can ? " is-ready" : ""),
|
|
3419
3424
|
"data-act": "confirm",
|
|
3420
3425
|
disabled: !can,
|
|
3421
3426
|
onMouseDown: (e) => {
|
|
@@ -3426,7 +3431,7 @@ function askLinkPopover(opts) {
|
|
|
3426
3431
|
]),
|
|
3427
3432
|
root
|
|
3428
3433
|
);
|
|
3429
|
-
const el = root.querySelector(".
|
|
3434
|
+
const el = root.querySelector(".markloom-link-pop");
|
|
3430
3435
|
if (el && !placed) {
|
|
3431
3436
|
placed = true;
|
|
3432
3437
|
const rect = readAnchor(opts.anchor);
|
|
@@ -3465,14 +3470,14 @@ var MentionMenu = (_class = class {
|
|
|
3465
3470
|
this.root = root;
|
|
3466
3471
|
this.host = host;
|
|
3467
3472
|
this.overlay = document.createElement("div");
|
|
3468
|
-
this.overlay.className = "
|
|
3473
|
+
this.overlay.className = "markloom-mention-overlay";
|
|
3469
3474
|
document.body.appendChild(this.overlay);
|
|
3470
|
-
root.addEventListener("
|
|
3475
|
+
root.addEventListener("markloom-redraw", this.reevaluate);
|
|
3471
3476
|
document.addEventListener("selectionchange", this.reevaluate);
|
|
3472
3477
|
root.addEventListener("keydown", this.onKeyDown, true);
|
|
3473
3478
|
}
|
|
3474
3479
|
destroy() {
|
|
3475
|
-
this.root.removeEventListener("
|
|
3480
|
+
this.root.removeEventListener("markloom-redraw", this.reevaluate);
|
|
3476
3481
|
document.removeEventListener("selectionchange", this.reevaluate);
|
|
3477
3482
|
this.root.removeEventListener("keydown", this.onKeyDown, true);
|
|
3478
3483
|
this.close();
|
|
@@ -3494,12 +3499,12 @@ var MentionMenu = (_class = class {
|
|
|
3494
3499
|
const leafIdx = sel.head.path[sel.head.path.length - 2];
|
|
3495
3500
|
const caret3 = sel.head.path[sel.head.path.length - 1];
|
|
3496
3501
|
const block = nodeAt2(this.host.doc(), blockPath);
|
|
3497
|
-
if (!block ||
|
|
3502
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph" && block.type !== "heading") {
|
|
3498
3503
|
this.close();
|
|
3499
3504
|
return;
|
|
3500
3505
|
}
|
|
3501
3506
|
const leaf = block.children[leafIdx];
|
|
3502
|
-
if (!leaf || !
|
|
3507
|
+
if (!leaf || !_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
3503
3508
|
this.close();
|
|
3504
3509
|
return;
|
|
3505
3510
|
}
|
|
@@ -3554,12 +3559,12 @@ var MentionMenu = (_class = class {
|
|
|
3554
3559
|
return;
|
|
3555
3560
|
}
|
|
3556
3561
|
const block = nodeAt2(this.host.doc(), t.blockPath);
|
|
3557
|
-
if (!block ||
|
|
3562
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block)) {
|
|
3558
3563
|
this.close();
|
|
3559
3564
|
return;
|
|
3560
3565
|
}
|
|
3561
3566
|
const leaf = block.children[t.leafIdx];
|
|
3562
|
-
if (!leaf || !
|
|
3567
|
+
if (!leaf || !_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
3563
3568
|
this.close();
|
|
3564
3569
|
return;
|
|
3565
3570
|
}
|
|
@@ -3595,7 +3600,7 @@ var MentionMenu = (_class = class {
|
|
|
3595
3600
|
_preact.render.call(void 0,
|
|
3596
3601
|
_preact.h.call(void 0,
|
|
3597
3602
|
"div",
|
|
3598
|
-
{ class: "
|
|
3603
|
+
{ class: "markloom-mention-menu" },
|
|
3599
3604
|
this.list.map((c, i) => _preact.h.call(void 0, "button", {
|
|
3600
3605
|
"key": c.id,
|
|
3601
3606
|
"type": "button",
|
|
@@ -3604,11 +3609,11 @@ var MentionMenu = (_class = class {
|
|
|
3604
3609
|
e.preventDefault();
|
|
3605
3610
|
this.apply(c);
|
|
3606
3611
|
}
|
|
3607
|
-
}, c.kind === "date" ? [icon("calendar", 14, "
|
|
3612
|
+
}, c.kind === "date" ? [icon("calendar", 14, "markloom-mention-ico"), " ", c.label] : ["@", c.label]))
|
|
3608
3613
|
),
|
|
3609
3614
|
this.overlay
|
|
3610
3615
|
);
|
|
3611
|
-
const el = this.overlay.querySelector(".
|
|
3616
|
+
const el = this.overlay.querySelector(".markloom-mention-menu");
|
|
3612
3617
|
if (el)
|
|
3613
3618
|
void place(rectRef(rect), el, { placement: "bottom-start", gap: 6 });
|
|
3614
3619
|
}
|
|
@@ -3627,7 +3632,7 @@ function samePath(a, b) {
|
|
|
3627
3632
|
function nodeAt2(doc, path) {
|
|
3628
3633
|
let cur = doc;
|
|
3629
3634
|
for (const seg of path) {
|
|
3630
|
-
if (
|
|
3635
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, cur))
|
|
3631
3636
|
return null;
|
|
3632
3637
|
const child = cur.children[seg];
|
|
3633
3638
|
if (!child)
|
|
@@ -3658,10 +3663,10 @@ var BLOCK_ITEMS = [
|
|
|
3658
3663
|
{ kind: "callout", label: "\u9AD8\u4EAE\u5757", ico: "callout", group: "box" }
|
|
3659
3664
|
];
|
|
3660
3665
|
var MARK_ITEMS = [
|
|
3661
|
-
{ name: "bold", label: "B", tip: `\u7C97\u4F53 (${mod} + B)`, md: "**\u6587\u672C** \u7A7A\u683C", cls: "
|
|
3662
|
-
{ name: "strike", label: "S", tip: `\u5220\u9664\u7EBF (${mod} + Shift + X)`, md: "~~\u6587\u672C~~ \u7A7A\u683C", cls: "
|
|
3663
|
-
{ name: "italic", label: "I", tip: `\u659C\u4F53 (${mod} + I)`, md: "*\u6587\u672C* \u7A7A\u683C", cls: "
|
|
3664
|
-
{ name: "underline", label: "U", tip: `\u4E0B\u5212\u7EBF (${mod} + U)`, md: "", cls: "
|
|
3666
|
+
{ name: "bold", label: "B", tip: `\u7C97\u4F53 (${mod} + B)`, md: "**\u6587\u672C** \u7A7A\u683C", cls: "markloom-bb-bold" },
|
|
3667
|
+
{ name: "strike", label: "S", tip: `\u5220\u9664\u7EBF (${mod} + Shift + X)`, md: "~~\u6587\u672C~~ \u7A7A\u683C", cls: "markloom-bb-strike" },
|
|
3668
|
+
{ name: "italic", label: "I", tip: `\u659C\u4F53 (${mod} + I)`, md: "*\u6587\u672C* \u7A7A\u683C", cls: "markloom-bb-italic" },
|
|
3669
|
+
{ name: "underline", label: "U", tip: `\u4E0B\u5212\u7EBF (${mod} + U)`, md: "", cls: "markloom-bb-under" }
|
|
3665
3670
|
];
|
|
3666
3671
|
var FONT_COLORS = [
|
|
3667
3672
|
{ value: null, title: "\u9ED8\u8BA4", swatch: "#1f2329" },
|
|
@@ -3692,25 +3697,25 @@ var BG_COLORS = [
|
|
|
3692
3697
|
{ value: "#7b67ee", title: "\u7D2B", swatch: "#7b67ee" }
|
|
3693
3698
|
];
|
|
3694
3699
|
function tipNode(title, md) {
|
|
3695
|
-
return _preact.h.call(void 0, "div", { class: "
|
|
3696
|
-
_preact.h.call(void 0, "div", { class: "
|
|
3697
|
-
md ? _preact.h.call(void 0, "div", { class: "
|
|
3700
|
+
return _preact.h.call(void 0, "div", { class: "markloom-bubble-tip", key: "tip" }, [
|
|
3701
|
+
_preact.h.call(void 0, "div", { class: "markloom-bubble-tip-t", key: "t" }, title),
|
|
3702
|
+
md ? _preact.h.call(void 0, "div", { class: "markloom-bubble-tip-md", key: "m" }, `Markdown: ${md}`) : null
|
|
3698
3703
|
]);
|
|
3699
3704
|
}
|
|
3700
3705
|
function blockIco(name, size2 = 18) {
|
|
3701
3706
|
if (name === "h1" || name === "h2" || name === "h3")
|
|
3702
|
-
return _preact.h.call(void 0, "span", { class: "
|
|
3707
|
+
return _preact.h.call(void 0, "span", { class: "markloom-bb-hico" }, [_preact.h.call(void 0, "span", {}, "H"), _preact.h.call(void 0, "sub", {}, name[1])]);
|
|
3703
3708
|
return icon(name, size2);
|
|
3704
3709
|
}
|
|
3705
3710
|
function currentBlockKind(doc, sel) {
|
|
3706
3711
|
const block = doc.children[sel.head.path[0]];
|
|
3707
|
-
if (!block ||
|
|
3712
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
3708
3713
|
return "paragraph";
|
|
3709
3714
|
if (block.type === "heading")
|
|
3710
3715
|
return `heading${Number(_nullishCoalesce(_optionalChain([block, 'access', _112 => _112.attrs, 'optionalAccess', _113 => _113.depth]), () => ( 1)))}`;
|
|
3711
3716
|
if (block.type === "list") {
|
|
3712
3717
|
const item = block.children[0];
|
|
3713
|
-
if (item && !
|
|
3718
|
+
if (item && !_chunkGQ2HHRGIcjs.isText.call(void 0, item) && item.attrs && "checked" in item.attrs)
|
|
3714
3719
|
return "task";
|
|
3715
3720
|
return _optionalChain([block, 'access', _114 => _114.attrs, 'optionalAccess', _115 => _115.ordered]) ? "ordered" : "bullet";
|
|
3716
3721
|
}
|
|
@@ -3736,7 +3741,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
3736
3741
|
this.root = root;
|
|
3737
3742
|
this.host = host;
|
|
3738
3743
|
this.overlay = document.createElement("div");
|
|
3739
|
-
this.overlay.className = "
|
|
3744
|
+
this.overlay.className = "markloom-bubble-overlay";
|
|
3740
3745
|
document.body.appendChild(this.overlay);
|
|
3741
3746
|
document.addEventListener("selectionchange", this.onSelChange);
|
|
3742
3747
|
document.addEventListener("pointerdown", this.onPointerDown, true);
|
|
@@ -3856,7 +3861,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
3856
3861
|
].join("|");
|
|
3857
3862
|
}
|
|
3858
3863
|
moveBubble(rect) {
|
|
3859
|
-
const el = this.overlay.querySelector(".
|
|
3864
|
+
const el = this.overlay.querySelector(".markloom-bubble");
|
|
3860
3865
|
if (!el)
|
|
3861
3866
|
return;
|
|
3862
3867
|
this.lastRect = rect;
|
|
@@ -3931,16 +3936,16 @@ var BubbleMenu = (_class2 = class {
|
|
|
3931
3936
|
}, SHOW_MS);
|
|
3932
3937
|
}}
|
|
3933
3938
|
activeMarks(sel) {
|
|
3934
|
-
const leaf =
|
|
3935
|
-
return new Set(
|
|
3939
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), sel.head.path.slice(0, -1));
|
|
3940
|
+
return new Set(_chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? (_nullishCoalesce(leaf.marks, () => ( []))).map((m) => m.name) : []);
|
|
3936
3941
|
}
|
|
3937
3942
|
activeAlign(sel) {
|
|
3938
3943
|
const block = this.host.doc().children[sel.head.path[0]];
|
|
3939
|
-
return !block ||
|
|
3944
|
+
return !block || _chunkGQ2HHRGIcjs.isText.call(void 0, block) ? "left" : _nullishCoalesce(_optionalChain([block, 'access', _116 => _116.attrs, 'optionalAccess', _117 => _117.align]), () => ( "left"));
|
|
3940
3945
|
}
|
|
3941
3946
|
styleAttrs(sel) {
|
|
3942
|
-
const leaf =
|
|
3943
|
-
if (!
|
|
3947
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), sel.head.path.slice(0, -1));
|
|
3948
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
3944
3949
|
return null;
|
|
3945
3950
|
const m = (_nullishCoalesce(leaf.marks, () => ( []))).find((x) => x.name === "textStyle");
|
|
3946
3951
|
return _nullishCoalesce(_optionalChain([m, 'optionalAccess', _118 => _118.attrs]), () => ( null));
|
|
@@ -3959,7 +3964,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
3959
3964
|
return;
|
|
3960
3965
|
const idx = sel.head.path[0];
|
|
3961
3966
|
const block = this.host.doc().children[idx];
|
|
3962
|
-
if (!block ||
|
|
3967
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
3963
3968
|
return;
|
|
3964
3969
|
const r = blockTransform(block, idx, kind, nid);
|
|
3965
3970
|
this.menu = null;
|
|
@@ -3968,7 +3973,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
3968
3973
|
hoverWrap(id, trigger, panel) {
|
|
3969
3974
|
return _preact.h.call(void 0, "div", {
|
|
3970
3975
|
key: id,
|
|
3971
|
-
class: "
|
|
3976
|
+
class: "markloom-bb-dd-wrap" + (this.menu === id ? " is-open" : ""),
|
|
3972
3977
|
"data-menu-wrap": id,
|
|
3973
3978
|
onMouseEnter: () => this.scheduleOpenMenu(id),
|
|
3974
3979
|
onMouseLeave: () => this.scheduleCloseMenu()
|
|
@@ -3985,22 +3990,22 @@ var BubbleMenu = (_class2 = class {
|
|
|
3985
3990
|
const curBg = this.activeBg(sel);
|
|
3986
3991
|
const colorSwatch = _nullishCoalesce(curColor, () => ( "#1f2329"));
|
|
3987
3992
|
const hasStyle = !!(curColor || curBg || active2.has("highlight"));
|
|
3988
|
-
const sep = (k) => _preact.h.call(void 0, "span", { key: k, class: "
|
|
3993
|
+
const sep = (k) => _preact.h.call(void 0, "span", { key: k, class: "markloom-bubble-sep" });
|
|
3989
3994
|
const blockBtn = _preact.h.call(void 0, "button", {
|
|
3990
3995
|
"key": "block",
|
|
3991
3996
|
"type": "button",
|
|
3992
|
-
"class": "
|
|
3997
|
+
"class": "markloom-bb-dd" + (this.menu === "block" ? " is-open" : ""),
|
|
3993
3998
|
"data-menu": "block",
|
|
3994
3999
|
"title": "\u6B63\u6587\u4E0E\u6807\u9898",
|
|
3995
4000
|
"onMouseDown": (e) => e.preventDefault()
|
|
3996
4001
|
}, [
|
|
3997
|
-
_preact.h.call(void 0, "span", { class: "
|
|
3998
|
-
icon("chevron-down", 12, "
|
|
4002
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-t", key: "t" }, "T"),
|
|
4003
|
+
icon("chevron-down", 12, "markloom-bb-chev"),
|
|
3999
4004
|
tipNode("\u6B63\u6587\u4E0E\u6807\u9898")
|
|
4000
4005
|
]);
|
|
4001
4006
|
const blockMenu = _preact.h.call(void 0, "div", {
|
|
4002
4007
|
key: "block-menu",
|
|
4003
|
-
class: "
|
|
4008
|
+
class: "markloom-bb-menu" + (this.menu === "block" ? " is-open" : ""),
|
|
4004
4009
|
"data-panel": "block"
|
|
4005
4010
|
}, (() => {
|
|
4006
4011
|
const rows = [];
|
|
@@ -4008,22 +4013,22 @@ var BubbleMenu = (_class2 = class {
|
|
|
4008
4013
|
for (const it of BLOCK_ITEMS) {
|
|
4009
4014
|
const g = _nullishCoalesce(it.group, () => ( "fmt"));
|
|
4010
4015
|
if (lastGroup && lastGroup !== g)
|
|
4011
|
-
rows.push(_preact.h.call(void 0, "div", { key: `sep-${g}`, class: "
|
|
4016
|
+
rows.push(_preact.h.call(void 0, "div", { key: `sep-${g}`, class: "markloom-bb-menu-sep" }));
|
|
4012
4017
|
lastGroup = g;
|
|
4013
4018
|
const on = curBlock === it.kind;
|
|
4014
4019
|
rows.push(_preact.h.call(void 0, "button", {
|
|
4015
4020
|
key: it.kind,
|
|
4016
4021
|
type: "button",
|
|
4017
|
-
class: "
|
|
4022
|
+
class: "markloom-bb-menu-item" + (on ? " is-on" : ""),
|
|
4018
4023
|
"data-block": it.kind,
|
|
4019
4024
|
onMouseDown: (e) => {
|
|
4020
4025
|
e.preventDefault();
|
|
4021
4026
|
this.applyBlock(it.kind);
|
|
4022
4027
|
}
|
|
4023
4028
|
}, [
|
|
4024
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4025
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4026
|
-
on ? _preact.h.call(void 0, "span", { class: "
|
|
4029
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-ico", key: "i" }, blockIco(it.ico, 18)),
|
|
4030
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-lab", key: "l" }, it.label),
|
|
4031
|
+
on ? _preact.h.call(void 0, "span", { class: "markloom-bb-menu-check", key: "c" }, icon("check", 16)) : _preact.h.call(void 0, "span", { key: "c" })
|
|
4027
4032
|
]));
|
|
4028
4033
|
}
|
|
4029
4034
|
return rows;
|
|
@@ -4031,18 +4036,18 @@ var BubbleMenu = (_class2 = class {
|
|
|
4031
4036
|
const alignBtn = _preact.h.call(void 0, "button", {
|
|
4032
4037
|
"key": "align",
|
|
4033
4038
|
"type": "button",
|
|
4034
|
-
"class": "
|
|
4039
|
+
"class": "markloom-bb-dd" + (this.menu === "align" ? " is-open" : ""),
|
|
4035
4040
|
"data-menu": "align",
|
|
4036
4041
|
"title": "\u5BF9\u9F50\u4E0E\u7F29\u8FDB",
|
|
4037
4042
|
"onMouseDown": (e) => e.preventDefault()
|
|
4038
4043
|
}, [
|
|
4039
4044
|
icon("text-align", 16),
|
|
4040
|
-
icon("chevron-down", 12, "
|
|
4045
|
+
icon("chevron-down", 12, "markloom-bb-chev"),
|
|
4041
4046
|
tipNode("\u5BF9\u9F50\u4E0E\u7F29\u8FDB")
|
|
4042
4047
|
]);
|
|
4043
4048
|
const alignMenu = _preact.h.call(void 0, "div", {
|
|
4044
4049
|
key: "align-menu",
|
|
4045
|
-
class: "
|
|
4050
|
+
class: "markloom-bb-menu" + (this.menu === "align" ? " is-open" : ""),
|
|
4046
4051
|
"data-panel": "align"
|
|
4047
4052
|
}, [
|
|
4048
4053
|
...[
|
|
@@ -4052,7 +4057,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4052
4057
|
].map((a) => _preact.h.call(void 0, "button", {
|
|
4053
4058
|
key: a.value,
|
|
4054
4059
|
type: "button",
|
|
4055
|
-
class: "
|
|
4060
|
+
class: "markloom-bb-menu-item" + (curAlign === a.value ? " is-on" : ""),
|
|
4056
4061
|
"data-align": a.value,
|
|
4057
4062
|
onMouseDown: (e) => {
|
|
4058
4063
|
e.preventDefault();
|
|
@@ -4067,15 +4072,15 @@ var BubbleMenu = (_class2 = class {
|
|
|
4067
4072
|
this.paint(this.lastRect, this.lastSel, true);
|
|
4068
4073
|
}
|
|
4069
4074
|
}, [
|
|
4070
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4071
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4072
|
-
curAlign === a.value ? _preact.h.call(void 0, "span", { class: "
|
|
4075
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-ico", key: "i" }, icon(a.ico, 18)),
|
|
4076
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-lab", key: "l" }, a.title),
|
|
4077
|
+
curAlign === a.value ? _preact.h.call(void 0, "span", { class: "markloom-bb-menu-check", key: "c" }, icon("check", 16)) : _preact.h.call(void 0, "span", { key: "c" })
|
|
4073
4078
|
])),
|
|
4074
|
-
_preact.h.call(void 0, "div", { key: "sep-ind", class: "
|
|
4079
|
+
_preact.h.call(void 0, "div", { key: "sep-ind", class: "markloom-bb-menu-sep" }),
|
|
4075
4080
|
_preact.h.call(void 0, "button", {
|
|
4076
4081
|
key: "indent",
|
|
4077
4082
|
type: "button",
|
|
4078
|
-
class: "
|
|
4083
|
+
class: "markloom-bb-menu-item",
|
|
4079
4084
|
"data-indent": "in",
|
|
4080
4085
|
onMouseDown: (e) => {
|
|
4081
4086
|
e.preventDefault();
|
|
@@ -4088,13 +4093,13 @@ var BubbleMenu = (_class2 = class {
|
|
|
4088
4093
|
this.menu = null;
|
|
4089
4094
|
}
|
|
4090
4095
|
}, [
|
|
4091
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4092
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4096
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-ico", key: "i" }, icon("indent-increase", 18)),
|
|
4097
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-lab", key: "l" }, "\u589E\u52A0\u7F29\u8FDB")
|
|
4093
4098
|
]),
|
|
4094
4099
|
_preact.h.call(void 0, "button", {
|
|
4095
4100
|
key: "outdent",
|
|
4096
4101
|
type: "button",
|
|
4097
|
-
class: "
|
|
4102
|
+
class: "markloom-bb-menu-item",
|
|
4098
4103
|
"data-indent": "out",
|
|
4099
4104
|
onMouseDown: (e) => {
|
|
4100
4105
|
e.preventDefault();
|
|
@@ -4107,14 +4112,14 @@ var BubbleMenu = (_class2 = class {
|
|
|
4107
4112
|
this.menu = null;
|
|
4108
4113
|
}
|
|
4109
4114
|
}, [
|
|
4110
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4111
|
-
_preact.h.call(void 0, "span", { class: "
|
|
4115
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-ico", key: "i" }, icon("indent-decrease", 18)),
|
|
4116
|
+
_preact.h.call(void 0, "span", { class: "markloom-bb-menu-lab", key: "l" }, "\u51CF\u5C11\u7F29\u8FDB")
|
|
4112
4117
|
])
|
|
4113
4118
|
]);
|
|
4114
4119
|
const markBtns = MARK_ITEMS.map((it) => _preact.h.call(void 0, "button", {
|
|
4115
4120
|
"key": it.name,
|
|
4116
4121
|
"type": "button",
|
|
4117
|
-
"class": `
|
|
4122
|
+
"class": `markloom-bb-mark ${_nullishCoalesce(it.cls, () => ( ""))}`,
|
|
4118
4123
|
"title": it.tip,
|
|
4119
4124
|
"data-active": active2.has(it.name) ? "" : void 0,
|
|
4120
4125
|
"data-mark": it.name,
|
|
@@ -4190,7 +4195,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4190
4195
|
const colorBtn = _preact.h.call(void 0, "button", {
|
|
4191
4196
|
"key": "color",
|
|
4192
4197
|
"type": "button",
|
|
4193
|
-
"class": "
|
|
4198
|
+
"class": "markloom-bb-color" + (this.menu === "color" ? " is-open" : "") + (curBg || active2.has("highlight") ? " has-hl" : ""),
|
|
4194
4199
|
"data-menu": "color",
|
|
4195
4200
|
"data-active": hasStyle ? "" : void 0,
|
|
4196
4201
|
"title": "\u6587\u5B57\u989C\u8272\u4E0E\u9AD8\u4EAE",
|
|
@@ -4198,27 +4203,27 @@ var BubbleMenu = (_class2 = class {
|
|
|
4198
4203
|
}, [
|
|
4199
4204
|
_preact.h.call(void 0, "span", {
|
|
4200
4205
|
key: "a",
|
|
4201
|
-
class: "
|
|
4206
|
+
class: "markloom-bb-a",
|
|
4202
4207
|
style: {
|
|
4203
4208
|
color: colorSwatch,
|
|
4204
4209
|
background: _nullishCoalesce(curBg, () => ( (active2.has("highlight") ? "#faf1d1" : "transparent")))
|
|
4205
4210
|
}
|
|
4206
4211
|
}, "A"),
|
|
4207
|
-
icon("chevron-down", 12, "
|
|
4212
|
+
icon("chevron-down", 12, "markloom-bb-chev"),
|
|
4208
4213
|
tipNode("\u6587\u5B57\u989C\u8272\u4E0E\u9AD8\u4EAE")
|
|
4209
4214
|
]);
|
|
4210
4215
|
const colorMenu = _preact.h.call(void 0, "div", {
|
|
4211
4216
|
key: "color-menu",
|
|
4212
|
-
class: "
|
|
4217
|
+
class: "markloom-bb-menu markloom-bb-menu-color" + (this.menu === "color" ? " is-open" : ""),
|
|
4213
4218
|
"data-panel": "color"
|
|
4214
4219
|
}, [
|
|
4215
|
-
_preact.h.call(void 0, "div", { class: "
|
|
4216
|
-
_preact.h.call(void 0, "div", { class: "
|
|
4220
|
+
_preact.h.call(void 0, "div", { class: "markloom-bb-color-sec", key: "ct" }, "\u5B57\u4F53\u989C\u8272"),
|
|
4221
|
+
_preact.h.call(void 0, "div", { class: "markloom-bb-swatches markloom-bb-font-row", key: "cs" }, FONT_COLORS.map((c) => {
|
|
4217
4222
|
const on = c.value === null ? !curColor : curColor === c.value;
|
|
4218
4223
|
return _preact.h.call(void 0, "button", {
|
|
4219
4224
|
key: c.title,
|
|
4220
4225
|
type: "button",
|
|
4221
|
-
class: "
|
|
4226
|
+
class: "markloom-bb-font-a" + (on ? " is-on" : ""),
|
|
4222
4227
|
title: c.title,
|
|
4223
4228
|
style: { color: c.swatch },
|
|
4224
4229
|
onMouseDown: (e) => {
|
|
@@ -4232,13 +4237,13 @@ var BubbleMenu = (_class2 = class {
|
|
|
4232
4237
|
}
|
|
4233
4238
|
}, "A");
|
|
4234
4239
|
})),
|
|
4235
|
-
_preact.h.call(void 0, "div", { class: "
|
|
4236
|
-
_preact.h.call(void 0, "div", { class: "
|
|
4240
|
+
_preact.h.call(void 0, "div", { class: "markloom-bb-color-sec", key: "ht" }, "\u80CC\u666F\u989C\u8272"),
|
|
4241
|
+
_preact.h.call(void 0, "div", { class: "markloom-bb-swatches markloom-bb-bg-row", key: "hs" }, BG_COLORS.map((c) => {
|
|
4237
4242
|
const on = c.value === null ? !curBg && !active2.has("highlight") : curBg === c.value;
|
|
4238
4243
|
return _preact.h.call(void 0, "button", {
|
|
4239
4244
|
key: c.title,
|
|
4240
4245
|
type: "button",
|
|
4241
|
-
class: "
|
|
4246
|
+
class: "markloom-bb-swatch" + (c.none ? " markloom-bb-swatch-none" : "") + (on ? " is-on" : ""),
|
|
4242
4247
|
"data-edge": c.edge ? "" : void 0,
|
|
4243
4248
|
title: c.title,
|
|
4244
4249
|
style: c.none ? void 0 : { background: c.swatch },
|
|
@@ -4264,7 +4269,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4264
4269
|
_preact.h.call(void 0, "button", {
|
|
4265
4270
|
key: "reset",
|
|
4266
4271
|
type: "button",
|
|
4267
|
-
class: "
|
|
4272
|
+
class: "markloom-bb-reset",
|
|
4268
4273
|
onMouseDown: (e) => {
|
|
4269
4274
|
e.preventDefault();
|
|
4270
4275
|
const cur = this.host.markSel();
|
|
@@ -4287,25 +4292,25 @@ var BubbleMenu = (_class2 = class {
|
|
|
4287
4292
|
const aiContinueBtn = this.host.openAi ? _preact.h.call(void 0, "button", {
|
|
4288
4293
|
"key": "ai-continue",
|
|
4289
4294
|
"type": "button",
|
|
4290
|
-
"class": "
|
|
4295
|
+
"class": "markloom-bb-ai",
|
|
4291
4296
|
"data-ai": "continue",
|
|
4292
4297
|
"title": "AI \u7EED\u5199",
|
|
4293
4298
|
"onMouseDown": (e) => {
|
|
4294
4299
|
e.preventDefault();
|
|
4295
4300
|
_optionalChain([this, 'access', _131 => _131.host, 'access', _132 => _132.openAi, 'optionalCall', _133 => _133("continue")]);
|
|
4296
4301
|
}
|
|
4297
|
-
}, [icon("sparkles", 16), _preact.h.call(void 0, "span", { class: "
|
|
4302
|
+
}, [icon("sparkles", 16), _preact.h.call(void 0, "span", { class: "markloom-bb-ai-lab", key: "l" }, "\u7EED\u5199"), tipNode("AI \u7EED\u5199")]) : null;
|
|
4298
4303
|
const aiRewriteBtn = this.host.openAi ? _preact.h.call(void 0, "button", {
|
|
4299
4304
|
"key": "ai-rewrite",
|
|
4300
4305
|
"type": "button",
|
|
4301
|
-
"class": "
|
|
4306
|
+
"class": "markloom-bb-ai",
|
|
4302
4307
|
"data-ai": "rewrite",
|
|
4303
4308
|
"title": "AI \u6539\u5199",
|
|
4304
4309
|
"onMouseDown": (e) => {
|
|
4305
4310
|
e.preventDefault();
|
|
4306
4311
|
_optionalChain([this, 'access', _134 => _134.host, 'access', _135 => _135.openAi, 'optionalCall', _136 => _136("rewrite")]);
|
|
4307
4312
|
}
|
|
4308
|
-
}, [icon("pen-line", 16), _preact.h.call(void 0, "span", { class: "
|
|
4313
|
+
}, [icon("pen-line", 16), _preact.h.call(void 0, "span", { class: "markloom-bb-ai-lab", key: "l" }, "\u6539\u5199"), tipNode("AI \u6539\u5199")]) : null;
|
|
4309
4314
|
const commentBtn = this.host.beginComment ? _preact.h.call(void 0, "button", {
|
|
4310
4315
|
"key": "comment",
|
|
4311
4316
|
"type": "button",
|
|
@@ -4318,9 +4323,9 @@ var BubbleMenu = (_class2 = class {
|
|
|
4318
4323
|
}, [icon("message-circle", 16), tipNode("\u8BC4\u8BBA")]) : null;
|
|
4319
4324
|
_preact.render.call(void 0,
|
|
4320
4325
|
_preact.h.call(void 0, "div", {
|
|
4321
|
-
class: "
|
|
4326
|
+
class: "markloom-bubble" + (settled ? " is-in" : "")
|
|
4322
4327
|
}, [
|
|
4323
|
-
_preact.h.call(void 0, "div", { class: "
|
|
4328
|
+
_preact.h.call(void 0, "div", { class: "markloom-bb-row", key: "row" }, [
|
|
4324
4329
|
this.hoverWrap("block", blockBtn, blockMenu),
|
|
4325
4330
|
sep("s0"),
|
|
4326
4331
|
this.hoverWrap("align", alignBtn, alignMenu),
|
|
@@ -4336,7 +4341,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4336
4341
|
]),
|
|
4337
4342
|
this.overlay
|
|
4338
4343
|
);
|
|
4339
|
-
const el = this.overlay.querySelector(".
|
|
4344
|
+
const el = this.overlay.querySelector(".markloom-bubble");
|
|
4340
4345
|
if (el) {
|
|
4341
4346
|
if (settled)
|
|
4342
4347
|
el.classList.add("is-in");
|
|
@@ -4409,7 +4414,7 @@ var CodeControls = (_class3 = class {
|
|
|
4409
4414
|
return;
|
|
4410
4415
|
}
|
|
4411
4416
|
this.menu = document.createElement("div");
|
|
4412
|
-
this.menu.className = "
|
|
4417
|
+
this.menu.className = "markloom-code-lang-menu";
|
|
4413
4418
|
this.menu.style.cssText = "position:fixed;z-index:1000";
|
|
4414
4419
|
for (const opt of ["\u7EAF\u6587\u672C", ...this.host.langs()]) {
|
|
4415
4420
|
const item = document.createElement("button");
|
|
@@ -4419,11 +4424,11 @@ var CodeControls = (_class3 = class {
|
|
|
4419
4424
|
ev.preventDefault();
|
|
4420
4425
|
ev.stopPropagation();
|
|
4421
4426
|
const doc = this.host.doc();
|
|
4422
|
-
const path =
|
|
4427
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, blockId);
|
|
4423
4428
|
if (path) {
|
|
4424
|
-
const node =
|
|
4429
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
4425
4430
|
const attrs = { ...node.attrs, lang: opt === "\u7EAF\u6587\u672C" ? void 0 : opt };
|
|
4426
|
-
this.host.dispatch([
|
|
4431
|
+
this.host.dispatch([_chunk4TMHVNL6cjs.rewriteNode.call(void 0, doc, blockId, { ...node, attrs })]);
|
|
4427
4432
|
}
|
|
4428
4433
|
this.closeMenu();
|
|
4429
4434
|
});
|
|
@@ -4481,7 +4486,7 @@ var DragHandle = (_class4 = class {
|
|
|
4481
4486
|
this.root = root;
|
|
4482
4487
|
this.host = host;
|
|
4483
4488
|
this.overlay = document.createElement("div");
|
|
4484
|
-
this.overlay.className = "
|
|
4489
|
+
this.overlay.className = "markloom-drag-overlay";
|
|
4485
4490
|
document.body.appendChild(this.overlay);
|
|
4486
4491
|
document.addEventListener("mousemove", this.onHover);
|
|
4487
4492
|
window.addEventListener("scroll", this.onLeave, true);
|
|
@@ -4495,7 +4500,7 @@ var DragHandle = (_class4 = class {
|
|
|
4495
4500
|
this.overlay.remove();
|
|
4496
4501
|
}
|
|
4497
4502
|
blocks() {
|
|
4498
|
-
return
|
|
4503
|
+
return _chunkSLRD6FMPcjs.elementChildren.call(void 0, _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root));
|
|
4499
4504
|
}
|
|
4500
4505
|
clearLeave() {
|
|
4501
4506
|
if (this.leaveTimer != null) {
|
|
@@ -4592,7 +4597,7 @@ var DragHandle = (_class4 = class {
|
|
|
4592
4597
|
document.removeEventListener("mousemove", move);
|
|
4593
4598
|
document.removeEventListener("mouseup", up);
|
|
4594
4599
|
if (active2 && this.drag) {
|
|
4595
|
-
const steps =
|
|
4600
|
+
const steps = _chunk4TMHVNL6cjs.moveBlock.call(void 0, this.host.doc(), fromIdx, this.drag.gap);
|
|
4596
4601
|
if (steps.length)
|
|
4597
4602
|
this.host.dispatch(steps);
|
|
4598
4603
|
}
|
|
@@ -4606,7 +4611,7 @@ var DragHandle = (_class4 = class {
|
|
|
4606
4611
|
}
|
|
4607
4612
|
toggleFold(blockIdx) {
|
|
4608
4613
|
const node = this.host.doc().children[blockIdx];
|
|
4609
|
-
if (!node ||
|
|
4614
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "heading")
|
|
4610
4615
|
return;
|
|
4611
4616
|
this.host.dispatch([{
|
|
4612
4617
|
kind: "replaceNode",
|
|
@@ -4617,7 +4622,7 @@ var DragHandle = (_class4 = class {
|
|
|
4617
4622
|
/** 整块文本选区(paragraph/heading 顶层叶),供手柄菜单套 mark */
|
|
4618
4623
|
blockSel(blockIdx) {
|
|
4619
4624
|
const block = this.host.doc().children[blockIdx];
|
|
4620
|
-
if (!block ||
|
|
4625
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4621
4626
|
return null;
|
|
4622
4627
|
if (block.type !== "paragraph" && block.type !== "heading" && block.type !== "code")
|
|
4623
4628
|
return null;
|
|
@@ -4626,7 +4631,7 @@ var DragHandle = (_class4 = class {
|
|
|
4626
4631
|
let lastLen = 0;
|
|
4627
4632
|
for (let i = 0; i < block.children.length; i++) {
|
|
4628
4633
|
const c = block.children[i];
|
|
4629
|
-
if (
|
|
4634
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c)) {
|
|
4630
4635
|
if (first < 0)
|
|
4631
4636
|
first = i;
|
|
4632
4637
|
last = i;
|
|
@@ -4645,7 +4650,7 @@ var DragHandle = (_class4 = class {
|
|
|
4645
4650
|
if (idx < 0)
|
|
4646
4651
|
return;
|
|
4647
4652
|
const block = this.host.doc().children[idx];
|
|
4648
|
-
if (!block ||
|
|
4653
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4649
4654
|
return;
|
|
4650
4655
|
const r = blockTransform(block, idx, kind, newId);
|
|
4651
4656
|
this.host.dispatch(r.steps, r.selection);
|
|
@@ -4684,12 +4689,12 @@ var DragHandle = (_class4 = class {
|
|
|
4684
4689
|
dropLine() {
|
|
4685
4690
|
if (!this.drag)
|
|
4686
4691
|
return null;
|
|
4687
|
-
const docEl =
|
|
4692
|
+
const docEl = _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root);
|
|
4688
4693
|
const blocks = this.blocks();
|
|
4689
4694
|
const gap = this.drag.gap;
|
|
4690
4695
|
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access', _164 => _164[0], 'optionalAccess', _165 => _165.getBoundingClientRect, 'call', _166 => _166(), 'access', _167 => _167.top]), () => ( 0)) : _nullishCoalesce(_optionalChain([blocks, 'access', _168 => _168[gap - 1], 'optionalAccess', _169 => _169.getBoundingClientRect, 'call', _170 => _170(), 'access', _171 => _171.bottom]), () => ( 0));
|
|
4691
4696
|
const box = docEl.getBoundingClientRect();
|
|
4692
|
-
return _preact.h.call(void 0, "div", { key: "drop", class: "
|
|
4697
|
+
return _preact.h.call(void 0, "div", { key: "drop", class: "markloom-drag-drop", style: `top:${y}px;left:${box.left}px;width:${box.width}px` });
|
|
4693
4698
|
}
|
|
4694
4699
|
gripSvg() {
|
|
4695
4700
|
return _preact.h.call(void 0, "svg", {
|
|
@@ -4721,13 +4726,13 @@ var DragHandle = (_class4 = class {
|
|
|
4721
4726
|
paintMenu() {
|
|
4722
4727
|
const idx = this.hoverIdx;
|
|
4723
4728
|
const block = this.host.doc().children[idx];
|
|
4724
|
-
if (!block ||
|
|
4729
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4725
4730
|
return null;
|
|
4726
4731
|
const kind = this.currentKind(block);
|
|
4727
4732
|
const typeRow = TYPE_ITEMS.map((it) => _preact.h.call(void 0, "button", {
|
|
4728
4733
|
key: it.kind,
|
|
4729
4734
|
type: "button",
|
|
4730
|
-
class: "
|
|
4735
|
+
class: "markloom-block-menu-btn" + (kind === it.kind ? " is-on" : ""),
|
|
4731
4736
|
title: it.title,
|
|
4732
4737
|
"data-block-kind": it.kind,
|
|
4733
4738
|
onMouseDown: (e) => {
|
|
@@ -4739,7 +4744,7 @@ var DragHandle = (_class4 = class {
|
|
|
4739
4744
|
const markRow = MARK_ITEMS2.map((it) => _preact.h.call(void 0, "button", {
|
|
4740
4745
|
key: it.name,
|
|
4741
4746
|
type: "button",
|
|
4742
|
-
class: "
|
|
4747
|
+
class: "markloom-block-menu-btn markloom-block-menu-mark",
|
|
4743
4748
|
title: it.title,
|
|
4744
4749
|
"data-mark": it.name,
|
|
4745
4750
|
onMouseDown: (e) => {
|
|
@@ -4751,7 +4756,7 @@ var DragHandle = (_class4 = class {
|
|
|
4751
4756
|
const colorRow = COLORS.map((c, i) => _preact.h.call(void 0, "button", {
|
|
4752
4757
|
key: `c${i}`,
|
|
4753
4758
|
type: "button",
|
|
4754
|
-
class: "
|
|
4759
|
+
class: "markloom-block-menu-swatch",
|
|
4755
4760
|
title: c.title,
|
|
4756
4761
|
style: `background:${c.swatch}`,
|
|
4757
4762
|
onMouseDown: (e) => {
|
|
@@ -4767,7 +4772,7 @@ var DragHandle = (_class4 = class {
|
|
|
4767
4772
|
].map((a) => _preact.h.call(void 0, "button", {
|
|
4768
4773
|
key: a.v,
|
|
4769
4774
|
type: "button",
|
|
4770
|
-
class: "
|
|
4775
|
+
class: "markloom-block-menu-btn",
|
|
4771
4776
|
title: a.title,
|
|
4772
4777
|
"data-align": a.v,
|
|
4773
4778
|
onMouseDown: (e) => {
|
|
@@ -4778,16 +4783,16 @@ var DragHandle = (_class4 = class {
|
|
|
4778
4783
|
}, icon(a.ico, 14)));
|
|
4779
4784
|
return _preact.h.call(void 0, "div", {
|
|
4780
4785
|
key: "menu",
|
|
4781
|
-
class: "
|
|
4786
|
+
class: "markloom-block-menu",
|
|
4782
4787
|
onMouseEnter: this.keepMenu,
|
|
4783
4788
|
onMouseLeave: this.scheduleCloseMenu
|
|
4784
4789
|
}, [
|
|
4785
|
-
_preact.h.call(void 0, "div", { key: "types", class: "
|
|
4786
|
-
_preact.h.call(void 0, "div", { key: "sep1", class: "
|
|
4787
|
-
_preact.h.call(void 0, "div", { key: "marks", class: "
|
|
4788
|
-
_preact.h.call(void 0, "div", { key: "colors", class: "
|
|
4789
|
-
_preact.h.call(void 0, "div", { key: "sep2", class: "
|
|
4790
|
-
_preact.h.call(void 0, "div", { key: "align", class: "
|
|
4790
|
+
_preact.h.call(void 0, "div", { key: "types", class: "markloom-block-menu-row" }, typeRow),
|
|
4791
|
+
_preact.h.call(void 0, "div", { key: "sep1", class: "markloom-block-menu-sep" }),
|
|
4792
|
+
_preact.h.call(void 0, "div", { key: "marks", class: "markloom-block-menu-row" }, markRow),
|
|
4793
|
+
_preact.h.call(void 0, "div", { key: "colors", class: "markloom-block-menu-row markloom-block-menu-colors" }, colorRow),
|
|
4794
|
+
_preact.h.call(void 0, "div", { key: "sep2", class: "markloom-block-menu-sep" }),
|
|
4795
|
+
_preact.h.call(void 0, "div", { key: "align", class: "markloom-block-menu-row" }, alignRow)
|
|
4791
4796
|
]);
|
|
4792
4797
|
}
|
|
4793
4798
|
paint() {
|
|
@@ -4802,7 +4807,7 @@ var DragHandle = (_class4 = class {
|
|
|
4802
4807
|
if (el) {
|
|
4803
4808
|
const r = el.getBoundingClientRect();
|
|
4804
4809
|
const depth = el.getAttribute("data-heading-depth");
|
|
4805
|
-
const isHeading = el.classList.contains("
|
|
4810
|
+
const isHeading = el.classList.contains("markloom-heading") && !!depth;
|
|
4806
4811
|
const collapsed = el.getAttribute("data-collapsed") === "true";
|
|
4807
4812
|
const BAR_H = 22;
|
|
4808
4813
|
const cs = getComputedStyle(el);
|
|
@@ -4814,7 +4819,7 @@ var DragHandle = (_class4 = class {
|
|
|
4814
4819
|
const barRight = r.left - 4;
|
|
4815
4820
|
children.push(_preact.h.call(void 0, "div", {
|
|
4816
4821
|
key: "hit",
|
|
4817
|
-
class: "
|
|
4822
|
+
class: "markloom-drag-hit",
|
|
4818
4823
|
style: `top:${r.top}px;left:${r.left - GUTTER}px;width:${GUTTER}px;height:${hitH}px`
|
|
4819
4824
|
}));
|
|
4820
4825
|
const dragDown = (e) => {
|
|
@@ -4827,7 +4832,7 @@ var DragHandle = (_class4 = class {
|
|
|
4827
4832
|
items.push(_preact.h.call(void 0, "button", {
|
|
4828
4833
|
key: "kind",
|
|
4829
4834
|
type: "button",
|
|
4830
|
-
class: "
|
|
4835
|
+
class: "markloom-block-kind" + (kindOn ? " is-on" : ""),
|
|
4831
4836
|
title: "\u62D6\u62FD\u79FB\u52A8 \xB7 \u60AC\u505C\u683C\u5F0F",
|
|
4832
4837
|
onMouseDown: dragDown,
|
|
4833
4838
|
onMouseEnter: this.keepMenu
|
|
@@ -4836,7 +4841,7 @@ var DragHandle = (_class4 = class {
|
|
|
4836
4841
|
items.push(_preact.h.call(void 0, "button", {
|
|
4837
4842
|
key: "add",
|
|
4838
4843
|
type: "button",
|
|
4839
|
-
class: "
|
|
4844
|
+
class: "markloom-add-handle",
|
|
4840
4845
|
title: "\u63D2\u5165\u5185\u5BB9",
|
|
4841
4846
|
onMouseDown: (e) => {
|
|
4842
4847
|
e.preventDefault();
|
|
@@ -4852,7 +4857,7 @@ var DragHandle = (_class4 = class {
|
|
|
4852
4857
|
items.push(_preact.h.call(void 0, "button", {
|
|
4853
4858
|
key: "handle",
|
|
4854
4859
|
type: "button",
|
|
4855
|
-
class: "
|
|
4860
|
+
class: "markloom-drag-handle",
|
|
4856
4861
|
title: "\u62D6\u62FD\u79FB\u52A8 \xB7 \u60AC\u505C\u683C\u5F0F",
|
|
4857
4862
|
onMouseDown: dragDown,
|
|
4858
4863
|
onMouseEnter: this.keepMenu
|
|
@@ -4861,7 +4866,7 @@ var DragHandle = (_class4 = class {
|
|
|
4861
4866
|
items.push(_preact.h.call(void 0, "button", {
|
|
4862
4867
|
key: "fold",
|
|
4863
4868
|
type: "button",
|
|
4864
|
-
class: "
|
|
4869
|
+
class: "markloom-heading-fold" + (collapsed ? " is-collapsed" : ""),
|
|
4865
4870
|
"data-heading-fold": "",
|
|
4866
4871
|
title: collapsed ? "\u5C55\u5F00" : "\u6298\u53E0",
|
|
4867
4872
|
"aria-expanded": collapsed ? "false" : "true",
|
|
@@ -4875,7 +4880,7 @@ var DragHandle = (_class4 = class {
|
|
|
4875
4880
|
}
|
|
4876
4881
|
children.push(_preact.h.call(void 0, "div", {
|
|
4877
4882
|
key: "bar",
|
|
4878
|
-
class: "
|
|
4883
|
+
class: "markloom-block-bar",
|
|
4879
4884
|
style: `top:${y}px;left:${barRight}px;transform:translateX(-100%)`,
|
|
4880
4885
|
onMouseEnter: this.keepMenu,
|
|
4881
4886
|
onMouseLeave: this.scheduleCloseMenu
|
|
@@ -4889,8 +4894,8 @@ var DragHandle = (_class4 = class {
|
|
|
4889
4894
|
}
|
|
4890
4895
|
_preact.render.call(void 0, _preact.h.call(void 0, "div", null, children), this.overlay);
|
|
4891
4896
|
if (this.menuOpen) {
|
|
4892
|
-
const bar = this.overlay.querySelector(".
|
|
4893
|
-
const menu = this.overlay.querySelector(".
|
|
4897
|
+
const bar = this.overlay.querySelector(".markloom-block-bar");
|
|
4898
|
+
const menu = this.overlay.querySelector(".markloom-block-menu");
|
|
4894
4899
|
if (bar && menu)
|
|
4895
4900
|
void place(bar, menu, { placement: "bottom-end", gap: 4 });
|
|
4896
4901
|
}
|
|
@@ -4941,11 +4946,11 @@ var ICON_PATHS = {
|
|
|
4941
4946
|
};
|
|
4942
4947
|
function iconNode(name) {
|
|
4943
4948
|
if (name === "h1" || name === "h2" || name === "h3")
|
|
4944
|
-
return _preact.h.call(void 0, "span", { class: "
|
|
4949
|
+
return _preact.h.call(void 0, "span", { class: "markloom-slash-icon markloom-slash-htxt" }, [_preact.h.call(void 0, "span", {}, "H"), _preact.h.call(void 0, "sub", {}, name[1])]);
|
|
4945
4950
|
const paths = _nullishCoalesce(ICON_PATHS[name], () => ( []));
|
|
4946
4951
|
return _preact.h.call(void 0,
|
|
4947
4952
|
"svg",
|
|
4948
|
-
{ class: "
|
|
4953
|
+
{ class: "markloom-slash-icon", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "1.8", "stroke-linecap": "round", "stroke-linejoin": "round" },
|
|
4949
4954
|
paths.map((d, i) => _preact.h.call(void 0, "path", { key: i, d }))
|
|
4950
4955
|
);
|
|
4951
4956
|
}
|
|
@@ -4962,14 +4967,14 @@ var SlashMenu = (_class5 = class {
|
|
|
4962
4967
|
this.root = root;
|
|
4963
4968
|
this.host = host;
|
|
4964
4969
|
this.overlay = document.createElement("div");
|
|
4965
|
-
this.overlay.className = "
|
|
4970
|
+
this.overlay.className = "markloom-slash-overlay";
|
|
4966
4971
|
document.body.appendChild(this.overlay);
|
|
4967
|
-
root.addEventListener("
|
|
4972
|
+
root.addEventListener("markloom-redraw", this.reevaluate);
|
|
4968
4973
|
document.addEventListener("selectionchange", this.reevaluate);
|
|
4969
4974
|
root.addEventListener("keydown", this.onKeyDown, true);
|
|
4970
4975
|
}
|
|
4971
4976
|
destroy() {
|
|
4972
|
-
this.root.removeEventListener("
|
|
4977
|
+
this.root.removeEventListener("markloom-redraw", this.reevaluate);
|
|
4973
4978
|
document.removeEventListener("selectionchange", this.reevaluate);
|
|
4974
4979
|
this.root.removeEventListener("keydown", this.onKeyDown, true);
|
|
4975
4980
|
this.close();
|
|
@@ -5008,11 +5013,11 @@ var SlashMenu = (_class5 = class {
|
|
|
5008
5013
|
}
|
|
5009
5014
|
const blockIdx = sel.head.path[0];
|
|
5010
5015
|
const block = this.host.doc().children[blockIdx];
|
|
5011
|
-
if (
|
|
5016
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph") {
|
|
5012
5017
|
this.close();
|
|
5013
5018
|
return;
|
|
5014
5019
|
}
|
|
5015
|
-
const head =
|
|
5020
|
+
const head = _chunkGQ2HHRGIcjs.isText.call(void 0, block.children[0]) ? block.children[0].text : "";
|
|
5016
5021
|
if (head[0] !== "/") {
|
|
5017
5022
|
this.close();
|
|
5018
5023
|
return;
|
|
@@ -5052,7 +5057,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5052
5057
|
apply(item) {
|
|
5053
5058
|
const doc = this.host.doc();
|
|
5054
5059
|
const block = doc.children[this.blockIdx];
|
|
5055
|
-
if (!item ||
|
|
5060
|
+
if (!item || _chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph") {
|
|
5056
5061
|
this.close();
|
|
5057
5062
|
return;
|
|
5058
5063
|
}
|
|
@@ -5085,13 +5090,13 @@ var SlashMenu = (_class5 = class {
|
|
|
5085
5090
|
_optionalChain([this, 'access', _185 => _185.host, 'access', _186 => _186.insertEmbed, 'optionalCall', _187 => _187(blockIdx, item.insert)]);
|
|
5086
5091
|
return;
|
|
5087
5092
|
}
|
|
5088
|
-
const node = item.insert === "table" ?
|
|
5093
|
+
const node = item.insert === "table" ? _chunk4TMHVNL6cjs.makeTable.call(void 0, newId2(), 3, 3) : { type: "raw", id: newId2(), attrs: { mdType: "thematicBreak" }, children: [{ text: "" }] };
|
|
5089
5094
|
this.host.dispatch([{ kind: "replaceNode", path: [blockIdx], node }]);
|
|
5090
5095
|
return;
|
|
5091
5096
|
}
|
|
5092
5097
|
const first = block.children[0];
|
|
5093
|
-
const rest =
|
|
5094
|
-
const head =
|
|
5098
|
+
const rest = _chunkGQ2HHRGIcjs.isText.call(void 0, first) ? first.text.slice(1 + this.query.length) : "";
|
|
5099
|
+
const head = _chunkGQ2HHRGIcjs.isText.call(void 0, first) ? { ...first, text: rest } : { text: rest };
|
|
5095
5100
|
const stripped = { ...block, children: [head, ...block.children.slice(1)] };
|
|
5096
5101
|
const extra = item.kind === "callout" ? { variant: calloutVariantFromQuery(this.query) } : void 0;
|
|
5097
5102
|
const r = blockTransform(stripped, blockIdx, item.kind, newId2, extra);
|
|
@@ -5117,7 +5122,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5117
5122
|
let prev = null;
|
|
5118
5123
|
list.forEach((it, i) => {
|
|
5119
5124
|
if (it.section !== prev) {
|
|
5120
|
-
rows.push(_preact.h.call(void 0, "div", { key: `h-${it.section}`, class: "
|
|
5125
|
+
rows.push(_preact.h.call(void 0, "div", { key: `h-${it.section}`, class: "markloom-slash-section" }, it.section));
|
|
5121
5126
|
prev = it.section;
|
|
5122
5127
|
}
|
|
5123
5128
|
rows.push(_preact.h.call(void 0, "button", {
|
|
@@ -5128,13 +5133,13 @@ var SlashMenu = (_class5 = class {
|
|
|
5128
5133
|
e.preventDefault();
|
|
5129
5134
|
this.apply(it);
|
|
5130
5135
|
}
|
|
5131
|
-
}, [iconNode(it.icon), _preact.h.call(void 0, "span", { class: "
|
|
5136
|
+
}, [iconNode(it.icon), _preact.h.call(void 0, "span", { class: "markloom-slash-label" }, it.label)]));
|
|
5132
5137
|
});
|
|
5133
5138
|
_preact.render.call(void 0,
|
|
5134
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5139
|
+
_preact.h.call(void 0, "div", { class: "markloom-slash" }, rows),
|
|
5135
5140
|
this.overlay
|
|
5136
5141
|
);
|
|
5137
|
-
const el = this.overlay.querySelector(".
|
|
5142
|
+
const el = this.overlay.querySelector(".markloom-slash");
|
|
5138
5143
|
if (el)
|
|
5139
5144
|
void place(rectRef(rect), el, { placement: "bottom-start", gap: 6 });
|
|
5140
5145
|
}
|
|
@@ -5246,8 +5251,8 @@ var inputRules = {
|
|
|
5246
5251
|
return null;
|
|
5247
5252
|
if (!(marker === "[]" || marker === "[ ]" || marker === "[x]" || marker === "[X]"))
|
|
5248
5253
|
return null;
|
|
5249
|
-
const item =
|
|
5250
|
-
if (!item ||
|
|
5254
|
+
const item = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
5255
|
+
if (!item || _chunkGQ2HHRGIcjs.isText.call(void 0, item) || item.type !== "list_item")
|
|
5251
5256
|
return null;
|
|
5252
5257
|
const checked = marker === "[x]" || marker === "[X]";
|
|
5253
5258
|
const para = { ...block, children: [{ text: rest }, ...block.children.slice(1)] };
|
|
@@ -5327,12 +5332,12 @@ var linkMark = {
|
|
|
5327
5332
|
tag: "a",
|
|
5328
5333
|
props: (mark) => {
|
|
5329
5334
|
if (!_optionalChain([mark, 'access', _191 => _191.attrs, 'optionalAccess', _192 => _192.url]))
|
|
5330
|
-
return { "data-mark": "link", class: "
|
|
5335
|
+
return { "data-mark": "link", class: "markloom-link" };
|
|
5331
5336
|
const url = String(mark.attrs.url);
|
|
5332
5337
|
return {
|
|
5333
5338
|
href: url,
|
|
5334
5339
|
"data-mark": "link",
|
|
5335
|
-
class: "
|
|
5340
|
+
class: "markloom-link",
|
|
5336
5341
|
rel: "noopener noreferrer",
|
|
5337
5342
|
title: url
|
|
5338
5343
|
};
|
|
@@ -5363,7 +5368,7 @@ var textStyleMark = {
|
|
|
5363
5368
|
var markExtensions = [boldMark, italicMark, codeMark, strikeMark, underlineMark, highlightMark, superscriptMark, subscriptMark, linkMark, textStyleMark];
|
|
5364
5369
|
|
|
5365
5370
|
// src/view/kit.ts
|
|
5366
|
-
function
|
|
5371
|
+
function markloomKit() {
|
|
5367
5372
|
return [...markExtensions, ...blockExtensions, inputRules, textAlign, history, ...decorationExtensions];
|
|
5368
5373
|
}
|
|
5369
5374
|
|
|
@@ -5385,7 +5390,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5385
5390
|
this.threads = initial.slice();
|
|
5386
5391
|
this.scrollRoot = _nullishCoalesce(findScrollParent(host.root), () => ( document.body));
|
|
5387
5392
|
this.overlay = document.createElement("div");
|
|
5388
|
-
this.overlay.className = "
|
|
5393
|
+
this.overlay.className = "markloom-comment-overlay";
|
|
5389
5394
|
this.scrollRoot.appendChild(this.overlay);
|
|
5390
5395
|
host.root.addEventListener("click", this.onRootClick);
|
|
5391
5396
|
document.addEventListener("keydown", this.onKey);
|
|
@@ -5400,8 +5405,8 @@ var CommentPanel = (_class6 = class {
|
|
|
5400
5405
|
window.removeEventListener("resize", this.onReflow);
|
|
5401
5406
|
_preact.render.call(void 0, null, this.overlay);
|
|
5402
5407
|
this.overlay.remove();
|
|
5403
|
-
this.scrollRoot.classList.remove("
|
|
5404
|
-
document.documentElement.classList.remove("
|
|
5408
|
+
this.scrollRoot.classList.remove("markloom-comment-rail-open");
|
|
5409
|
+
document.documentElement.classList.remove("markloom-comment-rail-open");
|
|
5405
5410
|
}
|
|
5406
5411
|
getThreads() {
|
|
5407
5412
|
return this.threads;
|
|
@@ -5515,7 +5520,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5515
5520
|
reply() {
|
|
5516
5521
|
if (this.mode.kind !== "view")
|
|
5517
5522
|
return;
|
|
5518
|
-
const ta = this.overlay.querySelector(`[data-thread="${cssEscape(this.mode.id)}"] .
|
|
5523
|
+
const ta = this.overlay.querySelector(`[data-thread="${cssEscape(this.mode.id)}"] .markloom-comment-reply textarea`);
|
|
5519
5524
|
const body = (_nullishCoalesce(_optionalChain([ta, 'optionalAccess', _203 => _203.value]), () => ( this.mode.reply))).trim();
|
|
5520
5525
|
if (!body)
|
|
5521
5526
|
return;
|
|
@@ -5540,7 +5545,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5540
5545
|
this.paint();
|
|
5541
5546
|
}
|
|
5542
5547
|
deleteThread(id) {
|
|
5543
|
-
const steps =
|
|
5548
|
+
const steps = _chunkYXQDCW4Ycjs.stripCommentMarks.call(void 0, this.host.doc(), id);
|
|
5544
5549
|
this.commitThreads(this.threads.filter((t) => t.id !== id));
|
|
5545
5550
|
this.activeId = null;
|
|
5546
5551
|
this.mode = this.threads.length ? { kind: "list" } : { kind: "closed" };
|
|
@@ -5557,7 +5562,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5557
5562
|
}
|
|
5558
5563
|
/** 卡片 top(相对 rail-body)。正文与栏共滚 → viewport 差即内容坐标。 */
|
|
5559
5564
|
cardTops(ids, composeTop) {
|
|
5560
|
-
const body = this.overlay.querySelector(".
|
|
5565
|
+
const body = this.overlay.querySelector(".markloom-comment-rail-body");
|
|
5561
5566
|
const bodyTop = _nullishCoalesce(_optionalChain([body, 'optionalAccess', _204 => _204.getBoundingClientRect, 'call', _205 => _205(), 'access', _206 => _206.top]), () => ( 0));
|
|
5562
5567
|
const raw = ids.map((id) => {
|
|
5563
5568
|
const el = this.host.root.querySelector(`[data-comment-id="${cssEscape(id)}"]`);
|
|
@@ -5577,11 +5582,11 @@ var CommentPanel = (_class6 = class {
|
|
|
5577
5582
|
return out;
|
|
5578
5583
|
}
|
|
5579
5584
|
reflowAfterPaint() {
|
|
5580
|
-
const rail = this.overlay.querySelector(".
|
|
5581
|
-
const body = this.overlay.querySelector(".
|
|
5585
|
+
const rail = this.overlay.querySelector(".markloom-comment-rail");
|
|
5586
|
+
const body = this.overlay.querySelector(".markloom-comment-rail-body");
|
|
5582
5587
|
if (!body)
|
|
5583
5588
|
return;
|
|
5584
|
-
const cards = [...body.querySelectorAll(".
|
|
5589
|
+
const cards = [...body.querySelectorAll(".markloom-comment-card")];
|
|
5585
5590
|
cards.sort((a, b) => (parseFloat(a.style.top) || 0) - (parseFloat(b.style.top) || 0));
|
|
5586
5591
|
let floor2 = 0;
|
|
5587
5592
|
let maxBottom = 0;
|
|
@@ -5596,7 +5601,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5596
5601
|
body.style.minHeight = `${Math.max(maxBottom + RAIL_PAD, 0)}px`;
|
|
5597
5602
|
if (rail) {
|
|
5598
5603
|
const sp = this.scrollRoot;
|
|
5599
|
-
const hd = rail.querySelector(".
|
|
5604
|
+
const hd = rail.querySelector(".markloom-comment-rail-hd");
|
|
5600
5605
|
const hdH = _nullishCoalesce(_optionalChain([hd, 'optionalAccess', _207 => _207.offsetHeight]), () => ( 52));
|
|
5601
5606
|
const need = Math.max(sp.scrollHeight, sp.clientHeight, maxBottom + hdH + RAIL_PAD);
|
|
5602
5607
|
rail.style.minHeight = `${need}px`;
|
|
@@ -5604,7 +5609,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5604
5609
|
}
|
|
5605
5610
|
paint() {
|
|
5606
5611
|
const open = this.mode.kind !== "closed";
|
|
5607
|
-
this.scrollRoot.classList.toggle("
|
|
5612
|
+
this.scrollRoot.classList.toggle("markloom-comment-rail-open", open);
|
|
5608
5613
|
if (!open) {
|
|
5609
5614
|
_preact.render.call(void 0, null, this.overlay);
|
|
5610
5615
|
return;
|
|
@@ -5621,20 +5626,20 @@ var CommentPanel = (_class6 = class {
|
|
|
5621
5626
|
const author = this.host.author();
|
|
5622
5627
|
_preact.render.call(void 0,
|
|
5623
5628
|
_preact.h.call(void 0, "aside", {
|
|
5624
|
-
class: "
|
|
5629
|
+
class: "markloom-comment-rail",
|
|
5625
5630
|
"data-comment-rail": "",
|
|
5626
5631
|
"aria-label": "\u8BC4\u8BBA"
|
|
5627
5632
|
}, [
|
|
5628
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5633
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-rail-hd", key: "hd" }, [
|
|
5629
5634
|
_preact.h.call(void 0,
|
|
5630
5635
|
"div",
|
|
5631
|
-
{ class: "
|
|
5636
|
+
{ class: "markloom-comment-rail-title", key: "t" },
|
|
5632
5637
|
`\u8BC4\u8BBA (${openCount})`
|
|
5633
5638
|
),
|
|
5634
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5639
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-rail-acts", key: "a" }, [
|
|
5635
5640
|
_preact.h.call(void 0, "button", {
|
|
5636
5641
|
type: "button",
|
|
5637
|
-
class: "
|
|
5642
|
+
class: "markloom-comment-icon" + (this.showResolved ? " markloom-comment-icon-on" : ""),
|
|
5638
5643
|
title: this.showResolved ? "\u53EA\u770B\u672A\u89E3\u51B3" : "\u663E\u793A\u5DF2\u89E3\u51B3",
|
|
5639
5644
|
"data-act": "filter",
|
|
5640
5645
|
onMouseDown: (e) => {
|
|
@@ -5645,7 +5650,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5645
5650
|
}, this.showResolved ? "\u5168" : "\u5F00"),
|
|
5646
5651
|
_preact.h.call(void 0, "button", {
|
|
5647
5652
|
type: "button",
|
|
5648
|
-
class: "
|
|
5653
|
+
class: "markloom-comment-icon",
|
|
5649
5654
|
title: "\u6536\u8D77",
|
|
5650
5655
|
"data-act": "close",
|
|
5651
5656
|
onMouseDown: (e) => {
|
|
@@ -5655,21 +5660,21 @@ var CommentPanel = (_class6 = class {
|
|
|
5655
5660
|
}, "\xBB")
|
|
5656
5661
|
])
|
|
5657
5662
|
]),
|
|
5658
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5663
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-rail-body", key: "body" }, [
|
|
5659
5664
|
composing && this.mode.kind === "compose" && _preact.h.call(void 0, "div", {
|
|
5660
|
-
class: "
|
|
5665
|
+
class: "markloom-comment-card markloom-comment-card-compose",
|
|
5661
5666
|
key: "compose",
|
|
5662
5667
|
"data-comment-ui": "compose",
|
|
5663
5668
|
style: { top: `${_nullishCoalesce(tops.get("__compose__"), () => ( 0))}px` }
|
|
5664
5669
|
}, [
|
|
5665
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5666
|
-
this.mode.quote ? _preact.h.call(void 0, "div", { class: "
|
|
5667
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5670
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-accent", key: "ac" }),
|
|
5671
|
+
this.mode.quote ? _preact.h.call(void 0, "div", { class: "markloom-comment-quote", key: "q" }, this.mode.quote) : null,
|
|
5672
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-msg", key: "who" }, [
|
|
5668
5673
|
avatar(author),
|
|
5669
|
-
_preact.h.call(void 0, "span", { class: "
|
|
5674
|
+
_preact.h.call(void 0, "span", { class: "markloom-comment-author" }, author.name)
|
|
5670
5675
|
]),
|
|
5671
5676
|
_preact.h.call(void 0, "textarea", {
|
|
5672
|
-
class: "
|
|
5677
|
+
class: "markloom-comment-input",
|
|
5673
5678
|
placeholder: "\u6DFB\u52A0\u8BC4\u8BBA\u2026",
|
|
5674
5679
|
defaultValue: this.mode.body,
|
|
5675
5680
|
autofocus: true,
|
|
@@ -5681,10 +5686,10 @@ var CommentPanel = (_class6 = class {
|
|
|
5681
5686
|
}
|
|
5682
5687
|
}
|
|
5683
5688
|
}),
|
|
5684
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5689
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-card-ft", key: "ft" }, [
|
|
5685
5690
|
_preact.h.call(void 0, "button", {
|
|
5686
5691
|
type: "button",
|
|
5687
|
-
class: "
|
|
5692
|
+
class: "markloom-comment-btn-ghost",
|
|
5688
5693
|
onMouseDown: (e) => {
|
|
5689
5694
|
e.preventDefault();
|
|
5690
5695
|
if (this.threads.length)
|
|
@@ -5695,7 +5700,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5695
5700
|
}, "\u53D6\u6D88"),
|
|
5696
5701
|
_preact.h.call(void 0, "button", {
|
|
5697
5702
|
type: "button",
|
|
5698
|
-
class: "
|
|
5703
|
+
class: "markloom-comment-btn",
|
|
5699
5704
|
onMouseDown: (e) => {
|
|
5700
5705
|
e.preventDefault();
|
|
5701
5706
|
this.submitCompose();
|
|
@@ -5705,7 +5710,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5705
5710
|
]),
|
|
5706
5711
|
...threads.map((t) => this.threadCard(t, t.id === viewId, ro, _nullishCoalesce(tops.get(t.id), () => ( 0)))),
|
|
5707
5712
|
!composing && !threads.length && _preact.h.call(void 0, "div", {
|
|
5708
|
-
class: "
|
|
5713
|
+
class: "markloom-comment-empty",
|
|
5709
5714
|
key: "empty",
|
|
5710
5715
|
style: { top: "24px" }
|
|
5711
5716
|
}, this.showResolved ? "\u6682\u65E0\u8BC4\u8BBA" : "\u6682\u65E0\u672A\u89E3\u51B3\u8BC4\u8BBA")
|
|
@@ -5726,7 +5731,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5726
5731
|
const head = thread.messages[0];
|
|
5727
5732
|
const n = thread.messages.length;
|
|
5728
5733
|
return _preact.h.call(void 0, "div", {
|
|
5729
|
-
class: "
|
|
5734
|
+
class: "markloom-comment-card" + (thread.resolved ? " markloom-comment-card-resolved" : "") + (expanded ? " markloom-comment-card-active" : ""),
|
|
5730
5735
|
key: thread.id,
|
|
5731
5736
|
"data-comment-ui": expanded ? "view" : "item",
|
|
5732
5737
|
"data-thread": thread.id,
|
|
@@ -5738,13 +5743,13 @@ var CommentPanel = (_class6 = class {
|
|
|
5738
5743
|
this.openThread(thread.id);
|
|
5739
5744
|
}
|
|
5740
5745
|
}, [
|
|
5741
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5742
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5743
|
-
quote ? _preact.h.call(void 0, "div", { class: "
|
|
5744
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5746
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-accent", key: "ac" }),
|
|
5747
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-card-hd", key: "hd" }, [
|
|
5748
|
+
quote ? _preact.h.call(void 0, "div", { class: "markloom-comment-quote", key: "q" }, quote) : _preact.h.call(void 0, "span", { key: "t" }, thread.resolved ? "\u5DF2\u89E3\u51B3" : "\u8BC4\u8BBA"),
|
|
5749
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-card-acts", key: "a" }, [
|
|
5745
5750
|
!ro && _preact.h.call(void 0, "button", {
|
|
5746
5751
|
type: "button",
|
|
5747
|
-
class: "
|
|
5752
|
+
class: "markloom-comment-icon",
|
|
5748
5753
|
title: thread.resolved ? "\u91CD\u65B0\u6253\u5F00" : "\u89E3\u51B3",
|
|
5749
5754
|
"data-act": "resolve",
|
|
5750
5755
|
onMouseDown: (e) => {
|
|
@@ -5755,7 +5760,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5755
5760
|
}, thread.resolved ? "\u21BA" : "\u2713"),
|
|
5756
5761
|
!ro && _preact.h.call(void 0, "button", {
|
|
5757
5762
|
type: "button",
|
|
5758
|
-
class: "
|
|
5763
|
+
class: "markloom-comment-icon",
|
|
5759
5764
|
title: "\u5220\u9664",
|
|
5760
5765
|
"data-act": "delete",
|
|
5761
5766
|
onMouseDown: (e) => {
|
|
@@ -5767,18 +5772,18 @@ var CommentPanel = (_class6 = class {
|
|
|
5767
5772
|
])
|
|
5768
5773
|
]),
|
|
5769
5774
|
// 折叠:只露主评
|
|
5770
|
-
!expanded && head && _preact.h.call(void 0, "div", { class: "
|
|
5775
|
+
!expanded && head && _preact.h.call(void 0, "div", { class: "markloom-comment-preview", key: "pv" }, [
|
|
5771
5776
|
msgRow(head),
|
|
5772
|
-
n > 1 && _preact.h.call(void 0, "div", { class: "
|
|
5777
|
+
n > 1 && _preact.h.call(void 0, "div", { class: "markloom-comment-more", key: "more" }, `${n - 1} \u6761\u56DE\u590D`)
|
|
5773
5778
|
]),
|
|
5774
5779
|
expanded && _preact.h.call(void 0,
|
|
5775
5780
|
"div",
|
|
5776
|
-
{ class: "
|
|
5781
|
+
{ class: "markloom-comment-msgs", key: "msgs" },
|
|
5777
5782
|
thread.messages.map((m) => msgRow(m))
|
|
5778
5783
|
),
|
|
5779
|
-
expanded && !ro && !thread.resolved && _preact.h.call(void 0, "div", { class: "
|
|
5784
|
+
expanded && !ro && !thread.resolved && _preact.h.call(void 0, "div", { class: "markloom-comment-reply", key: "rep" }, [
|
|
5780
5785
|
_preact.h.call(void 0, "textarea", {
|
|
5781
|
-
class: "
|
|
5786
|
+
class: "markloom-comment-input markloom-comment-input-sm",
|
|
5782
5787
|
placeholder: "\u56DE\u590D\u2026",
|
|
5783
5788
|
defaultValue: this.mode.kind === "view" && this.mode.id === thread.id ? this.mode.reply : "",
|
|
5784
5789
|
rows: 2,
|
|
@@ -5789,10 +5794,10 @@ var CommentPanel = (_class6 = class {
|
|
|
5789
5794
|
}
|
|
5790
5795
|
}
|
|
5791
5796
|
}),
|
|
5792
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5797
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-card-ft" }, [
|
|
5793
5798
|
_preact.h.call(void 0, "button", {
|
|
5794
5799
|
type: "button",
|
|
5795
|
-
class: "
|
|
5800
|
+
class: "markloom-comment-btn",
|
|
5796
5801
|
"data-act": "reply",
|
|
5797
5802
|
onMouseDown: (e) => {
|
|
5798
5803
|
e.preventDefault();
|
|
@@ -5807,18 +5812,18 @@ var CommentPanel = (_class6 = class {
|
|
|
5807
5812
|
function avatar(author) {
|
|
5808
5813
|
const initial = (author.name || "?").slice(0, 1);
|
|
5809
5814
|
if (author.avatar)
|
|
5810
|
-
return _preact.h.call(void 0, "img", { class: "
|
|
5811
|
-
return _preact.h.call(void 0, "div", { class: "
|
|
5815
|
+
return _preact.h.call(void 0, "img", { class: "markloom-comment-avatar", src: author.avatar, alt: "" });
|
|
5816
|
+
return _preact.h.call(void 0, "div", { class: "markloom-comment-avatar markloom-comment-avatar-fallback" }, initial);
|
|
5812
5817
|
}
|
|
5813
5818
|
function msgRow(m) {
|
|
5814
|
-
return _preact.h.call(void 0, "div", { class: "
|
|
5819
|
+
return _preact.h.call(void 0, "div", { class: "markloom-comment-msg", key: m.id }, [
|
|
5815
5820
|
avatar(m.author),
|
|
5816
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5817
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5818
|
-
_preact.h.call(void 0, "span", { class: "
|
|
5819
|
-
_preact.h.call(void 0, "span", { class: "
|
|
5821
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-msg-body" }, [
|
|
5822
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-msg-meta" }, [
|
|
5823
|
+
_preact.h.call(void 0, "span", { class: "markloom-comment-author" }, m.author.name),
|
|
5824
|
+
_preact.h.call(void 0, "span", { class: "markloom-comment-time" }, fmtTime(m.createdAt))
|
|
5820
5825
|
]),
|
|
5821
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5826
|
+
_preact.h.call(void 0, "div", { class: "markloom-comment-text" }, m.body)
|
|
5822
5827
|
])
|
|
5823
5828
|
]);
|
|
5824
5829
|
}
|
|
@@ -5867,9 +5872,9 @@ var TocPanel = (_class7 = class {
|
|
|
5867
5872
|
constructor(host) {;_class7.prototype.__init48.call(this);_class7.prototype.__init49.call(this);_class7.prototype.__init50.call(this);_class7.prototype.__init51.call(this);_class7.prototype.__init52.call(this);_class7.prototype.__init53.call(this);
|
|
5868
5873
|
this.host = host;
|
|
5869
5874
|
this.rail = document.createElement("div");
|
|
5870
|
-
this.rail.className = "
|
|
5875
|
+
this.rail.className = "markloom-toc-host";
|
|
5871
5876
|
document.body.appendChild(this.rail);
|
|
5872
|
-
host.root.addEventListener("
|
|
5877
|
+
host.root.addEventListener("markloom-redraw", this.onRedraw);
|
|
5873
5878
|
this.scrollRoot = _nullishCoalesce(findScrollParent2(host.root), () => ( window));
|
|
5874
5879
|
this.scrollRoot.addEventListener("scroll", this.onScroll, { passive: true, capture: true });
|
|
5875
5880
|
window.addEventListener("resize", this.onScroll);
|
|
@@ -5877,7 +5882,7 @@ var TocPanel = (_class7 = class {
|
|
|
5877
5882
|
this.refresh();
|
|
5878
5883
|
}
|
|
5879
5884
|
destroy() {
|
|
5880
|
-
this.host.root.removeEventListener("
|
|
5885
|
+
this.host.root.removeEventListener("markloom-redraw", this.onRedraw);
|
|
5881
5886
|
this.scrollRoot.removeEventListener("scroll", this.onScroll, { capture: true });
|
|
5882
5887
|
window.removeEventListener("resize", this.onScroll);
|
|
5883
5888
|
this.setPadOpen(false);
|
|
@@ -5892,13 +5897,13 @@ var TocPanel = (_class7 = class {
|
|
|
5892
5897
|
// 有滚动父 → 给滚动父加 padding(正文区);否则退回 html(lab 全页)
|
|
5893
5898
|
setPadOpen(open) {
|
|
5894
5899
|
const pad2 = this.scrollRoot instanceof HTMLElement ? this.scrollRoot : document.documentElement;
|
|
5895
|
-
pad2.classList.toggle("
|
|
5900
|
+
pad2.classList.toggle("markloom-toc-open", open);
|
|
5896
5901
|
if (pad2 !== document.documentElement)
|
|
5897
|
-
document.documentElement.classList.remove("
|
|
5902
|
+
document.documentElement.classList.remove("markloom-toc-open");
|
|
5898
5903
|
}
|
|
5899
5904
|
__init52() {this.onRedraw = () => this.refresh()}
|
|
5900
5905
|
refresh() {
|
|
5901
|
-
this.entries =
|
|
5906
|
+
this.entries = _chunkYXQDCW4Ycjs.outline.call(void 0, this.host.doc()).filter((e) => e.text.trim());
|
|
5902
5907
|
this.syncActive();
|
|
5903
5908
|
this.paint();
|
|
5904
5909
|
}
|
|
@@ -5938,7 +5943,7 @@ var TocPanel = (_class7 = class {
|
|
|
5938
5943
|
if (byId)
|
|
5939
5944
|
return byId;
|
|
5940
5945
|
}
|
|
5941
|
-
const docEl = _nullishCoalesce(this.host.root.querySelector(".
|
|
5946
|
+
const docEl = _nullishCoalesce(this.host.root.querySelector(".markloom-doc"), () => ( this.host.root));
|
|
5942
5947
|
const kids = [...docEl.children].filter((c) => c instanceof HTMLElement && c.dataset.blockId !== void 0);
|
|
5943
5948
|
const idx = e.path[0];
|
|
5944
5949
|
return _nullishCoalesce(kids[idx], () => ( null));
|
|
@@ -5964,14 +5969,14 @@ var TocPanel = (_class7 = class {
|
|
|
5964
5969
|
minLv = 1;
|
|
5965
5970
|
_preact.render.call(void 0,
|
|
5966
5971
|
_preact.h.call(void 0, "aside", {
|
|
5967
|
-
class: "
|
|
5972
|
+
class: "markloom-toc-rail",
|
|
5968
5973
|
"data-toc-rail": "",
|
|
5969
5974
|
"aria-label": "\u76EE\u5F55"
|
|
5970
5975
|
}, [
|
|
5971
|
-
_preact.h.call(void 0, "div", { class: "
|
|
5976
|
+
_preact.h.call(void 0, "div", { class: "markloom-toc-hd", key: "hd" }, "\u76EE\u5F55"),
|
|
5972
5977
|
_preact.h.call(void 0,
|
|
5973
5978
|
"nav",
|
|
5974
|
-
{ class: "
|
|
5979
|
+
{ class: "markloom-toc-nav", key: "nav" },
|
|
5975
5980
|
items.length ? items.map((e, i) => {
|
|
5976
5981
|
const key = _nullishCoalesce(e.id, () => ( pathKey(e.path)));
|
|
5977
5982
|
const active2 = this.activeId === key;
|
|
@@ -5979,7 +5984,7 @@ var TocPanel = (_class7 = class {
|
|
|
5979
5984
|
return _preact.h.call(void 0, "button", {
|
|
5980
5985
|
key: `${key}-${i}`,
|
|
5981
5986
|
type: "button",
|
|
5982
|
-
class: "
|
|
5987
|
+
class: "markloom-toc-item" + (active2 ? " markloom-toc-item-active" : ""),
|
|
5983
5988
|
"data-level": String(e.level),
|
|
5984
5989
|
"data-active": active2 ? "" : void 0,
|
|
5985
5990
|
"data-toc-id": _nullishCoalesce(e.id, () => ( void 0)),
|
|
@@ -5990,7 +5995,7 @@ var TocPanel = (_class7 = class {
|
|
|
5990
5995
|
this.jump(e);
|
|
5991
5996
|
}
|
|
5992
5997
|
}, e.text || "\u672A\u547D\u540D\u6807\u9898");
|
|
5993
|
-
}) : _preact.h.call(void 0, "div", { class: "
|
|
5998
|
+
}) : _preact.h.call(void 0, "div", { class: "markloom-toc-empty", key: "empty" }, "\u6DFB\u52A0\u6807\u9898\u540E\u663E\u793A\u76EE\u5F55")
|
|
5994
5999
|
)
|
|
5995
6000
|
]),
|
|
5996
6001
|
this.rail
|
|
@@ -6025,7 +6030,7 @@ var MentionPopovers = (_class8 = class {
|
|
|
6025
6030
|
constructor(host) {;_class8.prototype.__init54.call(this);_class8.prototype.__init55.call(this);_class8.prototype.__init56.call(this);_class8.prototype.__init57.call(this);
|
|
6026
6031
|
this.host = host;
|
|
6027
6032
|
this.overlay = document.createElement("div");
|
|
6028
|
-
this.overlay.className = "
|
|
6033
|
+
this.overlay.className = "markloom-mention-pop-host";
|
|
6029
6034
|
document.body.appendChild(this.overlay);
|
|
6030
6035
|
document.addEventListener("pointerdown", this.onDocDown, true);
|
|
6031
6036
|
document.addEventListener("keydown", this.onKey, true);
|
|
@@ -6105,33 +6110,33 @@ var MentionPopovers = (_class8 = class {
|
|
|
6105
6110
|
const initial = (p.name || "?").slice(0, 1);
|
|
6106
6111
|
_preact.render.call(void 0,
|
|
6107
6112
|
_preact.h.call(void 0, "div", {
|
|
6108
|
-
class: "
|
|
6113
|
+
class: "markloom-profile-card",
|
|
6109
6114
|
style: { position: "fixed", width: "280px", zIndex: "100" },
|
|
6110
6115
|
"data-mention-pop": "person",
|
|
6111
6116
|
onMouseDown: (e) => e.stopPropagation()
|
|
6112
6117
|
}, [
|
|
6113
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6114
|
-
p.avatar ? _preact.h.call(void 0, "img", { class: "
|
|
6115
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6116
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6117
|
-
p.title && _preact.h.call(void 0, "div", { class: "
|
|
6118
|
-
p.department && _preact.h.call(void 0, "div", { class: "
|
|
6118
|
+
_preact.h.call(void 0, "div", { class: "markloom-profile-head", key: "h" }, [
|
|
6119
|
+
p.avatar ? _preact.h.call(void 0, "img", { class: "markloom-profile-avatar", src: p.avatar, alt: "" }) : _preact.h.call(void 0, "div", { class: "markloom-profile-avatar markloom-profile-avatar-fallback" }, initial),
|
|
6120
|
+
_preact.h.call(void 0, "div", { class: "markloom-profile-id" }, [
|
|
6121
|
+
_preact.h.call(void 0, "div", { class: "markloom-profile-name" }, p.name),
|
|
6122
|
+
p.title && _preact.h.call(void 0, "div", { class: "markloom-profile-title" }, p.title),
|
|
6123
|
+
p.department && _preact.h.call(void 0, "div", { class: "markloom-profile-dept" }, p.department)
|
|
6119
6124
|
])
|
|
6120
6125
|
]),
|
|
6121
|
-
(p.email || p.status) && _preact.h.call(void 0, "div", { class: "
|
|
6122
|
-
p.status && _preact.h.call(void 0, "div", { class: "
|
|
6123
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6124
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6126
|
+
(p.email || p.status) && _preact.h.call(void 0, "div", { class: "markloom-profile-meta", key: "m" }, [
|
|
6127
|
+
p.status && _preact.h.call(void 0, "div", { class: "markloom-profile-row" }, [
|
|
6128
|
+
_preact.h.call(void 0, "span", { class: "markloom-profile-k" }, "\u72B6\u6001"),
|
|
6129
|
+
_preact.h.call(void 0, "span", { class: "markloom-profile-v" }, p.status)
|
|
6125
6130
|
]),
|
|
6126
|
-
p.email && _preact.h.call(void 0, "div", { class: "
|
|
6127
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6128
|
-
_preact.h.call(void 0, "a", { class: "
|
|
6131
|
+
p.email && _preact.h.call(void 0, "div", { class: "markloom-profile-row" }, [
|
|
6132
|
+
_preact.h.call(void 0, "span", { class: "markloom-profile-k" }, "\u90AE\u7BB1"),
|
|
6133
|
+
_preact.h.call(void 0, "a", { class: "markloom-profile-v markloom-profile-link", href: `mailto:${p.email}` }, p.email)
|
|
6129
6134
|
])
|
|
6130
6135
|
])
|
|
6131
6136
|
]),
|
|
6132
6137
|
this.overlay
|
|
6133
6138
|
);
|
|
6134
|
-
this.placePop(mode.rect, ".
|
|
6139
|
+
this.placePop(mode.rect, ".markloom-profile-card");
|
|
6135
6140
|
}
|
|
6136
6141
|
paintDateTime(mode) {
|
|
6137
6142
|
const draft = mode.draft;
|
|
@@ -6157,11 +6162,11 @@ var MentionPopovers = (_class8 = class {
|
|
|
6157
6162
|
_optionalChain([this, 'access', _217 => _217.host, 'access', _218 => _218.onDateChange, 'optionalCall', _219 => _219(mode.path, toIso(draft))]);
|
|
6158
6163
|
this.close();
|
|
6159
6164
|
};
|
|
6160
|
-
const spin = (key, max2, label) => _preact.h.call(void 0, "label", { class: "
|
|
6161
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6165
|
+
const spin = (key, max2, label) => _preact.h.call(void 0, "label", { class: "markloom-time-field", key }, [
|
|
6166
|
+
_preact.h.call(void 0, "span", { class: "markloom-time-field-lab" }, label),
|
|
6162
6167
|
_preact.h.call(void 0, "input", {
|
|
6163
6168
|
type: "number",
|
|
6164
|
-
class: "
|
|
6169
|
+
class: "markloom-time-input",
|
|
6165
6170
|
min: 0,
|
|
6166
6171
|
max: max2,
|
|
6167
6172
|
value: draft[key],
|
|
@@ -6177,15 +6182,15 @@ var MentionPopovers = (_class8 = class {
|
|
|
6177
6182
|
]);
|
|
6178
6183
|
_preact.render.call(void 0,
|
|
6179
6184
|
_preact.h.call(void 0, "div", {
|
|
6180
|
-
class: "
|
|
6185
|
+
class: "markloom-date-picker markloom-datetime-picker",
|
|
6181
6186
|
style: { position: "fixed", width: "300px", zIndex: "100" },
|
|
6182
6187
|
"data-mention-pop": "date",
|
|
6183
6188
|
onMouseDown: (e) => e.stopPropagation()
|
|
6184
6189
|
}, [
|
|
6185
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6190
|
+
_preact.h.call(void 0, "div", { class: "markloom-date-hd", key: "hd" }, [
|
|
6186
6191
|
_preact.h.call(void 0, "button", {
|
|
6187
6192
|
type: "button",
|
|
6188
|
-
class: "
|
|
6193
|
+
class: "markloom-date-nav",
|
|
6189
6194
|
"data-act": "prev",
|
|
6190
6195
|
onMouseDown: (e) => {
|
|
6191
6196
|
e.preventDefault();
|
|
@@ -6197,10 +6202,10 @@ var MentionPopovers = (_class8 = class {
|
|
|
6197
6202
|
setDraft({ viewY: ny, viewM: nm });
|
|
6198
6203
|
}
|
|
6199
6204
|
}, "\u2039"),
|
|
6200
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6205
|
+
_preact.h.call(void 0, "span", { class: "markloom-date-label" }, monthLabel),
|
|
6201
6206
|
_preact.h.call(void 0, "button", {
|
|
6202
6207
|
type: "button",
|
|
6203
|
-
class: "
|
|
6208
|
+
class: "markloom-date-nav",
|
|
6204
6209
|
"data-act": "next",
|
|
6205
6210
|
onMouseDown: (e) => {
|
|
6206
6211
|
e.preventDefault();
|
|
@@ -6215,16 +6220,16 @@ var MentionPopovers = (_class8 = class {
|
|
|
6215
6220
|
]),
|
|
6216
6221
|
_preact.h.call(void 0,
|
|
6217
6222
|
"div",
|
|
6218
|
-
{ class: "
|
|
6223
|
+
{ class: "markloom-date-week", key: "w" },
|
|
6219
6224
|
week.map((d) => _preact.h.call(void 0, "span", { key: d }, d))
|
|
6220
6225
|
),
|
|
6221
6226
|
_preact.h.call(void 0,
|
|
6222
6227
|
"div",
|
|
6223
|
-
{ class: "
|
|
6224
|
-
cells.map((c, i) => c.day == null ? _preact.h.call(void 0, "span", { key: `e${i}`, class: "
|
|
6228
|
+
{ class: "markloom-date-grid", key: "g" },
|
|
6229
|
+
cells.map((c, i) => c.day == null ? _preact.h.call(void 0, "span", { key: `e${i}`, class: "markloom-date-cell markloom-date-empty" }) : _preact.h.call(void 0, "button", {
|
|
6225
6230
|
key: `d${c.day}`,
|
|
6226
6231
|
type: "button",
|
|
6227
|
-
class: "
|
|
6232
|
+
class: "markloom-date-cell" + (draft.y === viewY && draft.m === viewM && draft.d === c.day ? " markloom-date-selected" : "") + (isToday(viewY, viewM, c.day) ? " markloom-date-today" : ""),
|
|
6228
6233
|
"data-day": String(c.day),
|
|
6229
6234
|
onMouseDown: (e) => {
|
|
6230
6235
|
e.preventDefault();
|
|
@@ -6233,18 +6238,18 @@ var MentionPopovers = (_class8 = class {
|
|
|
6233
6238
|
}, String(c.day)))
|
|
6234
6239
|
),
|
|
6235
6240
|
// 时:分:秒 一体
|
|
6236
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6241
|
+
_preact.h.call(void 0, "div", { class: "markloom-time-row", key: "time" }, [
|
|
6237
6242
|
spin("h", 23, "\u65F6"),
|
|
6238
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6243
|
+
_preact.h.call(void 0, "span", { class: "markloom-time-colon", key: "c1" }, ":"),
|
|
6239
6244
|
spin("min", 59, "\u5206"),
|
|
6240
|
-
_preact.h.call(void 0, "span", { class: "
|
|
6245
|
+
_preact.h.call(void 0, "span", { class: "markloom-time-colon", key: "c2" }, ":"),
|
|
6241
6246
|
spin("s", 59, "\u79D2")
|
|
6242
6247
|
]),
|
|
6243
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6244
|
-
_preact.h.call(void 0, "div", { class: "
|
|
6248
|
+
_preact.h.call(void 0, "div", { class: "markloom-date-preview", key: "pv" }, preview),
|
|
6249
|
+
_preact.h.call(void 0, "div", { class: "markloom-date-ft", key: "ft" }, [
|
|
6245
6250
|
_preact.h.call(void 0, "button", {
|
|
6246
6251
|
type: "button",
|
|
6247
|
-
class: "
|
|
6252
|
+
class: "markloom-date-today-btn",
|
|
6248
6253
|
"data-act": "now",
|
|
6249
6254
|
onMouseDown: (e) => {
|
|
6250
6255
|
e.preventDefault();
|
|
@@ -6263,7 +6268,7 @@ var MentionPopovers = (_class8 = class {
|
|
|
6263
6268
|
}, "\u73B0\u5728"),
|
|
6264
6269
|
_preact.h.call(void 0, "button", {
|
|
6265
6270
|
type: "button",
|
|
6266
|
-
class: "
|
|
6271
|
+
class: "markloom-date-ok",
|
|
6267
6272
|
"data-act": "ok",
|
|
6268
6273
|
onMouseDown: (e) => {
|
|
6269
6274
|
e.preventDefault();
|
|
@@ -6274,7 +6279,7 @@ var MentionPopovers = (_class8 = class {
|
|
|
6274
6279
|
]),
|
|
6275
6280
|
this.overlay
|
|
6276
6281
|
);
|
|
6277
|
-
this.placePop(mode.rect, ".
|
|
6282
|
+
this.placePop(mode.rect, ".markloom-date-picker");
|
|
6278
6283
|
}
|
|
6279
6284
|
}, _class8);
|
|
6280
6285
|
function pad(n) {
|
|
@@ -6336,7 +6341,7 @@ function atomIdsInSelection(doc, sel) {
|
|
|
6336
6341
|
const out = /* @__PURE__ */ new Set();
|
|
6337
6342
|
for (let i = lo; i <= hi; i++) {
|
|
6338
6343
|
const n = doc.children[i];
|
|
6339
|
-
if (!n ||
|
|
6344
|
+
if (!n || _chunkGQ2HHRGIcjs.isText.call(void 0, n))
|
|
6340
6345
|
continue;
|
|
6341
6346
|
if ((n.type === "image" || n.type === "embed") && n.id)
|
|
6342
6347
|
out.add(n.id);
|
|
@@ -6357,7 +6362,7 @@ var ImageControls = (_class9 = class {
|
|
|
6357
6362
|
this.root = root;
|
|
6358
6363
|
this.host = host;
|
|
6359
6364
|
this.overlay = document.createElement("div");
|
|
6360
|
-
this.overlay.className = "
|
|
6365
|
+
this.overlay.className = "markloom-image-overlay";
|
|
6361
6366
|
document.body.appendChild(this.overlay);
|
|
6362
6367
|
document.addEventListener("pointerdown", this.onDocDown, true);
|
|
6363
6368
|
document.addEventListener("keydown", this.onKeyDown);
|
|
@@ -6407,7 +6412,7 @@ var ImageControls = (_class9 = class {
|
|
|
6407
6412
|
}}
|
|
6408
6413
|
__init64() {this.onDocDown = (e) => {
|
|
6409
6414
|
const el = e.target instanceof HTMLElement ? e.target : null;
|
|
6410
|
-
if (_optionalChain([el, 'optionalAccess', _228 => _228.closest, 'call', _229 => _229(".
|
|
6415
|
+
if (_optionalChain([el, 'optionalAccess', _228 => _228.closest, 'call', _229 => _229(".markloom-image-overlay")]) || _optionalChain([el, 'optionalAccess', _230 => _230.closest, 'call', _231 => _231(".markloom-lightbox")]))
|
|
6411
6416
|
return;
|
|
6412
6417
|
const atom = _optionalChain([el, 'optionalAccess', _232 => _232.closest, 'call', _233 => _233('[data-atom="image"], [data-atom="embed"]')]);
|
|
6413
6418
|
if (atom && this.root.contains(atom)) {
|
|
@@ -6438,7 +6443,7 @@ var ImageControls = (_class9 = class {
|
|
|
6438
6443
|
return !!this.exclusiveId && !!this.atomEl(this.exclusiveId);
|
|
6439
6444
|
}
|
|
6440
6445
|
selectedBlockPath() {
|
|
6441
|
-
return this.exclusiveId ?
|
|
6446
|
+
return this.exclusiveId ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), this.exclusiveId) : null;
|
|
6442
6447
|
}
|
|
6443
6448
|
selectByBlockId(id) {
|
|
6444
6449
|
const atom = this.atomEl(id);
|
|
@@ -6474,10 +6479,10 @@ var ImageControls = (_class9 = class {
|
|
|
6474
6479
|
blockNode() {
|
|
6475
6480
|
if (!this.exclusiveId)
|
|
6476
6481
|
return null;
|
|
6477
|
-
const path =
|
|
6482
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), this.exclusiveId);
|
|
6478
6483
|
if (!path)
|
|
6479
6484
|
return null;
|
|
6480
|
-
const node =
|
|
6485
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6481
6486
|
return node.type === "image" || node.type === "embed" ? { path, node } : null;
|
|
6482
6487
|
}
|
|
6483
6488
|
patchAttrs(patch) {
|
|
@@ -6500,14 +6505,14 @@ var ImageControls = (_class9 = class {
|
|
|
6500
6505
|
const ex = this.exclusiveId ? this.atomEl(this.exclusiveId) : null;
|
|
6501
6506
|
if (ex) {
|
|
6502
6507
|
const r = ex.getBoundingClientRect();
|
|
6503
|
-
kids.push(_preact.h.call(void 0, "div", { key: "box", class: "
|
|
6508
|
+
kids.push(_preact.h.call(void 0, "div", { key: "box", class: "markloom-ic-box", style: `left:${r.left}px;top:${r.top}px;width:${r.width}px;height:${r.height}px` }));
|
|
6504
6509
|
if (ex.getAttribute("data-atom") === "image") {
|
|
6505
6510
|
for (const corner of ["nw", "ne", "sw", "se"]) {
|
|
6506
6511
|
const x = corner === "nw" || corner === "sw" ? r.left : r.right;
|
|
6507
6512
|
const y = corner === "nw" || corner === "ne" ? r.top : r.bottom;
|
|
6508
6513
|
kids.push(_preact.h.call(void 0, "div", {
|
|
6509
6514
|
key: corner,
|
|
6510
|
-
class: `
|
|
6515
|
+
class: `markloom-ic-handle markloom-ic-${corner}`,
|
|
6511
6516
|
style: `left:${x}px;top:${y}px`,
|
|
6512
6517
|
onPointerDown: (ev) => this.startResize(ev, corner)
|
|
6513
6518
|
}));
|
|
@@ -6524,15 +6529,15 @@ var ImageControls = (_class9 = class {
|
|
|
6524
6529
|
const r = atom.getBoundingClientRect();
|
|
6525
6530
|
kids.push(_preact.h.call(void 0, "div", {
|
|
6526
6531
|
key: `r-${id}`,
|
|
6527
|
-
class: "
|
|
6532
|
+
class: "markloom-ic-box",
|
|
6528
6533
|
style: `left:${r.left}px;top:${r.top}px;width:${r.width}px;height:${r.height}px`
|
|
6529
6534
|
}));
|
|
6530
6535
|
}
|
|
6531
6536
|
if (this.lightbox)
|
|
6532
|
-
kids.push(_preact.h.call(void 0, "div", { key: "lb", class: "
|
|
6537
|
+
kids.push(_preact.h.call(void 0, "div", { key: "lb", class: "markloom-lightbox", onPointerDown: () => this.clearSelected() }, [
|
|
6533
6538
|
_preact.h.call(void 0, "img", { key: "lbimg", src: this.lightbox })
|
|
6534
6539
|
]));
|
|
6535
|
-
_preact.render.call(void 0, kids.length ? _preact.h.call(void 0, "div", { class: "
|
|
6540
|
+
_preact.render.call(void 0, kids.length ? _preact.h.call(void 0, "div", { class: "markloom-ic" }, kids) : null, this.overlay);
|
|
6536
6541
|
}
|
|
6537
6542
|
toolbar(r) {
|
|
6538
6543
|
const cur = _nullishCoalesce(_optionalChain([this, 'access', _236 => _236.blockNode, 'call', _237 => _237(), 'optionalAccess', _238 => _238.node, 'access', _239 => _239.attrs, 'optionalAccess', _240 => _240.align]), () => ( "left"));
|
|
@@ -6556,11 +6561,11 @@ var ImageControls = (_class9 = class {
|
|
|
6556
6561
|
} else this.patchAttrs({ align: a.value });
|
|
6557
6562
|
}
|
|
6558
6563
|
}, icon(a.ico, 14)));
|
|
6559
|
-
const row = [_preact.h.call(void 0, "div", { key: "row", class: "
|
|
6564
|
+
const row = [_preact.h.call(void 0, "div", { key: "row", class: "markloom-ic-tb-row" }, btns)];
|
|
6560
6565
|
if (this.editingCaption)
|
|
6561
6566
|
row.push(_preact.h.call(void 0, "input", {
|
|
6562
6567
|
"key": "capin",
|
|
6563
|
-
"class": "
|
|
6568
|
+
"class": "markloom-ic-tb-caption",
|
|
6564
6569
|
"type": "text",
|
|
6565
6570
|
"value": cap,
|
|
6566
6571
|
"placeholder": "\u56FE\u6CE8\u2026",
|
|
@@ -6576,7 +6581,7 @@ var ImageControls = (_class9 = class {
|
|
|
6576
6581
|
}
|
|
6577
6582
|
}
|
|
6578
6583
|
}));
|
|
6579
|
-
return _preact.h.call(void 0, "div", { key: "tb", class: "
|
|
6584
|
+
return _preact.h.call(void 0, "div", { key: "tb", class: "markloom-ic-tb", style: `left:${r.left}px;top:${r.top - 40}px` }, row);
|
|
6580
6585
|
}
|
|
6581
6586
|
startResize(down, corner) {
|
|
6582
6587
|
down.preventDefault();
|
|
@@ -6662,7 +6667,7 @@ var TableControls = (_class10 = class {
|
|
|
6662
6667
|
this.root = root;
|
|
6663
6668
|
this.host = host;
|
|
6664
6669
|
this.overlay = document.createElement("div");
|
|
6665
|
-
this.overlay.className = "
|
|
6670
|
+
this.overlay.className = "markloom-table-overlay";
|
|
6666
6671
|
document.body.appendChild(this.overlay);
|
|
6667
6672
|
document.addEventListener("selectionchange", this.onSelChange);
|
|
6668
6673
|
document.addEventListener("pointerdown", this.onDocDown, true);
|
|
@@ -6687,11 +6692,11 @@ var TableControls = (_class10 = class {
|
|
|
6687
6692
|
// 选中表的 model 块路径(供 atomBlockGuard 拿定位)。无选中 / 无 id → null。
|
|
6688
6693
|
selectedBlockPath() {
|
|
6689
6694
|
const id = _optionalChain([this, 'access', _256 => _256.selectedBlock, 'optionalAccess', _257 => _257.getAttribute, 'call', _258 => _258("data-block-id")]);
|
|
6690
|
-
return id ?
|
|
6695
|
+
return id ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), id) : null;
|
|
6691
6696
|
}
|
|
6692
6697
|
// 按 model 块 id 选中对应表格(供 atomSelectGuard:光标逼近表 → 先选中而非直删)。选中成功返 true。
|
|
6693
6698
|
selectByBlockId(id) {
|
|
6694
|
-
const el = this.root.querySelector(`.
|
|
6699
|
+
const el = this.root.querySelector(`.markloom-table[data-atom="table"][data-block-id="${id}"]`);
|
|
6695
6700
|
if (!el)
|
|
6696
6701
|
return false;
|
|
6697
6702
|
this.selectWhole(el);
|
|
@@ -6719,7 +6724,7 @@ var TableControls = (_class10 = class {
|
|
|
6719
6724
|
this.selectedBlock = null;
|
|
6720
6725
|
this.paint();
|
|
6721
6726
|
}
|
|
6722
|
-
// 几何:量出 cols+1 条列边界 / rows+1 条行边界的视口坐标。span 稳健——DOM 里 .
|
|
6727
|
+
// 几何:量出 cols+1 条列边界 / rows+1 条行边界的视口坐标。span 稳健——DOM 里 .markloom-cell 按
|
|
6723
6728
|
// buildGrid 锚点序 emit(命脉:1 child = 1 td),第 i 个 cell 对应 anchors[i] 的锚点足迹。
|
|
6724
6729
|
// 每格 rect 的 left/top 填其足迹起列/起行的边界,right/bottom 填终列+1/终行+1 的边界。
|
|
6725
6730
|
// 无 span 时退化成原来的均匀网格。cells 数 !== 锚点数 → null(DOM 未就绪)。
|
|
@@ -6727,12 +6732,12 @@ var TableControls = (_class10 = class {
|
|
|
6727
6732
|
const path = this.tablePath(tableEl);
|
|
6728
6733
|
if (!path)
|
|
6729
6734
|
return null;
|
|
6730
|
-
const table =
|
|
6731
|
-
if (
|
|
6735
|
+
const table = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6736
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, table) || table.type !== "table")
|
|
6732
6737
|
return null;
|
|
6733
|
-
const grid =
|
|
6738
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, table);
|
|
6734
6739
|
const { rows, cols } = grid;
|
|
6735
|
-
const cells = Array.from(tableEl.querySelectorAll(".
|
|
6740
|
+
const cells = Array.from(tableEl.querySelectorAll(".markloom-cell"));
|
|
6736
6741
|
if (cells.length !== grid.anchors.length || cols === 0)
|
|
6737
6742
|
return null;
|
|
6738
6743
|
const rect = tableEl.getBoundingClientRect();
|
|
@@ -6770,14 +6775,14 @@ var TableControls = (_class10 = class {
|
|
|
6770
6775
|
}
|
|
6771
6776
|
tablePath(tableEl) {
|
|
6772
6777
|
const id = tableEl.getAttribute("data-block-id");
|
|
6773
|
-
return id ?
|
|
6778
|
+
return id ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), id) : null;
|
|
6774
6779
|
}
|
|
6775
6780
|
tableModel(tableEl) {
|
|
6776
6781
|
const path = this.tablePath(tableEl);
|
|
6777
6782
|
if (!path)
|
|
6778
6783
|
return null;
|
|
6779
|
-
const t =
|
|
6780
|
-
return !
|
|
6784
|
+
const t = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6785
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, t) && t.type === "table" ? t : null;
|
|
6781
6786
|
}
|
|
6782
6787
|
// 焦点驱动:caret 落在某表格的 cell 内 → 该表控制柄常驻显示;焦点移出表格 → 收起。
|
|
6783
6788
|
// 不随鼠标 hover 进出闪现(飞书式:聚焦即常驻)。选中/菜单/拖拽进行中不因选区变动收起(柄操作会短暂夺焦)。
|
|
@@ -6797,14 +6802,14 @@ var TableControls = (_class10 = class {
|
|
|
6797
6802
|
this.paint();
|
|
6798
6803
|
}
|
|
6799
6804
|
}}
|
|
6800
|
-
// 当前 caret/选区落在哪个表格内(锚点 DOM 往上找 .
|
|
6805
|
+
// 当前 caret/选区落在哪个表格内(锚点 DOM 往上找 .markloom-table,且在本编辑器根内)。
|
|
6801
6806
|
focusedTable() {
|
|
6802
6807
|
const sel = document.getSelection();
|
|
6803
6808
|
const node = _optionalChain([sel, 'optionalAccess', _262 => _262.anchorNode]);
|
|
6804
6809
|
if (!node)
|
|
6805
6810
|
return null;
|
|
6806
6811
|
const el = node instanceof HTMLElement ? node : node.parentElement;
|
|
6807
|
-
const table = _optionalChain([el, 'optionalAccess', _263 => _263.closest, 'call', _264 => _264(".
|
|
6812
|
+
const table = _optionalChain([el, 'optionalAccess', _263 => _263.closest, 'call', _264 => _264(".markloom-table")]);
|
|
6808
6813
|
return table && this.root.contains(table) ? table : null;
|
|
6809
6814
|
}
|
|
6810
6815
|
__init76() {this.onReflow = () => {
|
|
@@ -6820,7 +6825,7 @@ var TableControls = (_class10 = class {
|
|
|
6820
6825
|
const path = this.tablePath(this.active);
|
|
6821
6826
|
if (rect && t && path) {
|
|
6822
6827
|
e.preventDefault();
|
|
6823
|
-
this.host.dispatch([
|
|
6828
|
+
this.host.dispatch([_chunk4TMHVNL6cjs.clearCells.call(void 0, t, path, rect)]);
|
|
6824
6829
|
this.sel = null;
|
|
6825
6830
|
this.menu = null;
|
|
6826
6831
|
this.applySelClasses();
|
|
@@ -6836,7 +6841,7 @@ var TableControls = (_class10 = class {
|
|
|
6836
6841
|
const t = this.tableModel(this.active);
|
|
6837
6842
|
if (!t)
|
|
6838
6843
|
return null;
|
|
6839
|
-
const { rows, cols } =
|
|
6844
|
+
const { rows, cols } = _chunk4TMHVNL6cjs.buildGrid.call(void 0, t);
|
|
6840
6845
|
if (sel.kind === "all")
|
|
6841
6846
|
return { r1: 0, c1: 0, r2: rows - 1, c2: cols - 1 };
|
|
6842
6847
|
if (sel.kind === "row")
|
|
@@ -6851,11 +6856,11 @@ var TableControls = (_class10 = class {
|
|
|
6851
6856
|
// 点在 active 表格某格内 + 拖动 → 画矩形选区(拖过 >1 格时抑制默认光标选择,松手出合并菜单)。
|
|
6852
6857
|
__init78() {this.onDocDown = (e) => {
|
|
6853
6858
|
const el = e.target instanceof HTMLElement ? e.target : null;
|
|
6854
|
-
if (_optionalChain([el, 'optionalAccess', _265 => _265.closest, 'call', _266 => _266(".
|
|
6859
|
+
if (_optionalChain([el, 'optionalAccess', _265 => _265.closest, 'call', _266 => _266(".markloom-table-overlay")]))
|
|
6855
6860
|
return;
|
|
6856
6861
|
if (this.selectedBlock)
|
|
6857
6862
|
this.clearSelected();
|
|
6858
|
-
const cellEl = _optionalChain([el, 'optionalAccess', _267 => _267.closest, 'call', _268 => _268(".
|
|
6863
|
+
const cellEl = _optionalChain([el, 'optionalAccess', _267 => _267.closest, 'call', _268 => _268(".markloom-cell")]);
|
|
6859
6864
|
const inActive = cellEl && this.active && this.active.contains(cellEl);
|
|
6860
6865
|
if (inActive) {
|
|
6861
6866
|
if (this.sel && this.sel.kind !== "rect") {
|
|
@@ -6929,7 +6934,7 @@ var TableControls = (_class10 = class {
|
|
|
6929
6934
|
const selected = tableEl === this.selectedBlock;
|
|
6930
6935
|
return _preact.h.call(void 0, "div", {
|
|
6931
6936
|
key: "grip",
|
|
6932
|
-
class: `
|
|
6937
|
+
class: `markloom-tc-grip${selected ? " is-selected" : ""}`,
|
|
6933
6938
|
style: `left:${r.left - 22}px;top:${r.top - 22}px`,
|
|
6934
6939
|
title: "\u9009\u4E2D/\u79FB\u52A8\u8868\u683C",
|
|
6935
6940
|
onPointerDown: (e) => {
|
|
@@ -6963,7 +6968,7 @@ var TableControls = (_class10 = class {
|
|
|
6963
6968
|
document.removeEventListener("pointermove", move);
|
|
6964
6969
|
document.removeEventListener("pointerup", up);
|
|
6965
6970
|
if (active2 && this.blockDrag) {
|
|
6966
|
-
const steps =
|
|
6971
|
+
const steps = _chunk4TMHVNL6cjs.moveBlock.call(void 0, this.host.doc(), fromIdx, this.blockDrag.gap);
|
|
6967
6972
|
if (steps.length) {
|
|
6968
6973
|
this.clearSelected();
|
|
6969
6974
|
this.host.dispatch(steps);
|
|
@@ -6975,9 +6980,9 @@ var TableControls = (_class10 = class {
|
|
|
6975
6980
|
document.addEventListener("pointermove", move);
|
|
6976
6981
|
document.addEventListener("pointerup", up);
|
|
6977
6982
|
}
|
|
6978
|
-
// 鼠标 y → 顶层块间缝下标(0..n)。遍历 .
|
|
6983
|
+
// 鼠标 y → 顶层块间缝下标(0..n)。遍历 .markloom-doc 结构子(elementChildren 穿透布局层),y 落某块上半 → 该块前缝,下半 → 后缝。
|
|
6979
6984
|
gapAtY(y) {
|
|
6980
|
-
const blocks =
|
|
6985
|
+
const blocks = _chunkSLRD6FMPcjs.elementChildren.call(void 0, _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root));
|
|
6981
6986
|
for (let i = 0; i < blocks.length; i++) {
|
|
6982
6987
|
const r = blocks[i].getBoundingClientRect();
|
|
6983
6988
|
if (y < (r.top + r.bottom) / 2)
|
|
@@ -6985,27 +6990,27 @@ var TableControls = (_class10 = class {
|
|
|
6985
6990
|
}
|
|
6986
6991
|
return blocks.length;
|
|
6987
6992
|
}
|
|
6988
|
-
// 块拖拽落点线:第 gap 条缝的 Y(缝上块底 / 首缝取首块顶 / 末缝取末块底),横向铺满 .
|
|
6993
|
+
// 块拖拽落点线:第 gap 条缝的 Y(缝上块底 / 首缝取首块顶 / 末缝取末块底),横向铺满 .markloom-doc 宽。复用 .markloom-tc-drop-row。
|
|
6989
6994
|
blockDropLine() {
|
|
6990
6995
|
if (!this.blockDrag)
|
|
6991
6996
|
return null;
|
|
6992
|
-
const docEl =
|
|
6993
|
-
const blocks =
|
|
6997
|
+
const docEl = _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root);
|
|
6998
|
+
const blocks = _chunkSLRD6FMPcjs.elementChildren.call(void 0, docEl);
|
|
6994
6999
|
const gap = this.blockDrag.gap;
|
|
6995
7000
|
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access', _276 => _276[0], 'optionalAccess', _277 => _277.getBoundingClientRect, 'call', _278 => _278(), 'access', _279 => _279.top]), () => ( 0)) : _nullishCoalesce(_optionalChain([blocks, 'access', _280 => _280[gap - 1], 'optionalAccess', _281 => _281.getBoundingClientRect, 'call', _282 => _282(), 'access', _283 => _283.bottom]), () => ( 0));
|
|
6996
7001
|
const box = docEl.getBoundingClientRect();
|
|
6997
|
-
return _preact.h.call(void 0, "div", { key: "drop", class: "
|
|
7002
|
+
return _preact.h.call(void 0, "div", { key: "drop", class: "markloom-tc-drop markloom-tc-drop-row", style: `top:${y}px;left:${box.left}px;width:${box.width}px` });
|
|
6998
7003
|
}
|
|
6999
7004
|
// 选中态写到 cell 的 data-selected(纯视图,主题给强高亮)。span 稳健:每格取其锚点足迹,
|
|
7000
7005
|
// 与 sel(行/列/全选/矩形)相交则选中。矩形按归一化区间判交(足迹与 rect 有重叠即选)。
|
|
7001
7006
|
applySelClasses() {
|
|
7002
7007
|
if (!this.active)
|
|
7003
7008
|
return;
|
|
7004
|
-
const cells = Array.from(this.active.querySelectorAll(".
|
|
7009
|
+
const cells = Array.from(this.active.querySelectorAll(".markloom-cell"));
|
|
7005
7010
|
const table = this.tableModel(this.active);
|
|
7006
7011
|
if (!table)
|
|
7007
7012
|
return;
|
|
7008
|
-
const grid =
|
|
7013
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, table);
|
|
7009
7014
|
if (cells.length !== grid.anchors.length)
|
|
7010
7015
|
return;
|
|
7011
7016
|
const rect = _optionalChain([this, 'access', _284 => _284.sel, 'optionalAccess', _285 => _285.kind]) === "rect" ? normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2) : null;
|
|
@@ -7034,8 +7039,8 @@ var TableControls = (_class10 = class {
|
|
|
7034
7039
|
return;
|
|
7035
7040
|
}
|
|
7036
7041
|
const r = this.selectedBlock.getBoundingClientRect();
|
|
7037
|
-
_preact.render.call(void 0, _preact.h.call(void 0, "div", { class: "
|
|
7038
|
-
_preact.h.call(void 0, "div", { key: "box", class: "
|
|
7042
|
+
_preact.render.call(void 0, _preact.h.call(void 0, "div", { class: "markloom-tc" }, [
|
|
7043
|
+
_preact.h.call(void 0, "div", { key: "box", class: "markloom-ic-box", style: `left:${r.left}px;top:${r.top}px;width:${r.width}px;height:${r.height}px` }),
|
|
7039
7044
|
this.grip(this.selectedBlock),
|
|
7040
7045
|
this.blockDropLine()
|
|
7041
7046
|
]), this.overlay);
|
|
@@ -7051,11 +7056,11 @@ var TableControls = (_class10 = class {
|
|
|
7051
7056
|
_preact.render.call(void 0, null, this.overlay);
|
|
7052
7057
|
return;
|
|
7053
7058
|
}
|
|
7054
|
-
const wrap = this.active.closest(".
|
|
7059
|
+
const wrap = this.active.closest(".markloom-table-scroll");
|
|
7055
7060
|
const clip = wrap ? wrap.getBoundingClientRect() : null;
|
|
7056
7061
|
const pad2 = Math.max(BAR, DOT_OUT + 12);
|
|
7057
7062
|
const clipStyle = clip ? `position:fixed;inset:0;clip-path:inset(${Math.max(0, clip.top - pad2)}px ${Math.max(0, window.innerWidth - clip.right)}px ${Math.max(0, window.innerHeight - clip.bottom)}px ${Math.max(0, clip.left - pad2)}px)` : void 0;
|
|
7058
|
-
_preact.render.call(void 0, _preact.h.call(void 0, "div", { class: "
|
|
7063
|
+
_preact.render.call(void 0, _preact.h.call(void 0, "div", { class: "markloom-tc", style: clipStyle }, [
|
|
7059
7064
|
...this.colHandles(g),
|
|
7060
7065
|
...this.rowHandles(g),
|
|
7061
7066
|
...this.insertDots(g),
|
|
@@ -7075,7 +7080,7 @@ var TableControls = (_class10 = class {
|
|
|
7075
7080
|
const edge = c === 0 ? " is-first" : c === g.cols - 1 ? " is-last" : "";
|
|
7076
7081
|
out.push(_preact.h.call(void 0, "div", {
|
|
7077
7082
|
key: `ch${c}`,
|
|
7078
|
-
class: `
|
|
7083
|
+
class: `markloom-tc-handle markloom-tc-col${selected ? " is-selected" : ""}${edge}`,
|
|
7079
7084
|
style: `left:${left}px;top:${g.rect.top - BAR}px;width:${w}px;height:${BAR}px`,
|
|
7080
7085
|
onPointerDown: (e) => this.startHandle(e, "col", c)
|
|
7081
7086
|
}));
|
|
@@ -7091,14 +7096,14 @@ var TableControls = (_class10 = class {
|
|
|
7091
7096
|
const edge = r === 0 ? " is-first" : r === g.rows - 1 ? " is-last" : "";
|
|
7092
7097
|
out.push(_preact.h.call(void 0, "div", {
|
|
7093
7098
|
key: `rh${r}`,
|
|
7094
|
-
class: `
|
|
7099
|
+
class: `markloom-tc-handle markloom-tc-row${selected ? " is-selected" : ""}${edge}`,
|
|
7095
7100
|
style: `top:${top}px;left:${g.rect.left - BAR}px;height:${ht}px;width:${BAR}px`,
|
|
7096
7101
|
onPointerDown: (e) => this.startHandle(e, "row", r)
|
|
7097
7102
|
}));
|
|
7098
7103
|
}
|
|
7099
7104
|
out.push(_preact.h.call(void 0, "div", {
|
|
7100
7105
|
key: "all",
|
|
7101
|
-
class: `
|
|
7106
|
+
class: `markloom-tc-handle markloom-tc-all${_optionalChain([this, 'access', _296 => _296.sel, 'optionalAccess', _297 => _297.kind]) === "all" ? " is-selected" : ""}`,
|
|
7102
7107
|
style: `top:${g.rect.top - BAR}px;left:${g.rect.left - BAR}px;width:${BAR}px;height:${BAR}px`,
|
|
7103
7108
|
onPointerDown: (e) => this.selectAll(e)
|
|
7104
7109
|
}));
|
|
@@ -7115,9 +7120,9 @@ var TableControls = (_class10 = class {
|
|
|
7115
7120
|
this.paint();
|
|
7116
7121
|
}
|
|
7117
7122
|
// 列/行边界插入点(抄 note AddColumnButton 的三层结构):
|
|
7118
|
-
// 容器 .
|
|
7119
|
-
// 视觉点 .
|
|
7120
|
-
// 引导线 .
|
|
7123
|
+
// 容器 .markloom-tc-ins —— 24px 常驻命中区(HIT),悬在表格外、圆心对准边界;承 click + :hover(group)。
|
|
7124
|
+
// 视觉点 .markloom-tc-dot —— 纯展示(pointer-events:none),静止 scale(.15)≈3.6px 灰点,容器 hover 时放大成蓝 ⊕。
|
|
7125
|
+
// 引导线 .markloom-tc-guide —— 从表边贯穿表身,容器 hover 时点亮。
|
|
7121
7126
|
// 命脉:hover 检测在 24px 容器上,不在缩小的圆点上——否则接触面只有 3.6px,几乎点不中(之前的 bug)。
|
|
7122
7127
|
insertDots(g) {
|
|
7123
7128
|
const out = [];
|
|
@@ -7126,31 +7131,31 @@ var TableControls = (_class10 = class {
|
|
|
7126
7131
|
for (let c = 0; c <= g.cols; c++) {
|
|
7127
7132
|
out.push(_preact.h.call(void 0, "div", {
|
|
7128
7133
|
key: `ci${c}`,
|
|
7129
|
-
class: "
|
|
7134
|
+
class: "markloom-tc-ins markloom-tc-ins-col",
|
|
7130
7135
|
style: `left:${g.colX[c] - HIT / 2}px;top:${insY}px;width:${HIT}px;height:${HIT}px`,
|
|
7131
7136
|
title: "\u63D2\u5165\u5217",
|
|
7132
7137
|
onPointerDown: (e) => this.insertAt(e, g.tableEl, "col", c)
|
|
7133
7138
|
}, [
|
|
7134
7139
|
_preact.h.call(void 0, "div", {
|
|
7135
|
-
class: "
|
|
7140
|
+
class: "markloom-tc-guide markloom-tc-guide-col",
|
|
7136
7141
|
style: `left:${g.colX[c]}px;top:${g.rect.top}px;height:${g.rect.height}px`
|
|
7137
7142
|
}),
|
|
7138
|
-
_preact.h.call(void 0, "div", { class: "
|
|
7143
|
+
_preact.h.call(void 0, "div", { class: "markloom-tc-dot markloom-tc-dot-col" })
|
|
7139
7144
|
]));
|
|
7140
7145
|
}
|
|
7141
7146
|
for (let r = 0; r <= g.rows; r++) {
|
|
7142
7147
|
out.push(_preact.h.call(void 0, "div", {
|
|
7143
7148
|
key: `ri${r}`,
|
|
7144
|
-
class: "
|
|
7149
|
+
class: "markloom-tc-ins markloom-tc-ins-row",
|
|
7145
7150
|
style: `top:${g.rowY[r] - HIT / 2}px;left:${insX}px;width:${HIT}px;height:${HIT}px`,
|
|
7146
7151
|
title: "\u63D2\u5165\u884C",
|
|
7147
7152
|
onPointerDown: (e) => this.insertAt(e, g.tableEl, "row", r)
|
|
7148
7153
|
}, [
|
|
7149
7154
|
_preact.h.call(void 0, "div", {
|
|
7150
|
-
class: "
|
|
7155
|
+
class: "markloom-tc-guide markloom-tc-guide-row",
|
|
7151
7156
|
style: `top:${g.rowY[r]}px;left:${g.rect.left}px;width:${g.rect.width}px`
|
|
7152
7157
|
}),
|
|
7153
|
-
_preact.h.call(void 0, "div", { class: "
|
|
7158
|
+
_preact.h.call(void 0, "div", { class: "markloom-tc-dot markloom-tc-dot-row" })
|
|
7154
7159
|
]));
|
|
7155
7160
|
}
|
|
7156
7161
|
return out;
|
|
@@ -7158,7 +7163,7 @@ var TableControls = (_class10 = class {
|
|
|
7158
7163
|
insertAt(e, tableEl, kind, at) {
|
|
7159
7164
|
e.preventDefault();
|
|
7160
7165
|
e.stopPropagation();
|
|
7161
|
-
this.op(tableEl, (t, p) => kind === "col" ?
|
|
7166
|
+
this.op(tableEl, (t, p) => kind === "col" ? _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, at) : _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, at));
|
|
7162
7167
|
}
|
|
7163
7168
|
// 列右边界的拖拽改宽手柄。table-layout:fixed + colgroup 下每列宽都显式(无 1fr 余量),
|
|
7164
7169
|
// 故最后一列也给柄——拖它即改表总宽(同飞书),与中间列同一套 startResize。
|
|
@@ -7167,7 +7172,7 @@ var TableControls = (_class10 = class {
|
|
|
7167
7172
|
for (let c = 0; c < g.cols; c++) {
|
|
7168
7173
|
out.push(_preact.h.call(void 0, "div", {
|
|
7169
7174
|
key: `rz${c}`,
|
|
7170
|
-
class: "
|
|
7175
|
+
class: "markloom-tc-resize",
|
|
7171
7176
|
style: `left:${g.colX[c + 1] - 3}px;top:${g.rect.top}px;height:${g.rect.height}px`,
|
|
7172
7177
|
onPointerDown: (e) => this.startResize(e, g, c)
|
|
7173
7178
|
}));
|
|
@@ -7179,10 +7184,10 @@ var TableControls = (_class10 = class {
|
|
|
7179
7184
|
return null;
|
|
7180
7185
|
if (this.drag.kind === "col") {
|
|
7181
7186
|
const x = g.colX[Math.min(this.drag.to, g.cols)];
|
|
7182
|
-
return _preact.h.call(void 0, "div", { key: "di", class: "
|
|
7187
|
+
return _preact.h.call(void 0, "div", { key: "di", class: "markloom-tc-drop markloom-tc-drop-col", style: `left:${x}px;top:${g.rect.top - BAR}px;height:${g.rect.height + BAR}px` });
|
|
7183
7188
|
}
|
|
7184
7189
|
const y = g.rowY[Math.min(this.drag.to, g.rows)];
|
|
7185
|
-
return _preact.h.call(void 0, "div", { key: "di", class: "
|
|
7190
|
+
return _preact.h.call(void 0, "div", { key: "di", class: "markloom-tc-drop markloom-tc-drop-row", style: `top:${y}px;left:${g.rect.left - BAR}px;width:${g.rect.width + BAR}px` });
|
|
7186
7191
|
}
|
|
7187
7192
|
// 柄菜单:增删行列/清空/合并拆分/样式/冻结。锚到选中柄或矩形左上附近。
|
|
7188
7193
|
menuEl(g) {
|
|
@@ -7193,7 +7198,7 @@ var TableControls = (_class10 = class {
|
|
|
7193
7198
|
const x = m.kind === "col" ? g.colX[m.index] : m.kind === "rect" ? g.colX[rect ? rect.c1 : 0] : g.rect.left - BAR;
|
|
7194
7199
|
const y = m.kind === "col" ? g.rect.top - BAR : m.kind === "rect" ? g.rowY[rect ? rect.r2 + 1 : 0] : g.rowY[m.index];
|
|
7195
7200
|
const labels = this.menuLabels(m);
|
|
7196
|
-
return _preact.h.call(void 0, "div", { key: "menu", class: "
|
|
7201
|
+
return _preact.h.call(void 0, "div", { key: "menu", class: "markloom-tc-menu", style: `left:${x}px;top:${y}px` }, labels.map((label, i) => _preact.h.call(void 0, "button", {
|
|
7197
7202
|
key: i,
|
|
7198
7203
|
type: "button",
|
|
7199
7204
|
onPointerDown: (e) => this.clickMenu(e, g, m, i)
|
|
@@ -7216,33 +7221,33 @@ var TableControls = (_class10 = class {
|
|
|
7216
7221
|
runMenu(g, m, i) {
|
|
7217
7222
|
if (m.kind === "col") {
|
|
7218
7223
|
if (i === 0)
|
|
7219
|
-
this.op(g.tableEl, (t, p) =>
|
|
7224
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, m.index));
|
|
7220
7225
|
else if (i === 1)
|
|
7221
|
-
this.op(g.tableEl, (t, p) =>
|
|
7226
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, m.index + 1));
|
|
7222
7227
|
else if (i === 2)
|
|
7223
|
-
this.op(g.tableEl, (t, p) =>
|
|
7228
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.deleteCol.call(void 0, t, p, m.index, this.host.doc()));
|
|
7224
7229
|
else {
|
|
7225
7230
|
const a = i === 3 ? "left" : i === 4 ? "center" : "right";
|
|
7226
|
-
this.op(g.tableEl, (t, p) =>
|
|
7231
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setAlign.call(void 0, t, p, m.index, a));
|
|
7227
7232
|
}
|
|
7228
7233
|
} else if (m.kind === "row") {
|
|
7229
7234
|
if (i === 0)
|
|
7230
|
-
this.op(g.tableEl, (t, p) =>
|
|
7235
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, m.index));
|
|
7231
7236
|
else if (i === 1)
|
|
7232
|
-
this.op(g.tableEl, (t, p) =>
|
|
7233
|
-
else this.op(g.tableEl, (t, p) =>
|
|
7237
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, m.index + 1));
|
|
7238
|
+
else this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.deleteRow.call(void 0, t, p, m.index, this.host.doc()));
|
|
7234
7239
|
} else if (m.kind === "rect") {
|
|
7235
7240
|
this.runRectMenu(g, i);
|
|
7236
7241
|
} else {
|
|
7237
7242
|
if (i === 0)
|
|
7238
|
-
this.op(g.tableEl, (_t, p) =>
|
|
7243
|
+
this.op(g.tableEl, (_t, p) => _chunk4TMHVNL6cjs.deleteTableBlock.call(void 0, p, this.host.doc()));
|
|
7239
7244
|
else if (i === 1)
|
|
7240
|
-
this.op(g.tableEl, (t, p) =>
|
|
7245
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { rows: 1 }));
|
|
7241
7246
|
else if (i === 2)
|
|
7242
|
-
this.op(g.tableEl, (t, p) =>
|
|
7247
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { rows: 0 }));
|
|
7243
7248
|
else if (i === 3)
|
|
7244
|
-
this.op(g.tableEl, (t, p) =>
|
|
7245
|
-
else this.op(g.tableEl, (t, p) =>
|
|
7249
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { cols: 1 }));
|
|
7250
|
+
else this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { cols: 0 }));
|
|
7246
7251
|
}
|
|
7247
7252
|
this.menu = null;
|
|
7248
7253
|
}
|
|
@@ -7252,9 +7257,9 @@ var TableControls = (_class10 = class {
|
|
|
7252
7257
|
return;
|
|
7253
7258
|
const rr = normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2);
|
|
7254
7259
|
if (i === 0)
|
|
7255
|
-
this.op(g.tableEl, (t, p) =>
|
|
7260
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.mergeCells.call(void 0, t, p, rr.r1, rr.c1, rr.r2, rr.c2));
|
|
7256
7261
|
else if (i === 1)
|
|
7257
|
-
this.op(g.tableEl, (t, p) =>
|
|
7262
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.splitCell.call(void 0, t, p, rr.r1, rr.c1));
|
|
7258
7263
|
else if (i === 2) {
|
|
7259
7264
|
void askInput({
|
|
7260
7265
|
title: "\u5355\u5143\u683C\u80CC\u666F\u8272",
|
|
@@ -7263,10 +7268,10 @@ var TableControls = (_class10 = class {
|
|
|
7263
7268
|
confirmLabel: "\u5E94\u7528"
|
|
7264
7269
|
}).then((bg) => {
|
|
7265
7270
|
if (bg)
|
|
7266
|
-
this.op(g.tableEl, (t, p) =>
|
|
7271
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { bg }));
|
|
7267
7272
|
});
|
|
7268
7273
|
} else if (i === 3) {
|
|
7269
|
-
this.op(g.tableEl, (t, p) =>
|
|
7274
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { bg: null }));
|
|
7270
7275
|
} else if (i === 4) {
|
|
7271
7276
|
void askInput({
|
|
7272
7277
|
title: "\u5355\u5143\u683C\u8FB9\u6846\u8272",
|
|
@@ -7275,10 +7280,10 @@ var TableControls = (_class10 = class {
|
|
|
7275
7280
|
confirmLabel: "\u5E94\u7528"
|
|
7276
7281
|
}).then((border) => {
|
|
7277
7282
|
if (border)
|
|
7278
|
-
this.op(g.tableEl, (t, p) =>
|
|
7283
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { border }));
|
|
7279
7284
|
});
|
|
7280
7285
|
} else {
|
|
7281
|
-
this.op(g.tableEl, (t, p) =>
|
|
7286
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { border: null }));
|
|
7282
7287
|
}
|
|
7283
7288
|
}
|
|
7284
7289
|
// 按下行/列柄:暂不动,装 document 监听。位移超阈值 → 进拖拽重排;否则松手当点击(选中 + 双击式开菜单)。
|
|
@@ -7311,7 +7316,7 @@ var TableControls = (_class10 = class {
|
|
|
7311
7316
|
const { from, to } = this.drag;
|
|
7312
7317
|
const dest = to > from ? to - 1 : to;
|
|
7313
7318
|
if (dest !== from && !(kind === "row" && from === 0))
|
|
7314
|
-
this.op(this.active, (t, p) => kind === "col" ?
|
|
7319
|
+
this.op(this.active, (t, p) => kind === "col" ? _chunk4TMHVNL6cjs.moveCol.call(void 0, t, p, from, dest) : _chunk4TMHVNL6cjs.moveRow.call(void 0, t, p, from, dest));
|
|
7315
7320
|
this.drag = null;
|
|
7316
7321
|
this.paint();
|
|
7317
7322
|
} else {
|
|
@@ -7344,7 +7349,7 @@ var TableControls = (_class10 = class {
|
|
|
7344
7349
|
const startW = g.colX[col + 1] - g.colX[col];
|
|
7345
7350
|
this.resize = { col, startX: e.clientX, startW };
|
|
7346
7351
|
const tableEl = g.tableEl;
|
|
7347
|
-
const widths = (_nullishCoalesce(
|
|
7352
|
+
const widths = (_nullishCoalesce(_chunk4TMHVNL6cjs.tableColWidths.call(void 0, this.tableModel(tableEl)), () => ( this.measuredWidths(g)))).slice();
|
|
7348
7353
|
const colEls = Array.from(tableEl.querySelectorAll(":scope > colgroup > col"));
|
|
7349
7354
|
const move = (ev) => {
|
|
7350
7355
|
const next = Math.max(40, startW + (ev.clientX - this.resize.startX));
|
|
@@ -7358,7 +7363,7 @@ var TableControls = (_class10 = class {
|
|
|
7358
7363
|
document.removeEventListener("pointermove", move);
|
|
7359
7364
|
document.removeEventListener("pointerup", up);
|
|
7360
7365
|
this.resize = null;
|
|
7361
|
-
this.op(tableEl, (t, p) =>
|
|
7366
|
+
this.op(tableEl, (t, p) => _chunk4TMHVNL6cjs.setColWidths.call(void 0, t, p, widths));
|
|
7362
7367
|
};
|
|
7363
7368
|
document.addEventListener("pointermove", move);
|
|
7364
7369
|
document.addEventListener("pointerup", up);
|
|
@@ -7397,12 +7402,15 @@ var Editor = (_class11 = class {
|
|
|
7397
7402
|
|
|
7398
7403
|
/** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
|
|
7399
7404
|
__init85() {this.aiCtl = null}
|
|
7400
|
-
|
|
7405
|
+
/** 协作会话;applyingRemote 期间本地 steps 不上行 */
|
|
7406
|
+
__init86() {this.collabCtl = null}
|
|
7407
|
+
__init87() {this.applyingRemote = false}
|
|
7408
|
+
constructor(root, doc, opts = {}) {;_class11.prototype.__init79.call(this);_class11.prototype.__init80.call(this);_class11.prototype.__init81.call(this);_class11.prototype.__init82.call(this);_class11.prototype.__init83.call(this);_class11.prototype.__init84.call(this);_class11.prototype.__init85.call(this);_class11.prototype.__init86.call(this);_class11.prototype.__init87.call(this);_class11.prototype.__init88.call(this);_class11.prototype.__init89.call(this);_class11.prototype.__init90.call(this);_class11.prototype.__init91.call(this);_class11.prototype.__init92.call(this);_class11.prototype.__init93.call(this);_class11.prototype.__init94.call(this);_class11.prototype.__init95.call(this);_class11.prototype.__init96.call(this);_class11.prototype.__init97.call(this);_class11.prototype.__init98.call(this);_class11.prototype.__init99.call(this);_class11.prototype.__init100.call(this);_class11.prototype.__init101.call(this);_class11.prototype.__init102.call(this);_class11.prototype.__init103.call(this);
|
|
7401
7409
|
this.root = root;
|
|
7402
7410
|
const dev = typeof process !== "undefined" && _optionalChain([process, 'access', _371 => _371.env, 'optionalAccess', _372 => _372.NODE_ENV]) !== "production";
|
|
7403
|
-
this.history =
|
|
7411
|
+
this.history = _chunkYXQDCW4Ycjs.init.call(void 0, ensureGaps(doc), dev ? (d) => _chunkYXQDCW4Ycjs.firstViolation.call(void 0, _chunkYXQDCW4Ycjs.invariants.call(void 0, _chunk4TMHVNL6cjs.basicSchema, d)) : void 0);
|
|
7404
7412
|
this.opts = opts;
|
|
7405
|
-
const exts = _nullishCoalesce(opts.extensions, () => (
|
|
7413
|
+
const exts = _nullishCoalesce(opts.extensions, () => ( markloomKit()));
|
|
7406
7414
|
this.resolved = resolve(exts);
|
|
7407
7415
|
this.invisible = _nullishCoalesce(opts.invisibleCharacters, () => ( exts.some((e) => e.name === "invisibleCharacters")));
|
|
7408
7416
|
root.contentEditable = opts.editable === false ? "false" : "true";
|
|
@@ -7422,9 +7430,9 @@ var Editor = (_class11 = class {
|
|
|
7422
7430
|
this.imageControls = new ImageControls(root, {
|
|
7423
7431
|
doc: () => this.history.doc,
|
|
7424
7432
|
dispatch: (steps) => this.dispatch(steps),
|
|
7425
|
-
sel: () =>
|
|
7433
|
+
sel: () => _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc),
|
|
7426
7434
|
// atomSelect 变 → 重投影 data-selected(与 commentState 同构传 render)
|
|
7427
|
-
onAtomSelectChange: () => this.draw(_nullishCoalesce(
|
|
7435
|
+
onAtomSelectChange: () => this.draw(_nullishCoalesce(_chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0)))
|
|
7428
7436
|
});
|
|
7429
7437
|
this.mentionPops = new MentionPopovers({
|
|
7430
7438
|
root,
|
|
@@ -7440,7 +7448,7 @@ var Editor = (_class11 = class {
|
|
|
7440
7448
|
markSel: () => this.markSel(),
|
|
7441
7449
|
author: _nullishCoalesce(_optionalChain([opts, 'access', _376 => _376.comments, 'optionalAccess', _377 => _377.author]), () => ( (() => ({ id: "me", name: "\u6211" })))),
|
|
7442
7450
|
newId: newId3,
|
|
7443
|
-
redraw: () => this.draw(_nullishCoalesce(
|
|
7451
|
+
redraw: () => this.draw(_nullishCoalesce(_chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0))),
|
|
7444
7452
|
onChange: _optionalChain([opts, 'access', _378 => _378.comments, 'optionalAccess', _379 => _379.onChange]),
|
|
7445
7453
|
readonly: () => this.readonly
|
|
7446
7454
|
}, _nullishCoalesce(_optionalChain([opts, 'access', _380 => _380.comments, 'optionalAccess', _381 => _381.threads]), () => ( [])));
|
|
@@ -7452,8 +7460,8 @@ var Editor = (_class11 = class {
|
|
|
7452
7460
|
}
|
|
7453
7461
|
if (opts.ai) {
|
|
7454
7462
|
const cfg = typeof opts.ai === "object" ? opts.ai : {};
|
|
7455
|
-
this.aiCtl = new (0,
|
|
7456
|
-
stream:
|
|
7463
|
+
this.aiCtl = new (0, _chunkSLRD6FMPcjs.MarkloomAi)(() => this, {
|
|
7464
|
+
stream: _chunkSLRD6FMPcjs.createAiStream.call(void 0, cfg),
|
|
7457
7465
|
onError: _nullishCoalesce(cfg.onError, () => ( ((msg) => {
|
|
7458
7466
|
if (typeof window !== "undefined")
|
|
7459
7467
|
window.alert(msg);
|
|
@@ -7461,11 +7469,24 @@ var Editor = (_class11 = class {
|
|
|
7461
7469
|
onBusy: cfg.onBusy
|
|
7462
7470
|
});
|
|
7463
7471
|
}
|
|
7472
|
+
if (opts.collab) {
|
|
7473
|
+
this.collabCtl = _chunkAC5E42NHcjs.connectCollab.call(void 0,
|
|
7474
|
+
{ ...opts.collab, seed: _nullishCoalesce(opts.collab.seed, () => ( doc)) },
|
|
7475
|
+
{
|
|
7476
|
+
onDoc: (d) => this.replaceDoc(d),
|
|
7477
|
+
onRemote: (steps) => this.applyRemote(steps),
|
|
7478
|
+
onError: (msg) => {
|
|
7479
|
+
if (typeof console !== "undefined")
|
|
7480
|
+
console.warn("[markloom collab]", msg);
|
|
7481
|
+
}
|
|
7482
|
+
}
|
|
7483
|
+
);
|
|
7484
|
+
}
|
|
7464
7485
|
const host = {
|
|
7465
7486
|
root,
|
|
7466
7487
|
doc: () => this.history.doc,
|
|
7467
7488
|
dispatch: (steps, sel) => this.dispatch(steps, sel),
|
|
7468
|
-
sel: () =>
|
|
7489
|
+
sel: () => _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc),
|
|
7469
7490
|
markSel: () => this.markSel(),
|
|
7470
7491
|
insertImage: (idx) => this.slashInsertImage(idx),
|
|
7471
7492
|
insertMath: (idx) => this.slashInsertMath(idx),
|
|
@@ -7526,6 +7547,8 @@ var Editor = (_class11 = class {
|
|
|
7526
7547
|
_optionalChain([this, 'access', _393 => _393.commentPanel, 'optionalAccess', _394 => _394.destroy, 'call', _395 => _395()]);
|
|
7527
7548
|
_optionalChain([this, 'access', _396 => _396.tocPanel, 'optionalAccess', _397 => _397.destroy, 'call', _398 => _398()]);
|
|
7528
7549
|
_optionalChain([this, 'access', _399 => _399.aiCtl, 'optionalAccess', _400 => _400.destroy, 'call', _401 => _401()]);
|
|
7550
|
+
_optionalChain([this, 'access', _402 => _402.collabCtl, 'optionalAccess', _403 => _403.close, 'call', _404 => _404()]);
|
|
7551
|
+
this.collabCtl = null;
|
|
7529
7552
|
this.aiCtl = null;
|
|
7530
7553
|
for (const d of this.decorations)
|
|
7531
7554
|
d.destroy();
|
|
@@ -7535,11 +7558,15 @@ var Editor = (_class11 = class {
|
|
|
7535
7558
|
get ai() {
|
|
7536
7559
|
return this.aiCtl;
|
|
7537
7560
|
}
|
|
7561
|
+
/** 协作客户端(opts.collab 启用时) */
|
|
7562
|
+
get collab() {
|
|
7563
|
+
return this.collabCtl;
|
|
7564
|
+
}
|
|
7538
7565
|
openAi(mode) {
|
|
7539
|
-
_optionalChain([this, 'access',
|
|
7566
|
+
_optionalChain([this, 'access', _405 => _405.aiCtl, 'optionalAccess', _406 => _406.openAtFocus, 'call', _407 => _407(mode)]);
|
|
7540
7567
|
}
|
|
7541
7568
|
stopAi() {
|
|
7542
|
-
_optionalChain([this, 'access',
|
|
7569
|
+
_optionalChain([this, 'access', _408 => _408.aiCtl, 'optionalAccess', _409 => _409.stop, 'call', _410 => _410()]);
|
|
7543
7570
|
}
|
|
7544
7571
|
get doc() {
|
|
7545
7572
|
return this.history.doc;
|
|
@@ -7552,17 +7579,17 @@ var Editor = (_class11 = class {
|
|
|
7552
7579
|
// 运行时切显隐符(tiptap show/hide/toggleInvisibleCharacters 对位)。纯重绘,model 不动。
|
|
7553
7580
|
setInvisibleCharacters(visible) {
|
|
7554
7581
|
this.invisible = visible;
|
|
7555
|
-
this.draw(_nullishCoalesce(
|
|
7582
|
+
this.draw(_nullishCoalesce(_chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0)));
|
|
7556
7583
|
}
|
|
7557
7584
|
get invisibleCharacters() {
|
|
7558
7585
|
return this.invisible;
|
|
7559
7586
|
}
|
|
7560
7587
|
// 当前评论线程(侧信道);未启用评论时空数组。
|
|
7561
7588
|
get comments() {
|
|
7562
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
7589
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _411 => _411.commentPanel, 'optionalAccess', _412 => _412.getThreads, 'call', _413 => _413()]), () => ( []));
|
|
7563
7590
|
}
|
|
7564
7591
|
setComments(threads) {
|
|
7565
|
-
_optionalChain([this, 'access',
|
|
7592
|
+
_optionalChain([this, 'access', _414 => _414.commentPanel, 'optionalAccess', _415 => _415.setThreads, 'call', _416 => _416(threads)]);
|
|
7566
7593
|
}
|
|
7567
7594
|
get readonly() {
|
|
7568
7595
|
return this.opts.editable === false;
|
|
@@ -7580,28 +7607,28 @@ var Editor = (_class11 = class {
|
|
|
7580
7607
|
blockRenderers: this.resolved.blockRenderers,
|
|
7581
7608
|
renderMath: this.opts.renderMath,
|
|
7582
7609
|
invisibleCharacters: this.invisible,
|
|
7583
|
-
commentState: _optionalChain([this, 'access',
|
|
7610
|
+
commentState: _optionalChain([this, 'access', _417 => _417.commentPanel, 'optionalAccess', _418 => _418.renderState, 'call', _419 => _419()]),
|
|
7584
7611
|
atomSelect: this.imageControls.selectCtx()
|
|
7585
7612
|
}), this.root);
|
|
7586
|
-
stripStrayNodes(this.root.querySelector(".
|
|
7613
|
+
stripStrayNodes(this.root.querySelector(".markloom-doc"));
|
|
7587
7614
|
if (restore)
|
|
7588
|
-
|
|
7589
|
-
this.root.dispatchEvent(new Event("
|
|
7615
|
+
_chunkSLRD6FMPcjs.writeSelection.call(void 0, this.root, this.history.doc, restore);
|
|
7616
|
+
this.root.dispatchEvent(new Event("markloom-redraw", { bubbles: true }));
|
|
7590
7617
|
this.syncPlaceholder();
|
|
7591
7618
|
}
|
|
7592
7619
|
// 空块提示(不进 model):空 paragraph → opts.placeholder(slash 引导);
|
|
7593
7620
|
// 空 heading → 类型名 H1…H6(飞书/Notion 式)。空文档常显;光标落空块时也显。
|
|
7594
|
-
|
|
7621
|
+
__init88() {this.syncPlaceholder = () => {
|
|
7595
7622
|
if (this.composing || this.readonly)
|
|
7596
7623
|
return;
|
|
7597
|
-
const docEl =
|
|
7624
|
+
const docEl = _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root);
|
|
7598
7625
|
for (const el2 of docEl.querySelectorAll("[data-placeholder]"))
|
|
7599
7626
|
el2.removeAttribute("data-placeholder");
|
|
7600
7627
|
const kids = this.history.doc.children;
|
|
7601
|
-
const isEmptyLeafBlock = (n, type) => !
|
|
7628
|
+
const isEmptyLeafBlock = (n, type) => !_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.type === type && n.children.length > 0 && n.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text === "");
|
|
7602
7629
|
const labelOf = (n) => {
|
|
7603
7630
|
if (n.type === "heading") {
|
|
7604
|
-
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
7631
|
+
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access', _420 => _420.attrs, 'optionalAccess', _421 => _421.depth]), () => ( 1))), 1), 6);
|
|
7605
7632
|
return `H${d}`;
|
|
7606
7633
|
}
|
|
7607
7634
|
if (n.type === "paragraph" && this.opts.placeholder)
|
|
@@ -7610,7 +7637,7 @@ var Editor = (_class11 = class {
|
|
|
7610
7637
|
};
|
|
7611
7638
|
let idx = null;
|
|
7612
7639
|
let text = null;
|
|
7613
|
-
if (kids.length === 1 && !
|
|
7640
|
+
if (kids.length === 1 && !_chunkGQ2HHRGIcjs.isText.call(void 0, kids[0])) {
|
|
7614
7641
|
const lab = labelOf(kids[0]);
|
|
7615
7642
|
if (lab && (isEmptyLeafBlock(kids[0], "paragraph") || isEmptyLeafBlock(kids[0], "heading"))) {
|
|
7616
7643
|
idx = 0;
|
|
@@ -7618,7 +7645,7 @@ var Editor = (_class11 = class {
|
|
|
7618
7645
|
}
|
|
7619
7646
|
}
|
|
7620
7647
|
if (idx == null) {
|
|
7621
|
-
const sel =
|
|
7648
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7622
7649
|
if (sel) {
|
|
7623
7650
|
const a = sel.anchor.path;
|
|
7624
7651
|
const h13 = sel.head.path;
|
|
@@ -7626,7 +7653,7 @@ var Editor = (_class11 = class {
|
|
|
7626
7653
|
if (collapsed) {
|
|
7627
7654
|
const i = a[0];
|
|
7628
7655
|
const b = kids[i];
|
|
7629
|
-
if (b && !
|
|
7656
|
+
if (b && !_chunkGQ2HHRGIcjs.isText.call(void 0, b)) {
|
|
7630
7657
|
const lab = labelOf(b);
|
|
7631
7658
|
if (lab && (isEmptyLeafBlock(b, "paragraph") || isEmptyLeafBlock(b, "heading"))) {
|
|
7632
7659
|
idx = i;
|
|
@@ -7638,75 +7665,107 @@ var Editor = (_class11 = class {
|
|
|
7638
7665
|
}
|
|
7639
7666
|
if (idx == null || text == null)
|
|
7640
7667
|
return;
|
|
7641
|
-
const el =
|
|
7668
|
+
const el = _chunkSLRD6FMPcjs.elementChildren.call(void 0, docEl)[idx];
|
|
7642
7669
|
if (el)
|
|
7643
7670
|
el.setAttribute("data-placeholder", text);
|
|
7644
7671
|
}}
|
|
7645
7672
|
dispatch(steps, selectionAfter) {
|
|
7646
7673
|
if (steps.length === 0)
|
|
7647
7674
|
return;
|
|
7648
|
-
const after =
|
|
7675
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7649
7676
|
const batch = steps.concat(gapSteps(after));
|
|
7650
|
-
this.history =
|
|
7677
|
+
this.history = _chunkYXQDCW4Ycjs.commit.call(void 0, this.history, batch);
|
|
7651
7678
|
this.draw(selectionAfter);
|
|
7652
|
-
_optionalChain([this, 'access',
|
|
7679
|
+
_optionalChain([this, 'access', _422 => _422.opts, 'access', _423 => _423.onChange, 'optionalCall', _424 => _424(this.history.doc)]);
|
|
7680
|
+
if (!this.applyingRemote)
|
|
7681
|
+
_optionalChain([this, 'access', _425 => _425.collabCtl, 'optionalAccess', _426 => _426.push, 'call', _427 => _427(batch)]);
|
|
7653
7682
|
}
|
|
7654
7683
|
// AI 流式 / 事务内续写:并入 past 最后一条,一次 undo 回退整笔事务。
|
|
7655
7684
|
dispatchStream(steps, selectionAfter) {
|
|
7656
7685
|
if (steps.length === 0)
|
|
7657
7686
|
return;
|
|
7658
|
-
const after =
|
|
7687
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7659
7688
|
const batch = steps.concat(gapSteps(after));
|
|
7660
|
-
this.history =
|
|
7689
|
+
this.history = _chunkYXQDCW4Ycjs.amend.call(void 0, this.history, batch);
|
|
7661
7690
|
this.draw(selectionAfter);
|
|
7662
|
-
_optionalChain([this, 'access',
|
|
7691
|
+
_optionalChain([this, 'access', _428 => _428.opts, 'access', _429 => _429.onChange, 'optionalCall', _430 => _430(this.history.doc)]);
|
|
7692
|
+
if (!this.applyingRemote)
|
|
7693
|
+
_optionalChain([this, 'access', _431 => _431.collabCtl, 'optionalAccess', _432 => _432.push, 'call', _433 => _433(batch)]);
|
|
7694
|
+
}
|
|
7695
|
+
/** 远端协作 op:写入 model 但不上行 */
|
|
7696
|
+
applyRemote(steps, selectionAfter) {
|
|
7697
|
+
if (steps.length === 0)
|
|
7698
|
+
return;
|
|
7699
|
+
this.applyingRemote = true;
|
|
7700
|
+
try {
|
|
7701
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7702
|
+
const batch = steps.concat(gapSteps(after));
|
|
7703
|
+
this.history = _chunkYXQDCW4Ycjs.commit.call(void 0, this.history, batch);
|
|
7704
|
+
this.draw(selectionAfter);
|
|
7705
|
+
_optionalChain([this, 'access', _434 => _434.opts, 'access', _435 => _435.onChange, 'optionalCall', _436 => _436(this.history.doc)]);
|
|
7706
|
+
} finally {
|
|
7707
|
+
this.applyingRemote = false;
|
|
7708
|
+
}
|
|
7709
|
+
}
|
|
7710
|
+
/** 权威快照替换(welcome/resync);清空本地 undo 栈 */
|
|
7711
|
+
replaceDoc(doc) {
|
|
7712
|
+
const dev = typeof process !== "undefined" && _optionalChain([process, 'access', _437 => _437.env, 'optionalAccess', _438 => _438.NODE_ENV]) !== "production";
|
|
7713
|
+
this.history = _chunkYXQDCW4Ycjs.init.call(void 0, ensureGaps(doc), dev ? (d) => _chunkYXQDCW4Ycjs.firstViolation.call(void 0, _chunkYXQDCW4Ycjs.invariants.call(void 0, _chunk4TMHVNL6cjs.basicSchema, d)) : void 0);
|
|
7714
|
+
this.draw();
|
|
7715
|
+
_optionalChain([this, 'access', _439 => _439.opts, 'access', _440 => _440.onChange, 'optionalCall', _441 => _441(this.history.doc)]);
|
|
7663
7716
|
}
|
|
7664
7717
|
/** 回退一笔 history(AI 事务 discard = undo 整笔) */
|
|
7665
7718
|
undo() {
|
|
7666
|
-
const
|
|
7719
|
+
const last = this.history.past[this.history.past.length - 1];
|
|
7720
|
+
const next = _chunkYXQDCW4Ycjs.undo.call(void 0, this.history);
|
|
7667
7721
|
if (next === this.history)
|
|
7668
7722
|
return false;
|
|
7669
7723
|
this.history = next;
|
|
7670
7724
|
this.draw();
|
|
7671
|
-
_optionalChain([this, 'access',
|
|
7725
|
+
_optionalChain([this, 'access', _442 => _442.opts, 'access', _443 => _443.onChange, 'optionalCall', _444 => _444(this.history.doc)]);
|
|
7726
|
+
if (!this.applyingRemote && last)
|
|
7727
|
+
_optionalChain([this, 'access', _445 => _445.collabCtl, 'optionalAccess', _446 => _446.push, 'call', _447 => _447(last.inverse)]);
|
|
7672
7728
|
return true;
|
|
7673
7729
|
}
|
|
7674
7730
|
redo() {
|
|
7675
|
-
const
|
|
7731
|
+
const fut = this.history.future[0];
|
|
7732
|
+
const next = _chunkYXQDCW4Ycjs.redo.call(void 0, this.history);
|
|
7676
7733
|
if (next === this.history)
|
|
7677
7734
|
return false;
|
|
7678
7735
|
this.history = next;
|
|
7679
7736
|
this.draw();
|
|
7680
|
-
_optionalChain([this, 'access',
|
|
7737
|
+
_optionalChain([this, 'access', _448 => _448.opts, 'access', _449 => _449.onChange, 'optionalCall', _450 => _450(this.history.doc)]);
|
|
7738
|
+
if (!this.applyingRemote && fut)
|
|
7739
|
+
_optionalChain([this, 'access', _451 => _451.collabCtl, 'optionalAccess', _452 => _452.push, 'call', _453 => _453(fut.steps)]);
|
|
7681
7740
|
return true;
|
|
7682
7741
|
}
|
|
7683
7742
|
/** 续写:当前块后插空段并流式灌入 */
|
|
7684
7743
|
aiContinue(blockId) {
|
|
7685
|
-
return
|
|
7744
|
+
return _chunkSLRD6FMPcjs.startAiWrite.call(void 0, this, "continue", blockId);
|
|
7686
7745
|
}
|
|
7687
7746
|
/** 改写:清空当前块再流式回填 */
|
|
7688
7747
|
aiRewrite(blockId) {
|
|
7689
|
-
return
|
|
7748
|
+
return _chunkSLRD6FMPcjs.startAiWrite.call(void 0, this, "rewrite", blockId);
|
|
7690
7749
|
}
|
|
7691
7750
|
// 组字开始:快照「这一刻的叶文本」作为 3-way merge 的 base。
|
|
7692
7751
|
// IME 改动 = diff(base, DOM落定文本);AI 并发改动 = diff(base, model现态)。两者都相对 base。
|
|
7693
|
-
|
|
7752
|
+
__init89() {this.onCompositionStart = () => {
|
|
7694
7753
|
this.composing = true;
|
|
7695
|
-
const sel =
|
|
7754
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7696
7755
|
if (!sel) {
|
|
7697
7756
|
this.composeBase = null;
|
|
7698
7757
|
return;
|
|
7699
7758
|
}
|
|
7700
7759
|
const leafPath = sel.head.path.slice(0, -1);
|
|
7701
|
-
const leaf =
|
|
7702
|
-
this.composeBase = { leafPath, text:
|
|
7760
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, leafPath);
|
|
7761
|
+
this.composeBase = { leafPath, text: _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "" };
|
|
7703
7762
|
}}
|
|
7704
7763
|
// task 勾选:独立 capture 处理器(见 onTaskCheck)。此处:链接打开 + callout/math/mention。
|
|
7705
|
-
|
|
7764
|
+
__init90() {this.onClick = (e) => {
|
|
7706
7765
|
const target = e.target;
|
|
7707
|
-
if (_optionalChain([target, 'optionalAccess',
|
|
7766
|
+
if (_optionalChain([target, 'optionalAccess', _454 => _454.closest, 'optionalCall', _455 => _455("[data-task-check]")]))
|
|
7708
7767
|
return;
|
|
7709
|
-
const a = _optionalChain([target, 'optionalAccess',
|
|
7768
|
+
const a = _optionalChain([target, 'optionalAccess', _456 => _456.closest, 'optionalCall', _457 => _457('a[data-mark="link"]')]);
|
|
7710
7769
|
if (a && this.root.contains(a)) {
|
|
7711
7770
|
const href = a.getAttribute("href");
|
|
7712
7771
|
if (href) {
|
|
@@ -7721,10 +7780,10 @@ var Editor = (_class11 = class {
|
|
|
7721
7780
|
}
|
|
7722
7781
|
if (this.readonly)
|
|
7723
7782
|
return;
|
|
7724
|
-
const aiAct = _optionalChain([target, 'optionalAccess',
|
|
7783
|
+
const aiAct = _optionalChain([target, 'optionalAccess', _458 => _458.closest, 'optionalCall', _459 => _459("[data-ai-act]")]);
|
|
7725
7784
|
if (aiAct && this.root.contains(aiAct) && this.aiCtl) {
|
|
7726
7785
|
const blockEl = aiAct.closest("[data-ai-block][data-block-id]");
|
|
7727
|
-
const id2 = _optionalChain([blockEl, 'optionalAccess',
|
|
7786
|
+
const id2 = _optionalChain([blockEl, 'optionalAccess', _460 => _460.getAttribute, 'call', _461 => _461("data-block-id")]);
|
|
7728
7787
|
const act = aiAct.getAttribute("data-ai-act");
|
|
7729
7788
|
if (id2 && act) {
|
|
7730
7789
|
e.preventDefault();
|
|
@@ -7733,9 +7792,9 @@ var Editor = (_class11 = class {
|
|
|
7733
7792
|
return;
|
|
7734
7793
|
}
|
|
7735
7794
|
}
|
|
7736
|
-
const chip = _optionalChain([target, 'optionalAccess',
|
|
7737
|
-
const mathEl = _optionalChain([target, 'optionalAccess',
|
|
7738
|
-
const menEl = _optionalChain([target, 'optionalAccess',
|
|
7795
|
+
const chip = _optionalChain([target, 'optionalAccess', _462 => _462.closest, 'optionalCall', _463 => _463("[data-callout-variant]")]);
|
|
7796
|
+
const mathEl = _optionalChain([target, 'optionalAccess', _464 => _464.closest, 'optionalCall', _465 => _465('[data-atom="math"]')]);
|
|
7797
|
+
const menEl = _optionalChain([target, 'optionalAccess', _466 => _466.closest, 'optionalCall', _467 => _467('[data-atom="mention"]')]);
|
|
7739
7798
|
const hit = _nullishCoalesce(_nullishCoalesce(chip, () => ( mathEl)), () => ( menEl));
|
|
7740
7799
|
if (!hit) {
|
|
7741
7800
|
this.pendingMarks = null;
|
|
@@ -7751,14 +7810,14 @@ var Editor = (_class11 = class {
|
|
|
7751
7810
|
this.openMentionPop(menEl);
|
|
7752
7811
|
return;
|
|
7753
7812
|
}
|
|
7754
|
-
const id = _optionalChain([hit, 'access',
|
|
7813
|
+
const id = _optionalChain([hit, 'access', _468 => _468.closest, 'call', _469 => _469("[data-block-id]"), 'optionalAccess', _470 => _470.getAttribute, 'call', _471 => _471("data-block-id")]);
|
|
7755
7814
|
if (!id)
|
|
7756
7815
|
return;
|
|
7757
|
-
const path =
|
|
7816
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id);
|
|
7758
7817
|
if (!path)
|
|
7759
7818
|
return;
|
|
7760
|
-
const node =
|
|
7761
|
-
if (
|
|
7819
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path);
|
|
7820
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
7762
7821
|
return;
|
|
7763
7822
|
if (chip && node.type === "callout") {
|
|
7764
7823
|
e.preventDefault();
|
|
@@ -7768,7 +7827,7 @@ var Editor = (_class11 = class {
|
|
|
7768
7827
|
}
|
|
7769
7828
|
}}
|
|
7770
7829
|
// 任务 checkbox:capture 阶段处理;li[data-task] 定位 list_item,乐观更新 UI 再 commit model。
|
|
7771
|
-
|
|
7830
|
+
__init91() {this.onTaskCheck = (e) => {
|
|
7772
7831
|
if (this.readonly)
|
|
7773
7832
|
return;
|
|
7774
7833
|
const t = e.target;
|
|
@@ -7785,8 +7844,8 @@ var Editor = (_class11 = class {
|
|
|
7785
7844
|
const path = pathOfTaskItem(this.history.doc, this.root, li);
|
|
7786
7845
|
if (!path)
|
|
7787
7846
|
return;
|
|
7788
|
-
const node =
|
|
7789
|
-
if (!node ||
|
|
7847
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path);
|
|
7848
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "list_item" || _optionalChain([node, 'access', _472 => _472.attrs, 'optionalAccess', _473 => _473.checked]) == null)
|
|
7790
7849
|
return;
|
|
7791
7850
|
const next = !node.attrs.checked;
|
|
7792
7851
|
box.checked = next;
|
|
@@ -7799,21 +7858,21 @@ var Editor = (_class11 = class {
|
|
|
7799
7858
|
}}
|
|
7800
7859
|
openMentionPop(el) {
|
|
7801
7860
|
const blockEl = el.closest("[data-block-id]");
|
|
7802
|
-
const bid = _optionalChain([blockEl, 'optionalAccess',
|
|
7861
|
+
const bid = _optionalChain([blockEl, 'optionalAccess', _474 => _474.getAttribute, 'call', _475 => _475("data-block-id")]);
|
|
7803
7862
|
if (!bid)
|
|
7804
7863
|
return;
|
|
7805
|
-
const blockPath =
|
|
7864
|
+
const blockPath = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, bid);
|
|
7806
7865
|
if (!blockPath)
|
|
7807
7866
|
return;
|
|
7808
|
-
const block =
|
|
7809
|
-
if (
|
|
7867
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
7868
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block)
|
|
7810
7869
|
return;
|
|
7811
7870
|
const leafKey = el.getAttribute("data-leaf");
|
|
7812
7871
|
const leafIdx = leafKey != null && leafKey !== "" ? Number(leafKey) : -1;
|
|
7813
7872
|
if (leafIdx < 0 || leafIdx >= block.children.length)
|
|
7814
7873
|
return;
|
|
7815
7874
|
const atom = block.children[leafIdx];
|
|
7816
|
-
if (
|
|
7875
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "mention")
|
|
7817
7876
|
return;
|
|
7818
7877
|
const a = _nullishCoalesce(atom.attrs, () => ( {}));
|
|
7819
7878
|
const rect = el.getBoundingClientRect();
|
|
@@ -7824,7 +7883,7 @@ var Editor = (_class11 = class {
|
|
|
7824
7883
|
return;
|
|
7825
7884
|
}
|
|
7826
7885
|
const id = String(_nullishCoalesce(a.id, () => ( "")));
|
|
7827
|
-
const fromHost = _optionalChain([this, 'access',
|
|
7886
|
+
const fromHost = _optionalChain([this, 'access', _476 => _476.opts, 'access', _477 => _477.mentionProfile, 'optionalCall', _478 => _478(id)]);
|
|
7828
7887
|
const profile = _nullishCoalesce(fromHost, () => ( {
|
|
7829
7888
|
id,
|
|
7830
7889
|
name: typeof a.label === "string" ? a.label : id
|
|
@@ -7836,11 +7895,11 @@ var Editor = (_class11 = class {
|
|
|
7836
7895
|
return;
|
|
7837
7896
|
const blockPath = path.slice(0, -1);
|
|
7838
7897
|
const leafIdx = path[path.length - 1];
|
|
7839
|
-
const block =
|
|
7840
|
-
if (
|
|
7898
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
7899
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block || leafIdx >= block.children.length)
|
|
7841
7900
|
return;
|
|
7842
7901
|
const atom = block.children[leafIdx];
|
|
7843
|
-
if (
|
|
7902
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "mention")
|
|
7844
7903
|
return;
|
|
7845
7904
|
const children = block.children.slice();
|
|
7846
7905
|
const label = iso.includes("T") ? iso.replace("T", " ") : iso;
|
|
@@ -7850,7 +7909,7 @@ var Editor = (_class11 = class {
|
|
|
7850
7909
|
};
|
|
7851
7910
|
this.dispatch([{ kind: "replaceNode", path: blockPath, node: { ...block, children } }]);
|
|
7852
7911
|
}
|
|
7853
|
-
|
|
7912
|
+
__init92() {this.onBeforeInput = (e) => {
|
|
7854
7913
|
if (this.readonly || this.composing)
|
|
7855
7914
|
return;
|
|
7856
7915
|
const intent = intentOf(e.inputType);
|
|
@@ -7865,7 +7924,7 @@ var Editor = (_class11 = class {
|
|
|
7865
7924
|
}
|
|
7866
7925
|
if (this.atomBlockGuard(intent, _nullishCoalesce(e.data, () => ( "")), e))
|
|
7867
7926
|
return;
|
|
7868
|
-
const sel =
|
|
7927
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7869
7928
|
if (!sel) {
|
|
7870
7929
|
e.preventDefault();
|
|
7871
7930
|
return;
|
|
@@ -7888,7 +7947,7 @@ var Editor = (_class11 = class {
|
|
|
7888
7947
|
/** caret 是否在 type=ai 块内;是则返该块,否则 null */
|
|
7889
7948
|
aiBlockAt(sel) {
|
|
7890
7949
|
const top = this.history.doc.children[sel.head.path[0]];
|
|
7891
|
-
if (!top ||
|
|
7950
|
+
if (!top || _chunkGQ2HHRGIcjs.isText.call(void 0, top) || top.type !== "ai")
|
|
7892
7951
|
return null;
|
|
7893
7952
|
return top;
|
|
7894
7953
|
}
|
|
@@ -7899,14 +7958,14 @@ var Editor = (_class11 = class {
|
|
|
7899
7958
|
if (!this.aiCtl)
|
|
7900
7959
|
return false;
|
|
7901
7960
|
const top = this.history.doc.children[sel.head.path[0]];
|
|
7902
|
-
if (top && !
|
|
7961
|
+
if (top && !_chunkGQ2HHRGIcjs.isText.call(void 0, top) && top.type === "paragraph" && _optionalChain([top, 'access', _479 => _479.attrs, 'optionalAccess', _480 => _480.aiDraft])) {
|
|
7903
7962
|
e.preventDefault();
|
|
7904
7963
|
return true;
|
|
7905
7964
|
}
|
|
7906
7965
|
const ai = this.aiBlockAt(sel);
|
|
7907
7966
|
if (!ai || !ai.id)
|
|
7908
7967
|
return false;
|
|
7909
|
-
const status = typeof _optionalChain([ai, 'access',
|
|
7968
|
+
const status = typeof _optionalChain([ai, 'access', _481 => _481.attrs, 'optionalAccess', _482 => _482.status]) === "string" ? ai.attrs.status : "compose";
|
|
7910
7969
|
if (status === "loading") {
|
|
7911
7970
|
e.preventDefault();
|
|
7912
7971
|
return true;
|
|
@@ -7931,8 +7990,8 @@ var Editor = (_class11 = class {
|
|
|
7931
7990
|
if (!collapsed)
|
|
7932
7991
|
return null;
|
|
7933
7992
|
const off = sel.head.path[sel.head.path.length - 1];
|
|
7934
|
-
const leaf =
|
|
7935
|
-
const len =
|
|
7993
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, sel.head.path.slice(0, -1));
|
|
7994
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0;
|
|
7936
7995
|
if (len === 0)
|
|
7937
7996
|
return null;
|
|
7938
7997
|
return { atStart: off === 0, atEnd: off === len };
|
|
@@ -7968,10 +8027,10 @@ var Editor = (_class11 = class {
|
|
|
7968
8027
|
const rel = path.slice(1);
|
|
7969
8028
|
const doc = this.history.doc;
|
|
7970
8029
|
const block = doc.children[topIdx];
|
|
7971
|
-
if (!block ||
|
|
8030
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
7972
8031
|
return null;
|
|
7973
|
-
const startRel =
|
|
7974
|
-
const endRel =
|
|
8032
|
+
const startRel = _chunk4TMHVNL6cjs.firstLeafPath.call(void 0, block).concat(0);
|
|
8033
|
+
const endRel = _chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, block);
|
|
7975
8034
|
const eq = (a, b) => a.length === b.length && a.every((s, i) => s === b[i]);
|
|
7976
8035
|
const atStart = dir === "back" && eq(rel, startRel);
|
|
7977
8036
|
const atEnd = dir === "fwd" && eq(rel, endRel);
|
|
@@ -7981,7 +8040,7 @@ var Editor = (_class11 = class {
|
|
|
7981
8040
|
// 顶层第 idx 块若是图/表 atom → {控制器, id};否则 null。atomAtEdge(字符口径)与竖直键(视觉口径)共用。
|
|
7982
8041
|
atomAt(idx) {
|
|
7983
8042
|
const neighbor = this.history.doc.children[idx];
|
|
7984
|
-
if (!neighbor ||
|
|
8043
|
+
if (!neighbor || _chunkGQ2HHRGIcjs.isText.call(void 0, neighbor) || !neighbor.id)
|
|
7985
8044
|
return null;
|
|
7986
8045
|
const ctrl = this.atomControls(neighbor.type);
|
|
7987
8046
|
return ctrl ? { ctrl, id: neighbor.id } : null;
|
|
@@ -7999,7 +8058,7 @@ var Editor = (_class11 = class {
|
|
|
7999
8058
|
const caret3 = range.getBoundingClientRect();
|
|
8000
8059
|
if (caret3.width === 0 && caret3.height === 0)
|
|
8001
8060
|
return false;
|
|
8002
|
-
const blockEl =
|
|
8061
|
+
const blockEl = _chunkSLRD6FMPcjs.elementChildren.call(void 0, _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root))[topIdx];
|
|
8003
8062
|
if (!blockEl)
|
|
8004
8063
|
return false;
|
|
8005
8064
|
const box = blockEl.getBoundingClientRect();
|
|
@@ -8019,7 +8078,7 @@ var Editor = (_class11 = class {
|
|
|
8019
8078
|
return null;
|
|
8020
8079
|
const topIdx = path[0];
|
|
8021
8080
|
const block = this.history.doc.children[topIdx];
|
|
8022
|
-
if (!block ||
|
|
8081
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
8023
8082
|
return null;
|
|
8024
8083
|
if (!this.onEdgeVisualLine(topIdx, dir))
|
|
8025
8084
|
return null;
|
|
@@ -8063,7 +8122,7 @@ var Editor = (_class11 = class {
|
|
|
8063
8122
|
const only = doc.children.length === 1;
|
|
8064
8123
|
if (isTable) {
|
|
8065
8124
|
const caret4 = this.neighborCaret(idx, only ? [idx] : null);
|
|
8066
|
-
this.dispatch([
|
|
8125
|
+
this.dispatch([_chunk4TMHVNL6cjs.deleteTableBlock.call(void 0, [idx], doc)], caret4);
|
|
8067
8126
|
return true;
|
|
8068
8127
|
}
|
|
8069
8128
|
const insert = only ? [{ type: "paragraph", id: newId3(), children: [{ text: "" }] }] : [];
|
|
@@ -8104,30 +8163,30 @@ var Editor = (_class11 = class {
|
|
|
8104
8163
|
return at([...fallbackIdx, 0, 0]);
|
|
8105
8164
|
const doc = this.history.doc;
|
|
8106
8165
|
const prev = doc.children[removedIdx - 1];
|
|
8107
|
-
if (prev && !
|
|
8108
|
-
return at([removedIdx - 1, ...
|
|
8166
|
+
if (prev && !_chunkGQ2HHRGIcjs.isText.call(void 0, prev))
|
|
8167
|
+
return at([removedIdx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prev)]);
|
|
8109
8168
|
const next = doc.children[removedIdx + 1];
|
|
8110
|
-
if (next && !
|
|
8111
|
-
return at([removedIdx, ...
|
|
8169
|
+
if (next && !_chunkGQ2HHRGIcjs.isText.call(void 0, next))
|
|
8170
|
+
return at([removedIdx, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, next), 0]);
|
|
8112
8171
|
return at([Math.max(0, removedIdx - 1), 0, 0]);
|
|
8113
8172
|
}
|
|
8114
8173
|
isCodeBlock(blockPath) {
|
|
8115
8174
|
if (blockPath.length === 0)
|
|
8116
8175
|
return false;
|
|
8117
|
-
const block =
|
|
8118
|
-
return !
|
|
8176
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8177
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, block) && block.type === "code";
|
|
8119
8178
|
}
|
|
8120
8179
|
// caret 落在 list_item 段落内:tail = [paraIdx, leafIdx, char],去掉得 itemPath。塌缩选区才接管(indent/outdent 是块搬家)。
|
|
8121
8180
|
inListItem(path) {
|
|
8122
8181
|
if (path.length < 4)
|
|
8123
8182
|
return false;
|
|
8124
|
-
const item =
|
|
8125
|
-
return !!item && !
|
|
8183
|
+
const item = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path.slice(0, -3));
|
|
8184
|
+
return !!item && !_chunkGQ2HHRGIcjs.isText.call(void 0, item) && item.type === "list_item";
|
|
8126
8185
|
}
|
|
8127
8186
|
// intentOf 不认的删变体(word/line 删)在代码块边界的守卫:跨块涉码 / 塌缩在 code 对应边 → preventDefault(挡浏览器并块)。
|
|
8128
8187
|
// 非边界(代码块中段)不接管,放行——与 codeBlockGuard 的「只收边界、放行叶内」一致,不过度拦。
|
|
8129
8188
|
codeBoundaryDelete(dir, e) {
|
|
8130
|
-
const sel =
|
|
8189
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8131
8190
|
if (!sel)
|
|
8132
8191
|
return;
|
|
8133
8192
|
if (this.straddlesAtom(sel)) {
|
|
@@ -8150,7 +8209,7 @@ var Editor = (_class11 = class {
|
|
|
8150
8209
|
// 到 cell/文档真边界 mapInput 才返 null)——「删空本行/本段后再删能退上去」的语义由此路径提供。
|
|
8151
8210
|
// 一律 preventDefault(否则浏览器原生删破 DOM≡doc,后续 readSelection 读脏 DOM 返 null → 打字被吞)。
|
|
8152
8211
|
wordLineDelete(dir, inputType, e) {
|
|
8153
|
-
const sel =
|
|
8212
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8154
8213
|
if (!sel) {
|
|
8155
8214
|
e.preventDefault();
|
|
8156
8215
|
return;
|
|
@@ -8176,18 +8235,18 @@ var Editor = (_class11 = class {
|
|
|
8176
8235
|
// 正解是 3-way merge:base=组字前叶文本快照。IME 改动 = diff(base, DOM 落定文本)——
|
|
8177
8236
|
// 这是「相对 base 的纯 IME 局部编辑」,不含 AI 的并发改动。把它作为 Step 施加到 model 当前态,
|
|
8178
8237
|
// AI 在同段别处的改动得以保留(diff(model,DOM) 会把 AI 改动误当删除——那是错的)。
|
|
8179
|
-
|
|
8238
|
+
__init93() {this.onCompositionEnd = () => {
|
|
8180
8239
|
this.composing = false;
|
|
8181
8240
|
const base = this.composeBase;
|
|
8182
8241
|
this.composeBase = null;
|
|
8183
|
-
const sel =
|
|
8242
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8184
8243
|
if (!sel || !base) {
|
|
8185
8244
|
this.draw();
|
|
8186
8245
|
return;
|
|
8187
8246
|
}
|
|
8188
8247
|
const leafPath = base.leafPath;
|
|
8189
|
-
const dom =
|
|
8190
|
-
const domText = (_optionalChain([dom, 'optionalAccess',
|
|
8248
|
+
const dom = _chunkSLRD6FMPcjs.pointToDom.call(void 0, this.root, this.history.doc, { path: leafPath.concat(0) });
|
|
8249
|
+
const domText = (_optionalChain([dom, 'optionalAccess', _483 => _483.node]) && isDomText(dom.node) ? _nullishCoalesce(dom.node.textContent, () => ( "")) : "").replaceAll("\u200B", "");
|
|
8191
8250
|
const edit = diffSpan(base.text, domText);
|
|
8192
8251
|
if (!edit) {
|
|
8193
8252
|
this.draw();
|
|
@@ -8204,7 +8263,7 @@ var Editor = (_class11 = class {
|
|
|
8204
8263
|
}
|
|
8205
8264
|
this.dispatch(steps, caretAfter(leafPath, edit.at + edit.insert.length));
|
|
8206
8265
|
}}
|
|
8207
|
-
|
|
8266
|
+
__init94() {this.onKeyDown = (e) => {
|
|
8208
8267
|
if (this.readonly)
|
|
8209
8268
|
return;
|
|
8210
8269
|
const mod2 = e.metaKey || e.ctrlKey;
|
|
@@ -8233,7 +8292,7 @@ var Editor = (_class11 = class {
|
|
|
8233
8292
|
const doc = this.history.doc;
|
|
8234
8293
|
const nbrIdx = exitBack ? idx - 1 : idx + 1;
|
|
8235
8294
|
const nbr = doc.children[nbrIdx];
|
|
8236
|
-
if (nbr && !
|
|
8295
|
+
if (nbr && !_chunkGQ2HHRGIcjs.isText.call(void 0, nbr)) {
|
|
8237
8296
|
const nbrCtrl = nbr.id ? this.atomControls(nbr.type) : null;
|
|
8238
8297
|
if (nbrCtrl && nbrCtrl.selectByBlockId(nbr.id)) {
|
|
8239
8298
|
if (nbrCtrl !== selCtrl)
|
|
@@ -8241,8 +8300,8 @@ var Editor = (_class11 = class {
|
|
|
8241
8300
|
return;
|
|
8242
8301
|
}
|
|
8243
8302
|
selCtrl.clearSelected();
|
|
8244
|
-
const target = exitBack ? [nbrIdx, ...
|
|
8245
|
-
|
|
8303
|
+
const target = exitBack ? [nbrIdx, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, nbr)] : [nbrIdx, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, nbr), 0];
|
|
8304
|
+
_chunkSLRD6FMPcjs.writeSelection.call(void 0, this.root, doc, { anchor: { path: target }, head: { path: target } });
|
|
8246
8305
|
return;
|
|
8247
8306
|
}
|
|
8248
8307
|
selCtrl.clearSelected();
|
|
@@ -8250,7 +8309,7 @@ var Editor = (_class11 = class {
|
|
|
8250
8309
|
}
|
|
8251
8310
|
}
|
|
8252
8311
|
if ((exitBack || exitFwd) && !mod2 && !e.shiftKey && !selCtrl) {
|
|
8253
|
-
const sel =
|
|
8312
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8254
8313
|
if (sel) {
|
|
8255
8314
|
const dir = exitBack ? "back" : "fwd";
|
|
8256
8315
|
const hit = _nullishCoalesce(this.atomAtEdge(sel, dir), () => ( (e.key === "ArrowUp" || e.key === "ArrowDown" ? this.atomAtEdgeVertical(sel, dir) : null)));
|
|
@@ -8270,7 +8329,7 @@ var Editor = (_class11 = class {
|
|
|
8270
8329
|
return;
|
|
8271
8330
|
}
|
|
8272
8331
|
if (e.key === "Tab" && !e.shiftKey && !mod2) {
|
|
8273
|
-
const sel =
|
|
8332
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8274
8333
|
if (sel && this.isCodeBlock(sel.head.path.slice(0, -2))) {
|
|
8275
8334
|
const result = mapInput(this.history.doc, "insertText", " ", sel, newId3);
|
|
8276
8335
|
if (result) {
|
|
@@ -8288,13 +8347,13 @@ var Editor = (_class11 = class {
|
|
|
8288
8347
|
}
|
|
8289
8348
|
}
|
|
8290
8349
|
if (e.key === "Tab" && e.shiftKey && !mod2) {
|
|
8291
|
-
const sel =
|
|
8292
|
-
const blockPath = _optionalChain([sel, 'optionalAccess',
|
|
8350
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8351
|
+
const blockPath = _optionalChain([sel, 'optionalAccess', _484 => _484.head, 'access', _485 => _485.path, 'access', _486 => _486.slice, 'call', _487 => _487(0, -2)]);
|
|
8293
8352
|
if (sel && blockPath && this.isCodeBlock(blockPath)) {
|
|
8294
8353
|
e.preventDefault();
|
|
8295
8354
|
const leafPath = sel.head.path.slice(0, -1);
|
|
8296
|
-
const leaf =
|
|
8297
|
-
if (
|
|
8355
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, leafPath);
|
|
8356
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
8298
8357
|
const caret3 = sel.head.path[sel.head.path.length - 1];
|
|
8299
8358
|
const lineStart = leaf.text.lastIndexOf("\n", caret3 - 1) + 1;
|
|
8300
8359
|
const remove = unindentLen(leaf.text, lineStart);
|
|
@@ -8325,7 +8384,7 @@ var Editor = (_class11 = class {
|
|
|
8325
8384
|
e.preventDefault();
|
|
8326
8385
|
let rect = new DOMRect(0, 0, 0, 0);
|
|
8327
8386
|
try {
|
|
8328
|
-
const r = _optionalChain([document, 'access',
|
|
8387
|
+
const r = _optionalChain([document, 'access', _488 => _488.getSelection, 'call', _489 => _489(), 'optionalAccess', _490 => _490.getRangeAt, 'call', _491 => _491(0), 'optionalAccess', _492 => _492.getBoundingClientRect, 'call', _493 => _493()]);
|
|
8329
8388
|
if (r && (r.width || r.height))
|
|
8330
8389
|
rect = r;
|
|
8331
8390
|
} catch (e10) {
|
|
@@ -8341,15 +8400,15 @@ var Editor = (_class11 = class {
|
|
|
8341
8400
|
}
|
|
8342
8401
|
const cmd = mod2 ? this.resolved.keymap[chord(e)] : void 0;
|
|
8343
8402
|
if (cmd) {
|
|
8344
|
-
const r = cmd({ doc: this.history.doc, sel:
|
|
8403
|
+
const r = cmd({ doc: this.history.doc, sel: _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), markSel: this.markSel(), promptLink: this.opts.promptLink });
|
|
8345
8404
|
if (!r)
|
|
8346
8405
|
return;
|
|
8347
8406
|
e.preventDefault();
|
|
8348
8407
|
if ("history" in r) {
|
|
8349
8408
|
this.pendingMarks = null;
|
|
8350
|
-
this.history = r.history === "undo" ?
|
|
8409
|
+
this.history = r.history === "undo" ? _chunkYXQDCW4Ycjs.undo.call(void 0, this.history) : _chunkYXQDCW4Ycjs.redo.call(void 0, this.history);
|
|
8351
8410
|
this.draw();
|
|
8352
|
-
_optionalChain([this, 'access',
|
|
8411
|
+
_optionalChain([this, 'access', _494 => _494.opts, 'access', _495 => _495.onChange, 'optionalCall', _496 => _496(this.history.doc)]);
|
|
8353
8412
|
return;
|
|
8354
8413
|
}
|
|
8355
8414
|
if ("pendingToggle" in r) {
|
|
@@ -8365,7 +8424,7 @@ var Editor = (_class11 = class {
|
|
|
8365
8424
|
return;
|
|
8366
8425
|
}
|
|
8367
8426
|
if (mod2 && !e.shiftKey && (e.key === "a" || e.key === "A")) {
|
|
8368
|
-
const sel =
|
|
8427
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8369
8428
|
if (!sel)
|
|
8370
8429
|
return;
|
|
8371
8430
|
const blockPath = sel.head.path.slice(0, -2);
|
|
@@ -8373,7 +8432,7 @@ var Editor = (_class11 = class {
|
|
|
8373
8432
|
return;
|
|
8374
8433
|
e.preventDefault();
|
|
8375
8434
|
const len = leafText2(this.history.doc, [...blockPath, 0]).length;
|
|
8376
|
-
|
|
8435
|
+
_chunkSLRD6FMPcjs.writeSelection.call(void 0,
|
|
8377
8436
|
this.root,
|
|
8378
8437
|
this.history.doc,
|
|
8379
8438
|
{ anchor: { path: [...blockPath, 0, 0] }, head: { path: [...blockPath, 0, len] } }
|
|
@@ -8384,45 +8443,45 @@ var Editor = (_class11 = class {
|
|
|
8384
8443
|
// 代码块 model 是单纯文本叶,docToMd 只读首叶裸 text——加 mark 轻则渲幽灵 strong/save 后消失,
|
|
8385
8444
|
// 重则 toggleMark 把单叶按区间切成多叶,leaves(n)[0] 只取首叶 → 存盘丢码。marks 在代码块无语义,直接挡。
|
|
8386
8445
|
markSel() {
|
|
8387
|
-
const sel =
|
|
8446
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8388
8447
|
if (!sel)
|
|
8389
8448
|
return null;
|
|
8390
8449
|
if (this.isCodeBlock(sel.anchor.path.slice(0, -2)) || this.isCodeBlock(sel.head.path.slice(0, -2)))
|
|
8391
8450
|
return null;
|
|
8392
8451
|
return sel;
|
|
8393
8452
|
}
|
|
8394
|
-
// 复制/剪切/粘贴:选区 ⟷ markdown。md 是
|
|
8395
|
-
|
|
8396
|
-
const sel =
|
|
8453
|
+
// 复制/剪切/粘贴:选区 ⟷ markdown。md 是 markloom 的唯一真值,剪贴板也走 md,跨编辑器/外部可读。
|
|
8454
|
+
__init95() {this.onCopy = (e) => {
|
|
8455
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8397
8456
|
if (!sel)
|
|
8398
8457
|
return;
|
|
8399
8458
|
const md = serializeSelection(this.history.doc, sel);
|
|
8400
8459
|
if (!md)
|
|
8401
8460
|
return;
|
|
8402
8461
|
e.preventDefault();
|
|
8403
|
-
_optionalChain([e, 'access',
|
|
8462
|
+
_optionalChain([e, 'access', _497 => _497.clipboardData, 'optionalAccess', _498 => _498.setData, 'call', _499 => _499("text/plain", md)]);
|
|
8404
8463
|
}}
|
|
8405
|
-
|
|
8464
|
+
__init96() {this.onCut = (e) => {
|
|
8406
8465
|
if (this.readonly) {
|
|
8407
8466
|
e.preventDefault();
|
|
8408
8467
|
return;
|
|
8409
8468
|
}
|
|
8410
8469
|
e.preventDefault();
|
|
8411
|
-
const sel =
|
|
8470
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8412
8471
|
if (!sel)
|
|
8413
8472
|
return;
|
|
8414
8473
|
const md = serializeSelection(this.history.doc, sel);
|
|
8415
8474
|
if (!md)
|
|
8416
8475
|
return;
|
|
8417
|
-
_optionalChain([e, 'access',
|
|
8476
|
+
_optionalChain([e, 'access', _500 => _500.clipboardData, 'optionalAccess', _501 => _501.setData, 'call', _502 => _502("text/plain", md)]);
|
|
8418
8477
|
const del = mapInput(this.history.doc, "deleteForward", "", sel, newId3);
|
|
8419
8478
|
if (del)
|
|
8420
8479
|
this.dispatch(del.steps, del.selection);
|
|
8421
8480
|
}}
|
|
8422
|
-
|
|
8481
|
+
__init97() {this.onPaste = (e) => {
|
|
8423
8482
|
if (this.readonly || this.composing)
|
|
8424
8483
|
return;
|
|
8425
|
-
const sel =
|
|
8484
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8426
8485
|
if (!sel)
|
|
8427
8486
|
return;
|
|
8428
8487
|
const inCode = this.isCodeBlock(sel.head.path.slice(0, -2));
|
|
@@ -8433,15 +8492,15 @@ var Editor = (_class11 = class {
|
|
|
8433
8492
|
this.insertImageFile(file, sel);
|
|
8434
8493
|
return;
|
|
8435
8494
|
}
|
|
8436
|
-
const htmlUrl = imgSrcFromHtml(_optionalChain([e, 'access',
|
|
8437
|
-
if (htmlUrl && !_optionalChain([e, 'access',
|
|
8495
|
+
const htmlUrl = imgSrcFromHtml(_optionalChain([e, 'access', _503 => _503.clipboardData, 'optionalAccess', _504 => _504.getData, 'call', _505 => _505("text/html")]));
|
|
8496
|
+
if (htmlUrl && !_optionalChain([e, 'access', _506 => _506.clipboardData, 'optionalAccess', _507 => _507.getData, 'call', _508 => _508("text/plain")])) {
|
|
8438
8497
|
e.preventDefault();
|
|
8439
8498
|
this.insertImageUrl(htmlUrl, sel);
|
|
8440
8499
|
return;
|
|
8441
8500
|
}
|
|
8442
8501
|
}
|
|
8443
|
-
const raw = _nullishCoalesce(_optionalChain([e, 'access',
|
|
8444
|
-
const html = _nullishCoalesce(_optionalChain([e, 'access',
|
|
8502
|
+
const raw = _nullishCoalesce(_optionalChain([e, 'access', _509 => _509.clipboardData, 'optionalAccess', _510 => _510.getData, 'call', _511 => _511("text/plain")]), () => ( ""));
|
|
8503
|
+
const html = _nullishCoalesce(_optionalChain([e, 'access', _512 => _512.clipboardData, 'optionalAccess', _513 => _513.getData, 'call', _514 => _514("text/html")]), () => ( ""));
|
|
8445
8504
|
if (inCode) {
|
|
8446
8505
|
if (!raw && !html)
|
|
8447
8506
|
return;
|
|
@@ -8471,8 +8530,8 @@ var Editor = (_class11 = class {
|
|
|
8471
8530
|
}
|
|
8472
8531
|
}
|
|
8473
8532
|
if (html) {
|
|
8474
|
-
const blocks =
|
|
8475
|
-
if (blocks &&
|
|
8533
|
+
const blocks = _chunk4TMHVNL6cjs.htmlToBlocks.call(void 0, html);
|
|
8534
|
+
if (blocks && _chunk4TMHVNL6cjs.isRichHtmlBlocks.call(void 0, blocks)) {
|
|
8476
8535
|
e.preventDefault();
|
|
8477
8536
|
const result2 = mapPasteBlocks(this.history.doc, sel, blocks, newId3);
|
|
8478
8537
|
if (result2)
|
|
@@ -8508,12 +8567,12 @@ var Editor = (_class11 = class {
|
|
|
8508
8567
|
}
|
|
8509
8568
|
// 斜杠 /image:开原生文件选择,选中后把触发段(blockIdx,含 `/image`)整块替换成 image atom。
|
|
8510
8569
|
// 复用 onImage 上传钩子(未注入退回 data: URL)。取消选择 → 不动 model。
|
|
8511
|
-
|
|
8570
|
+
__init98() {this.slashInsertImage = (blockIdx) => {
|
|
8512
8571
|
const input = this.root.ownerDocument.createElement("input");
|
|
8513
8572
|
input.type = "file";
|
|
8514
8573
|
input.accept = "image/*";
|
|
8515
8574
|
input.onchange = () => {
|
|
8516
|
-
const file = _optionalChain([input, 'access',
|
|
8575
|
+
const file = _optionalChain([input, 'access', _515 => _515.files, 'optionalAccess', _516 => _516[0]]);
|
|
8517
8576
|
if (!file)
|
|
8518
8577
|
return;
|
|
8519
8578
|
const to = this.opts.onImage ? this.opts.onImage(file) : new Promise((resolve2, reject) => {
|
|
@@ -8531,7 +8590,7 @@ var Editor = (_class11 = class {
|
|
|
8531
8590
|
input.click();
|
|
8532
8591
|
}}
|
|
8533
8592
|
// 斜杠 /math → 当前段换成含 math atom 的段(display block)。
|
|
8534
|
-
|
|
8593
|
+
__init99() {this.slashInsertMath = (blockIdx) => {
|
|
8535
8594
|
void askInput({
|
|
8536
8595
|
title: "\u63D2\u5165\u516C\u5F0F",
|
|
8537
8596
|
description: "\u8F93\u5165 LaTeX\uFF0C\u4F8B\u5982 E=mc^2 \u6216 \\frac{a}{b}",
|
|
@@ -8549,13 +8608,13 @@ var Editor = (_class11 = class {
|
|
|
8549
8608
|
});
|
|
8550
8609
|
}}
|
|
8551
8610
|
// 斜杠 /youtube|/twitch|/audio|/file → embed 块。file/audio 走文件选择;yt/twitch 弹 URL。
|
|
8552
|
-
|
|
8611
|
+
__init100() {this.slashInsertEmbed = (blockIdx, kind) => {
|
|
8553
8612
|
if (kind === "file" || kind === "audio") {
|
|
8554
8613
|
const input = this.root.ownerDocument.createElement("input");
|
|
8555
8614
|
input.type = "file";
|
|
8556
8615
|
input.accept = kind === "audio" ? "audio/*" : "*/*";
|
|
8557
8616
|
input.onchange = () => {
|
|
8558
|
-
const file = _optionalChain([input, 'access',
|
|
8617
|
+
const file = _optionalChain([input, 'access', _517 => _517.files, 'optionalAccess', _518 => _518[0]]);
|
|
8559
8618
|
if (!file)
|
|
8560
8619
|
return;
|
|
8561
8620
|
const to = this.opts.onImage ? this.opts.onImage(file) : new Promise((resolve2, reject) => {
|
|
@@ -8603,23 +8662,23 @@ var Editor = (_class11 = class {
|
|
|
8603
8662
|
// 点 math atom → 弹层改 latex。叶路径:块 data-block-id + data-leaf 下标。
|
|
8604
8663
|
editMathAtom(mathEl) {
|
|
8605
8664
|
const blockEl = mathEl.closest("[data-block-id]");
|
|
8606
|
-
const id = _optionalChain([blockEl, 'optionalAccess',
|
|
8665
|
+
const id = _optionalChain([blockEl, 'optionalAccess', _519 => _519.getAttribute, 'call', _520 => _520("data-block-id")]);
|
|
8607
8666
|
if (!id)
|
|
8608
8667
|
return;
|
|
8609
|
-
const blockPath =
|
|
8668
|
+
const blockPath = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id);
|
|
8610
8669
|
if (!blockPath)
|
|
8611
8670
|
return;
|
|
8612
|
-
const block =
|
|
8613
|
-
if (
|
|
8671
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8672
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block)
|
|
8614
8673
|
return;
|
|
8615
8674
|
const leafKey = mathEl.getAttribute("data-leaf");
|
|
8616
8675
|
const leafIdx = leafKey != null && leafKey !== "" ? Number(leafKey) : -1;
|
|
8617
8676
|
if (leafIdx < 0 || leafIdx >= block.children.length)
|
|
8618
8677
|
return;
|
|
8619
8678
|
const atom = block.children[leafIdx];
|
|
8620
|
-
if (
|
|
8679
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "math")
|
|
8621
8680
|
return;
|
|
8622
|
-
const cur = String(_nullishCoalesce(_optionalChain([atom, 'access',
|
|
8681
|
+
const cur = String(_nullishCoalesce(_optionalChain([atom, 'access', _521 => _521.attrs, 'optionalAccess', _522 => _522.latex]), () => ( "")));
|
|
8623
8682
|
void askInput({
|
|
8624
8683
|
title: "\u7F16\u8F91\u516C\u5F0F",
|
|
8625
8684
|
description: "\u4FEE\u6539 LaTeX \u6E90\u7801",
|
|
@@ -8630,11 +8689,11 @@ var Editor = (_class11 = class {
|
|
|
8630
8689
|
}).then((next) => {
|
|
8631
8690
|
if (next == null || next.trim() === cur)
|
|
8632
8691
|
return;
|
|
8633
|
-
const b =
|
|
8634
|
-
if (
|
|
8692
|
+
const b = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8693
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, b) || !b || leafIdx >= b.children.length)
|
|
8635
8694
|
return;
|
|
8636
8695
|
const a = b.children[leafIdx];
|
|
8637
|
-
if (
|
|
8696
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, a) || a.type !== "math")
|
|
8638
8697
|
return;
|
|
8639
8698
|
const children = b.children.slice();
|
|
8640
8699
|
children[leafIdx] = { ...a, attrs: { ...a.attrs, latex: next.trim() } };
|
|
@@ -8646,13 +8705,13 @@ var Editor = (_class11 = class {
|
|
|
8646
8705
|
if (sel.anchor.path[0] !== sel.head.path[0] || sel.head.path.length !== 3)
|
|
8647
8706
|
return false;
|
|
8648
8707
|
const b = this.history.doc.children[sel.head.path[0]];
|
|
8649
|
-
if (!b ||
|
|
8708
|
+
if (!b || _chunkGQ2HHRGIcjs.isText.call(void 0, b) || b.type !== "paragraph")
|
|
8650
8709
|
return false;
|
|
8651
|
-
return b.children.length === 1 &&
|
|
8710
|
+
return b.children.length === 1 && _chunkGQ2HHRGIcjs.isText.call(void 0, b.children[0]) && b.children[0].text === "";
|
|
8652
8711
|
}
|
|
8653
8712
|
// floating menu(+ 柄):在 blockIdx 下方插一个只含 `/` 的空段,光标落 `/` 之后,派 input 事件唤起斜杠菜单。
|
|
8654
8713
|
// 复用 SlashMenu 的 onInput 触发路径(菜单只认「行首 `/`」),FloatingMenu 不需自己造菜单——+ 只是「打 /」的快捷。
|
|
8655
|
-
|
|
8714
|
+
__init101() {this.insertBelow = (blockIdx) => {
|
|
8656
8715
|
if (this.readonly)
|
|
8657
8716
|
return;
|
|
8658
8717
|
const id = newId3();
|
|
@@ -8678,37 +8737,37 @@ var Editor = (_class11 = class {
|
|
|
8678
8737
|
isAtomBlock(blockPath) {
|
|
8679
8738
|
if (blockPath.length === 0)
|
|
8680
8739
|
return false;
|
|
8681
|
-
return isAtom(
|
|
8740
|
+
return isAtom(_chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath));
|
|
8682
8741
|
}
|
|
8683
8742
|
// 找到 head 路径上的 table 祖先 → 当前 (r,c) → nextCell → 把光标写到目标格首段首叶。
|
|
8684
8743
|
// caret 落在哪个表格的哪一格。沿 head 找第一个 type==='table' 祖先块 → {tablePath, table, r, c}。
|
|
8685
8744
|
tableCaret() {
|
|
8686
|
-
const sel =
|
|
8745
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8687
8746
|
if (!sel)
|
|
8688
8747
|
return null;
|
|
8689
8748
|
const head = sel.head.path;
|
|
8690
8749
|
let node = this.history.doc;
|
|
8691
8750
|
const tablePath = [];
|
|
8692
8751
|
for (let i = 0; i < head.length; i++) {
|
|
8693
|
-
if (
|
|
8752
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node) || !node.children[head[i]])
|
|
8694
8753
|
break;
|
|
8695
|
-
if (!
|
|
8754
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, node) && node.type === "table")
|
|
8696
8755
|
break;
|
|
8697
8756
|
tablePath.push(head[i]);
|
|
8698
8757
|
node = node.children[head[i]];
|
|
8699
8758
|
}
|
|
8700
|
-
const table =
|
|
8701
|
-
if (
|
|
8759
|
+
const table = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, tablePath);
|
|
8760
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, table) || table.type !== "table")
|
|
8702
8761
|
return null;
|
|
8703
|
-
const cur =
|
|
8762
|
+
const cur = _chunk4TMHVNL6cjs.caretCell.call(void 0, tablePath, table, head);
|
|
8704
8763
|
return cur ? { tablePath, table, r: cur.r, c: cur.c, head } : null;
|
|
8705
8764
|
}
|
|
8706
8765
|
tabInTable(dir) {
|
|
8707
8766
|
const loc = this.tableCaret();
|
|
8708
8767
|
if (!loc)
|
|
8709
8768
|
return false;
|
|
8710
|
-
const to =
|
|
8711
|
-
const at = { path:
|
|
8769
|
+
const to = _chunk4TMHVNL6cjs.nextCell.call(void 0, loc.table, loc.r, loc.c, dir);
|
|
8770
|
+
const at = { path: _chunk4TMHVNL6cjs.cellCaret.call(void 0, loc.tablePath, loc.table, to.r, to.c, 0) };
|
|
8712
8771
|
this.draw({ anchor: at, head: at });
|
|
8713
8772
|
return true;
|
|
8714
8773
|
}
|
|
@@ -8720,43 +8779,43 @@ var Editor = (_class11 = class {
|
|
|
8720
8779
|
return false;
|
|
8721
8780
|
if (dir === "left" || dir === "right") {
|
|
8722
8781
|
const off2 = loc.head[loc.head.length - 1];
|
|
8723
|
-
const leaf =
|
|
8724
|
-
const len =
|
|
8782
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, loc.head.slice(0, -1));
|
|
8783
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0;
|
|
8725
8784
|
if (dir === "left" ? off2 > 0 : off2 < len)
|
|
8726
8785
|
return false;
|
|
8727
8786
|
}
|
|
8728
|
-
const to =
|
|
8787
|
+
const to = _chunk4TMHVNL6cjs.arrowCell.call(void 0, loc.table, loc.r, loc.c, dir);
|
|
8729
8788
|
if (!to)
|
|
8730
8789
|
return false;
|
|
8731
|
-
const grid =
|
|
8790
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, loc.table);
|
|
8732
8791
|
const idx = grid.at(to.r, to.c);
|
|
8733
8792
|
const cellNode = loc.table.children[idx];
|
|
8734
8793
|
let off = 0;
|
|
8735
8794
|
if (dir === "left" && cellNode) {
|
|
8736
8795
|
const para = cellNode.children[0];
|
|
8737
|
-
const lf = para && !
|
|
8738
|
-
off = lf &&
|
|
8796
|
+
const lf = para && !_chunkGQ2HHRGIcjs.isText.call(void 0, para) ? para.children[0] : void 0;
|
|
8797
|
+
off = lf && _chunkGQ2HHRGIcjs.isText.call(void 0, lf) ? lf.text.length : 0;
|
|
8739
8798
|
}
|
|
8740
|
-
const at = { path:
|
|
8799
|
+
const at = { path: _chunk4TMHVNL6cjs.cellCaret.call(void 0, loc.tablePath, loc.table, to.r, to.c, off) };
|
|
8741
8800
|
this.draw({ anchor: at, head: at });
|
|
8742
8801
|
return true;
|
|
8743
8802
|
}
|
|
8744
8803
|
// 飞书式行列高亮:焦点落入某 cell → 同行同列所有 cell 加标记属性(主题给浅色背景)。
|
|
8745
8804
|
// 纯 DOM 投影,不碰 model:语义表格里 td 嵌在 tbody>tr 下,用后代选择器收(文档序即行优先);
|
|
8746
8805
|
// 列数从 tr 的 cell 数读(每行等列)。同表换格时 focusout 先清 focusin 再标,同帧内同步完成不闪。
|
|
8747
|
-
|
|
8806
|
+
__init102() {this.onFocusIn = (e) => {
|
|
8748
8807
|
if (!(e.target instanceof HTMLElement))
|
|
8749
8808
|
return;
|
|
8750
|
-
const cell = e.target.closest(".
|
|
8751
|
-
const table = _optionalChain([cell, 'optionalAccess',
|
|
8809
|
+
const cell = e.target.closest(".markloom-cell");
|
|
8810
|
+
const table = _optionalChain([cell, 'optionalAccess', _523 => _523.closest, 'call', _524 => _524(".markloom-table")]);
|
|
8752
8811
|
if (!cell || !table)
|
|
8753
8812
|
return;
|
|
8754
8813
|
const id = table.getAttribute("data-block-id");
|
|
8755
|
-
const model = id ?
|
|
8756
|
-
if (!model ||
|
|
8814
|
+
const model = id ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, _nullishCoalesce(_chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id), () => ( []))) : null;
|
|
8815
|
+
if (!model || _chunkGQ2HHRGIcjs.isText.call(void 0, model) || model.type !== "table")
|
|
8757
8816
|
return;
|
|
8758
|
-
const grid =
|
|
8759
|
-
const cells = Array.from(table.querySelectorAll(".
|
|
8817
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, model);
|
|
8818
|
+
const cells = Array.from(table.querySelectorAll(".markloom-cell"));
|
|
8760
8819
|
if (cells.length !== grid.anchors.length)
|
|
8761
8820
|
return;
|
|
8762
8821
|
const idx = cells.indexOf(cell);
|
|
@@ -8769,13 +8828,13 @@ var Editor = (_class11 = class {
|
|
|
8769
8828
|
el.toggleAttribute("data-highlight-col", sameCol);
|
|
8770
8829
|
});
|
|
8771
8830
|
}}
|
|
8772
|
-
|
|
8831
|
+
__init103() {this.onFocusOut = (e) => {
|
|
8773
8832
|
if (!(e.target instanceof HTMLElement))
|
|
8774
8833
|
return;
|
|
8775
|
-
const table = _optionalChain([e, 'access',
|
|
8834
|
+
const table = _optionalChain([e, 'access', _525 => _525.target, 'access', _526 => _526.closest, 'call', _527 => _527(".markloom-cell"), 'optionalAccess', _528 => _528.closest, 'call', _529 => _529(".markloom-table")]);
|
|
8776
8835
|
if (!table)
|
|
8777
8836
|
return;
|
|
8778
|
-
table.querySelectorAll(".
|
|
8837
|
+
table.querySelectorAll(".markloom-cell").forEach((el) => {
|
|
8779
8838
|
el.removeAttribute("data-highlight-row");
|
|
8780
8839
|
el.removeAttribute("data-highlight-col");
|
|
8781
8840
|
});
|
|
@@ -8810,12 +8869,12 @@ function intentOf(inputType) {
|
|
|
8810
8869
|
}
|
|
8811
8870
|
}
|
|
8812
8871
|
function newId3() {
|
|
8813
|
-
return _nullishCoalesce(_optionalChain([globalThis, 'access',
|
|
8872
|
+
return _nullishCoalesce(_optionalChain([globalThis, 'access', _530 => _530.crypto, 'optionalAccess', _531 => _531.randomUUID, 'optionalCall', _532 => _532()]), () => ( `b-${Math.random().toString(36).slice(2)}`));
|
|
8814
8873
|
}
|
|
8815
8874
|
function pathOfTaskItem(doc, root, li) {
|
|
8816
8875
|
const id = li.getAttribute("data-block-id");
|
|
8817
8876
|
if (id) {
|
|
8818
|
-
const p =
|
|
8877
|
+
const p = _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, id);
|
|
8819
8878
|
if (p)
|
|
8820
8879
|
return p;
|
|
8821
8880
|
}
|
|
@@ -8823,13 +8882,13 @@ function pathOfTaskItem(doc, root, li) {
|
|
|
8823
8882
|
if (!listEl)
|
|
8824
8883
|
return null;
|
|
8825
8884
|
const listId = listEl.getAttribute("data-block-id");
|
|
8826
|
-
const listPath = listId ?
|
|
8885
|
+
const listPath = listId ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, listId) : null;
|
|
8827
8886
|
if (!listPath)
|
|
8828
8887
|
return null;
|
|
8829
|
-
const list =
|
|
8830
|
-
if (!list ||
|
|
8888
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
8889
|
+
if (!list || _chunkGQ2HHRGIcjs.isText.call(void 0, list) || list.type !== "list")
|
|
8831
8890
|
return null;
|
|
8832
|
-
const items =
|
|
8891
|
+
const items = _chunkSLRD6FMPcjs.elementChildren.call(void 0, listEl);
|
|
8833
8892
|
const idx = items.indexOf(li);
|
|
8834
8893
|
if (idx < 0 || idx >= list.children.length)
|
|
8835
8894
|
return null;
|
|
@@ -8904,7 +8963,7 @@ function imgSrcFromHtml(html) {
|
|
|
8904
8963
|
return null;
|
|
8905
8964
|
const body = new DOMParser().parseFromString(html, "text/html").body;
|
|
8906
8965
|
const imgs = body.querySelectorAll("img");
|
|
8907
|
-
if (imgs.length !== 1 || _optionalChain([body, 'access',
|
|
8966
|
+
if (imgs.length !== 1 || _optionalChain([body, 'access', _533 => _533.textContent, 'optionalAccess', _534 => _534.trim, 'call', _535 => _535()]))
|
|
8908
8967
|
return null;
|
|
8909
8968
|
return imgs[0].getAttribute("src");
|
|
8910
8969
|
}
|
|
@@ -9027,4 +9086,4 @@ function diffSpan(a, b) {
|
|
|
9027
9086
|
|
|
9028
9087
|
|
|
9029
9088
|
|
|
9030
|
-
exports.atomIsSelected = atomIsSelected; exports.defaultBlockTag = defaultBlockTag; exports.defaultMarkTag = defaultMarkTag; exports.renderImage = renderImage; exports.safeCssValue = safeCssValue; exports.textStyleCss = textStyleCss; exports.renderEmbed = renderEmbed; exports.youtubeId = youtubeId; exports.twitchChannel = twitchChannel; exports.renderCode = renderCode; exports.renderTable = renderTable; exports.renderHr = renderHr; exports.defaultBlockRenderers = defaultBlockRenderers; exports.renderDoc = renderDoc; exports.renderToHtml = renderToHtml; exports.caret = caret; exports.leafText = leafText2; exports.wordBoundaryBack = wordBoundaryBack; exports.wordBoundaryFwd = wordBoundaryFwd; exports.lineBoundaryBack = lineBoundaryBack; exports.lineBoundaryFwd = lineBoundaryFwd; exports.isAtom = isAtom; exports.isOpaque = isOpaque; exports.mapInput = mapInput; exports.wrapList = wrapList; exports.CALLOUT_VARIANTS = CALLOUT_VARIANTS; exports.calloutVariantFromQuery = calloutVariantFromQuery; exports.blockTransform = blockTransform; exports.setCalloutVariant = setCalloutVariant; exports.cycleCalloutVariant = cycleCalloutVariant; exports.setAlign = setAlign2; exports.marksAtCaret = marksAtCaret; exports.toggleMarkList = toggleMarkList; exports.toggleMark = toggleMark; exports.mergeTextStyleAttrs = mergeTextStyleAttrs; exports.setTextStyle = setTextStyle; exports.serializeSelection = serializeSelection; exports.mapPaste = mapPaste; exports.mapPasteBlocks = mapPasteBlocks; exports.indentItem = indentItem; exports.outdentItem = outdentItem; exports.resolve = resolve; exports.textAlign = textAlign; exports.tableBlock = tableBlock; exports.codeBlock = codeBlock; exports.imageBlock = imageBlock; exports.embedBlock = embedBlock; exports.hrBlock = hrBlock; exports.blockExtensions = blockExtensions; exports.askInput = askInput; exports.normalizeLinkUrl = normalizeLinkUrl; exports.askLinkPopover = askLinkPopover; exports.closeAskInput = closeAskInput; exports.MentionMenu = MentionMenu; exports.codeControls = codeControls; exports.bubbleMenu = bubbleMenu; exports.slashMenu = slashMenu; exports.mentionMenu = mentionMenu; exports.dragHandle = dragHandle; exports.decorationExtensions = decorationExtensions; exports.history = history; exports.inputRules = inputRules; exports.boldMark = boldMark; exports.italicMark = italicMark; exports.codeMark = codeMark; exports.strikeMark = strikeMark; exports.underlineMark = underlineMark; exports.highlightMark = highlightMark; exports.superscriptMark = superscriptMark; exports.subscriptMark = subscriptMark; exports.linkMark = linkMark; exports.textStyleMark = textStyleMark; exports.markExtensions = markExtensions; exports.
|
|
9089
|
+
exports.atomIsSelected = atomIsSelected; exports.defaultBlockTag = defaultBlockTag; exports.defaultMarkTag = defaultMarkTag; exports.renderImage = renderImage; exports.safeCssValue = safeCssValue; exports.textStyleCss = textStyleCss; exports.renderEmbed = renderEmbed; exports.youtubeId = youtubeId; exports.twitchChannel = twitchChannel; exports.renderCode = renderCode; exports.renderTable = renderTable; exports.renderHr = renderHr; exports.defaultBlockRenderers = defaultBlockRenderers; exports.renderDoc = renderDoc; exports.renderToHtml = renderToHtml; exports.caret = caret; exports.leafText = leafText2; exports.wordBoundaryBack = wordBoundaryBack; exports.wordBoundaryFwd = wordBoundaryFwd; exports.lineBoundaryBack = lineBoundaryBack; exports.lineBoundaryFwd = lineBoundaryFwd; exports.isAtom = isAtom; exports.isOpaque = isOpaque; exports.mapInput = mapInput; exports.wrapList = wrapList; exports.CALLOUT_VARIANTS = CALLOUT_VARIANTS; exports.calloutVariantFromQuery = calloutVariantFromQuery; exports.blockTransform = blockTransform; exports.setCalloutVariant = setCalloutVariant; exports.cycleCalloutVariant = cycleCalloutVariant; exports.setAlign = setAlign2; exports.marksAtCaret = marksAtCaret; exports.toggleMarkList = toggleMarkList; exports.toggleMark = toggleMark; exports.mergeTextStyleAttrs = mergeTextStyleAttrs; exports.setTextStyle = setTextStyle; exports.serializeSelection = serializeSelection; exports.mapPaste = mapPaste; exports.mapPasteBlocks = mapPasteBlocks; exports.indentItem = indentItem; exports.outdentItem = outdentItem; exports.resolve = resolve; exports.textAlign = textAlign; exports.tableBlock = tableBlock; exports.codeBlock = codeBlock; exports.imageBlock = imageBlock; exports.embedBlock = embedBlock; exports.hrBlock = hrBlock; exports.blockExtensions = blockExtensions; exports.askInput = askInput; exports.normalizeLinkUrl = normalizeLinkUrl; exports.askLinkPopover = askLinkPopover; exports.closeAskInput = closeAskInput; exports.MentionMenu = MentionMenu; exports.codeControls = codeControls; exports.bubbleMenu = bubbleMenu; exports.slashMenu = slashMenu; exports.mentionMenu = mentionMenu; exports.dragHandle = dragHandle; exports.decorationExtensions = decorationExtensions; exports.history = history; exports.inputRules = inputRules; exports.boldMark = boldMark; exports.italicMark = italicMark; exports.codeMark = codeMark; exports.strikeMark = strikeMark; exports.underlineMark = underlineMark; exports.highlightMark = highlightMark; exports.superscriptMark = superscriptMark; exports.subscriptMark = subscriptMark; exports.linkMark = linkMark; exports.textStyleMark = textStyleMark; exports.markExtensions = markExtensions; exports.markloomKit = markloomKit; exports.CommentPanel = CommentPanel; exports.TocPanel = TocPanel; exports.MentionPopovers = MentionPopovers; exports.Editor = Editor; exports.chord = chord; exports.diffSpan = diffSpan;
|