pull/3249/head
Steve Ruiz 2024-04-11 16:20:06 +01:00
rodzic e28175f4e6
commit cb473d9e96
1 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -115,7 +115,7 @@ export function useEditableText(
// When the text changes, update the text value.
const handleChange = useCallback(
(e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (!isEditing) return
if (editor.getEditingShapeId() !== id) return
let text = TextHelpers.normalizeText(e.currentTarget.value)
@ -131,15 +131,15 @@ export function useEditableText(
}
// ----------------------------
editor.updateShapes<TLUnknownShape & { props: { text: string } }>([
{ id, type, props: { text } },
])
editor.updateShape<TLUnknownShape & { props: { text: string } }>({
id,
type,
props: { text },
})
},
[editor, id, type, isEditing]
[editor, id, type]
)
const isEmpty = text.trim().length === 0
useEffect(() => {
if (!isEditing) return
@ -182,11 +182,11 @@ export function useEditableText(
// This is important so that when dragging a shape using the text label,
// the shape continues to be dragged, even if the cursor is over the UI.
if (!isEditing) {
if (editor.getEditingShapeId() !== id) {
setPointerCapture(e.currentTarget, e)
}
},
[editor, id, isEditing]
[editor, id]
)
const handleDoubleClick = stopEventPropagation
@ -200,7 +200,7 @@ export function useEditableText(
handleChange,
handleInputPointerDown,
handleDoubleClick,
isEmpty,
isEmpty: text.trim().length === 0,
isEditingAnything,
}
}