import FormTextArea from "../react/FormTextArea"; import NoteAutocomplete from "../react/NoteAutocomplete"; import FormSelect from "../react/FormSelect"; import Icon from "../react/Icon"; import FormTextBox from "../react/FormTextBox"; import { ComponentChildren, VNode } from "preact"; import FNote from "../../entities/fnote"; import { removeOwnedAttributesByNameOrType } from "../../services/attributes"; import { AttributeType } from "@triliumnext/commons"; import { useNoteLabel, useNoteRelation, useSpacedUpdate, useTooltip } from "../react/hooks"; import { t } from "../../services/i18n"; import { useEffect, useMemo, useRef } from "preact/hooks"; import appContext from "../../components/app_context"; import server from "../../services/server"; import HelpRemoveButtons from "../react/HelpRemoveButtons"; export interface SearchOption { attributeName: string; attributeType: "label" | "relation"; icon: string; label: string; tooltip?: string; component: (props: SearchOptionProps) => VNode; defaultValue?: string; additionalAttributesToDelete?: { type: "label" | "relation", name: string }[]; } interface SearchOptionProps { note: FNote; refreshResults: () => void; attributeName: string; attributeType: "label" | "relation"; additionalAttributesToDelete?: { type: "label" | "relation", name: string }[]; defaultValue?: string; error?: { message: string }; } export const SEARCH_OPTIONS: SearchOption[] = [ { attributeName: "searchString", attributeType: "label", icon: "bx bx-text", label: t("search_definition.search_string"), component: SearchStringOption }, { attributeName: "searchScript", attributeType: "relation", defaultValue: "root", icon: "bx bx-code", label: t("search_definition.search_script"), component: SearchScriptOption }, { attributeName: "ancestor", attributeType: "relation", defaultValue: "root", icon: "bx bx-filter-alt", label: t("search_definition.ancestor"), component: AncestorOption, additionalAttributesToDelete: [ { type: "label", name: "ancestorDepth" } ] }, { attributeName: "fastSearch", attributeType: "label", icon: "bx bx-run", label: t("search_definition.fast_search"), tooltip: t("search_definition.fast_search_description"), component: FastSearchOption }, { attributeName: "includeArchivedNotes", attributeType: "label", icon: "bx bx-archive", label: t("search_definition.include_archived"), tooltip: t("search_definition.include_archived_notes_description"), component: IncludeArchivedNotesOption }, { attributeName: "orderBy", attributeType: "label", defaultValue: "relevancy", icon: "bx bx-arrow-from-top", label: t("search_definition.order_by"), component: OrderByOption, additionalAttributesToDelete: [ { type: "label", name: "orderDirection" } ] }, { attributeName: "limit", attributeType: "label", defaultValue: "10", icon: "bx bx-stop", label: t("search_definition.limit"), tooltip: t("search_definition.limit_description"), component: LimitOption }, { attributeName: "debug", attributeType: "label", icon: "bx bx-bug", label: t("search_definition.debug"), tooltip: t("search_definition.debug_description"), component: DebugOption } ]; function SearchOption({ note, title, titleIcon, children, help, attributeName, attributeType, additionalAttributesToDelete }: { note: FNote; title: string, titleIcon?: string, children?: ComponentChildren, help?: ComponentChildren, attributeName: string, attributeType: AttributeType, additionalAttributesToDelete?: { type: "label" | "relation", name: string }[] }) { return (
#abc - {t("search_string.label_abc")}#year = 2019 - {t("search_string.label_year")}#rock #pop - {t("search_string.label_rock_pop")}#rock or #pop - {t("search_string.label_rock_or_pop")}#year <= 2000 - {t("search_string.label_year_comparison")}note.dateCreated >= MONTH-1 - {t("search_string.label_date_created")}{t("search_script.description1")}
{t("search_script.description2")}
{t("search_script.example_title")}
{t("search_script.example_code")}
{t("search_script.note")}
>}
note={note} {...restProps}
>
{t("debug.debug_info")}
{t("debug.access_info")} >} {...restProps} /> } function IncludeArchivedNotesOption({ ...restProps }: SearchOptionProps) { return