简体   繁体   English

如何获取Meteor-ShareJS文档文本

[英]How to get meteor-sharejs documents text

I am using meteor-sharejs 我正在使用meteor-sharejs

I add the package 我添加包裹

meteor add mizzao:sharejs-ace

Now in my view, i add the document 现在在我看来,我添加了文档

{{> sharejsAce docid="javascriptDoc" id="editor"}}

I know that meteor-sharejs creates ops collection and docs. 我知道meteor-sharejs创建ops集合和文档。

My Questions is how do i grab the current raw text of of the "javascriptDoc" document on the server so i send it somewhere else. 我的问题是如何在服务器上获取“ javascriptDoc”文档的当前原始文本,以便将其发送到其他地方。 Like listen for changes and grab that content. 喜欢听更改并获取该内容。

You probably want to check the ShareJS API for this. 您可能想要检查ShareJS API。

mizzao:sharejs is currently using ShareJS 0.6.3; mizzao:sharejs当前正在使用ShareJS 0.6.3; here is the server API . 这是服务器API You probably want to use the getSnapshot function. 您可能要使用getSnapshot函数。

The package makes ShareJS available in ShareJS.model , so try ShareJS.model.getSnapShot(...) on the server. 该软件包使得可用ShareJS ShareJS.model ,所以尽量ShareJS.model.getSnapShot(...)的服务器上。

Note: I wrote this package. 注意:我写了这个包。

My final solution 我的最终解决方案

   Meteor.methods({

    getDocumentText: function () {
        var result = getSnapshotSync('htmlDocumentId');
        return result.snapshot;
    }

});

//create sync method.    
getSnapshotSync = Meteor.wrapAsync(ShareJS.model.getSnapshot)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM