From 9a8fb7a696f86923f1be1cd9167a110abbeebe28 Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Sun, 17 Mar 2019 15:19:12 +0200 Subject: [PATCH] Added codeTag plugin into CKeditor --- .../ckeditor/ckeditor/plugins/codeTag/README.md | 8 ++++++++ .../ckeditor/plugins/codeTag/icons/code.png | Bin 0 -> 557 bytes .../ckeditor/ckeditor/plugins/codeTag/plugin.js | 15 +++++++++++++++ htmlarea/ckeditor_s9y_config.js | 8 +++++--- htmlarea/ckeditor_s9y_plugin.js | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 htmlarea/ckeditor/ckeditor/plugins/codeTag/README.md create mode 100644 htmlarea/ckeditor/ckeditor/plugins/codeTag/icons/code.png create mode 100644 htmlarea/ckeditor/ckeditor/plugins/codeTag/plugin.js 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 0000000000000000000000000000000000000000..f7f8c39b07286c8c26393f86f6cfd886eb9ebdc9 GIT binary patch literal 557 zcmV+|0@D47P)(_`g8%^e{{R4h=l}px2mk>USO5SzmjD14Z`WEM zkN^Myvq?ljRCwCNlQC=CKorN{8Oc<7dO})ExJ?>7X_Afz3ff$w@6fq6nmiZ+Ii%4; zhR#NxpdTRFqB-CWSp^!ri0A{D8hbEYmk1Ik?UF*@_`m!8?%q9)DW%{eHGqFzVHnPY z5GoAA+268vZxBV%jEG9tbpa8}K1amTbzLB$GK!+vy8<2a|HC>{qv5M1YZ{(y)lP1C?Ij7c2F_vdgN z$M=R|Of*dcL_Fnr{tyJgH3I-pN{zd&Td!8D&t2Dj+VA(U+wH2&X7i`(VR@6t3);G7?&lvNME=}{?l(YEdF vdcA&X+xE84UuH_Fi&u~P-#^ob1-}OXmAam_5Qlu?00000NkvXXu0mjfkUR5G literal 0 HcmV?d00001 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){