visual-space / visual-editor

Rich text editor for Flutter based on Delta format (Quill fork)
MIT License
283 stars 44 forks source link

Blocks - Indenting makes the ordered list numbers change when indenting #158

Closed DariusMuscalu closed 1 year ago

DariusMuscalu commented 1 year ago

When indenting a line in an ordered list, the lines below the one indented change their indexes to a number that doesn't make sense. Screenshot 2022-10-26 224416

Duplicated by #56

Join on discord to get advice and help or follow us on YouTube Visual Coding to learn more about the architecture of Visual Editor and other Flutter apps.

DariusMuscalu commented 1 year ago

I solved it for code blocks too, because it was using the same component as the ordered list (NumberPoint). The issue was that when creating a new block of ordered lists or code blocks, the indentLevelWidth property which was passed by reference from the DocumentService, kept holding the last indent values of each line from the past block and thus starting with the last index when creating a new block and giving it that number (i.e If we had 4 lines in an ordered list, the next block of type ordered list / code block would start with the index 5 and so on). We had to reset the indentLevelWidth values when entering a new line while looping through the nodes in DocumentService.

One issue that is left is that when indenting to a roman number index, it keeps the above index, not resetting it. image