kreativgebiet/rich

How to add 'pastefromword' plugin?

Opened this issue · 7 comments

How to enable 'pastefromword' plugin?

I got it running but pasting works correctly only when i paste word text via pressing the PasteFromWord button. When i paste word text directly into editor area the text is being filtered some how and pasted as plain text. How can i get it to work correctly?

@gogainda I believe that is the entire purpose of the PasteFromWord button... no?

I don't think you can have the main WYSIWYG editor work like the PasteFromWord button popup field without modifying the ckeditor tool itself.

Hi!
Paste from Word will only work with the button because of this:
https://github.com/bastiaanterhorst/rich/blob/master/lib/rich.rb#L72

You can enable the pastefromword business by adding vendoring the plugin files and loading the plugin in your initializer:
config.extraPlugins = 'stylesheetparser,richfile,MediaEmbed,PasteFromWord'

@bastiaanterhorst or @gogainda I'm having an issue trying to vendor a CKEditor plugin with rich.

I've downloaded the plugin (Justify) from here: http://ckeditor.com/addon/justify (v4.0.3).

I modified my rich.rb adding:
config.extraPlugins = 'stylesheetparser,richfile,MediaEmbed,Justify'

I then tried putting the unzipped Justify plugin contents at vendor/assets/ckeditor/plugins/Justify, but was getting an error that that file was not found.

I then moved the plugin.js file to vendor/assets/javascripts/ckeditor/plugins/Justify/ and it successfully found the file, however now I'm seeing a JavaScript error:
Uncaught [CKEDITOR.resourceManager.add] The resource name "justify" is already registered. ckeditor.js?body=1:178 Uncaught TypeError: Cannot read property 'icons' of null ckeditor.js?body=1:181

Thoughts?

I was able to get past that by removing the CKEDITOR.plugins.add( 'justify', { from the downloaded plugin's plugin.js file, however I'm still getting the second error mentioned above about the icons.

I was able to get it working. Here were my steps:

# Enable extra CKEDITOR plugins:
#
# HOWTO:
# 1) add the downloaded plugin's JS in: vendor/assets/javascripts/ckeditor/plugins/pluginName
# 2) add the downloaded plugin's button images in: vendor/assets/images/ckeditor/plugins/pluginName/icons
# 3) modify the rich gem's ckeditor build config to disable the plugin if it has already been enabled.
    #      * rich file = /vendor/assets/javascripts/ckeditor/build-config.js
    #      * in my case 'justify' was set to '1' which caused an error saying 'justify' has already been defined
# 4) add to the list of 'extraPlugins'
# 5) add to the list of 'toolbar' buttons
    #      * in my case it wasn't just 'Justify' as the button name, but rather the defined .ui.addButton in the plugin's plugin.js file
config.editor[:extraPlugins] = 'stylesheetparser,richfile,stylescombo,Justify'
config.editor[:toolbar] = [['Format','Styles'],['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],['Bold', 'Italic', '-','NumberedList', 'BulletedList', 'Blockquote', '-', 'richImage', 'richFile','MediaEmbed', '-', 'Link', 'Unlink'],['Source', 'ShowBlocks']]

Seems like the rich gem's ckeditor/build-config.js should not be marking all of the non-present plugins as "on". Thoughts?