🏗️ Split plugin type into block/inline subtypes

This commit is contained in:
Michael Große
2018-06-04 14:37:21 +02:00
parent ade337c5bc
commit a620d01b88
12 changed files with 92 additions and 91 deletions

View File

@ -1,73 +0,0 @@
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Lorem <wrap hi>"
},
{
"type": "text",
"text": "inline",
"marks": [
{
"type": "em"
}
]
},
{
"type": "text",
"text": "<\/wrap> ipsum"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "<WRAP important round>"
}
]
},
{
"type": "bullet_list",
"content": [
{
"type": "list_item",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": " Wichtige Box"
}
]
}
]
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "<\/WRAP>"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "bar"
}
]
}
]
}

View File

@ -1,9 +0,0 @@
Lorem <wrap hi>//inline//</wrap> ipsum
<WRAP important round>
* Wichtige Box
</WRAP>
bar

View File

@ -2,7 +2,7 @@
"type": "doc",
"content": [
{
"type": "dwplugin",
"type": "dwplugin_block",
"content": [
{
"type": "text",

View File

@ -0,0 +1,53 @@
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Lorem "
},
{
"type": "dwplugin_inline",
"content": [
{
"type": "text",
"text": "<wrap hi>"
}
],
"attrs": {
"class": "dwplugin",
"data-pluginname": "wrap_spanwrap"
}
},
{
"type": "text",
"text": "inline",
"marks": [
{
"type": "em"
}
]
},
{
"type": "dwplugin_inline",
"content": [
{
"type": "text",
"text": "<\/wrap>"
}
],
"attrs": {
"class": "dwplugin",
"data-pluginname": "wrap_spanwrap"
}
},
{
"type": "text",
"text": " ipsum"
}
]
}
]
}

View File

@ -0,0 +1 @@
Lorem <wrap hi>//inline//</wrap> ipsum

View File

@ -10,7 +10,7 @@ use dokuwiki\plugin\prosemirror\parser\SyntaxTreeBuilder;
*/
class jsonParser_plugin_prosemirror_test extends DokuWikiTest
{
protected $pluginsEnabled = ['prosemirror'];
protected $pluginsEnabled = ['prosemirror', 'wrap'];
/**
* @dataProvider rendererProvider

View File

@ -9,7 +9,7 @@
class renderer_plugin_prosemirror_test extends DokuWikiTest
{
protected $pluginsEnabled = ['prosemirror'];
protected $pluginsEnabled = ['prosemirror', 'wrap'];
/**
* @dataProvider rendererProvider
@ -23,6 +23,7 @@ class renderer_plugin_prosemirror_test extends DokuWikiTest
global $ID;
$ID = 'wiki:syntax';
$instructions = p_get_instructions($dokuwikiMarkup);
// print_r($instructions);
$doc = p_render('prosemirror', $instructions, $info);
$this->assertJsonStringEqualsJsonString($expectedJSON, $doc, $msg);
}

View File

@ -27,7 +27,8 @@ abstract class Node
'table_row' => TableRowNode::class,
'table_cell' => TableCellNode::class,
'rss' => RSSNode::class,
'dwplugin' => PluginNode::class,
'dwplugin_inline' => PluginNode::class,
'dwplugin_block' => PluginNode::class,
];

View File

@ -465,12 +465,17 @@ class renderer_plugin_prosemirror extends Doku_Renderer
if (empty($match)) {
return;
}
$node = new Node('dwplugin');
if ($this->nodestack->current()->getType() === 'paragraph') {
$nodetype = 'dwplugin_inline';
} else {
$nodetype = 'dwplugin_block';
}
$node = new Node($nodetype);
$node->attr('class', 'dwplugin');
$node->attr('data-pluginname', $name);
$this->nodestack->addTop($node);
$this->cdata($match);
$this->nodestack->drop('dwplugin');
$this->nodestack->drop($nodetype);
}
function smiley($smiley)

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
# we need additional plugin(s) for testing
https://github.com/selfthinker/dokuwiki_plugin_wrap.git lib/plugins/wrap

View File

@ -252,11 +252,31 @@ nodes = nodes.addToEnd('rss', {
},
});
nodes = nodes.addToEnd('dwplugin', {
nodes = nodes.addToEnd('dwplugin_block', {
content: 'text*',
marks: '_',
attrs: {
class: { default: 'dwplugin' },
'data-pluginname': {},
},
draggable: true,
inline: false,
group: 'block',
defining: true,
isolating: true,
code: true,
toDOM(node) {
return ['pre', node.attrs, 0];
},
});
nodes = nodes.addToEnd('dwplugin_inline', {
content: 'text*',
marks: '_',
attrs: {
class: { default: 'dwplugin' },
'data-pluginname': {},
},
draggable: true,
inline: true,

View File

@ -6,11 +6,11 @@
background-color: #ffdddd;
}
code.dwplugin {
.dwplugin {
border: 1px solid greenyellow;
}
code.dwplugin::before {
.dwplugin::before {
content: '🔧';
color: greenyellow;
cursor: grab;