Added codeTag plugin into CKeditor

This commit is contained in:
Jari Turkia 2019-03-17 15:19:12 +02:00 committed by onli
parent 99b8190180
commit 9a8fb7a696
5 changed files with 29 additions and 4 deletions

View File

@ -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';

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

View File

@ -0,0 +1,15 @@
CKEDITOR.plugins.add( 'codeTag', {
icons: 'code',
init: function( editor ) {
editor.addCommand( 'wrapCode', {
exec: function( editor ) {
editor.insertHtml( '<code>' + editor.getSelection().getSelectedText() + '</code>' );
}
});
editor.ui.addButton( 'Code', {
label: 'Wrap code',
command: 'wrapCode',
toolbar: 'insert'
});
}
});

View File

@ -65,7 +65,7 @@ CKEDITOR.editorConfig = function( config ) {
- Allow <pre[*attributes](*classes)> 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));

View File

@ -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){