markloom 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/ai.md +160 -0
- package/collab.md +68 -0
- package/dist/ai/index.cjs +4 -3
- package/dist/ai/index.d.cts +4 -2
- package/dist/ai/index.d.ts +4 -2
- package/dist/ai/index.js +3 -2
- package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
- package/dist/chunk-6DCI7AL3.js +208 -0
- package/dist/chunk-AC5E42NH.cjs +208 -0
- package/dist/chunk-GQ2HHRGI.cjs +16 -0
- package/dist/{chunk-QXJHFQLJ.js → chunk-JMOJU5EU.js} +4 -2
- 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-LNSKDJMF.cjs → chunk-SLRD6FMP.cjs} +27 -25
- package/dist/{chunk-VMUJM52A.js → chunk-WUHTCCAE.js} +65 -6
- package/dist/{chunk-VSTOMEU2.cjs → chunk-YJAWPRJW.cjs} +400 -341
- package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
- package/dist/client-A0ZQJnyR.d.ts +137 -0
- package/dist/client-BNams4wv.d.cts +137 -0
- package/dist/collab/index.cjs +19 -0
- package/dist/collab/index.d.cts +3 -0
- package/dist/collab/index.d.ts +3 -0
- package/dist/collab/index.js +19 -0
- package/dist/comments-DlExS6f-.d.cts +43 -0
- package/dist/comments-PhnR7Gkn.d.ts +43 -0
- package/dist/{controller-B_wG2Wh-.d.ts → controller-BkY1VPzc.d.ts} +17 -1
- package/dist/{controller-Cd1Dprrk.d.cts → controller-CVIZI--A.d.cts} +17 -1
- 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/package.json +10 -3
- package/dist/comments-USjT1wYN.d.cts +0 -105
- package/dist/comments-USjT1wYN.d.ts +0 -105
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ var _chunkHA6XHJUDcjs = require('./chunk-HA6XHJUD.cjs');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkSLRD6FMPcjs = require('./chunk-SLRD6FMP.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -53,10 +53,15 @@ var _chunkLNSKDJMFcjs = require('./chunk-LNSKDJMF.cjs');
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
|
|
56
57
|
|
|
57
58
|
|
|
59
|
+
var _chunkAC5E42NHcjs = require('./chunk-AC5E42NH.cjs');
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
|
|
60
65
|
|
|
61
66
|
// src/view/render.ts
|
|
62
67
|
var _preact = require('preact');
|
|
@@ -518,7 +523,7 @@ function twitchChannel(url) {
|
|
|
518
523
|
}
|
|
519
524
|
}
|
|
520
525
|
function leafText(spec) {
|
|
521
|
-
return spec.children.map((c) =>
|
|
526
|
+
return spec.children.map((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text : _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c) ? "" : leafText(c)).join("");
|
|
522
527
|
}
|
|
523
528
|
function aiBtn(act, label, cls, extra) {
|
|
524
529
|
return _preact.h.call(void 0, "button", {
|
|
@@ -586,7 +591,7 @@ function renderAiBlock(spec, tag, props, opts) {
|
|
|
586
591
|
return vn;
|
|
587
592
|
const p = vn.props;
|
|
588
593
|
p.class = [p.class, "markloom-ai-prompt"].filter(Boolean).join(" ");
|
|
589
|
-
if (i === 0 && !
|
|
594
|
+
if (i === 0 && !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "paragraph" && leafText(c) === "") {
|
|
590
595
|
p["data-placeholder"] = mode === "rewrite" ? "\u63CF\u8FF0\u600E\u4E48\u6539\u2026\uFF08\u56DE\u8F66\u751F\u6210\uFF09" : "\u8F93\u5165\u6307\u4EE4\uFF0C\u56DE\u8F66\u751F\u6210\u2026";
|
|
591
596
|
}
|
|
592
597
|
return vn;
|
|
@@ -658,9 +663,9 @@ function blockCtx(opts) {
|
|
|
658
663
|
};
|
|
659
664
|
}
|
|
660
665
|
function renderNode(node, key, opts) {
|
|
661
|
-
if (
|
|
666
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
662
667
|
return renderText(node, key, opts);
|
|
663
|
-
if (
|
|
668
|
+
if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, node))
|
|
664
669
|
return renderInlineAtom(node, key, opts);
|
|
665
670
|
const spec = node;
|
|
666
671
|
const renderer = opts.blockRenderers[spec.type];
|
|
@@ -743,7 +748,7 @@ function renderCode(spec, key, ctx) {
|
|
|
743
748
|
}
|
|
744
749
|
function renderTable(spec, key, ctx) {
|
|
745
750
|
const align = Array.isArray(_optionalChain([spec, 'access', _46 => _46.attrs, 'optionalAccess', _47 => _47.align])) ? spec.attrs.align : null;
|
|
746
|
-
const grid =
|
|
751
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, spec);
|
|
747
752
|
const freezeRows = Number(_nullishCoalesce(_optionalChain([spec, 'access', _48 => _48.attrs, 'optionalAccess', _49 => _49.freezeRows]), () => ( 0)));
|
|
748
753
|
const freezeCols = Number(_nullishCoalesce(_optionalChain([spec, 'access', _50 => _50.attrs, 'optionalAccess', _51 => _51.freezeCols]), () => ( 0)));
|
|
749
754
|
const cell = (cellNode, idx, tag) => {
|
|
@@ -783,7 +788,7 @@ function renderTable(spec, key, ctx) {
|
|
|
783
788
|
for (const r of Array.from(bodyRowsMap.keys()).sort((a, b) => a - b))
|
|
784
789
|
bodyRows.push(_preact.h.call(void 0, "tr", { key: r }, bodyRowsMap.get(r)));
|
|
785
790
|
const body = _preact.h.call(void 0, "tbody", { key: "tb" }, bodyRows);
|
|
786
|
-
const widths =
|
|
791
|
+
const widths = _chunk4TMHVNL6cjs.tableColWidths.call(void 0, spec);
|
|
787
792
|
const children = widths ? [_preact.h.call(void 0, "colgroup", { key: "cg" }, widths.map((w, i) => _preact.h.call(void 0, "col", { key: i, style: `width:${w}px` }))), head, body] : [head, body];
|
|
788
793
|
const table = _preact.h.call(void 0, "table", {
|
|
789
794
|
"key": _nullishCoalesce(spec.id, () => ( key)),
|
|
@@ -822,9 +827,9 @@ function renderDoc(doc, opts = {}) {
|
|
|
822
827
|
atomSelect: opts.atomSelect
|
|
823
828
|
};
|
|
824
829
|
const first = doc.children[0];
|
|
825
|
-
const emptyLeaf = (n) => leafText(n) === "" && n.children.every((c) =>
|
|
830
|
+
const emptyLeaf = (n) => leafText(n) === "" && n.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
826
831
|
let emptyDocPh;
|
|
827
|
-
if (doc.children.length === 1 && first && !
|
|
832
|
+
if (doc.children.length === 1 && first && !_chunkGQ2HHRGIcjs.isText.call(void 0, first) && emptyLeaf(first)) {
|
|
828
833
|
if (first.type === "paragraph" && opts.placeholder)
|
|
829
834
|
emptyDocPh = opts.placeholder;
|
|
830
835
|
else if (first.type === "heading")
|
|
@@ -833,7 +838,7 @@ function renderDoc(doc, opts = {}) {
|
|
|
833
838
|
let foldDepth = null;
|
|
834
839
|
const kids = doc.children.map((c, i) => {
|
|
835
840
|
let foldHidden = false;
|
|
836
|
-
if (!
|
|
841
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "heading") {
|
|
837
842
|
const depth = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([c, 'access', _65 => _65.attrs, 'optionalAccess', _66 => _66.depth]), () => ( 2))), 1), 6);
|
|
838
843
|
if (foldDepth != null && depth <= foldDepth)
|
|
839
844
|
foldDepth = null;
|
|
@@ -873,8 +878,8 @@ function sameLeaf(a, b) {
|
|
|
873
878
|
return a.length === b.length && a.slice(0, -1).every((s, i) => s === b[i]);
|
|
874
879
|
}
|
|
875
880
|
function leafText2(doc, leafPath) {
|
|
876
|
-
const leaf =
|
|
877
|
-
return
|
|
881
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, leafPath);
|
|
882
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
878
883
|
}
|
|
879
884
|
function catOf(cp) {
|
|
880
885
|
if (cp === 32 || cp === 9 || cp === 10 || cp === 12 || cp === 13 || cp === 160)
|
|
@@ -930,8 +935,8 @@ function lineBoundaryFwd(text, offset3) {
|
|
|
930
935
|
function inTableCell(doc, blockPath) {
|
|
931
936
|
if (blockPath.length < 2)
|
|
932
937
|
return false;
|
|
933
|
-
const parent =
|
|
934
|
-
return !
|
|
938
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath.slice(0, -1));
|
|
939
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, parent) && parent.type === "table_cell";
|
|
935
940
|
}
|
|
936
941
|
function cmpPath(a, b) {
|
|
937
942
|
const n = Math.min(a.length, b.length);
|
|
@@ -949,7 +954,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
949
954
|
return { steps: [{ kind: "deleteText", path: a.leafPath, offset: a.char, length: b.char - a.char }], caret: lo };
|
|
950
955
|
const sameBlock = a.blockPath.length === b.blockPath.length && a.blockPath.every((s, i) => s === b.blockPath[i]);
|
|
951
956
|
if (sameBlock) {
|
|
952
|
-
const block =
|
|
957
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
953
958
|
const head2 = block.children.slice(0, a.leafIdx);
|
|
954
959
|
const fromLeaf = trimTail(block.children[a.leafIdx], a.char);
|
|
955
960
|
const toLeaf = trimHead(block.children[b.leafIdx], b.char);
|
|
@@ -971,7 +976,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
971
976
|
const loCell = loRel[0];
|
|
972
977
|
const hiCell = hiRel[0];
|
|
973
978
|
const children = fromTop.children.map((cell, i) => {
|
|
974
|
-
if (i < loCell || i > hiCell ||
|
|
979
|
+
if (i < loCell || i > hiCell || _chunkGQ2HHRGIcjs.isText.call(void 0, cell))
|
|
975
980
|
return cell;
|
|
976
981
|
if (i === loCell)
|
|
977
982
|
return keepBefore(cell, loRel.slice(1));
|
|
@@ -1003,7 +1008,7 @@ function deleteRange(doc, p1, p2) {
|
|
|
1003
1008
|
insert.push(prunedHead);
|
|
1004
1009
|
if (prunedTail !== null && !isEmptyBlock(tail))
|
|
1005
1010
|
insert.push(prunedTail);
|
|
1006
|
-
caret3 = headLives ? lo : insert.length ? [loTop, ...
|
|
1011
|
+
caret3 = headLives ? lo : insert.length ? [loTop, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, insert[0]), 0] : [loTop, 0, 0];
|
|
1007
1012
|
}
|
|
1008
1013
|
return {
|
|
1009
1014
|
steps: [{ kind: "spliceChildren", path: [], at: loTop, remove: hiTop - loTop + 1, insert }],
|
|
@@ -1011,11 +1016,11 @@ function deleteRange(doc, p1, p2) {
|
|
|
1011
1016
|
};
|
|
1012
1017
|
}
|
|
1013
1018
|
function isEmptyBlock(block) {
|
|
1014
|
-
const text = (n) =>
|
|
1019
|
+
const text = (n) => _chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n.text : n.children.map(text).join("");
|
|
1015
1020
|
return text(block) === "";
|
|
1016
1021
|
}
|
|
1017
1022
|
function pruneEmpty(node) {
|
|
1018
|
-
if (
|
|
1023
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
1019
1024
|
return node;
|
|
1020
1025
|
const kids = node.children.map(pruneEmpty).filter((n) => n !== null);
|
|
1021
1026
|
if ((node.type === "list" || node.type === "list_item" || node.type === "quote") && kids.length === 0)
|
|
@@ -1024,7 +1029,7 @@ function pruneEmpty(node) {
|
|
|
1024
1029
|
}
|
|
1025
1030
|
function pruneBlock(node) {
|
|
1026
1031
|
const p = pruneEmpty(node);
|
|
1027
|
-
return p && !
|
|
1032
|
+
return p && !_chunkGQ2HHRGIcjs.isText.call(void 0, p) ? p : { type: "paragraph", id: node.id, children: [{ text: "" }] };
|
|
1028
1033
|
}
|
|
1029
1034
|
function keepBefore(node, rel) {
|
|
1030
1035
|
const idx = rel[0];
|
|
@@ -1066,16 +1071,16 @@ function appendLeavesAt(node, parentRel, leaves) {
|
|
|
1066
1071
|
return { ...node, children };
|
|
1067
1072
|
}
|
|
1068
1073
|
function trimTail(leaf, at) {
|
|
1069
|
-
return
|
|
1074
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(0, at) } : leaf;
|
|
1070
1075
|
}
|
|
1071
1076
|
function trimHead(leaf, at) {
|
|
1072
|
-
return
|
|
1077
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(at) } : leaf;
|
|
1073
1078
|
}
|
|
1074
1079
|
function isAtom(block) {
|
|
1075
|
-
return !
|
|
1080
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, block) && (block.type === "code" || block.type === "table" || block.type === "image" || block.type === "embed");
|
|
1076
1081
|
}
|
|
1077
1082
|
function isOpaque(block) {
|
|
1078
|
-
if (
|
|
1083
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
1079
1084
|
return false;
|
|
1080
1085
|
if (block.type === "table" || block.type === "image" || block.type === "embed")
|
|
1081
1086
|
return true;
|
|
@@ -1092,7 +1097,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1092
1097
|
const collapsed = from === to;
|
|
1093
1098
|
const parentPath = blockPath.slice(0, -1);
|
|
1094
1099
|
const blockIdx = blockPath[blockPath.length - 1];
|
|
1095
|
-
const block =
|
|
1100
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath);
|
|
1096
1101
|
if (intent === "insertLineBreak") {
|
|
1097
1102
|
if (block.type === "code" || block.type === "raw")
|
|
1098
1103
|
return mapInput(doc, "insertText", "\n", sel, newId4, rules, pendingMarks);
|
|
@@ -1104,7 +1109,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1104
1109
|
return null;
|
|
1105
1110
|
if (collapsed && rules.length) {
|
|
1106
1111
|
const leaf = block.children[leafIdx];
|
|
1107
|
-
const leafText3 =
|
|
1112
|
+
const leafText3 = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
1108
1113
|
const ctx = { doc, block, blockPath, parentPath, leafPath, leafIdx, leafText: leafText3, offset: from, marker: leafText3.slice(0, from), trigger: data, rest: leafText3.slice(from), newId: newId4 };
|
|
1109
1114
|
for (const rule of rules) {
|
|
1110
1115
|
const hit = rule.match(ctx);
|
|
@@ -1124,18 +1129,18 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1124
1129
|
}
|
|
1125
1130
|
case "insertParagraph": {
|
|
1126
1131
|
{
|
|
1127
|
-
const aiParent = parentPath.length ?
|
|
1132
|
+
const aiParent = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1128
1133
|
if (aiParent && aiParent.type === "ai")
|
|
1129
1134
|
return null;
|
|
1130
1135
|
}
|
|
1131
1136
|
if (block.type === "code") {
|
|
1132
1137
|
const codeLeaf = block.children[leafIdx];
|
|
1133
|
-
const codeText =
|
|
1138
|
+
const codeText = _chunkGQ2HHRGIcjs.isText.call(void 0, codeLeaf) ? codeLeaf.text : "";
|
|
1134
1139
|
if (collapsed && from === codeText.length && codeText.endsWith("\n")) {
|
|
1135
1140
|
const trimmed = codeText.slice(0, -1);
|
|
1136
1141
|
const kept = {
|
|
1137
1142
|
...block,
|
|
1138
|
-
children: [{ ...
|
|
1143
|
+
children: [{ ..._chunkGQ2HHRGIcjs.isText.call(void 0, codeLeaf) ? codeLeaf : { text: "" }, text: trimmed }]
|
|
1139
1144
|
};
|
|
1140
1145
|
const after = { type: "paragraph", id: newId4(), children: [{ text: "" }] };
|
|
1141
1146
|
return {
|
|
@@ -1152,22 +1157,22 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1152
1157
|
};
|
|
1153
1158
|
}
|
|
1154
1159
|
const splitLeaf = block.children[leafIdx];
|
|
1155
|
-
const splitText =
|
|
1160
|
+
const splitText = _chunkGQ2HHRGIcjs.isText.call(void 0, splitLeaf) ? splitLeaf.text : "";
|
|
1156
1161
|
const keepChildren = [...block.children.slice(0, leafIdx), { ...splitLeaf, text: splitText.slice(0, from) }];
|
|
1157
1162
|
const freshChildren = [{ ...splitLeaf, text: splitText.slice(to) }, ...block.children.slice(leafIdx + 1)];
|
|
1158
1163
|
const keep = { ...block, children: keepChildren };
|
|
1159
1164
|
const fresh = { type: "paragraph", id: newId4(), children: freshChildren };
|
|
1160
|
-
const itemNode = parentPath.length ?
|
|
1165
|
+
const itemNode = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1161
1166
|
if (itemNode && itemNode.type === "list_item") {
|
|
1162
1167
|
const itemIdx = parentPath[parentPath.length - 1];
|
|
1163
1168
|
const listPath = parentPath.slice(0, -1);
|
|
1164
|
-
const isLastItem = itemIdx ===
|
|
1169
|
+
const isLastItem = itemIdx === _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath).children.length - 1;
|
|
1165
1170
|
if (itemNode.children.length === 1 && isEmptyBlock(itemNode) && isLastItem) {
|
|
1166
1171
|
const listParentPath = listPath.slice(0, -1);
|
|
1167
|
-
const listParent =
|
|
1172
|
+
const listParent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listParentPath);
|
|
1168
1173
|
if (listParent.type === "list_item")
|
|
1169
1174
|
return outdentItem(doc, sel, newId4);
|
|
1170
|
-
const list =
|
|
1175
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
1171
1176
|
const before = list.children.slice(0, itemIdx);
|
|
1172
1177
|
const after = list.children.slice(itemIdx + 1);
|
|
1173
1178
|
const lifted = { type: "paragraph", id: itemNode.id, children: [{ text: "" }] };
|
|
@@ -1222,7 +1227,7 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1222
1227
|
if (from > 0)
|
|
1223
1228
|
return { steps: [{ kind: "deleteText", path: leafPath, offset: from - 1, length: 1 }], selection: caret(leafPath.concat(from - 1)) };
|
|
1224
1229
|
{
|
|
1225
|
-
const aiParent = parentPath.length ?
|
|
1230
|
+
const aiParent = parentPath.length ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath) : null;
|
|
1226
1231
|
if (aiParent && aiParent.type === "ai" && isEmptyBlock(block) && leafIdx === 0) {
|
|
1227
1232
|
const node = { type: "paragraph", id: aiParent.id, children: [{ text: "" }] };
|
|
1228
1233
|
return {
|
|
@@ -1232,9 +1237,9 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1232
1237
|
}
|
|
1233
1238
|
}
|
|
1234
1239
|
const prevInBlock = block.children[leafIdx - 1];
|
|
1235
|
-
if (leafIdx > 0 && prevInBlock &&
|
|
1240
|
+
if (leafIdx > 0 && prevInBlock && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, prevInBlock)) {
|
|
1236
1241
|
const before = block.children[leafIdx - 2];
|
|
1237
|
-
const landing = before &&
|
|
1242
|
+
const landing = before && _chunkGQ2HHRGIcjs.isText.call(void 0, before) ? [...blockPath, leafIdx - 2, before.text.length] : [...blockPath, leafIdx - 1, 0];
|
|
1238
1243
|
return { steps: [{ kind: "spliceChildren", path: blockPath, at: leafIdx - 1, remove: 1, insert: [] }], selection: caret(landing) };
|
|
1239
1244
|
}
|
|
1240
1245
|
if (blockIdx <= 0) {
|
|
@@ -1244,10 +1249,10 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1244
1249
|
const idx = cp[cp.length - 1];
|
|
1245
1250
|
if (idx < 1)
|
|
1246
1251
|
continue;
|
|
1247
|
-
const prevSib =
|
|
1248
|
-
if (
|
|
1252
|
+
const prevSib = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, cp.slice(0, -1)).children[idx - 1];
|
|
1253
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, prevSib))
|
|
1249
1254
|
break;
|
|
1250
|
-
const endOfPrev2 = [...cp.slice(0, -1), idx - 1, ...
|
|
1255
|
+
const endOfPrev2 = [...cp.slice(0, -1), idx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prevSib)];
|
|
1251
1256
|
const del2 = deleteRange(doc, endOfPrev2, sel.head.path);
|
|
1252
1257
|
return { steps: del2.steps, selection: caret(del2.caret) };
|
|
1253
1258
|
}
|
|
@@ -1257,11 +1262,11 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1257
1262
|
}
|
|
1258
1263
|
return null;
|
|
1259
1264
|
}
|
|
1260
|
-
const parent =
|
|
1265
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
1261
1266
|
const prev = parent.children[blockIdx - 1];
|
|
1262
|
-
if (!prev ||
|
|
1267
|
+
if (!prev || _chunkGQ2HHRGIcjs.isText.call(void 0, prev))
|
|
1263
1268
|
return null;
|
|
1264
|
-
const endOfPrev = [...parentPath, blockIdx - 1, ...
|
|
1269
|
+
const endOfPrev = [...parentPath, blockIdx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prev)];
|
|
1265
1270
|
const del = deleteRange(doc, endOfPrev, sel.head.path);
|
|
1266
1271
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1267
1272
|
}
|
|
@@ -1272,28 +1277,28 @@ function mapInput(doc, intent, data, sel, newId4, rules = [], pendingMarks) {
|
|
|
1272
1277
|
if (from < text.length)
|
|
1273
1278
|
return { steps: [{ kind: "deleteText", path: leafPath, offset: from, length: 1 }], selection: caret(leafPath.concat(from)) };
|
|
1274
1279
|
const nextInBlock = block.children[leafIdx + 1];
|
|
1275
|
-
if (nextInBlock &&
|
|
1280
|
+
if (nextInBlock && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, nextInBlock))
|
|
1276
1281
|
return { steps: [{ kind: "spliceChildren", path: blockPath, at: leafIdx + 1, remove: 1, insert: [] }], selection: caret(leafPath.concat(from)) };
|
|
1277
|
-
const parent =
|
|
1282
|
+
const parent = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
1278
1283
|
const next = parent.children[blockIdx + 1];
|
|
1279
|
-
if (!next ||
|
|
1284
|
+
if (!next || _chunkGQ2HHRGIcjs.isText.call(void 0, next)) {
|
|
1280
1285
|
if (inTableCell(doc, blockPath))
|
|
1281
1286
|
return null;
|
|
1282
1287
|
for (let cp = parentPath; cp.length > 0; cp = cp.slice(0, -1)) {
|
|
1283
1288
|
const idx = cp[cp.length - 1];
|
|
1284
|
-
const sibs =
|
|
1289
|
+
const sibs = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, cp.slice(0, -1)).children;
|
|
1285
1290
|
const nextSib = sibs[idx + 1];
|
|
1286
1291
|
if (!nextSib)
|
|
1287
1292
|
continue;
|
|
1288
|
-
if (
|
|
1293
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, nextSib))
|
|
1289
1294
|
break;
|
|
1290
|
-
const startOfNext2 = [...cp.slice(0, -1), idx + 1, ...
|
|
1295
|
+
const startOfNext2 = [...cp.slice(0, -1), idx + 1, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, nextSib), 0];
|
|
1291
1296
|
const del2 = deleteRange(doc, sel.head.path, startOfNext2);
|
|
1292
1297
|
return { steps: del2.steps, selection: caret(del2.caret) };
|
|
1293
1298
|
}
|
|
1294
1299
|
return null;
|
|
1295
1300
|
}
|
|
1296
|
-
const startOfNext = [...parentPath, blockIdx + 1, ...
|
|
1301
|
+
const startOfNext = [...parentPath, blockIdx + 1, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, next), 0];
|
|
1297
1302
|
const del = deleteRange(doc, sel.head.path, startOfNext);
|
|
1298
1303
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1299
1304
|
}
|
|
@@ -1354,8 +1359,8 @@ function blockTransform(block, blockIdx, kind, newId4, extra) {
|
|
|
1354
1359
|
}
|
|
1355
1360
|
}
|
|
1356
1361
|
function setCalloutVariant(doc, path, variant) {
|
|
1357
|
-
const node =
|
|
1358
|
-
if (!node ||
|
|
1362
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
1363
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "callout")
|
|
1359
1364
|
return null;
|
|
1360
1365
|
if (_optionalChain([node, 'access', _78 => _78.attrs, 'optionalAccess', _79 => _79.variant]) === variant)
|
|
1361
1366
|
return null;
|
|
@@ -1365,8 +1370,8 @@ function setCalloutVariant(doc, path, variant) {
|
|
|
1365
1370
|
};
|
|
1366
1371
|
}
|
|
1367
1372
|
function cycleCalloutVariant(doc, path) {
|
|
1368
|
-
const node =
|
|
1369
|
-
if (!node ||
|
|
1373
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
1374
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "callout")
|
|
1370
1375
|
return null;
|
|
1371
1376
|
const cur = String(_nullishCoalesce(_optionalChain([node, 'access', _80 => _80.attrs, 'optionalAccess', _81 => _81.variant]), () => ( "info")));
|
|
1372
1377
|
const i = CALLOUT_VARIANTS.indexOf(cur);
|
|
@@ -1396,7 +1401,7 @@ function mapCrossInput(doc, intent, data, sel, newId4) {
|
|
|
1396
1401
|
return { steps: del.steps, selection: caret(del.caret) };
|
|
1397
1402
|
if (intent === "insertText" && !data)
|
|
1398
1403
|
return null;
|
|
1399
|
-
const doc2 =
|
|
1404
|
+
const doc2 = _chunk4TMHVNL6cjs.applyAll.call(void 0, doc, del.steps);
|
|
1400
1405
|
const at = caret(del.caret);
|
|
1401
1406
|
const tail = mapInput(doc2, intent, data, at, newId4);
|
|
1402
1407
|
if (!tail)
|
|
@@ -1405,8 +1410,8 @@ function mapCrossInput(doc, intent, data, sel, newId4) {
|
|
|
1405
1410
|
}
|
|
1406
1411
|
var markable = (n) => n.type !== "code" && n.type !== "raw";
|
|
1407
1412
|
function marksAtCaret(doc, path) {
|
|
1408
|
-
const leaf =
|
|
1409
|
-
return
|
|
1413
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path.slice(0, -1));
|
|
1414
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? [..._nullishCoalesce(leaf.marks, () => ( []))] : [];
|
|
1410
1415
|
}
|
|
1411
1416
|
function toggleMarkList(marks, name, attrs) {
|
|
1412
1417
|
const on = attrs !== void 0 ? hasMarkEq(marks, name, attrs) : hasMark(marks, name);
|
|
@@ -1417,9 +1422,9 @@ function toggleMarkList(marks, name, attrs) {
|
|
|
1417
1422
|
function leafBlocksBetween(doc, fromBlock, toBlock) {
|
|
1418
1423
|
const all = [];
|
|
1419
1424
|
const walk = (node, path) => {
|
|
1420
|
-
if (!
|
|
1425
|
+
if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, node))
|
|
1421
1426
|
return;
|
|
1422
|
-
if (node.children.every((c) =>
|
|
1427
|
+
if (node.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) || _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c)))
|
|
1423
1428
|
all.push({ path, node });
|
|
1424
1429
|
else
|
|
1425
1430
|
node.children.forEach((c, i) => walk(c, [...path, i]));
|
|
@@ -1430,14 +1435,14 @@ function leafBlocksBetween(doc, fromBlock, toBlock) {
|
|
|
1430
1435
|
return fi < 0 || ti < 0 ? [] : all.slice(fi, ti + 1);
|
|
1431
1436
|
}
|
|
1432
1437
|
function totalChars(children) {
|
|
1433
|
-
return children.reduce((a, c) => a + (
|
|
1438
|
+
return children.reduce((a, c) => a + (_chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1), 0);
|
|
1434
1439
|
}
|
|
1435
1440
|
function spannedSegs(block, from, to) {
|
|
1436
1441
|
const out = [];
|
|
1437
1442
|
let pos = 0;
|
|
1438
1443
|
for (const leaf of block.children) {
|
|
1439
|
-
const len =
|
|
1440
|
-
if (
|
|
1444
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 1;
|
|
1445
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1441
1446
|
const lo = Math.max(from, pos);
|
|
1442
1447
|
const hi = Math.min(to, pos + len);
|
|
1443
1448
|
if (lo < hi)
|
|
@@ -1451,7 +1456,7 @@ function markChars(block, from, to, name, on, attrs) {
|
|
|
1451
1456
|
const out = [];
|
|
1452
1457
|
let pos = 0;
|
|
1453
1458
|
for (const leaf of block.children) {
|
|
1454
|
-
if (!
|
|
1459
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1455
1460
|
out.push(leaf);
|
|
1456
1461
|
pos += 1;
|
|
1457
1462
|
continue;
|
|
@@ -1532,7 +1537,7 @@ function textStyleChars(block, from, to, patch) {
|
|
|
1532
1537
|
const out = [];
|
|
1533
1538
|
let pos = 0;
|
|
1534
1539
|
for (const leaf of block.children) {
|
|
1535
|
-
if (!
|
|
1540
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
1536
1541
|
out.push(leaf);
|
|
1537
1542
|
pos += 1;
|
|
1538
1543
|
continue;
|
|
@@ -1578,11 +1583,11 @@ function setTextStyle(doc, sel, patch) {
|
|
|
1578
1583
|
};
|
|
1579
1584
|
}
|
|
1580
1585
|
function sliceLeaf(leaf, from, to) {
|
|
1581
|
-
return
|
|
1586
|
+
return _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? { ...leaf, text: leaf.text.slice(from, to) } : leaf;
|
|
1582
1587
|
}
|
|
1583
1588
|
function insertMarked(block, blockPath, leafIdx, from, to, text, marks) {
|
|
1584
1589
|
const leaf = block.children[leafIdx];
|
|
1585
|
-
if (!
|
|
1590
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
1586
1591
|
return null;
|
|
1587
1592
|
const markList = marks.length ? marks : void 0;
|
|
1588
1593
|
if (from === to && marksEq(leaf.marks, markList)) {
|
|
@@ -1627,7 +1632,7 @@ function insertHardBreak(block, blockPath, leafIdx, from, to) {
|
|
|
1627
1632
|
if (block.type !== "paragraph" && block.type !== "heading")
|
|
1628
1633
|
return null;
|
|
1629
1634
|
const leaf = block.children[leafIdx];
|
|
1630
|
-
if (!
|
|
1635
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
1631
1636
|
return null;
|
|
1632
1637
|
const before = leaf.text.slice(0, from);
|
|
1633
1638
|
const after = leaf.text.slice(to);
|
|
@@ -1644,7 +1649,7 @@ function insertHardBreak(block, blockPath, leafIdx, from, to) {
|
|
|
1644
1649
|
]);
|
|
1645
1650
|
const brAt = leafIdx + (before ? 1 : 0);
|
|
1646
1651
|
const afterIdx = brAt + 1;
|
|
1647
|
-
const landIdx = afterIdx < children.length &&
|
|
1652
|
+
const landIdx = afterIdx < children.length && _chunkGQ2HHRGIcjs.isText.call(void 0, children[afterIdx]) ? afterIdx : brAt;
|
|
1648
1653
|
return {
|
|
1649
1654
|
steps: [{ kind: "replaceNode", path: blockPath, node: { ...block, children } }],
|
|
1650
1655
|
selection: caret([...blockPath, landIdx, 0])
|
|
@@ -1654,21 +1659,21 @@ function coalesceLeaves(children) {
|
|
|
1654
1659
|
const out = [];
|
|
1655
1660
|
for (let i = 0; i < children.length; i++) {
|
|
1656
1661
|
const n = children[i];
|
|
1657
|
-
if (
|
|
1662
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.text === "" && children.length > 1) {
|
|
1658
1663
|
const prev2 = out[out.length - 1];
|
|
1659
1664
|
const next = children[i + 1];
|
|
1660
|
-
if (prev2 &&
|
|
1665
|
+
if (prev2 && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, prev2)) {
|
|
1661
1666
|
out.push(n);
|
|
1662
1667
|
continue;
|
|
1663
1668
|
}
|
|
1664
|
-
if (next &&
|
|
1669
|
+
if (next && _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, next)) {
|
|
1665
1670
|
out.push(n);
|
|
1666
1671
|
continue;
|
|
1667
1672
|
}
|
|
1668
1673
|
continue;
|
|
1669
1674
|
}
|
|
1670
1675
|
const prev = out[out.length - 1];
|
|
1671
|
-
if (prev &&
|
|
1676
|
+
if (prev && _chunkGQ2HHRGIcjs.isText.call(void 0, prev) && _chunkGQ2HHRGIcjs.isText.call(void 0, n) && marksEq(prev.marks, n.marks))
|
|
1672
1677
|
out[out.length - 1] = { ...prev, text: prev.text + n.text };
|
|
1673
1678
|
else
|
|
1674
1679
|
out.push(n);
|
|
@@ -1689,7 +1694,7 @@ function blockChar(children, leafIdx, char) {
|
|
|
1689
1694
|
let acc = 0;
|
|
1690
1695
|
for (let i = 0; i < leafIdx; i++) {
|
|
1691
1696
|
const c = children[i];
|
|
1692
|
-
acc +=
|
|
1697
|
+
acc += _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1;
|
|
1693
1698
|
}
|
|
1694
1699
|
return acc + char;
|
|
1695
1700
|
}
|
|
@@ -1697,17 +1702,17 @@ function locate(children, target) {
|
|
|
1697
1702
|
let acc = 0;
|
|
1698
1703
|
for (let i = 0; i < children.length; i++) {
|
|
1699
1704
|
const c = children[i];
|
|
1700
|
-
const len =
|
|
1705
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? c.text.length : 1;
|
|
1701
1706
|
if (target <= acc + len)
|
|
1702
1707
|
return [i, target - acc];
|
|
1703
1708
|
acc += len;
|
|
1704
1709
|
}
|
|
1705
1710
|
const last = children.length - 1;
|
|
1706
1711
|
const lc = children[last];
|
|
1707
|
-
return [last,
|
|
1712
|
+
return [last, _chunkGQ2HHRGIcjs.isText.call(void 0, lc) ? lc.text.length : 1];
|
|
1708
1713
|
}
|
|
1709
1714
|
function textLen(ns) {
|
|
1710
|
-
return ns.reduce((a, n) => a + (
|
|
1715
|
+
return ns.reduce((a, n) => a + (_chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n.text.length : 1), 0);
|
|
1711
1716
|
}
|
|
1712
1717
|
function stripSpan(b) {
|
|
1713
1718
|
return _optionalChain([b, 'access', _90 => _90.attrs, 'optionalAccess', _91 => _91.span]) ? { ...b, attrs: { ...b.attrs, span: void 0 } } : b;
|
|
@@ -1717,12 +1722,12 @@ function sliceDoc(doc, p1, p2) {
|
|
|
1717
1722
|
const a = split(lo);
|
|
1718
1723
|
const b = split(hi);
|
|
1719
1724
|
if (sameLeaf(lo, hi)) {
|
|
1720
|
-
const block =
|
|
1725
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
1721
1726
|
return { type: "doc", children: [stripSpan({ ...block, children: [sliceLeaf(block.children[a.leafIdx], a.char, b.char)] })] };
|
|
1722
1727
|
}
|
|
1723
1728
|
const sameBlock = a.blockPath.length === b.blockPath.length && a.blockPath.every((s, i) => s === b.blockPath[i]);
|
|
1724
1729
|
if (sameBlock) {
|
|
1725
|
-
const block =
|
|
1730
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, a.blockPath);
|
|
1726
1731
|
const mid = [trimHead(block.children[a.leafIdx], a.char), ...block.children.slice(a.leafIdx + 1, b.leafIdx), trimTail(block.children[b.leafIdx], b.char)];
|
|
1727
1732
|
return { type: "doc", children: [stripSpan({ ...block, children: coalesceLeaves(mid) })] };
|
|
1728
1733
|
}
|
|
@@ -1731,7 +1736,7 @@ function sliceDoc(doc, p1, p2) {
|
|
|
1731
1736
|
if (loTop === hiTop && doc.children[loTop].type === "table")
|
|
1732
1737
|
return { type: "doc", children: [stripSpan(doc.children[loTop])] };
|
|
1733
1738
|
const first = doc.children[loTop].type === "table" ? stripSpan(doc.children[loTop]) : stripSpan(keepAfter(doc.children[loTop], lo.slice(1)));
|
|
1734
|
-
const middle = doc.children.slice(loTop + 1, hiTop).map((n) =>
|
|
1739
|
+
const middle = doc.children.slice(loTop + 1, hiTop).map((n) => _chunkGQ2HHRGIcjs.isText.call(void 0, n) ? n : stripSpan(n));
|
|
1735
1740
|
const last = doc.children[hiTop].type === "table" ? stripSpan(doc.children[hiTop]) : stripSpan(keepBefore(doc.children[hiTop], hi.slice(1)));
|
|
1736
1741
|
return { type: "doc", children: [first, ...middle, last] };
|
|
1737
1742
|
}
|
|
@@ -1745,10 +1750,10 @@ function keepAfter(node, rel) {
|
|
|
1745
1750
|
function serializeSelection(doc, sel) {
|
|
1746
1751
|
if (cmpPath(sel.anchor.path, sel.head.path) === 0)
|
|
1747
1752
|
return "";
|
|
1748
|
-
return
|
|
1753
|
+
return _chunk4TMHVNL6cjs.docToMd.call(void 0, sliceDoc(doc, sel.anchor.path, sel.head.path), "");
|
|
1749
1754
|
}
|
|
1750
1755
|
function mapPaste(doc, sel, md, newId4) {
|
|
1751
|
-
const frag =
|
|
1756
|
+
const frag = _chunk4TMHVNL6cjs.mdToDoc.call(void 0, md).children.filter((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
1752
1757
|
return mapPasteBlocks(doc, sel, frag, newId4);
|
|
1753
1758
|
}
|
|
1754
1759
|
function mapPasteBlocks(doc, sel, frag, newId4) {
|
|
@@ -1756,7 +1761,7 @@ function mapPasteBlocks(doc, sel, frag, newId4) {
|
|
|
1756
1761
|
return null;
|
|
1757
1762
|
if (cmpPath(sel.anchor.path, sel.head.path) !== 0) {
|
|
1758
1763
|
const del = deleteRange(doc, sel.anchor.path, sel.head.path);
|
|
1759
|
-
const r = pasteAt(
|
|
1764
|
+
const r = pasteAt(_chunk4TMHVNL6cjs.applyAll.call(void 0, doc, del.steps), del.caret, frag, newId4);
|
|
1760
1765
|
return { steps: [...del.steps, ...r.steps], selection: r.selection };
|
|
1761
1766
|
}
|
|
1762
1767
|
return pasteAt(doc, sel.head.path, frag, newId4);
|
|
@@ -1767,13 +1772,13 @@ function indentItem(doc, sel, newId4) {
|
|
|
1767
1772
|
const itemIdx = itemPath[itemPath.length - 1];
|
|
1768
1773
|
if (itemIdx === 0)
|
|
1769
1774
|
return null;
|
|
1770
|
-
const list =
|
|
1771
|
-
if (!list ||
|
|
1775
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
1776
|
+
if (!list || _chunkGQ2HHRGIcjs.isText.call(void 0, list) || list.type !== "list")
|
|
1772
1777
|
return null;
|
|
1773
1778
|
const item = list.children[itemIdx];
|
|
1774
1779
|
const prev = list.children[itemIdx - 1];
|
|
1775
1780
|
const prevLast = prev.children[prev.children.length - 1];
|
|
1776
|
-
const intoExisting = !
|
|
1781
|
+
const intoExisting = !_chunkGQ2HHRGIcjs.isText.call(void 0, prevLast) && prevLast.type === "list";
|
|
1777
1782
|
const sublist = intoExisting ? { ...prevLast, children: [...prevLast.children, item] } : { ...list, id: newId4(), children: [item] };
|
|
1778
1783
|
const subIdx = intoExisting ? prev.children.length - 1 : prev.children.length;
|
|
1779
1784
|
const newPrev = { ...prev, children: intoExisting ? [...prev.children.slice(0, -1), sublist] : [...prev.children, sublist] };
|
|
@@ -1787,17 +1792,17 @@ function outdentItem(doc, sel, newId4) {
|
|
|
1787
1792
|
const itemPath = sel.head.path.slice(0, -3);
|
|
1788
1793
|
const sublistPath = itemPath.slice(0, -1);
|
|
1789
1794
|
const parentItemPath = sublistPath.slice(0, -1);
|
|
1790
|
-
const parentItem =
|
|
1795
|
+
const parentItem = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentItemPath);
|
|
1791
1796
|
if (!parentItem || parentItem.type !== "list_item")
|
|
1792
1797
|
return null;
|
|
1793
|
-
const sublist =
|
|
1794
|
-
if (!sublist ||
|
|
1798
|
+
const sublist = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, sublistPath);
|
|
1799
|
+
if (!sublist || _chunkGQ2HHRGIcjs.isText.call(void 0, sublist) || sublist.type !== "list")
|
|
1795
1800
|
return null;
|
|
1796
1801
|
const subItemIdx = itemPath[itemPath.length - 1];
|
|
1797
1802
|
const item = sublist.children[subItemIdx];
|
|
1798
1803
|
const following = sublist.children.slice(subItemIdx + 1);
|
|
1799
1804
|
const itemLast = item.children[item.children.length - 1];
|
|
1800
|
-
const newItem = following.length ? !
|
|
1805
|
+
const newItem = following.length ? !_chunkGQ2HHRGIcjs.isText.call(void 0, itemLast) && itemLast.type === "list" ? { ...item, children: [...item.children.slice(0, -1), { ...itemLast, children: [...itemLast.children, ...following] }] } : { ...item, children: [...item.children, { ...sublist, id: newId4(), children: following }] } : item;
|
|
1801
1806
|
const subIdxInParent = sublistPath[sublistPath.length - 1];
|
|
1802
1807
|
const preceding = sublist.children.slice(0, subItemIdx);
|
|
1803
1808
|
const newParentChildren = preceding.length ? [...parentItem.children.slice(0, subIdxInParent), { ...sublist, children: preceding }, ...parentItem.children.slice(subIdxInParent + 1)] : [...parentItem.children.slice(0, subIdxInParent), ...parentItem.children.slice(subIdxInParent + 1)];
|
|
@@ -1810,7 +1815,7 @@ function outdentItem(doc, sel, newId4) {
|
|
|
1810
1815
|
};
|
|
1811
1816
|
}
|
|
1812
1817
|
function isInline(b) {
|
|
1813
|
-
return !isAtom(b) && b.children.every(
|
|
1818
|
+
return !isAtom(b) && b.children.every(_chunkGQ2HHRGIcjs.isText);
|
|
1814
1819
|
}
|
|
1815
1820
|
function splitDeep(block, path, newId4) {
|
|
1816
1821
|
if (path.length === 2) {
|
|
@@ -1827,7 +1832,7 @@ function splitDeep(block, path, newId4) {
|
|
|
1827
1832
|
return [head, tail];
|
|
1828
1833
|
}
|
|
1829
1834
|
function emptyInline(b) {
|
|
1830
|
-
return isInline(b) && b.children.every((c) =>
|
|
1835
|
+
return isInline(b) && b.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text === "");
|
|
1831
1836
|
}
|
|
1832
1837
|
function lastInlinePath(b) {
|
|
1833
1838
|
if (isInline(b))
|
|
@@ -1850,7 +1855,7 @@ function spliceInline(block, path, leaves, atTail) {
|
|
|
1850
1855
|
return { ...block, children: [...block.children.slice(0, i), child, ...block.children.slice(i + 1)] };
|
|
1851
1856
|
}
|
|
1852
1857
|
function inlineLeaves(b) {
|
|
1853
|
-
return b.children.flatMap((c) =>
|
|
1858
|
+
return b.children.flatMap((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) ? [c] : inlineLeaves(c));
|
|
1854
1859
|
}
|
|
1855
1860
|
function flattenInline(frag) {
|
|
1856
1861
|
const out = [];
|
|
@@ -1862,8 +1867,8 @@ function flattenInline(frag) {
|
|
|
1862
1867
|
return coalesceLeaves(out);
|
|
1863
1868
|
}
|
|
1864
1869
|
function pasteTableInto(caretPath, target, src) {
|
|
1865
|
-
const tGrid =
|
|
1866
|
-
const sGrid =
|
|
1870
|
+
const tGrid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, target);
|
|
1871
|
+
const sGrid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, src);
|
|
1867
1872
|
const cellIdx = _nullishCoalesce(caretPath[1], () => ( 0));
|
|
1868
1873
|
const anchor = tGrid.cellOf(cellIdx);
|
|
1869
1874
|
const r0 = anchor.r;
|
|
@@ -1895,9 +1900,9 @@ function pasteTableInto(caretPath, target, src) {
|
|
|
1895
1900
|
}
|
|
1896
1901
|
function pasteAt(doc, caretPath, frag, newId4) {
|
|
1897
1902
|
const { blockPath, leafIdx, char } = split(caretPath);
|
|
1898
|
-
const block =
|
|
1903
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, blockPath);
|
|
1899
1904
|
const topBlock = doc.children[caretPath[0]];
|
|
1900
|
-
const inAtom = !
|
|
1905
|
+
const inAtom = !_chunkGQ2HHRGIcjs.isText.call(void 0, topBlock) && topBlock.type === "table";
|
|
1901
1906
|
if (inAtom && frag.length === 1 && frag[0].type === "table") {
|
|
1902
1907
|
return pasteTableInto(caretPath, topBlock, frag[0]);
|
|
1903
1908
|
}
|
|
@@ -3494,12 +3499,12 @@ var MentionMenu = (_class = class {
|
|
|
3494
3499
|
const leafIdx = sel.head.path[sel.head.path.length - 2];
|
|
3495
3500
|
const caret3 = sel.head.path[sel.head.path.length - 1];
|
|
3496
3501
|
const block = nodeAt2(this.host.doc(), blockPath);
|
|
3497
|
-
if (!block ||
|
|
3502
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph" && block.type !== "heading") {
|
|
3498
3503
|
this.close();
|
|
3499
3504
|
return;
|
|
3500
3505
|
}
|
|
3501
3506
|
const leaf = block.children[leafIdx];
|
|
3502
|
-
if (!leaf || !
|
|
3507
|
+
if (!leaf || !_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
3503
3508
|
this.close();
|
|
3504
3509
|
return;
|
|
3505
3510
|
}
|
|
@@ -3554,12 +3559,12 @@ var MentionMenu = (_class = class {
|
|
|
3554
3559
|
return;
|
|
3555
3560
|
}
|
|
3556
3561
|
const block = nodeAt2(this.host.doc(), t.blockPath);
|
|
3557
|
-
if (!block ||
|
|
3562
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block)) {
|
|
3558
3563
|
this.close();
|
|
3559
3564
|
return;
|
|
3560
3565
|
}
|
|
3561
3566
|
const leaf = block.children[t.leafIdx];
|
|
3562
|
-
if (!leaf || !
|
|
3567
|
+
if (!leaf || !_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
3563
3568
|
this.close();
|
|
3564
3569
|
return;
|
|
3565
3570
|
}
|
|
@@ -3627,7 +3632,7 @@ function samePath(a, b) {
|
|
|
3627
3632
|
function nodeAt2(doc, path) {
|
|
3628
3633
|
let cur = doc;
|
|
3629
3634
|
for (const seg of path) {
|
|
3630
|
-
if (
|
|
3635
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, cur))
|
|
3631
3636
|
return null;
|
|
3632
3637
|
const child = cur.children[seg];
|
|
3633
3638
|
if (!child)
|
|
@@ -3704,13 +3709,13 @@ function blockIco(name, size2 = 18) {
|
|
|
3704
3709
|
}
|
|
3705
3710
|
function currentBlockKind(doc, sel) {
|
|
3706
3711
|
const block = doc.children[sel.head.path[0]];
|
|
3707
|
-
if (!block ||
|
|
3712
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
3708
3713
|
return "paragraph";
|
|
3709
3714
|
if (block.type === "heading")
|
|
3710
3715
|
return `heading${Number(_nullishCoalesce(_optionalChain([block, 'access', _112 => _112.attrs, 'optionalAccess', _113 => _113.depth]), () => ( 1)))}`;
|
|
3711
3716
|
if (block.type === "list") {
|
|
3712
3717
|
const item = block.children[0];
|
|
3713
|
-
if (item && !
|
|
3718
|
+
if (item && !_chunkGQ2HHRGIcjs.isText.call(void 0, item) && item.attrs && "checked" in item.attrs)
|
|
3714
3719
|
return "task";
|
|
3715
3720
|
return _optionalChain([block, 'access', _114 => _114.attrs, 'optionalAccess', _115 => _115.ordered]) ? "ordered" : "bullet";
|
|
3716
3721
|
}
|
|
@@ -3931,16 +3936,16 @@ var BubbleMenu = (_class2 = class {
|
|
|
3931
3936
|
}, SHOW_MS);
|
|
3932
3937
|
}}
|
|
3933
3938
|
activeMarks(sel) {
|
|
3934
|
-
const leaf =
|
|
3935
|
-
return new Set(
|
|
3939
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), sel.head.path.slice(0, -1));
|
|
3940
|
+
return new Set(_chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? (_nullishCoalesce(leaf.marks, () => ( []))).map((m) => m.name) : []);
|
|
3936
3941
|
}
|
|
3937
3942
|
activeAlign(sel) {
|
|
3938
3943
|
const block = this.host.doc().children[sel.head.path[0]];
|
|
3939
|
-
return !block ||
|
|
3944
|
+
return !block || _chunkGQ2HHRGIcjs.isText.call(void 0, block) ? "left" : _nullishCoalesce(_optionalChain([block, 'access', _116 => _116.attrs, 'optionalAccess', _117 => _117.align]), () => ( "left"));
|
|
3940
3945
|
}
|
|
3941
3946
|
styleAttrs(sel) {
|
|
3942
|
-
const leaf =
|
|
3943
|
-
if (!
|
|
3947
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), sel.head.path.slice(0, -1));
|
|
3948
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
|
|
3944
3949
|
return null;
|
|
3945
3950
|
const m = (_nullishCoalesce(leaf.marks, () => ( []))).find((x) => x.name === "textStyle");
|
|
3946
3951
|
return _nullishCoalesce(_optionalChain([m, 'optionalAccess', _118 => _118.attrs]), () => ( null));
|
|
@@ -3959,7 +3964,7 @@ var BubbleMenu = (_class2 = class {
|
|
|
3959
3964
|
return;
|
|
3960
3965
|
const idx = sel.head.path[0];
|
|
3961
3966
|
const block = this.host.doc().children[idx];
|
|
3962
|
-
if (!block ||
|
|
3967
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
3963
3968
|
return;
|
|
3964
3969
|
const r = blockTransform(block, idx, kind, nid);
|
|
3965
3970
|
this.menu = null;
|
|
@@ -4419,11 +4424,11 @@ var CodeControls = (_class3 = class {
|
|
|
4419
4424
|
ev.preventDefault();
|
|
4420
4425
|
ev.stopPropagation();
|
|
4421
4426
|
const doc = this.host.doc();
|
|
4422
|
-
const path =
|
|
4427
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, blockId);
|
|
4423
4428
|
if (path) {
|
|
4424
|
-
const node =
|
|
4429
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, path);
|
|
4425
4430
|
const attrs = { ...node.attrs, lang: opt === "\u7EAF\u6587\u672C" ? void 0 : opt };
|
|
4426
|
-
this.host.dispatch([
|
|
4431
|
+
this.host.dispatch([_chunk4TMHVNL6cjs.rewriteNode.call(void 0, doc, blockId, { ...node, attrs })]);
|
|
4427
4432
|
}
|
|
4428
4433
|
this.closeMenu();
|
|
4429
4434
|
});
|
|
@@ -4495,7 +4500,7 @@ var DragHandle = (_class4 = class {
|
|
|
4495
4500
|
this.overlay.remove();
|
|
4496
4501
|
}
|
|
4497
4502
|
blocks() {
|
|
4498
|
-
return
|
|
4503
|
+
return _chunkSLRD6FMPcjs.elementChildren.call(void 0, _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root));
|
|
4499
4504
|
}
|
|
4500
4505
|
clearLeave() {
|
|
4501
4506
|
if (this.leaveTimer != null) {
|
|
@@ -4592,7 +4597,7 @@ var DragHandle = (_class4 = class {
|
|
|
4592
4597
|
document.removeEventListener("mousemove", move);
|
|
4593
4598
|
document.removeEventListener("mouseup", up);
|
|
4594
4599
|
if (active2 && this.drag) {
|
|
4595
|
-
const steps =
|
|
4600
|
+
const steps = _chunk4TMHVNL6cjs.moveBlock.call(void 0, this.host.doc(), fromIdx, this.drag.gap);
|
|
4596
4601
|
if (steps.length)
|
|
4597
4602
|
this.host.dispatch(steps);
|
|
4598
4603
|
}
|
|
@@ -4606,7 +4611,7 @@ var DragHandle = (_class4 = class {
|
|
|
4606
4611
|
}
|
|
4607
4612
|
toggleFold(blockIdx) {
|
|
4608
4613
|
const node = this.host.doc().children[blockIdx];
|
|
4609
|
-
if (!node ||
|
|
4614
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "heading")
|
|
4610
4615
|
return;
|
|
4611
4616
|
this.host.dispatch([{
|
|
4612
4617
|
kind: "replaceNode",
|
|
@@ -4617,7 +4622,7 @@ var DragHandle = (_class4 = class {
|
|
|
4617
4622
|
/** 整块文本选区(paragraph/heading 顶层叶),供手柄菜单套 mark */
|
|
4618
4623
|
blockSel(blockIdx) {
|
|
4619
4624
|
const block = this.host.doc().children[blockIdx];
|
|
4620
|
-
if (!block ||
|
|
4625
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4621
4626
|
return null;
|
|
4622
4627
|
if (block.type !== "paragraph" && block.type !== "heading" && block.type !== "code")
|
|
4623
4628
|
return null;
|
|
@@ -4626,7 +4631,7 @@ var DragHandle = (_class4 = class {
|
|
|
4626
4631
|
let lastLen = 0;
|
|
4627
4632
|
for (let i = 0; i < block.children.length; i++) {
|
|
4628
4633
|
const c = block.children[i];
|
|
4629
|
-
if (
|
|
4634
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c)) {
|
|
4630
4635
|
if (first < 0)
|
|
4631
4636
|
first = i;
|
|
4632
4637
|
last = i;
|
|
@@ -4645,7 +4650,7 @@ var DragHandle = (_class4 = class {
|
|
|
4645
4650
|
if (idx < 0)
|
|
4646
4651
|
return;
|
|
4647
4652
|
const block = this.host.doc().children[idx];
|
|
4648
|
-
if (!block ||
|
|
4653
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4649
4654
|
return;
|
|
4650
4655
|
const r = blockTransform(block, idx, kind, newId);
|
|
4651
4656
|
this.host.dispatch(r.steps, r.selection);
|
|
@@ -4684,7 +4689,7 @@ var DragHandle = (_class4 = class {
|
|
|
4684
4689
|
dropLine() {
|
|
4685
4690
|
if (!this.drag)
|
|
4686
4691
|
return null;
|
|
4687
|
-
const docEl =
|
|
4692
|
+
const docEl = _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root);
|
|
4688
4693
|
const blocks = this.blocks();
|
|
4689
4694
|
const gap = this.drag.gap;
|
|
4690
4695
|
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access', _164 => _164[0], 'optionalAccess', _165 => _165.getBoundingClientRect, 'call', _166 => _166(), 'access', _167 => _167.top]), () => ( 0)) : _nullishCoalesce(_optionalChain([blocks, 'access', _168 => _168[gap - 1], 'optionalAccess', _169 => _169.getBoundingClientRect, 'call', _170 => _170(), 'access', _171 => _171.bottom]), () => ( 0));
|
|
@@ -4721,7 +4726,7 @@ var DragHandle = (_class4 = class {
|
|
|
4721
4726
|
paintMenu() {
|
|
4722
4727
|
const idx = this.hoverIdx;
|
|
4723
4728
|
const block = this.host.doc().children[idx];
|
|
4724
|
-
if (!block ||
|
|
4729
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
4725
4730
|
return null;
|
|
4726
4731
|
const kind = this.currentKind(block);
|
|
4727
4732
|
const typeRow = TYPE_ITEMS.map((it) => _preact.h.call(void 0, "button", {
|
|
@@ -5008,11 +5013,11 @@ var SlashMenu = (_class5 = class {
|
|
|
5008
5013
|
}
|
|
5009
5014
|
const blockIdx = sel.head.path[0];
|
|
5010
5015
|
const block = this.host.doc().children[blockIdx];
|
|
5011
|
-
if (
|
|
5016
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph") {
|
|
5012
5017
|
this.close();
|
|
5013
5018
|
return;
|
|
5014
5019
|
}
|
|
5015
|
-
const head =
|
|
5020
|
+
const head = _chunkGQ2HHRGIcjs.isText.call(void 0, block.children[0]) ? block.children[0].text : "";
|
|
5016
5021
|
if (head[0] !== "/") {
|
|
5017
5022
|
this.close();
|
|
5018
5023
|
return;
|
|
@@ -5052,7 +5057,7 @@ var SlashMenu = (_class5 = class {
|
|
|
5052
5057
|
apply(item) {
|
|
5053
5058
|
const doc = this.host.doc();
|
|
5054
5059
|
const block = doc.children[this.blockIdx];
|
|
5055
|
-
if (!item ||
|
|
5060
|
+
if (!item || _chunkGQ2HHRGIcjs.isText.call(void 0, block) || block.type !== "paragraph") {
|
|
5056
5061
|
this.close();
|
|
5057
5062
|
return;
|
|
5058
5063
|
}
|
|
@@ -5085,13 +5090,13 @@ var SlashMenu = (_class5 = class {
|
|
|
5085
5090
|
_optionalChain([this, 'access', _185 => _185.host, 'access', _186 => _186.insertEmbed, 'optionalCall', _187 => _187(blockIdx, item.insert)]);
|
|
5086
5091
|
return;
|
|
5087
5092
|
}
|
|
5088
|
-
const node = item.insert === "table" ?
|
|
5093
|
+
const node = item.insert === "table" ? _chunk4TMHVNL6cjs.makeTable.call(void 0, newId2(), 3, 3) : { type: "raw", id: newId2(), attrs: { mdType: "thematicBreak" }, children: [{ text: "" }] };
|
|
5089
5094
|
this.host.dispatch([{ kind: "replaceNode", path: [blockIdx], node }]);
|
|
5090
5095
|
return;
|
|
5091
5096
|
}
|
|
5092
5097
|
const first = block.children[0];
|
|
5093
|
-
const rest =
|
|
5094
|
-
const head =
|
|
5098
|
+
const rest = _chunkGQ2HHRGIcjs.isText.call(void 0, first) ? first.text.slice(1 + this.query.length) : "";
|
|
5099
|
+
const head = _chunkGQ2HHRGIcjs.isText.call(void 0, first) ? { ...first, text: rest } : { text: rest };
|
|
5095
5100
|
const stripped = { ...block, children: [head, ...block.children.slice(1)] };
|
|
5096
5101
|
const extra = item.kind === "callout" ? { variant: calloutVariantFromQuery(this.query) } : void 0;
|
|
5097
5102
|
const r = blockTransform(stripped, blockIdx, item.kind, newId2, extra);
|
|
@@ -5246,8 +5251,8 @@ var inputRules = {
|
|
|
5246
5251
|
return null;
|
|
5247
5252
|
if (!(marker === "[]" || marker === "[ ]" || marker === "[x]" || marker === "[X]"))
|
|
5248
5253
|
return null;
|
|
5249
|
-
const item =
|
|
5250
|
-
if (!item ||
|
|
5254
|
+
const item = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, parentPath);
|
|
5255
|
+
if (!item || _chunkGQ2HHRGIcjs.isText.call(void 0, item) || item.type !== "list_item")
|
|
5251
5256
|
return null;
|
|
5252
5257
|
const checked = marker === "[x]" || marker === "[X]";
|
|
5253
5258
|
const para = { ...block, children: [{ text: rest }, ...block.children.slice(1)] };
|
|
@@ -5540,7 +5545,7 @@ var CommentPanel = (_class6 = class {
|
|
|
5540
5545
|
this.paint();
|
|
5541
5546
|
}
|
|
5542
5547
|
deleteThread(id) {
|
|
5543
|
-
const steps =
|
|
5548
|
+
const steps = _chunkYXQDCW4Ycjs.stripCommentMarks.call(void 0, this.host.doc(), id);
|
|
5544
5549
|
this.commitThreads(this.threads.filter((t) => t.id !== id));
|
|
5545
5550
|
this.activeId = null;
|
|
5546
5551
|
this.mode = this.threads.length ? { kind: "list" } : { kind: "closed" };
|
|
@@ -5898,7 +5903,7 @@ var TocPanel = (_class7 = class {
|
|
|
5898
5903
|
}
|
|
5899
5904
|
__init52() {this.onRedraw = () => this.refresh()}
|
|
5900
5905
|
refresh() {
|
|
5901
|
-
this.entries =
|
|
5906
|
+
this.entries = _chunkYXQDCW4Ycjs.outline.call(void 0, this.host.doc()).filter((e) => e.text.trim());
|
|
5902
5907
|
this.syncActive();
|
|
5903
5908
|
this.paint();
|
|
5904
5909
|
}
|
|
@@ -6336,7 +6341,7 @@ function atomIdsInSelection(doc, sel) {
|
|
|
6336
6341
|
const out = /* @__PURE__ */ new Set();
|
|
6337
6342
|
for (let i = lo; i <= hi; i++) {
|
|
6338
6343
|
const n = doc.children[i];
|
|
6339
|
-
if (!n ||
|
|
6344
|
+
if (!n || _chunkGQ2HHRGIcjs.isText.call(void 0, n))
|
|
6340
6345
|
continue;
|
|
6341
6346
|
if ((n.type === "image" || n.type === "embed") && n.id)
|
|
6342
6347
|
out.add(n.id);
|
|
@@ -6438,7 +6443,7 @@ var ImageControls = (_class9 = class {
|
|
|
6438
6443
|
return !!this.exclusiveId && !!this.atomEl(this.exclusiveId);
|
|
6439
6444
|
}
|
|
6440
6445
|
selectedBlockPath() {
|
|
6441
|
-
return this.exclusiveId ?
|
|
6446
|
+
return this.exclusiveId ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), this.exclusiveId) : null;
|
|
6442
6447
|
}
|
|
6443
6448
|
selectByBlockId(id) {
|
|
6444
6449
|
const atom = this.atomEl(id);
|
|
@@ -6474,10 +6479,10 @@ var ImageControls = (_class9 = class {
|
|
|
6474
6479
|
blockNode() {
|
|
6475
6480
|
if (!this.exclusiveId)
|
|
6476
6481
|
return null;
|
|
6477
|
-
const path =
|
|
6482
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), this.exclusiveId);
|
|
6478
6483
|
if (!path)
|
|
6479
6484
|
return null;
|
|
6480
|
-
const node =
|
|
6485
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6481
6486
|
return node.type === "image" || node.type === "embed" ? { path, node } : null;
|
|
6482
6487
|
}
|
|
6483
6488
|
patchAttrs(patch) {
|
|
@@ -6687,7 +6692,7 @@ var TableControls = (_class10 = class {
|
|
|
6687
6692
|
// 选中表的 model 块路径(供 atomBlockGuard 拿定位)。无选中 / 无 id → null。
|
|
6688
6693
|
selectedBlockPath() {
|
|
6689
6694
|
const id = _optionalChain([this, 'access', _256 => _256.selectedBlock, 'optionalAccess', _257 => _257.getAttribute, 'call', _258 => _258("data-block-id")]);
|
|
6690
|
-
return id ?
|
|
6695
|
+
return id ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), id) : null;
|
|
6691
6696
|
}
|
|
6692
6697
|
// 按 model 块 id 选中对应表格(供 atomSelectGuard:光标逼近表 → 先选中而非直删)。选中成功返 true。
|
|
6693
6698
|
selectByBlockId(id) {
|
|
@@ -6727,10 +6732,10 @@ var TableControls = (_class10 = class {
|
|
|
6727
6732
|
const path = this.tablePath(tableEl);
|
|
6728
6733
|
if (!path)
|
|
6729
6734
|
return null;
|
|
6730
|
-
const table =
|
|
6731
|
-
if (
|
|
6735
|
+
const table = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6736
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, table) || table.type !== "table")
|
|
6732
6737
|
return null;
|
|
6733
|
-
const grid =
|
|
6738
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, table);
|
|
6734
6739
|
const { rows, cols } = grid;
|
|
6735
6740
|
const cells = Array.from(tableEl.querySelectorAll(".markloom-cell"));
|
|
6736
6741
|
if (cells.length !== grid.anchors.length || cols === 0)
|
|
@@ -6770,14 +6775,14 @@ var TableControls = (_class10 = class {
|
|
|
6770
6775
|
}
|
|
6771
6776
|
tablePath(tableEl) {
|
|
6772
6777
|
const id = tableEl.getAttribute("data-block-id");
|
|
6773
|
-
return id ?
|
|
6778
|
+
return id ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.host.doc(), id) : null;
|
|
6774
6779
|
}
|
|
6775
6780
|
tableModel(tableEl) {
|
|
6776
6781
|
const path = this.tablePath(tableEl);
|
|
6777
6782
|
if (!path)
|
|
6778
6783
|
return null;
|
|
6779
|
-
const t =
|
|
6780
|
-
return !
|
|
6784
|
+
const t = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.host.doc(), path);
|
|
6785
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, t) && t.type === "table" ? t : null;
|
|
6781
6786
|
}
|
|
6782
6787
|
// 焦点驱动:caret 落在某表格的 cell 内 → 该表控制柄常驻显示;焦点移出表格 → 收起。
|
|
6783
6788
|
// 不随鼠标 hover 进出闪现(飞书式:聚焦即常驻)。选中/菜单/拖拽进行中不因选区变动收起(柄操作会短暂夺焦)。
|
|
@@ -6820,7 +6825,7 @@ var TableControls = (_class10 = class {
|
|
|
6820
6825
|
const path = this.tablePath(this.active);
|
|
6821
6826
|
if (rect && t && path) {
|
|
6822
6827
|
e.preventDefault();
|
|
6823
|
-
this.host.dispatch([
|
|
6828
|
+
this.host.dispatch([_chunk4TMHVNL6cjs.clearCells.call(void 0, t, path, rect)]);
|
|
6824
6829
|
this.sel = null;
|
|
6825
6830
|
this.menu = null;
|
|
6826
6831
|
this.applySelClasses();
|
|
@@ -6836,7 +6841,7 @@ var TableControls = (_class10 = class {
|
|
|
6836
6841
|
const t = this.tableModel(this.active);
|
|
6837
6842
|
if (!t)
|
|
6838
6843
|
return null;
|
|
6839
|
-
const { rows, cols } =
|
|
6844
|
+
const { rows, cols } = _chunk4TMHVNL6cjs.buildGrid.call(void 0, t);
|
|
6840
6845
|
if (sel.kind === "all")
|
|
6841
6846
|
return { r1: 0, c1: 0, r2: rows - 1, c2: cols - 1 };
|
|
6842
6847
|
if (sel.kind === "row")
|
|
@@ -6963,7 +6968,7 @@ var TableControls = (_class10 = class {
|
|
|
6963
6968
|
document.removeEventListener("pointermove", move);
|
|
6964
6969
|
document.removeEventListener("pointerup", up);
|
|
6965
6970
|
if (active2 && this.blockDrag) {
|
|
6966
|
-
const steps =
|
|
6971
|
+
const steps = _chunk4TMHVNL6cjs.moveBlock.call(void 0, this.host.doc(), fromIdx, this.blockDrag.gap);
|
|
6967
6972
|
if (steps.length) {
|
|
6968
6973
|
this.clearSelected();
|
|
6969
6974
|
this.host.dispatch(steps);
|
|
@@ -6977,7 +6982,7 @@ var TableControls = (_class10 = class {
|
|
|
6977
6982
|
}
|
|
6978
6983
|
// 鼠标 y → 顶层块间缝下标(0..n)。遍历 .markloom-doc 结构子(elementChildren 穿透布局层),y 落某块上半 → 该块前缝,下半 → 后缝。
|
|
6979
6984
|
gapAtY(y) {
|
|
6980
|
-
const blocks =
|
|
6985
|
+
const blocks = _chunkSLRD6FMPcjs.elementChildren.call(void 0, _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root));
|
|
6981
6986
|
for (let i = 0; i < blocks.length; i++) {
|
|
6982
6987
|
const r = blocks[i].getBoundingClientRect();
|
|
6983
6988
|
if (y < (r.top + r.bottom) / 2)
|
|
@@ -6989,8 +6994,8 @@ var TableControls = (_class10 = class {
|
|
|
6989
6994
|
blockDropLine() {
|
|
6990
6995
|
if (!this.blockDrag)
|
|
6991
6996
|
return null;
|
|
6992
|
-
const docEl =
|
|
6993
|
-
const blocks =
|
|
6997
|
+
const docEl = _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root);
|
|
6998
|
+
const blocks = _chunkSLRD6FMPcjs.elementChildren.call(void 0, docEl);
|
|
6994
6999
|
const gap = this.blockDrag.gap;
|
|
6995
7000
|
const y = gap === 0 ? _nullishCoalesce(_optionalChain([blocks, 'access', _276 => _276[0], 'optionalAccess', _277 => _277.getBoundingClientRect, 'call', _278 => _278(), 'access', _279 => _279.top]), () => ( 0)) : _nullishCoalesce(_optionalChain([blocks, 'access', _280 => _280[gap - 1], 'optionalAccess', _281 => _281.getBoundingClientRect, 'call', _282 => _282(), 'access', _283 => _283.bottom]), () => ( 0));
|
|
6996
7001
|
const box = docEl.getBoundingClientRect();
|
|
@@ -7005,7 +7010,7 @@ var TableControls = (_class10 = class {
|
|
|
7005
7010
|
const table = this.tableModel(this.active);
|
|
7006
7011
|
if (!table)
|
|
7007
7012
|
return;
|
|
7008
|
-
const grid =
|
|
7013
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, table);
|
|
7009
7014
|
if (cells.length !== grid.anchors.length)
|
|
7010
7015
|
return;
|
|
7011
7016
|
const rect = _optionalChain([this, 'access', _284 => _284.sel, 'optionalAccess', _285 => _285.kind]) === "rect" ? normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2) : null;
|
|
@@ -7158,7 +7163,7 @@ var TableControls = (_class10 = class {
|
|
|
7158
7163
|
insertAt(e, tableEl, kind, at) {
|
|
7159
7164
|
e.preventDefault();
|
|
7160
7165
|
e.stopPropagation();
|
|
7161
|
-
this.op(tableEl, (t, p) => kind === "col" ?
|
|
7166
|
+
this.op(tableEl, (t, p) => kind === "col" ? _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, at) : _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, at));
|
|
7162
7167
|
}
|
|
7163
7168
|
// 列右边界的拖拽改宽手柄。table-layout:fixed + colgroup 下每列宽都显式(无 1fr 余量),
|
|
7164
7169
|
// 故最后一列也给柄——拖它即改表总宽(同飞书),与中间列同一套 startResize。
|
|
@@ -7216,33 +7221,33 @@ var TableControls = (_class10 = class {
|
|
|
7216
7221
|
runMenu(g, m, i) {
|
|
7217
7222
|
if (m.kind === "col") {
|
|
7218
7223
|
if (i === 0)
|
|
7219
|
-
this.op(g.tableEl, (t, p) =>
|
|
7224
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, m.index));
|
|
7220
7225
|
else if (i === 1)
|
|
7221
|
-
this.op(g.tableEl, (t, p) =>
|
|
7226
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertCol.call(void 0, t, p, m.index + 1));
|
|
7222
7227
|
else if (i === 2)
|
|
7223
|
-
this.op(g.tableEl, (t, p) =>
|
|
7228
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.deleteCol.call(void 0, t, p, m.index, this.host.doc()));
|
|
7224
7229
|
else {
|
|
7225
7230
|
const a = i === 3 ? "left" : i === 4 ? "center" : "right";
|
|
7226
|
-
this.op(g.tableEl, (t, p) =>
|
|
7231
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setAlign.call(void 0, t, p, m.index, a));
|
|
7227
7232
|
}
|
|
7228
7233
|
} else if (m.kind === "row") {
|
|
7229
7234
|
if (i === 0)
|
|
7230
|
-
this.op(g.tableEl, (t, p) =>
|
|
7235
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, m.index));
|
|
7231
7236
|
else if (i === 1)
|
|
7232
|
-
this.op(g.tableEl, (t, p) =>
|
|
7233
|
-
else this.op(g.tableEl, (t, p) =>
|
|
7237
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.insertRow.call(void 0, t, p, m.index + 1));
|
|
7238
|
+
else this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.deleteRow.call(void 0, t, p, m.index, this.host.doc()));
|
|
7234
7239
|
} else if (m.kind === "rect") {
|
|
7235
7240
|
this.runRectMenu(g, i);
|
|
7236
7241
|
} else {
|
|
7237
7242
|
if (i === 0)
|
|
7238
|
-
this.op(g.tableEl, (_t, p) =>
|
|
7243
|
+
this.op(g.tableEl, (_t, p) => _chunk4TMHVNL6cjs.deleteTableBlock.call(void 0, p, this.host.doc()));
|
|
7239
7244
|
else if (i === 1)
|
|
7240
|
-
this.op(g.tableEl, (t, p) =>
|
|
7245
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { rows: 1 }));
|
|
7241
7246
|
else if (i === 2)
|
|
7242
|
-
this.op(g.tableEl, (t, p) =>
|
|
7247
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { rows: 0 }));
|
|
7243
7248
|
else if (i === 3)
|
|
7244
|
-
this.op(g.tableEl, (t, p) =>
|
|
7245
|
-
else this.op(g.tableEl, (t, p) =>
|
|
7249
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { cols: 1 }));
|
|
7250
|
+
else this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setFreeze.call(void 0, t, p, { cols: 0 }));
|
|
7246
7251
|
}
|
|
7247
7252
|
this.menu = null;
|
|
7248
7253
|
}
|
|
@@ -7252,9 +7257,9 @@ var TableControls = (_class10 = class {
|
|
|
7252
7257
|
return;
|
|
7253
7258
|
const rr = normRect(this.sel.r1, this.sel.c1, this.sel.r2, this.sel.c2);
|
|
7254
7259
|
if (i === 0)
|
|
7255
|
-
this.op(g.tableEl, (t, p) =>
|
|
7260
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.mergeCells.call(void 0, t, p, rr.r1, rr.c1, rr.r2, rr.c2));
|
|
7256
7261
|
else if (i === 1)
|
|
7257
|
-
this.op(g.tableEl, (t, p) =>
|
|
7262
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.splitCell.call(void 0, t, p, rr.r1, rr.c1));
|
|
7258
7263
|
else if (i === 2) {
|
|
7259
7264
|
void askInput({
|
|
7260
7265
|
title: "\u5355\u5143\u683C\u80CC\u666F\u8272",
|
|
@@ -7263,10 +7268,10 @@ var TableControls = (_class10 = class {
|
|
|
7263
7268
|
confirmLabel: "\u5E94\u7528"
|
|
7264
7269
|
}).then((bg) => {
|
|
7265
7270
|
if (bg)
|
|
7266
|
-
this.op(g.tableEl, (t, p) =>
|
|
7271
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { bg }));
|
|
7267
7272
|
});
|
|
7268
7273
|
} else if (i === 3) {
|
|
7269
|
-
this.op(g.tableEl, (t, p) =>
|
|
7274
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { bg: null }));
|
|
7270
7275
|
} else if (i === 4) {
|
|
7271
7276
|
void askInput({
|
|
7272
7277
|
title: "\u5355\u5143\u683C\u8FB9\u6846\u8272",
|
|
@@ -7275,10 +7280,10 @@ var TableControls = (_class10 = class {
|
|
|
7275
7280
|
confirmLabel: "\u5E94\u7528"
|
|
7276
7281
|
}).then((border) => {
|
|
7277
7282
|
if (border)
|
|
7278
|
-
this.op(g.tableEl, (t, p) =>
|
|
7283
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { border }));
|
|
7279
7284
|
});
|
|
7280
7285
|
} else {
|
|
7281
|
-
this.op(g.tableEl, (t, p) =>
|
|
7286
|
+
this.op(g.tableEl, (t, p) => _chunk4TMHVNL6cjs.setCellStyle.call(void 0, t, p, rr.r1, rr.c1, { border: null }));
|
|
7282
7287
|
}
|
|
7283
7288
|
}
|
|
7284
7289
|
// 按下行/列柄:暂不动,装 document 监听。位移超阈值 → 进拖拽重排;否则松手当点击(选中 + 双击式开菜单)。
|
|
@@ -7311,7 +7316,7 @@ var TableControls = (_class10 = class {
|
|
|
7311
7316
|
const { from, to } = this.drag;
|
|
7312
7317
|
const dest = to > from ? to - 1 : to;
|
|
7313
7318
|
if (dest !== from && !(kind === "row" && from === 0))
|
|
7314
|
-
this.op(this.active, (t, p) => kind === "col" ?
|
|
7319
|
+
this.op(this.active, (t, p) => kind === "col" ? _chunk4TMHVNL6cjs.moveCol.call(void 0, t, p, from, dest) : _chunk4TMHVNL6cjs.moveRow.call(void 0, t, p, from, dest));
|
|
7315
7320
|
this.drag = null;
|
|
7316
7321
|
this.paint();
|
|
7317
7322
|
} else {
|
|
@@ -7344,7 +7349,7 @@ var TableControls = (_class10 = class {
|
|
|
7344
7349
|
const startW = g.colX[col + 1] - g.colX[col];
|
|
7345
7350
|
this.resize = { col, startX: e.clientX, startW };
|
|
7346
7351
|
const tableEl = g.tableEl;
|
|
7347
|
-
const widths = (_nullishCoalesce(
|
|
7352
|
+
const widths = (_nullishCoalesce(_chunk4TMHVNL6cjs.tableColWidths.call(void 0, this.tableModel(tableEl)), () => ( this.measuredWidths(g)))).slice();
|
|
7348
7353
|
const colEls = Array.from(tableEl.querySelectorAll(":scope > colgroup > col"));
|
|
7349
7354
|
const move = (ev) => {
|
|
7350
7355
|
const next = Math.max(40, startW + (ev.clientX - this.resize.startX));
|
|
@@ -7358,7 +7363,7 @@ var TableControls = (_class10 = class {
|
|
|
7358
7363
|
document.removeEventListener("pointermove", move);
|
|
7359
7364
|
document.removeEventListener("pointerup", up);
|
|
7360
7365
|
this.resize = null;
|
|
7361
|
-
this.op(tableEl, (t, p) =>
|
|
7366
|
+
this.op(tableEl, (t, p) => _chunk4TMHVNL6cjs.setColWidths.call(void 0, t, p, widths));
|
|
7362
7367
|
};
|
|
7363
7368
|
document.addEventListener("pointermove", move);
|
|
7364
7369
|
document.addEventListener("pointerup", up);
|
|
@@ -7397,10 +7402,13 @@ var Editor = (_class11 = class {
|
|
|
7397
7402
|
|
|
7398
7403
|
/** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
|
|
7399
7404
|
__init85() {this.aiCtl = null}
|
|
7400
|
-
|
|
7405
|
+
/** 协作会话;applyingRemote 期间本地 steps 不上行 */
|
|
7406
|
+
__init86() {this.collabCtl = null}
|
|
7407
|
+
__init87() {this.applyingRemote = false}
|
|
7408
|
+
constructor(root, doc, opts = {}) {;_class11.prototype.__init79.call(this);_class11.prototype.__init80.call(this);_class11.prototype.__init81.call(this);_class11.prototype.__init82.call(this);_class11.prototype.__init83.call(this);_class11.prototype.__init84.call(this);_class11.prototype.__init85.call(this);_class11.prototype.__init86.call(this);_class11.prototype.__init87.call(this);_class11.prototype.__init88.call(this);_class11.prototype.__init89.call(this);_class11.prototype.__init90.call(this);_class11.prototype.__init91.call(this);_class11.prototype.__init92.call(this);_class11.prototype.__init93.call(this);_class11.prototype.__init94.call(this);_class11.prototype.__init95.call(this);_class11.prototype.__init96.call(this);_class11.prototype.__init97.call(this);_class11.prototype.__init98.call(this);_class11.prototype.__init99.call(this);_class11.prototype.__init100.call(this);_class11.prototype.__init101.call(this);_class11.prototype.__init102.call(this);_class11.prototype.__init103.call(this);
|
|
7401
7409
|
this.root = root;
|
|
7402
7410
|
const dev = typeof process !== "undefined" && _optionalChain([process, 'access', _371 => _371.env, 'optionalAccess', _372 => _372.NODE_ENV]) !== "production";
|
|
7403
|
-
this.history =
|
|
7411
|
+
this.history = _chunkYXQDCW4Ycjs.init.call(void 0, ensureGaps(doc), dev ? (d) => _chunkYXQDCW4Ycjs.firstViolation.call(void 0, _chunkYXQDCW4Ycjs.invariants.call(void 0, _chunk4TMHVNL6cjs.basicSchema, d)) : void 0);
|
|
7404
7412
|
this.opts = opts;
|
|
7405
7413
|
const exts = _nullishCoalesce(opts.extensions, () => ( markloomKit()));
|
|
7406
7414
|
this.resolved = resolve(exts);
|
|
@@ -7422,9 +7430,9 @@ var Editor = (_class11 = class {
|
|
|
7422
7430
|
this.imageControls = new ImageControls(root, {
|
|
7423
7431
|
doc: () => this.history.doc,
|
|
7424
7432
|
dispatch: (steps) => this.dispatch(steps),
|
|
7425
|
-
sel: () =>
|
|
7433
|
+
sel: () => _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc),
|
|
7426
7434
|
// atomSelect 变 → 重投影 data-selected(与 commentState 同构传 render)
|
|
7427
|
-
onAtomSelectChange: () => this.draw(_nullishCoalesce(
|
|
7435
|
+
onAtomSelectChange: () => this.draw(_nullishCoalesce(_chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0)))
|
|
7428
7436
|
});
|
|
7429
7437
|
this.mentionPops = new MentionPopovers({
|
|
7430
7438
|
root,
|
|
@@ -7440,7 +7448,7 @@ var Editor = (_class11 = class {
|
|
|
7440
7448
|
markSel: () => this.markSel(),
|
|
7441
7449
|
author: _nullishCoalesce(_optionalChain([opts, 'access', _376 => _376.comments, 'optionalAccess', _377 => _377.author]), () => ( (() => ({ id: "me", name: "\u6211" })))),
|
|
7442
7450
|
newId: newId3,
|
|
7443
|
-
redraw: () => this.draw(_nullishCoalesce(
|
|
7451
|
+
redraw: () => this.draw(_nullishCoalesce(_chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0))),
|
|
7444
7452
|
onChange: _optionalChain([opts, 'access', _378 => _378.comments, 'optionalAccess', _379 => _379.onChange]),
|
|
7445
7453
|
readonly: () => this.readonly
|
|
7446
7454
|
}, _nullishCoalesce(_optionalChain([opts, 'access', _380 => _380.comments, 'optionalAccess', _381 => _381.threads]), () => ( [])));
|
|
@@ -7452,8 +7460,8 @@ var Editor = (_class11 = class {
|
|
|
7452
7460
|
}
|
|
7453
7461
|
if (opts.ai) {
|
|
7454
7462
|
const cfg = typeof opts.ai === "object" ? opts.ai : {};
|
|
7455
|
-
this.aiCtl = new (0,
|
|
7456
|
-
stream:
|
|
7463
|
+
this.aiCtl = new (0, _chunkSLRD6FMPcjs.MarkloomAi)(() => this, {
|
|
7464
|
+
stream: _chunkSLRD6FMPcjs.createAiStream.call(void 0, cfg),
|
|
7457
7465
|
onError: _nullishCoalesce(cfg.onError, () => ( ((msg) => {
|
|
7458
7466
|
if (typeof window !== "undefined")
|
|
7459
7467
|
window.alert(msg);
|
|
@@ -7461,11 +7469,24 @@ var Editor = (_class11 = class {
|
|
|
7461
7469
|
onBusy: cfg.onBusy
|
|
7462
7470
|
});
|
|
7463
7471
|
}
|
|
7472
|
+
if (opts.collab) {
|
|
7473
|
+
this.collabCtl = _chunkAC5E42NHcjs.connectCollab.call(void 0,
|
|
7474
|
+
{ ...opts.collab, seed: _nullishCoalesce(opts.collab.seed, () => ( doc)) },
|
|
7475
|
+
{
|
|
7476
|
+
onDoc: (d) => this.replaceDoc(d),
|
|
7477
|
+
onRemote: (steps) => this.applyRemote(steps),
|
|
7478
|
+
onError: (msg) => {
|
|
7479
|
+
if (typeof console !== "undefined")
|
|
7480
|
+
console.warn("[markloom collab]", msg);
|
|
7481
|
+
}
|
|
7482
|
+
}
|
|
7483
|
+
);
|
|
7484
|
+
}
|
|
7464
7485
|
const host = {
|
|
7465
7486
|
root,
|
|
7466
7487
|
doc: () => this.history.doc,
|
|
7467
7488
|
dispatch: (steps, sel) => this.dispatch(steps, sel),
|
|
7468
|
-
sel: () =>
|
|
7489
|
+
sel: () => _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc),
|
|
7469
7490
|
markSel: () => this.markSel(),
|
|
7470
7491
|
insertImage: (idx) => this.slashInsertImage(idx),
|
|
7471
7492
|
insertMath: (idx) => this.slashInsertMath(idx),
|
|
@@ -7526,6 +7547,8 @@ var Editor = (_class11 = class {
|
|
|
7526
7547
|
_optionalChain([this, 'access', _393 => _393.commentPanel, 'optionalAccess', _394 => _394.destroy, 'call', _395 => _395()]);
|
|
7527
7548
|
_optionalChain([this, 'access', _396 => _396.tocPanel, 'optionalAccess', _397 => _397.destroy, 'call', _398 => _398()]);
|
|
7528
7549
|
_optionalChain([this, 'access', _399 => _399.aiCtl, 'optionalAccess', _400 => _400.destroy, 'call', _401 => _401()]);
|
|
7550
|
+
_optionalChain([this, 'access', _402 => _402.collabCtl, 'optionalAccess', _403 => _403.close, 'call', _404 => _404()]);
|
|
7551
|
+
this.collabCtl = null;
|
|
7529
7552
|
this.aiCtl = null;
|
|
7530
7553
|
for (const d of this.decorations)
|
|
7531
7554
|
d.destroy();
|
|
@@ -7535,11 +7558,15 @@ var Editor = (_class11 = class {
|
|
|
7535
7558
|
get ai() {
|
|
7536
7559
|
return this.aiCtl;
|
|
7537
7560
|
}
|
|
7561
|
+
/** 协作客户端(opts.collab 启用时) */
|
|
7562
|
+
get collab() {
|
|
7563
|
+
return this.collabCtl;
|
|
7564
|
+
}
|
|
7538
7565
|
openAi(mode) {
|
|
7539
|
-
_optionalChain([this, 'access',
|
|
7566
|
+
_optionalChain([this, 'access', _405 => _405.aiCtl, 'optionalAccess', _406 => _406.openAtFocus, 'call', _407 => _407(mode)]);
|
|
7540
7567
|
}
|
|
7541
7568
|
stopAi() {
|
|
7542
|
-
_optionalChain([this, 'access',
|
|
7569
|
+
_optionalChain([this, 'access', _408 => _408.aiCtl, 'optionalAccess', _409 => _409.stop, 'call', _410 => _410()]);
|
|
7543
7570
|
}
|
|
7544
7571
|
get doc() {
|
|
7545
7572
|
return this.history.doc;
|
|
@@ -7552,17 +7579,17 @@ var Editor = (_class11 = class {
|
|
|
7552
7579
|
// 运行时切显隐符(tiptap show/hide/toggleInvisibleCharacters 对位)。纯重绘,model 不动。
|
|
7553
7580
|
setInvisibleCharacters(visible) {
|
|
7554
7581
|
this.invisible = visible;
|
|
7555
|
-
this.draw(_nullishCoalesce(
|
|
7582
|
+
this.draw(_nullishCoalesce(_chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), () => ( void 0)));
|
|
7556
7583
|
}
|
|
7557
7584
|
get invisibleCharacters() {
|
|
7558
7585
|
return this.invisible;
|
|
7559
7586
|
}
|
|
7560
7587
|
// 当前评论线程(侧信道);未启用评论时空数组。
|
|
7561
7588
|
get comments() {
|
|
7562
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
7589
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _411 => _411.commentPanel, 'optionalAccess', _412 => _412.getThreads, 'call', _413 => _413()]), () => ( []));
|
|
7563
7590
|
}
|
|
7564
7591
|
setComments(threads) {
|
|
7565
|
-
_optionalChain([this, 'access',
|
|
7592
|
+
_optionalChain([this, 'access', _414 => _414.commentPanel, 'optionalAccess', _415 => _415.setThreads, 'call', _416 => _416(threads)]);
|
|
7566
7593
|
}
|
|
7567
7594
|
get readonly() {
|
|
7568
7595
|
return this.opts.editable === false;
|
|
@@ -7580,28 +7607,28 @@ var Editor = (_class11 = class {
|
|
|
7580
7607
|
blockRenderers: this.resolved.blockRenderers,
|
|
7581
7608
|
renderMath: this.opts.renderMath,
|
|
7582
7609
|
invisibleCharacters: this.invisible,
|
|
7583
|
-
commentState: _optionalChain([this, 'access',
|
|
7610
|
+
commentState: _optionalChain([this, 'access', _417 => _417.commentPanel, 'optionalAccess', _418 => _418.renderState, 'call', _419 => _419()]),
|
|
7584
7611
|
atomSelect: this.imageControls.selectCtx()
|
|
7585
7612
|
}), this.root);
|
|
7586
7613
|
stripStrayNodes(this.root.querySelector(".markloom-doc"));
|
|
7587
7614
|
if (restore)
|
|
7588
|
-
|
|
7615
|
+
_chunkSLRD6FMPcjs.writeSelection.call(void 0, this.root, this.history.doc, restore);
|
|
7589
7616
|
this.root.dispatchEvent(new Event("markloom-redraw", { bubbles: true }));
|
|
7590
7617
|
this.syncPlaceholder();
|
|
7591
7618
|
}
|
|
7592
7619
|
// 空块提示(不进 model):空 paragraph → opts.placeholder(slash 引导);
|
|
7593
7620
|
// 空 heading → 类型名 H1…H6(飞书/Notion 式)。空文档常显;光标落空块时也显。
|
|
7594
|
-
|
|
7621
|
+
__init88() {this.syncPlaceholder = () => {
|
|
7595
7622
|
if (this.composing || this.readonly)
|
|
7596
7623
|
return;
|
|
7597
|
-
const docEl =
|
|
7624
|
+
const docEl = _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root);
|
|
7598
7625
|
for (const el2 of docEl.querySelectorAll("[data-placeholder]"))
|
|
7599
7626
|
el2.removeAttribute("data-placeholder");
|
|
7600
7627
|
const kids = this.history.doc.children;
|
|
7601
|
-
const isEmptyLeafBlock = (n, type) => !
|
|
7628
|
+
const isEmptyLeafBlock = (n, type) => !_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.type === type && n.children.length > 0 && n.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text === "");
|
|
7602
7629
|
const labelOf = (n) => {
|
|
7603
7630
|
if (n.type === "heading") {
|
|
7604
|
-
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
7631
|
+
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access', _420 => _420.attrs, 'optionalAccess', _421 => _421.depth]), () => ( 1))), 1), 6);
|
|
7605
7632
|
return `H${d}`;
|
|
7606
7633
|
}
|
|
7607
7634
|
if (n.type === "paragraph" && this.opts.placeholder)
|
|
@@ -7610,7 +7637,7 @@ var Editor = (_class11 = class {
|
|
|
7610
7637
|
};
|
|
7611
7638
|
let idx = null;
|
|
7612
7639
|
let text = null;
|
|
7613
|
-
if (kids.length === 1 && !
|
|
7640
|
+
if (kids.length === 1 && !_chunkGQ2HHRGIcjs.isText.call(void 0, kids[0])) {
|
|
7614
7641
|
const lab = labelOf(kids[0]);
|
|
7615
7642
|
if (lab && (isEmptyLeafBlock(kids[0], "paragraph") || isEmptyLeafBlock(kids[0], "heading"))) {
|
|
7616
7643
|
idx = 0;
|
|
@@ -7618,7 +7645,7 @@ var Editor = (_class11 = class {
|
|
|
7618
7645
|
}
|
|
7619
7646
|
}
|
|
7620
7647
|
if (idx == null) {
|
|
7621
|
-
const sel =
|
|
7648
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7622
7649
|
if (sel) {
|
|
7623
7650
|
const a = sel.anchor.path;
|
|
7624
7651
|
const h13 = sel.head.path;
|
|
@@ -7626,7 +7653,7 @@ var Editor = (_class11 = class {
|
|
|
7626
7653
|
if (collapsed) {
|
|
7627
7654
|
const i = a[0];
|
|
7628
7655
|
const b = kids[i];
|
|
7629
|
-
if (b && !
|
|
7656
|
+
if (b && !_chunkGQ2HHRGIcjs.isText.call(void 0, b)) {
|
|
7630
7657
|
const lab = labelOf(b);
|
|
7631
7658
|
if (lab && (isEmptyLeafBlock(b, "paragraph") || isEmptyLeafBlock(b, "heading"))) {
|
|
7632
7659
|
idx = i;
|
|
@@ -7638,75 +7665,107 @@ var Editor = (_class11 = class {
|
|
|
7638
7665
|
}
|
|
7639
7666
|
if (idx == null || text == null)
|
|
7640
7667
|
return;
|
|
7641
|
-
const el =
|
|
7668
|
+
const el = _chunkSLRD6FMPcjs.elementChildren.call(void 0, docEl)[idx];
|
|
7642
7669
|
if (el)
|
|
7643
7670
|
el.setAttribute("data-placeholder", text);
|
|
7644
7671
|
}}
|
|
7645
7672
|
dispatch(steps, selectionAfter) {
|
|
7646
7673
|
if (steps.length === 0)
|
|
7647
7674
|
return;
|
|
7648
|
-
const after =
|
|
7675
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7649
7676
|
const batch = steps.concat(gapSteps(after));
|
|
7650
|
-
this.history =
|
|
7677
|
+
this.history = _chunkYXQDCW4Ycjs.commit.call(void 0, this.history, batch);
|
|
7651
7678
|
this.draw(selectionAfter);
|
|
7652
|
-
_optionalChain([this, 'access',
|
|
7679
|
+
_optionalChain([this, 'access', _422 => _422.opts, 'access', _423 => _423.onChange, 'optionalCall', _424 => _424(this.history.doc)]);
|
|
7680
|
+
if (!this.applyingRemote)
|
|
7681
|
+
_optionalChain([this, 'access', _425 => _425.collabCtl, 'optionalAccess', _426 => _426.push, 'call', _427 => _427(batch)]);
|
|
7653
7682
|
}
|
|
7654
7683
|
// AI 流式 / 事务内续写:并入 past 最后一条,一次 undo 回退整笔事务。
|
|
7655
7684
|
dispatchStream(steps, selectionAfter) {
|
|
7656
7685
|
if (steps.length === 0)
|
|
7657
7686
|
return;
|
|
7658
|
-
const after =
|
|
7687
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7659
7688
|
const batch = steps.concat(gapSteps(after));
|
|
7660
|
-
this.history =
|
|
7689
|
+
this.history = _chunkYXQDCW4Ycjs.amend.call(void 0, this.history, batch);
|
|
7661
7690
|
this.draw(selectionAfter);
|
|
7662
|
-
_optionalChain([this, 'access',
|
|
7691
|
+
_optionalChain([this, 'access', _428 => _428.opts, 'access', _429 => _429.onChange, 'optionalCall', _430 => _430(this.history.doc)]);
|
|
7692
|
+
if (!this.applyingRemote)
|
|
7693
|
+
_optionalChain([this, 'access', _431 => _431.collabCtl, 'optionalAccess', _432 => _432.push, 'call', _433 => _433(batch)]);
|
|
7694
|
+
}
|
|
7695
|
+
/** 远端协作 op:写入 model 但不上行 */
|
|
7696
|
+
applyRemote(steps, selectionAfter) {
|
|
7697
|
+
if (steps.length === 0)
|
|
7698
|
+
return;
|
|
7699
|
+
this.applyingRemote = true;
|
|
7700
|
+
try {
|
|
7701
|
+
const after = _chunk4TMHVNL6cjs.applyAll.call(void 0, this.history.doc, steps);
|
|
7702
|
+
const batch = steps.concat(gapSteps(after));
|
|
7703
|
+
this.history = _chunkYXQDCW4Ycjs.commit.call(void 0, this.history, batch);
|
|
7704
|
+
this.draw(selectionAfter);
|
|
7705
|
+
_optionalChain([this, 'access', _434 => _434.opts, 'access', _435 => _435.onChange, 'optionalCall', _436 => _436(this.history.doc)]);
|
|
7706
|
+
} finally {
|
|
7707
|
+
this.applyingRemote = false;
|
|
7708
|
+
}
|
|
7709
|
+
}
|
|
7710
|
+
/** 权威快照替换(welcome/resync);清空本地 undo 栈 */
|
|
7711
|
+
replaceDoc(doc) {
|
|
7712
|
+
const dev = typeof process !== "undefined" && _optionalChain([process, 'access', _437 => _437.env, 'optionalAccess', _438 => _438.NODE_ENV]) !== "production";
|
|
7713
|
+
this.history = _chunkYXQDCW4Ycjs.init.call(void 0, ensureGaps(doc), dev ? (d) => _chunkYXQDCW4Ycjs.firstViolation.call(void 0, _chunkYXQDCW4Ycjs.invariants.call(void 0, _chunk4TMHVNL6cjs.basicSchema, d)) : void 0);
|
|
7714
|
+
this.draw();
|
|
7715
|
+
_optionalChain([this, 'access', _439 => _439.opts, 'access', _440 => _440.onChange, 'optionalCall', _441 => _441(this.history.doc)]);
|
|
7663
7716
|
}
|
|
7664
7717
|
/** 回退一笔 history(AI 事务 discard = undo 整笔) */
|
|
7665
7718
|
undo() {
|
|
7666
|
-
const
|
|
7719
|
+
const last = this.history.past[this.history.past.length - 1];
|
|
7720
|
+
const next = _chunkYXQDCW4Ycjs.undo.call(void 0, this.history);
|
|
7667
7721
|
if (next === this.history)
|
|
7668
7722
|
return false;
|
|
7669
7723
|
this.history = next;
|
|
7670
7724
|
this.draw();
|
|
7671
|
-
_optionalChain([this, 'access',
|
|
7725
|
+
_optionalChain([this, 'access', _442 => _442.opts, 'access', _443 => _443.onChange, 'optionalCall', _444 => _444(this.history.doc)]);
|
|
7726
|
+
if (!this.applyingRemote && last)
|
|
7727
|
+
_optionalChain([this, 'access', _445 => _445.collabCtl, 'optionalAccess', _446 => _446.push, 'call', _447 => _447(last.inverse)]);
|
|
7672
7728
|
return true;
|
|
7673
7729
|
}
|
|
7674
7730
|
redo() {
|
|
7675
|
-
const
|
|
7731
|
+
const fut = this.history.future[0];
|
|
7732
|
+
const next = _chunkYXQDCW4Ycjs.redo.call(void 0, this.history);
|
|
7676
7733
|
if (next === this.history)
|
|
7677
7734
|
return false;
|
|
7678
7735
|
this.history = next;
|
|
7679
7736
|
this.draw();
|
|
7680
|
-
_optionalChain([this, 'access',
|
|
7737
|
+
_optionalChain([this, 'access', _448 => _448.opts, 'access', _449 => _449.onChange, 'optionalCall', _450 => _450(this.history.doc)]);
|
|
7738
|
+
if (!this.applyingRemote && fut)
|
|
7739
|
+
_optionalChain([this, 'access', _451 => _451.collabCtl, 'optionalAccess', _452 => _452.push, 'call', _453 => _453(fut.steps)]);
|
|
7681
7740
|
return true;
|
|
7682
7741
|
}
|
|
7683
7742
|
/** 续写:当前块后插空段并流式灌入 */
|
|
7684
7743
|
aiContinue(blockId) {
|
|
7685
|
-
return
|
|
7744
|
+
return _chunkSLRD6FMPcjs.startAiWrite.call(void 0, this, "continue", blockId);
|
|
7686
7745
|
}
|
|
7687
7746
|
/** 改写:清空当前块再流式回填 */
|
|
7688
7747
|
aiRewrite(blockId) {
|
|
7689
|
-
return
|
|
7748
|
+
return _chunkSLRD6FMPcjs.startAiWrite.call(void 0, this, "rewrite", blockId);
|
|
7690
7749
|
}
|
|
7691
7750
|
// 组字开始:快照「这一刻的叶文本」作为 3-way merge 的 base。
|
|
7692
7751
|
// IME 改动 = diff(base, DOM落定文本);AI 并发改动 = diff(base, model现态)。两者都相对 base。
|
|
7693
|
-
|
|
7752
|
+
__init89() {this.onCompositionStart = () => {
|
|
7694
7753
|
this.composing = true;
|
|
7695
|
-
const sel =
|
|
7754
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7696
7755
|
if (!sel) {
|
|
7697
7756
|
this.composeBase = null;
|
|
7698
7757
|
return;
|
|
7699
7758
|
}
|
|
7700
7759
|
const leafPath = sel.head.path.slice(0, -1);
|
|
7701
|
-
const leaf =
|
|
7702
|
-
this.composeBase = { leafPath, text:
|
|
7760
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, leafPath);
|
|
7761
|
+
this.composeBase = { leafPath, text: _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "" };
|
|
7703
7762
|
}}
|
|
7704
7763
|
// task 勾选:独立 capture 处理器(见 onTaskCheck)。此处:链接打开 + callout/math/mention。
|
|
7705
|
-
|
|
7764
|
+
__init90() {this.onClick = (e) => {
|
|
7706
7765
|
const target = e.target;
|
|
7707
|
-
if (_optionalChain([target, 'optionalAccess',
|
|
7766
|
+
if (_optionalChain([target, 'optionalAccess', _454 => _454.closest, 'optionalCall', _455 => _455("[data-task-check]")]))
|
|
7708
7767
|
return;
|
|
7709
|
-
const a = _optionalChain([target, 'optionalAccess',
|
|
7768
|
+
const a = _optionalChain([target, 'optionalAccess', _456 => _456.closest, 'optionalCall', _457 => _457('a[data-mark="link"]')]);
|
|
7710
7769
|
if (a && this.root.contains(a)) {
|
|
7711
7770
|
const href = a.getAttribute("href");
|
|
7712
7771
|
if (href) {
|
|
@@ -7721,10 +7780,10 @@ var Editor = (_class11 = class {
|
|
|
7721
7780
|
}
|
|
7722
7781
|
if (this.readonly)
|
|
7723
7782
|
return;
|
|
7724
|
-
const aiAct = _optionalChain([target, 'optionalAccess',
|
|
7783
|
+
const aiAct = _optionalChain([target, 'optionalAccess', _458 => _458.closest, 'optionalCall', _459 => _459("[data-ai-act]")]);
|
|
7725
7784
|
if (aiAct && this.root.contains(aiAct) && this.aiCtl) {
|
|
7726
7785
|
const blockEl = aiAct.closest("[data-ai-block][data-block-id]");
|
|
7727
|
-
const id2 = _optionalChain([blockEl, 'optionalAccess',
|
|
7786
|
+
const id2 = _optionalChain([blockEl, 'optionalAccess', _460 => _460.getAttribute, 'call', _461 => _461("data-block-id")]);
|
|
7728
7787
|
const act = aiAct.getAttribute("data-ai-act");
|
|
7729
7788
|
if (id2 && act) {
|
|
7730
7789
|
e.preventDefault();
|
|
@@ -7733,9 +7792,9 @@ var Editor = (_class11 = class {
|
|
|
7733
7792
|
return;
|
|
7734
7793
|
}
|
|
7735
7794
|
}
|
|
7736
|
-
const chip = _optionalChain([target, 'optionalAccess',
|
|
7737
|
-
const mathEl = _optionalChain([target, 'optionalAccess',
|
|
7738
|
-
const menEl = _optionalChain([target, 'optionalAccess',
|
|
7795
|
+
const chip = _optionalChain([target, 'optionalAccess', _462 => _462.closest, 'optionalCall', _463 => _463("[data-callout-variant]")]);
|
|
7796
|
+
const mathEl = _optionalChain([target, 'optionalAccess', _464 => _464.closest, 'optionalCall', _465 => _465('[data-atom="math"]')]);
|
|
7797
|
+
const menEl = _optionalChain([target, 'optionalAccess', _466 => _466.closest, 'optionalCall', _467 => _467('[data-atom="mention"]')]);
|
|
7739
7798
|
const hit = _nullishCoalesce(_nullishCoalesce(chip, () => ( mathEl)), () => ( menEl));
|
|
7740
7799
|
if (!hit) {
|
|
7741
7800
|
this.pendingMarks = null;
|
|
@@ -7751,14 +7810,14 @@ var Editor = (_class11 = class {
|
|
|
7751
7810
|
this.openMentionPop(menEl);
|
|
7752
7811
|
return;
|
|
7753
7812
|
}
|
|
7754
|
-
const id = _optionalChain([hit, 'access',
|
|
7813
|
+
const id = _optionalChain([hit, 'access', _468 => _468.closest, 'call', _469 => _469("[data-block-id]"), 'optionalAccess', _470 => _470.getAttribute, 'call', _471 => _471("data-block-id")]);
|
|
7755
7814
|
if (!id)
|
|
7756
7815
|
return;
|
|
7757
|
-
const path =
|
|
7816
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id);
|
|
7758
7817
|
if (!path)
|
|
7759
7818
|
return;
|
|
7760
|
-
const node =
|
|
7761
|
-
if (
|
|
7819
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path);
|
|
7820
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
7762
7821
|
return;
|
|
7763
7822
|
if (chip && node.type === "callout") {
|
|
7764
7823
|
e.preventDefault();
|
|
@@ -7768,7 +7827,7 @@ var Editor = (_class11 = class {
|
|
|
7768
7827
|
}
|
|
7769
7828
|
}}
|
|
7770
7829
|
// 任务 checkbox:capture 阶段处理;li[data-task] 定位 list_item,乐观更新 UI 再 commit model。
|
|
7771
|
-
|
|
7830
|
+
__init91() {this.onTaskCheck = (e) => {
|
|
7772
7831
|
if (this.readonly)
|
|
7773
7832
|
return;
|
|
7774
7833
|
const t = e.target;
|
|
@@ -7785,8 +7844,8 @@ var Editor = (_class11 = class {
|
|
|
7785
7844
|
const path = pathOfTaskItem(this.history.doc, this.root, li);
|
|
7786
7845
|
if (!path)
|
|
7787
7846
|
return;
|
|
7788
|
-
const node =
|
|
7789
|
-
if (!node ||
|
|
7847
|
+
const node = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path);
|
|
7848
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "list_item" || _optionalChain([node, 'access', _472 => _472.attrs, 'optionalAccess', _473 => _473.checked]) == null)
|
|
7790
7849
|
return;
|
|
7791
7850
|
const next = !node.attrs.checked;
|
|
7792
7851
|
box.checked = next;
|
|
@@ -7799,21 +7858,21 @@ var Editor = (_class11 = class {
|
|
|
7799
7858
|
}}
|
|
7800
7859
|
openMentionPop(el) {
|
|
7801
7860
|
const blockEl = el.closest("[data-block-id]");
|
|
7802
|
-
const bid = _optionalChain([blockEl, 'optionalAccess',
|
|
7861
|
+
const bid = _optionalChain([blockEl, 'optionalAccess', _474 => _474.getAttribute, 'call', _475 => _475("data-block-id")]);
|
|
7803
7862
|
if (!bid)
|
|
7804
7863
|
return;
|
|
7805
|
-
const blockPath =
|
|
7864
|
+
const blockPath = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, bid);
|
|
7806
7865
|
if (!blockPath)
|
|
7807
7866
|
return;
|
|
7808
|
-
const block =
|
|
7809
|
-
if (
|
|
7867
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
7868
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block)
|
|
7810
7869
|
return;
|
|
7811
7870
|
const leafKey = el.getAttribute("data-leaf");
|
|
7812
7871
|
const leafIdx = leafKey != null && leafKey !== "" ? Number(leafKey) : -1;
|
|
7813
7872
|
if (leafIdx < 0 || leafIdx >= block.children.length)
|
|
7814
7873
|
return;
|
|
7815
7874
|
const atom = block.children[leafIdx];
|
|
7816
|
-
if (
|
|
7875
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "mention")
|
|
7817
7876
|
return;
|
|
7818
7877
|
const a = _nullishCoalesce(atom.attrs, () => ( {}));
|
|
7819
7878
|
const rect = el.getBoundingClientRect();
|
|
@@ -7824,7 +7883,7 @@ var Editor = (_class11 = class {
|
|
|
7824
7883
|
return;
|
|
7825
7884
|
}
|
|
7826
7885
|
const id = String(_nullishCoalesce(a.id, () => ( "")));
|
|
7827
|
-
const fromHost = _optionalChain([this, 'access',
|
|
7886
|
+
const fromHost = _optionalChain([this, 'access', _476 => _476.opts, 'access', _477 => _477.mentionProfile, 'optionalCall', _478 => _478(id)]);
|
|
7828
7887
|
const profile = _nullishCoalesce(fromHost, () => ( {
|
|
7829
7888
|
id,
|
|
7830
7889
|
name: typeof a.label === "string" ? a.label : id
|
|
@@ -7836,11 +7895,11 @@ var Editor = (_class11 = class {
|
|
|
7836
7895
|
return;
|
|
7837
7896
|
const blockPath = path.slice(0, -1);
|
|
7838
7897
|
const leafIdx = path[path.length - 1];
|
|
7839
|
-
const block =
|
|
7840
|
-
if (
|
|
7898
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
7899
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block || leafIdx >= block.children.length)
|
|
7841
7900
|
return;
|
|
7842
7901
|
const atom = block.children[leafIdx];
|
|
7843
|
-
if (
|
|
7902
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "mention")
|
|
7844
7903
|
return;
|
|
7845
7904
|
const children = block.children.slice();
|
|
7846
7905
|
const label = iso.includes("T") ? iso.replace("T", " ") : iso;
|
|
@@ -7850,7 +7909,7 @@ var Editor = (_class11 = class {
|
|
|
7850
7909
|
};
|
|
7851
7910
|
this.dispatch([{ kind: "replaceNode", path: blockPath, node: { ...block, children } }]);
|
|
7852
7911
|
}
|
|
7853
|
-
|
|
7912
|
+
__init92() {this.onBeforeInput = (e) => {
|
|
7854
7913
|
if (this.readonly || this.composing)
|
|
7855
7914
|
return;
|
|
7856
7915
|
const intent = intentOf(e.inputType);
|
|
@@ -7865,7 +7924,7 @@ var Editor = (_class11 = class {
|
|
|
7865
7924
|
}
|
|
7866
7925
|
if (this.atomBlockGuard(intent, _nullishCoalesce(e.data, () => ( "")), e))
|
|
7867
7926
|
return;
|
|
7868
|
-
const sel =
|
|
7927
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
7869
7928
|
if (!sel) {
|
|
7870
7929
|
e.preventDefault();
|
|
7871
7930
|
return;
|
|
@@ -7888,7 +7947,7 @@ var Editor = (_class11 = class {
|
|
|
7888
7947
|
/** caret 是否在 type=ai 块内;是则返该块,否则 null */
|
|
7889
7948
|
aiBlockAt(sel) {
|
|
7890
7949
|
const top = this.history.doc.children[sel.head.path[0]];
|
|
7891
|
-
if (!top ||
|
|
7950
|
+
if (!top || _chunkGQ2HHRGIcjs.isText.call(void 0, top) || top.type !== "ai")
|
|
7892
7951
|
return null;
|
|
7893
7952
|
return top;
|
|
7894
7953
|
}
|
|
@@ -7899,14 +7958,14 @@ var Editor = (_class11 = class {
|
|
|
7899
7958
|
if (!this.aiCtl)
|
|
7900
7959
|
return false;
|
|
7901
7960
|
const top = this.history.doc.children[sel.head.path[0]];
|
|
7902
|
-
if (top && !
|
|
7961
|
+
if (top && !_chunkGQ2HHRGIcjs.isText.call(void 0, top) && top.type === "paragraph" && _optionalChain([top, 'access', _479 => _479.attrs, 'optionalAccess', _480 => _480.aiDraft])) {
|
|
7903
7962
|
e.preventDefault();
|
|
7904
7963
|
return true;
|
|
7905
7964
|
}
|
|
7906
7965
|
const ai = this.aiBlockAt(sel);
|
|
7907
7966
|
if (!ai || !ai.id)
|
|
7908
7967
|
return false;
|
|
7909
|
-
const status = typeof _optionalChain([ai, 'access',
|
|
7968
|
+
const status = typeof _optionalChain([ai, 'access', _481 => _481.attrs, 'optionalAccess', _482 => _482.status]) === "string" ? ai.attrs.status : "compose";
|
|
7910
7969
|
if (status === "loading") {
|
|
7911
7970
|
e.preventDefault();
|
|
7912
7971
|
return true;
|
|
@@ -7931,8 +7990,8 @@ var Editor = (_class11 = class {
|
|
|
7931
7990
|
if (!collapsed)
|
|
7932
7991
|
return null;
|
|
7933
7992
|
const off = sel.head.path[sel.head.path.length - 1];
|
|
7934
|
-
const leaf =
|
|
7935
|
-
const len =
|
|
7993
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, sel.head.path.slice(0, -1));
|
|
7994
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0;
|
|
7936
7995
|
if (len === 0)
|
|
7937
7996
|
return null;
|
|
7938
7997
|
return { atStart: off === 0, atEnd: off === len };
|
|
@@ -7968,10 +8027,10 @@ var Editor = (_class11 = class {
|
|
|
7968
8027
|
const rel = path.slice(1);
|
|
7969
8028
|
const doc = this.history.doc;
|
|
7970
8029
|
const block = doc.children[topIdx];
|
|
7971
|
-
if (!block ||
|
|
8030
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
7972
8031
|
return null;
|
|
7973
|
-
const startRel =
|
|
7974
|
-
const endRel =
|
|
8032
|
+
const startRel = _chunk4TMHVNL6cjs.firstLeafPath.call(void 0, block).concat(0);
|
|
8033
|
+
const endRel = _chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, block);
|
|
7975
8034
|
const eq = (a, b) => a.length === b.length && a.every((s, i) => s === b[i]);
|
|
7976
8035
|
const atStart = dir === "back" && eq(rel, startRel);
|
|
7977
8036
|
const atEnd = dir === "fwd" && eq(rel, endRel);
|
|
@@ -7981,7 +8040,7 @@ var Editor = (_class11 = class {
|
|
|
7981
8040
|
// 顶层第 idx 块若是图/表 atom → {控制器, id};否则 null。atomAtEdge(字符口径)与竖直键(视觉口径)共用。
|
|
7982
8041
|
atomAt(idx) {
|
|
7983
8042
|
const neighbor = this.history.doc.children[idx];
|
|
7984
|
-
if (!neighbor ||
|
|
8043
|
+
if (!neighbor || _chunkGQ2HHRGIcjs.isText.call(void 0, neighbor) || !neighbor.id)
|
|
7985
8044
|
return null;
|
|
7986
8045
|
const ctrl = this.atomControls(neighbor.type);
|
|
7987
8046
|
return ctrl ? { ctrl, id: neighbor.id } : null;
|
|
@@ -7999,7 +8058,7 @@ var Editor = (_class11 = class {
|
|
|
7999
8058
|
const caret3 = range.getBoundingClientRect();
|
|
8000
8059
|
if (caret3.width === 0 && caret3.height === 0)
|
|
8001
8060
|
return false;
|
|
8002
|
-
const blockEl =
|
|
8061
|
+
const blockEl = _chunkSLRD6FMPcjs.elementChildren.call(void 0, _chunkSLRD6FMPcjs.rootEl.call(void 0, this.root))[topIdx];
|
|
8003
8062
|
if (!blockEl)
|
|
8004
8063
|
return false;
|
|
8005
8064
|
const box = blockEl.getBoundingClientRect();
|
|
@@ -8019,7 +8078,7 @@ var Editor = (_class11 = class {
|
|
|
8019
8078
|
return null;
|
|
8020
8079
|
const topIdx = path[0];
|
|
8021
8080
|
const block = this.history.doc.children[topIdx];
|
|
8022
|
-
if (!block ||
|
|
8081
|
+
if (!block || _chunkGQ2HHRGIcjs.isText.call(void 0, block))
|
|
8023
8082
|
return null;
|
|
8024
8083
|
if (!this.onEdgeVisualLine(topIdx, dir))
|
|
8025
8084
|
return null;
|
|
@@ -8063,7 +8122,7 @@ var Editor = (_class11 = class {
|
|
|
8063
8122
|
const only = doc.children.length === 1;
|
|
8064
8123
|
if (isTable) {
|
|
8065
8124
|
const caret4 = this.neighborCaret(idx, only ? [idx] : null);
|
|
8066
|
-
this.dispatch([
|
|
8125
|
+
this.dispatch([_chunk4TMHVNL6cjs.deleteTableBlock.call(void 0, [idx], doc)], caret4);
|
|
8067
8126
|
return true;
|
|
8068
8127
|
}
|
|
8069
8128
|
const insert = only ? [{ type: "paragraph", id: newId3(), children: [{ text: "" }] }] : [];
|
|
@@ -8104,30 +8163,30 @@ var Editor = (_class11 = class {
|
|
|
8104
8163
|
return at([...fallbackIdx, 0, 0]);
|
|
8105
8164
|
const doc = this.history.doc;
|
|
8106
8165
|
const prev = doc.children[removedIdx - 1];
|
|
8107
|
-
if (prev && !
|
|
8108
|
-
return at([removedIdx - 1, ...
|
|
8166
|
+
if (prev && !_chunkGQ2HHRGIcjs.isText.call(void 0, prev))
|
|
8167
|
+
return at([removedIdx - 1, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, prev)]);
|
|
8109
8168
|
const next = doc.children[removedIdx + 1];
|
|
8110
|
-
if (next && !
|
|
8111
|
-
return at([removedIdx, ...
|
|
8169
|
+
if (next && !_chunkGQ2HHRGIcjs.isText.call(void 0, next))
|
|
8170
|
+
return at([removedIdx, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, next), 0]);
|
|
8112
8171
|
return at([Math.max(0, removedIdx - 1), 0, 0]);
|
|
8113
8172
|
}
|
|
8114
8173
|
isCodeBlock(blockPath) {
|
|
8115
8174
|
if (blockPath.length === 0)
|
|
8116
8175
|
return false;
|
|
8117
|
-
const block =
|
|
8118
|
-
return !
|
|
8176
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8177
|
+
return !_chunkGQ2HHRGIcjs.isText.call(void 0, block) && block.type === "code";
|
|
8119
8178
|
}
|
|
8120
8179
|
// caret 落在 list_item 段落内:tail = [paraIdx, leafIdx, char],去掉得 itemPath。塌缩选区才接管(indent/outdent 是块搬家)。
|
|
8121
8180
|
inListItem(path) {
|
|
8122
8181
|
if (path.length < 4)
|
|
8123
8182
|
return false;
|
|
8124
|
-
const item =
|
|
8125
|
-
return !!item && !
|
|
8183
|
+
const item = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, path.slice(0, -3));
|
|
8184
|
+
return !!item && !_chunkGQ2HHRGIcjs.isText.call(void 0, item) && item.type === "list_item";
|
|
8126
8185
|
}
|
|
8127
8186
|
// intentOf 不认的删变体(word/line 删)在代码块边界的守卫:跨块涉码 / 塌缩在 code 对应边 → preventDefault(挡浏览器并块)。
|
|
8128
8187
|
// 非边界(代码块中段)不接管,放行——与 codeBlockGuard 的「只收边界、放行叶内」一致,不过度拦。
|
|
8129
8188
|
codeBoundaryDelete(dir, e) {
|
|
8130
|
-
const sel =
|
|
8189
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8131
8190
|
if (!sel)
|
|
8132
8191
|
return;
|
|
8133
8192
|
if (this.straddlesAtom(sel)) {
|
|
@@ -8150,7 +8209,7 @@ var Editor = (_class11 = class {
|
|
|
8150
8209
|
// 到 cell/文档真边界 mapInput 才返 null)——「删空本行/本段后再删能退上去」的语义由此路径提供。
|
|
8151
8210
|
// 一律 preventDefault(否则浏览器原生删破 DOM≡doc,后续 readSelection 读脏 DOM 返 null → 打字被吞)。
|
|
8152
8211
|
wordLineDelete(dir, inputType, e) {
|
|
8153
|
-
const sel =
|
|
8212
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8154
8213
|
if (!sel) {
|
|
8155
8214
|
e.preventDefault();
|
|
8156
8215
|
return;
|
|
@@ -8176,18 +8235,18 @@ var Editor = (_class11 = class {
|
|
|
8176
8235
|
// 正解是 3-way merge:base=组字前叶文本快照。IME 改动 = diff(base, DOM 落定文本)——
|
|
8177
8236
|
// 这是「相对 base 的纯 IME 局部编辑」,不含 AI 的并发改动。把它作为 Step 施加到 model 当前态,
|
|
8178
8237
|
// AI 在同段别处的改动得以保留(diff(model,DOM) 会把 AI 改动误当删除——那是错的)。
|
|
8179
|
-
|
|
8238
|
+
__init93() {this.onCompositionEnd = () => {
|
|
8180
8239
|
this.composing = false;
|
|
8181
8240
|
const base = this.composeBase;
|
|
8182
8241
|
this.composeBase = null;
|
|
8183
|
-
const sel =
|
|
8242
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8184
8243
|
if (!sel || !base) {
|
|
8185
8244
|
this.draw();
|
|
8186
8245
|
return;
|
|
8187
8246
|
}
|
|
8188
8247
|
const leafPath = base.leafPath;
|
|
8189
|
-
const dom =
|
|
8190
|
-
const domText = (_optionalChain([dom, 'optionalAccess',
|
|
8248
|
+
const dom = _chunkSLRD6FMPcjs.pointToDom.call(void 0, this.root, this.history.doc, { path: leafPath.concat(0) });
|
|
8249
|
+
const domText = (_optionalChain([dom, 'optionalAccess', _483 => _483.node]) && isDomText(dom.node) ? _nullishCoalesce(dom.node.textContent, () => ( "")) : "").replaceAll("\u200B", "");
|
|
8191
8250
|
const edit = diffSpan(base.text, domText);
|
|
8192
8251
|
if (!edit) {
|
|
8193
8252
|
this.draw();
|
|
@@ -8204,7 +8263,7 @@ var Editor = (_class11 = class {
|
|
|
8204
8263
|
}
|
|
8205
8264
|
this.dispatch(steps, caretAfter(leafPath, edit.at + edit.insert.length));
|
|
8206
8265
|
}}
|
|
8207
|
-
|
|
8266
|
+
__init94() {this.onKeyDown = (e) => {
|
|
8208
8267
|
if (this.readonly)
|
|
8209
8268
|
return;
|
|
8210
8269
|
const mod2 = e.metaKey || e.ctrlKey;
|
|
@@ -8233,7 +8292,7 @@ var Editor = (_class11 = class {
|
|
|
8233
8292
|
const doc = this.history.doc;
|
|
8234
8293
|
const nbrIdx = exitBack ? idx - 1 : idx + 1;
|
|
8235
8294
|
const nbr = doc.children[nbrIdx];
|
|
8236
|
-
if (nbr && !
|
|
8295
|
+
if (nbr && !_chunkGQ2HHRGIcjs.isText.call(void 0, nbr)) {
|
|
8237
8296
|
const nbrCtrl = nbr.id ? this.atomControls(nbr.type) : null;
|
|
8238
8297
|
if (nbrCtrl && nbrCtrl.selectByBlockId(nbr.id)) {
|
|
8239
8298
|
if (nbrCtrl !== selCtrl)
|
|
@@ -8241,8 +8300,8 @@ var Editor = (_class11 = class {
|
|
|
8241
8300
|
return;
|
|
8242
8301
|
}
|
|
8243
8302
|
selCtrl.clearSelected();
|
|
8244
|
-
const target = exitBack ? [nbrIdx, ...
|
|
8245
|
-
|
|
8303
|
+
const target = exitBack ? [nbrIdx, ..._chunk4TMHVNL6cjs.lastLeafEnd.call(void 0, nbr)] : [nbrIdx, ..._chunk4TMHVNL6cjs.firstLeafPath.call(void 0, nbr), 0];
|
|
8304
|
+
_chunkSLRD6FMPcjs.writeSelection.call(void 0, this.root, doc, { anchor: { path: target }, head: { path: target } });
|
|
8246
8305
|
return;
|
|
8247
8306
|
}
|
|
8248
8307
|
selCtrl.clearSelected();
|
|
@@ -8250,7 +8309,7 @@ var Editor = (_class11 = class {
|
|
|
8250
8309
|
}
|
|
8251
8310
|
}
|
|
8252
8311
|
if ((exitBack || exitFwd) && !mod2 && !e.shiftKey && !selCtrl) {
|
|
8253
|
-
const sel =
|
|
8312
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8254
8313
|
if (sel) {
|
|
8255
8314
|
const dir = exitBack ? "back" : "fwd";
|
|
8256
8315
|
const hit = _nullishCoalesce(this.atomAtEdge(sel, dir), () => ( (e.key === "ArrowUp" || e.key === "ArrowDown" ? this.atomAtEdgeVertical(sel, dir) : null)));
|
|
@@ -8270,7 +8329,7 @@ var Editor = (_class11 = class {
|
|
|
8270
8329
|
return;
|
|
8271
8330
|
}
|
|
8272
8331
|
if (e.key === "Tab" && !e.shiftKey && !mod2) {
|
|
8273
|
-
const sel =
|
|
8332
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8274
8333
|
if (sel && this.isCodeBlock(sel.head.path.slice(0, -2))) {
|
|
8275
8334
|
const result = mapInput(this.history.doc, "insertText", " ", sel, newId3);
|
|
8276
8335
|
if (result) {
|
|
@@ -8288,13 +8347,13 @@ var Editor = (_class11 = class {
|
|
|
8288
8347
|
}
|
|
8289
8348
|
}
|
|
8290
8349
|
if (e.key === "Tab" && e.shiftKey && !mod2) {
|
|
8291
|
-
const sel =
|
|
8292
|
-
const blockPath = _optionalChain([sel, 'optionalAccess',
|
|
8350
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8351
|
+
const blockPath = _optionalChain([sel, 'optionalAccess', _484 => _484.head, 'access', _485 => _485.path, 'access', _486 => _486.slice, 'call', _487 => _487(0, -2)]);
|
|
8293
8352
|
if (sel && blockPath && this.isCodeBlock(blockPath)) {
|
|
8294
8353
|
e.preventDefault();
|
|
8295
8354
|
const leafPath = sel.head.path.slice(0, -1);
|
|
8296
|
-
const leaf =
|
|
8297
|
-
if (
|
|
8355
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, leafPath);
|
|
8356
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, leaf)) {
|
|
8298
8357
|
const caret3 = sel.head.path[sel.head.path.length - 1];
|
|
8299
8358
|
const lineStart = leaf.text.lastIndexOf("\n", caret3 - 1) + 1;
|
|
8300
8359
|
const remove = unindentLen(leaf.text, lineStart);
|
|
@@ -8325,7 +8384,7 @@ var Editor = (_class11 = class {
|
|
|
8325
8384
|
e.preventDefault();
|
|
8326
8385
|
let rect = new DOMRect(0, 0, 0, 0);
|
|
8327
8386
|
try {
|
|
8328
|
-
const r = _optionalChain([document, 'access',
|
|
8387
|
+
const r = _optionalChain([document, 'access', _488 => _488.getSelection, 'call', _489 => _489(), 'optionalAccess', _490 => _490.getRangeAt, 'call', _491 => _491(0), 'optionalAccess', _492 => _492.getBoundingClientRect, 'call', _493 => _493()]);
|
|
8329
8388
|
if (r && (r.width || r.height))
|
|
8330
8389
|
rect = r;
|
|
8331
8390
|
} catch (e10) {
|
|
@@ -8341,15 +8400,15 @@ var Editor = (_class11 = class {
|
|
|
8341
8400
|
}
|
|
8342
8401
|
const cmd = mod2 ? this.resolved.keymap[chord(e)] : void 0;
|
|
8343
8402
|
if (cmd) {
|
|
8344
|
-
const r = cmd({ doc: this.history.doc, sel:
|
|
8403
|
+
const r = cmd({ doc: this.history.doc, sel: _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc), markSel: this.markSel(), promptLink: this.opts.promptLink });
|
|
8345
8404
|
if (!r)
|
|
8346
8405
|
return;
|
|
8347
8406
|
e.preventDefault();
|
|
8348
8407
|
if ("history" in r) {
|
|
8349
8408
|
this.pendingMarks = null;
|
|
8350
|
-
this.history = r.history === "undo" ?
|
|
8409
|
+
this.history = r.history === "undo" ? _chunkYXQDCW4Ycjs.undo.call(void 0, this.history) : _chunkYXQDCW4Ycjs.redo.call(void 0, this.history);
|
|
8351
8410
|
this.draw();
|
|
8352
|
-
_optionalChain([this, 'access',
|
|
8411
|
+
_optionalChain([this, 'access', _494 => _494.opts, 'access', _495 => _495.onChange, 'optionalCall', _496 => _496(this.history.doc)]);
|
|
8353
8412
|
return;
|
|
8354
8413
|
}
|
|
8355
8414
|
if ("pendingToggle" in r) {
|
|
@@ -8365,7 +8424,7 @@ var Editor = (_class11 = class {
|
|
|
8365
8424
|
return;
|
|
8366
8425
|
}
|
|
8367
8426
|
if (mod2 && !e.shiftKey && (e.key === "a" || e.key === "A")) {
|
|
8368
|
-
const sel =
|
|
8427
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8369
8428
|
if (!sel)
|
|
8370
8429
|
return;
|
|
8371
8430
|
const blockPath = sel.head.path.slice(0, -2);
|
|
@@ -8373,7 +8432,7 @@ var Editor = (_class11 = class {
|
|
|
8373
8432
|
return;
|
|
8374
8433
|
e.preventDefault();
|
|
8375
8434
|
const len = leafText2(this.history.doc, [...blockPath, 0]).length;
|
|
8376
|
-
|
|
8435
|
+
_chunkSLRD6FMPcjs.writeSelection.call(void 0,
|
|
8377
8436
|
this.root,
|
|
8378
8437
|
this.history.doc,
|
|
8379
8438
|
{ anchor: { path: [...blockPath, 0, 0] }, head: { path: [...blockPath, 0, len] } }
|
|
@@ -8384,7 +8443,7 @@ var Editor = (_class11 = class {
|
|
|
8384
8443
|
// 代码块 model 是单纯文本叶,docToMd 只读首叶裸 text——加 mark 轻则渲幽灵 strong/save 后消失,
|
|
8385
8444
|
// 重则 toggleMark 把单叶按区间切成多叶,leaves(n)[0] 只取首叶 → 存盘丢码。marks 在代码块无语义,直接挡。
|
|
8386
8445
|
markSel() {
|
|
8387
|
-
const sel =
|
|
8446
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8388
8447
|
if (!sel)
|
|
8389
8448
|
return null;
|
|
8390
8449
|
if (this.isCodeBlock(sel.anchor.path.slice(0, -2)) || this.isCodeBlock(sel.head.path.slice(0, -2)))
|
|
@@ -8392,37 +8451,37 @@ var Editor = (_class11 = class {
|
|
|
8392
8451
|
return sel;
|
|
8393
8452
|
}
|
|
8394
8453
|
// 复制/剪切/粘贴:选区 ⟷ markdown。md 是 markloom 的唯一真值,剪贴板也走 md,跨编辑器/外部可读。
|
|
8395
|
-
|
|
8396
|
-
const sel =
|
|
8454
|
+
__init95() {this.onCopy = (e) => {
|
|
8455
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8397
8456
|
if (!sel)
|
|
8398
8457
|
return;
|
|
8399
8458
|
const md = serializeSelection(this.history.doc, sel);
|
|
8400
8459
|
if (!md)
|
|
8401
8460
|
return;
|
|
8402
8461
|
e.preventDefault();
|
|
8403
|
-
_optionalChain([e, 'access',
|
|
8462
|
+
_optionalChain([e, 'access', _497 => _497.clipboardData, 'optionalAccess', _498 => _498.setData, 'call', _499 => _499("text/plain", md)]);
|
|
8404
8463
|
}}
|
|
8405
|
-
|
|
8464
|
+
__init96() {this.onCut = (e) => {
|
|
8406
8465
|
if (this.readonly) {
|
|
8407
8466
|
e.preventDefault();
|
|
8408
8467
|
return;
|
|
8409
8468
|
}
|
|
8410
8469
|
e.preventDefault();
|
|
8411
|
-
const sel =
|
|
8470
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8412
8471
|
if (!sel)
|
|
8413
8472
|
return;
|
|
8414
8473
|
const md = serializeSelection(this.history.doc, sel);
|
|
8415
8474
|
if (!md)
|
|
8416
8475
|
return;
|
|
8417
|
-
_optionalChain([e, 'access',
|
|
8476
|
+
_optionalChain([e, 'access', _500 => _500.clipboardData, 'optionalAccess', _501 => _501.setData, 'call', _502 => _502("text/plain", md)]);
|
|
8418
8477
|
const del = mapInput(this.history.doc, "deleteForward", "", sel, newId3);
|
|
8419
8478
|
if (del)
|
|
8420
8479
|
this.dispatch(del.steps, del.selection);
|
|
8421
8480
|
}}
|
|
8422
|
-
|
|
8481
|
+
__init97() {this.onPaste = (e) => {
|
|
8423
8482
|
if (this.readonly || this.composing)
|
|
8424
8483
|
return;
|
|
8425
|
-
const sel =
|
|
8484
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8426
8485
|
if (!sel)
|
|
8427
8486
|
return;
|
|
8428
8487
|
const inCode = this.isCodeBlock(sel.head.path.slice(0, -2));
|
|
@@ -8433,15 +8492,15 @@ var Editor = (_class11 = class {
|
|
|
8433
8492
|
this.insertImageFile(file, sel);
|
|
8434
8493
|
return;
|
|
8435
8494
|
}
|
|
8436
|
-
const htmlUrl = imgSrcFromHtml(_optionalChain([e, 'access',
|
|
8437
|
-
if (htmlUrl && !_optionalChain([e, 'access',
|
|
8495
|
+
const htmlUrl = imgSrcFromHtml(_optionalChain([e, 'access', _503 => _503.clipboardData, 'optionalAccess', _504 => _504.getData, 'call', _505 => _505("text/html")]));
|
|
8496
|
+
if (htmlUrl && !_optionalChain([e, 'access', _506 => _506.clipboardData, 'optionalAccess', _507 => _507.getData, 'call', _508 => _508("text/plain")])) {
|
|
8438
8497
|
e.preventDefault();
|
|
8439
8498
|
this.insertImageUrl(htmlUrl, sel);
|
|
8440
8499
|
return;
|
|
8441
8500
|
}
|
|
8442
8501
|
}
|
|
8443
|
-
const raw = _nullishCoalesce(_optionalChain([e, 'access',
|
|
8444
|
-
const html = _nullishCoalesce(_optionalChain([e, 'access',
|
|
8502
|
+
const raw = _nullishCoalesce(_optionalChain([e, 'access', _509 => _509.clipboardData, 'optionalAccess', _510 => _510.getData, 'call', _511 => _511("text/plain")]), () => ( ""));
|
|
8503
|
+
const html = _nullishCoalesce(_optionalChain([e, 'access', _512 => _512.clipboardData, 'optionalAccess', _513 => _513.getData, 'call', _514 => _514("text/html")]), () => ( ""));
|
|
8445
8504
|
if (inCode) {
|
|
8446
8505
|
if (!raw && !html)
|
|
8447
8506
|
return;
|
|
@@ -8471,8 +8530,8 @@ var Editor = (_class11 = class {
|
|
|
8471
8530
|
}
|
|
8472
8531
|
}
|
|
8473
8532
|
if (html) {
|
|
8474
|
-
const blocks =
|
|
8475
|
-
if (blocks &&
|
|
8533
|
+
const blocks = _chunk4TMHVNL6cjs.htmlToBlocks.call(void 0, html);
|
|
8534
|
+
if (blocks && _chunk4TMHVNL6cjs.isRichHtmlBlocks.call(void 0, blocks)) {
|
|
8476
8535
|
e.preventDefault();
|
|
8477
8536
|
const result2 = mapPasteBlocks(this.history.doc, sel, blocks, newId3);
|
|
8478
8537
|
if (result2)
|
|
@@ -8508,12 +8567,12 @@ var Editor = (_class11 = class {
|
|
|
8508
8567
|
}
|
|
8509
8568
|
// 斜杠 /image:开原生文件选择,选中后把触发段(blockIdx,含 `/image`)整块替换成 image atom。
|
|
8510
8569
|
// 复用 onImage 上传钩子(未注入退回 data: URL)。取消选择 → 不动 model。
|
|
8511
|
-
|
|
8570
|
+
__init98() {this.slashInsertImage = (blockIdx) => {
|
|
8512
8571
|
const input = this.root.ownerDocument.createElement("input");
|
|
8513
8572
|
input.type = "file";
|
|
8514
8573
|
input.accept = "image/*";
|
|
8515
8574
|
input.onchange = () => {
|
|
8516
|
-
const file = _optionalChain([input, 'access',
|
|
8575
|
+
const file = _optionalChain([input, 'access', _515 => _515.files, 'optionalAccess', _516 => _516[0]]);
|
|
8517
8576
|
if (!file)
|
|
8518
8577
|
return;
|
|
8519
8578
|
const to = this.opts.onImage ? this.opts.onImage(file) : new Promise((resolve2, reject) => {
|
|
@@ -8531,7 +8590,7 @@ var Editor = (_class11 = class {
|
|
|
8531
8590
|
input.click();
|
|
8532
8591
|
}}
|
|
8533
8592
|
// 斜杠 /math → 当前段换成含 math atom 的段(display block)。
|
|
8534
|
-
|
|
8593
|
+
__init99() {this.slashInsertMath = (blockIdx) => {
|
|
8535
8594
|
void askInput({
|
|
8536
8595
|
title: "\u63D2\u5165\u516C\u5F0F",
|
|
8537
8596
|
description: "\u8F93\u5165 LaTeX\uFF0C\u4F8B\u5982 E=mc^2 \u6216 \\frac{a}{b}",
|
|
@@ -8549,13 +8608,13 @@ var Editor = (_class11 = class {
|
|
|
8549
8608
|
});
|
|
8550
8609
|
}}
|
|
8551
8610
|
// 斜杠 /youtube|/twitch|/audio|/file → embed 块。file/audio 走文件选择;yt/twitch 弹 URL。
|
|
8552
|
-
|
|
8611
|
+
__init100() {this.slashInsertEmbed = (blockIdx, kind) => {
|
|
8553
8612
|
if (kind === "file" || kind === "audio") {
|
|
8554
8613
|
const input = this.root.ownerDocument.createElement("input");
|
|
8555
8614
|
input.type = "file";
|
|
8556
8615
|
input.accept = kind === "audio" ? "audio/*" : "*/*";
|
|
8557
8616
|
input.onchange = () => {
|
|
8558
|
-
const file = _optionalChain([input, 'access',
|
|
8617
|
+
const file = _optionalChain([input, 'access', _517 => _517.files, 'optionalAccess', _518 => _518[0]]);
|
|
8559
8618
|
if (!file)
|
|
8560
8619
|
return;
|
|
8561
8620
|
const to = this.opts.onImage ? this.opts.onImage(file) : new Promise((resolve2, reject) => {
|
|
@@ -8603,23 +8662,23 @@ var Editor = (_class11 = class {
|
|
|
8603
8662
|
// 点 math atom → 弹层改 latex。叶路径:块 data-block-id + data-leaf 下标。
|
|
8604
8663
|
editMathAtom(mathEl) {
|
|
8605
8664
|
const blockEl = mathEl.closest("[data-block-id]");
|
|
8606
|
-
const id = _optionalChain([blockEl, 'optionalAccess',
|
|
8665
|
+
const id = _optionalChain([blockEl, 'optionalAccess', _519 => _519.getAttribute, 'call', _520 => _520("data-block-id")]);
|
|
8607
8666
|
if (!id)
|
|
8608
8667
|
return;
|
|
8609
|
-
const blockPath =
|
|
8668
|
+
const blockPath = _chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id);
|
|
8610
8669
|
if (!blockPath)
|
|
8611
8670
|
return;
|
|
8612
|
-
const block =
|
|
8613
|
-
if (
|
|
8671
|
+
const block = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8672
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, block) || !block)
|
|
8614
8673
|
return;
|
|
8615
8674
|
const leafKey = mathEl.getAttribute("data-leaf");
|
|
8616
8675
|
const leafIdx = leafKey != null && leafKey !== "" ? Number(leafKey) : -1;
|
|
8617
8676
|
if (leafIdx < 0 || leafIdx >= block.children.length)
|
|
8618
8677
|
return;
|
|
8619
8678
|
const atom = block.children[leafIdx];
|
|
8620
|
-
if (
|
|
8679
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, atom) || atom.type !== "math")
|
|
8621
8680
|
return;
|
|
8622
|
-
const cur = String(_nullishCoalesce(_optionalChain([atom, 'access',
|
|
8681
|
+
const cur = String(_nullishCoalesce(_optionalChain([atom, 'access', _521 => _521.attrs, 'optionalAccess', _522 => _522.latex]), () => ( "")));
|
|
8623
8682
|
void askInput({
|
|
8624
8683
|
title: "\u7F16\u8F91\u516C\u5F0F",
|
|
8625
8684
|
description: "\u4FEE\u6539 LaTeX \u6E90\u7801",
|
|
@@ -8630,11 +8689,11 @@ var Editor = (_class11 = class {
|
|
|
8630
8689
|
}).then((next) => {
|
|
8631
8690
|
if (next == null || next.trim() === cur)
|
|
8632
8691
|
return;
|
|
8633
|
-
const b =
|
|
8634
|
-
if (
|
|
8692
|
+
const b = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath);
|
|
8693
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, b) || !b || leafIdx >= b.children.length)
|
|
8635
8694
|
return;
|
|
8636
8695
|
const a = b.children[leafIdx];
|
|
8637
|
-
if (
|
|
8696
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, a) || a.type !== "math")
|
|
8638
8697
|
return;
|
|
8639
8698
|
const children = b.children.slice();
|
|
8640
8699
|
children[leafIdx] = { ...a, attrs: { ...a.attrs, latex: next.trim() } };
|
|
@@ -8646,13 +8705,13 @@ var Editor = (_class11 = class {
|
|
|
8646
8705
|
if (sel.anchor.path[0] !== sel.head.path[0] || sel.head.path.length !== 3)
|
|
8647
8706
|
return false;
|
|
8648
8707
|
const b = this.history.doc.children[sel.head.path[0]];
|
|
8649
|
-
if (!b ||
|
|
8708
|
+
if (!b || _chunkGQ2HHRGIcjs.isText.call(void 0, b) || b.type !== "paragraph")
|
|
8650
8709
|
return false;
|
|
8651
|
-
return b.children.length === 1 &&
|
|
8710
|
+
return b.children.length === 1 && _chunkGQ2HHRGIcjs.isText.call(void 0, b.children[0]) && b.children[0].text === "";
|
|
8652
8711
|
}
|
|
8653
8712
|
// floating menu(+ 柄):在 blockIdx 下方插一个只含 `/` 的空段,光标落 `/` 之后,派 input 事件唤起斜杠菜单。
|
|
8654
8713
|
// 复用 SlashMenu 的 onInput 触发路径(菜单只认「行首 `/`」),FloatingMenu 不需自己造菜单——+ 只是「打 /」的快捷。
|
|
8655
|
-
|
|
8714
|
+
__init101() {this.insertBelow = (blockIdx) => {
|
|
8656
8715
|
if (this.readonly)
|
|
8657
8716
|
return;
|
|
8658
8717
|
const id = newId3();
|
|
@@ -8678,37 +8737,37 @@ var Editor = (_class11 = class {
|
|
|
8678
8737
|
isAtomBlock(blockPath) {
|
|
8679
8738
|
if (blockPath.length === 0)
|
|
8680
8739
|
return false;
|
|
8681
|
-
return isAtom(
|
|
8740
|
+
return isAtom(_chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, blockPath));
|
|
8682
8741
|
}
|
|
8683
8742
|
// 找到 head 路径上的 table 祖先 → 当前 (r,c) → nextCell → 把光标写到目标格首段首叶。
|
|
8684
8743
|
// caret 落在哪个表格的哪一格。沿 head 找第一个 type==='table' 祖先块 → {tablePath, table, r, c}。
|
|
8685
8744
|
tableCaret() {
|
|
8686
|
-
const sel =
|
|
8745
|
+
const sel = _chunkSLRD6FMPcjs.readSelection.call(void 0, this.root, this.history.doc);
|
|
8687
8746
|
if (!sel)
|
|
8688
8747
|
return null;
|
|
8689
8748
|
const head = sel.head.path;
|
|
8690
8749
|
let node = this.history.doc;
|
|
8691
8750
|
const tablePath = [];
|
|
8692
8751
|
for (let i = 0; i < head.length; i++) {
|
|
8693
|
-
if (
|
|
8752
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node) || !node.children[head[i]])
|
|
8694
8753
|
break;
|
|
8695
|
-
if (!
|
|
8754
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, node) && node.type === "table")
|
|
8696
8755
|
break;
|
|
8697
8756
|
tablePath.push(head[i]);
|
|
8698
8757
|
node = node.children[head[i]];
|
|
8699
8758
|
}
|
|
8700
|
-
const table =
|
|
8701
|
-
if (
|
|
8759
|
+
const table = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, tablePath);
|
|
8760
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, table) || table.type !== "table")
|
|
8702
8761
|
return null;
|
|
8703
|
-
const cur =
|
|
8762
|
+
const cur = _chunk4TMHVNL6cjs.caretCell.call(void 0, tablePath, table, head);
|
|
8704
8763
|
return cur ? { tablePath, table, r: cur.r, c: cur.c, head } : null;
|
|
8705
8764
|
}
|
|
8706
8765
|
tabInTable(dir) {
|
|
8707
8766
|
const loc = this.tableCaret();
|
|
8708
8767
|
if (!loc)
|
|
8709
8768
|
return false;
|
|
8710
|
-
const to =
|
|
8711
|
-
const at = { path:
|
|
8769
|
+
const to = _chunk4TMHVNL6cjs.nextCell.call(void 0, loc.table, loc.r, loc.c, dir);
|
|
8770
|
+
const at = { path: _chunk4TMHVNL6cjs.cellCaret.call(void 0, loc.tablePath, loc.table, to.r, to.c, 0) };
|
|
8712
8771
|
this.draw({ anchor: at, head: at });
|
|
8713
8772
|
return true;
|
|
8714
8773
|
}
|
|
@@ -8720,42 +8779,42 @@ var Editor = (_class11 = class {
|
|
|
8720
8779
|
return false;
|
|
8721
8780
|
if (dir === "left" || dir === "right") {
|
|
8722
8781
|
const off2 = loc.head[loc.head.length - 1];
|
|
8723
|
-
const leaf =
|
|
8724
|
-
const len =
|
|
8782
|
+
const leaf = _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, loc.head.slice(0, -1));
|
|
8783
|
+
const len = _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0;
|
|
8725
8784
|
if (dir === "left" ? off2 > 0 : off2 < len)
|
|
8726
8785
|
return false;
|
|
8727
8786
|
}
|
|
8728
|
-
const to =
|
|
8787
|
+
const to = _chunk4TMHVNL6cjs.arrowCell.call(void 0, loc.table, loc.r, loc.c, dir);
|
|
8729
8788
|
if (!to)
|
|
8730
8789
|
return false;
|
|
8731
|
-
const grid =
|
|
8790
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, loc.table);
|
|
8732
8791
|
const idx = grid.at(to.r, to.c);
|
|
8733
8792
|
const cellNode = loc.table.children[idx];
|
|
8734
8793
|
let off = 0;
|
|
8735
8794
|
if (dir === "left" && cellNode) {
|
|
8736
8795
|
const para = cellNode.children[0];
|
|
8737
|
-
const lf = para && !
|
|
8738
|
-
off = lf &&
|
|
8796
|
+
const lf = para && !_chunkGQ2HHRGIcjs.isText.call(void 0, para) ? para.children[0] : void 0;
|
|
8797
|
+
off = lf && _chunkGQ2HHRGIcjs.isText.call(void 0, lf) ? lf.text.length : 0;
|
|
8739
8798
|
}
|
|
8740
|
-
const at = { path:
|
|
8799
|
+
const at = { path: _chunk4TMHVNL6cjs.cellCaret.call(void 0, loc.tablePath, loc.table, to.r, to.c, off) };
|
|
8741
8800
|
this.draw({ anchor: at, head: at });
|
|
8742
8801
|
return true;
|
|
8743
8802
|
}
|
|
8744
8803
|
// 飞书式行列高亮:焦点落入某 cell → 同行同列所有 cell 加标记属性(主题给浅色背景)。
|
|
8745
8804
|
// 纯 DOM 投影,不碰 model:语义表格里 td 嵌在 tbody>tr 下,用后代选择器收(文档序即行优先);
|
|
8746
8805
|
// 列数从 tr 的 cell 数读(每行等列)。同表换格时 focusout 先清 focusin 再标,同帧内同步完成不闪。
|
|
8747
|
-
|
|
8806
|
+
__init102() {this.onFocusIn = (e) => {
|
|
8748
8807
|
if (!(e.target instanceof HTMLElement))
|
|
8749
8808
|
return;
|
|
8750
8809
|
const cell = e.target.closest(".markloom-cell");
|
|
8751
|
-
const table = _optionalChain([cell, 'optionalAccess',
|
|
8810
|
+
const table = _optionalChain([cell, 'optionalAccess', _523 => _523.closest, 'call', _524 => _524(".markloom-table")]);
|
|
8752
8811
|
if (!cell || !table)
|
|
8753
8812
|
return;
|
|
8754
8813
|
const id = table.getAttribute("data-block-id");
|
|
8755
|
-
const model = id ?
|
|
8756
|
-
if (!model ||
|
|
8814
|
+
const model = id ? _chunk4TMHVNL6cjs.nodeAt.call(void 0, this.history.doc, _nullishCoalesce(_chunk4TMHVNL6cjs.pathOfId.call(void 0, this.history.doc, id), () => ( []))) : null;
|
|
8815
|
+
if (!model || _chunkGQ2HHRGIcjs.isText.call(void 0, model) || model.type !== "table")
|
|
8757
8816
|
return;
|
|
8758
|
-
const grid =
|
|
8817
|
+
const grid = _chunk4TMHVNL6cjs.buildGrid.call(void 0, model);
|
|
8759
8818
|
const cells = Array.from(table.querySelectorAll(".markloom-cell"));
|
|
8760
8819
|
if (cells.length !== grid.anchors.length)
|
|
8761
8820
|
return;
|
|
@@ -8769,10 +8828,10 @@ var Editor = (_class11 = class {
|
|
|
8769
8828
|
el.toggleAttribute("data-highlight-col", sameCol);
|
|
8770
8829
|
});
|
|
8771
8830
|
}}
|
|
8772
|
-
|
|
8831
|
+
__init103() {this.onFocusOut = (e) => {
|
|
8773
8832
|
if (!(e.target instanceof HTMLElement))
|
|
8774
8833
|
return;
|
|
8775
|
-
const table = _optionalChain([e, 'access',
|
|
8834
|
+
const table = _optionalChain([e, 'access', _525 => _525.target, 'access', _526 => _526.closest, 'call', _527 => _527(".markloom-cell"), 'optionalAccess', _528 => _528.closest, 'call', _529 => _529(".markloom-table")]);
|
|
8776
8835
|
if (!table)
|
|
8777
8836
|
return;
|
|
8778
8837
|
table.querySelectorAll(".markloom-cell").forEach((el) => {
|
|
@@ -8810,12 +8869,12 @@ function intentOf(inputType) {
|
|
|
8810
8869
|
}
|
|
8811
8870
|
}
|
|
8812
8871
|
function newId3() {
|
|
8813
|
-
return _nullishCoalesce(_optionalChain([globalThis, 'access',
|
|
8872
|
+
return _nullishCoalesce(_optionalChain([globalThis, 'access', _530 => _530.crypto, 'optionalAccess', _531 => _531.randomUUID, 'optionalCall', _532 => _532()]), () => ( `b-${Math.random().toString(36).slice(2)}`));
|
|
8814
8873
|
}
|
|
8815
8874
|
function pathOfTaskItem(doc, root, li) {
|
|
8816
8875
|
const id = li.getAttribute("data-block-id");
|
|
8817
8876
|
if (id) {
|
|
8818
|
-
const p =
|
|
8877
|
+
const p = _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, id);
|
|
8819
8878
|
if (p)
|
|
8820
8879
|
return p;
|
|
8821
8880
|
}
|
|
@@ -8823,13 +8882,13 @@ function pathOfTaskItem(doc, root, li) {
|
|
|
8823
8882
|
if (!listEl)
|
|
8824
8883
|
return null;
|
|
8825
8884
|
const listId = listEl.getAttribute("data-block-id");
|
|
8826
|
-
const listPath = listId ?
|
|
8885
|
+
const listPath = listId ? _chunk4TMHVNL6cjs.pathOfId.call(void 0, doc, listId) : null;
|
|
8827
8886
|
if (!listPath)
|
|
8828
8887
|
return null;
|
|
8829
|
-
const list =
|
|
8830
|
-
if (!list ||
|
|
8888
|
+
const list = _chunk4TMHVNL6cjs.nodeAt.call(void 0, doc, listPath);
|
|
8889
|
+
if (!list || _chunkGQ2HHRGIcjs.isText.call(void 0, list) || list.type !== "list")
|
|
8831
8890
|
return null;
|
|
8832
|
-
const items =
|
|
8891
|
+
const items = _chunkSLRD6FMPcjs.elementChildren.call(void 0, listEl);
|
|
8833
8892
|
const idx = items.indexOf(li);
|
|
8834
8893
|
if (idx < 0 || idx >= list.children.length)
|
|
8835
8894
|
return null;
|
|
@@ -8904,7 +8963,7 @@ function imgSrcFromHtml(html) {
|
|
|
8904
8963
|
return null;
|
|
8905
8964
|
const body = new DOMParser().parseFromString(html, "text/html").body;
|
|
8906
8965
|
const imgs = body.querySelectorAll("img");
|
|
8907
|
-
if (imgs.length !== 1 || _optionalChain([body, 'access',
|
|
8966
|
+
if (imgs.length !== 1 || _optionalChain([body, 'access', _533 => _533.textContent, 'optionalAccess', _534 => _534.trim, 'call', _535 => _535()]))
|
|
8908
8967
|
return null;
|
|
8909
8968
|
return imgs[0].getAttribute("src");
|
|
8910
8969
|
}
|