2013-03-11 54 views
1

我在我的iOS应用程序上实现了CKEditor,问题是我需要检测工具栏items.I有一个UIWebView显示CKEditor'demo.html'和一个按钮来测试过程,当按钮点击它触发的 'demo.html' 文件中的JavaScript功能,代码如下:如何使用javascript选择一个CKEditor工具栏项目?

从 'demo.html' 的Javascript:

<script type="text/javascript"> 

    function mateus(){ 

     // SIMULATE TOUCH ON TOOLBAR ITEM 

    } 

    CKEDITOR.replace('editor1', 
      { 
       extraPlugins : 'uicolor', 
       removePlugins: 'elementspath', 
       toolbar : 
       [ 
        [ 'Bold', 'Italic', 'Underline','NumberedList','BulletedList'] 
       ] 
}); 
</script> 

UIButton的行动:

-(IBAction)buttonTester:(id)sender{ 

    [webView stringByEvaluatingJavaScriptFromString:@"mateus()"]; 

} 

这部分工作正常,问题是,就像我之前说过的,我需要模拟工具栏项目上的触摸,我不知道该怎么做这样的事情!

简化:

如何使用javascript选择CKEditor的工具栏项目?

EDIT ------------------------------------------- ---------------------------

我搜索了一点,我在CKEditor的文档中找到这段代码:

editorInstance.execCommand('bold'); 

但我不能把它的工作,这是我新的尝试:

function mateus(){ 

      CKEDITOR.instances.editor1.execCommand('bold'); 

} 

回答

1

最后我抓到你了,就这么简单的样子:

要选择工具栏项想到了一个JavaScript函数简单的使用下面的代码片段:

function mateus(){ 

    //Desired item from toolbar, like:('Italic','Underline','Image'); 
    CKEDITOR.instances.editor1.execCommand('bold'); 

} 
相关问题