Skip to content

Commit e7e2860

Browse files
committed
untested attempt on fixing #169
This hasn't been tested and might not fully work yet. But it should show what needs to be adjusted.
1 parent 91c916b commit e7e2860

File tree

1 file changed

+21
-37
lines changed

1 file changed

+21
-37
lines changed

action/prosemirror.php

+21-37
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use dokuwiki\Extension\ActionPlugin;
44
use dokuwiki\Extension\EventHandler;
55
use dokuwiki\Extension\Event;
6+
use dokuwiki\plugin\gallery\classes\Options;
67
use dokuwiki\plugin\gallery\GalleryNode;
78
use dokuwiki\plugin\prosemirror\parser\RootNode;
89
use dokuwiki\plugin\prosemirror\schema\Node;
@@ -42,18 +43,33 @@ public function writeDefaultsToJSINFO(Event $event, $param)
4243
{
4344
global $JSINFO;
4445

45-
/** @var syntax_plugin_gallery $syntax */
46-
$syntax = plugin_load('syntax', 'gallery');
47-
$defaults = $syntax->getDataFromParams($syntax->getConf('options'));
48-
$attributes = $this->cleanAttributes($defaults);
46+
$options = new Options();
47+
$defaults = [
48+
'thumbnailsize' => $options->thumbnailWidth . 'x' . $options->thumbnailHeight,
49+
'imagesize' => $options->lightboxWidth . 'X' . $options->lightboxHeight,
50+
'cache' => $options->cache,
51+
'filter' => $options->filter,
52+
'showname' => $options->showname,
53+
'showtitle' => $options->showtitle,
54+
'crop' => $options->crop,
55+
'direct' => $options->direct,
56+
'reverse' => $options->reverse,
57+
'recursive' => $options->recursive,
58+
'align' => $options->align,
59+
'cols' => $options->columns,
60+
'limit' => $options->limit,
61+
'offset' => $options->offset,
62+
'paginate' => $options->paginate,
63+
'sort' => $options->sort,
64+
];
4965

5066
if (!isset($JSINFO['plugins'])) {
5167
$JSINFO['plugins'] = [];
5268
}
5369
$JSINFO['plugins']['gallery'] = [
5470
'defaults' => array_map(function ($default) {
5571
return ['default' => $default,];
56-
}, $attributes),
72+
}, $defaults),
5773
];
5874
$JSINFO['plugins']['gallery']['defaults']['namespace'] = ['default' => ''];
5975
}
@@ -82,7 +98,6 @@ public function renderFromInstructions(Event $event, $param)
8298
// FIXME we may have to parse the namespace from the original syntax ?
8399
$data = $event->data['data'];
84100
$ns = $data['ns'];
85-
$data = $this->cleanAttributes($data);
86101

87102
if (cleanID($ns) === $ns) {
88103
$ns = ':' . $ns;
@@ -94,37 +109,6 @@ public function renderFromInstructions(Event $event, $param)
94109
$event->data['renderer']->nodestack->add($node);
95110
}
96111

97-
/**
98-
* Slightly rewrite the attributes to the format expected by our schema
99-
*
100-
* @param $data
101-
*
102-
* @return mixed
103-
*/
104-
public function cleanAttributes($data)
105-
{
106-
$data['thumbnailsize'] = $data['tw'] . 'x' . $data['th'];
107-
$data['imagesize'] = $data['iw'] . 'X' . $data['ih'];
108-
if ($data['random']) {
109-
$data['sort'] = 'random';
110-
} else {
111-
$data['sort'] .= 'sort';
112-
}
113-
114-
if ($data['align'] === 1) {
115-
$data['align'] = 'right';
116-
} elseif ($data['align'] === 2) {
117-
$data['align'] = 'left';
118-
} else {
119-
$data['align'] = 'center';
120-
}
121-
122-
unset($data['tw'], $data['th'], $data['iw'], $data['ih'], $data['random']);
123-
unset($data['ns'], $data['galid']);
124-
125-
return $data;
126-
}
127-
128112
/**
129113
* Render our syntax instructions for prosemirror
130114
*

0 commit comments

Comments
 (0)