WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2c93cfc

Browse files
Revert more changes specific to laurent22#13841
1 parent fb91ee3 commit 2c93cfc

File tree

5 files changed

+16
-57
lines changed

5 files changed

+16
-57
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,6 @@ packages/lib/components/EncryptionConfigScreen/utils.test.js
12621262
packages/lib/components/EncryptionConfigScreen/utils.js
12631263
packages/lib/components/shared/NoteEditor/WarningBanner/onRichTextDismissLinkClick.js
12641264
packages/lib/components/shared/NoteEditor/WarningBanner/onRichTextReadMoreLinkClick.js
1265-
packages/lib/components/shared/NoteEditor/WarningBanner/useConvertToMarkdownBanner.js
12661265
packages/lib/components/shared/NoteEditor/WarningBanner/useEditorTypeMigrationBanner.js
12671266
packages/lib/components/shared/NoteList/getEmptyFolderMessage.js
12681267
packages/lib/components/shared/NoteRevisionViewer/getHelpMessage.js

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,6 @@ packages/lib/components/EncryptionConfigScreen/utils.test.js
12341234
packages/lib/components/EncryptionConfigScreen/utils.js
12351235
packages/lib/components/shared/NoteEditor/WarningBanner/onRichTextDismissLinkClick.js
12361236
packages/lib/components/shared/NoteEditor/WarningBanner/onRichTextReadMoreLinkClick.js
1237-
packages/lib/components/shared/NoteEditor/WarningBanner/useConvertToMarkdownBanner.js
12381237
packages/lib/components/shared/NoteEditor/WarningBanner/useEditorTypeMigrationBanner.js
12391238
packages/lib/components/shared/NoteList/getEmptyFolderMessage.js
12401239
packages/lib/components/shared/NoteRevisionViewer/getHelpMessage.js

packages/app-desktop/gui/NoteEditor/NoteEditor.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import useConnectToEditorPlugin from './utils/useConnectToEditorPlugin';
5959
import getResourceBaseUrl from './utils/getResourceBaseUrl';
6060
import useInitialCursorLocation from './utils/useInitialCursorLocation';
6161
import NotePositionService, { EditorCursorLocations } from '@joplin/lib/services/NotePositionService';
62-
import useConvertToMarkdownBanner from '@joplin/lib/components/shared/NoteEditor/WarningBanner/useConvertToMarkdownBanner';
6362

6463
const 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
&nbsp;
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
);

packages/app-mobile/components/NoteEditor/NoteEditor.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { Store } from 'redux';
1717
import { AppState } from '../../utils/types';
1818
import { MarkupLanguage } from '@joplin/renderer';
1919
import { EditorType } from './types';
20-
import shim from '@joplin/lib/shim';
2120

2221
let store: Store<AppState>;
2322
let registeredRuntime: RegisteredRuntime;
@@ -57,7 +56,6 @@ describe('NoteEditor', () => {
5756
store = createMockReduxStore();
5857
setupGlobalStore(store);
5958
registeredRuntime = mockCommandRuntimes(store);
60-
shim.showMessageBox = jest.fn();
6159
});
6260

6361
afterEach(() => {

packages/lib/components/shared/NoteEditor/WarningBanner/useConvertToMarkdownBanner.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)