我在我的 MVC 应用程序中使用 CKEditor ver.3.6。
我的要求是在 ckEditor 中用新文本更新所选文本。我可以找到方法 editor.getSelection().getSelectedText();用于从编辑器中获取选定的文本。我需要在按下工具栏按钮时使用所选文本添加一些标签,并使用 javascript 更新所选内容。
例如:
ckEditor中的内容是
<span>Edit content in the editor</span>
我从 ckEditor 中选择了“编辑器”这个词。我必须使用 javascript 代码将所选单词“editor”更新为“ckEditor”。
请提出合适的解决方案。
最佳答案
在按钮的 onclick 事件中使用此函数。
function Replace()
{
//after selecting the text in the editor
//get text to replace;
var repStr=$("#repTxt").val();
editor.insertHtml(repStr);
}
干杯 苏尼尔·拉吉
关于javascript - 使用 javascript 将 ckEditor 中的选定内容替换为新内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8785954/