Skip to content

Commit f50174f

Browse files
authored
fix(richtext-lexical): match the indentation spacing of paragraphs and lists (#8437)
Before this, indented paragraphs, un/ordered list-items, and checkbox list-items had 3 different sizes. This PR unifies all 3 to match. Related: - #8138 - facebook/lexical#4025 List-items were using a custom indentation size, instead of the browser's default. The reason I'm adapting list-items to this default size and not the paragraphs to list-items, is because when importing/exporting html in contexts where our CSS isn't present, visual consistency is maintained. Also, the browsers' default looks fine to me. Note: Lexical's detection of whether the checkbox is clicked is a bit hacky. I've made sure it doesn't break and added an explanatory comment to prevent anyone from breaking it in the future. ## Before ![image](https://github.com/user-attachments/assets/7195a592-a695-4131-af1a-df016c215758) ## After ![image](https://github.com/user-attachments/assets/ef3b708f-2ce6-4bf0-951e-15c550cdcc65)
1 parent 17e0547 commit f50174f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

packages/richtext-lexical/src/lexical/theme/EditorTheme.scss

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,34 @@
221221

222222
&__listItem {
223223
font-size: base(0.8);
224-
margin: 0 0 0.4em base(0.8);
224+
margin: 0 0 0.4em 40px;
225+
}
226+
227+
&__listItem[dir='rtl'] {
228+
margin: 0 40px 0.4em 0;
225229
}
226230

227231
&__listItemChecked,
228232
&__listItemUnchecked {
229233
position: relative;
230-
margin-inline: 0;
231-
padding-left: base(1.2);
232-
padding-right: base(1.2);
234+
// Instead of having margin-left: 40px like other list-items or indented paragraphs,
235+
// we use padding-left: 25px + margin-left: 15px = 40px, so that the click position
236+
// calculation in `CheckListPlugin` matches the checkbox
237+
margin-left: 15px;
238+
padding-left: 25px;
233239
list-style-type: none;
234240
outline: none;
235241
}
236242

243+
// See comment above for why we need this
244+
&__listItemUnchecked[dir='rtl'],
245+
&__listItemChecked[dir='rtl'] {
246+
margin-left: 0;
247+
padding-left: 0;
248+
padding-right: 25px;
249+
margin-right: 15px;
250+
}
251+
237252
&__listItemChecked {
238253
text-decoration: line-through;
239254
}

0 commit comments

Comments
 (0)