Skip to content

Preserve ordered list numbering offsets across load and save#1112

Open
zoltanhosszu wants to merge 3 commits into
mainfrom
fix-ordered-list-numbering-offset
Open

Preserve ordered list numbering offsets across load and save#1112
zoltanhosszu wants to merge 3 commits into
mainfrom
fix-ordered-list-numbering-offset

Conversation

@zoltanhosszu

@zoltanhosszu zoltanhosszu commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Bug

Loading an editor with a list that doesn't start at 1 snaps the numbering back to 1:

<ol>
  <li value="2">Should be 2</li>
  <li value="3">Should be 3</li>
</ol>

After load, the items render as 1, 2 — and saving persists the loss.

Root cause

Lexical numbers ordered lists from the start attribute on <ol> and ignores the value attributes on <li> when importing ($convertListItemElement never reads them; a ListNode transform renumbers items sequentially from the list's start). value is only written on export, for display fidelity.

Lexxy's sanitizers kept the cosmetic attribute and stripped the semantic one: value on <li> was allowlisted on both sides, but start on <ol> was stripped by DOMPurify when computing the form value and by Loofah when saving through Action Text. So any list with an offset lost it on the next edit — leaving exactly the HTML above in the database.

Fix

  • Allow start on <ol> through DOMPurify (client) and Loofah (server), so the bug is fixed going forward.

This comment was marked as resolved.

zoltanhosszu and others added 2 commits June 11, 2026 11:43
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Any list not starting at 1 lost its offset on the next edit, snapping
back to 1, 2, 3.

Allow `start` on <ol> through both sanitizers, so content persisted while start was being stripped recovers its numbering instead of staying broken. The repair runs in the editor element's `$generateNodesFromDOM` funnel, covering initial value load and paste alike.
@zoltanhosszu zoltanhosszu force-pushed the fix-ordered-list-numbering-offset branch 2 times, most recently from 6169736 to dab2f42 Compare June 11, 2026 10:28
Remove unused numbered_list fixtures
Navigate to the editor page before setting the test value

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@zoltanhosszu zoltanhosszu force-pushed the fix-ordered-list-numbering-offset branch from 0352c0a to 5772df8 Compare June 11, 2026 10:38
@zoltanhosszu zoltanhosszu marked this pull request as ready for review June 11, 2026 10:44
Copilot AI review requested due to automatic review settings June 11, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread test/browser/tests/formatting/ordered_list_numbering_offset.test.js
Comment thread test/system/ordered_list_numbering_test.rb
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.

2 participants