Skip to content

Commit

Permalink
Merge branch 't/11202'
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Nov 25, 2013
2 parents 9c3b8e4 + ef675a4 commit 50bcc9a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Fixed Issues:
* [#11132](http://dev.ckeditor.com/ticket/11132): [Firefox] Fixed: Caret is lost after drag and drop of inline widget.
* [#11182](http://dev.ckeditor.com/ticket/11182): [Internet Explorer 10-11] Fixed: Editor crashes (IE11) or works with minor issues (IE10) if page is loaded in Quirks Mode. See [`env.quirks`](http://docs.ckeditor.com/#!/api/CKEDITOR.env-property-quirks) for more details.
* [#11204](http://dev.ckeditor.com/ticket/11204): Added `figure` and `figcaption` styles to `contents.css` so [Enhanced Image](http://ckeditor.com/addon/image2) looks nicer.
* [#11202](http://dev.ckeditor.com/ticket/11202): Fixed: No newline at BB-code mode.

## CKEditor 4.3

Expand Down
45 changes: 26 additions & 19 deletions plugins/bbcode/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
tab.remove( 'txtAlt' );
tab.remove( 'basic' );
}
});
} );

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' },
convertMap = { strong: 'b', b: 'b', u: 'u', em: 'i', i: 'i', code: 'code', li: '*' },
Expand All @@ -34,7 +34,7 @@

// List of block-like tags.
var dtd = CKEDITOR.dtd,
blockLikeTags = CKEDITOR.tools.extend( { table:1 }, dtd.$block, dtd.$listItem, dtd.$tableContent, dtd.$list );
blockLikeTags = CKEDITOR.tools.extend( { table: 1 }, dtd.$block, dtd.$listItem, dtd.$tableContent, dtd.$list );

var semicolonFixRegex = /\s*(?:;\s*|$)/;

Expand All @@ -59,7 +59,7 @@
smileyReverseMap[ smileyMap[ i ] ] = i;
smileyRegExp.push( smileyMap[ i ].replace( /\(|\)|\:|\/|\*|\-|\|/g, function( match ) {
return '\\' + match;
}));
} ) );
}

smileyRegExp = new RegExp( smileyRegExp.join( '|' ), 'g' );
Expand All @@ -81,7 +81,7 @@
return function( html ) {
return html.replace( regex, function( match, entity ) {
return entities[ entity ];
});
} );
};
})();

Expand Down Expand Up @@ -380,12 +380,12 @@
addElement( new CKEDITOR.htmlParser.text( piece.substring( lastIndex, index ) ), currentNode );
addElement( new CKEDITOR.htmlParser.element( 'smiley', { desc: smileyReverseMap[ match ] } ), currentNode );
lastIndex = index + match.length;
});
} );

if ( lastIndex != piece.length )
addElement( new CKEDITOR.htmlParser.text( piece.substring( lastIndex, piece.length ) ), currentNode );
}
});
} );
}
};

Expand All @@ -404,29 +404,29 @@
return fragment;
};

var BBCodeWriter = CKEDITOR.tools.createClass({
var BBCodeWriter = CKEDITOR.tools.createClass( {
$: function() {
this._ = {
output: [],
rules: []
};

// List and list item.
this.setRules( 'list', { breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:1,breakAfterClose:1 });
this.setRules( 'list', { breakBeforeOpen: 1, breakAfterOpen: 1, breakBeforeClose: 1, breakAfterClose: 1 } );

this.setRules( '*', {
breakBeforeOpen: 1,
breakAfterOpen: 0,
breakBeforeClose: 1,
breakAfterClose: 0
});
} );

this.setRules( 'quote', {
breakBeforeOpen: 1,
breakAfterOpen: 0,
breakBeforeClose: 0,
breakAfterClose: 1
});
} );
},

proto: {
Expand Down Expand Up @@ -542,25 +542,32 @@
return decodeHtml( bbcode );
}
}
});
} );

var writer = new BBCodeWriter();

CKEDITOR.plugins.add( 'bbcode', {
requires: 'entities',

// Adapt some critical editor configuration for better support
// of BBCode environment.
beforeInit: function( editor ) {
// Adapt some critical editor configuration for better support
// of BBCode environment.
var config = editor.config;

CKEDITOR.tools.extend( config, {
// This one is for backwards compatibility only as
// editor#enterMode is already set at this stage (#11202).
enterMode: CKEDITOR.ENTER_BR,
basicEntities: false,
entities: false,
fillEmptyBlocks: false
}, true );

editor.filter.disable();

// Since CKEditor 4.3, editor#(active)enterMode is set before
// beforeInit. Properties got to be updated (#11202).
editor.activeEnterMode = editor.enterMode = CKEDITOR.ENTER_BR;
},

init: function( editor ) {
Expand All @@ -575,7 +582,7 @@
}

var bbcodeFilter = new CKEDITOR.htmlParser.filter();
bbcodeFilter.addRules({
bbcodeFilter.addRules( {
elements: {
blockquote: function( element ) {
var quoted = new CKEDITOR.htmlParser.element( 'div' );
Expand Down Expand Up @@ -632,9 +639,9 @@
};
}
}
});
} );

editor.dataProcessor.htmlFilter.addRules({
editor.dataProcessor.htmlFilter.addRules( {
elements: {
$: function( element ) {
var attributes = element.attributes,
Expand Down Expand Up @@ -739,7 +746,7 @@
if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE )
editor.once( 'contentDom', function() {
editor.on( 'setData', onSetData );
});
} );
else
editor.on( 'setData', onSetData );

Expand Down Expand Up @@ -770,10 +777,10 @@
}

return name;
});
} );
}
}
}
});
} );

})();

0 comments on commit 50bcc9a

Please sign in to comment.