@@ -59,7 +59,6 @@ import useConnectToEditorPlugin from './utils/useConnectToEditorPlugin';
5959import getResourceBaseUrl from './utils/getResourceBaseUrl' ;
6060import useInitialCursorLocation from './utils/useInitialCursorLocation' ;
6161import NotePositionService , { EditorCursorLocations } from '@joplin/lib/services/NotePositionService' ;
62- import useConvertToMarkdownBanner from '@joplin/lib/components/shared/NoteEditor/WarningBanner/useConvertToMarkdownBanner' ;
6362
6463const debounce = require ( 'debounce' ) ;
6564
@@ -497,12 +496,16 @@ function NoteEditorContent(props: NoteEditorProps) {
497496 setShowRevisions ( false ) ;
498497 } , [ ] ) ;
499498
499+ const onBannerConvertItToMarkdown = useCallback ( async ( event : React . MouseEvent < HTMLAnchorElement > ) => {
500+ event . preventDefault ( ) ;
501+ if ( ! props . selectedNoteIds || props . selectedNoteIds . length === 0 ) return ;
502+ await CommandService . instance ( ) . execute ( 'convertNoteToMarkdown' , props . selectedNoteIds [ 0 ] ) ;
503+ } , [ props . selectedNoteIds ] ) ;
500504
501- const convertToMarkdownBannerData = useConvertToMarkdownBanner ( {
502- note : formNote ,
503- readOnly : isReadOnly ,
504- dismissed : ! props . enableHtmlToMarkdownBanner ,
505- } ) ;
505+ const onHideBannerConvertItToMarkdown = async ( event : React . MouseEvent < HTMLAnchorElement > ) => {
506+ event . preventDefault ( ) ;
507+ Setting . setValue ( 'editor.enableHtmlToMarkdownBanner' , false ) ;
508+ } ;
506509
507510 const onBannerResourceClick = useCallback ( async ( event : React . MouseEvent < HTMLAnchorElement > ) => {
508511 event . preventDefault ( ) ;
@@ -649,16 +652,20 @@ function NoteEditorContent(props: NoteEditorProps) {
649652 const theme = themeStyle ( props . themeId ) ;
650653
651654 function renderConvertHtmlToMarkdown ( ) : React . ReactNode {
652- if ( ! convertToMarkdownBannerData . enabled ) return null ;
655+ if ( ! props . enableHtmlToMarkdownBanner ) return null ;
656+
657+ const note = props . notes . find ( n => n . id === props . selectedNoteIds [ 0 ] ) ;
658+ if ( ! note ) return null ;
659+ if ( note . markup_language !== MarkupLanguage . Html ) return null ;
653660
654661 return (
655662 < div style = { styles . resourceWatchBanner } >
656663 < p style = { styles . resourceWatchBannerLine } >
657664 { _ ( 'This note is in HTML format. Convert it to Markdown to edit it more easily.' ) }
658665
659- < button className = 'link-button' style = { styles . resourceWatchBannerAction } onClick = { convertToMarkdownBannerData . convert . onPress } > { convertToMarkdownBannerData . convert . label } </ button >
666+ < a href = "#" style = { styles . resourceWatchBannerAction } onClick = { onBannerConvertItToMarkdown } > { ` ${ _ ( 'Convert it' ) } ` } </ a >
660667 { ' / ' }
661- < button className = 'link-button' style = { styles . resourceWatchBannerAction } onClick = { convertToMarkdownBannerData . dismiss . onPress } > { convertToMarkdownBannerData . dismiss . label } </ button >
668+ < a href = "#" style = { styles . resourceWatchBannerAction } onClick = { onHideBannerConvertItToMarkdown } > { _ ( 'Don\'t show this message again' ) } </ a >
662669 </ p >
663670 </ div >
664671 ) ;
0 commit comments