Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kit/scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
48 changes: 26 additions & 22 deletions kit/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)" },
Expand All @@ -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)",
Expand All @@ -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 },
);
Expand All @@ -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({
Expand Down
Loading