markloom 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +29 -16
  2. package/ai.md +160 -0
  3. package/collab.md +68 -0
  4. package/dist/ai/index.cjs +4 -3
  5. package/dist/ai/index.d.cts +4 -2
  6. package/dist/ai/index.d.ts +4 -2
  7. package/dist/ai/index.js +5 -4
  8. package/dist/ai/theme.css +63 -63
  9. package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
  10. package/dist/chunk-6DCI7AL3.js +208 -0
  11. package/dist/chunk-AC5E42NH.cjs +208 -0
  12. package/dist/chunk-GQ2HHRGI.cjs +16 -0
  13. package/dist/{chunk-GUPMZI6Q.js → chunk-JMOJU5EU.js} +7 -5
  14. package/dist/chunk-JS527FDV.cjs +294 -0
  15. package/dist/chunk-LA5SBCGQ.js +16 -0
  16. package/dist/{chunk-ITVAR2UM.js → chunk-LEYAQNJA.js} +5 -3
  17. package/dist/{chunk-J3QWW6CN.js → chunk-MFYF2A6U.js} +5 -13
  18. package/dist/chunk-RLTHVQNQ.js +294 -0
  19. package/dist/{chunk-7Q6AXLF2.cjs → chunk-SLRD6FMP.cjs} +30 -28
  20. package/dist/{chunk-UCNEQGMY.js → chunk-WUHTCCAE.js} +391 -332
  21. package/dist/{chunk-2X6AF7XH.cjs → chunk-YJAWPRJW.cjs} +722 -663
  22. package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
  23. package/dist/client-A0ZQJnyR.d.ts +137 -0
  24. package/dist/client-BNams4wv.d.cts +137 -0
  25. package/dist/collab/index.cjs +19 -0
  26. package/dist/collab/index.d.cts +3 -0
  27. package/dist/collab/index.d.ts +3 -0
  28. package/dist/collab/index.js +19 -0
  29. package/dist/comments-DlExS6f-.d.cts +43 -0
  30. package/dist/comments-PhnR7Gkn.d.ts +43 -0
  31. package/dist/{controller-Dm4uLD3I.d.ts → controller-BkY1VPzc.d.ts} +24 -8
  32. package/dist/{controller-cE9iEYp3.d.cts → controller-CVIZI--A.d.cts} +24 -8
  33. package/dist/index.cjs +21 -243
  34. package/dist/index.d.cts +5 -7
  35. package/dist/index.d.ts +5 -7
  36. package/dist/index.js +22 -244
  37. package/dist/react/index.cjs +12 -9
  38. package/dist/react/index.d.cts +7 -5
  39. package/dist/react/index.d.ts +7 -5
  40. package/dist/react/index.js +12 -9
  41. package/dist/rebase-batch-8rL_aXEE.d.ts +38 -0
  42. package/dist/rebase-batch-bYnBJpRO.d.cts +38 -0
  43. package/dist/step-BrvHIK7O.d.cts +65 -0
  44. package/dist/step-BrvHIK7O.d.ts +65 -0
  45. package/dist/view/index.cjs +11 -8
  46. package/dist/view/index.d.cts +7 -5
  47. package/dist/view/index.d.ts +7 -5
  48. package/dist/view/index.js +9 -6
  49. package/dist/view/theme.css +507 -507
  50. package/package.json +10 -3
  51. package/dist/comments-USjT1wYN.d.cts +0 -105
  52. package/dist/comments-USjT1wYN.d.ts +0 -105
@@ -1,13 +1,8 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/tree/types.ts
2
- function isText(n) {
3
- return "text" in n;
4
- }
5
- function isElement(n) {
6
- return "children" in n;
7
- }
8
- function isInlineAtom(n) {
9
- return isElement(n) && (n.type === "mention" || n.type === "hard_break" || n.type === "math");
10
- }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+ var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
11
6
 
12
7
  // src/tree/addr.ts
