我写了自己的插件,可以生成一个简单的链接。奇怪的是,我无法编辑“ href”属性。其他属性可以编辑。
该元素不起作用:
{
type: 'text',
id: 'url',
label: 'URL',
commit: function(element) {
element.setAttribute('href', this.getValue());
},
setup: function(element) {
this.setValue(element.getAttribute('href'));
}
}
创建链接时,将写入href属性。当我编辑链接时,“ href”属性不会更改。奇怪的!
当我更改上面的代码并将属性名称重写为“ href-s”时:
{
type: 'text',
id: 'url',
label: 'URL',
commit: function(element) {
element.setAttribute('href-s', this.getValue());
},
setup: function(element) {
this.setValue(element.getAttribute('href-s'));
}
}
创建和编辑属性可以完美工作。
您不知道出什么问题了吗?
谢谢你。
由于各种内部原因,CKEditor使用data-cke-saved-href
属性href
在运行时进行复制。所以输出中的内容看起来像
<p>I'm a <a href="http://foo.com">plain link</a>.</p>
<p>I'm a <a href="mailto:[email protected]?subject=Subject&body=Body">mailto link</a>.</p>
实际上在编辑器DOM中有所不同
<p>I'm a <a data-cke-saved-href="http://foo.com" href="http://foo.com">plain link</a>.</p>
<p>I'm a <a data-cke-saved-href="mailto:[email protected]?subject=Subject&body=Body" href="mailto:[email protected]?subject=Subject&body=Body">mailto link</a>.</p>
data-
每次更改时href
都要更新属性,然后一切正常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句