It's better when it's simple

User Tools

Site Tools


Adding Support for other DokuWiki Plugins

As with the Prosemirror Plugin in general, this API is still very much in an APLHA stage and subject to change!

Prosemirror is very powerful, but also very complex and very subtle. Please work through the Prosemirror Library Guide before attempting an integration.

To add basic support for your plugin you need to implement the following basic aspects:

  • the schema
  • the renderer
  • the parser

There are further optional aspects for your plugin

  • the nodeview
  • the menu item
  • the keybindings
  • the input rule

The schema

A Prosemirror document is based on a schema. This schema defines

  • which nodes/marks exist,
  • where they are allowed,
  • what is allowed inside of them,
  • how they should be rendered
  • how they should be parsed, if pasted into the editor

The prosemirror documentation has an example for schema from scratch. There is also a reference documentation.

Our schema is currently available in a single file.

Nodes in a schema are usually organized into groups. We tried to keep these groups to DokuWiki's parse modes. However, since Prosemirror enforces a strict separation of inline and block content, these groups are not identical to the parser modes.

To add your own content to the schema, add a callback to window.Prosemirror.pluginSchemas that accepts the existing nodes and marks, modifies/extends them and returns them in an object. Please note that nodes and marks are not simple arrays, but ordered maps.

The renderer

The renderer renders DokuWiki's instructions into JSON as expected by Prosemirror according to the defined schema. Your integration needs to handle the PROSEMIRROR_RENDER_PLUGIN event. This event is triggered for the plugin instructions in the renderer.php get's the following data:

$eventData = [
    'name' => $name,
    'data' => $data,
    'state' => $state,
    'match' => $match,
    'renderer' => $this,

For your plugin, you need to prevent the default action and add your Node to the renderer. See the other modes for the available functions.

The parser

The parser is used to translate the JSON from Prosemirror back to DokuWiki's syntax. To parse you own node, you need to listen to the PROSEMIRROR_PARSE_UNKNOWN event. This event is triggered in the abstract Node class and contains the following data:

$eventData = [
    'node' => $node,
    'parent' => $parent,
    'previous' => $previous,
    'newNode' => null,

You need to prevent the default and return your instance of Node in the 'newNode' key.

plugin/prosemirror/plugin_support.txt · Last modified: 2018-07-23 15:52 by grosse

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki