@skillre/dsh-plugin-sticky-wall 0.8.2 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -229,6 +229,7 @@ window.__ModuleLoader__.load({
229
229
  "editorSaving": "\u4FDD\u5B58\u4E2D\u2026",
230
230
  "editorUnsaved": "\u672A\u4FDD\u5B58",
231
231
  "editorSaveFailed": "\u4FDD\u5B58\u5931\u8D25\uFF1A{message}",
232
+ "toolbarLabel": "\u7F16\u8F91\u5DE5\u5177\u680F",
232
233
  "toolbarStructure": "\u7ED3\u6784",
233
234
  "toolbarList": "\u5217\u8868",
234
235
  "toolbarTable": "\u8868\u683C",
@@ -261,7 +262,11 @@ window.__ModuleLoader__.load({
261
262
  // never a silent loss.
262
263
  "discardDraft": "\u653E\u5F03\u672A\u4FDD\u5B58\u7684\u5185\u5BB9\uFF1F",
263
264
  "keepEditing": "\u7EE7\u7EED\u7F16\u8F91",
264
- "discard": "\u653E\u5F03"
265
+ "discard": "\u653E\u5F03",
266
+ // The composer sheet is resizable; the grip needs a name for screen readers
267
+ // and a hint for everyone else.
268
+ "resizeSheet": "\u8C03\u6574\u4FBF\u7B7E\u7EB8\u5927\u5C0F",
269
+ "resizeSheetHint": "\u62D6\u52A8\u8C03\u6574\u5927\u5C0F \xB7 \u65B9\u5411\u952E\u5FAE\u8C03\uFF08Shift \u52A0\u5927\u6B65\u957F\uFF09\xB7 0 \u6216\u53CC\u51FB\u6062\u590D\u9ED8\u8BA4"
265
270
  };
266
271
  var en = {
267
272
  "nav": "Notes",
@@ -331,6 +336,7 @@ window.__ModuleLoader__.load({
331
336
  "editorSaving": "Saving\u2026",
332
337
  "editorUnsaved": "Unsaved",
333
338
  "editorSaveFailed": "Save failed: {message}",
339
+ "toolbarLabel": "Formatting toolbar",
334
340
  "toolbarStructure": "Structure",
335
341
  "toolbarList": "Lists",
336
342
  "toolbarTable": "Table",
@@ -359,11 +365,376 @@ window.__ModuleLoader__.load({
359
365
  "longNote": "Long note",
360
366
  "discardDraft": "Discard unsaved changes?",
361
367
  "keepEditing": "Keep editing",
362
- "discard": "Discard"
368
+ "discard": "Discard",
369
+ "resizeSheet": "Resize note sheet",
370
+ "resizeSheetHint": "Drag to resize \xB7 Arrow keys to fine-tune (Shift for a bigger step) \xB7 0 or double-click to reset"
363
371
  };
364
372
 
365
373
  // src/client/view.tsx
366
- var import_react2 = require("react");
374
+ var import_react3 = require("react");
375
+
376
+ // src/markdown-parse.ts
377
+ var INDENT_WIDTH = 2;
378
+ var CODE_INDENT = 4;
379
+ var MAX_DEPTH = 12;
380
+ function stepBudget(lineCount) {
381
+ return Math.max(1e3, lineCount * 64);
382
+ }
383
+ var FENCE = /^(`{3,}|~{3,})\s*(.*)$/;
384
+ var HEADING = /^(#{1,6})\s+(.*)$/;
385
+ var RULE = /^(?:[-*_][ \t]*){3,}$/;
386
+ var BULLET = /^([-*+])[ \t]+(.*)$/;
387
+ var ORDERED = /^(\d{1,9})[.)][ \t]+(.*)$/;
388
+ var QUOTE = /^>[ \t]?(.*)$/;
389
+ var TABLE_DIVIDER = /^\|?[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)*\|?[ \t]*$/;
390
+ function toLine(raw) {
391
+ let width = 0;
392
+ let index = 0;
393
+ while (index < raw.length) {
394
+ const char = raw[index];
395
+ if (char === " ") width += 1;
396
+ else if (char === " ") width += INDENT_WIDTH;
397
+ else break;
398
+ index += 1;
399
+ }
400
+ return { raw, indent: width, body: raw.slice(index) };
401
+ }
402
+ function stripColumns(raw, width) {
403
+ let consumed = 0;
404
+ let index = 0;
405
+ while (index < raw.length && consumed < width) {
406
+ const char = raw[index];
407
+ if (char === " ") {
408
+ consumed += 1;
409
+ index += 1;
410
+ } else if (char === " ") {
411
+ consumed += INDENT_WIDTH;
412
+ index += 1;
413
+ } else break;
414
+ }
415
+ return raw.slice(index);
416
+ }
417
+ function startsBlock(body) {
418
+ return FENCE.test(body) || HEADING.test(body) || RULE.test(body) || BULLET.test(body) || ORDERED.test(body) || QUOTE.test(body) || TABLE_DIVIDER.test(body);
419
+ }
420
+ function splitRow(line) {
421
+ const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
422
+ return trimmed.split("|").map((cell) => cell.trim());
423
+ }
424
+ function parseAlign(divider) {
425
+ return splitRow(divider).map((cell) => {
426
+ const left = cell.startsWith(":");
427
+ const right = cell.endsWith(":");
428
+ if (left && right) return "center";
429
+ if (right) return "right";
430
+ if (left) return "left";
431
+ return null;
432
+ });
433
+ }
434
+ function tableAt(lines, at, to) {
435
+ if (at + 1 >= to) return false;
436
+ const header = lines[at];
437
+ const divider = lines[at + 1];
438
+ if (header === void 0 || divider === void 0) return false;
439
+ return header.body.includes("|") && TABLE_DIVIDER.test(divider.body);
440
+ }
441
+ function parseOne(lines, index, to, blocks, depth) {
442
+ const line = lines[index];
443
+ if (line === void 0) return index + 1;
444
+ if (depth >= MAX_DEPTH) {
445
+ const literal = [];
446
+ let cursor2 = index;
447
+ while (cursor2 < to) {
448
+ const candidate = lines[cursor2];
449
+ if (candidate === void 0) break;
450
+ literal.push(candidate.body);
451
+ cursor2 += 1;
452
+ }
453
+ const text = literal.join("\n").trim();
454
+ if (text !== "") blocks.push({ kind: "paragraph", text });
455
+ return to;
456
+ }
457
+ const fence = FENCE.exec(line.body);
458
+ if (fence !== null) {
459
+ const marker = fence[1] ?? "```";
460
+ const char = marker.charAt(0);
461
+ const info = (fence[2] ?? "").trim();
462
+ const language = info === "" ? "" : info.split(/[\s{]/)[0] ?? "";
463
+ const body2 = [];
464
+ let cursor2 = index + 1;
465
+ while (cursor2 < to) {
466
+ const candidate = lines[cursor2];
467
+ if (candidate === void 0) break;
468
+ const closing = FENCE.exec(candidate.body);
469
+ if (closing !== null) {
470
+ const closingMarker = closing[1] ?? "";
471
+ if (closingMarker.charAt(0) === char && closingMarker.length >= marker.length) break;
472
+ }
473
+ body2.push(stripColumns(candidate.raw, line.indent));
474
+ cursor2 += 1;
475
+ }
476
+ blocks.push({ kind: "code", text: body2.join("\n"), language });
477
+ return cursor2 < to ? cursor2 + 1 : to;
478
+ }
479
+ const heading = HEADING.exec(line.body);
480
+ if (heading !== null) {
481
+ const level = Math.min(6, (heading[1] ?? "#").length);
482
+ blocks.push({ kind: "heading", level, text: (heading[2] ?? "").trim() });
483
+ return index + 1;
484
+ }
485
+ if (RULE.test(line.body)) {
486
+ blocks.push({ kind: "rule" });
487
+ return index + 1;
488
+ }
489
+ if (QUOTE.test(line.body)) {
490
+ const inner = [];
491
+ let cursor2 = index;
492
+ while (cursor2 < to) {
493
+ const candidate = lines[cursor2];
494
+ if (candidate === void 0) break;
495
+ const match = QUOTE.exec(candidate.body);
496
+ if (match !== null) {
497
+ inner.push(toLine(match[1] ?? ""));
498
+ cursor2 += 1;
499
+ continue;
500
+ }
501
+ if (candidate.body === "") {
502
+ let probe = cursor2;
503
+ while (probe < to && lines[probe]?.body === "") probe += 1;
504
+ const next = lines[probe];
505
+ if (next !== void 0 && QUOTE.test(next.body)) {
506
+ for (let blank = cursor2; blank < probe; blank += 1) inner.push(toLine(""));
507
+ cursor2 = probe;
508
+ continue;
509
+ }
510
+ }
511
+ break;
512
+ }
513
+ blocks.push({ kind: "quote", children: parseRange(inner, 0, inner.length, depth + 1) });
514
+ return Math.max(cursor2, index + 1);
515
+ }
516
+ if (tableAt(lines, index, to)) {
517
+ const header = splitRow(line.body);
518
+ const divider = lines[index + 1];
519
+ const align = parseAlign(divider === void 0 ? "" : divider.body);
520
+ const rows = [];
521
+ let cursor2 = index + 2;
522
+ while (cursor2 < to) {
523
+ const candidate = lines[cursor2];
524
+ if (candidate === void 0) break;
525
+ if (candidate.body === "" || !candidate.body.includes("|")) break;
526
+ if (startsBlock(candidate.body) && !TABLE_DIVIDER.test(candidate.body)) break;
527
+ rows.push(splitRow(candidate.body));
528
+ cursor2 += 1;
529
+ }
530
+ blocks.push({ kind: "table", header, rows, align });
531
+ return cursor2;
532
+ }
533
+ const bullet = BULLET.exec(line.body);
534
+ const ordered = bullet === null ? ORDERED.exec(line.body) : null;
535
+ if (bullet !== null || ordered !== null) {
536
+ const isOrdered = ordered !== null;
537
+ const start = isOrdered ? Number(ordered[1] ?? "1") : 1;
538
+ const baseIndent = line.indent;
539
+ const items = [];
540
+ let cursor2 = index;
541
+ while (cursor2 < to) {
542
+ const candidate = lines[cursor2];
543
+ if (candidate === void 0) break;
544
+ if (candidate.indent !== baseIndent) break;
545
+ const marker = isOrdered ? ORDERED.exec(candidate.body) : BULLET.exec(candidate.body);
546
+ if (marker === null) break;
547
+ let paragraph = marker[2] ?? "";
548
+ const nested = [];
549
+ let separated = false;
550
+ let probe = cursor2 + 1;
551
+ while (probe < to) {
552
+ const next = lines[probe];
553
+ if (next === void 0) break;
554
+ if (next.body === "") {
555
+ let ahead = probe;
556
+ while (ahead < to && lines[ahead]?.body === "") ahead += 1;
557
+ const resumed = lines[ahead];
558
+ if (resumed !== void 0 && resumed.indent >= baseIndent + INDENT_WIDTH) {
559
+ for (let blank = probe; blank < ahead; blank += 1) nested.push("");
560
+ separated = true;
561
+ probe = ahead;
562
+ continue;
563
+ }
564
+ break;
565
+ }
566
+ if (next.indent < baseIndent + INDENT_WIDTH) break;
567
+ const deindented = stripColumns(next.raw, baseIndent + INDENT_WIDTH);
568
+ const deLine = toLine(deindented);
569
+ if (!separated && nested.length === 0 && !startsBlock(deLine.body)) {
570
+ paragraph = paragraph === "" ? deLine.body : `${paragraph}
571
+ ${deLine.body}`;
572
+ probe += 1;
573
+ continue;
574
+ }
575
+ nested.push(deindented);
576
+ probe += 1;
577
+ }
578
+ items.push({
579
+ text: paragraph,
580
+ children: nested.length > 0 ? parseRange(nested.map(toLine), 0, nested.length, depth + 1) : []
581
+ });
582
+ cursor2 = probe;
583
+ let skip = cursor2;
584
+ while (skip < to && lines[skip]?.body === "") skip += 1;
585
+ const sibling = lines[skip];
586
+ if (sibling !== void 0 && sibling.indent === baseIndent) {
587
+ const siblingMarker = isOrdered ? ORDERED.exec(sibling.body) : BULLET.exec(sibling.body);
588
+ if (siblingMarker !== null) {
589
+ cursor2 = skip;
590
+ continue;
591
+ }
592
+ }
593
+ break;
594
+ }
595
+ blocks.push({ kind: "list", ordered: isOrdered, start, items });
596
+ return Math.max(cursor2, index + 1);
597
+ }
598
+ const previous = index > 0 ? lines[index - 1] : void 0;
599
+ if (line.indent >= CODE_INDENT && (previous === void 0 || previous.body === "")) {
600
+ const body2 = [];
601
+ let cursor2 = index;
602
+ let lastContent = index;
603
+ while (cursor2 < to) {
604
+ const candidate = lines[cursor2];
605
+ if (candidate === void 0) break;
606
+ if (candidate.body === "") {
607
+ body2.push("");
608
+ cursor2 += 1;
609
+ continue;
610
+ }
611
+ if (candidate.indent < CODE_INDENT) break;
612
+ body2.push(stripColumns(candidate.raw, CODE_INDENT));
613
+ lastContent = cursor2;
614
+ cursor2 += 1;
615
+ }
616
+ while (body2.length > 0 && body2[body2.length - 1] === "") body2.pop();
617
+ blocks.push({ kind: "indentedCode", text: body2.join("\n") });
618
+ return lastContent + 1;
619
+ }
620
+ const body = [line.body];
621
+ let cursor = index + 1;
622
+ while (cursor < to) {
623
+ const next = lines[cursor];
624
+ if (next === void 0) break;
625
+ if (next.body === "") break;
626
+ if (startsBlock(next.body)) break;
627
+ if (tableAt(lines, cursor, to)) break;
628
+ body.push(next.body);
629
+ cursor += 1;
630
+ }
631
+ blocks.push({ kind: "paragraph", text: body.join("\n") });
632
+ return cursor;
633
+ }
634
+ function parseRange(lines, from, to, depth) {
635
+ const blocks = [];
636
+ let index = from;
637
+ const budget = stepBudget(Math.max(1, to - from));
638
+ for (let step = 0; index < to; step += 1) {
639
+ if (step > budget) break;
640
+ const line = lines[index];
641
+ if (line === void 0) break;
642
+ if (line.body === "") {
643
+ index += 1;
644
+ continue;
645
+ }
646
+ const next = parseOne(lines, index, to, blocks, depth);
647
+ index = next > index ? next : index + 1;
648
+ }
649
+ return blocks;
650
+ }
651
+ function parseBlocks(source) {
652
+ const text = typeof source === "string" ? source : "";
653
+ const lines = text.replace(/\r\n?/g, "\n").split("\n").map(toLine);
654
+ return parseRange(lines, 0, lines.length, 0);
655
+ }
656
+ function stripInlineMarkdown(text) {
657
+ let out = text;
658
+ out = out.replace(/\\([\\`*_{}[\]()#+\-.!>~|])/g, "$1");
659
+ out = out.replace(/!\[([^\]]*)\]\([^)\s]*\)/g, "$1");
660
+ out = out.replace(/\[([^\]]*)\]\([^)\s]*\)/g, "$1");
661
+ out = out.replace(/`+([^`]*)`+/g, "$1");
662
+ out = out.replace(/\*\*\*([^*]+)\*\*\*/g, "$1");
663
+ out = out.replace(/\*\*([^*]+)\*\*/g, "$1");
664
+ out = out.replace(/\*([^*]+)\*/g, "$1");
665
+ out = out.replace(/~~([^~]+)~~/g, "$1");
666
+ out = out.replace(/(^|[^A-Za-z0-9])___([^_]+)___(?![A-Za-z0-9])/g, "$1$2");
667
+ out = out.replace(/(^|[^A-Za-z0-9])__([^_]+)__(?![A-Za-z0-9])/g, "$1$2");
668
+ out = out.replace(/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/g, "$1$2");
669
+ return out;
670
+ }
671
+ function flattenWhitespace(text) {
672
+ return text.replace(/\s+/g, " ").trim();
673
+ }
674
+ function truncateDigest(text, limit) {
675
+ if (text.length <= limit) return text;
676
+ let cut = limit;
677
+ const code = text.charCodeAt(cut - 1);
678
+ if (code >= 55296 && code <= 56319) cut -= 1;
679
+ return `${text.slice(0, cut).replace(/\s+$/, "")}\u2026`;
680
+ }
681
+ function firstVisibleText(block) {
682
+ switch (block.kind) {
683
+ case "rule":
684
+ return "";
685
+ case "code":
686
+ case "indentedCode":
687
+ return block.text.split("\n")[0] ?? "";
688
+ case "table":
689
+ return block.header.join(" ");
690
+ case "quote": {
691
+ for (const child of block.children) {
692
+ const text = firstVisibleText(child);
693
+ if (text !== "") return text;
694
+ }
695
+ return "";
696
+ }
697
+ case "list": {
698
+ for (const item of block.items) {
699
+ const own = item.text.replace(/^\[[ xX]\]\s*/, "");
700
+ if (own !== "") return own;
701
+ for (const child of item.children) {
702
+ const text = firstVisibleText(child);
703
+ if (text !== "") return text;
704
+ }
705
+ }
706
+ return "";
707
+ }
708
+ case "heading":
709
+ case "paragraph":
710
+ default:
711
+ return block.text;
712
+ }
713
+ }
714
+ function plainTextSummary(source, max = 90) {
715
+ const limit = Number.isFinite(max) ? Math.floor(max) : 0;
716
+ if (limit <= 0) return "";
717
+ const raw = typeof source === "string" ? source : "";
718
+ let blocks;
719
+ try {
720
+ blocks = parseBlocks(raw);
721
+ } catch {
722
+ return truncateDigest(flattenWhitespace(stripInlineMarkdown(raw)), limit);
723
+ }
724
+ for (const block of blocks) {
725
+ const candidate = firstVisibleText(block);
726
+ const digest = flattenWhitespace(stripInlineMarkdown(candidate));
727
+ if (digest !== "") return truncateDigest(digest, limit);
728
+ }
729
+ return "";
730
+ }
731
+ function safeHref(raw) {
732
+ const value = raw.trim();
733
+ if (value === "") return void 0;
734
+ if (/^(?:https?|mailto):/i.test(value)) return value;
735
+ if (/^www\./i.test(value)) return `https://${value}`;
736
+ return void 0;
737
+ }
367
738
 
368
739
  // src/layout.ts
369
740
  var GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));
@@ -416,14 +787,7 @@ window.__ModuleLoader__.load({
416
787
  }
417
788
  function estimateHeight(note, width) {
418
789
  const columnsPerLine = columnsPerLineFor(width);
419
- let lines = 0;
420
- for (const paragraph of note.body.split("\n")) {
421
- if (paragraph.trim() === "") {
422
- lines += 0.4;
423
- continue;
424
- }
425
- lines += Math.max(1, Math.ceil(columns(paragraph.replace(/^[#>*\-+\d. ]+/u, "")) / columnsPerLine));
426
- }
790
+ let lines = bodyLines(note.body, columnsPerLine);
427
791
  if (note.title !== "") {
428
792
  const titleColumns = columnsPerLineFor(width, 0.92);
429
793
  lines += Math.max(1, Math.ceil(columns(note.title) / titleColumns));
@@ -437,6 +801,66 @@ window.__ModuleLoader__.load({
437
801
  const estimated = Math.round(58 + clamped * 19);
438
802
  return Math.min(estimated, MAX_CARD_HEIGHT[width]);
439
803
  }
804
+ function bodyLines(body, columnsPerLine) {
805
+ let lines = 0;
806
+ for (const block of parseBlocks(body)) {
807
+ lines += blockLines(block, columnsPerLine);
808
+ }
809
+ return lines;
810
+ }
811
+ function blockLines(block, columnsPerLine) {
812
+ switch (block.kind) {
813
+ case "rule":
814
+ return 1.2;
815
+ case "code":
816
+ case "indentedCode": {
817
+ const count = block.text === "" ? 1 : block.text.split("\n").length;
818
+ return count * 0.95 + 1.3;
819
+ }
820
+ case "table": {
821
+ const rows = block.rows.length + 1;
822
+ return rows * 1.25 + 0.6;
823
+ }
824
+ case "heading":
825
+ return Math.max(1, Math.ceil(columns(block.text) / columnsPerLine)) + 0.55;
826
+ case "quote":
827
+ case "paragraph":
828
+ return paragraphLines(block.kind === "quote" ? blockText(block) : block.text, columnsPerLine, 0) + (block.kind === "quote" ? 0.5 : 0.5);
829
+ case "list": {
830
+ let lines = 0.5;
831
+ for (const item of block.items) {
832
+ const marker = 2;
833
+ lines += paragraphLines(item.text, Math.max(8, columnsPerLine - marker), 0);
834
+ for (const child of item.children) lines += blockLines(child, Math.max(8, columnsPerLine - 2));
835
+ lines += 0.12;
836
+ }
837
+ return lines;
838
+ }
839
+ default:
840
+ return 1;
841
+ }
842
+ }
843
+ function blockText(block) {
844
+ const parts = [];
845
+ for (const child of block.kind === "quote" ? block.children : []) {
846
+ if (child.kind === "paragraph" || child.kind === "heading") parts.push(child.text);
847
+ else if (child.kind === "list") parts.push(child.items.map((item) => item.text).join(" "));
848
+ else if (child.kind === "code" || child.kind === "indentedCode") parts.push(child.text);
849
+ else if (child.kind === "table") parts.push(child.header.join(" "));
850
+ }
851
+ return parts.join("\n");
852
+ }
853
+ function paragraphLines(text, columnsPerLine, extra) {
854
+ let lines = extra;
855
+ for (const part of text.split("\n")) {
856
+ if (part.trim() === "") {
857
+ lines += 0.4;
858
+ continue;
859
+ }
860
+ lines += Math.max(1, Math.ceil(columns(part) / columnsPerLine));
861
+ }
862
+ return lines;
863
+ }
440
864
  function columnsPerLineFor(width, density = 1) {
441
865
  return Math.max(8, Math.floor((WIDTH_PX[width] - 26) / 7.1 * density));
442
866
  }
@@ -512,212 +936,176 @@ window.__ModuleLoader__.load({
512
936
 
513
937
  // src/client/markdown.tsx
514
938
  var import_jsx_runtime = require("react/jsx-runtime");
515
- var FENCE = /^(```|~~~)\s*([A-Za-z0-9_+-]*)\s*$/;
516
- var HEADING = /^(#{1,4})\s+(.*)$/;
517
- var RULE = /^(?:[-*_]\s*){3,}$/;
518
- var BULLET = /^[-*+]\s+(.*)$/;
519
- var ORDERED = /^\d{1,3}[.)]\s+(.*)$/;
520
- var QUOTE = /^>\s?(.*)$/;
521
- var TABLE_DIVIDER = /^\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)*\|?\s*$/;
522
- function splitRow(line) {
523
- const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
524
- return trimmed.split("|").map((cell) => cell.trim());
939
+ var TASK = /^\[([ xX])\][ \t]+([\s\S]*)$/;
940
+ var ESCAPABLE = /* @__PURE__ */ new Set(["\\", "`", "*", "_", "{", "}", "[", "]", "(", ")", "#", "+", "-", ".", "!", ">", "~", "|"]);
941
+ function runLength(text, from, char) {
942
+ let length = 0;
943
+ while (text.charAt(from + length) === char) length += 1;
944
+ return length;
525
945
  }
526
- function parseBlocks(source) {
527
- const lines = source.replace(/\r\n?/g, "\n").split("\n");
528
- const blocks = [];
529
- let index = 0;
530
- while (index < lines.length) {
531
- const line = lines[index] ?? "";
532
- if (line.trim() === "") {
533
- index += 1;
534
- continue;
535
- }
536
- const fence = line.trim().match(FENCE);
537
- if (fence !== null) {
538
- const marker = fence[1] ?? "```";
539
- const language = fence[2] ?? "";
540
- const body2 = [];
541
- index += 1;
542
- while (index < lines.length && (lines[index] ?? "").trim() !== marker) {
543
- body2.push(lines[index] ?? "");
544
- index += 1;
545
- }
546
- if (index < lines.length) index += 1;
547
- blocks.push({ kind: "code", text: body2.join("\n"), language });
946
+ function isWordChar(text, at) {
947
+ const char = text.charAt(at);
948
+ if (char === "") return false;
949
+ return /[A-Za-z0-9]/.test(char);
950
+ }
951
+ function findClosing(text, from, delimiter) {
952
+ const char = delimiter.charAt(0);
953
+ const underscore = char === "_";
954
+ let index = from;
955
+ while (index < text.length) {
956
+ const found = text.indexOf(delimiter, index);
957
+ if (found === -1) return -1;
958
+ let backslashes = 0;
959
+ for (let probe = found - 1; probe >= 0 && text.charAt(probe) === "\\"; probe -= 1) backslashes += 1;
960
+ if (backslashes % 2 === 1) {
961
+ index = found + delimiter.length;
548
962
  continue;
549
963
  }
550
- const heading = line.match(HEADING);
551
- if (heading !== null) {
552
- const level = Math.min(4, (heading[1] ?? "#").length);
553
- blocks.push({ kind: "heading", level, text: (heading[2] ?? "").trim() });
554
- index += 1;
964
+ if (underscore && isWordChar(text, found + delimiter.length)) {
965
+ index = found + delimiter.length;
555
966
  continue;
556
967
  }
557
- if (RULE.test(line.trim())) {
558
- blocks.push({ kind: "rule" });
559
- index += 1;
968
+ if (runLength(text, found, char) < delimiter.length) {
969
+ index = found + 1;
560
970
  continue;
561
971
  }
562
- if (QUOTE.test(line.trim())) {
563
- const body2 = [];
564
- while (index < lines.length) {
565
- const current = lines[index] ?? "";
566
- const match = current.match(QUOTE);
567
- if (match === null) break;
568
- body2.push(match[1] ?? "");
569
- index += 1;
972
+ return found;
973
+ }
974
+ return -1;
975
+ }
976
+ function renderInline(text, keyPrefix = "i") {
977
+ const nodes = [];
978
+ let buffer = "";
979
+ let counter = 0;
980
+ let index = 0;
981
+ const nextKey = () => `${keyPrefix}-${counter++}`;
982
+ const flush = () => {
983
+ if (buffer === "") return;
984
+ const parts = buffer.split("\n");
985
+ parts.forEach((part, position) => {
986
+ if (part !== "") nodes.push(part);
987
+ if (position < parts.length - 1) nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}, nextKey()));
988
+ });
989
+ buffer = "";
990
+ };
991
+ while (index < text.length) {
992
+ const char = text.charAt(index);
993
+ if (char === "\\") {
994
+ const escaped = text.charAt(index + 1);
995
+ if (ESCAPABLE.has(escaped)) {
996
+ buffer += escaped;
997
+ index += 2;
998
+ continue;
570
999
  }
571
- blocks.push({ kind: "quote", text: body2.join("\n").trim() });
572
- continue;
573
1000
  }
574
- if (line.includes("|") && TABLE_DIVIDER.test(lines[index + 1] ?? "")) {
575
- const header = splitRow(line);
576
- const rows = [];
577
- index += 2;
578
- while (index < lines.length && (lines[index] ?? "").includes("|") && (lines[index] ?? "").trim() !== "") {
579
- rows.push(splitRow(lines[index] ?? ""));
580
- index += 1;
1001
+ if (char === "`") {
1002
+ const open = runLength(text, index, "`");
1003
+ const closing = findClosing(text, index + open, "`".repeat(open));
1004
+ if (closing !== -1) {
1005
+ flush();
1006
+ const inner = text.slice(index + open, closing);
1007
+ const trimmed = inner.length > 2 && inner.startsWith(" ") && inner.endsWith(" ") ? inner.slice(1, -1) : inner;
1008
+ nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "skw-md-code", children: trimmed }, nextKey()));
1009
+ index = closing + open;
1010
+ continue;
581
1011
  }
582
- blocks.push({ kind: "table", header, rows });
1012
+ buffer += "`".repeat(open);
1013
+ index += open;
583
1014
  continue;
584
1015
  }
585
- if (BULLET.test(line.trim()) || ORDERED.test(line.trim())) {
586
- const ordered = ORDERED.test(line.trim());
587
- const items = [];
588
- while (index < lines.length) {
589
- const current = lines[index] ?? "";
590
- const match = current.trim().match(ordered ? ORDERED : BULLET);
591
- if (match === null) break;
592
- items.push((match[1] ?? "").trim());
593
- index += 1;
1016
+ if (char === "*" || char === "_") {
1017
+ const run = runLength(text, index, char);
1018
+ const opens = char !== "_" || !isWordChar(text, index - 1);
1019
+ if (opens && run >= 3) {
1020
+ const delimiter = char.repeat(3);
1021
+ const closing = findClosing(text, index + 3, delimiter);
1022
+ if (closing > index + 3) {
1023
+ flush();
1024
+ nodes.push(
1025
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: renderInline(text.slice(index + 3, closing), `${keyPrefix}-se`) }) }, nextKey())
1026
+ );
1027
+ index = closing + 3;
1028
+ continue;
1029
+ }
1030
+ }
1031
+ if (opens && run >= 2) {
1032
+ const delimiter = char + char;
1033
+ const closing = findClosing(text, index + 2, delimiter);
1034
+ if (closing > index + 2) {
1035
+ flush();
1036
+ nodes.push(
1037
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: renderInline(text.slice(index + 2, closing), `${keyPrefix}-s`) }, nextKey())
1038
+ );
1039
+ index = closing + 2;
1040
+ continue;
1041
+ }
594
1042
  }
595
- blocks.push({ kind: "list", ordered, items });
1043
+ if (opens && run === 1) {
1044
+ const closing = findClosing(text, index + 1, char);
1045
+ if (closing > index + 1) {
1046
+ flush();
1047
+ nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: renderInline(text.slice(index + 1, closing), `${keyPrefix}-e`) }, nextKey()));
1048
+ index = closing + 1;
1049
+ continue;
1050
+ }
1051
+ }
1052
+ buffer += char.repeat(run);
1053
+ index += run;
596
1054
  continue;
597
1055
  }
598
- const body = [line.trim()];
599
- index += 1;
600
- while (index < lines.length) {
601
- const current = lines[index] ?? "";
602
- if (current.trim() === "") break;
603
- if (FENCE.test(current.trim()) || HEADING.test(current) || RULE.test(current.trim())) break;
604
- if (BULLET.test(current.trim()) || ORDERED.test(current.trim()) || QUOTE.test(current.trim())) break;
605
- body.push(current.trim());
606
- index += 1;
607
- }
608
- blocks.push({ kind: "paragraph", text: body.join("\n") });
609
- }
610
- return blocks;
611
- }
612
- function stripInlineMarkdown(text) {
613
- let out = text;
614
- out = out.replace(/!\[([^\]]*)\]\([^)\s]*\)/g, "$1");
615
- out = out.replace(/\[([^\]]*)\]\([^)\s]*\)/g, "$1");
616
- out = out.replace(/`+([^`]*)`+/g, "$1");
617
- out = out.replace(/\*\*\*([^*]+)\*\*\*/g, "$1");
618
- out = out.replace(/\*\*([^*]+)\*\*/g, "$1");
619
- out = out.replace(/\*([^*]+)\*/g, "$1");
620
- out = out.replace(/~~([^~]+)~~/g, "$1");
621
- out = out.replace(/(^|[^A-Za-z0-9])__([^_]+)__(?![A-Za-z0-9])/g, "$1$2");
622
- out = out.replace(/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/g, "$1$2");
623
- return out;
624
- }
625
- function flattenWhitespace(text) {
626
- return text.replace(/\s+/g, " ").trim();
627
- }
628
- function truncateDigest(text, limit) {
629
- if (text.length <= limit) return text;
630
- let cut = limit;
631
- const code = text.charCodeAt(cut - 1);
632
- if (code >= 55296 && code <= 56319) cut -= 1;
633
- return `${text.slice(0, cut).replace(/\s+$/, "")}\u2026`;
634
- }
635
- function plainTextSummary(source, max = 90) {
636
- const limit = Number.isFinite(max) ? Math.floor(max) : 0;
637
- if (limit <= 0) return "";
638
- const raw = typeof source === "string" ? source : "";
639
- let blocks;
640
- try {
641
- blocks = parseBlocks(raw);
642
- } catch {
643
- return truncateDigest(flattenWhitespace(stripInlineMarkdown(raw)), limit);
644
- }
645
- for (const block of blocks) {
646
- if (block.kind === "rule") continue;
647
- let candidate;
648
- if (block.kind === "code") {
649
- candidate = block.text.split("\n")[0] ?? "";
650
- } else if (block.kind === "list") {
651
- candidate = (block.items[0] ?? "").replace(/^\[[ xX]\]\s*/, "");
652
- } else if (block.kind === "table") {
653
- candidate = block.header.join(" ");
654
- } else {
655
- candidate = block.text;
1056
+ if (char === "~" && text.startsWith("~~", index)) {
1057
+ const closing = findClosing(text, index + 2, "~~");
1058
+ if (closing > index + 2) {
1059
+ flush();
1060
+ nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("s", { children: renderInline(text.slice(index + 2, closing), `${keyPrefix}-d`) }, nextKey()));
1061
+ index = closing + 2;
1062
+ continue;
1063
+ }
656
1064
  }
657
- const digest = flattenWhitespace(stripInlineMarkdown(candidate));
658
- if (digest !== "") return truncateDigest(digest, limit);
659
- }
660
- return "";
661
- }
662
- function safeHref(raw) {
663
- const value = raw.trim();
664
- if (value === "") return void 0;
665
- if (/^(?:https?|mailto):/i.test(value)) return value;
666
- if (/^www\./i.test(value)) return `https://${value}`;
667
- return void 0;
668
- }
669
- function renderInline(text, keyPrefix = "i") {
670
- const nodes = [];
671
- let rest = text;
672
- let counter = 0;
673
- const pattern = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(_[^_]+_)|(~~[^~]+~~)|(\[[^\]]+\]\([^)\s]+\))|((?:https?:\/\/|www\.)[^\s<>()]+)/g;
674
- let match;
675
- while ((match = pattern.exec(rest)) !== null) {
676
- if (match.index > 0) {
677
- const head = rest.slice(0, match.index);
678
- const parts = head.split("\n");
679
- parts.forEach((part, position) => {
680
- if (part !== "") nodes.push(part);
681
- if (position < parts.length - 1) nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}, `${keyPrefix}-br-${counter++}`));
682
- });
1065
+ if (char === "[") {
1066
+ const match = /^\[([^\]]*)\]\(((?:[^()\s]|\([^()\s]*\))*)\)/.exec(text.slice(index));
1067
+ if (match !== null) {
1068
+ flush();
1069
+ const label = match[1] ?? "";
1070
+ const href = safeHref(match[2] ?? "");
1071
+ nodes.push(
1072
+ href === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }, nextKey()) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "skw-md-link", href, target: "_blank", rel: "noreferrer noopener", children: renderInline(label, `${keyPrefix}-l`) }, nextKey())
1073
+ );
1074
+ index += match[0].length;
1075
+ continue;
1076
+ }
683
1077
  }
684
- const token = match[0];
685
- const key = `${keyPrefix}-${counter++}`;
686
- if (token.startsWith("`")) {
687
- nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "skw-md-code", children: token.slice(1, -1) }, key));
688
- } else if (token.startsWith("**")) {
689
- nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: renderInline(token.slice(2, -2), `${key}s`) }, key));
690
- } else if (token.startsWith("~~")) {
691
- nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("s", { children: renderInline(token.slice(2, -2), `${key}s`) }, key));
692
- } else if (token.startsWith("*")) {
693
- nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: renderInline(token.slice(1, -1), `${key}e`) }, key));
694
- } else if (token.startsWith("_")) {
695
- nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: renderInline(token.slice(1, -1), `${key}e`) }, key));
696
- } else if (token.startsWith("[")) {
697
- const split = token.match(/\[([^\]]+)\]\(([^)\s]+)\)/);
698
- const label = split?.[1] ?? token;
699
- const href = safeHref(split?.[2] ?? "");
700
- nodes.push(
701
- href === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }, key) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "skw-md-link", href, target: "_blank", rel: "noreferrer noopener", children: renderInline(label, `${key}l`) }, key)
702
- );
703
- } else {
704
- const href = safeHref(token);
705
- nodes.push(
706
- href === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: token }, key) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "skw-md-link", href, target: "_blank", rel: "noreferrer noopener", children: token }, key)
707
- );
1078
+ if (char === "h" || char === "w") {
1079
+ const match = /^(?:https?:\/\/|www\.)[^\s<>()]+/.exec(text.slice(index));
1080
+ if (match !== null) {
1081
+ const raw = match[0];
1082
+ const trimmed = raw.replace(/[.,;:!?]+$/, "");
1083
+ const href = safeHref(trimmed);
1084
+ if (href !== void 0) {
1085
+ flush();
1086
+ nodes.push(
1087
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "skw-md-link", href, target: "_blank", rel: "noreferrer noopener", children: trimmed }, nextKey())
1088
+ );
1089
+ index += trimmed.length;
1090
+ continue;
1091
+ }
1092
+ }
708
1093
  }
