quoin-editor 1.1.0 → 1.1.2
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 +20 -0
- package/dist/ai.cjs +80 -79
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +8 -7
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +26 -25
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +17 -16
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-RHQPAW4W.js → chunk-36OSSZDK.js} +6 -6
- package/dist/{chunk-RHQPAW4W.js.map → chunk-36OSSZDK.js.map} +1 -1
- package/dist/{chunk-3BXUGX5F.js → chunk-3G4ZWUUY.js} +4 -16
- package/dist/chunk-3G4ZWUUY.js.map +1 -0
- package/dist/{chunk-DTQFYHDJ.cjs → chunk-5DEPLPDS.cjs} +28 -28
- package/dist/{chunk-DTQFYHDJ.cjs.map → chunk-5DEPLPDS.cjs.map} +1 -1
- package/dist/{chunk-2EQ6FKSK.js → chunk-5LWJDRWD.js} +3 -3
- package/dist/{chunk-2EQ6FKSK.js.map → chunk-5LWJDRWD.js.map} +1 -1
- package/dist/{chunk-ITXCE6KL.js → chunk-5QNNF5ZJ.js} +5 -5
- package/dist/{chunk-ITXCE6KL.js.map → chunk-5QNNF5ZJ.js.map} +1 -1
- package/dist/{chunk-AIS37SL2.cjs → chunk-6H76FAI3.cjs} +79 -7
- package/dist/chunk-6H76FAI3.cjs.map +1 -0
- package/dist/{chunk-SKZC4K5S.cjs → chunk-6QLA3JOU.cjs} +90 -90
- package/dist/{chunk-SKZC4K5S.cjs.map → chunk-6QLA3JOU.cjs.map} +1 -1
- package/dist/{chunk-QEMGOL5L.cjs → chunk-ABVSP2XR.cjs} +325 -295
- package/dist/chunk-ABVSP2XR.cjs.map +1 -0
- package/dist/{chunk-KSF2HILJ.js → chunk-AQNVYFEU.js} +6 -6
- package/dist/{chunk-KSF2HILJ.js.map → chunk-AQNVYFEU.js.map} +1 -1
- package/dist/{chunk-ZTLYHRZT.cjs → chunk-BMEEEI43.cjs} +13 -13
- package/dist/{chunk-ZTLYHRZT.cjs.map → chunk-BMEEEI43.cjs.map} +1 -1
- package/dist/{chunk-RIIXJWBR.cjs → chunk-E52VO5JT.cjs} +4 -4
- package/dist/{chunk-RIIXJWBR.cjs.map → chunk-E52VO5JT.cjs.map} +1 -1
- package/dist/{chunk-WDO6DBYU.cjs → chunk-EABO523V.cjs} +31 -31
- package/dist/{chunk-WDO6DBYU.cjs.map → chunk-EABO523V.cjs.map} +1 -1
- package/dist/{chunk-TBCHYHNU.js → chunk-EDKQQKQR.js} +6 -6
- package/dist/{chunk-TBCHYHNU.js.map → chunk-EDKQQKQR.js.map} +1 -1
- package/dist/{chunk-IXVGHH7F.cjs → chunk-ES2QYHXL.cjs} +45 -45
- package/dist/{chunk-IXVGHH7F.cjs.map → chunk-ES2QYHXL.cjs.map} +1 -1
- package/dist/{chunk-QC35D2AU.js → chunk-G7HK4OHE.js} +24 -14
- package/dist/chunk-G7HK4OHE.js.map +1 -0
- package/dist/{chunk-L4D23LM2.js → chunk-IVWFPFUG.js} +4 -4
- package/dist/{chunk-L4D23LM2.js.map → chunk-IVWFPFUG.js.map} +1 -1
- package/dist/{chunk-SAEQMDAU.js → chunk-J37ORWSG.js} +7 -7
- package/dist/{chunk-SAEQMDAU.js.map → chunk-J37ORWSG.js.map} +1 -1
- package/dist/{chunk-XJDPQFPU.js → chunk-JEFQNZO4.js} +40 -10
- package/dist/chunk-JEFQNZO4.js.map +1 -0
- package/dist/{chunk-TNN6Z52D.js → chunk-JHA23OOK.js} +6 -6
- package/dist/{chunk-TNN6Z52D.js.map → chunk-JHA23OOK.js.map} +1 -1
- package/dist/{chunk-7FAVFJAS.js → chunk-JYO2T4MC.js} +3 -3
- package/dist/{chunk-7FAVFJAS.js.map → chunk-JYO2T4MC.js.map} +1 -1
- package/dist/{chunk-HQ43EIYO.cjs → chunk-K5HWMBWH.cjs} +9 -9
- package/dist/{chunk-HQ43EIYO.cjs.map → chunk-K5HWMBWH.cjs.map} +1 -1
- package/dist/{chunk-OM7E43ZN.cjs → chunk-KFIE4OJE.cjs} +15 -15
- package/dist/{chunk-OM7E43ZN.cjs.map → chunk-KFIE4OJE.cjs.map} +1 -1
- package/dist/{chunk-ZWB7SZVI.cjs → chunk-KKRQDVBJ.cjs} +24 -24
- package/dist/{chunk-ZWB7SZVI.cjs.map → chunk-KKRQDVBJ.cjs.map} +1 -1
- package/dist/{chunk-VFSVN5IQ.cjs → chunk-M5FREXRQ.cjs} +218 -218
- package/dist/{chunk-VFSVN5IQ.cjs.map → chunk-M5FREXRQ.cjs.map} +1 -1
- package/dist/{chunk-7SVKLWDT.cjs → chunk-OAAYF2EI.cjs} +13 -26
- package/dist/chunk-OAAYF2EI.cjs.map +1 -0
- package/dist/{chunk-HTLWPSMU.js → chunk-OIQAO7QU.js} +4 -4
- package/dist/{chunk-HTLWPSMU.js.map → chunk-OIQAO7QU.js.map} +1 -1
- package/dist/{chunk-3QRVAI53.cjs → chunk-P3T5XBYW.cjs} +6 -6
- package/dist/{chunk-3QRVAI53.cjs.map → chunk-P3T5XBYW.cjs.map} +1 -1
- package/dist/{chunk-NO3KTZDY.cjs → chunk-PNMBRBAT.cjs} +4 -4
- package/dist/{chunk-NO3KTZDY.cjs.map → chunk-PNMBRBAT.cjs.map} +1 -1
- package/dist/{chunk-MGMA5PEL.js → chunk-PRXIYHSX.js} +6 -6
- package/dist/{chunk-MGMA5PEL.js.map → chunk-PRXIYHSX.js.map} +1 -1
- package/dist/{chunk-QWS7KH3K.cjs → chunk-QAI3CM7V.cjs} +55 -55
- package/dist/{chunk-QWS7KH3K.cjs.map → chunk-QAI3CM7V.cjs.map} +1 -1
- package/dist/{chunk-L6OW2FL3.js → chunk-QLDXQOHQ.js} +79 -8
- package/dist/chunk-QLDXQOHQ.js.map +1 -0
- package/dist/{chunk-TYZSB7JT.js → chunk-RUC5OZXO.js} +3 -3
- package/dist/{chunk-TYZSB7JT.js.map → chunk-RUC5OZXO.js.map} +1 -1
- package/dist/{chunk-WHV5ZSIO.cjs → chunk-UGAOEZ3O.cjs} +15 -15
- package/dist/{chunk-WHV5ZSIO.cjs.map → chunk-UGAOEZ3O.cjs.map} +1 -1
- package/dist/{chunk-PJCHSHM3.js → chunk-V2ZBA5VC.js} +8 -8
- package/dist/{chunk-PJCHSHM3.js.map → chunk-V2ZBA5VC.js.map} +1 -1
- package/dist/{chunk-ACSEYJJF.cjs → chunk-VSUGJZ7G.cjs} +135 -125
- package/dist/chunk-VSUGJZ7G.cjs.map +1 -0
- package/dist/{chunk-LY2D45F2.cjs → chunk-XJ32XESJ.cjs} +98 -98
- package/dist/{chunk-LY2D45F2.cjs.map → chunk-XJ32XESJ.cjs.map} +1 -1
- package/dist/{chunk-JZJIWRF3.js → chunk-ZEQXMRJW.js} +3 -3
- package/dist/{chunk-JZJIWRF3.js.map → chunk-ZEQXMRJW.js.map} +1 -1
- package/dist/{chunk-HWEK7EX5.js → chunk-ZPGA5UIY.js} +7 -7
- package/dist/{chunk-HWEK7EX5.js.map → chunk-ZPGA5UIY.js.map} +1 -1
- package/dist/comments.cjs +60 -59
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +8 -7
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +27 -27
- package/dist/diff.js +3 -3
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed.cjs +11 -10
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +8 -7
- package/dist/embed.js.map +1 -1
- package/dist/emoji.cjs +11 -10
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +7 -6
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +58 -58
- package/dist/engine.js +3 -3
- package/dist/find.cjs +12 -11
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +7 -6
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +76 -75
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.js +5 -4
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +88 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +12 -11
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +9 -8
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +12 -11
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +9 -8
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +40 -39
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +9 -8
- package/dist/presence.js.map +1 -1
- package/dist/stats.cjs +12 -11
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +8 -7
- package/dist/stats.js.map +1 -1
- package/dist/table.cjs +27 -26
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +7 -6
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +11 -10
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +7 -6
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +119 -119
- package/dist/yjs.js +5 -5
- package/package.json +2 -1
- package/dist/chunk-3BXUGX5F.js.map +0 -1
- package/dist/chunk-7SVKLWDT.cjs.map +0 -1
- package/dist/chunk-ACSEYJJF.cjs.map +0 -1
- package/dist/chunk-AIS37SL2.cjs.map +0 -1
- package/dist/chunk-L6OW2FL3.js.map +0 -1
- package/dist/chunk-QC35D2AU.js.map +0 -1
- package/dist/chunk-QEMGOL5L.cjs.map +0 -1
- package/dist/chunk-XJDPQFPU.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkOAAYF2EI_cjs = require('./chunk-OAAYF2EI.cjs');
|
|
4
|
+
var chunk6H76FAI3_cjs = require('./chunk-6H76FAI3.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 = chunk6H76FAI3_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 = chunk6H76FAI3_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) : !chunk6H76FAI3_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: chunk6H76FAI3_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: chunk6H76FAI3_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(chunk6H76FAI3_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 : chunk6H76FAI3_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 = chunk6H76FAI3_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: chunk6H76FAI3_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: chunk6H76FAI3_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: chunk6H76FAI3_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) && chunk6H76FAI3_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: chunk6H76FAI3_cjs.updateBlock(doc, block.id, () => block), map };
|
|
175
175
|
},
|
|
176
176
|
invert: (before) => replaceBlockStep(requireBlock(before, block.id)),
|
|
177
177
|
toJSON: () => ({ stepType: "replaceBlock", block })
|
|
@@ -180,7 +180,7 @@ function replaceBlockStep(block) {
|
|
|
180
180
|
|
|
181
181
|
// src/engine/transform/replace-inline-step.ts
|
|
182
182
|
function replaceInlineStep(block, region, from, to, slice) {
|
|
183
|
-
const inserted =
|
|
183
|
+
const inserted = chunk6H76FAI3_cjs.inlineLength(slice);
|
|
184
184
|
const map = (pos, assoc = 1) => {
|
|
185
185
|
if (pos.block !== block || pos.region !== region || pos.offset < from) return pos;
|
|
186
186
|
if (pos.offset > to) return { ...pos, offset: pos.offset + inserted - (to - from) };
|
|
@@ -190,12 +190,12 @@ function replaceInlineStep(block, region, from, to, slice) {
|
|
|
190
190
|
stepType: "replaceInline",
|
|
191
191
|
apply(doc) {
|
|
192
192
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
193
|
-
const next =
|
|
193
|
+
const next = chunk6H76FAI3_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunk6H76FAI3_cjs.replaceInline(inline, from, to, slice)));
|
|
194
194
|
return { doc: next, map };
|
|
195
195
|
},
|
|
196
196
|
invert(before) {
|
|
197
197
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
198
|
-
return replaceInlineStep(block, region, from, from + inserted,
|
|
198
|
+
return replaceInlineStep(block, region, from, from + inserted, chunk6H76FAI3_cjs.sliceInline(inline, from, to));
|
|
199
199
|
},
|
|
200
200
|
toJSON: () => ({ stepType: "replaceInline", block, region, from, to, slice })
|
|
201
201
|
});
|
|
@@ -208,24 +208,24 @@ function markStep(stepType, target, mark, change) {
|
|
|
208
208
|
stepType,
|
|
209
209
|
apply(doc) {
|
|
210
210
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
211
|
-
return { doc:
|
|
211
|
+
return { doc: chunk6H76FAI3_cjs.updateBlock(doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
|
|
212
212
|
},
|
|
213
213
|
invert(before) {
|
|
214
214
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
215
|
-
return replaceInlineStep(block, region, from, to,
|
|
215
|
+
return replaceInlineStep(block, region, from, to, chunk6H76FAI3_cjs.sliceInline(inline, from, to));
|
|
216
216
|
},
|
|
217
217
|
toJSON: () => ({ stepType, ...target, mark })
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
function addMarkStep(block, region, from, to, mark) {
|
|
221
|
-
return markStep("addMark", { block, region, from, to }, mark, (inline) =>
|
|
221
|
+
return markStep("addMark", { block, region, from, to }, mark, (inline) => chunk6H76FAI3_cjs.addMarkRange(inline, from, to, mark));
|
|
222
222
|
}
|
|
223
223
|
function removeMarkStep(block, region, from, to, mark) {
|
|
224
224
|
return markStep(
|
|
225
225
|
"removeMark",
|
|
226
226
|
{ block, region, from, to },
|
|
227
227
|
mark,
|
|
228
|
-
(inline) =>
|
|
228
|
+
(inline) => chunk6H76FAI3_cjs.removeMarkRange(inline, from, to, mark)
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -255,7 +255,7 @@ function mapTextChange(before, after) {
|
|
|
255
255
|
const ops = removed.length + added.length > DIFF_LIMIT ? [
|
|
256
256
|
{ op: "delete", items: removed },
|
|
257
257
|
{ op: "insert", items: added }
|
|
258
|
-
] :
|
|
258
|
+
] : chunkOAAYF2EI_cjs.diffSequences(removed.split(""), added.split(""));
|
|
259
259
|
return (offset, assoc) => {
|
|
260
260
|
let b = from;
|
|
261
261
|
let a = from;
|
|
@@ -281,13 +281,13 @@ function replaceDocStep(next) {
|
|
|
281
281
|
const regionMaps = /* @__PURE__ */ new Map();
|
|
282
282
|
const map = (pos, assoc = 1) => {
|
|
283
283
|
const { block, region } = pos;
|
|
284
|
-
const survivor =
|
|
284
|
+
const survivor = chunk6H76FAI3_cjs.blockById(next, block);
|
|
285
285
|
if (survivor !== void 0) {
|
|
286
286
|
const key = JSON.stringify([block, region]);
|
|
287
287
|
let regionMap = regionMaps.get(key);
|
|
288
288
|
if (regionMap === void 0) {
|
|
289
|
-
const before =
|
|
290
|
-
regionMap = mapTextChange(before,
|
|
289
|
+
const before = chunk6H76FAI3_cjs.inlineText(chunk6H76FAI3_cjs.blockById(doc, block)?.regions[region] ?? []);
|
|
290
|
+
regionMap = mapTextChange(before, chunk6H76FAI3_cjs.inlineText(survivor.regions[region] ?? []));
|
|
291
291
|
regionMaps.set(key, regionMap);
|
|
292
292
|
}
|
|
293
293
|
const offset = regionMap(pos.offset, assoc);
|
|
@@ -321,10 +321,10 @@ function splitBlockStep(block, region, offset, created) {
|
|
|
321
321
|
type: created.type,
|
|
322
322
|
indent: created.indent,
|
|
323
323
|
attrs: created.attrs,
|
|
324
|
-
regions: { ...created.regions, [created.region]:
|
|
324
|
+
regions: { ...created.regions, [created.region]: chunk6H76FAI3_cjs.sliceInline(inline, offset, chunk6H76FAI3_cjs.inlineLength(inline)) }
|
|
325
325
|
};
|
|
326
|
-
const head = withRegion(target, region,
|
|
327
|
-
return { doc:
|
|
326
|
+
const head = withRegion(target, region, chunk6H76FAI3_cjs.sliceInline(inline, 0, offset));
|
|
327
|
+
return { doc: chunk6H76FAI3_cjs.replaceBlocks(doc, chunk6H76FAI3_cjs.indexOfBlock(doc, block), 1, [head, tail]), map };
|
|
328
328
|
},
|
|
329
329
|
invert: () => joinBlocksStep(block, region, created.id, created.region),
|
|
330
330
|
toJSON: () => ({ stepType: "splitBlock", block, region, offset, created })
|
|
@@ -336,17 +336,17 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
|
|
|
336
336
|
apply(doc) {
|
|
337
337
|
const first = requireBlock(doc, target);
|
|
338
338
|
const second = requireBlock(doc, source);
|
|
339
|
-
const index =
|
|
340
|
-
if (
|
|
339
|
+
const index = chunk6H76FAI3_cjs.indexOfBlock(doc, target);
|
|
340
|
+
if (chunk6H76FAI3_cjs.indexOfBlock(doc, source) !== index + 1) throw new StepError(`block "${source}" does not follow "${target}"`);
|
|
341
341
|
const head = requireRegion(first, targetRegion);
|
|
342
|
-
const length =
|
|
343
|
-
const merged =
|
|
342
|
+
const length = chunk6H76FAI3_cjs.inlineLength(head);
|
|
343
|
+
const merged = chunk6H76FAI3_cjs.replaceInline(head, length, length, requireRegion(second, sourceRegion));
|
|
344
344
|
const map = (pos) => pos.block === source ? { block: target, region: targetRegion, offset: length + (pos.region === sourceRegion ? pos.offset : 0) } : pos;
|
|
345
|
-
return { doc:
|
|
345
|
+
return { doc: chunk6H76FAI3_cjs.replaceBlocks(doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
|
|
346
346
|
},
|
|
347
347
|
invert(before) {
|
|
348
348
|
const { id, type, attrs, indent: indent2, regions } = requireBlock(before, source);
|
|
349
|
-
const length =
|
|
349
|
+
const length = chunk6H76FAI3_cjs.inlineLength(requireRegion(requireBlock(before, target), targetRegion));
|
|
350
350
|
const created = { id, type, attrs, indent: indent2, region: sourceRegion, regions };
|
|
351
351
|
return splitBlockStep(target, targetRegion, length, created);
|
|
352
352
|
},
|
|
@@ -355,9 +355,9 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
// src/engine/transform/step-json.ts
|
|
358
|
-
var isRegions = (value) =>
|
|
359
|
-
var isMark = (value) =>
|
|
360
|
-
var isBlockShape = (value) =>
|
|
358
|
+
var isRegions = (value) => chunk6H76FAI3_cjs.isRecord(value) && Object.values(value).every(Array.isArray);
|
|
359
|
+
var isMark = (value) => chunk6H76FAI3_cjs.isRecord(value) && typeof value.type === "string" && (value.attrs === void 0 || chunk6H76FAI3_cjs.isRecord(value.attrs));
|
|
360
|
+
var isBlockShape = (value) => chunk6H76FAI3_cjs.isRecord(value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && chunk6H76FAI3_cjs.isRecord(value.attrs);
|
|
361
361
|
var isBlock = (value) => isBlockShape(value) && isRegions(value.regions);
|
|
362
362
|
var isCreated = (value) => isBlockShape(value) && typeof value.region === "string" && (value.regions === void 0 || isRegions(value.regions));
|
|
363
363
|
var isString = (value) => typeof value === "string";
|
|
@@ -369,7 +369,7 @@ function docOf(blocks) {
|
|
|
369
369
|
if (new Set(blocks.map((block) => block.id)).size !== blocks.length) {
|
|
370
370
|
throw new StepError("a replaceDoc step repeats a block id");
|
|
371
371
|
}
|
|
372
|
-
return
|
|
372
|
+
return chunk6H76FAI3_cjs.createDoc(blocks);
|
|
373
373
|
}
|
|
374
374
|
function reader(json) {
|
|
375
375
|
return (key, accept) => {
|
|
@@ -406,7 +406,7 @@ function stepFromJSON(json) {
|
|
|
406
406
|
read("mark", isMarkOrType)
|
|
407
407
|
);
|
|
408
408
|
case "setAttrs":
|
|
409
|
-
return setAttrsStep(read("block", isString), patchFromJSON(read("patch",
|
|
409
|
+
return setAttrsStep(read("block", isString), patchFromJSON(read("patch", chunk6H76FAI3_cjs.isRecord)));
|
|
410
410
|
case "setIndent":
|
|
411
411
|
return setIndentStep(read("block", isString), read("indent", isInteger));
|
|
412
412
|
case "insertBlocks":
|
|
@@ -440,7 +440,7 @@ function stepFromJSON(json) {
|
|
|
440
440
|
|
|
441
441
|
// src/engine/model/position.ts
|
|
442
442
|
function comparePos(doc, a, b) {
|
|
443
|
-
return
|
|
443
|
+
return chunk6H76FAI3_cjs.requireBlockIndex(doc, a.block) - chunk6H76FAI3_cjs.requireBlockIndex(doc, b.block) || chunk6H76FAI3_cjs.compareRegionNames(a.region, b.region) || a.offset - b.offset;
|
|
444
444
|
}
|
|
445
445
|
function orderedRange(doc, anchor, head) {
|
|
446
446
|
return comparePos(doc, anchor, head) <= 0 ? { from: anchor, to: head } : { from: head, to: anchor };
|
|
@@ -479,7 +479,7 @@ function selectedBlockIds(doc, selection) {
|
|
|
479
479
|
if (selection === null) return [];
|
|
480
480
|
if (selection.kind === "node") return [selection.block];
|
|
481
481
|
const ends = selection.kind === "text" ? [selection.anchor.block, selection.head.block] : [selection.anchor, selection.head];
|
|
482
|
-
const [first, second] = ends.map((id) =>
|
|
482
|
+
const [first, second] = ends.map((id) => chunk6H76FAI3_cjs.requireBlockIndex(doc, id));
|
|
483
483
|
return doc.blocks.slice(Math.min(first, second), Math.max(first, second) + 1).map((block) => block.id);
|
|
484
484
|
}
|
|
485
485
|
function isBackward(doc, selection) {
|
|
@@ -487,7 +487,7 @@ function isBackward(doc, selection) {
|
|
|
487
487
|
const { anchor, head } = selection;
|
|
488
488
|
return doc.index.has(anchor.block) && doc.index.has(head.block) && comparePos(doc, anchor, head) > 0;
|
|
489
489
|
}
|
|
490
|
-
return doc.index.has(selection.anchor) && doc.index.has(selection.head) &&
|
|
490
|
+
return doc.index.has(selection.anchor) && doc.index.has(selection.head) && chunk6H76FAI3_cjs.indexOfBlock(doc, selection.anchor) > chunk6H76FAI3_cjs.indexOfBlock(doc, selection.head);
|
|
491
491
|
}
|
|
492
492
|
var blockProbe = (block) => ({ block, region: "", offset: 0 });
|
|
493
493
|
function mapSelection(selection, map, doc) {
|
|
@@ -506,18 +506,18 @@ function mapSelection(selection, map, doc) {
|
|
|
506
506
|
return anchor === selection.anchor && head === selection.head ? selection : textSelection(anchor, head);
|
|
507
507
|
}
|
|
508
508
|
function primaryRegion(schema, block) {
|
|
509
|
-
const spec =
|
|
509
|
+
const spec = chunk6H76FAI3_cjs.specFor(schema, block.type);
|
|
510
510
|
if (spec.flow === "text" && spec.primaryRegion !== void 0 && Object.hasOwn(block.regions, spec.primaryRegion)) {
|
|
511
511
|
return spec.primaryRegion;
|
|
512
512
|
}
|
|
513
513
|
return firstRegion(block);
|
|
514
514
|
}
|
|
515
515
|
function flowEdge(schema, block, atEnd) {
|
|
516
|
-
const region =
|
|
517
|
-
return region === null ? null : { block: block.id, region, offset: atEnd ?
|
|
516
|
+
const region = chunk6H76FAI3_cjs.specFor(schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
|
|
517
|
+
return region === null ? null : { block: block.id, region, offset: atEnd ? chunk6H76FAI3_cjs.inlineLength(block.regions[region]) : 0 };
|
|
518
518
|
}
|
|
519
519
|
function edge(doc, schema, blockId, atEnd) {
|
|
520
|
-
const block = doc.blocks[
|
|
520
|
+
const block = doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, blockId)];
|
|
521
521
|
const flow = flowEdge(schema, block, atEnd);
|
|
522
522
|
if (flow !== null) return textSelection(flow);
|
|
523
523
|
if (Object.keys(block.regions).length === 0) return nodeSelection(blockId);
|
|
@@ -533,13 +533,13 @@ function defaultSelection(doc, schema) {
|
|
|
533
533
|
return doc.blocks.length === 0 ? null : startOf(doc, schema, doc.blocks[0].id);
|
|
534
534
|
}
|
|
535
535
|
function validatePos(doc, schema, pos) {
|
|
536
|
-
const block =
|
|
536
|
+
const block = chunk6H76FAI3_cjs.blockById(doc, pos.block);
|
|
537
537
|
if (block === void 0) return null;
|
|
538
538
|
if (!Object.hasOwn(block.regions, pos.region)) {
|
|
539
539
|
const region = primaryRegion(schema, block);
|
|
540
540
|
return region === null ? nodeSelection(block.id) : { block: block.id, region, offset: 0 };
|
|
541
541
|
}
|
|
542
|
-
const length =
|
|
542
|
+
const length = chunk6H76FAI3_cjs.inlineLength(block.regions[pos.region]);
|
|
543
543
|
return pos.offset >= 0 && pos.offset <= length ? pos : { ...pos, offset: Math.min(Math.max(pos.offset, 0), length) };
|
|
544
544
|
}
|
|
545
545
|
function nearestFlow(doc, schema, from, to, atEnd) {
|
|
@@ -550,14 +550,14 @@ function nearestFlow(doc, schema, from, to, atEnd) {
|
|
|
550
550
|
}
|
|
551
551
|
return null;
|
|
552
552
|
}
|
|
553
|
-
var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[
|
|
553
|
+
var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, pos.block)], false)?.region === pos.region;
|
|
554
554
|
function clampToFlow(doc, schema, selection) {
|
|
555
555
|
const { anchor, head } = selection;
|
|
556
556
|
if (anchor.block === head.block) return selection;
|
|
557
557
|
const backward = comparePos(doc, anchor, head) > 0;
|
|
558
558
|
const [from, to] = backward ? [head, anchor] : [anchor, head];
|
|
559
|
-
const first =
|
|
560
|
-
const last =
|
|
559
|
+
const first = chunk6H76FAI3_cjs.requireBlockIndex(doc, from.block);
|
|
560
|
+
const last = chunk6H76FAI3_cjs.requireBlockIndex(doc, to.block);
|
|
561
561
|
const start = inFlow(doc, schema, from) ? from : nearestFlow(doc, schema, first + 1, last, false);
|
|
562
562
|
const end = inFlow(doc, schema, to) ? to : nearestFlow(doc, schema, last - 1, first, true);
|
|
563
563
|
if (start === from && end === to) return selection;
|
|
@@ -576,9 +576,9 @@ function validateText(doc, schema, selection) {
|
|
|
576
576
|
return clampToFlow(doc, schema, valid);
|
|
577
577
|
}
|
|
578
578
|
function validateNode(doc, schema, selection) {
|
|
579
|
-
const block =
|
|
579
|
+
const block = chunk6H76FAI3_cjs.blockById(doc, selection.block);
|
|
580
580
|
if (block === void 0) return defaultSelection(doc, schema);
|
|
581
|
-
return
|
|
581
|
+
return chunk6H76FAI3_cjs.specFor(schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
|
|
582
582
|
}
|
|
583
583
|
function validateSelection(doc, schema, selection) {
|
|
584
584
|
if (doc.blocks.length === 0) return null;
|
|
@@ -609,7 +609,7 @@ function hidingToggle(doc, index, isClosed = isClosedToggle) {
|
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
// src/engine/state/visible-selection.ts
|
|
612
|
-
var hiderOf = (doc, id) => hidingToggle(doc,
|
|
612
|
+
var hiderOf = (doc, id) => hidingToggle(doc, chunk6H76FAI3_cjs.requireBlockIndex(doc, id) + 1);
|
|
613
613
|
function toggleEnd(doc, schema, toggle) {
|
|
614
614
|
const end = endOf(doc, schema, doc.blocks[toggle].id);
|
|
615
615
|
return end.kind === "text" ? end.head : blockEnd(doc.blocks[toggle]);
|
|
@@ -623,7 +623,7 @@ function visibleText(doc, schema, selection) {
|
|
|
623
623
|
}
|
|
624
624
|
function visibleBlocks(doc, schema, selection) {
|
|
625
625
|
const ids = [selection.anchor, selection.head];
|
|
626
|
-
const indexes = ids.map((id) =>
|
|
626
|
+
const indexes = ids.map((id) => chunk6H76FAI3_cjs.requireBlockIndex(doc, id));
|
|
627
627
|
const from = Math.min(...indexes);
|
|
628
628
|
const to = Math.max(...indexes);
|
|
629
629
|
const hiders = indexes.map((index) => hidingToggle(doc, index + 1));
|
|
@@ -804,8 +804,8 @@ var Transaction = class {
|
|
|
804
804
|
// src/engine/commands/caret-marks.ts
|
|
805
805
|
function caretMarks(doc, schema, storedMarks, pos) {
|
|
806
806
|
if (storedMarks !== null) return storedMarks;
|
|
807
|
-
const inline =
|
|
808
|
-
return
|
|
807
|
+
const inline = chunk6H76FAI3_cjs.blockById(doc, pos.block)?.regions[pos.region] ?? [];
|
|
808
|
+
return chunk6H76FAI3_cjs.marksAt(inline, pos.offset, (mark) => schema.marks.get(mark.type)?.inclusive ?? true);
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
// src/engine/commands/run-commands.ts
|
|
@@ -949,7 +949,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
949
949
|
const { steps, undoText, at, marks } = record;
|
|
950
950
|
const tr = new Transaction(state).setMeta(UNFILTERED, true);
|
|
951
951
|
steps.forEach((step) => tr.step(step));
|
|
952
|
-
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [
|
|
952
|
+
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [chunk6H76FAI3_cjs.text(undoText, marks)]));
|
|
953
953
|
dispatch(tr.setSelection(textSelection({ ...at, offset: at.offset + undoText.length })));
|
|
954
954
|
}
|
|
955
955
|
return true;
|
|
@@ -958,7 +958,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
958
958
|
// src/engine/commands/block-helpers.ts
|
|
959
959
|
var ITEM_KINDS = /* @__PURE__ */ new Set(["bullet", "ordered", "task", "quote"]);
|
|
960
960
|
function specOf(schema, block) {
|
|
961
|
-
return
|
|
961
|
+
return chunk6H76FAI3_cjs.specFor(schema, block.type);
|
|
962
962
|
}
|
|
963
963
|
function isTextFlow(schema, block) {
|
|
964
964
|
return specOf(schema, block).flow === "text";
|
|
@@ -970,7 +970,7 @@ function isItem(block) {
|
|
|
970
970
|
return block.type === "MARKDOWN" && typeof block.attrs.kind === "string" && ITEM_KINDS.has(block.attrs.kind);
|
|
971
971
|
}
|
|
972
972
|
function regionLength(block, region) {
|
|
973
|
-
return Object.hasOwn(block.regions, region) ?
|
|
973
|
+
return Object.hasOwn(block.regions, region) ? chunk6H76FAI3_cjs.inlineLength(block.regions[region]) : 0;
|
|
974
974
|
}
|
|
975
975
|
function descendantsEnd(doc, index) {
|
|
976
976
|
const { indent: indent2 } = doc.blocks[index];
|
|
@@ -978,8 +978,8 @@ function descendantsEnd(doc, index) {
|
|
|
978
978
|
while (end < doc.blocks.length && doc.blocks[end].indent > indent2) end++;
|
|
979
979
|
return end;
|
|
980
980
|
}
|
|
981
|
-
function createBlock(schema, type, attrs = {}, indent2 = 0, id =
|
|
982
|
-
const initial =
|
|
981
|
+
function createBlock(schema, type, attrs = {}, indent2 = 0, id = chunk6H76FAI3_cjs.newId()) {
|
|
982
|
+
const initial = chunk6H76FAI3_cjs.specFor(schema, type).initial();
|
|
983
983
|
return { id, type, indent: indent2, attrs: { ...initial.attrs, ...attrs }, regions: initial.regions };
|
|
984
984
|
}
|
|
985
985
|
function withContent(schema, block, content) {
|
|
@@ -997,7 +997,7 @@ function headBlockId(selection) {
|
|
|
997
997
|
function selectedBlockRange(doc, selection) {
|
|
998
998
|
const ids = selectedBlockIds(doc, selection);
|
|
999
999
|
if (ids.length === 0) return null;
|
|
1000
|
-
const start =
|
|
1000
|
+
const start = chunk6H76FAI3_cjs.indexOfBlock(doc, ids[0]);
|
|
1001
1001
|
let end = start + ids.length;
|
|
1002
1002
|
for (let index = start; index < start + ids.length; index++) end = Math.max(end, descendantsEnd(doc, index));
|
|
1003
1003
|
return { start, end };
|
|
@@ -1041,7 +1041,7 @@ function shiftSubtree(tr, index, delta) {
|
|
|
1041
1041
|
// src/engine/commands/block-structure.ts
|
|
1042
1042
|
var toggleTask = (state, dispatch) => {
|
|
1043
1043
|
const { doc, selection } = state;
|
|
1044
|
-
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[
|
|
1044
|
+
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
|
|
1045
1045
|
if (tasks.length === 0) return false;
|
|
1046
1046
|
const checked = !tasks.every((block) => block.attrs.checked === true);
|
|
1047
1047
|
const tr = new Transaction(state);
|
|
@@ -1106,7 +1106,7 @@ function copiedSelection(selection, copies) {
|
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
1108
|
function duplicateBlocks(options = {}) {
|
|
1109
|
-
const makeId = options.newId ??
|
|
1109
|
+
const makeId = options.newId ?? chunk6H76FAI3_cjs.newId;
|
|
1110
1110
|
return (state, dispatch) => {
|
|
1111
1111
|
const { doc, selection } = state;
|
|
1112
1112
|
const range = selectedBlockRange(doc, selection);
|
|
@@ -1128,12 +1128,12 @@ var deleteBlocks = (state, dispatch) => {
|
|
|
1128
1128
|
return true;
|
|
1129
1129
|
};
|
|
1130
1130
|
function insertBlockAfter(type, attrs, options = {}) {
|
|
1131
|
-
const makeId = options.newId ??
|
|
1131
|
+
const makeId = options.newId ?? chunk6H76FAI3_cjs.newId;
|
|
1132
1132
|
return (state, dispatch) => {
|
|
1133
1133
|
const { doc, schema } = state;
|
|
1134
1134
|
const id = headBlockId(state.selection);
|
|
1135
1135
|
if (id === null) return false;
|
|
1136
|
-
const index =
|
|
1136
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(doc, id);
|
|
1137
1137
|
const current = doc.blocks[index];
|
|
1138
1138
|
const fillsCurrent = isParagraph(current) && regionLength(current, primaryRegion(schema, current) ?? "") === 0;
|
|
1139
1139
|
const block = createBlock(schema, type, attrs, current.indent, fillsCurrent ? current.id : makeId());
|
|
@@ -1153,10 +1153,10 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1153
1153
|
clear(tr, from, from.offset, to.offset);
|
|
1154
1154
|
return from;
|
|
1155
1155
|
}
|
|
1156
|
-
const block = tr.doc.blocks[
|
|
1156
|
+
const block = tr.doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, from.block)];
|
|
1157
1157
|
clear(tr, from, from.offset, regionLength(block, from.region));
|
|
1158
1158
|
for (const region of Object.keys(block.regions)) {
|
|
1159
|
-
const between =
|
|
1159
|
+
const between = chunk6H76FAI3_cjs.compareRegionNames(from.region, region) < 0 && chunk6H76FAI3_cjs.compareRegionNames(region, to.region) < 0;
|
|
1160
1160
|
if (between) clear(tr, { ...from, region }, 0, regionLength(block, region));
|
|
1161
1161
|
}
|
|
1162
1162
|
clear(tr, to, 0, to.offset);
|
|
@@ -1165,8 +1165,8 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1165
1165
|
function deleteRange(tr, schema, from, to, newId2) {
|
|
1166
1166
|
if (from.block === to.block) return deleteWithinBlock(tr, from, to);
|
|
1167
1167
|
const { doc } = tr;
|
|
1168
|
-
const start =
|
|
1169
|
-
const end =
|
|
1168
|
+
const start = chunk6H76FAI3_cjs.requireBlockIndex(doc, from.block);
|
|
1169
|
+
const end = chunk6H76FAI3_cjs.requireBlockIndex(doc, to.block);
|
|
1170
1170
|
const first = doc.blocks[start];
|
|
1171
1171
|
const last = doc.blocks[end];
|
|
1172
1172
|
const keepFirst = isTextFlow(schema, first);
|
|
@@ -1193,7 +1193,7 @@ function deleteRange(tr, schema, from, to, newId2) {
|
|
|
1193
1193
|
|
|
1194
1194
|
// src/engine/commands/insert-text-at.ts
|
|
1195
1195
|
function insertTextAt(tr, schema, pos, value) {
|
|
1196
|
-
const slice = [
|
|
1196
|
+
const slice = [chunk6H76FAI3_cjs.text(value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
|
|
1197
1197
|
tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, slice));
|
|
1198
1198
|
return { ...pos, offset: pos.offset + value.length };
|
|
1199
1199
|
}
|
|
@@ -1205,12 +1205,12 @@ function replaceBlocksWithText(tr, schema, range, value, makeId) {
|
|
|
1205
1205
|
const indent2 = range === null ? 0 : doc.blocks[index].indent;
|
|
1206
1206
|
if (range !== null) tr.step(removeBlocksStep(index, range.end - range.start));
|
|
1207
1207
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, indent2, makeId());
|
|
1208
|
-
const paragraph = withContent(schema, empty, [
|
|
1208
|
+
const paragraph = withContent(schema, empty, [chunk6H76FAI3_cjs.text(value)]);
|
|
1209
1209
|
tr.step(insertBlocksStep(index, [paragraph]));
|
|
1210
1210
|
tr.setSelection(endOf(tr.doc, schema, paragraph.id));
|
|
1211
1211
|
}
|
|
1212
1212
|
function insertText(value, options = {}) {
|
|
1213
|
-
const makeId = options.newId ??
|
|
1213
|
+
const makeId = options.newId ?? chunk6H76FAI3_cjs.newId;
|
|
1214
1214
|
return (state, dispatch) => {
|
|
1215
1215
|
if (value === "") return false;
|
|
1216
1216
|
const { doc, schema, selection } = state;
|
|
@@ -1233,9 +1233,9 @@ function markExtent(inline, offset, type) {
|
|
|
1233
1233
|
let position = 0;
|
|
1234
1234
|
for (const node of inline) {
|
|
1235
1235
|
starts.push(position);
|
|
1236
|
-
position +=
|
|
1236
|
+
position += chunk6H76FAI3_cjs.nodeLength(node);
|
|
1237
1237
|
}
|
|
1238
|
-
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] +
|
|
1238
|
+
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + chunk6H76FAI3_cjs.nodeLength(node));
|
|
1239
1239
|
const markOf = (index) => inline[index]?.marks.find((mark2) => mark2.type === type);
|
|
1240
1240
|
let seed = containing(offset);
|
|
1241
1241
|
let mark = markOf(seed);
|
|
@@ -1244,29 +1244,29 @@ function markExtent(inline, offset, type) {
|
|
|
1244
1244
|
mark = markOf(seed);
|
|
1245
1245
|
}
|
|
1246
1246
|
if (mark === void 0) return null;
|
|
1247
|
-
const shares = (index) => inline[index].marks.some((other) =>
|
|
1247
|
+
const shares = (index) => inline[index].marks.some((other) => chunk6H76FAI3_cjs.sameMark(other, mark));
|
|
1248
1248
|
let first = seed;
|
|
1249
1249
|
while (first > 0 && shares(first - 1)) first--;
|
|
1250
1250
|
let last = seed;
|
|
1251
1251
|
while (last < inline.length - 1 && shares(last + 1)) last++;
|
|
1252
|
-
return { from: starts[first], to: starts[last] +
|
|
1252
|
+
return { from: starts[first], to: starts[last] + chunk6H76FAI3_cjs.nodeLength(inline[last]) };
|
|
1253
1253
|
}
|
|
1254
1254
|
|
|
1255
1255
|
// src/engine/commands/storable-mark.ts
|
|
1256
1256
|
function readsBack(inline) {
|
|
1257
|
-
return
|
|
1257
|
+
return chunk6H76FAI3_cjs.equalInline(chunk6H76FAI3_cjs.parseInline(chunk6H76FAI3_cjs.serializeInline(inline)), chunk6H76FAI3_cjs.normalizeInline(inline));
|
|
1258
1258
|
}
|
|
1259
1259
|
function safeLink(mark) {
|
|
1260
1260
|
const href = mark.attrs?.href;
|
|
1261
|
-
const safe = typeof href === "string" ?
|
|
1261
|
+
const safe = typeof href === "string" ? chunk6H76FAI3_cjs.sanitizeHref(href) : null;
|
|
1262
1262
|
return safe ? { type: "link", attrs: { ...mark.attrs, href: safe } } : null;
|
|
1263
1263
|
}
|
|
1264
1264
|
function storableMark(mark) {
|
|
1265
1265
|
const candidate = mark.type === "link" ? safeLink(mark) : mark;
|
|
1266
|
-
return candidate !== null && readsBack([
|
|
1266
|
+
return candidate !== null && readsBack([chunk6H76FAI3_cjs.text("a", [candidate])]) ? candidate : null;
|
|
1267
1267
|
}
|
|
1268
1268
|
function storableAtom(type, attrs) {
|
|
1269
|
-
return readsBack([
|
|
1269
|
+
return readsBack([chunk6H76FAI3_cjs.atom(type, attrs)]);
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
1272
|
// src/engine/commands/selection-marks.ts
|
|
@@ -1285,8 +1285,8 @@ function textRanges(state, selection) {
|
|
|
1285
1285
|
if (from.region !== to.region) return [];
|
|
1286
1286
|
return [{ block: from.block, region: from.region, from: from.offset, to: to.offset }];
|
|
1287
1287
|
}
|
|
1288
|
-
const first =
|
|
1289
|
-
const last =
|
|
1288
|
+
const first = chunk6H76FAI3_cjs.requireBlockIndex(doc, from.block);
|
|
1289
|
+
const last = chunk6H76FAI3_cjs.requireBlockIndex(doc, to.block);
|
|
1290
1290
|
return doc.blocks.slice(first, last + 1).flatMap((block, i) => {
|
|
1291
1291
|
const whole = wholeRegion(schema, block);
|
|
1292
1292
|
if (whole === null) return [];
|
|
@@ -1298,7 +1298,7 @@ function textRanges(state, selection) {
|
|
|
1298
1298
|
function selectionRanges(state, selection) {
|
|
1299
1299
|
if (selection.kind === "text") return textRanges(state, selection);
|
|
1300
1300
|
return selectedBlockIds(state.doc, selection).flatMap((id) => {
|
|
1301
|
-
const whole = wholeRegion(state.schema, state.doc.blocks[
|
|
1301
|
+
const whole = wholeRegion(state.schema, state.doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(state.doc, id)]);
|
|
1302
1302
|
return whole === null ? [] : [whole];
|
|
1303
1303
|
});
|
|
1304
1304
|
}
|
|
@@ -1307,8 +1307,8 @@ function markRanges(state) {
|
|
|
1307
1307
|
return selection === null ? [] : selectionRanges(state, selection).filter((range) => range.from < range.to);
|
|
1308
1308
|
}
|
|
1309
1309
|
function rangeContent(state, range) {
|
|
1310
|
-
const inline =
|
|
1311
|
-
return
|
|
1310
|
+
const inline = chunk6H76FAI3_cjs.blockById(state.doc, range.block)?.regions[range.region] ?? [];
|
|
1311
|
+
return chunk6H76FAI3_cjs.sliceInline(inline, range.from, range.to);
|
|
1312
1312
|
}
|
|
1313
1313
|
function markCoverage(content, type, attrs) {
|
|
1314
1314
|
const carries = (node) => node.marks.some((mark) => matchesMark(mark, type, attrs));
|
|
@@ -1351,8 +1351,8 @@ function applyMark(type, attrs, mode) {
|
|
|
1351
1351
|
const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
|
|
1352
1352
|
const active = current.some((existing) => matchesMark(existing, type, mark.attrs));
|
|
1353
1353
|
const remove2 = mode === "remove" || mode === "toggle" && active;
|
|
1354
|
-
const next = remove2 ?
|
|
1355
|
-
if (
|
|
1354
|
+
const next = remove2 ? chunk6H76FAI3_cjs.removeMark(current, target) : chunk6H76FAI3_cjs.addMark(current, mark);
|
|
1355
|
+
if (chunk6H76FAI3_cjs.sameMarkSet(next, current)) return false;
|
|
1356
1356
|
dispatch?.(new Transaction(state).setStoredMarks(next));
|
|
1357
1357
|
return true;
|
|
1358
1358
|
}
|
|
@@ -1376,17 +1376,17 @@ function unsetMark(type) {
|
|
|
1376
1376
|
function linkRanges(state) {
|
|
1377
1377
|
const caret = collapsedCaret(state);
|
|
1378
1378
|
if (caret === null) return markRanges(state);
|
|
1379
|
-
const inline =
|
|
1379
|
+
const inline = chunk6H76FAI3_cjs.blockById(state.doc, caret.block)?.regions[caret.region] ?? [];
|
|
1380
1380
|
const extent = markExtent(inline, caret.offset, "link");
|
|
1381
1381
|
return extent === null ? [] : [{ block: caret.block, region: caret.region, ...extent }];
|
|
1382
1382
|
}
|
|
1383
1383
|
function setLink(href, title) {
|
|
1384
|
-
const safe =
|
|
1384
|
+
const safe = chunk6H76FAI3_cjs.sanitizeHref(href);
|
|
1385
1385
|
return (state, dispatch) => {
|
|
1386
1386
|
if (safe === null || safe === "") return false;
|
|
1387
1387
|
const link = { type: "link", attrs: title ? { href: safe, title } : { href: safe } };
|
|
1388
1388
|
return editRanges(state, dispatch, linkRanges(state), (tr, { block, region, from, to }, content) => {
|
|
1389
|
-
const linked2 = content.every((node) => node.marks.some((mark) =>
|
|
1389
|
+
const linked2 = content.every((node) => node.marks.some((mark) => chunk6H76FAI3_cjs.sameMark(mark, link)));
|
|
1390
1390
|
if (!linked2) tr.step(addMarkStep(block, region, from, to, link));
|
|
1391
1391
|
});
|
|
1392
1392
|
};
|
|
@@ -1416,7 +1416,7 @@ function insertAtom(type, attrs) {
|
|
|
1416
1416
|
const tr = new Transaction(state);
|
|
1417
1417
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
1418
1418
|
const caret = deleteRange(tr, schema, from, to);
|
|
1419
|
-
const node =
|
|
1419
|
+
const node = chunk6H76FAI3_cjs.atom(type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
|
|
1420
1420
|
tr.step(replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [node]));
|
|
1421
1421
|
tr.setSelection(textSelection({ ...caret, offset: caret.offset + 1 }));
|
|
1422
1422
|
dispatch?.(tr);
|
|
@@ -1434,19 +1434,19 @@ var TEXT_ATTRIBUTE = /* @__PURE__ */ new Map([
|
|
|
1434
1434
|
["MATH", "latex"]
|
|
1435
1435
|
]);
|
|
1436
1436
|
function holdsText(schema, type) {
|
|
1437
|
-
return TEXT_ATTRIBUTE.has(type) ||
|
|
1437
|
+
return TEXT_ATTRIBUTE.has(type) || chunk6H76FAI3_cjs.specFor(schema, type).flow === "text";
|
|
1438
1438
|
}
|
|
1439
1439
|
function sourceContent(schema, block) {
|
|
1440
1440
|
const field = TEXT_ATTRIBUTE.get(block.type);
|
|
1441
1441
|
if (field !== void 0) {
|
|
1442
1442
|
const value = block.attrs[field];
|
|
1443
|
-
return typeof value === "string" && value !== "" ? [
|
|
1443
|
+
return typeof value === "string" && value !== "" ? [chunk6H76FAI3_cjs.text(value)] : [];
|
|
1444
1444
|
}
|
|
1445
1445
|
const region = primaryRegion(schema, block);
|
|
1446
1446
|
return region === null ? [] : block.regions[region];
|
|
1447
1447
|
}
|
|
1448
1448
|
function plainText(schema, content) {
|
|
1449
|
-
return
|
|
1449
|
+
return chunk6H76FAI3_cjs.inlineText(content, (node) => schema.atoms.get(node.type)?.plainText(node.attrs) ?? "");
|
|
1450
1450
|
}
|
|
1451
1451
|
function convert(schema, block, type, attrs) {
|
|
1452
1452
|
const content = sourceContent(schema, block);
|
|
@@ -1465,7 +1465,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1465
1465
|
if (!holdsText(schema, type)) return false;
|
|
1466
1466
|
const ids = selectedBlockIds(doc, selection);
|
|
1467
1467
|
const convertible = (block) => isTextFlow(schema, block) || selection?.kind === "node" && TEXT_ATTRIBUTE.has(block.type);
|
|
1468
|
-
const blocks = ids.flatMap((id) =>
|
|
1468
|
+
const blocks = ids.flatMap((id) => chunk6H76FAI3_cjs.blockById(doc, id) ?? []).filter(convertible);
|
|
1469
1469
|
if (blocks.length === 0) return false;
|
|
1470
1470
|
const tr = new Transaction(state);
|
|
1471
1471
|
const moved2 = /* @__PURE__ */ new Map();
|
|
@@ -1479,7 +1479,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1479
1479
|
tr.step(replaceBlockStep(next));
|
|
1480
1480
|
const from = primaryRegion(schema, block);
|
|
1481
1481
|
const to = primaryRegion(schema, next);
|
|
1482
|
-
if (from !== null && to !== null) moved2.set(block.id, { from, to, length:
|
|
1482
|
+
if (from !== null && to !== null) moved2.set(block.id, { from, to, length: chunk6H76FAI3_cjs.inlineLength(next.regions[to]) });
|
|
1483
1483
|
}
|
|
1484
1484
|
if (!tr.docChanged) return false;
|
|
1485
1485
|
if (selection?.kind === "text" && moved2.size > 0) {
|
|
@@ -1490,7 +1490,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1490
1490
|
};
|
|
1491
1491
|
tr.setSelection(textSelection(carry(selection.anchor), carry(selection.head)));
|
|
1492
1492
|
}
|
|
1493
|
-
const converted = selection?.kind === "node" ?
|
|
1493
|
+
const converted = selection?.kind === "node" ? chunk6H76FAI3_cjs.blockById(tr.doc, selection.block) : void 0;
|
|
1494
1494
|
if (converted !== void 0 && isTextFlow(schema, converted)) tr.setSelection(endOf(tr.doc, schema, converted.id));
|
|
1495
1495
|
dispatch?.(tr);
|
|
1496
1496
|
return true;
|
|
@@ -1508,10 +1508,10 @@ function ruleTransaction(state, rules, context) {
|
|
|
1508
1508
|
const { selection, doc } = state;
|
|
1509
1509
|
if (selection?.kind !== "text") return null;
|
|
1510
1510
|
const { block: id, region, offset } = selection.head;
|
|
1511
|
-
const block = doc.blocks[
|
|
1511
|
+
const block = doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, id)];
|
|
1512
1512
|
const inline = block.regions[region];
|
|
1513
|
-
if (
|
|
1514
|
-
const before =
|
|
1513
|
+
if (chunk6H76FAI3_cjs.hasMark(chunk6H76FAI3_cjs.marksAt(inline, offset, () => true), "code")) return null;
|
|
1514
|
+
const before = chunk6H76FAI3_cjs.inlineText(chunk6H76FAI3_cjs.sliceInline(inline, 0, offset));
|
|
1515
1515
|
for (const rule of rules) {
|
|
1516
1516
|
const match = appliesTo(rule, block) ? rule.match.exec(before) : null;
|
|
1517
1517
|
if (match === null) continue;
|
|
@@ -1521,7 +1521,7 @@ function ruleTransaction(state, rules, context) {
|
|
|
1521
1521
|
return null;
|
|
1522
1522
|
}
|
|
1523
1523
|
function insertTextWithRules(value, rules, options = {}) {
|
|
1524
|
-
const context = { newId: options.newId ??
|
|
1524
|
+
const context = { newId: options.newId ?? chunk6H76FAI3_cjs.newId };
|
|
1525
1525
|
const insert = insertText(value, { origin: "input", newId: context.newId });
|
|
1526
1526
|
return (state, dispatch) => {
|
|
1527
1527
|
let fired = false;
|
|
@@ -1569,11 +1569,11 @@ var divider = {
|
|
|
1569
1569
|
kinds: PARAGRAPH,
|
|
1570
1570
|
handler(state, _match, range, context) {
|
|
1571
1571
|
const { doc, schema } = state;
|
|
1572
|
-
const index =
|
|
1572
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(doc, range.block);
|
|
1573
1573
|
const block = doc.blocks[index];
|
|
1574
1574
|
const content = block.regions[range.region];
|
|
1575
|
-
const tail =
|
|
1576
|
-
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ??
|
|
1575
|
+
const tail = chunk6H76FAI3_cjs.sliceInline(content, range.to, chunk6H76FAI3_cjs.inlineLength(content));
|
|
1576
|
+
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ?? chunk6H76FAI3_cjs.newId)());
|
|
1577
1577
|
const next = withContent(schema, empty, tail);
|
|
1578
1578
|
const tr = new Transaction(state);
|
|
1579
1579
|
tr.step(replaceBlockStep(createBlock(schema, "DIVIDER", {}, block.indent, block.id)));
|
|
@@ -1609,7 +1609,7 @@ var blockInputRules = [
|
|
|
1609
1609
|
|
|
1610
1610
|
// src/engine/markdown/autolink-href.ts
|
|
1611
1611
|
function autolinkHref(url) {
|
|
1612
|
-
return
|
|
1612
|
+
return chunk6H76FAI3_cjs.sanitizeHref(/^www\./i.test(url) ? `https://${url}` : url);
|
|
1613
1613
|
}
|
|
1614
1614
|
|
|
1615
1615
|
// src/engine/markdown/trim-url-end.ts
|
|
@@ -1631,12 +1631,12 @@ function trimUrlEnd(url) {
|
|
|
1631
1631
|
|
|
1632
1632
|
// src/engine/rules/region-inline.ts
|
|
1633
1633
|
function regionInline(state, range) {
|
|
1634
|
-
return state.doc.blocks[
|
|
1634
|
+
return state.doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(state.doc, range.block)].regions[range.region];
|
|
1635
1635
|
}
|
|
1636
1636
|
|
|
1637
1637
|
// src/engine/rules/touches-mark.ts
|
|
1638
1638
|
function touchesMark(inline, from, to, type) {
|
|
1639
|
-
return
|
|
1639
|
+
return chunk6H76FAI3_cjs.sliceInline(inline, from, to).some((node) => chunk6H76FAI3_cjs.hasMark(node.marks, type));
|
|
1640
1640
|
}
|
|
1641
1641
|
|
|
1642
1642
|
// src/engine/rules/autolink.ts
|
|
@@ -1670,7 +1670,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1670
1670
|
const contentTo = to - (close?.(found) ?? open);
|
|
1671
1671
|
const contentFrom = contentTo - found[1].length;
|
|
1672
1672
|
const from = contentFrom - open;
|
|
1673
|
-
if (wordBounded && WORD_CHARACTER.test(
|
|
1673
|
+
if (wordBounded && WORD_CHARACTER.test(chunk6H76FAI3_cjs.inlineText(chunk6H76FAI3_cjs.sliceInline(inline, to, to + 1)))) return null;
|
|
1674
1674
|
if (touchesMark(inline, from, contentFrom, "code") || touchesMark(inline, contentTo, to, "code")) return null;
|
|
1675
1675
|
const tr = new Transaction(state);
|
|
1676
1676
|
tr.step(addMarkStep(block, region, contentFrom, contentTo, added));
|
|
@@ -1678,7 +1678,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1678
1678
|
tr.step(replaceInlineStep(block, region, from, contentFrom, []));
|
|
1679
1679
|
const caret = { block, region, offset: from + found[1].length };
|
|
1680
1680
|
const carried = caretMarks(tr.doc, state.schema, null, caret);
|
|
1681
|
-
return tr.setSelection(textSelection(caret)).setStoredMarks(
|
|
1681
|
+
return tr.setSelection(textSelection(caret)).setStoredMarks(chunk6H76FAI3_cjs.removeMark(carried, added.type));
|
|
1682
1682
|
}
|
|
1683
1683
|
};
|
|
1684
1684
|
}
|
|
@@ -1699,7 +1699,7 @@ var markInputRules = [
|
|
|
1699
1699
|
open: 1,
|
|
1700
1700
|
close: (match) => match[2].length + 3,
|
|
1701
1701
|
mark(match) {
|
|
1702
|
-
const href =
|
|
1702
|
+
const href = chunk6H76FAI3_cjs.sanitizeHref(match[2]);
|
|
1703
1703
|
return href === null ? null : { type: "link", attrs: { href } };
|
|
1704
1704
|
}
|
|
1705
1705
|
}),
|
|
@@ -1717,7 +1717,7 @@ function replacing(name, match, replacement) {
|
|
|
1717
1717
|
handler(state, found, range) {
|
|
1718
1718
|
const value = typeof replacement === "string" ? replacement : replacement(found);
|
|
1719
1719
|
const from = range.to - (found[1] ?? found[0]).length;
|
|
1720
|
-
const node =
|
|
1720
|
+
const node = chunk6H76FAI3_cjs.text(value, chunk6H76FAI3_cjs.marksAt(regionInline(state, range), range.to, () => true));
|
|
1721
1721
|
return new Transaction(state).step(replaceInlineStep(range.block, range.region, from, range.to, [node]));
|
|
1722
1722
|
}
|
|
1723
1723
|
};
|
|
@@ -2001,7 +2001,7 @@ function nearestPaletteColor(css, kind) {
|
|
|
2001
2001
|
const table = PALETTE_RGB[kind];
|
|
2002
2002
|
let best = "default";
|
|
2003
2003
|
let least = Infinity;
|
|
2004
|
-
for (const name of
|
|
2004
|
+
for (const name of chunk6H76FAI3_cjs.PALETTE) {
|
|
2005
2005
|
for (const reference of table[name]) {
|
|
2006
2006
|
const gap = distance(rgb, reference);
|
|
2007
2007
|
if (gap < least) {
|
|
@@ -2015,31 +2015,31 @@ function nearestPaletteColor(css, kind) {
|
|
|
2015
2015
|
|
|
2016
2016
|
// src/engine/clipboard/html-marks.ts
|
|
2017
2017
|
function linkMark(element) {
|
|
2018
|
-
const href =
|
|
2018
|
+
const href = chunk6H76FAI3_cjs.sanitizeHref(element.getAttribute("href") ?? "");
|
|
2019
2019
|
if (href === null || href === "") return null;
|
|
2020
2020
|
const title = element.getAttribute("title");
|
|
2021
2021
|
return { type: "link", attrs: title ? { href, title } : { href } };
|
|
2022
2022
|
}
|
|
2023
2023
|
function highlightMark(element) {
|
|
2024
2024
|
const color = element.getAttribute("data-color") ?? "";
|
|
2025
|
-
return
|
|
2025
|
+
return chunk6H76FAI3_cjs.isPaletteColor(color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
|
|
2026
2026
|
}
|
|
2027
2027
|
function elementMarks(element, inherited) {
|
|
2028
2028
|
const tag = tagName(element);
|
|
2029
2029
|
const styles = parseStyle(element.getAttribute("style"));
|
|
2030
2030
|
let marks = inherited;
|
|
2031
2031
|
const add = (mark) => {
|
|
2032
|
-
marks =
|
|
2032
|
+
marks = chunk6H76FAI3_cjs.addMark(marks, mark);
|
|
2033
2033
|
};
|
|
2034
2034
|
const link = tag === "a" ? linkMark(element) : null;
|
|
2035
2035
|
if (link !== null) add(link);
|
|
2036
|
-
const linked2 =
|
|
2036
|
+
const linked2 = chunk6H76FAI3_cjs.hasMark(marks, "link");
|
|
2037
2037
|
const weight = fontWeight(styles);
|
|
2038
2038
|
if (weight !== null ? weight >= 600 : tag === "b" || tag === "strong") add({ type: "bold" });
|
|
2039
|
-
else if (weight !== null) marks =
|
|
2039
|
+
else if (weight !== null) marks = chunk6H76FAI3_cjs.removeMark(marks, "bold");
|
|
2040
2040
|
const slanted = isItalicStyle(styles);
|
|
2041
2041
|
if (slanted ?? (tag === "i" || tag === "em")) add({ type: "italic" });
|
|
2042
|
-
else if (slanted === false) marks =
|
|
2042
|
+
else if (slanted === false) marks = chunk6H76FAI3_cjs.removeMark(marks, "italic");
|
|
2043
2043
|
if (tag === "u" || !linked2 && hasDecoration(styles, "underline")) add({ type: "underline" });
|
|
2044
2044
|
if (tag === "s" || tag === "del" || tag === "strike" || hasDecoration(styles, "line-through")) {
|
|
2045
2045
|
add({ type: "strike" });
|
|
@@ -2058,7 +2058,7 @@ function elementMarks(element, inherited) {
|
|
|
2058
2058
|
}
|
|
2059
2059
|
|
|
2060
2060
|
// src/engine/clipboard/hoist-spaces.ts
|
|
2061
|
-
var shared = (a, b) => a.filter((mark) => b.some((other) =>
|
|
2061
|
+
var shared = (a, b) => a.filter((mark) => b.some((other) => chunk6H76FAI3_cjs.sameMark(mark, other)));
|
|
2062
2062
|
function hoistEdgeSpaces(pieces) {
|
|
2063
2063
|
const result = [];
|
|
2064
2064
|
pieces.forEach((piece, at) => {
|
|
@@ -2121,7 +2121,7 @@ function finish({ pieces }) {
|
|
|
2121
2121
|
break;
|
|
2122
2122
|
}
|
|
2123
2123
|
}
|
|
2124
|
-
const inline =
|
|
2124
|
+
const inline = chunk6H76FAI3_cjs.normalizeInline(hoistEdgeSpaces(pieces).map((piece) => chunk6H76FAI3_cjs.text(piece.text, piece.marks)));
|
|
2125
2125
|
return inline.every((node) => node.kind === "text" && node.text.trim() === "") ? [] : inline;
|
|
2126
2126
|
}
|
|
2127
2127
|
function visit(acc, node, style, depth) {
|
|
@@ -2218,7 +2218,7 @@ function wordListItem(paragraph, ctx, sink) {
|
|
|
2218
2218
|
|
|
2219
2219
|
// src/engine/clipboard/html-media.ts
|
|
2220
2220
|
function imageBlock(img, caption, ctx, sink) {
|
|
2221
|
-
const url =
|
|
2221
|
+
const url = chunk6H76FAI3_cjs.sanitizeHref(img.getAttribute("src") ?? "");
|
|
2222
2222
|
if (url === null || url === "") return;
|
|
2223
2223
|
emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: img.getAttribute("alt") ?? "", url }, { caption });
|
|
2224
2224
|
}
|
|
@@ -2256,7 +2256,7 @@ function tableBlock(table, ctx, sink) {
|
|
|
2256
2256
|
rows.forEach((row, r) => {
|
|
2257
2257
|
for (let c = 0; c < cols; c++) {
|
|
2258
2258
|
const cell = row.cells[c];
|
|
2259
|
-
regions[
|
|
2259
|
+
regions[chunk6H76FAI3_cjs.cellKey(r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
|
|
2260
2260
|
}
|
|
2261
2261
|
});
|
|
2262
2262
|
const header = rows[0].head || rows[0].cells.some((cell) => tagName(cell) === "th");
|
|
@@ -2269,7 +2269,7 @@ var HEADING = /^h([1-6])$/;
|
|
|
2269
2269
|
function emitRun(run, ctx, sink) {
|
|
2270
2270
|
const inline = inlineFromNodes(run, ctx);
|
|
2271
2271
|
if (inline.length === 0) return;
|
|
2272
|
-
const plain = ctx.run.kind === "heading" ?
|
|
2272
|
+
const plain = ctx.run.kind === "heading" ? chunk6H76FAI3_cjs.removeMarkRange(inline, 0, chunk6H76FAI3_cjs.inlineLength(inline), "bold") : inline;
|
|
2273
2273
|
emitText(sink, ctx.indent, ctx.run, plain);
|
|
2274
2274
|
}
|
|
2275
2275
|
function details(element, ctx, sink) {
|
|
@@ -2354,8 +2354,8 @@ function availableParser(parser) {
|
|
|
2354
2354
|
function fromHTML(html, options = {}) {
|
|
2355
2355
|
const parser = availableParser(options.parser);
|
|
2356
2356
|
if (parser === null) throw new Error("fromHTML needs a DOMParser");
|
|
2357
|
-
const makeId = options.newId ??
|
|
2358
|
-
const codec =
|
|
2357
|
+
const makeId = options.newId ?? chunk6H76FAI3_cjs.newId;
|
|
2358
|
+
const codec = chunk6H76FAI3_cjs.createBlockCodec(chunk6H76FAI3_cjs.createSchema(), { newId: makeId });
|
|
2359
2359
|
const { body } = parser.parseFromString(html, "text/html");
|
|
2360
2360
|
return blocksFromBody(body, makeId).map((block) => codec.toQuoin(block));
|
|
2361
2361
|
}
|
|
@@ -2376,7 +2376,7 @@ function quoteLines(text2) {
|
|
|
2376
2376
|
|
|
2377
2377
|
// src/engine/markdown/document/block-forms.ts
|
|
2378
2378
|
var ALERT_NAMES = new Map(
|
|
2379
|
-
Object.entries(
|
|
2379
|
+
Object.entries(chunk6H76FAI3_cjs.ALERT_TONES).map(([name, tone]) => [tone, name])
|
|
2380
2380
|
);
|
|
2381
2381
|
var DELIMITERS = /* @__PURE__ */ new Map([
|
|
2382
2382
|
["left", ":--"],
|
|
@@ -2386,8 +2386,8 @@ var DELIMITERS = /* @__PURE__ */ new Map([
|
|
|
2386
2386
|
var MIN_FENCE = 3;
|
|
2387
2387
|
var FENCE_LIKE_MATH_LINE = /^ {0,3}\${2,}[ \t]*$/m;
|
|
2388
2388
|
function calloutMarkdown(data) {
|
|
2389
|
-
const name = ALERT_NAMES.get(
|
|
2390
|
-
const body =
|
|
2389
|
+
const name = ALERT_NAMES.get(chunk6H76FAI3_cjs.str(data.tone)) ?? "NOTE";
|
|
2390
|
+
const body = chunk6H76FAI3_cjs.str(data.body);
|
|
2391
2391
|
return quoteLines(body === "" ? `[!${name}]` : `[!${name}]
|
|
2392
2392
|
${body}`);
|
|
2393
2393
|
}
|
|
@@ -2401,18 +2401,18 @@ function longestRun(value, char) {
|
|
|
2401
2401
|
return longest;
|
|
2402
2402
|
}
|
|
2403
2403
|
function codeMarkdown(data) {
|
|
2404
|
-
const code =
|
|
2405
|
-
const info =
|
|
2404
|
+
const code = chunk6H76FAI3_cjs.str(data.code);
|
|
2405
|
+
const info = chunk6H76FAI3_cjs.str(data.language);
|
|
2406
2406
|
const char = info.includes("`") ? "~" : "`";
|
|
2407
2407
|
const fence = char.repeat(Math.max(MIN_FENCE, longestRun(code, char) + 1));
|
|
2408
2408
|
return [fence + info.replace(/[\\&]/g, "\\$&"), ...code === "" ? [] : code.split("\n"), fence].join("\n");
|
|
2409
2409
|
}
|
|
2410
2410
|
function mathMarkdown(data) {
|
|
2411
|
-
const latex =
|
|
2411
|
+
const latex = chunk6H76FAI3_cjs.str(data.latex);
|
|
2412
2412
|
if (FENCE_LIKE_MATH_LINE.test(latex)) return null;
|
|
2413
2413
|
return ["$$", ...latex === "" ? [] : latex.split("\n"), "$$"].join("\n");
|
|
2414
2414
|
}
|
|
2415
|
-
var cellsOf = (row) => Array.isArray(row) ? row.map(
|
|
2415
|
+
var cellsOf = (row) => Array.isArray(row) ? row.map(chunk6H76FAI3_cjs.str) : [];
|
|
2416
2416
|
var rowMarkdown = (cells) => `| ${cells.join(" | ")} |`;
|
|
2417
2417
|
function tableMarkdown(data) {
|
|
2418
2418
|
const rows = Array.isArray(data.rows) ? data.rows.map(cellsOf) : [];
|
|
@@ -2439,7 +2439,7 @@ function needsComment(block, residual, schema, ctx) {
|
|
|
2439
2439
|
const native = NATIVE_KEYS.get(block.type);
|
|
2440
2440
|
if (!native) return false;
|
|
2441
2441
|
if (residual > 0) return true;
|
|
2442
|
-
return Object.keys(
|
|
2442
|
+
return Object.keys(chunk6H76FAI3_cjs.specFor(schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
|
|
2443
2443
|
}
|
|
2444
2444
|
|
|
2445
2445
|
// src/engine/markdown/document/comment-markdown.ts
|
|
@@ -2453,41 +2453,41 @@ function quoinComment(type, data, indent2) {
|
|
|
2453
2453
|
// src/engine/markdown/document/link-forms.ts
|
|
2454
2454
|
var oneLine = (value) => value.replace(/[\r\n]+/g, " ");
|
|
2455
2455
|
function linked(label, href, ctx) {
|
|
2456
|
-
return ctx.inline.serialize([
|
|
2456
|
+
return ctx.inline.serialize([chunk6H76FAI3_cjs.text(label || href, [{ type: "link", attrs: { href } }])]);
|
|
2457
2457
|
}
|
|
2458
2458
|
var assetUrl = (storageKey, ctx) => storageKey === "" ? "" : ctx.resolveAssetUrl(storageKey);
|
|
2459
2459
|
function imageMarkdown(data, ctx) {
|
|
2460
|
-
const href =
|
|
2460
|
+
const href = chunk6H76FAI3_cjs.str(data.url) || assetUrl(chunk6H76FAI3_cjs.str(data.storageKey), ctx);
|
|
2461
2461
|
if (href === "") return null;
|
|
2462
|
-
const caption =
|
|
2463
|
-
const alt = ctx.inline.serialize([
|
|
2464
|
-
return `![${alt}${
|
|
2462
|
+
const caption = chunk6H76FAI3_cjs.str(data.caption);
|
|
2463
|
+
const alt = ctx.inline.serialize([chunk6H76FAI3_cjs.text(oneLine(chunk6H76FAI3_cjs.str(data.alt)))]);
|
|
2464
|
+
return `![${alt}${chunk6H76FAI3_cjs.linkClose({ type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
|
|
2465
2465
|
}
|
|
2466
2466
|
function fileMarkdown(data, ctx) {
|
|
2467
|
-
const href = assetUrl(
|
|
2468
|
-
return href === "" ? null : linked(oneLine(
|
|
2467
|
+
const href = assetUrl(chunk6H76FAI3_cjs.str(data.storageKey), ctx);
|
|
2468
|
+
return href === "" ? null : linked(oneLine(chunk6H76FAI3_cjs.str(data.filename)), href, ctx);
|
|
2469
2469
|
}
|
|
2470
2470
|
function embedMarkdown(data, ctx) {
|
|
2471
|
-
const url =
|
|
2471
|
+
const url = chunk6H76FAI3_cjs.str(data.url);
|
|
2472
2472
|
return url === "" ? null : linked(url, url, ctx);
|
|
2473
2473
|
}
|
|
2474
2474
|
function bookmarkMarkdown(data, ctx) {
|
|
2475
|
-
const url =
|
|
2476
|
-
return url === "" ? null : linked(oneLine(
|
|
2475
|
+
const url = chunk6H76FAI3_cjs.str(data.url);
|
|
2476
|
+
return url === "" ? null : linked(oneLine(chunk6H76FAI3_cjs.str(data.title)), url, ctx);
|
|
2477
2477
|
}
|
|
2478
2478
|
|
|
2479
2479
|
// src/engine/markdown/document/block-markdown.ts
|
|
2480
2480
|
var QUOTE_PREFIX = "> ";
|
|
2481
2481
|
function markdownLine(block, data) {
|
|
2482
2482
|
const kind = block.attrs.kind ?? "paragraph";
|
|
2483
|
-
const markdown =
|
|
2484
|
-
const empty =
|
|
2483
|
+
const markdown = chunk6H76FAI3_cjs.str(data.markdown);
|
|
2484
|
+
const empty = chunk6H76FAI3_cjs.inlineLength(block.regions.text ?? []) === 0;
|
|
2485
2485
|
if (empty && (kind === "paragraph" || kind === "quote")) return null;
|
|
2486
2486
|
return kind === "quote" ? quoteLines(markdown.slice(QUOTE_PREFIX.length)) : markdown;
|
|
2487
2487
|
}
|
|
2488
2488
|
function toggleMarkdown(data) {
|
|
2489
2489
|
return `<details${data.open === true ? " open" : ""}>
|
|
2490
|
-
<summary>${
|
|
2490
|
+
<summary>${chunk6H76FAI3_cjs.str(data.markdown)}</summary>`;
|
|
2491
2491
|
}
|
|
2492
2492
|
function coreMarkdown(block, data, env, residual) {
|
|
2493
2493
|
switch (block.type) {
|
|
@@ -2520,9 +2520,9 @@ function coreMarkdown(block, data, env, residual) {
|
|
|
2520
2520
|
}
|
|
2521
2521
|
}
|
|
2522
2522
|
function blockMarkdown(block, env, { residual, asComment }) {
|
|
2523
|
-
const spec =
|
|
2523
|
+
const spec = chunk6H76FAI3_cjs.specFor(env.schema, block.type);
|
|
2524
2524
|
const data = spec.toData(block, env.ctx);
|
|
2525
|
-
const comment = () =>
|
|
2525
|
+
const comment = () => chunk6H76FAI3_cjs.isQuoinType(block.type) ? quoinComment(block.type, data, residual) : null;
|
|
2526
2526
|
if (asComment || env.lossless && !hasNativeForm(block.type)) return comment();
|
|
2527
2527
|
const written = spec.toMarkdown ? spec.toMarkdown(block, env.ctx) : coreMarkdown(block, data, env, residual);
|
|
2528
2528
|
if (written !== null) return written;
|
|
@@ -2552,7 +2552,7 @@ function createListContext() {
|
|
|
2552
2552
|
let placed = block;
|
|
2553
2553
|
let number = 1;
|
|
2554
2554
|
if (line2 === "ordered") {
|
|
2555
|
-
number = Math.min(runs.get(block.indent) ??
|
|
2555
|
+
number = Math.min(runs.get(block.indent) ?? chunk6H76FAI3_cjs.orderedStart(block.attrs.start), chunk6H76FAI3_cjs.MAX_MARKER_NUMBER);
|
|
2556
2556
|
runs.set(block.indent, number + 1);
|
|
2557
2557
|
if (number !== block.attrs.start) placed = { ...block, attrs: { ...block.attrs, start: number } };
|
|
2558
2558
|
} else {
|
|
@@ -2562,7 +2562,7 @@ function createListContext() {
|
|
|
2562
2562
|
const hang = isItem2 ? (line2 === "ordered" ? String(number).length : 0) + 2 : 0;
|
|
2563
2563
|
const container = comment ? void 0 : openedBy(block, prefix, hang);
|
|
2564
2564
|
if (container) stack.push(container);
|
|
2565
|
-
const bare = !comment && (line2 === "bullet" || line2 === "ordered") &&
|
|
2565
|
+
const bare = !comment && (line2 === "bullet" || line2 === "ordered") && chunk6H76FAI3_cjs.inlineLength(block.regions.text ?? []) === 0;
|
|
2566
2566
|
const fragile = isItem2 && (bare || line2 === "ordered" && number !== 1);
|
|
2567
2567
|
const shown = comment ? void 0 : line2;
|
|
2568
2568
|
return { block: placed, line: shown, prefix, hang, residual, parent, container, closed, bare, fragile, comment };
|
|
@@ -2580,7 +2580,7 @@ function stripComments(block) {
|
|
|
2580
2580
|
regions: Object.fromEntries(
|
|
2581
2581
|
regions.map(([name, inline]) => [
|
|
2582
2582
|
name,
|
|
2583
|
-
hasCommentMark(inline) ?
|
|
2583
|
+
hasCommentMark(inline) ? chunk6H76FAI3_cjs.removeMarkRange(inline, 0, chunk6H76FAI3_cjs.inlineLength(inline), "comment") : inline
|
|
2584
2584
|
])
|
|
2585
2585
|
)
|
|
2586
2586
|
};
|
|
@@ -2609,7 +2609,7 @@ function pieceOf(text2, placement) {
|
|
|
2609
2609
|
opened: placement.container,
|
|
2610
2610
|
bare: placement.bare,
|
|
2611
2611
|
fragile: placement.fragile,
|
|
2612
|
-
leadsHtml: hang > 0 &&
|
|
2612
|
+
leadsHtml: hang > 0 && chunk6H76FAI3_cjs.startsHtmlBlock(text2.split("\n")[0].slice(hang))
|
|
2613
2613
|
};
|
|
2614
2614
|
}
|
|
2615
2615
|
function takenAsItemText(previous, { parent, line: line2 }) {
|
|
@@ -2634,8 +2634,8 @@ function join(pieces) {
|
|
|
2634
2634
|
`;
|
|
2635
2635
|
}
|
|
2636
2636
|
function toMarkdown(blocks, options = {}) {
|
|
2637
|
-
const schema = options.schema ??
|
|
2638
|
-
const codec =
|
|
2637
|
+
const schema = options.schema ?? chunk6H76FAI3_cjs.createSchema();
|
|
2638
|
+
const codec = chunk6H76FAI3_cjs.createBlockCodec(schema);
|
|
2639
2639
|
const env = {
|
|
2640
2640
|
schema,
|
|
2641
2641
|
lossless: options.lossless === true,
|
|
@@ -2677,20 +2677,20 @@ function escapeAttr(value) {
|
|
|
2677
2677
|
|
|
2678
2678
|
// src/engine/render/serialize-html.ts
|
|
2679
2679
|
var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input"]);
|
|
2680
|
-
var attrsHtml = (node) =>
|
|
2680
|
+
var attrsHtml = (node) => chunk6H76FAI3_cjs.writtenAttrs(node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
|
|
2681
2681
|
var serializeHtml = (nodes) => nodes.map(
|
|
2682
2682
|
(node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${node.html ?? serializeHtml(node.children)}</${node.tag}>`}`
|
|
2683
2683
|
).join("");
|
|
2684
2684
|
|
|
2685
2685
|
// src/engine/render/to-html.ts
|
|
2686
|
-
var toHTML = (blocks, options = {}) => serializeHtml(
|
|
2686
|
+
var toHTML = (blocks, options = {}) => serializeHtml(chunk6H76FAI3_cjs.documentNodes(blocks, options));
|
|
2687
2687
|
|
|
2688
2688
|
// src/engine/render/to-plain-text.ts
|
|
2689
2689
|
function plainTextBlocks(blocks, schema) {
|
|
2690
|
-
return
|
|
2690
|
+
return chunk6H76FAI3_cjs.engineBlocksOf(blocks, schema).map((block) => chunk6H76FAI3_cjs.blockPlainText(block, schema));
|
|
2691
2691
|
}
|
|
2692
2692
|
function toPlainText(blocks, options = {}) {
|
|
2693
|
-
return plainTextBlocks(blocks, options.schema ??
|
|
2693
|
+
return plainTextBlocks(blocks, options.schema ?? chunk6H76FAI3_cjs.createSchema()).join("\n");
|
|
2694
2694
|
}
|
|
2695
2695
|
|
|
2696
2696
|
// src/engine/model/graphemes.ts
|
|
@@ -2742,7 +2742,7 @@ function countBlock(block, schema) {
|
|
|
2742
2742
|
if (!blocks) counted.set(schema, blocks = /* @__PURE__ */ new WeakMap());
|
|
2743
2743
|
const known = blocks.get(block);
|
|
2744
2744
|
if (known) return known;
|
|
2745
|
-
const text2 =
|
|
2745
|
+
const text2 = chunk6H76FAI3_cjs.blockPlainText(block, schema);
|
|
2746
2746
|
const stats = { characters: graphemeCount(text2), words: wordCount(text2) };
|
|
2747
2747
|
blocks.set(block, stats);
|
|
2748
2748
|
return stats;
|
|
@@ -2761,17 +2761,17 @@ function sum(blocks, schema) {
|
|
|
2761
2761
|
return { characters, words: words2 };
|
|
2762
2762
|
}
|
|
2763
2763
|
function countText(blocks, options = {}) {
|
|
2764
|
-
const schema = options.schema ?? (defaultSchema ??=
|
|
2765
|
-
return sum(
|
|
2764
|
+
const schema = options.schema ?? (defaultSchema ??= chunk6H76FAI3_cjs.createSchema());
|
|
2765
|
+
return sum(chunk6H76FAI3_cjs.engineBlocksOf(blocks, schema), schema);
|
|
2766
2766
|
}
|
|
2767
2767
|
function countDoc(doc, options = {}) {
|
|
2768
|
-
return sum(doc.blocks, options.schema ?? (defaultSchema ??=
|
|
2768
|
+
return sum(doc.blocks, options.schema ?? (defaultSchema ??= chunk6H76FAI3_cjs.createSchema()));
|
|
2769
2769
|
}
|
|
2770
2770
|
|
|
2771
2771
|
// src/engine/commands/block-style.ts
|
|
2772
2772
|
function patchBlocks(state, patch, only) {
|
|
2773
2773
|
const changing = selectedBlockIds(state.doc, state.selection).filter((id) => {
|
|
2774
|
-
const block =
|
|
2774
|
+
const block = chunk6H76FAI3_cjs.blockById(state.doc, id);
|
|
2775
2775
|
return block !== void 0 && (only === void 0 || block.type === only) && patchChangesAttrs(block.attrs, patch);
|
|
2776
2776
|
});
|
|
2777
2777
|
if (changing.length === 0) return null;
|
|
@@ -2799,7 +2799,7 @@ function setBlockColor(colors) {
|
|
|
2799
2799
|
const value = colors[key];
|
|
2800
2800
|
if (value !== void 0) patch[key] = value ?? void 0;
|
|
2801
2801
|
}
|
|
2802
|
-
const valid = Object.values(patch).every((value) => value === void 0 ||
|
|
2802
|
+
const valid = Object.values(patch).every((value) => value === void 0 || chunk6H76FAI3_cjs.isPaletteColor(value));
|
|
2803
2803
|
return valid ? patchCommand(patch, "MARKDOWN") : () => false;
|
|
2804
2804
|
}
|
|
2805
2805
|
|
|
@@ -2819,7 +2819,7 @@ function textCaret(state) {
|
|
|
2819
2819
|
const { doc, schema, selection } = state;
|
|
2820
2820
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
|
|
2821
2821
|
const pos = selection.head;
|
|
2822
|
-
const index =
|
|
2822
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(doc, pos.block);
|
|
2823
2823
|
const block = doc.blocks[index];
|
|
2824
2824
|
const inFlow2 = isTextFlow(schema, block) && pos.region === primaryRegion(schema, block);
|
|
2825
2825
|
return inFlow2 ? { block, index, pos } : null;
|
|
@@ -2827,14 +2827,14 @@ function textCaret(state) {
|
|
|
2827
2827
|
function joinInto(tr, schema, target, source) {
|
|
2828
2828
|
const targetRegion = primaryRegion(schema, target) ?? "";
|
|
2829
2829
|
tr.step(joinBlocksStep(target.id, targetRegion, source.id, primaryRegion(schema, source) ?? ""));
|
|
2830
|
-
capIndents(tr,
|
|
2830
|
+
capIndents(tr, chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, target.id) + 1);
|
|
2831
2831
|
const offset = regionLength(target, targetRegion);
|
|
2832
2832
|
tr.setSelection(textSelection({ block: target.id, region: targetRegion, offset }));
|
|
2833
2833
|
}
|
|
2834
2834
|
function joinIntoSummary(tr, schema, summary, source) {
|
|
2835
2835
|
const region = primaryRegion(schema, summary) ?? "";
|
|
2836
2836
|
const offset = regionLength(summary, region);
|
|
2837
|
-
const index =
|
|
2837
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, source.id);
|
|
2838
2838
|
const content = source.regions[primaryRegion(schema, source) ?? ""];
|
|
2839
2839
|
if (content.length > 0) tr.step(replaceInlineStep(summary.id, region, offset, offset, content));
|
|
2840
2840
|
tr.step(removeBlocksStep(index, 1));
|
|
@@ -2906,7 +2906,7 @@ function deleteReaching(forward, reach) {
|
|
|
2906
2906
|
const { selection } = state;
|
|
2907
2907
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
|
|
2908
2908
|
const { head } = selection;
|
|
2909
|
-
const value =
|
|
2909
|
+
const value = chunk6H76FAI3_cjs.inlineText(state.doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(state.doc, head.block)].regions[head.region]);
|
|
2910
2910
|
if (forward ? head.offset >= value.length : head.offset <= 0) {
|
|
2911
2911
|
return (forward ? deleteAtEnd : deleteAtStart)(state, dispatch);
|
|
2912
2912
|
}
|
|
@@ -2960,8 +2960,8 @@ function movedBlockIds(doc, ids) {
|
|
|
2960
2960
|
function gather(tr, runs, above) {
|
|
2961
2961
|
let anchor = above;
|
|
2962
2962
|
for (const run of runs) {
|
|
2963
|
-
const from =
|
|
2964
|
-
const at = anchor === null ? -1 :
|
|
2963
|
+
const from = chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, run[0]);
|
|
2964
|
+
const at = anchor === null ? -1 : chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, anchor);
|
|
2965
2965
|
const to = at < from ? at + 1 : at + 1 - run.length;
|
|
2966
2966
|
if (to !== from) tr.step(moveBlocksStep(from, run.length, to));
|
|
2967
2967
|
anchor = run[run.length - 1];
|
|
@@ -2989,7 +2989,7 @@ function moveBlocksTo(ids, toIndex, indent2) {
|
|
|
2989
2989
|
const first = runs[0][0];
|
|
2990
2990
|
const last = runs[runs.length - 1];
|
|
2991
2991
|
const clamped = Math.min(Math.max(indent2, 0), above ? above.indent + 1 : 0);
|
|
2992
|
-
reindent(tr,
|
|
2992
|
+
reindent(tr, chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, first), moved2.size, clamped);
|
|
2993
2993
|
if (!tr.docChanged) return false;
|
|
2994
2994
|
dispatch?.(tr.setSelection(blockRangeSelection(first, last[last.length - 1])));
|
|
2995
2995
|
return true;
|
|
@@ -3003,7 +3003,7 @@ var selectAll = (state, dispatch) => {
|
|
|
3003
3003
|
let next = blockRangeSelection(doc.blocks[0].id, doc.blocks[doc.blocks.length - 1].id);
|
|
3004
3004
|
if (selection?.kind === "text") {
|
|
3005
3005
|
const { anchor, head } = selection;
|
|
3006
|
-
const length =
|
|
3006
|
+
const length = chunk6H76FAI3_cjs.inlineLength(doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, head.block)].regions[head.region] ?? []);
|
|
3007
3007
|
const withinRegion = anchor.block === head.block && anchor.region === head.region;
|
|
3008
3008
|
const covers = Math.min(anchor.offset, head.offset) === 0 && Math.max(anchor.offset, head.offset) === length;
|
|
3009
3009
|
if (withinRegion && !covers) next = textSelection({ ...head, offset: 0 }, { ...head, offset: length });
|
|
@@ -3040,7 +3040,7 @@ function splitStep(schema, block, region, offset, id) {
|
|
|
3040
3040
|
// src/engine/commands/split-at.ts
|
|
3041
3041
|
function enterInHardBreakBlock({ tr, schema, block, index, pos, makeId }) {
|
|
3042
3042
|
const length = regionLength(block, pos.region);
|
|
3043
|
-
if (pos.offset === length &&
|
|
3043
|
+
if (pos.offset === length && chunk6H76FAI3_cjs.inlineText(block.regions[pos.region]).endsWith("\n")) {
|
|
3044
3044
|
tr.step(replaceInlineStep(block.id, pos.region, length - 1, length, []));
|
|
3045
3045
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, makeId());
|
|
3046
3046
|
tr.step(insertBlocksStep(descendantsEnd(tr.doc, index), [paragraph]));
|
|
@@ -3063,7 +3063,7 @@ function insertEmptyBefore({ tr, schema, block, index, pos, makeId }) {
|
|
|
3063
3063
|
function splitToggle({ tr, schema, block, index, pos, makeId }) {
|
|
3064
3064
|
const length = regionLength(block, pos.region);
|
|
3065
3065
|
const open = block.attrs.open === true;
|
|
3066
|
-
const tail =
|
|
3066
|
+
const tail = chunk6H76FAI3_cjs.sliceInline(block.regions[pos.region], pos.offset, length);
|
|
3067
3067
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, open ? block.indent + 1 : block.indent, makeId());
|
|
3068
3068
|
if (pos.offset < length) tr.step(replaceInlineStep(block.id, pos.region, pos.offset, length, []));
|
|
3069
3069
|
tr.step(insertBlocksStep(open ? index + 1 : descendantsEnd(tr.doc, index), [withContent(schema, empty, tail)]));
|
|
@@ -3075,7 +3075,7 @@ function splitInTwo({ tr, schema, block, pos, makeId }) {
|
|
|
3075
3075
|
tr.setSelection(textSelection({ block: tail.id, region: tail.region, offset: 0 }));
|
|
3076
3076
|
}
|
|
3077
3077
|
function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
3078
|
-
const index =
|
|
3078
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, pos.block);
|
|
3079
3079
|
const block = tr.doc.blocks[index];
|
|
3080
3080
|
if (!isTextFlow(schema, block) || pos.region !== primaryRegion(schema, block)) return false;
|
|
3081
3081
|
const target = { tr, schema, block, index, pos, makeId };
|
|
@@ -3090,13 +3090,13 @@ function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
|
3090
3090
|
|
|
3091
3091
|
// src/engine/commands/split-block.ts
|
|
3092
3092
|
function splitBlock(options = {}) {
|
|
3093
|
-
const makeId = options.newId ??
|
|
3093
|
+
const makeId = options.newId ?? chunk6H76FAI3_cjs.newId;
|
|
3094
3094
|
return (state, dispatch) => {
|
|
3095
3095
|
const { doc, schema, selection } = state;
|
|
3096
3096
|
if (selection === null || selection.kind === "blocks") return false;
|
|
3097
3097
|
const tr = new Transaction(state).setMeta(LINE_SPLIT, true);
|
|
3098
3098
|
if (selection.kind === "node") {
|
|
3099
|
-
const index =
|
|
3099
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(doc, selection.block);
|
|
3100
3100
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, doc.blocks[index].indent, makeId());
|
|
3101
3101
|
tr.step(insertBlocksStep(descendantsEnd(doc, index), [paragraph]));
|
|
3102
3102
|
tr.setSelection(startOf(tr.doc, schema, paragraph.id));
|
|
@@ -3206,7 +3206,7 @@ function replaceEmpty(tr, schema, index, blocks) {
|
|
|
3206
3206
|
tr.setSelection(endOf(tr.doc, schema, blocks[blocks.length - 1].id));
|
|
3207
3207
|
}
|
|
3208
3208
|
function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
3209
|
-
const index =
|
|
3209
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(tr.doc, caret.block);
|
|
3210
3210
|
const current = tr.doc.blocks[index];
|
|
3211
3211
|
const { region } = caret;
|
|
3212
3212
|
const first = pieces[0];
|
|
@@ -3215,7 +3215,7 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3215
3215
|
if (pieces.length === 1 && ends.openStart && ends.openEnd && textual(first)) {
|
|
3216
3216
|
const content = contentOf(schema, first);
|
|
3217
3217
|
insertAt(tr, caret, content);
|
|
3218
|
-
tr.setSelection(textSelection({ ...caret, offset: caret.offset +
|
|
3218
|
+
tr.setSelection(textSelection({ ...caret, offset: caret.offset + chunk6H76FAI3_cjs.inlineLength(content) }));
|
|
3219
3219
|
return;
|
|
3220
3220
|
}
|
|
3221
3221
|
const fresh = freshBlocks(pieces, current.indent, makeId);
|
|
@@ -3237,18 +3237,18 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3237
3237
|
if (atStart && !atEnd) {
|
|
3238
3238
|
if (middle.length > 0) insertCapped(tr, index, middle);
|
|
3239
3239
|
insertAt(tr, { ...caret, offset: 0 }, lastContent);
|
|
3240
|
-
tr.setSelection(textSelection({ ...caret, offset:
|
|
3240
|
+
tr.setSelection(textSelection({ ...caret, offset: chunk6H76FAI3_cjs.inlineLength(lastContent) }));
|
|
3241
3241
|
return;
|
|
3242
3242
|
}
|
|
3243
3243
|
const firstContent = mergeFirst ? contentOf(schema, fresh[0]) : [];
|
|
3244
3244
|
insertAt(tr, caret, firstContent);
|
|
3245
|
-
const offset = caret.offset +
|
|
3245
|
+
const offset = caret.offset + chunk6H76FAI3_cjs.inlineLength(firstContent);
|
|
3246
3246
|
const tail = !atEnd && (mergeLast || middle.length > 0) ? splitStep(schema, current, region, offset, makeId()) : null;
|
|
3247
3247
|
if (tail !== null) tr.step(tail.step);
|
|
3248
3248
|
if (middle.length > 0) insertCapped(tr, index + 1, middle);
|
|
3249
3249
|
if (tail !== null && mergeLast) {
|
|
3250
3250
|
insertAt(tr, { block: tail.tail.id, region: tail.tail.region, offset: 0 }, lastContent);
|
|
3251
|
-
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset:
|
|
3251
|
+
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: chunk6H76FAI3_cjs.inlineLength(lastContent) }));
|
|
3252
3252
|
} else if (middle.length > 0) {
|
|
3253
3253
|
tr.setSelection(endOf(tr.doc, schema, middle[middle.length - 1].id));
|
|
3254
3254
|
} else {
|
|
@@ -3274,10 +3274,10 @@ function appendAtEnd(tr, schema, pieces, makeId) {
|
|
|
3274
3274
|
tr.setSelection(endOf(tr.doc, schema, fresh[fresh.length - 1].id));
|
|
3275
3275
|
}
|
|
3276
3276
|
function insertSlice(slice, options = {}) {
|
|
3277
|
-
const makeId = options.newId ??
|
|
3277
|
+
const makeId = options.newId ?? chunk6H76FAI3_cjs.newId;
|
|
3278
3278
|
return (state, dispatch) => {
|
|
3279
3279
|
const { doc, schema, selection } = state;
|
|
3280
|
-
const codec =
|
|
3280
|
+
const codec = chunk6H76FAI3_cjs.createBlockCodec(schema, { newId: makeId });
|
|
3281
3281
|
const pieces = slice.blocks.flatMap((block) => codec.toEngineBlocks(block));
|
|
3282
3282
|
if (pieces.length === 0) return false;
|
|
3283
3283
|
const tr = new Transaction(state).setOrigin("paste");
|
|
@@ -3326,9 +3326,9 @@ function fenceTransaction(state) {
|
|
|
3326
3326
|
const { selection, doc } = state;
|
|
3327
3327
|
if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
|
|
3328
3328
|
const { block: id, region, offset } = selection.head;
|
|
3329
|
-
const block =
|
|
3329
|
+
const block = chunk6H76FAI3_cjs.blockById(doc, id);
|
|
3330
3330
|
if (block === void 0 || !isParagraph(block) || offset !== regionLength(block, region)) return null;
|
|
3331
|
-
const fence = FENCE.exec(
|
|
3331
|
+
const fence = FENCE.exec(chunk6H76FAI3_cjs.inlineText(block.regions[region]));
|
|
3332
3332
|
if (fence === null) return null;
|
|
3333
3333
|
return convertPrefix(state, { block: id, region, from: 0, to: offset }, setBlockType("CODE", { language: fence[1] }));
|
|
3334
3334
|
}
|
|
@@ -3395,9 +3395,9 @@ function coreExtensions(options = {}) {
|
|
|
3395
3395
|
return [
|
|
3396
3396
|
defineExtension({
|
|
3397
3397
|
name: "core",
|
|
3398
|
-
blocks:
|
|
3399
|
-
marks:
|
|
3400
|
-
atoms:
|
|
3398
|
+
blocks: chunk6H76FAI3_cjs.coreBlockSpecs,
|
|
3399
|
+
marks: chunk6H76FAI3_cjs.coreMarkSpecs,
|
|
3400
|
+
atoms: chunk6H76FAI3_cjs.coreAtomSpecs,
|
|
3401
3401
|
commands: coreCommands,
|
|
3402
3402
|
pasteRules: [linkOverSelection]
|
|
3403
3403
|
}),
|
|
@@ -3414,12 +3414,12 @@ function coreExtensions(options = {}) {
|
|
|
3414
3414
|
|
|
3415
3415
|
// src/engine/clipboard/serialize-slice.ts
|
|
3416
3416
|
function sliceText(slice, options) {
|
|
3417
|
-
const schema = options.schema ??
|
|
3417
|
+
const schema = options.schema ?? chunk6H76FAI3_cjs.createSchema();
|
|
3418
3418
|
if (slice.blocks.length === 1 && slice.openStart && slice.openEnd) {
|
|
3419
|
-
const pieces =
|
|
3419
|
+
const pieces = chunk6H76FAI3_cjs.createBlockCodec(schema).toEngineBlocks(slice.blocks[0]);
|
|
3420
3420
|
const block = pieces.length === 1 ? stripComments(pieces[0]) : null;
|
|
3421
3421
|
const region = block === null || !isTextFlow(schema, block) ? null : primaryRegion(schema, block);
|
|
3422
|
-
if (block !== null && region !== null) return
|
|
3422
|
+
if (block !== null && region !== null) return chunk6H76FAI3_cjs.inlinePlainText(block.regions[region] ?? [], schema);
|
|
3423
3423
|
}
|
|
3424
3424
|
const markdown = toMarkdown(slice.blocks, { schema, resolveAssetUrl: options.resolveAssetUrl, comments: false });
|
|
3425
3425
|
return markdown.replace(/\n$/, "");
|
|
@@ -3437,17 +3437,17 @@ function isFlowRegion(schema, block, region) {
|
|
|
3437
3437
|
return isTextFlow(schema, block) && region === primaryRegion(schema, block);
|
|
3438
3438
|
}
|
|
3439
3439
|
function trimmed(block, region, from, to) {
|
|
3440
|
-
return { ...block, regions: { ...block.regions, [region]:
|
|
3440
|
+
return { ...block, regions: { ...block.regions, [region]: chunk6H76FAI3_cjs.sliceInline(block.regions[region], from, to) } };
|
|
3441
3441
|
}
|
|
3442
3442
|
function insideOneRegion(schema, block, region, from, to) {
|
|
3443
3443
|
if (isFlowRegion(schema, block, region)) return trimmed(block, region, from, to);
|
|
3444
3444
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, block.id);
|
|
3445
|
-
return withContent(schema, paragraph,
|
|
3445
|
+
return withContent(schema, paragraph, chunk6H76FAI3_cjs.sliceInline(block.regions[region], from, to));
|
|
3446
3446
|
}
|
|
3447
3447
|
function textBlocks({ doc, schema }, selection) {
|
|
3448
3448
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
3449
|
-
const start =
|
|
3450
|
-
const end =
|
|
3449
|
+
const start = chunk6H76FAI3_cjs.requireBlockIndex(doc, from.block);
|
|
3450
|
+
const end = chunk6H76FAI3_cjs.requireBlockIndex(doc, to.block);
|
|
3451
3451
|
const first = doc.blocks[start];
|
|
3452
3452
|
if (start === end) {
|
|
3453
3453
|
if (from.region !== to.region) return [first];
|
|
@@ -3493,18 +3493,18 @@ var INLINE_SYNTAX = [/\*\*[^*\n]+\*\*/, /__[^_\n]+__/, /\[[^\]\n]+\]\([^)\s]+[^)
|
|
|
3493
3493
|
function looksLikeMarkdown(value) {
|
|
3494
3494
|
return value.split(/\r\n|\r|\n/).some((line2) => BLOCK_MARKERS.some((marker) => marker.test(line2))) || INLINE_SYNTAX.some((syntax) => syntax.test(value));
|
|
3495
3495
|
}
|
|
3496
|
-
function plainTextToBlocks(value, makeId =
|
|
3496
|
+
function plainTextToBlocks(value, makeId = chunk6H76FAI3_cjs.newId) {
|
|
3497
3497
|
return value.split(/\r\n|\r|\n/).filter((line2) => line2.trim() !== "").map((line2) => ({
|
|
3498
3498
|
id: makeId(),
|
|
3499
3499
|
type: "MARKDOWN",
|
|
3500
|
-
data: { markdown:
|
|
3500
|
+
data: { markdown: chunk6H76FAI3_cjs.serializeInline([chunk6H76FAI3_cjs.text(line2)], { escapeLineStart: true }) }
|
|
3501
3501
|
}));
|
|
3502
3502
|
}
|
|
3503
3503
|
|
|
3504
3504
|
// src/engine/clipboard/parse-slice-json.ts
|
|
3505
3505
|
function isBlock2(value) {
|
|
3506
|
-
if (!
|
|
3507
|
-
if (!
|
|
3506
|
+
if (!chunk6H76FAI3_cjs.isRecord(value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
|
|
3507
|
+
if (!chunk6H76FAI3_cjs.isRecord(value.data)) return false;
|
|
3508
3508
|
return value.indent === void 0 || Number.isInteger(value.indent) && value.indent >= 0;
|
|
3509
3509
|
}
|
|
3510
3510
|
function parseSliceJSON(json) {
|
|
@@ -3514,7 +3514,7 @@ function parseSliceJSON(json) {
|
|
|
3514
3514
|
} catch {
|
|
3515
3515
|
return null;
|
|
3516
3516
|
}
|
|
3517
|
-
if (!
|
|
3517
|
+
if (!chunk6H76FAI3_cjs.isRecord(parsed) || parsed.quoin !== 1 || !chunk6H76FAI3_cjs.isRecord(parsed.slice)) return null;
|
|
3518
3518
|
const { blocks, openStart, openEnd } = parsed.slice;
|
|
3519
3519
|
if (!Array.isArray(blocks) || blocks.length === 0 || !blocks.every(isBlock2)) return null;
|
|
3520
3520
|
if (typeof openStart !== "boolean" || typeof openEnd !== "boolean") return null;
|
|
@@ -3522,7 +3522,7 @@ function parseSliceJSON(json) {
|
|
|
3522
3522
|
}
|
|
3523
3523
|
|
|
3524
3524
|
// src/engine/clipboard/slice-from-clipboard.ts
|
|
3525
|
-
var isParagraph2 = (block) => block.type === "MARKDOWN" &&
|
|
3525
|
+
var isParagraph2 = (block) => block.type === "MARKDOWN" && chunk6H76FAI3_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
|
|
3526
3526
|
function openSlice(blocks, plainText2 = false) {
|
|
3527
3527
|
if (blocks.length === 0) return null;
|
|
3528
3528
|
const slice = { blocks, openStart: isParagraph2(blocks[0]), openEnd: isParagraph2(blocks[blocks.length - 1]) };
|
|
@@ -3532,14 +3532,14 @@ function linkBlocks(text2, makeId) {
|
|
|
3532
3532
|
const link = pastedLink(text2);
|
|
3533
3533
|
if (link === null) return null;
|
|
3534
3534
|
const { url, href, rest } = link;
|
|
3535
|
-
const linked2 =
|
|
3536
|
-
const markdown =
|
|
3535
|
+
const linked2 = chunk6H76FAI3_cjs.text(url, [{ type: "link", attrs: { href } }]);
|
|
3536
|
+
const markdown = chunk6H76FAI3_cjs.serializeInline(rest === "" ? [linked2] : [linked2, chunk6H76FAI3_cjs.text(rest)]);
|
|
3537
3537
|
return [{ id: makeId(), type: "MARKDOWN", data: { markdown } }];
|
|
3538
3538
|
}
|
|
3539
3539
|
function textBlocks2(text2, makeId) {
|
|
3540
3540
|
const link = linkBlocks(text2, makeId);
|
|
3541
3541
|
if (link !== null) return link;
|
|
3542
|
-
return looksLikeMarkdown(text2) ?
|
|
3542
|
+
return looksLikeMarkdown(text2) ? chunk6H76FAI3_cjs.fromMarkdown(text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
|
|
3543
3543
|
}
|
|
3544
3544
|
function htmlSlice(html, options) {
|
|
3545
3545
|
if (html === void 0) return null;
|
|
@@ -3551,7 +3551,7 @@ function sliceFromClipboard(data, options = {}) {
|
|
|
3551
3551
|
if (fromJson !== null) return fromJson;
|
|
3552
3552
|
const fromHtml = htmlSlice(data.html, options);
|
|
3553
3553
|
if (fromHtml !== null) return fromHtml;
|
|
3554
|
-
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ??
|
|
3554
|
+
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ?? chunk6H76FAI3_cjs.newId), true);
|
|
3555
3555
|
}
|
|
3556
3556
|
|
|
3557
3557
|
// src/engine/commands/is-active.ts
|
|
@@ -3560,7 +3560,7 @@ function hasAttrs(block, attrs) {
|
|
|
3560
3560
|
}
|
|
3561
3561
|
function isActive(state, name, attrs) {
|
|
3562
3562
|
if (state.schema.marks.has(name)) return selectionHasMark(state, name, attrs);
|
|
3563
|
-
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) =>
|
|
3563
|
+
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => chunk6H76FAI3_cjs.blockById(state.doc, id) ?? []);
|
|
3564
3564
|
const isBlockType = state.schema.blocks.has(name);
|
|
3565
3565
|
const matches = (block) => isBlockType ? block.type === name : block.type === "MARKDOWN" && block.attrs.kind === name;
|
|
3566
3566
|
return blocks.length > 0 && blocks.every((block) => matches(block) && hasAttrs(block, attrs));
|
|
@@ -3569,19 +3569,19 @@ function isActive(state, name, attrs) {
|
|
|
3569
3569
|
// src/engine/model/same-doc.ts
|
|
3570
3570
|
function sameDoc(a, b) {
|
|
3571
3571
|
if (a === b) return true;
|
|
3572
|
-
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) =>
|
|
3572
|
+
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => chunk6H76FAI3_cjs.sameValue(block, b.blocks[i]));
|
|
3573
3573
|
}
|
|
3574
3574
|
|
|
3575
3575
|
// src/engine/extension/same-blocks.ts
|
|
3576
3576
|
function sameBlock(a, b) {
|
|
3577
|
-
return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) &&
|
|
3577
|
+
return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) && chunk6H76FAI3_cjs.sameValue(a.data, b.data);
|
|
3578
3578
|
}
|
|
3579
3579
|
function sameBlocks(a, b) {
|
|
3580
|
-
return a === b ||
|
|
3580
|
+
return a === b || chunk6H76FAI3_cjs.sameItems(a, b, sameBlock);
|
|
3581
3581
|
}
|
|
3582
3582
|
|
|
3583
3583
|
// src/engine/extension/structural-echo.ts
|
|
3584
|
-
var sameIds = (a, b) =>
|
|
3584
|
+
var sameIds = (a, b) => chunk6H76FAI3_cjs.sameItems(a, b, (x, y) => x.id === y.id);
|
|
3585
3585
|
function copiedSequence(emissions, incoming) {
|
|
3586
3586
|
const verdicts = /* @__PURE__ */ new Map();
|
|
3587
3587
|
const sameAt = (block, index) => {
|
|
@@ -3762,7 +3762,7 @@ function resolveExtensions(extensions, isMac) {
|
|
|
3762
3762
|
);
|
|
3763
3763
|
return {
|
|
3764
3764
|
extensions: sorted,
|
|
3765
|
-
schema:
|
|
3765
|
+
schema: chunk6H76FAI3_cjs.createSchema({
|
|
3766
3766
|
blocks: sorted.flatMap((extension) => extension.blocks ?? []),
|
|
3767
3767
|
marks: sorted.flatMap((extension) => extension.marks ?? []),
|
|
3768
3768
|
atoms: sorted.flatMap((extension) => extension.atoms ?? [])
|
|
@@ -3786,7 +3786,7 @@ function createInternalEditor(options) {
|
|
|
3786
3786
|
const isMac = options.isMac ?? detectMac();
|
|
3787
3787
|
const resolved = resolveExtensions(options.extensions ?? coreExtensions({ newId: newId2 }), isMac);
|
|
3788
3788
|
const { schema, plugins } = resolved;
|
|
3789
|
-
const codec =
|
|
3789
|
+
const codec = chunk6H76FAI3_cjs.createBlockCodec(schema, { newId: newId2 });
|
|
3790
3790
|
const listeners = /* @__PURE__ */ new Set();
|
|
3791
3791
|
const mounts = /* @__PURE__ */ new Set();
|
|
3792
3792
|
let state = createState({ doc: codec.docFromBlocks(options.blocks), schema, plugins, clock: options.now });
|
|
@@ -4003,5 +4003,5 @@ exports.unsetMark = unsetMark;
|
|
|
4003
4003
|
exports.validateSelection = validateSelection;
|
|
4004
4004
|
exports.withContent = withContent;
|
|
4005
4005
|
exports.wordCount = wordCount;
|
|
4006
|
-
//# sourceMappingURL=chunk-
|
|
4007
|
-
//# sourceMappingURL=chunk-
|
|
4006
|
+
//# sourceMappingURL=chunk-M5FREXRQ.cjs.map
|
|
4007
|
+
//# sourceMappingURL=chunk-M5FREXRQ.cjs.map
|