quoin-editor 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/ai.cjs +78 -78
- package/dist/ai.js +6 -6
- package/dist/catalogue.cjs +24 -24
- package/dist/catalogue.js +16 -16
- package/dist/{chunk-DYWU4SQ2.js → chunk-3BCP6ZUM.js} +5 -6
- package/dist/chunk-3BCP6ZUM.js.map +1 -0
- package/dist/{chunk-L4D23LM2.js → chunk-4EU4BTLZ.js} +82 -34
- package/dist/chunk-4EU4BTLZ.js.map +1 -0
- package/dist/{chunk-VFSVN5IQ.cjs → chunk-4F2IWBFM.cjs} +294 -244
- package/dist/chunk-4F2IWBFM.cjs.map +1 -0
- package/dist/{chunk-HQ43EIYO.cjs → chunk-4T4TJ2QS.cjs} +9 -9
- package/dist/{chunk-HQ43EIYO.cjs.map → chunk-4T4TJ2QS.cjs.map} +1 -1
- package/dist/{chunk-7XQGOCUG.cjs → chunk-6X5A4DUQ.cjs} +290 -291
- package/dist/chunk-6X5A4DUQ.cjs.map +1 -0
- package/dist/{chunk-7FAVFJAS.js → chunk-AD3NY7NA.js} +3 -3
- package/dist/{chunk-7FAVFJAS.js.map → chunk-AD3NY7NA.js.map} +1 -1
- package/dist/{chunk-L6OW2FL3.js → chunk-BJTOLCRR.js} +84 -10
- package/dist/chunk-BJTOLCRR.js.map +1 -0
- package/dist/{chunk-HTLWPSMU.js → chunk-BKEHG4QV.js} +4 -4
- package/dist/{chunk-HTLWPSMU.js.map → chunk-BKEHG4QV.js.map} +1 -1
- package/dist/{chunk-7SVKLWDT.cjs → chunk-BM2GRZNM.cjs} +47 -43
- package/dist/chunk-BM2GRZNM.cjs.map +1 -0
- package/dist/{chunk-2EQ6FKSK.js → chunk-BXSWZEA5.js} +3 -3
- package/dist/{chunk-2EQ6FKSK.js.map → chunk-BXSWZEA5.js.map} +1 -1
- package/dist/{chunk-3BXUGX5F.js → chunk-CSKKSXCE.js} +38 -31
- package/dist/chunk-CSKKSXCE.js.map +1 -0
- package/dist/{chunk-U5BSCAMP.cjs → chunk-EQKFQK3C.cjs} +13 -13
- package/dist/{chunk-U5BSCAMP.cjs.map → chunk-EQKFQK3C.cjs.map} +1 -1
- package/dist/{chunk-TYZSB7JT.js → chunk-GHNQKJMD.js} +3 -3
- package/dist/{chunk-TYZSB7JT.js.map → chunk-GHNQKJMD.js.map} +1 -1
- package/dist/{chunk-RIIXJWBR.cjs → chunk-H3C3MJW5.cjs} +4 -4
- package/dist/{chunk-RIIXJWBR.cjs.map → chunk-H3C3MJW5.cjs.map} +1 -1
- package/dist/{chunk-UEVR4B5S.js → chunk-I4CSCA3O.js} +6 -6
- package/dist/{chunk-UEVR4B5S.js.map → chunk-I4CSCA3O.js.map} +1 -1
- package/dist/{chunk-SFMORPWB.js → chunk-I4NEX6SZ.js} +7 -7
- package/dist/{chunk-SFMORPWB.js.map → chunk-I4NEX6SZ.js.map} +1 -1
- package/dist/{chunk-L2QA2UTY.js → chunk-IHTHOAUY.js} +7 -7
- package/dist/{chunk-L2QA2UTY.js.map → chunk-IHTHOAUY.js.map} +1 -1
- package/dist/{chunk-KXRGY5LK.cjs → chunk-IQ2DE3Y3.cjs} +90 -90
- package/dist/{chunk-KXRGY5LK.cjs.map → chunk-IQ2DE3Y3.cjs.map} +1 -1
- package/dist/{chunk-W7B4WQ3L.cjs → chunk-K7E2DR5W.cjs} +24 -24
- package/dist/{chunk-W7B4WQ3L.cjs.map → chunk-K7E2DR5W.cjs.map} +1 -1
- package/dist/{chunk-QSXPKZ2F.js → chunk-KIU5MPZ4.js} +3 -3
- package/dist/{chunk-QSXPKZ2F.js.map → chunk-KIU5MPZ4.js.map} +1 -1
- package/dist/{chunk-MUIPM26J.js → chunk-MEXDDWJF.js} +6 -6
- package/dist/{chunk-MUIPM26J.js.map → chunk-MEXDDWJF.js.map} +1 -1
- package/dist/{chunk-IGZRZIAF.cjs → chunk-NNDLIP2C.cjs} +161 -136
- package/dist/chunk-NNDLIP2C.cjs.map +1 -0
- package/dist/{chunk-CKHKCPGL.js → chunk-OWX3Y5UU.js} +6 -6
- package/dist/{chunk-CKHKCPGL.js.map → chunk-OWX3Y5UU.js.map} +1 -1
- package/dist/{chunk-WAGBELKA.js → chunk-PMJ3VCSR.js} +5 -5
- package/dist/{chunk-WAGBELKA.js.map → chunk-PMJ3VCSR.js.map} +1 -1
- package/dist/{chunk-IEP7BPFN.js → chunk-PVCXTSUO.js} +49 -24
- package/dist/chunk-PVCXTSUO.js.map +1 -0
- package/dist/{chunk-7NAONESM.cjs → chunk-R45RJQRD.cjs} +31 -31
- package/dist/{chunk-7NAONESM.cjs.map → chunk-R45RJQRD.cjs.map} +1 -1
- package/dist/{chunk-VNRI5DAL.cjs → chunk-RENKFSFD.cjs} +28 -28
- package/dist/{chunk-VNRI5DAL.cjs.map → chunk-RENKFSFD.cjs.map} +1 -1
- package/dist/{chunk-KZ6ZFCGO.js → chunk-TG5T7BEJ.js} +8 -8
- package/dist/{chunk-KZ6ZFCGO.js.map → chunk-TG5T7BEJ.js.map} +1 -1
- package/dist/{chunk-WH56EW3H.cjs → chunk-TLMO46OV.cjs} +15 -15
- package/dist/{chunk-WH56EW3H.cjs.map → chunk-TLMO46OV.cjs.map} +1 -1
- package/dist/{chunk-XAS7LANM.cjs → chunk-TN32PKUI.cjs} +98 -98
- package/dist/{chunk-XAS7LANM.cjs.map → chunk-TN32PKUI.cjs.map} +1 -1
- package/dist/{chunk-JCEFSTVG.cjs → chunk-TWFMNDOC.cjs} +55 -55
- package/dist/{chunk-JCEFSTVG.cjs.map → chunk-TWFMNDOC.cjs.map} +1 -1
- package/dist/{chunk-OKWER2RV.cjs → chunk-UHAAYYMX.cjs} +45 -45
- package/dist/{chunk-OKWER2RV.cjs.map → chunk-UHAAYYMX.cjs.map} +1 -1
- package/dist/{chunk-EFRQMYZ6.cjs → chunk-UMTKQVOX.cjs} +4 -4
- package/dist/{chunk-EFRQMYZ6.cjs.map → chunk-UMTKQVOX.cjs.map} +1 -1
- package/dist/{chunk-OM7E43ZN.cjs → chunk-VNRBCUBV.cjs} +15 -15
- package/dist/{chunk-OM7E43ZN.cjs.map → chunk-VNRBCUBV.cjs.map} +1 -1
- package/dist/{chunk-RFLFRIPV.js → chunk-WCAUPASG.js} +6 -6
- package/dist/{chunk-RFLFRIPV.js.map → chunk-WCAUPASG.js.map} +1 -1
- package/dist/{chunk-AIS37SL2.cjs → chunk-WZA5S5EJ.cjs} +84 -9
- package/dist/chunk-WZA5S5EJ.cjs.map +1 -0
- package/dist/{chunk-VBJY2CSK.js → chunk-X4FDLUXJ.js} +6 -6
- package/dist/{chunk-VBJY2CSK.js.map → chunk-X4FDLUXJ.js.map} +1 -1
- package/dist/{chunk-3QRVAI53.cjs → chunk-XZ4NC3Q7.cjs} +6 -6
- package/dist/{chunk-3QRVAI53.cjs.map → chunk-XZ4NC3Q7.cjs.map} +1 -1
- package/dist/comments.cjs +58 -58
- package/dist/comments.js +7 -7
- package/dist/diff.cjs +29 -32
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.js +8 -11
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed.cjs +9 -9
- package/dist/embed.js +7 -7
- package/dist/emoji.cjs +9 -9
- package/dist/emoji.js +6 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +4 -1
- package/dist/engine.d.ts +4 -1
- package/dist/engine.js +3 -3
- package/dist/find.cjs +10 -10
- package/dist/find.js +6 -6
- package/dist/headless.cjs +74 -74
- package/dist/headless.js +4 -4
- package/dist/index.cjs +86 -86
- package/dist/index.js +5 -5
- package/dist/math.cjs +10 -10
- package/dist/math.js +8 -8
- package/dist/mention.cjs +10 -10
- package/dist/mention.js +8 -8
- package/dist/presence.cjs +38 -38
- package/dist/presence.js +7 -7
- package/dist/stats.cjs +10 -10
- package/dist/stats.js +7 -7
- package/dist/table.cjs +25 -25
- package/dist/table.js +6 -6
- package/dist/toc.cjs +9 -9
- package/dist/toc.js +6 -6
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +125 -120
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +11 -6
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3BXUGX5F.js.map +0 -1
- package/dist/chunk-7SVKLWDT.cjs.map +0 -1
- package/dist/chunk-7XQGOCUG.cjs.map +0 -1
- package/dist/chunk-AIS37SL2.cjs.map +0 -1
- package/dist/chunk-DYWU4SQ2.js.map +0 -1
- package/dist/chunk-IEP7BPFN.js.map +0 -1
- package/dist/chunk-IGZRZIAF.cjs.map +0 -1
- package/dist/chunk-L4D23LM2.js.map +0 -1
- package/dist/chunk-L6OW2FL3.js.map +0 -1
- package/dist/chunk-VFSVN5IQ.cjs.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNNDLIP2C_cjs = require('./chunk-NNDLIP2C.cjs');
|
|
4
4
|
var chunkA6PGQVTR_cjs = require('./chunk-A6PGQVTR.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
|
|
5
|
+
var chunk4F2IWBFM_cjs = require('./chunk-4F2IWBFM.cjs');
|
|
6
|
+
var chunkWZA5S5EJ_cjs = require('./chunk-WZA5S5EJ.cjs');
|
|
8
7
|
var React7 = require('react');
|
|
9
8
|
var lucideReact = require('lucide-react');
|
|
10
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -290,7 +289,7 @@ function useLabels() {
|
|
|
290
289
|
}
|
|
291
290
|
|
|
292
291
|
// src/blocks/caption-markdown.ts
|
|
293
|
-
var captionText = (markdown) =>
|
|
292
|
+
var captionText = (markdown) => chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.parseInline(markdown), () => "");
|
|
294
293
|
function Token({ text: text2, color, className }) {
|
|
295
294
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: chunkA6PGQVTR_cjs.tokenColour(color) }, className, children: text2 });
|
|
296
295
|
}
|
|
@@ -311,17 +310,17 @@ function assetHref(resolveAssetUrl, storageKey) {
|
|
|
311
310
|
if (storageKey === "") return null;
|
|
312
311
|
try {
|
|
313
312
|
const src = resolveAssetUrl(storageKey);
|
|
314
|
-
return typeof src === "string" &&
|
|
313
|
+
return typeof src === "string" && chunkWZA5S5EJ_cjs.sanitizeAssetUrl(src) || null;
|
|
315
314
|
} catch {
|
|
316
315
|
return null;
|
|
317
316
|
}
|
|
318
317
|
}
|
|
319
318
|
|
|
320
319
|
// src/blocks/image/image-source.ts
|
|
321
|
-
var hasPicture = (attrs) =>
|
|
320
|
+
var hasPicture = (attrs) => chunkWZA5S5EJ_cjs.str(attrs.url) !== "" || chunkWZA5S5EJ_cjs.str(attrs.storageKey) !== "";
|
|
322
321
|
function imageSource(attrs, resolveAssetUrl) {
|
|
323
|
-
const url =
|
|
324
|
-
return url === "" ? assetHref(resolveAssetUrl,
|
|
322
|
+
const url = chunkWZA5S5EJ_cjs.str(attrs.url);
|
|
323
|
+
return url === "" ? assetHref(resolveAssetUrl, chunkWZA5S5EJ_cjs.str(attrs.storageKey)) : chunkWZA5S5EJ_cjs.sanitizeHref(url);
|
|
325
324
|
}
|
|
326
325
|
var HINT = "text-sm text-muted-foreground";
|
|
327
326
|
var TONE = {
|
|
@@ -333,34 +332,34 @@ var TONE = {
|
|
|
333
332
|
};
|
|
334
333
|
function MarkdownPreview({ data }) {
|
|
335
334
|
const labels = useLabels();
|
|
336
|
-
const markdown =
|
|
335
|
+
const markdown = chunkWZA5S5EJ_cjs.str(data.markdown);
|
|
337
336
|
if (markdown.trim() === "") return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyMarkdown });
|
|
338
337
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap text-base leading-7", children: markdown });
|
|
339
338
|
}
|
|
340
339
|
function CodePreview({ data }) {
|
|
341
|
-
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: chunkWZA5S5EJ_cjs.str(data.code), language: chunkWZA5S5EJ_cjs.str(data.language) }) });
|
|
342
341
|
}
|
|
343
342
|
function ImagePreview({ data }) {
|
|
344
343
|
const { resolveAssetUrl, labels } = useQuoin();
|
|
345
344
|
const src = imageSource(data, resolveAssetUrl);
|
|
346
345
|
if (src === null) return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyImage });
|
|
347
|
-
const caption = captionText(
|
|
346
|
+
const caption = captionText(chunkWZA5S5EJ_cjs.str(data.caption));
|
|
348
347
|
return /* @__PURE__ */ jsxRuntime.jsxs("figure", { children: [
|
|
349
|
-
/* @__PURE__ */ jsxRuntime.jsx("img", { src, alt:
|
|
348
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: chunkWZA5S5EJ_cjs.str(data.alt) || labels.imageNoAlt, className: "max-w-full rounded-md" }),
|
|
350
349
|
caption && /* @__PURE__ */ jsxRuntime.jsx("figcaption", { className: HINT, children: caption })
|
|
351
350
|
] });
|
|
352
351
|
}
|
|
353
352
|
function FilePreview({ data }) {
|
|
354
353
|
const labels = useLabels();
|
|
355
|
-
const name =
|
|
354
|
+
const name = chunkWZA5S5EJ_cjs.str(data.filename);
|
|
356
355
|
if (name === "") return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyFile });
|
|
357
356
|
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: name });
|
|
358
357
|
}
|
|
359
358
|
function CalloutPreview({ data }) {
|
|
360
359
|
const labels = useLabels();
|
|
361
|
-
const body =
|
|
360
|
+
const body = chunkWZA5S5EJ_cjs.str(data.body);
|
|
362
361
|
if (body.trim() === "") return /* @__PURE__ */ jsxRuntime.jsx("p", { className: HINT, children: labels.emptyCallout });
|
|
363
|
-
const tone =
|
|
362
|
+
const tone = chunkWZA5S5EJ_cjs.str(data.tone) || "info";
|
|
364
363
|
const paint = TONE[tone] ?? "border-border bg-muted/50";
|
|
365
364
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-tone": tone, className: `rounded-md border-l-4 ${paint} p-3 text-sm`, children: body });
|
|
366
365
|
}
|
|
@@ -409,7 +408,7 @@ function selectNode(controller, blockId) {
|
|
|
409
408
|
const { editor } = controller;
|
|
410
409
|
const { selection } = editor.state;
|
|
411
410
|
if (selection?.kind === "node" && selection.block === blockId) return;
|
|
412
|
-
|
|
411
|
+
chunkNNDLIP2C_cjs.dispatchSelection(controller, chunk4F2IWBFM_cjs.nodeSelection(blockId));
|
|
413
412
|
}
|
|
414
413
|
function focusNode(controller, blockId) {
|
|
415
414
|
selectNode(controller, blockId);
|
|
@@ -439,8 +438,8 @@ var OPEN_EDITOR = "openEditor";
|
|
|
439
438
|
var ABOVE_CORE_KEYS = 200;
|
|
440
439
|
function turnedBlock(tr, { doc, selection }) {
|
|
441
440
|
if (selection?.kind !== "node" || tr.origin === "remote" || tr.origin === "reconcile") return void 0;
|
|
442
|
-
const before =
|
|
443
|
-
return before !== void 0 && before.type !==
|
|
441
|
+
const before = chunkWZA5S5EJ_cjs.blockById(tr.before.doc, selection.block);
|
|
442
|
+
return before !== void 0 && before.type !== chunkWZA5S5EJ_cjs.blockById(doc, selection.block)?.type ? selection.block : void 0;
|
|
444
443
|
}
|
|
445
444
|
function createVoidEditing() {
|
|
446
445
|
const starters = /* @__PURE__ */ new Map();
|
|
@@ -460,7 +459,7 @@ function createVoidEditing() {
|
|
|
460
459
|
start?.();
|
|
461
460
|
};
|
|
462
461
|
return {
|
|
463
|
-
extension:
|
|
462
|
+
extension: chunk4F2IWBFM_cjs.defineExtension({
|
|
464
463
|
name: "void-editing",
|
|
465
464
|
priority: ABOVE_CORE_KEYS,
|
|
466
465
|
keymap: { Enter: openEditor },
|
|
@@ -737,32 +736,32 @@ function settle(tr, before) {
|
|
|
737
736
|
const { schema } = tr.before;
|
|
738
737
|
const result = tr.selection;
|
|
739
738
|
if (result?.kind !== "blocks" || before?.kind === "blocks") return result;
|
|
740
|
-
const ids =
|
|
741
|
-
const head =
|
|
742
|
-
if (head !== null && ids.includes(head) &&
|
|
743
|
-
return
|
|
739
|
+
const ids = chunk4F2IWBFM_cjs.selectedBlockIds(doc, result);
|
|
740
|
+
const head = chunk4F2IWBFM_cjs.headBlockId(before);
|
|
741
|
+
if (head !== null && ids.includes(head) && chunk4F2IWBFM_cjs.validateSelection(doc, schema, before) === before) return before;
|
|
742
|
+
return chunk4F2IWBFM_cjs.endOf(doc, schema, ids[0]);
|
|
744
743
|
}
|
|
745
744
|
function runOnBlocks(controller, blockIds, command) {
|
|
746
745
|
const { state } = controller.editor;
|
|
747
746
|
const ids = blockIds.filter((id) => state.doc.index.has(id));
|
|
748
747
|
if (ids.length === 0) return false;
|
|
749
748
|
const before = state.selection;
|
|
750
|
-
const exact =
|
|
751
|
-
const ran = exact ? before :
|
|
752
|
-
const { ok, tr } =
|
|
753
|
-
const result = ok && tr !== null ? tr : new
|
|
749
|
+
const exact = chunkWZA5S5EJ_cjs.sameItems(chunk4F2IWBFM_cjs.selectedBlockIds(state.doc, before), ids);
|
|
750
|
+
const ran = exact ? before : chunk4F2IWBFM_cjs.blockRangeSelection(ids[0], ids[ids.length - 1]);
|
|
751
|
+
const { ok, tr } = chunk4F2IWBFM_cjs.runCommands(state, [chunk4F2IWBFM_cjs.setSelection(ran), command]);
|
|
752
|
+
const result = ok && tr !== null ? tr : new chunk4F2IWBFM_cjs.Transaction(state).setSelection(ran);
|
|
754
753
|
const settled = exact ? result.selection : settle(result, before);
|
|
755
|
-
if (!
|
|
756
|
-
if (result.docChanged || !
|
|
754
|
+
if (!chunk4F2IWBFM_cjs.sameSelection(settled, result.selection)) result.setSelection(settled);
|
|
755
|
+
if (result.docChanged || !chunk4F2IWBFM_cjs.sameSelection(result.selection, before)) controller.dispatch(result);
|
|
757
756
|
return ok;
|
|
758
757
|
}
|
|
759
758
|
var noChange = () => true;
|
|
760
759
|
|
|
761
760
|
// src/gutter/block-menu-items.ts
|
|
762
|
-
var rangeOf = (blockIds) =>
|
|
761
|
+
var rangeOf = (blockIds) => chunk4F2IWBFM_cjs.blockRangeSelection(blockIds[0], blockIds[blockIds.length - 1]);
|
|
763
762
|
function selectedWith(state, blockId) {
|
|
764
763
|
const { doc, selection } = state;
|
|
765
|
-
const selected =
|
|
764
|
+
const selected = chunk4F2IWBFM_cjs.selectedBlockIds(doc, selection);
|
|
766
765
|
const ofBlocks = selection?.kind === "blocks" || selection?.kind === "text" && selected.length > 1;
|
|
767
766
|
return ofBlocks && selected.includes(blockId) ? selected : null;
|
|
768
767
|
}
|
|
@@ -770,8 +769,8 @@ function menuTargets(state, blockId) {
|
|
|
770
769
|
const selected = selectedWith(state, blockId);
|
|
771
770
|
if (selected !== null) return selected;
|
|
772
771
|
const { doc } = state;
|
|
773
|
-
const index =
|
|
774
|
-
return doc.blocks.slice(index,
|
|
772
|
+
const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, blockId);
|
|
773
|
+
return doc.blocks.slice(index, chunk4F2IWBFM_cjs.descendantsEnd(doc, index)).map((block) => block.id);
|
|
775
774
|
}
|
|
776
775
|
function styleTargets(state, blockId) {
|
|
777
776
|
return selectedWith(state, blockId) ?? [blockId];
|
|
@@ -781,12 +780,12 @@ function menuActions(core, extra = []) {
|
|
|
781
780
|
}
|
|
782
781
|
function markdownOf(editor, blockIds, resolveAssetUrl) {
|
|
783
782
|
const { doc } = editor.state;
|
|
784
|
-
const range =
|
|
783
|
+
const range = chunk4F2IWBFM_cjs.selectedBlockRange(doc, rangeOf(blockIds));
|
|
785
784
|
if (range === null) return "";
|
|
786
|
-
const blocks = editor.codec.blocksFromDoc(
|
|
787
|
-
return
|
|
785
|
+
const blocks = editor.codec.blocksFromDoc(chunkWZA5S5EJ_cjs.createDoc(doc.blocks.slice(range.start, range.end)));
|
|
786
|
+
return chunk4F2IWBFM_cjs.toMarkdown(blocks, { schema: editor.schema, resolveAssetUrl, comments: false });
|
|
788
787
|
}
|
|
789
|
-
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)) && chunk4F2IWBFM_cjs.runCommands(state, [chunk4F2IWBFM_cjs.setSelection(rangeOf(blockIds)), command]).ok;
|
|
790
789
|
function coreBlockMenuActions(labels, options) {
|
|
791
790
|
const copy = (controller, blockIds, text2) => {
|
|
792
791
|
void copyText(text2).then((copied) => {
|
|
@@ -800,7 +799,7 @@ function coreBlockMenuActions(labels, options) {
|
|
|
800
799
|
label: labels.duplicate,
|
|
801
800
|
icon: lucideReact.CopyPlus,
|
|
802
801
|
shortcut: "Mod-d",
|
|
803
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
802
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunk4F2IWBFM_cjs.duplicateBlocks())
|
|
804
803
|
},
|
|
805
804
|
{
|
|
806
805
|
id: "copy",
|
|
@@ -819,23 +818,23 @@ function coreBlockMenuActions(labels, options) {
|
|
|
819
818
|
label: labels.moveUp,
|
|
820
819
|
icon: lucideReact.ArrowUp,
|
|
821
820
|
shortcut: "Mod-Shift-ArrowUp",
|
|
822
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
823
|
-
available: applies(
|
|
821
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunk4F2IWBFM_cjs.moveBlocksUp),
|
|
822
|
+
available: applies(chunk4F2IWBFM_cjs.moveBlocksUp)
|
|
824
823
|
},
|
|
825
824
|
{
|
|
826
825
|
id: "move-down",
|
|
827
826
|
label: labels.moveDown,
|
|
828
827
|
icon: lucideReact.ArrowDown,
|
|
829
828
|
shortcut: "Mod-Shift-ArrowDown",
|
|
830
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
831
|
-
available: applies(
|
|
829
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunk4F2IWBFM_cjs.moveBlocksDown),
|
|
830
|
+
available: applies(chunk4F2IWBFM_cjs.moveBlocksDown)
|
|
832
831
|
},
|
|
833
832
|
{
|
|
834
833
|
id: "delete",
|
|
835
834
|
label: labels.delete,
|
|
836
835
|
icon: lucideReact.Trash,
|
|
837
836
|
destructive: true,
|
|
838
|
-
run: (controller, blockIds) => runOnBlocks(controller, blockIds,
|
|
837
|
+
run: (controller, blockIds) => runOnBlocks(controller, blockIds, chunk4F2IWBFM_cjs.deleteBlocks)
|
|
839
838
|
}
|
|
840
839
|
];
|
|
841
840
|
}
|
|
@@ -881,7 +880,7 @@ var sharedTone = (blocks) => {
|
|
|
881
880
|
function CalloutMenus({ kit, controller, blocks }) {
|
|
882
881
|
const labels = useLabels();
|
|
883
882
|
const blockIds = blocks.map((block) => block.id);
|
|
884
|
-
const apply = (patch) => runOnBlocks(controller, blockIds,
|
|
883
|
+
const apply = (patch) => runOnBlocks(controller, blockIds, chunk4F2IWBFM_cjs.setAttrs(patch));
|
|
885
884
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
886
885
|
/* @__PURE__ */ jsxRuntime.jsxs(kit.Sub, { children: [
|
|
887
886
|
/* @__PURE__ */ jsxRuntime.jsxs(kit.SubTrigger, { children: [
|
|
@@ -901,7 +900,7 @@ function CalloutMenus({ kit, controller, blocks }) {
|
|
|
901
900
|
}
|
|
902
901
|
function sharedColor(blocks, key) {
|
|
903
902
|
const coloured = blocks.filter((block) => block.type === "MARKDOWN");
|
|
904
|
-
const colors = new Set(coloured.map((block) =>
|
|
903
|
+
const colors = new Set(coloured.map((block) => chunkWZA5S5EJ_cjs.paletteOrUndefined(block.attrs[key]) ?? "default"));
|
|
905
904
|
return colors.size === 1 ? [...colors][0] : "";
|
|
906
905
|
}
|
|
907
906
|
var swatches = {
|
|
@@ -914,7 +913,7 @@ function ColorGroups({ kit, value, onPick }) {
|
|
|
914
913
|
const backgroundTitle = React7.useId();
|
|
915
914
|
const group = (key, title, titleId) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
916
915
|
/* @__PURE__ */ jsxRuntime.jsx(kit.Label, { id: titleId, children: title }),
|
|
917
|
-
/* @__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: chunkWZA5S5EJ_cjs.PALETTE.map((name) => /* @__PURE__ */ jsxRuntime.jsxs(kit.RadioItem, { value: name, indicator: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4" }), children: [
|
|
918
917
|
swatches[key](name),
|
|
919
918
|
labels.colors[name]
|
|
920
919
|
] }, name)) })
|
|
@@ -929,7 +928,7 @@ function ColorMenu({ kit, controller, blocks }) {
|
|
|
929
928
|
const labels = useLabels();
|
|
930
929
|
const blockIds = blocks.map((block) => block.id);
|
|
931
930
|
const value = { color: sharedColor(blocks, "color"), background: sharedColor(blocks, "background") };
|
|
932
|
-
const pick = (key, name) => runOnBlocks(controller, blockIds,
|
|
931
|
+
const pick = (key, name) => runOnBlocks(controller, blockIds, chunk4F2IWBFM_cjs.setBlockColor({ [key]: name === "default" ? null : name }));
|
|
933
932
|
return /* @__PURE__ */ jsxRuntime.jsxs(kit.Sub, { children: [
|
|
934
933
|
/* @__PURE__ */ jsxRuntime.jsxs(kit.SubTrigger, { children: [
|
|
935
934
|
/* @__PURE__ */ jsxRuntime.jsx(MenuIcon, { icon: lucideReact.Palette }),
|
|
@@ -960,7 +959,7 @@ function modifierText(modifier, isMac, { keyNames }) {
|
|
|
960
959
|
return Object.hasOwn(MODIFIERS, name) ? keyNames[MODIFIERS[name]] : capitalized(modifier);
|
|
961
960
|
}
|
|
962
961
|
function formatShortcut(shortcut, platform = {}) {
|
|
963
|
-
const { isMac =
|
|
962
|
+
const { isMac = chunk4F2IWBFM_cjs.detectMac(), labels = englishLabels } = platform;
|
|
964
963
|
const parts = shortcut.split(shortcut.includes("+") ? "+" : "-");
|
|
965
964
|
const key = parts.pop() ?? shortcut;
|
|
966
965
|
const written = [...parts.map((modifier) => modifierText(modifier, isMac, labels)), keyText(key, labels)];
|
|
@@ -1040,21 +1039,21 @@ function languageOptions(query, plainText) {
|
|
|
1040
1039
|
}
|
|
1041
1040
|
|
|
1042
1041
|
// src/blocks/insert-blocks.ts
|
|
1043
|
-
var isEmptyParagraph = (schema, block) =>
|
|
1042
|
+
var isEmptyParagraph = (schema, block) => chunk4F2IWBFM_cjs.isParagraph(block) && chunk4F2IWBFM_cjs.regionLength(block, chunk4F2IWBFM_cjs.primaryRegion(schema, block) ?? "") === 0;
|
|
1044
1043
|
function fresh(schema, { id, type, attrs, regions }, indent3) {
|
|
1045
|
-
const block =
|
|
1044
|
+
const block = chunk4F2IWBFM_cjs.createBlock(schema, type, attrs, indent3, id);
|
|
1046
1045
|
return regions === void 0 ? block : { ...block, regions };
|
|
1047
1046
|
}
|
|
1048
1047
|
function landOnLine(tr, schema, index, indent3) {
|
|
1049
1048
|
const next = tr.doc.blocks[index];
|
|
1050
1049
|
const reused = next !== void 0 && next.indent === indent3 && isEmptyParagraph(schema, next);
|
|
1051
|
-
const line = reused ? next :
|
|
1052
|
-
if (!reused) tr.step(
|
|
1053
|
-
tr.setSelection(
|
|
1050
|
+
const line = reused ? next : chunk4F2IWBFM_cjs.createBlock(schema, schema.defaultTextBlock, {}, indent3);
|
|
1051
|
+
if (!reused) tr.step(chunk4F2IWBFM_cjs.insertBlocksStep(index, [line]));
|
|
1052
|
+
tr.setSelection(chunk4F2IWBFM_cjs.startOf(tr.doc, schema, line.id));
|
|
1054
1053
|
}
|
|
1055
1054
|
function land(tr, schema, landing, first, after) {
|
|
1056
|
-
if (landing === "text") tr.setSelection(
|
|
1057
|
-
if (landing === "editor") tr.setSelection(
|
|
1055
|
+
if (landing === "text") tr.setSelection(chunk4F2IWBFM_cjs.startOf(tr.doc, schema, first.id));
|
|
1056
|
+
if (landing === "editor") tr.setSelection(chunk4F2IWBFM_cjs.nodeSelection(first.id)).setMeta(OPEN_EDITOR, first.id);
|
|
1058
1057
|
if (landing === "line") landOnLine(tr, schema, after, first.indent);
|
|
1059
1058
|
}
|
|
1060
1059
|
function anchorIndex(doc, id) {
|
|
@@ -1064,24 +1063,24 @@ function anchorIndex(doc, id) {
|
|
|
1064
1063
|
function insertBlocks(blocks, landing, anchorId) {
|
|
1065
1064
|
return (state, dispatch) => {
|
|
1066
1065
|
const { doc, schema } = state;
|
|
1067
|
-
const id = anchorId === void 0 ?
|
|
1066
|
+
const id = anchorId === void 0 ? chunk4F2IWBFM_cjs.headBlockId(state.selection) : anchorId;
|
|
1068
1067
|
const index = anchorIndex(doc, id);
|
|
1069
1068
|
if (index === void 0 || blocks.length === 0) return false;
|
|
1070
1069
|
const anchor = id === null ? void 0 : doc.blocks[index];
|
|
1071
1070
|
const created2 = blocks.map((block) => fresh(schema, block, anchor?.indent ?? 0));
|
|
1072
|
-
const tr = new
|
|
1071
|
+
const tr = new chunk4F2IWBFM_cjs.Transaction(state);
|
|
1073
1072
|
const empty = anchor !== void 0 && landing !== "stay" && isEmptyParagraph(schema, anchor);
|
|
1074
1073
|
if (empty && landing === "line") {
|
|
1075
|
-
tr.step(
|
|
1074
|
+
tr.step(chunk4F2IWBFM_cjs.insertBlocksStep(index, created2)).setSelection(chunk4F2IWBFM_cjs.startOf(tr.doc, schema, anchor.id));
|
|
1076
1075
|
} else if (empty) {
|
|
1077
1076
|
const [first, ...rest] = created2;
|
|
1078
1077
|
const filled = { ...first, id: anchor.id };
|
|
1079
|
-
tr.step(
|
|
1080
|
-
if (rest.length > 0) tr.step(
|
|
1078
|
+
tr.step(chunk4F2IWBFM_cjs.replaceBlockStep(filled));
|
|
1079
|
+
if (rest.length > 0) tr.step(chunk4F2IWBFM_cjs.insertBlocksStep(index + 1, rest));
|
|
1081
1080
|
land(tr, schema, landing, filled, index + created2.length);
|
|
1082
1081
|
} else {
|
|
1083
|
-
const at = anchor === void 0 ? 0 :
|
|
1084
|
-
tr.step(
|
|
1082
|
+
const at = anchor === void 0 ? 0 : chunk4F2IWBFM_cjs.descendantsEnd(doc, index);
|
|
1083
|
+
tr.step(chunk4F2IWBFM_cjs.insertBlocksStep(at, created2));
|
|
1085
1084
|
land(tr, schema, landing, created2[0], at + created2.length);
|
|
1086
1085
|
}
|
|
1087
1086
|
dispatch?.(tr);
|
|
@@ -1094,7 +1093,7 @@ function landingFor(flow, hasEditor) {
|
|
|
1094
1093
|
}
|
|
1095
1094
|
function insertBlockToWrite(block, hasEditor, anchorId) {
|
|
1096
1095
|
return (state, dispatch) => {
|
|
1097
|
-
const landing = landingFor(
|
|
1096
|
+
const landing = landingFor(chunkWZA5S5EJ_cjs.specFor(state.schema, block.type).flow, hasEditor);
|
|
1098
1097
|
return insertBlocks([block], landing, anchorId)(state, dispatch);
|
|
1099
1098
|
};
|
|
1100
1099
|
}
|
|
@@ -1102,20 +1101,20 @@ function insertBlockToWrite(block, hasEditor, anchorId) {
|
|
|
1102
1101
|
// src/blocks/code/code-actions.ts
|
|
1103
1102
|
function writeCode(controller, blockId, code, group) {
|
|
1104
1103
|
const { editor } = controller;
|
|
1105
|
-
const block =
|
|
1104
|
+
const block = chunkWZA5S5EJ_cjs.blockById(editor.state.doc, blockId);
|
|
1106
1105
|
if (block === void 0 || block.attrs.code === code) return;
|
|
1107
|
-
controller.dispatch(editor.createTransaction().step(
|
|
1106
|
+
controller.dispatch(editor.createTransaction().step(chunk4F2IWBFM_cjs.setAttrsStep(blockId, { code })).setMeta(chunk4F2IWBFM_cjs.HISTORY_GROUP, group));
|
|
1108
1107
|
}
|
|
1109
1108
|
function codeToParagraph(blockId) {
|
|
1110
1109
|
return (state, dispatch) => {
|
|
1111
|
-
const turn =
|
|
1112
|
-
const { ok, tr } =
|
|
1110
|
+
const turn = chunk4F2IWBFM_cjs.setBlockType("MARKDOWN", { kind: "paragraph" });
|
|
1111
|
+
const { ok, tr } = chunk4F2IWBFM_cjs.runCommands(state, [chunk4F2IWBFM_cjs.setSelection(chunk4F2IWBFM_cjs.nodeSelection(blockId)), turn]);
|
|
1113
1112
|
if (ok && tr !== null) dispatch?.(tr);
|
|
1114
1113
|
return ok;
|
|
1115
1114
|
};
|
|
1116
1115
|
}
|
|
1117
1116
|
function leaveCode(controller, blockId, direction, addsLine = false) {
|
|
1118
|
-
const moved =
|
|
1117
|
+
const moved = chunkNNDLIP2C_cjs.moveToNeighbour(controller, blockId, direction);
|
|
1119
1118
|
if (!moved && !(addsLine && controller.run(insertBlocks([{ type: "MARKDOWN" }], "text", blockId)))) return false;
|
|
1120
1119
|
controller.focus();
|
|
1121
1120
|
return true;
|
|
@@ -1193,8 +1192,8 @@ var MOD_KEYS = [
|
|
|
1193
1192
|
["Mod-a", ({ value, start, end }) => start === 0 && end === value.length ? { kind: "selectAll" } : null]
|
|
1194
1193
|
];
|
|
1195
1194
|
function codeKeyAction(event, field, isMac) {
|
|
1196
|
-
const name =
|
|
1197
|
-
const modKey = MOD_KEYS.find(([key]) =>
|
|
1195
|
+
const name = chunk4F2IWBFM_cjs.keyName(event, isMac);
|
|
1196
|
+
const modKey = MOD_KEYS.find(([key]) => chunk4F2IWBFM_cjs.normalizeKey(key, isMac) === name);
|
|
1198
1197
|
const handler = modKey?.[1] ?? (Object.hasOwn(KEYS, name) ? KEYS[name] : void 0);
|
|
1199
1198
|
return handler?.(field) ?? null;
|
|
1200
1199
|
}
|
|
@@ -1240,7 +1239,7 @@ function travel({ controller, blockId, area }, command) {
|
|
|
1240
1239
|
const before = area.value;
|
|
1241
1240
|
controller.run(command);
|
|
1242
1241
|
const { selection } = controller.editor.state;
|
|
1243
|
-
const edit2 =
|
|
1242
|
+
const edit2 = chunkNNDLIP2C_cjs.textDiff(before, area.value);
|
|
1244
1243
|
if (selection?.kind !== "node" || selection.block !== blockId) controller.focus();
|
|
1245
1244
|
else if (edit2 !== null) area.setSelectionRange(edit2.from + edit2.insert.length, edit2.from + edit2.insert.length);
|
|
1246
1245
|
return true;
|
|
@@ -1256,13 +1255,13 @@ function runCodeAction(action, context) {
|
|
|
1256
1255
|
case "paragraph":
|
|
1257
1256
|
return selectAndFocus(context, codeToParagraph(blockId));
|
|
1258
1257
|
case "undo":
|
|
1259
|
-
return travel(context,
|
|
1258
|
+
return travel(context, chunk4F2IWBFM_cjs.undo);
|
|
1260
1259
|
case "redo":
|
|
1261
|
-
return travel(context,
|
|
1260
|
+
return travel(context, chunk4F2IWBFM_cjs.redo);
|
|
1262
1261
|
case "selectAll":
|
|
1263
|
-
return selectAndFocus(context,
|
|
1262
|
+
return selectAndFocus(context, chunk4F2IWBFM_cjs.selectAll);
|
|
1264
1263
|
case "escape":
|
|
1265
|
-
return selectAndFocus(context,
|
|
1264
|
+
return selectAndFocus(context, chunk4F2IWBFM_cjs.setSelection(chunk4F2IWBFM_cjs.blockRangeSelection(blockId)));
|
|
1266
1265
|
case "controls":
|
|
1267
1266
|
context.focusControls();
|
|
1268
1267
|
return true;
|
|
@@ -1325,18 +1324,18 @@ function CodeEditor({ block, controller, field, focusControls }) {
|
|
|
1325
1324
|
useTypeIntoCode(controller, blockId, field, edit2);
|
|
1326
1325
|
const onKeyDown = (event) => {
|
|
1327
1326
|
const area = event.currentTarget;
|
|
1328
|
-
if (
|
|
1327
|
+
if (chunkNNDLIP2C_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
1329
1328
|
const action = codeKeyAction(event, fieldOf(area), controller.isMac);
|
|
1330
1329
|
if (action !== null && runCodeAction(action, { controller, blockId, area, edit: edit2, focusControls })) event.preventDefault();
|
|
1331
1330
|
};
|
|
1332
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...{ [
|
|
1331
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...{ [chunkNNDLIP2C_cjs.NATIVE_INTERACTION]: "" }, dir: "ltr", className: "quoin-code-scroll", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-code-lines", children: [
|
|
1333
1332
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1334
1333
|
HighlightOverlay,
|
|
1335
1334
|
{
|
|
1336
1335
|
"aria-hidden": "true",
|
|
1337
1336
|
drawnRef: drawn,
|
|
1338
|
-
code:
|
|
1339
|
-
language:
|
|
1337
|
+
code: chunkWZA5S5EJ_cjs.str(block.attrs.code),
|
|
1338
|
+
language: chunkWZA5S5EJ_cjs.str(block.attrs.language)
|
|
1340
1339
|
}
|
|
1341
1340
|
),
|
|
1342
1341
|
/* @__PURE__ */ jsxRuntime.jsx("span", { ref: mark, "aria-hidden": "true", className: "quoin-code-caret" }),
|
|
@@ -1346,7 +1345,7 @@ function CodeEditor({ block, controller, field, focusControls }) {
|
|
|
1346
1345
|
ref: field,
|
|
1347
1346
|
"aria-label": labels.codeText,
|
|
1348
1347
|
"aria-keyshortcuts": "Alt+F10",
|
|
1349
|
-
value:
|
|
1348
|
+
value: chunkWZA5S5EJ_cjs.str(block.attrs.code),
|
|
1350
1349
|
wrap: "off",
|
|
1351
1350
|
tabIndex: -1,
|
|
1352
1351
|
spellCheck: false,
|
|
@@ -1399,7 +1398,7 @@ var Button = React7__namespace.forwardRef(function Button2({ className, variant
|
|
|
1399
1398
|
var COPIED_FOR_MS = 1500;
|
|
1400
1399
|
function CopyCodeButton({ code, controller }) {
|
|
1401
1400
|
const labels = useLabels();
|
|
1402
|
-
const readOnly =
|
|
1401
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
1403
1402
|
const [copied, setCopied] = React7.useState(false);
|
|
1404
1403
|
React7.useEffect(() => {
|
|
1405
1404
|
if (!copied) return;
|
|
@@ -1482,7 +1481,7 @@ var preventDefault = (event) => event.preventDefault();
|
|
|
1482
1481
|
|
|
1483
1482
|
// src/blocks/text/set-block-attrs.ts
|
|
1484
1483
|
function setBlockAttrs(controller, blockId, patch) {
|
|
1485
|
-
if (!controller.readOnly) controller.run(
|
|
1484
|
+
if (!controller.readOnly) controller.run(chunkNNDLIP2C_cjs.onBlock(blockId, chunk4F2IWBFM_cjs.setAttrs(patch)));
|
|
1486
1485
|
}
|
|
1487
1486
|
var FIELD = `quoin-code-language quoin-code-control ${FOCUS_RING}`;
|
|
1488
1487
|
var CONTENT = `${MENU_CONTENT} flex max-h-64 w-48 flex-col overflow-y-hidden`;
|
|
@@ -1498,7 +1497,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1498
1497
|
const options = draft === null ? [] : languageOptions(draft === shown ? "" : draft, labels.plainText);
|
|
1499
1498
|
const open = options.length > 0;
|
|
1500
1499
|
const optionId = (index) => `${listboxId}-${index}`;
|
|
1501
|
-
|
|
1500
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
1502
1501
|
list.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
1503
1502
|
}, [active]);
|
|
1504
1503
|
const close = () => {
|
|
@@ -1524,7 +1523,7 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1524
1523
|
onDone();
|
|
1525
1524
|
};
|
|
1526
1525
|
const onKeyDown = (event) => {
|
|
1527
|
-
if (
|
|
1526
|
+
if (chunkNNDLIP2C_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
1528
1527
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1529
1528
|
event.preventDefault();
|
|
1530
1529
|
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
@@ -1598,11 +1597,11 @@ function LanguageCombobox({ blockId, controller, language: language2, field, onD
|
|
|
1598
1597
|
}
|
|
1599
1598
|
var CodeBlock = ({ block, controller }) => {
|
|
1600
1599
|
const labels = useLabels();
|
|
1601
|
-
const readOnly =
|
|
1600
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
1602
1601
|
const languageField = React7.useRef(null);
|
|
1603
1602
|
const codeField = React7.useRef(null);
|
|
1604
|
-
const code =
|
|
1605
|
-
const language2 =
|
|
1603
|
+
const code = chunkWZA5S5EJ_cjs.str(block.attrs.code);
|
|
1604
|
+
const language2 = chunkWZA5S5EJ_cjs.str(block.attrs.language);
|
|
1606
1605
|
const name = languageName(language2) ?? language2;
|
|
1607
1606
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", "aria-label": labels.blockNames.code, contentEditable: false, className: "quoin-code", children: [
|
|
1608
1607
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-code-header", children: [
|
|
@@ -1700,7 +1699,7 @@ function selectHandlers(controller, blockId, root, onSelect) {
|
|
|
1700
1699
|
return {
|
|
1701
1700
|
onKeyDown(event) {
|
|
1702
1701
|
const key = event.nativeEvent;
|
|
1703
|
-
if (
|
|
1702
|
+
if (chunkNNDLIP2C_cjs.isComposingKey(controller, key)) return;
|
|
1704
1703
|
if (event.key === "Escape") select();
|
|
1705
1704
|
else if (!(event.metaKey || event.ctrlKey) || event.target.matches("input:not([type=file])") || !controller.edit(() => controller.editor.handleKey(key)))
|
|
1706
1705
|
return;
|
|
@@ -1838,16 +1837,16 @@ var kindOf = (value) => KINDS.find(([, pattern]) => pattern.test(value))?.[0];
|
|
|
1838
1837
|
var fileIcon = (mime, filename) => kindOf(mime) ?? kindOf(/\.([^.]+)$/.exec(filename)?.[1].toLowerCase() ?? "") ?? lucideReact.FileIcon;
|
|
1839
1838
|
|
|
1840
1839
|
// src/blocks/file/file-source.ts
|
|
1841
|
-
var fileName = (attrs) =>
|
|
1840
|
+
var fileName = (attrs) => chunkWZA5S5EJ_cjs.str(attrs.filename) || chunkWZA5S5EJ_cjs.str(attrs.storageKey);
|
|
1842
1841
|
var hasFile = (attrs) => fileName(attrs) !== "";
|
|
1843
1842
|
function FileCard({ block, controller, readOnly }) {
|
|
1844
1843
|
const { labels, resolveAssetUrl } = useQuoin();
|
|
1845
1844
|
const card = React7.useRef(null);
|
|
1846
1845
|
const { id, attrs } = block;
|
|
1847
1846
|
const name = fileName(attrs);
|
|
1848
|
-
const size =
|
|
1849
|
-
const href = assetHref(resolveAssetUrl,
|
|
1850
|
-
const Icon = fileIcon(
|
|
1847
|
+
const size = chunkWZA5S5EJ_cjs.optionalNumber(attrs.size);
|
|
1848
|
+
const href = assetHref(resolveAssetUrl, chunkWZA5S5EJ_cjs.str(attrs.storageKey));
|
|
1849
|
+
const Icon = fileIcon(chunkWZA5S5EJ_cjs.str(attrs.mime), name);
|
|
1851
1850
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: card, className: "quoin-file-card", ...selectHandlers(controller, id, card), children: [
|
|
1852
1851
|
/* @__PURE__ */ jsxRuntime.jsx(Icon, { "aria-hidden": "true", className: "quoin-file-icon" }),
|
|
1853
1852
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-file-name", children: name }),
|
|
@@ -1856,7 +1855,7 @@ function FileCard({ block, controller, readOnly }) {
|
|
|
1856
1855
|
"a",
|
|
1857
1856
|
{
|
|
1858
1857
|
href,
|
|
1859
|
-
download:
|
|
1858
|
+
download: chunkWZA5S5EJ_cjs.str(attrs.filename),
|
|
1860
1859
|
target: "_blank",
|
|
1861
1860
|
rel: "noopener",
|
|
1862
1861
|
"aria-label": labels.downloadFile(name),
|
|
@@ -1882,14 +1881,14 @@ function claimUpload(controller, blockId) {
|
|
|
1882
1881
|
}
|
|
1883
1882
|
var isNewestUpload = (controller, blockId, token) => newestUploads.get(controller)?.get(blockId) === token;
|
|
1884
1883
|
function assetOf(controller, blockId, type) {
|
|
1885
|
-
const block =
|
|
1884
|
+
const block = chunkWZA5S5EJ_cjs.blockById(controller.editor.state.doc, blockId);
|
|
1886
1885
|
if (block?.type !== type || controller.readOnly) return null;
|
|
1887
|
-
return { url:
|
|
1886
|
+
return { url: chunkWZA5S5EJ_cjs.str(block.attrs.url), storageKey: chunkWZA5S5EJ_cjs.str(block.attrs.storageKey) };
|
|
1888
1887
|
}
|
|
1889
1888
|
var sameAsset = (a, b) => a !== null && b !== null && a.url === b.url && a.storageKey === b.storageKey;
|
|
1890
1889
|
function writeAttrs(controller, blockId, patch, recorded) {
|
|
1891
1890
|
const { editor } = controller;
|
|
1892
|
-
const tr = editor.createTransaction().step(
|
|
1891
|
+
const tr = editor.createTransaction().step(chunk4F2IWBFM_cjs.setAttrsStep(blockId, patch));
|
|
1893
1892
|
editor.dispatch(recorded ? tr : tr.setMeta("addToHistory", false));
|
|
1894
1893
|
}
|
|
1895
1894
|
async function uploadInto(controller, blockId, file, { type, category }, { upload, onLand }, land2) {
|
|
@@ -1920,7 +1919,7 @@ var uploadFile = (controller, blockId, file, host) => uploadInto(
|
|
|
1920
1919
|
var anyFile = () => true;
|
|
1921
1920
|
var FileBlock = ({ block, controller }) => {
|
|
1922
1921
|
const labels = useLabels();
|
|
1923
|
-
const readOnly =
|
|
1922
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
1924
1923
|
const root = React7.useRef(null);
|
|
1925
1924
|
const filled = hasFile(block.attrs);
|
|
1926
1925
|
useNodeKeys(controller, block.id, !readOnly, !filled, root);
|
|
@@ -1984,7 +1983,7 @@ function usePartAnchor(controller, blockId, selector) {
|
|
|
1984
1983
|
}
|
|
1985
1984
|
var replaceItem = (title, run) => run ? [{ id: "replace", title, icon: lucideReact.Upload, run }] : [];
|
|
1986
1985
|
function deleteBlock(controller, blockId) {
|
|
1987
|
-
runOnBlocks(controller, [blockId],
|
|
1986
|
+
runOnBlocks(controller, [blockId], chunk4F2IWBFM_cjs.deleteBlocks);
|
|
1988
1987
|
controller.focus();
|
|
1989
1988
|
}
|
|
1990
1989
|
var deleteItem = (blockId, title) => ({
|
|
@@ -1999,8 +1998,8 @@ function markItem(mark, title, icon) {
|
|
|
1999
1998
|
id: mark,
|
|
2000
1999
|
title,
|
|
2001
2000
|
icon,
|
|
2002
|
-
isActive: (state) =>
|
|
2003
|
-
run: (controller) => void controller.run(
|
|
2001
|
+
isActive: (state) => chunk4F2IWBFM_cjs.isActive(state, mark),
|
|
2002
|
+
run: (controller) => void controller.run(chunk4F2IWBFM_cjs.toggleMark(mark))
|
|
2004
2003
|
};
|
|
2005
2004
|
}
|
|
2006
2005
|
var linkItem = (labels, openLink) => ({
|
|
@@ -2070,7 +2069,7 @@ function useRovingFocus() {
|
|
|
2070
2069
|
},
|
|
2071
2070
|
[syncTabStop]
|
|
2072
2071
|
);
|
|
2073
|
-
|
|
2072
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(syncTabStop);
|
|
2074
2073
|
const onFocus = (event) => {
|
|
2075
2074
|
if (!owns(event.target)) return;
|
|
2076
2075
|
current.current = event.target;
|
|
@@ -2089,7 +2088,7 @@ function useRovingFocus() {
|
|
|
2089
2088
|
// src/menus/floating/use-focus-key.ts
|
|
2090
2089
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
2091
2090
|
function useFocusKey(controller, focus) {
|
|
2092
|
-
|
|
2091
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
2093
2092
|
const intercept = (event) => {
|
|
2094
2093
|
if (!isFocusKey(event)) return false;
|
|
2095
2094
|
event.preventDefault();
|
|
@@ -2101,11 +2100,11 @@ function useFocusKey(controller, focus) {
|
|
|
2101
2100
|
}
|
|
2102
2101
|
function NodeToolbar(props) {
|
|
2103
2102
|
const { blockId, controller, label, anchor, items, next, buttonRefs, children, popover } = props;
|
|
2104
|
-
const state =
|
|
2103
|
+
const state = chunkNNDLIP2C_cjs.useEditorState(controller, chunkNNDLIP2C_cjs.wholeState);
|
|
2105
2104
|
const roving = useRovingFocus();
|
|
2106
2105
|
useFocusKey(controller, roving.focusCurrent);
|
|
2107
2106
|
const onKeyDown = (event) => {
|
|
2108
|
-
if (!roving.owns(event.target) ||
|
|
2107
|
+
if (!roving.owns(event.target) || chunkNNDLIP2C_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2109
2108
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
2110
2109
|
const ahead = tab && !event.shiftKey && next !== void 0 ? blockPart(controller, blockId, next) : void 0;
|
|
2111
2110
|
if (ahead !== void 0) ahead.focus();
|
|
@@ -2182,12 +2181,12 @@ function useSelectionSettled(controller) {
|
|
|
2182
2181
|
|
|
2183
2182
|
// src/blocks/void/use-toolbar-block.ts
|
|
2184
2183
|
var selectedBlock = (type, filled) => ({ doc, selection }) => {
|
|
2185
|
-
const block = selection?.kind === "node" ?
|
|
2184
|
+
const block = selection?.kind === "node" ? chunkWZA5S5EJ_cjs.blockById(doc, selection.block) : void 0;
|
|
2186
2185
|
return block?.type === type && filled(block.attrs) ? block.id : null;
|
|
2187
2186
|
};
|
|
2188
2187
|
function useToolbarBlock(controller, selected, keptFor = null) {
|
|
2189
|
-
const blockId =
|
|
2190
|
-
const readOnly =
|
|
2188
|
+
const blockId = chunkNNDLIP2C_cjs.useEditorState(controller, selected);
|
|
2189
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
2191
2190
|
const settled = useSelectionSettled(controller);
|
|
2192
2191
|
return blockId !== null && !readOnly && (settled || keptFor === blockId) ? blockId : null;
|
|
2193
2192
|
}
|
|
@@ -2266,7 +2265,7 @@ function ResizeHandles({ blockId, controller, frame, percent, centred, onPreview
|
|
|
2266
2265
|
const value = percent ?? drawn;
|
|
2267
2266
|
const write = (widthPercent) => setBlockAttrs(controller, blockId, { widthPercent });
|
|
2268
2267
|
const onKeyDown = (event) => {
|
|
2269
|
-
if (
|
|
2268
|
+
if (chunkNNDLIP2C_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2270
2269
|
const next = keyedWidth(event.key, value);
|
|
2271
2270
|
if (event.key === "Escape") controller.focus();
|
|
2272
2271
|
else if (next === null) return;
|
|
@@ -2308,7 +2307,7 @@ function ResizeHandles({ blockId, controller, frame, percent, centred, onPreview
|
|
|
2308
2307
|
"aria-valuetext": labels.widthValue(value),
|
|
2309
2308
|
"data-side": side,
|
|
2310
2309
|
className: "quoin-image-handle",
|
|
2311
|
-
...{ [
|
|
2310
|
+
...{ [chunkNNDLIP2C_cjs.NATIVE_INTERACTION]: "" },
|
|
2312
2311
|
...bubblePart(controller),
|
|
2313
2312
|
onKeyDown,
|
|
2314
2313
|
onPointerDown: onPointerDown(side),
|
|
@@ -2329,9 +2328,9 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2329
2328
|
const [failed, setFailed] = React7.useState(null);
|
|
2330
2329
|
const { id, attrs, regions } = block;
|
|
2331
2330
|
const src = imageSource(attrs, resolveAssetUrl);
|
|
2332
|
-
const alt =
|
|
2331
|
+
const alt = chunkWZA5S5EJ_cjs.str(attrs.alt);
|
|
2333
2332
|
const name = alt || labels.imageNoAlt;
|
|
2334
|
-
const percent =
|
|
2333
|
+
const percent = chunkWZA5S5EJ_cjs.optionalNumber(attrs.widthPercent);
|
|
2335
2334
|
const width = preview ?? percent;
|
|
2336
2335
|
const flagged = !readOnly && alt === "" && attrs.decorative !== true;
|
|
2337
2336
|
const select = () => focusNode(controller, id);
|
|
@@ -2345,8 +2344,8 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2345
2344
|
{
|
|
2346
2345
|
src,
|
|
2347
2346
|
alt: name,
|
|
2348
|
-
width:
|
|
2349
|
-
height:
|
|
2347
|
+
width: chunkWZA5S5EJ_cjs.optionalNumber(attrs.width),
|
|
2348
|
+
height: chunkWZA5S5EJ_cjs.optionalNumber(attrs.height),
|
|
2350
2349
|
draggable: false,
|
|
2351
2350
|
onError: () => setFailed(src),
|
|
2352
2351
|
onClick: select
|
|
@@ -2381,7 +2380,7 @@ function ImageFigure({ block, controller, readOnly }) {
|
|
|
2381
2380
|
)
|
|
2382
2381
|
] }),
|
|
2383
2382
|
(!readOnly || (regions.caption?.length ?? 0) > 0) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2384
|
-
|
|
2383
|
+
chunkNNDLIP2C_cjs.EditableRegion,
|
|
2385
2384
|
{
|
|
2386
2385
|
block: id,
|
|
2387
2386
|
region: "caption",
|
|
@@ -2399,8 +2398,8 @@ var WHITESPACE = /\s/;
|
|
|
2399
2398
|
function linkAddress(typed2) {
|
|
2400
2399
|
const address = typed2.trim();
|
|
2401
2400
|
if (WHITESPACE.test(address)) return null;
|
|
2402
|
-
const completed = !
|
|
2403
|
-
const href =
|
|
2401
|
+
const completed = !chunkWZA5S5EJ_cjs.SCHEME.test(address) && BARE_DOMAIN.test(address) ? `https://${address}` : address;
|
|
2402
|
+
const href = chunkWZA5S5EJ_cjs.sanitizeHref(completed);
|
|
2404
2403
|
return href || null;
|
|
2405
2404
|
}
|
|
2406
2405
|
var Input = React7__namespace.forwardRef(function Input2({ className, type, ...props }, ref) {
|
|
@@ -2507,8 +2506,8 @@ function ImageUploadArea({ blockId, controller }) {
|
|
|
2507
2506
|
);
|
|
2508
2507
|
}
|
|
2509
2508
|
function captionEnd(controller, blockId) {
|
|
2510
|
-
const caption =
|
|
2511
|
-
return { block: blockId, region: "caption", offset:
|
|
2509
|
+
const caption = chunkWZA5S5EJ_cjs.blockById(controller.editor.state.doc, blockId)?.regions.caption ?? [];
|
|
2510
|
+
return { block: blockId, region: "caption", offset: chunkWZA5S5EJ_cjs.inlineLength(caption) };
|
|
2512
2511
|
}
|
|
2513
2512
|
var plainEnter = (event) => event.key === "Enter" && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
2514
2513
|
var menuOpenOn = (host) => host?.getAttribute("aria-expanded") === "true";
|
|
@@ -2520,7 +2519,7 @@ function useImageKeys(controller, blockId, picture, editable, root) {
|
|
|
2520
2519
|
// then follows.
|
|
2521
2520
|
enter() {
|
|
2522
2521
|
const { editor } = controller;
|
|
2523
|
-
editor.dispatch(editor.createTransaction().setSelection(
|
|
2522
|
+
editor.dispatch(editor.createTransaction().setSelection(chunk4F2IWBFM_cjs.textSelection(captionEnd(controller, blockId))));
|
|
2524
2523
|
controller.focus();
|
|
2525
2524
|
},
|
|
2526
2525
|
type(key) {
|
|
@@ -2545,7 +2544,7 @@ function useImageKeys(controller, blockId, picture, editable, root) {
|
|
|
2545
2544
|
}
|
|
2546
2545
|
var ImageBlock = ({ block, controller }) => {
|
|
2547
2546
|
const labels = useLabels();
|
|
2548
|
-
const readOnly =
|
|
2547
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
2549
2548
|
const root = React7.useRef(null);
|
|
2550
2549
|
const picture = hasPicture(block.attrs);
|
|
2551
2550
|
useImageKeys(controller, block.id, picture, !readOnly, root);
|
|
@@ -2558,17 +2557,17 @@ var ImageBlock = ({ block, controller }) => {
|
|
|
2558
2557
|
"aria-label": labels.blockNames.image,
|
|
2559
2558
|
contentEditable: false,
|
|
2560
2559
|
className: "quoin-image",
|
|
2561
|
-
...picture ? { [
|
|
2560
|
+
...picture ? { [chunkNNDLIP2C_cjs.NODE_ENTRY]: "" } : void 0,
|
|
2562
2561
|
children: picture ? /* @__PURE__ */ jsxRuntime.jsx(ImageFigure, { block, controller, readOnly }) : empty
|
|
2563
2562
|
}
|
|
2564
2563
|
);
|
|
2565
2564
|
};
|
|
2566
2565
|
function useOutsidePress(element, ownerDocument, onPress) {
|
|
2567
2566
|
const latest = React7.useRef(onPress);
|
|
2568
|
-
|
|
2567
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
2569
2568
|
latest.current = onPress;
|
|
2570
2569
|
});
|
|
2571
|
-
|
|
2570
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
2572
2571
|
const doc = ownerDocument();
|
|
2573
2572
|
const inside = (target) => element.current?.contains(target) === true;
|
|
2574
2573
|
let touched = null;
|
|
@@ -2583,15 +2582,15 @@ function useOutsidePress(element, ownerDocument, onPress) {
|
|
|
2583
2582
|
if (touched !== null && !inside(event.target)) latest.current(touched);
|
|
2584
2583
|
touched = null;
|
|
2585
2584
|
};
|
|
2586
|
-
return
|
|
2585
|
+
return chunkNNDLIP2C_cjs.listen(doc, { pointerdown: down, click }, true);
|
|
2587
2586
|
}, [element, ownerDocument]);
|
|
2588
2587
|
}
|
|
2589
2588
|
function storeAlt(controller, blockId, opened, patch) {
|
|
2590
2589
|
const { editor } = controller;
|
|
2591
|
-
const attrs =
|
|
2592
|
-
const changed =
|
|
2590
|
+
const attrs = chunkWZA5S5EJ_cjs.blockById(editor.state.doc, blockId)?.attrs ?? {};
|
|
2591
|
+
const changed = chunkWZA5S5EJ_cjs.str(attrs.alt) !== opened.alt || attrs.decorative === true !== opened.decorative;
|
|
2593
2592
|
if (controller.readOnly || controller.root === null || changed) return;
|
|
2594
|
-
|
|
2593
|
+
chunkNNDLIP2C_cjs.onBlock(blockId, chunk4F2IWBFM_cjs.setAttrs(patch))(editor.state, (tr) => editor.dispatch(tr));
|
|
2595
2594
|
}
|
|
2596
2595
|
function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative, onClose }) {
|
|
2597
2596
|
const labels = useLabels();
|
|
@@ -2633,7 +2632,7 @@ function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative,
|
|
|
2633
2632
|
close(true);
|
|
2634
2633
|
};
|
|
2635
2634
|
const onKeyDown = (event) => {
|
|
2636
|
-
if (event.key !== "Tab" ||
|
|
2635
|
+
if (event.key !== "Tab" || chunkNNDLIP2C_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
2637
2636
|
const controls = [...event.currentTarget.elements];
|
|
2638
2637
|
const next = controls[controls.indexOf(event.target) + (event.shiftKey ? -1 : 1)];
|
|
2639
2638
|
event.preventDefault();
|
|
@@ -2661,7 +2660,7 @@ function AltTextPopover({ blockId, controller, anchor, opener, alt, decorative,
|
|
|
2661
2660
|
onCloseAutoFocus: preventDefault,
|
|
2662
2661
|
onEscapeKeyDown: (event) => {
|
|
2663
2662
|
event.preventDefault();
|
|
2664
|
-
if (!
|
|
2663
|
+
if (!chunkNNDLIP2C_cjs.isComposingKey(controller, event)) close(false);
|
|
2665
2664
|
},
|
|
2666
2665
|
...bubblePart(controller),
|
|
2667
2666
|
children: /* @__PURE__ */ jsxRuntime.jsxs("form", { noValidate: true, className: "quoin-image-alt", onSubmit: save, onKeyDown, children: [
|
|
@@ -2713,7 +2712,7 @@ function imageToolbarItems(blockId, labels, actions) {
|
|
|
2713
2712
|
id: align,
|
|
2714
2713
|
title: labels[label],
|
|
2715
2714
|
icon,
|
|
2716
|
-
isActive: (state) => (
|
|
2715
|
+
isActive: (state) => (chunkWZA5S5EJ_cjs.alignOrUndefined(chunkWZA5S5EJ_cjs.blockById(state.doc, blockId)?.attrs.align) ?? "left") === align,
|
|
2717
2716
|
run: (controller) => setBlockAttrs(controller, blockId, { align })
|
|
2718
2717
|
})
|
|
2719
2718
|
);
|
|
@@ -2755,11 +2754,11 @@ function ImageToolbarOverlay({ controller }) {
|
|
|
2755
2754
|
}
|
|
2756
2755
|
function ImageToolbar({ blockId, controller, editingAlt, onEditAlt }) {
|
|
2757
2756
|
const { labels, resolveAssetUrl } = useQuoin();
|
|
2758
|
-
const state =
|
|
2757
|
+
const state = chunkNNDLIP2C_cjs.useEditorState(controller, chunkNNDLIP2C_cjs.wholeState);
|
|
2759
2758
|
const picker = useReplacePicker(controller, blockId, uploadImage, "image/*");
|
|
2760
2759
|
const altButton = React7.useRef(null);
|
|
2761
2760
|
const anchor = usePartAnchor(controller, blockId, ".quoin-image-frame");
|
|
2762
|
-
const attrs =
|
|
2761
|
+
const attrs = chunkWZA5S5EJ_cjs.blockById(state.doc, blockId)?.attrs ?? {};
|
|
2763
2762
|
const items = imageToolbarItems(blockId, labels, {
|
|
2764
2763
|
replace: picker.open,
|
|
2765
2764
|
editAlt: () => {
|
|
@@ -2785,7 +2784,7 @@ function ImageToolbar({ blockId, controller, editingAlt, onEditAlt }) {
|
|
|
2785
2784
|
controller,
|
|
2786
2785
|
anchor,
|
|
2787
2786
|
opener: altButton,
|
|
2788
|
-
alt:
|
|
2787
|
+
alt: chunkWZA5S5EJ_cjs.str(attrs.alt),
|
|
2789
2788
|
decorative: attrs.decorative === true,
|
|
2790
2789
|
onClose: () => onEditAlt(null)
|
|
2791
2790
|
}
|
|
@@ -2987,13 +2986,13 @@ function CalloutToneMenu({ blockId, controller, tone }) {
|
|
|
2987
2986
|
}
|
|
2988
2987
|
var CalloutBlock = ({ block, controller }) => {
|
|
2989
2988
|
const labels = useLabels();
|
|
2990
|
-
const readOnly =
|
|
2989
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
2991
2990
|
const tone = calloutTone(block.attrs.tone);
|
|
2992
2991
|
const icon = calloutIcon(block.attrs, tone);
|
|
2993
2992
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("quoin-callout group/callout flex items-start gap-2", TONE[tone]), "data-tone": tone, children: [
|
|
2994
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 }),
|
|
2995
2994
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2996
|
-
|
|
2995
|
+
chunkNNDLIP2C_cjs.EditableRegion,
|
|
2997
2996
|
{
|
|
2998
2997
|
block: block.id,
|
|
2999
2998
|
region: "body",
|
|
@@ -3061,23 +3060,23 @@ var HEADING_LEVELS = ["mt-6 text-3xl", "mt-5 text-2xl", "mt-4 text-xl", "mt-3 te
|
|
|
3061
3060
|
var headingStyles = (level) => `quoin-heading mb-1 font-semibold leading-tight in-[[data-quoin-block]:first-child]:mt-0 ${HEADING_LEVELS[level - 1]}`;
|
|
3062
3061
|
function Heading({ block }) {
|
|
3063
3062
|
const labels = useLabels();
|
|
3064
|
-
const level =
|
|
3065
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: headingStyles(level), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3063
|
+
const level = chunkWZA5S5EJ_cjs.headingLevel(block.attrs.level);
|
|
3064
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: headingStyles(level), children: /* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.heading(level) }) });
|
|
3066
3065
|
}
|
|
3067
3066
|
function NumberedItem({ block, controller }) {
|
|
3068
3067
|
const labels = useLabels();
|
|
3069
|
-
const number =
|
|
3068
|
+
const number = chunkNNDLIP2C_cjs.useOrderedNumber(controller, block.id);
|
|
3070
3069
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "ordered", children: [
|
|
3071
3070
|
/* @__PURE__ */ jsxRuntime.jsx(ListMarker, { list: "ordered", number, depth: block.indent }),
|
|
3072
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3071
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.numberedItem(number) })
|
|
3073
3072
|
] });
|
|
3074
3073
|
}
|
|
3075
3074
|
function TaskItem({ block, controller }) {
|
|
3076
3075
|
const labels = useLabels();
|
|
3077
|
-
const hostId =
|
|
3076
|
+
const hostId = chunkNNDLIP2C_cjs.useRegionDomId(block.id, REGION);
|
|
3078
3077
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-task", "data-checked": block.attrs.checked === true, children: [
|
|
3079
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3080
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3078
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.TaskCheckbox, { block, controller, label: labels.task, labelledBy: hostId }),
|
|
3079
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.EditableRegion, { id: hostId, block: block.id, region: REGION, label: labels.task })
|
|
3081
3080
|
] });
|
|
3082
3081
|
}
|
|
3083
3082
|
var MarkdownBlock = (props) => {
|
|
@@ -3089,16 +3088,16 @@ var MarkdownBlock = (props) => {
|
|
|
3089
3088
|
case "bullet":
|
|
3090
3089
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-list-item", "data-list": "bullet", children: [
|
|
3091
3090
|
/* @__PURE__ */ jsxRuntime.jsx(ListMarker, { list: "bullet", depth: block.indent }),
|
|
3092
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3091
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.bulletItem })
|
|
3093
3092
|
] });
|
|
3094
3093
|
case "ordered":
|
|
3095
3094
|
return /* @__PURE__ */ jsxRuntime.jsx(NumberedItem, { ...props });
|
|
3096
3095
|
case "task":
|
|
3097
3096
|
return /* @__PURE__ */ jsxRuntime.jsx(TaskItem, { ...props });
|
|
3098
3097
|
case "quote":
|
|
3099
|
-
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(chunkNNDLIP2C_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.quote }) });
|
|
3100
3099
|
default:
|
|
3101
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3100
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.EditableRegion, { block: block.id, region: REGION, label: labels.paragraph });
|
|
3102
3101
|
}
|
|
3103
3102
|
};
|
|
3104
3103
|
|
|
@@ -3106,19 +3105,19 @@ var MarkdownBlock = (props) => {
|
|
|
3106
3105
|
function nestedBlockIds({ doc }, blockId) {
|
|
3107
3106
|
const index = doc.index.get(blockId);
|
|
3108
3107
|
if (index === void 0) return [];
|
|
3109
|
-
return doc.blocks.slice(index + 1,
|
|
3108
|
+
return doc.blocks.slice(index + 1, chunk4F2IWBFM_cjs.descendantsEnd(doc, index)).map((block) => block.id);
|
|
3110
3109
|
}
|
|
3111
3110
|
function useNestedBlocks(controller, blockId) {
|
|
3112
|
-
return
|
|
3111
|
+
return chunkNNDLIP2C_cjs.useEditorState(controller, (state) => nestedBlockIds(state, blockId), chunkWZA5S5EJ_cjs.sameItems);
|
|
3113
3112
|
}
|
|
3114
3113
|
var ToggleBlock = ({ block, controller }) => {
|
|
3115
3114
|
const labels = useLabels();
|
|
3116
|
-
const domId =
|
|
3115
|
+
const domId = chunkNNDLIP2C_cjs.useBlockDomId();
|
|
3117
3116
|
const nested = useNestedBlocks(controller, block.id);
|
|
3118
|
-
const open =
|
|
3117
|
+
const open = chunkNNDLIP2C_cjs.useToggleOpen(controller, block);
|
|
3119
3118
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-toggle", "data-open": open, children: [
|
|
3120
3119
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3121
|
-
|
|
3120
|
+
chunkNNDLIP2C_cjs.ToggleChevron,
|
|
3122
3121
|
{
|
|
3123
3122
|
block,
|
|
3124
3123
|
controller,
|
|
@@ -3126,7 +3125,7 @@ var ToggleBlock = ({ block, controller }) => {
|
|
|
3126
3125
|
controls: nested.length === 0 ? void 0 : nested.map(domId).join(" ")
|
|
3127
3126
|
}
|
|
3128
3127
|
),
|
|
3129
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3128
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkNNDLIP2C_cjs.EditableRegion, { block: block.id, region: "text", label: labels.toggle })
|
|
3130
3129
|
] });
|
|
3131
3130
|
};
|
|
3132
3131
|
|
|
@@ -3185,7 +3184,7 @@ function turnIntoTargets(labels) {
|
|
|
3185
3184
|
function TurnIntoItems({ kit, controller, blockIds }) {
|
|
3186
3185
|
const { blockTypes, labels } = useQuoin();
|
|
3187
3186
|
const targets = turnIntoTargets(labels).filter((target) => drawsType(blockTypes, target.type));
|
|
3188
|
-
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, chunk4F2IWBFM_cjs.setBlockType(target.type, target.attrs)), children: [
|
|
3189
3188
|
/* @__PURE__ */ jsxRuntime.jsx(MenuIcon, { icon: target.icon }),
|
|
3190
3189
|
target.label
|
|
3191
3190
|
] }, target.id));
|
|
@@ -3220,10 +3219,10 @@ function ActionItem({ kit, controller, action, blockIds }) {
|
|
|
3220
3219
|
);
|
|
3221
3220
|
}
|
|
3222
3221
|
function BlockMenuItems({ kit, controller, blocks, styled, title, actions }) {
|
|
3223
|
-
const state =
|
|
3222
|
+
const state = chunkNNDLIP2C_cjs.useEditorState(controller, chunkNNDLIP2C_cjs.wholeState);
|
|
3224
3223
|
const blockIds = blocks.map((block) => block.id);
|
|
3225
3224
|
const shown = actions.filter((action) => action.available?.(state, blockIds) ?? true);
|
|
3226
|
-
const anyText = styled.some((block) =>
|
|
3225
|
+
const anyText = styled.some((block) => chunk4F2IWBFM_cjs.isTextFlow(state.schema, block));
|
|
3227
3226
|
const anyMarkdown = styled.some((block) => block.type === "MARKDOWN");
|
|
3228
3227
|
const allCallouts = styled.length > 0 && styled.every((block) => block.type === "CALLOUT");
|
|
3229
3228
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -3265,7 +3264,7 @@ var CONTEXT_KIT = {
|
|
|
3265
3264
|
SubTrigger: ContextMenuSubTrigger
|
|
3266
3265
|
};
|
|
3267
3266
|
var GUTTER_BLOCK = "data-quoin-gutter-block";
|
|
3268
|
-
var OWN_MENU = `[${
|
|
3267
|
+
var OWN_MENU = `[${chunkNNDLIP2C_cjs.NATIVE_INTERACTION}], input, textarea, select`;
|
|
3269
3268
|
function contextBlock(controller, target) {
|
|
3270
3269
|
const { state } = controller.editor;
|
|
3271
3270
|
const gutter = target.closest(`[${GUTTER_BLOCK}]`)?.getAttribute(GUTTER_BLOCK);
|
|
@@ -3274,8 +3273,8 @@ function contextBlock(controller, target) {
|
|
|
3274
3273
|
if (selection?.kind === "blocks") return selection.head;
|
|
3275
3274
|
if (target.closest(OWN_MENU) || controller.registry.locate(target) !== null) return null;
|
|
3276
3275
|
const id = controller.blockAt(target);
|
|
3277
|
-
const block = id === void 0 ? void 0 :
|
|
3278
|
-
return block === void 0 ||
|
|
3276
|
+
const block = id === void 0 ? void 0 : chunkWZA5S5EJ_cjs.blockById(state.doc, id);
|
|
3277
|
+
return block === void 0 || chunk4F2IWBFM_cjs.isTextFlow(state.schema, block) ? null : block.id;
|
|
3279
3278
|
}
|
|
3280
3279
|
function useContextMenuOpener(controller, store, trigger) {
|
|
3281
3280
|
React7.useEffect(() => {
|
|
@@ -3294,7 +3293,7 @@ function useContextMenuOpener(controller, store, trigger) {
|
|
|
3294
3293
|
openBlockMenuAt(store, controller.editor.state, block, clientX, clientY);
|
|
3295
3294
|
hidden.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX, clientY }));
|
|
3296
3295
|
};
|
|
3297
|
-
return
|
|
3296
|
+
return chunkNNDLIP2C_cjs.listen(root, { mousedown: onMouseDown, contextmenu: onContextMenu });
|
|
3298
3297
|
}, [controller, store, trigger]);
|
|
3299
3298
|
}
|
|
3300
3299
|
|
|
@@ -3327,10 +3326,10 @@ var ExtensionBlockNames = React7.createContext({});
|
|
|
3327
3326
|
// src/gutter/use-menu-blocks.ts
|
|
3328
3327
|
function useLiveBlocks(controller, blockIds) {
|
|
3329
3328
|
const select = React7.useCallback(
|
|
3330
|
-
(state) => blockIds.flatMap((id) =>
|
|
3329
|
+
(state) => blockIds.flatMap((id) => chunkWZA5S5EJ_cjs.blockById(state.doc, id) ?? []),
|
|
3331
3330
|
[blockIds]
|
|
3332
3331
|
);
|
|
3333
|
-
return
|
|
3332
|
+
return chunkNNDLIP2C_cjs.useEditorState(controller, select, chunkWZA5S5EJ_cjs.sameItems);
|
|
3334
3333
|
}
|
|
3335
3334
|
function useMenuBlocks(controller, store, menu) {
|
|
3336
3335
|
const labels = useLabels();
|
|
@@ -3383,12 +3382,12 @@ function BlockContextMenu({ controller, store, actions }) {
|
|
|
3383
3382
|
// src/gutter/block-menu-keymap.ts
|
|
3384
3383
|
function blockMenuKeymap(store) {
|
|
3385
3384
|
const openForHead = (state, dispatch) => {
|
|
3386
|
-
const head =
|
|
3385
|
+
const head = chunk4F2IWBFM_cjs.headBlockId(state.selection);
|
|
3387
3386
|
if (head === null || !state.doc.index.has(head)) return false;
|
|
3388
3387
|
if (dispatch) openBlockMenu(store, state, head);
|
|
3389
3388
|
return true;
|
|
3390
3389
|
};
|
|
3391
|
-
return
|
|
3390
|
+
return chunk4F2IWBFM_cjs.defineExtension({ name: "block-menu", keymap: { "Mod-/": openForHead } });
|
|
3392
3391
|
}
|
|
3393
3392
|
var UNIQUE_OR_FOCUSABLE = ["id", "data-block-id", "contenteditable", "tabindex"];
|
|
3394
3393
|
function copyOf(shell) {
|
|
@@ -3457,7 +3456,7 @@ var DragOverlay = React7.forwardRef(function DragOverlay2(_props, ref) {
|
|
|
3457
3456
|
var DELETION_STEPS = /* @__PURE__ */ new Set(["removeBlocks", "setIndent"]);
|
|
3458
3457
|
function drawnPosition(doc, blockId) {
|
|
3459
3458
|
const index = doc.index.get(blockId) ?? 0;
|
|
3460
|
-
return [
|
|
3459
|
+
return [chunkNNDLIP2C_cjs.drawnBlockCount(doc, 0, index) + 1, chunkNNDLIP2C_cjs.drawnBlockCount(doc)];
|
|
3461
3460
|
}
|
|
3462
3461
|
function blockMovedMessage(doc, blockId, labels) {
|
|
3463
3462
|
return labels.blockMoved(...drawnPosition(doc, blockId));
|
|
@@ -3473,11 +3472,11 @@ function deletedCount(tr) {
|
|
|
3473
3472
|
return tr.steps.reduce((deleted, step, i) => {
|
|
3474
3473
|
const { index, count } = step.toJSON();
|
|
3475
3474
|
if (step.stepType !== "removeBlocks" || typeof index !== "number" || typeof count !== "number") return deleted;
|
|
3476
|
-
return deleted +
|
|
3475
|
+
return deleted + chunkNNDLIP2C_cjs.drawnBlockCount(tr.docs[i], index, index + count);
|
|
3477
3476
|
}, 0);
|
|
3478
3477
|
}
|
|
3479
3478
|
function insertedBlock(tr) {
|
|
3480
|
-
if (tr.getMeta(
|
|
3479
|
+
if (tr.getMeta(chunk4F2IWBFM_cjs.LINE_SPLIT) === true || tr.steps.some((step) => step.stepType === "removeBlocks")) return null;
|
|
3481
3480
|
const inserted = tr.steps.flatMap((step) => {
|
|
3482
3481
|
const { blocks } = step.toJSON();
|
|
3483
3482
|
return step.stepType === "insertBlocks" && Array.isArray(blocks) ? blocks : [];
|
|
@@ -3485,7 +3484,7 @@ function insertedBlock(tr) {
|
|
|
3485
3484
|
return inserted.find((block) => tr.doc.index.has(block.id))?.id ?? null;
|
|
3486
3485
|
}
|
|
3487
3486
|
function structureAnnouncement(tr, labels, undoKeys) {
|
|
3488
|
-
if (tr.origin !== "command" || tr.getMeta(
|
|
3487
|
+
if (tr.origin !== "command" || tr.getMeta(chunk4F2IWBFM_cjs.LINE_JOIN) === true) return null;
|
|
3489
3488
|
const moved = movedBlock(tr);
|
|
3490
3489
|
if (moved !== null) return blockMovedMessage(tr.doc, moved, labels);
|
|
3491
3490
|
const deleted = deletedCount(tr);
|
|
@@ -3515,7 +3514,7 @@ function inlineEdges(shell, box, rtl) {
|
|
|
3515
3514
|
function measure(controller, root, moved, rtl) {
|
|
3516
3515
|
const { doc } = controller.editor.state;
|
|
3517
3516
|
const origin = rootOrigin(root);
|
|
3518
|
-
return
|
|
3517
|
+
return chunkNNDLIP2C_cjs.visibleBlockIndexes(doc).flatMap((index) => {
|
|
3519
3518
|
const { id, indent: indent3 } = doc.blocks[index];
|
|
3520
3519
|
const shell = controller.blockElement(id);
|
|
3521
3520
|
if (shell === void 0) return [];
|
|
@@ -3530,7 +3529,7 @@ function measureDrag(controller, root, ids) {
|
|
|
3530
3529
|
const { doc } = controller.editor.state;
|
|
3531
3530
|
const direction = inlineDirection(root);
|
|
3532
3531
|
const rtl = direction === "rtl";
|
|
3533
|
-
const moved = new Set(
|
|
3532
|
+
const moved = new Set(chunk4F2IWBFM_cjs.movedBlockIds(doc, ids));
|
|
3534
3533
|
const blocks = measure(controller, root, moved, rtl);
|
|
3535
3534
|
const dragged = blocks.filter((block) => block.dragged);
|
|
3536
3535
|
if (dragged.length === 0) return null;
|
|
@@ -3590,7 +3589,7 @@ function draggedBlocks(controller, blockId) {
|
|
|
3590
3589
|
function followPress(press, root, view) {
|
|
3591
3590
|
const { controller, store, overlay, handle: handle2, pointerId } = press;
|
|
3592
3591
|
const doc = view.document;
|
|
3593
|
-
const scroll =
|
|
3592
|
+
const scroll = chunkNNDLIP2C_cjs.createAutoScroll(root, follow, SCROLL_EDGE);
|
|
3594
3593
|
let pointer = { x: press.x, y: press.y };
|
|
3595
3594
|
let active = null;
|
|
3596
3595
|
let unsubscribe = () => {
|
|
@@ -3643,7 +3642,7 @@ function followPress(press, root, view) {
|
|
|
3643
3642
|
finish();
|
|
3644
3643
|
if (dropped === null || dropped.target === null || controller.readOnly) return;
|
|
3645
3644
|
const { ids, layout, target } = dropped;
|
|
3646
|
-
if (!controller.run(
|
|
3645
|
+
if (!controller.run(chunk4F2IWBFM_cjs.moveBlocksTo(ids, layout.toIndex(target.index), target.indent))) return;
|
|
3647
3646
|
controller.focus();
|
|
3648
3647
|
press.onMoved(ids[0]);
|
|
3649
3648
|
}
|
|
@@ -3665,9 +3664,9 @@ function followPress(press, root, view) {
|
|
|
3665
3664
|
event.stopPropagation();
|
|
3666
3665
|
finish();
|
|
3667
3666
|
}
|
|
3668
|
-
const unlistenDocument =
|
|
3669
|
-
const unlistenBlur =
|
|
3670
|
-
const unlistenKeys =
|
|
3667
|
+
const unlistenDocument = chunkNNDLIP2C_cjs.listen(doc, { pointermove: onPointerMove, pointerup: onPointerUp, pointercancel: finish });
|
|
3668
|
+
const unlistenBlur = chunkNNDLIP2C_cjs.listen(view, { blur: finish });
|
|
3669
|
+
const unlistenKeys = chunkNNDLIP2C_cjs.listen(view, { keydown: onKeyDown }, true);
|
|
3671
3670
|
return finish;
|
|
3672
3671
|
}
|
|
3673
3672
|
function pressDragHandle(press) {
|
|
@@ -3719,12 +3718,12 @@ function useBlockDrag(controller, store, blockId, overlay) {
|
|
|
3719
3718
|
function addBlockBelow(controller, blockId) {
|
|
3720
3719
|
const { state } = controller.editor;
|
|
3721
3720
|
const { doc, schema } = state;
|
|
3722
|
-
const block =
|
|
3721
|
+
const block = chunkWZA5S5EJ_cjs.blockById(doc, blockId);
|
|
3723
3722
|
if (block === void 0) return false;
|
|
3724
|
-
const empty =
|
|
3725
|
-
const fill = empty ?
|
|
3726
|
-
const slash =
|
|
3727
|
-
const { ok, tr } =
|
|
3723
|
+
const empty = chunk4F2IWBFM_cjs.isParagraph(block) && chunk4F2IWBFM_cjs.regionLength(block, chunk4F2IWBFM_cjs.primaryRegion(schema, block) ?? "") === 0;
|
|
3724
|
+
const fill = empty ? chunk4F2IWBFM_cjs.setSelection(chunk4F2IWBFM_cjs.startOf(doc, schema, blockId)) : chunk4F2IWBFM_cjs.insertBlockAfter("MARKDOWN", { kind: "paragraph" });
|
|
3725
|
+
const slash = chunk4F2IWBFM_cjs.insertText("/", { origin: "command" });
|
|
3726
|
+
const { ok, tr } = chunk4F2IWBFM_cjs.runCommands(state, [chunk4F2IWBFM_cjs.setSelection(chunk4F2IWBFM_cjs.blockRangeSelection(blockId)), fill, slash]);
|
|
3728
3727
|
if (ok && tr !== null) controller.dispatch(tr);
|
|
3729
3728
|
controller.focus();
|
|
3730
3729
|
return ok;
|
|
@@ -3802,7 +3801,7 @@ function place2(controller, root, gutter, block) {
|
|
|
3802
3801
|
gutter.style.visibility = "";
|
|
3803
3802
|
}
|
|
3804
3803
|
function useGutterPosition(controller, gutter, block) {
|
|
3805
|
-
|
|
3804
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
3806
3805
|
const element = gutter.current;
|
|
3807
3806
|
const root = controller.root;
|
|
3808
3807
|
const view = root?.ownerDocument.defaultView;
|
|
@@ -3826,7 +3825,7 @@ function useGutterPosition(controller, gutter, block) {
|
|
|
3826
3825
|
};
|
|
3827
3826
|
}, [controller, gutter, block]);
|
|
3828
3827
|
}
|
|
3829
|
-
var headOf = (state) =>
|
|
3828
|
+
var headOf = (state) => chunk4F2IWBFM_cjs.headBlockId(state.selection);
|
|
3830
3829
|
function blockAcross(controller, root, y) {
|
|
3831
3830
|
const box = root.getBoundingClientRect();
|
|
3832
3831
|
const probe = root.ownerDocument.elementFromPoint?.(box.left + box.width / 2, y);
|
|
@@ -3834,7 +3833,7 @@ function blockAcross(controller, root, y) {
|
|
|
3834
3833
|
}
|
|
3835
3834
|
function useGutterTarget(controller, store, gutter) {
|
|
3836
3835
|
const hovered = useCanvasUi(store, (state) => state.hoveredBlock);
|
|
3837
|
-
const head =
|
|
3836
|
+
const head = chunkNNDLIP2C_cjs.useEditorState(controller, headOf);
|
|
3838
3837
|
const [focusWithin, setFocusWithin] = React7.useState(false);
|
|
3839
3838
|
React7.useEffect(() => {
|
|
3840
3839
|
const root = controller.root;
|
|
@@ -3852,7 +3851,7 @@ function useGutterTarget(controller, store, gutter) {
|
|
|
3852
3851
|
const onFocusIn = () => setFocusWithin(true);
|
|
3853
3852
|
const onFocusOut = (event) => setFocusWithin(root.contains(event.relatedTarget));
|
|
3854
3853
|
setFocusWithin(root.contains(root.ownerDocument.activeElement));
|
|
3855
|
-
return
|
|
3854
|
+
return chunkNNDLIP2C_cjs.listen(root, { pointermove: onPointerMove, pointerleave: onPointerLeave, focusin: onFocusIn, focusout: onFocusOut });
|
|
3856
3855
|
}, [controller, store, gutter]);
|
|
3857
3856
|
const fallback = focusWithin ? head : null;
|
|
3858
3857
|
const target = hovered ?? fallback;
|
|
@@ -3949,7 +3948,7 @@ function pointInHost(host, { node, offset }) {
|
|
|
3949
3948
|
return host.contains(node) ? { node, offset: Math.min(offset, nodeLength(node)) } : null;
|
|
3950
3949
|
}
|
|
3951
3950
|
function textRect(host, { from, to }) {
|
|
3952
|
-
const map =
|
|
3951
|
+
const map = chunkNNDLIP2C_cjs.domMapOf(host);
|
|
3953
3952
|
const range = host.ownerDocument.createRange();
|
|
3954
3953
|
if (map === void 0 || typeof range.getBoundingClientRect !== "function") return null;
|
|
3955
3954
|
const start = pointInHost(host, map.toDom(from, 1));
|
|
@@ -3962,7 +3961,7 @@ function textRect(host, { from, to }) {
|
|
|
3962
3961
|
}
|
|
3963
3962
|
function rangeRect(controller, range) {
|
|
3964
3963
|
const host = controller.registry.get(range.block, range.region);
|
|
3965
|
-
if (host === void 0 || !host.isConnected || controller.composingKey ===
|
|
3964
|
+
if (host === void 0 || !host.isConnected || controller.composingKey === chunkNNDLIP2C_cjs.hostKey(range.block, range.region)) {
|
|
3966
3965
|
return null;
|
|
3967
3966
|
}
|
|
3968
3967
|
const rect = textRect(host, range);
|
|
@@ -3978,7 +3977,7 @@ function union(a, b) {
|
|
|
3978
3977
|
function selectionRect(controller) {
|
|
3979
3978
|
const { state } = controller.editor;
|
|
3980
3979
|
if (state.selection?.kind !== "text") return null;
|
|
3981
|
-
const ranges =
|
|
3980
|
+
const ranges = chunk4F2IWBFM_cjs.markRanges(state);
|
|
3982
3981
|
if (ranges.length === 0) return null;
|
|
3983
3982
|
const first = rangeRect(controller, ranges[0]);
|
|
3984
3983
|
if (ranges.length === 1) return first;
|
|
@@ -3989,7 +3988,7 @@ function selectionRect(controller) {
|
|
|
3989
3988
|
// src/menus/floating/use-selection-anchor.ts
|
|
3990
3989
|
var ROOM_ABOVE = 56;
|
|
3991
3990
|
function selectionHost(controller) {
|
|
3992
|
-
const [first] =
|
|
3991
|
+
const [first] = chunk4F2IWBFM_cjs.markRanges(controller.editor.state);
|
|
3993
3992
|
return (first && controller.registry.get(first.block, first.region)) ?? controller.root ?? void 0;
|
|
3994
3993
|
}
|
|
3995
3994
|
function useSelectionAnchor(controller, state) {
|
|
@@ -4003,7 +4002,7 @@ function useSelectionAnchor(controller, state) {
|
|
|
4003
4002
|
[controller, state]
|
|
4004
4003
|
);
|
|
4005
4004
|
const [side, setSide] = React7.useState("top");
|
|
4006
|
-
|
|
4005
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4007
4006
|
const rect = selectionRect(controller);
|
|
4008
4007
|
if (rect) setSide(rect.top < ROOM_ABOVE ? "bottom" : "top");
|
|
4009
4008
|
}, [controller, state]);
|
|
@@ -4038,9 +4037,9 @@ var ICONS = { left: lucideReact.AlignLeft, center: lucideReact.AlignCenter, righ
|
|
|
4038
4037
|
var ALIGNS2 = Object.keys(ICONS);
|
|
4039
4038
|
var LABEL_KEYS = { left: "alignLeft", center: "alignCenter", right: "alignRight", justify: "alignJustify" };
|
|
4040
4039
|
function sharedAlign(state) {
|
|
4041
|
-
const blocks =
|
|
4040
|
+
const blocks = chunk4F2IWBFM_cjs.selectedBlockIds(state.doc, state.selection).map((id) => chunkWZA5S5EJ_cjs.blockById(state.doc, id)).filter((block) => block?.type === "MARKDOWN");
|
|
4042
4041
|
if (blocks.length === 0) return null;
|
|
4043
|
-
const aligns = new Set(blocks.map((block) =>
|
|
4042
|
+
const aligns = new Set(blocks.map((block) => chunkWZA5S5EJ_cjs.alignOrUndefined(block?.attrs.align) ?? "left"));
|
|
4044
4043
|
return aligns.size === 1 ? [...aligns][0] : "";
|
|
4045
4044
|
}
|
|
4046
4045
|
function AlignDropdown({ controller, state }) {
|
|
@@ -4049,7 +4048,7 @@ function AlignDropdown({ controller, state }) {
|
|
|
4049
4048
|
if (value === null) return null;
|
|
4050
4049
|
const Icon = value === "" ? lucideReact.AlignLeft : ICONS[value];
|
|
4051
4050
|
const trigger = /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.align, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {}) });
|
|
4052
|
-
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(chunk4F2IWBFM_cjs.setTextAlign(align)), children: ALIGNS2.map((align) => /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuRadioItem, { value: align, indicator: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4" }), children: [
|
|
4053
4052
|
/* @__PURE__ */ jsxRuntime.jsx(MenuIcon, { icon: ICONS[align] }),
|
|
4054
4053
|
labels[LABEL_KEYS[align]]
|
|
4055
4054
|
] }, align)) }) });
|
|
@@ -4057,8 +4056,8 @@ function AlignDropdown({ controller, state }) {
|
|
|
4057
4056
|
var MARKS = { color: "color", background: "highlight" };
|
|
4058
4057
|
function selectionColor(state, mark) {
|
|
4059
4058
|
const names = /* @__PURE__ */ new Set();
|
|
4060
|
-
for (const range of
|
|
4061
|
-
for (const node of
|
|
4059
|
+
for (const range of chunk4F2IWBFM_cjs.markRanges(state)) {
|
|
4060
|
+
for (const node of chunk4F2IWBFM_cjs.rangeContent(state, range)) {
|
|
4062
4061
|
const found = node.marks.find((candidate) => candidate.type === mark);
|
|
4063
4062
|
names.add(found === void 0 ? "default" : found.attrs?.color);
|
|
4064
4063
|
}
|
|
@@ -4067,7 +4066,7 @@ function selectionColor(state, mark) {
|
|
|
4067
4066
|
return names.size === 1 && typeof only === "string" ? only : "";
|
|
4068
4067
|
}
|
|
4069
4068
|
function colorCommand(key, name) {
|
|
4070
|
-
return name === "default" ?
|
|
4069
|
+
return name === "default" ? chunk4F2IWBFM_cjs.unsetMark(MARKS[key]) : chunk4F2IWBFM_cjs.setMark(MARKS[key], { color: name });
|
|
4071
4070
|
}
|
|
4072
4071
|
function ColorPopover({ controller, state }) {
|
|
4073
4072
|
const labels = useLabels();
|
|
@@ -4081,11 +4080,11 @@ function TurnIntoDropdown({ controller, state }) {
|
|
|
4081
4080
|
labels.turnInto,
|
|
4082
4081
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {})
|
|
4083
4082
|
] });
|
|
4084
|
-
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: chunk4F2IWBFM_cjs.selectedBlockIds(state.doc, state.selection) }) });
|
|
4085
4084
|
}
|
|
4086
4085
|
var DIVIDER = "mx-0.5 h-5 w-px shrink-0 bg-border";
|
|
4087
4086
|
function BubbleToolbar({ controller, labels, store, extraItems }) {
|
|
4088
|
-
const state =
|
|
4087
|
+
const state = chunkNNDLIP2C_cjs.useEditorState(controller, chunkNNDLIP2C_cjs.wholeState);
|
|
4089
4088
|
const { anchor, side } = useSelectionAnchor(controller, state);
|
|
4090
4089
|
const roving = useRovingFocus();
|
|
4091
4090
|
const items = React7.useMemo(() => bubbleItems(labels, () => store.set({ linkPopover: { open: true } })), [labels, store]);
|
|
@@ -4147,10 +4146,10 @@ function useMediaQuery(query, unsupported) {
|
|
|
4147
4146
|
var useFinePointer = () => useMediaQuery("(pointer: fine)", true);
|
|
4148
4147
|
|
|
4149
4148
|
// src/menus/bubble/use-bubble-visibility.ts
|
|
4150
|
-
var hasTextRange = (state) => state.selection?.kind === "text" && !
|
|
4149
|
+
var hasTextRange = (state) => state.selection?.kind === "text" && !chunk4F2IWBFM_cjs.isCollapsed(state.selection) && chunk4F2IWBFM_cjs.markRanges(state).length > 0;
|
|
4151
4150
|
function useBubbleVisibility(controller) {
|
|
4152
|
-
const range =
|
|
4153
|
-
const readOnly =
|
|
4151
|
+
const range = chunkNNDLIP2C_cjs.useEditorState(controller, hasTextRange);
|
|
4152
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
4154
4153
|
const fine = useFinePointer();
|
|
4155
4154
|
const settled = useSelectionSettled(controller);
|
|
4156
4155
|
return range && !readOnly && fine && settled;
|
|
@@ -4167,16 +4166,16 @@ function BubbleOverlay({ controller }) {
|
|
|
4167
4166
|
return /* @__PURE__ */ jsxRuntime.jsx(BubbleToolbar, { controller, labels, store, extraItems });
|
|
4168
4167
|
}
|
|
4169
4168
|
function bubbleExtension() {
|
|
4170
|
-
return
|
|
4169
|
+
return chunk4F2IWBFM_cjs.defineExtension({ name: "bubble", ui: { overlays: [BubbleOverlay] } });
|
|
4171
4170
|
}
|
|
4172
4171
|
|
|
4173
4172
|
// src/menus/link/link-at-selection.ts
|
|
4174
4173
|
function linkAround(state, from, to = from) {
|
|
4175
4174
|
if (from.block !== to.block || from.region !== to.region) return null;
|
|
4176
|
-
const inline =
|
|
4177
|
-
const extent =
|
|
4175
|
+
const inline = chunkNNDLIP2C_cjs.regionInline(state, from.block, from.region) ?? [];
|
|
4176
|
+
const extent = chunk4F2IWBFM_cjs.markExtent(inline, from.offset, "link");
|
|
4178
4177
|
if (extent === null || to.offset > extent.to) return null;
|
|
4179
|
-
const attrs =
|
|
4178
|
+
const attrs = chunkWZA5S5EJ_cjs.sliceInline(inline, extent.from, extent.to)[0]?.marks.find((mark) => mark.type === "link")?.attrs;
|
|
4180
4179
|
if (attrs?.href === void 0) return null;
|
|
4181
4180
|
const range = { block: from.block, region: from.region, ...extent };
|
|
4182
4181
|
return { href: attrs.href, title: attrs.title || void 0, range };
|
|
@@ -4184,7 +4183,7 @@ function linkAround(state, from, to = from) {
|
|
|
4184
4183
|
function linkAtSelection(state) {
|
|
4185
4184
|
const { selection } = state;
|
|
4186
4185
|
if (selection?.kind !== "text") return null;
|
|
4187
|
-
const { from, to } =
|
|
4186
|
+
const { from, to } = chunk4F2IWBFM_cjs.orderedRange(state.doc, selection.anchor, selection.head);
|
|
4188
4187
|
return linkAround(state, from, to);
|
|
4189
4188
|
}
|
|
4190
4189
|
|
|
@@ -4196,7 +4195,7 @@ function linkElementAt(controller, target) {
|
|
|
4196
4195
|
}
|
|
4197
4196
|
function linkAtElement(controller, state, element) {
|
|
4198
4197
|
const host = controller.registry.locate(element);
|
|
4199
|
-
const offset = host === null ? null :
|
|
4198
|
+
const offset = host === null ? null : chunkNNDLIP2C_cjs.domMapOf(host.element)?.fromDom(element, 0) ?? null;
|
|
4200
4199
|
if (host === null || offset === null) return null;
|
|
4201
4200
|
return linkAround(state, { block: host.block, region: host.region, offset });
|
|
4202
4201
|
}
|
|
@@ -4222,7 +4221,7 @@ function truncateMiddle(text2, max) {
|
|
|
4222
4221
|
// src/menus/link/unlink-range.ts
|
|
4223
4222
|
function unlinkRange({ block, region, from, to }) {
|
|
4224
4223
|
return (state, dispatch) => {
|
|
4225
|
-
const tr = new
|
|
4224
|
+
const tr = new chunk4F2IWBFM_cjs.Transaction(state).step(chunk4F2IWBFM_cjs.removeMarkStep(block, region, from, to, "link"));
|
|
4226
4225
|
if (!tr.docChanged) return false;
|
|
4227
4226
|
dispatch?.(tr);
|
|
4228
4227
|
return true;
|
|
@@ -4244,12 +4243,12 @@ function useRestedValue(value, delay) {
|
|
|
4244
4243
|
// src/menus/link/use-caret-in-link.ts
|
|
4245
4244
|
function caretLinkKey(state) {
|
|
4246
4245
|
const { selection } = state;
|
|
4247
|
-
if (selection?.kind !== "text" || !
|
|
4246
|
+
if (selection?.kind !== "text" || !chunk4F2IWBFM_cjs.isCollapsed(selection)) return null;
|
|
4248
4247
|
const link = linkAtSelection(state);
|
|
4249
4248
|
return link && [link.range.block, link.range.region, link.range.from, link.href].join("\0");
|
|
4250
4249
|
}
|
|
4251
4250
|
function useCaretInLink(controller, delay) {
|
|
4252
|
-
const key =
|
|
4251
|
+
const key = chunkNNDLIP2C_cjs.useEditorState(controller, caretLinkKey);
|
|
4253
4252
|
const settled = useSelectionSettled(controller);
|
|
4254
4253
|
return useRestedValue(settled ? key : null, delay) !== null;
|
|
4255
4254
|
}
|
|
@@ -4283,7 +4282,7 @@ var URL_LENGTH = 48;
|
|
|
4283
4282
|
var CARD = "flex w-auto items-center gap-0.5 py-1 ps-3 pe-1 shadow-md";
|
|
4284
4283
|
var ADDRESS = "me-1 whitespace-nowrap text-sm text-muted-foreground";
|
|
4285
4284
|
function LinkCard({ controller, labels, store, cardRef, element, onUnlinked }) {
|
|
4286
|
-
const state =
|
|
4285
|
+
const state = chunkNNDLIP2C_cjs.useEditorState(controller, chunkNNDLIP2C_cjs.wholeState);
|
|
4287
4286
|
const link = React7.useMemo(
|
|
4288
4287
|
() => element === null ? linkAtSelection(state) : linkAtElement(controller, state, element),
|
|
4289
4288
|
[controller, state, element]
|
|
@@ -4296,12 +4295,12 @@ function LinkCard({ controller, labels, store, cardRef, element, onUnlinked }) {
|
|
|
4296
4295
|
}, [controller, link]);
|
|
4297
4296
|
if (link === null) return null;
|
|
4298
4297
|
const { block, region, from, to } = link.range;
|
|
4299
|
-
const href =
|
|
4298
|
+
const href = chunkWZA5S5EJ_cjs.sanitizeHref(link.href);
|
|
4300
4299
|
const address = truncateMiddle(link.href, URL_LENGTH);
|
|
4301
4300
|
const edit2 = () => {
|
|
4302
4301
|
if (element !== null) {
|
|
4303
|
-
const selection =
|
|
4304
|
-
|
|
4302
|
+
const selection = chunk4F2IWBFM_cjs.textSelection({ block, region, offset: from }, { block, region, offset: to });
|
|
4303
|
+
chunkNNDLIP2C_cjs.dispatchSelection(controller, selection);
|
|
4305
4304
|
}
|
|
4306
4305
|
store.set({ linkPopover: { open: true } });
|
|
4307
4306
|
};
|
|
@@ -4343,12 +4342,12 @@ function LinkHoverCard(props) {
|
|
|
4343
4342
|
|
|
4344
4343
|
// src/menus/link/apply-link.ts
|
|
4345
4344
|
function insertLinkedText(value, href, caret) {
|
|
4346
|
-
const safe =
|
|
4345
|
+
const safe = chunkWZA5S5EJ_cjs.sanitizeHref(href);
|
|
4347
4346
|
return (state, dispatch) => {
|
|
4348
4347
|
if (!safe) return false;
|
|
4349
4348
|
const link = { type: "link", attrs: { href: safe } };
|
|
4350
|
-
const marks =
|
|
4351
|
-
const tr = new
|
|
4349
|
+
const marks = chunkWZA5S5EJ_cjs.addMark(chunk4F2IWBFM_cjs.caretMarks(state.doc, state.schema, state.storedMarks, caret), link);
|
|
4350
|
+
const tr = new chunk4F2IWBFM_cjs.Transaction(state).step(chunk4F2IWBFM_cjs.replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [chunkWZA5S5EJ_cjs.text(value, marks)])).setSelection(chunk4F2IWBFM_cjs.textSelection({ ...caret, offset: caret.offset + value.length }));
|
|
4352
4351
|
dispatch?.(tr);
|
|
4353
4352
|
return true;
|
|
4354
4353
|
};
|
|
@@ -4357,10 +4356,10 @@ function applyLink(href, value) {
|
|
|
4357
4356
|
return (state, dispatch) => {
|
|
4358
4357
|
const { selection } = state;
|
|
4359
4358
|
const link = linkAtSelection(state);
|
|
4360
|
-
if (selection?.kind === "text" &&
|
|
4359
|
+
if (selection?.kind === "text" && chunk4F2IWBFM_cjs.isCollapsed(selection) && link === null) {
|
|
4361
4360
|
return insertLinkedText(value, href, selection.head)(state, dispatch);
|
|
4362
4361
|
}
|
|
4363
|
-
return
|
|
4362
|
+
return chunk4F2IWBFM_cjs.setLink(href, link?.title)(state, dispatch);
|
|
4364
4363
|
};
|
|
4365
4364
|
}
|
|
4366
4365
|
var CONTENT2 = "w-80 p-2 shadow-md";
|
|
@@ -4371,7 +4370,7 @@ function popoverAnchor(controller, link) {
|
|
|
4371
4370
|
if (selection?.kind !== "text") return null;
|
|
4372
4371
|
const { block, region, offset } = selection.head;
|
|
4373
4372
|
const caret = link?.range ?? { block, region, from: offset, to: offset };
|
|
4374
|
-
const collapsed =
|
|
4373
|
+
const collapsed = chunk4F2IWBFM_cjs.isCollapsed(selection);
|
|
4375
4374
|
return virtualAnchor(
|
|
4376
4375
|
() => collapsed ? rangeRect(controller, caret) : selectionRect(controller),
|
|
4377
4376
|
() => controller.registry.get(block, region)
|
|
@@ -4383,7 +4382,7 @@ function LinkPopover({ controller, labels, onClose }) {
|
|
|
4383
4382
|
const [invalid, setInvalid] = React7.useState(false);
|
|
4384
4383
|
const messageId = React7.useId();
|
|
4385
4384
|
const anchor = React7.useMemo(() => ({ current: popoverAnchor(controller, link) }), [controller, link]);
|
|
4386
|
-
const openHref = link &&
|
|
4385
|
+
const openHref = link && chunkWZA5S5EJ_cjs.sanitizeHref(link.href);
|
|
4387
4386
|
const backToText = () => {
|
|
4388
4387
|
onClose();
|
|
4389
4388
|
controller.focus();
|
|
@@ -4400,7 +4399,7 @@ function LinkPopover({ controller, labels, onClose }) {
|
|
|
4400
4399
|
backToText();
|
|
4401
4400
|
};
|
|
4402
4401
|
const remove = () => {
|
|
4403
|
-
controller.run(
|
|
4402
|
+
controller.run(chunk4F2IWBFM_cjs.unsetLink);
|
|
4404
4403
|
backToText();
|
|
4405
4404
|
};
|
|
4406
4405
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4468,7 +4467,7 @@ function LinkOverlay({ controller }) {
|
|
|
4468
4467
|
const labels = useLabels();
|
|
4469
4468
|
const store = useCanvasUiStore();
|
|
4470
4469
|
const popoverOpen = useCanvasUi(store, isPopoverOpen);
|
|
4471
|
-
const readOnly =
|
|
4470
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
4472
4471
|
useLinkClicks(controller);
|
|
4473
4472
|
React7.useEffect(() => {
|
|
4474
4473
|
if (readOnly && store.get().linkPopover.open) store.set({ linkPopover: { open: false } });
|
|
@@ -4483,7 +4482,7 @@ function linkExtension(store) {
|
|
|
4483
4482
|
if (dispatch) store.set({ linkPopover: { open: true } });
|
|
4484
4483
|
return true;
|
|
4485
4484
|
};
|
|
4486
|
-
return
|
|
4485
|
+
return chunk4F2IWBFM_cjs.defineExtension({ name: "link", keymap: { "Mod-k": openPopover }, ui: { overlays: [LinkOverlay] } });
|
|
4487
4486
|
}
|
|
4488
4487
|
|
|
4489
4488
|
// src/menus/suggestion/find-trigger.ts
|
|
@@ -4491,7 +4490,7 @@ var DEFAULT_MAX_LENGTH = 40;
|
|
|
4491
4490
|
var NO_TRIGGER_TYPES = /* @__PURE__ */ new Set(["CODE", "TABLE"]);
|
|
4492
4491
|
var WHITESPACE2 = /\s/;
|
|
4493
4492
|
var ATOM = "\uFFFC";
|
|
4494
|
-
var hasCode = (inline) => inline.some((node) =>
|
|
4493
|
+
var hasCode = (inline) => inline.some((node) => chunkWZA5S5EJ_cjs.hasMark(node.marks, "code"));
|
|
4495
4494
|
function triggerOffset(text2, start, config) {
|
|
4496
4495
|
const { char, allowSpaces = false, startOfLine = false } = config;
|
|
4497
4496
|
const earliest = Math.max(0, text2.length - (config.maxLength ?? DEFAULT_MAX_LENGTH) - 1);
|
|
@@ -4508,15 +4507,15 @@ function triggerOffset(text2, start, config) {
|
|
|
4508
4507
|
}
|
|
4509
4508
|
function findTrigger(state, config) {
|
|
4510
4509
|
const { doc, selection } = state;
|
|
4511
|
-
if (selection?.kind !== "text" || !
|
|
4510
|
+
if (selection?.kind !== "text" || !chunk4F2IWBFM_cjs.isCollapsed(selection)) return null;
|
|
4512
4511
|
const { block: blockId, region, offset: caret } = selection.head;
|
|
4513
|
-
const block =
|
|
4512
|
+
const block = chunkWZA5S5EJ_cjs.blockById(doc, blockId);
|
|
4514
4513
|
if (block === void 0 || NO_TRIGGER_TYPES.has(block.type) || !Object.hasOwn(block.regions, region)) return null;
|
|
4515
4514
|
const inline = block.regions[region];
|
|
4516
4515
|
const start = Math.max(0, caret - (config.maxLength ?? DEFAULT_MAX_LENGTH) - 2);
|
|
4517
|
-
const from = triggerOffset(
|
|
4518
|
-
if (from === null || hasCode(
|
|
4519
|
-
const query =
|
|
4516
|
+
const from = triggerOffset(chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.sliceInline(inline, start, caret)), start, config);
|
|
4517
|
+
if (from === null || hasCode(chunkWZA5S5EJ_cjs.sliceInline(inline, from, caret))) return null;
|
|
4518
|
+
const query = chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.sliceInline(inline, from + 1, caret));
|
|
4520
4519
|
return { block: blockId, region, from, to: caret, query };
|
|
4521
4520
|
}
|
|
4522
4521
|
|
|
@@ -4546,7 +4545,7 @@ function suggestionPlugin(key, config) {
|
|
|
4546
4545
|
init: (state) => ({ active: nearest(state, findTrigger(state, config)), dismissedAt: null }),
|
|
4547
4546
|
apply(tr, value, oldState, newState) {
|
|
4548
4547
|
const dismissing = tr.getMeta(DISMISS) === key.name;
|
|
4549
|
-
if (!dismissing && !tr.docChanged &&
|
|
4548
|
+
if (!dismissing && !tr.docChanged && chunk4F2IWBFM_cjs.sameSelection(oldState.selection, newState.selection)) return value;
|
|
4550
4549
|
const found = findTrigger(newState, config);
|
|
4551
4550
|
let dismissedAt = null;
|
|
4552
4551
|
if (dismissing) dismissedAt = found && rangeOf2(found);
|
|
@@ -4563,14 +4562,14 @@ function suggestionPlugin(key, config) {
|
|
|
4563
4562
|
}
|
|
4564
4563
|
function dismissSuggestion(key) {
|
|
4565
4564
|
return (state, dispatch) => {
|
|
4566
|
-
if (
|
|
4567
|
-
dispatch?.(new
|
|
4565
|
+
if (chunk4F2IWBFM_cjs.getPluginState(state, key).active === null) return false;
|
|
4566
|
+
dispatch?.(new chunk4F2IWBFM_cjs.Transaction(state).setMeta(DISMISS, key.name));
|
|
4568
4567
|
return true;
|
|
4569
4568
|
};
|
|
4570
4569
|
}
|
|
4571
4570
|
|
|
4572
4571
|
// src/menus/slash/slash-key.ts
|
|
4573
|
-
var slashKey =
|
|
4572
|
+
var slashKey = chunk4F2IWBFM_cjs.createPluginKey("slash");
|
|
4574
4573
|
var DETAILS = {
|
|
4575
4574
|
text: { group: "basic", keywords: ["paragraph", "plain"], shortcut: "Mod-Alt-0" },
|
|
4576
4575
|
heading1: { group: "basic", keywords: ["h1", "title", "#"], shortcut: "Mod-Alt-1" },
|
|
@@ -4618,7 +4617,7 @@ function initialBlock({ schema }, definition, onError) {
|
|
|
4618
4617
|
const data = chunkA6PGQVTR_cjs.seedData(definition, onError());
|
|
4619
4618
|
if (data === null) return null;
|
|
4620
4619
|
if (data === void 0) return { type };
|
|
4621
|
-
return { type, ...
|
|
4620
|
+
return { type, ...chunkWZA5S5EJ_cjs.specFor(schema, type).fromData(data, chunkWZA5S5EJ_cjs.createBlockCodec(schema).context) };
|
|
4622
4621
|
}
|
|
4623
4622
|
var refuse = () => false;
|
|
4624
4623
|
function blockTypeSlashItems(definitions, onError = () => void 0) {
|
|
@@ -4646,10 +4645,10 @@ function useRangeAnchor(controller, range) {
|
|
|
4646
4645
|
const [side, setSide] = React7.useState("bottom");
|
|
4647
4646
|
const latest = React7.useRef(range);
|
|
4648
4647
|
const start = range === null ? null : `${range.block} ${range.region} ${range.from}`;
|
|
4649
|
-
|
|
4648
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4650
4649
|
latest.current = range;
|
|
4651
4650
|
});
|
|
4652
|
-
|
|
4651
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4653
4652
|
const rect = latest.current && rangeRect(controller, latest.current);
|
|
4654
4653
|
if (rect) setSide(sideFor(rect, window.innerHeight));
|
|
4655
4654
|
}, [controller, start]);
|
|
@@ -4675,11 +4674,11 @@ function openCombobox(host, listboxId) {
|
|
|
4675
4674
|
}
|
|
4676
4675
|
function useComboboxHost(controller, block, region, listboxId, activeOptionId) {
|
|
4677
4676
|
const host = React7.useRef(null);
|
|
4678
|
-
|
|
4677
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4679
4678
|
host.current = block === null || region === null ? null : controller.registry.get(block, region) ?? null;
|
|
4680
4679
|
return host.current === null ? void 0 : openCombobox(host.current, listboxId);
|
|
4681
4680
|
}, [controller, block, region, listboxId]);
|
|
4682
|
-
|
|
4681
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4683
4682
|
if (host.current !== null) restore(host.current, "aria-activedescendant", activeOptionId);
|
|
4684
4683
|
}, [block, region, activeOptionId]);
|
|
4685
4684
|
}
|
|
@@ -4725,10 +4724,10 @@ function handle(event, menu) {
|
|
|
4725
4724
|
}
|
|
4726
4725
|
function useSuggestionKeys(controller, open, menu) {
|
|
4727
4726
|
const latest = React7.useRef(menu);
|
|
4728
|
-
|
|
4727
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4729
4728
|
latest.current = menu;
|
|
4730
4729
|
});
|
|
4731
|
-
|
|
4730
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4732
4731
|
if (!open) return;
|
|
4733
4732
|
const intercept = (event) => {
|
|
4734
4733
|
const handled = handle(event, latest.current);
|
|
@@ -4749,10 +4748,10 @@ var isPromise = (value) => typeof value?.then === "function";
|
|
|
4749
4748
|
function useSuggestionResults(source, query, onError) {
|
|
4750
4749
|
const [answer, setAnswer] = React7.useState(FORGOTTEN);
|
|
4751
4750
|
const report = React7.useRef(onError);
|
|
4752
|
-
|
|
4751
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4753
4752
|
report.current = onError;
|
|
4754
4753
|
});
|
|
4755
|
-
|
|
4754
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4756
4755
|
if (query === null) {
|
|
4757
4756
|
setAnswer(FORGOTTEN);
|
|
4758
4757
|
return;
|
|
@@ -4796,9 +4795,9 @@ function useSuggestion({
|
|
|
4796
4795
|
emptyLabel
|
|
4797
4796
|
}) {
|
|
4798
4797
|
const { labels, onError } = useQuoin();
|
|
4799
|
-
const readOnly =
|
|
4800
|
-
const selectTrigger = React7.useCallback((state) =>
|
|
4801
|
-
const active =
|
|
4798
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
4799
|
+
const selectTrigger = React7.useCallback((state) => chunk4F2IWBFM_cjs.getPluginState(state, pluginKey).active, [pluginKey]);
|
|
4800
|
+
const active = chunkNNDLIP2C_cjs.useEditorState(controller, selectTrigger);
|
|
4802
4801
|
const trigger = readOnly ? null : active;
|
|
4803
4802
|
const results = useSuggestionResults(source, trigger?.query ?? null, onError);
|
|
4804
4803
|
const sections = React7.useMemo(() => groupItems(results.items, groupOf2), [results.items, groupOf2]);
|
|
@@ -4820,7 +4819,7 @@ function useSuggestion({
|
|
|
4820
4819
|
);
|
|
4821
4820
|
const select = React7.useCallback(
|
|
4822
4821
|
(index) => {
|
|
4823
|
-
const current =
|
|
4822
|
+
const current = chunk4F2IWBFM_cjs.getPluginState(controller.editor.state, pluginKey).active;
|
|
4824
4823
|
if (current !== null && index < ordered.length) onSelect(ordered[index], rangeOf2(current));
|
|
4825
4824
|
},
|
|
4826
4825
|
[controller, pluginKey, ordered, onSelect]
|
|
@@ -4868,7 +4867,7 @@ function SuggestionMenu(props) {
|
|
|
4868
4867
|
const { trigger, sections, activeIndex, listboxId } = suggestion;
|
|
4869
4868
|
const { anchor, side } = useRangeAnchor(controller, trigger);
|
|
4870
4869
|
const listbox = React7.useRef(null);
|
|
4871
|
-
|
|
4870
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
4872
4871
|
listbox.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
4873
4872
|
}, [activeIndex, sections]);
|
|
4874
4873
|
if (trigger === null) return null;
|
|
@@ -4927,14 +4926,14 @@ function SuggestionMenu(props) {
|
|
|
4927
4926
|
// src/menus/suggestion/replace-trigger.ts
|
|
4928
4927
|
function deleteTrigger({ block, region, from, to }) {
|
|
4929
4928
|
return (state, dispatch) => {
|
|
4930
|
-
const tr = new
|
|
4931
|
-
if (from >= to || !tr.maybeStep(
|
|
4932
|
-
dispatch?.(tr.setSelection(
|
|
4929
|
+
const tr = new chunk4F2IWBFM_cjs.Transaction(state);
|
|
4930
|
+
if (from >= to || !tr.maybeStep(chunk4F2IWBFM_cjs.replaceInlineStep(block, region, from, to, []))) return false;
|
|
4931
|
+
dispatch?.(tr.setSelection(chunk4F2IWBFM_cjs.textSelection({ block, region, offset: from })));
|
|
4933
4932
|
return true;
|
|
4934
4933
|
};
|
|
4935
4934
|
}
|
|
4936
4935
|
function triggerReplacement(state, range, command) {
|
|
4937
|
-
return
|
|
4936
|
+
return chunk4F2IWBFM_cjs.runCommands(state, command === void 0 ? [deleteTrigger(range)] : [deleteTrigger(range), command]);
|
|
4938
4937
|
}
|
|
4939
4938
|
function replaceTrigger(controller, range, command) {
|
|
4940
4939
|
const { ok, tr } = triggerReplacement(controller.editor.state, range, command);
|
|
@@ -4947,9 +4946,9 @@ var TEXT_STEPS = /* @__PURE__ */ new Set(["replaceInline", "addMark", "removeMar
|
|
|
4947
4946
|
var WHITESPACE3 = /\s/;
|
|
4948
4947
|
var changesBlocks = (tr) => tr !== null && tr.steps.some((step) => !TEXT_STEPS.has(step.stepType));
|
|
4949
4948
|
function withSpaceBefore(state, range) {
|
|
4950
|
-
const inline =
|
|
4949
|
+
const inline = chunkNNDLIP2C_cjs.regionInline(state, range.block, range.region);
|
|
4951
4950
|
if (inline === void 0 || range.from === 0) return null;
|
|
4952
|
-
const text2 =
|
|
4951
|
+
const text2 = chunkWZA5S5EJ_cjs.inlineText(inline);
|
|
4953
4952
|
const after = text2.charAt(range.to);
|
|
4954
4953
|
const spaced = text2.charAt(range.from - 1) === " " && (after === "" || WHITESPACE3.test(after));
|
|
4955
4954
|
return spaced ? { ...range, from: range.from - 1 } : null;
|
|
@@ -5054,7 +5053,7 @@ function SlashOverlay({ controller }) {
|
|
|
5054
5053
|
return /* @__PURE__ */ jsxRuntime.jsx(SlashMenu, { controller, labels, items });
|
|
5055
5054
|
}
|
|
5056
5055
|
function slashExtension() {
|
|
5057
|
-
return
|
|
5056
|
+
return chunk4F2IWBFM_cjs.defineExtension({
|
|
5058
5057
|
name: "slash",
|
|
5059
5058
|
plugins: [suggestionPlugin(slashKey, { char: "/" })],
|
|
5060
5059
|
ui: { overlays: [SlashOverlay] }
|
|
@@ -5064,7 +5063,7 @@ function commandItem(id, title, icon, command) {
|
|
|
5064
5063
|
return { id, title, icon, run: (controller) => void controller.run(command) };
|
|
5065
5064
|
}
|
|
5066
5065
|
function addBlockAtCaret(controller) {
|
|
5067
|
-
const block =
|
|
5066
|
+
const block = chunk4F2IWBFM_cjs.headBlockId(controller.editor.state.selection);
|
|
5068
5067
|
if (block !== null) addBlockBelow(controller, block);
|
|
5069
5068
|
}
|
|
5070
5069
|
function mobileItems(labels, openLink) {
|
|
@@ -5076,10 +5075,10 @@ function mobileItems(labels, openLink) {
|
|
|
5076
5075
|
markItem("strike", labels.strike, lucideReact.Strikethrough),
|
|
5077
5076
|
markItem("code", labels.code, lucideReact.Code),
|
|
5078
5077
|
linkItem(labels, openLink),
|
|
5079
|
-
commandItem("indent", labels.indent, lucideReact.ListIndentIncrease,
|
|
5080
|
-
commandItem("outdent", labels.outdent, lucideReact.ListIndentDecrease,
|
|
5081
|
-
commandItem("undo", labels.undo, lucideReact.Undo2,
|
|
5082
|
-
commandItem("redo", labels.redo, lucideReact.Redo2,
|
|
5078
|
+
commandItem("indent", labels.indent, lucideReact.ListIndentIncrease, chunk4F2IWBFM_cjs.indent),
|
|
5079
|
+
commandItem("outdent", labels.outdent, lucideReact.ListIndentDecrease, chunk4F2IWBFM_cjs.outdent),
|
|
5080
|
+
commandItem("undo", labels.undo, lucideReact.Undo2, chunk4F2IWBFM_cjs.undo),
|
|
5081
|
+
commandItem("redo", labels.redo, lucideReact.Redo2, chunk4F2IWBFM_cjs.redo)
|
|
5083
5082
|
]
|
|
5084
5083
|
};
|
|
5085
5084
|
}
|
|
@@ -5133,7 +5132,7 @@ function placement(viewport) {
|
|
|
5133
5132
|
function EditingTools({ controller }) {
|
|
5134
5133
|
const labels = useLabels();
|
|
5135
5134
|
const store = useCanvasUiStore();
|
|
5136
|
-
const state =
|
|
5135
|
+
const state = chunkNNDLIP2C_cjs.useEditorState(controller, chunkNNDLIP2C_cjs.wholeState);
|
|
5137
5136
|
const viewport = useVisualViewport();
|
|
5138
5137
|
const roving = useRovingFocus();
|
|
5139
5138
|
const items = React7.useMemo(() => mobileItems(labels, () => store.set({ linkPopover: { open: true } })), [labels, store]);
|
|
@@ -5390,7 +5389,7 @@ function shortcutsExtension(store) {
|
|
|
5390
5389
|
if (dispatch) store.set({ shortcutsOpen: true });
|
|
5391
5390
|
return true;
|
|
5392
5391
|
};
|
|
5393
|
-
return
|
|
5392
|
+
return chunk4F2IWBFM_cjs.defineExtension({
|
|
5394
5393
|
name: "shortcuts",
|
|
5395
5394
|
keymap: { [SHORTCUT]: open, "Mod-Shift-?": open },
|
|
5396
5395
|
ui: { overlays: [ShortcutsOverlay] }
|
|
@@ -5424,16 +5423,16 @@ function writeBlockData(controller, blockId, data) {
|
|
|
5424
5423
|
const index = doc.index.get(blockId);
|
|
5425
5424
|
if (index === void 0) return;
|
|
5426
5425
|
const block = doc.blocks[index];
|
|
5427
|
-
const { attrs, regions } =
|
|
5428
|
-
if (
|
|
5429
|
-
const tr = editor.createTransaction().step(
|
|
5430
|
-
editor.dispatch(tr.setMeta(
|
|
5426
|
+
const { attrs, regions } = chunkWZA5S5EJ_cjs.specFor(schema, block.type).fromData(data, editor.codec.context);
|
|
5427
|
+
if (chunkWZA5S5EJ_cjs.sameValue(attrs, block.attrs) && chunkWZA5S5EJ_cjs.sameValue(regions, block.regions)) return;
|
|
5428
|
+
const tr = editor.createTransaction().step(chunk4F2IWBFM_cjs.replaceBlockStep({ ...block, attrs, regions }));
|
|
5429
|
+
editor.dispatch(tr.setMeta(chunk4F2IWBFM_cjs.HISTORY_GROUP, `block-data:${blockId}`));
|
|
5431
5430
|
}
|
|
5432
5431
|
function insertAfterBlock(controller, blockId, type, definitions, onError) {
|
|
5433
5432
|
const editor = internal(controller);
|
|
5434
5433
|
const data = chunkA6PGQVTR_cjs.seedData(chunkA6PGQVTR_cjs.blockByType(definitions, type), onError);
|
|
5435
5434
|
if (data === null) return false;
|
|
5436
|
-
const content = data &&
|
|
5435
|
+
const content = data && chunkWZA5S5EJ_cjs.specFor(editor.state.schema, type).fromData(data, editor.codec.context);
|
|
5437
5436
|
controller.run(insertBlockToWrite({ type, ...content }, opensEditor(definitions, type), blockId));
|
|
5438
5437
|
return true;
|
|
5439
5438
|
}
|
|
@@ -5457,7 +5456,7 @@ function runHistoryKey(controller, event) {
|
|
|
5457
5456
|
}
|
|
5458
5457
|
function useBlockIndex(controller, blockId) {
|
|
5459
5458
|
const select = React7.useCallback((state) => state.doc.index.get(blockId) ?? -1, [blockId]);
|
|
5460
|
-
return
|
|
5459
|
+
return chunkNNDLIP2C_cjs.useEditorState(controller, select);
|
|
5461
5460
|
}
|
|
5462
5461
|
var FOCUSABLE = [
|
|
5463
5462
|
"input:not([disabled])",
|
|
@@ -5484,8 +5483,8 @@ function useEditingFocus(root, editing, stop) {
|
|
|
5484
5483
|
const leaveUnlessInside = (event) => {
|
|
5485
5484
|
if (!inside.current.has(event)) stop();
|
|
5486
5485
|
};
|
|
5487
|
-
const unlistenCapture =
|
|
5488
|
-
const unlisten =
|
|
5486
|
+
const unlistenCapture = chunkNNDLIP2C_cjs.listen(doc, { pointerdown: leaveForCanvas }, true);
|
|
5487
|
+
const unlisten = chunkNNDLIP2C_cjs.listen(doc, { pointerdown: leaveUnlessInside, focusin: leaveUnlessInside });
|
|
5489
5488
|
return () => {
|
|
5490
5489
|
unlistenCapture();
|
|
5491
5490
|
unlisten();
|
|
@@ -5514,8 +5513,8 @@ function VoidEditor({ Editor, controller, ...props }) {
|
|
|
5514
5513
|
}
|
|
5515
5514
|
function VoidBlock({ block, controller, definition }) {
|
|
5516
5515
|
const { blockTypes, labels } = useQuoin();
|
|
5517
|
-
const { report } = React7.useContext(
|
|
5518
|
-
const readOnly =
|
|
5516
|
+
const { report } = React7.useContext(chunkNNDLIP2C_cjs.BlockErrorContext);
|
|
5517
|
+
const readOnly = chunkNNDLIP2C_cjs.useReadOnly(controller);
|
|
5519
5518
|
const { editor: Editor, alwaysEditing = false } = definition;
|
|
5520
5519
|
const name = blockTypeLabel(labels, block, blockTypes);
|
|
5521
5520
|
const blockId = block.id;
|
|
@@ -5579,7 +5578,7 @@ function VoidBlock({ block, controller, definition }) {
|
|
|
5579
5578
|
role: "group",
|
|
5580
5579
|
"aria-label": name,
|
|
5581
5580
|
tabIndex: editorShown ? -1 : void 0,
|
|
5582
|
-
...{ [
|
|
5581
|
+
...{ [chunkNNDLIP2C_cjs.NATIVE_INTERACTION]: editorShown ? "" : void 0 },
|
|
5583
5582
|
onKeyDown,
|
|
5584
5583
|
...focusHandlers,
|
|
5585
5584
|
onClick,
|
|
@@ -5675,12 +5674,12 @@ function collectUi(extensions, definitions, readOnly = false, onError) {
|
|
|
5675
5674
|
|
|
5676
5675
|
// src/canvas/insert-uploads.ts
|
|
5677
5676
|
function fileBlock(file, stored) {
|
|
5678
|
-
if (isImageFile(file)) return { id:
|
|
5677
|
+
if (isImageFile(file)) return { id: chunkWZA5S5EJ_cjs.newId(), type: "IMAGE", attrs: { storageKey: stored.storageKey, alt: "" } };
|
|
5679
5678
|
return { type: "FILE", attrs: fileAttrs(file, stored) };
|
|
5680
5679
|
}
|
|
5681
5680
|
function anchorBlock(controller, at) {
|
|
5682
5681
|
const { doc, selection } = controller.editor.state;
|
|
5683
|
-
const candidates = [at?.block,
|
|
5682
|
+
const candidates = [at?.block, chunk4F2IWBFM_cjs.headBlockId(selection), doc.blocks[doc.blocks.length - 1]?.id];
|
|
5684
5683
|
return candidates.find((id) => typeof id === "string" && doc.index.has(id)) ?? null;
|
|
5685
5684
|
}
|
|
5686
5685
|
var writerOf = (controller) => ({
|
|
@@ -5689,7 +5688,7 @@ var writerOf = (controller) => ({
|
|
|
5689
5688
|
});
|
|
5690
5689
|
function movedOn(controller, before) {
|
|
5691
5690
|
const now = writerOf(controller);
|
|
5692
|
-
return now.focus !== before.focus || !
|
|
5691
|
+
return now.focus !== before.focus || !chunk4F2IWBFM_cjs.sameSelection(now.selection, before.selection);
|
|
5693
5692
|
}
|
|
5694
5693
|
async function insertUploads(controller, files, at, { upload, resolveAssetUrl, onError, unavailable, failed }) {
|
|
5695
5694
|
if (!upload) return onError(new Error(unavailable));
|
|
@@ -5717,15 +5716,15 @@ function holdsHead({ selection }, block) {
|
|
|
5717
5716
|
}
|
|
5718
5717
|
function markdownPlaceholder(state, block, labels) {
|
|
5719
5718
|
const { kind, level } = block.attrs;
|
|
5720
|
-
if (kind === "heading") return labels.placeholderHeading(
|
|
5719
|
+
if (kind === "heading") return labels.placeholderHeading(chunkWZA5S5EJ_cjs.headingLevel(level));
|
|
5721
5720
|
if (LIST_KINDS.has(kind)) return labels.placeholderList;
|
|
5722
5721
|
if (kind === "quote") return labels.placeholderQuote;
|
|
5723
5722
|
if (kind !== "paragraph") return void 0;
|
|
5724
5723
|
return holdsHead(state, block) || state.doc.blocks.length === 1 ? labels.placeholderEmpty : void 0;
|
|
5725
5724
|
}
|
|
5726
5725
|
function placeholderFor(state, block, labels) {
|
|
5727
|
-
const region =
|
|
5728
|
-
if (region === null ||
|
|
5726
|
+
const region = chunk4F2IWBFM_cjs.primaryRegion(state.schema, block);
|
|
5727
|
+
if (region === null || chunk4F2IWBFM_cjs.regionLength(block, region) > 0) return void 0;
|
|
5729
5728
|
switch (block.type) {
|
|
5730
5729
|
case "MARKDOWN":
|
|
5731
5730
|
return markdownPlaceholder(state, block, labels);
|
|
@@ -5746,13 +5745,13 @@ function firstLine2(text2) {
|
|
|
5746
5745
|
}
|
|
5747
5746
|
var selectedBlockLabel = (labels, definitions, extensionNames) => (block, schema) => {
|
|
5748
5747
|
const { attrs } = block;
|
|
5749
|
-
if (block.type === "IMAGE") return hasPicture(attrs) ?
|
|
5748
|
+
if (block.type === "IMAGE") return hasPicture(attrs) ? chunkWZA5S5EJ_cjs.str(attrs.alt) || labels.imageNoAlt : labels.emptyImage;
|
|
5750
5749
|
if (block.type === "CODE") {
|
|
5751
|
-
const language2 =
|
|
5750
|
+
const language2 = chunkWZA5S5EJ_cjs.str(attrs.language);
|
|
5752
5751
|
return labels.codeBlockName(languageName(language2) ?? (language2 || labels.plainText));
|
|
5753
5752
|
}
|
|
5754
5753
|
if (block.type === "FILE" && hasFile(attrs)) return labels.fileBlockName(firstLine2(fileName(attrs)));
|
|
5755
|
-
return firstLine2(
|
|
5754
|
+
return firstLine2(chunkWZA5S5EJ_cjs.blockPlainText(block, schema)) || blockTypeLabel(labels, block, definitions, extensionNames);
|
|
5756
5755
|
};
|
|
5757
5756
|
function revealLinkedBlock(controller, hash) {
|
|
5758
5757
|
const id = linkedBlockId(hash);
|
|
@@ -5760,7 +5759,7 @@ function revealLinkedBlock(controller, hash) {
|
|
|
5760
5759
|
if (id === null || shell === void 0) return false;
|
|
5761
5760
|
const { editor } = controller;
|
|
5762
5761
|
const { doc, schema } = editor.state;
|
|
5763
|
-
editor.dispatch(editor.createTransaction().setSelection(
|
|
5762
|
+
editor.dispatch(editor.createTransaction().setSelection(chunk4F2IWBFM_cjs.startOf(doc, schema, id)));
|
|
5764
5763
|
shell.scrollIntoView({ block: "center" });
|
|
5765
5764
|
return true;
|
|
5766
5765
|
}
|
|
@@ -5777,8 +5776,8 @@ function useBlockLinkTarget(controller, focusOnMount) {
|
|
|
5777
5776
|
}, [controller, focusOnMount]);
|
|
5778
5777
|
}
|
|
5779
5778
|
var WRITER_ORIGINS = /* @__PURE__ */ new Set(["command", "input", "paste"]);
|
|
5780
|
-
var isBlockDeletion = (tr) => WRITER_ORIGINS.has(tr.origin) && tr.getMeta(
|
|
5781
|
-
var isEmptyText = (schema, block) =>
|
|
5779
|
+
var isBlockDeletion = (tr) => WRITER_ORIGINS.has(tr.origin) && tr.getMeta(chunk4F2IWBFM_cjs.LINE_JOIN) !== true;
|
|
5780
|
+
var isEmptyText = (schema, block) => chunk4F2IWBFM_cjs.isTextFlow(schema, block) && chunk4F2IWBFM_cjs.regionLength(block, chunk4F2IWBFM_cjs.primaryRegion(schema, block) ?? "") === 0;
|
|
5782
5781
|
function filledLine({ origin, before }, schema) {
|
|
5783
5782
|
const { selection } = before;
|
|
5784
5783
|
if (origin !== "paste" || selection?.kind !== "text") return () => false;
|
|
@@ -5792,13 +5791,13 @@ function deletions(codec, tr) {
|
|
|
5792
5791
|
const { index, count } = step.toJSON();
|
|
5793
5792
|
if (typeof index !== "number" || typeof count !== "number") return [];
|
|
5794
5793
|
const { blocks } = tr.docs[i];
|
|
5795
|
-
const first = codec.blocksFromDoc(
|
|
5794
|
+
const first = codec.blocksFromDoc(chunkWZA5S5EJ_cjs.createDoc(blocks.slice(0, index))).length;
|
|
5796
5795
|
return blocks.slice(index, index + count).flatMap((block, offset) => filled(block) ? [] : [{ block: codec.toQuoin(block), index: first + offset }]);
|
|
5797
5796
|
});
|
|
5798
5797
|
}
|
|
5799
5798
|
function useDeleteReporter(controller, onDelete) {
|
|
5800
5799
|
const latest = React7.useRef(onDelete);
|
|
5801
|
-
|
|
5800
|
+
chunkNNDLIP2C_cjs.useIsomorphicLayoutEffect(() => {
|
|
5802
5801
|
latest.current = onDelete;
|
|
5803
5802
|
});
|
|
5804
5803
|
React7.useEffect(() => {
|
|
@@ -5852,7 +5851,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5852
5851
|
const [voidEditing] = React7.useState(createVoidEditing);
|
|
5853
5852
|
const [uiStore] = React7.useState(createCanvasUiStore);
|
|
5854
5853
|
const [allExtensions] = React7.useState(() => [
|
|
5855
|
-
...
|
|
5854
|
+
...chunk4F2IWBFM_cjs.coreExtensions(),
|
|
5856
5855
|
voidEditing.extension,
|
|
5857
5856
|
blockMenuKeymap(uiStore),
|
|
5858
5857
|
slashExtension(),
|
|
@@ -5870,7 +5869,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5870
5869
|
);
|
|
5871
5870
|
useTypedInPlaceWarning(blockTypes, readOnly);
|
|
5872
5871
|
const [focusOnMount] = React7.useState(autoFocus);
|
|
5873
|
-
const controller =
|
|
5872
|
+
const controller = chunkNNDLIP2C_cjs.useQuoinEditor({
|
|
5874
5873
|
blocks,
|
|
5875
5874
|
onChange,
|
|
5876
5875
|
readOnly,
|
|
@@ -5914,7 +5913,7 @@ var BlockCanvas = React7.forwardRef(function BlockCanvas2({
|
|
|
5914
5913
|
[controller, resolveAssetUrl]
|
|
5915
5914
|
);
|
|
5916
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(
|
|
5917
|
-
|
|
5916
|
+
chunkNNDLIP2C_cjs.EditorView,
|
|
5918
5917
|
{
|
|
5919
5918
|
controller,
|
|
5920
5919
|
renderers: ui.renderers,
|
|
@@ -6108,7 +6107,7 @@ function useAutosave({
|
|
|
6108
6107
|
const seen = seenRef.current;
|
|
6109
6108
|
seenRef.current = deps;
|
|
6110
6109
|
if (seen === null) return;
|
|
6111
|
-
const unchanged =
|
|
6110
|
+
const unchanged = chunkWZA5S5EJ_cjs.sameItems(seen, deps);
|
|
6112
6111
|
if (!unchanged) runner.markDirty();
|
|
6113
6112
|
}, deps);
|
|
6114
6113
|
React7__namespace.useEffect(() => {
|
|
@@ -6192,5 +6191,5 @@ exports.useQuoin = useQuoin;
|
|
|
6192
6191
|
exports.useRangeAnchor = useRangeAnchor;
|
|
6193
6192
|
exports.useRovingFocus = useRovingFocus;
|
|
6194
6193
|
exports.virtualAnchor = virtualAnchor;
|
|
6195
|
-
//# sourceMappingURL=chunk-
|
|
6196
|
-
//# sourceMappingURL=chunk-
|
|
6194
|
+
//# sourceMappingURL=chunk-6X5A4DUQ.cjs.map
|
|
6195
|
+
//# sourceMappingURL=chunk-6X5A4DUQ.cjs.map
|