From 67435353b39071fbe3295cc80e35ee3df952f082 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 19 Nov 2020 10:11:29 -0500 Subject: made inkingStroke honor _isBackground. prevented link anchor dots from moving when target isn't visible. made ui option for showing/hiding link lines and for autoMoving anchor dots. --- src/client/views/InkingStroke.tsx | 6 ++-- .../CollectionFreeFormLinkView.tsx | 15 ++++++---- src/client/views/linking/LinkMenuItem.tsx | 34 ++++++++++++++++++---- 3 files changed, 41 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index 7e424d8f0..5fd9d5fe4 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -120,7 +120,7 @@ export class InkingStroke extends ViewBoxBaseComponent 5 ? strokeColor : "transparent", strokeWidth, (strokeWidth + 15), StrCast(this.layoutDoc.strokeBezier), StrCast(this.layoutDoc.fillColor, "none"), - "none", "none", undefined, scaleX, scaleY, "", "visiblepainted", false, true); + "none", "none", undefined, scaleX, scaleY, "", this.props.Document._isBackground ? "none" : "visiblepainted", false, true); //points for adding const apoints = InteractionUtils.CreatePoints(data, left, top, strokeColor, strokeWidth, strokeWidth, @@ -178,7 +178,7 @@ export class InkingStroke extends ViewBoxBaseComponent this.onControlDown(e, pts.I)} pointerEvents="all" cursor="all-scroll" display={(pts.dot1 === formatInstance._currPoint || pts.dot2 === formatInstance._currPoint) ? "inherit" : "none"} /> ); const handleLines = handleLine.map((pts, i) => - + @@ -191,7 +191,7 @@ export class InkingStroke extends ViewBoxBaseComponent this._opacity = 1), 0); // since the render code depends on querying the Dom through getBoudndingClientRect, we need to delay triggering render() setTimeout(action(() => (!LinkDocs.length || !linkDoc.linkDisplay) && (this._opacity = 0.05)), 750); // this will unhighlight the link line. + if (!linkDoc.linkAutoMove) return; const acont = A.props.Document.type === DocumentType.LINK ? A.ContentDiv.getElementsByClassName("linkAnchorBox-cont") : []; const bcont = B.props.Document.type === DocumentType.LINK ? B.ContentDiv.getElementsByClassName("linkAnchorBox-cont") : []; const adiv = (acont.length ? acont[0] : A.ContentDiv); @@ -60,6 +61,7 @@ export class CollectionFreeFormLinkView extends React.Component ele.dataset.targetids?.includes((linkDoc[afield] as Doc)[Id])); const targetBhyperlink = linkEles.find((ele: any) => ele.dataset.targetids?.includes((linkDoc[bfield] as Doc)[Id])); + if ((!targetAhyperlink && !a.width) || (!targetBhyperlink && !b.width)) return; if (!targetBhyperlink) { A.rootDoc[afield + "_x"] = (apt.point.x - aleft) / awidth * 100; A.rootDoc[afield + "_y"] = (apt.point.y - atop) / aheight * 100; @@ -101,8 +103,8 @@ export class CollectionFreeFormLinkView extends React.Component { @undoBatch @action - showLink = () => { - this.props.linkDoc.hidden = !this.props.linkDoc.hidden; + autoMove = (e: React.PointerEvent) => { + e.stopPropagation(); + this.props.linkDoc.linkAutoMove = !this.props.linkDoc.linkAutoMove; } - render() { + @undoBatch + @action + showLink = (e: React.PointerEvent) => { + e.stopPropagation(); + this.props.linkDoc.linkDisplay = !this.props.linkDoc.linkDisplay; + } - const eyeIcon = this.props.linkDoc.hidden ? "eye-slash" : "eye"; + @undoBatch + @action + showAnchor = (e: React.PointerEvent) => { + e.stopPropagation(); + this.props.linkDoc.hidden = !this.props.linkDoc.hidden; + } + render() { let destinationIcon: FontAwesomeIconProps["icon"] = "question"; switch (this.props.destinationDoc.type) { case DocumentType.IMG: destinationIcon = "image"; break; @@ -243,9 +255,19 @@ export class LinkMenuItem extends React.Component {
-
{this.props.linkDoc.hidden ? "Show link" : "Hide link"}
}> +
{this.props.linkDoc.hidden ? "Show Anchor" : "Hide Anchor"}
}> +
+
+
+ +
{!this.props.linkDoc.linkDisplay ? "Show link" : "Hide link"}
}>
-
+
+ + +
{!this.props.linkDoc.linkAutoMove ? "Auto move dot" : "Freeze dot position"}
}> +
+
Edit Link
}> -- cgit v1.2.3-70-g09d2