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

Implements Tree.createRange, Tree.RangeToIndex, Tree.rangeToPath #543

Closed
easylogic opened this issue Jun 12, 2023 · 0 comments · Fixed by #544
Closed

Implements Tree.createRange, Tree.RangeToIndex, Tree.rangeToPath #543

easylogic opened this issue Jun 12, 2023 · 0 comments · Fixed by #544
Assignees

Comments

@easylogic
Copy link
Contributor

Description:

Simultaneously record and pass the tree change and selection within the update () function.

doc.update((root) => {
  root.tree.edit(0, 0, ...);
  root.selection = root.tree.createRange(0, 0); // TreeRange (CRDT)
});
doc.subscribe('$.tree', (event) => {
  if (event.type === 'remote-change') {
    const { actor, ops, presence } = event.value;

    const root = doc.getRoot();
    root.tree.rangeToIndex(root.selection); // [0, 0]
    root.tree.rangeToPath(root.selection); // [[0, 0], [0, 1]]
  }
});

Why:

It will be possible to synchronize tree selection information without any special implementation.

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

Successfully merging a pull request may close this issue.

1 participant