Discussion Thread AddOn

24 views
Skip to first unread message

Soroush Hat

unread,
Apr 23, 2013, 7:30:47 PM4/23/13
to sha...@googlegroups.com
Hi,

I'm using sharejs for a small project similar to google docs, and I want to allow people to mark a line in the document and start a discussion about that line. As people edit the document the line number of these lines changes, I'm wondering how can I transform this data (line numbers in this case) using sharejs.

Vincent Woo

unread,
Apr 23, 2013, 8:14:47 PM4/23/13
to sha...@googlegroups.com
You can have a JSON doc that looks like
{
   text: "Body of the document...",
  annotations: {
    1: "note for line 1",
    13: "note for line 13, etc"
  }
}

and then use the operations described in https://github.com/josephg/ShareJS/wiki/JSON-Operations to manipulate the doc.

Soroush Hat

unread,
Apr 23, 2013, 8:49:41 PM4/23/13
to sha...@googlegroups.com
Thanks for reply.

I can't understand how it keeps track of annotated lines, for instance in the JSON example you've written, if another user manipulates the document between lines 1 and 13, how it transforms 13 to the new value? Shall I do it manually with the JSON types' operations?

Jeremy Apthorp

unread,
Apr 23, 2013, 9:03:46 PM4/23/13
to sha...@googlegroups.com
You want rich text support, which is issue #1 in sharejs :)

--
You received this message because you are subscribed to the Google Groups "ShareJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharejs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--

j

Soroush Hat

unread,
Apr 23, 2013, 9:19:03 PM4/23/13
to sha...@googlegroups.com, norn...@nornagon.net
What if we store the annotated content in some db in xml format like this:
line 1 ....
....
<comment id="uid">commented line</comment>
....

then auto-save document to keep snapshot and user content synced.
And whenever the users wants to open an existing annotated document first load the snapshot from sharejs db and then annotate it using the saved xml content?
To unsubscribe from this group and stop receiving emails from it, send an email to sharejs+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 


--

j

Jeremy Apthorp

unread,
Apr 23, 2013, 10:03:47 PM4/23/13
to sha...@googlegroups.com
That sounds flaky :)

Maybe one way to hack it could be to use a data model of document-as-array-of-chars:

['t','h','i','s',' ','i','s',' ','m','y',' ','d','o','c']

and to add annotations:

['t','h','i','s',' ','i','s',' ',{'c':'this is a comment'},'m','y',{'c':null},' ','d','o','c']


j


To unsubscribe from this group and stop receiving emails from it, send an email to sharejs+u...@googlegroups.com.

Joseph Gentle

unread,
Apr 23, 2013, 11:03:28 PM4/23/13
to sha...@googlegroups.com
They could be actual strings.

['this is my doc'] -> ['this is ', {c:'comment'}, 'my', {c:null}, 'doc']

Its still not quite what you want though.

Jeremy Apthorp

unread,
Apr 23, 2013, 11:10:37 PM4/23/13
to sha...@googlegroups.com
The problem with them being actual strings is that you have to split them when you add an annotation, and there's no way to transform an insert or a change by a split.


j

Soroush Hat

unread,
Apr 23, 2013, 11:21:51 PM4/23/13
to sha...@googlegroups.com, norn...@nornagon.net
Joseph, Is this something that you may want to add to the rewrite version?

Joseph Gentle

unread,
Apr 23, 2013, 11:28:22 PM4/23/13
to sha...@googlegroups.com
Rich text? No. I'm hoping someone else does it. It goes here:
https://github.com/josephg/ot-types

-J
Reply all
Reply to author
Forward
0 new messages