mizzao / meteor-sharejs

Meteor smart package for transparently adding ShareJS editors to an app
MIT License
225 stars 53 forks source link

Apply to <input> ? #5

Closed darylantony closed 10 years ago

darylantony commented 10 years ago

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

mizzao commented 10 years ago

I think you can use ShareJS's attach_textarea with an <input> element instead of a <textarea> and it will work exactly the same way. Why not give it a try? I just never thought someone would want OT on an input.

For a quick test, why not just try changing the _sharejsText template to contain an <input type="text"> instead of a textarea. If it just works (and it should), then you can just extend the existing approach.

On closer inspection of my code, the opening and cleanup of the shareJS connection is a bit messy. I can probably improve that as well, when we add in these inputs.

In general though, you'll have to be careful with collaborative forms - while they may be all edited at once, only one person will actually "submit" the form or get it processed, and at that point you will need to use Meteor to replicate that state across all of the other users who are looking at the form.

mizzao commented 10 years ago

Closing this for now, as the code has changed significantly since my original post.

You may want to try implementing a ShareJS input in the new code written for Meteor 0.8.3. It should be easy to modularize from the current examples.