Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding my first CKEditor plugin using Twitter Bootstrap Icons
    primarykey
    data
    text
    <p>following this <a href="http://docs.cksource.com/CKEditor_3.x/Tutorials/Timestamp_Plugin" rel="nofollow">tutorial</a> I'm trying to create my first plugin for CKEditor, the main idea here is to allow users to pick from a SELECT element any (just one at time) of the icons as in <a href="http://twitter.github.io/bootstrap/base-css.html#icons" rel="nofollow">here</a> What I need to build and don't know how is a SELECT element that contains every class of those elements "icon-circle-arrow-up", "icon-globe" and so on so users can pick and write the code wherever they want and if it's possible render the element on the CKEditor area, of course Twitter Bootstrap class should be include as CSS links. What I have done so far is just this piece of code:</p> <pre><code>CKEDITOR.plugins.add('twitter-icons', { init: function(editor) { editor.insertHtml(); } }); </code></pre> <p>Where <code>insertHtml()</code> will write to editor something like <code>&lt;i class="some_class"&gt;&amp;nbsp;&lt;/i&gt;</code> and where <code>some_class</code> should take the value picked by users in the SELECT element. Any help or ideas in how to continue from here?</p> <p><strong>Update 1</strong> After research I got this:</p> <pre><code>CKEDITOR.plugins.add("tbootstrap", { requires: ["richcombo"], init: function(editor) { var config = editor.config, lang = editor.lang.format; var tb_icons = []; //new Array(); tb_icons[0] = ["&lt;i class='icon-glass'&gt;&amp;#8203;&lt;/i&gt;", "icon-glass", "icon-glass"]; tb_icons[1] = ["&lt;i class='icon-music'&gt;&amp;#8203;&lt;/i&gt;", "icon-music", "icon-music"]; tb_icons[2] = ["&lt;i class='icon-search'&gt;&amp;#8203;&lt;/i&gt;", "icon-search", "icon-search"]; tb_icons[3] = ["&lt;i class='icon-envelope'&gt;&amp;#8203;&lt;/i&gt;", "icon-envelope", "icon-envelope"]; tb_icons[4] = ["&lt;i class='icon-heart'&gt;&amp;#8203;&lt;/i&gt;", "icon-heart", "icon-heart"]; tb_icons[5] = ["&lt;i class='icon-star'&gt;&amp;#8203;&lt;/i&gt;", "icon-star", "icon-star"]; tb_icons[6] = ["&lt;i class='icon-star-empty'&gt;&amp;#8203;&lt;/i&gt;", "icon-star-empty", "icon-star-empty"]; tb_icons[7] = ["&lt;i class='icon-user'&gt;&amp;#8203;&lt;/i&gt;", "icon-user", "icon-user"]; tb_icons[8] = ["&lt;i class='icon-film'&gt;&amp;#8203;&lt;/i&gt;", "icon-film", "icon-film"]; tb_icons[9] = ["&lt;i class='icon-th-large'&gt;&amp;#8203;&lt;/i&gt;", "icon-th-large", "icon-th-large"]; tb_icons[10] = ["&lt;i class='icon-th'&gt;&amp;#8203;&lt;/i&gt;", "icon-th", "icon-th"]; editor.ui.addRichCombo("tbootstrap", { label: "TB Icons", title: "TB Icons", voiceLabel: "TB Icons", className: "cke_format", multiselect: false, panel: { css: [config.contentsCss, CKEDITOR.getUrl(CKEDITOR.skin.getPath("editor") + "editor.css")], voiceLabel: lang.panelVoiceLabel }, init: function() { this.startGroup("tbootstrap"); for (var this_tag in tb_icons) { this.add(tb_icons[this_tag][0], tb_icons[this_tag][1], tb_icons[this_tag][2]); } }, onClick: function(value) { editor.focus(); editor.fire("saveSnapshot"); editor.insertHtml(value); editor.fire("saveSnapshot"); } }); editor.insertHtml(); } }); </code></pre> <p>But I'm getting this error while trying to insert the element in the editor:</p> <blockquote> <p>SyntaxError: missing ) after argument list CKEDITOR.tools.callFunction(156,'​'); return false;</p> <p>SyntaxError: missing ) in parenthetical void('​')</p> </blockquote> <p>Any ideas?</p> <p><strong>Edit 2</strong> Tried this:</p> <pre><code>tb_icons[0] = ['&lt;i class=%27icon-glass%27&gt;&amp;#8203;&lt;/i&gt;', "icon-glass", "icon-glass"]; tb_icons[1] = ['&lt;i class=%27icon-music%27&gt;&amp;#8203;&lt;/i&gt;', "icon-music", "icon-music"]; </code></pre> <p>And this too:</p> <pre><code>tb_icons[0] = ["&lt;i class=%27icon-glass%27&gt;&amp;#8203;&lt;/i&gt;", "icon-glass", "icon-glass"]; tb_icons[1] = ["&lt;i class=%27icon-music%27&gt;&amp;#8203;&lt;/i&gt;", "icon-music", "icon-music"]; </code></pre> <p>Then in <code>onClick()</code> function change this:</p> <pre><code>editor.insertHtml(unscape(value)); </code></pre> <p>And the results are the same meaning same error</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.
 

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