-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
78 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
use dokuwiki\Extension\ActionPlugin; | ||
use dokuwiki\Extension\EventHandler; | ||
use dokuwiki\Extension\Event; | ||
|
@@ -17,10 +16,6 @@ | |
use dokuwiki\plugin\prosemirror\parser\InternalLinkNode; | ||
use dokuwiki\plugin\prosemirror\parser\LinkNode; | ||
|
||
if (!defined('DOKU_INC')) { | ||
die(); | ||
} | ||
|
||
class action_plugin_prosemirror_ajax extends ActionPlugin | ||
{ | ||
/** | ||
|
@@ -42,12 +37,10 @@ public function register(EventHandler $controller) | |
* Event: AJAX_CALL_UNKNOWN | ||
* | ||
* @param Event $event event object by reference | ||
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this | ||
* handler was registered] | ||
* | ||
* @return void | ||
*/ | ||
public function handleAjax(Event $event, $param) | ||
public function handleAjax(Event $event) | ||
{ | ||
if ($event->data !== 'plugin_prosemirror') { | ||
return; | ||
|
@@ -61,61 +54,52 @@ public function handleAjax(Event $event, $param) | |
foreach ($INPUT->arr('actions') as $action) { | ||
switch ($action) { | ||
case 'resolveInternalLink': | ||
{ | ||
$inner = $INPUT->str('inner'); | ||
$responseData[$action] = $this->resolveInternalLink($inner, $ID); | ||
break; | ||
} | ||
$inner = $INPUT->str('inner'); | ||
$responseData[$action] = $this->resolveInternalLink($inner, $ID); | ||
break; | ||
case 'resolveInterWikiLink': | ||
{ | ||
$inner = $INPUT->str('inner'); | ||
[$shortcut, $reference] = explode('>', $inner); | ||
$responseData[$action] = $this->resolveInterWikiLink($shortcut, $reference); | ||
break; | ||
} | ||
$inner = $INPUT->str('inner'); | ||
[$shortcut, $reference] = explode('>', $inner); | ||
$responseData[$action] = $this->resolveInterWikiLink($shortcut, $reference); | ||
break; | ||
case 'resolveMedia': | ||
{ | ||
$attrs = $INPUT->arr('attrs'); | ||
$responseData[$action] = [ | ||
'data-resolvedHtml' => ImageNode::resolveMedia( | ||
$attrs['id'], | ||
$attrs['title'], | ||
$attrs['align'], | ||
$attrs['width'], | ||
$attrs['height'], | ||
$attrs['cache'], | ||
$attrs['linking'] | ||
) | ||
]; | ||
break; | ||
} | ||
$attrs = $INPUT->arr('attrs'); | ||
$responseData[$action] = [ | ||
'data-resolvedHtml' => ImageNode::resolveMedia( | ||
$attrs['id'], | ||
$attrs['title'], | ||
$attrs['align'], | ||
$attrs['width'], | ||
$attrs['height'], | ||
$attrs['cache'], | ||
$attrs['linking'] | ||
) | ||
]; | ||
break; | ||
case 'resolveImageTitle': | ||
{ | ||
$image = $INPUT->arr('image'); | ||
$responseData[$action] = []; | ||
$responseData[$action]['data-resolvedImage'] = LinkNode::resolveImageTitle( | ||
$ID, | ||
$image['id'], | ||
$image['title'], | ||
$image['align'], | ||
$image['width'], | ||
$image['height'], | ||
$image['cache'] | ||
); | ||
break; | ||
} | ||
$image = $INPUT->arr('image'); | ||
$responseData[$action] = []; | ||
$responseData[$action]['data-resolvedImage'] = LinkNode::resolveImageTitle( | ||
$ID, | ||
$image['id'], | ||
$image['title'], | ||
$image['align'], | ||
$image['width'], | ||
$image['height'], | ||
$image['cache'] | ||
); | ||
break; | ||
case 'resolveRSS': | ||
{ | ||
$attrs = json_decode($INPUT->str('attrs'), true); | ||
$responseData[$action] = RSSNode::renderAttrsToHTML($attrs); | ||
break; | ||
} | ||
$attrs = json_decode($INPUT->str('attrs'), true); | ||
$responseData[$action] = RSSNode::renderAttrsToHTML($attrs); | ||
break; | ||
default: | ||
{ | ||
dbglog('Unknown action: ' . $action, __FILE__ . ': ' . __LINE__); | ||
http_status(400, 'unknown action'); | ||
return; | ||
} | ||
dokuwiki\Logger::getInstance(dokuwiki\Logger::LOG_DEBUG)->log( | ||
__FILE__ . ': ' . __LINE__, | ||
'Unknown action: ' . $action | ||
); | ||
http_status(400, 'unknown action'); | ||
return; | ||
} | ||
} | ||
|
||
|
@@ -148,12 +132,10 @@ protected function resolveInternalLink($inner, $curId) | |
* Event: AJAX_CALL_UNKNOWN | ||
* | ||
* @param Event $event event object by reference | ||
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this | ||
* handler was registered] | ||
* | ||
* @return void | ||
*/ | ||
public function switchEditors(Event $event, $param) | ||
public function switchEditors(Event $event) | ||
{ | ||
if ($event->data !== 'plugin_prosemirror_switch_editors') { | ||
return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,12 @@ | |
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
use dokuwiki\Extension\ActionPlugin; | ||
use dokuwiki\Extension\EventHandler; | ||
use dokuwiki\Extension\Event; | ||
use dokuwiki\Form\Form; | ||
use dokuwiki\Form\ButtonElement; | ||
|
||
if (!defined('DOKU_INC')) { | ||
die(); | ||
} | ||
|
||
class action_plugin_prosemirror_editor extends ActionPlugin | ||
{ | ||
/** | ||
|
@@ -208,7 +203,9 @@ public function addAddtionalForms(Event $event) | |
$linkForm->addRadioButton('linktype', $this->getLang('type:wiki page'))->val('internallink'); | ||
$linkForm->addRadioButton('linktype', $this->getLang('type:interwiki'))->val('interwikilink'); | ||
$linkForm->addRadioButton('linktype', $this->getLang('type:email'))->val('emaillink'); | ||
$linkForm->addRadioButton('linktype', $this->getLang('type:external'))->val('externallink')->attr('checked', 'checked'); | ||
$linkForm->addRadioButton('linktype', $this->getLang('type:external')) | ||
->val('externallink') | ||
->attr('checked', 'checked'); | ||
$linkForm->addRadioButton('linktype', $this->getLang('type:other'))->val('other'); | ||
$linkForm->addTagClose('fieldset'); | ||
$linkForm->addTagClose('div'); | ||
|
@@ -218,7 +215,9 @@ public function addAddtionalForms(Event $event) | |
$linkForm->addTagOpen('legend'); | ||
$linkForm->addHTML('Link Name Type'); | ||
$linkForm->addTagClose('legend'); | ||
$linkForm->addRadioButton('nametype', $this->getLang('type:automatic title'))->val('automatic')->attr('checked', 'checked'); | ||
$linkForm->addRadioButton('nametype', $this->getLang('type:automatic title')) | ||
->val('automatic') | ||
->attr('checked', 'checked'); | ||
$linkForm->addRadioButton('nametype', $this->getLang('type:custom title'))->val('custom'); | ||
$linkForm->addRadioButton('nametype', $this->getLang('type:image'))->val('image'); | ||
$linkForm->addTextInput('linkname', 'Link name')->attr('placeholder', $this->getLang('placeholder:link name')); | ||
|
@@ -240,9 +239,12 @@ public function addAddtionalForms(Event $event) | |
'style' => 'display: none;', | ||
]); | ||
$mediaForm->addFieldsetOpen($this->getLang('legend:media'))->addClass('js-media-fieldset'); | ||
$mediaForm->addButtonHTML('mediamanager', inlineSVG(DOKU_PLUGIN . 'prosemirror/images/file-image-outline.svg'))->attrs([ | ||
'type' => 'button', | ||
'class' => 'js-open-mediamanager mediaform_mediamanager' | ||
$mediaForm->addButtonHTML( | ||
'mediamanager', | ||
inlineSVG(DOKU_PLUGIN . 'prosemirror/images/file-image-outline.svg') | ||
)->attrs([ | ||
'type' => 'button', | ||
'class' => 'js-open-mediamanager mediaform_mediamanager' | ||
]); | ||
$mediaForm->addTextInput('mediatarget', $this->getLang('media target'))->attrs( | ||
[ | ||
|
@@ -272,7 +274,9 @@ public function addAddtionalForms(Event $event) | |
$mediaForm->addTagOpen('legend'); | ||
$mediaForm->addHTML($this->getLang('legend:alignment')); | ||
$mediaForm->addTagClose('legend'); | ||
$mediaForm->addRadioButton('alignment', $this->getLang('label:default alignment'))->val('')->attr('checked', 'checked'); | ||
$mediaForm->addRadioButton('alignment', $this->getLang('label:default alignment')) | ||
->val('') | ||
->attr('checked', 'checked'); | ||
$mediaForm->addRadioButton('alignment', $this->getLang('label:float left'))->val('left'); | ||
$mediaForm->addRadioButton('alignment', $this->getLang('label:center alignment'))->val('center'); | ||
$mediaForm->addRadioButton('alignment', $this->getLang('label:float right'))->val('right'); | ||
|
@@ -284,7 +288,9 @@ public function addAddtionalForms(Event $event) | |
$mediaForm->addTagOpen('legend'); | ||
$mediaForm->addHTML($this->getLang('legend:linking')); | ||
$mediaForm->addTagClose('legend'); | ||
$mediaForm->addRadioButton('linking', $this->getLang('label:default linking'))->val('details')->attr('checked', 'checked'); | ||
$mediaForm->addRadioButton('linking', $this->getLang('label:default linking')) | ||
->val('details') | ||
->attr('checked', 'checked'); | ||
$mediaForm->addRadioButton('linking', $this->getLang('label:direct linking'))->val('direct'); | ||
$mediaForm->addRadioButton('linking', $this->getLang('label:nolink'))->val('nolink'); | ||
$mediaForm->addRadioButton('linking', $this->getLang('label:linkonly'))->val('linkonly'); | ||
|
@@ -296,7 +302,9 @@ public function addAddtionalForms(Event $event) | |
$mediaForm->addTagOpen('legend'); | ||
$mediaForm->addHTML($this->getLang('legend:caching')); | ||
$mediaForm->addTagClose('legend'); | ||
$mediaForm->addRadioButton('caching', $this->getLang('label:default caching'))->val('')->attr('checked', 'checked'); | ||
$mediaForm->addRadioButton('caching', $this->getLang('label:default caching')) | ||
->val('') | ||
->attr('checked', 'checked'); | ||
$mediaForm->addRadioButton('caching', $this->getLang('label:recache'))->val('recache'); | ||
$mediaForm->addRadioButton('caching', $this->getLang('label:nocache'))->val('nocache'); | ||
$mediaForm->addTagClose('fieldset'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,11 @@ | |
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
use dokuwiki\Extension\ActionPlugin; | ||
use dokuwiki\Extension\EventHandler; | ||
use dokuwiki\Extension\Event; | ||
use dokuwiki\plugin\prosemirror\parser\SyntaxTreeBuilder; | ||
|
||
if (!defined('DOKU_INC')) { | ||
die(); | ||
} | ||
|
||
class action_plugin_prosemirror_parser extends ActionPlugin | ||
{ | ||
/** | ||
|
@@ -28,8 +23,8 @@ class action_plugin_prosemirror_parser extends ActionPlugin | |
*/ | ||
public function register(EventHandler $controller) | ||
{ | ||
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_preprocess'); | ||
$controller->register_hook('DRAFT_SAVE', 'BEFORE', $this, 'handle_draft'); | ||
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handlePreprocess'); | ||
$controller->register_hook('DRAFT_SAVE', 'BEFORE', $this, 'handleDraft'); | ||
} | ||
|
||
/** | ||
|
@@ -38,7 +33,7 @@ public function register(EventHandler $controller) | |
* @param Event $event | ||
* @param $param | ||
*/ | ||
public function handle_draft(Event $event, $param) | ||
public function handleDraft(Event $event, $param) | ||
{ | ||
global $INPUT; | ||
$unparsedJSON = $INPUT->post->str('prosemirror_json'); | ||
|
@@ -80,7 +75,7 @@ public function handle_draft(Event $event, $param) | |
* | ||
* @return void | ||
*/ | ||
public function handle_preprocess(Event $event, $param) | ||
public function handlePreprocess(Event $event, $param) | ||
{ | ||
global $TEXT, $INPUT; | ||
if ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
<?php | ||
|
||
// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps | ||
|
||
/** | ||
* DokuWiki Plugin prosemirror (Renderer Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
use dokuwiki\plugin\prosemirror\parser\ImageNode; | ||
use dokuwiki\plugin\prosemirror\parser\LocalLinkNode; | ||
use dokuwiki\plugin\prosemirror\parser\InternalLinkNode; | ||
|
@@ -20,12 +21,6 @@ | |
use dokuwiki\plugin\prosemirror\schema\Node; | ||
use dokuwiki\plugin\prosemirror\schema\NodeStack; | ||
|
||
if (!defined('DOKU_INC')) { | ||
die(); | ||
} | ||
|
||
require_once DOKU_INC . 'inc/parser/renderer.php'; | ||
|
||
class renderer_plugin_prosemirror extends Doku_Renderer | ||
{ | ||
/** @var NodeStack */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters