EditorSession
Class defined in model/EditorSession.js#20 inherits from

Start a transaction to manipulate the document

Parameters
transformationfunction

a function(tx) that performs actions on the transaction document tx

Example
doc.transaction(function(tx, args) {
  tx.update(...)
  ...
  tx.setSelection(newSelection)
})

Registers a hook for the update phase.

During update data should be derived necessary for rendering.

This is mainly used by extensions of the EditorSession to derive extra state information.

Parameters
[resource]string

the name of the resource

handlerFunction

the function handler

contextObject

owner of the handler

[options]Object

options for the resource handler

Registers a hook for the 'render' phase.

During render, components should be rerendered.

Parameters
[resource]string

the name of the resource

handlerFunction

the function handler

contextObject

owner of the handler

[options]Object

options for the resource handler

Example

This typically used by components that render node content.

class ImageComponent extends Component {
  didMount() {
    this.context.editorSession.onRender('document', this.rerender, this, {
      path: [this.props.node.id, 'src']
    })
  }
  dispose() {
    this.context.editorSession.off(this)
  }
  render($$) {
    ...
  }
}

Registers a hook for the 'post-render' phase.

ATM, this phase is used internally only, for recovering the DOM selection which typically gets destroyed due to rerendering

Parameters
[resource]string

the name of the resource

handlerFunction

the function handler

contextObject

owner of the handler

[options]Object

options for the resource handler

Registers a hook for the 'position' phase.

During position, components such as Overlays, for instance, should be positioned. At this stage, it is guaranteed that all content is rendered, and the DOM selection is set.

Parameters
[resource]string

the name of the resource

handlerFunction

the function handler

contextObject

owner of the handler

[options]Object

options for the resource handler