From 6cbe1098e37858ec9d0d7728b128e37e65719635 Mon Sep 17 00:00:00 2001 From: Pierre Baron Date: Wed, 16 Jul 2014 22:15:58 +0200 Subject: [PATCH] fixes #26 --- .gitignore | 2 ++ dialogs/pbckcode.js | 45 +++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 4673d8f..5d18378 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *.sublime-workspace *.sublime-project + +.idea/ \ No newline at end of file diff --git a/dialogs/pbckcode.js b/dialogs/pbckcode.js index 15871c8..7fe485b 100755 --- a/dialogs/pbckcode.js +++ b/dialogs/pbckcode.js @@ -11,10 +11,10 @@ CKEDITOR.dialog.add('pbckcodeDialog', function (editor) { var DEFAULT_SETTINGS = { cls : '', modes : [ - ['HTML', 'html'], - ['CSS', 'css'], - ['PHP', 'php'], - ['JS', 'javascript'] + ['HTML', 'html'], + ['CSS', 'css'], + ['PHP', 'php'], + ['JS', 'javascript'] ], theme : 'textmate', tab_size : 4 @@ -25,8 +25,8 @@ CKEDITOR.dialog.add('pbckcodeDialog', function (editor) { // merge user settings with default settings var settings = CKEDITOR.tools.extend(DEFAULT_SETTINGS, editor.config.pbckcode, true); - // CKEditor variables - var dialog; + // CKEditor variables + var dialog; var shighlighter = new PBSyntaxHighlighter(settings.highlighter); // ACE variables @@ -92,25 +92,26 @@ CKEDITOR.dialog.add('pbckcodeDialog', function (editor) { ] }, { - type : 'html', - html : '
', - id : 'code-textarea', + type : 'html', + html : '
', + id : 'code-textarea', className : 'cke_pbckcode_ace', - style : 'position: absolute; top: 80px; left: 10px; right: 10px; bottom: 50px;', - setup : function (element) { + style : 'position: absolute; top: 80px; left: 10px; right: 10px; bottom: 50px;', + setup : function (element) { // get the value of the editor var code = element.getHtml(); // replace some regexp - code = code.replace(new RegExp('
', 'g'), '\n'); - code = code.replace(new RegExp('
', 'g'), '\n'); - code = code.replace(new RegExp('<', 'g'), '<'); - code = code.replace(new RegExp('>', 'g'), '>'); - code = code.replace(new RegExp('&', 'g'), '&'); + code = code.replace(new RegExp('
', 'g'), '\n') + .replace(new RegExp('
', 'g'), '\n') + .replace(new RegExp('<', 'g'), '<') + .replace(new RegExp('>', 'g'), '>') + .replace(new RegExp('&', 'g'), '&') + .replace(new RegExp(' ', 'g'), ' '); aceEditor.setValue(code); }, - commit : function (element) { + commit : function (element) { element.setText(aceEditor.getValue()); } } @@ -128,21 +129,21 @@ CKEDITOR.dialog.add('pbckcodeDialog', function (editor) { editorPanel ], onLoad : function () { - dialog = this; + dialog = this; // we load the ACE plugin to our div aceEditor = ace.edit(dialog.getContentElement('editor', 'code-textarea') - .getElement().getId()); + .getElement().getId()); // save the aceEditor into the editor object for the resize event editor.aceEditor = aceEditor; // set default settings aceEditor.setTheme("ace/theme/" + settings.theme); - aceEditor.setHighlightActiveLine(true); + aceEditor.setHighlightActiveLine(true); aceSession = aceEditor.getSession(); - aceSession.setMode("ace/mode/" + settings.modes[0][1]); + aceSession.setMode("ace/mode/" + settings.modes[0][1]); aceSession.setTabSize(settings.tab_size); - aceSession.setUseSoftTabs(true); + aceSession.setUseSoftTabs(true); // load ace extensions whitespace = ace.require('ace/ext/whitespace');