An action returns the instance of Writer plugin with Writer methods
The instance object contains all the actions that's specified since before with the intention to get a single access point rather than retrieving multiple actions.
{ article: { create: () =>void { /* creates a new article */ }, open: (uuid) =>void { /* open article with passed uuid */ }, copy: (uuid) =>void { /* opens a modal to make a copy of chosen article */ }, preview: (uuid) =>void { /* opens a preview of chosen article */ } }, config: { get: () =>Promise { /* get current writer configuration */ }, core: () => Object { /* get current writer core configuration */ }, additional: () => Object { /* get current writer configuration */ } }, loadableComponents: { config: (name) => Object { /* get the configuration for that loadable component */}, config: () => Array { /* get all loadable components config */} }}
Preview also has a second optional parameter. This is a function supposed to handle custom images in the case where current configured ICP does not match the one where the images of the preview are supposed to be fetched from.
import { Plugin, Utility } from'@root'constMyComponent=async (props) => {constinstance=Utility.useLazyRef(() => {returnPlugin.getAction('my-bound-action-id') })constarticleUuid='07a99d1a-3387-4cd6-bc64-c07f0062bb78'// createinstance.current().article.create()// openinstance.current().article.open(artilceUuid)// copyinstance.current().article.copy(articleUuid)// previewinstance.current().article.preview(articleUuid)// preview with optional image generatorinstance.current().article.preview(articleUuid, data => {const {uuid,uri } = datareturn { url:functionToGenerateImageUrl(uuid, uri) } })// get writer configconstconfig=awaitinstance.current().config.get()// get all loadable component configconstloadableComponentConfigs=instance.curent().loadableComponents.config()// get Article size loadable component configconstarticleSizeLoadableComponentConfig=instance.curent().loadableComponents.config('ArticleSize)}