diff options
| author | Jenny Yu <jennyyu212@outlook.com> | 2022-04-28 16:17:25 -0400 | 
|---|---|---|
| committer | Jenny Yu <jennyyu212@outlook.com> | 2022-04-28 16:17:25 -0400 | 
| commit | 83c615b1b9706818894ee74481afd4c2bf34fe61 (patch) | |
| tree | 6e6a242fdbe1d5c164fce9d0c1ae84b4423ed40c /src/client/util/LinkManager.ts | |
| parent | 9f62b6d1c9848439671065dac9ed79bc393c83fa (diff) | |
| parent | 15bc17cbbe3816ab78ce653105ddff06bce18c59 (diff) | |
Merge branch 'master' into recording-jenny
Diffstat (limited to 'src/client/util/LinkManager.ts')
| -rw-r--r-- | src/client/util/LinkManager.ts | 21 | 
1 files changed, 13 insertions, 8 deletions
| diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index df2c02a8d..9445533dc 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -29,6 +29,7 @@ export class LinkManager {      public static currentLink: Opt<Doc>;      public static get Instance() { return LinkManager._instance; }      public static addLinkDB = (linkDb: any) => LinkManager.userLinkDBs.push(linkDb); +    public static AutoKeywords = "keywords:Usages";      static links: Doc[] = [];      constructor() {          LinkManager._instance = this; @@ -149,9 +150,11 @@ export class LinkManager {      public getRelatedGroupedLinks(anchor: Doc): Map<string, Array<Doc>> {          const anchorGroups = new Map<string, Array<Doc>>();          this.relatedLinker(anchor).forEach(link => { -            if (!link.linkRelationship || link?.linkRelationship !== "-ungrouped-") { -                const group = anchorGroups.get(StrCast(link.linkRelationship)); -                anchorGroups.set(StrCast(link.linkRelationship), group ? [...group, link] : [link]); +            if (link.linkRelationship && link.linkRelationship !== "-ungrouped-") { +                const relation = StrCast(link.linkRelationship); +                const anchorRelation = relation.indexOf(":") !== -1 ? relation.split(":")[Doc.AreProtosEqual(Cast(link.anchor1, Doc, null), anchor) ? 0 : 1] : relation; +                const group = anchorGroups.get(anchorRelation); +                anchorGroups.set(anchorRelation, group ? [...group, link] : [link]);              } else {                  // if link is in no groups then put it in default group                  const group = anchorGroups.get("*"); @@ -221,7 +224,9 @@ export class LinkManager {          const backLinkWithoutTargetView = secondDocs.find(d => DocumentManager.Instance.getDocumentViews(d.anchor1 as Doc).length === 0);          const linkWithoutTargetDoc = traverseBacklink === undefined ? fwdLinkWithoutTargetView || backLinkWithoutTargetView : traverseBacklink ? backLinkWithoutTargetView : fwdLinkWithoutTargetView;          const linkDocList = linkWithoutTargetDoc ? [linkWithoutTargetDoc] : (traverseBacklink === undefined ? firstDocs.concat(secondDocs) : traverseBacklink ? secondDocs : firstDocs); -        const followLinks = linkDocList.length ? (sourceDoc.isPushpin ? linkDocList : [linkDocList[0]]) : []; +        const followLinks = sourceDoc.isPushpin ? linkDocList : linkDocList.slice(0, 1); +        var count = 0; +        const allFinished = () => ++count === followLinks.length && finished?.();          followLinks.forEach(async linkDoc => {              if (linkDoc) {                  const target = (sourceDoc === linkDoc.anchor1 ? linkDoc.anchor2 : sourceDoc === linkDoc.anchor2 ? linkDoc.anchor1 : @@ -232,20 +237,20 @@ export class LinkManager {                          const tour = DocListCast(target[fieldKey]).reverse();                          LightboxView.SetLightboxDoc(currentContext, undefined, tour);                          setTimeout(LightboxView.Next); -                        finished?.(); +                        allFinished();                      } else {                          const containerAnnoDoc = Cast(target.annotationOn, Doc, null);                          const containerDoc = containerAnnoDoc || target;                          const containerDocContext = Cast(containerDoc?.context, Doc, null);                          const targetContext = LightboxView.LightboxDoc ? containerAnnoDoc || containerDocContext : containerDocContext;                          const targetNavContext = !Doc.AreProtosEqual(targetContext, currentContext) ? targetContext : undefined; -                        DocumentManager.Instance.jumpToDocument(target, zoom, (doc, finished) => createViewFunc(doc, StrCast(linkDoc.followLinkLocation, "lightbox"), finished), targetNavContext, linkDoc, undefined, sourceDoc, finished); +                        DocumentManager.Instance.jumpToDocument(target, zoom, (doc, finished) => createViewFunc(doc, StrCast(linkDoc.followLinkLocation, "lightbox"), finished), targetNavContext, linkDoc, undefined, sourceDoc, allFinished);                      }                  } else { -                    finished?.(); +                    allFinished();                  }              } else { -                finished?.(); +                allFinished();              }          });      } | 
