mirror of
https://github.com/cosmocode/dokuwiki-plugin-prosemirror.git
synced 2025-07-29 21:06:13 +00:00
🏗️ Split plugin type into block/inline subtypes
This commit is contained in:
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
Lorem <wrap hi>//inline//</wrap> ipsum
|
||||
|
||||
<WRAP important round>
|
||||
|
||||
* Wichtige Box
|
||||
|
||||
</WRAP>
|
||||
|
||||
bar
|
@ -2,7 +2,7 @@
|
||||
"type": "doc",
|
||||
"content": [
|
||||
{
|
||||
"type": "dwplugin",
|
||||
"type": "dwplugin_block",
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
|
53
_test/json/plugin_inline.json
Normal file
53
_test/json/plugin_inline.json
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
1
_test/json/plugin_inline.txt
Normal file
1
_test/json/plugin_inline.txt
Normal file
@ -0,0 +1 @@
|
||||
Lorem <wrap hi>//inline//</wrap> ipsum
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
];
|
||||
|
||||
|
||||
|
@ -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
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
# we need additional plugin(s) for testing
|
||||
https://github.com/selfthinker/dokuwiki_plugin_wrap.git lib/plugins/wrap
|
@ -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,
|
||||
|
@ -6,11 +6,11 @@
|
||||
background-color: #ffdddd;
|
||||
}
|
||||
|
||||
code.dwplugin {
|
||||
.dwplugin {
|
||||
border: 1px solid greenyellow;
|
||||
}
|
||||
|
||||
code.dwplugin::before {
|
||||
.dwplugin::before {
|
||||
content: '🔧';
|
||||
color: greenyellow;
|
||||
cursor: grab;
|
||||
|
Reference in New Issue
Block a user