feat(editor): add inline packages (#11048)

This commit is contained in:
Saul-Mirone
2025-03-20 13:47:35 +00:00
parent aa620af40f
commit e5e429e7b2
170 changed files with 1337 additions and 804 deletions

View File

@@ -1,3 +1,4 @@
export { FONT_BASE, FONT_SM, FONT_XS } from './font';
export { PANEL_BASE, PANEL_BASE_COLORS } from './panel';
export { scrollbarStyle } from './scrollbar-style';
export { affineTextStyles } from './text';

View File

@@ -0,0 +1,39 @@
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',
'line-height': 'auto',
};
}
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,
};
}

View File

@@ -4,6 +4,7 @@ import type {
ReferenceInfo,
} from '@blocksuite/affine-model';
import type { BlockComponent } from '@blocksuite/block-std';
import type { InlineEditor } from '@blocksuite/block-std/inline';
import type { BlockModel } from '@blocksuite/store';
export * from './uni-component';
export interface EditingState {
@@ -73,3 +74,5 @@ export interface AffineTextAttributes {
latex?: string | null;
footnote?: FootNote | null;
}
export type AffineInlineEditor = InlineEditor<AffineTextAttributes>;