quoin-editor 1.7.0 → 2.0.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/CHANGELOG.md +21 -1
- package/MIGRATION.md +137 -23
- package/README.md +32 -11
- package/dist/ai-labels-BXX32H9a.d.cts +53 -0
- package/dist/ai-labels-BXX32H9a.d.ts +53 -0
- package/dist/ai.cjs +84 -86
- package/dist/ai.d.cts +4 -53
- package/dist/ai.d.ts +4 -53
- package/dist/ai.js +8 -10
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +27 -26
- package/dist/catalogue.d.cts +10 -1
- package/dist/catalogue.d.ts +10 -1
- package/dist/catalogue.js +18 -17
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-MNA7MBCH.js → chunk-2UKI26JA.js} +9 -11
- package/dist/chunk-2UKI26JA.js.map +1 -0
- package/dist/{chunk-MZXW2HXP.cjs → chunk-4PIJC4FD.cjs} +27 -29
- package/dist/{chunk-OS2O6IKX.js → chunk-5RBMZGKV.js} +4 -4
- package/dist/{chunk-OS2O6IKX.js.map → chunk-5RBMZGKV.js.map} +1 -1
- package/dist/{chunk-OJ4O6HWC.js → chunk-5X52BAZB.js} +10 -12
- package/dist/chunk-5X52BAZB.js.map +1 -0
- package/dist/{chunk-JY5VUHKN.cjs → chunk-5YAJZSTI.cjs} +28 -30
- package/dist/{chunk-YEFPH27F.cjs → chunk-66OPHDFA.cjs} +92 -94
- package/dist/{chunk-PWUFFHAQ.js → chunk-6BVE46K7.js} +8 -10
- package/dist/chunk-6BVE46K7.js.map +1 -0
- package/dist/{chunk-LKZJ2TDU.cjs → chunk-77CNOLHY.cjs} +10 -13
- package/dist/{chunk-4T4TJ2QS.cjs → chunk-7E43TURF.cjs} +7 -7
- package/dist/{chunk-BJTOLCRR.js → chunk-7Y4B7NHO.js} +2 -2
- package/dist/chunk-7Y4B7NHO.js.map +1 -0
- package/dist/{chunk-7GU25Z6L.js → chunk-B4VCDJSA.js} +9 -11
- package/dist/chunk-B4VCDJSA.js.map +1 -0
- package/dist/{chunk-QR2NIDUK.cjs → chunk-BYYCD54G.cjs} +2 -2
- package/dist/{chunk-6T5YGCZ5.cjs → chunk-CJVJNMOB.cjs} +302 -299
- package/dist/{chunk-CSKKSXCE.js → chunk-CSPCDVCT.js} +3 -3
- package/dist/{chunk-CSKKSXCE.js.map → chunk-CSPCDVCT.js.map} +1 -1
- package/dist/{chunk-BF7733XS.cjs → chunk-D6CIIWCU.cjs} +57 -59
- package/dist/{chunk-GHNQKJMD.js → chunk-DBOZFNWU.js} +3 -3
- package/dist/{chunk-GHNQKJMD.js.map → chunk-DBOZFNWU.js.map} +1 -1
- package/dist/{chunk-BM2GRZNM.cjs → chunk-DJU25PFC.cjs} +11 -11
- package/dist/chunk-DLQCTGC3.js +10 -0
- package/dist/chunk-DLQCTGC3.js.map +1 -0
- package/dist/{chunk-RQXJKJ5S.js → chunk-EU5IGKMP.js} +7 -10
- package/dist/chunk-EU5IGKMP.js.map +1 -0
- package/dist/{chunk-VZZPCYA3.cjs → chunk-FK7EBZPX.cjs} +226 -226
- package/dist/{chunk-BXSWZEA5.js → chunk-GPTJYWGS.js} +3 -3
- package/dist/{chunk-BXSWZEA5.js.map → chunk-GPTJYWGS.js.map} +1 -1
- package/dist/{chunk-I722LBD3.cjs → chunk-HOSDMHK6.cjs} +32 -34
- package/dist/{chunk-AZF7B2AE.cjs → chunk-IKZSCTRF.cjs} +11 -11
- package/dist/{chunk-R7MYG522.js → chunk-IW4TMECB.js} +3 -3
- package/dist/{chunk-R7MYG522.js.map → chunk-IW4TMECB.js.map} +1 -1
- package/dist/{chunk-PLUMKN4B.js → chunk-J2SVYBTC.js} +10 -12
- package/dist/chunk-J2SVYBTC.js.map +1 -0
- package/dist/{chunk-UZS3TW75.js → chunk-KQPZTSW3.js} +9 -11
- package/dist/chunk-KQPZTSW3.js.map +1 -0
- package/dist/{chunk-STKGRXSA.cjs → chunk-LEICOZYK.cjs} +15 -17
- package/dist/{chunk-H3C3MJW5.cjs → chunk-LM3DHROX.cjs} +2 -2
- package/dist/{chunk-AD3NY7NA.js → chunk-LSI4RMTY.js} +3 -3
- package/dist/{chunk-AD3NY7NA.js.map → chunk-LSI4RMTY.js.map} +1 -1
- package/dist/{chunk-QOIVLYMW.js → chunk-M77A3EGD.js} +5 -5
- package/dist/{chunk-QOIVLYMW.js.map → chunk-M77A3EGD.js.map} +1 -1
- package/dist/{chunk-5JEQZIRI.js → chunk-MAS4AEF4.js} +8 -10
- package/dist/chunk-MAS4AEF4.js.map +1 -0
- package/dist/{chunk-KDK2ATMB.cjs → chunk-NFO3W644.cjs} +51 -53
- package/dist/{chunk-XFEDJEJF.js → chunk-NL5J77VD.js} +204 -204
- package/dist/chunk-NL5J77VD.js.map +1 -0
- package/dist/{chunk-WN7BZDNH.cjs → chunk-PURYVDC3.cjs} +13 -13
- package/dist/{chunk-G25FMFEZ.js → chunk-UDBLZILE.js} +4 -4
- package/dist/{chunk-G25FMFEZ.js.map → chunk-UDBLZILE.js.map} +1 -1
- package/dist/{chunk-FNJOPGMN.cjs → chunk-V4WQG7FR.cjs} +116 -118
- package/dist/{chunk-IJKGF6SC.js → chunk-YABGWOAV.js} +8 -10
- package/dist/chunk-YABGWOAV.js.map +1 -0
- package/dist/{chunk-XZ4NC3Q7.cjs → chunk-YEDPBYO5.cjs} +4 -4
- package/dist/{chunk-QJ34MOFV.cjs → chunk-Z6LAARPB.cjs} +315 -320
- package/dist/{chunk-HSLOPJVT.js → chunk-ZN5DHNSL.js} +19 -16
- package/dist/chunk-ZN5DHNSL.js.map +1 -0
- package/dist/chunk-ZWTIRGY5.cjs +10 -0
- package/dist/comments-labels-DWqsSz8G.d.cts +30 -0
- package/dist/comments-labels-DWqsSz8G.d.ts +30 -0
- package/dist/comments.cjs +63 -65
- package/dist/comments.d.cts +4 -30
- package/dist/comments.d.ts +4 -30
- package/dist/comments.js +9 -11
- package/dist/comments.js.map +1 -1
- package/dist/{diagram-extension-Da7hp-tv.d.ts → diagram-extension-22x_njXB.d.ts} +4 -12
- package/dist/{diagram-extension-D573COJv.d.cts → diagram-extension-C_FSkoj9.d.cts} +4 -12
- package/dist/diagram-labels-Bi_jEZ8_.d.cts +11 -0
- package/dist/diagram-labels-Bi_jEZ8_.d.ts +11 -0
- package/dist/diagram.cjs +10 -9
- package/dist/diagram.d.cts +3 -2
- package/dist/diagram.d.ts +3 -2
- package/dist/diagram.js +7 -6
- package/dist/diff-labels-DWwg7N0n.d.cts +27 -0
- package/dist/diff-labels-DWwg7N0n.d.ts +27 -0
- package/dist/diff.cjs +27 -29
- package/dist/diff.d.cts +4 -27
- package/dist/diff.d.ts +4 -27
- package/dist/diff.js +5 -7
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed-labels-BiVa9HYl.d.cts +23 -0
- package/dist/embed-labels-BiVa9HYl.d.ts +23 -0
- package/dist/embed.cjs +10 -9
- package/dist/embed.d.cts +4 -23
- package/dist/embed.d.ts +4 -23
- package/dist/embed.js +8 -7
- package/dist/emoji-extension-C832oGeT.d.ts +16 -0
- package/dist/emoji-extension-Dk5IQLZf.d.cts +16 -0
- package/dist/{emoji-extension-gRKnbW8G.d.ts → emoji-labels-YwOms7ZJ.d.cts} +2 -15
- package/dist/{emoji-extension-C3o_Y5uC.d.cts → emoji-labels-YwOms7ZJ.d.ts} +2 -15
- package/dist/emoji.cjs +10 -9
- package/dist/emoji.d.cts +4 -3
- package/dist/emoji.d.ts +4 -3
- package/dist/emoji.js +7 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +8 -7
- package/dist/engine.d.ts +8 -7
- package/dist/engine.js +3 -3
- package/dist/find-extension-BfruAPLi.d.cts +15 -0
- package/dist/find-extension-DmK9_N81.d.ts +15 -0
- package/dist/{find-extension-B_Ctrs6T.d.ts → find-labels-C4vs8Qe9.d.cts} +2 -14
- package/dist/{find-extension-BGGsJMu4.d.cts → find-labels-C4vs8Qe9.d.ts} +2 -14
- package/dist/find.cjs +11 -10
- package/dist/find.d.cts +2 -1
- package/dist/find.d.ts +2 -1
- package/dist/find.js +7 -6
- package/dist/headless.cjs +69 -89
- package/dist/headless.d.cts +21 -28
- package/dist/headless.d.ts +21 -28
- package/dist/headless.js +4 -4
- package/dist/highlight.cjs +7 -6
- package/dist/highlight.js +6 -5
- package/dist/highlight.js.map +1 -1
- package/dist/{index-CsG7OQoq.d.cts → index-3fYvwqUZ.d.cts} +1 -1
- package/dist/{index-h1llgZM-.d.ts → index-CgxnzCO5.d.ts} +1 -1
- package/dist/index.cjs +82 -101
- package/dist/index.d.cts +18 -185
- package/dist/index.d.ts +18 -185
- package/dist/index.js +6 -5
- package/dist/labels-BhRJYo46.d.ts +176 -0
- package/dist/labels-CiCxj2jP.d.cts +176 -0
- package/dist/locale-ar.cjs +565 -0
- package/dist/locale-ar.d.cts +63 -0
- package/dist/locale-ar.d.ts +63 -0
- package/dist/locale-ar.js +551 -0
- package/dist/locale-ar.js.map +1 -0
- package/dist/locale-de.cjs +510 -0
- package/dist/locale-de.d.cts +63 -0
- package/dist/locale-de.d.ts +63 -0
- package/dist/locale-de.js +496 -0
- package/dist/locale-de.js.map +1 -0
- package/dist/locale-es.cjs +510 -0
- package/dist/locale-es.d.cts +63 -0
- package/dist/locale-es.d.ts +63 -0
- package/dist/locale-es.js +496 -0
- package/dist/locale-es.js.map +1 -0
- package/dist/locale-fr.cjs +510 -0
- package/dist/locale-fr.d.cts +63 -0
- package/dist/locale-fr.d.ts +63 -0
- package/dist/locale-fr.js +496 -0
- package/dist/locale-fr.js.map +1 -0
- package/dist/locale-ja.cjs +505 -0
- package/dist/locale-ja.d.cts +63 -0
- package/dist/locale-ja.d.ts +63 -0
- package/dist/locale-ja.js +491 -0
- package/dist/locale-ja.js.map +1 -0
- package/dist/locale-pt.cjs +511 -0
- package/dist/locale-pt.d.cts +63 -0
- package/dist/locale-pt.d.ts +63 -0
- package/dist/locale-pt.js +497 -0
- package/dist/locale-pt.js.map +1 -0
- package/dist/locale-zh.cjs +505 -0
- package/dist/locale-zh.d.cts +63 -0
- package/dist/locale-zh.d.ts +63 -0
- package/dist/locale-zh.js +491 -0
- package/dist/locale-zh.js.map +1 -0
- package/dist/math-labels-DOf5KFxp.d.cts +24 -0
- package/dist/math-labels-DOf5KFxp.d.ts +24 -0
- package/dist/math.cjs +11 -10
- package/dist/math.d.cts +4 -24
- package/dist/math.d.ts +4 -24
- package/dist/math.js +9 -8
- package/dist/mention-labels-DIQy8LRT.d.cts +15 -0
- package/dist/mention-labels-DIQy8LRT.d.ts +15 -0
- package/dist/mention.cjs +11 -10
- package/dist/mention.d.cts +4 -15
- package/dist/mention.d.ts +4 -15
- package/dist/mention.js +9 -8
- package/dist/{view-controller-p-2x3J7Y.d.ts → node-reveal-BnFcnHhz.d.ts} +14 -14
- package/dist/{view-controller-BfVSNZYZ.d.cts → node-reveal-DY6bimv3.d.cts} +14 -14
- package/dist/palette-BrX-hEd-.d.cts +4 -0
- package/dist/palette-BrX-hEd-.d.ts +4 -0
- package/dist/presence-labels-DXVJLifl.d.cts +15 -0
- package/dist/presence-labels-DXVJLifl.d.ts +15 -0
- package/dist/presence.cjs +40 -42
- package/dist/presence.d.cts +4 -15
- package/dist/presence.d.ts +4 -15
- package/dist/presence.js +9 -11
- package/dist/presence.js.map +1 -1
- package/dist/source-labels-CeQDXsYZ.d.cts +9 -0
- package/dist/source-labels-CeQDXsYZ.d.ts +9 -0
- package/dist/source.cjs +11 -14
- package/dist/source.d.cts +5 -10
- package/dist/source.d.ts +5 -10
- package/dist/source.js +7 -10
- package/dist/source.js.map +1 -1
- package/dist/{stats-extension-oD6D1cYy.d.ts → stats-extension-D5HySF0a.d.cts} +4 -16
- package/dist/{stats-extension-XqOTvRaq.d.cts → stats-extension-Dmw0Ujxe.d.ts} +4 -16
- package/dist/stats-labels-W8gep51s.d.cts +15 -0
- package/dist/stats-labels-W8gep51s.d.ts +15 -0
- package/dist/stats.cjs +11 -10
- package/dist/stats.d.cts +3 -2
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +8 -7
- package/dist/styles.css +2 -2
- package/dist/table-extension-7LkLNK6Q.d.cts +15 -0
- package/dist/table-extension-DEpV0DnP.d.ts +15 -0
- package/dist/{table-extension-v6VB59bF.d.ts → table-labels-Dc-MzU3j.d.cts} +2 -14
- package/dist/{table-extension-BP47hHoz.d.cts → table-labels-Dc-MzU3j.d.ts} +2 -14
- package/dist/table.cjs +26 -25
- package/dist/table.d.cts +2 -1
- package/dist/table.d.ts +2 -1
- package/dist/table.js +7 -6
- package/dist/{to-html-1oD-CDle.d.cts → to-html-C19PbIzh.d.cts} +1 -0
- package/dist/{to-html-CLRBCX0I.d.ts → to-html-CogwrQer.d.ts} +1 -0
- package/dist/{to-markdown-CFPMbbiX.d.cts → to-markdown-C2w7Dzg8.d.cts} +1 -0
- package/dist/{to-markdown-BVOzhgVM.d.ts → to-markdown-DC1EUye5.d.ts} +1 -0
- package/dist/toc-extension-Dvh37bWQ.d.cts +15 -0
- package/dist/toc-extension-SVckrFmb.d.ts +15 -0
- package/dist/toc-labels-B2apPfXG.d.cts +14 -0
- package/dist/toc-labels-B2apPfXG.d.ts +14 -0
- package/dist/toc.cjs +10 -9
- package/dist/toc.d.cts +3 -2
- package/dist/toc.d.ts +3 -2
- package/dist/toc.js +7 -6
- package/dist/{types-DXF9p4qV.d.cts → types-Bzhq5AXj.d.cts} +1 -0
- package/dist/{types-BjLcmV00.d.ts → types-DMuuDBVh.d.ts} +1 -0
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +121 -121
- package/dist/yjs.d.cts +2 -2
- package/dist/yjs.d.ts +2 -2
- package/dist/yjs.js +5 -5
- package/package.json +71 -1
- package/dist/chunk-5JEQZIRI.js.map +0 -1
- package/dist/chunk-7GU25Z6L.js.map +0 -1
- package/dist/chunk-BJTOLCRR.js.map +0 -1
- package/dist/chunk-HSLOPJVT.js.map +0 -1
- package/dist/chunk-IJKGF6SC.js.map +0 -1
- package/dist/chunk-MNA7MBCH.js.map +0 -1
- package/dist/chunk-OJ4O6HWC.js.map +0 -1
- package/dist/chunk-PLUMKN4B.js.map +0 -1
- package/dist/chunk-PWUFFHAQ.js.map +0 -1
- package/dist/chunk-RQXJKJ5S.js.map +0 -1
- package/dist/chunk-UZS3TW75.js.map +0 -1
- package/dist/chunk-XFEDJEJF.js.map +0 -1
- package/dist/toc-extension-CI6jNOYl.d.cts +0 -26
- package/dist/toc-extension-CTHWjNJC.d.ts +0 -26
- /package/dist/{chunk-WZA5S5EJ.cjs → chunk-I7X7B3WD.cjs} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkDJU25PFC_cjs = require('./chunk-DJU25PFC.cjs');
|
|
4
|
+
var chunkI7X7B3WD_cjs = require('./chunk-I7X7B3WD.cjs');
|
|
5
5
|
|
|
6
6
|
// src/engine/transform/step.ts
|
|
7
7
|
var StepError = class extends Error {
|
|
@@ -10,7 +10,7 @@ var identityMap = (pos) => pos;
|
|
|
10
10
|
|
|
11
11
|
// src/engine/transform/step-access.ts
|
|
12
12
|
function requireBlock(doc, id) {
|
|
13
|
-
const block =
|
|
13
|
+
const block = chunkI7X7B3WD_cjs.blockById(doc, id);
|
|
14
14
|
if (block === void 0) throw new StepError(`no block "${id}"`);
|
|
15
15
|
return block;
|
|
16
16
|
}
|
|
@@ -20,7 +20,7 @@ function requireRegion(block, region) {
|
|
|
20
20
|
}
|
|
21
21
|
function requireRange(block, region, from, to) {
|
|
22
22
|
const inline = requireRegion(block, region);
|
|
23
|
-
const length =
|
|
23
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(inline);
|
|
24
24
|
if (!(Number.isInteger(from) && Number.isInteger(to) && from >= 0 && from <= to && to <= length)) {
|
|
25
25
|
throw new StepError(`range ${from} to ${to} is outside 0 to ${length} in "${block.id}" ${region}`);
|
|
26
26
|
}
|
|
@@ -44,7 +44,7 @@ function patchAttrs(attrs, patch) {
|
|
|
44
44
|
}
|
|
45
45
|
function patchChangesAttrs(attrs, patch) {
|
|
46
46
|
return Object.keys(patch).some(
|
|
47
|
-
(key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !
|
|
47
|
+
(key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !chunkI7X7B3WD_cjs.sameValue(attrs[key], patch[key])
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
function previousValues(attrs, patch) {
|
|
@@ -66,7 +66,7 @@ function setAttrsStep(block, patch) {
|
|
|
66
66
|
stepType: "setAttrs",
|
|
67
67
|
apply(doc) {
|
|
68
68
|
requireBlock(doc, block);
|
|
69
|
-
return { doc:
|
|
69
|
+
return { doc: chunkI7X7B3WD_cjs.updateBlock(doc, block, (b) => ({ ...b, attrs: patchAttrs(b.attrs, patch) })), map: identityMap };
|
|
70
70
|
},
|
|
71
71
|
invert: (before) => setAttrsStep(block, previousValues(requireBlock(before, block).attrs, patch)),
|
|
72
72
|
toJSON: () => ({ stepType: "setAttrs", block, patch: patchToJSON(patch) })
|
|
@@ -80,7 +80,7 @@ function setIndentStep(block, indent2) {
|
|
|
80
80
|
if (!Number.isInteger(indent2) || indent2 < 0) {
|
|
81
81
|
throw new StepError(`indent ${indent2} is not a non-negative integer`);
|
|
82
82
|
}
|
|
83
|
-
return { doc:
|
|
83
|
+
return { doc: chunkI7X7B3WD_cjs.updateBlock(doc, block, (b) => ({ ...b, indent: indent2 })), map: identityMap };
|
|
84
84
|
},
|
|
85
85
|
invert: (before) => setIndentStep(block, requireBlock(before, block).indent),
|
|
86
86
|
toJSON: () => ({ stepType: "setIndent", block, indent: indent2 })
|
|
@@ -89,7 +89,7 @@ function setIndentStep(block, indent2) {
|
|
|
89
89
|
|
|
90
90
|
// src/engine/transform/block-edges.ts
|
|
91
91
|
function orderedRegions(block) {
|
|
92
|
-
return Object.keys(block.regions).sort(
|
|
92
|
+
return Object.keys(block.regions).sort(chunkI7X7B3WD_cjs.compareRegionNames);
|
|
93
93
|
}
|
|
94
94
|
function firstRegion(block) {
|
|
95
95
|
return orderedRegions(block)[0] ?? null;
|
|
@@ -102,12 +102,12 @@ function blockEnd(block) {
|
|
|
102
102
|
return {
|
|
103
103
|
block: block.id,
|
|
104
104
|
region: region ?? "",
|
|
105
|
-
offset: region === void 0 ? 0 :
|
|
105
|
+
offset: region === void 0 ? 0 : chunkI7X7B3WD_cjs.inlineLength(block.regions[region])
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
function clampPos(block, pos) {
|
|
109
109
|
if (!Object.hasOwn(block.regions, pos.region)) return blockStart(block);
|
|
110
|
-
const length =
|
|
110
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(block.regions[pos.region]);
|
|
111
111
|
return pos.offset > length ? { ...pos, offset: length } : pos;
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -122,7 +122,7 @@ function insertBlocksStep(index, blocks) {
|
|
|
122
122
|
if (doc.index.has(id) || ids.has(id)) throw new StepError(`block "${id}" is already in the document`);
|
|
123
123
|
ids.add(id);
|
|
124
124
|
}
|
|
125
|
-
return { doc:
|
|
125
|
+
return { doc: chunkI7X7B3WD_cjs.replaceBlocks(doc, index, 0, blocks), map: identityMap };
|
|
126
126
|
},
|
|
127
127
|
invert: () => removeBlocksStep(index, blocks.length),
|
|
128
128
|
toJSON: () => ({ stepType: "insertBlocks", index, blocks })
|
|
@@ -142,7 +142,7 @@ function removeBlocksStep(index, count2) {
|
|
|
142
142
|
const after = following && blockStart(following);
|
|
143
143
|
return (assoc === -1 ? before ?? after : after ?? before) ?? pos;
|
|
144
144
|
};
|
|
145
|
-
return { doc:
|
|
145
|
+
return { doc: chunkI7X7B3WD_cjs.replaceBlocks(doc, index, count2, []), map };
|
|
146
146
|
},
|
|
147
147
|
invert: (before) => insertBlocksStep(index, before.blocks.slice(index, index + count2)),
|
|
148
148
|
toJSON: () => ({ stepType: "removeBlocks", index, count: count2 })
|
|
@@ -156,14 +156,14 @@ function moveBlocksStep(from, count2, to) {
|
|
|
156
156
|
requireSpan(to, count2, doc.blocks.length);
|
|
157
157
|
const moved2 = doc.blocks.slice(from, from + count2);
|
|
158
158
|
const rest = [...doc.blocks.slice(0, from), ...doc.blocks.slice(from + count2)];
|
|
159
|
-
return { doc:
|
|
159
|
+
return { doc: chunkI7X7B3WD_cjs.createDoc([...rest.slice(0, to), ...moved2, ...rest.slice(to)]), map: identityMap };
|
|
160
160
|
},
|
|
161
161
|
invert: () => moveBlocksStep(to, count2, from),
|
|
162
162
|
toJSON: () => ({ stepType: "moveBlocks", from, count: count2, to })
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
var keepsRegions = (before, after) => Object.entries(before.regions).every(
|
|
166
|
-
([name, inline]) => Object.hasOwn(after.regions, name) &&
|
|
166
|
+
([name, inline]) => Object.hasOwn(after.regions, name) && chunkI7X7B3WD_cjs.equalInline(inline, after.regions[name])
|
|
167
167
|
);
|
|
168
168
|
function replaceBlockStep(block) {
|
|
169
169
|
const clamp = (pos) => pos.block === block.id ? clampPos(block, pos) : pos;
|
|
@@ -171,7 +171,7 @@ function replaceBlockStep(block) {
|
|
|
171
171
|
stepType: "replaceBlock",
|
|
172
172
|
apply(doc) {
|
|
173
173
|
const map = keepsRegions(requireBlock(doc, block.id), block) ? identityMap : clamp;
|
|
174
|
-
return { doc:
|
|
174
|
+
return { doc: chunkI7X7B3WD_cjs.updateBlock(doc, block.id, () => block), map };
|
|
175
175
|
},
|
|
176
176
|
invert: (before) => replaceBlockStep(requireBlock(before, block.id)),
|
|
177
177
|
toJSON: () => ({ stepType: "replaceBlock", block })
|
|
@@ -184,15 +184,15 @@ function restoreMarksStep(block, region, from, to, slice) {
|
|
|
184
184
|
stepType: "restoreMarks",
|
|
185
185
|
apply(doc) {
|
|
186
186
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
187
|
-
if (
|
|
187
|
+
if (chunkI7X7B3WD_cjs.inlineText(slice) !== chunkI7X7B3WD_cjs.inlineText(chunkI7X7B3WD_cjs.sliceInline(inline, from, to))) {
|
|
188
188
|
throw new StepError(`marks restored over other content in "${block}" ${region}`);
|
|
189
189
|
}
|
|
190
|
-
const next =
|
|
190
|
+
const next = chunkI7X7B3WD_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunkI7X7B3WD_cjs.replaceInline(inline, from, to, slice)));
|
|
191
191
|
return { doc: next, map: identityMap };
|
|
192
192
|
},
|
|
193
193
|
invert(before) {
|
|
194
194
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
195
|
-
return restoreMarksStep(block, region, from, to,
|
|
195
|
+
return restoreMarksStep(block, region, from, to, chunkI7X7B3WD_cjs.sliceInline(inline, from, to));
|
|
196
196
|
},
|
|
197
197
|
toJSON: () => ({ stepType: "restoreMarks", block, region, from, to, slice })
|
|
198
198
|
});
|
|
@@ -203,24 +203,24 @@ function markStep(stepType, target, mark, change) {
|
|
|
203
203
|
stepType,
|
|
204
204
|
apply(doc) {
|
|
205
205
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
206
|
-
return { doc:
|
|
206
|
+
return { doc: chunkI7X7B3WD_cjs.updateBlock(doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
|
|
207
207
|
},
|
|
208
208
|
invert(before) {
|
|
209
209
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
210
|
-
return restoreMarksStep(block, region, from, to,
|
|
210
|
+
return restoreMarksStep(block, region, from, to, chunkI7X7B3WD_cjs.sliceInline(inline, from, to));
|
|
211
211
|
},
|
|
212
212
|
toJSON: () => ({ stepType, ...target, mark })
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
function addMarkStep(block, region, from, to, mark) {
|
|
216
|
-
return markStep("addMark", { block, region, from, to }, mark, (inline) =>
|
|
216
|
+
return markStep("addMark", { block, region, from, to }, mark, (inline) => chunkI7X7B3WD_cjs.addMarkRange(inline, from, to, mark));
|
|
217
217
|
}
|
|
218
218
|
function removeMarkStep(block, region, from, to, mark) {
|
|
219
219
|
return markStep(
|
|
220
220
|
"removeMark",
|
|
221
221
|
{ block, region, from, to },
|
|
222
222
|
mark,
|
|
223
|
-
(inline) =>
|
|
223
|
+
(inline) => chunkI7X7B3WD_cjs.removeMarkRange(inline, from, to, mark)
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -250,7 +250,7 @@ function mapTextChange(before, after) {
|
|
|
250
250
|
const ops = removed.length + added.length > DIFF_LIMIT ? [
|
|
251
251
|
{ op: "delete", items: removed },
|
|
252
252
|
{ op: "insert", items: added }
|
|
253
|
-
] :
|
|
253
|
+
] : chunkDJU25PFC_cjs.diffSequences(removed.split(""), added.split(""));
|
|
254
254
|
return (offset, assoc) => {
|
|
255
255
|
let b = from;
|
|
256
256
|
let a = from;
|
|
@@ -276,13 +276,13 @@ function replaceDocStep(next) {
|
|
|
276
276
|
const regionMaps = /* @__PURE__ */ new Map();
|
|
277
277
|
const map = (pos, assoc = 1) => {
|
|
278
278
|
const { block, region } = pos;
|
|
279
|
-
const survivor =
|
|
279
|
+
const survivor = chunkI7X7B3WD_cjs.blockById(next, block);
|
|
280
280
|
if (survivor !== void 0) {
|
|
281
281
|
const key = JSON.stringify([block, region]);
|
|
282
282
|
let regionMap = regionMaps.get(key);
|
|
283
283
|
if (regionMap === void 0) {
|
|
284
|
-
const before =
|
|
285
|
-
regionMap = mapTextChange(before,
|
|
284
|
+
const before = chunkI7X7B3WD_cjs.inlineText(chunkI7X7B3WD_cjs.blockById(doc, block)?.regions[region] ?? []);
|
|
285
|
+
regionMap = mapTextChange(before, chunkI7X7B3WD_cjs.inlineText(survivor.regions[region] ?? []));
|
|
286
286
|
regionMaps.set(key, regionMap);
|
|
287
287
|
}
|
|
288
288
|
const offset = regionMap(pos.offset, assoc);
|
|
@@ -300,7 +300,7 @@ function replaceDocStep(next) {
|
|
|
300
300
|
|
|
301
301
|
// src/engine/transform/replace-inline-step.ts
|
|
302
302
|
function replaceInlineStep(block, region, from, to, slice) {
|
|
303
|
-
const inserted =
|
|
303
|
+
const inserted = chunkI7X7B3WD_cjs.inlineLength(slice);
|
|
304
304
|
const map = (pos, assoc = 1) => {
|
|
305
305
|
if (pos.block !== block || pos.region !== region || pos.offset < from) return pos;
|
|
306
306
|
if (pos.offset > to) return { ...pos, offset: pos.offset + inserted - (to - from) };
|
|
@@ -310,12 +310,12 @@ function replaceInlineStep(block, region, from, to, slice) {
|
|
|
310
310
|
stepType: "replaceInline",
|
|
311
311
|
apply(doc) {
|
|
312
312
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
313
|
-
const next =
|
|
313
|
+
const next = chunkI7X7B3WD_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunkI7X7B3WD_cjs.replaceInline(inline, from, to, slice)));
|
|
314
314
|
return { doc: next, map };
|
|
315
315
|
},
|
|
316
316
|
invert(before) {
|
|
317
317
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
318
|
-
return replaceInlineStep(block, region, from, from + inserted,
|
|
318
|
+
return replaceInlineStep(block, region, from, from + inserted, chunkI7X7B3WD_cjs.sliceInline(inline, from, to));
|
|
319
319
|
},
|
|
320
320
|
toJSON: () => ({ stepType: "replaceInline", block, region, from, to, slice })
|
|
321
321
|
});
|
|
@@ -339,10 +339,10 @@ function splitBlockStep(block, region, offset, created) {
|
|
|
339
339
|
type: created.type,
|
|
340
340
|
indent: created.indent,
|
|
341
341
|
attrs: created.attrs,
|
|
342
|
-
regions: { ...created.regions, [created.region]:
|
|
342
|
+
regions: { ...created.regions, [created.region]: chunkI7X7B3WD_cjs.sliceInline(inline, offset, chunkI7X7B3WD_cjs.inlineLength(inline)) }
|
|
343
343
|
};
|
|
344
|
-
const head = withRegion(target, region,
|
|
345
|
-
return { doc:
|
|
344
|
+
const head = withRegion(target, region, chunkI7X7B3WD_cjs.sliceInline(inline, 0, offset));
|
|
345
|
+
return { doc: chunkI7X7B3WD_cjs.replaceBlocks(doc, chunkI7X7B3WD_cjs.indexOfBlock(doc, block), 1, [head, tail]), map };
|
|
346
346
|
},
|
|
347
347
|
invert: () => joinBlocksStep(block, region, created.id, created.region),
|
|
348
348
|
toJSON: () => ({ stepType: "splitBlock", block, region, offset, created })
|
|
@@ -354,17 +354,17 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
|
|
|
354
354
|
apply(doc) {
|
|
355
355
|
const first = requireBlock(doc, target);
|
|
356
356
|
const second = requireBlock(doc, source);
|
|
357
|
-
const index =
|
|
358
|
-
if (
|
|
357
|
+
const index = chunkI7X7B3WD_cjs.indexOfBlock(doc, target);
|
|
358
|
+
if (chunkI7X7B3WD_cjs.indexOfBlock(doc, source) !== index + 1) throw new StepError(`block "${source}" does not follow "${target}"`);
|
|
359
359
|
const head = requireRegion(first, targetRegion);
|
|
360
|
-
const length =
|
|
361
|
-
const merged =
|
|
360
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(head);
|
|
361
|
+
const merged = chunkI7X7B3WD_cjs.replaceInline(head, length, length, requireRegion(second, sourceRegion));
|
|
362
362
|
const map = (pos) => pos.block === source ? { block: target, region: targetRegion, offset: length + (pos.region === sourceRegion ? pos.offset : 0) } : pos;
|
|
363
|
-
return { doc:
|
|
363
|
+
return { doc: chunkI7X7B3WD_cjs.replaceBlocks(doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
|
|
364
364
|
},
|
|
365
365
|
invert(before) {
|
|
366
366
|
const { id, type, attrs, indent: indent2, regions } = requireBlock(before, source);
|
|
367
|
-
const length =
|
|
367
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(requireRegion(requireBlock(before, target), targetRegion));
|
|
368
368
|
const created = { id, type, attrs, indent: indent2, region: sourceRegion, regions };
|
|
369
369
|
return splitBlockStep(target, targetRegion, length, created);
|
|
370
370
|
},
|
|
@@ -373,9 +373,9 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
|
|
|
373
373
|
}
|
|
374
374
|
|
|
375
375
|
// src/engine/transform/step-json.ts
|
|
376
|
-
var isRegions = (value) =>
|
|
377
|
-
var isMark = (value) =>
|
|
378
|
-
var isBlockShape = (value) =>
|
|
376
|
+
var isRegions = (value) => chunkI7X7B3WD_cjs.isRecord(value) && Object.values(value).every(Array.isArray);
|
|
377
|
+
var isMark = (value) => chunkI7X7B3WD_cjs.isRecord(value) && typeof value.type === "string" && (value.attrs === void 0 || chunkI7X7B3WD_cjs.isRecord(value.attrs));
|
|
378
|
+
var isBlockShape = (value) => chunkI7X7B3WD_cjs.isRecord(value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && chunkI7X7B3WD_cjs.isRecord(value.attrs);
|
|
379
379
|
var isBlock = (value) => isBlockShape(value) && isRegions(value.regions);
|
|
380
380
|
var isCreated = (value) => isBlockShape(value) && typeof value.region === "string" && (value.regions === void 0 || isRegions(value.regions));
|
|
381
381
|
var isString = (value) => typeof value === "string";
|
|
@@ -387,7 +387,7 @@ function docOf(blocks) {
|
|
|
387
387
|
if (new Set(blocks.map((block) => block.id)).size !== blocks.length) {
|
|
388
388
|
throw new StepError("a replaceDoc step repeats a block id");
|
|
389
389
|
}
|
|
390
|
-
return
|
|
390
|
+
return chunkI7X7B3WD_cjs.createDoc(blocks);
|
|
391
391
|
}
|
|
392
392
|
function reader(json) {
|
|
393
393
|
return (key, accept) => {
|
|
@@ -432,7 +432,7 @@ function stepFromJSON(json) {
|
|
|
432
432
|
read("slice", isInline)
|
|
433
433
|
);
|
|
434
434
|
case "setAttrs":
|
|
435
|
-
return setAttrsStep(read("block", isString), patchFromJSON(read("patch",
|
|
435
|
+
return setAttrsStep(read("block", isString), patchFromJSON(read("patch", chunkI7X7B3WD_cjs.isRecord)));
|
|
436
436
|
case "setIndent":
|
|
437
437
|
return setIndentStep(read("block", isString), read("indent", isInteger));
|
|
438
438
|
case "insertBlocks":
|
|
@@ -466,7 +466,7 @@ function stepFromJSON(json) {
|
|
|
466
466
|
|
|
467
467
|
// src/engine/model/position.ts
|
|
468
468
|
function comparePos(doc, a, b) {
|
|
469
|
-
return
|
|
469
|
+
return chunkI7X7B3WD_cjs.requireBlockIndex(doc, a.block) - chunkI7X7B3WD_cjs.requireBlockIndex(doc, b.block) || chunkI7X7B3WD_cjs.compareRegionNames(a.region, b.region) || a.offset - b.offset;
|
|
470
470
|
}
|
|
471
471
|
function orderedRange(doc, anchor, head) {
|
|
472
472
|
return comparePos(doc, anchor, head) <= 0 ? { from: anchor, to: head } : { from: head, to: anchor };
|
|
@@ -505,7 +505,7 @@ function selectedBlockIds(doc, selection) {
|
|
|
505
505
|
if (selection === null) return [];
|
|
506
506
|
if (selection.kind === "node") return [selection.block];
|
|
507
507
|
const ends = selection.kind === "text" ? [selection.anchor.block, selection.head.block] : [selection.anchor, selection.head];
|
|
508
|
-
const [first, second] = ends.map((id) =>
|
|
508
|
+
const [first, second] = ends.map((id) => chunkI7X7B3WD_cjs.requireBlockIndex(doc, id));
|
|
509
509
|
return doc.blocks.slice(Math.min(first, second), Math.max(first, second) + 1).map((block) => block.id);
|
|
510
510
|
}
|
|
511
511
|
function isBackward(doc, selection) {
|
|
@@ -513,7 +513,7 @@ function isBackward(doc, selection) {
|
|
|
513
513
|
const { anchor, head } = selection;
|
|
514
514
|
return doc.index.has(anchor.block) && doc.index.has(head.block) && comparePos(doc, anchor, head) > 0;
|
|
515
515
|
}
|
|
516
|
-
return doc.index.has(selection.anchor) && doc.index.has(selection.head) &&
|
|
516
|
+
return doc.index.has(selection.anchor) && doc.index.has(selection.head) && chunkI7X7B3WD_cjs.indexOfBlock(doc, selection.anchor) > chunkI7X7B3WD_cjs.indexOfBlock(doc, selection.head);
|
|
517
517
|
}
|
|
518
518
|
var blockProbe = (block) => ({ block, region: "", offset: 0 });
|
|
519
519
|
function mapSelection(selection, map, doc) {
|
|
@@ -532,18 +532,18 @@ function mapSelection(selection, map, doc) {
|
|
|
532
532
|
return anchor === selection.anchor && head === selection.head ? selection : textSelection(anchor, head);
|
|
533
533
|
}
|
|
534
534
|
function primaryRegion(schema, block) {
|
|
535
|
-
const spec =
|
|
535
|
+
const spec = chunkI7X7B3WD_cjs.specFor(schema, block.type);
|
|
536
536
|
if (spec.flow === "text" && spec.primaryRegion !== void 0 && Object.hasOwn(block.regions, spec.primaryRegion)) {
|
|
537
537
|
return spec.primaryRegion;
|
|
538
538
|
}
|
|
539
539
|
return firstRegion(block);
|
|
540
540
|
}
|
|
541
541
|
function flowEdge(schema, block, atEnd) {
|
|
542
|
-
const region =
|
|
543
|
-
return region === null ? null : { block: block.id, region, offset: atEnd ?
|
|
542
|
+
const region = chunkI7X7B3WD_cjs.specFor(schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
|
|
543
|
+
return region === null ? null : { block: block.id, region, offset: atEnd ? chunkI7X7B3WD_cjs.inlineLength(block.regions[region]) : 0 };
|
|
544
544
|
}
|
|
545
545
|
function edge(doc, schema, blockId, atEnd) {
|
|
546
|
-
const block = doc.blocks[
|
|
546
|
+
const block = doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(doc, blockId)];
|
|
547
547
|
const flow = flowEdge(schema, block, atEnd);
|
|
548
548
|
if (flow !== null) return textSelection(flow);
|
|
549
549
|
if (Object.keys(block.regions).length === 0) return nodeSelection(blockId);
|
|
@@ -559,13 +559,13 @@ function defaultSelection(doc, schema) {
|
|
|
559
559
|
return doc.blocks.length === 0 ? null : startOf(doc, schema, doc.blocks[0].id);
|
|
560
560
|
}
|
|
561
561
|
function validatePos(doc, schema, pos) {
|
|
562
|
-
const block =
|
|
562
|
+
const block = chunkI7X7B3WD_cjs.blockById(doc, pos.block);
|
|
563
563
|
if (block === void 0) return null;
|
|
564
564
|
if (!Object.hasOwn(block.regions, pos.region)) {
|
|
565
565
|
const region = primaryRegion(schema, block);
|
|
566
566
|
return region === null ? nodeSelection(block.id) : { block: block.id, region, offset: 0 };
|
|
567
567
|
}
|
|
568
|
-
const length =
|
|
568
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(block.regions[pos.region]);
|
|
569
569
|
return pos.offset >= 0 && pos.offset <= length ? pos : { ...pos, offset: Math.min(Math.max(pos.offset, 0), length) };
|
|
570
570
|
}
|
|
571
571
|
function nearestFlow(doc, schema, from, to, atEnd) {
|
|
@@ -576,14 +576,14 @@ function nearestFlow(doc, schema, from, to, atEnd) {
|
|
|
576
576
|
}
|
|
577
577
|
return null;
|
|
578
578
|
}
|
|
579
|
-
var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[
|
|
579
|
+
var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(doc, pos.block)], false)?.region === pos.region;
|
|
580
580
|
function clampToFlow(doc, schema, selection) {
|
|
581
581
|
const { anchor, head } = selection;
|
|
582
582
|
if (anchor.block === head.block) return selection;
|
|
583
583
|
const backward = comparePos(doc, anchor, head) > 0;
|
|
584
584
|
const [from, to] = backward ? [head, anchor] : [anchor, head];
|
|
585
|
-
const first =
|
|
586
|
-
const last =
|
|
585
|
+
const first = chunkI7X7B3WD_cjs.requireBlockIndex(doc, from.block);
|
|
586
|
+
const last = chunkI7X7B3WD_cjs.requireBlockIndex(doc, to.block);
|
|
587
587
|
const start = inFlow(doc, schema, from) ? from : nearestFlow(doc, schema, first + 1, last, false);
|
|
588
588
|
const end = inFlow(doc, schema, to) ? to : nearestFlow(doc, schema, last - 1, first, true);
|
|
589
589
|
if (start === from && end === to) return selection;
|
|
@@ -602,9 +602,9 @@ function validateText(doc, schema, selection) {
|
|
|
602
602
|
return clampToFlow(doc, schema, valid);
|
|
603
603
|
}
|
|
604
604
|
function validateNode(doc, schema, selection) {
|
|
605
|
-
const block =
|
|
605
|
+
const block = chunkI7X7B3WD_cjs.blockById(doc, selection.block);
|
|
606
606
|
if (block === void 0) return defaultSelection(doc, schema);
|
|
607
|
-
return
|
|
607
|
+
return chunkI7X7B3WD_cjs.specFor(schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
|
|
608
608
|
}
|
|
609
609
|
function validateSelection(doc, schema, selection) {
|
|
610
610
|
if (doc.blocks.length === 0) return null;
|
|
@@ -635,7 +635,7 @@ function hidingToggle(doc, index, isClosed = isClosedToggle) {
|
|
|
635
635
|
}
|
|
636
636
|
|
|
637
637
|
// src/engine/state/visible-selection.ts
|
|
638
|
-
var hiderOf = (doc, id) => hidingToggle(doc,
|
|
638
|
+
var hiderOf = (doc, id) => hidingToggle(doc, chunkI7X7B3WD_cjs.requireBlockIndex(doc, id) + 1);
|
|
639
639
|
function toggleEnd(doc, schema, toggle) {
|
|
640
640
|
const end = endOf(doc, schema, doc.blocks[toggle].id);
|
|
641
641
|
return end.kind === "text" ? end.head : blockEnd(doc.blocks[toggle]);
|
|
@@ -649,7 +649,7 @@ function visibleText(doc, schema, selection) {
|
|
|
649
649
|
}
|
|
650
650
|
function visibleBlocks(doc, schema, selection) {
|
|
651
651
|
const ids = [selection.anchor, selection.head];
|
|
652
|
-
const indexes = ids.map((id) =>
|
|
652
|
+
const indexes = ids.map((id) => chunkI7X7B3WD_cjs.requireBlockIndex(doc, id));
|
|
653
653
|
const from = Math.min(...indexes);
|
|
654
654
|
const to = Math.max(...indexes);
|
|
655
655
|
const hiders = indexes.map((index) => hidingToggle(doc, index + 1));
|
|
@@ -830,8 +830,8 @@ var Transaction = class {
|
|
|
830
830
|
// src/engine/commands/caret-marks.ts
|
|
831
831
|
function caretMarks(doc, schema, storedMarks, pos) {
|
|
832
832
|
if (storedMarks !== null) return storedMarks;
|
|
833
|
-
const inline =
|
|
834
|
-
return
|
|
833
|
+
const inline = chunkI7X7B3WD_cjs.blockById(doc, pos.block)?.regions[pos.region] ?? [];
|
|
834
|
+
return chunkI7X7B3WD_cjs.marksAt(inline, pos.offset, (mark) => schema.marks.get(mark.type)?.inclusive ?? true);
|
|
835
835
|
}
|
|
836
836
|
|
|
837
837
|
// src/engine/commands/run-commands.ts
|
|
@@ -894,7 +894,7 @@ function editEnd(tr) {
|
|
|
894
894
|
const { selection } = tr;
|
|
895
895
|
if (selection?.kind === "text" && isCollapsed(selection)) return selection.head;
|
|
896
896
|
const last = replacements(tr).at(-1);
|
|
897
|
-
return last === void 0 ? null : { block: last.block, region: last.region, offset: last.from +
|
|
897
|
+
return last === void 0 ? null : { block: last.block, region: last.region, offset: last.from + chunkI7X7B3WD_cjs.inlineLength(last.slice) };
|
|
898
898
|
}
|
|
899
899
|
function continuesEdit(tr, end) {
|
|
900
900
|
if (end === null || end === void 0) return true;
|
|
@@ -909,12 +909,12 @@ function mapStep(step, map, before, after) {
|
|
|
909
909
|
const { block, region, from, to, index, count: count2 } = json;
|
|
910
910
|
const ids = (doc) => [...doc.index.keys()];
|
|
911
911
|
const gap = (i, list2, next) => next.indexOf(list2[i - 1]) + 1 || NaN;
|
|
912
|
-
const content = (doc, { block: block2, region: region2, offset }, end) =>
|
|
912
|
+
const content = (doc, { block: block2, region: region2, offset }, end) => chunkI7X7B3WD_cjs.sliceInline(chunkI7X7B3WD_cjs.blockById(doc, block2)?.regions[region2] ?? [], offset, end);
|
|
913
913
|
switch (json.stepType) {
|
|
914
914
|
case "setAttrs":
|
|
915
915
|
case "setIndent": {
|
|
916
916
|
const key = json.stepType === "setAttrs" ? "attrs" : "indent";
|
|
917
|
-
return
|
|
917
|
+
return chunkI7X7B3WD_cjs.sameValue(chunkI7X7B3WD_cjs.blockById(before, block)?.[key], chunkI7X7B3WD_cjs.blockById(after, block)?.[key]) ? step : null;
|
|
918
918
|
}
|
|
919
919
|
case "joinBlocks":
|
|
920
920
|
return step;
|
|
@@ -922,12 +922,12 @@ function mapStep(step, map, before, after) {
|
|
|
922
922
|
return null;
|
|
923
923
|
case "replaceBlock": {
|
|
924
924
|
const { id } = json.block;
|
|
925
|
-
return
|
|
925
|
+
return chunkI7X7B3WD_cjs.sameValue(chunkI7X7B3WD_cjs.blockById(before, id), chunkI7X7B3WD_cjs.blockById(after, id)) ? step : null;
|
|
926
926
|
}
|
|
927
927
|
case "insertBlocks":
|
|
928
928
|
case "removeBlocks":
|
|
929
929
|
json.index = index && gap(index, ids(before), ids(after));
|
|
930
|
-
if (!
|
|
930
|
+
if (!chunkI7X7B3WD_cjs.sameValue(after.blocks.slice(json.index, json.index + count2), before.blocks.slice(index, index + count2))) {
|
|
931
931
|
return null;
|
|
932
932
|
}
|
|
933
933
|
break;
|
|
@@ -936,7 +936,7 @@ function mapStep(step, map, before, after) {
|
|
|
936
936
|
const rest = (doc) => ids(doc).filter((id) => !moved2.includes(id));
|
|
937
937
|
json.from = after.index.get(moved2[0]) ?? NaN;
|
|
938
938
|
json.to = to && gap(to, rest(before), rest(after));
|
|
939
|
-
if (!
|
|
939
|
+
if (!chunkI7X7B3WD_cjs.sameValue(ids(after).slice(json.from, json.from + count2), moved2)) return null;
|
|
940
940
|
break;
|
|
941
941
|
}
|
|
942
942
|
default: {
|
|
@@ -947,7 +947,7 @@ function mapStep(step, map, before, after) {
|
|
|
947
947
|
const end = first === last ? start : map({ block, region, offset: last }, -1);
|
|
948
948
|
const moved2 = start.block !== end.block || start.region !== end.region;
|
|
949
949
|
const origin = { block, region, offset: first };
|
|
950
|
-
const kept =
|
|
950
|
+
const kept = chunkI7X7B3WD_cjs.sameValue(content(after, start, end.offset), content(before, origin, last));
|
|
951
951
|
if (moved2 || !kept) return null;
|
|
952
952
|
Object.assign(json, start, { from: start.offset, to: end.offset });
|
|
953
953
|
}
|
|
@@ -1116,7 +1116,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
1116
1116
|
const { steps, undoText, at, marks } = record;
|
|
1117
1117
|
const tr = new Transaction(state).setMeta(UNFILTERED, true);
|
|
1118
1118
|
steps.forEach((step) => tr.step(step));
|
|
1119
|
-
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [
|
|
1119
|
+
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [chunkI7X7B3WD_cjs.text(undoText, marks)]));
|
|
1120
1120
|
dispatch(tr.setSelection(textSelection({ ...at, offset: at.offset + undoText.length })));
|
|
1121
1121
|
}
|
|
1122
1122
|
return true;
|
|
@@ -1125,7 +1125,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
1125
1125
|
// src/engine/commands/block-helpers.ts
|
|
1126
1126
|
var ITEM_KINDS = /* @__PURE__ */ new Set(["bullet", "ordered", "task", "quote"]);
|
|
1127
1127
|
function specOf(schema, block) {
|
|
1128
|
-
return
|
|
1128
|
+
return chunkI7X7B3WD_cjs.specFor(schema, block.type);
|
|
1129
1129
|
}
|
|
1130
1130
|
function isTextFlow(schema, block) {
|
|
1131
1131
|
return specOf(schema, block).flow === "text";
|
|
@@ -1137,7 +1137,7 @@ function isItem(block) {
|
|
|
1137
1137
|
return block.type === "MARKDOWN" && typeof block.attrs.kind === "string" && ITEM_KINDS.has(block.attrs.kind);
|
|
1138
1138
|
}
|
|
1139
1139
|
function regionLength(block, region) {
|
|
1140
|
-
return Object.hasOwn(block.regions, region) ?
|
|
1140
|
+
return Object.hasOwn(block.regions, region) ? chunkI7X7B3WD_cjs.inlineLength(block.regions[region]) : 0;
|
|
1141
1141
|
}
|
|
1142
1142
|
function descendantsEnd(doc, index) {
|
|
1143
1143
|
const { indent: indent2 } = doc.blocks[index];
|
|
@@ -1145,8 +1145,8 @@ function descendantsEnd(doc, index) {
|
|
|
1145
1145
|
while (end < doc.blocks.length && doc.blocks[end].indent > indent2) end++;
|
|
1146
1146
|
return end;
|
|
1147
1147
|
}
|
|
1148
|
-
function createBlock(schema, type, attrs = {}, indent2 = 0, id =
|
|
1149
|
-
const initial =
|
|
1148
|
+
function createBlock(schema, type, attrs = {}, indent2 = 0, id = chunkI7X7B3WD_cjs.newId()) {
|
|
1149
|
+
const initial = chunkI7X7B3WD_cjs.specFor(schema, type).initial();
|
|
1150
1150
|
return { id, type, indent: indent2, attrs: { ...initial.attrs, ...attrs }, regions: initial.regions };
|
|
1151
1151
|
}
|
|
1152
1152
|
function withContent(schema, block, content) {
|
|
@@ -1164,7 +1164,7 @@ function headBlockId(selection) {
|
|
|
1164
1164
|
function selectedBlockRange(doc, selection) {
|
|
1165
1165
|
const ids = selectedBlockIds(doc, selection);
|
|
1166
1166
|
if (ids.length === 0) return null;
|
|
1167
|
-
const start =
|
|
1167
|
+
const start = chunkI7X7B3WD_cjs.indexOfBlock(doc, ids[0]);
|
|
1168
1168
|
let end = start + ids.length;
|
|
1169
1169
|
for (let index = start; index < start + ids.length; index++) end = Math.max(end, descendantsEnd(doc, index));
|
|
1170
1170
|
return { start, end };
|
|
@@ -1208,7 +1208,7 @@ function shiftSubtree(tr, index, delta) {
|
|
|
1208
1208
|
// src/engine/commands/block-structure.ts
|
|
1209
1209
|
var toggleTask = (state, dispatch) => {
|
|
1210
1210
|
const { doc, selection } = state;
|
|
1211
|
-
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[
|
|
1211
|
+
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
|
|
1212
1212
|
if (tasks.length === 0) return false;
|
|
1213
1213
|
const checked = !tasks.every((block) => block.attrs.checked === true);
|
|
1214
1214
|
const tr = new Transaction(state);
|
|
@@ -1273,7 +1273,7 @@ function copiedSelection(selection, copies) {
|
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
1275
|
function duplicateBlocks(options = {}) {
|
|
1276
|
-
const makeId = options.newId ??
|
|
1276
|
+
const makeId = options.newId ?? chunkI7X7B3WD_cjs.newId;
|
|
1277
1277
|
return (state, dispatch) => {
|
|
1278
1278
|
const { doc, selection } = state;
|
|
1279
1279
|
const range = selectedBlockRange(doc, selection);
|
|
@@ -1295,12 +1295,12 @@ var deleteBlocks = (state, dispatch) => {
|
|
|
1295
1295
|
return true;
|
|
1296
1296
|
};
|
|
1297
1297
|
function insertBlockAfter(type, attrs, options = {}) {
|
|
1298
|
-
const makeId = options.newId ??
|
|
1298
|
+
const makeId = options.newId ?? chunkI7X7B3WD_cjs.newId;
|
|
1299
1299
|
return (state, dispatch) => {
|
|
1300
1300
|
const { doc, schema } = state;
|
|
1301
1301
|
const id = headBlockId(state.selection);
|
|
1302
1302
|
if (id === null) return false;
|
|
1303
|
-
const index =
|
|
1303
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(doc, id);
|
|
1304
1304
|
const current = doc.blocks[index];
|
|
1305
1305
|
const fillsCurrent = isParagraph(current) && regionLength(current, primaryRegion(schema, current) ?? "") === 0;
|
|
1306
1306
|
const block = createBlock(schema, type, attrs, current.indent, fillsCurrent ? current.id : makeId());
|
|
@@ -1320,10 +1320,10 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1320
1320
|
clear(tr, from, from.offset, to.offset);
|
|
1321
1321
|
return from;
|
|
1322
1322
|
}
|
|
1323
|
-
const block = tr.doc.blocks[
|
|
1323
|
+
const block = tr.doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, from.block)];
|
|
1324
1324
|
clear(tr, from, from.offset, regionLength(block, from.region));
|
|
1325
1325
|
for (const region of Object.keys(block.regions)) {
|
|
1326
|
-
const between =
|
|
1326
|
+
const between = chunkI7X7B3WD_cjs.compareRegionNames(from.region, region) < 0 && chunkI7X7B3WD_cjs.compareRegionNames(region, to.region) < 0;
|
|
1327
1327
|
if (between) clear(tr, { ...from, region }, 0, regionLength(block, region));
|
|
1328
1328
|
}
|
|
1329
1329
|
clear(tr, to, 0, to.offset);
|
|
@@ -1332,8 +1332,8 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1332
1332
|
function deleteRange(tr, schema, from, to, newId2) {
|
|
1333
1333
|
if (from.block === to.block) return deleteWithinBlock(tr, from, to);
|
|
1334
1334
|
const { doc } = tr;
|
|
1335
|
-
const start =
|
|
1336
|
-
const end =
|
|
1335
|
+
const start = chunkI7X7B3WD_cjs.requireBlockIndex(doc, from.block);
|
|
1336
|
+
const end = chunkI7X7B3WD_cjs.requireBlockIndex(doc, to.block);
|
|
1337
1337
|
const first = doc.blocks[start];
|
|
1338
1338
|
const last = doc.blocks[end];
|
|
1339
1339
|
const keepFirst = isTextFlow(schema, first);
|
|
@@ -1360,7 +1360,7 @@ function deleteRange(tr, schema, from, to, newId2) {
|
|
|
1360
1360
|
|
|
1361
1361
|
// src/engine/commands/insert-text-at.ts
|
|
1362
1362
|
function insertTextAt(tr, schema, pos, value) {
|
|
1363
|
-
const slice = [
|
|
1363
|
+
const slice = [chunkI7X7B3WD_cjs.text(value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
|
|
1364
1364
|
tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, slice));
|
|
1365
1365
|
return { ...pos, offset: pos.offset + value.length };
|
|
1366
1366
|
}
|
|
@@ -1372,12 +1372,12 @@ function replaceBlocksWithText(tr, schema, range, value, makeId) {
|
|
|
1372
1372
|
const indent2 = range === null ? 0 : doc.blocks[index].indent;
|
|
1373
1373
|
if (range !== null) tr.step(removeBlocksStep(index, range.end - range.start));
|
|
1374
1374
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, indent2, makeId());
|
|
1375
|
-
const paragraph = withContent(schema, empty, [
|
|
1375
|
+
const paragraph = withContent(schema, empty, [chunkI7X7B3WD_cjs.text(value)]);
|
|
1376
1376
|
tr.step(insertBlocksStep(index, [paragraph]));
|
|
1377
1377
|
tr.setSelection(endOf(tr.doc, schema, paragraph.id));
|
|
1378
1378
|
}
|
|
1379
1379
|
function insertText(value, options = {}) {
|
|
1380
|
-
const makeId = options.newId ??
|
|
1380
|
+
const makeId = options.newId ?? chunkI7X7B3WD_cjs.newId;
|
|
1381
1381
|
return (state, dispatch) => {
|
|
1382
1382
|
if (value === "") return false;
|
|
1383
1383
|
const { doc, schema, selection } = state;
|
|
@@ -1400,9 +1400,9 @@ function markExtent(inline, offset, type) {
|
|
|
1400
1400
|
let position = 0;
|
|
1401
1401
|
for (const node of inline) {
|
|
1402
1402
|
starts.push(position);
|
|
1403
|
-
position +=
|
|
1403
|
+
position += chunkI7X7B3WD_cjs.nodeLength(node);
|
|
1404
1404
|
}
|
|
1405
|
-
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] +
|
|
1405
|
+
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + chunkI7X7B3WD_cjs.nodeLength(node));
|
|
1406
1406
|
const markOf = (index) => inline[index]?.marks.find((mark2) => mark2.type === type);
|
|
1407
1407
|
let seed = containing(offset);
|
|
1408
1408
|
let mark = markOf(seed);
|
|
@@ -1411,29 +1411,29 @@ function markExtent(inline, offset, type) {
|
|
|
1411
1411
|
mark = markOf(seed);
|
|
1412
1412
|
}
|
|
1413
1413
|
if (mark === void 0) return null;
|
|
1414
|
-
const shares = (index) => inline[index].marks.some((other) =>
|
|
1414
|
+
const shares = (index) => inline[index].marks.some((other) => chunkI7X7B3WD_cjs.sameMark(other, mark));
|
|
1415
1415
|
let first = seed;
|
|
1416
1416
|
while (first > 0 && shares(first - 1)) first--;
|
|
1417
1417
|
let last = seed;
|
|
1418
1418
|
while (last < inline.length - 1 && shares(last + 1)) last++;
|
|
1419
|
-
return { from: starts[first], to: starts[last] +
|
|
1419
|
+
return { from: starts[first], to: starts[last] + chunkI7X7B3WD_cjs.nodeLength(inline[last]) };
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
1422
|
// src/engine/commands/storable-mark.ts
|
|
1423
1423
|
function readsBack(inline) {
|
|
1424
|
-
return
|
|
1424
|
+
return chunkI7X7B3WD_cjs.equalInline(chunkI7X7B3WD_cjs.parseInline(chunkI7X7B3WD_cjs.serializeInline(inline)), chunkI7X7B3WD_cjs.normalizeInline(inline));
|
|
1425
1425
|
}
|
|
1426
1426
|
function safeLink(mark) {
|
|
1427
1427
|
const href = mark.attrs?.href;
|
|
1428
|
-
const safe = typeof href === "string" ?
|
|
1428
|
+
const safe = typeof href === "string" ? chunkI7X7B3WD_cjs.sanitizeHref(href) : null;
|
|
1429
1429
|
return safe ? { type: "link", attrs: { ...mark.attrs, href: safe } } : null;
|
|
1430
1430
|
}
|
|
1431
1431
|
function storableMark(mark) {
|
|
1432
1432
|
const candidate = mark.type === "link" ? safeLink(mark) : mark;
|
|
1433
|
-
return candidate !== null && readsBack([
|
|
1433
|
+
return candidate !== null && readsBack([chunkI7X7B3WD_cjs.text("a", [candidate])]) ? candidate : null;
|
|
1434
1434
|
}
|
|
1435
1435
|
function storableAtom(type, attrs) {
|
|
1436
|
-
return readsBack([
|
|
1436
|
+
return readsBack([chunkI7X7B3WD_cjs.atom(type, attrs)]);
|
|
1437
1437
|
}
|
|
1438
1438
|
|
|
1439
1439
|
// src/engine/commands/selection-marks.ts
|
|
@@ -1452,8 +1452,8 @@ function textRanges(state, selection) {
|
|
|
1452
1452
|
if (from.region !== to.region) return [];
|
|
1453
1453
|
return [{ block: from.block, region: from.region, from: from.offset, to: to.offset }];
|
|
1454
1454
|
}
|
|
1455
|
-
const first =
|
|
1456
|
-
const last =
|
|
1455
|
+
const first = chunkI7X7B3WD_cjs.requireBlockIndex(doc, from.block);
|
|
1456
|
+
const last = chunkI7X7B3WD_cjs.requireBlockIndex(doc, to.block);
|
|
1457
1457
|
return doc.blocks.slice(first, last + 1).flatMap((block, i) => {
|
|
1458
1458
|
const whole = wholeRegion(schema, block);
|
|
1459
1459
|
if (whole === null) return [];
|
|
@@ -1465,7 +1465,7 @@ function textRanges(state, selection) {
|
|
|
1465
1465
|
function selectionRanges(state, selection) {
|
|
1466
1466
|
if (selection.kind === "text") return textRanges(state, selection);
|
|
1467
1467
|
return selectedBlockIds(state.doc, selection).flatMap((id) => {
|
|
1468
|
-
const whole = wholeRegion(state.schema, state.doc.blocks[
|
|
1468
|
+
const whole = wholeRegion(state.schema, state.doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(state.doc, id)]);
|
|
1469
1469
|
return whole === null ? [] : [whole];
|
|
1470
1470
|
});
|
|
1471
1471
|
}
|
|
@@ -1474,8 +1474,8 @@ function markRanges(state) {
|
|
|
1474
1474
|
return selection === null ? [] : selectionRanges(state, selection).filter((range) => range.from < range.to);
|
|
1475
1475
|
}
|
|
1476
1476
|
function rangeContent(state, range) {
|
|
1477
|
-
const inline =
|
|
1478
|
-
return
|
|
1477
|
+
const inline = chunkI7X7B3WD_cjs.blockById(state.doc, range.block)?.regions[range.region] ?? [];
|
|
1478
|
+
return chunkI7X7B3WD_cjs.sliceInline(inline, range.from, range.to);
|
|
1479
1479
|
}
|
|
1480
1480
|
function markCoverage(content, type, attrs) {
|
|
1481
1481
|
const carries = (node) => node.marks.some((mark) => matchesMark(mark, type, attrs));
|
|
@@ -1518,8 +1518,8 @@ function applyMark(type, attrs, mode) {
|
|
|
1518
1518
|
const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
|
|
1519
1519
|
const active = current.some((existing) => matchesMark(existing, type, mark.attrs));
|
|
1520
1520
|
const remove2 = mode === "remove" || mode === "toggle" && active;
|
|
1521
|
-
const next = remove2 ?
|
|
1522
|
-
if (
|
|
1521
|
+
const next = remove2 ? chunkI7X7B3WD_cjs.removeMark(current, target) : chunkI7X7B3WD_cjs.addMark(current, mark);
|
|
1522
|
+
if (chunkI7X7B3WD_cjs.sameMarkSet(next, current)) return false;
|
|
1523
1523
|
dispatch?.(new Transaction(state).setStoredMarks(next));
|
|
1524
1524
|
return true;
|
|
1525
1525
|
}
|
|
@@ -1543,17 +1543,17 @@ function unsetMark(type) {
|
|
|
1543
1543
|
function linkRanges(state) {
|
|
1544
1544
|
const caret = collapsedCaret(state);
|
|
1545
1545
|
if (caret === null) return markRanges(state);
|
|
1546
|
-
const inline =
|
|
1546
|
+
const inline = chunkI7X7B3WD_cjs.blockById(state.doc, caret.block)?.regions[caret.region] ?? [];
|
|
1547
1547
|
const extent = markExtent(inline, caret.offset, "link");
|
|
1548
1548
|
return extent === null ? [] : [{ block: caret.block, region: caret.region, ...extent }];
|
|
1549
1549
|
}
|
|
1550
1550
|
function setLink(href, title) {
|
|
1551
|
-
const safe =
|
|
1551
|
+
const safe = chunkI7X7B3WD_cjs.sanitizeHref(href);
|
|
1552
1552
|
return (state, dispatch) => {
|
|
1553
1553
|
if (safe === null || safe === "") return false;
|
|
1554
1554
|
const link = { type: "link", attrs: title ? { href: safe, title } : { href: safe } };
|
|
1555
1555
|
return editRanges(state, dispatch, linkRanges(state), (tr, { block, region, from, to }, content) => {
|
|
1556
|
-
const linked2 = content.every((node) => node.marks.some((mark) =>
|
|
1556
|
+
const linked2 = content.every((node) => node.marks.some((mark) => chunkI7X7B3WD_cjs.sameMark(mark, link)));
|
|
1557
1557
|
if (!linked2) tr.step(addMarkStep(block, region, from, to, link));
|
|
1558
1558
|
});
|
|
1559
1559
|
};
|
|
@@ -1583,7 +1583,7 @@ function insertAtom(type, attrs) {
|
|
|
1583
1583
|
const tr = new Transaction(state);
|
|
1584
1584
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
1585
1585
|
const caret = deleteRange(tr, schema, from, to);
|
|
1586
|
-
const node =
|
|
1586
|
+
const node = chunkI7X7B3WD_cjs.atom(type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
|
|
1587
1587
|
tr.step(replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [node]));
|
|
1588
1588
|
tr.setSelection(textSelection({ ...caret, offset: caret.offset + 1 }));
|
|
1589
1589
|
dispatch?.(tr);
|
|
@@ -1601,19 +1601,19 @@ var TEXT_ATTRIBUTE = /* @__PURE__ */ new Map([
|
|
|
1601
1601
|
["MATH", "latex"]
|
|
1602
1602
|
]);
|
|
1603
1603
|
function holdsText(schema, type) {
|
|
1604
|
-
return TEXT_ATTRIBUTE.has(type) ||
|
|
1604
|
+
return TEXT_ATTRIBUTE.has(type) || chunkI7X7B3WD_cjs.specFor(schema, type).flow === "text";
|
|
1605
1605
|
}
|
|
1606
1606
|
function sourceContent(schema, block) {
|
|
1607
1607
|
const field = TEXT_ATTRIBUTE.get(block.type);
|
|
1608
1608
|
if (field !== void 0) {
|
|
1609
1609
|
const value = block.attrs[field];
|
|
1610
|
-
return typeof value === "string" && value !== "" ? [
|
|
1610
|
+
return typeof value === "string" && value !== "" ? [chunkI7X7B3WD_cjs.text(value)] : [];
|
|
1611
1611
|
}
|
|
1612
1612
|
const region = primaryRegion(schema, block);
|
|
1613
1613
|
return region === null ? [] : block.regions[region];
|
|
1614
1614
|
}
|
|
1615
1615
|
function plainText(schema, content) {
|
|
1616
|
-
return
|
|
1616
|
+
return chunkI7X7B3WD_cjs.inlineText(content, (node) => schema.atoms.get(node.type)?.plainText(node.attrs) ?? "");
|
|
1617
1617
|
}
|
|
1618
1618
|
function convert(schema, block, type, attrs) {
|
|
1619
1619
|
const content = sourceContent(schema, block);
|
|
@@ -1632,7 +1632,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1632
1632
|
if (!holdsText(schema, type)) return false;
|
|
1633
1633
|
const ids = selectedBlockIds(doc, selection);
|
|
1634
1634
|
const convertible = (block) => isTextFlow(schema, block) || selection?.kind === "node" && TEXT_ATTRIBUTE.has(block.type);
|
|
1635
|
-
const blocks = ids.flatMap((id) =>
|
|
1635
|
+
const blocks = ids.flatMap((id) => chunkI7X7B3WD_cjs.blockById(doc, id) ?? []).filter(convertible);
|
|
1636
1636
|
if (blocks.length === 0) return false;
|
|
1637
1637
|
const tr = new Transaction(state);
|
|
1638
1638
|
const moved2 = /* @__PURE__ */ new Map();
|
|
@@ -1646,7 +1646,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1646
1646
|
tr.step(replaceBlockStep(next));
|
|
1647
1647
|
const from = primaryRegion(schema, block);
|
|
1648
1648
|
const to = primaryRegion(schema, next);
|
|
1649
|
-
if (from !== null && to !== null) moved2.set(block.id, { from, to, length:
|
|
1649
|
+
if (from !== null && to !== null) moved2.set(block.id, { from, to, length: chunkI7X7B3WD_cjs.inlineLength(next.regions[to]) });
|
|
1650
1650
|
}
|
|
1651
1651
|
if (!tr.docChanged) return false;
|
|
1652
1652
|
if (selection?.kind === "text" && moved2.size > 0) {
|
|
@@ -1657,7 +1657,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1657
1657
|
};
|
|
1658
1658
|
tr.setSelection(textSelection(carry(selection.anchor), carry(selection.head)));
|
|
1659
1659
|
}
|
|
1660
|
-
const converted = selection?.kind === "node" ?
|
|
1660
|
+
const converted = selection?.kind === "node" ? chunkI7X7B3WD_cjs.blockById(tr.doc, selection.block) : void 0;
|
|
1661
1661
|
if (converted !== void 0 && isTextFlow(schema, converted)) tr.setSelection(endOf(tr.doc, schema, converted.id));
|
|
1662
1662
|
dispatch?.(tr);
|
|
1663
1663
|
return true;
|
|
@@ -1675,10 +1675,10 @@ function ruleTransaction(state, rules, context) {
|
|
|
1675
1675
|
const { selection, doc } = state;
|
|
1676
1676
|
if (selection?.kind !== "text") return null;
|
|
1677
1677
|
const { block: id, region, offset } = selection.head;
|
|
1678
|
-
const block = doc.blocks[
|
|
1678
|
+
const block = doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(doc, id)];
|
|
1679
1679
|
const inline = block.regions[region];
|
|
1680
|
-
if (
|
|
1681
|
-
const before =
|
|
1680
|
+
if (chunkI7X7B3WD_cjs.hasMark(chunkI7X7B3WD_cjs.marksAt(inline, offset, () => true), "code")) return null;
|
|
1681
|
+
const before = chunkI7X7B3WD_cjs.inlineText(chunkI7X7B3WD_cjs.sliceInline(inline, 0, offset));
|
|
1682
1682
|
for (const rule of rules) {
|
|
1683
1683
|
const match = appliesTo(rule, block) ? rule.match.exec(before) : null;
|
|
1684
1684
|
if (match === null) continue;
|
|
@@ -1688,7 +1688,7 @@ function ruleTransaction(state, rules, context) {
|
|
|
1688
1688
|
return null;
|
|
1689
1689
|
}
|
|
1690
1690
|
function insertTextWithRules(value, rules, options = {}) {
|
|
1691
|
-
const context = { newId: options.newId ??
|
|
1691
|
+
const context = { newId: options.newId ?? chunkI7X7B3WD_cjs.newId };
|
|
1692
1692
|
const insert = insertText(value, { origin: "input", newId: context.newId });
|
|
1693
1693
|
return (state, dispatch) => {
|
|
1694
1694
|
let fired = false;
|
|
@@ -1738,11 +1738,11 @@ var divider = {
|
|
|
1738
1738
|
kinds: PARAGRAPH,
|
|
1739
1739
|
handler(state, _match, range, context) {
|
|
1740
1740
|
const { doc, schema } = state;
|
|
1741
|
-
const index =
|
|
1741
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(doc, range.block);
|
|
1742
1742
|
const block = doc.blocks[index];
|
|
1743
1743
|
const content = block.regions[range.region];
|
|
1744
|
-
const tail =
|
|
1745
|
-
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ??
|
|
1744
|
+
const tail = chunkI7X7B3WD_cjs.sliceInline(content, range.to, chunkI7X7B3WD_cjs.inlineLength(content));
|
|
1745
|
+
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ?? chunkI7X7B3WD_cjs.newId)());
|
|
1746
1746
|
const next = withContent(schema, empty, tail);
|
|
1747
1747
|
const tr = new Transaction(state);
|
|
1748
1748
|
tr.step(replaceBlockStep(createBlock(schema, "DIVIDER", {}, block.indent, block.id)));
|
|
@@ -1780,7 +1780,7 @@ var blockInputRules = [
|
|
|
1780
1780
|
|
|
1781
1781
|
// src/engine/markdown/autolink-href.ts
|
|
1782
1782
|
function autolinkHref(url) {
|
|
1783
|
-
return
|
|
1783
|
+
return chunkI7X7B3WD_cjs.sanitizeHref(/^www\./i.test(url) ? `https://${url}` : url);
|
|
1784
1784
|
}
|
|
1785
1785
|
|
|
1786
1786
|
// src/engine/markdown/trim-url-end.ts
|
|
@@ -1802,12 +1802,12 @@ function trimUrlEnd(url) {
|
|
|
1802
1802
|
|
|
1803
1803
|
// src/engine/rules/region-inline.ts
|
|
1804
1804
|
function regionInline(state, range) {
|
|
1805
|
-
return state.doc.blocks[
|
|
1805
|
+
return state.doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(state.doc, range.block)].regions[range.region];
|
|
1806
1806
|
}
|
|
1807
1807
|
|
|
1808
1808
|
// src/engine/rules/touches-mark.ts
|
|
1809
1809
|
function touchesMark(inline, from, to, type) {
|
|
1810
|
-
return
|
|
1810
|
+
return chunkI7X7B3WD_cjs.sliceInline(inline, from, to).some((node) => chunkI7X7B3WD_cjs.hasMark(node.marks, type));
|
|
1811
1811
|
}
|
|
1812
1812
|
|
|
1813
1813
|
// src/engine/rules/autolink.ts
|
|
@@ -1841,7 +1841,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1841
1841
|
const contentTo = to - (close?.(found) ?? open);
|
|
1842
1842
|
const contentFrom = contentTo - found[1].length;
|
|
1843
1843
|
const from = contentFrom - open;
|
|
1844
|
-
if (wordBounded && WORD_CHARACTER.test(
|
|
1844
|
+
if (wordBounded && WORD_CHARACTER.test(chunkI7X7B3WD_cjs.inlineText(chunkI7X7B3WD_cjs.sliceInline(inline, to, to + 1)))) return null;
|
|
1845
1845
|
if (touchesMark(inline, from, contentFrom, "code") || touchesMark(inline, contentTo, to, "code")) return null;
|
|
1846
1846
|
const tr = new Transaction(state);
|
|
1847
1847
|
tr.step(addMarkStep(block, region, contentFrom, contentTo, added));
|
|
@@ -1849,7 +1849,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1849
1849
|
tr.step(replaceInlineStep(block, region, from, contentFrom, []));
|
|
1850
1850
|
const caret = { block, region, offset: from + found[1].length };
|
|
1851
1851
|
const carried = caretMarks(tr.doc, state.schema, null, caret);
|
|
1852
|
-
return tr.setSelection(textSelection(caret)).setStoredMarks(
|
|
1852
|
+
return tr.setSelection(textSelection(caret)).setStoredMarks(chunkI7X7B3WD_cjs.removeMark(carried, added.type));
|
|
1853
1853
|
}
|
|
1854
1854
|
};
|
|
1855
1855
|
}
|
|
@@ -1870,7 +1870,7 @@ var markInputRules = [
|
|
|
1870
1870
|
open: 1,
|
|
1871
1871
|
close: (match) => match[2].length + 3,
|
|
1872
1872
|
mark(match) {
|
|
1873
|
-
const href =
|
|
1873
|
+
const href = chunkI7X7B3WD_cjs.sanitizeHref(match[2]);
|
|
1874
1874
|
return href === null ? null : { type: "link", attrs: { href } };
|
|
1875
1875
|
}
|
|
1876
1876
|
}),
|
|
@@ -1888,7 +1888,7 @@ function replacing(name, match, replacement) {
|
|
|
1888
1888
|
handler(state, found, range) {
|
|
1889
1889
|
const value = typeof replacement === "string" ? replacement : replacement(found);
|
|
1890
1890
|
const from = range.to - (found[1] ?? found[0]).length;
|
|
1891
|
-
const node =
|
|
1891
|
+
const node = chunkI7X7B3WD_cjs.text(value, chunkI7X7B3WD_cjs.marksAt(regionInline(state, range), range.to, () => true));
|
|
1892
1892
|
return new Transaction(state).step(replaceInlineStep(range.block, range.region, from, range.to, [node]));
|
|
1893
1893
|
}
|
|
1894
1894
|
};
|
|
@@ -2172,7 +2172,7 @@ function nearestPaletteColor(css, kind) {
|
|
|
2172
2172
|
const table = PALETTE_RGB[kind];
|
|
2173
2173
|
let best = "default";
|
|
2174
2174
|
let least = Infinity;
|
|
2175
|
-
for (const name of
|
|
2175
|
+
for (const name of chunkI7X7B3WD_cjs.PALETTE) {
|
|
2176
2176
|
for (const reference of table[name]) {
|
|
2177
2177
|
const gap = distance(rgb, reference);
|
|
2178
2178
|
if (gap < least) {
|
|
@@ -2186,31 +2186,31 @@ function nearestPaletteColor(css, kind) {
|
|
|
2186
2186
|
|
|
2187
2187
|
// src/engine/clipboard/html-marks.ts
|
|
2188
2188
|
function linkMark(element) {
|
|
2189
|
-
const href =
|
|
2189
|
+
const href = chunkI7X7B3WD_cjs.sanitizeHref(element.getAttribute("href") ?? "");
|
|
2190
2190
|
if (href === null || href === "") return null;
|
|
2191
2191
|
const title = element.getAttribute("title");
|
|
2192
2192
|
return { type: "link", attrs: title ? { href, title } : { href } };
|
|
2193
2193
|
}
|
|
2194
2194
|
function highlightMark(element) {
|
|
2195
2195
|
const color = element.getAttribute("data-color") ?? "";
|
|
2196
|
-
return
|
|
2196
|
+
return chunkI7X7B3WD_cjs.isPaletteColor(color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
|
|
2197
2197
|
}
|
|
2198
2198
|
function elementMarks(element, inherited) {
|
|
2199
2199
|
const tag = tagName(element);
|
|
2200
2200
|
const styles = parseStyle(element.getAttribute("style"));
|
|
2201
2201
|
let marks = inherited;
|
|
2202
2202
|
const add = (mark) => {
|
|
2203
|
-
marks =
|
|
2203
|
+
marks = chunkI7X7B3WD_cjs.addMark(marks, mark);
|
|
2204
2204
|
};
|
|
2205
2205
|
const link = tag === "a" ? linkMark(element) : null;
|
|
2206
2206
|
if (link !== null) add(link);
|
|
2207
|
-
const linked2 =
|
|
2207
|
+
const linked2 = chunkI7X7B3WD_cjs.hasMark(marks, "link");
|
|
2208
2208
|
const weight = fontWeight(styles);
|
|
2209
2209
|
if (weight !== null ? weight >= 600 : tag === "b" || tag === "strong") add({ type: "bold" });
|
|
2210
|
-
else if (weight !== null) marks =
|
|
2210
|
+
else if (weight !== null) marks = chunkI7X7B3WD_cjs.removeMark(marks, "bold");
|
|
2211
2211
|
const slanted = isItalicStyle(styles);
|
|
2212
2212
|
if (slanted ?? (tag === "i" || tag === "em")) add({ type: "italic" });
|
|
2213
|
-
else if (slanted === false) marks =
|
|
2213
|
+
else if (slanted === false) marks = chunkI7X7B3WD_cjs.removeMark(marks, "italic");
|
|
2214
2214
|
if (tag === "u" || !linked2 && hasDecoration(styles, "underline")) add({ type: "underline" });
|
|
2215
2215
|
if (tag === "s" || tag === "del" || tag === "strike" || hasDecoration(styles, "line-through")) {
|
|
2216
2216
|
add({ type: "strike" });
|
|
@@ -2229,7 +2229,7 @@ function elementMarks(element, inherited) {
|
|
|
2229
2229
|
}
|
|
2230
2230
|
|
|
2231
2231
|
// src/engine/clipboard/hoist-spaces.ts
|
|
2232
|
-
var shared = (a, b) => a.filter((mark) => b.some((other) =>
|
|
2232
|
+
var shared = (a, b) => a.filter((mark) => b.some((other) => chunkI7X7B3WD_cjs.sameMark(mark, other)));
|
|
2233
2233
|
function hoistEdgeSpaces(pieces) {
|
|
2234
2234
|
const result = [];
|
|
2235
2235
|
pieces.forEach((piece, at) => {
|
|
@@ -2292,7 +2292,7 @@ function finish({ pieces }) {
|
|
|
2292
2292
|
break;
|
|
2293
2293
|
}
|
|
2294
2294
|
}
|
|
2295
|
-
const inline =
|
|
2295
|
+
const inline = chunkI7X7B3WD_cjs.normalizeInline(hoistEdgeSpaces(pieces).map((piece) => chunkI7X7B3WD_cjs.text(piece.text, piece.marks)));
|
|
2296
2296
|
return inline.every((node) => node.kind === "text" && node.text.trim() === "") ? [] : inline;
|
|
2297
2297
|
}
|
|
2298
2298
|
function visit(acc, node, style, depth) {
|
|
@@ -2389,7 +2389,7 @@ function wordListItem(paragraph, ctx, sink) {
|
|
|
2389
2389
|
|
|
2390
2390
|
// src/engine/clipboard/html-media.ts
|
|
2391
2391
|
function imageBlock(img, caption, ctx, sink) {
|
|
2392
|
-
const url =
|
|
2392
|
+
const url = chunkI7X7B3WD_cjs.sanitizeHref(img.getAttribute("src") ?? "");
|
|
2393
2393
|
if (url === null || url === "") return;
|
|
2394
2394
|
emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: img.getAttribute("alt") ?? "", url }, { caption });
|
|
2395
2395
|
}
|
|
@@ -2427,7 +2427,7 @@ function tableBlock(table, ctx, sink) {
|
|
|
2427
2427
|
rows.forEach((row, r) => {
|
|
2428
2428
|
for (let c = 0; c < cols; c++) {
|
|
2429
2429
|
const cell = row.cells[c];
|
|
2430
|
-
regions[
|
|
2430
|
+
regions[chunkI7X7B3WD_cjs.cellKey(r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
|
|
2431
2431
|
}
|
|
2432
2432
|
});
|
|
2433
2433
|
const header = rows[0].head || rows[0].cells.some((cell) => tagName(cell) === "th");
|
|
@@ -2440,7 +2440,7 @@ var HEADING = /^h([1-6])$/;
|
|
|
2440
2440
|
function emitRun(run, ctx, sink) {
|
|
2441
2441
|
const inline = inlineFromNodes(run, ctx);
|
|
2442
2442
|
if (inline.length === 0) return;
|
|
2443
|
-
const plain = ctx.run.kind === "heading" ?
|
|
2443
|
+
const plain = ctx.run.kind === "heading" ? chunkI7X7B3WD_cjs.removeMarkRange(inline, 0, chunkI7X7B3WD_cjs.inlineLength(inline), "bold") : inline;
|
|
2444
2444
|
emitText(sink, ctx.indent, ctx.run, plain);
|
|
2445
2445
|
}
|
|
2446
2446
|
function details(element, ctx, sink) {
|
|
@@ -2525,8 +2525,8 @@ function availableParser(parser) {
|
|
|
2525
2525
|
function fromHTML(html, options = {}) {
|
|
2526
2526
|
const parser = availableParser(options.parser);
|
|
2527
2527
|
if (parser === null) throw new Error("fromHTML needs a DOMParser");
|
|
2528
|
-
const makeId = options.newId ??
|
|
2529
|
-
const codec =
|
|
2528
|
+
const makeId = options.newId ?? chunkI7X7B3WD_cjs.newId;
|
|
2529
|
+
const codec = chunkI7X7B3WD_cjs.createBlockCodec(chunkI7X7B3WD_cjs.createSchema(), { newId: makeId });
|
|
2530
2530
|
const { body } = parser.parseFromString(html, "text/html");
|
|
2531
2531
|
return blocksFromBody(body, makeId).map((block) => codec.toQuoin(block));
|
|
2532
2532
|
}
|
|
@@ -2547,7 +2547,7 @@ function quoteLines(text2) {
|
|
|
2547
2547
|
|
|
2548
2548
|
// src/engine/markdown/document/block-forms.ts
|
|
2549
2549
|
var ALERT_NAMES = new Map(
|
|
2550
|
-
Object.entries(
|
|
2550
|
+
Object.entries(chunkI7X7B3WD_cjs.ALERT_TONES).map(([name, tone]) => [tone, name])
|
|
2551
2551
|
);
|
|
2552
2552
|
var DELIMITERS = /* @__PURE__ */ new Map([
|
|
2553
2553
|
["left", ":--"],
|
|
@@ -2557,8 +2557,8 @@ var DELIMITERS = /* @__PURE__ */ new Map([
|
|
|
2557
2557
|
var MIN_FENCE = 3;
|
|
2558
2558
|
var FENCE_LIKE_MATH_LINE = /^ {0,3}\${2,}[ \t]*$/m;
|
|
2559
2559
|
function calloutMarkdown(data) {
|
|
2560
|
-
const name = ALERT_NAMES.get(
|
|
2561
|
-
const body =
|
|
2560
|
+
const name = ALERT_NAMES.get(chunkI7X7B3WD_cjs.str(data.tone)) ?? "NOTE";
|
|
2561
|
+
const body = chunkI7X7B3WD_cjs.str(data.body);
|
|
2562
2562
|
return quoteLines(body === "" ? `[!${name}]` : `[!${name}]
|
|
2563
2563
|
${/^.*\|/.test(body) ? "\n" : ""}${body}`);
|
|
2564
2564
|
}
|
|
@@ -2572,18 +2572,18 @@ function longestRun(value, char) {
|
|
|
2572
2572
|
return longest;
|
|
2573
2573
|
}
|
|
2574
2574
|
function codeMarkdown(data) {
|
|
2575
|
-
const code =
|
|
2576
|
-
const info =
|
|
2575
|
+
const code = chunkI7X7B3WD_cjs.str(data.code);
|
|
2576
|
+
const info = chunkI7X7B3WD_cjs.str(data.language);
|
|
2577
2577
|
const char = info.includes("`") ? "~" : "`";
|
|
2578
2578
|
const fence = char.repeat(Math.max(MIN_FENCE, longestRun(code, char) + 1));
|
|
2579
2579
|
return [fence + info.replace(/[\\&]/g, "\\$&"), ...code === "" ? [] : code.split("\n"), fence].join("\n");
|
|
2580
2580
|
}
|
|
2581
2581
|
function mathMarkdown(data) {
|
|
2582
|
-
const latex =
|
|
2582
|
+
const latex = chunkI7X7B3WD_cjs.str(data.latex);
|
|
2583
2583
|
if (FENCE_LIKE_MATH_LINE.test(latex)) return null;
|
|
2584
2584
|
return ["$$", ...latex === "" ? [] : latex.split("\n"), "$$"].join("\n");
|
|
2585
2585
|
}
|
|
2586
|
-
var cellsOf = (row) => Array.isArray(row) ? row.map(
|
|
2586
|
+
var cellsOf = (row) => Array.isArray(row) ? row.map(chunkI7X7B3WD_cjs.str) : [];
|
|
2587
2587
|
var rowMarkdown = (cells) => `| ${cells.join(" | ")} |`;
|
|
2588
2588
|
function tableMarkdown(data) {
|
|
2589
2589
|
const rows = Array.isArray(data.rows) ? data.rows.map(cellsOf) : [];
|
|
@@ -2610,7 +2610,7 @@ function needsComment(block, residual, schema, ctx) {
|
|
|
2610
2610
|
const native = NATIVE_KEYS.get(block.type);
|
|
2611
2611
|
if (!native) return false;
|
|
2612
2612
|
if (residual > 0) return true;
|
|
2613
|
-
return Object.keys(
|
|
2613
|
+
return Object.keys(chunkI7X7B3WD_cjs.specFor(schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
|
|
2614
2614
|
}
|
|
2615
2615
|
|
|
2616
2616
|
// src/engine/markdown/document/comment-markdown.ts
|
|
@@ -2624,41 +2624,41 @@ function quoinComment(type, data, indent2) {
|
|
|
2624
2624
|
// src/engine/markdown/document/link-forms.ts
|
|
2625
2625
|
var oneLine = (value) => value.replace(/[\r\n]+/g, " ");
|
|
2626
2626
|
function linked(label, href, ctx) {
|
|
2627
|
-
return ctx.inline.serialize([
|
|
2627
|
+
return ctx.inline.serialize([chunkI7X7B3WD_cjs.text(label || href, [{ type: "link", attrs: { href } }])]);
|
|
2628
2628
|
}
|
|
2629
2629
|
var assetUrl = (storageKey, ctx) => storageKey === "" ? "" : ctx.resolveAssetUrl(storageKey);
|
|
2630
2630
|
function imageMarkdown(data, ctx) {
|
|
2631
|
-
const href =
|
|
2631
|
+
const href = chunkI7X7B3WD_cjs.str(data.url) || assetUrl(chunkI7X7B3WD_cjs.str(data.storageKey), ctx);
|
|
2632
2632
|
if (href === "") return null;
|
|
2633
|
-
const caption =
|
|
2634
|
-
const alt = ctx.inline.serialize([
|
|
2635
|
-
return `![${alt}${
|
|
2633
|
+
const caption = chunkI7X7B3WD_cjs.str(data.caption);
|
|
2634
|
+
const alt = ctx.inline.serialize([chunkI7X7B3WD_cjs.text(oneLine(chunkI7X7B3WD_cjs.str(data.alt)))]);
|
|
2635
|
+
return `![${alt}${chunkI7X7B3WD_cjs.linkClose({ type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
|
|
2636
2636
|
}
|
|
2637
2637
|
function fileMarkdown(data, ctx) {
|
|
2638
|
-
const href = assetUrl(
|
|
2639
|
-
return href === "" ? null : linked(oneLine(
|
|
2638
|
+
const href = assetUrl(chunkI7X7B3WD_cjs.str(data.storageKey), ctx);
|
|
2639
|
+
return href === "" ? null : linked(oneLine(chunkI7X7B3WD_cjs.str(data.filename)), href, ctx);
|
|
2640
2640
|
}
|
|
2641
2641
|
function embedMarkdown(data, ctx) {
|
|
2642
|
-
const url =
|
|
2642
|
+
const url = chunkI7X7B3WD_cjs.str(data.url);
|
|
2643
2643
|
return url === "" ? null : linked(url, url, ctx);
|
|
2644
2644
|
}
|
|
2645
2645
|
function bookmarkMarkdown(data, ctx) {
|
|
2646
|
-
const url =
|
|
2647
|
-
return url === "" ? null : linked(oneLine(
|
|
2646
|
+
const url = chunkI7X7B3WD_cjs.str(data.url);
|
|
2647
|
+
return url === "" ? null : linked(oneLine(chunkI7X7B3WD_cjs.str(data.title)), url, ctx);
|
|
2648
2648
|
}
|
|
2649
2649
|
|
|
2650
2650
|
// src/engine/markdown/document/block-markdown.ts
|
|
2651
2651
|
var QUOTE_PREFIX = "> ";
|
|
2652
2652
|
function markdownLine(block, data) {
|
|
2653
2653
|
const kind = block.attrs.kind ?? "paragraph";
|
|
2654
|
-
const markdown =
|
|
2655
|
-
const empty =
|
|
2654
|
+
const markdown = chunkI7X7B3WD_cjs.str(data.markdown);
|
|
2655
|
+
const empty = chunkI7X7B3WD_cjs.inlineLength(block.regions.text ?? []) === 0;
|
|
2656
2656
|
if (empty && (kind === "paragraph" || kind === "quote")) return null;
|
|
2657
2657
|
return kind === "quote" ? quoteLines(markdown.slice(QUOTE_PREFIX.length)) : markdown;
|
|
2658
2658
|
}
|
|
2659
2659
|
function toggleMarkdown(data) {
|
|
2660
2660
|
return `<details${data.open === true ? " open" : ""}>
|
|
2661
|
-
<summary>${
|
|
2661
|
+
<summary>${chunkI7X7B3WD_cjs.str(data.markdown)}</summary>`;
|
|
2662
2662
|
}
|
|
2663
2663
|
function coreMarkdown(block, data, env, residual) {
|
|
2664
2664
|
switch (block.type) {
|
|
@@ -2691,9 +2691,9 @@ function coreMarkdown(block, data, env, residual) {
|
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
2693
|
function blockMarkdown(block, env, { residual, asComment }) {
|
|
2694
|
-
const spec =
|
|
2694
|
+
const spec = chunkI7X7B3WD_cjs.specFor(env.schema, block.type);
|
|
2695
2695
|
const data = spec.toData(block, env.ctx);
|
|
2696
|
-
const comment = () =>
|
|
2696
|
+
const comment = () => chunkI7X7B3WD_cjs.isQuoinType(block.type) ? quoinComment(block.type, data, residual) : null;
|
|
2697
2697
|
if (asComment || env.lossless && !hasNativeForm(block.type)) return comment();
|
|
2698
2698
|
const written = spec.toMarkdown ? spec.toMarkdown(block, env.ctx) : coreMarkdown(block, data, env, residual);
|
|
2699
2699
|
if (written !== null) return written;
|
|
@@ -2723,7 +2723,7 @@ function createListContext() {
|
|
|
2723
2723
|
let placed = block;
|
|
2724
2724
|
let number = 1;
|
|
2725
2725
|
if (line2 === "ordered") {
|
|
2726
|
-
number = Math.min(runs.get(block.indent) ??
|
|
2726
|
+
number = Math.min(runs.get(block.indent) ?? chunkI7X7B3WD_cjs.orderedStart(block.attrs.start), chunkI7X7B3WD_cjs.MAX_MARKER_NUMBER);
|
|
2727
2727
|
runs.set(block.indent, number + 1);
|
|
2728
2728
|
if (number !== block.attrs.start) placed = { ...block, attrs: { ...block.attrs, start: number } };
|
|
2729
2729
|
} else {
|
|
@@ -2733,7 +2733,7 @@ function createListContext() {
|
|
|
2733
2733
|
const hang = isItem2 ? (line2 === "ordered" ? String(number).length : 0) + 2 : 0;
|
|
2734
2734
|
const container = comment ? void 0 : openedBy(block, prefix, hang);
|
|
2735
2735
|
if (container) stack.push(container);
|
|
2736
|
-
const bare = !comment && (line2 === "bullet" || line2 === "ordered") &&
|
|
2736
|
+
const bare = !comment && (line2 === "bullet" || line2 === "ordered") && chunkI7X7B3WD_cjs.inlineLength(block.regions.text ?? []) === 0;
|
|
2737
2737
|
const fragile = isItem2 && (bare || line2 === "ordered" && number !== 1);
|
|
2738
2738
|
const shown = comment ? void 0 : line2;
|
|
2739
2739
|
return { block: placed, line: shown, prefix, hang, residual, parent, container, closed, bare, fragile, comment };
|
|
@@ -2751,7 +2751,7 @@ function stripComments(block) {
|
|
|
2751
2751
|
regions: Object.fromEntries(
|
|
2752
2752
|
regions.map(([name, inline]) => [
|
|
2753
2753
|
name,
|
|
2754
|
-
hasCommentMark(inline) ?
|
|
2754
|
+
hasCommentMark(inline) ? chunkI7X7B3WD_cjs.removeMarkRange(inline, 0, chunkI7X7B3WD_cjs.inlineLength(inline), "comment") : inline
|
|
2755
2755
|
])
|
|
2756
2756
|
)
|
|
2757
2757
|
};
|
|
@@ -2780,7 +2780,7 @@ function pieceOf(text2, placement) {
|
|
|
2780
2780
|
opened: placement.container,
|
|
2781
2781
|
bare: placement.bare,
|
|
2782
2782
|
fragile: placement.fragile,
|
|
2783
|
-
leadsHtml: hang > 0 &&
|
|
2783
|
+
leadsHtml: hang > 0 && chunkI7X7B3WD_cjs.startsHtmlBlock(text2.split("\n")[0].slice(hang))
|
|
2784
2784
|
};
|
|
2785
2785
|
}
|
|
2786
2786
|
function takenAsItemText(previous, { parent, line: line2 }) {
|
|
@@ -2805,8 +2805,8 @@ function join(pieces) {
|
|
|
2805
2805
|
`;
|
|
2806
2806
|
}
|
|
2807
2807
|
function toMarkdown(blocks, options = {}) {
|
|
2808
|
-
const schema = options.schema ??
|
|
2809
|
-
const codec =
|
|
2808
|
+
const schema = options.schema ?? chunkI7X7B3WD_cjs.createSchema();
|
|
2809
|
+
const codec = chunkI7X7B3WD_cjs.createBlockCodec(schema);
|
|
2810
2810
|
const env = {
|
|
2811
2811
|
schema,
|
|
2812
2812
|
lossless: options.lossless === true,
|
|
@@ -2848,20 +2848,20 @@ function escapeAttr(value) {
|
|
|
2848
2848
|
|
|
2849
2849
|
// src/engine/render/serialize-html.ts
|
|
2850
2850
|
var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input"]);
|
|
2851
|
-
var attrsHtml = (node) =>
|
|
2851
|
+
var attrsHtml = (node) => chunkI7X7B3WD_cjs.writtenAttrs(node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
|
|
2852
2852
|
var serializeHtml = (nodes) => nodes.map(
|
|
2853
2853
|
(node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${node.html ?? serializeHtml(node.children)}</${node.tag}>`}`
|
|
2854
2854
|
).join("");
|
|
2855
2855
|
|
|
2856
2856
|
// src/engine/render/to-html.ts
|
|
2857
|
-
var toHTML = (blocks, options = {}) => serializeHtml(
|
|
2857
|
+
var toHTML = (blocks, options = {}) => serializeHtml(chunkI7X7B3WD_cjs.documentNodes(blocks, options));
|
|
2858
2858
|
|
|
2859
2859
|
// src/engine/render/to-plain-text.ts
|
|
2860
2860
|
function plainTextBlocks(blocks, schema) {
|
|
2861
|
-
return
|
|
2861
|
+
return chunkI7X7B3WD_cjs.engineBlocksOf(blocks, schema).map((block) => chunkI7X7B3WD_cjs.blockPlainText(block, schema));
|
|
2862
2862
|
}
|
|
2863
2863
|
function toPlainText(blocks, options = {}) {
|
|
2864
|
-
return plainTextBlocks(blocks, options.schema ??
|
|
2864
|
+
return plainTextBlocks(blocks, options.schema ?? chunkI7X7B3WD_cjs.createSchema()).join("\n");
|
|
2865
2865
|
}
|
|
2866
2866
|
|
|
2867
2867
|
// src/engine/model/graphemes.ts
|
|
@@ -2913,7 +2913,7 @@ function countBlock(block, schema) {
|
|
|
2913
2913
|
if (!blocks) counted.set(schema, blocks = /* @__PURE__ */ new WeakMap());
|
|
2914
2914
|
const known = blocks.get(block);
|
|
2915
2915
|
if (known) return known;
|
|
2916
|
-
const text2 =
|
|
2916
|
+
const text2 = chunkI7X7B3WD_cjs.blockPlainText(block, schema);
|
|
2917
2917
|
const stats = { characters: graphemeCount(text2), words: wordCount(text2) };
|
|
2918
2918
|
blocks.set(block, stats);
|
|
2919
2919
|
return stats;
|
|
@@ -2932,17 +2932,17 @@ function sum(blocks, schema) {
|
|
|
2932
2932
|
return { characters, words: words2 };
|
|
2933
2933
|
}
|
|
2934
2934
|
function countText(blocks, options = {}) {
|
|
2935
|
-
const schema = options.schema ?? (defaultSchema ??=
|
|
2936
|
-
return sum(
|
|
2935
|
+
const schema = options.schema ?? (defaultSchema ??= chunkI7X7B3WD_cjs.createSchema());
|
|
2936
|
+
return sum(chunkI7X7B3WD_cjs.engineBlocksOf(blocks, schema), schema);
|
|
2937
2937
|
}
|
|
2938
2938
|
function countDoc(doc, options = {}) {
|
|
2939
|
-
return sum(doc.blocks, options.schema ?? (defaultSchema ??=
|
|
2939
|
+
return sum(doc.blocks, options.schema ?? (defaultSchema ??= chunkI7X7B3WD_cjs.createSchema()));
|
|
2940
2940
|
}
|
|
2941
2941
|
|
|
2942
2942
|
// src/engine/commands/block-style.ts
|
|
2943
2943
|
function patchBlocks(state, patch, only) {
|
|
2944
2944
|
const changing = selectedBlockIds(state.doc, state.selection).filter((id) => {
|
|
2945
|
-
const block =
|
|
2945
|
+
const block = chunkI7X7B3WD_cjs.blockById(state.doc, id);
|
|
2946
2946
|
return block !== void 0 && (only === void 0 || block.type === only) && patchChangesAttrs(block.attrs, patch);
|
|
2947
2947
|
});
|
|
2948
2948
|
if (changing.length === 0) return null;
|
|
@@ -2970,7 +2970,7 @@ function setBlockColor(colors) {
|
|
|
2970
2970
|
const value = colors[key];
|
|
2971
2971
|
if (value !== void 0) patch[key] = value ?? void 0;
|
|
2972
2972
|
}
|
|
2973
|
-
const valid = Object.values(patch).every((value) => value === void 0 ||
|
|
2973
|
+
const valid = Object.values(patch).every((value) => value === void 0 || chunkI7X7B3WD_cjs.isPaletteColor(value));
|
|
2974
2974
|
return valid ? patchCommand(patch, "MARKDOWN") : () => false;
|
|
2975
2975
|
}
|
|
2976
2976
|
|
|
@@ -2990,7 +2990,7 @@ function textCaret(state) {
|
|
|
2990
2990
|
const { doc, schema, selection } = state;
|
|
2991
2991
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
|
|
2992
2992
|
const pos = selection.head;
|
|
2993
|
-
const index =
|
|
2993
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(doc, pos.block);
|
|
2994
2994
|
const block = doc.blocks[index];
|
|
2995
2995
|
const inFlow2 = isTextFlow(schema, block) && pos.region === primaryRegion(schema, block);
|
|
2996
2996
|
return inFlow2 ? { block, index, pos } : null;
|
|
@@ -2998,14 +2998,14 @@ function textCaret(state) {
|
|
|
2998
2998
|
function joinInto(tr, schema, target, source) {
|
|
2999
2999
|
const targetRegion = primaryRegion(schema, target) ?? "";
|
|
3000
3000
|
tr.step(joinBlocksStep(target.id, targetRegion, source.id, primaryRegion(schema, source) ?? ""));
|
|
3001
|
-
capIndents(tr,
|
|
3001
|
+
capIndents(tr, chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, target.id) + 1);
|
|
3002
3002
|
const offset = regionLength(target, targetRegion);
|
|
3003
3003
|
tr.setSelection(textSelection({ block: target.id, region: targetRegion, offset }));
|
|
3004
3004
|
}
|
|
3005
3005
|
function joinIntoSummary(tr, schema, summary, source) {
|
|
3006
3006
|
const region = primaryRegion(schema, summary) ?? "";
|
|
3007
3007
|
const offset = regionLength(summary, region);
|
|
3008
|
-
const index =
|
|
3008
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, source.id);
|
|
3009
3009
|
const content = source.regions[primaryRegion(schema, source) ?? ""];
|
|
3010
3010
|
if (content.length > 0) tr.step(replaceInlineStep(summary.id, region, offset, offset, content));
|
|
3011
3011
|
tr.step(removeBlocksStep(index, 1));
|
|
@@ -3077,7 +3077,7 @@ function deleteReaching(forward, reach) {
|
|
|
3077
3077
|
const { selection } = state;
|
|
3078
3078
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
|
|
3079
3079
|
const { head } = selection;
|
|
3080
|
-
const value =
|
|
3080
|
+
const value = chunkI7X7B3WD_cjs.inlineText(state.doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(state.doc, head.block)].regions[head.region]);
|
|
3081
3081
|
if (forward ? head.offset >= value.length : head.offset <= 0) {
|
|
3082
3082
|
return (forward ? deleteAtEnd : deleteAtStart)(state, dispatch);
|
|
3083
3083
|
}
|
|
@@ -3131,8 +3131,8 @@ function movedBlockIds(doc, ids) {
|
|
|
3131
3131
|
function gather(tr, runs, above) {
|
|
3132
3132
|
let anchor = above;
|
|
3133
3133
|
for (const run of runs) {
|
|
3134
|
-
const from =
|
|
3135
|
-
const at = anchor === null ? -1 :
|
|
3134
|
+
const from = chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, run[0]);
|
|
3135
|
+
const at = anchor === null ? -1 : chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, anchor);
|
|
3136
3136
|
const to = at < from ? at + 1 : at + 1 - run.length;
|
|
3137
3137
|
if (to !== from) tr.step(moveBlocksStep(from, run.length, to));
|
|
3138
3138
|
anchor = run[run.length - 1];
|
|
@@ -3160,7 +3160,7 @@ function moveBlocksTo(ids, toIndex, indent2) {
|
|
|
3160
3160
|
const first = runs[0][0];
|
|
3161
3161
|
const last = runs[runs.length - 1];
|
|
3162
3162
|
const clamped = Math.min(Math.max(indent2, 0), above ? above.indent + 1 : 0);
|
|
3163
|
-
reindent(tr,
|
|
3163
|
+
reindent(tr, chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, first), moved2.size, clamped);
|
|
3164
3164
|
if (!tr.docChanged) return false;
|
|
3165
3165
|
dispatch?.(tr.setSelection(blockRangeSelection(first, last[last.length - 1])));
|
|
3166
3166
|
return true;
|
|
@@ -3174,7 +3174,7 @@ var selectAll = (state, dispatch) => {
|
|
|
3174
3174
|
let next = blockRangeSelection(doc.blocks[0].id, doc.blocks[doc.blocks.length - 1].id);
|
|
3175
3175
|
if (selection?.kind === "text") {
|
|
3176
3176
|
const { anchor, head } = selection;
|
|
3177
|
-
const length =
|
|
3177
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(doc.blocks[chunkI7X7B3WD_cjs.requireBlockIndex(doc, head.block)].regions[head.region] ?? []);
|
|
3178
3178
|
const withinRegion = anchor.block === head.block && anchor.region === head.region;
|
|
3179
3179
|
const covers = Math.min(anchor.offset, head.offset) === 0 && Math.max(anchor.offset, head.offset) === length;
|
|
3180
3180
|
if (withinRegion && !covers) next = textSelection({ ...head, offset: 0 }, { ...head, offset: length });
|
|
@@ -3211,7 +3211,7 @@ function splitStep(schema, block, region, offset, id) {
|
|
|
3211
3211
|
// src/engine/commands/split-at.ts
|
|
3212
3212
|
function enterInHardBreakBlock({ tr, schema, block, index, pos, makeId }) {
|
|
3213
3213
|
const length = regionLength(block, pos.region);
|
|
3214
|
-
if (pos.offset === length &&
|
|
3214
|
+
if (pos.offset === length && chunkI7X7B3WD_cjs.inlineText(block.regions[pos.region]).endsWith("\n")) {
|
|
3215
3215
|
tr.step(replaceInlineStep(block.id, pos.region, length - 1, length, []));
|
|
3216
3216
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, makeId());
|
|
3217
3217
|
tr.step(insertBlocksStep(descendantsEnd(tr.doc, index), [paragraph]));
|
|
@@ -3234,7 +3234,7 @@ function insertEmptyBefore({ tr, schema, block, index, pos, makeId }) {
|
|
|
3234
3234
|
function splitToggle({ tr, schema, block, index, pos, makeId }) {
|
|
3235
3235
|
const length = regionLength(block, pos.region);
|
|
3236
3236
|
const open = block.attrs.open === true;
|
|
3237
|
-
const tail =
|
|
3237
|
+
const tail = chunkI7X7B3WD_cjs.sliceInline(block.regions[pos.region], pos.offset, length);
|
|
3238
3238
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, open ? block.indent + 1 : block.indent, makeId());
|
|
3239
3239
|
if (pos.offset < length) tr.step(replaceInlineStep(block.id, pos.region, pos.offset, length, []));
|
|
3240
3240
|
tr.step(insertBlocksStep(open ? index + 1 : descendantsEnd(tr.doc, index), [withContent(schema, empty, tail)]));
|
|
@@ -3246,7 +3246,7 @@ function splitInTwo({ tr, schema, block, pos, makeId }) {
|
|
|
3246
3246
|
tr.setSelection(textSelection({ block: tail.id, region: tail.region, offset: 0 }));
|
|
3247
3247
|
}
|
|
3248
3248
|
function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
3249
|
-
const index =
|
|
3249
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, pos.block);
|
|
3250
3250
|
const block = tr.doc.blocks[index];
|
|
3251
3251
|
if (!isTextFlow(schema, block) || pos.region !== primaryRegion(schema, block)) return false;
|
|
3252
3252
|
const target = { tr, schema, block, index, pos, makeId };
|
|
@@ -3261,13 +3261,13 @@ function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
|
3261
3261
|
|
|
3262
3262
|
// src/engine/commands/split-block.ts
|
|
3263
3263
|
function splitBlock(options = {}) {
|
|
3264
|
-
const makeId = options.newId ??
|
|
3264
|
+
const makeId = options.newId ?? chunkI7X7B3WD_cjs.newId;
|
|
3265
3265
|
return (state, dispatch) => {
|
|
3266
3266
|
const { doc, schema, selection } = state;
|
|
3267
3267
|
if (selection === null || selection.kind === "blocks") return false;
|
|
3268
3268
|
const tr = new Transaction(state).setMeta(LINE_SPLIT, true);
|
|
3269
3269
|
if (selection.kind === "node") {
|
|
3270
|
-
const index =
|
|
3270
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(doc, selection.block);
|
|
3271
3271
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, doc.blocks[index].indent, makeId());
|
|
3272
3272
|
tr.step(insertBlocksStep(descendantsEnd(doc, index), [paragraph]));
|
|
3273
3273
|
tr.setSelection(startOf(tr.doc, schema, paragraph.id));
|
|
@@ -3377,7 +3377,7 @@ function replaceEmpty(tr, schema, index, blocks) {
|
|
|
3377
3377
|
tr.setSelection(endOf(tr.doc, schema, blocks[blocks.length - 1].id));
|
|
3378
3378
|
}
|
|
3379
3379
|
function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
3380
|
-
const index =
|
|
3380
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(tr.doc, caret.block);
|
|
3381
3381
|
const current = tr.doc.blocks[index];
|
|
3382
3382
|
const { region } = caret;
|
|
3383
3383
|
const first = pieces[0];
|
|
@@ -3386,7 +3386,7 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3386
3386
|
if (pieces.length === 1 && ends.openStart && ends.openEnd && textual(first)) {
|
|
3387
3387
|
const content = contentOf(schema, first);
|
|
3388
3388
|
insertAt(tr, caret, content);
|
|
3389
|
-
tr.setSelection(textSelection({ ...caret, offset: caret.offset +
|
|
3389
|
+
tr.setSelection(textSelection({ ...caret, offset: caret.offset + chunkI7X7B3WD_cjs.inlineLength(content) }));
|
|
3390
3390
|
return;
|
|
3391
3391
|
}
|
|
3392
3392
|
const fresh = freshBlocks(pieces, current.indent, makeId);
|
|
@@ -3408,18 +3408,18 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3408
3408
|
if (atStart && !atEnd) {
|
|
3409
3409
|
if (middle.length > 0) insertCapped(tr, index, middle);
|
|
3410
3410
|
insertAt(tr, { ...caret, offset: 0 }, lastContent);
|
|
3411
|
-
tr.setSelection(textSelection({ ...caret, offset:
|
|
3411
|
+
tr.setSelection(textSelection({ ...caret, offset: chunkI7X7B3WD_cjs.inlineLength(lastContent) }));
|
|
3412
3412
|
return;
|
|
3413
3413
|
}
|
|
3414
3414
|
const firstContent = mergeFirst ? contentOf(schema, fresh[0]) : [];
|
|
3415
3415
|
insertAt(tr, caret, firstContent);
|
|
3416
|
-
const offset = caret.offset +
|
|
3416
|
+
const offset = caret.offset + chunkI7X7B3WD_cjs.inlineLength(firstContent);
|
|
3417
3417
|
const tail = !atEnd && (mergeLast || middle.length > 0) ? splitStep(schema, current, region, offset, makeId()) : null;
|
|
3418
3418
|
if (tail !== null) tr.step(tail.step);
|
|
3419
3419
|
if (middle.length > 0) insertCapped(tr, index + 1, middle);
|
|
3420
3420
|
if (tail !== null && mergeLast) {
|
|
3421
3421
|
insertAt(tr, { block: tail.tail.id, region: tail.tail.region, offset: 0 }, lastContent);
|
|
3422
|
-
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset:
|
|
3422
|
+
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: chunkI7X7B3WD_cjs.inlineLength(lastContent) }));
|
|
3423
3423
|
} else if (middle.length > 0) {
|
|
3424
3424
|
tr.setSelection(endOf(tr.doc, schema, middle[middle.length - 1].id));
|
|
3425
3425
|
} else {
|
|
@@ -3445,10 +3445,10 @@ function appendAtEnd(tr, schema, pieces, makeId) {
|
|
|
3445
3445
|
tr.setSelection(endOf(tr.doc, schema, fresh[fresh.length - 1].id));
|
|
3446
3446
|
}
|
|
3447
3447
|
function insertSlice(slice, options = {}) {
|
|
3448
|
-
const makeId = options.newId ??
|
|
3448
|
+
const makeId = options.newId ?? chunkI7X7B3WD_cjs.newId;
|
|
3449
3449
|
return (state, dispatch) => {
|
|
3450
3450
|
const { doc, schema, selection } = state;
|
|
3451
|
-
const codec =
|
|
3451
|
+
const codec = chunkI7X7B3WD_cjs.createBlockCodec(schema, { newId: makeId });
|
|
3452
3452
|
const pieces = slice.blocks.flatMap((block) => codec.toEngineBlocks(block));
|
|
3453
3453
|
if (pieces.length === 0) return false;
|
|
3454
3454
|
const tr = new Transaction(state).setOrigin("paste");
|
|
@@ -3497,9 +3497,9 @@ function fenceTransaction(state) {
|
|
|
3497
3497
|
const { selection, doc } = state;
|
|
3498
3498
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
|
|
3499
3499
|
const { block: id, region, offset } = selection.head;
|
|
3500
|
-
const block =
|
|
3500
|
+
const block = chunkI7X7B3WD_cjs.blockById(doc, id);
|
|
3501
3501
|
if (block === void 0 || !isParagraph(block) || offset !== regionLength(block, region)) return null;
|
|
3502
|
-
const fence = FENCE.exec(
|
|
3502
|
+
const fence = FENCE.exec(chunkI7X7B3WD_cjs.inlineText(block.regions[region]));
|
|
3503
3503
|
if (fence === null) return null;
|
|
3504
3504
|
return convertPrefix(state, { block: id, region, from: 0, to: offset }, setBlockType("CODE", { language: fence[1] }));
|
|
3505
3505
|
}
|
|
@@ -3566,9 +3566,9 @@ function coreExtensions(options = {}) {
|
|
|
3566
3566
|
return [
|
|
3567
3567
|
defineExtension({
|
|
3568
3568
|
name: "core",
|
|
3569
|
-
blocks:
|
|
3570
|
-
marks:
|
|
3571
|
-
atoms:
|
|
3569
|
+
blocks: chunkI7X7B3WD_cjs.coreBlockSpecs,
|
|
3570
|
+
marks: chunkI7X7B3WD_cjs.coreMarkSpecs,
|
|
3571
|
+
atoms: chunkI7X7B3WD_cjs.coreAtomSpecs,
|
|
3572
3572
|
commands: coreCommands,
|
|
3573
3573
|
pasteRules: [linkOverSelection]
|
|
3574
3574
|
}),
|
|
@@ -3585,12 +3585,12 @@ function coreExtensions(options = {}) {
|
|
|
3585
3585
|
|
|
3586
3586
|
// src/engine/clipboard/serialize-slice.ts
|
|
3587
3587
|
function sliceText(slice, options) {
|
|
3588
|
-
const schema = options.schema ??
|
|
3588
|
+
const schema = options.schema ?? chunkI7X7B3WD_cjs.createSchema();
|
|
3589
3589
|
if (slice.blocks.length === 1 && slice.openStart && slice.openEnd) {
|
|
3590
|
-
const pieces =
|
|
3590
|
+
const pieces = chunkI7X7B3WD_cjs.createBlockCodec(schema).toEngineBlocks(slice.blocks[0]);
|
|
3591
3591
|
const block = pieces.length === 1 ? stripComments(pieces[0]) : null;
|
|
3592
3592
|
const region = block === null || !isTextFlow(schema, block) ? null : primaryRegion(schema, block);
|
|
3593
|
-
if (block !== null && region !== null) return
|
|
3593
|
+
if (block !== null && region !== null) return chunkI7X7B3WD_cjs.inlinePlainText(block.regions[region] ?? [], schema);
|
|
3594
3594
|
}
|
|
3595
3595
|
const markdown = toMarkdown(slice.blocks, { schema, resolveAssetUrl: options.resolveAssetUrl, comments: false });
|
|
3596
3596
|
return markdown.replace(/\n$/, "");
|
|
@@ -3608,17 +3608,17 @@ function isFlowRegion(schema, block, region) {
|
|
|
3608
3608
|
return isTextFlow(schema, block) && region === primaryRegion(schema, block);
|
|
3609
3609
|
}
|
|
3610
3610
|
function trimmed(block, region, from, to) {
|
|
3611
|
-
return { ...block, regions: { ...block.regions, [region]:
|
|
3611
|
+
return { ...block, regions: { ...block.regions, [region]: chunkI7X7B3WD_cjs.sliceInline(block.regions[region], from, to) } };
|
|
3612
3612
|
}
|
|
3613
3613
|
function insideOneRegion(schema, block, region, from, to) {
|
|
3614
3614
|
if (isFlowRegion(schema, block, region)) return trimmed(block, region, from, to);
|
|
3615
3615
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, block.id);
|
|
3616
|
-
return withContent(schema, paragraph,
|
|
3616
|
+
return withContent(schema, paragraph, chunkI7X7B3WD_cjs.sliceInline(block.regions[region], from, to));
|
|
3617
3617
|
}
|
|
3618
3618
|
function textBlocks({ doc, schema }, selection) {
|
|
3619
3619
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
3620
|
-
const start =
|
|
3621
|
-
const end =
|
|
3620
|
+
const start = chunkI7X7B3WD_cjs.requireBlockIndex(doc, from.block);
|
|
3621
|
+
const end = chunkI7X7B3WD_cjs.requireBlockIndex(doc, to.block);
|
|
3622
3622
|
const first = doc.blocks[start];
|
|
3623
3623
|
if (start === end) {
|
|
3624
3624
|
if (from.region !== to.region) return [first];
|
|
@@ -3664,18 +3664,18 @@ var INLINE_SYNTAX = [/\*\*[^*\n]+\*\*/, /__[^_\n]+__/, /\[[^\]\n]+\]\([^)\s]+[^)
|
|
|
3664
3664
|
function looksLikeMarkdown(value) {
|
|
3665
3665
|
return value.split(/\r\n|\r|\n/).some((line2) => BLOCK_MARKERS.some((marker) => marker.test(line2))) || INLINE_SYNTAX.some((syntax) => syntax.test(value));
|
|
3666
3666
|
}
|
|
3667
|
-
function plainTextToBlocks(value, makeId =
|
|
3667
|
+
function plainTextToBlocks(value, makeId = chunkI7X7B3WD_cjs.newId) {
|
|
3668
3668
|
return value.split(/\r\n|\r|\n/).filter((line2) => line2.trim() !== "").map((line2) => ({
|
|
3669
3669
|
id: makeId(),
|
|
3670
3670
|
type: "MARKDOWN",
|
|
3671
|
-
data: { markdown:
|
|
3671
|
+
data: { markdown: chunkI7X7B3WD_cjs.serializeInline([chunkI7X7B3WD_cjs.text(line2)], { escapeLineStart: true }) }
|
|
3672
3672
|
}));
|
|
3673
3673
|
}
|
|
3674
3674
|
|
|
3675
3675
|
// src/engine/clipboard/parse-slice-json.ts
|
|
3676
3676
|
function isBlock2(value) {
|
|
3677
|
-
if (!
|
|
3678
|
-
if (!
|
|
3677
|
+
if (!chunkI7X7B3WD_cjs.isRecord(value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
|
|
3678
|
+
if (!chunkI7X7B3WD_cjs.isRecord(value.data)) return false;
|
|
3679
3679
|
return value.indent === void 0 || Number.isInteger(value.indent) && value.indent >= 0;
|
|
3680
3680
|
}
|
|
3681
3681
|
function parseSliceJSON(json) {
|
|
@@ -3685,7 +3685,7 @@ function parseSliceJSON(json) {
|
|
|
3685
3685
|
} catch {
|
|
3686
3686
|
return null;
|
|
3687
3687
|
}
|
|
3688
|
-
if (!
|
|
3688
|
+
if (!chunkI7X7B3WD_cjs.isRecord(parsed) || parsed.quoin !== 1 || !chunkI7X7B3WD_cjs.isRecord(parsed.slice)) return null;
|
|
3689
3689
|
const { blocks, openStart, openEnd } = parsed.slice;
|
|
3690
3690
|
if (!Array.isArray(blocks) || blocks.length === 0 || !blocks.every(isBlock2)) return null;
|
|
3691
3691
|
if (typeof openStart !== "boolean" || typeof openEnd !== "boolean") return null;
|
|
@@ -3693,7 +3693,7 @@ function parseSliceJSON(json) {
|
|
|
3693
3693
|
}
|
|
3694
3694
|
|
|
3695
3695
|
// src/engine/clipboard/slice-from-clipboard.ts
|
|
3696
|
-
var isParagraph2 = (block) => block.type === "MARKDOWN" &&
|
|
3696
|
+
var isParagraph2 = (block) => block.type === "MARKDOWN" && chunkI7X7B3WD_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
|
|
3697
3697
|
function openSlice(blocks, plainText2 = false) {
|
|
3698
3698
|
if (blocks.length === 0) return null;
|
|
3699
3699
|
const slice = { blocks, openStart: isParagraph2(blocks[0]), openEnd: isParagraph2(blocks[blocks.length - 1]) };
|
|
@@ -3703,14 +3703,14 @@ function linkBlocks(text2, makeId) {
|
|
|
3703
3703
|
const link = pastedLink(text2);
|
|
3704
3704
|
if (link === null) return null;
|
|
3705
3705
|
const { url, href, rest } = link;
|
|
3706
|
-
const linked2 =
|
|
3707
|
-
const markdown =
|
|
3706
|
+
const linked2 = chunkI7X7B3WD_cjs.text(url, [{ type: "link", attrs: { href } }]);
|
|
3707
|
+
const markdown = chunkI7X7B3WD_cjs.serializeInline(rest === "" ? [linked2] : [linked2, chunkI7X7B3WD_cjs.text(rest)]);
|
|
3708
3708
|
return [{ id: makeId(), type: "MARKDOWN", data: { markdown } }];
|
|
3709
3709
|
}
|
|
3710
3710
|
function textBlocks2(text2, makeId) {
|
|
3711
3711
|
const link = linkBlocks(text2, makeId);
|
|
3712
3712
|
if (link !== null) return link;
|
|
3713
|
-
return looksLikeMarkdown(text2) ?
|
|
3713
|
+
return looksLikeMarkdown(text2) ? chunkI7X7B3WD_cjs.fromMarkdown(text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
|
|
3714
3714
|
}
|
|
3715
3715
|
function htmlSlice(html, options) {
|
|
3716
3716
|
if (html === void 0) return null;
|
|
@@ -3722,7 +3722,7 @@ function sliceFromClipboard(data, options = {}) {
|
|
|
3722
3722
|
if (fromJson !== null) return fromJson;
|
|
3723
3723
|
const fromHtml = htmlSlice(data.html, options);
|
|
3724
3724
|
if (fromHtml !== null) return fromHtml;
|
|
3725
|
-
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ??
|
|
3725
|
+
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ?? chunkI7X7B3WD_cjs.newId), true);
|
|
3726
3726
|
}
|
|
3727
3727
|
|
|
3728
3728
|
// src/engine/commands/is-active.ts
|
|
@@ -3731,7 +3731,7 @@ function hasAttrs(block, attrs) {
|
|
|
3731
3731
|
}
|
|
3732
3732
|
function isActive(state, name, attrs) {
|
|
3733
3733
|
if (state.schema.marks.has(name)) return selectionHasMark(state, name, attrs);
|
|
3734
|
-
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) =>
|
|
3734
|
+
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => chunkI7X7B3WD_cjs.blockById(state.doc, id) ?? []);
|
|
3735
3735
|
const isBlockType = state.schema.blocks.has(name);
|
|
3736
3736
|
const matches = (block) => isBlockType ? block.type === name : block.type === "MARKDOWN" && block.attrs.kind === name;
|
|
3737
3737
|
return blocks.length > 0 && blocks.every((block) => matches(block) && hasAttrs(block, attrs));
|
|
@@ -3740,19 +3740,19 @@ function isActive(state, name, attrs) {
|
|
|
3740
3740
|
// src/engine/model/same-doc.ts
|
|
3741
3741
|
function sameDoc(a, b) {
|
|
3742
3742
|
if (a === b) return true;
|
|
3743
|
-
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) =>
|
|
3743
|
+
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => chunkI7X7B3WD_cjs.sameValue(block, b.blocks[i]));
|
|
3744
3744
|
}
|
|
3745
3745
|
|
|
3746
3746
|
// src/engine/extension/same-blocks.ts
|
|
3747
3747
|
function sameBlock(a, b) {
|
|
3748
|
-
return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) &&
|
|
3748
|
+
return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) && chunkI7X7B3WD_cjs.sameValue(a.data, b.data);
|
|
3749
3749
|
}
|
|
3750
3750
|
function sameBlocks(a, b) {
|
|
3751
|
-
return a === b ||
|
|
3751
|
+
return a === b || chunkI7X7B3WD_cjs.sameItems(a, b, sameBlock);
|
|
3752
3752
|
}
|
|
3753
3753
|
|
|
3754
3754
|
// src/engine/extension/structural-echo.ts
|
|
3755
|
-
var sameIds = (a, b) =>
|
|
3755
|
+
var sameIds = (a, b) => chunkI7X7B3WD_cjs.sameItems(a, b, (x, y) => x.id === y.id);
|
|
3756
3756
|
function copiedSequence(emissions, incoming) {
|
|
3757
3757
|
const verdicts = /* @__PURE__ */ new Map();
|
|
3758
3758
|
const sameAt = (block, index) => {
|
|
@@ -3933,7 +3933,7 @@ function resolveExtensions(extensions, isMac) {
|
|
|
3933
3933
|
const lowestFirst = [...extensions].sort((a, b) => priorityOf(a) - priorityOf(b));
|
|
3934
3934
|
return {
|
|
3935
3935
|
extensions: sorted,
|
|
3936
|
-
schema:
|
|
3936
|
+
schema: chunkI7X7B3WD_cjs.createSchema({
|
|
3937
3937
|
blocks: lowestFirst.flatMap((extension) => extension.blocks ?? []),
|
|
3938
3938
|
marks: lowestFirst.flatMap((extension) => extension.marks ?? []),
|
|
3939
3939
|
atoms: lowestFirst.flatMap((extension) => extension.atoms ?? [])
|
|
@@ -3957,7 +3957,7 @@ function createInternalEditor(options) {
|
|
|
3957
3957
|
const isMac = options.isMac ?? detectMac();
|
|
3958
3958
|
const resolved = resolveExtensions(options.extensions ?? coreExtensions({ newId: newId2 }), isMac);
|
|
3959
3959
|
const { schema, plugins } = resolved;
|
|
3960
|
-
const codec =
|
|
3960
|
+
const codec = chunkI7X7B3WD_cjs.createBlockCodec(schema, { newId: newId2 });
|
|
3961
3961
|
const listeners = /* @__PURE__ */ new Set();
|
|
3962
3962
|
const mounts = /* @__PURE__ */ new Set();
|
|
3963
3963
|
let state = createState({ doc: codec.docFromBlocks(options.blocks), schema, plugins, clock: options.now });
|