709
- rest = rest.slice(match.index + token.length);
710
- pattern.lastIndex = 0;
711
- }
712
- if (rest !== "") {
713
- const parts = rest.split("\n");
714
- parts.forEach((part, position) => {
715
- if (part !== "") nodes.push(part);
716
- if (position < parts.length - 1) nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}, `${keyPrefix}-br-${counter++}`));
717
- });
1094
+ buffer += char;
1095
+ index += 1;
718
1096
  }
1097
+ flush();
719
1098
  return nodes;
720
1099
  }
1100
+ function renderTask(item, key) {
1101
+ const match = TASK.exec(item);
1102
+ if (match === null) return renderInline(item, key);
1103
+ const checked = (match[1] ?? " ") !== " ";
1104
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "skw-md-task", "data-checked": checked, children: [
1105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "skw-md-box", "aria-hidden": "true", children: checked ? "\u2713" : "" }),
1106
+ renderInline(match[2] ?? "", `${key}t`)
1107
+ ] }, key);
1108
+ }
721
1109
  function renderBlock(block, key) {
722
1110
  switch (block.kind) {
723
1111
  case "heading": {
@@ -725,41 +1113,55 @@ window.__ModuleLoader__.load({
725
1113
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tag, { className: "skw-md-heading", children: renderInline(block.text, `${key}h`) }, key);
726
1114
  }
727
1115
  case "code":
728
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "skw-md-pre", "data-language": block.language || void 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: block.text }) }, key);
1116
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "skw-md-pre", "data-language": block.language === "" ? void 0 : block.language, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: block.text }) }, key);
1117
+ case "indentedCode":
1118
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "skw-md-pre", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: block.text }) }, key);
729
1119
  case "quote":
