mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-22 03:46:22 +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
11
package-lock.json
generated
11
package-lock.json
generated
|
@ -30,6 +30,7 @@
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
"remark-math": "^5.1.1",
|
"remark-math": "^5.1.1",
|
||||||
"remark-stringify": "^10.0.2",
|
"remark-stringify": "^10.0.2",
|
||||||
|
"remove-markdown": "^0.5.0",
|
||||||
"socket.io": "^4.6.1",
|
"socket.io": "^4.6.1",
|
||||||
"socket.io-client": "^4.6.1",
|
"socket.io-client": "^4.6.1",
|
||||||
"unified": "^10.1.2"
|
"unified": "^10.1.2"
|
||||||
|
@ -4695,6 +4696,11 @@
|
||||||
"url": "https://opencollective.com/unified"
|
"url": "https://opencollective.com/unified"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/remove-markdown": {
|
||||||
|
"version": "0.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/remove-markdown/-/remove-markdown-0.5.0.tgz",
|
||||||
|
"integrity": "sha512-x917M80K97K5IN1L8lUvFehsfhR8cYjGQ/yAMRI9E7JIKivtl5Emo5iD13DhMr+VojzMCiYk8V2byNPwT/oapg=="
|
||||||
|
},
|
||||||
"node_modules/require-from-string": {
|
"node_modules/require-from-string": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||||
|
@ -8836,6 +8842,11 @@
|
||||||
"unified": "^10.0.0"
|
"unified": "^10.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"remove-markdown": {
|
||||||
|
"version": "0.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/remove-markdown/-/remove-markdown-0.5.0.tgz",
|
||||||
|
"integrity": "sha512-x917M80K97K5IN1L8lUvFehsfhR8cYjGQ/yAMRI9E7JIKivtl5Emo5iD13DhMr+VojzMCiYk8V2byNPwT/oapg=="
|
||||||
|
},
|
||||||
"require-from-string": {
|
"require-from-string": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
"remark-math": "^5.1.1",
|
"remark-math": "^5.1.1",
|
||||||
"remark-stringify": "^10.0.2",
|
"remark-stringify": "^10.0.2",
|
||||||
|
"remove-markdown": "^0.5.0",
|
||||||
"socket.io": "^4.6.1",
|
"socket.io": "^4.6.1",
|
||||||
"socket.io-client": "^4.6.1",
|
"socket.io-client": "^4.6.1",
|
||||||
"unified": "^10.1.2"
|
"unified": "^10.1.2"
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Fuse from "fuse.js";
|
||||||
import { inputStyle } from "../components/styles";
|
import { inputStyle } from "../components/styles";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { setSetting } from "../components/settingsInputs";
|
import { setSetting } from "../components/settingsInputs";
|
||||||
|
import RemoveMarkdown from "remove-markdown";
|
||||||
|
|
||||||
function Notes() {
|
function Notes() {
|
||||||
if (!settings.newNotes) {
|
if (!settings.newNotes) {
|
||||||
|
@ -21,14 +22,24 @@ function Notes() {
|
||||||
|
|
||||||
let n = Object.values(localStorage.getObj("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 [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);
|
let found = search === "" ? n : fuse.search(search);
|
||||||
|
|
||||||
if (search !== "") {
|
if (search !== "") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue