Documented richeditor.listTypes & richeditor.getTypeInfo events (#5295)

This commit is contained in:
Luke Towers 2020-11-20 15:45:17 -06:00 committed by GitHub
parent e2eb299bee
commit c8899898e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 0 deletions

View File

@ -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) {