Skip to main content

code

The code control provides a code editor powered by CodeMirror.

Usage

Modular:

import { code } from "/42/ui/control/code.js"

const myCode = code({
lang: "javascript",
theme: "monokai",
src: "/path/to/file.js",
action(e, el) {
console.log(el.value)
},
})

Plan:

{
tag: "ui-code",
lang: "javascript",
theme: "monokai",
src: "/path/to/file.js",
action(e, el) {
console.log(el.value)
},
}

Properties

PropertyTypeDescription
langStringLanguage
themeStringEditor theme
srcStringFile path to load
srcdocStringInline content to load
singleLineBooleanSingle-line mode
modeStringEditor mode

Methods

  • getValue() - returns the current editor content
  • setValue(text) - sets the editor content