-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Is there an existing issue for this?
- I have searched the existing issues
The question
I have create this simple text to see how jsonEncode(_controller.document.toDelta().toJson()). This was the text in markdown:
TITLE
CATEGORY: Category
LIST
- Item
- Item: item
ORDERED LIST
- First
- Second: second
This is what jsonEncode(_controller.document.toDelta().toJson()) returned:
[{"insert":"Title\n","attributes":{"header":3}},{"insert":"CATEGORY: ","attributes":{"bold":true}},{"insert":"Category\n\n"},{"insert":"LIST","attributes":{"bold":true}},{"insert":"\n"},{"insert":"Item\n","attributes":{"list":"bullet"}},{"insert":"Item:","attributes":{"list":"bullet","bold":true}},{"insert":" item\n","attributes":{"list":"bullet"}},{"insert":"\n"},{"insert":"ORDERED LIST","attributes":{"bold":true}},{"insert":"\n"},{"insert":"First\n","attributes":{"list":"ordered"}},{"insert":"Second: ","attributes":{"list":"ordered","bold":true}},{"insert":"second\n","attributes":{"list":"ordered"}}]
Now, when I try to get a Document from it (using Document.fromJson(jsonDecode(jsonEncode(_controller.document.toDelta().toJson()))) it doesn't work because it has \n instead of \\n and because there is no {"insert": "\\n"} at the end (or I need to append 'r' in front of the string to denoted as a raw string. How should I deal with this? tks