Skip to content

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

Fix review issues: undoable lock/visibility toggles, use degToRad

Danila Poyarkovf14f0a4259d1
diff --git a/src/components/LayerTree.vue b/src/components/LayerTree.vue
index e5dd9335d..76467341d 100644
--- a/src/components/LayerTree.vue
+++ b/src/components/LayerTree.vue
@@ -67,12 +67,12 @@ const COMPONENT_TYPES = new Set(['COMPONENT', 'COMPONENT_SET', 'INSTANCE'])
function toggleNodeVisibility(id: string) {
const node = store.graph.getNode(id)
- if (node) store.updateNode(id, { visible: !node.visible })
+ if (node) store.updateNodeWithUndo(id, { visible: !node.visible }, node.visible ? 'Hide layer' : 'Show layer')
}
function toggleNodeLock(id: string) {
const node = store.graph.getNode(id)
- if (node) store.updateNode(id, { locked: !node.locked })
+ if (node) store.updateNodeWithUndo(id, { locked: !node.locked }, node.locked ? 'Unlock layer' : 'Lock layer')
}
function buildTree(parentId: string): LayerNode[] {
diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts
index 7252fe394..8f9afb5eb 100644
--- a/src/composables/use-canvas-input.ts
+++ b/src/composables/use-canvas-input.ts
@@ -10,7 +10,7 @@ import {
DEFAULT_TEXT_WIDTH,
DEFAULT_TEXT_HEIGHT
} from '@/constants'
-import { computeSelectionBounds, computeSnap } from '@open-pencil/core'
+import { computeSelectionBounds, computeSnap, degToRad } from '@open-pencil/core'
import type { EditorStore, Tool } from '@/stores/editor'
import type { NodeType, Rect, SceneNode, Vector } from '@open-pencil/core'
@@ -303,7 +303,7 @@ export function useCanvasInput(
if (node.rotation !== 0) {
const hw = node.width / 2
const hh = node.height / 2
- const rad = (-node.rotation * Math.PI) / 180
+ const rad = degToRad(-node.rotation)
const cos = Math.cos(rad)
const sin = Math.sin(rad)
const rx = dx - hw