aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-06-25 17:09:36 -0400
committerFawn <fangrui_tong@brown.edu>2019-06-25 17:09:36 -0400
commit41cf1e8536964764f18ab752140e484e36cbe464 (patch)
treee6daba46778d099620bd91808a54d615304706fb /src/client/documents/Documents.ts
parent522970375fe0227f9221a7e8be02875afd74ca63 (diff)
links can save
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts58
1 files changed, 15 insertions, 43 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 64032e096..fbd96fb66 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -35,8 +35,8 @@ import { DateField } from "../../new_fields/DateField";
import { UndoManager } from "../util/UndoManager";
import { RouteStore } from "../../server/RouteStore";
import { LinkManager } from "../util/LinkManager";
-import { LinkButtonBox } from "../views/nodes/LinkButtonBox";
-import { LinkButtonField, LinkButtonData } from "../../new_fields/LinkButtonField";
+// import { LinkButtonBox } from "../views/nodes/LinkButtonBox";
+// import { LinkButtonField, LinkButtonData } from "../../new_fields/LinkButtonField";
import { DocumentManager } from "../util/DocumentManager";
import { Id } from "../../new_fields/FieldSymbols";
var requestImageSize = require('request-image-size');
@@ -100,6 +100,7 @@ export namespace DocUtils {
let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1 });
let linkDocProto = Doc.GetProto(linkDoc);
+ linkDocProto.context = targetContext;
linkDocProto.title = title; //=== "" ? source.title + " to " + target.title : title;
linkDocProto.linkDescription = description;
linkDocProto.linkTags = tags;
@@ -111,36 +112,7 @@ export namespace DocUtils {
linkDocProto.anchor2Page = target.curPage;
linkDocProto.anchor2Groups = new List<Doc>([]);
- linkDocProto.context = targetContext;
-
- let sourceViews = DocumentManager.Instance.getDocumentViews(source);
- let targetViews = DocumentManager.Instance.getDocumentViews(target);
- sourceViews.forEach(sv => {
- targetViews.forEach(tv => {
-
- // TODO: do only for when diff contexts
- let proxy1 = Docs.LinkButtonDocument(
- { sourceViewId: StrCast(sv.props.Document[Id]), targetViewId: StrCast(tv.props.Document[Id]) },
- { width: 200, height: 100, borderRounding: 0 });
- let proxy1Proto = Doc.GetProto(proxy1);
- proxy1Proto.sourceViewId = StrCast(sv.props.Document[Id]);
- proxy1Proto.targetViewId = StrCast(tv.props.Document[Id]);
- proxy1Proto.isLinkButton = true;
-
- let proxy2 = Docs.LinkButtonDocument(
- { sourceViewId: StrCast(tv.props.Document[Id]), targetViewId: StrCast(sv.props.Document[Id]) },
- { width: 200, height: 100, borderRounding: 0 });
- let proxy2Proto = Doc.GetProto(proxy2);
- proxy2Proto.sourceViewId = StrCast(tv.props.Document[Id]);
- proxy2Proto.targetViewId = StrCast(sv.props.Document[Id]);
- proxy2Proto.isLinkButton = true;
-
- LinkManager.Instance.linkProxies.push(proxy1);
- LinkManager.Instance.linkProxies.push(proxy2);
- });
- });
-
- LinkManager.Instance.allLinks.push(linkDoc);
+ LinkManager.Instance.addLink(linkDoc);
return linkDoc;
}, "make link");
@@ -160,7 +132,7 @@ export namespace Docs {
let audioProto: Doc;
let pdfProto: Doc;
let iconProto: Doc;
- let linkProto: Doc;
+ // let linkProto: Doc;
const textProtoId = "textProto";
const histoProtoId = "histoProto";
const pdfProtoId = "pdfProto";
@@ -171,7 +143,7 @@ export namespace Docs {
const videoProtoId = "videoProto";
const audioProtoId = "audioProto";
const iconProtoId = "iconProto";
- const linkProtoId = "linkProto";
+ // const linkProtoId = "linkProto";
export function initProtos(): Promise<void> {
return DocServer.GetRefFields([textProtoId, histoProtoId, collProtoId, imageProtoId, webProtoId, kvpProtoId, videoProtoId, audioProtoId, pdfProtoId, iconProtoId]).then(fields => {
@@ -185,7 +157,7 @@ export namespace Docs {
audioProto = fields[audioProtoId] as Doc || CreateAudioPrototype();
pdfProto = fields[pdfProtoId] as Doc || CreatePdfPrototype();
iconProto = fields[iconProtoId] as Doc || CreateIconPrototype();
- linkProto = fields[linkProtoId] as Doc || CreateLinkPrototype();
+ // linkProto = fields[linkProtoId] as Doc || CreateLinkPrototype();
});
}
@@ -218,11 +190,11 @@ export namespace Docs {
{ x: 0, y: 0, width: Number(MINIMIZED_ICON_SIZE), height: Number(MINIMIZED_ICON_SIZE) });
return iconProto;
}
- function CreateLinkPrototype(): Doc {
- let linkProto = setupPrototypeOptions(linkProtoId, "LINK_PROTO", LinkButtonBox.LayoutString(),
- { x: 0, y: 0, width: 300 });
- return linkProto;
- }
+ // function CreateLinkPrototype(): Doc {
+ // let linkProto = setupPrototypeOptions(linkProtoId, "LINK_PROTO", LinkButtonBox.LayoutString(),
+ // { x: 0, y: 0, width: 300 });
+ // return linkProto;
+ // }
function CreateTextPrototype(): Doc {
let textProto = setupPrototypeOptions(textProtoId, "TEXT_PROTO", FormattedTextBox.LayoutString(),
{ x: 0, y: 0, width: 300, backgroundColor: "#f1efeb" });
@@ -309,9 +281,9 @@ export namespace Docs {
export function IconDocument(icon: string, options: DocumentOptions = {}) {
return CreateInstance(iconProto, new IconField(icon), options);
}
- export function LinkButtonDocument(data: LinkButtonData, options: DocumentOptions = {}) {
- return CreateInstance(linkProto, new LinkButtonField(data), options);
- }
+ // export function LinkButtonDocument(data: LinkButtonData, options: DocumentOptions = {}) {
+ // return CreateInstance(linkProto, new LinkButtonField(data), options);
+ // }
export function PdfDocument(url: string, options: DocumentOptions = {}) {
return CreateInstance(pdfProto, new PdfField(new URL(url)), options);
}