Git Product home page Git Product logo

meteor-sharejs's Introduction

meteor-sharejs

Meteor smart package for transparently adding ShareJS editors to an app. Includes CodeMirror and the Ace editor.

This package is only tested for meteor 1.3 or later

Install

For vanilla ShareJS with text only:

$ meteor add mizzao:sharejs

For ShareJS with the Ace editor

$ meteor add  mizzao:sharejs-ace

For ShareJS with the CodeMirror editor:

$ meteor add mizzao:sharejs-codemirror

Usage

No configuration necessary for anonymous document editing. If you want to integrate with Meteor accounts, see below.

Use this helper on the client to get a textarea with the specified docid (as an argument) and with a DOM id of "editor", for example:

{{> sharejsText docid=docid id="editor"}}

Use this helper to get an Ace editor. Make sure you specify a size (via CSS) on the #editor div or you won't see anything.

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

Use this helper to get a CodeMirror editor.

{{> sharejsCM docid=docid id="editor"}}

The templates will clean themselves up when re-rendered (i.e., you have several documents and docid changes.)

Client Configuration

For the Ace and CodeMirror editors, you can define onRender and onConnect callbacks in the options hash and use it to configure the editor. onRender is called when the editor is initially rendered, and onConnect is called after each successful connection to a document.

{{> sharejsAce docid=document onRender=config onConnect=setMode id="editor"}}

All standard Ace themes and extensions are supported. Note that the helper has to return a function inside of a function:

Template.foo.config = function () {
  return function(editor) {
    # Set some reasonable options on the editor
    editor.setTheme('ace/theme/monokai')
    editor.getSession().setMode('ace/mode/javascript')
    editor.setShowPrintMargin(false)
    editor.getSession().setUseWrapMode(true)
  }
};

Server Configuration

See this example config file for the various settings that you can use.

Persistence

By default, the documents and edit operations will be persisted in Meteor's Mongo database. Mongo is the recommended usage as you don't need a separate database and user integration is supported. "opsCollectionPerDoc": false can be useful to set if you don't want a separate ops collection for each document.

You can also use db.type of none to have all documents and operations in memory.

Meteor User-Accounts Integration

The Authorization was removed in version 0.9.0, because the current implementation did not added any security as Meteor.userId is not a secret token.

Advanced

You can access the ShareJS Server API via import { ShareJS } from 'meteor/mizzao:sharejs'. For example, you may want to delete documents ops when the document is deleted in your app. See the demo for an example.

Notes

  • When using the default mongo driver, you must not use collections called docs or ops. These are used by ShareJS.
  • It's best to create a Meteor.Collection for your documents which generates good unique ids to connect to ShareJS with. Use these to render the templates above. See the demo for examples.

Please submit pull requests for better features and cooperation!

Contributors

meteor-sharejs's People

Contributors

bitspook avatar charandas avatar cortexelus avatar davidsichau avatar mizzao avatar mquandalle avatar rajit avatar xananax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meteor-sharejs's Issues

Ace editor leaks `define`

I'm using sharejs with another library, xregexp. xregexp tries to define itself if a define function exists, but it logs some errors, because it passes some arguments that sharejs's define doesn't expect.

Anyway, why is ace.js being added with bare: true, and what changes would it take to make sharejs work without the bare flag?

Incompatible with 0.9

After running meteor add mizzao:sharejs i get The package mizzao:sharejs at 0.6.0 is incompatible with Meteor 0.9.0 or later. in my server console when running meteor and the atmosphere description also says "INCOMPATIBLE WITH METEOR 0.9.0 OR LATER"

"Errors when scanning packages" after loading sharejs on meteorite

Well, I'm pretty new to Meteor, but when trying to load sharejs on meteorite something goes wrong. I've tried a few times now, with different apps, and so far always the same result. Is this a bug?

Terminal:
Mallorys-MacBook-Air:reactivity-playground mallorym$ mrt add sharejs

Done installing smart packages

Stand back while Meteorite does its thing

Done installing smart packages

Ok, everything's ready. Here comes Meteor!

=> Errors while scanning packages:

