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