Пытаюсь сделать по мануалам
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import Widget from '@ckeditor/ckeditor5-widget/src/widget';
import InsertTooltipCommand from './inserttooltipcommand';
import { toWidget } from '@ckeditor/ckeditor5-widget/src/utils';
export default class TooltipEditing extends Plugin {
static get requires() {
return [ Widget ];
}
init() {
this._defineSchema();
this._defineConverters();
this.editor.commands.add('insertTooltip', new InsertTooltipCommand(this.editor));
}
_defineSchema() {
const schema = this.editor.model.schema;
schema.register('tooltip', {
// Behaves like a self-contained object (e.g. an image).
isObject: true,
isInline: true,
allowIn: 'paragraph',
allowAttributes: [ 'class', 'content' ]
});
}
_defineConverters() {
const conversion = this.editor.conversion;
conversion.for('editingDowncast').elementToElement({
model: 'tooltip',
view: (modelElement, downcastWriter) => {
const title = prompt( 'Текст' );
const header = prompt( 'Заголовок' );
const content = prompt( 'Содержание' );
const div = downcastWriter.createContainerElement('span', { class: 'p-post__tooltip', content: '<button class="b-button _plain" type="button" > <span class="b-icon _close"></span> </button> <h3>'+header+'</h3><p>'+content+'</p>' });
const text = downcastWriter.createText(title);
downcastWriter.insert(downcastWriter.createPositionAt(div, 0), text);
return toWidget(div, downcastWriter, { label: 'tooltip widget' });
}
});
}
}
В само тело контента вставляется
https://pix.my/FoyQ3J но после сохранения ничего нет.