diff --git a/components.d.ts b/components.d.ts index b6654b790..81a14cb96 100644 --- a/components.d.ts +++ b/components.d.ts @@ -63,6 +63,7 @@ declare module 'vue' { IconLucideLink: typeof import('~icons/lucide/link')['default'] IconLucideLoaderCircle: typeof import('~icons/lucide/loader-circle')['default'] IconLucideMessageCircle: typeof import('~icons/lucide/message-circle')['default'] + IconLucidePanelLeft: typeof import('~icons/lucide/panel-left')['default'] IconLucidePlus: typeof import('~icons/lucide/plus')['default'] IconLucideRadius: typeof import('~icons/lucide/radius')['default'] IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw')['default'] @@ -71,6 +72,7 @@ declare module 'vue' { IconLucideSend: typeof import('~icons/lucide/send')['default'] IconLucideSettings2: typeof import('~icons/lucide/settings2')['default'] IconLucideShare2: typeof import('~icons/lucide/share2')['default'] + IconLucideSidebar: typeof import('~icons/lucide/sidebar')['default'] IconLucideSparkles: typeof import('~icons/lucide/sparkles')['default'] IconLucideSquare: typeof import('~icons/lucide/square')['default'] IconLucideStrikethrough: typeof import('~icons/lucide/strikethrough')['default'] diff --git a/src/components/AppMenu.vue b/src/components/AppMenu.vue index 8ccd0f2a0..9e30b2f01 100644 --- a/src/components/AppMenu.vue +++ b/src/components/AppMenu.vue @@ -14,12 +14,33 @@ import { import IconChevronRight from '~icons/lucide/chevron-right' +import { ref, nextTick } from 'vue' + import { IS_TAURI } from '@/constants' import { openFileDialog } from '@/composables/use-menu' import { useEditorStore } from '@/stores/editor' const store = useEditorStore() +const editingName = ref(false) + +function startRename() { + editingName.value = true + nextTick(() => { + const input = document.querySelector('[data-doc-name-edit]') + input?.focus() + input?.select() + }) +} + +function commitRename(input: HTMLInputElement) { + const value = input.value.trim() + if (value) { + store.state.documentName = value + } + editingName.value = false +} + const isMac = navigator.platform.includes('Mac') const mod = isMac ? '⌘' : 'Ctrl+' @@ -122,17 +143,39 @@ const topMenus = [ diff --git a/src/composables/use-keyboard.ts b/src/composables/use-keyboard.ts index b77a2ee74..75b24180f 100644 --- a/src/composables/use-keyboard.ts +++ b/src/composables/use-keyboard.ts @@ -81,6 +81,11 @@ export function useKeyboard(store: EditorStore) { } if (e.metaKey || e.ctrlKey) { + if (e.code === 'Backslash') { + e.preventDefault() + store.state.showUI = !store.state.showUI + return + } if (e.code === 'KeyJ') { e.preventDefault() activeTab.value = activeTab.value === 'ai' ? 'design' : 'ai' diff --git a/src/stores/editor.ts b/src/stores/editor.ts index 1553abf7d..594bc88d5 100644 --- a/src/stores/editor.ts +++ b/src/stores/editor.ts @@ -174,6 +174,8 @@ export function createEditorStore() { y: number selection?: string[] }>, + showUI: true, + documentName: 'Untitled' as string, panX: 0, pageColor: { ...CANVAS_BG_COLOR } as Color, panY: 0, @@ -565,6 +567,8 @@ export function createEditorStore() { pageViewports.clear() fileHandle = handle ?? null filePath = path ?? null + state.documentName = file.name.replace(/\.fig$/i, '') + downloadName = file.name state.selectedIds = new Set() const firstPage = graph.getPages()[0] state.currentPageId = firstPage?.id ?? graph.rootId @@ -613,6 +617,7 @@ export function createEditorStore() { if (!path) return filePath = path fileHandle = null + state.documentName = path.split('/').pop()?.replace(/\.fig$/i, '') ?? 'Untitled' await writeFile(data) return } @@ -630,6 +635,7 @@ export function createEditorStore() { }) fileHandle = handle filePath = null + state.documentName = handle.name.replace(/\.fig$/i, '') await writeFile(data) return } catch (e) { @@ -640,6 +646,7 @@ export function createEditorStore() { const filename = prompt('Save as:', downloadName ?? 'Untitled.fig') if (!filename) return downloadName = filename + state.documentName = filename.replace(/\.fig$/i, '') downloadBlob(new Uint8Array(data), filename, 'application/octet-stream') } diff --git a/src/views/EditorView.vue b/src/views/EditorView.vue index f8f7db6a6..ace2460a6 100644 --- a/src/views/EditorView.vue +++ b/src/views/EditorView.vue @@ -72,7 +72,7 @@ function onDisconnect() {
+
+
+ + +
+ OpenPencil + {{ store.state.documentName }} + +
+
+