diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/SearchItem.tsx | 13 | ||||
-rw-r--r-- | src/new_fields/Doc.ts | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx index d30579907..0da0bdae8 100644 --- a/src/client/views/SearchItem.tsx +++ b/src/client/views/SearchItem.tsx @@ -8,6 +8,7 @@ import { Cast } from "../../new_fields/Types"; import { FieldView, FieldViewProps } from './nodes/FieldView'; import { computed } from "mobx"; import { IconField } from "../../new_fields/IconField"; +import { SetupDrag } from "../util/DragManager"; export interface SearchProps { @@ -40,9 +41,19 @@ export class SearchItem extends React.Component<SearchProps> { return <FontAwesomeIcon icon={button} className="documentView-minimizedIcon" />; } + collectionRef = React.createRef<HTMLDivElement>(); + startDocDrag = () => { + let doc = this.props.doc; + const isProto = Doc.GetT(doc, "isPrototype", "boolean", true); + if (isProto) { + return Doc.MakeDelegate(doc); + } else { + return Doc.MakeAlias(doc); + } + } render() { return ( - <div className="search-item" id="result" onClick={this.onClick}> + <div className="search-item" ref={this.collectionRef} id="result" onClick={this.onClick} onPointerDown={SetupDrag(this.collectionRef, this.startDocDrag)} > <div className="search-title" id="result" >title: {this.props.doc.title}</div> {/* <div className="search-type" id="result" >Type: {this.props.doc.layout}</div> */} {/* <div className="search-type" >{SearchItem.DocumentIcon(this.layout)}</div> */} diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index f844dad6e..2ab145fa3 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -92,8 +92,8 @@ export class Doc extends RefField { private [Self] = this; private [SelfProxy]: any; - public [WidthSym] = () => NumCast(this.__fields.width); // bcz: is this the right way to access width/height? it didn't work with : this.width - public [HeightSym] = () => NumCast(this.__fields.height); + public [WidthSym] = () => NumCast(this[SelfProxy].width); // bcz: is this the right way to access width/height? it didn't work with : this.width + public [HeightSym] = () => NumCast(this[SelfProxy].height); public [HandleUpdate](diff: any) { console.log(diff); |