While building package sharejs:
fs.js:654:18: ENOENT, no such file or directory 'ace-builds/src'
at Object.fs.readdirSync (fs.js:654:18)
at walk (package.js:27:28)
at getFilesFromFolder (package.js:50:16)
at Object.use (package.js:74:21)
at /Users/mallorym/.meteor/tools/858c88b520/tools/packages.js:1630:29
at Array.forEach (native)
at Function..each..forEach (/Users/mallorym/.meteor/tools/858c88b520/lib/node_modules/underscore/underscore.js:79:11)
at .extend.initFromPackageDir (/Users/mallorym/.meteor/tools/858c88b520/tools/packages.js:1434:7)
at /Users/mallorym/.meteor/tools/858c88b520/tools/library.js:254:15
at Object.enterJob (/Users/mallorym/.meteor/tools/858c88b520/tools/buildmessage.js:235:15)
at .extend.get (/Users/mallorym/.meteor/tools/858c88b520/tools/library.js:241:22)
at /Users/mallorym/.meteor/tools/858c88b520/tools/library.js:357:24
at Array.forEach (native)
at Function.
.each.
.forEach (/Users/mallorym/.meteor/tools/858c88b520/lib/node_modules/underscore/underscore.js:79:11)
at /Users/mallorym/.meteor/tools/858c88b520/tools/library.js:356:9
at Object.capture (/Users/mallorym/.meteor/tools/858c88b520/tools/buildmessage.js:191:5)
at _.extend.list (/Users/mallorym/.meteor/tools/858c88b520/tools/library.js:345:33)
at getPackages (/Users/mallorym/.meteor/tools/858c88b520/tools/commands.js:50:40)
at main.registerCommand.name (/Users/mallorym/.meteor/tools/858c88b520/tools/commands.js:550:13)
at /Users/mallorym/.meteor/tools/858c88b520/tools/main.js:949:23

/usr/local/lib/node_modules/meteorite/lib/command.js:41
throw "Command exited with " + code + "/" + signal;
^

Cannot change themes, language, etc. for editor. Routing issue?

New to Meteor, hopefully I'm missing something obvious...

Followed the basic setup in the Readme, works as expected with default options. Then I tried to set the language to JavaScript and theme to twilight:

Template.editor.config = function() {
  return function(editor) {
    editor.setShowPrintMargin(false);
    editor.setTheme('ace/theme/twilight');
    editor.getSession().setMode("ace/mode/javascript");
    return editor.getSession().setUseWrapMode(true);
  };
};

Console shows JavaScript errors, Ace cannot parse the requested assets. The current URL is:
/r/roomName

Ace is requesting assets at:
/r/mode-javascript.js
/r/theme-twilight.js

and these URLs return the application HTML. I'd assume it should be requesting these assets from the root URL, but I'm not sure.

I'm on Meteor 0.7.1. Here are the packages I'm using:

{
  "packages": {
    "bootstrap-3": {},
    "spin": {},
    "iron-router": {},
    "accounts-ui-bootstrap-3": {},
    "bootstrap-errors": {},
    "streams": {},
    "sharejs": {}
  }
}

Hopefully this is just a routing config issue. Any ideas? Thanks!

Error when upgrading to Meteor 1.0.4

/.meteor/packages/meteor-tool/.1.0.42.1fjh99x++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150317-19:49:12.725(-6)? (STDERR)                        throw(ex);
W20150317-19:49:12.725(-6)? (STDERR)                              ^
W20150317-19:49:12.736(-6)? (STDERR) TypeError: Object [object Object] has no method '_withDb'
W20150317-19:49:12.736(-6)? (STDERR)     at Package (packages/mizzao:sharejs/sharejs-server.coffee:31:16)
W20150317-19:49:12.736(-6)? (STDERR)     at packages/mizzao:sharejs/sharejs-server.coffee:3:1
W20150317-19:49:12.736(-6)? (STDERR)     at packages/mizzao:sharejs/sharejs-server.coffee:3:1
W20150317-19:49:12.736(-6)? (STDERR)     at /home/brett/Sites/drag/.meteor/local/build/programs/server/boot.js:222:10
W20150317-19:49:12.736(-6)? (STDERR)     at Array.forEach (native)
W20150317-19:49:12.737(-6)? (STDERR)     at Function._.each._.forEach (/home/brett/.meteor/packages/meteor-tool/.1.0.42.1fjh99x++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150317-19:49:12.737(-6)? (STDERR)     at /home/brett/Sites/drag/.meteor/local/build/programs/server/boot.js:117:5

My version file is using your package at version # 0.7.1
Also, I tried to bring it up to 0.7.3 but got the following error:

While checking for mizzao:[email protected]:
   error: No compatible build found

ShareJS 0.7.3 support?

Hi there,

I'm currently looking into adding sharejs 0.7.3 support to meteor-sharejs. Before I get too involved, I wanted to check to see if anyone here done this yet?

The main reason i'm looking to do this, is because from what i've been told, ShareJS 0.6 does not support multiple server instances, which was implemented in 0.7.3.

is the demo broken?

Exception in template helper: TypeError: Cannot read property 'extend' of undefined
    at Object.<anonymous> (http://localhost:3000/packages/mizzao:sharejs.js?

After the latest update the ace editor isn't loaded and I get the msg above

Simplest example not working for me

I am trying to get meteor-sharejs to work in the most basic example:

export LC_ALL=C   #for mongodb
curl https://install.meteor.com/ | sh
meteor create share
cd share
meteor add mizzao:sharejs
vi share.html   #replace '{{> hello}}' with '{{> sharejsText docid=docid id="editor"}}'
sudo meteor --port 3333

And all I get is this lousy 'Loading':
loading

I tried Meteor on Mac OS X and Ubuntu (in Docker with dedicated port), with Firefox, Chrome and Safari.

What should I change to get this basic example up and running correctly?

Strange Erros / Not able to reproduce consistently

In general I seem to be able to edit but the syncronization is weirdly slow (I check with multiple open browser windows).

a lot of other users are complaining that whatever they type just disappears after a second. i'm using a bunch of other packages so it may be some conflict.

here it is live:
http://voodoohop.com/contentDetail/voodoohop-reveillon-na-natureza

oh and also weirdly sometimes when i load my page now i see a white page with the javascript content that should be interpreted by the browser. but this may be unrelated to meteor-sharejs

Trouble on Android

Typing has some issues on Android. I just tried the demo http://documents.meteor.com/ on Android 5.1.1 (Chrome and the built-in web browser), and observed the following:

  • When using the popular Android keyboard SwiftKey, the behavior of typing is, roughly speaking, that typing a character erases the previously inserted character and then inserts the next character.
  • On the other hand, with the Samsung keyboard, typing individual letters works fine, but if I swipe a word, I get some seemingly random text (e.g. 'that' becomes 'at', while 'hello' becomes 'I' -- an autoprediction?).

I get the same behavior in my own app using meteor-sharejs with Ace editor.

At least it's functional, typing individual characters on a Samsung keyboard, but it's annoying to force users into this. Perhaps this could be fixed?

Editor always "Loading...", sharejs.open callback returning undefined @data and @_editor

I'm on the latest version of Meteor and meteor-sharejs and running into a strange issue. When browsing to a document page through iron-router/push state navigation (clicking on any links or hitting the back button to land on a "room" with Ace sharejs editor) the document will always say "Loading...". If a re-render is triggered it gets updated, but otherwise remains "Loading...". You can see the issue by creating a new room on SeeMeCode.com, and by going Home then clicking the browser Back button. Refreshing the entire page works, and setting a new question or changing the programming language fixes it.

I've looked into sharejs-client.coffee, @_editor and @data are both undefined in the sharejs.open call when this happens. I haven't found a workaround yet.

Please publish your package mizzao:sharejs for Windows

Hi!

This package has binary dependencies, and we wanted to give you a heads up that Meteor 1.1, with support for Windows will be released in a few days.

Now is the time to publish your package for Windows!

It should be very straightforward -- we've added new build machines that run Windows that you can access with the meteor admin get-machine command. This is the same as you've done before for the other architectures we support.

For complete directions on how to publish your package for Windows, visit https://github.com/meteor/meteor/wiki/Publishing-a-package-with-binary-dependencies-for-the-Windows-preview

On behalf of the Meteor team,
@stubailo, @Slava and @avital.

P.S. This is an automated message based on our database of package authors.

always display loading... in the editor

[Error] open@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:27630
http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:27370
emit@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:1368
setState@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:26404
onopen@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:13628
e@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:133:52
channelOpened@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:133:216
Rb@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:123:146
nd@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:101:252
md@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:96:297
ec@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:94:485
Bc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:93:311
yc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:80:386
dispatchEvent@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:79:353
Rc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:87:190
uc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:86:402
Qb@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:86:379
[native code]
e (sharejs.js, line 133)
channelOpened (sharejs.js, line 133)
Rb (sharejs.js, line 123)
nd (sharejs.js, line 101)
md (sharejs.js, line 96)
ec (sharejs.js, line 94)
Bc (sharejs.js, line 93)
yc (sharejs.js, line 80)
dispatchEvent (sharejs.js, line 79)
Rc (sharejs.js, line 87)
uc (sharejs.js, line 86)
Qb (sharejs.js, line 86)
(anonymous function)


[Error] TypeError: 'null' is not an object (evaluating 'this.zb.n')
Sb (sharejs.js, line 119)
(anonymous function)
(anonymous function) (sharejs.js, line 130)

[BUG REPORT]Build errors on windows

error on win7 x32, as well as on winServer 2012 x64, win10 x64

Below is the error message for win 7

=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:

While processing files with stylus (for target web.browser):

~MYPATH\AppData\Local.meteor\packages\meteor-tool\1.1.9\mt-os.windows.x
86_32\tools\static-assets\server\mini-files.js:34:13:
Surprising path:
/~MYPATH/AppData/Local/.meteor/packages/stylus/2.511.0_2/plugin.compileStyl
usBatch.os/npm/compileStylusBatch/node_modules/nib/lib/nib/overflow.styl
at toDosPath
(~MYPATH\AppData\Local.meteor\packages\meteor-tool\1.1.9\mt-os.windows.
x86_32\tools\static-assets\server\mini-files.js:34:13)
at Object.convertToOSPath
(~MYPATH\AppData\Local.meteor\packages\meteor-tool\1.1.9\mt-os.windows.
x86_32\tools\static-assets\server\mini-files.js:47:12)
at Object.wrapper (C:\tools\fs\files.js:1310:25)
at importer.readFile (plugin/compile-stylus.js:119:21)
at Array.map (native)
at processSourcemap (plugin/compile-stylus.js:139:52)
at StylusCompiler.compileOneFile (plugin/compile-stylus.js:169:23)
at multi-file-caching-compiler.js:115:45
at multi-file-caching-compiler.js:144:68
at
~MYPATH\AppData\Local.meteor\packages\stylus\2.511.0_2\plugin.compileSt
ylusBatch.os\npm\caching-compiler\node_modules\async\lib\async.js:182:20
at replenish
(~MYPATH\AppData\Local.meteor\packages\stylus\2.511.0_2\plugin.compileS
tylusBatch.os\npm\caching-compiler\node_modules\async\lib\async.js:317:21)
at
~MYPATH\AppData\Local.meteor\packages\stylus\2.511.0_2\plugin.compileSt
ylusBatch.os\npm\caching-compiler\node_modules\async\lib\async.js:328:15
at Object.async.forEachLimit.async.eachLimit
(~MYPATH\AppData\Local.meteor\packages\stylus\2.511.0_2\plugin.compileS
tylusBatch.os\npm\caching-compiler\node_modules\async\lib\async.js:221:35)
at StylusCompiler.processFilesForTarget
(multi-file-caching-compiler.js:95:11)

=> Your application has errors. Waiting for file change.

Cannot read propertype 'type' of undefined

Help! i got the following error when i tried to launch your demo app. I'm using a windows Operating system.

The same error also appear when I loaded the package into a different project to try out.

W2035-02:08:04.259(8)? (STDERR) C:\Users\shawnlim\Documents\Websites\meteorjs\me
teor-documents-demo\.meteor\local\build\programs\server\boot.js:194
W2035-02:08:04.574(8)? (STDERR) }).run();
W2035-02:08:04.575(8)? (STDERR)    ^
W2035-02:08:04.576(8)? (STDERR) TypeError: Cannot read property 'type' of undefi
ned
W2035-02:08:04.577(8)? (STDERR)     at Package (packages/sharejs\sharejs-server.
coffee:13:10)
W2035-02:08:04.578(8)? (STDERR)     at packages/sharejs.js:94:4
W2035-02:08:04.579(8)? (STDERR)     at packages/sharejs.js:103:3
W2035-02:08:04.579(8)? (STDERR)     at mains (C:\Users\shawnlim\Documents\Websit
es\meteorjs\meteor-documents-demo\.meteor\local\build\programs\server\boot.js:16
3:10)
W2035-02:08:04.587(8)? (STDERR)     at Array.forEach (native)
W2035-02:08:04.588(8)? (STDERR)     at Function._.each._.forEach (C:\Users\shawn
lim\AppData\Local\.meteor\tools\36f9aeca0e\lib\node_modules\underscore\underscor
e.js:79:11)
W2035-02:08:04.589(8)? (STDERR)     at C:\Users\shawnlim\Documents\Websites\mete
orjs\meteor-documents-demo\.meteor\local\build\programs\server\boot.js:80:5
=> Exited with code: 1
=> Meteor server restarted

the errors pop by on both meteor 0.6.6 (in another app of mine) and 0.6.5 (in your demo app)

Build error with latest version

I'm getting a build error after upgrading to the latest release of meteor-sharejs. I've tried with Meteor 0.7.1 and Meteor 0.8.0 with the same result :(

✗ meteor
[[[[[ ~/path/to/app ]]]]]

=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:

While building package `sharejs`:
error: File not found: ace-builds/src-min/ace.js

=> Your application has errors. Waiting for file change.

Setup Package

As I want to try out to implement a better undo manager. I wanted to setup the projects for development. However I always get this error:

While reading package from `/home/dsichau/meteor/packages/sharejs-ace`:
fs.js:665:18: ENOENT, no such file or directory 'ace-builds/src'
at Object.fs.readdirSync (fs.js:665:18)
at walk (package.js:19:28)
at getFilesFromFolder (package.js:47:16)
at package.js:68:21

The setup I have made was to clone the fork into $home/meteor/packages
The I run git submodule init
and git submodule update

However when I now want to add the package I get this problem.

What is the best way to setup this project for extending?

onRender config function not being called

onRender function runs, but the function we return from there never gets called. As a result, you cannot configure the editor (Ace in my case).

I ran into this problem while working on my own app, but I am able to reproduce it in the demo app too.

Clone from the repository and run the demo. The code editor will stay white (the default). You can see in the deployed version of the demo that it switches to black.

If you add debug lines to configAce:

  configAce: ->
    console.log "onRender called, returning config function …"
    (ace) ->
      console.log "Config function called!"
      # Set some reasonable options on the editor
      ace.setTheme('ace/theme/monokai')
      ace.setShowPrintMargin(false)
      ace.getSession().setUseWrapMode(true)

… you will see that only the fist console.log gets executed, but the second one never does.

Improve editor modularity

Instead of bundling editors, package could be split into base package + modules for each editor. Then others could create support for other editors.

Error while building package `sharejs`

Not working with meteor 0.8.1.1 on mint 16

yak@vm16 ~/discus $ mrt add sharejs
smart.json changed.. installing from smart.json
✓ jquery-autosize
    tag: https://github.com/spendflow/meteor-jquery-autosize.git#v1.17.8r1
✓ sharejs
    tag: https://github.com/mizzao/meteor-sharejs.git#v0.5.0

Done installing smart packages

Stand back while Meteorite does its thing

Done installing smart packages

Ok, everything's ready. Here comes Meteor!

=> Errors while scanning packages:

While building package `sharejs`:
error: File not found: ace-builds/src-min/ace.js

/usr/local/lib/node_modules/meteorite/lib/command.js:35
          throw "Command exited with " + code + "/" + signal;
                                                    ^
Command exited with 1/null

500 internal server error for ace.js webclient file

I upgraded to the latest Meteor version 1.0.2.1 and packages. I upgraded SharJS and added ShareJSAce, everything is running as expected on localhost. But after using demeteorizer to deploy to Modulus Ace never loads. The file "/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js" returns a 500 error, here's the server log:

{"line":"457","file":"webapp_server.js","message":"Error serving static file Error: ENOENT, stat '/mnt/data/2/programs/web.browser/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js'","time":{"$date":1419661767968},"level":"error"}

You can see the issue here:
https://www.seemecode.com/r/h2vaemo

Any ideas why this would be happening? Thanks!

meteor 0.6.6 browser-policy activation affects sharejs

Hi again, i'm using browser-policy to improve security against XSS. This is what appears in my client console when i loaded my meteor app with sharejs activated.

Refused to load the script 'http://ajaxorg.github.com/ace/build/src/ace.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
There are 0posts main.js?44864693a7c5e6807c732a29a1a625e0cdc22740:12
Refused to load the script 'http://ajaxorg.github.com/ace/build/src/ace.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
Uncaught ReferenceError: ace is not defined 

error when add sharejs package

sharejs: updating npm dependencies -- share, mongodb...
npm WARN using --force I sure hope you know what you are doing.
npm http GET https://registry.npmjs.org/share/0.6.2
npm http 200 https://registry.npmjs.org/share/0.6.2
npm http GET https://registry.npmjs.org/share/-/share-0.6.2.tgz
npm http 200 https://registry.npmjs.org/share/-/share-0.6.2.tgz
npm ERR! Error: shasum check failed for /var/folders/lm/f275qsjs2kq1myb10t208_ww0000gn/T/npm-6077-UgidaJ95/1402465562779-0.011807809583842754/tmp.tgz
npm ERR! Expected: cca5cff3b61b76d0e156756a962fb94db891e42a
npm ERR! Actual: c86206a0c7ee33e34b47c52a69bdb015f1d1b61d
npm ERR! From: https://registry.npmjs.org/share/-/share-0.6.2.tgz
npm ERR! at /Users/fan/.meteor/tools/5bf1690853/lib/node_modules/npm/node_modules/sha/index.js:38:8
npm ERR! at ReadStream. (/Users/fan/.meteor/tools/5bf1690853/lib/node_modules/npm/node_modules/sha/index.js:85:7)
npm ERR! at ReadStream.EventEmitter.emit (events.js:117:20)
npm ERR! at _stream_readable.js:920:16
npm ERR! at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues

npm ERR! System Darwin 13.2.0
npm ERR! command "/Users/fan/.meteor/tools/5bf1690853/bin/node" "/Users/fan/.meteor/tools/5bf1690853/bin/npm" "install" "--force" "[email protected]"
npm ERR! cwd /Users/fan/.meteorite/packages/sharejs/mizzao/meteor-sharejs/1d8137b59906ce210b2f5c015b7b142735bc2f4e/.npm/package-new-1jf8yke
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/fan/.meteorite/packages/sharejs/mizzao/meteor-sharejs/1d8137b59906ce210b2f5c015b7b142735bc2f4e/.npm/package-new-1jf8yke/npm-debug.log
npm ERR! not ok code 0

=> Errors while scanning packages:

While building package sharejs:
error: couldn't install npm package
error: File not found: .npm/package/node_modules/share/node_modules/browserchannel/dist/bcsocket.js
error: File not found: .npm/package/node_modules/share/webclient/share.js
error: File not found: .npm/package/node_modules/share/webclient/ace.js
error: File not found: .npm/package/node_modules/share/webclient/textarea.js

/usr/local/lib/node_modules/meteorite/lib/command.js:35
throw "Command exited with " + code + "/" + signal;
^
Command exited with 1/null

Ace editor 1.2.0 is compatible with ShareJS 0.6

It seems that in ace 1.2 some changes were made which made ace sharejs incompatible:

ajaxorg/ace#1745

Here is the stacktrace:

Uncaught TypeError: Cannot read property 'range' of undefinedapplyToShareJS @ ace.js:23
window.sharejs.extendDoc.editorListener @ ace.js:78
EventEmitter._signal @ ace.js:3378
module.applyDelta @ ace.js:6476
module.insertMergedLines @ ace.js:6374
module.insert @ ace.js:6302
module.insert @ ace.js:8817
module.insert @ ace.js:11961
exports.commands.exec @ ace.js:11105
(anonymous function) @ ace.js:10441
EventEmitter._emit.EventEmitter._dispatchEvent @ ace.js:3368
module.exec @ ace.js:10469
module.onTextInput @ ace.js:4091
module.onTextInput @ ace.js:11987
sendText @ ace.js:2117
onInput @ ace.js:2126

The problem seems the following method:

applyToShareJS = function(editorDoc, delta, doc) {
    var getStartOffsetPosition, pos, text;

    getStartOffsetPosition = function(range) {
      var i, line, lines, offset, _i, _len;

      lines = editorDoc.getLines(0, range.start.row);
      offset = 0;
      for (i = _i = 0, _len = lines.length; _i < _len; i = ++_i) {
        line = lines[i];
        offset += i < range.start.row ? line.length : range.start.column;
      }
      return offset + range.start.row;
    };
    pos = getStartOffsetPosition(delta.range);
    switch (delta.action) {
      case 'insertText':
        doc.insert(pos, delta.text);
        break;
      case 'removeText':
        doc.del(pos, delta.text.length);
        break;
      case 'insertLines':
        text = delta.lines.join('\n') + '\n';
        doc.insert(pos, text);
        break;
      case 'removeLines':
        text = delta.lines.join('\n') + '\n';
        doc.del(pos, text.length);
        break;
      default:
        throw new Error("unknown action: " + delta.action);
    }
  };

Where delta is defined different.

Setting docid through the Spacebars/Blaze helper

I'm unclear as to how I can pass in, for example, the document id if it's stored in a collection via data context or programmatically.

For example:

<div>
    {{> sharejsText docid="{{this.active_document._id}}" id="editor" }}
</div>

How can I have a variable holding the document ID and send it into the sharejsText helper? I tried enclosing it in triple braces to ensure it wouldn't be converted to a string literal, but that didn't assist since it was already inside of a helper.

Reviewing the codebase (I haven't learned yet to parse CoffeeScript effectively) it seems that there's a ReactiveVar that's created that's holding the document id. Should I try updating that instead?

Apologies if this is a handlebars/spacebars question rather than a sharejs question.

Apply to <input> ?

Hi Andrew,

Any ideas on how to apply shareJS to inputs? We're working on some collaborative form contexts.

Happy to fork and do PR's – with some direction :)

Inifinite text replication after dragging selection (CodeMirror)

In demo app, if you select CodeMirror editor, then select some text and try to drag it into another place, it gets automatically replicated until the browser crashes.

I'd like to try and fix that, but do you have any suggestions where to start looking for it?

Meteor version: 1.1.0.2 No compatible binary build found for this package

C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo\app [master]> meteor
[[[[[ C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo\app ]]]]]

=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:

While checking for mizzao:[email protected]:
error: No compatible binary build found for this package. Contact the package author and ask them to publish it
for your platform.

=> Your application has errors. Waiting for file change.

Error: Server-generated random doc names are not currently supported

I've updated to Meteor 0.8.2 and the latest version of sharejs, and the browser shows the error listed in the title. I don't have any configuration, just the template and its JS file. "_id" and "callback" are working as expected. Any ideas? Thanks!

{{> sharejsAce docId=_id callback=config id="editor"}}
Template.editor.helpers({
  config: function() {
    return function(editor) {
      editor.setShowPrintMargin(false);
      editor.getSession().setUseWrapMode(true);
      return editor;
    };
  }
});

[solution] The package mizzao:sharejs at 0.6.0 is incompatible with Meteor 0.9.0 or later

If you do

meteor create docs
cd docs
meteor add mizzao:sharejs

and get this error:

mizzao:sharejs: INCOMPATIBLE WITH METEOR 0.9.0 OR LATER

it means you should clone this package from this github instead.

However, if you do

git clone --recursive https://github.com/mizzao/meteor-sharejs
cd meteor-sharejs/demo
meteor

and get this error:

W20140913-03:54:33.561(-4)? (STDERR) The package mizzao:sharejs at 0.6.0 is incompatible with Meteor 0.9.0 or later. 
W20140913-03:54:33.897(-4)? (STDERR) If a new, compatible version of this package exists, running 'meteor update' should cause you to update.  

try installing it like this instead:

git clone --recursive https://github.com/mizzao/meteor-sharejs
mv meteor-sharejs/demo docs
mkdir docs/packages
mv meteor-sharejs docs/packages/mizzao:sharejs
cd docs
meteor

and it should work.

Passing in additional data variables to the template?

This isn't so much an issue as a question or enhancement request. Is there a way I can pass in additional data variables to the template helper so that I can decorate the resulting textarea with custom attributes?

The reason I ask is because I want to support some simple markdown editing using Bootstrap Markdown. All I really need to include is a data-provide="markdown" or "markdown-editable" but I can't seem to figure out a good way to pass this in.

I forked your package earlier, cloned it, and made my own shareJSMarkdown template, but I couldn't get the package to build successfully (I'll admit, I was out of my depth here). Also, even when I got it to work locally, the template didn't seem to make it across, and it's because I believe your helper needs to call the appropriate constructor and handle it in a string that gets generated and returned.

Not working with Meteor 0.8.0 / Blaze

I found a few easy changes that need to be made in sharejs-client.coffee:

Handlebars.SafeString is now Spacebars.SafeString
Handlebars.registerHelper is now UI.registerHelper

However this still doesn't fix it. Nothing gets rendered, but there are also no errors to look at so I'm not quite sure why it silently fails :(

Space & Return Keys result in Backspace behavior?

Okay, this is a weird one. I've got this Ace editor on a web project I'm working on. Working fine on desktop web, but on iPhone Safari and Chrome (haven't tested on Android), pressing the space or return keys in the editor causes the editor to delete the character preceding the cursor, i.e. a backspace behavior. I don't implement any special behavior that should be causing it but I'd appreciate it if someone could replicate on their end just to make sure. If you want to test out the issue on my site, visit: http://www.group.codes/M25EhSW55ewiguTCa

CodeMirror integration

As attempted by @robert-boulanger - however, he e-mailed me a bunch of files and I suggested he make a GitHub fork of this package instead.

Hi Andrew,

Your' right, it wasn't too hard to integrate it. I already was at this state when I wrote you yesterday. The reason it didn't work was the cm.js in the sharejs/webclient directory. It didn't work. I changed it with a different version and voila, all works now like expected.

Attached you find 
cm.js -> should replace the current one in sharejs/.npm/node_modules/share/webclient
package.js, sharejs-client.coffee, sharejs-templates.html  which I extended to handle CodeMirror as well
and client.coffee and index.html from your demo with CM integrated instead of ACE

It's up to you to integrate it into your current package. Packaging CodeMirror in the same way like Ace is a bit tricky, since the CM Checkout contains tons of html files meteor doesn't like. So I just integrated codemirror.js within the package and put the mode, css and keymap files into the client directory of the webapp.

However using CM instead of Ace allows you to create a collaborative texteditor also with non-monospaced fonts and allows simple formatting like we know from etherpad, which is great to write novels ;)

Thanks for your time and of course for developing sharejs-meteor in general.

Best regards

Robert 

My comments on the above:

  • CM comes in an NPM package so we can just use that instead of the submodule for Ace
  • Both Ace and CM should be served as assets and not sent to clients until requested
  • Please clarify what you mean by "different version". What worked and what didn't?

How can I get the value of the text area (sounds basic, but i've tried everything)?

Seems like a really basic question, but I can't figure out how to programmatically get the value of the code mirror editor. Is this possible?

I'm also looking to attach a listening event to the CodeMirror editor, so whenever changes are made, I would get the content of the editor, and render it in a separate div. But to do that, I need to some how have access to the CodeMirror object I think.

Adding authentication

@mizzao Nice work on this package. Clean code!

Do you have plans to add authentication using something like this?

OR

Any caveats/recommendations if a brand new node programmer tries to put it in? I know javascript/coffee well enough and have been getting my hands dirty with JS frameworks recently. Meteor is my newest love and I am trying to build a pet project based on sharejs using your smart package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.