Get instance
id
com.naviga.writer:getWriterInstance
description
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 */ }
}
}import { Plugin, Utility }Â from '@root'
const MyComponent = async (props) => {
const instance = Utility.useLazyRef(() => {
return Plugin.getAction('my-bound-action-id')
})
const articleUuid = '07a99d1a-3387-4cd6-bc64-c07f0062bb78'
// create
instance.current().article.create()
// open
instance.current().article.open(artilceUuid)
// copy
instance.current().article.copy(articleUuid)
// preview
instance.current().article.preview(articleUuid)
// preview with optional image generator
instance.current().article.preview(articleUuid, data => {
const {
uuid,
uri
} = data
return {
url: functionToGenerateImageUrl(uuid, uri)
}
})
// get writer config
const config = await instances.current().config.get()
}Last updated