Skip to content

Instantly share code, notes, and snippets.

@ljmotta
Last active October 13, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljmotta/3d981f8c544d0d441b5d5dbc8b78bc64 to your computer and use it in GitHub Desktop.
Save ljmotta/3d981f8c544d0d441b5d5dbc8b78bc64 to your computer and use it in GitHub Desktop.
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