There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat: support esc shortcut on input-edit (#6143)
Fangdun Tsai636fa503b84f
diff --git a/packages/frontend/component/src/ui/editable/inline-edit.tsx b/packages/frontend/component/src/ui/editable/inline-edit.tsxindex 07e0de7f7e..d4a638893c 100644--- a/packages/frontend/component/src/ui/editable/inline-edit.tsx+++ b/packages/frontend/component/src/ui/editable/inline-edit.tsx@@ -1,9 +1,12 @@import clsx from 'clsx';+import type {+ CSSProperties,+ ForwardedRef,+ HTMLAttributes,+ KeyboardEvent,+ PropsWithChildren,+} from 'react';import {- type CSSProperties,- type ForwardedRef,- type HTMLAttributes,- type PropsWithChildren,useCallback,useEffect,useImperativeHandle,@@ -29,6 +32,10 @@ export interface InlineEditProps* Whether the content is editable*/editable?: boolean;+ /**+ * Whether to exit when pressing `Escape`+ */+ exitible?: boolean;onInput?: (v: string) => void;onChange?: (v: string) => void;@@ -68,6 +75,7 @@ export interface InlineEditPropsexport const InlineEdit = ({value,editable,+ exitible,className,style,trigger = 'doubleClick',@@ -127,6 +135,16 @@ export const InlineEdit = ({inputRef.current?.scrollTo(0, 0);}, [submit]);+ const onKeyDown = useCallback(+ (e: KeyboardEvent<HTMLInputElement>) => {+ e.stopPropagation();+ if (!exitible) return;+ if (e.key !== 'Escape') return;+ inputRef.current?.blur();+ },+ [exitible]+ );+const inputHandler = useCallback((v: string) => {setEditingValue(v);@@ -198,6 +216,7 @@ export const InlineEdit = ({placeholder={placeholder}onBlur={onBlur}onEnter={onEnter}+ onKeyDown={onKeyDown}onChange={inputHandler}style={inputWrapperInheritsStyles}inputStyle={inputInheritsStyles}diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsxindex 69a12ea023..fb36120617 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx+++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx@@ -43,6 +43,7 @@ export const BlocksuiteHeaderTitle = (props: BlockSuiteHeaderTitleProps) => {value={title}onChange={onChange}editable={!isPublic}+ exitible={true}placeholder="Untitled"data-testid="title-edit-button"handleRef={inputHandleRef}