import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
import informationIcon from '../../themes/icons/information.svg';
import * as QMSCKEditorService from '../common/qmsCKEditorService';
import { version } from '@ckeditor/ckeditor5-utils';

export default class AboutCKEditor extends Plugin {
    init() {
        const editor = this.editor;
        const t = editor.t;
        editor.ui.componentFactory.add('aboutCKEditor', locale => {
            const buttonView = new ButtonView( locale );

            buttonView.set( {
                label: t('About CKEditor'),
                icon: informationIcon,
                withText: false,
                tooltip: true
            } );

            buttonView.on('execute', () => {
                QMSCKEditorService.aboutCKEditorNotify(version);
            });

            return buttonView;
        } );
    }
}
