mirror of
https://github.com/muerwre/markdown-home-tab.git
synced 2025-04-25 17:06:40 +07:00
moved delete button to editor
This commit is contained in:
parent
02333e6049
commit
ece7395b26
5 changed files with 14 additions and 20 deletions
|
@ -1,20 +1,25 @@
|
||||||
import { FC, PropsWithChildren } from "react";
|
import { FC, PropsWithChildren } from "react";
|
||||||
import styles from "./styles.module.scss";
|
import styles from "./styles.module.scss";
|
||||||
import { Button } from "~/components/buttons/Button";
|
import { Button } from "~/components/buttons/Button";
|
||||||
import { useContainerPaddings } from "~/modules/theme/hooks/useContainerPaddings";
|
|
||||||
|
|
||||||
interface EditorWrapperProps extends PropsWithChildren {
|
interface EditorWrapperProps extends PropsWithChildren {
|
||||||
onSave: () => void;
|
save: () => void;
|
||||||
|
remove: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditorWrapper: FC<EditorWrapperProps> = ({ children, onSave }) => {
|
const EditorWrapper: FC<EditorWrapperProps> = ({ children, save, remove }) => {
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
<div className={styles.content}>{children}</div>
|
<div className={styles.content}>{children}</div>
|
||||||
|
|
||||||
<div className={styles.panel}>
|
<div className={styles.panel}>
|
||||||
|
<Button onClick={remove} role="button" size="small" variant="outline">
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
|
||||||
<div className={styles.filler} />
|
<div className={styles.filler} />
|
||||||
<Button onClick={onSave} role="button" size="small">
|
|
||||||
|
<Button onClick={save} role="button" size="small">
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,6 +11,7 @@ interface MarkdownEditorContainerProps {
|
||||||
id: string;
|
id: string;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
startEditing: () => void;
|
startEditing: () => void;
|
||||||
|
remove: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RichEditor = lazy(() =>
|
const RichEditor = lazy(() =>
|
||||||
|
@ -23,6 +24,7 @@ export const MarkdownEditorContainer: FC<MarkdownEditorContainerProps> = ({
|
||||||
id,
|
id,
|
||||||
locked,
|
locked,
|
||||||
startEditing,
|
startEditing,
|
||||||
|
remove,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
settings: { richEditorEnabled },
|
settings: { richEditorEnabled },
|
||||||
|
@ -39,7 +41,7 @@ export const MarkdownEditorContainer: FC<MarkdownEditorContainerProps> = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
const editor = (
|
const editor = (
|
||||||
<EditorWrapper onSave={startEditing}>
|
<EditorWrapper save={startEditing} remove={remove}>
|
||||||
{richEditorEnabled ? (
|
{richEditorEnabled ? (
|
||||||
<RichEditor value={value} onChange={setValue} locked={locked} />
|
<RichEditor value={value} onChange={setValue} locked={locked} />
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -54,9 +54,6 @@ const DefaultLayout = ({
|
||||||
<GridLayoutItemWrapper
|
<GridLayoutItemWrapper
|
||||||
splitVertical={splitVertical}
|
splitVertical={splitVertical}
|
||||||
splitHorizontal={splitHorizontal}
|
splitHorizontal={splitHorizontal}
|
||||||
remove={remove}
|
|
||||||
locked={locked}
|
|
||||||
lock={lock}
|
|
||||||
showSettings={showSettings}
|
showSettings={showSettings}
|
||||||
>
|
>
|
||||||
{createElement(component, {
|
{createElement(component, {
|
||||||
|
@ -64,6 +61,7 @@ const DefaultLayout = ({
|
||||||
title: panelProps.params.title,
|
title: panelProps.params.title,
|
||||||
locked,
|
locked,
|
||||||
startEditing: lock,
|
startEditing: lock,
|
||||||
|
remove,
|
||||||
})}
|
})}
|
||||||
</GridLayoutItemWrapper>
|
</GridLayoutItemWrapper>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { FC, PropsWithChildren } from "react";
|
||||||
import styles from "./styles.module.scss";
|
import styles from "./styles.module.scss";
|
||||||
import { IconButton } from "~/components/buttons/IconButton";
|
import { IconButton } from "~/components/buttons/IconButton";
|
||||||
|
|
||||||
import DeleteIcon from "~/assets/images/delete.svg";
|
|
||||||
import SplitVertical from "~/assets/images/split-vertical.svg";
|
import SplitVertical from "~/assets/images/split-vertical.svg";
|
||||||
import SplitHorizontal from "~/assets/images/split-horizontal.svg";
|
import SplitHorizontal from "~/assets/images/split-horizontal.svg";
|
||||||
import Gear from "~/assets/images/gear.svg";
|
import Gear from "~/assets/images/gear.svg";
|
||||||
|
@ -10,9 +9,6 @@ import Gear from "~/assets/images/gear.svg";
|
||||||
type GridLayoutItemWrapperProps = PropsWithChildren & {
|
type GridLayoutItemWrapperProps = PropsWithChildren & {
|
||||||
splitVertical: () => void;
|
splitVertical: () => void;
|
||||||
splitHorizontal: () => void;
|
splitHorizontal: () => void;
|
||||||
remove: () => void;
|
|
||||||
locked: boolean;
|
|
||||||
lock: () => void;
|
|
||||||
showSettings: () => void;
|
showSettings: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,8 +17,6 @@ const GridLayoutItemWrapper: FC<GridLayoutItemWrapperProps> = ({
|
||||||
splitVertical,
|
splitVertical,
|
||||||
splitHorizontal,
|
splitHorizontal,
|
||||||
showSettings,
|
showSettings,
|
||||||
remove,
|
|
||||||
locked,
|
|
||||||
}) => (
|
}) => (
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
<div className={styles.menu}>
|
<div className={styles.menu}>
|
||||||
|
@ -49,12 +43,6 @@ const GridLayoutItemWrapper: FC<GridLayoutItemWrapperProps> = ({
|
||||||
>
|
>
|
||||||
<Gear />
|
<Gear />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
||||||
{!locked && (
|
|
||||||
<IconButton onClick={remove} role="button" className={styles.button}>
|
|
||||||
<DeleteIcon />
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -3,4 +3,5 @@ export interface GridLayoutComponentProps {
|
||||||
title: string;
|
title: string;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
startEditing: () => void;
|
startEditing: () => void;
|
||||||
|
remove: () => void;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue