From 1a48ccf57ae43bc582dcd7be453e0ad217d38828 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 7 Mar 2025 23:13:33 -0500
Subject: fixed following text hyperlinks to Docs. fixed using fieldinfos for
 DashFieldViews to get appropriate Schmema cell input.  fixed dashFieldView to
 show correct input editor for field type.

---
 src/client/views/collections/collectionSchema/SchemaCellField.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/client/views/collections/collectionSchema/SchemaCellField.tsx')

diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
index 5a64ecc62..20ec2f151 100644
--- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
@@ -21,7 +21,7 @@ import DOMPurify from 'dompurify';
  */
 
 export interface SchemaCellFieldProps {
-    contents: FieldType;
+    contents: FieldType | undefined;
     fieldContents?: FieldViewProps;
     editing?: boolean;
     oneLine?: boolean;
-- 
cgit v1.2.3-70-g09d2


From df173b02ffb7e2937d20a02beec1815b3af7c34e Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 9 Mar 2025 17:40:08 -0400
Subject: removed simulation doc.  fixed empty imageBox uploading.  fixed
 script typechecking.  fixed metadata doc.  fixed setting background colors of
 docs that have a template.

---
 src/client/documents/DocUtils.ts                       |  7 +++++--
 src/client/documents/DocumentTypes.ts                  |  1 -
 src/client/documents/Documents.ts                      |  4 ----
 src/client/util/CurrentUserUtils.ts                    | 16 ++++++++--------
 src/client/util/Scripting.ts                           |  7 +++----
 src/client/views/Main.tsx                              |  2 --
 src/client/views/StyleProvider.tsx                     |  2 +-
 .../collections/collectionSchema/SchemaCellField.tsx   |  2 --
 src/client/views/nodes/DiagramBox.tsx                  |  5 ++++-
 src/client/views/nodes/DocumentContentsView.tsx        | 11 ++++-------
 src/client/views/nodes/DocumentView.tsx                |  2 +-
 src/client/views/nodes/ImageBox.tsx                    | 18 +++++++-----------
 src/fields/Doc.ts                                      |  1 -
 13 files changed, 33 insertions(+), 45 deletions(-)

(limited to 'src/client/views/collections/collectionSchema/SchemaCellField.tsx')

diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts
index b216551d5..1c7ccadd1 100644
--- a/src/client/documents/DocUtils.ts
+++ b/src/client/documents/DocUtils.ts
@@ -691,6 +691,7 @@ export namespace DocUtils {
             }
             generatedDocuments.push(doc);
         }
