From 30928b9bd3a90a04f5735e0ffbf92d0f74ad5d7d Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 9 Feb 2021 19:57:29 -0500 Subject: cleanup of formattedtextboxcomment and linkDocPreview --- src/client/views/nodes/LinkDocPreview.tsx | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/client/views/nodes/LinkDocPreview.tsx') diff --git a/src/client/views/nodes/LinkDocPreview.tsx b/src/client/views/nodes/LinkDocPreview.tsx index 04a407eab..b1410e1f6 100644 --- a/src/client/views/nodes/LinkDocPreview.tsx +++ b/src/client/views/nodes/LinkDocPreview.tsx @@ -80,15 +80,17 @@ export class LinkDocPreview extends React.Component { } else { const anchorDoc = href.replace(Utils.prepend("/doc/"), "").split("?")[0]; anchorDoc && DocServer.GetRefField(anchorDoc).then(action(async anchor => { - if (anchor instanceof Doc) { + if (anchor instanceof Doc && DocListCast(anchor.links).length) { this._linkDoc = DocListCast(anchor.links)[0]; this._linkSrc = anchor; const targetanchor = LinkManager.getOppositeAnchor(this._linkDoc, this._linkSrc); runInAction(async () => { this._linkTarget = targetanchor; const target = this._linkTarget?.annotationOn ? await DocCastAsync(this._linkTarget.annotationOn) : this._linkTarget; - this._toolTipText = ""; - runInAction(() => this._targetDoc = target); + runInAction(() => { + this._toolTipText = ""; + this._targetDoc = target; + }); }); } })); @@ -99,8 +101,10 @@ export class LinkDocPreview extends React.Component { runInAction(async () => { this._linkTarget = Doc.AreProtosEqual(anchor1, linkSrc) || Doc.AreProtosEqual(anchor1.annotationOn as Doc, linkSrc) ? anchor2 : anchor1; const target = this._linkTarget?.annotationOn ? await DocCastAsync(this._linkTarget.annotationOn) : this._linkTarget; - this._toolTipText = ""; - runInAction(() => this._targetDoc = target); + runInAction(() => { + this._toolTipText = ""; + this._targetDoc = target; + }); }); } } @@ -125,22 +129,22 @@ export class LinkDocPreview extends React.Component { height = () => Math.min(225, NumCast(this._targetDoc?.[HeightSym](), 225)); @computed get previewHeader() { return !this._linkDoc || !this._targetDoc || !this._linkSrc ? (null) : -
-
+
+
{StrCast(this._targetDoc.title).length > 16 ? StrCast(this._targetDoc.title).substr(0, 16) + "..." : this._targetDoc.title} -

{StrCast(this._linkDoc.description)}

+

{StrCast(this._linkDoc.description)}

{(this.props.hrefs?.length || 0) <= 1 ? (null) : Next Link
} placement="top"> -
- +
+
} Delete Link
} placement="top"> -
- +
+
@@ -149,15 +153,15 @@ export class LinkDocPreview extends React.Component { @computed get docPreview() { return (!this._linkDoc || !this._targetDoc || !this._linkSrc) && !this._toolTipText ? (null) : -
+
{!this.props.showHeader ? (null) : this.previewHeader} -
+
{this._toolTipText ? this._toolTipText : { const targetanchor = LinkManager.getOppositeAnchor(this._linkDoc!, this._linkSrc!); targetanchor && this._targetDoc !== targetanchor && r?.focus(targetanchor); }} - Document={this._targetDoc} + Document={this._targetDoc!} moveDocument={returnFalse} rootSelected={returnFalse} styleProvider={this.props.docprops?.styleProvider} @@ -194,4 +198,4 @@ export class LinkDocPreview extends React.Component { {this.docPreview}
; } -} +} \ No newline at end of file -- cgit v1.2.3-70-g09d2