Skip to content

Commit

Permalink
fix: 在设置自动主题的浏览器或设备上,后台编辑器预览的暗色主题无法切换
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Feb 4, 2023
1 parent b730bf1 commit 02e757e
Show file tree
Hide file tree
Showing 3 changed files with 1,042 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"copy-to-clipboard": "^3.3.2",
"emoji-mart": "^5.2.1",
"front-matter": "^4.0.2",
"github-markdown-css": "^5.1.0",
"js-sha256": "^0.9.0",
"lodash": "^4.17.0",
"moment": "^2.29.0",
Expand Down
10 changes: 6 additions & 4 deletions packages/admin/src/components/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import mermaid from '@bytemd/plugin-mermaid';
import { Editor } from '@bytemd/react';
import { Spin } from 'antd';
import 'bytemd/dist/index.css';
import 'github-markdown-css/github-markdown.css';
import 'highlight.js/styles/vs.css';
import 'katex/dist/katex.css';
import { useMemo } from 'react';
import '../../style/github-markdown.css';
import { emoji } from './emoji';
import { imgUploadPlugin, uploadImg } from './imgUpload';
import './index.less';
import { insertMore } from './insertMore';
import { cn } from './locales';

import { useModel } from 'umi';
import { customContainer } from './customContainer';
import { historyIcon } from './history';
import { rawHTML } from './raw';
Expand All @@ -29,6 +30,9 @@ export default function EditorComponent(props: {
setLoading: (l: boolean) => void;
}) {
const { loading, setLoading } = props;
const { initialState } = useModel('@@initialState');
const navTheme = initialState.settings.navTheme;
const themeClass = navTheme.toLowerCase().includes('dark') ? 'dark' : 'light';
const plugins = useMemo(() => {
return [
customContainer(),
Expand All @@ -47,10 +51,8 @@ export default function EditorComponent(props: {
];
}, []);



return (
<div style={{ height: '100%' }}>
<div style={{ height: '100%' }} className={themeClass}>
<Spin spinning={loading} className="editor-wrapper">
<Editor
value={props.value}
Expand Down
Loading

0 comments on commit 02e757e

Please sign in to comment.