mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-25 16:25:54 +02:00
Add F2 rename shortcut (#142)
Adds F2 as a keyboard shortcut for focused note and notebook rows, reusing the existing inline rename flow. Reviewed-on: https://codeberg.org/ArkHost/HelixNotes/pulls/142
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { tick } from 'svelte';
|
||||||
import {
|
import {
|
||||||
notes,
|
notes,
|
||||||
sortedNotes,
|
sortedNotes,
|
||||||
@@ -143,6 +144,7 @@
|
|||||||
let sortMenu = $state<{ x: number; y: number } | null>(null);
|
let sortMenu = $state<{ x: number; y: number } | null>(null);
|
||||||
let editingNote = $state<string | null>(null);
|
let editingNote = $state<string | null>(null);
|
||||||
let editValue = $state('');
|
let editValue = $state('');
|
||||||
|
let renameInput: HTMLInputElement | null = $state(null);
|
||||||
let movePickerNote = $state<NoteEntry | null>(null);
|
let movePickerNote = $state<NoteEntry | null>(null);
|
||||||
let tagEditNote = $state<NoteEntry | null>(null);
|
let tagEditNote = $state<NoteEntry | null>(null);
|
||||||
let tagEditTags = $state<string[]>([]);
|
let tagEditTags = $state<string[]>([]);
|
||||||
@@ -701,10 +703,13 @@
|
|||||||
contextMenu = { x, y, note };
|
contextMenu = { x, y, note };
|
||||||
}
|
}
|
||||||
|
|
||||||
function startRename(note: NoteEntry) {
|
async function startRename(note: NoteEntry) {
|
||||||
contextMenu = null;
|
contextMenu = null;
|
||||||
editingNote = note.path;
|
editingNote = note.path;
|
||||||
editValue = note.meta.title;
|
editValue = note.meta.title;
|
||||||
|
await tick();
|
||||||
|
renameInput?.focus();
|
||||||
|
renameInput?.select();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotebookPath(note: NoteEntry): string {
|
function getNotebookPath(note: NoteEntry): string {
|
||||||
@@ -1055,6 +1060,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="rename-input"
|
class="rename-input"
|
||||||
|
bind:this={renameInput}
|
||||||
bind:value={editValue}
|
bind:value={editValue}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key === 'Enter') handleRename(note);
|
if (e.key === 'Enter') handleRename(note);
|
||||||
@@ -1073,6 +1079,12 @@
|
|||||||
class:qa-drag-above={$viewMode === 'quickaccess' && qaDragOver === noteIndex && qaDragFrom !== null && qaDragHalf === 'top'}
|
class:qa-drag-above={$viewMode === 'quickaccess' && qaDragOver === noteIndex && qaDragFrom !== null && qaDragHalf === 'top'}
|
||||||
class:qa-drag-below={$viewMode === 'quickaccess' && qaDragOver === noteIndex && qaDragFrom !== null && qaDragHalf === 'bottom'}
|
class:qa-drag-below={$viewMode === 'quickaccess' && qaDragOver === noteIndex && qaDragFrom !== null && qaDragHalf === 'bottom'}
|
||||||
onclick={(e) => handleNoteClick(e, note)}
|
onclick={(e) => handleNoteClick(e, note)}
|
||||||
|
onkeydown={(e) => {
|
||||||
|
if (e.key === 'F2') {
|
||||||
|
e.preventDefault();
|
||||||
|
startRename(note);
|
||||||
|
}
|
||||||
|
}}
|
||||||
ontouchstart={(e) => { if (isMobile && !isAndroid) handleTouchStart(e, note); }}
|
ontouchstart={(e) => { if (isMobile && !isAndroid) handleTouchStart(e, note); }}
|
||||||
ontouchmove={(e) => { if (isMobile && !isAndroid) handleTouchMove(e); }}
|
ontouchmove={(e) => { if (isMobile && !isAndroid) handleTouchMove(e); }}
|
||||||
ontouchend={() => { if (isMobile && !isAndroid) handleTouchEnd(); }}
|
ontouchend={() => { if (isMobile && !isAndroid) handleTouchEnd(); }}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
let editingNotebook = $state<string | null>(null);
|
let editingNotebook = $state<string | null>(null);
|
||||||
let editValue = $state('');
|
let editValue = $state('');
|
||||||
|
let renameInput: HTMLInputElement | null = $state(null);
|
||||||
let newNotebookName = $state('');
|
let newNotebookName = $state('');
|
||||||
let showNewNotebook = $state(false);
|
let showNewNotebook = $state(false);
|
||||||
let newNotebookInput: HTMLInputElement | null = $state(null);
|
let newNotebookInput: HTMLInputElement | null = $state(null);
|
||||||
@@ -454,10 +455,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function startRename(nb: NotebookEntry) {
|
async function startRename(nb: NotebookEntry) {
|
||||||
contextMenu = null;
|
contextMenu = null;
|
||||||
editingNotebook = nb.path;
|
editingNotebook = nb.path;
|
||||||
editValue = nb.name;
|
editValue = nb.name;
|
||||||
|
await tick();
|
||||||
|
renameInput?.focus();
|
||||||
|
renameInput?.select();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSetIcon(nb: NotebookEntry) {
|
async function handleSetIcon(nb: NotebookEntry) {
|
||||||
@@ -844,6 +848,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="rename-input"
|
class="rename-input"
|
||||||
|
bind:this={renameInput}
|
||||||
bind:value={editValue}
|
bind:value={editValue}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key === 'Enter') handleRename(nb);
|
if (e.key === 'Enter') handleRename(nb);
|
||||||
@@ -862,6 +867,12 @@
|
|||||||
style="padding-left: {8 + depth * 16}px"
|
style="padding-left: {8 + depth * 16}px"
|
||||||
draggable="true"
|
draggable="true"
|
||||||
onclick={() => selectNotebook(nb)}
|
onclick={() => selectNotebook(nb)}
|
||||||
|
onkeydown={(e) => {
|
||||||
|
if (e.key === 'F2') {
|
||||||
|
e.preventDefault();
|
||||||
|
startRename(nb);
|
||||||
|
}
|
||||||
|
}}
|
||||||
oncontextmenu={(e) => onContextMenu(e, nb)}
|
oncontextmenu={(e) => onContextMenu(e, nb)}
|
||||||
ondragstart={(e) => { draggedNotebookPath = nb.path; e.dataTransfer!.setData('text/plain', nb.path); e.dataTransfer!.effectAllowed = 'move'; }}
|
ondragstart={(e) => { draggedNotebookPath = nb.path; e.dataTransfer!.setData('text/plain', nb.path); e.dataTransfer!.effectAllowed = 'move'; }}
|
||||||
ondragend={() => { draggedNotebookPath = null; dropPosition = null; }}
|
ondragend={() => { draggedNotebookPath = null; dropPosition = null; }}
|
||||||
|
|||||||
Reference in New Issue
Block a user