Note that there are some explanatory texts on larger screens.

plurals
  1. POCKEditor default style for styleCommand (format styles with buttons)
    text
    copied!<p>I have created a CKEditor plugin which does the base p, h2, h3, h4 formatting with custom buttons (instead of the stylescombo). It works great, but if I uncheck an element (ex. 'h2'), sets the 'div' tag as parent element for the row. I want to be the 'p' as the default element and also the 'p' button can't be unchecked (unless I clicking on another, ex. 'h2' button). How is this possible?</p> <p>The plugin looks like:</p> <pre><code>CKEDITOR.plugins.add('stylesbuttons_custom',{ lang:'en', icons:'p,h2,h3,h4', init:function(editor){ var order=0; var addButtonCommand=function(buttonName,buttonLabel,commandName,styleDefiniton){ if (!styleDefiniton) return; var style=new CKEDITOR.style(styleDefiniton); editor.attachStyleStateChange(style,function(state){ !editor.readOnly &amp;&amp; editor.getCommand(commandName).setState(state); }); editor.addCommand(commandName,new CKEDITOR.styleCommand(style)); if (editor.ui.addButton){ editor.ui.addButton(buttonName,{ label:buttonLabel, command:commandName, toolbar:'basicstyles,'+(order+=10) }); } }; var lang=editor.lang.stylesbuttons_custom; 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'}); } }); </code></pre> <p>I load the plugin like:</p> <p><code>config.extraPlugins='stylesbuttons_custom';</code></p> <p>I put buttons to toolbar like:</p> <p><code>config.toolbar:[['P','H2','H3','H4','Pre']];</code></p> <p>Here is a screenshot about the problem: <img src="https://i.stack.imgur.com/GNJ8o.jpg" alt="enter image description here"></p>
 

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