Skip to content

Commit 78d670b

Browse files
committed
type: Fix toolbars type errors.
1 parent 41c6e69 commit 78d670b

File tree

7 files changed

+10
-18
lines changed

7 files changed

+10
-18
lines changed

src/commands/bold.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { ICommand} from './'
2+
import { ICommand } from './'
33

44
export const bold: ICommand = {
55
name: 'bold',

src/commands/fullscreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useRef, useState } from 'react';
2-
import { ICommand} from './';
2+
import { ICommand } from './';
33
import { IMarkdownEditor } from '../';
44

55
type Options = {

src/commands/preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
import { ICommand} from './';
2+
import { ICommand } from './';
33
import { IMarkdownEditor } from '../';
44

55
type Options = {

src/common/props.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/components/CodeMirror/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as CodeMirror from 'codemirror';
22
import 'codemirror/mode/markdown/markdown';
33
import React, { Component } from 'react';
44
import { DomEvent, IDefineModeOptions, IEventDict, IGetSelectionOptions, IInstance, ISetScrollOptions, ISetSelectionOptions } from '../../common/codemirror';
5-
import { IProps } from '../../common/props';
65
import './codemirror.less';
76
import './index.less';
87

@@ -17,7 +16,7 @@ if (!SERVER_RENDERED) {
1716
cm = require('codemirror');
1817
}
1918

20-
export interface ICodeMirror extends IProps {
19+
export interface ICodeMirror {
2120
value?: string,
2221
width?: number | string,
2322
height?: number | string,

src/components/ToolBar/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import * as React from "react";
2-
import { IProps } from '../../common/props';
32
import CodeMirror from 'codemirror';
43
import './index.less';
54
import { ICommand, defaultCommands } from '../../commands';
65
import { IMarkdownEditor } from '../../';
76

8-
export interface IToolBarProps extends IProps {
7+
export type IToolBarProps<T = (keyof (typeof defaultCommands)) | ICommand> = {
8+
className?: string;
99
editorProps: IMarkdownEditor;
1010
mode?: boolean;
1111
preview?: HTMLDivElement | null;
1212
container?: HTMLDivElement | null;
1313
containerEditor?: HTMLDivElement | null;
1414
prefixCls?: string;
1515
editor?: CodeMirror.Editor;
16-
toolbars?: (keyof (typeof defaultCommands))[] | ICommand[] | false;
16+
toolbars?: T[];
1717
onClick?: (type: string) => void;
1818
}
1919

@@ -26,7 +26,7 @@ export default function ToolBar(props: IToolBarProps) {
2626
}
2727
}
2828
return (
29-
<div className={`${prefixCls}-toolbar ${className} ${mode ? `${prefixCls}-toolbar-mode` : ''}`} {...htmlProps}>
29+
<div className={`${prefixCls}-toolbar ${className || ''} ${mode ? `${prefixCls}-toolbar-mode` : ''}`} {...htmlProps}>
3030
{[...toolbars].map((command, key) => {
3131
let buttonProps: React.ButtonHTMLAttributes<HTMLButtonElement> = {
3232
type: 'button',

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useState, createRef, useRef, useEffect } from 'react';
2-
import { IProps } from './common/props';
32
import CodeMirror, { ICodeMirror } from './components/CodeMirror';
43
import MarkdownPreview, { MarkdownPreviewProps } from '@uiw/react-markdown-preview';
54
import ToolBar, { IToolBarProps } from './components/ToolBar';
@@ -8,7 +7,8 @@ import './index.less';
87

98
export * from './commands';
109

11-
export interface IMarkdownEditor extends IProps, ICodeMirror {
10+
export interface IMarkdownEditor extends ICodeMirror {
11+
className?: string;
1212
prefixCls?: string,
1313
value?: string,
1414
height?: number,

0 commit comments

Comments
 (0)