From b1ea3f3ad16476e4c12e972aa70900eaf773b348 Mon Sep 17 00:00:00 2001 From: Caleb John Date: Sun, 25 Apr 2021 02:57:35 -0600 Subject: [PATCH] Desktop: Add "duplicate line" command in Markdown editor (#4873) Ref: https://discourse.joplinapp.org/t/duplicate-line-command/12650/15 --- packages/app-desktop/gui/MenuBar.tsx | 1 + .../gui/NoteEditor/commands/editorCommandDeclarations.ts | 4 ++++ packages/app-desktop/gui/menuCommandNames.ts | 1 + packages/lib/services/KeymapService.ts | 2 ++ 4 files changed, 8 insertions(+) diff --git a/packages/app-desktop/gui/MenuBar.tsx b/packages/app-desktop/gui/MenuBar.tsx index 6340891dc..7d7b3b74e 100644 --- a/packages/app-desktop/gui/MenuBar.tsx +++ b/packages/app-desktop/gui/MenuBar.tsx @@ -596,6 +596,7 @@ function useMenu(props: Props) { menuItemDic.attachFile, separator(), menuItemDic['editor.deleteLine'], + menuItemDic['editor.duplicateLine'], menuItemDic['editor.toggleComment'], menuItemDic['editor.sortSelectedLines'], menuItemDic['editor.indentLess'], diff --git a/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts b/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts index ce72406ed..a08f95c45 100644 --- a/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts +++ b/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts @@ -87,6 +87,10 @@ const declarations: CommandDeclaration[] = [ name: 'editor.deleteLine', label: () => _('Delete line'), }, + { + name: 'editor.duplicateLine', + label: () => _('Duplicate line'), + }, { name: 'editor.undo', label: () => _('Undo'), diff --git a/packages/app-desktop/gui/menuCommandNames.ts b/packages/app-desktop/gui/menuCommandNames.ts index 68a57b74c..c91d396df 100644 --- a/packages/app-desktop/gui/menuCommandNames.ts +++ b/packages/app-desktop/gui/menuCommandNames.ts @@ -35,6 +35,7 @@ export default function() { 'toggleSideBar', 'toggleVisiblePanes', 'editor.deleteLine', + 'editor.duplicateLine', 'editor.undo', 'editor.redo', 'editor.indentLess', diff --git a/packages/lib/services/KeymapService.ts b/packages/lib/services/KeymapService.ts index 3ecb38698..fa2bbc150 100644 --- a/packages/lib/services/KeymapService.ts +++ b/packages/lib/services/KeymapService.ts @@ -46,6 +46,7 @@ const defaultKeymapItems = { { accelerator: 'Shift+Cmd+P', command: 'commandPalette' }, { accelerator: 'F1', command: 'help' }, { accelerator: 'Cmd+D', command: 'editor.deleteLine' }, + { accelerator: 'Shift+Cmd+D', command: 'editor.duplicateLine' }, { accelerator: 'Cmd+Z', command: 'editor.undo' }, { accelerator: 'Cmd+Y', command: 'editor.redo' }, { accelerator: 'Cmd+[', command: 'editor.indentLess' }, @@ -87,6 +88,7 @@ const defaultKeymapItems = { { accelerator: 'Ctrl+Shift+P', command: 'commandPalette' }, { accelerator: 'F1', command: 'help' }, { accelerator: 'Ctrl+D', command: 'editor.deleteLine' }, + { accelerator: 'Shift+Ctrl+D', command: 'editor.duplicateLine' }, { accelerator: 'Ctrl+Z', command: 'editor.undo' }, { accelerator: 'Ctrl+Y', command: 'editor.redo' }, { accelerator: 'Ctrl+[', command: 'editor.indentLess' },