Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting OT Types #9

Closed
rawkode opened this issue Jul 16, 2018 · 2 comments
Closed

Supporting OT Types #9

rawkode opened this issue Jul 16, 2018 · 2 comments

Comments

@rawkode
Copy link

rawkode commented Jul 16, 2018

I may be mistaken, but I believe Notus is essentially an ot-type definition with different semantics to ottypes/richtext; is this the case? If so, what would be involved in supporting other types?

I'm looking to hook Zefyr up to ShareDB, which uses ottypes/rich-text

@pulyaevskiy
Copy link
Contributor

I haven't looked into ottypes that much, to be honest. In this regard the answer would be: no, Notus is not an ot-type definition and is not based or inspired by that project in any way.

However, if I read correctly, they use the same Delta format for rich-text. This means that theoretically everything should "just work" since I tried to port Delta to Dart as close as possible to original implementation.

It is easy to Notus document to Delta:

final doc = getMyDocument();
final delta = doc.toDelta();
// Delta is JSON serializable:
final json = jsonEncode(delta);

To get all individual changes in a document you need to listen on NotusDocument.changes stream. Note that you need to be aware of the source of each change, it can be either ChangeSource.local or ChangeSource.remote. This allows to prevent composing the same change twice depending on current site. I suspect that ShareDB might even abstract this details away.

Hope this helps.

@rawkode
Copy link
Author

rawkode commented Jul 16, 2018

Thanks, @pulyaevskiy. That's very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants