From 5c1eda33927987403181b46afb3834cda4963d02 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 18 Feb 2023 15:31:59 +0000 Subject: [PATCH] Chore: Mobile: Refactor note-screen-shared utility lib --- .../gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx | 2 +- packages/app-desktop/gui/NoteRevisionViewer.tsx | 2 +- .../components/NoteBodyViewer/hooks/useOnMessage.ts | 2 +- packages/app-mobile/components/screens/Note.tsx | 6 +++--- packages/lib/components/shared/note-screen-shared.ts | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx index 35c00e40e..1ed9e5599 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx @@ -32,7 +32,7 @@ import convertToScreenCoordinates from '../../../utils/convertToScreenCoordinate import { MarkupToHtml } from '@joplin/renderer'; const { clipboard } = require('electron'); const debounce = require('debounce'); -const shared = require('@joplin/lib/components/shared/note-screen-shared.js'); +import shared from '@joplin/lib/components/shared/note-screen-shared'; const Menu = bridge().Menu; const MenuItem = bridge().MenuItem; import { reg } from '@joplin/lib/registry'; diff --git a/packages/app-desktop/gui/NoteRevisionViewer.tsx b/packages/app-desktop/gui/NoteRevisionViewer.tsx index 20b1c962b..553acdea5 100644 --- a/packages/app-desktop/gui/NoteRevisionViewer.tsx +++ b/packages/app-desktop/gui/NoteRevisionViewer.tsx @@ -17,7 +17,7 @@ const urlUtils = require('@joplin/lib/urlUtils'); const ReactTooltip = require('react-tooltip'); const { urlDecode } = require('@joplin/lib/string-utils'); const { connect } = require('react-redux'); -const shared = require('@joplin/lib/components/shared/note-screen-shared.js'); +import shared from '@joplin/lib/components/shared/note-screen-shared'; interface Props { themeId: number; diff --git a/packages/app-mobile/components/NoteBodyViewer/hooks/useOnMessage.ts b/packages/app-mobile/components/NoteBodyViewer/hooks/useOnMessage.ts index b07568f08..ab2736d1d 100644 --- a/packages/app-mobile/components/NoteBodyViewer/hooks/useOnMessage.ts +++ b/packages/app-mobile/components/NoteBodyViewer/hooks/useOnMessage.ts @@ -1,5 +1,5 @@ import { useCallback } from 'react'; -const shared = require('@joplin/lib/components/shared/note-screen-shared'); +import shared from '@joplin/lib/components/shared/note-screen-shared'; export default function useOnMessage(onCheckboxChange: Function, noteBody: string, onMarkForDownload: Function, onJoplinLinkClick: Function, onResourceLongPress: Function) { return useCallback((event: any) => { diff --git a/packages/app-mobile/components/screens/Note.tsx b/packages/app-mobile/components/screens/Note.tsx index 1efcdf42b..42363688a 100644 --- a/packages/app-mobile/components/screens/Note.tsx +++ b/packages/app-mobile/components/screens/Note.tsx @@ -37,7 +37,7 @@ const { themeStyle, editorFont } = require('../global-style.js'); const { dialogs } = require('../../utils/dialogs.js'); const DialogBox = require('react-native-dialogbox').default; const ImageResizer = require('react-native-image-resizer').default; -const shared = require('@joplin/lib/components/shared/note-screen-shared.js'); +import shared from '@joplin/lib/components/shared/note-screen-shared'; import { ImagePickerResponse, launchImageLibrary } from 'react-native-image-picker'; import SelectDateTimeDialog from '../SelectDateTimeDialog'; import ShareExtension from '../../utils/ShareExtension.js'; @@ -496,7 +496,7 @@ class NoteScreenComponent extends BaseScreenComponent { makeSaveAction() { return async () => { - return shared.saveNoteButton_press(this); + return shared.saveNoteButton_press(this, null, null); }; } @@ -512,7 +512,7 @@ class NoteScreenComponent extends BaseScreenComponent { } async saveNoteButton_press(folderId: string = null) { - await shared.saveNoteButton_press(this, folderId); + await shared.saveNoteButton_press(this, folderId, null); Keyboard.dismiss(); } diff --git a/packages/lib/components/shared/note-screen-shared.ts b/packages/lib/components/shared/note-screen-shared.ts index d20e76368..a36824aea 100644 --- a/packages/lib/components/shared/note-screen-shared.ts +++ b/packages/lib/components/shared/note-screen-shared.ts @@ -20,7 +20,7 @@ interface Shared { isModified?: (comp: any)=> boolean; initState?: (comp: any)=> void; toggleIsTodo_onPress?: (comp: any)=> void; - toggleCheckboxRange?: (ipcMessage: string, noteBody: string)=> void; + toggleCheckboxRange?: (ipcMessage: string, noteBody: string)=> any; toggleCheckbox?: (ipcMessage: string, noteBody: string)=> void; installResourceHandling?: (refreshResourceHandler: any)=> void; uninstallResourceHandling?: (refreshResourceHandler: any)=> void; @@ -329,4 +329,4 @@ shared.uninstallResourceHandling = function(refreshResourceHandler: any) { DecryptionWorker.instance().off('resourceDecrypted', refreshResourceHandler); }; -module.exports = shared; +export default shared;