The MarkupEditor logo

Class: MarkupDelegate

MarkupDelegate()

A class you define and register with the MarkupEditor, whose methods the MessageHandler invokes if the delegate exists and the method exists. The MarkupDelegate is not part of the MarkupEditor web component. You would typically implement a MarkupDelegate (could be any name) and register it in a userscript.

This class is part of the MarkupEditor API documentation because without using TypeScript, there isn't a proper way to declare an interface.

Constructor

new MarkupDelegate()

Methods

markupClicked()

A click event was received in the editor.

markupDidBlur()

A blur event was received in the editor.

markupDidFocus()

A focus event was received in the editor.

markupError(code, message, info, alert)

An error occurred.

Parameters:
Name Type Description
code string

A MarkupEditor error code.

message string

The error message.

info string

Additional information about the error.

alert boolean

True if the user should be alerted; false if not.

markupImageAdded(src, divId)

An image was loaded in the editor. The same image may be present at multiple locations, but markupImageAdded will only be called once. The callback is useful when you are need to deal with local image insertion at the time it happens in your application environment, for example in response to someone pasting an image in.

Parameters:
Name Type Description
src string

The img src attribute.

divId string

The DIV that the image is in, typically 'editor'.

markupInput()

The editor received input of some kind, so the contents changed. This could be because of typing or image resizing, or pasting, or formatting, etc.

markupInsertImage(state, dispatch, view)

Invoked when the "Insert Image" button is pressed in the toolbar. The default behavior is ImageItem.openDialog in src/setup/menuitems.js.

Parameters:
Name Type Description
state EditorState
dispatch function
view EditorView

Invoked when the "Insert Link" button is pressed in the toolbar. The default behavior is LinkItem.openDialog in src/setup/menuitems.js.

Parameters:
Name Type Description
state EditorState
dispatch function
view EditorView

markupReady()

The editor is ready to be used. Scripts and styling have loaded and MU is available.

markupSearched()

Search was invoked in the editor.

markupSelectImage(state, dispatch, view)

Invoked when the "Select..." button is pressed in the standard "Insert Image" dialog. There is no default behavior. Instead, the "Select..." button is not shown by default.

Parameters:
Name Type Description
state EditorState
dispatch function
view EditorView

markupSelectionChanged()

The selection in the editor changed.

markupUpdateHeight(height)

The height of the editor changed to height.

Parameters:
Name Type Description
height number

Table of contents