Skip to content

AI-native design editor. Open-source Figma alternative.

fix(app): wire renderer into figma api

Danila Poyarkov5ddd0b966f42
diff --git a/packages/core/src/canvas/index.ts b/packages/core/src/canvas/index.ts
index e5da7439a..ae3bf83e7 100644
--- a/packages/core/src/canvas/index.ts
+++ b/packages/core/src/canvas/index.ts
@@ -1,2 +1,3 @@
+export { canMakeBooleanSourcePath } from './boolean'
export { SkiaRenderer, type RenderOverlays, type RulerTheme } from './renderer'
export { getAbsolutePositionFull, getAbsoluteRotation, getWorldHandles } from './coordinate'
diff --git a/packages/vue/src/editor/selection-capabilities/use.ts b/packages/vue/src/editor/selection-capabilities/use.ts
index a1e181e40..d750659d1 100644
--- a/packages/vue/src/editor/selection-capabilities/use.ts
+++ b/packages/vue/src/editor/selection-capabilities/use.ts
@@ -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),
diff --git a/src/app/automation/bridge/figma-factory.ts b/src/app/automation/bridge/figma-factory.ts
index 9df89da93..c965e1de9 100644
--- a/src/app/automation/bridge/figma-factory.ts
+++ b/src/app/automation/bridge/figma-factory.ts
@@ -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))