? Feature PR-5.0-dev b/c break Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
11 Mar 2023

Summary of Changes

The patch improve Editor and Buttons plugins.
Now they can use a real events.
It similar to #39657 but for Editors and Buttons.

This is fully backward compatible.

How this work.
Here I added a new event onEditorSetup and an Interface for EditorProviderInterface class.
And similar for buttons onEditorButtonsSetup and a Button class with Interface ButtonInterface.

On onEditorSetup an editor plugin should register own EditorProvider in EditorsRegistry.
On onEditorButtonsSetup a button plugin should register own Button(s) in ButtonsRegistry.

The system will retrieve a requested Editor from that registry and call required methods, that defined by EditorProviderInterface.

Example registering an Editor:

public function onEditorSetup(EditorSetupEvent $event)
{
$this->loadLanguage();
$event->getSubject()->add(new CodeMirrorProvider($this->params, $this->getApplication(), $this->getDispatcher()));
}

Example registering an editor Button:

public function onEditorButtonsSetup(EditorButtonsSetupEvent $event)
{
/** @var ButtonsRegistry $subject */
$subject = $event->getSubject();
$disabled = $event->getDisabledButtons();
if (\in_array($this->_name, $disabled)) {
return;
}
$button = $this->onDisplay($event->getEditorId());
if ($button) {
$subject->add($button);
}
}

Testing Instructions

Apply patch.
Set default editor to Codemirror and make sure it works.

Testing B/C:
Enable TinyMCE editor and make sure it works.

Actual result BEFORE applying this Pull Request

Works

Expected result AFTER applying this Pull Request

Works

Link to documentations

Please select:

avatar joomla-cms-bot joomla-cms-bot - change - 11 Mar 2023
Category Layout Libraries Front End Plugins
avatar Fedik Fedik - open - 11 Mar 2023
avatar Fedik Fedik - change - 11 Mar 2023
Status New Pending
5a3782b 11 Mar 2023 avatar Fedik phpcs
avatar Fedik Fedik - change - 11 Mar 2023
Labels Added: ? PR-4.3-dev
avatar HLeithner
HLeithner - comment - 13 Mar 2023

I like it but didn't had time to look at it in deep

avatar Fedik
Fedik - comment - 13 Mar 2023

I have "transformed" Codemirror and Article button, rest working in "legacy mode", can test b/c on them.
I will update rest later, when will know whether it suits us.

avatar Fedik Fedik - change - 26 Mar 2023
Labels Added: PR-4.4-dev
Removed: PR-4.3-dev
avatar laoneo
laoneo - comment - 30 Mar 2023

I guess it is better to rebase this pr to the 5.0-dev branch, as it will get more attention for new features. Thanks for understanding.

avatar Fedik
Fedik - comment - 2 Apr 2023

TODO: Button layout should load any asset for a buton when available.
TODO: Move buttons, asset, author from Ediitor $attributes to $params

return $this->provider->display($name, $html, [
'width' => $width,
'height' => $height,
'col' => $col,
'row' => $row,
'buttons' => $buttons,
'id' => $id,
'asset' => $asset,
'author' => $author,
], $params);

TODO: Improve event, add public get methods with typehint eg $event->getSubject()

avatar Fedik Fedik - change - 2 Apr 2023
The description was changed
avatar Fedik Fedik - edited - 2 Apr 2023
avatar Fedik Fedik - change - 7 Apr 2023
Labels Added: PR-5.0-dev
Removed: PR-4.4-dev
avatar Fedik Fedik - change - 7 Apr 2023
The description was changed
avatar Fedik Fedik - edited - 7 Apr 2023
avatar Fedik Fedik - change - 10 Apr 2023
Labels Added: ? b/c break
avatar Fedik Fedik - change - 23 Apr 2023
Title
[RFC] Make Editor and Buttons plugins to use plugin events
[5.0][RFC] Make Editor and Buttons plugins to use plugin events
avatar Fedik Fedik - edited - 23 Apr 2023
avatar Fedik Fedik - change - 13 May 2023
Labels Added: Feature
Removed: ?
avatar Fedik Fedik - change - 6 Aug 2023
Title
[5.0][RFC] Make Editor and Buttons plugins to use plugin events
[5.0][RFC][Events] Make Editor and Buttons plugins to use plugin events
avatar Fedik Fedik - edited - 6 Aug 2023
avatar HLeithner HLeithner - close - 21 Aug 2023
avatar HLeithner HLeithner - merge - 21 Aug 2023
avatar HLeithner HLeithner - change - 21 Aug 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-08-21 06:42:00
Closed_By HLeithner
avatar HLeithner
HLeithner - comment - 21 Aug 2023

Can you please create a manual entry for migration, not only that it changes, also what needs to be done to convert a button to use event triggers please.

I'm merging this for now to have more test coverage in alpha.

avatar Fedik
Fedik - comment - 21 Aug 2023

Do not forget the same for Cpatcha:

Also would be good to have a decision about following, client side api:

Which depend from Dialog PR #40150

avatar Fedik Fedik - change - 5 Sep 2023
The description was changed
avatar Fedik Fedik - edited - 5 Sep 2023

Add a Comment

Login with GitHub to post a comment