English version was created automatically using Drupal module auto_node_translate and free DeepL translator.
Drupal 8 and CKeditor - how to cancel inserting formatted text from Word
zveřejněno 2020-06-29
If you insert (CTRL+V ) text from Word into the CKeditor field, quite often some unwanted code gets in there, like spany ... Asking users to remember and use the CTRL+SHIFT+V shortcut is unrealistic in practice. Fortunately CKEditor itself can do it, now just how to do it in Drupal.
Default Configuration
In Drupal, or rather in the CKEditor configuration for text formats, you can choose some options for embedding, but none of it works properly.

Not even some existing modules like CKEditor Pastefromword https://www help.drupal.org/project/ckeditor_pastefromword.
Only editing the CKEditor configuration will really help.
Edit CKEditor Configuration
There are configuration options for CKEditor that set all sorts of things. However, in Drupal 8 it is no longer possible to add configuration options directly, but fortunately there is a CKEditor custom config module for this https://www.drupal.org/project/ckeditor_config
After installing it (currently version 8.x-3.0) will show a new CKEditor Custom Configuration option for CKEditor-enabled text format:

Our code will contain three lines:
pasteFromWordPromptCleanup=false
forcePasteAsPlainText=true
basicEntities=false
The first removes the pop-up box asking for an insert, the second removes the HTML tags, and the third option will prevent the insert &.
Let's demonstrate with an example. I created a simple formatted text in Word. When pasted in by default, it looked like this:


After applying the above 3 options, the plain text is pasted in.
Custom Module
In my case - where I have several different text formats defined - the above would need to be set everywhere. And on top of that via the contrib module. So I preferred to create a custom module where the settings are applied automatically. It's nothing complicated, it's just a few lines when using hook_editor_js_settings_alter(). where the editor['editorSettings'] variable is set.

Conclusion
So finally, CKeditor works exactly the way I want it to, without bothering users unnecessarily. And pasting text from Word generates clean unformatted code.