11"use client" ;
22
3- import { HeadingIcon , FontBoldIcon , FontItalicIcon , Link2Icon , UploadIcon } from "@radix-ui/react-icons" ;
3+ import { useTranslation } from "@/i18n/use-translation" ;
4+ import {
5+ FontBoldIcon ,
6+ FontItalicIcon ,
7+ HeadingIcon ,
8+ Link2Icon ,
9+ UploadIcon ,
10+ } from "@radix-ui/react-icons" ;
11+ import { Loader } from "lucide-react" ;
412import React from "react" ;
513import EditorCommandButton from "./EditorCommandButton" ;
614import { useMarkdownEditor } from "./useMarkdownEditor" ;
@@ -10,7 +18,11 @@ interface MarkdownEditorContentProps {
1018 onChange : ( value : string ) => void ;
1119}
1220
13- export function MarkdownEditorContent ( { bodyRef, onChange } : MarkdownEditorContentProps ) {
21+ export function MarkdownEditorContent ( {
22+ bodyRef,
23+ onChange,
24+ } : MarkdownEditorContentProps ) {
25+ const { _t } = useTranslation ( ) ;
1426 const editor = useMarkdownEditor ( {
1527 ref : bodyRef ,
1628 onChange,
@@ -40,15 +52,35 @@ export function MarkdownEditorContent({ bodyRef, onChange }: MarkdownEditorConte
4052 />
4153 < EditorCommandButton
4254 onClick = { ( ) => editor ?. executeCommand ( "upload-image" ) }
43- Icon = { < UploadIcon /> }
55+ Icon = {
56+ editor ?. isUploading ? (
57+ < Loader className = "w-4 h-4 animate-spin" />
58+ ) : (
59+ < UploadIcon />
60+ )
61+ }
4462 title = "Upload Image (Ctrl/Cmd + U)"
63+ isDisabled = { editor ?. isUploading }
4564 />
65+
66+ { editor ?. isUploading && (
67+ < div className = "flex items-center gap-2 text-sm text-muted-foreground" >
68+ < Loader className = "w-4 h-4 animate-spin" />
69+ < span > { _t ( "Uploading image" ) } ...</ span >
70+ </ div >
71+ ) }
4672 </ div >
4773 ) ;
4874
4975 return (
50- < div className = "flex flex-col justify-between md:items-center md:flex-row" >
51- { renderEditorToolbar ( ) }
76+ < div className = "flex flex-col justify-between" >
77+ < div className = "flex flex-col md:flex-row md:items-center md:justify-between" >
78+ { renderEditorToolbar ( ) }
79+
80+ < div className = "text-xs text-muted-foreground mt-2 md:mt-0 md:ml-4" >
81+ { _t ( "Tip: Drag & drop or paste images directly into the editor" ) }
82+ </ div >
83+ </ div >
5284 </ div >
5385 ) ;
54- }
86+ }
0 commit comments