@@ -82,7 +111,27 @@ export default function SearchDefinitionTab({ note }: TabContext) {
-
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
@@ -114,7 +163,21 @@ function SearchOption({ note, title, children, help, attributeName, attributeTyp
)
}
-function SearchStringOption() {
+function SearchStringOption({ note, refreshResults }: { note: FNote, refreshResults: () => void }) {
+ const currentValue = useRef("");
+ const spacedUpdate = useSpacedUpdate(async () => {
+ const searchString = currentValue.current;
+ appContext.lastSearchString = searchString;
+
+ await attributes.setAttribute(note, "label", "searchString", searchString);
+
+ if (note.title.startsWith(t("search_string.search_prefix"))) {
+ await server.put(`notes/${note.noteId}/title`, {
+ title: `${t("search_string.search_prefix")} ${searchString.length < 30 ? searchString : `${searchString.substr(0, 30)}…`}`
+ });
+ }
+ }, 1000);
+
return
@@ -133,6 +196,21 @@ function SearchStringOption() {
{
+ currentValue.current = text;
+ spacedUpdate.scheduleUpdate();
+ }}
+ onKeyDown={async (e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+
+ // this also in effect disallows new lines in query string.
+ // on one hand, this makes sense since search string is a label
+ // on the other hand, it could be nice for structuring long search string. It's probably a niche case though.
+ await spacedUpdate.updateNowIfNecessary();
+ refreshResults();
+ }
+ }}
/>
}
\ No newline at end of file
diff --git a/apps/client/src/widgets/ribbon_widgets/search_definition.ts b/apps/client/src/widgets/ribbon_widgets/search_definition.ts
index 24e59c473..ed3f3dde7 100644
--- a/apps/client/src/widgets/ribbon_widgets/search_definition.ts
+++ b/apps/client/src/widgets/ribbon_widgets/search_definition.ts
@@ -43,7 +43,7 @@ const TPL = /*html*/`