aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index c898f697b..ad3b880cd 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -216,6 +216,8 @@ export namespace Doc {
}
export function MakeLink(source: Doc, target: Doc) {
+ let protoSrc = source.proto ? source.proto : source;
+ let protoTarg = target.proto ? target.proto : target;
UndoManager.RunInBatch(() => {
let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1 });
//let linkDoc = new Doc;
@@ -226,15 +228,15 @@ export namespace Doc {
linkDoc.proto!.linkedTo = target;
linkDoc.proto!.linkedFrom = source;
- let linkedFrom = Cast(target.linkedFromDocs, listSpec(Doc));
+ let linkedFrom = Cast(protoTarg.linkedFromDocs, listSpec(Doc));
if (!linkedFrom) {
- target.linkedFromDocs = linkedFrom = new List<Doc>();
+ protoTarg.linkedFromDocs = linkedFrom = new List<Doc>();
}
linkedFrom.push(linkDoc);
- let linkedTo = Cast(source.linkedToDocs, listSpec(Doc));
+ let linkedTo = Cast(protoSrc.linkedToDocs, listSpec(Doc));
if (!linkedTo) {
- source.linkedToDocs = linkedTo = new List<Doc>();
+ protoSrc.linkedToDocs = linkedTo = new List<Doc>();
}
linkedTo.push(linkDoc);
return linkDoc;