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:
Antigravity
2026-05-27 21:47:50 +00:00
parent e3cb1307d3
commit ad8b8b815e
9 changed files with 1112 additions and 157 deletions

View File

@@ -0,0 +1,48 @@
import { Extension } from '@tiptap/core'
import { toast } from 'sonner'
/**
* Extension TipTap qui intercepte les commandes d'annulation (Undo) et de rétablissement (Redo)
* pour lever un toast discret (2 secondes) de confirmation, en indiquant dynamiquement le raccourci de l'action inverse selon l'OS.
*/
export const UndoRedoFeedbackExtension = Extension.create({
name: 'undoRedoFeedback',
addKeyboardShortcuts() {
const isMac = typeof window !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.userAgent)
const modKey = isMac ? '⌘' : 'Ctrl'
return {
'Mod-z': () => {
const success = this.editor.commands.undo()
if (success) {
toast.info('Action annulée', {
description: `Faites ${modKey}+Maj+Z pour rétablir.`,
duration: 2000,
})
}
return success
},
'Mod-y': () => {
const success = this.editor.commands.redo()
if (success) {
toast.info('Action rétablie', {
description: `Faites ${modKey}+Z pour annuler.`,
duration: 2000,
})
}
return success
},
'Mod-Shift-z': () => {
const success = this.editor.commands.redo()
if (success) {
toast.info('Action rétablie', {
description: `Faites ${modKey}+Z pour annuler.`,
duration: 2000,
})
}
return success
},
}
},
})