From c8899898e6da0a5c4eda440822984885cbd017d5 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Fri, 20 Nov 2020 15:45:17 -0600 Subject: [PATCH] Documented richeditor.listTypes & richeditor.getTypeInfo events (#5295) --- modules/backend/formwidgets/RichEditor.php | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/modules/backend/formwidgets/RichEditor.php b/modules/backend/formwidgets/RichEditor.php index 0949ced02..d8d26785e 100644 --- a/modules/backend/formwidgets/RichEditor.php +++ b/modules/backend/formwidgets/RichEditor.php @@ -186,6 +186,19 @@ class RichEditor extends FormWidgetBase { $result = []; + /** + * @event backend.richeditor.listTypes + * Register additional "page link types" to the RichEditor FormWidget + * + * Example usage: + * + * Event::listen('backend.richeditor.listTypes', function () { + * return [ + * 'my-identifier' => 'author.plugin::lang.richeditor.link_types.my_identifier', + * ]; + * }); + * + */ $apiResult = Event::fire('backend.richeditor.listTypes'); if (is_array($apiResult)) { foreach ($apiResult as $typeList) { @@ -205,6 +218,28 @@ class RichEditor extends FormWidgetBase protected function getPageLinks($type) { $result = []; + + /** + * @event backend.richeditor.getTypeInfo + * Register additional "page link types" to the RichEditor FormWidget + * + * Example usage: + * + * Event::listen('backend.richeditor.getTypeInfo', function ($type) { + * if ($type === 'my-identifier') { + * return [ + * 'https://example.com/page1' => 'Page 1', + * 'https://example.com/parent-page' => [ + * 'title' => 'Parent Page', + * 'links' => [ + * 'https://example.com/child-page' => 'Child Page', + * ], + * ], + * ]; + * } + * }); + * + */ $apiResult = Event::fire('backend.richeditor.getTypeInfo', [$type]); if (is_array($apiResult)) { foreach ($apiResult as $typeInfo) {