13
8
  function resolve(doc, path) {
@@ -17,7 +12,7 @@ function resolve(doc, path) {
17
12
  const indexInParent = [];
18
13
  let cur = doc;
19
14
  for (let i = 0; i < path.length - 1; i++) {
20
- if (!isElement(cur))
15
+ if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, cur))
21
16
  throw new Error(`path \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")} \u5728\u7B2C ${i} \u6BB5`);
22
17
  parents.push(cur);
23
18
  indexInParent.push(path[i]);
@@ -32,9 +27,9 @@ function resolve(doc, path) {
32
27
  function firstLeafPath(block) {
33
28
  for (let i = 0; i < block.children.length; i++) {
34
29
  const c = block.children[i];
35
- if (isInlineAtom(c))
30
+ if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c))
36
31
  continue;
37
- if (isText(c))
32
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
38
33
  return [i];
39
34
  return [i, ...firstLeafPath(c)];
40
35
  }
@@ -44,7 +39,7 @@ function normalizeToLeaf(doc, path) {
44
39
  const prefix = [];
45
40
  let cur = doc;
46
41
  for (let i = 0; i < path.length; i++) {
47
- if (isText(cur)) {
42
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, cur)) {
48
43
  return prefix.concat(Math.max(0, path[i]));
49
44
  }
50
45
  if (i === path.length - 1)
@@ -55,9 +50,9 @@ function normalizeToLeaf(doc, path) {
55
50
  prefix.push(path[i]);
56
51
  cur = child;
57
52
  }
58
- if (isText(cur))
53
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, cur))
59
54
  return prefix.concat(0);
60
- if (isInlineAtom(cur) && prefix.length >= 1) {
55
+ if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, cur) && prefix.length >= 1) {
61
56
  const parent = nodeAt(doc, prefix.slice(0, -1));
62
57
  const idx = prefix[prefix.length - 1];
63
58
  const base = prefix.slice(0, -1);
@@ -65,14 +60,14 @@ function normalizeToLeaf(doc, path) {
65
60
  const prev = parent.children[idx - 1];
66
61
  const next = parent.children[idx + 1];
67
62
  if (preferNext) {
68
- if (next && isText(next))
63
+ if (next && _chunkGQ2HHRGIcjs.isText.call(void 0, next))
69
64
  return base.concat(idx + 1, 0);
70
- if (prev && isText(prev))
65
+ if (prev && _chunkGQ2HHRGIcjs.isText.call(void 0, prev))
71
66
  return base.concat(idx - 1, prev.text.length);
72
67
  } else {
73
- if (prev && isText(prev))
68
+ if (prev && _chunkGQ2HHRGIcjs.isText.call(void 0, prev))
74
69
  return base.concat(idx - 1, prev.text.length);
75
- if (next && isText(next))
70
+ if (next && _chunkGQ2HHRGIcjs.isText.call(void 0, next))
76
71
  return base.concat(idx + 1, 0);
77
72
  }
78
73
  }
@@ -81,10 +76,10 @@ function normalizeToLeaf(doc, path) {
81
76
  const idx = prefix[prefix.length - 1];
82
77
  const base = prefix.slice(0, -1);
83
78
  const next = parent.children[idx + 1];
84
- if (next && !isText(next))
79
+ if (next && !_chunkGQ2HHRGIcjs.isText.call(void 0, next))
85
80
  return base.concat(idx + 1, firstLeafPath(next), 0);
86
81
  const prev = parent.children[idx - 1];
87
- if (prev && !isText(prev))
82
+ if (prev && !_chunkGQ2HHRGIcjs.isText.call(void 0, prev))
88
83
  return base.concat(idx - 1, lastLeafEnd(prev));
89
84
  }
90
85
  return prefix.concat(firstLeafPath(cur), 0);
@@ -92,9 +87,9 @@ function normalizeToLeaf(doc, path) {
92
87
  function lastLeafEnd(block) {
93
88
  for (let i = block.children.length - 1; i >= 0; i--) {
94
89
  const last = block.children[i];
95
- if (isInlineAtom(last))
90
+ if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, last))
96
91
  continue;
97
- if (isText(last))
92
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, last))
98
93
  return [i, last.text.length];
99
94
  return [i, ...lastLeafEnd(last)];
100
95
  }
@@ -103,7 +98,7 @@ function lastLeafEnd(block) {
103
98
  function nodeAt(doc, path) {
104
99
  let cur = doc;
105
100
  for (const seg of path) {
106
- if (!isElement(cur))
101
+ if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, cur))
107
102
  throw new Error(`nodeAt \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")}`);
108
103
  const child = cur.children[seg];
109
104
  if (!child)
@@ -114,7 +109,7 @@ function nodeAt(doc, path) {
114
109
  }
115
110
  function replaceAt(doc, path, next) {
116
111
  if (path.length === 0) {
117
- if (isText(next))
112
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, next))
118
113
  throw new Error("\u6839\u4E0D\u80FD\u662F\u6587\u672C\u53F6");
119
114
  return next;
120
115
  }
@@ -122,7 +117,7 @@ function replaceAt(doc, path, next) {
122
117
  }
