Last active
October 13, 2020 19:01
-
-
Save ljmotta/3d981f8c544d0d441b5d5dbc8b78bc64 to your computer and use it in GitHub Desktop.
Base64Png Editor Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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