Enh: Added humhub\modules\content\widgets\richtext\ProsemirrorRichText::parseOutput for pre render parsing

This commit is contained in:
buddh4 2018-08-31 18:21:07 +02:00
parent bc37921e7e
commit 11cc627704
2 changed files with 16 additions and 2 deletions

View File

@ -53,6 +53,8 @@ use yii\base\InvalidArgumentException;
*/
abstract class AbstractRichText extends JsWidget
{
const PRESET_DOCUMENT = 'document';
/**
* @event Event an event raised after the post-process phase of the rich text.
*/

View File

@ -154,7 +154,7 @@ class ProsemirrorRichText extends AbstractRichText
}
}
$this->text = static::parseMentionings($this->text, $this->edit);
$this->text = $this->parseOutput();
if ($this->maxLength > 0) {
$this->text = Helpers::truncateText($this->text, $this->maxLength);
@ -168,6 +168,14 @@ class ProsemirrorRichText extends AbstractRichText
}
/**
* @since v1.3.2
*/
protected function parseOutput()
{
return static::parseMentionings($this->text, $this->edit);
}
/**
* @return string truncated and stripped text
*/
@ -215,9 +223,13 @@ class ProsemirrorRichText extends AbstractRichText
return $container->isActive()
? '['.Html::encode($container->getDisplayName()).'](mention:'.$container->guid.' "'.$container->getUrl().'")'
: $notFoundResult;
} elseif($container instanceof Space) {
}
if($container instanceof Space) {
return '['.Html::encode($container->name).'](mention:'.$container->guid.' "'.$container->getUrl().'")';
}
return '';
});
}