UNPKG

@concordnow/ckeditor5-image-rendering

Version:
33 lines (29 loc) 614 B
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; export default class ImageAlign extends Plugin { static get pluginName() { return 'ImageAlign'; } init() { const editor = this.editor; const conversion = editor.conversion; conversion.for( 'upcast' ) .attributeToAttribute( { view: { name: 'img', styles: { 'float': /[\s\S]+/ } }, model: { key: 'imageStyle', value: viewImage => { return { left: 'alignLeft', right: 'alignRight', center: 'alignCenter' }[ viewImage.getStyle( 'float' ) ]; } } } ); } }