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