quoin-editor 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/ai.cjs +168 -249
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +37 -121
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +28 -43
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +20 -37
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
- package/dist/chunk-2EQ6FKSK.js.map +1 -0
- package/dist/{chunk-RJRX34BZ.js → chunk-3BXUGX5F.js} +4 -18
- package/dist/chunk-3BXUGX5F.js.map +1 -0
- package/dist/chunk-3QRVAI53.cjs +27 -0
- package/dist/chunk-3QRVAI53.cjs.map +1 -0
- package/dist/{chunk-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
- package/dist/chunk-7FAVFJAS.js.map +1 -0
- package/dist/{chunk-6V6GGBDK.cjs → chunk-7SVKLWDT.cjs} +24 -31
- package/dist/chunk-7SVKLWDT.cjs.map +1 -0
- package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
- package/dist/chunk-A6PGQVTR.cjs.map +1 -0
- package/dist/{chunk-P6KYXFZC.cjs → chunk-ACSEYJJF.cjs} +426 -534
- package/dist/chunk-ACSEYJJF.cjs.map +1 -0
- package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
- package/dist/chunk-AIS37SL2.cjs.map +1 -0
- package/dist/{chunk-X4HDKFW5.cjs → chunk-DTQFYHDJ.cjs} +56 -105
- package/dist/chunk-DTQFYHDJ.cjs.map +1 -0
- package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
- package/dist/chunk-HDJ653LM.js.map +1 -0
- package/dist/chunk-HQ43EIYO.cjs +94 -0
- package/dist/chunk-HQ43EIYO.cjs.map +1 -0
- package/dist/{chunk-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
- package/dist/chunk-HTLWPSMU.js.map +1 -0
- package/dist/{chunk-ADSJ42DO.js → chunk-HWEK7EX5.js} +17 -69
- package/dist/chunk-HWEK7EX5.js.map +1 -0
- package/dist/{chunk-623AOJM2.js → chunk-ITXCE6KL.js} +7 -25
- package/dist/chunk-ITXCE6KL.js.map +1 -0
- package/dist/{chunk-AUOEM3SF.cjs → chunk-IXVGHH7F.cjs} +102 -155
- package/dist/chunk-IXVGHH7F.cjs.map +1 -0
- package/dist/{chunk-NEZJ7ZP5.js → chunk-JZJIWRF3.js} +4 -8
- package/dist/chunk-JZJIWRF3.js.map +1 -0
- package/dist/{chunk-C23RQVRK.js → chunk-KSF2HILJ.js} +66 -216
- package/dist/chunk-KSF2HILJ.js.map +1 -0
- package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
- package/dist/chunk-L4D23LM2.js.map +1 -0
- package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
- package/dist/chunk-L6OW2FL3.js.map +1 -0
- package/dist/chunk-LE5XMIFJ.cjs +4 -3
- package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
- package/dist/{chunk-5MAYUGTE.cjs → chunk-LY2D45F2.cjs} +233 -363
- package/dist/chunk-LY2D45F2.cjs.map +1 -0
- package/dist/{chunk-VCLL5C7J.js → chunk-MGMA5PEL.js} +14 -57
- package/dist/chunk-MGMA5PEL.js.map +1 -0
- package/dist/chunk-MQUCCSWG.js +2 -3
- package/dist/chunk-MQUCCSWG.js.map +1 -1
- package/dist/chunk-NO3KTZDY.cjs +33 -0
- package/dist/chunk-NO3KTZDY.cjs.map +1 -0
- package/dist/{chunk-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
- package/dist/chunk-OM7E43ZN.cjs.map +1 -0
- package/dist/{chunk-JHQUHFLX.js → chunk-PJCHSHM3.js} +38 -120
- package/dist/chunk-PJCHSHM3.js.map +1 -0
- package/dist/{chunk-EPARJI4V.js → chunk-QC35D2AU.js} +107 -262
- package/dist/chunk-QC35D2AU.js.map +1 -0
- package/dist/{chunk-CW3AFJBR.cjs → chunk-QEMGOL5L.cjs} +1302 -1773
- package/dist/chunk-QEMGOL5L.cjs.map +1 -0
- package/dist/chunk-QWS7KH3K.cjs +483 -0
- package/dist/chunk-QWS7KH3K.cjs.map +1 -0
- package/dist/{chunk-IQBMAE3F.js → chunk-RHQPAW4W.js} +34 -92
- package/dist/chunk-RHQPAW4W.js.map +1 -0
- package/dist/chunk-RIIXJWBR.cjs +24 -0
- package/dist/chunk-RIIXJWBR.cjs.map +1 -0
- package/dist/{chunk-VRS6WCEK.js → chunk-SAEQMDAU.js} +60 -167
- package/dist/chunk-SAEQMDAU.js.map +1 -0
- package/dist/chunk-SKZC4K5S.cjs +612 -0
- package/dist/chunk-SKZC4K5S.cjs.map +1 -0
- package/dist/{chunk-N4FGA3H4.js → chunk-TBCHYHNU.js} +38 -105
- package/dist/chunk-TBCHYHNU.js.map +1 -0
- package/dist/{chunk-OSHZQR3W.js → chunk-TNN6Z52D.js} +13 -45
- package/dist/chunk-TNN6Z52D.js.map +1 -0
- package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
- package/dist/chunk-TYZSB7JT.js.map +1 -0
- package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
- package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
- package/dist/{chunk-FDRUAL3Z.cjs → chunk-WDO6DBYU.cjs} +90 -153
- package/dist/chunk-WDO6DBYU.cjs.map +1 -0
- package/dist/{chunk-WEYDDIBQ.cjs → chunk-WHV5ZSIO.cjs} +36 -64
- package/dist/chunk-WHV5ZSIO.cjs.map +1 -0
- package/dist/{chunk-T43RZTUT.js → chunk-XJDPQFPU.js} +693 -1247
- package/dist/chunk-XJDPQFPU.js.map +1 -0
- package/dist/{chunk-BQANU5BH.cjs → chunk-ZTLYHRZT.cjs} +34 -44
- package/dist/chunk-ZTLYHRZT.cjs.map +1 -0
- package/dist/chunk-ZWB7SZVI.cjs +200 -0
- package/dist/chunk-ZWB7SZVI.cjs.map +1 -0
- package/dist/comments.cjs +209 -290
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +81 -186
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +48 -65
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.d.cts +2 -2
- package/dist/diff.d.ts +2 -2
- package/dist/diff.js +8 -32
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +50 -63
- package/dist/docx.cjs.map +1 -1
- package/dist/docx.js +7 -22
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +18 -12
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +9 -16
- package/dist/embed.js.map +1 -1
- package/dist/emoji-data.cjs +7 -5
- package/dist/emoji-data.cjs.map +1 -1
- package/dist/emoji-data.js +3 -5
- package/dist/emoji-data.js.map +1 -1
- package/dist/emoji.cjs +25 -17
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +8 -17
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +229 -118
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.js +4 -118
- package/dist/engine.js.map +1 -1
- package/dist/find.cjs +29 -19
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +8 -19
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +290 -151
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +5 -1
- package/dist/headless.d.ts +5 -1
- package/dist/headless.js +5 -151
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +348 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +7 -183
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +19 -13
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +10 -17
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +19 -13
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +10 -17
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +98 -132
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +21 -78
- package/dist/presence.js.map +1 -1
- package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
- package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.ts} +25 -2
- package/dist/stats.cjs +26 -18
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +9 -18
- package/dist/stats.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table.cjs +89 -49
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +8 -49
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +25 -17
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +8 -17
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +13 -16
- package/dist/view.cjs.map +1 -1
- package/dist/view.d.cts +2 -2
- package/dist/view.d.ts +2 -2
- package/dist/view.js +7 -16
- package/dist/view.js.map +1 -1
- package/dist/yjs.cjs +186 -228
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +12 -80
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4SLJNZSM.cjs.map +0 -1
- package/dist/chunk-4XFXB37X.js.map +0 -1
- package/dist/chunk-5MAYUGTE.cjs.map +0 -1
- package/dist/chunk-623AOJM2.js.map +0 -1
- package/dist/chunk-6NULZPVC.js.map +0 -1
- package/dist/chunk-6V6GGBDK.cjs.map +0 -1
- package/dist/chunk-73653CJ4.cjs +0 -34
- package/dist/chunk-73653CJ4.cjs.map +0 -1
- package/dist/chunk-ADSJ42DO.js.map +0 -1
- package/dist/chunk-AUOEM3SF.cjs.map +0 -1
- package/dist/chunk-BQANU5BH.cjs.map +0 -1
- package/dist/chunk-C23RQVRK.js.map +0 -1
- package/dist/chunk-CW3AFJBR.cjs.map +0 -1
- package/dist/chunk-DUE3HCZD.js.map +0 -1
- package/dist/chunk-EH5KXQXY.cjs.map +0 -1
- package/dist/chunk-EPARJI4V.js.map +0 -1
- package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
- package/dist/chunk-IQBMAE3F.js.map +0 -1
- package/dist/chunk-JHQUHFLX.js.map +0 -1
- package/dist/chunk-KUYZMSMF.cjs +0 -100
- package/dist/chunk-KUYZMSMF.cjs.map +0 -1
- package/dist/chunk-LLTEGXWZ.cjs +0 -562
- package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
- package/dist/chunk-N4FGA3H4.js.map +0 -1
- package/dist/chunk-NEZJ7ZP5.js.map +0 -1
- package/dist/chunk-O4Z2WMFF.js.map +0 -1
- package/dist/chunk-OBMBSU2S.js.map +0 -1
- package/dist/chunk-OSHZQR3W.js.map +0 -1
- package/dist/chunk-P6KYXFZC.cjs.map +0 -1
- package/dist/chunk-R2BLBV43.cjs +0 -239
- package/dist/chunk-R2BLBV43.cjs.map +0 -1
- package/dist/chunk-RJRX34BZ.js.map +0 -1
- package/dist/chunk-T43RZTUT.js.map +0 -1
- package/dist/chunk-TLGX43P6.cjs.map +0 -1
- package/dist/chunk-U3LOLYAU.js.map +0 -1
- package/dist/chunk-UEKXVCKC.cjs +0 -716
- package/dist/chunk-UEKXVCKC.cjs.map +0 -1
- package/dist/chunk-VCLL5C7J.js.map +0 -1
- package/dist/chunk-VRS6WCEK.js.map +0 -1
- package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
- package/dist/chunk-X4HDKFW5.cjs.map +0 -1
- package/dist/chunk-X4P4TQXH.cjs +0 -30
- package/dist/chunk-X4P4TQXH.cjs.map +0 -1
- package/dist/chunk-XA3UEJIW.cjs +0 -25
- package/dist/chunk-XA3UEJIW.cjs.map +0 -1
- package/dist/chunk-YBMUEEM5.js.map +0 -1
- package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
|
@@ -1,79 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkVFSVN5IQ_cjs = require('./chunk-VFSVN5IQ.cjs');
|
|
4
|
+
var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var reactDom = require('react-dom');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
3
8
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
|
|
66
|
-
|
|
67
|
-
// src/view/react/use-editor-state.ts
|
|
68
|
-
var _react = require('react');
|
|
69
9
|
var wholeState = (state) => state;
|
|
70
10
|
function useEditorState(controller, selector, isEqual = Object.is) {
|
|
71
|
-
const last =
|
|
72
|
-
const subscribe =
|
|
11
|
+
const last = react.useRef(null);
|
|
12
|
+
const subscribe = react.useCallback(
|
|
73
13
|
(notify) => controller.editor.subscribe(() => notify()),
|
|
74
14
|
[controller]
|
|
75
15
|
);
|
|
76
|
-
const getSnapshot =
|
|
16
|
+
const getSnapshot = react.useCallback(() => {
|
|
77
17
|
const { state } = controller.editor;
|
|
78
18
|
const previous = last.current;
|
|
79
19
|
if (previous !== null && previous.state === state && previous.selector === selector) return previous.value;
|
|
@@ -82,19 +22,19 @@ function useEditorState(controller, selector, isEqual = Object.is) {
|
|
|
82
22
|
last.current = { state, selector, value };
|
|
83
23
|
return value;
|
|
84
24
|
}, [controller, selector, isEqual]);
|
|
85
|
-
return
|
|
25
|
+
return react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
86
26
|
}
|
|
87
27
|
|
|
88
28
|
// src/view/selection/selection-decorations.ts
|
|
89
29
|
var SELECTED = { class: "quoin-selected" };
|
|
90
30
|
function isCrossSelection(selection) {
|
|
91
|
-
if (
|
|
31
|
+
if (selection?.kind !== "text") return false;
|
|
92
32
|
const { anchor, head } = selection;
|
|
93
33
|
return anchor.block !== head.block || anchor.region !== head.region;
|
|
94
34
|
}
|
|
95
35
|
function selectionDecorations(state, mode) {
|
|
96
36
|
if (mode !== "decorations" || !isCrossSelection(state.selection)) return [];
|
|
97
|
-
return
|
|
37
|
+
return chunkVFSVN5IQ_cjs.markRanges(state).map(({ block, region, from, to }) => ({
|
|
98
38
|
kind: "inline",
|
|
99
39
|
block,
|
|
100
40
|
region,
|
|
@@ -105,9 +45,9 @@ function selectionDecorations(state, mode) {
|
|
|
105
45
|
}
|
|
106
46
|
|
|
107
47
|
// src/view/dom/attributes.ts
|
|
108
|
-
var sortedEntries = (attrs) =>
|
|
48
|
+
var sortedEntries = (attrs) => chunkAIS37SL2_cjs.dataAttributes(attrs, "");
|
|
109
49
|
function setAttributes(element, attrs, prefix = "") {
|
|
110
|
-
for (const [name, value] of
|
|
50
|
+
for (const [name, value] of chunkAIS37SL2_cjs.writtenAttrs(chunkAIS37SL2_cjs.dataAttributes(attrs, prefix))) element.setAttribute(name, value);
|
|
111
51
|
}
|
|
112
52
|
|
|
113
53
|
// src/view/dom/segments.ts
|
|
@@ -122,9 +62,9 @@ function decorationRanges(decorations, length) {
|
|
|
122
62
|
return ranges;
|
|
123
63
|
}
|
|
124
64
|
function toSegments(inline, decorations) {
|
|
125
|
-
const length =
|
|
65
|
+
const length = chunkAIS37SL2_cjs.inlineLength(inline);
|
|
126
66
|
const ranges = decorationRanges(decorations, length);
|
|
127
|
-
const widgets = decorations.filter((decoration) => decoration.kind === "widget").map((decoration) => ({ decoration, at: Math.min(Math.max(decoration.offset, 0), length) })).sort((a, b) => a.at - b.at || (
|
|
67
|
+
const widgets = decorations.filter((decoration) => decoration.kind === "widget").map((decoration) => ({ decoration, at: Math.min(Math.max(decoration.offset, 0), length) })).sort((a, b) => a.at - b.at || (a.decoration.side ?? 1) - (b.decoration.side ?? 1));
|
|
128
68
|
const edges = [...ranges.flatMap((range) => [range.from, range.to]), ...widgets.map((widget) => widget.at)];
|
|
129
69
|
const cuts = [...new Set(edges)].filter((point) => point > 0 && point < length).sort((a, b) => a - b);
|
|
130
70
|
const covering = (from, to) => ranges.filter((range) => range.from <= from && range.to >= to).map((range) => range.attrs);
|
|
@@ -138,7 +78,7 @@ function toSegments(inline, decorations) {
|
|
|
138
78
|
};
|
|
139
79
|
let start = 0;
|
|
140
80
|
for (const node of inline) {
|
|
141
|
-
const end = start +
|
|
81
|
+
const end = start + chunkAIS37SL2_cjs.nodeLength(node);
|
|
142
82
|
if (node.kind === "atom") {
|
|
143
83
|
placeWidgets(start);
|
|
144
84
|
segments.push({ kind: "atom", node, decorations: covering(start, end), from: start });
|
|
@@ -188,7 +128,7 @@ function create(doc, tag, attributes) {
|
|
|
188
128
|
return element;
|
|
189
129
|
}
|
|
190
130
|
function linkElement({ href = "", title } = {}, doc) {
|
|
191
|
-
const safe =
|
|
131
|
+
const safe = chunkAIS37SL2_cjs.sanitizeHref(href);
|
|
192
132
|
if (safe === null) return create(doc, "span", [["data-quoin-link", ""]]);
|
|
193
133
|
const anchor = create(doc, "a", [["href", safe], ["data-quoin-link", ""]]);
|
|
194
134
|
if (title) anchor.title = title;
|
|
@@ -196,8 +136,8 @@ function linkElement({ href = "", title } = {}, doc) {
|
|
|
196
136
|
}
|
|
197
137
|
function markElement2(mark2, doc) {
|
|
198
138
|
if (mark2.type === "link") return linkElement(mark2.attrs, doc);
|
|
199
|
-
const { tag, attrs } =
|
|
200
|
-
return create(doc, tag,
|
|
139
|
+
const { tag, attrs } = chunkAIS37SL2_cjs.markElement(mark2);
|
|
140
|
+
return create(doc, tag, chunkAIS37SL2_cjs.writtenAttrs(attrs));
|
|
201
141
|
}
|
|
202
142
|
|
|
203
143
|
// src/view/dom/wrappers.ts
|
|
@@ -239,8 +179,8 @@ function wrapperEntries(wrappers, from, to) {
|
|
|
239
179
|
|
|
240
180
|
// src/view/dom/atom-specs.ts
|
|
241
181
|
function defaultAtomText(node) {
|
|
242
|
-
if (node.type === "mention") return `@${
|
|
243
|
-
return node.type === "math" ?
|
|
182
|
+
if (node.type === "mention") return `@${node.attrs.label ?? ""}`;
|
|
183
|
+
return node.type === "math" ? node.attrs.latex ?? "" : node.type;
|
|
244
184
|
}
|
|
245
185
|
function mark(element, attribute, name) {
|
|
246
186
|
element.setAttribute("contenteditable", "false");
|
|
@@ -265,10 +205,10 @@ function atomSpec(segment, options, doc) {
|
|
|
265
205
|
sig: segmentSignature(segment),
|
|
266
206
|
create() {
|
|
267
207
|
const render = own(options.atoms, node.type);
|
|
268
|
-
const content = render ? mark(render(node, doc), "data-quoin-atom", node.type) : defaultAtom(node, doc,
|
|
208
|
+
const content = render ? mark(render(node, doc), "data-quoin-atom", node.type) : defaultAtom(node, doc, options.atomText ?? defaultAtomText);
|
|
269
209
|
const wrappers = createWrappers(node.marks, decorations, doc);
|
|
270
|
-
|
|
271
|
-
return
|
|
210
|
+
wrappers[wrappers.length - 1]?.appendChild(content);
|
|
211
|
+
return wrappers[0] ?? content;
|
|
272
212
|
},
|
|
273
213
|
refresh(top) {
|
|
274
214
|
const chain = unwrap(top, depth);
|
|
@@ -285,7 +225,7 @@ function widgetSpec(segment, options, doc) {
|
|
|
285
225
|
return {
|
|
286
226
|
sig: segmentSignature(segment),
|
|
287
227
|
create() {
|
|
288
|
-
const render =
|
|
228
|
+
const render = own(options.widgets, decoration.widget) ?? defaultWidget;
|
|
289
229
|
return mark(render(decoration, doc), "data-quoin-widget", decoration.widget);
|
|
290
230
|
},
|
|
291
231
|
describe: (node, out) => void out.push({ node, from, to: from, kind: "widget" })
|
|
@@ -294,7 +234,7 @@ function widgetSpec(segment, options, doc) {
|
|
|
294
234
|
|
|
295
235
|
// src/view/dom/dom-map.ts
|
|
296
236
|
var TEXT_NODE = 3;
|
|
297
|
-
var textLength = (node) => (
|
|
237
|
+
var textLength = (node) => (node.textContent ?? "").length;
|
|
298
238
|
var indexIn = (node) => Array.prototype.indexOf.call(node.parentNode.childNodes, node);
|
|
299
239
|
var pointAt = (entry, shift) => ({
|
|
300
240
|
node: entry.node.parentNode,
|
|
@@ -326,13 +266,13 @@ function createDomMap(host, length, entries) {
|
|
|
326
266
|
const at = Math.min(Math.max(offset, 0), length);
|
|
327
267
|
const after = texts.find((entry) => entry.from <= at && at < entry.to);
|
|
328
268
|
const before = texts.find((entry) => entry.from < at && at <= entry.to);
|
|
329
|
-
const text = assoc === 1 ?
|
|
269
|
+
const text = assoc === 1 ? after ?? before : before ?? after;
|
|
330
270
|
if (text) return { node: text.node, offset: at - text.from };
|
|
331
271
|
const next = stops.find((entry) => entry.from >= at);
|
|
332
272
|
const previous = breaksAndAtoms.filter((entry) => entry.to <= at).pop();
|
|
333
273
|
const beforeNext = next && pointAt(next, 0);
|
|
334
274
|
const afterPrevious = previous && pointAt(previous, 1);
|
|
335
|
-
return
|
|
275
|
+
return (assoc === 1 ? beforeNext ?? afterPrevious : afterPrevious ?? beforeNext) ?? { node: host, offset: 0 };
|
|
336
276
|
}
|
|
337
277
|
function atChild(parent, offset, end) {
|
|
338
278
|
const children = parent.childNodes;
|
|
@@ -345,7 +285,7 @@ function createDomMap(host, length, entries) {
|
|
|
345
285
|
function enclosingAtom(node) {
|
|
346
286
|
for (let current = node; current && current !== host; current = current.parentNode) {
|
|
347
287
|
const entry = byNode.get(current);
|
|
348
|
-
if (
|
|
288
|
+
if (entry?.kind === "atom" || entry?.kind === "widget") return entry;
|
|
349
289
|
}
|
|
350
290
|
return void 0;
|
|
351
291
|
}
|
|
@@ -353,7 +293,7 @@ function createDomMap(host, length, entries) {
|
|
|
353
293
|
if (!host.contains(node)) return null;
|
|
354
294
|
if (node === host) return atChild(host, offset, length);
|
|
355
295
|
const atom = enclosingAtom(node);
|
|
356
|
-
if (
|
|
296
|
+
if (atom?.kind === "widget") return atom.from;
|
|
357
297
|
if (atom) {
|
|
358
298
|
const inside = textBefore(atom.node, node, offset);
|
|
359
299
|
return inside > 0 && inside * 2 >= textLength(atom.node) ? atom.to : atom.from;
|
|
@@ -370,7 +310,7 @@ function createDomMap(host, length, entries) {
|
|
|
370
310
|
// src/view/dom/reconcile.ts
|
|
371
311
|
var signatures = /* @__PURE__ */ new WeakMap();
|
|
372
312
|
function keeps(node, spec) {
|
|
373
|
-
return signatures.get(node) === spec.sig && (
|
|
313
|
+
return signatures.get(node) === spec.sig && (spec.refresh?.(node) ?? true);
|
|
374
314
|
}
|
|
375
315
|
function reconcileChildren(parent, specs) {
|
|
376
316
|
const old = Array.from(parent.childNodes);
|
|
@@ -382,7 +322,7 @@ function reconcileChildren(parent, specs) {
|
|
|
382
322
|
oldEnd--;
|
|
383
323
|
newEnd--;
|
|
384
324
|
}
|
|
385
|
-
const anchor =
|
|
325
|
+
const anchor = old[oldEnd] ?? null;
|
|
386
326
|
for (let i = head; i < oldEnd; i++) parent.removeChild(old[i]);
|
|
387
327
|
for (let i = head; i < newEnd; i++) {
|
|
388
328
|
const node = specs[i].create();
|
|
@@ -394,8 +334,8 @@ function reconcileChildren(parent, specs) {
|
|
|
394
334
|
// src/view/dom/text-diff.ts
|
|
395
335
|
function textDiff(before, after, caretHint) {
|
|
396
336
|
if (before === after) return null;
|
|
397
|
-
const prefix =
|
|
398
|
-
const suffix =
|
|
337
|
+
const prefix = chunkVFSVN5IQ_cjs.commonPrefix(before, after);
|
|
338
|
+
const suffix = chunkVFSVN5IQ_cjs.commonSuffix(before, after);
|
|
399
339
|
const shared = Math.min(suffix, Math.min(before.length, after.length) - prefix);
|
|
400
340
|
const removed = before.length - prefix - shared;
|
|
401
341
|
const inserted = after.length - prefix - shared;
|
|
@@ -500,12 +440,12 @@ function specsFor(segment, options, doc) {
|
|
|
500
440
|
}
|
|
501
441
|
}
|
|
502
442
|
function needsFiller(inline) {
|
|
503
|
-
const content =
|
|
443
|
+
const content = chunkAIS37SL2_cjs.inlineText(inline);
|
|
504
444
|
return content === "" || content.endsWith("\n");
|
|
505
445
|
}
|
|
506
446
|
function renderInline(host, inline, decorations, options = {}) {
|
|
507
447
|
const doc = host.ownerDocument;
|
|
508
|
-
const length =
|
|
448
|
+
const length = chunkAIS37SL2_cjs.inlineLength(inline);
|
|
509
449
|
const specs = toSegments(inline, decorations).flatMap((segment) => specsFor(segment, options, doc));
|
|
510
450
|
if (needsFiller(inline)) specs.push(fillerSpec(doc, length));
|
|
511
451
|
reconcileChildren(host, specs);
|
|
@@ -542,7 +482,7 @@ function createHostRegistry(onRegister) {
|
|
|
542
482
|
const key = hostKey(entry.block, entry.region);
|
|
543
483
|
if (byKey.get(key) === entry) byKey.delete(key);
|
|
544
484
|
if (byElement.get(entry.element) === entry) byElement.delete(entry.element);
|
|
545
|
-
|
|
485
|
+
releases.get(entry)?.();
|
|
546
486
|
releases.delete(entry);
|
|
547
487
|
}
|
|
548
488
|
return {
|
|
@@ -555,7 +495,7 @@ function createHostRegistry(onRegister) {
|
|
|
555
495
|
if (onRegister) releases.set(entry, onRegister(element));
|
|
556
496
|
return () => forget(entry);
|
|
557
497
|
},
|
|
558
|
-
get: (block, region) =>
|
|
498
|
+
get: (block, region) => byKey.get(hostKey(block, region))?.element,
|
|
559
499
|
locate(node) {
|
|
560
500
|
for (let current = node; current; current = current.parentNode) {
|
|
561
501
|
const entry = byElement.get(current);
|
|
@@ -570,23 +510,23 @@ function createHostRegistry(onRegister) {
|
|
|
570
510
|
// src/view/controller/dom-selection.ts
|
|
571
511
|
function domToPos(registry, node, offset) {
|
|
572
512
|
const host = registry.locate(node);
|
|
573
|
-
const mapped = host &&
|
|
513
|
+
const mapped = host && domMapOf(host.element)?.fromDom(node, offset);
|
|
574
514
|
return host && typeof mapped === "number" ? { block: host.block, region: host.region, offset: mapped } : null;
|
|
575
515
|
}
|
|
576
516
|
function posToDom(registry, pos, assoc) {
|
|
577
517
|
const host = registry.get(pos.block, pos.region);
|
|
578
|
-
return
|
|
518
|
+
return (host && domMapOf(host)?.toDom(pos.offset, assoc)) ?? null;
|
|
579
519
|
}
|
|
580
520
|
function readSelection(registry, domSelection, blockAt2 = () => void 0) {
|
|
581
|
-
const anchorNode =
|
|
582
|
-
const focusNode =
|
|
521
|
+
const anchorNode = domSelection?.anchorNode;
|
|
522
|
+
const focusNode = domSelection?.focusNode;
|
|
583
523
|
if (!domSelection || !anchorNode || !focusNode) return null;
|
|
584
524
|
const anchor = domToPos(registry, anchorNode, domSelection.anchorOffset);
|
|
585
525
|
const head = domToPos(registry, focusNode, domSelection.focusOffset);
|
|
586
|
-
if (anchor && head) return
|
|
526
|
+
if (anchor && head) return chunkVFSVN5IQ_cjs.textSelection(anchor, head);
|
|
587
527
|
if (anchor || head || registry.locate(anchorNode) || registry.locate(focusNode)) return null;
|
|
588
528
|
const block = blockAt2(anchorNode);
|
|
589
|
-
return block !== void 0 && block === blockAt2(focusNode) ?
|
|
529
|
+
return block !== void 0 && block === blockAt2(focusNode) ? chunkVFSVN5IQ_cjs.nodeSelection(block) : null;
|
|
590
530
|
}
|
|
591
531
|
function selectBlock(domSelection, element) {
|
|
592
532
|
if (!element) return false;
|
|
@@ -603,7 +543,7 @@ function writeSelection(registry, selection, domSelection, blockElement) {
|
|
|
603
543
|
if (selection.kind !== "text") return false;
|
|
604
544
|
const { anchor, head } = selection;
|
|
605
545
|
if (anchor.block !== head.block || anchor.region !== head.region) return false;
|
|
606
|
-
if (
|
|
546
|
+
if (chunkVFSVN5IQ_cjs.sameSelection(readSelection(registry, domSelection), selection)) return true;
|
|
607
547
|
const base = posToDom(registry, anchor, anchor.offset < head.offset ? 1 : -1);
|
|
608
548
|
const extent = posToDom(registry, head, head.offset < anchor.offset ? 1 : -1);
|
|
609
549
|
if (!base || !extent) return false;
|
|
@@ -622,12 +562,12 @@ function listen(target, handlers, options) {
|
|
|
622
562
|
|
|
623
563
|
// src/view/navigation/node-entry.ts
|
|
624
564
|
var NODE_ENTRY = "data-quoin-node-entry";
|
|
625
|
-
var entersAsNode = (controller, block) =>
|
|
565
|
+
var entersAsNode = (controller, block) => controller.blockElement(block)?.querySelector(`[${NODE_ENTRY}]`) != null;
|
|
626
566
|
|
|
627
567
|
// src/view/controller/reader-toggles.ts
|
|
628
568
|
var NO_CHOICES = /* @__PURE__ */ new Map();
|
|
629
569
|
var stores = /* @__PURE__ */ new WeakMap();
|
|
630
|
-
var shownOpen = (block, choices) =>
|
|
570
|
+
var shownOpen = (block, choices) => choices.get(block.id) ?? block.attrs.open === true;
|
|
631
571
|
function createReaderToggles(controller) {
|
|
632
572
|
let choices = NO_CHOICES;
|
|
633
573
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -665,17 +605,17 @@ var known = /* @__PURE__ */ new WeakMap();
|
|
|
665
605
|
function hidersOf(doc) {
|
|
666
606
|
let hiders = known.get(doc);
|
|
667
607
|
if (hiders === void 0) {
|
|
668
|
-
const first = doc.blocks.findIndex(
|
|
669
|
-
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null :
|
|
608
|
+
const first = doc.blocks.findIndex(chunkVFSVN5IQ_cjs.isClosedToggle);
|
|
609
|
+
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null : chunkVFSVN5IQ_cjs.hidingToggle(doc, index + 1));
|
|
670
610
|
known.set(doc, hiders);
|
|
671
611
|
}
|
|
672
612
|
return hiders;
|
|
673
613
|
}
|
|
674
|
-
var hidingToggleAt = (doc, index) =>
|
|
614
|
+
var hidingToggleAt = (doc, index) => hidersOf(doc)[index] ?? null;
|
|
675
615
|
function isHiddenAt(doc, index, choices) {
|
|
676
616
|
if (choices.size === 0) return hidingToggleAt(doc, index) !== null;
|
|
677
617
|
const closed = (block) => block.type === "TOGGLE" && !shownOpen(block, choices);
|
|
678
|
-
return
|
|
618
|
+
return chunkVFSVN5IQ_cjs.hidingToggle(doc, index + 1, closed) !== null;
|
|
679
619
|
}
|
|
680
620
|
var visibleBlockIndexes = (doc) => hidersOf(doc).flatMap((hider, index) => hider === null ? [index] : []);
|
|
681
621
|
function drawnBlockCount(doc, start = 0, end = doc.blocks.length) {
|
|
@@ -700,20 +640,25 @@ function neighbourBlock(doc, from, direction, accept = anyBlock) {
|
|
|
700
640
|
}
|
|
701
641
|
function entryEdge(controller, block, direction) {
|
|
702
642
|
const { doc, schema } = controller.editor.state;
|
|
703
|
-
const edge = direction < 0 ?
|
|
643
|
+
const edge = direction < 0 ? chunkVFSVN5IQ_cjs.endOf(doc, schema, block) : chunkVFSVN5IQ_cjs.startOf(doc, schema, block);
|
|
704
644
|
if (edge.kind !== "text") return edge;
|
|
705
645
|
const drawn = controller.registry.get(edge.head.block, edge.head.region) !== void 0;
|
|
706
|
-
return drawn && !entersAsNode(controller, block) ? edge :
|
|
646
|
+
return drawn && !entersAsNode(controller, block) ? edge : chunkVFSVN5IQ_cjs.nodeSelection(block);
|
|
707
647
|
}
|
|
708
|
-
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ?
|
|
709
|
-
var
|
|
648
|
+
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ? chunkVFSVN5IQ_cjs.nodeSelection(block) : null;
|
|
649
|
+
var canBeEntered = (controller) => (block) => {
|
|
650
|
+
const { schema } = controller.editor.state;
|
|
651
|
+
const region = chunkVFSVN5IQ_cjs.isTextFlow(schema, block) ? chunkVFSVN5IQ_cjs.primaryRegion(schema, block) : null;
|
|
652
|
+
return region === null || controller.registry.get(block.id, region) !== void 0 || entersAsNode(controller, block.id);
|
|
653
|
+
};
|
|
654
|
+
var holdsTextHead = (controller) => (block) => chunkVFSVN5IQ_cjs.isTextFlow(controller.editor.state.schema, block) && entryEdge(controller, block.id, 1).kind === "text";
|
|
710
655
|
function neighbourHead(controller, from, direction) {
|
|
711
656
|
const target = neighbourBlock(controller.editor.state.doc, from, direction, holdsTextHead(controller));
|
|
712
657
|
const edge = target && entryEdge(controller, target.id, direction);
|
|
713
|
-
return
|
|
658
|
+
return edge?.kind === "text" ? edge.head : null;
|
|
714
659
|
}
|
|
715
660
|
function moveToNeighbour(controller, from, direction) {
|
|
716
|
-
const target = neighbourBlock(controller.editor.state.doc, from, direction);
|
|
661
|
+
const target = neighbourBlock(controller.editor.state.doc, from, direction, canBeEntered(controller));
|
|
717
662
|
if (target === null) return false;
|
|
718
663
|
dispatchSelection(controller, entryEdge(controller, target.id, direction));
|
|
719
664
|
return true;
|
|
@@ -748,7 +693,7 @@ function createAutoScroll(element, onScroll, edge = EDGE) {
|
|
|
748
693
|
function tick() {
|
|
749
694
|
frame = null;
|
|
750
695
|
if (delta === 0) return;
|
|
751
|
-
(
|
|
696
|
+
(container ?? win).scrollBy(0, delta);
|
|
752
697
|
onScroll();
|
|
753
698
|
frame = win.requestAnimationFrame(tick);
|
|
754
699
|
}
|
|
@@ -792,10 +737,10 @@ function nearest(items, element, x, y) {
|
|
|
792
737
|
}
|
|
793
738
|
return best;
|
|
794
739
|
}
|
|
795
|
-
var elementAt = (controller, x, y) =>
|
|
740
|
+
var elementAt = (controller, x, y) => controller.root?.ownerDocument.elementFromPoint(x, y) ?? null;
|
|
796
741
|
function hostAt(controller, x, y) {
|
|
797
742
|
const { registry } = controller;
|
|
798
|
-
return
|
|
743
|
+
return registry.locate(elementAt(controller, x, y)) ?? nearest(registry.all(), (entry) => entry.element, x, y);
|
|
799
744
|
}
|
|
800
745
|
function blockAt(controller, x, y) {
|
|
801
746
|
const element = elementAt(controller, x, y);
|
|
@@ -806,16 +751,16 @@ function blockAt(controller, x, y) {
|
|
|
806
751
|
const shell = controller.blockElement(doc.blocks[index].id);
|
|
807
752
|
return shell ? [{ id: doc.blocks[index].id, shell }] : [];
|
|
808
753
|
});
|
|
809
|
-
return
|
|
754
|
+
return nearest(drawn, (entry) => entry.shell, x, y)?.id ?? null;
|
|
810
755
|
}
|
|
811
756
|
function caretPosAt(controller, host, x, y) {
|
|
812
757
|
const { element, block, region } = host;
|
|
813
758
|
const at = (offset) => ({ block, region, offset });
|
|
814
|
-
const end =
|
|
759
|
+
const end = domMapOf(element)?.length ?? 0;
|
|
815
760
|
const box = element.getBoundingClientRect();
|
|
816
761
|
if (y < box.top) return at(0);
|
|
817
762
|
if (y >= box.bottom) return at(end);
|
|
818
|
-
return
|
|
763
|
+
return caretInHost(controller.registry, element, box, host, x, y) ?? at(x < box.left ? 0 : end);
|
|
819
764
|
}
|
|
820
765
|
|
|
821
766
|
// src/view/selection/native-interaction.ts
|
|
@@ -828,10 +773,10 @@ var CONTROLS = `button, a, input, select, textarea, [${NATIVE_INTERACTION}]`;
|
|
|
828
773
|
var sameHost = (pos, host) => pos.block === host.block && pos.region === host.region;
|
|
829
774
|
function anchorAtCrossing(controller) {
|
|
830
775
|
const native = controller.domSelection();
|
|
831
|
-
const anchor =
|
|
776
|
+
const anchor = native?.anchorNode && domToPos(controller.registry, native.anchorNode, native.anchorOffset);
|
|
832
777
|
if (anchor) return anchor;
|
|
833
778
|
const { selection } = controller.editor.state;
|
|
834
|
-
return
|
|
779
|
+
return selection?.kind === "text" ? selection.anchor : null;
|
|
835
780
|
}
|
|
836
781
|
function createCrossBlockPointer(controller) {
|
|
837
782
|
return {
|
|
@@ -845,7 +790,7 @@ function createCrossBlockPointer(controller) {
|
|
|
845
790
|
let preventMouseDown = false;
|
|
846
791
|
const scroll = createAutoScroll(root, () => follow(last.x, last.y));
|
|
847
792
|
function select(selection) {
|
|
848
|
-
if (
|
|
793
|
+
if (chunkVFSVN5IQ_cjs.sameSelection(selection, controller.editor.state.selection)) return;
|
|
849
794
|
dispatchSelection(controller, selection);
|
|
850
795
|
}
|
|
851
796
|
function startDragging() {
|
|
@@ -861,18 +806,18 @@ function createCrossBlockPointer(controller) {
|
|
|
861
806
|
if (current.anchor === null) return;
|
|
862
807
|
startDragging();
|
|
863
808
|
}
|
|
864
|
-
select(
|
|
809
|
+
select(chunkVFSVN5IQ_cjs.textSelection(current.anchor, caretPosAt(controller, target, x, y)));
|
|
865
810
|
}
|
|
866
811
|
function followBlocks(current, x, y) {
|
|
867
812
|
if (!controller.dragging && Math.hypot(x - current.x, y - current.y) < DRAG_DISTANCE) return;
|
|
868
813
|
const block = blockAt(controller, x, y);
|
|
869
814
|
if (block === null) return;
|
|
870
815
|
startDragging();
|
|
871
|
-
select(
|
|
816
|
+
select(chunkVFSVN5IQ_cjs.blockRangeSelection(current.start, block));
|
|
872
817
|
}
|
|
873
818
|
function follow(x, y) {
|
|
874
|
-
if (
|
|
875
|
-
else if (
|
|
819
|
+
if (press?.kind === "text") followText(press, x, y);
|
|
820
|
+
else if (press?.kind === "blocks") followBlocks(press, x, y);
|
|
876
821
|
}
|
|
877
822
|
function release() {
|
|
878
823
|
unfollow();
|
|
@@ -894,7 +839,7 @@ function createCrossBlockPointer(controller) {
|
|
|
894
839
|
}
|
|
895
840
|
function extendFrom(host, x, y) {
|
|
896
841
|
const { selection } = controller.editor.state;
|
|
897
|
-
if (
|
|
842
|
+
if (selection?.kind !== "text") return;
|
|
898
843
|
if (sameHost(selection.anchor, host) && !isCrossSelection(selection)) return;
|
|
899
844
|
press = { kind: "text", host, anchor: selection.anchor };
|
|
900
845
|
preventMouseDown = true;
|
|
@@ -916,7 +861,7 @@ function createCrossBlockPointer(controller) {
|
|
|
916
861
|
press = { kind: "blocks", start: block, x: event.clientX, y: event.clientY };
|
|
917
862
|
if (!event.shiftKey && entryEdge(controller, block, 1).kind === "node") {
|
|
918
863
|
controller.nodeReveal.pressed(block);
|
|
919
|
-
select(
|
|
864
|
+
select(chunkVFSVN5IQ_cjs.nodeSelection(block));
|
|
920
865
|
}
|
|
921
866
|
} else {
|
|
922
867
|
return;
|
|
@@ -944,7 +889,7 @@ function createCrossBlockPointer(controller) {
|
|
|
944
889
|
// src/view/selection/paint-selection.ts
|
|
945
890
|
var NAME = "quoin-selection";
|
|
946
891
|
function coveredRanges(controller) {
|
|
947
|
-
return
|
|
892
|
+
return chunkVFSVN5IQ_cjs.markRanges(controller.editor.state).flatMap(({ block, region, from, to }) => {
|
|
948
893
|
const host = controller.registry.get(block, region);
|
|
949
894
|
const map = host && domMapOf(host);
|
|
950
895
|
if (!host || !map) return [];
|
|
@@ -988,7 +933,7 @@ function decorationPainter() {
|
|
|
988
933
|
}
|
|
989
934
|
function createPainter(win) {
|
|
990
935
|
const { CSS: css, Highlight } = win;
|
|
991
|
-
return
|
|
936
|
+
return css?.highlights && Highlight ? highlightPainter(css.highlights, Highlight) : decorationPainter();
|
|
992
937
|
}
|
|
993
938
|
|
|
994
939
|
// src/view/selection/in-place.ts
|
|
@@ -1009,13 +954,13 @@ function inPlace(element, change) {
|
|
|
1009
954
|
}
|
|
1010
955
|
|
|
1011
956
|
// src/view/selection/selection-sink.ts
|
|
1012
|
-
var wholeBlocks = (selection) =>
|
|
957
|
+
var wholeBlocks = (selection) => selection?.kind === "blocks" || selection?.kind === "node";
|
|
1013
958
|
function heldBySink(selection) {
|
|
1014
959
|
return wholeBlocks(selection) || isCrossSelection(selection);
|
|
1015
960
|
}
|
|
1016
961
|
var NO_TEXT = "\xA0";
|
|
1017
962
|
function selectionText(state) {
|
|
1018
|
-
const text =
|
|
963
|
+
const text = chunkVFSVN5IQ_cjs.markRanges(state).map((range) => chunkAIS37SL2_cjs.inlinePlainText(chunkVFSVN5IQ_cjs.rangeContent(state, range), state.schema)).join("\n");
|
|
1019
964
|
return text === "" ? NO_TEXT : text;
|
|
1020
965
|
}
|
|
1021
966
|
var focusInPlace = (sink) => inPlace(sink, () => sink.focus({ preventScroll: true }));
|
|
@@ -1035,11 +980,11 @@ function focusSink(controller) {
|
|
|
1035
980
|
focusing = outer;
|
|
1036
981
|
}
|
|
1037
982
|
}
|
|
1038
|
-
|
|
983
|
+
sink.ownerDocument.getSelection()?.selectAllChildren(sink);
|
|
1039
984
|
}
|
|
1040
985
|
function selectedBlockName({ doc, schema, selection }, blockLabel) {
|
|
1041
|
-
const block =
|
|
1042
|
-
return block === void 0 ? null :
|
|
986
|
+
const block = selection?.kind === "node" ? chunkAIS37SL2_cjs.blockById(doc, selection.block) : void 0;
|
|
987
|
+
return block === void 0 ? null : blockLabel?.(block, schema) ?? "";
|
|
1043
988
|
}
|
|
1044
989
|
function clearSink(controller) {
|
|
1045
990
|
const { sink } = controller;
|
|
@@ -1058,11 +1003,11 @@ function createCrossMode(controller) {
|
|
|
1058
1003
|
const cross = isCrossSelection(state.selection);
|
|
1059
1004
|
synced = state;
|
|
1060
1005
|
if (cross) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1006
|
+
attached?.root.setAttribute(CROSS, "");
|
|
1007
|
+
attached?.painter.paint(controller);
|
|
1063
1008
|
} else if (active) {
|
|
1064
|
-
|
|
1065
|
-
|
|
1009
|
+
attached?.root.removeAttribute(CROSS);
|
|
1010
|
+
attached?.painter.clear();
|
|
1066
1011
|
}
|
|
1067
1012
|
if (!heldBySink(state.selection)) clearSink(controller);
|
|
1068
1013
|
active = cross;
|
|
@@ -1079,7 +1024,7 @@ function createCrossMode(controller) {
|
|
|
1079
1024
|
return active;
|
|
1080
1025
|
},
|
|
1081
1026
|
get mode() {
|
|
1082
|
-
return
|
|
1027
|
+
return attached?.painter.mode ?? "highlight";
|
|
1083
1028
|
},
|
|
1084
1029
|
attach(root) {
|
|
1085
1030
|
const view = root.ownerDocument.defaultView;
|
|
@@ -1103,7 +1048,7 @@ function createCrossMode(controller) {
|
|
|
1103
1048
|
}
|
|
1104
1049
|
|
|
1105
1050
|
// src/view/selection/node-reveal.ts
|
|
1106
|
-
var nodeOf = (selection) =>
|
|
1051
|
+
var nodeOf = (selection) => selection?.kind === "node" ? selection.block : null;
|
|
1107
1052
|
function createNodeReveal(element) {
|
|
1108
1053
|
let shown = null;
|
|
1109
1054
|
let pressed = null;
|
|
@@ -1125,7 +1070,7 @@ function createNodeReveal(element) {
|
|
|
1125
1070
|
show(selection, local) {
|
|
1126
1071
|
const block = nodeOf(selection);
|
|
1127
1072
|
if (block !== null && block !== pressed && (block !== shown || local && block === owed)) {
|
|
1128
|
-
|
|
1073
|
+
element(block)?.scrollIntoView({ block: "nearest" });
|
|
1129
1074
|
}
|
|
1130
1075
|
if (local) owed = null;
|
|
1131
1076
|
shown = block;
|
|
@@ -1143,11 +1088,11 @@ function createAnnouncer(stateOf, throttleMs = THROTTLE_MS) {
|
|
|
1143
1088
|
announce(message) {
|
|
1144
1089
|
const state = stateOf();
|
|
1145
1090
|
const now = Date.now();
|
|
1146
|
-
if (
|
|
1147
|
-
spoken = { message, state, serial: (
|
|
1091
|
+
if (spoken?.message === message && spoken.state === state && now - spoken.at < throttleMs) return;
|
|
1092
|
+
spoken = { message, state, serial: (spoken?.serial ?? 0) + 1, at: now };
|
|
1148
1093
|
for (const listener of [...listeners]) listener();
|
|
1149
1094
|
},
|
|
1150
|
-
current: () =>
|
|
1095
|
+
current: () => spoken?.state === stateOf() ? spoken : null,
|
|
1151
1096
|
subscribe(listener) {
|
|
1152
1097
|
listeners.add(listener);
|
|
1153
1098
|
return () => void listeners.delete(listener);
|
|
@@ -1175,20 +1120,20 @@ function createElementSlot(changed) {
|
|
|
1175
1120
|
|
|
1176
1121
|
// src/view/controller/selection-element.ts
|
|
1177
1122
|
function elementFor({ doc }, selection, rendered) {
|
|
1178
|
-
const id =
|
|
1123
|
+
const id = chunkVFSVN5IQ_cjs.headBlockId(selection);
|
|
1179
1124
|
const index = id === null ? void 0 : doc.index.get(id);
|
|
1180
1125
|
if (id === null || index === void 0) return void 0;
|
|
1181
1126
|
const hiding = hidingToggleAt(doc, index);
|
|
1182
1127
|
if (hiding !== null) return rendered.block(doc.blocks[hiding].id);
|
|
1183
|
-
const host =
|
|
1184
|
-
return
|
|
1128
|
+
const host = selection?.kind === "text" ? rendered.hosts.get(id, selection.head.region) : void 0;
|
|
1129
|
+
return host ?? rendered.block(id);
|
|
1185
1130
|
}
|
|
1186
1131
|
function selectionElement(state, rendered) {
|
|
1187
1132
|
const { doc, schema, selection } = state;
|
|
1188
|
-
if (doc.blocks.length === 0) return
|
|
1189
|
-
const sink = heldBySink(selection) ?
|
|
1133
|
+
if (doc.blocks.length === 0) return rendered.empty?.() ?? void 0;
|
|
1134
|
+
const sink = heldBySink(selection) ? rendered.sink?.() : null;
|
|
1190
1135
|
if (sink) return sink;
|
|
1191
|
-
return
|
|
1136
|
+
return elementFor(state, selection, rendered) ?? elementFor(state, chunkVFSVN5IQ_cjs.startOf(doc, schema, doc.blocks[0].id), rendered);
|
|
1192
1137
|
}
|
|
1193
1138
|
|
|
1194
1139
|
// src/view/controller/tab-stop.ts
|
|
@@ -1232,10 +1177,10 @@ function createDrawnElements(hosts, state) {
|
|
|
1232
1177
|
},
|
|
1233
1178
|
registerBlock: (id, element) => blocks.register(id, "", element),
|
|
1234
1179
|
block: rendered.block,
|
|
1235
|
-
blockAt: (node) =>
|
|
1180
|
+
blockAt: (node) => blocks.locate(node)?.block,
|
|
1236
1181
|
registerSink: sink.register,
|
|
1237
1182
|
registerEmptyHost: empty.register,
|
|
1238
|
-
isEditorElement: (element) => element === sink.element || element === empty.element || [hosts, blocks].some((registry) =>
|
|
1183
|
+
isEditorElement: (element) => element === sink.element || element === empty.element || [hosts, blocks].some((registry) => registry.locate(element)?.element === element),
|
|
1239
1184
|
focusElement,
|
|
1240
1185
|
syncTabStop
|
|
1241
1186
|
};
|
|
@@ -1243,7 +1188,7 @@ function createDrawnElements(hosts, state) {
|
|
|
1243
1188
|
|
|
1244
1189
|
// src/view/controller/focus-ownership.ts
|
|
1245
1190
|
function hasFocus(controller, doc) {
|
|
1246
|
-
const active =
|
|
1191
|
+
const active = doc?.activeElement ?? null;
|
|
1247
1192
|
return active !== null && controller.isEditorElement(active);
|
|
1248
1193
|
}
|
|
1249
1194
|
function ownsFocus(controller, doc) {
|
|
@@ -1255,9 +1200,9 @@ function ownsFocus(controller, doc) {
|
|
|
1255
1200
|
function focusTarget(state, target) {
|
|
1256
1201
|
const { doc, schema, selection } = state;
|
|
1257
1202
|
if (doc.blocks.length === 0) return null;
|
|
1258
|
-
if (target === "end") return
|
|
1259
|
-
if (target === "start" || target === void 0 && selection === null) return
|
|
1260
|
-
return target === void 0 ? selection :
|
|
1203
|
+
if (target === "end") return chunkVFSVN5IQ_cjs.endOf(doc, schema, doc.blocks[doc.blocks.length - 1].id);
|
|
1204
|
+
if (target === "start" || target === void 0 && selection === null) return chunkVFSVN5IQ_cjs.startOf(doc, schema, doc.blocks[0].id);
|
|
1205
|
+
return target === void 0 ? selection : chunkVFSVN5IQ_cjs.textSelection(target);
|
|
1261
1206
|
}
|
|
1262
1207
|
|
|
1263
1208
|
// src/view/controller/host-decorations.ts
|
|
@@ -1273,7 +1218,7 @@ function decorationsByHost(decorations) {
|
|
|
1273
1218
|
return byHost;
|
|
1274
1219
|
}
|
|
1275
1220
|
function sameDecoration(a, b) {
|
|
1276
|
-
if (a.kind !== b.kind || a.block !== b.block || !
|
|
1221
|
+
if (a.kind !== b.kind || a.block !== b.block || !chunkAIS37SL2_cjs.sameAttrs(a.attrs, b.attrs)) return false;
|
|
1277
1222
|
if (a.kind === "inline" && b.kind === "inline") {
|
|
1278
1223
|
return a.region === b.region && a.from === b.from && a.to === b.to;
|
|
1279
1224
|
}
|
|
@@ -1284,7 +1229,7 @@ function sameDecoration(a, b) {
|
|
|
1284
1229
|
return true;
|
|
1285
1230
|
}
|
|
1286
1231
|
function sameDecorations(a, b) {
|
|
1287
|
-
return a === b ||
|
|
1232
|
+
return a === b || chunkAIS37SL2_cjs.sameItems(a, b, sameDecoration);
|
|
1288
1233
|
}
|
|
1289
1234
|
var byMode = { highlight: /* @__PURE__ */ new WeakMap(), decorations: /* @__PURE__ */ new WeakMap() };
|
|
1290
1235
|
function hostDecorations(editor, block, region, mode = "highlight") {
|
|
@@ -1295,12 +1240,12 @@ function hostDecorations(editor, block, region, mode = "highlight") {
|
|
|
1295
1240
|
grouped = decorationsByHost([...editor.decorations(), ...selectionDecorations(state, mode)]);
|
|
1296
1241
|
byState.set(state, grouped);
|
|
1297
1242
|
}
|
|
1298
|
-
return
|
|
1243
|
+
return grouped.get(hostKey(block, region)) ?? NO_DECORATIONS;
|
|
1299
1244
|
}
|
|
1300
1245
|
|
|
1301
1246
|
// src/view/controller/region-inline.ts
|
|
1302
1247
|
function regionInline(state, block, region) {
|
|
1303
|
-
const regions =
|
|
1248
|
+
const regions = chunkAIS37SL2_cjs.blockById(state.doc, block)?.regions;
|
|
1304
1249
|
return regions && Object.hasOwn(regions, region) ? regions[region] : void 0;
|
|
1305
1250
|
}
|
|
1306
1251
|
|
|
@@ -1312,8 +1257,8 @@ function createHostRenderer(editor, options, decorationsOf, afterRender) {
|
|
|
1312
1257
|
if (inline === void 0) return false;
|
|
1313
1258
|
const decorations = decorationsOf(host.block, host.region);
|
|
1314
1259
|
const last = rendered.get(host.element);
|
|
1315
|
-
const restyled =
|
|
1316
|
-
if (!always &&
|
|
1260
|
+
const restyled = last?.inline === inline && !sameDecorations(last.decorations, decorations);
|
|
1261
|
+
if (!always && last?.inline === inline && !restyled) return false;
|
|
1317
1262
|
renderInline(host.element, inline, decorations, options);
|
|
1318
1263
|
afterRender(host.element);
|
|
1319
1264
|
rendered.set(host.element, { inline, decorations });
|
|
@@ -1343,14 +1288,14 @@ function createOutsideChanges(editorHasFocus, movedFrom) {
|
|
|
1343
1288
|
committed(tr) {
|
|
1344
1289
|
const outside = depth === 0 && editorHasFocus();
|
|
1345
1290
|
focused ||= outside;
|
|
1346
|
-
if (
|
|
1291
|
+
if (tr?.selectionSet !== false) {
|
|
1347
1292
|
moved = null;
|
|
1348
1293
|
settled ||= depth === 0;
|
|
1349
1294
|
return;
|
|
1350
1295
|
}
|
|
1351
|
-
const from =
|
|
1296
|
+
const from = moved ?? (outside && !settled ? movedFrom(tr.before.selection) : null);
|
|
1352
1297
|
settled ||= outside;
|
|
1353
|
-
moved = from &&
|
|
1298
|
+
moved = from && chunkVFSVN5IQ_cjs.mapSelection(from, (pos, assoc) => tr.mapPos(pos, assoc), tr.before.doc);
|
|
1354
1299
|
},
|
|
1355
1300
|
takeFocused() {
|
|
1356
1301
|
const value = focused;
|
|
@@ -1401,11 +1346,11 @@ function wrapSliceHTML(html, json) {
|
|
|
1401
1346
|
return `<div data-quoin-slice="${encode(json)}">${html}</div>`;
|
|
1402
1347
|
}
|
|
1403
1348
|
function readSliceHTML(html) {
|
|
1404
|
-
const encoded =
|
|
1349
|
+
const encoded = MARKER.exec(html)?.[2];
|
|
1405
1350
|
if (!encoded) return null;
|
|
1406
1351
|
try {
|
|
1407
1352
|
return decode(encoded);
|
|
1408
|
-
} catch
|
|
1353
|
+
} catch {
|
|
1409
1354
|
return null;
|
|
1410
1355
|
}
|
|
1411
1356
|
}
|
|
@@ -1413,7 +1358,7 @@ function readSliceHTML(html) {
|
|
|
1413
1358
|
// src/view/clipboard/paste-transfer.ts
|
|
1414
1359
|
function caretOf(controller) {
|
|
1415
1360
|
const { selection } = controller.editor.state;
|
|
1416
|
-
return
|
|
1361
|
+
return selection?.kind === "text" ? selection.head : null;
|
|
1417
1362
|
}
|
|
1418
1363
|
function transferFiles(transfer) {
|
|
1419
1364
|
const files = Array.from(transfer.files);
|
|
@@ -1423,7 +1368,7 @@ function transferFiles(transfer) {
|
|
|
1423
1368
|
function pasteTransfer(controller, transfer) {
|
|
1424
1369
|
const files = transferFiles(transfer);
|
|
1425
1370
|
if (files !== null) {
|
|
1426
|
-
|
|
1371
|
+
controller.onFiles?.(files, caretOf(controller));
|
|
1427
1372
|
return;
|
|
1428
1373
|
}
|
|
1429
1374
|
const text = transfer.getData("text/plain");
|
|
@@ -1443,7 +1388,7 @@ function handleCopy(controller, event, cut) {
|
|
|
1443
1388
|
clipboardData.setData("text/plain", copied.text);
|
|
1444
1389
|
clipboardData.setData("text/html", wrapSliceHTML(copied.html, copied.json));
|
|
1445
1390
|
clipboardData.setData(QUOIN_SLICE_TYPE, copied.json);
|
|
1446
|
-
if (cut) controller.run(
|
|
1391
|
+
if (cut) controller.run(chunkVFSVN5IQ_cjs.deleteSelection);
|
|
1447
1392
|
}
|
|
1448
1393
|
function handlePaste(controller, event) {
|
|
1449
1394
|
if (!event.clipboardData) return;
|
|
@@ -1458,9 +1403,9 @@ function dropPos(controller, x, y) {
|
|
|
1458
1403
|
return host && caretPosAt(controller, host, x, y);
|
|
1459
1404
|
}
|
|
1460
1405
|
function textlessBlockAt(controller, x, y) {
|
|
1461
|
-
const element =
|
|
1406
|
+
const element = controller.root?.ownerDocument.elementFromPoint(x, y);
|
|
1462
1407
|
const block = element ? controller.blockAt(element) : void 0;
|
|
1463
|
-
if (block === void 0 || controller.registry.locate(
|
|
1408
|
+
if (block === void 0 || controller.registry.locate(element ?? null) !== null) return null;
|
|
1464
1409
|
const hasText = [...controller.registry.all()].some((host) => host.block === block);
|
|
1465
1410
|
return hasText && !entersAsNode(controller, block) ? null : { block, region: "", offset: 0 };
|
|
1466
1411
|
}
|
|
@@ -1471,15 +1416,15 @@ function handleDrop(controller, event) {
|
|
|
1471
1416
|
const files = transferFiles(dataTransfer);
|
|
1472
1417
|
const onBlock2 = files && textlessBlockAt(controller, event.clientX, event.clientY);
|
|
1473
1418
|
if (files && onBlock2) {
|
|
1474
|
-
|
|
1419
|
+
controller.onFiles?.(files, onBlock2);
|
|
1475
1420
|
return;
|
|
1476
1421
|
}
|
|
1477
1422
|
const pos = dropPos(controller, event.clientX, event.clientY);
|
|
1478
|
-
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
1423
|
+
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(chunkVFSVN5IQ_cjs.textSelection(pos)).setOrigin("drop"));
|
|
1479
1424
|
pasteTransfer(controller, dataTransfer);
|
|
1480
1425
|
}
|
|
1481
1426
|
function handleDragOver(event) {
|
|
1482
|
-
const types =
|
|
1427
|
+
const types = event.dataTransfer?.types ?? [];
|
|
1483
1428
|
if (DROPPABLE.some((type) => types.includes(type))) event.preventDefault();
|
|
1484
1429
|
}
|
|
1485
1430
|
function handleDragStart(event) {
|
|
@@ -1488,9 +1433,9 @@ function handleDragStart(event) {
|
|
|
1488
1433
|
|
|
1489
1434
|
// src/view/clipboard/attach-clipboard.ts
|
|
1490
1435
|
function attachClipboard(controller, root, catchUp) {
|
|
1491
|
-
const inEmptyHost = (target) =>
|
|
1436
|
+
const inEmptyHost = (target) => target.closest?.("[data-quoin-empty]") != null;
|
|
1492
1437
|
const inEditor = ({ target }) => controller.registry.locate(target) !== null || controller.isEditorElement(target) || inEmptyHost(target);
|
|
1493
|
-
const inField = ({ target }) =>
|
|
1438
|
+
const inField = ({ target }) => target?.closest?.("input, textarea, select") != null;
|
|
1494
1439
|
const droppable = (event) => !controller.readOnly && !inField(event);
|
|
1495
1440
|
const onCopy = (event) => {
|
|
1496
1441
|
if (!inEditor(event)) return;
|
|
@@ -1550,7 +1495,7 @@ function textOutsideSelection(sink) {
|
|
|
1550
1495
|
};
|
|
1551
1496
|
}
|
|
1552
1497
|
function composedText(sink, { before, after }) {
|
|
1553
|
-
let text =
|
|
1498
|
+
let text = sink.textContent ?? "";
|
|
1554
1499
|
if (text.startsWith(before)) text = text.slice(before.length);
|
|
1555
1500
|
return text.endsWith(after) ? text.slice(0, text.length - after.length) : text;
|
|
1556
1501
|
}
|
|
@@ -1558,7 +1503,7 @@ function createSinkComposition(controller) {
|
|
|
1558
1503
|
let outside = null;
|
|
1559
1504
|
let stopWaiting = null;
|
|
1560
1505
|
function settle() {
|
|
1561
|
-
|
|
1506
|
+
stopWaiting?.();
|
|
1562
1507
|
stopWaiting = null;
|
|
1563
1508
|
const { sink } = controller;
|
|
1564
1509
|
const ignored = wholeBlocks(controller.editor.state.selection);
|
|
@@ -1571,7 +1516,7 @@ function createSinkComposition(controller) {
|
|
|
1571
1516
|
}
|
|
1572
1517
|
return {
|
|
1573
1518
|
start() {
|
|
1574
|
-
|
|
1519
|
+
stopWaiting?.();
|
|
1575
1520
|
stopWaiting = null;
|
|
1576
1521
|
if (outside === null && controller.sink !== null) outside = textOutsideSelection(controller.sink);
|
|
1577
1522
|
controller.composingKey = SINK_KEY;
|
|
@@ -1603,29 +1548,29 @@ function createSinkComposition(controller) {
|
|
|
1603
1548
|
var LINE_BREAK = "\n";
|
|
1604
1549
|
var transposeChars = (state, dispatch) => {
|
|
1605
1550
|
const { selection } = state;
|
|
1606
|
-
if (
|
|
1551
|
+
if (selection?.kind !== "text" || !chunkVFSVN5IQ_cjs.isCollapsed(selection)) return false;
|
|
1607
1552
|
const { head } = selection;
|
|
1608
|
-
const inline =
|
|
1553
|
+
const inline = chunkAIS37SL2_cjs.blockById(state.doc, head.block)?.regions[head.region];
|
|
1609
1554
|
if (inline === void 0) return false;
|
|
1610
|
-
const value =
|
|
1555
|
+
const value = chunkAIS37SL2_cjs.inlineText(inline);
|
|
1611
1556
|
const atLineEnd = head.offset === value.length || value[head.offset] === LINE_BREAK;
|
|
1612
|
-
const end = atLineEnd ? head.offset :
|
|
1613
|
-
const middle =
|
|
1614
|
-
const start =
|
|
1557
|
+
const end = atLineEnd ? head.offset : chunkVFSVN5IQ_cjs.nextGraphemeOffset(value, head.offset);
|
|
1558
|
+
const middle = chunkVFSVN5IQ_cjs.prevGraphemeOffset(value, end);
|
|
1559
|
+
const start = chunkVFSVN5IQ_cjs.prevGraphemeOffset(value, middle);
|
|
1615
1560
|
if (start === middle || value.slice(start, end).includes(LINE_BREAK)) return false;
|
|
1616
|
-
const swapped = [...
|
|
1617
|
-
const tr = new
|
|
1618
|
-
tr.step(
|
|
1619
|
-
|
|
1561
|
+
const swapped = [...chunkAIS37SL2_cjs.sliceInline(inline, middle, end), ...chunkAIS37SL2_cjs.sliceInline(inline, start, middle)];
|
|
1562
|
+
const tr = new chunkVFSVN5IQ_cjs.Transaction(state).setOrigin("input");
|
|
1563
|
+
tr.step(chunkVFSVN5IQ_cjs.replaceInlineStep(head.block, head.region, start, end, swapped));
|
|
1564
|
+
dispatch?.(tr.setSelection(chunkVFSVN5IQ_cjs.textSelection({ ...head, offset: end })));
|
|
1620
1565
|
return true;
|
|
1621
1566
|
};
|
|
1622
1567
|
|
|
1623
1568
|
// src/view/input/replace-range.ts
|
|
1624
1569
|
function replaceRange(editor, range, text, withRules) {
|
|
1625
1570
|
const dispatch = (tr) => editor.dispatch(tr);
|
|
1626
|
-
dispatch(editor.createTransaction().setSelection(
|
|
1627
|
-
if (text === "") return
|
|
1628
|
-
return withRules ? editor.insertText(text) :
|
|
1571
|
+
dispatch(editor.createTransaction().setSelection(chunkVFSVN5IQ_cjs.textSelection(range.from, range.to)).setOrigin("input"));
|
|
1572
|
+
if (text === "") return chunkVFSVN5IQ_cjs.deleteSelection(editor.state, (tr) => dispatch(tr.setOrigin("input")));
|
|
1573
|
+
return withRules ? editor.insertText(text) : chunkVFSVN5IQ_cjs.insertText(text, { origin: "input" })(editor.state, dispatch);
|
|
1629
1574
|
}
|
|
1630
1575
|
|
|
1631
1576
|
// src/view/input/target-range.ts
|
|
@@ -1636,13 +1581,13 @@ function targetRangeToModel(controller, event) {
|
|
|
1636
1581
|
const to = domToPos(controller.registry, range.endContainer, range.endOffset);
|
|
1637
1582
|
return from && to && { from, to };
|
|
1638
1583
|
}
|
|
1639
|
-
var isEmpty = ({ from, to }) =>
|
|
1584
|
+
var isEmpty = ({ from, to }) => chunkVFSVN5IQ_cjs.sameSelection(chunkVFSVN5IQ_cjs.textSelection(from), chunkVFSVN5IQ_cjs.textSelection(to));
|
|
1640
1585
|
function targetBeyondSelection(controller, event) {
|
|
1641
1586
|
const range = targetRangeToModel(controller, event);
|
|
1642
1587
|
if (range === null || isEmpty(range)) return null;
|
|
1643
1588
|
const { doc, selection } = controller.editor.state;
|
|
1644
|
-
const selected =
|
|
1645
|
-
const same = selected !== null &&
|
|
1589
|
+
const selected = chunkVFSVN5IQ_cjs.selectionRange(doc, selection);
|
|
1590
|
+
const same = selected !== null && chunkVFSVN5IQ_cjs.sameSelection(chunkVFSVN5IQ_cjs.textSelection(selected.from, selected.to), chunkVFSVN5IQ_cjs.textSelection(range.from, range.to));
|
|
1646
1591
|
return same ? null : range;
|
|
1647
1592
|
}
|
|
1648
1593
|
|
|
@@ -1657,41 +1602,41 @@ var targetOr = (command) => (controller, event) => {
|
|
|
1657
1602
|
};
|
|
1658
1603
|
var leaveToHandlers = () => void 0;
|
|
1659
1604
|
function insertTypedText(controller, event) {
|
|
1660
|
-
const text =
|
|
1605
|
+
const text = event.data ?? event.dataTransfer?.getData("text/plain");
|
|
1661
1606
|
if (!text) return;
|
|
1662
1607
|
const range = targetBeyondSelection(controller, event);
|
|
1663
1608
|
if (range === null) controller.edit(() => controller.editor.insertText(text));
|
|
1664
1609
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1665
1610
|
}
|
|
1666
1611
|
function deleteContentBackward(controller, event) {
|
|
1667
|
-
if (!controller.run(
|
|
1612
|
+
if (!controller.run(chunkVFSVN5IQ_cjs.undoInputRule)) targetOr(chunkVFSVN5IQ_cjs.deleteBackward)(controller, event);
|
|
1668
1613
|
}
|
|
1669
1614
|
function insertReplacementText(controller, event) {
|
|
1670
|
-
const text =
|
|
1615
|
+
const text = event.dataTransfer?.getData("text/plain") || event.data;
|
|
1671
1616
|
if (!text) return;
|
|
1672
1617
|
const range = targetRangeToModel(controller, event);
|
|
1673
|
-
if (range === null) controller.run(
|
|
1618
|
+
if (range === null) controller.run(chunkVFSVN5IQ_cjs.insertText(text, { origin: "input" }));
|
|
1674
1619
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1675
1620
|
}
|
|
1676
1621
|
var actions = {
|
|
1677
1622
|
insertText: insertTypedText,
|
|
1678
1623
|
insertReplacementText,
|
|
1679
1624
|
insertParagraph: (controller) => void controller.edit(() => controller.editor.handleKey(ENTER)),
|
|
1680
|
-
insertLineBreak: run(
|
|
1625
|
+
insertLineBreak: run(chunkVFSVN5IQ_cjs.insertHardBreak),
|
|
1681
1626
|
deleteContentBackward,
|
|
1682
|
-
deleteContentForward: targetOr(
|
|
1683
|
-
deleteWordBackward: targetOr(
|
|
1684
|
-
deleteWordForward: targetOr(
|
|
1685
|
-
deleteSoftLineBackward: targetOr(
|
|
1686
|
-
deleteHardLineBackward: targetOr(
|
|
1687
|
-
deleteSoftLineForward: targetOr(
|
|
1688
|
-
deleteHardLineForward: targetOr(
|
|
1689
|
-
formatBold: run(
|
|
1690
|
-
formatItalic: run(
|
|
1691
|
-
formatUnderline: run(
|
|
1692
|
-
formatStrikeThrough: run(
|
|
1693
|
-
historyUndo: run(
|
|
1694
|
-
historyRedo: run(
|
|
1627
|
+
deleteContentForward: targetOr(chunkVFSVN5IQ_cjs.deleteForward),
|
|
1628
|
+
deleteWordBackward: targetOr(chunkVFSVN5IQ_cjs.deleteWordBackward),
|
|
1629
|
+
deleteWordForward: targetOr(chunkVFSVN5IQ_cjs.deleteWordForward),
|
|
1630
|
+
deleteSoftLineBackward: targetOr(chunkVFSVN5IQ_cjs.deleteToLineStart),
|
|
1631
|
+
deleteHardLineBackward: targetOr(chunkVFSVN5IQ_cjs.deleteToLineStart),
|
|
1632
|
+
deleteSoftLineForward: targetOr(chunkVFSVN5IQ_cjs.deleteToLineEnd),
|
|
1633
|
+
deleteHardLineForward: targetOr(chunkVFSVN5IQ_cjs.deleteToLineEnd),
|
|
1634
|
+
formatBold: run(chunkVFSVN5IQ_cjs.toggleMark("bold")),
|
|
1635
|
+
formatItalic: run(chunkVFSVN5IQ_cjs.toggleMark("italic")),
|
|
1636
|
+
formatUnderline: run(chunkVFSVN5IQ_cjs.toggleMark("underline")),
|
|
1637
|
+
formatStrikeThrough: run(chunkVFSVN5IQ_cjs.toggleMark("strike")),
|
|
1638
|
+
historyUndo: run(chunkVFSVN5IQ_cjs.undo),
|
|
1639
|
+
historyRedo: run(chunkVFSVN5IQ_cjs.redo),
|
|
1695
1640
|
insertTranspose: run(transposeChars),
|
|
1696
1641
|
insertFromPaste: leaveToHandlers,
|
|
1697
1642
|
insertFromDrop: leaveToHandlers,
|
|
@@ -1782,7 +1727,7 @@ function commitEmptyHost(controller) {
|
|
|
1782
1727
|
// src/view/input/composition-snapshot.ts
|
|
1783
1728
|
function composedEnd(controller, block, region) {
|
|
1784
1729
|
const { selection } = controller.editor.state;
|
|
1785
|
-
if (
|
|
1730
|
+
if (selection?.kind !== "text") return void 0;
|
|
1786
1731
|
const ends = [selection.anchor, selection.head];
|
|
1787
1732
|
if (ends.some((pos) => pos.block !== block || pos.region !== region)) return void 0;
|
|
1788
1733
|
return Math.max(...ends.map((pos) => pos.offset));
|
|
@@ -1792,7 +1737,7 @@ function snapshotComposition(controller, block, region) {
|
|
|
1792
1737
|
const element = controller.registry.get(block, region);
|
|
1793
1738
|
const inline = regionInline(editor.state, block, region);
|
|
1794
1739
|
if (element === void 0 || inline === void 0) return null;
|
|
1795
|
-
const text =
|
|
1740
|
+
const text = chunkAIS37SL2_cjs.inlineText(inline);
|
|
1796
1741
|
const end = composedEnd(controller, block, region);
|
|
1797
1742
|
const since = [];
|
|
1798
1743
|
const release = editor.subscribe((_, tr) => void (tr && since.push(tr)));
|
|
@@ -1824,10 +1769,10 @@ var EMPTY_HOST = "empty";
|
|
|
1824
1769
|
function targetAt(controller, node) {
|
|
1825
1770
|
const entry = controller.registry.locate(node);
|
|
1826
1771
|
if (entry !== null) return { block: entry.block, region: entry.region };
|
|
1827
|
-
return node !== null &&
|
|
1772
|
+
return node !== null && controller.emptyHost?.contains(node) ? EMPTY_HOST : null;
|
|
1828
1773
|
}
|
|
1829
1774
|
function elementOf(controller, target) {
|
|
1830
|
-
if (target === EMPTY_HOST) return
|
|
1775
|
+
if (target === EMPTY_HOST) return controller.emptyHost ?? void 0;
|
|
1831
1776
|
return target ? controller.registry.get(target.block, target.region) : void 0;
|
|
1832
1777
|
}
|
|
1833
1778
|
function createCompositionHandlers(controller) {
|
|
@@ -1836,7 +1781,7 @@ function createCompositionHandlers(controller) {
|
|
|
1836
1781
|
let snapshot = null;
|
|
1837
1782
|
let stopWaiting = null;
|
|
1838
1783
|
function settle() {
|
|
1839
|
-
|
|
1784
|
+
stopWaiting?.();
|
|
1840
1785
|
stopWaiting = null;
|
|
1841
1786
|
active = false;
|
|
1842
1787
|
controller.composingKey = null;
|
|
@@ -1845,7 +1790,7 @@ function createCompositionHandlers(controller) {
|
|
|
1845
1790
|
target = null;
|
|
1846
1791
|
snapshot = null;
|
|
1847
1792
|
if (host === EMPTY_HOST) commitEmptyHost(controller);
|
|
1848
|
-
else if (host !== null && !
|
|
1793
|
+
else if (host !== null && !started?.settle()) {
|
|
1849
1794
|
controller.renderHost(host.block, host.region);
|
|
1850
1795
|
controller.syncSelectionToDom();
|
|
1851
1796
|
}
|
|
@@ -1853,17 +1798,17 @@ function createCompositionHandlers(controller) {
|
|
|
1853
1798
|
function waitForInput(element) {
|
|
1854
1799
|
const onInput = () => settle();
|
|
1855
1800
|
const timer = setTimeout(settle, 0);
|
|
1856
|
-
|
|
1801
|
+
element?.addEventListener("input", onInput);
|
|
1857
1802
|
stopWaiting = () => {
|
|
1858
1803
|
clearTimeout(timer);
|
|
1859
|
-
|
|
1804
|
+
element?.removeEventListener("input", onInput);
|
|
1860
1805
|
};
|
|
1861
1806
|
}
|
|
1862
1807
|
return {
|
|
1863
1808
|
start() {
|
|
1864
1809
|
if (stopWaiting !== null) settle();
|
|
1865
|
-
|
|
1866
|
-
target = targetAt(controller,
|
|
1810
|
+
snapshot?.release();
|
|
1811
|
+
target = targetAt(controller, controller.domSelection()?.anchorNode ?? null);
|
|
1867
1812
|
const host = target === EMPTY_HOST ? null : target;
|
|
1868
1813
|
snapshot = host && snapshotComposition(controller, host.block, host.region);
|
|
1869
1814
|
active = true;
|
|
@@ -1875,7 +1820,7 @@ function createCompositionHandlers(controller) {
|
|
|
1875
1820
|
},
|
|
1876
1821
|
release() {
|
|
1877
1822
|
if (stopWaiting !== null) settle();
|
|
1878
|
-
|
|
1823
|
+
snapshot?.release();
|
|
1879
1824
|
snapshot = null;
|
|
1880
1825
|
target = null;
|
|
1881
1826
|
if (active) controller.composingKey = null;
|
|
@@ -1891,7 +1836,7 @@ function createCompositionHandlers(controller) {
|
|
|
1891
1836
|
function domCaretOffset(host) {
|
|
1892
1837
|
const doc = host.ownerDocument;
|
|
1893
1838
|
const selection = doc.getSelection();
|
|
1894
|
-
const node =
|
|
1839
|
+
const node = selection?.focusNode;
|
|
1895
1840
|
if (!selection || !node || !host.contains(node)) return void 0;
|
|
1896
1841
|
const range = doc.createRange();
|
|
1897
1842
|
range.setStart(host, 0);
|
|
@@ -1904,9 +1849,9 @@ function reconcileHost(controller, block, region, caretHint) {
|
|
|
1904
1849
|
const element = controller.registry.get(block, region);
|
|
1905
1850
|
const inline = regionInline(controller.editor.state, block, region);
|
|
1906
1851
|
if (element === void 0 || inline === void 0) return false;
|
|
1907
|
-
const before =
|
|
1852
|
+
const before = chunkAIS37SL2_cjs.inlineText(inline);
|
|
1908
1853
|
const after = readDomText(element);
|
|
1909
|
-
const edit = before === after ? null : textDiff(before, after,
|
|
1854
|
+
const edit = before === after ? null : textDiff(before, after, domCaretOffset(element));
|
|
1910
1855
|
if (edit === null) return false;
|
|
1911
1856
|
const at = (offset) => ({ block, region, offset });
|
|
1912
1857
|
controller.edit(() => {
|
|
@@ -1961,7 +1906,7 @@ function createDomInputFallback(controller) {
|
|
|
1961
1906
|
};
|
|
1962
1907
|
},
|
|
1963
1908
|
drain(host) {
|
|
1964
|
-
|
|
1909
|
+
observers.get(host)?.takeRecords();
|
|
1965
1910
|
},
|
|
1966
1911
|
flush
|
|
1967
1912
|
};
|
|
@@ -1969,33 +1914,33 @@ function createDomInputFallback(controller) {
|
|
|
1969
1914
|
|
|
1970
1915
|
// src/view/navigation/cross-moves.ts
|
|
1971
1916
|
function moveHead(controller, { anchor }, head) {
|
|
1972
|
-
dispatchSelection(controller,
|
|
1917
|
+
dispatchSelection(controller, chunkVFSVN5IQ_cjs.textSelection(anchor, head));
|
|
1973
1918
|
return true;
|
|
1974
1919
|
}
|
|
1975
1920
|
function blockOf(controller, { block }) {
|
|
1976
1921
|
const { doc } = controller.editor.state;
|
|
1977
|
-
return doc.blocks[
|
|
1922
|
+
return doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, block)];
|
|
1978
1923
|
}
|
|
1979
1924
|
function collapseCross(controller, selection, direction) {
|
|
1980
|
-
const { from, to } =
|
|
1981
|
-
dispatchSelection(controller,
|
|
1925
|
+
const { from, to } = chunkVFSVN5IQ_cjs.selectionRange(controller.editor.state.doc, selection);
|
|
1926
|
+
dispatchSelection(controller, chunkVFSVN5IQ_cjs.textSelection(direction < 0 ? from : to));
|
|
1982
1927
|
return true;
|
|
1983
1928
|
}
|
|
1984
1929
|
function crossHeadVertically(controller, selection, direction) {
|
|
1985
1930
|
const { head } = selection;
|
|
1986
1931
|
const edge = neighbourHead(controller, head.block, direction);
|
|
1987
1932
|
if (edge !== null) {
|
|
1988
|
-
const end2 =
|
|
1933
|
+
const end2 = chunkVFSVN5IQ_cjs.regionLength(blockOf(controller, edge), edge.region);
|
|
1989
1934
|
return moveHead(controller, selection, { ...edge, offset: Math.min(head.offset, end2) });
|
|
1990
1935
|
}
|
|
1991
|
-
const end =
|
|
1936
|
+
const end = chunkVFSVN5IQ_cjs.regionLength(blockOf(controller, head), head.region);
|
|
1992
1937
|
return moveHead(controller, selection, { ...head, offset: direction < 0 ? 0 : end });
|
|
1993
1938
|
}
|
|
1994
1939
|
function crossHeadHorizontally(controller, selection, direction) {
|
|
1995
1940
|
const { head } = selection;
|
|
1996
|
-
const text =
|
|
1941
|
+
const text = chunkAIS37SL2_cjs.inlineText(blockOf(controller, head).regions[head.region] ?? []);
|
|
1997
1942
|
if (direction < 0 ? head.offset > 0 : head.offset < text.length) {
|
|
1998
|
-
const offset = direction < 0 ?
|
|
1943
|
+
const offset = direction < 0 ? chunkVFSVN5IQ_cjs.prevGraphemeOffset(text, head.offset) : chunkVFSVN5IQ_cjs.nextGraphemeOffset(text, head.offset);
|
|
1999
1944
|
return moveHead(controller, selection, { ...head, offset });
|
|
2000
1945
|
}
|
|
2001
1946
|
const edge = neighbourHead(controller, head.block, direction);
|
|
@@ -2008,15 +1953,15 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
2008
1953
|
const { editor } = controller;
|
|
2009
1954
|
const { state } = editor;
|
|
2010
1955
|
const { selection, doc } = state;
|
|
2011
|
-
if (
|
|
2012
|
-
if (
|
|
1956
|
+
if (selection?.kind === "node") return !extend && moveToNeighbour(controller, selection.block, direction);
|
|
1957
|
+
if (selection?.kind !== "text") return false;
|
|
2013
1958
|
if (isCrossSelection(selection)) {
|
|
2014
1959
|
const move = extend ? crossHeadHorizontally : collapseCross;
|
|
2015
1960
|
return move(controller, selection, direction);
|
|
2016
1961
|
}
|
|
2017
|
-
if (!extend && !
|
|
1962
|
+
if (!extend && !chunkVFSVN5IQ_cjs.isCollapsed(selection)) return false;
|
|
2018
1963
|
const { head } = selection;
|
|
2019
|
-
const length =
|
|
1964
|
+
const length = chunkVFSVN5IQ_cjs.regionLength(doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, head.block)], head.region);
|
|
2020
1965
|
if (direction < 0 ? head.offset > 0 : head.offset < length) return false;
|
|
2021
1966
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2022
1967
|
if (own2 !== null) {
|
|
@@ -2026,7 +1971,7 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
2026
1971
|
if (!extend) return moveToNeighbour(controller, head.block, direction);
|
|
2027
1972
|
const edge = neighbourHead(controller, head.block, direction);
|
|
2028
1973
|
if (edge === null) return false;
|
|
2029
|
-
dispatchSelection(controller,
|
|
1974
|
+
dispatchSelection(controller, chunkVFSVN5IQ_cjs.textSelection(selection.anchor, edge));
|
|
2030
1975
|
return true;
|
|
2031
1976
|
}
|
|
2032
1977
|
|
|
@@ -2053,7 +1998,7 @@ function caretClientRect(point) {
|
|
|
2053
1998
|
if (node.nodeType === TEXT_NODE3) return textCaretRect(node, offset);
|
|
2054
1999
|
const after = node.childNodes[offset];
|
|
2055
2000
|
const before = node.childNodes[offset - 1];
|
|
2056
|
-
return
|
|
2001
|
+
return (after && besideNode(after, true)) ?? (before && besideNode(before, false)) ?? null;
|
|
2057
2002
|
}
|
|
2058
2003
|
function contentBox(host) {
|
|
2059
2004
|
const box = host.getBoundingClientRect();
|
|
@@ -2070,7 +2015,7 @@ function lineEdgeRect(host, last) {
|
|
|
2070
2015
|
return caretClientRect(map.toDom(last ? map.length : 0, last ? -1 : 1));
|
|
2071
2016
|
}
|
|
2072
2017
|
function onEdgeLine(host, point, last) {
|
|
2073
|
-
if (
|
|
2018
|
+
if (domMapOf(host)?.length === 0) return true;
|
|
2074
2019
|
const caret = caretClientRect(point);
|
|
2075
2020
|
const edge = lineEdgeRect(host, last);
|
|
2076
2021
|
if (!caret || !edge) return false;
|
|
@@ -2124,12 +2069,12 @@ function caretAtGoal(controller, host, at, y) {
|
|
|
2124
2069
|
}
|
|
2125
2070
|
function landAtGoal(controller, block, direction) {
|
|
2126
2071
|
const { schema } = controller.editor.state;
|
|
2127
|
-
const region =
|
|
2072
|
+
const region = chunkVFSVN5IQ_cjs.isTextFlow(schema, block) ? chunkVFSVN5IQ_cjs.primaryRegion(schema, block) : null;
|
|
2128
2073
|
const host = region === null ? void 0 : controller.registry.get(block.id, region);
|
|
2129
2074
|
if (!host || region === null || controller.goalX === null) return null;
|
|
2130
2075
|
const line = lineInView(host, direction < 0);
|
|
2131
2076
|
const pos = line && caretAtGoal(controller, host, { block: block.id, region }, line.top + line.height / 2);
|
|
2132
|
-
return pos ?
|
|
2077
|
+
return pos ? chunkVFSVN5IQ_cjs.textSelection(pos) : null;
|
|
2133
2078
|
}
|
|
2134
2079
|
function moveInHost(controller, host, head, caret, direction) {
|
|
2135
2080
|
const { goalX } = controller;
|
|
@@ -2144,16 +2089,16 @@ function landing(controller, { head }, direction, extend) {
|
|
|
2144
2089
|
const point = posToDom(registry, head);
|
|
2145
2090
|
if (!host || !point) return null;
|
|
2146
2091
|
const caret = caretClientRect(point);
|
|
2147
|
-
controller.goalX ??=
|
|
2092
|
+
controller.goalX ??= caret?.left ?? null;
|
|
2148
2093
|
if (!(direction < 0 ? isOnFirstLine(host, point) : isOnLastLine(host, point))) {
|
|
2149
2094
|
const pos = moveInHost(controller, host, head, caret, direction);
|
|
2150
|
-
return pos &&
|
|
2095
|
+
return pos && chunkVFSVN5IQ_cjs.textSelection(pos);
|
|
2151
2096
|
}
|
|
2152
2097
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2153
2098
|
if (own2 !== null) return own2;
|
|
2154
|
-
const accept = extend ? holdsTextHead(controller) :
|
|
2099
|
+
const accept = extend ? holdsTextHead(controller) : canBeEntered(controller);
|
|
2155
2100
|
const target = neighbourBlock(controller.editor.state.doc, head.block, direction, accept);
|
|
2156
|
-
return target && (
|
|
2101
|
+
return target && (landAtGoal(controller, target, direction) ?? entryEdge(controller, target.id, direction));
|
|
2157
2102
|
}
|
|
2158
2103
|
function moveText(controller, selection, direction, extend) {
|
|
2159
2104
|
const next = landing(controller, selection, direction, extend);
|
|
@@ -2161,21 +2106,21 @@ function moveText(controller, selection, direction, extend) {
|
|
|
2161
2106
|
controller.nativeVerticalMove = true;
|
|
2162
2107
|
return false;
|
|
2163
2108
|
}
|
|
2164
|
-
const moved = extend && next.kind === "text" ?
|
|
2109
|
+
const moved = extend && next.kind === "text" ? chunkVFSVN5IQ_cjs.textSelection(selection.anchor, next.head) : next;
|
|
2165
2110
|
dispatchSelection(controller, moved);
|
|
2166
2111
|
return true;
|
|
2167
2112
|
}
|
|
2168
2113
|
function extendBlocks(controller, { anchor, head }, direction) {
|
|
2169
2114
|
const next = neighbourBlock(controller.editor.state.doc, head, direction);
|
|
2170
2115
|
if (next === null) return false;
|
|
2171
|
-
dispatchSelection(controller,
|
|
2116
|
+
dispatchSelection(controller, chunkVFSVN5IQ_cjs.blockRangeSelection(anchor, next.id));
|
|
2172
2117
|
return true;
|
|
2173
2118
|
}
|
|
2174
2119
|
function moveVertically(controller, direction, extend) {
|
|
2175
2120
|
const { selection } = controller.editor.state;
|
|
2176
|
-
if (
|
|
2177
|
-
if (
|
|
2178
|
-
if (
|
|
2121
|
+
if (selection?.kind === "node") return !extend && moveToNeighbour(controller, selection.block, direction);
|
|
2122
|
+
if (selection?.kind === "blocks") return extend && extendBlocks(controller, selection, direction);
|
|
2123
|
+
if (selection?.kind !== "text") return false;
|
|
2179
2124
|
if (!isCrossSelection(selection)) return moveText(controller, selection, direction, extend);
|
|
2180
2125
|
controller.goalX = null;
|
|
2181
2126
|
return (extend ? crossHeadVertically : collapseCross)(controller, selection, direction);
|
|
@@ -2184,8 +2129,8 @@ function moveVertically(controller, direction, extend) {
|
|
|
2184
2129
|
// src/view/input/flip-block.ts
|
|
2185
2130
|
var isTask = ({ type, attrs }) => type === "MARKDOWN" && attrs.kind === "task";
|
|
2186
2131
|
function flipCommand(block) {
|
|
2187
|
-
if (isTask(block)) return
|
|
2188
|
-
return block.type === "TOGGLE" ?
|
|
2132
|
+
if (isTask(block)) return chunkVFSVN5IQ_cjs.toggleTask;
|
|
2133
|
+
return block.type === "TOGGLE" ? chunkVFSVN5IQ_cjs.setAttrs({ open: block.attrs.open !== true }) : null;
|
|
2189
2134
|
}
|
|
2190
2135
|
var toggleState = (open) => open ? "expanded" : "collapsed";
|
|
2191
2136
|
function stateName(block) {
|
|
@@ -2193,11 +2138,11 @@ function stateName(block) {
|
|
|
2193
2138
|
return toggleState(block.attrs.open === true);
|
|
2194
2139
|
}
|
|
2195
2140
|
function blockHoldingCaret({ doc, selection }) {
|
|
2196
|
-
if (
|
|
2197
|
-
return
|
|
2141
|
+
if (selection?.kind !== "text" || selection.anchor.block !== selection.head.block) return null;
|
|
2142
|
+
return chunkAIS37SL2_cjs.blockById(doc, selection.head.block) ?? null;
|
|
2198
2143
|
}
|
|
2199
2144
|
function flipForReader(controller, block) {
|
|
2200
|
-
if (
|
|
2145
|
+
if (block?.type !== "TOGGLE") return false;
|
|
2201
2146
|
const toggles = readerToggles(controller);
|
|
2202
2147
|
toggles.flip(block);
|
|
2203
2148
|
controller.announce(toggleState(shownOpen(block, toggles.choices)));
|
|
@@ -2209,7 +2154,7 @@ function flipSelectedBlock(controller) {
|
|
|
2209
2154
|
if (controller.readOnly) return flipForReader(controller, block);
|
|
2210
2155
|
const command = block && flipCommand(block);
|
|
2211
2156
|
if (!block || !command || !controller.run(command)) return false;
|
|
2212
|
-
const after =
|
|
2157
|
+
const after = chunkAIS37SL2_cjs.blockById(editor.state.doc, block.id);
|
|
2213
2158
|
if (after) controller.announce(stateName(after));
|
|
2214
2159
|
return true;
|
|
2215
2160
|
}
|
|
@@ -2238,12 +2183,12 @@ function tab(controller, event) {
|
|
|
2238
2183
|
}
|
|
2239
2184
|
function typeOverNode(controller, event) {
|
|
2240
2185
|
const { key } = event;
|
|
2241
|
-
const node =
|
|
2186
|
+
const node = controller.editor.state.selection?.kind === "node";
|
|
2242
2187
|
if (!node || event.ctrlKey || event.metaKey || [...key].length !== 1) return false;
|
|
2243
2188
|
return controller.edit(() => controller.editor.insertText(key));
|
|
2244
2189
|
}
|
|
2245
2190
|
function holdHistoryKeys(controller, event) {
|
|
2246
|
-
const kind =
|
|
2191
|
+
const kind = controller.editor.state.selection?.kind;
|
|
2247
2192
|
if (kind !== "node" && kind !== "blocks") return false;
|
|
2248
2193
|
return Object.hasOwn(ARROWS, event.key) && (event.metaKey || event.ctrlKey || event.altKey);
|
|
2249
2194
|
}
|
|
@@ -2295,12 +2240,12 @@ function attachInput(controller, root) {
|
|
|
2295
2240
|
};
|
|
2296
2241
|
const onInput = (event) => fallback.onInput(event);
|
|
2297
2242
|
const onCompositionStart = (event) => {
|
|
2298
|
-
if (inHost(event) || inEmptyHost(event)) composition.start(
|
|
2243
|
+
if (inHost(event) || inEmptyHost(event)) composition.start();
|
|
2299
2244
|
else if (inSink(event)) sinkComposition.start();
|
|
2300
2245
|
};
|
|
2301
2246
|
const onCompositionEnd = (event) => {
|
|
2302
2247
|
if (inSink(event)) sinkComposition.end();
|
|
2303
|
-
else composition.end(
|
|
2248
|
+
else composition.end();
|
|
2304
2249
|
};
|
|
2305
2250
|
const detachClipboard = attachClipboard(controller, root, catchUp);
|
|
2306
2251
|
const unlisten = listen(root, {
|
|
@@ -2317,7 +2262,7 @@ function attachInput(controller, root) {
|
|
|
2317
2262
|
return {
|
|
2318
2263
|
observe,
|
|
2319
2264
|
unobserve(host) {
|
|
2320
|
-
|
|
2265
|
+
observed.get(host)?.();
|
|
2321
2266
|
observed.delete(host);
|
|
2322
2267
|
},
|
|
2323
2268
|
drain: fallback.drain,
|
|
@@ -2357,10 +2302,10 @@ function watchFocusReturn(root, handlers) {
|
|
|
2357
2302
|
|
|
2358
2303
|
// src/view/controller/selection-sync.ts
|
|
2359
2304
|
var selectionPoints = (selection) => [
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2305
|
+
selection?.anchorNode ?? null,
|
|
2306
|
+
selection?.anchorOffset ?? 0,
|
|
2307
|
+
selection?.focusNode ?? null,
|
|
2308
|
+
selection?.focusOffset ?? 0
|
|
2364
2309
|
];
|
|
2365
2310
|
var samePoints = (a, b) => a.every((point, index) => point === b[index]);
|
|
2366
2311
|
function createSelectionSync(doc, onChange) {
|
|
@@ -2420,17 +2365,17 @@ function bindRoot(controller, root, cross, committed) {
|
|
|
2420
2365
|
function movedSelection(controller, doc, model) {
|
|
2421
2366
|
if (controller.composingKey !== null || controller.dragging || !doc || !ownsFocus(controller, doc)) return null;
|
|
2422
2367
|
const selection = readSelection(controller.registry, doc.getSelection(), (node) => controller.blockAt(node));
|
|
2423
|
-
return selection === null ||
|
|
2368
|
+
return selection === null || chunkVFSVN5IQ_cjs.sameSelection(selection, model) ? null : selection;
|
|
2424
2369
|
}
|
|
2425
2370
|
function writeModelSelection(controller, doc, moved, local) {
|
|
2426
|
-
const domSelection =
|
|
2371
|
+
const domSelection = doc?.getSelection();
|
|
2427
2372
|
if (focusingSink(controller) || controller.composingKey !== null || !doc || !domSelection || !ownsFocus(controller, doc)) {
|
|
2428
2373
|
return;
|
|
2429
2374
|
}
|
|
2430
2375
|
const before = selectionPoints(domSelection);
|
|
2431
2376
|
const { selection } = controller.editor.state;
|
|
2432
2377
|
if (heldBySink(selection) && controller.sink !== null) focusSink(controller);
|
|
2433
|
-
else if (
|
|
2378
|
+
else if (selection?.kind === "blocks") domSelection.removeAllRanges();
|
|
2434
2379
|
else writeSelection(controller.registry, selection, domSelection, (id) => controller.blockElement(id));
|
|
2435
2380
|
controller.nodeReveal.show(selection, local);
|
|
2436
2381
|
if (!samePoints(before, selectionPoints(domSelection))) moved();
|
|
@@ -2438,25 +2383,25 @@ function writeModelSelection(controller, doc, moved, local) {
|
|
|
2438
2383
|
|
|
2439
2384
|
// src/view/controller/view-controller.ts
|
|
2440
2385
|
var runNow = (fn) => fn();
|
|
2441
|
-
var ViewController =
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2386
|
+
var ViewController = class {
|
|
2387
|
+
editor;
|
|
2388
|
+
registry = createHostRegistry((element) => {
|
|
2389
|
+
this.#binding?.input.observe(element);
|
|
2445
2390
|
this.#drawn.syncTabStop();
|
|
2446
2391
|
return () => {
|
|
2447
|
-
|
|
2392
|
+
this.#binding?.input.unobserve(element);
|
|
2448
2393
|
this.#drawn.syncTabStop();
|
|
2449
2394
|
};
|
|
2450
|
-
})
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2395
|
+
});
|
|
2396
|
+
keyInterceptors = /* @__PURE__ */ new Set();
|
|
2397
|
+
nodeReveal = createNodeReveal((id) => this.blockElement(id));
|
|
2398
|
+
announcer = createAnnouncer(() => this.#said);
|
|
2399
|
+
isMac;
|
|
2400
|
+
onFiles;
|
|
2401
|
+
goalX = null;
|
|
2402
|
+
nativeVerticalMove = false;
|
|
2403
|
+
dragging = false;
|
|
2404
|
+
composingKey = null;
|
|
2460
2405
|
#flush;
|
|
2461
2406
|
#hosts;
|
|
2462
2407
|
#drawn = createDrawnElements(this.registry, () => this.editor.state);
|
|
@@ -2471,21 +2416,21 @@ var ViewController = (_class = class {
|
|
|
2471
2416
|
#said;
|
|
2472
2417
|
#detachRoot = null;
|
|
2473
2418
|
#readOnlyState;
|
|
2474
|
-
constructor(options) {
|
|
2419
|
+
constructor(options) {
|
|
2475
2420
|
this.editor = options.editor;
|
|
2476
2421
|
options.editor.subscribe((state, tr) => {
|
|
2477
|
-
if (
|
|
2422
|
+
if (tr?.origin !== "remote") this.#said = state;
|
|
2478
2423
|
});
|
|
2479
|
-
this.#flush =
|
|
2424
|
+
this.#flush = options.flush ?? runNow;
|
|
2480
2425
|
this.onFiles = options.onFiles;
|
|
2481
|
-
this.isMac =
|
|
2426
|
+
this.isMac = options.isMac ?? chunkVFSVN5IQ_cjs.detectMac();
|
|
2482
2427
|
const decorationsOf = (block, region) => this.decorationsFor(block, region);
|
|
2483
|
-
const drain = (element) =>
|
|
2428
|
+
const drain = (element) => this.#binding?.input.drain(element);
|
|
2484
2429
|
this.#hosts = createHostRenderer(options.editor, options.render, decorationsOf, drain);
|
|
2485
|
-
this.#readOnlyState = createReadOnly(this.registry,
|
|
2430
|
+
this.#readOnlyState = createReadOnly(this.registry, options.readOnly ?? false);
|
|
2486
2431
|
}
|
|
2487
2432
|
get root() {
|
|
2488
|
-
return
|
|
2433
|
+
return this.#binding?.root ?? null;
|
|
2489
2434
|
}
|
|
2490
2435
|
get readOnly() {
|
|
2491
2436
|
return this.#readOnlyState.current();
|
|
@@ -2497,10 +2442,10 @@ var ViewController = (_class = class {
|
|
|
2497
2442
|
return this.#drawn.emptyHost;
|
|
2498
2443
|
}
|
|
2499
2444
|
attach(root) {
|
|
2500
|
-
|
|
2445
|
+
this.#detachRoot?.();
|
|
2501
2446
|
const binding = bindRoot(this, root, this.#cross, (_, tr) => {
|
|
2502
|
-
this.#quiet ||=
|
|
2503
|
-
this.#loud ||=
|
|
2447
|
+
this.#quiet ||= tr?.origin === "remote" && tr.docChanged;
|
|
2448
|
+
this.#loud ||= tr?.origin !== "remote";
|
|
2504
2449
|
this.#outside.committed(tr);
|
|
2505
2450
|
this.nodeReveal.follow(this.editor.state.selection);
|
|
2506
2451
|
this.#drawn.syncTabStop();
|
|
@@ -2605,14 +2550,14 @@ var ViewController = (_class = class {
|
|
|
2605
2550
|
const element = this.registry.get(block, region);
|
|
2606
2551
|
const host = element && { block, region, element };
|
|
2607
2552
|
if (!host || this.#isComposing(host) || !this.#hosts.render(host)) return;
|
|
2608
|
-
const inSelection = element.contains(
|
|
2553
|
+
const inSelection = element.contains(this.domSelection()?.focusNode ?? null);
|
|
2609
2554
|
if (inSelection && hasFocus(this, element.ownerDocument)) this.syncSelectionToDom();
|
|
2610
2555
|
}
|
|
2611
2556
|
domSelection() {
|
|
2612
|
-
return
|
|
2557
|
+
return this.#ownerDocument()?.getSelection() ?? null;
|
|
2613
2558
|
}
|
|
2614
2559
|
syncSelectionToDom(local) {
|
|
2615
|
-
writeModelSelection(this, this.#ownerDocument(), () =>
|
|
2560
|
+
writeModelSelection(this, this.#ownerDocument(), () => this.#binding?.selectionSync.suppressNext(), local);
|
|
2616
2561
|
}
|
|
2617
2562
|
// A pointer drag across hosts sets the model selection itself, while the browser keeps extending its own. Leaving
|
|
2618
2563
|
// cross mode re-renders the hosts that drew it as decorations, which can remove the node holding the caret, so the
|
|
@@ -2631,7 +2576,7 @@ var ViewController = (_class = class {
|
|
|
2631
2576
|
focus(target) {
|
|
2632
2577
|
const { editor } = this;
|
|
2633
2578
|
const selection = focusTarget(editor.state, target);
|
|
2634
|
-
if (selection !== null && !
|
|
2579
|
+
if (selection !== null && !chunkVFSVN5IQ_cjs.sameSelection(selection, editor.state.selection)) dispatchSelection(this, selection);
|
|
2635
2580
|
this.#takeFocus();
|
|
2636
2581
|
this.syncSelectionToDom();
|
|
2637
2582
|
}
|
|
@@ -2642,7 +2587,7 @@ var ViewController = (_class = class {
|
|
|
2642
2587
|
return this.#readOnlyState.subscribe(listener);
|
|
2643
2588
|
}
|
|
2644
2589
|
destroy() {
|
|
2645
|
-
|
|
2590
|
+
this.#detachRoot?.();
|
|
2646
2591
|
}
|
|
2647
2592
|
#selectFromDom(selection) {
|
|
2648
2593
|
const { editor } = this;
|
|
@@ -2652,7 +2597,7 @@ var ViewController = (_class = class {
|
|
|
2652
2597
|
return this.composingKey !== null && hostKey(host.block, host.region) === this.composingKey;
|
|
2653
2598
|
}
|
|
2654
2599
|
#ownerDocument() {
|
|
2655
|
-
return
|
|
2600
|
+
return (this.#binding?.root ?? this.registry.all().next().value?.element)?.ownerDocument ?? null;
|
|
2656
2601
|
}
|
|
2657
2602
|
// React replaces a host whose block changes kind, which drops focus, and Firefox does not move focus into another
|
|
2658
2603
|
// host when a script selects inside it.
|
|
@@ -2665,42 +2610,32 @@ var ViewController = (_class = class {
|
|
|
2665
2610
|
if (element === this.sink) focusSink(this);
|
|
2666
2611
|
else element.focus({ preventScroll });
|
|
2667
2612
|
}
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
// src/view/react/editor-context.ts
|
|
2671
|
-
|
|
2672
|
-
var QuoinEditorContext = _react.createContext.call(void 0, null);
|
|
2613
|
+
};
|
|
2614
|
+
var QuoinEditorContext = react.createContext(null);
|
|
2673
2615
|
function useViewController() {
|
|
2674
|
-
const controller =
|
|
2616
|
+
const controller = react.useContext(QuoinEditorContext);
|
|
2675
2617
|
if (controller === null) throw new Error("useViewController must be called inside an EditorView");
|
|
2676
2618
|
return controller;
|
|
2677
2619
|
}
|
|
2678
|
-
|
|
2679
|
-
// src/view/react/use-quoin-editor.ts
|
|
2680
|
-
|
|
2681
|
-
var _reactdom = require('react-dom');
|
|
2682
|
-
|
|
2683
|
-
// src/view/react/use-isomorphic-layout-effect.ts
|
|
2684
|
-
|
|
2685
|
-
var useIsomorphicLayoutEffect = typeof document === "undefined" ? _react.useEffect : _react.useLayoutEffect;
|
|
2620
|
+
var useIsomorphicLayoutEffect = typeof document === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
2686
2621
|
|
|
2687
2622
|
// src/view/react/use-quoin-editor.ts
|
|
2688
2623
|
function useQuoinEditor(options) {
|
|
2689
2624
|
const { blocks, readOnly = false } = options;
|
|
2690
|
-
const callbacks =
|
|
2691
|
-
const [controller] =
|
|
2692
|
-
const editor =
|
|
2625
|
+
const callbacks = react.useRef(options);
|
|
2626
|
+
const [controller] = react.useState(() => {
|
|
2627
|
+
const editor = chunkVFSVN5IQ_cjs.createEditor({
|
|
2693
2628
|
blocks,
|
|
2694
2629
|
extensions: options.extensions,
|
|
2695
2630
|
onChange: (next) => callbacks.current.onChange(next),
|
|
2696
|
-
onTransaction: (tr, state) =>
|
|
2631
|
+
onTransaction: (tr, state) => callbacks.current.onTransaction?.(tr, state)
|
|
2697
2632
|
});
|
|
2698
2633
|
return new ViewController({
|
|
2699
2634
|
editor,
|
|
2700
|
-
flush:
|
|
2635
|
+
flush: reactDom.flushSync,
|
|
2701
2636
|
render: options.render,
|
|
2702
2637
|
readOnly,
|
|
2703
|
-
onFiles: (files, at) =>
|
|
2638
|
+
onFiles: (files, at) => callbacks.current.onFiles?.(files, at)
|
|
2704
2639
|
});
|
|
2705
2640
|
});
|
|
2706
2641
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -2712,36 +2647,27 @@ function useQuoinEditor(options) {
|
|
|
2712
2647
|
useIsomorphicLayoutEffect(() => {
|
|
2713
2648
|
controller.setReadOnly(readOnly);
|
|
2714
2649
|
}, [controller, readOnly]);
|
|
2715
|
-
|
|
2650
|
+
react.useEffect(() => () => controller.destroy(), [controller]);
|
|
2716
2651
|
return controller;
|
|
2717
2652
|
}
|
|
2718
|
-
|
|
2719
|
-
// src/view/react/SelectionSink.tsx
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
// src/view/react/use-read-only.ts
|
|
2723
|
-
|
|
2724
2653
|
function useReadOnly(controller) {
|
|
2725
|
-
const subscribe =
|
|
2726
|
-
const read =
|
|
2727
|
-
return
|
|
2654
|
+
const subscribe = react.useCallback((notify) => controller.subscribeReadOnly(notify), [controller]);
|
|
2655
|
+
const read = react.useCallback(() => controller.readOnly, [controller]);
|
|
2656
|
+
return react.useSyncExternalStore(subscribe, read, read);
|
|
2728
2657
|
}
|
|
2729
|
-
|
|
2730
|
-
// src/view/react/SelectionSink.tsx
|
|
2731
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
2732
2658
|
function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
2733
2659
|
const controller = useViewController();
|
|
2734
|
-
const ref =
|
|
2660
|
+
const ref = react.useRef(null);
|
|
2735
2661
|
const readOnly = useReadOnly(controller);
|
|
2736
2662
|
const name = useEditorState(
|
|
2737
2663
|
controller,
|
|
2738
|
-
|
|
2664
|
+
react.useCallback((state) => selectedBlockName(state, blockLabel), [blockLabel])
|
|
2739
2665
|
);
|
|
2740
2666
|
useIsomorphicLayoutEffect(() => {
|
|
2741
2667
|
const sink = ref.current;
|
|
2742
2668
|
return sink ? controller.registerSink(sink) : void 0;
|
|
2743
2669
|
}, [controller]);
|
|
2744
|
-
return /* @__PURE__ */
|
|
2670
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2745
2671
|
"div",
|
|
2746
2672
|
{
|
|
2747
2673
|
ref,
|
|
@@ -2761,35 +2687,26 @@ function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
|
2761
2687
|
}
|
|
2762
2688
|
);
|
|
2763
2689
|
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
// src/view/react/block-placeholder.ts
|
|
2769
|
-
|
|
2770
|
-
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${_chunk4SLJNZSMcjs.headingLevel.call(void 0, attrs.level)}` : void 0;
|
|
2771
|
-
var BlockPlaceholderContext = _react.createContext.call(void 0, headingPlaceholder);
|
|
2690
|
+
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${chunkAIS37SL2_cjs.headingLevel(attrs.level)}` : void 0;
|
|
2691
|
+
var BlockPlaceholderContext = react.createContext(headingPlaceholder);
|
|
2772
2692
|
function regionPlaceholder(state, blockId, region, placeholderOf) {
|
|
2773
|
-
const block =
|
|
2774
|
-
return block !== void 0 &&
|
|
2693
|
+
const block = chunkAIS37SL2_cjs.blockById(state.doc, blockId);
|
|
2694
|
+
return block !== void 0 && chunkVFSVN5IQ_cjs.primaryRegion(state.schema, block) === region ? placeholderOf(state, block) : void 0;
|
|
2775
2695
|
}
|
|
2776
|
-
|
|
2777
|
-
// src/view/react/EditableRegion.tsx
|
|
2778
|
-
|
|
2779
2696
|
var samePainted = (a, b) => a.inline === b.inline && a.placeholder === b.placeholder && sameDecorations(a.decorations, b.decorations);
|
|
2780
2697
|
function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
2781
2698
|
const controller = useViewController();
|
|
2782
|
-
const placeholderOf =
|
|
2783
|
-
const ref =
|
|
2699
|
+
const placeholderOf = react.useContext(BlockPlaceholderContext);
|
|
2700
|
+
const ref = react.useRef(null);
|
|
2784
2701
|
const readOnly = useReadOnly(controller);
|
|
2785
|
-
const select =
|
|
2702
|
+
const select = react.useCallback(
|
|
2786
2703
|
(state) => {
|
|
2787
2704
|
const inline2 = regionInline(state, block, region);
|
|
2788
|
-
const empty = inline2 === void 0 ||
|
|
2705
|
+
const empty = inline2 === void 0 || chunkAIS37SL2_cjs.inlineLength(inline2) === 0;
|
|
2789
2706
|
return {
|
|
2790
2707
|
inline: inline2,
|
|
2791
2708
|
decorations: controller.decorationsFor(block, region),
|
|
2792
|
-
placeholder: empty ?
|
|
2709
|
+
placeholder: empty ? placeholder ?? regionPlaceholder(state, block, region, placeholderOf) : void 0
|
|
2793
2710
|
};
|
|
2794
2711
|
},
|
|
2795
2712
|
[controller, block, region, placeholder, placeholderOf]
|
|
@@ -2802,7 +2719,7 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2802
2719
|
useIsomorphicLayoutEffect(() => {
|
|
2803
2720
|
controller.renderHost(block, region);
|
|
2804
2721
|
}, [controller, block, region, inline, decorations]);
|
|
2805
|
-
return /* @__PURE__ */
|
|
2722
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2806
2723
|
"div",
|
|
2807
2724
|
{
|
|
2808
2725
|
ref,
|
|
@@ -2822,44 +2739,35 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2822
2739
|
}
|
|
2823
2740
|
);
|
|
2824
2741
|
}
|
|
2825
|
-
|
|
2826
|
-
// src/view/react/default-renderers.tsx
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
// src/view/react/callout-block.tsx
|
|
2830
|
-
|
|
2831
2742
|
var CalloutBlock = ({ block }) => {
|
|
2832
2743
|
const tone = typeof block.attrs.tone === "string" && block.attrs.tone !== "" ? block.attrs.tone : "info";
|
|
2833
|
-
return /* @__PURE__ */
|
|
2744
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-callout", "data-tone": tone, children: /* @__PURE__ */ jsxRuntime.jsx(EditableRegion, { block: block.id, region: "body", label: `Callout, ${tone}` }) });
|
|
2834
2745
|
};
|
|
2835
2746
|
|
|
2836
2747
|
// src/view/react/block-command.ts
|
|
2837
2748
|
function onBlock(id, command) {
|
|
2838
2749
|
return (state, dispatch) => {
|
|
2839
|
-
const { ok, tr } =
|
|
2750
|
+
const { ok, tr } = chunkVFSVN5IQ_cjs.runCommands(state, [chunkVFSVN5IQ_cjs.setSelection(chunkVFSVN5IQ_cjs.blockRangeSelection(id)), command]);
|
|
2840
2751
|
if (!ok || tr === null) return false;
|
|
2841
|
-
|
|
2752
|
+
dispatch?.(tr.setSelection(state.selection));
|
|
2842
2753
|
return true;
|
|
2843
2754
|
};
|
|
2844
2755
|
}
|
|
2845
2756
|
|
|
2846
2757
|
// src/view/react/prevent-mouse-focus.ts
|
|
2847
2758
|
var keepFocus = (event) => event.preventDefault();
|
|
2848
|
-
|
|
2849
|
-
// src/view/react/TaskCheckbox.tsx
|
|
2850
|
-
|
|
2851
2759
|
function TaskCheckbox({ block, controller, label, labelledBy }) {
|
|
2852
2760
|
const checked = block.attrs.checked === true;
|
|
2853
2761
|
const flip2 = flipCommand(block);
|
|
2854
2762
|
const readOnly = useReadOnly(controller);
|
|
2855
|
-
return /* @__PURE__ */
|
|
2763
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2856
2764
|
"button",
|
|
2857
2765
|
{
|
|
2858
2766
|
type: "button",
|
|
2859
2767
|
role: "checkbox",
|
|
2860
2768
|
"aria-checked": checked,
|
|
2861
2769
|
"aria-readonly": readOnly ? "true" : void 0,
|
|
2862
|
-
"aria-label":
|
|
2770
|
+
"aria-label": chunkAIS37SL2_cjs.firstNamed(label, "Task"),
|
|
2863
2771
|
"aria-labelledby": labelledBy,
|
|
2864
2772
|
className: "quoin-task-box",
|
|
2865
2773
|
contentEditable: false,
|
|
@@ -2868,7 +2776,7 @@ function TaskCheckbox({ block, controller, label, labelledBy }) {
|
|
|
2868
2776
|
onClick: () => {
|
|
2869
2777
|
if (flip2 && !controller.readOnly) controller.run(onBlock(block.id, flip2));
|
|
2870
2778
|
},
|
|
2871
|
-
children: checked ? /* @__PURE__ */
|
|
2779
|
+
children: checked ? /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 8.5l3 3 6-7", fill: "none", stroke: "currentColor", strokeWidth: "2" }) }) : null
|
|
2872
2780
|
}
|
|
2873
2781
|
);
|
|
2874
2782
|
}
|
|
@@ -2890,7 +2798,7 @@ function numberDoc(doc) {
|
|
|
2890
2798
|
numbers[index] = run2.next++;
|
|
2891
2799
|
return;
|
|
2892
2800
|
}
|
|
2893
|
-
const start =
|
|
2801
|
+
const start = chunkAIS37SL2_cjs.orderedStart(block.attrs.start);
|
|
2894
2802
|
numbers[index] = start;
|
|
2895
2803
|
runs.push({ indent: block.indent, next: start + 1 });
|
|
2896
2804
|
});
|
|
@@ -2903,7 +2811,7 @@ function orderedNumber(doc, index) {
|
|
|
2903
2811
|
numbers = numberDoc(doc);
|
|
2904
2812
|
cache.set(doc, numbers);
|
|
2905
2813
|
}
|
|
2906
|
-
return
|
|
2814
|
+
return numbers[index] ?? 1;
|
|
2907
2815
|
}
|
|
2908
2816
|
|
|
2909
2817
|
// src/view/react/use-ordered-number.ts
|
|
@@ -2913,63 +2821,54 @@ function useOrderedNumber(controller, blockId) {
|
|
|
2913
2821
|
return index === void 0 ? 1 : orderedNumber(doc, index);
|
|
2914
2822
|
});
|
|
2915
2823
|
}
|
|
2916
|
-
|
|
2917
|
-
// src/view/react/markdown-block.tsx
|
|
2918
|
-
|
|
2919
2824
|
var REGION = "text";
|
|
2920
2825
|
function TextRegion({ block, label }) {
|
|
2921
|
-
return /* @__PURE__ */
|
|
2826
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EditableRegion, { block: block.id, region: REGION, label });
|
|
2922
2827
|
}
|
|
2923
2828
|
function NumberedItem({ block, controller }) {
|
|
2924
2829
|
const number = useOrderedNumber(controller, block.id);
|
|
2925
|
-
return /* @__PURE__ */
|
|
2926
|
-
/* @__PURE__ */
|
|
2927
|
-
/* @__PURE__ */
|
|
2830
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "ordered", children: [
|
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-marker", "aria-hidden": "true", children: `${number}.` }),
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: `Numbered list item ${number}` })
|
|
2928
2833
|
] });
|
|
2929
2834
|
}
|
|
2930
2835
|
var MarkdownBlock = (props) => {
|
|
2931
2836
|
const { block } = props;
|
|
2932
2837
|
switch (block.attrs.kind) {
|
|
2933
2838
|
case "heading": {
|
|
2934
|
-
const level =
|
|
2935
|
-
return /* @__PURE__ */
|
|
2839
|
+
const level = chunkAIS37SL2_cjs.headingLevel(block.attrs.level);
|
|
2840
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: "quoin-heading", children: /* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: `Heading ${level}` }) });
|
|
2936
2841
|
}
|
|
2937
2842
|
case "bullet":
|
|
2938
|
-
return /* @__PURE__ */
|
|
2939
|
-
/* @__PURE__ */
|
|
2940
|
-
/* @__PURE__ */
|
|
2843
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "bullet", children: [
|
|
2844
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-marker", "aria-hidden": "true", children: "\u2022" }),
|
|
2845
|
+
/* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: "Bullet list item" })
|
|
2941
2846
|
] });
|
|
2942
2847
|
case "ordered":
|
|
2943
|
-
return /* @__PURE__ */
|
|
2848
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NumberedItem, { ...props });
|
|
2944
2849
|
case "task":
|
|
2945
|
-
return /* @__PURE__ */
|
|
2946
|
-
/* @__PURE__ */
|
|
2947
|
-
/* @__PURE__ */
|
|
2850
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-task", "data-checked": block.attrs.checked === true, children: [
|
|
2851
|
+
/* @__PURE__ */ jsxRuntime.jsx(TaskCheckbox, { block, controller: props.controller }),
|
|
2852
|
+
/* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: "Task" })
|
|
2948
2853
|
] });
|
|
2949
2854
|
case "quote":
|
|
2950
|
-
return /* @__PURE__ */
|
|
2855
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-quote", children: /* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: "Quote" }) });
|
|
2951
2856
|
default:
|
|
2952
|
-
return /* @__PURE__ */
|
|
2857
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: "Paragraph" });
|
|
2953
2858
|
}
|
|
2954
2859
|
};
|
|
2955
|
-
|
|
2956
|
-
// src/view/react/use-reader-choices.ts
|
|
2957
|
-
|
|
2958
2860
|
function useReaderChoices(controller) {
|
|
2959
2861
|
const store = readerToggles(controller);
|
|
2960
|
-
return
|
|
2862
|
+
return react.useSyncExternalStore(store.subscribe, () => store.choices, () => store.choices);
|
|
2961
2863
|
}
|
|
2962
2864
|
function useToggleOpen(controller, block) {
|
|
2963
2865
|
return shownOpen(block, useReaderChoices(controller));
|
|
2964
2866
|
}
|
|
2965
|
-
|
|
2966
|
-
// src/view/react/ToggleChevron.tsx
|
|
2967
|
-
|
|
2968
2867
|
function ToggleChevron({ block, controller, label = "Toggle", controls }) {
|
|
2969
2868
|
const open = useToggleOpen(controller, block);
|
|
2970
2869
|
const readOnly = useReadOnly(controller);
|
|
2971
2870
|
const flip2 = flipCommand(block);
|
|
2972
|
-
return /* @__PURE__ */
|
|
2871
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2973
2872
|
"button",
|
|
2974
2873
|
{
|
|
2975
2874
|
type: "button",
|
|
@@ -2984,48 +2883,56 @@ function ToggleChevron({ block, controller, label = "Toggle", controls }) {
|
|
|
2984
2883
|
if (controller.readOnly) readerToggles(controller).flip(block);
|
|
2985
2884
|
else if (flip2) controller.run(onBlock(block.id, flip2));
|
|
2986
2885
|
},
|
|
2987
|
-
children: /* @__PURE__ */
|
|
2886
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 3.5l4.5 4.5L6 12.5", fill: "none", stroke: "currentColor", strokeWidth: "2" }) })
|
|
2988
2887
|
}
|
|
2989
2888
|
);
|
|
2990
2889
|
}
|
|
2991
|
-
|
|
2992
|
-
// src/view/react/toggle-block.tsx
|
|
2993
|
-
|
|
2994
2890
|
var ToggleBlock = ({ block, controller }) => {
|
|
2995
2891
|
const open = useToggleOpen(controller, block);
|
|
2996
|
-
return /* @__PURE__ */
|
|
2997
|
-
/* @__PURE__ */
|
|
2998
|
-
/* @__PURE__ */
|
|
2892
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-toggle", "data-open": open, children: [
|
|
2893
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToggleChevron, { block, controller }),
|
|
2894
|
+
/* @__PURE__ */ jsxRuntime.jsx(EditableRegion, { block: block.id, region: "text", label: "Toggle" })
|
|
2999
2895
|
] });
|
|
3000
2896
|
};
|
|
3001
|
-
|
|
3002
|
-
// src/view/react/unsupported-block-label.ts
|
|
3003
|
-
|
|
3004
2897
|
var UNSUPPORTED_BLOCK = "Unsupported block";
|
|
3005
|
-
var UnsupportedBlockLabel =
|
|
3006
|
-
|
|
3007
|
-
// src/view/react/default-renderers.tsx
|
|
3008
|
-
|
|
2898
|
+
var UnsupportedBlockLabel = react.createContext(UNSUPPORTED_BLOCK);
|
|
3009
2899
|
var defaultRenderers = {
|
|
3010
2900
|
MARKDOWN: MarkdownBlock,
|
|
3011
2901
|
CALLOUT: CalloutBlock,
|
|
3012
2902
|
TOGGLE: ToggleBlock
|
|
3013
2903
|
};
|
|
3014
2904
|
var VoidBlockFallback = ({ block }) => {
|
|
3015
|
-
const label =
|
|
3016
|
-
if (block.type === "DIVIDER") return /* @__PURE__ */
|
|
3017
|
-
return /* @__PURE__ */
|
|
2905
|
+
const label = react.useContext(UnsupportedBlockLabel);
|
|
2906
|
+
if (block.type === "DIVIDER") return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-void", contentEditable: false, role: "separator" });
|
|
2907
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-void", contentEditable: false, role: "group", "aria-label": label, children: label });
|
|
3018
2908
|
};
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
2909
|
+
var BLOCK_ERROR = "Block could not be drawn";
|
|
2910
|
+
var BlockErrorContext = react.createContext({ label: BLOCK_ERROR });
|
|
2911
|
+
var Boundary = class extends react.Component {
|
|
2912
|
+
state = { block: this.props.block, failed: false };
|
|
2913
|
+
static getDerivedStateFromError() {
|
|
2914
|
+
return { failed: true };
|
|
2915
|
+
}
|
|
2916
|
+
static getDerivedStateFromProps(props, state) {
|
|
2917
|
+
return props.block === state.block ? null : { block: props.block, failed: false };
|
|
2918
|
+
}
|
|
2919
|
+
componentDidCatch(error) {
|
|
2920
|
+
this.props.report?.(error instanceof Error ? error : new Error(String(error)));
|
|
2921
|
+
}
|
|
2922
|
+
render() {
|
|
2923
|
+
if (!this.state.failed) return this.props.children;
|
|
2924
|
+
const { label } = this.props;
|
|
2925
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-void", contentEditable: false, role: "group", "aria-label": label, children: label });
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
function BlockErrorBoundary({ block, children }) {
|
|
2929
|
+
const { label, report } = react.useContext(BlockErrorContext);
|
|
2930
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Boundary, { block, label, report, children });
|
|
2931
|
+
}
|
|
2932
|
+
var BlockDomIdScope = react.createContext("quoin");
|
|
3026
2933
|
function useBlockDomId() {
|
|
3027
|
-
const scope =
|
|
3028
|
-
return
|
|
2934
|
+
const scope = react.useContext(BlockDomIdScope);
|
|
2935
|
+
return react.useCallback((block) => `${scope}-${encodeURIComponent(block)}`, [scope]);
|
|
3029
2936
|
}
|
|
3030
2937
|
function useRegionDomId(block, region) {
|
|
3031
2938
|
return `${useBlockDomId()(block)}/${encodeURIComponent(region)}`;
|
|
@@ -3042,7 +2949,7 @@ function covers(state, id, index) {
|
|
|
3042
2949
|
if (selection === null) return false;
|
|
3043
2950
|
if (selection.kind === "node") return selection.block === id;
|
|
3044
2951
|
if (selection.kind === "blocks") return within(state, index, [selection.anchor, selection.head]);
|
|
3045
|
-
if (!isCrossSelection(selection) ||
|
|
2952
|
+
if (!isCrossSelection(selection) || chunkVFSVN5IQ_cjs.isTextFlow(schema, doc.blocks[index])) return false;
|
|
3046
2953
|
return within(state, index, [selection.anchor.block, selection.head.block]);
|
|
3047
2954
|
}
|
|
3048
2955
|
function blockStatus(state, id, choices = NO_CHOICES) {
|
|
@@ -3051,16 +2958,18 @@ function blockStatus(state, id, choices = NO_CHOICES) {
|
|
|
3051
2958
|
if (isHiddenAt(state.doc, index, choices)) return "hidden";
|
|
3052
2959
|
return covers(state, id, index) ? "selected" : "plain";
|
|
3053
2960
|
}
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
2961
|
+
function safeAttrs(decorations) {
|
|
2962
|
+
const attrs = Object.assign({}, ...decorations.map((decoration) => decoration.attrs));
|
|
2963
|
+
for (const name of Object.keys(attrs)) if (!/^(data|aria)-/.test(name)) delete attrs[name];
|
|
2964
|
+
return attrs;
|
|
2965
|
+
}
|
|
3057
2966
|
function rendererFor(renderers, type) {
|
|
3058
2967
|
for (const table of [renderers, defaultRenderers]) if (Object.hasOwn(table, type)) return table[type];
|
|
3059
2968
|
return VoidBlockFallback;
|
|
3060
2969
|
}
|
|
3061
|
-
var BlockShell =
|
|
2970
|
+
var BlockShell = react.memo(function BlockShell2({ block, renderers }) {
|
|
3062
2971
|
const controller = useViewController();
|
|
3063
|
-
const ref =
|
|
2972
|
+
const ref = react.useRef(null);
|
|
3064
2973
|
const domId = useBlockDomId();
|
|
3065
2974
|
const choices = useReaderChoices(controller);
|
|
3066
2975
|
const status = useEditorState(controller, (state) => blockStatus(state, block.id, choices));
|
|
@@ -3073,37 +2982,30 @@ var BlockShell = _react.memo.call(void 0, function BlockShell2({ block, renderer
|
|
|
3073
2982
|
if (hidden) return null;
|
|
3074
2983
|
const Renderer = rendererFor(renderers, block.type);
|
|
3075
2984
|
const { kind, color, background, align } = block.attrs;
|
|
3076
|
-
return /* @__PURE__ */
|
|
2985
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3077
2986
|
"div",
|
|
3078
2987
|
{
|
|
3079
|
-
...
|
|
2988
|
+
...safeAttrs(decorations),
|
|
3080
2989
|
ref,
|
|
3081
2990
|
id: domId(block.id),
|
|
3082
2991
|
"data-quoin-block": "",
|
|
3083
2992
|
"data-block-id": block.id,
|
|
3084
2993
|
"data-type": block.type,
|
|
3085
|
-
"data-kind":
|
|
2994
|
+
"data-kind": chunkAIS37SL2_cjs.optionalString(kind),
|
|
3086
2995
|
"data-indent": block.indent,
|
|
3087
|
-
"data-color":
|
|
3088
|
-
"data-bg":
|
|
3089
|
-
"data-align":
|
|
2996
|
+
"data-color": chunkAIS37SL2_cjs.paletteOrUndefined(color),
|
|
2997
|
+
"data-bg": chunkAIS37SL2_cjs.paletteOrUndefined(background),
|
|
2998
|
+
"data-align": chunkAIS37SL2_cjs.alignOrUndefined(align),
|
|
3090
2999
|
style: { "--quoin-indent": block.indent },
|
|
3091
3000
|
tabIndex: -1,
|
|
3092
3001
|
"data-selected": status === "selected" ? "true" : void 0,
|
|
3093
|
-
children: /* @__PURE__ */
|
|
3002
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(BlockErrorBoundary, { block, children: /* @__PURE__ */ jsxRuntime.jsx(Renderer, { block, controller }) })
|
|
3094
3003
|
}
|
|
3095
3004
|
);
|
|
3096
3005
|
});
|
|
3097
|
-
|
|
3098
|
-
// src/view/react/EditorView.tsx
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
// src/view/react/EmptyDocumentHost.tsx
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
3006
|
function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
3105
3007
|
const controller = useViewController();
|
|
3106
|
-
const ref =
|
|
3008
|
+
const ref = react.useRef(null);
|
|
3107
3009
|
const readOnly = useReadOnly(controller);
|
|
3108
3010
|
useIsomorphicLayoutEffect(() => {
|
|
3109
3011
|
const host = ref.current;
|
|
@@ -3111,7 +3013,7 @@ function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
|
3111
3013
|
renderInline(host, [], []);
|
|
3112
3014
|
return controller.registerEmptyHost(host);
|
|
3113
3015
|
}, [controller]);
|
|
3114
|
-
return /* @__PURE__ */
|
|
3016
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3115
3017
|
"div",
|
|
3116
3018
|
{
|
|
3117
3019
|
ref,
|
|
@@ -3126,7 +3028,7 @@ function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
|
3126
3028
|
"data-placeholder": readOnly ? void 0 : placeholder,
|
|
3127
3029
|
"aria-placeholder": readOnly ? void 0 : placeholder,
|
|
3128
3030
|
spellCheck: true,
|
|
3129
|
-
onClick: () =>
|
|
3031
|
+
onClick: () => ref.current?.focus()
|
|
3130
3032
|
}
|
|
3131
3033
|
);
|
|
3132
3034
|
}
|
|
@@ -3134,9 +3036,6 @@ function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
|
3134
3036
|
// src/view/react/focus-owners.ts
|
|
3135
3037
|
var focusOwners = /* @__PURE__ */ new WeakMap();
|
|
3136
3038
|
|
|
3137
|
-
// src/view/react/LiveRegion.tsx
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
3039
|
// src/view/selection/selection-announcement.ts
|
|
3141
3040
|
var SILENCE = { key: "", message: "" };
|
|
3142
3041
|
function selectionAnnouncement({ doc, selection }, blocksSelected) {
|
|
@@ -3150,9 +3049,6 @@ function selectionAnnouncement({ doc, selection }, blocksSelected) {
|
|
|
3150
3049
|
const count = drawnBlockCount(doc, Math.min(first, last), Math.max(first, last) + 1);
|
|
3151
3050
|
return { key: `${selection.kind}:${anchor}:${head}`, message: blocksSelected(count) };
|
|
3152
3051
|
}
|
|
3153
|
-
|
|
3154
|
-
// src/view/react/LiveRegion.tsx
|
|
3155
|
-
|
|
3156
3052
|
function heardNow({ editor, announcer }, blocksSelected) {
|
|
3157
3053
|
const spoken = announcer.current();
|
|
3158
3054
|
if (spoken !== null) return { key: `said:${spoken.serial}`, message: spoken.message };
|
|
@@ -3160,7 +3056,7 @@ function heardNow({ editor, announcer }, blocksSelected) {
|
|
|
3160
3056
|
}
|
|
3161
3057
|
function LiveRegion({ blocksSelected }) {
|
|
3162
3058
|
const controller = useViewController();
|
|
3163
|
-
const subscribe =
|
|
3059
|
+
const subscribe = react.useCallback(
|
|
3164
3060
|
(notify) => {
|
|
3165
3061
|
const stopState = controller.editor.subscribe(() => notify());
|
|
3166
3062
|
const stopSpoken = controller.announcer.subscribe(notify);
|
|
@@ -3171,7 +3067,7 @@ function LiveRegion({ blocksSelected }) {
|
|
|
3171
3067
|
},
|
|
3172
3068
|
[controller]
|
|
3173
3069
|
);
|
|
3174
|
-
const read =
|
|
3070
|
+
const read = react.useMemo(() => {
|
|
3175
3071
|
let last = SILENCE;
|
|
3176
3072
|
return () => {
|
|
3177
3073
|
const next = heardNow(controller, blocksSelected);
|
|
@@ -3179,8 +3075,8 @@ function LiveRegion({ blocksSelected }) {
|
|
|
3179
3075
|
return last;
|
|
3180
3076
|
};
|
|
3181
3077
|
}, [controller, blocksSelected]);
|
|
3182
|
-
const { key, message } =
|
|
3183
|
-
return /* @__PURE__ */
|
|
3078
|
+
const { key, message } = react.useSyncExternalStore(subscribe, read, read);
|
|
3079
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-visually-hidden", role: "status", "aria-live": "polite", "aria-atomic": "true", children: message !== "" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: message }, key) });
|
|
3184
3080
|
}
|
|
3185
3081
|
|
|
3186
3082
|
// src/view/react/SelectionWriter.tsx
|
|
@@ -3190,23 +3086,16 @@ function SelectionWriter() {
|
|
|
3190
3086
|
useIsomorphicLayoutEffect(() => controller.afterRender(), [controller, state]);
|
|
3191
3087
|
return null;
|
|
3192
3088
|
}
|
|
3193
|
-
|
|
3194
|
-
// src/view/react/use-block-elements.tsx
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
3089
|
function useBlockElements(blocks, renderers) {
|
|
3198
|
-
const [made] =
|
|
3090
|
+
const [made] = react.useState(() => /* @__PURE__ */ new WeakMap());
|
|
3199
3091
|
return blocks.map((block) => {
|
|
3200
3092
|
const known2 = made.get(block);
|
|
3201
|
-
if (
|
|
3202
|
-
const element = /* @__PURE__ */
|
|
3093
|
+
if (known2?.renderers === renderers) return known2.element;
|
|
3094
|
+
const element = /* @__PURE__ */ jsxRuntime.jsx(BlockShell, { block, renderers }, block.id);
|
|
3203
3095
|
made.set(block, { renderers, element });
|
|
3204
3096
|
return element;
|
|
3205
3097
|
});
|
|
3206
3098
|
}
|
|
3207
|
-
|
|
3208
|
-
// src/view/react/EditorView.tsx
|
|
3209
|
-
|
|
3210
3099
|
var NO_RENDERERS = {};
|
|
3211
3100
|
var HINT = "Press Escape, then Tab, to leave the editor.";
|
|
3212
3101
|
var BLOCKS_SELECTED = (count) => `${count} ${count === 1 ? "block" : "blocks"} selected`;
|
|
@@ -3221,18 +3110,21 @@ function EditorView({
|
|
|
3221
3110
|
selectedContentLabel,
|
|
3222
3111
|
blockLabel,
|
|
3223
3112
|
unsupportedBlockLabel = UNSUPPORTED_BLOCK,
|
|
3113
|
+
blockErrorLabel = BLOCK_ERROR,
|
|
3114
|
+
onBlockError,
|
|
3224
3115
|
placeholder,
|
|
3225
3116
|
blockPlaceholder = headingPlaceholder,
|
|
3226
3117
|
blocksSelectedLabel = BLOCKS_SELECTED,
|
|
3227
3118
|
children
|
|
3228
3119
|
}) {
|
|
3229
|
-
const root =
|
|
3230
|
-
const hintId =
|
|
3231
|
-
const blockIdScope =
|
|
3120
|
+
const root = react.useRef(null);
|
|
3121
|
+
const hintId = react.useId();
|
|
3122
|
+
const blockIdScope = react.useId();
|
|
3232
3123
|
const blocks = useEditorState(controller, (state) => state.doc.blocks);
|
|
3124
|
+
const blockError = react.useMemo(() => ({ label: blockErrorLabel, report: onBlockError }), [blockErrorLabel, onBlockError]);
|
|
3233
3125
|
const shells = useBlockElements(blocks, renderers);
|
|
3234
3126
|
useIsomorphicLayoutEffect(() => root.current ? controller.attach(root.current) : void 0, [controller]);
|
|
3235
|
-
return /* @__PURE__ */
|
|
3127
|
+
return /* @__PURE__ */ jsxRuntime.jsx(QuoinEditorContext.Provider, { value: controller, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3236
3128
|
"div",
|
|
3237
3129
|
{
|
|
3238
3130
|
ref: root,
|
|
@@ -3243,62 +3135,62 @@ function EditorView({
|
|
|
3243
3135
|
"aria-describedby": hintId,
|
|
3244
3136
|
onFocusCapture: (event) => focusOwners.set(event.target, controller),
|
|
3245
3137
|
children: [
|
|
3246
|
-
/* @__PURE__ */
|
|
3138
|
+
/* @__PURE__ */ jsxRuntime.jsx(BlockDomIdScope.Provider, { value: blockIdScope, children: /* @__PURE__ */ jsxRuntime.jsx(UnsupportedBlockLabel.Provider, { value: unsupportedBlockLabel, children: /* @__PURE__ */ jsxRuntime.jsx(BlockErrorContext.Provider, { value: blockError, children: /* @__PURE__ */ jsxRuntime.jsx(BlockPlaceholderContext.Provider, { value: blockPlaceholder, children: blocks.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(EmptyDocumentHost, { placeholder, label: paragraphLabel }) : shells }) }) }) }),
|
|
3247
3139
|
children,
|
|
3248
|
-
/* @__PURE__ */
|
|
3249
|
-
/* @__PURE__ */
|
|
3250
|
-
/* @__PURE__ */
|
|
3251
|
-
/* @__PURE__ */
|
|
3140
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectionSink, { label: selectedContentLabel, blockLabel }),
|
|
3141
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id: hintId, className: "quoin-visually-hidden", children: hint }),
|
|
3142
|
+
/* @__PURE__ */ jsxRuntime.jsx(LiveRegion, { blocksSelected: blocksSelectedLabel }),
|
|
3143
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectionWriter, {})
|
|
3252
3144
|
]
|
|
3253
3145
|
}
|
|
3254
3146
|
) });
|
|
3255
3147
|
}
|
|
3256
3148
|
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
//# sourceMappingURL=chunk-
|
|
3149
|
+
exports.BlockErrorContext = BlockErrorContext;
|
|
3150
|
+
exports.BlockShell = BlockShell;
|
|
3151
|
+
exports.EditableRegion = EditableRegion;
|
|
3152
|
+
exports.EditorView = EditorView;
|
|
3153
|
+
exports.NATIVE_INTERACTION = NATIVE_INTERACTION;
|
|
3154
|
+
exports.NODE_ENTRY = NODE_ENTRY;
|
|
3155
|
+
exports.SelectionSink = SelectionSink;
|
|
3156
|
+
exports.TaskCheckbox = TaskCheckbox;
|
|
3157
|
+
exports.ToggleChevron = ToggleChevron;
|
|
3158
|
+
exports.ViewController = ViewController;
|
|
3159
|
+
exports.VoidBlockFallback = VoidBlockFallback;
|
|
3160
|
+
exports.caretClientRect = caretClientRect;
|
|
3161
|
+
exports.caretFromPoint = caretFromPoint;
|
|
3162
|
+
exports.createAutoScroll = createAutoScroll;
|
|
3163
|
+
exports.defaultRenderers = defaultRenderers;
|
|
3164
|
+
exports.dispatchSelection = dispatchSelection;
|
|
3165
|
+
exports.domMapOf = domMapOf;
|
|
3166
|
+
exports.domToPos = domToPos;
|
|
3167
|
+
exports.drawnBlockCount = drawnBlockCount;
|
|
3168
|
+
exports.focusOwners = focusOwners;
|
|
3169
|
+
exports.handleCopy = handleCopy;
|
|
3170
|
+
exports.hostKey = hostKey;
|
|
3171
|
+
exports.isComposingKey = isComposingKey;
|
|
3172
|
+
exports.isCrossSelection = isCrossSelection;
|
|
3173
|
+
exports.isOnFirstLine = isOnFirstLine;
|
|
3174
|
+
exports.isOnLastLine = isOnLastLine;
|
|
3175
|
+
exports.lineEdgeRect = lineEdgeRect;
|
|
3176
|
+
exports.listen = listen;
|
|
3177
|
+
exports.moveToNeighbour = moveToNeighbour;
|
|
3178
|
+
exports.neighbourBlock = neighbourBlock;
|
|
3179
|
+
exports.onBlock = onBlock;
|
|
3180
|
+
exports.posToDom = posToDom;
|
|
3181
|
+
exports.regionInline = regionInline;
|
|
3182
|
+
exports.renderInline = renderInline;
|
|
3183
|
+
exports.textDiff = textDiff;
|
|
3184
|
+
exports.useBlockDomId = useBlockDomId;
|
|
3185
|
+
exports.useEditorState = useEditorState;
|
|
3186
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
3187
|
+
exports.useOrderedNumber = useOrderedNumber;
|
|
3188
|
+
exports.useQuoinEditor = useQuoinEditor;
|
|
3189
|
+
exports.useReadOnly = useReadOnly;
|
|
3190
|
+
exports.useRegionDomId = useRegionDomId;
|
|
3191
|
+
exports.useToggleOpen = useToggleOpen;
|
|
3192
|
+
exports.useViewController = useViewController;
|
|
3193
|
+
exports.visibleBlockIndexes = visibleBlockIndexes;
|
|
3194
|
+
exports.wholeState = wholeState;
|
|
3195
|
+
//# sourceMappingURL=chunk-ACSEYJJF.cjs.map
|
|
3196
|
+
//# sourceMappingURL=chunk-ACSEYJJF.cjs.map
|