From 11d2743b553da47da88e77de1ac758e16e09b3e0 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Wed, 21 Aug 2019 13:55:46 -0400
Subject: adding docs works

---
 src/client/views/linking/LinkMenuItem.tsx | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

(limited to 'src/client/views/linking/LinkMenuItem.tsx')

diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index 7dc0a9fcd..65516b374 100644
--- a/src/client/views/linking/LinkMenuItem.tsx
+++ b/src/client/views/linking/LinkMenuItem.tsx
@@ -1,12 +1,12 @@
 import { library } from '@fortawesome/fontawesome-svg-core';
-import { faEdit, faEye, faTimes, faArrowRight, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
+import { faEdit, faEye, faTimes, faArrowRight, faChevronDown, faChevronUp, faGlobeAsia } from '@fortawesome/free-solid-svg-icons';
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 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 } from '../../../new_fields/Doc';
+import { Doc, DocListCastAsync, WidthSym } from '../../../new_fields/Doc';
 import { StrCast, Cast, FieldValue, NumCast } from '../../../new_fields/Types';
 import { observable, action } from 'mobx';
 import { LinkManager } from '../../util/LinkManager';
@@ -138,27 +138,29 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
         SelectionManager.DeselectAll();
     }
 
+    // DONE
     // this will open a link next to the source doc
     @undoBatch
     openLinkInPlace = () => {
         this.highlightDoc();
 
         let alias = Doc.MakeAlias(this.props.destinationDoc);
-        let y = this.props.sourceDoc.y;
-        let x = this.props.sourceDoc.x;
-        let parentView: any = undefined;
-        let parentDoc: Doc = this.props.sourceDoc;
+        let y = NumCast(this.props.sourceDoc.y);
+        let x = NumCast(this.props.sourceDoc.x);
+
+        let width = NumCast(this.props.sourceDoc.width);
+        let height = NumCast(this.props.sourceDoc.height);
+
+        alias.x = x + width + 30;
+        alias.y = y;
+        alias.width = width;
+        alias.height = height;
 
         SelectionManager.SelectedDocuments().map(dv => {
             if (dv.props.Document === this.props.sourceDoc) {
-                parentView = dv.props.ContainingCollectionView;
+                dv.props.addDocument && dv.props.addDocument(alias, false);
             }
         });
-
-        if (parentView) {
-            // console.log(parentDoc)
-            console.log(parentView.props.addDocument);
-        }
     }
 
     //set this to be the default link behavior, can be any of the above
-- 
cgit v1.2.3-70-g09d2

