Created
August 28, 2016 14:34
-
-
Save igotit-anything/08969c4de48b6fd8d97f16b93fb7c921 to your computer and use it in GitHub Desktop.
JavaScript. CKEditor plugin init codes with context menu. - example : Cy-GistInsert's plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
CKEditor Plugin | |
name : Cy-GistInsert. | |
2016-08-27.started by igotit. | |
*/ | |
CKEDITOR.plugins.add( 'Cy-GistInsert', { | |
icons: 'Cy-GistInsert', | |
init: function( editor ) { | |
editor.addCommand( 'cmd-insertgist1', new CKEDITOR.dialogCommand('Cy-GistInsertDlg')); // adding command with dialog. | |
editor.ui.addButton( 'Cy-GistInsert', { | |
label: 'Insert GitHub Gist', // button's tooltip text. | |
command: 'cmd-insertgist1', // the command to be executed when the button is clicked. | |
toolbar: 'insert' // toolbar groub into which the button will be added | |
}); | |
/// begin - context menu | |
if (editor.contextMenu) { | |
editor.addMenuGroup('Group_CyGistInsert'); | |
editor.addMenuItem('Item_CyGistInsert', { | |
label: 'Edit Cy-GistInsert', | |
icon: this.path + 'icons/Cy-GistInsert.png', | |
command: 'cmd-insertgist1', | |
group: 'Group_CyGistInsert' | |
}); | |
editor.contextMenu.addListener(function (element) { | |
if (element.getAscendant('div').getId() == 'Cy-GistInsert') { // <div id="Cy-GistInser"> </div> | |
return { Item_CyGistInsert: CKEDITOR.TRISTATE_OFF }; | |
} | |
}); | |
} | |
/// end - context menu | |
CKEDITOR.dialog.add('Cy-GistInsertDlg', this.path + 'dialogs/Cy-GistInsertDlg.js'); // related to real dlg filepath and file name. | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment