diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/linking/LinkFollowBox.tsx | 27 | ||||
-rw-r--r-- | src/client/views/linking/LinkMenuItem.tsx | 4 |
2 files changed, 21 insertions, 10 deletions
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<FieldViewProps> { @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<FieldViewProps> { 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<FieldViewProps> { ); } + componentWillUnmount = () => { + this._panDisposer && this._panDisposer(); + } + @action resetVars = () => { this.selectedContext = undefined; @@ -249,6 +254,7 @@ export class LinkFollowBox extends React.Component<FieldViewProps> { 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<FieldViewProps> { 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<FieldViewProps> { @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<LinkMenuItemProps> { } //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<LinkMenuItemProps> { {/* <div title="Follow link" className="button" onPointerDown={this.onFollowLink}><FontAwesomeIcon className="fa-icon" icon="arrow-right" size="sm" /></div> */} {/* New */} <div title="Follow link" className="button" onClick={() => LinkFollowBox.Instance.setLinkDocs(this.props.linkDoc, this.props.sourceDoc, this.props.destinationDoc)}><FontAwesomeIcon className="fa-icon" icon="arrow-right" size="sm" /></div> + {/* <div title="Follow link" className="button" onClick={this.defaultLinkBehavior}><FontAwesomeIcon className="fa-icon" icon="arrow-right" size="sm" /></div> */} + </div> </div> {this._showMore ? this.renderMetadata() : <></>} |