aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Rickert <andrew_rickert@brown.edu>2020-06-10 18:23:27 -0400
committerAndy Rickert <andrew_rickert@brown.edu>2020-06-10 18:23:27 -0400
commit78227f09b30db57c6f500bd2e2d02f43d133d1da (patch)
treee001398c1672351ee0b4eab5965e17e737f0c345
parent52f88acb3141e15b1063f489273d94d98447c87a (diff)
highlights
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx3
-rw-r--r--src/client/views/search/SearchItem.tsx2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index fc131cd38..cb84921f8 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -253,10 +253,13 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
const activeMark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight, { selected: true });
const res = terms.filter(t => t).map(term => this.findInNode(this._editorView!, this._editorView!.state.doc, term));
+ console.log(res);
let tr = this._editorView.state.tr;
const flattened: TextSelection[] = [];
res.map(r => r.map(h => flattened.push(h)));
+ console.log(flattened);
const lastSel = Math.min(flattened.length - 1, this._searchIndex);
+ console.log(lastSel)
flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 74750a40c..35fc211af 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -248,6 +248,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
setTimeout(() => this.targetDoc!.searchMatch = true, 0);
}
highlightDoc = (e: React.PointerEvent) => {
+ console.log(Cast(this.targetDoc.lines, listSpec("string"))!.length);
+
if (this.targetDoc!.type === DocumentType.LINK) {
if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {