add keyboard shortcuts to the api, remove best practices section

This commit is contained in:
Hans Pagel
2020-09-24 14:46:11 +02:00
parent 3084e6e160
commit 39c39862b4
8 changed files with 79 additions and 84 deletions

View File

@@ -0,0 +1,75 @@
# Keyboard Shortcuts
Keyboard shortcuts may be strings like `Shift-Control-Enter`. Keys are based on the strings that can appear in `event.key`. There is a little tool called [keycode.info](https://keycode.info/), which shows the `event.key` interactively. Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held). You may use `Space` as an alias for the <code>&nbsp;</code> name.
Modifiers can be given in any order. `Shift-`, `Alt-`, `Control-` and `Cmd-` are recognized. For characters that are created by holding shift, the `Shift-` prefix is implied, and should not be added explicitly.
You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Control-` on other platforms.
Tiptap and all of its extensions come with predefined keyboard shortcuts.
## Essentials
| Action | Windows/Linux | macOS |
| ------------------------ | ------------- | ----- |
| Copy | ⌃C | ⌘C |
| Cut | ⌃X | ⌘X |
| Paste | ⌃V | ⌘V |
| Paste without formatting | ⌃⇧V | ⌘⇧V |
| Undo | ⌃Z | ⌘Z |
| Redo | ⌃⇧Z | ⌘⇧Z |
| Insert or edit link | ⌃K | ⌘K |
| Open link | ⌥↩ | ⌥↩ |
| Find | ⌃F | ⌘F |
| Find and replace | ⌃H | ⌘⇧H |
| Find again | ⌃G | ⌘G |
| Find previous | ⌃⇧G | ⌘⇧G |
| Repeat last action | ⌃Y | ⌘Y |
| Add a line break | ⇧↩ | ⇧↩ |
## Text Formatting
| Action | Windows/Linux | macOS |
| --------------------- | ------------- | ----- |
| Bold | ⌃B | ⌘B |
| Italicize | ⌃I | ⌘I |
| Underline | ⌃U | ⌘U |
| Strikethrough | ⌥⇧5 | ⌘⇧X |
| Superscript | ⌃. | ⌘. |
| Subscript | ⌃, | ⌘, |
| Copy text formatting | ⌃⌥C | ⌘⌥C |
| Paste text formatting | ⌃⌥V | ⌘⌥V |
| Clear text formatting | ⌃\<br>⌃Space | ⌘\ |
| Increase font size | ⌃⇧> | ⌘⇧> |
| Decrease font size | ⌃⇧< | ⌘⇧< |
## Paragraph Formatting
| Action | Windows/Linux | macOS |
| ------------------------------ | ------------- | ----- |
| Increase paragraph indentation | ⌃] | ⌘] |
| Decrease paragraph indentation | ⌃[ | ⌘[ |
| Apply normal text style | ⌃⌥0 | ⌘⌥0 |
| Apply heading style 1 | ⌃⌥1 | ⌘⌥1 |
| Apply heading style 2 | ⌃⌥2 | ⌘⌥2 |
| Apply heading style 3 | ⌃⌥3 | ⌘⌥3 |
| Apply heading style 4 | ⌃⌥4 | ⌘⌥4 |
| Apply heading style 5 | ⌃⌥5 | ⌘⌥5 |
| Apply heading style 6 | ⌃⌥6 | ⌘⌥6 |
| Left align | ⌃⇧L | ⌘⇧L |
| Center align | ⌃⇧E | ⌘⇧E |
| Right align | ⌃⇧R | ⌘⇧R |
| Justify | ⌃⇧J | ⌘⇧J |
| Numbered list | ⌃⇧7 | ⌘⇧7 |
| Bulleted list | ⌃⇧8 | ⌘⇧8 |
| Move paragraph up | ⌃⇧↑ | ⌃⇧↑ |
| Move paragraph down | ⌃⇧↓ | ⌃⇧↓ |
## Text Selection
| Action | Windows/Linux | macOS |
| ------------------------------------------------- | ------------- | ----- |
| Select all | ⌃A | ⌘A |
| Extend selection one character to left | ⇧← | ⇧← |
| Extend selection one character to right | ⇧→ | ⇧→ |
| Extend selection one line up | ⇧↑ | ⇧↑ |
| Extend selection one line down | ⇧↓ | ⇧↓ |
| Extend selection one paragraph up | ⌥⇧↑ | ⌥⇧↑ |
| Extend selection one paragraph down | ⌥⇧↓ | ⌥⇧↓ |
| Extend selection to the beginning of the document | ⌃⇧↑ | ⌘⇧↑ |
| Extend selection to the end of the document | ⌃⇧↓ | ⌘⇧↓ |

View File

@@ -1,68 +0,0 @@
# Keyboard Shortcuts
## Essentials
| Action | Google Docs |
| ------------------------ | ----------- |
| Copy | ⌘C |
| Cut | ⌘X |
| Paste | ⌘V |
| Paste without formatting | ⌘⇧V |
| Undo | ⌘Z |
| Redo | ⌘⇧Z |
| Insert or edit link | ⌘K |
| Open link | ⌥↩ |
| Find | ⌘F |
| Find and replace | ⌘⇧H |
| Find again | ⌘G |
| Find previous | ⌘⇧G |
| Repeat last action | ⌘Y |
| Add a line break | ⇧↩ |
## Text Formatting
| Action | Google Docs |
| --------------------- | ----------- |
| Bold | ⌘B |
| Italicize | ⌘I |
| Underline | ⌘U |
| Strikethrough | ⌘⇧X |
| Superscript | ⌘. |
| Subscript | ⌘, |
| Copy text formatting | ⌘⌥C |
| Paste text formatting | ⌘⌥V |
| Clear text formatting | ⌘\ |
| Increase font size | ⌘⇧> |
| Decrease font size | ⌘⇧< |
## Paragraph Formatting
| Action | Google Docs |
| ------------------------------ | ----------- |
| Increase paragraph indentation | ⌘] |
| Decrease paragraph indentation | ⌘[ |
| Apply normal text style | ⌘⌥0 |
| Apply heading style 1 | ⌘⌥1 |
| Apply heading style 2 | ⌘⌥2 |
| Apply heading style 3 | ⌘⌥3 |
| Apply heading style 4 | ⌘⌥4 |
| Apply heading style 5 | ⌘⌥5 |
| Apply heading style 6 | ⌘⌥6 |
| Left align | ⌘⇧L |
| Center align | ⌘⇧E |
| Right align | ⌘⇧R |
| Justify | ⌘⇧J |
| Numbered list | ⌘⇧7 |
| Bulleted list | ⌘⇧8 |
| Move paragraph up | ⌃⇧↑ |
| Move paragraph down | ⌃⇧↓ |
## Text Selection
| Action | Google Docs |
| ------------------------------------------------- | ----------- |
| Select all | ⌘A |
| Extend selection one character to left | ⇧← |
| Extend selection one character to right | ⇧→ |
| Extend selection one line up | ⇧↑ |
| Extend selection one line down | ⇧↓ |
| Extend selection one paragraph up | ⌥⇧↑ |
| Extend selection one paragraph down | ⌥⇧↓ |
| Extend selection to the beginning of the document | ⌘⇧↑ |
| Extend selection to the end of the document | ⌘⇧↓ |

View File

@@ -1 +0,0 @@
# Menus

View File

@@ -1 +0,0 @@
# Overview

View File

@@ -177,15 +177,5 @@
link: /api/schema/get-schema
- title: generateHtml
link: /api/schema/generate-html
- title: Best Practices
items:
- title: Overview
link: /best-practices/overview/
draft: true
- title: Menus
link: /best-practices/menus/
draft: true
- title: Keyboard Shortcuts
link: /best-practices/keyboard-shortcuts/
draft: true
link: /api/keyboard-shortcuts

View File

@@ -25,7 +25,7 @@ export default new Node()
},
}))
.keys(({ editor }) => ({
'Shift-Ctrl-8': () => editor.bulletList(),
'Shift-Control-8': () => editor.bulletList(),
}))
.inputRules(({ type }) => [
wrappingInputRule(/^\s*([-+*])\s$/, type),

View File

@@ -29,7 +29,7 @@ export default new Node()
},
}))
.keys(({ editor }) => ({
'Shift-Ctrl-\\': () => editor.codeBlock(),
'Shift-Control-\\': () => editor.codeBlock(),
}))
.inputRules(({ type }) => [
textblockTypeInputRule(/^```$/, type),

View File

@@ -38,7 +38,7 @@ export default new Node()
},
}))
.keys(({ editor }) => ({
'Shift-Ctrl-9': () => editor.orderedList(),
'Shift-Control-9': () => editor.orderedList(),
}))
.inputRules(({ type }) => [
wrappingInputRule(