2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
8 CKEDITOR.on( 'dialogDefinition', function( ev )
\r
10 var tab, name = ev.data.name,
\r
11 definition = ev.data.definition;
\r
13 if ( name == 'link' )
\r
15 definition.removeContents( 'target' );
\r
16 definition.removeContents( 'upload' );
\r
17 definition.removeContents( 'advanced' );
\r
18 tab = definition.getContents( 'info' );
\r
19 tab.remove( 'emailSubject' );
\r
20 tab.remove( 'emailBody' );
\r
22 else if ( name == 'image' )
\r
24 definition.removeContents( 'advanced' );
\r
25 tab = definition.getContents( 'Link' );
\r
26 tab.remove( 'cmbTarget' );
\r
27 tab = definition.getContents( 'info' );
\r
28 tab.remove( 'txtAlt' );
\r
29 tab.remove( 'basic' );
\r
33 var bbcodeMap = { 'b' : 'strong', 'u': 'u', 'i' : 'em', 'color' : 'span', 'size' : 'span', 'quote' : 'blockquote', 'code' : 'code', 'url' : 'a', 'email' : 'span', 'img' : 'span', '*' : 'li', 'list' : 'ol' },
\r
34 convertMap = { 'strong' : 'b' , 'b' : 'b', 'u': 'u', 'em' : 'i', 'i': 'i', 'code' : 'code', 'li' : '*' },
\r
35 tagnameMap = { 'strong' : 'b', 'em' : 'i', 'u' : 'u', 'li' : '*', 'ul' : 'list', 'ol' : 'list', 'code' : 'code', 'a' : 'link', 'img' : 'img', 'blockquote' : 'quote' },
\r
36 stylesMap = { 'color' : 'color', 'size' : 'font-size' },
\r
37 attributesMap = { 'url' : 'href', 'email' : 'mailhref', 'quote': 'cite', 'list' : 'listType' };
\r
39 // List of block-like tags.
\r
40 var dtd = CKEDITOR.dtd,
\r
41 blockLikeTags = CKEDITOR.tools.extend( { table:1 }, dtd.$block, dtd.$listItem, dtd.$tableContent, dtd.$list );
\r
43 var semicolonFixRegex = /\s*(?:;\s*|$)/;
\r
44 function serializeStyleText( stylesObject )
\r
47 for ( var style in stylesObject )
\r
49 var styleVal = stylesObject[ style ],
\r
50 text = ( style + ':' + styleVal ).replace( semicolonFixRegex, ';' );
\r
57 function parseStyleText( styleText )
\r
61 .replace( /"/g, '"' )
\r
62 .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )
\r
64 retval[ name.toLowerCase() ] = value;
\r
69 function RGBToHex( cssStyle )
\r
71 return cssStyle.replace( /(?:rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\))/gi, function( match, red, green, blue )
\r
73 red = parseInt( red, 10 ).toString( 16 );
\r
74 green = parseInt( green, 10 ).toString( 16 );
\r
75 blue = parseInt( blue, 10 ).toString( 16 );
\r
76 var color = [red, green, blue] ;
\r
78 // Add padding zeros if the hex value is less than 0x10.
\r
79 for ( var i = 0 ; i < color.length ; i++ )
\r
80 color[i] = String( '0' + color[i] ).slice( -2 ) ;
\r
82 return '#' + color.join( '' ) ;
\r
86 // Maintain the map of smiley-to-description.
\r
87 var smileyMap = {"smiley":":)","sad":":(","wink":";)","laugh":":D","cheeky":":P","blush":":*)","surprise":":-o","indecision":":|","angry":">:(","angel":"o:)","cool":"8-)","devil":">:-)","crying":";(","kiss":":-*" },
\r
88 smileyReverseMap = {},
\r
91 // Build regexp for the list of smiley text.
\r
92 for ( var i in smileyMap )
\r
94 smileyReverseMap[ smileyMap[ i ] ] = i;
\r
95 smileyRegExp.push( smileyMap[ i ].replace( /\(|\)|\:|\/|\*|\-|\|/g, function( match ) { return '\\' + match; } ) );
\r
98 smileyRegExp = new RegExp( smileyRegExp.join( '|' ), 'g' );
\r
100 var decodeHtml = ( function ()
\r
105 nbsp : '\u00A0', // IE | FF
\r
106 shy : '\u00AD', // IE
\r
107 gt : '\u003E', // IE | FF | -- | Opera
\r
108 lt : '\u003C' // IE | FF | Safari | Opera
\r
111 for ( var entity in entities )
\r
112 regex.push( entity );
\r
114 regex = new RegExp( '&(' + regex.join( '|' ) + ');', 'g' );
\r
116 return function( html )
\r
118 return html.replace( regex, function( match, entity )
\r
120 return entities[ entity ];
\r
125 CKEDITOR.BBCodeParser = function()
\r
129 bbcPartsRegex : /(?:\[([^\/\]=]*?)(?:=([^\]]*?))?\])|(?:\[\/([a-z]{1,16})\])/ig
\r
133 CKEDITOR.BBCodeParser.prototype =
\r
135 parse : function( bbcode )
\r
141 while ( ( parts = this._.bbcPartsRegex.exec( bbcode ) ) )
\r
143 var tagIndex = parts.index;
\r
144 if ( tagIndex > lastIndex )
\r
146 var text = bbcode.substring( lastIndex, tagIndex );
\r
147 this.onText( text, 1 );
\r
150 lastIndex = this._.bbcPartsRegex.lastIndex;
\r
153 "parts" is an array with the following items:
\r
154 0 : The entire match for opening/closing tags and line-break;
\r
156 2 : open of tag excludes option;
\r
162 if ( ( part = parts[ 1 ] ) )
\r
164 part = part.toLowerCase();
\r
166 var tagName = bbcodeMap[ part ],
\r
169 optionPart = parts[ 2 ];
\r
173 if ( part == 'list' )
\r
175 if ( !isNaN( optionPart ) )
\r
176 optionPart = 'decimal';
\r
177 else if ( /^[a-z]+$/.test( optionPart ) )
\r
178 optionPart = 'lower-alpha';
\r
179 else if ( /^[A-Z]+$/.test( optionPart ) )
\r
180 optionPart = 'upper-alpha';
\r
183 if ( stylesMap[ part ] )
\r
185 // Font size represents percentage.
\r
186 if ( part == 'size' )
\r
189 styles[ stylesMap[ part ] ] = optionPart;
\r
190 attribs.style = serializeStyleText( styles );
\r
192 else if ( attributesMap[ part ] )
\r
193 attribs[ attributesMap[ part ] ] = optionPart;
\r
196 // Two special handling - image and email, protect them
\r
197 // as "span" with an attribute marker.
\r
198 if ( part == 'email' || part == 'img' )
\r
199 attribs[ 'bbcode' ] = part;
\r
201 this.onTagOpen( tagName, attribs, CKEDITOR.dtd.$empty[ tagName ] );
\r
204 else if ( ( part = parts[ 3 ] ) )
\r
205 this.onTagClose( bbcodeMap[ part ] );
\r
208 if ( bbcode.length > lastIndex )
\r
209 this.onText( bbcode.substring( lastIndex, bbcode.length ), 1 );
\r
214 * Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string.
\r
215 * @param {String} source The HTML to be parsed, filling the fragment.
\r
216 * @param {Number} [fixForBody=false] Wrap body with specified element if needed.
\r
217 * @returns CKEDITOR.htmlParser.fragment The fragment created.
\r
219 * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<b>Sample</b> Text' );
\r
220 * alert( fragment.children[0].name ); "b"
\r
221 * alert( fragment.children[1].value ); " Text"
\r
223 CKEDITOR.htmlParser.fragment.fromBBCode = function( source )
\r
225 var parser = new CKEDITOR.BBCodeParser(),
\r
226 fragment = new CKEDITOR.htmlParser.fragment(),
\r
227 pendingInline = [],
\r
229 currentNode = fragment,
\r
232 function checkPending( newTagName )
\r
234 if ( pendingInline.length > 0 )
\r
236 for ( var i = 0 ; i < pendingInline.length ; i++ )
\r
238 var pendingElement = pendingInline[ i ],
\r
239 pendingName = pendingElement.name,
\r
240 pendingDtd = CKEDITOR.dtd[ pendingName ],
\r
241 currentDtd = currentNode.name && CKEDITOR.dtd[ currentNode.name ];
\r
243 if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) )
\r
245 // Get a clone for the pending element.
\r
246 pendingElement = pendingElement.clone();
\r
248 // Add it to the current node and make it the current,
\r
249 // so the new element will be added inside of it.
\r
250 pendingElement.parent = currentNode;
\r
251 currentNode = pendingElement;
\r
253 // Remove the pending element (back the index by one
\r
254 // to properly process the next entry).
\r
255 pendingInline.splice( i, 1 );
\r
262 function checkPendingBrs( tagName, closing )
\r
264 var len = currentNode.children.length,
\r
265 previous = len > 0 && currentNode.children[ len - 1 ],
\r
266 lineBreakParent = !previous && BBCodeWriter.getRule( tagnameMap[ currentNode.name ], 'breakAfterOpen' ),
\r
267 lineBreakPrevious = previous && previous.type == CKEDITOR.NODE_ELEMENT && BBCodeWriter.getRule( tagnameMap[ previous.name ], 'breakAfterClose' ),
\r
268 lineBreakCurrent = tagName && BBCodeWriter.getRule( tagnameMap[ tagName ], closing ? 'breakBeforeClose' : 'breakBeforeOpen' );
\r
270 if ( pendingBrs && ( lineBreakParent || lineBreakPrevious || lineBreakCurrent ) )
\r
273 // 1. Either we're at the end of block, where it requires us to compensate the br filler
\r
274 // removing logic (from htmldataprocessor).
\r
275 // 2. Or we're at the end of pseudo block, where it requires us to compensate
\r
276 // the bogus br effect.
\r
277 if ( pendingBrs && tagName in blockLikeTags )
\r
280 while ( pendingBrs && pendingBrs-- )
\r
281 currentNode.children.push( previous = new CKEDITOR.htmlParser.element( 'br' ) );
\r
284 function addElement( node, target )
\r
286 checkPendingBrs( node.name, 1 );
\r
288 target = target || currentNode || fragment;
\r
290 var len = target.children.length,
\r
291 previous = len > 0 && target.children[ len - 1 ] || null;
\r
293 node.previous = previous;
\r
294 node.parent = target;
\r
296 target.children.push( node );
\r
298 if ( node.returnPoint )
\r
300 currentNode = node.returnPoint;
\r
301 delete node.returnPoint;
\r
305 parser.onTagOpen = function( tagName, attributes, selfClosing )
\r
307 var element = new CKEDITOR.htmlParser.element( tagName, attributes );
\r
309 // This is a tag to be removed if empty, so do not add it immediately.
\r
310 if ( CKEDITOR.dtd.$removeEmpty[ tagName ] )
\r
312 pendingInline.push( element );
\r
316 var currentName = currentNode.name;
\r
318 var currentDtd = currentName
\r
319 && ( CKEDITOR.dtd[ currentName ]
\r
320 || ( currentNode._.isBlockLike ? CKEDITOR.dtd.div : CKEDITOR.dtd.span ) );
\r
322 // If the element cannot be child of the current element.
\r
323 if ( currentDtd && !currentDtd[ tagName ] )
\r
325 var reApply = false,
\r
326 addPoint; // New position to start adding nodes.
\r
328 // If the element name is the same as the current element name,
\r
329 // then just close the current one and append the new one to the
\r
330 // parent. This situation usually happens with <p>, <li>, <dt> and
\r
331 // <dd>, specially in IE. Do not enter in this if block in this case.
\r
332 if ( tagName == currentName )
\r
333 addElement( currentNode, currentNode.parent );
\r
334 else if ( tagName in CKEDITOR.dtd.$listItem )
\r
336 parser.onTagOpen( 'ul', {} );
\r
337 addPoint = currentNode;
\r
342 addElement( currentNode, currentNode.parent );
\r
344 // The current element is an inline element, which
\r
345 // cannot hold the new one. Put it in the pending list,
\r
346 // and try adding the new one after it.
\r
347 pendingInline.unshift( currentNode );
\r
352 currentNode = addPoint;
\r
353 // Try adding it to the return point, or the parent element.
\r
355 currentNode = currentNode.returnPoint || currentNode.parent;
\r
359 parser.onTagOpen.apply( this, arguments );
\r
364 checkPending( tagName );
\r
365 checkPendingBrs( tagName );
\r
367 element.parent = currentNode;
\r
368 element.returnPoint = returnPoint;
\r
371 if ( element.isEmpty )
\r
372 addElement( element );
\r
374 currentNode = element;
\r
377 parser.onTagClose = function( tagName )
\r
379 // Check if there is any pending tag to be closed.
\r
380 for ( var i = pendingInline.length - 1 ; i >= 0 ; i-- )
\r
382 // If found, just remove it from the list.
\r
383 if ( tagName == pendingInline[ i ].name )
\r
385 pendingInline.splice( i, 1 );
\r
390 var pendingAdd = [],
\r
391 newPendingInline = [],
\r
392 candidate = currentNode;
\r
394 while ( candidate.type && candidate.name != tagName )
\r
396 // If this is an inline element, add it to the pending list, if we're
\r
397 // really closing one of the parents element later, they will continue
\r
399 if ( !candidate._.isBlockLike )
\r
400 newPendingInline.unshift( candidate );
\r
402 // This node should be added to it's parent at this point. But,
\r
403 // it should happen only if the closing tag is really closing
\r
404 // one of the nodes. So, for now, we just cache it.
\r
405 pendingAdd.push( candidate );
\r
407 candidate = candidate.parent;
\r
410 if ( candidate.type )
\r
412 // Add all elements that have been found in the above loop.
\r
413 for ( i = 0 ; i < pendingAdd.length ; i++ )
\r
415 var node = pendingAdd[ i ];
\r
416 addElement( node, node.parent );
\r
419 currentNode = candidate;
\r
422 addElement( candidate, candidate.parent );
\r
424 // The parent should start receiving new nodes now, except if
\r
425 // addElement changed the currentNode.
\r
426 if ( candidate == currentNode )
\r
427 currentNode = currentNode.parent;
\r
429 pendingInline = pendingInline.concat( newPendingInline );
\r
433 parser.onText = function( text )
\r
435 var currentDtd = CKEDITOR.dtd[ currentNode.name ];
\r
436 if ( !currentDtd || currentDtd[ '#' ] )
\r
441 text.replace(/([\r\n])|[^\r\n]*/g, function( piece, lineBreak )
\r
443 if ( lineBreak !== undefined && lineBreak.length )
\r
445 else if ( piece.length )
\r
449 // Create smiley from text emotion.
\r
450 piece.replace( smileyRegExp, function( match, index )
\r
452 addElement( new CKEDITOR.htmlParser.text( piece.substring( lastIndex, index ) ), currentNode );
\r
453 addElement( new CKEDITOR.htmlParser.element( 'smiley', { 'desc': smileyReverseMap[ match ] } ), currentNode );
\r
454 lastIndex = index + match.length;
\r
457 if ( lastIndex != piece.length )
\r
458 addElement( new CKEDITOR.htmlParser.text( piece.substring( lastIndex, piece.length ) ), currentNode );
\r
465 parser.parse( CKEDITOR.tools.htmlEncode( source ) );
\r
467 // Close all hanging nodes.
\r
468 while ( currentNode.type )
\r
470 var parent = currentNode.parent,
\r
471 node = currentNode;
\r
473 addElement( node, parent );
\r
474 currentNode = parent;
\r
480 CKEDITOR.htmlParser.BBCodeWriter = CKEDITOR.tools.createClass(
\r
490 // List and list item.
\r
491 this.setRules( 'list',
\r
493 breakBeforeOpen : 1,
\r
494 breakAfterOpen : 1,
\r
495 breakBeforeClose : 1,
\r
496 breakAfterClose : 1
\r
499 this.setRules( '*',
\r
501 breakBeforeOpen : 1,
\r
502 breakAfterOpen : 0,
\r
503 breakBeforeClose : 1,
\r
504 breakAfterClose : 0
\r
507 this.setRules( 'quote',
\r
509 breakBeforeOpen : 1,
\r
510 breakAfterOpen : 0,
\r
511 breakBeforeClose : 0,
\r
512 breakAfterClose : 1
\r
519 * Sets formatting rules for a given tag. The possible rules are:
\r
521 * <li><b>breakBeforeOpen</b>: break line before the opener tag for this element.</li>
\r
522 * <li><b>breakAfterOpen</b>: break line after the opener tag for this element.</li>
\r
523 * <li><b>breakBeforeClose</b>: break line before the closer tag for this element.</li>
\r
524 * <li><b>breakAfterClose</b>: break line after the closer tag for this element.</li>
\r
527 * All rules default to "false". Each call to the function overrides
\r
528 * already present rules, leaving the undefined untouched.
\r
530 * @param {String} tagName The tag name to which set the rules.
\r
531 * @param {Object} rules An object containing the element rules.
\r
533 * // Break line before and after "img" tags.
\r
534 * writer.setRules( 'list',
\r
536 * breakBeforeOpen : true
\r
537 * breakAfterOpen : true
\r
540 setRules : function( tagName, rules )
\r
542 var currentRules = this._.rules[ tagName ];
\r
544 if ( currentRules )
\r
545 CKEDITOR.tools.extend( currentRules, rules, true );
\r
547 this._.rules[ tagName ] = rules;
\r
550 getRule : function( tagName, ruleName )
\r
552 return this._.rules[ tagName ] && this._.rules[ tagName ][ ruleName ];
\r
555 openTag : function( tag, attributes )
\r
557 if ( tag in bbcodeMap )
\r
559 if ( this.getRule( tag, 'breakBeforeOpen' ) )
\r
560 this.lineBreak( 1 );
\r
562 this.write( '[', tag );
\r
563 var option = attributes.option;
\r
564 option && this.write( '=', option );
\r
567 if ( this.getRule( tag, 'breakAfterOpen' ) )
\r
568 this.lineBreak( 1 );
\r
570 else if ( tag == 'br' )
\r
571 this._.output.push( '\n' );
\r
574 openTagClose : function() { },
\r
575 attribute : function() { },
\r
577 closeTag : function( tag )
\r
579 if ( tag in bbcodeMap )
\r
581 if ( this.getRule( tag, 'breakBeforeClose' ) )
\r
582 this.lineBreak( 1 );
\r
584 tag != '*' && this.write( '[/', tag, ']' );
\r
586 if ( this.getRule( tag, 'breakAfterClose' ) )
\r
587 this.lineBreak( 1 );
\r
591 text : function( text )
\r
593 this.write( text );
\r
597 * Writes a comment.
\r
598 * @param {String} comment The comment text.
\r
600 * // Writes "<!-- My comment -->".
\r
601 * writer.comment( ' My comment ' );
\r
603 comment : function() {},
\r
606 * Output line-break for formatting.
\r
608 lineBreak : function()
\r
610 // Avoid line break when:
\r
611 // 1) Previous tag already put one.
\r
612 // 2) We're at output start.
\r
613 if ( !this._.hasLineBreak && this._.output.length )
\r
615 this.write( '\n' );
\r
616 this._.hasLineBreak = 1;
\r
622 this._.hasLineBreak = 0;
\r
623 var data = Array.prototype.join.call( arguments, '' );
\r
624 this._.output.push( data );
\r
629 this._.output = [];
\r
630 this._.hasLineBreak = 0;
\r
633 getHtml : function( reset )
\r
635 var bbcode = this._.output.join( '' );
\r
640 return decodeHtml ( bbcode );
\r
645 var BBCodeWriter = new CKEDITOR.htmlParser.BBCodeWriter();
\r
647 CKEDITOR.plugins.add( 'bbcode',
\r
649 requires : [ 'htmldataprocessor', 'entities' ],
\r
650 beforeInit : function( editor )
\r
652 // Adapt some critical editor configuration for better support
\r
653 // of BBCode environment.
\r
654 var config = editor.config;
\r
655 CKEDITOR.tools.extend( config,
\r
657 enterMode : CKEDITOR.ENTER_BR,
\r
658 basicEntities: false,
\r
660 fillEmptyBlocks : false
\r
663 init : function( editor )
\r
665 var config = editor.config;
\r
667 function BBCodeToHtml( code )
\r
669 var fragment = CKEDITOR.htmlParser.fragment.fromBBCode( code ),
\r
670 writer = new CKEDITOR.htmlParser.basicWriter();
\r
672 fragment.writeHtml( writer, dataFilter );
\r
673 return writer.getHtml( true );
\r
676 var dataFilter = new CKEDITOR.htmlParser.filter();
\r
677 dataFilter.addRules(
\r
681 'blockquote' : function( element )
\r
683 var quoted = new CKEDITOR.htmlParser.element( 'div' );
\r
684 quoted.children = element.children;
\r
685 element.children = [ quoted ];
\r
686 var citeText = element.attributes.cite;
\r
689 var cite = new CKEDITOR.htmlParser.element( 'cite' );
\r
690 cite.add( new CKEDITOR.htmlParser.text( citeText.replace( /^"|"$/g, '' ) ) );
\r
691 delete element.attributes.cite;
\r
692 element.children.unshift( cite );
\r
695 'span' : function( element )
\r
698 if ( ( bbcode = element.attributes.bbcode ) )
\r
700 if ( bbcode == 'img' )
\r
702 element.name = 'img';
\r
703 element.attributes.src = element.children[ 0 ].value;
\r
704 element.children = [];
\r
706 else if ( bbcode == 'email' )
\r
708 element.name = 'a';
\r
709 element.attributes.href = 'mailto:' + element.children[ 0 ].value;
\r
712 delete element.attributes.bbcode;
\r
715 'ol' : function ( element )
\r
717 if ( element.attributes.listType )
\r
719 if ( element.attributes.listType != 'decimal' )
\r
720 element.attributes.style = 'list-style-type:' + element.attributes.listType;
\r
723 element.name = 'ul';
\r
725 delete element.attributes.listType;
\r
727 a : function( element )
\r
729 if ( !element.attributes.href )
\r
730 element.attributes.href = element.children[ 0 ].value;
\r
732 'smiley' : function( element )
\r
734 element.name = 'img';
\r
736 var description = element.attributes.desc,
\r
737 image = config.smiley_images[ CKEDITOR.tools.indexOf( config.smiley_descriptions, description ) ],
\r
738 src = CKEDITOR.tools.htmlEncode( config.smiley_path + image );
\r
740 element.attributes =
\r
743 'data-cke-saved-src' : src,
\r
744 title : description,
\r
751 editor.dataProcessor.htmlFilter.addRules(
\r
755 $ : function( element )
\r
757 var attributes = element.attributes,
\r
758 style = parseStyleText( attributes.style ),
\r
761 var tagName = element.name;
\r
762 if ( tagName in convertMap )
\r
763 tagName = convertMap[ tagName ];
\r
764 else if ( tagName == 'span' )
\r
766 if ( ( value = style.color ) )
\r
769 value = RGBToHex( value );
\r
771 else if ( ( value = style[ 'font-size' ] ) )
\r
773 var percentValue = value.match( /(\d+)%$/ );
\r
774 if ( percentValue )
\r
776 value = percentValue[ 1 ];
\r
781 else if ( tagName == 'ol' || tagName == 'ul' )
\r
783 if ( ( value = style[ 'list-style-type'] ) )
\r
787 case 'lower-alpha':
\r
790 case 'upper-alpha':
\r
795 else if ( tagName == 'ol' )
\r
800 else if ( tagName == 'blockquote' )
\r
804 var cite = element.children[ 0 ],
\r
805 quoted = element.children[ 1 ],
\r
806 citeText = cite.name == 'cite' && cite.children[ 0 ].value;
\r
810 value = '"' + citeText + '"';
\r
811 element.children = quoted.children;
\r
821 else if ( tagName == 'a' )
\r
823 if ( ( value = attributes.href ) )
\r
825 if ( value.indexOf( 'mailto:' ) !== -1 )
\r
828 // [email] should have a single text child with email address.
\r
829 element.children = [ new CKEDITOR.htmlParser.text( value.replace( 'mailto:', '' ) ) ];
\r
834 var singleton = element.children.length == 1 && element.children[ 0 ];
\r
836 && singleton.type == CKEDITOR.NODE_TEXT
\r
837 && singleton.value == value )
\r
844 else if ( tagName == 'img' )
\r
846 element.isEmpty = 0;
\r
848 // Translate smiley (image) to text emotion.
\r
849 var src = attributes[ 'data-cke-saved-src' ];
\r
850 if ( src && src.indexOf( editor.config.smiley_path ) != -1 )
\r
851 return new CKEDITOR.htmlParser.text( smileyMap[ attributes.alt ] );
\r
853 element.children = [ new CKEDITOR.htmlParser.text( src ) ];
\r
856 element.name = tagName;
\r
857 value && ( element.attributes.option = value );
\r
862 // Remove any bogus br from the end of a pseudo block,
\r
863 // e.g. <div>some text<br /><p>paragraph</p></div>
\r
864 br : function( element )
\r
866 var next = element.next;
\r
867 if ( next && next.name in blockLikeTags )
\r
873 editor.dataProcessor.writer = BBCodeWriter;
\r
875 editor.on( 'editingBlockReady', function ()
\r
877 var wysiwyg = editor._.modes[ 'wysiwyg' ];
\r
878 wysiwyg.loadData = CKEDITOR.tools.override( wysiwyg.loadData, function( org )
\r
880 return function( data )
\r
882 return ( org.call( this, BBCodeToHtml( data ) ) );
\r
888 afterInit : function( editor )
\r
891 if ( editor._.elementsPath )
\r
893 // Eliminate irrelevant elements from displaying, e.g body and p.
\r
894 if ( ( filters = editor._.elementsPath.filters ) )
\r
895 filters.push( function( element )
\r
897 var htmlName = element.getName(),
\r
898 name = tagnameMap[ htmlName ] || false;
\r
900 // Specialized anchor presents as email.
\r
901 if ( name == 'link' && element.getAttribute( 'href' ).indexOf( 'mailto:' ) === 0 )
\r
903 // Styled span could be either size or color.
\r
904 else if ( htmlName == 'span' )
\r
906 if ( element.getStyle( 'font-size' ) )
\r
908 else if ( element.getStyle( 'color' ) )
\r
911 else if ( name == 'img' )
\r
913 var src = element.data( 'cke-saved-src' );
\r
914 if ( src && src.indexOf( editor.config.smiley_path ) === 0 )
\r