Skip to content
Permalink
Browse files

Merge pull request #55 from turnermm/geshi

Geshi
  • Loading branch information...
turnermm committed Mar 17, 2018
2 parents ba862e4 + 7f9eccc commit 3fc1c0a635954ed08bf90e0d97f539dbfd554e7c

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -97,22 +97,32 @@ CKEDITOR.dialog.add( 'geshiDialog', function( editor ) {
{
type: 'select',
id: 'ckg_geshi_lang',
label: editor.lang.geshi.lang,
label: "Select language", //editor.lang.geshi.lang,
items: ckg_geshi_langopts,
'default':ckg_geshi_langopts[0],
style: s_display,
onChange: function( api ) {
geshi_dialog.getContentElement( 'tab-basic', 'language' ).setValue(this.getValue());
// geshi_dialog.getContentElement( 'tab-basic', 'language' ).setValue(this.getValue());
}
},

{
type: 'text',
id: 'language',
style: t_display,
label: editor.lang.geshi.lang || 'Programming Language',
width: '175px',
validate: CKEDITOR.dialog.validate.notEmpty(editor.lang.geshi.lang_empty)
label: "<html><span title='"+editor.lang.geshi.tooltip+"' style = 'color:blue;text-decoration:underline;' onmouseover='this.style.cursor=\"pointer\";'>" + editor.lang.geshi.quick_srch+"</span></html>", //editor.lang.geshi.lang || 'Programming Language',
width: '125px',
onChange: function( api ) {
var srch = this.getValue().toLowerCase();
srch = srch.escapeRegExpCkg(srch);
var regex = new RegExp('^' +srch);
for(var i = 1; i< ckg_geshi_langopts.length; i++) {
if(regex.test(ckg_geshi_langopts[i])) {
srch=ckg_geshi_langopts[i];
break;
}
}
if(srch) geshi_dialog.getContentElement( 'tab-basic', 'ckg_geshi_lang' ).setValue(srch);
}
},
{
type: 'text',
@@ -146,28 +156,40 @@ CKEDITOR.dialog.add( 'geshiDialog', function( editor ) {
selection = editor.getSelection();
var text = selection.getSelectedText();
dialog.getContentElement( 'tab-basic', 'geshi' ).setValue( text );
String.prototype.escapeRegExpCkg = function(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
};
// dialog.getContentElement( 'tab-basic', 'language' ).style='display:block';
// alert( 'Current value: ' + dialog.getValueOf( 'tab-basic', 'ckg_geshi_lang' ) );
},

// This method is invoked once a user clicks the OK button, confirming the dialog.

onOk: function() {
// The context of this function is the dialog object itself.
// http://docs.ckeditor.com/#!/api/CKEDITOR.dialog

var dialog = this, retval;
var text = dialog.getValueOf( 'tab-basic', 'geshi' );
var which = dialog.getValueOf( 'tab-basic', 'which' );
//dialog.getValueOf( 'tab-basic', 'language');

var p_lang = dialog.getValueOf( 'tab-basic', 'ckg_geshi_lang' );
if(!p_lang) p_lang = dialog.getValueOf( 'tab-basic', 'language' );
if(!p_lang) return;
if(p_lang.match(/Not Set/i)) {
p_lang = "";
}

if(!p_lang) {
if(confirm('Language not found. Try again?')) {
return false;
}
}

if(p_lang) {
if(which == 'block') {
retval = '<pre class="code ' + p_lang+ '">' + text + '</pre>';
}
else retval = downloadable_header(p_lang,dialog.getValueOf( 'tab-basic', 'file' ) ) + text + downloadable_footer();
editor.insertHtml(retval);
}

}
};
@@ -1,6 +1,6 @@
CKEDITOR.plugins.setLang("geshi","de",{
title: 'Geshi Snippet oder Block',
lang: 'Sprache',
lang: 'Sprache auswählen',
which: 'Code-Schnippsel?',
codeblock: 'Code-Schnippsel',
snippet: 'Herunterladbarer Code-Schnippsel',
@@ -1,11 +1,13 @@
CKEDITOR.plugins.setLang("geshi","en",{
title: 'Geshi snippet or block',
lang: 'Language',
lang: 'Select language',
which: 'Codeblock or Snippet?',
codeblock: 'Codeblock',
snippet: 'Downloadable Snippet',
lang_empty: 'Language field cannot be empty.',
code: 'Text for Snippet or Codeblock',
code_empty: 'Snippet or Codeblock required.',
file: 'Snippet File name',
quick_srch: 'Quick search',
tooltip: 'Enter full or partial name, click to search language menu',
});

0 comments on commit 3fc1c0a

Please sign in to comment.
You can’t perform that action at this time.