Skip to content

Instantly share code, notes, and snippets.

@ljmotta
Last active October 13, 2020 19:08
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/b5a3a5d86177fc9c97b1a66f4813f155 to your computer and use it in GitHub Desktop.
Save ljmotta/b5a3a5d86177fc9c97b1a66f4813f155 to your computer and use it in GitHub Desktop.
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