Important Notice: Effective immediately, all support will be handled through Discord. Read more about the changes coming to Anodyne's services.

[MOD] CKEditor / WYSIWYG

A place to show off (and others to download) completed MODs. Note: support for MODs is handled by third parties, not Anodyne Productions.

Williams Thu Jun 01, 2017 4:37 pm

[MOD] CKEditor / WYSIWYG

A little while ago I started playing around with What You See Is What You Get (WYSIWYG) editors on my site, and after going through a couple of options settled on using CKEditor. Due to the way that Nova handles text (preserving new line characters in the database and converting them to brs on the fly) contrasting with how these editors work (usually defaulting to wrapping every paragraph in p tags or adding br tags in as you type), I had to find an editor that allowed a good deal of customisation, and I also had to modify how Nova dealt with post content (removing brs before insertion to the database as there was no option to just turn the adding of those tags off and then adding them back in when a post is called up for editing). CKEditor was a good fit for this and the Highlander has been running with it for a few months now. I've been asked to provide the plugin for others to use, and although there are still a few wrinkles in the implementation I think it's at a good enough point for people to utilise it now, so I've packaged it up into a mod.

The mod has been uploaded at https://xtras.anodyne-productions.com/i ... e/ckeditor. I'd recommend that anyone who uses the mod watches my GitHub repo for it at https://github.com/mtwilliams5/nova_mod_ckeditor which will be the first place to see any minor updates I make to address issues as they come up. Any issues with using the mod you can either raise here or on the GitHub page under issues - that last one is more likely to get it noticed by me, but I'll make sure to check the forums here regularly anyway to catch anything here as well.

One thing to note for anyone using this mod is that we found it took a bit of time for people to get used to using the editor for styles instead of using HTML tags directly. Once users got used to using the editor it works fine (you can even use keyboard shortcuts such as Ctrl+B instead of having to click the relevant buttons), but until then you may need to go in and re-edit posts and remind users about using the editor functions, as it will convert most html tags into HTML elements and treat the characters literally.
Matt aka
Krace / Williams

USS HighlanderMy Xtras Profile
ImageImage

Posts: 288


AgentPhoenix Thu Jun 01, 2017 9:26 pm

Re: [MOD] CKEditor / WYSIWYG

Awesome work! I may want to pick your brain about editors at some point as I'm looking at what makes the most sense for Nova 3 as well as the new forums that I'm building.
User avatar

Posts: 7596


Williams Fri Jun 02, 2017 12:11 am

Re: [MOD] CKEditor / WYSIWYG

Sure thing. The main issue with retrofitting one I've found is dealing with things in a way that is backwards-compatible; as I said above, Nova stores posts in the database with newline characters intact, whereas all of the editors I've found out there want to do things the proper HTML way - defaulting to p tags, but letting you change it to br tags. That's fine if the system is built from the ground up to expect that, but since Nova uses nl2br() a lot, you either end up with lots of double line breaks everywhere, or if you remove instances of that function, the old posts all lose their line breaks.

If Nova 3 is built from the ground up with an editor built in, then I'd say it would be a good idea to look into either converting nls to brs during the upgrade process to keep things consistent, or having something in there that will be able to handle the difference between old posts and new posts (a value in the DB maybe that the post comes from Nova 2, and the first time it is accessed for editing the conversion is done on the fly and that value is then removed, maybe?).

It'd also be good to include the ckeditor files (or whatever other editor may get used, as I assume other would work similarly) with the install like you do with jquery - I didn't here just so that it's easier to upgrade versions and the download size is smaller, but pulling the code from a cdn means that any relative paths in the custom config are relative to the file you're pulling in, meaning you have to set absolute paths in the config instead of relative.
Matt aka
Krace / Williams

USS HighlanderMy Xtras Profile
ImageImage

Posts: 288



Return to Nova MODs

Who is online

Users browsing this forum: No registered users and 1 guest

cron