@uiw/react-md-editor 3.25.2 → 3.25.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/mdeditor.js +5 -5
- package/dist/mdeditor.min.js +1 -1
- package/esm/Editor.js +24 -16
- package/esm/Editor.nohighlight.js +10 -5
- package/esm/components/TextArea/index.css +2 -4
- package/esm/components/TextArea/index.js +4 -0
- package/esm/components/Toolbar/index.d.ts +9 -1
- package/esm/components/Toolbar/index.js +21 -4
- package/lib/Editor.js +25 -17
- package/lib/Editor.nohighlight.js +10 -5
- package/lib/components/TextArea/index.js +4 -0
- package/lib/components/Toolbar/index.d.ts +9 -1
- package/lib/components/Toolbar/index.js +20 -4
- package/markdown-editor.css +2 -4
- package/package.json +1 -1
- package/src/Editor.nohighlight.tsx +16 -7
- package/src/Editor.tsx +32 -22
- package/src/components/TextArea/index.tsx +3 -2
- package/src/components/Toolbar/index.tsx +19 -4
|
@@ -7,7 +7,6 @@ import './index.less';
|
|
|
7
7
|
|
|
8
8
|
export interface IToolbarProps extends IProps {
|
|
9
9
|
overflow?: boolean;
|
|
10
|
-
toolbarBottom?: boolean;
|
|
11
10
|
onCommand?: (command: ICommand<string>, groupName?: string) => void;
|
|
12
11
|
commands?: ICommand<string>[];
|
|
13
12
|
isChild?: boolean;
|
|
@@ -125,13 +124,29 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
export default function Toolbar(props: IToolbarProps = {}) {
|
|
128
|
-
const { prefixCls,
|
|
127
|
+
const { prefixCls, isChild, className } = props;
|
|
129
128
|
const { commands, extraCommands } = useContext(EditorContext);
|
|
130
|
-
const bottomClassName = toolbarBottom ? 'bottom' : '';
|
|
131
129
|
return (
|
|
132
|
-
<div className={`${prefixCls}-toolbar ${
|
|
130
|
+
<div className={`${prefixCls}-toolbar ${className}`}>
|
|
133
131
|
<ToolbarItems {...props} commands={props.commands || commands || []} />
|
|
134
132
|
{!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}
|
|
135
133
|
</div>
|
|
136
134
|
);
|
|
137
135
|
}
|
|
136
|
+
|
|
137
|
+
interface ToolbarVisibilityProps {
|
|
138
|
+
hideToolbar?: boolean;
|
|
139
|
+
toolbarBottom: boolean;
|
|
140
|
+
placement: 'bottom' | 'top';
|
|
141
|
+
overflow: boolean;
|
|
142
|
+
prefixCls: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function ToolbarVisibility(props: ToolbarVisibilityProps) {
|
|
146
|
+
const { hideToolbar, toolbarBottom, placement, overflow, prefixCls } = props;
|
|
147
|
+
if (hideToolbar || (placement === 'bottom' && !toolbarBottom) || (placement === 'top' && toolbarBottom)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const cls = toolbarBottom ? 'bottom' : '';
|
|
151
|
+
return <Toolbar prefixCls={prefixCls} overflow={overflow} className={cls} />;
|
|
152
|
+
}
|