diff --git a/bun.lock b/bun.lock index 8712f8446..c17fc9806 100644 --- a/bun.lock +++ b/bun.lock @@ -29,6 +29,8 @@ "motion-v": "^2.0.0", "prismjs": "^1.30.0", "reka-ui": "^2.9.0", + "tailwind-merge": "^3.5.0", + "tailwind-variants": "^3.2.2", "tailwindcss": "^4.2.1", "trystero": "^0.22.0", "valibot": "^1.2.0", @@ -2166,6 +2168,10 @@ "tabbable": ["tabbable@6.4.0", "", {}, "sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg=="], + "tailwind-merge": ["tailwind-merge@3.5.0", "", {}, "sha512-I8K9wewnVDkL1NTGoqWmVEIlUcB9gFriAEkXkfCjX5ib8ezGxtR3xD7iZIxrfArjEsH7F1CHD4RFUtxefdqV/A=="], + + "tailwind-variants": ["tailwind-variants@3.2.2", "", { "peerDependencies": { "tailwind-merge": ">=3.0.0", "tailwindcss": "*" }, "optionalPeers": ["tailwind-merge"] }, "sha512-Mi4kHeMTLvKlM98XPnK+7HoBPmf4gygdFmqQPaDivc3DpYS6aIY6KiG/PgThrGvii5YZJqRsPz0aPyhoFzmZgg=="], + "tailwindcss": ["tailwindcss@4.2.1", "", {}, "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw=="], "tapable": ["tapable@2.3.0", "", {}, "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg=="], diff --git a/package.json b/package.json index b098424bf..54156eda2 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,8 @@ "motion-v": "^2.0.0", "prismjs": "^1.30.0", "reka-ui": "^2.9.0", + "tailwind-merge": "^3.5.0", + "tailwind-variants": "^3.2.2", "tailwindcss": "^4.2.1", "trystero": "^0.22.0", "valibot": "^1.2.0", diff --git a/src/components/AppMenu.vue b/src/components/AppMenu.vue index 5e8db6aaf..86f88ed8f 100644 --- a/src/components/AppMenu.vue +++ b/src/components/AppMenu.vue @@ -16,31 +16,32 @@ import { import IconChevronRight from '~icons/lucide/chevron-right' -import { ref, nextTick } from 'vue' +import { computed, ref } from 'vue' +import { useInlineRename } from '@/composables/use-inline-rename' +import { menuContent, menuItem, menuSeparator } from '@/components/ui/menu' import { IS_TAURI } from '@/constants' import { openFileDialog } from '@/composables/use-menu' import { useEditorStore } from '@/stores/editor' const store = useEditorStore() -const editingName = ref(false) +const DOCUMENT_NAME_ID = 'document-name' +const rename = useInlineRename<'document-name'>((_id, name) => { + store.state.documentName = name +}) +const editingName = computed(() => rename.editingId.value === DOCUMENT_NAME_ID) + +function setNameInputRef(el: HTMLInputElement | null) { + if (el) void rename.focusInput(el) +} function startRename() { - editingName.value = true - nextTick(() => { - const input = document.querySelector('[data-doc-name-edit]') - input?.focus() - input?.select() - }) + rename.start(DOCUMENT_NAME_ID, store.state.documentName) } function commitRename(input: HTMLInputElement) { - const value = input.value.trim() - if (value) { - store.state.documentName = value - } - editingName.value = false + rename.commit(DOCUMENT_NAME_ID, input) } const isMac = navigator.platform.includes('Mac') @@ -177,13 +178,13 @@ const topMenus = [ OpenPencil