Vizy provides a collection of events for extending its functionality. Modules and plugins can register event listeners, typically in their init()
methods, to modify Vizy’s behavior.
registerNodes
event#The event that is triggered for registration of nodes.
use verbb\vizy\events\RegisterNodesEvent;
use verbb\vizy\services\Nodes;
use yii\base\Event;
Event::on(Nodes::class, Nodes::EVENT_REGISTER_NODES, function(RegisterNodesEvent $event) {
$event->nodes[] = MyNode::class;
// ...
});
registerMarks
event#The event that is triggered for registration of marks.
use verbb\vizy\events\RegisterMarksEvent;
use verbb\vizy\services\Nodes;
use yii\base\Event;
Event::on(Nodes::class, Nodes::EVENT_REGISTER_MARKS, function(RegistermarksEvent $event) {
$event->marks[] = MyMark::class;
// ...
});
modifyNodeTag
event#The event that is triggered for when a node's HTML tag is rendered.
use verbb\vizy\events\ModifyNodeTagEvent;
use verbb\vizy\nodes\Paragraph;
use yii\base\Event;
Event::on(Paragraph::class, Paragraph::EVENT_MODIFY_TAG, function(ModifyNodeTagEvent $event) {
$tag = $event->tag;
$node = $event->node;
$opening = $event->opening;
$closing = $event->closing;
// ...
});
modifyMarkTag
event#The event that is triggered for when a mark's HTML tag is rendered.
use verbb\vizy\events\ModifyMarkTagEvent;
use verbb\vizy\marks\Bold;
use yii\base\Event;
Event::on(Bold::class, Bold::EVENT_MODIFY_TAG, function(ModifyMarkTagEvent $event) {
$tag = $event->tag;
$mark = $event->mark;
$opening = $event->opening;
$closing = $event->closing;
// ...
});
modifyRenderedNode
event#The event that is triggered for when a node's HTML has been generated and is rendered.
use verbb\vizy\events\ModifyRenderedNodeEvent;
use verbb\vizy\nodes\Image;
use yii\base\Event;
Event::on(Image::class, Image::EVENT_MODIFY_RENDERED_NODE, function(ModifyRenderedNodeEvent $event) {
$event->renderedNode = '<div class="wrapper">' . $event->renderedNode . '</div>';
});
registerLinkOptions
event#The event that is triggered when registering the link options for the field.
use verbb\vizy\events\RegisterLinkOptionsEvent;
use verbb\vizy\fields\VizyField;
use yii\base\Event;
Event::on(VizyField::class, VizyField::EVENT_REGISTER_LINK_OPTIONS, function(RegisterLinkOptionsEvent $event) {
$linkOptions = $event->linkOptions;
// ...
});
defineVizyConfig
event#The event that is triggered when loading the editor config.
use verbb\vizy\events\ModifyVizyConfigEvent;
use verbb\vizy\fields\VizyField;
use yii\base\Event;
Event::on(VizyField::class, VizyField::EVENT_DEFINE_VIZY_CONFIG, function(ModifyVizyConfigEvent $event) {
$config = $event->config;
$field = $event->field;
// ...
});