From b4ba1bc63a17bb96d30c4d926eaa01f2f082e696 Mon Sep 17 00:00:00 2001 From: Kitteh Date: Wed, 26 May 2021 10:13:38 +0100 Subject: [PATCH] Rename CodeJarEditor to CodeEditor. --- .../{CodeJar/CodeJarEditor.tsx => CodeEditor.tsx} | 14 ++++++++------ src/pages/Secrets/KeyValue/KeyValueSecretsEdit.tsx | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) rename src/elements/{CodeJar/CodeJarEditor.tsx => CodeEditor.tsx} (71%) diff --git a/src/elements/CodeJar/CodeJarEditor.tsx b/src/elements/CodeEditor.tsx similarity index 71% rename from src/elements/CodeJar/CodeJarEditor.tsx rename to src/elements/CodeEditor.tsx index a24474a..7f11b0e 100644 --- a/src/elements/CodeJar/CodeJarEditor.tsx +++ b/src/elements/CodeEditor.tsx @@ -2,23 +2,23 @@ import { Component, JSX, createRef } from "preact"; import { CodeJar as _CodeJar } from "codejar"; import { highlightElement } from "prismjs"; -interface CodeJarProps { +interface CodeEditorProps { language: string; tabSize: number; code: string; onUpdate: (code: string) => void; } -export class CodeJarEditor extends Component { +export class CodeEditor extends Component { editorRef = createRef(); jar = createRef<_CodeJar | null>(); - highlighter(e: HTMLElement, pos?: unknown): void { + highlighter(e: HTMLElement): void { highlightElement(e); } componentDidMount(): void { - this.jar.current = _CodeJar(this.editorRef.current, this.highlighter, { + this.jar.current = _CodeJar(this.editorRef.current, (e) => this.highlighter(e), { tab: " ".repeat(this.props.tabSize), window: window, }); @@ -36,7 +36,7 @@ export class CodeJarEditor extends Component { } } - componentDidUpdate(prevProps: CodeJarProps): void { + componentDidUpdate(prevProps: CodeEditorProps): void { if (!this.jar.current) return; if ( @@ -49,6 +49,8 @@ export class CodeJarEditor extends Component { } render(): JSX.Element { - return
; + return ( +
+ ); } } diff --git a/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.tsx b/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.tsx index be0f18f..984a6eb 100644 --- a/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.tsx +++ b/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.tsx @@ -1,4 +1,4 @@ -import { CodeJarEditor } from "../../../elements/CodeJar/CodeJarEditor"; +import { CodeEditor } from "../../../elements/CodeEditor"; import { Component, JSX, render } from "preact"; import { Page } from "../../../types/Page"; import { SecretTitleElement } from "../SecretTitleElement"; @@ -90,7 +90,7 @@ export class KVEditor extends Component { return (

-