loro/crates/loro-internal/tests/richtext.md
Zixuan Chen d942e3d7a2
Feat: Peritext-like rich text support (#123)
* feat: richtext wip

* feat: add insert to style range map wip

* feat: richtext state

* fix: fix style state inserting and style map

* fix: tiny vec merge err

* fix: comment err

* refactor: use new generic-btree & refine impl

* feat: fugue tracker

* feat: tracker

* feat: tracker

* fix: fix a few err in impl

* feat: init richtext content state

* feat: refactor arena

* feat: extract anchor_type info out of style flag

* refactor: state apply op more efficiently
we can now reuse the repr in state and op

* fix: new clippy errors

* refactor: use state chunk as delta item

* refactor: use two op to insert style start and style end

* feat: diff calc

* feat: handler

* fix: tracker checkout err

* fix: pass basic richtext handler tests

* fix: pass handler basic marking tests

* fix: pass all peritext criteria

* feat: snapshot encoding for richtext init

* refactor: replace Text with Richtext

* refacotr: rm text code

* fix: richtext checkout err

* refactor: diff of text and map

* refactor: del span

* refactor: event

* fix: fuzz err

* fix: pass all tests

* fix: fuzz err

* fix: list child cache err

* chore: rm debug code

* fix: encode enhanced err

* fix: encode enchanced

* fix: fix several richtext issue

* fix: richtext anchor err

* chore: rm debug code

* fix: richtext fuzz err

* feat: speedup text snapshot decode

* perf: optimize snapshot encoding

* perf: speed up decode & insert

* fix: fugue span merge err

* perf: speedup delete & id cursor map

* fix: fugue merge err

* chore: update utils

* perf: speedup text insert / del

* fix: cursor cache

* perf: reduce conversion by introducing InsertText

* perf: speed up by refined cursor cache

* chore: update gbtree dep

* refactor(wasm): use quill delta format

* chore: fix warnings
2023-10-29 14:02:13 +08:00

109 lines
3.7 KiB
Markdown

# Richtext Test Cases
#### 0. Insert into bold span
| Name | Text |
|:----------------|:-------------------------|
| Origin | `Hello World` |
| Concurrent A | `<b>Hello World</b>` |
| Concurrent B | `Hello New World` |
| Expected Result | `<b>Hello New World</b>` |
#### 1. Merge Concurrent Styles
| Name | Text |
|:----------------|:---------------------|
| Origin | Hello World |
| Concurrent A | `<b>Hello</b> World` |
| Concurrent B | `Hel<b>lo World</b>` |
| Expected Result | `<b>Hello World</b>` |
#### 2. Concurrent insert text & remove style
| Name | Text |
|:----------------|:-----------------------|
| Origin | `<b>Hello World</b>` |
| Concurrent A | `Hello <b>World</b>` |
| Concurrent B | `<b>Hello a World</b>` |
| Expected Result | `Hello a <b>World</b>` |
#### 3. Concurrent insert text & style
| Name | Text |
|:----------------|:-----------------------|
| Origin | `Hello World` |
| Concurrent A | `Hello <b>World</b>` |
| Concurrent B | `Hello a World` |
| Expected Result | `Hello a <b>World</b>` |
#### 4. Concurrently insert text and style that expands
This doesn't work well in our implementation
| Name | Text |
|:----------------|:----------------------|
| Origin | `Hello World` |
| Concurrent A | `<b>Hello</b> World` |
| Concurrent B | `Hello* World` |
| Expected Result | `<b>Hello*</b> World` |
#### 5. Concurrent text edit & style that shrink
| Name | Text |
|:----------------|:---------------------------|
| Origin | `Hello World` |
| Concurrent A | `<link>Hello</link> World` |
| Concurrent B | `Hey World` |
| Expected Result | `<link>Hey</link> World` |
#### 6. Local insertion expand rules
> [**Hello**](https://www.google.com) World
When insert a new character after "Hello", the new char should be bold but not link
> [**Hello**](https://www.google.com)**t** World
| Name | Text |
|:----------------|:----------------------------------|
| Origin | `<b><link>Hello</link><b> World` |
| Expected Result | `<b><link>Hello</link>t<b> World` |
#### 7. Concurrent unbold
In Peritext paper 2.3.2
| Name | Text |
|:----------------|:---------------------------------------------|
| Origin | `<b>The fox jumped</b> over the dog.` |
| Concurrent A | `The fox jumped over the dog.` |
| Concurrent B | `<b>The </b>fox<b> jumped</b> over the dog.` |
| Expected Result | `The fox jumped over the dog.` |
#### 8. Bold & Unbold
In Peritext paper 2.3.3
| Name | Text |
|:----------------|:---------------------------------------------|
| Origin | `<b>The fox jumped</b> over the dog.` |
| Concurrent A | `<b>The fox</b> jumped over the dog.` |
| Concurrent B | `<b>The</b> fox jumped over the <b>dog</b>.` |
| Expected Result | `<b>The</b> fox jumped over the <b>dog</b>.` |
#### 9. Overlapped formatting
In Peritext paper 3.2, example 3
| Name | Text |
|:----------------|:-----------------------------|
| Origin | The fox jumped. |
| Concurrent A | **The fox** jumped. |
| Concurrent B | The *fox jumped*. |
| Expected Result | **The _fox_**<i> jumped</i>. |
#### 10. Multiple instances of the same mark
![](https://i.postimg.cc/MTNGq8cH/Clean-Shot-2023-10-09-at-12-16-29-2x.png)