quoin-editor 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +15 -5
- package/dist/ai.cjs +66 -66
- package/dist/ai.js +5 -5
- package/dist/catalogue.cjs +20 -20
- package/dist/catalogue.js +12 -12
- package/dist/{chunk-BKEHG4QV.js → chunk-25HNTVEI.js} +3 -3
- package/dist/{chunk-BKEHG4QV.js.map → chunk-25HNTVEI.js.map} +1 -1
- package/dist/{chunk-TWFMNDOC.cjs → chunk-35CHEARK.cjs} +38 -38
- package/dist/{chunk-TWFMNDOC.cjs.map → chunk-35CHEARK.cjs.map} +1 -1
- package/dist/{chunk-KIU5MPZ4.js → chunk-4D7HZRNC.js} +3 -3
- package/dist/{chunk-KIU5MPZ4.js.map → chunk-4D7HZRNC.js.map} +1 -1
- package/dist/{chunk-TG5T7BEJ.js → chunk-4HFE3YFF.js} +6 -6
- package/dist/{chunk-TG5T7BEJ.js.map → chunk-4HFE3YFF.js.map} +1 -1
- package/dist/{chunk-K7E2DR5W.cjs → chunk-5ANJW76W.cjs} +20 -20
- package/dist/{chunk-K7E2DR5W.cjs.map → chunk-5ANJW76W.cjs.map} +1 -1
- package/dist/{chunk-RENKFSFD.cjs → chunk-A5LIN7FO.cjs} +26 -26
- package/dist/{chunk-RENKFSFD.cjs.map → chunk-A5LIN7FO.cjs.map} +1 -1
- package/dist/{chunk-TLMO46OV.cjs → chunk-BJIWN7BQ.cjs} +10 -10
- package/dist/{chunk-TLMO46OV.cjs.map → chunk-BJIWN7BQ.cjs.map} +1 -1
- package/dist/{chunk-OWX3Y5UU.js → chunk-BNUQ647G.js} +6 -6
- package/dist/{chunk-OWX3Y5UU.js.map → chunk-BNUQ647G.js.map} +1 -1
- package/dist/{chunk-MEXDDWJF.js → chunk-BR25RE7U.js} +5 -5
- package/dist/{chunk-MEXDDWJF.js.map → chunk-BR25RE7U.js.map} +1 -1
- package/dist/{chunk-PVCXTSUO.js → chunk-CCOPHCXX.js} +46 -6
- package/dist/chunk-CCOPHCXX.js.map +1 -0
- package/dist/{chunk-6X5A4DUQ.cjs → chunk-CZ5ZXBWC.cjs} +226 -227
- package/dist/chunk-CZ5ZXBWC.cjs.map +1 -0
- package/dist/{chunk-IQ2DE3Y3.cjs → chunk-DQV37F7J.cjs} +66 -66
- package/dist/{chunk-IQ2DE3Y3.cjs.map → chunk-DQV37F7J.cjs.map} +1 -1
- package/dist/{chunk-X4FDLUXJ.js → chunk-FOEEDJ5R.js} +5 -5
- package/dist/{chunk-X4FDLUXJ.js.map → chunk-FOEEDJ5R.js.map} +1 -1
- package/dist/{chunk-4F2IWBFM.cjs → chunk-G37GQ5JE.cjs} +4 -3
- package/dist/{chunk-4F2IWBFM.cjs.map → chunk-G37GQ5JE.cjs.map} +1 -1
- package/dist/{chunk-I4NEX6SZ.js → chunk-I7OOIEZZ.js} +5 -5
- package/dist/{chunk-I4NEX6SZ.js.map → chunk-I7OOIEZZ.js.map} +1 -1
- package/dist/{chunk-R45RJQRD.cjs → chunk-IGEWAL2J.cjs} +29 -29
- package/dist/{chunk-R45RJQRD.cjs.map → chunk-IGEWAL2J.cjs.map} +1 -1
- package/dist/{chunk-3BCP6ZUM.js → chunk-J552D3A7.js} +13 -14
- package/dist/chunk-J552D3A7.js.map +1 -0
- package/dist/{chunk-VNRBCUBV.cjs → chunk-JYKSWEXT.cjs} +6 -6
- package/dist/{chunk-VNRBCUBV.cjs.map → chunk-JYKSWEXT.cjs.map} +1 -1
- package/dist/{chunk-UMTKQVOX.cjs → chunk-K7JEN3KT.cjs} +4 -4
- package/dist/{chunk-UMTKQVOX.cjs.map → chunk-K7JEN3KT.cjs.map} +1 -1
- package/dist/{chunk-TN32PKUI.cjs → chunk-KMIWUFNM.cjs} +75 -75
- package/dist/{chunk-TN32PKUI.cjs.map → chunk-KMIWUFNM.cjs.map} +1 -1
- package/dist/{chunk-4EU4BTLZ.js → chunk-KXOAV7AT.js} +4 -4
- package/dist/{chunk-4EU4BTLZ.js.map → chunk-KXOAV7AT.js.map} +1 -1
- package/dist/{chunk-NNDLIP2C.cjs → chunk-OGBD74IR.cjs} +126 -86
- package/dist/chunk-OGBD74IR.cjs.map +1 -0
- package/dist/{chunk-PMJ3VCSR.js → chunk-SAPLIQF2.js} +4 -4
- package/dist/{chunk-PMJ3VCSR.js.map → chunk-SAPLIQF2.js.map} +1 -1
- package/dist/{chunk-UHAAYYMX.cjs → chunk-SCFW4JFT.cjs} +38 -38
- package/dist/{chunk-UHAAYYMX.cjs.map → chunk-SCFW4JFT.cjs.map} +1 -1
- package/dist/{chunk-IHTHOAUY.js → chunk-TARBFPWC.js} +6 -6
- package/dist/{chunk-IHTHOAUY.js.map → chunk-TARBFPWC.js.map} +1 -1
- package/dist/{chunk-WCAUPASG.js → chunk-Y7UKOBSY.js} +5 -5
- package/dist/{chunk-WCAUPASG.js.map → chunk-Y7UKOBSY.js.map} +1 -1
- package/dist/{chunk-I4CSCA3O.js → chunk-YCVNFRL3.js} +4 -4
- package/dist/{chunk-I4CSCA3O.js.map → chunk-YCVNFRL3.js.map} +1 -1
- package/dist/{chunk-EQKFQK3C.cjs → chunk-ZVCBTQA3.cjs} +10 -10
- package/dist/{chunk-EQKFQK3C.cjs.map → chunk-ZVCBTQA3.cjs.map} +1 -1
- package/dist/comments.cjs +48 -48
- package/dist/comments.js +4 -4
- package/dist/docx.cjs +1 -1
- package/dist/docx.js +1 -1
- package/dist/embed.cjs +6 -6
- package/dist/embed.js +4 -4
- package/dist/emoji.cjs +7 -7
- package/dist/emoji.js +4 -4
- package/dist/engine.cjs +43 -43
- package/dist/engine.js +1 -1
- package/dist/find.cjs +8 -8
- package/dist/find.js +4 -4
- package/dist/headless.cjs +59 -59
- package/dist/headless.d.cts +2 -2
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/index.cjs +71 -71
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/math.cjs +7 -7
- package/dist/math.js +5 -5
- package/dist/mention.cjs +7 -7
- package/dist/mention.js +5 -5
- package/dist/presence.cjs +33 -33
- package/dist/presence.js +5 -5
- package/dist/stats.cjs +7 -7
- package/dist/stats.d.cts +1 -1
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/table.cjs +23 -23
- package/dist/table.js +4 -4
- package/dist/toc.cjs +7 -7
- package/dist/toc.js +4 -4
- package/dist/{view-controller-BD1KwYfE.d.cts → view-controller-cxQJ5rQb.d.cts} +7 -0
- package/dist/{view-controller-y4cb60ue.d.ts → view-controller-zNqHm_Qg.d.ts} +7 -0
- package/dist/yjs.cjs +99 -99
- package/dist/yjs.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-3BCP6ZUM.js.map +0 -1
- package/dist/chunk-6X5A4DUQ.cjs.map +0 -1
- package/dist/chunk-NNDLIP2C.cjs.map +0 -1
- package/dist/chunk-PVCXTSUO.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkG37GQ5JE_cjs = require('./chunk-G37GQ5JE.cjs');
|
|
4
4
|
var chunkWZA5S5EJ_cjs = require('./chunk-WZA5S5EJ.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
@@ -34,7 +34,7 @@ function isCrossSelection(selection) {
|
|
|
34
34
|
}
|
|
35
35
|
function selectionDecorations(state, mode) {
|
|
36
36
|
if (mode !== "decorations" || !isCrossSelection(state.selection)) return [];
|
|
37
|
-
return
|
|
37
|
+
return chunkG37GQ5JE_cjs.markRanges(state).map(({ block, region, from, to }) => ({
|
|
38
38
|
kind: "inline",
|
|
39
39
|
block,
|
|
40
40
|
region,
|
|
@@ -339,8 +339,8 @@ function reconcileChildren(parent, specs) {
|
|
|
339
339
|
// src/view/dom/text-diff.ts
|
|
340
340
|
function textDiff(before, after, caretHint) {
|
|
341
341
|
if (before === after) return null;
|
|
342
|
-
const prefix =
|
|
343
|
-
const suffix =
|
|
342
|
+
const prefix = chunkG37GQ5JE_cjs.commonPrefix(before, after);
|
|
343
|
+
const suffix = chunkG37GQ5JE_cjs.commonSuffix(before, after);
|
|
344
344
|
const shared = Math.min(suffix, Math.min(before.length, after.length) - prefix);
|
|
345
345
|
const removed = before.length - prefix - shared;
|
|
346
346
|
const inserted = after.length - prefix - shared;
|
|
@@ -528,10 +528,10 @@ function readSelection(registry, domSelection, blockAt2 = () => void 0) {
|
|
|
528
528
|
if (!domSelection || !anchorNode || !focusNode) return null;
|
|
529
529
|
const anchor = domToPos(registry, anchorNode, domSelection.anchorOffset);
|
|
530
530
|
const head = domToPos(registry, focusNode, domSelection.focusOffset);
|
|
531
|
-
if (anchor && head) return
|
|
531
|
+
if (anchor && head) return chunkG37GQ5JE_cjs.textSelection(anchor, head);
|
|
532
532
|
if (anchor || head || registry.locate(anchorNode) || registry.locate(focusNode)) return null;
|
|
533
533
|
const block = blockAt2(anchorNode);
|
|
534
|
-
return block !== void 0 && block === blockAt2(focusNode) ?
|
|
534
|
+
return block !== void 0 && block === blockAt2(focusNode) ? chunkG37GQ5JE_cjs.nodeSelection(block) : null;
|
|
535
535
|
}
|
|
536
536
|
function selectBlock(domSelection, element) {
|
|
537
537
|
if (!element) return false;
|
|
@@ -548,7 +548,7 @@ function writeSelection(registry, selection, domSelection, blockElement) {
|
|
|
548
548
|
if (selection.kind !== "text") return false;
|
|
549
549
|
const { anchor, head } = selection;
|
|
550
550
|
if (anchor.block !== head.block || anchor.region !== head.region) return false;
|
|
551
|
-
if (
|
|
551
|
+
if (chunkG37GQ5JE_cjs.sameSelection(readSelection(registry, domSelection), selection)) return true;
|
|
552
552
|
const base = posToDom(registry, anchor, anchor.offset < head.offset ? 1 : -1);
|
|
553
553
|
const extent = posToDom(registry, head, head.offset < anchor.offset ? 1 : -1);
|
|
554
554
|
if (!base || !extent) return false;
|
|
@@ -610,8 +610,8 @@ var known = /* @__PURE__ */ new WeakMap();
|
|
|
610
610
|
function hidersOf(doc) {
|
|
611
611
|
let hiders = known.get(doc);
|
|
612
612
|
if (hiders === void 0) {
|
|
613
|
-
const first = doc.blocks.findIndex(
|
|
614
|
-
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null :
|
|
613
|
+
const first = doc.blocks.findIndex(chunkG37GQ5JE_cjs.isClosedToggle);
|
|
614
|
+
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null : chunkG37GQ5JE_cjs.hidingToggle(doc, index + 1));
|
|
615
615
|
known.set(doc, hiders);
|
|
616
616
|
}
|
|
617
617
|
return hiders;
|
|
@@ -620,7 +620,7 @@ var hidingToggleAt = (doc, index) => hidersOf(doc)[index] ?? null;
|
|
|
620
620
|
function isHiddenAt(doc, index, choices) {
|
|
621
621
|
if (choices.size === 0) return hidingToggleAt(doc, index) !== null;
|
|
622
622
|
const closed = (block) => block.type === "TOGGLE" && !shownOpen(block, choices);
|
|
623
|
-
return
|
|
623
|
+
return chunkG37GQ5JE_cjs.hidingToggle(doc, index + 1, closed) !== null;
|
|
624
624
|
}
|
|
625
625
|
var visibleBlockIndexes = (doc) => hidersOf(doc).flatMap((hider, index) => hider === null ? [index] : []);
|
|
626
626
|
function drawnBlockCount(doc, start = 0, end = doc.blocks.length) {
|
|
@@ -645,18 +645,18 @@ function neighbourBlock(doc, from, direction, accept = anyBlock) {
|
|
|
645
645
|
}
|
|
646
646
|
function entryEdge(controller, block, direction) {
|
|
647
647
|
const { doc, schema } = controller.editor.state;
|
|
648
|
-
const edge = direction < 0 ?
|
|
648
|
+
const edge = direction < 0 ? chunkG37GQ5JE_cjs.endOf(doc, schema, block) : chunkG37GQ5JE_cjs.startOf(doc, schema, block);
|
|
649
649
|
if (edge.kind !== "text") return edge;
|
|
650
650
|
const drawn = controller.registry.get(edge.head.block, edge.head.region) !== void 0;
|
|
651
|
-
return drawn && !entersAsNode(controller, block) ? edge :
|
|
651
|
+
return drawn && !entersAsNode(controller, block) ? edge : chunkG37GQ5JE_cjs.nodeSelection(block);
|
|
652
652
|
}
|
|
653
|
-
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ?
|
|
653
|
+
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ? chunkG37GQ5JE_cjs.nodeSelection(block) : null;
|
|
654
654
|
var canBeEntered = (controller) => (block) => {
|
|
655
655
|
const { schema } = controller.editor.state;
|
|
656
|
-
const region =
|
|
656
|
+
const region = chunkG37GQ5JE_cjs.isTextFlow(schema, block) ? chunkG37GQ5JE_cjs.primaryRegion(schema, block) : null;
|
|
657
657
|
return region === null || controller.registry.get(block.id, region) !== void 0 || entersAsNode(controller, block.id);
|
|
658
658
|
};
|
|
659
|
-
var holdsTextHead = (controller) => (block) =>
|
|
659
|
+
var holdsTextHead = (controller) => (block) => chunkG37GQ5JE_cjs.isTextFlow(controller.editor.state.schema, block) && entryEdge(controller, block.id, 1).kind === "text";
|
|
660
660
|
function neighbourHead(controller, from, direction) {
|
|
661
661
|
const target = neighbourBlock(controller.editor.state.doc, from, direction, holdsTextHead(controller));
|
|
662
662
|
const edge = target && entryEdge(controller, target.id, direction);
|
|
@@ -795,7 +795,7 @@ function createCrossBlockPointer(controller) {
|
|
|
795
795
|
let preventMouseDown = false;
|
|
796
796
|
const scroll = createAutoScroll(root, () => follow(last.x, last.y));
|
|
797
797
|
function select(selection) {
|
|
798
|
-
if (
|
|
798
|
+
if (chunkG37GQ5JE_cjs.sameSelection(selection, controller.editor.state.selection)) return;
|
|
799
799
|
dispatchSelection(controller, selection);
|
|
800
800
|
}
|
|
801
801
|
function startDragging() {
|
|
@@ -811,14 +811,14 @@ function createCrossBlockPointer(controller) {
|
|
|
811
811
|
if (current.anchor === null) return;
|
|
812
812
|
startDragging();
|
|
813
813
|
}
|
|
814
|
-
select(
|
|
814
|
+
select(chunkG37GQ5JE_cjs.textSelection(current.anchor, caretPosAt(controller, target, x, y)));
|
|
815
815
|
}
|
|
816
816
|
function followBlocks(current, x, y) {
|
|
817
817
|
if (!controller.dragging && Math.hypot(x - current.x, y - current.y) < DRAG_DISTANCE) return;
|
|
818
818
|
const block = blockAt(controller, x, y);
|
|
819
819
|
if (block === null) return;
|
|
820
820
|
startDragging();
|
|
821
|
-
select(
|
|
821
|
+
select(chunkG37GQ5JE_cjs.blockRangeSelection(current.start, block));
|
|
822
822
|
}
|
|
823
823
|
function follow(x, y) {
|
|
824
824
|
if (press?.kind === "text") followText(press, x, y);
|
|
@@ -854,9 +854,9 @@ function createCrossBlockPointer(controller) {
|
|
|
854
854
|
function pressWhole(block) {
|
|
855
855
|
if (entryEdge(controller, block, 1).kind !== "node") return;
|
|
856
856
|
const pressed = chunkWZA5S5EJ_cjs.blockById(controller.editor.state.doc, block);
|
|
857
|
-
if (pressed !== void 0 && !canBeEntered(controller)(pressed)) return select(
|
|
857
|
+
if (pressed !== void 0 && !canBeEntered(controller)(pressed)) return select(chunkG37GQ5JE_cjs.blockRangeSelection(block));
|
|
858
858
|
controller.nodeReveal.pressed(block);
|
|
859
|
-
select(
|
|
859
|
+
select(chunkG37GQ5JE_cjs.nodeSelection(block));
|
|
860
860
|
}
|
|
861
861
|
function onPointerDown(event) {
|
|
862
862
|
end();
|
|
@@ -898,7 +898,7 @@ function createCrossBlockPointer(controller) {
|
|
|
898
898
|
// src/view/selection/paint-selection.ts
|
|
899
899
|
var NAME = "quoin-selection";
|
|
900
900
|
function coveredRanges(controller) {
|
|
901
|
-
return
|
|
901
|
+
return chunkG37GQ5JE_cjs.markRanges(controller.editor.state).flatMap(({ block, region, from, to }) => {
|
|
902
902
|
const host = controller.registry.get(block, region);
|
|
903
903
|
const map = host && domMapOf(host);
|
|
904
904
|
if (!host || !map) return [];
|
|
@@ -969,7 +969,7 @@ function heldBySink(selection) {
|
|
|
969
969
|
}
|
|
970
970
|
var NO_TEXT = "\xA0";
|
|
971
971
|
function selectionText(state) {
|
|
972
|
-
const text =
|
|
972
|
+
const text = chunkG37GQ5JE_cjs.markRanges(state).map((range) => chunkWZA5S5EJ_cjs.inlinePlainText(chunkG37GQ5JE_cjs.rangeContent(state, range), state.schema)).join("\n");
|
|
973
973
|
return text === "" ? NO_TEXT : text;
|
|
974
974
|
}
|
|
975
975
|
var focusInPlace = (sink) => inPlace(sink, () => sink.focus({ preventScroll: true }));
|
|
@@ -1129,7 +1129,7 @@ function createElementSlot(changed) {
|
|
|
1129
1129
|
|
|
1130
1130
|
// src/view/controller/selection-element.ts
|
|
1131
1131
|
function elementFor({ doc }, selection, rendered) {
|
|
1132
|
-
const id =
|
|
1132
|
+
const id = chunkG37GQ5JE_cjs.headBlockId(selection);
|
|
1133
1133
|
const index = id === null ? void 0 : doc.index.get(id);
|
|
1134
1134
|
if (id === null || index === void 0) return void 0;
|
|
1135
1135
|
const hiding = hidingToggleAt(doc, index);
|
|
@@ -1142,7 +1142,7 @@ function selectionElement(state, rendered) {
|
|
|
1142
1142
|
if (doc.blocks.length === 0) return rendered.empty?.() ?? void 0;
|
|
1143
1143
|
const sink = heldBySink(selection) ? rendered.sink?.() : null;
|
|
1144
1144
|
if (sink) return sink;
|
|
1145
|
-
return elementFor(state, selection, rendered) ?? elementFor(state,
|
|
1145
|
+
return elementFor(state, selection, rendered) ?? elementFor(state, chunkG37GQ5JE_cjs.startOf(doc, schema, doc.blocks[0].id), rendered);
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
1148
|
// src/view/controller/tab-stop.ts
|
|
@@ -1195,6 +1195,31 @@ function createDrawnElements(hosts, state) {
|
|
|
1195
1195
|
};
|
|
1196
1196
|
}
|
|
1197
1197
|
|
|
1198
|
+
// src/view/controller/engagement.ts
|
|
1199
|
+
var chosenHere = (tr) => tr !== null && tr.selectionSet && !chunkG37GQ5JE_cjs.foreignOrigins.includes(tr.origin);
|
|
1200
|
+
function createEngagement(editor) {
|
|
1201
|
+
let engaged = false;
|
|
1202
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1203
|
+
function engage() {
|
|
1204
|
+
if (engaged) return;
|
|
1205
|
+
engaged = true;
|
|
1206
|
+
for (const listener of [...listeners]) listener();
|
|
1207
|
+
}
|
|
1208
|
+
editor.subscribe((_, tr) => {
|
|
1209
|
+
if (chosenHere(tr)) engage();
|
|
1210
|
+
});
|
|
1211
|
+
return {
|
|
1212
|
+
get engaged() {
|
|
1213
|
+
return engaged;
|
|
1214
|
+
},
|
|
1215
|
+
engage,
|
|
1216
|
+
subscribe(listener) {
|
|
1217
|
+
listeners.add(listener);
|
|
1218
|
+
return () => void listeners.delete(listener);
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1198
1223
|
// src/view/controller/focus-ownership.ts
|
|
1199
1224
|
function hasFocus(controller, doc) {
|
|
1200
1225
|
const active = doc?.activeElement ?? null;
|
|
@@ -1209,9 +1234,9 @@ function ownsFocus(controller, doc) {
|
|
|
1209
1234
|
function focusTarget(state, target) {
|
|
1210
1235
|
const { doc, schema, selection } = state;
|
|
1211
1236
|
if (doc.blocks.length === 0) return null;
|
|
1212
|
-
if (target === "end") return
|
|
1213
|
-
if (target === "start" || target === void 0 && selection === null) return
|
|
1214
|
-
return target === void 0 ? selection :
|
|
1237
|
+
if (target === "end") return chunkG37GQ5JE_cjs.endOf(doc, schema, doc.blocks[doc.blocks.length - 1].id);
|
|
1238
|
+
if (target === "start" || target === void 0 && selection === null) return chunkG37GQ5JE_cjs.startOf(doc, schema, doc.blocks[0].id);
|
|
1239
|
+
return target === void 0 ? selection : chunkG37GQ5JE_cjs.textSelection(target);
|
|
1215
1240
|
}
|
|
1216
1241
|
|
|
1217
1242
|
// src/view/controller/host-decorations.ts
|
|
@@ -1304,7 +1329,7 @@ function createOutsideChanges(editorHasFocus, movedFrom) {
|
|
|
1304
1329
|
}
|
|
1305
1330
|
const from = moved ?? (outside && !settled ? movedFrom(tr.before.selection) : null);
|
|
1306
1331
|
settled ||= outside;
|
|
1307
|
-
moved = from &&
|
|
1332
|
+
moved = from && chunkG37GQ5JE_cjs.mapSelection(from, (pos, assoc) => tr.mapPos(pos, assoc), tr.before.doc);
|
|
1308
1333
|
},
|
|
1309
1334
|
takeFocused() {
|
|
1310
1335
|
const value = focused;
|
|
@@ -1397,7 +1422,7 @@ function handleCopy(controller, event, cut) {
|
|
|
1397
1422
|
clipboardData.setData("text/plain", copied.text);
|
|
1398
1423
|
clipboardData.setData("text/html", wrapSliceHTML(copied.html, copied.json));
|
|
1399
1424
|
clipboardData.setData(QUOIN_SLICE_TYPE, copied.json);
|
|
1400
|
-
if (cut) controller.run(
|
|
1425
|
+
if (cut) controller.run(chunkG37GQ5JE_cjs.deleteSelection);
|
|
1401
1426
|
}
|
|
1402
1427
|
function handlePaste(controller, event) {
|
|
1403
1428
|
if (!event.clipboardData) return;
|
|
@@ -1429,7 +1454,7 @@ function handleDrop(controller, event) {
|
|
|
1429
1454
|
return;
|
|
1430
1455
|
}
|
|
1431
1456
|
const pos = dropPos(controller, event.clientX, event.clientY);
|
|
1432
|
-
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
1457
|
+
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(chunkG37GQ5JE_cjs.textSelection(pos)).setOrigin("drop"));
|
|
1433
1458
|
pasteTransfer(controller, dataTransfer);
|
|
1434
1459
|
}
|
|
1435
1460
|
function handleDragOver(event) {
|
|
@@ -1559,29 +1584,29 @@ function createSinkComposition(controller, settled = () => {
|
|
|
1559
1584
|
var LINE_BREAK = "\n";
|
|
1560
1585
|
var transposeChars = (state, dispatch) => {
|
|
1561
1586
|
const { selection } = state;
|
|
1562
|
-
if (selection?.kind !== "text" || !
|
|
1587
|
+
if (selection?.kind !== "text" || !chunkG37GQ5JE_cjs.isCollapsed(selection)) return false;
|
|
1563
1588
|
const { head } = selection;
|
|
1564
1589
|
const inline = chunkWZA5S5EJ_cjs.blockById(state.doc, head.block)?.regions[head.region];
|
|
1565
1590
|
if (inline === void 0) return false;
|
|
1566
1591
|
const value = chunkWZA5S5EJ_cjs.inlineText(inline);
|
|
1567
1592
|
const atLineEnd = head.offset === value.length || value[head.offset] === LINE_BREAK;
|
|
1568
|
-
const end = atLineEnd ? head.offset :
|
|
1569
|
-
const middle =
|
|
1570
|
-
const start =
|
|
1593
|
+
const end = atLineEnd ? head.offset : chunkG37GQ5JE_cjs.nextGraphemeOffset(value, head.offset);
|
|
1594
|
+
const middle = chunkG37GQ5JE_cjs.prevGraphemeOffset(value, end);
|
|
1595
|
+
const start = chunkG37GQ5JE_cjs.prevGraphemeOffset(value, middle);
|
|
1571
1596
|
if (start === middle || value.slice(start, end).includes(LINE_BREAK)) return false;
|
|
1572
1597
|
const swapped = [...chunkWZA5S5EJ_cjs.sliceInline(inline, middle, end), ...chunkWZA5S5EJ_cjs.sliceInline(inline, start, middle)];
|
|
1573
|
-
const tr = new
|
|
1574
|
-
tr.step(
|
|
1575
|
-
dispatch?.(tr.setSelection(
|
|
1598
|
+
const tr = new chunkG37GQ5JE_cjs.Transaction(state).setOrigin("input");
|
|
1599
|
+
tr.step(chunkG37GQ5JE_cjs.replaceInlineStep(head.block, head.region, start, end, swapped));
|
|
1600
|
+
dispatch?.(tr.setSelection(chunkG37GQ5JE_cjs.textSelection({ ...head, offset: end })));
|
|
1576
1601
|
return true;
|
|
1577
1602
|
};
|
|
1578
1603
|
|
|
1579
1604
|
// src/view/input/replace-range.ts
|
|
1580
1605
|
function replaceRange(editor, range, text, withRules) {
|
|
1581
1606
|
const dispatch = (tr) => editor.dispatch(tr);
|
|
1582
|
-
dispatch(editor.createTransaction().setSelection(
|
|
1583
|
-
if (text === "") return
|
|
1584
|
-
return withRules ? editor.insertText(text) :
|
|
1607
|
+
dispatch(editor.createTransaction().setSelection(chunkG37GQ5JE_cjs.textSelection(range.from, range.to)).setOrigin("input"));
|
|
1608
|
+
if (text === "") return chunkG37GQ5JE_cjs.deleteSelection(editor.state, (tr) => dispatch(tr.setOrigin("input")));
|
|
1609
|
+
return withRules ? editor.insertText(text) : chunkG37GQ5JE_cjs.insertText(text, { origin: "input" })(editor.state, dispatch);
|
|
1585
1610
|
}
|
|
1586
1611
|
|
|
1587
1612
|
// src/view/input/target-range.ts
|
|
@@ -1592,13 +1617,13 @@ function targetRangeToModel(controller, event) {
|
|
|
1592
1617
|
const to = domToPos(controller.registry, range.endContainer, range.endOffset);
|
|
1593
1618
|
return from && to && { from, to };
|
|
1594
1619
|
}
|
|
1595
|
-
var isEmpty = ({ from, to }) =>
|
|
1620
|
+
var isEmpty = ({ from, to }) => chunkG37GQ5JE_cjs.sameSelection(chunkG37GQ5JE_cjs.textSelection(from), chunkG37GQ5JE_cjs.textSelection(to));
|
|
1596
1621
|
function targetBeyondSelection(controller, event) {
|
|
1597
1622
|
const range = targetRangeToModel(controller, event);
|
|
1598
1623
|
if (range === null || isEmpty(range)) return null;
|
|
1599
1624
|
const { doc, selection } = controller.editor.state;
|
|
1600
|
-
const selected =
|
|
1601
|
-
const same = selected !== null &&
|
|
1625
|
+
const selected = chunkG37GQ5JE_cjs.selectionRange(doc, selection);
|
|
1626
|
+
const same = selected !== null && chunkG37GQ5JE_cjs.sameSelection(chunkG37GQ5JE_cjs.textSelection(selected.from, selected.to), chunkG37GQ5JE_cjs.textSelection(range.from, range.to));
|
|
1602
1627
|
return same ? null : range;
|
|
1603
1628
|
}
|
|
1604
1629
|
|
|
@@ -1620,34 +1645,34 @@ function insertTypedText(controller, event) {
|
|
|
1620
1645
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1621
1646
|
}
|
|
1622
1647
|
function deleteContentBackward(controller, event) {
|
|
1623
|
-
if (!controller.run(
|
|
1648
|
+
if (!controller.run(chunkG37GQ5JE_cjs.undoInputRule)) targetOr(chunkG37GQ5JE_cjs.deleteBackward)(controller, event);
|
|
1624
1649
|
}
|
|
1625
1650
|
function insertReplacementText(controller, event) {
|
|
1626
1651
|
const text = event.dataTransfer?.getData("text/plain") || event.data;
|
|
1627
1652
|
if (!text) return;
|
|
1628
1653
|
const range = targetRangeToModel(controller, event);
|
|
1629
|
-
if (range === null) controller.run(
|
|
1654
|
+
if (range === null) controller.run(chunkG37GQ5JE_cjs.insertText(text, { origin: "input" }));
|
|
1630
1655
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1631
1656
|
}
|
|
1632
1657
|
var actions = {
|
|
1633
1658
|
insertText: insertTypedText,
|
|
1634
1659
|
insertReplacementText,
|
|
1635
1660
|
insertParagraph: (controller) => void controller.edit(() => controller.editor.handleKey(ENTER)),
|
|
1636
|
-
insertLineBreak: run(
|
|
1661
|
+
insertLineBreak: run(chunkG37GQ5JE_cjs.insertHardBreak),
|
|
1637
1662
|
deleteContentBackward,
|
|
1638
|
-
deleteContentForward: targetOr(
|
|
1639
|
-
deleteWordBackward: targetOr(
|
|
1640
|
-
deleteWordForward: targetOr(
|
|
1641
|
-
deleteSoftLineBackward: targetOr(
|
|
1642
|
-
deleteHardLineBackward: targetOr(
|
|
1643
|
-
deleteSoftLineForward: targetOr(
|
|
1644
|
-
deleteHardLineForward: targetOr(
|
|
1645
|
-
formatBold: run(
|
|
1646
|
-
formatItalic: run(
|
|
1647
|
-
formatUnderline: run(
|
|
1648
|
-
formatStrikeThrough: run(
|
|
1649
|
-
historyUndo: run(
|
|
1650
|
-
historyRedo: run(
|
|
1663
|
+
deleteContentForward: targetOr(chunkG37GQ5JE_cjs.deleteForward),
|
|
1664
|
+
deleteWordBackward: targetOr(chunkG37GQ5JE_cjs.deleteWordBackward),
|
|
1665
|
+
deleteWordForward: targetOr(chunkG37GQ5JE_cjs.deleteWordForward),
|
|
1666
|
+
deleteSoftLineBackward: targetOr(chunkG37GQ5JE_cjs.deleteToLineStart),
|
|
1667
|
+
deleteHardLineBackward: targetOr(chunkG37GQ5JE_cjs.deleteToLineStart),
|
|
1668
|
+
deleteSoftLineForward: targetOr(chunkG37GQ5JE_cjs.deleteToLineEnd),
|
|
1669
|
+
deleteHardLineForward: targetOr(chunkG37GQ5JE_cjs.deleteToLineEnd),
|
|
1670
|
+
formatBold: run(chunkG37GQ5JE_cjs.toggleMark("bold")),
|
|
1671
|
+
formatItalic: run(chunkG37GQ5JE_cjs.toggleMark("italic")),
|
|
1672
|
+
formatUnderline: run(chunkG37GQ5JE_cjs.toggleMark("underline")),
|
|
1673
|
+
formatStrikeThrough: run(chunkG37GQ5JE_cjs.toggleMark("strike")),
|
|
1674
|
+
historyUndo: run(chunkG37GQ5JE_cjs.undo),
|
|
1675
|
+
historyRedo: run(chunkG37GQ5JE_cjs.redo),
|
|
1651
1676
|
insertTranspose: run(transposeChars),
|
|
1652
1677
|
insertFromPaste: leaveToHandlers,
|
|
1653
1678
|
insertFromDrop: leaveToHandlers,
|
|
@@ -1928,7 +1953,7 @@ function createDomInputFallback(controller) {
|
|
|
1928
1953
|
|
|
1929
1954
|
// src/view/navigation/cross-moves.ts
|
|
1930
1955
|
function moveHead(controller, { anchor }, head) {
|
|
1931
|
-
dispatchSelection(controller,
|
|
1956
|
+
dispatchSelection(controller, chunkG37GQ5JE_cjs.textSelection(anchor, head));
|
|
1932
1957
|
return true;
|
|
1933
1958
|
}
|
|
1934
1959
|
function blockOf(controller, { block }) {
|
|
@@ -1936,25 +1961,25 @@ function blockOf(controller, { block }) {
|
|
|
1936
1961
|
return doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, block)];
|
|
1937
1962
|
}
|
|
1938
1963
|
function collapseCross(controller, selection, direction) {
|
|
1939
|
-
const { from, to } =
|
|
1940
|
-
dispatchSelection(controller,
|
|
1964
|
+
const { from, to } = chunkG37GQ5JE_cjs.selectionRange(controller.editor.state.doc, selection);
|
|
1965
|
+
dispatchSelection(controller, chunkG37GQ5JE_cjs.textSelection(direction < 0 ? from : to));
|
|
1941
1966
|
return true;
|
|
1942
1967
|
}
|
|
1943
1968
|
function crossHeadVertically(controller, selection, direction) {
|
|
1944
1969
|
const { head } = selection;
|
|
1945
1970
|
const edge = neighbourHead(controller, head.block, direction);
|
|
1946
1971
|
if (edge !== null) {
|
|
1947
|
-
const end2 =
|
|
1972
|
+
const end2 = chunkG37GQ5JE_cjs.regionLength(blockOf(controller, edge), edge.region);
|
|
1948
1973
|
return moveHead(controller, selection, { ...edge, offset: Math.min(head.offset, end2) });
|
|
1949
1974
|
}
|
|
1950
|
-
const end =
|
|
1975
|
+
const end = chunkG37GQ5JE_cjs.regionLength(blockOf(controller, head), head.region);
|
|
1951
1976
|
return moveHead(controller, selection, { ...head, offset: direction < 0 ? 0 : end });
|
|
1952
1977
|
}
|
|
1953
1978
|
function crossHeadHorizontally(controller, selection, direction) {
|
|
1954
1979
|
const { head } = selection;
|
|
1955
1980
|
const text = chunkWZA5S5EJ_cjs.inlineText(blockOf(controller, head).regions[head.region] ?? []);
|
|
1956
1981
|
if (direction < 0 ? head.offset > 0 : head.offset < text.length) {
|
|
1957
|
-
const offset = direction < 0 ?
|
|
1982
|
+
const offset = direction < 0 ? chunkG37GQ5JE_cjs.prevGraphemeOffset(text, head.offset) : chunkG37GQ5JE_cjs.nextGraphemeOffset(text, head.offset);
|
|
1958
1983
|
return moveHead(controller, selection, { ...head, offset });
|
|
1959
1984
|
}
|
|
1960
1985
|
const edge = neighbourHead(controller, head.block, direction);
|
|
@@ -1973,9 +1998,9 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
1973
1998
|
const move = extend ? crossHeadHorizontally : collapseCross;
|
|
1974
1999
|
return move(controller, selection, direction);
|
|
1975
2000
|
}
|
|
1976
|
-
if (!extend && !
|
|
2001
|
+
if (!extend && !chunkG37GQ5JE_cjs.isCollapsed(selection)) return false;
|
|
1977
2002
|
const { head } = selection;
|
|
1978
|
-
const length =
|
|
2003
|
+
const length = chunkG37GQ5JE_cjs.regionLength(doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, head.block)], head.region);
|
|
1979
2004
|
if (direction < 0 ? head.offset > 0 : head.offset < length) return false;
|
|
1980
2005
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
1981
2006
|
if (own2 !== null) {
|
|
@@ -2081,12 +2106,12 @@ function caretAtGoal(controller, host, at, y) {
|
|
|
2081
2106
|
}
|
|
2082
2107
|
function landAtGoal(controller, block, direction) {
|
|
2083
2108
|
const { schema } = controller.editor.state;
|
|
2084
|
-
const region =
|
|
2109
|
+
const region = chunkG37GQ5JE_cjs.isTextFlow(schema, block) ? chunkG37GQ5JE_cjs.primaryRegion(schema, block) : null;
|
|
2085
2110
|
const host = region === null ? void 0 : controller.registry.get(block.id, region);
|
|
2086
2111
|
if (!host || region === null || controller.goalX === null) return null;
|
|
2087
2112
|
const line = lineInView(host, direction < 0);
|
|
2088
2113
|
const pos = line && caretAtGoal(controller, host, { block: block.id, region }, line.top + line.height / 2);
|
|
2089
|
-
return pos ?
|
|
2114
|
+
return pos ? chunkG37GQ5JE_cjs.textSelection(pos) : null;
|
|
2090
2115
|
}
|
|
2091
2116
|
function moveInHost(controller, host, head, caret, direction) {
|
|
2092
2117
|
const { goalX } = controller;
|
|
@@ -2105,7 +2130,7 @@ function landing(controller, { head }, direction, extend) {
|
|
|
2105
2130
|
controller.goalX ??= caret?.left ?? null;
|
|
2106
2131
|
if (!(direction < 0 ? isOnFirstLine(host, point) : isOnLastLine(host, point))) {
|
|
2107
2132
|
const pos = moveInHost(controller, host, head, caret, direction);
|
|
2108
|
-
return pos &&
|
|
2133
|
+
return pos && chunkG37GQ5JE_cjs.textSelection(pos);
|
|
2109
2134
|
}
|
|
2110
2135
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2111
2136
|
if (own2 !== null) return own2;
|
|
@@ -2127,7 +2152,7 @@ function moveText(controller, selection, direction, extend) {
|
|
|
2127
2152
|
function extendBlocks(controller, { anchor, head }, direction) {
|
|
2128
2153
|
const next = neighbourBlock(controller.editor.state.doc, head, direction);
|
|
2129
2154
|
if (next === null) return false;
|
|
2130
|
-
dispatchSelection(controller,
|
|
2155
|
+
dispatchSelection(controller, chunkG37GQ5JE_cjs.blockRangeSelection(anchor, next.id));
|
|
2131
2156
|
return true;
|
|
2132
2157
|
}
|
|
2133
2158
|
function moveVertically(controller, direction, extend) {
|
|
@@ -2143,8 +2168,8 @@ function moveVertically(controller, direction, extend) {
|
|
|
2143
2168
|
// src/view/input/flip-block.ts
|
|
2144
2169
|
var isTask = ({ type, attrs }) => type === "MARKDOWN" && attrs.kind === "task";
|
|
2145
2170
|
function flipCommand(block) {
|
|
2146
|
-
if (isTask(block)) return
|
|
2147
|
-
return block.type === "TOGGLE" ?
|
|
2171
|
+
if (isTask(block)) return chunkG37GQ5JE_cjs.toggleTask;
|
|
2172
|
+
return block.type === "TOGGLE" ? chunkG37GQ5JE_cjs.setAttrs({ open: block.attrs.open !== true }) : null;
|
|
2148
2173
|
}
|
|
2149
2174
|
var toggleState = (open) => open ? "expanded" : "collapsed";
|
|
2150
2175
|
function stateName(block) {
|
|
@@ -2242,7 +2267,7 @@ function attachInput(controller, root) {
|
|
|
2242
2267
|
const { editor } = controller;
|
|
2243
2268
|
let { selection } = editor.state;
|
|
2244
2269
|
const stop = editor.subscribe((_, tr) => {
|
|
2245
|
-
if (tr && selection) selection =
|
|
2270
|
+
if (tr && selection) selection = chunkG37GQ5JE_cjs.mapSelection(selection, (pos, assoc) => tr.mapPos(pos, assoc));
|
|
2246
2271
|
});
|
|
2247
2272
|
fallback.flush();
|
|
2248
2273
|
stop();
|
|
@@ -2399,7 +2424,7 @@ function bindRoot(controller, root, cross, committed) {
|
|
|
2399
2424
|
function movedSelection(controller, doc, model) {
|
|
2400
2425
|
if (controller.composingKey !== null || controller.dragging || !doc || !ownsFocus(controller, doc)) return null;
|
|
2401
2426
|
const selection = readSelection(controller.registry, doc.getSelection(), (node) => controller.blockAt(node));
|
|
2402
|
-
return selection === null ||
|
|
2427
|
+
return selection === null || chunkG37GQ5JE_cjs.sameSelection(selection, model) ? null : selection;
|
|
2403
2428
|
}
|
|
2404
2429
|
function writeModelSelection(controller, doc, moved, local) {
|
|
2405
2430
|
const domSelection = doc?.getSelection();
|
|
@@ -2430,6 +2455,7 @@ var ViewController = class {
|
|
|
2430
2455
|
keyInterceptors = /* @__PURE__ */ new Set();
|
|
2431
2456
|
nodeReveal = createNodeReveal((id) => this.blockElement(id));
|
|
2432
2457
|
announcer = createAnnouncer(() => this.#said);
|
|
2458
|
+
engagement;
|
|
2433
2459
|
isMac;
|
|
2434
2460
|
onFiles;
|
|
2435
2461
|
goalX = null;
|
|
@@ -2455,9 +2481,10 @@ var ViewController = class {
|
|
|
2455
2481
|
options.editor.subscribe((state, tr) => {
|
|
2456
2482
|
if (tr?.origin !== "remote") this.#said = state;
|
|
2457
2483
|
});
|
|
2484
|
+
this.engagement = createEngagement(options.editor);
|
|
2458
2485
|
this.#flush = options.flush ?? runNow;
|
|
2459
2486
|
this.onFiles = options.onFiles;
|
|
2460
|
-
this.isMac = options.isMac ??
|
|
2487
|
+
this.isMac = options.isMac ?? chunkG37GQ5JE_cjs.detectMac();
|
|
2461
2488
|
const decorationsOf = (block, region) => this.decorationsFor(block, region);
|
|
2462
2489
|
const drain = (element) => this.#binding?.input.drain(element);
|
|
2463
2490
|
this.#hosts = createHostRenderer(options.editor, options.render, decorationsOf, drain);
|
|
@@ -2610,7 +2637,7 @@ var ViewController = class {
|
|
|
2610
2637
|
focus(target) {
|
|
2611
2638
|
const { editor } = this;
|
|
2612
2639
|
const selection = focusTarget(editor.state, target);
|
|
2613
|
-
if (selection !== null && !
|
|
2640
|
+
if (selection !== null && !chunkG37GQ5JE_cjs.sameSelection(selection, editor.state.selection)) dispatchSelection(this, selection);
|
|
2614
2641
|
this.#takeFocus();
|
|
2615
2642
|
this.syncSelectionToDom();
|
|
2616
2643
|
}
|
|
@@ -2658,7 +2685,7 @@ function useQuoinEditor(options) {
|
|
|
2658
2685
|
const { blocks, readOnly = false } = options;
|
|
2659
2686
|
const callbacks = react.useRef(options);
|
|
2660
2687
|
const [controller] = react.useState(() => {
|
|
2661
|
-
const editor =
|
|
2688
|
+
const editor = chunkG37GQ5JE_cjs.createEditor({
|
|
2662
2689
|
blocks,
|
|
2663
2690
|
extensions: options.extensions,
|
|
2664
2691
|
onChange: (next) => callbacks.current.onChange(next),
|
|
@@ -2725,7 +2752,7 @@ var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && att
|
|
|
2725
2752
|
var BlockPlaceholderContext = react.createContext(headingPlaceholder);
|
|
2726
2753
|
function regionPlaceholder(state, blockId, region, placeholderOf) {
|
|
2727
2754
|
const block = chunkWZA5S5EJ_cjs.blockById(state.doc, blockId);
|
|
2728
|
-
return block !== void 0 &&
|
|
2755
|
+
return block !== void 0 && chunkG37GQ5JE_cjs.primaryRegion(state.schema, block) === region ? placeholderOf(state, block) : void 0;
|
|
2729
2756
|
}
|
|
2730
2757
|
var samePainted = (a, b) => a.inline === b.inline && a.placeholder === b.placeholder && sameDecorations(a.decorations, b.decorations);
|
|
2731
2758
|
function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
@@ -2781,7 +2808,7 @@ var CalloutBlock = ({ block }) => {
|
|
|
2781
2808
|
// src/view/react/block-command.ts
|
|
2782
2809
|
function onBlock(id, command) {
|
|
2783
2810
|
return (state, dispatch) => {
|
|
2784
|
-
const { ok, tr } =
|
|
2811
|
+
const { ok, tr } = chunkG37GQ5JE_cjs.runCommands(state, [chunkG37GQ5JE_cjs.setSelection(chunkG37GQ5JE_cjs.blockRangeSelection(id)), command]);
|
|
2785
2812
|
if (!ok || tr === null) return false;
|
|
2786
2813
|
dispatch?.(tr.setSelection(state.selection));
|
|
2787
2814
|
return true;
|
|
@@ -2984,7 +3011,7 @@ function covers(state, id, index) {
|
|
|
2984
3011
|
if (selection === null) return false;
|
|
2985
3012
|
if (selection.kind === "node") return selection.block === id;
|
|
2986
3013
|
if (selection.kind === "blocks") return within(state, index, [selection.anchor, selection.head]);
|
|
2987
|
-
if (!isCrossSelection(selection) ||
|
|
3014
|
+
if (!isCrossSelection(selection) || chunkG37GQ5JE_cjs.isTextFlow(schema, doc.blocks[index])) return false;
|
|
2988
3015
|
return within(state, index, [selection.anchor.block, selection.head.block]);
|
|
2989
3016
|
}
|
|
2990
3017
|
function blockStatus(state, id, choices = NO_CHOICES) {
|
|
@@ -2993,6 +3020,13 @@ function blockStatus(state, id, choices = NO_CHOICES) {
|
|
|
2993
3020
|
if (isHiddenAt(state.doc, index, choices)) return "hidden";
|
|
2994
3021
|
return covers(state, id, index) ? "selected" : "plain";
|
|
2995
3022
|
}
|
|
3023
|
+
var unwatched = () => () => {
|
|
3024
|
+
};
|
|
3025
|
+
function useEngaged(controller, watching) {
|
|
3026
|
+
const { engagement } = controller;
|
|
3027
|
+
const read = react.useCallback(() => engagement.engaged, [engagement]);
|
|
3028
|
+
return react.useSyncExternalStore(watching ? engagement.subscribe : unwatched, read, read);
|
|
3029
|
+
}
|
|
2996
3030
|
function safeAttrs(decorations) {
|
|
2997
3031
|
const attrs = Object.assign({}, ...decorations.map((decoration) => decoration.attrs));
|
|
2998
3032
|
for (const name of Object.keys(attrs)) if (!/^(data|aria)-/.test(name)) delete attrs[name];
|
|
@@ -3008,6 +3042,7 @@ var BlockShell = react.memo(function BlockShell2({ block, renderers }) {
|
|
|
3008
3042
|
const domId = useBlockDomId();
|
|
3009
3043
|
const choices = useReaderChoices(controller);
|
|
3010
3044
|
const status = useEditorState(controller, (state) => blockStatus(state, block.id, choices));
|
|
3045
|
+
const engaged = useEngaged(controller, status === "selected");
|
|
3011
3046
|
const decorations = useEditorState(controller, () => hostDecorations(controller.editor, block.id, ""), sameDecorations);
|
|
3012
3047
|
const hidden = status === "hidden";
|
|
3013
3048
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -3033,7 +3068,7 @@ var BlockShell = react.memo(function BlockShell2({ block, renderers }) {
|
|
|
3033
3068
|
"data-align": chunkWZA5S5EJ_cjs.alignOrUndefined(align),
|
|
3034
3069
|
style: { "--quoin-indent": block.indent },
|
|
3035
3070
|
tabIndex: -1,
|
|
3036
|
-
"data-selected": status === "selected" ? "true" : void 0,
|
|
3071
|
+
"data-selected": status === "selected" && engaged ? "true" : void 0,
|
|
3037
3072
|
children: /* @__PURE__ */ jsxRuntime.jsx(BlockErrorBoundary, { block, renderer: Renderer, children: /* @__PURE__ */ jsxRuntime.jsx(Renderer, { block, controller }) })
|
|
3038
3073
|
}
|
|
3039
3074
|
);
|
|
@@ -3084,10 +3119,10 @@ function selectionAnnouncement({ doc, selection }, blocksSelected) {
|
|
|
3084
3119
|
const count = drawnBlockCount(doc, Math.min(first, last), Math.max(first, last) + 1);
|
|
3085
3120
|
return { key: `${selection.kind}:${anchor}:${head}`, message: blocksSelected(count) };
|
|
3086
3121
|
}
|
|
3087
|
-
function heardNow({ editor, announcer }, blocksSelected) {
|
|
3122
|
+
function heardNow({ editor, announcer, engagement }, blocksSelected) {
|
|
3088
3123
|
const spoken = announcer.current();
|
|
3089
3124
|
if (spoken !== null) return { key: `said:${spoken.serial}`, message: spoken.message };
|
|
3090
|
-
return selectionAnnouncement(editor.state, blocksSelected);
|
|
3125
|
+
return engagement.engaged ? selectionAnnouncement(editor.state, blocksSelected) : SILENCE;
|
|
3091
3126
|
}
|
|
3092
3127
|
function LiveRegion({ blocksSelected }) {
|
|
3093
3128
|
const controller = useViewController();
|
|
@@ -3095,9 +3130,11 @@ function LiveRegion({ blocksSelected }) {
|
|
|
3095
3130
|
(notify) => {
|
|
3096
3131
|
const stopState = controller.editor.subscribe(() => notify());
|
|
3097
3132
|
const stopSpoken = controller.announcer.subscribe(notify);
|
|
3133
|
+
const stopEngaged = controller.engagement.subscribe(notify);
|
|
3098
3134
|
return () => {
|
|
3099
3135
|
stopState();
|
|
3100
3136
|
stopSpoken();
|
|
3137
|
+
stopEngaged();
|
|
3101
3138
|
};
|
|
3102
3139
|
},
|
|
3103
3140
|
[controller]
|
|
@@ -3169,6 +3206,9 @@ function EditorView({
|
|
|
3169
3206
|
"aria-label": label,
|
|
3170
3207
|
"aria-describedby": hintId,
|
|
3171
3208
|
onFocusCapture: (event) => focusOwners.set(event.target, controller),
|
|
3209
|
+
onFocus: (event) => {
|
|
3210
|
+
if (focusOwners.get(event.target) === controller) controller.engagement.engage();
|
|
3211
|
+
},
|
|
3172
3212
|
children: [
|
|
3173
3213
|
/* @__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 }) }) }) }),
|
|
3174
3214
|
children,
|
|
@@ -3227,5 +3267,5 @@ exports.useToggleOpen = useToggleOpen;
|
|
|
3227
3267
|
exports.useViewController = useViewController;
|
|
3228
3268
|
exports.visibleBlockIndexes = visibleBlockIndexes;
|
|
3229
3269
|
exports.wholeState = wholeState;
|
|
3230
|
-
//# sourceMappingURL=chunk-
|
|
3231
|
-
//# sourceMappingURL=chunk-
|
|
3270
|
+
//# sourceMappingURL=chunk-OGBD74IR.cjs.map
|
|
3271
|
+
//# sourceMappingURL=chunk-OGBD74IR.cjs.map
|