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

View File

@@ -10,7 +10,7 @@ import {
} from '@toeverything/components/board-types'; } from '@toeverything/components/board-types';
import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core'; import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; 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 { memo, useCallback, useEffect, useRef } from 'react';
import { import {
defaultTextStyle, defaultTextStyle,
@@ -135,6 +135,15 @@ export class EditorUtil extends TDShapeUtil<T, E> {
} }
}, [app, state, shape.id, editingText, editingId]); }, [app, state, shape.id, editingText, editingId]);
const onMouseDown = useCallback(
(e: MouseEvent) => {
if (e.detail === 2) {
app.setEditingText(shape.id);
}
},
[app, shape.id]
);
return ( return (
<HTMLContainer ref={ref} {...events}> <HTMLContainer ref={ref} {...events}>
<Container <Container
@@ -143,6 +152,7 @@ export class EditorUtil extends TDShapeUtil<T, E> {
onPointerDown={stopPropagation} onPointerDown={stopPropagation}
onMouseEnter={activateIfEditing} onMouseEnter={activateIfEditing}
onDragEnter={activateIfEditing} onDragEnter={activateIfEditing}
onMouseDown={onMouseDown}
> >
<MemoAffineEditor <MemoAffineEditor
workspace={workspace} workspace={workspace}