Skip to content

Support external model integration in @yorkie-js/react #1077

@hackerwins

Description

@hackerwins

Description:

We recently developed @yorkie-js/react to provide React bindings for Yorkie.
Currently, users receive a yorkie.Document via DocumentProvider and treat it as the source of truth(SOT).

However, in many real-world cases, editors(e.g., tldraw, Slate, Quill) maintain their own model as SOT instead of relying directly on yorkie.Document(details: document-editing.md). In such scenarios, the following workflow needs proper support:

  1. External modelyorkie.Document: When local edits occur in the editor, they should be reflected in the yorkie.Document.
  2. yorkie.DocumentExternal model: When remote changes occur in the yorkie.Document, the external editor model should be updated accordingly.

At the moment, @yorkie-js/react does not provide a clear interface for this two-way synchronization, which leads to boilerplate and makes integration harder.

Improvement ideas (to be researched further):

  • Provide an adapter or binding API that connects an external model with a yorkie.Document.
  • Expose hooks (e.g., useDocumentBinding) that encapsulate common synchronization patterns.
  • Experiment with migrating the react-tldraw example from @yorkie-js/sdk to @yorkie-js/react to validate this approach.

Next steps:

  • Research possible designs for external model bindings.
  • Explore trade-offs between flexibility and ease of use.
  • Use react-tldraw as a test case for validating the integration pattern.

Why:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions