Skip to content

Commit

Permalink
Merge branch 't/11926'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed May 13, 2014
2 parents edf271d + 94f8dcf commit d973681
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Expand Up @@ -12,7 +12,8 @@ Fixed Issues:
* [#11861](http://dev.ckeditor.com/ticket/11861): Fixed: [Webkit/Blink] Span elements created while joining adjacent elements. **Note:** Only a case when *Backspace* or *Delete* is pressed on collapsed (empty) selection is covered by this patch. The remaining case, with a non-empty selection, will be fixed in next release.
* [#10714](http://dev.ckeditor.com/ticket/10714): Fixed: [iOS] Selection and drop-downs are broken if touch listener is used due to [Webkit bug](https://bugs.webkit.org/show_bug.cgi?id=128924). Thanks to [Arty Gus](https://github.com/artygus)!
* [#11911](http://dev.ckeditor.com/ticket/11911): Fixed setting the `dir` attribute for preloaded language in [CKEDITOR.lang](http://docs.ckeditor.com/#!/api/CKEDITOR.lang). Thanks to [Akash Mohapatra](https://github.com/akashmohapatra)!
* [#11223](http://dev.ckeditor.com/ticket/11223): Fixed: issue when [Protected Source](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-protectedSource) was not working in the title element.
* [#11926](http://dev.ckeditor.com/ticket/11926): Fixed: Code snippet does not decode HTML entities when loading code from the `<code>` element.
* [#11223](http://dev.ckeditor.com/ticket/11223): Fixed: Issue when [Protected Source](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-protectedSource) was not working in the title element.
* [#11859](http://dev.ckeditor.com/ticket/11859): Fixed: Removed [Source Dialog](http://ckeditor.com/addon/sourcedialog) plugin from required in [Code Snippet](http://ckeditor.com/addon/codesnippet) sample.
* [#11754](http://dev.ckeditor.com/ticket/11754): Fixed: Infinite loop in Google Chrome when contents contains not closed attributes.
* [#11848](http://dev.ckeditor.com/ticket/11848): Fixed: [`editor.insertElement()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertElement) throwing an exception in IE, when there was no selection in editor.
Expand Down
11 changes: 9 additions & 2 deletions plugins/codesnippet/plugin.js
Expand Up @@ -273,7 +273,8 @@
// @param {CKEDITOR.editor} editor
function registerWidget( editor ) {
var codeClass = editor.config.codeSnippet_codeClass,
newLineRegex = /\r?\n/g;
newLineRegex = /\r?\n/g,
textarea = new CKEDITOR.dom.element( 'textarea' );

editor.widgets.add( 'codeSnippet', {
allowedContent: 'pre; code(language-*)',
Expand Down Expand Up @@ -345,13 +346,19 @@
if ( childrenArray.length != 1 || ( code = childrenArray[ 0 ] ).name != 'code' )
return;

// Upcast <code> with text only: http://dev.ckeditor.com/ticket/11926#comment:4
if ( code.children.length != 1 || code.children[ 0 ].type != CKEDITOR.NODE_TEXT )
return;

// Read language-* from <code> class attribute.
var matchResult = editor._.codesnippet.langsRegex.exec( code.attributes[ 'class' ] );

if ( matchResult )
data.lang = matchResult[ 1 ];

data.code = code.getHtml();
// Use textarea to decode HTML entities (#11926).
textarea.setHtml( code.getHtml() );
data.code = textarea.getValue();

code.addClass( codeClass );

Expand Down

0 comments on commit d973681

Please sign in to comment.