aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/LinkFollower.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-01-04 10:18:57 -0500
committerbobzel <zzzman@gmail.com>2024-01-04 10:18:57 -0500
commitebf32ac65d35053f847fb2cf60f915eb29d6fdd5 (patch)
treeaca380ddebb208b8114f75ba7cc07d24ab4158f6 /src/client/util/LinkFollower.ts
parentd1b3d3d852e6b8eed7949b17f566a59d97a2dcf4 (diff)
fixed text references to docs or fields to create docs that don't exist. fixed IsLinkFollowing observable by not making static (to fix docDecorations not appearing after link following)
Diffstat (limited to 'src/client/util/LinkFollower.ts')
-rw-r--r--src/client/util/LinkFollower.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/client/util/LinkFollower.ts b/src/client/util/LinkFollower.ts
index 146eed6c2..2df4d1ca8 100644
--- a/src/client/util/LinkFollower.ts
+++ b/src/client/util/LinkFollower.ts
@@ -10,6 +10,7 @@ import { LinkManager } from './LinkManager';
import { ScriptingGlobals } from './ScriptingGlobals';
import { SelectionManager } from './SelectionManager';
import { UndoManager } from './UndoManager';
+import { SnappingManager } from './SnappingManager';
/*
* link doc:
* - link_anchor_1: doc
@@ -23,19 +24,18 @@ import { UndoManager } from './UndoManager';
* - user defined kvps
*/
export class LinkFollower {
- @observable public static IsFollowing = false;
// follows a link - if the target is on screen, it highlights/pans to it.
// if the target isn't onscreen, then it will open up the target in the lightbox, or in place
// depending on the followLinkLocation property of the source (or the link itself as a fallback);
public static FollowLink = (linkDoc: Opt<Doc>, sourceDoc: Doc, altKey: boolean) => {
const batch = UndoManager.StartBatch('Follow Link');
- runInAction(() => (LinkFollower.IsFollowing = true)); // turn off decoration bounds while following links since animations may occur, and DocDecorations is based on screenToLocal which is not always an observable value
+ runInAction(() => SnappingManager.SetIsLinkFollowing(true)); // turn off decoration bounds while following links since animations may occur, and DocDecorations is based on screenToLocal which is not always an observable value
return LinkFollower.traverseLink(
linkDoc,
sourceDoc,
action(() => {
batch.end();
- Doc.AddUnHighlightWatcher(action(() => (LinkFollower.IsFollowing = false)));
+ Doc.AddUnHighlightWatcher(() => SnappingManager.SetIsLinkFollowing(false));
}),
altKey ? true : undefined
);
@@ -63,10 +63,10 @@ export class LinkFollower {
sourceDoc === linkDoc.link_anchor_1
? linkDoc.link_anchor_2
: sourceDoc === linkDoc.link_anchor_2
- ? linkDoc.link_anchor_1
- : Doc.AreProtosEqual(sourceDoc, linkDoc.link_anchor_1 as Doc) || Doc.AreProtosEqual((linkDoc.link_anchor_1 as Doc).annotationOn as Doc, sourceDoc)
- ? linkDoc.link_anchor_2
- : linkDoc.link_anchor_1
+ ? linkDoc.link_anchor_1
+ : Doc.AreProtosEqual(sourceDoc, linkDoc.link_anchor_1 as Doc) || Doc.AreProtosEqual((linkDoc.link_anchor_1 as Doc).annotationOn as Doc, sourceDoc)
+ ? linkDoc.link_anchor_2
+ : linkDoc.link_anchor_1
) as Doc;
const srcAnchor = LinkManager.getOppositeAnchor(linkDoc, target) ?? sourceDoc;
if (target) {