Skip to content

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

feat: add spacebar hold to temporarily activate Hand (pan) tool

TKmanc52f88e34c0f
diff --git a/packages/core/src/fonts.ts b/packages/core/src/fonts.ts
index 34ac729a7..5c8eaba1a 100644
--- a/packages/core/src/fonts.ts
+++ b/packages/core/src/fonts.ts
@@ -301,7 +301,7 @@ export function collectFontKeys(graph: SceneGraph, nodeIds: string[]): Array<[st
return [...fontKeys].map((k) => k.split('\0') as [string, string])
}
-let cjkFallbackFamilies: string[] = []
+const cjkFallbackFamilies: string[] = []
let cjkFallbackPromise: Promise<string[]> | null = null
function getCJKCandidates(): string[] {
diff --git a/packages/core/src/kiwi/kiwi-serialize.ts b/packages/core/src/kiwi/kiwi-serialize.ts
index f3dafdfa6..5d452aec6 100644
--- a/packages/core/src/kiwi/kiwi-serialize.ts
+++ b/packages/core/src/kiwi/kiwi-serialize.ts
@@ -2,23 +2,13 @@ export const FIG_KIWI_VERSION = 106
import { deflateSync, inflateSync } from 'fflate'
-<<<<<<< HEAD:packages/core/src/kiwi/kiwi-serialize.ts
import { getLoadedFontData, normalizeFontFamily, weightToStyle } from '../fonts'
import { encodeVectorNetworkBlob } from '../vector'
import { stringToGuid, VARIABLE_BINDING_FIELDS } from './kiwi-convert'
import type { SceneGraph, SceneNode, CharacterStyleOverride } from '../scene-graph'
-import type { Color, GUID } from '../types'
+import type { Color, GUID, Matrix } from '../types'
import type { NodeChange, Paint, VariableConsumptionEntry } from './codec'
-=======
-import { weightToStyle, getLoadedFontData, normalizeFontFamily } from './fonts'
-import { encodeVectorNetworkBlob } from './vector'
-import { stringToGuid, VARIABLE_BINDING_FIELDS } from './kiwi/kiwi-convert'
-
-import type { NodeChange, Paint, VariableConsumptionEntry } from './kiwi/codec'
-import type { SceneGraph, SceneNode, CharacterStyleOverride } from './scene-graph'
-import type { Color, GUID, Matrix } from './types'
->>>>>>> 4df3671 (fix: kiwi serialization bugs causing broken auto-layout in Figma import):packages/core/src/kiwi-serialize.ts
const fontDigestCache = new Map<string, Uint8Array>()
diff --git a/src/composables/use-keyboard.ts b/src/composables/use-keyboard.ts
index 81a256c5a..247018abd 100644
--- a/src/composables/use-keyboard.ts
+++ b/src/composables/use-keyboard.ts
@@ -94,6 +94,28 @@ export function useKeyboard() {
if (html) store.pasteFromHTML(html, cursorPos)
})
+ // Spacebar hold → temporary Hand tool (Figma-style canvas pan)
+ let toolBeforeSpace: (typeof store.state.activeTool) | null = null
+
+ useEventListener(window, 'keydown', (e: KeyboardEvent) => {
+ if (isEditing(e)) return
+ if (e.code === 'Space' && !e.metaKey && !e.ctrlKey && !e.altKey && !e.repeat) {
+ if (store.state.activeTool !== 'HAND') {
+ toolBeforeSpace = store.state.activeTool
+ store.setTool('HAND')
+ }
+ e.preventDefault()
+ }
+ })
+
+ useEventListener(window, 'keyup', (e: KeyboardEvent) => {
+ if (e.code === 'Space' && toolBeforeSpace) {
+ store.setTool(toolBeforeSpace)
+ toolBeforeSpace = null
+ e.preventDefault()
+ }
+ })
+
const keys = useMagicKeys({
passive: false,
onEventFired(e) {