root: move webapp to /web (#347)
* root: move webapp to /web * root: fix static build * root: fix static files not being served for e2e tests
This commit is contained in:
40
web/src/elements/CodeMirror.ts
Normal file
40
web/src/elements/CodeMirror.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { customElement, html, LitElement, property } from "lit-element";
|
||||
|
||||
// @ts-ignore
|
||||
import CodeMirror from "codemirror";
|
||||
import "codemirror/addon/display/autorefresh";
|
||||
import "codemirror/mode/xml/xml.js";
|
||||
import "codemirror/mode/yaml/yaml.js";
|
||||
import "codemirror/mode/python/python.js";
|
||||
|
||||
@customElement("pb-codemirror")
|
||||
export class CodeMirrorTextarea extends LitElement {
|
||||
@property()
|
||||
readOnly: boolean = false;
|
||||
|
||||
@property()
|
||||
mode: string = "yaml";
|
||||
|
||||
editor?: CodeMirror.EditorFromTextArea;
|
||||
|
||||
createRenderRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
firstUpdated() {
|
||||
const textarea = this.querySelector("textarea");
|
||||
if (!textarea) {
|
||||
return;
|
||||
}
|
||||
this.editor = CodeMirror.fromTextArea(textarea, {
|
||||
mode: this.mode,
|
||||
theme: "monokai",
|
||||
lineNumbers: false,
|
||||
readOnly: this.readOnly,
|
||||
autoRefresh: true,
|
||||
});
|
||||
this.editor.on("blur", (e) => {
|
||||
this.editor?.save();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user