Ui

User interface manipulation and handling

showNotification(name, title, message, sticky)

Show a notification

Parameters

showArticleMessage(origin, id, message, allowClose, buttons)

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)

Display a dialog with the specified content.

Supported dialog actions:

`dialog:enablePrimaryBtn`Enables the primary button

See: component/dialogComponent

Parameters

Example

import {api} from 'writer'

const tertiary = [{
     caption: this.context.i18n.t('Remove'),
     callback: () => {
         // Do something
     }
}]

api.ui.showDialog(
  require('./XimimageSoftcropComponent'),
  {
      src: img.src,
      width: this.props.node.width,
      height: this.props.node.height,
      crops: this.props.node.crops,
      callback: this.setSoftcropData.bind(this)
  },
  {
      tertiary: tertiary
  }
)

showAuthDialog(authComponent, authProps, authOptions)

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

Parameters

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

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