一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
29 行
1.0 KiB
TypeScript
29 行
1.0 KiB
TypeScript
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
|
|
import { CommandRuntimeProps } from '../types';
|
|
import Setting from '@joplin/lib/models/Setting';
|
|
import { AccessibilityInfo } from 'react-native';
|
|
import { _ } from '@joplin/lib/locale';
|
|
|
|
export const declaration: CommandDeclaration = {
|
|
// For compatibility with the desktop app, this command is called "toggleVisiblePanes".
|
|
name: 'toggleVisiblePanes',
|
|
label: () => 'Start/stop editing',
|
|
};
|
|
|
|
export const runtime = (props: CommandRuntimeProps): CommandRuntime => {
|
|
return {
|
|
execute: async (_context: CommandContext) => {
|
|
const panes = Setting.value('noteVisiblePanes') || ['viewer'];
|
|
props.dispatch({
|
|
type: 'NOTE_VISIBLE_PANES_SET',
|
|
panes: panes.includes('editor') ? ['viewer'] : ['editor'],
|
|
});
|
|
const currentMode = props.getMode();
|
|
const newMode = currentMode === 'edit' ? 'view' : 'edit';
|
|
props.setMode(newMode);
|
|
|
|
AccessibilityInfo.announceForAccessibility(newMode === 'view' ? _('Viewing') : _('Editing'));
|
|
},
|
|
};
|
|
};
|