fix(sticky): restore zoom-aware preset creation and live editing sync

This commit is contained in:
Hiren Kangad
2026-03-13 00:42:32 +05:30
parent 2d05226ddd
commit ce1cc60d67
4 changed files with 60 additions and 16 deletions
+8 -4
View File
@@ -14,7 +14,7 @@ import { DrawingSprite } from './sprites/DrawingSprite';
import type { DrawingObject } from './scene-format';
import { TextEditor } from './TextEditor';
import { clampTextFontSize } from './textLimits';
import { DEFAULT_STICKY_PRESET, STICKY_FONT_MAP, STICKY_WIDTH_MAP } from './stickyPresets';
import { DEFAULT_STICKY_PRESET, getStickyWorldMetricsForPreset } from './stickyPresets';
export enum ToolType {
SELECT = 'SELECT',
@@ -324,8 +324,10 @@ export function activateTool(
const rect = container.getBoundingClientRect();
const world = viewport.toWorld(e.clientX - rect.left, e.clientY - rect.top);
const cardW = STICKY_WIDTH_MAP[DEFAULT_STICKY_PRESET];
const cardH = 60; // auto-computed by StickySprite
const zoom = viewport.scale.x;
const presetMetrics = getStickyWorldMetricsForPreset(DEFAULT_STICKY_PRESET, zoom);
const cardW = presetMetrics.width;
const cardH = screenToWorld(60, zoom, 40, 200);
const stickyData = {
id: crypto.randomUUID(),
type: 'sticky' as const,
@@ -342,7 +344,7 @@ export function activateTool(
name: '',
visible: true,
text: '',
fontSize: STICKY_FONT_MAP[DEFAULT_STICKY_PRESET],
fontSize: presetMetrics.fontSize,
fontFamily: 'Inter, system-ui, sans-serif',
fill: '#ffd43b', // default yellow
textColor: '#1a1a1a',
@@ -374,6 +376,8 @@ export function activateTool(
}
ctx.broadcastElements?.([item.id]);
ctx.onChange();
}, (resizedItem) => {
ctx.scene.updateSpatialEntry(resizedItem);
});
ctx.textEditor!.clearText();
});