diff --git a/docs/KEYBINDINGS.md b/docs/KEYBINDINGS.md index db143887..4914abe4 100644 --- a/docs/KEYBINDINGS.md +++ b/docs/KEYBINDINGS.md @@ -13,11 +13,11 @@ Here is an example: ## Available modifiers -- `CmdOrCtrl` - `Cmd` on macOS +- `Option` on macOS - `Ctrl` -- `Alt`/`AltGr` or `Option` on macOS - `Shift` +- `Alt` and `AltGr` on Linux and Windows - `Super` on Linux and Windows ## Available keys @@ -28,133 +28,8 @@ Here is an example: - `PageUp` and `PageDown` - Empty string `""` to unset a accelerator -## Available id's +## Available key bindings -**MarkText menu (macOS only):** - -| Id | Default | Description | -| ------------------ | ---------------------------------------------- | --------------------------------------- | -| `mt.hide` | Command+H | Hide MarkText | -| `mt.hide-others` | Command+Alt+H | Hide all other windows except MarkText | -| `file.preferences` | Command+, | Open settings window | -| `file.quit` | Command+Q | Quit MarkText | - -**File menu:** - -| Id | Default | Description | -|:------------------- | -------------------------------------------------- | ----------------------------------------- | -| `file.new-file` | CmdOrCtrl+N | New file | -| `file.new-tab` | CmdOrCtrl+T | New tab | -| `file.open-file` | CmdOrCtrl+O | Open markdown file | -| `file.open-folder` | CmdOrCtrl+Shift+O | Open folder | -| `file.save` | CmdOrCtrl+S | Save | -| `file.save-as` | CmdOrCtrl+Shift+S | Save as... | -| `file.print` | - | Print current tab | -| `file.preferences` | Ctrl+, | Open settings window (Linux/Windows only) | -| `file.close-tab` | CmdOrCtrl+W | Close tab | -| `file.close-window` | CmdOrCtrl+Shift+W | Close window | -| `file.quit` | CmdOrCtrl+Q | Quit MarkText (Linux/Windows only) | - -**Edit menu:** - -| Id | Default | Description | -|:------------------------ | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -| `edit.undo` | CmdOrCtrl+Z | Undo last operation | -| `edit.redo` | CmdOrCtrl+Shift+Z | Redo last operation | -| `edit.cut` | CmdOrCtrl+X | Cut selected text | -| `edit.copy` | CmdOrCtrl+C | Copy selected text | -| `edit.paste` | CmdOrCtrl+V | Paste text | -| `edit.copy-as-markdown` | CmdOrCtrl+Shift+C | Copy selected text as markdown | -| `edit.copy-as-plaintext` | CmdOrCtrl+Shift+V | Copy selected text as plaintext | -| `edit.select-all` | CmdOrCtrl+A | Select all text of the document | -| `edit.duplicate` | CmdOrCtrl+Alt+P | Duplicate the current paragraph | -| `edit.create-paragraph` | CmdOrCtrl+Shift+N | Create a new paragraph after the current one | -| `edit.delete-paragraph` | CmdOrCtrl+Shift+D | Delete current paragraph | -| `edit.find` | CmdOrCtrl+F | Find information in the document | -| `edit.find-next` | F3 | Continue the search and find the next match (or Cmd+G on macOS) | -| `edit.find-previous` | Shift+F3 | Continue the search and find the previous match (or Shift+Cmd+G on macOS) | -| `edit.replace` | CmdOrCtrl+Alt+F | Replace the information with a replacement | -| `edit.find-in-folder` | CmdOrCtrl+Shift+F | Find files contain the keyword in opend folder | -| `edit.aidou` | CmdOrCtrl+/ | Show Aidou dialog | -| `edit.screenshot` | Command+Alt+A | Get the screenshot (macOS only) | - -**Paragraph menu:** - -| Id | Default | Description | -| --------------------------- | -------------------------------------------------- | ------------------------------------------------- | -| `paragraph.heading-1` | CmdOrCtrl+1 | Set line as heading 1 | -| `paragraph.heading-2` | CmdOrCtrl+2 | Set line as heading 2 | -| `paragraph.heading-3` | CmdOrCtrl+3 | Set line as heading 3 | -| `paragraph.heading-4` | CmdOrCtrl+4 | Set line as heading 4 | -| `paragraph.heading-5` | CmdOrCtrl+5 | Set line as heading 5 | -| `paragraph.heading-6` | CmdOrCtrl+6 | Set line as heading 6 | -| `paragraph.upgrade-heading` | CmdOrCtrl+= | Upgrade a heading | -| `paragraph.degrade-heading` | CmdOrCtrl+- | Degrade a heading | -| `paragraph.table` | CmdOrCtrl+Shift+T | Insert a table | -| `paragraph.code-fence` | CmdOrCtrl+Alt+C | Insert a code block | -| `paragraph.quote-block` | CmdOrCtrl+Alt+Q | Insert a quote block | -| `paragraph.math-formula` | CmdOrCtrl+Alt+M | Insert a math block | -| `paragraph.html-block` | CmdOrCtrl+Alt+J/H | Insert a HTML block (`J` on macOS, `H` otherwise) | -| `paragraph.order-list` | CmdOrCtrl+Alt+O | Insert a ordered list | -| `paragraph.bullet-list` | CmdOrCtrl+Alt+U | Insert a unordered list | -| `paragraph.task-list` | CmdOrCtrl+Alt+X | Insert a task list | -| `paragraph.loose-list-item` | CmdOrCtrl+Alt+L | Convert a list item to a loose list item | -| `paragraph.paragraph` | CmdOrCtrl+0 | Convert a heading to a paragraph | -| `paragraph.horizontal-line` | CmdOrCtrl+Alt+- | Add a horizontal line | -| `paragraph.front-matter` | CmdOrCtrl+Alt+Y | Insert a YAML frontmatter block | - -**Format menu:** - -| Id | Default | Description | -| --------------------- | -------------------------------------------------- | ------------------------------------------- | -| `format.strong` | CmdOrCtrl+B | Set the font of the selected text to bold | -| `format.emphasis` | CmdOrCtrl+I | Set the font of the selected text to italic | -| `format.underline` | CmdOrCtrl+U | Change the selected text to underline | -| `format.highlight` | CmdOrCtrl+Shift+H | Highlight the selected text by  tag | -| `format.inline-code` | CmdOrCtrl+` | Change the selected text to inline code | -| `format.inline-math` | CmdOrCtrl+Shift+M | Change the selected text to inline math | -| `format.strike` | CmdOrCtrl+D | Strike through the selected text | -| `format.hyperlink` | CmdOrCtrl+L | Insert a hyperlink | -| `format.image` | CmdOrCtrl+Shift+I | Insert a image | -| `format.clear-format` | CmdOrCtrl+Shift+R | Clear the formatting of the selected text | - -**Window menu:** - -| Id | Default | Description | -| --------------------------- | --------------------------------- | ------------------------------------------------------------------------------------ | -| `window.minimize` | CmdOrCtrl+M | Minimize the window | -| `window.toggle-full-screen` | F11 | Toggle fullscreen mode (or Ctrl+Command+F on macOS) | - -**View menu:** - -| Id | Default | Description | -| ----------------------- | -------------------------------------------------- | ---------------------------------------- | -| `view.command-palette` | CmdOrCtrl+Shift+P | Toggle command palette | -| `view.source-code-mode` | CmdOrCtrl+Alt+S | Switch to source code mode | -| `view.typewriter-mode` | CmdOrCtrl+Alt+T | Enable typewriter mode | -| `view.focus-mode` | CmdOrCtrl+Shift+J | Enable focus mode | -| `view.toggle-sidebar` | CmdOrCtrl+J | Toggle sidebar | -| `view.toggle-tabbar` | CmdOrCtrl+Alt+B | Toggle tabbar | -| `view.toggle-toc` . | CmdOrCtrl+K | Toggle table of contents | -| `view.toggle-dev-tools` | CmdOrCtrl+Alt+I | Toggle developer tools (debug mode only) | -| `view.dev-reload` | CmdOrCtrl+R | Reload window (debug mode only) | - -**Misc** - -| Id | Default | Description | -| ------------------------ | ---------------------------------------------------- | ---------------------------- | -| `tabs.cycle-forward` | Ctrl+Tab | Cycle through tabs | -| `tabs.cycle-backward` | Ctrl+Shift+Tab | Cycle backwards through tabs | -| `tabs.switch-to-left` | CmdOrCtrl+PageUp | Switch tab to the left | -| `tabs.switch-to-right` | CmdOrCtrl+PageDown | Switch tab to the right | -| `tabs.switch-to-first` | Alt+1 | Switch tab to the 1st | -| `tabs.switch-to-second` | Alt+2 | Switch tab to the 2nd | -| `tabs.switch-to-third` | Alt+3 | Switch tab to the 3rd | -| `tabs.switch-to-fourth` | Alt+4 | Switch tab to the 4th | -| `tabs.switch-to-fifth` | Alt+5 | Switch tab to the 5th | -| `tabs.switch-to-sixth` | Alt+6 | Switch tab to the 6th | -| `tabs.switch-to-seventh` | Alt+7 | Switch tab to the 7th | -| `tabs.switch-to-eighth` | Alt+8 | Switch tab to the 8th | -| `tabs.switch-to-ninth` | Alt+9 | Switch tab to the 9th | -| `tabs.switch-to-tenth` | Alt+0 | Switch tab to the 10th | -| `file.quick-open` | CmdOrCtrl+P | Open quick open dialog | +- [Key bindings for macOS](KEYBINDINGS_OSX.md) +- [Key bindings for Linux](KEYBINDINGS_LINUX.md) +- [Key bindings for Windows](KEYBINDINGS_WINDOWS.md) diff --git a/docs/KEYBINDINGS_LINUX.md b/docs/KEYBINDINGS_LINUX.md new file mode 100644 index 00000000..8162ffba --- /dev/null +++ b/docs/KEYBINDINGS_LINUX.md @@ -0,0 +1,139 @@ +# Key Bindings for Linux + +MarkText key bindings for Linux. Please see [general key bindings](KEYBINDINGS.md) for information how to use custom key bindings. + +## Available menu key bindings + +#### File menu + +| Id | Default | Description | +|:------------------- | --------------------------------------------- | ------------------------------------- | +| `file.new-file` | Ctrl+N | New file | +| `file.new-tab` | Ctrl+T | New tab | +| `file.open-file` | Ctrl+O | Open markdown file | +| `file.open-folder` | Ctrl+Shift+O | Open folder | +| `file.save` | Ctrl+S | Save | +| `file.save-as` | Ctrl+Shift+S | Save as... | +| `file.move-file` | - | Move current file to another location | +| `file.rename-file` | - | Rename current file | +| `file.print` | - | Print current tab | +| `file.preferences` | Ctrl+, | Open settings window | +| `file.close-tab` | Ctrl+W | Close tab | +| `file.close-window` | Ctrl+Shift+W | Close window | +| `file.quit` | Ctrl+Q | Quit MarkText | + +#### Edit menu + +| Id | Default | Description | +|:------------------------- | --------------------------------------------- | ----------------------------------------------- | +| `edit.undo` | Ctrl+Z | Undo last operation | +| `edit.redo` | Ctrl+Shift+Z | Redo last operation | +| `edit.cut` | Ctrl+X | Cut selected text | +| `edit.copy` | Ctrl+C | Copy selected text | +| `edit.paste` | Ctrl+V | Paste text | +| `edit.copy-as-markdown` | Ctrl+Shift+C | Copy selected text as markdown | +| `edit.copy-as-html` | - | Copy selected text as html | +| `edit.paste-as-plaintext` | Ctrl+Shift+V | Copy selected text as plaintext | +| `edit.select-all` | Ctrl+A | Select all text of the document | +| `edit.duplicate` | Ctrl+Shift+E | Duplicate the current paragraph | +| `edit.create-paragraph` | Ctrl+Shift+N | Create a new paragraph after the current one | +| `edit.delete-paragraph` | Ctrl+Shift+D | Delete current paragraph | +| `edit.find` | Ctrl+F | Find information in the document | +| `edit.find-next` | F3 | Continue the search and find the next match | +| `edit.find-previous` | Shift+F3 | Continue the search and find the previous match | +| `edit.replace` | Ctrl+R | Replace the information with a replacement | +| `edit.find-in-folder` | Ctrl+Shift+F | Find files contain the keyword in opend folder | +| `edit.aidou` | Ctrl+/ | Show Aidou dialog | + +#### Paragraph menu + +| Id | Default | Description | +| --------------------------- | --------------------------------------------- | ---------------------------------------- | +| `paragraph.heading-1` | Ctrl+Shift+1 | Set line as heading 1 | +| `paragraph.heading-2` | Ctrl+Shift+2 | Set line as heading 2 | +| `paragraph.heading-3` | Ctrl+Shift+3 | Set line as heading 3 | +| `paragraph.heading-4` | Ctrl+Shift+4 | Set line as heading 4 | +| `paragraph.heading-5` | Ctrl+Shift+5 | Set line as heading 5 | +| `paragraph.heading-6` | Ctrl+Shift+6 | Set line as heading 6 | +| `paragraph.upgrade-heading` | Ctrl+= | Upgrade a heading | +| `paragraph.degrade-heading` | Ctrl+- | Degrade a heading | +| `paragraph.table` | Ctrl+Shift+T | Insert a table | +| `paragraph.code-fence` | Ctrl+Shift+K | Insert a code block | +| `paragraph.quote-block` | Ctrl+Shift+Q | Insert a quote block | +| `paragraph.math-formula` | Ctrl+Alt+M | Insert a math block | +| `paragraph.html-block` | Ctrl+Alt+H | Insert a HTML block | +| `paragraph.order-list` | Ctrl+G | Insert a ordered list | +| `paragraph.bullet-list` | Ctrl+Shift+G | Insert a unordered list | +| `paragraph.task-list` | Ctrl+Shift+X | Insert a task list | +| `paragraph.loose-list-item` | Ctrl+Shift+L | Convert a list item to a loose list item | +| `paragraph.paragraph` | Ctrl+Shift+0 | Convert a heading to a paragraph | +| `paragraph.horizontal-line` | Ctrl+H | Add a horizontal line | +| `paragraph.front-matter` | Ctrl+Shift+Y | Insert a YAML frontmatter block | + +#### Format menu + +| Id | Default | Description | +| --------------------- | --------------------------------------------- | ----------------------------------------------- | +| `format.strong` | Ctrl+B | Set the font of the selected text to bold | +| `format.emphasis` | Ctrl+I | Set the font of the selected text to italic | +| `format.underline` | Ctrl+U | Change the selected text to underline | +| `format.superscript` | - | Change the selected text to underline | +| `format.subscript` | - | Change the selected text to underline | +| `format.highlight` | Ctrl+Shift+H | Highlight the selected text by tag | +| `format.inline-code` | Ctrl+` | Change the selected text to inline code | +| `format.inline-math` | Ctrl+Shift+M | Change the selected text to inline math | +| `format.strike` | Ctrl+D | Strike through the selected text | +| `format.hyperlink` | Ctrl+L | Insert a hyperlink | +| `format.image` | Ctrl+Shift+I | Insert a image | +| `format.clear-format` | Ctrl+Shift+R | Clear the formatting of the selected text | + +#### Window menu + +| Id | Default | Description | +| ----------------------------- | ---------------------------- | ------------------------- | +| `window.minimize` | Ctrl+M | Minimize the window | +| `window.toggle-always-on-top` | - | Toogle always on top mode | +| `window.zoom-in` | - | Zoom in | +| `window.zoom-out` | - | Zoom out | +| `window.toggle-full-screen` | F11 | Toggle fullscreen mode | + +#### View menu + +| Id | Default | Description | +| ----------------------- | --------------------------------------------- | ---------------------------------------- | +| `view.command-palette` | Ctrl+Shift+P | Toggle command palette | +| `view.source-code-mode` | Ctrl+E | Switch to source code mode | +| `view.typewriter-mode` | Ctrl+Shift+G | Enable typewriter mode | +| `view.focus-mode` | Ctrl+Shift+J | Enable focus mode | +| `view.toggle-sidebar` | Ctrl+J | Toggle sidebar | +| `view.toggle-tabbar` | Ctrl+Shift+B | Toggle tabbar | +| `view.toggle-toc` . | Ctrl+K | Toggle table of contents | +| `view.toggle-dev-tools` | Ctrl+Alt+I | Toggle developer tools (debug mode only) | +| `view.dev-reload` | Ctrl+F5 | Reload window (debug mode only) | + +## Available key bindings + +#### Tabs + +| Id | Default | Description | +| ------------------------ | ----------------------------------------------- | ---------------------------- | +| `tabs.cycle-forward` | Ctrl+Tab | Cycle through tabs | +| `tabs.cycle-backward` | Ctrl+Shift+Tab | Cycle backwards through tabs | +| `tabs.switch-to-left` | Ctrl+PageUp | Switch tab to the left | +| `tabs.switch-to-right` | Ctrl+PageDown | Switch tab to the right | +| `tabs.switch-to-first` | Ctrl+1 | Switch tab to the 1st | +| `tabs.switch-to-second` | Ctrl+2 | Switch tab to the 2nd | +| `tabs.switch-to-third` | Ctrl+3 | Switch tab to the 3rd | +| `tabs.switch-to-fourth` | Ctrl+4 | Switch tab to the 4th | +| `tabs.switch-to-fifth` | Ctrl+5 | Switch tab to the 5th | +| `tabs.switch-to-sixth` | Ctrl+6 | Switch tab to the 6th | +| `tabs.switch-to-seventh` | Ctrl+7 | Switch tab to the 7th | +| `tabs.switch-to-eighth` | Ctrl+8 | Switch tab to the 8th | +| `tabs.switch-to-ninth` | Ctrl+9 | Switch tab to the 9th | +| `tabs.switch-to-tenth` | Ctrl+0 | Switch tab to the 10th | + +#### Misc + +| Id | Default | Description | +| ----------------- | ---------------------------- | ---------------------- | +| `file.quick-open` | Ctrl+P | Open quick open dialog | diff --git a/docs/KEYBINDINGS_OSX.md b/docs/KEYBINDINGS_OSX.md new file mode 100644 index 00000000..14cbee1f --- /dev/null +++ b/docs/KEYBINDINGS_OSX.md @@ -0,0 +1,147 @@ +# Key Bindings for macOS + +MarkText key bindings for macOS. Please see [general key bindings](KEYBINDINGS.md) for information how to use custom key bindings. + +## Available menu key bindings + +#### MarkText menu + +| Id | Default | Description | +| ------------------ | ---------------------------------------------- | -------------------------------------- | +| `mt.hide` | Command+H | Hide MarkText | +| `mt.hide-others` | Command+Alt+H | Hide all other windows except MarkText | +| `file.preferences` | Command+, | Open settings window | +| `file.quit` | Command+Q | Quit MarkText | + +#### File menu + +| Id | Default | Description | +|:------------------- | ------------------------------------------------ | ------------------------------------- | +| `file.new-file` | Command+N | New file | +| `file.new-tab` | Command+T | New tab | +| `file.open-file` | Command+O | Open markdown file | +| `file.open-folder` | Command+Shift+O | Open folder | +| `file.save` | Command+S | Save | +| `file.save-as` | Command+Shift+S | Save as... | +| `file.move-file` | - | Move current file to another location | +| `file.rename-file` | - | Rename current file | +| `file.print` | - | Print current tab | +| `file.close-tab` | Command+W | Close tab | +| `file.close-window` | Command+Shift+W | Close window | + +#### Edit menu + +| Id | Default | Description | +|:------------------------ | ------------------------------------------------ | ----------------------------------------------- | +| `edit.undo` | Command+Z | Undo last operation | +| `edit.redo` | Command+Shift+Z | Redo last operation | +| `edit.cut` | Command+X | Cut selected text | +| `edit.copy` | Command+C | Copy selected text | +| `edit.paste` | Command+V | Paste text | +| `edit.copy-as-markdown` | Command+Shift+C | Copy selected text as markdown | +| `edit.copy-as-html` | - | Copy selected text as html | +| `edit.paste-as-plaintext` | Command+Shift+V | Copy selected text as plaintext | +| `edit.select-all` | Command+A | Select all text of the document | +| `edit.duplicate` | Command+Alt+P | Duplicate the current paragraph | +| `edit.create-paragraph` | Command+Shift+N | Create a new paragraph after the current one | +| `edit.delete-paragraph` | Command+Shift+D | Delete current paragraph | +| `edit.find` | Command+F | Find information in the document | +| `edit.find-next` | Cmd+G | Continue the search and find the next match | +| `edit.find-previous` | Shift+Cmd+G | Continue the search and find the previous match | +| `edit.replace` | Command+Alt+F | Replace the information with a replacement | +| `edit.find-in-folder` | Command+Shift+F | Find files contain the keyword in opend folder | +| `edit.aidou` | Command+/ | Show Aidou dialog | +| `edit.screenshot` | Command+Alt+A | Get the screenshot | + +#### Paragraph menu + +| Id | Default | Description | +| --------------------------- | ------------------------------------------------ | ---------------------------------------- | +| `paragraph.heading-1` | Command+1 | Set line as heading 1 | +| `paragraph.heading-2` | Command+2 | Set line as heading 2 | +| `paragraph.heading-3` | Command+3 | Set line as heading 3 | +| `paragraph.heading-4` | Command+4 | Set line as heading 4 | +| `paragraph.heading-5` | Command+5 | Set line as heading 5 | +| `paragraph.heading-6` | Command+6 | Set line as heading 6 | +| `paragraph.upgrade-heading` | Command+= | Upgrade a heading | +| `paragraph.degrade-heading` | Command+- | Degrade a heading | +| `paragraph.table` | Command+Shift+T | Insert a table | +| `paragraph.code-fence` | Command+Alt+C | Insert a code block | +| `paragraph.quote-block` | Command+Alt+Q | Insert a quote block | +| `paragraph.math-formula` | Command+Alt+M | Insert a math block | +| `paragraph.html-block` | Command+Alt+J | Insert a HTML block | +| `paragraph.order-list` | Command+Alt+O | Insert a ordered list | +| `paragraph.bullet-list` | Command+Alt+U | Insert a unordered list | +| `paragraph.task-list` | Command+Alt+X | Insert a task list | +| `paragraph.loose-list-item` | Command+Alt+L | Convert a list item to a loose list item | +| `paragraph.paragraph` | Command+0 | Convert a heading to a paragraph | +| `paragraph.horizontal-line` | Command+Alt+- | Add a horizontal line | +| `paragraph.front-matter` | Command+Alt+Y | Insert a YAML frontmatter block | + +#### Format menu + +| Id | Default | Description | +| --------------------- | ------------------------------------------------ | ----------------------------------------------- | +| `format.strong` | Command+B | Set the font of the selected text to bold | +| `format.emphasis` | Command+I | Set the font of the selected text to italic | +| `format.underline` | Command+U | Change the selected text to underline | +| `format.superscript` | - | Change the selected text to underline | +| `format.subscript` | - | Change the selected text to underline | +| `format.highlight` | Command+Shift+H | Highlight the selected text by tag | +| `format.inline-code` | Command+` | Change the selected text to inline code | +| `format.inline-math` | Command+Shift+M | Change the selected text to inline math | +| `format.strike` | Command+D | Strike through the selected text | +| `format.hyperlink` | Command+L | Insert a hyperlink | +| `format.image` | Command+Shift+I | Insert a image | +| `format.clear-format` | Command+Shift+R | Clear the formatting of the selected text | + +#### Window menu + +| Id | Default | Description | +| ----------------------------- | ----------------------------------------------- | ------------------------- | +| `window.minimize` | Command+M | Minimize the window | +| `window.toggle-always-on-top` | - | Toogle always on top mode | +| `window.zoom-in` | - | Zoom in | +| `window.zoom-out` | - | Zoom out | +| `window.toggle-full-screen` | Ctrl+Command+F | Toggle fullscreen mode | + +#### View menu + +| Id | Default | Description | +| ----------------------- | ------------------------------------------------ | ---------------------------------------- | +| `view.command-palette` | Command+Shift+P | Toggle command palette | +| `view.source-code-mode` | Command+Alt+S | Switch to source code mode | +| `view.typewriter-mode` | Command+Alt+T | Enable typewriter mode | +| `view.focus-mode` | Command+Shift+J | Enable focus mode | +| `view.toggle-sidebar` | Command+J | Toggle sidebar | +| `view.toggle-tabbar` | Command+Alt+B | Toggle tabbar | +| `view.toggle-toc` . | Command+K | Toggle table of contents | +| `view.toggle-dev-tools` | Command+Alt+I | Toggle developer tools (debug mode only) | +| `view.dev-reload` | Command+R | Reload window (debug mode only) | + +## Available key bindings + +#### Tabs + +| Id | Default | Description | +| ------------------------ | ----------------------------------------------- | ---------------------------- | +| `tabs.cycle-forward` | Ctrl+Tab | Cycle through tabs | +| `tabs.cycle-backward` | Ctrl+Shift+Tab | Cycle backwards through tabs | +| `tabs.switch-to-left` | Command+PageUp | Switch tab to the left | +| `tabs.switch-to-right` | Command+PageDown | Switch tab to the right | +| `tabs.switch-to-first` | Ctrl+1 | Switch tab to the 1st | +| `tabs.switch-to-second` | Ctrl+2 | Switch tab to the 2nd | +| `tabs.switch-to-third` | Ctrl+3 | Switch tab to the 3rd | +| `tabs.switch-to-fourth` | Ctrl+4 | Switch tab to the 4th | +| `tabs.switch-to-fifth` | Ctrl+5 | Switch tab to the 5th | +| `tabs.switch-to-sixth` | Ctrl+6 | Switch tab to the 6th | +| `tabs.switch-to-seventh` | Ctrl+7 | Switch tab to the 7th | +| `tabs.switch-to-eighth` | Ctrl+8 | Switch tab to the 8th | +| `tabs.switch-to-ninth` | Ctrl+9 | Switch tab to the 9th | +| `tabs.switch-to-tenth` | Ctrl+0 | Switch tab to the 10th | + +#### Misc + +| Id | Default | Description | +| ----------------- | ------------------------------- | ---------------------- | +| `file.quick-open` | Command+P | Open quick open dialog | diff --git a/docs/KEYBINDINGS_WINDOWS.md b/docs/KEYBINDINGS_WINDOWS.md new file mode 100644 index 00000000..5e5f4ed2 --- /dev/null +++ b/docs/KEYBINDINGS_WINDOWS.md @@ -0,0 +1,139 @@ +ew.source-code-m# Key Bindings for Windows + +MarkText key bindings for Windows. Please see [general key bindings](KEYBINDINGS.md) for information how to use custom key bindings. + +## Available menu key bindings + +#### File menu + +| Id | Default | Description | +|:------------------- | --------------------------------------------- | ------------------------------------- | +| `file.new-file` | Ctrl+N | New file | +| `file.new-tab` | Ctrl+T | New tab | +| `file.open-file` | Ctrl+O | Open markdown file | +| `file.open-folder` | Ctrl+Shift+O | Open folder | +| `file.save` | Ctrl+S | Save | +| `file.save-as` | Ctrl+Shift+S | Save as... | +| `file.move-file` | - | Move current file to another location | +| `file.rename-file` | - | Rename current file | +| `file.print` | - | Print current tab | +| `file.preferences` | Ctrl+, | Open settings window | +| `file.close-tab` | Ctrl+W | Close tab | +| `file.close-window` | Ctrl+Shift+W | Close window | +| `file.quit` | Ctrl+Q | Quit MarkText | + +#### Edit menu + +| Id | Default | Description | +|:------------------------ | --------------------------------------------- | ----------------------------------------------- | +| `edit.undo` | Ctrl+Z | Undo last operation | +| `edit.redo` | Ctrl+Shift+Z | Redo last operation | +| `edit.cut` | Ctrl+X | Cut selected text | +| `edit.copy` | Ctrl+C | Copy selected text | +| `edit.paste` | Ctrl+V | Paste text | +| `edit.copy-as-markdown` | Ctrl+Shift+C | Copy selected text as markdown | +| `edit.copy-as-html` | - | Copy selected text as html | +| `edit.paste-as-plaintext` | Ctrl+Shift+V | Copy selected text as plaintext | +| `edit.select-all` | Ctrl+A | Select all text of the document | +| `edit.duplicate` | Ctrl+Alt+P | Duplicate the current paragraph | +| `edit.create-paragraph` | Ctrl+Shift+N | Create a new paragraph after the current one | +| `edit.delete-paragraph` | Ctrl+Shift+D | Delete current paragraph | +| `edit.find` | Ctrl+F | Find information in the document | +| `edit.find-next` | F3 | Continue the search and find the next match | +| `edit.find-previous` | Shift+F3 | Continue the search and find the previous match | +| `edit.replace` | Ctrl+R | Replace the information with a replacement | +| `edit.find-in-folder` | Ctrl+Shift+F | Find files contain the keyword in opend folder | +| `edit.aidou` | Ctrl+/ | Show Aidou dialog | + +#### Paragraph menu + +| Id | Default | Description | +| --------------------------- | --------------------------------------------- | ---------------------------------------- | +| `paragraph.heading-1` | Ctrl+Shift+1 | Set line as heading 1 | +| `paragraph.heading-2` | Ctrl+Shift+2 | Set line as heading 2 | +| `paragraph.heading-3` | Ctrl+Shift+3 | Set line as heading 3 | +| `paragraph.heading-4` | Ctrl+Shift+4 | Set line as heading 4 | +| `paragraph.heading-5` | Ctrl+Shift+5 | Set line as heading 5 | +| `paragraph.heading-6` | Ctrl+Shift+6 | Set line as heading 6 | +| `paragraph.upgrade-heading` | Ctrl+= | Upgrade a heading | +| `paragraph.degrade-heading` | Ctrl+- | Degrade a heading | +| `paragraph.table` | Ctrl+Shift+T | Insert a table | +| `paragraph.code-fence` | Ctrl+Alt+C | Insert a code block | +| `paragraph.quote-block` | Ctrl+Alt+Q | Insert a quote block | +| `paragraph.math-formula` | Ctrl+Alt+M | Insert a math block | +| `paragraph.html-block` | Ctrl+Alt+H | Insert a HTML block | +| `paragraph.order-list` | Ctrl+Alt+O | Insert a ordered list | +| `paragraph.bullet-list` | Ctrl+Alt+U | Insert a unordered list | +| `paragraph.task-list` | Ctrl+Alt+X | Insert a task list | +| `paragraph.loose-list-item` | Ctrl+Alt+L | Convert a list item to a loose list item | +| `paragraph.paragraph` | Ctrl+Shift+0 | Convert a heading to a paragraph | +| `paragraph.horizontal-line` | Ctrl+Alt+- | Add a horizontal line | +| `paragraph.front-matter` | Ctrl+Alt+Y | Insert a YAML frontmatter block | + +#### Format menu + +| Id | Default | Description | +| --------------------- | --------------------------------------------- | ----------------------------------------------- | +| `format.strong` | Ctrl+B | Set the font of the selected text to bold | +| `format.emphasis` | Ctrl+I | Set the font of the selected text to italic | +| `format.underline` | Ctrl+U | Change the selected text to underline | +| `format.superscript` | - | Change the selected text to underline | +| `format.subscript` | - | Change the selected text to underline | +| `format.highlight` | Ctrl+Shift+H | Highlight the selected text by tag | +| `format.inline-code` | Ctrl+` | Change the selected text to inline code | +| `format.inline-math` | Ctrl+Shift+M | Change the selected text to inline math | +| `format.strike` | Ctrl+D | Strike through the selected text | +| `format.hyperlink` | Ctrl+L | Insert a hyperlink | +| `format.image` | Ctrl+Shift+I | Insert a image | +| `format.clear-format` | Ctrl+Shift+R | Clear the formatting of the selected text | + +#### Window menu + +| Id | Default | Description | +| ----------------------------- | ---------------------------- | ------------------------- | +| `window.minimize` | Ctrl+M | Minimize the window | +| `window.toggle-always-on-top` | - | Toogle always on top mode | +| `window.zoom-in` | - | Zoom in | +| `window.zoom-out` | - | Zoom out | +| `window.toggle-full-screen` | F11 | Toggle fullscreen mode | + +#### View menu + +| Id | Default | Description | +| ----------------------- | --------------------------------------------- | ---------------------------------------- | +| `view.command-palette` | Ctrl+Shift+P | Toggle command palette | +| `view.source-code-mode` | Ctrl+E | Switch to source code mode | +| `view.typewriter-mode` | Ctrl+Alt+T | Enable typewriter mode | +| `view.focus-mode` | Ctrl+Shift+J | Enable focus mode | +| `view.toggle-sidebar` | Ctrl+J | Toggle sidebar | +| `view.toggle-tabbar` | Ctrl+Shift+B | Toggle tabbar | +| `view.toggle-toc` . | Ctrl+K | Toggle table of contents | +| `view.toggle-dev-tools` | Ctrl+Alt+I | Toggle developer tools (debug mode only) | +| `view.dev-reload` | Ctrl+F5 | Reload window (debug mode only) | + +## Available key bindings + +#### Tabs + +| Id | Default | Description | +| ------------------------ | ----------------------------------------------- | ---------------------------- | +| `tabs.cycle-forward` | Ctrl+Tab | Cycle through tabs | +| `tabs.cycle-backward` | Ctrl+Shift+Tab | Cycle backwards through tabs | +| `tabs.switch-to-left` | Ctrl+PageUp | Switch tab to the left | +| `tabs.switch-to-right` | Ctrl+PageDown | Switch tab to the right | +| `tabs.switch-to-first` | Ctrl+1 | Switch tab to the 1st | +| `tabs.switch-to-second` | Ctrl+2 | Switch tab to the 2nd | +| `tabs.switch-to-third` | Ctrl+3 | Switch tab to the 3rd | +| `tabs.switch-to-fourth` | Ctrl+4 | Switch tab to the 4th | +| `tabs.switch-to-fifth` | Ctrl+5 | Switch tab to the 5th | +| `tabs.switch-to-sixth` | Ctrl+6 | Switch tab to the 6th | +| `tabs.switch-to-seventh` | Ctrl+7 | Switch tab to the 7th | +| `tabs.switch-to-eighth` | Ctrl+8 | Switch tab to the 8th | +| `tabs.switch-to-ninth` | Ctrl+9 | Switch tab to the 9th | +| `tabs.switch-to-tenth` | Ctrl+0 | Switch tab to the 10th | + +#### Misc + +| Id | Default | Description | +| ----------------- | ---------------------------- | ---------------------- | +| `file.quick-open` | Ctrl+P | Open quick open dialog | diff --git a/src/main/app/index.js b/src/main/app/index.js index 3014bce8..9bcf7f97 100644 --- a/src/main/app/index.js +++ b/src/main/app/index.js @@ -561,6 +561,11 @@ class App { // Convert map to object win.webContents.send('mt::keybindings-response', Object.fromEntries(keybindings.keys)) }) + + ipcMain.on('mt::open-keybindings-config', () => { + const { keybindings } = this._accessor + keybindings.openConfigInFileManager() + }) } } diff --git a/src/main/keyboard/keybindingsDarwin.js b/src/main/keyboard/keybindingsDarwin.js new file mode 100644 index 00000000..5111affe --- /dev/null +++ b/src/main/keyboard/keybindingsDarwin.js @@ -0,0 +1,114 @@ +// Key bindings for macOS. + +export default new Map([ + // MarkText menu + ['mt.hide', 'Command+H'], + ['mt.hide-others', 'Command+Alt+H'], + ['file.preferences', 'Command+,'], // located under MarkText menu in macOS only + + // File menu + ['file.new-file', 'Command+N'], + ['file.new-tab', 'Command+T'], + ['file.open-file', 'Command+O'], + ['file.open-folder', 'Command+Shift+O'], + ['file.save', 'Command+S'], + ['file.save-as', 'Command+Shift+S'], + ['file.move-file', ''], + ['file.rename-file', ''], + ['file.print', ''], + ['file.close-tab', 'Command+W'], + ['file.close-window', 'Command+Shift+W'], + ['file.quit', 'Command+Q'], + + // Edit menu + ['edit.undo', 'Command+Z'], + ['edit.redo', 'Command+Shift+Z'], + ['edit.cut', 'Command+X'], + ['edit.copy', 'Command+C'], + ['edit.paste', 'Command+V'], + ['edit.copy-as-markdown', 'Command+Shift+C'], + ['edit.copy-as-html', ''], + ['edit.paste-as-plaintext', 'Command+Shift+V'], + ['edit.select-all', 'Command+A'], + ['edit.duplicate', 'Command+Alt+D'], + ['edit.create-paragraph', 'Shift+Command+N'], + ['edit.delete-paragraph', 'Shift+Command+D'], + ['edit.find', 'Command+F'], + ['edit.find-next', 'Cmd+G'], + ['edit.find-previous', 'Cmd+Shift+G'], + ['edit.replace', 'Command+Alt+F'], + ['edit.find-in-folder', 'Shift+Command+F'], + ['edit.aidou', 'Command+/'], + ['edit.screenshot', 'Command+Alt+A'], // macOS only + + // Paragraph menu + ['paragraph.heading-1', 'Command+1'], + ['paragraph.heading-2', 'Command+2'], + ['paragraph.heading-3', 'Command+3'], + ['paragraph.heading-4', 'Command+4'], + ['paragraph.heading-5', 'Command+5'], + ['paragraph.heading-6', 'Command+6'], + ['paragraph.upgrade-heading', 'Command+='], + ['paragraph.degrade-heading', 'Command+-'], + ['paragraph.table', 'Command+Shift+T'], + ['paragraph.code-fence', 'Command+Alt+C'], + ['paragraph.quote-block', 'Command+Alt+Q'], + ['paragraph.math-formula', 'Command+Alt+M'], + ['paragraph.html-block', 'Command+Alt+J'], + ['paragraph.order-list', 'Command+Alt+O'], + ['paragraph.bullet-list', 'Command+Alt+U'], + ['paragraph.task-list', 'Command+Alt+X'], + ['paragraph.loose-list-item', 'Command+Alt+L'], + ['paragraph.paragraph', 'Command+0'], + ['paragraph.horizontal-line', 'Command+Alt+-'], + ['paragraph.front-matter', 'Command+Alt+Y'], + + // Format menu + ['format.strong', 'Command+B'], + ['format.emphasis', 'Command+I'], + ['format.underline', 'Command+U'], + ['format.superscript', ''], + ['format.subscript', ''], + ['format.highlight', 'Shift+Command+H'], + ['format.inline-code', 'Command+`'], + ['format.inline-math', 'Shift+Command+M'], + ['format.strike', 'Command+D'], + ['format.hyperlink', 'Command+L'], + ['format.image', 'Command+Shift+I'], + ['format.clear-format', 'Shift+Command+R'], + + // Window menu + ['window.minimize', 'Command+M'], + ['window.toggle-always-on-top', ''], + ['window.zoom-in', ''], + ['window.zoom-out', ''], + ['window.toggle-full-screen', 'Ctrl+Command+F'], + + // View menu + ['view.command-palette', 'Command+Shift+P'], + ['view.source-code-mode', 'Command+Alt+S'], + ['view.typewriter-mode', 'Command+Alt+T'], + ['view.focus-mode', 'Command+Shift+J'], + ['view.toggle-sidebar', 'Command+J'], + ['view.toggle-toc', 'Command+K'], + ['view.toggle-tabbar', 'Command+Alt+B'], + ['view.toggle-dev-tools', 'Command+Alt+I'], + ['view.dev-reload', 'Command+R'], + + // ======== Not included in application menu ======================== + ['tabs.cycle-forward', 'Ctrl+Tab'], + ['tabs.cycle-backward', 'Ctrl+Shift+Tab'], + ['tabs.switch-to-left', 'Command+PageUp'], + ['tabs.switch-to-right', 'Command+PageDown'], + ['tabs.switch-to-first', 'Ctrl+1'], + ['tabs.switch-to-second', 'Ctrl+2'], + ['tabs.switch-to-third', 'Ctrl+3'], + ['tabs.switch-to-fourth', 'Ctrl+4'], + ['tabs.switch-to-fifth', 'Ctrl+5'], + ['tabs.switch-to-sixth', 'Ctrl+6'], + ['tabs.switch-to-seventh', 'Ctrl+7'], + ['tabs.switch-to-eighth', 'Ctrl+8'], + ['tabs.switch-to-ninth', 'Ctrl+9'], + ['tabs.switch-to-tenth', 'Ctrl+0'], + ['file.quick-open', 'Command+P'] +]) diff --git a/src/main/keyboard/keybindingsLinux.js b/src/main/keyboard/keybindingsLinux.js new file mode 100644 index 00000000..4e66b336 --- /dev/null +++ b/src/main/keyboard/keybindingsLinux.js @@ -0,0 +1,116 @@ +// Key bindings for Linux. + +// NOTE: Avoid `Ctrl+Alt` and `Alt` shortcuts on Linux because Ubuntu based OSs have reserved system shortcuts (see GH#2370). + +export default new Map([ + // MarkText menu on macOS only + ['mt.hide', ''], + ['mt.hide-others', ''], + + // File menu + ['file.new-file', 'Ctrl+N'], + ['file.new-tab', 'Ctrl+T'], + ['file.open-file', 'Ctrl+O'], + ['file.open-folder', 'Ctrl+Shift+O'], + ['file.save', 'Ctrl+S'], + ['file.save-as', 'Ctrl+Shift+S'], + ['file.move-file', ''], + ['file.rename-file', ''], + ['file.print', ''], + ['file.preferences', 'Ctrl+,'], + ['file.close-tab', 'Ctrl+W'], + ['file.close-window', 'Ctrl+Shift+W'], + ['file.quit', 'Ctrl+Q'], + + // Edit menu + ['edit.undo', 'Ctrl+Z'], + ['edit.redo', 'Ctrl+Shift+Z'], + ['edit.cut', 'Ctrl+X'], + ['edit.copy', 'Ctrl+C'], + ['edit.paste', 'Ctrl+V'], + ['edit.copy-as-markdown', 'Ctrl+Shift+C'], + ['edit.copy-as-html', ''], + ['edit.paste-as-plaintext', 'Ctrl+Shift+V'], + ['edit.select-all', 'Ctrl+A'], + ['edit.duplicate', 'Ctrl+Shift+E'], + ['edit.create-paragraph', 'Ctrl+Shift+N'], + ['edit.delete-paragraph', 'Ctrl+Shift+D'], + ['edit.find', 'Ctrl+F'], + ['edit.find-next', 'F3'], + ['edit.find-previous', 'Shift+F3'], + ['edit.replace', 'Ctrl+R'], + ['edit.find-in-folder', 'Ctrl+Shift+F'], + ['edit.aidou', 'Ctrl+/'], + ['edit.screenshot', ''], // macOS only + + // Paragraph menu + ['paragraph.heading-1', 'Ctrl+Shift+1'], + ['paragraph.heading-2', 'Ctrl+Shift+2'], + ['paragraph.heading-3', 'Ctrl+Shift+3'], + ['paragraph.heading-4', 'Ctrl+Shift+4'], + ['paragraph.heading-5', 'Ctrl+Shift+5'], + ['paragraph.heading-6', 'Ctrl+Shift+6'], + ['paragraph.upgrade-heading', 'Ctrl+='], + ['paragraph.degrade-heading', 'Ctrl+-'], + ['paragraph.table', 'Ctrl+Shift+T'], + ['paragraph.code-fence', 'Ctrl+Shift+K'], + ['paragraph.quote-block', 'Ctrl+Shift+Q'], + ['paragraph.math-formula', 'Ctrl+Alt+M'], + ['paragraph.html-block', 'Ctrl+Alt+H'], + ['paragraph.order-list', 'Ctrl+G'], + ['paragraph.bullet-list', 'Ctrl+Shift+U'], + ['paragraph.task-list', 'Ctrl+Shift+X'], + ['paragraph.loose-list-item', 'Ctrl+Shift+L'], + ['paragraph.paragraph', 'Ctrl+Shift+0'], + ['paragraph.horizontal-line', 'Ctrl+H'], + ['paragraph.front-matter', 'Ctrl+Shift+Y'], + + // Format menu + ['format.strong', 'Ctrl+B'], + ['format.emphasis', 'Ctrl+I'], + ['format.underline', 'Ctrl+U'], + ['format.superscript', ''], + ['format.subscript', ''], + ['format.highlight', 'Ctrl+Shift+H'], + ['format.inline-code', 'Ctrl+`'], + ['format.inline-math', 'Ctrl+Shift+M'], + ['format.strike', 'Ctrl+D'], + ['format.hyperlink', 'Ctrl+L'], + ['format.image', 'Ctrl+Shift+I'], + ['format.clear-format', 'Ctrl+Shift+R'], + + // Window menu + ['window.minimize', 'Ctrl+M'], + ['window.toggle-always-on-top', ''], + ['window.zoom-in', ''], + ['window.zoom-out', ''], + ['window.toggle-full-screen', 'F11'], + + // View menu + ['view.command-palette', 'Ctrl+Shift+P'], + ['view.source-code-mode', 'Ctrl+E'], + ['view.typewriter-mode', 'Ctrl+Shift+G'], + ['view.focus-mode', 'Ctrl+Shift+J'], + ['view.toggle-sidebar', 'Ctrl+J'], + ['view.toggle-toc', 'Ctrl+K'], + ['view.toggle-tabbar', 'Ctrl+Shift+B'], + ['view.toggle-dev-tools', 'Ctrl+Alt+I'], + ['view.dev-reload', 'Ctrl+F5'], + + // ======== Not included in application menu ======================== + ['tabs.cycle-forward', 'Ctrl+Tab'], + ['tabs.cycle-backward', 'Ctrl+Shift+Tab'], + ['tabs.switch-to-left', 'Ctrl+PageUp'], + ['tabs.switch-to-right', 'Ctrl+PageDown'], + ['tabs.switch-to-first', 'Ctrl+1'], + ['tabs.switch-to-second', 'Ctrl+2'], + ['tabs.switch-to-third', 'Ctrl+3'], + ['tabs.switch-to-fourth', 'Ctrl+4'], + ['tabs.switch-to-fifth', 'Ctrl+5'], + ['tabs.switch-to-sixth', 'Ctrl+6'], + ['tabs.switch-to-seventh', 'Ctrl+7'], + ['tabs.switch-to-eighth', 'Ctrl+8'], + ['tabs.switch-to-ninth', 'Ctrl+9'], + ['tabs.switch-to-tenth', 'Ctrl+0'], + ['file.quick-open', 'Ctrl+P'] +]) diff --git a/src/main/keyboard/keybindingsWindows.js b/src/main/keyboard/keybindingsWindows.js new file mode 100644 index 00000000..4ab22477 --- /dev/null +++ b/src/main/keyboard/keybindingsWindows.js @@ -0,0 +1,114 @@ +// Key bindings for Windows. + +export default new Map([ + // MarkText menu on macOS only + ['mt.hide', ''], + ['mt.hide-others', ''], + + // File menu + ['file.new-file', 'Ctrl+N'], + ['file.new-tab', 'Ctrl+T'], + ['file.open-file', 'Ctrl+O'], + ['file.open-folder', 'Ctrl+Shift+O'], + ['file.save', 'Ctrl+S'], + ['file.save-as', 'Ctrl+Shift+S'], + ['file.move-file', ''], + ['file.rename-file', ''], + ['file.print', ''], + ['file.preferences', 'Ctrl+,'], + ['file.close-tab', 'Ctrl+W'], + ['file.close-window', 'Ctrl+Shift+W'], + ['file.quit', 'Ctrl+Q'], + + // Edit menu + ['edit.undo', 'Ctrl+Z'], + ['edit.redo', 'Ctrl+Shift+Z'], + ['edit.cut', 'Ctrl+X'], + ['edit.copy', 'Ctrl+C'], + ['edit.paste', 'Ctrl+V'], + ['edit.copy-as-markdown', 'Ctrl+Shift+C'], + ['edit.copy-as-html', ''], + ['edit.paste-as-plaintext', 'Ctrl+Shift+V'], + ['edit.select-all', 'Ctrl+A'], + ['edit.duplicate', 'Ctrl+Alt+D'], + ['edit.create-paragraph', 'Ctrl+Shift+N'], + ['edit.delete-paragraph', 'Ctrl+Shift+D'], + ['edit.find', 'Ctrl+F'], + ['edit.find-next', 'F3'], + ['edit.find-previous', 'Shift+F3'], + ['edit.replace', 'Ctrl+R'], + ['edit.find-in-folder', 'Ctrl+Shift+F'], + ['edit.aidou', 'Ctrl+/'], + ['edit.screenshot', ''], // macOS only + + // Paragraph menu + ['paragraph.heading-1', 'Ctrl+Shift+1'], + ['paragraph.heading-2', 'Ctrl+Shift+2'], + ['paragraph.heading-3', 'Ctrl+Shift+3'], + ['paragraph.heading-4', 'Ctrl+Shift+4'], + ['paragraph.heading-5', 'Ctrl+Shift+5'], + ['paragraph.heading-6', 'Ctrl+Shift+6'], + ['paragraph.upgrade-heading', 'Ctrl+='], + ['paragraph.degrade-heading', 'Ctrl+-'], + ['paragraph.table', 'Ctrl+Shift+T'], + ['paragraph.code-fence', 'Ctrl+Alt+C'], + ['paragraph.quote-block', 'Ctrl+Alt+Q'], + ['paragraph.math-formula', 'Ctrl+Alt+M'], + ['paragraph.html-block', 'Ctrl+Alt+H'], + ['paragraph.order-list', 'Ctrl+Alt+O'], + ['paragraph.bullet-list', 'Ctrl+Alt+U'], + ['paragraph.task-list', 'Ctrl+Alt+X'], + ['paragraph.loose-list-item', 'Ctrl+Alt+L'], + ['paragraph.paragraph', 'Ctrl+Shift+0'], + ['paragraph.horizontal-line', 'Ctrl+Alt+-'], + ['paragraph.front-matter', 'Ctrl+Alt+Y'], + + // Format menu + ['format.strong', 'Ctrl+B'], + ['format.emphasis', 'Ctrl+I'], + ['format.underline', 'Ctrl+U'], + ['format.superscript', ''], + ['format.subscript', ''], + ['format.highlight', 'Ctrl+Shift+H'], + ['format.inline-code', 'Ctrl+`'], + ['format.inline-math', 'Ctrl+Shift+M'], + ['format.strike', 'Ctrl+D'], + ['format.hyperlink', 'Ctrl+L'], + ['format.image', 'Ctrl+Shift+I'], + ['format.clear-format', 'Ctrl+Shift+R'], + + // Window menu + ['window.minimize', 'Ctrl+M'], + ['window.toggle-always-on-top', ''], + ['window.zoom-in', ''], + ['window.zoom-out', ''], + ['window.toggle-full-screen', 'F11'], + + // View menu + ['view.command-palette', 'Ctrl+Shift+P'], + ['view.source-code-mode', 'Ctrl+E'], + ['view.typewriter-mode', 'Ctrl+Alt+T'], + ['view.focus-mode', 'Ctrl+Shift+J'], + ['view.toggle-sidebar', 'Ctrl+J'], + ['view.toggle-toc', 'Ctrl+K'], + ['view.toggle-tabbar', 'Ctrl+Shift+B'], + ['view.toggle-dev-tools', 'Ctrl+Alt+I'], + ['view.dev-reload', 'Ctrl+F5'], + + // ======== Not included in application menu ======================== + ['tabs.cycle-forward', 'Ctrl+Tab'], + ['tabs.cycle-backward', 'Ctrl+Shift+Tab'], + ['tabs.switch-to-left', 'Ctrl+PageUp'], + ['tabs.switch-to-right', 'Ctrl+PageDown'], + ['tabs.switch-to-first', 'Ctrl+1'], + ['tabs.switch-to-second', 'Ctrl+2'], + ['tabs.switch-to-third', 'Ctrl+3'], + ['tabs.switch-to-fourth', 'Ctrl+4'], + ['tabs.switch-to-fifth', 'Ctrl+5'], + ['tabs.switch-to-sixth', 'Ctrl+6'], + ['tabs.switch-to-seventh', 'Ctrl+7'], + ['tabs.switch-to-eighth', 'Ctrl+8'], + ['tabs.switch-to-ninth', 'Ctrl+9'], + ['tabs.switch-to-tenth', 'Ctrl+0'], + ['file.quick-open', 'Ctrl+P'] +]) diff --git a/src/main/keyboard/shortcutHandler.js b/src/main/keyboard/shortcutHandler.js index d4ba4a15..46c1ab4b 100644 --- a/src/main/keyboard/shortcutHandler.js +++ b/src/main/keyboard/shortcutHandler.js @@ -1,14 +1,16 @@ -import { Menu } from 'electron' +import { shell, Menu } from 'electron' import fs from 'fs' import path from 'path' import log from 'electron-log' import isAccelerator from 'electron-is-accelerator' import electronLocalshortcut from '@hfelix/electron-localshortcut' import { isFile2 } from 'common/filesystem' -import { isOsx } from '../config' +import { isLinux, isOsx } from '../config' import { getKeyboardLanguage, getVirtualLetters } from '../keyboard' +import keybindingsDarwin from './keybindingsDarwin' +import keybindingsLinux from './keybindingsLinux' +import keybindingsWindows from './keybindingsWindows' -const tabSwitchBaseStroke = (isOsx) ? 'Ctrl' : 'Alt' // Problematic key bindings: // Aidou: Ctrl+/ -> dead key // Inline Code: Ctrl+` -> dead key @@ -21,109 +23,7 @@ class Keybindings { constructor (userDataPath) { this.configPath = path.join(userDataPath, 'keybindings.json') - this.keys = new Map([ - // MarkText - macOS only - ['mt.hide', 'Command+H'], - ['mt.hide-others', 'Command+Alt+H'], - - // File menu - ['file.new-file', 'CmdOrCtrl+N'], - ['file.new-tab', 'CmdOrCtrl+T'], - ['file.open-file', 'CmdOrCtrl+O'], - ['file.open-folder', 'CmdOrCtrl+Shift+O'], - ['file.save', 'CmdOrCtrl+S'], - ['file.save-as', 'CmdOrCtrl+Shift+S'], - ['file.preferences', 'CmdOrCtrl+,'], // marktext menu in macOS - ['file.close-tab', 'CmdOrCtrl+W'], - ['file.close-window', 'CmdOrCtrl+Shift+W'], - ['file.quit', 'CmdOrCtrl+Q'], - - // Edit menu - ['edit.undo', 'CmdOrCtrl+Z'], - ['edit.redo', 'CmdOrCtrl+Shift+Z'], - ['edit.cut', 'CmdOrCtrl+X'], - ['edit.copy', 'CmdOrCtrl+C'], - ['edit.paste', 'CmdOrCtrl+V'], - ['edit.copy-as-markdown', 'CmdOrCtrl+Shift+C'], - ['edit.copy-as-plaintext', 'CmdOrCtrl+Shift+V'], - ['edit.select-all', 'CmdOrCtrl+A'], - ['edit.duplicate', 'CmdOrCtrl+Alt+D'], - ['edit.create-paragraph', 'Shift+CmdOrCtrl+N'], - ['edit.delete-paragraph', 'Shift+CmdOrCtrl+D'], - ['edit.find', 'CmdOrCtrl+F'], - ['edit.find-next', isOsx ? 'Cmd+G' : 'F3'], - ['edit.find-previous', isOsx ? 'Cmd+Shift+G' : 'Shift+F3'], - ['edit.replace', 'CmdOrCtrl+Alt+F'], - ['edit.find-in-folder', 'Shift+CmdOrCtrl+F'], - ['edit.aidou', 'CmdOrCtrl+/'], - ['edit.screenshot', 'CmdOrCtrl+Alt+A'], // macOS only - - // Paragraph menu - ['paragraph.heading-1', 'CmdOrCtrl+1'], - ['paragraph.heading-2', 'CmdOrCtrl+2'], - ['paragraph.heading-3', 'CmdOrCtrl+3'], - ['paragraph.heading-4', 'CmdOrCtrl+4'], - ['paragraph.heading-5', 'CmdOrCtrl+5'], - ['paragraph.heading-6', 'CmdOrCtrl+6'], - ['paragraph.upgrade-heading', 'CmdOrCtrl+='], - ['paragraph.degrade-heading', 'CmdOrCtrl+-'], - ['paragraph.table', 'CmdOrCtrl+Shift+T'], - ['paragraph.code-fence', 'CmdOrCtrl+Alt+C'], - ['paragraph.quote-block', 'CmdOrCtrl+Alt+Q'], - ['paragraph.math-formula', 'CmdOrCtrl+Alt+M'], - ['paragraph.html-block', isOsx ? 'CmdOrCtrl+Alt+J' : 'CmdOrCtrl+Alt+H'], - ['paragraph.order-list', 'CmdOrCtrl+Alt+O'], - ['paragraph.bullet-list', 'CmdOrCtrl+Alt+U'], - ['paragraph.task-list', 'CmdOrCtrl+Alt+X'], - ['paragraph.loose-list-item', 'CmdOrCtrl+Alt+L'], - ['paragraph.paragraph', 'CmdOrCtrl+0'], - ['paragraph.horizontal-line', 'CmdOrCtrl+Alt+-'], - ['paragraph.front-matter', 'CmdOrCtrl+Alt+Y'], - - // Format menu - ['format.strong', 'CmdOrCtrl+B'], - ['format.emphasis', 'CmdOrCtrl+I'], - ['format.underline', 'CmdOrCtrl+U'], - ['format.highlight', 'Shift+CmdOrCtrl+H'], - ['format.inline-code', 'CmdOrCtrl+`'], - ['format.inline-math', 'Shift+CmdOrCtrl+M'], - ['format.strike', 'CmdOrCtrl+D'], - ['format.hyperlink', 'CmdOrCtrl+L'], - ['format.image', 'CmdOrCtrl+Shift+I'], - ['format.clear-format', 'Shift+CmdOrCtrl+R'], - - // Window menu - ['window.minimize', 'CmdOrCtrl+M'], - ['window.toggle-full-screen', isOsx ? 'Ctrl+Command+F' : 'F11'], - - // View menu - ['view.command-palette', 'CmdOrCtrl+Shift+P'], - ['view.source-code-mode', 'CmdOrCtrl+Alt+S'], - ['view.typewriter-mode', 'CmdOrCtrl+Alt+T'], - ['view.focus-mode', 'CmdOrCtrl+Shift+J'], - ['view.toggle-sidebar', 'CmdOrCtrl+J'], - ['view.toggle-toc', 'CmdOrCtrl+K'], - ['view.toggle-tabbar', 'CmdOrCtrl+Alt+B'], - ['view.toggle-dev-tools', 'CmdOrCtrl+Alt+I'], - ['view.dev-reload', 'CmdOrCtrl+R'], - - // Misc - ['tabs.cycle-forward', 'Ctrl+Tab'], - ['tabs.cycle-backward', 'Ctrl+Shift+Tab'], - ['tabs.switch-to-left', 'CmdOrCtrl+PageUp'], - ['tabs.switch-to-right', 'CmdOrCtrl+PageDown'], - ['tabs.switch-to-first', `${tabSwitchBaseStroke}+1`], - ['tabs.switch-to-second', `${tabSwitchBaseStroke}+2`], - ['tabs.switch-to-third', `${tabSwitchBaseStroke}+3`], - ['tabs.switch-to-fourth', `${tabSwitchBaseStroke}+4`], - ['tabs.switch-to-fifth', `${tabSwitchBaseStroke}+5`], - ['tabs.switch-to-sixth', `${tabSwitchBaseStroke}+6`], - ['tabs.switch-to-seventh', `${tabSwitchBaseStroke}+7`], - ['tabs.switch-to-eighth', `${tabSwitchBaseStroke}+8`], - ['tabs.switch-to-ninth', `${tabSwitchBaseStroke}+9`], - ['tabs.switch-to-tenth', `${tabSwitchBaseStroke}+0`], - ['file.quick-open', 'CmdOrCtrl+P'] - ]) + this.keys = this._getOsKeyMap() // Fix non-US keyboards this.mnemonics = new Map() @@ -168,8 +68,26 @@ class Keybindings { } } + openConfigInFileManager () { + const { configPath } = this + if (!isFile2(configPath)) { + fs.writeFileSync(configPath, '{\n\n\n}\n', 'utf-8') + } + shell.openPath(configPath) + .catch(err => console.error(err)) + } + // --- private -------------------------------- + _getOsKeyMap () { + if (isOsx) { + return keybindingsDarwin + } else if (isLinux) { + return keybindingsLinux + } + return keybindingsWindows + } + _fixLayout () { // Fix wrong virtual key mapping on non-QWERTY layouts electronLocalshortcut.updateVirtualKeys(getVirtualLetters()) @@ -219,18 +137,23 @@ class Keybindings { // Fix dead backquote key on layouts like German _fixInlineCode () { - this.keys.set('format.inline-code', 'CmdOrCtrl+Shift+B') + if (isOsx) { + this.keys.set('format.inline-code', 'Cmd+Shift+B') + } else { + this.keys.set('format.inline-code', 'Ctrl+Alt+B') + } } _loadLocalKeybindings () { if (global.MARKTEXT_SAFE_MODE || !isFile2(this.configPath)) { + console.log('Ignoring key bindings because safe mode is enabled.') return } let json try { json = JSON.parse(fs.readFileSync(this.configPath, 'utf8')) - } catch (e) { + } catch (_) { json = null } if (!json || typeof json !== 'object') { diff --git a/src/main/menu/actions/window.js b/src/main/menu/actions/window.js index bd0472ce..1dbf6531 100644 --- a/src/main/menu/actions/window.js +++ b/src/main/menu/actions/window.js @@ -5,17 +5,3 @@ export const toggleAlwaysOnTop = win => { ipcMain.emit('window-toggle-always-on-top', win) } } - -export const zoomIn = win => { - const { webContents } = win - const zoom = webContents.getZoomFactor() - // WORKAROUND: We need to set zoom on the browser window due to Electron#16018. - webContents.send('mt::window-zoom', Math.min(2.0, zoom + 0.125)) -} - -export const zoomOut = win => { - const { webContents } = win - const zoom = webContents.getZoomFactor() - // WORKAROUND: We need to set zoom on the browser window due to Electron#16018. - webContents.send('mt::window-zoom', Math.max(0.5, zoom - 0.125)) -} diff --git a/src/main/menu/templates/edit.js b/src/main/menu/templates/edit.js index afc7c357..2550e227 100755 --- a/src/main/menu/templates/edit.js +++ b/src/main/menu/templates/edit.js @@ -41,12 +41,13 @@ export default function (keybindings, userPreference) { } }, { label: 'Copy as HTML', + accelerator: keybindings.getAccelerator('edit.copy-as-html'), click (menuItem, browserWindow) { actions.edit(browserWindow, 'copyAsHtml') } }, { label: 'Paste as Plain Text', - accelerator: keybindings.getAccelerator('edit.copy-as-plaintext'), + accelerator: keybindings.getAccelerator('edit.paste-as-plaintext'), click (menuItem, browserWindow) { actions.edit(browserWindow, 'pasteAsPlainText') } diff --git a/src/main/menu/templates/file.js b/src/main/menu/templates/file.js index c0c1d228..542673c8 100755 --- a/src/main/menu/templates/file.js +++ b/src/main/menu/templates/file.js @@ -103,11 +103,13 @@ export default function (keybindings, userPreference, recentlyUsedFiles) { type: 'separator' }, { label: 'Move To...', + accelerator: keybindings.getAccelerator('file.move-file'), click (menuItem, browserWindow) { actions.moveTo(browserWindow) } }, { label: 'Rename...', + accelerator: keybindings.getAccelerator('file.rename-file'), click (menuItem, browserWindow) { actions.rename(browserWindow) } diff --git a/src/main/menu/templates/format.js b/src/main/menu/templates/format.js index c7e3b280..d3d9ea80 100644 --- a/src/main/menu/templates/format.js +++ b/src/main/menu/templates/format.js @@ -34,6 +34,7 @@ export default function (keybindings) { id: 'superscriptMenuItem', label: 'Superscript', type: 'checkbox', + accelerator: keybindings.getAccelerator('format.superscript'), click (menuItem, browserWindow) { actions.format(browserWindow, 'sup') } @@ -41,6 +42,7 @@ export default function (keybindings) { id: 'subscriptMenuItem', label: 'Subscript', type: 'checkbox', + accelerator: keybindings.getAccelerator('format.subscript'), click (menuItem, browserWindow) { actions.format(browserWindow, 'sub') } diff --git a/src/main/menu/templates/window.js b/src/main/menu/templates/window.js index c3a353e3..431e73ff 100755 --- a/src/main/menu/templates/window.js +++ b/src/main/menu/templates/window.js @@ -1,4 +1,5 @@ -import { toggleAlwaysOnTop, zoomIn, zoomOut } from '../actions/window' +import { toggleAlwaysOnTop } from '../actions/window' +import { zoomIn, zoomOut } from '../../windows/utils' import { isOsx } from '../../config' export default function (keybindings) { @@ -13,6 +14,7 @@ export default function (keybindings) { id: 'alwaysOnTopMenuItem', label: 'Always on Top', type: 'checkbox', + accelerator: keybindings.getAccelerator('window.toggle-always-on-top'), click (menuItem, browserWindow) { toggleAlwaysOnTop(browserWindow) } @@ -20,11 +22,13 @@ export default function (keybindings) { type: 'separator' }, { label: 'Zoom In', + accelerator: keybindings.getAccelerator('window.zoom-in'), click (menuItem, browserWindow) { zoomIn(browserWindow) } }, { label: 'Zoom Out', + accelerator: keybindings.getAccelerator('window.zoom-out'), click (menuItem, browserWindow) { zoomOut(browserWindow) } diff --git a/src/main/windows/editor.js b/src/main/windows/editor.js index 27de4b76..5745d8a6 100644 --- a/src/main/windows/editor.js +++ b/src/main/windows/editor.js @@ -5,7 +5,7 @@ import log from 'electron-log' import windowStateKeeper from 'electron-window-state' import { isChildOfDirectory, isSamePathSync } from 'common/filesystem/paths' import BaseWindow, { WindowLifecycle, WindowType } from './base' -import { ensureWindowPosition } from './utils' +import { ensureWindowPosition, zoomIn, zoomOut } from './utils' import { TITLE_BAR_HEIGHT, editorWinOptions, isLinux, isOsx } from '../config' import { loadMarkdownFile } from '../filesystem/markdown' @@ -96,6 +96,15 @@ class EditorWindow extends BaseWindow { this._doOpenFilesToOpen() this._markdownToOpen.length = 0 + + // Listen on default system mouse zoom event (e.g. Ctrl+MouseWheel on Linux/Windows). + win.webContents.on('zoom-changed', (event, zoomDirection) => { + if (zoomDirection === 'in') { + zoomIn(win) + } else if (zoomDirection === 'out') { + zoomOut(win) + } + }) }) win.webContents.once('did-fail-load', (event, errorCode, errorDescription) => { diff --git a/src/main/windows/utils.js b/src/main/windows/utils.js index f6a2837f..da00d4b1 100644 --- a/src/main/windows/utils.js +++ b/src/main/windows/utils.js @@ -1,6 +1,20 @@ import { screen } from 'electron' import { isLinux } from '../config' +export const zoomIn = win => { + const { webContents } = win + const zoom = webContents.getZoomFactor() + // WORKAROUND: We need to set zoom on the browser window due to Electron#16018. + webContents.send('mt::window-zoom', Math.min(2.0, zoom + 0.125)) +} + +export const zoomOut = win => { + const { webContents } = win + const zoom = webContents.getZoomFactor() + // WORKAROUND: We need to set zoom on the browser window due to Electron#16018. + webContents.send('mt::window-zoom', Math.max(0.5, zoom - 0.125)) +} + export const centerWindowOptions = options => { // "workArea" doesn't work on Linux const { bounds, workArea } = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) diff --git a/src/renderer/commands/index.js b/src/renderer/commands/index.js index 52a80f29..cf46e6a7 100644 --- a/src/renderer/commands/index.js +++ b/src/renderer/commands/index.js @@ -513,7 +513,7 @@ const commands = [ getCurrentWindow().minimize() } }, { - id: 'window.always-on-top', + id: 'window.toggle-always-on-top', description: 'Window: Always on Top', execute: async () => { ipcRenderer.send('mt::window-toggle-always-on-top') @@ -530,6 +530,7 @@ const commands = [ { id: 'file.zoom', description: 'Window: Zoom...', + shortcut: [(isOsx ? 'Cmd' : 'Ctrl'), 'Scroll'], subcommands: [{ id: 'file.zoom-0', description: '0.625', @@ -695,13 +696,13 @@ const commands = [ id: 'docs.user-guide', description: 'MarkText: End User Guide', execute: async () => { - shell.openExternal('https://github.com/marktext/marktext/blob/develop/docs/README.md') + shell.openExternal('https://github.com/marktext/marktext/blob/master/docs/README.md') } }, { id: 'docs.markdown-syntax', description: 'MarkText: Markdown Syntax Guide', execute: async () => { - shell.openExternal('https://github.com/marktext/marktext/blob/develop/docs/MARKDOWN_SYNTAX.md') + shell.openExternal('https://github.com/marktext/marktext/blob/master/docs/MARKDOWN_SYNTAX.md') } }, diff --git a/src/renderer/prefComponents/keybindings/index.vue b/src/renderer/prefComponents/keybindings/index.vue new file mode 100644 index 00000000..af5ee00a --- /dev/null +++ b/src/renderer/prefComponents/keybindings/index.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/renderer/prefComponents/sideBar/config.js b/src/renderer/prefComponents/sideBar/config.js index 65b839e3..26d462bc 100644 --- a/src/renderer/prefComponents/sideBar/config.js +++ b/src/renderer/prefComponents/sideBar/config.js @@ -43,6 +43,11 @@ export const category = [{ label: 'imageUploader', icon: ImageUploaderIcon, path: '/preference/imageUploader' +}, { + name: 'Key Bindings', + label: 'keybindings', + icon: ImageUploaderIcon, // TODO: Replace icon + path: '/preference/keybindings' }] export const searchContent = Object.keys(preferences).map(k => { diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js index 144c88fe..33c456fc 100644 --- a/src/renderer/router/index.js +++ b/src/renderer/router/index.js @@ -7,6 +7,7 @@ import SpellChecker from '@/prefComponents/spellchecker' import Theme from '@/prefComponents/theme' import Image from '@/prefComponents/image' import ImageUploader from '@/prefComponents/imageUploader' +import Keybindings from '@/prefComponents/keybindings' const routes = type => ([{ path: '/', redirect: type === 'editor' ? '/editor' : '/preference' @@ -31,6 +32,8 @@ const routes = type => ([{ path: 'image', component: Image, name: 'image' }, { path: 'imageUploader', component: ImageUploader, name: 'imageUploader' + }, { + path: 'keybindings', component: Keybindings, name: 'keybindings' }] }]) diff --git a/src/renderer/store/commandCenter.js b/src/renderer/store/commandCenter.js index ad6dede1..775e14e5 100644 --- a/src/renderer/store/commandCenter.js +++ b/src/renderer/store/commandCenter.js @@ -2,7 +2,6 @@ import { ipcRenderer } from 'electron' import log from 'electron-log' import bus from '../bus' import staticCommands, { RootCommand } from '../commands' -import { isOsx } from '@/util' const state = { rootCommand: new RootCommand(staticCommands) @@ -61,11 +60,11 @@ const executeCommand = (state, commandId) => { command.execute() } -const defaultCtrlKey = isOsx ? 'Cmd' : 'Ctrl' const normalizeAccelerator = acc => { try { return acc - .replace(/cmdorctrl|cmd|ctrl/i, defaultCtrlKey) + .replace(/cmdorctrl|cmd/i, 'Cmd') + .replace(/ctrl/i, 'Ctrl') .split('+') } catch (_) { return [acc]