Files
shadcn-ui/apps/v4/app/(create)/hooks/use-canva.tsx
shadcn 86d9b00084 chore: update deps (#9022)
* feat: init

* fix

* fix

* fix

* feat

* feat

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* feat: implement icons

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* feat: update init command

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* feat: dialog

* feat

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* feat: add registry:base item type

* feat: rename frame to canva

* fix

* feat

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fi

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* feat: add all colors

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* feat: add outfit font

* fix

* fix

* fix

* fix

* fix

* chore: changeset

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix
2025-12-12 21:01:44 +04:00

42 lines
855 B
TypeScript

"use client"
import * as React from "react"
import {
sendToIframe,
sendToParent,
useParentMessageListener,
} from "@/app/(create)/hooks/use-iframe-sync"
const MESSAGE_TYPE = "canva-zoom"
export type ZoomCommand =
| { type: "ZOOM_IN" }
| { type: "ZOOM_OUT" }
| { type: "ZOOM_SET"; value: number }
| { type: "ZOOM_FIT" }
| { type: "RESET" }
export function sendCanvaZoomCommand(
iframe: HTMLIFrameElement | null,
command: ZoomCommand
) {
sendToIframe(iframe, MESSAGE_TYPE, { command })
}
export function sendCanvaZoomUpdate(zoom: number) {
sendToParent(MESSAGE_TYPE, { zoom })
}
export function useCanvaZoomSync() {
const [zoom, setZoom] = React.useState(1)
useParentMessageListener<{ zoom: number }>(MESSAGE_TYPE, (data) => {
if (typeof data.zoom === "number") {
setZoom(data.zoom)
}
})
return zoom
}