JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.5
[ckeditor.git] / _source / plugins / bbcode / plugin.js
index 69de69d..e403d11 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -158,11 +158,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                 4 : close of tag;\r
                                 */\r
 \r
-                               // Opening tag\r
-                               if ( ( part = parts[ 1 ] ) )\r
+                               part = ( parts[ 1 ] || parts[ 3 ] || '' ).toLowerCase();\r
+                               // Unrecognized tags should be delivered as a simple text (#7860).\r
+                               if ( part && !bbcodeMap[ part ] )\r
                                {\r
-                                       part = part.toLowerCase();\r
+                                       this.onText( parts[ 0 ] );\r
+                                       continue;\r
+                               }\r
 \r
+                               // Opening tag\r
+                               if ( parts[ 1 ] )\r
+                               {\r
                                        var tagName = bbcodeMap[ part ],\r
                                                        attribs = {},\r
                                                        styles = {},\r
@@ -201,7 +207,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        this.onTagOpen( tagName, attribs, CKEDITOR.dtd.$empty[ tagName ] );\r
                                }\r
                                // Closing tag\r
-                               else if ( ( part = parts[ 3 ] ) )\r
+                               else if ( parts[ 3 ] )\r
                                        this.onTagClose( bbcodeMap[ part ] );\r
                        }\r
 \r
@@ -560,19 +566,33 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                this.lineBreak( 1 );\r
 \r
                                        this.write( '[', tag );\r
-                                       var option = attributes.option;\r
-                                       option && this.write( '=', option );\r
-                                       this.write( ']' );\r
+                               }\r
+                       },\r
+\r
+                       openTagClose : function( tag )\r
+                       {\r
 \r
+                               if ( tag == 'br' )\r
+                                       this._.output.push( '\n' );\r
+                               else if ( tag in bbcodeMap )\r
+                               {\r
+                                       this.write( ']' );\r
                                        if ( this.getRule( tag, 'breakAfterOpen' ) )\r
                                                this.lineBreak( 1 );\r
                                }\r
-                               else if ( tag == 'br' )\r
-                                       this._.output.push( '\n' );\r
                        },\r
 \r
-                       openTagClose : function() { },\r
-                       attribute : function() { },\r
+                       attribute : function( name, val )\r
+                       {\r
+                               if ( name == 'option' )\r
+                               {\r
+                                       // Force simply ampersand in attributes.\r
+                                       if ( typeof val == 'string' )\r
+                                               val = val.replace( /&/g, '&' );\r
+\r
+                                       this.write( '=', val );\r
+                               }\r
+                       },\r
 \r
                        closeTag : function( tag )\r
                        {\r
@@ -872,8 +892,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                          editor.dataProcessor.writer = BBCodeWriter;\r
 \r
-                         editor.on( 'editingBlockReady', function ()\r
+                         editor.on( 'beforeSetMode', function( evt )\r
                          {\r
+                                 evt.removeListener();\r
                                  var wysiwyg = editor._.modes[ 'wysiwyg' ];\r
                                  wysiwyg.loadData = CKEDITOR.tools.override( wysiwyg.loadData, function( org )\r
                                  {\r