Skip to content

Commit 384b444

Browse files
authored
🐛 fix(code-editor): align highlight layer with textarea layout (#643)
* 🐛 fix(code-editor): align highlight layer with textarea layout * 🐛 fix(code-editor): preserve inherited font style for highlight alignment
1 parent 971b512 commit 384b444

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎src/CodeEditor/style.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ export const styles = createStaticStyles(({ css, cssVar }) => {
1919
filled: lobeStaticStylish.variantFilledWithoutHover,
2020
highlight: css`
2121
pointer-events: none;
22+
23+
/* Mirror the textarea's text flow instead of the highlighter's flex rows. */
24+
pre code {
25+
display: block;
26+
27+
/* Keep the final empty line measurable after a trailing newline. */
28+
&::after {
29+
content: '\\200b';
30+
}
31+
32+
.line {
33+
display: inline;
34+
margin: 0;
35+
padding: 0;
36+
}
37+
38+
/* Token emphasis must not change glyph metrics relative to the textarea. */
39+
span {
40+
font-weight: inherit !important;
41+
font-style: inherit !important;
42+
}
43+
}
2244
`,
2345
outlined: lobeStaticStylish.variantOutlinedWithoutHover,
2446
root: css`

0 commit comments

Comments
 (0)