Skip to content

Instantly share code, notes, and snippets.

@fontamel
Created April 5, 2022 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fontamel/0237496efd7abf20ae8400508dfc5fe0 to your computer and use it in GitHub Desktop.
Save fontamel/0237496efd7abf20ae8400508dfc5fe0 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
function link_ckeditor(el)
{
// Full Set
CKEDITOR.config.toolbar = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
{ name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] },
{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
{ name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] },
'/',
{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
{ name: 'tools', items: [ 'Maximize', 'ShowBlocks' ] },
{ name: 'others', items: [ '-' ] },
{ name: 'about', items: [ 'About' ] }
];
// remove nbsp; from start of textarea
if(el.previousSibling) el.parentNode.removeChild(el.previousSibling);
$(el).parent().css('padding-left','6px');
var editor = CKEDITOR.replace( el, {
extraPlugins: 'colorbutton,colordialog,uploadimage',
// Configure your file manager integration. This example uses CKFinder 3 for PHP.
filebrowserBrowseUrl: '/ckfinder/3.4.5/ckfinder.html',
filebrowserImageBrowseUrl: '/ckfinder/3.4.5/ckfinder.html?type=Images',
filebrowserUploadUrl: '/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl: '/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Images',
// Upload dropped or pasted images to the CKFinder connector (note that the response type is set to JSON).
uploadUrl: '/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',
// Reduce the list of block elements listed in the Format drop-down to the most commonly used.
format_tags: 'p;h1;h2;h3;pre',
// Simplify the Image and Link dialog windows. The "Advanced" tab is not needed in most cases.
removeDialogTabs: 'image:advanced;link:advanced',
//height: 450,
//removeButtons: 'PasteFromWord'
on: {
change: function(){ jQuery(el).val(editor.getData()); }
}
});
// unblock typing in ckeditor dialog - events tracked with firebug > script > global pause > stack
jQuery(document).unbind('keypress').unbind('keydown').unbind('mousedown');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment