quoin-editor 1.1.0 → 1.1.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 +14 -0
- package/dist/ai.cjs +32 -31
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +5 -4
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +21 -20
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +12 -11
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-WDO6DBYU.cjs → chunk-7NAONESM.cjs} +26 -26
- package/dist/{chunk-WDO6DBYU.cjs.map → chunk-7NAONESM.cjs.map} +1 -1
- package/dist/{chunk-QEMGOL5L.cjs → chunk-7XQGOCUG.cjs} +132 -101
- package/dist/chunk-7XQGOCUG.cjs.map +1 -0
- package/dist/{chunk-RHQPAW4W.js → chunk-CKHKCPGL.js} +4 -4
- package/dist/{chunk-RHQPAW4W.js.map → chunk-CKHKCPGL.js.map} +1 -1
- package/dist/{chunk-XJDPQFPU.js → chunk-DYWU4SQ2.js} +38 -7
- package/dist/chunk-DYWU4SQ2.js.map +1 -0
- package/dist/{chunk-NO3KTZDY.cjs → chunk-EFRQMYZ6.cjs} +4 -4
- package/dist/{chunk-NO3KTZDY.cjs.map → chunk-EFRQMYZ6.cjs.map} +1 -1
- package/dist/{chunk-QC35D2AU.js → chunk-IEP7BPFN.js} +22 -12
- package/dist/chunk-IEP7BPFN.js.map +1 -0
- package/dist/{chunk-ACSEYJJF.cjs → chunk-IGZRZIAF.cjs} +22 -12
- package/dist/chunk-IGZRZIAF.cjs.map +1 -0
- package/dist/{chunk-QWS7KH3K.cjs → chunk-JCEFSTVG.cjs} +30 -30
- package/dist/{chunk-QWS7KH3K.cjs.map → chunk-JCEFSTVG.cjs.map} +1 -1
- package/dist/{chunk-SKZC4K5S.cjs → chunk-KXRGY5LK.cjs} +50 -50
- package/dist/{chunk-SKZC4K5S.cjs.map → chunk-KXRGY5LK.cjs.map} +1 -1
- package/dist/{chunk-PJCHSHM3.js → chunk-KZ6ZFCGO.js} +5 -5
- package/dist/{chunk-PJCHSHM3.js.map → chunk-KZ6ZFCGO.js.map} +1 -1
- package/dist/{chunk-HWEK7EX5.js → chunk-L2QA2UTY.js} +5 -5
- package/dist/{chunk-HWEK7EX5.js.map → chunk-L2QA2UTY.js.map} +1 -1
- package/dist/{chunk-KSF2HILJ.js → chunk-MUIPM26J.js} +4 -4
- package/dist/{chunk-KSF2HILJ.js.map → chunk-MUIPM26J.js.map} +1 -1
- package/dist/{chunk-IXVGHH7F.cjs → chunk-OKWER2RV.cjs} +15 -15
- package/dist/{chunk-IXVGHH7F.cjs.map → chunk-OKWER2RV.cjs.map} +1 -1
- package/dist/{chunk-JZJIWRF3.js → chunk-QSXPKZ2F.js} +3 -3
- package/dist/{chunk-JZJIWRF3.js.map → chunk-QSXPKZ2F.js.map} +1 -1
- package/dist/{chunk-MGMA5PEL.js → chunk-RFLFRIPV.js} +4 -4
- package/dist/{chunk-MGMA5PEL.js.map → chunk-RFLFRIPV.js.map} +1 -1
- package/dist/{chunk-SAEQMDAU.js → chunk-SFMORPWB.js} +4 -4
- package/dist/{chunk-SAEQMDAU.js.map → chunk-SFMORPWB.js.map} +1 -1
- package/dist/{chunk-ZTLYHRZT.cjs → chunk-U5BSCAMP.cjs} +5 -5
- package/dist/{chunk-ZTLYHRZT.cjs.map → chunk-U5BSCAMP.cjs.map} +1 -1
- package/dist/{chunk-TNN6Z52D.js → chunk-UEVR4B5S.js} +3 -3
- package/dist/{chunk-TNN6Z52D.js.map → chunk-UEVR4B5S.js.map} +1 -1
- package/dist/{chunk-TBCHYHNU.js → chunk-VBJY2CSK.js} +4 -4
- package/dist/{chunk-TBCHYHNU.js.map → chunk-VBJY2CSK.js.map} +1 -1
- package/dist/{chunk-DTQFYHDJ.cjs → chunk-VNRI5DAL.cjs} +20 -20
- package/dist/{chunk-DTQFYHDJ.cjs.map → chunk-VNRI5DAL.cjs.map} +1 -1
- package/dist/{chunk-ZWB7SZVI.cjs → chunk-W7B4WQ3L.cjs} +15 -15
- package/dist/{chunk-ZWB7SZVI.cjs.map → chunk-W7B4WQ3L.cjs.map} +1 -1
- package/dist/{chunk-ITXCE6KL.js → chunk-WAGBELKA.js} +3 -3
- package/dist/{chunk-ITXCE6KL.js.map → chunk-WAGBELKA.js.map} +1 -1
- package/dist/{chunk-WHV5ZSIO.cjs → chunk-WH56EW3H.cjs} +4 -4
- package/dist/{chunk-WHV5ZSIO.cjs.map → chunk-WH56EW3H.cjs.map} +1 -1
- package/dist/{chunk-LY2D45F2.cjs → chunk-XAS7LANM.cjs} +48 -48
- package/dist/{chunk-LY2D45F2.cjs.map → chunk-XAS7LANM.cjs.map} +1 -1
- package/dist/comments.cjs +29 -28
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +5 -4
- package/dist/comments.js.map +1 -1
- package/dist/embed.cjs +7 -6
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +4 -3
- package/dist/embed.js.map +1 -1
- package/dist/emoji.cjs +8 -7
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +4 -3
- package/dist/emoji.js.map +1 -1
- package/dist/find.cjs +9 -8
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +4 -3
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +18 -17
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.js +2 -1
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +30 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +8 -7
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +5 -4
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +8 -7
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +5 -4
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +14 -13
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +5 -4
- package/dist/presence.js.map +1 -1
- package/dist/stats.cjs +8 -7
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +4 -3
- package/dist/stats.js.map +1 -1
- package/dist/table.cjs +24 -23
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +4 -3
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +8 -7
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +4 -3
- package/dist/toc.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-ACSEYJJF.cjs.map +0 -1
- package/dist/chunk-QC35D2AU.js.map +0 -1
- package/dist/chunk-QEMGOL5L.cjs.map +0 -1
- package/dist/chunk-XJDPQFPU.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkIGZRZIAF_cjs = require('./chunk-IGZRZIAF.cjs');
|
|
4
4
|
var chunkA6PGQVTR_cjs = require('./chunk-A6PGQVTR.cjs');
|
|
5
5
|
var chunkVFSVN5IQ_cjs = require('./chunk-VFSVN5IQ.cjs');
|
|
6
6
|
var chunk7SVKLWDT_cjs = require('./chunk-7SVKLWDT.cjs');
|
|
@@ -238,6 +238,7 @@ var englishLabels = {
|
|
|
238
238
|
imageNoAlt: "Image, no description",
|
|
239
239
|
decorativeImage: "Decorative image",
|
|
240
240
|
noAltBadge: "No alt text",
|
|
241
|
+
addAltText: "No alt text, add alt text",
|
|
241
242
|
uploadFile: "Upload file",
|
|
242
243
|
dropFile: "Or drop or paste a file here.",
|
|
243
244
|
fileTools: "File tools",
|
|
@@ -408,7 +409,7 @@ function selectNode(controller, blockId) {
|
|
|
408
409
|
const { editor } = controller;
|
|
409
410
|
const { selection } = editor.state;
|
|
410
411
|
if (selection?.kind === "node" && selection.block === blockId) return;
|
|
411
|
-
|
|
412
|
+
chunkIGZRZIAF_cjs.dispatchSelection(controller, chunkVFSVN5IQ_cjs.nodeSelection(blockId));
|
|
412
413
|
}
|
|
413
414
|
function focusNode(controller, blockId) {
|
|
414
415
|
selectNode(controller, blockId);
|
|
@@ -1114,7 +1115,7 @@ function codeToParagraph(blockId) {
|
|
|
1114
1115
|
};
|
|
1115
1116
|
}
|
|
1116
1117
|
function leaveCode(controller, blockId, direction, addsLine = false) {
|
|
1117
|
-
const moved =
|
|
1118
|
+
const moved = chunkIGZRZIAF_cjs.moveToNeighbour(controller, blockId, direction);
|
|
1118
1119
|
if (!moved && !(addsLine && controller.run(insertBlocks([{ type: "MARKDOWN" }], "text", blockId)))) return false;
|
|
1119
1120
|
controller.focus();
|
|
1120
1121
|
return true;
|
|
@@ -1239,7 +1240,7 @@ function travel({ controller, blockId, area }, command) {
|
|
|
1239
1240
|
const before = area.value;
|
|
1240
1241
|
controller.run(command);
|
|
1241
1242
|
const { selection } = controller.editor.state;
|
|
1242
|
-
const edit2 =
|
|
1243
|
+
const edit2 = chunkIGZRZIAF_cjs.textDiff(before, area.value);
|
|
1243
1244
|
if (selection?.kind !== "node" || selection.block !== blockId) controller.focus();
|
|
1244
1245
|
else if (edit2 !== null) area.setSelectionRange(edit2.from + edit2.insert.length, edit2.from + edit2.insert.length);
|
|
1245
1246
|
return true;
|
|
@@ -1324,11 +1325,11 @@ function CodeEditor({ block, controller, field, focusControls }) {
|
|
|
1324
1325
|
useTypeIntoCode(controller, blockId, field, edit2);
|
|
1325
1326
|
const onKeyDown = (event) => {
|
|
1326
1327
|
const area = event.currentTarget;
|
|
1327
|
-
if (
|
|
1328
|
+
if (chunkIGZRZIAF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
1328
1329
|
const action = codeKeyAction(event, fieldOf(area), controller.isMac);
|
|
1329
1330
|
if (action !== null && runCodeAction(action, { controller, blockId, area, edit: edit2, focusControls })) event.preventDefault();
|
|
1330
1331
|
};
|
|
1331
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...{ [
|
|
1332
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...{ [chunkIGZRZIAF_cjs.NATIVE_INTERACTION]: "" }, dir: "ltr", className: "quoin-code-scroll", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-code-lines", children: [
|
|
1332
1333
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1333
1334
|
HighlightOverlay,
|
|
1334
1335
|
{
|
|
@@ -1398,7 +1399,7 @@ var Button = React7__namespace.forwardRef(function Button2({ className, variant
|
|
|
1398
1399
|
var COPIED_FOR_MS = 1500;
|
|
1399
1400
|
function CopyCodeButton({ code, controller }) {
|
|
1400
1401
|
const labels = useLabels();
|
|
1401
|
-
const readOnly =
|
|
1402
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
1402
1403
|
const [copied, setCopied] = React7.useState(false);
|
|
1403
1404
|
React7.useEffect(() => {
|
|
1404
1405
|
if (!copied) return;
|
|
@@ -1481,7 +1482,7 @@ var preventDefault = (event) => event.preventDefault();
|
|
|
1481
1482
|
|
|
1482
1483
|
// src/blocks/text/set-block-attrs.ts
|
|
1483
1484
|
function setBlockAttrs(controller, blockId, patch) {
|
|
1484
|
-
if (!controller.readOnly) controller.run(
|
|
1485
|
+
if (!controller.readOnly) controller.run(chunkIGZRZIAF_cjs.onBlock(blockId, chunkVFSVN5IQ_cjs.setAttrs(patch)));
|
|
1485
1486
|
}
|
|
1486
1487
|
var FIELD = `quoin-code-language quoin-code-control ${FOCUS_RING}`;
|
|
1487
1488
|
var CONTENT = `${MENU_CONTENT} flex max-h-64 w-48 flex-col overflow-y-hidden`;
|
|
@@ -1497,7 +1498,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1497
1498
|
const options = draft === null ? [] : languageOptions(draft === shown ? "" : draft, labels.plainText);
|
|
1498
1499
|
const open = options.length > 0;
|
|
1499
1500
|
const optionId = (index) => `${listboxId}-${index}`;
|
|
1500
|
-
|
|
1501
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
1501
1502
|
list.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
1502
1503
|
}, [active]);
|
|
1503
1504
|
const close = () => {
|
|
@@ -1523,7 +1524,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1523
1524
|
onDone();
|
|
1524
1525
|
};
|
|
1525
1526
|
const onKeyDown = (event) => {
|
|
1526
|
-
if (
|
|
1527
|
+
if (chunkIGZRZIAF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
1527
1528
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1528
1529
|
event.preventDefault();
|
|
1529
1530
|
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
@@ -1597,7 +1598,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1597
1598
|
}
|
|
1598
1599
|
var CodeBlock = ({ block, controller }) => {
|
|
1599
1600
|
const labels = useLabels();
|
|
1600
|
-
const readOnly =
|
|
1601
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
1601
1602
|
const languageField = React7.useRef(null);
|
|
1602
1603
|
const codeField = React7.useRef(null);
|
|
1603
1604
|
const code = chunkAIS37SL2_cjs.str(block.attrs.code);
|
|
@@ -1699,7 +1700,7 @@ function selectHandlers(controller, blockId, root, onSelect) {
|
|
|
1699
1700
|
return {
|
|
1700
1701
|
onKeyDown(event) {
|
|
1701
1702
|
const key = event.nativeEvent;
|
|
1702
|
-
if (
|
|
1703
|
+
if (chunkIGZRZIAF_cjs.isComposingKey(controller, key)) return;
|
|
1703
1704
|
if (event.key === "Escape") select();
|
|
1704
1705
|
else if (!(event.metaKey || event.ctrlKey) || event.target.matches("input:not([type=file])") || !controller.edit(() => controller.editor.handleKey(key)))
|
|
1705
1706
|
return;
|
|
@@ -1919,7 +1920,7 @@ var uploadFile = (controller, blockId, file, host) => uploadInto(
|
|
|
1919
1920
|
var anyFile = () => true;
|
|
1920
1921
|
var FileBlock = ({ block, controller }) => {
|
|
1921
1922
|
const labels = useLabels();
|
|
1922
|
-
const readOnly =
|
|
1923
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
1923
1924
|
const root = React7.useRef(null);
|
|
1924
1925
|
const filled = hasFile(block.attrs);
|
|
1925
1926
|
useNodeKeys(controller, block.id, !readOnly, !filled, root);
|
|
@@ -2069,7 +2070,7 @@ function useRovingFocus() {
|
|
|
2069
2070
|
},
|
|
2070
2071
|
[syncTabStop]
|
|
2071
2072
|
);
|
|
2072
|
-
|
|
2073
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(syncTabStop);
|
|
2073
2074
|
const onFocus = (event) => {
|
|
2074
2075
|
if (!owns(event.target)) return;
|
|
2075
2076
|
current.current = event.target;
|
|
@@ -2088,7 +2089,7 @@ function useRovingFocus() {
|
|
|
2088
2089
|
// src/menus/floating/use-focus-key.ts
|
|
2089
2090
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
2090
2091
|
function useFocusKey(controller, focus) {
|
|
2091
|
-
|
|
2092
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
2092
2093
|
const intercept = (event) => {
|
|
2093
2094
|
if (!isFocusKey(event)) return false;
|
|
2094
2095
|
event.preventDefault();
|
|
@@ -2100,11 +2101,11 @@ function useFocusKey(controller, focus) {
|
|
|
2100
2101
|
}
|
|
2101
2102
|
function NodeToolbar(props) {
|
|
2102
2103
|
const { blockId, controller, label, anchor, items, next, buttonRefs, children, popover } = props;
|
|
2103
|
-
const state =
|
|
2104
|
+
const state = chunkIGZRZIAF_cjs.useEditorState(controller, chunkIGZRZIAF_cjs.wholeState);
|
|
2104
2105
|
const roving = useRovingFocus();
|
|
2105
2106
|
useFocusKey(controller, roving.focusCurrent);
|
|
2106
2107
|
const onKeyDown = (event) => {
|
|
2107
|
-
if (!roving.owns(event.target) ||
|
|
2108
|
+
if (!roving.owns(event.target) || chunkIGZRZIAF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2108
2109
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
2109
2110
|
const ahead = tab && !event.shiftKey && next !== void 0 ? blockPart(controller, blockId, next) : void 0;
|
|
2110
2111
|
if (ahead !== void 0) ahead.focus();
|
|
@@ -2185,8 +2186,8 @@ var selectedBlock = (type, filled) => ({ doc, selection }) => {
|
|
|
2185
2186
|
return block?.type === type && filled(block.attrs) ? block.id : null;
|
|
2186
2187
|
};
|
|
2187
2188
|
function useToolbarBlock(controller, selected, keptFor = null) {
|
|
2188
|
-
const blockId =
|
|
2189
|
-
const readOnly =
|
|
2189
|
+
const blockId = chunkIGZRZIAF_cjs.useEditorState(controller, selected);
|
|
2190
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
2190
2191
|
const settled = useSelectionSettled(controller);
|
|
2191
2192
|
return blockId !== null && !readOnly && (settled || keptFor === blockId) ? blockId : null;
|
|
2192
2193
|
}
|
|
@@ -2265,7 +2266,7 @@ function ResizeHandles({ blockId, controller, frame, percent, centred, onPreview
|
|
|
2265
2266
|
const value = percent ?? drawn;
|
|
2266
2267
|
const write = (widthPercent) => setBlockAttrs(controller, blockId, { widthPercent });
|
|
2267
2268
|
const onKeyDown = (event) => {
|
|
2268
|
-
if (
|
|
2269
|
+
if (chunkIGZRZIAF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2269
2270
|
const next = keyedWidth(event.key, value);
|
|
2270
2271
|
if (event.key === "Escape") controller.focus();
|
|
2271
2272
|
else if (next === null) return;
|
|
@@ -2307,7 +2308,7 @@ function ResizeHandles({ blockId, controller, frame, percent, centred, onPreview
|
|
|
2307
2308
|
"aria-valuetext": labels.widthValue(value),
|
|
2308
2309
|
"data-side": side,
|
|
2309
2310
|
className: "quoin-image-handle",
|
|
2310
|
-
...{ [
|
|
2311
|
+
...{ [chunkIGZRZIAF_cjs.NATIVE_INTERACTION]: "" },
|
|
2311
2312
|
...bubblePart(controller),
|
|
2312
2313
|
onKeyDown,
|
|
2313
2314
|
onPointerDown: onPointerDown(side),
|
|
@@ -2334,6 +2335,9 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2334
2335
|
const width = preview ?? percent;
|
|
2335
2336
|
const flagged = !readOnly && alt === "" && attrs.decorative !== true;
|
|
2336
2337
|
const select = () => focusNode(controller, id);
|
|
2338
|
+
const badgeText = labels.noAltBadge ?? englishLabels.noAltBadge;
|
|
2339
|
+
const badgeName = labels.addAltText ?? englishLabels.addAltText;
|
|
2340
|
+
const translatedAlone = badgeText !== englishLabels.noAltBadge && badgeName === englishLabels.addAltText;
|
|
2337
2341
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2338
2342
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: frame, className: "quoin-image-frame", style: width === void 0 ? void 0 : { width: `${width}%` }, children: [
|
|
2339
2343
|
src !== null && src !== failed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2356,11 +2360,12 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2356
2360
|
{
|
|
2357
2361
|
type: "button",
|
|
2358
2362
|
className: "quoin-image-no-alt",
|
|
2363
|
+
"aria-label": translatedAlone ? void 0 : badgeName,
|
|
2359
2364
|
onClick: () => {
|
|
2360
2365
|
select();
|
|
2361
2366
|
requestAlt(controller, id);
|
|
2362
2367
|
},
|
|
2363
|
-
children:
|
|
2368
|
+
children: badgeText
|
|
2364
2369
|
}
|
|
2365
2370
|
),
|
|
2366
2371
|
!readOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2376,7 +2381,7 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2376
2381
|
)
|
|
2377
2382
|
] }),
|
|
2378
2383
|
(!readOnly || (regions.caption?.length ?? 0) > 0) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2379
|
-
|
|
2384
|
+
chunkIGZRZIAF_cjs.EditableRegion,
|
|
2380
2385
|
{
|
|
2381
2386
|
block: id,
|
|
2382
2387
|
region: "caption",
|
|
@@ -2540,7 +2545,7 @@ function useImageKeys(controller, blockId, picture, editable, root) {
|
|
|
2540
2545
|
}
|
|
2541
2546
|
var ImageBlock = ({ block, controller }) => {
|
|
2542
2547
|
const labels = useLabels();
|
|
2543
|
-
const readOnly =
|
|
2548
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
2544
2549
|
const root = React7.useRef(null);
|
|
2545
2550
|
const picture = hasPicture(block.attrs);
|
|
2546
2551
|
useImageKeys(controller, block.id, picture, !readOnly, root);
|
|
@@ -2553,17 +2558,17 @@ var ImageBlock = ({ block, controller }) => {
|
|
|
2553
2558
|
"aria-label": labels.blockNames.image,
|
|
2554
2559
|
contentEditable: false,
|
|
2555
2560
|
className: "quoin-image",
|
|
2556
|
-
...picture ? { [
|
|
2561
|
+
...picture ? { [chunkIGZRZIAF_cjs.NODE_ENTRY]: "" } : void 0,
|
|
2557
2562
|
children: picture ? /* @__PURE__ */ jsxRuntime.jsx(ImageFigure, { block, controller, readOnly }) : empty
|
|
2558
2563
|
}
|
|
2559
2564
|
);
|
|
2560
2565
|
};
|
|
2561
2566
|
function useOutsidePress(element, ownerDocument, onPress) {
|
|
2562
2567
|
const latest = React7.useRef(onPress);
|
|
2563
|
-
|
|
2568
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
2564
2569
|
latest.current = onPress;
|
|
2565
2570
|
});
|
|
2566
|
-
|
|
2571
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
2567
2572
|
const doc = ownerDocument();
|
|
2568
2573
|
const inside = (target) => element.current?.contains(target) === true;
|
|
2569
2574
|
let touched = null;
|
|
@@ -2578,7 +2583,7 @@ function useOutsidePress(element, ownerDocument, onPress) {
|
|
|
2578
2583
|
if (touched !== null && !inside(event.target)) latest.current(touched);
|
|
2579
2584
|
touched = null;
|
|
2580
2585
|
};
|
|
2581
|
-
return
|
|
2586
|
+
return chunkIGZRZIAF_cjs.listen(doc, { pointerdown: down, click }, true);
|
|
2582
2587
|
}, [element, ownerDocument]);
|
|
2583
2588
|
}
|
|
2584
2589
|
function storeAlt(controller, blockId, opened, patch) {
|
|
@@ -2586,7 +2591,7 @@ function storeAlt(controller, blockId, opened, patch) {
|
|
|
2586
2591
|
const attrs = chunkAIS37SL2_cjs.blockById(editor.state.doc, blockId)?.attrs ?? {};
|
|
2587
2592
|
const changed = chunkAIS37SL2_cjs.str(attrs.alt) !== opened.alt || attrs.decorative === true !== opened.decorative;
|
|
2588
2593
|
if (controller.readOnly || controller.root === null || changed) return;
|
|
2589
|
-
|
|
2594
|
+
chunkIGZRZIAF_cjs.onBlock(blockId, chunkVFSVN5IQ_cjs.setAttrs(patch))(editor.state, (tr) => editor.dispatch(tr));
|
|
2590
2595
|
}
|
|
2591
2596
|
function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative, onClose }) {
|
|
2592
2597
|
const labels = useLabels();
|
|
@@ -2628,7 +2633,7 @@ function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative,
|
|
|
2628
2633
|
close(true);
|
|
2629
2634
|
};
|
|
2630
2635
|
const onKeyDown = (event) => {
|
|
2631
|
-
if (event.key !== "Tab" ||
|
|
2636
|
+
if (event.key !== "Tab" || chunkIGZRZIAF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2632
2637
|
const controls = [...event.currentTarget.elements];
|
|
2633
2638
|
const next = controls[controls.indexOf(event.target) + (event.shiftKey ? -1 : 1)];
|
|
2634
2639
|
event.preventDefault();
|
|
@@ -2656,7 +2661,7 @@ function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative,
|
|
|
2656
2661
|
onCloseAutoFocus: preventDefault,
|
|
2657
2662
|
onEscapeKeyDown: (event) => {
|
|
2658
2663
|
event.preventDefault();
|
|
2659
|
-
if (!
|
|
2664
|
+
if (!chunkIGZRZIAF_cjs.isComposingKey(controller, event)) close(false);
|
|
2660
2665
|
},
|
|
2661
2666
|
...bubblePart(controller),
|
|
2662
2667
|
children: /* @__PURE__ */ jsxRuntime.jsxs("form", { noValidate: true, className: "quoin-image-alt", onSubmit: save, onKeyDown, children: [
|
|
@@ -2750,7 +2755,7 @@ function ImageToolbarOverlay({ controller }) {
|
|
|
2750
2755
|
}
|
|
2751
2756
|
function ImageToolbar({ blockId, controller, editingAlt, onEditAlt }) {
|
|
2752
2757
|
const { labels, resolveAssetUrl } = useQuoin();
|
|
2753
|
-
const state =
|
|
2758
|
+
const state = chunkIGZRZIAF_cjs.useEditorState(controller, chunkIGZRZIAF_cjs.wholeState);
|
|
2754
2759
|
const picker = useReplacePicker(controller, blockId, uploadImage, "image/*");
|
|
2755
2760
|
const altButton = React7.useRef(null);
|
|
2756
2761
|
const anchor = usePartAnchor(controller, blockId, ".quoin-image-frame");
|
|
@@ -2982,13 +2987,13 @@ function CalloutToneMenu({ blockId, controller, tone }) {
|
|
|
2982
2987
|
}
|
|
2983
2988
|
var CalloutBlock = ({ block, controller }) => {
|
|
2984
2989
|
const labels = useLabels();
|
|
2985
|
-
const readOnly =
|
|
2990
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
2986
2991
|
const tone = calloutTone(block.attrs.tone);
|
|
2987
2992
|
const icon = calloutIcon(block.attrs, tone);
|
|
2988
2993
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("quoin-callout group/callout flex items-start gap-2", TONE[tone]), "data-tone": tone, children: [
|
|
2989
2994
|
readOnly ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "flex size-6 items-center justify-center text-base", children: icon }) : /* @__PURE__ */ jsxRuntime.jsx(CalloutIconMenu, { blockId: block.id, controller, icon }),
|
|
2990
2995
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2991
|
-
|
|
2996
|
+
chunkIGZRZIAF_cjs.EditableRegion,
|
|
2992
2997
|
{
|
|
2993
2998
|
block: block.id,
|
|
2994
2999
|
region: "body",
|
|
@@ -3057,22 +3062,22 @@ var headingStyles = (level) => `quoin-heading mb-1 font-semibold leading-tight i
|
|
|
3057
3062
|
function Heading({ block }) {
|
|
3058
3063
|
const labels = useLabels();
|
|
3059
3064
|
const level = chunkAIS37SL2_cjs.headingLevel(block.attrs.level);
|
|
3060
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: headingStyles(level), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3065
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: headingStyles(level), children: /* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.heading(level) }) });
|
|
3061
3066
|
}
|
|
3062
3067
|
function NumberedItem({ block, controller }) {
|
|
3063
3068
|
const labels = useLabels();
|
|
3064
|
-
const number =
|
|
3069
|
+
const number = chunkIGZRZIAF_cjs.useOrderedNumber(controller, block.id);
|
|
3065
3070
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "ordered", children: [
|
|
3066
3071
|
/* @__PURE__ */ jsxRuntime.jsx(ListMarker, { list: "ordered", number, depth: block.indent }),
|
|
3067
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3072
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.numberedItem(number) })
|
|
3068
3073
|
] });
|
|
3069
3074
|
}
|
|
3070
3075
|
function TaskItem({ block, controller }) {
|
|
3071
3076
|
const labels = useLabels();
|
|
3072
|
-
const hostId =
|
|
3077
|
+
const hostId = chunkIGZRZIAF_cjs.useRegionDomId(block.id, REGION);
|
|
3073
3078
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-task", "data-checked": block.attrs.checked === true, children: [
|
|
3074
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3075
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3079
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.TaskCheckbox, { block, controller, label: labels.task, labelledBy: hostId }),
|
|
3080
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { id: hostId, block: block.id, region: REGION, label: labels.task })
|
|
3076
3081
|
] });
|
|
3077
3082
|
}
|
|
3078
3083
|
var MarkdownBlock = (props) => {
|
|
@@ -3084,16 +3089,16 @@ var MarkdownBlock = (props) => {
|
|
|
3084
3089
|
case "bullet":
|
|
3085
3090
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "bullet", children: [
|
|
3086
3091
|
/* @__PURE__ */ jsxRuntime.jsx(ListMarker, { list: "bullet", depth: block.indent }),
|
|
3087
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3092
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.bulletItem })
|
|
3088
3093
|
] });
|
|
3089
3094
|
case "ordered":
|
|
3090
3095
|
return /* @__PURE__ */ jsxRuntime.jsx(NumberedItem, { ...props });
|
|
3091
3096
|
case "task":
|
|
3092
3097
|
return /* @__PURE__ */ jsxRuntime.jsx(TaskItem, { ...props });
|
|
3093
3098
|
case "quote":
|
|
3094
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-quote", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3099
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-quote", children: /* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.quote }) });
|
|
3095
3100
|
default:
|
|
3096
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3101
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.paragraph });
|
|
3097
3102
|
}
|
|
3098
3103
|
};
|
|
3099
3104
|
|
|
@@ -3104,16 +3109,16 @@ function nestedBlockIds({ doc }, blockId) {
|
|
|
3104
3109
|
return doc.blocks.slice(index + 1, chunkVFSVN5IQ_cjs.descendantsEnd(doc, index)).map((block) => block.id);
|
|
3105
3110
|
}
|
|
3106
3111
|
function useNestedBlocks(controller, blockId) {
|
|
3107
|
-
return
|
|
3112
|
+
return chunkIGZRZIAF_cjs.useEditorState(controller, (state) => nestedBlockIds(state, blockId), chunkAIS37SL2_cjs.sameItems);
|
|
3108
3113
|
}
|
|
3109
3114
|
var ToggleBlock = ({ block, controller }) => {
|
|
3110
3115
|
const labels = useLabels();
|
|
3111
|
-
const domId =
|
|
3116
|
+
const domId = chunkIGZRZIAF_cjs.useBlockDomId();
|
|
3112
3117
|
const nested = useNestedBlocks(controller, block.id);
|
|
3113
|
-
const open =
|
|
3118
|
+
const open = chunkIGZRZIAF_cjs.useToggleOpen(controller, block);
|
|
3114
3119
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-toggle", "data-open": open, children: [
|
|
3115
3120
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3116
|
-
|
|
3121
|
+
chunkIGZRZIAF_cjs.ToggleChevron,
|
|
3117
3122
|
{
|
|
3118
3123
|
block,
|
|
3119
3124
|
controller,
|
|
@@ -3121,7 +3126,7 @@ var ToggleBlock = ({ block, controller }) => {
|
|
|
3121
3126
|
controls: nested.length === 0 ? void 0 : nested.map(domId).join(" ")
|
|
3122
3127
|
}
|
|
3123
3128
|
),
|
|
3124
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3129
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkIGZRZIAF_cjs.EditableRegion, { block: block.id, region: "text", label: labels.toggle })
|
|
3125
3130
|
] });
|
|
3126
3131
|
};
|
|
3127
3132
|
|
|
@@ -3215,7 +3220,7 @@ function ActionItem({ kit, controller, action, blockIds }) {
|
|
|
3215
3220
|
);
|
|
3216
3221
|
}
|
|
3217
3222
|
function BlockMenuItems({ kit, controller, blocks, styled, title, actions }) {
|
|
3218
|
-
const state =
|
|
3223
|
+
const state = chunkIGZRZIAF_cjs.useEditorState(controller, chunkIGZRZIAF_cjs.wholeState);
|
|
3219
3224
|
const blockIds = blocks.map((block) => block.id);
|
|
3220
3225
|
const shown = actions.filter((action) => action.available?.(state, blockIds) ?? true);
|
|
3221
3226
|
const anyText = styled.some((block) => chunkVFSVN5IQ_cjs.isTextFlow(state.schema, block));
|
|
@@ -3260,7 +3265,7 @@ var CONTEXT_KIT = {
|
|
|
3260
3265
|
SubTrigger: ContextMenuSubTrigger
|
|
3261
3266
|
};
|
|
3262
3267
|
var GUTTER_BLOCK = "data-quoin-gutter-block";
|
|
3263
|
-
var OWN_MENU = `[${
|
|
3268
|
+
var OWN_MENU = `[${chunkIGZRZIAF_cjs.NATIVE_INTERACTION}], input, textarea, select`;
|
|
3264
3269
|
function contextBlock(controller, target) {
|
|
3265
3270
|
const { state } = controller.editor;
|
|
3266
3271
|
const gutter = target.closest(`[${GUTTER_BLOCK}]`)?.getAttribute(GUTTER_BLOCK);
|
|
@@ -3289,7 +3294,7 @@ function useContextMenuOpener(controller, store, trigger) {
|
|
|
3289
3294
|
openBlockMenuAt(store, controller.editor.state, block, clientX, clientY);
|
|
3290
3295
|
hidden.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX, clientY }));
|
|
3291
3296
|
};
|
|
3292
|
-
return
|
|
3297
|
+
return chunkIGZRZIAF_cjs.listen(root, { mousedown: onMouseDown, contextmenu: onContextMenu });
|
|
3293
3298
|
}, [controller, store, trigger]);
|
|
3294
3299
|
}
|
|
3295
3300
|
|
|
@@ -3325,7 +3330,7 @@ function useLiveBlocks(controller, blockIds) {
|
|
|
3325
3330
|
(state) => blockIds.flatMap((id) => chunkAIS37SL2_cjs.blockById(state.doc, id) ?? []),
|
|
3326
3331
|
[blockIds]
|
|
3327
3332
|
);
|
|
3328
|
-
return
|
|
3333
|
+
return chunkIGZRZIAF_cjs.useEditorState(controller, select, chunkAIS37SL2_cjs.sameItems);
|
|
3329
3334
|
}
|
|
3330
3335
|
function useMenuBlocks(controller, store, menu) {
|
|
3331
3336
|
const labels = useLabels();
|
|
@@ -3452,7 +3457,7 @@ var DragOverlay = React7.forwardRef(function DragOverlay2(_props, ref) {
|
|
|
3452
3457
|
var DELETION_STEPS = /* @__PURE__ */ new Set(["removeBlocks", "setIndent"]);
|
|
3453
3458
|
function drawnPosition(doc, blockId) {
|
|
3454
3459
|
const index = doc.index.get(blockId) ?? 0;
|
|
3455
|
-
return [
|
|
3460
|
+
return [chunkIGZRZIAF_cjs.drawnBlockCount(doc, 0, index) + 1, chunkIGZRZIAF_cjs.drawnBlockCount(doc)];
|
|
3456
3461
|
}
|
|
3457
3462
|
function blockMovedMessage(doc, blockId, labels) {
|
|
3458
3463
|
return labels.blockMoved(...drawnPosition(doc, blockId));
|
|
@@ -3468,7 +3473,7 @@ function deletedCount(tr) {
|
|
|
3468
3473
|
return tr.steps.reduce((deleted, step, i) => {
|
|
3469
3474
|
const { index, count } = step.toJSON();
|
|
3470
3475
|
if (step.stepType !== "removeBlocks" || typeof index !== "number" || typeof count !== "number") return deleted;
|
|
3471
|
-
return deleted +
|
|
3476
|
+
return deleted + chunkIGZRZIAF_cjs.drawnBlockCount(tr.docs[i], index, index + count);
|
|
3472
3477
|
}, 0);
|
|
3473
3478
|
}
|
|
3474
3479
|
function insertedBlock(tr) {
|
|
@@ -3510,7 +3515,7 @@ function inlineEdges(shell, box, rtl) {
|
|
|
3510
3515
|
function measure(controller, root, moved, rtl) {
|
|
3511
3516
|
const { doc } = controller.editor.state;
|
|
3512
3517
|
const origin = rootOrigin(root);
|
|
3513
|
-
return
|
|
3518
|
+
return chunkIGZRZIAF_cjs.visibleBlockIndexes(doc).flatMap((index) => {
|
|
3514
3519
|
const { id, indent: indent3 } = doc.blocks[index];
|
|
3515
3520
|
const shell = controller.blockElement(id);
|
|
3516
3521
|
if (shell === void 0) return [];
|
|
@@ -3585,7 +3590,7 @@ function draggedBlocks(controller, blockId) {
|
|
|
3585
3590
|
function followPress(press, root, view) {
|
|
3586
3591
|
const { controller, store, overlay, handle: handle2, pointerId } = press;
|
|
3587
3592
|
const doc = view.document;
|
|
3588
|
-
const scroll =
|
|
3593
|
+
const scroll = chunkIGZRZIAF_cjs.createAutoScroll(root, follow, SCROLL_EDGE);
|
|
3589
3594
|
let pointer = { x: press.x, y: press.y };
|
|
3590
3595
|
let active = null;
|
|
3591
3596
|
let unsubscribe = () => {
|
|
@@ -3660,9 +3665,9 @@ function followPress(press, root, view) {
|
|
|
3660
3665
|
event.stopPropagation();
|
|
3661
3666
|
finish();
|
|
3662
3667
|
}
|
|
3663
|
-
const unlistenDocument =
|
|
3664
|
-
const unlistenBlur =
|
|
3665
|
-
const unlistenKeys =
|
|
3668
|
+
const unlistenDocument = chunkIGZRZIAF_cjs.listen(doc, { pointermove: onPointerMove, pointerup: onPointerUp, pointercancel: finish });
|
|
3669
|
+
const unlistenBlur = chunkIGZRZIAF_cjs.listen(view, { blur: finish });
|
|
3670
|
+
const unlistenKeys = chunkIGZRZIAF_cjs.listen(view, { keydown: onKeyDown }, true);
|
|
3666
3671
|
return finish;
|
|
3667
3672
|
}
|
|
3668
3673
|
function pressDragHandle(press) {
|
|
@@ -3797,7 +3802,7 @@ function place2(controller, root, gutter, block) {
|
|
|
3797
3802
|
gutter.style.visibility = "";
|
|
3798
3803
|
}
|
|
3799
3804
|
function useGutterPosition(controller, gutter, block) {
|
|
3800
|
-
|
|
3805
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
3801
3806
|
const element = gutter.current;
|
|
3802
3807
|
const root = controller.root;
|
|
3803
3808
|
const view = root?.ownerDocument.defaultView;
|
|
@@ -3829,7 +3834,7 @@ function blockAcross(controller, root, y) {
|
|
|
3829
3834
|
}
|
|
3830
3835
|
function useGutterTarget(controller, store, gutter) {
|
|
3831
3836
|
const hovered = useCanvasUi(store, (state) => state.hoveredBlock);
|
|
3832
|
-
const head =
|
|
3837
|
+
const head = chunkIGZRZIAF_cjs.useEditorState(controller, headOf);
|
|
3833
3838
|
const [focusWithin, setFocusWithin] = React7.useState(false);
|
|
3834
3839
|
React7.useEffect(() => {
|
|
3835
3840
|
const root = controller.root;
|
|
@@ -3847,7 +3852,7 @@ function useGutterTarget(controller, store, gutter) {
|
|
|
3847
3852
|
const onFocusIn = () => setFocusWithin(true);
|
|
3848
3853
|
const onFocusOut = (event) => setFocusWithin(root.contains(event.relatedTarget));
|
|
3849
3854
|
setFocusWithin(root.contains(root.ownerDocument.activeElement));
|
|
3850
|
-
return
|
|
3855
|
+
return chunkIGZRZIAF_cjs.listen(root, { pointermove: onPointerMove, pointerleave: onPointerLeave, focusin: onFocusIn, focusout: onFocusOut });
|
|
3851
3856
|
}, [controller, store, gutter]);
|
|
3852
3857
|
const fallback = focusWithin ? head : null;
|
|
3853
3858
|
const target = hovered ?? fallback;
|
|
@@ -3944,7 +3949,7 @@ function pointInHost(host, { node, offset }) {
|
|
|
3944
3949
|
return host.contains(node) ? { node, offset: Math.min(offset, nodeLength(node)) } : null;
|
|
3945
3950
|
}
|
|
3946
3951
|
function textRect(host, { from, to }) {
|
|
3947
|
-
const map =
|
|
3952
|
+
const map = chunkIGZRZIAF_cjs.domMapOf(host);
|
|
3948
3953
|
const range = host.ownerDocument.createRange();
|
|
3949
3954
|
if (map === void 0 || typeof range.getBoundingClientRect !== "function") return null;
|
|
3950
3955
|
const start = pointInHost(host, map.toDom(from, 1));
|
|
@@ -3957,7 +3962,7 @@ function textRect(host, { from, to }) {
|
|
|
3957
3962
|
}
|
|
3958
3963
|
function rangeRect(controller, range) {
|
|
3959
3964
|
const host = controller.registry.get(range.block, range.region);
|
|
3960
|
-
if (host === void 0 || !host.isConnected || controller.composingKey ===
|
|
3965
|
+
if (host === void 0 || !host.isConnected || controller.composingKey === chunkIGZRZIAF_cjs.hostKey(range.block, range.region)) {
|
|
3961
3966
|
return null;
|
|
3962
3967
|
}
|
|
3963
3968
|
const rect = textRect(host, range);
|
|
@@ -3998,7 +4003,7 @@ function useSelectionAnchor(controller, state) {
|
|
|
3998
4003
|
[controller, state]
|
|
3999
4004
|
);
|
|
4000
4005
|
const [side, setSide] = React7.useState("top");
|
|
4001
|
-
|
|
4006
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4002
4007
|
const rect = selectionRect(controller);
|
|
4003
4008
|
if (rect) setSide(rect.top < ROOM_ABOVE ? "bottom" : "top");
|
|
4004
4009
|
}, [controller, state]);
|
|
@@ -4080,7 +4085,7 @@ function TurnIntoDropdown({ controller, state }) {
|
|
|
4080
4085
|
}
|
|
4081
4086
|
var DIVIDER = "mx-0.5 h-5 w-px shrink-0 bg-border";
|
|
4082
4087
|
function BubbleToolbar({ controller, labels, store, extraItems }) {
|
|
4083
|
-
const state =
|
|
4088
|
+
const state = chunkIGZRZIAF_cjs.useEditorState(controller, chunkIGZRZIAF_cjs.wholeState);
|
|
4084
4089
|
const { anchor, side } = useSelectionAnchor(controller, state);
|
|
4085
4090
|
const roving = useRovingFocus();
|
|
4086
4091
|
const items = React7.useMemo(() => bubbleItems(labels, () => store.set({ linkPopover: { open: true } })), [labels, store]);
|
|
@@ -4144,8 +4149,8 @@ var useFinePointer = () => useMediaQuery("(pointer: fine)", true);
|
|
|
4144
4149
|
// src/menus/bubble/use-bubble-visibility.ts
|
|
4145
4150
|
var hasTextRange = (state) => state.selection?.kind === "text" && !chunkVFSVN5IQ_cjs.isCollapsed(state.selection) && chunkVFSVN5IQ_cjs.markRanges(state).length > 0;
|
|
4146
4151
|
function useBubbleVisibility(controller) {
|
|
4147
|
-
const range =
|
|
4148
|
-
const readOnly =
|
|
4152
|
+
const range = chunkIGZRZIAF_cjs.useEditorState(controller, hasTextRange);
|
|
4153
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
4149
4154
|
const fine = useFinePointer();
|
|
4150
4155
|
const settled = useSelectionSettled(controller);
|
|
4151
4156
|
return range && !readOnly && fine && settled;
|
|
@@ -4168,7 +4173,7 @@ function bubbleExtension() {
|
|
|
4168
4173
|
// src/menus/link/link-at-selection.ts
|
|
4169
4174
|
function linkAround(state, from, to = from) {
|
|
4170
4175
|
if (from.block !== to.block || from.region !== to.region) return null;
|
|
4171
|
-
const inline =
|
|
4176
|
+
const inline = chunkIGZRZIAF_cjs.regionInline(state, from.block, from.region) ?? [];
|
|
4172
4177
|
const extent = chunkVFSVN5IQ_cjs.markExtent(inline, from.offset, "link");
|
|
4173
4178
|
if (extent === null || to.offset > extent.to) return null;
|
|
4174
4179
|
const attrs = chunkAIS37SL2_cjs.sliceInline(inline, extent.from, extent.to)[0]?.marks.find((mark) => mark.type === "link")?.attrs;
|
|
@@ -4191,7 +4196,7 @@ function linkElementAt(controller, target) {
|
|
|
4191
4196
|
}
|
|
4192
4197
|
function linkAtElement(controller, state, element) {
|
|
4193
4198
|
const host = controller.registry.locate(element);
|
|
4194
|
-
const offset = host === null ? null :
|
|
4199
|
+
const offset = host === null ? null : chunkIGZRZIAF_cjs.domMapOf(host.element)?.fromDom(element, 0) ?? null;
|
|
4195
4200
|
if (host === null || offset === null) return null;
|
|
4196
4201
|
return linkAround(state, { block: host.block, region: host.region, offset });
|
|
4197
4202
|
}
|
|
@@ -4244,7 +4249,7 @@ function caretLinkKey(state) {
|
|
|
4244
4249
|
return link && [link.range.block, link.range.region, link.range.from, link.href].join("\0");
|
|
4245
4250
|
}
|
|
4246
4251
|
function useCaretInLink(controller, delay) {
|
|
4247
|
-
const key =
|
|
4252
|
+
const key = chunkIGZRZIAF_cjs.useEditorState(controller, caretLinkKey);
|
|
4248
4253
|
const settled = useSelectionSettled(controller);
|
|
4249
4254
|
return useRestedValue(settled ? key : null, delay) !== null;
|
|
4250
4255
|
}
|
|
@@ -4278,7 +4283,7 @@ var URL_LENGTH = 48;
|
|
|
4278
4283
|
var CARD = "flex w-auto items-center gap-0.5 py-1 ps-3 pe-1 shadow-md";
|
|
4279
4284
|
var ADDRESS = "me-1 whitespace-nowrap text-sm text-muted-foreground";
|
|
4280
4285
|
function LinkCard({ controller, labels, store, cardRef, element, onUnlinked }) {
|
|
4281
|
-
const state =
|
|
4286
|
+
const state = chunkIGZRZIAF_cjs.useEditorState(controller, chunkIGZRZIAF_cjs.wholeState);
|
|
4282
4287
|
const link = React7.useMemo(
|
|
4283
4288
|
() => element === null ? linkAtSelection(state) : linkAtElement(controller, state, element),
|
|
4284
4289
|
[controller, state, element]
|
|
@@ -4296,7 +4301,7 @@ function LinkCard({ controller, labels, store, cardRef, element, onUnlinked }) {
|
|
|
4296
4301
|
const edit2 = () => {
|
|
4297
4302
|
if (element !== null) {
|
|
4298
4303
|
const selection = chunkVFSVN5IQ_cjs.textSelection({ block, region, offset: from }, { block, region, offset: to });
|
|
4299
|
-
|
|
4304
|
+
chunkIGZRZIAF_cjs.dispatchSelection(controller, selection);
|
|
4300
4305
|
}
|
|
4301
4306
|
store.set({ linkPopover: { open: true } });
|
|
4302
4307
|
};
|
|
@@ -4463,7 +4468,7 @@ function LinkOverlay({ controller }) {
|
|
|
4463
4468
|
const labels = useLabels();
|
|
4464
4469
|
const store = useCanvasUiStore();
|
|
4465
4470
|
const popoverOpen = useCanvasUi(store, isPopoverOpen);
|
|
4466
|
-
const readOnly =
|
|
4471
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
4467
4472
|
useLinkClicks(controller);
|
|
4468
4473
|
React7.useEffect(() => {
|
|
4469
4474
|
if (readOnly && store.get().linkPopover.open) store.set({ linkPopover: { open: false } });
|
|
@@ -4641,10 +4646,10 @@ function useRangeAnchor(controller, range) {
|
|
|
4641
4646
|
const [side, setSide] = React7.useState("bottom");
|
|
4642
4647
|
const latest = React7.useRef(range);
|
|
4643
4648
|
const start = range === null ? null : `${range.block} ${range.region} ${range.from}`;
|
|
4644
|
-
|
|
4649
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4645
4650
|
latest.current = range;
|
|
4646
4651
|
});
|
|
4647
|
-
|
|
4652
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4648
4653
|
const rect = latest.current && rangeRect(controller, latest.current);
|
|
4649
4654
|
if (rect) setSide(sideFor(rect, window.innerHeight));
|
|
4650
4655
|
}, [controller, start]);
|
|
@@ -4670,11 +4675,11 @@ function openCombobox(host, listboxId) {
|
|
|
4670
4675
|
}
|
|
4671
4676
|
function useComboboxHost(controller, block, region, listboxId, activeOptionId) {
|
|
4672
4677
|
const host = React7.useRef(null);
|
|
4673
|
-
|
|
4678
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4674
4679
|
host.current = block === null || region === null ? null : controller.registry.get(block, region) ?? null;
|
|
4675
4680
|
return host.current === null ? void 0 : openCombobox(host.current, listboxId);
|
|
4676
4681
|
}, [controller, block, region, listboxId]);
|
|
4677
|
-
|
|
4682
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4678
4683
|
if (host.current !== null) restore(host.current, "aria-activedescendant", activeOptionId);
|
|
4679
4684
|
}, [block, region, activeOptionId]);
|
|
4680
4685
|
}
|
|
@@ -4720,10 +4725,10 @@ function handle(event, menu) {
|
|
|
4720
4725
|
}
|
|
4721
4726
|
function useSuggestionKeys(controller, open, menu) {
|
|
4722
4727
|
const latest = React7.useRef(menu);
|
|
4723
|
-
|
|
4728
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4724
4729
|
latest.current = menu;
|
|
4725
4730
|
});
|
|
4726
|
-
|
|
4731
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4727
4732
|
if (!open) return;
|
|
4728
4733
|
const intercept = (event) => {
|
|
4729
4734
|
const handled = handle(event, latest.current);
|
|
@@ -4744,10 +4749,10 @@ var isPromise = (value) => typeof value?.then === "function";
|
|
|
4744
4749
|
function useSuggestionResults(source, query, onError) {
|
|
4745
4750
|
const [answer, setAnswer] = React7.useState(FORGOTTEN);
|
|
4746
4751
|
const report = React7.useRef(onError);
|
|
4747
|
-
|
|
4752
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4748
4753
|
report.current = onError;
|
|
4749
4754
|
});
|
|
4750
|
-
|
|
4755
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4751
4756
|
if (query === null) {
|
|
4752
4757
|
setAnswer(FORGOTTEN);
|
|
4753
4758
|
return;
|
|
@@ -4791,9 +4796,9 @@ function useSuggestion({
|
|
|
4791
4796
|
emptyLabel
|
|
4792
4797
|
}) {
|
|
4793
4798
|
const { labels, onError } = useQuoin();
|
|
4794
|
-
const readOnly =
|
|
4799
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
4795
4800
|
const selectTrigger = React7.useCallback((state) => chunkVFSVN5IQ_cjs.getPluginState(state, pluginKey).active, [pluginKey]);
|
|
4796
|
-
const active =
|
|
4801
|
+
const active = chunkIGZRZIAF_cjs.useEditorState(controller, selectTrigger);
|
|
4797
4802
|
const trigger = readOnly ? null : active;
|
|
4798
4803
|
const results = useSuggestionResults(source, trigger?.query ?? null, onError);
|
|
4799
4804
|
const sections = React7.useMemo(() => groupItems(results.items, groupOf2), [results.items, groupOf2]);
|
|
@@ -4863,7 +4868,7 @@ function SuggestionMenu(props) {
|
|
|
4863
4868
|
const { trigger, sections, activeIndex, listboxId } = suggestion;
|
|
4864
4869
|
const { anchor, side } = useRangeAnchor(controller, trigger);
|
|
4865
4870
|
const listbox = React7.useRef(null);
|
|
4866
|
-
|
|
4871
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
4867
4872
|
listbox.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
4868
4873
|
}, [activeIndex, sections]);
|
|
4869
4874
|
if (trigger === null) return null;
|
|
@@ -4942,7 +4947,7 @@ var TEXT_STEPS = /* @__PURE__ */ new Set(["replaceInline", "addMark", "removeMar
|
|
|
4942
4947
|
var WHITESPACE3 = /\s/;
|
|
4943
4948
|
var changesBlocks = (tr) => tr !== null && tr.steps.some((step) => !TEXT_STEPS.has(step.stepType));
|
|
4944
4949
|
function withSpaceBefore(state, range) {
|
|
4945
|
-
const inline =
|
|
4950
|
+
const inline = chunkIGZRZIAF_cjs.regionInline(state, range.block, range.region);
|
|
4946
4951
|
if (inline === void 0 || range.from === 0) return null;
|
|
4947
4952
|
const text2 = chunkAIS37SL2_cjs.inlineText(inline);
|
|
4948
4953
|
const after = text2.charAt(range.to);
|
|
@@ -5128,7 +5133,7 @@ function placement(viewport) {
|
|
|
5128
5133
|
function EditingTools({ controller }) {
|
|
5129
5134
|
const labels = useLabels();
|
|
5130
5135
|
const store = useCanvasUiStore();
|
|
5131
|
-
const state =
|
|
5136
|
+
const state = chunkIGZRZIAF_cjs.useEditorState(controller, chunkIGZRZIAF_cjs.wholeState);
|
|
5132
5137
|
const viewport = useVisualViewport();
|
|
5133
5138
|
const roving = useRovingFocus();
|
|
5134
5139
|
const items = React7.useMemo(() => mobileItems(labels, () => store.set({ linkPopover: { open: true } })), [labels, store]);
|
|
@@ -5432,9 +5437,27 @@ function insertAfterBlock(controller, blockId, type, definitions, onError) {
|
|
|
5432
5437
|
controller.run(insertBlockToWrite({ type, ...content }, opensEditor(definitions, type), blockId));
|
|
5433
5438
|
return true;
|
|
5434
5439
|
}
|
|
5440
|
+
|
|
5441
|
+
// src/blocks/void/history-keys.ts
|
|
5442
|
+
var NOT_TEXT_INPUTS = /* @__PURE__ */ new Set(["button", "checkbox", "color", "file", "image", "radio", "range", "reset", "submit"]);
|
|
5443
|
+
function isTextField(element) {
|
|
5444
|
+
if (element instanceof HTMLInputElement) return !NOT_TEXT_INPUTS.has(element.type);
|
|
5445
|
+
if (element instanceof HTMLTextAreaElement) return true;
|
|
5446
|
+
const editable = element.closest("[contenteditable]");
|
|
5447
|
+
return editable !== null && editable.getAttribute("contenteditable") !== "false";
|
|
5448
|
+
}
|
|
5449
|
+
function isHistoryKey(controller, event) {
|
|
5450
|
+
const mod = controller.isMac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
|
|
5451
|
+
const key = event.key.toLowerCase();
|
|
5452
|
+
return mod && !event.altKey && (key === "z" || key === "y" && !event.shiftKey);
|
|
5453
|
+
}
|
|
5454
|
+
function runHistoryKey(controller, event) {
|
|
5455
|
+
if (!isHistoryKey(controller, event) || isTextField(event.target)) return false;
|
|
5456
|
+
return controller.edit(() => controller.editor.handleKey(event.nativeEvent));
|
|
5457
|
+
}
|
|
5435
5458
|
function useBlockIndex(controller, blockId) {
|
|
5436
5459
|
const select = React7.useCallback((state) => state.doc.index.get(blockId) ?? -1, [blockId]);
|
|
5437
|
-
return
|
|
5460
|
+
return chunkIGZRZIAF_cjs.useEditorState(controller, select);
|
|
5438
5461
|
}
|
|
5439
5462
|
var FOCUSABLE = [
|
|
5440
5463
|
"input:not([disabled])",
|
|
@@ -5461,8 +5484,8 @@ function useEditingFocus(root, editing, stop) {
|
|
|
5461
5484
|
const leaveUnlessInside = (event) => {
|
|
5462
5485
|
if (!inside.current.has(event)) stop();
|
|
5463
5486
|
};
|
|
5464
|
-
const unlistenCapture =
|
|
5465
|
-
const unlisten =
|
|
5487
|
+
const unlistenCapture = chunkIGZRZIAF_cjs.listen(doc, { pointerdown: leaveForCanvas }, true);
|
|
5488
|
+
const unlisten = chunkIGZRZIAF_cjs.listen(doc, { pointerdown: leaveUnlessInside, focusin: leaveUnlessInside });
|
|
5466
5489
|
return () => {
|
|
5467
5490
|
unlistenCapture();
|
|
5468
5491
|
unlisten();
|
|
@@ -5485,16 +5508,19 @@ function VoidPreview({ definition: { preview: Preview }, name, ...props }) {
|
|
|
5485
5508
|
if (Preview === void 0) return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-1 text-sm text-muted-foreground", children: name });
|
|
5486
5509
|
return /* @__PURE__ */ jsxRuntime.jsx(Preview, { ...props });
|
|
5487
5510
|
}
|
|
5511
|
+
function VoidEditor({ Editor, controller, ...props }) {
|
|
5512
|
+
const index = useBlockIndex(controller, props.blockId);
|
|
5513
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Editor, { ...props, index });
|
|
5514
|
+
}
|
|
5488
5515
|
function VoidBlock({ block, controller, definition }) {
|
|
5489
5516
|
const { blockTypes, labels } = useQuoin();
|
|
5490
|
-
const { report } = React7.useContext(
|
|
5491
|
-
const readOnly =
|
|
5517
|
+
const { report } = React7.useContext(chunkIGZRZIAF_cjs.BlockErrorContext);
|
|
5518
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
5492
5519
|
const { editor: Editor, alwaysEditing = false } = definition;
|
|
5493
5520
|
const name = blockTypeLabel(labels, block, blockTypes);
|
|
5494
5521
|
const blockId = block.id;
|
|
5495
5522
|
const editable = Editor !== void 0 && !readOnly;
|
|
5496
5523
|
const { editing, start, stop } = useVoidEditing(controller, blockId, editable);
|
|
5497
|
-
const index = useBlockIndex(controller, blockId);
|
|
5498
5524
|
const root = React7.useRef(null);
|
|
5499
5525
|
const focusHandlers = useEditingFocus(root, editing, stop);
|
|
5500
5526
|
useMissingPreviewWarning(readOnly, definition);
|
|
@@ -5530,6 +5556,10 @@ function VoidBlock({ block, controller, definition }) {
|
|
|
5530
5556
|
const editorShown = editable && (alwaysEditing || editing);
|
|
5531
5557
|
const data = React7.useMemo(() => chunkA6PGQVTR_cjs.parsedData(definition, readBlockData(controller, block)), [definition, controller, block]);
|
|
5532
5558
|
const onKeyDown = (event) => {
|
|
5559
|
+
if (!editorShown && !readOnly && isInteractive(root.current, event) && runHistoryKey(controller, event)) {
|
|
5560
|
+
event.preventDefault();
|
|
5561
|
+
return;
|
|
5562
|
+
}
|
|
5533
5563
|
if (event.key !== "Escape" || !editorShown || !root.current?.contains(event.target)) return;
|
|
5534
5564
|
event.preventDefault();
|
|
5535
5565
|
leave();
|
|
@@ -5549,19 +5579,20 @@ function VoidBlock({ block, controller, definition }) {
|
|
|
5549
5579
|
role: "group",
|
|
5550
5580
|
"aria-label": name,
|
|
5551
5581
|
tabIndex: editorShown ? -1 : void 0,
|
|
5552
|
-
...{ [
|
|
5582
|
+
...{ [chunkIGZRZIAF_cjs.NATIVE_INTERACTION]: editorShown ? "" : void 0 },
|
|
5553
5583
|
onKeyDown,
|
|
5554
5584
|
...focusHandlers,
|
|
5555
5585
|
onClick,
|
|
5556
5586
|
onDoubleClick,
|
|
5557
5587
|
children: [
|
|
5558
5588
|
editorShown && Editor ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5559
|
-
|
|
5589
|
+
VoidEditor,
|
|
5560
5590
|
{
|
|
5591
|
+
Editor,
|
|
5592
|
+
controller,
|
|
5561
5593
|
data,
|
|
5562
5594
|
onChange,
|
|
5563
5595
|
blockId,
|
|
5564
|
-
index,
|
|
5565
5596
|
onRemove,
|
|
5566
5597
|
onInsertBlock,
|
|
5567
5598
|
onDone: leave
|
|
@@ -5767,7 +5798,7 @@ function deletions(codec, tr) {
|
|
|
5767
5798
|
}
|
|
5768
5799
|
function useDeleteReporter(controller, onDelete) {
|
|
5769
5800
|
const latest = React7.useRef(onDelete);
|
|
5770
|
-
|
|
5801
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
5771
5802
|
latest.current = onDelete;
|
|
5772
5803
|
});
|
|
5773
5804
|
React7.useEffect(() => {
|
|
@@ -5839,7 +5870,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5839
5870
|
);
|
|
5840
5871
|
useTypedInPlaceWarning(blockTypes, readOnly);
|
|
5841
5872
|
const [focusOnMount] = React7.useState(autoFocus);
|
|
5842
|
-
const controller =
|
|
5873
|
+
const controller = chunkIGZRZIAF_cjs.useQuoinEditor({
|
|
5843
5874
|
blocks,
|
|
5844
5875
|
onChange,
|
|
5845
5876
|
readOnly,
|
|
@@ -5883,7 +5914,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5883
5914
|
[controller, resolveAssetUrl]
|
|
5884
5915
|
);
|
|
5885
5916
|
return /* @__PURE__ */ jsxRuntime.jsx(QuoinProvider, { value: { blockTypes, upload, resolveAssetUrl, onError, highlight, controller, labels }, children: /* @__PURE__ */ jsxRuntime.jsx(VoidEditingContext.Provider, { value: voidEditing, children: /* @__PURE__ */ jsxRuntime.jsx(SlashItemsProvider, { value: slashItems, children: /* @__PURE__ */ jsxRuntime.jsx(BubbleItemsProvider, { value: ui.bubbleItems, children: /* @__PURE__ */ jsxRuntime.jsx(CanvasUiProvider, { value: uiStore, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5886
|
-
|
|
5917
|
+
chunkIGZRZIAF_cjs.EditorView,
|
|
5887
5918
|
{
|
|
5888
5919
|
controller,
|
|
5889
5920
|
renderers: ui.renderers,
|
|
@@ -6161,5 +6192,5 @@ exports.useQuoin = useQuoin;
|
|
|
6161
6192
|
exports.useRangeAnchor = useRangeAnchor;
|
|
6162
6193
|
exports.useRovingFocus = useRovingFocus;
|
|
6163
6194
|
exports.virtualAnchor = virtualAnchor;
|
|
6164
|
-
//# sourceMappingURL=chunk-
|
|
6165
|
-
//# sourceMappingURL=chunk-
|
|
6195
|
+
//# sourceMappingURL=chunk-7XQGOCUG.cjs.map
|
|
6196
|
+
//# sourceMappingURL=chunk-7XQGOCUG.cjs.map
|