From a6e5fdd00fa4f8adcc67d709e95391d3ccaaaf52 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 3 Mar 2021 10:32:12 -0500 Subject: added functionPlot. trying to make fitWidth make sense everywhere (lightbox, stacking panels with autosize columns, etc). --- src/client/views/nodes/EquationBox.tsx | 39 +++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'src/client/views/nodes/EquationBox.tsx') diff --git a/src/client/views/nodes/EquationBox.tsx b/src/client/views/nodes/EquationBox.tsx index 5bc73d5d9..5bb904f91 100644 --- a/src/client/views/nodes/EquationBox.tsx +++ b/src/client/views/nodes/EquationBox.tsx @@ -1,18 +1,22 @@ import EquationEditor from 'equation-editor-react'; +import { action, reaction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { documentSchema } from '../../../fields/documentSchemas'; -import { createSchema, makeInterface } from '../../../fields/Schema'; -import { StrCast, NumCast } from '../../../fields/Types'; -import { ViewBoxBaseComponent } from '../DocComponent'; -import { FieldView, FieldViewProps } from './FieldView'; -import './LabelBox.scss'; import { Id } from '../../../fields/FieldSymbols'; -import { simulateMouseClick } from '../../../Utils'; +import { createSchema, makeInterface } from '../../../fields/Schema'; +import { NumCast, StrCast } from '../../../fields/Types'; import { TraceMobx } from '../../../fields/util'; -import { reaction, action } from 'mobx'; import { Docs } from '../../documents/Documents'; +import { ViewBoxBaseComponent } from '../DocComponent'; import { LightboxView } from '../LightboxView'; +import { FieldView, FieldViewProps } from './FieldView'; +import './LabelBox.scss'; +import functionPlot from "function-plot"; +import { DocumentManager } from '../../util/DocumentManager'; +import { Utils } from '../../../Utils'; +import { HeightSym, WidthSym } from '../../../fields/Doc'; + const EquationSchema = createSchema({}); @@ -39,18 +43,29 @@ export class EquationBox extends ViewBoxBaseComponent { const _height = Number(getComputedStyle(this._ref.current!.element.current).height.replace("px", "")); const _width = Number(getComputedStyle(this._ref.current!.element.current).width.replace("px", "")); - if (e.key === "Enter" || e.key === "Tab") { + if (e.key === "Enter") { const nextEq = Docs.Create.EquationDocument({ title: "# math", text: StrCast(this.dataDoc.text), _width, _height: 25, - x: NumCast(this.layoutDoc.x) + (e.key === "Tab" ? _width + 10 : 0), y: NumCast(this.layoutDoc.y) + (e.key === "Enter" ? _height + 10 : 0) + x: NumCast(this.layoutDoc.x), y: NumCast(this.layoutDoc.y) + _height + 10 }); EquationBox.SelectOnLoad = nextEq[Id]; this.props.addDocument?.(nextEq); e.stopPropagation(); + + } + if (e.key === "Tab") { + const graph = Docs.Create.FunctionPlotDocument([this.rootDoc], { + x: NumCast(this.layoutDoc.x) + this.layoutDoc[WidthSym](), + y: NumCast(this.layoutDoc.y), + _width: 400, _height: 300, _backgroundColor: "white" + }); + this.props.addDocument?.(graph); + e.stopPropagation(); } if (e.key === "Backspace" && !this.dataDoc.text) this.props.removeDocument?.(this.rootDoc); } @@ -72,11 +87,11 @@ export class EquationBox extends ViewBoxBaseComponent - ); + autoOperatorNames="sin cos tan" /> + ); } } \ No newline at end of file -- cgit v1.2.3-70-g09d2