fix(markdowm): markdown style hook error reporting (#2380)

* fix: markdown style hook report error

* fix: markdown style hook report error

* fix: markdown style hook report error

* Update database.ts

* refactor: be better

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
Co-authored-by: Rain <958414905@qq.com>
This commit is contained in:
katherinehhh 2023-08-04 09:37:06 +08:00 committed by GitHub
parent 316b12a4ba
commit d84c52618d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 34 deletions

View File

@ -19,6 +19,7 @@ import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import type { IPluginData } from '.';
import { useAPIClient, useRequest } from '../api-client';
import { useGlobalTheme } from '../global-theme';
import { useStyles as useMarkdownStyles } from '../schema-component/antd/markdown/style';
import { useParseMarkdown } from '../schema-component/antd/markdown/util';
import { useStyles } from './style';
@ -63,7 +64,8 @@ const stringToColor = function (str: string) {
const PluginDocument: React.FC<PluginDocumentProps> = (props) => {
const { styles } = useStyles();
const { componentCls, hashId } = useMarkdownStyles();
const { isDarkTheme } = useGlobalTheme();
const { componentCls, hashId } = useMarkdownStyles({ isDarkTheme });
const [docLang, setDocLang] = useState('');
const { name, path } = props;
const { data, loading, error } = useRequest<{

View File

@ -3,6 +3,7 @@ import { Input as AntdInput, Button, Space, Spin } from 'antd';
import cls from 'classnames';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useGlobalTheme } from '../../../global-theme';
import { useDesignable } from '../../hooks/useDesignable';
import { MarkdownVoidDesigner } from './Markdown.Void.Designer';
import { useStyles } from './style';
@ -44,7 +45,8 @@ const MarkdownEditor = (props: any) => {
export const MarkdownVoid: any = observer(
(props: any) => {
const { componentCls, hashId } = useStyles();
const { isDarkTheme } = useGlobalTheme();
const { componentCls, hashId } = useStyles({ isDarkTheme });
const { content, className } = props;
const field = useField();
const schema = useFieldSchema();

View File

@ -2,6 +2,7 @@ import { LoadingOutlined } from '@ant-design/icons';
import { connect, mapProps, mapReadPretty } from '@formily/react';
import { Input as AntdInput, Spin } from 'antd';
import React from 'react';
import { useGlobalTheme } from '../../../global-theme';
import { ReadPretty as InputReadPretty } from '../input';
import { MarkdownVoid } from './Markdown.Void';
import { useStyles } from './style';
@ -23,7 +24,8 @@ export const Markdown: any = connect(
);
export const MarkdownReadPretty = (props) => {
const { wrapSSR, hashId, componentCls: className } = useStyles();
const { isDarkTheme } = useGlobalTheme();
const { wrapSSR, hashId, componentCls: className } = useStyles({ isDarkTheme });
const { html = '', loading } = useParseMarkdown(props.value);
const text = convertToText(html);
const value = (

View File

@ -1,10 +1,8 @@
import { TinyColor } from '@ctrl/tinycolor';
import { useGlobalTheme } from '../../../global-theme';
import { genStyleHook } from './../__builtins__';
export const useStyles = genStyleHook('nb-markdown', (token) => {
export const useStyles = genStyleHook('nb-markdown', (token, { isDarkTheme }) => {
const { componentCls } = token;
const { isDarkTheme } = useGlobalTheme();
const colorFillAlterSolid = new TinyColor(token.colorFillAlter)
.onBackground(token.colorBgContainer)
.toHexShortString();
@ -36,15 +34,13 @@ export const useStyles = genStyleHook('nb-markdown', (token) => {
'.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag': {
fontWeight: 700,
},
'.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type':
{
color: '#800',
},
'.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type': {
color: '#800',
},
'.hljs-section,.hljs-title': { color: '#800', fontWeight: 700 },
'.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable':
{
color: '#ab5656',
},
'.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable': {
color: '#ab5656',
},
'.hljs-literal': { color: '#695' },
'.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code': {
color: '#397300',
@ -92,17 +88,15 @@ export const useStyles = genStyleHook('nb-markdown', (token) => {
borderRadius: token.borderRadiusSM,
},
'.hljs': { color: '#adbac7', background: '#22272e' },
'.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_':
{
color: '#f47067',
},
'.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_': {
color: '#f47067',
},
'.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_': {
color: '#dcbdfb',
},
'.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable':
{
color: '#6cb6ff',
},
'.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable': {
color: '#6cb6ff',
},
'.hljs-meta .hljs-string,.hljs-regexp,.hljs-string': { color: '#96d0ff' },
'.hljs-built_in,.hljs-symbol': { color: '#f69d50' },
'.hljs-code,.hljs-comment,.hljs-formula': { color: '#768390' },

View File

@ -264,17 +264,6 @@ export class Database extends EventEmitter implements AsyncEmitter {
this.migrations = new Migrations(context);
this.migrator = new Umzug({
logger: migratorOptions.logger || console,
migrations: this.migrations.callback(),
context,
storage: new SequelizeStorage({
modelName: `${this.options.tablePrefix || ''}migrations`,
...migratorOptions.storage,
sequelize: this.sequelize,
}),
});
this.sequelize.beforeDefine((model, opts) => {
if (this.options.tablePrefix) {
opts.tableName = `${this.options.tablePrefix}${opts.tableName || opts.modelName || opts.name.plural}`;
@ -287,7 +276,18 @@ export class Database extends EventEmitter implements AsyncEmitter {
timestamps: false,
namespace: 'core.migration',
duplicator: 'required',
fields: [{ type: 'string', name: 'name' }],
fields: [{ type: 'string', name: 'name', primaryKey: true }],
});
this.migrator = new Umzug({
logger: migratorOptions.logger || console,
migrations: this.migrations.callback(),
context,
storage: new SequelizeStorage({
modelName: `${this.options.tablePrefix || ''}migrations`,
...migratorOptions.storage,
sequelize: this.sequelize,
}),
});
this.initListener();