[英]Setting up ShareJS in Meteor
I am having trouble in setting up meteor-share.js . 我在设置meteor-share.js时遇到了麻烦。
Basically I followed their README. 基本上,我遵循他们的自述文件。
{{> sharejsAce docid=docid id="editor"}}
What is the second docid
here? 这里的第二个
docid
是什么? I guess it's a helper function of the template that contains the unique name of the document that I want to synchronize? 我猜这是模板的帮助程序功能,其中包含我要同步的文档的唯一名称?
What's the first docid
? 什么是第一个
docid
? is this keyword for meteor-share.js? 这个是meteor-share.js的关键字吗?
Once I include this in a html (or template), what do I need to do in the js side (client/server?)? 一旦将其包含在html(或模板)中,我需要在js端(客户端/服务器)做什么? Is there anything I should do make the template (sharejsAce) to share text?
我应该做些什么来使模板(sharejsAce)共享文本?
I do not maintain multiple editors in a page so I am not sure what I should include and exclude from the demo. 我不在页面中维护多个编辑器,因此我不确定应在演示中包括和排除哪些内容。
I wonder if this is simply a bug in the API. 我想知道这是否仅仅是API中的错误。 when I changed to codemirror editor it just worked.
当我更改为Codemirror编辑器后,它开始工作了。 The error was saying:
错误是在说:
Uncaught TypeError: Cannot read property 'range' of undefined
未捕获的TypeError:无法读取未定义的属性“范围”
I assume you are using version 1.2.0. 我假设您使用的是1.2.0版。 If this is the case, you need to force a downgrade to version 1.1.9.
在这种情况下,您需要强制降级到1.1.9版。
You can do this by running the following command: meteor add mizzao:sharejs-ace@=1.1.9
or by changing the version manually in the .meteor/versions
file: mizzao:sharejs-ace@1.1.9
. 您可以通过运行以下命令来做到这一点:
meteor add mizzao:sharejs-ace@=1.1.9
或在.meteor/versions
文件: mizzao:sharejs-ace@1.1.9
手动更改版本。
Read more about this issue on GitHub . 在GitHub上了解有关此问题的更多信息。
What is the second docid here?
这里的第二个医生是什么? I guess it's a helper function of the template that contains the unique name of the document that I want to synchronize?
我猜这是模板的帮助程序功能,其中包含我要同步的文档的唯一名称?
The docid
parameter in {{> sharejsAce docid=docid id="editor"}}
is used to specify the document which should be displayed in the editor. {{> sharejsAce docid=docid id="editor"}}
的docid
参数用于指定应在编辑器中显示的文档。 So, the second docid
is the name of the helper function which simply returns the document's _id
that has been selected: 因此, 第二个
docid
是helper函数的名称,该函数仅返回已选择的文档的_id
:
Template.docItem.events =
"click a": (e) ->
e.preventDefault()
Session.set("document", @_id)
Template.editor.helpers
docid: -> Session.get("document")
Once I include this in a html (or template), what do I need to do in the js side (client/server?)?
一旦将其包含在html(或模板)中,我需要在js端(客户端/服务器)做什么? Is there anything I should do make the template (sharejsAce) to share text?
我应该做些什么来使模板(sharejsAce)共享文本?
If you want to mirror ShareJS data with a Meteor collection and use the ShareJS user access control, you need to create a settings file, like in the demo : 如果要使用Meteor集合镜像ShareJS数据并使用ShareJS用户访问控制,则需要创建一个设置文件,如演示中所示 :
{
"sharejs": {
"options": {
"accounts_auth": {
"authorize": {
"collection": "documents",
"token_validations": {
"or": {
"invitedUsers": "is_in_array",
"userId": "is_equal"
}
},
"apply_on": [
"read",
"update",
"create",
"delete"
]
},
"authenticate": {
"collection": "users",
"token_validations": {
"_id": "is_equal"
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.