feat(whiteboard): activate text on dblclick

This commit is contained in:
austaras
2022-08-17 18:56:18 +08:00
committed by Austaras
parent 879a208034
commit a528984479
@@ -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}