Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
_edit_get_wysiwyg_info() and hook_edit_wysiwyg_info() are evil, crappy and designed to be temporary. We must convert this to use the plugin system.
Core should ship with a plugin that integrates Aloha Editor with Edit. Contrib could replace that plugin with one that integrates with another WYSIWYG editor, or even with *any* WYSIWYG editor.
Comments
Comment #0.0
Wim LeersUpdated issue summary.
Comment #0.1
Wim LeersUpdated issue summary.
Comment #1
yched CreditAttribution: yched commentedAs a preliminary step to ease later migration to plugins, the array keys in your current hook_edit_wysiwyg_info() should use underscores instead of spaces. Plugin's annotation reader doesn't support spaces, so you'd have to convert those entries, which is always tedious / error prone / raises "wtf ?"s in reviews :-)
Comment #2
Wim LeersThat is a super helpful hint, thanks @yched! :) If you have any more directions on how you'd like to see this implemented: let me know!
Comment #3
Wim LeersDone. I'm sure this can be significantly cleaned up in the future though.
http://drupalcode.org/project/edit.git/commit/987c2dc
Comment #4
yched CreditAttribution: yched commentedA couple remarks on the commited code :
in function _edit_wysiwyg_get_field_editor() :
The usual core practice is to put the Manager in a DIC entry at 'plugin.manager.[owner].[plugin_type]', using a
class EditBundle extends Bundle
in edit module.Dunno if this would help here, but if your plugin classes extend PluginBase, then plugin objects can access their own definition with $plugin->getDefinition(). Would it allow getting rid of your $wysiwyg_plugin['definition'] here ?
in ProcessedTextPropertyEditorManager:
This just in, but we're settling on a stacked notation, for legibility:
Strictly speaking we should be passing $this->discovery instead of $this.
Some of the core code had to pass $this because of a WTF around #1764278: Run PluginManagerBase::processDefinition() in a ProcessDecorator, but this just got fixed, and we'll be returning to passing $this->factory.
Nitpick: ProcessedTextPropertyEditorManager / ProcessedTextPropertyEditorInterface
Is there a way the class names could be simplified a bit ? :-)
Comment #5
yched CreditAttribution: yched commentedAlso, minor :
Core settles on lower case (and thus underscore separated I guess, even though we don(t have multi words examples right now) for the 'plugin type name'.
EntityManager uses 'Entity', but that one is a bit special because it's owned by a Component rather than a module - it's also heavily rediscussed right now.
Comment #6
Wim Leers*Thanks*, yched! :)
I looked a lot at Aggregator.module's implementation and there it is not done…
RE: simplification and pluginBase: I'm now using pluginBase — thanks a lot for the tip! :) At least somewhat less hacky now :)
RE: stacked notation for legibility: THANK YOU. Before it was a nightmare :P
RE: factory: okay, fixed, I was just doing what other examples in core were doing.
RE: plugin type naming: from what I've read, I understood that class-based things are fine to use CamelCase, the lowercase stuff is more for legacy reasons (familarity with previous APIs)?
RE: "Nitpick: ProcessedTextPropertyEditorManager / ProcessedTextPropertyEditorInterface", well I wanted to be as clear as possible. It encapsulates the whole: this is about making editors (not just WYSIWYG editors) pluggable for not plain text fields, but for processed text fields, and the proper Create.js term is "PropertyEditor widgets". (I already cut off the "widget" part.) I also much prefer conciseness, but for now I think this is best. I'm very much open to suggestions though :)
Commit: http://drupalcode.org/project/edit.git/commit/1f5004b.
Comment #7
yched CreditAttribution: yched commentedHappy to hear it could remove some hacks :-)
Yeah, aggregator was the 1st plugin that went in (possibly as part of the initial plugin API patch), so that was not really settled at this point. It should be fixed. All other plugin types that went in since then put their manager in the DIC.
Re: CamalCase as the $plugin_type string used as a second param for AnnotatedClassDiscovery :
no legacy reason here, plugins using AnnotatedClassDiscovery could have provided any kind of string they want (as long as they're suitable for a folder filename), and right now they all use lowercase, underscored strings - again, except EntityManager which is a bit special.
Actually, I think the main reason core currently uses lowercae for this is to have consistency with the name of the entry in the DIC :
plugin.manager.[owner].[plugin_type]
[owner] and [plugin_type] are lowercase-underscore there, and the same strings are used as params for AnnotatedClassDiscovery (i.e as folders in the lib/[module]/Drupal/Plugin tree.
So the two changes (DIC + lowercase) are actually related :-)
Comment #8
yched CreditAttribution: yched commentedClass naming : I'd tend to go with something like RichTextEditorPluginManager / RichTextEditorInterface - but well, I'm not really involved in the Create code and thus probably have a much more liberal bias regarding strict accuracy here ;-)
Note that we're namespaced, though, so perhaps some of the accuracy can be taken care of by the namespace part.
Comment #9
Wim LeersRE: CamelCase -> underscores & DIC: Done.
RE: "RichTextEditor": the problem is that this is not limited to Rich Text Editors (RTEs). I wouldn't call BU Editor (here on d.o) an RTE. Nor would I call http://oscargodson.github.com/EpicEditor/ an RTE. They're just "processed text" editors. We could decide to call them RTE's for simplicity's sake, but it wouldn't be accurate.
I did rename it from ProcessedTextPropertyEditorBase/Manager to ProcessedTextEditorBase/Manager; that's already much shorter and still stresses the "processed text" part.
Why not just go with "editor" as the name used in the DIC? Because also non-textual fields have "editors", and thus that would be confusing.
Commit again: http://drupalcode.org/project/edit.git/commit/244c9f7 :)
Comment #10
yched CreditAttribution: yched commentedCool - yes, ProcessedTextEditor[Interface\Base|Manager] sound better already :-)
Comment #11.0
(not verified) CreditAttribution: commentedUpdated issue summary.