aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-12-11 20:28:11 -0500
committerBob Zeleznik <zzzman@gmail.com>2019-12-11 20:28:11 -0500
commitac3fc59b4574719c22d95910bbbf0430be7de220 (patch)
treee0ee8ab2ca17a3c63bc4b7c1e77765e5d24a8e2f /src/client/views/search
parent4e8605c9e46acd3f3d9080073bdd6e80f049c85a (diff)
got rid of search_match&search_fields. Now have Doc.SearchQuery() and document.searchMatch
Diffstat (limited to 'src/client/views/search')
-rw-r--r--src/client/views/search/SearchBox.tsx10
-rw-r--r--src/client/views/search/SearchItem.tsx15
2 files changed, 14 insertions, 11 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index c45fbe210..fe21c29c3 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -85,7 +85,11 @@ export class SearchBox extends React.Component {
this._maxSearchIndex = 0;
}
- enter = (e: React.KeyboardEvent) => { if (e.key === "Enter") { this.submitSearch(); } };
+ enter = (e: React.KeyboardEvent) => {
+ if (e.key === "Enter") {
+ this.submitSearch();
+ }
+ }
public static async convertDataUri(imageUri: string, returnedFilename: string) {
try {
@@ -307,7 +311,7 @@ export class SearchBox extends React.Component {
this.getResults(this._searchString);
if (i < this._results.length) result = this._results[i];
if (result) {
- const highlights = Array.from([...Array.from(new Set(result[1]).values())]).filter(v => v !== "search_string");
+ const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
this._isSearch[i] = "search";
}
@@ -315,7 +319,7 @@ export class SearchBox extends React.Component {
else {
result = this._results[i];
if (result) {
- const highlights = Array.from([...Array.from(new Set(result[1]).values())]).filter(v => v !== "search_string");
+ const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
this._isSearch[i] = "search";
}
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 1007102f6..cdb6dcf7c 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -135,12 +135,11 @@ export class SearchItem extends React.Component<SearchItemProps> {
@observable _displayDim = 50;
componentDidMount() {
- this.props.doc.search_string = this.props.query;
- this.props.doc.search_fields = this.props.highlighting.join(", ");
+ Doc.SetSearchQuery(this.props.query);
+ this.props.doc.searchMatch = true;
}
componentWillUnmount() {
- this.props.doc.search_string = undefined;
- this.props.doc.search_fields = undefined;
+ this.props.doc.searchMatch = undefined;
}
//@computed
@@ -218,10 +217,10 @@ export class SearchItem extends React.Component<SearchItemProps> {
pointerDown = (e: React.PointerEvent) => { e.preventDefault(); e.button === 0 && SearchBox.Instance.openSearch(e); }
nextHighlight = (e: React.PointerEvent) => {
- e.preventDefault(); e.button === 0 && SearchBox.Instance.openSearch(e);
- const sstring = StrCast(this.props.doc.search_string);
- this.props.doc.search_string = "";
- setTimeout(() => this.props.doc.search_string = sstring, 0);
+ e.preventDefault();
+ e.button === 0 && SearchBox.Instance.openSearch(e);
+ this.props.doc.searchMatch = false;
+ setTimeout(() => this.props.doc.searchMatch = true, 0);
}
highlightDoc = (e: React.PointerEvent) => {
if (this.props.doc.type === DocumentType.LINK) {