diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/ShortCuts/ShortcutBoundary.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/ShortCuts/ShortcutBoundary.tsx new file mode 100644 index 00000000..b737a342 --- /dev/null +++ b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/ShortCuts/ShortcutBoundary.tsx @@ -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; + }, + }, + }), + ]; + }, +}); diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx index c389e0d6..d1b84570 100644 --- a/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx +++ b/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx @@ -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,