From 1ff04842204d09945847c6eebd4e3c279c3e8d50 Mon Sep 17 00:00:00 2001 From: kjimlau Date: Sun, 12 Sep 2021 23:40:05 +0800 Subject: [PATCH] feat: tagbook open autofocus tag searcher --- src/content-scripts/renderer/popup/tag-book/index.vue | 5 +++++ .../renderer/popup/tag-book/tag-searcher.vue | 7 +++++++ todo.md | 1 + 3 files changed, 13 insertions(+) diff --git a/src/content-scripts/renderer/popup/tag-book/index.vue b/src/content-scripts/renderer/popup/tag-book/index.vue index cda90f3..7261f0b 100644 --- a/src/content-scripts/renderer/popup/tag-book/index.vue +++ b/src/content-scripts/renderer/popup/tag-book/index.vue @@ -62,6 +62,11 @@ export default { height: `${TAG_BOOK_HEIGHT}px`, minHeight: `${TAG_BOOK_HEIGHT}px`, }); + watch(() => props.noteId, () => { + if (props.noteId) { + mitt.emit('tag-search-focus'); + } + }) watch( () => props.coor, () => { diff --git a/src/content-scripts/renderer/popup/tag-book/tag-searcher.vue b/src/content-scripts/renderer/popup/tag-book/tag-searcher.vue index b7841d5..675587e 100644 --- a/src/content-scripts/renderer/popup/tag-book/tag-searcher.vue +++ b/src/content-scripts/renderer/popup/tag-book/tag-searcher.vue @@ -2,7 +2,9 @@
@@ -33,6 +35,10 @@ export default { }); } ); + const taginput = ref(null); + mitt.on('tag-search-focus', () => { + (taginput.value as unknown as HTMLElement)?.focus(); + }) const handleEnter = () => { if (!searchText.value) return; @@ -44,6 +50,7 @@ export default { }); return { + taginput, searchText, handleEnter, }; diff --git a/todo.md b/todo.md index cd71dae..28de6cc 100644 --- a/todo.md +++ b/todo.md @@ -7,6 +7,7 @@ - [x] open link brings the note-id so can jump to note also - [x] delete the tag while deleting a note who is the only one that owns this tag - [x] searching notes +- [x] tag search auto focus - [ ] more precise rects selection rather than coor (select the real dom by text) - [ ] screenshot features - https://javascript.plainenglish.io/a-better-alternative-to-html2canvas-in-vuejs-3-e0686755d56e \ No newline at end of file