-
Notifications
You must be signed in to change notification settings - Fork 85
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
Feat: Peritext-like rich text support #123
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
we can now reuse the repr in state and op
zxch3n
changed the title
Feat: richtext & a bunch of refactoring
Feat: Peritext-like Rich Text
Oct 28, 2023
zxch3n
changed the title
Feat: Peritext-like Rich Text
Feat: Peritext-like rich text support
Oct 28, 2023
Leeeon233
approved these changes
Oct 29, 2023
use append_only_bytes::{AppendOnlyBytes, BytesSlice}; | ||
|
||
use crate::container::richtext::richtext_state::unicode_to_utf8_index; | ||
const INDEX_INTERVAL: u32 = 128; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the meaning of INDEX_INTERVAL
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a new rich text CRDT algorithm that is greatly inspired by Peritext.
It behaves just like Peritext when editing locally. The behavior only differ when there is concurrent insertion at the style boundaries.
It satisfies the requirements listed in Peritext paper Chapter 3 "CRITERIA FOR INTENT PRESERVATION". Specifically, it passes all the following tests besides the consistency fuzzing tests.
Richtext Test Cases
0. Insert into bold span
Hello World
<b>Hello World</b>
Hello New World
<b>Hello New World</b>
1. Merge Concurrent Styles
<b>Hello</b> World
Hel<b>lo World</b>
<b>Hello World</b>
2. Concurrent insert text & remove style
<b>Hello World</b>
Hello <b>World</b>
<b>Hello a World</b>
Hello a <b>World</b>
3. Concurrent insert text & style
Hello World
Hello <b>World</b>
Hello a World
Hello a <b>World</b>
4. Concurrently insert text and style that expands
This doesn't work well in our implementation
Hello World
<b>Hello</b> World
Hello* World
<b>Hello*</b> World
5. Concurrent text edit & style that shrink
Hello World
<link>Hello</link> World
Hey World
<link>Hey</link> World
6. Local insertion expand rules
When insert a new character after "Hello", the new char should be bold but not link
<b><link>Hello</link><b> World
<b><link>Hello</link>t<b> World
7. Concurrent unbold
In Peritext paper 2.3.2
<b>The fox jumped</b> over the dog.
The fox jumped over the dog.
<b>The </b>fox<b> jumped</b> over the dog.
The fox jumped over the dog.
8. Bold & Unbold
In Peritext paper 2.3.3
<b>The fox jumped</b> over the dog.
<b>The fox</b> jumped over the dog.
<b>The</b> fox jumped over the <b>dog</b>.
<b>The</b> fox jumped over the <b>dog</b>.
9. Overlapped formatting
In Peritext paper 3.2, example 3
10. Multiple instances of the same mark