aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts9
-rw-r--r--src/client/views/Main.tsx2
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx26
3 files changed, 20 insertions, 17 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index a735fe961..bf4acc857 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -17,6 +17,7 @@ import { KeyValueBox } from "../views/nodes/KeyValueBox"
import { PDFField } from "../../fields/PDFField";
import { PDFBox } from "../views/nodes/PDFBox";
import { CollectionPDFView } from "../views/collections/CollectionPDFView";
+import { RichTextField } from "../../fields/RichTextField";
export interface DocumentOptions {
x?: number;
@@ -77,9 +78,11 @@ export namespace Documents {
function setupPrototypeOptions(protoId: string, title: string, layout: string, options: DocumentOptions): Document {
return assignOptions(new Document(protoId), { ...options, title: title, layout: layout });
}
- function SetInstanceOptions<T, U extends Field & { Data: T }>(doc: Document, options: DocumentOptions, value: T, ctor: { new(): U }, id?: string) {
+ function SetInstanceOptions<T, U extends Field & { Data: T }>(doc: Document, options: DocumentOptions, value: T | undefined, ctor: { new(): U } | undefined, id?: string) {
var deleg = doc.MakeDelegate(id);
- deleg.SetData(KeyStore.Data, value, ctor);
+ if (value !== undefined && ctor !== undefined) {
+ deleg.SetData(KeyStore.Data, value, ctor);
+ }
return assignOptions(deleg, options);
}
@@ -131,7 +134,7 @@ export namespace Documents {
return doc;
}
export function TextDocument(options: DocumentOptions = {}) {
- return SetInstanceOptions(GetTextPrototype(), options, "", TextField);
+ return SetInstanceOptions(GetTextPrototype(), options, undefined, undefined);
}
export function PdfDocument(url: string, options: DocumentOptions = {}) {
return SetInstanceOptions(GetPdfPrototype(), options, new URL(url), PDFField);
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 73d5fa8a9..44fdf60ce 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -72,7 +72,7 @@ export class Main extends React.Component {
@action
createNewWorkspace = (init: boolean): void => {
- let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: `Main Container ${this.userWorkspaces.length}` });
+ let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: `Main Container ${this.userWorkspaces.length + 1}` });
let newId = mainDoc.Id;
request.post(this.contextualize("addWorkspaceId"), {
body: { target: newId },
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index 11c96d074..0d5e15767 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -170,19 +170,19 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
onKeyDown = (e: React.KeyboardEvent<Element>) => {
//if not these keys, make a textbox if preview cursor is active!
- if (!e.ctrlKey && !e.altKey) {
- if (this._previewCursorVisible) {
- //make textbox and add it to this collection
- let [x, y] = this.getTransform().transformPoint(this._downX, this._downY); (this._downX, this._downY);
- let newBox = Documents.TextDocument({ width: 200, height: 100, x: x, y: y, title: "new" });
- // mark this collection so that when the text box is created we can send it the SelectOnLoad prop to focus itself
- this._selectOnLoaded = newBox.Id;
- //set text to be the typed key and get focus on text box
- this.props.CollectionView.addDocument(newBox);
- //remove cursor from screen
- this._previewCursorVisible = false;
- }
- }
+ // if (!e.ctrlKey && !e.altKey) {
+ // if (this._previewCursorVisible) {
+ // //make textbox and add it to this collection
+ // let [x, y] = this.getTransform().transformPoint(this._downX, this._downY); (this._downX, this._downY);
+ // let newBox = Documents.TextDocument({ width: 200, height: 100, x: x, y: y, title: "new" });
+ // // mark this collection so that when the text box is created we can send it the SelectOnLoad prop to focus itself
+ // this._selectOnLoaded = newBox.Id;
+ // //set text to be the typed key and get focus on text box
+ // this.props.CollectionView.addDocument(newBox);
+ // //remove cursor from screen
+ // this._previewCursorVisible = false;
+ // }
+ // }
}
@action