-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃悰 Fix inserting newlines into formatted text
Consider a document with a single piece of bold text. As a `Delta`, this would be represented as: ```js const doc = new Delta().insert('a', {bold: true}) ``` Now consider the following `Delta` being applied: ```js const delta = new Delta().insert('\n1') ``` The above `Delta` will: - prepend the document with a newline - follow that newline with an **unformatted** string Indeed, using `doc.compose(delta)` yields: ```js const result = new Delta() .insert('\n1') .insert('a', {bold: true}) ``` However, the same result is not reached when using the Quill `editor.applyDelta()`, which instead results in bold formatting being incorrectly applied to our unformatted string: ```js const badResult = new Delta() .insert('\n') .insert('1a', {bold: true}) ``` This happens because Quill does an insert of the whole insertion, but doesn't handle the line splitting. This change fixes this issue by splitting ops on newlines, and handling them separately, which applies the correct formatting.
- Loading branch information
1 parent
c8dec17
commit 792052b
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
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
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