aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-05-19 01:15:22 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-05-19 01:15:22 -0400
commit3f12e4a4b776010e09d12a1adfb1d243675bcd6e (patch)
treed371b86985a26f62c69d4026e6d0e26246acf725 /src/client/documents/Documents.ts
parenta07655cb99cec80cb5d4e670b26e667999d259ec (diff)
Reorganized some stuff to hopefully make circular imports harder
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index ed260d42e..0ebf6ff75 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -34,6 +34,7 @@ import { StrokeData, InkField } from "../../new_fields/InkField";
import { dropActionType } from "../util/DragManager";
import { DateField } from "../../new_fields/DateField";
import { schema } from "prosemirror-schema-basic";
+import { UndoManager } from "../util/UndoManager";
export interface DocumentOptions {
x?: number;
@@ -64,6 +65,38 @@ export interface DocumentOptions {
}
const delegateKeys = ["x", "y", "width", "height", "panX", "panY"];
+export namespace DocUtils {
+ export function MakeLink(source: Doc, target: Doc) {
+ let protoSrc = source.proto ? source.proto : source;
+ let protoTarg = target.proto ? target.proto : target;
+ UndoManager.RunInBatch(() => {
+ let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1 });
+ //let linkDoc = new Doc;
+ linkDoc.proto!.title = "-link name-";
+ linkDoc.proto!.linkDescription = "";
+ linkDoc.proto!.linkTags = "Default";
+
+ linkDoc.proto!.linkedTo = target;
+ linkDoc.proto!.linkedFrom = source;
+
+ let linkedFrom = Cast(protoTarg.linkedFromDocs, listSpec(Doc));
+ if (!linkedFrom) {
+ protoTarg.linkedFromDocs = linkedFrom = new List<Doc>();
+ }
+ linkedFrom.push(linkDoc);
+
+ let linkedTo = Cast(protoSrc.linkedToDocs, listSpec(Doc));
+ if (!linkedTo) {
+ protoSrc.linkedToDocs = linkedTo = new List<Doc>();
+ }
+ linkedTo.push(linkDoc);
+ return linkDoc;
+ }, "make link");
+ }
+
+
+}
+
export namespace Docs {
let textProto: Doc;
let histoProto: Doc;