Document editor structure protections
pepoospina opened this issue · 0 comments
Add protections to document editor on drop to prevent document inconsistencies.
Assume the editor is a tree that is rendered as a list, so rendering visually flattens the tree. The style of a block is linked to the tree structure and some conditions must be met.
condition 1)
Paragraphs are wrapped by titles.
condition 2)
At any given level, all paragraphs must be the first children, followed by all titles.
All paragraphs "under" a title must be its children until the next title of that level. (here "under" refers to the visually flattened view). In other words, the lower syblings of a title cannot be a paragraph.
For example, this is a valid doc structure
P0
T1
P2
P2
T2
P4
But this is not valid
P0
T1
P1
P2
P3
P4
This is not valid because P2 and P3 are in different levels of the tree, but visually they look like syblings.
--
These conditions are forced while editing the document, but they are not forced when droping new content.
A Protection must be included so that if a title is dropped above a paragraph, it is moved under the last paragraph at that level.