aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Main.tsx10
-rw-r--r--src/documents/Documents.ts26
-rw-r--r--src/fields/BasicField.ts4
-rw-r--r--src/fields/DocumentReference.ts6
-rw-r--r--src/fields/Key.ts6
-rw-r--r--src/fields/ListField.ts9
-rw-r--r--src/fields/NumberField.ts2
-rw-r--r--src/fields/TextField.ts2
-rw-r--r--src/stores/RootStore.ts2
-rw-r--r--src/views/ContextMenu.tsx8
-rw-r--r--src/views/ContextMenuItem.tsx2
-rw-r--r--src/views/freeformcanvas/CollectionFreeFormView.scss4
-rw-r--r--src/views/nodes/FieldTextBox.tsx40
-rw-r--r--src/views/nodes/NodeView.scss10
-rw-r--r--src/views/nodes/RichTextView.tsx0
-rw-r--r--test/test.ts12
16 files changed, 60 insertions, 83 deletions
diff --git a/src/Main.tsx b/src/Main.tsx
index e5302bdee..7560abca7 100644
--- a/src/Main.tsx
+++ b/src/Main.tsx
@@ -27,22 +27,22 @@ let mainContainer = Documents.CollectionDocument(mainNodeCollection, {
x: 0, y: 0, width: window.screen.width, height: window.screen.height
})
-window.addEventListener("drop", function(e) {
+window.addEventListener("drop", function (e) {
e.preventDefault();
}, false)
-window.addEventListener("dragover", function(e) {
+window.addEventListener("dragover", function (e) {
e.preventDefault();
}, false)
-document.addEventListener("pointerdown", action(function(e: PointerEvent) {
+document.addEventListener("pointerdown", action(function (e: PointerEvent) {
if (!ContextMenu.Instance.intersects(e.pageX, e.pageY)) {
ContextMenu.Instance.clearItems()
}
}), true)
ReactDOM.render((
- <div style={{display: "grid"}}>
+ <div style={{ display: "grid" }}>
<h1>Dash Web</h1>
- <DocumentView Document={mainContainer} ContainingCollectionView={undefined} ContainingDocumentView={undefined}/>
+ <DocumentView Document={mainContainer} ContainingCollectionView={undefined} ContainingDocumentView={undefined} />
<DocumentDecorations />
<ContextMenu />
</div>), document.getElementById('root'));
diff --git a/src/documents/Documents.ts b/src/documents/Documents.ts
index fb7c7c4d9..60fa79eea 100644
--- a/src/documents/Documents.ts
+++ b/src/documents/Documents.ts
@@ -13,16 +13,16 @@ interface DocumentOptions {
export namespace Documents {
function setupOptions(doc: Document, options: DocumentOptions): void {
- if(options.x) {
+ if (options.x) {
doc.SetFieldValue(KeyStore.X, options.x, NumberField);
}
- if(options.y) {
+ if (options.y) {
doc.SetFieldValue(KeyStore.Y, options.y, NumberField);
}
- if(options.width) {
+ if (options.width) {
doc.SetFieldValue(KeyStore.Width, options.width, NumberField);
}
- if(options.height) {
+ if (options.height) {
doc.SetFieldValue(KeyStore.Height, options.height, NumberField);
}
doc.SetFieldValue(KeyStore.Scale, 1, NumberField);
@@ -30,9 +30,9 @@ export namespace Documents {
doc.SetFieldValue(KeyStore.PanY, 0, NumberField);
}
- let textProto:Document;
+ let textProto: Document;
function GetTextPrototype(): Document {
- if(!textProto) {
+ if (!textProto) {
textProto = new Document();
textProto.SetField(KeyStore.X, new NumberField(0));
textProto.SetField(KeyStore.Y, new NumberField(0));
@@ -44,16 +44,16 @@ export namespace Documents {
return textProto;
}
- export function TextDocument(text: string, options:DocumentOptions = {}): Document {
+ export function TextDocument(text: string, options: DocumentOptions = {}): Document {
let doc = GetTextPrototype().MakeDelegate();
setupOptions(doc, options);
// doc.SetField(KeyStore.Data, new TextField(text));
return doc;
}
- let imageProto:Document;
+ let imageProto: Document;
function GetImagePrototype(): Document {
- if(!imageProto) {
+ if (!imageProto) {
imageProto = new Document();
imageProto.SetField(KeyStore.X, new NumberField(0));
imageProto.SetField(KeyStore.Y, new NumberField(0));
@@ -66,16 +66,16 @@ export namespace Documents {
return imageProto;
}
- export function ImageDocument(url: string, options:DocumentOptions = {}): Document {
+ export function ImageDocument(url: string, options: DocumentOptions = {}): Document {
let doc = GetImagePrototype().MakeDelegate();
setupOptions(doc, options);
doc.SetField(KeyStore.Data, new TextField(url));
return doc;
}
- let collectionProto:Document;
+ let collectionProto: Document;
function GetCollectionPrototype(): Document {
- if(!collectionProto) {
+ if (!collectionProto) {
collectionProto = new Document();
collectionProto.SetField(KeyStore.X, new NumberField(0));
collectionProto.SetField(KeyStore.Y, new NumberField(0));
@@ -90,7 +90,7 @@ export namespace Documents {
return collectionProto;
}
- export function CollectionDocument( documents: Array<Document>, options:DocumentOptions = {}): Document {
+ export function CollectionDocument(documents: Array<Document>, options: DocumentOptions = {}): Document {
let doc = GetCollectionPrototype().MakeDelegate();
setupOptions(doc, options);
doc.SetField(KeyStore.Data, new ListField(documents));
diff --git a/src/fields/BasicField.ts b/src/fields/BasicField.ts
index 437024d07..fb5cc773e 100644
--- a/src/fields/BasicField.ts
+++ b/src/fields/BasicField.ts
@@ -9,7 +9,7 @@ export abstract class BasicField<T> extends Field {
}
@observable
- private data:T;
+ private data: T;
@computed
get Data(): T {
@@ -17,7 +17,7 @@ export abstract class BasicField<T> extends Field {
}
set Data(value: T) {
- if(this.data === value) {
+ if (this.data === value) {
return;
}
this.data = value;
diff --git a/src/fields/DocumentReference.ts b/src/fields/DocumentReference.ts
index 936067bd2..f8be335ef 100644
--- a/src/fields/DocumentReference.ts
+++ b/src/fields/DocumentReference.ts
@@ -4,7 +4,7 @@ import { Key } from "./Key";
import { DocumentUpdatedArgs } from "./FieldUpdatedArgs";
export class DocumentReference extends Field {
- get Key(): Key{
+ get Key(): Key {
return this.key;
}
@@ -16,11 +16,11 @@ export class DocumentReference extends Field {
super();
}
- private DocFieldUpdated(args: DocumentUpdatedArgs):void{
+ private DocFieldUpdated(args: DocumentUpdatedArgs): void {
// this.FieldUpdated.emit(args.fieldArgs);
}
- Dereference() : Opt<Field> {
+ Dereference(): Opt<Field> {
return this.document.GetField(this.key);
}
diff --git a/src/fields/Key.ts b/src/fields/Key.ts
index 1f8ba0be5..f8418d5c0 100644
--- a/src/fields/Key.ts
+++ b/src/fields/Key.ts
@@ -3,13 +3,13 @@ import { Utils } from "../Utils";
import { observable } from "mobx";
export class Key extends Field {
- private name:string;
+ private name: string;
- get Name():string {
+ get Name(): string {
return this.name;
}
- constructor(name:string){
+ constructor(name: string) {
super(Utils.GenerateDeterministicGuid(name));
this.name = name;
diff --git a/src/fields/ListField.ts b/src/fields/ListField.ts
index dd96ea8c8..8607ebe43 100644
--- a/src/fields/ListField.ts
+++ b/src/fields/ListField.ts
@@ -6,16 +6,7 @@ export class ListField<T extends Field> extends BasicField<T[]> {
super(data.slice());
}
- Get(index:number) : T{
- return this.Data[index];
- }
-
- Set(index:number, value:T):void {
- this.Data[index] = value;
- }
-
Copy(): Field {
return new ListField<T>(this.Data);
}
-
} \ No newline at end of file
diff --git a/src/fields/NumberField.ts b/src/fields/NumberField.ts
index cbe15f987..c3444f644 100644
--- a/src/fields/NumberField.ts
+++ b/src/fields/NumberField.ts
@@ -8,6 +8,4 @@ export class NumberField extends BasicField<number> {
Copy() {
return new NumberField(this.Data);
}
-
-
} \ No newline at end of file
diff --git a/src/fields/TextField.ts b/src/fields/TextField.ts
index a7c221788..95825d2ae 100644
--- a/src/fields/TextField.ts
+++ b/src/fields/TextField.ts
@@ -8,6 +8,4 @@ export class TextField extends BasicField<string> {
Copy() {
return new TextField(this.Data);
}
-
-
}
diff --git a/src/stores/RootStore.ts b/src/stores/RootStore.ts
index fa551c1d1..393c52d57 100644
--- a/src/stores/RootStore.ts
+++ b/src/stores/RootStore.ts
@@ -10,7 +10,7 @@ export class RootStore {
private static _instance: RootStore;
- public static get Instance():RootStore {
+ public static get Instance(): RootStore {
return this._instance || (this._instance = new this());
}
} \ No newline at end of file
diff --git a/src/views/ContextMenu.tsx b/src/views/ContextMenu.tsx
index 299ce91c6..4f26a75d2 100644
--- a/src/views/ContextMenu.tsx
+++ b/src/views/ContextMenu.tsx
@@ -8,7 +8,7 @@ import "./ContextMenu.scss"
export class ContextMenu extends React.Component {
static Instance: ContextMenu
- @observable private _items: Array<ContextMenuProps> = [{description:"test", event:(e:React.MouseEvent) => e.preventDefault()}];
+ @observable private _items: Array<ContextMenuProps> = [{ description: "test", event: (e: React.MouseEvent) => e.preventDefault() }];
@observable private _pageX: number = 0;
@observable private _pageY: number = 0;
@observable private _display: string = "none";
@@ -57,10 +57,10 @@ export class ContextMenu extends React.Component {
}
render() {
- return(
- <div className="contextMenu-cont" style={{left: this._pageX, top: this._pageY, display: this._display }} ref={this.ref}>
+ return (
+ <div className="contextMenu-cont" style={{ left: this._pageX, top: this._pageY, display: this._display }} ref={this.ref}>
{this._items.map(prop => {
- return <ContextMenuItem {...prop} key={prop.description}/>
+ return <ContextMenuItem {...prop} key={prop.description} />
})}
</div>
)
diff --git a/src/views/ContextMenuItem.tsx b/src/views/ContextMenuItem.tsx
index beacb44d2..8f00f8b3d 100644
--- a/src/views/ContextMenuItem.tsx
+++ b/src/views/ContextMenuItem.tsx
@@ -8,7 +8,7 @@ export interface ContextMenuProps {
export class ContextMenuItem extends React.Component<ContextMenuProps> {
render() {
- return(
+ return (
<div className="contextMenu-item" onClick={this.props.event}>
<div className="contextMenu-description">{this.props.description}</div>
</div>
diff --git a/src/views/freeformcanvas/CollectionFreeFormView.scss b/src/views/freeformcanvas/CollectionFreeFormView.scss
index cb4805eb3..6ad6ad86c 100644
--- a/src/views/freeformcanvas/CollectionFreeFormView.scss
+++ b/src/views/freeformcanvas/CollectionFreeFormView.scss
@@ -5,11 +5,9 @@
width: 100%;
height: 100%;
overflow: hidden;
-
.collectionfreeformview {
position: absolute;
top: 0;
left: 0;
}
-}
-
+} \ No newline at end of file
diff --git a/src/views/nodes/FieldTextBox.tsx b/src/views/nodes/FieldTextBox.tsx
index 3b8743627..4539bbab0 100644
--- a/src/views/nodes/FieldTextBox.tsx
+++ b/src/views/nodes/FieldTextBox.tsx
@@ -5,19 +5,19 @@ import { TextField } from "../../fields/TextField";
import React = require("react")
import { action, observable, reaction, IReactionDisposer } from "mobx";
-import {schema} from "prosemirror-schema-basic";
-import {EditorState, Transaction} from "prosemirror-state"
-import {EditorView} from "prosemirror-view"
-import {keymap} from "prosemirror-keymap"
-import {baseKeymap} from "prosemirror-commands"
-import {undo, redo, history} from "prosemirror-history"
+import { schema } from "prosemirror-schema-basic";
+import { EditorState, Transaction } from "prosemirror-state"
+import { EditorView } from "prosemirror-view"
+import { keymap } from "prosemirror-keymap"
+import { baseKeymap } from "prosemirror-commands"
+import { undo, redo, history } from "prosemirror-history"
import { Opt } from "../../fields/Field";
import "./FieldTextBox.scss"
interface IProps {
- fieldKey:Key;
- doc:Document;
+ fieldKey: Key;
+ doc: Document;
}
// FieldTextBox: Displays an editable plain text node that maps to a specified Key of a Document
@@ -41,7 +41,7 @@ export class FieldTextBox extends React.Component<IProps> {
private _editorView: Opt<EditorView>;
private _reactionDisposer: Opt<IReactionDisposer>;
- constructor(props:IProps) {
+ constructor(props: IProps) {
super(props);
this._ref = React.createRef();
@@ -50,33 +50,33 @@ export class FieldTextBox extends React.Component<IProps> {
}
dispatchTransaction = (tx: Transaction) => {
- if(this._editorView) {
+ if (this._editorView) {
const state = this._editorView.state.apply(tx);
this._editorView.updateState(state);
- const {doc, fieldKey} = this.props;
+ const { doc, fieldKey } = this.props;
doc.SetFieldValue(fieldKey, JSON.stringify(state.toJSON()), TextField);
}
}
componentDidMount() {
- let state:EditorState;
- const {doc, fieldKey} = this.props;
+ let state: EditorState;
+ const { doc, fieldKey } = this.props;
const config = {
schema,
plugins: [
history(),
- keymap({"Mod-z": undo, "Mod-y": redo}),
+ keymap({ "Mod-z": undo, "Mod-y": redo }),
keymap(baseKeymap)
]
};
let field = doc.GetFieldT(fieldKey, TextField);
- if(field) {
+ if (field) {
state = EditorState.fromJSON(config, JSON.parse(field.Data));
} else {
state = EditorState.create(config);
}
- if(this._ref.current) {
+ if (this._ref.current) {
this._editorView = new EditorView(this._ref.current, {
state,
dispatchTransaction: this.dispatchTransaction
@@ -87,17 +87,17 @@ export class FieldTextBox extends React.Component<IProps> {
const field = this.props.doc.GetFieldT(this.props.fieldKey, TextField);
return field ? field.Data : undefined;
}, (field) => {
- if(field && this._editorView) {
+ if (field && this._editorView) {
this._editorView.updateState(EditorState.fromJSON(config, JSON.parse(field)));
}
})
}
componentWillUnmount() {
- if(this._editorView) {
+ if (this._editorView) {
this._editorView.destroy();
}
- if(this._reactionDisposer) {
+ if (this._reactionDisposer) {
this._reactionDisposer();
}
}
@@ -108,7 +108,7 @@ export class FieldTextBox extends React.Component<IProps> {
@action
onChange(e: React.ChangeEvent<HTMLInputElement>) {
- const {fieldKey, doc} = this.props;
+ const { fieldKey, doc } = this.props;
doc.SetFieldValue(fieldKey, e.target.value, TextField);
}
diff --git a/src/views/nodes/NodeView.scss b/src/views/nodes/NodeView.scss
index a68335f87..dac1c0a8e 100644
--- a/src/views/nodes/NodeView.scss
+++ b/src/views/nodes/NodeView.scss
@@ -1,31 +1,23 @@
.node {
position: absolute;
background: #cdcdcd;
-
overflow: hidden;
-
-
&.minimized {
width: 30px;
height: 30px;
}
-
.top {
background: #232323;
height: 20px;
cursor: pointer;
}
-
.content {
padding: 20px 20px;
height: auto;
box-sizing: border-box;
-
}
-
.scroll-box {
overflow-y: scroll;
height: calc(100% - 20px);
}
-}
-
+} \ No newline at end of file
diff --git a/src/views/nodes/RichTextView.tsx b/src/views/nodes/RichTextView.tsx
deleted file mode 100644
index e69de29bb..000000000
--- a/src/views/nodes/RichTextView.tsx
+++ /dev/null
diff --git a/test/test.ts b/test/test.ts
index 3c8fae8d7..213ccea03 100644
--- a/test/test.ts
+++ b/test/test.ts
@@ -17,14 +17,14 @@ describe('Number Controller', () => {
it('Should update', () => {
const numController = new NumberField(15);
let ran = false;
- reaction(() => numController.Data, (data) => {ran = true;})
+ reaction(() => numController.Data, (data) => { ran = true; })
expect(ran).to.equal(false);
numController.Data = 5;
expect(ran).to.equal(true);
});
});
-describe("Document", () =>{
+describe("Document", () => {
it('should hold fields', () => {
let key = new Key("Test");
let key2 = new Key("Test2");
@@ -42,7 +42,7 @@ describe("Document", () =>{
let key = new Key("Test");
let key2 = new Key("Test2");
let ran = false;
- reaction(() => doc.GetField(key), (field) => {ran = true});
+ reaction(() => doc.GetField(key), (field) => { ran = true });
expect(ran).to.equal(false);
doc.SetField(key2, new NumberField(4));
@@ -69,7 +69,7 @@ describe("Reference", () => {
let ref3 = new DocumentReference(doc2, key2);
let ref4 = new DocumentReference(doc2, key);
-
+
expect(ref.Dereference()).to.equal(numCont);
expect(ref.DereferenceToRoot()).to.equal(numCont);
expect(ref2.Dereference()).to.equal(undefined);
@@ -79,7 +79,7 @@ describe("Reference", () => {
expect(ref4.Dereference()).to.equal(undefined);
expect(ref4.DereferenceToRoot()).to.equal(undefined);
});
-
+
it('should work with prototypes', () => {
let doc = new Document;
let doc2 = doc.MakeDelegate();
@@ -152,7 +152,7 @@ describe("Reference", () => {
let ran = false;
reaction(() => {
let field = doc2.GetFieldT(key, NumberField);
- if(field) {
+ if (field) {
return field.Data;
}
return undefined;