aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-07-08 15:25:06 -0400
committerab <abdullah_ahmed@brown.edu>2019-07-08 15:25:06 -0400
commitf65f3f16b50a3e43555626ed5fb97c78aed9c5a4 (patch)
treeab800ee62d00b6e6382e9b530447e67cf5d06f15 /src
parent7627ed4d04f9bdcc2144c2b82197881e3f097c9a (diff)
idk
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx28
-rw-r--r--src/client/views/search/SearchItem.tsx14
2 files changed, 26 insertions, 16 deletions
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<SearchItemProps> {
}
- @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<SearchItemProps> {
let returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
let returnYDimension = () => this._displayDim;
let scale = () => returnXDimension() / NumCast(renderDoc.nativeWidth, returnXDimension());
- return <div
+ renderDoc = Doc.MakeDelegate(renderDoc);
+ const docview = <div
onPointerDown={action(() => { 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<SearchItemProps> {
ContentScaling={scale}
/>
</div>;
+ 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<SearchItemProps> {
<div className="search-title" id="result" >{this.props.doc.title}</div>
<div className="search-info" style={{ width: this._useIcons ? "15%" : "400px" }}>
<div className={`icon-${this._useIcons ? "icons" : "live"}`}>
- <div className="search-type" >{this.DocumentIcon}</div>
+ <div className="search-type" >{this.DocumentIcon()}</div>
<div className="search-label">{this.props.doc.type}</div>
</div>
<div className="link-container item">