Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, @Reinmar notifies that there is an error in the CKEditor's style.js where the this._.enterMode is not defined.</p> <p>Doing this on style.js, resolve the problem:</p> <pre><code>this._ = { definition: styleDefinition, enterMode: CKEDITOR.config.enterMode }; </code></pre> <p>And from now on when a style button is unchecked the block changes to the default 'p' element.</p> <p>Now my complete working plugin looks like:</p> <pre><code>(function(){ CKEDITOR.plugins.add('custombuttons',{ lang:'hu,en,de,ro', init:function(editor){ var order=0,t=this,lang=editor.lang.custombuttons; // addButtonCommand helper var addButtonCommand=function(buttonName,buttonLabel,commandName,styleDefiniton){ var style=new CKEDITOR.style(styleDefiniton); var styleCommand=function(style){ this.style=style; this.allowedContent=style; this.requiredContent=style; this.contextSensitive=true; }; styleCommand.prototype={ exec:function(editor){ editor.focus(); if (this.state==CKEDITOR.TRISTATE_OFF) editor.applyStyle(this.style); else if (this.state==CKEDITOR.TRISTATE_ON) editor.removeStyle(this.style); if(commandName!='fakecommand'){editor.execCommand('fakecommand');editor.execCommand('fakecommand');} /* hack to change button state properly */ }, refresh:function(editor,path){ this.setState(path&amp;&amp;this.style.checkApplicable(path)?(this.style.checkActive(path)?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF):CKEDITOR.TRISTATE_DISABLED); } }; editor.addCommand(commandName,new styleCommand(style)); if(editor.ui.addButton){editor.ui.addButton(buttonName,{label:buttonLabel,command:commandName,toolbar:'basicstyles,'+(order+=10),icon:t.path+'images/'+commandName+'.png'});} }; // _fakebutton (hack) addButtonCommand('_fakebutton','','fakecommand',{element:'span'}); // style buttons addButtonCommand('P',lang.p,'p',{element:'p'}); addButtonCommand('H2',lang.h2,'h2',{element:'h2'}); addButtonCommand('H3',lang.h3,'h3',{element:'h3'}); addButtonCommand('H4',lang.h4,'h4',{element:'h4'}); addButtonCommand('Pre',lang.pre,'pre',{element:'pre'}); addButtonCommand('Mini',lang.mini,'mini',{element:'p',attributes:{class:'mini'}}); addButtonCommand('Important',lang.important,'important',{element:'span',attributes:{class:'important'}}); addButtonCommand('Comment',lang.comment,'comment',{element:'span',attributes:{class:'comment'}}); addButtonCommand('Mark',lang.mark,'mark',{element:'mark'}); addButtonCommand('ImgLeft',lang.imgLeft,'imgLeft',{element:'img',attributes:{class:'imgleft'}}); addButtonCommand('ImgRight',lang.imgRight,'imgRight',{element:'img',attributes:{class:'imgright'}}); addButtonCommand('ImgCenter',lang.imgCenter,'imgCenter',{element:'img',attributes:{class:'imgcenter'}}); // button shortcut keys editor.setKeystroke( [ [CKEDITOR.CTRL+48,'p'], // Ctrl+0 [CKEDITOR.CTRL+49,'h2'], // Ctrl+1 [CKEDITOR.CTRL+50,'h3'], // Ctrl+2 [CKEDITOR.CTRL+51,'h4'], // Ctrl+3 ]); } }); })(); </code></pre> <p>There is still a hack in the code. I needed to run a 'fakecommand' to really update (refilter?) the changed tags and all its parent tags. For example the 'p.mini' button caused problems (the state was not updated) when clicked multiple time. So there is still an unelegant solution. Any idea how to force to update or refilter the code after a style is applied?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload