Skip to content

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.

feat(whiteboard): activate text on dblclick

austarasa5289844790a
diff --git a/libs/components/board-shapes/src/editor-util/EditorUtil.tsx b/libs/components/board-shapes/src/editor-util/EditorUtil.tsx
index 6e6f123a72..cb6e56275a 100644
--- a/libs/components/board-shapes/src/editor-util/EditorUtil.tsx
+++ b/libs/components/board-shapes/src/editor-util/EditorUtil.tsx
@@ -10,7 +10,7 @@ import {
} from '@toeverything/components/board-types';
import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui';
-import type { SyntheticEvent } from 'react';
+import type { MouseEvent, SyntheticEvent } from 'react';
import { memo, useCallback, useEffect, useRef } from 'react';
import {
defaultTextStyle,
@@ -135,6 +135,15 @@ export class EditorUtil extends TDShapeUtil<T, E> {
}
}, [app, state, shape.id, editingText, editingId]);
+ const onMouseDown = useCallback(
+ (e: MouseEvent) => {
+ if (e.detail === 2) {
+ app.setEditingText(shape.id);
+ }
+ },
+ [app, shape.id]
+ );
+
return (
<HTMLContainer ref={ref} {...events}>
<Container
@@ -143,6 +152,7 @@ export class EditorUtil extends TDShapeUtil<T, E> {
onPointerDown={stopPropagation}
onMouseEnter={activateIfEditing}
onDragEnter={activateIfEditing}
+ onMouseDown={onMouseDown}
>
<MemoAffineEditor
workspace={workspace}