Add Code snippet to the editor
2 posters
Page 1 of 1
Add Code snippet to the editor
Inspired by the code snippet in help forumotion, I wrote this script, but using font bbcode instead of the table bbcode. This will allow more flexible use, for example, copied bbcode to other forums not available to this script.
Go to Admin Panel > Modules > JavaScript codes management and create a new script with the following settings:
Title: Code snippet
Placement: In all the pages
Demo
How to set up?
Go to Admin Panel > Modules > JavaScript codes management and create a new script with the following settings:
Title: Code snippet
Placement: In all the pages
- Code:
jQuery(function($) {
'use strict';
$('head').append($('<style>', {
text: '.sceditor-button-inline-code div{background-image:url(http://i21.servimg.com/u/f21/18/21/41/30/snippe10.png)!important}.post-entry font[face="monospace"]{color:green;background:#f4f4f4;padding:0 5px;display:inline-block;margin:0 3px;border-radius:2px}'
}));
if (!$.sceditor) return;
$(function() {
$('#text_editor_textarea').sceditor('instance').css('font[face="monospace"]{color:green;background:#f4f4f4;padding:2px 5px;display:inline-block;margin:-2px 3px;border-radius:2px}');
});
function inlineCode(editor) {
editor.insert('[font=monospace]', '[/font]');
}
$.sceditor.command.set('inline-code', {
exec: function() {
inlineCode(this);
},
txtExec: function() {
inlineCode(this);
},
tooltip: 'Code snippet'
});
toolbar = toolbar.replace(/code/, 'code,inline-code');
});
Last edited by Zzbaivong on Mon 16 May - 10:46; edited 1 time in total
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum