Skip to content

Conversation

@juliaroldi
Copy link
Contributor

When apply alignment in table cells that has list items, also apply the alignment to the list items.
SaveList

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds alignment support for list items within table cells. When applying horizontal alignment to table cells containing list items, the alignment now propagates to the list items themselves, ensuring consistent formatting.

Changes:

  • Extended alignTableCellHorizontally to apply text alignment to list items within table cells
  • Maintained existing behavior of removing paragraph-level text align properties
  • Added comprehensive test coverage for list item alignment in various scenarios (LTR, RTL, mixed content)

Reviewed changes

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

File Description
packages/roosterjs-content-model-api/lib/modelApi/table/alignTableCell.ts Added logic to apply alignment to ListItem blocks and moved paragraph textAlign removal logic into the alignment callback
packages/roosterjs-content-model-api/test/modelApi/table/alignTableCellTest.ts Added comprehensive test cases for list item alignment in table cells, including RTL scenarios and mixed content

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

for (const block of cell.blocks) {
if (block.blockType === 'Paragraph' && block.format.textAlign) {
delete mutateBlock(block).format.textAlign;
} else if (block.blockType == 'BlockGroup' && block.blockGroupType == 'ListItem') {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

Inconsistent equality operator used. Line 52 uses strict equality (===) for blockType comparison, but this line uses loose equality (==) for both blockType and blockGroupType comparisons. For consistency and to avoid potential type coercion issues, use strict equality (===) for both comparisons on this line.

Suggested change
} else if (block.blockType == 'BlockGroup' && block.blockGroupType == 'ListItem') {
} else if (block.blockType === 'BlockGroup' && block.blockGroupType === 'ListItem') {

Copilot uses AI. Check for mistakes.
alignTableCellInternal(table, cell => {
cell.format.textAlign =
const alignment =
TextAlignValueMap[operation][cell.format.direction == 'rtl' ? 'rtl' : 'ltr'];
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

Inconsistent equality operator used. For consistency with line 52 which uses strict equality (===), this comparison should also use strict equality (===) instead of loose equality (==).

Suggested change
TextAlignValueMap[operation][cell.format.direction == 'rtl' ? 'rtl' : 'ltr'];
TextAlignValueMap[operation][cell.format.direction === 'rtl' ? 'rtl' : 'ltr'];

Copilot uses AI. Check for mistakes.
@juliaroldi juliaroldi merged commit abc43d1 into master Feb 3, 2026
7 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.

3 participants