@latentic/live-markdown 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0] - 2026-08-28
4
+
5
+ ### Added
6
+
7
+ - **A host can theme fenced-code syntax colours.** Each palette entry carries a
8
+ CSS custom property alongside its colour, and the editor paints
9
+ `var(--md-code-…, <One Light value>)`, so a dark theme can restyle code.
10
+ Previously impossible: the editor takes no `extensions` prop and the generated
11
+ highlight classes are content-hashed, leaving no seam at all.
12
+
13
+ The clipboard renderer deliberately keeps literal colours. Pasted HTML arrives
14
+ with no stylesheet, so a `var()` there resolves to nothing and pastes
15
+ colourless code into Google Docs or Word — and the document being pasted into
16
+ is white whatever theme the editor was in.
17
+
18
+ Roles are named individually (`--md-code-keyword`, `--md-code-string`, …) even
19
+ where two share a value, so one can be restyled without the other. A host that
20
+ sets no variables gets a byte-identical palette: the literal is the fallback.
21
+
3
22
  ## [0.1.1] - 2026-08-24
4
23
 
5
24
  ### Added
package/dist/index.js CHANGED
@@ -443,23 +443,59 @@ function onEditorUpdate(view, fn) {
443
443
  };
444
444
  }
445
445
  var CODE_PALETTE = [
446
- { tag: [tags.keyword, tags.modifier, tags.operatorKeyword], color: "#a626a4" },
447
- { tag: [tags.string, tags.special(tags.string)], color: "#50a14f" },
448
- { tag: tags.comment, color: "#a0a1a7", fontStyle: "italic" },
449
- { tag: [tags.number, tags.bool, tags.null, tags.atom], color: "#986801" },
450
- { tag: [tags.function(tags.variableName), tags.function(tags.propertyName)], color: "#4078f2" },
451
- { tag: [tags.typeName, tags.className, tags.namespace], color: "#c18401" },
452
- { tag: tags.definition(tags.variableName), color: "#e45649" },
453
- { tag: tags.propertyName, color: "#4078f2" },
454
- { tag: [tags.tagName, tags.self], color: "#e45649" },
455
- { tag: tags.attributeName, color: "#986801" },
456
- { tag: [tags.regexp, tags.escape], color: "#0184bc" },
457
- { tag: tags.invalid, color: "#ca1243" }
446
+ {
447
+ tag: [tags.keyword, tags.modifier, tags.operatorKeyword],
448
+ color: "#a626a4",
449
+ cssVar: "--md-code-keyword"
450
+ },
451
+ {
452
+ tag: [tags.string, tags.special(tags.string)],
453
+ color: "#50a14f",
454
+ cssVar: "--md-code-string"
455
+ },
456
+ {
457
+ tag: tags.comment,
458
+ color: "#a0a1a7",
459
+ cssVar: "--md-code-comment",
460
+ fontStyle: "italic"
461
+ },
462
+ {
463
+ tag: [tags.number, tags.bool, tags.null, tags.atom],
464
+ color: "#986801",
465
+ cssVar: "--md-code-literal"
466
+ },
467
+ {
468
+ tag: [tags.function(tags.variableName), tags.function(tags.propertyName)],
469
+ color: "#4078f2",
470
+ cssVar: "--md-code-function"
471
+ },
472
+ {
473
+ tag: [tags.typeName, tags.className, tags.namespace],
474
+ color: "#c18401",
475
+ cssVar: "--md-code-type"
476
+ },
477
+ {
478
+ tag: tags.definition(tags.variableName),
479
+ color: "#e45649",
480
+ cssVar: "--md-code-variable"
481
+ },
482
+ { tag: tags.propertyName, color: "#4078f2", cssVar: "--md-code-property" },
483
+ { tag: [tags.tagName, tags.self], color: "#e45649", cssVar: "--md-code-tag" },
484
+ { tag: tags.attributeName, color: "#986801", cssVar: "--md-code-attribute" },
485
+ { tag: [tags.regexp, tags.escape], color: "#0184bc", cssVar: "--md-code-regexp" },
486
+ { tag: tags.invalid, color: "#ca1243", cssVar: "--md-code-invalid" }
458
487
  ];
488
+ function themedColor(spec) {
489
+ return `var(${spec.cssVar}, ${spec.color})`;
490
+ }
459
491
 
460
492
  // src/codemirror/code/codeHighlight.ts
461
493
  var style = HighlightStyle.define(
462
- CODE_PALETTE.map((spec) => ({ tag: spec.tag, color: spec.color, fontStyle: spec.fontStyle }))
494
+ CODE_PALETTE.map((spec) => ({
495
+ tag: spec.tag,
496
+ color: themedColor(spec),
497
+ fontStyle: spec.fontStyle
498
+ }))
463
499
  );
464
500
  var codeHighlight = syntaxHighlighting(style);
465
501