From accfe9900c0b830ef08db3c70fe4940dd3c8c81e Mon Sep 17 00:00:00 2001 From: monikahedman Date: Mon, 26 Aug 2019 10:43:19 -0400 Subject: open in place working --- src/client/views/linking/LinkFollowBox.tsx | 27 ++++++++++++++++++--------- src/client/views/linking/LinkMenuItem.tsx | 4 +++- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/client/views/linking/LinkFollowBox.tsx b/src/client/views/linking/LinkFollowBox.tsx index 5cf14cf58..35b4deeac 100644 --- a/src/client/views/linking/LinkFollowBox.tsx +++ b/src/client/views/linking/LinkFollowBox.tsx @@ -1,4 +1,4 @@ -import { observable, computed, action, trace, ObservableMap, runInAction, reaction } from "mobx"; +import { observable, computed, action, trace, ObservableMap, runInAction, reaction, IReactionDisposer } from "mobx"; import React = require("react"); import { observer } from "mobx-react"; import { FieldViewProps, FieldView } from "../nodes/FieldView"; @@ -43,6 +43,7 @@ export class LinkFollowBox extends React.Component { @observable sourceView: DocumentView | undefined = undefined; @observable canPan: boolean = false; @observable shouldUseOnlyParentContext = false; + _panDisposer?: IReactionDisposer; @observable private _docs: { col: Doc, target: Doc }[] = []; @observable private _otherDocs: { col: Doc, target: Doc }[] = []; @@ -55,7 +56,7 @@ export class LinkFollowBox extends React.Component { componentDidMount = () => { this.resetVars(); - reaction( + this._panDisposer = reaction( () => LinkFollowBox.destinationDoc, async newLinkDestination => { if (LinkFollowBox.destinationDoc && this.sourceView && this.sourceView.props.ContainingCollectionView) { @@ -75,6 +76,10 @@ export class LinkFollowBox extends React.Component { ); } + componentWillUnmount = () => { + this._panDisposer && this._panDisposer(); + } + @action resetVars = () => { this.selectedContext = undefined; @@ -249,6 +254,7 @@ export class LinkFollowBox extends React.Component { if (LinkFollowBox.destinationDoc && LinkFollowBox.sourceDoc) { let alias = Doc.MakeAlias(LinkFollowBox.destinationDoc); + console.log(alias) let y = NumCast(LinkFollowBox.sourceDoc.y); let x = NumCast(LinkFollowBox.sourceDoc.x); @@ -260,13 +266,11 @@ export class LinkFollowBox extends React.Component { alias.width = width; alias.height = height; - SelectionManager.SelectedDocuments().map(dv => { - if (dv.props.Document === LinkFollowBox.sourceDoc) { - dv.props.addDocument && dv.props.addDocument(alias, false); - } - }); + if (this.sourceView && this.sourceView.props.addDocument) { + this.sourceView.props.addDocument(alias, false); + } - this.jumpToLink({ shouldZoom: false }); + this.jumpToLink({ shouldZoom: options.shouldZoom }); this.highlightDoc(); SelectionManager.DeselectAll(); @@ -279,8 +283,13 @@ export class LinkFollowBox extends React.Component { @action currentLinkBehavior = () => { - if (this.selectedMode === FollowModes.INPLACE) { + let shouldZoom: boolean | undefined = this.selectedOption === "" ? undefined : + this.selectedOption === FollowOptions.NOZOOM ? false : true; + if (this.selectedMode === FollowModes.INPLACE) { + console.log("hello") + console.log(shouldZoom) + if (shouldZoom !== undefined) this.openLinkInPlace({ shouldZoom: shouldZoom }); } else if (this.selectedMode === FollowModes.OPENFULL) { diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 406429ebf..d2dc3f7ff 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -175,7 +175,7 @@ export class LinkMenuItem extends React.Component { } //set this to be the default link behavior, can be any of the above - // private defaultLinkBehavior: any = LinkFollowBox.computeLinkDocs(this.props.linkDoc); + private defaultLinkBehavior: any = this.openLinkInPlace; onEdit = (e: React.PointerEvent): void => { e.stopPropagation(); @@ -244,6 +244,8 @@ export class LinkMenuItem extends React.Component { {/*
*/} {/* New */}
LinkFollowBox.Instance.setLinkDocs(this.props.linkDoc, this.props.sourceDoc, this.props.destinationDoc)}>
+ {/*
*/} + {this._showMore ? this.renderMetadata() : <>} -- cgit v1.2.3-70-g09d2