mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(editor): add inline packages (#11048)
This commit is contained in:
@@ -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';
|
||||
|
||||
39
blocksuite/affine/shared/src/styles/text.ts
Normal file
39
blocksuite/affine/shared/src/styles/text.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user