fix: 🚸 add a shortcut limit to prevent events from propagating in the wysiwyg editor

This commit is contained in:
Alexis Gousseau 2026-02-05 11:10:03 +01:00
parent ec4a92196b
commit e6f0ca3cde
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,24 @@
// * Packages
import { Extension } from "@tiptap/core";
import { Plugin } from "prosemirror-state";
export const ShortcutBoundary = Extension.create({
addProseMirrorPlugins() {
return [
new Plugin({
props: {
// Set new event on key down.
handleKeyDown(view, event) {
if (!(event.ctrlKey || event.metaKey)) return false;
// Stop the propagation event to the app.
event.stopPropagation();
// Keep @tiptap editor manage the shortcut.
return false;
},
},
}),
];
},
});

View file

@ -17,6 +17,7 @@ import TextAlign from "@tiptap/extension-text-align";
// * Components shadcn
import { Label } from "@/components/ui/label";
// * Other
import { ShortcutBoundary } from "@/back/Components/Inputs/Wysiwyg/Extensions/ShortCuts/ShortcutBoundary";
import { Link } from "@/back/Components/Inputs/Wysiwyg/Extensions/Link/Link";
import { Image } from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/Image";
import InputError from "@/back/Components/InputError";
@ -92,6 +93,7 @@ export default function SimpleWysiwyg({
link: false, // Custom link extension.
}),
// Specific extensions.
ShortcutBoundary,
TaskList,
TaskItem.configure({
nested: true,