当使用“从Word粘贴”对话框时,它似乎会自动运行,但也可以从代码中使用。
我不是CKEditor API方面的专家,因此可能有一种更有效或更正确的方法来实现这一点,但在当前版本(3.3.1)中似乎可以做到这一点:
function cleanUp() {
if (!CKEDITOR.cleanWord) {
// since the filter is lazily loaded by the pastefromword plugin we need to add it ourselves.
// We use the same function as the callback for when the cleanup filter is loaded. Change the script path to the correct one
CKEDITOR.scriptLoader.load("../plugins/pastefromword/filter/default.js", cleanUp, null, false, true );
alert('loading script for the first usage');
} else { // The cleanWord is available for use
// change to the correct editor instance
var editor = CKEDITOR.instances.editor1;
// perform the clean up
var cleanedUpData = CKEDITOR.cleanWord(editor .getData(), editor );
// do something with the clean up
alert(cleanedUpData);
}
}
cleanUp();
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
(搜索“pasteFromWord”选项)。
如果您需要更高级的东西,但是需要服务器访问,我建议您关闭WordOff(
http://wordoff.org/
). 您可以围绕其服务构建一个代理和jsonp包装器,这样就可以从客户端使用它,而无需安装服务器。