[WEB-1067] chore: enter key entension added to editor package and issue modal description improvement (#4617)

* chore: enter key extension added to RichTextEditorWithRef editor package

* chore: enter to submit functionality added to issue and inbox issue modal description
This commit is contained in:
Anmol Singh Bhatia 2024-05-28 11:48:20 +05:30 committed by GitHub
parent a8fcaf1f48
commit 05807fe123
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 50 additions and 2 deletions

View file

@ -0,0 +1,25 @@
import { Extension } from "@tiptap/core";
export const EnterKeyExtension = (onEnterKeyPress?: () => void) =>
Extension.create({
name: "enterKey",
addKeyboardShortcuts(this) {
return {
Enter: () => {
if (onEnterKeyPress) {
onEnterKeyPress();
}
return true;
},
"Shift-Enter": ({ editor }) =>
editor.commands.first(({ commands }) => [
() => commands.newlineInCode(),
() => commands.splitListItem("listItem"),
() => commands.createParagraphNear(),
() => commands.liftEmptyBlock(),
() => commands.splitBlock(),
]),
};
},
});

View file

@ -1,13 +1,21 @@
import { UploadImage } from "@plane/editor-core";
import { DragAndDrop, SlashCommand } from "@plane/editor-extensions";
import { EnterKeyExtension } from "./enter-key-extension";
type TArguments = {
uploadFile: UploadImage;
dragDropEnabled?: boolean;
setHideDragHandle?: (hideDragHandlerFromDragDrop: () => void) => void;
onEnterKeyPress?: () => void;
};
export const RichTextEditorExtensions = ({ uploadFile, dragDropEnabled, setHideDragHandle }: TArguments) => [
export const RichTextEditorExtensions = ({
uploadFile,
dragDropEnabled,
setHideDragHandle,
onEnterKeyPress,
}: TArguments) => [
SlashCommand(uploadFile),
dragDropEnabled === true && DragAndDrop(setHideDragHandle),
EnterKeyExtension(onEnterKeyPress),
];

View file

@ -37,6 +37,7 @@ export type IRichTextEditor = {
};
placeholder?: string | ((isFocused: boolean, value: string) => string);
tabIndex?: number;
onEnterKeyPress?: (e?: any) => void;
};
const RichTextEditor = (props: IRichTextEditor) => {
@ -54,6 +55,7 @@ const RichTextEditor = (props: IRichTextEditor) => {
placeholder,
tabIndex,
mentionHandler,
onEnterKeyPress,
} = props;
const [hideDragHandleOnMouseLeave, setHideDragHandleOnMouseLeave] = React.useState<() => void>(() => {});
@ -80,6 +82,7 @@ const RichTextEditor = (props: IRichTextEditor) => {
uploadFile: fileHandler.upload,
dragDropEnabled,
setHideDragHandle: setHideDragHandleFunction,
onEnterKeyPress,
}),
tabIndex,
mentionHandler,