Skip to content

fix(editor): keep list item classes in getSemanticHTML - #4838

Open
dawidskowron wants to merge 1 commit into
slab:mainfrom
dawidskowron:fix/semantic-html-list-item-classes
Open

dawidskowron wants to merge 1 commit into
slab:mainfrom
dawidskowron:fix/semantic-html-list-item-classes

Conversation

@dawidskowron

Copy link
Copy Markdown

Fixes #4271.

Summary

getSemanticHTML() drops CSS classes when rebuilding list items. As a result, changing a list item's alignment does not change the exported HTML, so applications saving that HTML lose the formatting.

Preserve classes on real list items, excluding ql-indent-* because semantic HTML already represents indentation through nested lists. Escape class attribute values with the existing escapeText helper, and keep empty wrapper items for skipped indentation levels classless.

Example

For a centered bullet item followed by an unaligned item:

<!-- Before -->
<ul><li>one</li><li>two</li></ul>

<!-- After -->
<ul><li class="ql-align-center">one</li><li>two</li></ul>

Tests

  • Added seven regression cases covering aligned bullet and ordered lists, checklists, skipped indentation levels, indent-only items, direction and custom classes, and class attribute escaping. The bullet case also checks that classes do not leak between items. Six cases fail before the fix due to missing classes; all seven pass afterward.
  • All 528 Chromium unit tests pass.
  • E2E completes without unexpected failures.
  • ESLint and TypeScript checks pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use the alignment in the list, getSemanticHtml to get the content missing alignment class name

1 participant