ultisuite-client/lib/drive/extensions/docs-graphic-keyboard.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

32 lines
938 B
TypeScript

import { Extension } from "@tiptap/core"
import { Plugin, PluginKey } from "@tiptap/pm/state"
import { runGraphicKeyboardAction } from "@/lib/drive/docs-graphic-keyboard"
export const docsGraphicKeyboardKey = new PluginKey("docsGraphicKeyboard")
/**
* Keyboard control for selected graphics:
* - Arrows: move (Shift = 10px); in-flow (« Avec le texte »): ↑↓ reorder, ←→ cycle left/center/right
* - Alt+Arrows: resize (Shift = 20px)
* - [ / ]: rotate ±5° (Shift = ±15°)
* - Mod+[ / Mod+]: send backward / bring forward
*/
export const DocsGraphicKeyboard = Extension.create({
name: "docsGraphicKeyboard",
priority: 1000,
addProseMirrorPlugins() {
const editor = this.editor
return [
new Plugin({
key: docsGraphicKeyboardKey,
props: {
handleKeyDown(_view, event) {
return runGraphicKeyboardAction(editor, event)
},
},
}),
]
},
})