aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json5
-rw-r--r--package.json2
-rw-r--r--src/client/util/CurrentUserUtils.ts19
-rw-r--r--src/client/views/LightboxView.tsx2
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx4
-rw-r--r--src/client/views/collections/CollectionSubView.tsx2
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx2
-rw-r--r--src/client/views/collections/TreeView.tsx4
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
-rw-r--r--src/client/views/nodes/EquationBox.tsx7
-rw-r--r--src/client/views/nodes/FunctionPlotBox.tsx46
-rw-r--r--src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts2
-rw-r--r--src/fields/util.ts2
13 files changed, 61 insertions, 38 deletions
diff --git a/package-lock.json b/package-lock.json
index 3cbdb7a74..0eff1ff92 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5674,9 +5674,8 @@
"integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w=="
},
"equation-editor-react": {
- "version": "0.0.6",
- "resolved": "https://registry.npmjs.org/equation-editor-react/-/equation-editor-react-0.0.6.tgz",
- "integrity": "sha512-7Zsx04yh4DsirpMzMVnEaDwMxrpcjiAt6NOvSj+DEOa56VfKGXsmouWFOCtSVixahDSVEDs53LbhnPqFh4cVqw==",
+ "version": "github:bobzel/equation-editor-react#75915e852b4b36a6a4cd3e1cbc80598da6b65227",
+ "from": "github:bobzel/equation-editor-react#useLocally",
"requires": {
"jquery": "^3.4.1",
"mathquill": "^0.10.1-a"
diff --git a/package.json b/package.json
index aae4fdfff..7a9ec6f99 100644
--- a/package.json
+++ b/package.json
@@ -153,7 +153,7 @@
"cookie-session": "^2.0.0-rc.1",
"cors": "^2.8.5",
"depcheck": "^0.9.2",
- "equation-editor-react": "0.0.6",
+ "equation-editor-react": "github:bobzel/equation-editor-react#useLocally",
"exif": "^0.6.0",
"express": "^4.16.4",
"express-flash": "0.0.2",
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 0f7c2571b..825d7b1d7 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -226,7 +226,7 @@ export class CurrentUserUtils {
title: "Advanced Item Prototypes", _xMargin: 0, _showTitle: "title",
hidden: ComputedField.MakeFunction("IsNoviceMode()") as any,
_stayInCollection: true, _hideContextMenu: true,
- _autoHeight: true, _width: 500, _columnWidth: 35, ignoreClick: true, _lockedPosition: true, _chromeStatus: "disabled",
+ _autoHeight: true, _width: 500, _height: 300, _fitWidth: true, _columnWidth: 35, ignoreClick: true, _lockedPosition: true, _chromeStatus: "disabled",
dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), system: true
}));
} else {
@@ -365,12 +365,12 @@ export class CurrentUserUtils {
}[] {
if (doc.emptyPresentation === undefined) {
doc.emptyPresentation = Docs.Create.PresDocument(new List<Doc>(),
- { title: "Untitled Presentation", _viewType: CollectionViewType.Stacking, _width: 400, _height: 500, targetDropAction: "alias", _chromeStatus: "replaced", boxShadow: "0 0", system: true, cloneFieldFilter: new List<string>(["system"]) });
+ { title: "Untitled Presentation", _viewType: CollectionViewType.Stacking, _fitWidth: true, _width: 400, _height: 500, targetDropAction: "alias", _chromeStatus: "replaced", boxShadow: "0 0", system: true, cloneFieldFilter: new List<string>(["system"]) });
((doc.emptyPresentation as Doc).proto as Doc)["dragFactory-count"] = 0;
}
if (doc.emptyCollection === undefined) {
doc.emptyCollection = Docs.Create.FreeformDocument([],
- { _nativeWidth: undefined, _nativeHeight: undefined, _width: 150, _height: 100, title: "freeform", system: true, cloneFieldFilter: new List<string>(["system"]) });
+ { _nativeWidth: undefined, _nativeHeight: undefined, _fitWidth: true, _width: 150, _height: 100, title: "freeform", system: true, cloneFieldFilter: new List<string>(["system"]) });
((doc.emptyCollection as Doc).proto as Doc)["dragFactory-count"] = 0;
}
if (doc.emptyPane === undefined) {
@@ -496,14 +496,14 @@ export class CurrentUserUtils {
_stayInCollection: true,
dragFactory,
clickFactory,
- hidden: ComputedField.MakeFunction("IsNoviceMode()") as any,
- system: true
+ hidden: noviceMode ? ComputedField.MakeFunction("IsNoviceMode()") as any : undefined,
+ system: true,
}));
if (dragCreatorSet === undefined) {
doc.myItemCreators = new PrefetchProxy(Docs.Create.MasonryDocument(creatorBtns, {
title: "Basic Item Creators", _showTitle: "title", _xMargin: 0, _stayInCollection: true, _hideContextMenu: true,
- _autoHeight: true, _width: 500, _columnWidth: 35, ignoreClick: true, _lockedPosition: true, _chromeStatus: "disabled",
+ _autoHeight: true, _width: 500, _height: 300, _fitWidth: true, _columnWidth: 35, ignoreClick: true, _lockedPosition: true, _chromeStatus: "disabled",
dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), system: true
}));
} else {
@@ -718,8 +718,8 @@ export class CurrentUserUtils {
if (doc.myCreators === undefined) {
doc.myCreators = new PrefetchProxy(Docs.Create.StackingDocument([creatorBtns, templateBtns], {
- title: "all Creators", _yMargin: 0, _autoHeight: true, _xMargin: 0,
- _width: 500, ignoreClick: true, _lockedPosition: true, _chromeStatus: "disabled", system: true
+ title: "all Creators", _yMargin: 0, _autoHeight: true, _xMargin: 0, _fitWidth: true,
+ _width: 500, _height: 300, ignoreClick: true, _lockedPosition: true, _chromeStatus: "disabled", system: true
}));
}
// setup a color picker
@@ -888,7 +888,7 @@ export class CurrentUserUtils {
static setupDefaultPresentation(doc: Doc) {
if (doc["template-presentation"] === undefined) {
doc["template-presentation"] = new PrefetchProxy(Docs.Create.PresElementBoxDocument({
- title: "pres element template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data", system: true
+ title: "pres element template", backgroundColor: "transparent", _xMargin: 5, _fitWidth: true, _height: 46, isTemplateDoc: true, isTemplateForField: "data", system: true
}));
}
}
@@ -1180,6 +1180,7 @@ export class CurrentUserUtils {
y: 400,
_width: 1500,
_height: 1000,
+ _fitWidth: true,
title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`,
};
const freeformDoc = CurrentUserUtils.GuestTarget || Docs.Create.FreeformDocument([], freeformOptions);
diff --git a/src/client/views/LightboxView.tsx b/src/client/views/LightboxView.tsx
index 3fc72c45c..9b14c180e 100644
--- a/src/client/views/LightboxView.tsx
+++ b/src/client/views/LightboxView.tsx
@@ -260,7 +260,7 @@ export class LightboxView extends React.Component<LightboxViewProps> {
})}
<LightboxTourBtn navBtn={this.navBtn} future={this.future} stepInto={this.stepInto} tourMap={this.tourMap} />
<div className="lightboxView-navBtn" title={"toggle fit width"} style={{ position: "absolute", right: 10, top: 10, color: "white" }}
- onClick={e => { e.stopPropagation(); LightboxView.LightboxDoc!._fitWidth = !LightboxView.LightboxDoc!._fitWidth }}>
+ onClick={e => { e.stopPropagation(); LightboxView.LightboxDoc!._fitWidth = !LightboxView.LightboxDoc!._fitWidth; }}>
<FontAwesomeIcon icon={"arrows-alt-h"} size="2x" />
</div>
</div>;
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 550a4082b..0c8e26e91 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -400,7 +400,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
const emptyPane = CurrentUserUtils.EmptyPane;
emptyPane["dragFactory-count"] = NumCast(emptyPane["dragFactory-count"]) + 1;
CollectionDockingView.AddSplit(Docs.Create.FreeformDocument([], {
- _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`
+ _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), _fitWidth: true, title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`
}), "", stack);
}
});
@@ -423,7 +423,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
const emptyPane = CurrentUserUtils.EmptyPane;
emptyPane["dragFactory-count"] = NumCast(emptyPane["dragFactory-count"]) + 1;
CollectionDockingView.AddSplit(Docs.Create.FreeformDocument([], {
- _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`
+ _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), _fitWidth: true, title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`
}), "", stack);
}));
}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 639650b94..e5c835f39 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -230,7 +230,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
const dropped = dropCreator(this.props.isAnnotationOverlay ? this.rootDoc : undefined);
this.addDocument(dropped);
return dropped;
- }
+ };
return true;
}
return false;
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 9e312b03f..b14949d47 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -173,6 +173,8 @@ export class
layerProvider={this.props.layerProvider}
PanelWidth={this.rtfWidth}
PanelHeight={this.rtfOutlineHeight}
+ NativeWidth={this.rtfWidth}
+ NativeHeight={this.rtfOutlineHeight}
focus={this.props.focus}
ScreenToLocalTransform={this.titleTransform}
docFilters={returnEmptyFilter}
diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx
index e383cf176..e80cc970b 100644
--- a/src/client/views/collections/TreeView.tsx
+++ b/src/client/views/collections/TreeView.tsx
@@ -597,8 +597,8 @@ export class TreeView extends React.Component<TreeViewProps> {
moveDocument={this.move}
removeDocument={this.props.removeDoc}
ScreenToLocalTransform={this.getTransform}
- NativeHeight={returnZero}
- NativeWidth={returnZero}
+ NativeHeight={() => 18}
+ NativeWidth={this.truncateTitleWidth}
PanelWidth={this.truncateTitleWidth}
PanelHeight={() => 18}
contextMenuItems={this.contextMenuItems}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index af8ccb9c5..74f00d1b3 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -284,7 +284,7 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
this.bringToFront(dropDoc);
}
return dropDoc || this.rootDoc;
- }
+ };
return true;
}
diff --git a/src/client/views/nodes/EquationBox.tsx b/src/client/views/nodes/EquationBox.tsx
index 5bb904f91..f49405d02 100644
--- a/src/client/views/nodes/EquationBox.tsx
+++ b/src/client/views/nodes/EquationBox.tsx
@@ -2,6 +2,7 @@ import EquationEditor from 'equation-editor-react';
import { action, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
+import { WidthSym } from '../../../fields/Doc';
import { documentSchema } from '../../../fields/documentSchemas';
import { Id } from '../../../fields/FieldSymbols';
import { createSchema, makeInterface } from '../../../fields/Schema';
@@ -11,11 +12,7 @@ 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';
+import './EquationBox.scss';
const EquationSchema = createSchema({});
diff --git a/src/client/views/nodes/FunctionPlotBox.tsx b/src/client/views/nodes/FunctionPlotBox.tsx
index dba08b506..f35677014 100644
--- a/src/client/views/nodes/FunctionPlotBox.tsx
+++ b/src/client/views/nodes/FunctionPlotBox.tsx
@@ -3,14 +3,16 @@ import functionPlot from "function-plot";
import { observer } from 'mobx-react';
import * as React from 'react';
import { documentSchema } from '../../../fields/documentSchemas';
-import { createSchema, makeInterface } from '../../../fields/Schema';
-import { StrCast } from '../../../fields/Types';
+import { createSchema, makeInterface, listSpec } from '../../../fields/Schema';
+import { StrCast, Cast } from '../../../fields/Types';
import { TraceMobx } from '../../../fields/util';
import { ViewBoxBaseComponent } from '../DocComponent';
import { FieldView, FieldViewProps } from './FieldView';
import './LabelBox.scss';
-import { DocListCast } from '../../../fields/Doc';
-import { computed } from 'mobx';
+import { DocListCast, Doc } from '../../../fields/Doc';
+import { computed, action, reaction } from 'mobx';
+import { Docs } from '../../documents/Documents';
+import { List } from '../../../fields/List';
const EquationSchema = createSchema({});
@@ -22,24 +24,47 @@ const EquationDocument = makeInterface(EquationSchema, documentSchema);
export class FunctionPlotBox extends ViewBoxBaseComponent<FieldViewProps, EquationDocument>(EquationDocument) {
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FunctionPlotBox, fieldKey); }
public static GraphCount = 0;
- _ref: React.RefObject<EquationEditor> = React.createRef();
_plot: any;
_plotId = "";
+ _plotEle: any;
constructor(props: any) {
super(props);
this._plotId = "graph" + FunctionPlotBox.GraphCount++;
}
- createGraph = (ele: HTMLDivElement) => {
- let width = this.props.PanelWidth();
- let height = this.props.PanelHeight();
+ componentDidMount() {
+ this.props.setContentView?.(this);
+ reaction(() => [DocListCast(this.dataDoc.data).lastElement()?.text, this.dataDoc.xRange, this.dataDoc.yRange],
+ () => this.createGraph());
+ }
+ getAnchor = () => {
+ const anchor = Docs.Create.TextanchorDocument({
+ useLinkSmallAnchor: true,
+ hideLinkButton: true,
+ annotationOn: this.rootDoc
+ });
+ anchor.xRange = new List<number>(Array.from(this._plot.options.xAxis.domain));
+ anchor.yRange = new List<number>(Array.from(this._plot.options.yAxis.domain));
+ return anchor;
+ }
+ @action
+ scrollFocus = (doc: Doc, smooth: boolean) => {
+ this.dataDoc.xRange = new List<number>(Array.from(Cast(doc.xRange, listSpec("number"), Cast(this.dataDoc.xRange, listSpec("number"), [-10, 10]))));
+ this.dataDoc.yRange = new List<number>(Array.from(Cast(doc.yRange, listSpec("number"), Cast(this.dataDoc.xRange, listSpec("number"), [-1, 9]))));
+ return 0;
+ }
+ createGraph = (ele?: HTMLDivElement) => {
+ this._plotEle = ele || this._plotEle;
+ const width = this.props.PanelWidth();
+ const height = this.props.PanelHeight();
const fn = StrCast(DocListCast(this.dataDoc.data).lastElement()?.text, "x^2").replace(/\\frac\{(.*)\}\{(.*)\}/, "($1/$2)");
console.log("Graphing:" + fn);
try {
this._plot = functionPlot({
- target: "#" + ele.id,
+ target: "#" + this._plotEle.id,
width,
height,
- yAxis: { domain: [-1, 9] },
+ xAxis: { domain: Cast(this.dataDoc.xRange, listSpec("number"), [-10, 10]) },
+ yAxis: { domain: Cast(this.dataDoc.xRange, listSpec("number"), [-1, 9]) },
grid: true,
data: [
{
@@ -53,7 +78,6 @@ export class FunctionPlotBox extends ViewBoxBaseComponent<FieldViewProps, Equati
}
}
@computed get theGraph() {
- const fn = StrCast(DocListCast(this.dataDoc.data).lastElement()?.text, "x^2");
return <div id={`${this._plotId}`} ref={r => r && this.createGraph(r)} style={{ position: "absolute", width: "100%", height: "100%" }}
onPointerDown={e => e.stopPropagation()} />;
}
diff --git a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
index aa51a3a64..d5c77786c 100644
--- a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
+++ b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
@@ -146,7 +146,7 @@ export function buildKeymap<S extends Schema<any>>(schema: S, props: any, mapKey
bind("Ctrl-m", (state: EditorState<S>, dispatch: (tx: Transaction<S>) => void) => {
dispatch(state.tr.replaceSelectionWith(schema.nodes.equation.create({ fieldKey: "math" + Utils.GenerateGuid() })));
- })
+ });
for (let i = 1; i <= 6; i++) {
bind("Shift-Ctrl-" + i, setBlockType(schema.nodes.heading, { level: i }));
diff --git a/src/fields/util.ts b/src/fields/util.ts
index 36c765dd0..5d98971da 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -302,7 +302,7 @@ export function setter(target: any, in_prop: string | symbol | number, value: an
}
export function getter(target: any, in_prop: string | symbol | number, receiver: any): any {
- let prop = in_prop;
+ const prop = in_prop;
if (in_prop === AclSym) return target[AclSym];
if (in_prop === "toString" || (in_prop !== HeightSym && in_prop !== WidthSym && in_prop !== LayoutSym && typeof prop === "symbol")) return target.__fields[prop] || target[prop];