What would be a good or recommended way to model SVG DOM tree in Google's Realtime API? Specifically, stringify the SVG DOM tree and choose a collaborative string model or is there a better way? Thanks.
Asked
Active
Viewed 151 times
2
-
Please don't close this, it is a great question. – Ali Afshar Jul 18 '13 at 14:23
-
It's a good question. Although it's slightly broad, it's a very specific problem that we face too. There's no real way to implement something specific, because it'll work. The question is really what the RT team intended in this case. @AliAfshar you can vote to reopen. – Frodo Baggins Oct 30 '13 at 17:28
1 Answers
1
It depends on what you want to do with it. If all you want to do is to display something, without it being editable, then I would just store it is a blob. E.g., maybe just a static string.
If you want to be able to edit it, a collaborative string is problematic, as its hard to guarantee that the results of merging different collaborator's actions will result in well-formed XML.
Instead you could use custom objects to model the various nodes in the tree. You could do this either with a generic dom-like model where nodes have arbitrary attributes, or with specific classes different element types. I think the last would be the most powerful way to deal with it, and the nicest to work with, but also the most work to setup.

Cheryl Simon
- 46,552
- 15
- 93
- 82
-
If the editing is through visual UI, meaning no direct user editing of the SVG strings (like Draw.io), then would a collaborative string be the most easiest and direct way? I've saw your youtube presentation that mentions the API will perform a diff before transformation, or something to that effect, to conserve bandwidth and if so, then I guess that's ok. Also, after searching for days, am I right to say that you can only bind collaborative strings to a textbox and not bind anything else directly to any DOM node? Thanks. – TomYip Jul 18 '13 at 23:36
-
Even if the user is not directly editing it, its still hard to guarantee that a text-based merge of changes to an SVG string will result in well-formed XML. I think that people have done it, it would probably work in 90% of the cases, but it might result in lots of weird bugs. – Cheryl Simon Jul 19 '13 at 17:47
-
We don't provide any utilities to bind to dom elements other than a textbox. You can still use the Collab Strings in other contexts, just like the other collab objects, you just have to do the updates to the string yourself. – Cheryl Simon Jul 19 '13 at 17:48
-