feat(editor): implement US-EDITOR-UX with global block selection, redesigned slash menu (favorites & preview), contextual placeholders, smart paste extended, turn into and undo/redo toasts
This commit is contained in:
27
memento-note/lib/editor/turn-into-shortcut-extension.ts
Normal file
27
memento-note/lib/editor/turn-into-shortcut-extension.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Extension } from '@tiptap/core'
|
||||
|
||||
/**
|
||||
* Extension TipTap qui permet de transformer instantanément le bloc sous le curseur
|
||||
* en cyclant entre Titre 1, Titre 2, Titre 3 et Paragraphe normal via le raccourci clavier Cmd+Shift+H (ou Ctrl+Shift+H).
|
||||
*/
|
||||
export const TurnIntoShortcutExtension = Extension.create({
|
||||
name: 'turnIntoShortcut',
|
||||
|
||||
addKeyboardShortcuts() {
|
||||
return {
|
||||
'Mod-Shift-h': () => {
|
||||
const { editor } = this
|
||||
|
||||
if (editor.isActive('heading', { level: 1 })) {
|
||||
return editor.chain().focus().toggleHeading({ level: 2 }).run()
|
||||
} else if (editor.isActive('heading', { level: 2 })) {
|
||||
return editor.chain().focus().toggleHeading({ level: 3 }).run()
|
||||
} else if (editor.isActive('heading', { level: 3 })) {
|
||||
return editor.chain().focus().setParagraph().run()
|
||||
} else {
|
||||
return editor.chain().focus().toggleHeading({ level: 1 }).run()
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user