diff --git a/htmlarea/ckeditor/ckeditor/plugins/codeTag/README.md b/htmlarea/ckeditor/ckeditor/plugins/codeTag/README.md new file mode 100644 index 00000000..7e1ad884 --- /dev/null +++ b/htmlarea/ckeditor/ckeditor/plugins/codeTag/README.md @@ -0,0 +1,8 @@ +Code tag in CKEditor +============== + +![](http://imgur.com/LN0MAEZ.png) + +Install by placing in ckeditor/plugins/ and add the following to ckeditor/config.js + + config.extraPlugins = 'codeTag'; \ No newline at end of file diff --git a/htmlarea/ckeditor/ckeditor/plugins/codeTag/icons/code.png b/htmlarea/ckeditor/ckeditor/plugins/codeTag/icons/code.png new file mode 100644 index 00000000..f7f8c39b Binary files /dev/null and b/htmlarea/ckeditor/ckeditor/plugins/codeTag/icons/code.png differ diff --git a/htmlarea/ckeditor/ckeditor/plugins/codeTag/plugin.js b/htmlarea/ckeditor/ckeditor/plugins/codeTag/plugin.js new file mode 100644 index 00000000..802f7680 --- /dev/null +++ b/htmlarea/ckeditor/ckeditor/plugins/codeTag/plugin.js @@ -0,0 +1,15 @@ +CKEDITOR.plugins.add( 'codeTag', { + icons: 'code', + init: function( editor ) { + editor.addCommand( 'wrapCode', { + exec: function( editor ) { + editor.insertHtml( '' + editor.getSelection().getSelectedText() + '' ); + } + }); + editor.ui.addButton( 'Code', { + label: 'Wrap code', + command: 'wrapCode', + toolbar: 'insert' + }); + } +}); \ No newline at end of file diff --git a/htmlarea/ckeditor_s9y_config.js b/htmlarea/ckeditor_s9y_config.js index b973bbe9..174dca37 100644 --- a/htmlarea/ckeditor_s9y_config.js +++ b/htmlarea/ckeditor_s9y_config.js @@ -65,7 +65,7 @@ CKEDITOR.editorConfig = function( config ) { - Allow for custom attributes/classes in code blocks */ // protect - config.extraAllowedContent = 'mediainsert[*]{*}(*);gallery[*]{*}(*);media[*]{*}(*);script[*]{*}(*);audio[*]{*}(*);div[*]{*}(*);span[*]{*}(*);img[height,width];pre[*](*);'; + config.extraAllowedContent = 'mediainsert[*]{*}(*);gallery[*]{*}(*);media[*]{*}(*);script[*]{*}(*);audio[*]{*}(*);div[*]{*}(*);span[*]{*}(*);img[height,width];pre[*](*);code;tt;'; // Do not use auto paragraphs, added to these allowed tags (only!). Please regard that this was marked deprecated by CKE 4.4.5, but is a need for (our use of) extraAllowedContent - check this again by future versions! config.autoParagraph = false; // defaults(true) @@ -234,7 +234,8 @@ CKEDITOR.editorConfig = function( config ) { { name: 'others', items : s9ypluginbuttons }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }, { name: 'document', groups : [ 'mode', 'document', 'doctools' ], items : [ 'Source' ] }, - { name: 'cheatsheet', items : ['CheatSheet'] } + { name: 'cheatsheet', items : ['CheatSheet'] }, + { name: 'codetag', items: [ 'Code' ] } ]; // console.log(JSON.stringify(config.toolbar_Full)); @@ -252,7 +253,8 @@ CKEDITOR.editorConfig = function( config ) { { name: 'mediaembed', items: [ 'MediaEmbed' ] }, { name: 'others', items: s9ypluginbuttons }, { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source' ] }, - { name: 'about', items: [ 'About' ] } + { name: 'about', items: [ 'About' ] }, + //{ name: 'codetag', items: [ 'Code' ] } ]; // console.log(JSON.stringify(config.toolbar_s9y)); diff --git a/htmlarea/ckeditor_s9y_plugin.js b/htmlarea/ckeditor_s9y_plugin.js index 476a6931..ae440fce 100644 --- a/htmlarea/ckeditor_s9y_plugin.js +++ b/htmlarea/ckeditor_s9y_plugin.js @@ -17,7 +17,7 @@ // Plugin Dependencies: widget Add-on Dependencies: Line Utilities and Clipboard // mediaembed is a fast and simple YouTube code CKEditor-Plugin: v. 0.5+ (https://github.com/frozeman/MediaEmbed, 2013-09-12) to avoid ACF restrictions // procurator and cheatsheet are S9y only plugins - var customplugins = 'mediaembed,procurator,cheatsheet,'; + var customplugins = 'mediaembed,procurator,cheatsheet,codeTag,'; // for any new instance when it is created - listen on load CKEDITOR.on('instanceReady', function(evt){