1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Mobile: Add note revision viewer (#12305)

This commit is contained in:
Henry Heino
2025-05-27 09:22:52 -07:00
committed by GitHub
parent 47e4f36f97
commit 293eac9c04
13 changed files with 366 additions and 30 deletions

View File

@@ -15,6 +15,10 @@ import uuid from '@joplin/lib/uuid';
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
import useContentScripts from './hooks/useContentScripts';
import { MarkupLanguage } from '@joplin/renderer';
import shim from '@joplin/lib/shim';
import CommandService from '@joplin/lib/services/CommandService';
import { AppState } from '../../utils/types';
import { connect } from 'react-redux';
interface Props {
themeId: number;
@@ -27,7 +31,6 @@ interface Props {
paddingBottom: number;
initialScroll: number|null;
noteHash: string;
onJoplinLinkClick: HandleMessageCallback;
onCheckboxChange?: HandleMessageCallback;
onRequestEditResource?: HandleMessageCallback;
onMarkForDownload?: OnMarkForDownloadCallback;
@@ -36,7 +39,15 @@ interface Props {
pluginStates: PluginStates;
}
export default function NoteBodyViewer(props: Props) {
const onJoplinLinkClick = async (message: string) => {
try {
await CommandService.instance().execute('openItem', message);
} catch (error) {
await shim.showErrorDialog(error.message);
}
};
function NoteBodyViewer(props: Props) {
const webviewRef = useRef<WebViewControl>(null);
const onScroll = useCallback(async (scrollTop: number) => {
@@ -45,14 +56,14 @@ export default function NoteBodyViewer(props: Props) {
const onResourceLongPress = useOnResourceLongPress(
{
onJoplinLinkClick: props.onJoplinLinkClick,
onJoplinLinkClick,
onRequestEditResource: props.onRequestEditResource,
},
);
const onPostMessage = useOnMessage(props.noteBody, {
onMarkForDownload: props.onMarkForDownload,
onJoplinLinkClick: props.onJoplinLinkClick,
onJoplinLinkClick,
onRequestEditResource: props.onRequestEditResource,
onCheckboxChange: props.onCheckboxChange,
onResourceLongPress,
@@ -118,3 +129,9 @@ export default function NoteBodyViewer(props: Props) {
</View>
);
}
export default connect((state: AppState) => ({
themeId: state.settings.theme,
fontSize: state.settings['style.viewer.fontSize'],
pluginStates: state.pluginService.plugins,
}))(NoteBodyViewer);