+ style={{ width: `${this._textRect.width * s}px`, height: `${this._textRect.height * s}px` }}>
diff --git a/src/client/views/Templates.tsx b/src/client/views/Templates.tsx
index 52021861f..a0f9fe7e5 100644
--- a/src/client/views/Templates.tsx
+++ b/src/client/views/Templates.tsx
@@ -39,15 +39,15 @@ export namespace Templates {
// export const BasicLayout = new Template("Basic layout", "{layout}");
export const OuterCaption = new Template("Outer caption", TemplatePosition.OutterBottom,
- `
`
+ `
`
);
export const InnerCaption = new Template("Inner caption", TemplatePosition.InnerBottom,
- `
`
+ `
`
);
export const SideCaption = new Template("Side caption", TemplatePosition.OutterRight,
- `
`
+ `
`
);
export const Title = new Template("Title", TemplatePosition.InnerTop,
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 07599c345..e9c46aa9d 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -47,7 +47,9 @@ export class DocumentContentsView extends React.Component
obj.active = this.props.parentActive) };
- for (const key of this.layoutKeys) {
+ let keys: Key[] = [];
+ keys.push(...this.layoutKeys, KeyStore.Caption) // bcz: hack to get templates to work
+ for (const key of keys) {
bindings[key.Name + "Key"] = key; // this maps string values of the form Key to an actual key Kestore.keyname e.g, "DataKey" => KeyStore.Data
}
for (const key of this.layoutFields) {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index bae14193e..6dddab600 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -26,6 +26,7 @@ import React = require("react");
import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
import { MarqueeView } from "../collections/collectionFreeForm/MarqueeView";
+import { TextField } from "../../../fields/TextField";
export interface DocumentViewProps {
ContainingCollectionView: Opt;
@@ -88,7 +89,6 @@ export function FakeJsxArgs(keys: string[], fields: string[] = []): JsxArgs {
export class DocumentView extends React.Component {
private _downX: number = 0;
private _downY: number = 0;
- @computed get base(): string { return this.props.Document.GetText(KeyStore.BaseLayout, "Error loading base layout data
"); }
private _mainCont = React.createRef();
private _dropDisposer?: DragManager.DragDropDisposer;
@@ -249,17 +249,20 @@ export class DocumentView extends React.Component {
}
}
- updateLayout = (): void => {
- let base = this.base;
- let layout = this.base;
+ updateLayout = async () => {
+ const baseLayout = await this.props.Document.GetTAsync(KeyStore.BaseLayout, TextField);
+ if (baseLayout) {
+ let base = baseLayout.Data;
+ let layout = baseLayout.Data;
- this.templates.forEach(template => {
- let temp = template.Layout;
- layout = temp.replace("{layout}", base);
- base = layout;
- });
+ this.templates.forEach(template => {
+ let temp = template.Layout;
+ layout = temp.replace("{layout}", base);
+ base = layout;
+ });
- this.props.Document.SetText(KeyStore.Layout, layout);
+ this.props.Document.SetText(KeyStore.Layout, layout);
+ }
}
@action
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index fc8d757f6..92957ed19 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -50,6 +50,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
return FieldView.LayoutString(FormattedTextBox, fieldStr);
}
private _ref: React.RefObject;
+ private _proseRef: React.RefObject;
private _editorView: Opt;
private _gotDown: boolean = false;
private _reactionDisposer: Opt;
@@ -60,6 +61,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
super(props);
this._ref = React.createRef();
+ this._proseRef = React.createRef();
this.onChange = this.onChange.bind(this);
}
@@ -188,9 +190,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
onFocused = (e: React.FocusEvent): void => {
if (!this.props.isOverlay) {
- if (MainOverlayTextBox.Instance.TextDoc != this.props.Document) {
- MainOverlayTextBox.Instance.SetTextDoc(this.props.Document, this.props.fieldKey, this._ref.current!, this.props.ScreenToLocalTransform);
- }
+ MainOverlayTextBox.Instance.SetTextDoc(this.props.Document, this.props.fieldKey, this._ref.current!, this.props.ScreenToLocalTransform);
} else {
if (this._ref.current) {
this._ref.current.scrollTop = MainOverlayTextBox.Instance.TextScroll;
@@ -232,7 +232,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
}
onClick = (e: React.MouseEvent): void => {
- this._ref.current!.focus();
+ this._proseRef.current!.focus();
}
tooltipTextMenuPlugin() {
@@ -277,7 +277,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
let color = this.props.Document.GetText(KeyStore.BackgroundColor, "");
let interactive = InkingControl.Instance.selectedTool ? "" : "-interactive";
return (
-
);
}
--
cgit v1.2.3-70-g09d2
From 407c104f0ad0957d71f73c14f5b835fab387ecd2 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Thu, 2 May 2019 00:50:08 -0400
Subject: fixed up templates a bit. starting on summarization
---
src/client/views/Templates.tsx | 3 ++
.../collections/collectionFreeForm/MarqueeView.tsx | 5 +++-
src/client/views/nodes/DocumentContentsView.tsx | 25 +++++++++++++++--
src/client/views/nodes/DocumentView.tsx | 32 ++++------------------
4 files changed, 36 insertions(+), 29 deletions(-)
(limited to 'src/client/views/nodes/DocumentContentsView.tsx')
diff --git a/src/client/views/Templates.tsx b/src/client/views/Templates.tsx
index 25d89772e..e17dd2354 100644
--- a/src/client/views/Templates.tsx
+++ b/src/client/views/Templates.tsx
@@ -53,6 +53,9 @@ export namespace Templates {
export const Title = new Template("Title", TemplatePosition.InnerTop,
`{layout}
{props.Document.title}
`
);
+ export const Summary = new Template("Title", TemplatePosition.InnerTop,
+ `{layout}
{props.Document.doc1.title}
`
+ );
export const TemplateList: Template[] = [Title, OuterCaption, InnerCaption, SideCaption];
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 85a12defa..c58e7780c 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -13,6 +13,8 @@ import { Utils } from "../../../../Utils";
import { Doc } from "../../../../new_fields/Doc";
import { NumCast, Cast } from "../../../../new_fields/Types";
import { InkField, StrokeData } from "../../../../new_fields/InkField";
+import { Templates } from "../../Templates";
+import { List } from "../../../../new_fields/List";
interface MarqueeViewProps {
getContainerTransform: () => Transform;
@@ -178,7 +180,8 @@ export class MarqueeView extends React.Component
// SelectionManager.DeselectAll();
if (e.key === "r") {
let summary = Docs.TextDocument({ x: bounds.left, y: bounds.top, width: 300, height: 100, backgroundColor: "yellow", title: "-summary-" });
- Doc.MakeLink(summary.proto!, newCollection.proto!);
+ summary.doc1 = newCollection.proto!;
+ summary.templates = new List([Templates.Summary.Layout]);
this.props.addLiveTextDocument(summary);
e.preventDefault();
}
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 794442469..24e8a36ae 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -20,7 +20,8 @@ import { HistogramBox } from "../../northstar/dash-nodes/HistogramBox";
import React = require("react");
import { FieldViewProps } from "./FieldView";
import { Without, OmitKeys } from "../../../Utils";
-import { Cast } from "../../../new_fields/Types";
+import { Cast, StrCast } from "../../../new_fields/Types";
+import { List } from "../../../new_fields/List";
const JsxParser = require('react-jsx-parser').default; //TODO Why does this need to be imported like this?
type BindingProps = Without;
@@ -40,11 +41,31 @@ export class DocumentContentsView extends React.Component obj.active = this.props.parentActive).omit };
}
+ @computed get templates(): List {
+ let field = this.props.Document.templates;
+ if (field && field instanceof List) {
+ return field;
+ }
+ return new List();
+ }
+ set templates(templates: List) { this.props.Document.templates = templates; }
+ get finalLayout() {
+ const baseLayout = this.layout;
+ let base = baseLayout;
+ let layout = baseLayout;
+
+ this.templates.forEach(template => {
+ layout = template.replace("{layout}", base);
+ base = layout;
+ });
+ return layout;
+ }
+
render() {
return { console.log(test); }}
/>;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index ae2d3af13..e83f3fcba 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -243,42 +243,22 @@ export class DocumentView extends DocComponent(Docu
}
}
- updateLayout = async () => {
- const baseLayout = await StrCast(this.props.Document.baseLayout);
- if (baseLayout) {
- let base = baseLayout;
- let layout = baseLayout;
-
- this.templates.forEach(template => {
- layout = template.replace("{layout}", base);
- base = layout;
- });
-
- this.props.Document.layout = layout;
- }
- }
@action
addTemplate = (template: Template) => {
- let templates = this.templates;
- templates.push(template.Layout);
- this.templates = new List(templates.map(t => t));
- this.updateLayout();
+ this.templates.push(template.Layout);
+ this.templates = this.templates;
}
@action
removeTemplate = (template: Template) => {
- let templates = this.templates;
- for (let i = 0; i < templates.length; i++) {
- let temp = templates[i];
- if (temp === template.Layout) {
- templates.splice(i, 1);
+ for (let i = 0; i < this.templates.length; i++) {
+ if (this.templates[i] === template.Layout) {
+ this.templates.splice(i, 1);
break;
}
}
- templates = new List(templates.splice(0, templates.length));
- this.templates = templates;
- this.updateLayout();
+ this.templates = this.templates;
}
@action
--
cgit v1.2.3-70-g09d2
From a78282cdf7fbb99386484640e1fb89d4b9b0cbee Mon Sep 17 00:00:00 2001
From: bob
Date: Thu, 2 May 2019 16:19:07 -0400
Subject: fixed some things with trees and summaries.
---
src/client/views/Main.tsx | 3 +--
src/client/views/Templates.tsx | 12 +++++++++++-
src/client/views/collections/CollectionTreeView.tsx | 10 +++++++---
.../views/collections/collectionFreeForm/MarqueeView.tsx | 4 +++-
src/client/views/nodes/DocumentContentsView.tsx | 3 ++-
src/client/views/nodes/FieldView.tsx | 11 ++++-------
src/client/views/nodes/ImageBox.scss | 2 ++
src/new_fields/List.ts | 6 +++---
src/server/authentication/models/current_user_utils.ts | 2 ++
9 files changed, 35 insertions(+), 18 deletions(-)
(limited to 'src/client/views/nodes/DocumentContentsView.tsx')
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index a07a2d5b1..97eb73d7f 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -144,8 +144,7 @@ export class Main extends React.Component {
createNewWorkspace = async (id?: string) => {
const list = Cast(CurrentUserUtils.UserDocument.data, listSpec(Doc));
if (list) {
- let libraryDoc = Docs.TreeDocument([CurrentUserUtils.UserDocument], { x: 0, y: 400, title: `Library: ${CurrentUserUtils.email} ${list.length + 1}` });
- libraryDoc.excludeFromLibrary = true;
+ let libraryDoc = await (CurrentUserUtils.UserDocument.library as Doc);
let freeformDoc = Docs.FreeformDocument([], { x: 0, y: 400, title: `WS collection ${list.length + 1}` });
var dockingLayout = { content: [{ type: 'row', content: [CollectionDockingView.makeDocumentConfig(libraryDoc, 150), CollectionDockingView.makeDocumentConfig(freeformDoc, 600)] }] };
let mainDoc = Docs.DockDocument([libraryDoc, freeformDoc], JSON.stringify(dockingLayout), { title: `Workspace ${list.length + 1}` });
diff --git a/src/client/views/Templates.tsx b/src/client/views/Templates.tsx
index e17dd2354..668ae5312 100644
--- a/src/client/views/Templates.tsx
+++ b/src/client/views/Templates.tsx
@@ -54,7 +54,17 @@ export namespace Templates {
`{layout}
{props.Document.title}
`
);
export const Summary = new Template("Title", TemplatePosition.InnerTop,
- `{layout}
{props.Document.doc1.title}
`
+ `
+
+ {layout}
+
+
+
+
+
+
+
+
`
);
export const TemplateList: Template[] = [Title, OuterCaption, InnerCaption, SideCaption];
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 48b226615..2cef1462b 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -1,7 +1,7 @@
import { IconProp, library } from '@fortawesome/fontawesome-svg-core';
import { faCaretDown, faCaretRight, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, observable } from "mobx";
+import { action, observable, trace } from "mobx";
import { observer } from "mobx-react";
import { DragManager, SetupDrag, dropActionType } from "../../util/DragManager";
import { EditableView } from "../EditableView";
@@ -145,8 +145,11 @@ class TreeView extends React.Component {
;
}
public static GetChildElements(docs: Doc[], remove: ((doc: Doc) => void), move: DragManager.MoveFunction, dropAction: dropActionType) {
- return docs.filter(child => !child.excludeFromLibrary).map(child =>
-
);
+ return docs.filter(child => !child.excludeFromLibrary).filter(doc => FieldValue(doc)).map(child => {
+ console.log("child = " + child[Id]);
+ return
+ }
+ );
}
}
@@ -168,6 +171,7 @@ export class CollectionTreeView extends CollectionSubView(Document) {
}
}
render() {
+ trace();
const children = this.children;
let dropAction = StrCast(this.props.Document.dropAction, "alias") as dropActionType;
if (!children) {
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index c58e7780c..82027a6f2 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -180,7 +180,9 @@ export class MarqueeView extends React.Component
// SelectionManager.DeselectAll();
if (e.key === "r") {
let summary = Docs.TextDocument({ x: bounds.left, y: bounds.top, width: 300, height: 100, backgroundColor: "yellow", title: "-summary-" });
- summary.doc1 = newCollection.proto!;
+ summary.doc1 = selected[0];
+ if (selected.length > 1)
+ summary.doc2 = selected[1];
summary.templates = new List([Templates.Summary.Layout]);
this.props.addLiveTextDocument(summary);
e.preventDefault();
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 24e8a36ae..ddfe79a5c 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -15,6 +15,7 @@ import { IconBox } from "./IconBox";
import { KeyValueBox } from "./KeyValueBox";
import { PDFBox } from "./PDFBox";
import { VideoBox } from "./VideoBox";
+import { FieldView } from "./FieldView";
import { WebBox } from "./WebBox";
import { HistogramBox } from "../../northstar/dash-nodes/HistogramBox";
import React = require("react");
@@ -63,7 +64,7 @@ export class DocumentContentsView extends React.Component {
}
render() {
const field = this.field;
- if (!field) {
+ if (field === undefined) {
return {''}
;
}
- if (typeof field === "string") {
- return {field}
;
- }
+ // if (typeof field === "string") {
+ // return {field}
;
+ // }
else if (field instanceof RichTextField) {
return ;
}
@@ -108,9 +108,6 @@ export class FieldView extends React.Component {
// else if (field instanceof HtmlField) {
// return
// }
- else if (typeof field === "number") {
- return {field}
;
- }
else if (!(field instanceof Promise)) {
return {JSON.stringify(field)}
;
}
diff --git a/src/client/views/nodes/ImageBox.scss b/src/client/views/nodes/ImageBox.scss
index 9fe211df0..2316a050e 100644
--- a/src/client/views/nodes/ImageBox.scss
+++ b/src/client/views/nodes/ImageBox.scss
@@ -10,6 +10,8 @@
}
.imageBox-cont-interactive {
pointer-events: all;
+ width:100%;
+ height:auto;
}
.imageBox-dot {
diff --git a/src/new_fields/List.ts b/src/new_fields/List.ts
index 1c4b96c81..db7932cec 100644
--- a/src/new_fields/List.ts
+++ b/src/new_fields/List.ts
@@ -2,7 +2,7 @@ import { Deserializable, autoObject } from "../client/util/SerializationHelper";
import { Field, Update, Self, FieldResult } from "./Doc";
import { setter, getter, deleteProperty } from "./util";
import { serializable, alias, list } from "serializr";
-import { observable } from "mobx";
+import { observable, action } from "mobx";
import { ObjectField, OnUpdate, Copy } from "./ObjectField";
import { RefField } from "./RefField";
import { ProxyField } from "./Proxy";
@@ -25,12 +25,12 @@ const listHandlers: any = {
this[Update]();
return field;
},
- push(...items: any[]) {
+ push: action(function (this: any, ...items: any[]) {
items = items.map(toObjectField);
const res = this[Self].__fields.push(...items);
this[Update]();
return res;
- },
+ }),
reverse() {
const res = this[Self].__fields.reverse();
this[Update]();
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 9db470ca0..93c2afb1d 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -26,6 +26,8 @@ export class CurrentUserUtils {
doc.title = this.email;
doc.data = new List();
doc.optionalRightCollection = Docs.SchemaDocument([], { title: "Pending documents" });
+ doc.library = Docs.TreeDocument([doc], { title: `Library: ${CurrentUserUtils.email}` });
+ (doc.library as Doc).excludeFromLibrary = true;
return doc;
}
--
cgit v1.2.3-70-g09d2
From 14232f5951af02d5a10ce0435a8b38a4e0502cbb Mon Sep 17 00:00:00 2001
From: Tyler Schicke
Date: Thu, 2 May 2019 23:13:07 -0400
Subject: Made DocumentContents JsxParser an observer
---
src/client/views/nodes/DocumentContentsView.tsx | 11 ++++++++++-
src/new_fields/Doc.ts | 1 -
2 files changed, 10 insertions(+), 2 deletions(-)
(limited to 'src/client/views/nodes/DocumentContentsView.tsx')
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index ddfe79a5c..bbc927b5a 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -30,6 +30,15 @@ export interface JsxBindings {
props: BindingProps;
}
+class ObserverJsxParser1 extends JsxParser {
+ constructor(props: any) {
+ super(props);
+ observer(this as any);
+ }
+}
+
+const ObserverJsxParser: typeof JsxParser = ObserverJsxParser1 as any;
+
@observer
export class DocumentContentsView extends React.Component boolean,
@@ -63,7 +72,7 @@ export class DocumentContentsView extends React.Component