mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
feat(whiteboard): activate text on dblclick
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user