Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(jump_to_note): extract CSS into own file
Elian Doranf307ad7fe08a
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex d6595af061..fcff2695fa 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -2024,103 +2024,6 @@ textarea {font-size: 1em;}-.jump-to-note-dialog .modal-dialog {- max-width: 900px;- width: 90%;-}--.jump-to-note-dialog .modal-header {- align-items: center;-}--.jump-to-note-dialog .modal-body {- padding: 0;- min-height: 200px;-}--.jump-to-note-results .aa-dropdown-menu {- max-height: calc(80vh - 200px);- width: 100%;- max-width: none;- overflow-y: auto;- overflow-x: hidden;- text-overflow: ellipsis;- box-shadow: none;-}--.jump-to-note-results {- width: 100%;-}--.jump-to-note-results .aa-suggestions {- padding: 0;- width: 100%;-}--/* Command palette styling */-.jump-to-note-dialog .command-suggestion {- display: flex;- align-items: center;- gap: 0.75rem;- font-size: 0.9em;-}--.jump-to-note-dialog .aa-suggestion .command-suggestion,-.jump-to-note-dialog .aa-suggestion .command-suggestion div {- padding: 0;-}--.jump-to-note-dialog .aa-cursor .command-suggestion,-.jump-to-note-dialog .aa-suggestion:hover .command-suggestion {- background-color: transparent;-}--.jump-to-note-dialog .show-in-full-search,-.jump-to-note-results .show-in-full-search {- border-top: 1px solid var(--main-border-color);- padding-top: 12px;- margin-top: 12px;-}--.jump-to-note-results .aa-suggestion .search-notes-action {- border-top: 1px solid var(--main-border-color);- margin-top: 8px;- padding-top: 8px;-}--.jump-to-note-results .aa-suggestion:has(.search-notes-action)::after {- display: none;-}--.jump-to-note-dialog .command-icon {- color: var(--muted-text-color);- font-size: 1.125rem;- flex-shrink: 0;- margin-top: 0.125rem;-}--.jump-to-note-dialog .command-content {- flex-grow: 1;- min-width: 0;-}--.jump-to-note-dialog .command-name {- font-weight: bold;-}--.jump-to-note-dialog .command-description {- font-size: 0.8em;- line-height: 1.3;- opacity: 0.75;-}--.jump-to-note-dialog kbd.command-shortcut {- background-color: transparent;- color: inherit;- opacity: 0.75;- font-family: inherit !important;-}-.empty-table-placeholder {text-align: center;color: var(--muted-text-color);diff --git a/apps/client/src/widgets/dialogs/jump_to_note.css b/apps/client/src/widgets/dialogs/jump_to_note.cssnew file mode 100644index 0000000000..80964b289f--- /dev/null+++ b/apps/client/src/widgets/dialogs/jump_to_note.css@@ -0,0 +1,96 @@+.jump-to-note-dialog .modal-dialog {+ max-width: 900px;+ width: 90%;+}++.jump-to-note-dialog .modal-header {+ align-items: center;+}++.jump-to-note-dialog .modal-body {+ padding: 0;+ min-height: 200px;+}++.jump-to-note-results .aa-dropdown-menu {+ max-height: calc(80vh - 200px);+ width: 100%;+ max-width: none;+ overflow-y: auto;+ overflow-x: hidden;+ text-overflow: ellipsis;+ box-shadow: none;+}++.jump-to-note-results {+ width: 100%;+}++.jump-to-note-results .aa-suggestions {+ padding: 0;+ width: 100%;+}++/* Command palette styling */+.jump-to-note-dialog .command-suggestion {+ display: flex;+ align-items: center;+ gap: 0.75rem;+ font-size: 0.9em;+}++.jump-to-note-dialog .aa-suggestion .command-suggestion,+.jump-to-note-dialog .aa-suggestion .command-suggestion div {+ padding: 0;+}++.jump-to-note-dialog .aa-cursor .command-suggestion,+.jump-to-note-dialog .aa-suggestion:hover .command-suggestion {+ background-color: transparent;+}++.jump-to-note-dialog .show-in-full-search,+.jump-to-note-results .show-in-full-search {+ border-top: 1px solid var(--main-border-color);+ padding-top: 12px;+ margin-top: 12px;+}++.jump-to-note-results .aa-suggestion .search-notes-action {+ border-top: 1px solid var(--main-border-color);+ margin-top: 8px;+ padding-top: 8px;+}++.jump-to-note-results .aa-suggestion:has(.search-notes-action)::after {+ display: none;+}++.jump-to-note-dialog .command-icon {+ color: var(--muted-text-color);+ font-size: 1.125rem;+ flex-shrink: 0;+ margin-top: 0.125rem;+}++.jump-to-note-dialog .command-content {+ flex-grow: 1;+ min-width: 0;+}++.jump-to-note-dialog .command-name {+ font-weight: bold;+}++.jump-to-note-dialog .command-description {+ font-size: 0.8em;+ line-height: 1.3;+ opacity: 0.75;+}++.jump-to-note-dialog kbd.command-shortcut {+ background-color: transparent;+ color: inherit;+ opacity: 0.75;+ font-family: inherit !important;+}diff --git a/apps/client/src/widgets/dialogs/jump_to_note.tsx b/apps/client/src/widgets/dialogs/jump_to_note.tsxindex 44c825e082..319fa61955 100644--- a/apps/client/src/widgets/dialogs/jump_to_note.tsx+++ b/apps/client/src/widgets/dialogs/jump_to_note.tsx@@ -1,14 +1,17 @@-import Modal from "../react/Modal";-import Button from "../react/Button";-import NoteAutocomplete from "../react/NoteAutocomplete";-import { t } from "../../services/i18n";+import "./jump_to_note.css";+import { useRef, useState } from "preact/hooks";-import note_autocomplete, { Suggestion } from "../../services/note_autocomplete";+import appContext from "../../components/app_context";import commandRegistry from "../../services/command_registry";-import { refToJQuerySelector } from "../react/react_utils";-import { useTriliumEvent } from "../react/hooks";+import { t } from "../../services/i18n";+import note_autocomplete, { Suggestion } from "../../services/note_autocomplete";import shortcutService from "../../services/shortcuts";+import Button from "../react/Button";+import { useTriliumEvent } from "../react/hooks";+import Modal from "../react/Modal";+import NoteAutocomplete from "../react/NoteAutocomplete";+import { refToJQuerySelector } from "../react/react_utils";const KEEP_LAST_SEARCH_FOR_X_SECONDS = 120;@@ -23,14 +26,14 @@ export default function JumpToNoteDialogComponent() {const [ initialText, setInitialText ] = useState(isCommandMode ? "> " : "");const actualText = useRef<string>(initialText);const [ shown, setShown ] = useState(false);-- async function openDialog(commandMode: boolean) {++ async function openDialog(commandMode: boolean) {let newMode: Mode;let initialText = "";if (commandMode) {newMode = "commands";- initialText = ">";+ initialText = ">";} else if (Date.now() - lastOpenedTs <= KEEP_LAST_SEARCH_FOR_X_SECONDS * 1000 && actualText.current) {// if you open the Jump To dialog soon after using it previously, it can often mean that you// actually want to search for the same thing (e.g., you opened the wrong note at first try)@@ -58,7 +61,7 @@ export default function JumpToNoteDialogComponent() {if (!suggestion) {return;}-+setShown(false);if (suggestion.notePath) {appContext.tabManager.getActiveContext()?.setNote(suggestion.notePath);@@ -93,7 +96,7 @@ export default function JumpToNoteDialogComponent() {} else {$autoComplete.trigger("select");}-+// Add keyboard shortcut for full searchshortcutService.bindElShortcut($autoComplete, "ctrl+return", () => {if (!isCommandMode) {@@ -101,7 +104,7 @@ export default function JumpToNoteDialogComponent() {}});}-+async function showInFullSearch() {try {setShown(false);@@ -136,18 +139,18 @@ export default function JumpToNoteDialogComponent() {setIsCommandMode(text.startsWith(">"));}}onChange={onItemSelected}- />}+ />}onShown={onShown}onHidden={() => setShown(false)}- footer={!isCommandMode && <Button- className="show-in-full-text-button"- text={t("jump_to_note.search_button")}+ footer={!isCommandMode && <Button+ className="show-in-full-text-button"+ text={t("jump_to_note.search_button")}keyboardShortcut="Ctrl+Enter"onClick={showInFullSearch}/>}show={shown}>- <div className="algolia-autocomplete-container jump-to-note-results" ref={containerRef}></div>+ <div className="algolia-autocomplete-container jump-to-note-results" ref={containerRef} /></Modal>);}