aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-06-19 12:50:58 -0400
committerFawn <fangrui_tong@brown.edu>2019-06-19 12:50:58 -0400
commitf362dbfc237536c6c4a8c6d088c3dc818080f7c2 (patch)
tree99088a6afb1a26752a808d249eff40e2818639ed /src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx
parent8e5afb5bbb47324a381b5184254e77eba7bd8536 (diff)
both tail ends of a cut link appear on hover/focus of an anchor
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx
new file mode 100644
index 000000000..81a00ba95
--- /dev/null
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkWithProxyView.tsx
@@ -0,0 +1,60 @@
+import { observer } from "mobx-react";
+import { Doc, HeightSym, WidthSym } from "../../../../new_fields/Doc";
+import { BoolCast, NumCast, StrCast } from "../../../../new_fields/Types";
+import { InkingControl } from "../../InkingControl";
+import "./CollectionFreeFormLinkView.scss";
+import React = require("react");
+import v5 = require("uuid/v5");
+import { DocumentView } from "../../nodes/DocumentView";
+import { Docs } from "../../../documents/Documents";
+import { observable } from "mobx";
+
+export interface CollectionFreeFormLinkViewProps {
+ sourceView: DocumentView;
+ targetView: DocumentView;
+ proxyDoc: Doc;
+ addDocTab: (document: Doc, where: string) => void;
+}
+
+@observer
+export class CollectionFreeFormLinkWithProxyView extends React.Component<CollectionFreeFormLinkViewProps> {
+
+ // @observable private _proxyX: number = NumCast(this.props.proxyDoc.x);
+ // @observable private _proxyY: number = NumCast(this.props.proxyDoc.y);
+
+ followButton = (e: React.PointerEvent): void => {
+ // TODO: would be nicer to open docview in context
+ e.stopPropagation();
+ console.log("follow");
+ this.props.addDocTab(this.props.targetView.props.Document, "onRight");
+ }
+
+ render() {
+ let a1 = this.props.sourceView;
+ let a2 = this.props.proxyDoc;
+ let x1 = NumCast(a1.Document.x) + (BoolCast(a1.Document.isMinimized, false) ? 5 : NumCast(a1.Document.width) / NumCast(a1.Document.zoomBasis, 1) / 2);
+ let y1 = NumCast(a1.Document.y) + (BoolCast(a1.Document.isMinimized, false) ? 5 : NumCast(a1.Document.height) / NumCast(a1.Document.zoomBasis, 1) / 2);
+
+ let x2 = NumCast(a2.x) + (BoolCast(a2.isMinimized, false) ? 5 : NumCast(a2.width) / NumCast(a2.zoomBasis, 1) / 2);
+ let y2 = NumCast(a2.y) + (BoolCast(a2.isMinimized, false) ? 5 : NumCast(a2.height) / NumCast(a2.zoomBasis, 1) / 2);
+
+ // let containing = "";
+ // if (this.props.targetView.props.ContainingCollectionView) {
+ // containing = StrCast(this.props.targetView.props.ContainingCollectionView.props.Document.title);
+ // }
+
+ // let text = "link to " + StrCast(this.props.targetView.props.Document.title) + (containing === "" ? "" : (" in the context of " + containing));
+ return (
+ <>
+ <line className="collectionfreeformlinkview-linkLine"
+ style={{ strokeWidth: `${2 * 1 / 2}` }}
+ x1={`${x1}`} y1={`${y1}`}
+ x2={`${x2}`} y2={`${y2}`} />
+ {/* <circle className="collectionfreeformlinkview-linkCircle" cx={x2} cy={y2} r={20} ></circle>
+ <text textAnchor="middle" className="collectionfreeformlinkview-linkText" x={`${x2}`} y={`${y2}`}> {text}</text> */}
+ </>
+ );
+ }
+}
+
+//onPointerDown={this.followButton} \ No newline at end of file