mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
fix(editor): blur ContentEditor on Escape (#1338)
ESC did nothing inside the issue description editor because browsers don't blur contenteditable elements by default, leaving users stuck in the editor with no keyboard escape hatch. Add a blur-shortcut extension mirroring TitleEditor's behavior and wire it into ContentEditor's edit-mode extension set.
This commit is contained in:
20
packages/views/editor/extensions/blur-shortcut.ts
Normal file
20
packages/views/editor/extensions/blur-shortcut.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Extension } from "@tiptap/core";
|
||||
|
||||
/**
|
||||
* Escape → blur the editor. Without this, pressing ESC inside the
|
||||
* contenteditable does nothing (browsers don't blur contenteditables by
|
||||
* default), leaving users stuck in the editor with no keyboard escape hatch.
|
||||
*/
|
||||
export function createBlurShortcutExtension() {
|
||||
return Extension.create({
|
||||
name: "blurShortcut",
|
||||
addKeyboardShortcuts() {
|
||||
return {
|
||||
Escape: ({ editor }) => {
|
||||
editor.commands.blur();
|
||||
return true;
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import { createMentionSuggestion } from "./mention-suggestion";
|
||||
import { CodeBlockView } from "./code-block-view";
|
||||
import { createMarkdownPasteExtension } from "./markdown-paste";
|
||||
import { createSubmitExtension } from "./submit-shortcut";
|
||||
import { createBlurShortcutExtension } from "./blur-shortcut";
|
||||
import { createFileUploadExtension } from "./file-upload";
|
||||
import { FileCardExtension } from "./file-card";
|
||||
import { ImageView } from "./image-view";
|
||||
@@ -137,6 +138,7 @@ export function createEditorExtensions(
|
||||
},
|
||||
{ submitOnEnter: options.submitOnEnter ?? false },
|
||||
),
|
||||
createBlurShortcutExtension(),
|
||||
createFileUploadExtension(options.onUploadFileRef!),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user