diff options
author | Monika Hedman <monika_hedman@brown.edu> | 2019-03-16 18:48:21 -0400 |
---|---|---|
committer | Monika Hedman <monika_hedman@brown.edu> | 2019-03-16 18:48:21 -0400 |
commit | 3101134e8e579a6f9202d552c46d2a8bd70fda79 (patch) | |
tree | 1c582a510af7127406cac7516308a1896e4c1bc8 /src | |
parent | 914114aaffbbd492f68c5e580acf6a28f43dc2c7 (diff) |
cant get image stuff????
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/Documents.ts | 2 | ||||
-rw-r--r-- | src/client/views/collections/CollectionFreeFormView.tsx | 23 | ||||
-rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 8 |
3 files changed, 31 insertions, 2 deletions
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") + `</div> </div>` }; - function FixedCaption(fieldName: string = "Caption") { + export function FixedCaption(fieldName: string = "Caption") { return `<div style="position:absolute; height:30px; bottom:0; width:100%"> <div style="position:absolute; width:100%; height:100%; text-align:center;bottom:0;">` + 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("<div") + if (start) { + console.log(e.target); + console.log(this.props.Document.GetData(KeyStore.Layout, TextField, new String)) + var children = this.props.Document.GetList<Document>(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<SubCollectionViewProps> 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<SubCollectionViewProps> let html = e.dataTransfer.getData("text/html"); let text = e.dataTransfer.getData("text/plain"); + if (html && html.indexOf("<img") != 0) { console.log("not good"); let htmlDoc = Documents.HtmlDocument(html, { ...options, width: 300, height: 300 }); |