Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from turnermm/geshi
Geshi
- Loading branch information
Showing
8 changed files
with
235 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ rev_17-Jan_30-08_40 | |
30 Jan 2017 | ||
Synched with ckgedit | ||
|
||
May 5 | ||
Synched geshi update to ckgedit | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
/** | ||
* Copyright (c) 2014-2016, CKSource - Frederico Knabben. All rights reserved. | ||
* Licensed under the terms of the MIT License (see LICENSE.md). | ||
* | ||
* The abbr plugin dialog window definition. | ||
* | ||
* Created out of the CKEditor Plugin SDK: | ||
* http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1 | ||
*/ | ||
|
||
// Our dialog definition. | ||
CKEDITOR.dialog.add( 'geshiDialog', function( editor ) { | ||
var radio, ckg_geshi_langopts = new Array(); | ||
var href, id,geshi_dialog, t_display,s_display; | ||
|
||
var getHref = function() { | ||
var data = window.location.pathname; | ||
var qs = window.location.search; | ||
var matches = data.match(/\/(.*?)\/(doku.php)?\/?(.*)/); | ||
|
||
if(qs_match = qs.match(/id=([\w:_\.]+)\b/)) { //none | ||
id = qs_match[1]; | ||
href = matches[0]; | ||
} | ||
else if(!matches[2]) | ||
{ | ||
id = matches[3]; | ||
href = matches[1] + '/doku.php'; | ||
} | ||
else { | ||
id = matches[3]; | ||
href = matches[2] + '/doku.php'; | ||
} | ||
if(!href) href='doku.php'; | ||
if(!id) id = 'start'; | ||
return {'href':href, 'id':id}; | ||
}; | ||
|
||
var downloadable_header = function(type,fname) { | ||
var id = 'start'; | ||
var file = fname ? fname: 'temp.' + type; | ||
var href_vals = getHref(); | ||
return '<dl class="file">' | ||
+'<dt><a href="' + href_vals.href + '?do=export_code&id=' + href_vals.id+ '&codeblock=0" title="Download Snippet" class="mediafile mf_' + type +'">' +file +'</a></dt> <dd><pre class="file ' + type+ '">'; | ||
}; | ||
|
||
var downloadable_footer = function() { | ||
return "</pre> </dd></dl>"; | ||
} | ||
|
||
ckg_geshi_langopts = editor.config.geshi_opts; | ||
if(!ckg_geshi_langopts.match(/ENotfound/)) { | ||
ckg_geshi_langopts = ckg_geshi_langopts.split(';;'); | ||
var tmp; | ||
for(var i=0; i<ckg_geshi_langopts.length; i++) { | ||
tmp = ckg_geshi_langopts[i] ; | ||
ckg_geshi_langopts[i] = new Array(tmp); | ||
} | ||
ckg_geshi_langopts.unshift(['Not Set']); | ||
s_display = 'display:block'; | ||
t_display = 'display:none'; | ||
} | ||
else { | ||
t_display = 'display:inline'; | ||
s_display = 'display:none'; | ||
ckg_geshi_langopts = []; | ||
} | ||
return { | ||
|
||
// Basic properties of the dialog window: title, minimum size. | ||
title: 'Abbreviation Properties', | ||
minWidth: 600, | ||
minHeight: 350, | ||
|
||
// Dialog window content definition. | ||
contents: [ | ||
{ | ||
// Definition of the Basic Settings dialog tab (page). | ||
id: 'tab-basic', | ||
label: 'Basic Settings', | ||
|
||
// The tab content. | ||
elements: [ | ||
{ | ||
// Text input field for the abbreviation text. | ||
type: 'textarea', | ||
rows:18, | ||
cols: 80, | ||
id: 'geshi', | ||
label: editor.lang.geshi.code, | ||
// Validation checking whether the field is not empty. | ||
validate: CKEDITOR.dialog.validate.notEmpty(editor.lang.geshi.code_empty) | ||
}, | ||
{ | ||
type: 'hbox', | ||
widths: [ '33%', '33%','33%'], | ||
children: [ | ||
{ | ||
type: 'select', | ||
id: 'ckg_geshi_lang', | ||
label: 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()); | ||
} | ||
}, | ||
|
||
{ | ||
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) | ||
}, | ||
{ | ||
type: 'text', | ||
id: 'file', | ||
label: editor.lang.geshi.file || 'File name', | ||
width: '175px', | ||
}, | ||
{ | ||
type: 'radio', | ||
id: 'which', | ||
label: editor.lang.geshi.which, | ||
items: [ [ editor.lang.geshi.codeblock, 'block' ], [ editor.lang.geshi.snippet, 'snippet' ] ], | ||
'default': 'block', | ||
style: 'color: green', | ||
onClick: function() { | ||
radio = this.getValue(); | ||
} | ||
}, | ||
] //hbox children | ||
}, //hbox | ||
|
||
] //elements | ||
}, //contents | ||
|
||
], //contents | ||
|
||
onShow : function() | ||
{ | ||
var dialog = this; | ||
geshi_dialog = dialog; | ||
selection = editor.getSelection(); | ||
var text = selection.getSelectedText(); | ||
dialog.getContentElement( 'tab-basic', 'geshi' ).setValue( text ); | ||
// 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(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); | ||
|
||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.