Index: lams_central/web/includes/javascript/ckconfig_custom.js =================================================================== diff -u -rebf117035c692f7069000d6b7bace23cfc94619a -r394f403c289f0fd7808c228840bead5c4e7d5d32 --- lams_central/web/includes/javascript/ckconfig_custom.js (.../ckconfig_custom.js) (revision ebf117035c692f7069000d6b7bace23cfc94619a) +++ lams_central/web/includes/javascript/ckconfig_custom.js (.../ckconfig_custom.js) (revision 394f403c289f0fd7808c228840bead5c4e7d5d32) @@ -131,7 +131,7 @@ CKEDITOR.config.format_tags = 'div;h1;h2;h3;h4;h5;h6;pre;address;p' ; CKEDITOR.config.enterMode = 'div'; CKEDITOR.plugins.addExternal('wikilink', CKEDITOR.basePath + '../tool/lawiki10/wikilink/', 'plugin.js'); -CKEDITOR.config.extraPlugins = 'wikilink,jlatexmath,image2,html5audio,bootstrapTabs,bootpanel,bootsnippets'; +CKEDITOR.config.extraPlugins = 'wikilink,jlatexmath,image2,html5audio,confighelper,bootstrapTabs,bootpanel,bootsnippets'; CKEDITOR.config.enterMode = CKEDITOR.ENTER_DIV; CKEDITOR.config.removePlugins = 'elementspath,about,specialchar'; CKEDITOR.config.allowedContent = true; @@ -145,6 +145,16 @@ // ---- Additional scripts ----- CKEDITOR.on('instanceReady', function(e){ + //add custom classes + var classes = e.editor.config.classes; + if (classes) { + for (classIter of classes.split(' ')) { + if (classIter) { + e.editor._.editable.$.classList.add(classIter); + } + } + } + //set min-height CSS property var height = e.editor.config.height; if ( ! height ) { @@ -169,4 +179,22 @@ f.data.dataValue = tempDiv.innerHTML; }); + + //function adds "cke_filled" class to CKEditor, if it's not empty. And removes it otherwise. + var placeholderLessenHandler = function(editor) { + var ckeditorData = editor.getData(); + + var isEmpty = (ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|

|<\/p>|\xa0/g, "").length == 0); + if (isEmpty) { + editor._.editable.$.classList.remove("cke_filled"); + } else { + editor._.editable.$.classList.add("cke_filled"); + } + } + //add cke_filled class on editor's instanceReady + placeholderLessenHandler(e.editor); + //add cke_filled class on editor gets changed + e.editor.on('change', function(event) { + placeholderLessenHandler(event.editor); + }); });