如何将CKEDitor 5 Bold插件应用于我自己的内联元素

时间:2019-12-29 13:36:31

标签: ckeditor ckeditor5

我遵循了https://ckeditor.com/docs/ckeditor5/latest/framework/guides/tutorials/implementing-an-inline-widget.html上的实施内嵌窗口小部件教程。

我想扩展它以启用占位符的加粗。

我将this.editor.model.schema.extend( 'placeholder', { allowAttributes: 'bold' } );添加到了PlaceholderEditing.init(),所以现在看起来像这样:

    init() {
        this._defineSchema();
        this._defineConverters();

        this.editor.commands.add('placeholder', new PlaceholderCommand(this.editor));

        this.editor.editing.mapper.on(
            'viewToModelPosition',
            viewToModelPositionOutsideModelElement(this.editor.model, viewElement => viewElement.hasClass('placeholder'))
        );
        this.editor.config.define( 'placeholderConfig', {
            types: [ 'date', 'first name', 'surname' ]
        } );
        this.editor.model.schema.extend( 'placeholder', { allowAttributes: 'bold' } ); //ADDED
    }

然后我将占位符包裹在<strong></strong>中,就像这样:

<strong><span class="placeholder" >{mike}</span></strong>

检查器向我显示该属性已添加到模型中的placeholder,如下所示:

enter image description here

但是,在编辑器中呈现的html并没有向下转换<strong></strong>

enter image description here

我该如何做?

1 个答案:

答案 0 :(得分:0)

看来目前尚无办法干净地做到这一点。已经存在一个问题:https://github.com/ckeditor/ckeditor5/issues/1633