Search code examples
svggoogle-drive-apigoogle-drive-realtime-api

Google Drive Realtime API, how should I model SVG in the collaborative model


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.


Solution

  • 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.