Ui

showNotification(name, title, message, [sticky], [level])

Show a notification, if Writer is used inside of Dashboard, the notification will be elevated and displayed through the Dashboard notification instead

Parameters

Example

api.ui.showNotification(
   'plugin.id',
   'An insightful title',
   'And descriptive text',
   false
)

showArticleMessage(origin, id, options)

Display a message with static positioning at the top of the article. Can disallow closing, and can include buttons with callback functions.

Parameters

Example

api.ui.showArticleMessage('some.plugin.io', 'my-message-id', {
    message: 'This is important',
    buttons: [
        {
            label: 'Say hello',
            onClick: () => {
                // Do something
            }
        }
    ]
})

showDialog(contentComponent, props, options, [focusPrimary], [theme], [takeover], [cssClass], [clearSelection], [disableEscKey], [heading])

Display a dialog with the specified content.

Supported dialog actions:

`dialog:enablePrimaryBtn`Enables the primary button`dialog:disablePrimaryBtn`Disables the primary button

See: component/dialogComponent

Parameters

Example

import {api} from 'writer'
import {ComponentShownInDialog} from './ComponentShownInDialog'

api.ui.showDialog(
  ComponentShownInDialog,
  {
      src: img.src,
      width: this.props.node.width,
      height: this.props.node.height,
      crops: this.props.node.crops,
      callback: this.setSoftcropData.bind(this)
  },
  {
      title: "This is my title for the dialog",
      primary: 'Save',
      secondary: 'Close',
      tertiary: [{
         caption: 'Remove',
         callback: () => {
             // Do something
         }
      }],
      takeover: true,
      theme: 'dark',
      cssClass: 'extra-css-class'
  }
)

showAuthDialog(authComponent, authProps, authOptions)

Display a Auth dialog (401/402) above any other dialogs.

Parameters

showMessageDialog(messages, cbContinue, cbCancel, [heading], [showTimestamp])

Display a number of messages and different options depending on the severity on each message. Messages can be of type info, warning or error.

If there are error messages the user will not be able to continue. If there are warnings the user can continue but suggested to cancel. If only info messages only a continue is possible.

Parameters

Example

import {api} from 'writer'

api.ui.showMessageDialog(
    [{
        type: 'info',
        message: 'Hello'
    }],
    () => {
        console.log('The user clicked continue!')
    },
    () => {
        console.warn('The user clicked cancel')
    }
)

showConfirmDialog(title, message, buttons)

Display a simple confirmation dialog

Parameters

Example

api.ui.showConfirmDialog(
     'Title-string',
     'Message string',
     {
         primary: {
             label: this.getLabel('Ok'),
             callback: () => { logic }
         },
         secondary: {
             label: this.getLabel('Cancel'),
             callback: () => { logic }
         }
     }
)

showBottomPanel(pluginName, component, [props], [sticky])

Renders a supplied component in a screen-wide panel which smoothly animates from the bottom of the screen.

Parameters

Example

api.ui.showBottomPanel(
    'im-mycoolplugin',
    MyCoolComponent,
    {
        propName: 'propvalue
    },
    true
)

showOverlay(pluginName, component, [props])

Renders a supplied component in a "fullscreen" overlay.

Parameters

Example

api.ui.showOverlay(
    'im-mycoolplugin',
    MyCoolComponent,
    {
        propName: 'propvalue
    }
)

hideOverlay(pluginName)

Hides the overlay. Useful to call this in a component that rendered as and overlay component.

Parameters

Example

api.ui.hideOverlay('im-mycoolplugin')

getComponent()

Deprecated

Deprecated, use import {UIComponent} from 'writer' statements for UIComponents instead

Last updated