aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx25
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx14
-rw-r--r--src/client/views/nodes/DocumentView.tsx8
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx4
-rw-r--r--src/fields/Document.ts9
5 files changed, 43 insertions, 17 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index cb6668634..4cdd0d554 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -44,17 +44,20 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
drop = (e: Event, de: DragManager.DropEvent) => {
super.drop(e, de);
- const doc: DocumentView = de.data["document"];
- const xOffset = de.data["xOffset"] as number || 0;
- const yOffset = de.data["yOffset"] as number || 0;
- //this should be able to use translate and scale methods on an Identity transform, no?
- const transform = this.getTransform();
- const screenX = de.x - xOffset;
- const screenY = de.y - yOffset;
- const [x, y] = transform.transformPoint(screenX, screenY);
- doc.props.Document.SetNumber(KeyStore.X, x);
- doc.props.Document.SetNumber(KeyStore.Y, y);
- this.bringToFront(doc);
+
+ if (!de.data["alias"]) {
+ const doc: DocumentView = de.data["document"];
+ const xOffset = de.data["xOffset"] as number || 0;
+ const yOffset = de.data["yOffset"] as number || 0;
+ //this should be able to use translate and scale methods on an Identity transform, no?
+ const transform = this.getTransform();
+ const screenX = de.x - xOffset;
+ const screenY = de.y - yOffset;
+ const [x, y] = transform.transformPoint(screenX, screenY);
+ doc.props.Document.SetNumber(KeyStore.X, x);
+ doc.props.Document.SetNumber(KeyStore.Y, y);
+ this.bringToFront(doc);
+ }
}
@action
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 7e269caf1..be3cb0d5f 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -43,11 +43,21 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
@action
protected drop(e: Event, de: DragManager.DropEvent) {
const doc: DocumentView = de.data["document"];
+ if (de.data["alias"]) {
+ let newDoc = doc.props.Document.CreateAlias()
+ const xOffset = de.data["xOffset"] as number || 0
+ const yOffset = de.data["yOffset"] as number || 0
+ newDoc.SetNumber(KeyStore.X, de.x - xOffset)
+ newDoc.SetNumber(KeyStore.Y, de.y - yOffset)
+ newDoc.SetNumber(KeyStore.Width, doc.props.Document.GetNumber(KeyStore.Width, 100))
+ newDoc.SetNumber(KeyStore.Height, doc.props.Document.GetNumber(KeyStore.Height, 100))
+ this.props.addDocument(newDoc)
+ }
if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this.props.CollectionView) {
- if (doc.props.RemoveDocument) {
+ if (!de.data["alias"] && doc.props.RemoveDocument) {
doc.props.RemoveDocument(doc.props.Document);
}
- this.props.addDocument(doc.props.Document);
+ this.props.addDocument(de.data["alias"] ? doc.props.Document.CreateAlias() : doc.props.Document);
}
e.stopPropagation();
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index ad1328e5d..bc8bbfef1 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -96,9 +96,12 @@ export class DocumentView extends React.Component<DocumentViewProps> {
this._downX = e.clientX;
this._downY = e.clientY;
if (e.shiftKey && e.buttons === 1) {
+ console.log("Hello")
+ let document = e.ctrlKey ? this.props.Document.CreateAlias() : this.props.Document
CollectionDockingView.Instance.StartOtherDrag(this._mainCont.current!, this.props.Document);
e.stopPropagation();
- } else {
+ }
+ else {
this._contextMenuCanOpen = true;
if (this.active && !e.isDefaultPrevented()) {
e.stopPropagation();
@@ -127,11 +130,12 @@ export class DocumentView extends React.Component<DocumentViewProps> {
dragData["document"] = this;
dragData["xOffset"] = e.x - left;
dragData["yOffset"] = e.y - top;
+ dragData["alias"] = e.shiftKey
DragManager.StartDrag(this._mainCont.current, dragData, {
handlers: {
dragComplete: action((e: DragManager.DragCompleteEvent) => { }),
},
- hideSource: true
+ hideSource: !e.shiftKey
})
}
}
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index c0969a8c3..57ac880df 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -48,6 +48,7 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
const state = this._editorView.state.apply(tx);
this._editorView.updateState(state);
const { doc, fieldKey } = this.props;
+ // doc.SetOnPrototype(fieldKey, new RichTextField(JSON.stringify(state.toJSON())))
doc.SetData(fieldKey, JSON.stringify(state.toJSON()), RichTextField);
}
}
@@ -103,7 +104,8 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
@action
onChange(e: React.ChangeEvent<HTMLInputElement>) {
const { fieldKey, doc } = this.props;
- doc.SetData(fieldKey, e.target.value, RichTextField);
+ doc.SetOnPrototype(fieldKey, new RichTextField(e.target.value))
+ // doc.SetData(fieldKey, e.target.value, RichTextField);
}
onPointerDown = (e: React.PointerEvent): void => {
let me = this;
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 823991759..39648a950 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -2,7 +2,7 @@ import { Key } from "./Key"
import { KeyStore } from "./KeyStore";
import { Field, Cast, FieldWaiting, FieldValue, FieldId } from "./Field"
import { NumberField } from "./NumberField";
-import { ObservableMap, computed, action } from "mobx";
+import { ObservableMap, computed, action, runInAction } from "mobx";
import { TextField } from "./TextField";
import { ListField } from "./ListField";
import { Server } from "../client/Server";
@@ -210,6 +210,13 @@ export class Document extends Field {
return protos;
}
+ CreateAlias(id?: string): Document {
+ let alias = new Document(id)
+ alias.Set(KeyStore.Prototype, this)
+
+ return alias
+ }
+
MakeDelegate(id?: string): Document {
let delegate = new Document(id);