Problem/Motivation
Nonsensical situations that are currently not prevented by the UI:
- Enabling CKEditor for a Markdown-powered text format.
- Enabling CKEditor while the
filter_autop
(orfilter_url
) filter is enabled.
(If it doesn't make sense to you that using filter_autop
and filter_url
precludes you from using CKEditor, then please read #1911884: Enable CKEditor in the Standard install profile and #1933896: Prevent enabling a text editor if a text format has one or more FILTER_TYPE_MARKUP_LANGUAGE filters enabled FIRST.)
Proposed resolution
As of #1782838: WYSIWYG in core: round one — filter types, filters can have types. filter_autop
and filter_url
are marked as FILTER_TYPE_MARKUP_LANGUAGE
, because they are in effect extremely minimal markup languages.
Whenever >=1 FILTER_TYPE_MARKUP_LANGUAGE
-type filter is enabled, we should disallow the enabling of a text editor.
Remaining tasks
- Get feedback. Figure out how to deal with edge cases, like http://oscargodson.github.com/EpicEditor/ — a Markdown "WYSIWYG" editor.
- Write the code. Should probably use Drupal core's dialog and/or
#states
.
User interface changes
TBD
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#25 | 1933896-25.patch | 8.31 KB | oknate |
#25 | 1933896-interdiff--22-25.txt | 4.31 KB | oknate |
#22 | 1933896-22.patch | 8.46 KB | oknate |
#22 | 1933896--interdiff-20-22.txt | 7.32 KB | oknate |
#20 | 1933896-20.patch | 8.48 KB | oknate |
Comments
Comment #1
NaheemSays CreditAttribution: NaheemSays commentedIn the cases where it is sometimes necessary to disable the wysiwyg, filter_autop along with http://drupal.org/project/wysiwyg_linebreaks is something which makes it all a little more useable, so I would as an end user like that sort of functionality to remain in parallel with the use of an editor.
Comment #1.0
NaheemSays CreditAttribution: NaheemSays commentedExplain edge case.
Comment #2
quicksketchIn #1933916-2: [meta] How do we want to facilitate enabling of CKEditor for sites upgraded from Drupal 7 to Drupal 8?, I posted a long comment about dealing with auto-p (and could be applied to auto-url also). This issue should move forward since it is important for formats that are truly irreversible. In the other issue, we can consider changing the type of auto-p and auto-url filters from FILTER_TYPE_MARKUP_LANGUAGE to FILTER_TYPE_TRANSFORM_REVERSIBLE, so they wouldn't be affected by this restriction.
Comment #3
sunOnly CKEditor can be disallowed for non-HTML formats. Other editors might be explicitly designed to work with a particular markup format.
That said, CKEditor is definitely able to produce BBCode. I wouldn't be surprised if there is a plugin for it that make it produce Markdown.
Likewise, editors like http://markitup.jaysalvat.com/home/ are capable of producing various markup formats.
Consequently, a HTML vs. no-HTML markup format differentiation doesn't make much sense. We rather have to map individual editors to markup formats, whereas enabling certain editor plugins can enable an editor for a different markup format.
Comment #4
quicksketchI kind of agree here also. Maybe we need a registry of markup languages to text editors? By default it would be an empty list (or possibly include auto-p/auto-a as compatible with CKEditor, depending on the outcome of #1933916: [meta] How do we want to facilitate enabling of CKEditor for sites upgraded from Drupal 7 to Drupal 8?).
However if we convert auto-p/auto-a to be FILTER_TYPE_TRANSFORM_REVERSIBLE, we end up with no really dangerous/disallowed configurations of the included core filters and editors, mitigating this entire problem somewhat. If a contrib module adds new filters that aren't compatible with a particular WYSIWYG, I would think a notice on the project page or in the README would probably suffice.
Comment #5
Wim Leers#3 focuses on the unanswered question of edge cases. I personally agree, but it means we must add more metadata to both text formats and text editors.
The last paragraph of #4 suggests we don't have to solve this problem at all. What are your thoughts on that, sun? I guess it's true that people who are sufficiently advanced that they install additional text editors or filters know what they're doing, in which case this issue is moot.
Comment #6
Wim LeersSo:
filter_autop
in the text format, when combined with e.g. https://drupal.org/project/wysiwyg_linebreaks (which has already been ported to Drupal 8 by now!).However, the whole point of this issue is to protect the user against mistakes, so that he is warned/prevented from creating text format + associated text editor configurations that break things. That is achievable, as #3 and #4 indicate. But not without introducing a whole lot of additional complexity.
That additional complexity would be:
FILTER_TYPE_MARKUP_LANGUAGE
declares whichmarkup_language
(that would be the key) it is for (html
,markdown
…) — and when no such filter is enabled, assumehtml
.FILTER_TYPE_MARKUP_LANGUAGE
filters with non-identical markup languages are enabled. I.e. JS to track this, showing a modal whenever the user makes a mistake.In other words: a bit extra metadata, and quite a lot of extra JS to protect the user.
The question is: is this worth the effort? How many non-expert users (i.e. who don't need this protection) are going to install custom markup languages? Isn't the majority of non-expert users just going to stick with what core provides and use/configure CKEditor, potentially installing additional CKEditor plugins? As long as users stick to 1) HTML, 2) CKEditor, they're going to have excellent protection/guidance already.
Hence demoting the priority to minor.
(FWIW: other text editors, such as TinyMCE and Aloha Editor and whatnot can also implement this protection/guidance, APIs are provided for that. So please don't get agitated by the fact that I'm calling out CKEditor specifically in the above :))
Comment #7
NaheemSays CreditAttribution: NaheemSays commentedI suspect a few people will add either smileys/emoticons or bbcode to atleast some plugins. Either that or a video filter.
People especially coming from other forum software will be used to such features.
Comment #7.0
NaheemSays CreditAttribution: NaheemSays commentedUpdated issue summary.
Comment #14
oknateComment #15
oknateWhat if we just add a warning? Here's a patch that does this.
I think we can allow people to do something foolish. If we do want to add validation still, I think I need it explained to me a bit more.
This doesn't make when sense for a workflow in which the editor CKEditor is already selected. I think more often than not, the editor would be selected before enabling filters.
If it is simply when any FILTER_TYPE_MARKUP_LANGUAGE filter is enabled, we prevent the enabling of a text editor, how do we tell if an editor is a text editor? Are all editors text editors? I'm not as familiar with editor plugins.
Comment #16
oknateHere's a screenshot of patch #15:
Comment #17
oknateHere's some validation. It hard codes the two filters in core of type
Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE
, rather than finding any filter where the type is type isDrupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE
.It could be abstracted more, I guess.
I had some trouble with the HTML within the label of the filter_autop: I ended up using htis code:
Html::decodeEntities(strip_tags($get_filter_label('filter_autop')))
. If there's a better solution, let me know.Comment #18
oknateComment #19
oknateScreenshot of #17:
Comment #20
oknateAbstracting it, and adding test coverage. Also, I was able to do away with this:
Html::decodeEntities(strip_tags($get_filter_label('filter_autop')))
As far as edge cases, perhaps we should just handle CKEditor in the validation? Or just leave the warning (see #15)?
Comment #22
oknateTrying this again, the last version passed locally, but not on testbot. Trying
responseContains
instead ofpageTextContains
.Also changed the verbiage slightly.
Comment #24
oknateAssigning to myself to fix the test and coding standard issues. I don't know what's going on. It's passing locally, but failing on testbot.
Comment #25
oknateI pulled down the latest, and instead of it showing the first form error, it shows the last. So I guess that's a new change. Updated the test to only set one of the filters at a time, so that we can see the first message. (With both filters turned on, only the second form error displays.) Also, fixed coding standard errors.
Comment #33
Wim LeersThanks @smustgrave for pointing me here again!
In the ~3 years since then, the equivalent of this was implemented as a validation constraint inside CKEditor 5 specifically:
\Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator::checkNoMarkupFilters()
.Still, this should be done universally, for all text editors, arguably. OTOH … perhaps it's fine to keep it as-is, because of
as mentioned in the issue summary.Thinking about this more, I think that's actually the only sane conclusion: doing this after all this time will for sure break the existing non-HTML assistive text editors and would be too disruptive for too little gain.
This may come up again in #3231354: [PP-1] [META] Discuss: merge the Editor config entity into the FilterFormat config entity.