quoin-editor 1.0.0 → 1.0.1
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 +46 -0
- package/dist/ai.cjs +135 -94
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +62 -21
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +25 -25
- package/dist/catalogue.d.cts +6 -6
- package/dist/catalogue.d.ts +6 -6
- package/dist/catalogue.js +17 -17
- package/dist/{chunk-MQ2XQ4MX.js → chunk-26Q4LSIU.js} +6 -6
- package/dist/chunk-26Q4LSIU.js.map +1 -0
- package/dist/{chunk-AEJXZBVR.cjs → chunk-56C7GCKO.cjs} +110 -103
- package/dist/chunk-56C7GCKO.cjs.map +1 -0
- package/dist/{chunk-GTTPVJSD.cjs → chunk-5M4QG3ZC.cjs} +262 -245
- package/dist/chunk-5M4QG3ZC.cjs.map +1 -0
- package/dist/{chunk-2VDK27IF.cjs → chunk-5R3ISX4A.cjs} +312 -335
- package/dist/chunk-5R3ISX4A.cjs.map +1 -0
- package/dist/{chunk-LCQSG4M6.js → chunk-62WKUAQY.js} +18 -18
- package/dist/{chunk-LCQSG4M6.js.map → chunk-62WKUAQY.js.map} +1 -1
- package/dist/{chunk-NOKWNK2O.js → chunk-6LMS5J3Y.js} +3 -2
- package/dist/{chunk-HELJTLNC.cjs → chunk-6PKVJZQV.cjs} +12 -12
- package/dist/chunk-6PKVJZQV.cjs.map +1 -0
- package/dist/chunk-6YSGUAVW.js +376 -0
- package/dist/chunk-6YSGUAVW.js.map +1 -0
- package/dist/{chunk-CDELOHDY.cjs → chunk-75C6PX2L.cjs} +23 -23
- package/dist/{chunk-CDELOHDY.cjs.map → chunk-75C6PX2L.cjs.map} +1 -1
- package/dist/{chunk-T7SW6OWV.js → chunk-A4IJSJKL.js} +5 -5
- package/dist/{chunk-ND5XJVK2.cjs → chunk-BTBHHBVR.cjs} +19 -19
- package/dist/{chunk-ND5XJVK2.cjs.map → chunk-BTBHHBVR.cjs.map} +1 -1
- package/dist/{chunk-WXMYDXPN.cjs → chunk-CLTHD5GO.cjs} +4 -3
- package/dist/chunk-CLTHD5GO.cjs.map +1 -0
- package/dist/{chunk-OMOBMXD5.cjs → chunk-EH5KXQXY.cjs} +7 -2
- package/dist/chunk-EH5KXQXY.cjs.map +1 -0
- package/dist/{chunk-WQHV3MRE.cjs → chunk-ESMAW4NK.cjs} +12 -12
- package/dist/{chunk-WQHV3MRE.cjs.map → chunk-ESMAW4NK.cjs.map} +1 -1
- package/dist/{chunk-SLVDAHHK.cjs → chunk-EYFCOV3T.cjs} +5 -5
- package/dist/{chunk-SLVDAHHK.cjs.map → chunk-EYFCOV3T.cjs.map} +1 -1
- package/dist/{chunk-5DNCCN6X.cjs → chunk-F5V3IEEE.cjs} +27 -27
- package/dist/{chunk-5DNCCN6X.cjs.map → chunk-F5V3IEEE.cjs.map} +1 -1
- package/dist/{chunk-PMWCQSQX.js → chunk-GPIDU3GN.js} +5 -5
- package/dist/{chunk-PZ4GT5JO.cjs → chunk-HOIDJEVI.cjs} +316 -300
- package/dist/chunk-HOIDJEVI.cjs.map +1 -0
- package/dist/{chunk-RDG4VI6E.cjs → chunk-JJ3RASQS.cjs} +90 -90
- package/dist/{chunk-RDG4VI6E.cjs.map → chunk-JJ3RASQS.cjs.map} +1 -1
- package/dist/{chunk-ZGZEJCRV.js → chunk-LE3F7WIP.js} +23 -46
- package/dist/chunk-LE3F7WIP.js.map +1 -0
- package/dist/chunk-LE5XMIFJ.cjs +14 -0
- package/dist/chunk-LE5XMIFJ.cjs.map +1 -0
- package/dist/{chunk-POBM7MGR.js → chunk-LMAEPFTX.js} +2 -2
- package/dist/{chunk-ZHOSSWUM.js → chunk-LV6EYPJO.js} +4 -3
- package/dist/chunk-LV6EYPJO.js.map +1 -0
- package/dist/chunk-MLRAVUFG.cjs +376 -0
- package/dist/chunk-MLRAVUFG.cjs.map +1 -0
- package/dist/chunk-MQUCCSWG.js +14 -0
- package/dist/chunk-MQUCCSWG.js.map +1 -0
- package/dist/{chunk-XEBWC7ZL.js → chunk-O4Z2WMFF.js} +7 -2
- package/dist/chunk-O4Z2WMFF.js.map +1 -0
- package/dist/{chunk-K574XHMM.js → chunk-OCCKQHCY.js} +2 -2
- package/dist/{chunk-SG37UBDO.js → chunk-PGSS4IOS.js} +7 -7
- package/dist/{chunk-RUDWMKYX.js → chunk-PIWRSX7U.js} +8 -8
- package/dist/{chunk-PWUEPDA3.cjs → chunk-PX6LZMH4.cjs} +44 -44
- package/dist/{chunk-PWUEPDA3.cjs.map → chunk-PX6LZMH4.cjs.map} +1 -1
- package/dist/{chunk-JDPTZUBW.js → chunk-QXG3HWDS.js} +4 -4
- package/dist/{chunk-NNDYYEW5.js → chunk-RQW3P3GH.js} +5 -5
- package/dist/{chunk-ZS2WA357.js → chunk-SSIRYUCK.js} +144 -127
- package/dist/chunk-SSIRYUCK.js.map +1 -0
- package/dist/{chunk-47MLKSI2.js → chunk-UBNG5YCG.js} +6 -6
- package/dist/{chunk-KXOBZGQO.js → chunk-UCXLRRWY.js} +21 -14
- package/dist/chunk-UCXLRRWY.js.map +1 -0
- package/dist/{chunk-EL2OEJQC.cjs → chunk-UDAVVEFC.cjs} +56 -56
- package/dist/{chunk-EL2OEJQC.cjs.map → chunk-UDAVVEFC.cjs.map} +1 -1
- package/dist/{chunk-HJIQT3S5.js → chunk-UPSLDTLT.js} +100 -84
- package/dist/chunk-UPSLDTLT.js.map +1 -0
- package/dist/{chunk-GLLXHMH2.cjs → chunk-UWNZG2SD.cjs} +3 -3
- package/dist/{chunk-GLLXHMH2.cjs.map → chunk-UWNZG2SD.cjs.map} +1 -1
- package/dist/{chunk-HZSSEYJS.cjs → chunk-V3KLMSRO.cjs} +30 -30
- package/dist/{chunk-HZSSEYJS.cjs.map → chunk-V3KLMSRO.cjs.map} +1 -1
- package/dist/{chunk-ZC24WB7Y.cjs → chunk-VACTAZWS.cjs} +14 -14
- package/dist/{chunk-ZC24WB7Y.cjs.map → chunk-VACTAZWS.cjs.map} +1 -1
- package/dist/{chunk-KAVU6T6J.js → chunk-WMN6566P.js} +5 -5
- package/dist/{chunk-2QCRZ7OL.cjs → chunk-XX5FTPJR.cjs} +12 -11
- package/dist/{chunk-2QCRZ7OL.cjs.map → chunk-XX5FTPJR.cjs.map} +1 -1
- package/dist/comments.cjs +113 -98
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.d.cts +6 -1
- package/dist/comments.d.ts +6 -1
- package/dist/comments.js +32 -17
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +43 -40
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.js +16 -13
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +60 -40
- package/dist/docx.cjs.map +1 -1
- package/dist/docx.d.cts +6 -0
- package/dist/docx.d.ts +6 -0
- package/dist/docx.js +32 -12
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +9 -9
- package/dist/embed.d.cts +1 -1
- package/dist/embed.d.ts +1 -1
- package/dist/embed.js +8 -8
- package/dist/{emoji-extension-DpQ43HjE.d.ts → emoji-extension-CmPlRssm.d.ts} +1 -1
- package/dist/{emoji-extension-C12gDPm6.d.cts → emoji-extension-zJ6F7hW8.d.cts} +1 -1
- package/dist/emoji.cjs +8 -8
- package/dist/emoji.d.cts +3 -3
- package/dist/emoji.d.ts +3 -3
- package/dist/emoji.js +7 -7
- package/dist/engine.cjs +4 -4
- package/dist/engine.d.cts +2 -2
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +3 -3
- package/dist/{find-extension-_sbZEt3R.d.cts → find-extension-BcRyE9K4.d.cts} +1 -1
- package/dist/{find-extension-DKqLLSuP.d.ts → find-extension-CmFehyul.d.ts} +1 -1
- package/dist/find.cjs +8 -8
- package/dist/find.d.cts +2 -2
- package/dist/find.d.ts +2 -2
- package/dist/find.js +7 -7
- package/dist/headless.cjs +5 -5
- package/dist/headless.d.cts +4 -4
- package/dist/headless.d.ts +4 -4
- package/dist/headless.js +4 -4
- package/dist/{index-CgD72kHB.d.cts → index-CFPmCee4.d.cts} +5 -2
- package/dist/{index-DNYbTK3w.d.ts → index-DiCGV60d.d.ts} +5 -2
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/math.cjs +10 -10
- package/dist/math.d.cts +1 -1
- package/dist/math.d.ts +1 -1
- package/dist/math.js +9 -9
- package/dist/mention.cjs +10 -10
- package/dist/mention.d.cts +1 -1
- package/dist/mention.d.ts +1 -1
- package/dist/mention.js +9 -9
- package/dist/presence.cjs +96 -99
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.d.cts +2 -2
- package/dist/presence.d.ts +2 -2
- package/dist/presence.js +64 -67
- package/dist/presence.js.map +1 -1
- package/dist/{stats-extension-Bly88uio.d.ts → stats-extension-DisOEbbI.d.ts} +1 -1
- package/dist/{stats-extension-CJPijvUb.d.cts → stats-extension-Dt1lgP3m.d.cts} +1 -1
- package/dist/stats.cjs +9 -9
- package/dist/stats.d.cts +3 -3
- package/dist/stats.d.ts +3 -3
- package/dist/stats.js +8 -8
- package/dist/styles.css +1 -1
- package/dist/{table-extension-Dzf4k6hI.d.ts → table-extension-BTMJnT7J.d.ts} +1 -1
- package/dist/{table-extension-BTLxFy2S.d.cts → table-extension-DxZz3jqp.d.cts} +1 -1
- package/dist/table.cjs +8 -8
- package/dist/table.d.cts +2 -2
- package/dist/table.d.ts +2 -2
- package/dist/table.js +7 -7
- package/dist/{toc-extension-DWm5alVj.d.ts → toc-extension-CR9U-l6j.d.ts} +1 -1
- package/dist/{toc-extension-B3-s6h2x.d.cts → toc-extension-DGHywOBv.d.cts} +1 -1
- package/dist/toc.cjs +8 -8
- package/dist/toc.d.cts +2 -2
- package/dist/toc.d.ts +2 -2
- package/dist/toc.js +7 -7
- package/dist/{types-a1CRBlEh.d.ts → types-C6_QkXzy.d.ts} +1 -9
- package/dist/{types-Cz7XJLaK.d.cts → types-CJ7Gq3GX.d.cts} +1 -9
- package/dist/{view-controller-DSHw0ltQ.d.cts → view-controller-BD1KwYfE.d.cts} +6 -19
- package/dist/{view-controller-UbpzblGl.d.ts → view-controller-y4cb60ue.d.ts} +6 -19
- package/dist/view.cjs +6 -6
- package/dist/view.js +3 -3
- package/dist/yjs.cjs +234 -396
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.d.cts +3 -3
- package/dist/yjs.d.ts +3 -3
- package/dist/yjs.js +126 -288
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2VDK27IF.cjs.map +0 -1
- package/dist/chunk-AEJXZBVR.cjs.map +0 -1
- package/dist/chunk-E75EHRPA.cjs +0 -175
- package/dist/chunk-E75EHRPA.cjs.map +0 -1
- package/dist/chunk-GTTPVJSD.cjs.map +0 -1
- package/dist/chunk-HELJTLNC.cjs.map +0 -1
- package/dist/chunk-HJIQT3S5.js.map +0 -1
- package/dist/chunk-JEIFJHEI.js +0 -14
- package/dist/chunk-JEIFJHEI.js.map +0 -1
- package/dist/chunk-KXOBZGQO.js.map +0 -1
- package/dist/chunk-MQ2XQ4MX.js.map +0 -1
- package/dist/chunk-OMOBMXD5.cjs.map +0 -1
- package/dist/chunk-PZ4GT5JO.cjs.map +0 -1
- package/dist/chunk-QAW5NH6S.cjs +0 -14
- package/dist/chunk-QAW5NH6S.cjs.map +0 -1
- package/dist/chunk-TC4DARU2.js +0 -175
- package/dist/chunk-TC4DARU2.js.map +0 -1
- package/dist/chunk-WXMYDXPN.cjs.map +0 -1
- package/dist/chunk-XEBWC7ZL.js.map +0 -1
- package/dist/chunk-ZGZEJCRV.js.map +0 -1
- package/dist/chunk-ZHOSSWUM.js.map +0 -1
- package/dist/chunk-ZS2WA357.js.map +0 -1
- /package/dist/{chunk-NOKWNK2O.js.map → chunk-6LMS5J3Y.js.map} +0 -0
- /package/dist/{chunk-T7SW6OWV.js.map → chunk-A4IJSJKL.js.map} +0 -0
- /package/dist/{chunk-PMWCQSQX.js.map → chunk-GPIDU3GN.js.map} +0 -0
- /package/dist/{chunk-POBM7MGR.js.map → chunk-LMAEPFTX.js.map} +0 -0
- /package/dist/{chunk-K574XHMM.js.map → chunk-OCCKQHCY.js.map} +0 -0
- /package/dist/{chunk-SG37UBDO.js.map → chunk-PGSS4IOS.js.map} +0 -0
- /package/dist/{chunk-RUDWMKYX.js.map → chunk-PIWRSX7U.js.map} +0 -0
- /package/dist/{chunk-JDPTZUBW.js.map → chunk-QXG3HWDS.js.map} +0 -0
- /package/dist/{chunk-NNDYYEW5.js.map → chunk-RQW3P3GH.js.map} +0 -0
- /package/dist/{chunk-47MLKSI2.js.map → chunk-UBNG5YCG.js.map} +0 -0
- /package/dist/{chunk-KAVU6T6J.js.map → chunk-WMN6566P.js.map} +0 -0
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var _chunkHOIDJEVIcjs = require('./chunk-HOIDJEVI.cjs');
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
@@ -61,7 +61,7 @@ var _chunkPZ4GT5JOcjs = require('./chunk-PZ4GT5JO.cjs');
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunkBTBHHBVRcjs = require('./chunk-BTBHHBVR.cjs');
|
|
65
65
|
|
|
66
66
|
// src/view/react/use-editor-state.ts
|
|
67
67
|
var _react = require('react');
|
|
@@ -93,7 +93,7 @@ function isCrossSelection(selection) {
|
|
|
93
93
|
}
|
|
94
94
|
function selectionDecorations(state, mode) {
|
|
95
95
|
if (mode !== "decorations" || !isCrossSelection(state.selection)) return [];
|
|
96
|
-
return
|
|
96
|
+
return _chunkHOIDJEVIcjs.markRanges.call(void 0, state).map(({ block, region, from, to }) => ({
|
|
97
97
|
kind: "inline",
|
|
98
98
|
block,
|
|
99
99
|
region,
|
|
@@ -104,9 +104,9 @@ function selectionDecorations(state, mode) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// src/view/dom/attributes.ts
|
|
107
|
-
var sortedEntries = (attrs) =>
|
|
107
|
+
var sortedEntries = (attrs) => _chunkBTBHHBVRcjs.dataAttributes.call(void 0, attrs, "");
|
|
108
108
|
function setAttributes(element, attrs, prefix = "") {
|
|
109
|
-
for (const [name, value] of
|
|
109
|
+
for (const [name, value] of _chunkBTBHHBVRcjs.writtenAttrs.call(void 0, _chunkBTBHHBVRcjs.dataAttributes.call(void 0, attrs, prefix))) element.setAttribute(name, value);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// src/view/dom/segments.ts
|
|
@@ -121,7 +121,7 @@ function decorationRanges(decorations, length) {
|
|
|
121
121
|
return ranges;
|
|
122
122
|
}
|
|
123
123
|
function toSegments(inline, decorations) {
|
|
124
|
-
const length =
|
|
124
|
+
const length = _chunkBTBHHBVRcjs.inlineLength.call(void 0, inline);
|
|
125
125
|
const ranges = decorationRanges(decorations, length);
|
|
126
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 || (_nullishCoalesce(a.decoration.side, () => ( 1))) - (_nullishCoalesce(b.decoration.side, () => ( 1))));
|
|
127
127
|
const edges = [...ranges.flatMap((range) => [range.from, range.to]), ...widgets.map((widget) => widget.at)];
|
|
@@ -137,7 +137,7 @@ function toSegments(inline, decorations) {
|
|
|
137
137
|
};
|
|
138
138
|
let start = 0;
|
|
139
139
|
for (const node of inline) {
|
|
140
|
-
const end = start +
|
|
140
|
+
const end = start + _chunkBTBHHBVRcjs.nodeLength.call(void 0, node);
|
|
141
141
|
if (node.kind === "atom") {
|
|
142
142
|
placeWidgets(start);
|
|
143
143
|
segments.push({ kind: "atom", node, decorations: covering(start, end), from: start });
|
|
@@ -187,7 +187,7 @@ function create(doc, tag, attributes) {
|
|
|
187
187
|
return element;
|
|
188
188
|
}
|
|
189
189
|
function linkElement({ href = "", title } = {}, doc) {
|
|
190
|
-
const safe =
|
|
190
|
+
const safe = _chunkBTBHHBVRcjs.sanitizeHref.call(void 0, href);
|
|
191
191
|
if (safe === null) return create(doc, "span", [["data-quoin-link", ""]]);
|
|
192
192
|
const anchor = create(doc, "a", [["href", safe], ["data-quoin-link", ""]]);
|
|
193
193
|
if (title) anchor.title = title;
|
|
@@ -195,8 +195,8 @@ function linkElement({ href = "", title } = {}, doc) {
|
|
|
195
195
|
}
|
|
196
196
|
function markElement2(mark2, doc) {
|
|
197
197
|
if (mark2.type === "link") return linkElement(mark2.attrs, doc);
|
|
198
|
-
const { tag, attrs } =
|
|
199
|
-
return create(doc, tag,
|
|
198
|
+
const { tag, attrs } = _chunkBTBHHBVRcjs.markElement.call(void 0, mark2);
|
|
199
|
+
return create(doc, tag, _chunkBTBHHBVRcjs.writtenAttrs.call(void 0, attrs));
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// src/view/dom/wrappers.ts
|
|
@@ -393,8 +393,8 @@ function reconcileChildren(parent, specs) {
|
|
|
393
393
|
// src/view/dom/text-diff.ts
|
|
394
394
|
function textDiff(before, after, caretHint) {
|
|
395
395
|
if (before === after) return null;
|
|
396
|
-
const prefix =
|
|
397
|
-
const suffix =
|
|
396
|
+
const prefix = _chunkHOIDJEVIcjs.commonPrefix.call(void 0, before, after);
|
|
397
|
+
const suffix = _chunkHOIDJEVIcjs.commonSuffix.call(void 0, before, after);
|
|
398
398
|
const shared = Math.min(suffix, Math.min(before.length, after.length) - prefix);
|
|
399
399
|
const removed = before.length - prefix - shared;
|
|
400
400
|
const inserted = after.length - prefix - shared;
|
|
@@ -499,12 +499,12 @@ function specsFor(segment, options, doc) {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
function needsFiller(inline) {
|
|
502
|
-
const content =
|
|
502
|
+
const content = _chunkBTBHHBVRcjs.inlineText.call(void 0, inline);
|
|
503
503
|
return content === "" || content.endsWith("\n");
|
|
504
504
|
}
|
|
505
505
|
function renderInline(host, inline, decorations, options = {}) {
|
|
506
506
|
const doc = host.ownerDocument;
|
|
507
|
-
const length =
|
|
507
|
+
const length = _chunkBTBHHBVRcjs.inlineLength.call(void 0, inline);
|
|
508
508
|
const specs = toSegments(inline, decorations).flatMap((segment) => specsFor(segment, options, doc));
|
|
509
509
|
if (needsFiller(inline)) specs.push(fillerSpec(doc, length));
|
|
510
510
|
reconcileChildren(host, specs);
|
|
@@ -582,10 +582,10 @@ function readSelection(registry, domSelection, blockAt2 = () => void 0) {
|
|
|
582
582
|
if (!domSelection || !anchorNode || !focusNode) return null;
|
|
583
583
|
const anchor = domToPos(registry, anchorNode, domSelection.anchorOffset);
|
|
584
584
|
const head = domToPos(registry, focusNode, domSelection.focusOffset);
|
|
585
|
-
if (anchor && head) return
|
|
585
|
+
if (anchor && head) return _chunkHOIDJEVIcjs.textSelection.call(void 0, anchor, head);
|
|
586
586
|
if (anchor || head || registry.locate(anchorNode) || registry.locate(focusNode)) return null;
|
|
587
587
|
const block = blockAt2(anchorNode);
|
|
588
|
-
return block !== void 0 && block === blockAt2(focusNode) ?
|
|
588
|
+
return block !== void 0 && block === blockAt2(focusNode) ? _chunkHOIDJEVIcjs.nodeSelection.call(void 0, block) : null;
|
|
589
589
|
}
|
|
590
590
|
function selectBlock(domSelection, element) {
|
|
591
591
|
if (!element) return false;
|
|
@@ -602,7 +602,7 @@ function writeSelection(registry, selection, domSelection, blockElement) {
|
|
|
602
602
|
if (selection.kind !== "text") return false;
|
|
603
603
|
const { anchor, head } = selection;
|
|
604
604
|
if (anchor.block !== head.block || anchor.region !== head.region) return false;
|
|
605
|
-
if (
|
|
605
|
+
if (_chunkHOIDJEVIcjs.sameSelection.call(void 0, readSelection(registry, domSelection), selection)) return true;
|
|
606
606
|
const base = posToDom(registry, anchor, anchor.offset < head.offset ? 1 : -1);
|
|
607
607
|
const extent = posToDom(registry, head, head.offset < anchor.offset ? 1 : -1);
|
|
608
608
|
if (!base || !extent) return false;
|
|
@@ -610,6 +610,15 @@ function writeSelection(registry, selection, domSelection, blockElement) {
|
|
|
610
610
|
return true;
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
+
// src/view/dom/listen.ts
|
|
614
|
+
function listen(target, handlers, options) {
|
|
615
|
+
const entries = Object.entries(handlers);
|
|
616
|
+
for (const [type, handler] of entries) target.addEventListener(type, handler, options);
|
|
617
|
+
return () => {
|
|
618
|
+
for (const [type, handler] of entries) target.removeEventListener(type, handler, options);
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
|
|
613
622
|
// src/view/navigation/node-entry.ts
|
|
614
623
|
var NODE_ENTRY = "data-quoin-node-entry";
|
|
615
624
|
var entersAsNode = (controller, block) => _optionalChain([controller, 'access', _25 => _25.blockElement, 'call', _26 => _26(block), 'optionalAccess', _27 => _27.querySelector, 'call', _28 => _28(`[${NODE_ENTRY}]`)]) != null;
|
|
@@ -655,8 +664,8 @@ var known = /* @__PURE__ */ new WeakMap();
|
|
|
655
664
|
function hidersOf(doc) {
|
|
656
665
|
let hiders = known.get(doc);
|
|
657
666
|
if (hiders === void 0) {
|
|
658
|
-
const first = doc.blocks.findIndex(
|
|
659
|
-
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null :
|
|
667
|
+
const first = doc.blocks.findIndex(_chunkHOIDJEVIcjs.isClosedToggle);
|
|
668
|
+
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null : _chunkHOIDJEVIcjs.hidingToggle.call(void 0, doc, index + 1));
|
|
660
669
|
known.set(doc, hiders);
|
|
661
670
|
}
|
|
662
671
|
return hiders;
|
|
@@ -665,7 +674,7 @@ var hidingToggleAt = (doc, index) => _nullishCoalesce(hidersOf(doc)[index], () =
|
|
|
665
674
|
function isHiddenAt(doc, index, choices) {
|
|
666
675
|
if (choices.size === 0) return hidingToggleAt(doc, index) !== null;
|
|
667
676
|
const closed = (block) => block.type === "TOGGLE" && !shownOpen(block, choices);
|
|
668
|
-
return
|
|
677
|
+
return _chunkHOIDJEVIcjs.hidingToggle.call(void 0, doc, index + 1, closed) !== null;
|
|
669
678
|
}
|
|
670
679
|
var visibleBlockIndexes = (doc) => hidersOf(doc).flatMap((hider, index) => hider === null ? [index] : []);
|
|
671
680
|
function drawnBlockCount(doc, start = 0, end = doc.blocks.length) {
|
|
@@ -690,13 +699,13 @@ function neighbourBlock(doc, from, direction, accept = anyBlock) {
|
|
|
690
699
|
}
|
|
691
700
|
function entryEdge(controller, block, direction) {
|
|
692
701
|
const { doc, schema } = controller.editor.state;
|
|
693
|
-
const edge = direction < 0 ?
|
|
702
|
+
const edge = direction < 0 ? _chunkHOIDJEVIcjs.endOf.call(void 0, doc, schema, block) : _chunkHOIDJEVIcjs.startOf.call(void 0, doc, schema, block);
|
|
694
703
|
if (edge.kind !== "text") return edge;
|
|
695
704
|
const drawn = controller.registry.get(edge.head.block, edge.head.region) !== void 0;
|
|
696
|
-
return drawn && !entersAsNode(controller, block) ? edge :
|
|
705
|
+
return drawn && !entersAsNode(controller, block) ? edge : _chunkHOIDJEVIcjs.nodeSelection.call(void 0, block);
|
|
697
706
|
}
|
|
698
|
-
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ?
|
|
699
|
-
var holdsTextHead = (controller) => (block) =>
|
|
707
|
+
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ? _chunkHOIDJEVIcjs.nodeSelection.call(void 0, block) : null;
|
|
708
|
+
var holdsTextHead = (controller) => (block) => _chunkHOIDJEVIcjs.isTextFlow.call(void 0, controller.editor.state.schema, block) && entryEdge(controller, block.id, 1).kind === "text";
|
|
700
709
|
function neighbourHead(controller, from, direction) {
|
|
701
710
|
const target = neighbourBlock(controller.editor.state.doc, from, direction, holdsTextHead(controller));
|
|
702
711
|
const edge = target && entryEdge(controller, target.id, direction);
|
|
@@ -829,11 +838,13 @@ function createCrossBlockPointer(controller) {
|
|
|
829
838
|
const doc = root.ownerDocument;
|
|
830
839
|
const view = doc.defaultView;
|
|
831
840
|
let press = null;
|
|
841
|
+
let unfollow = () => {
|
|
842
|
+
};
|
|
832
843
|
let last = { x: 0, y: 0 };
|
|
833
844
|
let preventMouseDown = false;
|
|
834
845
|
const scroll = createAutoScroll(root, () => follow(last.x, last.y));
|
|
835
846
|
function select(selection) {
|
|
836
|
-
if (
|
|
847
|
+
if (_chunkHOIDJEVIcjs.sameSelection.call(void 0, selection, controller.editor.state.selection)) return;
|
|
837
848
|
dispatchSelection(controller, selection);
|
|
838
849
|
}
|
|
839
850
|
function startDragging() {
|
|
@@ -849,24 +860,21 @@ function createCrossBlockPointer(controller) {
|
|
|
849
860
|
if (current.anchor === null) return;
|
|
850
861
|
startDragging();
|
|
851
862
|
}
|
|
852
|
-
select(
|
|
863
|
+
select(_chunkHOIDJEVIcjs.textSelection.call(void 0, current.anchor, caretPosAt(controller, target, x, y)));
|
|
853
864
|
}
|
|
854
865
|
function followBlocks(current, x, y) {
|
|
855
866
|
if (!controller.dragging && Math.hypot(x - current.x, y - current.y) < DRAG_DISTANCE) return;
|
|
856
867
|
const block = blockAt(controller, x, y);
|
|
857
868
|
if (block === null) return;
|
|
858
869
|
startDragging();
|
|
859
|
-
select(
|
|
870
|
+
select(_chunkHOIDJEVIcjs.blockRangeSelection.call(void 0, current.start, block));
|
|
860
871
|
}
|
|
861
872
|
function follow(x, y) {
|
|
862
873
|
if (_optionalChain([press, 'optionalAccess', _40 => _40.kind]) === "text") followText(press, x, y);
|
|
863
874
|
else if (_optionalChain([press, 'optionalAccess', _41 => _41.kind]) === "blocks") followBlocks(press, x, y);
|
|
864
875
|
}
|
|
865
876
|
function release() {
|
|
866
|
-
|
|
867
|
-
doc.removeEventListener("pointerup", end);
|
|
868
|
-
doc.removeEventListener("pointercancel", end);
|
|
869
|
-
view.removeEventListener("blur", end);
|
|
877
|
+
unfollow();
|
|
870
878
|
scroll.stop();
|
|
871
879
|
press = null;
|
|
872
880
|
const dragged = controller.dragging;
|
|
@@ -907,26 +915,26 @@ function createCrossBlockPointer(controller) {
|
|
|
907
915
|
press = { kind: "blocks", start: block, x: event.clientX, y: event.clientY };
|
|
908
916
|
if (!event.shiftKey && entryEdge(controller, block, 1).kind === "node") {
|
|
909
917
|
controller.nodeReveal.pressed(block);
|
|
910
|
-
select(
|
|
918
|
+
select(_chunkHOIDJEVIcjs.nodeSelection.call(void 0, block));
|
|
911
919
|
}
|
|
912
920
|
} else {
|
|
913
921
|
return;
|
|
914
922
|
}
|
|
915
|
-
doc
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
923
|
+
const unfollowDocument = listen(doc, { pointermove: onPointerMove, pointerup: end, pointercancel: end });
|
|
924
|
+
const unfollowView = listen(view, { blur: end });
|
|
925
|
+
unfollow = () => {
|
|
926
|
+
unfollowDocument();
|
|
927
|
+
unfollowView();
|
|
928
|
+
};
|
|
919
929
|
}
|
|
920
930
|
function onMouseDown(event) {
|
|
921
931
|
if (preventMouseDown) event.preventDefault();
|
|
922
932
|
preventMouseDown = false;
|
|
923
933
|
}
|
|
924
|
-
root
|
|
925
|
-
root.addEventListener("mousedown", onMouseDown);
|
|
934
|
+
const unlisten = listen(root, { pointerdown: onPointerDown, mousedown: onMouseDown });
|
|
926
935
|
return () => {
|
|
927
936
|
release();
|
|
928
|
-
|
|
929
|
-
root.removeEventListener("mousedown", onMouseDown);
|
|
937
|
+
unlisten();
|
|
930
938
|
};
|
|
931
939
|
}
|
|
932
940
|
};
|
|
@@ -935,7 +943,7 @@ function createCrossBlockPointer(controller) {
|
|
|
935
943
|
// src/view/selection/paint-selection.ts
|
|
936
944
|
var NAME = "quoin-selection";
|
|
937
945
|
function coveredRanges(controller) {
|
|
938
|
-
return
|
|
946
|
+
return _chunkHOIDJEVIcjs.markRanges.call(void 0, controller.editor.state).flatMap(({ block, region, from, to }) => {
|
|
939
947
|
const host = controller.registry.get(block, region);
|
|
940
948
|
const map = host && domMapOf(host);
|
|
941
949
|
if (!host || !map) return [];
|
|
@@ -1006,7 +1014,7 @@ function heldBySink(selection) {
|
|
|
1006
1014
|
}
|
|
1007
1015
|
var NO_TEXT = "\xA0";
|
|
1008
1016
|
function selectionText(state) {
|
|
1009
|
-
const text =
|
|
1017
|
+
const text = _chunkHOIDJEVIcjs.markRanges.call(void 0, state).map((range) => _chunkBTBHHBVRcjs.inlinePlainText.call(void 0, _chunkHOIDJEVIcjs.rangeContent.call(void 0, state, range), state.schema)).join("\n");
|
|
1010
1018
|
return text === "" ? NO_TEXT : text;
|
|
1011
1019
|
}
|
|
1012
1020
|
var focusInPlace = (sink) => inPlace(sink, () => sink.focus({ preventScroll: true }));
|
|
@@ -1029,7 +1037,7 @@ function focusSink(controller) {
|
|
|
1029
1037
|
_optionalChain([sink, 'access', _46 => _46.ownerDocument, 'access', _47 => _47.getSelection, 'call', _48 => _48(), 'optionalAccess', _49 => _49.selectAllChildren, 'call', _50 => _50(sink)]);
|
|
1030
1038
|
}
|
|
1031
1039
|
function selectedBlockName({ doc, schema, selection }, blockLabel) {
|
|
1032
|
-
const block = _optionalChain([selection, 'optionalAccess', _51 => _51.kind]) === "node" ?
|
|
1040
|
+
const block = _optionalChain([selection, 'optionalAccess', _51 => _51.kind]) === "node" ? _chunkBTBHHBVRcjs.blockById.call(void 0, doc, selection.block) : void 0;
|
|
1033
1041
|
return block === void 0 ? null : _nullishCoalesce(_optionalChain([blockLabel, 'optionalCall', _52 => _52(block, schema)]), () => ( ""));
|
|
1034
1042
|
}
|
|
1035
1043
|
function clearSink(controller) {
|
|
@@ -1098,19 +1106,27 @@ var nodeOf = (selection) => _optionalChain([selection, 'optionalAccess', _67 =>
|
|
|
1098
1106
|
function createNodeReveal(element) {
|
|
1099
1107
|
let shown = null;
|
|
1100
1108
|
let pressed = null;
|
|
1109
|
+
let owed = null;
|
|
1101
1110
|
return {
|
|
1102
1111
|
pressed(block) {
|
|
1103
1112
|
pressed = block;
|
|
1104
1113
|
},
|
|
1105
1114
|
follow(selection) {
|
|
1106
|
-
|
|
1115
|
+
const block = nodeOf(selection);
|
|
1116
|
+
if (block !== shown) shown = null;
|
|
1117
|
+
if (block !== owed) owed = null;
|
|
1107
1118
|
},
|
|
1108
1119
|
settle(selection) {
|
|
1109
|
-
|
|
1120
|
+
const block = nodeOf(selection);
|
|
1121
|
+
if (block !== shown) owed = block;
|
|
1122
|
+
shown = block;
|
|
1110
1123
|
},
|
|
1111
|
-
show(selection) {
|
|
1124
|
+
show(selection, local) {
|
|
1112
1125
|
const block = nodeOf(selection);
|
|
1113
|
-
if (block !== null && block !==
|
|
1126
|
+
if (block !== null && block !== pressed && (block !== shown || local && block === owed)) {
|
|
1127
|
+
_optionalChain([element, 'call', _68 => _68(block), 'optionalAccess', _69 => _69.scrollIntoView, 'call', _70 => _70({ block: "nearest" })]);
|
|
1128
|
+
}
|
|
1129
|
+
if (local) owed = null;
|
|
1114
1130
|
shown = block;
|
|
1115
1131
|
pressed = null;
|
|
1116
1132
|
}
|
|
@@ -1158,7 +1174,7 @@ function createElementSlot(changed) {
|
|
|
1158
1174
|
|
|
1159
1175
|
// src/view/controller/selection-element.ts
|
|
1160
1176
|
function elementFor({ doc }, selection, rendered) {
|
|
1161
|
-
const id =
|
|
1177
|
+
const id = _chunkHOIDJEVIcjs.headBlockId.call(void 0, selection);
|
|
1162
1178
|
const index = id === null ? void 0 : doc.index.get(id);
|
|
1163
1179
|
if (id === null || index === void 0) return void 0;
|
|
1164
1180
|
const hiding = hidingToggleAt(doc, index);
|
|
@@ -1171,7 +1187,7 @@ function selectionElement(state, rendered) {
|
|
|
1171
1187
|
if (doc.blocks.length === 0) return _nullishCoalesce(_optionalChain([rendered, 'access', _75 => _75.empty, 'optionalCall', _76 => _76()]), () => ( void 0));
|
|
1172
1188
|
const sink = heldBySink(selection) ? _optionalChain([rendered, 'access', _77 => _77.sink, 'optionalCall', _78 => _78()]) : null;
|
|
1173
1189
|
if (sink) return sink;
|
|
1174
|
-
return _nullishCoalesce(elementFor(state, selection, rendered), () => ( elementFor(state,
|
|
1190
|
+
return _nullishCoalesce(elementFor(state, selection, rendered), () => ( elementFor(state, _chunkHOIDJEVIcjs.startOf.call(void 0, doc, schema, doc.blocks[0].id), rendered)));
|
|
1175
1191
|
}
|
|
1176
1192
|
|
|
1177
1193
|
// src/view/controller/tab-stop.ts
|
|
@@ -1238,9 +1254,9 @@ function ownsFocus(controller, doc) {
|
|
|
1238
1254
|
function focusTarget(state, target) {
|
|
1239
1255
|
const { doc, schema, selection } = state;
|
|
1240
1256
|
if (doc.blocks.length === 0) return null;
|
|
1241
|
-
if (target === "end") return
|
|
1242
|
-
if (target === "start" || target === void 0 && selection === null) return
|
|
1243
|
-
return target === void 0 ? selection :
|
|
1257
|
+
if (target === "end") return _chunkHOIDJEVIcjs.endOf.call(void 0, doc, schema, doc.blocks[doc.blocks.length - 1].id);
|
|
1258
|
+
if (target === "start" || target === void 0 && selection === null) return _chunkHOIDJEVIcjs.startOf.call(void 0, doc, schema, doc.blocks[0].id);
|
|
1259
|
+
return target === void 0 ? selection : _chunkHOIDJEVIcjs.textSelection.call(void 0, target);
|
|
1244
1260
|
}
|
|
1245
1261
|
|
|
1246
1262
|
// src/view/controller/host-decorations.ts
|
|
@@ -1256,7 +1272,7 @@ function decorationsByHost(decorations) {
|
|
|
1256
1272
|
return byHost;
|
|
1257
1273
|
}
|
|
1258
1274
|
function sameDecoration(a, b) {
|
|
1259
|
-
if (a.kind !== b.kind || a.block !== b.block || !
|
|
1275
|
+
if (a.kind !== b.kind || a.block !== b.block || !_chunkBTBHHBVRcjs.sameAttrs.call(void 0, a.attrs, b.attrs)) return false;
|
|
1260
1276
|
if (a.kind === "inline" && b.kind === "inline") {
|
|
1261
1277
|
return a.region === b.region && a.from === b.from && a.to === b.to;
|
|
1262
1278
|
}
|
|
@@ -1267,7 +1283,7 @@ function sameDecoration(a, b) {
|
|
|
1267
1283
|
return true;
|
|
1268
1284
|
}
|
|
1269
1285
|
function sameDecorations(a, b) {
|
|
1270
|
-
return a === b ||
|
|
1286
|
+
return a === b || _chunkBTBHHBVRcjs.sameItems.call(void 0, a, b, sameDecoration);
|
|
1271
1287
|
}
|
|
1272
1288
|
var byMode = { highlight: /* @__PURE__ */ new WeakMap(), decorations: /* @__PURE__ */ new WeakMap() };
|
|
1273
1289
|
function hostDecorations(editor, block, region, mode = "highlight") {
|
|
@@ -1283,7 +1299,7 @@ function hostDecorations(editor, block, region, mode = "highlight") {
|
|
|
1283
1299
|
|
|
1284
1300
|
// src/view/controller/region-inline.ts
|
|
1285
1301
|
function regionInline(state, block, region) {
|
|
1286
|
-
const regions = _optionalChain([
|
|
1302
|
+
const regions = _optionalChain([_chunkBTBHHBVRcjs.blockById.call(void 0, state.doc, block), 'optionalAccess', _86 => _86.regions]);
|
|
1287
1303
|
return regions && Object.hasOwn(regions, region) ? regions[region] : void 0;
|
|
1288
1304
|
}
|
|
1289
1305
|
|
|
@@ -1333,7 +1349,7 @@ function createOutsideChanges(editorHasFocus, movedFrom) {
|
|
|
1333
1349
|
}
|
|
1334
1350
|
const from = _nullishCoalesce(moved, () => ( (outside && !settled ? movedFrom(tr.before.selection) : null)));
|
|
1335
1351
|
settled ||= outside;
|
|
1336
|
-
moved = from &&
|
|
1352
|
+
moved = from && _chunkHOIDJEVIcjs.mapSelection.call(void 0, from, (pos, assoc) => tr.mapPos(pos, assoc), tr.before.doc);
|
|
1337
1353
|
},
|
|
1338
1354
|
takeFocused() {
|
|
1339
1355
|
const value = focused;
|
|
@@ -1426,7 +1442,7 @@ function handleCopy(controller, event, cut) {
|
|
|
1426
1442
|
clipboardData.setData("text/plain", copied.text);
|
|
1427
1443
|
clipboardData.setData("text/html", wrapSliceHTML(copied.html, copied.json));
|
|
1428
1444
|
clipboardData.setData(QUOIN_SLICE_TYPE, copied.json);
|
|
1429
|
-
if (cut) controller.run(
|
|
1445
|
+
if (cut) controller.run(_chunkHOIDJEVIcjs.deleteSelection);
|
|
1430
1446
|
}
|
|
1431
1447
|
function handlePaste(controller, event) {
|
|
1432
1448
|
if (!event.clipboardData) return;
|
|
@@ -1458,7 +1474,7 @@ function handleDrop(controller, event) {
|
|
|
1458
1474
|
return;
|
|
1459
1475
|
}
|
|
1460
1476
|
const pos = dropPos(controller, event.clientX, event.clientY);
|
|
1461
|
-
if (pos)
|
|
1477
|
+
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(_chunkHOIDJEVIcjs.textSelection.call(void 0, pos)).setOrigin("drop"));
|
|
1462
1478
|
pasteTransfer(controller, dataTransfer);
|
|
1463
1479
|
}
|
|
1464
1480
|
function handleDragOver(event) {
|
|
@@ -1586,29 +1602,29 @@ function createSinkComposition(controller) {
|
|
|
1586
1602
|
var LINE_BREAK = "\n";
|
|
1587
1603
|
var transposeChars = (state, dispatch) => {
|
|
1588
1604
|
const { selection } = state;
|
|
1589
|
-
if (_optionalChain([selection, 'optionalAccess', _110 => _110.kind]) !== "text" || !
|
|
1605
|
+
if (_optionalChain([selection, 'optionalAccess', _110 => _110.kind]) !== "text" || !_chunkHOIDJEVIcjs.isCollapsed.call(void 0, selection)) return false;
|
|
1590
1606
|
const { head } = selection;
|
|
1591
|
-
const inline = _optionalChain([
|
|
1607
|
+
const inline = _optionalChain([_chunkBTBHHBVRcjs.blockById.call(void 0, state.doc, head.block), 'optionalAccess', _111 => _111.regions, 'access', _112 => _112[head.region]]);
|
|
1592
1608
|
if (inline === void 0) return false;
|
|
1593
|
-
const value =
|
|
1609
|
+
const value = _chunkBTBHHBVRcjs.inlineText.call(void 0, inline);
|
|
1594
1610
|
const atLineEnd = head.offset === value.length || value[head.offset] === LINE_BREAK;
|
|
1595
|
-
const end = atLineEnd ? head.offset :
|
|
1596
|
-
const middle =
|
|
1597
|
-
const start =
|
|
1611
|
+
const end = atLineEnd ? head.offset : _chunkHOIDJEVIcjs.nextGraphemeOffset.call(void 0, value, head.offset);
|
|
1612
|
+
const middle = _chunkHOIDJEVIcjs.prevGraphemeOffset.call(void 0, value, end);
|
|
1613
|
+
const start = _chunkHOIDJEVIcjs.prevGraphemeOffset.call(void 0, value, middle);
|
|
1598
1614
|
if (start === middle || value.slice(start, end).includes(LINE_BREAK)) return false;
|
|
1599
|
-
const swapped = [...
|
|
1600
|
-
const tr = new (0,
|
|
1601
|
-
tr.step(
|
|
1602
|
-
_optionalChain([dispatch, 'optionalCall', _113 => _113(tr.setSelection(
|
|
1615
|
+
const swapped = [..._chunkBTBHHBVRcjs.sliceInline.call(void 0, inline, middle, end), ..._chunkBTBHHBVRcjs.sliceInline.call(void 0, inline, start, middle)];
|
|
1616
|
+
const tr = new (0, _chunkHOIDJEVIcjs.Transaction)(state).setOrigin("input");
|
|
1617
|
+
tr.step(_chunkHOIDJEVIcjs.replaceInlineStep.call(void 0, head.block, head.region, start, end, swapped));
|
|
1618
|
+
_optionalChain([dispatch, 'optionalCall', _113 => _113(tr.setSelection(_chunkHOIDJEVIcjs.textSelection.call(void 0, { ...head, offset: end })))]);
|
|
1603
1619
|
return true;
|
|
1604
1620
|
};
|
|
1605
1621
|
|
|
1606
1622
|
// src/view/input/replace-range.ts
|
|
1607
1623
|
function replaceRange(editor, range, text, withRules) {
|
|
1608
1624
|
const dispatch = (tr) => editor.dispatch(tr);
|
|
1609
|
-
dispatch(editor.createTransaction().setSelection(
|
|
1610
|
-
if (text === "") return
|
|
1611
|
-
return withRules ? editor.insertText(text) :
|
|
1625
|
+
dispatch(editor.createTransaction().setSelection(_chunkHOIDJEVIcjs.textSelection.call(void 0, range.from, range.to)).setOrigin("input"));
|
|
1626
|
+
if (text === "") return _chunkHOIDJEVIcjs.deleteSelection.call(void 0, editor.state, (tr) => dispatch(tr.setOrigin("input")));
|
|
1627
|
+
return withRules ? editor.insertText(text) : _chunkHOIDJEVIcjs.insertText.call(void 0, text, { origin: "input" })(editor.state, dispatch);
|
|
1612
1628
|
}
|
|
1613
1629
|
|
|
1614
1630
|
// src/view/input/target-range.ts
|
|
@@ -1619,13 +1635,13 @@ function targetRangeToModel(controller, event) {
|
|
|
1619
1635
|
const to = domToPos(controller.registry, range.endContainer, range.endOffset);
|
|
1620
1636
|
return from && to && { from, to };
|
|
1621
1637
|
}
|
|
1622
|
-
var isEmpty = ({ from, to }) =>
|
|
1638
|
+
var isEmpty = ({ from, to }) => _chunkHOIDJEVIcjs.sameSelection.call(void 0, _chunkHOIDJEVIcjs.textSelection.call(void 0, from), _chunkHOIDJEVIcjs.textSelection.call(void 0, to));
|
|
1623
1639
|
function targetBeyondSelection(controller, event) {
|
|
1624
1640
|
const range = targetRangeToModel(controller, event);
|
|
1625
1641
|
if (range === null || isEmpty(range)) return null;
|
|
1626
1642
|
const { doc, selection } = controller.editor.state;
|
|
1627
|
-
const selected =
|
|
1628
|
-
const same = selected !== null &&
|
|
1643
|
+
const selected = _chunkHOIDJEVIcjs.selectionRange.call(void 0, doc, selection);
|
|
1644
|
+
const same = selected !== null && _chunkHOIDJEVIcjs.sameSelection.call(void 0, _chunkHOIDJEVIcjs.textSelection.call(void 0, selected.from, selected.to), _chunkHOIDJEVIcjs.textSelection.call(void 0, range.from, range.to));
|
|
1629
1645
|
return same ? null : range;
|
|
1630
1646
|
}
|
|
1631
1647
|
|
|
@@ -1647,34 +1663,34 @@ function insertTypedText(controller, event) {
|
|
|
1647
1663
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1648
1664
|
}
|
|
1649
1665
|
function deleteContentBackward(controller, event) {
|
|
1650
|
-
if (!controller.run(
|
|
1666
|
+
if (!controller.run(_chunkHOIDJEVIcjs.undoInputRule)) targetOr((0, _chunkHOIDJEVIcjs.deleteBackward))(controller, event);
|
|
1651
1667
|
}
|
|
1652
1668
|
function insertReplacementText(controller, event) {
|
|
1653
1669
|
const text = _optionalChain([event, 'access', _117 => _117.dataTransfer, 'optionalAccess', _118 => _118.getData, 'call', _119 => _119("text/plain")]) || event.data;
|
|
1654
1670
|
if (!text) return;
|
|
1655
1671
|
const range = targetRangeToModel(controller, event);
|
|
1656
|
-
if (range === null) controller.run(
|
|
1672
|
+
if (range === null) controller.run(_chunkHOIDJEVIcjs.insertText.call(void 0, text, { origin: "input" }));
|
|
1657
1673
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1658
1674
|
}
|
|
1659
1675
|
var actions = {
|
|
1660
1676
|
insertText: insertTypedText,
|
|
1661
1677
|
insertReplacementText,
|
|
1662
1678
|
insertParagraph: (controller) => void controller.edit(() => controller.editor.handleKey(ENTER)),
|
|
1663
|
-
insertLineBreak: run(
|
|
1679
|
+
insertLineBreak: run(_chunkHOIDJEVIcjs.insertHardBreak),
|
|
1664
1680
|
deleteContentBackward,
|
|
1665
|
-
deleteContentForward: targetOr(
|
|
1666
|
-
deleteWordBackward: targetOr(
|
|
1667
|
-
deleteWordForward: targetOr(
|
|
1668
|
-
deleteSoftLineBackward: targetOr(
|
|
1669
|
-
deleteHardLineBackward: targetOr(
|
|
1670
|
-
deleteSoftLineForward: targetOr(
|
|
1671
|
-
deleteHardLineForward: targetOr(
|
|
1672
|
-
formatBold: run(
|
|
1673
|
-
formatItalic: run(
|
|
1674
|
-
formatUnderline: run(
|
|
1675
|
-
formatStrikeThrough: run(
|
|
1676
|
-
historyUndo: run(
|
|
1677
|
-
historyRedo: run(
|
|
1681
|
+
deleteContentForward: targetOr(_chunkHOIDJEVIcjs.deleteForward),
|
|
1682
|
+
deleteWordBackward: targetOr(_chunkHOIDJEVIcjs.deleteWordBackward),
|
|
1683
|
+
deleteWordForward: targetOr(_chunkHOIDJEVIcjs.deleteWordForward),
|
|
1684
|
+
deleteSoftLineBackward: targetOr(_chunkHOIDJEVIcjs.deleteToLineStart),
|
|
1685
|
+
deleteHardLineBackward: targetOr(_chunkHOIDJEVIcjs.deleteToLineStart),
|
|
1686
|
+
deleteSoftLineForward: targetOr(_chunkHOIDJEVIcjs.deleteToLineEnd),
|
|
1687
|
+
deleteHardLineForward: targetOr(_chunkHOIDJEVIcjs.deleteToLineEnd),
|
|
1688
|
+
formatBold: run(_chunkHOIDJEVIcjs.toggleMark.call(void 0, "bold")),
|
|
1689
|
+
formatItalic: run(_chunkHOIDJEVIcjs.toggleMark.call(void 0, "italic")),
|
|
1690
|
+
formatUnderline: run(_chunkHOIDJEVIcjs.toggleMark.call(void 0, "underline")),
|
|
1691
|
+
formatStrikeThrough: run(_chunkHOIDJEVIcjs.toggleMark.call(void 0, "strike")),
|
|
1692
|
+
historyUndo: run(_chunkHOIDJEVIcjs.undo),
|
|
1693
|
+
historyRedo: run(_chunkHOIDJEVIcjs.redo),
|
|
1678
1694
|
insertTranspose: run(transposeChars),
|
|
1679
1695
|
insertFromPaste: leaveToHandlers,
|
|
1680
1696
|
insertFromDrop: leaveToHandlers,
|
|
@@ -1775,7 +1791,7 @@ function snapshotComposition(controller, block, region) {
|
|
|
1775
1791
|
const element = controller.registry.get(block, region);
|
|
1776
1792
|
const inline = regionInline(editor.state, block, region);
|
|
1777
1793
|
if (element === void 0 || inline === void 0) return null;
|
|
1778
|
-
const text =
|
|
1794
|
+
const text = _chunkBTBHHBVRcjs.inlineText.call(void 0, inline);
|
|
1779
1795
|
const end = composedEnd(controller, block, region);
|
|
1780
1796
|
const since = [];
|
|
1781
1797
|
const release = editor.subscribe((_, tr) => void (tr && since.push(tr)));
|
|
@@ -1811,7 +1827,7 @@ function targetAt(controller, node) {
|
|
|
1811
1827
|
}
|
|
1812
1828
|
function elementOf(controller, target) {
|
|
1813
1829
|
if (target === EMPTY_HOST) return _nullishCoalesce(controller.emptyHost, () => ( void 0));
|
|
1814
|
-
return target
|
|
1830
|
+
return target ? controller.registry.get(target.block, target.region) : void 0;
|
|
1815
1831
|
}
|
|
1816
1832
|
function createCompositionHandlers(controller) {
|
|
1817
1833
|
let active = false;
|
|
@@ -1887,7 +1903,7 @@ function reconcileHost(controller, block, region, caretHint) {
|
|
|
1887
1903
|
const element = controller.registry.get(block, region);
|
|
1888
1904
|
const inline = regionInline(controller.editor.state, block, region);
|
|
1889
1905
|
if (element === void 0 || inline === void 0) return false;
|
|
1890
|
-
const before =
|
|
1906
|
+
const before = _chunkBTBHHBVRcjs.inlineText.call(void 0, inline);
|
|
1891
1907
|
const after = readDomText(element);
|
|
1892
1908
|
const edit = before === after ? null : textDiff(before, after, _nullishCoalesce(caretHint, () => ( domCaretOffset(element))));
|
|
1893
1909
|
if (edit === null) return false;
|
|
@@ -1952,33 +1968,33 @@ function createDomInputFallback(controller) {
|
|
|
1952
1968
|
|
|
1953
1969
|
// src/view/navigation/cross-moves.ts
|
|
1954
1970
|
function moveHead(controller, { anchor }, head) {
|
|
1955
|
-
dispatchSelection(controller,
|
|
1971
|
+
dispatchSelection(controller, _chunkHOIDJEVIcjs.textSelection.call(void 0, anchor, head));
|
|
1956
1972
|
return true;
|
|
1957
1973
|
}
|
|
1958
1974
|
function blockOf(controller, { block }) {
|
|
1959
1975
|
const { doc } = controller.editor.state;
|
|
1960
|
-
return doc.blocks[
|
|
1976
|
+
return doc.blocks[_chunkBTBHHBVRcjs.requireBlockIndex.call(void 0, doc, block)];
|
|
1961
1977
|
}
|
|
1962
1978
|
function collapseCross(controller, selection, direction) {
|
|
1963
|
-
const { from, to } =
|
|
1964
|
-
dispatchSelection(controller,
|
|
1979
|
+
const { from, to } = _chunkHOIDJEVIcjs.selectionRange.call(void 0, controller.editor.state.doc, selection);
|
|
1980
|
+
dispatchSelection(controller, _chunkHOIDJEVIcjs.textSelection.call(void 0, direction < 0 ? from : to));
|
|
1965
1981
|
return true;
|
|
1966
1982
|
}
|
|
1967
1983
|
function crossHeadVertically(controller, selection, direction) {
|
|
1968
1984
|
const { head } = selection;
|
|
1969
1985
|
const edge = neighbourHead(controller, head.block, direction);
|
|
1970
1986
|
if (edge !== null) {
|
|
1971
|
-
const end2 =
|
|
1987
|
+
const end2 = _chunkHOIDJEVIcjs.regionLength.call(void 0, blockOf(controller, edge), edge.region);
|
|
1972
1988
|
return moveHead(controller, selection, { ...edge, offset: Math.min(head.offset, end2) });
|
|
1973
1989
|
}
|
|
1974
|
-
const end =
|
|
1990
|
+
const end = _chunkHOIDJEVIcjs.regionLength.call(void 0, blockOf(controller, head), head.region);
|
|
1975
1991
|
return moveHead(controller, selection, { ...head, offset: direction < 0 ? 0 : end });
|
|
1976
1992
|
}
|
|
1977
1993
|
function crossHeadHorizontally(controller, selection, direction) {
|
|
1978
1994
|
const { head } = selection;
|
|
1979
|
-
const text =
|
|
1995
|
+
const text = _chunkBTBHHBVRcjs.inlineText.call(void 0, _nullishCoalesce(blockOf(controller, head).regions[head.region], () => ( [])));
|
|
1980
1996
|
if (direction < 0 ? head.offset > 0 : head.offset < text.length) {
|
|
1981
|
-
const offset = direction < 0 ?
|
|
1997
|
+
const offset = direction < 0 ? _chunkHOIDJEVIcjs.prevGraphemeOffset.call(void 0, text, head.offset) : _chunkHOIDJEVIcjs.nextGraphemeOffset.call(void 0, text, head.offset);
|
|
1982
1998
|
return moveHead(controller, selection, { ...head, offset });
|
|
1983
1999
|
}
|
|
1984
2000
|
const edge = neighbourHead(controller, head.block, direction);
|
|
@@ -1997,9 +2013,9 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
1997
2013
|
const move = extend ? crossHeadHorizontally : collapseCross;
|
|
1998
2014
|
return move(controller, selection, direction);
|
|
1999
2015
|
}
|
|
2000
|
-
if (!extend && !
|
|
2016
|
+
if (!extend && !_chunkHOIDJEVIcjs.isCollapsed.call(void 0, selection)) return false;
|
|
2001
2017
|
const { head } = selection;
|
|
2002
|
-
const length =
|
|
2018
|
+
const length = _chunkHOIDJEVIcjs.regionLength.call(void 0, doc.blocks[_chunkBTBHHBVRcjs.requireBlockIndex.call(void 0, doc, head.block)], head.region);
|
|
2003
2019
|
if (direction < 0 ? head.offset > 0 : head.offset < length) return false;
|
|
2004
2020
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2005
2021
|
if (own2 !== null) {
|
|
@@ -2009,7 +2025,7 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
2009
2025
|
if (!extend) return moveToNeighbour(controller, head.block, direction);
|
|
2010
2026
|
const edge = neighbourHead(controller, head.block, direction);
|
|
2011
2027
|
if (edge === null) return false;
|
|
2012
|
-
dispatchSelection(controller,
|
|
2028
|
+
dispatchSelection(controller, _chunkHOIDJEVIcjs.textSelection.call(void 0, selection.anchor, edge));
|
|
2013
2029
|
return true;
|
|
2014
2030
|
}
|
|
2015
2031
|
|
|
@@ -2107,12 +2123,12 @@ function caretAtGoal(controller, host, at, y) {
|
|
|
2107
2123
|
}
|
|
2108
2124
|
function landAtGoal(controller, block, direction) {
|
|
2109
2125
|
const { schema } = controller.editor.state;
|
|
2110
|
-
const region =
|
|
2126
|
+
const region = _chunkHOIDJEVIcjs.isTextFlow.call(void 0, schema, block) ? _chunkHOIDJEVIcjs.primaryRegion.call(void 0, schema, block) : null;
|
|
2111
2127
|
const host = region === null ? void 0 : controller.registry.get(block.id, region);
|
|
2112
2128
|
if (!host || region === null || controller.goalX === null) return null;
|
|
2113
2129
|
const line = lineInView(host, direction < 0);
|
|
2114
2130
|
const pos = line && caretAtGoal(controller, host, { block: block.id, region }, line.top + line.height / 2);
|
|
2115
|
-
return pos ?
|
|
2131
|
+
return pos ? _chunkHOIDJEVIcjs.textSelection.call(void 0, pos) : null;
|
|
2116
2132
|
}
|
|
2117
2133
|
function moveInHost(controller, host, head, caret, direction) {
|
|
2118
2134
|
const { goalX } = controller;
|
|
@@ -2130,7 +2146,7 @@ function landing(controller, { head }, direction, extend) {
|
|
|
2130
2146
|
controller.goalX ??= _nullishCoalesce(_optionalChain([caret, 'optionalAccess', _147 => _147.left]), () => ( null));
|
|
2131
2147
|
if (!(direction < 0 ? isOnFirstLine(host, point) : isOnLastLine(host, point))) {
|
|
2132
2148
|
const pos = moveInHost(controller, host, head, caret, direction);
|
|
2133
|
-
return pos &&
|
|
2149
|
+
return pos && _chunkHOIDJEVIcjs.textSelection.call(void 0, pos);
|
|
2134
2150
|
}
|
|
2135
2151
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2136
2152
|
if (own2 !== null) return own2;
|
|
@@ -2144,14 +2160,14 @@ function moveText(controller, selection, direction, extend) {
|
|
|
2144
2160
|
controller.nativeVerticalMove = true;
|
|
2145
2161
|
return false;
|
|
2146
2162
|
}
|
|
2147
|
-
const moved = extend && next.kind === "text" ?
|
|
2163
|
+
const moved = extend && next.kind === "text" ? _chunkHOIDJEVIcjs.textSelection.call(void 0, selection.anchor, next.head) : next;
|
|
2148
2164
|
dispatchSelection(controller, moved);
|
|
2149
2165
|
return true;
|
|
2150
2166
|
}
|
|
2151
2167
|
function extendBlocks(controller, { anchor, head }, direction) {
|
|
2152
2168
|
const next = neighbourBlock(controller.editor.state.doc, head, direction);
|
|
2153
2169
|
if (next === null) return false;
|
|
2154
|
-
dispatchSelection(controller,
|
|
2170
|
+
dispatchSelection(controller, _chunkHOIDJEVIcjs.blockRangeSelection.call(void 0, anchor, next.id));
|
|
2155
2171
|
return true;
|
|
2156
2172
|
}
|
|
2157
2173
|
function moveVertically(controller, direction, extend) {
|
|
@@ -2167,8 +2183,8 @@ function moveVertically(controller, direction, extend) {
|
|
|
2167
2183
|
// src/view/input/flip-block.ts
|
|
2168
2184
|
var isTask = ({ type, attrs }) => type === "MARKDOWN" && attrs.kind === "task";
|
|
2169
2185
|
function flipCommand(block) {
|
|
2170
|
-
if (isTask(block)) return
|
|
2171
|
-
return block.type === "TOGGLE" ?
|
|
2186
|
+
if (isTask(block)) return _chunkHOIDJEVIcjs.toggleTask;
|
|
2187
|
+
return block.type === "TOGGLE" ? _chunkHOIDJEVIcjs.setAttrs.call(void 0, { open: block.attrs.open !== true }) : null;
|
|
2172
2188
|
}
|
|
2173
2189
|
var toggleState = (open) => open ? "expanded" : "collapsed";
|
|
2174
2190
|
function stateName(block) {
|
|
@@ -2177,7 +2193,7 @@ function stateName(block) {
|
|
|
2177
2193
|
}
|
|
2178
2194
|
function blockHoldingCaret({ doc, selection }) {
|
|
2179
2195
|
if (_optionalChain([selection, 'optionalAccess', _151 => _151.kind]) !== "text" || selection.anchor.block !== selection.head.block) return null;
|
|
2180
|
-
return _nullishCoalesce(
|
|
2196
|
+
return _nullishCoalesce(_chunkBTBHHBVRcjs.blockById.call(void 0, doc, selection.head.block), () => ( null));
|
|
2181
2197
|
}
|
|
2182
2198
|
function flipForReader(controller, block) {
|
|
2183
2199
|
if (_optionalChain([block, 'optionalAccess', _152 => _152.type]) !== "TOGGLE") return false;
|
|
@@ -2192,7 +2208,7 @@ function flipSelectedBlock(controller) {
|
|
|
2192
2208
|
if (controller.readOnly) return flipForReader(controller, block);
|
|
2193
2209
|
const command = block && flipCommand(block);
|
|
2194
2210
|
if (!block || !command || !controller.run(command)) return false;
|
|
2195
|
-
const after =
|
|
2211
|
+
const after = _chunkBTBHHBVRcjs.blockById.call(void 0, editor.state.doc, block.id);
|
|
2196
2212
|
if (after) controller.announce(stateName(after));
|
|
2197
2213
|
return true;
|
|
2198
2214
|
}
|
|
@@ -2286,11 +2302,13 @@ function attachInput(controller, root) {
|
|
|
2286
2302
|
else composition.end(event);
|
|
2287
2303
|
};
|
|
2288
2304
|
const detachClipboard = attachClipboard(controller, root, catchUp);
|
|
2289
|
-
root
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2305
|
+
const unlisten = listen(root, {
|
|
2306
|
+
keydown: onKeyDown,
|
|
2307
|
+
beforeinput: onBeforeInput,
|
|
2308
|
+
input: onInput,
|
|
2309
|
+
compositionstart: onCompositionStart,
|
|
2310
|
+
compositionend: onCompositionEnd
|
|
2311
|
+
});
|
|
2294
2312
|
function observe(host) {
|
|
2295
2313
|
if (!observed.has(host)) observed.set(host, fallback.observe(host));
|
|
2296
2314
|
}
|
|
@@ -2306,11 +2324,7 @@ function attachInput(controller, root) {
|
|
|
2306
2324
|
composition.release();
|
|
2307
2325
|
sinkComposition.release();
|
|
2308
2326
|
detachClipboard();
|
|
2309
|
-
|
|
2310
|
-
root.removeEventListener("beforeinput", onBeforeInput);
|
|
2311
|
-
root.removeEventListener("input", onInput);
|
|
2312
|
-
root.removeEventListener("compositionstart", onCompositionStart);
|
|
2313
|
-
root.removeEventListener("compositionend", onCompositionEnd);
|
|
2327
|
+
unlisten();
|
|
2314
2328
|
for (const stop of observed.values()) stop();
|
|
2315
2329
|
observed.clear();
|
|
2316
2330
|
}
|
|
@@ -2332,13 +2346,11 @@ function watchFocusReturn(root, handlers) {
|
|
|
2332
2346
|
const onFocusOut = (event) => {
|
|
2333
2347
|
if (!root.contains(event.relatedTarget)) pressed = false;
|
|
2334
2348
|
};
|
|
2335
|
-
root
|
|
2336
|
-
root
|
|
2337
|
-
root.addEventListener("focusout", onFocusOut);
|
|
2349
|
+
const unlistenPress = listen(root, { pointerdown: onPointerDown }, true);
|
|
2350
|
+
const unlistenFocus = listen(root, { focusin: onFocusIn, focusout: onFocusOut });
|
|
2338
2351
|
return () => {
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
root.removeEventListener("focusout", onFocusOut);
|
|
2352
|
+
unlistenPress();
|
|
2353
|
+
unlistenFocus();
|
|
2342
2354
|
};
|
|
2343
2355
|
}
|
|
2344
2356
|
|
|
@@ -2407,9 +2419,9 @@ function bindRoot(controller, root, cross, committed) {
|
|
|
2407
2419
|
function movedSelection(controller, doc, model) {
|
|
2408
2420
|
if (controller.composingKey !== null || controller.dragging || !doc || !ownsFocus(controller, doc)) return null;
|
|
2409
2421
|
const selection = readSelection(controller.registry, doc.getSelection(), (node) => controller.blockAt(node));
|
|
2410
|
-
return selection === null ||
|
|
2422
|
+
return selection === null || _chunkHOIDJEVIcjs.sameSelection.call(void 0, selection, model) ? null : selection;
|
|
2411
2423
|
}
|
|
2412
|
-
function writeModelSelection(controller, doc, moved) {
|
|
2424
|
+
function writeModelSelection(controller, doc, moved, local) {
|
|
2413
2425
|
const domSelection = _optionalChain([doc, 'optionalAccess', _168 => _168.getSelection, 'call', _169 => _169()]);
|
|
2414
2426
|
if (focusingSink(controller) || controller.composingKey !== null || !doc || !domSelection || !ownsFocus(controller, doc)) {
|
|
2415
2427
|
return;
|
|
@@ -2419,7 +2431,7 @@ function writeModelSelection(controller, doc, moved) {
|
|
|
2419
2431
|
if (heldBySink(selection) && controller.sink !== null) focusSink(controller);
|
|
2420
2432
|
else if (_optionalChain([selection, 'optionalAccess', _170 => _170.kind]) === "blocks") domSelection.removeAllRanges();
|
|
2421
2433
|
else writeSelection(controller.registry, selection, domSelection, (id) => controller.blockElement(id));
|
|
2422
|
-
controller.nodeReveal.show(selection);
|
|
2434
|
+
controller.nodeReveal.show(selection, local);
|
|
2423
2435
|
if (!samePoints(before, selectionPoints(domSelection))) moved();
|
|
2424
2436
|
}
|
|
2425
2437
|
|
|
@@ -2428,102 +2440,105 @@ var runNow = (fn) => fn();
|
|
|
2428
2440
|
var ViewController = (_class = class {
|
|
2429
2441
|
|
|
2430
2442
|
__init() {this.registry = createHostRegistry((element) => {
|
|
2431
|
-
_optionalChain([this, 'access', _179 => _179
|
|
2432
|
-
this
|
|
2443
|
+
_optionalChain([this, 'access', _179 => _179.#binding, 'optionalAccess', _180 => _180.input, 'access', _181 => _181.observe, 'call', _182 => _182(element)]);
|
|
2444
|
+
this.#drawn.syncTabStop();
|
|
2433
2445
|
return () => {
|
|
2434
|
-
_optionalChain([this, 'access', _183 => _183
|
|
2435
|
-
this
|
|
2446
|
+
_optionalChain([this, 'access', _183 => _183.#binding, 'optionalAccess', _184 => _184.input, 'access', _185 => _185.unobserve, 'call', _186 => _186(element)]);
|
|
2447
|
+
this.#drawn.syncTabStop();
|
|
2436
2448
|
};
|
|
2437
2449
|
})}
|
|
2438
2450
|
__init2() {this.keyInterceptors = /* @__PURE__ */ new Set()}
|
|
2439
2451
|
__init3() {this.nodeReveal = createNodeReveal((id) => this.blockElement(id))}
|
|
2440
|
-
__init4() {this.announcer = createAnnouncer(() => this
|
|
2452
|
+
__init4() {this.announcer = createAnnouncer(() => this.#said)}
|
|
2441
2453
|
|
|
2442
2454
|
|
|
2443
2455
|
__init5() {this.goalX = null}
|
|
2444
2456
|
__init6() {this.nativeVerticalMove = false}
|
|
2445
2457
|
__init7() {this.dragging = false}
|
|
2446
2458
|
__init8() {this.composingKey = null}
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
() => hasFocus(this, this
|
|
2453
|
-
(model) => movedSelection(this, this
|
|
2454
|
-
)
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2459
|
+
#flush;
|
|
2460
|
+
#hosts;
|
|
2461
|
+
#drawn = createDrawnElements(this.registry, () => this.editor.state);
|
|
2462
|
+
#cross = createCrossMode(this);
|
|
2463
|
+
#outside = createOutsideChanges(
|
|
2464
|
+
() => hasFocus(this, this.#ownerDocument()),
|
|
2465
|
+
(model) => movedSelection(this, this.#ownerDocument(), model)
|
|
2466
|
+
);
|
|
2467
|
+
#binding = null;
|
|
2468
|
+
#quiet = false;
|
|
2469
|
+
#loud = false;
|
|
2470
|
+
#said;
|
|
2471
|
+
#detachRoot = null;
|
|
2472
|
+
#readOnlyState;
|
|
2473
|
+
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);
|
|
2461
2474
|
this.editor = options.editor;
|
|
2462
2475
|
options.editor.subscribe((state, tr) => {
|
|
2463
|
-
if (_optionalChain([tr, 'optionalAccess', _187 => _187.origin]) !== "remote") this
|
|
2476
|
+
if (_optionalChain([tr, 'optionalAccess', _187 => _187.origin]) !== "remote") this.#said = state;
|
|
2464
2477
|
});
|
|
2465
|
-
this
|
|
2478
|
+
this.#flush = _nullishCoalesce(options.flush, () => ( runNow));
|
|
2466
2479
|
this.onFiles = options.onFiles;
|
|
2467
|
-
this.isMac = _nullishCoalesce(options.isMac, () => (
|
|
2480
|
+
this.isMac = _nullishCoalesce(options.isMac, () => ( _chunkHOIDJEVIcjs.detectMac.call(void 0, )));
|
|
2468
2481
|
const decorationsOf = (block, region) => this.decorationsFor(block, region);
|
|
2469
|
-
|
|
2470
|
-
this
|
|
2482
|
+
const drain = (element) => _optionalChain([this, 'access', _188 => _188.#binding, 'optionalAccess', _189 => _189.input, 'access', _190 => _190.drain, 'call', _191 => _191(element)]);
|
|
2483
|
+
this.#hosts = createHostRenderer(options.editor, options.render, decorationsOf, drain);
|
|
2484
|
+
this.#readOnlyState = createReadOnly(this.registry, _nullishCoalesce(options.readOnly, () => ( false)));
|
|
2471
2485
|
}
|
|
2472
2486
|
get root() {
|
|
2473
|
-
return _nullishCoalesce(_optionalChain([this, 'access', _192 => _192
|
|
2487
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _192 => _192.#binding, 'optionalAccess', _193 => _193.root]), () => ( null));
|
|
2474
2488
|
}
|
|
2475
2489
|
get readOnly() {
|
|
2476
|
-
return this
|
|
2490
|
+
return this.#readOnlyState.current();
|
|
2477
2491
|
}
|
|
2478
2492
|
get sink() {
|
|
2479
|
-
return this
|
|
2493
|
+
return this.#drawn.sink;
|
|
2480
2494
|
}
|
|
2481
2495
|
get emptyHost() {
|
|
2482
|
-
return this
|
|
2496
|
+
return this.#drawn.emptyHost;
|
|
2483
2497
|
}
|
|
2484
2498
|
attach(root) {
|
|
2485
|
-
_optionalChain([this, 'access', _194 => _194
|
|
2486
|
-
const binding = bindRoot(this, root, this
|
|
2487
|
-
this
|
|
2488
|
-
this
|
|
2499
|
+
_optionalChain([this, 'access', _194 => _194.#detachRoot, 'optionalCall', _195 => _195()]);
|
|
2500
|
+
const binding = bindRoot(this, root, this.#cross, (_, tr) => {
|
|
2501
|
+
this.#quiet ||= _optionalChain([tr, 'optionalAccess', _196 => _196.origin]) === "remote" && tr.docChanged;
|
|
2502
|
+
this.#loud ||= _optionalChain([tr, 'optionalAccess', _197 => _197.origin]) !== "remote";
|
|
2503
|
+
this.#outside.committed(tr);
|
|
2489
2504
|
this.nodeReveal.follow(this.editor.state.selection);
|
|
2490
|
-
this
|
|
2491
|
-
this
|
|
2505
|
+
this.#drawn.syncTabStop();
|
|
2506
|
+
this.#cross.syncLater();
|
|
2492
2507
|
});
|
|
2493
2508
|
const unmount = this.editor.mount();
|
|
2494
2509
|
const detach = () => {
|
|
2495
2510
|
unmount();
|
|
2496
2511
|
binding.detach();
|
|
2497
|
-
if (this
|
|
2498
|
-
this
|
|
2499
|
-
this
|
|
2512
|
+
if (this.#detachRoot !== detach) return;
|
|
2513
|
+
this.#detachRoot = null;
|
|
2514
|
+
this.#binding = null;
|
|
2500
2515
|
};
|
|
2501
|
-
this
|
|
2502
|
-
this
|
|
2503
|
-
this
|
|
2516
|
+
this.#binding = binding;
|
|
2517
|
+
this.#detachRoot = detach;
|
|
2518
|
+
this.#drawn.syncTabStop();
|
|
2504
2519
|
return detach;
|
|
2505
2520
|
}
|
|
2506
2521
|
registerBlockElement(id, element) {
|
|
2507
|
-
return this
|
|
2522
|
+
return this.#drawn.registerBlock(id, element);
|
|
2508
2523
|
}
|
|
2509
2524
|
blockElement(id) {
|
|
2510
|
-
return this
|
|
2525
|
+
return this.#drawn.block(id);
|
|
2511
2526
|
}
|
|
2512
2527
|
blockAt(node) {
|
|
2513
|
-
return this
|
|
2528
|
+
return this.#drawn.blockAt(node);
|
|
2514
2529
|
}
|
|
2515
2530
|
registerSink(element) {
|
|
2516
|
-
return this
|
|
2531
|
+
return this.#drawn.registerSink(element);
|
|
2517
2532
|
}
|
|
2518
2533
|
// An empty document draws one host that stands for a paragraph not created yet, so it belongs to no block.
|
|
2519
2534
|
registerEmptyHost(element) {
|
|
2520
|
-
return this
|
|
2535
|
+
return this.#drawn.registerEmptyHost(element);
|
|
2521
2536
|
}
|
|
2522
2537
|
isEditorElement(element) {
|
|
2523
|
-
return this
|
|
2538
|
+
return this.#drawn.isEditorElement(element);
|
|
2524
2539
|
}
|
|
2525
2540
|
decorationsFor(block, region) {
|
|
2526
|
-
return hostDecorations(this.editor, block, region, this
|
|
2541
|
+
return hostDecorations(this.editor, block, region, this.#cross.mode);
|
|
2527
2542
|
}
|
|
2528
2543
|
dispatch(tr) {
|
|
2529
2544
|
this.edit(() => {
|
|
@@ -2536,34 +2551,35 @@ var ViewController = (_class = class {
|
|
|
2536
2551
|
// open a popover that takes it.
|
|
2537
2552
|
edit(change) {
|
|
2538
2553
|
const before = this.editor.state;
|
|
2539
|
-
const doc = this
|
|
2554
|
+
const doc = this.#ownerDocument();
|
|
2540
2555
|
const focused = hasFocus(this, doc);
|
|
2541
2556
|
let handled = false;
|
|
2542
|
-
this
|
|
2543
|
-
() => this
|
|
2557
|
+
this.#flush(
|
|
2558
|
+
() => this.#outside.inside(() => {
|
|
2544
2559
|
handled = change();
|
|
2545
2560
|
})
|
|
2546
2561
|
);
|
|
2547
2562
|
if (this.editor.state === before) return handled;
|
|
2548
2563
|
if (this.editor.state.doc !== before.doc) this.goalX = null;
|
|
2549
2564
|
this.refreshHosts();
|
|
2550
|
-
this
|
|
2551
|
-
if (focused && doc !== null && ownsFocus(this, doc)) this
|
|
2552
|
-
this.syncSelectionToDom();
|
|
2565
|
+
this.#cross.sync();
|
|
2566
|
+
if (focused && doc !== null && ownsFocus(this, doc)) this.#keepFocus();
|
|
2567
|
+
this.syncSelectionToDom(true);
|
|
2553
2568
|
return handled;
|
|
2554
2569
|
}
|
|
2555
2570
|
// A change made outside edit() reaches the hosts when React draws them, so the selection is written back once that
|
|
2556
|
-
// has happened, and focus follows a host the change replaced. A
|
|
2571
|
+
// has happened, and focus follows a host the change replaced. A render of collaborators' changes alone, or of one
|
|
2572
|
+
// that changed the document, scrolls nothing doing so; a caret move of theirs leaves the rest to scroll as it would.
|
|
2557
2573
|
afterRender() {
|
|
2558
|
-
const
|
|
2559
|
-
this
|
|
2560
|
-
const doc = this
|
|
2561
|
-
const moved = this
|
|
2562
|
-
if (!this
|
|
2563
|
-
if (moved) this
|
|
2564
|
-
this
|
|
2574
|
+
const quiet = this.#quiet || !this.#loud;
|
|
2575
|
+
this.#quiet = this.#loud = false;
|
|
2576
|
+
const doc = this.#ownerDocument();
|
|
2577
|
+
const moved = this.#outside.takeMoved();
|
|
2578
|
+
if (!this.#outside.takeFocused() || !doc || !ownsFocus(this, doc)) return;
|
|
2579
|
+
if (moved) this.#selectFromDom(moved);
|
|
2580
|
+
this.#cross.sync();
|
|
2565
2581
|
const follow = () => {
|
|
2566
|
-
this
|
|
2582
|
+
this.#keepFocus(quiet);
|
|
2567
2583
|
this.syncSelectionToDom();
|
|
2568
2584
|
};
|
|
2569
2585
|
if (!quiet) return follow();
|
|
@@ -2572,7 +2588,7 @@ var ViewController = (_class = class {
|
|
|
2572
2588
|
}
|
|
2573
2589
|
refreshHosts() {
|
|
2574
2590
|
for (const host of this.registry.all()) {
|
|
2575
|
-
if (!this
|
|
2591
|
+
if (!this.#isComposing(host)) this.#hosts.renderIfChanged(host);
|
|
2576
2592
|
}
|
|
2577
2593
|
}
|
|
2578
2594
|
run(command) {
|
|
@@ -2587,63 +2603,63 @@ var ViewController = (_class = class {
|
|
|
2587
2603
|
renderHost(block, region) {
|
|
2588
2604
|
const element = this.registry.get(block, region);
|
|
2589
2605
|
const host = element && { block, region, element };
|
|
2590
|
-
if (!host || this
|
|
2591
|
-
const inSelection = element.contains(_nullishCoalesce(_optionalChain([this, 'access',
|
|
2606
|
+
if (!host || this.#isComposing(host) || !this.#hosts.render(host)) return;
|
|
2607
|
+
const inSelection = element.contains(_nullishCoalesce(_optionalChain([this, 'access', _198 => _198.domSelection, 'call', _199 => _199(), 'optionalAccess', _200 => _200.focusNode]), () => ( null)));
|
|
2592
2608
|
if (inSelection && hasFocus(this, element.ownerDocument)) this.syncSelectionToDom();
|
|
2593
2609
|
}
|
|
2594
2610
|
domSelection() {
|
|
2595
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2611
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _201 => _201.#ownerDocument, 'call', _202 => _202(), 'optionalAccess', _203 => _203.getSelection, 'call', _204 => _204()]), () => ( null));
|
|
2596
2612
|
}
|
|
2597
|
-
syncSelectionToDom() {
|
|
2598
|
-
writeModelSelection(this, this
|
|
2613
|
+
syncSelectionToDom(local) {
|
|
2614
|
+
writeModelSelection(this, this.#ownerDocument(), () => _optionalChain([this, 'access', _205 => _205.#binding, 'optionalAccess', _206 => _206.selectionSync, 'access', _207 => _207.suppressNext, 'call', _208 => _208()]), local);
|
|
2599
2615
|
}
|
|
2600
2616
|
// A pointer drag across hosts sets the model selection itself, while the browser keeps extending its own. Leaving
|
|
2601
2617
|
// cross mode re-renders the hosts that drew it as decorations, which can remove the node holding the caret, so the
|
|
2602
2618
|
// selection is written back.
|
|
2603
2619
|
readSelectionFromDom() {
|
|
2604
|
-
const selection = movedSelection(this, this
|
|
2620
|
+
const selection = movedSelection(this, this.#ownerDocument(), this.editor.state.selection);
|
|
2605
2621
|
if (selection === null) return;
|
|
2606
|
-
const wasCross = this
|
|
2622
|
+
const wasCross = this.#cross.active;
|
|
2607
2623
|
if (!this.nativeVerticalMove) this.goalX = null;
|
|
2608
|
-
this
|
|
2609
|
-
this
|
|
2610
|
-
if (!wasCross && !this
|
|
2611
|
-
this
|
|
2624
|
+
this.#flush(() => this.#selectFromDom(selection));
|
|
2625
|
+
this.#cross.sync();
|
|
2626
|
+
if (!wasCross && !this.#cross.active) return;
|
|
2627
|
+
this.#keepFocus();
|
|
2612
2628
|
this.syncSelectionToDom();
|
|
2613
2629
|
}
|
|
2614
2630
|
focus(target) {
|
|
2615
2631
|
const { editor } = this;
|
|
2616
2632
|
const selection = focusTarget(editor.state, target);
|
|
2617
|
-
if (selection !== null && !
|
|
2618
|
-
this
|
|
2633
|
+
if (selection !== null && !_chunkHOIDJEVIcjs.sameSelection.call(void 0, selection, editor.state.selection)) dispatchSelection(this, selection);
|
|
2634
|
+
this.#takeFocus();
|
|
2619
2635
|
this.syncSelectionToDom();
|
|
2620
2636
|
}
|
|
2621
2637
|
setReadOnly(readOnly) {
|
|
2622
|
-
this
|
|
2638
|
+
this.#readOnlyState.set(readOnly);
|
|
2623
2639
|
}
|
|
2624
2640
|
subscribeReadOnly(listener) {
|
|
2625
|
-
return this
|
|
2641
|
+
return this.#readOnlyState.subscribe(listener);
|
|
2626
2642
|
}
|
|
2627
2643
|
destroy() {
|
|
2628
|
-
_optionalChain([this, 'access',
|
|
2644
|
+
_optionalChain([this, 'access', _209 => _209.#detachRoot, 'optionalCall', _210 => _210()]);
|
|
2629
2645
|
}
|
|
2630
|
-
selectFromDom(selection) {
|
|
2646
|
+
#selectFromDom(selection) {
|
|
2631
2647
|
const { editor } = this;
|
|
2632
|
-
this
|
|
2648
|
+
this.#outside.inside(() => editor.dispatch(editor.createTransaction().setSelection(selection).setOrigin("input")));
|
|
2633
2649
|
}
|
|
2634
|
-
isComposing(host) {
|
|
2650
|
+
#isComposing(host) {
|
|
2635
2651
|
return this.composingKey !== null && hostKey(host.block, host.region) === this.composingKey;
|
|
2636
2652
|
}
|
|
2637
|
-
ownerDocument() {
|
|
2638
|
-
return _nullishCoalesce(_optionalChain([(_nullishCoalesce(_optionalChain([this, 'access',
|
|
2653
|
+
#ownerDocument() {
|
|
2654
|
+
return _nullishCoalesce(_optionalChain([(_nullishCoalesce(_optionalChain([this, 'access', _211 => _211.#binding, 'optionalAccess', _212 => _212.root]), () => ( _optionalChain([this, 'access', _213 => _213.registry, 'access', _214 => _214.all, 'call', _215 => _215(), 'access', _216 => _216.next, 'call', _217 => _217(), 'access', _218 => _218.value, 'optionalAccess', _219 => _219.element])))), 'optionalAccess', _220 => _220.ownerDocument]), () => ( null));
|
|
2639
2655
|
}
|
|
2640
2656
|
// React replaces a host whose block changes kind, which drops focus, and Firefox does not move focus into another
|
|
2641
2657
|
// host when a script selects inside it.
|
|
2642
|
-
keepFocus(preventScroll) {
|
|
2643
|
-
if (this.composingKey === null) this
|
|
2658
|
+
#keepFocus(preventScroll) {
|
|
2659
|
+
if (this.composingKey === null) this.#takeFocus(preventScroll);
|
|
2644
2660
|
}
|
|
2645
|
-
takeFocus(preventScroll) {
|
|
2646
|
-
const element = this
|
|
2661
|
+
#takeFocus(preventScroll) {
|
|
2662
|
+
const element = this.#drawn.focusElement();
|
|
2647
2663
|
if (!element || element.ownerDocument.activeElement === element) return;
|
|
2648
2664
|
if (element === this.sink) focusSink(this);
|
|
2649
2665
|
else element.focus({ preventScroll });
|
|
@@ -2672,18 +2688,18 @@ function useQuoinEditor(options) {
|
|
|
2672
2688
|
const { blocks, readOnly = false } = options;
|
|
2673
2689
|
const callbacks = _react.useRef.call(void 0, options);
|
|
2674
2690
|
const [controller] = _react.useState.call(void 0, () => {
|
|
2675
|
-
const editor =
|
|
2691
|
+
const editor = _chunkHOIDJEVIcjs.createEditor.call(void 0, {
|
|
2676
2692
|
blocks,
|
|
2677
2693
|
extensions: options.extensions,
|
|
2678
2694
|
onChange: (next) => callbacks.current.onChange(next),
|
|
2679
|
-
onTransaction: (tr, state) => _optionalChain([callbacks, 'access',
|
|
2695
|
+
onTransaction: (tr, state) => _optionalChain([callbacks, 'access', _221 => _221.current, 'access', _222 => _222.onTransaction, 'optionalCall', _223 => _223(tr, state)])
|
|
2680
2696
|
});
|
|
2681
2697
|
return new ViewController({
|
|
2682
2698
|
editor,
|
|
2683
2699
|
flush: _reactdom.flushSync,
|
|
2684
2700
|
render: options.render,
|
|
2685
2701
|
readOnly,
|
|
2686
|
-
onFiles: (files, at) => _optionalChain([callbacks, 'access',
|
|
2702
|
+
onFiles: (files, at) => _optionalChain([callbacks, 'access', _224 => _224.current, 'access', _225 => _225.onFiles, 'optionalCall', _226 => _226(files, at)])
|
|
2687
2703
|
});
|
|
2688
2704
|
});
|
|
2689
2705
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -2722,7 +2738,7 @@ function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
|
2722
2738
|
);
|
|
2723
2739
|
useIsomorphicLayoutEffect(() => {
|
|
2724
2740
|
const sink = ref.current;
|
|
2725
|
-
return sink
|
|
2741
|
+
return sink ? controller.registerSink(sink) : void 0;
|
|
2726
2742
|
}, [controller]);
|
|
2727
2743
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2728
2744
|
"div",
|
|
@@ -2750,11 +2766,11 @@ function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
|
2750
2766
|
|
|
2751
2767
|
// src/view/react/block-placeholder.ts
|
|
2752
2768
|
|
|
2753
|
-
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${
|
|
2769
|
+
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${_chunkBTBHHBVRcjs.headingLevel.call(void 0, attrs.level)}` : void 0;
|
|
2754
2770
|
var BlockPlaceholderContext = _react.createContext.call(void 0, headingPlaceholder);
|
|
2755
2771
|
function regionPlaceholder(state, blockId, region, placeholderOf) {
|
|
2756
|
-
const block =
|
|
2757
|
-
return block !== void 0 &&
|
|
2772
|
+
const block = _chunkBTBHHBVRcjs.blockById.call(void 0, state.doc, blockId);
|
|
2773
|
+
return block !== void 0 && _chunkHOIDJEVIcjs.primaryRegion.call(void 0, state.schema, block) === region ? placeholderOf(state, block) : void 0;
|
|
2758
2774
|
}
|
|
2759
2775
|
|
|
2760
2776
|
// src/view/react/EditableRegion.tsx
|
|
@@ -2768,7 +2784,7 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2768
2784
|
const select = _react.useCallback.call(void 0,
|
|
2769
2785
|
(state) => {
|
|
2770
2786
|
const inline2 = regionInline(state, block, region);
|
|
2771
|
-
const empty = inline2 === void 0 ||
|
|
2787
|
+
const empty = inline2 === void 0 || _chunkBTBHHBVRcjs.inlineLength.call(void 0, inline2) === 0;
|
|
2772
2788
|
return {
|
|
2773
2789
|
inline: inline2,
|
|
2774
2790
|
decorations: controller.decorationsFor(block, region),
|
|
@@ -2780,7 +2796,7 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2780
2796
|
const { inline, decorations, placeholder: shown } = useEditorState(controller, select, samePainted);
|
|
2781
2797
|
useIsomorphicLayoutEffect(() => {
|
|
2782
2798
|
const host = ref.current;
|
|
2783
|
-
return host
|
|
2799
|
+
return host ? controller.registry.register(block, region, host) : void 0;
|
|
2784
2800
|
}, [controller, block, region]);
|
|
2785
2801
|
useIsomorphicLayoutEffect(() => {
|
|
2786
2802
|
controller.renderHost(block, region);
|
|
@@ -2819,9 +2835,9 @@ var CalloutBlock = ({ block }) => {
|
|
|
2819
2835
|
// src/view/react/block-command.ts
|
|
2820
2836
|
function onBlock(id, command) {
|
|
2821
2837
|
return (state, dispatch) => {
|
|
2822
|
-
const { ok, tr } =
|
|
2838
|
+
const { ok, tr } = _chunkHOIDJEVIcjs.runCommands.call(void 0, state, [_chunkHOIDJEVIcjs.setSelection.call(void 0, _chunkHOIDJEVIcjs.blockRangeSelection.call(void 0, id)), command]);
|
|
2823
2839
|
if (!ok || tr === null) return false;
|
|
2824
|
-
_optionalChain([dispatch, 'optionalCall',
|
|
2840
|
+
_optionalChain([dispatch, 'optionalCall', _227 => _227(tr.setSelection(state.selection))]);
|
|
2825
2841
|
return true;
|
|
2826
2842
|
};
|
|
2827
2843
|
}
|
|
@@ -2873,7 +2889,7 @@ function numberDoc(doc) {
|
|
|
2873
2889
|
numbers[index] = run2.next++;
|
|
2874
2890
|
return;
|
|
2875
2891
|
}
|
|
2876
|
-
const start =
|
|
2892
|
+
const start = _chunkBTBHHBVRcjs.orderedStart.call(void 0, block.attrs.start);
|
|
2877
2893
|
numbers[index] = start;
|
|
2878
2894
|
runs.push({ indent: block.indent, next: start + 1 });
|
|
2879
2895
|
});
|
|
@@ -2914,7 +2930,7 @@ var MarkdownBlock = (props) => {
|
|
|
2914
2930
|
const { block } = props;
|
|
2915
2931
|
switch (block.attrs.kind) {
|
|
2916
2932
|
case "heading": {
|
|
2917
|
-
const level =
|
|
2933
|
+
const level = _chunkBTBHHBVRcjs.headingLevel.call(void 0, block.attrs.level);
|
|
2918
2934
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "heading", "aria-level": level, className: "quoin-heading", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TextRegion, { block, label: `Heading ${level}` }) });
|
|
2919
2935
|
}
|
|
2920
2936
|
case "bullet":
|
|
@@ -3025,7 +3041,7 @@ function covers(state, id, index) {
|
|
|
3025
3041
|
if (selection === null) return false;
|
|
3026
3042
|
if (selection.kind === "node") return selection.block === id;
|
|
3027
3043
|
if (selection.kind === "blocks") return within(state, index, [selection.anchor, selection.head]);
|
|
3028
|
-
if (!isCrossSelection(selection) ||
|
|
3044
|
+
if (!isCrossSelection(selection) || _chunkHOIDJEVIcjs.isTextFlow.call(void 0, schema, doc.blocks[index])) return false;
|
|
3029
3045
|
return within(state, index, [selection.anchor.block, selection.head.block]);
|
|
3030
3046
|
}
|
|
3031
3047
|
function blockStatus(state, id, choices = NO_CHOICES) {
|
|
@@ -3051,7 +3067,7 @@ var BlockShell = _react.memo.call(void 0, function BlockShell2({ block, renderer
|
|
|
3051
3067
|
const hidden = status === "hidden";
|
|
3052
3068
|
useIsomorphicLayoutEffect(() => {
|
|
3053
3069
|
const element = ref.current;
|
|
3054
|
-
return hidden || element
|
|
3070
|
+
return hidden || !element ? void 0 : controller.registerBlockElement(block.id, element);
|
|
3055
3071
|
}, [controller, block.id, hidden]);
|
|
3056
3072
|
if (hidden) return null;
|
|
3057
3073
|
const Renderer = rendererFor(renderers, block.type);
|
|
@@ -3065,11 +3081,11 @@ var BlockShell = _react.memo.call(void 0, function BlockShell2({ block, renderer
|
|
|
3065
3081
|
"data-quoin-block": "",
|
|
3066
3082
|
"data-block-id": block.id,
|
|
3067
3083
|
"data-type": block.type,
|
|
3068
|
-
"data-kind":
|
|
3084
|
+
"data-kind": _chunkBTBHHBVRcjs.optionalString.call(void 0, kind),
|
|
3069
3085
|
"data-indent": block.indent,
|
|
3070
|
-
"data-color":
|
|
3071
|
-
"data-bg":
|
|
3072
|
-
"data-align":
|
|
3086
|
+
"data-color": _chunkBTBHHBVRcjs.paletteOrUndefined.call(void 0, color),
|
|
3087
|
+
"data-bg": _chunkBTBHHBVRcjs.paletteOrUndefined.call(void 0, background),
|
|
3088
|
+
"data-align": _chunkBTBHHBVRcjs.alignOrUndefined.call(void 0, align),
|
|
3073
3089
|
style: { "--quoin-indent": block.indent },
|
|
3074
3090
|
tabIndex: -1,
|
|
3075
3091
|
"data-selected": status === "selected" ? "true" : void 0,
|
|
@@ -3109,7 +3125,7 @@ function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
|
3109
3125
|
"data-placeholder": readOnly ? void 0 : placeholder,
|
|
3110
3126
|
"aria-placeholder": readOnly ? void 0 : placeholder,
|
|
3111
3127
|
spellCheck: true,
|
|
3112
|
-
onClick: () => _optionalChain([ref, 'access',
|
|
3128
|
+
onClick: () => _optionalChain([ref, 'access', _228 => _228.current, 'optionalAccess', _229 => _229.focus, 'call', _230 => _230()])
|
|
3113
3129
|
}
|
|
3114
3130
|
);
|
|
3115
3131
|
}
|
|
@@ -3181,7 +3197,7 @@ function useBlockElements(blocks, renderers) {
|
|
|
3181
3197
|
const [made] = _react.useState.call(void 0, () => /* @__PURE__ */ new WeakMap());
|
|
3182
3198
|
return blocks.map((block) => {
|
|
3183
3199
|
const known2 = made.get(block);
|
|
3184
|
-
if (_optionalChain([known2, 'optionalAccess',
|
|
3200
|
+
if (_optionalChain([known2, 'optionalAccess', _231 => _231.renderers]) === renderers) return known2.element;
|
|
3185
3201
|
const element = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BlockShell, { block, renderers }, block.id);
|
|
3186
3202
|
made.set(block, { renderers, element });
|
|
3187
3203
|
return element;
|
|
@@ -3214,7 +3230,7 @@ function EditorView({
|
|
|
3214
3230
|
const blockIdScope = _react.useId.call(void 0, );
|
|
3215
3231
|
const blocks = useEditorState(controller, (state) => state.doc.blocks);
|
|
3216
3232
|
const shells = useBlockElements(blocks, renderers);
|
|
3217
|
-
useIsomorphicLayoutEffect(() => root.current
|
|
3233
|
+
useIsomorphicLayoutEffect(() => root.current ? controller.attach(root.current) : void 0, [controller]);
|
|
3218
3234
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QuoinEditorContext.Provider, { value: controller, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3219
3235
|
"div",
|
|
3220
3236
|
{
|
|
@@ -3224,7 +3240,7 @@ function EditorView({
|
|
|
3224
3240
|
role: "group",
|
|
3225
3241
|
"aria-label": label,
|
|
3226
3242
|
"aria-describedby": hintId,
|
|
3227
|
-
|
|
3243
|
+
onFocusCapture: (event) => focusOwners.set(event.target, controller),
|
|
3228
3244
|
children: [
|
|
3229
3245
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BlockDomIdScope.Provider, { value: blockIdScope, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UnsupportedBlockLabel.Provider, { value: unsupportedBlockLabel, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BlockPlaceholderContext.Provider, { value: blockPlaceholder, children: blocks.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EmptyDocumentHost, { placeholder, label: paragraphLabel }) : shells }) }) }),
|
|
3230
3246
|
children,
|
|
@@ -3282,5 +3298,6 @@ function EditorView({
|
|
|
3282
3298
|
|
|
3283
3299
|
|
|
3284
3300
|
|
|
3285
|
-
|
|
3286
|
-
|
|
3301
|
+
|
|
3302
|
+
exports.dispatchSelection = dispatchSelection; exports.wholeState = wholeState; exports.useEditorState = useEditorState; exports.useReadOnly = useReadOnly; exports.isCrossSelection = isCrossSelection; exports.NODE_ENTRY = NODE_ENTRY; exports.visibleBlockIndexes = visibleBlockIndexes; exports.drawnBlockCount = drawnBlockCount; exports.neighbourBlock = neighbourBlock; exports.moveToNeighbour = moveToNeighbour; exports.textDiff = textDiff; exports.domMapOf = domMapOf; exports.renderInline = renderInline; exports.domToPos = domToPos; exports.posToDom = posToDom; exports.caretFromPoint = caretFromPoint; exports.caretClientRect = caretClientRect; exports.lineEdgeRect = lineEdgeRect; exports.isOnFirstLine = isOnFirstLine; exports.isOnLastLine = isOnLastLine; exports.isComposingKey = isComposingKey; exports.NATIVE_INTERACTION = NATIVE_INTERACTION; exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect; exports.onBlock = onBlock; exports.listen = listen; exports.createAutoScroll = createAutoScroll; exports.hostKey = hostKey; exports.regionInline = regionInline; exports.handleCopy = handleCopy; exports.ViewController = ViewController; exports.useViewController = useViewController; exports.useQuoinEditor = useQuoinEditor; exports.useBlockDomId = useBlockDomId; exports.useRegionDomId = useRegionDomId; exports.focusOwners = focusOwners; exports.SelectionSink = SelectionSink; exports.EditableRegion = EditableRegion; exports.TaskCheckbox = TaskCheckbox; exports.useOrderedNumber = useOrderedNumber; exports.useToggleOpen = useToggleOpen; exports.ToggleChevron = ToggleChevron; exports.defaultRenderers = defaultRenderers; exports.VoidBlockFallback = VoidBlockFallback; exports.BlockShell = BlockShell; exports.EditorView = EditorView;
|
|
3303
|
+
//# sourceMappingURL=chunk-5M4QG3ZC.cjs.map
|