2024-08-10 23:13:20 +02:00
|
|
|
const defaultBrush = `
|
|
|
|
; This is your brush.
|
|
|
|
; Feel free to edit it to your liking!
|
|
|
|
(stroke
|
|
|
|
8 ; thickness
|
|
|
|
(rgba 0.0 0.0 0.0 1.0) ; color
|
|
|
|
(vec)) ; position
|
|
|
|
`.trim();
|
|
|
|
|
|
|
|
export class BrushEditor extends HTMLElement {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
connectedCallback() {
|
|
|
|
this.classList.add("rkgk-panel");
|
|
|
|
|
|
|
|
this.textArea = this.appendChild(document.createElement("pre"));
|
|
|
|
this.textArea.classList.add("text-area");
|
2024-08-17 22:16:31 +02:00
|
|
|
this.textArea.textContent = localStorage.getItem("rkgk.brushEditor.code") ?? defaultBrush;
|
2024-08-10 23:13:20 +02:00
|
|
|
this.textArea.contentEditable = true;
|
|
|
|
this.textArea.spellcheck = false;
|
|
|
|
this.textArea.addEventListener("input", () => {
|
2024-08-17 22:16:31 +02:00
|
|
|
localStorage.setItem("rkgk.brushEditor.code", this.code);
|
2024-08-10 23:13:20 +02:00
|
|
|
this.dispatchEvent(
|
|
|
|
Object.assign(new Event(".codeChanged"), {
|
2024-08-17 22:16:31 +02:00
|
|
|
newCode: this.code,
|
2024-08-10 23:13:20 +02:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get code() {
|
|
|
|
return this.textArea.textContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define("rkgk-brush-editor", BrushEditor);
|