diff options
author | ab <abdullah_ahmed@brown.edu> | 2019-07-10 12:40:25 -0400 |
---|---|---|
committer | ab <abdullah_ahmed@brown.edu> | 2019-07-10 12:40:25 -0400 |
commit | 1fb746bcb228a348da1b4d8056aab59e073ee89e (patch) | |
tree | 35625ae8684cbd26f6bf293db883776f5d81fd7a /src | |
parent | 90fac4c0290b00524e8c8fe2fe5c6da092cf36b9 (diff) |
fix preview highlighting
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 7 | ||||
-rw-r--r-- | src/client/views/search/SearchItem.tsx | 1 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index f24536f3a..c566ba049 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -129,7 +129,8 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe const state = this._editorView.state.apply(tx); this._editorView.updateState(state); this._applyingChange = true; - if (this.dataDoc[this.props.fieldKey]) { + const fieldkey = "preview"; + if (Object.keys(this.dataDoc).indexOf(fieldkey) !== -1) { this.dataDoc[this.props.fieldKey] = new RichTextField(JSON.stringify(state.toJSON())); this.dataDoc[this.props.fieldKey + "_text"] = state.doc.textBetween(0, state.doc.content.size, "\n\n"); } @@ -160,9 +161,7 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe let start = pos; tokens.forEach((word) => { if (terms.includes(word) && this._editorView) { - if (Object.keys(this.props.Document).indexOf(fieldkey) === -1) { - this._editorView.dispatch(this._editorView.state.tr.addMark(start, start + word.length, mark).removeStoredMark(mark)); - } + this._editorView.dispatch(this._editorView.state.tr.addMark(start, start + word.length, mark).removeStoredMark(mark)); // else { // this._editorView.state.tr.addMark(start, start + word.length, mark).removeStoredMark(mark); // } diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 1d71fc6aa..a54be4437 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -212,6 +212,7 @@ export class SearchItem extends React.Component<SearchItemProps> { </div>; const data = renderDoc.data; if (data instanceof ObjectField) newRenderDoc.data = ObjectField.MakeCopy(data); + newRenderDoc.preview = true; newRenderDoc.search_string = "hundo"; return docview; } |