aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts12
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx10
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx26
-rw-r--r--src/server/database.ts4
-rw-r--r--src/server/index.ts5
5 files changed, 45 insertions, 12 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 7b30dff98..bb463b36f 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -34,6 +34,7 @@ export interface DocumentOptions {
title?: string;
panx?: number;
pany?: number;
+ page?: number;
scale?: number;
layout?: string;
layoutKeys?: Key[];
@@ -78,6 +79,7 @@ export namespace Documents {
if (options.title !== undefined) { doc.SetText(KeyStore.Title, options.title); }
if (options.panx !== undefined) { doc.SetNumber(KeyStore.PanX, options.panx); }
if (options.pany !== undefined) { doc.SetNumber(KeyStore.PanY, options.pany); }
+ if (options.page !== undefined) { doc.SetNumber(KeyStore.Page, options.page); }
if (options.scale !== undefined) { doc.SetNumber(KeyStore.Scale, options.scale); }
if (options.viewType !== undefined) { doc.SetNumber(KeyStore.ViewType, options.viewType); }
if (options.layout !== undefined) { doc.SetText(KeyStore.Layout, options.layout); }
@@ -146,9 +148,9 @@ export namespace Documents {
export function ImageDocument(url: string, options: DocumentOptions = {}) {
let doc = SetInstanceOptions(GetImagePrototype(), { ...options, layoutKeys: [KeyStore.Data, KeyStore.Annotations, KeyStore.Caption] },
new URL(url), ImageField);
- doc.SetText(KeyStore.Caption, "my caption...");
- doc.SetText(KeyStore.BackgroundLayout, EmbeddedCaption());
- doc.SetText(KeyStore.OverlayLayout, FixedCaption());
+ // doc.SetText(KeyStore.Caption, "my caption...");
+ // doc.SetText(KeyStore.BackgroundLayout, EmbeddedCaption());
+ // doc.SetText(KeyStore.OverlayLayout, FixedCaption());
return doc;
}
export function VideoDocument(url: string, options: DocumentOptions = {}) {
@@ -194,10 +196,10 @@ export namespace Documents {
+ FormattedTextBox.LayoutString("CaptionKey") +
`</div>
</div>` };
- function FixedCaption() {
+ function FixedCaption(fieldName: string = "Caption") {
return `<div style="position:absolute; height:30px; bottom:0; width:100%">
<div style="position:absolute; width:100%; height:100%; text-align:center;bottom:0;">`
- + FormattedTextBox.LayoutString("CaptionKey") +
+ + FormattedTextBox.LayoutString(fieldName + "Key") +
`</div>
</div>` };
} \ No newline at end of file
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 6a0404663..94005a4c0 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -150,9 +150,13 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
}
}
componentWillUnmount: () => void = () => {
- this._goldenLayout.unbind('itemDropped', this.itemDropped);
- this._goldenLayout.unbind('tabCreated', this.tabCreated);
- this._goldenLayout.unbind('stackCreated', this.stackCreated);
+ try {
+ this._goldenLayout.unbind('itemDropped', this.itemDropped);
+ this._goldenLayout.unbind('tabCreated', this.tabCreated);
+ this._goldenLayout.unbind('stackCreated', this.stackCreated);
+ } catch (e) {
+
+ }
this._goldenLayout.destroy();
this._goldenLayout = null;
window.removeEventListener('resize', this.onResize);
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index b0cd7e017..2dba62ee0 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -92,6 +92,9 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
onPointerUp = (e: PointerEvent): void => {
+ if (this._marquee) {
+ document.removeEventListener("keydown", this.marqueeCommand);
+ }
document.removeEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
e.stopPropagation();
@@ -115,6 +118,13 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
+ @action
+ clearMarquee = () => {
+ document.removeEventListener("pointermove", this.onPointerMove);
+ document.removeEventListener("pointerup", this.onPointerUp);
+ this._marquee = false;
+ }
+
intersectRect(r1: { left: number, right: number, top: number, bottom: number },
r2: { left: number, right: number, top: number, bottom: number }) {
return !(r2.left > r1.right ||
@@ -157,6 +167,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
let wasMarquee = this._marquee;
this._marquee = e.buttons != 2;
if (this._marquee && !wasMarquee) {
+ this._previewCursorVisible = false;
document.addEventListener("keydown", this.marqueeCommand);
}
@@ -176,8 +187,23 @@ export class CollectionFreeFormView extends CollectionViewBase {
marqueeCommand = (e: KeyboardEvent) => {
if (e.key == "Backspace") {
this.marqueeSelect().map(d => this.props.removeDocument(d));
+ this.clearMarquee();
}
if (e.key == "c") {
+ let p = this.getTransform().transformPoint(this._downX, this._downY);
+ let v = this.getTransform().transformDirection(this._lastX - this._downX, this._lastY - this._downY);
+ let selected = this.marqueeSelect().map(m => m);
+ this.marqueeSelect().map(d => this.props.removeDocument(d));
+ //setTimeout(() => {
+ this.props.CollectionView.addDocument(Documents.FreeformDocument(selected.map(d => {
+ d.SetNumber(KeyStore.X, d.GetNumber(KeyStore.X, 0) - p[0] - 400);
+ d.SetNumber(KeyStore.Y, d.GetNumber(KeyStore.Y, 0) - p[1] - 400);
+ d.SetNumber(KeyStore.Page, this.props.Document.GetNumber(KeyStore.Page, 0));
+ d.SetText(KeyStore.Title, "" + d.GetNumber(KeyStore.Width, 0) + " " + d.GetNumber(KeyStore.Height, 0));
+ return d;
+ }), { x: p[0], y: p[1], panx: 0, pany: 0, width: 800, height: 800, title: "a nested collection" }));
+ // }, 100);
+ this.clearMarquee();
}
}
diff --git a/src/server/database.ts b/src/server/database.ts
index 07c5819ab..f3c1c9427 100644
--- a/src/server/database.ts
+++ b/src/server/database.ts
@@ -16,12 +16,12 @@ export class Database {
})
}
- public update(id: string, value: any) {
+ public update(id: string, value: any, callback: () => void) {
if (this.db) {
let collection = this.db.collection('documents');
collection.update({ _id: id }, { $set: value }, {
upsert: true
- });
+ }, callback);
}
}
diff --git a/src/server/index.ts b/src/server/index.ts
index 0d0b65b22..83fa84746 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -173,8 +173,9 @@ function getFields([ids, callback]: [string[], (result: any) => void]) {
}
function setField(socket: Socket, newValue: Transferable) {
- Database.Instance.update(newValue._id, newValue)
- socket.broadcast.emit(MessageStore.SetField.Message, newValue)
+ Database.Instance.update(newValue._id, newValue, () => {
+ socket.broadcast.emit(MessageStore.SetField.Message, newValue);
+ })
}
server.listen(serverPort);