CKEDITOR.plugins.add( 'html5audio', { requires: 'widget', lang: 'de,en,eu,es,fr,ru,uk,uz', icons: 'html5audio', init: function( editor ) { editor.widgets.add( 'html5audio', { button: editor.lang.html5audio.button, template: '
', // We add the audio element when needed in the data function, to avoid having an undefined src attribute. // See issue #9 on github: https://github.com/iametza/ckeditor-html5-audio/issues/9 editables: {}, /* * Allowed content rules (http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules): * - div-s with text-align,float,margin-left,margin-right inline style rules and required ckeditor-html5-audio class. * - audio tags with src and controls attributes. */ allowedContent: 'div(!ckeditor-html5-audio){text-align,float,margin-left,margin-right}; audio[src,controls,autoplay];', requiredContent: 'div(ckeditor-html5-audio); audio[src,controls];', upcast: function( element ) { return element.name === 'div' && element.hasClass( 'ckeditor-html5-audio' ); }, dialog: 'html5audio', init: function() { var src = ''; var autoplay = ''; var align = this.element.getStyle( 'text-align' ); // If there's a child (the audio element) if ( this.element.getChild( 0 ) ) { // get it's attributes. src = this.element.getChild( 0 ).getAttribute( 'src' ); autoplay = this.element.getChild( 0 ).getAttribute( 'autoplay' ); } if ( src ) { this.setData( 'src', src ); if ( align ) { this.setData( 'align', align ); } else { this.setData( 'align', 'none' ); } if ( autoplay ) { this.setData( 'autoplay', 'yes' ); } } }, data: function() { // If there is an audio source if ( this.data.src ) { // and there isn't a child (the audio element) if ( !this.element.getChild( 0 ) ) { // Create a new