2

I know there is "Paste Text" button in CKEditor, and I can limit allowed HTML tags.
But it's very hard to explain clients to use specific button when they insert text.
As result they often insert "dirt" texts with HTML tags.

As I remember there was setting in early versions of CKEditor to force insert plain text by default but cannot find it in current version.

Is there any solution for the problem?

UPDATE: I don't want to restrict user to use some tags. But user should get "clean" plain text without HTML tags when insert text.

  • By insert, do you mean typing or 'regular' pasting? For me insertion is typing, but if no HTML is allowed, ckeditor makes no sense. – Neograph734 Sep 14 at 3:50
  • By insert I mean paste (ctrl-V). HTML is allowed. I don't want to restrict user to use some tags. But user should get "clean" plain text when insert it. I would like ctrl-V works as "Paste Text" button by default. – Dimetry Sep 14 at 4:01
1

You want to change the ckeditor configuration to always paste as plain text.

This defined in https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-forcePasteAsPlainText

It comes down to the following JavaScript configuration:

// All content will be pasted as plain text. 
config.forcePasteAsPlainText = true;

Have a look here for where to set it Is there advanced configuration for CKEditor in Drupal 8?

Or just use module CKEditor custom config and set in custom configuration: forcePasteAsPlainText = true

| improve this answer | |
  • Many thanks. It really helped. If you refer to CKEditor custom config module I'll accept it as answer. – Dimetry Sep 16 at 9:33
  • I deliberately did not because there are apparently multiple methods to get the config working. Therefore the other topic provides a more complete overview of the options. – Neograph734 Sep 16 at 9:35
1

Eventually I used module CKEditor custom config and set in custom configuration: forcePasteAsPlainText = true

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.