aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/linking
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-09-06 01:42:32 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-09-06 01:42:32 -0400
commit760465b0723e2b21a07269afe61a0207a0bc5580 (patch)
treefcfac8c7495ea95096a22aba401fc99cb6d17a13 /src/client/views/linking
parente5b52b1083c86b946a2758983e397826579d2282 (diff)
parent717e32f8f140127a628c5ea4b7543c1703459e15 (diff)
merged
Diffstat (limited to 'src/client/views/linking')
-rw-r--r--src/client/views/linking/LinkFollowBox.tsx17
-rw-r--r--src/client/views/linking/LinkMenuItem.tsx36
2 files changed, 28 insertions, 25 deletions
diff --git a/src/client/views/linking/LinkFollowBox.tsx b/src/client/views/linking/LinkFollowBox.tsx
index 74663f9af..13a341543 100644
--- a/src/client/views/linking/LinkFollowBox.tsx
+++ b/src/client/views/linking/LinkFollowBox.tsx
@@ -17,7 +17,7 @@ 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";
+import { docs_v1 } from "googleapis";
enum FollowModes {
OPENTAB = "Open in Tab",
@@ -198,6 +198,12 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
}
+ _addDocTab: (undefined | ((doc: Doc, dataDoc: Doc | undefined, where: string) => void));
+
+ setAddDocTab = (addFunc: (doc: Doc, dataDoc: Doc | undefined, where: string) => void) => {
+ this._addDocTab = addFunc;
+ }
+
@undoBatch
openLinkColRight = (options: { context: Doc, shouldZoom: boolean }) => {
if (LinkFollowBox.destinationDoc) {
@@ -240,7 +246,7 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
let targetContext = await Cast(proto.targetContext, Doc);
let sourceContext = await Cast(proto.sourceContext, Doc);
- let dockingFunc = (document: Doc) => { this.props.addDocTab(document, undefined, "inTab"); SelectionManager.DeselectAll(); };
+ let dockingFunc = (document: Doc) => { this._addDocTab && this._addDocTab(document, undefined, "inTab"); SelectionManager.DeselectAll(); };
if (LinkFollowBox.destinationDoc === LinkFollowBox.linkDoc.anchor2 && targetContext) {
DocumentManager.Instance.jumpToDocument(jumpToDoc, options.shouldZoom, false, async document => dockingFunc(document), undefined, targetContext);
@@ -266,9 +272,8 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
openLinkTab = () => {
if (LinkFollowBox.destinationDoc) {
let fullScreenAlias = Doc.MakeAlias(LinkFollowBox.destinationDoc);
- // THIS IS EMPTY FUNCTION
- this.props.addDocTab(fullScreenAlias, undefined, "inTab");
- console.log(this.props.addDocTab);
+ // this.prosp.addDocTab is empty -- use the link source's addDocTab
+ this._addDocTab && this._addDocTab(fullScreenAlias, undefined, "inTab");
this.highlightDoc();
SelectionManager.DeselectAll();
@@ -285,7 +290,7 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
options.context.panX = newPanX;
options.context.panY = newPanY;
}
- this.props.addDocTab(options.context, undefined, "inTab");
+ this._addDocTab && this._addDocTab(options.context, undefined, "inTab");
if (options.shouldZoom) this.jumpToLink({ shouldZoom: options.shouldZoom });
this.highlightDoc();
diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index 6895dae9a..19a0023e9 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,12 @@ 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);
+ LinkFollowBox.Instance.setAddDocTab(this.props.addDocTab);
+ }
e.stopPropagation();
}
@@ -98,7 +97,6 @@ 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();
}