Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Base64Png Editor Interface
import { Editor, EditorApi, EditorInitArgs, KogitoEditorEnvelopeContextType } from "@kogito-tooling/editor/dist/api";
import { Rect } from "@kogito-tooling/guided-tour/dist/api";
import { Base64PngEditor } from "./Base64PngEditor";
export class Base64PngEditorInterface implements Editor {
private editorRef: React.RefObject<EditorApi>;
public af_isReact = true;
public af_componentId: "base64png-editor";
public af_componentTitle: "Base64 PNG Editor";
constructor(
private readonly envelopeContext: KogitoEditorEnvelopeContextType,
private readonly initArgs: EditorInitArgs
) {
this.editorRef = React.createRef<EditorApi>();
}
public getContent(): Promise<string> {
return this.editorRef.current?.getContent()!;
}
public getElementPosition(selector: string): Promise<Rect | undefined> {
return this.editorRef.current?.getElementPosition(selector)!;
}
public setContent(path: string, content: string): Promise<void> {
return this.editorRef.current?.setContent(path, content)!;
}
public getPreview(): Promise<string | undefined> {
return this.editorRef.current?.getPreview()!;
}
public undo(): Promise<void> {
return this.editorRef.current?.undo()!;
}
public redo(): Promise<void> {
return this.editorRef.current?.redo()!;
}
public af_componentRoot() {
return <Base64PngEditor ref={this.editorRef} envelopeContext={this.envelopeContext} />;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment