diff --git a/docs/public/editor/editor.js b/docs/public/editor/editor.js index ebed2712909..f2dff90fb95 100644 --- a/docs/public/editor/editor.js +++ b/docs/public/editor/editor.js @@ -2,15 +2,8 @@ // gh-aw Playground - Application Logic // ================================================================ -import { EditorView, basicSetup } from 'https://esm.sh/codemirror@6.0.2'; -import { EditorState, Compartment } from 'https://esm.sh/@codemirror/state@6.5.4'; -import { keymap } from 'https://esm.sh/@codemirror/view@6.39.14'; -import { yaml } from 'https://esm.sh/@codemirror/lang-yaml@6.1.2'; -import { markdown } from 'https://esm.sh/@codemirror/lang-markdown@6.5.0'; -import { indentUnit } from 'https://esm.sh/@codemirror/language@6.12.1'; -import { oneDark } from 'https://esm.sh/@codemirror/theme-one-dark@6.1.3'; import { createWorkerCompiler } from '/gh-aw/wasm/compiler-loader.js'; -import { frontmatterHoverTooltip } from './hover-tooltips.js'; +import { attachHoverTooltips } from './hover-tooltips.js'; // --------------------------------------------------------------- // Sample workflow registry @@ -59,9 +52,10 @@ function setHashQuietly(value) { const $ = (id) => document.getElementById(id); const sampleSelect = $('sampleSelect'); -const editorMount = $('editorMount'); +const editorTextarea = $('editorTextarea'); const outputPlaceholder = $('outputPlaceholder'); -const outputMount = $('outputMount'); +const outputCode = $('outputCode'); +const outputPre = $('outputPre'); const statusBadge = $('statusBadge'); const statusText = $('statusText'); const statusDot = $('statusDot'); @@ -88,94 +82,79 @@ let pendingCompile = false; let isDragging = false; // --------------------------------------------------------------- -// Theme — follows browser's prefers-color-scheme automatically. -// Primer CSS handles the page via data-color-mode="auto". -// We only need to toggle the CodeMirror theme (oneDark vs default). -// --------------------------------------------------------------- -const editorThemeConfig = new Compartment(); -const outputThemeConfig = new Compartment(); -const darkMq = window.matchMedia('(prefers-color-scheme: dark)'); - -function isDark() { - return darkMq.matches; -} - -function cmThemeFor(dark) { - return dark ? oneDark : []; -} - -function applyCmTheme() { - const theme = cmThemeFor(isDark()); - editorView.dispatch({ effects: editorThemeConfig.reconfigure(theme) }); - outputView.dispatch({ effects: outputThemeConfig.reconfigure(theme) }); -} - -// --------------------------------------------------------------- -// CodeMirror: Input Editor (Markdown with YAML frontmatter) +// Input Editor (
@@ -259,7 +273,7 @@
Compiled YAML will appear here
- +