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
package/dist/yjs.cjs
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _chunkTLGX43P6cjs = require('./chunk-TLGX43P6.cjs');
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -45,10 +45,10 @@ var _chunkMLRAVUFGcjs = require('./chunk-MLRAVUFG.cjs');
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunk6V6GGBDKcjs = require('./chunk-6V6GGBDK.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
@@ -57,10 +57,10 @@ var _chunkXX5FTPJRcjs = require('./chunk-XX5FTPJR.cjs');
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
var
|
|
60
|
+
var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
|
|
61
61
|
|
|
62
62
|
// src/yjs/read-shared.ts
|
|
63
|
-
var _yjs = require('yjs'); var Y = _interopRequireWildcard(_yjs); var Y2 = _interopRequireWildcard(_yjs); var Y3 = _interopRequireWildcard(_yjs);
|
|
63
|
+
var _yjs = require('yjs'); var Y = _interopRequireWildcard(_yjs); var Y2 = _interopRequireWildcard(_yjs); var Y3 = _interopRequireWildcard(_yjs); var Y4 = _interopRequireWildcard(_yjs);
|
|
64
64
|
|
|
65
65
|
// src/yjs/required-regions.ts
|
|
66
66
|
var noRequiredRegions = () => [];
|
|
@@ -79,7 +79,7 @@ function requiredRegions(schema) {
|
|
|
79
79
|
|
|
80
80
|
// src/yjs/read-shared.ts
|
|
81
81
|
function reader(required) {
|
|
82
|
-
const spans = [
|
|
82
|
+
const spans = [_chunkTLGX43P6cjs.emptySpan.call(void 0, )];
|
|
83
83
|
const entries = /* @__PURE__ */ new Map();
|
|
84
84
|
const markers = /* @__PURE__ */ new Map();
|
|
85
85
|
const order = [];
|
|
@@ -89,7 +89,6 @@ function reader(required) {
|
|
|
89
89
|
let entry = null;
|
|
90
90
|
let open = null;
|
|
91
91
|
let stray = null;
|
|
92
|
-
let clean = true;
|
|
93
92
|
const segFor = (region2, host, at, ops = []) => {
|
|
94
93
|
const seg = { host, region: region2, at, length: 0 };
|
|
95
94
|
host.segs.push(seg);
|
|
@@ -106,7 +105,6 @@ function reader(required) {
|
|
|
106
105
|
open.length += length;
|
|
107
106
|
held2.get(open).push(op);
|
|
108
107
|
} else if (span.index === 0 || span.entry !== null) {
|
|
109
|
-
clean = false;
|
|
110
108
|
if (stray === null) {
|
|
111
109
|
stray = { host: span, at: span.length, length: 0, ops: [], after: _nullishCoalesce(order[order.length - 1], () => ( null)) };
|
|
112
110
|
strays.push(stray);
|
|
@@ -116,35 +114,29 @@ function reader(required) {
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
function marker(map) {
|
|
119
|
-
span =
|
|
117
|
+
span = _chunkTLGX43P6cjs.emptySpan.call(void 0, );
|
|
120
118
|
span.index = spans.length;
|
|
121
119
|
spans.push(span);
|
|
122
120
|
[open, stray] = [null, null];
|
|
123
|
-
const fields =
|
|
121
|
+
const fields = _chunkTLGX43P6cjs.readMarker.call(void 0, map);
|
|
124
122
|
const kept = fields !== null && !entries.has(fields.id);
|
|
125
123
|
entry = kept ? { id: fields.id, map, span, regions: [], copies: [] } : null;
|
|
126
124
|
if (entry !== null) {
|
|
127
125
|
span.entry = entry;
|
|
128
126
|
entries.set(entry.id, entry);
|
|
129
127
|
markers.set(entry, fields);
|
|
130
|
-
} else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
span.copyOf = entries.get(fields.id);
|
|
134
|
-
span.copyOf.copies.push(span);
|
|
135
|
-
}
|
|
128
|
+
} else if (fields !== null) {
|
|
129
|
+
span.copyOf = entries.get(fields.id);
|
|
130
|
+
span.copyOf.copies.push(span);
|
|
136
131
|
}
|
|
137
132
|
}
|
|
138
133
|
function embed(value) {
|
|
139
|
-
let name =
|
|
134
|
+
let name = _chunkTLGX43P6cjs.regionNameOf.call(void 0, value);
|
|
140
135
|
stray = null;
|
|
141
136
|
const missing = (one) => !entry.regions.some((region2) => region2.name === one);
|
|
142
137
|
if (name !== null && entry !== null) {
|
|
143
138
|
const needed = required(markers.get(entry).type);
|
|
144
|
-
if (needed.length > 0 && !needed.includes(name))
|
|
145
|
-
clean = false;
|
|
146
|
-
name = _nullishCoalesce(needed.find(missing), () => ( null));
|
|
147
|
-
}
|
|
139
|
+
if (needed.length > 0 && !needed.includes(name)) name = _nullishCoalesce(needed.find(missing), () => ( null));
|
|
148
140
|
if (name !== null && missing(name)) {
|
|
149
141
|
const region2 = { name, entry, segs: [] };
|
|
150
142
|
entry.regions.push(region2);
|
|
@@ -153,13 +145,12 @@ function reader(required) {
|
|
|
153
145
|
return;
|
|
154
146
|
}
|
|
155
147
|
}
|
|
156
|
-
clean = false;
|
|
157
148
|
if (open !== null) open = opened(open.region);
|
|
158
149
|
}
|
|
159
150
|
return {
|
|
160
151
|
read(op) {
|
|
161
152
|
const { insert } = op;
|
|
162
|
-
if (typeof insert === "string" ||
|
|
153
|
+
if (typeof insert === "string" || _chunkTLGX43P6cjs.isAtomEmbed.call(void 0, insert)) {
|
|
163
154
|
const length = typeof insert === "string" ? insert.length : 1;
|
|
164
155
|
content(op, length);
|
|
165
156
|
span.length += length;
|
|
@@ -189,20 +180,36 @@ function reader(required) {
|
|
|
189
180
|
for (const name of required(type)) {
|
|
190
181
|
if (!kept.regions.some((region2) => region2.name === name)) kept.regions.push({ name, entry: kept, segs: [] });
|
|
191
182
|
}
|
|
192
|
-
const inline = (segs) =>
|
|
183
|
+
const inline = (segs) => _chunkTLGX43P6cjs.inlineOfOps.call(void 0, segs.flatMap((seg) => held2.get(seg)));
|
|
193
184
|
const regions = kept.regions.map(({ name, segs }) => [name, inline(segs)]);
|
|
194
185
|
return { id: kept.id, type, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess', _7 => _7.toJSON, 'call', _8 => _8()]), () => ( {})), regions: Object.fromEntries(regions) };
|
|
195
186
|
});
|
|
196
|
-
const layout =
|
|
197
|
-
return { doc:
|
|
187
|
+
const layout = _chunkTLGX43P6cjs.createLayout.call(void 0, spans, entries, { read, leading: new Set(leading), unread });
|
|
188
|
+
return { doc: _chunk4SLJNZSMcjs.createDoc.call(void 0, blocks), layout };
|
|
198
189
|
}
|
|
199
190
|
};
|
|
200
191
|
}
|
|
201
192
|
function readShared(text2, required = noRequiredRegions) {
|
|
202
193
|
const read = reader(required);
|
|
203
|
-
|
|
194
|
+
readItems(text2, () => read, read);
|
|
204
195
|
return read.finish();
|
|
205
196
|
}
|
|
197
|
+
function readItems(text2, readerOf, read) {
|
|
198
|
+
const attributes = /* @__PURE__ */ new Map();
|
|
199
|
+
for (let item = text2._start; item !== null; item = item.right) {
|
|
200
|
+
const { content } = item;
|
|
201
|
+
if (item.deleted) continue;
|
|
202
|
+
if (content instanceof Y.ContentFormat) {
|
|
203
|
+
if (content.value === null) attributes.delete(content.key);
|
|
204
|
+
else attributes.set(content.key, content.value);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
for (const insert of content instanceof Y.ContentString ? [content.str] : content.getContent()) {
|
|
208
|
+
if (insert instanceof Y.Map) read = readerOf(insert);
|
|
209
|
+
_optionalChain([read, 'optionalAccess', _9 => _9.read, 'call', _10 => _10({ insert, attributes: Object.fromEntries(attributes) })]);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
206
213
|
|
|
207
214
|
// src/yjs/shared.ts
|
|
208
215
|
function reread(shared) {
|
|
@@ -212,41 +219,41 @@ function reread(shared) {
|
|
|
212
219
|
function insertContent(shared, region2, offset, inline) {
|
|
213
220
|
if (inline.length === 0) return;
|
|
214
221
|
if (region2.segs.length === 0) return openRegion(shared, region2, inline);
|
|
215
|
-
const { seg, rel } =
|
|
216
|
-
|
|
217
|
-
|
|
222
|
+
const { seg, rel } = _chunkTLGX43P6cjs.pointOf.call(void 0, region2, offset);
|
|
223
|
+
_chunkTLGX43P6cjs.insertInline.call(void 0, shared.text, _chunkTLGX43P6cjs.spanStart.call(void 0, shared.layout, seg.host) + rel, inline);
|
|
224
|
+
_chunkTLGX43P6cjs.grow.call(void 0, shared.layout, seg, rel, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline));
|
|
218
225
|
}
|
|
219
226
|
function deleteContent(shared, region2, from, to) {
|
|
220
|
-
for (const { seg, rel, length } of
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
for (const { seg, rel, length } of _chunkTLGX43P6cjs.piecesOf.call(void 0, region2, from, to).reverse()) {
|
|
228
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, shared.text, _chunkTLGX43P6cjs.spanStart.call(void 0, shared.layout, seg.host) + rel, length);
|
|
229
|
+
_chunkTLGX43P6cjs.grow.call(void 0, shared.layout, seg, rel, -length);
|
|
223
230
|
}
|
|
224
231
|
}
|
|
225
232
|
function formatContent(shared, region2, from, to, attributes) {
|
|
226
|
-
for (const { seg, rel, length } of
|
|
227
|
-
shared.text.format(
|
|
233
|
+
for (const { seg, rel, length } of _chunkTLGX43P6cjs.piecesOf.call(void 0, region2, from, to)) {
|
|
234
|
+
shared.text.format(_chunkTLGX43P6cjs.spanStart.call(void 0, shared.layout, seg.host) + rel, length, attributes);
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
function openRegion(shared, { name, entry }, inline) {
|
|
231
|
-
const at =
|
|
232
|
-
shared.text.insertEmbed(at,
|
|
233
|
-
|
|
238
|
+
const at = _chunkTLGX43P6cjs.spanStart.call(void 0, shared.layout, entry.span) + entry.span.length;
|
|
239
|
+
shared.text.insertEmbed(at, _chunkTLGX43P6cjs.regionStart.call(void 0, name), {});
|
|
240
|
+
_chunkTLGX43P6cjs.insertInline.call(void 0, shared.text, at + 1, inline);
|
|
234
241
|
reread(shared);
|
|
235
242
|
}
|
|
236
243
|
|
|
237
244
|
// src/yjs/inline-span.ts
|
|
238
245
|
var units = (inline) => inline.flatMap(
|
|
239
|
-
(node) => node.kind === "text" ? Array.from({ length: node.text.length }, (_, i) =>
|
|
246
|
+
(node) => node.kind === "text" ? Array.from({ length: node.text.length }, (_, i) => _chunk4SLJNZSMcjs.text.call(void 0, node.text[i], node.marks)) : [node]
|
|
240
247
|
);
|
|
241
248
|
function changedSpan(before, after) {
|
|
242
249
|
const a = units(before);
|
|
243
250
|
const b = units(after);
|
|
244
251
|
let start = 0;
|
|
245
|
-
while (start < a.length && start < b.length &&
|
|
252
|
+
while (start < a.length && start < b.length && _chunk4SLJNZSMcjs.equalNode.call(void 0, a[start], b[start])) start += 1;
|
|
246
253
|
let end = 0;
|
|
247
254
|
const shared = Math.min(a.length, b.length) - start;
|
|
248
|
-
while (end < shared &&
|
|
249
|
-
return { from: start, to:
|
|
255
|
+
while (end < shared && _chunk4SLJNZSMcjs.equalNode.call(void 0, a[a.length - 1 - end], b[b.length - 1 - end])) end += 1;
|
|
256
|
+
return { from: start, to: _chunk4SLJNZSMcjs.inlineLength.call(void 0, before) - end, slice: _chunk4SLJNZSMcjs.sliceInline.call(void 0, after, start, _chunk4SLJNZSMcjs.inlineLength.call(void 0, after) - end) };
|
|
250
257
|
}
|
|
251
258
|
|
|
252
259
|
// src/yjs/plain.ts
|
|
@@ -259,17 +266,17 @@ function isPlain({ span, regions }) {
|
|
|
259
266
|
}
|
|
260
267
|
return span.length === end;
|
|
261
268
|
}
|
|
262
|
-
function
|
|
263
|
-
const next = _chunkMLRAVUFGcjs.cleanEntry.call(void 0, block, map);
|
|
269
|
+
function adopted(entry, next) {
|
|
264
270
|
next.copies.push(...entry.copies);
|
|
265
271
|
for (const copy of next.copies) copy.copyOf = next;
|
|
266
272
|
return next;
|
|
267
273
|
}
|
|
274
|
+
var rewritten = (entry, block, map = entry.map) => adopted(entry, _chunkTLGX43P6cjs.cleanEntry.call(void 0, block, map));
|
|
268
275
|
function crossesStray(layout, index) {
|
|
269
276
|
const { read, leading, unread } = layout.strays;
|
|
270
277
|
return unread || read.some((seg) => {
|
|
271
|
-
const region2 =
|
|
272
|
-
return leading.has(seg) ? index <= region2 : region2 < index && index <=
|
|
278
|
+
const region2 = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, seg.region.entry.span);
|
|
279
|
+
return leading.has(seg) ? index <= region2 : region2 < index && index <= _chunkTLGX43P6cjs.indexOf.call(void 0, layout, seg.host);
|
|
273
280
|
});
|
|
274
281
|
}
|
|
275
282
|
|
|
@@ -277,11 +284,11 @@ function crossesStray(layout, index) {
|
|
|
277
284
|
function insertBlocks(shared, next, blocks) {
|
|
278
285
|
const { layout, text: text2 } = shared;
|
|
279
286
|
const span = next === null ? null : layout.entries.get(next).span;
|
|
280
|
-
const index = span === null ? layout.spans.length :
|
|
287
|
+
const index = span === null ? layout.spans.length : _chunkTLGX43P6cjs.indexOf.call(void 0, layout, span);
|
|
281
288
|
const crosses = blocks.some((block) => Object.keys(block.regions).length > 0) && crossesStray(layout, index);
|
|
282
|
-
const maps =
|
|
289
|
+
const maps = _chunkTLGX43P6cjs.writeBlocks.call(void 0, text2, span === null ? _chunkTLGX43P6cjs.textLength.call(void 0, layout) : _chunkTLGX43P6cjs.spanStart.call(void 0, layout, span), blocks);
|
|
283
290
|
if (crosses) reread(shared);
|
|
284
|
-
else
|
|
291
|
+
else _chunkTLGX43P6cjs.placeEntries.call(void 0, layout, index, 0, blocks.map((block, i) => _chunkTLGX43P6cjs.cleanEntry.call(void 0, block, maps[i])));
|
|
285
292
|
}
|
|
286
293
|
function ownParts(entry, span) {
|
|
287
294
|
const parts = [];
|
|
@@ -296,15 +303,15 @@ function ownParts(entry, span) {
|
|
|
296
303
|
}
|
|
297
304
|
function dropSpans(shared, spans) {
|
|
298
305
|
const { layout, text: text2 } = shared;
|
|
299
|
-
for (const span of [...spans].sort((a, b) =>
|
|
300
|
-
const at =
|
|
301
|
-
|
|
302
|
-
|
|
306
|
+
for (const span of [...spans].sort((a, b) => _chunkTLGX43P6cjs.indexOf.call(void 0, layout, b) - _chunkTLGX43P6cjs.indexOf.call(void 0, layout, a))) {
|
|
307
|
+
const at = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, span);
|
|
308
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, text2, _chunkTLGX43P6cjs.spanStart.call(void 0, layout, span), span.length);
|
|
309
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, at, 1, []);
|
|
303
310
|
}
|
|
304
311
|
}
|
|
305
312
|
function unreadBefore(layout, span) {
|
|
306
313
|
const before = [];
|
|
307
|
-
for (let at =
|
|
314
|
+
for (let at = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, span) - 1; at > 0 && layout.spans[at].entry === null; at--) {
|
|
308
315
|
before.push(layout.spans[at]);
|
|
309
316
|
}
|
|
310
317
|
return before;
|
|
@@ -316,22 +323,22 @@ function removeBlock(shared, id) {
|
|
|
316
323
|
if (isPlain(entry)) return dropSpans(shared, [.../* @__PURE__ */ new Set([entry.span, ...unread])]);
|
|
317
324
|
dropSpans(shared, [...new Set(unread)]);
|
|
318
325
|
const ranges = [];
|
|
319
|
-
const start =
|
|
326
|
+
const start = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, entry.span);
|
|
320
327
|
ranges.push(...ownParts(entry, entry.span).map(([at, length]) => [start + at, length]));
|
|
321
328
|
for (const seg of entry.regions.flatMap((region2) => region2.segs)) {
|
|
322
|
-
if (seg.host !== entry.span) ranges.push([
|
|
329
|
+
if (seg.host !== entry.span) ranges.push([_chunkTLGX43P6cjs.spanStart.call(void 0, layout, seg.host) + seg.at, seg.length]);
|
|
323
330
|
}
|
|
324
|
-
for (const [at, length] of ranges.sort((a, b) => b[0] - a[0])) if (length > 0)
|
|
331
|
+
for (const [at, length] of ranges.sort((a, b) => b[0] - a[0])) if (length > 0) _chunkTLGX43P6cjs.deleteText.call(void 0, text2, at, length);
|
|
325
332
|
reread(shared);
|
|
326
333
|
}
|
|
327
334
|
|
|
328
335
|
// src/yjs/sync-block.ts
|
|
329
336
|
function syncAttrs(map, before, after) {
|
|
330
|
-
const current =
|
|
337
|
+
const current = _chunkTLGX43P6cjs.attrsMap.call(void 0, map, after);
|
|
331
338
|
if (current === null) return;
|
|
332
|
-
const kept = new Map(
|
|
339
|
+
const kept = new Map(_chunkTLGX43P6cjs.definedEntries.call(void 0, after));
|
|
333
340
|
for (const key of [...current.keys()]) if (!kept.has(key)) current.delete(key);
|
|
334
|
-
for (const [key, value] of kept) if (!
|
|
341
|
+
for (const [key, value] of kept) if (!_chunk6V6GGBDKcjs.sameValue.call(void 0, before[key], value)) current.set(key, value);
|
|
335
342
|
}
|
|
336
343
|
function keptNames(before, after) {
|
|
337
344
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -349,50 +356,49 @@ function syncRegions(shared, entry, before, after) {
|
|
|
349
356
|
const names = Object.keys(after.regions);
|
|
350
357
|
const queue = entry.regions.map(({ name }) => [name, before.regions[name]]);
|
|
351
358
|
const kept = keptNames(queue.map(([name]) => name), names);
|
|
352
|
-
let at =
|
|
359
|
+
let at = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, entry.span) + 1;
|
|
353
360
|
const dropGone = () => {
|
|
354
|
-
while (queue.length > 0 && !kept.has(queue[0][0]))
|
|
361
|
+
while (queue.length > 0 && !kept.has(queue[0][0])) _chunkTLGX43P6cjs.deleteText.call(void 0, text2, at, 1 + _chunk4SLJNZSMcjs.inlineLength.call(void 0, queue.shift()[1]));
|
|
355
362
|
};
|
|
356
363
|
for (const name of names) {
|
|
357
364
|
dropGone();
|
|
358
365
|
const inline = after.regions[name];
|
|
359
366
|
if (kept.has(name)) {
|
|
360
367
|
const { from, to, slice } = changedSpan(queue.shift()[1], inline);
|
|
361
|
-
if (to > from)
|
|
362
|
-
|
|
368
|
+
if (to > from) _chunkTLGX43P6cjs.deleteText.call(void 0, text2, at + 1 + from, to - from);
|
|
369
|
+
_chunkTLGX43P6cjs.insertInline.call(void 0, text2, at + 1 + from, slice);
|
|
363
370
|
} else {
|
|
364
|
-
text2.insertEmbed(at,
|
|
365
|
-
|
|
371
|
+
text2.insertEmbed(at, _chunkTLGX43P6cjs.regionStart.call(void 0, name), {});
|
|
372
|
+
_chunkTLGX43P6cjs.insertInline.call(void 0, text2, at + 1, inline);
|
|
366
373
|
}
|
|
367
|
-
at += 1 +
|
|
374
|
+
at += 1 + _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline);
|
|
368
375
|
}
|
|
369
376
|
dropGone();
|
|
370
|
-
|
|
377
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, _chunkTLGX43P6cjs.indexOf.call(void 0, layout, entry.span), 1, [rewritten(entry, after)]);
|
|
371
378
|
}
|
|
372
379
|
function syncBlock(shared, before, after, next) {
|
|
373
380
|
if (before === after) return;
|
|
374
381
|
const entry = shared.layout.entries.get(before.id);
|
|
375
382
|
const plain = isPlain(entry);
|
|
376
|
-
if (!plain && !
|
|
383
|
+
if (!plain && !_chunk6V6GGBDKcjs.sameValue.call(void 0, Object.keys(before.regions), Object.keys(after.regions))) {
|
|
377
384
|
removeBlock(shared, before.id);
|
|
378
385
|
insertBlocks(shared, next, [after]);
|
|
379
386
|
return;
|
|
380
387
|
}
|
|
381
|
-
if (before
|
|
382
|
-
if (before.indent !== after.indent) entry.map.set("indent", after.indent);
|
|
388
|
+
for (const key of ["type", "indent"]) if (before[key] !== after[key]) entry.map.set(key, after[key]);
|
|
383
389
|
syncAttrs(entry.map, before.attrs, after.attrs);
|
|
384
390
|
if (plain) {
|
|
385
391
|
const gains = Object.keys(before.regions).length === 0 && Object.keys(after.regions).length > 0;
|
|
386
|
-
const crosses = gains && crossesStray(shared.layout,
|
|
392
|
+
const crosses = gains && crossesStray(shared.layout, _chunkTLGX43P6cjs.indexOf.call(void 0, shared.layout, entry.span));
|
|
387
393
|
syncRegions(shared, entry, before, after);
|
|
388
394
|
if (crosses) reread(shared);
|
|
389
395
|
return;
|
|
390
396
|
}
|
|
391
397
|
for (const name of entry.regions.map((region2) => region2.name)) {
|
|
392
398
|
const [was, now] = [before.regions[name], after.regions[name]];
|
|
393
|
-
if (
|
|
399
|
+
if (_chunk4SLJNZSMcjs.equalInline.call(void 0, was, now)) continue;
|
|
394
400
|
const { from, to, slice } = changedSpan(was, now);
|
|
395
|
-
const region2 =
|
|
401
|
+
const region2 = _chunkTLGX43P6cjs.regionOf.call(void 0, shared.layout, before.id, name);
|
|
396
402
|
deleteContent(shared, region2, from, to);
|
|
397
403
|
insertContent(shared, region2, from, slice);
|
|
398
404
|
}
|
|
@@ -426,18 +432,18 @@ var held = (region2) => region2 !== void 0 && region2.segs.length > 0;
|
|
|
426
432
|
function writeSplit(shared, after, { block, region: region2, offset, created }) {
|
|
427
433
|
const { layout, text: text2 } = shared;
|
|
428
434
|
const entry = layout.entries.get(block);
|
|
429
|
-
const tail =
|
|
435
|
+
const tail = _chunk4SLJNZSMcjs.blockById.call(void 0, after, created.id);
|
|
430
436
|
const last = entry.regions[entry.regions.length - 1];
|
|
431
437
|
if (!held(last) || last.name !== region2 || Object.keys(tail.regions).at(-1) !== created.region) return false;
|
|
432
|
-
const { seg, rel } =
|
|
433
|
-
const map =
|
|
434
|
-
|
|
438
|
+
const { seg, rel } = _chunkTLGX43P6cjs.pointOf.call(void 0, last, offset);
|
|
439
|
+
const map = _chunkTLGX43P6cjs.markerOf.call(void 0, tail);
|
|
440
|
+
_chunkTLGX43P6cjs.writeBlock.call(void 0, text2, _chunkTLGX43P6cjs.spanStart.call(void 0, layout, seg.host) + rel, tail, map, created.region);
|
|
435
441
|
if (!isPlain(entry)) {
|
|
436
442
|
reread(shared);
|
|
437
443
|
return true;
|
|
438
444
|
}
|
|
439
|
-
const head = rewritten(entry,
|
|
440
|
-
|
|
445
|
+
const head = rewritten(entry, _chunk4SLJNZSMcjs.blockById.call(void 0, after, block));
|
|
446
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, _chunkTLGX43P6cjs.indexOf.call(void 0, layout, entry.span), 1, [head, _chunkTLGX43P6cjs.cleanEntry.call(void 0, tail, map)]);
|
|
441
447
|
return true;
|
|
442
448
|
}
|
|
443
449
|
function writeJoin(shared, after, join2) {
|
|
@@ -446,28 +452,28 @@ function writeJoin(shared, after, join2) {
|
|
|
446
452
|
const [into, from] = [target, source].map((id) => layout.entries.get(id));
|
|
447
453
|
const [end, start] = [into.regions.at(-1), from.regions[0]];
|
|
448
454
|
if (!held(end) || !held(start) || end.name !== targetRegion || start.name !== sourceRegion) return false;
|
|
449
|
-
const between = layout.spans.slice(
|
|
455
|
+
const between = layout.spans.slice(_chunkTLGX43P6cjs.indexOf.call(void 0, layout, into.span) + 1, _chunkTLGX43P6cjs.indexOf.call(void 0, layout, from.span));
|
|
450
456
|
dropSpans(shared, [...from.copies, ...between]);
|
|
451
|
-
const at =
|
|
457
|
+
const at = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, from.span);
|
|
452
458
|
if (!isPlain(into) || !isPlain(from)) {
|
|
453
459
|
const own = start.segs.find((seg) => seg.host === from.span);
|
|
454
|
-
|
|
455
|
-
|
|
460
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, text2, at + own.at - 1, 1);
|
|
461
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, text2, at, 1);
|
|
456
462
|
reread(shared);
|
|
457
463
|
return true;
|
|
458
464
|
}
|
|
459
|
-
const index =
|
|
465
|
+
const index = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, into.span);
|
|
460
466
|
const moved = from.regions[0].segs[0].length;
|
|
461
467
|
const rest = from.span.length - 2 - moved;
|
|
462
|
-
if (rest > 0)
|
|
463
|
-
|
|
464
|
-
|
|
468
|
+
if (rest > 0) _chunkTLGX43P6cjs.deleteText.call(void 0, text2, at + 2 + moved, rest);
|
|
469
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, text2, at, 2);
|
|
470
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, index, 2, [rewritten(into, _chunk4SLJNZSMcjs.blockById.call(void 0, after, target))]);
|
|
465
471
|
return true;
|
|
466
472
|
}
|
|
467
473
|
|
|
468
474
|
// src/yjs/local-to-yjs.ts
|
|
469
|
-
var region = ({ shared, params }) =>
|
|
470
|
-
var following = (doc, id) => _nullishCoalesce(_optionalChain([doc, 'access',
|
|
475
|
+
var region = ({ shared, params }) => _chunkTLGX43P6cjs.regionOf.call(void 0, shared.layout, params.block, params.region);
|
|
476
|
+
var following = (doc, id) => _nullishCoalesce(_optionalChain([doc, 'access', _11 => _11.blocks, 'access', _12 => _12[doc.index.get(id) + 1], 'optionalAccess', _13 => _13.id]), () => ( null));
|
|
471
477
|
function replaceInline(context) {
|
|
472
478
|
const { from, to, slice } = context.params;
|
|
473
479
|
const target = region(context);
|
|
@@ -477,19 +483,19 @@ function replaceInline(context) {
|
|
|
477
483
|
function format(context, keys) {
|
|
478
484
|
const { block, region: name, from, to } = context.params;
|
|
479
485
|
if (to === from) return;
|
|
480
|
-
const inline =
|
|
481
|
-
formatContent(context.shared, region(context), from, to, keys(
|
|
486
|
+
const inline = _chunk4SLJNZSMcjs.blockById.call(void 0, context.before, block).regions[name];
|
|
487
|
+
formatContent(context.shared, region(context), from, to, keys(_chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to)));
|
|
482
488
|
}
|
|
483
489
|
function removedKeys(mark, inline) {
|
|
484
|
-
if (typeof mark !== "string") return { [
|
|
490
|
+
if (typeof mark !== "string") return { [_chunkTLGX43P6cjs.markAttribute.call(void 0, mark)[0]]: null };
|
|
485
491
|
const marks = inline.flatMap((node) => node.marks.filter((candidate) => candidate.type === mark));
|
|
486
|
-
return Object.fromEntries(marks.map((found) => [
|
|
492
|
+
return Object.fromEntries(marks.map((found) => [_chunkTLGX43P6cjs.markAttribute.call(void 0, found)[0], null]));
|
|
487
493
|
}
|
|
488
494
|
function setAttrs({ shared, after, params }) {
|
|
489
495
|
const id = params.block;
|
|
490
496
|
const { map } = shared.layout.entries.get(id);
|
|
491
|
-
const next =
|
|
492
|
-
const attrs =
|
|
497
|
+
const next = _chunk4SLJNZSMcjs.blockById.call(void 0, after, id).attrs;
|
|
498
|
+
const attrs = _chunkTLGX43P6cjs.attrsMap.call(void 0, map, next);
|
|
493
499
|
if (attrs === null) return;
|
|
494
500
|
for (const key of Object.keys(params.patch)) {
|
|
495
501
|
if (next[key] === void 0) attrs.delete(key);
|
|
@@ -501,15 +507,15 @@ function moveBlocks({ shared, before, after, params }) {
|
|
|
501
507
|
if (count === 0 || from === to) return;
|
|
502
508
|
const moved = before.blocks.slice(from, from + count);
|
|
503
509
|
for (const block of moved) removeBlock(shared, block.id);
|
|
504
|
-
insertBlocks(shared, _nullishCoalesce(_optionalChain([after, 'access',
|
|
510
|
+
insertBlocks(shared, _nullishCoalesce(_optionalChain([after, 'access', _14 => _14.blocks, 'access', _15 => _15[to + count], 'optionalAccess', _16 => _16.id]), () => ( null)), moved);
|
|
505
511
|
}
|
|
506
512
|
var WRITERS = {
|
|
507
513
|
replaceInline,
|
|
508
|
-
addMark: (context) => format(context, () => Object.fromEntries([
|
|
514
|
+
addMark: (context) => format(context, () => Object.fromEntries([_chunkTLGX43P6cjs.markAttribute.call(void 0, context.params.mark)])),
|
|
509
515
|
removeMark: (context) => format(context, (inline) => removedKeys(context.params.mark, inline)),
|
|
510
516
|
setAttrs,
|
|
511
517
|
setIndent: ({ shared, params }) => shared.layout.entries.get(params.block).map.set("indent", params.indent),
|
|
512
|
-
insertBlocks: ({ shared, before, params }) => insertBlocks(shared, _nullishCoalesce(_optionalChain([before, 'access',
|
|
518
|
+
insertBlocks: ({ shared, before, params }) => insertBlocks(shared, _nullishCoalesce(_optionalChain([before, 'access', _17 => _17.blocks, 'access', _18 => _18[params.index], 'optionalAccess', _19 => _19.id]), () => ( null)), params.blocks),
|
|
513
519
|
removeBlocks: ({ shared, before, params }) => {
|
|
514
520
|
const { index, count } = params;
|
|
515
521
|
for (const block of before.blocks.slice(index, index + count)) removeBlock(shared, block.id);
|
|
@@ -527,7 +533,7 @@ var WRITERS = {
|
|
|
527
533
|
},
|
|
528
534
|
replaceBlock: ({ shared, before, params }) => {
|
|
529
535
|
const block = params.block;
|
|
530
|
-
syncBlock(shared,
|
|
536
|
+
syncBlock(shared, _chunk4SLJNZSMcjs.blockById.call(void 0, before, block.id), block, following(before, block.id));
|
|
531
537
|
}
|
|
532
538
|
};
|
|
533
539
|
function writeLocalSteps(shared, steps, docs) {
|
|
@@ -544,108 +550,157 @@ function seedOrLoad(editor, text2, { origin, seed, required }) {
|
|
|
544
550
|
const { blocks } = editor.state.doc;
|
|
545
551
|
if (text2.length === 0 && seed === "if-empty") {
|
|
546
552
|
let maps = [];
|
|
547
|
-
text2.doc.transact(() => maps =
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
return
|
|
553
|
+
text2.doc.transact(() => maps = _chunkTLGX43P6cjs.writeBlocks.call(void 0, text2, 0, blocks), origin);
|
|
554
|
+
const layout2 = _chunkTLGX43P6cjs.createLayout.call(void 0, [_chunkTLGX43P6cjs.emptySpan.call(void 0, )], /* @__PURE__ */ new Map());
|
|
555
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout2, 1, 0, blocks.map((block, i) => _chunkTLGX43P6cjs.cleanEntry.call(void 0, block, maps[i])));
|
|
556
|
+
return layout2;
|
|
551
557
|
}
|
|
552
558
|
const { doc, layout } = readShared(text2, required);
|
|
553
|
-
if (!
|
|
559
|
+
if (!_chunkZKVOS57Qcjs.sameDoc.call(void 0, doc, editor.state.doc)) _chunkTLGX43P6cjs.applyRemote.call(void 0, editor, [_chunkZKVOS57Qcjs.replaceDocStep.call(void 0, doc)]);
|
|
554
560
|
return layout;
|
|
555
561
|
}
|
|
556
562
|
|
|
563
|
+
// src/yjs/read-blocks.ts
|
|
564
|
+
|
|
565
|
+
function touchedEntries(layout, delta) {
|
|
566
|
+
const touched = /* @__PURE__ */ new Map();
|
|
567
|
+
let at = 0;
|
|
568
|
+
for (const op of delta) {
|
|
569
|
+
const length = _nullishCoalesce(_nullishCoalesce(op.retain, () => ( op.delete)), () => ( 0));
|
|
570
|
+
if (op.insert instanceof Y2.Map || op.retain && op.attributes) return null;
|
|
571
|
+
if (op.retain === void 0) {
|
|
572
|
+
const span = _chunkTLGX43P6cjs.spanAt.call(void 0, layout, at, op.insert === void 0);
|
|
573
|
+
const start = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, span);
|
|
574
|
+
if (span.entry === null || start === at || at + length > start + span.length) return null;
|
|
575
|
+
touched.set(span.entry.map, span.entry);
|
|
576
|
+
}
|
|
577
|
+
at += length;
|
|
578
|
+
}
|
|
579
|
+
return touched;
|
|
580
|
+
}
|
|
581
|
+
function readBlocks(shared, entries, doc) {
|
|
582
|
+
const { layout } = shared;
|
|
583
|
+
const readers = /* @__PURE__ */ new Map();
|
|
584
|
+
for (const [map, entry] of entries) {
|
|
585
|
+
if (!isPlain(entry)) return null;
|
|
586
|
+
readers.set(map, reader(shared.required));
|
|
587
|
+
}
|
|
588
|
+
readItems(shared.text, (marker) => readers.get(marker));
|
|
589
|
+
const steps = [];
|
|
590
|
+
for (const [map, entry] of entries) {
|
|
591
|
+
const { doc: one, layout: own } = readers.get(map).finish();
|
|
592
|
+
const next = own.spans[1].entry;
|
|
593
|
+
const at = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, entry.span);
|
|
594
|
+
if (crossesStray(own, 1) || crossesStray(layout, at)) return null;
|
|
595
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, at, 1, [adopted(entry, next)]);
|
|
596
|
+
if (!_chunk6V6GGBDKcjs.sameValue.call(void 0, _chunk4SLJNZSMcjs.blockById.call(void 0, doc, entry.id), one.blocks[0])) steps.push(_chunkZKVOS57Qcjs.replaceBlockStep.call(void 0, one.blocks[0]));
|
|
597
|
+
}
|
|
598
|
+
return steps;
|
|
599
|
+
}
|
|
600
|
+
|
|
557
601
|
// src/yjs/read-split-join.ts
|
|
558
602
|
|
|
559
603
|
var bare = (op) => op === void 0 || op.attributes === void 0;
|
|
560
604
|
function split(layout, delta, required) {
|
|
561
|
-
const [at, ops] = _optionalChain([delta, 'access',
|
|
562
|
-
const map = _optionalChain([ops, 'access',
|
|
563
|
-
const name =
|
|
564
|
-
if (ops.length !== 2 || !(map instanceof
|
|
565
|
-
const marker =
|
|
566
|
-
const span =
|
|
605
|
+
const [at, ops] = _optionalChain([delta, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.retain]) === void 0 ? [0, delta] : [delta[0].retain, delta.slice(1)];
|
|
606
|
+
const map = _optionalChain([ops, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.insert]);
|
|
607
|
+
const name = _chunkTLGX43P6cjs.regionNameOf.call(void 0, _optionalChain([ops, 'access', _24 => _24[1], 'optionalAccess', _25 => _25.insert]));
|
|
608
|
+
if (ops.length !== 2 || !(map instanceof Y3.Map) || name === null || !bare(delta[0])) return null;
|
|
609
|
+
const marker = _chunkTLGX43P6cjs.readMarker.call(void 0, map);
|
|
610
|
+
const span = _chunkTLGX43P6cjs.spanAt.call(void 0, layout, at);
|
|
567
611
|
if (span.entry === null || !isPlain(span.entry)) return null;
|
|
568
612
|
const region2 = span.entry.regions.at(-1);
|
|
569
|
-
const seg = _optionalChain([region2, 'optionalAccess',
|
|
570
|
-
const rel = at -
|
|
613
|
+
const seg = _optionalChain([region2, 'optionalAccess', _26 => _26.segs, 'access', _27 => _27[0]]);
|
|
614
|
+
const rel = at - _chunkTLGX43P6cjs.spanStart.call(void 0, layout, span);
|
|
571
615
|
if (marker === null || layout.entries.has(marker.id) || seg === void 0) return null;
|
|
572
616
|
if (rel < seg.at || rel > seg.at + seg.length) return null;
|
|
573
617
|
if (required(marker.type).some((needed) => needed !== name)) return null;
|
|
574
618
|
const { id, type, indent, attrs } = marker;
|
|
575
|
-
const created = { id, type, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess',
|
|
576
|
-
return { step:
|
|
619
|
+
const created = { id, type, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess', _28 => _28.toJSON, 'call', _29 => _29()]), () => ( {})), region: name, regions: {} };
|
|
620
|
+
return { step: _chunkZKVOS57Qcjs.splitBlockStep.call(void 0, span.entry.id, region2.name, _chunkTLGX43P6cjs.offsetIn.call(void 0, seg, rel), created), map };
|
|
577
621
|
}
|
|
578
622
|
function join(layout, delta) {
|
|
579
|
-
const [at, ops] = _optionalChain([delta, 'access',
|
|
623
|
+
const [at, ops] = _optionalChain([delta, 'access', _30 => _30[0], 'optionalAccess', _31 => _31.retain]) === void 0 ? [0, delta] : [delta[0].retain, delta.slice(1)];
|
|
580
624
|
if (ops.length !== 1 || ops[0].delete !== 2 || !bare(delta[0])) return null;
|
|
581
|
-
const span =
|
|
625
|
+
const span = _chunkTLGX43P6cjs.spanAt.call(void 0, layout, at, true);
|
|
582
626
|
const source = span.entry;
|
|
583
|
-
const target = _nullishCoalesce(_optionalChain([layout, 'access',
|
|
584
|
-
if (
|
|
627
|
+
const target = _nullishCoalesce(_optionalChain([layout, 'access', _32 => _32.spans, 'access', _33 => _33[span.index - 1], 'optionalAccess', _34 => _34.entry]), () => ( null));
|
|
628
|
+
if (_chunkTLGX43P6cjs.spanStart.call(void 0, layout, span) !== at || source === null || target === null) return null;
|
|
585
629
|
if (source.regions.length !== 1 || target.regions.length === 0 || source.copies.length > 0) return null;
|
|
586
630
|
if (!isPlain(source) || !isPlain(target)) return null;
|
|
587
|
-
return
|
|
631
|
+
return _chunkZKVOS57Qcjs.joinBlocksStep.call(void 0, target.id, target.regions.at(-1).name, source.id, source.regions[0].name);
|
|
588
632
|
}
|
|
589
633
|
function splitOrJoin(layout, delta, doc, required) {
|
|
590
634
|
const found = split(layout, delta, required);
|
|
591
|
-
const step = _nullishCoalesce(_optionalChain([found, 'optionalAccess',
|
|
635
|
+
const step = _nullishCoalesce(_optionalChain([found, 'optionalAccess', _35 => _35.step]), () => ( join(layout, delta)));
|
|
592
636
|
if (step === null) return null;
|
|
593
637
|
const after = step.apply(doc).doc;
|
|
594
638
|
const { block, target, created } = step.toJSON();
|
|
595
639
|
const kept = layout.entries.get(_nullishCoalesce(block, () => ( target)));
|
|
596
|
-
const entries = [rewritten(kept,
|
|
597
|
-
if (found !== null) entries.push(
|
|
598
|
-
|
|
640
|
+
const entries = [rewritten(kept, _chunk4SLJNZSMcjs.blockById.call(void 0, after, kept.id))];
|
|
641
|
+
if (found !== null) entries.push(_chunkTLGX43P6cjs.cleanEntry.call(void 0, _chunk4SLJNZSMcjs.blockById.call(void 0, after, created.id), found.map));
|
|
642
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, _chunkTLGX43P6cjs.indexOf.call(void 0, layout, kept.span), found === null ? 2 : 1, entries);
|
|
599
643
|
return step;
|
|
600
644
|
}
|
|
601
645
|
|
|
602
646
|
// src/yjs/yjs-to-steps.ts
|
|
603
647
|
var REREAD = new Error("reread");
|
|
604
|
-
function markerSteps(shared, event, doc) {
|
|
648
|
+
function markerSteps(shared, event, doc, read) {
|
|
605
649
|
const target = event.target;
|
|
606
650
|
const marker = target.parent === shared.text ? target : target.parent;
|
|
607
|
-
const fields = _chunkMLRAVUFGcjs.readMarker.call(void 0, marker);
|
|
608
|
-
const block = fields === null ? void 0 : _chunkBTBHHBVRcjs.blockById.call(void 0, doc, fields.id);
|
|
609
|
-
if (block === void 0 || _optionalChain([shared, 'access', _34 => _34.layout, 'access', _35 => _35.entries, 'access', _36 => _36.get, 'call', _37 => _37(block.id), 'optionalAccess', _38 => _38.map]) !== marker) return [];
|
|
610
651
|
const keys = [...event.keysChanged];
|
|
652
|
+
if (target === marker && keys.includes("id")) throw REREAD;
|
|
653
|
+
const fields = _chunkTLGX43P6cjs.readMarker.call(void 0, marker);
|
|
654
|
+
const block = fields === null ? void 0 : _chunk4SLJNZSMcjs.blockById.call(void 0, doc, fields.id);
|
|
655
|
+
const entry = block === void 0 ? void 0 : shared.layout.entries.get(block.id);
|
|
656
|
+
if (block === void 0 || _optionalChain([entry, 'optionalAccess', _36 => _36.map]) !== marker || read.has(marker)) return [];
|
|
611
657
|
if (target !== marker) {
|
|
612
658
|
if (fields.attrs !== target) return [];
|
|
613
|
-
return [
|
|
659
|
+
return [_chunkZKVOS57Qcjs.setAttrsStep.call(void 0, block.id, Object.fromEntries(keys.map((key) => [key, target.get(key)])))];
|
|
660
|
+
}
|
|
661
|
+
if (keys.includes("type")) {
|
|
662
|
+
read.set(marker, entry);
|
|
663
|
+
return [];
|
|
614
664
|
}
|
|
615
|
-
if (keys.includes("id") || keys.includes("type")) throw REREAD;
|
|
616
665
|
const { indent, attrs } = fields;
|
|
617
|
-
if (keys.every((key) => key === "indent")) return [
|
|
618
|
-
return [
|
|
666
|
+
if (keys.every((key) => key === "indent")) return [_chunkZKVOS57Qcjs.setIndentStep.call(void 0, block.id, indent)];
|
|
667
|
+
return [_chunkZKVOS57Qcjs.replaceBlockStep.call(void 0, { ...block, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess', _37 => _37.toJSON, 'call', _38 => _38()]), () => ( {})) })];
|
|
619
668
|
}
|
|
620
669
|
function contentSteps(shared, events, doc) {
|
|
621
670
|
const textEvent = events.find((event) => event.target === shared.text);
|
|
622
|
-
const delta = _nullishCoalesce(_optionalChain([textEvent, 'optionalAccess',
|
|
671
|
+
const delta = _nullishCoalesce(_optionalChain([textEvent, 'optionalAccess', _39 => _39.delta]), () => ( []));
|
|
672
|
+
const touched = touchedEntries(shared.layout, delta);
|
|
623
673
|
const structure = splitOrJoin(shared.layout, delta, doc, shared.required);
|
|
624
|
-
const steps = structure === null ?
|
|
625
|
-
if (steps === null) throw REREAD;
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
674
|
+
const steps = structure === null ? _chunkTLGX43P6cjs.textSteps.call(void 0, shared.layout, delta) : [structure];
|
|
675
|
+
if (steps === null && touched === null) throw REREAD;
|
|
676
|
+
const read = steps === null ? touched : /* @__PURE__ */ new Map();
|
|
677
|
+
const all = [];
|
|
678
|
+
let current = doc;
|
|
679
|
+
const take = (more) => {
|
|
680
|
+
if (more === null) throw REREAD;
|
|
681
|
+
for (const step of more) {
|
|
630
682
|
current = step.apply(current).doc;
|
|
631
|
-
|
|
683
|
+
all.push(step);
|
|
632
684
|
}
|
|
633
|
-
}
|
|
634
|
-
|
|
685
|
+
};
|
|
686
|
+
take(_nullishCoalesce(steps, () => ( [])));
|
|
687
|
+
for (const event of events) if (event !== textEvent) take(markerSteps(shared, event, current, read));
|
|
688
|
+
if (read.size > 0) take(readBlocks(shared, read, current));
|
|
689
|
+
return { steps: all, structural: read.size > 0 };
|
|
635
690
|
}
|
|
636
691
|
function readRemote(shared, events, doc) {
|
|
637
692
|
try {
|
|
638
|
-
return
|
|
693
|
+
return contentSteps(shared, events, doc);
|
|
639
694
|
} catch (error) {
|
|
640
695
|
const read = readShared(shared.text, shared.required);
|
|
641
696
|
shared.layout = read.layout;
|
|
642
697
|
const blocks = read.doc.blocks.map((block) => {
|
|
643
|
-
const held2 =
|
|
644
|
-
return held2 !== void 0 &&
|
|
698
|
+
const held2 = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, block.id);
|
|
699
|
+
return held2 !== void 0 && _chunk6V6GGBDKcjs.sameValue.call(void 0, held2, block) ? held2 : block;
|
|
645
700
|
});
|
|
646
|
-
const next =
|
|
701
|
+
const next = _chunk4SLJNZSMcjs.createDoc.call(void 0, blocks);
|
|
647
702
|
const failed = error === REREAD ? void 0 : error;
|
|
648
|
-
return { steps:
|
|
703
|
+
return { steps: _chunkZKVOS57Qcjs.sameDoc.call(void 0, next, doc) ? [] : [_chunkZKVOS57Qcjs.replaceDocStep.call(void 0, next)], structural: true, failed };
|
|
649
704
|
}
|
|
650
705
|
}
|
|
651
706
|
|
|
@@ -658,18 +713,18 @@ function bind(editor, text2, options) {
|
|
|
658
713
|
const history = options.history();
|
|
659
714
|
const shared = { text: text2, layout, stale: false, required };
|
|
660
715
|
const ours = (origin) => origin === origins.local || origin === origins.untracked;
|
|
661
|
-
|
|
716
|
+
const held2 = /* @__PURE__ */ new WeakMap();
|
|
662
717
|
const written = /* @__PURE__ */ new WeakSet();
|
|
663
718
|
const hold = (transaction) => {
|
|
664
|
-
if (!ours(transaction.origin)) held2
|
|
719
|
+
if (!ours(transaction.origin)) held2.set(transaction, _chunkTLGX43P6cjs.holdSelection.call(void 0, text2, shared.layout, editor.state.selection));
|
|
665
720
|
};
|
|
666
721
|
const observer = (events, transaction) => {
|
|
667
722
|
if (ours(transaction.origin)) return;
|
|
668
723
|
const { steps, structural, failed } = readRemote(shared, events, editor.state.doc);
|
|
669
724
|
if (steps.length > 0 && transaction.origin !== history.manager) {
|
|
670
|
-
|
|
725
|
+
_chunkTLGX43P6cjs.applyRemote.call(void 0, editor, steps, structural ? _chunkTLGX43P6cjs.restoreSelection.call(void 0, text2, shared.layout, held2.get(transaction)) : null);
|
|
671
726
|
} else if (steps.length > 0) {
|
|
672
|
-
const tr =
|
|
727
|
+
const tr = _chunkTLGX43P6cjs.sharedChange.call(void 0, editor, steps, history.hint(), "history");
|
|
673
728
|
written.add(tr);
|
|
674
729
|
editor.dispatch(tr);
|
|
675
730
|
}
|
|
@@ -677,9 +732,7 @@ function bind(editor, text2, options) {
|
|
|
677
732
|
};
|
|
678
733
|
const settle = () => {
|
|
679
734
|
shared.stale = false;
|
|
680
|
-
|
|
681
|
-
shared.layout = read.layout;
|
|
682
|
-
if (!_chunkHOIDJEVIcjs.sameDoc.call(void 0, read.doc, editor.state.doc)) _chunkMLRAVUFGcjs.applyRemote.call(void 0, editor, [_chunkHOIDJEVIcjs.replaceDocStep.call(void 0, read.doc)]);
|
|
735
|
+
shared.layout = seedOrLoad(editor, text2, { origin: origins.local, seed: false, required });
|
|
683
736
|
};
|
|
684
737
|
doc.on("beforeTransaction", hold);
|
|
685
738
|
text2.observeDeep(observer);
|
|
@@ -708,7 +761,7 @@ function bind(editor, text2, options) {
|
|
|
708
761
|
var GROUP_DELAY = 500;
|
|
709
762
|
var SELECTION = "selection";
|
|
710
763
|
function undoHistory(text2, origin) {
|
|
711
|
-
const manager = new
|
|
764
|
+
const manager = new Y4.UndoManager(text2, { trackedOrigins: /* @__PURE__ */ new Set([origin]), captureTimeout: Infinity });
|
|
712
765
|
let group = null;
|
|
713
766
|
let time = 0;
|
|
714
767
|
let before = null;
|
|
@@ -721,21 +774,20 @@ function undoHistory(text2, origin) {
|
|
|
721
774
|
if (tr.getMeta("closeHistory") === true) group = null;
|
|
722
775
|
return;
|
|
723
776
|
}
|
|
724
|
-
const next =
|
|
777
|
+
const next = _chunkZKVOS57Qcjs.groupOf.call(void 0, tr);
|
|
725
778
|
if (next === null || next !== group || tr.time - time >= GROUP_DELAY) manager.stopCapturing();
|
|
726
779
|
group = next;
|
|
727
780
|
time = tr.time;
|
|
728
781
|
before = tr.before.selection;
|
|
729
782
|
},
|
|
730
783
|
travel(direction, editor) {
|
|
731
|
-
const
|
|
732
|
-
const item = stack.at(-1);
|
|
784
|
+
const item = manager[`${direction}Stack`].at(-1);
|
|
733
785
|
if (item === void 0) return false;
|
|
734
786
|
hint = _nullishCoalesce(item.meta.get(SELECTION), () => ( null));
|
|
735
787
|
before = editor.state.selection;
|
|
736
788
|
group = null;
|
|
737
789
|
try {
|
|
738
|
-
return
|
|
790
|
+
return manager[direction]() !== null;
|
|
739
791
|
} finally {
|
|
740
792
|
hint = null;
|
|
741
793
|
}
|
|
@@ -777,44 +829,44 @@ function yjsCollaboration(options) {
|
|
|
777
829
|
const at = ++disconnects;
|
|
778
830
|
setTimeout(() => {
|
|
779
831
|
if (binding !== null || at !== disconnects) return;
|
|
780
|
-
_optionalChain([history, 'optionalAccess',
|
|
832
|
+
_optionalChain([history, 'optionalAccess', _40 => _40.manager, 'access', _41 => _41.destroy, 'call', _42 => _42()]);
|
|
781
833
|
history = void 0;
|
|
782
834
|
}, 16);
|
|
783
835
|
};
|
|
784
836
|
},
|
|
785
837
|
onLocalTransaction: (tr, state) => {
|
|
786
|
-
if (_optionalChain([binding, 'optionalAccess',
|
|
838
|
+
if (_optionalChain([binding, 'optionalAccess', _43 => _43.editor, 'access', _44 => _44.state]) === state) binding.local(tr);
|
|
787
839
|
},
|
|
788
840
|
history: {
|
|
789
|
-
undo: () => _nullishCoalesce(_optionalChain([binding, 'optionalAccess',
|
|
790
|
-
redo: () => _nullishCoalesce(_optionalChain([binding, 'optionalAccess',
|
|
841
|
+
undo: () => _nullishCoalesce(_optionalChain([binding, 'optionalAccess', _45 => _45.travel, 'call', _46 => _46("undo")]), () => ( false)),
|
|
842
|
+
redo: () => _nullishCoalesce(_optionalChain([binding, 'optionalAccess', _47 => _47.travel, 'call', _48 => _48("redo")]), () => ( false)),
|
|
791
843
|
canUndo: () => binding !== null && history.manager.canUndo(),
|
|
792
844
|
canRedo: () => binding !== null && history.manager.canRedo()
|
|
793
845
|
}
|
|
794
846
|
};
|
|
795
|
-
|
|
847
|
+
_chunkTLGX43P6cjs.holdBinding.call(void 0, collaboration, () => binding);
|
|
796
848
|
return collaboration;
|
|
797
849
|
}
|
|
798
850
|
|
|
799
851
|
// src/engine/collab/collaboration-link.ts
|
|
800
|
-
var linkKey =
|
|
852
|
+
var linkKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, "collaborationLink");
|
|
801
853
|
var linkPlugin = {
|
|
802
854
|
key: linkKey,
|
|
803
855
|
init: () => ({ mounts: 0, disconnect: null, warned: false }),
|
|
804
856
|
apply: (_tr, link) => link
|
|
805
857
|
};
|
|
806
|
-
var linkOf = (state) =>
|
|
858
|
+
var linkOf = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, linkKey);
|
|
807
859
|
|
|
808
860
|
// src/engine/collab/warn-host-blocks.ts
|
|
809
861
|
function warnHostBlocks() {
|
|
810
|
-
if (typeof process !== "undefined" && _optionalChain([process, 'optionalAccess',
|
|
862
|
+
if (typeof process !== "undefined" && _optionalChain([process, 'optionalAccess', _49 => _49.env, 'optionalAccess', _50 => _50.NODE_ENV]) === "production") return;
|
|
811
863
|
console.warn(
|
|
812
864
|
"Quoin: blocks were supplied to a collaborative editor and ignored, since the shared document holds its content. Supply its starting blocks once and keep the ones it emits."
|
|
813
865
|
);
|
|
814
866
|
}
|
|
815
867
|
|
|
816
868
|
// src/engine/collab/collaboration-extension.ts
|
|
817
|
-
var providerKey =
|
|
869
|
+
var providerKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, _chunkZKVOS57Qcjs.HISTORY_PROVIDER);
|
|
818
870
|
function providing(history) {
|
|
819
871
|
const provider = {
|
|
820
872
|
undo: (dryRun) => dryRun ? history.canUndo() : history.undo(),
|
|
@@ -824,7 +876,7 @@ function providing(history) {
|
|
|
824
876
|
}
|
|
825
877
|
function collaborationExtension(adapter) {
|
|
826
878
|
const { history } = adapter;
|
|
827
|
-
return
|
|
879
|
+
return _chunkZKVOS57Qcjs.defineExtension.call(void 0, {
|
|
828
880
|
name: "collaboration",
|
|
829
881
|
plugins: history === void 0 ? [linkPlugin] : [linkPlugin, providing(history)],
|
|
830
882
|
onMount(editor) {
|
|
@@ -840,7 +892,7 @@ function collaborationExtension(adapter) {
|
|
|
840
892
|
}
|
|
841
893
|
return () => {
|
|
842
894
|
link.mounts -= 1;
|
|
843
|
-
if (link.mounts === 0) _optionalChain([link, 'access',
|
|
895
|
+
if (link.mounts === 0) _optionalChain([link, 'access', _51 => _51.disconnect, 'optionalCall', _52 => _52()]);
|
|
844
896
|
};
|
|
845
897
|
},
|
|
846
898
|
onTransaction(tr, state) {
|
|
@@ -860,5 +912,5 @@ function collaborationExtension(adapter) {
|
|
|
860
912
|
|
|
861
913
|
|
|
862
914
|
|
|
863
|
-
exports.applyRemote =
|
|
915
|
+
exports.applyRemote = _chunkTLGX43P6cjs.applyRemote; exports.collaborationExtension = collaborationExtension; exports.yjsCollaboration = yjsCollaboration;
|
|
864
916
|
//# sourceMappingURL=yjs.cjs.map
|