1
0
Fork 0

Add working code highlighting to CodeJarEditor.

This commit is contained in:
Kitteh 2021-05-26 09:20:04 +01:00
parent 5f9400b642
commit a776930590

View file

@ -1,5 +1,6 @@
import { Component, JSX, createRef } from "preact";
import { CodeJar as _CodeJar } from "codejar";
import { highlightElement } from "prismjs";
interface CodeJarProps {
language: string;
@ -12,8 +13,12 @@ export class CodeJarEditor extends Component<CodeJarProps, unknown> {
editorRef = createRef<HTMLDivElement>();
jar = createRef<_CodeJar | null>();
highlighter(e: HTMLElement, pos?: unknown): void {
highlightElement(e);
}
componentDidMount(): void {
this.jar.current = _CodeJar(this.editorRef.current, () => {}, {
this.jar.current = _CodeJar(this.editorRef.current, this.highlighter, {
tab: " ".repeat(this.props.tabSize),
window: window,
});