From c34e68b65c19df13c56f6281d48772b3ec05378b Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Fri, 12 Jun 2020 18:41:40 -0400 Subject: expanding highlights --- src/client/views/search/SearchItem.tsx | 62 +++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 37283e0fb..63baf625e 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -58,6 +58,7 @@ export class SelectorContextMenu extends React.Component { super(props); this.fetchDocuments(); + } async fetchDocuments() { @@ -180,18 +181,29 @@ export class SearchItem extends ViewBoxBaseComponent {console.log(NumCast(search));this.searchPos=NumCast(search) },{ fireImmediately: true } ); + this._reactionDisposer2 = reaction( + () => this._useIcons, + el=> {console.log("YUH"); + setTimeout(() =>(this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null), 1); + } + ); + Doc.SetSearchQuery(this.query); this.rootDoc.searchMatch = true; } componentWillUnmount() { this.rootDoc.searchMatch = undefined; this._reactionDisposer && this._reactionDisposer(); + this._reactionDisposer2 && this._reactionDisposer2(); + } @observable searchPos: number|undefined =0; private _reactionDisposer?: IReactionDisposer; + private _reactionDisposer2?: IReactionDisposer; + @computed get highlightPos(){return NumCast(this.rootDoc.searchIndex)} @@ -243,9 +255,12 @@ export class SearchItem extends ViewBoxBaseComponent { this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} > + return
{ this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} > -
; +
+
{this.rootDoc.type ? this.rootDoc.type : "Other"}
+ + ; } collectionRef = React.createRef(); @@ -380,10 +395,36 @@ export class SearchItem extends ViewBoxBaseComponent { + this._displayLines = !this._displayLines; + //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); + })} + //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} + > + {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
`${l}`
)} + ;; + } + else { + return ; + } + } + + //this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); + + @observable _displayLines: boolean = true; returnButtons(){ return
- {`Instance ${NumCast(this.rootDoc.searchIndex)===0? NumCast(this.rootDoc.length):NumCast(this.rootDoc.searchIndex) } of ${NumCast(this.rootDoc.length)}`} + {this.returnLines()} + {`Instance ${NumCast(this.rootDoc.searchIndex)===0? NumCast(this.rootDoc.length):NumCast(this.rootDoc.searchIndex) } of ${NumCast(this.rootDoc.length)}`} @@ -393,6 +434,9 @@ export class SearchItem extends ViewBoxBaseComponent } + private _mainRef: React.RefObject = React.createRef(); + + render() { const doc1 = Cast(this.rootDoc!.anchor1, Doc); const doc2 = Cast(this.rootDoc!.anchor2, Doc); @@ -429,26 +473,20 @@ export class SearchItem extends ViewBoxBaseComponent -
+
{StrCast(this.rootDoc.title)}
{this.rootDoc.highlighting? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "":null}
- {/* {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
{l}
)} */} +
{NumCast(this.rootDoc.length) > 1? this.returnButtons(): null} - {/* - */} +
{this.DocumentIcon()}
-
{this.rootDoc.type ? this.rootDoc.type : "Other"}
-- cgit v1.2.3-70-g09d2