aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-02-05 11:33:30 -0500
committerbob <bcz@cs.brown.edu>2019-02-05 11:33:30 -0500
commit46a3ba510a02464b27b806af8fd1131dbc3da242 (patch)
treef2f247d04107062243fd36a1f59867ab84280014 /src
parent58c7742c18f82fe854784b083dfa723a8f256b72 (diff)
more reorg
Diffstat (limited to 'src')
-rw-r--r--src/documents/Documents.ts4
-rw-r--r--src/views/collections/CollectionDockingView.tsx4
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx8
-rw-r--r--src/views/collections/CollectionSchemaView.tsx6
-rw-r--r--src/views/nodes/DocumentView.tsx14
-rw-r--r--src/views/nodes/FieldView.tsx7
-rw-r--r--src/views/nodes/FormattedTextBox.scss (renamed from src/views/nodes/FieldTextBox.scss)2
-rw-r--r--src/views/nodes/FormattedTextBox.tsx (renamed from src/views/nodes/FieldTextBox.tsx)18
-rw-r--r--src/views/nodes/ImageBox.tsx4
9 files changed, 33 insertions, 34 deletions
diff --git a/src/documents/Documents.ts b/src/documents/Documents.ts
index 29ef32966..b69b79dd3 100644
--- a/src/documents/Documents.ts
+++ b/src/documents/Documents.ts
@@ -3,7 +3,7 @@ import { KeyStore } from "../fields/Key";
import { TextField } from "../fields/TextField";
import { NumberField } from "../fields/NumberField";
import { ListField } from "../fields/ListField";
-import { FieldTextBox } from "../views/nodes/FieldTextBox";
+import { FormattedTextBox } from "../views/nodes/FormattedTextBox";
import { CollectionDockingView } from "../views/collections/CollectionDockingView";
import { CollectionSchemaView } from "../views/collections/CollectionSchemaView";
import { ImageField } from "../fields/ImageField";
@@ -49,7 +49,7 @@ export namespace Documents {
textProto.SetField(KeyStore.Y, new NumberField(0));
textProto.SetField(KeyStore.Width, new NumberField(300));
textProto.SetField(KeyStore.Height, new NumberField(150));
- textProto.SetField(KeyStore.Layout, new TextField(FieldTextBox.LayoutString()));
+ textProto.SetField(KeyStore.Layout, new TextField(FormattedTextBox.LayoutString()));
textProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data]));
}
return textProto;
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index 1a523e1bf..49f1a0bf0 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -69,7 +69,7 @@ export class CollectionDockingView extends CollectionViewBase {
@action
onResize = (event: any) => {
- var cur = this.props.DocumentContentsOfCollection!.MainContent.current;
+ var cur = this.props.DocumentViewForCollection!.MainContent.current;
// bcz: since GoldenLayout isn't a React component itself, we need to notify it to resize when its document container's size has changed
CollectionDockingView.myLayout.updateSize(cur!.getBoundingClientRect().width, cur!.getBoundingClientRect().height);
@@ -255,7 +255,7 @@ export class CollectionDockingView extends CollectionViewBase {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
// bcz: not sure why, but I need these to force the flexlayout to update when the collection size changes.
- var s = this.props.DocumentContentsOfCollection != undefined ? this.props.DocumentContentsOfCollection!.ScalingToScreenSpace : 1;
+ var s = this.props.DocumentViewForCollection != undefined ? this.props.DocumentViewForCollection!.ScalingToScreenSpace : 1;
var w = Document.GetFieldValue(KeyStore.Width, NumberField, Number(0)) / s;
var h = Document.GetFieldValue(KeyStore.Height, NumberField, Number(0)) / s;
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index c91946475..d266a55d9 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -39,7 +39,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
const xOffset = de.data["xOffset"] as number || 0;
const yOffset = de.data["yOffset"] as number || 0;
const { scale, translateX, translateY } = Utils.GetScreenTransform(this._canvasRef.current!);
- let sscale = this.props.DocumentContentsOfCollection!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
+ let sscale = this.props.DocumentViewForCollection!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
const screenX = de.x - xOffset;
const screenY = de.y - yOffset;
const docX = (screenX - translateX) / sscale / scale;
@@ -94,7 +94,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
if (!e.cancelBubble && this.active) {
e.preventDefault();
e.stopPropagation();
- let currScale: number = this.props.DocumentContentsOfCollection!.ScalingToScreenSpace;
+ let currScale: number = this.props.DocumentViewForCollection!.ScalingToScreenSpace;
let x = this.props.DocumentForCollection.GetFieldValue(KeyStore.PanX, NumberField, Number(0));
let y = this.props.DocumentForCollection.GetFieldValue(KeyStore.PanY, NumberField, Number(0));
this.props.DocumentForCollection.SetFieldValue(KeyStore.PanX, x + (e.pageX - this._lastX) / currScale, NumberField);
@@ -108,7 +108,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
onPointerWheel = (e: React.WheelEvent): void => {
e.stopPropagation();
- let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.DocumentContentsOfCollection!.TransformToLocalPoint(e.pageX, e.pageY);
+ let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.DocumentViewForCollection!.TransformToLocalPoint(e.pageX, e.pageY);
var deltaScale = (1 - (e.deltaY / 1000)) * Ss;
@@ -198,7 +198,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
<div className="node-container" ref={this._nodeContainerRef}>
{value.map(doc => {
- return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentContentsView={this.props.DocumentContentsOfCollection} />);
+ return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentContentsView={this.props.DocumentViewForCollection} />);
})}
</div>
</div>
diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx
index 8c79c9189..b2ff95329 100644
--- a/src/views/collections/CollectionSchemaView.tsx
+++ b/src/views/collections/CollectionSchemaView.tsx
@@ -20,13 +20,13 @@ export class CollectionSchemaView extends CollectionViewBase {
selectedIndex = 0;
renderCell = (rowProps: CellInfo) => {
- if (!this.props.DocumentContentsOfCollection) {
+ if (!this.props.DocumentViewForCollection) {
return <div></div>
}
let props: FieldViewProps = {
doc: rowProps.value[0],
fieldKey: rowProps.value[1],
- documentViewContainer: this.props.DocumentContentsOfCollection
+ documentViewContainer: this.props.DocumentViewForCollection
}
return (
<FieldView {...props} />
@@ -78,7 +78,7 @@ export class CollectionSchemaView extends CollectionViewBase {
let content;
if (this.selectedIndex != -1) {
content = (<DocumentView Document={children[this.selectedIndex]}
- DocumentContentsView={this.props.DocumentContentsOfCollection}
+ DocumentContentsView={this.props.DocumentViewForCollection}
ContainingCollectionView={this} />)
} else {
content = <div />
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index fd5ffeb61..7ff1ef5cc 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -11,7 +11,7 @@ import { CollectionDockingView } from "../collections/CollectionDockingView";
import { CollectionFreeFormView } from "../collections/CollectionFreeFormView";
import { CollectionSchemaView } from "../collections/CollectionSchemaView";
import { CollectionViewBase, COLLECTION_BORDER_WIDTH } from "../collections/CollectionViewBase";
-import { FieldTextBox } from "../nodes/FieldTextBox";
+import { FormattedTextBox } from "../nodes/FormattedTextBox";
import { ImageBox } from "../nodes/ImageBox";
import "./NodeView.scss";
import React = require("react");
@@ -49,9 +49,9 @@ export class DocumentView extends React.Component<DocumentViewProps> {
//
@computed
public get ScalingToScreenSpace(): number {
- if (this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView.props.DocumentContentsOfCollection != undefined) {
+ if (this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView.props.DocumentViewForCollection != undefined) {
let ss = this.props.ContainingCollectionView.props.DocumentForCollection.GetFieldValue(KeyStore.Scale, NumberField, Number(1));
- return this.props.ContainingCollectionView.props.DocumentContentsOfCollection.ScalingToScreenSpace * ss;
+ return this.props.ContainingCollectionView.props.DocumentViewForCollection.ScalingToScreenSpace * ss;
}
return 1;
}
@@ -62,8 +62,8 @@ export class DocumentView extends React.Component<DocumentViewProps> {
public TransformToLocalPoint(screenX: number, screenY: number) {
// if this collection view is nested within another collection view, then
// first transform the screen point into the parent collection's coordinate space.
- let { LocalX: parentX, LocalY: parentY } = this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView.props.DocumentContentsOfCollection != undefined ?
- this.props.ContainingCollectionView.props.DocumentContentsOfCollection.TransformToLocalPoint(screenX, screenY) :
+ let { LocalX: parentX, LocalY: parentY } = this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView.props.DocumentViewForCollection != undefined ?
+ this.props.ContainingCollectionView.props.DocumentViewForCollection.TransformToLocalPoint(screenX, screenY) :
{ LocalX: screenX, LocalY: screenY };
let ContainerX: number = parentX - COLLECTION_BORDER_WIDTH;
let ContainerY: number = parentY - COLLECTION_BORDER_WIDTH;
@@ -111,7 +111,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
// if this collection view is nested within another collection view, then
// first transform the local point into the parent collection's coordinate space.
- let containingDocView = this.props.ContainingCollectionView != undefined ? this.props.ContainingCollectionView.props.DocumentContentsOfCollection : undefined;//.ContainingDocumentContentsView;
+ let containingDocView = this.props.ContainingCollectionView != undefined ? this.props.ContainingCollectionView.props.DocumentViewForCollection : undefined;//.ContainingDocumentContentsView;
if (containingDocView != undefined) {
let ss = containingDocView.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1));
let panxx = containingDocView.props.Document.GetFieldValue(KeyStore.PanX, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
@@ -144,7 +144,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
height: "100%",
}}>
<JsxParser
- components={{ FieldTextBox, ImageBox, CollectionFreeFormView, CollectionDockingView, CollectionSchemaView }}
+ components={{ FormattedTextBox: FormattedTextBox, ImageBox, CollectionFreeFormView, CollectionDockingView, CollectionSchemaView }}
bindings={bindings}
jsx={this.layout}
showWarnings={true}
diff --git a/src/views/nodes/FieldView.tsx b/src/views/nodes/FieldView.tsx
index 9f0404dbf..370f6d324 100644
--- a/src/views/nodes/FieldView.tsx
+++ b/src/views/nodes/FieldView.tsx
@@ -6,7 +6,7 @@ import { Field, Opt } from "../../fields/Field";
import { TextField } from "../../fields/TextField";
import { NumberField } from "../../fields/NumberField";
import { RichTextField } from "../../fields/RichTextField";
-import { FieldTextBox } from "./FieldTextBox";
+import { FormattedTextBox } from "./FormattedTextBox";
import { ImageField } from "../../fields/ImageField";
import { ImageBox } from "./ImageBox";
import { Key } from "../../fields/Key";
@@ -15,7 +15,7 @@ import { DocumentView } from "./DocumentView";
//
// these properties get assigned through the render() method of the DocumentView when it creates this node.
// However, that only happens because the properties are "defined" in the markup for the field view.
-// See the LayoutString method on each field view : ImageBox, FieldTextBox, etc.
+// See the LayoutString method on each field view : ImageBox, FormattedTextBox, etc.
//
export interface FieldViewProps {
fieldKey: Key;
@@ -25,6 +25,7 @@ export interface FieldViewProps {
@observer
export class FieldView extends React.Component<FieldViewProps> {
+ public static LayoutString(fieldType: string) { return `<${fieldType} doc={Document} documentViewContainer={DocumentContentsView} fieldKey={DataKey} />`; }
@computed
get field(): Opt<Field> {
const { doc, fieldKey } = this.props;
@@ -39,7 +40,7 @@ export class FieldView extends React.Component<FieldViewProps> {
return <p>{field.Data}</p>
}
else if (field instanceof RichTextField) {
- return <FieldTextBox {...this.props} />
+ return <FormattedTextBox {...this.props} />
}
else if (field instanceof ImageField) {
return <ImageBox {...this.props} />
diff --git a/src/views/nodes/FieldTextBox.scss b/src/views/nodes/FormattedTextBox.scss
index b6ce2fabc..492367fce 100644
--- a/src/views/nodes/FieldTextBox.scss
+++ b/src/views/nodes/FormattedTextBox.scss
@@ -8,7 +8,7 @@
outline: none !important
}
-.fieldTextBox-cont {
+.formattedTextBox-cont {
background: white;
padding: 1vw;
} \ No newline at end of file
diff --git a/src/views/nodes/FieldTextBox.tsx b/src/views/nodes/FormattedTextBox.tsx
index 0e884a031..d51e91315 100644
--- a/src/views/nodes/FieldTextBox.tsx
+++ b/src/views/nodes/FormattedTextBox.tsx
@@ -5,23 +5,21 @@ import { keymap } from "prosemirror-keymap";
import { schema } from "prosemirror-schema-basic";
import { EditorState, Transaction } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
-import { Document } from "../../fields/Document";
import { Opt } from "../../fields/Field";
-import { Key } from "../../fields/Key";
import { SelectionManager } from "../../util/SelectionManager";
-import "./FieldTextBox.scss";
+import "./FormattedTextBox.scss";
import React = require("react")
import { RichTextField } from "../../fields/RichTextField";
-import { FieldViewProps } from "./FieldView";
+import { FieldViewProps, FieldView } from "./FieldView";
import { CollectionFreeFormDocumentView } from "./CollectionFreeFormDocumentView";
-// FieldTextBox: Displays an editable plain text node that maps to a specified Key of a Document
+// FormattedTextBox: Displays an editable plain text node that maps to a specified Key of a Document
//
-// HTML Markup: <FieldTextBox Doc={Document's ID} FieldKey={Key's name + "Key"}
+// HTML Markup: <FormattedTextBox Doc={Document's ID} FieldKey={Key's name + "Key"}
//
// In Code, the node's HTML is specified in the document's parameterized structure as:
-// document.SetField(KeyStore.Layout, "<FieldTextBox doc={doc} fieldKey={<KEYNAME>Key} />");
+// document.SetField(KeyStore.Layout, "<FormattedTextBox doc={doc} fieldKey={<KEYNAME>Key} />");
// and the node's binding to the specified document KEYNAME as:
// document.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.<KEYNAME>]));
// The Jsx parser at run time will bind:
@@ -32,9 +30,9 @@ import { CollectionFreeFormDocumentView } from "./CollectionFreeFormDocumentView
// specified Key and assigns it to an HTML input node. When changes are made tot his node,
// this will edit the document and assign the new value to that field.
//
-export class FieldTextBox extends React.Component<FieldViewProps> {
+export class FormattedTextBox extends React.Component<FieldViewProps> {
- public static LayoutString() { return "<FieldTextBox doc={Document} documentViewContainer={DocumentContentsView} fieldKey={DataKey} />"; }
+ public static LayoutString() { return FieldView.LayoutString("FormattedTextBox"); }
private _ref: React.RefObject<HTMLDivElement>;
private _editorView: Opt<EditorView>;
private _reactionDisposer: Opt<IReactionDisposer>;
@@ -116,7 +114,7 @@ export class FieldTextBox extends React.Component<FieldViewProps> {
}
}
render() {
- return (<div className="fieldTextBox-cont"
+ return (<div className="formattedTextBox-cont"
style={{
color: "initial",
whiteSpace: "initial"
diff --git a/src/views/nodes/ImageBox.tsx b/src/views/nodes/ImageBox.tsx
index a4254ce39..cced95c89 100644
--- a/src/views/nodes/ImageBox.tsx
+++ b/src/views/nodes/ImageBox.tsx
@@ -5,7 +5,7 @@ import { SelectionManager } from "../../util/SelectionManager";
import "./ImageBox.scss";
import React = require("react")
import { ImageField } from '../../fields/ImageField';
-import { FieldViewProps } from './FieldView';
+import { FieldViewProps, FieldView } from './FieldView';
import { CollectionFreeFormDocumentView } from './CollectionFreeFormDocumentView';
interface ImageBoxState {
@@ -15,7 +15,7 @@ interface ImageBoxState {
export class ImageBox extends React.Component<FieldViewProps, ImageBoxState> {
- public static LayoutString() { return "<ImageBox doc={Document} documentViewContainer={DocumentContentsView} fieldKey={DataKey} />"; }
+ public static LayoutString() { return FieldView.LayoutString("ImageBox"); }
private _ref: React.RefObject<HTMLDivElement>;
private _downX: number = 0;
private _downY: number = 0;