123
118
  function spliceAt(doc, path, at, remove, insert) {
124
119
  return update(doc, path, 0, (node) => {
125
- if (!isElement(node))
120
+ if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, node))
126
121
  throw new Error("spliceAt \u76EE\u6807\u4E0D\u662F\u5143\u7D20");
127
122
  const children = node.children.slice();
128
123
  children.splice(at, remove, ...insert);
@@ -132,11 +127,11 @@ function spliceAt(doc, path, at, remove, insert) {
132
127
  function update(node, path, depth, fn) {
133
128
  if (depth === path.length) {
134
129
  const r = fn(node);
135
- if (isText(r))
130
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, r))
136
131
  throw new Error("update \u4E0D\u80FD\u628A\u5143\u7D20\u6362\u6210\u6587\u672C\u53F6");
137
132
  return r;
138
133
  }
139
- if (!isElement(node))
134
+ if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, node))
140
135
  throw new Error(`update \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")}`);
141
136
  const idx = path[depth];
142
137
  const children = node.children.slice();
@@ -146,7 +141,7 @@ function update(node, path, depth, fn) {
146
141
  function updateChild(node, path, depth, fn) {
147
142
  if (depth === path.length)
148
143
  return fn(node);
149
- if (!isElement(node))
144
+ if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, node))
150
145
  throw new Error(`update \u8D8A\u8FC7\u6587\u672C\u53F6: ${path.join(",")}`);
151
146
  const idx = path[depth];
152
147
  const children = node.children.slice();
@@ -159,10 +154,10 @@ function tableShape(table) {
159
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))) };
160
155
  }
161
156
  function colspanOf(cell) {
162
- return isText(cell) ? 1 : Math.max(1, Number(_nullishCoalesce(_optionalChain([cell, 'access', _6 => _6.attrs, 'optionalAccess', _7 => _7.colspan]), () => ( 1))));
157
+ return _chunkGQ2HHRGIcjs.isText.call(void 0, cell) ? 1 : Math.max(1, Number(_nullishCoalesce(_optionalChain([cell, 'access', _6 => _6.attrs, 'optionalAccess', _7 => _7.colspan]), () => ( 1))));
163
158
  }
164
159
  function rowspanOf(cell) {
165
- return isText(cell) ? 1 : Math.max(1, Number(_nullishCoalesce(_optionalChain([cell, 'access', _8 => _8.attrs, 'optionalAccess', _9 => _9.rowspan]), () => ( 1))));
160
+ return _chunkGQ2HHRGIcjs.isText.call(void 0, cell) ? 1 : Math.max(1, Number(_nullishCoalesce(_optionalChain([cell, 'access', _8 => _8.attrs, 'optionalAccess', _9 => _9.rowspan]), () => ( 1))));
166
161
  }
