aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/documents/DocumentTypes.ts3
-rw-r--r--src/client/documents/Documents.ts13
-rw-r--r--src/client/views/ScriptBox.tsx3
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx5
4 files changed, 19 insertions, 5 deletions
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index 06b15d78c..170d54e96 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -25,5 +25,6 @@ export enum DocumentType {
DOCULINK = "doculink",
PDFANNO = "pdfanno",
INK = "ink",
- DOCUMENT = "document"
+ DOCUMENT = "document",
+ SCRIPT = "script"
} \ No newline at end of file
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index b16e03f66..1d5f5fd95 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -55,6 +55,7 @@ import { MessageStore } from "../../server/Message";
import { ContextMenuProps } from "../views/ContextMenuItem";
import { ContextMenu } from "../views/ContextMenu";
import { LinkBox } from "../views/nodes/LinkBox";
+import { ScriptBox } from "../views/ScriptBox";
const requestImageSize = require('../util/request-image-size');
const path = require('path');
@@ -262,6 +263,10 @@ export namespace Docs {
[DocumentType.INK, {
layout: { view: InkingStroke, dataField: data },
options: { backgroundColor: "transparent" }
+ }],
+ [DocumentType.SCRIPT, {
+ layout: { view: ScriptBox, dataField: data },
+ options: { backgroundColor: "transparent" }
}]
]);
@@ -527,6 +532,10 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.TEXT), text, options);
}
+ export function ScriptDocument(options: DocumentOptions = {}) {
+ return InstanceFromProto(Prototypes.get(DocumentType.SCRIPT), undefined, options);
+ }
+
export function LinkDocument(source: { doc: Doc, ctx?: Doc }, target: { doc: Doc, ctx?: Doc }, options: DocumentOptions = {}, id?: string) {
const doc = InstanceFromProto(Prototypes.get(DocumentType.LINK), undefined, { isButton: true, treeViewHideTitle: true, treeViewOpen: false, removeDropProperties: new List(["isBackground", "isButton"]), ...options });
const linkDocProto = Doc.GetProto(doc);
@@ -810,7 +819,7 @@ export namespace Docs {
created = Docs.Create.TextDocument("", { ...{ _width: 200, _height: 25, _autoHeight: true }, ...resolved });
layout = FormattedTextBox.LayoutString;
}
- created.layout = layout?.(fieldKey);
+ created.layout = layout ?.(fieldKey);
created.title = fieldKey;
proto && (created.proto = Doc.GetProto(proto));
return created;
@@ -921,7 +930,7 @@ export namespace DocUtils {
});
ContextMenu.Instance.addItem({
description: "Add Template Doc ...",
- subitems: DocListCast(Cast(Doc.UserDoc().expandingButtons, Doc, null)?.data).map(btnDoc => Cast(btnDoc?.dragFactory, Doc, null)).filter(doc => doc).map((dragDoc, i) => ({
+ subitems: DocListCast(Cast(Doc.UserDoc().expandingButtons, Doc, null) ?.data).map(btnDoc => Cast(btnDoc ?.dragFactory, Doc, null)).filter(doc => doc).map((dragDoc, i) => ({
description: ":" + StrCast(dragDoc.title),
event: (args: { x: number, y: number }) => {
const newDoc = Doc.ApplyTemplate(dragDoc);
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index cc5d7640e..85b7a6dc4 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -12,6 +12,7 @@ import { CompileScript } from "../util/Scripting";
import { ScriptField } from "../../new_fields/ScriptField";
import { DragManager } from "../util/DragManager";
import { EditableView } from "./EditableView";
+import { FieldView } from "./nodes/FieldView";
export interface ScriptBoxProps {
onSave: (text: string, onError: (error: string) => void) => void;
@@ -23,6 +24,8 @@ export interface ScriptBoxProps {
@observer
export class ScriptBox extends React.Component<ScriptBoxProps> {
+ public static LayoutString(fieldStr: string) { return FieldView.LayoutString(ScriptBox, fieldStr); }
+
@observable
private _scriptText: string;
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index bfda13eb3..3d2e8c81b 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -26,6 +26,7 @@ import { PDFBox } from "./PDFBox";
import { PresBox } from "./PresBox";
import { QueryBox } from "./QueryBox";
import { ColorBox } from "./ColorBox";
+import { ScriptBox } from "../ScriptBox"
import { DocuLinkBox } from "./DocuLinkBox";
import { PresElementBox } from "../presentationview/PresElementBox";
import { VideoBox } from "./VideoBox";
@@ -85,7 +86,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
if (this.props.LayoutDoc || (this.props.DataDoc === undefined && typeof Doc.LayoutField(this.props.Document) !== "string")) {
// if there is no dataDoc (ie, we're not rendering a template layout), but this document has a layout document (not a layout string),
// then we render the layout document as a template and use this document as the data context for the template layout.
- return Doc.expandTemplateLayout(this.props.LayoutDoc?.() || Doc.Layout(this.props.Document), this.props.Document);
+ return Doc.expandTemplateLayout(this.props.LayoutDoc ?.() || Doc.Layout(this.props.Document), this.props.Document);
}
return Doc.Layout(this.props.Document);
}
@@ -108,7 +109,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
FormattedTextBox, ImageBox, DirectoryImportBox, FontIconBox, ButtonBox, SliderBox, FieldView,
CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
PDFBox, VideoBox, AudioBox, HistogramBox, PresBox, YoutubeBox, PresElementBox, QueryBox,
- ColorBox, DashWebRTCVideo, DocuLinkBox, InkingStroke, DocumentBox, LinkBox
+ ColorBox, DashWebRTCVideo, DocuLinkBox, InkingStroke, DocumentBox, LinkBox, ScriptBox
}}
bindings={this.CreateBindings()}
jsx={this.layout}