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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/documents') 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") + -- cgit v1.2.3-70-g09d2 From 88b175395307e31ce713ff66c3e2ae9c62e1a369 Mon Sep 17 00:00:00 2001 From: Tyler Schicke 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/client/documents') 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 8601bcbb46c80282d1fac6863544f9c72050ebd4 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Sat, 16 Mar 2019 23:16:26 -0400 Subject: Fixed server bug --- src/client/Server.ts | 30 +++++++++++++++++++++++++++--- src/client/SocketStub.ts | 1 + src/client/documents/Documents.ts | 2 +- src/client/views/nodes/DocumentView.tsx | 6 +++++- 4 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src/client/documents') diff --git a/src/client/Server.ts b/src/client/Server.ts index f0cf0bb9b..f2d7de75c 100644 --- a/src/client/Server.ts +++ b/src/client/Server.ts @@ -40,8 +40,8 @@ export class Server { return this.ClientFieldsCached.get(fieldid); }, (field, reaction) => { if (field !== "") { - callback(field) reaction.dispose() + callback(field) } }) } @@ -49,14 +49,38 @@ export class Server { } public static GetFields(fieldIds: FieldId[], callback: (fields: { [id: string]: Field }) => any) { - SocketStub.SEND_FIELDS_REQUEST(fieldIds, (fields) => { + let neededFieldIds: FieldId[] = []; + let waitingFieldIds: FieldId[] = []; + let existingFields: { [id: string]: Field } = {}; + for (let id of fieldIds) { + let field = this.ClientFieldsCached.get(id); + if (!field) { + neededFieldIds.push(id); + } else if (field === FieldWaiting) { + waitingFieldIds.push(id); + } else { + existingFields[id] = field; + } + } + SocketStub.SEND_FIELDS_REQUEST(neededFieldIds, (fields) => { for (let key in fields) { let field = fields[key]; if (!this.ClientFieldsCached.has(field.Id)) { this.ClientFieldsCached.set(field.Id, field) } } - callback(fields) + reaction(() => { + return waitingFieldIds.map(this.ClientFieldsCached.get); + }, (cachedFields, reaction) => { + if (!cachedFields.some(field => !field || field === FieldWaiting)) { + reaction.dispose(); + for (let field of cachedFields) { + let realField = field as Field; + existingFields[realField.Id] = realField; + } + callback({ ...fields, ...existingFields }) + } + }, { fireImmediately: true }) }); } diff --git a/src/client/SocketStub.ts b/src/client/SocketStub.ts index 18df4ca0a..a0b89b7c9 100644 --- a/src/client/SocketStub.ts +++ b/src/client/SocketStub.ts @@ -7,6 +7,7 @@ import { Utils } from "../Utils"; import { Server } from "./Server"; import { ServerUtils } from "../server/ServerUtil"; +//TODO tfs: I think it might be cleaner to not have SocketStub deal with turning what the server gives it into Fields (in other words not call ServerUtils.FromJson), and leave that for the Server class. export class SocketStub { static FieldStore: ObservableMap = new ObservableMap(); diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 7b6409a62..bec4dd697 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -175,7 +175,7 @@ export namespace Documents { return SetInstanceOptions(GetAudioPrototype(), options, [new URL(url), AudioField]); } export function TextDocument(options: DocumentOptions = {}) { - return SetInstanceOptions(GetTextPrototype(), options, ["", RichTextField]); + return SetInstanceOptions(GetTextPrototype(), options, ["", TextField]); } export function PdfDocument(url: string, options: DocumentOptions = {}) { return SetInstanceOptions(GetPdfPrototype(), options, [new URL(url), PDFField]); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 3c1f98ef8..7a43c34d0 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -188,6 +188,9 @@ export class DocumentView extends React.Component { SelectionManager.SelectDoc(this, e.ctrlKey); } } + stopPropogation = (e: React.SyntheticEvent) => { + e.stopPropagation(); + } deleteClicked = (): void => { if (this.props.RemoveDocument) { @@ -338,7 +341,8 @@ export class DocumentView extends React.Component { }} onDrop={this.onDrop} onContextMenu={this.onContextMenu} - onPointerDown={this.onPointerDown} > + onPointerDown={this.onPointerDown} + onPointerUp={this.stopPropogation} > ) -- cgit v1.2.3-70-g09d2 From dcbd110cd73d13a543e8c0013ca98340968f6d9f Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 17 Mar 2019 00:10:39 -0400 Subject: adjusted caption layout --- src/client/documents/Documents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/documents') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index bec4dd697..a92cf97fe 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -222,7 +222,7 @@ export namespace Documents {
{layout}
-
+
-- cgit v1.2.3-70-g09d2