DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:prosemirror:plugin_support

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
plugin:prosemirror:plugin_support [2018-07-23 15:28] – created grosseplugin:prosemirror:plugin_support [2018-07-23 15:52] (current) – [The parser] grosse
Line 36: Line 36:
 We tried to keep these groups to DokuWiki's parse modes. 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. 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 [[https://github.com/marijnh/orderedmap#readme|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 [[https://github.com/cosmocode/dokuwiki-plugin-prosemirror/blob/master/renderer.php|renderer.php]] get's the following data:
 +<code php>
 +$eventData = [
 +    'name' => $name,
 +    'data' => $data,
 +    'state' => $state,
 +    'match' => $match,
 +    'renderer' => $this,
 +];
 +</code>
 +
 +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 [[https://github.com/cosmocode/dokuwiki-plugin-prosemirror/blob/master/parser/Node.php|Node]] class and contains the following data:
 +
 +<code php>
 +$eventData = [
 +    'node' => $node,
 +    'parent' => $parent,
 +    'previous' => $previous,
 +    'newNode' => null,
 +];
 +</code>
 +
 +You need to prevent the default and return your instance of ''Node'' in the ''%%'newNode'%%'' key.
plugin/prosemirror/plugin_support.1532352486.txt.gz · Last modified: 2018-07-23 15:28 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