Skip to content

Commit efe75aa

Browse files
authored
Merge pull request #18801 from ckeditor/cc/7990-paragraph-styles
Fix (list, table): Improved rendering of the <p> element when it is an only child of a list item (`<li>`) or a table cell (`<td>` or `<th>`). Closes #17440. Fix: (list, table): Improve the paragraphs' spacing in lists and tables. Closes: #11347. MAJOR BREAKING CHANGE (list): Removed vertical spacing in list items by resetting margins for `<p>` elements that are the child of a `<li>` element. MAJOR BREAKING CHANGE (table): Removed vertical spacing in table cells by collapsing margins of <p> elements that are the only child of a `<td>` or `<th>` element.
2 parents 6ef279c + 9629216 commit efe75aa

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

packages/ckeditor5-list/theme/listformatting.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@
1010
}
1111

1212
.ck-content li {
13+
/* Opinionated list content styling: prevents content shift
14+
* when a list becomes multi-block (Enter + Backspace scenario).
15+
* See: https://github.com/ckeditor/ckeditor5/pull/18801
16+
*/
17+
& > p:first-of-type {
18+
margin-top: 0;
19+
}
20+
21+
/* Prevents margins from appearing when a bogus paragraph
22+
* receives line height or text alignment.
23+
* Ensures a consistent experience with the first paragraph.
24+
* See: https://github.com/ckeditor/ckeditor5/pull/18801
25+
*/
26+
& > p:only-child {
27+
margin-top: 0;
28+
margin-bottom: 0;
29+
}
30+
1331
&.ck-list-marker-bold::marker {
1432
font-weight: bold;
1533
}

packages/ckeditor5-table/theme/table.css

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,29 @@
5454

5555
& > td,
5656
& > th {
57-
/* stylelint-enable no-descending-specificity */
57+
/* Opinionated table content styling: prevents content from shifting
58+
* when Enter is pressed in the first cell.
59+
* See: https://github.com/ckeditor/ckeditor5/pull/18801
60+
*/
61+
& > p:first-of-type {
62+
margin-top: 0;
63+
}
64+
65+
/* Mirrors the rule above for the last paragraph to keep the
66+
* experience consistent with the first paragraph.
67+
*
68+
* Together, these rules prevent margins from appearing when a
69+
* bogus paragraph becomes a real paragraph after it receives line
70+
* height, text alignment, or other block style.
71+
*
72+
* See: https://github.com/ckeditor/ckeditor5/pull/18801
73+
*/
74+
& > p:last-of-type {
75+
margin-bottom: 0;
76+
}
77+
5878
min-width: 2em;
59-
padding: .4em;
79+
padding: 0.4em;
6080

6181
/* The border is inherited from .ck-editor__nested-editable styles, so theoretically it's not necessary here.
6282
However, the border is a content style, so it should use .ck-content (so it works outside the editor).

0 commit comments

Comments
 (0)