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.tsx16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/client/views/nodes/LinkMenuItem.tsx b/src/client/views/nodes/LinkMenuItem.tsx
index e2ea43a3c..a012c9db2 100644
--- a/src/client/views/nodes/LinkMenuItem.tsx
+++ b/src/client/views/nodes/LinkMenuItem.tsx
@@ -14,6 +14,7 @@ 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);
@@ -45,7 +46,10 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
let targetContext = await Cast(proto.targetContext, Doc);
let sourceContext = await Cast(proto.sourceContext, Doc);
let guid = StrCast(this.props.linkDoc.guid);
- // let href = Utils.prepend("/doc/" + sourceContext[Id]); // trying to get id (?) so that we can search for this in the link marks
+ let href;
+ if (sourceContext) {
+ href = Utils.prepend("/doc/" + sourceContext[Id]); // trying to get id (?) so that we can search for this in the link marks
+ }
let self = this;
let dockingFunc = (document: Doc) => { this.props.addDocTab(document, undefined, "inTab"); SelectionManager.DeselectAll(); };
@@ -58,8 +62,14 @@ 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!));
- // jumpToDoc.linkHref = href;
- jumpToDoc.guid = guid;
+ if (guid) {
+ jumpToDoc.guid = guid;
+ } else if (href) { // retroactively fixing old in-text links by adding guid
+ console.log('wegotthis', href, guid);
+ jumpToDoc.linkHref = href;
+ let newguid = Utils.GenerateGuid();
+ 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)));