-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various list numbering improvements #565
Conversation
Build failed. |
Build succeeded. |
while (displayLevels > 0) { | ||
content += " counter(" + listCounterName + (textLevel - displayLevels + 1) + "," + stylemap[style] + ")"; | ||
if(displayLevels > 1) { | ||
content += '"' + suffix + '"'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should suffix
use the escapeCSSString
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, is this expected to add a suffix
char after each individual list item? I can't find anything in the ODT specs around how this should work, but from playing with LibreOffice, this seems to be purely a suffix (i.e., after the complete counter). The joining character looks like it's always a decimal.
If this isn't the case, it'd be good to make sure your test document contains a list definition showing the behaviour you expect from this loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had assumed that suffix
was also the list separator but your analysis is correct and supported by this helpful link https://wiki.openoffice.org/wiki/Number_labels
Due to the difficulties with getting the actual rendered text from a pseudo element, I'd suggest additional tests be added to |
Build succeeded. |
// check the previous list to be continued has the same list style | ||
if (styleName === previousStyleName) { | ||
list.setAttributeNS(helperns, "reset-none", "true"); | ||
rule = 'text|list[webodfhelper|reset-none="true"] '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is now a general rule that can be placed in webodf.css.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this but this doesn't seem to work as this rule needs to override an existing dynamic rule for the list counter reset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably would need to be { counter-reset: none !important; }
Build failed. |
Build succeeded. |
} else if (node.localName === "list-level-style-bullet") { | ||
contentRule = getBulletRule(node); | ||
} | ||
return contentRule + ';'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The surrounding \n
's and the comments above should be kept together with the content rule creation.
Build succeeded. |
May I propose to also update the welcome.odt file to feature the improvements with this PR? |
@thz we would definitely be open to that. Do you have any suggestions? |
Build succeeded. |
* Assigns a unique identifier to this list element and gives it a list counter | ||
* using CSS rules that target the unique identifier | ||
* @param {!string} id | ||
* @param {!Element} listElement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note in the API dox that this could be a list or a list-item. Ideally the name of the argument would hint to that as well, because I initially with just listElement
understood that this could be just a text:list
element and was puzzled by the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have changed some of this code around now, the rule generation method only takes text:list elements while the recursive tree traversal deals with all elements.
Build succeeded. |
Build succeeded. |
Build succeeded. |
Just pushed up a rebase so that this can be looked at again soon |
On my schedule for tomorrow/this friday. Really looking forward to get this finally in. |
* <office:document> | ||
* <text:list> | ||
* <text:list-item/> counter: level1 value: 1 | ||
* <text:list> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the detailed explanation, helps a lot!
One nitpick: the example does not match the ODF spec, <text:list>
elements can be only childs of <text:list-item>
elements, not <text:list>
directly, so the example should be something like
<text:list>
<text:list-item> counter: level1 value: 1
<text:list>
<text:list-item/> counter: level2 value: 1
</text:list>
</text:list-item>
etc.
Cool 🍦 ! Might be that my eyes got tired by looking at it a third(?) time, but could only find those minor problems :) So please work on those, then rebase, for the final testing. I put the "Ship it" stamp already on my desk, to be able to quickly apply it :) |
Moved the processing of the list style to get the content rule into a separate method so it can be re used for continue list styles. Also ensured that the new getContentRule function returns a complete rule with the semicolon on the end.
Implemented a changed list counter setup where each list level has its own counter. This is to support behaviour defined where you can display only a subset of the list numbers. This is defined here: http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1418890_253892949
Giving each list a unique counter allows us to implement continued numbering functionality while avoiding unexpected numbering due to how CSS counter values are scoped to an elements sibilings or children.
This adds support for the text:continue-numbering and text:continue-list attributes. The text:continue-numbering attribute specifies whether to continue the immediately preceding list if it has the same style. http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#attribute-text_continue-numbering The text:continue-list attribute specifes the unique identifier of a list to continue numbering from in the document. These must also have the same style. http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#attribute-text_continue-list https://tools.oasis-open.org/issues/browse/OFFICE-3558
The removed code was intended to implement continue list functionality. However this code no longer worked due to a regression introduced in commit 3ae9e0c. As I have refactored this area and implemented the continue list functionality in the new list styles class this old code is no longer required. The removed code in OdfCanvas also made use of the getFirstNonWhitespaceChild function in OdfUtils and the removed code was the last remaining usage of it. As it is preferable to make use of DOM API calls which give us the desired behaviour such as element.firstElementChild I have removed this function.
Added unit tests for the continue lists and added some examples of continued and multi level lists to visual-tests.fodt
Build succeeded. |
Really good work! Let's have it in master. Please merge! |
Various list numbering improvements
This PR adds support for displaying multi level list numbering. The approach used was to use a different counter for each level instead of using nested CSS counters. This was because you can limit the levels of numbering displayed to a subset of the current level e.g. displaying two levels
1.1. Level 2
1.1. Level 3
1.1. Level 4
The nested counter approach was not compatible with the above option of list numbering.
Also added was continuing the numbering of previous lists in the document. This approach was intially modeled off existing code in OdfCanvas that partially implemented this feature but due to a regression this code was not being reached anymore.
The new approach assigns unique counters to all text:list elements regardless of whether they need to be continued or not. This allows us to circumvent CSS scoping rules that prevent using the same counter across different lists which was how the old approach worked. If a list continues another list in the document it can simply be assigned the unique counters from the list it continues from. This is a cleaner approach overall as it reduces the amount of overridden CSS rules.
Lists can either continue the list directly preceding them in document or they can continue a list anywhere in the document by referencing its xml:id. Both these cases are handled in this PR.
To better illustrate the three main improvements made in this PR I have included a comparison screenshot of WebODF rendering the updated visual-tests.fodt.