Problem/Motivation

Nonsensical situations that are currently not prevented by the UI:

  1. Enabling CKEditor for a Markdown-powered text format.
  2. Enabling CKEditor while the filter_autop (or filter_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

  1. Get feedback. Figure out how to deal with edge cases, like http://oscargodson.github.com/EpicEditor/ — a Markdown "WYSIWYG" editor.
  2. Write the code. Should probably use Drupal core's dialog and/or #states.

User interface changes

TBD

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NaheemSays’s picture

In 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.

NaheemSays’s picture

Issue summary: View changes

Explain edge case.

quicksketch’s picture

In #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.

sun’s picture

Only 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.

quicksketch’s picture

I 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.

Wim Leers’s picture

#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.

Wim Leers’s picture

Priority: Normal » Minor
Issue tags: -sprint

So:

  1. It is possible to use a text editor when using a custom markup language (BBCode, Markdown, etc.): see #3.
  2. It is possible to use a text editor when using 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:

  1. Each FILTER_TYPE_MARKUP_LANGUAGE declares which markup_language (that would be the key) it is for (html, markdown …) — and when no such filter is enabled, assume html.
  2. Each text editor declares which markup languages (plural!) it can be used on.
  3. Whenever the user adds or remove text format filters, warn the user when >=2 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.
  4. Whenever the user enables a text editor that doesn't match the markup language implied by the enabled filters, also warn the user.
  5. Whenever the user enables a text format filter that is not supported by the associated text editor, also warn the user.

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 :))

NaheemSays’s picture

I 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.

NaheemSays’s picture

Issue summary: View changes

Updated issue summary.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

oknate’s picture

oknate’s picture

Version: 8.6.x-dev » 8.9.x-dev
Status: Active » Needs review
FileSize
1.38 KB

What 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.

Whenever >=1 FILTER_TYPE_MARKUP_LANGUAGE-type filter is enabled, we should disallow the enabling of a text editor.

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.

oknate’s picture

FileSize
247.53 KB

Here's a screenshot of patch #15:

warning for the two plugins

oknate’s picture

Here'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 is Drupal\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.

oknate’s picture

Issue tags: +Needs tests
oknate’s picture

FileSize
77.16 KB

Screenshot of #17:
filter validation

oknate’s picture

Abstracting 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)?

Status: Needs review » Needs work

The last submitted patch, 20: 1933896-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

oknate’s picture

Status: Needs work » Needs review
FileSize
7.32 KB
8.46 KB

Trying this again, the last version passed locally, but not on testbot. Trying responseContains instead of pageTextContains.

Also changed the verbiage slightly.

Status: Needs review » Needs work

The last submitted patch, 22: 1933896-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

oknate’s picture

Assigned: Unassigned » oknate

Assigning 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.

oknate’s picture

Assigned: oknate » Unassigned
Status: Needs work » Needs review
FileSize
4.31 KB
8.31 KB

I 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.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Wim Leers’s picture

Status: Needs review » Closed (works as designed)
Related issues: +#3231354: [PP-1] [META] Discuss: merge the Editor config entity into the FilterFormat config entity

Thanks @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 . Figure out how to deal with edge cases, like http://oscargodson.github.com/EpicEditor/ — a Markdown "WYSIWYG" editor. 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.