quoin-editor 1.0.1 → 1.0.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 +12 -0
- package/dist/ai.cjs +78 -78
- package/dist/ai.js +6 -6
- package/dist/catalogue.cjs +24 -24
- package/dist/catalogue.js +16 -16
- package/dist/{chunk-BTBHHBVR.cjs → chunk-4SLJNZSM.cjs} +11 -7
- package/dist/chunk-4SLJNZSM.cjs.map +1 -0
- package/dist/{chunk-62WKUAQY.js → chunk-4XFXB37X.js} +7 -3
- package/dist/chunk-4XFXB37X.js.map +1 -0
- package/dist/{chunk-56C7GCKO.cjs → chunk-5MAYUGTE.cjs} +97 -97
- package/dist/{chunk-56C7GCKO.cjs.map → chunk-5MAYUGTE.cjs.map} +1 -1
- package/dist/{chunk-QXG3HWDS.js → chunk-623AOJM2.js} +4 -4
- package/dist/{chunk-6YSGUAVW.js → chunk-6NULZPVC.js} +6 -8
- package/dist/chunk-6NULZPVC.js.map +1 -0
- package/dist/{chunk-XX5FTPJR.cjs → chunk-6V6GGBDK.cjs} +10 -10
- package/dist/{chunk-XX5FTPJR.cjs.map → chunk-6V6GGBDK.cjs.map} +1 -1
- package/dist/{chunk-CLTHD5GO.cjs → chunk-73653CJ4.cjs} +3 -3
- package/dist/{chunk-CLTHD5GO.cjs.map → chunk-73653CJ4.cjs.map} +1 -1
- package/dist/{chunk-UBNG5YCG.js → chunk-ADSJ42DO.js} +6 -6
- package/dist/{chunk-PX6LZMH4.cjs → chunk-AUOEM3SF.cjs} +44 -44
- package/dist/{chunk-PX6LZMH4.cjs.map → chunk-AUOEM3SF.cjs.map} +1 -1
- package/dist/{chunk-ESMAW4NK.cjs → chunk-BQANU5BH.cjs} +12 -12
- package/dist/{chunk-ESMAW4NK.cjs.map → chunk-BQANU5BH.cjs.map} +1 -1
- package/dist/{chunk-UCXLRRWY.js → chunk-C23RQVRK.js} +5 -5
- package/dist/{chunk-5R3ISX4A.cjs → chunk-CW3AFJBR.cjs} +288 -295
- package/dist/chunk-CW3AFJBR.cjs.map +1 -0
- package/dist/{chunk-26Q4LSIU.js → chunk-DUE3HCZD.js} +2 -2
- package/dist/{chunk-SSIRYUCK.js → chunk-EPARJI4V.js} +6 -5
- package/dist/chunk-EPARJI4V.js.map +1 -0
- package/dist/{chunk-V3KLMSRO.cjs → chunk-FDRUAL3Z.cjs} +30 -30
- package/dist/{chunk-V3KLMSRO.cjs.map → chunk-FDRUAL3Z.cjs.map} +1 -1
- package/dist/{chunk-A4IJSJKL.js → chunk-IQBMAE3F.js} +5 -5
- package/dist/{chunk-PIWRSX7U.js → chunk-JHQUHFLX.js} +7 -7
- package/dist/{chunk-6PKVJZQV.cjs → chunk-KUYZMSMF.cjs} +8 -8
- package/dist/{chunk-6PKVJZQV.cjs.map → chunk-KUYZMSMF.cjs.map} +1 -1
- package/dist/{chunk-UDAVVEFC.cjs → chunk-LLTEGXWZ.cjs} +54 -54
- package/dist/{chunk-UDAVVEFC.cjs.map → chunk-LLTEGXWZ.cjs.map} +1 -1
- package/dist/{chunk-RQW3P3GH.js → chunk-N4FGA3H4.js} +5 -5
- package/dist/{chunk-LV6EYPJO.js → chunk-NEZJ7ZP5.js} +2 -2
- package/dist/{chunk-UPSLDTLT.js → chunk-OBMBSU2S.js} +3 -3
- package/dist/{chunk-WMN6566P.js → chunk-OSHZQR3W.js} +5 -5
- package/dist/{chunk-5M4QG3ZC.cjs → chunk-P6KYXFZC.cjs} +116 -115
- package/dist/chunk-P6KYXFZC.cjs.map +1 -0
- package/dist/{chunk-75C6PX2L.cjs → chunk-R2BLBV43.cjs} +23 -23
- package/dist/{chunk-75C6PX2L.cjs.map → chunk-R2BLBV43.cjs.map} +1 -1
- package/dist/{chunk-6LMS5J3Y.js → chunk-RJRX34BZ.js} +2 -2
- package/dist/{chunk-LE3F7WIP.js → chunk-T43RZTUT.js} +148 -155
- package/dist/chunk-T43RZTUT.js.map +1 -0
- package/dist/{chunk-MLRAVUFG.cjs → chunk-TLGX43P6.cjs} +17 -19
- package/dist/chunk-TLGX43P6.cjs.map +1 -0
- package/dist/{chunk-LMAEPFTX.js → chunk-U3LOLYAU.js} +2 -2
- package/dist/{chunk-JJ3RASQS.cjs → chunk-UEKXVCKC.cjs} +101 -91
- package/dist/chunk-UEKXVCKC.cjs.map +1 -0
- package/dist/{chunk-GPIDU3GN.js → chunk-VCLL5C7J.js} +5 -5
- package/dist/{chunk-PGSS4IOS.js → chunk-VRS6WCEK.js} +19 -9
- package/dist/chunk-VRS6WCEK.js.map +1 -0
- package/dist/{chunk-VACTAZWS.cjs → chunk-WEYDDIBQ.cjs} +14 -14
- package/dist/{chunk-VACTAZWS.cjs.map → chunk-WEYDDIBQ.cjs.map} +1 -1
- package/dist/{chunk-F5V3IEEE.cjs → chunk-X4HDKFW5.cjs} +27 -27
- package/dist/{chunk-F5V3IEEE.cjs.map → chunk-X4HDKFW5.cjs.map} +1 -1
- package/dist/{chunk-EYFCOV3T.cjs → chunk-X4P4TQXH.cjs} +5 -5
- package/dist/{chunk-EYFCOV3T.cjs.map → chunk-X4P4TQXH.cjs.map} +1 -1
- package/dist/{chunk-UWNZG2SD.cjs → chunk-XA3UEJIW.cjs} +3 -3
- package/dist/{chunk-UWNZG2SD.cjs.map → chunk-XA3UEJIW.cjs.map} +1 -1
- package/dist/{chunk-OCCKQHCY.js → chunk-YBMUEEM5.js} +2 -2
- package/dist/{chunk-HOIDJEVI.cjs → chunk-ZKVOS57Q.cjs} +217 -217
- package/dist/{chunk-HOIDJEVI.cjs.map → chunk-ZKVOS57Q.cjs.map} +1 -1
- package/dist/comments.cjs +58 -58
- package/dist/comments.js +7 -7
- package/dist/diff.cjs +28 -27
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.js +5 -4
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed.cjs +8 -8
- package/dist/embed.js +7 -7
- package/dist/emoji.cjs +7 -7
- package/dist/emoji.js +6 -6
- package/dist/engine.cjs +4 -4
- package/dist/engine.js +3 -3
- package/dist/find.cjs +7 -7
- package/dist/find.js +6 -6
- package/dist/headless.cjs +5 -5
- package/dist/headless.js +4 -4
- package/dist/index.cjs +6 -6
- package/dist/index.js +5 -5
- package/dist/math.cjs +9 -9
- package/dist/math.js +8 -8
- package/dist/mention.cjs +9 -9
- package/dist/mention.js +8 -8
- package/dist/presence.cjs +39 -42
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +9 -12
- package/dist/presence.js.map +1 -1
- package/dist/stats.cjs +8 -8
- package/dist/stats.js +7 -7
- package/dist/table.cjs +7 -7
- package/dist/table.js +6 -6
- package/dist/toc.cjs +7 -7
- package/dist/toc.js +6 -6
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +223 -171
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +104 -52
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-5M4QG3ZC.cjs.map +0 -1
- package/dist/chunk-5R3ISX4A.cjs.map +0 -1
- package/dist/chunk-62WKUAQY.js.map +0 -1
- package/dist/chunk-6YSGUAVW.js.map +0 -1
- package/dist/chunk-BTBHHBVR.cjs.map +0 -1
- package/dist/chunk-JJ3RASQS.cjs.map +0 -1
- package/dist/chunk-LE3F7WIP.js.map +0 -1
- package/dist/chunk-MLRAVUFG.cjs.map +0 -1
- package/dist/chunk-PGSS4IOS.js.map +0 -1
- package/dist/chunk-SSIRYUCK.js.map +0 -1
- /package/dist/{chunk-QXG3HWDS.js.map → chunk-623AOJM2.js.map} +0 -0
- /package/dist/{chunk-UBNG5YCG.js.map → chunk-ADSJ42DO.js.map} +0 -0
- /package/dist/{chunk-UCXLRRWY.js.map → chunk-C23RQVRK.js.map} +0 -0
- /package/dist/{chunk-26Q4LSIU.js.map → chunk-DUE3HCZD.js.map} +0 -0
- /package/dist/{chunk-A4IJSJKL.js.map → chunk-IQBMAE3F.js.map} +0 -0
- /package/dist/{chunk-PIWRSX7U.js.map → chunk-JHQUHFLX.js.map} +0 -0
- /package/dist/{chunk-RQW3P3GH.js.map → chunk-N4FGA3H4.js.map} +0 -0
- /package/dist/{chunk-LV6EYPJO.js.map → chunk-NEZJ7ZP5.js.map} +0 -0
- /package/dist/{chunk-UPSLDTLT.js.map → chunk-OBMBSU2S.js.map} +0 -0
- /package/dist/{chunk-WMN6566P.js.map → chunk-OSHZQR3W.js.map} +0 -0
- /package/dist/{chunk-6LMS5J3Y.js.map → chunk-RJRX34BZ.js.map} +0 -0
- /package/dist/{chunk-LMAEPFTX.js.map → chunk-U3LOLYAU.js.map} +0 -0
- /package/dist/{chunk-GPIDU3GN.js.map → chunk-VCLL5C7J.js.map} +0 -0
- /package/dist/{chunk-OCCKQHCY.js.map → chunk-YBMUEEM5.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk6V6GGBDKcjs = require('./chunk-6V6GGBDK.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -56,7 +56,7 @@ var _chunkXX5FTPJRcjs = require('./chunk-XX5FTPJR.cjs');
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
|
|
60
60
|
|
|
61
61
|
// src/engine/transform/step.ts
|
|
62
62
|
var StepError = class extends Error {
|
|
@@ -65,7 +65,7 @@ var identityMap = (pos) => pos;
|
|
|
65
65
|
|
|
66
66
|
// src/engine/transform/step-access.ts
|
|
67
67
|
function requireBlock(doc, id) {
|
|
68
|
-
const block =
|
|
68
|
+
const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, id);
|
|
69
69
|
if (block === void 0) throw new StepError(`no block "${id}"`);
|
|
70
70
|
return block;
|
|
71
71
|
}
|
|
@@ -75,7 +75,7 @@ function requireRegion(block, region) {
|
|
|
75
75
|
}
|
|
76
76
|
function requireRange(block, region, from, to) {
|
|
77
77
|
const inline = requireRegion(block, region);
|
|
78
|
-
const length =
|
|
78
|
+
const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline);
|
|
79
79
|
if (!(Number.isInteger(from) && Number.isInteger(to) && from >= 0 && from <= to && to <= length)) {
|
|
80
80
|
throw new StepError(`range ${from} to ${to} is outside 0 to ${length} in "${block.id}" ${region}`);
|
|
81
81
|
}
|
|
@@ -99,7 +99,7 @@ function patchAttrs(attrs, patch) {
|
|
|
99
99
|
}
|
|
100
100
|
function patchChangesAttrs(attrs, patch) {
|
|
101
101
|
return Object.keys(patch).some(
|
|
102
|
-
(key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !
|
|
102
|
+
(key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !_chunk6V6GGBDKcjs.sameValue.call(void 0, attrs[key], patch[key])
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
function previousValues(attrs, patch) {
|
|
@@ -121,7 +121,7 @@ function setAttrsStep(block, patch) {
|
|
|
121
121
|
stepType: "setAttrs",
|
|
122
122
|
apply(doc) {
|
|
123
123
|
requireBlock(doc, block);
|
|
124
|
-
return { doc:
|
|
124
|
+
return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => ({ ...b, attrs: patchAttrs(b.attrs, patch) })), map: identityMap };
|
|
125
125
|
},
|
|
126
126
|
invert: (before) => setAttrsStep(block, previousValues(requireBlock(before, block).attrs, patch)),
|
|
127
127
|
toJSON: () => ({ stepType: "setAttrs", block, patch: patchToJSON(patch) })
|
|
@@ -135,7 +135,7 @@ function setIndentStep(block, indent2) {
|
|
|
135
135
|
if (!Number.isInteger(indent2) || indent2 < 0) {
|
|
136
136
|
throw new StepError(`indent ${indent2} is not a non-negative integer`);
|
|
137
137
|
}
|
|
138
|
-
return { doc:
|
|
138
|
+
return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => ({ ...b, indent: indent2 })), map: identityMap };
|
|
139
139
|
},
|
|
140
140
|
invert: (before) => setIndentStep(block, requireBlock(before, block).indent),
|
|
141
141
|
toJSON: () => ({ stepType: "setIndent", block, indent: indent2 })
|
|
@@ -144,7 +144,7 @@ function setIndentStep(block, indent2) {
|
|
|
144
144
|
|
|
145
145
|
// src/engine/transform/block-edges.ts
|
|
146
146
|
function orderedRegions(block) {
|
|
147
|
-
return Object.keys(block.regions).sort(
|
|
147
|
+
return Object.keys(block.regions).sort(_chunk4SLJNZSMcjs.compareRegionNames);
|
|
148
148
|
}
|
|
149
149
|
function firstRegion(block) {
|
|
150
150
|
return _nullishCoalesce(orderedRegions(block)[0], () => ( null));
|
|
@@ -157,12 +157,12 @@ function blockEnd(block) {
|
|
|
157
157
|
return {
|
|
158
158
|
block: block.id,
|
|
159
159
|
region: _nullishCoalesce(region, () => ( "")),
|
|
160
|
-
offset: region === void 0 ? 0 :
|
|
160
|
+
offset: region === void 0 ? 0 : _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[region])
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
function clampPos(block, pos) {
|
|
164
164
|
if (!Object.hasOwn(block.regions, pos.region)) return blockStart(block);
|
|
165
|
-
const length =
|
|
165
|
+
const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[pos.region]);
|
|
166
166
|
return pos.offset > length ? { ...pos, offset: length } : pos;
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -177,7 +177,7 @@ function insertBlocksStep(index, blocks) {
|
|
|
177
177
|
if (doc.index.has(id) || ids.has(id)) throw new StepError(`block "${id}" is already in the document`);
|
|
178
178
|
ids.add(id);
|
|
179
179
|
}
|
|
180
|
-
return { doc:
|
|
180
|
+
return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, index, 0, blocks), map: identityMap };
|
|
181
181
|
},
|
|
182
182
|
invert: () => removeBlocksStep(index, blocks.length),
|
|
183
183
|
toJSON: () => ({ stepType: "insertBlocks", index, blocks })
|
|
@@ -197,7 +197,7 @@ function removeBlocksStep(index, count2) {
|
|
|
197
197
|
const after = following && blockStart(following);
|
|
198
198
|
return _nullishCoalesce((assoc === -1 ? _nullishCoalesce(before, () => ( after)) : _nullishCoalesce(after, () => ( before))), () => ( pos));
|
|
199
199
|
};
|
|
200
|
-
return { doc:
|
|
200
|
+
return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, index, count2, []), map };
|
|
201
201
|
},
|
|
202
202
|
invert: (before) => insertBlocksStep(index, before.blocks.slice(index, index + count2)),
|
|
203
203
|
toJSON: () => ({ stepType: "removeBlocks", index, count: count2 })
|
|
@@ -211,14 +211,14 @@ function moveBlocksStep(from, count2, to) {
|
|
|
211
211
|
requireSpan(to, count2, doc.blocks.length);
|
|
212
212
|
const moved2 = doc.blocks.slice(from, from + count2);
|
|
213
213
|
const rest = [...doc.blocks.slice(0, from), ...doc.blocks.slice(from + count2)];
|
|
214
|
-
return { doc:
|
|
214
|
+
return { doc: _chunk4SLJNZSMcjs.createDoc.call(void 0, [...rest.slice(0, to), ...moved2, ...rest.slice(to)]), map: identityMap };
|
|
215
215
|
},
|
|
216
216
|
invert: () => moveBlocksStep(to, count2, from),
|
|
217
217
|
toJSON: () => ({ stepType: "moveBlocks", from, count: count2, to })
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
var keepsRegions = (before, after) => Object.entries(before.regions).every(
|
|
221
|
-
([name, inline]) => Object.hasOwn(after.regions, name) &&
|
|
221
|
+
([name, inline]) => Object.hasOwn(after.regions, name) && _chunk4SLJNZSMcjs.equalInline.call(void 0, inline, after.regions[name])
|
|
222
222
|
);
|
|
223
223
|
function replaceBlockStep(block) {
|
|
224
224
|
const clamp = (pos) => pos.block === block.id ? clampPos(block, pos) : pos;
|
|
@@ -226,7 +226,7 @@ function replaceBlockStep(block) {
|
|
|
226
226
|
stepType: "replaceBlock",
|
|
227
227
|
apply(doc) {
|
|
228
228
|
const map = keepsRegions(requireBlock(doc, block.id), block) ? identityMap : clamp;
|
|
229
|
-
return { doc:
|
|
229
|
+
return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block.id, () => block), map };
|
|
230
230
|
},
|
|
231
231
|
invert: (before) => replaceBlockStep(requireBlock(before, block.id)),
|
|
232
232
|
toJSON: () => ({ stepType: "replaceBlock", block })
|
|
@@ -235,7 +235,7 @@ function replaceBlockStep(block) {
|
|
|
235
235
|
|
|
236
236
|
// src/engine/transform/replace-inline-step.ts
|
|
237
237
|
function replaceInlineStep(block, region, from, to, slice) {
|
|
238
|
-
const inserted =
|
|
238
|
+
const inserted = _chunk4SLJNZSMcjs.inlineLength.call(void 0, slice);
|
|
239
239
|
const map = (pos, assoc = 1) => {
|
|
240
240
|
if (pos.block !== block || pos.region !== region || pos.offset < from) return pos;
|
|
241
241
|
if (pos.offset > to) return { ...pos, offset: pos.offset + inserted - (to - from) };
|
|
@@ -245,12 +245,12 @@ function replaceInlineStep(block, region, from, to, slice) {
|
|
|
245
245
|
stepType: "replaceInline",
|
|
246
246
|
apply(doc) {
|
|
247
247
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
248
|
-
const next =
|
|
248
|
+
const next = _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => withRegion(b, region, _chunk4SLJNZSMcjs.replaceInline.call(void 0, inline, from, to, slice)));
|
|
249
249
|
return { doc: next, map };
|
|
250
250
|
},
|
|
251
251
|
invert(before) {
|
|
252
252
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
253
|
-
return replaceInlineStep(block, region, from, from + inserted,
|
|
253
|
+
return replaceInlineStep(block, region, from, from + inserted, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to));
|
|
254
254
|
},
|
|
255
255
|
toJSON: () => ({ stepType: "replaceInline", block, region, from, to, slice })
|
|
256
256
|
});
|
|
@@ -263,24 +263,24 @@ function markStep(stepType, target, mark, change) {
|
|
|
263
263
|
stepType,
|
|
264
264
|
apply(doc) {
|
|
265
265
|
const inline = requireRange(requireBlock(doc, block), region, from, to);
|
|
266
|
-
return { doc:
|
|
266
|
+
return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
|
|
267
267
|
},
|
|
268
268
|
invert(before) {
|
|
269
269
|
const inline = requireRange(requireBlock(before, block), region, from, to);
|
|
270
|
-
return replaceInlineStep(block, region, from, to,
|
|
270
|
+
return replaceInlineStep(block, region, from, to, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to));
|
|
271
271
|
},
|
|
272
272
|
toJSON: () => ({ stepType, ...target, mark })
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
function addMarkStep(block, region, from, to, mark) {
|
|
276
|
-
return markStep("addMark", { block, region, from, to }, mark, (inline) =>
|
|
276
|
+
return markStep("addMark", { block, region, from, to }, mark, (inline) => _chunk4SLJNZSMcjs.addMarkRange.call(void 0, inline, from, to, mark));
|
|
277
277
|
}
|
|
278
278
|
function removeMarkStep(block, region, from, to, mark) {
|
|
279
279
|
return markStep(
|
|
280
280
|
"removeMark",
|
|
281
281
|
{ block, region, from, to },
|
|
282
282
|
mark,
|
|
283
|
-
(inline) =>
|
|
283
|
+
(inline) => _chunk4SLJNZSMcjs.removeMarkRange.call(void 0, inline, from, to, mark)
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
286
|
|
|
@@ -310,7 +310,7 @@ function mapTextChange(before, after) {
|
|
|
310
310
|
const ops = removed.length + added.length > DIFF_LIMIT ? [
|
|
311
311
|
{ op: "delete", items: removed },
|
|
312
312
|
{ op: "insert", items: added }
|
|
313
|
-
] :
|
|
313
|
+
] : _chunk6V6GGBDKcjs.diffSequences.call(void 0, removed.split(""), added.split(""));
|
|
314
314
|
return (offset, assoc) => {
|
|
315
315
|
let b = from;
|
|
316
316
|
let a = from;
|
|
@@ -336,13 +336,13 @@ function replaceDocStep(next) {
|
|
|
336
336
|
const regionMaps = /* @__PURE__ */ new Map();
|
|
337
337
|
const map = (pos, assoc = 1) => {
|
|
338
338
|
const { block, region } = pos;
|
|
339
|
-
const survivor =
|
|
339
|
+
const survivor = _chunk4SLJNZSMcjs.blockById.call(void 0, next, block);
|
|
340
340
|
if (survivor !== void 0) {
|
|
341
341
|
const key = JSON.stringify([block, region]);
|
|
342
342
|
let regionMap = regionMaps.get(key);
|
|
343
343
|
if (regionMap === void 0) {
|
|
344
|
-
const before =
|
|
345
|
-
regionMap = mapTextChange(before,
|
|
344
|
+
const before = _chunk4SLJNZSMcjs.inlineText.call(void 0, _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _2 => _2.regions, 'access', _3 => _3[region]]), () => ( [])));
|
|
345
|
+
regionMap = mapTextChange(before, _chunk4SLJNZSMcjs.inlineText.call(void 0, _nullishCoalesce(survivor.regions[region], () => ( []))));
|
|
346
346
|
regionMaps.set(key, regionMap);
|
|
347
347
|
}
|
|
348
348
|
const offset = regionMap(pos.offset, assoc);
|
|
@@ -376,10 +376,10 @@ function splitBlockStep(block, region, offset, created) {
|
|
|
376
376
|
type: created.type,
|
|
377
377
|
indent: created.indent,
|
|
378
378
|
attrs: created.attrs,
|
|
379
|
-
regions: { ...created.regions, [created.region]:
|
|
379
|
+
regions: { ...created.regions, [created.region]: _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, offset, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline)) }
|
|
380
380
|
};
|
|
381
|
-
const head = withRegion(target, region,
|
|
382
|
-
return { doc:
|
|
381
|
+
const head = withRegion(target, region, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, 0, offset));
|
|
382
|
+
return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, block), 1, [head, tail]), map };
|
|
383
383
|
},
|
|
384
384
|
invert: () => joinBlocksStep(block, region, created.id, created.region),
|
|
385
385
|
toJSON: () => ({ stepType: "splitBlock", block, region, offset, created })
|
|
@@ -391,17 +391,17 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
|
|
|
391
391
|
apply(doc) {
|
|
392
392
|
const first = requireBlock(doc, target);
|
|
393
393
|
const second = requireBlock(doc, source);
|
|
394
|
-
const index =
|
|
395
|
-
if (
|
|
394
|
+
const index = _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, target);
|
|
395
|
+
if (_chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, source) !== index + 1) throw new StepError(`block "${source}" does not follow "${target}"`);
|
|
396
396
|
const head = requireRegion(first, targetRegion);
|
|
397
|
-
const length =
|
|
398
|
-
const merged =
|
|
397
|
+
const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, head);
|
|
398
|
+
const merged = _chunk4SLJNZSMcjs.replaceInline.call(void 0, head, length, length, requireRegion(second, sourceRegion));
|
|
399
399
|
const map = (pos) => pos.block === source ? { block: target, region: targetRegion, offset: length + (pos.region === sourceRegion ? pos.offset : 0) } : pos;
|
|
400
|
-
return { doc:
|
|
400
|
+
return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
|
|
401
401
|
},
|
|
402
402
|
invert(before) {
|
|
403
403
|
const { id, type, attrs, indent: indent2, regions } = requireBlock(before, source);
|
|
404
|
-
const length =
|
|
404
|
+
const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, requireRegion(requireBlock(before, target), targetRegion));
|
|
405
405
|
const created = { id, type, attrs, indent: indent2, region: sourceRegion, regions };
|
|
406
406
|
return splitBlockStep(target, targetRegion, length, created);
|
|
407
407
|
},
|
|
@@ -410,9 +410,9 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
// src/engine/transform/step-json.ts
|
|
413
|
-
var isRegions = (value) =>
|
|
414
|
-
var isMark = (value) =>
|
|
415
|
-
var isBlockShape = (value) =>
|
|
413
|
+
var isRegions = (value) => _chunk4SLJNZSMcjs.isRecord.call(void 0, value) && Object.values(value).every(Array.isArray);
|
|
414
|
+
var isMark = (value) => _chunk4SLJNZSMcjs.isRecord.call(void 0, value) && typeof value.type === "string" && (value.attrs === void 0 || _chunk4SLJNZSMcjs.isRecord.call(void 0, value.attrs));
|
|
415
|
+
var isBlockShape = (value) => _chunk4SLJNZSMcjs.isRecord.call(void 0, value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && _chunk4SLJNZSMcjs.isRecord.call(void 0, value.attrs);
|
|
416
416
|
var isBlock = (value) => isBlockShape(value) && isRegions(value.regions);
|
|
417
417
|
var isCreated = (value) => isBlockShape(value) && typeof value.region === "string" && (value.regions === void 0 || isRegions(value.regions));
|
|
418
418
|
var isString = (value) => typeof value === "string";
|
|
@@ -424,7 +424,7 @@ function docOf(blocks) {
|
|
|
424
424
|
if (new Set(blocks.map((block) => block.id)).size !== blocks.length) {
|
|
425
425
|
throw new StepError("a replaceDoc step repeats a block id");
|
|
426
426
|
}
|
|
427
|
-
return
|
|
427
|
+
return _chunk4SLJNZSMcjs.createDoc.call(void 0, blocks);
|
|
428
428
|
}
|
|
429
429
|
function reader(json) {
|
|
430
430
|
return (key, accept) => {
|
|
@@ -461,7 +461,7 @@ function stepFromJSON(json) {
|
|
|
461
461
|
read("mark", isMarkOrType)
|
|
462
462
|
);
|
|
463
463
|
case "setAttrs":
|
|
464
|
-
return setAttrsStep(read("block", isString), patchFromJSON(read("patch",
|
|
464
|
+
return setAttrsStep(read("block", isString), patchFromJSON(read("patch", _chunk4SLJNZSMcjs.isRecord)));
|
|
465
465
|
case "setIndent":
|
|
466
466
|
return setIndentStep(read("block", isString), read("indent", isInteger));
|
|
467
467
|
case "insertBlocks":
|
|
@@ -495,7 +495,7 @@ function stepFromJSON(json) {
|
|
|
495
495
|
|
|
496
496
|
// src/engine/model/position.ts
|
|
497
497
|
function comparePos(doc, a, b) {
|
|
498
|
-
return
|
|
498
|
+
return _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, a.block) - _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, b.block) || _chunk4SLJNZSMcjs.compareRegionNames.call(void 0, a.region, b.region) || a.offset - b.offset;
|
|
499
499
|
}
|
|
500
500
|
function orderedRange(doc, anchor, head) {
|
|
501
501
|
return comparePos(doc, anchor, head) <= 0 ? { from: anchor, to: head } : { from: head, to: anchor };
|
|
@@ -534,7 +534,7 @@ function selectedBlockIds(doc, selection) {
|
|
|
534
534
|
if (selection === null) return [];
|
|
535
535
|
if (selection.kind === "node") return [selection.block];
|
|
536
536
|
const ends = selection.kind === "text" ? [selection.anchor.block, selection.head.block] : [selection.anchor, selection.head];
|
|
537
|
-
const [first, second] = ends.map((id) =>
|
|
537
|
+
const [first, second] = ends.map((id) => _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id));
|
|
538
538
|
return doc.blocks.slice(Math.min(first, second), Math.max(first, second) + 1).map((block) => block.id);
|
|
539
539
|
}
|
|
540
540
|
function isBackward(doc, selection) {
|
|
@@ -542,7 +542,7 @@ function isBackward(doc, selection) {
|
|
|
542
542
|
const { anchor, head } = selection;
|
|
543
543
|
return doc.index.has(anchor.block) && doc.index.has(head.block) && comparePos(doc, anchor, head) > 0;
|
|
544
544
|
}
|
|
545
|
-
return doc.index.has(selection.anchor) && doc.index.has(selection.head) &&
|
|
545
|
+
return doc.index.has(selection.anchor) && doc.index.has(selection.head) && _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, selection.anchor) > _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, selection.head);
|
|
546
546
|
}
|
|
547
547
|
var blockProbe = (block) => ({ block, region: "", offset: 0 });
|
|
548
548
|
function mapSelection(selection, map, doc) {
|
|
@@ -561,18 +561,18 @@ function mapSelection(selection, map, doc) {
|
|
|
561
561
|
return anchor === selection.anchor && head === selection.head ? selection : textSelection(anchor, head);
|
|
562
562
|
}
|
|
563
563
|
function primaryRegion(schema, block) {
|
|
564
|
-
const spec =
|
|
564
|
+
const spec = _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type);
|
|
565
565
|
if (spec.flow === "text" && spec.primaryRegion !== void 0 && Object.hasOwn(block.regions, spec.primaryRegion)) {
|
|
566
566
|
return spec.primaryRegion;
|
|
567
567
|
}
|
|
568
568
|
return firstRegion(block);
|
|
569
569
|
}
|
|
570
570
|
function flowEdge(schema, block, atEnd) {
|
|
571
|
-
const region =
|
|
572
|
-
return region === null ? null : { block: block.id, region, offset: atEnd ?
|
|
571
|
+
const region = _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
|
|
572
|
+
return region === null ? null : { block: block.id, region, offset: atEnd ? _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[region]) : 0 };
|
|
573
573
|
}
|
|
574
574
|
function edge(doc, schema, blockId, atEnd) {
|
|
575
|
-
const block = doc.blocks[
|
|
575
|
+
const block = doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, blockId)];
|
|
576
576
|
const flow = flowEdge(schema, block, atEnd);
|
|
577
577
|
if (flow !== null) return textSelection(flow);
|
|
578
578
|
if (Object.keys(block.regions).length === 0) return nodeSelection(blockId);
|
|
@@ -588,13 +588,13 @@ function defaultSelection(doc, schema) {
|
|
|
588
588
|
return doc.blocks.length === 0 ? null : startOf(doc, schema, doc.blocks[0].id);
|
|
589
589
|
}
|
|
590
590
|
function validatePos(doc, schema, pos) {
|
|
591
|
-
const block =
|
|
591
|
+
const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, pos.block);
|
|
592
592
|
if (block === void 0) return null;
|
|
593
593
|
if (!Object.hasOwn(block.regions, pos.region)) {
|
|
594
594
|
const region = primaryRegion(schema, block);
|
|
595
595
|
return region === null ? nodeSelection(block.id) : { block: block.id, region, offset: 0 };
|
|
596
596
|
}
|
|
597
|
-
const length =
|
|
597
|
+
const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[pos.region]);
|
|
598
598
|
return pos.offset >= 0 && pos.offset <= length ? pos : { ...pos, offset: Math.min(Math.max(pos.offset, 0), length) };
|
|
599
599
|
}
|
|
600
600
|
function nearestFlow(doc, schema, from, to, atEnd) {
|
|
@@ -605,14 +605,14 @@ function nearestFlow(doc, schema, from, to, atEnd) {
|
|
|
605
605
|
}
|
|
606
606
|
return null;
|
|
607
607
|
}
|
|
608
|
-
var inFlow = (doc, schema, pos) => _optionalChain([flowEdge, 'call', _6 => _6(schema, doc.blocks[
|
|
608
|
+
var inFlow = (doc, schema, pos) => _optionalChain([flowEdge, 'call', _6 => _6(schema, doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, pos.block)], false), 'optionalAccess', _7 => _7.region]) === pos.region;
|
|
609
609
|
function clampToFlow(doc, schema, selection) {
|
|
610
610
|
const { anchor, head } = selection;
|
|
611
611
|
if (anchor.block === head.block) return selection;
|
|
612
612
|
const backward = comparePos(doc, anchor, head) > 0;
|
|
613
613
|
const [from, to] = backward ? [head, anchor] : [anchor, head];
|
|
614
|
-
const first =
|
|
615
|
-
const last =
|
|
614
|
+
const first = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
|
|
615
|
+
const last = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
|
|
616
616
|
const start = inFlow(doc, schema, from) ? from : nearestFlow(doc, schema, first + 1, last, false);
|
|
617
617
|
const end = inFlow(doc, schema, to) ? to : nearestFlow(doc, schema, last - 1, first, true);
|
|
618
618
|
if (start === from && end === to) return selection;
|
|
@@ -631,9 +631,9 @@ function validateText(doc, schema, selection) {
|
|
|
631
631
|
return clampToFlow(doc, schema, valid);
|
|
632
632
|
}
|
|
633
633
|
function validateNode(doc, schema, selection) {
|
|
634
|
-
const block =
|
|
634
|
+
const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, selection.block);
|
|
635
635
|
if (block === void 0) return defaultSelection(doc, schema);
|
|
636
|
-
return
|
|
636
|
+
return _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
|
|
637
637
|
}
|
|
638
638
|
function validateSelection(doc, schema, selection) {
|
|
639
639
|
if (doc.blocks.length === 0) return null;
|
|
@@ -664,7 +664,7 @@ function hidingToggle(doc, index, isClosed = isClosedToggle) {
|
|
|
664
664
|
}
|
|
665
665
|
|
|
666
666
|
// src/engine/state/visible-selection.ts
|
|
667
|
-
var hiderOf = (doc, id) => hidingToggle(doc,
|
|
667
|
+
var hiderOf = (doc, id) => hidingToggle(doc, _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id) + 1);
|
|
668
668
|
function toggleEnd(doc, schema, toggle) {
|
|
669
669
|
const end = endOf(doc, schema, doc.blocks[toggle].id);
|
|
670
670
|
return end.kind === "text" ? end.head : blockEnd(doc.blocks[toggle]);
|
|
@@ -678,7 +678,7 @@ function visibleText(doc, schema, selection) {
|
|
|
678
678
|
}
|
|
679
679
|
function visibleBlocks(doc, schema, selection) {
|
|
680
680
|
const ids = [selection.anchor, selection.head];
|
|
681
|
-
const indexes = ids.map((id) =>
|
|
681
|
+
const indexes = ids.map((id) => _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id));
|
|
682
682
|
const from = Math.min(...indexes);
|
|
683
683
|
const to = Math.max(...indexes);
|
|
684
684
|
const hiders = indexes.map((index) => hidingToggle(doc, index + 1));
|
|
@@ -859,8 +859,8 @@ var Transaction = class {
|
|
|
859
859
|
// src/engine/commands/caret-marks.ts
|
|
860
860
|
function caretMarks(doc, schema, storedMarks, pos) {
|
|
861
861
|
if (storedMarks !== null) return storedMarks;
|
|
862
|
-
const inline = _nullishCoalesce(_optionalChain([
|
|
863
|
-
return
|
|
862
|
+
const inline = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, pos.block), 'optionalAccess', _8 => _8.regions, 'access', _9 => _9[pos.region]]), () => ( []));
|
|
863
|
+
return _chunk4SLJNZSMcjs.marksAt.call(void 0, inline, pos.offset, (mark) => _nullishCoalesce(_optionalChain([schema, 'access', _10 => _10.marks, 'access', _11 => _11.get, 'call', _12 => _12(mark.type), 'optionalAccess', _13 => _13.inclusive]), () => ( true)));
|
|
864
864
|
}
|
|
865
865
|
|
|
866
866
|
// src/engine/commands/run-commands.ts
|
|
@@ -1004,7 +1004,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
1004
1004
|
const { steps, undoText, at, marks } = record;
|
|
1005
1005
|
const tr = new Transaction(state).setMeta(UNFILTERED, true);
|
|
1006
1006
|
steps.forEach((step) => tr.step(step));
|
|
1007
|
-
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [
|
|
1007
|
+
tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [_chunk4SLJNZSMcjs.text.call(void 0, undoText, marks)]));
|
|
1008
1008
|
dispatch(tr.setSelection(textSelection({ ...at, offset: at.offset + undoText.length })));
|
|
1009
1009
|
}
|
|
1010
1010
|
return true;
|
|
@@ -1013,7 +1013,7 @@ var undoInputRule = (state, dispatch) => {
|
|
|
1013
1013
|
// src/engine/commands/block-helpers.ts
|
|
1014
1014
|
var ITEM_KINDS = /* @__PURE__ */ new Set(["bullet", "ordered", "task", "quote"]);
|
|
1015
1015
|
function specOf(schema, block) {
|
|
1016
|
-
return
|
|
1016
|
+
return _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type);
|
|
1017
1017
|
}
|
|
1018
1018
|
function isTextFlow(schema, block) {
|
|
1019
1019
|
return specOf(schema, block).flow === "text";
|
|
@@ -1025,7 +1025,7 @@ function isItem(block) {
|
|
|
1025
1025
|
return block.type === "MARKDOWN" && typeof block.attrs.kind === "string" && ITEM_KINDS.has(block.attrs.kind);
|
|
1026
1026
|
}
|
|
1027
1027
|
function regionLength(block, region) {
|
|
1028
|
-
return Object.hasOwn(block.regions, region) ?
|
|
1028
|
+
return Object.hasOwn(block.regions, region) ? _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[region]) : 0;
|
|
1029
1029
|
}
|
|
1030
1030
|
function descendantsEnd(doc, index) {
|
|
1031
1031
|
const { indent: indent2 } = doc.blocks[index];
|
|
@@ -1033,8 +1033,8 @@ function descendantsEnd(doc, index) {
|
|
|
1033
1033
|
while (end < doc.blocks.length && doc.blocks[end].indent > indent2) end++;
|
|
1034
1034
|
return end;
|
|
1035
1035
|
}
|
|
1036
|
-
function createBlock(schema, type, attrs = {}, indent2 = 0, id =
|
|
1037
|
-
const initial =
|
|
1036
|
+
function createBlock(schema, type, attrs = {}, indent2 = 0, id = _chunk4SLJNZSMcjs.newId.call(void 0, )) {
|
|
1037
|
+
const initial = _chunk4SLJNZSMcjs.specFor.call(void 0, schema, type).initial();
|
|
1038
1038
|
return { id, type, indent: indent2, attrs: { ...initial.attrs, ...attrs }, regions: initial.regions };
|
|
1039
1039
|
}
|
|
1040
1040
|
function withContent(schema, block, content) {
|
|
@@ -1052,7 +1052,7 @@ function headBlockId(selection) {
|
|
|
1052
1052
|
function selectedBlockRange(doc, selection) {
|
|
1053
1053
|
const ids = selectedBlockIds(doc, selection);
|
|
1054
1054
|
if (ids.length === 0) return null;
|
|
1055
|
-
const start =
|
|
1055
|
+
const start = _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, ids[0]);
|
|
1056
1056
|
let end = start + ids.length;
|
|
1057
1057
|
for (let index = start; index < start + ids.length; index++) end = Math.max(end, descendantsEnd(doc, index));
|
|
1058
1058
|
return { start, end };
|
|
@@ -1096,7 +1096,7 @@ function shiftSubtree(tr, index, delta) {
|
|
|
1096
1096
|
// src/engine/commands/block-structure.ts
|
|
1097
1097
|
var toggleTask = (state, dispatch) => {
|
|
1098
1098
|
const { doc, selection } = state;
|
|
1099
|
-
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[
|
|
1099
|
+
const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
|
|
1100
1100
|
if (tasks.length === 0) return false;
|
|
1101
1101
|
const checked = !tasks.every((block) => block.attrs.checked === true);
|
|
1102
1102
|
const tr = new Transaction(state);
|
|
@@ -1161,7 +1161,7 @@ function copiedSelection(selection, copies) {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
1163
1163
|
function duplicateBlocks(options = {}) {
|
|
1164
|
-
const makeId = _nullishCoalesce(options.newId, () => (
|
|
1164
|
+
const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
|
|
1165
1165
|
return (state, dispatch) => {
|
|
1166
1166
|
const { doc, selection } = state;
|
|
1167
1167
|
const range = selectedBlockRange(doc, selection);
|
|
@@ -1183,12 +1183,12 @@ var deleteBlocks = (state, dispatch) => {
|
|
|
1183
1183
|
return true;
|
|
1184
1184
|
};
|
|
1185
1185
|
function insertBlockAfter(type, attrs, options = {}) {
|
|
1186
|
-
const makeId = _nullishCoalesce(options.newId, () => (
|
|
1186
|
+
const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
|
|
1187
1187
|
return (state, dispatch) => {
|
|
1188
1188
|
const { doc, schema } = state;
|
|
1189
1189
|
const id = headBlockId(state.selection);
|
|
1190
1190
|
if (id === null) return false;
|
|
1191
|
-
const index =
|
|
1191
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id);
|
|
1192
1192
|
const current = doc.blocks[index];
|
|
1193
1193
|
const fillsCurrent = isParagraph(current) && regionLength(current, _nullishCoalesce(primaryRegion(schema, current), () => ( ""))) === 0;
|
|
1194
1194
|
const block = createBlock(schema, type, attrs, current.indent, fillsCurrent ? current.id : makeId());
|
|
@@ -1208,10 +1208,10 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1208
1208
|
clear(tr, from, from.offset, to.offset);
|
|
1209
1209
|
return from;
|
|
1210
1210
|
}
|
|
1211
|
-
const block = tr.doc.blocks[
|
|
1211
|
+
const block = tr.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, from.block)];
|
|
1212
1212
|
clear(tr, from, from.offset, regionLength(block, from.region));
|
|
1213
1213
|
for (const region of Object.keys(block.regions)) {
|
|
1214
|
-
const between =
|
|
1214
|
+
const between = _chunk4SLJNZSMcjs.compareRegionNames.call(void 0, from.region, region) < 0 && _chunk4SLJNZSMcjs.compareRegionNames.call(void 0, region, to.region) < 0;
|
|
1215
1215
|
if (between) clear(tr, { ...from, region }, 0, regionLength(block, region));
|
|
1216
1216
|
}
|
|
1217
1217
|
clear(tr, to, 0, to.offset);
|
|
@@ -1220,8 +1220,8 @@ function deleteWithinBlock(tr, from, to) {
|
|
|
1220
1220
|
function deleteRange(tr, schema, from, to, newId2) {
|
|
1221
1221
|
if (from.block === to.block) return deleteWithinBlock(tr, from, to);
|
|
1222
1222
|
const { doc } = tr;
|
|
1223
|
-
const start =
|
|
1224
|
-
const end =
|
|
1223
|
+
const start = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
|
|
1224
|
+
const end = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
|
|
1225
1225
|
const first = doc.blocks[start];
|
|
1226
1226
|
const last = doc.blocks[end];
|
|
1227
1227
|
const keepFirst = isTextFlow(schema, first);
|
|
@@ -1248,7 +1248,7 @@ function deleteRange(tr, schema, from, to, newId2) {
|
|
|
1248
1248
|
|
|
1249
1249
|
// src/engine/commands/insert-text-at.ts
|
|
1250
1250
|
function insertTextAt(tr, schema, pos, value) {
|
|
1251
|
-
const slice = [
|
|
1251
|
+
const slice = [_chunk4SLJNZSMcjs.text.call(void 0, value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
|
|
1252
1252
|
tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, slice));
|
|
1253
1253
|
return { ...pos, offset: pos.offset + value.length };
|
|
1254
1254
|
}
|
|
@@ -1260,12 +1260,12 @@ function replaceBlocksWithText(tr, schema, range, value, makeId) {
|
|
|
1260
1260
|
const indent2 = range === null ? 0 : doc.blocks[index].indent;
|
|
1261
1261
|
if (range !== null) tr.step(removeBlocksStep(index, range.end - range.start));
|
|
1262
1262
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, indent2, makeId());
|
|
1263
|
-
const paragraph = withContent(schema, empty, [
|
|
1263
|
+
const paragraph = withContent(schema, empty, [_chunk4SLJNZSMcjs.text.call(void 0, value)]);
|
|
1264
1264
|
tr.step(insertBlocksStep(index, [paragraph]));
|
|
1265
1265
|
tr.setSelection(endOf(tr.doc, schema, paragraph.id));
|
|
1266
1266
|
}
|
|
1267
1267
|
function insertText(value, options = {}) {
|
|
1268
|
-
const makeId = _nullishCoalesce(options.newId, () => (
|
|
1268
|
+
const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
|
|
1269
1269
|
return (state, dispatch) => {
|
|
1270
1270
|
if (value === "") return false;
|
|
1271
1271
|
const { doc, schema, selection } = state;
|
|
@@ -1288,9 +1288,9 @@ function markExtent(inline, offset, type) {
|
|
|
1288
1288
|
let position = 0;
|
|
1289
1289
|
for (const node of inline) {
|
|
1290
1290
|
starts.push(position);
|
|
1291
|
-
position +=
|
|
1291
|
+
position += _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
|
|
1292
1292
|
}
|
|
1293
|
-
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] +
|
|
1293
|
+
const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + _chunk4SLJNZSMcjs.nodeLength.call(void 0, node));
|
|
1294
1294
|
const markOf = (index) => _optionalChain([inline, 'access', _33 => _33[index], 'optionalAccess', _34 => _34.marks, 'access', _35 => _35.find, 'call', _36 => _36((mark2) => mark2.type === type)]);
|
|
1295
1295
|
let seed = containing(offset);
|
|
1296
1296
|
let mark = markOf(seed);
|
|
@@ -1299,29 +1299,29 @@ function markExtent(inline, offset, type) {
|
|
|
1299
1299
|
mark = markOf(seed);
|
|
1300
1300
|
}
|
|
1301
1301
|
if (mark === void 0) return null;
|
|
1302
|
-
const shares = (index) => inline[index].marks.some((other) =>
|
|
1302
|
+
const shares = (index) => inline[index].marks.some((other) => _chunk4SLJNZSMcjs.sameMark.call(void 0, other, mark));
|
|
1303
1303
|
let first = seed;
|
|
1304
1304
|
while (first > 0 && shares(first - 1)) first--;
|
|
1305
1305
|
let last = seed;
|
|
1306
1306
|
while (last < inline.length - 1 && shares(last + 1)) last++;
|
|
1307
|
-
return { from: starts[first], to: starts[last] +
|
|
1307
|
+
return { from: starts[first], to: starts[last] + _chunk4SLJNZSMcjs.nodeLength.call(void 0, inline[last]) };
|
|
1308
1308
|
}
|
|
1309
1309
|
|
|
1310
1310
|
// src/engine/commands/storable-mark.ts
|
|
1311
1311
|
function readsBack(inline) {
|
|
1312
|
-
return
|
|
1312
|
+
return _chunk4SLJNZSMcjs.equalInline.call(void 0, _chunk4SLJNZSMcjs.parseInline.call(void 0, _chunk4SLJNZSMcjs.serializeInline.call(void 0, inline)), _chunk4SLJNZSMcjs.normalizeInline.call(void 0, inline));
|
|
1313
1313
|
}
|
|
1314
1314
|
function safeLink(mark) {
|
|
1315
1315
|
const href = _optionalChain([mark, 'access', _37 => _37.attrs, 'optionalAccess', _38 => _38.href]);
|
|
1316
|
-
const safe = typeof href === "string" ?
|
|
1316
|
+
const safe = typeof href === "string" ? _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, href) : null;
|
|
1317
1317
|
return safe ? { type: "link", attrs: { ...mark.attrs, href: safe } } : null;
|
|
1318
1318
|
}
|
|
1319
1319
|
function storableMark(mark) {
|
|
1320
1320
|
const candidate = mark.type === "link" ? safeLink(mark) : mark;
|
|
1321
|
-
return candidate !== null && readsBack([
|
|
1321
|
+
return candidate !== null && readsBack([_chunk4SLJNZSMcjs.text.call(void 0, "a", [candidate])]) ? candidate : null;
|
|
1322
1322
|
}
|
|
1323
1323
|
function storableAtom(type, attrs) {
|
|
1324
|
-
return readsBack([
|
|
1324
|
+
return readsBack([_chunk4SLJNZSMcjs.atom.call(void 0, type, attrs)]);
|
|
1325
1325
|
}
|
|
1326
1326
|
|
|
1327
1327
|
// src/engine/commands/selection-marks.ts
|
|
@@ -1340,8 +1340,8 @@ function textRanges(state, selection) {
|
|
|
1340
1340
|
if (from.region !== to.region) return [];
|
|
1341
1341
|
return [{ block: from.block, region: from.region, from: from.offset, to: to.offset }];
|
|
1342
1342
|
}
|
|
1343
|
-
const first =
|
|
1344
|
-
const last =
|
|
1343
|
+
const first = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
|
|
1344
|
+
const last = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
|
|
1345
1345
|
return doc.blocks.slice(first, last + 1).flatMap((block, i) => {
|
|
1346
1346
|
const whole = wholeRegion(schema, block);
|
|
1347
1347
|
if (whole === null) return [];
|
|
@@ -1353,7 +1353,7 @@ function textRanges(state, selection) {
|
|
|
1353
1353
|
function selectionRanges(state, selection) {
|
|
1354
1354
|
if (selection.kind === "text") return textRanges(state, selection);
|
|
1355
1355
|
return selectedBlockIds(state.doc, selection).flatMap((id) => {
|
|
1356
|
-
const whole = wholeRegion(state.schema, state.doc.blocks[
|
|
1356
|
+
const whole = wholeRegion(state.schema, state.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, state.doc, id)]);
|
|
1357
1357
|
return whole === null ? [] : [whole];
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
@@ -1362,8 +1362,8 @@ function markRanges(state) {
|
|
|
1362
1362
|
return selection === null ? [] : selectionRanges(state, selection).filter((range) => range.from < range.to);
|
|
1363
1363
|
}
|
|
1364
1364
|
function rangeContent(state, range) {
|
|
1365
|
-
const inline = _nullishCoalesce(_optionalChain([
|
|
1366
|
-
return
|
|
1365
|
+
const inline = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, range.block), 'optionalAccess', _41 => _41.regions, 'access', _42 => _42[range.region]]), () => ( []));
|
|
1366
|
+
return _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, range.from, range.to);
|
|
1367
1367
|
}
|
|
1368
1368
|
function markCoverage(content, type, attrs) {
|
|
1369
1369
|
const carries = (node) => node.marks.some((mark) => matchesMark(mark, type, attrs));
|
|
@@ -1406,8 +1406,8 @@ function applyMark(type, attrs, mode) {
|
|
|
1406
1406
|
const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
|
|
1407
1407
|
const active = current.some((existing) => matchesMark(existing, type, mark.attrs));
|
|
1408
1408
|
const remove2 = mode === "remove" || mode === "toggle" && active;
|
|
1409
|
-
const next = remove2 ?
|
|
1410
|
-
if (
|
|
1409
|
+
const next = remove2 ? _chunk4SLJNZSMcjs.removeMark.call(void 0, current, target) : _chunk4SLJNZSMcjs.addMark.call(void 0, current, mark);
|
|
1410
|
+
if (_chunk4SLJNZSMcjs.sameMarkSet.call(void 0, next, current)) return false;
|
|
1411
1411
|
_optionalChain([dispatch, 'optionalCall', _46 => _46(new Transaction(state).setStoredMarks(next))]);
|
|
1412
1412
|
return true;
|
|
1413
1413
|
}
|
|
@@ -1431,17 +1431,17 @@ function unsetMark(type) {
|
|
|
1431
1431
|
function linkRanges(state) {
|
|
1432
1432
|
const caret = collapsedCaret(state);
|
|
1433
1433
|
if (caret === null) return markRanges(state);
|
|
1434
|
-
const inline = _nullishCoalesce(_optionalChain([
|
|
1434
|
+
const inline = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, caret.block), 'optionalAccess', _47 => _47.regions, 'access', _48 => _48[caret.region]]), () => ( []));
|
|
1435
1435
|
const extent = markExtent(inline, caret.offset, "link");
|
|
1436
1436
|
return extent === null ? [] : [{ block: caret.block, region: caret.region, ...extent }];
|
|
1437
1437
|
}
|
|
1438
1438
|
function setLink(href, title) {
|
|
1439
|
-
const safe =
|
|
1439
|
+
const safe = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, href);
|
|
1440
1440
|
return (state, dispatch) => {
|
|
1441
1441
|
if (safe === null || safe === "") return false;
|
|
1442
1442
|
const link = { type: "link", attrs: title ? { href: safe, title } : { href: safe } };
|
|
1443
1443
|
return editRanges(state, dispatch, linkRanges(state), (tr, { block, region, from, to }, content) => {
|
|
1444
|
-
const linked2 = content.every((node) => node.marks.some((mark) =>
|
|
1444
|
+
const linked2 = content.every((node) => node.marks.some((mark) => _chunk4SLJNZSMcjs.sameMark.call(void 0, mark, link)));
|
|
1445
1445
|
if (!linked2) tr.step(addMarkStep(block, region, from, to, link));
|
|
1446
1446
|
});
|
|
1447
1447
|
};
|
|
@@ -1471,7 +1471,7 @@ function insertAtom(type, attrs) {
|
|
|
1471
1471
|
const tr = new Transaction(state);
|
|
1472
1472
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
1473
1473
|
const caret = deleteRange(tr, schema, from, to);
|
|
1474
|
-
const node =
|
|
1474
|
+
const node = _chunk4SLJNZSMcjs.atom.call(void 0, type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
|
|
1475
1475
|
tr.step(replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [node]));
|
|
1476
1476
|
tr.setSelection(textSelection({ ...caret, offset: caret.offset + 1 }));
|
|
1477
1477
|
_optionalChain([dispatch, 'optionalCall', _51 => _51(tr)]);
|
|
@@ -1489,19 +1489,19 @@ var TEXT_ATTRIBUTE = /* @__PURE__ */ new Map([
|
|
|
1489
1489
|
["MATH", "latex"]
|
|
1490
1490
|
]);
|
|
1491
1491
|
function holdsText(schema, type) {
|
|
1492
|
-
return TEXT_ATTRIBUTE.has(type) ||
|
|
1492
|
+
return TEXT_ATTRIBUTE.has(type) || _chunk4SLJNZSMcjs.specFor.call(void 0, schema, type).flow === "text";
|
|
1493
1493
|
}
|
|
1494
1494
|
function sourceContent(schema, block) {
|
|
1495
1495
|
const field = TEXT_ATTRIBUTE.get(block.type);
|
|
1496
1496
|
if (field !== void 0) {
|
|
1497
1497
|
const value = block.attrs[field];
|
|
1498
|
-
return typeof value === "string" && value !== "" ? [
|
|
1498
|
+
return typeof value === "string" && value !== "" ? [_chunk4SLJNZSMcjs.text.call(void 0, value)] : [];
|
|
1499
1499
|
}
|
|
1500
1500
|
const region = primaryRegion(schema, block);
|
|
1501
1501
|
return region === null ? [] : block.regions[region];
|
|
1502
1502
|
}
|
|
1503
1503
|
function plainText(schema, content) {
|
|
1504
|
-
return
|
|
1504
|
+
return _chunk4SLJNZSMcjs.inlineText.call(void 0, content, (node) => _nullishCoalesce(_optionalChain([schema, 'access', _52 => _52.atoms, 'access', _53 => _53.get, 'call', _54 => _54(node.type), 'optionalAccess', _55 => _55.plainText, 'call', _56 => _56(node.attrs)]), () => ( "")));
|
|
1505
1505
|
}
|
|
1506
1506
|
function convert(schema, block, type, attrs) {
|
|
1507
1507
|
const content = sourceContent(schema, block);
|
|
@@ -1520,7 +1520,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1520
1520
|
if (!holdsText(schema, type)) return false;
|
|
1521
1521
|
const ids = selectedBlockIds(doc, selection);
|
|
1522
1522
|
const convertible = (block) => isTextFlow(schema, block) || _optionalChain([selection, 'optionalAccess', _57 => _57.kind]) === "node" && TEXT_ATTRIBUTE.has(block.type);
|
|
1523
|
-
const blocks = ids.flatMap((id) => _nullishCoalesce(
|
|
1523
|
+
const blocks = ids.flatMap((id) => _nullishCoalesce(_chunk4SLJNZSMcjs.blockById.call(void 0, doc, id), () => ( []))).filter(convertible);
|
|
1524
1524
|
if (blocks.length === 0) return false;
|
|
1525
1525
|
const tr = new Transaction(state);
|
|
1526
1526
|
const moved2 = /* @__PURE__ */ new Map();
|
|
@@ -1534,7 +1534,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1534
1534
|
tr.step(replaceBlockStep(next));
|
|
1535
1535
|
const from = primaryRegion(schema, block);
|
|
1536
1536
|
const to = primaryRegion(schema, next);
|
|
1537
|
-
if (from !== null && to !== null) moved2.set(block.id, { from, to, length:
|
|
1537
|
+
if (from !== null && to !== null) moved2.set(block.id, { from, to, length: _chunk4SLJNZSMcjs.inlineLength.call(void 0, next.regions[to]) });
|
|
1538
1538
|
}
|
|
1539
1539
|
if (!tr.docChanged) return false;
|
|
1540
1540
|
if (_optionalChain([selection, 'optionalAccess', _58 => _58.kind]) === "text" && moved2.size > 0) {
|
|
@@ -1545,7 +1545,7 @@ function setBlockType(type, attrs = {}) {
|
|
|
1545
1545
|
};
|
|
1546
1546
|
tr.setSelection(textSelection(carry(selection.anchor), carry(selection.head)));
|
|
1547
1547
|
}
|
|
1548
|
-
const converted = _optionalChain([selection, 'optionalAccess', _59 => _59.kind]) === "node" ?
|
|
1548
|
+
const converted = _optionalChain([selection, 'optionalAccess', _59 => _59.kind]) === "node" ? _chunk4SLJNZSMcjs.blockById.call(void 0, tr.doc, selection.block) : void 0;
|
|
1549
1549
|
if (converted !== void 0 && isTextFlow(schema, converted)) tr.setSelection(endOf(tr.doc, schema, converted.id));
|
|
1550
1550
|
_optionalChain([dispatch, 'optionalCall', _60 => _60(tr)]);
|
|
1551
1551
|
return true;
|
|
@@ -1563,10 +1563,10 @@ function ruleTransaction(state, rules, context) {
|
|
|
1563
1563
|
const { selection, doc } = state;
|
|
1564
1564
|
if (_optionalChain([selection, 'optionalAccess', _61 => _61.kind]) !== "text") return null;
|
|
1565
1565
|
const { block: id, region, offset } = selection.head;
|
|
1566
|
-
const block = doc.blocks[
|
|
1566
|
+
const block = doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id)];
|
|
1567
1567
|
const inline = block.regions[region];
|
|
1568
|
-
if (
|
|
1569
|
-
const before =
|
|
1568
|
+
if (_chunk4SLJNZSMcjs.hasMark.call(void 0, _chunk4SLJNZSMcjs.marksAt.call(void 0, inline, offset, () => true), "code")) return null;
|
|
1569
|
+
const before = _chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, 0, offset));
|
|
1570
1570
|
for (const rule of rules) {
|
|
1571
1571
|
const match = appliesTo(rule, block) ? rule.match.exec(before) : null;
|
|
1572
1572
|
if (match === null) continue;
|
|
@@ -1576,7 +1576,7 @@ function ruleTransaction(state, rules, context) {
|
|
|
1576
1576
|
return null;
|
|
1577
1577
|
}
|
|
1578
1578
|
function insertTextWithRules(value, rules, options = {}) {
|
|
1579
|
-
const context = { newId: _nullishCoalesce(options.newId, () => (
|
|
1579
|
+
const context = { newId: _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId)) };
|
|
1580
1580
|
const insert = insertText(value, { origin: "input", newId: context.newId });
|
|
1581
1581
|
return (state, dispatch) => {
|
|
1582
1582
|
let fired = false;
|
|
@@ -1624,11 +1624,11 @@ var divider = {
|
|
|
1624
1624
|
kinds: PARAGRAPH,
|
|
1625
1625
|
handler(state, _match, range, context) {
|
|
1626
1626
|
const { doc, schema } = state;
|
|
1627
|
-
const index =
|
|
1627
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, range.block);
|
|
1628
1628
|
const block = doc.blocks[index];
|
|
1629
1629
|
const content = block.regions[range.region];
|
|
1630
|
-
const tail =
|
|
1631
|
-
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (_nullishCoalesce(_optionalChain([context, 'optionalAccess', _65 => _65.newId]), () => ( (0,
|
|
1630
|
+
const tail = _chunk4SLJNZSMcjs.sliceInline.call(void 0, content, range.to, _chunk4SLJNZSMcjs.inlineLength.call(void 0, content));
|
|
1631
|
+
const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (_nullishCoalesce(_optionalChain([context, 'optionalAccess', _65 => _65.newId]), () => ( (0, _chunk4SLJNZSMcjs.newId))))());
|
|
1632
1632
|
const next = withContent(schema, empty, tail);
|
|
1633
1633
|
const tr = new Transaction(state);
|
|
1634
1634
|
tr.step(replaceBlockStep(createBlock(schema, "DIVIDER", {}, block.indent, block.id)));
|
|
@@ -1664,7 +1664,7 @@ var blockInputRules = [
|
|
|
1664
1664
|
|
|
1665
1665
|
// src/engine/markdown/autolink-href.ts
|
|
1666
1666
|
function autolinkHref(url) {
|
|
1667
|
-
return
|
|
1667
|
+
return _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, /^www\./i.test(url) ? `https://${url}` : url);
|
|
1668
1668
|
}
|
|
1669
1669
|
|
|
1670
1670
|
// src/engine/markdown/trim-url-end.ts
|
|
@@ -1686,12 +1686,12 @@ function trimUrlEnd(url) {
|
|
|
1686
1686
|
|
|
1687
1687
|
// src/engine/rules/region-inline.ts
|
|
1688
1688
|
function regionInline(state, range) {
|
|
1689
|
-
return state.doc.blocks[
|
|
1689
|
+
return state.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, state.doc, range.block)].regions[range.region];
|
|
1690
1690
|
}
|
|
1691
1691
|
|
|
1692
1692
|
// src/engine/rules/touches-mark.ts
|
|
1693
1693
|
function touchesMark(inline, from, to, type) {
|
|
1694
|
-
return
|
|
1694
|
+
return _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to).some((node) => _chunk4SLJNZSMcjs.hasMark.call(void 0, node.marks, type));
|
|
1695
1695
|
}
|
|
1696
1696
|
|
|
1697
1697
|
// src/engine/rules/autolink.ts
|
|
@@ -1725,7 +1725,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1725
1725
|
const contentTo = to - (_nullishCoalesce(_optionalChain([close, 'optionalCall', _66 => _66(found)]), () => ( open)));
|
|
1726
1726
|
const contentFrom = contentTo - found[1].length;
|
|
1727
1727
|
const from = contentFrom - open;
|
|
1728
|
-
if (wordBounded && WORD_CHARACTER.test(
|
|
1728
|
+
if (wordBounded && WORD_CHARACTER.test(_chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, to, to + 1)))) return null;
|
|
1729
1729
|
if (touchesMark(inline, from, contentFrom, "code") || touchesMark(inline, contentTo, to, "code")) return null;
|
|
1730
1730
|
const tr = new Transaction(state);
|
|
1731
1731
|
tr.step(addMarkStep(block, region, contentFrom, contentTo, added));
|
|
@@ -1733,7 +1733,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
|
|
|
1733
1733
|
tr.step(replaceInlineStep(block, region, from, contentFrom, []));
|
|
1734
1734
|
const caret = { block, region, offset: from + found[1].length };
|
|
1735
1735
|
const carried = caretMarks(tr.doc, state.schema, null, caret);
|
|
1736
|
-
return tr.setSelection(textSelection(caret)).setStoredMarks(
|
|
1736
|
+
return tr.setSelection(textSelection(caret)).setStoredMarks(_chunk4SLJNZSMcjs.removeMark.call(void 0, carried, added.type));
|
|
1737
1737
|
}
|
|
1738
1738
|
};
|
|
1739
1739
|
}
|
|
@@ -1754,7 +1754,7 @@ var markInputRules = [
|
|
|
1754
1754
|
open: 1,
|
|
1755
1755
|
close: (match) => match[2].length + 3,
|
|
1756
1756
|
mark(match) {
|
|
1757
|
-
const href =
|
|
1757
|
+
const href = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, match[2]);
|
|
1758
1758
|
return href === null ? null : { type: "link", attrs: { href } };
|
|
1759
1759
|
}
|
|
1760
1760
|
}),
|
|
@@ -1772,7 +1772,7 @@ function replacing(name, match, replacement) {
|
|
|
1772
1772
|
handler(state, found, range) {
|
|
1773
1773
|
const value = typeof replacement === "string" ? replacement : replacement(found);
|
|
1774
1774
|
const from = range.to - (_nullishCoalesce(found[1], () => ( found[0]))).length;
|
|
1775
|
-
const node =
|
|
1775
|
+
const node = _chunk4SLJNZSMcjs.text.call(void 0, value, _chunk4SLJNZSMcjs.marksAt.call(void 0, regionInline(state, range), range.to, () => true));
|
|
1776
1776
|
return new Transaction(state).step(replaceInlineStep(range.block, range.region, from, range.to, [node]));
|
|
1777
1777
|
}
|
|
1778
1778
|
};
|
|
@@ -2056,7 +2056,7 @@ function nearestPaletteColor(css, kind) {
|
|
|
2056
2056
|
const table = PALETTE_RGB[kind];
|
|
2057
2057
|
let best = "default";
|
|
2058
2058
|
let least = Infinity;
|
|
2059
|
-
for (const name of
|
|
2059
|
+
for (const name of _chunk4SLJNZSMcjs.PALETTE) {
|
|
2060
2060
|
for (const reference of table[name]) {
|
|
2061
2061
|
const gap = distance(rgb, reference);
|
|
2062
2062
|
if (gap < least) {
|
|
@@ -2070,31 +2070,31 @@ function nearestPaletteColor(css, kind) {
|
|
|
2070
2070
|
|
|
2071
2071
|
// src/engine/clipboard/html-marks.ts
|
|
2072
2072
|
function linkMark(element) {
|
|
2073
|
-
const href =
|
|
2073
|
+
const href = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, _nullishCoalesce(element.getAttribute("href"), () => ( "")));
|
|
2074
2074
|
if (href === null || href === "") return null;
|
|
2075
2075
|
const title = element.getAttribute("title");
|
|
2076
2076
|
return { type: "link", attrs: title ? { href, title } : { href } };
|
|
2077
2077
|
}
|
|
2078
2078
|
function highlightMark(element) {
|
|
2079
2079
|
const color = _nullishCoalesce(element.getAttribute("data-color"), () => ( ""));
|
|
2080
|
-
return
|
|
2080
|
+
return _chunk4SLJNZSMcjs.isPaletteColor.call(void 0, color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
|
|
2081
2081
|
}
|
|
2082
2082
|
function elementMarks(element, inherited) {
|
|
2083
2083
|
const tag = tagName(element);
|
|
2084
2084
|
const styles = parseStyle(element.getAttribute("style"));
|
|
2085
2085
|
let marks = inherited;
|
|
2086
2086
|
const add = (mark) => {
|
|
2087
|
-
marks =
|
|
2087
|
+
marks = _chunk4SLJNZSMcjs.addMark.call(void 0, marks, mark);
|
|
2088
2088
|
};
|
|
2089
2089
|
const link = tag === "a" ? linkMark(element) : null;
|
|
2090
2090
|
if (link !== null) add(link);
|
|
2091
|
-
const linked2 =
|
|
2091
|
+
const linked2 = _chunk4SLJNZSMcjs.hasMark.call(void 0, marks, "link");
|
|
2092
2092
|
const weight = fontWeight(styles);
|
|
2093
2093
|
if (weight !== null ? weight >= 600 : tag === "b" || tag === "strong") add({ type: "bold" });
|
|
2094
|
-
else if (weight !== null) marks =
|
|
2094
|
+
else if (weight !== null) marks = _chunk4SLJNZSMcjs.removeMark.call(void 0, marks, "bold");
|
|
2095
2095
|
const slanted = isItalicStyle(styles);
|
|
2096
2096
|
if (_nullishCoalesce(slanted, () => ( (tag === "i" || tag === "em")))) add({ type: "italic" });
|
|
2097
|
-
else if (slanted === false) marks =
|
|
2097
|
+
else if (slanted === false) marks = _chunk4SLJNZSMcjs.removeMark.call(void 0, marks, "italic");
|
|
2098
2098
|
if (tag === "u" || !linked2 && hasDecoration(styles, "underline")) add({ type: "underline" });
|
|
2099
2099
|
if (tag === "s" || tag === "del" || tag === "strike" || hasDecoration(styles, "line-through")) {
|
|
2100
2100
|
add({ type: "strike" });
|
|
@@ -2113,7 +2113,7 @@ function elementMarks(element, inherited) {
|
|
|
2113
2113
|
}
|
|
2114
2114
|
|
|
2115
2115
|
// src/engine/clipboard/hoist-spaces.ts
|
|
2116
|
-
var shared = (a, b) => a.filter((mark) => b.some((other) =>
|
|
2116
|
+
var shared = (a, b) => a.filter((mark) => b.some((other) => _chunk4SLJNZSMcjs.sameMark.call(void 0, mark, other)));
|
|
2117
2117
|
function hoistEdgeSpaces(pieces) {
|
|
2118
2118
|
const result = [];
|
|
2119
2119
|
pieces.forEach((piece, at) => {
|
|
@@ -2176,7 +2176,7 @@ function finish({ pieces }) {
|
|
|
2176
2176
|
break;
|
|
2177
2177
|
}
|
|
2178
2178
|
}
|
|
2179
|
-
const inline =
|
|
2179
|
+
const inline = _chunk4SLJNZSMcjs.normalizeInline.call(void 0, hoistEdgeSpaces(pieces).map((piece) => _chunk4SLJNZSMcjs.text.call(void 0, piece.text, piece.marks)));
|
|
2180
2180
|
return inline.every((node) => node.kind === "text" && node.text.trim() === "") ? [] : inline;
|
|
2181
2181
|
}
|
|
2182
2182
|
function visit(acc, node, style, depth) {
|
|
@@ -2273,7 +2273,7 @@ function wordListItem(paragraph, ctx, sink) {
|
|
|
2273
2273
|
|
|
2274
2274
|
// src/engine/clipboard/html-media.ts
|
|
2275
2275
|
function imageBlock(img, caption, ctx, sink) {
|
|
2276
|
-
const url =
|
|
2276
|
+
const url = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, _nullishCoalesce(img.getAttribute("src"), () => ( "")));
|
|
2277
2277
|
if (url === null || url === "") return;
|
|
2278
2278
|
emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: _nullishCoalesce(img.getAttribute("alt"), () => ( "")), url }, { caption });
|
|
2279
2279
|
}
|
|
@@ -2311,7 +2311,7 @@ function tableBlock(table, ctx, sink) {
|
|
|
2311
2311
|
rows.forEach((row, r) => {
|
|
2312
2312
|
for (let c = 0; c < cols; c++) {
|
|
2313
2313
|
const cell = row.cells[c];
|
|
2314
|
-
regions[
|
|
2314
|
+
regions[_chunk4SLJNZSMcjs.cellKey.call(void 0, r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
|
|
2315
2315
|
}
|
|
2316
2316
|
});
|
|
2317
2317
|
const header = rows[0].head || rows[0].cells.some((cell) => tagName(cell) === "th");
|
|
@@ -2324,7 +2324,7 @@ var HEADING = /^h([1-6])$/;
|
|
|
2324
2324
|
function emitRun(run, ctx, sink) {
|
|
2325
2325
|
const inline = inlineFromNodes(run, ctx);
|
|
2326
2326
|
if (inline.length === 0) return;
|
|
2327
|
-
const plain = ctx.run.kind === "heading" ?
|
|
2327
|
+
const plain = ctx.run.kind === "heading" ? _chunk4SLJNZSMcjs.removeMarkRange.call(void 0, inline, 0, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline), "bold") : inline;
|
|
2328
2328
|
emitText(sink, ctx.indent, ctx.run, plain);
|
|
2329
2329
|
}
|
|
2330
2330
|
function details(element, ctx, sink) {
|
|
@@ -2409,8 +2409,8 @@ function availableParser(parser) {
|
|
|
2409
2409
|
function fromHTML(html, options = {}) {
|
|
2410
2410
|
const parser = availableParser(options.parser);
|
|
2411
2411
|
if (parser === null) throw new Error("fromHTML needs a DOMParser");
|
|
2412
|
-
const makeId = _nullishCoalesce(options.newId, () => (
|
|
2413
|
-
const codec =
|
|
2412
|
+
const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
|
|
2413
|
+
const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, _chunk4SLJNZSMcjs.createSchema.call(void 0, ), { newId: makeId });
|
|
2414
2414
|
const { body } = parser.parseFromString(html, "text/html");
|
|
2415
2415
|
return blocksFromBody(body, makeId).map((block) => codec.toQuoin(block));
|
|
2416
2416
|
}
|
|
@@ -2431,7 +2431,7 @@ function quoteLines(text2) {
|
|
|
2431
2431
|
|
|
2432
2432
|
// src/engine/markdown/document/block-forms.ts
|
|
2433
2433
|
var ALERT_NAMES = new Map(
|
|
2434
|
-
Object.entries(
|
|
2434
|
+
Object.entries(_chunk4SLJNZSMcjs.ALERT_TONES).map(([name, tone]) => [tone, name])
|
|
2435
2435
|
);
|
|
2436
2436
|
var DELIMITERS = /* @__PURE__ */ new Map([
|
|
2437
2437
|
["left", ":--"],
|
|
@@ -2441,8 +2441,8 @@ var DELIMITERS = /* @__PURE__ */ new Map([
|
|
|
2441
2441
|
var MIN_FENCE = 3;
|
|
2442
2442
|
var FENCE_LIKE_MATH_LINE = /^ {0,3}\${2,}[ \t]*$/m;
|
|
2443
2443
|
function calloutMarkdown(data) {
|
|
2444
|
-
const name = _nullishCoalesce(ALERT_NAMES.get(
|
|
2445
|
-
const body =
|
|
2444
|
+
const name = _nullishCoalesce(ALERT_NAMES.get(_chunk4SLJNZSMcjs.str.call(void 0, data.tone)), () => ( "NOTE"));
|
|
2445
|
+
const body = _chunk4SLJNZSMcjs.str.call(void 0, data.body);
|
|
2446
2446
|
return quoteLines(body === "" ? `[!${name}]` : `[!${name}]
|
|
2447
2447
|
${body}`);
|
|
2448
2448
|
}
|
|
@@ -2456,18 +2456,18 @@ function longestRun(value, char) {
|
|
|
2456
2456
|
return longest;
|
|
2457
2457
|
}
|
|
2458
2458
|
function codeMarkdown(data) {
|
|
2459
|
-
const code =
|
|
2460
|
-
const info =
|
|
2459
|
+
const code = _chunk4SLJNZSMcjs.str.call(void 0, data.code);
|
|
2460
|
+
const info = _chunk4SLJNZSMcjs.str.call(void 0, data.language);
|
|
2461
2461
|
const char = info.includes("`") ? "~" : "`";
|
|
2462
2462
|
const fence = char.repeat(Math.max(MIN_FENCE, longestRun(code, char) + 1));
|
|
2463
2463
|
return [fence + info.replace(/[\\&]/g, "\\$&"), ...code === "" ? [] : code.split("\n"), fence].join("\n");
|
|
2464
2464
|
}
|
|
2465
2465
|
function mathMarkdown(data) {
|
|
2466
|
-
const latex =
|
|
2466
|
+
const latex = _chunk4SLJNZSMcjs.str.call(void 0, data.latex);
|
|
2467
2467
|
if (FENCE_LIKE_MATH_LINE.test(latex)) return null;
|
|
2468
2468
|
return ["$$", ...latex === "" ? [] : latex.split("\n"), "$$"].join("\n");
|
|
2469
2469
|
}
|
|
2470
|
-
var cellsOf = (row) => Array.isArray(row) ? row.map(
|
|
2470
|
+
var cellsOf = (row) => Array.isArray(row) ? row.map(_chunk4SLJNZSMcjs.str) : [];
|
|
2471
2471
|
var rowMarkdown = (cells) => `| ${cells.join(" | ")} |`;
|
|
2472
2472
|
function tableMarkdown(data) {
|
|
2473
2473
|
const rows = Array.isArray(data.rows) ? data.rows.map(cellsOf) : [];
|
|
@@ -2494,7 +2494,7 @@ function needsComment(block, residual, schema, ctx) {
|
|
|
2494
2494
|
const native = NATIVE_KEYS.get(block.type);
|
|
2495
2495
|
if (!native) return false;
|
|
2496
2496
|
if (residual > 0) return true;
|
|
2497
|
-
return Object.keys(
|
|
2497
|
+
return Object.keys(_chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
|
|
2498
2498
|
}
|
|
2499
2499
|
|
|
2500
2500
|
// src/engine/markdown/document/comment-markdown.ts
|
|
@@ -2508,41 +2508,41 @@ function quoinComment(type, data, indent2) {
|
|
|
2508
2508
|
// src/engine/markdown/document/link-forms.ts
|
|
2509
2509
|
var oneLine = (value) => value.replace(/[\r\n]+/g, " ");
|
|
2510
2510
|
function linked(label, href, ctx) {
|
|
2511
|
-
return ctx.inline.serialize([
|
|
2511
|
+
return ctx.inline.serialize([_chunk4SLJNZSMcjs.text.call(void 0, label || href, [{ type: "link", attrs: { href } }])]);
|
|
2512
2512
|
}
|
|
2513
2513
|
var assetUrl = (storageKey, ctx) => storageKey === "" ? "" : ctx.resolveAssetUrl(storageKey);
|
|
2514
2514
|
function imageMarkdown(data, ctx) {
|
|
2515
|
-
const href =
|
|
2515
|
+
const href = _chunk4SLJNZSMcjs.str.call(void 0, data.url) || assetUrl(_chunk4SLJNZSMcjs.str.call(void 0, data.storageKey), ctx);
|
|
2516
2516
|
if (href === "") return null;
|
|
2517
|
-
const caption =
|
|
2518
|
-
const alt = ctx.inline.serialize([
|
|
2519
|
-
return `![${alt}${
|
|
2517
|
+
const caption = _chunk4SLJNZSMcjs.str.call(void 0, data.caption);
|
|
2518
|
+
const alt = ctx.inline.serialize([_chunk4SLJNZSMcjs.text.call(void 0, oneLine(_chunk4SLJNZSMcjs.str.call(void 0, data.alt)))]);
|
|
2519
|
+
return `![${alt}${_chunk4SLJNZSMcjs.linkClose.call(void 0, { type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
|
|
2520
2520
|
}
|
|
2521
2521
|
function fileMarkdown(data, ctx) {
|
|
2522
|
-
const href = assetUrl(
|
|
2523
|
-
return href === "" ? null : linked(oneLine(
|
|
2522
|
+
const href = assetUrl(_chunk4SLJNZSMcjs.str.call(void 0, data.storageKey), ctx);
|
|
2523
|
+
return href === "" ? null : linked(oneLine(_chunk4SLJNZSMcjs.str.call(void 0, data.filename)), href, ctx);
|
|
2524
2524
|
}
|
|
2525
2525
|
function embedMarkdown(data, ctx) {
|
|
2526
|
-
const url =
|
|
2526
|
+
const url = _chunk4SLJNZSMcjs.str.call(void 0, data.url);
|
|
2527
2527
|
return url === "" ? null : linked(url, url, ctx);
|
|
2528
2528
|
}
|
|
2529
2529
|
function bookmarkMarkdown(data, ctx) {
|
|
2530
|
-
const url =
|
|
2531
|
-
return url === "" ? null : linked(oneLine(
|
|
2530
|
+
const url = _chunk4SLJNZSMcjs.str.call(void 0, data.url);
|
|
2531
|
+
return url === "" ? null : linked(oneLine(_chunk4SLJNZSMcjs.str.call(void 0, data.title)), url, ctx);
|
|
2532
2532
|
}
|
|
2533
2533
|
|
|
2534
2534
|
// src/engine/markdown/document/block-markdown.ts
|
|
2535
2535
|
var QUOTE_PREFIX = "> ";
|
|
2536
2536
|
function markdownLine(block, data) {
|
|
2537
2537
|
const kind = _nullishCoalesce(block.attrs.kind, () => ( "paragraph"));
|
|
2538
|
-
const markdown =
|
|
2539
|
-
const empty =
|
|
2538
|
+
const markdown = _chunk4SLJNZSMcjs.str.call(void 0, data.markdown);
|
|
2539
|
+
const empty = _chunk4SLJNZSMcjs.inlineLength.call(void 0, _nullishCoalesce(block.regions.text, () => ( []))) === 0;
|
|
2540
2540
|
if (empty && (kind === "paragraph" || kind === "quote")) return null;
|
|
2541
2541
|
return kind === "quote" ? quoteLines(markdown.slice(QUOTE_PREFIX.length)) : markdown;
|
|
2542
2542
|
}
|
|
2543
2543
|
function toggleMarkdown(data) {
|
|
2544
2544
|
return `<details${data.open === true ? " open" : ""}>
|
|
2545
|
-
<summary>${
|
|
2545
|
+
<summary>${_chunk4SLJNZSMcjs.str.call(void 0, data.markdown)}</summary>`;
|
|
2546
2546
|
}
|
|
2547
2547
|
function coreMarkdown(block, data, env, residual) {
|
|
2548
2548
|
switch (block.type) {
|
|
@@ -2575,9 +2575,9 @@ function coreMarkdown(block, data, env, residual) {
|
|
|
2575
2575
|
}
|
|
2576
2576
|
}
|
|
2577
2577
|
function blockMarkdown(block, env, { residual, asComment }) {
|
|
2578
|
-
const spec =
|
|
2578
|
+
const spec = _chunk4SLJNZSMcjs.specFor.call(void 0, env.schema, block.type);
|
|
2579
2579
|
const data = spec.toData(block, env.ctx);
|
|
2580
|
-
const comment = () =>
|
|
2580
|
+
const comment = () => _chunk4SLJNZSMcjs.isQuoinType.call(void 0, block.type) ? quoinComment(block.type, data, residual) : null;
|
|
2581
2581
|
if (asComment || env.lossless && !hasNativeForm(block.type)) return comment();
|
|
2582
2582
|
const written = spec.toMarkdown ? spec.toMarkdown(block, env.ctx) : coreMarkdown(block, data, env, residual);
|
|
2583
2583
|
if (written !== null) return written;
|
|
@@ -2607,7 +2607,7 @@ function createListContext() {
|
|
|
2607
2607
|
let placed = block;
|
|
2608
2608
|
let number = 1;
|
|
2609
2609
|
if (line2 === "ordered") {
|
|
2610
|
-
number = Math.min(_nullishCoalesce(runs.get(block.indent), () => (
|
|
2610
|
+
number = Math.min(_nullishCoalesce(runs.get(block.indent), () => ( _chunk4SLJNZSMcjs.orderedStart.call(void 0, block.attrs.start))), _chunk4SLJNZSMcjs.MAX_MARKER_NUMBER);
|
|
2611
2611
|
runs.set(block.indent, number + 1);
|
|
2612
2612
|
if (number !== block.attrs.start) placed = { ...block, attrs: { ...block.attrs, start: number } };
|
|
2613
2613
|
} else {
|
|
@@ -2617,7 +2617,7 @@ function createListContext() {
|
|
|
2617
2617
|
const hang = isItem2 ? (line2 === "ordered" ? String(number).length : 0) + 2 : 0;
|
|
2618
2618
|
const container = comment ? void 0 : openedBy(block, prefix, hang);
|
|
2619
2619
|
if (container) stack.push(container);
|
|
2620
|
-
const bare = !comment && (line2 === "bullet" || line2 === "ordered") &&
|
|
2620
|
+
const bare = !comment && (line2 === "bullet" || line2 === "ordered") && _chunk4SLJNZSMcjs.inlineLength.call(void 0, _nullishCoalesce(block.regions.text, () => ( []))) === 0;
|
|
2621
2621
|
const fragile = isItem2 && (bare || line2 === "ordered" && number !== 1);
|
|
2622
2622
|
const shown = comment ? void 0 : line2;
|
|
2623
2623
|
return { block: placed, line: shown, prefix, hang, residual, parent, container, closed, bare, fragile, comment };
|
|
@@ -2635,7 +2635,7 @@ function stripComments(block) {
|
|
|
2635
2635
|
regions: Object.fromEntries(
|
|
2636
2636
|
regions.map(([name, inline]) => [
|
|
2637
2637
|
name,
|
|
2638
|
-
hasCommentMark(inline) ?
|
|
2638
|
+
hasCommentMark(inline) ? _chunk4SLJNZSMcjs.removeMarkRange.call(void 0, inline, 0, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline), "comment") : inline
|
|
2639
2639
|
])
|
|
2640
2640
|
)
|
|
2641
2641
|
};
|
|
@@ -2664,7 +2664,7 @@ function pieceOf(text2, placement) {
|
|
|
2664
2664
|
opened: placement.container,
|
|
2665
2665
|
bare: placement.bare,
|
|
2666
2666
|
fragile: placement.fragile,
|
|
2667
|
-
leadsHtml: hang > 0 &&
|
|
2667
|
+
leadsHtml: hang > 0 && _chunk4SLJNZSMcjs.startsHtmlBlock.call(void 0, text2.split("\n")[0].slice(hang))
|
|
2668
2668
|
};
|
|
2669
2669
|
}
|
|
2670
2670
|
function takenAsItemText(previous, { parent, line: line2 }) {
|
|
@@ -2689,8 +2689,8 @@ function join(pieces) {
|
|
|
2689
2689
|
`;
|
|
2690
2690
|
}
|
|
2691
2691
|
function toMarkdown(blocks, options = {}) {
|
|
2692
|
-
const schema = _nullishCoalesce(options.schema, () => (
|
|
2693
|
-
const codec =
|
|
2692
|
+
const schema = _nullishCoalesce(options.schema, () => ( _chunk4SLJNZSMcjs.createSchema.call(void 0, )));
|
|
2693
|
+
const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema);
|
|
2694
2694
|
const env = {
|
|
2695
2695
|
schema,
|
|
2696
2696
|
lossless: options.lossless === true,
|
|
@@ -2732,20 +2732,20 @@ function escapeAttr(value) {
|
|
|
2732
2732
|
|
|
2733
2733
|
// src/engine/render/serialize-html.ts
|
|
2734
2734
|
var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input"]);
|
|
2735
|
-
var attrsHtml = (node) =>
|
|
2735
|
+
var attrsHtml = (node) => _chunk4SLJNZSMcjs.writtenAttrs.call(void 0, node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
|
|
2736
2736
|
var serializeHtml = (nodes) => nodes.map(
|
|
2737
2737
|
(node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${_nullishCoalesce(node.html, () => ( serializeHtml(node.children)))}</${node.tag}>`}`
|
|
2738
2738
|
).join("");
|
|
2739
2739
|
|
|
2740
2740
|
// src/engine/render/to-html.ts
|
|
2741
|
-
var toHTML = (blocks, options = {}) => serializeHtml(
|
|
2741
|
+
var toHTML = (blocks, options = {}) => serializeHtml(_chunk4SLJNZSMcjs.documentNodes.call(void 0, blocks, options));
|
|
2742
2742
|
|
|
2743
2743
|
// src/engine/render/to-plain-text.ts
|
|
2744
2744
|
function plainTextBlocks(blocks, schema) {
|
|
2745
|
-
return
|
|
2745
|
+
return _chunk4SLJNZSMcjs.engineBlocksOf.call(void 0, blocks, schema).map((block) => _chunk4SLJNZSMcjs.blockPlainText.call(void 0, block, schema));
|
|
2746
2746
|
}
|
|
2747
2747
|
function toPlainText(blocks, options = {}) {
|
|
2748
|
-
return plainTextBlocks(blocks, _nullishCoalesce(options.schema, () => (
|
|
2748
|
+
return plainTextBlocks(blocks, _nullishCoalesce(options.schema, () => ( _chunk4SLJNZSMcjs.createSchema.call(void 0, )))).join("\n");
|
|
2749
2749
|
}
|
|
2750
2750
|
|
|
2751
2751
|
// src/engine/model/graphemes.ts
|
|
@@ -2797,7 +2797,7 @@ function countBlock(block, schema) {
|
|
|
2797
2797
|
if (!blocks) counted.set(schema, blocks = /* @__PURE__ */ new WeakMap());
|
|
2798
2798
|
const known = blocks.get(block);
|
|
2799
2799
|
if (known) return known;
|
|
2800
|
-
const text2 =
|
|
2800
|
+
const text2 = _chunk4SLJNZSMcjs.blockPlainText.call(void 0, block, schema);
|
|
2801
2801
|
const stats = { characters: graphemeCount(text2), words: wordCount(text2) };
|
|
2802
2802
|
blocks.set(block, stats);
|
|
2803
2803
|
return stats;
|
|
@@ -2816,17 +2816,17 @@ function sum(blocks, schema) {
|
|
|
2816
2816
|
return { characters, words: words2 };
|
|
2817
2817
|
}
|
|
2818
2818
|
function countText(blocks, options = {}) {
|
|
2819
|
-
const schema = _nullishCoalesce(options.schema, () => ( (defaultSchema ??=
|
|
2820
|
-
return sum(
|
|
2819
|
+
const schema = _nullishCoalesce(options.schema, () => ( (defaultSchema ??= _chunk4SLJNZSMcjs.createSchema.call(void 0, ))));
|
|
2820
|
+
return sum(_chunk4SLJNZSMcjs.engineBlocksOf.call(void 0, blocks, schema), schema);
|
|
2821
2821
|
}
|
|
2822
2822
|
function countDoc(doc, options = {}) {
|
|
2823
|
-
return sum(doc.blocks, _nullishCoalesce(options.schema, () => ( (defaultSchema ??=
|
|
2823
|
+
return sum(doc.blocks, _nullishCoalesce(options.schema, () => ( (defaultSchema ??= _chunk4SLJNZSMcjs.createSchema.call(void 0, )))));
|
|
2824
2824
|
}
|
|
2825
2825
|
|
|
2826
2826
|
// src/engine/commands/block-style.ts
|
|
2827
2827
|
function patchBlocks(state, patch, only) {
|
|
2828
2828
|
const changing = selectedBlockIds(state.doc, state.selection).filter((id) => {
|
|
2829
|
-
const block =
|
|
2829
|
+
const block = _chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, id);
|
|
2830
2830
|
return block !== void 0 && (only === void 0 || block.type === only) && patchChangesAttrs(block.attrs, patch);
|
|
2831
2831
|
});
|
|
2832
2832
|
if (changing.length === 0) return null;
|
|
@@ -2854,7 +2854,7 @@ function setBlockColor(colors) {
|
|
|
2854
2854
|
const value = colors[key];
|
|
2855
2855
|
if (value !== void 0) patch[key] = _nullishCoalesce(value, () => ( void 0));
|
|
2856
2856
|
}
|
|
2857
|
-
const valid = Object.values(patch).every((value) => value === void 0 ||
|
|
2857
|
+
const valid = Object.values(patch).every((value) => value === void 0 || _chunk4SLJNZSMcjs.isPaletteColor.call(void 0, value));
|
|
2858
2858
|
return valid ? patchCommand(patch, "MARKDOWN") : () => false;
|
|
2859
2859
|
}
|
|
2860
2860
|
|
|
@@ -2874,7 +2874,7 @@ function textCaret(state) {
|
|
|
2874
2874
|
const { doc, schema, selection } = state;
|
|
2875
2875
|
if (_optionalChain([selection, 'optionalAccess', _89 => _89.kind]) !== "text" || !isCollapsed(selection)) return null;
|
|
2876
2876
|
const pos = selection.head;
|
|
2877
|
-
const index =
|
|
2877
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, pos.block);
|
|
2878
2878
|
const block = doc.blocks[index];
|
|
2879
2879
|
const inFlow2 = isTextFlow(schema, block) && pos.region === primaryRegion(schema, block);
|
|
2880
2880
|
return inFlow2 ? { block, index, pos } : null;
|
|
@@ -2882,14 +2882,14 @@ function textCaret(state) {
|
|
|
2882
2882
|
function joinInto(tr, schema, target, source) {
|
|
2883
2883
|
const targetRegion = _nullishCoalesce(primaryRegion(schema, target), () => ( ""));
|
|
2884
2884
|
tr.step(joinBlocksStep(target.id, targetRegion, source.id, _nullishCoalesce(primaryRegion(schema, source), () => ( ""))));
|
|
2885
|
-
capIndents(tr,
|
|
2885
|
+
capIndents(tr, _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, target.id) + 1);
|
|
2886
2886
|
const offset = regionLength(target, targetRegion);
|
|
2887
2887
|
tr.setSelection(textSelection({ block: target.id, region: targetRegion, offset }));
|
|
2888
2888
|
}
|
|
2889
2889
|
function joinIntoSummary(tr, schema, summary, source) {
|
|
2890
2890
|
const region = _nullishCoalesce(primaryRegion(schema, summary), () => ( ""));
|
|
2891
2891
|
const offset = regionLength(summary, region);
|
|
2892
|
-
const index =
|
|
2892
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, source.id);
|
|
2893
2893
|
const content = source.regions[_nullishCoalesce(primaryRegion(schema, source), () => ( ""))];
|
|
2894
2894
|
if (content.length > 0) tr.step(replaceInlineStep(summary.id, region, offset, offset, content));
|
|
2895
2895
|
tr.step(removeBlocksStep(index, 1));
|
|
@@ -2961,7 +2961,7 @@ function deleteReaching(forward, reach) {
|
|
|
2961
2961
|
const { selection } = state;
|
|
2962
2962
|
if (_optionalChain([selection, 'optionalAccess', _94 => _94.kind]) !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
|
|
2963
2963
|
const { head } = selection;
|
|
2964
|
-
const value =
|
|
2964
|
+
const value = _chunk4SLJNZSMcjs.inlineText.call(void 0, state.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, state.doc, head.block)].regions[head.region]);
|
|
2965
2965
|
if (forward ? head.offset >= value.length : head.offset <= 0) {
|
|
2966
2966
|
return (forward ? deleteAtEnd : deleteAtStart)(state, dispatch);
|
|
2967
2967
|
}
|
|
@@ -3015,8 +3015,8 @@ function movedBlockIds(doc, ids) {
|
|
|
3015
3015
|
function gather(tr, runs, above) {
|
|
3016
3016
|
let anchor = above;
|
|
3017
3017
|
for (const run of runs) {
|
|
3018
|
-
const from =
|
|
3019
|
-
const at = anchor === null ? -1 :
|
|
3018
|
+
const from = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, run[0]);
|
|
3019
|
+
const at = anchor === null ? -1 : _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, anchor);
|
|
3020
3020
|
const to = at < from ? at + 1 : at + 1 - run.length;
|
|
3021
3021
|
if (to !== from) tr.step(moveBlocksStep(from, run.length, to));
|
|
3022
3022
|
anchor = run[run.length - 1];
|
|
@@ -3044,7 +3044,7 @@ function moveBlocksTo(ids, toIndex, indent2) {
|
|
|
3044
3044
|
const first = runs[0][0];
|
|
3045
3045
|
const last = runs[runs.length - 1];
|
|
3046
3046
|
const clamped = Math.min(Math.max(indent2, 0), above ? above.indent + 1 : 0);
|
|
3047
|
-
reindent(tr,
|
|
3047
|
+
reindent(tr, _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, first), moved2.size, clamped);
|
|
3048
3048
|
if (!tr.docChanged) return false;
|
|
3049
3049
|
_optionalChain([dispatch, 'optionalCall', _100 => _100(tr.setSelection(blockRangeSelection(first, last[last.length - 1])))]);
|
|
3050
3050
|
return true;
|
|
@@ -3058,7 +3058,7 @@ var selectAll = (state, dispatch) => {
|
|
|
3058
3058
|
let next = blockRangeSelection(doc.blocks[0].id, doc.blocks[doc.blocks.length - 1].id);
|
|
3059
3059
|
if (_optionalChain([selection, 'optionalAccess', _101 => _101.kind]) === "text") {
|
|
3060
3060
|
const { anchor, head } = selection;
|
|
3061
|
-
const length =
|
|
3061
|
+
const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, _nullishCoalesce(doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, head.block)].regions[head.region], () => ( [])));
|
|
3062
3062
|
const withinRegion = anchor.block === head.block && anchor.region === head.region;
|
|
3063
3063
|
const covers = Math.min(anchor.offset, head.offset) === 0 && Math.max(anchor.offset, head.offset) === length;
|
|
3064
3064
|
if (withinRegion && !covers) next = textSelection({ ...head, offset: 0 }, { ...head, offset: length });
|
|
@@ -3095,7 +3095,7 @@ function splitStep(schema, block, region, offset, id) {
|
|
|
3095
3095
|
// src/engine/commands/split-at.ts
|
|
3096
3096
|
function enterInHardBreakBlock({ tr, schema, block, index, pos, makeId }) {
|
|
3097
3097
|
const length = regionLength(block, pos.region);
|
|
3098
|
-
if (pos.offset === length &&
|
|
3098
|
+
if (pos.offset === length && _chunk4SLJNZSMcjs.inlineText.call(void 0, block.regions[pos.region]).endsWith("\n")) {
|
|
3099
3099
|
tr.step(replaceInlineStep(block.id, pos.region, length - 1, length, []));
|
|
3100
3100
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, makeId());
|
|
3101
3101
|
tr.step(insertBlocksStep(descendantsEnd(tr.doc, index), [paragraph]));
|
|
@@ -3118,7 +3118,7 @@ function insertEmptyBefore({ tr, schema, block, index, pos, makeId }) {
|
|
|
3118
3118
|
function splitToggle({ tr, schema, block, index, pos, makeId }) {
|
|
3119
3119
|
const length = regionLength(block, pos.region);
|
|
3120
3120
|
const open = block.attrs.open === true;
|
|
3121
|
-
const tail =
|
|
3121
|
+
const tail = _chunk4SLJNZSMcjs.sliceInline.call(void 0, block.regions[pos.region], pos.offset, length);
|
|
3122
3122
|
const empty = createBlock(schema, schema.defaultTextBlock, {}, open ? block.indent + 1 : block.indent, makeId());
|
|
3123
3123
|
if (pos.offset < length) tr.step(replaceInlineStep(block.id, pos.region, pos.offset, length, []));
|
|
3124
3124
|
tr.step(insertBlocksStep(open ? index + 1 : descendantsEnd(tr.doc, index), [withContent(schema, empty, tail)]));
|
|
@@ -3130,7 +3130,7 @@ function splitInTwo({ tr, schema, block, pos, makeId }) {
|
|
|
3130
3130
|
tr.setSelection(textSelection({ block: tail.id, region: tail.region, offset: 0 }));
|
|
3131
3131
|
}
|
|
3132
3132
|
function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
3133
|
-
const index =
|
|
3133
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, pos.block);
|
|
3134
3134
|
const block = tr.doc.blocks[index];
|
|
3135
3135
|
if (!isTextFlow(schema, block) || pos.region !== primaryRegion(schema, block)) return false;
|
|
3136
3136
|
const target = { tr, schema, block, index, pos, makeId };
|
|
@@ -3145,13 +3145,13 @@ function splitAt(tr, schema, pos, collapsed, makeId) {
|
|
|
3145
3145
|
|
|
3146
3146
|
// src/engine/commands/split-block.ts
|
|
3147
3147
|
function splitBlock(options = {}) {
|
|
3148
|
-
const makeId = _nullishCoalesce(options.newId, () => (
|
|
3148
|
+
const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
|
|
3149
3149
|
return (state, dispatch) => {
|
|
3150
3150
|
const { doc, schema, selection } = state;
|
|
3151
3151
|
if (selection === null || selection.kind === "blocks") return false;
|
|
3152
3152
|
const tr = new Transaction(state).setMeta(LINE_SPLIT, true);
|
|
3153
3153
|
if (selection.kind === "node") {
|
|
3154
|
-
const index =
|
|
3154
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, selection.block);
|
|
3155
3155
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, doc.blocks[index].indent, makeId());
|
|
3156
3156
|
tr.step(insertBlocksStep(descendantsEnd(doc, index), [paragraph]));
|
|
3157
3157
|
tr.setSelection(startOf(tr.doc, schema, paragraph.id));
|
|
@@ -3261,7 +3261,7 @@ function replaceEmpty(tr, schema, index, blocks) {
|
|
|
3261
3261
|
tr.setSelection(endOf(tr.doc, schema, blocks[blocks.length - 1].id));
|
|
3262
3262
|
}
|
|
3263
3263
|
function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
3264
|
-
const index =
|
|
3264
|
+
const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, caret.block);
|
|
3265
3265
|
const current = tr.doc.blocks[index];
|
|
3266
3266
|
const { region } = caret;
|
|
3267
3267
|
const first = pieces[0];
|
|
@@ -3270,7 +3270,7 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3270
3270
|
if (pieces.length === 1 && ends.openStart && ends.openEnd && textual(first)) {
|
|
3271
3271
|
const content = contentOf(schema, first);
|
|
3272
3272
|
insertAt(tr, caret, content);
|
|
3273
|
-
tr.setSelection(textSelection({ ...caret, offset: caret.offset +
|
|
3273
|
+
tr.setSelection(textSelection({ ...caret, offset: caret.offset + _chunk4SLJNZSMcjs.inlineLength.call(void 0, content) }));
|
|
3274
3274
|
return;
|
|
3275
3275
|
}
|
|
3276
3276
|
const fresh = freshBlocks(pieces, current.indent, makeId);
|
|
@@ -3292,18 +3292,18 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
|
|
|
3292
3292
|
if (atStart && !atEnd) {
|
|
3293
3293
|
if (middle.length > 0) insertCapped(tr, index, middle);
|
|
3294
3294
|
insertAt(tr, { ...caret, offset: 0 }, lastContent);
|
|
3295
|
-
tr.setSelection(textSelection({ ...caret, offset:
|
|
3295
|
+
tr.setSelection(textSelection({ ...caret, offset: _chunk4SLJNZSMcjs.inlineLength.call(void 0, lastContent) }));
|
|
3296
3296
|
return;
|
|
3297
3297
|
}
|
|
3298
3298
|
const firstContent = mergeFirst ? contentOf(schema, fresh[0]) : [];
|
|
3299
3299
|
insertAt(tr, caret, firstContent);
|
|
3300
|
-
const offset = caret.offset +
|
|
3300
|
+
const offset = caret.offset + _chunk4SLJNZSMcjs.inlineLength.call(void 0, firstContent);
|
|
3301
3301
|
const tail = !atEnd && (mergeLast || middle.length > 0) ? splitStep(schema, current, region, offset, makeId()) : null;
|
|
3302
3302
|
if (tail !== null) tr.step(tail.step);
|
|
3303
3303
|
if (middle.length > 0) insertCapped(tr, index + 1, middle);
|
|
3304
3304
|
if (tail !== null && mergeLast) {
|
|
3305
3305
|
insertAt(tr, { block: tail.tail.id, region: tail.tail.region, offset: 0 }, lastContent);
|
|
3306
|
-
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset:
|
|
3306
|
+
tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: _chunk4SLJNZSMcjs.inlineLength.call(void 0, lastContent) }));
|
|
3307
3307
|
} else if (middle.length > 0) {
|
|
3308
3308
|
tr.setSelection(endOf(tr.doc, schema, middle[middle.length - 1].id));
|
|
3309
3309
|
} else {
|
|
@@ -3329,10 +3329,10 @@ function appendAtEnd(tr, schema, pieces, makeId) {
|
|
|
3329
3329
|
tr.setSelection(endOf(tr.doc, schema, fresh[fresh.length - 1].id));
|
|
3330
3330
|
}
|
|
3331
3331
|
function insertSlice(slice, options = {}) {
|
|
3332
|
-
const makeId = _nullishCoalesce(options.newId, () => (
|
|
3332
|
+
const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
|
|
3333
3333
|
return (state, dispatch) => {
|
|
3334
3334
|
const { doc, schema, selection } = state;
|
|
3335
|
-
const codec =
|
|
3335
|
+
const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema, { newId: makeId });
|
|
3336
3336
|
const pieces = slice.blocks.flatMap((block) => codec.toEngineBlocks(block));
|
|
3337
3337
|
if (pieces.length === 0) return false;
|
|
3338
3338
|
const tr = new Transaction(state).setOrigin("paste");
|
|
@@ -3381,9 +3381,9 @@ function fenceTransaction(state) {
|
|
|
3381
3381
|
const { selection, doc } = state;
|
|
3382
3382
|
if (_optionalChain([selection, 'optionalAccess', _118 => _118.kind]) !== "text" || !isCollapsed(selection)) return null;
|
|
3383
3383
|
const { block: id, region, offset } = selection.head;
|
|
3384
|
-
const block =
|
|
3384
|
+
const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, id);
|
|
3385
3385
|
if (block === void 0 || !isParagraph(block) || offset !== regionLength(block, region)) return null;
|
|
3386
|
-
const fence = FENCE.exec(
|
|
3386
|
+
const fence = FENCE.exec(_chunk4SLJNZSMcjs.inlineText.call(void 0, block.regions[region]));
|
|
3387
3387
|
if (fence === null) return null;
|
|
3388
3388
|
return convertPrefix(state, { block: id, region, from: 0, to: offset }, setBlockType("CODE", { language: fence[1] }));
|
|
3389
3389
|
}
|
|
@@ -3450,9 +3450,9 @@ function coreExtensions(options = {}) {
|
|
|
3450
3450
|
return [
|
|
3451
3451
|
defineExtension({
|
|
3452
3452
|
name: "core",
|
|
3453
|
-
blocks:
|
|
3454
|
-
marks:
|
|
3455
|
-
atoms:
|
|
3453
|
+
blocks: _chunk4SLJNZSMcjs.coreBlockSpecs,
|
|
3454
|
+
marks: _chunk4SLJNZSMcjs.coreMarkSpecs,
|
|
3455
|
+
atoms: _chunk4SLJNZSMcjs.coreAtomSpecs,
|
|
3456
3456
|
commands: coreCommands,
|
|
3457
3457
|
pasteRules: [linkOverSelection]
|
|
3458
3458
|
}),
|
|
@@ -3469,12 +3469,12 @@ function coreExtensions(options = {}) {
|
|
|
3469
3469
|
|
|
3470
3470
|
// src/engine/clipboard/serialize-slice.ts
|
|
3471
3471
|
function sliceText(slice, options) {
|
|
3472
|
-
const schema = _nullishCoalesce(options.schema, () => (
|
|
3472
|
+
const schema = _nullishCoalesce(options.schema, () => ( _chunk4SLJNZSMcjs.createSchema.call(void 0, )));
|
|
3473
3473
|
if (slice.blocks.length === 1 && slice.openStart && slice.openEnd) {
|
|
3474
|
-
const pieces =
|
|
3474
|
+
const pieces = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema).toEngineBlocks(slice.blocks[0]);
|
|
3475
3475
|
const block = pieces.length === 1 ? stripComments(pieces[0]) : null;
|
|
3476
3476
|
const region = block === null || !isTextFlow(schema, block) ? null : primaryRegion(schema, block);
|
|
3477
|
-
if (block !== null && region !== null) return
|
|
3477
|
+
if (block !== null && region !== null) return _chunk4SLJNZSMcjs.inlinePlainText.call(void 0, _nullishCoalesce(block.regions[region], () => ( [])), schema);
|
|
3478
3478
|
}
|
|
3479
3479
|
const markdown = toMarkdown(slice.blocks, { schema, resolveAssetUrl: options.resolveAssetUrl, comments: false });
|
|
3480
3480
|
return markdown.replace(/\n$/, "");
|
|
@@ -3492,17 +3492,17 @@ function isFlowRegion(schema, block, region) {
|
|
|
3492
3492
|
return isTextFlow(schema, block) && region === primaryRegion(schema, block);
|
|
3493
3493
|
}
|
|
3494
3494
|
function trimmed(block, region, from, to) {
|
|
3495
|
-
return { ...block, regions: { ...block.regions, [region]:
|
|
3495
|
+
return { ...block, regions: { ...block.regions, [region]: _chunk4SLJNZSMcjs.sliceInline.call(void 0, block.regions[region], from, to) } };
|
|
3496
3496
|
}
|
|
3497
3497
|
function insideOneRegion(schema, block, region, from, to) {
|
|
3498
3498
|
if (isFlowRegion(schema, block, region)) return trimmed(block, region, from, to);
|
|
3499
3499
|
const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, block.id);
|
|
3500
|
-
return withContent(schema, paragraph,
|
|
3500
|
+
return withContent(schema, paragraph, _chunk4SLJNZSMcjs.sliceInline.call(void 0, block.regions[region], from, to));
|
|
3501
3501
|
}
|
|
3502
3502
|
function textBlocks({ doc, schema }, selection) {
|
|
3503
3503
|
const { from, to } = orderedRange(doc, selection.anchor, selection.head);
|
|
3504
|
-
const start =
|
|
3505
|
-
const end =
|
|
3504
|
+
const start = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
|
|
3505
|
+
const end = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
|
|
3506
3506
|
const first = doc.blocks[start];
|
|
3507
3507
|
if (start === end) {
|
|
3508
3508
|
if (from.region !== to.region) return [first];
|
|
@@ -3548,18 +3548,18 @@ var INLINE_SYNTAX = [/\*\*[^*\n]+\*\*/, /__[^_\n]+__/, /\[[^\]\n]+\]\([^)\s]+[^)
|
|
|
3548
3548
|
function looksLikeMarkdown(value) {
|
|
3549
3549
|
return value.split(/\r\n|\r|\n/).some((line2) => BLOCK_MARKERS.some((marker) => marker.test(line2))) || INLINE_SYNTAX.some((syntax) => syntax.test(value));
|
|
3550
3550
|
}
|
|
3551
|
-
function plainTextToBlocks(value, makeId =
|
|
3551
|
+
function plainTextToBlocks(value, makeId = _chunk4SLJNZSMcjs.newId) {
|
|
3552
3552
|
return value.split(/\r\n|\r|\n/).filter((line2) => line2.trim() !== "").map((line2) => ({
|
|
3553
3553
|
id: makeId(),
|
|
3554
3554
|
type: "MARKDOWN",
|
|
3555
|
-
data: { markdown:
|
|
3555
|
+
data: { markdown: _chunk4SLJNZSMcjs.serializeInline.call(void 0, [_chunk4SLJNZSMcjs.text.call(void 0, line2)], { escapeLineStart: true }) }
|
|
3556
3556
|
}));
|
|
3557
3557
|
}
|
|
3558
3558
|
|
|
3559
3559
|
// src/engine/clipboard/parse-slice-json.ts
|
|
3560
3560
|
function isBlock2(value) {
|
|
3561
|
-
if (!
|
|
3562
|
-
if (!
|
|
3561
|
+
if (!_chunk4SLJNZSMcjs.isRecord.call(void 0, value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
|
|
3562
|
+
if (!_chunk4SLJNZSMcjs.isRecord.call(void 0, value.data)) return false;
|
|
3563
3563
|
return value.indent === void 0 || Number.isInteger(value.indent) && value.indent >= 0;
|
|
3564
3564
|
}
|
|
3565
3565
|
function parseSliceJSON(json) {
|
|
@@ -3569,7 +3569,7 @@ function parseSliceJSON(json) {
|
|
|
3569
3569
|
} catch (e) {
|
|
3570
3570
|
return null;
|
|
3571
3571
|
}
|
|
3572
|
-
if (!
|
|
3572
|
+
if (!_chunk4SLJNZSMcjs.isRecord.call(void 0, parsed) || parsed.quoin !== 1 || !_chunk4SLJNZSMcjs.isRecord.call(void 0, parsed.slice)) return null;
|
|
3573
3573
|
const { blocks, openStart, openEnd } = parsed.slice;
|
|
3574
3574
|
if (!Array.isArray(blocks) || blocks.length === 0 || !blocks.every(isBlock2)) return null;
|
|
3575
3575
|
if (typeof openStart !== "boolean" || typeof openEnd !== "boolean") return null;
|
|
@@ -3577,7 +3577,7 @@ function parseSliceJSON(json) {
|
|
|
3577
3577
|
}
|
|
3578
3578
|
|
|
3579
3579
|
// src/engine/clipboard/slice-from-clipboard.ts
|
|
3580
|
-
var isParagraph2 = (block) => block.type === "MARKDOWN" &&
|
|
3580
|
+
var isParagraph2 = (block) => block.type === "MARKDOWN" && _chunk4SLJNZSMcjs.parseLine.call(void 0, String(_nullishCoalesce(block.data.markdown, () => ( "")))).kind === "paragraph";
|
|
3581
3581
|
function openSlice(blocks, plainText2 = false) {
|
|
3582
3582
|
if (blocks.length === 0) return null;
|
|
3583
3583
|
const slice = { blocks, openStart: isParagraph2(blocks[0]), openEnd: isParagraph2(blocks[blocks.length - 1]) };
|
|
@@ -3587,14 +3587,14 @@ function linkBlocks(text2, makeId) {
|
|
|
3587
3587
|
const link = pastedLink(text2);
|
|
3588
3588
|
if (link === null) return null;
|
|
3589
3589
|
const { url, href, rest } = link;
|
|
3590
|
-
const linked2 =
|
|
3591
|
-
const markdown =
|
|
3590
|
+
const linked2 = _chunk4SLJNZSMcjs.text.call(void 0, url, [{ type: "link", attrs: { href } }]);
|
|
3591
|
+
const markdown = _chunk4SLJNZSMcjs.serializeInline.call(void 0, rest === "" ? [linked2] : [linked2, _chunk4SLJNZSMcjs.text.call(void 0, rest)]);
|
|
3592
3592
|
return [{ id: makeId(), type: "MARKDOWN", data: { markdown } }];
|
|
3593
3593
|
}
|
|
3594
3594
|
function textBlocks2(text2, makeId) {
|
|
3595
3595
|
const link = linkBlocks(text2, makeId);
|
|
3596
3596
|
if (link !== null) return link;
|
|
3597
|
-
return looksLikeMarkdown(text2) ?
|
|
3597
|
+
return looksLikeMarkdown(text2) ? _chunk4SLJNZSMcjs.fromMarkdown.call(void 0, text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
|
|
3598
3598
|
}
|
|
3599
3599
|
function htmlSlice(html, options) {
|
|
3600
3600
|
if (html === void 0) return null;
|
|
@@ -3606,7 +3606,7 @@ function sliceFromClipboard(data, options = {}) {
|
|
|
3606
3606
|
if (fromJson !== null) return fromJson;
|
|
3607
3607
|
const fromHtml = htmlSlice(data.html, options);
|
|
3608
3608
|
if (fromHtml !== null) return fromHtml;
|
|
3609
|
-
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, _nullishCoalesce(options.newId, () => (
|
|
3609
|
+
return data.text === void 0 ? null : openSlice(textBlocks2(data.text, _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId))), true);
|
|
3610
3610
|
}
|
|
3611
3611
|
|
|
3612
3612
|
// src/engine/commands/is-active.ts
|
|
@@ -3615,7 +3615,7 @@ function hasAttrs(block, attrs) {
|
|
|
3615
3615
|
}
|
|
3616
3616
|
function isActive(state, name, attrs) {
|
|
3617
3617
|
if (state.schema.marks.has(name)) return selectionHasMark(state, name, attrs);
|
|
3618
|
-
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => _nullishCoalesce(
|
|
3618
|
+
const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => _nullishCoalesce(_chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, id), () => ( [])));
|
|
3619
3619
|
const isBlockType = state.schema.blocks.has(name);
|
|
3620
3620
|
const matches = (block) => isBlockType ? block.type === name : block.type === "MARKDOWN" && block.attrs.kind === name;
|
|
3621
3621
|
return blocks.length > 0 && blocks.every((block) => matches(block) && hasAttrs(block, attrs));
|
|
@@ -3624,19 +3624,19 @@ function isActive(state, name, attrs) {
|
|
|
3624
3624
|
// src/engine/model/same-doc.ts
|
|
3625
3625
|
function sameDoc(a, b) {
|
|
3626
3626
|
if (a === b) return true;
|
|
3627
|
-
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) =>
|
|
3627
|
+
return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => _chunk6V6GGBDKcjs.sameValue.call(void 0, block, b.blocks[i]));
|
|
3628
3628
|
}
|
|
3629
3629
|
|
|
3630
3630
|
// src/engine/extension/same-blocks.ts
|
|
3631
3631
|
function sameBlock(a, b) {
|
|
3632
|
-
return a === b || a.id === b.id && a.type === b.type && (_nullishCoalesce(a.indent, () => ( 0))) === (_nullishCoalesce(b.indent, () => ( 0))) &&
|
|
3632
|
+
return a === b || a.id === b.id && a.type === b.type && (_nullishCoalesce(a.indent, () => ( 0))) === (_nullishCoalesce(b.indent, () => ( 0))) && _chunk6V6GGBDKcjs.sameValue.call(void 0, a.data, b.data);
|
|
3633
3633
|
}
|
|
3634
3634
|
function sameBlocks(a, b) {
|
|
3635
|
-
return a === b ||
|
|
3635
|
+
return a === b || _chunk4SLJNZSMcjs.sameItems.call(void 0, a, b, sameBlock);
|
|
3636
3636
|
}
|
|
3637
3637
|
|
|
3638
3638
|
// src/engine/extension/structural-echo.ts
|
|
3639
|
-
var sameIds = (a, b) =>
|
|
3639
|
+
var sameIds = (a, b) => _chunk4SLJNZSMcjs.sameItems.call(void 0, a, b, (x, y) => x.id === y.id);
|
|
3640
3640
|
function copiedSequence(emissions, incoming) {
|
|
3641
3641
|
const verdicts = /* @__PURE__ */ new Map();
|
|
3642
3642
|
const sameAt = (block, index) => {
|
|
@@ -3817,7 +3817,7 @@ function resolveExtensions(extensions, isMac) {
|
|
|
3817
3817
|
);
|
|
3818
3818
|
return {
|
|
3819
3819
|
extensions: sorted,
|
|
3820
|
-
schema:
|
|
3820
|
+
schema: _chunk4SLJNZSMcjs.createSchema.call(void 0, {
|
|
3821
3821
|
blocks: sorted.flatMap((extension) => _nullishCoalesce(extension.blocks, () => ( []))),
|
|
3822
3822
|
marks: sorted.flatMap((extension) => _nullishCoalesce(extension.marks, () => ( []))),
|
|
3823
3823
|
atoms: sorted.flatMap((extension) => _nullishCoalesce(extension.atoms, () => ( [])))
|
|
@@ -3841,7 +3841,7 @@ function createInternalEditor(options) {
|
|
|
3841
3841
|
const isMac = _nullishCoalesce(options.isMac, () => ( detectMac()));
|
|
3842
3842
|
const resolved = resolveExtensions(_nullishCoalesce(options.extensions, () => ( coreExtensions({ newId: newId2 }))), isMac);
|
|
3843
3843
|
const { schema, plugins } = resolved;
|
|
3844
|
-
const codec =
|
|
3844
|
+
const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema, { newId: newId2 });
|
|
3845
3845
|
const listeners = /* @__PURE__ */ new Set();
|
|
3846
3846
|
const mounts = /* @__PURE__ */ new Set();
|
|
3847
3847
|
let state = createState({ doc: codec.docFromBlocks(options.blocks), schema, plugins, clock: options.now });
|
|
@@ -4060,4 +4060,4 @@ function createInternalEditor(options) {
|
|
|
4060
4060
|
|
|
4061
4061
|
|
|
4062
4062
|
exports.setAttrsStep = setAttrsStep; exports.setIndentStep = setIndentStep; exports.insertBlocksStep = insertBlocksStep; exports.removeBlocksStep = removeBlocksStep; exports.moveBlocksStep = moveBlocksStep; exports.replaceBlockStep = replaceBlockStep; exports.replaceInlineStep = replaceInlineStep; exports.addMarkStep = addMarkStep; exports.removeMarkStep = removeMarkStep; exports.commonPrefix = commonPrefix; exports.commonSuffix = commonSuffix; exports.replaceDocStep = replaceDocStep; exports.splitBlockStep = splitBlockStep; exports.joinBlocksStep = joinBlocksStep; exports.stepFromJSON = stepFromJSON; exports.comparePos = comparePos; exports.orderedRange = orderedRange; exports.textSelection = textSelection; exports.nodeSelection = nodeSelection; exports.blockRangeSelection = blockRangeSelection; exports.isCollapsed = isCollapsed; exports.sameSelection = sameSelection; exports.selectionRange = selectionRange; exports.selectedBlockIds = selectedBlockIds; exports.mapSelection = mapSelection; exports.primaryRegion = primaryRegion; exports.startOf = startOf; exports.endOf = endOf; exports.validateSelection = validateSelection; exports.isClosedToggle = isClosedToggle; exports.hidingToggle = hidingToggle; exports.createState = createState; exports.applyTransaction = applyTransaction; exports.getPluginState = getPluginState; exports.createPluginKey = createPluginKey; exports.Transaction = Transaction; exports.caretMarks = caretMarks; exports.runCommands = runCommands; exports.HISTORY_PROVIDER = HISTORY_PROVIDER; exports.HISTORY_GROUP = HISTORY_GROUP; exports.groupOf = groupOf; exports.undo = undo; exports.redo = redo; exports.undoInputRule = undoInputRule; exports.isTextFlow = isTextFlow; exports.isParagraph = isParagraph; exports.regionLength = regionLength; exports.descendantsEnd = descendantsEnd; exports.createBlock = createBlock; exports.withContent = withContent; exports.headBlockId = headBlockId; exports.selectedBlockRange = selectedBlockRange; exports.capIndents = capIndents; exports.toggleTask = toggleTask; exports.indent = indent; exports.outdent = outdent; exports.moveBlocksUp = moveBlocksUp; exports.moveBlocksDown = moveBlocksDown; exports.duplicateBlocks = duplicateBlocks; exports.deleteBlocks = deleteBlocks; exports.insertBlockAfter = insertBlockAfter; exports.deleteRange = deleteRange; exports.insertTextAt = insertTextAt; exports.insertText = insertText; exports.markExtent = markExtent; exports.markRanges = markRanges; exports.rangeContent = rangeContent; exports.markCoverage = markCoverage; exports.toggleMark = toggleMark; exports.setMark = setMark; exports.unsetMark = unsetMark; exports.setLink = setLink; exports.unsetLink = unsetLink; exports.insertMention = insertMention; exports.setBlockType = setBlockType; exports.insertTextWithRules = insertTextWithRules; exports.blockInputRules = blockInputRules; exports.regionInline = regionInline; exports.markInputRules = markInputRules; exports.typographyRules = typographyRules; exports.fromHTML = fromHTML; exports.toMarkdown = toMarkdown; exports.toHTML = toHTML; exports.toPlainText = toPlainText; exports.graphemeCount = graphemeCount; exports.wordCount = wordCount; exports.nextGraphemeOffset = nextGraphemeOffset; exports.prevGraphemeOffset = prevGraphemeOffset; exports.countBlock = countBlock; exports.countText = countText; exports.countDoc = countDoc; exports.setAttrs = setAttrs; exports.setTextAlign = setTextAlign; exports.setBlockColor = setBlockColor; exports.LINE_JOIN = LINE_JOIN; exports.deleteSelection = deleteSelection; exports.deleteBackward = deleteBackward; exports.deleteForward = deleteForward; exports.deleteWordBackward = deleteWordBackward; exports.deleteWordForward = deleteWordForward; exports.deleteToLineStart = deleteToLineStart; exports.deleteToLineEnd = deleteToLineEnd; exports.insertHardBreak = insertHardBreak; exports.movedBlockIds = movedBlockIds; exports.moveBlocksTo = moveBlocksTo; exports.selectAll = selectAll; exports.setSelection = setSelection; exports.LINE_SPLIT = LINE_SPLIT; exports.freshBlocks = freshBlocks; exports.pasteAtCaret = pasteAtCaret; exports.insertSlice = insertSlice; exports.pastedLink = pastedLink; exports.defineExtension = defineExtension; exports.coreExtensions = coreExtensions; exports.sliceFromSelection = sliceFromSelection; exports.sliceFromClipboard = sliceFromClipboard; exports.isActive = isActive; exports.sameDoc = sameDoc; exports.detectMac = detectMac; exports.normalizeKey = normalizeKey; exports.keyName = keyName; exports.createEditor = createEditor;
|
|
4063
|
-
//# sourceMappingURL=chunk-
|
|
4063
|
+
//# sourceMappingURL=chunk-ZKVOS57Q.cjs.map
|