【发布时间】:2017-10-27 11:34:17
【问题描述】:
我正在创建一个自定义插件以允许编辑 itemprop 属性。 它工作得很好,只是在重新加载时属性会被剥离。 知道我做错了什么吗?
我阅读了可以在文档中找到的所有内容,包括以下示例:https://github.com/ckeditor/ckeditor-docs-samples/blob/master/tutorial-abbr-acf/abbr/plugin.js#L24
如果我禁用 ACF,它会起作用。
export default CKEDITOR => {
CKEDITOR.plugins.add('itemprop', {
init(editor) {
editor.addCommand('itemprop', new CKEDITOR.dialogCommand('itempropDialog', {
allowedContent: '*[itemprop]'
}));
CKEDITOR.dialog.add('itempropDialog', editor => {
return {
title: 'Itemprop',
contents: [
{
id: 'tab-main',
label: 'Itemprop',
elements: [
{
type: 'text',
id: 'itemprop',
label: 'Itemprop',
setup(element) {
this.setValue(element.getAttribute('itemprop'));
},
commit(element) {
element.setAttribute('itemprop', this.getValue());
}
}
]
}
],
onShow() {
const selection = editor.getSelection();
const element = selection.getStartElement();
this.element = element;
this.setupContent(this.element);
},
onOk() {
this.commitContent(this.element);
}
};
});
}
});
};
【问题讨论】:
-
现在我可以通过
extraAllowedContent('*[itemprop]')让它工作,但我更愿意让自动化解决方案工作。
标签: ckeditor