我遵循了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
中,如下所示:
但是,在编辑器中呈现的html没有向下转换<strong></strong>
我该如何进行这项工作?
似乎目前尚无办法干净地进行此操作。已经存在一个问题:https://github.com/ckeditor/ckeditor5/issues/1633