+        return doc;
     }
 
     export function GetNewTextDoc(title: string, x: number, y: number, width?: number, height?: number, annotationOn?: Doc, backgroundColor?: string) {
@@ -841,7 +842,7 @@ export namespace DocUtils {
     export function uploadFileToDoc(file: File, options: DocumentOptions, overwriteDoc: Doc) {
         const generatedDocuments: Doc[] = [];
         // Since this file has an overwriteDoc, we can set the client tracking guid to the overwriteDoc's guid.
-        Networking.UploadFilesToServer([{ file, guid: overwriteDoc[Id] }]).then(upfiles => {
+        return Networking.UploadFilesToServer([{ file, guid: overwriteDoc[Id] }]).then(upfiles => {
             const {
                 source: { newFilename, mimetype },
                 result,
@@ -851,7 +852,9 @@ export namespace DocUtils {
                     overwriteDoc.loadingError = result.message;
                     Doc.removeCurrentlyLoading(overwriteDoc);
                 }
-            } else newFilename && mimetype && processFileupload(generatedDocuments, newFilename, mimetype, result, options, overwriteDoc);
+                return undefined;
+            }
+            return newFilename && mimetype ? processFileupload(generatedDocuments, newFilename, mimetype, result, options, overwriteDoc) : undefined;
         });
     }
 
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index 00f5dedd6..03626107f 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -31,7 +31,6 @@ export enum DocumentType {
     DATAVIZ = 'dataviz',
     ANNOPALETTE = 'annopalette',
     LOADING = 'loading',
-    SIMULATION = 'simulation', // physics simulation
     MESSAGE = 'message', // chat message
 
     // special purpose wrappers that either take no data or are compositions of lower level types
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 4b5979965..317bb7feb 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1150,9 +1150,5 @@ export namespace Docs {
         export function DelegateDocument(proto: Doc, options: DocumentOptions = {}) {
             return InstanceFromProto(proto, undefined, options);
         }
-
-        export function SimulationDocument(options?: DocumentOptions) {
-            return InstanceFromProto(Prototypes.get(DocumentType.SIMULATION), undefined, { ...(options || {}) });
-        }
     }
 }
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 778b522c4..21e1d3e12 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -109,7 +109,7 @@ export class CurrentUserUtils {
         const reqdClickList = reqdTempOpts.map(opts => {
             const allOpts = {...reqdClickOpts, ...opts.opts};
             const clickDoc = tempClicks ? DocListCast(tempClicks.data).find(fdoc => fdoc.title === opts.opts.title): undefined;
-            return DocUtils.AssignOpts(clickDoc, allOpts) ?? Docs.Create.ScriptingDocument(ScriptField.MakeScript(opts.script, allOpts),allOpts);
+            return DocUtils.AssignOpts(clickDoc, allOpts) ?? Docs.Create.ScriptingDocument(ScriptField.MakeScript(opts.script),allOpts);
         });
 
         const reqdOpts:DocumentOptions = { title: "child click editors", _height:75, isSystem: true};
@@ -270,21 +270,23 @@ export class CurrentUserUtils {
 
             // "<div style={'height:100%'}>" +
             // "    <FormattedTextBox {...props} fieldKey={'header'} dontSelectOnLoad={'true'} ignoreAutoHeight={'true'} pointerEvents='{this._header_pointerEvents||`none`}' fontSize='{this._header_fontSize}px' height='{this._header_height}px' background='{this._header_color}' />" +
-            // "    <FormattedTextBox {...props} fieldKey={'text'} position='absolute' top='{(this._header_height)*scale}px' height='calc({100/scale}% - {this._header_height}px)'/>" +
+            // "    <FormattedTextBox {...props} fieldKey={'text'} position='absolute' top='{this._header_height}px' height='calc(100% - {this._header_height}px)'/>" +
             // "</div>";
         const headerBtnHgt = 10;
         const headerTemplate = (opts:DocumentOptions) => 
             MakeTemplate(Docs.Create.RTFDocument(new RichTextField(JSON.stringify(json), ""), { ...opts, title: "Header Template", 
-                layout:`<HTMLdiv transformOrigin='top left' width='{100/scale}%' height='{100/scale}%' transform='scale({scale})'>
+                layout:`<HTMLdiv transformOrigin='top left' width='100%' height='100%'>
                             <FormattedTextBox {...props} dontScale='true' fieldKey={'text'} height='calc(100% - ${headerBtnHgt}px - {this._header_height||0}px)'  />
                             <FormattedTextBox {...props} dontScale='true' fieldKey={'header'} dontSelectOnLoad='true' ignoreAutoHeight='true' fontSize='{this._header_fontSize||9}px' height='{(this._header_height||0)}px' backgroundColor='{this._header_color || "lightGray"}' />
-                            <HTMLdiv fontSize='${headerBtnHgt - 1}px' height='${headerBtnHgt}px' backgroundColor='yellow' onClick={‘(this._header_height=Math.min(Math.max(0,this._height-30),this._header_height===0?50:0)) + (this._layout_autoHeightMargins=this._header_height ? this._header_height+${headerBtnHgt}:0)’} > Metadata</HTMLdiv>
+                            <HTMLdiv fontSize='${headerBtnHgt - 1}px' height='${headerBtnHgt}px' backgroundColor='yellow'
+                                   onClick={‘(this._header_height=(this._header_height===0?50:0)) + (this._layout_autoHeightMargins=this._header_height ? this._header_height+${headerBtnHgt}:0)’} > Metadata
+                                   </HTMLdiv>
                         </HTMLdiv>`
                     }, "header"));
         const slideView = (opts:DocumentOptions) => 
             MakeTemplate(Docs.Create.MultirowDocument(
                     [
-                        Docs.Create.MulticolumnDocument([], { title: "hero", _height: 200,  isSystem: true }),
+                        Docs.Create.MulticolumnDocument([], { title: "hero", _xMargin: 10, _height: 200,  isSystem: true }),
                         Docs.Create.TextDocument("", { title: "text", _layout_fitWidth:true,  _height: 100, isSystem: true, text_fontFamily: StrCast(Doc.UserDoc().fontFamily), text_fontSize: StrCast(Doc.UserDoc().fontSize) })
                     ], {...opts, title: "Slide View Template"}));
         const plotlyApi = () => {
@@ -390,7 +392,6 @@ pie title Minerals in my tap water
             {key: "Image",      creator: opts => Docs.Create.ImageDocument("", opts),       opts: { _width: 400, _height:400 }},
             {key: "Equation",   creator: opts => Docs.Create.EquationDocument("",opts),     opts: { _width: 50,  _height: 50, nativeWidth: 40, nativeHeight: 40, _xMargin: 10, _yMargin: 10}},
             {key: "Noteboard",  creator: opts => Docs.Create.NoteTakingDocument([], opts),  opts: { _width: 250, _height: 200, _layout_fitWidth: true}},
-            {key: "Simulation", creator: opts => Docs.Create.SimulationDocument(opts),      opts: { _width: 300, _height: 300, }},
             {key: "Collection", creator: opts => Docs.Create.FreeformDocument([], opts),    opts: { _width: 150, _height: 100, _layout_fitWidth: true }},
             {key: "Webpage",    creator: opts => Docs.Create.WebDocument("",opts),          opts: { _width: 400, _height: 512, _nativeWidth: 850, data_useCors: true, }},
             {key: "Comparison", creator: opts => Docs.Create.ComparisonDocument("", opts),  opts: { _width: 300, _height: 300 }},
@@ -428,7 +429,6 @@ pie title Minerals in my tap water
             { toolTip: "Tap or drag to create an equation",       title: "Math", icon: "calculator",    dragFactory: doc.emptyEquation as Doc,   clickFactory: DocCast(doc.emptyEquation)},
             { toolTip: "Tap or drag to create a mermaid node",    title: "Mermaids", icon: "rocket",    dragFactory: doc.emptyMermaids as Doc,   clickFactory: DocCast(doc.emptyMermaids)}, 
             { toolTip: "Tap or drag to create a plotly node",     title: "Plotly", icon: "rocket",      dragFactory: doc.emptyPlotly as Doc,     clickFactory: DocCast(doc.emptyMermaids)}, 
-            { toolTip: "Tap or drag to create a physics simulation",title: "Simulation", icon: "rocket",dragFactory: doc.emptySimulation as Doc, clickFactory: DocCast(doc.emptySimulation), funcs: { hidden: "IsNoviceMode()"}}, 
             { toolTip: "Tap or drag to create a note board",      title: "Notes", icon: "book",         dragFactory: doc.emptyNoteboard as Doc,  clickFactory: DocCast(doc.emptyNoteboard)},
             { toolTip: "Tap or drag to create an image",          title: "Image", icon: "image",        dragFactory: doc.emptyImage as Doc,      clickFactory: DocCast(doc.emptyImage)},
             { toolTip: "Tap or drag to create a collection",      title: "Col", icon: "folder",         dragFactory: doc.emptyCollection as Doc, clickFactory: DocCast(doc.emptyTab)},
@@ -443,7 +443,7 @@ pie title Minerals in my tap water
             { toolTip: "Tap or drag to create a button",          title: "Button", icon: "circle",      dragFactory: doc.emptyButton as Doc,     clickFactory: DocCast(doc.emptyButton)},
             { toolTip: "Tap or drag to create a scripting box",   title: "Script", icon: "terminal",    dragFactory: doc.emptyScript as Doc,     clickFactory: DocCast(doc.emptyScript),                                             funcs: { hidden: "IsNoviceMode()"}},
             { toolTip: "Tap or drag to create a data viz node",   title: "DataViz", icon: "chart-bar",  dragFactory: doc.emptyDataViz as Doc,    clickFactory: DocCast(doc.emptyDataViz)},
-            { toolTip: "Tap or drag to create a journal entry",   title: "Journal", icon: "note",       dragFactory: doc.emptyDailyJournal as Doc,clickFactory:DocCast(doc.emptyDataJournal), },
+            { toolTip: "Tap or drag to create a journal entry",   title: "Journal", icon: "book",       dragFactory: doc.emptyDailyJournal as Doc,clickFactory:DocCast(doc.emptyDataJournal), },
             { toolTip: "Tap or drag to create a bullet slide",    title: "PPT Slide", icon: "person-chalkboard",   dragFactory: doc.emptySlide as Doc,       clickFactory: DocCast(doc.emptySlide),     openFactoryLocation: OpenWhere.overlay,funcs: { hidden: "IsNoviceMode()"}},
             { toolTip: "Tap or drag to create a view slide",      title: "View Slide", icon: "address-card",       dragFactory: doc.emptyViewSlide as Doc,   clickFactory: DocCast(doc.emptyViewSlide), openFactoryLocation: OpenWhere.overlay,funcs: { hidden: "IsNoviceMode()"}},
             { toolTip: "Tap or drag to create a data note",       title: "DataNote", icon: "window-maximize",      dragFactory: doc.emptyHeader as Doc,      clickFactory: DocCast(doc.emptyHeader),    openFactoryAsDelegate: true,           funcs: { hidden: "IsNoviceMode()"} },
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index c6d98496a..b0886a67c 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -54,6 +54,7 @@ function Run(script: string | undefined, customParams: string[], diagnostics: ts
         (diag.code !== 2552 ||!Object.keys(scriptingGlobals).includes(diagnostics[0].messageText.toString().match(/Cannot find name '([A-Za-z0-9$-_]+)'/)?.[1]??"-------"))
     ); // prettier-ignore
     if ((options.typecheck !== false && errors.length) || !script) {
+        console.log('Script Compile Failed: ' + script + ' ', errors);
         return { compiled: false, errors };
     }
 
@@ -228,10 +229,8 @@ export function CompileScript(script: string, options: ScriptOptions = {}): Comp
     }
     paramNames.push(...Object.keys(params).filter(p => p !== 'this' && !Object.keys(capturedVariables).includes(p)));
 
-    const paramList = paramNames.map(key => {
-        const val = typeof params[key] === 'string' && params[key].length && !'"\'`'.includes(params[key][0]) ? `"${params[key]}"` : params[key];
-        return `${key}: ${val}`;
-    });
+    const paramList = paramNames.map(key => `${key}: ${params[key] === Doc.name ? 'any' : params[key]}`);
+
     for (const key in capturedVariables) {
         if (key !== 'this') {
             const val = capturedVariables[key];
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index e5347e692..22725a2b9 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -45,7 +45,6 @@ import { LoadingBox } from './nodes/LoadingBox';
 import { MapBox } from './nodes/MapBox/MapBox';
 import { MapPushpinBox } from './nodes/MapBox/MapPushpinBox';
 import { PDFBox } from './nodes/PDFBox';
-import { PhysicsSimulationBox } from './nodes/PhysicsBox/PhysicsSimulationBox';
 import { RecordingBox } from './nodes/RecordingBox';
 import { ScreenshotBox } from './nodes/ScreenshotBox';
 import { ScriptingBox } from './nodes/ScriptingBox';
@@ -154,7 +153,6 @@ FieldLoader.ServerLoadStatus = { requested: 0, retrieved: 0, message: 'cache' };
             CalendarBox,
             ComparisonBox,
             LoadingBox,
-            PhysicsSimulationBox,
             SchemaRowBox,
             ImportElementBox,
             MapPushpinBox,
diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx
index b04b1ae65..331ee1707 100644
--- a/src/client/views/StyleProvider.tsx
+++ b/src/client/views/StyleProvider.tsx
@@ -254,7 +254,7 @@ export function DefaultStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps &
             const usePath = StrCast(doc?.[dataKey + "_usePath"]);
             const alternate = usePath.includes(":hover") ? ( isHovering?.() ? '_' + usePath.replace(":hover","") : "") : usePath ? "_" +usePath:usePath;
             let docColor: Opt<string> = StrCast(doc?.[fieldKey+alternate], StrCast(doc?.['backgroundColor' +alternate], isCaption ? 'rgba(0,0,0,0.4)' : ''));
-            if (doc?.[StrCast(doc?.layout_fieldKey)] instanceof Doc) docColor = StrCast(doc._backgroundColor,docColor)
+            if (!docColor && doc?.[StrCast(doc?.layout_fieldKey)] instanceof Doc) docColor = StrCast(doc._backgroundColor,docColor)
             // prettier-ignore
             switch (layoutDoc?.type) {
                 case DocumentType.PRESELEMENT: docColor = docColor || ""; break;
diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
index 20ec2f151..e6acff061 100644
--- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
@@ -107,7 +107,6 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
         this._disposers.fieldUpdate = reaction(
             () => this._props.GetValue(),
             fieldVal => {
-                console.log('Update: ' + this._props.Document.title, this._props.fieldKey, fieldVal);
                 this._unrenderedContent = fieldVal ?? '';
                 this.finalizeEdit(false, false, false);
             }
@@ -127,7 +126,6 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
     _unmounted = false;
     componentWillUnmount(): void {
         this._unmounted = true;
-        console.log('Unmount: ' + this._props.Document.title, this._props.fieldKey);
         this._overlayDisposer?.();
         Object.values(this._disposers).forEach(disposer => disposer?.());
         this.finalizeEdit(false, true, false);
diff --git a/src/client/views/nodes/DiagramBox.tsx b/src/client/views/nodes/DiagramBox.tsx
index e77cde431..a49c69be3 100644
--- a/src/client/views/nodes/DiagramBox.tsx
+++ b/src/client/views/nodes/DiagramBox.tsx
@@ -18,6 +18,7 @@ import { InkingStroke } from '../InkingStroke';
 import './DiagramBox.scss';
 import { FieldView, FieldViewProps } from './FieldView';
 import { FormattedTextBox } from './formattedText/FormattedTextBox';
+import { Tooltip } from '@mui/material';
 /**
  * this is a class for the diagram box doc type that can be found in the tools section of the side bar
  */
@@ -208,7 +209,9 @@ export class DiagramBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
                     <button type="button" onClick={this.generateMermaidCode}>
                         Gen
                     </button>
-                    <input type="checkbox" onClick={action(() => (this._showCode = !this._showCode))} />
+                    <Tooltip title="show diagram code">
+                        <input type="checkbox" onClick={action(() => (this._showCode = !this._showCode))} />
+                    </Tooltip>
                 </div>
                 <div className="DIYNodeBox-content">
                     {this._showCode ? (
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index aab8a183a..47c5734f7 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -23,7 +23,6 @@ interface HTMLtagProps {
     htmltag: string;
     onClick?: ScriptField;
     onInput?: ScriptField;
-    scaling: number;
     children?: JSX.Element[];
 }
 
@@ -43,7 +42,7 @@ interface HTMLtagProps {
 export class HTMLtag extends React.Component<HTMLtagProps> {
     click = () => {
         const clickScript = this.props.onClick as Opt<ScriptField>;
-        clickScript?.script.run({ this: this.props.Document, scale: this.props.scaling });
+        clickScript?.script.run({ this: this.props.Document });
     };
     onInput = (e: React.FormEvent<unknown>) => {
         const onInputScript = this.props.onInput as Opt<ScriptField>;
@@ -56,7 +55,6 @@ export class HTMLtag extends React.Component<HTMLtagProps> {
             'dragStarting',
             'dragEnding',
             'htmltag',
-            'scaling',
             'Document',
             'key',
             'onInput',
@@ -65,7 +63,7 @@ export class HTMLtag extends React.Component<HTMLtagProps> {
         ]).omit;
         const replacer = (match: string, expr: string) =>
             // bcz: this executes a script to convert a property expression string:  { script }  into a value
-            (ScriptField.MakeFunction(expr, { this: Doc.name, scale: 'number' })?.script.run({ this: this.props.Document, scale: this.props.scaling }).result as string) || '';
+            (ScriptField.MakeFunction(expr, { this: Doc.name })?.script.run({ this: this.props.Document }).result as string) || '';
         Object.keys(divKeys).forEach((prop: string) => {
             const p = (this.props as unknown as { [key: string]: string })[prop] as string;
             style[prop] = p?.replace(/{([^.'][^}']+)}/g, replacer);
@@ -166,12 +164,11 @@ export class DocumentContentsView extends ObservableReactComponent<DocumentConte
         layoutFrame = layoutFrame.replace(/(>[^{]*)[^=]\{([^.'][^<}]+)\}([^}]*<)/g, replacer);
 
         // replace HTML<tag> with corresponding HTML tag as in:  <HTMLdiv> becomes  <HTMLtag Document={props.Document} htmltag='div'>
-        const replacer2 = (match: string, p1: string) => `<HTMLtag Document={props.Document} scaling='${this._props.NativeDimScaling?.() || 1}' htmltag='${p1}'`;
+        const replacer2 = (match: string, p1: string) => `<HTMLtag Document={props.Document} htmltag='${p1}'`;
         layoutFrame = layoutFrame.replace(/<HTML([a-zA-Z0-9_-]+)/g, replacer2);
 
         // replace /HTML<tag> with </HTMLdiv>  as in:  </HTMLdiv> becomes  </HTMLtag>
         const replacer3 = (/* match: any, p1: string, offset: any, string: any */) => `</HTMLtag`;
-
         layoutFrame = layoutFrame.replace(/<\/HTML([a-zA-Z0-9_-]+)/g, replacer3);
 
         // add onClick function to props
@@ -181,7 +178,7 @@ export class DocumentContentsView extends ObservableReactComponent<DocumentConte
                 const code = XRegExp.matchRecursive(splits[1], '{', '}', '', { valueNames: ['between', 'left', 'match', 'right', 'between'] });
                 layoutFrame = splits[0] + ` ${func}={props.${func}} ` + splits[1].substring(code[1].end + 1);
                 const script = code[1].value.replace(/^‘/, '').replace(/’$/, ''); // ‘’ are not valid quotes in javascript so get rid of them -- they may be present to make it easier to write complex scripts - see headerTemplate in currentUserUtils.ts
-                return ScriptField.MakeScript(script, { this: Doc.name, scale: 'number', value: 'string' });
+                return ScriptField.MakeScript(script, { this: Doc.name, value: 'string' });
             }
             return undefined;
             // add input function to props
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index a514ee04e..cac276535 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -134,7 +134,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
     @computed get border()            { return this.style(this.layoutDoc, StyleProp.Border) as string || ""; } // prettier-ignore
     @computed get borderRounding()    { return this.style(this.layoutDoc, StyleProp.BorderRounding) as string; } // prettier-ignore
     @computed get widgetDecorations() { return this.style(this.layoutDoc, StyleProp.Decorations) as JSX.Element; } // prettier-ignore
-    @computed get backgroundBoxColor(){ return this.style(this.layoutDoc, StyleProp.BackgroundColor + ':docView') as string; } // prettier-ignore
+    @computed get backgroundBoxColor(){ return this.style(this.Document, StyleProp.BackgroundColor + ':docView') as string; } // prettier-ignore
     @computed get showTitle()         { return this.style(this.layoutDoc, StyleProp.ShowTitle) as Opt<string>; } // prettier-ignore
     @computed get showCaption()       { return this.style(this.layoutDoc, StyleProp.ShowCaption) as string ?? "";  } // prettier-ignore
     @computed get headerMargin()      { return this.style(this.layoutDoc, StyleProp.HeaderMargin)  as number ?? 0; } // prettier-ignore
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index 017ef7191..5b06e9fc5 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -148,9 +148,9 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
         );
         const { layoutDoc } = this;
         this._disposers.path = reaction(
-            () => ({ nativeSize: this.nativeSize, width: NumCast(this.layoutDoc._width) }),
-            ({ nativeSize, width }) => {
-                if ((layoutDoc === this.layoutDoc && !this.layoutDoc._layout_nativeDimEditable) || !this.layoutDoc._height) {
+            () => ({ nativeSize: this.nativeSize, width: NumCast(this.layoutDoc._width), height: this.layoutDoc._height }),
+            ({ nativeSize, width, height }) => {
+                if ((layoutDoc === this.layoutDoc && !this.layoutDoc._layout_nativeDimEditable) || !height) {
                     this.layoutDoc._height = (width * nativeSize.nativeHeight) / nativeSize.nativeWidth;
                 }
             },
@@ -834,14 +834,10 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
             const file = input.files?.[0];
             if (file) {
                 const disposer = OverlayView.ShowSpinner();
-                const [{ result }] = await Networking.UploadFilesToServer({ file });
-                if (result instanceof Error) {
-                    alert('Error uploading files - possibly due to unsupported file types');
-                } else {
-                    this.dataDoc[this.fieldKey] = new ImageField(result.accessPaths.agnostic.client);
-                    !(result instanceof Error) && DocUtils.assignImageInfo(result, this.dataDoc);
-                }
-                disposer();
+                DocUtils.uploadFileToDoc(file, {}, this.Document).then(doc => {
+                    disposer();
+                    doc && (doc.height = undefined);
+                });
             } else {
                 console.log('No file selected');
             }
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index dc4a5a011..fc89dcbe7 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1517,7 +1517,6 @@ export namespace Doc {
             case DocumentType.MAP: return 'map-marker-alt';
             case DocumentType.DATAVIZ: return 'chart-bar';
             case DocumentType.EQUATION: return 'calculator';
-            case DocumentType.SIMULATION: return 'rocket';
             case DocumentType.CONFIG: return 'folder-closed';
             default:
         }
-- 
cgit v1.2.3-70-g09d2

