我遵循了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>
我该如何做?