ullright - ckEditor

Cheatsheet

Custom paste cleanings

ullright: web/js/CKeditor_config.js

  CKEDITOR.on('instanceReady', function(ev) {
    ev.editor.on('paste', function(evt) {
        if (evt.data['html']) {
         
          // Force word import cleanup on every paste, not only word
          // From http://stackoverflow.com/questions/5227140/ckeditor-use-pastefromword-filtering-on-all-pasted-content/8379364#8379364
          evt.data['html'] = '<!--class="Mso"-->'+evt.data['html'];
         
          // Remove <p> tags in <li> tags
          var doc = document.implementation.createHTMLDocument("");
          doc.documentElement.innerHTML = evt.data['html']
          $(doc).find('li p').each(function() {
            $(this).replaceWith($(this).html());
          });
          evt.data['html'] = doc.documentElement.innerHTML;

          // Replace <p class="headline01"> with h2
          var regex = /<p class="headline01">([^<]*)<\/p>/g;
          evt.data['html'] = evt.data['html'].replace(regex, 
            function (match, inner) {
              return '<h2> '+ inner + '</h2>';
          });
         
        }
    }, null, null, 9);
  });
 
  config.pasteFromWordPromptCleanup = false;
  config.pasteFromWordRemoveFontStyles = true;
  config.pasteFromWordRemoveStyles = true;

 

HTML entites handling

config.basicEntities = true;
config.entities = false;

ullright CKEditor config is: encode basic entities (nbsp, gt, lt, amp) but do not encode other entities (umlauts,...) to allow easy database text-search

 

Upgrade

  • Download new Version
  • Replace old files in /web/ullCorePlugin/js/ckeditor with new ones
  • ? Delete directories starting with "_"
  • Recreate symlinks
    • cd plugins/ullCorePlugin/web/js/ckeditor/plugins/
    • ln -s ../../ckeditor_plugins/shybutton/ shybutton
    • ln -s ../../ckeditor_plugins/ullLink/ ullLink
    • cd ../../../../../../
    • svn add plugins/ullCorePlugin/web/js/ckeditor
    • svn commit plugins/ullCorePlugin/web/js/ -m 'Upgraded CKEditor'

Problems

Race condition while loading several customConfig files
http://dev.ckeditor.com/ticket/6504

Not possible to set a body class for the styles dropdown
https://dev.ckeditor.com/ticket/7452

Forum post:
http://cksource.com/forums/viewtopic.php?f=6&t=27293

Custom dialoge

http://docs.cksource.com/CKEditor_3.x/Tutorials/SimpleLink_Plugin_Part_1

http://blog.xoundboy.com/?p=393

http://www.codingfriends.com/index.php/2010/12/10/ckeditor-custom-dialog/

http://theholyjava.wordpress.com/2011/04/04/how-to-customize-ckeditor-with-your-own-plugins-skins-configurations/

Totally custom
http://www.mikee.se/Archive.aspx/Details/plugin_existing_code_into_ckeditor_20100201

Disabling context menu entries
http://alfonsoml.blogspot.co.at/2009/12/adjusting-context-menu-of-ckeditor.html