From a555303c34ec2ac79084100bdf21f9d88dba86b1 Mon Sep 17 00:00:00 2001 From: brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> Date: Thu, 26 Jan 2023 22:15:06 -0500 Subject: add option to colon menu --- src/client/documents/Documents.ts | 14 ++++++++++---- src/client/util/CurrentUserUtils.ts | 3 ++- src/client/views/nodes/PhysicsSimulationBox.tsx | 6 ++++-- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 46d7c087c..c7556d668 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -657,7 +657,13 @@ export namespace Docs { options: { _fitWidth: true, _fitHeight: true, nativeDimModifiable: true, links: '@links(self)' }, }, ], - [DocumentType.SIMULATION, { layout: { view: PhysicsSimulationBox, dataField: defaultDataKey }, options: { _height: 150 } }] + [ + DocumentType.SIMULATION, + { + layout: { view: PhysicsSimulationBox, dataField: defaultDataKey }, + options: { _height: 150 } + } + ] ]); const suffix = 'Proto'; @@ -1178,9 +1184,9 @@ export namespace Docs { return InstanceFromProto(proto, undefined, options); } - // export function SimulationDocument(options: DocumentOptions = {}) { - // return InstanceFromProto(Prototypes.get(DocumentType.SIMULATION), undefined, { title: document.title, ...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 a4788d38d..f0397b0c6 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -260,7 +260,7 @@ export class CurrentUserUtils { {key: "Noteboard", creator: opts => Docs.Create.NoteTakingDocument([], opts), opts: { _width: 250, _height: 200 }}, {key: "Collection", creator: opts => Docs.Create.FreeformDocument([], opts), opts: { _width: 150, _height: 100 }}, {key: "Equation", creator: opts => Docs.Create.EquationDocument(opts), opts: { _width: 300, _height: 35, _backgroundGridShow: true, }}, - // {key: "Simulation", creator: opts => Docs.Create.SimulationDocument(opts), opts: { _width: 300, _height: 35, _backgroundGridShow: true, }}, + {key: "Simulation", creator: opts => Docs.Create.SimulationDocument(opts), opts: { _width: 300, _height: 35, _backgroundGridShow: true, }}, {key: "Webpage", creator: opts => Docs.Create.WebDocument("",opts), opts: { _width: 400, _height: 512, _nativeWidth: 850, useCors: true, }}, {key: "Comparison", creator: Docs.Create.ComparisonDocument, opts: { _width: 300, _height: 300 }}, {key: "Audio", creator: opts => Docs.Create.AudioDocument(nullAudio, opts),opts: { _width: 200, _height: 100, }}, @@ -287,6 +287,7 @@ export class CurrentUserUtils { { toolTip: "Tap or drag to create a note board", title: "Notes", icon: "folder", dragFactory: doc.emptyNoteboard as Doc, }, { toolTip: "Tap or drag to create a collection", title: "Col", icon: "folder", dragFactory: doc.emptyCollection as Doc, clickFactory: DocCast(doc.emptyTab), scripts: { onClick: 'openOnRight(copyDragFactory(this.clickFactory))', onDragStart: '{ return copyDragFactory(this.dragFactory);}'}, }, { toolTip: "Tap or drag to create an equation", title: "Math", icon: "calculator", dragFactory: doc.emptyEquation as Doc, }, + { toolTip: "Tap or drag to create a physics simulation", title: "Simulation", icon: "calculator", dragFactory: doc.emptySimulation as Doc, }, { toolTip: "Tap or drag to create a webpage", title: "Web", icon: "globe-asia", dragFactory: doc.emptyWebpage as Doc, }, { toolTip: "Tap or drag to create a comparison box", title: "Compare", icon: "columns", dragFactory: doc.emptyComparison as Doc, }, { toolTip: "Tap or drag to create an audio recorder", title: "Audio", icon: "microphone", dragFactory: doc.emptyAudio as Doc, scripts: { onClick: 'openInOverlay(copyDragFactory(this.dragFactory))', onDragStart: '{ return copyDragFactory(this.dragFactory);}'}, }, diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx index b62caf926..568a5b40c 100644 --- a/src/client/views/nodes/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsSimulationBox.tsx @@ -1,8 +1,10 @@ import "./PhysicsSimulationBox.scss"; import { FieldView, FieldViewProps } from './FieldView'; import React = require('react'); - -export default class PhysicsSimulationBox extends React.Component { +import { ViewBoxAnnotatableComponent } from '../DocComponent'; +import { observer } from 'mobx-react'; +@observer +export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent() { public static LayoutString(fieldKey: string) { return FieldView.LayoutString(PhysicsSimulationBox, fieldKey); } render () { return (

Hello world!

)} -- cgit v1.2.3-70-g09d2