aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LinkMenuItem.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/LinkMenuItem.tsx')
-rw-r--r--src/client/views/nodes/LinkMenuItem.tsx15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/client/views/nodes/LinkMenuItem.tsx b/src/client/views/nodes/LinkMenuItem.tsx
index 90b335933..259dbc04e 100644
--- a/src/client/views/nodes/LinkMenuItem.tsx
+++ b/src/client/views/nodes/LinkMenuItem.tsx
@@ -13,6 +13,8 @@ import { LinkManager } from '../../util/LinkManager';
import { DragLinkAsDocument } from '../../util/DragManager';
import { CollectionDockingView } from '../collections/CollectionDockingView';
import { SelectionManager } from '../../util/SelectionManager';
+import { Utils } from '../../../Utils';
+import { Id } from '../../../new_fields/FieldSymbols';
library.add(faEye, faEdit, faTimes, faArrowRight, faChevronDown, faChevronUp);
@@ -43,9 +45,9 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
let proto = Doc.GetProto(this.props.linkDoc);
let targetContext = await Cast(proto.targetContext, Doc);
let sourceContext = await Cast(proto.sourceContext, Doc);
+ let guid = StrCast(this.props.linkDoc.guid);
let self = this;
-
let dockingFunc = (document: Doc) => { this.props.addDocTab(document, undefined, "inTab"); SelectionManager.DeselectAll(); };
if (e.ctrlKey) {
dockingFunc = (document: Doc) => CollectionDockingView.Instance.AddRightSplit(document, undefined);
@@ -56,6 +58,17 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
}
else if (this.props.destinationDoc === self.props.linkDoc.anchor1 && sourceContext) {
DocumentManager.Instance.jumpToDocument(jumpToDoc, e.altKey, false, document => dockingFunc(sourceContext!));
+ if (guid) {
+ console.log('wegotthis', self.props.linkDoc.anchor2, jumpToDoc[Id]);
+ jumpToDoc.linkHref = Utils.prepend("/doc/" + StrCast(this.props.linkDoc.anchor2));
+ jumpToDoc.guid = guid;
+ } else { // retroactively fixing old in-text links by adding guid
+ console.log('wegotthis', self.props.linkDoc.anchor2, jumpToDoc[Id]);
+ jumpToDoc.linkHref = Utils.prepend("/doc/" + StrCast(this.props.linkDoc.anchor2));
+ let newguid = Utils.GenerateGuid();
+ this.props.linkDoc.guid = newguid;
+ jumpToDoc.guid = newguid;
+ }
}
else if (DocumentManager.Instance.getDocumentView(jumpToDoc)) {
DocumentManager.Instance.jumpToDocument(jumpToDoc, e.altKey, undefined, undefined, NumCast((this.props.destinationDoc === self.props.linkDoc.anchor2 ? self.props.linkDoc.anchor2Page : self.props.linkDoc.anchor1Page)));