markloom 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/ai.md +160 -0
- package/collab.md +70 -0
- package/dist/ai/index.cjs +4 -3
- package/dist/ai/index.d.cts +4 -2
- package/dist/ai/index.d.ts +4 -2
- package/dist/ai/index.js +3 -2
- package/dist/chunk-4JSJAHTB.js +255 -0
- package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
- package/dist/chunk-ALZ3A5CS.cjs +255 -0
- package/dist/{chunk-QXJHFQLJ.js → chunk-FCH7LZFI.js} +23 -15
- package/dist/chunk-GQ2HHRGI.cjs +16 -0
- package/dist/chunk-JS527FDV.cjs +294 -0
- package/dist/chunk-LA5SBCGQ.js +16 -0
- package/dist/{chunk-ITVAR2UM.js → chunk-LEYAQNJA.js} +5 -3
- package/dist/{chunk-J3QWW6CN.js → chunk-MFYF2A6U.js} +5 -13
- package/dist/chunk-RLTHVQNQ.js +294 -0
- package/dist/{chunk-VSTOMEU2.cjs → chunk-VXM7Q6P5.cjs} +813 -478
- package/dist/{chunk-LNSKDJMF.cjs → chunk-YIFOGP2D.cjs} +46 -38
- package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
- package/dist/{chunk-VMUJM52A.js → chunk-ZMTLSFLO.js} +350 -15
- package/dist/client-6KiH4kGK.d.ts +144 -0
- package/dist/client-ZRZj2nkq.d.cts +144 -0
- package/dist/collab/index.cjs +25 -0
- package/dist/collab/index.d.cts +11 -0
- package/dist/collab/index.d.ts +11 -0
- package/dist/collab/index.js +25 -0
- package/dist/comments-DlExS6f-.d.cts +43 -0
- package/dist/comments-PhnR7Gkn.d.ts +43 -0
- package/dist/{controller-B_wG2Wh-.d.ts → controller-BNuuUM3E.d.ts} +26 -2
- package/dist/{controller-Cd1Dprrk.d.cts → controller-DQITsFhy.d.cts} +26 -2
- package/dist/index.cjs +21 -243
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +22 -244
- package/dist/react/index.cjs +8 -5
- package/dist/react/index.d.cts +4 -2
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +7 -4
- package/dist/rebase-batch-8rL_aXEE.d.ts +38 -0
- package/dist/rebase-batch-bYnBJpRO.d.cts +38 -0
- package/dist/step-BrvHIK7O.d.cts +65 -0
- package/dist/step-BrvHIK7O.d.ts +65 -0
- package/dist/view/index.cjs +11 -8
- package/dist/view/index.d.cts +5 -3
- package/dist/view/index.d.ts +5 -3
- package/dist/view/index.js +7 -4
- package/dist/view/theme.css +72 -0
- package/package.json +10 -3
- package/dist/comments-USjT1wYN.d.cts +0 -105
- package/dist/comments-USjT1wYN.d.ts +0 -105
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
|
|
10
12
|
|
|
11
13
|
// src/view/selection.ts
|
|
12
14
|
function rootEl(root) {
|
|
@@ -68,7 +70,7 @@ function domToPoint(root, doc, container, domOffset) {
|
|
|
68
70
|
}
|
|
69
71
|
if (segs.length === 0)
|
|
70
72
|
return null;
|
|
71
|
-
return { path:
|
|
73
|
+
return { path: _chunk4TMHVNL6cjs.normalizeToLeaf.call(void 0, doc, segs.concat(charOffset)) };
|
|
72
74
|
}
|
|
73
75
|
function readSelection(root, doc) {
|
|
74
76
|
const sel = root.ownerDocument.getSelection();
|
|
@@ -216,18 +218,18 @@ function focusBlockId(ed) {
|
|
|
216
218
|
const sel = readSelection(ed.root, ed.doc);
|
|
217
219
|
const idx = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _8 => _8.head, 'access', _9 => _9.path, 'access', _10 => _10[0]]), () => ( Math.max(0, ed.doc.children.length - 1)));
|
|
218
220
|
const b = ed.doc.children[idx];
|
|
219
|
-
if (!b ||
|
|
221
|
+
if (!b || _chunkGQ2HHRGIcjs.isText.call(void 0, b) || !b.id)
|
|
220
222
|
return null;
|
|
221
223
|
return b.id;
|
|
222
224
|
}
|
|
223
225
|
function blockPlainText(doc, blockId) {
|
|
224
|
-
const b = doc.children.find((c) => !
|
|
226
|
+
const b = doc.children.find((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === blockId);
|
|
225
227
|
if (!b)
|
|
226
228
|
return "";
|
|
227
229
|
return collectText(b);
|
|
228
230
|
}
|
|
229
231
|
function collectText(n) {
|
|
230
|
-
if (
|
|
232
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n))
|
|
231
233
|
return n.text;
|
|
232
234
|
return n.children.map(collectText).join("");
|
|
233
235
|
}
|
|
@@ -247,11 +249,11 @@ function emptyLike(block) {
|
|
|
247
249
|
return { type: "paragraph", id: block.id, attrs: block.attrs ? { ...block.attrs } : void 0, children: [{ text: "" }] };
|
|
248
250
|
}
|
|
249
251
|
function streamTargetId(doc, blockId) {
|
|
250
|
-
const b = doc.children.find((c) => !
|
|
252
|
+
const b = doc.children.find((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === blockId);
|
|
251
253
|
if (!b)
|
|
252
254
|
return blockId;
|
|
253
255
|
if (b.type === "quote" || b.type === "callout") {
|
|
254
|
-
const inner = b.children.find((c) => !
|
|
256
|
+
const inner = b.children.find((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.type === "paragraph");
|
|
255
257
|
if (_optionalChain([inner, 'optionalAccess', _11 => _11.id]))
|
|
256
258
|
return inner.id;
|
|
257
259
|
}
|
|
@@ -273,16 +275,16 @@ function startAiWrite(ed, mode, blockId) {
|
|
|
273
275
|
if (mode === "continue") {
|
|
274
276
|
const id = newId();
|
|
275
277
|
const empty = { type: "paragraph", id, children: [{ text: "" }] };
|
|
276
|
-
ed.dispatch([
|
|
278
|
+
ed.dispatch([_chunk4TMHVNL6cjs.insertAfter.call(void 0, doc, focus, [empty])]);
|
|
277
279
|
targetId = id;
|
|
278
280
|
} else {
|
|
279
|
-
const block = doc.children.find((c) => !
|
|
281
|
+
const block = doc.children.find((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === focus);
|
|
280
282
|
if (!block)
|
|
281
283
|
throw new Error(`block not found: ${focus}`);
|
|
282
284
|
if (block.type === "table" || block.type === "image" || block.type === "embed" || block.type === "raw")
|
|
283
285
|
throw new Error(`cannot rewrite ${block.type}`);
|
|
284
286
|
const cleared = emptyLike(block);
|
|
285
|
-
ed.dispatch([
|
|
287
|
+
ed.dispatch([_chunk4TMHVNL6cjs.rewriteNode.call(void 0, doc, focus, cleared)]);
|
|
286
288
|
targetId = streamTargetId(ed.doc, focus);
|
|
287
289
|
}
|
|
288
290
|
opened = true;
|
|
@@ -291,7 +293,7 @@ function startAiWrite(ed, mode, blockId) {
|
|
|
291
293
|
if (!alive || !text)
|
|
292
294
|
return;
|
|
293
295
|
setup();
|
|
294
|
-
const step =
|
|
296
|
+
const step = _chunk4TMHVNL6cjs.appendText.call(void 0, ed.doc, targetId, text);
|
|
295
297
|
ed.dispatchStream([step]);
|
|
296
298
|
};
|
|
297
299
|
const finish = () => {
|
|
@@ -316,7 +318,7 @@ function precedingPlainText(doc, blockIdx) {
|
|
|
316
318
|
const parts = [];
|
|
317
319
|
for (let i = 0; i < blockIdx && i < doc.children.length; i++) {
|
|
318
320
|
const b = doc.children[i];
|
|
319
|
-
if (
|
|
321
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, b) || !b.id)
|
|
320
322
|
continue;
|
|
321
323
|
if (b.type === "image" || b.type === "table" || b.type === "embed" || b.type === "raw" || b.type === "ai")
|
|
322
324
|
continue;
|
|
@@ -409,7 +411,7 @@ var MarkloomAi = (_class = class {
|
|
|
409
411
|
return;
|
|
410
412
|
}
|
|
411
413
|
const doc = ed.doc;
|
|
412
|
-
const idx = doc.children.findIndex((c) => !
|
|
414
|
+
const idx = doc.children.findIndex((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === bid);
|
|
413
415
|
if (idx < 0)
|
|
414
416
|
return;
|
|
415
417
|
const cur = doc.children[idx];
|
|
@@ -618,7 +620,7 @@ var MarkloomAi = (_class = class {
|
|
|
618
620
|
const steps = [];
|
|
619
621
|
for (let i = 0; i < doc.children.length; i++) {
|
|
620
622
|
const c = doc.children[i];
|
|
621
|
-
if (
|
|
623
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c) || _optionalChain([c, 'access', _57 => _57.attrs, 'optionalAccess', _58 => _58.aiFrom]) !== blockId)
|
|
622
624
|
continue;
|
|
623
625
|
const attrs = { ..._nullishCoalesce(c.attrs, () => ( {})) };
|
|
624
626
|
delete attrs.aiDraft;
|
|
@@ -634,12 +636,12 @@ var MarkloomAi = (_class = class {
|
|
|
634
636
|
next.attrs = clean;
|
|
635
637
|
steps.push({ kind: "replaceNode", path: [i], node: next });
|
|
636
638
|
}
|
|
637
|
-
const aiIdx0 = doc.children.findIndex((c) => !
|
|
639
|
+
const aiIdx0 = doc.children.findIndex((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === blockId);
|
|
638
640
|
if (aiIdx0 >= 0)
|
|
639
641
|
steps.push({ kind: "spliceChildren", path: [], at: aiIdx0, remove: 1, insert: [] });
|
|
640
642
|
if (!steps.length)
|
|
641
643
|
return;
|
|
642
|
-
const firstDraft = doc.children.findIndex((c) => !
|
|
644
|
+
const firstDraft = doc.children.findIndex((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && _optionalChain([c, 'access', _59 => _59.attrs, 'optionalAccess', _60 => _60.aiFrom]) === blockId);
|
|
643
645
|
let caretAt = firstDraft >= 0 ? firstDraft : Math.max(0, aiIdx0);
|
|
644
646
|
if (firstDraft > aiIdx0)
|
|
645
647
|
caretAt = firstDraft - 1;
|
|
@@ -658,7 +660,7 @@ var MarkloomAi = (_class = class {
|
|
|
658
660
|
this.txOpen = false;
|
|
659
661
|
this.txBlockId = null;
|
|
660
662
|
}
|
|
661
|
-
/** 整笔撤回事务(= undo) */
|
|
663
|
+
/** 整笔撤回事务(= undo);务必不留 aiDraft 孤儿段 */
|
|
662
664
|
discard(blockId) {
|
|
663
665
|
if (this.streamingId === blockId) {
|
|
664
666
|
_optionalChain([this, 'access', _61 => _61.abort, 'optionalAccess', _62 => _62.abort, 'call', _63 => _63()]);
|
|
@@ -670,39 +672,45 @@ var MarkloomAi = (_class = class {
|
|
|
670
672
|
}
|
|
671
673
|
if (this.txOpen && (this.txBlockId === blockId || !this.txBlockId)) {
|
|
672
674
|
this.rollback();
|
|
675
|
+
this.purgeDrafts(blockId);
|
|
673
676
|
return;
|
|
674
677
|
}
|
|
678
|
+
this.purgeDrafts(blockId, true);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* 清掉 aiFrom=blockId 的顶层 draft;shell=true 时把 ai 壳也换成空段。
|
|
682
|
+
* discard / 异常恢复共用。
|
|
683
|
+
*/
|
|
684
|
+
purgeDrafts(blockId, shell = false) {
|
|
675
685
|
const ed = this.getEditor();
|
|
676
686
|
if (!ed)
|
|
677
687
|
return;
|
|
678
|
-
const found = this.findAi(ed, blockId);
|
|
679
|
-
if (!found)
|
|
680
|
-
return;
|
|
681
|
-
const steps = [];
|
|
682
688
|
const doc = ed.doc;
|
|
689
|
+
const steps = [];
|
|
683
690
|
const idxs = draftIndices(doc, blockId);
|
|
684
691
|
for (let i = idxs.length - 1; i >= 0; i--)
|
|
685
692
|
steps.push({ kind: "spliceChildren", path: [], at: idxs[i], remove: 1, insert: [] });
|
|
686
|
-
let aiIdx = doc.children.findIndex((c) => !
|
|
693
|
+
let aiIdx = doc.children.findIndex((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === blockId);
|
|
687
694
|
let shift = 0;
|
|
688
695
|
for (const i of idxs) {
|
|
689
696
|
if (i < aiIdx)
|
|
690
697
|
shift++;
|
|
691
698
|
}
|
|
692
699
|
aiIdx -= shift;
|
|
693
|
-
if (aiIdx >= 0) {
|
|
700
|
+
if (shell && aiIdx >= 0) {
|
|
694
701
|
steps.push({
|
|
695
702
|
kind: "replaceNode",
|
|
696
703
|
path: [aiIdx],
|
|
697
|
-
node: { type: "paragraph", id:
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
if (steps.length) {
|
|
701
|
-
ed.dispatch(steps, {
|
|
702
|
-
anchor: { path: [Math.max(0, aiIdx), 0, 0] },
|
|
703
|
-
head: { path: [Math.max(0, aiIdx), 0, 0] }
|
|
704
|
+
node: { type: "paragraph", id: blockId, children: [{ text: "" }] }
|
|
704
705
|
});
|
|
705
706
|
}
|
|
707
|
+
if (!steps.length)
|
|
708
|
+
return;
|
|
709
|
+
const caretAt = Math.max(0, aiIdx >= 0 ? aiIdx : _nullishCoalesce(idxs[0], () => ( 0)));
|
|
710
|
+
ed.dispatch(steps, {
|
|
711
|
+
anchor: { path: [caretAt, 0, 0] },
|
|
712
|
+
head: { path: [caretAt, 0, 0] }
|
|
713
|
+
});
|
|
706
714
|
}
|
|
707
715
|
act(blockId, action) {
|
|
708
716
|
if (action === "accept")
|
|
@@ -722,11 +730,11 @@ var MarkloomAi = (_class = class {
|
|
|
722
730
|
this.txBlockId = null;
|
|
723
731
|
}
|
|
724
732
|
findAi(ed, blockId) {
|
|
725
|
-
const path =
|
|
733
|
+
const path = _chunk4TMHVNL6cjs.pathOfId.call(void 0, ed.doc, blockId);
|
|
726
734
|
if (!path)
|
|
727
735
|
return null;
|
|
728
736
|
const node = path.reduce((n, i) => n.children[i], ed.doc);
|
|
729
|
-
if (!node ||
|
|
737
|
+
if (!node || _chunkGQ2HHRGIcjs.isText.call(void 0, node) || node.type !== "ai")
|
|
730
738
|
return null;
|
|
731
739
|
return { path, node };
|
|
732
740
|
}
|
|
@@ -750,7 +758,7 @@ var MarkloomAi = (_class = class {
|
|
|
750
758
|
paintMd(ed, blockId, md, streaming) {
|
|
751
759
|
const doc = ed.doc;
|
|
752
760
|
const idxs = draftIndices(doc, blockId);
|
|
753
|
-
const aiIdx = doc.children.findIndex((c) => !
|
|
761
|
+
const aiIdx = doc.children.findIndex((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c) && c.id === blockId);
|
|
754
762
|
const at = idxs.length ? idxs[0] : aiIdx >= 0 ? aiIdx + 1 : -1;
|
|
755
763
|
if (at < 0)
|
|
756
764
|
return;
|
|
@@ -780,7 +788,7 @@ var MarkloomAi = (_class = class {
|
|
|
780
788
|
const src = streaming ? softCloseMd(raw) : raw;
|
|
781
789
|
let blocks;
|
|
782
790
|
try {
|
|
783
|
-
const tops =
|
|
791
|
+
const tops = _chunk4TMHVNL6cjs.mdToDoc.call(void 0, src).children.filter((c) => !_chunkGQ2HHRGIcjs.isText.call(void 0, c));
|
|
784
792
|
blocks = tops.map((c, i) => stampDraft(c, blockId, `${blockId}_d${i}`, streaming && i === tops.length - 1));
|
|
785
793
|
} catch (e2) {
|
|
786
794
|
blocks = [{
|
|
@@ -869,7 +877,7 @@ function softCloseMd(md) {
|
|
|
869
877
|
}
|
|
870
878
|
function stampDraft(node, aiFrom, id, streamTail = false) {
|
|
871
879
|
const kids = node.children.map((c, i) => {
|
|
872
|
-
if (
|
|
880
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
|
|
873
881
|
return c;
|
|
874
882
|
return stampInner(c, `${id}_${i}`);
|
|
875
883
|
});
|
|
@@ -880,7 +888,7 @@ function stampDraft(node, aiFrom, id, streamTail = false) {
|
|
|
880
888
|
}
|
|
881
889
|
function stampInner(node, id) {
|
|
882
890
|
const kids = node.children.map((c, i) => {
|
|
883
|
-
if (
|
|
891
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
|
|
884
892
|
return c;
|
|
885
893
|
return stampInner(c, `${id}_${i}`);
|
|
886
894
|
});
|
|
@@ -895,7 +903,7 @@ function draftIndices(doc, aiId) {
|
|
|
895
903
|
const out = [];
|
|
896
904
|
for (let i = 0; i < doc.children.length; i++) {
|
|
897
905
|
const c = doc.children[i];
|
|
898
|
-
if (!
|
|
906
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) && _optionalChain([c, 'access', _67 => _67.attrs, 'optionalAccess', _68 => _68.aiFrom]) === aiId)
|
|
899
907
|
out.push(i);
|
|
900
908
|
}
|
|
901
909
|
return out;
|
|
@@ -905,7 +913,7 @@ function promptText(ai) {
|
|
|
905
913
|
return p ? collectText2(p) : "";
|
|
906
914
|
}
|
|
907
915
|
function collectText2(n) {
|
|
908
|
-
if (
|
|
916
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n))
|
|
909
917
|
return n.text;
|
|
910
918
|
return n.children.map(collectText2).join("");
|
|
911
919
|
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
|
|
10
12
|
|
|
11
13
|
// src/tree/history.ts
|
|
12
14
|
function init(doc, validate) {
|
|
@@ -18,8 +20,8 @@ function gate(h, next) {
|
|
|
18
20
|
throw new Error(`[invariant] \u63D0\u4EA4\u4EA7\u751F\u975E\u6CD5 doc: ${v}`);
|
|
19
21
|
}
|
|
20
22
|
function commit(h, steps) {
|
|
21
|
-
const inverse =
|
|
22
|
-
const next =
|
|
23
|
+
const inverse = _chunk4TMHVNL6cjs.invertAll.call(void 0, h.doc, steps);
|
|
24
|
+
const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, steps);
|
|
23
25
|
gate(h, next);
|
|
24
26
|
return { ...h, doc: next, past: h.past.concat({ steps, inverse }), future: [] };
|
|
25
27
|
}
|
|
@@ -29,10 +31,10 @@ function amend(h, more) {
|
|
|
29
31
|
if (h.past.length === 0)
|
|
30
32
|
return commit(h, more);
|
|
31
33
|
const last = h.past[h.past.length - 1];
|
|
32
|
-
const before =
|
|
34
|
+
const before = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, last.inverse);
|
|
33
35
|
const steps = last.steps.concat(more);
|
|
34
|
-
const inverse =
|
|
35
|
-
const next =
|
|
36
|
+
const inverse = _chunk4TMHVNL6cjs.invertAll.call(void 0, before, steps);
|
|
37
|
+
const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, before, steps);
|
|
36
38
|
gate(h, next);
|
|
37
39
|
return {
|
|
38
40
|
...h,
|
|
@@ -45,7 +47,7 @@ function undo(h) {
|
|
|
45
47
|
const last = h.past[h.past.length - 1];
|
|
46
48
|
if (!last)
|
|
47
49
|
return h;
|
|
48
|
-
const next =
|
|
50
|
+
const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, last.inverse);
|
|
49
51
|
gate(h, next);
|
|
50
52
|
return { ...h, doc: next, past: h.past.slice(0, -1), future: [last, ...h.future] };
|
|
51
53
|
}
|
|
@@ -53,7 +55,7 @@ function redo(h) {
|
|
|
53
55
|
const next = h.future[0];
|
|
54
56
|
if (!next)
|
|
55
57
|
return h;
|
|
56
|
-
const doc =
|
|
58
|
+
const doc = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, next.steps);
|
|
57
59
|
gate(h, doc);
|
|
58
60
|
return { ...h, doc, past: h.past.concat(next), future: h.future.slice(1) };
|
|
59
61
|
}
|
|
@@ -61,13 +63,13 @@ function redo(h) {
|
|
|
61
63
|
// src/tree/invariants.ts
|
|
62
64
|
function invariants(schema, doc) {
|
|
63
65
|
const out = [];
|
|
64
|
-
out.push(...
|
|
66
|
+
out.push(..._chunk4TMHVNL6cjs.validateAll.call(void 0, schema, doc));
|
|
65
67
|
const ids = /* @__PURE__ */ new Map();
|
|
66
68
|
walk(doc, [], schema, out, ids);
|
|
67
69
|
return out;
|
|
68
70
|
}
|
|
69
71
|
function walk(node, path, schema, out, ids) {
|
|
70
|
-
if (
|
|
72
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node)) {
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
if (node.id !== void 0) {
|
|
@@ -100,7 +102,7 @@ function walk(node, path, schema, out, ids) {
|
|
|
100
102
|
out.push({ path, reason: `[embed] \u7F3A src` });
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
103
|
-
for (const reason of
|
|
105
|
+
for (const reason of _chunk4TMHVNL6cjs.checkTable.call(void 0, node)) {
|
|
104
106
|
out.push({ path, reason: `[table] ${reason}` });
|
|
105
107
|
}
|
|
106
108
|
return;
|
|
@@ -108,7 +110,7 @@ function walk(node, path, schema, out, ids) {
|
|
|
108
110
|
if (_optionalChain([spec, 'optionalAccess', _14 => _14.marks])) {
|
|
109
111
|
for (let i = 0; i < node.children.length; i++) {
|
|
110
112
|
const child = node.children[i];
|
|
111
|
-
if (
|
|
113
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, child) && child.marks) {
|
|
112
114
|
for (const m of child.marks) {
|
|
113
115
|
if (!spec.marks.includes(m.name)) {
|
|
114
116
|
out.push({ path: path.concat(i), reason: `${node.type} \u4E0D\u5141\u8BB8 mark "${m.name}"` });
|
|
@@ -133,7 +135,7 @@ function firstViolation(vs) {
|
|
|
133
135
|
function headingText(node) {
|
|
134
136
|
let out = "";
|
|
135
137
|
for (const c of node.children) {
|
|
136
|
-
if (
|
|
138
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
|
|
137
139
|
out += c.text;
|
|
138
140
|
}
|
|
139
141
|
return out;
|
|
@@ -141,7 +143,7 @@ function headingText(node) {
|
|
|
141
143
|
function outline(doc) {
|
|
142
144
|
const out = [];
|
|
143
145
|
const walk2 = (node, path) => {
|
|
144
|
-
if (
|
|
146
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
145
147
|
return;
|
|
146
148
|
if (node.type === "heading") {
|
|
147
149
|
const level = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([node, 'access', _15 => _15.attrs, 'optionalAccess', _16 => _16.depth]), () => ( 1))), 1), 6);
|
|
@@ -159,14 +161,14 @@ function outline(doc) {
|
|
|
159
161
|
function commentIdsInDoc(doc) {
|
|
160
162
|
const ids = /* @__PURE__ */ new Set();
|
|
161
163
|
const walk2 = (n) => {
|
|
162
|
-
if (
|
|
164
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n)) {
|
|
163
165
|
for (const m of _nullishCoalesce(n.marks, () => ( []))) {
|
|
164
166
|
if (m.name === "comment" && _optionalChain([m, 'access', _17 => _17.attrs, 'optionalAccess', _18 => _18.id]) != null)
|
|
165
167
|
ids.add(String(m.attrs.id));
|
|
166
168
|
}
|
|
167
169
|
return;
|
|
168
170
|
}
|
|
169
|
-
if (
|
|
171
|
+
if (_chunkGQ2HHRGIcjs.isElement.call(void 0, n))
|
|
170
172
|
for (const c of n.children)
|
|
171
173
|
walk2(c);
|
|
172
174
|
};
|
|
@@ -180,10 +182,10 @@ function stripLeaf(leaf, id) {
|
|
|
180
182
|
function stripCommentMarks(doc, id) {
|
|
181
183
|
const steps = [];
|
|
182
184
|
const walk2 = (node, path) => {
|
|
183
|
-
if (node.children.every((c) =>
|
|
185
|
+
if (node.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) || _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c))) {
|
|
184
186
|
let changed = false;
|
|
185
187
|
const children = node.children.map((c) => {
|
|
186
|
-
if (!
|
|
188
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) || !_optionalChain([c, 'access', _21 => _21.marks, 'optionalAccess', _22 => _22.some, 'call', _23 => _23((m) => m.name === "comment" && String(_optionalChain([m, 'access', _24 => _24.attrs, 'optionalAccess', _25 => _25.id])) === id)]))
|
|
187
189
|
return c;
|
|
188
190
|
changed = true;
|
|
189
191
|
return stripLeaf(c, id);
|
|
@@ -193,12 +195,12 @@ function stripCommentMarks(doc, id) {
|
|
|
193
195
|
return;
|
|
194
196
|
}
|
|
195
197
|
node.children.forEach((c, i) => {
|
|
196
|
-
if (
|
|
198
|
+
if (_chunkGQ2HHRGIcjs.isElement.call(void 0, c))
|
|
197
199
|
walk2(c, path.concat(i));
|
|
198
200
|
});
|
|
199
201
|
};
|
|
200
202
|
doc.children.forEach((c, i) => {
|
|
201
|
-
if (
|
|
203
|
+
if (_chunkGQ2HHRGIcjs.isElement.call(void 0, c))
|
|
202
204
|
walk2(c, [i]);
|
|
203
205
|
});
|
|
204
206
|
return steps;
|