diff options
Diffstat (limited to 'src/client/views')
| -rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 17 | ||||
| -rw-r--r-- | src/client/views/search/SearchItem.tsx | 14 |
2 files changed, 21 insertions, 10 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 340455677..2fdb16cc3 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -152,9 +152,7 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe if (terms.includes(word) && this._editorView) { this._editorView.dispatch(this._editorView.state.tr.addMark(start, start + word.length, mark).removeStoredMark(mark)); } - else { - start += word.length + 1; - } + start += word.length + 1; }); } }); @@ -172,6 +170,12 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe } } }); + // const fieldkey = 'search_string'; + // if (Object.keys(this.props.Document).indexOf(fieldkey) !== -1) { + // this.props.Document[fieldkey] = undefined; + // } + // else this.props.Document.proto![fieldkey] = undefined; + // } } } @@ -255,7 +259,12 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe this._searchReactionDisposer = reaction(() => { return StrCast(this.props.Document.search_string); }, searchString => { - this.highlightSearchTerms([searchString]); + if (searchString) { + this.highlightSearchTerms([searchString]); + } + else { + this.unhighlightSearchTerms(); + } }); this._reactionDisposer = reaction( diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index d2e57c5ca..9c91c524b 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -149,12 +149,14 @@ export class SearchItem extends React.Component<SearchItemProps> { highlightTextBox = (doc: Doc) => { if (this.props.query) { - doc.search_string = this.props.query; - // FormattedTextBox.Instance.highlightSearchTerms([this.props.query]); - } - else { - // FormattedTextBox.Instance.highlightSearchTerms(["hello"]); - doc.search_string = "hello"; + const fieldkey = 'search_string'; + if (Object.keys(doc).indexOf(fieldkey) === -1) { + doc.search_string = this.props.query; + } + else { + doc.search_string = undefined; + } + } } |
