mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
refactor(editor): remove global types in config (#10143)
Closes: [BS-2554](https://linear.app/affine-design/issue/BS-2554/remove-global-types-in-block-config)
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
} from 'shiki';
|
||||
import getWasm from 'shiki/wasm';
|
||||
|
||||
import { CodeBlockConfigExtension } from './code-block-config.js';
|
||||
import {
|
||||
CODE_BLOCK_DEFAULT_DARK_THEME,
|
||||
CODE_BLOCK_DEFAULT_LIGHT_THEME,
|
||||
@@ -27,7 +28,10 @@ export class CodeBlockService extends BlockService {
|
||||
highlighter$: Signal<HighlighterCore | null> = signal(null);
|
||||
|
||||
get langs() {
|
||||
return this.std.getConfig('affine:code')?.langs ?? bundledLanguagesInfo;
|
||||
return (
|
||||
this.std.getOptional(CodeBlockConfigExtension.identifier)?.langs ??
|
||||
bundledLanguagesInfo
|
||||
);
|
||||
}
|
||||
|
||||
get themeKey() {
|
||||
@@ -46,7 +50,9 @@ export class CodeBlockService extends BlockService {
|
||||
engine: createOnigurumaEngine(() => getWasm),
|
||||
})
|
||||
.then(async highlighter => {
|
||||
const config = this.std.getConfig('affine:code');
|
||||
const config = this.std.getOptional(
|
||||
CodeBlockConfigExtension.identifier
|
||||
);
|
||||
const darkTheme = config?.theme?.dark ?? CODE_BLOCK_DEFAULT_DARK_THEME;
|
||||
const lightTheme =
|
||||
config?.theme?.light ?? CODE_BLOCK_DEFAULT_LIGHT_THEME;
|
||||
|
||||
Reference in New Issue
Block a user