From 3101134e8e579a6f9202d552c46d2a8bd70fda79 Mon Sep 17 00:00:00 2001 From: Monika Hedman Date: Sat, 16 Mar 2019 18:48:21 -0400 Subject: cant get image stuff???? --- src/client/documents/Documents.ts | 2 +- .../views/collections/CollectionFreeFormView.tsx | 23 +++++++++++++++++++++- .../views/collections/CollectionViewBase.tsx | 8 ++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 05bc743be..983253347 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -209,7 +209,7 @@ export namespace Documents { + FormattedTextBox.LayoutString("CaptionKey") + ` ` }; - function FixedCaption(fieldName: string = "Caption") { + export function FixedCaption(fieldName: string = "Caption") { return `
` + FormattedTextBox.LayoutString(fieldName + "Key") + diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index a94539312..79ea77c77 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -31,6 +31,7 @@ import { MarqueeView } from "./MarqueeView"; import { PreviewCursor } from "./PreviewCursor"; import React = require("react"); const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this? +import { ImageField } from '../../../fields/ImageField'; @observer export class CollectionFreeFormView extends CollectionViewBase { @@ -208,7 +209,27 @@ export class CollectionFreeFormView extends CollectionViewBase { @action onDrop = (e: React.DragEvent): void => { var pt = this.getTransform().transformPoint(e.pageX, e.pageY); - super.onDrop(e, { x: pt[0], y: pt[1] }); + + let text = e.dataTransfer.getData("text/plain"); + let start = text.startsWith("(KeyStore.Data, []); + console.log(children); + if (children) { + children.forEach(f => { + console.log(f.GetData(KeyStore.Layout, TextField, new String)); + }); + } + // let xx = this.props.Document.GetT(KeyStore.Thumbnail, ImageField) + // if (xx) { + // console.log(xx.toString()) + // } + this.props.Document.SetData(KeyStore.Layout, text, TextField); + e.stopPropagation(); + } + else { super.onDrop(e, { x: pt[0], y: pt[1] }); } } onDragOver = (): void => { diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index eda62a4ca..dd05837d8 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -47,12 +47,19 @@ export class CollectionViewBase extends React.Component protected drop(e: Event, de: DragManager.DropEvent) { const docView: DocumentView = de.data["documentView"]; const doc: Document = de.data["document"]; + if (docView && (!docView.props.ContainingCollectionView || docView.props.ContainingCollectionView !== this.props.CollectionView)) { if (docView.props.RemoveDocument) { + docView.props.RemoveDocument(docView.props.Document); } + console.log("2"); + //console.log(docView.props.Document.GetData(KeyStore.Data, "")) + //let text = doc.GetText(KeyStore.DocumentText, ""); + console.log("text") this.props.addDocument(docView.props.Document); } else if (doc) { + // console.log("3"); this.props.removeDocument(doc); this.props.addDocument(doc); } @@ -67,6 +74,7 @@ export class CollectionViewBase extends React.Component let html = e.dataTransfer.getData("text/html"); let text = e.dataTransfer.getData("text/plain"); + if (html && html.indexOf(" Date: Sat, 16 Mar 2019 21:48:13 -0400 Subject: Everything but the actual template works --- src/client/documents/Documents.ts | 15 ++++++++++++++- .../views/collections/CollectionFreeFormView.tsx | 22 +--------------------- .../views/collections/CollectionViewBase.tsx | 8 ++++++-- src/client/views/nodes/DocumentView.tsx | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 983253347..7b6409a62 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -209,10 +209,23 @@ export namespace Documents { + FormattedTextBox.LayoutString("CaptionKey") + `
` }; - export function FixedCaption(fieldName: string = "Caption") { + function FixedCaption(fieldName: string = "Caption") { return `
` + FormattedTextBox.LayoutString(fieldName + "Key") + `
` }; + + function Caption() { + return (` +
+
+ {layout} +
+
+ +
+
+ `) + } } \ No newline at end of file diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index 79ea77c77..0a4b57ffb 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -209,27 +209,7 @@ export class CollectionFreeFormView extends CollectionViewBase { @action onDrop = (e: React.DragEvent): void => { var pt = this.getTransform().transformPoint(e.pageX, e.pageY); - - let text = e.dataTransfer.getData("text/plain"); - let start = text.startsWith("(KeyStore.Data, []); - console.log(children); - if (children) { - children.forEach(f => { - console.log(f.GetData(KeyStore.Layout, TextField, new String)); - }); - } - // let xx = this.props.Document.GetT(KeyStore.Thumbnail, ImageField) - // if (xx) { - // console.log(xx.toString()) - // } - this.props.Document.SetData(KeyStore.Layout, text, TextField); - e.stopPropagation(); - } - else { super.onDrop(e, { x: pt[0], y: pt[1] }); } + super.onDrop(e, { x: pt[0], y: pt[1] }); } onDragOver = (): void => { diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index dd05837d8..b0f42125a 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -68,13 +68,17 @@ export class CollectionViewBase extends React.Component @action protected onDrop(e: React.DragEvent, options: DocumentOptions): void { - e.stopPropagation() - e.preventDefault() let that = this; let html = e.dataTransfer.getData("text/html"); let text = e.dataTransfer.getData("text/plain"); + if (text && text.startsWith(" { e.stopPropagation(); } + onDrop = (e: React.DragEvent) => { + if (e.isDefaultPrevented()) { + return; + } + let text = e.dataTransfer.getData("text/plain"); + if (text && text.startsWith(" { e.stopPropagation(); @@ -315,6 +329,7 @@ export class DocumentView extends React.Component { transformOrigin: "left top", transform: `scale(${scaling} , ${scaling})` }} + onDrop={this.onDrop} onContextMenu={this.onContextMenu} onPointerDown={this.onPointerDown} > -- cgit v1.2.3-70-g09d2 From a5a5e17adb4f5881c905baa13669c0ca4e884467 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Sat, 16 Mar 2019 21:52:33 -0400 Subject: Cleanup --- src/client/views/collections/CollectionFreeFormView.tsx | 7 ++----- src/client/views/collections/CollectionViewBase.tsx | 6 ------ 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index 0a4b57ffb..9dc1ae847 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -1,11 +1,10 @@ -import { action, computed, observable, trace } from "mobx"; +import { action, computed, observable } from "mobx"; import { observer } from "mobx-react"; import { Document } from "../../../fields/Document"; import { FieldWaiting } from "../../../fields/Field"; import { KeyStore } from "../../../fields/KeyStore"; import { ListField } from "../../../fields/ListField"; import { TextField } from "../../../fields/TextField"; -import { Documents } from "../../documents/Documents"; import { DragManager } from "../../util/DragManager"; import { Transform } from "../../util/Transform"; import { undoBatch } from "../../util/UndoManager"; @@ -31,7 +30,6 @@ import { MarqueeView } from "./MarqueeView"; import { PreviewCursor } from "./PreviewCursor"; import React = require("react"); const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this? -import { ImageField } from '../../../fields/ImageField'; @observer export class CollectionFreeFormView extends CollectionViewBase { @@ -199,7 +197,6 @@ export class CollectionFreeFormView extends CollectionViewBase { @action private SetPan(panX: number, panY: number) { var x1 = this.getLocalTransform().inverse().Scale; - var x2 = this.getTransform().inverse().Scale; const newPanX = Math.min((1 - 1 / x1) * this.nativeWidth, Math.max(0, panX)); const newPanY = Math.min((1 - 1 / x1) * this.nativeHeight, Math.max(0, panY)); this.props.Document.SetNumber(KeyStore.PanX, this.isAnnotationOverlay ? newPanX : panX); @@ -309,7 +306,7 @@ export class CollectionFreeFormView extends CollectionViewBase { //when focus is lost, this will remove the preview cursor @action - onBlur = (e: React.FocusEvent): void => { + onBlur = (): void => { this.PreviewCursorVisible = false; } diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index b0f42125a..d9598aa72 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -50,16 +50,10 @@ export class CollectionViewBase extends React.Component if (docView && (!docView.props.ContainingCollectionView || docView.props.ContainingCollectionView !== this.props.CollectionView)) { if (docView.props.RemoveDocument) { - docView.props.RemoveDocument(docView.props.Document); } - console.log("2"); - //console.log(docView.props.Document.GetData(KeyStore.Data, "")) - //let text = doc.GetText(KeyStore.DocumentText, ""); - console.log("text") this.props.addDocument(docView.props.Document); } else if (doc) { - // console.log("3"); this.props.removeDocument(doc); this.props.addDocument(doc); } -- cgit v1.2.3-70-g09d2