Skip to content

Add WordLikeStyles flight for list spacing and image alignment - #3482

Merged
Bryan Valverde U (BryanValverdeU) merged 8 commits into
masterfrom
u/bvalverde/defaultStylesListItems
Nov 11, 2026
Merged

Bryan Valverde U (BryanValverdeU) merged 8 commits into
masterfrom
u/bvalverde/defaultStylesListItems

Conversation

@BryanValverdeU

@BryanValverdeU Bryan Valverde U (BryanValverdeU) commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add the opt-in WordLikeStyles experimental feature for list spacing and image alignment. Enable it with experimentalFeatures: ['WordLikeStyles'] in the editor options; existing behavior is unchanged when the flight is disabled.

  • Set margin-bottom: 2px on list items and margin-inline-start: 8px on their direct element children, supporting both LTR and RTL layouts. Nested descendants are not directly styled, and accessibility roles remain unconditional.
  • Default images without an explicit vertical alignment to vertical-align: middle, bringing the image behavior from [Test] Default all images to vertical-align: middle #3473 behind the same flight. Preserve explicit image alignment.
  • Cover enabled and disabled behavior, cached list items, explicit image alignment, and image rendering.

Screenshots

Image alignment

Before and after screenshots reused from #3473.

Before

Image alignment before WordLikeStyles

After

Image alignment with WordLikeStyles enabled

List spacing

#Before
image

#After
image

How to test

  1. Run yarn eslint, yarn test:fast, and yarn b.
  2. Create an editor without WordLikeStyles. Verify that list spacing and image alignment retain their existing behavior.
  3. Create an editor with experimentalFeatures: ['WordLikeStyles']. Verify that list items have 2px bottom spacing and their direct element children have 8px inline-start spacing in both LTR and RTL layouts.
  4. With the flight enabled, insert images without explicit alignment and verify that they use vertical-align: middle. Verify that images with explicit top, middle, or bottom alignment retain that alignment.

Gate list spacing and default image alignment behind the opt-in WordLikeStyles experimental feature. Preserve existing behavior when disabled and explicit image alignment when enabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37c6533-a7d0-4633-b0e9-3cbba6c613b8
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-11-11 21:12 UTC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37c6533-a7d0-4633-b0e9-3cbba6c613b8

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.

🟡 Changes recommended

The list inset is applied to individual inline formatting runs, creating gaps within mixed-format text while leaving plain-text list items without an inset.

1 open issue
What changed in this PR

Adds the opt-in WordLikeStyles feature to RoosterJS’s Content Model rendering, introducing list spacing and default image alignment while preserving behavior when disabled.

Changes:

  • Add list-item bottom spacing and inline-start margins on direct element children.
  • Default images to middle alignment when enabled, preserving explicit alignment.
  • Add coverage for feature gating, LTR/RTL lists, cached list items, and image rendering.
File Description
packages/​roosterjs-content-model-types/​lib/​editor/​ExperimentalFeature.ts Declare and document WordLikeStyles.
packages/​roosterjs-content-model-dom/​test/​modelToDom/​handlers/​handleListItemTest.ts Cover list spacing, direction, caching, and disabled behavior.
packages/​roosterjs-content-model-dom/​test/​modelToDom/​handlers/​handleImageTest.ts Verify image rendering with default middle alignment.
packages/​roosterjs-content-model-dom/​test/​formatHandlers/​common/​verticalAlignFormatHandlerTest.ts Cover gated defaults and explicit image alignment.
packages/​roosterjs-content-model-dom/​lib/​modelToDom/​handlers/​handleListItem.ts Apply gated list spacing while retaining accessibility roles.
packages/​roosterjs-content-model-dom/​lib/​formatHandlers/​common/​verticalAlignFormatHandler.ts Apply the gated image-alignment default.

Review effort: Balanced

Preserve existing list margins, retain paragraph wrappers, and render direction-aware spacing from model formats.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37c6533-a7d0-4633-b0e9-3cbba6c613b8
Accept browser-specific role and style attribute ordering in WordLikeStyles wrapper assertions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37c6533-a7d0-4633-b0e9-3cbba6c613b8
@BryanValverdeU
Bryan Valverde U (BryanValverdeU) marked this pull request as ready for review November 2, 2026 19:08
@BryanValverdeU
Bryan Valverde U (BryanValverdeU) merged commit 6e9548c into master Nov 11, 2026
11 checks passed
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.

4 participants