0

试图启动并运行简单版本的 codemirror,但是当我在两个 diff 浏览器(或 incog 中的一个)上访问文档时,我在控制台中收到此错误:

解析前向通道时出错错误:transformData 处的映射无效

这是两个不同的用户登录并访问同一个文档。当没有人登录并且只有两个差异浏览器访问文档时工作正常。我按照根目录中的说明设置了 settings.json 文件,并且正在运行流星 1.2.1,因为该版本仍然适用于 Sharejs。我正在运行它:meteor --release 1.2.1 --settings settings.json。

{
 "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"
            }
        }
      }
    }
  }
}

在文档呈现时的 HTML 中,两者都具有正确的 docid(即相同的 docid)......但显然我没有看到文本镜像。

使用简单的 codemirror 版本 ( {{> sharejsCM docid=docid id="editor"}})

有任何想法吗?

4

1 回答 1

0

查看https://www.coursera.org/learn/web-application-development/lecture/QAxTR/textcircle中的示例 代码为:textcircle.html:

<head>
    <title>Text Circle</title>
</head>
<body>
    <h1>Welcome to Text Circle - a Collaboration Tool.</h1>
    {{> editor}}
</body>
<template name="editor">
   {{> sharejsCM docid=docId id="Editor"}} 
</template>

---- textcircle.js:

this.Documents = new Mongo.Collection("documents");

if (Meteor.isClient) {
  Template.editor.helpers( {
    docId: function () {
      var doc = Documents.findOne();
      if (doc) {
        return doc._id;
      } else {
        return null;
      }
    }
  })
}

if (Meteor.isServer){
    Meteor.startup(function(){
        // code to run on server at startup
    if (! Documents.findOne()) { // No docs yet.
      Documents.insert({title: "My new documents."})
    }
    })
}

我还不知道 id="editor" 做了什么。我在这里将其更改为 id="Editor" ,甚至将其删除,两个窗口之间的结果没有明显差异。

于 2016-09-03T03:49:55.767 回答