@@ -13,7 +13,8 @@ export const useCopyCurrentEditorToClipboard = () => {
1313
1414 return async ( asFormat : 'html' | 'markdown' ) => {
1515 if ( ! editor ) {
16- toast ( t ( 'Editor unavailable' ) , VariantType . ERROR , { duration : 3000 } ) ;
16+ const message = t ( 'Editor unavailable' ) ;
17+ toast ( message , VariantType . ERROR , { duration : 3000 } ) ;
1718 return ;
1819 }
1920
@@ -23,10 +24,20 @@ export const useCopyCurrentEditorToClipboard = () => {
2324 ? await editor . blocksToHTMLLossy ( )
2425 : await editor . blocksToMarkdownLossy ( ) ;
2526 await navigator . clipboard . writeText ( editorContentFormatted ) ;
26- toast ( t ( 'Copied to clipboard' ) , VariantType . SUCCESS , { duration : 3000 } ) ;
27+ const successMessage =
28+ asFormat === 'markdown'
29+ ? t ( 'Copied as Markdown to clipboard' )
30+ : t ( 'Copied to clipboard' ) ;
31+
32+ toast ( successMessage , VariantType . SUCCESS , { duration : 3000 } ) ;
2733 } catch ( error ) {
2834 console . error ( error ) ;
29- toast ( t ( 'Failed to copy to clipboard' ) , VariantType . ERROR , {
35+ const errorMessage =
36+ asFormat === 'markdown'
37+ ? t ( 'Failed to copy as Markdown to clipboard' )
38+ : t ( 'Failed to copy to clipboard' ) ;
39+
40+ toast ( errorMessage , VariantType . ERROR , {
3041 duration : 3000 ,
3142 } ) ;
3243 }
0 commit comments