Skip to content

Commit 7e8dee4

Browse files
committed
Desktop: Added keyboard shortcut and menu item for toggleEditorPlugin command
1 parent 69fb1ab commit 7e8dee4

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

packages/app-desktop/gui/MenuBar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ function useMenu(props: Props) {
789789
shim.isMac() ? noItem : menuItemDic.toggleMenuBar,
790790
menuItemDic.toggleNoteList,
791791
menuItemDic.toggleVisiblePanes,
792+
menuItemDic.toggleEditorPlugin,
792793
{
793794
label: _('Layout button sequence'),
794795
submenu: layoutButtonSequenceMenuItems,

packages/app-desktop/gui/menuCommandNames.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function() {
4343
'togglePerFolderSortOrder',
4444
'toggleSideBar',
4545
'toggleVisiblePanes',
46+
'toggleEditorPlugin',
4647
'toggleTabMovesFocus',
4748
'editor.deleteLine',
4849
'editor.duplicateLine',

packages/lib/commands/toggleEditorPlugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ export const runtime = (): CommandRuntime => {
4545
});
4646
}
4747
},
48+
49+
enabledCondition: 'hasActivePluginEditor',
4850
};
4951
};

packages/lib/services/KeymapService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const defaultKeymapItems = {
4242
{ accelerator: 'Option+Cmd+S', command: 'toggleSideBar' },
4343
{ accelerator: 'Option+Cmd+L', command: 'toggleNoteList' },
4444
{ accelerator: 'Cmd+L', command: 'toggleVisiblePanes' },
45+
{ accelerator: 'Option+Cmd+V', command: 'toggleEditorPlugin' },
4546
{ accelerator: 'Cmd+0', command: 'zoomActualSize' },
4647
{ accelerator: 'Cmd+E', command: 'toggleExternalEditing' },
4748
{ accelerator: 'Option+Cmd+T', command: 'setTags' },
@@ -93,6 +94,7 @@ const defaultKeymapItems = {
9394
{ accelerator: 'Ctrl+Shift+M', command: 'toggleMenuBar' },
9495
{ accelerator: 'F11', command: 'toggleNoteList' },
9596
{ accelerator: 'Ctrl+L', command: 'toggleVisiblePanes' },
97+
{ accelerator: 'Alt+Ctrl+V', command: 'toggleEditorPlugin' },
9698
{ accelerator: 'Ctrl+0', command: 'zoomActualSize' },
9799
{ accelerator: 'Ctrl+E', command: 'toggleExternalEditing' },
98100
{ accelerator: 'Ctrl+Alt+T', command: 'setTags' },

packages/lib/services/commands/stateToWhenClauseContext.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FolderEntity, NoteEntity } from '../database/types';
77
import { itemIsReadOnlySync, ItemSlice } from '../../models/utils/readOnly';
88
import ItemChange from '../../models/ItemChange';
99
import { getTrashFolderId } from '../trash';
10+
import getActivePluginEditorView from '../plugins/utils/getActivePluginEditorView';
1011

1112
export interface WhenClauseContextOptions {
1213
commandFolderId?: string;
@@ -43,6 +44,7 @@ export interface WhenClauseContext {
4344
oneNoteSelected: boolean;
4445
someNotesSelected: boolean;
4546
syncStarted: boolean;
47+
hasActivePluginEditor: boolean;
4648
}
4749

4850
export default function stateToWhenClauseContext(state: State, options: WhenClauseContextOptions = null): WhenClauseContext {
@@ -61,6 +63,8 @@ export default function stateToWhenClauseContext(state: State, options: WhenClau
6163
const commandFolderId = options.commandFolderId || windowState.selectedFolderId;
6264
const commandFolder: FolderEntity = commandFolderId ? BaseModel.byId(state.folders, commandFolderId) : null;
6365

66+
const { editorPlugin } = state.pluginService ? getActivePluginEditorView(state.pluginService.plugins) : { editorPlugin: null };
67+
6468
const settings = state.settings || {};
6569

6670
return {
@@ -108,5 +112,7 @@ export default function stateToWhenClauseContext(state: State, options: WhenClau
108112
joplinServerConnected: [9, 10].includes(settings['sync.target']),
109113
joplinCloudAccountType: settings['sync.target'] === 10 ? settings['sync.10.accountType'] : 0,
110114
hasMultiProfiles: state.profileConfig && state.profileConfig.profiles.length > 1,
115+
116+
hasActivePluginEditor: !!editorPlugin,
111117
};
112118
}

0 commit comments

Comments
 (0)