@zuilib/text-editor 0.7.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,11 +14,11 @@ import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
14
14
  import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
15
15
  import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
16
16
  import { TablePlugin } from "@lexical/react/LexicalTablePlugin";
17
- import { CHECK_LIST, CODE, TRANSFORMERS as TRANSFORMERS2 } from "@lexical/markdown";
17
+ import { CHECK_LIST, CODE as CODE2, TRANSFORMERS as TRANSFORMERS2 } from "@lexical/markdown";
18
18
  import { useLexicalComposerContext as useLexicalComposerContext6 } from "@lexical/react/LexicalComposerContext";
19
19
  import { HeadingNode, QuoteNode } from "@lexical/rich-text";
20
20
  import { ListItemNode, ListNode as ListNode2 } from "@lexical/list";
21
- import { CodeHighlightNode, CodeNode } from "@lexical/code";
21
+ import { CodeHighlightNode, CodeNode as CodeNode2 } from "@lexical/code";
22
22
  import { AutoLinkNode, LinkNode } from "@lexical/link";
23
23
  import { TableCellNode as TableCellNode2, TableNode as TableNode2, TableRowNode as TableRowNode2 } from "@lexical/table";
24
24
 
@@ -160,12 +160,1411 @@ function CodeBlockShortcutPlugin() {
160
160
  // src/plugins/CodeHighlightPlugin.tsx
161
161
  import { useEffect as useEffect3 } from "react";
162
162
  import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
163
- import { registerCodeHighlighting } from "@lexical/code";
163
+
164
+ // src/code/registry.ts
165
+ var PLAIN_LANGUAGE = "plain";
166
+ var PLAIN = {
167
+ name: PLAIN_LANGUAGE,
168
+ aliases: ["plaintext", "text", "txt"],
169
+ rules: []
170
+ };
171
+ var grammars = /* @__PURE__ */ new Map();
172
+ function normalize(name) {
173
+ return name.trim().toLowerCase();
174
+ }
175
+ function registerCodeLanguage(grammar) {
176
+ for (const name of [grammar.name, ...grammar.aliases ?? []]) {
177
+ grammars.set(normalize(name), grammar);
178
+ }
179
+ }
180
+ function hasCodeLanguage(name) {
181
+ return grammars.has(normalize(name));
182
+ }
183
+ function resolveCodeLanguage(name) {
184
+ if (!name) return PLAIN;
185
+ const key = normalize(name);
186
+ return grammars.get(key) ?? (key.startsWith("diff-") ? grammars.get("diff") : void 0) ?? PLAIN;
187
+ }
188
+ function getCodeLanguages() {
189
+ return [...new Set([...grammars.values()].map((g) => g.name))].sort();
190
+ }
191
+ registerCodeLanguage(PLAIN);
192
+
193
+ // src/code/languages/common.ts
194
+ var LINE_COMMENT = String.raw`//[^\n]*`;
195
+ var BLOCK_COMMENT = String.raw`/\*[^]*?(?:\*/|$)`;
196
+ var HASH_COMMENT = String.raw`#[^\n]*`;
197
+ var DOUBLE_QUOTED = String.raw`"(?:[^"\\\n]|\\[^])*"?`;
198
+ var SINGLE_QUOTED = String.raw`'(?:[^'\\\n]|\\[^])*'?`;
199
+ var TRIPLE_DOUBLE_QUOTED = String.raw`"""[^]*?(?:"""|$)`;
200
+ var TRIPLE_SINGLE_QUOTED = String.raw`'''[^]*?(?:'''|$)`;
201
+ var BACKTICK_QUOTED = String.raw`\`(?:[^\`\\]|\\[^])*\`?`;
202
+ var C_NUMBER = String.raw`\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)[a-zA-Z]*\b`;
203
+ var ANNOTATION = String.raw`@[\w.]+`;
204
+ var MEMBER = String.raw`(?<=\.\s*)[A-Za-z_$][\w$]*\b(?!\s*\()`;
205
+ var C_OPERATOR = String.raw`[-+*/%=!<>&|^~?:]+`;
206
+ var PUNCTUATION = String.raw`[{}()\[\];,.]`;
207
+
208
+ // src/code/languages/c.ts
209
+ var PREPROCESSOR = String.raw`(?<=^|\n)[ \t]*#[ \t]*\w+[^\n]*`;
210
+ var c = {
211
+ name: "c",
212
+ aliases: ["h", "cpp", "c++", "cc", "cxx", "hpp", "hh"],
213
+ rules: [
214
+ { type: "comment", match: LINE_COMMENT },
215
+ { type: "comment", match: BLOCK_COMMENT },
216
+ { type: "meta", match: PREPROCESSOR },
217
+ { type: "string", match: DOUBLE_QUOTED },
218
+ { type: "string", match: SINGLE_QUOTED },
219
+ { type: "number", match: C_NUMBER },
220
+ { type: "property", match: MEMBER },
221
+ { type: "operator", match: String.raw`->|::|` + C_OPERATOR },
222
+ { type: "punctuation", match: PUNCTUATION }
223
+ ],
224
+ keywords: [
225
+ "auto",
226
+ "break",
227
+ "case",
228
+ "const",
229
+ "continue",
230
+ "default",
231
+ "do",
232
+ "else",
233
+ "enum",
234
+ "extern",
235
+ "for",
236
+ "goto",
237
+ "if",
238
+ "inline",
239
+ "register",
240
+ "restrict",
241
+ "return",
242
+ "sizeof",
243
+ "static",
244
+ "struct",
245
+ "switch",
246
+ "typedef",
247
+ "union",
248
+ "volatile",
249
+ "while",
250
+ // C++
251
+ "catch",
252
+ "class",
253
+ "const_cast",
254
+ "constexpr",
255
+ "consteval",
256
+ "delete",
257
+ "dynamic_cast",
258
+ "explicit",
259
+ "export",
260
+ "final",
261
+ "friend",
262
+ "mutable",
263
+ "namespace",
264
+ "new",
265
+ "noexcept",
266
+ "operator",
267
+ "override",
268
+ "private",
269
+ "protected",
270
+ "public",
271
+ "reinterpret_cast",
272
+ "static_cast",
273
+ "template",
274
+ "this",
275
+ "throw",
276
+ "try",
277
+ "typename",
278
+ "using",
279
+ "virtual"
280
+ ],
281
+ types: [
282
+ "bool",
283
+ "char",
284
+ "double",
285
+ "float",
286
+ "int",
287
+ "long",
288
+ "short",
289
+ "signed",
290
+ "unsigned",
291
+ "void",
292
+ "wchar_t",
293
+ "size_t",
294
+ "ssize_t",
295
+ "int8_t",
296
+ "int16_t",
297
+ "int32_t",
298
+ "int64_t",
299
+ "uint8_t",
300
+ "uint16_t",
301
+ "uint32_t",
302
+ "uint64_t"
303
+ ],
304
+ constants: ["true", "false", "NULL", "nullptr"],
305
+ callIsFunction: true,
306
+ capitalizedIsType: true
307
+ };
308
+
309
+ // src/code/languages/css.ts
310
+ var css = {
311
+ name: "css",
312
+ aliases: ["scss", "less", "postcss"],
313
+ rules: [
314
+ { type: "comment", match: BLOCK_COMMENT },
315
+ { type: "comment", match: LINE_COMMENT },
316
+ { type: "keyword", match: String.raw`@[\w-]+|!\s*important\b` },
317
+ { type: "variable", match: String.raw`--[\w-]+|\$[\w-]+` },
318
+ { type: "string", match: DOUBLE_QUOTED },
319
+ { type: "string", match: SINGLE_QUOTED },
320
+ { type: "tag", match: String.raw`(?<=(?:^|[{};]|\*/)\s*)[^{};@\s][^{};]*?(?=\s*\{)` },
321
+ { type: "property", match: String.raw`(?<=[{;(]\s*)[-\w]+(?=\s*:)` },
322
+ { type: "constant", match: String.raw`#[\da-fA-F]{3,8}\b` },
323
+ { type: "function", match: String.raw`[-\w]+(?=\()` },
324
+ { type: "number", match: String.raw`(?<![\w-])[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?(?:%|[a-zA-Z]+)?` },
325
+ { type: "punctuation", match: String.raw`[{}()\[\];:,]` },
326
+ { type: "operator", match: String.raw`[>+~*/=]` }
327
+ ]
328
+ };
329
+
330
+ // src/code/languages/diff.ts
331
+ var LINE = String.raw`[^\n]*`;
332
+ var AT = String.raw`(?<=^|\n)`;
333
+ var diff = {
334
+ name: "diff",
335
+ aliases: ["patch"],
336
+ rules: [
337
+ { type: "comment", match: AT + String.raw`(?:diff |index |--- |\+\+\+ |Index: |={3,}|\*{3} )` + LINE },
338
+ { type: "meta", match: AT + String.raw`@@` + LINE },
339
+ { type: "inserted", match: AT + String.raw`\+` + LINE },
340
+ { type: "deleted", match: AT + "-" + LINE }
341
+ ]
342
+ };
343
+
344
+ // src/code/languages/go.ts
345
+ var go = {
346
+ name: "go",
347
+ aliases: ["golang"],
348
+ rules: [
349
+ { type: "comment", match: LINE_COMMENT },
350
+ { type: "comment", match: BLOCK_COMMENT },
351
+ { type: "string", match: String.raw`\`[^\`]*\`?` },
352
+ { type: "string", match: DOUBLE_QUOTED },
353
+ { type: "string", match: SINGLE_QUOTED },
354
+ { type: "number", match: C_NUMBER },
355
+ { type: "property", match: MEMBER },
356
+ { type: "operator", match: String.raw`:=|<-|\.\.\.|` + C_OPERATOR },
357
+ { type: "punctuation", match: PUNCTUATION }
358
+ ],
359
+ keywords: [
360
+ "break",
361
+ "case",
362
+ "chan",
363
+ "const",
364
+ "continue",
365
+ "default",
366
+ "defer",
367
+ "else",
368
+ "fallthrough",
369
+ "for",
370
+ "func",
371
+ "go",
372
+ "goto",
373
+ "if",
374
+ "import",
375
+ "interface",
376
+ "map",
377
+ "package",
378
+ "range",
379
+ "return",
380
+ "select",
381
+ "struct",
382
+ "switch",
383
+ "type",
384
+ "var"
385
+ ],
386
+ types: [
387
+ "any",
388
+ "bool",
389
+ "byte",
390
+ "comparable",
391
+ "complex64",
392
+ "complex128",
393
+ "error",
394
+ "float32",
395
+ "float64",
396
+ "int",
397
+ "int8",
398
+ "int16",
399
+ "int32",
400
+ "int64",
401
+ "rune",
402
+ "string",
403
+ "uint",
404
+ "uint8",
405
+ "uint16",
406
+ "uint32",
407
+ "uint64",
408
+ "uintptr"
409
+ ],
410
+ builtins: [
411
+ "append",
412
+ "cap",
413
+ "clear",
414
+ "close",
415
+ "complex",
416
+ "copy",
417
+ "delete",
418
+ "imag",
419
+ "len",
420
+ "make",
421
+ "max",
422
+ "min",
423
+ "new",
424
+ "panic",
425
+ "print",
426
+ "println",
427
+ "real",
428
+ "recover"
429
+ ],
430
+ constants: ["true", "false", "nil", "iota"],
431
+ callIsFunction: true,
432
+ // Exported names are Capitalized in Go; coloring them all as types is noise
433
+ capitalizedIsType: false
434
+ };
435
+
436
+ // src/code/languages/java.ts
437
+ var java = {
438
+ name: "java",
439
+ rules: [
440
+ { type: "comment", match: LINE_COMMENT },
441
+ { type: "comment", match: BLOCK_COMMENT },
442
+ { type: "string", match: TRIPLE_DOUBLE_QUOTED },
443
+ { type: "string", match: DOUBLE_QUOTED },
444
+ { type: "string", match: SINGLE_QUOTED },
445
+ { type: "meta", match: ANNOTATION },
446
+ { type: "number", match: C_NUMBER },
447
+ { type: "property", match: MEMBER },
448
+ { type: "operator", match: String.raw`->|::|` + C_OPERATOR },
449
+ { type: "punctuation", match: PUNCTUATION }
450
+ ],
451
+ keywords: [
452
+ "abstract",
453
+ "assert",
454
+ "break",
455
+ "case",
456
+ "catch",
457
+ "class",
458
+ "const",
459
+ "continue",
460
+ "default",
461
+ "do",
462
+ "else",
463
+ "enum",
464
+ "extends",
465
+ "final",
466
+ "finally",
467
+ "for",
468
+ "goto",
469
+ "if",
470
+ "implements",
471
+ "import",
472
+ "instanceof",
473
+ "interface",
474
+ "native",
475
+ "new",
476
+ "package",
477
+ "permits",
478
+ "private",
479
+ "protected",
480
+ "public",
481
+ "record",
482
+ "return",
483
+ "sealed",
484
+ "static",
485
+ "strictfp",
486
+ "super",
487
+ "switch",
488
+ "synchronized",
489
+ "this",
490
+ "throw",
491
+ "throws",
492
+ "transient",
493
+ "try",
494
+ "var",
495
+ "volatile",
496
+ "while",
497
+ "yield"
498
+ ],
499
+ types: ["boolean", "byte", "char", "double", "float", "int", "long", "short", "void"],
500
+ constants: ["true", "false", "null"],
501
+ callIsFunction: true,
502
+ capitalizedIsType: true
503
+ };
504
+
505
+ // src/code/languages/javascript.ts
506
+ var REGEX = String.raw`(?<=(?:^|[=(,:;!&|?{}\[+\-*%<>~^]|\breturn|\btypeof|\bcase|\bof|\bin)\s*)/(?![/*])(?:[^/\\\n\[]|\\[^]|\[(?:[^\]\\\n]|\\[^])*\])+/[dgimsuyv]*`;
507
+ var JSX_TAG = String.raw`(?<=<\/?)[A-Za-z][\w.:-]*`;
508
+ var javascript = {
509
+ name: "javascript",
510
+ aliases: ["js", "jsx", "mjs", "cjs", "typescript", "ts", "tsx", "mts", "cts"],
511
+ rules: [
512
+ { type: "comment", match: LINE_COMMENT },
513
+ { type: "comment", match: BLOCK_COMMENT },
514
+ { type: "string", match: BACKTICK_QUOTED },
515
+ { type: "string", match: DOUBLE_QUOTED },
516
+ { type: "string", match: SINGLE_QUOTED },
517
+ { type: "regex", match: REGEX },
518
+ { type: "meta", match: ANNOTATION },
519
+ { type: "number", match: C_NUMBER },
520
+ { type: "property", match: MEMBER },
521
+ { type: "tag", match: JSX_TAG },
522
+ { type: "operator", match: String.raw`=>|\.\.\.|` + C_OPERATOR },
523
+ { type: "punctuation", match: PUNCTUATION }
524
+ ],
525
+ keywords: [
526
+ "as",
527
+ "async",
528
+ "await",
529
+ "break",
530
+ "case",
531
+ "catch",
532
+ "class",
533
+ "const",
534
+ "continue",
535
+ "debugger",
536
+ "default",
537
+ "delete",
538
+ "do",
539
+ "else",
540
+ "enum",
541
+ "export",
542
+ "extends",
543
+ "finally",
544
+ "for",
545
+ "from",
546
+ "function",
547
+ "get",
548
+ "if",
549
+ "implements",
550
+ "import",
551
+ "in",
552
+ "instanceof",
553
+ "interface",
554
+ "let",
555
+ "new",
556
+ "of",
557
+ "package",
558
+ "private",
559
+ "protected",
560
+ "public",
561
+ "return",
562
+ "set",
563
+ "static",
564
+ "super",
565
+ "switch",
566
+ "this",
567
+ "throw",
568
+ "try",
569
+ "typeof",
570
+ "var",
571
+ "void",
572
+ "while",
573
+ "with",
574
+ "yield",
575
+ // TypeScript
576
+ "abstract",
577
+ "asserts",
578
+ "declare",
579
+ "infer",
580
+ "is",
581
+ "keyof",
582
+ "module",
583
+ "namespace",
584
+ "override",
585
+ "readonly",
586
+ "satisfies",
587
+ "type",
588
+ "unique"
589
+ ],
590
+ types: [
591
+ "any",
592
+ "bigint",
593
+ "boolean",
594
+ "never",
595
+ "null",
596
+ "number",
597
+ "object",
598
+ "string",
599
+ "symbol",
600
+ "undefined",
601
+ "unknown",
602
+ "void"
603
+ ],
604
+ builtins: [
605
+ "Array",
606
+ "BigInt",
607
+ "Boolean",
608
+ "Date",
609
+ "Error",
610
+ "JSON",
611
+ "Map",
612
+ "Math",
613
+ "Number",
614
+ "Object",
615
+ "Promise",
616
+ "Proxy",
617
+ "Reflect",
618
+ "RegExp",
619
+ "Set",
620
+ "String",
621
+ "Symbol",
622
+ "WeakMap",
623
+ "WeakSet",
624
+ "console",
625
+ "document",
626
+ "globalThis",
627
+ "window",
628
+ "parseFloat",
629
+ "parseInt",
630
+ "setTimeout",
631
+ "setInterval",
632
+ "clearTimeout",
633
+ "clearInterval",
634
+ "fetch",
635
+ "require",
636
+ "process"
637
+ ],
638
+ constants: ["true", "false", "null", "undefined", "NaN", "Infinity"],
639
+ callIsFunction: true,
640
+ capitalizedIsType: true
641
+ };
642
+
643
+ // src/code/languages/json.ts
644
+ var json = {
645
+ name: "json",
646
+ aliases: ["jsonc", "json5"],
647
+ rules: [
648
+ { type: "comment", match: String.raw`//[^\n]*|/\*[^]*?(?:\*/|$)` },
649
+ { type: "property", match: String.raw`"(?:[^"\\\n]|\\[^])*"(?=\s*:)` },
650
+ { type: "string", match: String.raw`"(?:[^"\\\n]|\\[^])*"?` },
651
+ { type: "number", match: String.raw`-?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b` },
652
+ { type: "punctuation", match: String.raw`[{}\[\]:,]` }
653
+ ],
654
+ constants: ["true", "false", "null"]
655
+ };
656
+
657
+ // src/code/languages/kotlin.ts
658
+ var kotlin = {
659
+ name: "kotlin",
660
+ aliases: ["kt", "kts"],
661
+ rules: [
662
+ { type: "comment", match: LINE_COMMENT },
663
+ { type: "comment", match: BLOCK_COMMENT },
664
+ { type: "string", match: TRIPLE_DOUBLE_QUOTED },
665
+ { type: "string", match: DOUBLE_QUOTED },
666
+ { type: "string", match: SINGLE_QUOTED },
667
+ { type: "meta", match: ANNOTATION },
668
+ { type: "number", match: C_NUMBER },
669
+ { type: "property", match: MEMBER },
670
+ { type: "operator", match: String.raw`->|\.\.|\?:|!!|` + C_OPERATOR },
671
+ { type: "punctuation", match: PUNCTUATION }
672
+ ],
673
+ keywords: [
674
+ "abstract",
675
+ "actual",
676
+ "annotation",
677
+ "as",
678
+ "break",
679
+ "by",
680
+ "catch",
681
+ "class",
682
+ "companion",
683
+ "const",
684
+ "constructor",
685
+ "continue",
686
+ "crossinline",
687
+ "data",
688
+ "do",
689
+ "else",
690
+ "enum",
691
+ "expect",
692
+ "external",
693
+ "final",
694
+ "finally",
695
+ "for",
696
+ "fun",
697
+ "get",
698
+ "if",
699
+ "import",
700
+ "in",
701
+ "infix",
702
+ "init",
703
+ "inline",
704
+ "inner",
705
+ "interface",
706
+ "internal",
707
+ "is",
708
+ "lateinit",
709
+ "noinline",
710
+ "object",
711
+ "open",
712
+ "operator",
713
+ "out",
714
+ "override",
715
+ "package",
716
+ "private",
717
+ "protected",
718
+ "public",
719
+ "reified",
720
+ "return",
721
+ "sealed",
722
+ "set",
723
+ "super",
724
+ "suspend",
725
+ "tailrec",
726
+ "this",
727
+ "throw",
728
+ "try",
729
+ "typealias",
730
+ "val",
731
+ "value",
732
+ "var",
733
+ "vararg",
734
+ "when",
735
+ "where",
736
+ "while"
737
+ ],
738
+ builtins: [
739
+ "it",
740
+ "println",
741
+ "print",
742
+ "listOf",
743
+ "mutableListOf",
744
+ "mapOf",
745
+ "mutableMapOf",
746
+ "setOf",
747
+ "mutableSetOf",
748
+ "arrayOf",
749
+ "emptyList",
750
+ "emptyMap",
751
+ "lazy",
752
+ "require",
753
+ "check",
754
+ "error",
755
+ "TODO",
756
+ "apply",
757
+ "also",
758
+ "let",
759
+ "run",
760
+ "with",
761
+ "takeIf",
762
+ "takeUnless",
763
+ "repeat"
764
+ ],
765
+ constants: ["true", "false", "null"],
766
+ callIsFunction: true,
767
+ capitalizedIsType: true
768
+ };
769
+
770
+ // src/code/languages/markdown.ts
771
+ var AT2 = String.raw`(?<=^|\n)`;
772
+ var markdown = {
773
+ name: "markdown",
774
+ aliases: ["md", "mdx"],
775
+ rules: [
776
+ { type: "comment", match: String.raw`<!--[^]*?(?:-->|$)` },
777
+ { type: "string", match: String.raw`\`\`\`[^]*?(?:\`\`\`|$)|\`[^\`\n]*\`` },
778
+ { type: "keyword", match: AT2 + String.raw`#{1,6}[ \t][^\n]*` },
779
+ { type: "meta", match: AT2 + String.raw`(?:>|[-*+]|\d+\.)(?=\s)` },
780
+ { type: "tag", match: String.raw`\*\*[^*\n]+\*\*|__[^_\n]+__` },
781
+ { type: "variable", match: String.raw`(?<![*\w])\*[^*\n]+\*(?!\w)|(?<![_\w])_[^_\n]+_(?!\w)` },
782
+ { type: "function", match: String.raw`!?\[[^\]\n]*\](?=\()` },
783
+ { type: "string", match: String.raw`(?<=\]\()[^)\n]*(?=\))` },
784
+ { type: "punctuation", match: AT2 + String.raw`(?:---+|\*\*\*+|___+)(?=\n|$)` }
785
+ ]
786
+ };
787
+
788
+ // src/code/languages/markup.ts
789
+ var markup = {
790
+ name: "html",
791
+ aliases: ["xml", "svg", "xhtml", "vue", "markup", "rss", "atom"],
792
+ rules: [
793
+ { type: "comment", match: String.raw`<!--[^]*?(?:-->|$)` },
794
+ { type: "string", match: String.raw`<!\[CDATA\[[^]*?(?:\]\]>|$)` },
795
+ { type: "meta", match: String.raw`<![\w]+[^>]*>?|<\?[^]*?(?:\?>|$)` },
796
+ { type: "tag", match: String.raw`(?<=<\/?)[A-Za-z][\w:.-]*` },
797
+ { type: "string", match: String.raw`(?<=<[^>]*=\s*)(?:"[^"]*"|'[^']*')` },
798
+ { type: "attr", match: String.raw`(?<=<[^>]*\s)[^\s"'<>/=]+` },
799
+ { type: "punctuation", match: String.raw`<\/?|\/?>|(?<=<[^>]*)=` },
800
+ { type: "constant", match: String.raw`&#?\w+;` }
801
+ ]
802
+ };
803
+
804
+ // src/code/languages/python.ts
805
+ var PREFIX = String.raw`(?:\b[rRbBuUfF]{1,2})?`;
806
+ var NUMBER = String.raw`\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?[jJ]?)\b`;
807
+ var python = {
808
+ name: "python",
809
+ aliases: ["py", "py3"],
810
+ rules: [
811
+ { type: "comment", match: HASH_COMMENT },
812
+ { type: "string", match: PREFIX + String.raw`"""[^]*?(?:"""|$)` },
813
+ { type: "string", match: PREFIX + String.raw`'''[^]*?(?:'''|$)` },
814
+ { type: "string", match: PREFIX + String.raw`"(?:[^"\\\n]|\\[^])*"?` },
815
+ { type: "string", match: PREFIX + String.raw`'(?:[^'\\\n]|\\[^])*'?` },
816
+ { type: "meta", match: String.raw`@[\w.]+` },
817
+ { type: "number", match: NUMBER },
818
+ { type: "property", match: MEMBER },
819
+ { type: "operator", match: String.raw`->|:=|\*\*|//|[-+*/%=!<>&|^~@]+` },
820
+ { type: "punctuation", match: PUNCTUATION + "|:" }
821
+ ],
822
+ keywords: [
823
+ "and",
824
+ "as",
825
+ "assert",
826
+ "async",
827
+ "await",
828
+ "break",
829
+ "case",
830
+ "class",
831
+ "continue",
832
+ "def",
833
+ "del",
834
+ "elif",
835
+ "else",
836
+ "except",
837
+ "finally",
838
+ "for",
839
+ "from",
840
+ "global",
841
+ "if",
842
+ "import",
843
+ "in",
844
+ "is",
845
+ "lambda",
846
+ "match",
847
+ "nonlocal",
848
+ "not",
849
+ "or",
850
+ "pass",
851
+ "raise",
852
+ "return",
853
+ "try",
854
+ "while",
855
+ "with",
856
+ "yield"
857
+ ],
858
+ builtins: [
859
+ "self",
860
+ "cls",
861
+ "print",
862
+ "len",
863
+ "range",
864
+ "enumerate",
865
+ "zip",
866
+ "map",
867
+ "filter",
868
+ "sorted",
869
+ "reversed",
870
+ "open",
871
+ "input",
872
+ "abs",
873
+ "min",
874
+ "max",
875
+ "sum",
876
+ "any",
877
+ "all",
878
+ "iter",
879
+ "next",
880
+ "isinstance",
881
+ "issubclass",
882
+ "getattr",
883
+ "setattr",
884
+ "hasattr",
885
+ "super",
886
+ "type",
887
+ "id",
888
+ "hash",
889
+ "repr",
890
+ "format",
891
+ "vars",
892
+ "dir"
893
+ ],
894
+ types: ["int", "float", "str", "bytes", "bool", "list", "dict", "set", "tuple", "object", "complex", "frozenset"],
895
+ constants: ["True", "False", "None", "Ellipsis", "NotImplemented"],
896
+ callIsFunction: true,
897
+ capitalizedIsType: true
898
+ };
899
+
900
+ // src/code/languages/rust.ts
901
+ var NUMBER2 = String.raw`\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)(?:[iuf](?:8|16|32|64|128|size))?\b`;
902
+ var rust = {
903
+ name: "rust",
904
+ aliases: ["rs"],
905
+ rules: [
906
+ { type: "comment", match: LINE_COMMENT },
907
+ { type: "comment", match: BLOCK_COMMENT },
908
+ { type: "meta", match: String.raw`#!?\[[^\]\n]*\]` },
909
+ { type: "string", match: String.raw`b?r#*"[^]*?(?:"#*|$)` },
910
+ { type: "string", match: String.raw`b?"(?:[^"\\]|\\[^])*"?` },
911
+ { type: "string", match: String.raw`b?'(?:[^'\\\n]|\\[^])'` },
912
+ { type: "variable", match: String.raw`'[a-z_]\w*\b(?!')` },
913
+ { type: "function", match: String.raw`\b[a-z_]\w*!(?=[\s(\[{])` },
914
+ { type: "number", match: NUMBER2 },
915
+ { type: "property", match: MEMBER },
916
+ { type: "operator", match: String.raw`->|=>|::|\.\.=?|` + C_OPERATOR },
917
+ { type: "punctuation", match: PUNCTUATION + "|#" }
918
+ ],
919
+ keywords: [
920
+ "as",
921
+ "async",
922
+ "await",
923
+ "break",
924
+ "const",
925
+ "continue",
926
+ "crate",
927
+ "dyn",
928
+ "else",
929
+ "enum",
930
+ "extern",
931
+ "fn",
932
+ "for",
933
+ "if",
934
+ "impl",
935
+ "in",
936
+ "let",
937
+ "loop",
938
+ "match",
939
+ "mod",
940
+ "move",
941
+ "mut",
942
+ "pub",
943
+ "ref",
944
+ "return",
945
+ "self",
946
+ "Self",
947
+ "static",
948
+ "struct",
949
+ "super",
950
+ "trait",
951
+ "type",
952
+ "union",
953
+ "unsafe",
954
+ "use",
955
+ "where",
956
+ "while"
957
+ ],
958
+ types: [
959
+ "bool",
960
+ "char",
961
+ "f32",
962
+ "f64",
963
+ "i8",
964
+ "i16",
965
+ "i32",
966
+ "i64",
967
+ "i128",
968
+ "isize",
969
+ "str",
970
+ "u8",
971
+ "u16",
972
+ "u32",
973
+ "u64",
974
+ "u128",
975
+ "usize",
976
+ "String",
977
+ "Vec",
978
+ "Option",
979
+ "Result",
980
+ "Box",
981
+ "Rc",
982
+ "Arc",
983
+ "HashMap",
984
+ "HashSet"
985
+ ],
986
+ constants: ["true", "false", "None", "Some", "Ok", "Err"],
987
+ callIsFunction: true,
988
+ capitalizedIsType: true
989
+ };
990
+
991
+ // src/code/languages/shell.ts
992
+ var shell = {
993
+ name: "shell",
994
+ aliases: ["sh", "bash", "zsh", "console", "shellsession"],
995
+ rules: [
996
+ { type: "variable", match: String.raw`\$\{[^}\n]*\}|\$\w+|\$[@#?*!$-]` },
997
+ { type: "comment", match: String.raw`(?<=^|\s)#[^\n]*` },
998
+ { type: "string", match: String.raw`"(?:[^"\\\n]|\\[^])*"?` },
999
+ { type: "string", match: String.raw`'[^'\n]*'?` },
1000
+ { type: "punctuation", match: String.raw`(?<=^|\n)[$#](?=\s)` },
1001
+ { type: "attr", match: String.raw`(?<=\s)--?[A-Za-z][\w-]*` },
1002
+ { type: "operator", match: String.raw`\|\|?|&&?|;;?|[<>]+|=` },
1003
+ { type: "punctuation", match: String.raw`[(){}\[\]]` }
1004
+ ],
1005
+ identifier: String.raw`[A-Za-z_][\w.-]*`,
1006
+ keywords: [
1007
+ "if",
1008
+ "then",
1009
+ "else",
1010
+ "elif",
1011
+ "fi",
1012
+ "for",
1013
+ "while",
1014
+ "until",
1015
+ "do",
1016
+ "done",
1017
+ "case",
1018
+ "esac",
1019
+ "in",
1020
+ "function",
1021
+ "select",
1022
+ "time",
1023
+ "return",
1024
+ "exit",
1025
+ "local",
1026
+ "export",
1027
+ "readonly",
1028
+ "declare",
1029
+ "set",
1030
+ "unset",
1031
+ "shift",
1032
+ "source",
1033
+ "alias",
1034
+ "break",
1035
+ "continue"
1036
+ ],
1037
+ builtins: [
1038
+ "echo",
1039
+ "cd",
1040
+ "ls",
1041
+ "pwd",
1042
+ "cat",
1043
+ "grep",
1044
+ "sed",
1045
+ "awk",
1046
+ "mkdir",
1047
+ "rm",
1048
+ "cp",
1049
+ "mv",
1050
+ "chmod",
1051
+ "chown",
1052
+ "curl",
1053
+ "wget",
1054
+ "git",
1055
+ "npm",
1056
+ "pnpm",
1057
+ "yarn",
1058
+ "npx",
1059
+ "node",
1060
+ "python",
1061
+ "python3",
1062
+ "pip",
1063
+ "docker",
1064
+ "kubectl",
1065
+ "sudo",
1066
+ "test",
1067
+ "printf",
1068
+ "read",
1069
+ "eval",
1070
+ "exec",
1071
+ "trap",
1072
+ "wait",
1073
+ "kill",
1074
+ "ps",
1075
+ "tar",
1076
+ "zip",
1077
+ "unzip",
1078
+ "touch",
1079
+ "find",
1080
+ "xargs",
1081
+ "sort",
1082
+ "uniq",
1083
+ "head",
1084
+ "tail",
1085
+ "wc",
1086
+ "tee",
1087
+ "which",
1088
+ "env",
1089
+ "ssh",
1090
+ "scp",
1091
+ "make",
1092
+ "cargo",
1093
+ "go",
1094
+ "brew",
1095
+ "apt",
1096
+ "apt-get",
1097
+ "gradle",
1098
+ "mvn",
1099
+ "java",
1100
+ "jq",
1101
+ "true",
1102
+ "false"
1103
+ ]
1104
+ };
1105
+
1106
+ // src/code/languages/sql.ts
1107
+ var sql = {
1108
+ name: "sql",
1109
+ aliases: ["mysql", "postgres", "postgresql", "pgsql", "plsql", "sqlite", "soql"],
1110
+ caseInsensitive: true,
1111
+ rules: [
1112
+ { type: "comment", match: String.raw`--[^\n]*` },
1113
+ { type: "comment", match: BLOCK_COMMENT },
1114
+ { type: "string", match: String.raw`'(?:[^'\n]|'')*'?` },
1115
+ { type: "variable", match: String.raw`[@:]\w+|\$\d+` },
1116
+ { type: "number", match: String.raw`\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b` },
1117
+ { type: "operator", match: String.raw`\|\||::|[-+*/%=<>!]+` },
1118
+ { type: "punctuation", match: String.raw`[(),;.]` }
1119
+ ],
1120
+ keywords: [
1121
+ "add",
1122
+ "all",
1123
+ "alter",
1124
+ "and",
1125
+ "as",
1126
+ "asc",
1127
+ "begin",
1128
+ "between",
1129
+ "by",
1130
+ "cascade",
1131
+ "case",
1132
+ "check",
1133
+ "column",
1134
+ "commit",
1135
+ "constraint",
1136
+ "create",
1137
+ "cross",
1138
+ "default",
1139
+ "delete",
1140
+ "desc",
1141
+ "distinct",
1142
+ "drop",
1143
+ "else",
1144
+ "end",
1145
+ "except",
1146
+ "exists",
1147
+ "foreign",
1148
+ "from",
1149
+ "full",
1150
+ "group",
1151
+ "having",
1152
+ "if",
1153
+ "in",
1154
+ "index",
1155
+ "inner",
1156
+ "insert",
1157
+ "intersect",
1158
+ "into",
1159
+ "is",
1160
+ "join",
1161
+ "key",
1162
+ "left",
1163
+ "like",
1164
+ "limit",
1165
+ "not",
1166
+ "null",
1167
+ "offset",
1168
+ "on",
1169
+ "or",
1170
+ "order",
1171
+ "outer",
1172
+ "primary",
1173
+ "references",
1174
+ "returning",
1175
+ "right",
1176
+ "rollback",
1177
+ "select",
1178
+ "set",
1179
+ "table",
1180
+ "then",
1181
+ "top",
1182
+ "transaction",
1183
+ "truncate",
1184
+ "union",
1185
+ "unique",
1186
+ "update",
1187
+ "using",
1188
+ "values",
1189
+ "view",
1190
+ "when",
1191
+ "where",
1192
+ "with",
1193
+ "recursive",
1194
+ "ilike",
1195
+ "over",
1196
+ "partition",
1197
+ "window",
1198
+ "rows",
1199
+ "range",
1200
+ "fetch",
1201
+ "first",
1202
+ "next",
1203
+ "only",
1204
+ "nulls",
1205
+ "last",
1206
+ "explain",
1207
+ "analyze",
1208
+ "grant",
1209
+ "revoke",
1210
+ "schema",
1211
+ "database",
1212
+ "trigger",
1213
+ "procedure",
1214
+ "function",
1215
+ "returns",
1216
+ "declare",
1217
+ "cursor",
1218
+ "loop",
1219
+ "while",
1220
+ "for",
1221
+ "exec",
1222
+ "execute",
1223
+ "merge",
1224
+ "matched",
1225
+ "replace",
1226
+ "ignore",
1227
+ "conflict",
1228
+ "do",
1229
+ "nothing",
1230
+ "nowait",
1231
+ "lock",
1232
+ "share",
1233
+ "lateral",
1234
+ "natural",
1235
+ "any",
1236
+ "some",
1237
+ "escape"
1238
+ ],
1239
+ types: [
1240
+ "int",
1241
+ "integer",
1242
+ "bigint",
1243
+ "smallint",
1244
+ "tinyint",
1245
+ "varchar",
1246
+ "char",
1247
+ "text",
1248
+ "boolean",
1249
+ "bool",
1250
+ "date",
1251
+ "timestamp",
1252
+ "timestamptz",
1253
+ "time",
1254
+ "interval",
1255
+ "decimal",
1256
+ "numeric",
1257
+ "float",
1258
+ "real",
1259
+ "double",
1260
+ "serial",
1261
+ "bigserial",
1262
+ "uuid",
1263
+ "json",
1264
+ "jsonb",
1265
+ "bytea",
1266
+ "blob",
1267
+ "array",
1268
+ "money",
1269
+ "precision",
1270
+ "varying"
1271
+ ],
1272
+ builtins: [
1273
+ "count",
1274
+ "sum",
1275
+ "avg",
1276
+ "min",
1277
+ "max",
1278
+ "coalesce",
1279
+ "now",
1280
+ "cast",
1281
+ "concat",
1282
+ "lower",
1283
+ "upper",
1284
+ "length",
1285
+ "substring",
1286
+ "round",
1287
+ "trim",
1288
+ "nullif",
1289
+ "greatest",
1290
+ "least",
1291
+ "array_agg",
1292
+ "string_agg",
1293
+ "json_agg",
1294
+ "row_number",
1295
+ "rank",
1296
+ "dense_rank",
1297
+ "date_trunc",
1298
+ "extract",
1299
+ "current_date",
1300
+ "current_timestamp",
1301
+ "current_user",
1302
+ "exists",
1303
+ "abs",
1304
+ "ceil",
1305
+ "floor",
1306
+ "random",
1307
+ "generate_series"
1308
+ ],
1309
+ constants: ["true", "false", "null", "unknown"],
1310
+ callIsFunction: true
1311
+ };
1312
+
1313
+ // src/code/languages/yaml.ts
1314
+ var LINE_START = String.raw`(?<=^|\n)`;
1315
+ var KEY = String.raw`(?<=^|\n|\s|-\s)(?:"(?:[^"\\\n]|\\[^])*"|'(?:[^'\n]|'')*'|[^\s"'#\-\[\]{},:!&*?|>][^:#\n]*?)(?=:(?:\s|$))`;
1316
+ var yaml = {
1317
+ name: "yaml",
1318
+ aliases: ["yml"],
1319
+ rules: [
1320
+ { type: "comment", match: String.raw`(?<=^|\s)#[^\n]*` },
1321
+ { type: "meta", match: LINE_START + String.raw`(?:---|\.\.\.)(?=\s|$)` },
1322
+ { type: "property", match: KEY },
1323
+ { type: "variable", match: String.raw`[&*][\w-]+` },
1324
+ { type: "meta", match: String.raw`![\w!/:-]*` },
1325
+ { type: "string", match: String.raw`"(?:[^"\\\n]|\\[^])*"?` },
1326
+ { type: "string", match: String.raw`'(?:[^'\n]|'')*'?` },
1327
+ { type: "punctuation", match: String.raw`(?<=:\s*)[|>][-+]?\d*(?=[ \t]*(?:\n|$|#))` },
1328
+ { type: "punctuation", match: String.raw`(?<=^|\n|\s)-(?=\s)|[\[\]{},:]` },
1329
+ { type: "constant", match: String.raw`(?<=:\s)~(?=\s|$)` },
1330
+ {
1331
+ type: "number",
1332
+ match: String.raw`(?<![\w.-])[-+]?(?:0x[\da-fA-F]+|\d[\d_]*(?:\.\d*)?(?:[eE][+-]?\d+)?|\.inf|\.nan)(?![\w.-])`
1333
+ }
1334
+ ],
1335
+ constants: [
1336
+ "true",
1337
+ "false",
1338
+ "null",
1339
+ "yes",
1340
+ "no",
1341
+ "on",
1342
+ "off",
1343
+ "True",
1344
+ "False",
1345
+ "Null",
1346
+ "Yes",
1347
+ "No",
1348
+ "On",
1349
+ "Off",
1350
+ "TRUE",
1351
+ "FALSE",
1352
+ "NULL",
1353
+ "YES",
1354
+ "NO",
1355
+ "ON",
1356
+ "OFF"
1357
+ ]
1358
+ };
1359
+
1360
+ // src/code/languages/index.ts
1361
+ var BUILTIN_CODE_LANGUAGES = [
1362
+ javascript,
1363
+ kotlin,
1364
+ java,
1365
+ c,
1366
+ python,
1367
+ go,
1368
+ rust,
1369
+ json,
1370
+ yaml,
1371
+ shell,
1372
+ sql,
1373
+ css,
1374
+ markup,
1375
+ diff,
1376
+ markdown
1377
+ ];
1378
+ for (const grammar of BUILTIN_CODE_LANGUAGES) registerCodeLanguage(grammar);
1379
+
1380
+ // src/code/lexer.ts
1381
+ var DEFAULT_IDENTIFIER = String.raw`[A-Za-z_$][\w$]*`;
1382
+ var WHITESPACE = String.raw`\s+`;
1383
+ var SCREAMING_CASE = /^[A-Z][A-Z\d_]+$/;
1384
+ var CAPITALIZED = /^[A-Z]/;
1385
+ var compiled = /* @__PURE__ */ new WeakMap();
1386
+ function countGroups(source) {
1387
+ return new RegExp(`${source}|`).exec("").length - 1;
1388
+ }
1389
+ function compile(grammar) {
1390
+ const cached = compiled.get(grammar);
1391
+ if (cached) return cached;
1392
+ const rules = [...grammar.rules, "whitespace", "identifier"];
1393
+ const sources = rules.map((rule) => {
1394
+ if (rule === "whitespace") return WHITESPACE;
1395
+ if (rule === "identifier") return grammar.identifier ?? DEFAULT_IDENTIFIER;
1396
+ return rule.match;
1397
+ });
1398
+ const groupStarts = [];
1399
+ let group = 1;
1400
+ for (const source of sources) {
1401
+ groupStarts.push(group);
1402
+ group += 1 + countGroups(source);
1403
+ }
1404
+ const regex = new RegExp(
1405
+ sources.map((source) => `(${source})`).join("|"),
1406
+ grammar.caseInsensitive ? "yi" : "y"
1407
+ );
1408
+ const words = /* @__PURE__ */ new Map();
1409
+ const addWords = (list, type) => {
1410
+ for (const word of list ?? []) {
1411
+ words.set(grammar.caseInsensitive ? word.toLowerCase() : word, type);
1412
+ }
1413
+ };
1414
+ addWords(grammar.builtins, "builtin");
1415
+ addWords(grammar.types, "type");
1416
+ addWords(grammar.constants, "constant");
1417
+ addWords(grammar.keywords, "keyword");
1418
+ const result = { regex, groupStarts, rules, words };
1419
+ compiled.set(grammar, result);
1420
+ return result;
1421
+ }
1422
+ function isCallee(code, end) {
1423
+ let i = end;
1424
+ while (code[i] === " " || code[i] === " ") i++;
1425
+ return code[i] === "(";
1426
+ }
1427
+ function classifyIdentifier(word, grammar, words, code, end) {
1428
+ const known = words.get(grammar.caseInsensitive ? word.toLowerCase() : word);
1429
+ if (known) return known;
1430
+ if (grammar.capitalizedIsType) {
1431
+ if (SCREAMING_CASE.test(word)) return "constant";
1432
+ if (CAPITALIZED.test(word)) return "type";
1433
+ }
1434
+ if (grammar.callIsFunction && isCallee(code, end)) return "function";
1435
+ return "text";
1436
+ }
1437
+ function matchedRule(match, compiled2) {
1438
+ const { groupStarts, rules } = compiled2;
1439
+ for (let i = 0; i < groupStarts.length; i++) {
1440
+ if (match[groupStarts[i]] !== void 0) return rules[i];
1441
+ }
1442
+ throw new Error("zui code lexer: no alternative matched");
1443
+ }
1444
+ function tokenizeCode(code, grammar) {
1445
+ const c2 = compile(grammar);
1446
+ const tokens = [];
1447
+ const push = (type, text) => {
1448
+ const last = tokens[tokens.length - 1];
1449
+ if (last && last.type === type) {
1450
+ tokens[tokens.length - 1] = { type, text: last.text + text };
1451
+ } else {
1452
+ tokens.push({ type, text });
1453
+ }
1454
+ };
1455
+ let pos = 0;
1456
+ let textStart = 0;
1457
+ const flushText = (end) => {
1458
+ if (end > textStart) push("text", code.slice(textStart, end));
1459
+ };
1460
+ while (pos < code.length) {
1461
+ c2.regex.lastIndex = pos;
1462
+ const match = c2.regex.exec(code);
1463
+ if (match === null || match[0].length === 0) {
1464
+ pos += 1;
1465
+ continue;
1466
+ }
1467
+ const text = match[0];
1468
+ const end = pos + text.length;
1469
+ const rule = matchedRule(match, c2);
1470
+ let type;
1471
+ if (rule === "whitespace") type = "text";
1472
+ else if (rule === "identifier") type = classifyIdentifier(text, grammar, c2.words, code, end);
1473
+ else type = rule.type;
1474
+ if (type !== "text") {
1475
+ flushText(pos);
1476
+ push(type, text);
1477
+ textStart = end;
1478
+ }
1479
+ pos = end;
1480
+ }
1481
+ flushText(code.length);
1482
+ return tokens;
1483
+ }
1484
+
1485
+ // src/code/lexicalTokenizer.ts
1486
+ import {
1487
+ $createLineBreakNode,
1488
+ $createTabNode,
1489
+ $nodesOfType
1490
+ } from "lexical";
1491
+ import { $createCodeHighlightNode, CodeNode, registerCodeHighlighting } from "@lexical/code";
1492
+ import { mergeRegister } from "@lexical/utils";
1493
+ var MAX_HIGHLIGHT_LENGTH = 2e5;
1494
+ function grammarFor(code, language) {
1495
+ return code.length > MAX_HIGHLIGHT_LENGTH ? PLAIN : resolveCodeLanguage(language);
1496
+ }
1497
+ var codeTokenizer = {
1498
+ defaultLanguage: PLAIN_LANGUAGE,
1499
+ tokenize(code, language) {
1500
+ return tokenizeCode(code, grammarFor(code, language)).map(
1501
+ (token) => token.type === "text" ? token.text : { type: token.type, alias: "", content: token.text }
1502
+ );
1503
+ },
1504
+ $tokenize(codeNode, language) {
1505
+ const code = codeNode.getTextContent();
1506
+ const nodes = [];
1507
+ for (const { type, text } of tokenizeCode(code, grammarFor(code, language))) {
1508
+ const highlightType = type === "text" ? void 0 : type;
1509
+ for (const part of text.split(/(\n|\t)/)) {
1510
+ if (part === "\n") nodes.push($createLineBreakNode());
1511
+ else if (part === " ") nodes.push($createTabNode());
1512
+ else if (part.length > 0) nodes.push($createCodeHighlightNode(part, highlightType));
1513
+ }
1514
+ }
1515
+ return nodes;
1516
+ }
1517
+ };
1518
+ function openLanguageGate(language) {
1519
+ const prism = globalThis.Prism;
1520
+ const table = prism?.languages;
1521
+ if (!table || Object.prototype.hasOwnProperty.call(table, language)) return false;
1522
+ table[language] = {};
1523
+ return true;
1524
+ }
1525
+ function registerCodeBlockHighlighting(editor) {
1526
+ const unregister = mergeRegister(
1527
+ editor.registerNodeTransform(CodeNode, (node) => {
1528
+ const language = node.getLanguage();
1529
+ if (language && openLanguageGate(language)) node.markDirty();
1530
+ }),
1531
+ registerCodeHighlighting(editor, codeTokenizer)
1532
+ );
1533
+ editor.update(
1534
+ () => {
1535
+ for (const node of $nodesOfType(CodeNode)) node.markDirty();
1536
+ },
1537
+ { tag: "history-merge" }
1538
+ );
1539
+ return unregister;
1540
+ }
1541
+
1542
+ // src/code/types.ts
1543
+ var CODE_TOKEN_TYPES = [
1544
+ "comment",
1545
+ "string",
1546
+ "number",
1547
+ "keyword",
1548
+ "builtin",
1549
+ "type",
1550
+ "function",
1551
+ "property",
1552
+ "variable",
1553
+ "constant",
1554
+ "operator",
1555
+ "punctuation",
1556
+ "tag",
1557
+ "attr",
1558
+ "regex",
1559
+ "meta",
1560
+ "inserted",
1561
+ "deleted"
1562
+ ];
1563
+
1564
+ // src/plugins/CodeHighlightPlugin.tsx
164
1565
  function CodeHighlightPlugin() {
165
1566
  const [editor] = useLexicalComposerContext3();
166
- useEffect3(() => {
167
- return registerCodeHighlighting(editor);
168
- }, [editor]);
1567
+ useEffect3(() => registerCodeBlockHighlighting(editor), [editor]);
169
1568
  return null;
170
1569
  }
171
1570
 
@@ -199,8 +1598,8 @@ function MarkdownSyncPlugin({
199
1598
  if (dirtyElements.size === 0 && dirtyLeaves.size === 0) return;
200
1599
  if (tags.has("initial-load")) return;
201
1600
  editorState.read(() => {
202
- const markdown = $convertToMarkdownString(transformers);
203
- onChangeRef.current?.(markdown);
1601
+ const markdown2 = $convertToMarkdownString(transformers);
1602
+ onChangeRef.current?.(markdown2);
204
1603
  });
205
1604
  }
206
1605
  );
@@ -211,7 +1610,7 @@ function MarkdownSyncPlugin({
211
1610
  // src/nodes/FrontmatterNode.ts
212
1611
  import {
213
1612
  $applyNodeReplacement,
214
- $createLineBreakNode,
1613
+ $createLineBreakNode as $createLineBreakNode2,
215
1614
  $createTextNode,
216
1615
  ElementNode
217
1616
  } from "lexical";
@@ -280,7 +1679,7 @@ ${body}
280
1679
  while (lines.length > 0 && lines[lines.length - 1].length === 0) lines.pop();
281
1680
  const node = $createFrontmatterNode();
282
1681
  lines.forEach((line, index) => {
283
- if (index > 0) node.append($createLineBreakNode());
1682
+ if (index > 0) node.append($createLineBreakNode2());
284
1683
  node.append($createTextNode(line));
285
1684
  });
286
1685
  rootNode.append(node);
@@ -300,12 +1699,26 @@ import {
300
1699
  useEffect as useEffect7,
301
1700
  useMemo,
302
1701
  useRef as useRef4,
303
- useState as useState3
1702
+ useState as useState3,
1703
+ useContext as useContext2
304
1704
  } from "react";
305
1705
  import { $getNodeByKey as $getNodeByKey2 } from "lexical";
306
1706
  import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
307
1707
  import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
308
1708
 
1709
+ // src/editorContext.ts
1710
+ import { createContext, useContext } from "react";
1711
+ var EditorContext = createContext(null);
1712
+ function useEditorContext() {
1713
+ const ctx = useContext(EditorContext);
1714
+ if (!ctx) {
1715
+ throw new Error(
1716
+ "@zuilib/text-editor: this component must be rendered inside <MarkdownEditor> or <MarkdownEditor.Root>"
1717
+ );
1718
+ }
1719
+ return ctx;
1720
+ }
1721
+
309
1722
  // src/drawing/focusCommand.ts
310
1723
  import { createCommand } from "lexical";
311
1724
  var DRAWING_FOCUS_COMMAND = createCommand(
@@ -381,9 +1794,9 @@ var SIDE_FIXED_POINTS = {
381
1794
  function serializeDrawingData(data) {
382
1795
  return JSON.stringify(data);
383
1796
  }
384
- function parseDrawingData(json) {
1797
+ function parseDrawingData(json2) {
385
1798
  try {
386
- return normalizeDrawingData(JSON.parse(json));
1799
+ return normalizeDrawingData(JSON.parse(json2));
387
1800
  } catch {
388
1801
  return EMPTY_DRAWING;
389
1802
  }
@@ -531,7 +1944,7 @@ function bbox(shape) {
531
1944
  h: Math.abs(shape.h)
532
1945
  };
533
1946
  }
534
- function normalize(shape) {
1947
+ function normalize2(shape) {
535
1948
  if (isConnectorType(shape.type)) return shape;
536
1949
  if (shape.w >= 0 && shape.h >= 0) return shape;
537
1950
  const b = bbox(shape);
@@ -573,10 +1986,10 @@ function manhattan(a, b) {
573
1986
  return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
574
1987
  }
575
1988
  function ellipsePolygon(r, segments = 40) {
576
- const c = rectCenter(r);
1989
+ const c2 = rectCenter(r);
577
1990
  return Array.from({ length: segments }, (_, i) => {
578
1991
  const a = i * 2 * Math.PI / segments;
579
- return { x: c.x + r.w / 2 * Math.cos(a), y: c.y + r.h / 2 * Math.sin(a) };
1992
+ return { x: c2.x + r.w / 2 * Math.cos(a), y: c2.y + r.h / 2 * Math.sin(a) };
580
1993
  });
581
1994
  }
582
1995
  function rectPolygon(r) {
@@ -739,23 +2152,23 @@ var BOX_DEFINITIONS = {
739
2152
  defaultFill: "#ffec99",
740
2153
  outline: (s) => {
741
2154
  const b = bbox(s);
742
- const f = NOTE_FOLD(b);
2155
+ const f3 = NOTE_FOLD(b);
743
2156
  return [
744
2157
  { x: b.x, y: b.y },
745
2158
  { x: b.x + b.w, y: b.y },
746
- { x: b.x + b.w, y: b.y + b.h - f },
747
- { x: b.x + b.w - f, y: b.y + b.h },
2159
+ { x: b.x + b.w, y: b.y + b.h - f3 },
2160
+ { x: b.x + b.w - f3, y: b.y + b.h },
748
2161
  { x: b.x, y: b.y + b.h }
749
2162
  ];
750
2163
  },
751
2164
  textArea: (s) => {
752
2165
  const b = bbox(s);
753
- const f = NOTE_FOLD(b);
2166
+ const f3 = NOTE_FOLD(b);
754
2167
  return {
755
2168
  x: b.x + BOX_TEXT_PADDING,
756
2169
  y: b.y + BOX_TEXT_PADDING,
757
2170
  w: Math.max(b.w - BOX_TEXT_PADDING * 2, 20),
758
- h: Math.max(b.h - BOX_TEXT_PADDING * 2 - f / 2, 10)
2171
+ h: Math.max(b.h - BOX_TEXT_PADDING * 2 - f3 / 2, 10)
759
2172
  };
760
2173
  }
761
2174
  },
@@ -898,7 +2311,7 @@ function fixedPointFor(box, point) {
898
2311
  [fy * b.h, "fy", 0],
899
2312
  [(1 - fy) * b.h, "fy", 1]
900
2313
  ];
901
- edges.sort((a, c) => a[0] - c[0]);
2314
+ edges.sort((a, c2) => a[0] - c2[0]);
902
2315
  const [, axis, value] = edges[0];
903
2316
  const snapped = axis === "fx" ? [value, fy] : [fx, value];
904
2317
  return [round3(snapped[0]), round3(snapped[1])];
@@ -920,9 +2333,9 @@ function bindingHeading(box, binding, toward) {
920
2333
  const fixed = edgeHeading(binding);
921
2334
  if (fixed) return fixed;
922
2335
  const b = bbox(box);
923
- const c = center(box);
924
- const dx = (toward.x - c.x) / Math.max(b.w, 1);
925
- const dy = (toward.y - c.y) / Math.max(b.h, 1);
2336
+ const c2 = center(box);
2337
+ const dx = (toward.x - c2.x) / Math.max(b.w, 1);
2338
+ const dy = (toward.y - c2.y) / Math.max(b.h, 1);
926
2339
  if (Math.abs(dx) >= Math.abs(dy)) return dx >= 0 ? "right" : "left";
927
2340
  return dy >= 0 ? "down" : "up";
928
2341
  }
@@ -1192,17 +2605,17 @@ function simplify(points) {
1192
2605
  return out;
1193
2606
  }
1194
2607
  function applyElbowOverride(points, t, obstacles) {
1195
- const [a, b, c, d] = points;
1196
- const horizontalMiddle = Math.abs(b.y - c.y) < 0.01 && Math.abs(b.x - c.x) > 0.01;
1197
- const verticalMiddle = Math.abs(b.x - c.x) < 0.01 && Math.abs(b.y - c.y) > 0.01;
2608
+ const [a, b, c2, d] = points;
2609
+ const horizontalMiddle = Math.abs(b.y - c2.y) < 0.01 && Math.abs(b.x - c2.x) > 0.01;
2610
+ const verticalMiddle = Math.abs(b.x - c2.x) < 0.01 && Math.abs(b.y - c2.y) > 0.01;
1198
2611
  const clamped = Math.min(0.95, Math.max(0.05, t));
1199
2612
  let next;
1200
2613
  if (verticalMiddle) {
1201
2614
  const x = a.x + (d.x - a.x) * clamped;
1202
- next = [a, { x, y: b.y }, { x, y: c.y }, d];
2615
+ next = [a, { x, y: b.y }, { x, y: c2.y }, d];
1203
2616
  } else if (horizontalMiddle) {
1204
2617
  const y = a.y + (d.y - a.y) * clamped;
1205
- next = [a, { x: b.x, y }, { x: c.x, y }, d];
2618
+ next = [a, { x: b.x, y }, { x: c2.x, y }, d];
1206
2619
  } else {
1207
2620
  return points;
1208
2621
  }
@@ -1257,13 +2670,17 @@ function segmentAngleAt(points, index, backward) {
1257
2670
  }
1258
2671
  return 0;
1259
2672
  }
1260
- function arrowHeadPath(tip, angle, length) {
2673
+ function arrowHeadPoints(tip, angle, length) {
1261
2674
  const spread = Math.PI / 7;
1262
- const hx1 = tip.x - length * Math.cos(angle - spread);
1263
- const hy1 = tip.y - length * Math.sin(angle - spread);
1264
- const hx2 = tip.x - length * Math.cos(angle + spread);
1265
- const hy2 = tip.y - length * Math.sin(angle + spread);
1266
- return `M ${fmt(hx1)} ${fmt(hy1)} L ${fmt(tip.x)} ${fmt(tip.y)} L ${fmt(hx2)} ${fmt(hy2)}`;
2675
+ return [
2676
+ { x: tip.x - length * Math.cos(angle - spread), y: tip.y - length * Math.sin(angle - spread) },
2677
+ tip,
2678
+ { x: tip.x - length * Math.cos(angle + spread), y: tip.y - length * Math.sin(angle + spread) }
2679
+ ];
2680
+ }
2681
+ function arrowHeadPath(tip, angle, length) {
2682
+ const [a, t, b] = arrowHeadPoints(tip, angle, length);
2683
+ return `M ${fmt(a.x)} ${fmt(a.y)} L ${fmt(t.x)} ${fmt(t.y)} L ${fmt(b.x)} ${fmt(b.y)}`;
1267
2684
  }
1268
2685
  function pathLength(points) {
1269
2686
  let total = 0;
@@ -1569,9 +2986,9 @@ var STROKE_WIDTH = 2;
1569
2986
  function isDrawingSkeleton(value) {
1570
2987
  return isRecord2(value) && Array.isArray(value.boxes);
1571
2988
  }
1572
- function parseDrawingSkeleton(json) {
2989
+ function parseDrawingSkeleton(json2) {
1573
2990
  try {
1574
- const parsed = JSON.parse(json);
2991
+ const parsed = JSON.parse(json2);
1575
2992
  if (!isDrawingSkeleton(parsed)) return EMPTY_DRAWING;
1576
2993
  return expandSkeleton(normalizeSkeleton(parsed));
1577
2994
  } catch {
@@ -1584,7 +3001,7 @@ function expandSkeleton(skeleton) {
1584
3001
  const sizes = new Map(boxes.map((box) => [box.id, measureBox(box, boxTypes.get(box.id))]));
1585
3002
  const boxIds = new Set(boxTypes.keys());
1586
3003
  const connectors = (skeleton.connectors ?? []).filter(
1587
- (c) => boxIds.has(endId(c.from)) && boxIds.has(endId(c.to)) && endId(c.from) !== endId(c.to)
3004
+ (c2) => boxIds.has(endId(c2.from)) && boxIds.has(endId(c2.to)) && endId(c2.from) !== endId(c2.to)
1588
3005
  );
1589
3006
  const positions = layoutBoxes(boxes, sizes, connectors, skeleton.direction ?? "right");
1590
3007
  const boxShapes = boxes.map(
@@ -1599,7 +3016,7 @@ function expandSkeleton(skeleton) {
1599
3016
  used.add(id);
1600
3017
  return id;
1601
3018
  };
1602
- const connectorShapes = connectors.map((c) => expandConnector(c, centers, nextId("c")));
3019
+ const connectorShapes = connectors.map((c2) => expandConnector(c2, centers, nextId("c")));
1603
3020
  const textShapes = (skeleton.texts ?? []).map((t) => expandText(t, nextId("t")));
1604
3021
  const shapes = resolveBindings([...boxShapes, ...connectorShapes, ...textShapes]);
1605
3022
  const bottom = shapes.reduce((max, shape) => {
@@ -1652,7 +3069,7 @@ function layoutBoxes(boxes, sizes, connectors, direction) {
1652
3069
  const positions = /* @__PURE__ */ new Map();
1653
3070
  const auto = boxes.filter((box) => box.x === void 0 || box.y === void 0);
1654
3071
  const autoIds = new Set(auto.map((box) => box.id));
1655
- const edges = connectors.map((c) => ({ from: endId(c.from), to: endId(c.to) })).filter((e) => e.from !== e.to && autoIds.has(e.from) && autoIds.has(e.to));
3072
+ const edges = connectors.map((c2) => ({ from: endId(c2.from), to: endId(c2.to) })).filter((e) => e.from !== e.to && autoIds.has(e.from) && autoIds.has(e.to));
1656
3073
  const ranks = rankNodes(
1657
3074
  auto.map((box) => box.id),
1658
3075
  acyclicEdges(
@@ -1671,7 +3088,7 @@ function layoutBoxes(boxes, sizes, connectors, direction) {
1671
3088
  const rowCross = rows.map(
1672
3089
  (row) => row.reduce((sum, id) => sum + sizes.get(id)[cross], 0) + Math.max(0, row.length - 1) * STACK_GAP
1673
3090
  );
1674
- const maxCross = rowCross.reduce((max, c) => Math.max(max, c), 0);
3091
+ const maxCross = rowCross.reduce((max, c2) => Math.max(max, c2), 0);
1675
3092
  let mainOffset = LAYOUT_ORIGIN;
1676
3093
  rows.forEach((row, rank) => {
1677
3094
  let crossOffset = LAYOUT_ORIGIN + (maxCross - rowCross[rank]) / 2;
@@ -1800,8 +3217,8 @@ function normalizeSkeleton(raw) {
1800
3217
  const box = normalizeBox(b);
1801
3218
  return box ? [box] : [];
1802
3219
  });
1803
- const connectors = Array.isArray(value.connectors) ? value.connectors.flatMap((c) => {
1804
- const connector = normalizeConnector(c);
3220
+ const connectors = Array.isArray(value.connectors) ? value.connectors.flatMap((c2) => {
3221
+ const connector = normalizeConnector(c2);
1805
3222
  return connector ? [connector] : [];
1806
3223
  }) : [];
1807
3224
  const texts = Array.isArray(value.texts) ? value.texts.flatMap((t) => {
@@ -2375,7 +3792,7 @@ function BoxGeometry({
2375
3792
  }
2376
3793
  );
2377
3794
  case "note": {
2378
- const f = NOTE_FOLD(b);
3795
+ const f3 = NOTE_FOLD(b);
2379
3796
  const r = b.x + b.w;
2380
3797
  const btm = b.y + b.h;
2381
3798
  return /* @__PURE__ */ jsxs4("g", { children: [
@@ -2383,7 +3800,7 @@ function BoxGeometry({
2383
3800
  "path",
2384
3801
  {
2385
3802
  ...stroke,
2386
- d: `M ${n(b.x)} ${n(b.y)} H ${n(r)} V ${n(btm - f)} L ${n(r - f)} ${n(btm)} H ${n(b.x)} Z`,
3803
+ d: `M ${n(b.x)} ${n(b.y)} H ${n(r)} V ${n(btm - f3)} L ${n(r - f3)} ${n(btm)} H ${n(b.x)} Z`,
2387
3804
  fill
2388
3805
  }
2389
3806
  ),
@@ -2391,7 +3808,7 @@ function BoxGeometry({
2391
3808
  "path",
2392
3809
  {
2393
3810
  ...stroke,
2394
- d: `M ${n(r - f)} ${n(btm)} V ${n(btm - f)} H ${n(r)}`,
3811
+ d: `M ${n(r - f3)} ${n(btm)} V ${n(btm - f3)} H ${n(r)}`,
2395
3812
  fill: "rgba(0,0,0,0.08)"
2396
3813
  }
2397
3814
  )
@@ -2474,8 +3891,385 @@ function BoxGeometry({
2474
3891
  }
2475
3892
  }
2476
3893
 
2477
- // src/drawing/canvas/ShapeView.tsx
3894
+ // src/drawing/ink.ts
3895
+ var SAMPLE_STEP = 5;
3896
+ var PRESSURE = 0.3;
3897
+ function seedFrom(text) {
3898
+ let h = 2166136261;
3899
+ for (let i = 0; i < text.length; i++) {
3900
+ h ^= text.charCodeAt(i);
3901
+ h = Math.imul(h, 16777619);
3902
+ }
3903
+ return h >>> 0;
3904
+ }
3905
+ function mulberry32(seed) {
3906
+ let a = seed >>> 0;
3907
+ return () => {
3908
+ a = a + 1831565813 | 0;
3909
+ let t = Math.imul(a ^ a >>> 15, 1 | a);
3910
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
3911
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
3912
+ };
3913
+ }
3914
+ function inkAmplitude(size) {
3915
+ return Math.min(4, Math.max(1, size * 0.03));
3916
+ }
3917
+ function inkFillOffset(seed) {
3918
+ const rand = mulberry32(seed ^ 2654435769);
3919
+ const angle = rand() * Math.PI * 2;
3920
+ const d = 2 + rand();
3921
+ return { x: Math.cos(angle) * d, y: Math.sin(angle) * d };
3922
+ }
3923
+ function makeField(seed, amplitude, closed) {
3924
+ const rand = mulberry32(seed);
3925
+ const int = (lo, span) => lo + Math.floor(rand() * span);
3926
+ const f1 = closed ? int(2, 2) : 1.5 + rand();
3927
+ const f22 = closed ? int(5, 3) : 3 + rand() * 2;
3928
+ const g = closed ? int(2, 2) : 1 + rand();
3929
+ const p1 = rand() * Math.PI * 2;
3930
+ const p2 = rand() * Math.PI * 2;
3931
+ const pg = rand() * Math.PI * 2;
3932
+ const a1 = amplitude * (0.55 + rand() * 0.15);
3933
+ const a2 = amplitude * 0.3;
3934
+ const TAU = Math.PI * 2;
3935
+ return {
3936
+ offset: (t) => a1 * Math.sin(TAU * f1 * t + p1) + a2 * Math.sin(TAU * f22 * t + p2),
3937
+ pressure: (t) => 1 + PRESSURE * Math.sin(TAU * g * t + pg)
3938
+ };
3939
+ }
3940
+ function resample(points, closed) {
3941
+ const src = closed ? [...points, points[0]] : [...points];
3942
+ const lengths = [];
3943
+ let total = 0;
3944
+ for (let i = 1; i < src.length; i++) {
3945
+ const l = Math.hypot(src[i].x - src[i - 1].x, src[i].y - src[i - 1].y);
3946
+ lengths.push(l);
3947
+ total += l;
3948
+ }
3949
+ if (total === 0) return { points: [src[0]], ts: [0] };
3950
+ const out = [];
3951
+ const ts = [];
3952
+ let walked = 0;
3953
+ for (let i = 1; i < src.length; i++) {
3954
+ const a = src[i - 1];
3955
+ const b = src[i];
3956
+ const l = lengths[i - 1];
3957
+ const n2 = Math.max(1, Math.round(l / SAMPLE_STEP));
3958
+ for (let k = 0; k < n2; k++) {
3959
+ const u = k / n2;
3960
+ out.push({ x: a.x + (b.x - a.x) * u, y: a.y + (b.y - a.y) * u });
3961
+ ts.push((walked + l * u) / total);
3962
+ }
3963
+ walked += l;
3964
+ }
3965
+ if (!closed) {
3966
+ out.push(src[src.length - 1]);
3967
+ ts.push(1);
3968
+ }
3969
+ return { points: out, ts };
3970
+ }
3971
+ function normalAt(points, i, closed) {
3972
+ const n2 = points.length;
3973
+ const prev = points[closed ? (i - 1 + n2) % n2 : Math.max(0, i - 1)];
3974
+ const next = points[closed ? (i + 1) % n2 : Math.min(n2 - 1, i + 1)];
3975
+ const tx = next.x - prev.x;
3976
+ const ty = next.y - prev.y;
3977
+ const len = Math.hypot(tx, ty) || 1;
3978
+ return { x: -ty / len, y: tx / len };
3979
+ }
3980
+ var f = (v) => Number.isInteger(v) ? String(v) : v.toFixed(2);
3981
+ var pathOf = (points) => points.map((p, i) => `${i === 0 ? "M" : "L"} ${f(p.x)} ${f(p.y)}`).join(" ");
3982
+ function inkStroke(points, options) {
3983
+ if (points.length < 2) return { ring: "", center: "" };
3984
+ const { closed, seed, width, amplitude } = options;
3985
+ const field = makeField(seed, amplitude, closed);
3986
+ const { points: pts, ts } = resample(points, closed);
3987
+ if (pts.length < 2) return { ring: "", center: "" };
3988
+ const center2 = [];
3989
+ const outer = [];
3990
+ const inner = [];
3991
+ for (let i = 0; i < pts.length; i++) {
3992
+ const t = ts[i];
3993
+ const nrm = normalAt(pts, i, closed);
3994
+ const off = field.offset(t);
3995
+ const c2 = { x: pts[i].x + nrm.x * off, y: pts[i].y + nrm.y * off };
3996
+ const taper = closed ? 1 : 0.55 + 0.45 * Math.min(1, t / 0.1, (1 - t) / 0.1);
3997
+ const half = width * field.pressure(t) * taper / 2;
3998
+ center2.push(c2);
3999
+ outer.push({ x: c2.x + nrm.x * half, y: c2.y + nrm.y * half });
4000
+ inner.push({ x: c2.x - nrm.x * half, y: c2.y - nrm.y * half });
4001
+ }
4002
+ if (closed) {
4003
+ return {
4004
+ ring: `${pathOf(outer)} Z ${pathOf([...inner].reverse())} Z`,
4005
+ center: `${pathOf(center2)} Z`
4006
+ };
4007
+ }
4008
+ return {
4009
+ ring: `${pathOf(outer)} ${pathOf([...inner].reverse()).replace(/^M/, "L")} Z`,
4010
+ center: pathOf(center2)
4011
+ };
4012
+ }
4013
+ function roundedRectPolygon(r, radius, segments = 4) {
4014
+ const rad = Math.min(radius, r.w / 2, r.h / 2);
4015
+ if (rad <= 0) {
4016
+ return [
4017
+ { x: r.x, y: r.y },
4018
+ { x: r.x + r.w, y: r.y },
4019
+ { x: r.x + r.w, y: r.y + r.h },
4020
+ { x: r.x, y: r.y + r.h }
4021
+ ];
4022
+ }
4023
+ const corners = [
4024
+ [r.x + r.w - rad, r.y + rad, -Math.PI / 2],
4025
+ [r.x + r.w - rad, r.y + r.h - rad, 0],
4026
+ [r.x + rad, r.y + r.h - rad, Math.PI / 2],
4027
+ [r.x + rad, r.y + rad, Math.PI]
4028
+ ];
4029
+ const out = [];
4030
+ for (const [cx, cy, start] of corners) {
4031
+ for (let i = 0; i <= segments; i++) {
4032
+ const a = start + Math.PI / 2 * (i / segments);
4033
+ out.push({ x: cx + rad * Math.cos(a), y: cy + rad * Math.sin(a) });
4034
+ }
4035
+ }
4036
+ return out;
4037
+ }
4038
+ function roundedPolyline(points, cornerRadius = 6, segments = 4) {
4039
+ if (points.length < 3) return [...points];
4040
+ const out = [points[0]];
4041
+ for (let i = 1; i < points.length - 1; i++) {
4042
+ const prev = points[i - 1];
4043
+ const p = points[i];
4044
+ const next = points[i + 1];
4045
+ const inLen = Math.hypot(p.x - prev.x, p.y - prev.y);
4046
+ const outLen = Math.hypot(next.x - p.x, next.y - p.y);
4047
+ const r = Math.min(cornerRadius, inLen / 2, outLen / 2);
4048
+ if (r < 0.5) {
4049
+ out.push(p);
4050
+ continue;
4051
+ }
4052
+ const a = { x: p.x - (p.x - prev.x) / inLen * r, y: p.y - (p.y - prev.y) / inLen * r };
4053
+ const b = { x: p.x + (next.x - p.x) / outLen * r, y: p.y + (next.y - p.y) / outLen * r };
4054
+ for (let k = 0; k <= segments; k++) {
4055
+ const u = k / segments;
4056
+ const v = 1 - u;
4057
+ out.push({
4058
+ x: v * v * a.x + 2 * v * u * p.x + u * u * b.x,
4059
+ y: v * v * a.y + 2 * v * u * p.y + u * u * b.y
4060
+ });
4061
+ }
4062
+ }
4063
+ out.push(points[points.length - 1]);
4064
+ return out;
4065
+ }
4066
+ function sampleCubic(p0, p1, p2, p3, segments = 10) {
4067
+ const out = [];
4068
+ for (let k = 1; k <= segments; k++) {
4069
+ const u = k / segments;
4070
+ const v = 1 - u;
4071
+ out.push({
4072
+ x: v * v * v * p0.x + 3 * v * v * u * p1.x + 3 * v * u * u * p2.x + u * u * u * p3.x,
4073
+ y: v * v * v * p0.y + 3 * v * v * u * p1.y + 3 * v * u * u * p2.y + u * u * u * p3.y
4074
+ });
4075
+ }
4076
+ return out;
4077
+ }
4078
+ function arcPolygon(cx, cy, rx, ry, from, to, segments = 12) {
4079
+ return Array.from({ length: segments + 1 }, (_, i) => {
4080
+ const a = from + (to - from) * i / segments;
4081
+ return { x: cx + rx * Math.cos(a), y: cy + ry * Math.sin(a) };
4082
+ });
4083
+ }
4084
+
4085
+ // src/drawing/shapes/inkRender.tsx
2478
4086
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
4087
+ var f2 = (v) => Number.isInteger(v) ? String(v) : v.toFixed(2);
4088
+ function extent(points) {
4089
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
4090
+ for (const p of points) {
4091
+ if (p.x < minX) minX = p.x;
4092
+ if (p.x > maxX) maxX = p.x;
4093
+ if (p.y < minY) minY = p.y;
4094
+ if (p.y > maxY) maxY = p.y;
4095
+ }
4096
+ return { w: maxX - minX, h: maxY - minY };
4097
+ }
4098
+ function InkBoxGeometry({ shape }) {
4099
+ const b = bbox(shape);
4100
+ const seed = seedFrom(shape.id);
4101
+ const width = shape.strokeWidth;
4102
+ const off = inkFillOffset(seed);
4103
+ const fillTransform = `translate(${f2(off.x)} ${f2(off.y)})`;
4104
+ const amplitudeOf = (points) => inkAmplitude(Math.min(extent(points).w, extent(points).h));
4105
+ const closed = (points, part, fill = shape.fill) => {
4106
+ const s = inkStroke(points, { closed: true, seed: seed + part, width, amplitude: amplitudeOf(points) });
4107
+ return /* @__PURE__ */ jsxs5("g", { children: [
4108
+ /* @__PURE__ */ jsx5("path", { d: s.center, fill, stroke: "none", transform: fillTransform }),
4109
+ /* @__PURE__ */ jsx5("path", { d: s.ring, fill: shape.stroke, fillRule: "evenodd", stroke: "none" })
4110
+ ] });
4111
+ };
4112
+ const open = (points, part, w = width) => /* @__PURE__ */ jsx5(
4113
+ "path",
4114
+ {
4115
+ d: inkStroke(points, { closed: false, seed: seed + part, width: w, amplitude: amplitudeOf(points) }).ring,
4116
+ fill: shape.stroke,
4117
+ stroke: "none"
4118
+ }
4119
+ );
4120
+ switch (shape.type) {
4121
+ case "rect":
4122
+ return closed(roundedRectPolygon(b, Math.min(8, b.w / 4, b.h / 4)), 0);
4123
+ case "ellipse":
4124
+ return closed(ellipsePolygon(b, 64), 0);
4125
+ case "diamond":
4126
+ return closed(
4127
+ [
4128
+ { x: b.x + b.w / 2, y: b.y },
4129
+ { x: b.x + b.w, y: b.y + b.h / 2 },
4130
+ { x: b.x + b.w / 2, y: b.y + b.h },
4131
+ { x: b.x, y: b.y + b.h / 2 }
4132
+ ],
4133
+ 0
4134
+ );
4135
+ case "note": {
4136
+ const fold = NOTE_FOLD(b);
4137
+ const r = b.x + b.w;
4138
+ const btm = b.y + b.h;
4139
+ const fillPts = [
4140
+ { x: b.x, y: b.y },
4141
+ { x: r, y: b.y },
4142
+ { x: r, y: btm - fold },
4143
+ { x: r - fold, y: btm },
4144
+ { x: b.x, y: btm }
4145
+ ];
4146
+ const foldPts = [
4147
+ { x: r - fold, y: btm },
4148
+ { x: r - fold, y: btm - fold },
4149
+ { x: r, y: btm - fold }
4150
+ ];
4151
+ return /* @__PURE__ */ jsxs5("g", { children: [
4152
+ closed(fillPts, 0),
4153
+ /* @__PURE__ */ jsx5(
4154
+ "path",
4155
+ {
4156
+ d: `M ${foldPts.map((p) => `${f2(p.x)} ${f2(p.y)}`).join(" L ")} Z`,
4157
+ fill: "rgba(0,0,0,0.08)",
4158
+ stroke: "none"
4159
+ }
4160
+ ),
4161
+ open(foldPts, 1)
4162
+ ] });
4163
+ }
4164
+ case "cylinder": {
4165
+ const ry = CYLINDER_RY(b);
4166
+ const rx = b.w / 2;
4167
+ const cx = b.x + rx;
4168
+ const body = [
4169
+ { x: b.x, y: b.y + ry },
4170
+ { x: b.x, y: b.y + b.h - ry },
4171
+ ...arcPolygon(cx, b.y + b.h - ry, rx, ry, Math.PI, 0, 16),
4172
+ { x: b.x + b.w, y: b.y + ry }
4173
+ ];
4174
+ const s = inkStroke(body, { closed: false, seed: seed + 0, width, amplitude: amplitudeOf(body) });
4175
+ return /* @__PURE__ */ jsxs5("g", { children: [
4176
+ /* @__PURE__ */ jsx5("path", { d: `${s.center} Z`, fill: shape.fill, stroke: "none", transform: fillTransform }),
4177
+ /* @__PURE__ */ jsx5("path", { d: s.ring, fill: shape.stroke, stroke: "none" }),
4178
+ closed(ellipsePolygon({ x: b.x, y: b.y, w: b.w, h: ry * 2 }, 48), 1)
4179
+ ] });
4180
+ }
4181
+ case "cloud": {
4182
+ const p = (u, v) => ({ x: b.x + u * b.w, y: b.y + v * b.h });
4183
+ const start = p(0.22, 0.86);
4184
+ const segs = [
4185
+ [p(0.04, 0.88), p(0, 0.58), p(0.16, 0.5)],
4186
+ [p(0.08, 0.26), p(0.3, 0.12), p(0.42, 0.28)],
4187
+ [p(0.5, 0.02), p(0.76, 0.04), p(0.78, 0.3)],
4188
+ [p(0.98, 0.26), p(1.04, 0.56), p(0.88, 0.64)],
4189
+ [p(1, 0.8), p(0.9, 0.9), p(0.76, 0.86)]
4190
+ ];
4191
+ const pts = [start];
4192
+ let from = start;
4193
+ for (const [c1, c2, to] of segs) {
4194
+ pts.push(...sampleCubic(from, c1, c2, to, 8));
4195
+ from = to;
4196
+ }
4197
+ return closed(pts, 0);
4198
+ }
4199
+ case "queue": {
4200
+ const rx = QUEUE_RX(b);
4201
+ const ry = b.h / 2;
4202
+ const body = [
4203
+ { x: b.x + rx, y: b.y },
4204
+ { x: b.x + b.w - rx, y: b.y },
4205
+ { x: b.x + b.w - rx, y: b.y + b.h },
4206
+ { x: b.x + rx, y: b.y + b.h },
4207
+ ...arcPolygon(b.x + rx, b.y + ry, rx, ry, Math.PI / 2, 3 * Math.PI / 2, 16).slice(1, -1)
4208
+ ];
4209
+ return /* @__PURE__ */ jsxs5("g", { children: [
4210
+ closed(body, 0),
4211
+ closed(ellipsePolygon({ x: b.x + b.w - rx * 2, y: b.y, w: rx * 2, h: b.h }, 48), 1)
4212
+ ] });
4213
+ }
4214
+ case "actor": {
4215
+ const figH = b.h * ACTOR_FIGURE_RATIO;
4216
+ const cx = b.x + b.w / 2;
4217
+ const r = Math.max(4, Math.min(figH * 0.16, b.w * 0.2));
4218
+ const neck = b.y + r * 2;
4219
+ const hip = b.y + figH * 0.62;
4220
+ const armY = neck + figH * 0.12;
4221
+ const reach = Math.min(b.w * 0.32, figH * 0.3);
4222
+ return /* @__PURE__ */ jsxs5("g", { children: [
4223
+ closed(ellipsePolygon({ x: cx - r, y: b.y, w: r * 2, h: r * 2 }, 32), 0),
4224
+ open([{ x: cx, y: neck }, { x: cx, y: hip }], 1),
4225
+ open([{ x: cx - reach, y: armY }, { x: cx + reach, y: armY }], 2),
4226
+ open(
4227
+ [
4228
+ { x: cx - reach, y: b.y + figH },
4229
+ { x: cx, y: hip },
4230
+ { x: cx + reach, y: b.y + figH }
4231
+ ],
4232
+ 3
4233
+ )
4234
+ ] });
4235
+ }
4236
+ default:
4237
+ return null;
4238
+ }
4239
+ }
4240
+ function InkConnector({
4241
+ shape,
4242
+ points
4243
+ }) {
4244
+ if (points.length < 2) return null;
4245
+ const seed = seedFrom(shape.id);
4246
+ const length = pathLength(points);
4247
+ const amplitude = Math.min(3, Math.max(0.8, length * 0.015));
4248
+ const width = shape.strokeWidth;
4249
+ const line = inkStroke(roundedPolyline(points), { closed: false, seed, width, amplitude });
4250
+ const heads = [];
4251
+ if (shape.type === "arrow" && length >= 1) {
4252
+ const headLength = Math.min(14, 4 + length / 4);
4253
+ const last = points.length - 1;
4254
+ heads.push(arrowHeadPoints(points[last], segmentAngleAt(points, last, false), headLength));
4255
+ if (shape.bidirectional) {
4256
+ heads.push(arrowHeadPoints(points[0], segmentAngleAt(points, 0, true), headLength));
4257
+ }
4258
+ }
4259
+ return /* @__PURE__ */ jsxs5("g", { fill: shape.stroke, stroke: "none", children: [
4260
+ /* @__PURE__ */ jsx5("path", { d: line.ring }),
4261
+ heads.map((pts, i) => /* @__PURE__ */ jsx5(
4262
+ "path",
4263
+ {
4264
+ d: inkStroke(pts, { closed: false, seed: seed + 1 + i, width: width * 1.15, amplitude: 0.8 }).ring
4265
+ },
4266
+ i
4267
+ ))
4268
+ ] });
4269
+ }
4270
+
4271
+ // src/drawing/canvas/ShapeView.tsx
4272
+ import { Fragment, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
2479
4273
  import { createElement } from "react";
2480
4274
  var CONNECTOR_FONT_SIZE = 12;
2481
4275
  var CONNECTOR_LABEL_MAX_WIDTH = 160;
@@ -2497,7 +4291,7 @@ var textStyle = { userSelect: "none" };
2497
4291
  function luminance(color) {
2498
4292
  const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color);
2499
4293
  if (!m) return 1;
2500
- const hex = m[1].length === 3 ? m[1].replace(/./g, (c) => c + c) : m[1];
4294
+ const hex = m[1].length === 3 ? m[1].replace(/./g, (c2) => c2 + c2) : m[1];
2501
4295
  const [r, g, b] = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255);
2502
4296
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
2503
4297
  }
@@ -2526,7 +4320,7 @@ function BoxTexts({
2526
4320
  fill: textColorFor(shape),
2527
4321
  textAnchor: "middle"
2528
4322
  };
2529
- return /* @__PURE__ */ jsxs5("g", { children: [
4323
+ return /* @__PURE__ */ jsxs6("g", { children: [
2530
4324
  slots.includes("label") && hideField !== "label" && (shape.label ? labelLines.map((line, i) => /* @__PURE__ */ createElement(
2531
4325
  "text",
2532
4326
  {
@@ -2541,7 +4335,7 @@ function BoxTexts({
2541
4335
  style: textStyle
2542
4336
  },
2543
4337
  line
2544
- )) : hints && /* @__PURE__ */ jsx5(
4338
+ )) : hints && /* @__PURE__ */ jsx6(
2545
4339
  "text",
2546
4340
  {
2547
4341
  ...common,
@@ -2564,7 +4358,7 @@ function BoxTexts({
2564
4358
  style: textStyle
2565
4359
  },
2566
4360
  line
2567
- )) : hints && /* @__PURE__ */ jsx5(
4361
+ )) : hints && /* @__PURE__ */ jsx6(
2568
4362
  "text",
2569
4363
  {
2570
4364
  ...common,
@@ -2588,7 +4382,7 @@ function BoxTexts({
2588
4382
  style: textStyle
2589
4383
  },
2590
4384
  line
2591
- )) : hints && /* @__PURE__ */ jsx5(
4385
+ )) : hints && /* @__PURE__ */ jsx6(
2592
4386
  "text",
2593
4387
  {
2594
4388
  ...common,
@@ -2612,8 +4406,8 @@ function ConnectorLabel({
2612
4406
  const { x: midX, y: midY } = connectorMidpoint(points);
2613
4407
  const lineH = CONNECTOR_FONT_SIZE * LINE_HEIGHT;
2614
4408
  const startY = midY - (lines.length - 1) * lineH / 2 + CONNECTOR_FONT_SIZE * 0.35;
2615
- return /* @__PURE__ */ jsxs5("g", { children: [
2616
- /* @__PURE__ */ jsx5(
4409
+ return /* @__PURE__ */ jsxs6("g", { children: [
4410
+ /* @__PURE__ */ jsx6(
2617
4411
  "rect",
2618
4412
  {
2619
4413
  x: midX - size.w / 2 - 5,
@@ -2625,7 +4419,7 @@ function ConnectorLabel({
2625
4419
  opacity: 0.94
2626
4420
  }
2627
4421
  ),
2628
- lines.map((line, i) => /* @__PURE__ */ jsx5(
4422
+ lines.map((line, i) => /* @__PURE__ */ jsx6(
2629
4423
  "text",
2630
4424
  {
2631
4425
  x: midX,
@@ -2644,7 +4438,8 @@ function ShapeView({
2644
4438
  shape,
2645
4439
  points,
2646
4440
  hideField,
2647
- showHints
4441
+ showHints,
4442
+ ink = false
2648
4443
  }) {
2649
4444
  const stroke = {
2650
4445
  stroke: shape.stroke,
@@ -2653,9 +4448,9 @@ function ShapeView({
2653
4448
  strokeLinejoin: "round"
2654
4449
  };
2655
4450
  if (isBoxType(shape.type)) {
2656
- return /* @__PURE__ */ jsxs5("g", { children: [
2657
- /* @__PURE__ */ jsx5(BoxGeometry, { shape, stroke }),
2658
- /* @__PURE__ */ jsx5(BoxTexts, { shape, hideField, showHints })
4451
+ return /* @__PURE__ */ jsxs6("g", { children: [
4452
+ ink ? /* @__PURE__ */ jsx6(InkBoxGeometry, { shape }) : /* @__PURE__ */ jsx6(BoxGeometry, { shape, stroke }),
4453
+ /* @__PURE__ */ jsx6(BoxTexts, { shape, hideField, showHints })
2659
4454
  ] });
2660
4455
  }
2661
4456
  if (isConnectorType(shape.type)) {
@@ -2663,13 +4458,15 @@ function ShapeView({
2663
4458
  { x: shape.x, y: shape.y },
2664
4459
  { x: shape.x + shape.w, y: shape.y + shape.h }
2665
4460
  ];
2666
- return /* @__PURE__ */ jsxs5("g", { children: [
2667
- /* @__PURE__ */ jsx5("path", { ...stroke, d: polylinePath(pts), fill: "none" }),
2668
- arrowHeads(shape, pts).map((d, i) => /* @__PURE__ */ jsx5("path", { ...stroke, d, fill: "none" }, i)),
2669
- shape.text && hideField !== "text" && /* @__PURE__ */ jsx5(ConnectorLabel, { shape, points: pts })
4461
+ return /* @__PURE__ */ jsxs6("g", { children: [
4462
+ ink ? /* @__PURE__ */ jsx6(InkConnector, { shape, points: pts }) : /* @__PURE__ */ jsxs6(Fragment, { children: [
4463
+ /* @__PURE__ */ jsx6("path", { ...stroke, d: polylinePath(pts), fill: "none" }),
4464
+ arrowHeads(shape, pts).map((d, i) => /* @__PURE__ */ jsx6("path", { ...stroke, d, fill: "none" }, i))
4465
+ ] }),
4466
+ shape.text && hideField !== "text" && /* @__PURE__ */ jsx6(ConnectorLabel, { shape, points: pts })
2670
4467
  ] });
2671
4468
  }
2672
- return /* @__PURE__ */ jsx5(
4469
+ return /* @__PURE__ */ jsx6(
2673
4470
  "text",
2674
4471
  {
2675
4472
  x: shape.x,
@@ -2677,7 +4474,7 @@ function ShapeView({
2677
4474
  fill: shape.stroke,
2678
4475
  fontSize: FONT_SIZE,
2679
4476
  style: { userSelect: "none", whiteSpace: "pre" },
2680
- children: (shape.text ?? "").split("\n").map((line, i) => /* @__PURE__ */ jsx5("tspan", { x: shape.x, dy: i === 0 ? 0 : FONT_SIZE * LINE_HEIGHT, children: line }, i))
4477
+ children: (shape.text ?? "").split("\n").map((line, i) => /* @__PURE__ */ jsx6("tspan", { x: shape.x, dy: i === 0 ? 0 : FONT_SIZE * LINE_HEIGHT, children: line }, i))
2681
4478
  }
2682
4479
  );
2683
4480
  }
@@ -2686,10 +4483,10 @@ function HitArea({
2686
4483
  points
2687
4484
  }) {
2688
4485
  if (isConnectorType(shape.type) && points) {
2689
- return /* @__PURE__ */ jsx5("path", { d: polylinePath(points), fill: "none", stroke: "transparent", strokeWidth: 16 });
4486
+ return /* @__PURE__ */ jsx6("path", { d: polylinePath(points), fill: "none", stroke: "transparent", strokeWidth: 16 });
2690
4487
  }
2691
4488
  const b = bbox(shape);
2692
- return /* @__PURE__ */ jsx5(
4489
+ return /* @__PURE__ */ jsx6(
2693
4490
  "rect",
2694
4491
  {
2695
4492
  x: b.x - 2,
@@ -2708,7 +4505,7 @@ import {
2708
4505
  useRef as useRef2,
2709
4506
  useState
2710
4507
  } from "react";
2711
- import { jsx as jsx6 } from "react/jsx-runtime";
4508
+ import { jsx as jsx7 } from "react/jsx-runtime";
2712
4509
  function TextEditOverlay({
2713
4510
  shape,
2714
4511
  field,
@@ -2811,7 +4608,7 @@ function TextEditOverlay({
2811
4608
  });
2812
4609
  }
2813
4610
  const placeholder = field === "label" ? "Label" : field === "footer" ? "Footer" : "Text";
2814
- return /* @__PURE__ */ jsx6(
4611
+ return /* @__PURE__ */ jsx7(
2815
4612
  "textarea",
2816
4613
  {
2817
4614
  ref,
@@ -2831,16 +4628,16 @@ function TextEditOverlay({
2831
4628
  import { useEffect as useEffect6, useRef as useRef3, useState as useState2 } from "react";
2832
4629
 
2833
4630
  // src/components/blockWidthOptions.tsx
2834
- import { Fragment, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
4631
+ import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2835
4632
  var LAYOUT_OPTIONS = [
2836
4633
  {
2837
4634
  preset: "compact",
2838
4635
  label: "Compact (shrink to content, tight rows)",
2839
4636
  width: "content",
2840
4637
  density: "compact",
2841
- icon: /* @__PURE__ */ jsxs6(Fragment, { children: [
2842
- /* @__PURE__ */ jsx7("path", { d: "M3 4v12M17 4v12" }),
2843
- /* @__PURE__ */ jsx7("path", { d: "M5.5 10h3M11.5 10h3M6.5 7.5L9 10l-2.5 2.5M13.5 7.5L11 10l2.5 2.5" })
4638
+ icon: /* @__PURE__ */ jsxs7(Fragment2, { children: [
4639
+ /* @__PURE__ */ jsx8("path", { d: "M3 4v12M17 4v12" }),
4640
+ /* @__PURE__ */ jsx8("path", { d: "M5.5 10h3M11.5 10h3M6.5 7.5L9 10l-2.5 2.5M13.5 7.5L11 10l2.5 2.5" })
2844
4641
  ] })
2845
4642
  },
2846
4643
  {
@@ -2848,9 +4645,9 @@ var LAYOUT_OPTIONS = [
2848
4645
  label: "Comfortable (text width)",
2849
4646
  width: "text",
2850
4647
  density: "comfortable",
2851
- icon: /* @__PURE__ */ jsxs6(Fragment, { children: [
2852
- /* @__PURE__ */ jsx7("path", { d: "M3 4v12M17 4v12" }),
2853
- /* @__PURE__ */ jsx7("path", { d: "M6.5 7h7M6.5 10h7M6.5 13h4.5" })
4648
+ icon: /* @__PURE__ */ jsxs7(Fragment2, { children: [
4649
+ /* @__PURE__ */ jsx8("path", { d: "M3 4v12M17 4v12" }),
4650
+ /* @__PURE__ */ jsx8("path", { d: "M6.5 7h7M6.5 10h7M6.5 13h4.5" })
2854
4651
  ] })
2855
4652
  },
2856
4653
  {
@@ -2858,9 +4655,9 @@ var LAYOUT_OPTIONS = [
2858
4655
  label: "Full width",
2859
4656
  width: "full",
2860
4657
  density: "comfortable",
2861
- icon: /* @__PURE__ */ jsxs6(Fragment, { children: [
2862
- /* @__PURE__ */ jsx7("path", { d: "M3 4v12M17 4v12" }),
2863
- /* @__PURE__ */ jsx7("path", { d: "M6 10h8M8.5 7.5L6 10l2.5 2.5M11.5 7.5L14 10l-2.5 2.5" })
4658
+ icon: /* @__PURE__ */ jsxs7(Fragment2, { children: [
4659
+ /* @__PURE__ */ jsx8("path", { d: "M3 4v12M17 4v12" }),
4660
+ /* @__PURE__ */ jsx8("path", { d: "M6 10h8M8.5 7.5L6 10l2.5 2.5M11.5 7.5L14 10l-2.5 2.5" })
2864
4661
  ] })
2865
4662
  }
2866
4663
  ];
@@ -2869,7 +4666,7 @@ function layoutPreset(width) {
2869
4666
  }
2870
4667
 
2871
4668
  // src/drawing/canvas/Toolbar.tsx
2872
- import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
4669
+ import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2873
4670
  var PRIMARY_TOOLS = [
2874
4671
  { tool: "select", label: "Select" },
2875
4672
  { tool: "rect", label: "Rectangle" },
@@ -2888,7 +4685,7 @@ function ToolButton({
2888
4685
  className,
2889
4686
  pressed
2890
4687
  }) {
2891
- return /* @__PURE__ */ jsx8(
4688
+ return /* @__PURE__ */ jsx9(
2892
4689
  "button",
2893
4690
  {
2894
4691
  type: "button",
@@ -2897,7 +4694,7 @@ function ToolButton({
2897
4694
  "aria-pressed": pressed ?? active,
2898
4695
  className: `zui-drawing-tool ${active ? "is-active" : ""} ${className ?? ""}`,
2899
4696
  onClick,
2900
- children: /* @__PURE__ */ jsx8(Icon, { children })
4697
+ children: /* @__PURE__ */ jsx9(Icon, { children })
2901
4698
  }
2902
4699
  );
2903
4700
  }
@@ -2930,11 +4727,11 @@ function DrawingToolbar({
2930
4727
  }, [moreOpen]);
2931
4728
  const moreActive = MORE_SHAPES.includes(tool);
2932
4729
  const moreIcon = moreActive ? SHAPE_ICONS[tool] : SHAPE_ICONS[lastMore];
2933
- return /* @__PURE__ */ jsxs7(Fragment2, { children: [
2934
- /* @__PURE__ */ jsxs7("div", { className: "zui-drawing-toolbar-group", role: "toolbar", "aria-label": "Drawing tools", children: [
2935
- PRIMARY_TOOLS.map(({ tool: t, label }) => /* @__PURE__ */ jsx8(ToolButton, { label, active: tool === t, onClick: () => onToolChange(t), children: SHAPE_ICONS[t] }, t)),
2936
- /* @__PURE__ */ jsxs7("div", { className: "zui-drawing-more", ref: moreRef, children: [
2937
- /* @__PURE__ */ jsxs7(
4730
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
4731
+ /* @__PURE__ */ jsxs8("div", { className: "zui-drawing-toolbar-group", role: "toolbar", "aria-label": "Drawing tools", children: [
4732
+ PRIMARY_TOOLS.map(({ tool: t, label }) => /* @__PURE__ */ jsx9(ToolButton, { label, active: tool === t, onClick: () => onToolChange(t), children: SHAPE_ICONS[t] }, t)),
4733
+ /* @__PURE__ */ jsxs8("div", { className: "zui-drawing-more", ref: moreRef, children: [
4734
+ /* @__PURE__ */ jsxs8(
2938
4735
  "button",
2939
4736
  {
2940
4737
  type: "button",
@@ -2945,12 +4742,12 @@ function DrawingToolbar({
2945
4742
  className: `zui-drawing-tool zui-drawing-tool-more ${moreActive ? "is-active" : ""}`,
2946
4743
  onClick: () => setMoreOpen((open) => !open),
2947
4744
  children: [
2948
- /* @__PURE__ */ jsx8(Icon, { children: moreIcon }),
2949
- /* @__PURE__ */ jsx8("span", { className: "zui-drawing-caret", "aria-hidden": "true" })
4745
+ /* @__PURE__ */ jsx9(Icon, { children: moreIcon }),
4746
+ /* @__PURE__ */ jsx9("span", { className: "zui-drawing-caret", "aria-hidden": "true" })
2950
4747
  ]
2951
4748
  }
2952
4749
  ),
2953
- moreOpen && /* @__PURE__ */ jsx8("div", { className: "zui-drawing-popover", role: "menu", children: MORE_SHAPES.map((type) => /* @__PURE__ */ jsxs7(
4750
+ moreOpen && /* @__PURE__ */ jsx9("div", { className: "zui-drawing-popover", role: "menu", children: MORE_SHAPES.map((type) => /* @__PURE__ */ jsxs8(
2954
4751
  "button",
2955
4752
  {
2956
4753
  type: "button",
@@ -2963,8 +4760,8 @@ function DrawingToolbar({
2963
4760
  setMoreOpen(false);
2964
4761
  },
2965
4762
  children: [
2966
- /* @__PURE__ */ jsx8(Icon, { size: 18, children: SHAPE_ICONS[type] }),
2967
- /* @__PURE__ */ jsx8("span", { children: BOX_DEFINITIONS[type].label })
4763
+ /* @__PURE__ */ jsx9(Icon, { size: 18, children: SHAPE_ICONS[type] }),
4764
+ /* @__PURE__ */ jsx9("span", { children: BOX_DEFINITIONS[type].label })
2968
4765
  ]
2969
4766
  },
2970
4767
  type
@@ -2972,8 +4769,8 @@ function DrawingToolbar({
2972
4769
  ] })
2973
4770
  ] }),
2974
4771
  properties,
2975
- /* @__PURE__ */ jsxs7("div", { className: "zui-drawing-toolbar-group zui-drawing-toolbar-group-end", children: [
2976
- /* @__PURE__ */ jsx8(
4772
+ /* @__PURE__ */ jsxs8("div", { className: "zui-drawing-toolbar-group zui-drawing-toolbar-group-end", children: [
4773
+ /* @__PURE__ */ jsx9(
2977
4774
  ToolButton,
2978
4775
  {
2979
4776
  label: copied ? "Copied Mermaid to clipboard" : "Copy as Mermaid",
@@ -2988,8 +4785,8 @@ function DrawingToolbar({
2988
4785
  children: copied ? UI_ICONS.check : UI_ICONS.mermaid
2989
4786
  }
2990
4787
  ),
2991
- /* @__PURE__ */ jsx8("span", { className: "zui-drawing-toolbar-divider" }),
2992
- LAYOUT_OPTIONS.map(({ preset, label, icon, width: presetWidth }) => /* @__PURE__ */ jsx8(
4788
+ /* @__PURE__ */ jsx9("span", { className: "zui-drawing-toolbar-divider" }),
4789
+ LAYOUT_OPTIONS.map(({ preset, label, icon, width: presetWidth }) => /* @__PURE__ */ jsx9(
2993
4790
  ToolButton,
2994
4791
  {
2995
4792
  label,
@@ -3004,7 +4801,7 @@ function DrawingToolbar({
3004
4801
  }
3005
4802
 
3006
4803
  // src/drawing/canvas/DrawingCanvas.tsx
3007
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
4804
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
3008
4805
  var MIN_HEIGHT = 120;
3009
4806
  var MAX_HEIGHT = 1200;
3010
4807
  var WIDTH_CLASS = {
@@ -3040,6 +4837,7 @@ function DrawingCanvas({ nodeKey, data }) {
3040
4837
  const [shapes, setShapes] = useState3(data.shapes);
3041
4838
  const [canvasHeight, setCanvasHeight] = useState3(data.canvasHeight);
3042
4839
  const [width, setWidth] = useState3(data.width ?? "full");
4840
+ const ink = useContext2(EditorContext)?.drawingStyle === "ink";
3043
4841
  const [tool, setTool] = useState3("select");
3044
4842
  const [selectedIds, setSelectedIds] = useState3(EMPTY_SET);
3045
4843
  const [editingText, setEditingText] = useState3(null);
@@ -3103,9 +4901,9 @@ function DrawingCanvas({ nodeKey, data }) {
3103
4901
  ...nextWidth !== "full" || explicitFull ? { width: nextWidth } : {},
3104
4902
  shapes: nextShapes
3105
4903
  };
3106
- const json = serializeDrawingData(payload);
3107
- if (json === lastCommittedRef.current) return;
3108
- lastCommittedRef.current = json;
4904
+ const json2 = serializeDrawingData(payload);
4905
+ if (json2 === lastCommittedRef.current) return;
4906
+ lastCommittedRef.current = json2;
3109
4907
  editor.update(() => {
3110
4908
  const node = $getNodeByKey2(nodeKey);
3111
4909
  if ($isDrawingNode(node)) node.setData(payload);
@@ -3349,7 +5147,7 @@ function DrawingCanvas({ nodeKey, data }) {
3349
5147
  })
3350
5148
  );
3351
5149
  }
3352
- updateShapes((prev) => prev.map(normalize), { commit: true });
5150
+ updateShapes((prev) => prev.map(normalize2), { commit: true });
3353
5151
  },
3354
5152
  [getPoint, paths, updateShapes, startTextEditing]
3355
5153
  );
@@ -3500,11 +5298,11 @@ function DrawingCanvas({ nodeKey, data }) {
3500
5298
  const propStroke = single?.stroke ?? selection[0]?.stroke ?? stroke;
3501
5299
  const propFill = single?.fill ?? selection[0]?.fill ?? fill;
3502
5300
  const canvasCursor = tool === "select" ? "default" : tool === "text" ? "text" : "crosshair";
3503
- return /* @__PURE__ */ jsxs8(
5301
+ return /* @__PURE__ */ jsxs9(
3504
5302
  "div",
3505
5303
  {
3506
5304
  ref: rootRef,
3507
- className: `zui-drawing-canvas ${WIDTH_CLASS[width]} ${isEditable ? "is-editable" : ""}`,
5305
+ className: `zui-drawing-canvas ${WIDTH_CLASS[width]} ${isEditable ? "is-editable" : ""} ${ink ? "is-ink" : ""}`,
3508
5306
  tabIndex: isEditable ? 0 : void 0,
3509
5307
  onFocus: () => editor.dispatchCommand(DRAWING_FOCUS_COMMAND, nodeKey),
3510
5308
  onBlur: (e) => {
@@ -3512,7 +5310,7 @@ function DrawingCanvas({ nodeKey, data }) {
3512
5310
  editor.dispatchCommand(DRAWING_FOCUS_COMMAND, null);
3513
5311
  },
3514
5312
  children: [
3515
- isEditable && /* @__PURE__ */ jsx9("div", { className: "zui-drawing-toolbar", onPointerDown: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx9(
5313
+ isEditable && /* @__PURE__ */ jsx10("div", { className: "zui-drawing-toolbar", onPointerDown: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx10(
3516
5314
  DrawingToolbar,
3517
5315
  {
3518
5316
  tool,
@@ -3526,7 +5324,7 @@ function DrawingCanvas({ nodeKey, data }) {
3526
5324
  properties: (
3527
5325
  // Inline in the same row (so the stage never shifts); shown
3528
5326
  // only while the canvas has focus (see .zui-drawing-props-host)
3529
- /* @__PURE__ */ jsx9("div", { className: "zui-drawing-props-host", children: /* @__PURE__ */ jsx9(
5327
+ /* @__PURE__ */ jsx10("div", { className: "zui-drawing-props-host", children: /* @__PURE__ */ jsx10(
3530
5328
  PropertyBar,
3531
5329
  {
3532
5330
  selection,
@@ -3541,8 +5339,8 @@ function DrawingCanvas({ nodeKey, data }) {
3541
5339
  )
3542
5340
  }
3543
5341
  ) }),
3544
- /* @__PURE__ */ jsxs8("div", { className: "zui-drawing-stage", children: [
3545
- /* @__PURE__ */ jsxs8(
5342
+ /* @__PURE__ */ jsxs9("div", { className: "zui-drawing-stage", children: [
5343
+ /* @__PURE__ */ jsxs9(
3546
5344
  "svg",
3547
5345
  {
3548
5346
  ref: svgRef,
@@ -3573,7 +5371,7 @@ function DrawingCanvas({ nodeKey, data }) {
3573
5371
  }
3574
5372
  },
3575
5373
  children: [
3576
- shapes.map((shape) => /* @__PURE__ */ jsxs8(
5374
+ shapes.map((shape) => /* @__PURE__ */ jsxs9(
3577
5375
  "g",
3578
5376
  {
3579
5377
  "data-shape-id": shape.id,
@@ -3581,11 +5379,12 @@ function DrawingCanvas({ nodeKey, data }) {
3581
5379
  style: { cursor: isEditable && tool === "select" ? "move" : void 0 },
3582
5380
  onPointerDown: (e) => handleShapePointerDown(e, shape),
3583
5381
  children: [
3584
- /* @__PURE__ */ jsx9(HitArea, { shape, points: paths.get(shape.id) }),
3585
- shape.id === editingText?.id && shape.type === "text" ? null : /* @__PURE__ */ jsx9(
5382
+ /* @__PURE__ */ jsx10(HitArea, { shape, points: paths.get(shape.id) }),
5383
+ shape.id === editingText?.id && shape.type === "text" ? null : /* @__PURE__ */ jsx10(
3586
5384
  ShapeView,
3587
5385
  {
3588
5386
  shape,
5387
+ ink,
3589
5388
  points: paths.get(shape.id),
3590
5389
  hideField: shape.id === editingText?.id ? editingText.field : null,
3591
5390
  showHints: isEditable && tool === "select" && single?.id === shape.id && shape.id !== editingText?.id
@@ -3595,7 +5394,7 @@ function DrawingCanvas({ nodeKey, data }) {
3595
5394
  },
3596
5395
  shape.id
3597
5396
  )),
3598
- hoverBox && /* @__PURE__ */ jsx9(
5397
+ hoverBox && /* @__PURE__ */ jsx10(
3599
5398
  "polygon",
3600
5399
  {
3601
5400
  className: "zui-drawing-selection zui-drawing-bind-target",
@@ -3608,7 +5407,7 @@ function DrawingCanvas({ nodeKey, data }) {
3608
5407
  pointerEvents: "none"
3609
5408
  }
3610
5409
  ),
3611
- single && isEditable && !editingText && /* @__PURE__ */ jsx9(
5410
+ single && isEditable && !editingText && /* @__PURE__ */ jsx10(
3612
5411
  SelectionOverlay,
3613
5412
  {
3614
5413
  shape: single,
@@ -3618,13 +5417,13 @@ function DrawingCanvas({ nodeKey, data }) {
3618
5417
  onWaypointRemove: removeWaypoint
3619
5418
  }
3620
5419
  ),
3621
- selection.length > 1 && isEditable && /* @__PURE__ */ jsx9(GroupSelectionOverlay, { shapes: selection, paths }),
3622
- marquee && /* @__PURE__ */ jsx9(MarqueeOverlay, { rect: marqueeRect(marquee.origin, marquee.current) })
5420
+ selection.length > 1 && isEditable && /* @__PURE__ */ jsx10(GroupSelectionOverlay, { shapes: selection, paths }),
5421
+ marquee && /* @__PURE__ */ jsx10(MarqueeOverlay, { rect: marqueeRect(marquee.origin, marquee.current) })
3623
5422
  ]
3624
5423
  }
3625
5424
  ),
3626
- isEditable && shapes.length === 0 && /* @__PURE__ */ jsx9("div", { className: "zui-drawing-empty", "aria-hidden": "true", children: "Pick a shape above, then click or drag on the canvas" }),
3627
- editingShape && editingText && /* @__PURE__ */ jsx9(
5425
+ isEditable && shapes.length === 0 && /* @__PURE__ */ jsx10("div", { className: "zui-drawing-empty", "aria-hidden": "true", children: "Pick a shape above, then click or drag on the canvas" }),
5426
+ editingShape && editingText && /* @__PURE__ */ jsx10(
3628
5427
  "div",
3629
5428
  {
3630
5429
  className: "zui-drawing-overlay",
@@ -3633,7 +5432,7 @@ function DrawingCanvas({ nodeKey, data }) {
3633
5432
  width: logicalWidth ?? void 0,
3634
5433
  height: logicalWidth ? canvasHeight : void 0
3635
5434
  },
3636
- children: /* @__PURE__ */ jsx9(
5435
+ children: /* @__PURE__ */ jsx10(
3637
5436
  TextEditOverlay,
3638
5437
  {
3639
5438
  shape: editingShape,
@@ -3645,7 +5444,7 @@ function DrawingCanvas({ nodeKey, data }) {
3645
5444
  )
3646
5445
  }
3647
5446
  ),
3648
- isEditable && /* @__PURE__ */ jsx9(
5447
+ isEditable && /* @__PURE__ */ jsx10(
3649
5448
  HeightHandle,
3650
5449
  {
3651
5450
  height: canvasHeight,
@@ -3669,7 +5468,7 @@ function HeightHandle({
3669
5468
  const latestRef = useRef4(height);
3670
5469
  latestRef.current = height;
3671
5470
  const clamp = (h) => Math.round(Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, h)));
3672
- return /* @__PURE__ */ jsx9(
5471
+ return /* @__PURE__ */ jsx10(
3673
5472
  "div",
3674
5473
  {
3675
5474
  className: "zui-drawing-resize",
@@ -3692,13 +5491,13 @@ function HeightHandle({
3692
5491
  dragRef.current = null;
3693
5492
  onCommit(latestRef.current);
3694
5493
  },
3695
- children: /* @__PURE__ */ jsx9(Icon, { size: 14, children: UI_ICONS.grip })
5494
+ children: /* @__PURE__ */ jsx10(Icon, { size: 14, children: UI_ICONS.grip })
3696
5495
  }
3697
5496
  );
3698
5497
  }
3699
5498
 
3700
5499
  // src/nodes/DrawingNode.tsx
3701
- import { jsx as jsx10 } from "react/jsx-runtime";
5500
+ import { jsx as jsx11 } from "react/jsx-runtime";
3702
5501
  var DrawingNode = class _DrawingNode extends DecoratorNode {
3703
5502
  static getType() {
3704
5503
  return "drawing";
@@ -3762,7 +5561,7 @@ var DrawingNode = class _DrawingNode extends DecoratorNode {
3762
5561
  return false;
3763
5562
  }
3764
5563
  decorate(_editor, _config) {
3765
- return /* @__PURE__ */ jsx10(DrawingCanvas, { nodeKey: this.getKey(), data: this.getData() });
5564
+ return /* @__PURE__ */ jsx11(DrawingCanvas, { nodeKey: this.getKey(), data: this.getData() });
3766
5565
  }
3767
5566
  };
3768
5567
  function $createDrawingNode(data = serializeDrawingData(EMPTY_DRAWING)) {
@@ -4076,6 +5875,19 @@ var TABLE = {
4076
5875
  type: "element"
4077
5876
  };
4078
5877
 
5878
+ // src/transformers/codeTransformer.ts
5879
+ import { CODE } from "@lexical/markdown";
5880
+ import { $isCodeNode as $isCodeNode2 } from "@lexical/code";
5881
+ var CODE_BLOCK = {
5882
+ ...CODE,
5883
+ export: (node, exportChildren) => {
5884
+ if (!$isCodeNode2(node)) return null;
5885
+ if (node.getLanguage() !== PLAIN_LANGUAGE) return CODE.export?.(node, exportChildren) ?? null;
5886
+ const text = node.getTextContent();
5887
+ return "```" + (text ? "\n" + text : "") + "\n```";
5888
+ }
5889
+ };
5890
+
4079
5891
  // src/theme.ts
4080
5892
  var editorTheme = {
4081
5893
  ltr: "text-left",
@@ -4113,38 +5925,9 @@ var editorTheme = {
4113
5925
  underlineStrikethrough: "underline line-through"
4114
5926
  },
4115
5927
  code: "zui-code bg-muted rounded-md p-4 font-mono text-sm block my-2 overflow-x-auto",
4116
- codeHighlight: {
4117
- atrule: "text-blue-500",
4118
- attr: "text-yellow-500",
4119
- boolean: "text-purple-500",
4120
- builtin: "text-cyan-500",
4121
- cdata: "text-gray-500",
4122
- char: "text-green-500",
4123
- class: "text-yellow-500",
4124
- "class-name": "text-yellow-500",
4125
- comment: "text-gray-500",
4126
- constant: "text-purple-500",
4127
- deleted: "text-red-500",
4128
- doctype: "text-gray-500",
4129
- entity: "text-red-500",
4130
- function: "text-blue-500",
4131
- important: "text-red-500",
4132
- inserted: "text-green-500",
4133
- keyword: "text-purple-500",
4134
- namespace: "text-purple-500",
4135
- number: "text-green-500",
4136
- operator: "text-gray-500",
4137
- prolog: "text-gray-500",
4138
- property: "text-blue-500",
4139
- punctuation: "text-gray-500",
4140
- regex: "text-red-500",
4141
- selector: "text-blue-500",
4142
- string: "text-green-500",
4143
- symbol: "text-green-500",
4144
- tag: "text-red-500",
4145
- url: "text-blue-500",
4146
- variable: "text-blue-500"
4147
- },
5928
+ codeHighlight: Object.fromEntries(
5929
+ CODE_TOKEN_TYPES.map((type) => [type, `zui-token zui-token-${type}`])
5930
+ ),
4148
5931
  quote: "zui-quote border-l-4 border-border pl-4 italic",
4149
5932
  frontmatter: "zui-frontmatter",
4150
5933
  table: "zui-table",
@@ -4155,23 +5938,18 @@ var editorTheme = {
4155
5938
  drawing: "zui-drawing"
4156
5939
  };
4157
5940
 
4158
- // src/editorContext.ts
4159
- import { createContext, useContext } from "react";
4160
- var EditorContext = createContext(null);
4161
- function useEditorContext() {
4162
- const ctx = useContext(EditorContext);
4163
- if (!ctx) {
4164
- throw new Error(
4165
- "@zuilib/text-editor: this component must be rendered inside <MarkdownEditor> or <MarkdownEditor.Root>"
4166
- );
4167
- }
4168
- return ctx;
4169
- }
4170
-
4171
5941
  // src/EditorRoot.tsx
4172
- import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
4173
- var SYNC_TRANSFORMERS = [FRONTMATTER, DRAWING, DIAGRAM, CHECK_LIST, TABLE, ...TRANSFORMERS2];
4174
- var SHORTCUT_TRANSFORMERS = [TABLE, ...TRANSFORMERS2.filter((t) => t !== CODE)];
5942
+ import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
5943
+ var SYNC_TRANSFORMERS = [
5944
+ FRONTMATTER,
5945
+ DRAWING,
5946
+ DIAGRAM,
5947
+ CHECK_LIST,
5948
+ TABLE,
5949
+ CODE_BLOCK,
5950
+ ...TRANSFORMERS2.filter((t) => t !== CODE2)
5951
+ ];
5952
+ var SHORTCUT_TRANSFORMERS = [TABLE, ...TRANSFORMERS2.filter((t) => t !== CODE2)];
4175
5953
  var NO_DEFAULT_BLOCK_WIDTH = {};
4176
5954
  function onError(error) {
4177
5955
  console.error(error);
@@ -4181,7 +5959,7 @@ var editorNodes = [
4181
5959
  ListNode2,
4182
5960
  ListItemNode,
4183
5961
  QuoteNode,
4184
- CodeNode,
5962
+ CodeNode2,
4185
5963
  CodeHighlightNode,
4186
5964
  AutoLinkNode,
4187
5965
  LinkNode,
@@ -4207,6 +5985,7 @@ function EditorRoot({
4207
5985
  autoFocus = false,
4208
5986
  measure,
4209
5987
  defaultBlockWidth = NO_DEFAULT_BLOCK_WIDTH,
5988
+ drawingStyle = "clean",
4210
5989
  children
4211
5990
  }) {
4212
5991
  const latestValueRef = useRef5(value ?? "");
@@ -4248,19 +6027,20 @@ function EditorRoot({
4248
6027
  autoFocus,
4249
6028
  rawValue: value ?? "",
4250
6029
  onRawChange: handleChange,
4251
- defaultBlockWidth
6030
+ defaultBlockWidth,
6031
+ drawingStyle
4252
6032
  }),
4253
- [mode, readOnly, autoFocus, value, handleChange, defaultBlockWidth]
6033
+ [mode, readOnly, autoFocus, value, handleChange, defaultBlockWidth, drawingStyle]
4254
6034
  );
4255
6035
  const isRaw = mode === "edit-raw";
4256
6036
  const rootStyle = useMemo2(
4257
6037
  () => measure !== void 0 ? { "--zui-text-editor-measure": measure } : void 0,
4258
6038
  [measure]
4259
6039
  );
4260
- return /* @__PURE__ */ jsx11(LexicalComposer, { initialConfig, children: /* @__PURE__ */ jsx11(EditorContext.Provider, { value: context, children: /* @__PURE__ */ jsxs9("div", { className: `zui-text-editor ${className ?? ""}`, style: rootStyle, children: [
6040
+ return /* @__PURE__ */ jsx12(LexicalComposer, { initialConfig, children: /* @__PURE__ */ jsx12(EditorContext.Provider, { value: context, children: /* @__PURE__ */ jsxs10("div", { className: `zui-text-editor ${className ?? ""}`, style: rootStyle, children: [
4261
6041
  children,
4262
- !isRaw && /* @__PURE__ */ jsxs9(Fragment3, { children: [
4263
- /* @__PURE__ */ jsx11(
6042
+ !isRaw && /* @__PURE__ */ jsxs10(Fragment4, { children: [
6043
+ /* @__PURE__ */ jsx12(
4264
6044
  MarkdownSyncPlugin,
4265
6045
  {
4266
6046
  initialMarkdown: mode === "view" ? value ?? "" : capturedMarkdown,
@@ -4268,17 +6048,17 @@ function EditorRoot({
4268
6048
  transformers: SYNC_TRANSFORMERS
4269
6049
  }
4270
6050
  ),
4271
- /* @__PURE__ */ jsx11(HistoryPlugin, {}),
4272
- /* @__PURE__ */ jsx11(ListPlugin, {}),
4273
- /* @__PURE__ */ jsx11(CheckListPlugin, {}),
4274
- /* @__PURE__ */ jsx11(ChecklistShortcutPlugin, {}),
4275
- /* @__PURE__ */ jsx11(CodeBlockShortcutPlugin, {}),
4276
- /* @__PURE__ */ jsx11(CodeHighlightPlugin, {}),
4277
- /* @__PURE__ */ jsx11(TablePlugin, {}),
4278
- /* @__PURE__ */ jsx11(LinkPlugin, {}),
4279
- /* @__PURE__ */ jsx11(MarkdownShortcutPlugin, { transformers: SHORTCUT_TRANSFORMERS }),
4280
- /* @__PURE__ */ jsx11(ReadOnlyPlugin, { readOnly: readOnly || mode === "view" }),
4281
- autoFocus && /* @__PURE__ */ jsx11(AutoFocusPlugin, {})
6051
+ /* @__PURE__ */ jsx12(HistoryPlugin, {}),
6052
+ /* @__PURE__ */ jsx12(ListPlugin, {}),
6053
+ /* @__PURE__ */ jsx12(CheckListPlugin, {}),
6054
+ /* @__PURE__ */ jsx12(ChecklistShortcutPlugin, {}),
6055
+ /* @__PURE__ */ jsx12(CodeBlockShortcutPlugin, {}),
6056
+ /* @__PURE__ */ jsx12(CodeHighlightPlugin, {}),
6057
+ /* @__PURE__ */ jsx12(TablePlugin, {}),
6058
+ /* @__PURE__ */ jsx12(LinkPlugin, {}),
6059
+ /* @__PURE__ */ jsx12(MarkdownShortcutPlugin, { transformers: SHORTCUT_TRANSFORMERS }),
6060
+ /* @__PURE__ */ jsx12(ReadOnlyPlugin, { readOnly: readOnly || mode === "view" }),
6061
+ autoFocus && /* @__PURE__ */ jsx12(AutoFocusPlugin, {})
4282
6062
  ] })
4283
6063
  ] }) }) }, mountKey);
4284
6064
  }
@@ -4298,7 +6078,7 @@ import {
4298
6078
  import { $getRoot, $getSelection as $getSelection3, $isRangeSelection as $isRangeSelection3 } from "lexical";
4299
6079
  import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
4300
6080
  import { $isHeadingNode } from "@lexical/rich-text";
4301
- import { jsx as jsx12 } from "react/jsx-runtime";
6081
+ import { jsx as jsx13 } from "react/jsx-runtime";
4302
6082
  var HEADING_LEVELS = {
4303
6083
  h1: 1,
4304
6084
  h2: 2,
@@ -4396,7 +6176,7 @@ function FoldingPlugin() {
4396
6176
  return next;
4397
6177
  });
4398
6178
  }, []);
4399
- return /* @__PURE__ */ jsx12("div", { className: "zui-text-editor-fold-gutter", children: buttons.map(({ key, folded, top, height }) => /* @__PURE__ */ jsx12(
6179
+ return /* @__PURE__ */ jsx13("div", { className: "zui-text-editor-fold-gutter", children: buttons.map(({ key, folded, top, height }) => /* @__PURE__ */ jsx13(
4400
6180
  "button",
4401
6181
  {
4402
6182
  type: "button",
@@ -4406,7 +6186,7 @@ function FoldingPlugin() {
4406
6186
  "aria-label": folded ? "Expand section" : "Collapse section",
4407
6187
  "aria-expanded": !folded,
4408
6188
  onClick: () => toggle(key),
4409
- children: /* @__PURE__ */ jsx12(
6189
+ children: /* @__PURE__ */ jsx13(
4410
6190
  "svg",
4411
6191
  {
4412
6192
  viewBox: "0 0 20 20",
@@ -4417,7 +6197,7 @@ function FoldingPlugin() {
4417
6197
  strokeWidth: "2",
4418
6198
  strokeLinecap: "round",
4419
6199
  strokeLinejoin: "round",
4420
- children: /* @__PURE__ */ jsx12("path", { d: "M6 8l4 4 4-4" })
6200
+ children: /* @__PURE__ */ jsx13("path", { d: "M6 8l4 4 4-4" })
4421
6201
  }
4422
6202
  )
4423
6203
  },
@@ -4445,7 +6225,7 @@ import {
4445
6225
  } from "lexical";
4446
6226
  import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
4447
6227
  import { INSERT_TABLE_COMMAND } from "@lexical/table";
4448
- import { $insertNodeToNearestRoot, mergeRegister } from "@lexical/utils";
6228
+ import { $insertNodeToNearestRoot, mergeRegister as mergeRegister2 } from "@lexical/utils";
4449
6229
  var TRACKED_FORMATS = [
4450
6230
  "bold",
4451
6231
  "italic",
@@ -4470,7 +6250,7 @@ function useMarkdownEditor() {
4470
6250
  const activeDrawingRef = useRef7(null);
4471
6251
  const [drawingWidth, setDrawingWidth] = useState6(null);
4472
6252
  useEffect10(
4473
- () => mergeRegister(
6253
+ () => mergeRegister2(
4474
6254
  editor.registerUpdateListener(({ editorState }) => {
4475
6255
  editorState.read(() => {
4476
6256
  const table = $getSelectedTable();
@@ -4612,23 +6392,23 @@ function useMarkdownEditor() {
4612
6392
  }
4613
6393
 
4614
6394
  // src/components/Toolbar.tsx
4615
- import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
6395
+ import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
4616
6396
  function Toolbar({ children, className }) {
4617
- return /* @__PURE__ */ jsx13(
6397
+ return /* @__PURE__ */ jsx14(
4618
6398
  "div",
4619
6399
  {
4620
6400
  className: `zui-text-editor-toolbar ${className ?? ""}`,
4621
6401
  role: "toolbar",
4622
- children: children ?? /* @__PURE__ */ jsxs10(Fragment4, { children: [
4623
- /* @__PURE__ */ jsx13(FormatButtons, {}),
4624
- /* @__PURE__ */ jsx13(ToolbarDivider, {}),
4625
- /* @__PURE__ */ jsx13(InsertButtons, {})
6402
+ children: children ?? /* @__PURE__ */ jsxs11(Fragment5, { children: [
6403
+ /* @__PURE__ */ jsx14(FormatButtons, {}),
6404
+ /* @__PURE__ */ jsx14(ToolbarDivider, {}),
6405
+ /* @__PURE__ */ jsx14(InsertButtons, {})
4626
6406
  ] })
4627
6407
  }
4628
6408
  );
4629
6409
  }
4630
6410
  function ToolbarDivider() {
4631
- return /* @__PURE__ */ jsx13("div", { className: "zui-text-editor-toolbar-divider" });
6411
+ return /* @__PURE__ */ jsx14("div", { className: "zui-text-editor-toolbar-divider" });
4632
6412
  }
4633
6413
  function ToolbarButton({
4634
6414
  label,
@@ -4638,7 +6418,7 @@ function ToolbarButton({
4638
6418
  disabled = false,
4639
6419
  className
4640
6420
  }) {
4641
- return /* @__PURE__ */ jsx13(
6421
+ return /* @__PURE__ */ jsx14(
4642
6422
  "button",
4643
6423
  {
4644
6424
  type: "button",
@@ -4654,7 +6434,7 @@ function ToolbarButton({
4654
6434
  );
4655
6435
  }
4656
6436
  function Icon2({ children, strokeWidth = 1.5 }) {
4657
- return /* @__PURE__ */ jsx13(
6437
+ return /* @__PURE__ */ jsx14(
4658
6438
  "svg",
4659
6439
  {
4660
6440
  viewBox: "0 0 20 20",
@@ -4673,27 +6453,27 @@ var FORMAT_BUTTONS = [
4673
6453
  {
4674
6454
  format: "bold",
4675
6455
  label: "Bold",
4676
- icon: /* @__PURE__ */ jsx13(Icon2, { strokeWidth: 1.8, children: /* @__PURE__ */ jsx13("path", { d: "M6 3.5h5a3 3 0 0 1 0 6H6zm0 6h6a3 3 0 0 1 0 6H6z" }) })
6456
+ icon: /* @__PURE__ */ jsx14(Icon2, { strokeWidth: 1.8, children: /* @__PURE__ */ jsx14("path", { d: "M6 3.5h5a3 3 0 0 1 0 6H6zm0 6h6a3 3 0 0 1 0 6H6z" }) })
4677
6457
  },
4678
6458
  {
4679
6459
  format: "italic",
4680
6460
  label: "Italic",
4681
- icon: /* @__PURE__ */ jsx13(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx13("path", { d: "M8.5 3.5h6M5.5 16.5h6M11.5 3.5l-3 13" }) })
6461
+ icon: /* @__PURE__ */ jsx14(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx14("path", { d: "M8.5 3.5h6M5.5 16.5h6M11.5 3.5l-3 13" }) })
4682
6462
  },
4683
6463
  {
4684
6464
  format: "strikethrough",
4685
6465
  label: "Strikethrough",
4686
- icon: /* @__PURE__ */ jsx13(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx13("path", { d: "M4 10h12M13.5 5.5c-.6-1.2-2-2-3.5-2-2 0-3.5 1.2-3.5 2.8 0 .5.1.9.4 1.3m-.4 5c.5 1.6 2 2.9 3.9 2.9 2 0 3.6-1.2 3.6-2.9 0-.4-.1-.8-.2-1.1" }) })
6466
+ icon: /* @__PURE__ */ jsx14(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx14("path", { d: "M4 10h12M13.5 5.5c-.6-1.2-2-2-3.5-2-2 0-3.5 1.2-3.5 2.8 0 .5.1.9.4 1.3m-.4 5c.5 1.6 2 2.9 3.9 2.9 2 0 3.6-1.2 3.6-2.9 0-.4-.1-.8-.2-1.1" }) })
4687
6467
  },
4688
6468
  {
4689
6469
  format: "code",
4690
6470
  label: "Inline code",
4691
- icon: /* @__PURE__ */ jsx13(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx13("path", { d: "M7.5 6L4 10l3.5 4M12.5 6L16 10l-3.5 4" }) })
6471
+ icon: /* @__PURE__ */ jsx14(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx14("path", { d: "M7.5 6L4 10l3.5 4M12.5 6L16 10l-3.5 4" }) })
4692
6472
  }
4693
6473
  ];
4694
6474
  function FormatButtons() {
4695
6475
  const { activeFormats, toggleFormat } = useMarkdownEditor();
4696
- return /* @__PURE__ */ jsx13(Fragment4, { children: FORMAT_BUTTONS.map(({ format, label, icon }) => /* @__PURE__ */ jsx13(
6476
+ return /* @__PURE__ */ jsx14(Fragment5, { children: FORMAT_BUTTONS.map(({ format, label, icon }) => /* @__PURE__ */ jsx14(
4697
6477
  ToolbarButton,
4698
6478
  {
4699
6479
  label,
@@ -4706,36 +6486,36 @@ function FormatButtons() {
4706
6486
  }
4707
6487
  function InsertButtons() {
4708
6488
  const { insertTable, insertDrawing } = useMarkdownEditor();
4709
- return /* @__PURE__ */ jsxs10(Fragment4, { children: [
4710
- /* @__PURE__ */ jsx13(ToolbarButton, { label: "Insert table", onClick: () => insertTable(), children: /* @__PURE__ */ jsxs10(Icon2, { children: [
4711
- /* @__PURE__ */ jsx13("rect", { x: "3", y: "3.5", width: "14", height: "13", rx: "1.5" }),
4712
- /* @__PURE__ */ jsx13("path", { d: "M3 8h14M8 8v8.5M13 8v8.5" })
6489
+ return /* @__PURE__ */ jsxs11(Fragment5, { children: [
6490
+ /* @__PURE__ */ jsx14(ToolbarButton, { label: "Insert table", onClick: () => insertTable(), children: /* @__PURE__ */ jsxs11(Icon2, { children: [
6491
+ /* @__PURE__ */ jsx14("rect", { x: "3", y: "3.5", width: "14", height: "13", rx: "1.5" }),
6492
+ /* @__PURE__ */ jsx14("path", { d: "M3 8h14M8 8v8.5M13 8v8.5" })
4713
6493
  ] }) }),
4714
- /* @__PURE__ */ jsx13(ToolbarButton, { label: "Insert drawing", onClick: insertDrawing, children: /* @__PURE__ */ jsxs10(Icon2, { children: [
4715
- /* @__PURE__ */ jsx13("rect", { x: "3", y: "5", width: "8", height: "6", rx: "1.5" }),
4716
- /* @__PURE__ */ jsx13("path", { d: "M13.5 8h3M14.5 6.5L17.5 8l-3 1.5" }),
4717
- /* @__PURE__ */ jsx13("ellipse", { cx: "13", cy: "14.5", rx: "4", ry: "2.8" })
6494
+ /* @__PURE__ */ jsx14(ToolbarButton, { label: "Insert drawing", onClick: insertDrawing, children: /* @__PURE__ */ jsxs11(Icon2, { children: [
6495
+ /* @__PURE__ */ jsx14("rect", { x: "3", y: "5", width: "8", height: "6", rx: "1.5" }),
6496
+ /* @__PURE__ */ jsx14("path", { d: "M13.5 8h3M14.5 6.5L17.5 8l-3 1.5" }),
6497
+ /* @__PURE__ */ jsx14("ellipse", { cx: "13", cy: "14.5", rx: "4", ry: "2.8" })
4718
6498
  ] }) })
4719
6499
  ] });
4720
6500
  }
4721
6501
  function HistoryButtons() {
4722
6502
  const { canUndo, canRedo, undo, redo } = useMarkdownEditor();
4723
- return /* @__PURE__ */ jsxs10(Fragment4, { children: [
4724
- /* @__PURE__ */ jsx13(ToolbarButton, { label: "Undo", onClick: undo, disabled: !canUndo, children: /* @__PURE__ */ jsxs10(Icon2, { children: [
4725
- /* @__PURE__ */ jsx13("path", { d: "M7 6L3.5 9.5 7 13" }),
4726
- /* @__PURE__ */ jsx13("path", { d: "M3.5 9.5H12a4 4 0 0 1 0 8h-1" })
6503
+ return /* @__PURE__ */ jsxs11(Fragment5, { children: [
6504
+ /* @__PURE__ */ jsx14(ToolbarButton, { label: "Undo", onClick: undo, disabled: !canUndo, children: /* @__PURE__ */ jsxs11(Icon2, { children: [
6505
+ /* @__PURE__ */ jsx14("path", { d: "M7 6L3.5 9.5 7 13" }),
6506
+ /* @__PURE__ */ jsx14("path", { d: "M3.5 9.5H12a4 4 0 0 1 0 8h-1" })
4727
6507
  ] }) }),
4728
- /* @__PURE__ */ jsx13(ToolbarButton, { label: "Redo", onClick: redo, disabled: !canRedo, children: /* @__PURE__ */ jsxs10(Icon2, { children: [
4729
- /* @__PURE__ */ jsx13("path", { d: "M13 6l3.5 3.5L13 13" }),
4730
- /* @__PURE__ */ jsx13("path", { d: "M16.5 9.5H8a4 4 0 0 0 0 8h1" })
6508
+ /* @__PURE__ */ jsx14(ToolbarButton, { label: "Redo", onClick: redo, disabled: !canRedo, children: /* @__PURE__ */ jsxs11(Icon2, { children: [
6509
+ /* @__PURE__ */ jsx14("path", { d: "M13 6l3.5 3.5L13 13" }),
6510
+ /* @__PURE__ */ jsx14("path", { d: "M16.5 9.5H8a4 4 0 0 0 0 8h1" })
4731
6511
  ] }) })
4732
6512
  ] });
4733
6513
  }
4734
6514
 
4735
6515
  // src/plugins/TableSettingsPlugin.tsx
4736
- import { jsx as jsx14 } from "react/jsx-runtime";
6516
+ import { jsx as jsx15 } from "react/jsx-runtime";
4737
6517
  function Icon3({ children }) {
4738
- return /* @__PURE__ */ jsx14(
6518
+ return /* @__PURE__ */ jsx15(
4739
6519
  "svg",
4740
6520
  {
4741
6521
  viewBox: "0 0 20 20",
@@ -4796,20 +6576,20 @@ function TableSettingsPlugin() {
4796
6576
  [editor]
4797
6577
  );
4798
6578
  if (!isEditable || !anchor || !settings) return null;
4799
- return /* @__PURE__ */ jsx14(
6579
+ return /* @__PURE__ */ jsx15(
4800
6580
  "div",
4801
6581
  {
4802
6582
  className: "zui-table-settings",
4803
6583
  role: "toolbar",
4804
6584
  "aria-label": "Table settings",
4805
6585
  style: { top: anchor.top, right: anchor.right },
4806
- children: LAYOUT_OPTIONS.map(({ preset, label, icon, width, density }) => /* @__PURE__ */ jsx14(
6586
+ children: LAYOUT_OPTIONS.map(({ preset, label, icon, width, density }) => /* @__PURE__ */ jsx15(
4807
6587
  ToolbarButton,
4808
6588
  {
4809
6589
  label,
4810
6590
  active: layoutPreset(settings.width) === preset,
4811
6591
  onClick: () => update({ width, density }),
4812
- children: /* @__PURE__ */ jsx14(Icon3, { children: icon })
6592
+ children: /* @__PURE__ */ jsx15(Icon3, { children: icon })
4813
6593
  },
4814
6594
  preset
4815
6595
  ))
@@ -4818,7 +6598,7 @@ function TableSettingsPlugin() {
4818
6598
  }
4819
6599
 
4820
6600
  // src/EditorContent.tsx
4821
- import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
6601
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
4822
6602
  function EditorContent({
4823
6603
  placeholder = "Start writing...",
4824
6604
  foldable = true,
@@ -4826,7 +6606,7 @@ function EditorContent({
4826
6606
  }) {
4827
6607
  const { mode, readOnly, autoFocus, rawValue, onRawChange } = useEditorContext();
4828
6608
  if (mode === "edit-raw") {
4829
- return /* @__PURE__ */ jsx15(
6609
+ return /* @__PURE__ */ jsx16(
4830
6610
  "textarea",
4831
6611
  {
4832
6612
  className: "zui-text-editor-textarea",
@@ -4839,24 +6619,24 @@ function EditorContent({
4839
6619
  }
4840
6620
  );
4841
6621
  }
4842
- return /* @__PURE__ */ jsxs11("div", { className: "zui-text-editor-body", children: [
4843
- /* @__PURE__ */ jsxs11("div", { className: "zui-text-editor-main", children: [
4844
- /* @__PURE__ */ jsx15(
6622
+ return /* @__PURE__ */ jsxs12("div", { className: "zui-text-editor-body", children: [
6623
+ /* @__PURE__ */ jsxs12("div", { className: "zui-text-editor-main", children: [
6624
+ /* @__PURE__ */ jsx16(
4845
6625
  RichTextPlugin,
4846
6626
  {
4847
- contentEditable: /* @__PURE__ */ jsx15(
6627
+ contentEditable: /* @__PURE__ */ jsx16(
4848
6628
  ContentEditable,
4849
6629
  {
4850
6630
  className: "zui-text-editor-content",
4851
6631
  "aria-placeholder": placeholder,
4852
- placeholder: /* @__PURE__ */ jsx15("div", { className: "zui-text-editor-placeholder", children: placeholder })
6632
+ placeholder: /* @__PURE__ */ jsx16("div", { className: "zui-text-editor-placeholder", children: placeholder })
4853
6633
  }
4854
6634
  ),
4855
6635
  ErrorBoundary: LexicalErrorBoundary
4856
6636
  }
4857
6637
  ),
4858
- foldable && /* @__PURE__ */ jsx15(FoldingPlugin, {}),
4859
- /* @__PURE__ */ jsx15(TableSettingsPlugin, {})
6638
+ foldable && /* @__PURE__ */ jsx16(FoldingPlugin, {}),
6639
+ /* @__PURE__ */ jsx16(TableSettingsPlugin, {})
4860
6640
  ] }),
4861
6641
  children
4862
6642
  ] });
@@ -4868,7 +6648,7 @@ import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexic
4868
6648
  import {
4869
6649
  TableOfContentsPlugin
4870
6650
  } from "@lexical/react/LexicalTableOfContentsPlugin";
4871
- import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
6651
+ import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
4872
6652
  var INDENT_PER_LEVEL = {
4873
6653
  h1: 0,
4874
6654
  h2: 1,
@@ -4920,16 +6700,16 @@ function OutlinePlugin() {
4920
6700
  },
4921
6701
  [editor]
4922
6702
  );
4923
- return /* @__PURE__ */ jsx16(TableOfContentsPlugin, { children: (entries) => {
6703
+ return /* @__PURE__ */ jsx17(TableOfContentsPlugin, { children: (entries) => {
4924
6704
  for (const [key] of entries) {
4925
6705
  editor.getElementByKey(key)?.setAttribute("data-outline-key", key);
4926
6706
  }
4927
- return /* @__PURE__ */ jsxs12(
6707
+ return /* @__PURE__ */ jsxs13(
4928
6708
  "div",
4929
6709
  {
4930
6710
  className: `zui-text-editor-outline ${collapsed ? "is-collapsed" : ""}`,
4931
6711
  children: [
4932
- /* @__PURE__ */ jsx16(
6712
+ /* @__PURE__ */ jsx17(
4933
6713
  "button",
4934
6714
  {
4935
6715
  type: "button",
@@ -4937,8 +6717,8 @@ function OutlinePlugin() {
4937
6717
  title: collapsed ? "Show outline" : "Hide outline",
4938
6718
  "aria-label": collapsed ? "Show outline" : "Hide outline",
4939
6719
  "aria-expanded": !collapsed,
4940
- onClick: () => setCollapsed((c) => !c),
4941
- children: /* @__PURE__ */ jsx16(
6720
+ onClick: () => setCollapsed((c2) => !c2),
6721
+ children: /* @__PURE__ */ jsx17(
4942
6722
  "svg",
4943
6723
  {
4944
6724
  viewBox: "0 0 20 20",
@@ -4948,14 +6728,14 @@ function OutlinePlugin() {
4948
6728
  stroke: "currentColor",
4949
6729
  strokeWidth: "1.8",
4950
6730
  strokeLinecap: "round",
4951
- children: /* @__PURE__ */ jsx16("path", { d: "M4 5h12M4 10h8M4 15h10" })
6731
+ children: /* @__PURE__ */ jsx17("path", { d: "M4 5h12M4 10h8M4 15h10" })
4952
6732
  }
4953
6733
  )
4954
6734
  }
4955
6735
  ),
4956
- !collapsed && /* @__PURE__ */ jsxs12("nav", { className: "zui-text-editor-outline-list", "aria-label": "Table of contents", children: [
4957
- entries.length === 0 && /* @__PURE__ */ jsx16("div", { className: "zui-text-editor-outline-empty", children: "No headings" }),
4958
- entries.map(([key, text, tag]) => /* @__PURE__ */ jsx16(
6736
+ !collapsed && /* @__PURE__ */ jsxs13("nav", { className: "zui-text-editor-outline-list", "aria-label": "Table of contents", children: [
6737
+ entries.length === 0 && /* @__PURE__ */ jsx17("div", { className: "zui-text-editor-outline-empty", children: "No headings" }),
6738
+ entries.map(([key, text, tag]) => /* @__PURE__ */ jsx17(
4959
6739
  "button",
4960
6740
  {
4961
6741
  type: "button",
@@ -4976,11 +6756,11 @@ function OutlinePlugin() {
4976
6756
  }
4977
6757
 
4978
6758
  // src/MarkdownEditor.tsx
4979
- import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
6759
+ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
4980
6760
  var DEFAULT_ITEMS = {
4981
- format: /* @__PURE__ */ jsx17(FormatButtons, {}),
4982
- insert: /* @__PURE__ */ jsx17(InsertButtons, {}),
4983
- history: /* @__PURE__ */ jsx17(HistoryButtons, {})
6761
+ format: /* @__PURE__ */ jsx18(FormatButtons, {}),
6762
+ insert: /* @__PURE__ */ jsx18(InsertButtons, {}),
6763
+ history: /* @__PURE__ */ jsx18(HistoryButtons, {})
4984
6764
  };
4985
6765
  function EditorToolbar({
4986
6766
  children,
@@ -4988,7 +6768,7 @@ function EditorToolbar({
4988
6768
  }) {
4989
6769
  const { mode, readOnly } = useEditorContext();
4990
6770
  if (mode !== "edit-md" || readOnly) return null;
4991
- return /* @__PURE__ */ jsx17(Toolbar, { className, children });
6771
+ return /* @__PURE__ */ jsx18(Toolbar, { className, children });
4992
6772
  }
4993
6773
  function MarkdownEditor({
4994
6774
  placeholder,
@@ -4997,10 +6777,10 @@ function MarkdownEditor({
4997
6777
  foldable = true,
4998
6778
  ...rootProps
4999
6779
  }) {
5000
- return /* @__PURE__ */ jsxs13(EditorRoot, { ...rootProps, children: [
5001
- toolbar === true && /* @__PURE__ */ jsx17(EditorToolbar, {}),
6780
+ return /* @__PURE__ */ jsxs14(EditorRoot, { ...rootProps, children: [
6781
+ toolbar === true && /* @__PURE__ */ jsx18(EditorToolbar, {}),
5002
6782
  typeof toolbar === "function" && toolbar(DEFAULT_ITEMS),
5003
- /* @__PURE__ */ jsx17(EditorContent, { placeholder, foldable, children: outline && /* @__PURE__ */ jsx17(OutlinePlugin, {}) })
6783
+ /* @__PURE__ */ jsx18(EditorContent, { placeholder, foldable, children: outline && /* @__PURE__ */ jsx18(OutlinePlugin, {}) })
5004
6784
  ] });
5005
6785
  }
5006
6786
  MarkdownEditor.Root = EditorRoot;
@@ -5187,6 +6967,9 @@ export {
5187
6967
  BLOCK_WIDTHS,
5188
6968
  BOX_DEFINITIONS,
5189
6969
  BOX_TYPES,
6970
+ BUILTIN_CODE_LANGUAGES,
6971
+ CODE_BLOCK,
6972
+ CODE_TOKEN_TYPES,
5190
6973
  COLOR_PRESETS,
5191
6974
  CONNECTOR_TYPES,
5192
6975
  DEFAULT_TABLE_SETTINGS,
@@ -5203,6 +6986,7 @@ export {
5203
6986
  HistoryButtons,
5204
6987
  InsertButtons,
5205
6988
  MarkdownEditor_default as MarkdownEditor,
6989
+ PLAIN_LANGUAGE,
5206
6990
  SHAPE_TYPES,
5207
6991
  SIDE_FIXED_POINTS,
5208
6992
  STROKE_COLORS,
@@ -5214,12 +6998,18 @@ export {
5214
6998
  anchorPoint,
5215
6999
  bindEndpoints,
5216
7000
  boxOutline,
7001
+ codeTokenizer,
5217
7002
  connectorPoints,
5218
7003
  drawingToMermaid,
5219
7004
  expandSkeleton,
5220
7005
  findBoxAt,
5221
7006
  fixedPointFor,
5222
7007
  formatTableSettingsMarker,
7008
+ getCodeLanguages,
7009
+ hasCodeLanguage,
7010
+ inkAmplitude,
7011
+ inkFillOffset,
7012
+ inkStroke,
5223
7013
  isBlockWidth,
5224
7014
  isDrawingSkeleton,
5225
7015
  makeBinding,
@@ -5227,8 +7017,15 @@ export {
5227
7017
  parseDrawingData,
5228
7018
  parseDrawingSkeleton,
5229
7019
  parseTableSettingsMarker,
7020
+ registerCodeBlockHighlighting,
7021
+ registerCodeLanguage,
5230
7022
  resolveBindings,
7023
+ resolveCodeLanguage,
7024
+ roundedPolyline,
7025
+ roundedRectPolygon,
5231
7026
  routeElbow,
7027
+ seedFrom,
5232
7028
  serializeDrawingData,
7029
+ tokenizeCode,
5233
7030
  useMarkdownEditor
5234
7031
  };