Filter to paste from Google Doc and keep style (bold, italic, underline).
My frst time posting a plugin.
I'm posting my solution in case it is useful to someone. I had this issue with pasting from googleDocs. And I found someone made a branch of CKEditor in github (13877) which corrects this.
But I needed it to work with my version of CKEditor which I cannot change bacause it is integrated with Prcocesswire CMS.
So I wrote this plugin.
The code is originally from Frederico Knabben, written in ckeditor-dev-t-13877 branch (https://github.com/cksource/ckeditor-dev/tree/t/13877) has been adapted in a plugin.
This filter detects all style that is already in the toolbar. So if underline is missing for example you must add it to the toolbar.
Instruction for Processwire :
For processwire, you must edit the field that has CKEditor and make sure that :
- copy the plugin folder in site/modules/InputfieldCKEditor/plugins
- ACF is On
- pasteFromGoogleDoc plugin is enabled
- CKEditor toolbar configuration contains Bold, Italic and Underline
- e.g : Format, Styles, -, Bold, Italic, Underline, -, RemoveFormat
- if Underline is not in the toolbar for example, it will be bypassed by the filter.
The recommended way to install all CKEditor add-ons is to create a custom build by using Online builder. To do that, click the Add to my editor button on the plugin page. When you are done, click the Build my editor button on the right side of the page to go to Online builder.
Note: This add-on is already selected to be a part of your current build.
Add-on installation instructions
If you want to add the plugin manually, you will need to:
- Extract the downloaded plugin
pluginsfolder of your CKEditor installation. Example:
- Enable the plugin by using the
extraPluginsconfiguration setting. Example:
config.extraPlugins = 'pasteFromGoogleDoc';
- Download and configure all its dependencies, too.
Note: The plugin may have additional requirements. Check the add-on page and documentation for more details.