mirror of
https://github.com/artegoser/AnoPaper.git
synced 2025-02-23 12:43:14 +03:00
fix: search by plain text
This commit is contained in:
parent
f1f2e96a50
commit
0b7523c57d
3 changed files with 29 additions and 6 deletions
|
@ -5,6 +5,7 @@ import Fuse from "fuse.js";
|
|||
import { inputStyle } from "../components/styles";
|
||||
import { useState } from "react";
|
||||
import { setSetting } from "../components/settingsInputs";
|
||||
import RemoveMarkdown from "remove-markdown";
|
||||
|
||||
function Notes() {
|
||||
if (!settings.newNotes) {
|
||||
|
@ -21,14 +22,24 @@ function Notes() {
|
|||
|
||||
let n = Object.values(localStorage.getObj("Notes"));
|
||||
|
||||
let fuse = new Fuse(n, {
|
||||
includeScore: true,
|
||||
useExtendedSearch: true,
|
||||
keys: ["name", "text", "textTime", "tags"],
|
||||
});
|
||||
|
||||
let [search, setSearch] = useState("");
|
||||
|
||||
let fuse;
|
||||
|
||||
if (search)
|
||||
fuse = new Fuse(n, {
|
||||
includeScore: true,
|
||||
useExtendedSearch: true,
|
||||
keys: [
|
||||
"name",
|
||||
"textTime",
|
||||
{
|
||||
name: "text",
|
||||
getFn: (obj) => RemoveMarkdown(obj.text),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
let found = search === "" ? n : fuse.search(search);
|
||||
|
||||
if (search !== "") {
|
||||
|
|
Loading…
Add table
Reference in a new issue