CKEditor Custom Plugins Button

I wrote a special plugin for CKEditor - successfully on all fronts, save it for now: I canโ€™t, for life, figure out how to configure the image on the button on the editorโ€™s toolbar. Since Iโ€™m a new user, you need to click to see the attached picture; the selected square in the upper left should have a beautiful picture (like most other elements of the toolbar).

Screenshothot

+44
ckeditor
Jul 16 '09 at 19:28
source share
9 answers

I wrote a complete tutorial covering all aspects of CKeditor plugin development, including buttons, context menus, dialogs, and more.

+71
Jan 26 '10 at 16:32
source share

The answer is to set the button settings icon property as follows:

editor.ui.addButton('your-plugin', { label: 'Your Plugin Label', command: 'YourPlugin', icon: this.path + 'images/your-plugin.jpg' }); 

Your plugins directory should have a "images" subdirectory where your button should go. In the above snippet, replace "your-plugin.jpg" with a JPG, GIF, or PNG image for your button.

This answer, of course, assumes that you know how to create a button image using some kind of graphics editor such as Gimp, Photoshop, etc.

+15
Apr 01 2018-11-11T00:
source share

Some information for others is trying to write plugins for CKEditor 3.0.

I started by copying the source from the plugins / flash and now I got a button with the youtube logo .... this is an excerpt from plugins / youtube / plugin.js

 editor.ui.addButton( 'YouTube', { label : editor.lang.common.youtube, command : 'youtube', icon: this.path + 'images/youtube.gif' }); 

You will also need to edit the language file ... for example. Lang / en.js

Add your plugin name to the "general" section (this displays as a tooltip when you hover over the button) and add an entire block for your plugin with all your lines, for example ...

 // YouTube Dialog youtube : { properties : 'YouTube Properties', propertiesTab : 'Properties', title : 'YouTube Properties', chkPlay : 'Auto Play', chkLoop : 'Loop', chkMenu : 'Enable YouTube Menu', chkFull : 'Allow Fullscreen', scale : 'Scale', scaleAll : 'Show all', scaleNoBorder : 'No Border', scaleFit : 'Exact Fit', access : 'Script Access', accessAlways : 'Always', accessSameDomain : 'Same domain', accessNever : 'Never', align : 'Align', alignLeft : 'Left', alignAbsBottom: 'Abs Bottom', alignAbsMiddle: 'Abs Middle', alignBaseline : 'Baseline', alignBottom : 'Bottom', alignMiddle : 'Middle', alignRight : 'Right', alignTextTop : 'Text Top', alignTop : 'Top', quality : 'Quality', qualityBest : 'Best', qualityHigh : 'High', qualityAutoHigh : 'Auto High', qualityMedium : 'Medium', qualityAutoLow : 'Auto Low', qualityLow : 'Low', windowModeWindow : 'Window', windowModeOpaque : 'Opaque', windowModeTransparent : 'Transparent', windowMode : 'Window mode', flashvars : 'Variables for YouTube', bgcolor : 'Background color', width : 'Width', height : 'Height', hSpace : 'HSpace', vSpace : 'VSpace', validateSrc : 'URL must not be empty.', validateWidth : 'Width must be a number.', validateHeight : 'Height must be a number.', validateHSpace : 'HSpace must be a number.', validateVSpace : 'VSpace must be a number.' } 
+10
Aug 17 '09 at 23:21
source share

these are some plugins for CKEditor 3.x

CKEditor Plugins

Highslide JS Plugin, LrcShow Plugin, FileIcon Plugin, InsertHtml Plugin, SyntaxHighlighter Plugin

Download: CKEditor 3.x Plugins

+4
Dec 15 '09 at 7:38
source share

Try this link. Give you a little more information about creating the CKEditor plugin.

http://www.sayopenweb.com/plugin-for-ckeditor/

+2
Jan 28 '11 at 12:14
source share

There is a fairly comprehensive tutorial on the CKEditor documentation website: CKEditor Plugin SDK - Introduction

At this point, it covers:

  • Creating an editor team
  • Creating a toolbar button with an icon
  • Explanation of how to register a plugin in CKEditor
  • Creating a two-tab plugin dialog box
  • Adding a context menu
  • Advanced Content Filter (ACF) Integration (per page )

If you are interested in creating your own widgets, also check out the Widgets SDK Tutorial

+2
Jan 05 '14 at 12:16
source share

This article about creating a CKEditor plugin in a Drupal context may also be useful http://mito-team.com/article/2012/collapse-button-for-ckeditor-for-drupal

There are code samples and a step-by-step guide to creating your own CKEditor plugin using a custom button.

+1
02 Oct.
source share

To add your own icon, you need to edit the skins / moono / *. css For the editor itself you need to add the same CSS class to the following files

  • editor.css
  • editor_gecko.css (firefox)
  • editor_ie.css
  • editor_ie7.css
  • editor_ie8.css
  • editor_iequirks.css

Format Name for CSS Button Class: .cke_button__myCustomIcon_icon

You can use your own image file for the icon or edit sprite / skins / moono / icons.png to add your own.

In your plugin.js you need something like

 editor.ui.addButton('myplugin', { label: 'myplugin', command: FCKCommand_myplugin, icon: 'myCustomIcon' }); 
+1
Jan 28 '16 at 19:29
source share

Regarding the awesome font, I was able to achieve this with CSS:

 span.cke_button_icon.cke_button__bold_icon { position: relative !important; background-image: none !important; &:after { font-family: FontAwesome; position: absolute; font-size: 16px; content: "\f032"; } } 
0
Apr 10 '16 at 14:22
source share



All Articles