Jump to content

CKEditor - trying to modify HTML-output with plugin htmlWriter


nurkka
 Share

Recommended Posts

Hi,

CKEditor generates <br /> instead of <br>, so I searched a method, to replace trailing slashes in self closing html tags.

I found the CKEditor plugin Htmlwriter, which does just that, and installed it in /site/modules/InputfieldCKEditor/plugins/ in it's own subdirectory /htmlwriter/. Next I activated the plugin in my field configuration (field »body«) in the backend and added the required settings as JSON ({"selfClosingEnd": ">"}) to the now available »Htmlwriter settings« field.

But that didn't work. So, I placed some debug code in Htmlwriter's plugin.js (console.log('plugin loaded') ;), but the message never showed up in the console. The same debug code in e.g. /wire/modules/Inputfield/InputfieldCKEditor/plugins/sourcedialog/plugin.js showed up perfectly.

So, I assume the /site/modules/InputfieldCKEditor/plugins/htmlwriter/plugin.js isn't included at all, although it's configured in the field settings.

I also get no error message, no 404s in the network panel or something like that.

Additionally, if I try to set configuration settings in /site/modules/InputfieldCKEditor/config.js or /site/modules/InputfieldCKEditor/config-body.js they are ignored, while settings in the »Custom Config Options« field in the field settings work perfectly.

Does anybody know what I am missing here?

How is it possible to set up this CKEditor plugin properly in ProcessWire?

Thanks in advance!

Link to comment
Share on other sites

Thanks for your reply, LostKobrakai. I tried to put the plugin under /wire/, but that didn't work either.

Then I renamed the plugin to »htmlwriter2« (located in /site/modules/InputfieldCKEditor/plugins/htmlwriter2/) and surprisingly that worked. I think there is a naming conflict with code in ckeditor.js. Perhaps, the plugin »htmlwriter« is already pre-installed or it has meanwhile been integrated in the CKEditor core. Nonetheless, I couldn't get it to work without installing it as »htmlwriter2«.

Unfortunately, I also had no luck in configuring the plugin via the field settings of my »body«-Field. I tried the following JSON in the »htmlwriter2 settings«:

{"selfClosingEnd": ">"}

But that didn't work. I had to write this setting directly into the plugin file, but I would really like it better to be set via the backend.

You asked, why someone would want to remove the trailing slashes of self closing tags – When I switched from XHTML to HTML5, I decided not to use trailing slashes anymore and I just wanted the HTML output to look equally, even if it comes from CKEditor.

Next I will try to find out how the setting above can be set via the field settings in the ProcessWire backend.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...