2017-11-08 6 views
0

私はOfficeドキュメントバージョン5.0.3のみを使用しています。正常に動作します。見つけると、文書エディタでテキストを置き換えるOnlyoffice APIを呼び出してテキストを置き換える方法

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)); 

を渡されたデータに基づいてテキストを検索と置換したい最後に、私はコードの下に使用してonlyoffice APIでテキストを置き換え

答えて

0

ありがとうございます。ここ

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

私は文書の内容を変更するためにasc_replaceTextの方法を使用することが間違っている、この関数に

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)); 
0

を渡されたデータに基づいてテキストを検索と置換します。あなたのリクエストは、ドキュメントビルダー(APIのこのセクションをご覧ください)またはプラグインを使用して実現できます。また、find-replaceメソッドの機能リストは、ドキュメントビルダの次のアップデートで追加され、プラグインでも利用可能になることをお知らせします。

+0

@Alexander_onlyofficeご返信ありがとうございます –

関連する問題