import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
import TemplateIcon from '../../themes/icons/template.svg';
import TemplateDialogCommand from './templatedialogcommand';
export default class QMSCKEditorTemplatePlugin extends Plugin {
    init() {
        const editor = this.editor;
        const t = editor.t;
        editor.ui.componentFactory.add('qmsTemplate', locale => {
            const view = new ButtonView(locale);
            const command = editor.commands.get('templateDialog');
            view.set({
                label: t('Add Template'),
                icon: TemplateIcon,
                tooltip: true
            });

            view.bind('isEnabled').to(command);

            view.on('execute', () => {
              command.execute();
            });

            return view;
        });

        editor.commands.add('templateDialog', new TemplateDialogCommand(editor));
    }
}
