Problem/Motivation
Editor plugins all implement PluginFormInterface, which is used for subforms. Their plugin configuration forms are always contained by a parent form.
Currently they are explicitly tied to the form structure defined by editor_form_filter_format_form_alter().
Proposed resolution
#2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) introduced the concept of SubformState, for partial forms that are built as part of a larger form.
Editor plugins should utilize this to remove the coupling to the parent form structure.
Remaining tasks
User interface changes
N/A
API changes
API addition. Editor forms directly implementing the PluginFormInterface methods (instead of the deprecated settingsForm* methods) will be passed a SubformState instance.
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 2819731-21.patch | 10.06 KB | wim leers |
| #21 | interdiff.txt | 1.99 KB | wim leers |
| #20 | 2819731-editor-20.patch | 9.76 KB | tim.plunkett |
| #18 | 2819731-editor-18.patch | 9.16 KB | tim.plunkett |
| #12 | 2819731-editor-12-interdiff.txt | 3.12 KB | tim.plunkett |
Comments
Comment #2
tim.plunkettThis is independent of #2326721: EditorPluginInterface should extend PluginFormInterface, but the patches will conflict, so probably best to wait on that.
Comment #3
wim leers+1!
Comment #4
wim leersComment #5
tim.plunkettDo you think this needs tests to prove exactly WHY we need this change?
Comment #7
tim.plunkettHmm, that switch was fine for block plugins, because they were already doing the correct form_state manipulate to only pass the appropriate values along.
My guess (without actually looking at editor plugins) is that all of their $form_state->getValue calls were relative to the editor form itself, and not just it's own form valudes
Comment #8
wim leersThis is true. See
\Drupal\ckeditor\Plugin\Editor\CKEditor::settingsFormSubmit():Does this mean we can't do this until D9? I think we can predict what catch will say about that :)
How about we do something like:
settingsFormSubmit(), or the newsubmitConfigurationForm().Comment #9
tim.plunkettHow about this?
Comment #10
wim leersI'd like to see this patch without these changes, because that would prove it doesn't break BC.
Alternatively, make this change, but then we'll need to add test coverage for this, probably to
\Drupal\Tests\editor\Unit\EditorBaseTest.Isn't this always going to be true, because of line 175, which always does
$form_state->set('editor_plugin', $plugin);?Comment #11
tim.plunkettWell, this is only set when $editor is truthy, so I thought it best to check.
Uploading a version without the CKEditor changes, but also a full patch with test coverage.
Comment #12
tim.plunkettWim pointed out that I should not change the existing coverage, just add more.
Interdiff is against #9
Comment #13
wim leersThanks! Very close to RTBC.
Just one small thing left:
These comments are the same as the original ones.
They should say something like
settingsForm() uses SubFormState and is deprecated in favor of buildConfigurationForm() which uses FormState, the BC layer ensures they are have the same results.Repeat for all three.
This should also update the CR at https://www.drupal.org/node/2819753.
Comment #18
tim.plunkettReroll. Did not address #13 yet.
Comment #20
tim.plunkett#3002933: Fix "The Drupal\editor\Plugin\EditorBase::settingsFormSubmit method is deprecated since version 8.3.x and will be removed in 9.0.0." and friends rewrote editor plugins to use PluginFormInterface.
So, another reroll.
Comment #21
wim leers🥳 Thanks, Tim! 🙏
Addressed my own nits in #13.
Comment #22
larowlan😎
Committed ef01478 and pushed to 8.8.x. Thanks!
Comment #24
larowlanCan we get those change record updates please (or the tag removed).
Thanks!
Comment #25
wim leersChange record updated: https://www.drupal.org/node/2819753/revisions/view/11495020/11528210