730
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("blockquote", { className: "skw-md-quote", children: renderInline(block.text, `${key}q`) }, key);
1120
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("blockquote", { className: "skw-md-quote", children: block.children.map((child, position) => renderBlock(child, `${key}q${position}`)) }, key);
731
1121
  case "rule":
732
1122
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", { className: "skw-md-rule" }, key);
733
- case "list":
734
- return block.ordered ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { className: "skw-md-list", children: block.items.map((item, position) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: renderTask(item, `${key}-${position}`) }, `${key}-${position}`)) }, key) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "skw-md-list", children: block.items.map((item, position) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: renderTask(item, `${key}-${position}`) }, `${key}-${position}`)) }, key);
1123
+ case "list": {
1124
+ const Tag = block.ordered ? "ol" : "ul";
1125
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tag, { className: "skw-md-list", start: block.ordered && block.start !== 1 ? block.start : void 0, children: block.items.map((item, position) => {
1126
+ const itemKey = `${key}-${position}`;
1127
+ const hasChildren = item.children.length > 0;
1128
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
1129
+ item.text === "" ? null : renderTask(item.text, `${itemKey}t`),
1130
+ hasChildren ? item.children.map((child, childIndex) => renderBlock(child, `${itemKey}c${childIndex}`)) : null
1131
+ ] }, itemKey);
1132
+ }) }, key);
1133
+ }
735
1134
  case "table":
736
1135
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { className: "skw-md-table", children: [
737
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: block.header.map((cell, position) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: renderInline(cell, `${key}h${position}`) }, `${key}-h-${position}`)) }) }),
738
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: block.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: row.map((cell, position) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: renderInline(cell, `${key}r${rowIndex}${position}`) }, `${key}-r-${rowIndex}-${position}`)) }, `${key}-r-${rowIndex}`)) })
1136
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: block.header.map((cell, position) => {
1137
+ const align = block.align[position] ?? null;
1138
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { style: align === null ? void 0 : { textAlign: align }, children: renderInline(cell, `${key}h${position}`) }, `${key}-h-${position}`);
1139
+ }) }) }),
1140
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: block.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: row.map((cell, position) => {
1141
+ const align = block.align[position] ?? null;
1142
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { style: align === null ? void 0 : { textAlign: align }, children: renderInline(cell, `${key}r${rowIndex}${position}`) }, `${key}-r-${rowIndex}-${position}`);
1143
+ }) }, `${key}-r-${rowIndex}`)) })
739
1144
  ] }, key);
740
1145
  case "paragraph":
741
1146
  default:
742
1147
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "skw-md-p", children: renderInline(block.text, `${key}p`) }, key);
743
1148
  }
744
1149
  }
745
- function renderTask(item, key) {
746
- const match = item.match(/^\[( |x|X)\]\s+(.*)$/);
747
- if (match === null) return renderInline(item, key);
748
- const checked = (match[1] ?? " ") !== " ";
749
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "skw-md-task", "data-checked": checked, children: [
750
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "skw-md-box", "aria-hidden": "true", children: checked ? "\u2713" : "" }),
751
- renderInline(match[2] ?? "", `${key}t`)
752
- ] }, key);
753
- }
754
1150
  function Markdown({ source, compact = false }) {
755
- const blocks = parseBlocks(source);
1151
+ let blocks;
1152
+ try {
1153
+ blocks = parseBlocks(source);
1154
+ } catch {
1155
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "skw-md", "data-compact": compact, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "skw-md-p", children: typeof source === "string" ? source : "" }) });
1156
+ }
756
1157
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "skw-md", "data-compact": compact, children: blocks.map((block, index) => renderBlock(block, `b${index}`)) });
757
1158
  }
758
1159
 
759
1160
  // src/client/editor.tsx
760
1161
  var import_react = require("react");
761
1162
  var import_jsx_runtime2 = require("react/jsx-runtime");
762
- var INDENT = " ";
1163
+ var INDENT_WIDTH2 = 2;
1164
+ var INDENT = " ".repeat(INDENT_WIDTH2);
763
1165
  var MIN_HEIGHT_PX = 88;
764
1166
  var VIEWPORT_SHARE = 0.6;
765
1167
  function clampRange(value, start, end) {
@@ -921,38 +1323,46 @@ window.__ModuleLoader__.load({
921
1323
  \`\`\``;
922
1324
  return insertBlock(ctx, block, 4 + body.length);
923
1325
  }
924
- var TOOLBAR_LABEL = { zh: "\u7F16\u8F91\u5DE5\u5177\u680F", en: "Formatting toolbar" };
1326
+ var TOOLBAR_LABEL = {
1327
+ key: "toolbarLabel",
1328
+ zh: "\u7F16\u8F91\u5DE5\u5177\u680F",
1329
+ en: "Formatting toolbar"
1330
+ };
925
1331
  var TOOLBAR = [
926
1332
  {
927
1333
  id: "structure",
1334
+ key: "toolbarStructure",
928
1335
  zh: "\u7ED3\u6784",
929
1336
  en: "Structure",
930
1337
  actions: [
931
- { id: "h1", zh: "\u4E00\u7EA7\u6807\u9898", en: "Heading 1", glyph: "H1", run: applyHeading(1) },
932
- { id: "h2", zh: "\u4E8C\u7EA7\u6807\u9898", en: "Heading 2", glyph: "H2", run: applyHeading(2) },
933
- { id: "h3", zh: "\u4E09\u7EA7\u6807\u9898", en: "Heading 3", glyph: "H3", run: applyHeading(3) },
934
- { id: "quote", zh: "\u5F15\u7528", en: "Blockquote", glyph: "\u275D", run: applyQuote },
935
- { id: "rule", zh: "\u5206\u5272\u7EBF", en: "Divider", glyph: "\u2014", run: (ctx) => insertBlock(ctx, "---", 4) },
936
- { id: "code-block", zh: "\u4EE3\u7801\u5757", en: "Code block", glyph: "{ }", run: insertCodeBlock }
1338
+ { id: "h1", key: "mdH1", zh: "\u4E00\u7EA7\u6807\u9898", en: "Heading 1", glyph: "H1", run: applyHeading(1) },
1339
+ { id: "h2", key: "mdH2", zh: "\u4E8C\u7EA7\u6807\u9898", en: "Heading 2", glyph: "H2", run: applyHeading(2) },
1340
+ { id: "h3", key: "mdH3", zh: "\u4E09\u7EA7\u6807\u9898", en: "Heading 3", glyph: "H3", run: applyHeading(3) },
1341
+ { id: "quote", key: "mdQuote", zh: "\u5F15\u7528", en: "Blockquote", glyph: "\u275D", run: applyQuote },
1342
+ { id: "rule", key: "mdHr", zh: "\u5206\u5272\u7EBF", en: "Divider", glyph: "\u2014", run: (ctx) => insertBlock(ctx, "---", 4) },
1343
+ { id: "code-block", key: "mdCodeBlock", zh: "\u4EE3\u7801\u5757", en: "Code block", glyph: "{ }", run: insertCodeBlock }
937
1344
  ]
938
1345
  },
939
1346
  {
940
1347
  id: "lists",
1348
+ key: "toolbarList",
941
1349
  zh: "\u5217\u8868",
942
1350
  en: "Lists",
943
1351
  actions: [
944
- { id: "bullet", zh: "\u65E0\u5E8F\u5217\u8868", en: "Bullet list", glyph: "\u2022", run: applyList("bullet") },
945
- { id: "ordered", zh: "\u6709\u5E8F\u5217\u8868", en: "Numbered list", glyph: "1.", run: applyList("ordered") },
946
- { id: "todo", zh: "\u5F85\u529E", en: "Todo", glyph: "\u2611", run: applyList("todo") }
1352
+ { id: "bullet", key: "mdBullet", zh: "\u65E0\u5E8F\u5217\u8868", en: "Bullet list", glyph: "\u2022", run: applyList("bullet") },
1353
+ { id: "ordered", key: "mdOrdered", zh: "\u6709\u5E8F\u5217\u8868", en: "Numbered list", glyph: "1.", run: applyList("ordered") },
1354
+ { id: "todo", key: "mdTodo", zh: "\u5F85\u529E", en: "Todo", glyph: "\u2611", run: applyList("todo") }
947
1355
  ]
948
1356
  },
949
1357
  {
950
1358
  id: "table",
1359
+ key: "toolbarTable",
951
1360
  zh: "\u8868\u683C",
952
1361
  en: "Table",
953
1362
  actions: [
954
1363
  {
955
1364
  id: "table",
1365
+ key: "mdTable",
956
1366
  zh: "\u63D2\u5165\u8868\u683C",
957
1367
  en: "Insert table",
958
1368
  glyph: "\u25A6",
@@ -965,52 +1375,157 @@ window.__ModuleLoader__.load({
965
1375
  },
966
1376
  {
967
1377
  id: "inline",
1378
+ key: "toolbarInline",
968
1379
  zh: "\u884C\u5185",
969
1380
  en: "Inline",
970
1381
  actions: [
971
- { id: "bold", zh: "\u7C97\u4F53", en: "Bold", glyph: "B", style: "bold", run: (ctx) => wrapSelection(ctx, "**", "**") },
972
- { id: "italic", zh: "\u659C\u4F53", en: "Italic", glyph: "I", style: "italic", run: (ctx) => wrapSelection(ctx, "_", "_") },
973
- { id: "strike", zh: "\u5220\u9664\u7EBF", en: "Strikethrough", glyph: "S", style: "strike", run: (ctx) => wrapSelection(ctx, "~~", "~~") },
974
- { id: "code", zh: "\u884C\u5185\u4EE3\u7801", en: "Inline code", glyph: "<>", run: (ctx) => wrapSelection(ctx, "`", "`") },
975
- { id: "link", zh: "\u94FE\u63A5", en: "Link", glyph: "\u26D3", run: (ctx) => wrapSelection(ctx, "[", "](https://)") }
1382
+ { id: "bold", key: "mdBold", zh: "\u7C97\u4F53", en: "Bold", glyph: "B", style: "bold", run: (ctx) => wrapSelection(ctx, "**", "**") },
1383
+ { id: "italic", key: "mdItalic", zh: "\u659C\u4F53", en: "Italic", glyph: "I", style: "italic", run: (ctx) => wrapSelection(ctx, "_", "_") },
1384
+ { id: "strike", key: "mdStrike", zh: "\u5220\u9664\u7EBF", en: "Strikethrough", glyph: "S", style: "strike", run: (ctx) => wrapSelection(ctx, "~~", "~~") },
1385
+ { id: "code", key: "mdCode", zh: "\u884C\u5185\u4EE3\u7801", en: "Inline code", glyph: "<>", run: (ctx) => wrapSelection(ctx, "`", "`") },
1386
+ { id: "link", key: "mdLink", zh: "\u94FE\u63A5", en: "Link", glyph: "\u26D3", run: (ctx) => wrapSelection(ctx, "[", "](https://)") }
976
1387
  ]
977
1388
  },
978
1389
  {
979
1390
  id: "other",
1391
+ key: "toolbarOther",
980
1392
  zh: "\u5176\u4ED6",
981
1393
  en: "Other",
982
- actions: [{ id: "timestamp", zh: "\u65E5\u671F\u65F6\u95F4", en: "Date and time", glyph: "\u231A", run: insertStamp }]
1394
+ actions: [{ id: "timestamp", key: "mdTimestamp", zh: "\u65E5\u671F\u65F6\u95F4", en: "Date and time", glyph: "\u231A", run: insertStamp }]
983
1395
  }
984
1396
  ];
1397
+ var TOOLBAR_KEYS = [
1398
+ TOOLBAR_LABEL.key,
1399
+ ...TOOLBAR.flatMap((group) => [group.key, ...group.actions.map((action) => action.key)])
1400
+ ];
1401
+ function columnsOf(prefix) {
1402
+ let width = 0;
1403
+ for (const char of prefix) width += char === " " ? INDENT_WIDTH2 : 1;
1404
+ return width;
1405
+ }
985
1406
  function indentSelection(value, start, end, direction) {
986
1407
  return rewriteLines(value, start, end, (line) => {
987
- if (direction === 1) return `${INDENT}${line}`;
988
- if (line.startsWith(INDENT)) return line.slice(INDENT.length);
989
- if (line.startsWith(" ")) return line.slice(1);
990
- return line.replace(/^ {1,2}/, "");
1408
+ if (line.trim() === "") return line;
1409
+ const prefix = leadingSpace(line);
1410
+ const body = line.slice(prefix.length);
1411
+ if (direction === 1) return `${prefix}${INDENT}${body}`;
1412
+ const level = Math.floor(columnsOf(prefix) / INDENT_WIDTH2);
1413
+ return `${" ".repeat(Math.max(0, level - 1) * INDENT_WIDTH2)}${body}`;
991
1414
  });
992
1415
  }
1416
+ function fenceLines(lines) {
1417
+ const marked = lines.map(() => false);
1418
+ let open = null;
1419
+ lines.forEach((line, index) => {
1420
+ const body = line.trimStart();
1421
+ const match = FENCE_OPEN.exec(body);
1422
+ const marker = match?.[1] ?? "";
1423
+ if (open === null) {
1424
+ if (marker !== "") {
1425
+ open = { char: marker.charAt(0), length: marker.length };
1426
+ marked[index] = true;
1427
+ }
1428
+ return;
1429
+ }
1430
+ marked[index] = true;
1431
+ if (marker !== "" && marker.charAt(0) === open.char && marker.length >= open.length) open = null;
1432
+ });
1433
+ return marked;
1434
+ }
1435
+ var FENCE_OPEN = /^(`{3,}|~{3,})/;
1436
+ var TABLE_DIVIDER2 = /^\|?[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)*\|?[ \t]*$/;
1437
+ function splitTableRow(line) {
1438
+ const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
1439
+ if (trimmed.trim() === "") return [];
1440
+ return trimmed.split("|");
1441
+ }
1442
+ function tableInsertion(lines, index) {
1443
+ const isRow = (at) => (lines[at] ?? "").trimStart().includes("|");
1444
+ const isDivider = (at) => TABLE_DIVIDER2.test((lines[at] ?? "").trimStart());
1445
+ let first = index;
1446
+ while (first > 0 && isRow(first - 1)) first -= 1;
1447
+ if (!isDivider(first + 1)) return null;
1448
+ const cells = splitTableRow(lines[index] ?? "");
1449
+ if (cells.length === 0) return null;
1450
+ let last = index;
1451
+ if (index === first) {
1452
+ last = first + 1;
1453
+ while (isRow(last + 1) && !isDivider(last + 1)) last += 1;
1454
+ } else {
1455
+ while (isRow(last + 1)) last += 1;
1456
+ }
1457
+ return { at: last, columns: cells.length };
1458
+ }
1459
+ var QUOTE_PREFIX = /^(?:>[ \t]?)+/;
993
1460
  var CONTINUE_TODO = /^([ \t]*)([-*+])[ \t]+\[[ xX]\][ \t]+/;
994
1461
  var CONTINUE_BULLET = /^([ \t]*)([-*+])[ \t]+/;
995
1462
  var CONTINUE_ORDERED = /^([ \t]*)(\d{1,3})([.)])[ \t]+/;
996
- function continueList(value, start, end) {
1463
+ function plainNewline(value, start, end) {
1464
+ const caret = start + 1;
1465
+ return { value: `${value.slice(0, start)}
1466
+ ${value.slice(end)}`, start: caret, end: caret };
1467
+ }
1468
+ function dropMarkerLine(value, from, to) {
1469
+ const end = to < value.length ? to + 1 : to;
1470
+ return { value: value.slice(0, from) + value.slice(end), start: from, end: from };
1471
+ }
1472
+ function continueLine(value, start, end) {
997
1473
  const line = lineBounds(value, start);
998
1474
  const text = value.slice(line.from, line.to);
1475
+ const lines = value.split("\n");
1476
+ const index = value.slice(0, line.from).split("\n").length - 1;
1477
+ if (fenceLines(lines)[index] === true) return plainNewline(value, start, end);
1478
+ const body = text.slice(leadingSpace(text).length);
1479
+ const quote = QUOTE_PREFIX.exec(body);
1480
+ if (quote !== null) {
1481
+ const prefix2 = leadingSpace(text);
1482
+ if (start - line.from < prefix2.length + quote[0].length) return null;
1483
+ if (body.slice(quote[0].length).trim() === "") return dropMarkerLine(value, line.from, line.to);
1484
+ const marker2 = quote[0].endsWith(" ") || quote[0].endsWith(" ") ? quote[0] : `${quote[0]} `;
1485
+ const insert = `
1486
+ ${prefix2}${marker2}`;
1487
+ const caret = start + insert.length;
1488
+ return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
1489
+ }
999
1490
  const todo = CONTINUE_TODO.exec(text);
1000
1491
  const bullet = todo === null ? CONTINUE_BULLET.exec(text) : null;
1001
1492
  const ordered = todo === null && bullet === null ? CONTINUE_ORDERED.exec(text) : null;
1002
1493
  const marker = (todo ?? bullet ?? ordered)?.[0];
1003
- if (marker === void 0) return null;
1004
- if (start - line.from < marker.length) return null;
1005
- const body = text.slice(marker.length);
1006
- if (body.trim() === "") {
1007
- return { value: value.slice(0, line.from) + value.slice(line.to), start: line.from, end: line.from };
1008
- }
1009
- const nextMarker = todo !== null ? `${todo[1] ?? ""}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${bullet[1] ?? ""}${bullet[2] ?? "-"} ` : `${ordered?.[1] ?? ""}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
1010
- const insert = `
1494
+ if (marker !== void 0) {
1495
+ if (start - line.from >= marker.length) {
1496
+ const itemBody = text.slice(marker.length);
1497
+ if (itemBody.trim() === "") {
1498
+ return dropMarkerLine(value, line.from, line.to);
1499
+ }
1500
+ const nextMarker = todo !== null ? `${todo[1] ?? ""}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${bullet[1] ?? ""}${bullet[2] ?? "-"} ` : `${ordered?.[1] ?? ""}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
1501
+ const insert = `
1011
1502
  ${nextMarker}`;
1012
- const caret = start + insert.length;
1013
- return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
1503
+ const caret = start + insert.length;
1504
+ return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
1505
+ }
1506
+ }
1507
+ const table = tableInsertion(lines, index);
1508
+ if (table !== null) {
1509
+ if (start !== line.to) return null;
1510
+ const row = `|${" |".repeat(table.columns)}`;
1511
+ const at = lines.slice(0, table.at + 1).reduce((sum, entry) => sum + entry.length + 1, 0) - 1;
1512
+ const insert = `
1513
+ ${row}`;
1514
+ const caret = at + 3;
1515
+ return {
1516
+ value: `${value.slice(0, at)}${insert}${value.slice(at)}`,
1517
+ start: caret,
1518
+ end: caret
1519
+ };
1520
+ }
1521
+ const prefix = leadingSpace(text);
1522
+ if (prefix !== "" && text.trim() !== "" && start - line.from >= prefix.length) {
1523
+ const insert = `
1524
+ ${prefix}`;
1525
+ const caret = start + insert.length;
1526
+ return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
1527
+ }
1528
+ return null;
1014
1529
  }
1015
1530
  function MarkdownEditor(props) {
1016
1531
  const {
@@ -1023,9 +1538,20 @@ window.__ModuleLoader__.load({
1023
1538
  label,
1024
1539
  toolbar = true,
1025
1540
  autoFocus = true,
1541
+ fill = false,
1026
1542
  disabled = false,
1027
- locale = "zh"
1543
+ locale = "zh",
1544
+ t,
1545
+ hidden = false
1028
1546
  } = props;
1547
+ const labelOf = (0, import_react.useCallback)(
1548
+ (pair) => {
1549
+ if (t === void 0) return pair[locale];
1550
+ const translated = t(pair.key);
1551
+ return translated === pair.key ? pair[locale] : translated;
1552
+ },
1553
+ [locale, t]
1554
+ );
1029
1555
  const areaRef = (0, import_react.useRef)(null);
1030
1556
  const composing = (0, import_react.useRef)(false);
1031
1557
  const justEnded = (0, import_react.useRef)(false);
@@ -1085,6 +1611,11 @@ window.__ModuleLoader__.load({
1085
1611
  const measure = (0, import_react.useCallback)(() => {
1086
1612
  const node = areaRef.current;
1087
1613
  if (node === null) return;
1614
+ if (fill) {
1615
+ node.style.height = "";
1616
+ node.style.overflowY = "";
1617
+ return;
1618
+ }
1088
1619
  const view = node.ownerDocument.defaultView;
1089
1620
  const cap = Math.max(MIN_HEIGHT_PX, Math.round((view === null ? 0 : view.innerHeight) * VIEWPORT_SHARE));
1090
1621
  node.style.height = "auto";
@@ -1092,13 +1623,13 @@ window.__ModuleLoader__.load({
1092
1623
  const wanted = node.scrollHeight + border;
1093
1624
  node.style.height = `${Math.min(Math.max(wanted, MIN_HEIGHT_PX), cap)}px`;
1094
1625
  node.style.overflowY = wanted > cap ? "auto" : "hidden";
1095
- }, []);
1626
+ }, [fill]);
1096
1627
  (0, import_react.useLayoutEffect)(() => {
1097
1628
  measure();
1098
1629
  }, [measure, value, disabled]);
1099
1630
  (0, import_react.useEffect)(() => {
1100
1631
  const node = areaRef.current;
1101
- if (node === null) return;
1632
+ if (node === null || fill) return;
1102
1633
  let lastWidth = 0;
1103
1634
  const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver((entries) => {
1104
1635
  const width = Math.round(entries[0]?.contentRect.width ?? 0);
@@ -1112,7 +1643,7 @@ window.__ModuleLoader__.load({
1112
1643
  observer?.disconnect();
1113
1644
  window.removeEventListener("resize", measure);
1114
1645
  };
1115
- }, [measure]);
1646
+ }, [fill, measure]);
1116
1647
  (0, import_react.useLayoutEffect)(() => {
1117
1648
  if (!autoFocus) return;
1118
1649
  const node = areaRef.current;
@@ -1121,6 +1652,14 @@ window.__ModuleLoader__.load({
1121
1652
  const end = node.value.length;
1122
1653
  if (!composing.current) node.setSelectionRange(end, end);
1123
1654
  }, [autoFocus]);
1655
+ const wasHidden = (0, import_react.useRef)(hidden);
1656
+ (0, import_react.useLayoutEffect)(() => {
1657
+ if (wasHidden.current && !hidden) {
1658
+ const node = areaRef.current;
1659
+ if (node !== null && !composing.current) node.focus();
1660
+ }
1661
+ wasHidden.current = hidden;
1662
+ }, [hidden]);
1124
1663
  const commit = (0, import_react.useCallback)(
1125
1664
  (edit) => {
1126
1665
  if (edit === null) return;
@@ -1141,19 +1680,22 @@ window.__ModuleLoader__.load({
1141
1680
  },
1142
1681
  [maxLength, onChange, value]
1143
1682
  );
1683
+ function saveOnce(event) {
1684
+ event.preventDefault();
1685
+ event.stopPropagation();
1686
+ if (!event.repeat) onSave?.();
1687
+ }
1144
1688
  function onKeyDown(event) {
1145
1689
  if (guarded(event)) return;
1146
1690
  const node = event.currentTarget;
1147
1691
  const modifier = event.metaKey || event.ctrlKey;
1148
1692
  if (event.key !== "Tab" && event.key !== "Escape") tabEscape.current = false;
1149
1693
  if (modifier && (event.key === "s" || event.key === "S")) {
1150
- event.preventDefault();
1151
- if (!event.repeat) onSave?.();
1694
+ saveOnce(event);
1152
1695
  return;
1153
1696
  }
1154
1697
  if (modifier && event.key === "Enter") {
1155
- event.preventDefault();
1156
- if (!event.repeat) onSave?.();
1698
+ saveOnce(event);
1157
1699
  return;
1158
1700
  }
1159
1701
  if (event.key === "Escape") {
@@ -1171,7 +1713,7 @@ window.__ModuleLoader__.load({
1171
1713
  return;
1172
1714
  }
1173
1715
  if (event.key === "Enter" && !modifier && !event.shiftKey && !event.altKey) {
1174
- const continuation = continueList(value, node.selectionStart, node.selectionEnd);
1716
+ const continuation = continueLine(value, node.selectionStart, node.selectionEnd);
1175
1717
  if (continuation === null) return;
1176
1718
  event.preventDefault();
1177
1719
  commit(continuation);
@@ -1185,57 +1727,78 @@ window.__ModuleLoader__.load({
1185
1727
  if (node === null) return;
1186
1728
  commit(action.run({ value, start: node.selectionStart, end: node.selectionEnd, locale }));
1187
1729
  }
1188
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-ed-root", "data-disabled": disabled ? "true" : void 0, children: [
1189
- toolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1190
- "div",
1191
- {
1192
- className: "skw-ed-toolbar",
1193
- role: "toolbar",
1194
- "aria-label": TOOLBAR_LABEL[locale],
1195
- onMouseDown: onToolbarMouseDown,
1196
- children: TOOLBAR.map((group) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-ed-group", role: "group", "aria-label": group[locale], children: group.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1197
- "button",
1730
+ const rootStyle = hidden ? { display: "none" } : void 0;
1731
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1732
+ "div",
1733
+ {
1734
+ className: "skw-ed-root",
1735
+ style: rootStyle,
1736
+ "data-hidden": hidden ? "true" : void 0,
1737
+ "data-disabled": disabled ? "true" : void 0,
1738
+ "data-fill": fill ? "true" : void 0,
1739
+ "aria-hidden": hidden ? "true" : void 0,
1740
+ children: [
1741
+ toolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1742
+ "div",
1198
1743
  {
1199
- type: "button",
1200
- className: "skw-ed-btn",
1201
- "data-action": action.id,
1202
- "data-style": action.style,
1203
- "aria-label": action[locale],
1204
- title: action[locale],
1205
- disabled,
1206
- onClick: () => {
1207
- runAction(action);
1744
+ className: "skw-ed-toolbar",
1745
+ role: "toolbar",
1746
+ "aria-label": labelOf(TOOLBAR_LABEL),
1747
+ onMouseDown: onToolbarMouseDown,
1748
+ children: TOOLBAR.map((group) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-ed-group", role: "group", "aria-label": labelOf(group), children: group.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1749
+ "button",
1750
+ {
1751
+ type: "button",
1752
+ className: "skw-ed-btn",
1753
+ "data-action": action.id,
1754
+ "data-style": action.style,
1755
+ "aria-label": labelOf(action),
1756
+ title: labelOf(action),
1757
+ disabled,
1758
+ onClick: () => {
1759
+ runAction(action);
1760
+ },
1761
+ children: action.glyph
1762
+ },
1763
+ action.id
1764
+ )) }, group.id))
1765
+ }
1766
+ ),
1767
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1768
+ "textarea",
1769
+ {
1770
+ ref: areaRef,
1771
+ className: "skw-ed-input",
1772
+ value,
1773
+ onChange: (event) => {
1774
+ onChange(event.target.value);
1208
1775
  },
1209
- children: action.glyph
1210
- },
1211
- action.id
1212
- )) }, group.id))
1213
- }
1214
- ),
1215
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1216
- "textarea",
1217
- {
1218
- ref: areaRef,
1219
- className: "skw-ed-input",
1220
- value,
1221
- onChange: (event) => {
1222
- onChange(event.target.value);
1223
- },
1224
- onKeyDown,
1225
- placeholder,
1226
- maxLength,
1227
- disabled,
1228
- "aria-label": label,
1229
- autoComplete: "off",
1230
- spellCheck: true
1231
- }
1232
- )
1233
- ] });
1776
+ onKeyDown,
1777
+ placeholder,
1778
+ maxLength,
1779
+ disabled,
1780
+ "aria-label": label,
1781
+ autoComplete: "off",
1782
+ spellCheck: true
1783
+ }
1784
+ )
1785
+ ]
1786
+ }
1787
+ );
1234
1788
  }
1235
1789
  var EDITOR_CSS = `
1236
1790
  .skw-ed-root { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
1237
1791
  .skw-ed-root *, .skw-ed-root *::before, .skw-ed-root *::after { box-sizing: border-box; }
1238
1792
  .skw-ed-root[data-disabled="true"] { opacity: .7; }
1793
+ /* Hidden by the composer's preview toggle. The inline style is what actually
1794
+ hides it (an author display rule beats the UA sheet's [hidden] rule, so the
1795
+ attribute alone leaves the editor laid out); this rule is the belt to that
1796
+ braces for a caller that sets the data attribute without the style. */
1797
+ .skw-ed-root[data-hidden="true"] { display: none !important; }
1798
+ /* Fill mode: the sheet gives the editor a box and the editor fills it, so a
1799
+ taller sheet means more visible text instead of more empty sheet. */
1800
+ .skw-ed-root[data-fill="true"] { flex: 1 1 auto; min-height: 0; }
1801
+ .skw-ed-root[data-fill="true"] .skw-ed-input { flex: 1 1 auto; min-height: 96px; }
1239
1802
  .skw-ed-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); }
1240
1803
  .skw-ed-group { display: inline-flex; align-items: center; gap: 1px; padding: 0 2px; }
1241
1804
  .skw-ed-group + .skw-ed-group { border-left: 1px solid var(--dsw-alias-border-l1); }
@@ -1252,6 +1815,223 @@ window.__ModuleLoader__.load({
1252
1815
  .skw-ed-input:disabled { opacity: .7; }
1253
1816
  `;
1254
1817
 
1818
+ // src/client/use-sheet-size.ts
1819
+ var import_react2 = require("react");
1820
+
1821
+ // src/client/sheet-size.ts
1822
+ var SHEET_DEFAULT = { width: 880, height: 680 };
1823
+ var SHEET_MIN = { width: 460, height: 380 };
1824
+ var SHEET_MARGIN = 24;
1825
+ var SHEET_STORAGE_KEY = "skillre-sticky-wall.sheet-size";
1826
+ var SHEET_KEY_STEP = 16;
1827
+ var SHEET_KEY_STEP_LARGE = 64;
1828
+ function clampAxis(value, min, max) {
1829
+ const hi = Number.isFinite(max) ? Math.max(1, Math.round(max)) : Math.max(1, Math.round(min));
1830
+ const lo = Math.min(Math.round(min), hi);
1831
+ if (Number.isNaN(value)) return lo;
1832
+ if (value === Number.POSITIVE_INFINITY) return hi;
1833
+ if (value === Number.NEGATIVE_INFINITY) return lo;
1834
+ return Math.min(hi, Math.max(lo, Math.round(value)));
1835
+ }
1836
+ function clampSheetSize(size, viewport) {
1837
+ return {
1838
+ width: clampAxis(size.width, SHEET_MIN.width, viewport.width - SHEET_MARGIN * 2),
1839
+ height: clampAxis(size.height, SHEET_MIN.height, viewport.height - SHEET_MARGIN * 2)
1840
+ };
1841
+ }
1842
+ function resizeSheet(start, delta, viewport) {
1843
+ return clampSheetSize({ width: start.width + delta.dx, height: start.height + delta.dy }, viewport);
1844
+ }
1845
+ function mergePreference(previous, applied, next) {
1846
+ return {
1847
+ width: next.width === applied.width ? previous.width : next.width,
1848
+ height: next.height === applied.height ? previous.height : next.height
1849
+ };
1850
+ }
1851
+ function arrowDelta(key, large) {
1852
+ const step = large ? SHEET_KEY_STEP_LARGE : SHEET_KEY_STEP;
1853
+ switch (key) {
1854
+ case "ArrowLeft":
1855
+ return { dx: -step, dy: 0 };
1856
+ case "ArrowRight":
1857
+ return { dx: step, dy: 0 };
1858
+ case "ArrowUp":
1859
+ return { dx: 0, dy: -step };
1860
+ case "ArrowDown":
1861
+ return { dx: 0, dy: step };
1862
+ default:
1863
+ return null;
1864
+ }
1865
+ }
1866
+ function parseSheetSize(raw) {
1867
+ if (raw === null) return null;
1868
+ const text = raw.trim();
1869
+ if (text === "") return null;
1870
+ let parsed;
1871
+ try {
1872
+ parsed = JSON.parse(text);
1873
+ } catch {
1874
+ return null;
1875
+ }
1876
+ if (typeof parsed !== "object" || parsed === null) return null;
1877
+ const record = parsed;
1878
+ const width = record.width;
1879
+ const height = record.height;
1880
+ if (typeof width !== "number" || typeof height !== "number") return null;
1881
+ if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
1882
+ if (width <= 0 || height <= 0) return null;
1883
+ return { width: Math.round(width), height: Math.round(height) };
1884
+ }
1885
+ function serializeSheetSize(size) {
1886
+ return JSON.stringify({ width: Math.round(size.width), height: Math.round(size.height) });
1887
+ }
1888
+ function readSheetSize(storage) {
1889
+ if (storage === null || storage === void 0) return null;
1890
+ try {
1891
+ return parseSheetSize(storage.getItem(SHEET_STORAGE_KEY));
1892
+ } catch {
1893
+ return null;
1894
+ }
1895
+ }
1896
+ function writeSheetSize(storage, size) {
1897
+ if (storage === null || storage === void 0) return;
1898
+ try {
1899
+ storage.setItem(SHEET_STORAGE_KEY, serializeSheetSize(size));
1900
+ } catch {
1901
+ }
1902
+ }
1903
+
1904
+ // src/client/use-sheet-size.ts
1905
+ function browserStorage() {
1906
+ try {
1907
+ return globalThis.localStorage ?? null;
1908
+ } catch {
1909
+ return null;
1910
+ }
1911
+ }
1912
+ function viewportNow() {
1913
+ const width = typeof globalThis.innerWidth === "number" ? globalThis.innerWidth : 0;
1914
+ const height = typeof globalThis.innerHeight === "number" ? globalThis.innerHeight : 0;
1915
+ return { width: Math.max(1, width), height: Math.max(1, height) };
1916
+ }
1917
+ function useSheetSize() {
1918
+ const [preferred, setPreferred] = (0, import_react2.useState)(() => readSheetSize(browserStorage()) ?? { ...SHEET_DEFAULT });
1919
+ const [viewport, setViewport] = (0, import_react2.useState)(viewportNow);
1920
+ const latest = (0, import_react2.useRef)({ preferred, viewport });
1921
+ latest.current = { preferred, viewport };
1922
+ const storage = (0, import_react2.useRef)(null);
1923
+ storage.current ??= browserStorage();
1924
+ const persist = (0, import_react2.useCallback)((size) => {
1925
+ writeSheetSize(storage.current, size);
1926
+ }, []);
1927
+ const commit = (0, import_react2.useCallback)(
1928
+ (size) => {
1929
+ latest.current = { ...latest.current, preferred: size };
1930
+ setPreferred(size);
1931
+ persist(size);
1932
+ },
1933
+ [persist]
1934
+ );
1935
+ const reset = (0, import_react2.useCallback)(() => {
1936
+ commit({ ...SHEET_DEFAULT });
1937
+ }, [commit]);
1938
+ (0, import_react2.useLayoutEffect)(() => {
1939
+ const sync = () => {
1940
+ const next = viewportNow();
1941
+ const current = latest.current.viewport;
1942
+ if (next.width === current.width && next.height === current.height) return;
1943
+ latest.current = { ...latest.current, viewport: next };
1944
+ setViewport(next);
1945
+ };
1946
+ globalThis.addEventListener?.("resize", sync);
1947
+ return () => {
1948
+ globalThis.removeEventListener?.("resize", sync);
1949
+ };
1950
+ }, []);
1951
+ const drag = (0, import_react2.useRef)(null);
1952
+ const onPointerDown = (0, import_react2.useCallback)((event) => {
1953
+ if (event.button !== 0) return;
1954
+ event.preventDefault();
1955
+ try {
1956
+ event.currentTarget.focus();
1957
+ } catch {
1958
+ }
1959
+ drag.current = {
1960
+ pointerId: event.pointerId,
1961
+ start: clampSheetSize(latest.current.preferred, latest.current.viewport),
1962
+ startPreference: latest.current.preferred,
1963
+ x: event.clientX,
1964
+ y: event.clientY,
1965
+ moved: false
1966
+ };
1967
+ try {
1968
+ event.currentTarget.setPointerCapture?.(event.pointerId);
1969
+ } catch {
1970
+ }
1971
+ }, []);
1972
+ const onPointerMove = (0, import_react2.useCallback)((event) => {
1973
+ const current = drag.current;
1974
+ if (current === null || current.pointerId !== event.pointerId) return;
1975
+ const dx = event.clientX - current.x;
1976
+ const dy = event.clientY - current.y;
1977
+ if (dx === 0 && dy === 0) return;
1978
+ current.moved = true;
1979
+ const next = resizeSheet(current.start, { dx, dy }, latest.current.viewport);
1980
+ latest.current = { ...latest.current, preferred: next };
1981
+ setPreferred(next);
1982
+ }, []);
1983
+ const finish = (0, import_react2.useCallback)(
1984
+ (event) => {
1985
+ const current = drag.current;
1986
+ if (current === null || current.pointerId !== event.pointerId) return;
1987
+ drag.current = null;
1988
+ try {
1989
+ event.currentTarget.releasePointerCapture?.(current.pointerId);
1990
+ } catch {
1991
+ }
1992
+ if (!current.moved) return;
1993
+ const applied = clampSheetSize(current.startPreference, latest.current.viewport);
1994
+ commit(mergePreference(current.startPreference, applied, latest.current.preferred));
1995
+ },
1996
+ [commit]
1997
+ );
1998
+ const onKeyDown = (0, import_react2.useCallback)(
1999
+ (event) => {
2000
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
2001
+ if (event.repeat) return;
2002
+ if (event.key === "0") {
2003
+ event.preventDefault();
2004
+ event.stopPropagation();
2005
+ reset();
2006
+ return;
2007
+ }
2008
+ const delta = arrowDelta(event.key, event.shiftKey);
2009
+ if (delta === null) return;
2010
+ event.preventDefault();
2011
+ event.stopPropagation();
2012
+ const applied = clampSheetSize(latest.current.preferred, latest.current.viewport);
2013
+ const next = resizeSheet(applied, delta, latest.current.viewport);
2014
+ commit(mergePreference(latest.current.preferred, applied, next));
2015
+ },
2016
+ [commit, reset]
2017
+ );
2018
+ return {
2019
+ size: clampSheetSize(preferred, viewport),
2020
+ bounds: {
2021
+ min: clampSheetSize({ width: 0, height: 0 }, viewport),
2022
+ max: clampSheetSize({ width: Number.POSITIVE_INFINITY, height: Number.POSITIVE_INFINITY }, viewport)
2023
+ },
2024
+ grip: {
2025
+ onPointerDown,
2026
+ onPointerMove,
2027
+ onPointerUp: finish,
2028
+ onPointerCancel: finish,
2029
+ onKeyDown,
2030
+ onDoubleClick: reset
2031
+ }
2032
+ };
2033
+ }
2034
+
1255
2035
  // src/client/styles.ts
1256
2036
  var WALL_CSS = `
1257
2037
  .skw-page {
@@ -1670,8 +2450,41 @@ window.__ModuleLoader__.load({
1670
2450
 
1671
2451
  /* Rendered Markdown.
1672
2452
  Sized in em so it follows the card's own font size at every width preset,
1673
- and kept quiet: headings are one step up, not a document outline. */
1674
- .skw-md { font-size: inherit; line-height: inherit; }
2453
+ and kept quiet: headings are one step up, not a document outline.
2454
+
2455
+ The palette is a MIDDLE LAYER declared on .skw-md itself, because that one
2456
+ element is rendered on two surfaces: inside a note card, and inside the
2457
+ composer's neutral preview pane, which is NOT a .skw-note. A note's own
2458
+ --skw-note-* variables exist only on .skw-note, so a .skw-md-* rule that read
2459
+ them directly resolved to nothing in the preview pane \u2014 and every color-mix()
2460
+ built on that empty variable was an invalid declaration there, which is why
2461
+ the preview lost its code chip, quote rail, rule and table borders. Routing
2462
+ every rule through --skw-md-* fixes that at the source.
2463
+
2464
+ The defaults are the shell's own label/brand tokens, so a .skw-md on a neutral
2465
+ surface is readable with no extra rule. A note card re-points the layer at its
2466
+ own palette below. The fallback inside each var() is the last resort for a
2467
+ .skw-md rendered outside the sheet entirely. */
2468
+ .skw-md {
2469
+ font-size: inherit; line-height: inherit;
2470
+ --skw-md-ink: var(--dsw-alias-label-primary);
2471
+ --skw-md-accent: var(--dsw-alias-brand-primary);
2472
+ --skw-md-accent-ink: var(--dsw-alias-brand-primary);
2473
+ }
2474
+ /* A note card re-points the middle layer at its own palette, so a card's
2475
+ Markdown keeps exactly the colors it had when the rules read --skw-note-*
2476
+ directly. This MUST be a descendant rule and not a line inside the twelve
2477
+ .skw-note[data-color] palette rules: a custom property declared on .skw-md
2478
+ beats an inherited value from its ancestor, so a note-level
2479
+ --skw-md-ink: var(--skw-note-ink) would be shadowed by the default above and
2480
+ change nothing. This selector's specificity is what wins.
2481
+ Dark mode needs no extra rule: the palette rules already restate --skw-note-*
2482
+ under body[data-ds-dark-theme], and this mapping inherits. */
2483
+ .skw-note .skw-md {
2484
+ --skw-md-ink: var(--skw-note-ink);
2485
+ --skw-md-accent: var(--skw-note-accent);
2486
+ --skw-md-accent-ink: var(--skw-note-accent-ink);
2487
+ }
1675
2488
  .skw-md[data-compact="true"] > *:first-child { margin-top: 0; }
1676
2489
  .skw-md[data-compact="true"] > *:last-child { margin-bottom: 0; }
1677
2490
  .skw-md .skw-md-p { margin: 0 0 .5em; }
@@ -1683,51 +2496,52 @@ window.__ModuleLoader__.load({
1683
2496
  .skw-md h5.skw-md-heading, .skw-md h6.skw-md-heading { font-size: 1em; }
1684
2497
  .skw-md .skw-md-list { margin: .35em 0 .55em; padding-left: 1.15em; }
1685
2498
  .skw-md .skw-md-list li { margin: .12em 0; }
1686
- .skw-md .skw-md-list li::marker { color: var(--skw-note-accent-ink); }
2499
+ .skw-md .skw-md-list li::marker { color: var(--skw-md-accent-ink, currentColor); }
1687
2500
  .skw-md .skw-md-pre {
1688
2501
  margin: .45em 0; padding: 7px 9px; border-radius: 7px; overflow: auto;
1689
- background: color-mix(in srgb, var(--skw-note-ink) 9%, transparent);
1690
- border: 1px solid color-mix(in srgb, var(--skw-note-ink) 14%, transparent);
2502
+ background: color-mix(in srgb, var(--skw-md-ink, currentColor) 9%, transparent);
2503
+ border: 1px solid color-mix(in srgb, var(--skw-md-ink, currentColor) 14%, transparent);
1691
2504
  font-size: .92em; line-height: 1.45; max-height: 180px;
1692
2505
  }
1693
2506
  .skw-md .skw-md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
1694
2507
  .skw-md .skw-md-code {
1695
2508
  padding: .08em .34em; border-radius: 4px; font-size: .94em;
1696
2509
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
1697
- background: color-mix(in srgb, var(--skw-note-ink) 11%, transparent);
2510
+ background: color-mix(in srgb, var(--skw-md-ink, currentColor) 11%, transparent);
1698
2511
  }
1699
2512
  .skw-md .skw-md-quote {
1700
2513
  margin: .4em 0; padding: .1em 0 .1em .7em;
1701
- border-left: 2px solid var(--skw-note-accent);
1702
- color: color-mix(in srgb, var(--skw-note-ink) 82%, transparent);
2514
+ border-left: 2px solid var(--skw-md-accent, currentColor);
2515
+ color: color-mix(in srgb, var(--skw-md-ink, currentColor) 82%, transparent);
1703
2516
  }
1704
- .skw-md .skw-md-rule { margin: .6em 0; border: 0; border-top: 1px solid color-mix(in srgb, var(--skw-note-ink) 22%, transparent); }
1705
- .skw-md .skw-md-link { color: var(--skw-note-accent-ink); text-decoration: underline; text-underline-offset: 2px; }
2517
+ .skw-md .skw-md-rule { margin: .6em 0; border: 0; border-top: 1px solid color-mix(in srgb, var(--skw-md-ink, currentColor) 22%, transparent); }
2518
+ .skw-md .skw-md-link { color: var(--skw-md-accent-ink, currentColor); text-decoration: underline; text-underline-offset: 2px; }
1706
2519
  .skw-md .skw-md-link:hover { text-decoration-thickness: 2px; }
1707
2520
  .skw-md .skw-md-table { margin: .45em 0; border-collapse: collapse; width: 100%; font-size: .94em; }
1708
2521
  .skw-md .skw-md-table th, .skw-md .skw-md-table td {
1709
- padding: 3px 6px; border: 1px solid color-mix(in srgb, var(--skw-note-ink) 18%, transparent); text-align: left;
2522
+ padding: 3px 6px; border: 1px solid color-mix(in srgb, var(--skw-md-ink, currentColor) 18%, transparent); text-align: left;
1710
2523
  }
1711
- .skw-md .skw-md-table th { background: color-mix(in srgb, var(--skw-note-ink) 7%, transparent); font-weight: 600; }
2524
+ .skw-md .skw-md-table th { background: color-mix(in srgb, var(--skw-md-ink, currentColor) 7%, transparent); font-weight: 600; }
1712
2525
  .skw-md .skw-md-task { display: inline-flex; align-items: baseline; gap: 5px; }
1713
2526
  .skw-md .skw-md-box {
1714
2527
  display: inline-flex; align-items: center; justify-content: center;
1715
2528
  width: 12px; height: 12px; flex: none; border-radius: 3px; font-size: 9px; line-height: 1;
1716
- border: 1px solid color-mix(in srgb, var(--skw-note-ink) 40%, transparent);
2529
+ border: 1px solid color-mix(in srgb, var(--skw-md-ink, currentColor) 40%, transparent);
1717
2530
  }
1718
- .skw-md .skw-md-task[data-checked="true"] .skw-md-box { background: var(--skw-note-accent); border-color: transparent; color: var(--skw-note-accent-ink); }
2531
+ .skw-md .skw-md-task[data-checked="true"] .skw-md-box { background: var(--skw-md-accent, currentColor); border-color: transparent; color: var(--skw-md-accent-ink, currentColor); }
1719
2532
  .skw-md .skw-md-task[data-checked="true"] { opacity: .78; }
1720
2533
 
1721
- /* Composer preview pane: same Markdown, on a neutral sheet instead of a note. */
2534
+ /* Composer preview pane: the same Markdown on a neutral sheet instead of a note.
2535
+ It needs NO palette overrides of its own: .skw-md above already resolves the
2536
+ middle layer to the theme tokens here (there is no .skw-note ancestor to
2537
+ supply --skw-note-*), so every .skw-md-* rule renders on both surfaces from
2538
+ one definition instead of a per-surface patch list. */
1722
2539
  .skw-preview-box {
1723
2540
  min-height: 132px; max-height: 42vh; overflow: auto; padding: 9px 11px;
1724
2541
  border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px;
1725
2542
  background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary);
1726
2543
  font-size: 13px; line-height: 20px;
1727
2544
  }
1728
- .skw-preview-box .skw-md-link { color: var(--dsw-alias-brand-primary); }
1729
- .skw-preview-box .skw-md-code { background: var(--dsw-alias-bg-layer-2); }
1730
- .skw-preview-box .skw-md-pre { background: var(--dsw-alias-bg-layer-2); border-color: var(--dsw-alias-border-l1); }
1731
2545
  .skw-preview-empty { margin: 0; color: var(--dsw-alias-label-tertiary); }
1732
2546
  .skw-sheet-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
1733
2547
  .skw-sheet-row .skw-spacer { flex: 1; }
@@ -1802,7 +2616,44 @@ window.__ModuleLoader__.load({
1802
2616
 
1803
2617
  /* Composer sheet */
1804
2618
  .skw-scrim { position: fixed; inset: 0; background: var(--dsw-alias-bg-mask-2); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 40; }
1805
- .skw-sheet { width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; border-radius: 12px; border: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-base); box-shadow: 0 12px 40px var(--dsw-alias-bg-mask-3); overflow: hidden; }
2619
+ .skw-sheet { position: relative; width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; border-radius: 12px; border: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-base); box-shadow: 0 12px 40px var(--dsw-alias-bg-mask-3); overflow: hidden; }
2620
+ /* The composer sheet: large by default and sized by the user. These are the
2621
+ FALLBACKS only \u2014 the hook writes an explicit width/height inline, already
2622
+ clamped to the current window. They matter for the one frame before the
2623
+ client script runs, and for a user whose stored size has no viewport to fit.
2624
+ The 48px is SHEET_MARGIN * 2 (24px per side): if the two ever disagree, this
2625
+ max-height silently caps the sheet below the size the hook thinks it has,
2626
+ which shows up as the last few pixels of a downward drag doing nothing. It
2627
+ must stay in step with sheet-size.ts. */
2628
+ .skw-sheet-composer { width: min(880px, 100%); height: min(680px, calc(100vh - 48px)); max-height: calc(100vh - 48px); }
2629
+ /* Fill mode: the sheet's own fields keep their natural height and the editor
2630
+ takes everything left, so a taller sheet means MORE VISIBLE TEXT rather than
2631
+ more empty sheet. */
2632
+ .skw-sheet-body[data-fill="true"] { flex: 1 1 auto; min-height: 0; overflow: auto; }
2633
+ .skw-sheet-body[data-fill="true"] > .skw-input,
2634
+ .skw-sheet-body[data-fill="true"] > .skw-sheet-row { flex: 0 0 auto; }
2635
+ .skw-preview-fill { flex: 1 1 auto; min-height: 96px; max-height: none; }
2636
+ /* A hint exposed to assistive technology only: a title attribute is not an
2637
+ accessible description, so the keyboard contract lives in real DOM text. */
2638
+ .skw-sr-only {
2639
+ position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
2640
+ overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
2641
+ }
2642
+ /* The resize grip: a 22px corner, reachable by pointer, keyboard and double
2643
+ click. touch-action: none is what lets a touch drag resize instead of
2644
+ scrolling the page behind the scrim. */
2645
+ .skw-sheet-grip {
2646
+ position: absolute; right: 2px; bottom: 2px; width: 22px; height: 22px;
2647
+ display: flex; align-items: center; justify-content: center;
2648
+ color: var(--dsw-alias-label-tertiary); cursor: nwse-resize;
2649
+ touch-action: none; border-radius: 4px; user-select: none;
2650
+ }
2651
+ .skw-sheet-grip:hover { color: var(--dsw-alias-label-secondary); }
2652
+ .skw-sheet-grip:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: -2px; color: var(--dsw-alias-label-primary); }
2653
+ /* The footer's buttons must never sit under the grip: the grip is 22px wide at
2654
+ right: 2px, so it occupies the rightmost 24px and 30px leaves 6px of air.
2655
+ Change the grip's size and this number together. */
2656
+ .skw-sheet-composer .skw-sheet-foot { padding-right: 30px; }
1806
2657
  .skw-sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--dsw-alias-border-l1); font-weight: 600; }
1807
2658
  .skw-sheet-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; overflow: auto; }
1808
2659
  .skw-input, .skw-textarea { width: 100%; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); padding: 7px 10px; }
@@ -1900,9 +2751,11 @@ window.__ModuleLoader__.load({
1900
2751
  onSave,
1901
2752
  onCancel
1902
2753
  }) {
1903
- const [preview, setPreview] = (0, import_react2.useState)(false);
1904
- const [confirmDiscard, setConfirmDiscard] = (0, import_react2.useState)(false);
1905
- const initial = (0, import_react2.useRef)(JSON.stringify(draft));
2754
+ const [preview, setPreview] = (0, import_react3.useState)(false);
2755
+ const [confirmDiscard, setConfirmDiscard] = (0, import_react3.useState)(false);
2756
+ const sheet = useSheetSize();
2757
+ const hintId = (0, import_react3.useId)();
2758
+ const initial = (0, import_react3.useRef)(JSON.stringify(draft));
1906
2759
  const dirty = JSON.stringify(draft) !== initial.current;
1907
2760
  const requestClose = () => {
1908
2761
  if (busy) return;
@@ -1922,10 +2775,11 @@ window.__ModuleLoader__.load({
1922
2775
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1923
2776
  "div",
1924
2777
  {
1925
- className: "skw-sheet",
2778
+ className: "skw-sheet skw-sheet-composer",
1926
2779
  role: "dialog",
1927
2780
  "aria-modal": "true",
1928
2781
  "aria-label": draft.id ? t("edit") : t("new"),
2782
+ style: { width: `${sheet.size.width}px`, height: `${sheet.size.height}px` },
1929
2783
  onKeyDown: (event) => {
1930
2784
  if (event.repeat) return;
1931
2785
  if (isComposingEvent(event.nativeEvent)) return;
@@ -1936,6 +2790,7 @@ window.__ModuleLoader__.load({
1936
2790
  }
1937
2791
  },
1938
2792
  children: [
2793
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: hintId, className: "skw-sr-only", children: t("resizeSheetHint") }),
1939
2794
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-head", children: [
1940
2795
  draft.id ? t("edit") : t("new"),
1941
2796
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
@@ -1951,7 +2806,7 @@ window.__ModuleLoader__.load({
1951
2806
  }
1952
2807
  )
1953
2808
  ] }),
1954
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-body", children: [
2809
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-body", "data-fill": "true", children: [
1955
2810
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1956
2811
  "input",
1957
2812
  {
@@ -1963,10 +2818,14 @@ window.__ModuleLoader__.load({
1963
2818
  "aria-label": t("titlePlaceholder")
1964
2819
  }
1965
2820
  ),
1966
- preview ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-preview-box", children: draft.body.trim() === "" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-preview-empty", children: t("bodyPlaceholder") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { source: draft.body }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2821
+ preview && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-preview-box skw-preview-fill", children: draft.body.trim() === "" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-preview-empty", children: t("bodyPlaceholder") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { source: draft.body }) }),
2822
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1967
2823
  MarkdownEditor,
1968
2824
  {
1969
2825
  value: draft.body,
2826
+ fill: true,
2827
+ hidden: preview,
2828
+ t,
1970
2829
  onChange: (body) => onChange({ body }),
1971
2830
  onSave: save,
1972
2831
  onEscape: requestClose,
@@ -2022,7 +2881,24 @@ window.__ModuleLoader__.load({
2022
2881
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
2023
2882
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-btn", type: "button", onClick: requestClose, disabled: busy, children: t("cancel") }),
2024
2883
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-btn skw-btn-primary", type: "button", onClick: save, disabled: busy, children: t("save") })
2025
- ] })
2884
+ ] }),
2885
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2886
+ "div",
2887
+ {
2888
+ className: "skw-sheet-grip",
2889
+ role: "separator",
2890
+ "aria-label": t("resizeSheet"),
2891
+ "aria-valuenow": sheet.size.width,
2892
+ "aria-valuemin": sheet.bounds.min.width,
2893
+ "aria-valuemax": sheet.bounds.max.width,
2894
+ "aria-valuetext": `${sheet.size.width}\xD7${sheet.size.height}px`,
2895
+ "aria-describedby": hintId,
2896
+ tabIndex: 0,
2897
+ title: t("resizeSheetHint"),
2898
+ ...sheet.grip,
2899
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M9 1 1 9M9 5 5 9", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" }) })
2900
+ }
2901
+ )
2026
2902
  ]
2027
2903
  }
2028
2904
  ),
@@ -2052,8 +2928,8 @@ window.__ModuleLoader__.load({
2052
2928
  onConfirm,
2053
2929
  onCancel
2054
2930
  }) {
2055
- const cancelRef = (0, import_react2.useRef)(null);
2056
- (0, import_react2.useEffect)(() => {
2931
+ const cancelRef = (0, import_react3.useRef)(null);
2932
+ (0, import_react3.useEffect)(() => {
2057
2933
  const previous = typeof document === "undefined" ? null : document.activeElement;
2058
2934
  cancelRef.current?.focus();
2059
2935
  return () => {
@@ -2097,7 +2973,7 @@ window.__ModuleLoader__.load({
2097
2973
  }
2098
2974
  );
2099
2975
  }
2100
- var NoteCard = (0, import_react2.memo)(function NoteCard2({
2976
+ var NoteCard = (0, import_react3.memo)(function NoteCard2({
2101
2977
  note,
2102
2978
  index,
2103
2979
  surface,
@@ -2243,63 +3119,63 @@ window.__ModuleLoader__.load({
2243
3119
  ] });
2244
3120
  }
2245
3121
  function WallPage({ api, locale, t }) {
2246
- const [notes, setNotes] = (0, import_react2.useState)([]);
2247
- const [filter, setFilter] = (0, import_react2.useState)("all");
2248
- const [sort, setSort] = (0, import_react2.useState)("pinned");
2249
- const [view, setView] = (0, import_react2.useState)("canvas");
2250
- const [query, setQuery] = (0, import_react2.useState)("");
2251
- const [showArchived, setShowArchived] = (0, import_react2.useState)(false);
2252
- const [loading, setLoading] = (0, import_react2.useState)(true);
2253
- const [busy, setBusy] = (0, import_react2.useState)(false);
2254
- const [error, setError] = (0, import_react2.useState)("");
2255
- const [draft, setDraft] = (0, import_react2.useState)(null);
2256
- const [draftError, setDraftError] = (0, import_react2.useState)("");
2257
- const [draftStatus, setDraftStatus] = (0, import_react2.useState)("idle");
2258
- const [notesDir, setNotesDir] = (0, import_react2.useState)("");
2259
- const [confirming, setConfirming] = (0, import_react2.useState)(null);
2260
- const [zoom, setZoom] = (0, import_react2.useState)(1);
2261
- const [viewportTick, setViewportTick] = (0, import_react2.useState)(0);
2262
- const [capture, setCapture] = (0, import_react2.useState)("");
2263
- const [arrivedId, setArrivedId] = (0, import_react2.useState)(null);
2264
- const [menuOpen, setMenuOpen] = (0, import_react2.useState)(false);
2265
- const [, setLocaleRevision] = (0, import_react2.useState)(0);
2266
- const alive = (0, import_react2.useRef)(true);
2267
- const life = (0, import_react2.useRef)(new AbortController());
2268
- const sequence = (0, import_react2.useRef)(0);
2269
- const inFlight = (0, import_react2.useRef)(false);
2270
- const queue = (0, import_react2.useRef)(Promise.resolve());
2271
- const revision = (0, import_react2.useRef)(0);
2272
- const draftOpen = (0, import_react2.useRef)(false);
2273
- const viewportRefCurrent = (0, import_react2.useRef)(null);
2274
- const worldRef = (0, import_react2.useRef)(null);
2275
- const centreRef = (0, import_react2.useRef)(null);
2276
- const menuRef = (0, import_react2.useRef)(null);
2277
- const dockRef = (0, import_react2.useRef)(null);
2278
- const detachWheel = (0, import_react2.useRef)(null);
2279
- const camera = (0, import_react2.useRef)({ zoom: 1, panX: 0, panY: 0 });
2280
- const centreRequest = (0, import_react2.useRef)(true);
2281
- const drag = (0, import_react2.useRef)(null);
2282
- const pan = (0, import_react2.useRef)(null);
2283
- const live = (0, import_react2.useRef)({ mutate: (_run) => {
3122
+ const [notes, setNotes] = (0, import_react3.useState)([]);
3123
+ const [filter, setFilter] = (0, import_react3.useState)("all");
3124
+ const [sort, setSort] = (0, import_react3.useState)("pinned");
3125
+ const [view, setView] = (0, import_react3.useState)("canvas");
3126
+ const [query, setQuery] = (0, import_react3.useState)("");
3127
+ const [showArchived, setShowArchived] = (0, import_react3.useState)(false);
3128
+ const [loading, setLoading] = (0, import_react3.useState)(true);
3129
+ const [busy, setBusy] = (0, import_react3.useState)(false);
3130
+ const [error, setError] = (0, import_react3.useState)("");
3131
+ const [draft, setDraft] = (0, import_react3.useState)(null);
3132
+ const [draftError, setDraftError] = (0, import_react3.useState)("");
3133
+ const [draftStatus, setDraftStatus] = (0, import_react3.useState)("idle");
3134
+ const [notesDir, setNotesDir] = (0, import_react3.useState)("");
3135
+ const [confirming, setConfirming] = (0, import_react3.useState)(null);
3136
+ const [zoom, setZoom] = (0, import_react3.useState)(1);
3137
+ const [viewportTick, setViewportTick] = (0, import_react3.useState)(0);
3138
+ const [capture, setCapture] = (0, import_react3.useState)("");
3139
+ const [arrivedId, setArrivedId] = (0, import_react3.useState)(null);
3140
+ const [menuOpen, setMenuOpen] = (0, import_react3.useState)(false);
3141
+ const [, setLocaleRevision] = (0, import_react3.useState)(0);
3142
+ const alive = (0, import_react3.useRef)(true);
3143
+ const life = (0, import_react3.useRef)(new AbortController());
3144
+ const sequence = (0, import_react3.useRef)(0);
3145
+ const inFlight = (0, import_react3.useRef)(false);
3146
+ const queue = (0, import_react3.useRef)(Promise.resolve());
3147
+ const revision = (0, import_react3.useRef)(0);
3148
+ const draftOpen = (0, import_react3.useRef)(false);
3149
+ const viewportRefCurrent = (0, import_react3.useRef)(null);
3150
+ const worldRef = (0, import_react3.useRef)(null);
3151
+ const centreRef = (0, import_react3.useRef)(null);
3152
+ const menuRef = (0, import_react3.useRef)(null);
3153
+ const dockRef = (0, import_react3.useRef)(null);
3154
+ const detachWheel = (0, import_react3.useRef)(null);
3155
+ const camera = (0, import_react3.useRef)({ zoom: 1, panX: 0, panY: 0 });
3156
+ const centreRequest = (0, import_react3.useRef)(true);
3157
+ const drag = (0, import_react3.useRef)(null);
3158
+ const pan = (0, import_react3.useRef)(null);
3159
+ const live = (0, import_react3.useRef)({ mutate: (_run) => {
2284
3160
  } });
2285
3161
  live.current.mutate = (run) => {
2286
3162
  void mutate(run);
2287
3163
  };
2288
3164
  const activeLocale = locale.getSnapshot().active;
2289
3165
  draftOpen.current = draft !== null;
2290
- const stableIndex = (0, import_react2.useMemo)(() => {
3166
+ const stableIndex = (0, import_react3.useMemo)(() => {
2291
3167
  const map = /* @__PURE__ */ new Map();
2292
3168
  notes.forEach((note, index) => map.set(note.id, index));
2293
3169
  return map;
2294
3170
  }, [notes]);
2295
3171
  const indexOf = (note) => stableIndex.get(note.id) ?? 0;
2296
- (0, import_react2.useEffect)(() => {
3172
+ (0, import_react3.useEffect)(() => {
2297
3173
  const unsubscribe = locale.subscribe(() => {
2298
3174
  if (alive.current) setLocaleRevision((value) => value + 1);
2299
3175
  });
2300
3176
  return unsubscribe;
2301
3177
  }, [locale]);
2302
- (0, import_react2.useEffect)(() => {
3178
+ (0, import_react3.useEffect)(() => {
2303
3179
  if (!menuOpen) return;
2304
3180
  const onPointerDown = (event) => {
2305
3181
  const node = menuRef.current;
@@ -2316,7 +3192,7 @@ window.__ModuleLoader__.load({
2316
3192
  window.removeEventListener("keydown", onKeyDown);
2317
3193
  };
2318
3194
  }, [menuOpen]);
2319
- const reload = (0, import_react2.useMemo)(() => async (options) => {
3195
+ const reload = (0, import_react3.useMemo)(() => async (options) => {
2320
3196
  const seq = ++sequence.current;
2321
3197
  setLoading(true);
2322
3198
  try {
@@ -2334,7 +3210,7 @@ window.__ModuleLoader__.load({
2334
3210
  }
2335
3211
  }, [api, t]);
2336
3212
  const includeArchived = showArchived || filter === "archived";
2337
- (0, import_react2.useEffect)(() => {
3213
+ (0, import_react3.useEffect)(() => {
2338
3214
  alive.current = true;
2339
3215
  life.current = new AbortController();
2340
3216
  void reload({ includeArchived, sort });
@@ -2344,7 +3220,7 @@ window.__ModuleLoader__.load({
2344
3220
  sequence.current += 1;
2345
3221
  };
2346
3222
  }, [reload, includeArchived, sort]);
2347
- (0, import_react2.useEffect)(() => {
3223
+ (0, import_react3.useEffect)(() => {
2348
3224
  let timer = 0;
2349
3225
  const check = async () => {
2350
3226
  if (!alive.current || life.current.signal.aborted) return;
@@ -2455,7 +3331,7 @@ window.__ModuleLoader__.load({
2455
3331
  setDraftStatus("idle");
2456
3332
  });
2457
3333
  }
2458
- const visible = (0, import_react2.useMemo)(() => {
3334
+ const visible = (0, import_react3.useMemo)(() => {
2459
3335
  const needle = query.trim().toLowerCase();
2460
3336
  return notes.filter((note) => {
2461
3337
  if (filter === "archived" && !note.archived) return false;
@@ -2466,13 +3342,13 @@ window.__ModuleLoader__.load({
2466
3342
  });
2467
3343
  }, [notes, filter, query, showArchived]);
2468
3344
  const archivedCount = notes.filter((note) => note.archived).length;
2469
- const greeting = (0, import_react2.useMemo)(() => {
3345
+ const greeting = (0, import_react3.useMemo)(() => {
2470
3346
  const hour = (/* @__PURE__ */ new Date()).getHours();
2471
3347
  const key = hour < 5 ? "greetNight" : hour < 12 ? "greetMorning" : hour < 18 ? "greetAfternoon" : "greetEvening";
2472
3348
  return t(key);
2473
3349
  }, [t, activeLocale]);
2474
3350
  const emptyCopy = filter === "archived" ? t("emptyArchived") : query.trim() !== "" ? t("noResults") : t("empty");
2475
- const wallBounds = (0, import_react2.useMemo)(() => {
3351
+ const wallBounds = (0, import_react3.useMemo)(() => {
2476
3352
  let minX = Number.POSITIVE_INFINITY;
2477
3353
  let minY = Number.POSITIVE_INFINITY;
2478
3354
  let maxX = Number.NEGATIVE_INFINITY;
@@ -2507,10 +3383,10 @@ window.__ModuleLoader__.load({
2507
3383
  };
2508
3384
  }, [visible, stableIndex]);
2509
3385
  const wallCentre = wallBounds.centre;
2510
- const boundsRef = (0, import_react2.useRef)(wallBounds);
3386
+ const boundsRef = (0, import_react3.useRef)(wallBounds);
2511
3387
  boundsRef.current = wallBounds;
2512
3388
  const hasNotes = visible.length > 0;
2513
- const applyCamera = (0, import_react2.useCallback)(() => {
3389
+ const applyCamera = (0, import_react3.useCallback)(() => {
2514
3390
  const current = camera.current;
2515
3391
  const world = worldRef.current;
2516
3392
  const viewport = viewportRefCurrent.current;
@@ -2525,14 +3401,14 @@ window.__ModuleLoader__.load({
2525
3401
  viewport.style.backgroundPosition = `${current.panX}px ${current.panY}px`;
2526
3402
  }
2527
3403
  }, []);
2528
- const tween = (0, import_react2.useRef)(0);
2529
- const stopTween = (0, import_react2.useCallback)(() => {
3404
+ const tween = (0, import_react3.useRef)(0);
3405
+ const stopTween = (0, import_react3.useCallback)(() => {
2530
3406
  if (tween.current !== 0) {
2531
3407
  cancelAnimationFrame(tween.current);
2532
3408
  tween.current = 0;
2533
3409
  }
2534
3410
  }, []);
2535
- const glideCameraTo = (0, import_react2.useCallback)((zoomTarget, panX, panY) => {
3411
+ const glideCameraTo = (0, import_react3.useCallback)((zoomTarget, panX, panY) => {
2536
3412
  const target = clampZoom(zoomTarget);
2537
3413
  const to = { zoom: target, panX, panY };
2538
3414
  stopTween();
@@ -2565,13 +3441,13 @@ window.__ModuleLoader__.load({
2565
3441
  tween.current = requestAnimationFrame(frame);
2566
3442
  setZoom(to.zoom);
2567
3443
  }, [applyCamera, stopTween]);
2568
- const glideTo = (0, import_react2.useCallback)((zoomTarget, worldX, worldY) => {
3444
+ const glideTo = (0, import_react3.useCallback)((zoomTarget, worldX, worldY) => {
2569
3445
  const viewport = viewportRefCurrent.current;
2570
3446
  if (viewport === null) return;
2571
3447
  const target = clampZoom(zoomTarget);
2572
3448
  glideCameraTo(target, viewport.clientWidth / 2 - worldX * target, viewport.clientHeight / 2 - worldY * target);
2573
3449
  }, [glideCameraTo]);
2574
- const centreOn = (0, import_react2.useCallback)((worldX, worldY) => {
3450
+ const centreOn = (0, import_react3.useCallback)((worldX, worldY) => {
2575
3451
  stopTween();
2576
3452
  const viewport = viewportRefCurrent.current;
2577
3453
  const current = camera.current;
@@ -2583,11 +3459,11 @@ window.__ModuleLoader__.load({
2583
3459
  }
2584
3460
  applyCamera();
2585
3461
  }, [applyCamera, stopTween]);
2586
- (0, import_react2.useEffect)(() => {
3462
+ (0, import_react3.useEffect)(() => {
2587
3463
  if (hasNotes) centreRequest.current = true;
2588
3464
  setViewportTick((value) => value + 1);
2589
3465
  }, [hasNotes, view]);
2590
- const zoomTo = (0, import_react2.useCallback)((next, anchor) => {
3466
+ const zoomTo = (0, import_react3.useCallback)((next, anchor) => {
2591
3467
  const viewport = viewportRefCurrent.current;
2592
3468
  const current = camera.current;
2593
3469
  const target = clampZoom(next);
@@ -2606,7 +3482,7 @@ window.__ModuleLoader__.load({
2606
3482
  setZoom(target);
2607
3483
  applyCamera();
2608
3484
  }, [applyCamera]);
2609
- const fitWall = (0, import_react2.useCallback)(() => {
3485
+ const fitWall = (0, import_react3.useCallback)(() => {
2610
3486
  const viewport = viewportRefCurrent.current;
2611
3487
  if (viewport === null) return;
2612
3488
  const availableWidth = viewport.clientWidth || 960;
@@ -2649,10 +3525,10 @@ window.__ModuleLoader__.load({
2649
3525
  setZoom(target);
2650
3526
  centreOn(centreX, centreY);
2651
3527
  }, [centreOn]);
2652
- const resetView = (0, import_react2.useCallback)(() => {
3528
+ const resetView = (0, import_react3.useCallback)(() => {
2653
3529
  fitWall();
2654
3530
  }, [fitWall]);
2655
- const centreReserve = (0, import_react2.useCallback)(() => {
3531
+ const centreReserve = (0, import_react3.useCallback)(() => {
2656
3532
  const base = CENTRE_RESERVE;
2657
3533
  const viewport = viewportRefCurrent.current;
2658
3534
  const centre = centreRef.current;
@@ -2670,7 +3546,7 @@ window.__ModuleLoader__.load({
2670
3546
  halfHeight: base.halfHeight
2671
3547
  };
2672
3548
  }, []);
2673
- const revealBox = (0, import_react2.useCallback)((box) => {
3549
+ const revealBox = (0, import_react3.useCallback)((box) => {
2674
3550
  const viewport = viewportRefCurrent.current;
2675
3551
  if (viewport === null) return;
2676
3552
  const width = viewport.clientWidth || 960;
@@ -2736,8 +3612,8 @@ window.__ModuleLoader__.load({
2736
3612
  const y = fieldY + halfH + gap + box.height * targetZoom / 2;
2737
3613
  glideCameraTo(targetZoom, width / 2 - cardX * targetZoom, y - cardY * targetZoom);
2738
3614
  }, [glideCameraTo]);
2739
- const arrival = (0, import_react2.useRef)(null);
2740
- (0, import_react2.useEffect)(() => {
3615
+ const arrival = (0, import_react3.useRef)(null);
3616
+ (0, import_react3.useEffect)(() => {
2741
3617
  const pending = arrival.current;
2742
3618
  if (pending === null) return;
2743
3619
  const note = notes.find((candidate) => candidate.id === pending.id);
@@ -2756,7 +3632,7 @@ window.__ModuleLoader__.load({
2756
3632
  clearTimeout(timer);
2757
3633
  };
2758
3634
  }, [notes]);
2759
- const onWheel = (0, import_react2.useCallback)((event) => {
3635
+ const onWheel = (0, import_react3.useCallback)((event) => {
2760
3636
  const node = viewportRefCurrent.current;
2761
3637
  if (node === null) return;
2762
3638
  if (event.ctrlKey || event.metaKey) {
@@ -2770,7 +3646,7 @@ window.__ModuleLoader__.load({
2770
3646
  camera.current.panY -= event.deltaY * WHEEL_PAN;
2771
3647
  applyCamera();
2772
3648
  }, [applyCamera, zoomTo]);
2773
- const bindViewport = (0, import_react2.useCallback)((node) => {
3649
+ const bindViewport = (0, import_react3.useCallback)((node) => {
2774
3650
  viewportRefCurrent.current = node;
2775
3651
  detachWheel.current?.();
2776
3652
  detachWheel.current = null;
@@ -2778,14 +3654,14 @@ window.__ModuleLoader__.load({
2778
3654
  node.addEventListener("wheel", onWheel, { passive: false });
2779
3655
  detachWheel.current = () => node.removeEventListener("wheel", onWheel);
2780
3656
  }, [onWheel]);
2781
- (0, import_react2.useEffect)(() => {
3657
+ (0, import_react3.useEffect)(() => {
2782
3658
  const node = viewportRefCurrent.current;
2783
3659
  if (node === null) return;
2784
3660
  detachWheel.current?.();
2785
3661
  node.addEventListener("wheel", onWheel, { passive: false });
2786
3662
  detachWheel.current = () => node.removeEventListener("wheel", onWheel);
2787
3663
  }, [onWheel]);
2788
- (0, import_react2.useEffect)(() => {
3664
+ (0, import_react3.useEffect)(() => {
2789
3665
  const node = viewportRefCurrent.current;
2790
3666
  if (node === null || typeof ResizeObserver === "undefined") return;
2791
3667
  const observer = new ResizeObserver(() => {
@@ -2796,7 +3672,7 @@ window.__ModuleLoader__.load({
2796
3672
  observer.observe(node);
2797
3673
  return () => observer.disconnect();
2798
3674
  }, [view]);
2799
- (0, import_react2.useLayoutEffect)(() => {
3675
+ (0, import_react3.useLayoutEffect)(() => {
2800
3676
  if (view !== "canvas") return;
2801
3677
  if (centreRequest.current) {
2802
3678
  centreRequest.current = false;
@@ -2852,7 +3728,7 @@ window.__ModuleLoader__.load({
2852
3728
  lastY: event.clientY
2853
3729
  };
2854
3730
  }
2855
- (0, import_react2.useEffect)(() => {
3731
+ (0, import_react3.useEffect)(() => {
2856
3732
  const paintDrag = (current) => {
2857
3733
  current.frame = 0;
2858
3734
  const node = current.node;
@@ -2953,7 +3829,7 @@ window.__ModuleLoader__.load({
2953
3829
  pan.current?.node?.removeAttribute("data-panning");
2954
3830
  };
2955
3831
  }, [api, applyCamera]);
2956
- const latestActions = (0, import_react2.useRef)(null);
3832
+ const latestActions = (0, import_react3.useRef)(null);
2957
3833
  latestActions.current = {
2958
3834
  edit: openComposer,
2959
3835
  patch: (note, patch) => {
@@ -2970,7 +3846,7 @@ window.__ModuleLoader__.load({
2970
3846
  },
2971
3847
  drag: startDrag
2972
3848
  };
2973
- const actions = (0, import_react2.useMemo)(() => ({
3849
+ const actions = (0, import_react3.useMemo)(() => ({
2974
3850
  edit: (note) => latestActions.current?.edit(note),
2975
3851
  patch: (note, patch) => latestActions.current?.patch(note, patch),
2976
3852
  remove: (note) => latestActions.current?.remove(note),