aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts6
-rw-r--r--src/client/util/DragManager.ts2
-rw-r--r--src/client/views/ContextMenu.scss31
-rw-r--r--src/client/views/ContextMenu.tsx11
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx10
-rw-r--r--src/client/views/collections/CollectionFreeFormView.scss13
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx36
-rw-r--r--src/client/views/collections/CollectionView.tsx1
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx3
-rw-r--r--src/client/views/nodes/DocumentView.tsx2
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx2
-rw-r--r--src/client/views/nodes/PDFBox.tsx4
-rw-r--r--src/server/database.ts4
-rw-r--r--src/server/index.ts5
14 files changed, 106 insertions, 24 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 14ee7f2fd..b1edfabc7 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); }
@@ -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/util/DragManager.ts b/src/client/util/DragManager.ts
index 4a61220a5..9bd7d5c24 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -158,7 +158,7 @@ export namespace DragManager {
e.preventDefault();
x += e.movementX;
y += e.movementY;
- if (e.shiftKey) {
+ if (e.shiftKey && (e.button == 2 || e.altKey)) {
abortDrag();
CollectionDockingView.Instance.StartOtherDrag(doc, { pageX: e.pageX, pageY: e.pageY, preventDefault: () => { }, button: 0 });
}
diff --git a/src/client/views/ContextMenu.scss b/src/client/views/ContextMenu.scss
index f6830d9cd..20db5f3eb 100644
--- a/src/client/views/ContextMenu.scss
+++ b/src/client/views/ContextMenu.scss
@@ -22,6 +22,7 @@
}
.contextMenu-item {
+<<<<<<< HEAD
width: auto;
height: auto;
background: $light-color-secondary;
@@ -42,6 +43,29 @@
padding: 10px;
white-space: nowrap;
font-size: 13px;
+=======
+ width: auto;
+ height: auto;
+ background: #F0F8FF;
+ display: flex;
+ justify-content: left;
+ align-items: center;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ transition: all .1s;
+ border-width: .11px;
+ border-style: none;
+ border-color: rgb(187, 186, 186);
+ border-bottom-style: solid;
+ padding: 10px;
+ white-space: nowrap;
+ // font-size: 1.5vw;
+ font-size: 12px;
+>>>>>>> a680579f74380eb016f0ffd61b3818d0850984b5
}
.contextMenu-item:hover {
@@ -50,6 +74,13 @@
}
.contextMenu-description {
+<<<<<<< HEAD
text-align: left;
width: 8vw;
}
+=======
+ // font-size: 1.5vw;
+ text-align: left;
+ // width: 8vw;
+}
+>>>>>>> a680579f74380eb016f0ffd61b3818d0850984b5
diff --git a/src/client/views/ContextMenu.tsx b/src/client/views/ContextMenu.tsx
index d68dc6e66..9109b56bb 100644
--- a/src/client/views/ContextMenu.tsx
+++ b/src/client/views/ContextMenu.tsx
@@ -46,11 +46,13 @@ export class ContextMenu extends React.Component {
@action
displayMenu(x: number, y: number) {
- this._pageX = x
- this._pageY = window.innerHeight - y >= 100 ? y : window.innerHeight - y;
+ //maxX and maxY will change if the UI/font size changes, but will work for any amount
+ //of items added to the menu
+ let maxX = window.innerWidth - 150;
+ let maxY = window.innerHeight - (this._items.length * 34 + 30);
- // y pos absolute to top only when there's enough space
- this._yRelativeToTop = window.innerHeight - y >= 100;
+ this._pageX = x > maxX ? maxX : x;
+ this._pageY = y > maxY ? maxY : y;
this._searchString = "";
@@ -77,6 +79,7 @@ export class ContextMenu extends React.Component {
let style = this._yRelativeToTop ? { left: this._pageX, top: this._pageY, display: this._display } :
{ left: this._pageX, bottom: this._pageY, display: this._display };
+
return (
<div className="contextMenu-cont" style={style} ref={this.ref}>
<input className="contextMenu-item" type="text" placeholder="Search . . ." value={this._searchString} onChange={this.onChange}></input>
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.scss b/src/client/views/collections/CollectionFreeFormView.scss
index ffd440310..2756874bf 100644
--- a/src/client/views/collections/CollectionFreeFormView.scss
+++ b/src/client/views/collections/CollectionFreeFormView.scss
@@ -48,6 +48,7 @@
background: $light-color-secondary;
}
+<<<<<<< HEAD
border: 0px solid transparent;
border-radius: $border-radius;
box-sizing: border-box;
@@ -58,6 +59,18 @@
height: 100%;
overflow: hidden;
.collectionfreeformview {
+=======
+ .collectionfreeformview > .jsx-parser{
+ position:absolute;
+ height: 100%;
+ }
+ .formattedTextBox-cont {
+ background:yellow;
+ }
+
+ border-style: solid;
+ box-sizing: content-box;
+>>>>>>> a680579f74380eb016f0ffd61b3818d0850984b5
position: absolute;
top: 0;
left: 0;
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index b0cd7e017..74d37ccec 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -77,7 +77,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
onPointerDown = (e: React.PointerEvent): void => {
- if (((e.button === 2 && this.props.active()) || !e.defaultPrevented) && !e.shiftKey &&
+ if (((e.button === 2 && this.props.active()) || !e.defaultPrevented) &&
(!this.isAnnotationOverlay || this.zoomScaling != 1 || e.button == 0)) {
document.removeEventListener("pointermove", this.onPointerMove);
document.addEventListener("pointermove", this.onPointerMove);
@@ -92,8 +92,9 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
onPointerUp = (e: PointerEvent): void => {
- document.removeEventListener("pointermove", this.onPointerMove);
- document.removeEventListener("pointerup", this.onPointerUp);
+ if (this._marquee) {
+ document.removeEventListener("keydown", this.marqueeCommand);
+ }
e.stopPropagation();
if (this._marquee) {
@@ -102,7 +103,6 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
var selectedDocs = this.marqueeSelect();
selectedDocs.map(s => this.props.CollectionView.SelectedDocs.push(s.Id));
- this._marquee = false;
}
else if (!this._marquee && Math.abs(this._downX - e.clientX) < 3 && Math.abs(this._downY - e.clientY) < 3) {
//show preview text cursor on tap
@@ -112,7 +112,14 @@ export class CollectionFreeFormView extends CollectionViewBase {
this.props.select(false);
}
}
+ this.cleanupInteractions();
+ }
+ @action
+ cleanupInteractions = () => {
+ document.removeEventListener("pointermove", this.onPointerMove);
+ document.removeEventListener("pointerup", this.onPointerUp);
+ this._marquee = false;
}
intersectRect(r1: { left: number, right: number, top: number, bottom: number },
@@ -126,7 +133,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
marqueeSelect() {
this.props.CollectionView.SelectedDocs.length = 0;
var curPage = this.props.Document.GetNumber(KeyStore.CurPage, 1);
- let p = this.getTransform().transformPoint(this._downX, this._downY);
+ let p = this.getTransform().transformPoint(this._downX < this._lastX ? this._downX : this._lastX, this._downY < this._lastY ? this._downY : this._lastY);
let v = this.getTransform().transformDirection(this._lastX - this._downX, this._lastY - this._downY);
let selRect = { left: p[0], top: p[1], right: p[0] + v[0], bottom: p[1] + v[1] }
@@ -155,8 +162,9 @@ export class CollectionFreeFormView extends CollectionViewBase {
e.stopPropagation();
e.preventDefault();
let wasMarquee = this._marquee;
- this._marquee = e.buttons != 2;
+ this._marquee = e.buttons != 2 && !e.altKey && !e.metaKey;
if (this._marquee && !wasMarquee) {
+ this._previewCursorVisible = false;
document.addEventListener("keydown", this.marqueeCommand);
}
@@ -176,8 +184,24 @@ export class CollectionFreeFormView extends CollectionViewBase {
marqueeCommand = (e: KeyboardEvent) => {
if (e.key == "Backspace") {
this.marqueeSelect().map(d => this.props.removeDocument(d));
+ this.cleanupInteractions();
}
if (e.key == "c") {
+ let p = this.getTransform().transformPoint(this._downX < this._lastX ? this._downX : this._lastX, this._downY < this._lastY ? this._downY : this._lastY);
+ 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] - v[0] / 2);
+ d.SetNumber(KeyStore.Y, d.GetNumber(KeyStore.Y, 0) - p[1] - v[1] / 2);
+ 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: v[0], height: v[1], title: "a nested collection" }));
+ // }, 100);
+ this.cleanupInteractions();
}
}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 7320e873f..ac634ed53 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -99,7 +99,6 @@ export class CollectionView extends React.Component<CollectionViewProps> {
ContextMenu.Instance.addItem({ description: "Freeform", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Freeform) })
ContextMenu.Instance.addItem({ description: "Schema", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Schema) })
ContextMenu.Instance.addItem({ description: "Treeview", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Tree) })
- ContextMenu.Instance.addItem({ description: "Docking", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Docking) })
}
}
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index b126b40a9..31c89a75d 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -130,6 +130,9 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
if (type.indexOf("audio") !== -1) {
doc = Documents.AudioDocument(path, { ...options, nativeWidth: 300, width: 300, })
}
+ if (type.indexOf("pdf") !== -1) {
+ doc = Documents.PdfDocument(path, { ...options, nativeWidth: 300, width: 300, })
+ }
let docs = that.props.Document.GetT(KeyStore.Data, ListField);
if (docs != FieldWaiting) {
if (!docs) {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index dc793c16d..da40f0dc1 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -182,7 +182,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
if (Math.abs(this._downX - e.clientX) > 3 || Math.abs(this._downY - e.clientY) > 3) {
document.removeEventListener("pointermove", this.onPointerMove)
document.removeEventListener("pointerup", this.onPointerUp);
- if (!this.topMost || e.buttons == 2) {
+ if (!this.topMost || e.buttons == 2 || e.altKey) {
this.startDragging(e.x, e.y);
}
}
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 521b0324e..f5d4c030b 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -113,7 +113,7 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
this.props.doc.SetData(this.props.fieldKey, e.target.value, RichTextField);
}
onPointerDown = (e: React.PointerEvent): void => {
- if (e.buttons === 1 && this.props.isSelected()) {
+ if (e.buttons === 1 && this.props.isSelected() && !e.altKey) {
e.stopPropagation();
}
}
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 70a70c7c8..368a80b8e 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -423,7 +423,9 @@ export class PDFBox extends React.Component<FieldViewProps> {
// so this design is flawed.
var nativeWidth = this.props.doc.GetNumber(KeyStore.NativeWidth, 0);
if (!this.props.doc.GetNumber(KeyStore.NativeHeight, 0)) {
- this.props.doc.SetNumber(KeyStore.NativeHeight, nativeWidth * r.entry.height / r.entry.width);
+ var nativeHeight = nativeWidth * r.entry.height / r.entry.width;
+ this.props.doc.SetNumber(KeyStore.Height, nativeHeight / nativeWidth * this.props.doc.GetNumber(KeyStore.Width, 0));
+ this.props.doc.SetNumber(KeyStore.NativeHeight, nativeHeight);
}
if (!this.props.doc.GetT(KeyStore.Thumbnail, ImageField)) {
this.saveThumbnail();
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);