CKEDITOR.dialog.add( 'injectDialog', function( editor ) { return { title: 'Вставка Inject', minWidth: 400, minHeight: 200, contents: [ { id: 'tab-basic', label: 'Базовые', elements: [ { type: 'text', id: 'url', label: 'Вставьте ссылку', validate: CKEDITOR.dialog.validate.notEmpty( "Поле для ссылки не должно быть пустым" ), setup: function( element ) { this.setValue( element.getAttribute( "url" ) ); }, commit: function( element ) { element.setText( this.getValue() ); } }, { type: 'radio', id: 'orientation', label: 'Выбрать', items: [ [ 'Маленький', '1' ], [ 'Большой', '2' ], [ 'Узкий', '3' ] ], 'default': '1', setup: function( element ) { this.setValue( element.getAttribute( "type" ) ); }, commit: function( element ) { element.setAttribute( "orientation", this.getValue() ); } } ] }, ], onShow: function() { var selection = editor.getSelection(); var element = selection.getStartElement(); //console.log(editor.getSelectedHtml(true)); //element = editor.document.createElement( editor.getSelectedRanges() ); if ( !element || !element.hasClass('insinject') ) { element = editor.document.createElement( 'inject' ); this.insertMode = true; } else this.insertMode = false; this.element = element; if ( !this.insertMode ) this.setupContent( this.element ); }, onOk: function() { var dialog = this; var inject = editor.document.createElement( 'div' ); inject.setAttribute('class', 'insinject'); inject.setAttribute( 'type', dialog.getValueOf('tab-basic', 'orientation') ); inject.setAttribute( 'url', dialog.getValueOf( 'tab-basic', 'url' ) ); inject.setHtml('  '); editor.insertElement( inject ); } }; });