quoin-editor 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/ai.cjs +80 -79
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +8 -7
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +26 -25
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +17 -16
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-RHQPAW4W.js → chunk-36OSSZDK.js} +6 -6
- package/dist/{chunk-RHQPAW4W.js.map → chunk-36OSSZDK.js.map} +1 -1
- package/dist/{chunk-3BXUGX5F.js → chunk-3G4ZWUUY.js} +4 -16
- package/dist/chunk-3G4ZWUUY.js.map +1 -0
- package/dist/{chunk-DTQFYHDJ.cjs → chunk-5DEPLPDS.cjs} +28 -28
- package/dist/{chunk-DTQFYHDJ.cjs.map → chunk-5DEPLPDS.cjs.map} +1 -1
- package/dist/{chunk-2EQ6FKSK.js → chunk-5LWJDRWD.js} +3 -3
- package/dist/{chunk-2EQ6FKSK.js.map → chunk-5LWJDRWD.js.map} +1 -1
- package/dist/{chunk-ITXCE6KL.js → chunk-5QNNF5ZJ.js} +5 -5
- package/dist/{chunk-ITXCE6KL.js.map → chunk-5QNNF5ZJ.js.map} +1 -1
- package/dist/{chunk-AIS37SL2.cjs → chunk-6H76FAI3.cjs} +79 -7
- package/dist/chunk-6H76FAI3.cjs.map +1 -0
- package/dist/{chunk-SKZC4K5S.cjs → chunk-6QLA3JOU.cjs} +90 -90
- package/dist/{chunk-SKZC4K5S.cjs.map → chunk-6QLA3JOU.cjs.map} +1 -1
- package/dist/{chunk-QEMGOL5L.cjs → chunk-ABVSP2XR.cjs} +325 -295
- package/dist/chunk-ABVSP2XR.cjs.map +1 -0
- package/dist/{chunk-KSF2HILJ.js → chunk-AQNVYFEU.js} +6 -6
- package/dist/{chunk-KSF2HILJ.js.map → chunk-AQNVYFEU.js.map} +1 -1
- package/dist/{chunk-ZTLYHRZT.cjs → chunk-BMEEEI43.cjs} +13 -13
- package/dist/{chunk-ZTLYHRZT.cjs.map → chunk-BMEEEI43.cjs.map} +1 -1
- package/dist/{chunk-RIIXJWBR.cjs → chunk-E52VO5JT.cjs} +4 -4
- package/dist/{chunk-RIIXJWBR.cjs.map → chunk-E52VO5JT.cjs.map} +1 -1
- package/dist/{chunk-WDO6DBYU.cjs → chunk-EABO523V.cjs} +31 -31
- package/dist/{chunk-WDO6DBYU.cjs.map → chunk-EABO523V.cjs.map} +1 -1
- package/dist/{chunk-TBCHYHNU.js → chunk-EDKQQKQR.js} +6 -6
- package/dist/{chunk-TBCHYHNU.js.map → chunk-EDKQQKQR.js.map} +1 -1
- package/dist/{chunk-IXVGHH7F.cjs → chunk-ES2QYHXL.cjs} +45 -45
- package/dist/{chunk-IXVGHH7F.cjs.map → chunk-ES2QYHXL.cjs.map} +1 -1
- package/dist/{chunk-QC35D2AU.js → chunk-G7HK4OHE.js} +24 -14
- package/dist/chunk-G7HK4OHE.js.map +1 -0
- package/dist/{chunk-L4D23LM2.js → chunk-IVWFPFUG.js} +4 -4
- package/dist/{chunk-L4D23LM2.js.map → chunk-IVWFPFUG.js.map} +1 -1
- package/dist/{chunk-SAEQMDAU.js → chunk-J37ORWSG.js} +7 -7
- package/dist/{chunk-SAEQMDAU.js.map → chunk-J37ORWSG.js.map} +1 -1
- package/dist/{chunk-XJDPQFPU.js → chunk-JEFQNZO4.js} +40 -10
- package/dist/chunk-JEFQNZO4.js.map +1 -0
- package/dist/{chunk-TNN6Z52D.js → chunk-JHA23OOK.js} +6 -6
- package/dist/{chunk-TNN6Z52D.js.map → chunk-JHA23OOK.js.map} +1 -1
- package/dist/{chunk-7FAVFJAS.js → chunk-JYO2T4MC.js} +3 -3
- package/dist/{chunk-7FAVFJAS.js.map → chunk-JYO2T4MC.js.map} +1 -1
- package/dist/{chunk-HQ43EIYO.cjs → chunk-K5HWMBWH.cjs} +9 -9
- package/dist/{chunk-HQ43EIYO.cjs.map → chunk-K5HWMBWH.cjs.map} +1 -1
- package/dist/{chunk-OM7E43ZN.cjs → chunk-KFIE4OJE.cjs} +15 -15
- package/dist/{chunk-OM7E43ZN.cjs.map → chunk-KFIE4OJE.cjs.map} +1 -1
- package/dist/{chunk-ZWB7SZVI.cjs → chunk-KKRQDVBJ.cjs} +24 -24
- package/dist/{chunk-ZWB7SZVI.cjs.map → chunk-KKRQDVBJ.cjs.map} +1 -1
- package/dist/{chunk-VFSVN5IQ.cjs → chunk-M5FREXRQ.cjs} +218 -218
- package/dist/{chunk-VFSVN5IQ.cjs.map → chunk-M5FREXRQ.cjs.map} +1 -1
- package/dist/{chunk-7SVKLWDT.cjs → chunk-OAAYF2EI.cjs} +13 -26
- package/dist/chunk-OAAYF2EI.cjs.map +1 -0
- package/dist/{chunk-HTLWPSMU.js → chunk-OIQAO7QU.js} +4 -4
- package/dist/{chunk-HTLWPSMU.js.map → chunk-OIQAO7QU.js.map} +1 -1
- package/dist/{chunk-3QRVAI53.cjs → chunk-P3T5XBYW.cjs} +6 -6
- package/dist/{chunk-3QRVAI53.cjs.map → chunk-P3T5XBYW.cjs.map} +1 -1
- package/dist/{chunk-NO3KTZDY.cjs → chunk-PNMBRBAT.cjs} +4 -4
- package/dist/{chunk-NO3KTZDY.cjs.map → chunk-PNMBRBAT.cjs.map} +1 -1
- package/dist/{chunk-MGMA5PEL.js → chunk-PRXIYHSX.js} +6 -6
- package/dist/{chunk-MGMA5PEL.js.map → chunk-PRXIYHSX.js.map} +1 -1
- package/dist/{chunk-QWS7KH3K.cjs → chunk-QAI3CM7V.cjs} +55 -55
- package/dist/{chunk-QWS7KH3K.cjs.map → chunk-QAI3CM7V.cjs.map} +1 -1
- package/dist/{chunk-L6OW2FL3.js → chunk-QLDXQOHQ.js} +79 -8
- package/dist/chunk-QLDXQOHQ.js.map +1 -0
- package/dist/{chunk-TYZSB7JT.js → chunk-RUC5OZXO.js} +3 -3
- package/dist/{chunk-TYZSB7JT.js.map → chunk-RUC5OZXO.js.map} +1 -1
- package/dist/{chunk-WHV5ZSIO.cjs → chunk-UGAOEZ3O.cjs} +15 -15
- package/dist/{chunk-WHV5ZSIO.cjs.map → chunk-UGAOEZ3O.cjs.map} +1 -1
- package/dist/{chunk-PJCHSHM3.js → chunk-V2ZBA5VC.js} +8 -8
- package/dist/{chunk-PJCHSHM3.js.map → chunk-V2ZBA5VC.js.map} +1 -1
- package/dist/{chunk-ACSEYJJF.cjs → chunk-VSUGJZ7G.cjs} +135 -125
- package/dist/chunk-VSUGJZ7G.cjs.map +1 -0
- package/dist/{chunk-LY2D45F2.cjs → chunk-XJ32XESJ.cjs} +98 -98
- package/dist/{chunk-LY2D45F2.cjs.map → chunk-XJ32XESJ.cjs.map} +1 -1
- package/dist/{chunk-JZJIWRF3.js → chunk-ZEQXMRJW.js} +3 -3
- package/dist/{chunk-JZJIWRF3.js.map → chunk-ZEQXMRJW.js.map} +1 -1
- package/dist/{chunk-HWEK7EX5.js → chunk-ZPGA5UIY.js} +7 -7
- package/dist/{chunk-HWEK7EX5.js.map → chunk-ZPGA5UIY.js.map} +1 -1
- package/dist/comments.cjs +60 -59
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +8 -7
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +27 -27
- package/dist/diff.js +3 -3
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed.cjs +11 -10
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +8 -7
- package/dist/embed.js.map +1 -1
- package/dist/emoji.cjs +11 -10
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +7 -6
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +58 -58
- package/dist/engine.js +3 -3
- package/dist/find.cjs +12 -11
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +7 -6
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +76 -75
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.js +5 -4
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +88 -87
- 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 +6 -5
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +12 -11
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +9 -8
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +12 -11
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +9 -8
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +40 -39
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +9 -8
- package/dist/presence.js.map +1 -1
- package/dist/stats.cjs +12 -11
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +8 -7
- package/dist/stats.js.map +1 -1
- package/dist/table.cjs +27 -26
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +7 -6
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +11 -10
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +7 -6
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +119 -119
- package/dist/yjs.js +5 -5
- package/package.json +2 -1
- package/dist/chunk-3BXUGX5F.js.map +0 -1
- package/dist/chunk-7SVKLWDT.cjs.map +0 -1
- package/dist/chunk-ACSEYJJF.cjs.map +0 -1
- package/dist/chunk-AIS37SL2.cjs.map +0 -1
- package/dist/chunk-L6OW2FL3.js.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,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVSUGJZ7G_cjs = require('./chunk-VSUGJZ7G.cjs');
|
|
4
4
|
var chunkA6PGQVTR_cjs = require('./chunk-A6PGQVTR.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
|
|
5
|
+
var chunkM5FREXRQ_cjs = require('./chunk-M5FREXRQ.cjs');
|
|
6
|
+
var chunk6H76FAI3_cjs = require('./chunk-6H76FAI3.cjs');
|
|
8
7
|
var React7 = require('react');
|
|
9
8
|
var lucideReact = require('lucide-react');
|
|
10
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -238,6 +237,7 @@ var englishLabels = {
|
|
|
238
237
|
imageNoAlt: "Image, no description",
|
|
239
238
|
decorativeImage: "Decorative image",
|
|
240
239
|
noAltBadge: "No alt text",
|
|
240
|
+
addAltText: "No alt text, add alt text",
|
|
241
241
|
uploadFile: "Upload file",
|
|
242
242
|
dropFile: "Or drop or paste a file here.",
|
|
243
243
|
fileTools: "File tools",
|
|
@@ -289,7 +289,7 @@ function useLabels() {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// src/blocks/caption-markdown.ts
|
|
292
|
-
var captionText = (markdown) =>
|
|
292
|
+
var captionText = (markdown) => chunk6H76FAI3_cjs.inlineText(chunk6H76FAI3_cjs.parseInline(markdown), () => "");
|
|
293
293
|
function Token({ text: text2, color, className }) {
|
|
294
294
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: chunkA6PGQVTR_cjs.tokenColour(color) }, className, children: text2 });
|
|
295
295
|
}
|
|
@@ -310,17 +310,17 @@ function assetHref(resolveAssetUrl, storageKey) {
|
|
|
310
310
|
if (storageKey === "") return null;
|
|
311
311
|
try {
|
|
312
312
|
const src = resolveAssetUrl(storageKey);
|
|
313
|
-
return typeof src === "string" &&
|
|
313
|
+
return typeof src === "string" && chunk6H76FAI3_cjs.sanitizeAssetUrl(src) || null;
|
|
314
314
|
} catch {
|
|
315
315
|
return null;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
// src/blocks/image/image-source.ts
|
|
320
|
-
var hasPicture = (attrs) =>
|
|
320
|
+
var hasPicture = (attrs) => chunk6H76FAI3_cjs.str(attrs.url) !== "" || chunk6H76FAI3_cjs.str(attrs.storageKey) !== "";
|
|
321
321
|
function imageSource(attrs, resolveAssetUrl) {
|
|
322
|
-
const url =
|
|
323
|
-
return url === "" ? assetHref(resolveAssetUrl,
|
|
322
|
+
const url = chunk6H76FAI3_cjs.str(attrs.url);
|
|
323
|
+
return url === "" ? assetHref(resolveAssetUrl, chunk6H76FAI3_cjs.str(attrs.storageKey)) : chunk6H76FAI3_cjs.sanitizeHref(url);
|
|
324
324
|
}
|
|
325
325
|
var HINT = "text-sm text-muted-foreground";
|
|
326
326
|
var TONE = {
|
|
@@ -332,34 +332,34 @@ var TONE = {
|
|
|
332
332
|
};
|
|
333
333
|
function MarkdownPreview({ data }) {
|
|
334
334
|
const labels = useLabels();
|
|
335
|
-
const markdown =
|
|
335
|
+
const markdown = chunk6H76FAI3_cjs.str(data.markdown);
|
|
336
336
|
if (markdown.trim() === "") return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyMarkdown });
|
|
337
337
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap text-base leading-7", children: markdown });
|
|
338
338
|
}
|
|
339
339
|
function CodePreview({ data }) {
|
|
340
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { dir: "ltr", className: "quoin-code quoin-code-scroll pt-3", children: /* @__PURE__ */ jsxRuntime.jsx(HighlightOverlay, { code:
|
|
340
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { dir: "ltr", className: "quoin-code quoin-code-scroll pt-3", children: /* @__PURE__ */ jsxRuntime.jsx(HighlightOverlay, { code: chunk6H76FAI3_cjs.str(data.code), language: chunk6H76FAI3_cjs.str(data.language) }) });
|
|
341
341
|
}
|
|
342
342
|
function ImagePreview({ data }) {
|
|
343
343
|
const { resolveAssetUrl, labels } = useQuoin();
|
|
344
344
|
const src = imageSource(data, resolveAssetUrl);
|
|
345
345
|
if (src === null) return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyImage });
|
|
346
|
-
const caption = captionText(
|
|
346
|
+
const caption = captionText(chunk6H76FAI3_cjs.str(data.caption));
|
|
347
347
|
return /* @__PURE__ */ jsxRuntime.jsxs("figure", { children: [
|
|
348
|
-
/* @__PURE__ */ jsxRuntime.jsx("img", { src, alt:
|
|
348
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: chunk6H76FAI3_cjs.str(data.alt) || labels.imageNoAlt, className: "max-w-full rounded-md" }),
|
|
349
349
|
caption && /* @__PURE__ */ jsxRuntime.jsx("figcaption", { className: HINT, children: caption })
|
|
350
350
|
] });
|
|
351
351
|
}
|
|
352
352
|
function FilePreview({ data }) {
|
|
353
353
|
const labels = useLabels();
|
|
354
|
-
const name =
|
|
354
|
+
const name = chunk6H76FAI3_cjs.str(data.filename);
|
|
355
355
|
if (name === "") return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyFile });
|
|
356
356
|
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: name });
|
|
357
357
|
}
|
|
358
358
|
function CalloutPreview({ data }) {
|
|
359
359
|
const labels = useLabels();
|
|
360
|
-
const body =
|
|
360
|
+
const body = chunk6H76FAI3_cjs.str(data.body);
|
|
361
361
|
if (body.trim() === "") return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyCallout });
|
|
362
|
-
const tone =
|
|
362
|
+
const tone = chunk6H76FAI3_cjs.str(data.tone) || "info";
|
|
363
363
|
const paint = TONE[tone] ?? "border-border bg-muted/50";
|
|
364
364
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-tone": tone, className: `rounded-md border-l-4 ${paint} p-3 text-sm`, children: body });
|
|
365
365
|
}
|
|
@@ -408,7 +408,7 @@ function selectNode(controller, blockId) {
|
|
|
408
408
|
const { editor } = controller;
|
|
409
409
|
const { selection } = editor.state;
|
|
410
410
|
if (selection?.kind === "node" && selection.block === blockId) return;
|
|
411
|
-
|
|
411
|
+
chunkVSUGJZ7G_cjs.dispatchSelection(controller, chunkM5FREXRQ_cjs.nodeSelection(blockId));
|
|
412
412
|
}
|
|
413
413
|
function focusNode(controller, blockId) {
|
|
414
414
|
selectNode(controller, blockId);
|
|
@@ -438,8 +438,8 @@ var OPEN_EDITOR = "openEditor";
|
|
|
438
438
|
var ABOVE_CORE_KEYS = 200;
|
|
439
439
|
function turnedBlock(tr, { doc, selection }) {
|
|
440
440
|
if (selection?.kind !== "node" || tr.origin === "remote" || tr.origin === "reconcile") return void 0;
|
|
441
|
-
const before =
|
|
442
|
-
return before !== void 0 && before.type !==
|
|
441
|
+
const before = chunk6H76FAI3_cjs.blockById(tr.before.doc, selection.block);
|
|
442
|
+
return before !== void 0 && before.type !== chunk6H76FAI3_cjs.blockById(doc, selection.block)?.type ? selection.block : void 0;
|
|
443
443
|
}
|
|
444
444
|
function createVoidEditing() {
|
|
445
445
|
const starters = /* @__PURE__ */ new Map();
|
|
@@ -459,7 +459,7 @@ function createVoidEditing() {
|
|
|
459
459
|
start?.();
|
|
460
460
|
};
|
|
461
461
|
return {
|
|
462
|
-
extension:
|
|
462
|
+
extension: chunkM5FREXRQ_cjs.defineExtension({
|
|
463
463
|
name: "void-editing",
|
|
464
464
|
priority: ABOVE_CORE_KEYS,
|
|
465
465
|
keymap: { Enter: openEditor },
|
|
@@ -736,32 +736,32 @@ function settle(tr, before) {
|
|
|
736
736
|
const { schema } = tr.before;
|
|
737
737
|
const result = tr.selection;
|
|
738
738
|
if (result?.kind !== "blocks" || before?.kind === "blocks") return result;
|
|
739
|
-
const ids =
|
|
740
|
-
const head =
|
|
741
|
-
if (head !== null && ids.includes(head) &&
|
|
742
|
-
return
|
|
739
|
+
const ids = chunkM5FREXRQ_cjs.selectedBlockIds(doc, result);
|
|
740
|
+
const head = chunkM5FREXRQ_cjs.headBlockId(before);
|
|
741
|
+
if (head !== null && ids.includes(head) && chunkM5FREXRQ_cjs.validateSelection(doc, schema, before) === before) return before;
|
|
742
|
+
return chunkM5FREXRQ_cjs.endOf(doc, schema, ids[0]);
|
|
743
743
|
}
|
|
744
744
|
function runOnBlocks(controller, blockIds, command) {
|
|
745
745
|
const { state } = controller.editor;
|
|
746
746
|
const ids = blockIds.filter((id) => state.doc.index.has(id));
|
|
747
747
|
if (ids.length === 0) return false;
|
|
748
748
|
const before = state.selection;
|
|
749
|
-
const exact =
|
|
750
|
-
const ran = exact ? before :
|
|
751
|
-
const { ok, tr } =
|
|
752
|
-
const result = ok && tr !== null ? tr : new
|
|
749
|
+
const exact = chunk6H76FAI3_cjs.sameItems(chunkM5FREXRQ_cjs.selectedBlockIds(state.doc, before), ids);
|
|
750
|
+
const ran = exact ? before : chunkM5FREXRQ_cjs.blockRangeSelection(ids[0], ids[ids.length - 1]);
|
|
751
|
+
const { ok, tr } = chunkM5FREXRQ_cjs.runCommands(state, [chunkM5FREXRQ_cjs.setSelection(ran), command]);
|
|
752
|
+
const result = ok && tr !== null ? tr : new chunkM5FREXRQ_cjs.Transaction(state).setSelection(ran);
|
|
753
753
|
const settled = exact ? result.selection : settle(result, before);
|
|
754
|
-
if (!
|
|
755
|
-
if (result.docChanged || !
|
|
754
|
+
if (!chunkM5FREXRQ_cjs.sameSelection(settled, result.selection)) result.setSelection(settled);
|
|
755
|
+
if (result.docChanged || !chunkM5FREXRQ_cjs.sameSelection(result.selection, before)) controller.dispatch(result);
|
|
756
756
|
return ok;
|
|
757
757
|
}
|
|
758
758
|
var noChange = () => true;
|
|
759
759
|
|
|
760
760
|
// src/gutter/block-menu-items.ts
|
|
761
|
-
var rangeOf = (blockIds) =>
|
|
761
|
+
var rangeOf = (blockIds) => chunkM5FREXRQ_cjs.blockRangeSelection(blockIds[0], blockIds[blockIds.length - 1]);
|
|
762
762
|
function selectedWith(state, blockId) {
|
|
763
763
|
const { doc, selection } = state;
|
|
764
|
-
const selected =
|
|
764
|
+
const selected = chunkM5FREXRQ_cjs.selectedBlockIds(doc, selection);
|
|
765
765
|
const ofBlocks = selection?.kind === "blocks" || selection?.kind === "text" && selected.length > 1;
|
|
766
766
|
return ofBlocks && selected.includes(blockId) ? selected : null;
|
|
767
767
|
}
|
|
@@ -769,8 +769,8 @@ function menuTargets(state, blockId) {
|
|
|
769
769
|
const selected = selectedWith(state, blockId);
|
|
770
770
|
if (selected !== null) return selected;
|
|
771
771
|
const { doc } = state;
|
|
772
|
-
const index =
|
|
773
|
-
return doc.blocks.slice(index,
|
|
772
|
+
const index = chunk6H76FAI3_cjs.requireBlockIndex(doc, blockId);
|
|
773
|
+
return doc.blocks.slice(index, chunkM5FREXRQ_cjs.descendantsEnd(doc, index)).map((block) => block.id);
|
|
774
774
|
}
|
|
775
775
|
function styleTargets(state, blockId) {
|
|
776
776
|
return selectedWith(state, blockId) ?? [blockId];
|
|
@@ -780,12 +780,12 @@ function menuActions(core, extra = []) {
|
|
|
780
780
|
}
|
|
781
781
|
function markdownOf(editor, blockIds, resolveAssetUrl) {
|
|
782
782
|
const { doc } = editor.state;
|
|
783
|
-
const range =
|
|
783
|
+
const range = chunkM5FREXRQ_cjs.selectedBlockRange(doc, rangeOf(blockIds));
|
|
784
784
|
if (range === null) return "";
|
|
785
|
-
const blocks = editor.codec.blocksFromDoc(
|
|
786
|
-
return
|
|
785
|
+
const blocks = editor.codec.blocksFromDoc(chunk6H76FAI3_cjs.createDoc(doc.blocks.slice(range.start, range.end)));
|
|
786
|
+
return chunkM5FREXRQ_cjs.toMarkdown(blocks, { schema: editor.schema, resolveAssetUrl, comments: false });
|
|
787
787
|
}
|
|
788
|
-
var applies = (command) => (state, blockIds) => blockIds.every((id) => state.doc.index.has(id)) &&
|
|
788
|
+
var applies = (command) => (state, blockIds) => blockIds.every((id) => state.doc.index.has(id)) && chunkM5FREXRQ_cjs.runCommands(state, [chunkM5FREXRQ_cjs.setSelection(rangeOf(blockIds)), command]).ok;
|
|
789
789
|
function coreBlockMenuActions(labels, options) {
|
|
790
790
|
const copy = (controller, blockIds, text2) => {
|
|
791
791
|
void copyText(text2).then((copied) => {
|
|
@@ -799,7 +799,7 @@ function coreBlockMenuActions(labels, options) {
|
|
|
799
799
|
label: labels.duplicate,
|
|
800
800
|
icon: lucideReact.CopyPlus,
|
|
801
801
|
shortcut: "Mod-d",
|
|
802
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
802
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.duplicateBlocks())
|
|
803
803
|
},
|
|
804
804
|
{
|
|
805
805
|
id: "copy",
|
|
@@ -818,23 +818,23 @@ function coreBlockMenuActions(labels, options) {
|
|
|
818
818
|
label: labels.moveUp,
|
|
819
819
|
icon: lucideReact.ArrowUp,
|
|
820
820
|
shortcut: "Mod-Shift-ArrowUp",
|
|
821
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
822
|
-
available: applies(
|
|
821
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.moveBlocksUp),
|
|
822
|
+
available: applies(chunkM5FREXRQ_cjs.moveBlocksUp)
|
|
823
823
|
},
|
|
824
824
|
{
|
|
825
825
|
id: "move-down",
|
|
826
826
|
label: labels.moveDown,
|
|
827
827
|
icon: lucideReact.ArrowDown,
|
|
828
828
|
shortcut: "Mod-Shift-ArrowDown",
|
|
829
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
830
|
-
available: applies(
|
|
829
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.moveBlocksDown),
|
|
830
|
+
available: applies(chunkM5FREXRQ_cjs.moveBlocksDown)
|
|
831
831
|
},
|
|
832
832
|
{
|
|
833
833
|
id: "delete",
|
|
834
834
|
label: labels.delete,
|
|
835
835
|
icon: lucideReact.Trash,
|
|
836
836
|
destructive: true,
|
|
837
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
837
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.deleteBlocks)
|
|
838
838
|
}
|
|
839
839
|
];
|
|
840
840
|
}
|
|
@@ -880,7 +880,7 @@ var sharedTone = (blocks) => {
|
|
|
880
880
|
function CalloutMenus({ kit, controller, blocks }) {
|
|
881
881
|
const labels = useLabels();
|
|
882
882
|
const blockIds = blocks.map((block) => block.id);
|
|
883
|
-
const apply = (patch) => runOnBlocks(controller, blockIds,
|
|
883
|
+
const apply = (patch) => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.setAttrs(patch));
|
|
884
884
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
885
885
|
/* @__PURE__ */ jsxRuntime.jsxs(kit.Sub, { children: [
|
|
886
886
|
/* @__PURE__ */ jsxRuntime.jsxs(kit.SubTrigger, { children: [
|
|
@@ -900,7 +900,7 @@ function CalloutMenus({ kit, controller, blocks }) {
|
|
|
900
900
|
}
|
|
901
901
|
function sharedColor(blocks, key) {
|
|
902
902
|
const coloured = blocks.filter((block) => block.type === "MARKDOWN");
|
|
903
|
-
const colors = new Set(coloured.map((block) =>
|
|
903
|
+
const colors = new Set(coloured.map((block) => chunk6H76FAI3_cjs.paletteOrUndefined(block.attrs[key]) ?? "default"));
|
|
904
904
|
return colors.size === 1 ? [...colors][0] : "";
|
|
905
905
|
}
|
|
906
906
|
var swatches = {
|
|
@@ -913,7 +913,7 @@ function ColorGroups({ kit, value, onPick }) {
|
|
|
913
913
|
const backgroundTitle = React7.useId();
|
|
914
914
|
const group = (key, title, titleId) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
915
915
|
/* @__PURE__ */ jsxRuntime.jsx(kit.Label, { id: titleId, children: title }),
|
|
916
|
-
/* @__PURE__ */ jsxRuntime.jsx(kit.RadioGroup, { "aria-labelledby": titleId, value: value[key], onValueChange: (name) => onPick(key, name), children:
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx(kit.RadioGroup, { "aria-labelledby": titleId, value: value[key], onValueChange: (name) => onPick(key, name), children: chunk6H76FAI3_cjs.PALETTE.map((name) => /* @__PURE__ */ jsxRuntime.jsxs(kit.RadioItem, { value: name, indicator: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4" }), children: [
|
|
917
917
|
swatches[key](name),
|
|
918
918
|
labels.colors[name]
|
|
919
919
|
] }, name)) })
|
|
@@ -928,7 +928,7 @@ function ColorMenu({ kit, controller, blocks }) {
|
|
|
928
928
|
const labels = useLabels();
|
|
929
929
|
const blockIds = blocks.map((block) => block.id);
|
|
930
930
|
const value = { color: sharedColor(blocks, "color"), background: sharedColor(blocks, "background") };
|
|
931
|
-
const pick = (key, name) => runOnBlocks(controller, blockIds,
|
|
931
|
+
const pick = (key, name) => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.setBlockColor({ [key]: name === "default" ? null : name }));
|
|
932
932
|
return /* @__PURE__ */ jsxRuntime.jsxs(kit.Sub, { children: [
|
|
933
933
|
/* @__PURE__ */ jsxRuntime.jsxs(kit.SubTrigger, { children: [
|
|
934
934
|
/* @__PURE__ */ jsxRuntime.jsx(MenuIcon, { icon: lucideReact.Palette }),
|
|
@@ -959,7 +959,7 @@ function modifierText(modifier, isMac, { keyNames }) {
|
|
|
959
959
|
return Object.hasOwn(MODIFIERS, name) ? keyNames[MODIFIERS[name]] : capitalized(modifier);
|
|
960
960
|
}
|
|
961
961
|
function formatShortcut(shortcut, platform = {}) {
|
|
962
|
-
const { isMac =
|
|
962
|
+
const { isMac = chunkM5FREXRQ_cjs.detectMac(), labels = englishLabels } = platform;
|
|
963
963
|
const parts = shortcut.split(shortcut.includes("+") ? "+" : "-");
|
|
964
964
|
const key = parts.pop() ?? shortcut;
|
|
965
965
|
const written = [...parts.map((modifier) => modifierText(modifier, isMac, labels)), keyText(key, labels)];
|
|
@@ -1039,21 +1039,21 @@ function languageOptions(query, plainText) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
1041
|
// src/blocks/insert-blocks.ts
|
|
1042
|
-
var isEmptyParagraph = (schema, block) =>
|
|
1042
|
+
var isEmptyParagraph = (schema, block) => chunkM5FREXRQ_cjs.isParagraph(block) && chunkM5FREXRQ_cjs.regionLength(block, chunkM5FREXRQ_cjs.primaryRegion(schema, block) ?? "") === 0;
|
|
1043
1043
|
function fresh(schema, { id, type, attrs, regions }, indent3) {
|
|
1044
|
-
const block =
|
|
1044
|
+
const block = chunkM5FREXRQ_cjs.createBlock(schema, type, attrs, indent3, id);
|
|
1045
1045
|
return regions === void 0 ? block : { ...block, regions };
|
|
1046
1046
|
}
|
|
1047
1047
|
function landOnLine(tr, schema, index, indent3) {
|
|
1048
1048
|
const next = tr.doc.blocks[index];
|
|
1049
1049
|
const reused = next !== void 0 && next.indent === indent3 && isEmptyParagraph(schema, next);
|
|
1050
|
-
const line = reused ? next :
|
|
1051
|
-
if (!reused) tr.step(
|
|
1052
|
-
tr.setSelection(
|
|
1050
|
+
const line = reused ? next : chunkM5FREXRQ_cjs.createBlock(schema, schema.defaultTextBlock, {}, indent3);
|
|
1051
|
+
if (!reused) tr.step(chunkM5FREXRQ_cjs.insertBlocksStep(index, [line]));
|
|
1052
|
+
tr.setSelection(chunkM5FREXRQ_cjs.startOf(tr.doc, schema, line.id));
|
|
1053
1053
|
}
|
|
1054
1054
|
function land(tr, schema, landing, first, after) {
|
|
1055
|
-
if (landing === "text") tr.setSelection(
|
|
1056
|
-
if (landing === "editor") tr.setSelection(
|
|
1055
|
+
if (landing === "text") tr.setSelection(chunkM5FREXRQ_cjs.startOf(tr.doc, schema, first.id));
|
|
1056
|
+
if (landing === "editor") tr.setSelection(chunkM5FREXRQ_cjs.nodeSelection(first.id)).setMeta(OPEN_EDITOR, first.id);
|
|
1057
1057
|
if (landing === "line") landOnLine(tr, schema, after, first.indent);
|
|
1058
1058
|
}
|
|
1059
1059
|
function anchorIndex(doc, id) {
|
|
@@ -1063,24 +1063,24 @@ function anchorIndex(doc, id) {
|
|
|
1063
1063
|
function insertBlocks(blocks, landing, anchorId) {
|
|
1064
1064
|
return (state, dispatch) => {
|
|
1065
1065
|
const { doc, schema } = state;
|
|
1066
|
-
const id = anchorId === void 0 ?
|
|
1066
|
+
const id = anchorId === void 0 ? chunkM5FREXRQ_cjs.headBlockId(state.selection) : anchorId;
|
|
1067
1067
|
const index = anchorIndex(doc, id);
|
|
1068
1068
|
if (index === void 0 || blocks.length === 0) return false;
|
|
1069
1069
|
const anchor = id === null ? void 0 : doc.blocks[index];
|
|
1070
1070
|
const created2 = blocks.map((block) => fresh(schema, block, anchor?.indent ?? 0));
|
|
1071
|
-
const tr = new
|
|
1071
|
+
const tr = new chunkM5FREXRQ_cjs.Transaction(state);
|
|
1072
1072
|
const empty = anchor !== void 0 && landing !== "stay" && isEmptyParagraph(schema, anchor);
|
|
1073
1073
|
if (empty && landing === "line") {
|
|
1074
|
-
tr.step(
|
|
1074
|
+
tr.step(chunkM5FREXRQ_cjs.insertBlocksStep(index, created2)).setSelection(chunkM5FREXRQ_cjs.startOf(tr.doc, schema, anchor.id));
|
|
1075
1075
|
} else if (empty) {
|
|
1076
1076
|
const [first, ...rest] = created2;
|
|
1077
1077
|
const filled = { ...first, id: anchor.id };
|
|
1078
|
-
tr.step(
|
|
1079
|
-
if (rest.length > 0) tr.step(
|
|
1078
|
+
tr.step(chunkM5FREXRQ_cjs.replaceBlockStep(filled));
|
|
1079
|
+
if (rest.length > 0) tr.step(chunkM5FREXRQ_cjs.insertBlocksStep(index + 1, rest));
|
|
1080
1080
|
land(tr, schema, landing, filled, index + created2.length);
|
|
1081
1081
|
} else {
|
|
1082
|
-
const at = anchor === void 0 ? 0 :
|
|
1083
|
-
tr.step(
|
|
1082
|
+
const at = anchor === void 0 ? 0 : chunkM5FREXRQ_cjs.descendantsEnd(doc, index);
|
|
1083
|
+
tr.step(chunkM5FREXRQ_cjs.insertBlocksStep(at, created2));
|
|
1084
1084
|
land(tr, schema, landing, created2[0], at + created2.length);
|
|
1085
1085
|
}
|
|
1086
1086
|
dispatch?.(tr);
|
|
@@ -1093,7 +1093,7 @@ function landingFor(flow, hasEditor) {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
function insertBlockToWrite(block, hasEditor, anchorId) {
|
|
1095
1095
|
return (state, dispatch) => {
|
|
1096
|
-
const landing = landingFor(
|
|
1096
|
+
const landing = landingFor(chunk6H76FAI3_cjs.specFor(state.schema, block.type).flow, hasEditor);
|
|
1097
1097
|
return insertBlocks([block], landing, anchorId)(state, dispatch);
|
|
1098
1098
|
};
|
|
1099
1099
|
}
|
|
@@ -1101,20 +1101,20 @@ function insertBlockToWrite(block, hasEditor, anchorId) {
|
|
|
1101
1101
|
// src/blocks/code/code-actions.ts
|
|
1102
1102
|
function writeCode(controller, blockId, code, group) {
|
|
1103
1103
|
const { editor } = controller;
|
|
1104
|
-
const block =
|
|
1104
|
+
const block = chunk6H76FAI3_cjs.blockById(editor.state.doc, blockId);
|
|
1105
1105
|
if (block === void 0 || block.attrs.code === code) return;
|
|
1106
|
-
controller.dispatch(editor.createTransaction().step(
|
|
1106
|
+
controller.dispatch(editor.createTransaction().step(chunkM5FREXRQ_cjs.setAttrsStep(blockId, { code })).setMeta(chunkM5FREXRQ_cjs.HISTORY_GROUP, group));
|
|
1107
1107
|
}
|
|
1108
1108
|
function codeToParagraph(blockId) {
|
|
1109
1109
|
return (state, dispatch) => {
|
|
1110
|
-
const turn =
|
|
1111
|
-
const { ok, tr } =
|
|
1110
|
+
const turn = chunkM5FREXRQ_cjs.setBlockType("MARKDOWN", { kind: "paragraph" });
|
|
1111
|
+
const { ok, tr } = chunkM5FREXRQ_cjs.runCommands(state, [chunkM5FREXRQ_cjs.setSelection(chunkM5FREXRQ_cjs.nodeSelection(blockId)), turn]);
|
|
1112
1112
|
if (ok && tr !== null) dispatch?.(tr);
|
|
1113
1113
|
return ok;
|
|
1114
1114
|
};
|
|
1115
1115
|
}
|
|
1116
1116
|
function leaveCode(controller, blockId, direction, addsLine = false) {
|
|
1117
|
-
const moved =
|
|
1117
|
+
const moved = chunkVSUGJZ7G_cjs.moveToNeighbour(controller, blockId, direction);
|
|
1118
1118
|
if (!moved && !(addsLine && controller.run(insertBlocks([{ type: "MARKDOWN" }], "text", blockId)))) return false;
|
|
1119
1119
|
controller.focus();
|
|
1120
1120
|
return true;
|
|
@@ -1192,8 +1192,8 @@ var MOD_KEYS = [
|
|
|
1192
1192
|
["Mod-a", ({ value, start, end }) => start === 0 && end === value.length ? { kind: "selectAll" } : null]
|
|
1193
1193
|
];
|
|
1194
1194
|
function codeKeyAction(event, field, isMac) {
|
|
1195
|
-
const name =
|
|
1196
|
-
const modKey = MOD_KEYS.find(([key]) =>
|
|
1195
|
+
const name = chunkM5FREXRQ_cjs.keyName(event, isMac);
|
|
1196
|
+
const modKey = MOD_KEYS.find(([key]) => chunkM5FREXRQ_cjs.normalizeKey(key, isMac) === name);
|
|
1197
1197
|
const handler = modKey?.[1] ?? (Object.hasOwn(KEYS, name) ? KEYS[name] : void 0);
|
|
1198
1198
|
return handler?.(field) ?? null;
|
|
1199
1199
|
}
|
|
@@ -1239,7 +1239,7 @@ function travel({ controller, blockId, area }, command) {
|
|
|
1239
1239
|
const before = area.value;
|
|
1240
1240
|
controller.run(command);
|
|
1241
1241
|
const { selection } = controller.editor.state;
|
|
1242
|
-
const edit2 =
|
|
1242
|
+
const edit2 = chunkVSUGJZ7G_cjs.textDiff(before, area.value);
|
|
1243
1243
|
if (selection?.kind !== "node" || selection.block !== blockId) controller.focus();
|
|
1244
1244
|
else if (edit2 !== null) area.setSelectionRange(edit2.from + edit2.insert.length, edit2.from + edit2.insert.length);
|
|
1245
1245
|
return true;
|
|
@@ -1255,13 +1255,13 @@ function runCodeAction(action, context) {
|
|
|
1255
1255
|
case "paragraph":
|
|
1256
1256
|
return selectAndFocus(context, codeToParagraph(blockId));
|
|
1257
1257
|
case "undo":
|
|
1258
|
-
return travel(context,
|
|
1258
|
+
return travel(context, chunkM5FREXRQ_cjs.undo);
|
|
1259
1259
|
case "redo":
|
|
1260
|
-
return travel(context,
|
|
1260
|
+
return travel(context, chunkM5FREXRQ_cjs.redo);
|
|
1261
1261
|
case "selectAll":
|
|
1262
|
-
return selectAndFocus(context,
|
|
1262
|
+
return selectAndFocus(context, chunkM5FREXRQ_cjs.selectAll);
|
|
1263
1263
|
case "escape":
|
|
1264
|
-
return selectAndFocus(context,
|
|
1264
|
+
return selectAndFocus(context, chunkM5FREXRQ_cjs.setSelection(chunkM5FREXRQ_cjs.blockRangeSelection(blockId)));
|
|
1265
1265
|
case "controls":
|
|
1266
1266
|
context.focusControls();
|
|
1267
1267
|
return true;
|
|
@@ -1324,18 +1324,18 @@ function CodeEditor({ block, controller, field, focusControls }) {
|
|
|
1324
1324
|
useTypeIntoCode(controller, blockId, field, edit2);
|
|
1325
1325
|
const onKeyDown = (event) => {
|
|
1326
1326
|
const area = event.currentTarget;
|
|
1327
|
-
if (
|
|
1327
|
+
if (chunkVSUGJZ7G_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
1328
1328
|
const action = codeKeyAction(event, fieldOf(area), controller.isMac);
|
|
1329
1329
|
if (action !== null && runCodeAction(action, { controller, blockId, area, edit: edit2, focusControls })) event.preventDefault();
|
|
1330
1330
|
};
|
|
1331
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...{ [
|
|
1331
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...{ [chunkVSUGJZ7G_cjs.NATIVE_INTERACTION]: "" }, dir: "ltr", className: "quoin-code-scroll", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-code-lines", children: [
|
|
1332
1332
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1333
1333
|
HighlightOverlay,
|
|
1334
1334
|
{
|
|
1335
1335
|
"aria-hidden": "true",
|
|
1336
1336
|
drawnRef: drawn,
|
|
1337
|
-
code:
|
|
1338
|
-
language:
|
|
1337
|
+
code: chunk6H76FAI3_cjs.str(block.attrs.code),
|
|
1338
|
+
language: chunk6H76FAI3_cjs.str(block.attrs.language)
|
|
1339
1339
|
}
|
|
1340
1340
|
),
|
|
1341
1341
|
/* @__PURE__ */ jsxRuntime.jsx("span", { ref: mark, "aria-hidden": "true", className: "quoin-code-caret" }),
|
|
@@ -1345,7 +1345,7 @@ function CodeEditor({ block, controller, field, focusControls }) {
|
|
|
1345
1345
|
ref: field,
|
|
1346
1346
|
"aria-label": labels.codeText,
|
|
1347
1347
|
"aria-keyshortcuts": "Alt+F10",
|
|
1348
|
-
value:
|
|
1348
|
+
value: chunk6H76FAI3_cjs.str(block.attrs.code),
|
|
1349
1349
|
wrap: "off",
|
|
1350
1350
|
tabIndex: -1,
|
|
1351
1351
|
spellCheck: false,
|
|
@@ -1398,7 +1398,7 @@ var Button = React7__namespace.forwardRef(function Button2({ className, variant
|
|
|
1398
1398
|
var COPIED_FOR_MS = 1500;
|
|
1399
1399
|
function CopyCodeButton({ code, controller }) {
|
|
1400
1400
|
const labels = useLabels();
|
|
1401
|
-
const readOnly =
|
|
1401
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
1402
1402
|
const [copied, setCopied] = React7.useState(false);
|
|
1403
1403
|
React7.useEffect(() => {
|
|
1404
1404
|
if (!copied) return;
|
|
@@ -1481,7 +1481,7 @@ var preventDefault = (event) => event.preventDefault();
|
|
|
1481
1481
|
|
|
1482
1482
|
// src/blocks/text/set-block-attrs.ts
|
|
1483
1483
|
function setBlockAttrs(controller, blockId, patch) {
|
|
1484
|
-
if (!controller.readOnly) controller.run(
|
|
1484
|
+
if (!controller.readOnly) controller.run(chunkVSUGJZ7G_cjs.onBlock(blockId, chunkM5FREXRQ_cjs.setAttrs(patch)));
|
|
1485
1485
|
}
|
|
1486
1486
|
var FIELD = `quoin-code-language quoin-code-control ${FOCUS_RING}`;
|
|
1487
1487
|
var CONTENT = `${MENU_CONTENT} flex max-h-64 w-48 flex-col overflow-y-hidden`;
|
|
@@ -1497,7 +1497,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1497
1497
|
const options = draft === null ? [] : languageOptions(draft === shown ? "" : draft, labels.plainText);
|
|
1498
1498
|
const open = options.length > 0;
|
|
1499
1499
|
const optionId = (index) => `${listboxId}-${index}`;
|
|
1500
|
-
|
|
1500
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
1501
1501
|
list.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
1502
1502
|
}, [active]);
|
|
1503
1503
|
const close = () => {
|
|
@@ -1523,7 +1523,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1523
1523
|
onDone();
|
|
1524
1524
|
};
|
|
1525
1525
|
const onKeyDown = (event) => {
|
|
1526
|
-
if (
|
|
1526
|
+
if (chunkVSUGJZ7G_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
1527
1527
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1528
1528
|
event.preventDefault();
|
|
1529
1529
|
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
@@ -1597,11 +1597,11 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1597
1597
|
}
|
|
1598
1598
|
var CodeBlock = ({ block, controller }) => {
|
|
1599
1599
|
const labels = useLabels();
|
|
1600
|
-
const readOnly =
|
|
1600
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
1601
1601
|
const languageField = React7.useRef(null);
|
|
1602
1602
|
const codeField = React7.useRef(null);
|
|
1603
|
-
const code =
|
|
1604
|
-
const language2 =
|
|
1603
|
+
const code = chunk6H76FAI3_cjs.str(block.attrs.code);
|
|
1604
|
+
const language2 = chunk6H76FAI3_cjs.str(block.attrs.language);
|
|
1605
1605
|
const name = languageName(language2) ?? language2;
|
|
1606
1606
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", "aria-label": labels.blockNames.code, contentEditable: false, className: "quoin-code", children: [
|
|
1607
1607
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-code-header", children: [
|
|
@@ -1699,7 +1699,7 @@ function selectHandlers(controller, blockId, root, onSelect) {
|
|
|
1699
1699
|
return {
|
|
1700
1700
|
onKeyDown(event) {
|
|
1701
1701
|
const key = event.nativeEvent;
|
|
1702
|
-
if (
|
|
1702
|
+
if (chunkVSUGJZ7G_cjs.isComposingKey(controller, key)) return;
|
|
1703
1703
|
if (event.key === "Escape") select();
|
|
1704
1704
|
else if (!(event.metaKey || event.ctrlKey) || event.target.matches("input:not([type=file])") || !controller.edit(() => controller.editor.handleKey(key)))
|
|
1705
1705
|
return;
|
|
@@ -1837,16 +1837,16 @@ var kindOf = (value) => KINDS.find(([, pattern]) => pattern.test(value))?.[0];
|
|
|
1837
1837
|
var fileIcon = (mime, filename) => kindOf(mime) ?? kindOf(/\.([^.]+)$/.exec(filename)?.[1].toLowerCase() ?? "") ?? lucideReact.FileIcon;
|
|
1838
1838
|
|
|
1839
1839
|
// src/blocks/file/file-source.ts
|
|
1840
|
-
var fileName = (attrs) =>
|
|
1840
|
+
var fileName = (attrs) => chunk6H76FAI3_cjs.str(attrs.filename) || chunk6H76FAI3_cjs.str(attrs.storageKey);
|
|
1841
1841
|
var hasFile = (attrs) => fileName(attrs) !== "";
|
|
1842
1842
|
function FileCard({ block, controller, readOnly }) {
|
|
1843
1843
|
const { labels, resolveAssetUrl } = useQuoin();
|
|
1844
1844
|
const card = React7.useRef(null);
|
|
1845
1845
|
const { id, attrs } = block;
|
|
1846
1846
|
const name = fileName(attrs);
|
|
1847
|
-
const size =
|
|
1848
|
-
const href = assetHref(resolveAssetUrl,
|
|
1849
|
-
const Icon = fileIcon(
|
|
1847
|
+
const size = chunk6H76FAI3_cjs.optionalNumber(attrs.size);
|
|
1848
|
+
const href = assetHref(resolveAssetUrl, chunk6H76FAI3_cjs.str(attrs.storageKey));
|
|
1849
|
+
const Icon = fileIcon(chunk6H76FAI3_cjs.str(attrs.mime), name);
|
|
1850
1850
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: card, className: "quoin-file-card", ...selectHandlers(controller, id, card), children: [
|
|
1851
1851
|
/* @__PURE__ */ jsxRuntime.jsx(Icon, { "aria-hidden": "true", className: "quoin-file-icon" }),
|
|
1852
1852
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-file-name", children: name }),
|
|
@@ -1855,7 +1855,7 @@ function FileCard({ block, controller, readOnly }) {
|
|
|
1855
1855
|
"a",
|
|
1856
1856
|
{
|
|
1857
1857
|
href,
|
|
1858
|
-
download:
|
|
1858
|
+
download: chunk6H76FAI3_cjs.str(attrs.filename),
|
|
1859
1859
|
target: "_blank",
|
|
1860
1860
|
rel: "noopener",
|
|
1861
1861
|
"aria-label": labels.downloadFile(name),
|
|
@@ -1881,14 +1881,14 @@ function claimUpload(controller, blockId) {
|
|
|
1881
1881
|
}
|
|
1882
1882
|
var isNewestUpload = (controller, blockId, token) => newestUploads.get(controller)?.get(blockId) === token;
|
|
1883
1883
|
function assetOf(controller, blockId, type) {
|
|
1884
|
-
const block =
|
|
1884
|
+
const block = chunk6H76FAI3_cjs.blockById(controller.editor.state.doc, blockId);
|
|
1885
1885
|
if (block?.type !== type || controller.readOnly) return null;
|
|
1886
|
-
return { url:
|
|
1886
|
+
return { url: chunk6H76FAI3_cjs.str(block.attrs.url), storageKey: chunk6H76FAI3_cjs.str(block.attrs.storageKey) };
|
|
1887
1887
|
}
|
|
1888
1888
|
var sameAsset = (a, b) => a !== null && b !== null && a.url === b.url && a.storageKey === b.storageKey;
|
|
1889
1889
|
function writeAttrs(controller, blockId, patch, recorded) {
|
|
1890
1890
|
const { editor } = controller;
|
|
1891
|
-
const tr = editor.createTransaction().step(
|
|
1891
|
+
const tr = editor.createTransaction().step(chunkM5FREXRQ_cjs.setAttrsStep(blockId, patch));
|
|
1892
1892
|
editor.dispatch(recorded ? tr : tr.setMeta("addToHistory", false));
|
|
1893
1893
|
}
|
|
1894
1894
|
async function uploadInto(controller, blockId, file, { type, category }, { upload, onLand }, land2) {
|
|
@@ -1919,7 +1919,7 @@ var uploadFile = (controller, blockId, file, host) => uploadInto(
|
|
|
1919
1919
|
var anyFile = () => true;
|
|
1920
1920
|
var FileBlock = ({ block, controller }) => {
|
|
1921
1921
|
const labels = useLabels();
|
|
1922
|
-
const readOnly =
|
|
1922
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
1923
1923
|
const root = React7.useRef(null);
|
|
1924
1924
|
const filled = hasFile(block.attrs);
|
|
1925
1925
|
useNodeKeys(controller, block.id, !readOnly, !filled, root);
|
|
@@ -1983,7 +1983,7 @@ function usePartAnchor(controller, blockId, selector) {
|
|
|
1983
1983
|
}
|
|
1984
1984
|
var replaceItem = (title, run) => run ? [{ id: "replace", title, icon: lucideReact.Upload, run }] : [];
|
|
1985
1985
|
function deleteBlock(controller, blockId) {
|
|
1986
|
-
runOnBlocks(controller, [blockId],
|
|
1986
|
+
runOnBlocks(controller, [blockId], chunkM5FREXRQ_cjs.deleteBlocks);
|
|
1987
1987
|
controller.focus();
|
|
1988
1988
|
}
|
|
1989
1989
|
var deleteItem = (blockId, title) => ({
|
|
@@ -1998,8 +1998,8 @@ function markItem(mark, title, icon) {
|
|
|
1998
1998
|
id: mark,
|
|
1999
1999
|
title,
|
|
2000
2000
|
icon,
|
|
2001
|
-
isActive: (state) =>
|
|
2002
|
-
run: (controller) => void controller.run(
|
|
2001
|
+
isActive: (state) => chunkM5FREXRQ_cjs.isActive(state, mark),
|
|
2002
|
+
run: (controller) => void controller.run(chunkM5FREXRQ_cjs.toggleMark(mark))
|
|
2003
2003
|
};
|
|
2004
2004
|
}
|
|
2005
2005
|
var linkItem = (labels, openLink) => ({
|
|
@@ -2069,7 +2069,7 @@ function useRovingFocus() {
|
|
|
2069
2069
|
},
|
|
2070
2070
|
[syncTabStop]
|
|
2071
2071
|
);
|
|
2072
|
-
|
|
2072
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(syncTabStop);
|
|
2073
2073
|
const onFocus = (event) => {
|
|
2074
2074
|
if (!owns(event.target)) return;
|
|
2075
2075
|
current.current = event.target;
|
|
@@ -2088,7 +2088,7 @@ function useRovingFocus() {
|
|
|
2088
2088
|
// src/menus/floating/use-focus-key.ts
|
|
2089
2089
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
2090
2090
|
function useFocusKey(controller, focus) {
|
|
2091
|
-
|
|
2091
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
2092
2092
|
const intercept = (event) => {
|
|
2093
2093
|
if (!isFocusKey(event)) return false;
|
|
2094
2094
|
event.preventDefault();
|
|
@@ -2100,11 +2100,11 @@ function useFocusKey(controller, focus) {
|
|
|
2100
2100
|
}
|
|
2101
2101
|
function NodeToolbar(props) {
|
|
2102
2102
|
const { blockId, controller, label, anchor, items, next, buttonRefs, children, popover } = props;
|
|
2103
|
-
const state =
|
|
2103
|
+
const state = chunkVSUGJZ7G_cjs.useEditorState(controller, chunkVSUGJZ7G_cjs.wholeState);
|
|
2104
2104
|
const roving = useRovingFocus();
|
|
2105
2105
|
useFocusKey(controller, roving.focusCurrent);
|
|
2106
2106
|
const onKeyDown = (event) => {
|
|
2107
|
-
if (!roving.owns(event.target) ||
|
|
2107
|
+
if (!roving.owns(event.target) || chunkVSUGJZ7G_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2108
2108
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
2109
2109
|
const ahead = tab && !event.shiftKey && next !== void 0 ? blockPart(controller, blockId, next) : void 0;
|
|
2110
2110
|
if (ahead !== void 0) ahead.focus();
|
|
@@ -2181,12 +2181,12 @@ function useSelectionSettled(controller) {
|
|
|
2181
2181
|
|
|
2182
2182
|
// src/blocks/void/use-toolbar-block.ts
|
|
2183
2183
|
var selectedBlock = (type, filled) => ({ doc, selection }) => {
|
|
2184
|
-
const block = selection?.kind === "node" ?
|
|
2184
|
+
const block = selection?.kind === "node" ? chunk6H76FAI3_cjs.blockById(doc, selection.block) : void 0;
|
|
2185
2185
|
return block?.type === type && filled(block.attrs) ? block.id : null;
|
|
2186
2186
|
};
|
|
2187
2187
|
function useToolbarBlock(controller, selected, keptFor = null) {
|
|
2188
|
-
const blockId =
|
|
2189
|
-
const readOnly =
|
|
2188
|
+
const blockId = chunkVSUGJZ7G_cjs.useEditorState(controller, selected);
|
|
2189
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
2190
2190
|
const settled = useSelectionSettled(controller);
|
|
2191
2191
|
return blockId !== null && !readOnly && (settled || keptFor === blockId) ? blockId : null;
|
|
2192
2192
|
}
|
|
@@ -2265,7 +2265,7 @@ function ResizeHandles({ blockId, controller, frame, percent, centred, onPreview
|
|
|
2265
2265
|
const value = percent ?? drawn;
|
|
2266
2266
|
const write = (widthPercent) => setBlockAttrs(controller, blockId, { widthPercent });
|
|
2267
2267
|
const onKeyDown = (event) => {
|
|
2268
|
-
if (
|
|
2268
|
+
if (chunkVSUGJZ7G_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2269
2269
|
const next = keyedWidth(event.key, value);
|
|
2270
2270
|
if (event.key === "Escape") controller.focus();
|
|
2271
2271
|
else if (next === null) return;
|
|
@@ -2307,7 +2307,7 @@ function ResizeHandles({ blockId, controller, frame, percent, centred, onPreview
|
|
|
2307
2307
|
"aria-valuetext": labels.widthValue(value),
|
|
2308
2308
|
"data-side": side,
|
|
2309
2309
|
className: "quoin-image-handle",
|
|
2310
|
-
...{ [
|
|
2310
|
+
...{ [chunkVSUGJZ7G_cjs.NATIVE_INTERACTION]: "" },
|
|
2311
2311
|
...bubblePart(controller),
|
|
2312
2312
|
onKeyDown,
|
|
2313
2313
|
onPointerDown: onPointerDown(side),
|
|
@@ -2328,12 +2328,15 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2328
2328
|
const [failed, setFailed] = React7.useState(null);
|
|
2329
2329
|
const { id, attrs, regions } = block;
|
|
2330
2330
|
const src = imageSource(attrs, resolveAssetUrl);
|
|
2331
|
-
const alt =
|
|
2331
|
+
const alt = chunk6H76FAI3_cjs.str(attrs.alt);
|
|
2332
2332
|
const name = alt || labels.imageNoAlt;
|
|
2333
|
-
const percent =
|
|
2333
|
+
const percent = chunk6H76FAI3_cjs.optionalNumber(attrs.widthPercent);
|
|
2334
2334
|
const width = preview ?? percent;
|
|
2335
2335
|
const flagged = !readOnly && alt === "" && attrs.decorative !== true;
|
|
2336
2336
|
const select = () => focusNode(controller, id);
|
|
2337
|
+
const badgeText = labels.noAltBadge ?? englishLabels.noAltBadge;
|
|
2338
|
+
const badgeName = labels.addAltText ?? englishLabels.addAltText;
|
|
2339
|
+
const translatedAlone = badgeText !== englishLabels.noAltBadge && badgeName === englishLabels.addAltText;
|
|
2337
2340
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2338
2341
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: frame, className: "quoin-image-frame", style: width === void 0 ? void 0 : { width: `${width}%` }, children: [
|
|
2339
2342
|
src !== null && src !== failed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2341,8 +2344,8 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2341
2344
|
{
|
|
2342
2345
|
src,
|
|
2343
2346
|
alt: name,
|
|
2344
|
-
width:
|
|
2345
|
-
height:
|
|
2347
|
+
width: chunk6H76FAI3_cjs.optionalNumber(attrs.width),
|
|
2348
|
+
height: chunk6H76FAI3_cjs.optionalNumber(attrs.height),
|
|
2346
2349
|
draggable: false,
|
|
2347
2350
|
onError: () => setFailed(src),
|
|
2348
2351
|
onClick: select
|
|
@@ -2356,11 +2359,12 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2356
2359
|
{
|
|
2357
2360
|
type: "button",
|
|
2358
2361
|
className: "quoin-image-no-alt",
|
|
2362
|
+
"aria-label": translatedAlone ? void 0 : badgeName,
|
|
2359
2363
|
onClick: () => {
|
|
2360
2364
|
select();
|
|
2361
2365
|
requestAlt(controller, id);
|
|
2362
2366
|
},
|
|
2363
|
-
children:
|
|
2367
|
+
children: badgeText
|
|
2364
2368
|
}
|
|
2365
2369
|
),
|
|
2366
2370
|
!readOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2376,7 +2380,7 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2376
2380
|
)
|
|
2377
2381
|
] }),
|
|
2378
2382
|
(!readOnly || (regions.caption?.length ?? 0) > 0) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2379
|
-
|
|
2383
|
+
chunkVSUGJZ7G_cjs.EditableRegion,
|
|
2380
2384
|
{
|
|
2381
2385
|
block: id,
|
|
2382
2386
|
region: "caption",
|
|
@@ -2394,8 +2398,8 @@ var WHITESPACE = /\s/;
|
|
|
2394
2398
|
function linkAddress(typed2) {
|
|
2395
2399
|
const address = typed2.trim();
|
|
2396
2400
|
if (WHITESPACE.test(address)) return null;
|
|
2397
|
-
const completed = !
|
|
2398
|
-
const href =
|
|
2401
|
+
const completed = !chunk6H76FAI3_cjs.SCHEME.test(address) && BARE_DOMAIN.test(address) ? `https://${address}` : address;
|
|
2402
|
+
const href = chunk6H76FAI3_cjs.sanitizeHref(completed);
|
|
2399
2403
|
return href || null;
|
|
2400
2404
|
}
|
|
2401
2405
|
var Input = React7__namespace.forwardRef(function Input2({ className, type, ...props }, ref) {
|
|
@@ -2502,8 +2506,8 @@ function ImageUploadArea({ blockId, controller }) {
|
|
|
2502
2506
|
);
|
|
2503
2507
|
}
|
|
2504
2508
|
function captionEnd(controller, blockId) {
|
|
2505
|
-
const caption =
|
|
2506
|
-
return { block: blockId, region: "caption", offset:
|
|
2509
|
+
const caption = chunk6H76FAI3_cjs.blockById(controller.editor.state.doc, blockId)?.regions.caption ?? [];
|
|
2510
|
+
return { block: blockId, region: "caption", offset: chunk6H76FAI3_cjs.inlineLength(caption) };
|
|
2507
2511
|
}
|
|
2508
2512
|
var plainEnter = (event) => event.key === "Enter" && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
2509
2513
|
var menuOpenOn = (host) => host?.getAttribute("aria-expanded") === "true";
|
|
@@ -2515,7 +2519,7 @@ function useImageKeys(controller, blockId, picture, editable, root) {
|
|
|
2515
2519
|
// then follows.
|
|
2516
2520
|
enter() {
|
|
2517
2521
|
const { editor } = controller;
|
|
2518
|
-
editor.dispatch(editor.createTransaction().setSelection(
|
|
2522
|
+
editor.dispatch(editor.createTransaction().setSelection(chunkM5FREXRQ_cjs.textSelection(captionEnd(controller, blockId))));
|
|
2519
2523
|
controller.focus();
|
|
2520
2524
|
},
|
|
2521
2525
|
type(key) {
|
|
@@ -2540,7 +2544,7 @@ function useImageKeys(controller, blockId, picture, editable, root) {
|
|
|
2540
2544
|
}
|
|
2541
2545
|
var ImageBlock = ({ block, controller }) => {
|
|
2542
2546
|
const labels = useLabels();
|
|
2543
|
-
const readOnly =
|
|
2547
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
2544
2548
|
const root = React7.useRef(null);
|
|
2545
2549
|
const picture = hasPicture(block.attrs);
|
|
2546
2550
|
useImageKeys(controller, block.id, picture, !readOnly, root);
|
|
@@ -2553,17 +2557,17 @@ var ImageBlock = ({ block, controller }) => {
|
|
|
2553
2557
|
"aria-label": labels.blockNames.image,
|
|
2554
2558
|
contentEditable: false,
|
|
2555
2559
|
className: "quoin-image",
|
|
2556
|
-
...picture ? { [
|
|
2560
|
+
...picture ? { [chunkVSUGJZ7G_cjs.NODE_ENTRY]: "" } : void 0,
|
|
2557
2561
|
children: picture ? /* @__PURE__ */ jsxRuntime.jsx(ImageFigure, { block, controller, readOnly }) : empty
|
|
2558
2562
|
}
|
|
2559
2563
|
);
|
|
2560
2564
|
};
|
|
2561
2565
|
function useOutsidePress(element, ownerDocument, onPress) {
|
|
2562
2566
|
const latest = React7.useRef(onPress);
|
|
2563
|
-
|
|
2567
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
2564
2568
|
latest.current = onPress;
|
|
2565
2569
|
});
|
|
2566
|
-
|
|
2570
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
2567
2571
|
const doc = ownerDocument();
|
|
2568
2572
|
const inside = (target) => element.current?.contains(target) === true;
|
|
2569
2573
|
let touched = null;
|
|
@@ -2578,15 +2582,15 @@ function useOutsidePress(element, ownerDocument, onPress) {
|
|
|
2578
2582
|
if (touched !== null && !inside(event.target)) latest.current(touched);
|
|
2579
2583
|
touched = null;
|
|
2580
2584
|
};
|
|
2581
|
-
return
|
|
2585
|
+
return chunkVSUGJZ7G_cjs.listen(doc, { pointerdown: down, click }, true);
|
|
2582
2586
|
}, [element, ownerDocument]);
|
|
2583
2587
|
}
|
|
2584
2588
|
function storeAlt(controller, blockId, opened, patch) {
|
|
2585
2589
|
const { editor } = controller;
|
|
2586
|
-
const attrs =
|
|
2587
|
-
const changed =
|
|
2590
|
+
const attrs = chunk6H76FAI3_cjs.blockById(editor.state.doc, blockId)?.attrs ?? {};
|
|
2591
|
+
const changed = chunk6H76FAI3_cjs.str(attrs.alt) !== opened.alt || attrs.decorative === true !== opened.decorative;
|
|
2588
2592
|
if (controller.readOnly || controller.root === null || changed) return;
|
|
2589
|
-
|
|
2593
|
+
chunkVSUGJZ7G_cjs.onBlock(blockId, chunkM5FREXRQ_cjs.setAttrs(patch))(editor.state, (tr) => editor.dispatch(tr));
|
|
2590
2594
|
}
|
|
2591
2595
|
function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative, onClose }) {
|
|
2592
2596
|
const labels = useLabels();
|
|
@@ -2628,7 +2632,7 @@ function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative,
|
|
|
2628
2632
|
close(true);
|
|
2629
2633
|
};
|
|
2630
2634
|
const onKeyDown = (event) => {
|
|
2631
|
-
if (event.key !== "Tab" ||
|
|
2635
|
+
if (event.key !== "Tab" || chunkVSUGJZ7G_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2632
2636
|
const controls = [...event.currentTarget.elements];
|
|
2633
2637
|
const next = controls[controls.indexOf(event.target) + (event.shiftKey ? -1 : 1)];
|
|
2634
2638
|
event.preventDefault();
|
|
@@ -2656,7 +2660,7 @@ function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative,
|
|
|
2656
2660
|
onCloseAutoFocus: preventDefault,
|
|
2657
2661
|
onEscapeKeyDown: (event) => {
|
|
2658
2662
|
event.preventDefault();
|
|
2659
|
-
if (!
|
|
2663
|
+
if (!chunkVSUGJZ7G_cjs.isComposingKey(controller, event)) close(false);
|
|
2660
2664
|
},
|
|
2661
2665
|
...bubblePart(controller),
|
|
2662
2666
|
children: /* @__PURE__ */ jsxRuntime.jsxs("form", { noValidate: true, className: "quoin-image-alt", onSubmit: save, onKeyDown, children: [
|
|
@@ -2708,7 +2712,7 @@ function imageToolbarItems(blockId, labels, actions) {
|
|
|
2708
2712
|
id: align,
|
|
2709
2713
|
title: labels[label],
|
|
2710
2714
|
icon,
|
|
2711
|
-
isActive: (state) => (
|
|
2715
|
+
isActive: (state) => (chunk6H76FAI3_cjs.alignOrUndefined(chunk6H76FAI3_cjs.blockById(state.doc, blockId)?.attrs.align) ?? "left") === align,
|
|
2712
2716
|
run: (controller) => setBlockAttrs(controller, blockId, { align })
|
|
2713
2717
|
})
|
|
2714
2718
|
);
|
|
@@ -2750,11 +2754,11 @@ function ImageToolbarOverlay({ controller }) {
|
|
|
2750
2754
|
}
|
|
2751
2755
|
function ImageToolbar({ blockId, controller, editingAlt, onEditAlt }) {
|
|
2752
2756
|
const { labels, resolveAssetUrl } = useQuoin();
|
|
2753
|
-
const state =
|
|
2757
|
+
const state = chunkVSUGJZ7G_cjs.useEditorState(controller, chunkVSUGJZ7G_cjs.wholeState);
|
|
2754
2758
|
const picker = useReplacePicker(controller, blockId, uploadImage, "image/*");
|
|
2755
2759
|
const altButton = React7.useRef(null);
|
|
2756
2760
|
const anchor = usePartAnchor(controller, blockId, ".quoin-image-frame");
|
|
2757
|
-
const attrs =
|
|
2761
|
+
const attrs = chunk6H76FAI3_cjs.blockById(state.doc, blockId)?.attrs ?? {};
|
|
2758
2762
|
const items = imageToolbarItems(blockId, labels, {
|
|
2759
2763
|
replace: picker.open,
|
|
2760
2764
|
editAlt: () => {
|
|
@@ -2780,7 +2784,7 @@ function ImageToolbar({ blockId, controller, editingAlt, onEditAlt }) {
|
|
|
2780
2784
|
controller,
|
|
2781
2785
|
anchor,
|
|
2782
2786
|
opener: altButton,
|
|
2783
|
-
alt:
|
|
2787
|
+
alt: chunk6H76FAI3_cjs.str(attrs.alt),
|
|
2784
2788
|
decorative: attrs.decorative === true,
|
|
2785
2789
|
onClose: () => onEditAlt(null)
|
|
2786
2790
|
}
|
|
@@ -2982,13 +2986,13 @@ function CalloutToneMenu({ blockId, controller, tone }) {
|
|
|
2982
2986
|
}
|
|
2983
2987
|
var CalloutBlock = ({ block, controller }) => {
|
|
2984
2988
|
const labels = useLabels();
|
|
2985
|
-
const readOnly =
|
|
2989
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
2986
2990
|
const tone = calloutTone(block.attrs.tone);
|
|
2987
2991
|
const icon = calloutIcon(block.attrs, tone);
|
|
2988
2992
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("quoin-callout group/callout flex items-start gap-2", TONE[tone]), "data-tone": tone, children: [
|
|
2989
2993
|
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
2994
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2991
|
-
|
|
2995
|
+
chunkVSUGJZ7G_cjs.EditableRegion,
|
|
2992
2996
|
{
|
|
2993
2997
|
block: block.id,
|
|
2994
2998
|
region: "body",
|
|
@@ -3056,23 +3060,23 @@ var HEADING_LEVELS = ["mt-6 text-3xl", "mt-5 text-2xl", "mt-4 text-xl", "mt-3 te
|
|
|
3056
3060
|
var headingStyles = (level) => `quoin-heading mb-1 font-semibold leading-tight in-[[data-quoin-block]:first-child]:mt-0 ${HEADING_LEVELS[level - 1]}`;
|
|
3057
3061
|
function Heading({ block }) {
|
|
3058
3062
|
const labels = useLabels();
|
|
3059
|
-
const level =
|
|
3060
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: headingStyles(level), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3063
|
+
const level = chunk6H76FAI3_cjs.headingLevel(block.attrs.level);
|
|
3064
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: headingStyles(level), children: /* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.heading(level) }) });
|
|
3061
3065
|
}
|
|
3062
3066
|
function NumberedItem({ block, controller }) {
|
|
3063
3067
|
const labels = useLabels();
|
|
3064
|
-
const number =
|
|
3068
|
+
const number = chunkVSUGJZ7G_cjs.useOrderedNumber(controller, block.id);
|
|
3065
3069
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "ordered", children: [
|
|
3066
3070
|
/* @__PURE__ */ jsxRuntime.jsx(ListMarker, { list: "ordered", number, depth: block.indent }),
|
|
3067
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3071
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.numberedItem(number) })
|
|
3068
3072
|
] });
|
|
3069
3073
|
}
|
|
3070
3074
|
function TaskItem({ block, controller }) {
|
|
3071
3075
|
const labels = useLabels();
|
|
3072
|
-
const hostId =
|
|
3076
|
+
const hostId = chunkVSUGJZ7G_cjs.useRegionDomId(block.id, REGION);
|
|
3073
3077
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-task", "data-checked": block.attrs.checked === true, children: [
|
|
3074
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3075
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3078
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.TaskCheckbox, { block, controller, label: labels.task, labelledBy: hostId }),
|
|
3079
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { id: hostId, block: block.id, region: REGION, label: labels.task })
|
|
3076
3080
|
] });
|
|
3077
3081
|
}
|
|
3078
3082
|
var MarkdownBlock = (props) => {
|
|
@@ -3084,16 +3088,16 @@ var MarkdownBlock = (props) => {
|
|
|
3084
3088
|
case "bullet":
|
|
3085
3089
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "bullet", children: [
|
|
3086
3090
|
/* @__PURE__ */ jsxRuntime.jsx(ListMarker, { list: "bullet", depth: block.indent }),
|
|
3087
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3091
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.bulletItem })
|
|
3088
3092
|
] });
|
|
3089
3093
|
case "ordered":
|
|
3090
3094
|
return /* @__PURE__ */ jsxRuntime.jsx(NumberedItem, { ...props });
|
|
3091
3095
|
case "task":
|
|
3092
3096
|
return /* @__PURE__ */ jsxRuntime.jsx(TaskItem, { ...props });
|
|
3093
3097
|
case "quote":
|
|
3094
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-quote", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3098
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-quote", children: /* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.quote }) });
|
|
3095
3099
|
default:
|
|
3096
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3100
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.paragraph });
|
|
3097
3101
|
}
|
|
3098
3102
|
};
|
|
3099
3103
|
|
|
@@ -3101,19 +3105,19 @@ var MarkdownBlock = (props) => {
|
|
|
3101
3105
|
function nestedBlockIds({ doc }, blockId) {
|
|
3102
3106
|
const index = doc.index.get(blockId);
|
|
3103
3107
|
if (index === void 0) return [];
|
|
3104
|
-
return doc.blocks.slice(index + 1,
|
|
3108
|
+
return doc.blocks.slice(index + 1, chunkM5FREXRQ_cjs.descendantsEnd(doc, index)).map((block) => block.id);
|
|
3105
3109
|
}
|
|
3106
3110
|
function useNestedBlocks(controller, blockId) {
|
|
3107
|
-
return
|
|
3111
|
+
return chunkVSUGJZ7G_cjs.useEditorState(controller, (state) => nestedBlockIds(state, blockId), chunk6H76FAI3_cjs.sameItems);
|
|
3108
3112
|
}
|
|
3109
3113
|
var ToggleBlock = ({ block, controller }) => {
|
|
3110
3114
|
const labels = useLabels();
|
|
3111
|
-
const domId =
|
|
3115
|
+
const domId = chunkVSUGJZ7G_cjs.useBlockDomId();
|
|
3112
3116
|
const nested = useNestedBlocks(controller, block.id);
|
|
3113
|
-
const open =
|
|
3117
|
+
const open = chunkVSUGJZ7G_cjs.useToggleOpen(controller, block);
|
|
3114
3118
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-toggle", "data-open": open, children: [
|
|
3115
3119
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3116
|
-
|
|
3120
|
+
chunkVSUGJZ7G_cjs.ToggleChevron,
|
|
3117
3121
|
{
|
|
3118
3122
|
block,
|
|
3119
3123
|
controller,
|
|
@@ -3121,7 +3125,7 @@ var ToggleBlock = ({ block, controller }) => {
|
|
|
3121
3125
|
controls: nested.length === 0 ? void 0 : nested.map(domId).join(" ")
|
|
3122
3126
|
}
|
|
3123
3127
|
),
|
|
3124
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3128
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkVSUGJZ7G_cjs.EditableRegion, { block: block.id, region: "text", label: labels.toggle })
|
|
3125
3129
|
] });
|
|
3126
3130
|
};
|
|
3127
3131
|
|
|
@@ -3180,7 +3184,7 @@ function turnIntoTargets(labels) {
|
|
|
3180
3184
|
function TurnIntoItems({ kit, controller, blockIds }) {
|
|
3181
3185
|
const { blockTypes, labels } = useQuoin();
|
|
3182
3186
|
const targets = turnIntoTargets(labels).filter((target) => drawsType(blockTypes, target.type));
|
|
3183
|
-
return targets.map((target) => /* @__PURE__ */ jsxRuntime.jsxs(kit.Item, { onSelect: () => runOnBlocks(controller, blockIds,
|
|
3187
|
+
return targets.map((target) => /* @__PURE__ */ jsxRuntime.jsxs(kit.Item, { onSelect: () => runOnBlocks(controller, blockIds, chunkM5FREXRQ_cjs.setBlockType(target.type, target.attrs)), children: [
|
|
3184
3188
|
/* @__PURE__ */ jsxRuntime.jsx(MenuIcon, { icon: target.icon }),
|
|
3185
3189
|
target.label
|
|
3186
3190
|
] }, target.id));
|
|
@@ -3215,10 +3219,10 @@ function ActionItem({ kit, controller, action, blockIds }) {
|
|
|
3215
3219
|
);
|
|
3216
3220
|
}
|
|
3217
3221
|
function BlockMenuItems({ kit, controller, blocks, styled, title, actions }) {
|
|
3218
|
-
const state =
|
|
3222
|
+
const state = chunkVSUGJZ7G_cjs.useEditorState(controller, chunkVSUGJZ7G_cjs.wholeState);
|
|
3219
3223
|
const blockIds = blocks.map((block) => block.id);
|
|
3220
3224
|
const shown = actions.filter((action) => action.available?.(state, blockIds) ?? true);
|
|
3221
|
-
const anyText = styled.some((block) =>
|
|
3225
|
+
const anyText = styled.some((block) => chunkM5FREXRQ_cjs.isTextFlow(state.schema, block));
|
|
3222
3226
|
const anyMarkdown = styled.some((block) => block.type === "MARKDOWN");
|
|
3223
3227
|
const allCallouts = styled.length > 0 && styled.every((block) => block.type === "CALLOUT");
|
|
3224
3228
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -3260,7 +3264,7 @@ var CONTEXT_KIT = {
|
|
|
3260
3264
|
SubTrigger: ContextMenuSubTrigger
|
|
3261
3265
|
};
|
|
3262
3266
|
var GUTTER_BLOCK = "data-quoin-gutter-block";
|
|
3263
|
-
var OWN_MENU = `[${
|
|
3267
|
+
var OWN_MENU = `[${chunkVSUGJZ7G_cjs.NATIVE_INTERACTION}], input, textarea, select`;
|
|
3264
3268
|
function contextBlock(controller, target) {
|
|
3265
3269
|
const { state } = controller.editor;
|
|
3266
3270
|
const gutter = target.closest(`[${GUTTER_BLOCK}]`)?.getAttribute(GUTTER_BLOCK);
|
|
@@ -3269,8 +3273,8 @@ function contextBlock(controller, target) {
|
|
|
3269
3273
|
if (selection?.kind === "blocks") return selection.head;
|
|
3270
3274
|
if (target.closest(OWN_MENU) || controller.registry.locate(target) !== null) return null;
|
|
3271
3275
|
const id = controller.blockAt(target);
|
|
3272
|
-
const block = id === void 0 ? void 0 :
|
|
3273
|
-
return block === void 0 ||
|
|
3276
|
+
const block = id === void 0 ? void 0 : chunk6H76FAI3_cjs.blockById(state.doc, id);
|
|
3277
|
+
return block === void 0 || chunkM5FREXRQ_cjs.isTextFlow(state.schema, block) ? null : block.id;
|
|
3274
3278
|
}
|
|
3275
3279
|
function useContextMenuOpener(controller, store, trigger) {
|
|
3276
3280
|
React7.useEffect(() => {
|
|
@@ -3289,7 +3293,7 @@ function useContextMenuOpener(controller, store, trigger) {
|
|
|
3289
3293
|
openBlockMenuAt(store, controller.editor.state, block, clientX, clientY);
|
|
3290
3294
|
hidden.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX, clientY }));
|
|
3291
3295
|
};
|
|
3292
|
-
return
|
|
3296
|
+
return chunkVSUGJZ7G_cjs.listen(root, { mousedown: onMouseDown, contextmenu: onContextMenu });
|
|
3293
3297
|
}, [controller, store, trigger]);
|
|
3294
3298
|
}
|
|
3295
3299
|
|
|
@@ -3322,10 +3326,10 @@ var ExtensionBlockNames = React7.createContext({});
|
|
|
3322
3326
|
// src/gutter/use-menu-blocks.ts
|
|
3323
3327
|
function useLiveBlocks(controller, blockIds) {
|
|
3324
3328
|
const select = React7.useCallback(
|
|
3325
|
-
(state) => blockIds.flatMap((id) =>
|
|
3329
|
+
(state) => blockIds.flatMap((id) => chunk6H76FAI3_cjs.blockById(state.doc, id) ?? []),
|
|
3326
3330
|
[blockIds]
|
|
3327
3331
|
);
|
|
3328
|
-
return
|
|
3332
|
+
return chunkVSUGJZ7G_cjs.useEditorState(controller, select, chunk6H76FAI3_cjs.sameItems);
|
|
3329
3333
|
}
|
|
3330
3334
|
function useMenuBlocks(controller, store, menu) {
|
|
3331
3335
|
const labels = useLabels();
|
|
@@ -3378,12 +3382,12 @@ function BlockContextMenu({ controller, store, actions }) {
|
|
|
3378
3382
|
// src/gutter/block-menu-keymap.ts
|
|
3379
3383
|
function blockMenuKeymap(store) {
|
|
3380
3384
|
const openForHead = (state, dispatch) => {
|
|
3381
|
-
const head =
|
|
3385
|
+
const head = chunkM5FREXRQ_cjs.headBlockId(state.selection);
|
|
3382
3386
|
if (head === null || !state.doc.index.has(head)) return false;
|
|
3383
3387
|
if (dispatch) openBlockMenu(store, state, head);
|
|
3384
3388
|
return true;
|
|
3385
3389
|
};
|
|
3386
|
-
return
|
|
3390
|
+
return chunkM5FREXRQ_cjs.defineExtension({ name: "block-menu", keymap: { "Mod-/": openForHead } });
|
|
3387
3391
|
}
|
|
3388
3392
|
var UNIQUE_OR_FOCUSABLE = ["id", "data-block-id", "contenteditable", "tabindex"];
|
|
3389
3393
|
function copyOf(shell) {
|
|
@@ -3452,7 +3456,7 @@ var DragOverlay = React7.forwardRef(function DragOverlay2(_props, ref) {
|
|
|
3452
3456
|
var DELETION_STEPS = /* @__PURE__ */ new Set(["removeBlocks", "setIndent"]);
|
|
3453
3457
|
function drawnPosition(doc, blockId) {
|
|
3454
3458
|
const index = doc.index.get(blockId) ?? 0;
|
|
3455
|
-
return [
|
|
3459
|
+
return [chunkVSUGJZ7G_cjs.drawnBlockCount(doc, 0, index) + 1, chunkVSUGJZ7G_cjs.drawnBlockCount(doc)];
|
|
3456
3460
|
}
|
|
3457
3461
|
function blockMovedMessage(doc, blockId, labels) {
|
|
3458
3462
|
return labels.blockMoved(...drawnPosition(doc, blockId));
|
|
@@ -3468,11 +3472,11 @@ function deletedCount(tr) {
|
|
|
3468
3472
|
return tr.steps.reduce((deleted, step, i) => {
|
|
3469
3473
|
const { index, count } = step.toJSON();
|
|
3470
3474
|
if (step.stepType !== "removeBlocks" || typeof index !== "number" || typeof count !== "number") return deleted;
|
|
3471
|
-
return deleted +
|
|
3475
|
+
return deleted + chunkVSUGJZ7G_cjs.drawnBlockCount(tr.docs[i], index, index + count);
|
|
3472
3476
|
}, 0);
|
|
3473
3477
|
}
|
|
3474
3478
|
function insertedBlock(tr) {
|
|
3475
|
-
if (tr.getMeta(
|
|
3479
|
+
if (tr.getMeta(chunkM5FREXRQ_cjs.LINE_SPLIT) === true || tr.steps.some((step) => step.stepType === "removeBlocks")) return null;
|
|
3476
3480
|
const inserted = tr.steps.flatMap((step) => {
|
|
3477
3481
|
const { blocks } = step.toJSON();
|
|
3478
3482
|
return step.stepType === "insertBlocks" && Array.isArray(blocks) ? blocks : [];
|
|
@@ -3480,7 +3484,7 @@ function insertedBlock(tr) {
|
|
|
3480
3484
|
return inserted.find((block) => tr.doc.index.has(block.id))?.id ?? null;
|
|
3481
3485
|
}
|
|
3482
3486
|
function structureAnnouncement(tr, labels, undoKeys) {
|
|
3483
|
-
if (tr.origin !== "command" || tr.getMeta(
|
|
3487
|
+
if (tr.origin !== "command" || tr.getMeta(chunkM5FREXRQ_cjs.LINE_JOIN) === true) return null;
|
|
3484
3488
|
const moved = movedBlock(tr);
|
|
3485
3489
|
if (moved !== null) return blockMovedMessage(tr.doc, moved, labels);
|
|
3486
3490
|
const deleted = deletedCount(tr);
|
|
@@ -3510,7 +3514,7 @@ function inlineEdges(shell, box, rtl) {
|
|
|
3510
3514
|
function measure(controller, root, moved, rtl) {
|
|
3511
3515
|
const { doc } = controller.editor.state;
|
|
3512
3516
|
const origin = rootOrigin(root);
|
|
3513
|
-
return
|
|
3517
|
+
return chunkVSUGJZ7G_cjs.visibleBlockIndexes(doc).flatMap((index) => {
|
|
3514
3518
|
const { id, indent: indent3 } = doc.blocks[index];
|
|
3515
3519
|
const shell = controller.blockElement(id);
|
|
3516
3520
|
if (shell === void 0) return [];
|
|
@@ -3525,7 +3529,7 @@ function measureDrag(controller, root, ids) {
|
|
|
3525
3529
|
const { doc } = controller.editor.state;
|
|
3526
3530
|
const direction = inlineDirection(root);
|
|
3527
3531
|
const rtl = direction === "rtl";
|
|
3528
|
-
const moved = new Set(
|
|
3532
|
+
const moved = new Set(chunkM5FREXRQ_cjs.movedBlockIds(doc, ids));
|
|
3529
3533
|
const blocks = measure(controller, root, moved, rtl);
|
|
3530
3534
|
const dragged = blocks.filter((block) => block.dragged);
|
|
3531
3535
|
if (dragged.length === 0) return null;
|
|
@@ -3585,7 +3589,7 @@ function draggedBlocks(controller, blockId) {
|
|
|
3585
3589
|
function followPress(press, root, view) {
|
|
3586
3590
|
const { controller, store, overlay, handle: handle2, pointerId } = press;
|
|
3587
3591
|
const doc = view.document;
|
|
3588
|
-
const scroll =
|
|
3592
|
+
const scroll = chunkVSUGJZ7G_cjs.createAutoScroll(root, follow, SCROLL_EDGE);
|
|
3589
3593
|
let pointer = { x: press.x, y: press.y };
|
|
3590
3594
|
let active = null;
|
|
3591
3595
|
let unsubscribe = () => {
|
|
@@ -3638,7 +3642,7 @@ function followPress(press, root, view) {
|
|
|
3638
3642
|
finish();
|
|
3639
3643
|
if (dropped === null || dropped.target === null || controller.readOnly) return;
|
|
3640
3644
|
const { ids, layout, target } = dropped;
|
|
3641
|
-
if (!controller.run(
|
|
3645
|
+
if (!controller.run(chunkM5FREXRQ_cjs.moveBlocksTo(ids, layout.toIndex(target.index), target.indent))) return;
|
|
3642
3646
|
controller.focus();
|
|
3643
3647
|
press.onMoved(ids[0]);
|
|
3644
3648
|
}
|
|
@@ -3660,9 +3664,9 @@ function followPress(press, root, view) {
|
|
|
3660
3664
|
event.stopPropagation();
|
|
3661
3665
|
finish();
|
|
3662
3666
|
}
|
|
3663
|
-
const unlistenDocument =
|
|
3664
|
-
const unlistenBlur =
|
|
3665
|
-
const unlistenKeys =
|
|
3667
|
+
const unlistenDocument = chunkVSUGJZ7G_cjs.listen(doc, { pointermove: onPointerMove, pointerup: onPointerUp, pointercancel: finish });
|
|
3668
|
+
const unlistenBlur = chunkVSUGJZ7G_cjs.listen(view, { blur: finish });
|
|
3669
|
+
const unlistenKeys = chunkVSUGJZ7G_cjs.listen(view, { keydown: onKeyDown }, true);
|
|
3666
3670
|
return finish;
|
|
3667
3671
|
}
|
|
3668
3672
|
function pressDragHandle(press) {
|
|
@@ -3714,12 +3718,12 @@ function useBlockDrag(controller, store, blockId, overlay) {
|
|
|
3714
3718
|
function addBlockBelow(controller, blockId) {
|
|
3715
3719
|
const { state } = controller.editor;
|
|
3716
3720
|
const { doc, schema } = state;
|
|
3717
|
-
const block =
|
|
3721
|
+
const block = chunk6H76FAI3_cjs.blockById(doc, blockId);
|
|
3718
3722
|
if (block === void 0) return false;
|
|
3719
|
-
const empty =
|
|
3720
|
-
const fill = empty ?
|
|
3721
|
-
const slash =
|
|
3722
|
-
const { ok, tr } =
|
|
3723
|
+
const empty = chunkM5FREXRQ_cjs.isParagraph(block) && chunkM5FREXRQ_cjs.regionLength(block, chunkM5FREXRQ_cjs.primaryRegion(schema, block) ?? "") === 0;
|
|
3724
|
+
const fill = empty ? chunkM5FREXRQ_cjs.setSelection(chunkM5FREXRQ_cjs.startOf(doc, schema, blockId)) : chunkM5FREXRQ_cjs.insertBlockAfter("MARKDOWN", { kind: "paragraph" });
|
|
3725
|
+
const slash = chunkM5FREXRQ_cjs.insertText("/", { origin: "command" });
|
|
3726
|
+
const { ok, tr } = chunkM5FREXRQ_cjs.runCommands(state, [chunkM5FREXRQ_cjs.setSelection(chunkM5FREXRQ_cjs.blockRangeSelection(blockId)), fill, slash]);
|
|
3723
3727
|
if (ok && tr !== null) controller.dispatch(tr);
|
|
3724
3728
|
controller.focus();
|
|
3725
3729
|
return ok;
|
|
@@ -3797,7 +3801,7 @@ function place2(controller, root, gutter, block) {
|
|
|
3797
3801
|
gutter.style.visibility = "";
|
|
3798
3802
|
}
|
|
3799
3803
|
function useGutterPosition(controller, gutter, block) {
|
|
3800
|
-
|
|
3804
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
3801
3805
|
const element = gutter.current;
|
|
3802
3806
|
const root = controller.root;
|
|
3803
3807
|
const view = root?.ownerDocument.defaultView;
|
|
@@ -3821,7 +3825,7 @@ function useGutterPosition(controller, gutter, block) {
|
|
|
3821
3825
|
};
|
|
3822
3826
|
}, [controller, gutter, block]);
|
|
3823
3827
|
}
|
|
3824
|
-
var headOf = (state) =>
|
|
3828
|
+
var headOf = (state) => chunkM5FREXRQ_cjs.headBlockId(state.selection);
|
|
3825
3829
|
function blockAcross(controller, root, y) {
|
|
3826
3830
|
const box = root.getBoundingClientRect();
|
|
3827
3831
|
const probe = root.ownerDocument.elementFromPoint?.(box.left + box.width / 2, y);
|
|
@@ -3829,7 +3833,7 @@ function blockAcross(controller, root, y) {
|
|
|
3829
3833
|
}
|
|
3830
3834
|
function useGutterTarget(controller, store, gutter) {
|
|
3831
3835
|
const hovered = useCanvasUi(store, (state) => state.hoveredBlock);
|
|
3832
|
-
const head =
|
|
3836
|
+
const head = chunkVSUGJZ7G_cjs.useEditorState(controller, headOf);
|
|
3833
3837
|
const [focusWithin, setFocusWithin] = React7.useState(false);
|
|
3834
3838
|
React7.useEffect(() => {
|
|
3835
3839
|
const root = controller.root;
|
|
@@ -3847,7 +3851,7 @@ function useGutterTarget(controller, store, gutter) {
|
|
|
3847
3851
|
const onFocusIn = () => setFocusWithin(true);
|
|
3848
3852
|
const onFocusOut = (event) => setFocusWithin(root.contains(event.relatedTarget));
|
|
3849
3853
|
setFocusWithin(root.contains(root.ownerDocument.activeElement));
|
|
3850
|
-
return
|
|
3854
|
+
return chunkVSUGJZ7G_cjs.listen(root, { pointermove: onPointerMove, pointerleave: onPointerLeave, focusin: onFocusIn, focusout: onFocusOut });
|
|
3851
3855
|
}, [controller, store, gutter]);
|
|
3852
3856
|
const fallback = focusWithin ? head : null;
|
|
3853
3857
|
const target = hovered ?? fallback;
|
|
@@ -3944,7 +3948,7 @@ function pointInHost(host, { node, offset }) {
|
|
|
3944
3948
|
return host.contains(node) ? { node, offset: Math.min(offset, nodeLength(node)) } : null;
|
|
3945
3949
|
}
|
|
3946
3950
|
function textRect(host, { from, to }) {
|
|
3947
|
-
const map =
|
|
3951
|
+
const map = chunkVSUGJZ7G_cjs.domMapOf(host);
|
|
3948
3952
|
const range = host.ownerDocument.createRange();
|
|
3949
3953
|
if (map === void 0 || typeof range.getBoundingClientRect !== "function") return null;
|
|
3950
3954
|
const start = pointInHost(host, map.toDom(from, 1));
|
|
@@ -3957,7 +3961,7 @@ function textRect(host, { from, to }) {
|
|
|
3957
3961
|
}
|
|
3958
3962
|
function rangeRect(controller, range) {
|
|
3959
3963
|
const host = controller.registry.get(range.block, range.region);
|
|
3960
|
-
if (host === void 0 || !host.isConnected || controller.composingKey ===
|
|
3964
|
+
if (host === void 0 || !host.isConnected || controller.composingKey === chunkVSUGJZ7G_cjs.hostKey(range.block, range.region)) {
|
|
3961
3965
|
return null;
|
|
3962
3966
|
}
|
|
3963
3967
|
const rect = textRect(host, range);
|
|
@@ -3973,7 +3977,7 @@ function union(a, b) {
|
|
|
3973
3977
|
function selectionRect(controller) {
|
|
3974
3978
|
const { state } = controller.editor;
|
|
3975
3979
|
if (state.selection?.kind !== "text") return null;
|
|
3976
|
-
const ranges =
|
|
3980
|
+
const ranges = chunkM5FREXRQ_cjs.markRanges(state);
|
|
3977
3981
|
if (ranges.length === 0) return null;
|
|
3978
3982
|
const first = rangeRect(controller, ranges[0]);
|
|
3979
3983
|
if (ranges.length === 1) return first;
|
|
@@ -3984,7 +3988,7 @@ function selectionRect(controller) {
|
|
|
3984
3988
|
// src/menus/floating/use-selection-anchor.ts
|
|
3985
3989
|
var ROOM_ABOVE = 56;
|
|
3986
3990
|
function selectionHost(controller) {
|
|
3987
|
-
const [first] =
|
|
3991
|
+
const [first] = chunkM5FREXRQ_cjs.markRanges(controller.editor.state);
|
|
3988
3992
|
return (first && controller.registry.get(first.block, first.region)) ?? controller.root ?? void 0;
|
|
3989
3993
|
}
|
|
3990
3994
|
function useSelectionAnchor(controller, state) {
|
|
@@ -3998,7 +4002,7 @@ function useSelectionAnchor(controller, state) {
|
|
|
3998
4002
|
[controller, state]
|
|
3999
4003
|
);
|
|
4000
4004
|
const [side, setSide] = React7.useState("top");
|
|
4001
|
-
|
|
4005
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4002
4006
|
const rect = selectionRect(controller);
|
|
4003
4007
|
if (rect) setSide(rect.top < ROOM_ABOVE ? "bottom" : "top");
|
|
4004
4008
|
}, [controller, state]);
|
|
@@ -4033,9 +4037,9 @@ var ICONS = { left: lucideReact.AlignLeft, center: lucideReact.AlignCenter, righ
|
|
|
4033
4037
|
var ALIGNS2 = Object.keys(ICONS);
|
|
4034
4038
|
var LABEL_KEYS = { left: "alignLeft", center: "alignCenter", right: "alignRight", justify: "alignJustify" };
|
|
4035
4039
|
function sharedAlign(state) {
|
|
4036
|
-
const blocks =
|
|
4040
|
+
const blocks = chunkM5FREXRQ_cjs.selectedBlockIds(state.doc, state.selection).map((id) => chunk6H76FAI3_cjs.blockById(state.doc, id)).filter((block) => block?.type === "MARKDOWN");
|
|
4037
4041
|
if (blocks.length === 0) return null;
|
|
4038
|
-
const aligns = new Set(blocks.map((block) =>
|
|
4042
|
+
const aligns = new Set(blocks.map((block) => chunk6H76FAI3_cjs.alignOrUndefined(block?.attrs.align) ?? "left"));
|
|
4039
4043
|
return aligns.size === 1 ? [...aligns][0] : "";
|
|
4040
4044
|
}
|
|
4041
4045
|
function AlignDropdown({ controller, state }) {
|
|
@@ -4044,7 +4048,7 @@ function AlignDropdown({ controller, state }) {
|
|
|
4044
4048
|
if (value === null) return null;
|
|
4045
4049
|
const Icon = value === "" ? lucideReact.AlignLeft : ICONS[value];
|
|
4046
4050
|
const trigger = /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.align, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {}) });
|
|
4047
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ToolbarMenu, { controller, trigger, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioGroup, { value, onValueChange: (align) => controller.run(
|
|
4051
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToolbarMenu, { controller, trigger, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioGroup, { value, onValueChange: (align) => controller.run(chunkM5FREXRQ_cjs.setTextAlign(align)), children: ALIGNS2.map((align) => /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuRadioItem, { value: align, indicator: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4" }), children: [
|
|
4048
4052
|
/* @__PURE__ */ jsxRuntime.jsx(MenuIcon, { icon: ICONS[align] }),
|
|
4049
4053
|
labels[LABEL_KEYS[align]]
|
|
4050
4054
|
] }, align)) }) });
|
|
@@ -4052,8 +4056,8 @@ function AlignDropdown({ controller, state }) {
|
|
|
4052
4056
|
var MARKS = { color: "color", background: "highlight" };
|
|
4053
4057
|
function selectionColor(state, mark) {
|
|
4054
4058
|
const names = /* @__PURE__ */ new Set();
|
|
4055
|
-
for (const range of
|
|
4056
|
-
for (const node of
|
|
4059
|
+
for (const range of chunkM5FREXRQ_cjs.markRanges(state)) {
|
|
4060
|
+
for (const node of chunkM5FREXRQ_cjs.rangeContent(state, range)) {
|
|
4057
4061
|
const found = node.marks.find((candidate) => candidate.type === mark);
|
|
4058
4062
|
names.add(found === void 0 ? "default" : found.attrs?.color);
|
|
4059
4063
|
}
|
|
@@ -4062,7 +4066,7 @@ function selectionColor(state, mark) {
|
|
|
4062
4066
|
return names.size === 1 && typeof only === "string" ? only : "";
|
|
4063
4067
|
}
|
|
4064
4068
|
function colorCommand(key, name) {
|
|
4065
|
-
return name === "default" ?
|
|
4069
|
+
return name === "default" ? chunkM5FREXRQ_cjs.unsetMark(MARKS[key]) : chunkM5FREXRQ_cjs.setMark(MARKS[key], { color: name });
|
|
4066
4070
|
}
|
|
4067
4071
|
function ColorPopover({ controller, state }) {
|
|
4068
4072
|
const labels = useLabels();
|
|
@@ -4076,11 +4080,11 @@ function TurnIntoDropdown({ controller, state }) {
|
|
|
4076
4080
|
labels.turnInto,
|
|
4077
4081
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {})
|
|
4078
4082
|
] });
|
|
4079
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ToolbarMenu, { controller, trigger, children: /* @__PURE__ */ jsxRuntime.jsx(TurnIntoItems, { kit: DROPDOWN_KIT, controller, blockIds:
|
|
4083
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToolbarMenu, { controller, trigger, children: /* @__PURE__ */ jsxRuntime.jsx(TurnIntoItems, { kit: DROPDOWN_KIT, controller, blockIds: chunkM5FREXRQ_cjs.selectedBlockIds(state.doc, state.selection) }) });
|
|
4080
4084
|
}
|
|
4081
4085
|
var DIVIDER = "mx-0.5 h-5 w-px shrink-0 bg-border";
|
|
4082
4086
|
function BubbleToolbar({ controller, labels, store, extraItems }) {
|
|
4083
|
-
const state =
|
|
4087
|
+
const state = chunkVSUGJZ7G_cjs.useEditorState(controller, chunkVSUGJZ7G_cjs.wholeState);
|
|
4084
4088
|
const { anchor, side } = useSelectionAnchor(controller, state);
|
|
4085
4089
|
const roving = useRovingFocus();
|
|
4086
4090
|
const items = React7.useMemo(() => bubbleItems(labels, () => store.set({ linkPopover: { open: true } })), [labels, store]);
|
|
@@ -4142,10 +4146,10 @@ function useMediaQuery(query, unsupported) {
|
|
|
4142
4146
|
var useFinePointer = () => useMediaQuery("(pointer: fine)", true);
|
|
4143
4147
|
|
|
4144
4148
|
// src/menus/bubble/use-bubble-visibility.ts
|
|
4145
|
-
var hasTextRange = (state) => state.selection?.kind === "text" && !
|
|
4149
|
+
var hasTextRange = (state) => state.selection?.kind === "text" && !chunkM5FREXRQ_cjs.isCollapsed(state.selection) && chunkM5FREXRQ_cjs.markRanges(state).length > 0;
|
|
4146
4150
|
function useBubbleVisibility(controller) {
|
|
4147
|
-
const range =
|
|
4148
|
-
const readOnly =
|
|
4151
|
+
const range = chunkVSUGJZ7G_cjs.useEditorState(controller, hasTextRange);
|
|
4152
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
4149
4153
|
const fine = useFinePointer();
|
|
4150
4154
|
const settled = useSelectionSettled(controller);
|
|
4151
4155
|
return range && !readOnly && fine && settled;
|
|
@@ -4162,16 +4166,16 @@ function BubbleOverlay({ controller }) {
|
|
|
4162
4166
|
return /* @__PURE__ */ jsxRuntime.jsx(BubbleToolbar, { controller, labels, store, extraItems });
|
|
4163
4167
|
}
|
|
4164
4168
|
function bubbleExtension() {
|
|
4165
|
-
return
|
|
4169
|
+
return chunkM5FREXRQ_cjs.defineExtension({ name: "bubble", ui: { overlays: [BubbleOverlay] } });
|
|
4166
4170
|
}
|
|
4167
4171
|
|
|
4168
4172
|
// src/menus/link/link-at-selection.ts
|
|
4169
4173
|
function linkAround(state, from, to = from) {
|
|
4170
4174
|
if (from.block !== to.block || from.region !== to.region) return null;
|
|
4171
|
-
const inline =
|
|
4172
|
-
const extent =
|
|
4175
|
+
const inline = chunkVSUGJZ7G_cjs.regionInline(state, from.block, from.region) ?? [];
|
|
4176
|
+
const extent = chunkM5FREXRQ_cjs.markExtent(inline, from.offset, "link");
|
|
4173
4177
|
if (extent === null || to.offset > extent.to) return null;
|
|
4174
|
-
const attrs =
|
|
4178
|
+
const attrs = chunk6H76FAI3_cjs.sliceInline(inline, extent.from, extent.to)[0]?.marks.find((mark) => mark.type === "link")?.attrs;
|
|
4175
4179
|
if (attrs?.href === void 0) return null;
|
|
4176
4180
|
const range = { block: from.block, region: from.region, ...extent };
|
|
4177
4181
|
return { href: attrs.href, title: attrs.title || void 0, range };
|
|
@@ -4179,7 +4183,7 @@ function linkAround(state, from, to = from) {
|
|
|
4179
4183
|
function linkAtSelection(state) {
|
|
4180
4184
|
const { selection } = state;
|
|
4181
4185
|
if (selection?.kind !== "text") return null;
|
|
4182
|
-
const { from, to } =
|
|
4186
|
+
const { from, to } = chunkM5FREXRQ_cjs.orderedRange(state.doc, selection.anchor, selection.head);
|
|
4183
4187
|
return linkAround(state, from, to);
|
|
4184
4188
|
}
|
|
4185
4189
|
|
|
@@ -4191,7 +4195,7 @@ function linkElementAt(controller, target) {
|
|
|
4191
4195
|
}
|
|
4192
4196
|
function linkAtElement(controller, state, element) {
|
|
4193
4197
|
const host = controller.registry.locate(element);
|
|
4194
|
-
const offset = host === null ? null :
|
|
4198
|
+
const offset = host === null ? null : chunkVSUGJZ7G_cjs.domMapOf(host.element)?.fromDom(element, 0) ?? null;
|
|
4195
4199
|
if (host === null || offset === null) return null;
|
|
4196
4200
|
return linkAround(state, { block: host.block, region: host.region, offset });
|
|
4197
4201
|
}
|
|
@@ -4217,7 +4221,7 @@ function truncateMiddle(text2, max) {
|
|
|
4217
4221
|
// src/menus/link/unlink-range.ts
|
|
4218
4222
|
function unlinkRange({ block, region, from, to }) {
|
|
4219
4223
|
return (state, dispatch) => {
|
|
4220
|
-
const tr = new
|
|
4224
|
+
const tr = new chunkM5FREXRQ_cjs.Transaction(state).step(chunkM5FREXRQ_cjs.removeMarkStep(block, region, from, to, "link"));
|
|
4221
4225
|
if (!tr.docChanged) return false;
|
|
4222
4226
|
dispatch?.(tr);
|
|
4223
4227
|
return true;
|
|
@@ -4239,12 +4243,12 @@ function useRestedValue(value, delay) {
|
|
|
4239
4243
|
// src/menus/link/use-caret-in-link.ts
|
|
4240
4244
|
function caretLinkKey(state) {
|
|
4241
4245
|
const { selection } = state;
|
|
4242
|
-
if (selection?.kind !== "text" || !
|
|
4246
|
+
if (selection?.kind !== "text" || !chunkM5FREXRQ_cjs.isCollapsed(selection)) return null;
|
|
4243
4247
|
const link = linkAtSelection(state);
|
|
4244
4248
|
return link && [link.range.block, link.range.region, link.range.from, link.href].join("\0");
|
|
4245
4249
|
}
|
|
4246
4250
|
function useCaretInLink(controller, delay) {
|
|
4247
|
-
const key =
|
|
4251
|
+
const key = chunkVSUGJZ7G_cjs.useEditorState(controller, caretLinkKey);
|
|
4248
4252
|
const settled = useSelectionSettled(controller);
|
|
4249
4253
|
return useRestedValue(settled ? key : null, delay) !== null;
|
|
4250
4254
|
}
|
|
@@ -4278,7 +4282,7 @@ var URL_LENGTH = 48;
|
|
|
4278
4282
|
var CARD = "flex w-auto items-center gap-0.5 py-1 ps-3 pe-1 shadow-md";
|
|
4279
4283
|
var ADDRESS = "me-1 whitespace-nowrap text-sm text-muted-foreground";
|
|
4280
4284
|
function LinkCard({ controller, labels, store, cardRef, element, onUnlinked }) {
|
|
4281
|
-
const state =
|
|
4285
|
+
const state = chunkVSUGJZ7G_cjs.useEditorState(controller, chunkVSUGJZ7G_cjs.wholeState);
|
|
4282
4286
|
const link = React7.useMemo(
|
|
4283
4287
|
() => element === null ? linkAtSelection(state) : linkAtElement(controller, state, element),
|
|
4284
4288
|
[controller, state, element]
|
|
@@ -4291,12 +4295,12 @@ function LinkCard({ controller, labels, store, cardRef, element, onUnlinked }) {
|
|
|
4291
4295
|
}, [controller, link]);
|
|
4292
4296
|
if (link === null) return null;
|
|
4293
4297
|
const { block, region, from, to } = link.range;
|
|
4294
|
-
const href =
|
|
4298
|
+
const href = chunk6H76FAI3_cjs.sanitizeHref(link.href);
|
|
4295
4299
|
const address = truncateMiddle(link.href, URL_LENGTH);
|
|
4296
4300
|
const edit2 = () => {
|
|
4297
4301
|
if (element !== null) {
|
|
4298
|
-
const selection =
|
|
4299
|
-
|
|
4302
|
+
const selection = chunkM5FREXRQ_cjs.textSelection({ block, region, offset: from }, { block, region, offset: to });
|
|
4303
|
+
chunkVSUGJZ7G_cjs.dispatchSelection(controller, selection);
|
|
4300
4304
|
}
|
|
4301
4305
|
store.set({ linkPopover: { open: true } });
|
|
4302
4306
|
};
|
|
@@ -4338,12 +4342,12 @@ function LinkHoverCard(props) {
|
|
|
4338
4342
|
|
|
4339
4343
|
// src/menus/link/apply-link.ts
|
|
4340
4344
|
function insertLinkedText(value, href, caret) {
|
|
4341
|
-
const safe =
|
|
4345
|
+
const safe = chunk6H76FAI3_cjs.sanitizeHref(href);
|
|
4342
4346
|
return (state, dispatch) => {
|
|
4343
4347
|
if (!safe) return false;
|
|
4344
4348
|
const link = { type: "link", attrs: { href: safe } };
|
|
4345
|
-
const marks =
|
|
4346
|
-
const tr = new
|
|
4349
|
+
const marks = chunk6H76FAI3_cjs.addMark(chunkM5FREXRQ_cjs.caretMarks(state.doc, state.schema, state.storedMarks, caret), link);
|
|
4350
|
+
const tr = new chunkM5FREXRQ_cjs.Transaction(state).step(chunkM5FREXRQ_cjs.replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [chunk6H76FAI3_cjs.text(value, marks)])).setSelection(chunkM5FREXRQ_cjs.textSelection({ ...caret, offset: caret.offset + value.length }));
|
|
4347
4351
|
dispatch?.(tr);
|
|
4348
4352
|
return true;
|
|
4349
4353
|
};
|
|
@@ -4352,10 +4356,10 @@ function applyLink(href, value) {
|
|
|
4352
4356
|
return (state, dispatch) => {
|
|
4353
4357
|
const { selection } = state;
|
|
4354
4358
|
const link = linkAtSelection(state);
|
|
4355
|
-
if (selection?.kind === "text" &&
|
|
4359
|
+
if (selection?.kind === "text" && chunkM5FREXRQ_cjs.isCollapsed(selection) && link === null) {
|
|
4356
4360
|
return insertLinkedText(value, href, selection.head)(state, dispatch);
|
|
4357
4361
|
}
|
|
4358
|
-
return
|
|
4362
|
+
return chunkM5FREXRQ_cjs.setLink(href, link?.title)(state, dispatch);
|
|
4359
4363
|
};
|
|
4360
4364
|
}
|
|
4361
4365
|
var CONTENT2 = "w-80 p-2 shadow-md";
|
|
@@ -4366,7 +4370,7 @@ function popoverAnchor(controller, link) {
|
|
|
4366
4370
|
if (selection?.kind !== "text") return null;
|
|
4367
4371
|
const { block, region, offset } = selection.head;
|
|
4368
4372
|
const caret = link?.range ?? { block, region, from: offset, to: offset };
|
|
4369
|
-
const collapsed =
|
|
4373
|
+
const collapsed = chunkM5FREXRQ_cjs.isCollapsed(selection);
|
|
4370
4374
|
return virtualAnchor(
|
|
4371
4375
|
() => collapsed ? rangeRect(controller, caret) : selectionRect(controller),
|
|
4372
4376
|
() => controller.registry.get(block, region)
|
|
@@ -4378,7 +4382,7 @@ function LinkPopover({ controller, labels, onClose }) {
|
|
|
4378
4382
|
const [invalid, setInvalid] = React7.useState(false);
|
|
4379
4383
|
const messageId = React7.useId();
|
|
4380
4384
|
const anchor = React7.useMemo(() => ({ current: popoverAnchor(controller, link) }), [controller, link]);
|
|
4381
|
-
const openHref = link &&
|
|
4385
|
+
const openHref = link && chunk6H76FAI3_cjs.sanitizeHref(link.href);
|
|
4382
4386
|
const backToText = () => {
|
|
4383
4387
|
onClose();
|
|
4384
4388
|
controller.focus();
|
|
@@ -4395,7 +4399,7 @@ function LinkPopover({ controller, labels, onClose }) {
|
|
|
4395
4399
|
backToText();
|
|
4396
4400
|
};
|
|
4397
4401
|
const remove = () => {
|
|
4398
|
-
controller.run(
|
|
4402
|
+
controller.run(chunkM5FREXRQ_cjs.unsetLink);
|
|
4399
4403
|
backToText();
|
|
4400
4404
|
};
|
|
4401
4405
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4463,7 +4467,7 @@ function LinkOverlay({ controller }) {
|
|
|
4463
4467
|
const labels = useLabels();
|
|
4464
4468
|
const store = useCanvasUiStore();
|
|
4465
4469
|
const popoverOpen = useCanvasUi(store, isPopoverOpen);
|
|
4466
|
-
const readOnly =
|
|
4470
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
4467
4471
|
useLinkClicks(controller);
|
|
4468
4472
|
React7.useEffect(() => {
|
|
4469
4473
|
if (readOnly && store.get().linkPopover.open) store.set({ linkPopover: { open: false } });
|
|
@@ -4478,7 +4482,7 @@ function linkExtension(store) {
|
|
|
4478
4482
|
if (dispatch) store.set({ linkPopover: { open: true } });
|
|
4479
4483
|
return true;
|
|
4480
4484
|
};
|
|
4481
|
-
return
|
|
4485
|
+
return chunkM5FREXRQ_cjs.defineExtension({ name: "link", keymap: { "Mod-k": openPopover }, ui: { overlays: [LinkOverlay] } });
|
|
4482
4486
|
}
|
|
4483
4487
|
|
|
4484
4488
|
// src/menus/suggestion/find-trigger.ts
|
|
@@ -4486,7 +4490,7 @@ var DEFAULT_MAX_LENGTH = 40;
|
|
|
4486
4490
|
var NO_TRIGGER_TYPES = /* @__PURE__ */ new Set(["CODE", "TABLE"]);
|
|
4487
4491
|
var WHITESPACE2 = /\s/;
|
|
4488
4492
|
var ATOM = "\uFFFC";
|
|
4489
|
-
var hasCode = (inline) => inline.some((node) =>
|
|
4493
|
+
var hasCode = (inline) => inline.some((node) => chunk6H76FAI3_cjs.hasMark(node.marks, "code"));
|
|
4490
4494
|
function triggerOffset(text2, start, config) {
|
|
4491
4495
|
const { char, allowSpaces = false, startOfLine = false } = config;
|
|
4492
4496
|
const earliest = Math.max(0, text2.length - (config.maxLength ?? DEFAULT_MAX_LENGTH) - 1);
|
|
@@ -4503,15 +4507,15 @@ function triggerOffset(text2, start, config) {
|
|
|
4503
4507
|
}
|
|
4504
4508
|
function findTrigger(state, config) {
|
|
4505
4509
|
const { doc, selection } = state;
|
|
4506
|
-
if (selection?.kind !== "text" || !
|
|
4510
|
+
if (selection?.kind !== "text" || !chunkM5FREXRQ_cjs.isCollapsed(selection)) return null;
|
|
4507
4511
|
const { block: blockId, region, offset: caret } = selection.head;
|
|
4508
|
-
const block =
|
|
4512
|
+
const block = chunk6H76FAI3_cjs.blockById(doc, blockId);
|
|
4509
4513
|
if (block === void 0 || NO_TRIGGER_TYPES.has(block.type) || !Object.hasOwn(block.regions, region)) return null;
|
|
4510
4514
|
const inline = block.regions[region];
|
|
4511
4515
|
const start = Math.max(0, caret - (config.maxLength ?? DEFAULT_MAX_LENGTH) - 2);
|
|
4512
|
-
const from = triggerOffset(
|
|
4513
|
-
if (from === null || hasCode(
|
|
4514
|
-
const query =
|
|
4516
|
+
const from = triggerOffset(chunk6H76FAI3_cjs.inlineText(chunk6H76FAI3_cjs.sliceInline(inline, start, caret)), start, config);
|
|
4517
|
+
if (from === null || hasCode(chunk6H76FAI3_cjs.sliceInline(inline, from, caret))) return null;
|
|
4518
|
+
const query = chunk6H76FAI3_cjs.inlineText(chunk6H76FAI3_cjs.sliceInline(inline, from + 1, caret));
|
|
4515
4519
|
return { block: blockId, region, from, to: caret, query };
|
|
4516
4520
|
}
|
|
4517
4521
|
|
|
@@ -4541,7 +4545,7 @@ function suggestionPlugin(key, config) {
|
|
|
4541
4545
|
init: (state) => ({ active: nearest(state, findTrigger(state, config)), dismissedAt: null }),
|
|
4542
4546
|
apply(tr, value, oldState, newState) {
|
|
4543
4547
|
const dismissing = tr.getMeta(DISMISS) === key.name;
|
|
4544
|
-
if (!dismissing && !tr.docChanged &&
|
|
4548
|
+
if (!dismissing && !tr.docChanged && chunkM5FREXRQ_cjs.sameSelection(oldState.selection, newState.selection)) return value;
|
|
4545
4549
|
const found = findTrigger(newState, config);
|
|
4546
4550
|
let dismissedAt = null;
|
|
4547
4551
|
if (dismissing) dismissedAt = found && rangeOf2(found);
|
|
@@ -4558,14 +4562,14 @@ function suggestionPlugin(key, config) {
|
|
|
4558
4562
|
}
|
|
4559
4563
|
function dismissSuggestion(key) {
|
|
4560
4564
|
return (state, dispatch) => {
|
|
4561
|
-
if (
|
|
4562
|
-
dispatch?.(new
|
|
4565
|
+
if (chunkM5FREXRQ_cjs.getPluginState(state, key).active === null) return false;
|
|
4566
|
+
dispatch?.(new chunkM5FREXRQ_cjs.Transaction(state).setMeta(DISMISS, key.name));
|
|
4563
4567
|
return true;
|
|
4564
4568
|
};
|
|
4565
4569
|
}
|
|
4566
4570
|
|
|
4567
4571
|
// src/menus/slash/slash-key.ts
|
|
4568
|
-
var slashKey =
|
|
4572
|
+
var slashKey = chunkM5FREXRQ_cjs.createPluginKey("slash");
|
|
4569
4573
|
var DETAILS = {
|
|
4570
4574
|
text: { group: "basic", keywords: ["paragraph", "plain"], shortcut: "Mod-Alt-0" },
|
|
4571
4575
|
heading1: { group: "basic", keywords: ["h1", "title", "#"], shortcut: "Mod-Alt-1" },
|
|
@@ -4613,7 +4617,7 @@ function initialBlock({ schema }, definition, onError) {
|
|
|
4613
4617
|
const data = chunkA6PGQVTR_cjs.seedData(definition, onError());
|
|
4614
4618
|
if (data === null) return null;
|
|
4615
4619
|
if (data === void 0) return { type };
|
|
4616
|
-
return { type, ...
|
|
4620
|
+
return { type, ...chunk6H76FAI3_cjs.specFor(schema, type).fromData(data, chunk6H76FAI3_cjs.createBlockCodec(schema).context) };
|
|
4617
4621
|
}
|
|
4618
4622
|
var refuse = () => false;
|
|
4619
4623
|
function blockTypeSlashItems(definitions, onError = () => void 0) {
|
|
@@ -4641,10 +4645,10 @@ function useRangeAnchor(controller, range) {
|
|
|
4641
4645
|
const [side, setSide] = React7.useState("bottom");
|
|
4642
4646
|
const latest = React7.useRef(range);
|
|
4643
4647
|
const start = range === null ? null : `${range.block} ${range.region} ${range.from}`;
|
|
4644
|
-
|
|
4648
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4645
4649
|
latest.current = range;
|
|
4646
4650
|
});
|
|
4647
|
-
|
|
4651
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4648
4652
|
const rect = latest.current && rangeRect(controller, latest.current);
|
|
4649
4653
|
if (rect) setSide(sideFor(rect, window.innerHeight));
|
|
4650
4654
|
}, [controller, start]);
|
|
@@ -4670,11 +4674,11 @@ function openCombobox(host, listboxId) {
|
|
|
4670
4674
|
}
|
|
4671
4675
|
function useComboboxHost(controller, block, region, listboxId, activeOptionId) {
|
|
4672
4676
|
const host = React7.useRef(null);
|
|
4673
|
-
|
|
4677
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4674
4678
|
host.current = block === null || region === null ? null : controller.registry.get(block, region) ?? null;
|
|
4675
4679
|
return host.current === null ? void 0 : openCombobox(host.current, listboxId);
|
|
4676
4680
|
}, [controller, block, region, listboxId]);
|
|
4677
|
-
|
|
4681
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4678
4682
|
if (host.current !== null) restore(host.current, "aria-activedescendant", activeOptionId);
|
|
4679
4683
|
}, [block, region, activeOptionId]);
|
|
4680
4684
|
}
|
|
@@ -4720,10 +4724,10 @@ function handle(event, menu) {
|
|
|
4720
4724
|
}
|
|
4721
4725
|
function useSuggestionKeys(controller, open, menu) {
|
|
4722
4726
|
const latest = React7.useRef(menu);
|
|
4723
|
-
|
|
4727
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4724
4728
|
latest.current = menu;
|
|
4725
4729
|
});
|
|
4726
|
-
|
|
4730
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4727
4731
|
if (!open) return;
|
|
4728
4732
|
const intercept = (event) => {
|
|
4729
4733
|
const handled = handle(event, latest.current);
|
|
@@ -4744,10 +4748,10 @@ var isPromise = (value) => typeof value?.then === "function";
|
|
|
4744
4748
|
function useSuggestionResults(source, query, onError) {
|
|
4745
4749
|
const [answer, setAnswer] = React7.useState(FORGOTTEN);
|
|
4746
4750
|
const report = React7.useRef(onError);
|
|
4747
|
-
|
|
4751
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4748
4752
|
report.current = onError;
|
|
4749
4753
|
});
|
|
4750
|
-
|
|
4754
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4751
4755
|
if (query === null) {
|
|
4752
4756
|
setAnswer(FORGOTTEN);
|
|
4753
4757
|
return;
|
|
@@ -4791,9 +4795,9 @@ function useSuggestion({
|
|
|
4791
4795
|
emptyLabel
|
|
4792
4796
|
}) {
|
|
4793
4797
|
const { labels, onError } = useQuoin();
|
|
4794
|
-
const readOnly =
|
|
4795
|
-
const selectTrigger = React7.useCallback((state) =>
|
|
4796
|
-
const active =
|
|
4798
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
4799
|
+
const selectTrigger = React7.useCallback((state) => chunkM5FREXRQ_cjs.getPluginState(state, pluginKey).active, [pluginKey]);
|
|
4800
|
+
const active = chunkVSUGJZ7G_cjs.useEditorState(controller, selectTrigger);
|
|
4797
4801
|
const trigger = readOnly ? null : active;
|
|
4798
4802
|
const results = useSuggestionResults(source, trigger?.query ?? null, onError);
|
|
4799
4803
|
const sections = React7.useMemo(() => groupItems(results.items, groupOf2), [results.items, groupOf2]);
|
|
@@ -4815,7 +4819,7 @@ function useSuggestion({
|
|
|
4815
4819
|
);
|
|
4816
4820
|
const select = React7.useCallback(
|
|
4817
4821
|
(index) => {
|
|
4818
|
-
const current =
|
|
4822
|
+
const current = chunkM5FREXRQ_cjs.getPluginState(controller.editor.state, pluginKey).active;
|
|
4819
4823
|
if (current !== null && index < ordered.length) onSelect(ordered[index], rangeOf2(current));
|
|
4820
4824
|
},
|
|
4821
4825
|
[controller, pluginKey, ordered, onSelect]
|
|
@@ -4863,7 +4867,7 @@ function SuggestionMenu(props) {
|
|
|
4863
4867
|
const { trigger, sections, activeIndex, listboxId } = suggestion;
|
|
4864
4868
|
const { anchor, side } = useRangeAnchor(controller, trigger);
|
|
4865
4869
|
const listbox = React7.useRef(null);
|
|
4866
|
-
|
|
4870
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
4867
4871
|
listbox.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
4868
4872
|
}, [activeIndex, sections]);
|
|
4869
4873
|
if (trigger === null) return null;
|
|
@@ -4922,14 +4926,14 @@ function SuggestionMenu(props) {
|
|
|
4922
4926
|
// src/menus/suggestion/replace-trigger.ts
|
|
4923
4927
|
function deleteTrigger({ block, region, from, to }) {
|
|
4924
4928
|
return (state, dispatch) => {
|
|
4925
|
-
const tr = new
|
|
4926
|
-
if (from >= to || !tr.maybeStep(
|
|
4927
|
-
dispatch?.(tr.setSelection(
|
|
4929
|
+
const tr = new chunkM5FREXRQ_cjs.Transaction(state);
|
|
4930
|
+
if (from >= to || !tr.maybeStep(chunkM5FREXRQ_cjs.replaceInlineStep(block, region, from, to, []))) return false;
|
|
4931
|
+
dispatch?.(tr.setSelection(chunkM5FREXRQ_cjs.textSelection({ block, region, offset: from })));
|
|
4928
4932
|
return true;
|
|
4929
4933
|
};
|
|
4930
4934
|
}
|
|
4931
4935
|
function triggerReplacement(state, range, command) {
|
|
4932
|
-
return
|
|
4936
|
+
return chunkM5FREXRQ_cjs.runCommands(state, command === void 0 ? [deleteTrigger(range)] : [deleteTrigger(range), command]);
|
|
4933
4937
|
}
|
|
4934
4938
|
function replaceTrigger(controller, range, command) {
|
|
4935
4939
|
const { ok, tr } = triggerReplacement(controller.editor.state, range, command);
|
|
@@ -4942,9 +4946,9 @@ var TEXT_STEPS = /* @__PURE__ */ new Set(["replaceInline", "addMark", "removeMar
|
|
|
4942
4946
|
var WHITESPACE3 = /\s/;
|
|
4943
4947
|
var changesBlocks = (tr) => tr !== null && tr.steps.some((step) => !TEXT_STEPS.has(step.stepType));
|
|
4944
4948
|
function withSpaceBefore(state, range) {
|
|
4945
|
-
const inline =
|
|
4949
|
+
const inline = chunkVSUGJZ7G_cjs.regionInline(state, range.block, range.region);
|
|
4946
4950
|
if (inline === void 0 || range.from === 0) return null;
|
|
4947
|
-
const text2 =
|
|
4951
|
+
const text2 = chunk6H76FAI3_cjs.inlineText(inline);
|
|
4948
4952
|
const after = text2.charAt(range.to);
|
|
4949
4953
|
const spaced = text2.charAt(range.from - 1) === " " && (after === "" || WHITESPACE3.test(after));
|
|
4950
4954
|
return spaced ? { ...range, from: range.from - 1 } : null;
|
|
@@ -5049,7 +5053,7 @@ function SlashOverlay({ controller }) {
|
|
|
5049
5053
|
return /* @__PURE__ */ jsxRuntime.jsx(SlashMenu, { controller, labels, items });
|
|
5050
5054
|
}
|
|
5051
5055
|
function slashExtension() {
|
|
5052
|
-
return
|
|
5056
|
+
return chunkM5FREXRQ_cjs.defineExtension({
|
|
5053
5057
|
name: "slash",
|
|
5054
5058
|
plugins: [suggestionPlugin(slashKey, { char: "/" })],
|
|
5055
5059
|
ui: { overlays: [SlashOverlay] }
|
|
@@ -5059,7 +5063,7 @@ function commandItem(id, title, icon, command) {
|
|
|
5059
5063
|
return { id, title, icon, run: (controller) => void controller.run(command) };
|
|
5060
5064
|
}
|
|
5061
5065
|
function addBlockAtCaret(controller) {
|
|
5062
|
-
const block =
|
|
5066
|
+
const block = chunkM5FREXRQ_cjs.headBlockId(controller.editor.state.selection);
|
|
5063
5067
|
if (block !== null) addBlockBelow(controller, block);
|
|
5064
5068
|
}
|
|
5065
5069
|
function mobileItems(labels, openLink) {
|
|
@@ -5071,10 +5075,10 @@ function mobileItems(labels, openLink) {
|
|
|
5071
5075
|
markItem("strike", labels.strike, lucideReact.Strikethrough),
|
|
5072
5076
|
markItem("code", labels.code, lucideReact.Code),
|
|
5073
5077
|
linkItem(labels, openLink),
|
|
5074
|
-
commandItem("indent", labels.indent, lucideReact.ListIndentIncrease,
|
|
5075
|
-
commandItem("outdent", labels.outdent, lucideReact.ListIndentDecrease,
|
|
5076
|
-
commandItem("undo", labels.undo, lucideReact.Undo2,
|
|
5077
|
-
commandItem("redo", labels.redo, lucideReact.Redo2,
|
|
5078
|
+
commandItem("indent", labels.indent, lucideReact.ListIndentIncrease, chunkM5FREXRQ_cjs.indent),
|
|
5079
|
+
commandItem("outdent", labels.outdent, lucideReact.ListIndentDecrease, chunkM5FREXRQ_cjs.outdent),
|
|
5080
|
+
commandItem("undo", labels.undo, lucideReact.Undo2, chunkM5FREXRQ_cjs.undo),
|
|
5081
|
+
commandItem("redo", labels.redo, lucideReact.Redo2, chunkM5FREXRQ_cjs.redo)
|
|
5078
5082
|
]
|
|
5079
5083
|
};
|
|
5080
5084
|
}
|
|
@@ -5128,7 +5132,7 @@ function placement(viewport) {
|
|
|
5128
5132
|
function EditingTools({ controller }) {
|
|
5129
5133
|
const labels = useLabels();
|
|
5130
5134
|
const store = useCanvasUiStore();
|
|
5131
|
-
const state =
|
|
5135
|
+
const state = chunkVSUGJZ7G_cjs.useEditorState(controller, chunkVSUGJZ7G_cjs.wholeState);
|
|
5132
5136
|
const viewport = useVisualViewport();
|
|
5133
5137
|
const roving = useRovingFocus();
|
|
5134
5138
|
const items = React7.useMemo(() => mobileItems(labels, () => store.set({ linkPopover: { open: true } })), [labels, store]);
|
|
@@ -5385,7 +5389,7 @@ function shortcutsExtension(store) {
|
|
|
5385
5389
|
if (dispatch) store.set({ shortcutsOpen: true });
|
|
5386
5390
|
return true;
|
|
5387
5391
|
};
|
|
5388
|
-
return
|
|
5392
|
+
return chunkM5FREXRQ_cjs.defineExtension({
|
|
5389
5393
|
name: "shortcuts",
|
|
5390
5394
|
keymap: { [SHORTCUT]: open, "Mod-Shift-?": open },
|
|
5391
5395
|
ui: { overlays: [ShortcutsOverlay] }
|
|
@@ -5419,22 +5423,40 @@ function writeBlockData(controller, blockId, data) {
|
|
|
5419
5423
|
const index = doc.index.get(blockId);
|
|
5420
5424
|
if (index === void 0) return;
|
|
5421
5425
|
const block = doc.blocks[index];
|
|
5422
|
-
const { attrs, regions } =
|
|
5423
|
-
if (
|
|
5424
|
-
const tr = editor.createTransaction().step(
|
|
5425
|
-
editor.dispatch(tr.setMeta(
|
|
5426
|
+
const { attrs, regions } = chunk6H76FAI3_cjs.specFor(schema, block.type).fromData(data, editor.codec.context);
|
|
5427
|
+
if (chunk6H76FAI3_cjs.sameValue(attrs, block.attrs) && chunk6H76FAI3_cjs.sameValue(regions, block.regions)) return;
|
|
5428
|
+
const tr = editor.createTransaction().step(chunkM5FREXRQ_cjs.replaceBlockStep({ ...block, attrs, regions }));
|
|
5429
|
+
editor.dispatch(tr.setMeta(chunkM5FREXRQ_cjs.HISTORY_GROUP, `block-data:${blockId}`));
|
|
5426
5430
|
}
|
|
5427
5431
|
function insertAfterBlock(controller, blockId, type, definitions, onError) {
|
|
5428
5432
|
const editor = internal(controller);
|
|
5429
5433
|
const data = chunkA6PGQVTR_cjs.seedData(chunkA6PGQVTR_cjs.blockByType(definitions, type), onError);
|
|
5430
5434
|
if (data === null) return false;
|
|
5431
|
-
const content = data &&
|
|
5435
|
+
const content = data && chunk6H76FAI3_cjs.specFor(editor.state.schema, type).fromData(data, editor.codec.context);
|
|
5432
5436
|
controller.run(insertBlockToWrite({ type, ...content }, opensEditor(definitions, type), blockId));
|
|
5433
5437
|
return true;
|
|
5434
5438
|
}
|
|
5439
|
+
|
|
5440
|
+
// src/blocks/void/history-keys.ts
|
|
5441
|
+
var NOT_TEXT_INPUTS = /* @__PURE__ */ new Set(["button", "checkbox", "color", "file", "image", "radio", "range", "reset", "submit"]);
|
|
5442
|
+
function isTextField(element) {
|
|
5443
|
+
if (element instanceof HTMLInputElement) return !NOT_TEXT_INPUTS.has(element.type);
|
|
5444
|
+
if (element instanceof HTMLTextAreaElement) return true;
|
|
5445
|
+
const editable = element.closest("[contenteditable]");
|
|
5446
|
+
return editable !== null && editable.getAttribute("contenteditable") !== "false";
|
|
5447
|
+
}
|
|
5448
|
+
function isHistoryKey(controller, event) {
|
|
5449
|
+
const mod = controller.isMac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
|
|
5450
|
+
const key = event.key.toLowerCase();
|
|
5451
|
+
return mod && !event.altKey && (key === "z" || key === "y" && !event.shiftKey);
|
|
5452
|
+
}
|
|
5453
|
+
function runHistoryKey(controller, event) {
|
|
5454
|
+
if (!isHistoryKey(controller, event) || isTextField(event.target)) return false;
|
|
5455
|
+
return controller.edit(() => controller.editor.handleKey(event.nativeEvent));
|
|
5456
|
+
}
|
|
5435
5457
|
function useBlockIndex(controller, blockId) {
|
|
5436
5458
|
const select = React7.useCallback((state) => state.doc.index.get(blockId) ?? -1, [blockId]);
|
|
5437
|
-
return
|
|
5459
|
+
return chunkVSUGJZ7G_cjs.useEditorState(controller, select);
|
|
5438
5460
|
}
|
|
5439
5461
|
var FOCUSABLE = [
|
|
5440
5462
|
"input:not([disabled])",
|
|
@@ -5461,8 +5483,8 @@ function useEditingFocus(root, editing, stop) {
|
|
|
5461
5483
|
const leaveUnlessInside = (event) => {
|
|
5462
5484
|
if (!inside.current.has(event)) stop();
|
|
5463
5485
|
};
|
|
5464
|
-
const unlistenCapture =
|
|
5465
|
-
const unlisten =
|
|
5486
|
+
const unlistenCapture = chunkVSUGJZ7G_cjs.listen(doc, { pointerdown: leaveForCanvas }, true);
|
|
5487
|
+
const unlisten = chunkVSUGJZ7G_cjs.listen(doc, { pointerdown: leaveUnlessInside, focusin: leaveUnlessInside });
|
|
5466
5488
|
return () => {
|
|
5467
5489
|
unlistenCapture();
|
|
5468
5490
|
unlisten();
|
|
@@ -5485,16 +5507,19 @@ function VoidPreview({ definition: { preview: Preview }, name, ...props }) {
|
|
|
5485
5507
|
if (Preview === void 0) return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-1 text-sm text-muted-foreground", children: name });
|
|
5486
5508
|
return /* @__PURE__ */ jsxRuntime.jsx(Preview, { ...props });
|
|
5487
5509
|
}
|
|
5510
|
+
function VoidEditor({ Editor, controller, ...props }) {
|
|
5511
|
+
const index = useBlockIndex(controller, props.blockId);
|
|
5512
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Editor, { ...props, index });
|
|
5513
|
+
}
|
|
5488
5514
|
function VoidBlock({ block, controller, definition }) {
|
|
5489
5515
|
const { blockTypes, labels } = useQuoin();
|
|
5490
|
-
const { report } = React7.useContext(
|
|
5491
|
-
const readOnly =
|
|
5516
|
+
const { report } = React7.useContext(chunkVSUGJZ7G_cjs.BlockErrorContext);
|
|
5517
|
+
const readOnly = chunkVSUGJZ7G_cjs.useReadOnly(controller);
|
|
5492
5518
|
const { editor: Editor, alwaysEditing = false } = definition;
|
|
5493
5519
|
const name = blockTypeLabel(labels, block, blockTypes);
|
|
5494
5520
|
const blockId = block.id;
|
|
5495
5521
|
const editable = Editor !== void 0 && !readOnly;
|
|
5496
5522
|
const { editing, start, stop } = useVoidEditing(controller, blockId, editable);
|
|
5497
|
-
const index = useBlockIndex(controller, blockId);
|
|
5498
5523
|
const root = React7.useRef(null);
|
|
5499
5524
|
const focusHandlers = useEditingFocus(root, editing, stop);
|
|
5500
5525
|
useMissingPreviewWarning(readOnly, definition);
|
|
@@ -5530,6 +5555,10 @@ function VoidBlock({ block, controller, definition }) {
|
|
|
5530
5555
|
const editorShown = editable && (alwaysEditing || editing);
|
|
5531
5556
|
const data = React7.useMemo(() => chunkA6PGQVTR_cjs.parsedData(definition, readBlockData(controller, block)), [definition, controller, block]);
|
|
5532
5557
|
const onKeyDown = (event) => {
|
|
5558
|
+
if (!editorShown && !readOnly && isInteractive(root.current, event) && runHistoryKey(controller, event)) {
|
|
5559
|
+
event.preventDefault();
|
|
5560
|
+
return;
|
|
5561
|
+
}
|
|
5533
5562
|
if (event.key !== "Escape" || !editorShown || !root.current?.contains(event.target)) return;
|
|
5534
5563
|
event.preventDefault();
|
|
5535
5564
|
leave();
|
|
@@ -5549,19 +5578,20 @@ function VoidBlock({ block, controller, definition }) {
|
|
|
5549
5578
|
role: "group",
|
|
5550
5579
|
"aria-label": name,
|
|
5551
5580
|
tabIndex: editorShown ? -1 : void 0,
|
|
5552
|
-
...{ [
|
|
5581
|
+
...{ [chunkVSUGJZ7G_cjs.NATIVE_INTERACTION]: editorShown ? "" : void 0 },
|
|
5553
5582
|
onKeyDown,
|
|
5554
5583
|
...focusHandlers,
|
|
5555
5584
|
onClick,
|
|
5556
5585
|
onDoubleClick,
|
|
5557
5586
|
children: [
|
|
5558
5587
|
editorShown && Editor ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5559
|
-
|
|
5588
|
+
VoidEditor,
|
|
5560
5589
|
{
|
|
5590
|
+
Editor,
|
|
5591
|
+
controller,
|
|
5561
5592
|
data,
|
|
5562
5593
|
onChange,
|
|
5563
5594
|
blockId,
|
|
5564
|
-
index,
|
|
5565
5595
|
onRemove,
|
|
5566
5596
|
onInsertBlock,
|
|
5567
5597
|
onDone: leave
|
|
@@ -5644,12 +5674,12 @@ function collectUi(extensions, definitions, readOnly = false, onError) {
|
|
|
5644
5674
|
|
|
5645
5675
|
// src/canvas/insert-uploads.ts
|
|
5646
5676
|
function fileBlock(file, stored) {
|
|
5647
|
-
if (isImageFile(file)) return { id:
|
|
5677
|
+
if (isImageFile(file)) return { id: chunk6H76FAI3_cjs.newId(), type: "IMAGE", attrs: { storageKey: stored.storageKey, alt: "" } };
|
|
5648
5678
|
return { type: "FILE", attrs: fileAttrs(file, stored) };
|
|
5649
5679
|
}
|
|
5650
5680
|
function anchorBlock(controller, at) {
|
|
5651
5681
|
const { doc, selection } = controller.editor.state;
|
|
5652
|
-
const candidates = [at?.block,
|
|
5682
|
+
const candidates = [at?.block, chunkM5FREXRQ_cjs.headBlockId(selection), doc.blocks[doc.blocks.length - 1]?.id];
|
|
5653
5683
|
return candidates.find((id) => typeof id === "string" && doc.index.has(id)) ?? null;
|
|
5654
5684
|
}
|
|
5655
5685
|
var writerOf = (controller) => ({
|
|
@@ -5658,7 +5688,7 @@ var writerOf = (controller) => ({
|
|
|
5658
5688
|
});
|
|
5659
5689
|
function movedOn(controller, before) {
|
|
5660
5690
|
const now = writerOf(controller);
|
|
5661
|
-
return now.focus !== before.focus || !
|
|
5691
|
+
return now.focus !== before.focus || !chunkM5FREXRQ_cjs.sameSelection(now.selection, before.selection);
|
|
5662
5692
|
}
|
|
5663
5693
|
async function insertUploads(controller, files, at, { upload, resolveAssetUrl, onError, unavailable, failed }) {
|
|
5664
5694
|
if (!upload) return onError(new Error(unavailable));
|
|
@@ -5686,15 +5716,15 @@ function holdsHead({ selection }, block) {
|
|
|
5686
5716
|
}
|
|
5687
5717
|
function markdownPlaceholder(state, block, labels) {
|
|
5688
5718
|
const { kind, level } = block.attrs;
|
|
5689
|
-
if (kind === "heading") return labels.placeholderHeading(
|
|
5719
|
+
if (kind === "heading") return labels.placeholderHeading(chunk6H76FAI3_cjs.headingLevel(level));
|
|
5690
5720
|
if (LIST_KINDS.has(kind)) return labels.placeholderList;
|
|
5691
5721
|
if (kind === "quote") return labels.placeholderQuote;
|
|
5692
5722
|
if (kind !== "paragraph") return void 0;
|
|
5693
5723
|
return holdsHead(state, block) || state.doc.blocks.length === 1 ? labels.placeholderEmpty : void 0;
|
|
5694
5724
|
}
|
|
5695
5725
|
function placeholderFor(state, block, labels) {
|
|
5696
|
-
const region =
|
|
5697
|
-
if (region === null ||
|
|
5726
|
+
const region = chunkM5FREXRQ_cjs.primaryRegion(state.schema, block);
|
|
5727
|
+
if (region === null || chunkM5FREXRQ_cjs.regionLength(block, region) > 0) return void 0;
|
|
5698
5728
|
switch (block.type) {
|
|
5699
5729
|
case "MARKDOWN":
|
|
5700
5730
|
return markdownPlaceholder(state, block, labels);
|
|
@@ -5715,13 +5745,13 @@ function firstLine2(text2) {
|
|
|
5715
5745
|
}
|
|
5716
5746
|
var selectedBlockLabel = (labels, definitions, extensionNames) => (block, schema) => {
|
|
5717
5747
|
const { attrs } = block;
|
|
5718
|
-
if (block.type === "IMAGE") return hasPicture(attrs) ?
|
|
5748
|
+
if (block.type === "IMAGE") return hasPicture(attrs) ? chunk6H76FAI3_cjs.str(attrs.alt) || labels.imageNoAlt : labels.emptyImage;
|
|
5719
5749
|
if (block.type === "CODE") {
|
|
5720
|
-
const language2 =
|
|
5750
|
+
const language2 = chunk6H76FAI3_cjs.str(attrs.language);
|
|
5721
5751
|
return labels.codeBlockName(languageName(language2) ?? (language2 || labels.plainText));
|
|
5722
5752
|
}
|
|
5723
5753
|
if (block.type === "FILE" && hasFile(attrs)) return labels.fileBlockName(firstLine2(fileName(attrs)));
|
|
5724
|
-
return firstLine2(
|
|
5754
|
+
return firstLine2(chunk6H76FAI3_cjs.blockPlainText(block, schema)) || blockTypeLabel(labels, block, definitions, extensionNames);
|
|
5725
5755
|
};
|
|
5726
5756
|
function revealLinkedBlock(controller, hash) {
|
|
5727
5757
|
const id = linkedBlockId(hash);
|
|
@@ -5729,7 +5759,7 @@ function revealLinkedBlock(controller, hash) {
|
|
|
5729
5759
|
if (id === null || shell === void 0) return false;
|
|
5730
5760
|
const { editor } = controller;
|
|
5731
5761
|
const { doc, schema } = editor.state;
|
|
5732
|
-
editor.dispatch(editor.createTransaction().setSelection(
|
|
5762
|
+
editor.dispatch(editor.createTransaction().setSelection(chunkM5FREXRQ_cjs.startOf(doc, schema, id)));
|
|
5733
5763
|
shell.scrollIntoView({ block: "center" });
|
|
5734
5764
|
return true;
|
|
5735
5765
|
}
|
|
@@ -5746,8 +5776,8 @@ function useBlockLinkTarget(controller, focusOnMount) {
|
|
|
5746
5776
|
}, [controller, focusOnMount]);
|
|
5747
5777
|
}
|
|
5748
5778
|
var WRITER_ORIGINS = /* @__PURE__ */ new Set(["command", "input", "paste"]);
|
|
5749
|
-
var isBlockDeletion = (tr) => WRITER_ORIGINS.has(tr.origin) && tr.getMeta(
|
|
5750
|
-
var isEmptyText = (schema, block) =>
|
|
5779
|
+
var isBlockDeletion = (tr) => WRITER_ORIGINS.has(tr.origin) && tr.getMeta(chunkM5FREXRQ_cjs.LINE_JOIN) !== true;
|
|
5780
|
+
var isEmptyText = (schema, block) => chunkM5FREXRQ_cjs.isTextFlow(schema, block) && chunkM5FREXRQ_cjs.regionLength(block, chunkM5FREXRQ_cjs.primaryRegion(schema, block) ?? "") === 0;
|
|
5751
5781
|
function filledLine({ origin, before }, schema) {
|
|
5752
5782
|
const { selection } = before;
|
|
5753
5783
|
if (origin !== "paste" || selection?.kind !== "text") return () => false;
|
|
@@ -5761,13 +5791,13 @@ function deletions(codec, tr) {
|
|
|
5761
5791
|
const { index, count } = step.toJSON();
|
|
5762
5792
|
if (typeof index !== "number" || typeof count !== "number") return [];
|
|
5763
5793
|
const { blocks } = tr.docs[i];
|
|
5764
|
-
const first = codec.blocksFromDoc(
|
|
5794
|
+
const first = codec.blocksFromDoc(chunk6H76FAI3_cjs.createDoc(blocks.slice(0, index))).length;
|
|
5765
5795
|
return blocks.slice(index, index + count).flatMap((block, offset) => filled(block) ? [] : [{ block: codec.toQuoin(block), index: first + offset }]);
|
|
5766
5796
|
});
|
|
5767
5797
|
}
|
|
5768
5798
|
function useDeleteReporter(controller, onDelete) {
|
|
5769
5799
|
const latest = React7.useRef(onDelete);
|
|
5770
|
-
|
|
5800
|
+
chunkVSUGJZ7G_cjs.useIsomorphicLayoutEffect(() => {
|
|
5771
5801
|
latest.current = onDelete;
|
|
5772
5802
|
});
|
|
5773
5803
|
React7.useEffect(() => {
|
|
@@ -5821,7 +5851,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5821
5851
|
const [voidEditing] = React7.useState(createVoidEditing);
|
|
5822
5852
|
const [uiStore] = React7.useState(createCanvasUiStore);
|
|
5823
5853
|
const [allExtensions] = React7.useState(() => [
|
|
5824
|
-
...
|
|
5854
|
+
...chunkM5FREXRQ_cjs.coreExtensions(),
|
|
5825
5855
|
voidEditing.extension,
|
|
5826
5856
|
blockMenuKeymap(uiStore),
|
|
5827
5857
|
slashExtension(),
|
|
@@ -5839,7 +5869,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5839
5869
|
);
|
|
5840
5870
|
useTypedInPlaceWarning(blockTypes, readOnly);
|
|
5841
5871
|
const [focusOnMount] = React7.useState(autoFocus);
|
|
5842
|
-
const controller =
|
|
5872
|
+
const controller = chunkVSUGJZ7G_cjs.useQuoinEditor({
|
|
5843
5873
|
blocks,
|
|
5844
5874
|
onChange,
|
|
5845
5875
|
readOnly,
|
|
@@ -5883,7 +5913,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5883
5913
|
[controller, resolveAssetUrl]
|
|
5884
5914
|
);
|
|
5885
5915
|
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
|
-
|
|
5916
|
+
chunkVSUGJZ7G_cjs.EditorView,
|
|
5887
5917
|
{
|
|
5888
5918
|
controller,
|
|
5889
5919
|
renderers: ui.renderers,
|
|
@@ -6077,7 +6107,7 @@ function useAutosave({
|
|
|
6077
6107
|
const seen = seenRef.current;
|
|
6078
6108
|
seenRef.current = deps;
|
|
6079
6109
|
if (seen === null) return;
|
|
6080
|
-
const unchanged =
|
|
6110
|
+
const unchanged = chunk6H76FAI3_cjs.sameItems(seen, deps);
|
|
6081
6111
|
if (!unchanged) runner.markDirty();
|
|
6082
6112
|
}, deps);
|
|
6083
6113
|
React7__namespace.useEffect(() => {
|
|
@@ -6161,5 +6191,5 @@ exports.useQuoin = useQuoin;
|
|
|
6161
6191
|
exports.useRangeAnchor = useRangeAnchor;
|
|
6162
6192
|
exports.useRovingFocus = useRovingFocus;
|
|
6163
6193
|
exports.virtualAnchor = virtualAnchor;
|
|
6164
|
-
//# sourceMappingURL=chunk-
|
|
6165
|
-
//# sourceMappingURL=chunk-
|
|
6194
|
+
//# sourceMappingURL=chunk-ABVSP2XR.cjs.map
|
|
6195
|
+
//# sourceMappingURL=chunk-ABVSP2XR.cjs.map
|