diff options
author | bob <bcz@cs.brown.edu> | 2019-09-05 13:22:53 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-09-05 13:22:53 -0400 |
commit | 2157c8e3fc08479c98a1f86575bc419f7061abb2 (patch) | |
tree | 27257b99674cb227c4be6c7893cc2f0fab56540f | |
parent | 179b2c7c68e3d240f3f39083bdb686ad31761c04 (diff) |
fixed default link following behavior for link menu items
-rw-r--r-- | src/client/views/linking/LinkFollowBox.tsx | 3 | ||||
-rw-r--r-- | src/client/views/linking/LinkMenuItem.tsx | 40 |
2 files changed, 20 insertions, 23 deletions
diff --git a/src/client/views/linking/LinkFollowBox.tsx b/src/client/views/linking/LinkFollowBox.tsx index 74663f9af..11d495c97 100644 --- a/src/client/views/linking/LinkFollowBox.tsx +++ b/src/client/views/linking/LinkFollowBox.tsx @@ -17,7 +17,6 @@ import { listSpec } from "../../../new_fields/Schema"; import { DocServer } from "../../DocServer"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faTimes } from '@fortawesome/free-solid-svg-icons'; -import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils"; enum FollowModes { OPENTAB = "Open in Tab", @@ -321,7 +320,7 @@ export class LinkFollowBox extends React.Component<FieldViewProps> { } //set this to be the default link behavior, can be any of the above - public defaultLinkBehavior: (options?: any) => void = this.openLinkTab; + public defaultLinkBehavior: (options?: any) => string = (options?: any) => "inTab"; @action currentLinkBehavior = () => { diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 6895dae9a..8ea43d521 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -1,26 +1,17 @@ import { library } from '@fortawesome/fontawesome-svg-core'; -import { faEdit, faEye, faTimes, faArrowRight, faChevronDown, faChevronUp, faGlobeAsia } from '@fortawesome/free-solid-svg-icons'; +import { faArrowRight, faChevronDown, faChevronUp, faEdit, faEye, faTimes } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { action, observable } from 'mobx'; import { observer } from "mobx-react"; -import { DocumentManager } from "../../util/DocumentManager"; -import { undoBatch } from "../../util/UndoManager"; -import './LinkMenu.scss'; -import React = require("react"); -import { Doc, DocListCastAsync, WidthSym } from '../../../new_fields/Doc'; -import { StrCast, Cast, FieldValue, NumCast } from '../../../new_fields/Types'; -import { observable, action, computed } from 'mobx'; -import { LinkManager } from '../../util/LinkManager'; +import { Doc } from '../../../new_fields/Doc'; +import { Cast, StrCast } from '../../../new_fields/Types'; import { DragLinkAsDocument } from '../../util/DragManager'; -import { CollectionDockingView } from '../collections/CollectionDockingView'; -import { SelectionManager } from '../../util/SelectionManager'; -import { CollectionViewType } from '../collections/CollectionBaseView'; -import { DocumentView } from '../nodes/DocumentView'; -import { SearchUtil } from '../../util/SearchUtil'; -import { LinkFollowBox } from './LinkFollowBox'; +import { LinkManager } from '../../util/LinkManager'; import { ContextMenu } from '../ContextMenu'; import { MainView } from '../MainView'; -import { Docs } from '../../documents/Documents'; -import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils'; +import { LinkFollowBox } from './LinkFollowBox'; +import './LinkMenu.scss'; +import React = require("react"); library.add(faEye, faEdit, faTimes, faArrowRight, faChevronDown, faChevronUp); @@ -37,7 +28,9 @@ interface LinkMenuItemProps { export class LinkMenuItem extends React.Component<LinkMenuItemProps> { private _drag = React.createRef<HTMLDivElement>(); @observable private _showMore: boolean = false; - @action toggleShowMore() { this._showMore = !this._showMore; } + @action toggleShowMore() { + this._showMore = !this._showMore; + } onEdit = (e: React.PointerEvent): void => { e.stopPropagation(); @@ -75,6 +68,11 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> { onLinkButtonUp = (e: PointerEvent): void => { document.removeEventListener("pointermove", this.onLinkButtonMoved); document.removeEventListener("pointerup", this.onLinkButtonUp); + + if (LinkFollowBox.Instance !== undefined) { + LinkFollowBox.Instance.props.Document.isMinimized = false; + LinkFollowBox.Instance.setLinkDocs(this.props.linkDoc, this.props.sourceDoc, this.props.destinationDoc); + } e.stopPropagation(); } @@ -98,9 +96,9 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> { @action.bound async followDefault() { if (LinkFollowBox.Instance !== undefined) { - LinkFollowBox.Instance.props.Document.isMinimized = false; - LinkFollowBox.Instance.setLinkDocs(this.props.linkDoc, this.props.sourceDoc, this.props.destinationDoc); - LinkFollowBox.Instance.defaultLinkBehavior(); + if (LinkFollowBox.Instance.defaultLinkBehavior() === "inTab") { + this.props.addDocTab(this.props.destinationDoc, undefined, "inTab"); + } } } |