From f65f3f16b50a3e43555626ed5fb97c78aed9c5a4 Mon Sep 17 00:00:00 2001 From: ab Date: Mon, 8 Jul 2019 15:25:06 -0400 Subject: idk --- src/client/views/nodes/FormattedTextBox.tsx | 28 +++++++++++++++++----------- src/client/views/search/SearchItem.tsx | 14 +++++++++----- 2 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 3c40819a8..a5fa4582d 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -256,17 +256,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe }, { fireImmediately: true }); } - this._searchReactionDisposer = reaction(() => { - return StrCast(this.props.Document.search_string); - }, searchString => { - if (searchString) { - this.highlightSearchTerms([searchString]); - } - else { - this.unhighlightSearchTerms(); - } - }); - this._reactionDisposer = reaction( () => { const field = this.dataDoc ? Cast(this.dataDoc[this.props.fieldKey], RichTextField) : undefined; @@ -275,7 +264,24 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe field => this._editorView && !this._applyingChange && this.props.Document[this.props.fieldKey] instanceof RichTextField && this._editorView.updateState(EditorState.fromJSON(config, JSON.parse(field))) ); + this.setupEditor(config, this.dataDoc, this.props.fieldKey); + + this._searchReactionDisposer = reaction(() => { + return StrCast(this.props.Document.search_string); + }, searchString => { + const fieldkey = 'preview'; + let preview = false; + // if (!this._editorView && Object.keys(this.props.Document).indexOf(fieldkey) !== -1) { + // preview = true; + // } + if (searchString) { + this.highlightSearchTerms([searchString]); + } + else { + this.unhighlightSearchTerms(); + } + }, { fireImmediately: true }); } private setupEditor(config: any, doc: Doc, fieldKey: string) { diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 9c91c524b..de071ab0c 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -161,8 +161,9 @@ export class SearchItem extends React.Component { } - @computed - public get DocumentIcon() { + //@computed + @action + public DocumentIcon() { let layoutresult = StrCast(this.props.doc.type); if (!this._useIcons) { let renderDoc = this.props.doc; @@ -182,7 +183,8 @@ export class SearchItem extends React.Component { let returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); let returnYDimension = () => this._displayDim; let scale = () => returnXDimension() / NumCast(renderDoc.nativeWidth, returnXDimension()); - return
{ this._useIcons = !this._useIcons; this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); })} onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} onPointerLeave={action(() => this._displayDim = 50)} > @@ -207,8 +209,10 @@ export class SearchItem extends React.Component { ContentScaling={scale} />
; + renderDoc.preview = true; + renderDoc.search_string = "hundo"; + return docview; } - let button = layoutresult.indexOf(DocTypes.PDF) !== -1 ? faFilePdf : layoutresult.indexOf(DocTypes.IMG) !== -1 ? faImage : layoutresult.indexOf(DocTypes.TEXT) !== -1 ? faStickyNote : @@ -293,7 +297,7 @@ export class SearchItem extends React.Component {
{this.props.doc.title}
-
{this.DocumentIcon}
+
{this.DocumentIcon()}
{this.props.doc.type}
-- cgit v1.2.3-70-g09d2