Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Base64Png Editor Use Imperative Handle
import { DEFAULT_RECT } from "@kogito-tooling/guided-tour/dist/api";
export const Base64PngEditor = React.forwardRef<EditorApi, Props>((props, forwardedRef) => {
// ...
useImperativeHandle(forwardedRef, () => {
return {
/**
* We are going to pass through on each of the method here.
*/
getContent: () => Promise.resolve(getContent()),
getPreview: () => Promise.resolve(getPreview()),
setContent: (path: string, content: string) => Promise.resolve(setContent(path, content)),
/**
* We're going to implement this methods further in the tutorial
*/
undo: () => Promise.resolve(),
redo: () => Promise.resolve(),
/**
* This method is not going to be implemented on this example, so it always resolve a DEFAULT_RECT.
*/
getElementPosition: (selector: string) => Promise.resolve(DEFAULT_RECT),
};
});
// ...
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment