0

我正在使用 Onlyoffice 文档服务器版本 5.0.3 它工作正常。在文档编辑器中查找和替换文本

Onlyoffice配置文件:editor.jsp

config = {
    "document": {
    "fileType": "docx",
    "key": "Khirz6zTPdfd7",
    "title": "sample.docx",
    "url": "http://192.168.0.1:8080/onlyofficeexample/files/192.168.0.1/sample.docx"
    },
    "documentType": "text",
    "editorConfig": {
        "callbackUrl": "http://192.168.0.1:8080/onlyofficeexample/IndexServlet?type=track&fileName=sample.docx&userAddress=192.168.0.1"
    }
         ........
         .......
  };
var docEditor = new DocsAPI.DocEditor("placeholder", config);
setTimeout(function(){
      var text_replace = {
        textsearch: "~($#effective_date#$)~",
        textreplace: "23/05/1991",
        matchcase: false,
        matchword: false,
        highlight: true
     };
     docEditor.onReplaceText(text_replace);
}, 30000);

我正在尝试用调用 API 替换文本,并在 Onlyoffice API 调用中创建了进一步的触发函数。

   //trigger function
     onReplaceText: function (data) {
            $me.trigger("onreplacetext", data)
     }, 

在这里,我想根据传递给此函数的数据查找和替换文本

     onReplaceText:function(data){

     }
    Common.Gateway.on('onreplacetext',_.bind(me.onReplaceText, me));

谢谢你

4

2 回答 2

0

使用 asc_replaceText 的方法修改文档内容是不正确的。您的请求可以通过文档构建器(请参阅 API 的这一部分)或插件的方式实现。我们也很高兴地宣布 find-replace 方法的功能列表将添加到文档构建器的以下更新中,并且它也可用于插件。

于 2017-11-10T12:24:41.037 回答
0

最后,我使用下面的代码替换了 onlyoffice API 中的文本。

//trigger function    
 onReplaceText: function (data) {
        $me.trigger("onreplacetext", data)
 }, 

在这里,我想根据传递给此函数的数据查找和替换文本

 onReplaceText:function(data){
   data=data.data;
   this.api.asc_replaceText(data.textsearch, data.textreplace,true, data.matchcase, data.matchword);
  }
Common.Gateway.on('onreplacetext',_.bind(me.onReplaceText, me));
于 2017-11-08T10:55:50.540 回答