167
162
  function buildGrid(table) {
168
163
  const { rows, cols } = tableShape(table);
@@ -220,10 +215,10 @@ function makeTable(id, rows, cols) {
220
215
  function cellText(table, r, c) {
221
216
  const idx = buildGrid(table).at(r, c);
222
217
  const cell = idx < 0 ? void 0 : table.children[idx];
223
- if (!cell || isText(cell) || isText(cell.children[0]))
218
+ if (!cell || _chunkGQ2HHRGIcjs.isText.call(void 0, cell) || _chunkGQ2HHRGIcjs.isText.call(void 0, cell.children[0]))
224
219
  return "";
225
220
  const leaf = cell.children[0].children[0];
226
- return leaf && isText(leaf) ? leaf.text : "";
221
+ return leaf && _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text : "";
227
222
  }
228
223
  function nextCell(table, r, c, dir) {
229
224
  const grid = buildGrid(table);
@@ -255,7 +250,7 @@ function arrowCell(table, r, c, dir) {
255
250
  return { r: a.r, c: a.c };
256
251
  }
257
252
  function withSpan(cell, cs, rs) {
258
- if (isText(cell))
253
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, cell))
259
254
  return cell;
260
255
  const attrs = { ...cell.attrs };
261
256
  if (cs > 1)
@@ -462,7 +457,7 @@ function mergeCells(table, tablePath, r1, c1, r2, c2) {
462
457
  for (const idx of covered.slice(1)) {
463
458
  const cell = table.children[idx];
464
459
  for (const p of cell.children) {
465
- if (!isText(p) && p.type === "paragraph" && isNonEmptyPara(p))
460
+ if (!_chunkGQ2HHRGIcjs.isText.call(void 0, p) && p.type === "paragraph" && isNonEmptyPara(p))
466
461
  paras.push(p);
467
462
  }
468
463
  }
@@ -472,7 +467,7 @@ function mergeCells(table, tablePath, r1, c1, r2, c2) {
472
467
  return { kind: "replaceNode", path: tablePath, node: { ...table, children } };
473
468
  }
474
469
  function isNonEmptyPara(p) {
475
- return p.children.some((c) => isText(c) && c.text !== "");
470
+ return p.children.some((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.text !== "");
476
471
  }
477
472
  function splitCell(table, tablePath, r, c) {
478
473
  const grid = buildGrid(table);
@@ -510,7 +505,7 @@ function setCellStyle(table, tablePath, r, c, style) {
510
505
  function clearCells(table, tablePath, rect) {
511
506
  const grid = buildGrid(table);
512
507
  const children = table.children.map((cell, i) => {
513
- if (isText(cell) || cell.type !== "table_cell")
508
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, cell) || cell.type !== "table_cell")
514
509
  return cell;
515
510
  const m = grid.cellOf(i);
516
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;
@@ -563,7 +558,7 @@ function deleteTableBlock(tablePath, doc) {
563
558
  }
564
559
  function tableAt(doc, tablePath) {
565
560
  const n = nodeAt(doc, tablePath);
566
- return !isText(n) && n.type === "table" ? n : null;
561
+ return !_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.type === "table" ? n : null;
567
562
  }
568
563
  function checkTable(table) {
569
564
  const out = [];
@@ -582,12 +577,12 @@ function checkTable(table) {
582
577
  void covered;
583
578
  }
584
579
  table.children.forEach((cell, i) => {
585
- if (isText(cell) || cell.type !== "table_cell") {
580
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, cell) || cell.type !== "table_cell") {
586
581
  out.push(`children[${i}] \u4E0D\u662F table_cell`);
587
582
  return;
588
583
  }
589
584
  for (const child of cell.children) {
590
- if (!isText(child) && child.type !== "paragraph")
585
+ if (!_chunkGQ2HHRGIcjs.isText.call(void 0, child) && child.type !== "paragraph")
591
586
  out.push(`children[${i}] cell \u5185\u975E paragraph: ${child.type}`);
592
587
  }
593
588
  });
@@ -860,7 +855,7 @@ function phrasingToNodes(nodes, md) {
860
855
  const atom = open.includes("data-math") ? mathFromHtml(open) : mentionFromHtml(open);
861
856
  if (!atom)
862
857
  continue;
863
- const dropEmpty = (ns) => ns.filter((n) => !(isText(n) && n.text === "" && !_optionalChain([n, 'access', _47 => _47.marks, 'optionalAccess', _48 => _48.length])));
858
+ const dropEmpty = (ns) => ns.filter((n) => !(_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.text === "" && !_optionalChain([n, 'access', _47 => _47.marks, 'optionalAccess', _48 => _48.length])));
864
859
  return [
865
860
  ...i > 0 ? dropEmpty(phrasingToNodes(nodes.slice(0, i), md)) : [],
866
861
  atom,
@@ -877,7 +872,7 @@ function phrasingWithBreaks(nodes, md) {
877
872
  return;
878
873
  const leaves2 = phrasingToText(run, [], md);
879
874
  for (const l of leaves2) {
880
- if (isText(l) && l.text === "" && !_optionalChain([l, 'access', _49 => _49.marks, 'optionalAccess', _50 => _50.length]) && out.length)
875
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, l) && l.text === "" && !_optionalChain([l, 'access', _49 => _49.marks, 'optionalAccess', _50 => _50.length]) && out.length)
881
876
  continue;
882
877
  out.push(l);
883
878
  }
@@ -1324,7 +1319,7 @@ function elevateInlineImages(block) {
1324
1319
  buf = [];
1325
1320
  };
1326
1321
  for (const c of block.children) {
1327
- if (isText(c)) {
1322
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, c)) {
1328
1323
  const im = _optionalChain([c, 'access', _81 => _81.marks, 'optionalAccess', _82 => _82.find, 'call', _83 => _83((m) => m.name === "image")]);
1329
1324
  if (im) {
1330
1325
  flush();
@@ -1437,7 +1432,7 @@ function domNodesToBlocks(nodes) {
1437
1432
  }
1438
1433
  const paras = cellDomToParas(el);
1439
1434
  for (const para of paras) {
1440
- if (para.children.length === 1 && isText(para.children[0]) && !para.children[0].text.trim() && !para.children[0].marks)
1435
+ if (para.children.length === 1 && _chunkGQ2HHRGIcjs.isText.call(void 0, para.children[0]) && !para.children[0].text.trim() && !para.children[0].marks)
1441
1436
  continue;
1442
1437
  out.push(...elevateInlineImages(para));
1443
1438
  }
@@ -1457,7 +1452,7 @@ function isRichHtmlBlocks(blocks) {
1457
1452
  const b = blocks[0];
1458
1453
  if (b.type !== "paragraph" && b.type !== "heading")
1459
1454
  return true;
1460
- return b.children.some((c) => !isText(c) || (_nullishCoalesce(_optionalChain([c, 'access', _84 => _84.marks, 'optionalAccess', _85 => _85.length]), () => ( 0))) > 0 || c.text.includes("\n"));
1455
+ return b.children.some((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) || (_nullishCoalesce(_optionalChain([c, 'access', _84 => _84.marks, 'optionalAccess', _85 => _85.length]), () => ( 0))) > 0 || c.text.includes("\n"));
1461
1456
  }
1462
1457
  var htmlOnlyMarks = /* @__PURE__ */ new Set(["underline", "highlight", "superscript", "subscript", "textStyle", "comment"]);
1463
1458
  function textToPhrasing(leaf) {
@@ -1491,7 +1486,7 @@ function textToPhrasing(leaf) {
1491
1486
  }
1492
1487
  return node;
1493
1488
  }
1494
- var leaves = (n) => n.children.filter(isText);
1489
+ var leaves = (n) => n.children.filter(_chunkGQ2HHRGIcjs.isText);
1495
1490
  function mentionHtml(n) {
1496
1491
  const id = String(_nullishCoalesce(_optionalChain([n, 'access', _103 => _103.attrs, 'optionalAccess', _104 => _104.id]), () => ( "")));
1497
1492
  const label = typeof _optionalChain([n, 'access', _105 => _105.attrs, 'optionalAccess', _106 => _106.label]) === "string" ? n.attrs.label : id;
@@ -1515,9 +1510,9 @@ function embedHtml(n) {
1515
1510
  }
1516
1511
  function phrasingChildren(n) {
1517
1512
  return n.children.flatMap((c) => {
1518
- if (isText(c))
1513
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
1519
1514
  return [textToPhrasing(c)];
1520
- if (isInlineAtom(c)) {
1515
+ if (_chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c)) {
1521
1516
  if (c.type === "hard_break")
1522
1517
  return [{ type: "break" }];
1523
1518
  if (c.type === "math")
@@ -1528,7 +1523,7 @@ function phrasingChildren(n) {
1528
1523
  });
1529
1524
  }
1530
1525
  function cellPhrasing(cell) {
1531
- const paras = cell.children.filter(isElement);
1526
+ const paras = cell.children.filter(_chunkGQ2HHRGIcjs.isElement);
1532
1527
  const src = paras.length ? paras : [cell];
1533
1528
  const out = [];
1534
1529
  src.forEach((p, i) => {
@@ -1541,7 +1536,7 @@ function cellPhrasing(cell) {
1541
1536
  function tableToMdast(n) {
1542
1537
  const cols = Number(_nullishCoalesce(_optionalChain([n, 'access', _125 => _125.attrs, 'optionalAccess', _126 => _126.cols]), () => ( 1)));
1543
1538
  const align = Array.isArray(_optionalChain([n, 'access', _127 => _127.attrs, 'optionalAccess', _128 => _128.align])) ? n.attrs.align : void 0;
1544
- const cells = n.children.filter(isElement);
1539
+ const cells = n.children.filter(_chunkGQ2HHRGIcjs.isElement);
1545
1540
  const rows = [];
1546
1541
  for (let r = 0; r * cols < cells.length; r++) {
1547
1542
  const rowCells = cells.slice(r * cols, (r + 1) * cols).map((cell) => ({
@@ -1667,14 +1662,14 @@ function leafToHtml(leaf) {
1667
1662
  return s;
1668
1663
  }
1669
1664
  function cellInnerHtml(cell) {
1670
- const paras = cell.children.filter(isElement);
1665
+ const paras = cell.children.filter(_chunkGQ2HHRGIcjs.isElement);
1671
1666
  const src = paras.length ? paras : [cell];
1672
1667
  return src.map((p) => leaves(p).map(leafToHtml).join("")).join("<br>");
1673
1668
  }
1674
1669
  function tableHasExtras(n) {
1675
1670
  if (Number(_nullishCoalesce(_optionalChain([n, 'access', _138 => _138.attrs, 'optionalAccess', _139 => _139.freezeRows]), () => ( 0))) > 0 || Number(_nullishCoalesce(_optionalChain([n, 'access', _140 => _140.attrs, 'optionalAccess', _141 => _141.freezeCols]), () => ( 0))) > 0)
1676
1671
  return true;
1677
- return n.children.filter(isElement).some((c) => colspanOf(c) > 1 || rowspanOf(c) > 1 || _optionalChain([c, 'access', _142 => _142.attrs, 'optionalAccess', _143 => _143.bg]) != null || _optionalChain([c, 'access', _144 => _144.attrs, 'optionalAccess', _145 => _145.border]) != null || c.children.filter(isElement).length > 1);
1672
+ return n.children.filter(_chunkGQ2HHRGIcjs.isElement).some((c) => colspanOf(c) > 1 || rowspanOf(c) > 1 || _optionalChain([c, 'access', _142 => _142.attrs, 'optionalAccess', _143 => _143.bg]) != null || _optionalChain([c, 'access', _144 => _144.attrs, 'optionalAccess', _145 => _145.border]) != null || c.children.filter(_chunkGQ2HHRGIcjs.isElement).length > 1);
1678
1673
  }
1679
1674
  function tableToHtml(n) {
1680
1675
  const grid = buildGrid(n);
@@ -1705,7 +1700,7 @@ function tableToHtml(n) {
1705
1700
  return `<table${tableAttrs}>${trs.join("")}</table>`;
1706
1701
  }
1707
1702
  function containerToHtml(openAttrs, children) {
1708
- const inner = children.filter(isElement).map((c) => _mdastutiltomarkdown.toMarkdown.call(void 0, { type: "root", children: [nodeToMdast(c)] }, { extensions: [_mdastutilgfm.gfmToMarkdown.call(void 0, )] }).trimEnd()).join("\n\n");
1703
+ const inner = children.filter(_chunkGQ2HHRGIcjs.isElement).map((c) => _mdastutiltomarkdown.toMarkdown.call(void 0, { type: "root", children: [nodeToMdast(c)] }, { extensions: [_mdastutilgfm.gfmToMarkdown.call(void 0, )] }).trimEnd()).join("\n\n");
1709
1704
  return `<div ${openAttrs}>
1710
1705
 
1711
1706
  ${inner}
@@ -1783,13 +1778,13 @@ function nodeToMdast(n) {
1783
1778
  return { type: "paragraph", children: phrasingChildren(n) };
1784
1779
  }
1785
1780
  case "quote":
1786
- return { type: "blockquote", children: n.children.filter(isElement).map(nodeToMdast) };
1781
+ return { type: "blockquote", children: n.children.filter(_chunkGQ2HHRGIcjs.isElement).map(nodeToMdast) };
1787
1782
  case "callout":
1788
1783
  return { type: "html", value: calloutToHtml(n) };
1789
1784
  case "list":
1790
- return { type: "list", ordered: !!_optionalChain([n, 'access', _167 => _167.attrs, 'optionalAccess', _168 => _168.ordered]), start: _nullishCoalesce(_optionalChain([n, 'access', _169 => _169.attrs, 'optionalAccess', _170 => _170.start]), () => ( null)), children: n.children.filter(isElement).map(nodeToMdast) };
1785
+ return { type: "list", ordered: !!_optionalChain([n, 'access', _167 => _167.attrs, 'optionalAccess', _168 => _168.ordered]), start: _nullishCoalesce(_optionalChain([n, 'access', _169 => _169.attrs, 'optionalAccess', _170 => _170.start]), () => ( null)), children: n.children.filter(_chunkGQ2HHRGIcjs.isElement).map(nodeToMdast) };
1791
1786
  case "list_item":
1792
- return { type: "listItem", checked: _nullishCoalesce(_optionalChain([n, 'access', _171 => _171.attrs, 'optionalAccess', _172 => _172.checked]), () => ( null)), children: n.children.filter(isElement).map(nodeToMdast) };
1787
+ return { type: "listItem", checked: _nullishCoalesce(_optionalChain([n, 'access', _171 => _171.attrs, 'optionalAccess', _172 => _172.checked]), () => ( null)), children: n.children.filter(_chunkGQ2HHRGIcjs.isElement).map(nodeToMdast) };
1793
1788
  case "code":
1794
1789
  return { type: "code", lang: _nullishCoalesce(_optionalChain([n, 'access', _173 => _173.attrs, 'optionalAccess', _174 => _174.lang]), () => ( null)), meta: _nullishCoalesce(_optionalChain([n, 'access', _175 => _175.attrs, 'optionalAccess', _176 => _176.meta]), () => ( null)), value: _nullishCoalesce(_optionalChain([leaves, 'call', _177 => _177(n), 'access', _178 => _178[0], 'optionalAccess', _179 => _179.text]), () => ( "")) };
1795
1790
  case "table":
@@ -1833,10 +1828,10 @@ function clean(block, srcMd) {
1833
1828
  if (!s)
1834
1829
  return false;
1835
1830
  const reparsed = mdToDoc(srcMd.slice(s[0], s[1])).children[0];
1836
- return !!reparsed && !isText(reparsed) && eq(block, reparsed);
1831
+ return !!reparsed && !_chunkGQ2HHRGIcjs.isText.call(void 0, reparsed) && eq(block, reparsed);
1837
1832
  }
1838
- var isOpaqueBlock = (n) => !isText(n) && (n.type === "table" || n.type === "image" || n.type === "embed" || n.type === "raw" && _optionalChain([n, 'access', _185 => _185.attrs, 'optionalAccess', _186 => _186.mdType]) === "thematicBreak");
1839
- var isSynthGapPara = (n) => !isText(n) && n.type === "paragraph" && !_optionalChain([n, 'access', _187 => _187.attrs, 'optionalAccess', _188 => _188.span]) && n.children.length === 1 && isText(n.children[0]) && n.children[0].text === "";
1833
+ var isOpaqueBlock = (n) => !_chunkGQ2HHRGIcjs.isText.call(void 0, n) && (n.type === "table" || n.type === "image" || n.type === "embed" || n.type === "raw" && _optionalChain([n, 'access', _185 => _185.attrs, 'optionalAccess', _186 => _186.mdType]) === "thematicBreak");
1834
+ var isSynthGapPara = (n) => !_chunkGQ2HHRGIcjs.isText.call(void 0, n) && n.type === "paragraph" && !_optionalChain([n, 'access', _187 => _187.attrs, 'optionalAccess', _188 => _188.span]) && n.children.length === 1 && _chunkGQ2HHRGIcjs.isText.call(void 0, n.children[0]) && n.children[0].text === "";
1840
1835
  function trimSynthGapPara(children) {
1841
1836
  return children.filter((n, i) => {
1842
1837
  if (!isSynthGapPara(n))
@@ -1851,7 +1846,7 @@ function docToMd(doc, srcMd) {
1851
1846
  let cursor = 0;
1852
1847
  const blocks = trimSynthGapPara(doc.children);
1853
1848
  for (const block of blocks) {
1854
- if (isText(block))
1849
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, block))
1855
1850
  continue;
1856
1851
  const s = _optionalChain([block, 'access', _189 => _189.attrs, 'optionalAccess', _190 => _190.span]);
1857
1852
  if (s)
@@ -1917,7 +1912,7 @@ function maxReachableDepth(schema) {
1917
1912
  }
1918
1913
  function validate(schema, doc) {
1919
1914
  function check(node, typePath) {
1920
- if (isText(node))
1915
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
1921
1916
  return true;
1922
1917
  const spec = schema.nodes[node.type];
1923
1918
  if (!spec)
@@ -1925,7 +1920,7 @@ function validate(schema, doc) {
1925
1920
  if (spec.atom)
1926
1921
  return true;
1927
1922
  for (const child of node.children) {
1928
- const childType = isText(child) ? "text" : child.type;
1923
+ const childType = _chunkGQ2HHRGIcjs.isText.call(void 0, child) ? "text" : child.type;
1929
1924
  if (!spec.content.includes(childType))
1930
1925
  return `${typePath}/${node.type}: \u4E0D\u5141\u8BB8 child "${childType}"`;
1931
1926
  const r = check(child, `${typePath}/${node.type}`);
@@ -1939,7 +1934,7 @@ function validate(schema, doc) {
1939
1934
  function validateAll(schema, doc) {
1940
1935
  const out = [];
1941
1936
  function check(node, path) {
1942
- if (isText(node))
1937
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
1943
1938
  return;
1944
1939
  const spec = schema.nodes[node.type];
1945
1940
  if (!spec) {
@@ -1950,7 +1945,7 @@ function validateAll(schema, doc) {
1950
1945
  return;
1951
1946
  for (let i = 0; i < node.children.length; i++) {
1952
1947
  const child = node.children[i];
1953
- const childType = isText(child) ? "text" : child.type;
1948
+ const childType = _chunkGQ2HHRGIcjs.isText.call(void 0, child) ? "text" : child.type;
1954
1949
  if (!spec.content.includes(childType))
1955
1950
  out.push({ path: path.concat(i), reason: `${node.type} \u4E0D\u5141\u8BB8 child "${childType}"` });
1956
1951
  check(child, path.concat(i));
@@ -2000,14 +1995,14 @@ function apply(doc, step) {
2000
1995
  switch (step.kind) {
2001
1996
  case "insertText": {
2002
1997
  const leaf = nodeAt(doc, step.path);
2003
- if (!isText(leaf))
1998
+ if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
2004
1999
  throw new Error("insertText \u76EE\u6807\u4E0D\u662F\u6587\u672C\u53F6");
2005
2000
  const text = leaf.text.slice(0, step.offset) + step.text + leaf.text.slice(step.offset);
2006
2001
  return replaceAt(doc, step.path, { ...leaf, text });
2007
2002
  }
2008
2003
  case "deleteText": {
2009
2004
  const leaf = nodeAt(doc, step.path);
2010
- if (!isText(leaf))
2005
+ if (!_chunkGQ2HHRGIcjs.isText.call(void 0, leaf))
2011
2006
  throw new Error("deleteText \u76EE\u6807\u4E0D\u662F\u6587\u672C\u53F6");
2012
2007
  const text = leaf.text.slice(0, step.offset) + leaf.text.slice(step.offset + step.length);
2013
2008
  return replaceAt(doc, step.path, { ...leaf, text });
@@ -2063,7 +2058,7 @@ function invertAll(doc, steps) {
2063
2058
  // src/tree/ai.ts
2064
2059
  function pathOfId(doc, id) {
2065
2060
  function walk(node, prefix) {
2066
- if (isText(node))
2061
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
2067
2062
  return null;
2068
2063
  if (node.id === id)
2069
2064
  return prefix;
@@ -2079,7 +2074,7 @@ function pathOfId(doc, id) {
2079
2074
  function buildIdIndex(doc) {
2080
2075
  const index = /* @__PURE__ */ new Map();
2081
2076
  function walk(node, prefix) {
2082
- if (isText(node))
2077
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
2083
2078
  return;
2084
2079
  if (node.id !== void 0 && !index.has(node.id))
2085
2080
  index.set(node.id, prefix);
@@ -2091,19 +2086,19 @@ function buildIdIndex(doc) {
2091
2086
  }
2092
2087
  function leafPathAndLen(doc, blockPath) {
2093
2088
  const block = blockPath.reduce((n, i2) => n.children[i2], doc);
2094
- if (!isElement(block))
2089
+ if (!_chunkGQ2HHRGIcjs.isElement.call(void 0, block))
2095
2090
  throw new Error("\u5757\u4E0D\u662F\u5143\u7D20");
2096
- const i = block.children.findIndex(isText);
2091
+ const i = block.children.findIndex(_chunkGQ2HHRGIcjs.isText);
2097
2092
  if (i === -1)
2098
2093
  return null;
2099
2094
  const leaf = block.children[i];
2100
- return { path: blockPath.concat(i), len: isText(leaf) ? leaf.text.length : 0 };
2095
+ return { path: blockPath.concat(i), len: _chunkGQ2HHRGIcjs.isText.call(void 0, leaf) ? leaf.text.length : 0 };
2101
2096
  }
2102
2097
  function resolve2(doc, id, index) {
2103
2098
  return index ? _nullishCoalesce(index.get(id), () => ( null)) : pathOfId(doc, id);
2104
2099
  }
2105
2100
  function collectIds(node, out) {
2106
- if (isText(node))
2101
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
2107
2102
  return;
2108
2103
  if (node.id !== void 0)
2109
2104
  out.push(node.id);
@@ -2134,7 +2129,7 @@ function appendText(doc, blockId, text, index) {
2134
2129
  }
2135
2130
  function badTable(doc) {
2136
2131
  for (const c of doc.children) {
2137
- if (!isText(c) && c.type === "table") {
2132
+ if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "table") {
2138
2133
  const errs = checkTable(c);
2139
2134
  if (errs.length > 0)
2140
2135
  return errs[0];
@@ -2190,7 +2185,7 @@ function insertAfter(doc, afterId, nodes, index, schema) {
2190
2185
  function idBlocks(doc) {
2191
2186
  const out = [];
2192
2187
  function walk(node) {
2193
- if (isText(node))
2188
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
2194
2189
  return;
2195
2190
  if (node.id)
2196
2191
  out.push(node);
@@ -2299,7 +2294,4 @@ function deepEqual(a, b) {
2299
2294
 
2300
2295
 
2301
2296
 
2302
-
2303
-
2304
-
2305
- exports.isText = isText; exports.isElement = isElement; exports.isInlineAtom = isInlineAtom; 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.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;
2297
+ 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.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;