Skip to content

Conversation

@Fedik
Copy link
Member

@Fedik Fedik commented Mar 11, 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:

@Fedik Fedik requested a review from laoneo as a code owner March 11, 2023 13:46
@joomla-cms-bot joomla-cms-bot added PR-4.3-dev RFC Request for Comment labels Mar 11, 2023
@HLeithner HLeithner added Feature b/c break This item changes the behavior in an incompatible why. HEADS UP labels Apr 7, 2023
@Fedik Fedik changed the title [RFC] Make Editor and Buttons plugins to use plugin events [5.0][RFC] Make Editor and Buttons plugins to use plugin events Apr 23, 2023
Fedik added 4 commits July 1, 2023 20:08
 Conflicts:
	plugins/editors/codemirror/src/Extension/Codemirror.php
 Conflicts:
	plugins/editors/codemirror/src/Extension/Codemirror.php
@Fedik Fedik changed the 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 Aug 6, 2023
@HLeithner HLeithner merged commit c5b41b4 into joomla:5.0-dev Aug 21, 2023
@HLeithner
Copy link
Member

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.

@Fedik
Copy link
Member Author

Fedik commented Aug 21, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

b/c break This item changes the behavior in an incompatible why. HEADS UP Documentation Required Feature RFC Request for Comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants