I have a command function that dispatches a new state with metadata saying a tooltip has to be displayed. In a PluginView update
method, I watch for that metadata and display the tootip if present.
However calling getMeta
in the update
method returns undefined.
const displayIframeLinkInput = (state, dispatch, view) => {
if (dispatch) {
const tr = state.tr.setMeta('iframe-link-input', 'open')
dispatch(tr)
}
return true
}
class iframeLinkInputView {
/**
*
* @param {EditorView} view
*/
constructor(view) {
this.view = view
this.CSS = 'iframe-link-input-dialog'
this.dialog = document.createElement('div')
this.form = document.createElement('form')
this.input = document.createElement('input')
this.button = document.createElement('button')
this.form.appendChild(this.input)
this.form.appendChild(this.button)
this.dialog.appendChild(this.form)
view.dom.parentNode.appendChild(this.dialog)
}
_onSubmit(e) {
e.preventDefault()
console.log('submit')
}
/**
* @param {EditorView} view
* @param {EditorState} lastState
*/
update(view, lastState) {
console.log('update: ', view, lastState) <---- meta property is empty in both
}
destroy() {
this.dialog.remove()
}
}
export const iframeLinkInputPlugin = new Plugin({
view(editorView) {
return new iframeLinkInputView(editorView)
},
})