diff options
author | Max <max@nextcloud.com> | 2022-02-08 18:41:55 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-02-09 11:42:48 +0300 |
commit | 87aa0695d7bb49fb65c486de3758d48abeee7925 (patch) | |
tree | a24230284432a697487dc0df31be067c6e2afd75 /src | |
parent | 95c706d16bc64cbc612fc9fd3d134e28f0269333 (diff) |
fix: adjust keyboard shortcuts and help modal
Tiptap v2 changed some defaults for the keyboard shortcuts.
* use new default ctrl+shift+X for strike through.
Old ctrl+d is used to create bookmarks in firefox.
* Keep old ctrl+shift+1 ... ctrl+shift+6 for headings.
No reason to change as far as i can tell.
Also more consistent with lists (ctrl+shift+7/8).
* Change ordered lists to ctrl+shift+7.
New default from tiptap.
This way it comes right after the headings.
Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/EditorFactory.js | 2 | ||||
-rw-r--r-- | src/components/HelpModal.vue | 6 | ||||
-rw-r--r-- | src/nodes/Heading.js | 14 | ||||
-rw-r--r-- | src/nodes/index.js | 2 |
4 files changed, 21 insertions, 3 deletions
diff --git a/src/EditorFactory.js b/src/EditorFactory.js index 8a1601c16..55d63f2d5 100644 --- a/src/EditorFactory.js +++ b/src/EditorFactory.js @@ -22,7 +22,6 @@ import Document from '@tiptap/extension-document' import Paragraph from '@tiptap/extension-paragraph' import Text from '@tiptap/extension-text' -import Heading from '@tiptap/extension-heading' import History from '@tiptap/extension-history' import Blockquote from '@tiptap/extension-blockquote' import Placeholder from '@tiptap/extension-placeholder' @@ -37,6 +36,7 @@ import { ListItem, BulletList, TrailingNode, + Heading, } from './nodes' import { Markdown, Emoji } from './extensions' import { translate as t } from '@nextcloud/l10n' diff --git a/src/components/HelpModal.vue b/src/components/HelpModal.vue index c85edb2b5..590dccaab 100644 --- a/src/components/HelpModal.vue +++ b/src/components/HelpModal.vue @@ -47,7 +47,9 @@ <td v-if="!isMobile"> <kbd>{{ t('text', 'Ctrl') }}</kbd> + - <kbd>D</kbd> + <kbd>{{ t('text', 'Shift') }}</kbd> + + + <kbd>X</kbd> </td> </tr> <tr> @@ -123,7 +125,7 @@ + <kbd>{{ t('text', 'Shift') }}</kbd> + - <kbd>9</kbd> + <kbd>7</kbd> </td> </tr> <tr> diff --git a/src/nodes/Heading.js b/src/nodes/Heading.js new file mode 100644 index 000000000..0ec91c36f --- /dev/null +++ b/src/nodes/Heading.js @@ -0,0 +1,14 @@ +import TipTapHeading from '@tiptap/extension-heading' + +const Heading = TipTapHeading.extend({ + + addKeyboardShortcuts() { + return this.options.levels.reduce((items, level) => ({ + ...items, + [`Mod-Shift-${level}`]: () => this.editor.commands.toggleHeading({ level }), + }), {}) + }, + +}) + +export default Heading diff --git a/src/nodes/index.js b/src/nodes/index.js index ba3356992..c0ebf5aac 100644 --- a/src/nodes/index.js +++ b/src/nodes/index.js @@ -25,6 +25,7 @@ import PlainTextDocument from './PlainTextDocument' import ListItem from './ListItem' import BulletList from './BulletList' import TrailingNode from './TrailingNode' +import Heading from './Heading' export { Image, @@ -32,4 +33,5 @@ export { ListItem, BulletList, TrailingNode, + Heading, } |