quoin-editor 2.0.4 → 2.1.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 +110 -0
- package/MIGRATION.md +1 -1
- package/README.md +14 -13
- package/dist/ai.cjs +124 -94
- package/dist/ai.d.cts +7 -0
- package/dist/ai.d.ts +7 -0
- package/dist/ai.js +50 -20
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +28 -26
- package/dist/catalogue.js +19 -17
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-JGEDJYIV.cjs → chunk-2FUWXPPC.cjs} +92 -98
- package/dist/{chunk-NHNW5DK3.js → chunk-3F76QQ65.js} +6 -6
- package/dist/{chunk-NHNW5DK3.js.map → chunk-3F76QQ65.js.map} +1 -1
- package/dist/{chunk-DBOZFNWU.js → chunk-3QYFAAQR.js} +3 -3
- package/dist/{chunk-DBOZFNWU.js.map → chunk-3QYFAAQR.js.map} +1 -1
- package/dist/{chunk-I7X7B3WD.cjs → chunk-4JDRDPLC.cjs} +17 -8
- package/dist/{chunk-EBSDPHPS.cjs → chunk-4UFWFV43.cjs} +1060 -719
- package/dist/{chunk-LM3DHROX.cjs → chunk-5AUIA4B3.cjs} +2 -2
- package/dist/{chunk-3INFNIGN.cjs → chunk-5H3BB5VJ.cjs} +131 -78
- package/dist/{chunk-DJU25PFC.cjs → chunk-5L2NSIHZ.cjs} +11 -11
- package/dist/{chunk-W376L2GM.js → chunk-6Y7JAWYY.js} +8 -8
- package/dist/chunk-6Y7JAWYY.js.map +1 -0
- package/dist/{chunk-UDBLZILE.js → chunk-ATKDXQEY.js} +12 -7
- package/dist/{chunk-UDBLZILE.js.map → chunk-ATKDXQEY.js.map} +1 -1
- package/dist/{chunk-A2IQHMIH.js → chunk-BE2SYPK5.js} +49 -54
- package/dist/chunk-BE2SYPK5.js.map +1 -0
- package/dist/{chunk-PURYVDC3.cjs → chunk-CFICD2JP.cjs} +21 -16
- package/dist/{chunk-3HW3WRYC.cjs → chunk-CSIUXYRU.cjs} +2 -2
- package/dist/{chunk-N7BSFDDM.cjs → chunk-DBKL524I.cjs} +23 -23
- package/dist/{chunk-XE3IYW5B.js → chunk-DEFYFIWW.js} +90 -37
- package/dist/chunk-DEFYFIWW.js.map +1 -0
- package/dist/{chunk-7E43TURF.cjs → chunk-ECI3PSMS.cjs} +7 -7
- package/dist/{chunk-4G645EYO.js → chunk-F73QEF7E.js} +5 -5
- package/dist/{chunk-4G645EYO.js.map → chunk-F73QEF7E.js.map} +1 -1
- package/dist/{chunk-KHRVCTQQ.cjs → chunk-FUT7XLMP.cjs} +61 -74
- package/dist/{chunk-7J63427U.cjs → chunk-GQSBOBOM.cjs} +375 -320
- package/dist/{chunk-LU3T3JB4.js → chunk-HPNSQWRD.js} +15 -28
- package/dist/chunk-HPNSQWRD.js.map +1 -0
- package/dist/{chunk-7Y4B7NHO.js → chunk-I34BFOLL.js} +18 -11
- package/dist/chunk-I34BFOLL.js.map +1 -0
- package/dist/{chunk-AJT54OMZ.js → chunk-IFRXEFQH.js} +9 -15
- package/dist/chunk-IFRXEFQH.js.map +1 -0
- package/dist/{chunk-YYW33WUL.cjs → chunk-K3XWVRL4.cjs} +8 -8
- package/dist/{chunk-LSI4RMTY.js → chunk-L5L6YNLT.js} +3 -3
- package/dist/{chunk-LSI4RMTY.js.map → chunk-L5L6YNLT.js.map} +1 -1
- package/dist/{chunk-2BPXVQBP.js → chunk-MO4UMXMT.js} +238 -86
- package/dist/chunk-MO4UMXMT.js.map +1 -0
- package/dist/{chunk-2QKFRKOP.cjs → chunk-N25EH2GZ.cjs} +351 -205
- package/dist/{chunk-CSPCDVCT.js → chunk-NCV2ML25.js} +3 -3
- package/dist/{chunk-CSPCDVCT.js.map → chunk-NCV2ML25.js.map} +1 -1
- package/dist/{chunk-NUQ64S5B.cjs → chunk-OJSKSQTL.cjs} +26 -26
- package/dist/chunk-PIWMU4BV.js +9 -0
- package/dist/chunk-PIWMU4BV.js.map +1 -0
- package/dist/chunk-QFGWSFOI.cjs +10 -0
- package/dist/{chunk-GPTJYWGS.js → chunk-RNBLVGWY.js} +3 -3
- package/dist/{chunk-GPTJYWGS.js.map → chunk-RNBLVGWY.js.map} +1 -1
- package/dist/{chunk-5RBMZGKV.js → chunk-TL2MJOWM.js} +325 -57
- package/dist/chunk-TL2MJOWM.js.map +1 -0
- package/dist/{chunk-YEDPBYO5.cjs → chunk-UDQ52EEC.cjs} +4 -4
- package/dist/{chunk-EIWPJWY3.js → chunk-UE2NQPNG.js} +5 -5
- package/dist/{chunk-EIWPJWY3.js.map → chunk-UE2NQPNG.js.map} +1 -1
- package/dist/{chunk-BE2YHZXA.cjs → chunk-ULV3SCYP.cjs} +26 -15
- package/dist/{chunk-WDBFGX3U.cjs → chunk-VTTMJGWP.cjs} +72 -77
- package/dist/{chunk-556PFYES.js → chunk-WK4UGDZN.js} +290 -235
- package/dist/chunk-WK4UGDZN.js.map +1 -0
- package/dist/{chunk-JZF6UQH5.cjs → chunk-WMKA37NJ.cjs} +12 -12
- package/dist/{chunk-F2ZK6Z52.js → chunk-Y26F2X4E.js} +3 -3
- package/dist/{chunk-F2ZK6Z52.js.map → chunk-Y26F2X4E.js.map} +1 -1
- package/dist/{chunk-FK7EBZPX.cjs → chunk-Z5EEDCRI.cjs} +549 -276
- package/dist/{chunk-G6NBQYMM.js → chunk-ZGFZRVQA.js} +817 -478
- package/dist/chunk-ZGFZRVQA.js.map +1 -0
- package/dist/{chunk-QLVX7MPS.js → chunk-ZQF45LA4.js} +19 -8
- package/dist/chunk-ZQF45LA4.js.map +1 -0
- package/dist/comments.cjs +127 -65
- package/dist/comments.d.cts +35 -2
- package/dist/comments.d.ts +35 -2
- package/dist/comments.js +73 -12
- package/dist/comments.js.map +1 -1
- package/dist/{diagram-extension-22x_njXB.d.ts → diagram-extension-BMlh8GCw.d.ts} +1 -1
- package/dist/{diagram-extension-C_FSkoj9.d.cts → diagram-extension-gmndUpti.d.cts} +1 -1
- package/dist/diagram.cjs +10 -9
- package/dist/diagram.d.cts +2 -2
- package/dist/diagram.d.ts +2 -2
- package/dist/diagram.js +7 -6
- package/dist/diff.cjs +25 -25
- package/dist/diff.js +3 -3
- package/dist/docx.cjs +31 -30
- package/dist/docx.js +5 -4
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +10 -9
- package/dist/embed.js +8 -7
- package/dist/{emoji-extension-Dk5IQLZf.d.cts → emoji-extension-DD9CQTQj.d.cts} +1 -1
- package/dist/{emoji-extension-C832oGeT.d.ts → emoji-extension-U_PWZ2fX.d.ts} +1 -1
- package/dist/emoji.cjs +10 -9
- package/dist/emoji.d.cts +2 -2
- package/dist/emoji.d.ts +2 -2
- package/dist/emoji.js +7 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +3 -3
- package/dist/engine.d.ts +3 -3
- package/dist/engine.js +3 -3
- package/dist/{find-extension-DmK9_N81.d.ts → find-extension-BGlqooZi.d.ts} +1 -1
- package/dist/{find-extension-BfruAPLi.d.cts → find-extension-BPnAJ8bY.d.cts} +1 -1
- package/dist/find.cjs +11 -10
- package/dist/find.d.cts +1 -1
- package/dist/find.d.ts +1 -1
- package/dist/find.js +7 -6
- package/dist/headless.cjs +70 -69
- package/dist/headless.d.cts +33 -10
- package/dist/headless.d.ts +33 -10
- package/dist/headless.js +5 -4
- package/dist/highlight.cjs +7 -6
- package/dist/highlight.js +6 -5
- package/dist/highlight.js.map +1 -1
- package/dist/{index-3fYvwqUZ.d.cts → index-DN7vRKFw.d.cts} +1 -1
- package/dist/{index-CgxnzCO5.d.ts → index-DyIYI3PM.d.ts} +1 -1
- package/dist/index.cjs +82 -81
- package/dist/index.d.cts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +6 -5
- package/dist/{labels-CiCxj2jP.d.cts → labels-BJORhN93.d.ts} +10 -5
- package/dist/{labels-BhRJYo46.d.ts → labels-CVYJ2-1X.d.cts} +10 -5
- package/dist/locale-ar.cjs +10 -0
- package/dist/locale-ar.d.cts +1 -1
- package/dist/locale-ar.d.ts +1 -1
- package/dist/locale-ar.js +10 -0
- package/dist/locale-ar.js.map +1 -1
- package/dist/locale-de.cjs +4 -0
- package/dist/locale-de.d.cts +1 -1
- package/dist/locale-de.d.ts +1 -1
- package/dist/locale-de.js +4 -0
- package/dist/locale-de.js.map +1 -1
- package/dist/locale-es.cjs +4 -0
- package/dist/locale-es.d.cts +1 -1
- package/dist/locale-es.d.ts +1 -1
- package/dist/locale-es.js +4 -0
- package/dist/locale-es.js.map +1 -1
- package/dist/locale-fr.cjs +4 -0
- package/dist/locale-fr.d.cts +1 -1
- package/dist/locale-fr.d.ts +1 -1
- package/dist/locale-fr.js +4 -0
- package/dist/locale-fr.js.map +1 -1
- package/dist/locale-ja.cjs +4 -0
- package/dist/locale-ja.d.cts +1 -1
- package/dist/locale-ja.d.ts +1 -1
- package/dist/locale-ja.js +4 -0
- package/dist/locale-ja.js.map +1 -1
- package/dist/locale-pt.cjs +4 -0
- package/dist/locale-pt.d.cts +1 -1
- package/dist/locale-pt.d.ts +1 -1
- package/dist/locale-pt.js +4 -0
- package/dist/locale-pt.js.map +1 -1
- package/dist/locale-zh.cjs +4 -0
- package/dist/locale-zh.d.cts +1 -1
- package/dist/locale-zh.d.ts +1 -1
- package/dist/locale-zh.js +4 -0
- package/dist/locale-zh.js.map +1 -1
- package/dist/math.cjs +11 -10
- package/dist/math.js +9 -8
- package/dist/mention.cjs +11 -10
- package/dist/mention.js +9 -8
- package/dist/{node-reveal-DY6bimv3.d.cts → node-reveal-Be7Xa0BL.d.cts} +1 -1
- package/dist/{node-reveal-BnFcnHhz.d.ts → node-reveal-CftIEqF_.d.ts} +1 -1
- package/dist/palette-DuIFHYHc.d.cts +10 -0
- package/dist/palette-DuIFHYHc.d.ts +10 -0
- package/dist/presence.cjs +39 -38
- package/dist/presence.js +8 -7
- package/dist/presence.js.map +1 -1
- package/dist/source.cjs +10 -9
- package/dist/source.d.cts +1 -1
- package/dist/source.d.ts +1 -1
- package/dist/source.js +6 -5
- package/dist/source.js.map +1 -1
- package/dist/{stats-extension-Dmw0Ujxe.d.ts → stats-extension-Bbpr593p.d.ts} +1 -1
- package/dist/{stats-extension-D5HySF0a.d.cts → stats-extension-D7FaeydW.d.cts} +1 -1
- package/dist/stats.cjs +12 -10
- package/dist/stats.d.cts +2 -2
- package/dist/stats.d.ts +2 -2
- package/dist/stats.js +9 -7
- package/dist/styles.css +1 -1
- package/dist/{table-extension-7LkLNK6Q.d.cts → table-extension-DNijjmxV.d.cts} +1 -1
- package/dist/{table-extension-DEpV0DnP.d.ts → table-extension-Dp6FYGPh.d.ts} +1 -1
- package/dist/table.cjs +26 -25
- package/dist/table.d.cts +4 -3
- package/dist/table.d.ts +4 -3
- package/dist/table.js +7 -6
- package/dist/{toc-extension-Dvh37bWQ.d.cts → toc-extension-BGEVAmSY.d.cts} +1 -1
- package/dist/{toc-extension-SVckrFmb.d.ts → toc-extension-DZIe40eV.d.ts} +1 -1
- package/dist/toc.cjs +10 -9
- package/dist/toc.d.cts +2 -2
- package/dist/toc.d.ts +2 -2
- package/dist/toc.js +7 -6
- package/dist/{types-DMuuDBVh.d.ts → types-Byu2a9qk.d.ts} +6 -1
- package/dist/{types-Bzhq5AXj.d.cts → types-DdDlCyyZ.d.cts} +6 -1
- 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 +4 -3
- package/dist/chunk-2BPXVQBP.js.map +0 -1
- package/dist/chunk-556PFYES.js.map +0 -1
- package/dist/chunk-5RBMZGKV.js.map +0 -1
- package/dist/chunk-7Y4B7NHO.js.map +0 -1
- package/dist/chunk-A2IQHMIH.js.map +0 -1
- package/dist/chunk-AJT54OMZ.js.map +0 -1
- package/dist/chunk-G6NBQYMM.js.map +0 -1
- package/dist/chunk-LU3T3JB4.js.map +0 -1
- package/dist/chunk-QLVX7MPS.js.map +0 -1
- package/dist/chunk-W376L2GM.js.map +0 -1
- package/dist/chunk-XE3IYW5B.js.map +0 -1
- package/dist/palette-BrX-hEd-.d.cts +0 -4
- package/dist/palette-BrX-hEd-.d.ts +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk5L2NSIHZ_cjs = require('./chunk-5L2NSIHZ.cjs');
|
|
4
|
+
var chunk4JDRDPLC_cjs = require('./chunk-4JDRDPLC.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 = chunk4JDRDPLC_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 = chunk4JDRDPLC_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) : !chunk4JDRDPLC_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: chunk4JDRDPLC_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: chunk4JDRDPLC_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(chunk4JDRDPLC_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 : chunk4JDRDPLC_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 = chunk4JDRDPLC_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: chunk4JDRDPLC_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: chunk4JDRDPLC_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: chunk4JDRDPLC_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) && chunk4JDRDPLC_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: chunk4JDRDPLC_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 (chunk4JDRDPLC_cjs.inlineText(slice) !== chunk4JDRDPLC_cjs.inlineText(chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunk4JDRDPLC_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, chunk4JDRDPLC_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: chunk4JDRDPLC_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, chunk4JDRDPLC_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) => chunk4JDRDPLC_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) => chunk4JDRDPLC_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
|
+
] : chunk5L2NSIHZ_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 = chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.inlineText(chunk4JDRDPLC_cjs.blockById(doc, block)?.regions[region] ?? []);
|
|
285
|
+
regionMap = mapTextChange(before, chunk4JDRDPLC_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 = chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunk4JDRDPLC_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, chunk4JDRDPLC_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]: chunk4JDRDPLC_cjs.sliceInline(inline, offset, chunk4JDRDPLC_cjs.inlineLength(inline)) }
|
|
343
343
|
};
|
|
344
|
-
const head = withRegion(target, region,
|
|
345
|
-
return { doc:
|
|
344
|
+
const head = withRegion(target, region, chunk4JDRDPLC_cjs.sliceInline(inline, 0, offset));
|
|
345
|
+
return { doc: chunk4JDRDPLC_cjs.replaceBlocks(doc, chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.indexOfBlock(doc, target);
|
|
358
|
+
if (chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.inlineLength(head);
|
|
361
|
+
const merged = chunk4JDRDPLC_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: chunk4JDRDPLC_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 = chunk4JDRDPLC_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) => chunk4JDRDPLC_cjs.isRecord(value) && Object.values(value).every(Array.isArray);
|
|
377
|
+
var isMark = (value) => chunk4JDRDPLC_cjs.isRecord(value) && typeof value.type === "string" && (value.attrs === void 0 || chunk4JDRDPLC_cjs.isRecord(value.attrs));
|
|
378
|
+
var isBlockShape = (value) => chunk4JDRDPLC_cjs.isRecord(value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && chunk4JDRDPLC_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 chunk4JDRDPLC_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", chunk4JDRDPLC_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 chunk4JDRDPLC_cjs.requireBlockIndex(doc, a.block) - chunk4JDRDPLC_cjs.requireBlockIndex(doc, b.block) || chunk4JDRDPLC_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) => chunk4JDRDPLC_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) && chunk4JDRDPLC_cjs.indexOfBlock(doc, selection.anchor) > chunk4JDRDPLC_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 = chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.specFor(schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
|
|
543
|
+
return region === null ? null : { block: block.id, region, offset: atEnd ? chunk4JDRDPLC_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[chunk4JDRDPLC_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 = chunk4JDRDPLC_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 = chunk4JDRDPLC_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[chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.requireBlockIndex(doc, from.block);
|
|
586
|
+
const last = chunk4JDRDPLC_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 = chunk4JDRDPLC_cjs.blockById(doc, selection.block);
|
|
606
606
|
if (block === void 0) return defaultSelection(doc, schema);
|
|
607
|
-
return
|
|
607
|
+
return chunk4JDRDPLC_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, chunk4JDRDPLC_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) => chunk4JDRDPLC_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));
|
|
@@ -722,6 +722,20 @@ function createPluginKey(name) {
|
|
|
722
722
|
return { name };
|
|
723
723
|
}
|
|
724
724
|
|
|
725
|
+
// src/engine/state/carry-selection.ts
|
|
726
|
+
function carrySelection(selection, map, before, after, origin) {
|
|
727
|
+
if (origin !== "remote" || selection.kind !== "text") return mapSelection(selection, map, before);
|
|
728
|
+
const { anchor, head } = selection;
|
|
729
|
+
const backward = isBackward(before, selection);
|
|
730
|
+
const [from, to] = backward ? [head, anchor] : [anchor, head];
|
|
731
|
+
const end = map(to, after.index.has(to.block) ? -1 : 1);
|
|
732
|
+
const mapped = isCollapsed(selection) ? end : map(from, 1);
|
|
733
|
+
const inside = after.index.has(mapped.block) && after.index.has(end.block);
|
|
734
|
+
const start = inside && comparePos(after, mapped, end) > 0 ? end : mapped;
|
|
735
|
+
if (start === from && end === to) return selection;
|
|
736
|
+
return backward ? textSelection(end, start) : textSelection(start, end);
|
|
737
|
+
}
|
|
738
|
+
|
|
725
739
|
// src/engine/state/transaction.ts
|
|
726
740
|
var foreignOrigins = ["remote", "reconcile", "history"];
|
|
727
741
|
var UNFILTERED = "unfiltered";
|
|
@@ -783,7 +797,7 @@ var Transaction = class {
|
|
|
783
797
|
step(step) {
|
|
784
798
|
const { doc, map } = step.apply(this.#currentDoc);
|
|
785
799
|
if (this.#currentSelection !== null) {
|
|
786
|
-
this.#currentSelection =
|
|
800
|
+
this.#currentSelection = carrySelection(this.#currentSelection, map, this.#currentDoc, doc, this.origin);
|
|
787
801
|
}
|
|
788
802
|
this.#docList.push(this.#currentDoc);
|
|
789
803
|
this.#stepList.push(step);
|
|
@@ -830,8 +844,8 @@ var Transaction = class {
|
|
|
830
844
|
// src/engine/commands/caret-marks.ts
|
|
831
845
|
function caretMarks(doc, schema, storedMarks, pos) {
|
|
832
846
|
if (storedMarks !== null) return storedMarks;
|
|
833
|
-
const inline =
|
|
834
|
-
return
|
|
847
|
+
const inline = chunk4JDRDPLC_cjs.blockById(doc, pos.block)?.regions[pos.region] ?? [];
|
|
848
|
+
return chunk4JDRDPLC_cjs.marksAt(inline, pos.offset, (mark) => schema.marks.get(mark.type)?.inclusive ?? true);
|
|
835
849
|
}
|
|
836
850
|
|
|
837
851
|
// src/engine/commands/run-commands.ts
|
|
@@ -894,7 +908,7 @@ function editEnd(tr) {
|
|
|
894
908
|
const { selection } = tr;
|
|
895
909
|
if (selection?.kind === "text" && isCollapsed(selection)) return selection.head;
|
|
896
910
|
const last = replacements(tr).at(-1);
|
|
897
|
-
return last === void 0 ? null : { block: last.block, region: last.region, offset: last.from +
|
|
911
|
+
return last === void 0 ? null : { block: last.block, region: last.region, offset: last.from + chunk4JDRDPLC_cjs.inlineLength(last.slice) };
|
|
898
912
|
}
|
|
899
913
|
function continuesEdit(tr, end) {
|
|
900
914
|
if (end === null || end === void 0) return true;
|
|
@@ -909,12 +923,12 @@ function mapStep(step, map, before, after) {
|
|
|
909
923
|
const { block, region, from, to, index, count: count2 } = json;
|
|
910
924
|
const ids = (doc) => [...doc.index.keys()];
|
|
911
925
|
const gap = (i, list2, next) => next.indexOf(list2[i - 1]) + 1 || NaN;
|
|
912
|
-
const content = (doc, { block: block2, region: region2, offset }, end) =>
|
|
926
|
+
const content = (doc, { block: block2, region: region2, offset }, end) => chunk4JDRDPLC_cjs.sliceInline(chunk4JDRDPLC_cjs.blockById(doc, block2)?.regions[region2] ?? [], offset, end);
|
|
913
927
|
switch (json.stepType) {
|
|
914
928
|
case "setAttrs":
|
|
915
929
|
case "setIndent": {
|
|
916
930
|
const key = json.stepType === "setAttrs" ? "attrs" : "indent";
|
|
917
|
-
return
|
|
931
|
+
return chunk4JDRDPLC_cjs.sameValue(chunk4JDRDPLC_cjs.blockById(before, block)?.[key], chunk4JDRDPLC_cjs.blockById(after, block)?.[key]) ? step : null;
|
|
918
932
|
}
|
|
919
933
|
case "joinBlocks":
|
|
920
934
|
return step;
|
|
@@ -922,12 +936,12 @@ function mapStep(step, map, before, after) {
|
|
|
922
936
|
return null;
|
|
923
937
|
case "replaceBlock": {
|
|
924
938
|
const { id } = json.block;
|
|
925
|
-
return
|
|
939
|
+
return chunk4JDRDPLC_cjs.sameValue(chunk4JDRDPLC_cjs.blockById(before, id), chunk4JDRDPLC_cjs.blockById(after, id)) ? step : null;
|
|
926
940
|
}
|
|
927
941
|
case "insertBlocks":
|
|
928
942
|
case "removeBlocks":
|
|
929
943
|
json.index = index && gap(index, ids(before), ids(after));
|
|
930
|
-
if (!
|
|
944
|
+
if (!chunk4JDRDPLC_cjs.sameValue(after.blocks.slice(json.index, json.index + count2), before.blocks.slice(index, index + count2))) {
|
|
931
945
|
return null;
|
|
932
946
|
}
|
|
933
947
|
break;
|
|
@@ -936,7 +950,7 @@ function mapStep(step, map, before, after) {
|
|
|
936
950
|
const rest = (doc) => ids(doc).filter((id) => !moved2.includes(id));
|
|
937
951
|
json.from = after.index.get(moved2[0]) ?? NaN;
|
|
938
952
|
json.to = to && gap(to, rest(before), rest(after));
|
|
939
|
-
if (!
|
|
953
|
+
if (!chunk4JDRDPLC_cjs.sameValue(ids(after).slice(json.from, json.from + count2), moved2)) return null;
|
|
940
954
|
break;
|
|
941
955
|
}
|
|
942
956
|
default: {
|
|
@@ -947,7 +961,7 @@ function mapStep(step, map, before, after) {
|
|
|
947
961
|
const end = first === last ? start : map({ block, region, offset: last }, -1);
|
|
948
962
|
const moved2 = start.block !== end.block || start.region !== end.region;
|
|
949
963
|
const origin = { block, region, offset: first };
|
|
950
|
-
const kept =
|
|
964
|
+
const kept = chunk4JDRDPLC_cjs.sameValue(content(after, start, end.offset), content(before, origin, last));
|
|
951
965
|
if (moved2 || !kept) return null;
|
|
952
966
|
Object.assign(json, start, { from: start.offset, to: end.offset });
|
|
953
967
|
}
|
|
@@ -969,22 +983,53 @@ var blocksOf = (step) => {
|
|
|
969
983
|
const { block, created, target = null, source = target } = fields(step);
|
|
970
984
|
return typeof block === "string" ? [block, created?.id ?? block] : [target, source];
|
|
971
985
|
};
|
|
972
|
-
function
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
986
|
+
function changedBlocks(before, after) {
|
|
987
|
+
const next = (doc, id) => doc.blocks[doc.index.get(id) + 1]?.id;
|
|
988
|
+
return [.../* @__PURE__ */ new Set([...before.index.keys(), ...after.index.keys()])].filter((id) => {
|
|
989
|
+
const [was, is] = [chunk4JDRDPLC_cjs.blockById(before, id), chunk4JDRDPLC_cjs.blockById(after, id)];
|
|
990
|
+
return !was || !is || !chunk4JDRDPLC_cjs.sameValue(was, is) || next(before, id) !== next(after, id);
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
function pairOf(step, inverse, rewritten) {
|
|
994
|
+
if (step.stepType === "splitBlock") {
|
|
995
|
+
const { block: block2, region: region2, created } = fields(step);
|
|
996
|
+
const side = (pos) => pos.block === block2 && pos.region === region2 ? -1 : pos.block === created.id ? 1 : 0;
|
|
997
|
+
return { recover: () => null, side };
|
|
998
|
+
}
|
|
999
|
+
if (inverse.stepType !== "replaceInline") return void 0;
|
|
1000
|
+
const { block, region, from, to } = fields(inverse);
|
|
1001
|
+
const put = fields(rewritten);
|
|
1002
|
+
const here = (pos) => pos.block === block && pos.region === region;
|
|
1003
|
+
return {
|
|
1004
|
+
recover(pos, assoc) {
|
|
979
1005
|
const at = pos.offset - (assoc < 0 ? 1 : 0);
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
985
|
-
return pos;
|
|
1006
|
+
const offset = pos.offset - from + put.from;
|
|
1007
|
+
return here(pos) && at >= from && at < to ? { block: put.block, region: put.region, offset } : null;
|
|
1008
|
+
},
|
|
1009
|
+
side: (pos) => !here(pos) ? 0 : pos.offset <= from ? -1 : pos.offset >= to ? 1 : 0
|
|
986
1010
|
};
|
|
987
|
-
|
|
1011
|
+
}
|
|
1012
|
+
var through = (links) => (pos, assoc = 1) => {
|
|
1013
|
+
for (let i = 0; i < links.length; i++) {
|
|
1014
|
+
const { map, pair, back } = links[i];
|
|
1015
|
+
if (pair && back) {
|
|
1016
|
+
const put = pair.recover(pos, assoc);
|
|
1017
|
+
const j = put ? links.indexOf(pair.ahead, i) : -1;
|
|
1018
|
+
if (j > i) {
|
|
1019
|
+
[pos, i] = [put, j];
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
pair.now = pair.side(pos);
|
|
1023
|
+
}
|
|
1024
|
+
pos = map(pos, !back && pair?.now || assoc);
|
|
1025
|
+
}
|
|
1026
|
+
return pos;
|
|
1027
|
+
};
|
|
1028
|
+
function rebaseItems(items, tr) {
|
|
1029
|
+
const kept = [];
|
|
1030
|
+
const named = tr.steps.flatMap(blocksOf);
|
|
1031
|
+
const touched = named.includes(null) ? changedBlocks(tr.before.doc, tr.doc) : named;
|
|
1032
|
+
let [before, after, change] = [tr.before.doc, tr.doc, tr.maps.map((map) => ({ map }))];
|
|
988
1033
|
items: for (const item of [...items].reverse()) {
|
|
989
1034
|
const { selection } = item;
|
|
990
1035
|
const caret = !selection ? [] : selection.kind === "node" ? [selection.block] : selection.kind === "text" ? [selection.anchor.block, selection.head.block] : [selection.anchor, selection.head];
|
|
@@ -1000,16 +1045,12 @@ function rebaseItems(items, tr) {
|
|
|
1000
1045
|
if (!original) continue items;
|
|
1001
1046
|
if (!apart) {
|
|
1002
1047
|
const inverse = step.invert(b);
|
|
1003
|
-
const
|
|
1004
|
-
back.unshift(map);
|
|
1005
|
-
if (result
|
|
1006
|
-
mirrors.set(map, [result.map, fields(inverse), fields(rewritten)]);
|
|
1007
|
-
}
|
|
1048
|
+
const pair = result ? pairOf(step, inverse, rewritten) : void 0;
|
|
1049
|
+
back.unshift({ map: inverse.apply(original.doc).map, pair, back: true });
|
|
1050
|
+
if (result) ahead.push(pair ? pair.ahead = { map: result.map, pair } : { map: result.map });
|
|
1008
1051
|
}
|
|
1009
|
-
if (result)
|
|
1010
|
-
|
|
1011
|
-
if (!apart) ahead.push(result.map);
|
|
1012
|
-
} else steps = null;
|
|
1052
|
+
if (result) [a, steps] = [result.doc, [...steps, rewritten]];
|
|
1053
|
+
else steps = null;
|
|
1013
1054
|
b = original.doc;
|
|
1014
1055
|
}
|
|
1015
1056
|
[before, after, change] = [b, steps ? a : after, [...back, ...change, ...steps ? ahead : []]];
|
|
@@ -1116,7 +1157,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
1116
1157
|
const { steps, undoText, at, marks } = record;
|
|
1117
1158
|
const tr = new Transaction(state).setMeta(UNFILTERED, true);
|
|
1118
1159
|
steps.forEach((step) => tr.step(step));
|
|
1119
|
-
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [
|
|
1160
|
+
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [chunk4JDRDPLC_cjs.text(undoText, marks)]));
|
|
1120
1161
|
dispatch(tr.setSelection(textSelection({ ...at, offset: at.offset + undoText.length })));
|
|
1121
1162
|
}
|
|
1122
1163
|
return true;
|
|
@@ -1125,7 +1166,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
1125
1166
|
// src/engine/commands/block-helpers.ts
|
|
1126
1167
|
var ITEM_KINDS = /* @__PURE__ */ new Set(["bullet", "ordered", "task", "quote"]);
|
|
1127
1168
|
function specOf(schema, block) {
|
|
1128
|
-
return
|
|
1169
|
+
return chunk4JDRDPLC_cjs.specFor(schema, block.type);
|
|
1129
1170
|
}
|
|
1130
1171
|
function isTextFlow(schema, block) {
|
|
1131
1172
|
return specOf(schema, block).flow === "text";
|
|
@@ -1137,7 +1178,7 @@ function isItem(block) {
|
|
|
1137
1178
|
return block.type === "MARKDOWN" && typeof block.attrs.kind === "string" && ITEM_KINDS.has(block.attrs.kind);
|
|
1138
1179
|
}
|
|
1139
1180
|
function regionLength(block, region) {
|
|
1140
|
-
return Object.hasOwn(block.regions, region) ?
|
|
1181
|
+
return Object.hasOwn(block.regions, region) ? chunk4JDRDPLC_cjs.inlineLength(block.regions[region]) : 0;
|
|
1141
1182
|
}
|
|
1142
1183
|
function descendantsEnd(doc, index) {
|
|
1143
1184
|
const { indent: indent2 } = doc.blocks[index];
|
|
@@ -1145,8 +1186,8 @@ function descendantsEnd(doc, index) {
|
|
|
1145
1186
|
while (end < doc.blocks.length && doc.blocks[end].indent > indent2) end++;
|
|
1146
1187
|
return end;
|
|
1147
1188
|
}
|
|
1148
|
-
function createBlock(schema, type, attrs = {}, indent2 = 0, id =
|
|
1149
|
-
const initial =
|
|
1189
|
+
function createBlock(schema, type, attrs = {}, indent2 = 0, id = chunk4JDRDPLC_cjs.newId()) {
|
|
1190
|
+
const initial = chunk4JDRDPLC_cjs.specFor(schema, type).initial();
|
|
1150
1191
|
return { id, type, indent: indent2, attrs: { ...initial.attrs, ...attrs }, regions: initial.regions };
|
|
1151
1192
|
}
|
|
1152
1193
|
function withContent(schema, block, content) {
|
|
@@ -1164,7 +1205,7 @@ function headBlockId(selection) {
|
|
|
1164
1205
|
function selectedBlockRange(doc, selection) {
|
|
1165
1206
|
const ids = selectedBlockIds(doc, selection);
|
|
1166
1207
|
if (ids.length === 0) return null;
|
|
1167
|
-
const start =
|
|
1208
|
+
const start = chunk4JDRDPLC_cjs.indexOfBlock(doc, ids[0]);
|
|
1168
1209
|
let end = start + ids.length;
|
|
1169
1210
|
for (let index = start; index < start + ids.length; index++) end = Math.max(end, descendantsEnd(doc, index));
|
|
1170
1211
|
return { start, end };
|
|
@@ -1208,7 +1249,7 @@ function shiftSubtree(tr, index, delta) {
|
|
|
1208
1249
|
// src/engine/commands/block-structure.ts
|
|
1209
1250
|
var toggleTask = (state, dispatch) => {
|
|
1210
1251
|
const { doc, selection } = state;
|
|
1211
|
-
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[
|
|
1252
|
+
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
|
|
1212
1253
|
if (tasks.length === 0) return false;
|
|
1213
1254
|
const checked = !tasks.every((block) => block.attrs.checked === true);
|
|
1214
1255
|
const tr = new Transaction(state);
|
|
@@ -1273,7 +1314,7 @@ function copiedSelection(selection, copies) {
|
|
|
1273
1314
|
}
|
|
1274
1315
|
}
|
|
1275
1316
|
function duplicateBlocks(options = {}) {
|
|
1276
|
-
const makeId = options.newId ??
|
|
1317
|
+
const makeId = options.newId ?? chunk4JDRDPLC_cjs.newId;
|
|
1277
1318
|
return (state, dispatch) => {
|
|
1278
1319
|
const { doc, selection } = state;
|
|
1279
1320
|
const range = selectedBlockRange(doc, selection);
|
|
@@ -1295,12 +1336,12 @@ var deleteBlocks = (state, dispatch) => {
|
|
|
1295
1336
|
return true;
|
|
1296
1337
|
};
|
|
1297
1338
|
function insertBlockAfter(type, attrs, options = {}) {
|
|
1298
|
-
const makeId = options.newId ??
|
|
1339
|
+
const makeId = options.newId ?? chunk4JDRDPLC_cjs.newId;
|
|
1299
1340
|
return (state, dispatch) => {
|
|
1300
1341
|
const { doc, schema } = state;
|
|
1301
1342
|
const id = headBlockId(state.selection);
|
|
1302
1343
|
if (id === null) return false;
|
|
1303
|
-
const index =
|
|
1344
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(doc, id);
|
|
1304
1345
|
const current = doc.blocks[index];
|
|
1305
1346
|
const fillsCurrent = isParagraph(current) && regionLength(current, primaryRegion(schema, current) ?? "") === 0;
|
|
1306
1347
|
const block = createBlock(schema, type, attrs, current.indent, fillsCurrent ? current.id : makeId());
|
|
@@ -1311,19 +1352,41 @@ function insertBlockAfter(type, attrs, options = {}) {
|
|
|
1311
1352
|
};
|
|
1312
1353
|
}
|
|
1313
1354
|
|
|
1355
|
+
// src/engine/blocks/table-cell.ts
|
|
1356
|
+
var CELL = /^cell:(\d+):(\d+)$/;
|
|
1357
|
+
function cellOf(region) {
|
|
1358
|
+
const match = CELL.exec(region);
|
|
1359
|
+
return match === null ? null : [Number(match[1]), Number(match[2])];
|
|
1360
|
+
}
|
|
1361
|
+
function cellsBetween(a, b) {
|
|
1362
|
+
const cells = [];
|
|
1363
|
+
for (let row = Math.min(a[0], b[0]); row <= Math.max(a[0], b[0]); row++) {
|
|
1364
|
+
for (let col = Math.min(a[1], b[1]); col <= Math.max(a[1], b[1]); col++) cells.push([row, col]);
|
|
1365
|
+
}
|
|
1366
|
+
return cells;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1314
1369
|
// src/engine/commands/delete-range.ts
|
|
1315
1370
|
function clear(tr, pos, start, end) {
|
|
1316
1371
|
if (start < end) tr.step(replaceInlineStep(pos.block, pos.region, start, end, []));
|
|
1317
1372
|
}
|
|
1373
|
+
function clearCells(tr, block, from, to) {
|
|
1374
|
+
const cells = cellsBetween(from, to).map((cell) => chunk4JDRDPLC_cjs.cellKey(...cell));
|
|
1375
|
+
for (const region of cells) clear(tr, { block: block.id, region}, 0, regionLength(block, region));
|
|
1376
|
+
return { block: block.id, region: cells[0], offset: 0 };
|
|
1377
|
+
}
|
|
1318
1378
|
function deleteWithinBlock(tr, from, to) {
|
|
1319
1379
|
if (from.region === to.region) {
|
|
1320
1380
|
clear(tr, from, from.offset, to.offset);
|
|
1321
1381
|
return from;
|
|
1322
1382
|
}
|
|
1323
|
-
const block = tr.doc.blocks[
|
|
1383
|
+
const block = tr.doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, from.block)];
|
|
1384
|
+
const first = cellOf(from.region);
|
|
1385
|
+
const last = cellOf(to.region);
|
|
1386
|
+
if (first !== null && last !== null) return clearCells(tr, block, first, last);
|
|
1324
1387
|
clear(tr, from, from.offset, regionLength(block, from.region));
|
|
1325
1388
|
for (const region of Object.keys(block.regions)) {
|
|
1326
|
-
const between =
|
|
1389
|
+
const between = chunk4JDRDPLC_cjs.compareRegionNames(from.region, region) < 0 && chunk4JDRDPLC_cjs.compareRegionNames(region, to.region) < 0;
|
|
1327
1390
|
if (between) clear(tr, { ...from, region }, 0, regionLength(block, region));
|
|
1328
1391
|
}
|
|
1329
1392
|
clear(tr, to, 0, to.offset);
|
|
@@ -1332,8 +1395,8 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1332
1395
|
function deleteRange(tr, schema, from, to, newId2) {
|
|
1333
1396
|
if (from.block === to.block) return deleteWithinBlock(tr, from, to);
|
|
1334
1397
|
const { doc } = tr;
|
|
1335
|
-
const start =
|
|
1336
|
-
const end =
|
|
1398
|
+
const start = chunk4JDRDPLC_cjs.requireBlockIndex(doc, from.block);
|
|
1399
|
+
const end = chunk4JDRDPLC_cjs.requireBlockIndex(doc, to.block);
|
|
1337
1400
|
const first = doc.blocks[start];
|
|
1338
1401
|
const last = doc.blocks[end];
|
|
1339
1402
|
const keepFirst = isTextFlow(schema, first);
|
|
@@ -1360,7 +1423,7 @@ function deleteRange(tr, schema, from, to, newId2) {
|
|
|
1360
1423
|
|
|
1361
1424
|
// src/engine/commands/insert-text-at.ts
|
|
1362
1425
|
function insertTextAt(tr, schema, pos, value) {
|
|
1363
|
-
const slice = [
|
|
1426
|
+
const slice = [chunk4JDRDPLC_cjs.text(value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
|
|
1364
1427
|
tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, slice));
|
|
1365
1428
|
return { ...pos, offset: pos.offset + value.length };
|
|
1366
1429
|
}
|
|
@@ -1372,12 +1435,12 @@ function replaceBlocksWithText(tr, schema, range, value, makeId) {
|
|
|
1372
1435
|
const indent2 = range === null ? 0 : doc.blocks[index].indent;
|
|
1373
1436
|
if (range !== null) tr.step(removeBlocksStep(index, range.end - range.start));
|
|
1374
1437
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, indent2, makeId());
|
|
1375
|
-
const paragraph = withContent(schema, empty, [
|
|
1438
|
+
const paragraph = withContent(schema, empty, [chunk4JDRDPLC_cjs.text(value)]);
|
|
1376
1439
|
tr.step(insertBlocksStep(index, [paragraph]));
|
|
1377
1440
|
tr.setSelection(endOf(tr.doc, schema, paragraph.id));
|
|
1378
1441
|
}
|
|
1379
1442
|
function insertText(value, options = {}) {
|
|
1380
|
-
const makeId = options.newId ??
|
|
1443
|
+
const makeId = options.newId ?? chunk4JDRDPLC_cjs.newId;
|
|
1381
1444
|
return (state, dispatch) => {
|
|
1382
1445
|
if (value === "") return false;
|
|
1383
1446
|
const { doc, schema, selection } = state;
|
|
@@ -1400,9 +1463,9 @@ function markExtent(inline, offset, type) {
|
|
|
1400
1463
|
let position = 0;
|
|
1401
1464
|
for (const node of inline) {
|
|
1402
1465
|
starts.push(position);
|
|
1403
|
-
position +=
|
|
1466
|
+
position += chunk4JDRDPLC_cjs.nodeLength(node);
|
|
1404
1467
|
}
|
|
1405
|
-
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] +
|
|
1468
|
+
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + chunk4JDRDPLC_cjs.nodeLength(node));
|
|
1406
1469
|
const markOf = (index) => inline[index]?.marks.find((mark2) => mark2.type === type);
|
|
1407
1470
|
let seed = containing(offset);
|
|
1408
1471
|
let mark = markOf(seed);
|
|
@@ -1411,29 +1474,33 @@ function markExtent(inline, offset, type) {
|
|
|
1411
1474
|
mark = markOf(seed);
|
|
1412
1475
|
}
|
|
1413
1476
|
if (mark === void 0) return null;
|
|
1414
|
-
const shares = (index) => inline[index].marks.some((other) =>
|
|
1477
|
+
const shares = (index) => inline[index].marks.some((other) => chunk4JDRDPLC_cjs.sameMark(other, mark));
|
|
1415
1478
|
let first = seed;
|
|
1416
1479
|
while (first > 0 && shares(first - 1)) first--;
|
|
1417
1480
|
let last = seed;
|
|
1418
1481
|
while (last < inline.length - 1 && shares(last + 1)) last++;
|
|
1419
|
-
return { from: starts[first], to: starts[last] +
|
|
1482
|
+
return { from: starts[first], to: starts[last] + chunk4JDRDPLC_cjs.nodeLength(inline[last]) };
|
|
1420
1483
|
}
|
|
1421
1484
|
|
|
1422
1485
|
// src/engine/commands/storable-mark.ts
|
|
1423
1486
|
function readsBack(inline) {
|
|
1424
|
-
|
|
1487
|
+
try {
|
|
1488
|
+
return chunk4JDRDPLC_cjs.equalInline(chunk4JDRDPLC_cjs.parseInline(chunk4JDRDPLC_cjs.serializeInline(inline)), chunk4JDRDPLC_cjs.normalizeInline(inline));
|
|
1489
|
+
} catch {
|
|
1490
|
+
return false;
|
|
1491
|
+
}
|
|
1425
1492
|
}
|
|
1426
1493
|
function safeLink(mark) {
|
|
1427
1494
|
const href = mark.attrs?.href;
|
|
1428
|
-
const safe = typeof href === "string" ?
|
|
1495
|
+
const safe = typeof href === "string" ? chunk4JDRDPLC_cjs.sanitizeHref(href) : null;
|
|
1429
1496
|
return safe ? { type: "link", attrs: { ...mark.attrs, href: safe } } : null;
|
|
1430
1497
|
}
|
|
1431
1498
|
function storableMark(mark) {
|
|
1432
1499
|
const candidate = mark.type === "link" ? safeLink(mark) : mark;
|
|
1433
|
-
return candidate !== null && readsBack([
|
|
1500
|
+
return candidate !== null && readsBack([chunk4JDRDPLC_cjs.text("a", [candidate])]) ? candidate : null;
|
|
1434
1501
|
}
|
|
1435
1502
|
function storableAtom(type, attrs) {
|
|
1436
|
-
return readsBack([
|
|
1503
|
+
return readsBack([chunk4JDRDPLC_cjs.atom(type, attrs)]);
|
|
1437
1504
|
}
|
|
1438
1505
|
|
|
1439
1506
|
// src/engine/commands/selection-marks.ts
|
|
@@ -1452,8 +1519,8 @@ function textRanges(state, selection) {
|
|
|
1452
1519
|
if (from.region !== to.region) return [];
|
|
1453
1520
|
return [{ block: from.block, region: from.region, from: from.offset, to: to.offset }];
|
|
1454
1521
|
}
|
|
1455
|
-
const first =
|
|
1456
|
-
const last =
|
|
1522
|
+
const first = chunk4JDRDPLC_cjs.requireBlockIndex(doc, from.block);
|
|
1523
|
+
const last = chunk4JDRDPLC_cjs.requireBlockIndex(doc, to.block);
|
|
1457
1524
|
return doc.blocks.slice(first, last + 1).flatMap((block, i) => {
|
|
1458
1525
|
const whole = wholeRegion(schema, block);
|
|
1459
1526
|
if (whole === null) return [];
|
|
@@ -1465,7 +1532,7 @@ function textRanges(state, selection) {
|
|
|
1465
1532
|
function selectionRanges(state, selection) {
|
|
1466
1533
|
if (selection.kind === "text") return textRanges(state, selection);
|
|
1467
1534
|
return selectedBlockIds(state.doc, selection).flatMap((id) => {
|
|
1468
|
-
const whole = wholeRegion(state.schema, state.doc.blocks[
|
|
1535
|
+
const whole = wholeRegion(state.schema, state.doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(state.doc, id)]);
|
|
1469
1536
|
return whole === null ? [] : [whole];
|
|
1470
1537
|
});
|
|
1471
1538
|
}
|
|
@@ -1474,8 +1541,8 @@ function markRanges(state) {
|
|
|
1474
1541
|
return selection === null ? [] : selectionRanges(state, selection).filter((range) => range.from < range.to);
|
|
1475
1542
|
}
|
|
1476
1543
|
function rangeContent(state, range) {
|
|
1477
|
-
const inline =
|
|
1478
|
-
return
|
|
1544
|
+
const inline = chunk4JDRDPLC_cjs.blockById(state.doc, range.block)?.regions[range.region] ?? [];
|
|
1545
|
+
return chunk4JDRDPLC_cjs.sliceInline(inline, range.from, range.to);
|
|
1479
1546
|
}
|
|
1480
1547
|
function markCoverage(content, type, attrs) {
|
|
1481
1548
|
const carries = (node) => node.marks.some((mark) => matchesMark(mark, type, attrs));
|
|
@@ -1518,8 +1585,8 @@ function applyMark(type, attrs, mode) {
|
|
|
1518
1585
|
const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
|
|
1519
1586
|
const active = current.some((existing) => matchesMark(existing, type, mark.attrs));
|
|
1520
1587
|
const remove2 = mode === "remove" || mode === "toggle" && active;
|
|
1521
|
-
const next = remove2 ?
|
|
1522
|
-
if (
|
|
1588
|
+
const next = remove2 ? chunk4JDRDPLC_cjs.removeMark(current, target) : chunk4JDRDPLC_cjs.addMark(current, mark);
|
|
1589
|
+
if (chunk4JDRDPLC_cjs.sameMarkSet(next, current)) return false;
|
|
1523
1590
|
dispatch?.(new Transaction(state).setStoredMarks(next));
|
|
1524
1591
|
return true;
|
|
1525
1592
|
}
|
|
@@ -1543,17 +1610,17 @@ function unsetMark(type) {
|
|
|
1543
1610
|
function linkRanges(state) {
|
|
1544
1611
|
const caret = collapsedCaret(state);
|
|
1545
1612
|
if (caret === null) return markRanges(state);
|
|
1546
|
-
const inline =
|
|
1613
|
+
const inline = chunk4JDRDPLC_cjs.blockById(state.doc, caret.block)?.regions[caret.region] ?? [];
|
|
1547
1614
|
const extent = markExtent(inline, caret.offset, "link");
|
|
1548
1615
|
return extent === null ? [] : [{ block: caret.block, region: caret.region, ...extent }];
|
|
1549
1616
|
}
|
|
1550
1617
|
function setLink(href, title) {
|
|
1551
|
-
const safe =
|
|
1618
|
+
const safe = chunk4JDRDPLC_cjs.sanitizeHref(href);
|
|
1552
1619
|
return (state, dispatch) => {
|
|
1553
1620
|
if (safe === null || safe === "") return false;
|
|
1554
1621
|
const link = { type: "link", attrs: title ? { href: safe, title } : { href: safe } };
|
|
1555
1622
|
return editRanges(state, dispatch, linkRanges(state), (tr, { block, region, from, to }, content) => {
|
|
1556
|
-
const linked2 = content.every((node) => node.marks.some((mark) =>
|
|
1623
|
+
const linked2 = content.every((node) => node.marks.some((mark) => chunk4JDRDPLC_cjs.sameMark(mark, link)));
|
|
1557
1624
|
if (!linked2) tr.step(addMarkStep(block, region, from, to, link));
|
|
1558
1625
|
});
|
|
1559
1626
|
};
|
|
@@ -1583,7 +1650,7 @@ function insertAtom(type, attrs) {
|
|
|
1583
1650
|
const tr = new Transaction(state);
|
|
1584
1651
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
1585
1652
|
const caret = deleteRange(tr, schema, from, to);
|
|
1586
|
-
const node =
|
|
1653
|
+
const node = chunk4JDRDPLC_cjs.atom(type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
|
|
1587
1654
|
tr.step(replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [node]));
|
|
1588
1655
|
tr.setSelection(textSelection({ ...caret, offset: caret.offset + 1 }));
|
|
1589
1656
|
dispatch?.(tr);
|
|
@@ -1601,19 +1668,19 @@ var TEXT_ATTRIBUTE = /* @__PURE__ */ new Map([
|
|
|
1601
1668
|
["MATH", "latex"]
|
|
1602
1669
|
]);
|
|
1603
1670
|
function holdsText(schema, type) {
|
|
1604
|
-
return TEXT_ATTRIBUTE.has(type) ||
|
|
1671
|
+
return TEXT_ATTRIBUTE.has(type) || chunk4JDRDPLC_cjs.specFor(schema, type).flow === "text";
|
|
1605
1672
|
}
|
|
1606
1673
|
function sourceContent(schema, block) {
|
|
1607
1674
|
const field = TEXT_ATTRIBUTE.get(block.type);
|
|
1608
1675
|
if (field !== void 0) {
|
|
1609
1676
|
const value = block.attrs[field];
|
|
1610
|
-
return typeof value === "string" && value !== "" ? [
|
|
1677
|
+
return typeof value === "string" && value !== "" ? [chunk4JDRDPLC_cjs.text(value)] : [];
|
|
1611
1678
|
}
|
|
1612
1679
|
const region = primaryRegion(schema, block);
|
|
1613
1680
|
return region === null ? [] : block.regions[region];
|
|
1614
1681
|
}
|
|
1615
1682
|
function plainText(schema, content) {
|
|
1616
|
-
return
|
|
1683
|
+
return chunk4JDRDPLC_cjs.inlineText(content, (node) => schema.atoms.get(node.type)?.plainText(node.attrs) ?? "");
|
|
1617
1684
|
}
|
|
1618
1685
|
function convert(schema, block, type, attrs) {
|
|
1619
1686
|
const content = sourceContent(schema, block);
|
|
@@ -1632,7 +1699,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1632
1699
|
if (!holdsText(schema, type)) return false;
|
|
1633
1700
|
const ids = selectedBlockIds(doc, selection);
|
|
1634
1701
|
const convertible = (block) => isTextFlow(schema, block) || selection?.kind === "node" && TEXT_ATTRIBUTE.has(block.type);
|
|
1635
|
-
const blocks = ids.flatMap((id) =>
|
|
1702
|
+
const blocks = ids.flatMap((id) => chunk4JDRDPLC_cjs.blockById(doc, id) ?? []).filter(convertible);
|
|
1636
1703
|
if (blocks.length === 0) return false;
|
|
1637
1704
|
const tr = new Transaction(state);
|
|
1638
1705
|
const moved2 = /* @__PURE__ */ new Map();
|
|
@@ -1646,7 +1713,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1646
1713
|
tr.step(replaceBlockStep(next));
|
|
1647
1714
|
const from = primaryRegion(schema, block);
|
|
1648
1715
|
const to = primaryRegion(schema, next);
|
|
1649
|
-
if (from !== null && to !== null) moved2.set(block.id, { from, to, length:
|
|
1716
|
+
if (from !== null && to !== null) moved2.set(block.id, { from, to, length: chunk4JDRDPLC_cjs.inlineLength(next.regions[to]) });
|
|
1650
1717
|
}
|
|
1651
1718
|
if (!tr.docChanged) return false;
|
|
1652
1719
|
if (selection?.kind === "text" && moved2.size > 0) {
|
|
@@ -1657,7 +1724,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1657
1724
|
};
|
|
1658
1725
|
tr.setSelection(textSelection(carry(selection.anchor), carry(selection.head)));
|
|
1659
1726
|
}
|
|
1660
|
-
const converted = selection?.kind === "node" ?
|
|
1727
|
+
const converted = selection?.kind === "node" ? chunk4JDRDPLC_cjs.blockById(tr.doc, selection.block) : void 0;
|
|
1661
1728
|
if (converted !== void 0 && isTextFlow(schema, converted)) tr.setSelection(endOf(tr.doc, schema, converted.id));
|
|
1662
1729
|
dispatch?.(tr);
|
|
1663
1730
|
return true;
|
|
@@ -1675,10 +1742,10 @@ function ruleTransaction(state, rules, context) {
|
|
|
1675
1742
|
const { selection, doc } = state;
|
|
1676
1743
|
if (selection?.kind !== "text") return null;
|
|
1677
1744
|
const { block: id, region, offset } = selection.head;
|
|
1678
|
-
const block = doc.blocks[
|
|
1745
|
+
const block = doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(doc, id)];
|
|
1679
1746
|
const inline = block.regions[region];
|
|
1680
|
-
if (
|
|
1681
|
-
const before =
|
|
1747
|
+
if (chunk4JDRDPLC_cjs.hasMark(chunk4JDRDPLC_cjs.marksAt(inline, offset, () => true), "code")) return null;
|
|
1748
|
+
const before = chunk4JDRDPLC_cjs.inlineText(chunk4JDRDPLC_cjs.sliceInline(inline, 0, offset));
|
|
1682
1749
|
for (const rule of rules) {
|
|
1683
1750
|
const match = appliesTo(rule, block) ? rule.match.exec(before) : null;
|
|
1684
1751
|
if (match === null) continue;
|
|
@@ -1688,7 +1755,7 @@ function ruleTransaction(state, rules, context) {
|
|
|
1688
1755
|
return null;
|
|
1689
1756
|
}
|
|
1690
1757
|
function insertTextWithRules(value, rules, options = {}) {
|
|
1691
|
-
const context = { newId: options.newId ??
|
|
1758
|
+
const context = { newId: options.newId ?? chunk4JDRDPLC_cjs.newId };
|
|
1692
1759
|
const insert = insertText(value, { origin: "input", newId: context.newId });
|
|
1693
1760
|
return (state, dispatch) => {
|
|
1694
1761
|
let fired = false;
|
|
@@ -1738,11 +1805,11 @@ var divider = {
|
|
|
1738
1805
|
kinds: PARAGRAPH,
|
|
1739
1806
|
handler(state, _match, range, context) {
|
|
1740
1807
|
const { doc, schema } = state;
|
|
1741
|
-
const index =
|
|
1808
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(doc, range.block);
|
|
1742
1809
|
const block = doc.blocks[index];
|
|
1743
1810
|
const content = block.regions[range.region];
|
|
1744
|
-
const tail =
|
|
1745
|
-
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ??
|
|
1811
|
+
const tail = chunk4JDRDPLC_cjs.sliceInline(content, range.to, chunk4JDRDPLC_cjs.inlineLength(content));
|
|
1812
|
+
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ?? chunk4JDRDPLC_cjs.newId)());
|
|
1746
1813
|
const next = withContent(schema, empty, tail);
|
|
1747
1814
|
const tr = new Transaction(state);
|
|
1748
1815
|
tr.step(replaceBlockStep(createBlock(schema, "DIVIDER", {}, block.indent, block.id)));
|
|
@@ -1780,7 +1847,7 @@ var blockInputRules = [
|
|
|
1780
1847
|
|
|
1781
1848
|
// src/engine/markdown/autolink-href.ts
|
|
1782
1849
|
function autolinkHref(url) {
|
|
1783
|
-
return
|
|
1850
|
+
return chunk4JDRDPLC_cjs.sanitizeHref(/^www\./i.test(url) ? `https://${url}` : url);
|
|
1784
1851
|
}
|
|
1785
1852
|
|
|
1786
1853
|
// src/engine/markdown/trim-url-end.ts
|
|
@@ -1802,12 +1869,12 @@ function trimUrlEnd(url) {
|
|
|
1802
1869
|
|
|
1803
1870
|
// src/engine/rules/region-inline.ts
|
|
1804
1871
|
function regionInline(state, range) {
|
|
1805
|
-
return state.doc.blocks[
|
|
1872
|
+
return state.doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(state.doc, range.block)].regions[range.region];
|
|
1806
1873
|
}
|
|
1807
1874
|
|
|
1808
1875
|
// src/engine/rules/touches-mark.ts
|
|
1809
1876
|
function touchesMark(inline, from, to, type) {
|
|
1810
|
-
return
|
|
1877
|
+
return chunk4JDRDPLC_cjs.sliceInline(inline, from, to).some((node) => chunk4JDRDPLC_cjs.hasMark(node.marks, type));
|
|
1811
1878
|
}
|
|
1812
1879
|
|
|
1813
1880
|
// src/engine/rules/autolink.ts
|
|
@@ -1841,7 +1908,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1841
1908
|
const contentTo = to - (close?.(found) ?? open);
|
|
1842
1909
|
const contentFrom = contentTo - found[1].length;
|
|
1843
1910
|
const from = contentFrom - open;
|
|
1844
|
-
if (wordBounded && WORD_CHARACTER.test(
|
|
1911
|
+
if (wordBounded && WORD_CHARACTER.test(chunk4JDRDPLC_cjs.inlineText(chunk4JDRDPLC_cjs.sliceInline(inline, to, to + 1)))) return null;
|
|
1845
1912
|
if (touchesMark(inline, from, contentFrom, "code") || touchesMark(inline, contentTo, to, "code")) return null;
|
|
1846
1913
|
const tr = new Transaction(state);
|
|
1847
1914
|
tr.step(addMarkStep(block, region, contentFrom, contentTo, added));
|
|
@@ -1849,7 +1916,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1849
1916
|
tr.step(replaceInlineStep(block, region, from, contentFrom, []));
|
|
1850
1917
|
const caret = { block, region, offset: from + found[1].length };
|
|
1851
1918
|
const carried = caretMarks(tr.doc, state.schema, null, caret);
|
|
1852
|
-
return tr.setSelection(textSelection(caret)).setStoredMarks(
|
|
1919
|
+
return tr.setSelection(textSelection(caret)).setStoredMarks(chunk4JDRDPLC_cjs.removeMark(carried, added.type));
|
|
1853
1920
|
}
|
|
1854
1921
|
};
|
|
1855
1922
|
}
|
|
@@ -1870,7 +1937,7 @@ var markInputRules = [
|
|
|
1870
1937
|
open: 1,
|
|
1871
1938
|
close: (match) => match[2].length + 3,
|
|
1872
1939
|
mark(match) {
|
|
1873
|
-
const href =
|
|
1940
|
+
const href = chunk4JDRDPLC_cjs.sanitizeHref(match[2]);
|
|
1874
1941
|
return href === null ? null : { type: "link", attrs: { href } };
|
|
1875
1942
|
}
|
|
1876
1943
|
}),
|
|
@@ -1888,7 +1955,7 @@ function replacing(name, match, replacement) {
|
|
|
1888
1955
|
handler(state, found, range) {
|
|
1889
1956
|
const value = typeof replacement === "string" ? replacement : replacement(found);
|
|
1890
1957
|
const from = range.to - (found[1] ?? found[0]).length;
|
|
1891
|
-
const node =
|
|
1958
|
+
const node = chunk4JDRDPLC_cjs.text(value, chunk4JDRDPLC_cjs.marksAt(regionInline(state, range), range.to, () => true));
|
|
1892
1959
|
return new Transaction(state).step(replaceInlineStep(range.block, range.region, from, range.to, [node]));
|
|
1893
1960
|
}
|
|
1894
1961
|
};
|
|
@@ -1919,6 +1986,38 @@ function typographyRules(options = {}) {
|
|
|
1919
1986
|
];
|
|
1920
1987
|
}
|
|
1921
1988
|
|
|
1989
|
+
// src/engine/clipboard/html-class-rules.ts
|
|
1990
|
+
var RULE = /([^{}]+)\{([^{}]*)\}/g;
|
|
1991
|
+
var COMMENT = /\/\*[\s\S]*?\*\/|<!--|-->/g;
|
|
1992
|
+
var CLASS_SELECTOR = /^(?:[a-z][\w-]*)?\.[a-z_][\w-]*$/i;
|
|
1993
|
+
function inlineClassRules(body) {
|
|
1994
|
+
const sheets = /* @__PURE__ */ new Map();
|
|
1995
|
+
for (const sheet of Array.from(body.ownerDocument.querySelectorAll("style"))) {
|
|
1996
|
+
for (const [, selectors, declarations] of (sheet.textContent ?? "").replace(COMMENT, "").matchAll(RULE)) {
|
|
1997
|
+
for (const selector of selectors.split(",").map((part) => part.trim())) {
|
|
1998
|
+
if (!CLASS_SELECTOR.test(selector)) continue;
|
|
1999
|
+
for (const element of Array.from(body.querySelectorAll(selector))) {
|
|
2000
|
+
sheets.set(element, `${sheets.get(element) ?? ""}${declarations};`);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
for (const [element, rules] of sheets) element.setAttribute("style", rules + (element.getAttribute("style") ?? ""));
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
// src/engine/clipboard/html-task-box.ts
|
|
2009
|
+
var BALLOT_BOX = /^([☐☑☒])\s*/;
|
|
2010
|
+
var UNCHECKED = "\u2610";
|
|
2011
|
+
var BOXABLE = /* @__PURE__ */ new Set(["paragraph", "bullet", "ordered"]);
|
|
2012
|
+
function boxedTask(attrs, content) {
|
|
2013
|
+
const box = BOXABLE.has(String(attrs.kind)) ? BALLOT_BOX.exec(chunk4JDRDPLC_cjs.inlineText(content)) : null;
|
|
2014
|
+
if (box === null) return { attrs, content };
|
|
2015
|
+
return {
|
|
2016
|
+
attrs: { kind: "task", checked: box[1] !== UNCHECKED },
|
|
2017
|
+
content: chunk4JDRDPLC_cjs.sliceInline(content, box[0].length, chunk4JDRDPLC_cjs.inlineLength(content))
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
|
|
1922
2021
|
// src/engine/clipboard/html-context.ts
|
|
1923
2022
|
var PARAGRAPH2 = { kind: "paragraph" };
|
|
1924
2023
|
var child = (ctx, patch = {}) => ({
|
|
@@ -1929,7 +2028,10 @@ var child = (ctx, patch = {}) => ({
|
|
|
1929
2028
|
function emit(sink, type, indent2, attrs, regions) {
|
|
1930
2029
|
sink.out.push({ id: sink.newId(), type, indent: indent2, attrs, regions });
|
|
1931
2030
|
}
|
|
1932
|
-
|
|
2031
|
+
function emitText(sink, indent2, attrs, content) {
|
|
2032
|
+
const task = boxedTask(attrs, content);
|
|
2033
|
+
emit(sink, "MARKDOWN", indent2, task.attrs, { text: task.content });
|
|
2034
|
+
}
|
|
1933
2035
|
|
|
1934
2036
|
// src/engine/clipboard/html-dom.ts
|
|
1935
2037
|
var ELEMENT_NODE = 1;
|
|
@@ -2107,14 +2209,14 @@ function isItalicStyle(styles) {
|
|
|
2107
2209
|
}
|
|
2108
2210
|
var PRESERVING = /* @__PURE__ */ new Set(["pre", "pre-wrap", "break-spaces"]);
|
|
2109
2211
|
var COLLAPSING = /* @__PURE__ */ new Set(["normal", "nowrap", "pre-line"]);
|
|
2110
|
-
var MONOSPACE = /\b
|
|
2212
|
+
var MONOSPACE = /\bmono\b|monospace|menlo|monaco|consol|courier/;
|
|
2111
2213
|
function keepsWhitespace(styles) {
|
|
2112
2214
|
const value = styles.get("white-space");
|
|
2113
2215
|
if (value === void 0) return null;
|
|
2114
2216
|
if (PRESERVING.has(value)) return true;
|
|
2115
2217
|
return COLLAPSING.has(value) ? false : null;
|
|
2116
2218
|
}
|
|
2117
|
-
var isMonospace = (styles) => MONOSPACE.test(styles.get("font-family") ?? "");
|
|
2219
|
+
var isMonospace = (styles) => MONOSPACE.test(styles.get("font-family") ?? styles.get("font") ?? "");
|
|
2118
2220
|
function hasDecoration(styles, line2) {
|
|
2119
2221
|
return (styles.get("text-decoration") ?? "").includes(line2) || (styles.get("text-decoration-line") ?? "").includes(line2);
|
|
2120
2222
|
}
|
|
@@ -2138,8 +2240,28 @@ function fromFunction(args) {
|
|
|
2138
2240
|
if ([r, g, b, alpha].some(Number.isNaN)) return null;
|
|
2139
2241
|
return { rgb: [r, g, b], alpha };
|
|
2140
2242
|
}
|
|
2243
|
+
var NAMED = new Map(
|
|
2244
|
+
Object.entries({
|
|
2245
|
+
black: "#000",
|
|
2246
|
+
white: "#fff",
|
|
2247
|
+
red: "#f00",
|
|
2248
|
+
lime: "#0f0",
|
|
2249
|
+
blue: "#00f",
|
|
2250
|
+
yellow: "#ff0",
|
|
2251
|
+
aqua: "#0ff",
|
|
2252
|
+
fuchsia: "#f0f",
|
|
2253
|
+
maroon: "#800000",
|
|
2254
|
+
green: "#008000",
|
|
2255
|
+
navy: "#000080",
|
|
2256
|
+
olive: "#808000",
|
|
2257
|
+
purple: "#800080",
|
|
2258
|
+
teal: "#008080",
|
|
2259
|
+
gray: "#808080",
|
|
2260
|
+
silver: "#c0c0c0"
|
|
2261
|
+
})
|
|
2262
|
+
);
|
|
2141
2263
|
function parseColor(css) {
|
|
2142
|
-
const value = css.trim();
|
|
2264
|
+
const value = NAMED.get(css.trim()) ?? css.trim();
|
|
2143
2265
|
const hex = HEX.exec(value);
|
|
2144
2266
|
const functional = FUNCTION.exec(value);
|
|
2145
2267
|
const parsed = hex ? fromHex(hex[1]) : functional ? fromFunction(functional[1]) : null;
|
|
@@ -2172,7 +2294,7 @@ function nearestPaletteColor(css, kind) {
|
|
|
2172
2294
|
const table = PALETTE_RGB[kind];
|
|
2173
2295
|
let best = "default";
|
|
2174
2296
|
let least = Infinity;
|
|
2175
|
-
for (const name of
|
|
2297
|
+
for (const name of chunk4JDRDPLC_cjs.PALETTE) {
|
|
2176
2298
|
for (const reference of table[name]) {
|
|
2177
2299
|
const gap = distance(rgb, reference);
|
|
2178
2300
|
if (gap < least) {
|
|
@@ -2186,50 +2308,55 @@ function nearestPaletteColor(css, kind) {
|
|
|
2186
2308
|
|
|
2187
2309
|
// src/engine/clipboard/html-marks.ts
|
|
2188
2310
|
function linkMark(element) {
|
|
2189
|
-
const href =
|
|
2311
|
+
const href = chunk4JDRDPLC_cjs.sanitizeHref(element.getAttribute("href") ?? "");
|
|
2190
2312
|
if (href === null || href === "") return null;
|
|
2191
2313
|
const title = element.getAttribute("title");
|
|
2192
2314
|
return { type: "link", attrs: title ? { href, title } : { href } };
|
|
2193
2315
|
}
|
|
2194
2316
|
function highlightMark(element) {
|
|
2195
2317
|
const color = element.getAttribute("data-color") ?? "";
|
|
2196
|
-
return
|
|
2318
|
+
return chunk4JDRDPLC_cjs.isPaletteColor(color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
|
|
2319
|
+
}
|
|
2320
|
+
var CODE_TAGS = /* @__PURE__ */ new Set(["code", "kbd", "tt", "samp"]);
|
|
2321
|
+
function fontAttributes(element) {
|
|
2322
|
+
return `color:${element.getAttribute("color") ?? ""};font-family:${element.getAttribute("face") ?? ""};`;
|
|
2197
2323
|
}
|
|
2198
2324
|
function elementMarks(element, inherited) {
|
|
2199
2325
|
const tag = tagName(element);
|
|
2200
|
-
const
|
|
2326
|
+
const pageStyle = isFragmentRoot(element);
|
|
2327
|
+
const styles = parseStyle((tag === "font" ? fontAttributes(element) : "") + (element.getAttribute("style") ?? ""));
|
|
2201
2328
|
let marks = inherited;
|
|
2202
2329
|
const add = (mark) => {
|
|
2203
|
-
marks =
|
|
2330
|
+
marks = chunk4JDRDPLC_cjs.addMark(marks, mark);
|
|
2204
2331
|
};
|
|
2205
2332
|
const link = tag === "a" ? linkMark(element) : null;
|
|
2206
2333
|
if (link !== null) add(link);
|
|
2207
|
-
const linked2 =
|
|
2334
|
+
const linked2 = chunk4JDRDPLC_cjs.hasMark(marks, "link");
|
|
2208
2335
|
const weight = fontWeight(styles);
|
|
2209
2336
|
if (weight !== null ? weight >= 600 : tag === "b" || tag === "strong") add({ type: "bold" });
|
|
2210
|
-
else if (weight !== null) marks =
|
|
2337
|
+
else if (weight !== null) marks = chunk4JDRDPLC_cjs.removeMark(marks, "bold");
|
|
2211
2338
|
const slanted = isItalicStyle(styles);
|
|
2212
2339
|
if (slanted ?? (tag === "i" || tag === "em")) add({ type: "italic" });
|
|
2213
|
-
else if (slanted === false) marks =
|
|
2340
|
+
else if (slanted === false) marks = chunk4JDRDPLC_cjs.removeMark(marks, "italic");
|
|
2214
2341
|
if (tag === "u" || !linked2 && hasDecoration(styles, "underline")) add({ type: "underline" });
|
|
2215
2342
|
if (tag === "s" || tag === "del" || tag === "strike" || hasDecoration(styles, "line-through")) {
|
|
2216
2343
|
add({ type: "strike" });
|
|
2217
2344
|
}
|
|
2218
|
-
if (tag
|
|
2345
|
+
if (CODE_TAGS.has(tag) || !pageStyle && isMonospace(styles)) add({ type: "code" });
|
|
2219
2346
|
const align = verticalAlign(styles);
|
|
2220
2347
|
if (tag === "sub" || align === "sub") add({ type: "sub" });
|
|
2221
2348
|
if (tag === "sup" || align === "super") add({ type: "sup" });
|
|
2222
2349
|
if (tag === "mark") add(highlightMark(element));
|
|
2223
|
-
const
|
|
2224
|
-
const color = linked2 || pageColors ? null : nearestPaletteColor(styles.get("color") ?? "", "text");
|
|
2350
|
+
const color = linked2 || pageStyle ? null : nearestPaletteColor(styles.get("color") ?? "", "text");
|
|
2225
2351
|
if (color !== null) add({ type: "color", attrs: { color } });
|
|
2226
|
-
const
|
|
2352
|
+
const fill = styles.get("background-color") ?? styles.get("background") ?? "";
|
|
2353
|
+
const background = pageStyle ? null : nearestPaletteColor(fill, "background");
|
|
2227
2354
|
if (background !== null) add({ type: "background", attrs: { color: background } });
|
|
2228
2355
|
return marks;
|
|
2229
2356
|
}
|
|
2230
2357
|
|
|
2231
2358
|
// src/engine/clipboard/hoist-spaces.ts
|
|
2232
|
-
var shared = (a, b) => a.filter((mark) => b.some((other) =>
|
|
2359
|
+
var shared = (a, b) => a.filter((mark) => b.some((other) => chunk4JDRDPLC_cjs.sameMark(mark, other)));
|
|
2233
2360
|
function hoistEdgeSpaces(pieces) {
|
|
2234
2361
|
const result = [];
|
|
2235
2362
|
pieces.forEach((piece, at) => {
|
|
@@ -2285,14 +2412,14 @@ function append(acc, raw, marks, preformatted) {
|
|
|
2285
2412
|
function finish({ pieces }) {
|
|
2286
2413
|
while (pieces.length > 0) {
|
|
2287
2414
|
const last = pieces[pieces.length - 1];
|
|
2288
|
-
const trimmed2 = last.text.replace(/[ \n]+$/, "");
|
|
2415
|
+
const trimmed2 = last.text.replace(/[ \n\u00a0]+$/, "");
|
|
2289
2416
|
if (trimmed2 === "") pieces.pop();
|
|
2290
2417
|
else {
|
|
2291
2418
|
pieces[pieces.length - 1] = { ...last, text: trimmed2 };
|
|
2292
2419
|
break;
|
|
2293
2420
|
}
|
|
2294
2421
|
}
|
|
2295
|
-
const inline =
|
|
2422
|
+
const inline = chunk4JDRDPLC_cjs.normalizeInline(hoistEdgeSpaces(pieces).map((piece) => chunk4JDRDPLC_cjs.text(piece.text, piece.marks)));
|
|
2296
2423
|
return inline.every((node) => node.kind === "text" && node.text.trim() === "") ? [] : inline;
|
|
2297
2424
|
}
|
|
2298
2425
|
function visit(acc, node, style, depth) {
|
|
@@ -2318,6 +2445,63 @@ function inlineFromNodes(nodes, style) {
|
|
|
2318
2445
|
return finish(acc);
|
|
2319
2446
|
}
|
|
2320
2447
|
|
|
2448
|
+
// src/engine/clipboard/html-font-size.ts
|
|
2449
|
+
var LENGTH = /(\d*\.?\d+)(px|pt)/;
|
|
2450
|
+
var MEDIUM_PX = 16;
|
|
2451
|
+
var LEVELS = [
|
|
2452
|
+
[1.8, 1],
|
|
2453
|
+
[1.4, 2],
|
|
2454
|
+
[1.15, 3]
|
|
2455
|
+
];
|
|
2456
|
+
function declaredSize(element) {
|
|
2457
|
+
const styles = parseStyle(element.getAttribute("style"));
|
|
2458
|
+
const length = LENGTH.exec(styles.get("font-size") ?? styles.get("font") ?? "");
|
|
2459
|
+
return length && Number(length[1]) * (length[2] === "pt" ? 4 / 3 : 1);
|
|
2460
|
+
}
|
|
2461
|
+
function sizeOf(element, known) {
|
|
2462
|
+
const chain = [];
|
|
2463
|
+
let size;
|
|
2464
|
+
for (let at = element; at !== null && size == null; at = at.parentElement) {
|
|
2465
|
+
chain.push(at);
|
|
2466
|
+
size = known.get(at) ?? declaredSize(at);
|
|
2467
|
+
}
|
|
2468
|
+
const resolved = size ?? MEDIUM_PX;
|
|
2469
|
+
for (const at of chain) known.set(at, resolved);
|
|
2470
|
+
return resolved;
|
|
2471
|
+
}
|
|
2472
|
+
function eachText(root, visit2) {
|
|
2473
|
+
const pending = [root];
|
|
2474
|
+
for (let node = pending.pop(); node !== void 0; node = pending.pop()) {
|
|
2475
|
+
if (node.nodeType === TEXT_NODE) visit2(node.nodeValue ?? "", node.parentElement ?? root);
|
|
2476
|
+
else if (isElement(node) && !isDropped(node) && !isMsoIgnored(node)) {
|
|
2477
|
+
for (let part = node.lastChild; part !== null; part = part.previousSibling) pending.push(part);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
function bodySize(body, known) {
|
|
2482
|
+
const weights = /* @__PURE__ */ new Map([[MEDIUM_PX, 0]]);
|
|
2483
|
+
eachText(body, (text2, parent) => {
|
|
2484
|
+
const weight = text2.replace(/\s/g, "").length;
|
|
2485
|
+
if (weight === 0) return;
|
|
2486
|
+
const size = sizeOf(parent, known);
|
|
2487
|
+
weights.set(size, (weights.get(size) ?? 0) + weight);
|
|
2488
|
+
});
|
|
2489
|
+
return [...weights].reduce((most, entry) => entry[1] > most[1] ? entry : most)[0];
|
|
2490
|
+
}
|
|
2491
|
+
function sizedHeading(root) {
|
|
2492
|
+
const known = /* @__PURE__ */ new Map();
|
|
2493
|
+
let base;
|
|
2494
|
+
return (paragraph) => {
|
|
2495
|
+
let least = Infinity;
|
|
2496
|
+
eachText(paragraph, (text2, parent) => {
|
|
2497
|
+
if (/\S/.test(text2)) least = Math.min(least, sizeOf(parent, known));
|
|
2498
|
+
});
|
|
2499
|
+
if (least === Infinity) return null;
|
|
2500
|
+
const body = base ??= bodySize(root, known);
|
|
2501
|
+
return LEVELS.find(([ratio]) => least >= body * ratio)?.[1] ?? null;
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2321
2505
|
// src/engine/clipboard/html-lists.ts
|
|
2322
2506
|
var LIST_TAGS = /* @__PURE__ */ new Set(["ul", "ol"]);
|
|
2323
2507
|
var MARKER_NUMBER = /^(\d+)[.)]$/;
|
|
@@ -2328,7 +2512,9 @@ function checkboxState(node) {
|
|
|
2328
2512
|
return node.hasAttribute("checked");
|
|
2329
2513
|
}
|
|
2330
2514
|
if (hasClass(node, "checkbox-on")) return true;
|
|
2331
|
-
|
|
2515
|
+
if (hasClass(node, "checkbox-off")) return false;
|
|
2516
|
+
const box = node.getAttribute("role") === "checkbox" || node.getAttribute("aria-roledescription") === "checkbox";
|
|
2517
|
+
return box ? node.getAttribute("aria-checked") === "true" : null;
|
|
2332
2518
|
}
|
|
2333
2519
|
function takeCheckbox(nodes) {
|
|
2334
2520
|
const at = nodes.findIndex((node) => checkboxState(node) !== null);
|
|
@@ -2336,20 +2522,26 @@ function takeCheckbox(nodes) {
|
|
|
2336
2522
|
return { checked: checkboxState(nodes[at]), rest: nodes.filter((_, index) => index !== at) };
|
|
2337
2523
|
}
|
|
2338
2524
|
var isPlainWrapper = (node) => isElement(node) && ["p", "div"].includes(tagName(node)) && !hasBlockDescendant(node);
|
|
2525
|
+
var WORD_LEVELS = 9;
|
|
2526
|
+
function depthOf(item) {
|
|
2527
|
+
const level = Math.trunc(Number(item.getAttribute("data-aria-level"))) || 1;
|
|
2528
|
+
return Math.min(WORD_LEVELS, Math.max(1, level)) - 1;
|
|
2529
|
+
}
|
|
2339
2530
|
function listItem(item, base, ctx, sink) {
|
|
2340
2531
|
const own = takeCheckbox(Array.from(item.childNodes));
|
|
2341
2532
|
const split = own.rest.findIndex(breaksRun);
|
|
2342
2533
|
let content = inlineFromNodes(split < 0 ? own.rest : own.rest.slice(0, split), ctx);
|
|
2343
2534
|
let rest = split < 0 ? [] : own.rest.slice(split);
|
|
2344
|
-
let checked = own.checked;
|
|
2535
|
+
let checked = checkboxState(item) ?? own.checked;
|
|
2345
2536
|
if (content.length === 0 && rest.length > 0 && isPlainWrapper(rest[0])) {
|
|
2346
2537
|
const inner = takeCheckbox(Array.from(rest[0].childNodes));
|
|
2347
2538
|
checked = checked ?? inner.checked;
|
|
2348
2539
|
content = inlineFromNodes(inner.rest, ctx);
|
|
2349
2540
|
rest = rest.slice(1);
|
|
2350
2541
|
}
|
|
2351
|
-
|
|
2352
|
-
sink
|
|
2542
|
+
const indent2 = ctx.indent + depthOf(item);
|
|
2543
|
+
emitText(sink, indent2, checked === null ? base : { kind: "task", checked }, content);
|
|
2544
|
+
sink.walk(rest, child(ctx, { indent: indent2 + 1, run: PARAGRAPH2 }));
|
|
2353
2545
|
}
|
|
2354
2546
|
function firstNumber(list2) {
|
|
2355
2547
|
const start = Number.parseInt(list2.getAttribute("start") ?? "", 10);
|
|
@@ -2389,7 +2581,7 @@ function wordListItem(paragraph, ctx, sink) {
|
|
|
2389
2581
|
|
|
2390
2582
|
// src/engine/clipboard/html-media.ts
|
|
2391
2583
|
function imageBlock(img, caption, ctx, sink) {
|
|
2392
|
-
const url =
|
|
2584
|
+
const url = chunk4JDRDPLC_cjs.sanitizeHref(img.getAttribute("src") ?? "");
|
|
2393
2585
|
if (url === null || url === "") return;
|
|
2394
2586
|
emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: img.getAttribute("alt") ?? "", url }, { caption });
|
|
2395
2587
|
}
|
|
@@ -2405,6 +2597,7 @@ function figure(element, ctx, sink) {
|
|
|
2405
2597
|
|
|
2406
2598
|
// src/engine/clipboard/html-table.ts
|
|
2407
2599
|
var SECTIONS = /* @__PURE__ */ new Set(["thead", "tbody", "tfoot"]);
|
|
2600
|
+
var MAX_SPAN = 1e3;
|
|
2408
2601
|
function rowOf(tr, head) {
|
|
2409
2602
|
return { cells: Array.from(tr.children).filter((cell) => ["td", "th"].includes(tagName(cell))), head };
|
|
2410
2603
|
}
|
|
@@ -2419,15 +2612,33 @@ function tableRows(table) {
|
|
|
2419
2612
|
}
|
|
2420
2613
|
return rows;
|
|
2421
2614
|
}
|
|
2615
|
+
var span = (cell, name) => Math.min(MAX_SPAN, Math.max(1, Number.parseInt(cell.getAttribute(name) ?? "", 10) || 1));
|
|
2616
|
+
function grid(rows) {
|
|
2617
|
+
const slots = rows.map(() => []);
|
|
2618
|
+
rows.forEach(({ cells }, r) => {
|
|
2619
|
+
let c = 0;
|
|
2620
|
+
for (const cell of cells) {
|
|
2621
|
+
while (slots[r][c] !== void 0) c++;
|
|
2622
|
+
const across = span(cell, "colspan");
|
|
2623
|
+
const down = Math.min(span(cell, "rowspan"), rows.length - r);
|
|
2624
|
+
for (let dr = 0; dr < down; dr++) {
|
|
2625
|
+
for (let dc = 0; dc < across; dc++) slots[r + dr][c + dc] = dr === 0 && dc === 0 ? cell : null;
|
|
2626
|
+
}
|
|
2627
|
+
c += across;
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
return slots;
|
|
2631
|
+
}
|
|
2422
2632
|
function tableBlock(table, ctx, sink) {
|
|
2423
2633
|
const rows = tableRows(table);
|
|
2424
|
-
const
|
|
2634
|
+
const slots = grid(rows);
|
|
2635
|
+
const cols = slots.reduce((widest, row) => Math.max(widest, row.length), 0);
|
|
2425
2636
|
if (rows.length === 0 || cols === 0) return;
|
|
2426
2637
|
const regions = {};
|
|
2427
|
-
|
|
2638
|
+
slots.forEach((row, r) => {
|
|
2428
2639
|
for (let c = 0; c < cols; c++) {
|
|
2429
|
-
const cell = row
|
|
2430
|
-
regions[
|
|
2640
|
+
const cell = row[c];
|
|
2641
|
+
regions[chunk4JDRDPLC_cjs.cellKey(r, c)] = cell ? inlineFromNodes(cell.childNodes, ctx) : [];
|
|
2431
2642
|
}
|
|
2432
2643
|
});
|
|
2433
2644
|
const header = rows[0].head || rows[0].cells.some((cell) => tagName(cell) === "th");
|
|
@@ -2440,7 +2651,7 @@ var HEADING = /^h([1-6])$/;
|
|
|
2440
2651
|
function emitRun(run, ctx, sink) {
|
|
2441
2652
|
const inline = inlineFromNodes(run, ctx);
|
|
2442
2653
|
if (inline.length === 0) return;
|
|
2443
|
-
const plain = ctx.run.kind === "heading" ?
|
|
2654
|
+
const plain = ctx.run.kind === "heading" ? chunk4JDRDPLC_cjs.removeMarkRange(inline, 0, chunk4JDRDPLC_cjs.inlineLength(inline), "bold") : inline;
|
|
2444
2655
|
emitText(sink, ctx.indent, ctx.run, plain);
|
|
2445
2656
|
}
|
|
2446
2657
|
function details(element, ctx, sink) {
|
|
@@ -2457,12 +2668,27 @@ function styledContext(element, outer) {
|
|
|
2457
2668
|
const ctx = { ...outer, marks, preformatted: keeps ?? outer.preformatted };
|
|
2458
2669
|
return { ctx, code: keeps === true && isMonospace(styles) };
|
|
2459
2670
|
}
|
|
2671
|
+
function isBold(element, ctx) {
|
|
2672
|
+
const inline = inlineFromNodes(element.childNodes, ctx);
|
|
2673
|
+
return chunk4JDRDPLC_cjs.rangeHasMark(inline, 0, chunk4JDRDPLC_cjs.inlineLength(inline), "bold");
|
|
2674
|
+
}
|
|
2675
|
+
function headingLevel(element, tag, ctx, sink) {
|
|
2676
|
+
const named = HEADING.exec(tag);
|
|
2677
|
+
if (named) return Number(named[1]);
|
|
2678
|
+
if (element.getAttribute("role") === "heading") {
|
|
2679
|
+
return Math.min(6, Math.max(1, Math.trunc(Number(element.getAttribute("aria-level"))) || 2));
|
|
2680
|
+
}
|
|
2681
|
+
const paragraph = (tag === "p" || tag === "div") && ctx.run.kind === "paragraph" && !hasBlockDescendant(element);
|
|
2682
|
+
const level = paragraph ? sink.sizedHeading(element) : null;
|
|
2683
|
+
return level === 1 || level !== null && isBold(element, ctx) ? level : null;
|
|
2684
|
+
}
|
|
2460
2685
|
function handleBlock(element, outer, sink) {
|
|
2461
2686
|
const { ctx, code } = styledContext(element, outer);
|
|
2462
2687
|
const tag = tagName(element);
|
|
2463
2688
|
if (code && tag === "div") return codeBlock(element, ctx, sink);
|
|
2464
|
-
|
|
2465
|
-
|
|
2689
|
+
if (tag === "p" && wordListItem(element, ctx, sink)) return;
|
|
2690
|
+
const level = headingLevel(element, tag, ctx, sink);
|
|
2691
|
+
if (level !== null) return sink.walk(element.childNodes, child(ctx, { run: { kind: "heading", level } }));
|
|
2466
2692
|
switch (tag) {
|
|
2467
2693
|
case "ul":
|
|
2468
2694
|
case "ol":
|
|
@@ -2485,8 +2711,6 @@ function handleBlock(element, outer, sink) {
|
|
|
2485
2711
|
return figure(element, ctx, sink);
|
|
2486
2712
|
case "details":
|
|
2487
2713
|
return details(element, ctx, sink);
|
|
2488
|
-
case "p":
|
|
2489
|
-
if (wordListItem(element, ctx, sink)) return;
|
|
2490
2714
|
}
|
|
2491
2715
|
sink.walk(element.childNodes, child(ctx));
|
|
2492
2716
|
}
|
|
@@ -2512,7 +2736,13 @@ function walkNodes(nodes, ctx, sink) {
|
|
|
2512
2736
|
flush();
|
|
2513
2737
|
}
|
|
2514
2738
|
function blocksFromBody(body, newId2) {
|
|
2515
|
-
|
|
2739
|
+
inlineClassRules(body);
|
|
2740
|
+
const sink = {
|
|
2741
|
+
out: [],
|
|
2742
|
+
newId: newId2,
|
|
2743
|
+
sizedHeading: sizedHeading(body),
|
|
2744
|
+
walk: (nodes, ctx) => walkNodes(nodes, ctx, sink)
|
|
2745
|
+
};
|
|
2516
2746
|
sink.walk(body.childNodes, { indent: 0, marks: [], run: PARAGRAPH2, preformatted: false, depth: 0 });
|
|
2517
2747
|
return sink.out;
|
|
2518
2748
|
}
|
|
@@ -2525,8 +2755,8 @@ function availableParser(parser) {
|
|
|
2525
2755
|
function fromHTML(html, options = {}) {
|
|
2526
2756
|
const parser = availableParser(options.parser);
|
|
2527
2757
|
if (parser === null) throw new Error("fromHTML needs a DOMParser");
|
|
2528
|
-
const makeId = options.newId ??
|
|
2529
|
-
const codec =
|
|
2758
|
+
const makeId = options.newId ?? chunk4JDRDPLC_cjs.newId;
|
|
2759
|
+
const codec = chunk4JDRDPLC_cjs.createBlockCodec(chunk4JDRDPLC_cjs.createSchema(), { newId: makeId });
|
|
2530
2760
|
const { body } = parser.parseFromString(html, "text/html");
|
|
2531
2761
|
return blocksFromBody(body, makeId).map((block) => codec.toQuoin(block));
|
|
2532
2762
|
}
|
|
@@ -2547,7 +2777,7 @@ function quoteLines(text2) {
|
|
|
2547
2777
|
|
|
2548
2778
|
// src/engine/markdown/document/block-forms.ts
|
|
2549
2779
|
var ALERT_NAMES = new Map(
|
|
2550
|
-
Object.entries(
|
|
2780
|
+
Object.entries(chunk4JDRDPLC_cjs.ALERT_TONES).map(([name, tone]) => [tone, name])
|
|
2551
2781
|
);
|
|
2552
2782
|
var DELIMITERS = /* @__PURE__ */ new Map([
|
|
2553
2783
|
["left", ":--"],
|
|
@@ -2557,8 +2787,8 @@ var DELIMITERS = /* @__PURE__ */ new Map([
|
|
|
2557
2787
|
var MIN_FENCE = 3;
|
|
2558
2788
|
var FENCE_LIKE_MATH_LINE = /^ {0,3}\${2,}[ \t]*$/m;
|
|
2559
2789
|
function calloutMarkdown(data) {
|
|
2560
|
-
const name = ALERT_NAMES.get(
|
|
2561
|
-
const body =
|
|
2790
|
+
const name = ALERT_NAMES.get(chunk4JDRDPLC_cjs.str(data.tone)) ?? "NOTE";
|
|
2791
|
+
const body = chunk4JDRDPLC_cjs.str(data.body);
|
|
2562
2792
|
return quoteLines(body === "" ? `[!${name}]` : `[!${name}]
|
|
2563
2793
|
${/^.*\|/.test(body) ? "\n" : ""}${body}`);
|
|
2564
2794
|
}
|
|
@@ -2572,18 +2802,18 @@ function longestRun(value, char) {
|
|
|
2572
2802
|
return longest;
|
|
2573
2803
|
}
|
|
2574
2804
|
function codeMarkdown(data) {
|
|
2575
|
-
const code =
|
|
2576
|
-
const info =
|
|
2805
|
+
const code = chunk4JDRDPLC_cjs.str(data.code);
|
|
2806
|
+
const info = chunk4JDRDPLC_cjs.str(data.language);
|
|
2577
2807
|
const char = info.includes("`") ? "~" : "`";
|
|
2578
2808
|
const fence = char.repeat(Math.max(MIN_FENCE, longestRun(code, char) + 1));
|
|
2579
2809
|
return [fence + info.replace(/[\\&]/g, "\\$&"), ...code === "" ? [] : code.split("\n"), fence].join("\n");
|
|
2580
2810
|
}
|
|
2581
2811
|
function mathMarkdown(data) {
|
|
2582
|
-
const latex =
|
|
2812
|
+
const latex = chunk4JDRDPLC_cjs.str(data.latex);
|
|
2583
2813
|
if (FENCE_LIKE_MATH_LINE.test(latex)) return null;
|
|
2584
2814
|
return ["$$", ...latex === "" ? [] : latex.split("\n"), "$$"].join("\n");
|
|
2585
2815
|
}
|
|
2586
|
-
var cellsOf = (row) => Array.isArray(row) ? row.map(
|
|
2816
|
+
var cellsOf = (row) => Array.isArray(row) ? row.map(chunk4JDRDPLC_cjs.str) : [];
|
|
2587
2817
|
var rowMarkdown = (cells) => `| ${cells.join(" | ")} |`;
|
|
2588
2818
|
function tableMarkdown(data) {
|
|
2589
2819
|
const rows = Array.isArray(data.rows) ? data.rows.map(cellsOf) : [];
|
|
@@ -2610,7 +2840,7 @@ function needsComment(block, residual, schema, ctx) {
|
|
|
2610
2840
|
const native = NATIVE_KEYS.get(block.type);
|
|
2611
2841
|
if (!native) return false;
|
|
2612
2842
|
if (residual > 0) return true;
|
|
2613
|
-
return Object.keys(
|
|
2843
|
+
return Object.keys(chunk4JDRDPLC_cjs.specFor(schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
|
|
2614
2844
|
}
|
|
2615
2845
|
|
|
2616
2846
|
// src/engine/markdown/document/comment-markdown.ts
|
|
@@ -2624,41 +2854,41 @@ function quoinComment(type, data, indent2) {
|
|
|
2624
2854
|
// src/engine/markdown/document/link-forms.ts
|
|
2625
2855
|
var oneLine = (value) => value.replace(/[\r\n]+/g, " ");
|
|
2626
2856
|
function linked(label, href, ctx) {
|
|
2627
|
-
return ctx.inline.serialize([
|
|
2857
|
+
return ctx.inline.serialize([chunk4JDRDPLC_cjs.text(label || href, [{ type: "link", attrs: { href } }])]);
|
|
2628
2858
|
}
|
|
2629
2859
|
var assetUrl = (storageKey, ctx) => storageKey === "" ? "" : ctx.resolveAssetUrl(storageKey);
|
|
2630
2860
|
function imageMarkdown(data, ctx) {
|
|
2631
|
-
const href =
|
|
2861
|
+
const href = chunk4JDRDPLC_cjs.str(data.url) || assetUrl(chunk4JDRDPLC_cjs.str(data.storageKey), ctx);
|
|
2632
2862
|
if (href === "") return null;
|
|
2633
|
-
const caption =
|
|
2634
|
-
const alt = ctx.inline.serialize([
|
|
2635
|
-
return `![${alt}${
|
|
2863
|
+
const caption = chunk4JDRDPLC_cjs.str(data.caption);
|
|
2864
|
+
const alt = ctx.inline.serialize([chunk4JDRDPLC_cjs.text(oneLine(chunk4JDRDPLC_cjs.str(data.alt)))]);
|
|
2865
|
+
return `![${alt}${chunk4JDRDPLC_cjs.linkClose({ type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
|
|
2636
2866
|
}
|
|
2637
2867
|
function fileMarkdown(data, ctx) {
|
|
2638
|
-
const href = assetUrl(
|
|
2639
|
-
return href === "" ? null : linked(oneLine(
|
|
2868
|
+
const href = assetUrl(chunk4JDRDPLC_cjs.str(data.storageKey), ctx);
|
|
2869
|
+
return href === "" ? null : linked(oneLine(chunk4JDRDPLC_cjs.str(data.filename)), href, ctx);
|
|
2640
2870
|
}
|
|
2641
2871
|
function embedMarkdown(data, ctx) {
|
|
2642
|
-
const url =
|
|
2872
|
+
const url = chunk4JDRDPLC_cjs.str(data.url);
|
|
2643
2873
|
return url === "" ? null : linked(url, url, ctx);
|
|
2644
2874
|
}
|
|
2645
2875
|
function bookmarkMarkdown(data, ctx) {
|
|
2646
|
-
const url =
|
|
2647
|
-
return url === "" ? null : linked(oneLine(
|
|
2876
|
+
const url = chunk4JDRDPLC_cjs.str(data.url);
|
|
2877
|
+
return url === "" ? null : linked(oneLine(chunk4JDRDPLC_cjs.str(data.title)), url, ctx);
|
|
2648
2878
|
}
|
|
2649
2879
|
|
|
2650
2880
|
// src/engine/markdown/document/block-markdown.ts
|
|
2651
2881
|
var QUOTE_PREFIX = "> ";
|
|
2652
2882
|
function markdownLine(block, data) {
|
|
2653
2883
|
const kind = block.attrs.kind ?? "paragraph";
|
|
2654
|
-
const markdown =
|
|
2655
|
-
const empty =
|
|
2884
|
+
const markdown = chunk4JDRDPLC_cjs.str(data.markdown);
|
|
2885
|
+
const empty = chunk4JDRDPLC_cjs.inlineLength(block.regions.text ?? []) === 0;
|
|
2656
2886
|
if (empty && (kind === "paragraph" || kind === "quote")) return null;
|
|
2657
2887
|
return kind === "quote" ? quoteLines(markdown.slice(QUOTE_PREFIX.length)) : markdown;
|
|
2658
2888
|
}
|
|
2659
2889
|
function toggleMarkdown(data) {
|
|
2660
2890
|
return `<details${data.open === true ? " open" : ""}>
|
|
2661
|
-
<summary>${
|
|
2891
|
+
<summary>${chunk4JDRDPLC_cjs.str(data.markdown)}</summary>`;
|
|
2662
2892
|
}
|
|
2663
2893
|
function coreMarkdown(block, data, env, residual) {
|
|
2664
2894
|
switch (block.type) {
|
|
@@ -2691,9 +2921,9 @@ function coreMarkdown(block, data, env, residual) {
|
|
|
2691
2921
|
}
|
|
2692
2922
|
}
|
|
2693
2923
|
function blockMarkdown(block, env, { residual, asComment }) {
|
|
2694
|
-
const spec =
|
|
2924
|
+
const spec = chunk4JDRDPLC_cjs.specFor(env.schema, block.type);
|
|
2695
2925
|
const data = spec.toData(block, env.ctx);
|
|
2696
|
-
const comment = () =>
|
|
2926
|
+
const comment = () => chunk4JDRDPLC_cjs.isQuoinType(block.type) ? quoinComment(block.type, data, residual) : null;
|
|
2697
2927
|
if (asComment || env.lossless && !hasNativeForm(block.type)) return comment();
|
|
2698
2928
|
const written = spec.toMarkdown ? spec.toMarkdown(block, env.ctx) : coreMarkdown(block, data, env, residual);
|
|
2699
2929
|
if (written !== null) return written;
|
|
@@ -2723,7 +2953,7 @@ function createListContext() {
|
|
|
2723
2953
|
let placed = block;
|
|
2724
2954
|
let number = 1;
|
|
2725
2955
|
if (line2 === "ordered") {
|
|
2726
|
-
number = Math.min(runs.get(block.indent) ??
|
|
2956
|
+
number = Math.min(runs.get(block.indent) ?? chunk4JDRDPLC_cjs.orderedStart(block.attrs.start), chunk4JDRDPLC_cjs.MAX_MARKER_NUMBER);
|
|
2727
2957
|
runs.set(block.indent, number + 1);
|
|
2728
2958
|
if (number !== block.attrs.start) placed = { ...block, attrs: { ...block.attrs, start: number } };
|
|
2729
2959
|
} else {
|
|
@@ -2733,7 +2963,7 @@ function createListContext() {
|
|
|
2733
2963
|
const hang = isItem2 ? (line2 === "ordered" ? String(number).length : 0) + 2 : 0;
|
|
2734
2964
|
const container = comment ? void 0 : openedBy(block, prefix, hang);
|
|
2735
2965
|
if (container) stack.push(container);
|
|
2736
|
-
const bare = !comment && (line2 === "bullet" || line2 === "ordered") &&
|
|
2966
|
+
const bare = !comment && (line2 === "bullet" || line2 === "ordered") && chunk4JDRDPLC_cjs.inlineLength(block.regions.text ?? []) === 0;
|
|
2737
2967
|
const fragile = isItem2 && (bare || line2 === "ordered" && number !== 1);
|
|
2738
2968
|
const shown = comment ? void 0 : line2;
|
|
2739
2969
|
return { block: placed, line: shown, prefix, hang, residual, parent, container, closed, bare, fragile, comment };
|
|
@@ -2751,7 +2981,7 @@ function stripComments(block) {
|
|
|
2751
2981
|
regions: Object.fromEntries(
|
|
2752
2982
|
regions.map(([name, inline]) => [
|
|
2753
2983
|
name,
|
|
2754
|
-
hasCommentMark(inline) ?
|
|
2984
|
+
hasCommentMark(inline) ? chunk4JDRDPLC_cjs.removeMarkRange(inline, 0, chunk4JDRDPLC_cjs.inlineLength(inline), "comment") : inline
|
|
2755
2985
|
])
|
|
2756
2986
|
)
|
|
2757
2987
|
};
|
|
@@ -2780,7 +3010,7 @@ function pieceOf(text2, placement) {
|
|
|
2780
3010
|
opened: placement.container,
|
|
2781
3011
|
bare: placement.bare,
|
|
2782
3012
|
fragile: placement.fragile,
|
|
2783
|
-
leadsHtml: hang > 0 &&
|
|
3013
|
+
leadsHtml: hang > 0 && chunk4JDRDPLC_cjs.startsHtmlBlock(text2.split("\n")[0].slice(hang))
|
|
2784
3014
|
};
|
|
2785
3015
|
}
|
|
2786
3016
|
function takenAsItemText(previous, { parent, line: line2 }) {
|
|
@@ -2805,8 +3035,8 @@ function join(pieces) {
|
|
|
2805
3035
|
`;
|
|
2806
3036
|
}
|
|
2807
3037
|
function toMarkdown(blocks, options = {}) {
|
|
2808
|
-
const schema = options.schema ??
|
|
2809
|
-
const codec =
|
|
3038
|
+
const schema = options.schema ?? chunk4JDRDPLC_cjs.createSchema();
|
|
3039
|
+
const codec = chunk4JDRDPLC_cjs.createBlockCodec(schema);
|
|
2810
3040
|
const env = {
|
|
2811
3041
|
schema,
|
|
2812
3042
|
lossless: options.lossless === true,
|
|
@@ -2848,20 +3078,20 @@ function escapeAttr(value) {
|
|
|
2848
3078
|
|
|
2849
3079
|
// src/engine/render/serialize-html.ts
|
|
2850
3080
|
var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input"]);
|
|
2851
|
-
var attrsHtml = (node) =>
|
|
3081
|
+
var attrsHtml = (node) => chunk4JDRDPLC_cjs.writtenAttrs(node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
|
|
2852
3082
|
var serializeHtml = (nodes) => nodes.map(
|
|
2853
3083
|
(node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${node.html ?? serializeHtml(node.children)}</${node.tag}>`}`
|
|
2854
3084
|
).join("");
|
|
2855
3085
|
|
|
2856
3086
|
// src/engine/render/to-html.ts
|
|
2857
|
-
var toHTML = (blocks, options = {}) => serializeHtml(
|
|
3087
|
+
var toHTML = (blocks, options = {}) => serializeHtml(chunk4JDRDPLC_cjs.documentNodes(blocks, options));
|
|
2858
3088
|
|
|
2859
3089
|
// src/engine/render/to-plain-text.ts
|
|
2860
3090
|
function plainTextBlocks(blocks, schema) {
|
|
2861
|
-
return
|
|
3091
|
+
return chunk4JDRDPLC_cjs.engineBlocksOf(blocks, schema).map((block) => chunk4JDRDPLC_cjs.blockPlainText(block, schema));
|
|
2862
3092
|
}
|
|
2863
3093
|
function toPlainText(blocks, options = {}) {
|
|
2864
|
-
return plainTextBlocks(blocks, options.schema ??
|
|
3094
|
+
return plainTextBlocks(blocks, options.schema ?? chunk4JDRDPLC_cjs.createSchema()).join("\n");
|
|
2865
3095
|
}
|
|
2866
3096
|
|
|
2867
3097
|
// src/engine/model/graphemes.ts
|
|
@@ -2887,6 +3117,12 @@ function words(text2) {
|
|
|
2887
3117
|
}
|
|
2888
3118
|
return [...wordSegmenter.segment(text2)].filter((s) => s.isWordLike).map((s) => ({ start: s.index, end: s.index + s.segment.length }));
|
|
2889
3119
|
}
|
|
3120
|
+
function graphemePrefix(text2, count2) {
|
|
3121
|
+
if (!graphemeSegmenter) return [...text2].slice(0, count2).join("");
|
|
3122
|
+
let seen = 0;
|
|
3123
|
+
for (const { index } of graphemeSegmenter.segment(text2)) if (seen++ === count2) return text2.slice(0, index);
|
|
3124
|
+
return text2;
|
|
3125
|
+
}
|
|
2890
3126
|
function graphemeCount(text2) {
|
|
2891
3127
|
return boundaries(text2).length - 1;
|
|
2892
3128
|
}
|
|
@@ -2913,7 +3149,7 @@ function countBlock(block, schema) {
|
|
|
2913
3149
|
if (!blocks) counted.set(schema, blocks = /* @__PURE__ */ new WeakMap());
|
|
2914
3150
|
const known = blocks.get(block);
|
|
2915
3151
|
if (known) return known;
|
|
2916
|
-
const text2 =
|
|
3152
|
+
const text2 = chunk4JDRDPLC_cjs.blockPlainText(block, schema);
|
|
2917
3153
|
const stats = { characters: graphemeCount(text2), words: wordCount(text2) };
|
|
2918
3154
|
blocks.set(block, stats);
|
|
2919
3155
|
return stats;
|
|
@@ -2932,17 +3168,17 @@ function sum(blocks, schema) {
|
|
|
2932
3168
|
return { characters, words: words2 };
|
|
2933
3169
|
}
|
|
2934
3170
|
function countText(blocks, options = {}) {
|
|
2935
|
-
const schema = options.schema ?? (defaultSchema ??=
|
|
2936
|
-
return sum(
|
|
3171
|
+
const schema = options.schema ?? (defaultSchema ??= chunk4JDRDPLC_cjs.createSchema());
|
|
3172
|
+
return sum(chunk4JDRDPLC_cjs.engineBlocksOf(blocks, schema), schema);
|
|
2937
3173
|
}
|
|
2938
3174
|
function countDoc(doc, options = {}) {
|
|
2939
|
-
return sum(doc.blocks, options.schema ?? (defaultSchema ??=
|
|
3175
|
+
return sum(doc.blocks, options.schema ?? (defaultSchema ??= chunk4JDRDPLC_cjs.createSchema()));
|
|
2940
3176
|
}
|
|
2941
3177
|
|
|
2942
3178
|
// src/engine/commands/block-style.ts
|
|
2943
3179
|
function patchBlocks(state, patch, only) {
|
|
2944
3180
|
const changing = selectedBlockIds(state.doc, state.selection).filter((id) => {
|
|
2945
|
-
const block =
|
|
3181
|
+
const block = chunk4JDRDPLC_cjs.blockById(state.doc, id);
|
|
2946
3182
|
return block !== void 0 && (only === void 0 || block.type === only) && patchChangesAttrs(block.attrs, patch);
|
|
2947
3183
|
});
|
|
2948
3184
|
if (changing.length === 0) return null;
|
|
@@ -2970,7 +3206,7 @@ function setBlockColor(colors) {
|
|
|
2970
3206
|
const value = colors[key];
|
|
2971
3207
|
if (value !== void 0) patch[key] = value ?? void 0;
|
|
2972
3208
|
}
|
|
2973
|
-
const valid = Object.values(patch).every((value) => value === void 0 ||
|
|
3209
|
+
const valid = Object.values(patch).every((value) => value === void 0 || chunk4JDRDPLC_cjs.isPaletteColor(value));
|
|
2974
3210
|
return valid ? patchCommand(patch, "MARKDOWN") : () => false;
|
|
2975
3211
|
}
|
|
2976
3212
|
|
|
@@ -2990,7 +3226,7 @@ function textCaret(state) {
|
|
|
2990
3226
|
const { doc, schema, selection } = state;
|
|
2991
3227
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
|
|
2992
3228
|
const pos = selection.head;
|
|
2993
|
-
const index =
|
|
3229
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(doc, pos.block);
|
|
2994
3230
|
const block = doc.blocks[index];
|
|
2995
3231
|
const inFlow2 = isTextFlow(schema, block) && pos.region === primaryRegion(schema, block);
|
|
2996
3232
|
return inFlow2 ? { block, index, pos } : null;
|
|
@@ -2998,14 +3234,14 @@ function textCaret(state) {
|
|
|
2998
3234
|
function joinInto(tr, schema, target, source) {
|
|
2999
3235
|
const targetRegion = primaryRegion(schema, target) ?? "";
|
|
3000
3236
|
tr.step(joinBlocksStep(target.id, targetRegion, source.id, primaryRegion(schema, source) ?? ""));
|
|
3001
|
-
capIndents(tr,
|
|
3237
|
+
capIndents(tr, chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, target.id) + 1);
|
|
3002
3238
|
const offset = regionLength(target, targetRegion);
|
|
3003
3239
|
tr.setSelection(textSelection({ block: target.id, region: targetRegion, offset }));
|
|
3004
3240
|
}
|
|
3005
3241
|
function joinIntoSummary(tr, schema, summary, source) {
|
|
3006
3242
|
const region = primaryRegion(schema, summary) ?? "";
|
|
3007
3243
|
const offset = regionLength(summary, region);
|
|
3008
|
-
const index =
|
|
3244
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, source.id);
|
|
3009
3245
|
const content = source.regions[primaryRegion(schema, source) ?? ""];
|
|
3010
3246
|
if (content.length > 0) tr.step(replaceInlineStep(summary.id, region, offset, offset, content));
|
|
3011
3247
|
tr.step(removeBlocksStep(index, 1));
|
|
@@ -3077,7 +3313,7 @@ function deleteReaching(forward, reach) {
|
|
|
3077
3313
|
const { selection } = state;
|
|
3078
3314
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
|
|
3079
3315
|
const { head } = selection;
|
|
3080
|
-
const value =
|
|
3316
|
+
const value = chunk4JDRDPLC_cjs.inlineText(state.doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(state.doc, head.block)].regions[head.region]);
|
|
3081
3317
|
if (forward ? head.offset >= value.length : head.offset <= 0) {
|
|
3082
3318
|
return (forward ? deleteAtEnd : deleteAtStart)(state, dispatch);
|
|
3083
3319
|
}
|
|
@@ -3131,8 +3367,8 @@ function movedBlockIds(doc, ids) {
|
|
|
3131
3367
|
function gather(tr, runs, above) {
|
|
3132
3368
|
let anchor = above;
|
|
3133
3369
|
for (const run of runs) {
|
|
3134
|
-
const from =
|
|
3135
|
-
const at = anchor === null ? -1 :
|
|
3370
|
+
const from = chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, run[0]);
|
|
3371
|
+
const at = anchor === null ? -1 : chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, anchor);
|
|
3136
3372
|
const to = at < from ? at + 1 : at + 1 - run.length;
|
|
3137
3373
|
if (to !== from) tr.step(moveBlocksStep(from, run.length, to));
|
|
3138
3374
|
anchor = run[run.length - 1];
|
|
@@ -3160,7 +3396,7 @@ function moveBlocksTo(ids, toIndex, indent2) {
|
|
|
3160
3396
|
const first = runs[0][0];
|
|
3161
3397
|
const last = runs[runs.length - 1];
|
|
3162
3398
|
const clamped = Math.min(Math.max(indent2, 0), above ? above.indent + 1 : 0);
|
|
3163
|
-
reindent(tr,
|
|
3399
|
+
reindent(tr, chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, first), moved2.size, clamped);
|
|
3164
3400
|
if (!tr.docChanged) return false;
|
|
3165
3401
|
dispatch?.(tr.setSelection(blockRangeSelection(first, last[last.length - 1])));
|
|
3166
3402
|
return true;
|
|
@@ -3174,7 +3410,7 @@ var selectAll = (state, dispatch) => {
|
|
|
3174
3410
|
let next = blockRangeSelection(doc.blocks[0].id, doc.blocks[doc.blocks.length - 1].id);
|
|
3175
3411
|
if (selection?.kind === "text") {
|
|
3176
3412
|
const { anchor, head } = selection;
|
|
3177
|
-
const length =
|
|
3413
|
+
const length = chunk4JDRDPLC_cjs.inlineLength(doc.blocks[chunk4JDRDPLC_cjs.requireBlockIndex(doc, head.block)].regions[head.region] ?? []);
|
|
3178
3414
|
const withinRegion = anchor.block === head.block && anchor.region === head.region;
|
|
3179
3415
|
const covers = Math.min(anchor.offset, head.offset) === 0 && Math.max(anchor.offset, head.offset) === length;
|
|
3180
3416
|
if (withinRegion && !covers) next = textSelection({ ...head, offset: 0 }, { ...head, offset: length });
|
|
@@ -3211,7 +3447,7 @@ function splitStep(schema, block, region, offset, id) {
|
|
|
3211
3447
|
// src/engine/commands/split-at.ts
|
|
3212
3448
|
function enterInHardBreakBlock({ tr, schema, block, index, pos, makeId }) {
|
|
3213
3449
|
const length = regionLength(block, pos.region);
|
|
3214
|
-
if (pos.offset === length &&
|
|
3450
|
+
if (pos.offset === length && chunk4JDRDPLC_cjs.inlineText(block.regions[pos.region]).endsWith("\n")) {
|
|
3215
3451
|
tr.step(replaceInlineStep(block.id, pos.region, length - 1, length, []));
|
|
3216
3452
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, makeId());
|
|
3217
3453
|
tr.step(insertBlocksStep(descendantsEnd(tr.doc, index), [paragraph]));
|
|
@@ -3234,7 +3470,7 @@ function insertEmptyBefore({ tr, schema, block, index, pos, makeId }) {
|
|
|
3234
3470
|
function splitToggle({ tr, schema, block, index, pos, makeId }) {
|
|
3235
3471
|
const length = regionLength(block, pos.region);
|
|
3236
3472
|
const open = block.attrs.open === true;
|
|
3237
|
-
const tail =
|
|
3473
|
+
const tail = chunk4JDRDPLC_cjs.sliceInline(block.regions[pos.region], pos.offset, length);
|
|
3238
3474
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, open ? block.indent + 1 : block.indent, makeId());
|
|
3239
3475
|
if (pos.offset < length) tr.step(replaceInlineStep(block.id, pos.region, pos.offset, length, []));
|
|
3240
3476
|
tr.step(insertBlocksStep(open ? index + 1 : descendantsEnd(tr.doc, index), [withContent(schema, empty, tail)]));
|
|
@@ -3246,7 +3482,7 @@ function splitInTwo({ tr, schema, block, pos, makeId }) {
|
|
|
3246
3482
|
tr.setSelection(textSelection({ block: tail.id, region: tail.region, offset: 0 }));
|
|
3247
3483
|
}
|
|
3248
3484
|
function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
3249
|
-
const index =
|
|
3485
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, pos.block);
|
|
3250
3486
|
const block = tr.doc.blocks[index];
|
|
3251
3487
|
if (!isTextFlow(schema, block) || pos.region !== primaryRegion(schema, block)) return false;
|
|
3252
3488
|
const target = { tr, schema, block, index, pos, makeId };
|
|
@@ -3261,13 +3497,13 @@ function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
|
3261
3497
|
|
|
3262
3498
|
// src/engine/commands/split-block.ts
|
|
3263
3499
|
function splitBlock(options = {}) {
|
|
3264
|
-
const makeId = options.newId ??
|
|
3500
|
+
const makeId = options.newId ?? chunk4JDRDPLC_cjs.newId;
|
|
3265
3501
|
return (state, dispatch) => {
|
|
3266
3502
|
const { doc, schema, selection } = state;
|
|
3267
3503
|
if (selection === null || selection.kind === "blocks") return false;
|
|
3268
3504
|
const tr = new Transaction(state).setMeta(LINE_SPLIT, true);
|
|
3269
3505
|
if (selection.kind === "node") {
|
|
3270
|
-
const index =
|
|
3506
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(doc, selection.block);
|
|
3271
3507
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, doc.blocks[index].indent, makeId());
|
|
3272
3508
|
tr.step(insertBlocksStep(descendantsEnd(doc, index), [paragraph]));
|
|
3273
3509
|
tr.setSelection(startOf(tr.doc, schema, paragraph.id));
|
|
@@ -3377,7 +3613,7 @@ function replaceEmpty(tr, schema, index, blocks) {
|
|
|
3377
3613
|
tr.setSelection(endOf(tr.doc, schema, blocks[blocks.length - 1].id));
|
|
3378
3614
|
}
|
|
3379
3615
|
function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
3380
|
-
const index =
|
|
3616
|
+
const index = chunk4JDRDPLC_cjs.requireBlockIndex(tr.doc, caret.block);
|
|
3381
3617
|
const current = tr.doc.blocks[index];
|
|
3382
3618
|
const { region } = caret;
|
|
3383
3619
|
const first = pieces[0];
|
|
@@ -3386,7 +3622,7 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3386
3622
|
if (pieces.length === 1 && ends.openStart && ends.openEnd && textual(first)) {
|
|
3387
3623
|
const content = contentOf(schema, first);
|
|
3388
3624
|
insertAt(tr, caret, content);
|
|
3389
|
-
tr.setSelection(textSelection({ ...caret, offset: caret.offset +
|
|
3625
|
+
tr.setSelection(textSelection({ ...caret, offset: caret.offset + chunk4JDRDPLC_cjs.inlineLength(content) }));
|
|
3390
3626
|
return;
|
|
3391
3627
|
}
|
|
3392
3628
|
const fresh = freshBlocks(pieces, current.indent, makeId);
|
|
@@ -3408,18 +3644,18 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3408
3644
|
if (atStart && !atEnd) {
|
|
3409
3645
|
if (middle.length > 0) insertCapped(tr, index, middle);
|
|
3410
3646
|
insertAt(tr, { ...caret, offset: 0 }, lastContent);
|
|
3411
|
-
tr.setSelection(textSelection({ ...caret, offset:
|
|
3647
|
+
tr.setSelection(textSelection({ ...caret, offset: chunk4JDRDPLC_cjs.inlineLength(lastContent) }));
|
|
3412
3648
|
return;
|
|
3413
3649
|
}
|
|
3414
3650
|
const firstContent = mergeFirst ? contentOf(schema, fresh[0]) : [];
|
|
3415
3651
|
insertAt(tr, caret, firstContent);
|
|
3416
|
-
const offset = caret.offset +
|
|
3652
|
+
const offset = caret.offset + chunk4JDRDPLC_cjs.inlineLength(firstContent);
|
|
3417
3653
|
const tail = !atEnd && (mergeLast || middle.length > 0) ? splitStep(schema, current, region, offset, makeId()) : null;
|
|
3418
3654
|
if (tail !== null) tr.step(tail.step);
|
|
3419
3655
|
if (middle.length > 0) insertCapped(tr, index + 1, middle);
|
|
3420
3656
|
if (tail !== null && mergeLast) {
|
|
3421
3657
|
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:
|
|
3658
|
+
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: chunk4JDRDPLC_cjs.inlineLength(lastContent) }));
|
|
3423
3659
|
} else if (middle.length > 0) {
|
|
3424
3660
|
tr.setSelection(endOf(tr.doc, schema, middle[middle.length - 1].id));
|
|
3425
3661
|
} else {
|
|
@@ -3445,10 +3681,10 @@ function appendAtEnd(tr, schema, pieces, makeId) {
|
|
|
3445
3681
|
tr.setSelection(endOf(tr.doc, schema, fresh[fresh.length - 1].id));
|
|
3446
3682
|
}
|
|
3447
3683
|
function insertSlice(slice, options = {}) {
|
|
3448
|
-
const makeId = options.newId ??
|
|
3684
|
+
const makeId = options.newId ?? chunk4JDRDPLC_cjs.newId;
|
|
3449
3685
|
return (state, dispatch) => {
|
|
3450
3686
|
const { doc, schema, selection } = state;
|
|
3451
|
-
const codec =
|
|
3687
|
+
const codec = chunk4JDRDPLC_cjs.createBlockCodec(schema, { newId: makeId });
|
|
3452
3688
|
const pieces = slice.blocks.flatMap((block) => codec.toEngineBlocks(block));
|
|
3453
3689
|
if (pieces.length === 0) return false;
|
|
3454
3690
|
const tr = new Transaction(state).setOrigin("paste");
|
|
@@ -3497,9 +3733,9 @@ function fenceTransaction(state) {
|
|
|
3497
3733
|
const { selection, doc } = state;
|
|
3498
3734
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
|
|
3499
3735
|
const { block: id, region, offset } = selection.head;
|
|
3500
|
-
const block =
|
|
3736
|
+
const block = chunk4JDRDPLC_cjs.blockById(doc, id);
|
|
3501
3737
|
if (block === void 0 || !isParagraph(block) || offset !== regionLength(block, region)) return null;
|
|
3502
|
-
const fence = FENCE.exec(
|
|
3738
|
+
const fence = FENCE.exec(chunk4JDRDPLC_cjs.inlineText(block.regions[region]));
|
|
3503
3739
|
if (fence === null) return null;
|
|
3504
3740
|
return convertPrefix(state, { block: id, region, from: 0, to: offset }, setBlockType("CODE", { language: fence[1] }));
|
|
3505
3741
|
}
|
|
@@ -3566,9 +3802,9 @@ function coreExtensions(options = {}) {
|
|
|
3566
3802
|
return [
|
|
3567
3803
|
defineExtension({
|
|
3568
3804
|
name: "core",
|
|
3569
|
-
blocks:
|
|
3570
|
-
marks:
|
|
3571
|
-
atoms:
|
|
3805
|
+
blocks: chunk4JDRDPLC_cjs.coreBlockSpecs,
|
|
3806
|
+
marks: chunk4JDRDPLC_cjs.coreMarkSpecs,
|
|
3807
|
+
atoms: chunk4JDRDPLC_cjs.coreAtomSpecs,
|
|
3572
3808
|
commands: coreCommands,
|
|
3573
3809
|
pasteRules: [linkOverSelection]
|
|
3574
3810
|
}),
|
|
@@ -3585,12 +3821,13 @@ function coreExtensions(options = {}) {
|
|
|
3585
3821
|
|
|
3586
3822
|
// src/engine/clipboard/serialize-slice.ts
|
|
3587
3823
|
function sliceText(slice, options) {
|
|
3588
|
-
const schema = options.schema ??
|
|
3824
|
+
const schema = options.schema ?? chunk4JDRDPLC_cjs.createSchema();
|
|
3589
3825
|
if (slice.blocks.length === 1 && slice.openStart && slice.openEnd) {
|
|
3590
|
-
const pieces =
|
|
3826
|
+
const pieces = chunk4JDRDPLC_cjs.createBlockCodec(schema).toEngineBlocks(slice.blocks[0]);
|
|
3591
3827
|
const block = pieces.length === 1 ? stripComments(pieces[0]) : null;
|
|
3592
3828
|
const region = block === null || !isTextFlow(schema, block) ? null : primaryRegion(schema, block);
|
|
3593
|
-
if (block !== null && region !== null) return
|
|
3829
|
+
if (block !== null && region !== null) return chunk4JDRDPLC_cjs.inlinePlainText(block.regions[region] ?? [], schema);
|
|
3830
|
+
if (block?.type === "TABLE") return chunk4JDRDPLC_cjs.blockPlainText(block, schema);
|
|
3594
3831
|
}
|
|
3595
3832
|
const markdown = toMarkdown(slice.blocks, { schema, resolveAssetUrl: options.resolveAssetUrl, comments: false });
|
|
3596
3833
|
return markdown.replace(/\n$/, "");
|
|
@@ -3603,25 +3840,51 @@ function sliceToClipboard(slice, options = {}) {
|
|
|
3603
3840
|
};
|
|
3604
3841
|
}
|
|
3605
3842
|
|
|
3843
|
+
// src/engine/clipboard/table-part.ts
|
|
3844
|
+
function tablePart(block, from, to) {
|
|
3845
|
+
const a = cellOf(from);
|
|
3846
|
+
const b = cellOf(to);
|
|
3847
|
+
if (a === null || b === null) return block;
|
|
3848
|
+
const cells = cellsBetween(a, b);
|
|
3849
|
+
const [top, left] = cells[0];
|
|
3850
|
+
const [bottom, right] = cells[cells.length - 1];
|
|
3851
|
+
const regions = {};
|
|
3852
|
+
for (const [row, col] of cells) regions[chunk4JDRDPLC_cjs.cellKey(row - top, col - left)] = block.regions[chunk4JDRDPLC_cjs.cellKey(row, col)] ?? [];
|
|
3853
|
+
const columns = (list2) => Array.isArray(list2) ? list2.slice(left, right + 1) : list2;
|
|
3854
|
+
const { attrs } = block;
|
|
3855
|
+
return {
|
|
3856
|
+
...block,
|
|
3857
|
+
regions,
|
|
3858
|
+
attrs: {
|
|
3859
|
+
...attrs,
|
|
3860
|
+
rows: bottom - top + 1,
|
|
3861
|
+
cols: right - left + 1,
|
|
3862
|
+
header: attrs.header !== false && top === 0,
|
|
3863
|
+
align: columns(attrs.align),
|
|
3864
|
+
widths: columns(attrs.widths)
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3606
3869
|
// src/engine/clipboard/extract-slice.ts
|
|
3607
3870
|
function isFlowRegion(schema, block, region) {
|
|
3608
3871
|
return isTextFlow(schema, block) && region === primaryRegion(schema, block);
|
|
3609
3872
|
}
|
|
3610
3873
|
function trimmed(block, region, from, to) {
|
|
3611
|
-
return { ...block, regions: { ...block.regions, [region]:
|
|
3874
|
+
return { ...block, regions: { ...block.regions, [region]: chunk4JDRDPLC_cjs.sliceInline(block.regions[region], from, to) } };
|
|
3612
3875
|
}
|
|
3613
3876
|
function insideOneRegion(schema, block, region, from, to) {
|
|
3614
3877
|
if (isFlowRegion(schema, block, region)) return trimmed(block, region, from, to);
|
|
3615
3878
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, block.id);
|
|
3616
|
-
return withContent(schema, paragraph,
|
|
3879
|
+
return withContent(schema, paragraph, chunk4JDRDPLC_cjs.sliceInline(block.regions[region], from, to));
|
|
3617
3880
|
}
|
|
3618
3881
|
function textBlocks({ doc, schema }, selection) {
|
|
3619
3882
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
3620
|
-
const start =
|
|
3621
|
-
const end =
|
|
3883
|
+
const start = chunk4JDRDPLC_cjs.requireBlockIndex(doc, from.block);
|
|
3884
|
+
const end = chunk4JDRDPLC_cjs.requireBlockIndex(doc, to.block);
|
|
3622
3885
|
const first = doc.blocks[start];
|
|
3623
3886
|
if (start === end) {
|
|
3624
|
-
if (from.region !== to.region) return [first];
|
|
3887
|
+
if (from.region !== to.region) return [tablePart(first, from.region, to.region)];
|
|
3625
3888
|
return [insideOneRegion(schema, first, from.region, from.offset, to.offset)];
|
|
3626
3889
|
}
|
|
3627
3890
|
const last = doc.blocks[end];
|
|
@@ -3664,18 +3927,18 @@ var INLINE_SYNTAX = [/\*\*[^*\n]+\*\*/, /__[^_\n]+__/, /\[[^\]\n]+\]\([^)\s]+[^)
|
|
|
3664
3927
|
function looksLikeMarkdown(value) {
|
|
3665
3928
|
return value.split(/\r\n|\r|\n/).some((line2) => BLOCK_MARKERS.some((marker) => marker.test(line2))) || INLINE_SYNTAX.some((syntax) => syntax.test(value));
|
|
3666
3929
|
}
|
|
3667
|
-
function plainTextToBlocks(value, makeId =
|
|
3930
|
+
function plainTextToBlocks(value, makeId = chunk4JDRDPLC_cjs.newId) {
|
|
3668
3931
|
return value.split(/\r\n|\r|\n/).filter((line2) => line2.trim() !== "").map((line2) => ({
|
|
3669
3932
|
id: makeId(),
|
|
3670
3933
|
type: "MARKDOWN",
|
|
3671
|
-
data: { markdown:
|
|
3934
|
+
data: { markdown: chunk4JDRDPLC_cjs.serializeInline([chunk4JDRDPLC_cjs.text(line2)], { escapeLineStart: true }) }
|
|
3672
3935
|
}));
|
|
3673
3936
|
}
|
|
3674
3937
|
|
|
3675
3938
|
// src/engine/clipboard/parse-slice-json.ts
|
|
3676
3939
|
function isBlock2(value) {
|
|
3677
|
-
if (!
|
|
3678
|
-
if (!
|
|
3940
|
+
if (!chunk4JDRDPLC_cjs.isRecord(value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
|
|
3941
|
+
if (!chunk4JDRDPLC_cjs.isRecord(value.data)) return false;
|
|
3679
3942
|
return value.indent === void 0 || Number.isInteger(value.indent) && value.indent >= 0;
|
|
3680
3943
|
}
|
|
3681
3944
|
function parseSliceJSON(json) {
|
|
@@ -3685,15 +3948,18 @@ function parseSliceJSON(json) {
|
|
|
3685
3948
|
} catch {
|
|
3686
3949
|
return null;
|
|
3687
3950
|
}
|
|
3688
|
-
if (!
|
|
3951
|
+
if (!chunk4JDRDPLC_cjs.isRecord(parsed) || parsed.quoin !== 1 || !chunk4JDRDPLC_cjs.isRecord(parsed.slice)) return null;
|
|
3689
3952
|
const { blocks, openStart, openEnd } = parsed.slice;
|
|
3690
3953
|
if (!Array.isArray(blocks) || blocks.length === 0 || !blocks.every(isBlock2)) return null;
|
|
3691
3954
|
if (typeof openStart !== "boolean" || typeof openEnd !== "boolean") return null;
|
|
3692
3955
|
return { blocks, openStart, openEnd };
|
|
3693
3956
|
}
|
|
3694
3957
|
|
|
3958
|
+
// src/engine/clipboard/slice.ts
|
|
3959
|
+
var PASTED_HTML = "pastedHTML";
|
|
3960
|
+
|
|
3695
3961
|
// src/engine/clipboard/slice-from-clipboard.ts
|
|
3696
|
-
var isParagraph2 = (block) => block.type === "MARKDOWN" &&
|
|
3962
|
+
var isParagraph2 = (block) => block.type === "MARKDOWN" && chunk4JDRDPLC_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
|
|
3697
3963
|
function openSlice(blocks, plainText2 = false) {
|
|
3698
3964
|
if (blocks.length === 0) return null;
|
|
3699
3965
|
const slice = { blocks, openStart: isParagraph2(blocks[0]), openEnd: isParagraph2(blocks[blocks.length - 1]) };
|
|
@@ -3703,27 +3969,29 @@ function linkBlocks(text2, makeId) {
|
|
|
3703
3969
|
const link = pastedLink(text2);
|
|
3704
3970
|
if (link === null) return null;
|
|
3705
3971
|
const { url, href, rest } = link;
|
|
3706
|
-
const linked2 =
|
|
3707
|
-
const markdown =
|
|
3972
|
+
const linked2 = chunk4JDRDPLC_cjs.text(url, [{ type: "link", attrs: { href } }]);
|
|
3973
|
+
const markdown = chunk4JDRDPLC_cjs.serializeInline(rest === "" ? [linked2] : [linked2, chunk4JDRDPLC_cjs.text(rest)]);
|
|
3708
3974
|
return [{ id: makeId(), type: "MARKDOWN", data: { markdown } }];
|
|
3709
3975
|
}
|
|
3710
3976
|
function textBlocks2(text2, makeId) {
|
|
3711
3977
|
const link = linkBlocks(text2, makeId);
|
|
3712
3978
|
if (link !== null) return link;
|
|
3713
|
-
return looksLikeMarkdown(text2) ?
|
|
3979
|
+
return looksLikeMarkdown(text2) ? chunk4JDRDPLC_cjs.fromMarkdown(text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
|
|
3714
3980
|
}
|
|
3715
3981
|
function htmlSlice(html, options) {
|
|
3716
3982
|
if (html === void 0) return null;
|
|
3717
3983
|
const parser = availableParser(options.parser);
|
|
3718
|
-
|
|
3984
|
+
const slice = parser === null ? null : openSlice(fromHTML(html, { ...options, parser }));
|
|
3985
|
+
return slice && { ...slice, fromHTML: true };
|
|
3719
3986
|
}
|
|
3720
3987
|
function sliceFromClipboard(data, options = {}) {
|
|
3721
3988
|
const fromJson = data.json === void 0 ? null : parseSliceJSON(data.json);
|
|
3722
3989
|
if (fromJson !== null) return fromJson;
|
|
3723
3990
|
const fromHtml = htmlSlice(data.html, options);
|
|
3724
3991
|
if (fromHtml !== null) return fromHtml;
|
|
3725
|
-
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ??
|
|
3992
|
+
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ?? chunk4JDRDPLC_cjs.newId), true);
|
|
3726
3993
|
}
|
|
3994
|
+
var dispatchPaste = (slice, dispatch) => (tr) => dispatch(slice.fromHTML ? tr.setMeta(PASTED_HTML, true) : tr);
|
|
3727
3995
|
|
|
3728
3996
|
// src/engine/commands/is-active.ts
|
|
3729
3997
|
function hasAttrs(block, attrs) {
|
|
@@ -3731,7 +3999,7 @@ function hasAttrs(block, attrs) {
|
|
|
3731
3999
|
}
|
|
3732
4000
|
function isActive(state, name, attrs) {
|
|
3733
4001
|
if (state.schema.marks.has(name)) return selectionHasMark(state, name, attrs);
|
|
3734
|
-
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) =>
|
|
4002
|
+
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => chunk4JDRDPLC_cjs.blockById(state.doc, id) ?? []);
|
|
3735
4003
|
const isBlockType = state.schema.blocks.has(name);
|
|
3736
4004
|
const matches = (block) => isBlockType ? block.type === name : block.type === "MARKDOWN" && block.attrs.kind === name;
|
|
3737
4005
|
return blocks.length > 0 && blocks.every((block) => matches(block) && hasAttrs(block, attrs));
|
|
@@ -3740,19 +4008,19 @@ function isActive(state, name, attrs) {
|
|
|
3740
4008
|
// src/engine/model/same-doc.ts
|
|
3741
4009
|
function sameDoc(a, b) {
|
|
3742
4010
|
if (a === b) return true;
|
|
3743
|
-
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) =>
|
|
4011
|
+
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => chunk4JDRDPLC_cjs.sameValue(block, b.blocks[i]));
|
|
3744
4012
|
}
|
|
3745
4013
|
|
|
3746
4014
|
// src/engine/extension/same-blocks.ts
|
|
3747
4015
|
function sameBlock(a, b) {
|
|
3748
|
-
return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) &&
|
|
4016
|
+
return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) && chunk4JDRDPLC_cjs.sameValue(a.data, b.data);
|
|
3749
4017
|
}
|
|
3750
4018
|
function sameBlocks(a, b) {
|
|
3751
|
-
return a === b ||
|
|
4019
|
+
return a === b || chunk4JDRDPLC_cjs.sameItems(a, b, sameBlock);
|
|
3752
4020
|
}
|
|
3753
4021
|
|
|
3754
4022
|
// src/engine/extension/structural-echo.ts
|
|
3755
|
-
var sameIds = (a, b) =>
|
|
4023
|
+
var sameIds = (a, b) => chunk4JDRDPLC_cjs.sameItems(a, b, (x, y) => x.id === y.id);
|
|
3756
4024
|
function copiedSequence(emissions, incoming) {
|
|
3757
4025
|
const verdicts = /* @__PURE__ */ new Map();
|
|
3758
4026
|
const sameAt = (block, index) => {
|
|
@@ -3933,7 +4201,7 @@ function resolveExtensions(extensions, isMac) {
|
|
|
3933
4201
|
const lowestFirst = [...extensions].sort((a, b) => priorityOf(a) - priorityOf(b));
|
|
3934
4202
|
return {
|
|
3935
4203
|
extensions: sorted,
|
|
3936
|
-
schema:
|
|
4204
|
+
schema: chunk4JDRDPLC_cjs.createSchema({
|
|
3937
4205
|
blocks: lowestFirst.flatMap((extension) => extension.blocks ?? []),
|
|
3938
4206
|
marks: lowestFirst.flatMap((extension) => extension.marks ?? []),
|
|
3939
4207
|
atoms: lowestFirst.flatMap((extension) => extension.atoms ?? [])
|
|
@@ -3957,7 +4225,7 @@ function createInternalEditor(options) {
|
|
|
3957
4225
|
const isMac = options.isMac ?? detectMac();
|
|
3958
4226
|
const resolved = resolveExtensions(options.extensions ?? coreExtensions({ newId: newId2 }), isMac);
|
|
3959
4227
|
const { schema, plugins } = resolved;
|
|
3960
|
-
const codec =
|
|
4228
|
+
const codec = chunk4JDRDPLC_cjs.createBlockCodec(schema, { newId: newId2 });
|
|
3961
4229
|
const listeners = /* @__PURE__ */ new Set();
|
|
3962
4230
|
const mounts = /* @__PURE__ */ new Set();
|
|
3963
4231
|
let state = createState({ doc: codec.docFromBlocks(options.blocks), schema, plugins, clock: options.now });
|
|
@@ -3988,10 +4256,10 @@ function createInternalEditor(options) {
|
|
|
3988
4256
|
function paste(data, parser) {
|
|
3989
4257
|
if (destroyed) return false;
|
|
3990
4258
|
const { text: text2 } = data;
|
|
3991
|
-
const ruled = text2 !== void 0 && resolved.pasteRules.some((rule) => rule.match(text2, state)?.(state, dispatch));
|
|
4259
|
+
const ruled = text2 !== void 0 && resolved.pasteRules.some((rule) => rule.match(text2, state, data)?.(state, dispatch));
|
|
3992
4260
|
if (ruled) return true;
|
|
3993
4261
|
const slice = sliceFromClipboard(data, { parser, newId: newId2 });
|
|
3994
|
-
return slice !== null && insertSlice(slice, { newId: newId2 })(state, dispatch);
|
|
4262
|
+
return slice !== null && insertSlice(slice, { newId: newId2 })(state, dispatchPaste(slice, dispatch));
|
|
3995
4263
|
}
|
|
3996
4264
|
function copy() {
|
|
3997
4265
|
const slice = sliceFromSelection(state, codec);
|
|
@@ -4056,6 +4324,7 @@ exports.HISTORY_GROUP = HISTORY_GROUP;
|
|
|
4056
4324
|
exports.HISTORY_PROVIDER = HISTORY_PROVIDER;
|
|
4057
4325
|
exports.LINE_JOIN = LINE_JOIN;
|
|
4058
4326
|
exports.LINE_SPLIT = LINE_SPLIT;
|
|
4327
|
+
exports.PASTED_HTML = PASTED_HTML;
|
|
4059
4328
|
exports.Transaction = Transaction;
|
|
4060
4329
|
exports.addMarkStep = addMarkStep;
|
|
4061
4330
|
exports.applyTransaction = applyTransaction;
|
|
@@ -4063,6 +4332,9 @@ exports.blockInputRules = blockInputRules;
|
|
|
4063
4332
|
exports.blockRangeSelection = blockRangeSelection;
|
|
4064
4333
|
exports.capIndents = capIndents;
|
|
4065
4334
|
exports.caretMarks = caretMarks;
|
|
4335
|
+
exports.carrySelection = carrySelection;
|
|
4336
|
+
exports.cellOf = cellOf;
|
|
4337
|
+
exports.cellsBetween = cellsBetween;
|
|
4066
4338
|
exports.commonPrefix = commonPrefix;
|
|
4067
4339
|
exports.commonSuffix = commonSuffix;
|
|
4068
4340
|
exports.comparePos = comparePos;
|
|
@@ -4095,6 +4367,7 @@ exports.freshBlocks = freshBlocks;
|
|
|
4095
4367
|
exports.fromHTML = fromHTML;
|
|
4096
4368
|
exports.getPluginState = getPluginState;
|
|
4097
4369
|
exports.graphemeCount = graphemeCount;
|
|
4370
|
+
exports.graphemePrefix = graphemePrefix;
|
|
4098
4371
|
exports.groupOf = groupOf;
|
|
4099
4372
|
exports.headBlockId = headBlockId;
|
|
4100
4373
|
exports.hidingToggle = hidingToggle;
|