AI-native design editor. Open-source Figma alternative.
Add context menu to layers panel
Danila Poyarkov90e29f13a293
diff --git a/components.d.ts b/components.d.tsindex 08622f113..dfbbd5b11 100644--- a/components.d.ts+++ b/components.d.ts@@ -82,6 +82,7 @@ declare module 'vue' {IconLucideX: typeof import('~icons/lucide/x')['default']LayersPanel: typeof import('./src/components/LayersPanel.vue')['default']LayoutSection: typeof import('./src/components/properties/LayoutSection.vue')['default']+ NodeContextMenuContent: typeof import('./src/components/NodeContextMenuContent.vue')['default']PageSection: typeof import('./src/components/properties/PageSection.vue')['default']PagesPanel: typeof import('./src/components/PagesPanel.vue')['default']PositionSection: typeof import('./src/components/properties/PositionSection.vue')['default']diff --git a/src/components/AppMenu.vue b/src/components/AppMenu.vueindex 9e30b2f01..16fa3ce62 100644--- a/src/components/AppMenu.vue+++ b/src/components/AppMenu.vue@@ -159,7 +159,8 @@ const topMenus = [v-elseclass="min-w-0 flex-1 cursor-default truncate rounded px-1 py-0.5 text-xs text-surface hover:bg-hover"@dblclick="startRename"- >{{ store.state.documentName }}</span>+ >{{ store.state.documentName }}</span+ ><buttonclass="flex size-6 shrink-0 cursor-pointer items-center justify-center rounded text-muted transition-colors hover:bg-hover hover:text-surface"title="Toggle UI (⌘\)"@@ -177,58 +178,60 @@ const topMenus = [{{ menu.label }}</MenubarTrigger>- <MenubarPortal>- <MenubarContent- :side-offset="4"- align="start"- class="min-w-52 rounded-lg border border-border bg-panel p-1 shadow-lg"- >- <template v-for="(item, i) in menu.items" :key="i">- <MenubarSeparator v-if="item.separator" class="mx-1 my-1 h-px bg-border" />- <MenubarSub v-else-if="item.sub">- <MenubarSubTrigger- class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs text-surface outline-none select-none hover:bg-hover"+ <MenubarPortal>+ <MenubarContent+ :side-offset="4"+ align="start"+ class="min-w-52 rounded-lg border border-border bg-panel p-1 shadow-lg"+ >+ <template v-for="(item, i) in menu.items" :key="i">+ <MenubarSeparator v-if="item.separator" class="mx-1 my-1 h-px bg-border" />+ <MenubarSub v-else-if="item.sub">+ <MenubarSubTrigger+ class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs text-surface outline-none select-none hover:bg-hover"+ >+ <span class="flex-1">{{ item.label }}</span>+ <IconChevronRight class="size-3 text-muted" />+ </MenubarSubTrigger>+ <MenubarPortal>+ <MenubarSubContent+ :side-offset="4"+ class="min-w-44 rounded-lg border border-border bg-panel p-1 shadow-lg"+ >+ <template v-for="(sub, j) in item.sub" :key="j">+ <MenubarSeparator v-if="sub.separator" class="mx-1 my-1 h-px bg-border" />+ <MenubarItem+ v-else+ class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none select-none"+ :class="sub.disabled ? 'text-muted/50' : 'text-surface hover:bg-hover'"+ :disabled="sub.disabled"+ @select="sub.action?.()"+ >+ <span class="flex-1">{{ sub.label }}</span>+ <span v-if="sub.shortcut" class="text-[11px] text-muted">{{+ sub.shortcut+ }}</span>+ </MenubarItem>+ </template>+ </MenubarSubContent>+ </MenubarPortal>+ </MenubarSub>+ <MenubarItem+ v-else+ class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none select-none"+ :class="item.disabled ? 'text-muted/50' : 'text-surface hover:bg-hover'"+ :disabled="item.disabled"+ @select="item.action?.()"><span class="flex-1">{{ item.label }}</span>- <IconChevronRight class="size-3 text-muted" />- </MenubarSubTrigger>- <MenubarPortal>- <MenubarSubContent- :side-offset="4"- class="min-w-44 rounded-lg border border-border bg-panel p-1 shadow-lg"- >- <template v-for="(sub, j) in item.sub" :key="j">- <MenubarSeparator v-if="sub.separator" class="mx-1 my-1 h-px bg-border" />- <MenubarItem- v-else- class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none select-none"- :class="sub.disabled ? 'text-muted/50' : 'text-surface hover:bg-hover'"- :disabled="sub.disabled"- @select="sub.action?.()"- >- <span class="flex-1">{{ sub.label }}</span>- <span v-if="sub.shortcut" class="text-[11px] text-muted">{{- sub.shortcut- }}</span>- </MenubarItem>- </template>- </MenubarSubContent>- </MenubarPortal>- </MenubarSub>- <MenubarItem- v-else- class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none select-none"- :class="item.disabled ? 'text-muted/50' : 'text-surface hover:bg-hover'"- :disabled="item.disabled"- @select="item.action?.()"- >- <span class="flex-1">{{ item.label }}</span>- <span v-if="item.shortcut" class="text-[11px] text-muted">{{ item.shortcut }}</span>- </MenubarItem>- </template>- </MenubarContent>- </MenubarPortal>- </MenubarMenu>+ <span v-if="item.shortcut" class="text-[11px] text-muted">{{+ item.shortcut+ }}</span>+ </MenubarItem>+ </template>+ </MenubarContent>+ </MenubarPortal>+ </MenubarMenu></MenubarRoot></div></div>diff --git a/src/components/CanvasContextMenu.vue b/src/components/CanvasContextMenu.vueindex dc012cedc..354fd72d6 100644--- a/src/components/CanvasContextMenu.vue+++ b/src/components/CanvasContextMenu.vue@@ -1,68 +1,11 @@<script setup lang="ts">-import { computed } from 'vue'-import {- ContextMenuRoot,- ContextMenuTrigger,- ContextMenuContent,- ContextMenuItem,- ContextMenuSeparator,- ContextMenuSub,- ContextMenuSubTrigger,- ContextMenuSubContent,- ContextMenuPortal-} from 'reka-ui'+import { ContextMenuRoot, ContextMenuTrigger, ContextMenuPortal } from 'reka-ui'import { useEditorStore } from '@/stores/editor'+import NodeContextMenuContent from './NodeContextMenuContent.vue'const store = useEditorStore()-const hasSelection = computed(() => {- void store.state.sceneVersion- return store.state.selectedIds.size > 0-})--const singleNode = computed(() => {- void store.state.sceneVersion- if (store.state.selectedIds.size !== 1) return null- const id = [...store.state.selectedIds][0]- return store.graph.getNode(id) ?? null-})--const multiCount = computed(() => {- void store.state.sceneVersion- return store.state.selectedIds.size-})--const isInstance = computed(() => singleNode.value?.type === 'INSTANCE')-const isComponent = computed(() => singleNode.value?.type === 'COMPONENT')-const isGroup = computed(() => singleNode.value?.type === 'GROUP')--const canCreateComponentSet = computed(() => {- void store.state.sceneVersion- if (store.state.selectedIds.size < 2) return false- return [...store.state.selectedIds].every((id) => {- const n = store.graph.getNode(id)- return n?.type === 'COMPONENT'- })-})--const otherPages = computed(() => {- void store.state.sceneVersion- return store.graph.getPages().filter((p) => p.id !== store.state.currentPageId)-})--const isVisible = computed(() => {- void store.state.sceneVersion- if (!singleNode.value) return true- return singleNode.value.visible-})--const isLocked = computed(() => {- void store.state.sceneVersion- if (!singleNode.value) return false- return singleNode.value.locked-})-function onRightClick(e: MouseEvent) {const el = e.currentTarget as HTMLElementconst canvas = el.querySelector('canvas')@@ -81,13 +24,6 @@ function onRightClick(e: MouseEvent) {store.clearSelection()}}--const itemClass =- 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-surface outline-none data-[highlighted]:bg-hover data-[disabled]:cursor-default data-[disabled]:text-muted'-const componentItemClass =- 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-[#9747ff] outline-none data-[highlighted]:bg-[#9747ff]/12 data-[disabled]:cursor-default data-[disabled]:text-[#9747ff]/40'-const menuClass =- 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 shadow-[0_8px_30px_rgb(0_0_0/0.4)] animate-in fade-in zoom-in-95'</script><template>@@ -97,159 +33,7 @@ const menuClass =</ContextMenuTrigger><ContextMenuPortal>- <ContextMenuContent :class="menuClass" :side-offset="2" align="start">- <!-- Clipboard -->- <ContextMenuItem- :class="itemClass"- :disabled="!hasSelection"- @select="document.execCommand('copy')"- >- <span>Copy</span>- <span class="text-[11px] text-muted">⌘C</span>- </ContextMenuItem>- <ContextMenuItem- :class="itemClass"- :disabled="!hasSelection"- @select="document.execCommand('cut')"- >- <span>Cut</span>- <span class="text-[11px] text-muted">⌘X</span>- </ContextMenuItem>- <ContextMenuItem :class="itemClass" @select="document.execCommand('paste')">- <span>Paste here</span>- <span class="text-[11px] text-muted">⌘V</span>- </ContextMenuItem>- <ContextMenuItem- :class="itemClass"- :disabled="!hasSelection"- @select="store.duplicateSelected()"- >- <span>Duplicate</span>- <span class="text-[11px] text-muted">⌘D</span>- </ContextMenuItem>- <ContextMenuItem- :class="itemClass"- :disabled="!hasSelection"- @select="store.deleteSelected()"- >- <span>Delete</span>- <span class="text-[11px] text-muted">⌫</span>- </ContextMenuItem>-- <ContextMenuSeparator class="my-1 h-px bg-border" />-- <!-- Move to page -->- <ContextMenuSub v-if="otherPages.length > 0 && hasSelection">- <ContextMenuSubTrigger :class="itemClass">- <span>Move to page</span>- <span class="text-sm text-muted">›</span>- </ContextMenuSubTrigger>- <ContextMenuPortal>- <ContextMenuSubContent :class="menuClass">- <ContextMenuItem- v-for="page in otherPages"- :key="page.id"- :class="itemClass"- @select="store.moveToPage(page.id)"- >- {{ page.name }}- </ContextMenuItem>- </ContextMenuSubContent>- </ContextMenuPortal>- </ContextMenuSub>-- <!-- Z-order -->- <ContextMenuItem- :class="itemClass"- :disabled="!hasSelection"- @select="store.bringToFront()"- >- <span>Bring to front</span>- <span class="text-[11px] text-muted">]</span>- </ContextMenuItem>- <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.sendToBack()">- <span>Send to back</span>- <span class="text-[11px] text-muted">[</span>- </ContextMenuItem>-- <ContextMenuSeparator class="my-1 h-px bg-border" />-- <!-- Grouping -->- <ContextMenuItem- :class="itemClass"- :disabled="multiCount < 2"- @select="store.groupSelected()"- >- <span>Group</span>- <span class="text-[11px] text-muted">⌘G</span>- </ContextMenuItem>- <ContextMenuItem v-if="isGroup" :class="itemClass" @select="store.ungroupSelected()">- <span>Ungroup</span>- <span class="text-[11px] text-muted">⇧⌘G</span>- </ContextMenuItem>- <ContextMenuItem v-if="hasSelection" :class="itemClass" @select="store.wrapInAutoLayout()">- <span>Add auto layout</span>- <span class="text-[11px] text-muted">⇧A</span>- </ContextMenuItem>-- <ContextMenuSeparator class="my-1 h-px bg-border" />-- <!-- Components -->- <ContextMenuItem- :class="componentItemClass"- :disabled="!hasSelection"- @select="store.createComponentFromSelection()"- >- <span>Create component</span>- <span class="text-[11px] text-[#9747ff]/60">⌥⌘K</span>- </ContextMenuItem>- <ContextMenuItem- v-if="canCreateComponentSet"- :class="componentItemClass"- @select="store.createComponentSetFromComponents()"- >- <span>Create component set</span>- <span class="text-[11px] text-[#9747ff]/60">⇧⌘K</span>- </ContextMenuItem>- <ContextMenuItem- v-if="isComponent"- :class="componentItemClass"- @select="store.createInstanceFromComponent(singleNode!.id)"- >- <span>Create instance</span>- </ContextMenuItem>- <ContextMenuItem- v-if="isInstance"- :class="componentItemClass"- @select="store.goToMainComponent()"- >- <span>Go to main component</span>- </ContextMenuItem>- <ContextMenuItem v-if="isInstance" :class="itemClass" @select="store.detachInstance()">- <span>Detach instance</span>- <span class="text-[11px] text-muted">⌥⌘B</span>- </ContextMenuItem>-- <template v-if="hasSelection">- <ContextMenuSeparator class="my-1 h-px bg-border" />-- <ContextMenuItem :class="itemClass" @select="store.toggleVisibility()">- <span>{{ isVisible ? 'Hide' : 'Show' }}</span>- <span class="text-[11px] text-muted">⇧⌘H</span>- </ContextMenuItem>- <ContextMenuItem :class="itemClass" @select="store.toggleLock()">- <span>{{ isLocked ? 'Unlock' : 'Lock' }}</span>- <span class="text-[11px] text-muted">⇧⌘L</span>- </ContextMenuItem>-- <ContextMenuSeparator class="my-1 h-px bg-border" />-- <ContextMenuItem :class="itemClass" @select="store.exportSelection(1, 'PNG')">- <span>Export as PNG</span>- <span class="text-[11px] text-muted">⇧⌘E</span>- </ContextMenuItem>- </template>- </ContextMenuContent>+ <NodeContextMenuContent /></ContextMenuPortal></ContextMenuRoot></template>diff --git a/src/components/LayersPanel.vue b/src/components/LayersPanel.vueindex b11e3e426..6dc8b96d2 100644--- a/src/components/LayersPanel.vue+++ b/src/components/LayersPanel.vue@@ -1,7 +1,9 @@<script setup lang="ts">import { ref, watch } from 'vue'import { useEventListener } from '@vueuse/core'-import { TreeRoot, TreeItem } from 'reka-ui'+import { TreeRoot, TreeItem, ContextMenuRoot, ContextMenuTrigger, ContextMenuPortal } from 'reka-ui'++import NodeContextMenuContent from './NodeContextMenuContent.vue'import IconCircle from '~icons/lucide/circle'import IconComponent from '~icons/lucide/diamond'@@ -80,6 +82,16 @@ function onSelect(ev: CustomEvent) {}}+function onLayerRightClick(e: MouseEvent) {+ const row = (e.target as HTMLElement).closest<HTMLElement>('[data-node-id]')+ if (!row) return+ const nodeId = row.dataset.nodeId+ if (!nodeId) return+ if (!store.state.selectedIds.has(nodeId)) {+ store.select([nodeId])+ }+}+function toggleExpand(id: string) {const idx = expanded.value.indexOf(id)if (idx >= 0) {@@ -231,67 +243,76 @@ function updateDropTarget(ev: PointerEvent) {<header class="shrink-0 px-3 py-2 text-[11px] uppercase tracking-wider text-muted">Layers</header>- <div ref="listRef" class="relative flex-1 overflow-y-auto px-1">- <TreeRoot- :key="treeKey"- v-slot="{ flattenItems }"- :items="items"- :get-key="(v: LayerNode) => v.id"- :get-children="(v: LayerNode) => v.children"- v-model:expanded="expanded"- >- <div- v-for="item in flattenItems"- :key="item._id"- :data-node-id="item.value.id"- :data-level="item.level"- >- <TreeItem v-slot="{ isExpanded }" v-bind="item.bind" as-child @select="onSelect">- <button- class="group/row flex w-full cursor-pointer items-center gap-1 rounded border-none py-1 text-left text-xs"- :class="[- store.state.selectedIds.has(item.value.id)- ? 'bg-accent text-white'- : 'bg-transparent text-surface hover:bg-hover',- dragging && dragNodeId === item.value.id ? 'opacity-30' : '',- dropIntoId === item.value.id ? 'ring-2 ring-accent ring-inset' : '',- !item.value.visible ? 'opacity-50' : ''- ]"- :style="{ paddingLeft: `${8 + (item.level - 1) * 16}px` }"- @pointerdown.prevent="onPointerDown($event, item.value.id)"+ <ContextMenuRoot :modal="false">+ <ContextMenuTrigger as-child @contextmenu="onLayerRightClick">+ <div ref="listRef" class="relative flex-1 overflow-y-auto px-1">+ <TreeRoot+ :key="treeKey"+ v-slot="{ flattenItems }"+ :items="items"+ :get-key="(v: LayerNode) => v.id"+ :get-children="(v: LayerNode) => v.children"+ v-model:expanded="expanded"+ >+ <div+ v-for="item in flattenItems"+ :key="item._id"+ :data-node-id="item.value.id"+ :data-level="item.level">- <span- v-if="item.hasChildren"- class="flex w-4 shrink-0 cursor-pointer items-center justify-center text-muted transition-transform hover:text-surface"- :class="isExpanded ? 'rotate-90' : 'rotate-0'"- @click.stop="toggleExpand(item.value.id)"- >- <icon-lucide-chevron-right class="size-3" />- </span>- <span v-else class="w-4 shrink-0" />- <component- :is="nodeIcons[item.value.type] ?? IconSquare"- class="size-3 shrink-0"- :class="- COMPONENT_TYPES.has(item.value.type) ? 'text-[#9747ff] opacity-100' : 'opacity-70'- "- />- <span class="min-w-0 flex-1 truncate">{{ item.value.name }}</span>- <icon-lucide-eye-off- v-if="!item.value.visible"- class="mr-1 size-3 shrink-0 text-muted"- />- </button>- </TreeItem>+ <TreeItem v-slot="{ isExpanded }" v-bind="item.bind" as-child @select="onSelect">+ <button+ class="group/row flex w-full cursor-pointer items-center gap-1 rounded border-none py-1 text-left text-xs"+ :class="[+ store.state.selectedIds.has(item.value.id)+ ? 'bg-accent text-white'+ : 'bg-transparent text-surface hover:bg-hover',+ dragging && dragNodeId === item.value.id ? 'opacity-30' : '',+ dropIntoId === item.value.id ? 'ring-2 ring-accent ring-inset' : '',+ !item.value.visible ? 'opacity-50' : ''+ ]"+ :style="{ paddingLeft: `${8 + (item.level - 1) * 16}px` }"+ @pointerdown.prevent="onPointerDown($event, item.value.id)"+ >+ <span+ v-if="item.hasChildren"+ class="flex w-4 shrink-0 cursor-pointer items-center justify-center text-muted transition-transform hover:text-surface"+ :class="isExpanded ? 'rotate-90' : 'rotate-0'"+ @click.stop="toggleExpand(item.value.id)"+ >+ <icon-lucide-chevron-right class="size-3" />+ </span>+ <span v-else class="w-4 shrink-0" />+ <component+ :is="nodeIcons[item.value.type] ?? IconSquare"+ class="size-3 shrink-0"+ :class="+ COMPONENT_TYPES.has(item.value.type)+ ? 'text-[#9747ff] opacity-100'+ : 'opacity-70'+ "+ />+ <span class="min-w-0 flex-1 truncate">{{ item.value.name }}</span>+ <icon-lucide-eye-off+ v-if="!item.value.visible"+ class="mr-1 size-3 shrink-0 text-muted"+ />+ </button>+ </TreeItem>+ </div>+ </TreeRoot>++ <!-- Drop indicator line -->+ <div+ v-if="dragging && indicatorY >= 0"+ class="pointer-events-none absolute right-1 left-1 h-0.5 bg-accent"+ :style="{ top: `${indicatorY}px`, marginLeft: `${indicatorDepth * 16}px` }"+ /></div>- </TreeRoot>-- <!-- Drop indicator line -->- <div- v-if="dragging && indicatorY >= 0"- class="pointer-events-none absolute right-1 left-1 h-0.5 bg-accent"- :style="{ top: `${indicatorY}px`, marginLeft: `${indicatorDepth * 16}px` }"- />- </div>+ </ContextMenuTrigger>+ <ContextMenuPortal>+ <NodeContextMenuContent />+ </ContextMenuPortal>+ </ContextMenuRoot></aside></template>diff --git a/src/components/NodeContextMenuContent.vue b/src/components/NodeContextMenuContent.vuenew file mode 100644index 000000000..5b0fa451b--- /dev/null+++ b/src/components/NodeContextMenuContent.vue@@ -0,0 +1,209 @@+<script setup lang="ts">+import { computed } from 'vue'+import {+ ContextMenuContent,+ ContextMenuItem,+ ContextMenuSeparator,+ ContextMenuSub,+ ContextMenuSubTrigger,+ ContextMenuSubContent,+ ContextMenuPortal+} from 'reka-ui'++import { useEditorStore } from '@/stores/editor'++const store = useEditorStore()++const hasSelection = computed(() => {+ void store.state.sceneVersion+ return store.state.selectedIds.size > 0+})++const singleNode = computed(() => {+ void store.state.sceneVersion+ if (store.state.selectedIds.size !== 1) return null+ const id = [...store.state.selectedIds][0]+ return store.graph.getNode(id) ?? null+})++const multiCount = computed(() => {+ void store.state.sceneVersion+ return store.state.selectedIds.size+})++const isInstance = computed(() => singleNode.value?.type === 'INSTANCE')+const isComponent = computed(() => singleNode.value?.type === 'COMPONENT')+const isGroup = computed(() => singleNode.value?.type === 'GROUP')++const canCreateComponentSet = computed(() => {+ void store.state.sceneVersion+ if (store.state.selectedIds.size < 2) return false+ return [...store.state.selectedIds].every((id) => {+ const n = store.graph.getNode(id)+ return n?.type === 'COMPONENT'+ })+})++const otherPages = computed(() => {+ void store.state.sceneVersion+ return store.graph.getPages().filter((p) => p.id !== store.state.currentPageId)+})++const isVisible = computed(() => {+ void store.state.sceneVersion+ if (!singleNode.value) return true+ return singleNode.value.visible+})++const isLocked = computed(() => {+ void store.state.sceneVersion+ if (!singleNode.value) return false+ return singleNode.value.locked+})++const itemClass =+ 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-surface outline-none data-[highlighted]:bg-hover data-[disabled]:cursor-default data-[disabled]:text-muted'+const componentItemClass =+ 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-[#9747ff] outline-none data-[highlighted]:bg-[#9747ff]/12 data-[disabled]:cursor-default data-[disabled]:text-[#9747ff]/40'+const menuClass =+ 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 shadow-[0_8px_30px_rgb(0_0_0/0.4)] animate-in fade-in zoom-in-95'+</script>++<template>+ <ContextMenuContent :class="menuClass" :side-offset="2" align="start">+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="document.execCommand('copy')"+ >+ <span>Copy</span>+ <span class="text-[11px] text-muted">⌘C</span>+ </ContextMenuItem>+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="document.execCommand('cut')"+ >+ <span>Cut</span>+ <span class="text-[11px] text-muted">⌘X</span>+ </ContextMenuItem>+ <ContextMenuItem :class="itemClass" @select="document.execCommand('paste')">+ <span>Paste here</span>+ <span class="text-[11px] text-muted">⌘V</span>+ </ContextMenuItem>+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="store.duplicateSelected()"+ >+ <span>Duplicate</span>+ <span class="text-[11px] text-muted">⌘D</span>+ </ContextMenuItem>+ <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.deleteSelected()">+ <span>Delete</span>+ <span class="text-[11px] text-muted">⌫</span>+ </ContextMenuItem>++ <ContextMenuSeparator class="my-1 h-px bg-border" />++ <ContextMenuSub v-if="otherPages.length > 0 && hasSelection">+ <ContextMenuSubTrigger :class="itemClass">+ <span>Move to page</span>+ <span class="text-sm text-muted">›</span>+ </ContextMenuSubTrigger>+ <ContextMenuPortal>+ <ContextMenuSubContent :class="menuClass">+ <ContextMenuItem+ v-for="page in otherPages"+ :key="page.id"+ :class="itemClass"+ @select="store.moveToPage(page.id)"+ >+ {{ page.name }}+ </ContextMenuItem>+ </ContextMenuSubContent>+ </ContextMenuPortal>+ </ContextMenuSub>++ <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.bringToFront()">+ <span>Bring to front</span>+ <span class="text-[11px] text-muted">]</span>+ </ContextMenuItem>+ <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.sendToBack()">+ <span>Send to back</span>+ <span class="text-[11px] text-muted">[</span>+ </ContextMenuItem>++ <ContextMenuSeparator class="my-1 h-px bg-border" />++ <ContextMenuItem :class="itemClass" :disabled="multiCount < 2" @select="store.groupSelected()">+ <span>Group</span>+ <span class="text-[11px] text-muted">⌘G</span>+ </ContextMenuItem>+ <ContextMenuItem v-if="isGroup" :class="itemClass" @select="store.ungroupSelected()">+ <span>Ungroup</span>+ <span class="text-[11px] text-muted">⇧⌘G</span>+ </ContextMenuItem>+ <ContextMenuItem v-if="hasSelection" :class="itemClass" @select="store.wrapInAutoLayout()">+ <span>Add auto layout</span>+ <span class="text-[11px] text-muted">⇧A</span>+ </ContextMenuItem>++ <ContextMenuSeparator class="my-1 h-px bg-border" />++ <ContextMenuItem+ :class="componentItemClass"+ :disabled="!hasSelection"+ @select="store.createComponentFromSelection()"+ >+ <span>Create component</span>+ <span class="text-[11px] text-[#9747ff]/60">⌥⌘K</span>+ </ContextMenuItem>+ <ContextMenuItem+ v-if="canCreateComponentSet"+ :class="componentItemClass"+ @select="store.createComponentSetFromComponents()"+ >+ <span>Create component set</span>+ <span class="text-[11px] text-[#9747ff]/60">⇧⌘K</span>+ </ContextMenuItem>+ <ContextMenuItem+ v-if="isComponent"+ :class="componentItemClass"+ @select="store.createInstanceFromComponent(singleNode!.id)"+ >+ <span>Create instance</span>+ </ContextMenuItem>+ <ContextMenuItem+ v-if="isInstance"+ :class="componentItemClass"+ @select="store.goToMainComponent()"+ >+ <span>Go to main component</span>+ </ContextMenuItem>+ <ContextMenuItem v-if="isInstance" :class="itemClass" @select="store.detachInstance()">+ <span>Detach instance</span>+ <span class="text-[11px] text-muted">⌥⌘B</span>+ </ContextMenuItem>++ <template v-if="hasSelection">+ <ContextMenuSeparator class="my-1 h-px bg-border" />++ <ContextMenuItem :class="itemClass" @select="store.toggleVisibility()">+ <span>{{ isVisible ? 'Hide' : 'Show' }}</span>+ <span class="text-[11px] text-muted">⇧⌘H</span>+ </ContextMenuItem>+ <ContextMenuItem :class="itemClass" @select="store.toggleLock()">+ <span>{{ isLocked ? 'Unlock' : 'Lock' }}</span>+ <span class="text-[11px] text-muted">⇧⌘L</span>+ </ContextMenuItem>++ <ContextMenuSeparator class="my-1 h-px bg-border" />++ <ContextMenuItem :class="itemClass" @select="store.exportSelection(1, 'PNG')">+ <span>Export as PNG</span>+ <span class="text-[11px] text-muted">⇧⌘E</span>+ </ContextMenuItem>+ </template>+ </ContextMenuContent>+</template>diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.tsindex dcd761251..0bd09c866 100644--- a/src/composables/use-canvas-input.ts+++ b/src/composables/use-canvas-input.ts@@ -1161,28 +1161,43 @@ export function useCanvasInput(// Safari macOS: trackpad pinch-to-zoom uses gesture events, not wheel+ctrlKeylet gestureStartZoom = 1- useEventListener(canvasRef, 'gesturestart' as keyof HTMLElementEventMap, (e: Event) => {- e.preventDefault()- gestureStartZoom = store.state.zoom- }, { passive: false })- useEventListener(canvasRef, 'gesturechange' as keyof HTMLElementEventMap, (e: Event) => {- e.preventDefault()- const ge = e as GestureEvent- const canvas = canvasRef.value- if (!canvas) return- const rect = canvas.getBoundingClientRect()- const sx = (ge.clientX ?? rect.width / 2) - rect.left- const sy = (ge.clientY ?? rect.height / 2) - rect.top- const newZoom = Math.max(0.02, Math.min(256, gestureStartZoom * ge.scale))- const zoomRatio = newZoom / store.state.zoom- store.state.panX = sx - (sx - store.state.panX) * zoomRatio- store.state.panY = sy - (sy - store.state.panY) * zoomRatio- store.state.zoom = newZoom- store.requestRepaint()- }, { passive: false })- useEventListener(canvasRef, 'gestureend' as keyof HTMLElementEventMap, (e: Event) => {- e.preventDefault()- }, { passive: false })+ useEventListener(+ canvasRef,+ 'gesturestart' as keyof HTMLElementEventMap,+ (e: Event) => {+ e.preventDefault()+ gestureStartZoom = store.state.zoom+ },+ { passive: false }+ )+ useEventListener(+ canvasRef,+ 'gesturechange' as keyof HTMLElementEventMap,+ (e: Event) => {+ e.preventDefault()+ const ge = e as GestureEvent+ const canvas = canvasRef.value+ if (!canvas) return+ const rect = canvas.getBoundingClientRect()+ const sx = (ge.clientX ?? rect.width / 2) - rect.left+ const sy = (ge.clientY ?? rect.height / 2) - rect.top+ const newZoom = Math.max(0.02, Math.min(256, gestureStartZoom * ge.scale))+ const zoomRatio = newZoom / store.state.zoom+ store.state.panX = sx - (sx - store.state.panX) * zoomRatio+ store.state.panY = sy - (sy - store.state.panY) * zoomRatio+ store.state.zoom = newZoom+ store.requestRepaint()+ },+ { passive: false }+ )+ useEventListener(+ canvasRef,+ 'gestureend' as keyof HTMLElementEventMap,+ (e: Event) => {+ e.preventDefault()+ },+ { passive: false }+ )return {drag,diff --git a/src/stores/editor.ts b/src/stores/editor.tsindex 2bb73f08c..1be9d9930 100644--- a/src/stores/editor.ts+++ b/src/stores/editor.ts@@ -618,7 +618,11 @@ export function createEditorStore() {if (!path) returnfilePath = pathfileHandle = null- state.documentName = path.split('/').pop()?.replace(/\.fig$/i, '') ?? 'Untitled'+ state.documentName =+ path+ .split('/')+ .pop()+ ?.replace(/\.fig$/i, '') ?? 'Untitled'await writeFile(data)return}@@ -1595,8 +1599,8 @@ export function createEditorStore() {parseFigmaClipboard(html).then((figma) => {if (figma) {const bounds = figmaNodesBounds(figma.nodes)- const viewCenterX = (-state.panX + (window.innerWidth / 2)) / state.zoom- const viewCenterY = (-state.panY + (window.innerHeight / 2)) / state.zoom+ const viewCenterX = (-state.panX + window.innerWidth / 2) / state.zoom+ const viewCenterY = (-state.panY + window.innerHeight / 2) / state.zoomconst offsetX = bounds ? viewCenterX - (bounds.x + bounds.w / 2) : 0const offsetY = bounds ? viewCenterY - (bounds.y + bounds.h / 2) : 0diff --git a/src/views/EditorView.vue b/src/views/EditorView.vueindex badbc35f3..801384510 100644--- a/src/views/EditorView.vue+++ b/src/views/EditorView.vue@@ -37,8 +37,6 @@ useEventListener({ passive: false })--const params = useUrlSearchParams('history')const showChrome = !('no-chrome' in params)if (!('test' in params)) {