markloom 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/ai.md +160 -0
- package/collab.md +70 -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 +3 -2
- package/dist/chunk-4JSJAHTB.js +255 -0
- package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
- package/dist/chunk-ALZ3A5CS.cjs +255 -0
- package/dist/{chunk-QXJHFQLJ.js → chunk-FCH7LZFI.js} +23 -15
- package/dist/chunk-GQ2HHRGI.cjs +16 -0
- 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-VSTOMEU2.cjs → chunk-VXM7Q6P5.cjs} +813 -478
- package/dist/{chunk-LNSKDJMF.cjs → chunk-YIFOGP2D.cjs} +46 -38
- package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
- package/dist/{chunk-VMUJM52A.js → chunk-ZMTLSFLO.js} +350 -15
- package/dist/client-6KiH4kGK.d.ts +144 -0
- package/dist/client-ZRZj2nkq.d.cts +144 -0
- package/dist/collab/index.cjs +25 -0
- package/dist/collab/index.d.cts +11 -0
- package/dist/collab/index.d.ts +11 -0
- package/dist/collab/index.js +25 -0
- package/dist/comments-DlExS6f-.d.cts +43 -0
- package/dist/comments-PhnR7Gkn.d.ts +43 -0
- package/dist/{controller-B_wG2Wh-.d.ts → controller-BNuuUM3E.d.ts} +26 -2
- package/dist/{controller-Cd1Dprrk.d.cts → controller-DQITsFhy.d.cts} +26 -2
- 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 +8 -5
- package/dist/react/index.d.cts +4 -2
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +7 -4
- 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 +5 -3
- package/dist/view/index.d.ts +5 -3
- package/dist/view/index.js +7 -4
- package/dist/view/theme.css +72 -0
- package/package.json +10 -3
- package/dist/comments-USjT1wYN.d.cts +0 -105
- package/dist/comments-USjT1wYN.d.ts +0 -105
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -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 _chunkYIFOGP2Dcjs = require('./chunk-YIFOGP2D.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -53,10 +53,17 @@ var _chunkLNSKDJMFcjs = require('./chunk-LNSKDJMF.cjs');
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
|
|
61
|
+
var _chunkALZ3A5CScjs = require('./chunk-ALZ3A5CS.cjs');
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
|
|
60
67
|
|
|
61
68
|
// src/view/render.ts
|
|
62
69
|
var _preact = require('preact');
|
|
@@ -518,7 +525,7 @@ function twitchChannel(url) {
|
|
|
518
525
|
}
|
|
519
526
|
}
|
|
520
527
|
function leafText(spec) {
|
|
521
|
-
return spec.children.map((c) =>
|
|
528
|
+
return spec.children.map((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text : _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c) ? "" : leafText(c)).join("");
|
|
522
529
|
}
|
|
523
530
|
function aiBtn(act, label, cls, extra) {
|
|
524
531
|
return _preact.h.call(void 0, "button", {
|
|
@@ -586,7 +593,7 @@ function renderAiBlock(spec, tag, props, opts) {
|
|
|
586
593
|
return vn;
|
|
587
594
|
const p = vn.props;
|
|
588
595
|
p.class = [p.class, "markloom-ai-prompt"].filter(Boolean).join(" ");
|
|
589
|
-
if (i === 0 && !
|
|
596
|
+
if (i === 0 && !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "paragraph" && leafText(c) === "") {
|
|
590
597
|
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
598
|
}
|
|
592
599
|
return vn;
|
|
@@ -658,9 +665,9 @@ function blockCtx(opts) {
|
|
|
658
665
|
};
|
|
659
666
|
}
|
|
660
667
|
function renderNode(node, key, opts) {
|
|
661
|
-
if (
|
|
668
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
662
669
|
return renderText(node, key, opts);
|
|
663
|
-
if (
|
|
670
|
+
if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, node))
|
|
664
671
|
return renderInlineAtom(node, key, opts);
|
|
665
672
|
const spec = node;
|
|
666
673
|
const renderer = opts.blockRenderers[spec.type];
|
|
@@ -743,7 +750,7 @@ function renderCode(spec, key, ctx) {
|
|
|
743
750
|
}
|
|
744
751
|
function renderTable(spec, key, ctx) {
|
|
745
752
|
const align = Array.isArray(_optionalChain([spec, 'access', _46 => _46.attrs, 'optionalAccess', _47 => _47.align])) ? spec.attrs.align : null;
|
|
746
|
-
const grid =
|
|
753
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, spec);
|
|
747
754
|
const freezeRows = Number(_nullishCoalesce(_optionalChain([spec, 'access', _48 => _48.attrs, 'optionalAccess', _49 => _49.freezeRows]), () => ( 0)));
|
|
748
755
|
const freezeCols = Number(_nullishCoalesce(_optionalChain([spec, 'access', _50 => _50.attrs, 'optionalAccess', _51 => _51.freezeCols]), () => ( 0)));
|
|
749
756
|
const cell = (cellNode, idx, tag) => {
|
|
@@ -783,7 +790,7 @@ function renderTable(spec, key, ctx) {
|
|
|
783
790
|
for (const r of Array.from(bodyRowsMap.keys()).sort((a, b) => a - b))
|
|
784
791
|
bodyRows.push(_preact.h.call(void 0, "tr", { key: r }, bodyRowsMap.get(r)));
|
|
785
792
|
const body = _preact.h.call(void 0, "tbody", { key: "tb" }, bodyRows);
|
|
786
|
-
const widths =
|
|
793
|
+
const widths = _chunk4TMHVNL6cjs.tableColWidths.call(void 0, spec);
|
|
787
794
|
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
795
|
const table = _preact.h.call(void 0, "table", {
|
|
789
796
|
"key": _nullishCoalesce(spec.id, () => ( key)),
|
|
@@ -822,9 +829,9 @@ function renderDoc(doc, opts = {}) {
|
|
|
822
829
|
atomSelect: opts.atomSelect
|
|
823
830
|
};
|
|
824
831
|
const first = doc.children[0];
|
|
825
|
-
const emptyLeaf = (n) => leafText(n) === "" && n.children.every((c) =>
|
|
832
|
+
const emptyLeaf = (n) => leafText(n) === "" && n.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
826
833
|
let emptyDocPh;
|
|
827
|
-
if (doc.children.length === 1 && first && !
|
|
834
|
+
if (doc.children.length === 1 && first && !_chunkGQ2HHRGIcjs.isText.call(void 0, first) && emptyLeaf(first)) {
|
|
828
835
|
if (first.type === "paragraph" && opts.placeholder)
|
|
829
836
|
emptyDocPh = opts.placeholder;
|
|
830
837
|
else if (first.type === "heading")
|
|
@@ -833,7 +840,7 @@ function renderDoc(doc, opts = {}) {
|
|
|
833
840
|
let foldDepth = null;
|
|
834
841
|
const kids = doc.children.map((c, i) => {
|
|
835
842
|
let foldHidden = false;
|
|
836
|
-
if (!
|
|
843
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "heading") {
|
|
837
844
|
const depth = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([c, 'access', _65 => _65.attrs, 'optionalAccess', _66 => _66.depth]), () => ( 2))), 1), 6);
|
|
838
845
|
if (foldDepth != null && depth <= foldDepth)
|
|
839
846
|
foldDepth = null;
|
|
@@ -873,8 +880,8 @@ function sameLeaf(a, b) {
|
|
|
873
880
|
return a.length === b.length && a.slice(0, -1).every((s, i) => s === b[i]);
|
|
874
881
|
}
|
|
875
882
|
function leafText2(doc, leafPath) {
|
|
876
|
-
const leaf =
|
|
877
|
-
return
|
|
883
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, leafPath);
|
|
884
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
878
885
|
}
|
|
879
886
|
function catOf(cp) {
|
|
880
887
|
if (cp === 32 || cp === 9 || cp === 10 || cp === 12 || cp === 13 || cp === 160)
|
|
@@ -930,8 +937,8 @@ function lineBoundaryFwd(text, offset3) {
|
|
|
930
937
|
function inTableCell(doc, blockPath) {
|
|
931
938
|
if (blockPath.length < 2)
|
|
932
939
|
return false;
|
|
933
|
-
const parent =
|
|
934
|
-
return !
|
|
940
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath.slice(0, -1));
|
|
941
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, parent) && parent.type === "table_cell";
|
|
935
942
|
}
|
|
936
943
|
function cmpPath(a, b) {
|
|
937
944
|
const n = Math.min(a.length, b.length);
|
|
@@ -949,7 +956,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
949
956
|
return { steps: [{ kind: "deleteText", path: a.leafPath, offset: a.char, length: b.char - a.char }], caret: lo };
|
|
950
957
|
const sameBlock = a.blockPath.length === b.blockPath.length && a.blockPath.every((s, i) => s === b.blockPath[i]);
|
|
951
958
|
if (sameBlock) {
|
|
952
|
-
const block =
|
|
959
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
953
960
|
const head2 = block.children.slice(0, a.leafIdx);
|
|
954
961
|
const fromLeaf = trimTail(block.children[a.leafIdx], a.char);
|
|
955
962
|
const toLeaf = trimHead(block.children[b.leafIdx], b.char);
|
|
@@ -971,7 +978,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
971
978
|
const loCell = loRel[0];
|
|
972
979
|
const hiCell = hiRel[0];
|
|
973
980
|
const children = fromTop.children.map((cell, i) => {
|
|
974
|
-
if (i < loCell || i > hiCell ||
|
|
981
|
+
if (i < loCell || i > hiCell || _chunkGQ2HHRGIcjs.isText.call(void 0, cell))
|
|
975
982
|
return cell;
|
|
976
983
|
if (i === loCell)
|
|
977
984
|
return keepBefore(cell, loRel.slice(1));
|
|
@@ -1003,7 +1010,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
1003
1010
|
insert.push(prunedHead);
|
|
1004
1011
|
if (prunedTail !== null && !isEmptyBlock(tail))
|
|
1005
1012
|
insert.push(prunedTail);
|
|
1006
|
-
caret3 = headLives ? lo : insert.length ? [loTop, ...
|
|
1013
|
+
caret3 = headLives ? lo : insert.length ? [loTop, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, insert[0]), 0] : [loTop, 0, 0];
|
|
1007
1014
|
}
|
|
1008
1015
|
return {
|
|
1009
1016
|
steps: [{ kind: "spliceChildren", path: [], at: loTop, remove: hiTop - loTop + 1, insert }],
|
|
@@ -1011,11 +1018,11 @@ function deleteRange(doc, p1, p2) {
|
|
|
1011
1018
|
};
|
|
1012
1019
|
}
|
|
1013
1020
|
function isEmptyBlock(block) {
|
|
1014
|
-
const text = (n) =>
|
|
1021
|
+
const text = (n) => _chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n.text : n.children.map(text).join("");
|
|
1015
1022
|
return text(block) === "";
|
|
1016
1023
|
}
|
|
1017
1024
|
function pruneEmpty(node) {
|
|
1018
|
-
if (
|
|
1025
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
1019
1026
|
return node;
|
|
1020
1027
|
const kids = node.children.map(pruneEmpty).filter((n) => n !== null);
|
|
1021
1028
|
if ((node.type === "list" || node.type === "list_item" || node.type === "quote") && kids.length === 0)
|
|
@@ -1024,7 +1031,7 @@ function pruneEmpty(node) {
|
|
|
1024
1031
|
}
|
|
1025
1032
|
function pruneBlock(node) {
|
|
1026
1033
|
const p = pruneEmpty(node);
|
|
1027
|
-
return p && !
|
|
1034
|
+
return p && !_chunkGQ2HHRGIcjs.isText.call(void 0, p) ? p : { type: "paragraph", id: node.id, children: [{ text: "" }] };
|
|
1028
1035
|
}
|
|
1029
1036
|
function keepBefore(node, rel) {
|
|
1030
1037
|
const idx = rel[0];
|
|
@@ -1066,16 +1073,16 @@ function appendLeavesAt(node, parentRel, leaves) {
|
|
|
1066
1073
|
return { ...node, children };
|
|
1067
1074
|
}
|
|
1068
1075
|
function trimTail(leaf, at) {
|
|
1069
|
-
return
|
|
1076
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(0, at) } : leaf;
|
|
1070
1077
|
}
|
|
1071
1078
|
function trimHead(leaf, at) {
|
|
1072
|
-
return
|
|
1079
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(at) } : leaf;
|
|
1073
1080
|
}
|
|
1074
1081
|
function isAtom(block) {
|
|
1075
|
-
return !
|
|
1082
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, block) && (block.type === "code" || block.type === "table" || block.type === "image" || block.type === "embed");
|
|
1076
1083
|
}
|
|
1077
1084
|
function isOpaque(block) {
|
|
1078
|
-
if (
|
|
1085
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
1079
1086
|
return false;
|
|
1080
1087
|
if (block.type === "table" || block.type === "image" || block.type === "embed")
|
|
1081
1088
|
return true;
|
|
@@ -1092,7 +1099,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1092
1099
|
const collapsed = from === to;
|
|
1093
1100
|
const parentPath = blockPath.slice(0, -1);
|
|
1094
1101
|
const blockIdx = blockPath[blockPath.length - 1];
|
|
1095
|
-
const block =
|
|
1102
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath);
|
|
1096
1103
|
if (intent === "insertLineBreak") {
|
|
1097
1104
|
if (block.type === "code" || block.type === "raw")
|
|
1098
1105
|
return mapInput(doc, "insertText", "\n", sel, newId4, rules, pendingMarks);
|
|
@@ -1104,7 +1111,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1104
1111
|
return null;
|
|
1105
1112
|
if (collapsed && rules.length) {
|
|
1106
1113
|
const leaf = block.children[leafIdx];
|
|
1107
|
-
const leafText3 =
|
|
1114
|
+
const leafText3 = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
1108
1115
|
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
1116
|
for (const rule of rules) {
|
|
1110
1117
|
const hit = rule.match(ctx);
|
|
@@ -1124,18 +1131,18 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1124
1131
|
}
|
|
1125
1132
|
case "insertParagraph": {
|
|
1126
1133
|
{
|
|
1127
|
-
const aiParent = parentPath.length ?
|
|
1134
|
+
const aiParent = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1128
1135
|
if (aiParent && aiParent.type === "ai")
|
|
1129
1136
|
return null;
|
|
1130
1137
|
}
|
|
1131
1138
|
if (block.type === "code") {
|
|
1132
1139
|
const codeLeaf = block.children[leafIdx];
|
|
1133
|
-
const codeText =
|
|
1140
|
+
const codeText = _chunkGQ2HHRGIcjs.isText.call(void 0, codeLeaf) ? codeLeaf.text : "";
|
|
1134
1141
|
if (collapsed && from === codeText.length && codeText.endsWith("\n")) {
|
|
1135
1142
|
const trimmed = codeText.slice(0, -1);
|
|
1136
1143
|
const kept = {
|
|
1137
1144
|
...block,
|
|
1138
|
-
children: [{ ...
|
|
1145
|
+
children: [{ ..._chunkGQ2HHRGIcjs.isText.call(void 0, codeLeaf) ? codeLeaf : { text: "" }, text: trimmed }]
|
|
1139
1146
|
};
|
|
1140
1147
|
const after = { type: "paragraph", id: newId4(), children: [{ text: "" }] };
|
|
1141
1148
|
return {
|
|
@@ -1152,22 +1159,22 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1152
1159
|
};
|
|
1153
1160
|
}
|
|
1154
1161
|
const splitLeaf = block.children[leafIdx];
|
|
1155
|
-
const splitText =
|
|
1162
|
+
const splitText = _chunkGQ2HHRGIcjs.isText.call(void 0, splitLeaf) ? splitLeaf.text : "";
|
|
1156
1163
|
const keepChildren = [...block.children.slice(0, leafIdx), { ...splitLeaf, text: splitText.slice(0, from) }];
|
|
1157
1164
|
const freshChildren = [{ ...splitLeaf, text: splitText.slice(to) }, ...block.children.slice(leafIdx + 1)];
|
|
1158
1165
|
const keep = { ...block, children: keepChildren };
|
|
1159
1166
|
const fresh = { type: "paragraph", id: newId4(), children: freshChildren };
|
|
1160
|
-
const itemNode = parentPath.length ?
|
|
1167
|
+
const itemNode = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1161
1168
|
if (itemNode && itemNode.type === "list_item") {
|
|
1162
1169
|
const itemIdx = parentPath[parentPath.length - 1];
|
|
1163
1170
|
const listPath = parentPath.slice(0, -1);
|
|
1164
|
-
const isLastItem = itemIdx ===
|
|
1171
|
+
const isLastItem = itemIdx === _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath).children.length - 1;
|
|
1165
1172
|
if (itemNode.children.length === 1 && isEmptyBlock(itemNode) && isLastItem) {
|
|
1166
1173
|
const listParentPath = listPath.slice(0, -1);
|
|
1167
|
-
const listParent =
|
|
1174
|
+
const listParent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listParentPath);
|
|
1168
1175
|
if (listParent.type === "list_item")
|
|
1169
1176
|
return outdentItem(doc, sel, newId4);
|
|
1170
|
-
const list =
|
|
1177
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
1171
1178
|
const before = list.children.slice(0, itemIdx);
|
|
1172
1179
|
const after = list.children.slice(itemIdx + 1);
|
|
1173
1180
|
const lifted = { type: "paragraph", id: itemNode.id, children: [{ text: "" }] };
|
|
@@ -1222,19 +1229,40 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1222
1229
|
if (from > 0)
|
|
1223
1230
|
return { steps: [{ kind: "deleteText", path: leafPath, offset: from - 1, length: 1 }], selection: caret(leafPath.concat(from - 1)) };
|
|
1224
1231
|
{
|
|
1225
|
-
const aiParent = parentPath.length ?
|
|
1226
|
-
if (aiParent && aiParent.type === "ai" && isEmptyBlock(block) && leafIdx === 0) {
|
|
1227
|
-
const
|
|
1232
|
+
const aiParent = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1233
|
+
if (aiParent && aiParent.type === "ai" && aiParent.id && isEmptyBlock(block) && leafIdx === 0) {
|
|
1234
|
+
const aiId = aiParent.id;
|
|
1235
|
+
const steps = [];
|
|
1236
|
+
const draftAt = [];
|
|
1237
|
+
for (let i = 0; i < doc.children.length; i++) {
|
|
1238
|
+
const c = doc.children[i];
|
|
1239
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && _optionalChain([c, 'access', _73 => _73.attrs, 'optionalAccess', _74 => _74.aiFrom]) === aiId)
|
|
1240
|
+
draftAt.push(i);
|
|
1241
|
+
}
|
|
1242
|
+
for (let i = draftAt.length - 1; i >= 0; i--)
|
|
1243
|
+
steps.push({ kind: "spliceChildren", path: [], at: draftAt[i], remove: 1, insert: [] });
|
|
1244
|
+
let aiIdx = _nullishCoalesce(parentPath[0], () => ( 0));
|
|
1245
|
+
let shift3 = 0;
|
|
1246
|
+
for (const i of draftAt) {
|
|
1247
|
+
if (i < aiIdx)
|
|
1248
|
+
shift3++;
|
|
1249
|
+
}
|
|
1250
|
+
aiIdx -= shift3;
|
|
1251
|
+
steps.push({
|
|
1252
|
+
kind: "replaceNode",
|
|
1253
|
+
path: [aiIdx],
|
|
1254
|
+
node: { type: "paragraph", id: aiId, children: [{ text: "" }] }
|
|
1255
|
+
});
|
|
1228
1256
|
return {
|
|
1229
|
-
steps
|
|
1230
|
-
selection: caret([
|
|
1257
|
+
steps,
|
|
1258
|
+
selection: caret([Math.max(0, aiIdx), 0, 0])
|
|
1231
1259
|
};
|
|
1232
1260
|
}
|
|
1233
1261
|
}
|
|
1234
1262
|
const prevInBlock = block.children[leafIdx - 1];
|
|
1235
|
-
if (leafIdx > 0 && prevInBlock &&
|
|
1263
|
+
if (leafIdx > 0 && prevInBlock && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, prevInBlock)) {
|
|
1236
1264
|
const before = block.children[leafIdx - 2];
|
|
1237
|
-
const landing = before &&
|
|
1265
|
+
const landing = before && _chunkGQ2HHRGIcjs.isText.call(void 0, before) ? [...blockPath, leafIdx - 2, before.text.length] : [...blockPath, leafIdx - 1, 0];
|
|
1238
1266
|
return { steps: [{ kind: "spliceChildren", path: blockPath, at: leafIdx - 1, remove: 1, insert: [] }], selection: caret(landing) };
|
|
1239
1267
|
}
|
|
1240
1268
|
if (blockIdx <= 0) {
|
|
@@ -1244,10 +1272,10 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1244
1272
|
const idx = cp[cp.length - 1];
|
|
1245
1273
|
if (idx < 1)
|
|
1246
1274
|
continue;
|
|
1247
|
-
const prevSib =
|
|
1248
|
-
if (
|
|
1275
|
+
const prevSib = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, cp.slice(0, -1)).children[idx - 1];
|
|
1276
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, prevSib))
|
|
1249
1277
|
break;
|
|
1250
|
-
const endOfPrev2 = [...cp.slice(0, -1), idx - 1, ...
|
|
1278
|
+
const endOfPrev2 = [...cp.slice(0, -1), idx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prevSib)];
|
|
1251
1279
|
const del2 = deleteRange(doc, endOfPrev2, sel.head.path);
|
|
1252
1280
|
return { steps: del2.steps, selection: caret(del2.caret) };
|
|
1253
1281
|
}
|
|
@@ -1257,11 +1285,11 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1257
1285
|
}
|
|
1258
1286
|
return null;
|
|
1259
1287
|
}
|
|
1260
|
-
const parent =
|
|
1288
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
1261
1289
|
const prev = parent.children[blockIdx - 1];
|
|
1262
|
-
if (!prev ||
|
|
1290
|
+
if (!prev || _chunkGQ2HHRGIcjs.isText.call(void 0, prev))
|
|
1263
1291
|
return null;
|
|
1264
|
-
const endOfPrev = [...parentPath, blockIdx - 1, ...
|
|
1292
|
+
const endOfPrev = [...parentPath, blockIdx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prev)];
|
|
1265
1293
|
const del = deleteRange(doc, endOfPrev, sel.head.path);
|
|
1266
1294
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1267
1295
|
}
|
|
@@ -1272,28 +1300,28 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1272
1300
|
if (from < text.length)
|
|
1273
1301
|
return { steps: [{ kind: "deleteText", path: leafPath, offset: from, length: 1 }], selection: caret(leafPath.concat(from)) };
|
|
1274
1302
|
const nextInBlock = block.children[leafIdx + 1];
|
|
1275
|
-
if (nextInBlock &&
|
|
1303
|
+
if (nextInBlock && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, nextInBlock))
|
|
1276
1304
|
return { steps: [{ kind: "spliceChildren", path: blockPath, at: leafIdx + 1, remove: 1, insert: [] }], selection: caret(leafPath.concat(from)) };
|
|
1277
|
-
const parent =
|
|
1305
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
1278
1306
|
const next = parent.children[blockIdx + 1];
|
|
1279
|
-
if (!next ||
|
|
1307
|
+
if (!next || _chunkGQ2HHRGIcjs.isText.call(void 0, next)) {
|
|
1280
1308
|
if (inTableCell(doc, blockPath))
|
|
1281
1309
|
return null;
|
|
1282
1310
|
for (let cp = parentPath; cp.length > 0; cp = cp.slice(0, -1)) {
|
|
1283
1311
|
const idx = cp[cp.length - 1];
|
|
1284
|
-
const sibs =
|
|
1312
|
+
const sibs = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, cp.slice(0, -1)).children;
|
|
1285
1313
|
const nextSib = sibs[idx + 1];
|
|
1286
1314
|
if (!nextSib)
|
|
1287
1315
|
continue;
|
|
1288
|
-
if (
|
|
1316
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, nextSib))
|
|
1289
1317
|
break;
|
|
1290
|
-
const startOfNext2 = [...cp.slice(0, -1), idx + 1, ...
|
|
1318
|
+
const startOfNext2 = [...cp.slice(0, -1), idx + 1, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, nextSib), 0];
|
|
1291
1319
|
const del2 = deleteRange(doc, sel.head.path, startOfNext2);
|
|
1292
1320
|
return { steps: del2.steps, selection: caret(del2.caret) };
|
|
1293
1321
|
}
|
|
1294
1322
|
return null;
|
|
1295
1323
|
}
|
|
1296
|
-
const startOfNext = [...parentPath, blockIdx + 1, ...
|
|
1324
|
+
const startOfNext = [...parentPath, blockIdx + 1, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, next), 0];
|
|
1297
1325
|
const del = deleteRange(doc, sel.head.path, startOfNext);
|
|
1298
1326
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1299
1327
|
}
|
|
@@ -1302,7 +1330,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1302
1330
|
function wrapList(block, blockIdx, newId4, rest, tail, ordered, start) {
|
|
1303
1331
|
const para = { type: "paragraph", id: newId4(), children: [{ text: rest }, ...tail] };
|
|
1304
1332
|
const item = { type: "list_item", id: newId4(), children: [para] };
|
|
1305
|
-
const span = _optionalChain([block, 'access',
|
|
1333
|
+
const span = _optionalChain([block, 'access', _75 => _75.attrs, 'optionalAccess', _76 => _76.span]);
|
|
1306
1334
|
const attrs = ordered ? { span, ordered: true, start: start === 1 ? void 0 : start } : { span, ordered: false };
|
|
1307
1335
|
const list = { ...block, type: "list", attrs, children: [item] };
|
|
1308
1336
|
return { steps: [{ kind: "replaceNode", path: [blockIdx], node: list }], selection: caret([blockIdx, 0, 0, 0, 0]) };
|
|
@@ -1321,7 +1349,7 @@ function calloutVariantFromQuery(q) {
|
|
|
1321
1349
|
function blockTransform(block, blockIdx, kind, newId4, extra) {
|
|
1322
1350
|
const kids = block.type === "quote" || block.type === "list" ? [{ text: "" }] : block.children;
|
|
1323
1351
|
const bp = [blockIdx];
|
|
1324
|
-
const span = _optionalChain([block, 'access',
|
|
1352
|
+
const span = _optionalChain([block, 'access', _77 => _77.attrs, 'optionalAccess', _78 => _78.span]);
|
|
1325
1353
|
switch (kind) {
|
|
1326
1354
|
case "heading1":
|
|
1327
1355
|
case "heading2":
|
|
@@ -1335,7 +1363,7 @@ function blockTransform(block, blockIdx, kind, newId4, extra) {
|
|
|
1335
1363
|
}
|
|
1336
1364
|
case "callout": {
|
|
1337
1365
|
const inner = { type: "paragraph", id: newId4(), children: kids };
|
|
1338
|
-
const variant = _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
1366
|
+
const variant = _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _79 => _79.variant]), () => ( "info"));
|
|
1339
1367
|
return { steps: [{ kind: "replaceNode", path: bp, node: { type: "callout", id: block.id, attrs: { span, variant }, children: [inner] } }], selection: caret([blockIdx, 0, 0, 0]) };
|
|
1340
1368
|
}
|
|
1341
1369
|
case "bullet":
|
|
@@ -1354,10 +1382,10 @@ function blockTransform(block, blockIdx, kind, newId4, extra) {
|
|
|
1354
1382
|
}
|
|
1355
1383
|
}
|
|
1356
1384
|
function setCalloutVariant(doc, path, variant) {
|
|
1357
|
-
const node =
|
|
1358
|
-
if (!node ||
|
|
1385
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
1386
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "callout")
|
|
1359
1387
|
return null;
|
|
1360
|
-
if (_optionalChain([node, 'access',
|
|
1388
|
+
if (_optionalChain([node, 'access', _80 => _80.attrs, 'optionalAccess', _81 => _81.variant]) === variant)
|
|
1361
1389
|
return null;
|
|
1362
1390
|
return {
|
|
1363
1391
|
steps: [{ kind: "replaceNode", path, node: { ...node, attrs: { ...node.attrs, variant } } }],
|
|
@@ -1365,10 +1393,10 @@ function setCalloutVariant(doc, path, variant) {
|
|
|
1365
1393
|
};
|
|
1366
1394
|
}
|
|
1367
1395
|
function cycleCalloutVariant(doc, path) {
|
|
1368
|
-
const node =
|
|
1369
|
-
if (!node ||
|
|
1396
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
1397
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "callout")
|
|
1370
1398
|
return null;
|
|
1371
|
-
const cur = String(_nullishCoalesce(_optionalChain([node, 'access',
|
|
1399
|
+
const cur = String(_nullishCoalesce(_optionalChain([node, 'access', _82 => _82.attrs, 'optionalAccess', _83 => _83.variant]), () => ( "info")));
|
|
1372
1400
|
const i = CALLOUT_VARIANTS.indexOf(cur);
|
|
1373
1401
|
const next = CALLOUT_VARIANTS[(i >= 0 ? i + 1 : 1) % CALLOUT_VARIANTS.length];
|
|
1374
1402
|
return setCalloutVariant(doc, path, next);
|
|
@@ -1396,7 +1424,7 @@ function mapCrossInput(doc, intent, data, sel, newId4) {
|
|
|
1396
1424
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1397
1425
|
if (intent === "insertText" && !data)
|
|
1398
1426
|
return null;
|
|
1399
|
-
const doc2 =
|
|
1427
|
+
const doc2 = _chunk4TMHVNL6cjs.applyAll.call(void 0, doc, del.steps);
|
|
1400
1428
|
const at = caret(del.caret);
|
|
1401
1429
|
const tail = mapInput(doc2, intent, data, at, newId4);
|
|
1402
1430
|
if (!tail)
|
|
@@ -1405,8 +1433,8 @@ function mapCrossInput(doc, intent, data, sel, newId4) {
|
|
|
1405
1433
|
}
|
|
1406
1434
|
var markable = (n) => n.type !== "code" && n.type !== "raw";
|
|
1407
1435
|
function marksAtCaret(doc, path) {
|
|
1408
|
-
const leaf =
|
|
1409
|
-
return
|
|
1436
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path.slice(0, -1));
|
|
1437
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? [..._nullishCoalesce(leaf.marks, () => ( []))] : [];
|
|
1410
1438
|
}
|
|
1411
1439
|
function toggleMarkList(marks, name, attrs) {
|
|
1412
1440
|
const on = attrs !== void 0 ? hasMarkEq(marks, name, attrs) : hasMark(marks, name);
|
|
@@ -1417,9 +1445,9 @@ function toggleMarkList(marks, name, attrs) {
|
|
|
1417
1445
|
function leafBlocksBetween(doc, fromBlock, toBlock) {
|
|
1418
1446
|
const all = [];
|
|
1419
1447
|
const walk = (node, path) => {
|
|
1420
|
-
if (!
|
|
1448
|
+
if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, node))
|
|
1421
1449
|
return;
|
|
1422
|
-
if (node.children.every((c) =>
|
|
1450
|
+
if (node.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) || _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c)))
|
|
1423
1451
|
all.push({ path, node });
|
|
1424
1452
|
else
|
|
1425
1453
|
node.children.forEach((c, i) => walk(c, [...path, i]));
|
|
@@ -1430,14 +1458,14 @@ function leafBlocksBetween(doc, fromBlock, toBlock) {
|
|
|
1430
1458
|
return fi < 0 || ti < 0 ? [] : all.slice(fi, ti + 1);
|
|
1431
1459
|
}
|
|
1432
1460
|
function totalChars(children) {
|
|
1433
|
-
return children.reduce((a, c) => a + (
|
|
1461
|
+
return children.reduce((a, c) => a + (_chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1), 0);
|
|
1434
1462
|
}
|
|
1435
1463
|
function spannedSegs(block, from, to) {
|
|
1436
1464
|
const out = [];
|
|
1437
1465
|
let pos = 0;
|
|
1438
1466
|
for (const leaf of block.children) {
|
|
1439
|
-
const len =
|
|
1440
|
-
if (
|
|
1467
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 1;
|
|
1468
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1441
1469
|
const lo = Math.max(from, pos);
|
|
1442
1470
|
const hi = Math.min(to, pos + len);
|
|
1443
1471
|
if (lo < hi)
|
|
@@ -1451,7 +1479,7 @@ function markChars(block, from, to, name, on, attrs) {
|
|
|
1451
1479
|
const out = [];
|
|
1452
1480
|
let pos = 0;
|
|
1453
1481
|
for (const leaf of block.children) {
|
|
1454
|
-
if (!
|
|
1482
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1455
1483
|
out.push(leaf);
|
|
1456
1484
|
pos += 1;
|
|
1457
1485
|
continue;
|
|
@@ -1521,8 +1549,8 @@ function mergeTextStyleAttrs(attrs, patch) {
|
|
|
1521
1549
|
return Object.keys(out).length ? out : null;
|
|
1522
1550
|
}
|
|
1523
1551
|
function applyTextStyleLeaf(leaf, patch) {
|
|
1524
|
-
const cur = _optionalChain([leaf, 'access',
|
|
1525
|
-
const merged = mergeTextStyleAttrs(_optionalChain([cur, 'optionalAccess',
|
|
1552
|
+
const cur = _optionalChain([leaf, 'access', _84 => _84.marks, 'optionalAccess', _85 => _85.find, 'call', _86 => _86((m) => m.name === "textStyle")]);
|
|
1553
|
+
const merged = mergeTextStyleAttrs(_optionalChain([cur, 'optionalAccess', _87 => _87.attrs]), patch);
|
|
1526
1554
|
const rest = (_nullishCoalesce(leaf.marks, () => ( []))).filter((m) => m.name !== "textStyle");
|
|
1527
1555
|
if (!merged)
|
|
1528
1556
|
return { ...leaf, marks: rest.length ? rest : void 0 };
|
|
@@ -1532,7 +1560,7 @@ function textStyleChars(block, from, to, patch) {
|
|
|
1532
1560
|
const out = [];
|
|
1533
1561
|
let pos = 0;
|
|
1534
1562
|
for (const leaf of block.children) {
|
|
1535
|
-
if (!
|
|
1563
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1536
1564
|
out.push(leaf);
|
|
1537
1565
|
pos += 1;
|
|
1538
1566
|
continue;
|
|
@@ -1578,11 +1606,11 @@ function setTextStyle(doc, sel, patch) {
|
|
|
1578
1606
|
};
|
|
1579
1607
|
}
|
|
1580
1608
|
function sliceLeaf(leaf, from, to) {
|
|
1581
|
-
return
|
|
1609
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(from, to) } : leaf;
|
|
1582
1610
|
}
|
|
1583
1611
|
function insertMarked(block, blockPath, leafIdx, from, to, text, marks) {
|
|
1584
1612
|
const leaf = block.children[leafIdx];
|
|
1585
|
-
if (!
|
|
1613
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
1586
1614
|
return null;
|
|
1587
1615
|
const markList = marks.length ? marks : void 0;
|
|
1588
1616
|
if (from === to && marksEq(leaf.marks, markList)) {
|
|
@@ -1610,10 +1638,10 @@ function insertMarked(block, blockPath, leafIdx, from, to, text, marks) {
|
|
|
1610
1638
|
};
|
|
1611
1639
|
}
|
|
1612
1640
|
function hasMark(marks, name) {
|
|
1613
|
-
return !!_optionalChain([marks, 'optionalAccess',
|
|
1641
|
+
return !!_optionalChain([marks, 'optionalAccess', _88 => _88.some, 'call', _89 => _89((m) => m.name === name)]);
|
|
1614
1642
|
}
|
|
1615
1643
|
function hasMarkEq(marks, name, attrs) {
|
|
1616
|
-
return !!_optionalChain([marks, 'optionalAccess',
|
|
1644
|
+
return !!_optionalChain([marks, 'optionalAccess', _90 => _90.some, 'call', _91 => _91((m) => m.name === name && attrsEq(m.attrs, attrs))]);
|
|
1617
1645
|
}
|
|
1618
1646
|
function setMark(leaf, name, on, attrs) {
|
|
1619
1647
|
if (on) {
|
|
@@ -1627,7 +1655,7 @@ function insertHardBreak(block, blockPath, leafIdx, from, to) {
|
|
|
1627
1655
|
if (block.type !== "paragraph" && block.type !== "heading")
|
|
1628
1656
|
return null;
|
|
1629
1657
|
const leaf = block.children[leafIdx];
|
|
1630
|
-
if (!
|
|
1658
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
1631
1659
|
return null;
|
|
1632
1660
|
const before = leaf.text.slice(0, from);
|
|
1633
1661
|
const after = leaf.text.slice(to);
|
|
@@ -1644,7 +1672,7 @@ function insertHardBreak(block, blockPath, leafIdx, from, to) {
|
|
|
1644
1672
|
]);
|
|
1645
1673
|
const brAt = leafIdx + (before ? 1 : 0);
|
|
1646
1674
|
const afterIdx = brAt + 1;
|
|
1647
|
-
const landIdx = afterIdx < children.length &&
|
|
1675
|
+
const landIdx = afterIdx < children.length && _chunkGQ2HHRGIcjs.isText.call(void 0, children[afterIdx]) ? afterIdx : brAt;
|
|
1648
1676
|
return {
|
|
1649
1677
|
steps: [{ kind: "replaceNode", path: blockPath, node: { ...block, children } }],
|
|
1650
1678
|
selection: caret([...blockPath, landIdx, 0])
|
|
@@ -1654,21 +1682,21 @@ function coalesceLeaves(children) {
|
|
|
1654
1682
|
const out = [];
|
|
1655
1683
|
for (let i = 0; i < children.length; i++) {
|
|
1656
1684
|
const n = children[i];
|
|
1657
|
-
if (
|
|
1685
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.text === "" && children.length > 1) {
|
|
1658
1686
|
const prev2 = out[out.length - 1];
|
|
1659
1687
|
const next = children[i + 1];
|
|
1660
|
-
if (prev2 &&
|
|
1688
|
+
if (prev2 && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, prev2)) {
|
|
1661
1689
|
out.push(n);
|
|
1662
1690
|
continue;
|
|
1663
1691
|
}
|
|
1664
|
-
if (next &&
|
|
1692
|
+
if (next && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, next)) {
|
|
1665
1693
|
out.push(n);
|
|
1666
1694
|
continue;
|
|
1667
1695
|
}
|
|
1668
1696
|
continue;
|
|
1669
1697
|
}
|
|
1670
1698
|
const prev = out[out.length - 1];
|
|
1671
|
-
if (prev &&
|
|
1699
|
+
if (prev && _chunkGQ2HHRGIcjs.isText.call(void 0, prev) && _chunkGQ2HHRGIcjs.isText.call(void 0, n) && marksEq(prev.marks, n.marks))
|
|
1672
1700
|
out[out.length - 1] = { ...prev, text: prev.text + n.text };
|
|
1673
1701
|
else
|
|
1674
1702
|
out.push(n);
|
|
@@ -1689,7 +1717,7 @@ function blockChar(children, leafIdx, char) {
|
|
|
1689
1717
|
let acc = 0;
|
|
1690
1718
|
for (let i = 0; i < leafIdx; i++) {
|
|
1691
1719
|
const c = children[i];
|
|
1692
|
-
acc +=
|
|
1720
|
+
acc += _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1;
|
|
1693
1721
|
}
|
|
1694
1722
|
return acc + char;
|
|
1695
1723
|
}
|
|
@@ -1697,32 +1725,32 @@ function locate(children, target) {
|
|
|
1697
1725
|
let acc = 0;
|
|
1698
1726
|
for (let i = 0; i < children.length; i++) {
|
|
1699
1727
|
const c = children[i];
|
|
1700
|
-
const len =
|
|
1728
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1;
|
|
1701
1729
|
if (target <= acc + len)
|
|
1702
1730
|
return [i, target - acc];
|
|
1703
1731
|
acc += len;
|
|
1704
1732
|
}
|
|
1705
1733
|
const last = children.length - 1;
|
|
1706
1734
|
const lc = children[last];
|
|
1707
|
-
return [last,
|
|
1735
|
+
return [last, _chunkGQ2HHRGIcjs.isText.call(void 0, lc) ? lc.text.length : 1];
|
|
1708
1736
|
}
|
|
1709
1737
|
function textLen(ns) {
|
|
1710
|
-
return ns.reduce((a, n) => a + (
|
|
1738
|
+
return ns.reduce((a, n) => a + (_chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n.text.length : 1), 0);
|
|
1711
1739
|
}
|
|
1712
1740
|
function stripSpan(b) {
|
|
1713
|
-
return _optionalChain([b, 'access',
|
|
1741
|
+
return _optionalChain([b, 'access', _92 => _92.attrs, 'optionalAccess', _93 => _93.span]) ? { ...b, attrs: { ...b.attrs, span: void 0 } } : b;
|
|
1714
1742
|
}
|
|
1715
1743
|
function sliceDoc(doc, p1, p2) {
|
|
1716
1744
|
const [lo, hi] = cmpPath(p1, p2) <= 0 ? [p1, p2] : [p2, p1];
|
|
1717
1745
|
const a = split(lo);
|
|
1718
1746
|
const b = split(hi);
|
|
1719
1747
|
if (sameLeaf(lo, hi)) {
|
|
1720
|
-
const block =
|
|
1748
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
1721
1749
|
return { type: "doc", children: [stripSpan({ ...block, children: [sliceLeaf(block.children[a.leafIdx], a.char, b.char)] })] };
|
|
1722
1750
|
}
|
|
1723
1751
|
const sameBlock = a.blockPath.length === b.blockPath.length && a.blockPath.every((s, i) => s === b.blockPath[i]);
|
|
1724
1752
|
if (sameBlock) {
|
|
1725
|
-
const block =
|
|
1753
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
1726
1754
|
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
1755
|
return { type: "doc", children: [stripSpan({ ...block, children: coalesceLeaves(mid) })] };
|
|
1728
1756
|
}
|
|
@@ -1731,7 +1759,7 @@ function sliceDoc(doc, p1, p2) {
|
|
|
1731
1759
|
if (loTop === hiTop && doc.children[loTop].type === "table")
|
|
1732
1760
|
return { type: "doc", children: [stripSpan(doc.children[loTop])] };
|
|
1733
1761
|
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) =>
|
|
1762
|
+
const middle = doc.children.slice(loTop + 1, hiTop).map((n) => _chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n : stripSpan(n));
|
|
1735
1763
|
const last = doc.children[hiTop].type === "table" ? stripSpan(doc.children[hiTop]) : stripSpan(keepBefore(doc.children[hiTop], hi.slice(1)));
|
|
1736
1764
|
return { type: "doc", children: [first, ...middle, last] };
|
|
1737
1765
|
}
|
|
@@ -1745,10 +1773,10 @@ function keepAfter(node, rel) {
|
|
|
1745
1773
|
function serializeSelection(doc, sel) {
|
|
1746
1774
|
if (cmpPath(sel.anchor.path, sel.head.path) === 0)
|
|
1747
1775
|
return "";
|
|
1748
|
-
return
|
|
1776
|
+
return _chunk4TMHVNL6cjs.docToMd.call(void 0, sliceDoc(doc, sel.anchor.path, sel.head.path), "");
|
|
1749
1777
|
}
|
|
1750
1778
|
function mapPaste(doc, sel, md, newId4) {
|
|
1751
|
-
const frag =
|
|
1779
|
+
const frag = _chunk4TMHVNL6cjs.mdToDoc.call(void 0, md).children.filter((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
1752
1780
|
return mapPasteBlocks(doc, sel, frag, newId4);
|
|
1753
1781
|
}
|
|
1754
1782
|
function mapPasteBlocks(doc, sel, frag, newId4) {
|
|
@@ -1756,7 +1784,7 @@ function mapPasteBlocks(doc, sel, frag, newId4) {
|
|
|
1756
1784
|
return null;
|
|
1757
1785
|
if (cmpPath(sel.anchor.path, sel.head.path) !== 0) {
|
|
1758
1786
|
const del = deleteRange(doc, sel.anchor.path, sel.head.path);
|
|
1759
|
-
const r = pasteAt(
|
|
1787
|
+
const r = pasteAt(_chunk4TMHVNL6cjs.applyAll.call(void 0, doc, del.steps), del.caret, frag, newId4);
|
|
1760
1788
|
return { steps: [...del.steps, ...r.steps], selection: r.selection };
|
|
1761
1789
|
}
|
|
1762
1790
|
return pasteAt(doc, sel.head.path, frag, newId4);
|
|
@@ -1767,13 +1795,13 @@ function indentItem(doc, sel, newId4) {
|
|
|
1767
1795
|
const itemIdx = itemPath[itemPath.length - 1];
|
|
1768
1796
|
if (itemIdx === 0)
|
|
1769
1797
|
return null;
|
|
1770
|
-
const list =
|
|
1771
|
-
if (!list ||
|
|
1798
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
1799
|
+
if (!list || _chunkGQ2HHRGIcjs.isText.call(void 0, list) || list.type !== "list")
|
|
1772
1800
|
return null;
|
|
1773
1801
|
const item = list.children[itemIdx];
|
|
1774
1802
|
const prev = list.children[itemIdx - 1];
|
|
1775
1803
|
const prevLast = prev.children[prev.children.length - 1];
|
|
1776
|
-
const intoExisting = !
|
|
1804
|
+
const intoExisting = !_chunkGQ2HHRGIcjs.isText.call(void 0, prevLast) && prevLast.type === "list";
|
|
1777
1805
|
const sublist = intoExisting ? { ...prevLast, children: [...prevLast.children, item] } : { ...list, id: newId4(), children: [item] };
|
|
1778
1806
|
const subIdx = intoExisting ? prev.children.length - 1 : prev.children.length;
|
|
1779
1807
|
const newPrev = { ...prev, children: intoExisting ? [...prev.children.slice(0, -1), sublist] : [...prev.children, sublist] };
|
|
@@ -1787,17 +1815,17 @@ function outdentItem(doc, sel, newId4) {
|
|
|
1787
1815
|
const itemPath = sel.head.path.slice(0, -3);
|
|
1788
1816
|
const sublistPath = itemPath.slice(0, -1);
|
|
1789
1817
|
const parentItemPath = sublistPath.slice(0, -1);
|
|
1790
|
-
const parentItem =
|
|
1818
|
+
const parentItem = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentItemPath);
|
|
1791
1819
|
if (!parentItem || parentItem.type !== "list_item")
|
|
1792
1820
|
return null;
|
|
1793
|
-
const sublist =
|
|
1794
|
-
if (!sublist ||
|
|
1821
|
+
const sublist = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, sublistPath);
|
|
1822
|
+
if (!sublist || _chunkGQ2HHRGIcjs.isText.call(void 0, sublist) || sublist.type !== "list")
|
|
1795
1823
|
return null;
|
|
1796
1824
|
const subItemIdx = itemPath[itemPath.length - 1];
|
|
1797
1825
|
const item = sublist.children[subItemIdx];
|
|
1798
1826
|
const following = sublist.children.slice(subItemIdx + 1);
|
|
1799
1827
|
const itemLast = item.children[item.children.length - 1];
|
|
1800
|
-
const newItem = following.length ? !
|
|
1828
|
+
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
1829
|
const subIdxInParent = sublistPath[sublistPath.length - 1];
|
|
1802
1830
|
const preceding = sublist.children.slice(0, subItemIdx);
|
|
1803
1831
|
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 +1838,7 @@ function outdentItem(doc, sel, newId4) {
|
|
|
1810
1838
|
};
|
|
1811
1839
|
}
|
|
1812
1840
|
function isInline(b) {
|
|
1813
|
-
return !isAtom(b) && b.children.every(
|
|
1841
|
+
return !isAtom(b) && b.children.every(_chunkGQ2HHRGIcjs.isText);
|
|
1814
1842
|
}
|
|
1815
1843
|
function splitDeep(block, path, newId4) {
|
|
1816
1844
|
if (path.length === 2) {
|
|
@@ -1827,7 +1855,7 @@ function splitDeep(block, path, newId4) {
|
|
|
1827
1855
|
return [head, tail];
|
|
1828
1856
|
}
|
|
1829
1857
|
function emptyInline(b) {
|
|
1830
|
-
return isInline(b) && b.children.every((c) =>
|
|
1858
|
+
return isInline(b) && b.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text === "");
|
|
1831
1859
|
}
|
|
1832
1860
|
function lastInlinePath(b) {
|
|
1833
1861
|
if (isInline(b))
|
|
@@ -1850,7 +1878,7 @@ function spliceInline(block, path, leaves, atTail) {
|
|
|
1850
1878
|
return { ...block, children: [...block.children.slice(0, i), child, ...block.children.slice(i + 1)] };
|
|
1851
1879
|
}
|
|
1852
1880
|
function inlineLeaves(b) {
|
|
1853
|
-
return b.children.flatMap((c) =>
|
|
1881
|
+
return b.children.flatMap((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? [c] : inlineLeaves(c));
|
|
1854
1882
|
}
|
|
1855
1883
|
function flattenInline(frag) {
|
|
1856
1884
|
const out = [];
|
|
@@ -1862,8 +1890,8 @@ function flattenInline(frag) {
|
|
|
1862
1890
|
return coalesceLeaves(out);
|
|
1863
1891
|
}
|
|
1864
1892
|
function pasteTableInto(caretPath, target, src) {
|
|
1865
|
-
const tGrid =
|
|
1866
|
-
const sGrid =
|
|
1893
|
+
const tGrid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, target);
|
|
1894
|
+
const sGrid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, src);
|
|
1867
1895
|
const cellIdx = _nullishCoalesce(caretPath[1], () => ( 0));
|
|
1868
1896
|
const anchor = tGrid.cellOf(cellIdx);
|
|
1869
1897
|
const r0 = anchor.r;
|
|
@@ -1895,9 +1923,9 @@ function pasteTableInto(caretPath, target, src) {
|
|
|
1895
1923
|
}
|
|
1896
1924
|
function pasteAt(doc, caretPath, frag, newId4) {
|
|
1897
1925
|
const { blockPath, leafIdx, char } = split(caretPath);
|
|
1898
|
-
const block =
|
|
1926
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath);
|
|
1899
1927
|
const topBlock = doc.children[caretPath[0]];
|
|
1900
|
-
const inAtom = !
|
|
1928
|
+
const inAtom = !_chunkGQ2HHRGIcjs.isText.call(void 0, topBlock) && topBlock.type === "table";
|
|
1901
1929
|
if (inAtom && frag.length === 1 && frag[0].type === "table") {
|
|
1902
1930
|
return pasteTableInto(caretPath, topBlock, frag[0]);
|
|
1903
1931
|
}
|
|
@@ -3232,7 +3260,7 @@ function askInput(opts) {
|
|
|
3232
3260
|
let value = _nullishCoalesce(opts.defaultValue, () => ( ""));
|
|
3233
3261
|
let error = null;
|
|
3234
3262
|
const finish = (v) => {
|
|
3235
|
-
if (_optionalChain([active, 'optionalAccess',
|
|
3263
|
+
if (_optionalChain([active, 'optionalAccess', _94 => _94.root]) !== root)
|
|
3236
3264
|
return;
|
|
3237
3265
|
dismissActive(v);
|
|
3238
3266
|
};
|
|
@@ -3324,8 +3352,8 @@ function askInput(opts) {
|
|
|
3324
3352
|
);
|
|
3325
3353
|
queueMicrotask(() => {
|
|
3326
3354
|
const el = root.querySelector("input, textarea");
|
|
3327
|
-
_optionalChain([el, 'optionalAccess',
|
|
3328
|
-
_optionalChain([el, 'optionalAccess',
|
|
3355
|
+
_optionalChain([el, 'optionalAccess', _95 => _95.focus, 'call', _96 => _96()]);
|
|
3356
|
+
_optionalChain([el, 'optionalAccess', _97 => _97.select, 'call', _98 => _98()]);
|
|
3329
3357
|
});
|
|
3330
3358
|
};
|
|
3331
3359
|
active = { resolve: resolve2, root, onKey };
|
|
@@ -3353,7 +3381,7 @@ function askLinkPopover(opts) {
|
|
|
3353
3381
|
let value = _nullishCoalesce(opts.defaultValue, () => ( ""));
|
|
3354
3382
|
let placed = false;
|
|
3355
3383
|
const finish = (v) => {
|
|
3356
|
-
if (_optionalChain([active, 'optionalAccess',
|
|
3384
|
+
if (_optionalChain([active, 'optionalAccess', _99 => _99.root]) !== root)
|
|
3357
3385
|
return;
|
|
3358
3386
|
dismissActive(v);
|
|
3359
3387
|
};
|
|
@@ -3377,7 +3405,7 @@ function askLinkPopover(opts) {
|
|
|
3377
3405
|
finish(null);
|
|
3378
3406
|
};
|
|
3379
3407
|
queueMicrotask(() => {
|
|
3380
|
-
if (_optionalChain([active, 'optionalAccess',
|
|
3408
|
+
if (_optionalChain([active, 'optionalAccess', _100 => _100.root]) === root)
|
|
3381
3409
|
document.addEventListener("pointerdown", onDocDown, true);
|
|
3382
3410
|
});
|
|
3383
3411
|
const paint = (focus = false) => {
|
|
@@ -3435,9 +3463,9 @@ function askLinkPopover(opts) {
|
|
|
3435
3463
|
if (focus) {
|
|
3436
3464
|
queueMicrotask(() => {
|
|
3437
3465
|
const input = root.querySelector("input");
|
|
3438
|
-
_optionalChain([input, 'optionalAccess',
|
|
3466
|
+
_optionalChain([input, 'optionalAccess', _101 => _101.focus, 'call', _102 => _102()]);
|
|
3439
3467
|
if (opts.defaultValue)
|
|
3440
|
-
_optionalChain([input, 'optionalAccess',
|
|
3468
|
+
_optionalChain([input, 'optionalAccess', _103 => _103.select, 'call', _104 => _104()]);
|
|
3441
3469
|
});
|
|
3442
3470
|
}
|
|
3443
3471
|
};
|
|
@@ -3480,7 +3508,7 @@ var MentionMenu = (_class = class {
|
|
|
3480
3508
|
}
|
|
3481
3509
|
// 光标落点变化后重判:段落/标题文本叶,光标前的文本在词边界有 `@` 起头的连续非空白段 → 开菜单。
|
|
3482
3510
|
__init6() {this.reevaluate = () => {
|
|
3483
|
-
const source = _optionalChain([this, 'access',
|
|
3511
|
+
const source = _optionalChain([this, 'access', _108 => _108.host, 'access', _109 => _109.mentionSource, 'optionalCall', _110 => _110()]);
|
|
3484
3512
|
if (!source) {
|
|
3485
3513
|
this.close();
|
|
3486
3514
|
return;
|
|
@@ -3494,12 +3522,12 @@ var MentionMenu = (_class = class {
|
|
|
3494
3522
|
const leafIdx = sel.head.path[sel.head.path.length - 2];
|
|
3495
3523
|
const caret3 = sel.head.path[sel.head.path.length - 1];
|
|
3496
3524
|
const block = nodeAt2(this.host.doc(), blockPath);
|
|
3497
|
-
if (!block ||
|
|
3525
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph" && block.type !== "heading") {
|
|
3498
3526
|
this.close();
|
|
3499
3527
|
return;
|
|
3500
3528
|
}
|
|
3501
3529
|
const leaf = block.children[leafIdx];
|
|
3502
|
-
if (!leaf || !
|
|
3530
|
+
if (!leaf || !_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
3503
3531
|
this.close();
|
|
3504
3532
|
return;
|
|
3505
3533
|
}
|
|
@@ -3554,12 +3582,12 @@ var MentionMenu = (_class = class {
|
|
|
3554
3582
|
return;
|
|
3555
3583
|
}
|
|
3556
3584
|
const block = nodeAt2(this.host.doc(), t.blockPath);
|
|
3557
|
-
if (!block ||
|
|
3585
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block)) {
|
|
3558
3586
|
this.close();
|
|
3559
3587
|
return;
|
|
3560
3588
|
}
|
|
3561
3589
|
const leaf = block.children[t.leafIdx];
|
|
3562
|
-
if (!leaf || !
|
|
3590
|
+
if (!leaf || !_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
3563
3591
|
this.close();
|
|
3564
3592
|
return;
|
|
3565
3593
|
}
|
|
@@ -3591,7 +3619,7 @@ var MentionMenu = (_class = class {
|
|
|
3591
3619
|
paint() {
|
|
3592
3620
|
const dom = document.getSelection();
|
|
3593
3621
|
const range = dom && dom.rangeCount ? dom.getRangeAt(0) : null;
|
|
3594
|
-
const rect = _optionalChain([range, 'optionalAccess',
|
|
3622
|
+
const rect = _optionalChain([range, 'optionalAccess', _111 => _111.getBoundingClientRect]) ? range.getBoundingClientRect() : { left: 0, bottom: 0 };
|
|
3595
3623
|
_preact.render.call(void 0,
|
|
3596
3624
|
_preact.h.call(void 0,
|
|
3597
3625
|
"div",
|
|
@@ -3627,7 +3655,7 @@ function samePath(a, b) {
|
|
|
3627
3655
|
function nodeAt2(doc, path) {
|
|
3628
3656
|
let cur = doc;
|
|
3629
3657
|
for (const seg of path) {
|
|
3630
|
-
if (
|
|
3658
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, cur))
|
|
3631
3659
|
return null;
|
|
3632
3660
|
const child = cur.children[seg];
|
|
3633
3661
|
if (!child)
|
|
@@ -3642,7 +3670,7 @@ function nodeAt2(doc, path) {
|
|
|
3642
3670
|
var SHOW_MS = 300;
|
|
3643
3671
|
var MENU_OPEN_MS = 300;
|
|
3644
3672
|
var MENU_CLOSE_MS = 120;
|
|
3645
|
-
var nid = () => _nullishCoalesce(_optionalChain([crypto, 'access',
|
|
3673
|
+
var nid = () => _nullishCoalesce(_optionalChain([crypto, 'access', _112 => _112.randomUUID, 'optionalCall', _113 => _113()]), () => ( `n${Math.random().toString(36).slice(2)}`));
|
|
3646
3674
|
var isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
3647
3675
|
var mod = isMac ? "\u2318" : "Ctrl";
|
|
3648
3676
|
var BLOCK_ITEMS = [
|
|
@@ -3704,15 +3732,15 @@ function blockIco(name, size2 = 18) {
|
|
|
3704
3732
|
}
|
|
3705
3733
|
function currentBlockKind(doc, sel) {
|
|
3706
3734
|
const block = doc.children[sel.head.path[0]];
|
|
3707
|
-
if (!block ||
|
|
3735
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
3708
3736
|
return "paragraph";
|
|
3709
3737
|
if (block.type === "heading")
|
|
3710
|
-
return `heading${Number(_nullishCoalesce(_optionalChain([block, 'access',
|
|
3738
|
+
return `heading${Number(_nullishCoalesce(_optionalChain([block, 'access', _114 => _114.attrs, 'optionalAccess', _115 => _115.depth]), () => ( 1)))}`;
|
|
3711
3739
|
if (block.type === "list") {
|
|
3712
3740
|
const item = block.children[0];
|
|
3713
|
-
if (item && !
|
|
3741
|
+
if (item && !_chunkGQ2HHRGIcjs.isText.call(void 0, item) && item.attrs && "checked" in item.attrs)
|
|
3714
3742
|
return "task";
|
|
3715
|
-
return _optionalChain([block, 'access',
|
|
3743
|
+
return _optionalChain([block, 'access', _116 => _116.attrs, 'optionalAccess', _117 => _117.ordered]) ? "ordered" : "bullet";
|
|
3716
3744
|
}
|
|
3717
3745
|
return block.type;
|
|
3718
3746
|
}
|
|
@@ -3931,26 +3959,26 @@ var BubbleMenu = (_class2 = class {
|
|
|
3931
3959
|
}, SHOW_MS);
|
|
3932
3960
|
}}
|
|
3933
3961
|
activeMarks(sel) {
|
|
3934
|
-
const leaf =
|
|
3935
|
-
return new Set(
|
|
3962
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), sel.head.path.slice(0, -1));
|
|
3963
|
+
return new Set(_chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? (_nullishCoalesce(leaf.marks, () => ( []))).map((m) => m.name) : []);
|
|
3936
3964
|
}
|
|
3937
3965
|
activeAlign(sel) {
|
|
3938
3966
|
const block = this.host.doc().children[sel.head.path[0]];
|
|
3939
|
-
return !block ||
|
|
3967
|
+
return !block || _chunkGQ2HHRGIcjs.isText.call(void 0, block) ? "left" : _nullishCoalesce(_optionalChain([block, 'access', _118 => _118.attrs, 'optionalAccess', _119 => _119.align]), () => ( "left"));
|
|
3940
3968
|
}
|
|
3941
3969
|
styleAttrs(sel) {
|
|
3942
|
-
const leaf =
|
|
3943
|
-
if (!
|
|
3970
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), sel.head.path.slice(0, -1));
|
|
3971
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
3944
3972
|
return null;
|
|
3945
3973
|
const m = (_nullishCoalesce(leaf.marks, () => ( []))).find((x) => x.name === "textStyle");
|
|
3946
|
-
return _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
3974
|
+
return _nullishCoalesce(_optionalChain([m, 'optionalAccess', _120 => _120.attrs]), () => ( null));
|
|
3947
3975
|
}
|
|
3948
3976
|
activeColor(sel) {
|
|
3949
|
-
const c = _optionalChain([this, 'access',
|
|
3977
|
+
const c = _optionalChain([this, 'access', _121 => _121.styleAttrs, 'call', _122 => _122(sel), 'optionalAccess', _123 => _123.color]);
|
|
3950
3978
|
return typeof c === "string" ? c : null;
|
|
3951
3979
|
}
|
|
3952
3980
|
activeBg(sel) {
|
|
3953
|
-
const c = _optionalChain([this, 'access',
|
|
3981
|
+
const c = _optionalChain([this, 'access', _124 => _124.styleAttrs, 'call', _125 => _125(sel), 'optionalAccess', _126 => _126.backgroundColor]);
|
|
3954
3982
|
return typeof c === "string" ? c : null;
|
|
3955
3983
|
}
|
|
3956
3984
|
applyBlock(kind) {
|
|
@@ -3959,7 +3987,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
3959
3987
|
return;
|
|
3960
3988
|
const idx = sel.head.path[0];
|
|
3961
3989
|
const block = this.host.doc().children[idx];
|
|
3962
|
-
if (!block ||
|
|
3990
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
3963
3991
|
return;
|
|
3964
3992
|
const r = blockTransform(block, idx, kind, nid);
|
|
3965
3993
|
this.menu = null;
|
|
@@ -4161,7 +4189,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4161
4189
|
}
|
|
4162
4190
|
const rect2 = _nullishCoalesce(_nullishCoalesce(this.lastRect, () => ( (() => {
|
|
4163
4191
|
try {
|
|
4164
|
-
return _optionalChain([document, 'access',
|
|
4192
|
+
return _optionalChain([document, 'access', _127 => _127.getSelection, 'call', _128 => _128(), 'optionalAccess', _129 => _129.getRangeAt, 'call', _130 => _130(0), 'optionalAccess', _131 => _131.getBoundingClientRect, 'call', _132 => _132()]);
|
|
4165
4193
|
} catch (e8) {
|
|
4166
4194
|
return null;
|
|
4167
4195
|
}
|
|
@@ -4292,7 +4320,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4292
4320
|
"title": "AI \u7EED\u5199",
|
|
4293
4321
|
"onMouseDown": (e) => {
|
|
4294
4322
|
e.preventDefault();
|
|
4295
|
-
_optionalChain([this, 'access',
|
|
4323
|
+
_optionalChain([this, 'access', _133 => _133.host, 'access', _134 => _134.openAi, 'optionalCall', _135 => _135("continue")]);
|
|
4296
4324
|
}
|
|
4297
4325
|
}, [icon("sparkles", 16), _preact.h.call(void 0, "span", { class: "markloom-bb-ai-lab", key: "l" }, "\u7EED\u5199"), tipNode("AI \u7EED\u5199")]) : null;
|
|
4298
4326
|
const aiRewriteBtn = this.host.openAi ? _preact.h.call(void 0, "button", {
|
|
@@ -4303,7 +4331,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4303
4331
|
"title": "AI \u6539\u5199",
|
|
4304
4332
|
"onMouseDown": (e) => {
|
|
4305
4333
|
e.preventDefault();
|
|
4306
|
-
_optionalChain([this, 'access',
|
|
4334
|
+
_optionalChain([this, 'access', _136 => _136.host, 'access', _137 => _137.openAi, 'optionalCall', _138 => _138("rewrite")]);
|
|
4307
4335
|
}
|
|
4308
4336
|
}, [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
4337
|
const commentBtn = this.host.beginComment ? _preact.h.call(void 0, "button", {
|
|
@@ -4313,7 +4341,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
4313
4341
|
"data-mark": "comment",
|
|
4314
4342
|
"onMouseDown": (e) => {
|
|
4315
4343
|
e.preventDefault();
|
|
4316
|
-
_optionalChain([this, 'access',
|
|
4344
|
+
_optionalChain([this, 'access', _139 => _139.host, 'access', _140 => _140.beginComment, 'optionalCall', _141 => _141()]);
|
|
4317
4345
|
}
|
|
4318
4346
|
}, [icon("message-circle", 16), tipNode("\u8BC4\u8BBA")]) : null;
|
|
4319
4347
|
_preact.render.call(void 0,
|
|
@@ -4373,7 +4401,7 @@ var CodeControls = (_class3 = class {
|
|
|
4373
4401
|
this.closeMenu();
|
|
4374
4402
|
}
|
|
4375
4403
|
__init25() {this.closeMenu = () => {
|
|
4376
|
-
_optionalChain([this, 'access',
|
|
4404
|
+
_optionalChain([this, 'access', _152 => _152.menu, 'optionalAccess', _153 => _153.remove, 'call', _154 => _154()]);
|
|
4377
4405
|
this.menu = null;
|
|
4378
4406
|
}}
|
|
4379
4407
|
__init26() {this.onDown = (e) => {
|
|
@@ -4383,7 +4411,7 @@ var CodeControls = (_class3 = class {
|
|
|
4383
4411
|
e.preventDefault();
|
|
4384
4412
|
e.stopPropagation();
|
|
4385
4413
|
const box = copyBtn.closest("[data-code-block]");
|
|
4386
|
-
const text = _nullishCoalesce(_optionalChain([(_nullishCoalesce(_optionalChain([box, 'optionalAccess',
|
|
4414
|
+
const text = _nullishCoalesce(_optionalChain([(_nullishCoalesce(_optionalChain([box, 'optionalAccess', _155 => _155.querySelector, 'call', _156 => _156("[data-code-hl]")]), () => ( box))), 'optionalAccess', _157 => _157.textContent]), () => ( ""));
|
|
4387
4415
|
navigator.clipboard.writeText(text.trimEnd()).then(() => {
|
|
4388
4416
|
copyBtn.dataset.copied = "";
|
|
4389
4417
|
setTimeout(() => {
|
|
@@ -4399,7 +4427,7 @@ var CodeControls = (_class3 = class {
|
|
|
4399
4427
|
}
|
|
4400
4428
|
e.preventDefault();
|
|
4401
4429
|
e.stopPropagation();
|
|
4402
|
-
const blockId = _optionalChain([langBtn, 'access',
|
|
4430
|
+
const blockId = _optionalChain([langBtn, 'access', _158 => _158.closest, 'call', _159 => _159("[data-code-block]"), 'optionalAccess', _160 => _160.dataset, 'access', _161 => _161.blockId]);
|
|
4403
4431
|
if (!blockId) {
|
|
4404
4432
|
this.closeMenu();
|
|
4405
4433
|
return;
|
|
@@ -4419,11 +4447,11 @@ var CodeControls = (_class3 = class {
|
|
|
4419
4447
|
ev.preventDefault();
|
|
4420
4448
|
ev.stopPropagation();
|
|
4421
4449
|
const doc = this.host.doc();
|
|
4422
|
-
const path =
|
|
4450
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, blockId);
|
|
4423
4451
|
if (path) {
|
|
4424
|
-
const node =
|
|
4452
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
4425
4453
|
const attrs = { ...node.attrs, lang: opt === "\u7EAF\u6587\u672C" ? void 0 : opt };
|
|
4426
|
-
this.host.dispatch([
|
|
4454
|
+
this.host.dispatch([_chunk4TMHVNL6cjs.rewriteNode.call(void 0, doc, blockId, { ...node, attrs })]);
|
|
4427
4455
|
}
|
|
4428
4456
|
this.closeMenu();
|
|
4429
4457
|
});
|
|
@@ -4467,7 +4495,7 @@ var COLORS = [
|
|
|
4467
4495
|
{ value: "#2563eb", title: "\u84DD", swatch: "#2563eb" },
|
|
4468
4496
|
{ value: "#7c3aed", title: "\u7D2B", swatch: "#7c3aed" }
|
|
4469
4497
|
];
|
|
4470
|
-
var newId = () => _nullishCoalesce(_optionalChain([crypto, 'optionalAccess',
|
|
4498
|
+
var newId = () => _nullishCoalesce(_optionalChain([crypto, 'optionalAccess', _162 => _162.randomUUID, 'optionalCall', _163 => _163()]), () => ( `b${Math.random().toString(36).slice(2)}`));
|
|
4471
4499
|
var DragHandle = (_class4 = class {
|
|
4472
4500
|
|
|
4473
4501
|
|
|
@@ -4495,7 +4523,7 @@ var DragHandle = (_class4 = class {
|
|
|
4495
4523
|
this.overlay.remove();
|
|
4496
4524
|
}
|
|
4497
4525
|
blocks() {
|
|
4498
|
-
return
|
|
4526
|
+
return _chunkYIFOGP2Dcjs.elementChildren.call(void 0, _chunkYIFOGP2Dcjs.rootEl.call(void 0, this.root));
|
|
4499
4527
|
}
|
|
4500
4528
|
clearLeave() {
|
|
4501
4529
|
if (this.leaveTimer != null) {
|
|
@@ -4592,7 +4620,7 @@ var DragHandle = (_class4 = class {
|
|
|
4592
4620
|
document.removeEventListener("mousemove", move);
|
|
4593
4621
|
document.removeEventListener("mouseup", up);
|
|
4594
4622
|
if (active2 && this.drag) {
|
|
4595
|
-
const steps =
|
|
4623
|
+
const steps = _chunk4TMHVNL6cjs.moveBlock.call(void 0, this.host.doc(), fromIdx, this.drag.gap);
|
|
4596
4624
|
if (steps.length)
|
|
4597
4625
|
this.host.dispatch(steps);
|
|
4598
4626
|
}
|
|
@@ -4606,18 +4634,18 @@ var DragHandle = (_class4 = class {
|
|
|
4606
4634
|
}
|
|
4607
4635
|
toggleFold(blockIdx) {
|
|
4608
4636
|
const node = this.host.doc().children[blockIdx];
|
|
4609
|
-
if (!node ||
|
|
4637
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "heading")
|
|
4610
4638
|
return;
|
|
4611
4639
|
this.host.dispatch([{
|
|
4612
4640
|
kind: "replaceNode",
|
|
4613
4641
|
path: [blockIdx],
|
|
4614
|
-
node: { ...node, attrs: { ...node.attrs, collapsed: !_optionalChain([node, 'access',
|
|
4642
|
+
node: { ...node, attrs: { ...node.attrs, collapsed: !_optionalChain([node, 'access', _164 => _164.attrs, 'optionalAccess', _165 => _165.collapsed]) } }
|
|
4615
4643
|
}]);
|
|
4616
4644
|
}
|
|
4617
4645
|
/** 整块文本选区(paragraph/heading 顶层叶),供手柄菜单套 mark */
|
|
4618
4646
|
blockSel(blockIdx) {
|
|
4619
4647
|
const block = this.host.doc().children[blockIdx];
|
|
4620
|
-
if (!block ||
|
|
4648
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4621
4649
|
return null;
|
|
4622
4650
|
if (block.type !== "paragraph" && block.type !== "heading" && block.type !== "code")
|
|
4623
4651
|
return null;
|
|
@@ -4626,7 +4654,7 @@ var DragHandle = (_class4 = class {
|
|
|
4626
4654
|
let lastLen = 0;
|
|
4627
4655
|
for (let i = 0; i < block.children.length; i++) {
|
|
4628
4656
|
const c = block.children[i];
|
|
4629
|
-
if (
|
|
4657
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c)) {
|
|
4630
4658
|
if (first < 0)
|
|
4631
4659
|
first = i;
|
|
4632
4660
|
last = i;
|
|
@@ -4645,7 +4673,7 @@ var DragHandle = (_class4 = class {
|
|
|
4645
4673
|
if (idx < 0)
|
|
4646
4674
|
return;
|
|
4647
4675
|
const block = this.host.doc().children[idx];
|
|
4648
|
-
if (!block ||
|
|
4676
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4649
4677
|
return;
|
|
4650
4678
|
const r = blockTransform(block, idx, kind, newId);
|
|
4651
4679
|
this.host.dispatch(r.steps, r.selection);
|
|
@@ -4684,10 +4712,10 @@ var DragHandle = (_class4 = class {
|
|
|
4684
4712
|
dropLine() {
|
|
4685
4713
|
if (!this.drag)
|
|
4686
4714
|
return null;
|
|
4687
|
-
const docEl =
|
|
4715
|
+
const docEl = _chunkYIFOGP2Dcjs.rootEl.call(void 0, this.root);
|
|
4688
4716
|
const blocks = this.blocks();
|
|
4689
4717
|
const gap = this.drag.gap;
|
|
4690
|
-
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access',
|
|
4718
|
+
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access', _166 => _166[0], 'optionalAccess', _167 => _167.getBoundingClientRect, 'call', _168 => _168(), 'access', _169 => _169.top]), () => ( 0)) : _nullishCoalesce(_optionalChain([blocks, 'access', _170 => _170[gap - 1], 'optionalAccess', _171 => _171.getBoundingClientRect, 'call', _172 => _172(), 'access', _173 => _173.bottom]), () => ( 0));
|
|
4691
4719
|
const box = docEl.getBoundingClientRect();
|
|
4692
4720
|
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
4721
|
}
|
|
@@ -4711,9 +4739,9 @@ var DragHandle = (_class4 = class {
|
|
|
4711
4739
|
}
|
|
4712
4740
|
currentKind(block) {
|
|
4713
4741
|
if (block.type === "heading")
|
|
4714
|
-
return `heading${Math.min(Number(_nullishCoalesce(_optionalChain([block, 'access',
|
|
4742
|
+
return `heading${Math.min(Number(_nullishCoalesce(_optionalChain([block, 'access', _174 => _174.attrs, 'optionalAccess', _175 => _175.depth]), () => ( 1))), 3)}`;
|
|
4715
4743
|
if (block.type === "list")
|
|
4716
|
-
return _optionalChain([block, 'access',
|
|
4744
|
+
return _optionalChain([block, 'access', _176 => _176.attrs, 'optionalAccess', _177 => _177.ordered]) ? "ordered" : "bullet";
|
|
4717
4745
|
if (block.type === "quote" || block.type === "code" || block.type === "paragraph")
|
|
4718
4746
|
return block.type;
|
|
4719
4747
|
return "";
|
|
@@ -4721,7 +4749,7 @@ var DragHandle = (_class4 = class {
|
|
|
4721
4749
|
paintMenu() {
|
|
4722
4750
|
const idx = this.hoverIdx;
|
|
4723
4751
|
const block = this.host.doc().children[idx];
|
|
4724
|
-
if (!block ||
|
|
4752
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4725
4753
|
return null;
|
|
4726
4754
|
const kind = this.currentKind(block);
|
|
4727
4755
|
const typeRow = TYPE_ITEMS.map((it) => _preact.h.call(void 0, "button", {
|
|
@@ -4977,7 +5005,7 @@ var SlashMenu = (_class5 = class {
|
|
|
4977
5005
|
}
|
|
4978
5006
|
allItems() {
|
|
4979
5007
|
const base = ITEMS.filter((it) => !("ai" in it) || !!this.host.openAiSlash);
|
|
4980
|
-
const extra = (_nullishCoalesce(_optionalChain([this, 'access',
|
|
5008
|
+
const extra = (_nullishCoalesce(_optionalChain([this, 'access', _178 => _178.host, 'access', _179 => _179.slashCommands, 'optionalCall', _180 => _180()]), () => ( []))).map((cmd) => ({
|
|
4981
5009
|
label: cmd.label,
|
|
4982
5010
|
hint: cmd.hint,
|
|
4983
5011
|
section: _nullishCoalesce(cmd.section, () => ( "AI")),
|
|
@@ -5008,11 +5036,11 @@ var SlashMenu = (_class5 = class {
|
|
|
5008
5036
|
}
|
|
5009
5037
|
const blockIdx = sel.head.path[0];
|
|
5010
5038
|
const block = this.host.doc().children[blockIdx];
|
|
5011
|
-
if (
|
|
5039
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph") {
|
|
5012
5040
|
this.close();
|
|
5013
5041
|
return;
|
|
5014
5042
|
}
|
|
5015
|
-
const head =
|
|
5043
|
+
const head = _chunkGQ2HHRGIcjs.isText.call(void 0, block.children[0]) ? block.children[0].text : "";
|
|
5016
5044
|
if (head[0] !== "/") {
|
|
5017
5045
|
this.close();
|
|
5018
5046
|
return;
|
|
@@ -5052,7 +5080,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5052
5080
|
apply(item) {
|
|
5053
5081
|
const doc = this.host.doc();
|
|
5054
5082
|
const block = doc.children[this.blockIdx];
|
|
5055
|
-
if (!item ||
|
|
5083
|
+
if (!item || _chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph") {
|
|
5056
5084
|
this.close();
|
|
5057
5085
|
return;
|
|
5058
5086
|
}
|
|
@@ -5060,7 +5088,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5060
5088
|
const query = this.query;
|
|
5061
5089
|
this.close();
|
|
5062
5090
|
if ("ai" in item) {
|
|
5063
|
-
_optionalChain([this, 'access',
|
|
5091
|
+
_optionalChain([this, 'access', _181 => _181.host, 'access', _182 => _182.openAiSlash, 'optionalCall', _183 => _183({ blockIdx, query })]);
|
|
5064
5092
|
return;
|
|
5065
5093
|
}
|
|
5066
5094
|
if ("cmd" in item) {
|
|
@@ -5078,20 +5106,20 @@ var SlashMenu = (_class5 = class {
|
|
|
5078
5106
|
return;
|
|
5079
5107
|
}
|
|
5080
5108
|
if (item.insert === "math") {
|
|
5081
|
-
_optionalChain([this, 'access',
|
|
5109
|
+
_optionalChain([this, 'access', _184 => _184.host, 'access', _185 => _185.insertMath, 'optionalCall', _186 => _186(blockIdx)]);
|
|
5082
5110
|
return;
|
|
5083
5111
|
}
|
|
5084
5112
|
if (item.insert === "youtube" || item.insert === "twitch" || item.insert === "audio" || item.insert === "file") {
|
|
5085
|
-
_optionalChain([this, 'access',
|
|
5113
|
+
_optionalChain([this, 'access', _187 => _187.host, 'access', _188 => _188.insertEmbed, 'optionalCall', _189 => _189(blockIdx, item.insert)]);
|
|
5086
5114
|
return;
|
|
5087
5115
|
}
|
|
5088
|
-
const node = item.insert === "table" ?
|
|
5116
|
+
const node = item.insert === "table" ? _chunk4TMHVNL6cjs.makeTable.call(void 0, newId2(), 3, 3) : { type: "raw", id: newId2(), attrs: { mdType: "thematicBreak" }, children: [{ text: "" }] };
|
|
5089
5117
|
this.host.dispatch([{ kind: "replaceNode", path: [blockIdx], node }]);
|
|
5090
5118
|
return;
|
|
5091
5119
|
}
|
|
5092
5120
|
const first = block.children[0];
|
|
5093
|
-
const rest =
|
|
5094
|
-
const head =
|
|
5121
|
+
const rest = _chunkGQ2HHRGIcjs.isText.call(void 0, first) ? first.text.slice(1 + this.query.length) : "";
|
|
5122
|
+
const head = _chunkGQ2HHRGIcjs.isText.call(void 0, first) ? { ...first, text: rest } : { text: rest };
|
|
5095
5123
|
const stripped = { ...block, children: [head, ...block.children.slice(1)] };
|
|
5096
5124
|
const extra = item.kind === "callout" ? { variant: calloutVariantFromQuery(this.query) } : void 0;
|
|
5097
5125
|
const r = blockTransform(stripped, blockIdx, item.kind, newId2, extra);
|
|
@@ -5112,7 +5140,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5112
5140
|
this.active = Math.min(this.active, list.length - 1);
|
|
5113
5141
|
const dom = document.getSelection();
|
|
5114
5142
|
const range = dom && dom.rangeCount ? dom.getRangeAt(0) : null;
|
|
5115
|
-
const rect = _optionalChain([range, 'optionalAccess',
|
|
5143
|
+
const rect = _optionalChain([range, 'optionalAccess', _190 => _190.getBoundingClientRect]) ? range.getBoundingClientRect() : { left: 0, bottom: 0 };
|
|
5116
5144
|
const rows = [];
|
|
5117
5145
|
let prev = null;
|
|
5118
5146
|
list.forEach((it, i) => {
|
|
@@ -5139,7 +5167,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5139
5167
|
void place(rectRef(rect), el, { placement: "bottom-start", gap: 6 });
|
|
5140
5168
|
}
|
|
5141
5169
|
}, _class5);
|
|
5142
|
-
var newId2 = () => _nullishCoalesce(_optionalChain([crypto, 'optionalAccess',
|
|
5170
|
+
var newId2 = () => _nullishCoalesce(_optionalChain([crypto, 'optionalAccess', _191 => _191.randomUUID, 'optionalCall', _192 => _192()]), () => ( `s${Math.random().toString(36).slice(2)}`));
|
|
5143
5171
|
|
|
5144
5172
|
// src/view/extensions/decorations.ts
|
|
5145
5173
|
var codeControls = { name: "codeControls", decorations: [(host) => new CodeControls(host.root, host)] };
|
|
@@ -5246,8 +5274,8 @@ var inputRules = {
|
|
|
5246
5274
|
return null;
|
|
5247
5275
|
if (!(marker === "[]" || marker === "[ ]" || marker === "[x]" || marker === "[X]"))
|
|
5248
5276
|
return null;
|
|
5249
|
-
const item =
|
|
5250
|
-
if (!item ||
|
|
5277
|
+
const item = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
5278
|
+
if (!item || _chunkGQ2HHRGIcjs.isText.call(void 0, item) || item.type !== "list_item")
|
|
5251
5279
|
return null;
|
|
5252
5280
|
const checked = marker === "[x]" || marker === "[X]";
|
|
5253
5281
|
const para = { ...block, children: [{ text: rest }, ...block.children.slice(1)] };
|
|
@@ -5326,7 +5354,7 @@ var linkMark = {
|
|
|
5326
5354
|
name: "link",
|
|
5327
5355
|
tag: "a",
|
|
5328
5356
|
props: (mark) => {
|
|
5329
|
-
if (!_optionalChain([mark, 'access',
|
|
5357
|
+
if (!_optionalChain([mark, 'access', _193 => _193.attrs, 'optionalAccess', _194 => _194.url]))
|
|
5330
5358
|
return { "data-mark": "link", class: "markloom-link" };
|
|
5331
5359
|
const url = String(mark.attrs.url);
|
|
5332
5360
|
return {
|
|
@@ -5461,10 +5489,10 @@ var CommentPanel = (_class6 = class {
|
|
|
5461
5489
|
}
|
|
5462
5490
|
commitThreads(next) {
|
|
5463
5491
|
this.threads = next;
|
|
5464
|
-
_optionalChain([this, 'access',
|
|
5492
|
+
_optionalChain([this, 'access', _198 => _198.host, 'access', _199 => _199.onChange, 'optionalCall', _200 => _200(this.threads)]);
|
|
5465
5493
|
}
|
|
5466
5494
|
__init45() {this.onRootClick = (e) => {
|
|
5467
|
-
const el = _optionalChain([e, 'access',
|
|
5495
|
+
const el = _optionalChain([e, 'access', _201 => _201.target, 'optionalAccess', _202 => _202.closest, 'optionalCall', _203 => _203("[data-comment-id]")]);
|
|
5468
5496
|
if (!el || !this.host.root.contains(el))
|
|
5469
5497
|
return;
|
|
5470
5498
|
const id = el.getAttribute("data-comment-id");
|
|
@@ -5490,7 +5518,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5490
5518
|
if (this.mode.kind !== "compose")
|
|
5491
5519
|
return;
|
|
5492
5520
|
const ta = this.overlay.querySelector('[data-comment-ui="compose"] textarea');
|
|
5493
|
-
const body = (_nullishCoalesce(_optionalChain([ta, 'optionalAccess',
|
|
5521
|
+
const body = (_nullishCoalesce(_optionalChain([ta, 'optionalAccess', _204 => _204.value]), () => ( this.mode.body))).trim();
|
|
5494
5522
|
if (!body)
|
|
5495
5523
|
return;
|
|
5496
5524
|
const id = this.host.newId();
|
|
@@ -5516,7 +5544,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5516
5544
|
if (this.mode.kind !== "view")
|
|
5517
5545
|
return;
|
|
5518
5546
|
const ta = this.overlay.querySelector(`[data-thread="${cssEscape(this.mode.id)}"] .markloom-comment-reply textarea`);
|
|
5519
|
-
const body = (_nullishCoalesce(_optionalChain([ta, 'optionalAccess',
|
|
5547
|
+
const body = (_nullishCoalesce(_optionalChain([ta, 'optionalAccess', _205 => _205.value]), () => ( this.mode.reply))).trim();
|
|
5520
5548
|
if (!body)
|
|
5521
5549
|
return;
|
|
5522
5550
|
const id = this.mode.id;
|
|
@@ -5540,7 +5568,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5540
5568
|
this.paint();
|
|
5541
5569
|
}
|
|
5542
5570
|
deleteThread(id) {
|
|
5543
|
-
const steps =
|
|
5571
|
+
const steps = _chunkYXQDCW4Ycjs.stripCommentMarks.call(void 0, this.host.doc(), id);
|
|
5544
5572
|
this.commitThreads(this.threads.filter((t) => t.id !== id));
|
|
5545
5573
|
this.activeId = null;
|
|
5546
5574
|
this.mode = this.threads.length ? { kind: "list" } : { kind: "closed" };
|
|
@@ -5558,7 +5586,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5558
5586
|
/** 卡片 top(相对 rail-body)。正文与栏共滚 → viewport 差即内容坐标。 */
|
|
5559
5587
|
cardTops(ids, composeTop) {
|
|
5560
5588
|
const body = this.overlay.querySelector(".markloom-comment-rail-body");
|
|
5561
|
-
const bodyTop = _nullishCoalesce(_optionalChain([body, 'optionalAccess',
|
|
5589
|
+
const bodyTop = _nullishCoalesce(_optionalChain([body, 'optionalAccess', _206 => _206.getBoundingClientRect, 'call', _207 => _207(), 'access', _208 => _208.top]), () => ( 0));
|
|
5562
5590
|
const raw = ids.map((id) => {
|
|
5563
5591
|
const el = this.host.root.querySelector(`[data-comment-id="${cssEscape(id)}"]`);
|
|
5564
5592
|
const y = el ? el.getBoundingClientRect().top - bodyTop : 0;
|
|
@@ -5597,7 +5625,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5597
5625
|
if (rail) {
|
|
5598
5626
|
const sp = this.scrollRoot;
|
|
5599
5627
|
const hd = rail.querySelector(".markloom-comment-rail-hd");
|
|
5600
|
-
const hdH = _nullishCoalesce(_optionalChain([hd, 'optionalAccess',
|
|
5628
|
+
const hdH = _nullishCoalesce(_optionalChain([hd, 'optionalAccess', _209 => _209.offsetHeight]), () => ( 52));
|
|
5601
5629
|
const need = Math.max(sp.scrollHeight, sp.clientHeight, maxBottom + hdH + RAIL_PAD);
|
|
5602
5630
|
rail.style.minHeight = `${need}px`;
|
|
5603
5631
|
}
|
|
@@ -5717,7 +5745,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5717
5745
|
this.reflowAfterPaint();
|
|
5718
5746
|
if (composing) {
|
|
5719
5747
|
const ta = this.overlay.querySelector('[data-comment-ui="compose"] textarea');
|
|
5720
|
-
_optionalChain([ta, 'optionalAccess',
|
|
5748
|
+
_optionalChain([ta, 'optionalAccess', _210 => _210.focus, 'call', _211 => _211()]);
|
|
5721
5749
|
}
|
|
5722
5750
|
});
|
|
5723
5751
|
}
|
|
@@ -5832,7 +5860,7 @@ function markQuote(root, id) {
|
|
|
5832
5860
|
}
|
|
5833
5861
|
function markTop(root, id) {
|
|
5834
5862
|
const el = root.querySelector(`[data-comment-id="${cssEscape(id)}"]`);
|
|
5835
|
-
return _nullishCoalesce(_optionalChain([el, 'optionalAccess',
|
|
5863
|
+
return _nullishCoalesce(_optionalChain([el, 'optionalAccess', _212 => _212.getBoundingClientRect, 'call', _213 => _213(), 'access', _214 => _214.top]), () => ( 1e9));
|
|
5836
5864
|
}
|
|
5837
5865
|
function fmtTime(ts) {
|
|
5838
5866
|
const d = new Date(ts);
|
|
@@ -5898,7 +5926,7 @@ var TocPanel = (_class7 = class {
|
|
|
5898
5926
|
}
|
|
5899
5927
|
__init52() {this.onRedraw = () => this.refresh()}
|
|
5900
5928
|
refresh() {
|
|
5901
|
-
this.entries =
|
|
5929
|
+
this.entries = _chunkYXQDCW4Ycjs.outline.call(void 0, this.host.doc()).filter((e) => e.text.trim());
|
|
5902
5930
|
this.syncActive();
|
|
5903
5931
|
this.paint();
|
|
5904
5932
|
}
|
|
@@ -6075,7 +6103,7 @@ var MentionPopovers = (_class8 = class {
|
|
|
6075
6103
|
const t = e.target;
|
|
6076
6104
|
if (this.overlay.contains(t))
|
|
6077
6105
|
return;
|
|
6078
|
-
if (_optionalChain([t, 'access',
|
|
6106
|
+
if (_optionalChain([t, 'access', _217 => _217.closest, 'optionalCall', _218 => _218('[data-atom="mention"]')]))
|
|
6079
6107
|
return;
|
|
6080
6108
|
this.close();
|
|
6081
6109
|
}}
|
|
@@ -6154,7 +6182,7 @@ var MentionPopovers = (_class8 = class {
|
|
|
6154
6182
|
this.paint();
|
|
6155
6183
|
};
|
|
6156
6184
|
const apply = () => {
|
|
6157
|
-
_optionalChain([this, 'access',
|
|
6185
|
+
_optionalChain([this, 'access', _219 => _219.host, 'access', _220 => _220.onDateChange, 'optionalCall', _221 => _221(mode.path, toIso(draft))]);
|
|
6158
6186
|
this.close();
|
|
6159
6187
|
};
|
|
6160
6188
|
const spin = (key, max2, label) => _preact.h.call(void 0, "label", { class: "markloom-time-field", key }, [
|
|
@@ -6317,6 +6345,201 @@ function isToday(y, m, day) {
|
|
|
6317
6345
|
// src/view/editor.ts
|
|
6318
6346
|
|
|
6319
6347
|
|
|
6348
|
+
// src/view/collab-presence.ts
|
|
6349
|
+
function wireOf(sel) {
|
|
6350
|
+
const split2 = (p) => {
|
|
6351
|
+
const path = p.path;
|
|
6352
|
+
if (path.length < 1)
|
|
6353
|
+
return { path: [], offset: 0 };
|
|
6354
|
+
return { path: path.slice(0, -1), offset: path[path.length - 1] };
|
|
6355
|
+
};
|
|
6356
|
+
return { anchor: split2(sel.anchor), head: split2(sel.head) };
|
|
6357
|
+
}
|
|
6358
|
+
function posOf(w) {
|
|
6359
|
+
return { path: w.path.concat(w.offset) };
|
|
6360
|
+
}
|
|
6361
|
+
var CollabPresence = (_class9 = class {
|
|
6362
|
+
|
|
6363
|
+
|
|
6364
|
+
|
|
6365
|
+
|
|
6366
|
+
__init58() {this.peers = []}
|
|
6367
|
+
__init59() {this.self = null}
|
|
6368
|
+
__init60() {this.presenceTimer = null}
|
|
6369
|
+
__init61() {this.lastWire = ""}
|
|
6370
|
+
__init62() {this.onSel = () => this.schedulePresence()}
|
|
6371
|
+
__init63() {this.onScroll = () => this.paintCarets()}
|
|
6372
|
+
__init64() {this.onResize = () => this.paintCarets()}
|
|
6373
|
+
__init65() {this.destroyed = false}
|
|
6374
|
+
constructor(host) {;_class9.prototype.__init58.call(this);_class9.prototype.__init59.call(this);_class9.prototype.__init60.call(this);_class9.prototype.__init61.call(this);_class9.prototype.__init62.call(this);_class9.prototype.__init63.call(this);_class9.prototype.__init64.call(this);_class9.prototype.__init65.call(this);
|
|
6375
|
+
this.host = host;
|
|
6376
|
+
const root = host.root;
|
|
6377
|
+
if (getComputedStyle(root).position === "static")
|
|
6378
|
+
root.style.position = "relative";
|
|
6379
|
+
this.rail = document.createElement("div");
|
|
6380
|
+
this.rail.className = "markloom-collab-rail";
|
|
6381
|
+
this.rail.setAttribute("contenteditable", "false");
|
|
6382
|
+
this.avatars = document.createElement("div");
|
|
6383
|
+
this.avatars.className = "markloom-collab-avatars";
|
|
6384
|
+
this.rail.appendChild(this.avatars);
|
|
6385
|
+
this.carets = document.createElement("div");
|
|
6386
|
+
this.carets.className = "markloom-collab-carets";
|
|
6387
|
+
this.carets.setAttribute("contenteditable", "false");
|
|
6388
|
+
root.appendChild(this.rail);
|
|
6389
|
+
root.appendChild(this.carets);
|
|
6390
|
+
document.addEventListener("selectionchange", this.onSel);
|
|
6391
|
+
window.addEventListener("scroll", this.onScroll, true);
|
|
6392
|
+
window.addEventListener("resize", this.onResize);
|
|
6393
|
+
}
|
|
6394
|
+
/** welcome 后设本人;peers 更新时刷新 */
|
|
6395
|
+
setSelf(siteId, name, color) {
|
|
6396
|
+
this.self = { siteId, name, color: _chunkALZ3A5CScjs.collabColor.call(void 0, siteId, color) };
|
|
6397
|
+
this.paintAvatars();
|
|
6398
|
+
}
|
|
6399
|
+
setPeers(peers) {
|
|
6400
|
+
this.peers = peers.map((p) => ({
|
|
6401
|
+
...p,
|
|
6402
|
+
color: _chunkALZ3A5CScjs.collabColor.call(void 0, p.siteId, p.color)
|
|
6403
|
+
}));
|
|
6404
|
+
this.paintAvatars();
|
|
6405
|
+
this.paintCarets();
|
|
6406
|
+
}
|
|
6407
|
+
/** model 重绘后光标 DOM 位可能变 */
|
|
6408
|
+
onRedraw() {
|
|
6409
|
+
this.paintCarets();
|
|
6410
|
+
}
|
|
6411
|
+
destroy() {
|
|
6412
|
+
this.destroyed = true;
|
|
6413
|
+
document.removeEventListener("selectionchange", this.onSel);
|
|
6414
|
+
window.removeEventListener("scroll", this.onScroll, true);
|
|
6415
|
+
window.removeEventListener("resize", this.onResize);
|
|
6416
|
+
if (this.presenceTimer)
|
|
6417
|
+
clearTimeout(this.presenceTimer);
|
|
6418
|
+
this.rail.remove();
|
|
6419
|
+
this.carets.remove();
|
|
6420
|
+
}
|
|
6421
|
+
schedulePresence() {
|
|
6422
|
+
if (this.presenceTimer)
|
|
6423
|
+
clearTimeout(this.presenceTimer);
|
|
6424
|
+
this.presenceTimer = setTimeout(() => {
|
|
6425
|
+
this.presenceTimer = null;
|
|
6426
|
+
this.sendPresence();
|
|
6427
|
+
}, 80);
|
|
6428
|
+
}
|
|
6429
|
+
sendPresence() {
|
|
6430
|
+
const c = this.host.collab();
|
|
6431
|
+
if (!c || this.destroyed)
|
|
6432
|
+
return;
|
|
6433
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.host.root, this.host.doc());
|
|
6434
|
+
if (!sel) {
|
|
6435
|
+
c.presence(null);
|
|
6436
|
+
return;
|
|
6437
|
+
}
|
|
6438
|
+
const w = wireOf(sel);
|
|
6439
|
+
const key = JSON.stringify(w);
|
|
6440
|
+
if (key === this.lastWire)
|
|
6441
|
+
return;
|
|
6442
|
+
this.lastWire = key;
|
|
6443
|
+
c.presence(w);
|
|
6444
|
+
}
|
|
6445
|
+
paintAvatars() {
|
|
6446
|
+
const list = [];
|
|
6447
|
+
if (this.self) {
|
|
6448
|
+
list.push({
|
|
6449
|
+
siteId: this.self.siteId,
|
|
6450
|
+
name: this.self.name,
|
|
6451
|
+
color: this.self.color
|
|
6452
|
+
});
|
|
6453
|
+
}
|
|
6454
|
+
for (const p of this.peers) {
|
|
6455
|
+
if (this.self && p.siteId === this.self.siteId)
|
|
6456
|
+
continue;
|
|
6457
|
+
list.push(p);
|
|
6458
|
+
}
|
|
6459
|
+
list.sort((a, b) => {
|
|
6460
|
+
if (this.self) {
|
|
6461
|
+
if (a.siteId === this.self.siteId)
|
|
6462
|
+
return 1;
|
|
6463
|
+
if (b.siteId === this.self.siteId)
|
|
6464
|
+
return -1;
|
|
6465
|
+
}
|
|
6466
|
+
return a.siteId - b.siteId;
|
|
6467
|
+
});
|
|
6468
|
+
this.avatars.replaceChildren();
|
|
6469
|
+
if (list.length === 0) {
|
|
6470
|
+
this.rail.hidden = true;
|
|
6471
|
+
return;
|
|
6472
|
+
}
|
|
6473
|
+
this.rail.hidden = false;
|
|
6474
|
+
for (const p of list) {
|
|
6475
|
+
const el = document.createElement("div");
|
|
6476
|
+
el.className = "markloom-collab-avatar";
|
|
6477
|
+
if (this.self && p.siteId === this.self.siteId)
|
|
6478
|
+
el.classList.add("is-self");
|
|
6479
|
+
el.style.setProperty("--collab-c", p.color || _chunkALZ3A5CScjs.collabColor.call(void 0, p.siteId));
|
|
6480
|
+
el.textContent = _chunkALZ3A5CScjs.collabInitial.call(void 0, p.name, p.siteId);
|
|
6481
|
+
el.title = p.name || `\u7528\u6237 ${p.siteId}`;
|
|
6482
|
+
this.avatars.appendChild(el);
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
paintCarets() {
|
|
6486
|
+
this.carets.replaceChildren();
|
|
6487
|
+
const root = this.host.root;
|
|
6488
|
+
const doc = this.host.doc();
|
|
6489
|
+
const rootRect = root.getBoundingClientRect();
|
|
6490
|
+
const scrollX = root.scrollLeft;
|
|
6491
|
+
const scrollY = root.scrollTop;
|
|
6492
|
+
for (const p of this.peers) {
|
|
6493
|
+
if (this.self && p.siteId === this.self.siteId)
|
|
6494
|
+
continue;
|
|
6495
|
+
if (!_optionalChain([p, 'access', _222 => _222.sel, 'optionalAccess', _223 => _223.head]))
|
|
6496
|
+
continue;
|
|
6497
|
+
const pos = posOf(p.sel.head);
|
|
6498
|
+
const dom = _chunkYIFOGP2Dcjs.pointToDom.call(void 0, root, doc, pos);
|
|
6499
|
+
if (!dom)
|
|
6500
|
+
continue;
|
|
6501
|
+
const range = document.createRange();
|
|
6502
|
+
try {
|
|
6503
|
+
const n = dom.node;
|
|
6504
|
+
const max2 = n.nodeType === 3 ? _nullishCoalesce(_optionalChain([n, 'access', _224 => _224.textContent, 'optionalAccess', _225 => _225.length]), () => ( 0)) : 0;
|
|
6505
|
+
const off = Math.max(0, Math.min(dom.offset, max2));
|
|
6506
|
+
range.setStart(n, off);
|
|
6507
|
+
range.setEnd(n, off);
|
|
6508
|
+
} catch (e9) {
|
|
6509
|
+
continue;
|
|
6510
|
+
}
|
|
6511
|
+
const rects = range.getClientRects();
|
|
6512
|
+
const rect = _nullishCoalesce(rects[0], () => ( range.getBoundingClientRect()));
|
|
6513
|
+
if (!rect || rect.width === 0 && rect.height === 0 && rect.top === 0) {
|
|
6514
|
+
const leaf = dom.node.parentElement;
|
|
6515
|
+
if (!leaf)
|
|
6516
|
+
continue;
|
|
6517
|
+
const r = leaf.getBoundingClientRect();
|
|
6518
|
+
this.addCaret(p, r, rootRect, scrollX, scrollY);
|
|
6519
|
+
continue;
|
|
6520
|
+
}
|
|
6521
|
+
this.addCaret(p, rect, rootRect, scrollX, scrollY);
|
|
6522
|
+
}
|
|
6523
|
+
}
|
|
6524
|
+
addCaret(p, rect, rootRect, scrollX, scrollY) {
|
|
6525
|
+
const color = p.color || _chunkALZ3A5CScjs.collabColor.call(void 0, p.siteId);
|
|
6526
|
+
const el = document.createElement("div");
|
|
6527
|
+
el.className = "markloom-collab-caret";
|
|
6528
|
+
el.style.setProperty("--collab-c", color);
|
|
6529
|
+
const left = rect.left - rootRect.left + scrollX;
|
|
6530
|
+
const top = rect.top - rootRect.top + scrollY;
|
|
6531
|
+
const h13 = Math.max(rect.height || 16, 14);
|
|
6532
|
+
el.style.left = `${left}px`;
|
|
6533
|
+
el.style.top = `${top}px`;
|
|
6534
|
+
el.style.height = `${h13}px`;
|
|
6535
|
+
const lab = document.createElement("div");
|
|
6536
|
+
lab.className = "markloom-collab-caret-lab";
|
|
6537
|
+
lab.textContent = p.name || `\u7528\u6237${p.siteId}`;
|
|
6538
|
+
el.appendChild(lab);
|
|
6539
|
+
this.carets.appendChild(el);
|
|
6540
|
+
}
|
|
6541
|
+
}, _class9);
|
|
6542
|
+
|
|
6320
6543
|
// src/view/image-controls.ts
|
|
6321
6544
|
|
|
6322
6545
|
var DRAG_THRESHOLD = 4;
|
|
@@ -6336,24 +6559,24 @@ function atomIdsInSelection(doc, sel) {
|
|
|
6336
6559
|
const out = /* @__PURE__ */ new Set();
|
|
6337
6560
|
for (let i = lo; i <= hi; i++) {
|
|
6338
6561
|
const n = doc.children[i];
|
|
6339
|
-
if (!n ||
|
|
6562
|
+
if (!n || _chunkGQ2HHRGIcjs.isText.call(void 0, n))
|
|
6340
6563
|
continue;
|
|
6341
6564
|
if ((n.type === "image" || n.type === "embed") && n.id)
|
|
6342
6565
|
out.add(n.id);
|
|
6343
6566
|
}
|
|
6344
6567
|
return out;
|
|
6345
6568
|
}
|
|
6346
|
-
var ImageControls = (
|
|
6569
|
+
var ImageControls = (_class10 = class {
|
|
6347
6570
|
|
|
6348
6571
|
|
|
6349
6572
|
|
|
6350
6573
|
/** 点选 exclusive 块 id(全套柄);与 range 互斥 */
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
constructor(root, host) {;
|
|
6574
|
+
__init66() {this.exclusiveId = null}
|
|
6575
|
+
__init67() {this.rangeIds = /* @__PURE__ */ new Set()}
|
|
6576
|
+
__init68() {this.lightbox = null}
|
|
6577
|
+
__init69() {this.editingCaption = false}
|
|
6578
|
+
__init70() {this.ctxKey = ""}
|
|
6579
|
+
constructor(root, host) {;_class10.prototype.__init66.call(this);_class10.prototype.__init67.call(this);_class10.prototype.__init68.call(this);_class10.prototype.__init69.call(this);_class10.prototype.__init70.call(this);_class10.prototype.__init71.call(this);_class10.prototype.__init72.call(this);_class10.prototype.__init73.call(this);_class10.prototype.__init74.call(this);
|
|
6357
6580
|
this.root = root;
|
|
6358
6581
|
this.host = host;
|
|
6359
6582
|
this.overlay = document.createElement("div");
|
|
@@ -6394,7 +6617,7 @@ var ImageControls = (_class9 = class {
|
|
|
6394
6617
|
this.host.onAtomSelectChange();
|
|
6395
6618
|
this.paint();
|
|
6396
6619
|
}
|
|
6397
|
-
|
|
6620
|
+
__init71() {this.onSelChange = () => {
|
|
6398
6621
|
if (this.lightbox)
|
|
6399
6622
|
return;
|
|
6400
6623
|
const sel = this.host.sel();
|
|
@@ -6405,14 +6628,14 @@ var ImageControls = (_class9 = class {
|
|
|
6405
6628
|
this.rangeIds = nextRange;
|
|
6406
6629
|
this.publishCtx();
|
|
6407
6630
|
}}
|
|
6408
|
-
|
|
6631
|
+
__init72() {this.onDocDown = (e) => {
|
|
6409
6632
|
const el = e.target instanceof HTMLElement ? e.target : null;
|
|
6410
|
-
if (_optionalChain([el, 'optionalAccess',
|
|
6633
|
+
if (_optionalChain([el, 'optionalAccess', _234 => _234.closest, 'call', _235 => _235(".markloom-image-overlay")]) || _optionalChain([el, 'optionalAccess', _236 => _236.closest, 'call', _237 => _237(".markloom-lightbox")]))
|
|
6411
6634
|
return;
|
|
6412
|
-
const atom = _optionalChain([el, 'optionalAccess',
|
|
6635
|
+
const atom = _optionalChain([el, 'optionalAccess', _238 => _238.closest, 'call', _239 => _239('[data-atom="image"], [data-atom="embed"]')]);
|
|
6413
6636
|
if (atom && this.root.contains(atom)) {
|
|
6414
6637
|
const host = atom.dataset.blockId ? atom : atom.closest("[data-block-id]");
|
|
6415
|
-
const id = _nullishCoalesce(_nullishCoalesce(_optionalChain([host, 'optionalAccess',
|
|
6638
|
+
const id = _nullishCoalesce(_nullishCoalesce(_optionalChain([host, 'optionalAccess', _240 => _240.dataset, 'access', _241 => _241.blockId]), () => ( atom.dataset.blockId)), () => ( null));
|
|
6416
6639
|
if (id && id === this.exclusiveId) {
|
|
6417
6640
|
if ((_nullishCoalesce(host, () => ( atom))).getAttribute("data-atom") === "image" || atom.closest('[data-atom="image"]'))
|
|
6418
6641
|
this.lightbox = imgSrc(_nullishCoalesce(host, () => ( atom)));
|
|
@@ -6426,11 +6649,11 @@ var ImageControls = (_class9 = class {
|
|
|
6426
6649
|
if (this.exclusiveId || this.lightbox || this.rangeIds.size)
|
|
6427
6650
|
this.clearSelected();
|
|
6428
6651
|
}}
|
|
6429
|
-
|
|
6652
|
+
__init73() {this.onKeyDown = (e) => {
|
|
6430
6653
|
if (e.key === "Escape" && (this.lightbox || this.exclusiveId))
|
|
6431
6654
|
this.clearSelected();
|
|
6432
6655
|
}}
|
|
6433
|
-
|
|
6656
|
+
__init74() {this.onReflow = () => {
|
|
6434
6657
|
if (this.exclusiveId || this.rangeIds.size || this.lightbox)
|
|
6435
6658
|
this.paint();
|
|
6436
6659
|
}}
|
|
@@ -6438,7 +6661,7 @@ var ImageControls = (_class9 = class {
|
|
|
6438
6661
|
return !!this.exclusiveId && !!this.atomEl(this.exclusiveId);
|
|
6439
6662
|
}
|
|
6440
6663
|
selectedBlockPath() {
|
|
6441
|
-
return this.exclusiveId ?
|
|
6664
|
+
return this.exclusiveId ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), this.exclusiveId) : null;
|
|
6442
6665
|
}
|
|
6443
6666
|
selectByBlockId(id) {
|
|
6444
6667
|
const atom = this.atomEl(id);
|
|
@@ -6474,10 +6697,10 @@ var ImageControls = (_class9 = class {
|
|
|
6474
6697
|
blockNode() {
|
|
6475
6698
|
if (!this.exclusiveId)
|
|
6476
6699
|
return null;
|
|
6477
|
-
const path =
|
|
6700
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), this.exclusiveId);
|
|
6478
6701
|
if (!path)
|
|
6479
6702
|
return null;
|
|
6480
|
-
const node =
|
|
6703
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6481
6704
|
return node.type === "image" || node.type === "embed" ? { path, node } : null;
|
|
6482
6705
|
}
|
|
6483
6706
|
patchAttrs(patch) {
|
|
@@ -6535,8 +6758,8 @@ var ImageControls = (_class9 = class {
|
|
|
6535
6758
|
_preact.render.call(void 0, kids.length ? _preact.h.call(void 0, "div", { class: "markloom-ic" }, kids) : null, this.overlay);
|
|
6536
6759
|
}
|
|
6537
6760
|
toolbar(r) {
|
|
6538
|
-
const cur = _nullishCoalesce(_optionalChain([this, 'access',
|
|
6539
|
-
const cap = String(_nullishCoalesce(_optionalChain([this, 'access',
|
|
6761
|
+
const cur = _nullishCoalesce(_optionalChain([this, 'access', _242 => _242.blockNode, 'call', _243 => _243(), 'optionalAccess', _244 => _244.node, 'access', _245 => _245.attrs, 'optionalAccess', _246 => _246.align]), () => ( "left"));
|
|
6762
|
+
const cap = String(_nullishCoalesce(_optionalChain([this, 'access', _247 => _247.blockNode, 'call', _248 => _248(), 'optionalAccess', _249 => _249.node, 'access', _250 => _250.attrs, 'optionalAccess', _251 => _251.caption]), () => ( "")));
|
|
6540
6763
|
const aligns = [
|
|
6541
6764
|
{ value: "left", ico: "align-left", title: "\u5DE6\u5BF9\u9F50" },
|
|
6542
6765
|
{ value: "center", ico: "align-center", title: "\u5C45\u4E2D" },
|
|
@@ -6582,7 +6805,7 @@ var ImageControls = (_class9 = class {
|
|
|
6582
6805
|
down.preventDefault();
|
|
6583
6806
|
down.stopPropagation();
|
|
6584
6807
|
const el = this.exclusiveId ? this.atomEl(this.exclusiveId) : null;
|
|
6585
|
-
const img = _optionalChain([el, 'optionalAccess',
|
|
6808
|
+
const img = _optionalChain([el, 'optionalAccess', _252 => _252.matches, 'call', _253 => _253("img")]) ? el : _optionalChain([el, 'optionalAccess', _254 => _254.querySelector, 'call', _255 => _255("img")]);
|
|
6586
6809
|
if (!img)
|
|
6587
6810
|
return;
|
|
6588
6811
|
const r = img.getBoundingClientRect();
|
|
@@ -6622,10 +6845,10 @@ var ImageControls = (_class9 = class {
|
|
|
6622
6845
|
this.exclusiveId = null;
|
|
6623
6846
|
this.publishCtx();
|
|
6624
6847
|
}
|
|
6625
|
-
},
|
|
6848
|
+
}, _class10);
|
|
6626
6849
|
function imgSrc(atom) {
|
|
6627
6850
|
const img = atom.matches("img") ? atom : atom.querySelector("img");
|
|
6628
|
-
return _nullishCoalesce(_optionalChain([img, 'optionalAccess',
|
|
6851
|
+
return _nullishCoalesce(_optionalChain([img, 'optionalAccess', _256 => _256.getAttribute, 'call', _257 => _257("src")]), () => ( null));
|
|
6629
6852
|
}
|
|
6630
6853
|
function cssEscape3(s) {
|
|
6631
6854
|
if (typeof CSS !== "undefined" && typeof CSS.escape === "function")
|
|
@@ -6642,23 +6865,23 @@ var DRAG_THRESHOLD2 = 4;
|
|
|
6642
6865
|
function normRect(r1, c1, r2, c2) {
|
|
6643
6866
|
return { r1: Math.min(r1, r2), c1: Math.min(c1, c2), r2: Math.max(r1, r2), c2: Math.max(c1, c2) };
|
|
6644
6867
|
}
|
|
6645
|
-
var TableControls = (
|
|
6868
|
+
var TableControls = (_class11 = class {
|
|
6646
6869
|
|
|
6647
6870
|
|
|
6648
6871
|
|
|
6649
|
-
|
|
6872
|
+
__init75() {this.active = null}
|
|
6650
6873
|
// 当前显示控制柄的表格
|
|
6651
|
-
|
|
6874
|
+
__init76() {this.selectedBlock = null}
|
|
6652
6875
|
// 整表被选中(两段删第一段);与 active/sel 正交
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6876
|
+
__init77() {this.sel = null}
|
|
6877
|
+
__init78() {this.drag = null}
|
|
6878
|
+
__init79() {this.resize = null}
|
|
6879
|
+
__init80() {this.menu = null}
|
|
6880
|
+
__init81() {this.rectDrag = false}
|
|
6658
6881
|
// 正在拖拽画矩形选区(guard 焦点变动别收起控制柄)
|
|
6659
|
-
|
|
6882
|
+
__init82() {this.blockDrag = null}
|
|
6660
6883
|
// 整表选中态拖拽移动:落点缝下标(0..n)
|
|
6661
|
-
constructor(root, host) {;
|
|
6884
|
+
constructor(root, host) {;_class11.prototype.__init75.call(this);_class11.prototype.__init76.call(this);_class11.prototype.__init77.call(this);_class11.prototype.__init78.call(this);_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);
|
|
6662
6885
|
this.root = root;
|
|
6663
6886
|
this.host = host;
|
|
6664
6887
|
this.overlay = document.createElement("div");
|
|
@@ -6686,8 +6909,8 @@ var TableControls = (_class10 = class {
|
|
|
6686
6909
|
}
|
|
6687
6910
|
// 选中表的 model 块路径(供 atomBlockGuard 拿定位)。无选中 / 无 id → null。
|
|
6688
6911
|
selectedBlockPath() {
|
|
6689
|
-
const id = _optionalChain([this, 'access',
|
|
6690
|
-
return id ?
|
|
6912
|
+
const id = _optionalChain([this, 'access', _262 => _262.selectedBlock, 'optionalAccess', _263 => _263.getAttribute, 'call', _264 => _264("data-block-id")]);
|
|
6913
|
+
return id ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), id) : null;
|
|
6691
6914
|
}
|
|
6692
6915
|
// 按 model 块 id 选中对应表格(供 atomSelectGuard:光标逼近表 → 先选中而非直删)。选中成功返 true。
|
|
6693
6916
|
selectByBlockId(id) {
|
|
@@ -6715,7 +6938,7 @@ var TableControls = (_class10 = class {
|
|
|
6715
6938
|
this.paint();
|
|
6716
6939
|
}
|
|
6717
6940
|
clearSelected() {
|
|
6718
|
-
_optionalChain([this, 'access',
|
|
6941
|
+
_optionalChain([this, 'access', _265 => _265.selectedBlock, 'optionalAccess', _266 => _266.removeAttribute, 'call', _267 => _267("data-block-selected")]);
|
|
6719
6942
|
this.selectedBlock = null;
|
|
6720
6943
|
this.paint();
|
|
6721
6944
|
}
|
|
@@ -6727,10 +6950,10 @@ var TableControls = (_class10 = class {
|
|
|
6727
6950
|
const path = this.tablePath(tableEl);
|
|
6728
6951
|
if (!path)
|
|
6729
6952
|
return null;
|
|
6730
|
-
const table =
|
|
6731
|
-
if (
|
|
6953
|
+
const table = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6954
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, table) || table.type !== "table")
|
|
6732
6955
|
return null;
|
|
6733
|
-
const grid =
|
|
6956
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, table);
|
|
6734
6957
|
const { rows, cols } = grid;
|
|
6735
6958
|
const cells = Array.from(tableEl.querySelectorAll(".markloom-cell"));
|
|
6736
6959
|
if (cells.length !== grid.anchors.length || cols === 0)
|
|
@@ -6770,18 +6993,18 @@ var TableControls = (_class10 = class {
|
|
|
6770
6993
|
}
|
|
6771
6994
|
tablePath(tableEl) {
|
|
6772
6995
|
const id = tableEl.getAttribute("data-block-id");
|
|
6773
|
-
return id ?
|
|
6996
|
+
return id ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), id) : null;
|
|
6774
6997
|
}
|
|
6775
6998
|
tableModel(tableEl) {
|
|
6776
6999
|
const path = this.tablePath(tableEl);
|
|
6777
7000
|
if (!path)
|
|
6778
7001
|
return null;
|
|
6779
|
-
const t =
|
|
6780
|
-
return !
|
|
7002
|
+
const t = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
7003
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, t) && t.type === "table" ? t : null;
|
|
6781
7004
|
}
|
|
6782
7005
|
// 焦点驱动:caret 落在某表格的 cell 内 → 该表控制柄常驻显示;焦点移出表格 → 收起。
|
|
6783
7006
|
// 不随鼠标 hover 进出闪现(飞书式:聚焦即常驻)。选中/菜单/拖拽进行中不因选区变动收起(柄操作会短暂夺焦)。
|
|
6784
|
-
|
|
7007
|
+
__init83() {this.onSelChange = () => {
|
|
6785
7008
|
if (this.selectedBlock)
|
|
6786
7009
|
return;
|
|
6787
7010
|
if (this.sel || this.menu || this.drag || this.resize || this.rectDrag)
|
|
@@ -6800,18 +7023,18 @@ var TableControls = (_class10 = class {
|
|
|
6800
7023
|
// 当前 caret/选区落在哪个表格内(锚点 DOM 往上找 .markloom-table,且在本编辑器根内)。
|
|
6801
7024
|
focusedTable() {
|
|
6802
7025
|
const sel = document.getSelection();
|
|
6803
|
-
const node = _optionalChain([sel, 'optionalAccess',
|
|
7026
|
+
const node = _optionalChain([sel, 'optionalAccess', _268 => _268.anchorNode]);
|
|
6804
7027
|
if (!node)
|
|
6805
7028
|
return null;
|
|
6806
7029
|
const el = node instanceof HTMLElement ? node : node.parentElement;
|
|
6807
|
-
const table = _optionalChain([el, 'optionalAccess',
|
|
7030
|
+
const table = _optionalChain([el, 'optionalAccess', _269 => _269.closest, 'call', _270 => _270(".markloom-table")]);
|
|
6808
7031
|
return table && this.root.contains(table) ? table : null;
|
|
6809
7032
|
}
|
|
6810
|
-
|
|
7033
|
+
__init84() {this.onReflow = () => {
|
|
6811
7034
|
if (this.active || this.selectedBlock)
|
|
6812
7035
|
this.paint();
|
|
6813
7036
|
}}
|
|
6814
|
-
|
|
7037
|
+
__init85() {this.onKeyDown = (e) => {
|
|
6815
7038
|
if (e.key === "Escape" && this.selectedBlock)
|
|
6816
7039
|
this.clearSelected();
|
|
6817
7040
|
if ((e.key === "Backspace" || e.key === "Delete") && this.sel && this.active) {
|
|
@@ -6820,7 +7043,7 @@ var TableControls = (_class10 = class {
|
|
|
6820
7043
|
const path = this.tablePath(this.active);
|
|
6821
7044
|
if (rect && t && path) {
|
|
6822
7045
|
e.preventDefault();
|
|
6823
|
-
this.host.dispatch([
|
|
7046
|
+
this.host.dispatch([_chunk4TMHVNL6cjs.clearCells.call(void 0, t, path, rect)]);
|
|
6824
7047
|
this.sel = null;
|
|
6825
7048
|
this.menu = null;
|
|
6826
7049
|
this.applySelClasses();
|
|
@@ -6836,7 +7059,7 @@ var TableControls = (_class10 = class {
|
|
|
6836
7059
|
const t = this.tableModel(this.active);
|
|
6837
7060
|
if (!t)
|
|
6838
7061
|
return null;
|
|
6839
|
-
const { rows, cols } =
|
|
7062
|
+
const { rows, cols } = _chunk4TMHVNL6cjs.buildGrid.call(void 0, t);
|
|
6840
7063
|
if (sel.kind === "all")
|
|
6841
7064
|
return { r1: 0, c1: 0, r2: rows - 1, c2: cols - 1 };
|
|
6842
7065
|
if (sel.kind === "row")
|
|
@@ -6849,13 +7072,13 @@ var TableControls = (_class10 = class {
|
|
|
6849
7072
|
}
|
|
6850
7073
|
// 点在控制柄/菜单之外:清选中 + 关菜单。capture 阶段抢在编辑器聚焦前判定。
|
|
6851
7074
|
// 点在 active 表格某格内 + 拖动 → 画矩形选区(拖过 >1 格时抑制默认光标选择,松手出合并菜单)。
|
|
6852
|
-
|
|
7075
|
+
__init86() {this.onDocDown = (e) => {
|
|
6853
7076
|
const el = e.target instanceof HTMLElement ? e.target : null;
|
|
6854
|
-
if (_optionalChain([el, 'optionalAccess',
|
|
7077
|
+
if (_optionalChain([el, 'optionalAccess', _271 => _271.closest, 'call', _272 => _272(".markloom-table-overlay")]))
|
|
6855
7078
|
return;
|
|
6856
7079
|
if (this.selectedBlock)
|
|
6857
7080
|
this.clearSelected();
|
|
6858
|
-
const cellEl = _optionalChain([el, 'optionalAccess',
|
|
7081
|
+
const cellEl = _optionalChain([el, 'optionalAccess', _273 => _273.closest, 'call', _274 => _274(".markloom-cell")]);
|
|
6859
7082
|
const inActive = cellEl && this.active && this.active.contains(cellEl);
|
|
6860
7083
|
if (inActive) {
|
|
6861
7084
|
if (this.sel && this.sel.kind !== "rect") {
|
|
@@ -6903,7 +7126,7 @@ var TableControls = (_class10 = class {
|
|
|
6903
7126
|
const up = () => {
|
|
6904
7127
|
document.removeEventListener("pointermove", move);
|
|
6905
7128
|
document.removeEventListener("pointerup", up);
|
|
6906
|
-
if (active2 && _optionalChain([this, 'access',
|
|
7129
|
+
if (active2 && _optionalChain([this, 'access', _275 => _275.sel, 'optionalAccess', _276 => _276.kind]) === "rect") {
|
|
6907
7130
|
const rr = normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2);
|
|
6908
7131
|
if (rr.r1 !== rr.r2 || rr.c1 !== rr.c2)
|
|
6909
7132
|
this.menu = { kind: "rect" };
|
|
@@ -6911,7 +7134,7 @@ var TableControls = (_class10 = class {
|
|
|
6911
7134
|
this.sel = null;
|
|
6912
7135
|
this.applySelClasses();
|
|
6913
7136
|
this.paint();
|
|
6914
|
-
} else if (!active2 && _optionalChain([this, 'access',
|
|
7137
|
+
} else if (!active2 && _optionalChain([this, 'access', _277 => _277.sel, 'optionalAccess', _278 => _278.kind]) === "rect") {
|
|
6915
7138
|
this.sel = null;
|
|
6916
7139
|
this.menu = null;
|
|
6917
7140
|
this.applySelClasses();
|
|
@@ -6944,7 +7167,7 @@ var TableControls = (_class10 = class {
|
|
|
6944
7167
|
// 整表选中态拖拽移动:按下抓柄超阈值 → 进块拖拽,实时算落点缝(gapAtY)+ 画落点线;松手 dispatch moveBlock。
|
|
6945
7168
|
// 未超阈值(纯点击)→ 保持选中(selectWhole 已在抓柄 onPointerDown 里做过)。
|
|
6946
7169
|
beginBlockDrag(tableEl, down) {
|
|
6947
|
-
const fromIdx = _optionalChain([this, 'access',
|
|
7170
|
+
const fromIdx = _optionalChain([this, 'access', _279 => _279.tablePath, 'call', _280 => _280(tableEl), 'optionalAccess', _281 => _281[0]]);
|
|
6948
7171
|
if (fromIdx == null)
|
|
6949
7172
|
return;
|
|
6950
7173
|
const startX = down.clientX;
|
|
@@ -6963,7 +7186,7 @@ var TableControls = (_class10 = class {
|
|
|
6963
7186
|
document.removeEventListener("pointermove", move);
|
|
6964
7187
|
document.removeEventListener("pointerup", up);
|
|
6965
7188
|
if (active2 && this.blockDrag) {
|
|
6966
|
-
const steps =
|
|
7189
|
+
const steps = _chunk4TMHVNL6cjs.moveBlock.call(void 0, this.host.doc(), fromIdx, this.blockDrag.gap);
|
|
6967
7190
|
if (steps.length) {
|
|
6968
7191
|
this.clearSelected();
|
|
6969
7192
|
this.host.dispatch(steps);
|
|
@@ -6977,7 +7200,7 @@ var TableControls = (_class10 = class {
|
|
|
6977
7200
|
}
|
|
6978
7201
|
// 鼠标 y → 顶层块间缝下标(0..n)。遍历 .markloom-doc 结构子(elementChildren 穿透布局层),y 落某块上半 → 该块前缝,下半 → 后缝。
|
|
6979
7202
|
gapAtY(y) {
|
|
6980
|
-
const blocks =
|
|
7203
|
+
const blocks = _chunkYIFOGP2Dcjs.elementChildren.call(void 0, _chunkYIFOGP2Dcjs.rootEl.call(void 0, this.root));
|
|
6981
7204
|
for (let i = 0; i < blocks.length; i++) {
|
|
6982
7205
|
const r = blocks[i].getBoundingClientRect();
|
|
6983
7206
|
if (y < (r.top + r.bottom) / 2)
|
|
@@ -6989,10 +7212,10 @@ var TableControls = (_class10 = class {
|
|
|
6989
7212
|
blockDropLine() {
|
|
6990
7213
|
if (!this.blockDrag)
|
|
6991
7214
|
return null;
|
|
6992
|
-
const docEl =
|
|
6993
|
-
const blocks =
|
|
7215
|
+
const docEl = _chunkYIFOGP2Dcjs.rootEl.call(void 0, this.root);
|
|
7216
|
+
const blocks = _chunkYIFOGP2Dcjs.elementChildren.call(void 0, docEl);
|
|
6994
7217
|
const gap = this.blockDrag.gap;
|
|
6995
|
-
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access',
|
|
7218
|
+
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access', _282 => _282[0], 'optionalAccess', _283 => _283.getBoundingClientRect, 'call', _284 => _284(), 'access', _285 => _285.top]), () => ( 0)) : _nullishCoalesce(_optionalChain([blocks, 'access', _286 => _286[gap - 1], 'optionalAccess', _287 => _287.getBoundingClientRect, 'call', _288 => _288(), 'access', _289 => _289.bottom]), () => ( 0));
|
|
6996
7219
|
const box = docEl.getBoundingClientRect();
|
|
6997
7220
|
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
7221
|
}
|
|
@@ -7005,13 +7228,13 @@ var TableControls = (_class10 = class {
|
|
|
7005
7228
|
const table = this.tableModel(this.active);
|
|
7006
7229
|
if (!table)
|
|
7007
7230
|
return;
|
|
7008
|
-
const grid =
|
|
7231
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, table);
|
|
7009
7232
|
if (cells.length !== grid.anchors.length)
|
|
7010
7233
|
return;
|
|
7011
|
-
const rect = _optionalChain([this, 'access',
|
|
7234
|
+
const rect = _optionalChain([this, 'access', _290 => _290.sel, 'optionalAccess', _291 => _291.kind]) === "rect" ? normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2) : null;
|
|
7012
7235
|
cells.forEach((el, i) => {
|
|
7013
7236
|
const m = grid.cellOf(grid.anchors[i]);
|
|
7014
|
-
const on = _optionalChain([this, 'access',
|
|
7237
|
+
const on = _optionalChain([this, 'access', _292 => _292.sel, 'optionalAccess', _293 => _293.kind]) === "all" || _optionalChain([this, 'access', _294 => _294.sel, 'optionalAccess', _295 => _295.kind]) === "row" && m.r <= this.sel.index && this.sel.index < m.r + m.rowspan || _optionalChain([this, 'access', _296 => _296.sel, 'optionalAccess', _297 => _297.kind]) === "col" && m.c <= this.sel.index && this.sel.index < m.c + m.colspan || rect && m.r <= rect.r2 && m.r + m.rowspan - 1 >= rect.r1 && m.c <= rect.c2 && m.c + m.colspan - 1 >= rect.c1;
|
|
7015
7238
|
el.toggleAttribute("data-selected", !!on);
|
|
7016
7239
|
});
|
|
7017
7240
|
}
|
|
@@ -7071,7 +7294,7 @@ var TableControls = (_class10 = class {
|
|
|
7071
7294
|
for (let c = 0; c < g.cols; c++) {
|
|
7072
7295
|
const left = g.colX[c];
|
|
7073
7296
|
const w = g.colX[c + 1] - g.colX[c];
|
|
7074
|
-
const selected = _optionalChain([this, 'access',
|
|
7297
|
+
const selected = _optionalChain([this, 'access', _298 => _298.sel, 'optionalAccess', _299 => _299.kind]) === "col" && this.sel.index === c;
|
|
7075
7298
|
const edge = c === 0 ? " is-first" : c === g.cols - 1 ? " is-last" : "";
|
|
7076
7299
|
out.push(_preact.h.call(void 0, "div", {
|
|
7077
7300
|
key: `ch${c}`,
|
|
@@ -7087,7 +7310,7 @@ var TableControls = (_class10 = class {
|
|
|
7087
7310
|
for (let r = 0; r < g.rows; r++) {
|
|
7088
7311
|
const top = g.rowY[r];
|
|
7089
7312
|
const ht = g.rowY[r + 1] - g.rowY[r];
|
|
7090
|
-
const selected = _optionalChain([this, 'access',
|
|
7313
|
+
const selected = _optionalChain([this, 'access', _300 => _300.sel, 'optionalAccess', _301 => _301.kind]) === "row" && this.sel.index === r;
|
|
7091
7314
|
const edge = r === 0 ? " is-first" : r === g.rows - 1 ? " is-last" : "";
|
|
7092
7315
|
out.push(_preact.h.call(void 0, "div", {
|
|
7093
7316
|
key: `rh${r}`,
|
|
@@ -7098,7 +7321,7 @@ var TableControls = (_class10 = class {
|
|
|
7098
7321
|
}
|
|
7099
7322
|
out.push(_preact.h.call(void 0, "div", {
|
|
7100
7323
|
key: "all",
|
|
7101
|
-
class: `markloom-tc-handle markloom-tc-all${_optionalChain([this, 'access',
|
|
7324
|
+
class: `markloom-tc-handle markloom-tc-all${_optionalChain([this, 'access', _302 => _302.sel, 'optionalAccess', _303 => _303.kind]) === "all" ? " is-selected" : ""}`,
|
|
7102
7325
|
style: `top:${g.rect.top - BAR}px;left:${g.rect.left - BAR}px;width:${BAR}px;height:${BAR}px`,
|
|
7103
7326
|
onPointerDown: (e) => this.selectAll(e)
|
|
7104
7327
|
}));
|
|
@@ -7107,7 +7330,7 @@ var TableControls = (_class10 = class {
|
|
|
7107
7330
|
selectAll(e) {
|
|
7108
7331
|
e.preventDefault();
|
|
7109
7332
|
e.stopPropagation();
|
|
7110
|
-
if (_optionalChain([this, 'access',
|
|
7333
|
+
if (_optionalChain([this, 'access', _304 => _304.sel, 'optionalAccess', _305 => _305.kind]) === "all")
|
|
7111
7334
|
this.menu = { kind: "all", index: 0 };
|
|
7112
7335
|
else
|
|
7113
7336
|
this.sel = { kind: "all" };
|
|
@@ -7158,7 +7381,7 @@ var TableControls = (_class10 = class {
|
|
|
7158
7381
|
insertAt(e, tableEl, kind, at) {
|
|
7159
7382
|
e.preventDefault();
|
|
7160
7383
|
e.stopPropagation();
|
|
7161
|
-
this.op(tableEl, (t, p) => kind === "col" ?
|
|
7384
|
+
this.op(tableEl, (t, p) => kind === "col" ? _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, at) : _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, at));
|
|
7162
7385
|
}
|
|
7163
7386
|
// 列右边界的拖拽改宽手柄。table-layout:fixed + colgroup 下每列宽都显式(无 1fr 余量),
|
|
7164
7387
|
// 故最后一列也给柄——拖它即改表总宽(同飞书),与中间列同一套 startResize。
|
|
@@ -7189,7 +7412,7 @@ var TableControls = (_class10 = class {
|
|
|
7189
7412
|
const m = this.menu;
|
|
7190
7413
|
if (!m)
|
|
7191
7414
|
return null;
|
|
7192
|
-
const rect = _optionalChain([this, 'access',
|
|
7415
|
+
const rect = _optionalChain([this, 'access', _306 => _306.sel, 'optionalAccess', _307 => _307.kind]) === "rect" ? normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2) : null;
|
|
7193
7416
|
const x = m.kind === "col" ? g.colX[m.index] : m.kind === "rect" ? g.colX[rect ? rect.c1 : 0] : g.rect.left - BAR;
|
|
7194
7417
|
const y = m.kind === "col" ? g.rect.top - BAR : m.kind === "rect" ? g.rowY[rect ? rect.r2 + 1 : 0] : g.rowY[m.index];
|
|
7195
7418
|
const labels = this.menuLabels(m);
|
|
@@ -7216,45 +7439,45 @@ var TableControls = (_class10 = class {
|
|
|
7216
7439
|
runMenu(g, m, i) {
|
|
7217
7440
|
if (m.kind === "col") {
|
|
7218
7441
|
if (i === 0)
|
|
7219
|
-
this.op(g.tableEl, (t, p) =>
|
|
7442
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, m.index));
|
|
7220
7443
|
else if (i === 1)
|
|
7221
|
-
this.op(g.tableEl, (t, p) =>
|
|
7444
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, m.index + 1));
|
|
7222
7445
|
else if (i === 2)
|
|
7223
|
-
this.op(g.tableEl, (t, p) =>
|
|
7446
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.deleteCol.call(void 0, t, p, m.index, this.host.doc()));
|
|
7224
7447
|
else {
|
|
7225
7448
|
const a = i === 3 ? "left" : i === 4 ? "center" : "right";
|
|
7226
|
-
this.op(g.tableEl, (t, p) =>
|
|
7449
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setAlign.call(void 0, t, p, m.index, a));
|
|
7227
7450
|
}
|
|
7228
7451
|
} else if (m.kind === "row") {
|
|
7229
7452
|
if (i === 0)
|
|
7230
|
-
this.op(g.tableEl, (t, p) =>
|
|
7453
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, m.index));
|
|
7231
7454
|
else if (i === 1)
|
|
7232
|
-
this.op(g.tableEl, (t, p) =>
|
|
7233
|
-
else this.op(g.tableEl, (t, p) =>
|
|
7455
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, m.index + 1));
|
|
7456
|
+
else this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.deleteRow.call(void 0, t, p, m.index, this.host.doc()));
|
|
7234
7457
|
} else if (m.kind === "rect") {
|
|
7235
7458
|
this.runRectMenu(g, i);
|
|
7236
7459
|
} else {
|
|
7237
7460
|
if (i === 0)
|
|
7238
|
-
this.op(g.tableEl, (_t, p) =>
|
|
7461
|
+
this.op(g.tableEl, (_t, p) => _chunk4TMHVNL6cjs.deleteTableBlock.call(void 0, p, this.host.doc()));
|
|
7239
7462
|
else if (i === 1)
|
|
7240
|
-
this.op(g.tableEl, (t, p) =>
|
|
7463
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { rows: 1 }));
|
|
7241
7464
|
else if (i === 2)
|
|
7242
|
-
this.op(g.tableEl, (t, p) =>
|
|
7465
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { rows: 0 }));
|
|
7243
7466
|
else if (i === 3)
|
|
7244
|
-
this.op(g.tableEl, (t, p) =>
|
|
7245
|
-
else this.op(g.tableEl, (t, p) =>
|
|
7467
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { cols: 1 }));
|
|
7468
|
+
else this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { cols: 0 }));
|
|
7246
7469
|
}
|
|
7247
7470
|
this.menu = null;
|
|
7248
7471
|
}
|
|
7249
7472
|
// 矩形菜单:合并 / 拆分左上格 / 设背景·边框 / 清除。背景色·边框色用 prompt 取值(装饰,非命脉,不做取色器)。
|
|
7250
7473
|
runRectMenu(g, i) {
|
|
7251
|
-
if (_optionalChain([this, 'access',
|
|
7474
|
+
if (_optionalChain([this, 'access', _308 => _308.sel, 'optionalAccess', _309 => _309.kind]) !== "rect")
|
|
7252
7475
|
return;
|
|
7253
7476
|
const rr = normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2);
|
|
7254
7477
|
if (i === 0)
|
|
7255
|
-
this.op(g.tableEl, (t, p) =>
|
|
7478
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.mergeCells.call(void 0, t, p, rr.r1, rr.c1, rr.r2, rr.c2));
|
|
7256
7479
|
else if (i === 1)
|
|
7257
|
-
this.op(g.tableEl, (t, p) =>
|
|
7480
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.splitCell.call(void 0, t, p, rr.r1, rr.c1));
|
|
7258
7481
|
else if (i === 2) {
|
|
7259
7482
|
void askInput({
|
|
7260
7483
|
title: "\u5355\u5143\u683C\u80CC\u666F\u8272",
|
|
@@ -7263,10 +7486,10 @@ var TableControls = (_class10 = class {
|
|
|
7263
7486
|
confirmLabel: "\u5E94\u7528"
|
|
7264
7487
|
}).then((bg) => {
|
|
7265
7488
|
if (bg)
|
|
7266
|
-
this.op(g.tableEl, (t, p) =>
|
|
7489
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { bg }));
|
|
7267
7490
|
});
|
|
7268
7491
|
} else if (i === 3) {
|
|
7269
|
-
this.op(g.tableEl, (t, p) =>
|
|
7492
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { bg: null }));
|
|
7270
7493
|
} else if (i === 4) {
|
|
7271
7494
|
void askInput({
|
|
7272
7495
|
title: "\u5355\u5143\u683C\u8FB9\u6846\u8272",
|
|
@@ -7275,10 +7498,10 @@ var TableControls = (_class10 = class {
|
|
|
7275
7498
|
confirmLabel: "\u5E94\u7528"
|
|
7276
7499
|
}).then((border) => {
|
|
7277
7500
|
if (border)
|
|
7278
|
-
this.op(g.tableEl, (t, p) =>
|
|
7501
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { border }));
|
|
7279
7502
|
});
|
|
7280
7503
|
} else {
|
|
7281
|
-
this.op(g.tableEl, (t, p) =>
|
|
7504
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { border: null }));
|
|
7282
7505
|
}
|
|
7283
7506
|
}
|
|
7284
7507
|
// 按下行/列柄:暂不动,装 document 监听。位移超阈值 → 进拖拽重排;否则松手当点击(选中 + 双击式开菜单)。
|
|
@@ -7311,11 +7534,11 @@ var TableControls = (_class10 = class {
|
|
|
7311
7534
|
const { from, to } = this.drag;
|
|
7312
7535
|
const dest = to > from ? to - 1 : to;
|
|
7313
7536
|
if (dest !== from && !(kind === "row" && from === 0))
|
|
7314
|
-
this.op(this.active, (t, p) => kind === "col" ?
|
|
7537
|
+
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
7538
|
this.drag = null;
|
|
7316
7539
|
this.paint();
|
|
7317
7540
|
} else {
|
|
7318
|
-
if (_optionalChain([this, 'access',
|
|
7541
|
+
if (_optionalChain([this, 'access', _310 => _310.sel, 'optionalAccess', _311 => _311.kind]) === kind && this.sel.index === index)
|
|
7319
7542
|
this.menu = { kind, index };
|
|
7320
7543
|
else
|
|
7321
7544
|
this.sel = { kind, index };
|
|
@@ -7344,7 +7567,7 @@ var TableControls = (_class10 = class {
|
|
|
7344
7567
|
const startW = g.colX[col + 1] - g.colX[col];
|
|
7345
7568
|
this.resize = { col, startX: e.clientX, startW };
|
|
7346
7569
|
const tableEl = g.tableEl;
|
|
7347
|
-
const widths = (_nullishCoalesce(
|
|
7570
|
+
const widths = (_nullishCoalesce(_chunk4TMHVNL6cjs.tableColWidths.call(void 0, this.tableModel(tableEl)), () => ( this.measuredWidths(g)))).slice();
|
|
7348
7571
|
const colEls = Array.from(tableEl.querySelectorAll(":scope > colgroup > col"));
|
|
7349
7572
|
const move = (ev) => {
|
|
7350
7573
|
const next = Math.max(40, startW + (ev.clientX - this.resize.startX));
|
|
@@ -7358,7 +7581,7 @@ var TableControls = (_class10 = class {
|
|
|
7358
7581
|
document.removeEventListener("pointermove", move);
|
|
7359
7582
|
document.removeEventListener("pointerup", up);
|
|
7360
7583
|
this.resize = null;
|
|
7361
|
-
this.op(tableEl, (t, p) =>
|
|
7584
|
+
this.op(tableEl, (t, p) => _chunk4TMHVNL6cjs.setColWidths.call(void 0, t, p, widths));
|
|
7362
7585
|
};
|
|
7363
7586
|
document.addEventListener("pointermove", move);
|
|
7364
7587
|
document.addEventListener("pointerup", up);
|
|
@@ -7370,37 +7593,41 @@ var TableControls = (_class10 = class {
|
|
|
7370
7593
|
out.push(g.colX[c + 1] - g.colX[c]);
|
|
7371
7594
|
return out;
|
|
7372
7595
|
}
|
|
7373
|
-
},
|
|
7596
|
+
}, _class11);
|
|
7374
7597
|
|
|
7375
7598
|
// src/view/editor.ts
|
|
7376
|
-
var Editor = (
|
|
7599
|
+
var Editor = (_class12 = class {
|
|
7377
7600
|
|
|
7378
7601
|
|
|
7379
|
-
|
|
7380
|
-
|
|
7602
|
+
__init87() {this.composing = false}
|
|
7603
|
+
__init88() {this.composeBase = null}
|
|
7381
7604
|
// pending marks(对齐 PM storedMarks):塌缩光标 Cmd+B 等切换后,下一次 insertText 带这套 marks。
|
|
7382
7605
|
// null = 继承所在叶;Mark[] = 强制(可空=明确无 mark)。移光标/点选清空;连续打字保持。
|
|
7383
|
-
|
|
7606
|
+
__init89() {this.pendingMarks = null}
|
|
7384
7607
|
|
|
7385
7608
|
|
|
7386
7609
|
// 显隐符开关(纯投影,不进 model)。setInvisibleCharacters 运行时切。
|
|
7387
|
-
|
|
7610
|
+
__init90() {this.invisible = false}
|
|
7388
7611
|
// atom 选中态属内核(方向键选中/atomBlockGuard 直接引用),故 typed 字段;纯浮层走 decorations 循环。
|
|
7389
7612
|
|
|
7390
7613
|
|
|
7391
7614
|
// 评论:与 renderState 紧耦合(active/resolved class),typed 字段;装 comments extension 或传 comments option 即开。
|
|
7392
|
-
|
|
7615
|
+
__init91() {this.commentPanel = null}
|
|
7393
7616
|
// 左侧目录(飞书式 H1–H6 索引)
|
|
7394
|
-
|
|
7617
|
+
__init92() {this.tocPanel = null}
|
|
7395
7618
|
// mention 点击浮层:person 名片 / date 选择器
|
|
7396
7619
|
|
|
7397
7620
|
|
|
7398
7621
|
/** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
|
|
7399
|
-
|
|
7400
|
-
|
|
7622
|
+
__init93() {this.aiCtl = null}
|
|
7623
|
+
/** 协作会话;applyingRemote 期间本地 steps 不上行 */
|
|
7624
|
+
__init94() {this.collabCtl = null}
|
|
7625
|
+
__init95() {this.collabUi = null}
|
|
7626
|
+
__init96() {this.applyingRemote = false}
|
|
7627
|
+
constructor(root, doc, opts = {}) {;_class12.prototype.__init87.call(this);_class12.prototype.__init88.call(this);_class12.prototype.__init89.call(this);_class12.prototype.__init90.call(this);_class12.prototype.__init91.call(this);_class12.prototype.__init92.call(this);_class12.prototype.__init93.call(this);_class12.prototype.__init94.call(this);_class12.prototype.__init95.call(this);_class12.prototype.__init96.call(this);_class12.prototype.__init97.call(this);_class12.prototype.__init98.call(this);_class12.prototype.__init99.call(this);_class12.prototype.__init100.call(this);_class12.prototype.__init101.call(this);_class12.prototype.__init102.call(this);_class12.prototype.__init103.call(this);_class12.prototype.__init104.call(this);_class12.prototype.__init105.call(this);_class12.prototype.__init106.call(this);_class12.prototype.__init107.call(this);_class12.prototype.__init108.call(this);_class12.prototype.__init109.call(this);_class12.prototype.__init110.call(this);_class12.prototype.__init111.call(this);_class12.prototype.__init112.call(this);
|
|
7401
7628
|
this.root = root;
|
|
7402
|
-
const dev = typeof process !== "undefined" && _optionalChain([process, 'access',
|
|
7403
|
-
this.history =
|
|
7629
|
+
const dev = typeof process !== "undefined" && _optionalChain([process, 'access', _377 => _377.env, 'optionalAccess', _378 => _378.NODE_ENV]) !== "production";
|
|
7630
|
+
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
7631
|
this.opts = opts;
|
|
7405
7632
|
const exts = _nullishCoalesce(opts.extensions, () => ( markloomKit()));
|
|
7406
7633
|
this.resolved = resolve(exts);
|
|
@@ -7422,13 +7649,13 @@ var Editor = (_class11 = class {
|
|
|
7422
7649
|
this.imageControls = new ImageControls(root, {
|
|
7423
7650
|
doc: () => this.history.doc,
|
|
7424
7651
|
dispatch: (steps) => this.dispatch(steps),
|
|
7425
|
-
sel: () =>
|
|
7652
|
+
sel: () => _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc),
|
|
7426
7653
|
// atomSelect 变 → 重投影 data-selected(与 commentState 同构传 render)
|
|
7427
|
-
onAtomSelectChange: () => this.draw(_nullishCoalesce(
|
|
7654
|
+
onAtomSelectChange: () => this.draw(_nullishCoalesce(_chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0)))
|
|
7428
7655
|
});
|
|
7429
7656
|
this.mentionPops = new MentionPopovers({
|
|
7430
7657
|
root,
|
|
7431
|
-
profile: (id) => _optionalChain([this, 'access',
|
|
7658
|
+
profile: (id) => _optionalChain([this, 'access', _379 => _379.opts, 'access', _380 => _380.mentionProfile, 'optionalCall', _381 => _381(id)]),
|
|
7432
7659
|
onDateChange: (path, iso) => this.setMentionDate(path, iso)
|
|
7433
7660
|
});
|
|
7434
7661
|
const commentsOn = opts.comments !== void 0 || exts.some((e) => e.name === "comments");
|
|
@@ -7438,12 +7665,12 @@ var Editor = (_class11 = class {
|
|
|
7438
7665
|
doc: () => this.history.doc,
|
|
7439
7666
|
dispatch: (steps, sel) => this.dispatch(steps, sel),
|
|
7440
7667
|
markSel: () => this.markSel(),
|
|
7441
|
-
author: _nullishCoalesce(_optionalChain([opts, 'access',
|
|
7668
|
+
author: _nullishCoalesce(_optionalChain([opts, 'access', _382 => _382.comments, 'optionalAccess', _383 => _383.author]), () => ( (() => ({ id: "me", name: "\u6211" })))),
|
|
7442
7669
|
newId: newId3,
|
|
7443
|
-
redraw: () => this.draw(_nullishCoalesce(
|
|
7444
|
-
onChange: _optionalChain([opts, 'access',
|
|
7670
|
+
redraw: () => this.draw(_nullishCoalesce(_chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0))),
|
|
7671
|
+
onChange: _optionalChain([opts, 'access', _384 => _384.comments, 'optionalAccess', _385 => _385.onChange]),
|
|
7445
7672
|
readonly: () => this.readonly
|
|
7446
|
-
}, _nullishCoalesce(_optionalChain([opts, 'access',
|
|
7673
|
+
}, _nullishCoalesce(_optionalChain([opts, 'access', _386 => _386.comments, 'optionalAccess', _387 => _387.threads]), () => ( [])));
|
|
7447
7674
|
}
|
|
7448
7675
|
if (opts.toc) {
|
|
7449
7676
|
this.tocPanel = new TocPanel({ root, doc: () => this.history.doc });
|
|
@@ -7452,8 +7679,8 @@ var Editor = (_class11 = class {
|
|
|
7452
7679
|
}
|
|
7453
7680
|
if (opts.ai) {
|
|
7454
7681
|
const cfg = typeof opts.ai === "object" ? opts.ai : {};
|
|
7455
|
-
this.aiCtl = new (0,
|
|
7456
|
-
stream:
|
|
7682
|
+
this.aiCtl = new (0, _chunkYIFOGP2Dcjs.MarkloomAi)(() => this, {
|
|
7683
|
+
stream: _chunkYIFOGP2Dcjs.createAiStream.call(void 0, cfg),
|
|
7457
7684
|
onError: _nullishCoalesce(cfg.onError, () => ( ((msg) => {
|
|
7458
7685
|
if (typeof window !== "undefined")
|
|
7459
7686
|
window.alert(msg);
|
|
@@ -7461,17 +7688,37 @@ var Editor = (_class11 = class {
|
|
|
7461
7688
|
onBusy: cfg.onBusy
|
|
7462
7689
|
});
|
|
7463
7690
|
}
|
|
7691
|
+
if (opts.collab) {
|
|
7692
|
+
this.collabUi = new CollabPresence({
|
|
7693
|
+
root,
|
|
7694
|
+
doc: () => this.history.doc,
|
|
7695
|
+
collab: () => this.collabCtl
|
|
7696
|
+
});
|
|
7697
|
+
this.collabCtl = _chunkALZ3A5CScjs.connectCollab.call(void 0,
|
|
7698
|
+
{ ...opts.collab, seed: _nullishCoalesce(opts.collab.seed, () => ( doc)) },
|
|
7699
|
+
{
|
|
7700
|
+
onDoc: (d) => this.replaceDoc(d),
|
|
7701
|
+
onRemote: (steps) => this.applyRemote(steps),
|
|
7702
|
+
onWelcome: (info) => _optionalChain([this, 'access', _388 => _388.collabUi, 'optionalAccess', _389 => _389.setSelf, 'call', _390 => _390(info.siteId, info.name, info.color)]),
|
|
7703
|
+
onPeers: (peers) => _optionalChain([this, 'access', _391 => _391.collabUi, 'optionalAccess', _392 => _392.setPeers, 'call', _393 => _393(peers)]),
|
|
7704
|
+
onError: (msg) => {
|
|
7705
|
+
if (typeof console !== "undefined")
|
|
7706
|
+
console.warn("[markloom collab]", msg);
|
|
7707
|
+
}
|
|
7708
|
+
}
|
|
7709
|
+
);
|
|
7710
|
+
}
|
|
7464
7711
|
const host = {
|
|
7465
7712
|
root,
|
|
7466
7713
|
doc: () => this.history.doc,
|
|
7467
7714
|
dispatch: (steps, sel) => this.dispatch(steps, sel),
|
|
7468
|
-
sel: () =>
|
|
7715
|
+
sel: () => _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc),
|
|
7469
7716
|
markSel: () => this.markSel(),
|
|
7470
7717
|
insertImage: (idx) => this.slashInsertImage(idx),
|
|
7471
7718
|
insertMath: (idx) => this.slashInsertMath(idx),
|
|
7472
7719
|
insertEmbed: (idx, kind) => this.slashInsertEmbed(idx, kind),
|
|
7473
7720
|
insertBelow: (idx) => this.insertBelow(idx),
|
|
7474
|
-
langs: () => _nullishCoalesce(_optionalChain([this, 'access',
|
|
7721
|
+
langs: () => _nullishCoalesce(_optionalChain([this, 'access', _394 => _394.opts, 'access', _395 => _395.nodeViews, 'optionalAccess', _396 => _396.code, 'optionalAccess', _397 => _397.langs, 'optionalCall', _398 => _398()]), () => ( [])),
|
|
7475
7722
|
mentionSource: () => this.opts.mentionSource,
|
|
7476
7723
|
// 气泡/Cmd+K:host 注入同步取 URL;未注入时气泡与下方 onKeyDown 走 askInput。
|
|
7477
7724
|
promptLink: this.opts.promptLink ? () => this.opts.promptLink() : void 0,
|
|
@@ -7489,7 +7736,7 @@ var Editor = (_class11 = class {
|
|
|
7489
7736
|
if (!this.aiCtl)
|
|
7490
7737
|
return void 0;
|
|
7491
7738
|
return (mode) => {
|
|
7492
|
-
_optionalChain([this, 'access',
|
|
7739
|
+
_optionalChain([this, 'access', _399 => _399.aiCtl, 'optionalAccess', _400 => _400.openAtFocus, 'call', _401 => _401(mode)]);
|
|
7493
7740
|
};
|
|
7494
7741
|
}
|
|
7495
7742
|
});
|
|
@@ -7500,7 +7747,7 @@ var Editor = (_class11 = class {
|
|
|
7500
7747
|
if (!this.aiCtl)
|
|
7501
7748
|
return void 0;
|
|
7502
7749
|
return (ctx) => {
|
|
7503
|
-
_optionalChain([this, 'access',
|
|
7750
|
+
_optionalChain([this, 'access', _402 => _402.aiCtl, 'optionalAccess', _403 => _403.openFromSlash, 'call', _404 => _404(ctx.blockIdx, ctx.query)]);
|
|
7504
7751
|
};
|
|
7505
7752
|
}
|
|
7506
7753
|
});
|
|
@@ -7523,9 +7770,13 @@ var Editor = (_class11 = class {
|
|
|
7523
7770
|
this.tableControls.destroy();
|
|
7524
7771
|
this.imageControls.destroy();
|
|
7525
7772
|
this.mentionPops.destroy();
|
|
7526
|
-
_optionalChain([this, 'access',
|
|
7527
|
-
_optionalChain([this, 'access',
|
|
7528
|
-
_optionalChain([this, 'access',
|
|
7773
|
+
_optionalChain([this, 'access', _405 => _405.commentPanel, 'optionalAccess', _406 => _406.destroy, 'call', _407 => _407()]);
|
|
7774
|
+
_optionalChain([this, 'access', _408 => _408.tocPanel, 'optionalAccess', _409 => _409.destroy, 'call', _410 => _410()]);
|
|
7775
|
+
_optionalChain([this, 'access', _411 => _411.aiCtl, 'optionalAccess', _412 => _412.destroy, 'call', _413 => _413()]);
|
|
7776
|
+
_optionalChain([this, 'access', _414 => _414.collabUi, 'optionalAccess', _415 => _415.destroy, 'call', _416 => _416()]);
|
|
7777
|
+
this.collabUi = null;
|
|
7778
|
+
_optionalChain([this, 'access', _417 => _417.collabCtl, 'optionalAccess', _418 => _418.close, 'call', _419 => _419()]);
|
|
7779
|
+
this.collabCtl = null;
|
|
7529
7780
|
this.aiCtl = null;
|
|
7530
7781
|
for (const d of this.decorations)
|
|
7531
7782
|
d.destroy();
|
|
@@ -7535,11 +7786,15 @@ var Editor = (_class11 = class {
|
|
|
7535
7786
|
get ai() {
|
|
7536
7787
|
return this.aiCtl;
|
|
7537
7788
|
}
|
|
7789
|
+
/** 协作客户端(opts.collab 启用时) */
|
|
7790
|
+
get collab() {
|
|
7791
|
+
return this.collabCtl;
|
|
7792
|
+
}
|
|
7538
7793
|
openAi(mode) {
|
|
7539
|
-
_optionalChain([this, 'access',
|
|
7794
|
+
_optionalChain([this, 'access', _420 => _420.aiCtl, 'optionalAccess', _421 => _421.openAtFocus, 'call', _422 => _422(mode)]);
|
|
7540
7795
|
}
|
|
7541
7796
|
stopAi() {
|
|
7542
|
-
_optionalChain([this, 'access',
|
|
7797
|
+
_optionalChain([this, 'access', _423 => _423.aiCtl, 'optionalAccess', _424 => _424.stop, 'call', _425 => _425()]);
|
|
7543
7798
|
}
|
|
7544
7799
|
get doc() {
|
|
7545
7800
|
return this.history.doc;
|
|
@@ -7552,17 +7807,17 @@ var Editor = (_class11 = class {
|
|
|
7552
7807
|
// 运行时切显隐符(tiptap show/hide/toggleInvisibleCharacters 对位)。纯重绘,model 不动。
|
|
7553
7808
|
setInvisibleCharacters(visible) {
|
|
7554
7809
|
this.invisible = visible;
|
|
7555
|
-
this.draw(_nullishCoalesce(
|
|
7810
|
+
this.draw(_nullishCoalesce(_chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0)));
|
|
7556
7811
|
}
|
|
7557
7812
|
get invisibleCharacters() {
|
|
7558
7813
|
return this.invisible;
|
|
7559
7814
|
}
|
|
7560
7815
|
// 当前评论线程(侧信道);未启用评论时空数组。
|
|
7561
7816
|
get comments() {
|
|
7562
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
7817
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _426 => _426.commentPanel, 'optionalAccess', _427 => _427.getThreads, 'call', _428 => _428()]), () => ( []));
|
|
7563
7818
|
}
|
|
7564
7819
|
setComments(threads) {
|
|
7565
|
-
_optionalChain([this, 'access',
|
|
7820
|
+
_optionalChain([this, 'access', _429 => _429.commentPanel, 'optionalAccess', _430 => _430.setThreads, 'call', _431 => _431(threads)]);
|
|
7566
7821
|
}
|
|
7567
7822
|
get readonly() {
|
|
7568
7823
|
return this.opts.editable === false;
|
|
@@ -7580,28 +7835,29 @@ var Editor = (_class11 = class {
|
|
|
7580
7835
|
blockRenderers: this.resolved.blockRenderers,
|
|
7581
7836
|
renderMath: this.opts.renderMath,
|
|
7582
7837
|
invisibleCharacters: this.invisible,
|
|
7583
|
-
commentState: _optionalChain([this, 'access',
|
|
7838
|
+
commentState: _optionalChain([this, 'access', _432 => _432.commentPanel, 'optionalAccess', _433 => _433.renderState, 'call', _434 => _434()]),
|
|
7584
7839
|
atomSelect: this.imageControls.selectCtx()
|
|
7585
7840
|
}), this.root);
|
|
7586
7841
|
stripStrayNodes(this.root.querySelector(".markloom-doc"));
|
|
7587
7842
|
if (restore)
|
|
7588
|
-
|
|
7843
|
+
_chunkYIFOGP2Dcjs.writeSelection.call(void 0, this.root, this.history.doc, restore);
|
|
7589
7844
|
this.root.dispatchEvent(new Event("markloom-redraw", { bubbles: true }));
|
|
7590
7845
|
this.syncPlaceholder();
|
|
7846
|
+
_optionalChain([this, 'access', _435 => _435.collabUi, 'optionalAccess', _436 => _436.onRedraw, 'call', _437 => _437()]);
|
|
7591
7847
|
}
|
|
7592
7848
|
// 空块提示(不进 model):空 paragraph → opts.placeholder(slash 引导);
|
|
7593
7849
|
// 空 heading → 类型名 H1…H6(飞书/Notion 式)。空文档常显;光标落空块时也显。
|
|
7594
|
-
|
|
7850
|
+
__init97() {this.syncPlaceholder = () => {
|
|
7595
7851
|
if (this.composing || this.readonly)
|
|
7596
7852
|
return;
|
|
7597
|
-
const docEl =
|
|
7853
|
+
const docEl = _chunkYIFOGP2Dcjs.rootEl.call(void 0, this.root);
|
|
7598
7854
|
for (const el2 of docEl.querySelectorAll("[data-placeholder]"))
|
|
7599
7855
|
el2.removeAttribute("data-placeholder");
|
|
7600
7856
|
const kids = this.history.doc.children;
|
|
7601
|
-
const isEmptyLeafBlock = (n, type) => !
|
|
7857
|
+
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
7858
|
const labelOf = (n) => {
|
|
7603
7859
|
if (n.type === "heading") {
|
|
7604
|
-
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
7860
|
+
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access', _438 => _438.attrs, 'optionalAccess', _439 => _439.depth]), () => ( 1))), 1), 6);
|
|
7605
7861
|
return `H${d}`;
|
|
7606
7862
|
}
|
|
7607
7863
|
if (n.type === "paragraph" && this.opts.placeholder)
|
|
@@ -7610,7 +7866,7 @@ var Editor = (_class11 = class {
|
|
|
7610
7866
|
};
|
|
7611
7867
|
let idx = null;
|
|
7612
7868
|
let text = null;
|
|
7613
|
-
if (kids.length === 1 && !
|
|
7869
|
+
if (kids.length === 1 && !_chunkGQ2HHRGIcjs.isText.call(void 0, kids[0])) {
|
|
7614
7870
|
const lab = labelOf(kids[0]);
|
|
7615
7871
|
if (lab && (isEmptyLeafBlock(kids[0], "paragraph") || isEmptyLeafBlock(kids[0], "heading"))) {
|
|
7616
7872
|
idx = 0;
|
|
@@ -7618,7 +7874,7 @@ var Editor = (_class11 = class {
|
|
|
7618
7874
|
}
|
|
7619
7875
|
}
|
|
7620
7876
|
if (idx == null) {
|
|
7621
|
-
const sel =
|
|
7877
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7622
7878
|
if (sel) {
|
|
7623
7879
|
const a = sel.anchor.path;
|
|
7624
7880
|
const h13 = sel.head.path;
|
|
@@ -7626,7 +7882,7 @@ var Editor = (_class11 = class {
|
|
|
7626
7882
|
if (collapsed) {
|
|
7627
7883
|
const i = a[0];
|
|
7628
7884
|
const b = kids[i];
|
|
7629
|
-
if (b && !
|
|
7885
|
+
if (b && !_chunkGQ2HHRGIcjs.isText.call(void 0, b)) {
|
|
7630
7886
|
const lab = labelOf(b);
|
|
7631
7887
|
if (lab && (isEmptyLeafBlock(b, "paragraph") || isEmptyLeafBlock(b, "heading"))) {
|
|
7632
7888
|
idx = i;
|
|
@@ -7638,75 +7894,107 @@ var Editor = (_class11 = class {
|
|
|
7638
7894
|
}
|
|
7639
7895
|
if (idx == null || text == null)
|
|
7640
7896
|
return;
|
|
7641
|
-
const el =
|
|
7897
|
+
const el = _chunkYIFOGP2Dcjs.elementChildren.call(void 0, docEl)[idx];
|
|
7642
7898
|
if (el)
|
|
7643
7899
|
el.setAttribute("data-placeholder", text);
|
|
7644
7900
|
}}
|
|
7645
7901
|
dispatch(steps, selectionAfter) {
|
|
7646
7902
|
if (steps.length === 0)
|
|
7647
7903
|
return;
|
|
7648
|
-
const after =
|
|
7904
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7649
7905
|
const batch = steps.concat(gapSteps(after));
|
|
7650
|
-
this.history =
|
|
7906
|
+
this.history = _chunkYXQDCW4Ycjs.commit.call(void 0, this.history, batch);
|
|
7651
7907
|
this.draw(selectionAfter);
|
|
7652
|
-
_optionalChain([this, 'access',
|
|
7908
|
+
_optionalChain([this, 'access', _440 => _440.opts, 'access', _441 => _441.onChange, 'optionalCall', _442 => _442(this.history.doc)]);
|
|
7909
|
+
if (!this.applyingRemote)
|
|
7910
|
+
_optionalChain([this, 'access', _443 => _443.collabCtl, 'optionalAccess', _444 => _444.push, 'call', _445 => _445(batch)]);
|
|
7653
7911
|
}
|
|
7654
7912
|
// AI 流式 / 事务内续写:并入 past 最后一条,一次 undo 回退整笔事务。
|
|
7655
7913
|
dispatchStream(steps, selectionAfter) {
|
|
7656
7914
|
if (steps.length === 0)
|
|
7657
7915
|
return;
|
|
7658
|
-
const after =
|
|
7916
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7659
7917
|
const batch = steps.concat(gapSteps(after));
|
|
7660
|
-
this.history =
|
|
7918
|
+
this.history = _chunkYXQDCW4Ycjs.amend.call(void 0, this.history, batch);
|
|
7661
7919
|
this.draw(selectionAfter);
|
|
7662
|
-
_optionalChain([this, 'access',
|
|
7920
|
+
_optionalChain([this, 'access', _446 => _446.opts, 'access', _447 => _447.onChange, 'optionalCall', _448 => _448(this.history.doc)]);
|
|
7921
|
+
if (!this.applyingRemote)
|
|
7922
|
+
_optionalChain([this, 'access', _449 => _449.collabCtl, 'optionalAccess', _450 => _450.push, 'call', _451 => _451(batch)]);
|
|
7923
|
+
}
|
|
7924
|
+
/** 远端协作 op:写入 model 但不上行 */
|
|
7925
|
+
applyRemote(steps, selectionAfter) {
|
|
7926
|
+
if (steps.length === 0)
|
|
7927
|
+
return;
|
|
7928
|
+
this.applyingRemote = true;
|
|
7929
|
+
try {
|
|
7930
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7931
|
+
const batch = steps.concat(gapSteps(after));
|
|
7932
|
+
this.history = _chunkYXQDCW4Ycjs.commit.call(void 0, this.history, batch);
|
|
7933
|
+
this.draw(selectionAfter);
|
|
7934
|
+
_optionalChain([this, 'access', _452 => _452.opts, 'access', _453 => _453.onChange, 'optionalCall', _454 => _454(this.history.doc)]);
|
|
7935
|
+
} finally {
|
|
7936
|
+
this.applyingRemote = false;
|
|
7937
|
+
}
|
|
7938
|
+
}
|
|
7939
|
+
/** 权威快照替换(welcome/resync);清空本地 undo 栈 */
|
|
7940
|
+
replaceDoc(doc) {
|
|
7941
|
+
const dev = typeof process !== "undefined" && _optionalChain([process, 'access', _455 => _455.env, 'optionalAccess', _456 => _456.NODE_ENV]) !== "production";
|
|
7942
|
+
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);
|
|
7943
|
+
this.draw();
|
|
7944
|
+
_optionalChain([this, 'access', _457 => _457.opts, 'access', _458 => _458.onChange, 'optionalCall', _459 => _459(this.history.doc)]);
|
|
7663
7945
|
}
|
|
7664
7946
|
/** 回退一笔 history(AI 事务 discard = undo 整笔) */
|
|
7665
7947
|
undo() {
|
|
7666
|
-
const
|
|
7948
|
+
const last = this.history.past[this.history.past.length - 1];
|
|
7949
|
+
const next = _chunkYXQDCW4Ycjs.undo.call(void 0, this.history);
|
|
7667
7950
|
if (next === this.history)
|
|
7668
7951
|
return false;
|
|
7669
7952
|
this.history = next;
|
|
7670
7953
|
this.draw();
|
|
7671
|
-
_optionalChain([this, 'access',
|
|
7954
|
+
_optionalChain([this, 'access', _460 => _460.opts, 'access', _461 => _461.onChange, 'optionalCall', _462 => _462(this.history.doc)]);
|
|
7955
|
+
if (!this.applyingRemote && last)
|
|
7956
|
+
_optionalChain([this, 'access', _463 => _463.collabCtl, 'optionalAccess', _464 => _464.push, 'call', _465 => _465(last.inverse)]);
|
|
7672
7957
|
return true;
|
|
7673
7958
|
}
|
|
7674
7959
|
redo() {
|
|
7675
|
-
const
|
|
7960
|
+
const fut = this.history.future[0];
|
|
7961
|
+
const next = _chunkYXQDCW4Ycjs.redo.call(void 0, this.history);
|
|
7676
7962
|
if (next === this.history)
|
|
7677
7963
|
return false;
|
|
7678
7964
|
this.history = next;
|
|
7679
7965
|
this.draw();
|
|
7680
|
-
_optionalChain([this, 'access',
|
|
7966
|
+
_optionalChain([this, 'access', _466 => _466.opts, 'access', _467 => _467.onChange, 'optionalCall', _468 => _468(this.history.doc)]);
|
|
7967
|
+
if (!this.applyingRemote && fut)
|
|
7968
|
+
_optionalChain([this, 'access', _469 => _469.collabCtl, 'optionalAccess', _470 => _470.push, 'call', _471 => _471(fut.steps)]);
|
|
7681
7969
|
return true;
|
|
7682
7970
|
}
|
|
7683
7971
|
/** 续写:当前块后插空段并流式灌入 */
|
|
7684
7972
|
aiContinue(blockId) {
|
|
7685
|
-
return
|
|
7973
|
+
return _chunkYIFOGP2Dcjs.startAiWrite.call(void 0, this, "continue", blockId);
|
|
7686
7974
|
}
|
|
7687
7975
|
/** 改写:清空当前块再流式回填 */
|
|
7688
7976
|
aiRewrite(blockId) {
|
|
7689
|
-
return
|
|
7977
|
+
return _chunkYIFOGP2Dcjs.startAiWrite.call(void 0, this, "rewrite", blockId);
|
|
7690
7978
|
}
|
|
7691
7979
|
// 组字开始:快照「这一刻的叶文本」作为 3-way merge 的 base。
|
|
7692
7980
|
// IME 改动 = diff(base, DOM落定文本);AI 并发改动 = diff(base, model现态)。两者都相对 base。
|
|
7693
|
-
|
|
7981
|
+
__init98() {this.onCompositionStart = () => {
|
|
7694
7982
|
this.composing = true;
|
|
7695
|
-
const sel =
|
|
7983
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7696
7984
|
if (!sel) {
|
|
7697
7985
|
this.composeBase = null;
|
|
7698
7986
|
return;
|
|
7699
7987
|
}
|
|
7700
7988
|
const leafPath = sel.head.path.slice(0, -1);
|
|
7701
|
-
const leaf =
|
|
7702
|
-
this.composeBase = { leafPath, text:
|
|
7989
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, leafPath);
|
|
7990
|
+
this.composeBase = { leafPath, text: _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "" };
|
|
7703
7991
|
}}
|
|
7704
7992
|
// task 勾选:独立 capture 处理器(见 onTaskCheck)。此处:链接打开 + callout/math/mention。
|
|
7705
|
-
|
|
7993
|
+
__init99() {this.onClick = (e) => {
|
|
7706
7994
|
const target = e.target;
|
|
7707
|
-
if (_optionalChain([target, 'optionalAccess',
|
|
7995
|
+
if (_optionalChain([target, 'optionalAccess', _472 => _472.closest, 'optionalCall', _473 => _473("[data-task-check]")]))
|
|
7708
7996
|
return;
|
|
7709
|
-
const a = _optionalChain([target, 'optionalAccess',
|
|
7997
|
+
const a = _optionalChain([target, 'optionalAccess', _474 => _474.closest, 'optionalCall', _475 => _475('a[data-mark="link"]')]);
|
|
7710
7998
|
if (a && this.root.contains(a)) {
|
|
7711
7999
|
const href = a.getAttribute("href");
|
|
7712
8000
|
if (href) {
|
|
@@ -7721,10 +8009,10 @@ var Editor = (_class11 = class {
|
|
|
7721
8009
|
}
|
|
7722
8010
|
if (this.readonly)
|
|
7723
8011
|
return;
|
|
7724
|
-
const aiAct = _optionalChain([target, 'optionalAccess',
|
|
8012
|
+
const aiAct = _optionalChain([target, 'optionalAccess', _476 => _476.closest, 'optionalCall', _477 => _477("[data-ai-act]")]);
|
|
7725
8013
|
if (aiAct && this.root.contains(aiAct) && this.aiCtl) {
|
|
7726
8014
|
const blockEl = aiAct.closest("[data-ai-block][data-block-id]");
|
|
7727
|
-
const id2 = _optionalChain([blockEl, 'optionalAccess',
|
|
8015
|
+
const id2 = _optionalChain([blockEl, 'optionalAccess', _478 => _478.getAttribute, 'call', _479 => _479("data-block-id")]);
|
|
7728
8016
|
const act = aiAct.getAttribute("data-ai-act");
|
|
7729
8017
|
if (id2 && act) {
|
|
7730
8018
|
e.preventDefault();
|
|
@@ -7733,9 +8021,9 @@ var Editor = (_class11 = class {
|
|
|
7733
8021
|
return;
|
|
7734
8022
|
}
|
|
7735
8023
|
}
|
|
7736
|
-
const chip = _optionalChain([target, 'optionalAccess',
|
|
7737
|
-
const mathEl = _optionalChain([target, 'optionalAccess',
|
|
7738
|
-
const menEl = _optionalChain([target, 'optionalAccess',
|
|
8024
|
+
const chip = _optionalChain([target, 'optionalAccess', _480 => _480.closest, 'optionalCall', _481 => _481("[data-callout-variant]")]);
|
|
8025
|
+
const mathEl = _optionalChain([target, 'optionalAccess', _482 => _482.closest, 'optionalCall', _483 => _483('[data-atom="math"]')]);
|
|
8026
|
+
const menEl = _optionalChain([target, 'optionalAccess', _484 => _484.closest, 'optionalCall', _485 => _485('[data-atom="mention"]')]);
|
|
7739
8027
|
const hit = _nullishCoalesce(_nullishCoalesce(chip, () => ( mathEl)), () => ( menEl));
|
|
7740
8028
|
if (!hit) {
|
|
7741
8029
|
this.pendingMarks = null;
|
|
@@ -7751,14 +8039,14 @@ var Editor = (_class11 = class {
|
|
|
7751
8039
|
this.openMentionPop(menEl);
|
|
7752
8040
|
return;
|
|
7753
8041
|
}
|
|
7754
|
-
const id = _optionalChain([hit, 'access',
|
|
8042
|
+
const id = _optionalChain([hit, 'access', _486 => _486.closest, 'call', _487 => _487("[data-block-id]"), 'optionalAccess', _488 => _488.getAttribute, 'call', _489 => _489("data-block-id")]);
|
|
7755
8043
|
if (!id)
|
|
7756
8044
|
return;
|
|
7757
|
-
const path =
|
|
8045
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id);
|
|
7758
8046
|
if (!path)
|
|
7759
8047
|
return;
|
|
7760
|
-
const node =
|
|
7761
|
-
if (
|
|
8048
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path);
|
|
8049
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
7762
8050
|
return;
|
|
7763
8051
|
if (chip && node.type === "callout") {
|
|
7764
8052
|
e.preventDefault();
|
|
@@ -7768,7 +8056,7 @@ var Editor = (_class11 = class {
|
|
|
7768
8056
|
}
|
|
7769
8057
|
}}
|
|
7770
8058
|
// 任务 checkbox:capture 阶段处理;li[data-task] 定位 list_item,乐观更新 UI 再 commit model。
|
|
7771
|
-
|
|
8059
|
+
__init100() {this.onTaskCheck = (e) => {
|
|
7772
8060
|
if (this.readonly)
|
|
7773
8061
|
return;
|
|
7774
8062
|
const t = e.target;
|
|
@@ -7785,8 +8073,8 @@ var Editor = (_class11 = class {
|
|
|
7785
8073
|
const path = pathOfTaskItem(this.history.doc, this.root, li);
|
|
7786
8074
|
if (!path)
|
|
7787
8075
|
return;
|
|
7788
|
-
const node =
|
|
7789
|
-
if (!node ||
|
|
8076
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path);
|
|
8077
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "list_item" || _optionalChain([node, 'access', _490 => _490.attrs, 'optionalAccess', _491 => _491.checked]) == null)
|
|
7790
8078
|
return;
|
|
7791
8079
|
const next = !node.attrs.checked;
|
|
7792
8080
|
box.checked = next;
|
|
@@ -7799,21 +8087,21 @@ var Editor = (_class11 = class {
|
|
|
7799
8087
|
}}
|
|
7800
8088
|
openMentionPop(el) {
|
|
7801
8089
|
const blockEl = el.closest("[data-block-id]");
|
|
7802
|
-
const bid = _optionalChain([blockEl, 'optionalAccess',
|
|
8090
|
+
const bid = _optionalChain([blockEl, 'optionalAccess', _492 => _492.getAttribute, 'call', _493 => _493("data-block-id")]);
|
|
7803
8091
|
if (!bid)
|
|
7804
8092
|
return;
|
|
7805
|
-
const blockPath =
|
|
8093
|
+
const blockPath = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, bid);
|
|
7806
8094
|
if (!blockPath)
|
|
7807
8095
|
return;
|
|
7808
|
-
const block =
|
|
7809
|
-
if (
|
|
8096
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8097
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block)
|
|
7810
8098
|
return;
|
|
7811
8099
|
const leafKey = el.getAttribute("data-leaf");
|
|
7812
8100
|
const leafIdx = leafKey != null && leafKey !== "" ? Number(leafKey) : -1;
|
|
7813
8101
|
if (leafIdx < 0 || leafIdx >= block.children.length)
|
|
7814
8102
|
return;
|
|
7815
8103
|
const atom = block.children[leafIdx];
|
|
7816
|
-
if (
|
|
8104
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "mention")
|
|
7817
8105
|
return;
|
|
7818
8106
|
const a = _nullishCoalesce(atom.attrs, () => ( {}));
|
|
7819
8107
|
const rect = el.getBoundingClientRect();
|
|
@@ -7824,7 +8112,7 @@ var Editor = (_class11 = class {
|
|
|
7824
8112
|
return;
|
|
7825
8113
|
}
|
|
7826
8114
|
const id = String(_nullishCoalesce(a.id, () => ( "")));
|
|
7827
|
-
const fromHost = _optionalChain([this, 'access',
|
|
8115
|
+
const fromHost = _optionalChain([this, 'access', _494 => _494.opts, 'access', _495 => _495.mentionProfile, 'optionalCall', _496 => _496(id)]);
|
|
7828
8116
|
const profile = _nullishCoalesce(fromHost, () => ( {
|
|
7829
8117
|
id,
|
|
7830
8118
|
name: typeof a.label === "string" ? a.label : id
|
|
@@ -7836,11 +8124,11 @@ var Editor = (_class11 = class {
|
|
|
7836
8124
|
return;
|
|
7837
8125
|
const blockPath = path.slice(0, -1);
|
|
7838
8126
|
const leafIdx = path[path.length - 1];
|
|
7839
|
-
const block =
|
|
7840
|
-
if (
|
|
8127
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8128
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block || leafIdx >= block.children.length)
|
|
7841
8129
|
return;
|
|
7842
8130
|
const atom = block.children[leafIdx];
|
|
7843
|
-
if (
|
|
8131
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "mention")
|
|
7844
8132
|
return;
|
|
7845
8133
|
const children = block.children.slice();
|
|
7846
8134
|
const label = iso.includes("T") ? iso.replace("T", " ") : iso;
|
|
@@ -7850,7 +8138,7 @@ var Editor = (_class11 = class {
|
|
|
7850
8138
|
};
|
|
7851
8139
|
this.dispatch([{ kind: "replaceNode", path: blockPath, node: { ...block, children } }]);
|
|
7852
8140
|
}
|
|
7853
|
-
|
|
8141
|
+
__init101() {this.onBeforeInput = (e) => {
|
|
7854
8142
|
if (this.readonly || this.composing)
|
|
7855
8143
|
return;
|
|
7856
8144
|
const intent = intentOf(e.inputType);
|
|
@@ -7865,7 +8153,7 @@ var Editor = (_class11 = class {
|
|
|
7865
8153
|
}
|
|
7866
8154
|
if (this.atomBlockGuard(intent, _nullishCoalesce(e.data, () => ( "")), e))
|
|
7867
8155
|
return;
|
|
7868
|
-
const sel =
|
|
8156
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7869
8157
|
if (!sel) {
|
|
7870
8158
|
e.preventDefault();
|
|
7871
8159
|
return;
|
|
@@ -7888,29 +8176,47 @@ var Editor = (_class11 = class {
|
|
|
7888
8176
|
/** caret 是否在 type=ai 块内;是则返该块,否则 null */
|
|
7889
8177
|
aiBlockAt(sel) {
|
|
7890
8178
|
const top = this.history.doc.children[sel.head.path[0]];
|
|
7891
|
-
if (!top ||
|
|
8179
|
+
if (!top || _chunkGQ2HHRGIcjs.isText.call(void 0, top) || top.type !== "ai")
|
|
7892
8180
|
return null;
|
|
7893
8181
|
return top;
|
|
7894
8182
|
}
|
|
7895
8183
|
// AI 输入守卫:
|
|
7896
|
-
// · 顶层 draft
|
|
7897
|
-
// ·
|
|
8184
|
+
// · 顶层 draft(attrs.aiDraft)且对应 ai 壳仍在 → 只读(确认前淡化)
|
|
8185
|
+
// · 孤儿 draft(壳已丢)→ 当场解锁可编辑,避免「虚区域无法输入」
|
|
8186
|
+
// · ai 块内:Enter 生成/确认;loading 锁输入;空指令块首退格 → discard
|
|
7898
8187
|
aiBlockGuard(intent, sel, e) {
|
|
7899
8188
|
if (!this.aiCtl)
|
|
7900
8189
|
return false;
|
|
7901
8190
|
const top = this.history.doc.children[sel.head.path[0]];
|
|
7902
|
-
if (top && !
|
|
7903
|
-
|
|
7904
|
-
|
|
8191
|
+
if (top && !_chunkGQ2HHRGIcjs.isText.call(void 0, top) && _optionalChain([top, 'access', _497 => _497.attrs, 'optionalAccess', _498 => _498.aiDraft])) {
|
|
8192
|
+
const from = typeof top.attrs.aiFrom === "string" ? top.attrs.aiFrom : "";
|
|
8193
|
+
const live = !!from && this.history.doc.children.some(
|
|
8194
|
+
(c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "ai" && c.id === from
|
|
8195
|
+
);
|
|
8196
|
+
if (live) {
|
|
8197
|
+
e.preventDefault();
|
|
8198
|
+
return true;
|
|
8199
|
+
}
|
|
8200
|
+
this.promoteOrphanAiDrafts();
|
|
7905
8201
|
}
|
|
7906
8202
|
const ai = this.aiBlockAt(sel);
|
|
7907
8203
|
if (!ai || !ai.id)
|
|
7908
8204
|
return false;
|
|
7909
|
-
const status = typeof _optionalChain([ai, 'access',
|
|
8205
|
+
const status = typeof _optionalChain([ai, 'access', _499 => _499.attrs, 'optionalAccess', _500 => _500.status]) === "string" ? ai.attrs.status : "compose";
|
|
7910
8206
|
if (status === "loading") {
|
|
7911
8207
|
e.preventDefault();
|
|
7912
8208
|
return true;
|
|
7913
8209
|
}
|
|
8210
|
+
if (intent === "deleteBackward") {
|
|
8211
|
+
const prompt = ai.children[0];
|
|
8212
|
+
const empty = !prompt || _chunkGQ2HHRGIcjs.isText.call(void 0, prompt) || !_chunkGQ2HHRGIcjs.isText.call(void 0, prompt) && prompt.type === "paragraph" && prompt.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text === "");
|
|
8213
|
+
const atPromptStart = sel.head.path.length >= 4 && sel.head.path[1] === 0 && sel.head.path[sel.head.path.length - 1] === 0;
|
|
8214
|
+
if (empty && atPromptStart) {
|
|
8215
|
+
e.preventDefault();
|
|
8216
|
+
this.aiCtl.discard(ai.id);
|
|
8217
|
+
return true;
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
7914
8220
|
if (intent === "insertParagraph") {
|
|
7915
8221
|
e.preventDefault();
|
|
7916
8222
|
if (status === "preview")
|
|
@@ -7921,6 +8227,35 @@ var Editor = (_class11 = class {
|
|
|
7921
8227
|
}
|
|
7922
8228
|
return false;
|
|
7923
8229
|
}
|
|
8230
|
+
/** 壳已不在的 aiDraft 顶层块 → 剥事务标记,恢复可编辑 */
|
|
8231
|
+
promoteOrphanAiDrafts() {
|
|
8232
|
+
const doc = this.history.doc;
|
|
8233
|
+
const liveAi = /* @__PURE__ */ new Set();
|
|
8234
|
+
for (const c of doc.children) {
|
|
8235
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "ai" && c.id)
|
|
8236
|
+
liveAi.add(c.id);
|
|
8237
|
+
}
|
|
8238
|
+
const steps = [];
|
|
8239
|
+
for (let i = 0; i < doc.children.length; i++) {
|
|
8240
|
+
const c = doc.children[i];
|
|
8241
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c) || !_optionalChain([c, 'access', _501 => _501.attrs, 'optionalAccess', _502 => _502.aiDraft]))
|
|
8242
|
+
continue;
|
|
8243
|
+
const from = typeof c.attrs.aiFrom === "string" ? c.attrs.aiFrom : "";
|
|
8244
|
+
if (from && liveAi.has(from))
|
|
8245
|
+
continue;
|
|
8246
|
+
const attrs = { ...c.attrs };
|
|
8247
|
+
delete attrs.aiDraft;
|
|
8248
|
+
delete attrs.aiFrom;
|
|
8249
|
+
delete attrs.aiStream;
|
|
8250
|
+
const clean = Object.keys(attrs).length ? attrs : void 0;
|
|
8251
|
+
const next = { type: c.type, id: c.id, children: c.children };
|
|
8252
|
+
if (clean)
|
|
8253
|
+
next.attrs = clean;
|
|
8254
|
+
steps.push({ kind: "replaceNode", path: [i], node: next });
|
|
8255
|
+
}
|
|
8256
|
+
if (steps.length)
|
|
8257
|
+
this.dispatch(steps);
|
|
8258
|
+
}
|
|
7924
8259
|
// 塌缩 caret 落在**非空** code 块的边界时,给出它在首/尾。否则返 null(不在 code / 非塌缩 / 空块 → 放行给 mapInput)。
|
|
7925
8260
|
// 「code 内首尾删会与相邻块并块、破坏『单文本叶』不变量」是 codeBlockGuard 与 codeBoundaryDelete 共守的同一判定,
|
|
7926
8261
|
// 抽成单一真相:collapsed/off/len/边界只算一处,两处消费,口径不漂。空块(len===0)无内容可护,放行删空块。
|
|
@@ -7931,8 +8266,8 @@ var Editor = (_class11 = class {
|
|
|
7931
8266
|
if (!collapsed)
|
|
7932
8267
|
return null;
|
|
7933
8268
|
const off = sel.head.path[sel.head.path.length - 1];
|
|
7934
|
-
const leaf =
|
|
7935
|
-
const len =
|
|
8269
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, sel.head.path.slice(0, -1));
|
|
8270
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0;
|
|
7936
8271
|
if (len === 0)
|
|
7937
8272
|
return null;
|
|
7938
8273
|
return { atStart: off === 0, atEnd: off === len };
|
|
@@ -7968,10 +8303,10 @@ var Editor = (_class11 = class {
|
|
|
7968
8303
|
const rel = path.slice(1);
|
|
7969
8304
|
const doc = this.history.doc;
|
|
7970
8305
|
const block = doc.children[topIdx];
|
|
7971
|
-
if (!block ||
|
|
8306
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
7972
8307
|
return null;
|
|
7973
|
-
const startRel =
|
|
7974
|
-
const endRel =
|
|
8308
|
+
const startRel = _chunk4TMHVNL6cjs.firstLeafPath.call(void 0, block).concat(0);
|
|
8309
|
+
const endRel = _chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, block);
|
|
7975
8310
|
const eq = (a, b) => a.length === b.length && a.every((s, i) => s === b[i]);
|
|
7976
8311
|
const atStart = dir === "back" && eq(rel, startRel);
|
|
7977
8312
|
const atEnd = dir === "fwd" && eq(rel, endRel);
|
|
@@ -7981,7 +8316,7 @@ var Editor = (_class11 = class {
|
|
|
7981
8316
|
// 顶层第 idx 块若是图/表 atom → {控制器, id};否则 null。atomAtEdge(字符口径)与竖直键(视觉口径)共用。
|
|
7982
8317
|
atomAt(idx) {
|
|
7983
8318
|
const neighbor = this.history.doc.children[idx];
|
|
7984
|
-
if (!neighbor ||
|
|
8319
|
+
if (!neighbor || _chunkGQ2HHRGIcjs.isText.call(void 0, neighbor) || !neighbor.id)
|
|
7985
8320
|
return null;
|
|
7986
8321
|
const ctrl = this.atomControls(neighbor.type);
|
|
7987
8322
|
return ctrl ? { ctrl, id: neighbor.id } : null;
|
|
@@ -7999,7 +8334,7 @@ var Editor = (_class11 = class {
|
|
|
7999
8334
|
const caret3 = range.getBoundingClientRect();
|
|
8000
8335
|
if (caret3.width === 0 && caret3.height === 0)
|
|
8001
8336
|
return false;
|
|
8002
|
-
const blockEl =
|
|
8337
|
+
const blockEl = _chunkYIFOGP2Dcjs.elementChildren.call(void 0, _chunkYIFOGP2Dcjs.rootEl.call(void 0, this.root))[topIdx];
|
|
8003
8338
|
if (!blockEl)
|
|
8004
8339
|
return false;
|
|
8005
8340
|
const box = blockEl.getBoundingClientRect();
|
|
@@ -8019,7 +8354,7 @@ var Editor = (_class11 = class {
|
|
|
8019
8354
|
return null;
|
|
8020
8355
|
const topIdx = path[0];
|
|
8021
8356
|
const block = this.history.doc.children[topIdx];
|
|
8022
|
-
if (!block ||
|
|
8357
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
8023
8358
|
return null;
|
|
8024
8359
|
if (!this.onEdgeVisualLine(topIdx, dir))
|
|
8025
8360
|
return null;
|
|
@@ -8063,7 +8398,7 @@ var Editor = (_class11 = class {
|
|
|
8063
8398
|
const only = doc.children.length === 1;
|
|
8064
8399
|
if (isTable) {
|
|
8065
8400
|
const caret4 = this.neighborCaret(idx, only ? [idx] : null);
|
|
8066
|
-
this.dispatch([
|
|
8401
|
+
this.dispatch([_chunk4TMHVNL6cjs.deleteTableBlock.call(void 0, [idx], doc)], caret4);
|
|
8067
8402
|
return true;
|
|
8068
8403
|
}
|
|
8069
8404
|
const insert = only ? [{ type: "paragraph", id: newId3(), children: [{ text: "" }] }] : [];
|
|
@@ -8104,30 +8439,30 @@ var Editor = (_class11 = class {
|
|
|
8104
8439
|
return at([...fallbackIdx, 0, 0]);
|
|
8105
8440
|
const doc = this.history.doc;
|
|
8106
8441
|
const prev = doc.children[removedIdx - 1];
|
|
8107
|
-
if (prev && !
|
|
8108
|
-
return at([removedIdx - 1, ...
|
|
8442
|
+
if (prev && !_chunkGQ2HHRGIcjs.isText.call(void 0, prev))
|
|
8443
|
+
return at([removedIdx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prev)]);
|
|
8109
8444
|
const next = doc.children[removedIdx + 1];
|
|
8110
|
-
if (next && !
|
|
8111
|
-
return at([removedIdx, ...
|
|
8445
|
+
if (next && !_chunkGQ2HHRGIcjs.isText.call(void 0, next))
|
|
8446
|
+
return at([removedIdx, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, next), 0]);
|
|
8112
8447
|
return at([Math.max(0, removedIdx - 1), 0, 0]);
|
|
8113
8448
|
}
|
|
8114
8449
|
isCodeBlock(blockPath) {
|
|
8115
8450
|
if (blockPath.length === 0)
|
|
8116
8451
|
return false;
|
|
8117
|
-
const block =
|
|
8118
|
-
return !
|
|
8452
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8453
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, block) && block.type === "code";
|
|
8119
8454
|
}
|
|
8120
8455
|
// caret 落在 list_item 段落内:tail = [paraIdx, leafIdx, char],去掉得 itemPath。塌缩选区才接管(indent/outdent 是块搬家)。
|
|
8121
8456
|
inListItem(path) {
|
|
8122
8457
|
if (path.length < 4)
|
|
8123
8458
|
return false;
|
|
8124
|
-
const item =
|
|
8125
|
-
return !!item && !
|
|
8459
|
+
const item = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path.slice(0, -3));
|
|
8460
|
+
return !!item && !_chunkGQ2HHRGIcjs.isText.call(void 0, item) && item.type === "list_item";
|
|
8126
8461
|
}
|
|
8127
8462
|
// intentOf 不认的删变体(word/line 删)在代码块边界的守卫:跨块涉码 / 塌缩在 code 对应边 → preventDefault(挡浏览器并块)。
|
|
8128
8463
|
// 非边界(代码块中段)不接管,放行——与 codeBlockGuard 的「只收边界、放行叶内」一致,不过度拦。
|
|
8129
8464
|
codeBoundaryDelete(dir, e) {
|
|
8130
|
-
const sel =
|
|
8465
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8131
8466
|
if (!sel)
|
|
8132
8467
|
return;
|
|
8133
8468
|
if (this.straddlesAtom(sel)) {
|
|
@@ -8150,7 +8485,7 @@ var Editor = (_class11 = class {
|
|
|
8150
8485
|
// 到 cell/文档真边界 mapInput 才返 null)——「删空本行/本段后再删能退上去」的语义由此路径提供。
|
|
8151
8486
|
// 一律 preventDefault(否则浏览器原生删破 DOM≡doc,后续 readSelection 读脏 DOM 返 null → 打字被吞)。
|
|
8152
8487
|
wordLineDelete(dir, inputType, e) {
|
|
8153
|
-
const sel =
|
|
8488
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8154
8489
|
if (!sel) {
|
|
8155
8490
|
e.preventDefault();
|
|
8156
8491
|
return;
|
|
@@ -8176,18 +8511,18 @@ var Editor = (_class11 = class {
|
|
|
8176
8511
|
// 正解是 3-way merge:base=组字前叶文本快照。IME 改动 = diff(base, DOM 落定文本)——
|
|
8177
8512
|
// 这是「相对 base 的纯 IME 局部编辑」,不含 AI 的并发改动。把它作为 Step 施加到 model 当前态,
|
|
8178
8513
|
// AI 在同段别处的改动得以保留(diff(model,DOM) 会把 AI 改动误当删除——那是错的)。
|
|
8179
|
-
|
|
8514
|
+
__init102() {this.onCompositionEnd = () => {
|
|
8180
8515
|
this.composing = false;
|
|
8181
8516
|
const base = this.composeBase;
|
|
8182
8517
|
this.composeBase = null;
|
|
8183
|
-
const sel =
|
|
8518
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8184
8519
|
if (!sel || !base) {
|
|
8185
8520
|
this.draw();
|
|
8186
8521
|
return;
|
|
8187
8522
|
}
|
|
8188
8523
|
const leafPath = base.leafPath;
|
|
8189
|
-
const dom =
|
|
8190
|
-
const domText = (_optionalChain([dom, 'optionalAccess',
|
|
8524
|
+
const dom = _chunkYIFOGP2Dcjs.pointToDom.call(void 0, this.root, this.history.doc, { path: leafPath.concat(0) });
|
|
8525
|
+
const domText = (_optionalChain([dom, 'optionalAccess', _503 => _503.node]) && isDomText(dom.node) ? _nullishCoalesce(dom.node.textContent, () => ( "")) : "").replaceAll("\u200B", "");
|
|
8191
8526
|
const edit = diffSpan(base.text, domText);
|
|
8192
8527
|
if (!edit) {
|
|
8193
8528
|
this.draw();
|
|
@@ -8204,7 +8539,7 @@ var Editor = (_class11 = class {
|
|
|
8204
8539
|
}
|
|
8205
8540
|
this.dispatch(steps, caretAfter(leafPath, edit.at + edit.insert.length));
|
|
8206
8541
|
}}
|
|
8207
|
-
|
|
8542
|
+
__init103() {this.onKeyDown = (e) => {
|
|
8208
8543
|
if (this.readonly)
|
|
8209
8544
|
return;
|
|
8210
8545
|
const mod2 = e.metaKey || e.ctrlKey;
|
|
@@ -8233,7 +8568,7 @@ var Editor = (_class11 = class {
|
|
|
8233
8568
|
const doc = this.history.doc;
|
|
8234
8569
|
const nbrIdx = exitBack ? idx - 1 : idx + 1;
|
|
8235
8570
|
const nbr = doc.children[nbrIdx];
|
|
8236
|
-
if (nbr && !
|
|
8571
|
+
if (nbr && !_chunkGQ2HHRGIcjs.isText.call(void 0, nbr)) {
|
|
8237
8572
|
const nbrCtrl = nbr.id ? this.atomControls(nbr.type) : null;
|
|
8238
8573
|
if (nbrCtrl && nbrCtrl.selectByBlockId(nbr.id)) {
|
|
8239
8574
|
if (nbrCtrl !== selCtrl)
|
|
@@ -8241,8 +8576,8 @@ var Editor = (_class11 = class {
|
|
|
8241
8576
|
return;
|
|
8242
8577
|
}
|
|
8243
8578
|
selCtrl.clearSelected();
|
|
8244
|
-
const target = exitBack ? [nbrIdx, ...
|
|
8245
|
-
|
|
8579
|
+
const target = exitBack ? [nbrIdx, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, nbr)] : [nbrIdx, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, nbr), 0];
|
|
8580
|
+
_chunkYIFOGP2Dcjs.writeSelection.call(void 0, this.root, doc, { anchor: { path: target }, head: { path: target } });
|
|
8246
8581
|
return;
|
|
8247
8582
|
}
|
|
8248
8583
|
selCtrl.clearSelected();
|
|
@@ -8250,7 +8585,7 @@ var Editor = (_class11 = class {
|
|
|
8250
8585
|
}
|
|
8251
8586
|
}
|
|
8252
8587
|
if ((exitBack || exitFwd) && !mod2 && !e.shiftKey && !selCtrl) {
|
|
8253
|
-
const sel =
|
|
8588
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8254
8589
|
if (sel) {
|
|
8255
8590
|
const dir = exitBack ? "back" : "fwd";
|
|
8256
8591
|
const hit = _nullishCoalesce(this.atomAtEdge(sel, dir), () => ( (e.key === "ArrowUp" || e.key === "ArrowDown" ? this.atomAtEdgeVertical(sel, dir) : null)));
|
|
@@ -8270,7 +8605,7 @@ var Editor = (_class11 = class {
|
|
|
8270
8605
|
return;
|
|
8271
8606
|
}
|
|
8272
8607
|
if (e.key === "Tab" && !e.shiftKey && !mod2) {
|
|
8273
|
-
const sel =
|
|
8608
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8274
8609
|
if (sel && this.isCodeBlock(sel.head.path.slice(0, -2))) {
|
|
8275
8610
|
const result = mapInput(this.history.doc, "insertText", " ", sel, newId3);
|
|
8276
8611
|
if (result) {
|
|
@@ -8288,13 +8623,13 @@ var Editor = (_class11 = class {
|
|
|
8288
8623
|
}
|
|
8289
8624
|
}
|
|
8290
8625
|
if (e.key === "Tab" && e.shiftKey && !mod2) {
|
|
8291
|
-
const sel =
|
|
8292
|
-
const blockPath = _optionalChain([sel, 'optionalAccess',
|
|
8626
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8627
|
+
const blockPath = _optionalChain([sel, 'optionalAccess', _504 => _504.head, 'access', _505 => _505.path, 'access', _506 => _506.slice, 'call', _507 => _507(0, -2)]);
|
|
8293
8628
|
if (sel && blockPath && this.isCodeBlock(blockPath)) {
|
|
8294
8629
|
e.preventDefault();
|
|
8295
8630
|
const leafPath = sel.head.path.slice(0, -1);
|
|
8296
|
-
const leaf =
|
|
8297
|
-
if (
|
|
8631
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, leafPath);
|
|
8632
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
8298
8633
|
const caret3 = sel.head.path[sel.head.path.length - 1];
|
|
8299
8634
|
const lineStart = leaf.text.lastIndexOf("\n", caret3 - 1) + 1;
|
|
8300
8635
|
const remove = unindentLen(leaf.text, lineStart);
|
|
@@ -8325,10 +8660,10 @@ var Editor = (_class11 = class {
|
|
|
8325
8660
|
e.preventDefault();
|
|
8326
8661
|
let rect = new DOMRect(0, 0, 0, 0);
|
|
8327
8662
|
try {
|
|
8328
|
-
const r = _optionalChain([document, 'access',
|
|
8663
|
+
const r = _optionalChain([document, 'access', _508 => _508.getSelection, 'call', _509 => _509(), 'optionalAccess', _510 => _510.getRangeAt, 'call', _511 => _511(0), 'optionalAccess', _512 => _512.getBoundingClientRect, 'call', _513 => _513()]);
|
|
8329
8664
|
if (r && (r.width || r.height))
|
|
8330
8665
|
rect = r;
|
|
8331
|
-
} catch (
|
|
8666
|
+
} catch (e11) {
|
|
8332
8667
|
}
|
|
8333
8668
|
void askLinkPopover({ anchor: rect }).then((url) => {
|
|
8334
8669
|
if (!url)
|
|
@@ -8341,15 +8676,15 @@ var Editor = (_class11 = class {
|
|
|
8341
8676
|
}
|
|
8342
8677
|
const cmd = mod2 ? this.resolved.keymap[chord(e)] : void 0;
|
|
8343
8678
|
if (cmd) {
|
|
8344
|
-
const r = cmd({ doc: this.history.doc, sel:
|
|
8679
|
+
const r = cmd({ doc: this.history.doc, sel: _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc), markSel: this.markSel(), promptLink: this.opts.promptLink });
|
|
8345
8680
|
if (!r)
|
|
8346
8681
|
return;
|
|
8347
8682
|
e.preventDefault();
|
|
8348
8683
|
if ("history" in r) {
|
|
8349
8684
|
this.pendingMarks = null;
|
|
8350
|
-
this.history = r.history === "undo" ?
|
|
8685
|
+
this.history = r.history === "undo" ? _chunkYXQDCW4Ycjs.undo.call(void 0, this.history) : _chunkYXQDCW4Ycjs.redo.call(void 0, this.history);
|
|
8351
8686
|
this.draw();
|
|
8352
|
-
_optionalChain([this, 'access',
|
|
8687
|
+
_optionalChain([this, 'access', _514 => _514.opts, 'access', _515 => _515.onChange, 'optionalCall', _516 => _516(this.history.doc)]);
|
|
8353
8688
|
return;
|
|
8354
8689
|
}
|
|
8355
8690
|
if ("pendingToggle" in r) {
|
|
@@ -8365,7 +8700,7 @@ var Editor = (_class11 = class {
|
|
|
8365
8700
|
return;
|
|
8366
8701
|
}
|
|
8367
8702
|
if (mod2 && !e.shiftKey && (e.key === "a" || e.key === "A")) {
|
|
8368
|
-
const sel =
|
|
8703
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8369
8704
|
if (!sel)
|
|
8370
8705
|
return;
|
|
8371
8706
|
const blockPath = sel.head.path.slice(0, -2);
|
|
@@ -8373,7 +8708,7 @@ var Editor = (_class11 = class {
|
|
|
8373
8708
|
return;
|
|
8374
8709
|
e.preventDefault();
|
|
8375
8710
|
const len = leafText2(this.history.doc, [...blockPath, 0]).length;
|
|
8376
|
-
|
|
8711
|
+
_chunkYIFOGP2Dcjs.writeSelection.call(void 0,
|
|
8377
8712
|
this.root,
|
|
8378
8713
|
this.history.doc,
|
|
8379
8714
|
{ anchor: { path: [...blockPath, 0, 0] }, head: { path: [...blockPath, 0, len] } }
|
|
@@ -8384,7 +8719,7 @@ var Editor = (_class11 = class {
|
|
|
8384
8719
|
// 代码块 model 是单纯文本叶,docToMd 只读首叶裸 text——加 mark 轻则渲幽灵 strong/save 后消失,
|
|
8385
8720
|
// 重则 toggleMark 把单叶按区间切成多叶,leaves(n)[0] 只取首叶 → 存盘丢码。marks 在代码块无语义,直接挡。
|
|
8386
8721
|
markSel() {
|
|
8387
|
-
const sel =
|
|
8722
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8388
8723
|
if (!sel)
|
|
8389
8724
|
return null;
|
|
8390
8725
|
if (this.isCodeBlock(sel.anchor.path.slice(0, -2)) || this.isCodeBlock(sel.head.path.slice(0, -2)))
|
|
@@ -8392,37 +8727,37 @@ var Editor = (_class11 = class {
|
|
|
8392
8727
|
return sel;
|
|
8393
8728
|
}
|
|
8394
8729
|
// 复制/剪切/粘贴:选区 ⟷ markdown。md 是 markloom 的唯一真值,剪贴板也走 md,跨编辑器/外部可读。
|
|
8395
|
-
|
|
8396
|
-
const sel =
|
|
8730
|
+
__init104() {this.onCopy = (e) => {
|
|
8731
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8397
8732
|
if (!sel)
|
|
8398
8733
|
return;
|
|
8399
8734
|
const md = serializeSelection(this.history.doc, sel);
|
|
8400
8735
|
if (!md)
|
|
8401
8736
|
return;
|
|
8402
8737
|
e.preventDefault();
|
|
8403
|
-
_optionalChain([e, 'access',
|
|
8738
|
+
_optionalChain([e, 'access', _517 => _517.clipboardData, 'optionalAccess', _518 => _518.setData, 'call', _519 => _519("text/plain", md)]);
|
|
8404
8739
|
}}
|
|
8405
|
-
|
|
8740
|
+
__init105() {this.onCut = (e) => {
|
|
8406
8741
|
if (this.readonly) {
|
|
8407
8742
|
e.preventDefault();
|
|
8408
8743
|
return;
|
|
8409
8744
|
}
|
|
8410
8745
|
e.preventDefault();
|
|
8411
|
-
const sel =
|
|
8746
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8412
8747
|
if (!sel)
|
|
8413
8748
|
return;
|
|
8414
8749
|
const md = serializeSelection(this.history.doc, sel);
|
|
8415
8750
|
if (!md)
|
|
8416
8751
|
return;
|
|
8417
|
-
_optionalChain([e, 'access',
|
|
8752
|
+
_optionalChain([e, 'access', _520 => _520.clipboardData, 'optionalAccess', _521 => _521.setData, 'call', _522 => _522("text/plain", md)]);
|
|
8418
8753
|
const del = mapInput(this.history.doc, "deleteForward", "", sel, newId3);
|
|
8419
8754
|
if (del)
|
|
8420
8755
|
this.dispatch(del.steps, del.selection);
|
|
8421
8756
|
}}
|
|
8422
|
-
|
|
8757
|
+
__init106() {this.onPaste = (e) => {
|
|
8423
8758
|
if (this.readonly || this.composing)
|
|
8424
8759
|
return;
|
|
8425
|
-
const sel =
|
|
8760
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8426
8761
|
if (!sel)
|
|
8427
8762
|
return;
|
|
8428
8763
|
const inCode = this.isCodeBlock(sel.head.path.slice(0, -2));
|
|
@@ -8433,15 +8768,15 @@ var Editor = (_class11 = class {
|
|
|
8433
8768
|
this.insertImageFile(file, sel);
|
|
8434
8769
|
return;
|
|
8435
8770
|
}
|
|
8436
|
-
const htmlUrl = imgSrcFromHtml(_optionalChain([e, 'access',
|
|
8437
|
-
if (htmlUrl && !_optionalChain([e, 'access',
|
|
8771
|
+
const htmlUrl = imgSrcFromHtml(_optionalChain([e, 'access', _523 => _523.clipboardData, 'optionalAccess', _524 => _524.getData, 'call', _525 => _525("text/html")]));
|
|
8772
|
+
if (htmlUrl && !_optionalChain([e, 'access', _526 => _526.clipboardData, 'optionalAccess', _527 => _527.getData, 'call', _528 => _528("text/plain")])) {
|
|
8438
8773
|
e.preventDefault();
|
|
8439
8774
|
this.insertImageUrl(htmlUrl, sel);
|
|
8440
8775
|
return;
|
|
8441
8776
|
}
|
|
8442
8777
|
}
|
|
8443
|
-
const raw = _nullishCoalesce(_optionalChain([e, 'access',
|
|
8444
|
-
const html = _nullishCoalesce(_optionalChain([e, 'access',
|
|
8778
|
+
const raw = _nullishCoalesce(_optionalChain([e, 'access', _529 => _529.clipboardData, 'optionalAccess', _530 => _530.getData, 'call', _531 => _531("text/plain")]), () => ( ""));
|
|
8779
|
+
const html = _nullishCoalesce(_optionalChain([e, 'access', _532 => _532.clipboardData, 'optionalAccess', _533 => _533.getData, 'call', _534 => _534("text/html")]), () => ( ""));
|
|
8445
8780
|
if (inCode) {
|
|
8446
8781
|
if (!raw && !html)
|
|
8447
8782
|
return;
|
|
@@ -8471,8 +8806,8 @@ var Editor = (_class11 = class {
|
|
|
8471
8806
|
}
|
|
8472
8807
|
}
|
|
8473
8808
|
if (html) {
|
|
8474
|
-
const blocks =
|
|
8475
|
-
if (blocks &&
|
|
8809
|
+
const blocks = _chunk4TMHVNL6cjs.htmlToBlocks.call(void 0, html);
|
|
8810
|
+
if (blocks && _chunk4TMHVNL6cjs.isRichHtmlBlocks.call(void 0, blocks)) {
|
|
8476
8811
|
e.preventDefault();
|
|
8477
8812
|
const result2 = mapPasteBlocks(this.history.doc, sel, blocks, newId3);
|
|
8478
8813
|
if (result2)
|
|
@@ -8508,12 +8843,12 @@ var Editor = (_class11 = class {
|
|
|
8508
8843
|
}
|
|
8509
8844
|
// 斜杠 /image:开原生文件选择,选中后把触发段(blockIdx,含 `/image`)整块替换成 image atom。
|
|
8510
8845
|
// 复用 onImage 上传钩子(未注入退回 data: URL)。取消选择 → 不动 model。
|
|
8511
|
-
|
|
8846
|
+
__init107() {this.slashInsertImage = (blockIdx) => {
|
|
8512
8847
|
const input = this.root.ownerDocument.createElement("input");
|
|
8513
8848
|
input.type = "file";
|
|
8514
8849
|
input.accept = "image/*";
|
|
8515
8850
|
input.onchange = () => {
|
|
8516
|
-
const file = _optionalChain([input, 'access',
|
|
8851
|
+
const file = _optionalChain([input, 'access', _535 => _535.files, 'optionalAccess', _536 => _536[0]]);
|
|
8517
8852
|
if (!file)
|
|
8518
8853
|
return;
|
|
8519
8854
|
const to = this.opts.onImage ? this.opts.onImage(file) : new Promise((resolve2, reject) => {
|
|
@@ -8531,7 +8866,7 @@ var Editor = (_class11 = class {
|
|
|
8531
8866
|
input.click();
|
|
8532
8867
|
}}
|
|
8533
8868
|
// 斜杠 /math → 当前段换成含 math atom 的段(display block)。
|
|
8534
|
-
|
|
8869
|
+
__init108() {this.slashInsertMath = (blockIdx) => {
|
|
8535
8870
|
void askInput({
|
|
8536
8871
|
title: "\u63D2\u5165\u516C\u5F0F",
|
|
8537
8872
|
description: "\u8F93\u5165 LaTeX\uFF0C\u4F8B\u5982 E=mc^2 \u6216 \\frac{a}{b}",
|
|
@@ -8549,13 +8884,13 @@ var Editor = (_class11 = class {
|
|
|
8549
8884
|
});
|
|
8550
8885
|
}}
|
|
8551
8886
|
// 斜杠 /youtube|/twitch|/audio|/file → embed 块。file/audio 走文件选择;yt/twitch 弹 URL。
|
|
8552
|
-
|
|
8887
|
+
__init109() {this.slashInsertEmbed = (blockIdx, kind) => {
|
|
8553
8888
|
if (kind === "file" || kind === "audio") {
|
|
8554
8889
|
const input = this.root.ownerDocument.createElement("input");
|
|
8555
8890
|
input.type = "file";
|
|
8556
8891
|
input.accept = kind === "audio" ? "audio/*" : "*/*";
|
|
8557
8892
|
input.onchange = () => {
|
|
8558
|
-
const file = _optionalChain([input, 'access',
|
|
8893
|
+
const file = _optionalChain([input, 'access', _537 => _537.files, 'optionalAccess', _538 => _538[0]]);
|
|
8559
8894
|
if (!file)
|
|
8560
8895
|
return;
|
|
8561
8896
|
const to = this.opts.onImage ? this.opts.onImage(file) : new Promise((resolve2, reject) => {
|
|
@@ -8603,23 +8938,23 @@ var Editor = (_class11 = class {
|
|
|
8603
8938
|
// 点 math atom → 弹层改 latex。叶路径:块 data-block-id + data-leaf 下标。
|
|
8604
8939
|
editMathAtom(mathEl) {
|
|
8605
8940
|
const blockEl = mathEl.closest("[data-block-id]");
|
|
8606
|
-
const id = _optionalChain([blockEl, 'optionalAccess',
|
|
8941
|
+
const id = _optionalChain([blockEl, 'optionalAccess', _539 => _539.getAttribute, 'call', _540 => _540("data-block-id")]);
|
|
8607
8942
|
if (!id)
|
|
8608
8943
|
return;
|
|
8609
|
-
const blockPath =
|
|
8944
|
+
const blockPath = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id);
|
|
8610
8945
|
if (!blockPath)
|
|
8611
8946
|
return;
|
|
8612
|
-
const block =
|
|
8613
|
-
if (
|
|
8947
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8948
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block)
|
|
8614
8949
|
return;
|
|
8615
8950
|
const leafKey = mathEl.getAttribute("data-leaf");
|
|
8616
8951
|
const leafIdx = leafKey != null && leafKey !== "" ? Number(leafKey) : -1;
|
|
8617
8952
|
if (leafIdx < 0 || leafIdx >= block.children.length)
|
|
8618
8953
|
return;
|
|
8619
8954
|
const atom = block.children[leafIdx];
|
|
8620
|
-
if (
|
|
8955
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "math")
|
|
8621
8956
|
return;
|
|
8622
|
-
const cur = String(_nullishCoalesce(_optionalChain([atom, 'access',
|
|
8957
|
+
const cur = String(_nullishCoalesce(_optionalChain([atom, 'access', _541 => _541.attrs, 'optionalAccess', _542 => _542.latex]), () => ( "")));
|
|
8623
8958
|
void askInput({
|
|
8624
8959
|
title: "\u7F16\u8F91\u516C\u5F0F",
|
|
8625
8960
|
description: "\u4FEE\u6539 LaTeX \u6E90\u7801",
|
|
@@ -8630,11 +8965,11 @@ var Editor = (_class11 = class {
|
|
|
8630
8965
|
}).then((next) => {
|
|
8631
8966
|
if (next == null || next.trim() === cur)
|
|
8632
8967
|
return;
|
|
8633
|
-
const b =
|
|
8634
|
-
if (
|
|
8968
|
+
const b = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8969
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, b) || !b || leafIdx >= b.children.length)
|
|
8635
8970
|
return;
|
|
8636
8971
|
const a = b.children[leafIdx];
|
|
8637
|
-
if (
|
|
8972
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, a) || a.type !== "math")
|
|
8638
8973
|
return;
|
|
8639
8974
|
const children = b.children.slice();
|
|
8640
8975
|
children[leafIdx] = { ...a, attrs: { ...a.attrs, latex: next.trim() } };
|
|
@@ -8646,13 +8981,13 @@ var Editor = (_class11 = class {
|
|
|
8646
8981
|
if (sel.anchor.path[0] !== sel.head.path[0] || sel.head.path.length !== 3)
|
|
8647
8982
|
return false;
|
|
8648
8983
|
const b = this.history.doc.children[sel.head.path[0]];
|
|
8649
|
-
if (!b ||
|
|
8984
|
+
if (!b || _chunkGQ2HHRGIcjs.isText.call(void 0, b) || b.type !== "paragraph")
|
|
8650
8985
|
return false;
|
|
8651
|
-
return b.children.length === 1 &&
|
|
8986
|
+
return b.children.length === 1 && _chunkGQ2HHRGIcjs.isText.call(void 0, b.children[0]) && b.children[0].text === "";
|
|
8652
8987
|
}
|
|
8653
8988
|
// floating menu(+ 柄):在 blockIdx 下方插一个只含 `/` 的空段,光标落 `/` 之后,派 input 事件唤起斜杠菜单。
|
|
8654
8989
|
// 复用 SlashMenu 的 onInput 触发路径(菜单只认「行首 `/`」),FloatingMenu 不需自己造菜单——+ 只是「打 /」的快捷。
|
|
8655
|
-
|
|
8990
|
+
__init110() {this.insertBelow = (blockIdx) => {
|
|
8656
8991
|
if (this.readonly)
|
|
8657
8992
|
return;
|
|
8658
8993
|
const id = newId3();
|
|
@@ -8678,37 +9013,37 @@ var Editor = (_class11 = class {
|
|
|
8678
9013
|
isAtomBlock(blockPath) {
|
|
8679
9014
|
if (blockPath.length === 0)
|
|
8680
9015
|
return false;
|
|
8681
|
-
return isAtom(
|
|
9016
|
+
return isAtom(_chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath));
|
|
8682
9017
|
}
|
|
8683
9018
|
// 找到 head 路径上的 table 祖先 → 当前 (r,c) → nextCell → 把光标写到目标格首段首叶。
|
|
8684
9019
|
// caret 落在哪个表格的哪一格。沿 head 找第一个 type==='table' 祖先块 → {tablePath, table, r, c}。
|
|
8685
9020
|
tableCaret() {
|
|
8686
|
-
const sel =
|
|
9021
|
+
const sel = _chunkYIFOGP2Dcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8687
9022
|
if (!sel)
|
|
8688
9023
|
return null;
|
|
8689
9024
|
const head = sel.head.path;
|
|
8690
9025
|
let node = this.history.doc;
|
|
8691
9026
|
const tablePath = [];
|
|
8692
9027
|
for (let i = 0; i < head.length; i++) {
|
|
8693
|
-
if (
|
|
9028
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node) || !node.children[head[i]])
|
|
8694
9029
|
break;
|
|
8695
|
-
if (!
|
|
9030
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, node) && node.type === "table")
|
|
8696
9031
|
break;
|
|
8697
9032
|
tablePath.push(head[i]);
|
|
8698
9033
|
node = node.children[head[i]];
|
|
8699
9034
|
}
|
|
8700
|
-
const table =
|
|
8701
|
-
if (
|
|
9035
|
+
const table = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, tablePath);
|
|
9036
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, table) || table.type !== "table")
|
|
8702
9037
|
return null;
|
|
8703
|
-
const cur =
|
|
9038
|
+
const cur = _chunk4TMHVNL6cjs.caretCell.call(void 0, tablePath, table, head);
|
|
8704
9039
|
return cur ? { tablePath, table, r: cur.r, c: cur.c, head } : null;
|
|
8705
9040
|
}
|
|
8706
9041
|
tabInTable(dir) {
|
|
8707
9042
|
const loc = this.tableCaret();
|
|
8708
9043
|
if (!loc)
|
|
8709
9044
|
return false;
|
|
8710
|
-
const to =
|
|
8711
|
-
const at = { path:
|
|
9045
|
+
const to = _chunk4TMHVNL6cjs.nextCell.call(void 0, loc.table, loc.r, loc.c, dir);
|
|
9046
|
+
const at = { path: _chunk4TMHVNL6cjs.cellCaret.call(void 0, loc.tablePath, loc.table, to.r, to.c, 0) };
|
|
8712
9047
|
this.draw({ anchor: at, head: at });
|
|
8713
9048
|
return true;
|
|
8714
9049
|
}
|
|
@@ -8720,42 +9055,42 @@ var Editor = (_class11 = class {
|
|
|
8720
9055
|
return false;
|
|
8721
9056
|
if (dir === "left" || dir === "right") {
|
|
8722
9057
|
const off2 = loc.head[loc.head.length - 1];
|
|
8723
|
-
const leaf =
|
|
8724
|
-
const len =
|
|
9058
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, loc.head.slice(0, -1));
|
|
9059
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0;
|
|
8725
9060
|
if (dir === "left" ? off2 > 0 : off2 < len)
|
|
8726
9061
|
return false;
|
|
8727
9062
|
}
|
|
8728
|
-
const to =
|
|
9063
|
+
const to = _chunk4TMHVNL6cjs.arrowCell.call(void 0, loc.table, loc.r, loc.c, dir);
|
|
8729
9064
|
if (!to)
|
|
8730
9065
|
return false;
|
|
8731
|
-
const grid =
|
|
9066
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, loc.table);
|
|
8732
9067
|
const idx = grid.at(to.r, to.c);
|
|
8733
9068
|
const cellNode = loc.table.children[idx];
|
|
8734
9069
|
let off = 0;
|
|
8735
9070
|
if (dir === "left" && cellNode) {
|
|
8736
9071
|
const para = cellNode.children[0];
|
|
8737
|
-
const lf = para && !
|
|
8738
|
-
off = lf &&
|
|
9072
|
+
const lf = para && !_chunkGQ2HHRGIcjs.isText.call(void 0, para) ? para.children[0] : void 0;
|
|
9073
|
+
off = lf && _chunkGQ2HHRGIcjs.isText.call(void 0, lf) ? lf.text.length : 0;
|
|
8739
9074
|
}
|
|
8740
|
-
const at = { path:
|
|
9075
|
+
const at = { path: _chunk4TMHVNL6cjs.cellCaret.call(void 0, loc.tablePath, loc.table, to.r, to.c, off) };
|
|
8741
9076
|
this.draw({ anchor: at, head: at });
|
|
8742
9077
|
return true;
|
|
8743
9078
|
}
|
|
8744
9079
|
// 飞书式行列高亮:焦点落入某 cell → 同行同列所有 cell 加标记属性(主题给浅色背景)。
|
|
8745
9080
|
// 纯 DOM 投影,不碰 model:语义表格里 td 嵌在 tbody>tr 下,用后代选择器收(文档序即行优先);
|
|
8746
9081
|
// 列数从 tr 的 cell 数读(每行等列)。同表换格时 focusout 先清 focusin 再标,同帧内同步完成不闪。
|
|
8747
|
-
|
|
9082
|
+
__init111() {this.onFocusIn = (e) => {
|
|
8748
9083
|
if (!(e.target instanceof HTMLElement))
|
|
8749
9084
|
return;
|
|
8750
9085
|
const cell = e.target.closest(".markloom-cell");
|
|
8751
|
-
const table = _optionalChain([cell, 'optionalAccess',
|
|
9086
|
+
const table = _optionalChain([cell, 'optionalAccess', _543 => _543.closest, 'call', _544 => _544(".markloom-table")]);
|
|
8752
9087
|
if (!cell || !table)
|
|
8753
9088
|
return;
|
|
8754
9089
|
const id = table.getAttribute("data-block-id");
|
|
8755
|
-
const model = id ?
|
|
8756
|
-
if (!model ||
|
|
9090
|
+
const model = id ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, _nullishCoalesce(_chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id), () => ( []))) : null;
|
|
9091
|
+
if (!model || _chunkGQ2HHRGIcjs.isText.call(void 0, model) || model.type !== "table")
|
|
8757
9092
|
return;
|
|
8758
|
-
const grid =
|
|
9093
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, model);
|
|
8759
9094
|
const cells = Array.from(table.querySelectorAll(".markloom-cell"));
|
|
8760
9095
|
if (cells.length !== grid.anchors.length)
|
|
8761
9096
|
return;
|
|
@@ -8769,10 +9104,10 @@ var Editor = (_class11 = class {
|
|
|
8769
9104
|
el.toggleAttribute("data-highlight-col", sameCol);
|
|
8770
9105
|
});
|
|
8771
9106
|
}}
|
|
8772
|
-
|
|
9107
|
+
__init112() {this.onFocusOut = (e) => {
|
|
8773
9108
|
if (!(e.target instanceof HTMLElement))
|
|
8774
9109
|
return;
|
|
8775
|
-
const table = _optionalChain([e, 'access',
|
|
9110
|
+
const table = _optionalChain([e, 'access', _545 => _545.target, 'access', _546 => _546.closest, 'call', _547 => _547(".markloom-cell"), 'optionalAccess', _548 => _548.closest, 'call', _549 => _549(".markloom-table")]);
|
|
8776
9111
|
if (!table)
|
|
8777
9112
|
return;
|
|
8778
9113
|
table.querySelectorAll(".markloom-cell").forEach((el) => {
|
|
@@ -8780,7 +9115,7 @@ var Editor = (_class11 = class {
|
|
|
8780
9115
|
el.removeAttribute("data-highlight-col");
|
|
8781
9116
|
});
|
|
8782
9117
|
}}
|
|
8783
|
-
},
|
|
9118
|
+
}, _class12);
|
|
8784
9119
|
function chord(e) {
|
|
8785
9120
|
const key = e.key.length === 1 ? e.key.toLowerCase() : e.key;
|
|
8786
9121
|
return `Mod-${e.shiftKey ? "Shift-" : ""}${key}`;
|
|
@@ -8810,12 +9145,12 @@ function intentOf(inputType) {
|
|
|
8810
9145
|
}
|
|
8811
9146
|
}
|
|
8812
9147
|
function newId3() {
|
|
8813
|
-
return _nullishCoalesce(_optionalChain([globalThis, 'access',
|
|
9148
|
+
return _nullishCoalesce(_optionalChain([globalThis, 'access', _550 => _550.crypto, 'optionalAccess', _551 => _551.randomUUID, 'optionalCall', _552 => _552()]), () => ( `b-${Math.random().toString(36).slice(2)}`));
|
|
8814
9149
|
}
|
|
8815
9150
|
function pathOfTaskItem(doc, root, li) {
|
|
8816
9151
|
const id = li.getAttribute("data-block-id");
|
|
8817
9152
|
if (id) {
|
|
8818
|
-
const p =
|
|
9153
|
+
const p = _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, id);
|
|
8819
9154
|
if (p)
|
|
8820
9155
|
return p;
|
|
8821
9156
|
}
|
|
@@ -8823,13 +9158,13 @@ function pathOfTaskItem(doc, root, li) {
|
|
|
8823
9158
|
if (!listEl)
|
|
8824
9159
|
return null;
|
|
8825
9160
|
const listId = listEl.getAttribute("data-block-id");
|
|
8826
|
-
const listPath = listId ?
|
|
9161
|
+
const listPath = listId ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, listId) : null;
|
|
8827
9162
|
if (!listPath)
|
|
8828
9163
|
return null;
|
|
8829
|
-
const list =
|
|
8830
|
-
if (!list ||
|
|
9164
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
9165
|
+
if (!list || _chunkGQ2HHRGIcjs.isText.call(void 0, list) || list.type !== "list")
|
|
8831
9166
|
return null;
|
|
8832
|
-
const items =
|
|
9167
|
+
const items = _chunkYIFOGP2Dcjs.elementChildren.call(void 0, listEl);
|
|
8833
9168
|
const idx = items.indexOf(li);
|
|
8834
9169
|
if (idx < 0 || idx >= list.children.length)
|
|
8835
9170
|
return null;
|
|
@@ -8904,7 +9239,7 @@ function imgSrcFromHtml(html) {
|
|
|
8904
9239
|
return null;
|
|
8905
9240
|
const body = new DOMParser().parseFromString(html, "text/html").body;
|
|
8906
9241
|
const imgs = body.querySelectorAll("img");
|
|
8907
|
-
if (imgs.length !== 1 || _optionalChain([body, 'access',
|
|
9242
|
+
if (imgs.length !== 1 || _optionalChain([body, 'access', _553 => _553.textContent, 'optionalAccess', _554 => _554.trim, 'call', _555 => _555()]))
|
|
8908
9243
|
return null;
|
|
8909
9244
|
return imgs[0].getAttribute("src");
|
|
8910
9245
|
}
|