markloom 0.5.0 → 0.6.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/PACKAGES.md +26 -0
- package/README.md +20 -2
- package/collab.md +44 -7
- package/dist/ai/index.cjs +4 -4
- package/dist/ai/index.d.cts +5 -4
- package/dist/ai/index.d.ts +5 -4
- package/dist/ai/index.js +3 -3
- package/dist/ai/theme.css +66 -102
- package/dist/{chunk-YJAWPRJW.cjs → chunk-ACFYBYZJ.cjs} +2817 -903
- package/dist/chunk-CGYCJORO.js +759 -0
- package/dist/chunk-EADZKEU4.cjs +498 -0
- package/dist/chunk-EJSFZHGT.js +24 -0
- package/dist/{chunk-SLRD6FMP.cjs → chunk-I5VK4U7J.cjs} +122 -73
- package/dist/{chunk-WUHTCCAE.js → chunk-KYZJIOOL.js} +2403 -489
- package/dist/chunk-QEVME6ZU.cjs +759 -0
- package/dist/{chunk-MFYF2A6U.js → chunk-SNFF6X45.js} +51 -1
- package/dist/{chunk-JMOJU5EU.js → chunk-TB2OY3D4.js} +69 -20
- package/dist/{chunk-4TMHVNL6.cjs → chunk-TWD5T4YC.cjs} +155 -105
- package/dist/{chunk-JS527FDV.cjs → chunk-U3JZDFL4.cjs} +49 -9
- package/dist/{chunk-RLTHVQNQ.js → chunk-VSBIMMI7.js} +45 -5
- package/dist/chunk-YBAT343I.js +498 -0
- package/dist/chunk-ZKQSQSSM.cjs +24 -0
- package/dist/{client-BNams4wv.d.cts → client-CLYq17SW.d.ts} +70 -7
- package/dist/{client-A0ZQJnyR.d.ts → client-DAth8pPq.d.cts} +70 -7
- package/dist/collab/index.cjs +22 -4
- package/dist/collab/index.d.cts +24 -3
- package/dist/collab/index.d.ts +24 -3
- package/dist/collab/index.js +24 -6
- package/dist/{controller-BkY1VPzc.d.ts → controller-6AJ36G52.d.ts} +108 -8
- package/dist/{controller-CVIZI--A.d.cts → controller-BIOO_XKJ.d.cts} +108 -8
- package/dist/index.cjs +57 -7
- package/dist/index.d.cts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +54 -4
- package/dist/io/index.cjs +1413 -0
- package/dist/io/index.d.cts +33 -0
- package/dist/io/index.d.ts +33 -0
- package/dist/io/index.js +1413 -0
- package/dist/react/index.cjs +8 -8
- package/dist/react/index.d.cts +5 -4
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +7 -7
- package/dist/{rebase-batch-8rL_aXEE.d.ts → rebase-batch-DlerAcFN.d.ts} +11 -9
- package/dist/{rebase-batch-bYnBJpRO.d.cts → rebase-batch-PjENQ742.d.cts} +11 -9
- package/dist/suggest-Bk4zLzuv.d.ts +120 -0
- package/dist/suggest-BkGGiPKA.d.cts +120 -0
- package/dist/types-COUweEav.d.cts +30 -0
- package/dist/types-COUweEav.d.ts +30 -0
- package/dist/versions-9mG1epfB.d.cts +51 -0
- package/dist/versions-Bubyo4pt.d.ts +51 -0
- package/dist/view/index.cjs +56 -12
- package/dist/view/index.d.cts +203 -11
- package/dist/view/index.d.ts +203 -11
- package/dist/view/index.js +52 -8
- package/dist/view/theme.css +1840 -1526
- package/io.md +38 -0
- package/package.json +21 -5
- package/dist/chunk-6DCI7AL3.js +0 -208
- package/dist/chunk-AC5E42NH.cjs +0 -208
- package/dist/chunk-GQ2HHRGI.cjs +0 -16
- package/dist/chunk-LA5SBCGQ.js +0 -16
- package/dist/chunk-LEYAQNJA.js +0 -220
- package/dist/chunk-YXQDCW4Y.cjs +0 -220
- package/dist/comments-DlExS6f-.d.cts +0 -43
- package/dist/comments-PhnR7Gkn.d.ts +0 -43
- package/dist/step-BrvHIK7O.d.cts +0 -65
- package/dist/step-BrvHIK7O.d.ts +0 -65
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkZKQSQSSMcjs = require('./chunk-ZKQSQSSM.cjs');
|
|
6
6
|
|
|
7
7
|
// src/tree/addr.ts
|
|
8
8
|
function resolve(doc, path) {
|
|
@@ -12,7 +12,7 @@ function resolve(doc, path) {
|
|
|
12
12
|
const indexInParent = [];
|
|
13
13
|
let cur = doc;
|
|
14
14
|
for (let i = 0; i < path.length - 1; i++) {
|
|
15
|
-
if (!
|
|
15
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, cur))
|
|
16
16
|
throw new Error(`path \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")} \u5728\u7B2C ${i} \u6BB5`);
|
|
17
17
|
parents.push(cur);
|
|
18
18
|
indexInParent.push(path[i]);
|
|
@@ -27,9 +27,9 @@ function resolve(doc, path) {
|
|
|
27
27
|
function firstLeafPath(block) {
|
|
28
28
|
for (let i = 0; i < block.children.length; i++) {
|
|
29
29
|
const c = block.children[i];
|
|
30
|
-
if (
|
|
30
|
+
if (_chunkZKQSQSSMcjs.isInlineAtom.call(void 0, c))
|
|
31
31
|
continue;
|
|
32
|
-
if (
|
|
32
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, c))
|
|
33
33
|
return [i];
|
|
34
34
|
return [i, ...firstLeafPath(c)];
|
|
35
35
|
}
|
|
@@ -39,7 +39,7 @@ function normalizeToLeaf(doc, path) {
|
|
|
39
39
|
const prefix = [];
|
|
40
40
|
let cur = doc;
|
|
41
41
|
for (let i = 0; i < path.length; i++) {
|
|
42
|
-
if (
|
|
42
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, cur)) {
|
|
43
43
|
return prefix.concat(Math.max(0, path[i]));
|
|
44
44
|
}
|
|
45
45
|
if (i === path.length - 1)
|
|
@@ -50,9 +50,9 @@ function normalizeToLeaf(doc, path) {
|
|
|
50
50
|
prefix.push(path[i]);
|
|
51
51
|
cur = child;
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
53
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, cur))
|
|
54
54
|
return prefix.concat(0);
|
|
55
|
-
if (
|
|
55
|
+
if (_chunkZKQSQSSMcjs.isInlineAtom.call(void 0, cur) && prefix.length >= 1) {
|
|
56
56
|
const parent = nodeAt(doc, prefix.slice(0, -1));
|
|
57
57
|
const idx = prefix[prefix.length - 1];
|
|
58
58
|
const base = prefix.slice(0, -1);
|
|
@@ -60,14 +60,14 @@ function normalizeToLeaf(doc, path) {
|
|
|
60
60
|
const prev = parent.children[idx - 1];
|
|
61
61
|
const next = parent.children[idx + 1];
|
|
62
62
|
if (preferNext) {
|
|
63
|
-
if (next &&
|
|
63
|
+
if (next && _chunkZKQSQSSMcjs.isText.call(void 0, next))
|
|
64
64
|
return base.concat(idx + 1, 0);
|
|
65
|
-
if (prev &&
|
|
65
|
+
if (prev && _chunkZKQSQSSMcjs.isText.call(void 0, prev))
|
|
66
66
|
return base.concat(idx - 1, prev.text.length);
|
|
67
67
|
} else {
|
|
68
|
-
if (prev &&
|
|
68
|
+
if (prev && _chunkZKQSQSSMcjs.isText.call(void 0, prev))
|
|
69
69
|
return base.concat(idx - 1, prev.text.length);
|
|
70
|
-
if (next &&
|
|
70
|
+
if (next && _chunkZKQSQSSMcjs.isText.call(void 0, next))
|
|
71
71
|
return base.concat(idx + 1, 0);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -76,10 +76,10 @@ function normalizeToLeaf(doc, path) {
|
|
|
76
76
|
const idx = prefix[prefix.length - 1];
|
|
77
77
|
const base = prefix.slice(0, -1);
|
|
78
78
|
const next = parent.children[idx + 1];
|
|
79
|
-
if (next && !
|
|
79
|
+
if (next && !_chunkZKQSQSSMcjs.isText.call(void 0, next))
|
|
80
80
|
return base.concat(idx + 1, firstLeafPath(next), 0);
|
|
81
81
|
const prev = parent.children[idx - 1];
|
|
82
|
-
if (prev && !
|
|
82
|
+
if (prev && !_chunkZKQSQSSMcjs.isText.call(void 0, prev))
|
|
83
83
|
return base.concat(idx - 1, lastLeafEnd(prev));
|
|
84
84
|
}
|
|
85
85
|
return prefix.concat(firstLeafPath(cur), 0);
|
|
@@ -87,9 +87,9 @@ function normalizeToLeaf(doc, path) {
|
|
|
87
87
|
function lastLeafEnd(block) {
|
|
88
88
|
for (let i = block.children.length - 1; i >= 0; i--) {
|
|
89
89
|
const last = block.children[i];
|
|
90
|
-
if (
|
|
90
|
+
if (_chunkZKQSQSSMcjs.isInlineAtom.call(void 0, last))
|
|
91
91
|
continue;
|
|
92
|
-
if (
|
|
92
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, last))
|
|
93
93
|
return [i, last.text.length];
|
|
94
94
|
return [i, ...lastLeafEnd(last)];
|
|
95
95
|
}
|
|
@@ -98,7 +98,7 @@ function lastLeafEnd(block) {
|
|
|
98
98
|
function nodeAt(doc, path) {
|
|
99
99
|
let cur = doc;
|
|
100
100
|
for (const seg of path) {
|
|
101
|
-
if (!
|
|
101
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, cur))
|
|
102
102
|
throw new Error(`nodeAt \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")}`);
|
|
103
103
|
const child = cur.children[seg];
|
|
104
104
|
if (!child)
|
|
@@ -109,7 +109,7 @@ function nodeAt(doc, path) {
|
|
|
109
109
|
}
|
|
110
110
|
function replaceAt(doc, path, next) {
|
|
111
111
|
if (path.length === 0) {
|
|
112
|
-
if (
|
|
112
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, next))
|
|
113
113
|
throw new Error("\u6839\u4E0D\u80FD\u662F\u6587\u672C\u53F6");
|
|
114
114
|
return next;
|
|
115
115
|
}
|
|
@@ -117,7 +117,7 @@ function replaceAt(doc, path, next) {
|
|
|
117
117
|
}
|
|
118
118
|
function spliceAt(doc, path, at, remove, insert) {
|
|
119
119
|
return update(doc, path, 0, (node) => {
|
|
120
|
-
if (!
|
|
120
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, node))
|
|
121
121
|
throw new Error("spliceAt \u76EE\u6807\u4E0D\u662F\u5143\u7D20");
|
|
122
122
|
const children = node.children.slice();
|
|
123
123
|
children.splice(at, remove, ...insert);
|
|
@@ -127,11 +127,11 @@ function spliceAt(doc, path, at, remove, insert) {
|
|
|
127
127
|
function update(node, path, depth, fn) {
|
|
128
128
|
if (depth === path.length) {
|
|
129
129
|
const r = fn(node);
|
|
130
|
-
if (
|
|
130
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, r))
|
|
131
131
|
throw new Error("update \u4E0D\u80FD\u628A\u5143\u7D20\u6362\u6210\u6587\u672C\u53F6");
|
|
132
132
|
return r;
|
|
133
133
|
}
|
|
134
|
-
if (!
|
|
134
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, node))
|
|
135
135
|
throw new Error(`update \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")}`);
|
|
136
136
|
const idx = path[depth];
|
|
137
137
|
const children = node.children.slice();
|
|
@@ -141,7 +141,7 @@ function update(node, path, depth, fn) {
|
|
|
141
141
|
function updateChild(node, path, depth, fn) {
|
|
142
142
|
if (depth === path.length)
|
|
143
143
|
return fn(node);
|
|
144
|
-
if (!
|
|
144
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, node))
|
|
145
145
|
throw new Error(`update \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")}`);
|
|
146
146
|
const idx = path[depth];
|
|
147
147
|
const children = node.children.slice();
|
|
@@ -154,10 +154,10 @@ function tableShape(table) {
|
|
|
154
154
|
return { rows: Number(_nullishCoalesce(_optionalChain([table, 'access', _2 => _2.attrs, 'optionalAccess', _3 => _3.rows]), () => ( 0))), cols: Number(_nullishCoalesce(_optionalChain([table, 'access', _4 => _4.attrs, 'optionalAccess', _5 => _5.cols]), () => ( 0))) };
|
|
155
155
|
}
|
|
156
156
|
function colspanOf(cell) {
|
|
157
|
-
return
|
|
157
|
+
return _chunkZKQSQSSMcjs.isText.call(void 0, cell) ? 1 : Math.max(1, Number(_nullishCoalesce(_optionalChain([cell, 'access', _6 => _6.attrs, 'optionalAccess', _7 => _7.colspan]), () => ( 1))));
|
|
158
158
|
}
|
|
159
159
|
function rowspanOf(cell) {
|
|
160
|
-
return
|
|
160
|
+
return _chunkZKQSQSSMcjs.isText.call(void 0, cell) ? 1 : Math.max(1, Number(_nullishCoalesce(_optionalChain([cell, 'access', _8 => _8.attrs, 'optionalAccess', _9 => _9.rowspan]), () => ( 1))));
|
|
161
161
|
}
|
|
162
162
|
function buildGrid(table) {
|
|
163
163
|
const { rows, cols } = tableShape(table);
|
|
@@ -215,10 +215,10 @@ function makeTable(id, rows, cols) {
|
|
|
215
215
|
function cellText(table, r, c) {
|
|
216
216
|
const idx = buildGrid(table).at(r, c);
|
|
217
217
|
const cell = idx < 0 ? void 0 : table.children[idx];
|
|
218
|
-
if (!cell ||
|
|
218
|
+
if (!cell || _chunkZKQSQSSMcjs.isText.call(void 0, cell) || _chunkZKQSQSSMcjs.isText.call(void 0, cell.children[0]))
|
|
219
219
|
return "";
|
|
220
220
|
const leaf = cell.children[0].children[0];
|
|
221
|
-
return leaf &&
|
|
221
|
+
return leaf && _chunkZKQSQSSMcjs.isText.call(void 0, leaf) ? leaf.text : "";
|
|
222
222
|
}
|
|
223
223
|
function nextCell(table, r, c, dir) {
|
|
224
224
|
const grid = buildGrid(table);
|
|
@@ -250,7 +250,7 @@ function arrowCell(table, r, c, dir) {
|
|
|
250
250
|
return { r: a.r, c: a.c };
|
|
251
251
|
}
|
|
252
252
|
function withSpan(cell, cs, rs) {
|
|
253
|
-
if (
|
|
253
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, cell))
|
|
254
254
|
return cell;
|
|
255
255
|
const attrs = { ...cell.attrs };
|
|
256
256
|
if (cs > 1)
|
|
@@ -457,7 +457,7 @@ function mergeCells(table, tablePath, r1, c1, r2, c2) {
|
|
|
457
457
|
for (const idx of covered.slice(1)) {
|
|
458
458
|
const cell = table.children[idx];
|
|
459
459
|
for (const p of cell.children) {
|
|
460
|
-
if (!
|
|
460
|
+
if (!_chunkZKQSQSSMcjs.isText.call(void 0, p) && p.type === "paragraph" && isNonEmptyPara(p))
|
|
461
461
|
paras.push(p);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
@@ -467,7 +467,7 @@ function mergeCells(table, tablePath, r1, c1, r2, c2) {
|
|
|
467
467
|
return { kind: "replaceNode", path: tablePath, node: { ...table, children } };
|
|
468
468
|
}
|
|
469
469
|
function isNonEmptyPara(p) {
|
|
470
|
-
return p.children.some((c) =>
|
|
470
|
+
return p.children.some((c) => _chunkZKQSQSSMcjs.isText.call(void 0, c) && c.text !== "");
|
|
471
471
|
}
|
|
472
472
|
function splitCell(table, tablePath, r, c) {
|
|
473
473
|
const grid = buildGrid(table);
|
|
@@ -505,7 +505,7 @@ function setCellStyle(table, tablePath, r, c, style) {
|
|
|
505
505
|
function clearCells(table, tablePath, rect) {
|
|
506
506
|
const grid = buildGrid(table);
|
|
507
507
|
const children = table.children.map((cell, i) => {
|
|
508
|
-
if (
|
|
508
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, cell) || cell.type !== "table_cell")
|
|
509
509
|
return cell;
|
|
510
510
|
const m = grid.cellOf(i);
|
|
511
511
|
const hit = m.r <= rect.r2 && m.r + m.rowspan - 1 >= rect.r1 && m.c <= rect.c2 && m.c + m.colspan - 1 >= rect.c1;
|
|
@@ -558,7 +558,7 @@ function deleteTableBlock(tablePath, doc) {
|
|
|
558
558
|
}
|
|
559
559
|
function tableAt(doc, tablePath) {
|
|
560
560
|
const n = nodeAt(doc, tablePath);
|
|
561
|
-
return !
|
|
561
|
+
return !_chunkZKQSQSSMcjs.isText.call(void 0, n) && n.type === "table" ? n : null;
|
|
562
562
|
}
|
|
563
563
|
function checkTable(table) {
|
|
564
564
|
const out = [];
|
|
@@ -577,12 +577,12 @@ function checkTable(table) {
|
|
|
577
577
|
void covered;
|
|
578
578
|
}
|
|
579
579
|
table.children.forEach((cell, i) => {
|
|
580
|
-
if (
|
|
580
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, cell) || cell.type !== "table_cell") {
|
|
581
581
|
out.push(`children[${i}] \u4E0D\u662F table_cell`);
|
|
582
582
|
return;
|
|
583
583
|
}
|
|
584
584
|
for (const child of cell.children) {
|
|
585
|
-
if (!
|
|
585
|
+
if (!_chunkZKQSQSSMcjs.isText.call(void 0, child) && child.type !== "paragraph")
|
|
586
586
|
out.push(`children[${i}] cell \u5185\u975E paragraph: ${child.type}`);
|
|
587
587
|
}
|
|
588
588
|
});
|
|
@@ -855,7 +855,7 @@ function phrasingToNodes(nodes, md) {
|
|
|
855
855
|
const atom = open.includes("data-math") ? mathFromHtml(open) : mentionFromHtml(open);
|
|
856
856
|
if (!atom)
|
|
857
857
|
continue;
|
|
858
|
-
const dropEmpty = (ns) => ns.filter((n) => !(
|
|
858
|
+
const dropEmpty = (ns) => ns.filter((n) => !(_chunkZKQSQSSMcjs.isText.call(void 0, n) && n.text === "" && !_optionalChain([n, 'access', _47 => _47.marks, 'optionalAccess', _48 => _48.length])));
|
|
859
859
|
return [
|
|
860
860
|
...i > 0 ? dropEmpty(phrasingToNodes(nodes.slice(0, i), md)) : [],
|
|
861
861
|
atom,
|
|
@@ -872,7 +872,7 @@ function phrasingWithBreaks(nodes, md) {
|
|
|
872
872
|
return;
|
|
873
873
|
const leaves2 = phrasingToText(run, [], md);
|
|
874
874
|
for (const l of leaves2) {
|
|
875
|
-
if (
|
|
875
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, l) && l.text === "" && !_optionalChain([l, 'access', _49 => _49.marks, 'optionalAccess', _50 => _50.length]) && out.length)
|
|
876
876
|
continue;
|
|
877
877
|
out.push(l);
|
|
878
878
|
}
|
|
@@ -1319,7 +1319,7 @@ function elevateInlineImages(block) {
|
|
|
1319
1319
|
buf = [];
|
|
1320
1320
|
};
|
|
1321
1321
|
for (const c of block.children) {
|
|
1322
|
-
if (
|
|
1322
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, c)) {
|
|
1323
1323
|
const im = _optionalChain([c, 'access', _81 => _81.marks, 'optionalAccess', _82 => _82.find, 'call', _83 => _83((m) => m.name === "image")]);
|
|
1324
1324
|
if (im) {
|
|
1325
1325
|
flush();
|
|
@@ -1432,7 +1432,7 @@ function domNodesToBlocks(nodes) {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
const paras = cellDomToParas(el);
|
|
1434
1434
|
for (const para of paras) {
|
|
1435
|
-
if (para.children.length === 1 &&
|
|
1435
|
+
if (para.children.length === 1 && _chunkZKQSQSSMcjs.isText.call(void 0, para.children[0]) && !para.children[0].text.trim() && !para.children[0].marks)
|
|
1436
1436
|
continue;
|
|
1437
1437
|
out.push(...elevateInlineImages(para));
|
|
1438
1438
|
}
|
|
@@ -1452,11 +1452,58 @@ function isRichHtmlBlocks(blocks) {
|
|
|
1452
1452
|
const b = blocks[0];
|
|
1453
1453
|
if (b.type !== "paragraph" && b.type !== "heading")
|
|
1454
1454
|
return true;
|
|
1455
|
-
return b.children.some((c) => !
|
|
1455
|
+
return b.children.some((c) => !_chunkZKQSQSSMcjs.isText.call(void 0, c) || (_nullishCoalesce(_optionalChain([c, 'access', _84 => _84.marks, 'optionalAccess', _85 => _85.length]), () => ( 0))) > 0 || c.text.includes("\n"));
|
|
1456
|
+
}
|
|
1457
|
+
function isPlainTransportHtml(blocks) {
|
|
1458
|
+
if (!blocks.length)
|
|
1459
|
+
return false;
|
|
1460
|
+
for (const b of blocks) {
|
|
1461
|
+
if (b.type === "code")
|
|
1462
|
+
continue;
|
|
1463
|
+
if (b.type === "raw")
|
|
1464
|
+
continue;
|
|
1465
|
+
if (b.type !== "paragraph")
|
|
1466
|
+
return false;
|
|
1467
|
+
if (paraHasRichInline(b))
|
|
1468
|
+
return false;
|
|
1469
|
+
}
|
|
1470
|
+
return true;
|
|
1471
|
+
}
|
|
1472
|
+
function paraHasRichInline(b) {
|
|
1473
|
+
for (const c of b.children) {
|
|
1474
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, c)) {
|
|
1475
|
+
if ((_nullishCoalesce(_optionalChain([c, 'access', _86 => _86.marks, 'optionalAccess', _87 => _87.length]), () => ( 0))) > 0)
|
|
1476
|
+
return true;
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, c))
|
|
1480
|
+
return true;
|
|
1481
|
+
if (c.type === "hard_break")
|
|
1482
|
+
continue;
|
|
1483
|
+
return true;
|
|
1484
|
+
}
|
|
1485
|
+
return false;
|
|
1486
|
+
}
|
|
1487
|
+
function mdStructureBeatsTransport(plain) {
|
|
1488
|
+
const blocks = mdToDoc(plain).children.filter((c) => _chunkZKQSQSSMcjs.isElement.call(void 0, c));
|
|
1489
|
+
if (!blocks.length)
|
|
1490
|
+
return false;
|
|
1491
|
+
for (const b of blocks) {
|
|
1492
|
+
if (b.type === "heading" || b.type === "list" || b.type === "blockquote" || b.type === "table" || b.type === "code" || b.type === "image" || b.type === "embed")
|
|
1493
|
+
return true;
|
|
1494
|
+
if (b.type === "paragraph" && paraHasRichInline(b))
|
|
1495
|
+
return true;
|
|
1496
|
+
if (b.type === "raw" && _optionalChain([b, 'access', _88 => _88.attrs, 'optionalAccess', _89 => _89.mdType]) === "thematicBreak")
|
|
1497
|
+
return true;
|
|
1498
|
+
}
|
|
1499
|
+
return false;
|
|
1500
|
+
}
|
|
1501
|
+
function preferMarkdownPaste(plain, htmlBlocks) {
|
|
1502
|
+
return !!plain.trim() && isPlainTransportHtml(htmlBlocks) && mdStructureBeatsTransport(plain);
|
|
1456
1503
|
}
|
|
1457
1504
|
var htmlOnlyMarks = /* @__PURE__ */ new Set(["underline", "highlight", "superscript", "subscript", "textStyle", "comment"]);
|
|
1458
1505
|
function textToPhrasing(leaf) {
|
|
1459
|
-
if (_optionalChain([leaf, 'access',
|
|
1506
|
+
if (_optionalChain([leaf, 'access', _90 => _90.marks, 'optionalAccess', _91 => _91.some, 'call', _92 => _92((m) => htmlOnlyMarks.has(m.name))]))
|
|
1460
1507
|
return { type: "html", value: leafToHtml(leaf) };
|
|
1461
1508
|
let node = { type: "text", value: leaf.text };
|
|
1462
1509
|
for (const m of _nullishCoalesce(leaf.marks, () => ( []))) {
|
|
@@ -1477,42 +1524,42 @@ function textToPhrasing(leaf) {
|
|
|
1477
1524
|
node = { type: "html", value: leaf.text };
|
|
1478
1525
|
break;
|
|
1479
1526
|
case "image":
|
|
1480
|
-
node = _optionalChain([m, 'access',
|
|
1527
|
+
node = _optionalChain([m, 'access', _93 => _93.attrs, 'optionalAccess', _94 => _94.w]) != null || _optionalChain([m, 'access', _95 => _95.attrs, 'optionalAccess', _96 => _96.h]) != null ? { type: "html", value: imgHtml(String(_nullishCoalesce(_optionalChain([m, 'access', _97 => _97.attrs, 'optionalAccess', _98 => _98.url]), () => ( ""))), leaf.text, m.attrs) } : { type: "image", url: String(_nullishCoalesce(_optionalChain([m, 'access', _99 => _99.attrs, 'optionalAccess', _100 => _100.url]), () => ( ""))), title: _nullishCoalesce(_optionalChain([m, 'access', _101 => _101.attrs, 'optionalAccess', _102 => _102.title]), () => ( null)), alt: leaf.text };
|
|
1481
1528
|
break;
|
|
1482
1529
|
case "link":
|
|
1483
|
-
node = { type: "link", url: String(_nullishCoalesce(_optionalChain([m, 'access',
|
|
1530
|
+
node = { type: "link", url: String(_nullishCoalesce(_optionalChain([m, 'access', _103 => _103.attrs, 'optionalAccess', _104 => _104.url]), () => ( ""))), title: _nullishCoalesce(_optionalChain([m, 'access', _105 => _105.attrs, 'optionalAccess', _106 => _106.title]), () => ( null)), children: [node] };
|
|
1484
1531
|
break;
|
|
1485
1532
|
}
|
|
1486
1533
|
}
|
|
1487
1534
|
return node;
|
|
1488
1535
|
}
|
|
1489
|
-
var leaves = (n) => n.children.filter(
|
|
1536
|
+
var leaves = (n) => n.children.filter(_chunkZKQSQSSMcjs.isText);
|
|
1490
1537
|
function mentionHtml(n) {
|
|
1491
|
-
const id = String(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1492
|
-
const label = typeof _optionalChain([n, 'access',
|
|
1493
|
-
const kind = typeof _optionalChain([n, 'access',
|
|
1494
|
-
const date = typeof _optionalChain([n, 'access',
|
|
1495
|
-
const glyph = _optionalChain([n, 'access',
|
|
1538
|
+
const id = String(_nullishCoalesce(_optionalChain([n, 'access', _107 => _107.attrs, 'optionalAccess', _108 => _108.id]), () => ( "")));
|
|
1539
|
+
const label = typeof _optionalChain([n, 'access', _109 => _109.attrs, 'optionalAccess', _110 => _110.label]) === "string" ? n.attrs.label : id;
|
|
1540
|
+
const kind = typeof _optionalChain([n, 'access', _111 => _111.attrs, 'optionalAccess', _112 => _112.kind]) === "string" && n.attrs.kind !== "person" ? ` data-kind="${escHtml(n.attrs.kind)}"` : "";
|
|
1541
|
+
const date = typeof _optionalChain([n, 'access', _113 => _113.attrs, 'optionalAccess', _114 => _114.date]) === "string" ? ` data-date="${escHtml(n.attrs.date)}"` : "";
|
|
1542
|
+
const glyph = _optionalChain([n, 'access', _115 => _115.attrs, 'optionalAccess', _116 => _116.kind]) === "date" ? "" : "@";
|
|
1496
1543
|
return `<span data-mention data-id="${escHtml(id)}" data-label="${escHtml(label)}"${kind}${date}>${glyph}${escHtml(label)}</span>`;
|
|
1497
1544
|
}
|
|
1498
1545
|
function mathHtml(n) {
|
|
1499
|
-
const latex = String(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1500
|
-
const display = _optionalChain([n, 'access',
|
|
1546
|
+
const latex = String(_nullishCoalesce(_optionalChain([n, 'access', _117 => _117.attrs, 'optionalAccess', _118 => _118.latex]), () => ( "")));
|
|
1547
|
+
const display = _optionalChain([n, 'access', _119 => _119.attrs, 'optionalAccess', _120 => _120.display]) === "block" ? "block" : "inline";
|
|
1501
1548
|
const wrap = display === "block" ? "$$" : "$";
|
|
1502
1549
|
return `<span data-math data-latex="${escHtml(latex)}" data-display="${display}">${wrap}${escHtml(latex)}${wrap}</span>`;
|
|
1503
1550
|
}
|
|
1504
1551
|
function embedHtml(n) {
|
|
1505
|
-
const kind = String(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1506
|
-
const src = String(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1507
|
-
const title = typeof _optionalChain([n, 'access',
|
|
1508
|
-
const name = typeof _optionalChain([n, 'access',
|
|
1552
|
+
const kind = String(_nullishCoalesce(_optionalChain([n, 'access', _121 => _121.attrs, 'optionalAccess', _122 => _122.kind]), () => ( "")));
|
|
1553
|
+
const src = String(_nullishCoalesce(_optionalChain([n, 'access', _123 => _123.attrs, 'optionalAccess', _124 => _124.src]), () => ( "")));
|
|
1554
|
+
const title = typeof _optionalChain([n, 'access', _125 => _125.attrs, 'optionalAccess', _126 => _126.title]) === "string" ? ` data-title="${escHtml(n.attrs.title)}"` : "";
|
|
1555
|
+
const name = typeof _optionalChain([n, 'access', _127 => _127.attrs, 'optionalAccess', _128 => _128.name]) === "string" ? ` data-name="${escHtml(n.attrs.name)}"` : "";
|
|
1509
1556
|
return `<div data-embed data-kind="${escHtml(kind)}" data-src="${escHtml(src)}"${title}${name}></div>`;
|
|
1510
1557
|
}
|
|
1511
1558
|
function phrasingChildren(n) {
|
|
1512
1559
|
return n.children.flatMap((c) => {
|
|
1513
|
-
if (
|
|
1560
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, c))
|
|
1514
1561
|
return [textToPhrasing(c)];
|
|
1515
|
-
if (
|
|
1562
|
+
if (_chunkZKQSQSSMcjs.isInlineAtom.call(void 0, c)) {
|
|
1516
1563
|
if (c.type === "hard_break")
|
|
1517
1564
|
return [{ type: "break" }];
|
|
1518
1565
|
if (c.type === "math")
|
|
@@ -1523,7 +1570,7 @@ function phrasingChildren(n) {
|
|
|
1523
1570
|
});
|
|
1524
1571
|
}
|
|
1525
1572
|
function cellPhrasing(cell) {
|
|
1526
|
-
const paras = cell.children.filter(
|
|
1573
|
+
const paras = cell.children.filter(_chunkZKQSQSSMcjs.isElement);
|
|
1527
1574
|
const src = paras.length ? paras : [cell];
|
|
1528
1575
|
const out = [];
|
|
1529
1576
|
src.forEach((p, i) => {
|
|
@@ -1534,9 +1581,9 @@ function cellPhrasing(cell) {
|
|
|
1534
1581
|
return out;
|
|
1535
1582
|
}
|
|
1536
1583
|
function tableToMdast(n) {
|
|
1537
|
-
const cols = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1538
|
-
const align = Array.isArray(_optionalChain([n, 'access',
|
|
1539
|
-
const cells = n.children.filter(
|
|
1584
|
+
const cols = Number(_nullishCoalesce(_optionalChain([n, 'access', _129 => _129.attrs, 'optionalAccess', _130 => _130.cols]), () => ( 1)));
|
|
1585
|
+
const align = Array.isArray(_optionalChain([n, 'access', _131 => _131.attrs, 'optionalAccess', _132 => _132.align])) ? n.attrs.align : void 0;
|
|
1586
|
+
const cells = n.children.filter(_chunkZKQSQSSMcjs.isElement);
|
|
1540
1587
|
const rows = [];
|
|
1541
1588
|
for (let r = 0; r * cols < cells.length; r++) {
|
|
1542
1589
|
const rowCells = cells.slice(r * cols, (r + 1) * cols).map((cell) => ({
|
|
@@ -1553,9 +1600,9 @@ function escHtml(s) {
|
|
|
1553
1600
|
return out;
|
|
1554
1601
|
}
|
|
1555
1602
|
function imgHtml(url, alt, attrs, align = "") {
|
|
1556
|
-
const w = _optionalChain([attrs, 'optionalAccess',
|
|
1557
|
-
const h = _optionalChain([attrs, 'optionalAccess',
|
|
1558
|
-
const title = _optionalChain([attrs, 'optionalAccess',
|
|
1603
|
+
const w = _optionalChain([attrs, 'optionalAccess', _133 => _133.w]);
|
|
1604
|
+
const h = _optionalChain([attrs, 'optionalAccess', _134 => _134.h]);
|
|
1605
|
+
const title = _optionalChain([attrs, 'optionalAccess', _135 => _135.title]);
|
|
1559
1606
|
const style = align === "center" ? "display:block;margin-left:auto;margin-right:auto" : align === "right" ? "display:block;margin-left:auto" : "";
|
|
1560
1607
|
return `<img src="${escHtml(url)}" alt="${escHtml(alt)}"` + (title != null ? ` title="${escHtml(String(title))}"` : "") + (w != null ? ` width="${Number(w)}"` : "") + (h != null ? ` height="${Number(h)}"` : "") + (style ? ` style="${style}"` : "") + ">";
|
|
1561
1608
|
}
|
|
@@ -1643,7 +1690,7 @@ function leafToHtml(leaf) {
|
|
|
1643
1690
|
break;
|
|
1644
1691
|
}
|
|
1645
1692
|
case "comment": {
|
|
1646
|
-
const cid = escHtml(String(_nullishCoalesce(_optionalChain([m, 'access',
|
|
1693
|
+
const cid = escHtml(String(_nullishCoalesce(_optionalChain([m, 'access', _136 => _136.attrs, 'optionalAccess', _137 => _137.id]), () => ( ""))));
|
|
1647
1694
|
s = `<span data-comment="${cid}">${s}</span>`;
|
|
1648
1695
|
break;
|
|
1649
1696
|
}
|
|
@@ -1652,37 +1699,37 @@ function leafToHtml(leaf) {
|
|
|
1652
1699
|
break;
|
|
1653
1700
|
// 逐字 HTML 叶:不转义
|
|
1654
1701
|
case "link":
|
|
1655
|
-
s = `<a href="${escHtml(String(_nullishCoalesce(_optionalChain([m, 'access',
|
|
1702
|
+
s = `<a href="${escHtml(String(_nullishCoalesce(_optionalChain([m, 'access', _138 => _138.attrs, 'optionalAccess', _139 => _139.url]), () => ( ""))))}">${s}</a>`;
|
|
1656
1703
|
break;
|
|
1657
1704
|
case "image":
|
|
1658
|
-
s = imgHtml(String(_nullishCoalesce(_optionalChain([m, 'access',
|
|
1705
|
+
s = imgHtml(String(_nullishCoalesce(_optionalChain([m, 'access', _140 => _140.attrs, 'optionalAccess', _141 => _141.url]), () => ( ""))), leaf.text, m.attrs);
|
|
1659
1706
|
break;
|
|
1660
1707
|
}
|
|
1661
1708
|
}
|
|
1662
1709
|
return s;
|
|
1663
1710
|
}
|
|
1664
1711
|
function cellInnerHtml(cell) {
|
|
1665
|
-
const paras = cell.children.filter(
|
|
1712
|
+
const paras = cell.children.filter(_chunkZKQSQSSMcjs.isElement);
|
|
1666
1713
|
const src = paras.length ? paras : [cell];
|
|
1667
1714
|
return src.map((p) => leaves(p).map(leafToHtml).join("")).join("<br>");
|
|
1668
1715
|
}
|
|
1669
1716
|
function tableHasExtras(n) {
|
|
1670
|
-
if (Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1717
|
+
if (Number(_nullishCoalesce(_optionalChain([n, 'access', _142 => _142.attrs, 'optionalAccess', _143 => _143.freezeRows]), () => ( 0))) > 0 || Number(_nullishCoalesce(_optionalChain([n, 'access', _144 => _144.attrs, 'optionalAccess', _145 => _145.freezeCols]), () => ( 0))) > 0)
|
|
1671
1718
|
return true;
|
|
1672
|
-
return n.children.filter(
|
|
1719
|
+
return n.children.filter(_chunkZKQSQSSMcjs.isElement).some((c) => colspanOf(c) > 1 || rowspanOf(c) > 1 || _optionalChain([c, 'access', _146 => _146.attrs, 'optionalAccess', _147 => _147.bg]) != null || _optionalChain([c, 'access', _148 => _148.attrs, 'optionalAccess', _149 => _149.border]) != null || c.children.filter(_chunkZKQSQSSMcjs.isElement).length > 1);
|
|
1673
1720
|
}
|
|
1674
1721
|
function tableToHtml(n) {
|
|
1675
1722
|
const grid = buildGrid(n);
|
|
1676
|
-
const align = Array.isArray(_optionalChain([n, 'access',
|
|
1677
|
-
const freezeRows = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1678
|
-
const freezeCols = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
1723
|
+
const align = Array.isArray(_optionalChain([n, 'access', _150 => _150.attrs, 'optionalAccess', _151 => _151.align])) ? n.attrs.align : null;
|
|
1724
|
+
const freezeRows = Number(_nullishCoalesce(_optionalChain([n, 'access', _152 => _152.attrs, 'optionalAccess', _153 => _153.freezeRows]), () => ( 0)));
|
|
1725
|
+
const freezeCols = Number(_nullishCoalesce(_optionalChain([n, 'access', _154 => _154.attrs, 'optionalAccess', _155 => _155.freezeCols]), () => ( 0)));
|
|
1679
1726
|
const rowCells = /* @__PURE__ */ new Map();
|
|
1680
1727
|
for (const idx of grid.anchors) {
|
|
1681
1728
|
const cell = n.children[idx];
|
|
1682
1729
|
const m = grid.cellOf(idx);
|
|
1683
|
-
const a = _optionalChain([align, 'optionalAccess',
|
|
1684
|
-
const bg = _optionalChain([cell, 'access',
|
|
1685
|
-
const border = _optionalChain([cell, 'access',
|
|
1730
|
+
const a = _optionalChain([align, 'optionalAccess', _156 => _156[m.c]]);
|
|
1731
|
+
const bg = _optionalChain([cell, 'access', _157 => _157.attrs, 'optionalAccess', _158 => _158.bg]);
|
|
1732
|
+
const border = _optionalChain([cell, 'access', _159 => _159.attrs, 'optionalAccess', _160 => _160.border]);
|
|
1686
1733
|
const styles = [a && `text-align:${a}`, bg && `background:${bg}`, border && `border-color:${border}`].filter(Boolean).join(";");
|
|
1687
1734
|
const attrs = [
|
|
1688
1735
|
m.colspan > 1 && ` colspan="${m.colspan}"`,
|
|
@@ -1700,7 +1747,7 @@ function tableToHtml(n) {
|
|
|
1700
1747
|
return `<table${tableAttrs}>${trs.join("")}</table>`;
|
|
1701
1748
|
}
|
|
1702
1749
|
function containerToHtml(openAttrs, children) {
|
|
1703
|
-
const inner = children.filter(
|
|
1750
|
+
const inner = children.filter(_chunkZKQSQSSMcjs.isElement).map((c) => _mdastutiltomarkdown.toMarkdown.call(void 0, { type: "root", children: [nodeToMdast(c)] }, { extensions: [_mdastutilgfm.gfmToMarkdown.call(void 0, )] }).trimEnd()).join("\n\n");
|
|
1704
1751
|
return `<div ${openAttrs}>
|
|
1705
1752
|
|
|
1706
1753
|
${inner}
|
|
@@ -1708,7 +1755,7 @@ ${inner}
|
|
|
1708
1755
|
</div>`;
|
|
1709
1756
|
}
|
|
1710
1757
|
function calloutToHtml(n) {
|
|
1711
|
-
const variant = typeof _optionalChain([n, 'access',
|
|
1758
|
+
const variant = typeof _optionalChain([n, 'access', _161 => _161.attrs, 'optionalAccess', _162 => _162.variant]) === "string" ? n.attrs.variant : "info";
|
|
1712
1759
|
return containerToHtml(`data-callout data-variant="${escHtml(variant)}"`, n.children);
|
|
1713
1760
|
}
|
|
1714
1761
|
function containerOpenKind(b) {
|
|
@@ -1728,7 +1775,7 @@ function readOpenAttr(openTag, sel, attr, fallback) {
|
|
|
1728
1775
|
if (typeof DOMParser === "undefined")
|
|
1729
1776
|
return fallback;
|
|
1730
1777
|
const div = new DOMParser().parseFromString(`${openTag}</div>`, "text/html").querySelector(sel);
|
|
1731
|
-
return _nullishCoalesce(_optionalChain([div, 'optionalAccess',
|
|
1778
|
+
return _nullishCoalesce(_optionalChain([div, 'optionalAccess', _163 => _163.getAttribute, 'call', _164 => _164(attr)]), () => ( fallback));
|
|
1732
1779
|
}
|
|
1733
1780
|
function stitchContainers(blocks, md) {
|
|
1734
1781
|
const out = [];
|
|
@@ -1765,28 +1812,28 @@ function stitchContainers(blocks, md) {
|
|
|
1765
1812
|
function nodeToMdast(n) {
|
|
1766
1813
|
switch (n.type) {
|
|
1767
1814
|
case "heading": {
|
|
1768
|
-
const depth = _nullishCoalesce(_optionalChain([n, 'access',
|
|
1769
|
-
const align = _optionalChain([n, 'access',
|
|
1815
|
+
const depth = _nullishCoalesce(_optionalChain([n, 'access', _165 => _165.attrs, 'optionalAccess', _166 => _166.depth]), () => ( 1));
|
|
1816
|
+
const align = _optionalChain([n, 'access', _167 => _167.attrs, 'optionalAccess', _168 => _168.align]);
|
|
1770
1817
|
if (align && align !== "left")
|
|
1771
1818
|
return { type: "html", value: `<h${depth} style="text-align:${align}">${leaves(n).map(leafToHtml).join("")}</h${depth}>` };
|
|
1772
1819
|
return { type: "heading", depth, children: phrasingChildren(n) };
|
|
1773
1820
|
}
|
|
1774
1821
|
case "paragraph": {
|
|
1775
|
-
const align = _optionalChain([n, 'access',
|
|
1822
|
+
const align = _optionalChain([n, 'access', _169 => _169.attrs, 'optionalAccess', _170 => _170.align]);
|
|
1776
1823
|
if (align && align !== "left")
|
|
1777
1824
|
return { type: "html", value: `<p style="text-align:${align}">${leaves(n).map(leafToHtml).join("")}</p>` };
|
|
1778
1825
|
return { type: "paragraph", children: phrasingChildren(n) };
|
|
1779
1826
|
}
|
|
1780
1827
|
case "quote":
|
|
1781
|
-
return { type: "blockquote", children: n.children.filter(
|
|
1828
|
+
return { type: "blockquote", children: n.children.filter(_chunkZKQSQSSMcjs.isElement).map(nodeToMdast) };
|
|
1782
1829
|
case "callout":
|
|
1783
1830
|
return { type: "html", value: calloutToHtml(n) };
|
|
1784
1831
|
case "list":
|
|
1785
|
-
return { type: "list", ordered: !!_optionalChain([n, 'access',
|
|
1832
|
+
return { type: "list", ordered: !!_optionalChain([n, 'access', _171 => _171.attrs, 'optionalAccess', _172 => _172.ordered]), start: _nullishCoalesce(_optionalChain([n, 'access', _173 => _173.attrs, 'optionalAccess', _174 => _174.start]), () => ( null)), children: n.children.filter(_chunkZKQSQSSMcjs.isElement).map(nodeToMdast) };
|
|
1786
1833
|
case "list_item":
|
|
1787
|
-
return { type: "listItem", checked: _nullishCoalesce(_optionalChain([n, 'access',
|
|
1834
|
+
return { type: "listItem", checked: _nullishCoalesce(_optionalChain([n, 'access', _175 => _175.attrs, 'optionalAccess', _176 => _176.checked]), () => ( null)), children: n.children.filter(_chunkZKQSQSSMcjs.isElement).map(nodeToMdast) };
|
|
1788
1835
|
case "code":
|
|
1789
|
-
return { type: "code", lang: _nullishCoalesce(_optionalChain([n, 'access',
|
|
1836
|
+
return { type: "code", lang: _nullishCoalesce(_optionalChain([n, 'access', _177 => _177.attrs, 'optionalAccess', _178 => _178.lang]), () => ( null)), meta: _nullishCoalesce(_optionalChain([n, 'access', _179 => _179.attrs, 'optionalAccess', _180 => _180.meta]), () => ( null)), value: _nullishCoalesce(_optionalChain([leaves, 'call', _181 => _181(n), 'access', _182 => _182[0], 'optionalAccess', _183 => _183.text]), () => ( "")) };
|
|
1790
1837
|
case "table":
|
|
1791
1838
|
return tableHasExtras(n) ? { type: "html", value: tableToHtml(n) } : tableToMdast(n);
|
|
1792
1839
|
case "image": {
|
|
@@ -1804,7 +1851,7 @@ function nodeToMdast(n) {
|
|
|
1804
1851
|
case "embed":
|
|
1805
1852
|
return { type: "html", value: embedHtml(n) };
|
|
1806
1853
|
case "raw": {
|
|
1807
|
-
const raw = _nullishCoalesce(_optionalChain([leaves, 'call',
|
|
1854
|
+
const raw = _nullishCoalesce(_optionalChain([leaves, 'call', _184 => _184(n), 'access', _185 => _185[0], 'optionalAccess', _186 => _186.text]), () => ( ""));
|
|
1808
1855
|
return { type: "html", value: raw };
|
|
1809
1856
|
}
|
|
1810
1857
|
default:
|
|
@@ -1824,14 +1871,14 @@ function eq(a, b) {
|
|
|
1824
1871
|
return ak.length === bk.length && ak.every((k) => eq(a[k], b[k]));
|
|
1825
1872
|
}
|
|
1826
1873
|
function clean(block, srcMd) {
|
|
1827
|
-
const s = _optionalChain([block, 'access',
|
|
1874
|
+
const s = _optionalChain([block, 'access', _187 => _187.attrs, 'optionalAccess', _188 => _188.span]);
|
|
1828
1875
|
if (!s)
|
|
1829
1876
|
return false;
|
|
1830
1877
|
const reparsed = mdToDoc(srcMd.slice(s[0], s[1])).children[0];
|
|
1831
|
-
return !!reparsed && !
|
|
1878
|
+
return !!reparsed && !_chunkZKQSQSSMcjs.isText.call(void 0, reparsed) && eq(block, reparsed);
|
|
1832
1879
|
}
|
|
1833
|
-
var isOpaqueBlock = (n) => !
|
|
1834
|
-
var isSynthGapPara = (n) => !
|
|
1880
|
+
var isOpaqueBlock = (n) => !_chunkZKQSQSSMcjs.isText.call(void 0, n) && (n.type === "table" || n.type === "image" || n.type === "embed" || n.type === "raw" && _optionalChain([n, 'access', _189 => _189.attrs, 'optionalAccess', _190 => _190.mdType]) === "thematicBreak");
|
|
1881
|
+
var isSynthGapPara = (n) => !_chunkZKQSQSSMcjs.isText.call(void 0, n) && n.type === "paragraph" && !_optionalChain([n, 'access', _191 => _191.attrs, 'optionalAccess', _192 => _192.span]) && n.children.length === 1 && _chunkZKQSQSSMcjs.isText.call(void 0, n.children[0]) && n.children[0].text === "";
|
|
1835
1882
|
function trimSynthGapPara(children) {
|
|
1836
1883
|
return children.filter((n, i) => {
|
|
1837
1884
|
if (!isSynthGapPara(n))
|
|
@@ -1846,9 +1893,9 @@ function docToMd(doc, srcMd) {
|
|
|
1846
1893
|
let cursor = 0;
|
|
1847
1894
|
const blocks = trimSynthGapPara(doc.children);
|
|
1848
1895
|
for (const block of blocks) {
|
|
1849
|
-
if (
|
|
1896
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, block))
|
|
1850
1897
|
continue;
|
|
1851
|
-
const s = _optionalChain([block, 'access',
|
|
1898
|
+
const s = _optionalChain([block, 'access', _193 => _193.attrs, 'optionalAccess', _194 => _194.span]);
|
|
1852
1899
|
if (s)
|
|
1853
1900
|
out += srcMd.slice(cursor, s[0]);
|
|
1854
1901
|
if (s && clean(block, srcMd)) {
|
|
@@ -1912,7 +1959,7 @@ function maxReachableDepth(schema) {
|
|
|
1912
1959
|
}
|
|
1913
1960
|
function validate(schema, doc) {
|
|
1914
1961
|
function check(node, typePath) {
|
|
1915
|
-
if (
|
|
1962
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
|
|
1916
1963
|
return true;
|
|
1917
1964
|
const spec = schema.nodes[node.type];
|
|
1918
1965
|
if (!spec)
|
|
@@ -1920,7 +1967,7 @@ function validate(schema, doc) {
|
|
|
1920
1967
|
if (spec.atom)
|
|
1921
1968
|
return true;
|
|
1922
1969
|
for (const child of node.children) {
|
|
1923
|
-
const childType =
|
|
1970
|
+
const childType = _chunkZKQSQSSMcjs.isText.call(void 0, child) ? "text" : child.type;
|
|
1924
1971
|
if (!spec.content.includes(childType))
|
|
1925
1972
|
return `${typePath}/${node.type}: \u4E0D\u5141\u8BB8 child "${childType}"`;
|
|
1926
1973
|
const r = check(child, `${typePath}/${node.type}`);
|
|
@@ -1934,7 +1981,7 @@ function validate(schema, doc) {
|
|
|
1934
1981
|
function validateAll(schema, doc) {
|
|
1935
1982
|
const out = [];
|
|
1936
1983
|
function check(node, path) {
|
|
1937
|
-
if (
|
|
1984
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
|
|
1938
1985
|
return;
|
|
1939
1986
|
const spec = schema.nodes[node.type];
|
|
1940
1987
|
if (!spec) {
|
|
@@ -1945,7 +1992,7 @@ function validateAll(schema, doc) {
|
|
|
1945
1992
|
return;
|
|
1946
1993
|
for (let i = 0; i < node.children.length; i++) {
|
|
1947
1994
|
const child = node.children[i];
|
|
1948
|
-
const childType =
|
|
1995
|
+
const childType = _chunkZKQSQSSMcjs.isText.call(void 0, child) ? "text" : child.type;
|
|
1949
1996
|
if (!spec.content.includes(childType))
|
|
1950
1997
|
out.push({ path: path.concat(i), reason: `${node.type} \u4E0D\u5141\u8BB8 child "${childType}"` });
|
|
1951
1998
|
check(child, path.concat(i));
|
|
@@ -1995,14 +2042,14 @@ function apply(doc, step) {
|
|
|
1995
2042
|
switch (step.kind) {
|
|
1996
2043
|
case "insertText": {
|
|
1997
2044
|
const leaf = nodeAt(doc, step.path);
|
|
1998
|
-
if (!
|
|
2045
|
+
if (!_chunkZKQSQSSMcjs.isText.call(void 0, leaf))
|
|
1999
2046
|
throw new Error("insertText \u76EE\u6807\u4E0D\u662F\u6587\u672C\u53F6");
|
|
2000
2047
|
const text = leaf.text.slice(0, step.offset) + step.text + leaf.text.slice(step.offset);
|
|
2001
2048
|
return replaceAt(doc, step.path, { ...leaf, text });
|
|
2002
2049
|
}
|
|
2003
2050
|
case "deleteText": {
|
|
2004
2051
|
const leaf = nodeAt(doc, step.path);
|
|
2005
|
-
if (!
|
|
2052
|
+
if (!_chunkZKQSQSSMcjs.isText.call(void 0, leaf))
|
|
2006
2053
|
throw new Error("deleteText \u76EE\u6807\u4E0D\u662F\u6587\u672C\u53F6");
|
|
2007
2054
|
const text = leaf.text.slice(0, step.offset) + leaf.text.slice(step.offset + step.length);
|
|
2008
2055
|
return replaceAt(doc, step.path, { ...leaf, text });
|
|
@@ -2058,7 +2105,7 @@ function invertAll(doc, steps) {
|
|
|
2058
2105
|
// src/tree/ai.ts
|
|
2059
2106
|
function pathOfId(doc, id) {
|
|
2060
2107
|
function walk(node, prefix) {
|
|
2061
|
-
if (
|
|
2108
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
|
|
2062
2109
|
return null;
|
|
2063
2110
|
if (node.id === id)
|
|
2064
2111
|
return prefix;
|
|
@@ -2074,7 +2121,7 @@ function pathOfId(doc, id) {
|
|
|
2074
2121
|
function buildIdIndex(doc) {
|
|
2075
2122
|
const index = /* @__PURE__ */ new Map();
|
|
2076
2123
|
function walk(node, prefix) {
|
|
2077
|
-
if (
|
|
2124
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
|
|
2078
2125
|
return;
|
|
2079
2126
|
if (node.id !== void 0 && !index.has(node.id))
|
|
2080
2127
|
index.set(node.id, prefix);
|
|
@@ -2086,19 +2133,19 @@ function buildIdIndex(doc) {
|
|
|
2086
2133
|
}
|
|
2087
2134
|
function leafPathAndLen(doc, blockPath) {
|
|
2088
2135
|
const block = blockPath.reduce((n, i2) => n.children[i2], doc);
|
|
2089
|
-
if (!
|
|
2136
|
+
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, block))
|
|
2090
2137
|
throw new Error("\u5757\u4E0D\u662F\u5143\u7D20");
|
|
2091
|
-
const i = block.children.findIndex(
|
|
2138
|
+
const i = block.children.findIndex(_chunkZKQSQSSMcjs.isText);
|
|
2092
2139
|
if (i === -1)
|
|
2093
2140
|
return null;
|
|
2094
2141
|
const leaf = block.children[i];
|
|
2095
|
-
return { path: blockPath.concat(i), len:
|
|
2142
|
+
return { path: blockPath.concat(i), len: _chunkZKQSQSSMcjs.isText.call(void 0, leaf) ? leaf.text.length : 0 };
|
|
2096
2143
|
}
|
|
2097
2144
|
function resolve2(doc, id, index) {
|
|
2098
2145
|
return index ? _nullishCoalesce(index.get(id), () => ( null)) : pathOfId(doc, id);
|
|
2099
2146
|
}
|
|
2100
2147
|
function collectIds(node, out) {
|
|
2101
|
-
if (
|
|
2148
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
|
|
2102
2149
|
return;
|
|
2103
2150
|
if (node.id !== void 0)
|
|
2104
2151
|
out.push(node.id);
|
|
@@ -2129,7 +2176,7 @@ function appendText(doc, blockId, text, index) {
|
|
|
2129
2176
|
}
|
|
2130
2177
|
function badTable(doc) {
|
|
2131
2178
|
for (const c of doc.children) {
|
|
2132
|
-
if (!
|
|
2179
|
+
if (!_chunkZKQSQSSMcjs.isText.call(void 0, c) && c.type === "table") {
|
|
2133
2180
|
const errs = checkTable(c);
|
|
2134
2181
|
if (errs.length > 0)
|
|
2135
2182
|
return errs[0];
|
|
@@ -2185,7 +2232,7 @@ function insertAfter(doc, afterId, nodes, index, schema) {
|
|
|
2185
2232
|
function idBlocks(doc) {
|
|
2186
2233
|
const out = [];
|
|
2187
2234
|
function walk(node) {
|
|
2188
|
-
if (
|
|
2235
|
+
if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
|
|
2189
2236
|
return;
|
|
2190
2237
|
if (node.id)
|
|
2191
2238
|
out.push(node);
|
|
@@ -2294,4 +2341,7 @@ function deepEqual(a, b) {
|
|
|
2294
2341
|
|
|
2295
2342
|
|
|
2296
2343
|
|
|
2297
|
-
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
|
|
2347
|
+
exports.resolve = resolve; exports.firstLeafPath = firstLeafPath; exports.normalizeToLeaf = normalizeToLeaf; exports.lastLeafEnd = lastLeafEnd; exports.nodeAt = nodeAt; exports.replaceAt = replaceAt; exports.spliceAt = spliceAt; exports.tableShape = tableShape; exports.colspanOf = colspanOf; exports.rowspanOf = rowspanOf; exports.buildGrid = buildGrid; exports.cellCaret = cellCaret; exports.caretCell = caretCell; exports.makeTable = makeTable; exports.cellText = cellText; exports.nextCell = nextCell; exports.arrowCell = arrowCell; exports.insertRow = insertRow; exports.deleteRow = deleteRow; exports.insertCol = insertCol; exports.deleteCol = deleteCol; exports.hasSpan = hasSpan; exports.moveRow = moveRow; exports.moveCol = moveCol; exports.tableColWidths = tableColWidths; exports.setColWidths = setColWidths; exports.setAlign = setAlign; exports.mergeCells = mergeCells; exports.splitCell = splitCell; exports.setCellStyle = setCellStyle; exports.clearCells = clearCells; exports.setFreeze = setFreeze; exports.deleteTableBlock = deleteTableBlock; exports.tableAt = tableAt; exports.checkTable = checkTable; exports.tableSchema = tableSchema; exports.mdToDoc = mdToDoc; exports.htmlToBlocks = htmlToBlocks; exports.isRichHtmlBlocks = isRichHtmlBlocks; exports.isPlainTransportHtml = isPlainTransportHtml; exports.mdStructureBeatsTransport = mdStructureBeatsTransport; exports.preferMarkdownPaste = preferMarkdownPaste; exports.embedHtml = embedHtml; exports.tableHasExtras = tableHasExtras; exports.tableToHtml = tableToHtml; exports.calloutToHtml = calloutToHtml; exports.docToMd = docToMd; exports.checkSchema = checkSchema; exports.validate = validate; exports.validateAll = validateAll; exports.basicSchema = basicSchema; exports.apply = apply; exports.invert = invert; exports.applyAll = applyAll; exports.moveBlock = moveBlock; exports.invertAll = invertAll; exports.pathOfId = pathOfId; exports.buildIdIndex = buildIdIndex; exports.appendText = appendText; exports.rewriteNode = rewriteNode; exports.insertAfter = insertAfter; exports.diffById = diffById;
|