fix: address code review findings from crop/text commit
- CropOverlay: register move/up handlers dynamically on drag start (single
handler instead of 8x per-handle), remove on drag end. Override destroy()
to call _cleanup() preventing keyboard listener leaks.
- Text format toolbar: re-measure text bounds (w/h) after fontSize/fontFamily
changes, update spatial index and transform box.
- TextEditor: add clearText() method; tools.ts uses it instead of fragile
document.querySelector('textarea').
- SceneManager._updateItem: apply crop mask on remote sync for image items.
- useCanvasSetup: stop TextEditor on unmount to prevent orphaned textarea.
- Double-click zoom: use item.data dimensions instead of getBounds() (which
includes shadow offset).
This commit is contained in:
@@ -700,20 +700,33 @@ export default function Editor({ isPublicView }: EditorProps) {
|
||||
fill={textToolbar.fill}
|
||||
position={textToolbar.items.length >= 2 ? 'below' : 'above'}
|
||||
onFontSizeChange={(size) => {
|
||||
const scene = canvasRef.current?.getScene();
|
||||
for (const item of textToolbar.items) {
|
||||
(item.data as TextObject).fontSize = size;
|
||||
const s = (item.displayObject as any)?.style;
|
||||
if (s) s.fontSize = size;
|
||||
// Re-measure text bounds
|
||||
const bounds = item.displayObject.getLocalBounds();
|
||||
item.data.w = bounds.width;
|
||||
item.data.h = bounds.height;
|
||||
if (scene) scene.updateSpatialEntry(item);
|
||||
}
|
||||
selectionRef.current?.transformBox.update(textToolbar.items);
|
||||
onCanvasChange(textToolbar.items.map(i => i.id));
|
||||
updateOverlays();
|
||||
}}
|
||||
onFontFamilyChange={(family) => {
|
||||
const scene = canvasRef.current?.getScene();
|
||||
for (const item of textToolbar.items) {
|
||||
(item.data as TextObject).fontFamily = family;
|
||||
const s = (item.displayObject as any)?.style;
|
||||
if (s) s.fontFamily = family;
|
||||
const bounds = item.displayObject.getLocalBounds();
|
||||
item.data.w = bounds.width;
|
||||
item.data.h = bounds.height;
|
||||
if (scene) scene.updateSpatialEntry(item);
|
||||
}
|
||||
selectionRef.current?.transformBox.update(textToolbar.items);
|
||||
onCanvasChange(textToolbar.items.map(i => i.id));
|
||||
updateOverlays();
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user