groupdocs-editor / GroupDocs.Editor-for-Java

GroupDocs.Editor for Java examples, plugins and showcase projects
https://products.groupdocs.com/editor/java
MIT License
1 stars 4 forks source link

Issue saving nested list #23

Open atirtahirgroupdocs opened 1 year ago

atirtahirgroupdocs commented 1 year ago

This issue is raised in https://forum.groupdocs.com/t/editor-for-java-error-saving-word-document/12382/3

Hi, Please take a look at this GIF https://drive.google.com/file/d/1F6Nww6Qi1sIeLlGieDbHlpWZG_ssJgrD/view and this image - ul-structure There is a problem when we copy some nested list from google docs, paste it in app and save it. Thanks

denis-gvardionov commented 1 year ago

Hello!

The W3C specs for the UL HTML element are postulating the next:

Only LI, transparent elements (INS and DEL) and script-supporting elements (SCRIPT and TEMPLATE) are valid children for the UL element (same for OL).

From the provided screenshot I see a root UL element, which have 2 children: LI (that is valid) and UL (that is invalid). Tjis is a broken HTML markup, and GroupDocs.Editor cannot allow, pas and process such invalid HTML markup, because in this case the overall document structure and styles will became undefined behavior. You may check this by yourself with the W3C Validator, for example: https://validator.w3.org/nu/#textarea

If you want a nested unordered list in another unordered list (this is valid), then you need to wrap the nested UL inside LI, as it is shown at the beginning of this page.

Regarding the error message:

Only LI element or transparent element can be added as child to this ‘ul’ element, but not the given ‘com.groupdocs.editor.htmlcss.a.b.b.d’ element

It is slightly inaccurate - there should be a

Only LI element or transparent element can be added as child to this ‘ul’ element, but not the given ‘ul’ element

This error message will be fixed in the next release, but, the overall HTML validation and verification mechanism will be untouched.

Regarding the "There is a problem when we copy some nested list from google docs, paste it in app and save it." - this may explain the reason of this issue. Maybe, when copying text from Google Docs, it stores it inside the clipboard in the wrong way, or something like that. Anyway, when the HTML markup is pasted inside the GroupDocs.Editor and saved, it is broken and thus is rejected.

If this scenario is vital for you and you cannot avoid such copy-pasting from Google Docs or somehow fix it, we can suggest the way that is implemented by the most web-browsers - allow such invalid HTML markup, but automatically wrap nested UL inside the LI element. It is a complex algorithm to detect such "broken use-cases" but it can be done if you really need it. But, again, it is much more better to paste a correct HTML markup.