From 3d2f9640a248546ec9ff40392666baac93d2e5a2 Mon Sep 17 00:00:00 2001 From: Kinflou <149606337+Kinflou@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:46:03 +0800 Subject: [PATCH 1/2] kit: keep the editor WASM in the packed kit wasm-pack writes a .gitignore of * into pkg-editor/, and yarn pack honours it, so a consumer installing the kit by git got it without the editor WASM. prepare.sh now removes that file after building (and when it skips an existing build). --- kit/scripts/prepare.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kit/scripts/prepare.sh b/kit/scripts/prepare.sh index a745bcc..3830329 100755 --- a/kit/scripts/prepare.sh +++ b/kit/scripts/prepare.sh @@ -16,8 +16,11 @@ if [ "${COMLINE_KIT_EDITOR:-1}" = "0" ]; then exit 0 fi +# wasm-pack writes a `.gitignore` of `*` into its output, and `yarn pack` +# honours it, which would leave the built editor out of the package. if [ -f pkg-editor/comline_playground_wasm.js ] && [ pkg-editor/comline_playground_wasm.js -nt ../wasm/Cargo.toml ]; then echo "comline-web-kit: pkg-editor/ is already built, skipping" >&2 + rm -f pkg-editor/.gitignore exit 0 fi @@ -32,3 +35,4 @@ done rustup target add wasm32-unknown-unknown >/dev/null 2>&1 || true wasm-pack build ../wasm --release --target web --out-dir ../kit/pkg-editor --out-name comline_playground_wasm +rm -f pkg-editor/.gitignore From 2e058f14451ec96da0d72ab462abd89697773132 Mon Sep 17 00:00:00 2001 From: Kinflou <149606337+Kinflou@users.noreply.github.com> Date: Sun, 15 Nov 2026 00:12:10 +0800 Subject: [PATCH 2/2] kit: the editor's syntax colours come from custom properties The token colours, the active line and the selection read --cl-tok-*, --cl-active-line and --cl-selection, defaulting to the playground's current colours, so a page can restyle the editor (a light theme included). The playground looks the same. --- kit/src/editor/editor.ts | 48 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/kit/src/editor/editor.ts b/kit/src/editor/editor.ts index 713822d..478e37f 100644 --- a/kit/src/editor/editor.ts +++ b/kit/src/editor/editor.ts @@ -304,6 +304,10 @@ function hoverInfo(ctx: EditorContext) { } // ── theme ───────────────────────────────────────────────────────────────── +// Colours come from the page's custom properties: --bg, --bg-2, --fg, --muted +// and --border for the chrome, and --cl-tok-* (with these defaults, the +// playground's) for the syntax, so a page can restyle the editor, a light +// theme included. const theme = EditorView.theme( { "&": { height: "100%", fontSize: "0.85rem", backgroundColor: "var(--bg)", color: "var(--fg)" }, @@ -312,9 +316,9 @@ const theme = EditorView.theme( lineHeight: "1.55", }, ".cm-gutters": { backgroundColor: "var(--bg)", color: "var(--muted)", border: "none" }, - ".cm-activeLine": { backgroundColor: "#ffffff08" }, - ".cm-activeLineGutter": { backgroundColor: "#ffffff08" }, - ".cm-selectionBackground, &.cm-focused .cm-selectionBackground": { backgroundColor: "#3d59a1" }, + ".cm-activeLine": { backgroundColor: "var(--cl-active-line, #ffffff08)" }, + ".cm-activeLineGutter": { backgroundColor: "var(--cl-active-line, #ffffff08)" }, + ".cm-selectionBackground, &.cm-focused .cm-selectionBackground": { backgroundColor: "var(--cl-selection, #3d59a1)" }, ".cm-cursor": { borderLeftColor: "var(--fg)" }, ".cm-tooltip": { backgroundColor: "var(--bg-2)", @@ -339,13 +343,13 @@ const theme = EditorView.theme( fontStyle: "italic", fontSize: "0.85em", }, - ".cm-tok-kw": { color: "#bb9af7" }, - ".cm-tok-type": { color: "#7dcfff" }, - ".cm-tok-str": { color: "#9ece6a" }, - ".cm-tok-comment": { color: "#565f89", fontStyle: "italic" }, - ".cm-tok-ann": { color: "#e0af68" }, - ".cm-tok-num": { color: "#ff9e64" }, - ".cm-tok-var": { color: "#73daca" }, + ".cm-tok-kw": { color: "var(--cl-tok-kw, #bb9af7)" }, + ".cm-tok-type": { color: "var(--cl-tok-type, #7dcfff)" }, + ".cm-tok-str": { color: "var(--cl-tok-str, #9ece6a)" }, + ".cm-tok-comment": { color: "var(--cl-tok-comment, #565f89)", fontStyle: "italic" }, + ".cm-tok-ann": { color: "var(--cl-tok-ann, #e0af68)" }, + ".cm-tok-num": { color: "var(--cl-tok-num, #ff9e64)" }, + ".cm-tok-var": { color: "var(--cl-tok-var, #73daca)" }, }, { dark: true }, ); @@ -354,18 +358,18 @@ const theme = EditorView.theme( // One grammar-agnostic highlight style (Lezer tags → the schema editor's // palette), shared by every generated language. const generatedHighlightStyle = HighlightStyle.define([ - { tag: [t.keyword, t.modifier, t.definitionKeyword, t.moduleKeyword, t.controlKeyword, t.operatorKeyword], color: "#bb9af7" }, - { tag: [t.string, t.special(t.string), t.regexp], color: "#9ece6a" }, - { tag: [t.comment], color: "#565f89", fontStyle: "italic" }, - { tag: [t.number, t.bool, t.null, t.atom], color: "#ff9e64" }, - { tag: [t.typeName, t.className, t.namespace], color: "#7dcfff" }, - { tag: [t.propertyName, t.attributeName], color: "#7aa2f7" }, - { tag: [t.function(t.variableName), t.function(t.propertyName), t.macroName], color: "#7aa2f7" }, - { tag: [t.operator, t.punctuation, t.bracket, t.separator, t.derefOperator], color: "#9aa5ce" }, - { tag: [t.meta], color: "#e0af68" }, - { tag: [t.self], color: "#f7768e" }, - { tag: [t.variableName], color: "#e4e4ef" }, - { tag: [t.invalid], color: "#f7768e" }, + { tag: [t.keyword, t.modifier, t.definitionKeyword, t.moduleKeyword, t.controlKeyword, t.operatorKeyword], color: "var(--cl-tok-kw, #bb9af7)" }, + { tag: [t.string, t.special(t.string), t.regexp], color: "var(--cl-tok-str, #9ece6a)" }, + { tag: [t.comment], color: "var(--cl-tok-comment, #565f89)", fontStyle: "italic" }, + { tag: [t.number, t.bool, t.null, t.atom], color: "var(--cl-tok-num, #ff9e64)" }, + { tag: [t.typeName, t.className, t.namespace], color: "var(--cl-tok-type, #7dcfff)" }, + { tag: [t.propertyName, t.attributeName], color: "var(--cl-tok-fn, #7aa2f7)" }, + { tag: [t.function(t.variableName), t.function(t.propertyName), t.macroName], color: "var(--cl-tok-fn, #7aa2f7)" }, + { tag: [t.operator, t.punctuation, t.bracket, t.separator, t.derefOperator], color: "var(--cl-tok-op, #9aa5ce)" }, + { tag: [t.meta], color: "var(--cl-tok-ann, #e0af68)" }, + { tag: [t.self], color: "var(--cl-tok-self, #f7768e)" }, + { tag: [t.variableName], color: "var(--fg)" }, + { tag: [t.invalid], color: "var(--cl-tok-self, #f7768e)" }, ]); const readOnlyTheme = EditorView.theme({