123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
-
- (function() {
-
- function isallMediasEmbed( element ) {
- var attributes = element.attributes;
- return ( attributes.mtype == 'allmedias');
- }
- function createFakeElement( editor, realElement ) {
- return editor.createFakeParserElement( realElement, 'cke_allMedias', 'allMedias', true );
- }
- CKEDITOR.plugins.add( 'allmedias', {
- requires: 'dialog,fakeobjects',
- lang: 'en,zh-cn,zh',
- icons: 'allmedias',
- onLoad: function() {
- CKEDITOR.addCss( 'img.cke_allmedias' +
- '{' +
- 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
- 'background-position: center center;' +
- 'background-repeat: no-repeat;' +
- 'border: 1px solid #a9a9a9;' +
- 'width: 80px;' +
- 'height: 80px;' +
- '}'
- );
-
- },
- init: function( editor ) {
- editor.addCommand( 'allmedias', new CKEDITOR.dialogCommand( 'allmedias' ) );
- editor.ui.addButton && editor.ui.addButton( 'allmedias', {
- label: 'Вставить различные медиа',
- command: 'allmedias',
- toolbar: 'insert,5'
- });
- CKEDITOR.dialog.add( 'allmedias', this.path + 'dialogs/allmedias.js' );
-
- if ( editor.addMenuItems ) {
- editor.addMenuGroup( 'mediagroup' );
- editor.addMenuItems({
- mediamenu: {
- label: editor.lang.allmedias.properties,
- command: 'allmedias',
- group: 'mediagroup',
- icon: this.icons,
-
- }
- });
- }
- editor.on( 'doubleclick', function( evt ) {
- var element = evt.data.element;
- if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'allmedias' )
- evt.data.dialog = 'allmedias';
- });
-
- if ( editor.contextMenu ) {
- editor.contextMenu.addListener( function( element, selection ) {
- if ( element && element.is( 'img' ) && !element.isReadOnly() && element.data( 'cke-real-element-type' ) == 'allmedias' )
- return { mediamenu: CKEDITOR.TRISTATE_OFF };
- });
- }
- },
- afterInit: function( editor ) {
- var dataProcessor = editor.dataProcessor,
- dataFilter = dataProcessor && dataProcessor.dataFilter;
- htmlFilter = dataProcessor && dataProcessor.htmlFilter;
- if ( dataFilter ) {
- dataFilter.addRules({
- elements: {
- 'cke:object': function( element ) {
- var attributes = element.attributes;
-
- if ( !isallMediasEmbed( element ) ) {
-
- for ( var i = 0; i < element.children.length; i++ ) {
- if ( element.children[ i ].name == 'cke:embed' ) {
- if ( !isallMediasEmbed( element.children[ i ] ) )
- return null;
- return createFakeElement( editor, element );
- }
- }
- return null;
- }
- else{
- return createFakeElement( editor, element );
- }
- },
- 'cke:embed': function( element ) {
- if ( !isallMediasEmbed( element ) )
- return null;
- return createFakeElement( editor, element );
- }
- }
- }, 1 );
- }
-
- }
- });
- })();
- CKEDITOR.tools.extend( CKEDITOR.config, {
-
- allMediasEmbedTagOnly: false,
-
- allMediasAddEmbedTag: true,
-
- allMediasConvertOnEdit: false
- });
|