aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormonikahedman <monika_hedman@brown.edu>2019-08-22 19:42:54 -0400
committermonikahedman <monika_hedman@brown.edu>2019-08-22 19:42:54 -0400
commit1fb290bcc1c46214cfd553f31c1282d2694530ea (patch)
treece1771d0a5db7ad7c88680c9a0d05033f32b8289 /src
parent5c9f40006aa157c58ec40828ebd4845c16daa8af (diff)
making the box come up
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts4
-rw-r--r--src/client/views/MainView.tsx2
-rw-r--r--src/client/views/linking/LinkFollowBox.scss2
-rw-r--r--src/client/views/linking/LinkFollowBox.tsx87
-rw-r--r--src/client/views/linking/LinkMenuItem.tsx12
5 files changed, 73 insertions, 34 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index cd612aaa9..b7c8f4c12 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -446,6 +446,10 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.DRAGBOX), undefined, { ...(options || {}) });
}
+ export function LinkFollowBoxDocument(options?: DocumentOptions) {
+ return InstanceFromProto(Prototypes.get(DocumentType.LINKFOLLOW), undefined, { ...(options || {}) });
+ }
+
export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, viewType: CollectionViewType.Docking, dockingConfig: config }, id);
}
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index f3c8a176c..79c44ae72 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -443,6 +443,7 @@ export class MainView extends React.Component {
let imgurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg";
let addColNode = action(() => Docs.Create.FreeformDocument([], { width: this.pwidth * .7, height: this.pheight, title: "a freeform collection" }));
+ let addLinkFollowBox = action(() => Docs.Create.LinkFollowBoxDocument({ width: 200, height: 500, title: "Link Follow Document" }));
let addPresNode = action(() => Doc.UserDoc().curPresentation = Docs.Create.PresDocument(new List<Doc>(), { width: 200, height: 500, title: "a presentation trail" }));
let addWebNode = action(() => Docs.Create.WebDocument("https://en.wikipedia.org/wiki/Hedgehog", { width: 300, height: 300, title: "New Webpage" }));
let addDragboxNode = action(() => Docs.Create.DragboxDocument({ width: 40, height: 40, title: "drag collection" }));
@@ -458,6 +459,7 @@ export class MainView extends React.Component {
[React.createRef<HTMLDivElement>(), "globe-asia", "Add Website", addWebNode],
[React.createRef<HTMLDivElement>(), "bolt", "Add Button", addButtonDocument],
[React.createRef<HTMLDivElement>(), "file", "Add Document Dragger", addDragboxNode],
+ [React.createRef<HTMLDivElement>(), "caret-up", "Open Link Follow Box", addLinkFollowBox],
[React.createRef<HTMLDivElement>(), "cloud-upload-alt", "Import Directory", addImportCollectionNode], //remove at some point in favor of addImportCollectionNode
//[React.createRef<HTMLDivElement>(), "play", "Add Youtube Searcher", addYoutubeSearcher],
];
diff --git a/src/client/views/linking/LinkFollowBox.scss b/src/client/views/linking/LinkFollowBox.scss
index c764b002f..522191792 100644
--- a/src/client/views/linking/LinkFollowBox.scss
+++ b/src/client/views/linking/LinkFollowBox.scss
@@ -2,5 +2,5 @@
.linkFollowBox-main {
position: absolute;
- background: $main-accent;
+ background: red;
} \ No newline at end of file
diff --git a/src/client/views/linking/LinkFollowBox.tsx b/src/client/views/linking/LinkFollowBox.tsx
index 7fc4449d3..247b67776 100644
--- a/src/client/views/linking/LinkFollowBox.tsx
+++ b/src/client/views/linking/LinkFollowBox.tsx
@@ -9,13 +9,22 @@ import { CollectionViewType } from "../collections/CollectionBaseView";
import { CollectionDockingView } from "../collections/CollectionDockingView";
import { SelectionManager } from "../../util/SelectionManager";
import { DocumentManager } from "../../util/DocumentManager";
+import { DocumentView } from "../nodes/DocumentView";
+import "./LinkFollowBox.scss";
+
+export type LinkParamOptions = {
+ container: Doc;
+ context: Doc;
+ sourceDoc: Doc;
+ shoudldZoom: boolean;
+ linkDoc: Doc;
+};
@observer
export class LinkFollowBox extends React.Component<FieldViewProps> {
public static LayoutString() { return FieldView.LayoutString(LinkFollowBox); }
public static Instance: LinkFollowBox;
- //set this to be the default link behavior, can be any of the above
unhighlight = () => {
Doc.UnhighlightAll();
@@ -31,19 +40,32 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
}, 10000);
}
+ // DONE
+ @undoBatch
+ openFullScreen = (destinationDoc: Doc) => {
+ let view: DocumentView | null = DocumentManager.Instance.getDocumentView(destinationDoc)
+ view && CollectionDockingView.Instance && CollectionDockingView.Instance.OpenFullScreen(view);
+ }
+
+ // should container be a doc or documentview or what? This one needs work and is more long term
+ @undoBatch
+ openInContainer = (destinationDoc: Doc, options: { container: Doc }) => {
+
+ }
+
// NOT TESTED
// col = collection the doc is in
// target = the document to center on
@undoBatch
- openLinkColRight = (destinationDoc: Doc, col: Doc) => {
- col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
- if (NumCast(col.viewType, CollectionViewType.Invalid) === CollectionViewType.Freeform) {
+ openLinkColRight = (destinationDoc: Doc, options: { context: Doc }) => {
+ options.context = Doc.IsPrototype(options.context) ? Doc.MakeDelegate(options.context) : options.context;
+ if (NumCast(options.context.viewType, CollectionViewType.Invalid) === CollectionViewType.Freeform) {
const newPanX = NumCast(destinationDoc.x) + NumCast(destinationDoc.width) / NumCast(destinationDoc.zoomBasis, 1) / 2;
const newPanY = NumCast(destinationDoc.y) + NumCast(destinationDoc.height) / NumCast(destinationDoc.zoomBasis, 1) / 2;
- col.panX = newPanX;
- col.panY = newPanY;
+ options.context.panX = newPanX;
+ options.context.panY = newPanY;
}
- CollectionDockingView.Instance.AddRightSplit(col, undefined);
+ CollectionDockingView.Instance.AddRightSplit(options.context, undefined);
}
// DONE
@@ -60,39 +82,39 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
// this is the standard "follow link" (jump to document)
// taken from follow link
@undoBatch
- jumpToLink = async (destinationDoc: Doc, shouldZoom: boolean, linkDoc: Doc) => {
+ jumpToLink = async (destinationDoc: Doc, options: { shouldZoom: boolean, linkDoc: Doc }) => {
//there is an issue right now so this will be false automatically
- shouldZoom = false;
+ options.shouldZoom = false;
this.highlightDoc(destinationDoc);
let jumpToDoc = destinationDoc;
let pdfDoc = FieldValue(Cast(destinationDoc, Doc));
if (pdfDoc) {
jumpToDoc = pdfDoc;
}
- let proto = Doc.GetProto(linkDoc);
+ let proto = Doc.GetProto(options.linkDoc);
let targetContext = await Cast(proto.targetContext, Doc);
let sourceContext = await Cast(proto.sourceContext, Doc);
let dockingFunc = (document: Doc) => { this.props.addDocTab(document, undefined, "inTab"); SelectionManager.DeselectAll(); };
- if (destinationDoc === linkDoc.anchor2 && targetContext) {
- DocumentManager.Instance.jumpToDocument(jumpToDoc, shouldZoom, false, async document => dockingFunc(document), undefined, targetContext);
+ if (destinationDoc === options.linkDoc.anchor2 && targetContext) {
+ DocumentManager.Instance.jumpToDocument(jumpToDoc, options.shouldZoom, false, async document => dockingFunc(document), undefined, targetContext);
}
- else if (destinationDoc === linkDoc.anchor1 && sourceContext) {
- DocumentManager.Instance.jumpToDocument(jumpToDoc, shouldZoom, false, document => dockingFunc(sourceContext!));
+ else if (destinationDoc === options.linkDoc.anchor1 && sourceContext) {
+ DocumentManager.Instance.jumpToDocument(jumpToDoc, options.shouldZoom, false, document => dockingFunc(sourceContext!));
}
else if (DocumentManager.Instance.getDocumentView(jumpToDoc)) {
- DocumentManager.Instance.jumpToDocument(jumpToDoc, shouldZoom, undefined, undefined, NumCast((destinationDoc === linkDoc.anchor2 ? linkDoc.anchor2Page : linkDoc.anchor1Page)));
+ DocumentManager.Instance.jumpToDocument(jumpToDoc, options.shouldZoom, undefined, undefined, NumCast((destinationDoc === options.linkDoc.anchor2 ? options.linkDoc.anchor2Page : options.linkDoc.anchor1Page)));
}
else {
- DocumentManager.Instance.jumpToDocument(jumpToDoc, shouldZoom, false, dockingFunc);
+ DocumentManager.Instance.jumpToDocument(jumpToDoc, options.shouldZoom, false, dockingFunc);
}
}
// DONE
// opens link in new tab (not in a collection)
- // this opens it full screen, do we need a separate full screen option?
+ // this opens it full screen in new tab
@undoBatch
openLinkTab = (destinationDoc: Doc) => {
this.highlightDoc(destinationDoc);
@@ -106,32 +128,32 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
// col = collection the doc is in
// target = the document to center on
@undoBatch
- openLinkColTab = (destinationDoc: Doc, col: Doc) => {
+ openLinkColTab = (destinationDoc: Doc, options: { context: Doc }) => {
this.highlightDoc(destinationDoc);
- col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
- if (NumCast(col.viewType, CollectionViewType.Invalid) === CollectionViewType.Freeform) {
+ options.context = Doc.IsPrototype(options.context) ? Doc.MakeDelegate(options.context) : options.context;
+ if (NumCast(options.context.viewType, CollectionViewType.Invalid) === CollectionViewType.Freeform) {
const newPanX = NumCast(destinationDoc.x) + NumCast(destinationDoc.width) / NumCast(destinationDoc.zoomBasis, 1) / 2;
const newPanY = NumCast(destinationDoc.y) + NumCast(destinationDoc.height) / NumCast(destinationDoc.zoomBasis, 1) / 2;
- col.panX = newPanX;
- col.panY = newPanY;
+ options.context.panX = newPanX;
+ options.context.panY = newPanY;
}
// CollectionDockingView.Instance.AddRightSplit(col, undefined);
- this.props.addDocTab(col, undefined, "inTab");
+ this.props.addDocTab(options.context, undefined, "inTab");
SelectionManager.DeselectAll();
}
// DONE
// this will open a link next to the source doc
@undoBatch
- openLinkInPlace = (destinationDoc: Doc, sourceDoc: Doc) => {
+ openLinkInPlace = (destinationDoc: Doc, options: { sourceDoc: Doc }) => {
this.highlightDoc(destinationDoc);
let alias = Doc.MakeAlias(destinationDoc);
- let y = NumCast(sourceDoc.y);
- let x = NumCast(sourceDoc.x);
+ let y = NumCast(options.sourceDoc.y);
+ let x = NumCast(options.sourceDoc.x);
- let width = NumCast(sourceDoc.width);
- let height = NumCast(sourceDoc.height);
+ let width = NumCast(options.sourceDoc.width);
+ let height = NumCast(options.sourceDoc.height);
alias.x = x + width + 30;
alias.y = y;
@@ -139,18 +161,19 @@ export class LinkFollowBox extends React.Component<FieldViewProps> {
alias.height = height;
SelectionManager.SelectedDocuments().map(dv => {
- if (dv.props.Document === sourceDoc) {
+ if (dv.props.Document === options.sourceDoc) {
dv.props.addDocument && dv.props.addDocument(alias, false);
}
});
}
- private defaultLinkBehavior: any = this.openLinkInPlace;
- private currentLinkBehavior: any = this.defaultLinkBehavior;
+ //set this to be the default link behavior, can be any of the above
+ private defaultLinkBehavior: (destinationDoc: Doc, options?: any) => void = this.openLinkInPlace;
+ private currentLinkBehavior: (destinationDoc: Doc, options?: any) => void = this.defaultLinkBehavior;
render() {
return (
- <div className="linkFollowBox-main">
+ <div className="linkFollowBox-main" style={{ height: NumCast(this.props.Document.height), width: NumCast(this.props.Document.width) }}>
</div>
);
diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index 41723030d..60f27c664 100644
--- a/src/client/views/linking/LinkMenuItem.tsx
+++ b/src/client/views/linking/LinkMenuItem.tsx
@@ -15,6 +15,7 @@ import { CollectionDockingView } from '../collections/CollectionDockingView';
import { SelectionManager } from '../../util/SelectionManager';
import { CollectionViewType } from '../collections/CollectionBaseView';
import { DocumentView } from '../nodes/DocumentView';
+import { SearchUtil } from '../../util/SearchUtil';
library.add(faEye, faEdit, faTimes, faArrowRight, faChevronDown, faChevronUp);
@@ -64,6 +65,13 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
}
// DONE
+ @undoBatch
+ openFullScreen = () => {
+ let view: DocumentView | null = DocumentManager.Instance.getDocumentView(this.props.destinationDoc);
+ view && CollectionDockingView.Instance && CollectionDockingView.Instance.OpenFullScreen(view);
+ }
+
+ // DONE
// this opens the linked doc in a right split, NOT in its collection
@undoBatch
openLinkRight = () => {
@@ -161,10 +169,12 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
dv.props.addDocument && dv.props.addDocument(alias, false);
}
});
+
+ this.jumpToLink(false);
}
//set this to be the default link behavior, can be any of the above
- private defaultLinkBehavior: any = this.openLinkInPlace;
+ private defaultLinkBehavior: any = this.openLinkTab;
onEdit = (e: React.PointerEvent): void => {
e.stopPropagation();