fix(app): wire renderer into figma api

This commit is contained in:
Danila Poyarkov 2026-05-17 18:49:35 +03:00
parent d48e3e5335
commit 5ddd0b966f
3 changed files with 11 additions and 2 deletions

View file

@ -1,2 +1,3 @@
export { canMakeBooleanSourcePath } from './boolean'
export { SkiaRenderer, type RenderOverlays, type RulerTheme } from './renderer'
export { getAbsolutePositionFull, getAbsoluteRotation, getWorldHandles } from './coordinate'

View file

@ -1,5 +1,7 @@
import { computed } from 'vue'
import { canMakeBooleanSourcePath } from '@open-pencil/core/canvas'
import { useSelectionState } from '#vue/editor/selection-state/use'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
@ -14,6 +16,11 @@ export function useSelectionCapabilities() {
const selection = useSelectionState()
const { editor, selectedIds, selectedNode, selectedCount, hasSelection } = selection
const selectedNodesCanFlatten = useSceneComputed(() => {
const nodes = editor.getSelectedNodes()
return nodes.length > 0 && nodes.every(canMakeBooleanSourcePath)
})
return {
selectedIds,
selectedNode,
@ -35,8 +42,8 @@ export function useSelectionCapabilities() {
canToggleVisibility: computed(() => hasSelection.value),
canToggleLock: computed(() => hasSelection.value),
canFlip: computed(() => hasSelection.value),
canBooleanOperation: computed(() => selectedCount.value >= 2),
canFlatten: computed(() => hasSelection.value),
canBooleanOperation: computed(() => selectedCount.value >= 2 && selectedNodesCanFlatten.value),
canFlatten: computed(() => selectedNodesCanFlatten.value),
canGoToMainComponent: computed(() => selection.isInstance.value),
canCreateInstance: computed(() => selectedNode.value?.type === 'COMPONENT'),
canMoveToPage: useSceneComputed(() => hasSelection.value && editor.graph.getPages().length > 1),

View file

@ -5,6 +5,7 @@ import { listFonts } from '@/app/editor/fonts'
export function makeFigmaFromStore(store: EditorStore): FigmaAPI {
const api = new FigmaAPI(store.graph)
api.setRenderer(store.renderer ?? null)
api.currentPage = api.wrapNode(store.state.currentPageId)
api.currentPage.selection = [...store.state.selectedIds]
.map((id) => api.getNodeById(id))