好吧,这看起来很简单,我想<strike>
在选择之前添加一个并在选择之后添加/by User</strike>
..
这是我到目前为止得到的:
CKEDITOR.plugins.add('test',
{
init: function (editor) {
editor.addCommand('inserttest',
{
exec: function (editor) {
var selection = editor.getSelection();
if (!selection) {
return;
}
var text = selection.getSelectedText();
editor.insertHtml('<strike>' + text + ' /By User </strike>');
}
});
editor.ui.addButton('test',
{
label: 'Insert test',
command: 'inserttest',
icon: this.path + 'images/test.png'
});
}
});
这有点工作,但它有一些怪癖它删除了所有 html 并且它也不能验证我们是否已经在罢工中......
那么我将如何在不丢失 html 的情况下做到这一点?并验证我已经不在罢工标签内?
我试图分析插件的源代码,但发现它至少可以说令人困惑......
注意我使用 asp.net 控制女巫似乎使用 CKEditor 的 3.6.4 版本。