diff options
author | madelinegr <mgriswold99@gmail.com> | 2019-02-25 17:51:40 -0500 |
---|---|---|
committer | madelinegr <mgriswold99@gmail.com> | 2019-02-25 17:51:40 -0500 |
commit | efe5d9515c88f6e0963ae1c04545b7bbbd8beb55 (patch) | |
tree | fb18426341cee8f8f6f04dc39e5e2d7b53f9c529 | |
parent | dfe69e008b073a5c1dace2dc047e6696318e4720 (diff) |
fixed some of bugs caused by pulling from master
-rw-r--r-- | src/client/documents/Documents.ts | 27 | ||||
-rw-r--r-- | src/client/views/nodes/FieldView.tsx | 5 | ||||
-rw-r--r-- | src/client/views/nodes/WebBox.tsx | 8 | ||||
-rw-r--r-- | src/fields/WebField.ts | 15 | ||||
-rw-r--r-- | src/server/Message.ts | 2 |
5 files changed, 17 insertions, 40 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 398c6f1a2..5c73c6b87 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -7,17 +7,12 @@ import { ListField } from "../../fields/ListField"; import { FormattedTextBox } from "../views/nodes/FormattedTextBox"; import { ImageField } from "../../fields/ImageField"; import { ImageBox } from "../views/nodes/ImageBox"; -<<<<<<< HEAD import { WebField } from "../../fields/WebField"; import { WebBox } from "../views/nodes/WebBox"; import { CollectionFreeFormView } from "../views/collections/CollectionFreeFormView"; import { FieldId } from "../../fields/Field"; -======= import { CollectionView, CollectionViewType } from "../views/collections/CollectionView"; import { FieldView } from "../views/nodes/FieldView"; -import { HtmlField } from "../../fields/HtmlField"; -import { WebView } from "../views/nodes/WebView"; ->>>>>>> bb418216efa9cc2e191b970e4cbe5080f4fd2b87 export interface DocumentOptions { x?: number; @@ -88,28 +83,6 @@ export namespace Documents { return doc; } - let htmlProto: Document; - const htmlProtoId = "htmlProto"; - function GetHtmlPrototype(): Document { - if (!htmlProto) { - htmlProto = new Document(htmlProtoId); - htmlProto.Set(KeyStore.X, new NumberField(0)); - htmlProto.Set(KeyStore.Y, new NumberField(0)); - htmlProto.Set(KeyStore.Width, new NumberField(300)); - htmlProto.Set(KeyStore.Height, new NumberField(150)); - htmlProto.Set(KeyStore.Layout, new TextField(WebView.LayoutString())); - htmlProto.Set(KeyStore.LayoutKeys, new ListField([KeyStore.Data])); - } - return htmlProto; - } - - export function HtmlDocument(html: string, options: DocumentOptions = {}): Document { - let doc = GetHtmlPrototype().MakeDelegate(); - setupOptions(doc, options); - doc.Set(KeyStore.Data, new HtmlField(html)); - return doc; - } - let imageProto: Document; const imageProtoId = "imageProto"; function GetImagePrototype(): Document { diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 368ad049d..978cfe196 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -11,13 +11,10 @@ import { WebField } from "../../../fields/WebField"; import { Key } from "../../../fields/Key"; import { FormattedTextBox } from "./FormattedTextBox"; import { ImageBox } from "./ImageBox"; -<<<<<<< HEAD import { WebBox } from "./WebBox"; import { DocumentView } from "./DocumentView"; -======= import { HtmlField } from "../../../fields/HtmlField"; import { WebView } from "./WebView"; ->>>>>>> bb418216efa9cc2e191b970e4cbe5080f4fd2b87 // // these properties get assigned through the render() method of the DocumentView when it creates this node. @@ -61,8 +58,6 @@ export class FieldView extends React.Component<FieldViewProps> { } else if (field instanceof NumberField) { return <p>{field.Data}</p> - } else if (field instanceof HtmlField) { - return <WebView {...this.props} /> } else if (field != FieldWaiting) { return <p>{field.GetValue}</p> } else diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index b9d0853b9..4f774bae2 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -9,12 +9,12 @@ import { CollectionFreeFormDocumentView } from './CollectionFreeFormDocumentView import { FieldWaiting } from '../../../fields/Field'; import { observer } from "mobx-react" import { observable, action, spy } from 'mobx'; -import { KeyStore } from '../../../fields/Key'; +import { KeyStore } from '../../../fields/KeyStore'; @observer export class WebBox extends React.Component<FieldViewProps> { - public static LayoutString() { return FieldView.LayoutString("WebBox"); } + public static LayoutString() { return FieldView.LayoutString(WebBox); } private _ref: React.RefObject<HTMLDivElement>; private _downX: number = 0; private _downY: number = 0; @@ -38,8 +38,7 @@ export class WebBox extends React.Component<FieldViewProps> { onPointerDown = (e: React.PointerEvent): void => { if (Date.now() - this._lastTap < 300) { - if (e.buttons === 1 && this.props.DocumentViewForField instanceof CollectionFreeFormDocumentView && - SelectionManager.IsSelected(this.props.DocumentViewForField)) { + if (e.buttons === 1 && this.props.isSelected()) { e.stopPropagation(); this._downX = e.clientX; this._downY = e.clientY; @@ -50,6 +49,7 @@ export class WebBox extends React.Component<FieldViewProps> { this._lastTap = Date.now(); } } + @action onPointerUp = (e: PointerEvent): void => { document.removeEventListener("pointerup", this.onPointerUp); diff --git a/src/fields/WebField.ts b/src/fields/WebField.ts index cd3519128..8f945d686 100644 --- a/src/fields/WebField.ts +++ b/src/fields/WebField.ts @@ -1,9 +1,10 @@ import { BasicField } from "./BasicField"; -import { Field } from "./Field"; +import { Field, FieldId } from "./Field"; +import { Types } from "../server/Message"; export class WebField extends BasicField<URL> { - constructor(data: URL | undefined = undefined) { - super(data == undefined ? new URL("https://crossorigin.me/" + "https://cs.brown.edu/") : data); + constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) { + super(data == undefined ? new URL("https://crossorigin.me/" + "https://cs.brown.edu/") : data, save, id); } toString(): string { @@ -18,4 +19,12 @@ export class WebField extends BasicField<URL> { return new WebField(this.Data); } + ToJson(): { type: Types, data: URL, _id: string } { + return { + type: Types.Web, + data: this.Data, + _id: this.Id + } + } + }
\ No newline at end of file diff --git a/src/server/Message.ts b/src/server/Message.ts index 80fc9a80d..148e6e723 100644 --- a/src/server/Message.ts +++ b/src/server/Message.ts @@ -45,7 +45,7 @@ export class GetFieldArgs { } export enum Types { - Number, List, Key, Image, Document, Text, RichText, DocumentReference, Html + Number, List, Key, Image, Web, Document, Text, RichText, DocumentReference, Html } export class DocumentTransfer implements Transferable { |