Files
AFFiNE-Mirror/blocksuite/affine/shared/src/styles/text.ts
T
Saul-Mirone 88339b4022 fix(editor): inline code style (#12585)
Closes: #12576
Closes: [BS-2080](https://linear.app/affine-design/issue/BS-2080/update-inline-code-font-size)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Style**
  - Improved the appearance of code elements within lists by adjusting font size and padding.
  - Updated inline code styling for better vertical alignment and consistency with surrounding text.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 04:11:02 +00:00

41 lines
1.2 KiB
TypeScript

import type { StyleInfo } from 'lit/directives/style-map.js';
import type { AffineTextAttributes } from '../types';
export function affineTextStyles(
props: AffineTextAttributes,
override?: Readonly<StyleInfo>
): StyleInfo {
let textDecorations = '';
if (props.underline) {
textDecorations += 'underline';
}
if (props.strike) {
textDecorations += ' line-through';
}
let inlineCodeStyle = {};
if (props.code) {
inlineCodeStyle = {
'font-family': 'var(--affine-font-code-family)',
background: 'var(--affine-background-code-block)',
border: '1px solid var(--affine-border-color)',
'border-radius': '4px',
color: 'var(--affine-text-primary-color)',
'font-variant-ligatures': 'none',
'vertical-align': 'bottom',
'line-height': 'inherit',
};
}
return {
'font-weight': props.bold ? 'bolder' : 'inherit',
'font-style': props.italic ? 'italic' : 'normal',
'background-color': props.background ? props.background : undefined,
color: props.color ? props.color : undefined,
'text-decoration': textDecorations.length > 0 ? textDecorations : 'none',
...inlineCodeStyle,
...override,
};
}