Skip to content

Commit 535d87f

Browse files
author
Piotr Jasiun
committed
Merge branch 't/11788b'
2 parents c4a1982 + e16d9d6 commit 535d87f

File tree

306 files changed

+85914
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+85914
-10
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Fixed Issues:
1818
* [#11880](http://dev.ckeditor.com/ticket/11880): Fixed: [IE8-9] Linked image has a default thick border.
1919
* [#11822](http://dev.ckeditor.com/ticket/11822): Fixed: [Webkit] Anchors editing by double click broken in some cases.
2020
* [#11823](http://dev.ckeditor.com/ticket/11823): [IE8] Fixed: [Table Resize](http://ckeditor.com/addon/tableresize) throws error over scrollbar.
21+
* [#11788](http://dev.ckeditor.com/ticket/11788): Fixed: It is not possible to change language back to undefined in [Code Snippet](http://ckeditor.com/addon/codesnippet) dialog.
2122

2223
Other changes:
2324

plugins/codesnippet/dialogs/codesnippet.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
lang = editor.lang.codesnippet,
1212
clientHeight = document.documentElement.clientHeight,
1313
langSelectItems = [],
14-
langSelectDefaultValue,
1514
snippetLangId;
1615

16+
langSelectItems.push( [ editor.lang.common.notSet, '' ] );
17+
1718
for ( snippetLangId in snippetLangs )
1819
langSelectItems.push( [ snippetLangs[ snippetLangId ], snippetLangId ] );
1920

20-
if ( langSelectItems.length )
21-
langSelectDefaultValue = langSelectItems[ 0 ][ 1 ];
22-
2321
// Size adjustments.
2422
var size = CKEDITOR.document.getWindow().getViewPaneSize(),
2523
// Make it maximum 800px wide, but still fully visible in the viewport.
@@ -43,9 +41,9 @@
4341
type: 'select',
4442
label: lang.language,
4543
items: langSelectItems,
46-
'default': langSelectDefaultValue,
4744
setup: function( widget ) {
48-
this.setValue( widget.ready ? widget.data.lang : '' );
45+
if ( widget.ready && widget.data.lang )
46+
this.setValue( widget.data.lang );
4947

5048
// The only way to have an empty select value in Firefox is
5149
// to set a negative selectedIndex.

plugins/codesnippet/plugin.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@
318318
if ( newData.code )
319319
this.parts.code.setHtml( CKEDITOR.tools.htmlEncode( newData.code ) );
320320

321+
// Remove old .language-* class.
322+
if ( oldData && newData.lang != oldData.lang )
323+
this.parts.code.removeClass( 'language-' + oldData.lang );
324+
321325
// Lang needs to be specified in order to apply formatting.
322326
if ( newData.lang ) {
323327
// Apply new .language-* class.
324328
this.parts.code.addClass( 'language-' + newData.lang );
325329

326-
// Remove old .language-* class.
327-
if ( oldData && newData.lang != oldData.lang )
328-
this.parts.code.removeClass( 'language-' + oldData.lang );
329-
330330
this.highlight();
331331
}
332332

@@ -420,6 +420,7 @@ CKEDITOR.config.codeSnippet_codeClass = 'hljs';
420420

421421
/**
422422
* Restricts languages available in the "Code Snippet" dialog window.
423+
* Node that the empty value is always added to the list.
423424
*
424425
* **Note**: If using a custom highlighter library (the default is [highlight.js](http://highlightjs.org)),
425426
* you may need to refer to external documentation to set `config.codeSnippet_languages` properly.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
4+
For licensing, see LICENSE.md or http://ckeditor.com/license
5+
-->
6+
<html>
7+
<head>
8+
<meta charset="utf-8">
9+
<title>Code Snippet &mdash; CKEditor Sample</title>
10+
<script src="../../../ckeditor.js"></script>
11+
<link href="../../../samples/sample.css" rel="stylesheet">
12+
<meta name="ckeditor-sample-name" content="Code Snippet plugin">
13+
<meta name="ckeditor-sample-group" content="Plugins">
14+
<meta name="ckeditor-sample-description" content="View and modify code using the Code Snippet plugin.">
15+
<meta name="ckeditor-sample-isnew" content="1">
16+
<style>
17+
18+
#editable
19+
{
20+
padding: 10px 20px;
21+
}
22+
pre > code {
23+
display: block;
24+
}
25+
26+
</style>
27+
</head>
28+
<body>
29+
<textarea id="editor1">
30+
&lt;p&gt;JavaScript code:&lt;/p&gt;
31+
32+
&lt;pre&gt;
33+
&lt;code class="language-javascript"&gt;function isEmpty( object ) {
34+
for ( var i in object ) {
35+
if ( object.hasOwnProperty( i ) )
36+
return false;
37+
}
38+
return true;
39+
}&lt;/code&gt;&lt;/pre&gt;
40+
41+
&lt;p&gt;SQL query:&lt;/p&gt;
42+
43+
&lt;pre&gt;
44+
&lt;code class="language-sql"&gt;SELECT cust.id FROM cust LEFT JOIN loc ON ( cust.loc_id = loc.id ) WHERE cust.type IN ( 1, 2 );&lt;/code&gt;&lt;/pre&gt;
45+
46+
&lt;p&gt;Unknown markup:&lt;/p&gt;
47+
48+
&lt;pre&gt;
49+
&lt;code&gt; ________________
50+
/ \
51+
| How about moo? | ^__^
52+
\________________/ (oo)\_______
53+
\ (__)\ )\/\
54+
||----w |
55+
|| ||
56+
&lt;/code&gt;&lt;/pre&gt;
57+
</textarea>
58+
59+
<h2>Inline editor</h2>
60+
61+
<div id="editable" contenteditable="true">
62+
63+
<p>JavaScript code:</p>
64+
65+
<pre><code class="language-javascript">function isEmpty( object ) {
66+
for ( var i in object ) {
67+
if ( object.hasOwnProperty( i ) )
68+
return false;
69+
}
70+
return true;
71+
}</code></pre>
72+
73+
<p>SQL query:</p>
74+
75+
<pre><code class="language-sql">SELECT cust.id, cust.name, loc.city FROM cust LEFT JOIN loc ON ( cust.loc_id = loc.id ) WHERE cust.type IN ( 1, 2 );</code></pre>
76+
77+
<p>Unknown markup:</p>
78+
79+
<pre><code> ________________
80+
/ \
81+
| How about moo? | ^__^
82+
\________________/ (oo)\_______
83+
\ (__)\ )\/\
84+
||----w |
85+
|| ||
86+
</code></pre>
87+
</div>
88+
89+
<script>
90+
( function() {
91+
CKEDITOR.disableAutoInline = true;
92+
93+
var config = {
94+
extraPlugins: 'codesnippet,codesnippetgeshi',
95+
codeSnippetGeshi_url: 'plugins/codesnippetgeshi/dev/colorize.php',
96+
toolbar: [
97+
[ 'Source', 'Sourcedialog' ], [ 'Undo', 'Redo' ], [ 'Bold', 'Italic', 'Underline' ], [ 'CodeSnippet' ]
98+
],
99+
codeSnippet_theme: 'monokai_sublime',
100+
height: 400
101+
};
102+
103+
CKEDITOR.replace( 'editor1', config );
104+
105+
CKEDITOR.inline( 'editable', CKEDITOR.tools.extend( {}, config, {
106+
extraPlugins: 'codesnippet,codesnippetgeshi,sourcedialog'
107+
}, true ) );
108+
}() );
109+
</script>
110+
111+
<div id="footer">
112+
<hr>
113+
<p>
114+
CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
115+
</p>
116+
<p id="copy">
117+
Copyright &copy; 2003-2014, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
118+
Knabben. All rights reserved.
119+
</p>
120+
</div>
121+
</body>
122+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
if ( function_exists( 'stream_resolve_include_path' ) && stream_resolve_include_path( 'geshi/geshi.php' ) === FALSE ) {
4+
die( '<pre class="html">Please install the geshi library. Refer to plugins/codesnippetgeshi/README.md for more information.</pre>' );
5+
}
6+
7+
include_once 'geshi/geshi.php';
8+
9+
$json_string = file_get_contents( 'php://input' );
10+
$json_object = json_decode( $json_string );
11+
12+
$geshi = new GeSHi( $json_object->html, $json_object->lang );
13+
14+
echo $geshi->parse_code();
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
/**
4+
* Another GeSHi example script
5+
*
6+
* Configure your Apache server with 'AcceptPathInfo true' and something like
7+
* 'Alias /viewmysource /var/www/geshi/contrib/aliased.php'. Don't forget
8+
* to protect this alias as necessary.
9+
*
10+
* Usage - visit /viewmysource/file.name.ext to see that file with syntax
11+
* highlighting, where "viewmysource" is the name of the alias you set up.
12+
* You can use this without an alias too, just by visiting
13+
* aliased.php/file.name.ext.
14+
*
15+
* @author Ross Golder <ross@golder.org>
16+
* @version $Id: aliased.php 2533 2012-08-15 18:49:04Z benbe $
17+
*/
18+
19+
// Your config here
20+
define("SOURCE_ROOT", "/var/www/your/source/root/");
21+
22+
// Assume you've put geshi in the include_path already
23+
require_once("geshi.php");
24+
25+
// Get path info
26+
$path = SOURCE_ROOT.$_SERVER['PATH_INFO'];
27+
28+
// Check for dickheads trying to use '../' to get to sensitive areas
29+
$base_path_len = strlen(SOURCE_ROOT);
30+
$real_path = realpath($path);
31+
if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) {
32+
exit("Access outside acceptable path.");
33+
}
34+
35+
// Check file exists
36+
if(!file_exists($path)) {
37+
exit("File not found ($path).");
38+
}
39+
40+
// Prepare GeSHi instance
41+
$geshi = new GeSHi();
42+
$geshi->set_language('text');
43+
$geshi->load_from_file($path);
44+
$geshi->set_header_type(GESHI_HEADER_PRE);
45+
$geshi->enable_classes();
46+
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
47+
$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
48+
$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
49+
$geshi->set_code_style('color: #000020;', 'color: #000020;');
50+
$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
51+
$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
52+
$geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name());
53+
$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
54+
$geshi->set_footer_content('Parsed in <TIME> seconds, using GeSHi <VERSION>');
55+
$geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
56+
57+
?>
58+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
59+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
60+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
61+
<head>
62+
<title>Source code viewer - <?php echo $path; ?> - <?php $geshi->get_language_name(); ?></title>
63+
<style type="text/css">
64+
<!--
65+
<?php
66+
// Output the stylesheet. Note it doesn't output the <style> tag
67+
echo $geshi->get_stylesheet();
68+
?>
69+
html {
70+
background-color: #f0f0f0;
71+
}
72+
body {
73+
font-family: Verdana, Arial, sans-serif;
74+
margin: 10px;
75+
border: 2px solid #e0e0e0;
76+
background-color: #fcfcfc;
77+
padding: 5px;
78+
}
79+
h2 {
80+
margin: .1em 0 .2em .5em;
81+
border-bottom: 1px solid #b0b0b0;
82+
color: #b0b0b0;
83+
font-weight: normal;
84+
font-size: 150%;
85+
}
86+
h3 {
87+
margin: .1em 0 .2em .5em;
88+
color: #b0b0b0;
89+
font-weight: normal;
90+
font-size: 120%;
91+
}
92+
#footer {
93+
text-align: center;
94+
font-size: 80%;
95+
color: #a9a9a9;
96+
}
97+
#footer a {
98+
color: #9999ff;
99+
}
100+
textarea {
101+
border: 1px solid #b0b0b0;
102+
font-size: 90%;
103+
color: #333;
104+
margin-left: 20px;
105+
}
106+
select, input {
107+
margin-left: 20px;
108+
}
109+
p {
110+
font-size: 90%;
111+
margin-left: .5em;
112+
}
113+
-->
114+
</style>
115+
</head>
116+
<body>
117+
<?php
118+
// The fun part :)
119+
echo $geshi->parse_code();
120+
?>
121+
<hr/>
122+
</body>
123+
</html>

0 commit comments

Comments
 (0)