quoin-editor 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/ai.cjs +168 -249
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +37 -121
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +28 -43
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +20 -37
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
- package/dist/chunk-2EQ6FKSK.js.map +1 -0
- package/dist/{chunk-RJRX34BZ.js → chunk-3BXUGX5F.js} +4 -18
- package/dist/chunk-3BXUGX5F.js.map +1 -0
- package/dist/chunk-3QRVAI53.cjs +27 -0
- package/dist/chunk-3QRVAI53.cjs.map +1 -0
- package/dist/{chunk-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
- package/dist/chunk-7FAVFJAS.js.map +1 -0
- package/dist/{chunk-6V6GGBDK.cjs → chunk-7SVKLWDT.cjs} +24 -31
- package/dist/chunk-7SVKLWDT.cjs.map +1 -0
- package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
- package/dist/chunk-A6PGQVTR.cjs.map +1 -0
- package/dist/{chunk-P6KYXFZC.cjs → chunk-ACSEYJJF.cjs} +426 -534
- package/dist/chunk-ACSEYJJF.cjs.map +1 -0
- package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
- package/dist/chunk-AIS37SL2.cjs.map +1 -0
- package/dist/{chunk-X4HDKFW5.cjs → chunk-DTQFYHDJ.cjs} +56 -105
- package/dist/chunk-DTQFYHDJ.cjs.map +1 -0
- package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
- package/dist/chunk-HDJ653LM.js.map +1 -0
- package/dist/chunk-HQ43EIYO.cjs +94 -0
- package/dist/chunk-HQ43EIYO.cjs.map +1 -0
- package/dist/{chunk-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
- package/dist/chunk-HTLWPSMU.js.map +1 -0
- package/dist/{chunk-ADSJ42DO.js → chunk-HWEK7EX5.js} +17 -69
- package/dist/chunk-HWEK7EX5.js.map +1 -0
- package/dist/{chunk-623AOJM2.js → chunk-ITXCE6KL.js} +7 -25
- package/dist/chunk-ITXCE6KL.js.map +1 -0
- package/dist/{chunk-AUOEM3SF.cjs → chunk-IXVGHH7F.cjs} +102 -155
- package/dist/chunk-IXVGHH7F.cjs.map +1 -0
- package/dist/{chunk-NEZJ7ZP5.js → chunk-JZJIWRF3.js} +4 -8
- package/dist/chunk-JZJIWRF3.js.map +1 -0
- package/dist/{chunk-C23RQVRK.js → chunk-KSF2HILJ.js} +66 -216
- package/dist/chunk-KSF2HILJ.js.map +1 -0
- package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
- package/dist/chunk-L4D23LM2.js.map +1 -0
- package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
- package/dist/chunk-L6OW2FL3.js.map +1 -0
- package/dist/chunk-LE5XMIFJ.cjs +4 -3
- package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
- package/dist/{chunk-5MAYUGTE.cjs → chunk-LY2D45F2.cjs} +233 -363
- package/dist/chunk-LY2D45F2.cjs.map +1 -0
- package/dist/{chunk-VCLL5C7J.js → chunk-MGMA5PEL.js} +14 -57
- package/dist/chunk-MGMA5PEL.js.map +1 -0
- package/dist/chunk-MQUCCSWG.js +2 -3
- package/dist/chunk-MQUCCSWG.js.map +1 -1
- package/dist/chunk-NO3KTZDY.cjs +33 -0
- package/dist/chunk-NO3KTZDY.cjs.map +1 -0
- package/dist/{chunk-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
- package/dist/chunk-OM7E43ZN.cjs.map +1 -0
- package/dist/{chunk-JHQUHFLX.js → chunk-PJCHSHM3.js} +38 -120
- package/dist/chunk-PJCHSHM3.js.map +1 -0
- package/dist/{chunk-EPARJI4V.js → chunk-QC35D2AU.js} +107 -262
- package/dist/chunk-QC35D2AU.js.map +1 -0
- package/dist/{chunk-CW3AFJBR.cjs → chunk-QEMGOL5L.cjs} +1302 -1773
- package/dist/chunk-QEMGOL5L.cjs.map +1 -0
- package/dist/chunk-QWS7KH3K.cjs +483 -0
- package/dist/chunk-QWS7KH3K.cjs.map +1 -0
- package/dist/{chunk-IQBMAE3F.js → chunk-RHQPAW4W.js} +34 -92
- package/dist/chunk-RHQPAW4W.js.map +1 -0
- package/dist/chunk-RIIXJWBR.cjs +24 -0
- package/dist/chunk-RIIXJWBR.cjs.map +1 -0
- package/dist/{chunk-VRS6WCEK.js → chunk-SAEQMDAU.js} +60 -167
- package/dist/chunk-SAEQMDAU.js.map +1 -0
- package/dist/chunk-SKZC4K5S.cjs +612 -0
- package/dist/chunk-SKZC4K5S.cjs.map +1 -0
- package/dist/{chunk-N4FGA3H4.js → chunk-TBCHYHNU.js} +38 -105
- package/dist/chunk-TBCHYHNU.js.map +1 -0
- package/dist/{chunk-OSHZQR3W.js → chunk-TNN6Z52D.js} +13 -45
- package/dist/chunk-TNN6Z52D.js.map +1 -0
- package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
- package/dist/chunk-TYZSB7JT.js.map +1 -0
- package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
- package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
- package/dist/{chunk-FDRUAL3Z.cjs → chunk-WDO6DBYU.cjs} +90 -153
- package/dist/chunk-WDO6DBYU.cjs.map +1 -0
- package/dist/{chunk-WEYDDIBQ.cjs → chunk-WHV5ZSIO.cjs} +36 -64
- package/dist/chunk-WHV5ZSIO.cjs.map +1 -0
- package/dist/{chunk-T43RZTUT.js → chunk-XJDPQFPU.js} +693 -1247
- package/dist/chunk-XJDPQFPU.js.map +1 -0
- package/dist/{chunk-BQANU5BH.cjs → chunk-ZTLYHRZT.cjs} +34 -44
- package/dist/chunk-ZTLYHRZT.cjs.map +1 -0
- package/dist/chunk-ZWB7SZVI.cjs +200 -0
- package/dist/chunk-ZWB7SZVI.cjs.map +1 -0
- package/dist/comments.cjs +209 -290
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +81 -186
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +48 -65
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.d.cts +2 -2
- package/dist/diff.d.ts +2 -2
- package/dist/diff.js +8 -32
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +50 -63
- package/dist/docx.cjs.map +1 -1
- package/dist/docx.js +7 -22
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +18 -12
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +9 -16
- package/dist/embed.js.map +1 -1
- package/dist/emoji-data.cjs +7 -5
- package/dist/emoji-data.cjs.map +1 -1
- package/dist/emoji-data.js +3 -5
- package/dist/emoji-data.js.map +1 -1
- package/dist/emoji.cjs +25 -17
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +8 -17
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +229 -118
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.js +4 -118
- package/dist/engine.js.map +1 -1
- package/dist/find.cjs +29 -19
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +8 -19
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +290 -151
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +5 -1
- package/dist/headless.d.ts +5 -1
- package/dist/headless.js +5 -151
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +348 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +7 -183
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +19 -13
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +10 -17
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +19 -13
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +10 -17
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +98 -132
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +21 -78
- package/dist/presence.js.map +1 -1
- package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
- package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.ts} +25 -2
- package/dist/stats.cjs +26 -18
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +9 -18
- package/dist/stats.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table.cjs +89 -49
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +8 -49
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +25 -17
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +8 -17
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +13 -16
- package/dist/view.cjs.map +1 -1
- package/dist/view.d.cts +2 -2
- package/dist/view.d.ts +2 -2
- package/dist/view.js +7 -16
- package/dist/view.js.map +1 -1
- package/dist/yjs.cjs +186 -228
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +12 -80
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4SLJNZSM.cjs.map +0 -1
- package/dist/chunk-4XFXB37X.js.map +0 -1
- package/dist/chunk-5MAYUGTE.cjs.map +0 -1
- package/dist/chunk-623AOJM2.js.map +0 -1
- package/dist/chunk-6NULZPVC.js.map +0 -1
- package/dist/chunk-6V6GGBDK.cjs.map +0 -1
- package/dist/chunk-73653CJ4.cjs +0 -34
- package/dist/chunk-73653CJ4.cjs.map +0 -1
- package/dist/chunk-ADSJ42DO.js.map +0 -1
- package/dist/chunk-AUOEM3SF.cjs.map +0 -1
- package/dist/chunk-BQANU5BH.cjs.map +0 -1
- package/dist/chunk-C23RQVRK.js.map +0 -1
- package/dist/chunk-CW3AFJBR.cjs.map +0 -1
- package/dist/chunk-DUE3HCZD.js.map +0 -1
- package/dist/chunk-EH5KXQXY.cjs.map +0 -1
- package/dist/chunk-EPARJI4V.js.map +0 -1
- package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
- package/dist/chunk-IQBMAE3F.js.map +0 -1
- package/dist/chunk-JHQUHFLX.js.map +0 -1
- package/dist/chunk-KUYZMSMF.cjs +0 -100
- package/dist/chunk-KUYZMSMF.cjs.map +0 -1
- package/dist/chunk-LLTEGXWZ.cjs +0 -562
- package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
- package/dist/chunk-N4FGA3H4.js.map +0 -1
- package/dist/chunk-NEZJ7ZP5.js.map +0 -1
- package/dist/chunk-O4Z2WMFF.js.map +0 -1
- package/dist/chunk-OBMBSU2S.js.map +0 -1
- package/dist/chunk-OSHZQR3W.js.map +0 -1
- package/dist/chunk-P6KYXFZC.cjs.map +0 -1
- package/dist/chunk-R2BLBV43.cjs +0 -239
- package/dist/chunk-R2BLBV43.cjs.map +0 -1
- package/dist/chunk-RJRX34BZ.js.map +0 -1
- package/dist/chunk-T43RZTUT.js.map +0 -1
- package/dist/chunk-TLGX43P6.cjs.map +0 -1
- package/dist/chunk-U3LOLYAU.js.map +0 -1
- package/dist/chunk-UEKXVCKC.cjs +0 -716
- package/dist/chunk-UEKXVCKC.cjs.map +0 -1
- package/dist/chunk-VCLL5C7J.js.map +0 -1
- package/dist/chunk-VRS6WCEK.js.map +0 -1
- package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
- package/dist/chunk-X4HDKFW5.cjs.map +0 -1
- package/dist/chunk-X4P4TQXH.cjs +0 -30
- package/dist/chunk-X4P4TQXH.cjs.map +0 -1
- package/dist/chunk-XA3UEJIW.cjs +0 -25
- package/dist/chunk-XA3UEJIW.cjs.map +0 -1
- package/dist/chunk-YBMUEEM5.js.map +0 -1
- package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
|
@@ -1,71 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
deleteBackward,
|
|
8
|
-
deleteForward,
|
|
9
|
-
deleteSelection,
|
|
10
|
-
deleteToLineEnd,
|
|
11
|
-
deleteToLineStart,
|
|
12
|
-
deleteWordBackward,
|
|
13
|
-
deleteWordForward,
|
|
14
|
-
detectMac,
|
|
15
|
-
endOf,
|
|
16
|
-
headBlockId,
|
|
17
|
-
hidingToggle,
|
|
18
|
-
insertHardBreak,
|
|
19
|
-
insertText,
|
|
20
|
-
isClosedToggle,
|
|
21
|
-
isCollapsed,
|
|
22
|
-
isTextFlow,
|
|
23
|
-
mapSelection,
|
|
24
|
-
markRanges,
|
|
25
|
-
nextGraphemeOffset,
|
|
26
|
-
nodeSelection,
|
|
27
|
-
prevGraphemeOffset,
|
|
28
|
-
primaryRegion,
|
|
29
|
-
rangeContent,
|
|
30
|
-
redo,
|
|
31
|
-
regionLength,
|
|
32
|
-
replaceInlineStep,
|
|
33
|
-
runCommands,
|
|
34
|
-
sameSelection,
|
|
35
|
-
selectionRange,
|
|
36
|
-
setAttrs,
|
|
37
|
-
setSelection,
|
|
38
|
-
startOf,
|
|
39
|
-
textSelection,
|
|
40
|
-
toggleMark,
|
|
41
|
-
toggleTask,
|
|
42
|
-
undo,
|
|
43
|
-
undoInputRule
|
|
44
|
-
} from "./chunk-OBMBSU2S.js";
|
|
45
|
-
import {
|
|
46
|
-
alignOrUndefined,
|
|
47
|
-
blockById,
|
|
48
|
-
dataAttributes,
|
|
49
|
-
firstNamed,
|
|
50
|
-
headingLevel,
|
|
51
|
-
inlineLength,
|
|
52
|
-
inlinePlainText,
|
|
53
|
-
inlineText,
|
|
54
|
-
markElement,
|
|
55
|
-
nodeLength,
|
|
56
|
-
optionalString,
|
|
57
|
-
orderedStart,
|
|
58
|
-
paletteOrUndefined,
|
|
59
|
-
requireBlockIndex,
|
|
60
|
-
sameAttrs,
|
|
61
|
-
sameItems,
|
|
62
|
-
sanitizeHref,
|
|
63
|
-
sliceInline,
|
|
64
|
-
writtenAttrs
|
|
65
|
-
} from "./chunk-4XFXB37X.js";
|
|
66
|
-
|
|
67
|
-
// src/view/react/use-editor-state.ts
|
|
68
|
-
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
1
|
+
import { toggleMark, hidingToggle, isTextFlow, markRanges, toggleTask, setAttrs, runCommands, setSelection, blockRangeSelection, primaryRegion, isClosedToggle, commonPrefix, commonSuffix, deleteSelection, detectMac, sameSelection, createEditor, endOf, startOf, nodeSelection, mapSelection, textSelection, rangeContent, headBlockId, redo, undo, insertHardBreak, undoInputRule, insertText, isCollapsed, nextGraphemeOffset, prevGraphemeOffset, Transaction, replaceInlineStep, selectionRange, regionLength, deleteBackward, deleteToLineEnd, deleteToLineStart, deleteWordForward, deleteWordBackward, deleteForward } from './chunk-L4D23LM2.js';
|
|
2
|
+
import { alignOrUndefined, paletteOrUndefined, optionalString, headingLevel, sameItems, inlineLength, firstNamed, sameAttrs, blockById, orderedStart, nodeLength, inlineText, inlinePlainText, dataAttributes, writtenAttrs, markElement, sanitizeHref, sliceInline, requireBlockIndex } from './chunk-L6OW2FL3.js';
|
|
3
|
+
import { createContext, memo, useRef, useContext, useCallback, useSyncExternalStore, useEffect, useLayoutEffect, Component, useState, useId, useMemo } from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
69
7
|
var wholeState = (state) => state;
|
|
70
8
|
function useEditorState(controller, selector, isEqual = Object.is) {
|
|
71
9
|
const last = useRef(null);
|
|
@@ -706,6 +644,11 @@ function entryEdge(controller, block, direction) {
|
|
|
706
644
|
return drawn && !entersAsNode(controller, block) ? edge : nodeSelection(block);
|
|
707
645
|
}
|
|
708
646
|
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ? nodeSelection(block) : null;
|
|
647
|
+
var canBeEntered = (controller) => (block) => {
|
|
648
|
+
const { schema } = controller.editor.state;
|
|
649
|
+
const region = isTextFlow(schema, block) ? primaryRegion(schema, block) : null;
|
|
650
|
+
return region === null || controller.registry.get(block.id, region) !== void 0 || entersAsNode(controller, block.id);
|
|
651
|
+
};
|
|
709
652
|
var holdsTextHead = (controller) => (block) => isTextFlow(controller.editor.state.schema, block) && entryEdge(controller, block.id, 1).kind === "text";
|
|
710
653
|
function neighbourHead(controller, from, direction) {
|
|
711
654
|
const target = neighbourBlock(controller.editor.state.doc, from, direction, holdsTextHead(controller));
|
|
@@ -713,7 +656,7 @@ function neighbourHead(controller, from, direction) {
|
|
|
713
656
|
return edge?.kind === "text" ? edge.head : null;
|
|
714
657
|
}
|
|
715
658
|
function moveToNeighbour(controller, from, direction) {
|
|
716
|
-
const target = neighbourBlock(controller.editor.state.doc, from, direction);
|
|
659
|
+
const target = neighbourBlock(controller.editor.state.doc, from, direction, canBeEntered(controller));
|
|
717
660
|
if (target === null) return false;
|
|
718
661
|
dispatchSelection(controller, entryEdge(controller, target.id, direction));
|
|
719
662
|
return true;
|
|
@@ -1906,7 +1849,7 @@ function reconcileHost(controller, block, region, caretHint) {
|
|
|
1906
1849
|
if (element === void 0 || inline === void 0) return false;
|
|
1907
1850
|
const before = inlineText(inline);
|
|
1908
1851
|
const after = readDomText(element);
|
|
1909
|
-
const edit = before === after ? null : textDiff(before, after,
|
|
1852
|
+
const edit = before === after ? null : textDiff(before, after, domCaretOffset(element));
|
|
1910
1853
|
if (edit === null) return false;
|
|
1911
1854
|
const at = (offset) => ({ block, region, offset });
|
|
1912
1855
|
controller.edit(() => {
|
|
@@ -2151,7 +2094,7 @@ function landing(controller, { head }, direction, extend) {
|
|
|
2151
2094
|
}
|
|
2152
2095
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2153
2096
|
if (own2 !== null) return own2;
|
|
2154
|
-
const accept = extend ? holdsTextHead(controller) :
|
|
2097
|
+
const accept = extend ? holdsTextHead(controller) : canBeEntered(controller);
|
|
2155
2098
|
const target = neighbourBlock(controller.editor.state.doc, head.block, direction, accept);
|
|
2156
2099
|
return target && (landAtGoal(controller, target, direction) ?? entryEdge(controller, target.id, direction));
|
|
2157
2100
|
}
|
|
@@ -2295,12 +2238,12 @@ function attachInput(controller, root) {
|
|
|
2295
2238
|
};
|
|
2296
2239
|
const onInput = (event) => fallback.onInput(event);
|
|
2297
2240
|
const onCompositionStart = (event) => {
|
|
2298
|
-
if (inHost(event) || inEmptyHost(event)) composition.start(
|
|
2241
|
+
if (inHost(event) || inEmptyHost(event)) composition.start();
|
|
2299
2242
|
else if (inSink(event)) sinkComposition.start();
|
|
2300
2243
|
};
|
|
2301
2244
|
const onCompositionEnd = (event) => {
|
|
2302
2245
|
if (inSink(event)) sinkComposition.end();
|
|
2303
|
-
else composition.end(
|
|
2246
|
+
else composition.end();
|
|
2304
2247
|
};
|
|
2305
2248
|
const detachClipboard = attachClipboard(controller, root, catchUp);
|
|
2306
2249
|
const unlisten = listen(root, {
|
|
@@ -2666,28 +2609,18 @@ var ViewController = class {
|
|
|
2666
2609
|
else element.focus({ preventScroll });
|
|
2667
2610
|
}
|
|
2668
2611
|
};
|
|
2669
|
-
|
|
2670
|
-
// src/view/react/editor-context.ts
|
|
2671
|
-
import { createContext, useContext } from "react";
|
|
2672
2612
|
var QuoinEditorContext = createContext(null);
|
|
2673
2613
|
function useViewController() {
|
|
2674
2614
|
const controller = useContext(QuoinEditorContext);
|
|
2675
2615
|
if (controller === null) throw new Error("useViewController must be called inside an EditorView");
|
|
2676
2616
|
return controller;
|
|
2677
2617
|
}
|
|
2678
|
-
|
|
2679
|
-
// src/view/react/use-quoin-editor.ts
|
|
2680
|
-
import { useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
2681
|
-
import { flushSync } from "react-dom";
|
|
2682
|
-
|
|
2683
|
-
// src/view/react/use-isomorphic-layout-effect.ts
|
|
2684
|
-
import { useEffect, useLayoutEffect } from "react";
|
|
2685
2618
|
var useIsomorphicLayoutEffect = typeof document === "undefined" ? useEffect : useLayoutEffect;
|
|
2686
2619
|
|
|
2687
2620
|
// src/view/react/use-quoin-editor.ts
|
|
2688
2621
|
function useQuoinEditor(options) {
|
|
2689
2622
|
const { blocks, readOnly = false } = options;
|
|
2690
|
-
const callbacks =
|
|
2623
|
+
const callbacks = useRef(options);
|
|
2691
2624
|
const [controller] = useState(() => {
|
|
2692
2625
|
const editor = createEditor({
|
|
2693
2626
|
blocks,
|
|
@@ -2712,30 +2645,21 @@ function useQuoinEditor(options) {
|
|
|
2712
2645
|
useIsomorphicLayoutEffect(() => {
|
|
2713
2646
|
controller.setReadOnly(readOnly);
|
|
2714
2647
|
}, [controller, readOnly]);
|
|
2715
|
-
|
|
2648
|
+
useEffect(() => () => controller.destroy(), [controller]);
|
|
2716
2649
|
return controller;
|
|
2717
2650
|
}
|
|
2718
|
-
|
|
2719
|
-
// src/view/react/SelectionSink.tsx
|
|
2720
|
-
import { useCallback as useCallback3, useRef as useRef3 } from "react";
|
|
2721
|
-
|
|
2722
|
-
// src/view/react/use-read-only.ts
|
|
2723
|
-
import { useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
2724
2651
|
function useReadOnly(controller) {
|
|
2725
|
-
const subscribe =
|
|
2726
|
-
const read =
|
|
2727
|
-
return
|
|
2652
|
+
const subscribe = useCallback((notify) => controller.subscribeReadOnly(notify), [controller]);
|
|
2653
|
+
const read = useCallback(() => controller.readOnly, [controller]);
|
|
2654
|
+
return useSyncExternalStore(subscribe, read, read);
|
|
2728
2655
|
}
|
|
2729
|
-
|
|
2730
|
-
// src/view/react/SelectionSink.tsx
|
|
2731
|
-
import { jsx } from "react/jsx-runtime";
|
|
2732
2656
|
function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
2733
2657
|
const controller = useViewController();
|
|
2734
|
-
const ref =
|
|
2658
|
+
const ref = useRef(null);
|
|
2735
2659
|
const readOnly = useReadOnly(controller);
|
|
2736
2660
|
const name = useEditorState(
|
|
2737
2661
|
controller,
|
|
2738
|
-
|
|
2662
|
+
useCallback((state) => selectedBlockName(state, blockLabel), [blockLabel])
|
|
2739
2663
|
);
|
|
2740
2664
|
useIsomorphicLayoutEffect(() => {
|
|
2741
2665
|
const sink = ref.current;
|
|
@@ -2761,28 +2685,19 @@ function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
|
2761
2685
|
}
|
|
2762
2686
|
);
|
|
2763
2687
|
}
|
|
2764
|
-
|
|
2765
|
-
// src/view/react/EditableRegion.tsx
|
|
2766
|
-
import { useCallback as useCallback4, useContext as useContext2, useRef as useRef4 } from "react";
|
|
2767
|
-
|
|
2768
|
-
// src/view/react/block-placeholder.ts
|
|
2769
|
-
import { createContext as createContext2 } from "react";
|
|
2770
2688
|
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${headingLevel(attrs.level)}` : void 0;
|
|
2771
|
-
var BlockPlaceholderContext =
|
|
2689
|
+
var BlockPlaceholderContext = createContext(headingPlaceholder);
|
|
2772
2690
|
function regionPlaceholder(state, blockId, region, placeholderOf) {
|
|
2773
2691
|
const block = blockById(state.doc, blockId);
|
|
2774
2692
|
return block !== void 0 && primaryRegion(state.schema, block) === region ? placeholderOf(state, block) : void 0;
|
|
2775
2693
|
}
|
|
2776
|
-
|
|
2777
|
-
// src/view/react/EditableRegion.tsx
|
|
2778
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
2779
2694
|
var samePainted = (a, b) => a.inline === b.inline && a.placeholder === b.placeholder && sameDecorations(a.decorations, b.decorations);
|
|
2780
2695
|
function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
2781
2696
|
const controller = useViewController();
|
|
2782
|
-
const placeholderOf =
|
|
2783
|
-
const ref =
|
|
2697
|
+
const placeholderOf = useContext(BlockPlaceholderContext);
|
|
2698
|
+
const ref = useRef(null);
|
|
2784
2699
|
const readOnly = useReadOnly(controller);
|
|
2785
|
-
const select =
|
|
2700
|
+
const select = useCallback(
|
|
2786
2701
|
(state) => {
|
|
2787
2702
|
const inline2 = regionInline(state, block, region);
|
|
2788
2703
|
const empty = inline2 === void 0 || inlineLength(inline2) === 0;
|
|
@@ -2802,7 +2717,7 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2802
2717
|
useIsomorphicLayoutEffect(() => {
|
|
2803
2718
|
controller.renderHost(block, region);
|
|
2804
2719
|
}, [controller, block, region, inline, decorations]);
|
|
2805
|
-
return /* @__PURE__ */
|
|
2720
|
+
return /* @__PURE__ */ jsx(
|
|
2806
2721
|
"div",
|
|
2807
2722
|
{
|
|
2808
2723
|
ref,
|
|
@@ -2822,15 +2737,9 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2822
2737
|
}
|
|
2823
2738
|
);
|
|
2824
2739
|
}
|
|
2825
|
-
|
|
2826
|
-
// src/view/react/default-renderers.tsx
|
|
2827
|
-
import { useContext as useContext3 } from "react";
|
|
2828
|
-
|
|
2829
|
-
// src/view/react/callout-block.tsx
|
|
2830
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
2831
2740
|
var CalloutBlock = ({ block }) => {
|
|
2832
2741
|
const tone = typeof block.attrs.tone === "string" && block.attrs.tone !== "" ? block.attrs.tone : "info";
|
|
2833
|
-
return /* @__PURE__ */
|
|
2742
|
+
return /* @__PURE__ */ jsx("div", { className: "quoin-callout", "data-tone": tone, children: /* @__PURE__ */ jsx(EditableRegion, { block: block.id, region: "body", label: `Callout, ${tone}` }) });
|
|
2834
2743
|
};
|
|
2835
2744
|
|
|
2836
2745
|
// src/view/react/block-command.ts
|
|
@@ -2845,14 +2754,11 @@ function onBlock(id, command) {
|
|
|
2845
2754
|
|
|
2846
2755
|
// src/view/react/prevent-mouse-focus.ts
|
|
2847
2756
|
var keepFocus = (event) => event.preventDefault();
|
|
2848
|
-
|
|
2849
|
-
// src/view/react/TaskCheckbox.tsx
|
|
2850
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
2851
2757
|
function TaskCheckbox({ block, controller, label, labelledBy }) {
|
|
2852
2758
|
const checked = block.attrs.checked === true;
|
|
2853
2759
|
const flip2 = flipCommand(block);
|
|
2854
2760
|
const readOnly = useReadOnly(controller);
|
|
2855
|
-
return /* @__PURE__ */
|
|
2761
|
+
return /* @__PURE__ */ jsx(
|
|
2856
2762
|
"button",
|
|
2857
2763
|
{
|
|
2858
2764
|
type: "button",
|
|
@@ -2868,7 +2774,7 @@ function TaskCheckbox({ block, controller, label, labelledBy }) {
|
|
|
2868
2774
|
onClick: () => {
|
|
2869
2775
|
if (flip2 && !controller.readOnly) controller.run(onBlock(block.id, flip2));
|
|
2870
2776
|
},
|
|
2871
|
-
children: checked ? /* @__PURE__ */
|
|
2777
|
+
children: checked ? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx("path", { d: "M3.5 8.5l3 3 6-7", fill: "none", stroke: "currentColor", strokeWidth: "2" }) }) : null
|
|
2872
2778
|
}
|
|
2873
2779
|
);
|
|
2874
2780
|
}
|
|
@@ -2913,18 +2819,15 @@ function useOrderedNumber(controller, blockId) {
|
|
|
2913
2819
|
return index === void 0 ? 1 : orderedNumber(doc, index);
|
|
2914
2820
|
});
|
|
2915
2821
|
}
|
|
2916
|
-
|
|
2917
|
-
// src/view/react/markdown-block.tsx
|
|
2918
|
-
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
2919
2822
|
var REGION = "text";
|
|
2920
2823
|
function TextRegion({ block, label }) {
|
|
2921
|
-
return /* @__PURE__ */
|
|
2824
|
+
return /* @__PURE__ */ jsx(EditableRegion, { block: block.id, region: REGION, label });
|
|
2922
2825
|
}
|
|
2923
2826
|
function NumberedItem({ block, controller }) {
|
|
2924
2827
|
const number = useOrderedNumber(controller, block.id);
|
|
2925
2828
|
return /* @__PURE__ */ jsxs("div", { className: "quoin-list-item", "data-list": "ordered", children: [
|
|
2926
|
-
/* @__PURE__ */
|
|
2927
|
-
/* @__PURE__ */
|
|
2829
|
+
/* @__PURE__ */ jsx("span", { className: "quoin-marker", "aria-hidden": "true", children: `${number}.` }),
|
|
2830
|
+
/* @__PURE__ */ jsx(TextRegion, { block, label: `Numbered list item ${number}` })
|
|
2928
2831
|
] });
|
|
2929
2832
|
}
|
|
2930
2833
|
var MarkdownBlock = (props) => {
|
|
@@ -2932,44 +2835,38 @@ var MarkdownBlock = (props) => {
|
|
|
2932
2835
|
switch (block.attrs.kind) {
|
|
2933
2836
|
case "heading": {
|
|
2934
2837
|
const level = headingLevel(block.attrs.level);
|
|
2935
|
-
return /* @__PURE__ */
|
|
2838
|
+
return /* @__PURE__ */ jsx("div", { role: "heading", "aria-level": level, className: "quoin-heading", children: /* @__PURE__ */ jsx(TextRegion, { block, label: `Heading ${level}` }) });
|
|
2936
2839
|
}
|
|
2937
2840
|
case "bullet":
|
|
2938
2841
|
return /* @__PURE__ */ jsxs("div", { className: "quoin-list-item", "data-list": "bullet", children: [
|
|
2939
|
-
/* @__PURE__ */
|
|
2940
|
-
/* @__PURE__ */
|
|
2842
|
+
/* @__PURE__ */ jsx("span", { className: "quoin-marker", "aria-hidden": "true", children: "\u2022" }),
|
|
2843
|
+
/* @__PURE__ */ jsx(TextRegion, { block, label: "Bullet list item" })
|
|
2941
2844
|
] });
|
|
2942
2845
|
case "ordered":
|
|
2943
|
-
return /* @__PURE__ */
|
|
2846
|
+
return /* @__PURE__ */ jsx(NumberedItem, { ...props });
|
|
2944
2847
|
case "task":
|
|
2945
2848
|
return /* @__PURE__ */ jsxs("div", { className: "quoin-task", "data-checked": block.attrs.checked === true, children: [
|
|
2946
|
-
/* @__PURE__ */
|
|
2947
|
-
/* @__PURE__ */
|
|
2849
|
+
/* @__PURE__ */ jsx(TaskCheckbox, { block, controller: props.controller }),
|
|
2850
|
+
/* @__PURE__ */ jsx(TextRegion, { block, label: "Task" })
|
|
2948
2851
|
] });
|
|
2949
2852
|
case "quote":
|
|
2950
|
-
return /* @__PURE__ */
|
|
2853
|
+
return /* @__PURE__ */ jsx("div", { className: "quoin-quote", children: /* @__PURE__ */ jsx(TextRegion, { block, label: "Quote" }) });
|
|
2951
2854
|
default:
|
|
2952
|
-
return /* @__PURE__ */
|
|
2855
|
+
return /* @__PURE__ */ jsx(TextRegion, { block, label: "Paragraph" });
|
|
2953
2856
|
}
|
|
2954
2857
|
};
|
|
2955
|
-
|
|
2956
|
-
// src/view/react/use-reader-choices.ts
|
|
2957
|
-
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
2958
2858
|
function useReaderChoices(controller) {
|
|
2959
2859
|
const store = readerToggles(controller);
|
|
2960
|
-
return
|
|
2860
|
+
return useSyncExternalStore(store.subscribe, () => store.choices, () => store.choices);
|
|
2961
2861
|
}
|
|
2962
2862
|
function useToggleOpen(controller, block) {
|
|
2963
2863
|
return shownOpen(block, useReaderChoices(controller));
|
|
2964
2864
|
}
|
|
2965
|
-
|
|
2966
|
-
// src/view/react/ToggleChevron.tsx
|
|
2967
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2968
2865
|
function ToggleChevron({ block, controller, label = "Toggle", controls }) {
|
|
2969
2866
|
const open = useToggleOpen(controller, block);
|
|
2970
2867
|
const readOnly = useReadOnly(controller);
|
|
2971
2868
|
const flip2 = flipCommand(block);
|
|
2972
|
-
return /* @__PURE__ */
|
|
2869
|
+
return /* @__PURE__ */ jsx(
|
|
2973
2870
|
"button",
|
|
2974
2871
|
{
|
|
2975
2872
|
type: "button",
|
|
@@ -2984,48 +2881,56 @@ function ToggleChevron({ block, controller, label = "Toggle", controls }) {
|
|
|
2984
2881
|
if (controller.readOnly) readerToggles(controller).flip(block);
|
|
2985
2882
|
else if (flip2) controller.run(onBlock(block.id, flip2));
|
|
2986
2883
|
},
|
|
2987
|
-
children: /* @__PURE__ */
|
|
2884
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx("path", { d: "M6 3.5l4.5 4.5L6 12.5", fill: "none", stroke: "currentColor", strokeWidth: "2" }) })
|
|
2988
2885
|
}
|
|
2989
2886
|
);
|
|
2990
2887
|
}
|
|
2991
|
-
|
|
2992
|
-
// src/view/react/toggle-block.tsx
|
|
2993
|
-
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2994
2888
|
var ToggleBlock = ({ block, controller }) => {
|
|
2995
2889
|
const open = useToggleOpen(controller, block);
|
|
2996
|
-
return /* @__PURE__ */
|
|
2997
|
-
/* @__PURE__ */
|
|
2998
|
-
/* @__PURE__ */
|
|
2890
|
+
return /* @__PURE__ */ jsxs("div", { className: "quoin-toggle", "data-open": open, children: [
|
|
2891
|
+
/* @__PURE__ */ jsx(ToggleChevron, { block, controller }),
|
|
2892
|
+
/* @__PURE__ */ jsx(EditableRegion, { block: block.id, region: "text", label: "Toggle" })
|
|
2999
2893
|
] });
|
|
3000
2894
|
};
|
|
3001
|
-
|
|
3002
|
-
// src/view/react/unsupported-block-label.ts
|
|
3003
|
-
import { createContext as createContext3 } from "react";
|
|
3004
2895
|
var UNSUPPORTED_BLOCK = "Unsupported block";
|
|
3005
|
-
var UnsupportedBlockLabel =
|
|
3006
|
-
|
|
3007
|
-
// src/view/react/default-renderers.tsx
|
|
3008
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
2896
|
+
var UnsupportedBlockLabel = createContext(UNSUPPORTED_BLOCK);
|
|
3009
2897
|
var defaultRenderers = {
|
|
3010
2898
|
MARKDOWN: MarkdownBlock,
|
|
3011
2899
|
CALLOUT: CalloutBlock,
|
|
3012
2900
|
TOGGLE: ToggleBlock
|
|
3013
2901
|
};
|
|
3014
2902
|
var VoidBlockFallback = ({ block }) => {
|
|
3015
|
-
const label =
|
|
3016
|
-
if (block.type === "DIVIDER") return /* @__PURE__ */
|
|
3017
|
-
return /* @__PURE__ */
|
|
2903
|
+
const label = useContext(UnsupportedBlockLabel);
|
|
2904
|
+
if (block.type === "DIVIDER") return /* @__PURE__ */ jsx("div", { className: "quoin-void", contentEditable: false, role: "separator" });
|
|
2905
|
+
return /* @__PURE__ */ jsx("div", { className: "quoin-void", contentEditable: false, role: "group", "aria-label": label, children: label });
|
|
3018
2906
|
};
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
2907
|
+
var BLOCK_ERROR = "Block could not be drawn";
|
|
2908
|
+
var BlockErrorContext = createContext({ label: BLOCK_ERROR });
|
|
2909
|
+
var Boundary = class extends Component {
|
|
2910
|
+
state = { block: this.props.block, failed: false };
|
|
2911
|
+
static getDerivedStateFromError() {
|
|
2912
|
+
return { failed: true };
|
|
2913
|
+
}
|
|
2914
|
+
static getDerivedStateFromProps(props, state) {
|
|
2915
|
+
return props.block === state.block ? null : { block: props.block, failed: false };
|
|
2916
|
+
}
|
|
2917
|
+
componentDidCatch(error) {
|
|
2918
|
+
this.props.report?.(error instanceof Error ? error : new Error(String(error)));
|
|
2919
|
+
}
|
|
2920
|
+
render() {
|
|
2921
|
+
if (!this.state.failed) return this.props.children;
|
|
2922
|
+
const { label } = this.props;
|
|
2923
|
+
return /* @__PURE__ */ jsx("div", { className: "quoin-void", contentEditable: false, role: "group", "aria-label": label, children: label });
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
function BlockErrorBoundary({ block, children }) {
|
|
2927
|
+
const { label, report } = useContext(BlockErrorContext);
|
|
2928
|
+
return /* @__PURE__ */ jsx(Boundary, { block, label, report, children });
|
|
2929
|
+
}
|
|
2930
|
+
var BlockDomIdScope = createContext("quoin");
|
|
3026
2931
|
function useBlockDomId() {
|
|
3027
|
-
const scope =
|
|
3028
|
-
return
|
|
2932
|
+
const scope = useContext(BlockDomIdScope);
|
|
2933
|
+
return useCallback((block) => `${scope}-${encodeURIComponent(block)}`, [scope]);
|
|
3029
2934
|
}
|
|
3030
2935
|
function useRegionDomId(block, region) {
|
|
3031
2936
|
return `${useBlockDomId()(block)}/${encodeURIComponent(region)}`;
|
|
@@ -3051,16 +2956,18 @@ function blockStatus(state, id, choices = NO_CHOICES) {
|
|
|
3051
2956
|
if (isHiddenAt(state.doc, index, choices)) return "hidden";
|
|
3052
2957
|
return covers(state, id, index) ? "selected" : "plain";
|
|
3053
2958
|
}
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
2959
|
+
function safeAttrs(decorations) {
|
|
2960
|
+
const attrs = Object.assign({}, ...decorations.map((decoration) => decoration.attrs));
|
|
2961
|
+
for (const name of Object.keys(attrs)) if (!/^(data|aria)-/.test(name)) delete attrs[name];
|
|
2962
|
+
return attrs;
|
|
2963
|
+
}
|
|
3057
2964
|
function rendererFor(renderers, type) {
|
|
3058
2965
|
for (const table of [renderers, defaultRenderers]) if (Object.hasOwn(table, type)) return table[type];
|
|
3059
2966
|
return VoidBlockFallback;
|
|
3060
2967
|
}
|
|
3061
2968
|
var BlockShell = memo(function BlockShell2({ block, renderers }) {
|
|
3062
2969
|
const controller = useViewController();
|
|
3063
|
-
const ref =
|
|
2970
|
+
const ref = useRef(null);
|
|
3064
2971
|
const domId = useBlockDomId();
|
|
3065
2972
|
const choices = useReaderChoices(controller);
|
|
3066
2973
|
const status = useEditorState(controller, (state) => blockStatus(state, block.id, choices));
|
|
@@ -3073,10 +2980,10 @@ var BlockShell = memo(function BlockShell2({ block, renderers }) {
|
|
|
3073
2980
|
if (hidden) return null;
|
|
3074
2981
|
const Renderer = rendererFor(renderers, block.type);
|
|
3075
2982
|
const { kind, color, background, align } = block.attrs;
|
|
3076
|
-
return /* @__PURE__ */
|
|
2983
|
+
return /* @__PURE__ */ jsx(
|
|
3077
2984
|
"div",
|
|
3078
2985
|
{
|
|
3079
|
-
...
|
|
2986
|
+
...safeAttrs(decorations),
|
|
3080
2987
|
ref,
|
|
3081
2988
|
id: domId(block.id),
|
|
3082
2989
|
"data-quoin-block": "",
|
|
@@ -3090,20 +2997,13 @@ var BlockShell = memo(function BlockShell2({ block, renderers }) {
|
|
|
3090
2997
|
style: { "--quoin-indent": block.indent },
|
|
3091
2998
|
tabIndex: -1,
|
|
3092
2999
|
"data-selected": status === "selected" ? "true" : void 0,
|
|
3093
|
-
children: /* @__PURE__ */
|
|
3000
|
+
children: /* @__PURE__ */ jsx(BlockErrorBoundary, { block, children: /* @__PURE__ */ jsx(Renderer, { block, controller }) })
|
|
3094
3001
|
}
|
|
3095
3002
|
);
|
|
3096
3003
|
});
|
|
3097
|
-
|
|
3098
|
-
// src/view/react/EditorView.tsx
|
|
3099
|
-
import { useId, useRef as useRef7 } from "react";
|
|
3100
|
-
|
|
3101
|
-
// src/view/react/EmptyDocumentHost.tsx
|
|
3102
|
-
import { useRef as useRef6 } from "react";
|
|
3103
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
3104
3004
|
function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
3105
3005
|
const controller = useViewController();
|
|
3106
|
-
const ref =
|
|
3006
|
+
const ref = useRef(null);
|
|
3107
3007
|
const readOnly = useReadOnly(controller);
|
|
3108
3008
|
useIsomorphicLayoutEffect(() => {
|
|
3109
3009
|
const host = ref.current;
|
|
@@ -3111,7 +3011,7 @@ function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
|
3111
3011
|
renderInline(host, [], []);
|
|
3112
3012
|
return controller.registerEmptyHost(host);
|
|
3113
3013
|
}, [controller]);
|
|
3114
|
-
return /* @__PURE__ */
|
|
3014
|
+
return /* @__PURE__ */ jsx(
|
|
3115
3015
|
"div",
|
|
3116
3016
|
{
|
|
3117
3017
|
ref,
|
|
@@ -3134,9 +3034,6 @@ function EmptyDocumentHost({ placeholder, label = "Paragraph" }) {
|
|
|
3134
3034
|
// src/view/react/focus-owners.ts
|
|
3135
3035
|
var focusOwners = /* @__PURE__ */ new WeakMap();
|
|
3136
3036
|
|
|
3137
|
-
// src/view/react/LiveRegion.tsx
|
|
3138
|
-
import { useCallback as useCallback6, useMemo, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
3139
|
-
|
|
3140
3037
|
// src/view/selection/selection-announcement.ts
|
|
3141
3038
|
var SILENCE = { key: "", message: "" };
|
|
3142
3039
|
function selectionAnnouncement({ doc, selection }, blocksSelected) {
|
|
@@ -3150,9 +3047,6 @@ function selectionAnnouncement({ doc, selection }, blocksSelected) {
|
|
|
3150
3047
|
const count = drawnBlockCount(doc, Math.min(first, last), Math.max(first, last) + 1);
|
|
3151
3048
|
return { key: `${selection.kind}:${anchor}:${head}`, message: blocksSelected(count) };
|
|
3152
3049
|
}
|
|
3153
|
-
|
|
3154
|
-
// src/view/react/LiveRegion.tsx
|
|
3155
|
-
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
3156
3050
|
function heardNow({ editor, announcer }, blocksSelected) {
|
|
3157
3051
|
const spoken = announcer.current();
|
|
3158
3052
|
if (spoken !== null) return { key: `said:${spoken.serial}`, message: spoken.message };
|
|
@@ -3160,7 +3054,7 @@ function heardNow({ editor, announcer }, blocksSelected) {
|
|
|
3160
3054
|
}
|
|
3161
3055
|
function LiveRegion({ blocksSelected }) {
|
|
3162
3056
|
const controller = useViewController();
|
|
3163
|
-
const subscribe =
|
|
3057
|
+
const subscribe = useCallback(
|
|
3164
3058
|
(notify) => {
|
|
3165
3059
|
const stopState = controller.editor.subscribe(() => notify());
|
|
3166
3060
|
const stopSpoken = controller.announcer.subscribe(notify);
|
|
@@ -3179,8 +3073,8 @@ function LiveRegion({ blocksSelected }) {
|
|
|
3179
3073
|
return last;
|
|
3180
3074
|
};
|
|
3181
3075
|
}, [controller, blocksSelected]);
|
|
3182
|
-
const { key, message } =
|
|
3183
|
-
return /* @__PURE__ */
|
|
3076
|
+
const { key, message } = useSyncExternalStore(subscribe, read, read);
|
|
3077
|
+
return /* @__PURE__ */ jsx("div", { className: "quoin-visually-hidden", role: "status", "aria-live": "polite", "aria-atomic": "true", children: message !== "" && /* @__PURE__ */ jsx("span", { children: message }, key) });
|
|
3184
3078
|
}
|
|
3185
3079
|
|
|
3186
3080
|
// src/view/react/SelectionWriter.tsx
|
|
@@ -3190,23 +3084,16 @@ function SelectionWriter() {
|
|
|
3190
3084
|
useIsomorphicLayoutEffect(() => controller.afterRender(), [controller, state]);
|
|
3191
3085
|
return null;
|
|
3192
3086
|
}
|
|
3193
|
-
|
|
3194
|
-
// src/view/react/use-block-elements.tsx
|
|
3195
|
-
import { useState as useState2 } from "react";
|
|
3196
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
3197
3087
|
function useBlockElements(blocks, renderers) {
|
|
3198
|
-
const [made] =
|
|
3088
|
+
const [made] = useState(() => /* @__PURE__ */ new WeakMap());
|
|
3199
3089
|
return blocks.map((block) => {
|
|
3200
3090
|
const known2 = made.get(block);
|
|
3201
3091
|
if (known2?.renderers === renderers) return known2.element;
|
|
3202
|
-
const element = /* @__PURE__ */
|
|
3092
|
+
const element = /* @__PURE__ */ jsx(BlockShell, { block, renderers }, block.id);
|
|
3203
3093
|
made.set(block, { renderers, element });
|
|
3204
3094
|
return element;
|
|
3205
3095
|
});
|
|
3206
3096
|
}
|
|
3207
|
-
|
|
3208
|
-
// src/view/react/EditorView.tsx
|
|
3209
|
-
import { jsx as jsx13, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
3210
3097
|
var NO_RENDERERS = {};
|
|
3211
3098
|
var HINT = "Press Escape, then Tab, to leave the editor.";
|
|
3212
3099
|
var BLOCKS_SELECTED = (count) => `${count} ${count === 1 ? "block" : "blocks"} selected`;
|
|
@@ -3221,18 +3108,21 @@ function EditorView({
|
|
|
3221
3108
|
selectedContentLabel,
|
|
3222
3109
|
blockLabel,
|
|
3223
3110
|
unsupportedBlockLabel = UNSUPPORTED_BLOCK,
|
|
3111
|
+
blockErrorLabel = BLOCK_ERROR,
|
|
3112
|
+
onBlockError,
|
|
3224
3113
|
placeholder,
|
|
3225
3114
|
blockPlaceholder = headingPlaceholder,
|
|
3226
3115
|
blocksSelectedLabel = BLOCKS_SELECTED,
|
|
3227
3116
|
children
|
|
3228
3117
|
}) {
|
|
3229
|
-
const root =
|
|
3118
|
+
const root = useRef(null);
|
|
3230
3119
|
const hintId = useId();
|
|
3231
3120
|
const blockIdScope = useId();
|
|
3232
3121
|
const blocks = useEditorState(controller, (state) => state.doc.blocks);
|
|
3122
|
+
const blockError = useMemo(() => ({ label: blockErrorLabel, report: onBlockError }), [blockErrorLabel, onBlockError]);
|
|
3233
3123
|
const shells = useBlockElements(blocks, renderers);
|
|
3234
3124
|
useIsomorphicLayoutEffect(() => root.current ? controller.attach(root.current) : void 0, [controller]);
|
|
3235
|
-
return /* @__PURE__ */
|
|
3125
|
+
return /* @__PURE__ */ jsx(QuoinEditorContext.Provider, { value: controller, children: /* @__PURE__ */ jsxs(
|
|
3236
3126
|
"div",
|
|
3237
3127
|
{
|
|
3238
3128
|
ref: root,
|
|
@@ -3243,62 +3133,17 @@ function EditorView({
|
|
|
3243
3133
|
"aria-describedby": hintId,
|
|
3244
3134
|
onFocusCapture: (event) => focusOwners.set(event.target, controller),
|
|
3245
3135
|
children: [
|
|
3246
|
-
/* @__PURE__ */
|
|
3136
|
+
/* @__PURE__ */ jsx(BlockDomIdScope.Provider, { value: blockIdScope, children: /* @__PURE__ */ jsx(UnsupportedBlockLabel.Provider, { value: unsupportedBlockLabel, children: /* @__PURE__ */ jsx(BlockErrorContext.Provider, { value: blockError, children: /* @__PURE__ */ jsx(BlockPlaceholderContext.Provider, { value: blockPlaceholder, children: blocks.length === 0 ? /* @__PURE__ */ jsx(EmptyDocumentHost, { placeholder, label: paragraphLabel }) : shells }) }) }) }),
|
|
3247
3137
|
children,
|
|
3248
|
-
/* @__PURE__ */
|
|
3249
|
-
/* @__PURE__ */
|
|
3250
|
-
/* @__PURE__ */
|
|
3251
|
-
/* @__PURE__ */
|
|
3138
|
+
/* @__PURE__ */ jsx(SelectionSink, { label: selectedContentLabel, blockLabel }),
|
|
3139
|
+
/* @__PURE__ */ jsx("div", { id: hintId, className: "quoin-visually-hidden", children: hint }),
|
|
3140
|
+
/* @__PURE__ */ jsx(LiveRegion, { blocksSelected: blocksSelectedLabel }),
|
|
3141
|
+
/* @__PURE__ */ jsx(SelectionWriter, {})
|
|
3252
3142
|
]
|
|
3253
3143
|
}
|
|
3254
3144
|
) });
|
|
3255
3145
|
}
|
|
3256
3146
|
|
|
3257
|
-
export {
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
useEditorState,
|
|
3261
|
-
useReadOnly,
|
|
3262
|
-
isCrossSelection,
|
|
3263
|
-
NODE_ENTRY,
|
|
3264
|
-
visibleBlockIndexes,
|
|
3265
|
-
drawnBlockCount,
|
|
3266
|
-
neighbourBlock,
|
|
3267
|
-
moveToNeighbour,
|
|
3268
|
-
textDiff,
|
|
3269
|
-
domMapOf,
|
|
3270
|
-
renderInline,
|
|
3271
|
-
domToPos,
|
|
3272
|
-
posToDom,
|
|
3273
|
-
caretFromPoint,
|
|
3274
|
-
caretClientRect,
|
|
3275
|
-
lineEdgeRect,
|
|
3276
|
-
isOnFirstLine,
|
|
3277
|
-
isOnLastLine,
|
|
3278
|
-
isComposingKey,
|
|
3279
|
-
NATIVE_INTERACTION,
|
|
3280
|
-
useIsomorphicLayoutEffect,
|
|
3281
|
-
onBlock,
|
|
3282
|
-
listen,
|
|
3283
|
-
createAutoScroll,
|
|
3284
|
-
hostKey,
|
|
3285
|
-
regionInline,
|
|
3286
|
-
handleCopy,
|
|
3287
|
-
ViewController,
|
|
3288
|
-
useViewController,
|
|
3289
|
-
useQuoinEditor,
|
|
3290
|
-
useBlockDomId,
|
|
3291
|
-
useRegionDomId,
|
|
3292
|
-
focusOwners,
|
|
3293
|
-
SelectionSink,
|
|
3294
|
-
EditableRegion,
|
|
3295
|
-
TaskCheckbox,
|
|
3296
|
-
useOrderedNumber,
|
|
3297
|
-
useToggleOpen,
|
|
3298
|
-
ToggleChevron,
|
|
3299
|
-
defaultRenderers,
|
|
3300
|
-
VoidBlockFallback,
|
|
3301
|
-
BlockShell,
|
|
3302
|
-
EditorView
|
|
3303
|
-
};
|
|
3304
|
-
//# sourceMappingURL=chunk-EPARJI4V.js.map
|
|
3147
|
+
export { BlockErrorContext, BlockShell, EditableRegion, EditorView, NATIVE_INTERACTION, NODE_ENTRY, SelectionSink, TaskCheckbox, ToggleChevron, ViewController, VoidBlockFallback, caretClientRect, caretFromPoint, createAutoScroll, defaultRenderers, dispatchSelection, domMapOf, domToPos, drawnBlockCount, focusOwners, handleCopy, hostKey, isComposingKey, isCrossSelection, isOnFirstLine, isOnLastLine, lineEdgeRect, listen, moveToNeighbour, neighbourBlock, onBlock, posToDom, regionInline, renderInline, textDiff, useBlockDomId, useEditorState, useIsomorphicLayoutEffect, useOrderedNumber, useQuoinEditor, useReadOnly, useRegionDomId, useToggleOpen, useViewController, visibleBlockIndexes, wholeState };
|
|
3148
|
+
//# sourceMappingURL=chunk-QC35D2AU.js.map
|
|
3149
|
+
//# sourceMappingURL=chunk-QC35D2AU.js.map
|