Desktop: Resolves #11664: Reorganised note list context menu

pull/11665/head
Laurent Cozic 2025-01-16 17:42:17 +00:00
parent 6a1b498e96
commit f602ad8a63
3 changed files with 52 additions and 48 deletions

View File

@ -7,7 +7,7 @@ import Setting from '@joplin/lib/models/Setting';
export const declaration: CommandDeclaration = {
name: 'openNoteInNewWindow',
label: () => _('Edit in new window'),
label: () => _('Open in new window'),
iconName: 'icon-share',
};

View File

@ -7,7 +7,7 @@ const bridge = require('@electron/remote').require('./bridge').default;
export const declaration: CommandDeclaration = {
name: 'startExternalEditing',
label: () => _('Edit in external editor'),
label: () => _('Open in external editor'),
iconName: 'icon-share',
};

View File

@ -42,34 +42,24 @@ export default class NoteListUtils {
const menu = new Menu();
if (!includeEncryptedNotes && !includeDeletedNotes) {
if (singleNoteId) {
menu.append(
new MenuItem(menuUtils.commandToStatefulMenuItem('openNoteInNewWindow', singleNoteId)),
);
const cmd = props.watchedNoteFiles.includes(singleNoteId) ? 'stopExternalEditing' : 'startExternalEditing';
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menu.append(new MenuItem(menuUtils.commandToStatefulMenuItem(cmd, singleNoteId) as any));
menu.append(new MenuItem({ type: 'separator' }));
}
menu.append(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
new MenuItem(menuUtils.commandToStatefulMenuItem('setTags', noteIds) as any),
);
menu.append(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
new MenuItem(menuUtils.commandToStatefulMenuItem('moveToFolder', noteIds) as any),
);
menu.append(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
new MenuItem(menuUtils.commandToStatefulMenuItem('duplicateNote', noteIds) as any),
);
if (singleNoteId) {
const editInMenu = new Menu();
const cmd = props.watchedNoteFiles.includes(singleNoteId) ? 'stopExternalEditing' : 'startExternalEditing';
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
editInMenu.append(new MenuItem(menuUtils.commandToStatefulMenuItem(cmd, singleNoteId) as any));
editInMenu.append(
new MenuItem(menuUtils.commandToStatefulMenuItem('openNoteInNewWindow', singleNoteId)),
);
menu.append(new MenuItem({ label: _('Edit in...'), submenu: editInMenu }));
}
menu.append(new MenuItem({ type: 'separator' }));
if (noteIds.length <= 1) {
menu.append(
@ -107,6 +97,41 @@ export default class NoteListUtils {
);
}
menu.append(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
new MenuItem(menuUtils.commandToStatefulMenuItem('moveToFolder', noteIds) as any),
);
menu.append(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
new MenuItem(menuUtils.commandToStatefulMenuItem('duplicateNote', noteIds) as any),
);
if (includeDeletedNotes) {
menu.append(
new MenuItem(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menuUtils.commandToStatefulMenuItem('restoreNote', noteIds) as any,
),
);
menu.append(
new MenuItem(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menuUtils.commandToStatefulMenuItem('permanentlyDeleteNote', noteIds) as any,
),
);
} else {
menu.append(
new MenuItem(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menuUtils.commandToStatefulMenuItem('deleteNote', noteIds) as any,
),
);
}
menu.append(new MenuItem({ type: 'separator' }));
menu.append(
new MenuItem({
label: _('Copy Markdown link'),
@ -132,6 +157,8 @@ export default class NoteListUtils {
);
}
menu.append(new MenuItem({ type: 'separator' }));
if ([9, 10].includes(Setting.value('sync.target'))) {
menu.append(
new MenuItem(
@ -177,29 +204,6 @@ export default class NoteListUtils {
menu.append(exportMenuItem);
}
if (includeDeletedNotes) {
menu.append(
new MenuItem(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menuUtils.commandToStatefulMenuItem('restoreNote', noteIds) as any,
),
);
menu.append(
new MenuItem(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menuUtils.commandToStatefulMenuItem('permanentlyDeleteNote', noteIds) as any,
),
);
} else {
menu.append(
new MenuItem(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
menuUtils.commandToStatefulMenuItem('deleteNote', noteIds) as any,
),
);
}
const pluginViewInfos = pluginUtils.viewInfosByType(props.plugins, 'menuItem');
for (const info of pluginViewInfos) {