@uiw/react-md-editor 3.25.1 → 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.
@@ -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, toolbarBottom, isChild } = props;
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 ${bottomClassName}`}>
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
+ }