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

问题描述 投票:0回答:1

我遵循了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

我该如何进行这项工作?

ckeditor ckeditor5
1个回答
0
投票

似乎目前尚无办法干净地进行此操作。已经存在一个问题:https://github.com/ckeditor/ckeditor5/issues/1633

© www.soinside.com 2019 - 2024. All rights reserved.