From e65db880110971f84f13d894e4a8a2d90052e830 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Fri, 11 Sep 2026 13:04:25 +0200 Subject: [PATCH] ui: hide variable debug panel, size readout, and copy button --- src/ui.tsx | 164 +---------------------------------------------------- 1 file changed, 1 insertion(+), 163 deletions(-) diff --git a/src/ui.tsx b/src/ui.tsx index 74a13b2..4b0ca92 100644 --- a/src/ui.tsx +++ b/src/ui.tsx @@ -7,8 +7,6 @@ import { IconButton, IconExpand24, IconCollapse24, - IconCheck24, - IconCopySmall24, IconDockToSide24 } from '@create-figma-plugin/ui' import { emit, on } from '@create-figma-plugin/utilities' @@ -20,34 +18,6 @@ const MIN_WINDOW_SIZE = { width: 320, height: 200 } // and the upper bound of drag-resize also comes from there. useWindowResize max is set // very high — actual clamp is done by main via clampWindowSize (bounds*zoom). -// One debug output row: variable name from code (as in main.ts), -// optional — calculation formula, optional — value substitution into the formula, -// and the value itself (monospace, right-aligned). -function Field (props: { name: string; formula?: string; subst?: string; value: string | number }) { - return ( -
- {props.name} - {props.value} - {props.formula != null && ( - {props.formula} - )} - {props.subst != null && ( - {props.subst} - )} -
- ) -} - -// Section card: title + list of Fields. -function Section (props: { title: string; children: preact.ComponentChildren }) { - return ( -
- {props.title} -
{props.children}
-
- ) -} - function Plugin () { const [currentWindowSize, setCurrentWindowSize] = useState(MIN_WINDOW_SIZE) const resizeRef = useRef({ active: false, dir: '', startX: 0, startY: 0, startW: 0, startH: 0, fixedAxis: 'none' as 'none' | 'x' | 'y' }) @@ -65,7 +35,6 @@ function Plugin () { relX: number; relY: number center: { x: number; y: number } } | null>(null) - const [copied, setCopied] = useState(false) // Custom resize over the WHOLE perimeter (8 handles: 4 edges + 4 corners). // Left/top edges move the window (main moves via reposition), right/bottom — resize only. @@ -205,75 +174,6 @@ function Plugin () { }) } - // Copies all debug values (RAW + calc) to the clipboard as text. - // Important: in the Figma plugin iframe navigator.clipboard is often unavailable (or its - // promise silently rejects), so a fallback via document.execCommand('copy') is mandatory. - function copyInfo () { - if (windowInfo == null) return - const i = windowInfo - const lines = [ - '== RAW · Figma API ==', - `figma.ui.getPosition().canvasSpace.x = ${i.x}`, - `figma.ui.getPosition().canvasSpace.y = ${i.y}`, - `figma.viewport.zoom = ${i.zoom}`, - `figma.viewport.bounds = ${i.viewport.x},${i.viewport.y} · ${i.viewport.width}×${i.viewport.height}`, - `lastSize.width = ${i.width}`, - `lastSize.height = ${i.height}`, - `relX = ${i.relX} (x − bounds.x)`, - `relY = ${i.relY} (y − bounds.y)`, - '', - '== CALC · in main.ts ==', - `gapL = ${i.gapL} (x − bounds.x)`, - `gapR = ${i.gapR} (bounds.x + bounds.width − (x + w))`, - `gapT = ${i.gapT} (y − bounds.y)`, - `gapB = ${i.gapB} (bounds.y + bounds.height − (y + h))`, - `center.x = ${i.center.x} (x + w / 2)`, - `center.y = ${i.center.y} (y + h / 2)` - ] - const text = lines.join('\n') - - function markCopied () { - setCopied(true) - setTimeout(function () { setCopied(false) }, 1200) - } - - // Path 1: modern async Clipboard API (if available and worked) - if (navigator.clipboard != null && navigator.clipboard.writeText != null) { - const apiResult = navigator.clipboard.writeText(text) - if (apiResult != null && typeof apiResult.then === 'function') { - apiResult.then(function () { markCopied() }).catch(function () { - // silent — fall back - fallbackCopy(text, markCopied) - }) - return - } - } - // Path 2: synchronous fallback for iframe/non-secure contexts - fallbackCopy(text, markCopied) - } - - // Fallback copy via a temp