Skip to content

Commit a75cda9

Browse files
authored
Merge pull request #18765 from ckeditor/ck/18710
Other (core): Implemented the --ck-content-font-family, --ck-content-font-size and --ck-content-font-color CSS variables to standardize font family, size, and color styling in CKEditor 5 content. Closes #18710. MAJOR BREAKING CHANGE: The editor now enforces a default font family of Helvetica, Arial, Tahoma, Verdana, Sans-Serif, affecting both editing and rendered content. This may impact existing styling and layout, so custom font-family settings should be reviewed. See #18710. MAJOR BREAKING CHANGE: The editor now enforces a default font size of medium, affecting both editing and rendered content. This may impact existing styling and layout, so custom font-size settings should be reviewed. See #18710. MAJOR BREAKING CHANGE: The editor now enforces a default font color of #000, affecting both editing and rendered content. This may impact existing styling and layout, so custom color settings should be reviewed. See #18710. MAJOR BREAKING CHANGE: The editor now enforces a default word break of break-word, affecting both editing and rendered content. This may impact existing styling and layout, so custom word-break settings should be reviewed. See #18710.
2 parents e4bed9d + f7ec559 commit a75cda9

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

docs/getting-started/setup/css.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,36 @@ For example, the override below will tweak the border radius of several elements
6060

6161
## Customizing the look of the features
6262

63-
Similarly to the customizable editor look, some features also provide an interface to change their styles via [native CSS variables](https://www.w3.org/TR/css-variables/).
63+
Similarly to the customizable editor look, some features also provide an interface to change their styles via [native CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascading_variables/Using_CSS_custom_properties).
6464

65-
For example, if you want to change the color of the mentions' background and text, you can do the following override:
65+
### General content styling
66+
67+
CKEditor 5 provides CSS variables to standardize font and line height styling across the content. These variables control the default appearance of text the content. You can override them in the following way:
68+
69+
```css
70+
:root {
71+
/* Override the default font family */
72+
--ck-content-font-family: "Roboto";
73+
74+
/* Override the default font size */
75+
--ck-content-font-size: 16px;
76+
77+
/* Override the default font color */
78+
--ck-content-font-color: hsl(225, 5%, 45.00%);
79+
80+
/* Override the default line height */
81+
--ck-content-line-height: 2;
82+
}
83+
```
84+
85+
### Feature-specific styling
86+
87+
Individual features also provide CSS variables for their specific styling needs. For example, if you want to change the color of the mentions' background and text, you can do the following override:
6688

6789
```css
6890
:root {
69-
--ck-color-mention-background: black;
70-
--ck-color-mention-text: white;
91+
--ck-content-color-mention-background: black;
92+
--ck-content-color-mention-text: white;
7193
}
7294
```
7395

docs/updating/update-to-46.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,18 @@ If your build throws errors after the update, search and replace the old names w
8080
Manually updating all these numerous imports could be time-consuming and error-prone. We recommend using the [tables with the changed import/export names](https://raw.githubusercontent.com/ckeditor/ckeditor5/refs/heads/master/docs/updating/nim-migration/migrating-exports.md) as context for tools such as Copilot, ChatGPT, or other LLM-based services that can automatically update all imports in your project.
8181
</info-box>
8282

83-
Last but not least, this release put us on the clean and straight path towards the [deprecation of old installation methods](https://github.com/ckeditor/ckeditor5/issues/17779). Please let us know if you have any questions on GitHub or support channels.
84-
85-
### Opinionated default content styles and CSS renames
83+
### Introduction of the default content styles
8684

8785
To improve the out-of-the-box experience and accessibility, we are introducing opinionated defaults for content styling. From this version, we ship a small defaults layer applied to `.ck-content`:
8886

8987
```css
9088

9189
:root {
92-
--ck-content-font-family: Helvetica, Arial, Tahoma, Verdana, Sans-Serif;
93-
--ck-content-font-size: medium;
94-
--ck-content-font-color: #000;
95-
--ck-content-line-height: 1.5;
90+
--ck-content-font-family: Helvetica, Arial, Tahoma, Verdana, Sans-Serif;
91+
--ck-content-font-size: medium;
92+
--ck-content-font-color: #000;
93+
--ck-content-line-height: 1.5;
94+
--ck-content-word-break: break-word;
9695
}
9796

9897
.ck-content {
@@ -103,11 +102,13 @@ To improve the out-of-the-box experience and accessibility, we are introducing o
103102
}
104103
```
105104

106-
Those content styles are easily replaceable via CSS variable override. It is possible that you already style those things with more specific selectors.
105+
Those content styles are easily replaceable via CSS variable override. It is possible that you already style those things with more specific selectors but we recommend to use the variables from now on.
106+
You can read more about the reasons in our [GitHub issue](https://github.com/ckeditor/ckeditor5/issues/18710).
107107

108-
While working on this initiative, we decided to standardize the CSS naming, too. All older variables that applied to the content styles now share the consistent `--ck-content-*` prefix.
108+
**Migration:**
109+
* If you notice that the new editor's content styling affected your content appearance, make sure to update your custom style sheet, and use the new variable names.
109110

110-
#### Content area CSS variables renamed to `--ck-content-*` prefix
111+
### Content area CSS variables renamed to `--ck-content-*` prefix
111112

112113
To improve consistency, all CSS variables that affect the styles of the editor content area ("content styles") have been renamed to use the `--ck-content-*` prefix. This change affects variables used for highlights, image captions, mentions, table captions, image style spacing, and to-do list checkmarks.
113114

packages/ckeditor5-core/theme/core.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
*/
55

66
:root {
7+
--ck-content-font-family: Helvetica, Arial, Tahoma, Verdana, Sans-Serif;
8+
--ck-content-font-size: medium;
9+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
10+
--ck-content-font-color: #000;
711
--ck-content-line-height: 1.5;
12+
--ck-content-word-break: break-word;
813
}
914

1015
.ck-content {
16+
font-family: var(--ck-content-font-family);
17+
font-size: var(--ck-content-font-size);
18+
color: var(--ck-content-font-color);
1119
line-height: var(--ck-content-line-height);
20+
word-break: var(--ck-content-word-break);
1221
}

packages/ckeditor5-page-break/theme/pagebreak.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
text-transform: uppercase;
2828
border: 1px solid hsl(0, 0%, 77%);
2929
border-radius: 2px;
30-
font-family: Helvetica, Arial, Tahoma, Verdana, Sans-Serif;
3130
font-size: 0.75em;
3231
font-weight: bold;
3332
color: hsl(0, 0%, 20%);

0 commit comments

Comments
 (0)