CodeEditor
AppEngine-agnostic code editor primitive on a textarea engine (line-number gutter, active line, theme, readonly, placeholder). M2: Tab / Shift+Tab indent (Esc then Tab leaves), Ctrl/Cmd+/ comment toggle, auto-indent, bracket and quote pairs, a toolbar (find / replace, format, copy, full screen), format-on-save. M3: diagnostics (markers in the gutter, tinted lines, a list that jumps to the spot), completion (getSuggestions, a listbox) and hover (getHover). Later: Monaco lazy engine, multi-cursor, minimap, folding, vim/emacs keymap. EJS sibling at modules/ui/CodeEditor/CodeEditor.ejs (kui-ejs) at parity: the M2 editing aids and the M3 diagnostics, completion and hover; on the server the `format` / `getSuggestions` / `getHover` options name global functions, in the browser `KuiCodeEditor.attach(root, opts)` takes functions. Used by the RulesetEditor code fields (the automation script with completion, hover and checks).
Type msg. or press Ctrl+Space for suggestions; Ctrl+/ comments a line; Ctrl+F finds.
<CodeEditor id="script" language="js" value={code} onChange={setCode} showToolbar
markers={markers} format={tidy} getSuggestions={() => names} getHover={({ word }) => help(word)} />Read-only JavaScript snippet with line numbers.
<CodeEditor
id="example"
label="example.js"
language="js"
theme="light"
value={source}
readonly
showLineNumbers
/>Editable markdown. The hidden form input is synced to the value.
const [src, setSrc] = useState('# Hello');
<CodeEditor
id="readme"
name="readme"
label="README.md"
language="markdown"
theme="dark"
value={src}
onChange={setSrc}
placeholder="Start typing markdown…"
/>