quoin-editor 1.0.0 → 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 +58 -0
- package/dist/ai.cjs +135 -94
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +62 -21
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +25 -25
- package/dist/catalogue.d.cts +6 -6
- package/dist/catalogue.d.ts +6 -6
- package/dist/catalogue.js +17 -17
- package/dist/{chunk-ND5XJVK2.cjs → chunk-4SLJNZSM.cjs} +27 -23
- package/dist/chunk-4SLJNZSM.cjs.map +1 -0
- package/dist/{chunk-LCQSG4M6.js → chunk-4XFXB37X.js} +22 -18
- package/dist/chunk-4XFXB37X.js.map +1 -0
- package/dist/{chunk-AEJXZBVR.cjs → chunk-5MAYUGTE.cjs} +110 -103
- package/dist/chunk-5MAYUGTE.cjs.map +1 -0
- package/dist/{chunk-JDPTZUBW.js → chunk-623AOJM2.js} +4 -4
- package/dist/chunk-6NULZPVC.js +374 -0
- package/dist/chunk-6NULZPVC.js.map +1 -0
- package/dist/{chunk-2QCRZ7OL.cjs → chunk-6V6GGBDK.cjs} +12 -11
- package/dist/{chunk-2QCRZ7OL.cjs.map → chunk-6V6GGBDK.cjs.map} +1 -1
- package/dist/{chunk-WXMYDXPN.cjs → chunk-73653CJ4.cjs} +4 -3
- package/dist/chunk-73653CJ4.cjs.map +1 -0
- package/dist/{chunk-47MLKSI2.js → chunk-ADSJ42DO.js} +6 -6
- package/dist/{chunk-PWUEPDA3.cjs → chunk-AUOEM3SF.cjs} +44 -44
- package/dist/{chunk-PWUEPDA3.cjs.map → chunk-AUOEM3SF.cjs.map} +1 -1
- package/dist/{chunk-WQHV3MRE.cjs → chunk-BQANU5BH.cjs} +12 -12
- package/dist/{chunk-WQHV3MRE.cjs.map → chunk-BQANU5BH.cjs.map} +1 -1
- package/dist/{chunk-KXOBZGQO.js → chunk-C23RQVRK.js} +21 -14
- package/dist/chunk-C23RQVRK.js.map +1 -0
- package/dist/{chunk-2VDK27IF.cjs → chunk-CW3AFJBR.cjs} +312 -342
- package/dist/chunk-CW3AFJBR.cjs.map +1 -0
- package/dist/{chunk-MQ2XQ4MX.js → chunk-DUE3HCZD.js} +6 -6
- package/dist/chunk-DUE3HCZD.js.map +1 -0
- package/dist/{chunk-OMOBMXD5.cjs → chunk-EH5KXQXY.cjs} +7 -2
- package/dist/chunk-EH5KXQXY.cjs.map +1 -0
- package/dist/{chunk-ZS2WA357.js → chunk-EPARJI4V.js} +147 -129
- package/dist/chunk-EPARJI4V.js.map +1 -0
- package/dist/{chunk-HZSSEYJS.cjs → chunk-FDRUAL3Z.cjs} +30 -30
- package/dist/{chunk-HZSSEYJS.cjs.map → chunk-FDRUAL3Z.cjs.map} +1 -1
- package/dist/{chunk-T7SW6OWV.js → chunk-IQBMAE3F.js} +5 -5
- package/dist/{chunk-RUDWMKYX.js → chunk-JHQUHFLX.js} +8 -8
- package/dist/{chunk-HELJTLNC.cjs → chunk-KUYZMSMF.cjs} +12 -12
- package/dist/chunk-KUYZMSMF.cjs.map +1 -0
- package/dist/chunk-LE5XMIFJ.cjs +14 -0
- package/dist/chunk-LE5XMIFJ.cjs.map +1 -0
- package/dist/{chunk-EL2OEJQC.cjs → chunk-LLTEGXWZ.cjs} +56 -56
- package/dist/{chunk-EL2OEJQC.cjs.map → chunk-LLTEGXWZ.cjs.map} +1 -1
- package/dist/chunk-MQUCCSWG.js +14 -0
- package/dist/chunk-MQUCCSWG.js.map +1 -0
- package/dist/{chunk-NNDYYEW5.js → chunk-N4FGA3H4.js} +5 -5
- package/dist/{chunk-ZHOSSWUM.js → chunk-NEZJ7ZP5.js} +4 -3
- package/dist/chunk-NEZJ7ZP5.js.map +1 -0
- package/dist/{chunk-XEBWC7ZL.js → chunk-O4Z2WMFF.js} +7 -2
- package/dist/chunk-O4Z2WMFF.js.map +1 -0
- package/dist/{chunk-HJIQT3S5.js → chunk-OBMBSU2S.js} +100 -84
- package/dist/chunk-OBMBSU2S.js.map +1 -0
- package/dist/{chunk-KAVU6T6J.js → chunk-OSHZQR3W.js} +5 -5
- package/dist/{chunk-GTTPVJSD.cjs → chunk-P6KYXFZC.cjs} +265 -247
- package/dist/chunk-P6KYXFZC.cjs.map +1 -0
- package/dist/{chunk-CDELOHDY.cjs → chunk-R2BLBV43.cjs} +23 -23
- package/dist/{chunk-CDELOHDY.cjs.map → chunk-R2BLBV43.cjs.map} +1 -1
- package/dist/{chunk-NOKWNK2O.js → chunk-RJRX34BZ.js} +3 -2
- package/dist/{chunk-ZGZEJCRV.js → chunk-T43RZTUT.js} +166 -196
- package/dist/chunk-T43RZTUT.js.map +1 -0
- package/dist/chunk-TLGX43P6.cjs +374 -0
- package/dist/chunk-TLGX43P6.cjs.map +1 -0
- package/dist/{chunk-POBM7MGR.js → chunk-U3LOLYAU.js} +2 -2
- package/dist/{chunk-RDG4VI6E.cjs → chunk-UEKXVCKC.cjs} +103 -93
- package/dist/chunk-UEKXVCKC.cjs.map +1 -0
- package/dist/{chunk-PMWCQSQX.js → chunk-VCLL5C7J.js} +5 -5
- package/dist/{chunk-SG37UBDO.js → chunk-VRS6WCEK.js} +20 -10
- package/dist/chunk-VRS6WCEK.js.map +1 -0
- package/dist/{chunk-ZC24WB7Y.cjs → chunk-WEYDDIBQ.cjs} +14 -14
- package/dist/{chunk-ZC24WB7Y.cjs.map → chunk-WEYDDIBQ.cjs.map} +1 -1
- package/dist/{chunk-5DNCCN6X.cjs → chunk-X4HDKFW5.cjs} +27 -27
- package/dist/{chunk-5DNCCN6X.cjs.map → chunk-X4HDKFW5.cjs.map} +1 -1
- package/dist/{chunk-SLVDAHHK.cjs → chunk-X4P4TQXH.cjs} +5 -5
- package/dist/{chunk-SLVDAHHK.cjs.map → chunk-X4P4TQXH.cjs.map} +1 -1
- package/dist/{chunk-GLLXHMH2.cjs → chunk-XA3UEJIW.cjs} +3 -3
- package/dist/{chunk-GLLXHMH2.cjs.map → chunk-XA3UEJIW.cjs.map} +1 -1
- package/dist/{chunk-K574XHMM.js → chunk-YBMUEEM5.js} +2 -2
- package/dist/{chunk-PZ4GT5JO.cjs → chunk-ZKVOS57Q.cjs} +316 -300
- package/dist/chunk-ZKVOS57Q.cjs.map +1 -0
- package/dist/comments.cjs +113 -98
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.d.cts +6 -1
- package/dist/comments.d.ts +6 -1
- package/dist/comments.js +32 -17
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +44 -40
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.js +17 -13
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +60 -40
- package/dist/docx.cjs.map +1 -1
- package/dist/docx.d.cts +6 -0
- package/dist/docx.d.ts +6 -0
- package/dist/docx.js +32 -12
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +9 -9
- package/dist/embed.d.cts +1 -1
- package/dist/embed.d.ts +1 -1
- package/dist/embed.js +8 -8
- package/dist/{emoji-extension-DpQ43HjE.d.ts → emoji-extension-CmPlRssm.d.ts} +1 -1
- package/dist/{emoji-extension-C12gDPm6.d.cts → emoji-extension-zJ6F7hW8.d.cts} +1 -1
- package/dist/emoji.cjs +8 -8
- package/dist/emoji.d.cts +3 -3
- package/dist/emoji.d.ts +3 -3
- package/dist/emoji.js +7 -7
- package/dist/engine.cjs +4 -4
- package/dist/engine.d.cts +2 -2
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +3 -3
- package/dist/{find-extension-_sbZEt3R.d.cts → find-extension-BcRyE9K4.d.cts} +1 -1
- package/dist/{find-extension-DKqLLSuP.d.ts → find-extension-CmFehyul.d.ts} +1 -1
- package/dist/find.cjs +8 -8
- package/dist/find.d.cts +2 -2
- package/dist/find.d.ts +2 -2
- package/dist/find.js +7 -7
- package/dist/headless.cjs +5 -5
- package/dist/headless.d.cts +4 -4
- package/dist/headless.d.ts +4 -4
- package/dist/headless.js +4 -4
- package/dist/{index-CgD72kHB.d.cts → index-CFPmCee4.d.cts} +5 -2
- package/dist/{index-DNYbTK3w.d.ts → index-DiCGV60d.d.ts} +5 -2
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/math.cjs +10 -10
- package/dist/math.d.cts +1 -1
- package/dist/math.d.ts +1 -1
- package/dist/math.js +9 -9
- package/dist/mention.cjs +10 -10
- package/dist/mention.d.cts +1 -1
- package/dist/mention.d.ts +1 -1
- package/dist/mention.js +9 -9
- package/dist/presence.cjs +98 -104
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.d.cts +2 -2
- package/dist/presence.d.ts +2 -2
- package/dist/presence.js +66 -72
- package/dist/presence.js.map +1 -1
- package/dist/{stats-extension-Bly88uio.d.ts → stats-extension-DisOEbbI.d.ts} +1 -1
- package/dist/{stats-extension-CJPijvUb.d.cts → stats-extension-Dt1lgP3m.d.cts} +1 -1
- package/dist/stats.cjs +9 -9
- package/dist/stats.d.cts +3 -3
- package/dist/stats.d.ts +3 -3
- package/dist/stats.js +8 -8
- package/dist/styles.css +1 -1
- package/dist/{table-extension-Dzf4k6hI.d.ts → table-extension-BTMJnT7J.d.ts} +1 -1
- package/dist/{table-extension-BTLxFy2S.d.cts → table-extension-DxZz3jqp.d.cts} +1 -1
- package/dist/table.cjs +8 -8
- package/dist/table.d.cts +2 -2
- package/dist/table.d.ts +2 -2
- package/dist/table.js +7 -7
- package/dist/{toc-extension-DWm5alVj.d.ts → toc-extension-CR9U-l6j.d.ts} +1 -1
- package/dist/{toc-extension-B3-s6h2x.d.cts → toc-extension-DGHywOBv.d.cts} +1 -1
- package/dist/toc.cjs +8 -8
- package/dist/toc.d.cts +2 -2
- package/dist/toc.d.ts +2 -2
- package/dist/toc.js +7 -7
- package/dist/{types-a1CRBlEh.d.ts → types-C6_QkXzy.d.ts} +1 -9
- package/dist/{types-Cz7XJLaK.d.cts → types-CJ7Gq3GX.d.cts} +1 -9
- package/dist/{view-controller-DSHw0ltQ.d.cts → view-controller-BD1KwYfE.d.cts} +6 -19
- package/dist/{view-controller-UbpzblGl.d.ts → view-controller-y4cb60ue.d.ts} +6 -19
- package/dist/view.cjs +6 -6
- package/dist/view.js +3 -3
- package/dist/yjs.cjs +302 -412
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.d.cts +3 -3
- package/dist/yjs.d.ts +3 -3
- package/dist/yjs.js +211 -321
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2VDK27IF.cjs.map +0 -1
- package/dist/chunk-AEJXZBVR.cjs.map +0 -1
- package/dist/chunk-E75EHRPA.cjs +0 -175
- package/dist/chunk-E75EHRPA.cjs.map +0 -1
- package/dist/chunk-GTTPVJSD.cjs.map +0 -1
- package/dist/chunk-HELJTLNC.cjs.map +0 -1
- package/dist/chunk-HJIQT3S5.js.map +0 -1
- package/dist/chunk-JEIFJHEI.js +0 -14
- package/dist/chunk-JEIFJHEI.js.map +0 -1
- package/dist/chunk-KXOBZGQO.js.map +0 -1
- package/dist/chunk-LCQSG4M6.js.map +0 -1
- package/dist/chunk-MQ2XQ4MX.js.map +0 -1
- package/dist/chunk-ND5XJVK2.cjs.map +0 -1
- package/dist/chunk-OMOBMXD5.cjs.map +0 -1
- package/dist/chunk-PZ4GT5JO.cjs.map +0 -1
- package/dist/chunk-QAW5NH6S.cjs +0 -14
- package/dist/chunk-QAW5NH6S.cjs.map +0 -1
- package/dist/chunk-RDG4VI6E.cjs.map +0 -1
- package/dist/chunk-SG37UBDO.js.map +0 -1
- package/dist/chunk-TC4DARU2.js +0 -175
- package/dist/chunk-TC4DARU2.js.map +0 -1
- package/dist/chunk-WXMYDXPN.cjs.map +0 -1
- package/dist/chunk-XEBWC7ZL.js.map +0 -1
- package/dist/chunk-ZGZEJCRV.js.map +0 -1
- package/dist/chunk-ZHOSSWUM.js.map +0 -1
- package/dist/chunk-ZS2WA357.js.map +0 -1
- /package/dist/{chunk-JDPTZUBW.js.map → chunk-623AOJM2.js.map} +0 -0
- /package/dist/{chunk-47MLKSI2.js.map → chunk-ADSJ42DO.js.map} +0 -0
- /package/dist/{chunk-T7SW6OWV.js.map → chunk-IQBMAE3F.js.map} +0 -0
- /package/dist/{chunk-RUDWMKYX.js.map → chunk-JHQUHFLX.js.map} +0 -0
- /package/dist/{chunk-NNDYYEW5.js.map → chunk-N4FGA3H4.js.map} +0 -0
- /package/dist/{chunk-KAVU6T6J.js.map → chunk-OSHZQR3W.js.map} +0 -0
- /package/dist/{chunk-NOKWNK2O.js.map → chunk-RJRX34BZ.js.map} +0 -0
- /package/dist/{chunk-POBM7MGR.js.map → chunk-U3LOLYAU.js.map} +0 -0
- /package/dist/{chunk-PMWCQSQX.js.map → chunk-VCLL5C7J.js.map} +0 -0
- /package/dist/{chunk-K574XHMM.js.map → chunk-YBMUEEM5.js.map} +0 -0
package/dist/yjs.cjs
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var _chunkE75EHRPAcjs = require('./chunk-E75EHRPA.cjs');
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
|
|
@@ -32,12 +31,11 @@ var _chunkE75EHRPAcjs = require('./chunk-E75EHRPA.cjs');
|
|
|
32
31
|
|
|
33
32
|
|
|
34
33
|
|
|
34
|
+
var _chunkTLGX43P6cjs = require('./chunk-TLGX43P6.cjs');
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
var _chunkPZ4GT5JOcjs = require('./chunk-PZ4GT5JO.cjs');
|
|
38
37
|
|
|
39
38
|
|
|
40
|
-
var _chunk2QCRZ7OLcjs = require('./chunk-2QCRZ7OL.cjs');
|
|
41
39
|
|
|
42
40
|
|
|
43
41
|
|
|
@@ -47,127 +45,23 @@ var _chunk2QCRZ7OLcjs = require('./chunk-2QCRZ7OL.cjs');
|
|
|
47
45
|
|
|
48
46
|
|
|
49
47
|
|
|
48
|
+
var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
|
|
50
49
|
|
|
51
50
|
|
|
51
|
+
var _chunk6V6GGBDKcjs = require('./chunk-6V6GGBDK.cjs');
|
|
52
52
|
|
|
53
|
-
var _chunkND5XJVK2cjs = require('./chunk-ND5XJVK2.cjs');
|
|
54
53
|
|
|
55
|
-
// src/engine/collab/apply-remote.ts
|
|
56
|
-
function applyRemote(editor, steps, selectionHint) {
|
|
57
|
-
const tr = editor.createTransaction().setOrigin("remote").setMeta("addToHistory", false);
|
|
58
|
-
for (const step of steps) tr.step(step);
|
|
59
|
-
if (selectionHint && _chunkPZ4GT5JOcjs.sameSelection.call(void 0, _chunkPZ4GT5JOcjs.validateSelection.call(void 0, tr.doc, editor.schema, selectionHint), selectionHint)) {
|
|
60
|
-
tr.setSelection(selectionHint);
|
|
61
|
-
}
|
|
62
|
-
editor.dispatch(tr);
|
|
63
|
-
}
|
|
64
54
|
|
|
65
|
-
// src/yjs/local-to-yjs.ts
|
|
66
|
-
var _yjs = require('yjs'); var Y4 = _interopRequireWildcard(_yjs); var Y = _interopRequireWildcard(_yjs); var Y2 = _interopRequireWildcard(_yjs); var Y3 = _interopRequireWildcard(_yjs); var Y5 = _interopRequireWildcard(_yjs); var Y6 = _interopRequireWildcard(_yjs);
|
|
67
|
-
|
|
68
|
-
// src/yjs/doc-shape.ts
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// src/yjs/marks-codec.ts
|
|
72
|
-
var ESCAPE = "$";
|
|
73
|
-
var escapeKey = (key) => key in Object.prototype || key.startsWith(ESCAPE) ? ESCAPE + key : key;
|
|
74
|
-
var unescapeKey = (key) => key.startsWith(ESCAPE) ? key.slice(1) : key;
|
|
75
|
-
var onlyString = (attrs, key) => Object.keys(attrs).length === 1 && Object.hasOwn(attrs, key) && typeof attrs[key] === "string";
|
|
76
|
-
function markAttribute(mark) {
|
|
77
|
-
const key = _chunkND5XJVK2cjs.markKey.call(void 0, mark);
|
|
78
|
-
const { attrs } = mark;
|
|
79
|
-
const stacked = key !== mark.type;
|
|
80
|
-
if (attrs === void 0) return [escapeKey(key), !stacked];
|
|
81
|
-
if (stacked && onlyString(attrs, "id")) return [escapeKey(key), true];
|
|
82
|
-
if (onlyString(attrs, mark.type)) return [escapeKey(key), attrs[mark.type]];
|
|
83
|
-
return [escapeKey(key), attrs];
|
|
84
|
-
}
|
|
85
|
-
function stackedType(key) {
|
|
86
|
-
const colon = key.indexOf(":");
|
|
87
|
-
if (colon < 1) return null;
|
|
88
|
-
const type = key.slice(0, colon);
|
|
89
|
-
const id = key.slice(colon + 1);
|
|
90
|
-
return _chunkND5XJVK2cjs.markKey.call(void 0, { type, attrs: { id } }) === key ? [type, id] : null;
|
|
91
|
-
}
|
|
92
|
-
function markFromAttribute(attribute, value) {
|
|
93
|
-
const key = unescapeKey(attribute);
|
|
94
|
-
const stacked = stackedType(key);
|
|
95
|
-
const type = _nullishCoalesce(_optionalChain([stacked, 'optionalAccess', _2 => _2[0]]), () => ( key));
|
|
96
|
-
if (value === true) return stacked === null ? { type } : { type, attrs: { id: stacked[1] } };
|
|
97
|
-
if (value === false) return { type };
|
|
98
|
-
if (typeof value === "string") return { type, attrs: { [type]: value } };
|
|
99
|
-
return { type, attrs: value };
|
|
100
|
-
}
|
|
101
|
-
var marksToAttributes = (marks) => Object.fromEntries(marks.map(markAttribute));
|
|
102
|
-
var attributesToMarks = (attributes = {}) => Object.entries(attributes).map(([key, value]) => markFromAttribute(key, value));
|
|
103
|
-
|
|
104
|
-
// src/yjs/inline-codec.ts
|
|
105
|
-
var inlineOps = (inline) => inline.map((node) => ({
|
|
106
|
-
insert: node.kind === "text" ? node.text : { atom: node.type, attrs: node.attrs },
|
|
107
|
-
attributes: marksToAttributes(node.marks)
|
|
108
|
-
}));
|
|
109
|
-
function insertInline(target, at, inline) {
|
|
110
|
-
let offset = at;
|
|
111
|
-
for (const node of inline) {
|
|
112
|
-
const attributes = marksToAttributes(node.marks);
|
|
113
|
-
if (node.kind === "text") target.insert(offset, node.text, attributes);
|
|
114
|
-
else target.insertEmbed(offset, { atom: node.type, attrs: node.attrs }, attributes);
|
|
115
|
-
offset += _chunkND5XJVK2cjs.nodeLength.call(void 0, node);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function nodeOf({ insert, attributes }) {
|
|
119
|
-
const marks = attributesToMarks(attributes);
|
|
120
|
-
return typeof insert === "string" ? _chunkND5XJVK2cjs.text.call(void 0, insert, marks) : _chunkND5XJVK2cjs.atom.call(void 0, insert.atom, insert.attrs, marks);
|
|
121
|
-
}
|
|
122
|
-
var inlineOfOps = (ops) => _chunkND5XJVK2cjs.normalizeInline.call(void 0, ops.map(nodeOf));
|
|
123
|
-
|
|
124
|
-
// src/yjs/doc-shape.ts
|
|
125
|
-
var deleteText = (text2, at, length) => text2.applyDelta(at > 0 ? [{ retain: at }, { delete: length }] : [{ delete: length }]);
|
|
126
|
-
var regionStart = (name) => ({ r: name });
|
|
127
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !(value instanceof Y.AbstractType);
|
|
128
|
-
var regionNameOf = (embed) => isPlainObject(embed) && typeof embed.r === "string" && embed.atom === void 0 ? embed.r : null;
|
|
129
|
-
var isAtomEmbed = (embed) => isPlainObject(embed) && typeof embed.atom === "string" && isPlainObject(embed.attrs);
|
|
130
|
-
var definedEntries = (attrs) => Object.entries(attrs).filter(([, value]) => value !== void 0);
|
|
131
|
-
function markerOf(block) {
|
|
132
|
-
return new Y.Map([
|
|
133
|
-
["id", block.id],
|
|
134
|
-
["type", block.type],
|
|
135
|
-
["indent", block.indent],
|
|
136
|
-
["attrs", new Y.Map(definedEntries(block.attrs))]
|
|
137
|
-
]);
|
|
138
|
-
}
|
|
139
|
-
function readMarker(map) {
|
|
140
|
-
const [id, type, indent, attrs] = ["id", "type", "indent", "attrs"].map((key) => map.get(key));
|
|
141
|
-
if (typeof id !== "string") return null;
|
|
142
|
-
return {
|
|
143
|
-
id,
|
|
144
|
-
type: typeof type === "string" ? type : "",
|
|
145
|
-
indent: typeof indent === "number" ? indent : 0,
|
|
146
|
-
attrs: attrs instanceof Y.Map ? attrs : null
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function blockOps(block, map, open) {
|
|
150
|
-
const ops = [{ insert: map, attributes: {} }];
|
|
151
|
-
for (const [name, inline] of Object.entries(block.regions)) {
|
|
152
|
-
ops.push({ insert: regionStart(name), attributes: {} });
|
|
153
|
-
if (name === open) break;
|
|
154
|
-
ops.push(...inlineOps(inline));
|
|
155
|
-
}
|
|
156
|
-
return ops;
|
|
157
|
-
}
|
|
158
|
-
var writeOps = (text2, at, ops) => text2.applyDelta(at > 0 ? [{ retain: at }, ...ops] : ops);
|
|
159
|
-
function writeBlock(text2, at, block, map, open) {
|
|
160
|
-
writeOps(text2, at, blockOps(block, map, open));
|
|
161
|
-
}
|
|
162
|
-
function writeBlocks(text2, at, blocks) {
|
|
163
|
-
const maps = blocks.map(markerOf);
|
|
164
|
-
writeOps(text2, at, blocks.flatMap((block, i) => blockOps(block, maps[i])));
|
|
165
|
-
return maps;
|
|
166
|
-
}
|
|
167
55
|
|
|
168
|
-
// src/yjs/read-shared.ts
|
|
169
56
|
|
|
170
57
|
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
|
|
61
|
+
|
|
62
|
+
// src/yjs/read-shared.ts
|
|
63
|
+
var _yjs = require('yjs'); var Y = _interopRequireWildcard(_yjs); var Y2 = _interopRequireWildcard(_yjs); var Y3 = _interopRequireWildcard(_yjs); var Y4 = _interopRequireWildcard(_yjs);
|
|
64
|
+
|
|
171
65
|
// src/yjs/required-regions.ts
|
|
172
66
|
var noRequiredRegions = () => [];
|
|
173
67
|
function requiredRegions(schema) {
|
|
@@ -176,7 +70,7 @@ function requiredRegions(schema) {
|
|
|
176
70
|
let names = known.get(type);
|
|
177
71
|
if (names === void 0) {
|
|
178
72
|
const spec = schema.blocks.get(type);
|
|
179
|
-
names = _optionalChain([spec, 'optionalAccess',
|
|
73
|
+
names = _optionalChain([spec, 'optionalAccess', _2 => _2.flow]) === "text" ? Object.keys(spec.initial().regions) : [];
|
|
180
74
|
known.set(type, names);
|
|
181
75
|
}
|
|
182
76
|
return names;
|
|
@@ -185,7 +79,7 @@ function requiredRegions(schema) {
|
|
|
185
79
|
|
|
186
80
|
// src/yjs/read-shared.ts
|
|
187
81
|
function reader(required) {
|
|
188
|
-
const spans = [
|
|
82
|
+
const spans = [_chunkTLGX43P6cjs.emptySpan.call(void 0, )];
|
|
189
83
|
const entries = /* @__PURE__ */ new Map();
|
|
190
84
|
const markers = /* @__PURE__ */ new Map();
|
|
191
85
|
const order = [];
|
|
@@ -195,7 +89,6 @@ function reader(required) {
|
|
|
195
89
|
let entry = null;
|
|
196
90
|
let open = null;
|
|
197
91
|
let stray = null;
|
|
198
|
-
let clean = true;
|
|
199
92
|
const segFor = (region2, host, at, ops = []) => {
|
|
200
93
|
const seg = { host, region: region2, at, length: 0 };
|
|
201
94
|
host.segs.push(seg);
|
|
@@ -212,7 +105,6 @@ function reader(required) {
|
|
|
212
105
|
open.length += length;
|
|
213
106
|
held2.get(open).push(op);
|
|
214
107
|
} else if (span.index === 0 || span.entry !== null) {
|
|
215
|
-
clean = false;
|
|
216
108
|
if (stray === null) {
|
|
217
109
|
stray = { host: span, at: span.length, length: 0, ops: [], after: _nullishCoalesce(order[order.length - 1], () => ( null)) };
|
|
218
110
|
strays.push(stray);
|
|
@@ -222,48 +114,49 @@ function reader(required) {
|
|
|
222
114
|
}
|
|
223
115
|
}
|
|
224
116
|
function marker(map) {
|
|
225
|
-
span =
|
|
117
|
+
span = _chunkTLGX43P6cjs.emptySpan.call(void 0, );
|
|
226
118
|
span.index = spans.length;
|
|
227
119
|
spans.push(span);
|
|
228
120
|
[open, stray] = [null, null];
|
|
229
|
-
const fields = readMarker(map);
|
|
121
|
+
const fields = _chunkTLGX43P6cjs.readMarker.call(void 0, map);
|
|
230
122
|
const kept = fields !== null && !entries.has(fields.id);
|
|
231
123
|
entry = kept ? { id: fields.id, map, span, regions: [], copies: [] } : null;
|
|
232
124
|
if (entry !== null) {
|
|
233
125
|
span.entry = entry;
|
|
234
126
|
entries.set(entry.id, entry);
|
|
235
127
|
markers.set(entry, fields);
|
|
236
|
-
} else {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
span.copyOf = entries.get(fields.id);
|
|
240
|
-
span.copyOf.copies.push(span);
|
|
241
|
-
}
|
|
128
|
+
} else if (fields !== null) {
|
|
129
|
+
span.copyOf = entries.get(fields.id);
|
|
130
|
+
span.copyOf.copies.push(span);
|
|
242
131
|
}
|
|
243
132
|
}
|
|
244
133
|
function embed(value) {
|
|
245
|
-
|
|
134
|
+
let name = _chunkTLGX43P6cjs.regionNameOf.call(void 0, value);
|
|
246
135
|
stray = null;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
136
|
+
const missing = (one) => !entry.regions.some((region2) => region2.name === one);
|
|
137
|
+
if (name !== null && entry !== null) {
|
|
138
|
+
const needed = required(markers.get(entry).type);
|
|
139
|
+
if (needed.length > 0 && !needed.includes(name)) name = _nullishCoalesce(needed.find(missing), () => ( null));
|
|
140
|
+
if (name !== null && missing(name)) {
|
|
141
|
+
const region2 = { name, entry, segs: [] };
|
|
142
|
+
entry.regions.push(region2);
|
|
143
|
+
order.push(region2);
|
|
144
|
+
open = opened(region2);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
253
147
|
}
|
|
254
|
-
clean = false;
|
|
255
148
|
if (open !== null) open = opened(open.region);
|
|
256
149
|
}
|
|
257
150
|
return {
|
|
258
151
|
read(op) {
|
|
259
152
|
const { insert } = op;
|
|
260
|
-
if (typeof insert === "string" || isAtomEmbed(insert)) {
|
|
153
|
+
if (typeof insert === "string" || _chunkTLGX43P6cjs.isAtomEmbed.call(void 0, insert)) {
|
|
261
154
|
const length = typeof insert === "string" ? insert.length : 1;
|
|
262
155
|
content(op, length);
|
|
263
156
|
span.length += length;
|
|
264
157
|
return;
|
|
265
158
|
}
|
|
266
|
-
if (insert instanceof
|
|
159
|
+
if (insert instanceof Y.Map) marker(insert);
|
|
267
160
|
else embed(insert);
|
|
268
161
|
span.length += 1;
|
|
269
162
|
},
|
|
@@ -281,26 +174,42 @@ function reader(required) {
|
|
|
281
174
|
if (after === null) leading.push(seg);
|
|
282
175
|
else region2.segs.push(seg);
|
|
283
176
|
}
|
|
284
|
-
_optionalChain([order, 'access',
|
|
177
|
+
_optionalChain([order, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.segs, 'access', _5 => _5.unshift, 'call', _6 => _6(...leading)]);
|
|
285
178
|
const blocks = [...entries.values()].map((kept) => {
|
|
286
179
|
const { type, indent, attrs } = markers.get(kept);
|
|
287
180
|
for (const name of required(type)) {
|
|
288
181
|
if (!kept.regions.some((region2) => region2.name === name)) kept.regions.push({ name, entry: kept, segs: [] });
|
|
289
182
|
}
|
|
290
|
-
const inline = (segs) => inlineOfOps(segs.flatMap((seg) => held2.get(seg)));
|
|
183
|
+
const inline = (segs) => _chunkTLGX43P6cjs.inlineOfOps.call(void 0, segs.flatMap((seg) => held2.get(seg)));
|
|
291
184
|
const regions = kept.regions.map(({ name, segs }) => [name, inline(segs)]);
|
|
292
|
-
return { id: kept.id, type, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess',
|
|
185
|
+
return { id: kept.id, type, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess', _7 => _7.toJSON, 'call', _8 => _8()]), () => ( {})), regions: Object.fromEntries(regions) };
|
|
293
186
|
});
|
|
294
|
-
const layout =
|
|
295
|
-
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 };
|
|
296
189
|
}
|
|
297
190
|
};
|
|
298
191
|
}
|
|
299
192
|
function readShared(text2, required = noRequiredRegions) {
|
|
300
193
|
const read = reader(required);
|
|
301
|
-
|
|
194
|
+
readItems(text2, () => read, read);
|
|
302
195
|
return read.finish();
|
|
303
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
|
+
}
|
|
304
213
|
|
|
305
214
|
// src/yjs/shared.ts
|
|
306
215
|
function reread(shared) {
|
|
@@ -310,44 +219,41 @@ function reread(shared) {
|
|
|
310
219
|
function insertContent(shared, region2, offset, inline) {
|
|
311
220
|
if (inline.length === 0) return;
|
|
312
221
|
if (region2.segs.length === 0) return openRegion(shared, region2, inline);
|
|
313
|
-
const { seg, rel } =
|
|
314
|
-
insertInline(shared.text,
|
|
315
|
-
|
|
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));
|
|
316
225
|
}
|
|
317
226
|
function deleteContent(shared, region2, from, to) {
|
|
318
|
-
for (const { seg, rel, length } of
|
|
319
|
-
deleteText(shared.text,
|
|
320
|
-
|
|
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);
|
|
321
230
|
}
|
|
322
231
|
}
|
|
323
232
|
function formatContent(shared, region2, from, to, attributes) {
|
|
324
|
-
for (const { seg, rel, length } of
|
|
325
|
-
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);
|
|
326
235
|
}
|
|
327
236
|
}
|
|
328
237
|
function openRegion(shared, { name, entry }, inline) {
|
|
329
|
-
const at =
|
|
330
|
-
shared.text.insertEmbed(at, regionStart(name), {});
|
|
331
|
-
insertInline(shared.text, at + 1, inline);
|
|
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);
|
|
332
241
|
reread(shared);
|
|
333
242
|
}
|
|
334
243
|
|
|
335
|
-
// src/yjs/sync-block.ts
|
|
336
|
-
|
|
337
|
-
|
|
338
244
|
// src/yjs/inline-span.ts
|
|
339
245
|
var units = (inline) => inline.flatMap(
|
|
340
|
-
(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]
|
|
341
247
|
);
|
|
342
248
|
function changedSpan(before, after) {
|
|
343
249
|
const a = units(before);
|
|
344
250
|
const b = units(after);
|
|
345
251
|
let start = 0;
|
|
346
|
-
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;
|
|
347
253
|
let end = 0;
|
|
348
254
|
const shared = Math.min(a.length, b.length) - start;
|
|
349
|
-
while (end < shared &&
|
|
350
|
-
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) };
|
|
351
257
|
}
|
|
352
258
|
|
|
353
259
|
// src/yjs/plain.ts
|
|
@@ -360,17 +266,17 @@ function isPlain({ span, regions }) {
|
|
|
360
266
|
}
|
|
361
267
|
return span.length === end;
|
|
362
268
|
}
|
|
363
|
-
function
|
|
364
|
-
const next = _chunkE75EHRPAcjs.cleanEntry.call(void 0, block, map);
|
|
269
|
+
function adopted(entry, next) {
|
|
365
270
|
next.copies.push(...entry.copies);
|
|
366
271
|
for (const copy of next.copies) copy.copyOf = next;
|
|
367
272
|
return next;
|
|
368
273
|
}
|
|
274
|
+
var rewritten = (entry, block, map = entry.map) => adopted(entry, _chunkTLGX43P6cjs.cleanEntry.call(void 0, block, map));
|
|
369
275
|
function crossesStray(layout, index) {
|
|
370
276
|
const { read, leading, unread } = layout.strays;
|
|
371
277
|
return unread || read.some((seg) => {
|
|
372
|
-
const region2 =
|
|
373
|
-
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);
|
|
374
280
|
});
|
|
375
281
|
}
|
|
376
282
|
|
|
@@ -378,11 +284,11 @@ function crossesStray(layout, index) {
|
|
|
378
284
|
function insertBlocks(shared, next, blocks) {
|
|
379
285
|
const { layout, text: text2 } = shared;
|
|
380
286
|
const span = next === null ? null : layout.entries.get(next).span;
|
|
381
|
-
const index = span === null ? layout.spans.length :
|
|
287
|
+
const index = span === null ? layout.spans.length : _chunkTLGX43P6cjs.indexOf.call(void 0, layout, span);
|
|
382
288
|
const crosses = blocks.some((block) => Object.keys(block.regions).length > 0) && crossesStray(layout, index);
|
|
383
|
-
const maps = writeBlocks(text2, span === null ?
|
|
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);
|
|
384
290
|
if (crosses) reread(shared);
|
|
385
|
-
else
|
|
291
|
+
else _chunkTLGX43P6cjs.placeEntries.call(void 0, layout, index, 0, blocks.map((block, i) => _chunkTLGX43P6cjs.cleanEntry.call(void 0, block, maps[i])));
|
|
386
292
|
}
|
|
387
293
|
function ownParts(entry, span) {
|
|
388
294
|
const parts = [];
|
|
@@ -397,15 +303,15 @@ function ownParts(entry, span) {
|
|
|
397
303
|
}
|
|
398
304
|
function dropSpans(shared, spans) {
|
|
399
305
|
const { layout, text: text2 } = shared;
|
|
400
|
-
for (const span of [...spans].sort((a, b) =>
|
|
401
|
-
const at =
|
|
402
|
-
deleteText(text2,
|
|
403
|
-
|
|
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, []);
|
|
404
310
|
}
|
|
405
311
|
}
|
|
406
312
|
function unreadBefore(layout, span) {
|
|
407
313
|
const before = [];
|
|
408
|
-
for (let at =
|
|
314
|
+
for (let at = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, span) - 1; at > 0 && layout.spans[at].entry === null; at--) {
|
|
409
315
|
before.push(layout.spans[at]);
|
|
410
316
|
}
|
|
411
317
|
return before;
|
|
@@ -417,25 +323,22 @@ function removeBlock(shared, id) {
|
|
|
417
323
|
if (isPlain(entry)) return dropSpans(shared, [.../* @__PURE__ */ new Set([entry.span, ...unread])]);
|
|
418
324
|
dropSpans(shared, [...new Set(unread)]);
|
|
419
325
|
const ranges = [];
|
|
420
|
-
const start =
|
|
326
|
+
const start = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, entry.span);
|
|
421
327
|
ranges.push(...ownParts(entry, entry.span).map(([at, length]) => [start + at, length]));
|
|
422
328
|
for (const seg of entry.regions.flatMap((region2) => region2.segs)) {
|
|
423
|
-
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]);
|
|
424
330
|
}
|
|
425
|
-
for (const [at, length] of ranges.sort((a, b) => b[0] - a[0])) if (length > 0) deleteText(text2, at, length);
|
|
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);
|
|
426
332
|
reread(shared);
|
|
427
333
|
}
|
|
428
334
|
|
|
429
335
|
// src/yjs/sync-block.ts
|
|
430
336
|
function syncAttrs(map, before, after) {
|
|
431
|
-
const current =
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
const kept = new Map(definedEntries(after));
|
|
337
|
+
const current = _chunkTLGX43P6cjs.attrsMap.call(void 0, map, after);
|
|
338
|
+
if (current === null) return;
|
|
339
|
+
const kept = new Map(_chunkTLGX43P6cjs.definedEntries.call(void 0, after));
|
|
437
340
|
for (const key of [...current.keys()]) if (!kept.has(key)) current.delete(key);
|
|
438
|
-
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);
|
|
439
342
|
}
|
|
440
343
|
function keptNames(before, after) {
|
|
441
344
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -451,52 +354,51 @@ function keptNames(before, after) {
|
|
|
451
354
|
function syncRegions(shared, entry, before, after) {
|
|
452
355
|
const { text: text2, layout } = shared;
|
|
453
356
|
const names = Object.keys(after.regions);
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
let at =
|
|
357
|
+
const queue = entry.regions.map(({ name }) => [name, before.regions[name]]);
|
|
358
|
+
const kept = keptNames(queue.map(([name]) => name), names);
|
|
359
|
+
let at = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, entry.span) + 1;
|
|
457
360
|
const dropGone = () => {
|
|
458
|
-
while (queue.length > 0 && !kept.has(queue[0][0])) deleteText(text2, at, 1 +
|
|
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]));
|
|
459
362
|
};
|
|
460
363
|
for (const name of names) {
|
|
461
364
|
dropGone();
|
|
462
365
|
const inline = after.regions[name];
|
|
463
366
|
if (kept.has(name)) {
|
|
464
367
|
const { from, to, slice } = changedSpan(queue.shift()[1], inline);
|
|
465
|
-
if (to > from) deleteText(text2, at + 1 + from, to - from);
|
|
466
|
-
insertInline(text2, at + 1 + from, slice);
|
|
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);
|
|
467
370
|
} else {
|
|
468
|
-
text2.insertEmbed(at, regionStart(name), {});
|
|
469
|
-
insertInline(text2, at + 1, inline);
|
|
371
|
+
text2.insertEmbed(at, _chunkTLGX43P6cjs.regionStart.call(void 0, name), {});
|
|
372
|
+
_chunkTLGX43P6cjs.insertInline.call(void 0, text2, at + 1, inline);
|
|
470
373
|
}
|
|
471
|
-
at += 1 +
|
|
374
|
+
at += 1 + _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline);
|
|
472
375
|
}
|
|
473
376
|
dropGone();
|
|
474
|
-
|
|
377
|
+
_chunkTLGX43P6cjs.placeEntries.call(void 0, layout, _chunkTLGX43P6cjs.indexOf.call(void 0, layout, entry.span), 1, [rewritten(entry, after)]);
|
|
475
378
|
}
|
|
476
379
|
function syncBlock(shared, before, after, next) {
|
|
477
380
|
if (before === after) return;
|
|
478
381
|
const entry = shared.layout.entries.get(before.id);
|
|
479
382
|
const plain = isPlain(entry);
|
|
480
|
-
if (!plain && !
|
|
383
|
+
if (!plain && !_chunk6V6GGBDKcjs.sameValue.call(void 0, Object.keys(before.regions), Object.keys(after.regions))) {
|
|
481
384
|
removeBlock(shared, before.id);
|
|
482
385
|
insertBlocks(shared, next, [after]);
|
|
483
386
|
return;
|
|
484
387
|
}
|
|
485
|
-
if (before
|
|
486
|
-
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]);
|
|
487
389
|
syncAttrs(entry.map, before.attrs, after.attrs);
|
|
488
390
|
if (plain) {
|
|
489
391
|
const gains = Object.keys(before.regions).length === 0 && Object.keys(after.regions).length > 0;
|
|
490
|
-
const crosses = gains && crossesStray(shared.layout,
|
|
392
|
+
const crosses = gains && crossesStray(shared.layout, _chunkTLGX43P6cjs.indexOf.call(void 0, shared.layout, entry.span));
|
|
491
393
|
syncRegions(shared, entry, before, after);
|
|
492
394
|
if (crosses) reread(shared);
|
|
493
395
|
return;
|
|
494
396
|
}
|
|
495
397
|
for (const name of entry.regions.map((region2) => region2.name)) {
|
|
496
398
|
const [was, now] = [before.regions[name], after.regions[name]];
|
|
497
|
-
if (
|
|
399
|
+
if (_chunk4SLJNZSMcjs.equalInline.call(void 0, was, now)) continue;
|
|
498
400
|
const { from, to, slice } = changedSpan(was, now);
|
|
499
|
-
const region2 =
|
|
401
|
+
const region2 = _chunkTLGX43P6cjs.regionOf.call(void 0, shared.layout, before.id, name);
|
|
500
402
|
deleteContent(shared, region2, from, to);
|
|
501
403
|
insertContent(shared, region2, from, slice);
|
|
502
404
|
}
|
|
@@ -530,18 +432,18 @@ var held = (region2) => region2 !== void 0 && region2.segs.length > 0;
|
|
|
530
432
|
function writeSplit(shared, after, { block, region: region2, offset, created }) {
|
|
531
433
|
const { layout, text: text2 } = shared;
|
|
532
434
|
const entry = layout.entries.get(block);
|
|
533
|
-
const tail =
|
|
435
|
+
const tail = _chunk4SLJNZSMcjs.blockById.call(void 0, after, created.id);
|
|
534
436
|
const last = entry.regions[entry.regions.length - 1];
|
|
535
437
|
if (!held(last) || last.name !== region2 || Object.keys(tail.regions).at(-1) !== created.region) return false;
|
|
536
|
-
const { seg, rel } =
|
|
537
|
-
const map = markerOf(tail);
|
|
538
|
-
writeBlock(text2,
|
|
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);
|
|
539
441
|
if (!isPlain(entry)) {
|
|
540
442
|
reread(shared);
|
|
541
443
|
return true;
|
|
542
444
|
}
|
|
543
|
-
const head = rewritten(entry,
|
|
544
|
-
|
|
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)]);
|
|
545
447
|
return true;
|
|
546
448
|
}
|
|
547
449
|
function writeJoin(shared, after, join2) {
|
|
@@ -550,28 +452,28 @@ function writeJoin(shared, after, join2) {
|
|
|
550
452
|
const [into, from] = [target, source].map((id) => layout.entries.get(id));
|
|
551
453
|
const [end, start] = [into.regions.at(-1), from.regions[0]];
|
|
552
454
|
if (!held(end) || !held(start) || end.name !== targetRegion || start.name !== sourceRegion) return false;
|
|
553
|
-
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));
|
|
554
456
|
dropSpans(shared, [...from.copies, ...between]);
|
|
555
|
-
const at =
|
|
457
|
+
const at = _chunkTLGX43P6cjs.spanStart.call(void 0, layout, from.span);
|
|
556
458
|
if (!isPlain(into) || !isPlain(from)) {
|
|
557
459
|
const own = start.segs.find((seg) => seg.host === from.span);
|
|
558
|
-
deleteText(text2, at + own.at - 1, 1);
|
|
559
|
-
deleteText(text2, at, 1);
|
|
460
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, text2, at + own.at - 1, 1);
|
|
461
|
+
_chunkTLGX43P6cjs.deleteText.call(void 0, text2, at, 1);
|
|
560
462
|
reread(shared);
|
|
561
463
|
return true;
|
|
562
464
|
}
|
|
563
|
-
const index =
|
|
465
|
+
const index = _chunkTLGX43P6cjs.indexOf.call(void 0, layout, into.span);
|
|
564
466
|
const moved = from.regions[0].segs[0].length;
|
|
565
467
|
const rest = from.span.length - 2 - moved;
|
|
566
|
-
if (rest > 0) deleteText(text2, at + 2 + moved, rest);
|
|
567
|
-
deleteText(text2, at, 2);
|
|
568
|
-
|
|
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))]);
|
|
569
471
|
return true;
|
|
570
472
|
}
|
|
571
473
|
|
|
572
474
|
// src/yjs/local-to-yjs.ts
|
|
573
|
-
var region = ({ shared, params }) =>
|
|
574
|
-
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));
|
|
575
477
|
function replaceInline(context) {
|
|
576
478
|
const { from, to, slice } = context.params;
|
|
577
479
|
const target = region(context);
|
|
@@ -581,20 +483,20 @@ function replaceInline(context) {
|
|
|
581
483
|
function format(context, keys) {
|
|
582
484
|
const { block, region: name, from, to } = context.params;
|
|
583
485
|
if (to === from) return;
|
|
584
|
-
const inline =
|
|
585
|
-
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)));
|
|
586
488
|
}
|
|
587
489
|
function removedKeys(mark, inline) {
|
|
588
|
-
if (typeof mark !== "string") return { [markAttribute(mark)[0]]: null };
|
|
490
|
+
if (typeof mark !== "string") return { [_chunkTLGX43P6cjs.markAttribute.call(void 0, mark)[0]]: null };
|
|
589
491
|
const marks = inline.flatMap((node) => node.marks.filter((candidate) => candidate.type === mark));
|
|
590
|
-
return Object.fromEntries(marks.map((found) => [markAttribute(found)[0], null]));
|
|
492
|
+
return Object.fromEntries(marks.map((found) => [_chunkTLGX43P6cjs.markAttribute.call(void 0, found)[0], null]));
|
|
591
493
|
}
|
|
592
494
|
function setAttrs({ shared, after, params }) {
|
|
593
495
|
const id = params.block;
|
|
594
496
|
const { map } = shared.layout.entries.get(id);
|
|
595
|
-
const next =
|
|
596
|
-
const attrs =
|
|
597
|
-
if (
|
|
497
|
+
const next = _chunk4SLJNZSMcjs.blockById.call(void 0, after, id).attrs;
|
|
498
|
+
const attrs = _chunkTLGX43P6cjs.attrsMap.call(void 0, map, next);
|
|
499
|
+
if (attrs === null) return;
|
|
598
500
|
for (const key of Object.keys(params.patch)) {
|
|
599
501
|
if (next[key] === void 0) attrs.delete(key);
|
|
600
502
|
else attrs.set(key, next[key]);
|
|
@@ -605,15 +507,15 @@ function moveBlocks({ shared, before, after, params }) {
|
|
|
605
507
|
if (count === 0 || from === to) return;
|
|
606
508
|
const moved = before.blocks.slice(from, from + count);
|
|
607
509
|
for (const block of moved) removeBlock(shared, block.id);
|
|
608
|
-
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);
|
|
609
511
|
}
|
|
610
512
|
var WRITERS = {
|
|
611
513
|
replaceInline,
|
|
612
|
-
addMark: (context) => format(context, () => Object.fromEntries([markAttribute(context.params.mark)])),
|
|
514
|
+
addMark: (context) => format(context, () => Object.fromEntries([_chunkTLGX43P6cjs.markAttribute.call(void 0, context.params.mark)])),
|
|
613
515
|
removeMark: (context) => format(context, (inline) => removedKeys(context.params.mark, inline)),
|
|
614
516
|
setAttrs,
|
|
615
517
|
setIndent: ({ shared, params }) => shared.layout.entries.get(params.block).map.set("indent", params.indent),
|
|
616
|
-
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),
|
|
617
519
|
removeBlocks: ({ shared, before, params }) => {
|
|
618
520
|
const { index, count } = params;
|
|
619
521
|
for (const block of before.blocks.slice(index, index + count)) removeBlock(shared, block.id);
|
|
@@ -631,7 +533,7 @@ var WRITERS = {
|
|
|
631
533
|
},
|
|
632
534
|
replaceBlock: ({ shared, before, params }) => {
|
|
633
535
|
const block = params.block;
|
|
634
|
-
syncBlock(shared,
|
|
536
|
+
syncBlock(shared, _chunk4SLJNZSMcjs.blockById.call(void 0, before, block.id), block, following(before, block.id));
|
|
635
537
|
}
|
|
636
538
|
};
|
|
637
539
|
function writeLocalSteps(shared, steps, docs) {
|
|
@@ -643,77 +545,57 @@ function writeLocalSteps(shared, steps, docs) {
|
|
|
643
545
|
});
|
|
644
546
|
}
|
|
645
547
|
|
|
646
|
-
// src/yjs/own-change.ts
|
|
647
|
-
function ownChange(editor, steps, hint) {
|
|
648
|
-
const tr = editor.createTransaction().setOrigin("history").setMeta("addToHistory", false);
|
|
649
|
-
for (const step of steps) tr.step(step);
|
|
650
|
-
if (hint && _chunkPZ4GT5JOcjs.sameSelection.call(void 0, _chunkPZ4GT5JOcjs.validateSelection.call(void 0, tr.doc, editor.schema, hint), hint)) tr.setSelection(hint);
|
|
651
|
-
return tr;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
548
|
// src/yjs/seed.ts
|
|
655
549
|
function seedOrLoad(editor, text2, { origin, seed, required }) {
|
|
656
550
|
const { blocks } = editor.state.doc;
|
|
657
551
|
if (text2.length === 0 && seed === "if-empty") {
|
|
658
552
|
let maps = [];
|
|
659
|
-
text2.doc.transact(() => maps = writeBlocks(text2, 0, blocks), origin);
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
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;
|
|
663
557
|
}
|
|
664
558
|
const { doc, layout } = readShared(text2, required);
|
|
665
|
-
if (!
|
|
559
|
+
if (!_chunkZKVOS57Qcjs.sameDoc.call(void 0, doc, editor.state.doc)) _chunkTLGX43P6cjs.applyRemote.call(void 0, editor, [_chunkZKVOS57Qcjs.replaceDocStep.call(void 0, doc)]);
|
|
666
560
|
return layout;
|
|
667
561
|
}
|
|
668
562
|
|
|
669
|
-
// src/yjs/
|
|
563
|
+
// src/yjs/read-blocks.ts
|
|
670
564
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
hint = _nullishCoalesce(item.meta.get(SELECTION), () => ( null));
|
|
706
|
-
before = editor.state.selection;
|
|
707
|
-
group = null;
|
|
708
|
-
try {
|
|
709
|
-
return (direction === "undo" ? manager.undo() : manager.redo()) !== null;
|
|
710
|
-
} finally {
|
|
711
|
-
hint = null;
|
|
712
|
-
}
|
|
713
|
-
},
|
|
714
|
-
hint: () => hint,
|
|
715
|
-
destroy: () => manager.destroy()
|
|
716
|
-
};
|
|
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;
|
|
717
599
|
}
|
|
718
600
|
|
|
719
601
|
// src/yjs/read-split-join.ts
|
|
@@ -722,30 +604,31 @@ var bare = (op) => op === void 0 || op.attributes === void 0;
|
|
|
722
604
|
function split(layout, delta, required) {
|
|
723
605
|
const [at, ops] = _optionalChain([delta, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.retain]) === void 0 ? [0, delta] : [delta[0].retain, delta.slice(1)];
|
|
724
606
|
const map = _optionalChain([ops, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.insert]);
|
|
725
|
-
const name = regionNameOf(_optionalChain([ops, 'access', _24 => _24[1], 'optionalAccess', _25 => _25.insert]));
|
|
726
|
-
if (ops.length !== 2 || !(map instanceof
|
|
727
|
-
const marker = readMarker(map);
|
|
728
|
-
const span =
|
|
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);
|
|
729
611
|
if (span.entry === null || !isPlain(span.entry)) return null;
|
|
730
612
|
const region2 = span.entry.regions.at(-1);
|
|
731
613
|
const seg = _optionalChain([region2, 'optionalAccess', _26 => _26.segs, 'access', _27 => _27[0]]);
|
|
732
|
-
const rel = at -
|
|
733
|
-
if (marker === null || seg === void 0
|
|
614
|
+
const rel = at - _chunkTLGX43P6cjs.spanStart.call(void 0, layout, span);
|
|
615
|
+
if (marker === null || layout.entries.has(marker.id) || seg === void 0) return null;
|
|
616
|
+
if (rel < seg.at || rel > seg.at + seg.length) return null;
|
|
734
617
|
if (required(marker.type).some((needed) => needed !== name)) return null;
|
|
735
618
|
const { id, type, indent, attrs } = marker;
|
|
736
619
|
const created = { id, type, indent, attrs: _nullishCoalesce(_optionalChain([attrs, 'optionalAccess', _28 => _28.toJSON, 'call', _29 => _29()]), () => ( {})), region: name, regions: {} };
|
|
737
|
-
return { step:
|
|
620
|
+
return { step: _chunkZKVOS57Qcjs.splitBlockStep.call(void 0, span.entry.id, region2.name, _chunkTLGX43P6cjs.offsetIn.call(void 0, seg, rel), created), map };
|
|
738
621
|
}
|
|
739
622
|
function join(layout, delta) {
|
|
740
623
|
const [at, ops] = _optionalChain([delta, 'access', _30 => _30[0], 'optionalAccess', _31 => _31.retain]) === void 0 ? [0, delta] : [delta[0].retain, delta.slice(1)];
|
|
741
624
|
if (ops.length !== 1 || ops[0].delete !== 2 || !bare(delta[0])) return null;
|
|
742
|
-
const span =
|
|
625
|
+
const span = _chunkTLGX43P6cjs.spanAt.call(void 0, layout, at, true);
|
|
743
626
|
const source = span.entry;
|
|
744
627
|
const target = _nullishCoalesce(_optionalChain([layout, 'access', _32 => _32.spans, 'access', _33 => _33[span.index - 1], 'optionalAccess', _34 => _34.entry]), () => ( null));
|
|
745
|
-
if (
|
|
628
|
+
if (_chunkTLGX43P6cjs.spanStart.call(void 0, layout, span) !== at || source === null || target === null) return null;
|
|
746
629
|
if (source.regions.length !== 1 || target.regions.length === 0 || source.copies.length > 0) return null;
|
|
747
630
|
if (!isPlain(source) || !isPlain(target)) return null;
|
|
748
|
-
return
|
|
631
|
+
return _chunkZKVOS57Qcjs.joinBlocksStep.call(void 0, target.id, target.regions.at(-1).name, source.id, source.regions[0].name);
|
|
749
632
|
}
|
|
750
633
|
function splitOrJoin(layout, delta, doc, required) {
|
|
751
634
|
const found = split(layout, delta, required);
|
|
@@ -754,152 +637,107 @@ function splitOrJoin(layout, delta, doc, required) {
|
|
|
754
637
|
const after = step.apply(doc).doc;
|
|
755
638
|
const { block, target, created } = step.toJSON();
|
|
756
639
|
const kept = layout.entries.get(_nullishCoalesce(block, () => ( target)));
|
|
757
|
-
const entries = [rewritten(kept,
|
|
758
|
-
if (found !== null) entries.push(
|
|
759
|
-
|
|
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);
|
|
760
643
|
return step;
|
|
761
644
|
}
|
|
762
645
|
|
|
763
|
-
// src/yjs/text-steps.ts
|
|
764
|
-
function segAt(layout, at, item) {
|
|
765
|
-
const span = _chunkE75EHRPAcjs.spanAt.call(void 0, layout, at, item);
|
|
766
|
-
const rel = at - _chunkE75EHRPAcjs.spanStart.call(void 0, layout, span);
|
|
767
|
-
const seg = span.segs.find((candidate) => candidate.at <= rel && rel <= candidate.at + candidate.length);
|
|
768
|
-
return seg === void 0 ? null : { seg, rel };
|
|
769
|
-
}
|
|
770
|
-
function formatSteps(layout, at, length, attributes) {
|
|
771
|
-
const steps = [];
|
|
772
|
-
for (let span = _chunkE75EHRPAcjs.spanAt.call(void 0, layout, at, true); ; span = layout.spans[span.index + 1]) {
|
|
773
|
-
const start = _chunkE75EHRPAcjs.spanStart.call(void 0, layout, span);
|
|
774
|
-
if (start >= at + length) break;
|
|
775
|
-
for (const seg of span.segs) {
|
|
776
|
-
const from = Math.max(at - start, seg.at);
|
|
777
|
-
const to = Math.min(at + length - start, seg.at + seg.length);
|
|
778
|
-
if (to <= from) continue;
|
|
779
|
-
const { entry, name } = seg.region;
|
|
780
|
-
const [first, last] = [_chunkE75EHRPAcjs.offsetIn.call(void 0, seg, from), _chunkE75EHRPAcjs.offsetIn.call(void 0, seg, to)];
|
|
781
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
782
|
-
const mark = markFromAttribute(key, _nullishCoalesce(value, () => ( true)));
|
|
783
|
-
steps.push((value === null ? _chunkPZ4GT5JOcjs.removeMarkStep : (0, _chunkPZ4GT5JOcjs.addMarkStep))(entry.id, name, first, last, mark));
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
if (span.index + 1 >= layout.spans.length) break;
|
|
787
|
-
}
|
|
788
|
-
return steps;
|
|
789
|
-
}
|
|
790
|
-
function textSteps(layout, delta) {
|
|
791
|
-
const steps = [];
|
|
792
|
-
let at = 0;
|
|
793
|
-
for (const op of delta) {
|
|
794
|
-
if (op.retain !== void 0) {
|
|
795
|
-
if (op.attributes !== void 0) steps.push(...formatSteps(layout, at, op.retain, op.attributes));
|
|
796
|
-
at += op.retain;
|
|
797
|
-
} else if (op.delete !== void 0) {
|
|
798
|
-
const found = segAt(layout, at, true);
|
|
799
|
-
if (found === null || found.rel + op.delete > found.seg.at + found.seg.length) return null;
|
|
800
|
-
const from = _chunkE75EHRPAcjs.offsetIn.call(void 0, found.seg, found.rel);
|
|
801
|
-
const { entry, name } = found.seg.region;
|
|
802
|
-
steps.push(_chunkPZ4GT5JOcjs.replaceInlineStep.call(void 0, entry.id, name, from, from + op.delete, []));
|
|
803
|
-
_chunkE75EHRPAcjs.grow.call(void 0, layout, found.seg, found.rel, -op.delete);
|
|
804
|
-
} else {
|
|
805
|
-
const found = typeof op.insert === "string" || isAtomEmbed(op.insert) ? segAt(layout, at, false) : null;
|
|
806
|
-
if (found === null) return null;
|
|
807
|
-
const inline = inlineOfOps([op]);
|
|
808
|
-
const from = _chunkE75EHRPAcjs.offsetIn.call(void 0, found.seg, found.rel);
|
|
809
|
-
const { entry, name } = found.seg.region;
|
|
810
|
-
steps.push(_chunkPZ4GT5JOcjs.replaceInlineStep.call(void 0, entry.id, name, from, from, inline));
|
|
811
|
-
_chunkE75EHRPAcjs.grow.call(void 0, layout, found.seg, found.rel, _chunkND5XJVK2cjs.inlineLength.call(void 0, inline));
|
|
812
|
-
at += _chunkND5XJVK2cjs.inlineLength.call(void 0, inline);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
return steps;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
646
|
// src/yjs/yjs-to-steps.ts
|
|
819
647
|
var REREAD = new Error("reread");
|
|
820
|
-
function markerSteps(shared, event, doc) {
|
|
648
|
+
function markerSteps(shared, event, doc, read) {
|
|
821
649
|
const target = event.target;
|
|
822
650
|
const marker = target.parent === shared.text ? target : target.parent;
|
|
823
|
-
const fields = readMarker(marker);
|
|
824
|
-
const block = fields === null ? void 0 : _chunkND5XJVK2cjs.blockById.call(void 0, doc, fields.id);
|
|
825
|
-
if (block === void 0 || _optionalChain([shared, 'access', _36 => _36.layout, 'access', _37 => _37.entries, 'access', _38 => _38.get, 'call', _39 => _39(block.id), 'optionalAccess', _40 => _40.map]) !== marker) return [];
|
|
826
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 [];
|
|
827
657
|
if (target !== marker) {
|
|
828
658
|
if (fields.attrs !== target) return [];
|
|
829
|
-
return [
|
|
659
|
+
return [_chunkZKVOS57Qcjs.setAttrsStep.call(void 0, block.id, Object.fromEntries(keys.map((key) => [key, target.get(key)])))];
|
|
830
660
|
}
|
|
831
|
-
if (keys.includes("
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
661
|
+
if (keys.includes("type")) {
|
|
662
|
+
read.set(marker, entry);
|
|
663
|
+
return [];
|
|
664
|
+
}
|
|
665
|
+
const { indent, attrs } = fields;
|
|
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()]), () => ( {})) })];
|
|
837
668
|
}
|
|
838
669
|
function contentSteps(shared, events, doc) {
|
|
839
670
|
const textEvent = events.find((event) => event.target === shared.text);
|
|
840
|
-
const delta = _nullishCoalesce(_optionalChain([textEvent, 'optionalAccess',
|
|
671
|
+
const delta = _nullishCoalesce(_optionalChain([textEvent, 'optionalAccess', _39 => _39.delta]), () => ( []));
|
|
672
|
+
const touched = touchedEntries(shared.layout, delta);
|
|
841
673
|
const structure = splitOrJoin(shared.layout, delta, doc, shared.required);
|
|
842
|
-
const steps = structure === null ? textSteps(shared.layout, delta) : [structure];
|
|
843
|
-
if (steps === null) throw REREAD;
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
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) {
|
|
848
682
|
current = step.apply(current).doc;
|
|
849
|
-
|
|
683
|
+
all.push(step);
|
|
850
684
|
}
|
|
851
|
-
}
|
|
852
|
-
|
|
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 };
|
|
853
690
|
}
|
|
854
691
|
function readRemote(shared, events, doc) {
|
|
855
692
|
try {
|
|
856
|
-
return
|
|
857
|
-
} catch (
|
|
693
|
+
return contentSteps(shared, events, doc);
|
|
694
|
+
} catch (error) {
|
|
858
695
|
const read = readShared(shared.text, shared.required);
|
|
859
696
|
shared.layout = read.layout;
|
|
860
697
|
const blocks = read.doc.blocks.map((block) => {
|
|
861
|
-
const held2 =
|
|
862
|
-
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;
|
|
863
700
|
});
|
|
864
|
-
const next =
|
|
865
|
-
|
|
701
|
+
const next = _chunk4SLJNZSMcjs.createDoc.call(void 0, blocks);
|
|
702
|
+
const failed = error === REREAD ? void 0 : error;
|
|
703
|
+
return { steps: _chunkZKVOS57Qcjs.sameDoc.call(void 0, next, doc) ? [] : [_chunkZKVOS57Qcjs.replaceDocStep.call(void 0, next)], structural: true, failed };
|
|
866
704
|
}
|
|
867
705
|
}
|
|
868
706
|
|
|
869
707
|
// src/yjs/binding.ts
|
|
870
|
-
function bind(editor, text2,
|
|
708
|
+
function bind(editor, text2, options) {
|
|
709
|
+
const { origins, seed, onError } = options;
|
|
871
710
|
const doc = text2.doc;
|
|
872
711
|
const required = requiredRegions(editor.state.schema);
|
|
873
712
|
const layout = seedOrLoad(editor, text2, { origin: origins.local, seed, required });
|
|
713
|
+
const history = options.history();
|
|
874
714
|
const shared = { text: text2, layout, stale: false, required };
|
|
875
|
-
const history = undoHistory(text2, origins.local);
|
|
876
715
|
const ours = (origin) => origin === origins.local || origin === origins.untracked;
|
|
877
|
-
|
|
716
|
+
const held2 = /* @__PURE__ */ new WeakMap();
|
|
878
717
|
const written = /* @__PURE__ */ new WeakSet();
|
|
879
718
|
const hold = (transaction) => {
|
|
880
|
-
if (!ours(transaction.origin)) held2
|
|
719
|
+
if (!ours(transaction.origin)) held2.set(transaction, _chunkTLGX43P6cjs.holdSelection.call(void 0, text2, shared.layout, editor.state.selection));
|
|
881
720
|
};
|
|
882
721
|
const observer = (events, transaction) => {
|
|
883
722
|
if (ours(transaction.origin)) return;
|
|
884
|
-
const { steps, structural } = readRemote(shared, events, editor.state.doc);
|
|
885
|
-
if (steps.length
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
723
|
+
const { steps, structural, failed } = readRemote(shared, events, editor.state.doc);
|
|
724
|
+
if (steps.length > 0 && transaction.origin !== history.manager) {
|
|
725
|
+
_chunkTLGX43P6cjs.applyRemote.call(void 0, editor, steps, structural ? _chunkTLGX43P6cjs.restoreSelection.call(void 0, text2, shared.layout, held2.get(transaction)) : null);
|
|
726
|
+
} else if (steps.length > 0) {
|
|
727
|
+
const tr = _chunkTLGX43P6cjs.sharedChange.call(void 0, editor, steps, history.hint(), "history");
|
|
728
|
+
written.add(tr);
|
|
729
|
+
editor.dispatch(tr);
|
|
730
|
+
}
|
|
731
|
+
if (failed) onError(failed);
|
|
891
732
|
};
|
|
892
733
|
const settle = () => {
|
|
893
734
|
shared.stale = false;
|
|
894
|
-
|
|
895
|
-
shared.layout = read.layout;
|
|
896
|
-
if (!_chunkPZ4GT5JOcjs.sameDoc.call(void 0, read.doc, editor.state.doc)) applyRemote(editor, [_chunkPZ4GT5JOcjs.replaceDocStep.call(void 0, read.doc)]);
|
|
735
|
+
shared.layout = seedOrLoad(editor, text2, { origin: origins.local, seed: false, required });
|
|
897
736
|
};
|
|
898
737
|
doc.on("beforeTransaction", hold);
|
|
899
738
|
text2.observeDeep(observer);
|
|
900
739
|
return {
|
|
901
740
|
editor,
|
|
902
|
-
history,
|
|
903
741
|
shared,
|
|
904
742
|
local(tr) {
|
|
905
743
|
if (written.has(tr)) return;
|
|
@@ -914,18 +752,59 @@ function bind(editor, text2, { origins, seed }) {
|
|
|
914
752
|
stop() {
|
|
915
753
|
doc.off("beforeTransaction", hold);
|
|
916
754
|
text2.unobserveDeep(observer);
|
|
917
|
-
history.destroy();
|
|
918
755
|
}
|
|
919
756
|
};
|
|
920
757
|
}
|
|
921
758
|
|
|
759
|
+
// src/yjs/undo-history.ts
|
|
760
|
+
|
|
761
|
+
var GROUP_DELAY = 500;
|
|
762
|
+
var SELECTION = "selection";
|
|
763
|
+
function undoHistory(text2, origin) {
|
|
764
|
+
const manager = new Y4.UndoManager(text2, { trackedOrigins: /* @__PURE__ */ new Set([origin]), captureTimeout: Infinity });
|
|
765
|
+
let group = null;
|
|
766
|
+
let time = 0;
|
|
767
|
+
let before = null;
|
|
768
|
+
let hint = null;
|
|
769
|
+
manager.on("stack-item-added", ({ stackItem }) => stackItem.meta.set(SELECTION, before));
|
|
770
|
+
return {
|
|
771
|
+
manager,
|
|
772
|
+
record(tr) {
|
|
773
|
+
if (!tr.docChanged) {
|
|
774
|
+
if (tr.getMeta("closeHistory") === true) group = null;
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const next = _chunkZKVOS57Qcjs.groupOf.call(void 0, tr);
|
|
778
|
+
if (next === null || next !== group || tr.time - time >= GROUP_DELAY) manager.stopCapturing();
|
|
779
|
+
group = next;
|
|
780
|
+
time = tr.time;
|
|
781
|
+
before = tr.before.selection;
|
|
782
|
+
},
|
|
783
|
+
travel(direction, editor) {
|
|
784
|
+
const item = manager[`${direction}Stack`].at(-1);
|
|
785
|
+
if (item === void 0) return false;
|
|
786
|
+
hint = _nullishCoalesce(item.meta.get(SELECTION), () => ( null));
|
|
787
|
+
before = editor.state.selection;
|
|
788
|
+
group = null;
|
|
789
|
+
try {
|
|
790
|
+
return manager[direction]() !== null;
|
|
791
|
+
} finally {
|
|
792
|
+
hint = null;
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
hint: () => hint
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
|
|
922
799
|
// src/yjs/index.ts
|
|
923
800
|
function yjsCollaboration(options) {
|
|
924
801
|
const { doc, field = "quoin", awareness, user, seed = "if-empty" } = options;
|
|
925
802
|
const onError = _nullishCoalesce(options.onError, () => ( ((error) => console.error(error))));
|
|
926
803
|
const text2 = doc.getText(field);
|
|
927
804
|
const origins = { local: { user }, untracked: {} };
|
|
805
|
+
let history;
|
|
928
806
|
let binding = null;
|
|
807
|
+
let disconnects = 0;
|
|
929
808
|
const collaboration = {
|
|
930
809
|
doc,
|
|
931
810
|
text: text2,
|
|
@@ -937,46 +816,57 @@ function yjsCollaboration(options) {
|
|
|
937
816
|
onError(new Error("A Yjs collaboration connects one editor at a time; this editor stays unconnected."));
|
|
938
817
|
return () => void 0;
|
|
939
818
|
}
|
|
940
|
-
const current = bind(editor, text2, {
|
|
819
|
+
const current = bind(editor, text2, {
|
|
820
|
+
origins,
|
|
821
|
+
seed,
|
|
822
|
+
onError,
|
|
823
|
+
history: () => history ??= undoHistory(text2, origins.local)
|
|
824
|
+
});
|
|
941
825
|
binding = current;
|
|
942
826
|
return () => {
|
|
943
827
|
current.stop();
|
|
944
828
|
if (binding === current) binding = null;
|
|
829
|
+
const at = ++disconnects;
|
|
830
|
+
setTimeout(() => {
|
|
831
|
+
if (binding !== null || at !== disconnects) return;
|
|
832
|
+
_optionalChain([history, 'optionalAccess', _40 => _40.manager, 'access', _41 => _41.destroy, 'call', _42 => _42()]);
|
|
833
|
+
history = void 0;
|
|
834
|
+
}, 16);
|
|
945
835
|
};
|
|
946
836
|
},
|
|
947
837
|
onLocalTransaction: (tr, state) => {
|
|
948
|
-
if (_optionalChain([binding, 'optionalAccess',
|
|
838
|
+
if (_optionalChain([binding, 'optionalAccess', _43 => _43.editor, 'access', _44 => _44.state]) === state) binding.local(tr);
|
|
949
839
|
},
|
|
950
840
|
history: {
|
|
951
|
-
undo: () => _nullishCoalesce(_optionalChain([binding, 'optionalAccess',
|
|
952
|
-
redo: () => _nullishCoalesce(_optionalChain([binding, 'optionalAccess',
|
|
953
|
-
canUndo: () =>
|
|
954
|
-
canRedo: () =>
|
|
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)),
|
|
843
|
+
canUndo: () => binding !== null && history.manager.canUndo(),
|
|
844
|
+
canRedo: () => binding !== null && history.manager.canRedo()
|
|
955
845
|
}
|
|
956
846
|
};
|
|
957
|
-
|
|
847
|
+
_chunkTLGX43P6cjs.holdBinding.call(void 0, collaboration, () => binding);
|
|
958
848
|
return collaboration;
|
|
959
849
|
}
|
|
960
850
|
|
|
961
851
|
// src/engine/collab/collaboration-link.ts
|
|
962
|
-
var linkKey =
|
|
852
|
+
var linkKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, "collaborationLink");
|
|
963
853
|
var linkPlugin = {
|
|
964
854
|
key: linkKey,
|
|
965
855
|
init: () => ({ mounts: 0, disconnect: null, warned: false }),
|
|
966
856
|
apply: (_tr, link) => link
|
|
967
857
|
};
|
|
968
|
-
var linkOf = (state) =>
|
|
858
|
+
var linkOf = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, linkKey);
|
|
969
859
|
|
|
970
860
|
// src/engine/collab/warn-host-blocks.ts
|
|
971
861
|
function warnHostBlocks() {
|
|
972
|
-
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;
|
|
973
863
|
console.warn(
|
|
974
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."
|
|
975
865
|
);
|
|
976
866
|
}
|
|
977
867
|
|
|
978
868
|
// src/engine/collab/collaboration-extension.ts
|
|
979
|
-
var providerKey =
|
|
869
|
+
var providerKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, _chunkZKVOS57Qcjs.HISTORY_PROVIDER);
|
|
980
870
|
function providing(history) {
|
|
981
871
|
const provider = {
|
|
982
872
|
undo: (dryRun) => dryRun ? history.canUndo() : history.undo(),
|
|
@@ -986,7 +876,7 @@ function providing(history) {
|
|
|
986
876
|
}
|
|
987
877
|
function collaborationExtension(adapter) {
|
|
988
878
|
const { history } = adapter;
|
|
989
|
-
return
|
|
879
|
+
return _chunkZKVOS57Qcjs.defineExtension.call(void 0, {
|
|
990
880
|
name: "collaboration",
|
|
991
881
|
plugins: history === void 0 ? [linkPlugin] : [linkPlugin, providing(history)],
|
|
992
882
|
onMount(editor) {
|
|
@@ -1002,7 +892,7 @@ function collaborationExtension(adapter) {
|
|
|
1002
892
|
}
|
|
1003
893
|
return () => {
|
|
1004
894
|
link.mounts -= 1;
|
|
1005
|
-
if (link.mounts === 0) _optionalChain([link, 'access',
|
|
895
|
+
if (link.mounts === 0) _optionalChain([link, 'access', _51 => _51.disconnect, 'optionalCall', _52 => _52()]);
|
|
1006
896
|
};
|
|
1007
897
|
},
|
|
1008
898
|
onTransaction(tr, state) {
|
|
@@ -1022,5 +912,5 @@ function collaborationExtension(adapter) {
|
|
|
1022
912
|
|
|
1023
913
|
|
|
1024
914
|
|
|
1025
|
-
exports.applyRemote = applyRemote; exports.collaborationExtension = collaborationExtension; exports.yjsCollaboration = yjsCollaboration;
|
|
915
|
+
exports.applyRemote = _chunkTLGX43P6cjs.applyRemote; exports.collaborationExtension = collaborationExtension; exports.yjsCollaboration = yjsCollaboration;
|
|
1026
916
|
//# sourceMappingURL=yjs.cjs.map
|