From 4a64d3819081f916dd74233c222c0b2a2cc93d81 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 29 Mar 2024 12:05:05 -0400 Subject: fixed making strokes able to allow followTarget click funcs to what they're linked to. Made it possible to render links to links. avoid deleting links when switching tabs/closing app. --- src/client/views/nodes/DocumentView.tsx | 4 +++- src/client/views/nodes/LinkBox.tsx | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/client/views/nodes') diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 6d8656888..3e8d672d6 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -50,6 +50,7 @@ import { KeyValueBox } from './KeyValueBox'; import { LinkAnchorBox } from './LinkAnchorBox'; import { FormattedTextBox } from './formattedText/FormattedTextBox'; import { PresEffect, PresEffectDirection } from './trails'; +import { InkingStroke } from '../InkingStroke'; interface Window { MediaRecorder: MediaRecorder; } @@ -200,6 +201,7 @@ export class DocumentViewInternal extends DocComponent() { const anchor = anch?.layout_unrendered ? DocCast(anch.annotationOn) : anch; return DocumentManager.Instance.getDocumentView(anchor, this.DocumentView?.().containerViewPath?.().lastElement()); }; + _hackToSeeIfDeleted: any; componentWillUnmount() { + this._hackToSeeIfDeleted && clearTimeout(this._hackToSeeIfDeleted); Object.keys(this._disposers).forEach(key => this._disposers[key]()); } componentDidMount() { this._props.setContentViewBox?.(this); this._disposers.deleting = reaction( () => !this.anchor1 || !this.anchor2, - empty => empty && this._props.removeDocument?.(this.Document) + empty => empty && (this._hackToSeeIfDeleted = setTimeout(() => this._props.removeDocument?.(this.Document), 1000)) ); this._disposers.dragging = reaction( () => ({ drag: SnappingManager.IsDragging }), @@ -100,8 +102,10 @@ export class LinkBox extends ViewBoxBaseComponent() { var foundParent = false; const getAnchor = (field: FieldResult): Element[] => { - const doc = DocCast(field); + const docField = DocCast(field); + const doc = docField?.layout_unrendered ? DocCast(docField.annotationOn, docField) : docField; const ele = document.getElementById(doc[Id]); + if (ele?.className === 'linkBox-label') foundParent = true; if (ele?.getBoundingClientRect().width) return [ele]; const eles = Array.from(document.getElementsByClassName(doc[Id])).filter(ele => ele?.getBoundingClientRect().width); const annoOn = DocCast(doc.annotationOn); @@ -124,7 +128,10 @@ export class LinkBox extends ViewBoxBaseComponent() { return null; } if (foundParent) { - setTimeout(action(() => (this._forceAnimate = this._forceAnimate + 1))); + setTimeout( + action(() => (this._forceAnimate = this._forceAnimate + 0.01)), + 1 + ); } if (at || bt) setTimeout(action(() => (this._forceAnimate = this._forceAnimate + 0.01))); // this forces an update during a transition animation @@ -171,6 +178,8 @@ export class LinkBox extends ViewBoxBaseComponent() { color={color} labels={