aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r--src/client/views/nodes/DataVizBox/DataVizBox.tsx111
-rw-r--r--src/client/views/nodes/DataVizBox/components/Histogram.tsx534
-rw-r--r--src/client/views/nodes/DataVizBox/components/LineChart.tsx105
-rw-r--r--src/client/views/nodes/DataVizBox/components/PieChart.tsx401
-rw-r--r--src/client/views/nodes/DataVizBox/components/TableBox.tsx87
-rw-r--r--src/client/views/nodes/DocumentView.tsx17
-rw-r--r--src/client/views/nodes/FontIconBox/FontIconBox.tsx4
-rw-r--r--src/client/views/nodes/FunctionPlotBox.tsx4
-rw-r--r--src/client/views/nodes/ImageBox.tsx14
-rw-r--r--src/client/views/nodes/KeyValueBox.tsx17
-rw-r--r--src/client/views/nodes/LinkBox.tsx2
-rw-r--r--src/client/views/nodes/MapBox/MapBox.tsx2
-rw-r--r--src/client/views/nodes/MapBox/MapBox2.tsx2
-rw-r--r--src/client/views/nodes/PDFBox.tsx6
-rw-r--r--src/client/views/nodes/WebBox.tsx16
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx29
-rw-r--r--src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts2
-rw-r--r--src/client/views/nodes/formattedText/RichTextMenu.tsx2
-rw-r--r--src/client/views/nodes/trails/PresBox.tsx567
-rw-r--r--src/client/views/nodes/trails/PresElementBox.tsx50
20 files changed, 1047 insertions, 925 deletions
diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index 0cc73f32f..059c39c68 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -20,7 +20,7 @@ export enum DataVizView {
TABLE = 'table',
LINECHART = 'lineChart',
HISTOGRAM = 'histogram',
- PIECHART = 'pieChart'
+ PIECHART = 'pieChart',
}
@observer
@@ -39,20 +39,22 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// current displayed chart type
@computed get dataVizView(): DataVizView {
- return StrCast(this.layoutDoc._dataVizView, 'table') as DataVizView;
+ return StrCast(this.layoutDoc._dataViz, 'table') as DataVizView;
}
@action // pinned / linked anchor doc includes selected rows, graph titles, and graph colors
restoreView = (data: Doc) => {
- const changedView = this.dataVizView !== data.presDataVizView && (this.layoutDoc._dataVizView = data.presDataVizView);
- const changedAxes = this.axes.join('') !== StrListCast(data.presDataVizAxes).join('') && (this.layoutDoc._data_vizAxes = new List<string>(StrListCast(data.presDataVizAxes)));
- this.layoutDoc.selected = Field.Copy(data.selected);
+ const changedView = this.dataVizView !== data.config_dataViz && (this.layoutDoc._dataViz = data.config_dataViz);
+ const changedAxes = this.axes.join('') !== StrListCast(data.config_dataVizAxes).join('') && (this.layoutDoc._dataViz_axes = new List<string>(StrListCast(data.config_dataVizAxes)));
+ this.layoutDoc.dataViz_selectedRows = Field.Copy(data.dataViz_selectedRows);
this.layoutDoc.histogramBarColors = Field.Copy(data.histogramBarColors);
this.layoutDoc.defaultHistogramColor = data.defaultHistogramColor;
this.layoutDoc.pieSliceColors = Field.Copy(data.pieSliceColors);
Object.keys(this.layoutDoc).map(key => {
- if (key.startsWith('histogram-title') || key.startsWith('lineChart-title') || key.startsWith('pieChart-title')){ this.layoutDoc['_'+key] = data[key]; }
- })
+ if (key.startsWith('histogram_title') || key.startsWith('lineChart_title') || key.startsWith('pieChart_title')) {
+ this.layoutDoc['_' + key] = data[key];
+ }
+ });
const func = () => this._chartRenderer?.restoreView(data);
if (changedView || changedAxes) {
setTimeout(func, 100);
@@ -69,23 +71,25 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// this is for when we want the whole doc (so when the chartBox getAnchor returns without a marker)
/*put in some options*/
});
- anchor.presDataVizView = this.dataVizView;
- anchor.presDataVizAxes = this.axes.length ? new List<string>(this.axes) : undefined;
- anchor.selected = Field.Copy(this.layoutDoc.selected);
+ anchor.config_dataViz = this.dataVizView;
+ anchor.config_dataVizAxes = this.axes.length ? new List<string>(this.axes) : undefined;
+ anchor.dataViz_selectedRows = Field.Copy(this.layoutDoc.dataViz_selectedRows);
anchor.histogramBarColors = Field.Copy(this.layoutDoc.histogramBarColors);
anchor.defaultHistogramColor = this.layoutDoc.defaultHistogramColor;
anchor.pieSliceColors = Field.Copy(this.layoutDoc.pieSliceColors);
Object.keys(this.layoutDoc).map(key => {
- if (key.startsWith('histogram-title') || key.startsWith('lineChart-title') || key.startsWith('pieChart-title')){ anchor[key] = this.layoutDoc[key]; }
- })
+ if (key.startsWith('histogram_title') || key.startsWith('lineChart_title') || key.startsWith('pieChart_title')) {
+ anchor[key] = this.layoutDoc[key];
+ }
+ });
this.addDocument(anchor);
return anchor;
};
@computed.struct get axes() {
- return StrListCast(this.layoutDoc.data_vizAxes);
+ return StrListCast(this.layoutDoc.dataViz_axes);
}
- selectAxes = (axes: string[]) => (this.layoutDoc.data_vizAxes = new List<string>(axes));
+ selectAxes = (axes: string[]) => (this.layoutDoc.dataViz_axes = new List<string>(axes));
// toggles for user to decide which chart type to view the data in
@computed get selectView() {
@@ -94,10 +98,53 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
const margin = { top: 10, right: 25, bottom: 75, left: 45 };
if (!this.pairs) return 'no data';
switch (this.dataVizView) {
- case DataVizView.TABLE: return <TableBox layoutDoc={this.layoutDoc} pairs={this.pairs} axes={this.axes} height={height} width={width} margin={margin} rootDoc={this.rootDoc} docView={this.props.DocumentView} selectAxes={this.selectAxes}/>;
- case DataVizView.LINECHART: return <LineChart layoutDoc={this.layoutDoc} ref={r => (this._chartRenderer = r ?? undefined)} height={height} width={width} fieldKey={this.fieldKey} margin={margin} rootDoc={this.rootDoc} axes={this.axes} pairs={this.pairs} dataDoc={this.dataDoc} />;
- case DataVizView.HISTOGRAM: return <Histogram layoutDoc={this.layoutDoc} ref={r => (this._chartRenderer = r ?? undefined)} height={height} width={width} fieldKey={this.fieldKey} margin={margin} rootDoc={this.rootDoc} axes={this.axes} pairs={this.pairs} dataDoc={this.dataDoc} />;
- case DataVizView.PIECHART: return <PieChart layoutDoc={this.layoutDoc} ref={r => (this._chartRenderer = r ?? undefined)} height={height} width={width} fieldKey={this.fieldKey} margin={margin} rootDoc={this.rootDoc} axes={this.axes} pairs={this.pairs} dataDoc={this.dataDoc} />;
+ case DataVizView.TABLE:
+ return <TableBox layoutDoc={this.layoutDoc} pairs={this.pairs} axes={this.axes} height={height} width={width} margin={margin} rootDoc={this.rootDoc} docView={this.props.DocumentView} selectAxes={this.selectAxes} />;
+ case DataVizView.LINECHART:
+ return (
+ <LineChart
+ layoutDoc={this.layoutDoc}
+ ref={r => (this._chartRenderer = r ?? undefined)}
+ height={height}
+ width={width}
+ fieldKey={this.fieldKey}
+ margin={margin}
+ rootDoc={this.rootDoc}
+ axes={this.axes}
+ pairs={this.pairs}
+ dataDoc={this.dataDoc}
+ />
+ );
+ case DataVizView.HISTOGRAM:
+ return (
+ <Histogram
+ layoutDoc={this.layoutDoc}
+ ref={r => (this._chartRenderer = r ?? undefined)}
+ height={height}
+ width={width}
+ fieldKey={this.fieldKey}
+ margin={margin}
+ rootDoc={this.rootDoc}
+ axes={this.axes}
+ pairs={this.pairs}
+ dataDoc={this.dataDoc}
+ />
+ );
+ case DataVizView.PIECHART:
+ return (
+ <PieChart
+ layoutDoc={this.layoutDoc}
+ ref={r => (this._chartRenderer = r ?? undefined)}
+ height={height}
+ width={width}
+ fieldKey={this.fieldKey}
+ margin={margin}
+ rootDoc={this.rootDoc}
+ axes={this.axes}
+ pairs={this.pairs}
+ dataDoc={this.dataDoc}
+ />
+ );
}
}
@@ -118,14 +165,10 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
render() {
- if (!this.layoutDoc._dataVizView) this.layoutDoc._dataVizView = this.dataVizView;
+ if (!this.layoutDoc._dataViz) this.layoutDoc._dataViz = this.dataVizView;
return !this.pairs?.length ? (
// displays how to get data into the DataVizBox if its empty
- <div className="start-message">
- To create a DataViz box, either import / drag a CSV file into your canvas
- or copy a data table and use the command 'ctrl + p' to bring the data table
- to your canvas.
- </div>
+ <div className="start-message">To create a DataViz box, either import / drag a CSV file into your canvas or copy a data table and use the command 'ctrl + p' to bring the data table to your canvas.</div>
) : (
<div
className="dataViz"
@@ -141,22 +184,10 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
)
}>
<div className={'datatype-button'}>
- <Toggle text={"TABLE"} toggleType={ToggleType.BUTTON} type={Type.SEC} color={"black"}
- onClick={e => this.layoutDoc._dataVizView = DataVizView.TABLE}
- toggleStatus={this.layoutDoc._dataVizView == DataVizView.TABLE}
- />
- <Toggle text={"LINECHART"} toggleType={ToggleType.BUTTON} type={Type.SEC} color={"black"}
- onClick={e => this.layoutDoc._dataVizView = DataVizView.LINECHART}
- toggleStatus={this.layoutDoc._dataVizView == DataVizView.LINECHART}
- />
- <Toggle text={"HISTOGRAM"} toggleType={ToggleType.BUTTON} type={Type.SEC} color={"black"}
- onClick={e => this.layoutDoc._dataVizView = DataVizView.HISTOGRAM}
- toggleStatus={this.layoutDoc._dataVizView == DataVizView.HISTOGRAM}
- />
- <Toggle text={"PIE CHART"} toggleType={ToggleType.BUTTON} type={Type.SEC} color={"black"}
- onClick={e => this.layoutDoc._dataVizView = DataVizView.PIECHART}
- toggleStatus={this.layoutDoc._dataVizView == DataVizView.PIECHART}
- />
+ <Toggle text={'TABLE'} toggleType={ToggleType.BUTTON} type={Type.SEC} color={'black'} onClick={e => (this.layoutDoc._dataViz = DataVizView.TABLE)} toggleStatus={this.layoutDoc._dataViz == DataVizView.TABLE} />
+ <Toggle text={'LINECHART'} toggleType={ToggleType.BUTTON} type={Type.SEC} color={'black'} onClick={e => (this.layoutDoc._dataViz = DataVizView.LINECHART)} toggleStatus={this.layoutDoc._dataViz == DataVizView.LINECHART} />
+ <Toggle text={'HISTOGRAM'} toggleType={ToggleType.BUTTON} type={Type.SEC} color={'black'} onClick={e => (this.layoutDoc._dataViz = DataVizView.HISTOGRAM)} toggleStatus={this.layoutDoc._dataViz == DataVizView.HISTOGRAM} />
+ <Toggle text={'PIE CHART'} toggleType={ToggleType.BUTTON} type={Type.SEC} color={'black'} onClick={e => (this.layoutDoc._dataViz = DataVizView.PIECHART)} toggleStatus={this.layoutDoc._dataViz == DataVizView.PIECHART} />
</div>
{this.selectView}
</div>
diff --git a/src/client/views/nodes/DataVizBox/components/Histogram.tsx b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
index df6aac6bc..086db2a47 100644
--- a/src/client/views/nodes/DataVizBox/components/Histogram.tsx
+++ b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
@@ -1,20 +1,20 @@
-import { observer } from "mobx-react";
-import { Doc, StrListCast } from "../../../../../fields/Doc";
+import { observer } from 'mobx-react';
+import { Doc, StrListCast } from '../../../../../fields/Doc';
import * as React from 'react';
import * as d3 from 'd3';
-import { IReactionDisposer, action, computed, observable, reaction } from "mobx";
-import { LinkManager } from "../../../../util/LinkManager";
-import { Cast, DocCast, StrCast} from "../../../../../fields/Types";
-import { PinProps, PresBox } from "../../trails";
-import { Docs } from "../../../../documents/Documents";
-import { List } from "../../../../../fields/List";
+import { IReactionDisposer, action, computed, observable, reaction } from 'mobx';
+import { LinkManager } from '../../../../util/LinkManager';
+import { Cast, DocCast, StrCast } from '../../../../../fields/Types';
+import { PinProps, PresBox } from '../../trails';
+import { Docs } from '../../../../documents/Documents';
+import { List } from '../../../../../fields/List';
import './Chart.scss';
-import { ColorPicker, EditableText, IconButton, Size, Type } from "browndash-components";
-import { FaFillDrip } from "react-icons/fa";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { listSpec } from "../../../../../fields/Schema";
-import { scaleCreatorNumerical, yAxisCreator } from "../utils/D3Utils";
-import { undoBatch, undoable } from "../../../../util/UndoManager";
+import { ColorPicker, EditableText, IconButton, Size, Type } from 'browndash-components';
+import { FaFillDrip } from 'react-icons/fa';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { listSpec } from '../../../../../fields/Schema';
+import { scaleCreatorNumerical, yAxisCreator } from '../utils/D3Utils';
+import { undoBatch, undoable } from '../../../../util/UndoManager';
export interface HistogramProps {
rootDoc: Doc;
@@ -35,7 +35,6 @@ export interface HistogramProps {
@observer
export class Histogram extends React.Component<HistogramProps> {
-
private _disposers: { [key: string]: IReactionDisposer } = {};
private _histogramRef: React.RefObject<HTMLDivElement> = React.createRef();
private _histogramSvg: d3.Selection<SVGGElement, unknown, null, undefined> | undefined;
@@ -49,32 +48,37 @@ export class Histogram extends React.Component<HistogramProps> {
// filters all data to just display selected data if brushed (created from an incoming link)
@computed get _histogramData() {
- var guids = StrListCast(this.props.layoutDoc.rowGuids);
+ var guids = StrListCast(this.props.layoutDoc.dataViz_rowGuids);
if (this.props.axes.length < 1) return [];
if (this.props.axes.length < 2) {
var ax0 = this.props.axes[0];
- if (/\d/.test(this.props.pairs[0][ax0])){ this.numericalXData = true }
+ if (/\d/.test(this.props.pairs[0][ax0])) {
+ this.numericalXData = true;
+ }
return this.props.pairs
- ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)])))
- .map(pair => ({ [ax0]: (pair[this.props.axes[0]])}))
- };
+ ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)])))
+ .map(pair => ({ [ax0]: pair[this.props.axes[0]] }));
+ }
var ax0 = this.props.axes[0];
var ax1 = this.props.axes[1];
- if (/\d/.test(this.props.pairs[0][ax0])) { this.numericalXData = true;}
- if (/\d/.test(this.props.pairs[0][ax1]) ) { this.numericalYData = true;}
+ if (/\d/.test(this.props.pairs[0][ax0])) {
+ this.numericalXData = true;
+ }
+ if (/\d/.test(this.props.pairs[0][ax1])) {
+ this.numericalYData = true;
+ }
return this.props.pairs
- ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)])))
- .map(pair => ({ [ax0]: (pair[this.props.axes[0]]), [ax1]: (pair[this.props.axes[1]]) }))
+ ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)])))
+ .map(pair => ({ [ax0]: pair[this.props.axes[0]], [ax1]: pair[this.props.axes[1]] }));
}
- @computed get defaultGraphTitle(){
+ @computed get defaultGraphTitle() {
var ax0 = this.props.axes[0];
- var ax1 = (this.props.axes.length>1)? this.props.axes[1] : undefined;
- if (this.props.axes.length<2 || !ax1 || !/\d/.test(this.props.pairs[0][ax1]) || !this.numericalYData){
- return ax0 + " Histogram";
- }
- else return ax0 + " by " + ax1 + " Histogram";
- }
+ var ax1 = this.props.axes.length > 1 ? this.props.axes[1] : undefined;
+ if (this.props.axes.length < 2 || !ax1 || !/\d/.test(this.props.pairs[0][ax1]) || !this.numericalYData) {
+ return ax0 + ' Histogram';
+ } else return ax0 + ' by ' + ax1 + ' Histogram';
+ }
@computed get incomingLinks() {
return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
@@ -83,11 +87,11 @@ export class Histogram extends React.Component<HistogramProps> {
}
@computed get rangeVals(): { xMin?: number; xMax?: number; yMin?: number; yMax?: number } {
- if (this.numericalXData){
+ if (this.numericalXData) {
const data = this.data(this._histogramData);
- return {xMin: Math.min.apply(null, data), xMax: Math.max.apply(null, data), yMin:0, yMax:0}
+ return { xMin: Math.min.apply(null, data), xMax: Math.max.apply(null, data), yMin: 0, yMax: 0 };
}
- return {xMin:0, xMax:0, yMin:0, yMax:0}
+ return { xMin: 0, xMax: 0, yMin: 0, yMax: 0 };
}
componentWillUnmount() {
@@ -97,7 +101,7 @@ export class Histogram extends React.Component<HistogramProps> {
this._disposers.chartData = reaction(
() => ({ dataSet: this._histogramData, w: this.width, h: this.height }),
({ dataSet, w, h }) => {
- if (dataSet!.length>0) {
+ if (dataSet!.length > 0) {
this.drawChart(dataSet, w, h);
}
},
@@ -113,7 +117,7 @@ export class Histogram extends React.Component<HistogramProps> {
//
title: 'histogram doc selection' + this._currSelected,
});
- PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: pinProps?.pinData }, this.props.dataDoc);
+ PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: pinProps?.pinData }, this.props.rootDoc);
return anchor;
};
@@ -127,20 +131,22 @@ export class Histogram extends React.Component<HistogramProps> {
// cleans data by converting numerical data to numbers and taking out empty cells
data = (dataSet: any) => {
- var validData = dataSet.filter((d: { [x: string]: unknown; }) => {
+ var validData = dataSet.filter((d: { [x: string]: unknown }) => {
var valid = true;
Object.keys(dataSet[0]).map(key => {
if (!d[key] || Number.isNaN(d[key])) valid = false;
- })
+ });
return valid;
- })
- var field = dataSet[0]? Object.keys(dataSet[0])[0] : undefined;
- const data = validData.map((d: { [x: string]: any; }) => {
- if (this.numericalXData) { return +d[field!].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') }
- return d[field!]
- })
+ });
+ var field = dataSet[0] ? Object.keys(dataSet[0])[0] : undefined;
+ const data = validData.map((d: { [x: string]: any }) => {
+ if (this.numericalXData) {
+ return +d[field!].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '');
+ }
+ return d[field!];
+ });
return data;
- }
+ };
// outlines the bar selected / hovered over
highlightSelectedBar = (changeSelectedVariables: boolean, svg: any, eachRectWidth: any, pointerX: any, xAxisTitle: any, yAxisTitle: any, histDataSet: any) => {
@@ -148,35 +154,31 @@ export class Histogram extends React.Component<HistogramProps> {
var barCounter = -1;
const selected = svg.selectAll('.histogram-bar').filter((d: any) => {
barCounter++; // uses the order of bars and width of each bar to find which one the pointer is over
- if ((barCounter*eachRectWidth ) <= pointerX && pointerX <= ((barCounter+1)*eachRectWidth)){
- var showSelected = this.numericalYData? this._histogramData.filter((data: { [x: string]: any; }) => StrCast(data[xAxisTitle]).replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')==d[0])[0]
- : histDataSet.filter((data: { [x: string]: any; }) => data[xAxisTitle].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')==d[0])[0];
- if (this.numericalXData){
+ if (barCounter * eachRectWidth <= pointerX && pointerX <= (barCounter + 1) * eachRectWidth) {
+ var showSelected = this.numericalYData
+ ? this._histogramData.filter((data: { [x: string]: any }) => StrCast(data[xAxisTitle]).replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') == d[0])[0]
+ : histDataSet.filter((data: { [x: string]: any }) => data[xAxisTitle].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') == d[0])[0];
+ if (this.numericalXData) {
// calculating frequency
- if (d[0] && d[1] && d[0]!=d[1]){
- showSelected = {[xAxisTitle]: (d3.min(d) + " to " + d3.max(d)), frequency: d.length}
- }
- else if (!this.numericalYData) showSelected = {[xAxisTitle]: showSelected[xAxisTitle], frequency: d.length}
- }
- if (changeSelectedVariables){
- // for when a bar is selected - not just hovered over
- sameAsCurrent = this._currSelected?
- (showSelected[xAxisTitle]==this._currSelected![xAxisTitle]
- && showSelected[yAxisTitle]==this._currSelected![yAxisTitle])
- : false;
- this._currSelected = sameAsCurrent? undefined: showSelected;
- this.selectedData = sameAsCurrent? undefined: d;
+ if (d[0] && d[1] && d[0] != d[1]) {
+ showSelected = { [xAxisTitle]: d3.min(d) + ' to ' + d3.max(d), frequency: d.length };
+ } else if (!this.numericalYData) showSelected = { [xAxisTitle]: showSelected[xAxisTitle], frequency: d.length };
}
- else this.hoverOverData = d;
- return true
+ if (changeSelectedVariables) {
+ // for when a bar is selected - not just hovered over
+ sameAsCurrent = this._currSelected ? showSelected[xAxisTitle] == this._currSelected![xAxisTitle] && showSelected[yAxisTitle] == this._currSelected![yAxisTitle] : false;
+ this._currSelected = sameAsCurrent ? undefined : showSelected;
+ this.selectedData = sameAsCurrent ? undefined : d;
+ } else this.hoverOverData = d;
+ return true;
}
return false;
});
- if (changeSelectedVariables){
+ if (changeSelectedVariables) {
if (sameAsCurrent!) this.curBarSelected = undefined;
else this.curBarSelected = selected;
}
- }
+ };
// draws the histogram
drawChart = (dataSet: any, width: number, height: number) => {
@@ -184,306 +186,338 @@ export class Histogram extends React.Component<HistogramProps> {
d3.select(this._histogramRef.current).select('.tooltip').remove();
var data = this.data(dataSet);
- var xAxisTitle = Object.keys(dataSet[0])[0]
+ var xAxisTitle = Object.keys(dataSet[0])[0];
var yAxisTitle = this.numericalYData ? Object.keys(dataSet[0])[1] : 'frequency';
- let uniqueArr: unknown[] = [...new Set(data)]
- var numBins = (this.numericalXData && Number.isInteger(data[0]))? (this.rangeVals.xMax! - this.rangeVals.xMin! ) : uniqueArr.length
- var translateXAxis = !this.numericalXData || numBins<this.maxBins ? width/(numBins+1)/2 : 0;
- if (numBins>this.maxBins) numBins = this.maxBins;
- var startingPoint = this.numericalXData? this.rangeVals.xMin! : 0;
- var endingPoint = this.numericalXData? this.rangeVals.xMax! : numBins;
+ let uniqueArr: unknown[] = [...new Set(data)];
+ var numBins = this.numericalXData && Number.isInteger(data[0]) ? this.rangeVals.xMax! - this.rangeVals.xMin! : uniqueArr.length;
+ var translateXAxis = !this.numericalXData || numBins < this.maxBins ? width / (numBins + 1) / 2 : 0;
+ if (numBins > this.maxBins) numBins = this.maxBins;
+ var startingPoint = this.numericalXData ? this.rangeVals.xMin! : 0;
+ var endingPoint = this.numericalXData ? this.rangeVals.xMax! : numBins;
// converts data into Objects
- var histDataSet = dataSet.filter((d: { [x: string]: unknown; }) => {
+ var histDataSet = dataSet.filter((d: { [x: string]: unknown }) => {
var valid = true;
Object.keys(dataSet[0]).map(key => {
if (!d[key] || Number.isNaN(d[key])) valid = false;
- })
+ });
return valid;
});
if (!this.numericalXData) {
- var histStringDataSet: { [x: string]: unknown; }[] = [];
- if (this.numericalYData){
- for (let i=0; i<dataSet.length; i++){
- histStringDataSet.push({[yAxisTitle]: dataSet[i][yAxisTitle], [xAxisTitle]: dataSet[i][xAxisTitle]})
+ var histStringDataSet: { [x: string]: unknown }[] = [];
+ if (this.numericalYData) {
+ for (let i = 0; i < dataSet.length; i++) {
+ histStringDataSet.push({ [yAxisTitle]: dataSet[i][yAxisTitle], [xAxisTitle]: dataSet[i][xAxisTitle] });
}
- }
- else{
- for (let i=0; i<uniqueArr.length; i++){
- histStringDataSet.push({[yAxisTitle]: 0, [xAxisTitle]: uniqueArr[i]})
+ } else {
+ for (let i = 0; i < uniqueArr.length; i++) {
+ histStringDataSet.push({ [yAxisTitle]: 0, [xAxisTitle]: uniqueArr[i] });
}
- for (let i=0; i<data.length; i++){
- let barData = histStringDataSet.filter(each => each[xAxisTitle]==data[i])
- histStringDataSet.filter(each => each[xAxisTitle]==data[i])[0][yAxisTitle] = Number(barData[0][yAxisTitle]) + 1;
+ for (let i = 0; i < data.length; i++) {
+ let barData = histStringDataSet.filter(each => each[xAxisTitle] == data[i]);
+ histStringDataSet.filter(each => each[xAxisTitle] == data[i])[0][yAxisTitle] = Number(barData[0][yAxisTitle]) + 1;
}
}
- histDataSet = histStringDataSet
+ histDataSet = histStringDataSet;
}
// initial graph and binning data for histogram
var svg = (this._histogramSvg = d3
.select(this._histogramRef.current)
- .append("svg")
- .attr("class", "graph")
- .attr("width", width + this.props.margin.right + this.props.margin.left)
- .attr("height", height + this.props.margin.top + this.props.margin.bottom)
- .append("g")
- .attr("transform",
- "translate(" + this.props.margin.left + "," + this.props.margin.top + ")"));
- var x = d3.scaleLinear()
- .domain(this.numericalXData? [startingPoint!, endingPoint!] : [0, numBins])
- .range([0, width ]);
- var histogram = d3.histogram()
- .value(function(d) {return d})
+ .append('svg')
+ .attr('class', 'graph')
+ .attr('width', width + this.props.margin.right + this.props.margin.left)
+ .attr('height', height + this.props.margin.top + this.props.margin.bottom)
+ .append('g')
+ .attr('transform', 'translate(' + this.props.margin.left + ',' + this.props.margin.top + ')'));
+ var x = d3
+ .scaleLinear()
+ .domain(this.numericalXData ? [startingPoint!, endingPoint!] : [0, numBins])
+ .range([0, width]);
+ var histogram = d3
+ .histogram()
+ .value(function (d) {
+ return d;
+ })
.domain([startingPoint!, endingPoint!])
- .thresholds(x.ticks(numBins))
- var bins = histogram(data)
- var eachRectWidth = width/(bins.length)
- var graphStartingPoint = (bins[0].x1 && bins[1])? bins[0].x1! - (bins[1].x1! - bins[1].x0!) : 0;
+ .thresholds(x.ticks(numBins));
+ var bins = histogram(data);
+ var eachRectWidth = width / bins.length;
+ var graphStartingPoint = bins[0].x1 && bins[1] ? bins[0].x1! - (bins[1].x1! - bins[1].x0!) : 0;
bins[0].x0 = graphStartingPoint;
- x = x.domain([graphStartingPoint, endingPoint])
- .range([0, Number.isInteger(this.rangeVals.xMin!)? (width-eachRectWidth) : width ])
+ x = x.domain([graphStartingPoint, endingPoint]).range([0, Number.isInteger(this.rangeVals.xMin!) ? width - eachRectWidth : width]);
var xAxis;
// more calculations based on bins
// x-axis
- if (!this.numericalXData) { // reorganize to match data if the data is strings rather than numbers
+ if (!this.numericalXData) {
+ // reorganize to match data if the data is strings rather than numbers
// uniqueArr.sort()
- histDataSet.sort()
- for (let i=0; i<data.length; i++){
- var index = 0
- for (let j=0; j<uniqueArr.length; j++){
- if (uniqueArr[j] == data[i]){
+ histDataSet.sort();
+ for (let i = 0; i < data.length; i++) {
+ var index = 0;
+ for (let j = 0; j < uniqueArr.length; j++) {
+ if (uniqueArr[j] == data[i]) {
index = j;
}
}
- if (bins[index]) bins[index].push(data[i])
+ if (bins[index]) bins[index].push(data[i]);
}
bins.pop();
- eachRectWidth = width/(bins.length)
- bins.forEach(d => d.x0 = d.x0!)
- xAxis = d3.axisBottom(x)
- .ticks(bins.length>1? bins.length-1: 1)
- .tickFormat( i => uniqueArr[i.valueOf()] as string)
- .tickPadding(10)
- x.range([0, width-eachRectWidth])
- x.domain([0, bins.length-1])
+ eachRectWidth = width / bins.length;
+ bins.forEach(d => (d.x0 = d.x0!));
+ xAxis = d3
+ .axisBottom(x)
+ .ticks(bins.length > 1 ? bins.length - 1 : 1)
+ .tickFormat(i => uniqueArr[i.valueOf()] as string)
+ .tickPadding(10);
+ x.range([0, width - eachRectWidth]);
+ x.domain([0, bins.length - 1]);
translateXAxis = eachRectWidth / 2;
- }
- else {
+ } else {
var allSame = true;
- for (var i=0; i<bins.length; i++){
- if (bins[i] && bins[i][0]){
+ for (var i = 0; i < bins.length; i++) {
+ if (bins[i] && bins[i][0]) {
var compare = bins[i][0];
- for (let j=1; j<bins[i].length; j++){
+ for (let j = 1; j < bins[i].length; j++) {
if (bins[i][j] != compare) allSame = false;
}
}
}
- if (allSame){
+ if (allSame) {
translateXAxis = eachRectWidth / 2;
- eachRectWidth = width/(bins.length)
- }
- else {
- eachRectWidth = width/(bins.length+1)
- var tickDiff = (bins.length>=2? (bins[bins.length-2].x1!-bins[bins.length-2].x0!): 0)
+ eachRectWidth = width / bins.length;
+ } else {
+ eachRectWidth = width / (bins.length + 1);
+ var tickDiff = bins.length >= 2 ? bins[bins.length - 2].x1! - bins[bins.length - 2].x0! : 0;
var curDomain = x.domain();
- x.domain([curDomain[0], curDomain[0] + tickDiff*bins.length])
+ x.domain([curDomain[0], curDomain[0] + tickDiff * bins.length]);
}
- xAxis = d3.axisBottom(x)
- .ticks(bins.length-1)
- x.range([0, width-eachRectWidth])
+ xAxis = d3.axisBottom(x).ticks(bins.length - 1);
+ x.range([0, width - eachRectWidth]);
}
// y-axis
- const maxFrequency = this.numericalYData? d3.max(histDataSet, function(d: any) {
- return d[yAxisTitle]? Number(d[yAxisTitle]!.replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')) : 0})
- : d3.max(bins, function(d) { return d.length; })
- var y = d3.scaleLinear()
- .range([height, 0]);
- y.domain([0, +maxFrequency!]);
- var yAxis = d3.axisLeft(y)
- .ticks(maxFrequency!)
- if (this.numericalYData){
+ const maxFrequency = this.numericalYData
+ ? d3.max(histDataSet, function (d: any) {
+ return d[yAxisTitle] ? Number(d[yAxisTitle]!.replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')) : 0;
+ })
+ : d3.max(bins, function (d) {
+ return d.length;
+ });
+ var y = d3.scaleLinear().range([height, 0]);
+ y.domain([0, +maxFrequency!]);
+ var yAxis = d3.axisLeft(y).ticks(maxFrequency!);
+ if (this.numericalYData) {
const yScale = scaleCreatorNumerical(0, Number(maxFrequency), height, 0);
yAxisCreator(svg.append('g'), width, yScale);
+ } else {
+ svg.append('g').call(yAxis);
}
- else{
- svg.append("g")
- .call(yAxis);
- }
- svg.append("g")
- .attr("transform", "translate(" + translateXAxis + ", " + height + ")")
- .call(xAxis)
+ svg.append('g')
+ .attr('transform', 'translate(' + translateXAxis + ', ' + height + ')')
+ .call(xAxis);
// click/hover
const onPointClick = action((e: any) => this.highlightSelectedBar(true, svg, eachRectWidth, d3.pointer(e)[0], xAxisTitle, yAxisTitle, histDataSet));
const onHover = action((e: any) => {
- const selected = this.highlightSelectedBar(false, svg, eachRectWidth, d3.pointer(e)[0], xAxisTitle, yAxisTitle, histDataSet)
+ const selected = this.highlightSelectedBar(false, svg, eachRectWidth, d3.pointer(e)[0], xAxisTitle, yAxisTitle, histDataSet);
updateHighlights();
- })
+ });
const mouseOut = action((e: any) => {
this.hoverOverData = undefined;
updateHighlights();
- })
+ });
const updateHighlights = () => {
const hoverOverBar = this.hoverOverData;
const selectedData = this.selectedData;
- svg.selectAll('rect').attr("class", function(d: any) { return ((hoverOverBar && hoverOverBar[0]==d[0]) || selectedData && selectedData[0]==d[0])? 'histogram-bar hover' : 'histogram-bar'; })
- }
- svg.on('click', onPointClick)
- .on('mouseover', onHover)
- .on('mouseout', mouseOut)
+ svg.selectAll('rect').attr('class', function (d: any) {
+ return (hoverOverBar && hoverOverBar[0] == d[0]) || (selectedData && selectedData[0] == d[0]) ? 'histogram-bar hover' : 'histogram-bar';
+ });
+ };
+ svg.on('click', onPointClick).on('mouseover', onHover).on('mouseout', mouseOut);
// axis titles
- svg.append("text")
- .attr("transform", "translate(" + (width/2) + " ," + (height+40) + ")")
- .style("text-anchor", "middle")
+ svg.append('text')
+ .attr('transform', 'translate(' + width / 2 + ' ,' + (height + 40) + ')')
+ .style('text-anchor', 'middle')
.text(xAxisTitle);
- svg.append("text")
- .attr("transform", "rotate(-90)" + " " + "translate( 0, " + -10 + ")")
- .attr("x", -(height/2))
- .attr("y", -20)
- .style("text-anchor", "middle")
+ svg.append('text')
+ .attr('transform', 'rotate(-90)' + ' ' + 'translate( 0, ' + -10 + ')')
+ .attr('x', -(height / 2))
+ .attr('y', -20)
+ .style('text-anchor', 'middle')
.text(yAxisTitle);
- d3.format('.0f')
+ d3.format('.0f');
// draw bars
var selected = this.selectedData;
- svg.selectAll("rect")
+ svg.selectAll('rect')
.data(bins)
.enter()
- .append("rect")
- .attr("transform", this.numericalYData?
- function (d) {
- var eachData = histDataSet.filter((data: { [x: string]: number; }) => {return data[xAxisTitle]==d[0]})
- var length = eachData.length? eachData[0][yAxisTitle].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') : 0;
- return "translate(" + x(d.x0!) + "," + y(length) + ")";
- }
- : function(d) { return "translate(" + x(d.x0!) + "," + y(d.length) + ")"; })
- .attr("height", this.numericalYData?
- function(d) {
- var eachData = histDataSet.filter((data: { [x: string]: number; }) => {return data[xAxisTitle]==d[0]})
- var length = eachData.length? eachData[0][yAxisTitle].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') : 0;
- return height-y(length)}
- : function(d) {
- return height - y(d.length)})
- .attr("width", eachRectWidth)
- .attr("class", selected?
- function(d) {
- return (selected && selected[0]==d[0])? 'histogram-bar hover' : 'histogram-bar';
- }: function(d) {return 'histogram-bar'})
- .attr("fill", (d)=>{
+ .append('rect')
+ .attr(
+ 'transform',
+ this.numericalYData
+ ? function (d) {
+ var eachData = histDataSet.filter((data: { [x: string]: number }) => {
+ return data[xAxisTitle] == d[0];
+ });
+ var length = eachData.length ? eachData[0][yAxisTitle].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') : 0;
+ return 'translate(' + x(d.x0!) + ',' + y(length) + ')';
+ }
+ : function (d) {
+ return 'translate(' + x(d.x0!) + ',' + y(d.length) + ')';
+ }
+ )
+ .attr(
+ 'height',
+ this.numericalYData
+ ? function (d) {
+ var eachData = histDataSet.filter((data: { [x: string]: number }) => {
+ return data[xAxisTitle] == d[0];
+ });
+ var length = eachData.length ? eachData[0][yAxisTitle].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') : 0;
+ return height - y(length);
+ }
+ : function (d) {
+ return height - y(d.length);
+ }
+ )
+ .attr('width', eachRectWidth)
+ .attr(
+ 'class',
+ selected
+ ? function (d) {
+ return selected && selected[0] == d[0] ? 'histogram-bar hover' : 'histogram-bar';
+ }
+ : function (d) {
+ return 'histogram-bar';
+ }
+ )
+ .attr('fill', d => {
var barColor;
var barColors = StrListCast(this.props.layoutDoc.histogramBarColors).map(each => each.split('::'));
- barColors.map(each => {
- if (d[0] && d[0].toString() && each[0]==d[0].toString()) barColor = each[1];
+ barColors.map(each => {
+ if (d[0] && d[0].toString() && each[0] == d[0].toString()) barColor = each[1];
else {
- var range = StrCast(each[0]).split(" to ");
- if (Number(range[0])<=d[0] && d[0]<=Number(range[1])) barColor = each[1];
+ var range = StrCast(each[0]).split(' to ');
+ if (Number(range[0]) <= d[0] && d[0] <= Number(range[1])) barColor = each[1];
}
});
- return barColor? StrCast(barColor) : StrCast(this.props.layoutDoc.defaultHistogramColor)})
+ return barColor ? StrCast(barColor) : StrCast(this.props.layoutDoc.defaultHistogramColor);
+ });
};
@action changeSelectedColor = (color: string) => {
- this.curBarSelected.attr("fill", color);
- var barName = StrCast(this._currSelected[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''))
+ this.curBarSelected.attr('fill', color);
+ var barName = StrCast(this._currSelected[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''));
- const barColors = Cast(this.props.layoutDoc.histogramBarColors, listSpec("string"), null);
- barColors.map(each => { if (each.split('::')[0] == barName) barColors.splice(barColors.indexOf(each), 1) });
+ const barColors = Cast(this.props.layoutDoc.histogramBarColors, listSpec('string'), null);
+ barColors.map(each => {
+ if (each.split('::')[0] == barName) barColors.splice(barColors.indexOf(each), 1);
+ });
barColors.push(StrCast(barName + '::' + color));
};
-
- @action eraseSelectedColor= () => {
- this.curBarSelected.attr("fill", this.props.layoutDoc.defaultHistogramColor);
- var barName = StrCast(this._currSelected[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''))
- const barColors = Cast(this.props.layoutDoc.histogramBarColors, listSpec("string"), null);
- barColors.map(each => { if (each.split('::')[0] == barName) barColors.splice(barColors.indexOf(each), 1) });
+ @action eraseSelectedColor = () => {
+ this.curBarSelected.attr('fill', this.props.layoutDoc.defaultHistogramColor);
+ var barName = StrCast(this._currSelected[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''));
+
+ const barColors = Cast(this.props.layoutDoc.histogramBarColors, listSpec('string'), null);
+ barColors.map(each => {
+ if (each.split('::')[0] == barName) barColors.splice(barColors.indexOf(each), 1);
+ });
};
render() {
- this._histogramData
- var curSelectedBarName;
- var titleAccessor: any='';
- if (this.props.axes.length==2) titleAccessor = 'histogram-title-'+this.props.axes[0]+'-'+this.props.axes[1];
- else if (this.props.axes.length>0) titleAccessor = 'histogram-title-'+this.props.axes[0];
+ this._histogramData;
+ var curSelectedBarName = '';
+ var titleAccessor: any = '';
+ if (this.props.axes.length == 2) titleAccessor = 'dataViz_title_histogram_' + this.props.axes[0] + '-' + this.props.axes[1];
+ else if (this.props.axes.length > 0) titleAccessor = 'dataViz_title_histogram_' + this.props.axes[0];
if (!this.props.layoutDoc[titleAccessor]) this.props.layoutDoc[titleAccessor] = this.defaultGraphTitle;
if (!this.props.layoutDoc.defaultHistogramColor) this.props.layoutDoc.defaultHistogramColor = '#69b3a2';
if (!this.props.layoutDoc.histogramBarColors) this.props.layoutDoc.histogramBarColors = new List<string>();
var selected: string;
- if (this._currSelected){
- curSelectedBarName = StrCast(this._currSelected![this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''))
+ if (this._currSelected) {
+ curSelectedBarName = StrCast(this._currSelected![this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''));
selected = '{ ';
Object.keys(this._currSelected).map(key => {
- key!=''? selected += key + ': ' + this._currSelected[key] + ', ': '';
- })
- selected = selected.substring(0, selected.length-2);
+ key != '' ? (selected += key + ': ' + this._currSelected[key] + ', ') : '';
+ });
+ selected = selected.substring(0, selected.length - 2);
selected += ' }';
- }
- else selected = 'none';
+ } else selected = 'none';
var selectedBarColor;
var barColors = StrListCast(this.props.layoutDoc.histogramBarColors).map(each => each.split('::'));
- barColors.map(each => {if (each[0]==curSelectedBarName!) selectedBarColor = each[1]});
+ barColors.map(each => {
+ if (each[0] == curSelectedBarName!) selectedBarColor = each[1];
+ });
this.componentDidMount();
- if (this._histogramData.length>0){
- return (
- this.props.axes.length >= 1 ? (
- <div className="chart-container" >
- <div className="graph-title">
+ if (this._histogramData.length > 0) {
+ return this.props.axes.length >= 1 ? (
+ <div className="chart-container">
+ <div className="graph-title">
<EditableText
val={StrCast(this.props.layoutDoc[titleAccessor])}
- setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
- color={"black"}
+ setVal={undoable(
+ action(val => (this.props.layoutDoc[titleAccessor] = val as string)),
+ 'Change Graph Title'
+ )}
+ color={'black'}
size={Size.LARGE}
fillWidth
/>
- &nbsp; &nbsp;
+ &nbsp; &nbsp;
<ColorPicker
- tooltip={'Change Default Bar Color'}
- type={Type.SEC}
- icon={<FaFillDrip/>}
+ tooltip={'Change Default Bar Color'}
+ type={Type.SEC}
+ icon={<FaFillDrip />}
selectedColor={StrCast(this.props.layoutDoc.defaultHistogramColor)}
- setSelectedColor={undoable (color => this.props.layoutDoc.defaultHistogramColor = color, "Change Default Bar Color")}
+ setFinalColor={undoable(color => (this.props.layoutDoc.defaultHistogramColor = color), 'Change Default Bar Color')}
+ setSelectedColor={undoable(color => (this.props.layoutDoc.defaultHistogramColor = color), 'Change Default Bar Color')}
size={Size.XSMALL}
/>
</div>
<div ref={this._histogramRef} />
- {selected != 'none' ?
+ {selected != 'none' ? (
<div className={'selected-data'}>
Selected: {selected}
&nbsp; &nbsp;
<ColorPicker
- tooltip={'Change Bar Color'}
- type={Type.SEC}
- icon={<FaFillDrip/>}
- selectedColor={selectedBarColor? selectedBarColor : this.curBarSelected.attr("fill")}
- setSelectedColor={undoable (color => this.changeSelectedColor(color), "Change Selected Bar Color")}
+ tooltip={'Change Bar Color'}
+ type={Type.SEC}
+ icon={<FaFillDrip />}
+ selectedColor={selectedBarColor ? selectedBarColor : this.curBarSelected.attr('fill')}
+ setFinalColor={undoable(color => this.changeSelectedColor(color), 'Change Selected Bar Color')}
+ setSelectedColor={undoable(color => this.changeSelectedColor(color), 'Change Selected Bar Color')}
size={Size.XSMALL}
/>
&nbsp;
<IconButton
- icon={<FontAwesomeIcon icon={'eraser'} />}
- size={Size.XSMALL}
- color={'black'}
+ icon={<FontAwesomeIcon icon={'eraser'} />}
+ size={Size.XSMALL}
+ color={'black'}
type={Type.SEC}
tooltip={'Revert to the default bar color'}
- onClick={undoable (action(() => this.eraseSelectedColor()), "Change Selected Bar Color")}
+ onClick={undoable(
+ action(() => this.eraseSelectedColor()),
+ 'Change Selected Bar Color'
+ )}
/>
</div>
- : null}
+ ) : null}
</div>
- ) : <span className="chart-container"> {'first use table view to select a column to graph'}</span>
+ ) : (
+ <span className="chart-container"> {'first use table view to select a column to graph'}</span>
+ );
+ } else
+ return (
+ // when it is a brushed table and the incoming table doesn't have any rows selected
+ <div className="chart-container">Selected rows of data from the incoming DataVizBox to display.</div>
);
- }
- else return (
- // when it is a brushed table and the incoming table doesn't have any rows selected
- <div className='chart-container'>
- Selected rows of data from the incoming DataVizBox to display.
- </div>
- )
}
-} \ No newline at end of file
+}
diff --git a/src/client/views/nodes/DataVizBox/components/LineChart.tsx b/src/client/views/nodes/DataVizBox/components/LineChart.tsx
index 8bace941f..8e549adbe 100644
--- a/src/client/views/nodes/DataVizBox/components/LineChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/LineChart.tsx
@@ -50,20 +50,21 @@ export class LineChart extends React.Component<LineChartProps> {
// TODO: nda - some sort of mapping that keeps track of the annotated points so we can easily remove when annotations list updates
@computed get _lineChartData() {
- var guids = StrListCast(this.props.layoutDoc.rowGuids);
+ var guids = StrListCast(this.props.layoutDoc.dataViz_rowGuids);
if (this.props.axes.length <= 1) return [];
return this.props.pairs
- ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)])))
+ ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)])))
.map(pair => ({ x: Number(pair[this.props.axes[0]]), y: Number(pair[this.props.axes[1]]) }))
.sort((a, b) => (a.x < b.x ? -1 : 1));
}
- @computed get graphTitle(){
- return this.props.axes[1] + " vs. " + this.props.axes[0] + " Line Chart";
- }
+ @computed get graphTitle() {
+ return this.props.axes[1] + ' vs. ' + this.props.axes[0] + ' Line Chart';
+ }
@computed get incomingLinks() {
return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
.filter(link => {
- return link.link_anchor_1 == this.props.rootDoc.draggedFrom}) // get links where this chart doc is the target of the link
+ return link.link_anchor_1 == this.props.rootDoc.draggedFrom;
+ }) // get links where this chart doc is the target of the link
.map(link => DocCast(link.link_anchor_1)); // then return the source of the link
}
@computed get incomingSelected() {
@@ -158,7 +159,7 @@ export class LineChart extends React.Component<LineChartProps> {
@action
restoreView = (data: Doc) => {
- const coords = Cast(data.presDataVizSelection, listSpec('number'), null);
+ const coords = Cast(data.config_dataVizSelection, listSpec('number'), null);
if (coords?.length > 1 && (this._currSelected?.x !== coords[0] || this._currSelected?.y !== coords[1])) {
this.setCurrSelected(coords[0], coords[1]);
return true;
@@ -176,8 +177,8 @@ export class LineChart extends React.Component<LineChartProps> {
//
title: 'line doc selection' + this._currSelected?.x,
});
- PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: pinProps?.pinData }, this.props.dataDoc);
- anchor.presDataVizSelection = this._currSelected ? new List<number>([this._currSelected.x, this._currSelected.y]) : undefined;
+ PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: pinProps?.pinData }, this.props.rootDoc);
+ anchor.config_dataVizSelection = this._currSelected ? new List<number>([this._currSelected.x, this._currSelected.y]) : undefined;
return anchor;
};
@@ -189,14 +190,13 @@ export class LineChart extends React.Component<LineChartProps> {
return this.props.width - this.props.margin.left - this.props.margin.right;
}
- @computed get defaultGraphTitle(){
+ @computed get defaultGraphTitle() {
var ax0 = this.props.axes[0];
- var ax1 = (this.props.axes.length>1)? this.props.axes[1] : undefined;
- if (this.props.axes.length<2 || !/\d/.test(this.props.pairs[0][ax0]) || !ax1){
- return ax0 + " Line Chart";
- }
- else return ax1 + " by " + ax0 + " Line Chart";
- }
+ var ax1 = this.props.axes.length > 1 ? this.props.axes[1] : undefined;
+ if (this.props.axes.length < 2 || !/\d/.test(this.props.pairs[0][ax0]) || !ax1) {
+ return ax0 + ' Line Chart';
+ } else return ax1 + ' by ' + ax0 + ' Line Chart';
+ }
setupTooltip() {
return d3
@@ -215,7 +215,7 @@ export class LineChart extends React.Component<LineChartProps> {
@action
setCurrSelected(x?: number, y?: number) {
// TODO: nda - get rid of svg element in the list?
- if (this._currSelected && this._currSelected.x==x && this._currSelected.y==y) this._currSelected = undefined;
+ if (this._currSelected && this._currSelected.x == x && this._currSelected.y == y) this._currSelected = undefined;
else this._currSelected = x !== undefined && y !== undefined ? { x, y } : undefined;
this.props.pairs.forEach(pair => pair[this.props.axes[0]] === x && pair[this.props.axes[1]] === y && (pair.selected = true));
}
@@ -256,7 +256,7 @@ export class LineChart extends React.Component<LineChartProps> {
const svg = (this._lineChartSvg = d3
.select(this._lineChartRef.current)
.append('svg')
- .attr("class", "graph")
+ .attr('class', 'graph')
.attr('width', `${width + margin.left + margin.right}`)
.attr('height', `${height + margin.top + margin.bottom}`)
.append('g')
@@ -271,13 +271,13 @@ export class LineChart extends React.Component<LineChartProps> {
// get valid data points
const data = dataSet[0];
const lineGen = createLineGenerator(xScale, yScale);
- var validData = data.filter((d => {
+ var validData = data.filter(d => {
var valid = true;
Object.keys(data[0]).map(key => {
if (!d[key] || Number.isNaN(d[key])) valid = false;
- })
+ });
return valid;
- }))
+ });
// draw the plot line
drawLine(svg.append('path'), validData, lineGen);
// draw the datapoint circle
@@ -321,17 +321,17 @@ export class LineChart extends React.Component<LineChartProps> {
.on('click', onPointClick);
// axis titles
- svg.append("text")
- .attr("transform", "translate(" + (width/2) + " ," + (height+40) + ")")
- .style("text-anchor", "middle")
+ svg.append('text')
+ .attr('transform', 'translate(' + width / 2 + ' ,' + (height + 40) + ')')
+ .style('text-anchor', 'middle')
.text(this.props.axes[0]);
- svg.append("text")
- .attr("transform", "rotate(-90)" + " " + "translate( 0, " + -10 + ")")
- .attr("x", -(height/2))
- .attr("y", -20)
- .attr("height", 20)
- .attr("width", 20)
- .style("text-anchor", "middle")
+ svg.append('text')
+ .attr('transform', 'rotate(-90)' + ' ' + 'translate( 0, ' + -10 + ')')
+ .attr('x', -(height / 2))
+ .attr('y', -20)
+ .attr('height', 20)
+ .attr('width', 20)
+ .style('text-anchor', 'middle')
.text(this.props.axes[1]);
};
@@ -348,42 +348,41 @@ export class LineChart extends React.Component<LineChartProps> {
tooltip
.html(() => `<b>(${d0.x},${d0.y})</b>`) // text content for tooltip
.style('pointer-events', 'none')
- .style('transform', `translate(${xScale(d0.x)-this.width}px,${yScale(d0.y)}px)`);
+ .style('transform', `translate(${xScale(d0.x) - this.width}px,${yScale(d0.y)}px)`);
}
render() {
this.componentDidMount();
- var titleAccessor:any = '';
- if (this.props.axes.length==2) titleAccessor = 'lineChart-title-'+this.props.axes[0]+'-'+this.props.axes[1];
- else if (this.props.axes.length>0) titleAccessor = 'lineChart-title-'+this.props.axes[0];
+ var titleAccessor: any = '';
+ if (this.props.axes.length == 2) titleAccessor = 'dataViz_title_lineChart_' + this.props.axes[0] + '-' + this.props.axes[1];
+ else if (this.props.axes.length > 0) titleAccessor = 'dataViz_title_lineChart_' + this.props.axes[0];
if (!this.props.layoutDoc[titleAccessor]) this.props.layoutDoc[titleAccessor] = this.defaultGraphTitle;
const selectedPt = this._currSelected ? `{ ${this.props.axes[0]}: ${this._currSelected.x} ${this.props.axes[1]}: ${this._currSelected.y} }` : 'none';
- if (this._lineChartData.length>0){
- return (
- this.props.axes.length>=2 && /\d/.test(this.props.pairs[0][this.props.axes[0]]) && /\d/.test(this.props.pairs[0][this.props.axes[1]]) ? (
- <div className="chart-container" >
- <div className="graph-title">
+ if (this._lineChartData.length > 0) {
+ return this.props.axes.length >= 2 && /\d/.test(this.props.pairs[0][this.props.axes[0]]) && /\d/.test(this.props.pairs[0][this.props.axes[1]]) ? (
+ <div className="chart-container">
+ <div className="graph-title">
<EditableText
val={StrCast(this.props.layoutDoc[titleAccessor])}
- setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
- color={"black"}
+ setVal={undoable(
+ action(val => (this.props.layoutDoc[titleAccessor] = val as string)),
+ 'Change Graph Title'
+ )}
+ color={'black'}
size={Size.LARGE}
fillWidth
/>
</div>
<div ref={this._lineChartRef} />
- {selectedPt!='none'?
- <div className={'selected-data'}> {`Selected: ${selectedPt}`}</div>
- : null}
+ {selectedPt != 'none' ? <div className={'selected-data'}> {`Selected: ${selectedPt}`}</div> : null}
</div>
- ) : <span className="chart-container"> {'first use table view to select two numerical axes to plot'}</span>
+ ) : (
+ <span className="chart-container"> {'first use table view to select two numerical axes to plot'}</span>
+ );
+ } else
+ return (
+ // when it is a brushed table and the incoming table doesn't have any rows selected
+ <div className="chart-container">Selected rows of data from the incoming DataVizBox to display.</div>
);
- }
- else return (
- // when it is a brushed table and the incoming table doesn't have any rows selected
- <div className='chart-container'>
- Selected rows of data from the incoming DataVizBox to display.
- </div>
- )
}
}
diff --git a/src/client/views/nodes/DataVizBox/components/PieChart.tsx b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
index 0c54d0a4e..fe77293f0 100644
--- a/src/client/views/nodes/DataVizBox/components/PieChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
@@ -1,18 +1,18 @@
-import { observer } from "mobx-react";
-import { Doc, StrListCast } from "../../../../../fields/Doc";
+import { observer } from 'mobx-react';
+import { Doc, StrListCast } from '../../../../../fields/Doc';
import * as React from 'react';
import * as d3 from 'd3';
-import { IReactionDisposer, action, computed, observable, reaction } from "mobx";
-import { LinkManager } from "../../../../util/LinkManager";
-import { Cast, DocCast, StrCast} from "../../../../../fields/Types";
-import { PinProps, PresBox } from "../../trails";
-import { Docs } from "../../../../documents/Documents";
-import { List } from "../../../../../fields/List";
+import { IReactionDisposer, action, computed, observable, reaction } from 'mobx';
+import { LinkManager } from '../../../../util/LinkManager';
+import { Cast, DocCast, StrCast } from '../../../../../fields/Types';
+import { PinProps, PresBox } from '../../trails';
+import { Docs } from '../../../../documents/Documents';
+import { List } from '../../../../../fields/List';
import './Chart.scss';
-import { ColorPicker, EditableText, Size, Type } from "browndash-components";
-import { FaFillDrip } from "react-icons/fa";
-import { listSpec } from "../../../../../fields/Schema";
-import { undoable } from "../../../../util/UndoManager";
+import { ColorPicker, EditableText, Size, Type } from 'browndash-components';
+import { FaFillDrip } from 'react-icons/fa';
+import { listSpec } from '../../../../../fields/Schema';
+import { undoable } from '../../../../util/UndoManager';
export interface PieChartProps {
rootDoc: Doc;
@@ -33,7 +33,6 @@ export interface PieChartProps {
@observer
export class PieChart extends React.Component<PieChartProps> {
-
private _disposers: { [key: string]: IReactionDisposer } = {};
private _piechartRef: React.RefObject<HTMLDivElement> = React.createRef();
private _piechartSvg: d3.Selection<SVGGElement, unknown, null, undefined> | undefined;
@@ -45,31 +44,34 @@ export class PieChart extends React.Component<PieChartProps> {
// filters all data to just display selected data if brushed (created from an incoming link)
@computed get _piechartData() {
- var guids = StrListCast(this.props.layoutDoc.rowGuids);
+ var guids = StrListCast(this.props.layoutDoc.dataViz_rowGuids);
if (this.props.axes.length < 1) return [];
if (this.props.axes.length < 2) {
var ax0 = this.props.axes[0];
- if (/\d/.test(this.props.pairs[0][ax0])){ this.byCategory = false }
+ if (/\d/.test(this.props.pairs[0][ax0])) {
+ this.byCategory = false;
+ }
return this.props.pairs
- ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)])))
- .map(pair => ({ [ax0]: (pair[this.props.axes[0]])}))
- };
+ ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)])))
+ .map(pair => ({ [ax0]: pair[this.props.axes[0]] }));
+ }
var ax0 = this.props.axes[0];
var ax1 = this.props.axes[1];
- if (/\d/.test(this.props.pairs[0][ax0])) { this.byCategory = false; }
+ if (/\d/.test(this.props.pairs[0][ax0])) {
+ this.byCategory = false;
+ }
return this.props.pairs
- ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)])))
- .map(pair => ({ [ax0]: (pair[this.props.axes[0]]), [ax1]: (pair[this.props.axes[1]]) }))
+ ?.filter(pair => (!this.incomingLinks.length ? true : this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)])))
+ .map(pair => ({ [ax0]: pair[this.props.axes[0]], [ax1]: pair[this.props.axes[1]] }));
}
- @computed get defaultGraphTitle(){
+ @computed get defaultGraphTitle() {
var ax0 = this.props.axes[0];
- var ax1 = (this.props.axes.length>1)? this.props.axes[1] : undefined;
- if (this.props.axes.length<2 || !/\d/.test(this.props.pairs[0][ax0]) || !ax1){
- return ax0 + " Pie Chart";
- }
- else return ax1 + " by " + ax0 + " Pie Chart";
- }
+ var ax1 = this.props.axes.length > 1 ? this.props.axes[1] : undefined;
+ if (this.props.axes.length < 2 || !/\d/.test(this.props.pairs[0][ax0]) || !ax1) {
+ return ax0 + ' Pie Chart';
+ } else return ax1 + ' by ' + ax0 + ' Pie Chart';
+ }
@computed get incomingLinks() {
return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
@@ -84,7 +86,7 @@ export class PieChart extends React.Component<PieChartProps> {
this._disposers.chartData = reaction(
() => ({ dataSet: this._piechartData, w: this.width, h: this.height }),
({ dataSet, w, h }) => {
- if (dataSet!.length>0) {
+ if (dataSet!.length > 0) {
this.drawChart(dataSet, w, h);
}
},
@@ -100,7 +102,7 @@ export class PieChart extends React.Component<PieChartProps> {
//
title: 'piechart doc selection' + this._currSelected,
});
- PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: pinProps?.pinData }, this.props.dataDoc);
+ PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: pinProps?.pinData }, this.props.rootDoc);
return anchor;
};
@@ -114,167 +116,177 @@ export class PieChart extends React.Component<PieChartProps> {
// cleans data by converting numerical data to numbers and taking out empty cells
data = (dataSet: any) => {
- var validData = dataSet.filter((d: { [x: string]: unknown; }) => {
+ var validData = dataSet.filter((d: { [x: string]: unknown }) => {
var valid = true;
Object.keys(dataSet[0]).map(key => {
if (!d[key] || Number.isNaN(d[key])) valid = false;
- })
+ });
return valid;
- })
- var field = dataSet[0]? Object.keys(dataSet[0])[0] : undefined;
- const data = validData.map((d: { [x: string]: any; }) => {
- if (!this.byCategory) { return +d[field!].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') }
- return d[field!]
- })
+ });
+ var field = dataSet[0] ? Object.keys(dataSet[0])[0] : undefined;
+ const data = validData.map((d: { [x: string]: any }) => {
+ if (!this.byCategory) {
+ return +d[field!].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '');
+ }
+ return d[field!];
+ });
return data;
- }
+ };
// outlines the slice selected / hovered over
highlightSelectedSlice = (changeSelectedVariables: boolean, svg: any, arc: any, radius: any, pointer: any, pieDataSet: any) => {
- var index = -1;
- var sameAsCurrent: boolean;
- const selected = svg.selectAll('.slice').filter((d: any) => {
- index++;
- var p1 = [0,0]; // center of pie
- var p3 = [arc.centroid(d)[0]*2, arc.centroid(d)[1]*2]; // outward peak of arc
- var p2 = [radius*Math.sin(d.startAngle), -radius*Math.cos(d.startAngle)]; // start of arc
- var p4 = [radius*Math.sin(d.endAngle), -radius*Math.cos(d.endAngle)]; // end of arc
+ var index = -1;
+ var sameAsCurrent: boolean;
+ const selected = svg.selectAll('.slice').filter((d: any) => {
+ index++;
+ var p1 = [0, 0]; // center of pie
+ var p3 = [arc.centroid(d)[0] * 2, arc.centroid(d)[1] * 2]; // outward peak of arc
+ var p2 = [radius * Math.sin(d.startAngle), -radius * Math.cos(d.startAngle)]; // start of arc
+ var p4 = [radius * Math.sin(d.endAngle), -radius * Math.cos(d.endAngle)]; // end of arc
- // draw an imaginary horizontal line from the pointer to see how many times it crosses a slice edge
- var lineCrossCount = 0;
- // if for all 4 lines
- if (Math.min(p1[1], p2[1])<=pointer[1] && pointer[1]<=Math.max(p1[1], p2[1])){ // within y bounds
- if (pointer[0] <= (pointer[1]-p1[1])*(p2[0]-p1[0])/(p2[1]-p1[1])+p1[0]) lineCrossCount++; } // intercepts x
- if (Math.min(p2[1], p3[1])<=pointer[1] && pointer[1]<=Math.max(p2[1], p3[1])){
- if (pointer[0] <= (pointer[1]-p2[1])*(p3[0]-p2[0])/(p3[1]-p2[1])+p2[0]) lineCrossCount++; }
- if (Math.min(p3[1], p4[1])<=pointer[1] && pointer[1]<=Math.max(p3[1], p4[1])){
- if (pointer[0] <= (pointer[1]-p3[1])*(p4[0]-p3[0])/(p4[1]-p3[1])+p3[0]) lineCrossCount++; }
- if (Math.min(p4[1], p1[1])<=pointer[1] && pointer[1]<=Math.max(p4[1], p1[1])){
- if (pointer[0] <= (pointer[1]-p4[1])*(p1[0]-p4[0])/(p1[1]-p4[1])+p4[0]) lineCrossCount++; }
- if (lineCrossCount % 2 != 0) { // inside the slice of it crosses an odd number of edges
- var showSelected = this.byCategory? pieDataSet[index] : this._piechartData[index];
- if (changeSelectedVariables){
- // for when a bar is selected - not just hovered over
- sameAsCurrent = (this._currSelected)?
- (showSelected[Object.keys(showSelected)[0]]==this._currSelected![Object.keys(showSelected)[0]]
- && showSelected[Object.keys(showSelected)[1]]==this._currSelected![Object.keys(showSelected)[1]])
- :
- this._currSelected===showSelected;
- this._currSelected = sameAsCurrent? undefined: showSelected;
- this.selectedData = sameAsCurrent? undefined: d;
- }
- else this.hoverOverData = d;
- return true;
- }
- return false;
- });
- if (changeSelectedVariables){
- if (sameAsCurrent!) this.curSliceSelected = undefined;
- else this.curSliceSelected = selected;
+ // draw an imaginary horizontal line from the pointer to see how many times it crosses a slice edge
+ var lineCrossCount = 0;
+ // if for all 4 lines
+ if (Math.min(p1[1], p2[1]) <= pointer[1] && pointer[1] <= Math.max(p1[1], p2[1])) {
+ // within y bounds
+ if (pointer[0] <= ((pointer[1] - p1[1]) * (p2[0] - p1[0])) / (p2[1] - p1[1]) + p1[0]) lineCrossCount++;
+ } // intercepts x
+ if (Math.min(p2[1], p3[1]) <= pointer[1] && pointer[1] <= Math.max(p2[1], p3[1])) {
+ if (pointer[0] <= ((pointer[1] - p2[1]) * (p3[0] - p2[0])) / (p3[1] - p2[1]) + p2[0]) lineCrossCount++;
}
- }
+ if (Math.min(p3[1], p4[1]) <= pointer[1] && pointer[1] <= Math.max(p3[1], p4[1])) {
+ if (pointer[0] <= ((pointer[1] - p3[1]) * (p4[0] - p3[0])) / (p4[1] - p3[1]) + p3[0]) lineCrossCount++;
+ }
+ if (Math.min(p4[1], p1[1]) <= pointer[1] && pointer[1] <= Math.max(p4[1], p1[1])) {
+ if (pointer[0] <= ((pointer[1] - p4[1]) * (p1[0] - p4[0])) / (p1[1] - p4[1]) + p4[0]) lineCrossCount++;
+ }
+ if (lineCrossCount % 2 != 0) {
+ // inside the slice of it crosses an odd number of edges
+ var showSelected = this.byCategory ? pieDataSet[index] : this._piechartData[index];
+ if (changeSelectedVariables) {
+ // for when a bar is selected - not just hovered over
+ sameAsCurrent = this._currSelected
+ ? showSelected[Object.keys(showSelected)[0]] == this._currSelected![Object.keys(showSelected)[0]] && showSelected[Object.keys(showSelected)[1]] == this._currSelected![Object.keys(showSelected)[1]]
+ : this._currSelected === showSelected;
+ this._currSelected = sameAsCurrent ? undefined : showSelected;
+ this.selectedData = sameAsCurrent ? undefined : d;
+ } else this.hoverOverData = d;
+ return true;
+ }
+ return false;
+ });
+ if (changeSelectedVariables) {
+ if (sameAsCurrent!) this.curSliceSelected = undefined;
+ else this.curSliceSelected = selected;
+ }
+ };
// draws the pie chart
drawChart = (dataSet: any, width: number, height: number) => {
d3.select(this._piechartRef.current).select('svg').remove();
d3.select(this._piechartRef.current).select('.tooltip').remove();
-
- var percentField = Object.keys(dataSet[0])[0]
- var descriptionField = Object.keys(dataSet[0])[1]!
- var radius = Math.min(width, height-this.props.margin.top-this.props.margin.bottom) /2
+
+ var percentField = Object.keys(dataSet[0])[0];
+ var descriptionField = Object.keys(dataSet[0])[1]!;
+ var radius = Math.min(width, height - this.props.margin.top - this.props.margin.bottom) / 2;
// converts data into Objects
var data = this.data(dataSet);
- var pieDataSet = dataSet.filter((d: { [x: string]: unknown; }) => {
+ var pieDataSet = dataSet.filter((d: { [x: string]: unknown }) => {
var valid = true;
Object.keys(dataSet[0]).map(key => {
if (!d[key] || Number.isNaN(d[key])) valid = false;
- })
+ });
return valid;
});
- if (this.byCategory){
- let uniqueCategories = [...new Set(data)]
+ if (this.byCategory) {
+ let uniqueCategories = [...new Set(data)];
var pieStringDataSet: { frequency: number }[] = [];
- for (let i=0; i<uniqueCategories.length; i++){
- pieStringDataSet.push({frequency: 0, [percentField]: uniqueCategories[i]})
+ for (let i = 0; i < uniqueCategories.length; i++) {
+ pieStringDataSet.push({ frequency: 0, [percentField]: uniqueCategories[i] });
}
- for (let i=0; i<data.length; i++){
- let sliceData = pieStringDataSet.filter((each: any) => each[percentField]==data[i])
+ for (let i = 0; i < data.length; i++) {
+ let sliceData = pieStringDataSet.filter((each: any) => each[percentField] == data[i]);
sliceData[0].frequency = sliceData[0].frequency + 1;
}
- pieDataSet = pieStringDataSet
- percentField = Object.keys(pieDataSet[0])[0]
- descriptionField = Object.keys(pieDataSet[0])[1]!
- data = this.data(pieStringDataSet)
+ pieDataSet = pieStringDataSet;
+ percentField = Object.keys(pieDataSet[0])[0];
+ descriptionField = Object.keys(pieDataSet[0])[1]!;
+ data = this.data(pieStringDataSet);
}
- var trackDuplicates : {[key: string]: any} = {};
- data.forEach((eachData: any) => !trackDuplicates[eachData]? trackDuplicates[eachData] = 0: null)
+ var trackDuplicates: { [key: string]: any } = {};
+ data.forEach((eachData: any) => (!trackDuplicates[eachData] ? (trackDuplicates[eachData] = 0) : null));
// initial chart
var svg = (this._piechartSvg = d3
.select(this._piechartRef.current)
- .append("svg")
- .attr("class", "graph")
- .attr("width", width + this.props.margin.right + this.props.margin.left)
- .attr("height", height + this.props.margin.top + this.props.margin.bottom)
- .append("g"));
- let g = svg.append("g")
- .attr("transform",
- "translate(" + (width/2 + this.props.margin.left) + "," + height/2 + ")");
+ .append('svg')
+ .attr('class', 'graph')
+ .attr('width', width + this.props.margin.right + this.props.margin.left)
+ .attr('height', height + this.props.margin.top + this.props.margin.bottom)
+ .append('g'));
+ let g = svg.append('g').attr('transform', 'translate(' + (width / 2 + this.props.margin.left) + ',' + height / 2 + ')');
var pie = d3.pie();
- var arc = d3.arc()
- .innerRadius(0)
- .outerRadius(radius);
+ var arc = d3.arc().innerRadius(0).outerRadius(radius);
// click/hover
const onPointClick = action((e: any) => this.highlightSelectedSlice(true, svg, arc, radius, d3.pointer(e), pieDataSet));
const onHover = action((e: any) => {
- const selected = this.highlightSelectedSlice(false, svg, arc, radius, d3.pointer(e), pieDataSet)
+ const selected = this.highlightSelectedSlice(false, svg, arc, radius, d3.pointer(e), pieDataSet);
updateHighlights();
- })
+ });
const mouseOut = action((e: any) => {
this.hoverOverData = undefined;
updateHighlights();
- })
+ });
const updateHighlights = () => {
const hoverOverSlice = this.hoverOverData;
const selectedData = this.selectedData;
- svg.selectAll('path').attr("class", function(d: any) {
- return ((selectedData && d.startAngle==selectedData.startAngle && d.endAngle==selectedData.endAngle)
- || ((hoverOverSlice && d.startAngle==hoverOverSlice.startAngle && d.endAngle==hoverOverSlice.endAngle)))? 'slice hover' : 'slice'; })
- }
+ svg.selectAll('path').attr('class', function (d: any) {
+ return (selectedData && d.startAngle == selectedData.startAngle && d.endAngle == selectedData.endAngle) || (hoverOverSlice && d.startAngle == hoverOverSlice.startAngle && d.endAngle == hoverOverSlice.endAngle)
+ ? 'slice hover'
+ : 'slice';
+ });
+ };
// drawing the slices
var selected = this.selectedData;
- var arcs = g.selectAll("arc")
- .data(pie(data))
- .enter()
- .append("g")
- arcs.append("path")
- .attr("fill", (d, i)=>{
- var possibleDataPoints = pieDataSet.filter((each: { [x: string]: any | { valueOf(): number; }; }) => {
+ var arcs = g.selectAll('arc').data(pie(data)).enter().append('g');
+ arcs.append('path')
+ .attr('fill', (d, i) => {
+ var possibleDataPoints = pieDataSet.filter((each: { [x: string]: any | { valueOf(): number } }) => {
try {
- return Number(each[percentField].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''))==Number(d.data)
+ return Number(each[percentField].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')) == Number(d.data);
} catch (error) {
- return each[percentField]==d.data
- }})
+ return each[percentField] == d.data;
+ }
+ });
var dataPoint;
- if (possibleDataPoints.length==1) dataPoint = possibleDataPoints[0];
- else{
- dataPoint = possibleDataPoints[trackDuplicates[d.data.toString()]]
+ if (possibleDataPoints.length == 1) dataPoint = possibleDataPoints[0];
+ else {
+ dataPoint = possibleDataPoints[trackDuplicates[d.data.toString()]];
trackDuplicates[d.data.toString()] = trackDuplicates[d.data.toString()] + 1;
}
var sliceColor;
- if (dataPoint){
+ if (dataPoint) {
var accessByName = dataPoint[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '');
var sliceColors = StrListCast(this.props.layoutDoc.pieSliceColors).map(each => each.split('::'));
- sliceColors.map(each => {if (each[0]==StrCast(accessByName)) sliceColor = each[1]});
+ sliceColors.map(each => {
+ if (each[0] == StrCast(accessByName)) sliceColor = each[1];
+ });
}
- return sliceColor? StrCast(sliceColor) : d3.schemeSet3[i]? d3.schemeSet3[i]: d3.schemeSet3[i%(d3.schemeSet3.length)] })
- .attr("class", selected?
- function(d) {
- return (selected && d.startAngle==selected.startAngle && d.endAngle==selected.endAngle)? 'slice hover' : 'slice';
- }: function(d) {return 'slice'})
+ return sliceColor ? StrCast(sliceColor) : d3.schemeSet3[i] ? d3.schemeSet3[i] : d3.schemeSet3[i % d3.schemeSet3.length];
+ })
+ .attr(
+ 'class',
+ selected
+ ? function (d) {
+ return selected && d.startAngle == selected.startAngle && d.endAngle == selected.endAngle ? 'slice hover' : 'slice';
+ }
+ : function (d) {
+ return 'slice';
+ }
+ )
.attr('d', arc)
.on('click', onPointClick)
.on('mouseover', onHover)
@@ -282,99 +294,106 @@ export class PieChart extends React.Component<PieChartProps> {
// adding labels
trackDuplicates = {};
- data.forEach((eachData: any) => !trackDuplicates[eachData]? trackDuplicates[eachData] = 0: null)
- arcs.append("text")
- .attr("transform",function(d){
- var centroid = arc.centroid(d as unknown as d3.DefaultArcObject)
- var heightOffset = (centroid[1]/radius) * Math.abs(centroid[1])
- return "translate("+ (centroid[0]+centroid[0]/(radius*.02)) + "," + (centroid[1]+heightOffset) + ")"; })
- .attr("text-anchor", "middle")
- .text(function(d){
- var possibleDataPoints = pieDataSet.filter((each: { [x: string]: any | { valueOf(): number; }; }) => {
+ data.forEach((eachData: any) => (!trackDuplicates[eachData] ? (trackDuplicates[eachData] = 0) : null));
+ arcs.append('text')
+ .attr('transform', function (d) {
+ var centroid = arc.centroid(d as unknown as d3.DefaultArcObject);
+ var heightOffset = (centroid[1] / radius) * Math.abs(centroid[1]);
+ return 'translate(' + (centroid[0] + centroid[0] / (radius * 0.02)) + ',' + (centroid[1] + heightOffset) + ')';
+ })
+ .attr('text-anchor', 'middle')
+ .text(function (d) {
+ var possibleDataPoints = pieDataSet.filter((each: { [x: string]: any | { valueOf(): number } }) => {
try {
- return Number(each[percentField].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''))==Number(d.data)
+ return Number(each[percentField].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')) == Number(d.data);
} catch (error) {
- return each[percentField]==d.data
- }})
+ return each[percentField] == d.data;
+ }
+ });
var dataPoint;
- if (possibleDataPoints.length==1) dataPoint = possibleDataPoints[0];
- else{
- dataPoint = possibleDataPoints[trackDuplicates[d.data.toString()]]
+ if (possibleDataPoints.length == 1) dataPoint = possibleDataPoints[0];
+ else {
+ dataPoint = possibleDataPoints[trackDuplicates[d.data.toString()]];
trackDuplicates[d.data.toString()] = trackDuplicates[d.data.toString()] + 1;
}
- return dataPoint? dataPoint[percentField]! + (!descriptionField? '' : (' - ' + dataPoint[descriptionField]))! : ''})
+ return dataPoint ? dataPoint[percentField]! + (!descriptionField ? '' : ' - ' + dataPoint[descriptionField])! : '';
+ });
};
@action changeSelectedColor = (color: string) => {
- this.curSliceSelected.attr("fill", color);
- var sliceName = this._currSelected[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '')
-
- const sliceColors = Cast(this.props.layoutDoc.pieSliceColors, listSpec("string"), null);
- sliceColors.map(each => { if (each.split('::')[0] == sliceName) sliceColors.splice(sliceColors.indexOf(each), 1) });
+ this.curSliceSelected.attr('fill', color);
+ var sliceName = this._currSelected[this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '');
+
+ const sliceColors = Cast(this.props.layoutDoc.pieSliceColors, listSpec('string'), null);
+ sliceColors.map(each => {
+ if (each.split('::')[0] == sliceName) sliceColors.splice(sliceColors.indexOf(each), 1);
+ });
sliceColors.push(StrCast(sliceName + '::' + color));
};
render() {
this.componentDidMount();
- var titleAccessor: any='';
- if (this.props.axes.length==2) titleAccessor = 'pieChart-title-'+this.props.axes[0]+'-'+this.props.axes[1];
- else if (this.props.axes.length>0) titleAccessor = 'pieChart-title-'+this.props.axes[0];
+ var titleAccessor: any = '';
+ if (this.props.axes.length == 2) titleAccessor = 'dataViz_title_pieChart_' + this.props.axes[0] + '-' + this.props.axes[1];
+ else if (this.props.axes.length > 0) titleAccessor = 'dataViz_title_pieChart_' + this.props.axes[0];
if (!this.props.layoutDoc[titleAccessor]) this.props.layoutDoc[titleAccessor] = this.defaultGraphTitle;
if (!this.props.layoutDoc.pieSliceColors) this.props.layoutDoc.pieSliceColors = new List<string>();
var selected: string;
- var curSelectedSliceName;
- if (this._currSelected){
- curSelectedSliceName = StrCast(this._currSelected![this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''))
+ var curSelectedSliceName = '';
+ if (this._currSelected) {
+ curSelectedSliceName = StrCast(this._currSelected![this.props.axes[0]].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, ''));
selected = '{ ';
Object.keys(this._currSelected).map(key => {
- key!=''? selected += key + ': ' + this._currSelected[key] + ', ': '';
- })
- selected = selected.substring(0, selected.length-2);
+ key != '' ? (selected += key + ': ' + this._currSelected[key] + ', ') : '';
+ });
+ selected = selected.substring(0, selected.length - 2);
selected += ' }';
- }
- else selected = 'none';
+ } else selected = 'none';
var selectedSliceColor;
var sliceColors = StrListCast(this.props.layoutDoc.pieSliceColors).map(each => each.split('::'));
- sliceColors.map(each => {if (each[0]==curSelectedSliceName!) selectedSliceColor = each[1]});
+ sliceColors.map(each => {
+ if (each[0] == curSelectedSliceName!) selectedSliceColor = each[1];
+ });
- if (this._piechartData.length>0){
- return (
- this.props.axes.length >= 1 ? (
+ if (this._piechartData.length > 0) {
+ return this.props.axes.length >= 1 ? (
<div className="chart-container">
- <div className="graph-title">
+ <div className="graph-title">
<EditableText
val={StrCast(this.props.layoutDoc[titleAccessor])}
- setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
- color={"black"}
+ setVal={undoable(
+ action(val => (this.props.layoutDoc[titleAccessor] = val as string)),
+ 'Change Graph Title'
+ )}
+ color={'black'}
size={Size.LARGE}
fillWidth
/>
</div>
<div ref={this._piechartRef} />
- {selected != 'none' ?
+ {selected != 'none' ? (
<div className={'selected-data'}>
Selected: {selected}
&nbsp; &nbsp;
<ColorPicker
- tooltip={'Change Slice Color'}
- type={Type.SEC}
- icon={<FaFillDrip/>}
- selectedColor={selectedSliceColor? selectedSliceColor : this.curSliceSelected.attr("fill")}
- setSelectedColor={undoable (color => this.changeSelectedColor(color), "Change Selected Slice Color")}
+ tooltip={'Change Slice Color'}
+ type={Type.SEC}
+ icon={<FaFillDrip />}
+ selectedColor={selectedSliceColor ? selectedSliceColor : this.curSliceSelected.attr('fill')}
+ setFinalColor={undoable(color => this.changeSelectedColor(color), 'Change Selected Slice Color')}
+ setSelectedColor={undoable(color => this.changeSelectedColor(color), 'Change Selected Slice Color')}
size={Size.XSMALL}
/>
</div>
- : null}
+ ) : null}
</div>
- ) : <span className="chart-container"> {'first use table view to select a column to graph'}</span>
+ ) : (
+ <span className="chart-container"> {'first use table view to select a column to graph'}</span>
+ );
+ } else
+ return (
+ // when it is a brushed table and the incoming table doesn't have any rows selected
+ <div className="chart-container">Selected rows of data from the incoming DataVizBox to display.</div>
);
- }
- else return (
- // when it is a brushed table and the incoming table doesn't have any rows selected
- <div className='chart-container'>
- Selected rows of data from the incoming DataVizBox to display.
- </div>
- )
}
-
-} \ No newline at end of file
+}
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index f56d34fa6..5579d6d80 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -1,4 +1,4 @@
-import { action, computed, } from 'mobx';
+import { action, computed } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Doc, Field, StrListCast } from '../../../../../fields/Doc';
@@ -31,44 +31,45 @@ interface TableBoxProps {
@observer
export class TableBox extends React.Component<TableBoxProps> {
-
// filters all data to just display selected data if brushed (created from an incoming link)
@computed get _tableData() {
if (this.incomingLinks.length! <= 0) return this.props.pairs;
- var guids = StrListCast(this.props.layoutDoc.rowGuids);
- return this.props.pairs?.filter(pair => this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)]))
+ var guids = StrListCast(this.props.layoutDoc.dataViz_rowGuids);
+ return this.props.pairs?.filter(pair => this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)]));
}
@computed get incomingLinks() {
return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
.filter(link => {
- return link.link_anchor_1 == this.props.rootDoc.draggedFrom}) // get links where this chart doc is the target of the link
+ return link.link_anchor_1 == this.props.rootDoc.draggedFrom;
+ }) // get links where this chart doc is the target of the link
.map(link => DocCast(link.link_anchor_1)); // then return the source of the link
}
@computed get columns() {
- if (!this.props.layoutDoc.rowGuids) this.props.layoutDoc.rowGuids = new List<string>();
- const guids = Cast(this.props.layoutDoc.rowGuids, listSpec("string"), null);
- if (guids.length==0) this.props.pairs.map(row => guids.push(Utils.GenerateGuid()));
- return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header!='' && header!=undefined) : [];
+ if (!this.props.layoutDoc.dataViz_rowGuids) this.props.layoutDoc.dataViz_rowGuids = new List<string>();
+ const guids = Cast(this.props.layoutDoc.dataViz_rowGuids, listSpec('string'), null);
+ if (guids.length == 0) this.props.pairs.map(row => guids.push(Utils.GenerateGuid()));
+ return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header != '' && header != undefined) : [];
}
// updates the 'selected' field to no longer include rows that aren't in the table
filterSelectedRowsDown() {
- if (!this.props.layoutDoc.selected) this.props.layoutDoc.selected = new List<string>();
- const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
- const incomingSelected = this.incomingLinks.length? StrListCast(this.incomingLinks[0].selected) : undefined;
- if (incomingSelected){
+ if (!this.props.layoutDoc.dataViz_selectedRows) this.props.layoutDoc.dataViz_selectedRows = new List<string>();
+ const selected = Cast(this.props.layoutDoc.dataViz_selectedRows, listSpec('string'), null);
+ const incomingSelected = this.incomingLinks.length ? StrListCast(this.incomingLinks[0].dataViz_selectedRows) : undefined;
+ if (incomingSelected) {
selected.map(guid => {
- if (!incomingSelected.includes(guid)) selected.splice(selected.indexOf(guid), 1)}); // filters through selected to remove guids that were removed in the incoming data
+ if (!incomingSelected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
+ }); // filters through selected to remove guids that were removed in the incoming data
}
}
render() {
this.filterSelectedRowsDown();
- if (this._tableData.length>0){
+ if (this._tableData.length > 0) {
return (
- <div className="table-container" style={{height: this.props.height}}>
+ <div className="table-container" style={{ height: this.props.height }}>
<table className="table">
<thead>
<tr className="table-row">
@@ -83,7 +84,8 @@ export class TableBox extends React.Component<TableBoxProps> {
style={{
color: this.props.axes.slice().reverse().lastElement() === col ? 'darkgreen' : this.props.axes.lastElement() === col ? 'darkred' : undefined,
background: this.props.axes.slice().reverse().lastElement() === col ? '#E3fbdb' : this.props.axes.lastElement() === col ? '#Fbdbdb' : undefined,
- fontWeight: 'bolder', border: '3px solid black'
+ fontWeight: 'bolder',
+ border: '3px solid black',
}}
onPointerDown={e => {
const downX = e.clientX;
@@ -91,12 +93,13 @@ export class TableBox extends React.Component<TableBoxProps> {
setupMoveUpEvents(
{},
e,
- e => { // dragging off a column to create a brushed DataVizBox
+ e => {
+ // dragging off a column to create a brushed DataVizBox
const sourceAnchorCreator = () => this.props.docView?.()!.rootDoc!;
const targetCreator = (annotationOn: Doc | undefined) => {
const embedding = Doc.MakeEmbedding(this.props.docView?.()!.rootDoc!);
- embedding._dataVizView = DataVizView.TABLE;
- embedding._data_vizAxes = new List<string>([col, col]);
+ embedding._dataViz = DataVizView.TABLE;
+ embedding._dataViz_axes = new List<string>([col, col]);
embedding._draggedFrom = this.props.docView?.()!.rootDoc!;
embedding.annotationOn = annotationOn; //this.props.docView?.()!.rootDoc!;
embedding.histogramBarColors = Field.Copy(this.props.layoutDoc.histogramBarColors);
@@ -142,25 +145,33 @@ export class TableBox extends React.Component<TableBoxProps> {
<tbody>
{this._tableData?.map((p, i) => {
var containsData = false;
- var guid = StrListCast(this.props.layoutDoc.rowGuids)![this.props.pairs.indexOf(p)]
- this.columns.map(col => {if (p[col]!='' && p[col]!=null && p[col]!=undefined) containsData = true})
- if (containsData){
+ var guid = StrListCast(this.props.layoutDoc.dataViz_rowGuids)![this.props.pairs.indexOf(p)];
+ this.columns.map(col => {
+ if (p[col] != '' && p[col] != null && p[col] != undefined) containsData = true;
+ });
+ if (containsData) {
return (
- <tr key={i} className="table-row" onClick={action(e => {
+ <tr
+ key={i}
+ className="table-row"
+ onClick={action(e => {
// selecting a row
- const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
+ const selected = Cast(this.props.layoutDoc.dataViz_selectedRows, listSpec('string'), null);
if (selected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
else {
- selected.push(guid)};
- })} style={{ background: StrListCast(this.props.layoutDoc.selected).includes(guid) ? 'lightgrey' : '', width: '110%' }}>
+ selected.push(guid);
+ }
+ })}
+ style={{ background: StrListCast(this.props.layoutDoc.dataViz_selectedRows).includes(guid) ? 'lightgrey' : '', width: '110%' }}>
{this.columns.map(col => {
- // each cell
- var colSelected = this.props.axes[0]==col || this.props.axes[1]==col;
- return (
- <td key={this.columns.indexOf(col)} style={{border: colSelected? '3px solid black' : '1px solid black', fontWeight: colSelected? 'bolder' : 'normal'}}>
+ // each cell
+ var colSelected = this.props.axes[0] == col || this.props.axes[1] == col;
+ return (
+ <td key={this.columns.indexOf(col)} style={{ border: colSelected ? '3px solid black' : '1px solid black', fontWeight: colSelected ? 'bolder' : 'normal' }}>
{p[col]}
</td>
- )})}
+ );
+ })}
</tr>
);
}
@@ -169,12 +180,10 @@ export class TableBox extends React.Component<TableBoxProps> {
</table>
</div>
);
- }
- else return (
- // when it is a brushed table and the incoming table doesn't have any rows selected
- <div className='chart-container'>
- Selected rows of data from the incoming DataVizBox to display.
- </div>
- )
+ } else
+ return (
+ // when it is a brushed table and the incoming table doesn't have any rows selected
+ <div className="chart-container">Selected rows of data from the incoming DataVizBox to display.</div>
+ );
}
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 90fb55290..c5dead708 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -113,7 +113,7 @@ export interface DocComponentView {
getAnchor?: (addAsAnnotation: boolean, pinData?: PinProps) => Doc; // returns an Anchor Doc that represents the current state of the doc's componentview (e.g., the current playhead location of a an audio/video box)
restoreView?: (viewSpec: Doc) => boolean;
scrollPreview?: (docView: DocumentView, doc: Doc, focusSpeed: number, options: DocFocusOptions) => Opt<number>; // returns the duration of the focus
- brushView?: (view: { width: number; height: number; panX: number; panY: number }) => void;
+ brushView?: (view: { width: number; height: number; panX: number; panY: number }, transTime: number) => void;
getView?: (doc: Doc) => Promise<Opt<DocumentView>>; // returns a nested DocumentView for the specified doc or undefined
addDocTab?: (doc: Doc, where: OpenWhere) => boolean; // determines how to add a document - used in following links to open the target ina local lightbox
addDocument?: (doc: Doc | Doc[], annotationKey?: string) => boolean; // add a document (used only by collections)
@@ -1095,6 +1095,8 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
pointerEvents: this.rootDoc.ignoreClick ? 'none' : this.isContentActive() || this.props.isDocumentActive?.() ? 'all' : undefined,
minWidth: 50 * ffscale(),
maxHeight: `max(100%, ${20 * ffscale()}px)`,
+ background: StrCast(this.layoutDoc._backgroundColor, 'rgba(0,0,0,0.2)'),
+ color: lightOrDark(StrCast(this.layoutDoc._backgroundColor, 'black')),
}}>
<FormattedTextBox
{...this.props}
@@ -1112,10 +1114,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
</div>
);
const targetDoc = showTitle?.startsWith('_') ? this.layoutDoc : this.rootDoc;
- const background = StrCast(
- SharingManager.Instance.users.find(u => u.user.email === this.dataDoc.author)?.sharingDoc.headingColor,
- Doc.UserDoc().layout_showTitle && [DocumentType.RTF, DocumentType.COL].includes(this.rootDoc.type as any) ? StrCast(Doc.SharingDoc().headingColor) : SettingsManager.Instance.userVariantColor
- );
+ const background = StrCast(SharingManager.Instance.users.find(u => u.user.email === this.dataDoc.author)?.sharingDoc.headingColor, StrCast(Doc.SharingDoc().headingColor, SettingsManager.Instance.userVariantColor));
const sidebarWidthPercent = +StrCast(this.layoutDoc.layout_sidebarWidthPercent).replace('%', '');
const titleView = !showTitle ? null : (
<div
@@ -1204,7 +1203,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
* @returns a function that will wrap a JSX animation element wrapping any JSX element
*/
public static AnimationEffect(renderDoc: JSX.Element, presEffectDoc: Opt<Doc>, root: Doc) {
- const dir = presEffectDoc?.presEffectDirection ?? presEffectDoc?.followLinkAnimDirection;
+ const dir = presEffectDoc?.presentation_effectDirection ?? presEffectDoc?.followLinkAnimDirection;
const effectProps = {
left: dir === PresEffectDirection.Left,
right: dir === PresEffectDirection.Right,
@@ -1212,10 +1211,10 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
bottom: dir === PresEffectDirection.Bottom,
opposite: true,
delay: 0,
- duration: Cast(presEffectDoc?.presTransition, 'number', Cast(presEffectDoc?.followLinkTransitionTime, 'number', null)),
+ duration: Cast(presEffectDoc?.presentation_transition, 'number', Cast(presEffectDoc?.followLinkTransitionTime, 'number', null)),
};
//prettier-ignore
- switch (StrCast(presEffectDoc?.presEffect, StrCast(presEffectDoc?.followLinkAnimEffect))) {
+ switch (StrCast(presEffectDoc?.presentation_effect, StrCast(presEffectDoc?.followLinkAnimEffect))) {
default:
case PresEffect.None: return renderDoc;
case PresEffect.Zoom: return <Zoom {...effectProps}>{renderDoc}</Zoom>;
@@ -1543,7 +1542,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
<div className="webBox-textHighlight">
<ObserverJsxParser autoCloseVoidElements={true} key={42} onError={(e: any) => console.log('PARSE error', e)} renderInWrapper={false} jsx={StrCast(this.textHtmlOverlay)} />
</div>,
- { presEffect: this.htmlOverlayEffect ?? 'Zoom' } as any as Doc,
+ { presentation_effect: this.htmlOverlayEffect ?? 'Zoom' } as any as Doc,
this.rootDoc
)}{' '}
</Fade>
diff --git a/src/client/views/nodes/FontIconBox/FontIconBox.tsx b/src/client/views/nodes/FontIconBox/FontIconBox.tsx
index 1b2209224..bf3c79cf9 100644
--- a/src/client/views/nodes/FontIconBox/FontIconBox.tsx
+++ b/src/client/views/nodes/FontIconBox/FontIconBox.tsx
@@ -267,7 +267,7 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
return ScriptCast(this.rootDoc.script);
}
- colorBatch:UndoManager.Batch|undefined;
+ colorBatch: UndoManager.Batch | undefined;
/**
* Color button
*/
@@ -285,7 +285,7 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
setFinalColor={value => {
this.colorScript?.script.run({ this: this.layoutDoc, self: this.rootDoc, value: value, _readOnly_: false });
this.colorBatch?.end();
- this.colorBatch= undefined;
+ this.colorBatch = undefined;
}}
selectedColor={curColor}
type={Type.PRIM}
diff --git a/src/client/views/nodes/FunctionPlotBox.tsx b/src/client/views/nodes/FunctionPlotBox.tsx
index 61711417f..40f48dafe 100644
--- a/src/client/views/nodes/FunctionPlotBox.tsx
+++ b/src/client/views/nodes/FunctionPlotBox.tsx
@@ -48,8 +48,8 @@ export class FunctionPlotBox extends ViewBoxAnnotatableComponent<FieldViewProps>
annotationOn: this.rootDoc,
});
PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: { ...(pinProps?.pinData ?? {}), datarange: true } }, this.rootDoc);
- anchor.presXRange = new List<number>(Array.from(this._plot.options.xAxis.domain));
- anchor.presYRange = new List<number>(Array.from(this._plot.options.yAxis.domain));
+ anchor.config_xRange = new List<number>(Array.from(this._plot.options.xAxis.domain));
+ anchor.config_yRange = new List<number>(Array.from(this._plot.options.yAxis.domain));
if (addAsAnnotation) this.addDocument(anchor);
return anchor;
};
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index d763753a5..c7ccd1ea0 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -22,7 +22,6 @@ import { DocumentType } from '../../documents/DocumentTypes';
import { Networking } from '../../Network';
import { DocumentManager } from '../../util/DocumentManager';
import { DragManager } from '../../util/DragManager';
-import { SnappingManager } from '../../util/SnappingManager';
import { undoBatch } from '../../util/UndoManager';
import { ContextMenu } from '../../views/ContextMenu';
import { CollectionFreeFormView } from '../collections/collectionFreeForm/CollectionFreeFormView';
@@ -80,10 +79,10 @@ export class ImageBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
this._getAnchor?.(this._savedAnnotations, false) ?? // use marquee anchor, otherwise, save zoom/pan as anchor
Docs.Create.ConfigDocument({
title: 'ImgAnchor:' + this.rootDoc.title,
- presPanX: NumCast(this.layoutDoc._freeform_panX),
- presPanY: NumCast(this.layoutDoc._freeform_panY),
- presViewScale: Cast(this.layoutDoc._freeform_scale, 'number', null),
- presTransition: 1000,
+ config_panX: NumCast(this.layoutDoc._freeform_panX),
+ config_panY: NumCast(this.layoutDoc._freeform_panY),
+ config_viewScale: Cast(this.layoutDoc._freeform_scale, 'number', null),
+ presentation_transition: 1000,
annotationOn: this.rootDoc,
});
if (anchor) {
@@ -295,7 +294,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
choosePath(url: URL) {
const lower = url.href.toLowerCase();
if (url.protocol === 'data') return url.href;
- if (url.href.indexOf(window.location.origin) === -1 && url.href.indexOf("dashblobstore") === -1) return Utils.CorsProxy(url.href);
+ if (url.href.indexOf(window.location.origin) === -1 && url.href.indexOf('dashblobstore') === -1) return Utils.CorsProxy(url.href);
if (!/\.(png|jpg|jpeg|gif|webp)$/.test(lower)) return `/assets/unknown-file-icon-hi.png`;
const ext = extname(url.href);
@@ -414,7 +413,8 @@ export class ImageBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
@computed get content() {
TraceMobx();
- const backAlpha = DashColor(this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor)).alpha();
+ const backColor = DashColor(this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor));
+ const backAlpha = backColor.red() === 0 && backColor.green() === 0 && backColor.blue() === 0 ? backColor.alpha() : 1;
const srcpath = this.layoutDoc.hideImage ? '' : this.paths[0];
const fadepath = this.layoutDoc.hideImage ? '' : this.paths.lastElement();
const { nativeWidth, nativeHeight, nativeOrientation } = this.nativeSize;
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index a6712a3db..673f711be 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -4,7 +4,7 @@ import { Doc, Field, FieldResult } from '../../../fields/Doc';
import { List } from '../../../fields/List';
import { RichTextField } from '../../../fields/RichTextField';
import { ComputedField, ScriptField } from '../../../fields/ScriptField';
-import { DocCast, NumCast } from '../../../fields/Types';
+import { DocCast } from '../../../fields/Types';
import { ImageField } from '../../../fields/URLField';
import { returnAll, returnAlways, returnTrue } from '../../../Utils';
import { Docs } from '../../documents/Documents';
@@ -13,6 +13,7 @@ import { CompiledScript, CompileScript, ScriptOptions } from '../../util/Scripti
import { undoBatch } from '../../util/UndoManager';
import { ContextMenu } from '../ContextMenu';
import { ContextMenuProps } from '../ContextMenuItem';
+import { DocumentIconContainer } from './DocumentIcon';
import { OpenWhere } from './DocumentView';
import { FieldView, FieldViewProps } from './FieldView';
import { FormattedTextBox } from './formattedText/FormattedTextBox';
@@ -20,10 +21,6 @@ import { ImageBox } from './ImageBox';
import './KeyValueBox.scss';
import { KeyValuePair } from './KeyValuePair';
import React = require('react');
-import { DocumentManager } from '../../util/DocumentManager';
-import { ScriptingGlobals } from '../../util/ScriptingGlobals';
-import { ScriptingRepl } from '../ScriptingRepl';
-import { DocumentIconContainer } from './DocumentIcon';
export type KVPScript = {
script: CompiledScript;
@@ -147,7 +144,15 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
const self = this;
const keys = Object.keys(ids).slice();
//for (const key of [...keys.filter(id => id !== 'layout' && !id.includes('_')).sort(), ...keys.filter(id => id === 'layout' || id.includes('_')).sort()]) {
- for (const key of keys.sort()) {
+ for (const key of keys.sort((a: string, b: string) => {
+ const a_ = a.split('_')[0];
+ const b_ = b.split('_')[0];
+ if (a_ < b_) return -1;
+ if (a_ > b_) return 1;
+ if (a === a_) return -1;
+ if (b === b_) return 1;
+ return a === b ? 0 : a < b ? -1 : 1;
+ })) {
rows.push(
<KeyValuePair
doc={realDoc}
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index 710d41471..efb949a47 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -18,7 +18,7 @@ export class LinkBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.props.setContentView?.(this);
}
render() {
- if (this.dataDoc.treeViewOpen === undefined) setTimeout(() => (this.dataDoc.treeViewOpen = true));
+ if (this.dataDoc.treeView_Open === undefined) setTimeout(() => (this.dataDoc.treeView_Open = true));
return (
<div className={`linkBox-container${this.props.isContentActive() ? '-interactive' : ''}`} style={{ background: this.props.styleProvider?.(this.layoutDoc, this.props, StyleProp.BackgroundColor) }}>
<ComparisonBox
diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx
index 4919ee94c..cf017d746 100644
--- a/src/client/views/nodes/MapBox/MapBox.tsx
+++ b/src/client/views/nodes/MapBox/MapBox.tsx
@@ -102,7 +102,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
}
private _setPreviewCursor: undefined | ((x: number, y: number, drag: boolean, hide: boolean) => void);
@computed get inlineTextAnnotations() {
- return this.allMapMarkers.filter(a => a.textInlineAnnotations);
+ return this.allMapMarkers.filter(a => a.text_inlineAnnotations);
}
@observable private _map: google.maps.Map = null as unknown as google.maps.Map;
diff --git a/src/client/views/nodes/MapBox/MapBox2.tsx b/src/client/views/nodes/MapBox/MapBox2.tsx
index a9154c5bb..b3ae8242d 100644
--- a/src/client/views/nodes/MapBox/MapBox2.tsx
+++ b/src/client/views/nodes/MapBox/MapBox2.tsx
@@ -100,7 +100,7 @@ export class MapBox2 extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
}
private _setPreviewCursor: undefined | ((x: number, y: number, drag: boolean, hide: boolean) => void);
@computed get inlineTextAnnotations() {
- return this.allMapMarkers.filter(a => a.textInlineAnnotations);
+ return this.allMapMarkers.filter(a => a.text_inlineAnnotations);
}
@observable private _map: google.maps.Map = null as unknown as google.maps.Map;
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index fd4c6366b..758b49655 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -213,7 +213,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
);
}
- brushView = (view: { width: number; height: number; panX: number; panY: number }) => this._pdfViewer?.brushView(view);
+ brushView = (view: { width: number; height: number; panX: number; panY: number }, transTime: number) => this._pdfViewer?.brushView(view, transTime);
sidebarAddDocTab = (doc: Doc, where: OpenWhere) => {
if (DocListCast(this.props.Document[this.props.fieldKey + '_sidebar']).includes(doc) && !this.SidebarShown) {
@@ -224,7 +224,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
};
focus = (anchor: Doc, options: DocFocusOptions) => {
this._initialScrollTarget = anchor;
- return this._pdfViewer?.scrollFocus(anchor, NumCast(anchor.y, NumCast(anchor.presViewScroll)), options);
+ return this._pdfViewer?.scrollFocus(anchor, NumCast(anchor.y, NumCast(anchor.config_scrollTop)), options);
};
getView = async (doc: Doc) => {
@@ -247,7 +247,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
const anchor = annoAnchor ?? docAnchor();
PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: { ...(pinProps?.pinData ?? {}), scrollable: true, pannable: true } }, this.rootDoc);
anchor.text = ele?.textContent ?? '';
- anchor.textHtml = ele?.innerHTML;
+ anchor.text_html = ele?.innerHTML;
if (addAsAnnotation || annoAnchor) {
this.addDocument(anchor);
}
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index f5df42161..febf8341e 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -51,7 +51,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
public static sidebarResizerWidth = 5;
static webStyleSheet = addStyleSheet();
private _setPreviewCursor: undefined | ((x: number, y: number, drag: boolean, hide: boolean) => void);
- private _setBrushViewer: undefined | ((view: { width: number; height: number; panX: number; panY: number }) => void);
+ private _setBrushViewer: undefined | ((view: { width: number; height: number; panX: number; panY: number }, transTime: number) => void);
private _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
private _outerRef: React.RefObject<HTMLDivElement> = React.createRef();
private _disposers: { [name: string]: IReactionDisposer } = {};
@@ -91,7 +91,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
return DocListCast(this.dataDoc[this.annotationKey]);
}
@computed get inlineTextAnnotations() {
- return this.allAnnotations.filter(a => a.textInlineAnnotations);
+ return this.allAnnotations.filter(a => a.text_inlineAnnotations);
}
@computed get webField() {
return Cast(this.rootDoc[this.props.fieldKey], WebField)?.url;
@@ -133,7 +133,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
(this._iframe?.contentWindow as any)?.find(searchString, false, bwd, true);
}
} catch (e) {
- console.log("WebBox search error", e)
+ console.log('WebBox search error', e);
}
return true;
};
@@ -281,8 +281,8 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
return this._savedAnnotations;
};
- setBrushViewer = (func?: (view: { width: number; height: number; panX: number; panY: number }) => void) => (this._setBrushViewer = func);
- brushView = (view: { width: number; height: number; panX: number; panY: number }) => this._setBrushViewer?.(view);
+ setBrushViewer = (func?: (view: { width: number; height: number; panX: number; panY: number }, transTime: number) => void) => (this._setBrushViewer = func);
+ brushView = (view: { width: number; height: number; panX: number; panY: number }, transTime: number) => this._setBrushViewer?.(view, transTime);
focus = (anchor: Doc, options: DocFocusOptions) => {
if (anchor !== this.rootDoc && this._outerRef.current) {
const windowHeight = this.props.PanelHeight() / (this.props.NativeDimScaling?.() || 1);
@@ -303,7 +303,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
getView = (doc: Doc) => {
if (Doc.AreProtosEqual(doc, this.rootDoc)) return new Promise<Opt<DocumentView>>(res => res(this.props.DocumentView?.()));
if (this.rootDoc.layout_fieldKey === 'layout_icon') this.props.DocumentView?.().iconify();
- const webUrl = WebCast(doc.presData)?.url;
+ const webUrl = WebCast(doc.config_data)?.url;
if (this._url && webUrl && webUrl.href !== this._url) this.setData(webUrl.href);
if (this._sidebarRef?.current?.makeDocUnfiltered(doc) && !this.SidebarShown) this.toggleSidebar(false);
return new Promise<Opt<DocumentView>>(res => DocumentManager.Instance.AddViewRenderedCb(doc, dv => res(dv)));
@@ -334,7 +334,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
});
PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: { ...(pinProps?.pinData ?? {}), scrollable: pinProps?.pinData ? true : false, pannable: true } }, this.rootDoc);
anchor.text = ele?.textContent ?? '';
- anchor.textHtml = ele?.innerHTML;
+ anchor.text_html = ele?.innerHTML;
//addAsAnnotation &&
this.addDocumentWrapper(anchor);
return anchor;
@@ -761,7 +761,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
}
addDocumentWrapper = (doc: Doc | Doc[], annotationKey?: string) => {
- (doc instanceof Doc ? [doc] : doc).forEach(doc => (doc.presData = new WebField(this._url)));
+ (doc instanceof Doc ? [doc] : doc).forEach(doc => (doc.config_data = new WebField(this._url)));
return this.addDocument(doc, annotationKey);
};
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 1dcc445e8..eea4f513e 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -417,7 +417,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
DocListCast(Doc.MyPublishedDocs.data).forEach(term => (tr = this.hyperlinkTerm(tr, term, newAutoLinks)));
tr = tr.setSelection(isNodeSel && false ? new NodeSelection(tr.doc.resolve(f)) : new TextSelection(tr.doc.resolve(f), tr.doc.resolve(t)));
this._editorView?.dispatch(tr);
- this.prepareForTyping();
+ // this.prepareForTyping();
}
oldAutoLinks.filter(oldLink => !newAutoLinks.has(oldLink) && oldLink.link_anchor_2 !== this.rootDoc).forEach(LinkManager.Instance.deleteLink);
};
@@ -730,7 +730,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
@undoBatch
showTargetTrail = (anchor: Doc) => {
- const trail = DocCast(anchor.presTrail);
+ const trail = DocCast(anchor.presentationTrail);
if (trail) {
Doc.ActivePresentation = trail;
this.props.addDocTab(trail, OpenWhere.replaceRight);
@@ -1237,7 +1237,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
this._disposers.selected = reaction(
() => this.props.isSelected(),
action(selected => {
- selected && this.prepareForTyping();
+ //selected && setTimeout(() => this.prepareForTyping());
if (FormattedTextBox._globalHighlights.has('Bold Text')) {
this.layoutDoc[DocCss] = this.layoutDoc[DocCss] + 1; // css change happens outside of mobx/react, so this will notify anyone interested in the layout that it has changed
}
@@ -1550,18 +1550,17 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
// add user mark for any first character that was typed since the user mark that gets set in KeyPress won't have been called yet.
prepareForTyping = () => {
- this._editorView?.dispatch(
- this._editorView?.state.tr.setStoredMarks([
- ...(this._editorView.state.storedMarks?.filter(mark => ![schema.marks.em, schema.marks.underline, schema.marks.pFontFamily, schema.marks.pFontSize, schema.marks.strong, schema.marks.pFontColor].includes(mark.type)) ?? []),
- ...[schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: Math.floor(Date.now() / 1000) })],
- ...(Doc.UserDoc().fontColor !== 'transparent' && Doc.UserDoc().fontColor ? [schema.mark(schema.marks.pFontColor, { color: StrCast(Doc.UserDoc().fontColor) })] : []),
- ...(Doc.UserDoc().fontStyle === 'italics' ? [schema.mark(schema.marks.em)] : []),
- ...(Doc.UserDoc().textDecoration === 'underline' ? [schema.mark(schema.marks.underline)] : []),
- ...(Doc.UserDoc().fontFamily ? [schema.mark(schema.marks.pFontFamily, { family: this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.FontFamily) })] : []),
- ...(Doc.UserDoc().fontSize ? [schema.mark(schema.marks.pFontSize, { fontSize: this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.FontSize) })] : []),
- ...(Doc.UserDoc().fontWeight === 'bold' ? [schema.mark(schema.marks.strong)] : []),
- ])
- );
+ if (!this._editorView) return;
+ const docDefaultMarks = [
+ ...(Doc.UserDoc().fontColor !== 'transparent' && Doc.UserDoc().fontColor ? [schema.mark(schema.marks.pFontColor, { color: StrCast(Doc.UserDoc().fontColor) })] : []),
+ ...(Doc.UserDoc().fontStyle === 'italics' ? [schema.mark(schema.marks.em)] : []),
+ ...(Doc.UserDoc().textDecoration === 'underline' ? [schema.mark(schema.marks.underline)] : []),
+ ...(Doc.UserDoc().fontFamily ? [schema.mark(schema.marks.pFontFamily, { family: this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.FontFamily) })] : []),
+ ...(Doc.UserDoc().fontSize ? [schema.mark(schema.marks.pFontSize, { fontSize: this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.FontSize) })] : []),
+ ...(Doc.UserDoc().fontWeight === 'bold' ? [schema.mark(schema.marks.strong)] : []),
+ ...[schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: Math.floor(Date.now() / 1000) })],
+ ];
+ this._editorView?.dispatch(this._editorView?.state.tr.setStoredMarks(docDefaultMarks));
};
@action
diff --git a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
index 112a0d87e..ec11079b4 100644
--- a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
+++ b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
@@ -334,7 +334,7 @@ export function buildKeymap<S extends Schema<any>>(schema: S, props: any, mapKey
//Command to create a blank space
bind('Space', (state: EditorState, dispatch: (tx: Transaction) => void) => {
- if (GetEffectiveAcl(props.DataDoc) != AclEdit && GetEffectiveAcl(props.DataDoc) != AclAugment && GetEffectiveAcl(props.DataDoc) != AclAdmin) return true;
+ if (props.DataDoc && GetEffectiveAcl(props.DataDoc) != AclEdit && GetEffectiveAcl(props.DataDoc) != AclAugment && GetEffectiveAcl(props.DataDoc) != AclAdmin) return true;
const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());
dispatch(splitMetadata(marks, state.tr));
return false;
diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index 7c3e4baad..9c46459b0 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -104,7 +104,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
_disposer: IReactionDisposer | undefined;
componentDidMount() {
this._disposer = reaction(
- () => SelectionManager.Views(),
+ () => SelectionManager.Views().slice(),
views => this.updateMenu(undefined, undefined, undefined)
);
}
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index aaedffc77..05f59d8fe 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -74,7 +74,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
constructor(props: any) {
super(props);
if (!PresBox.navigateToDocScript) {
- PresBox.navigateToDocScript = ScriptField.MakeFunction('navigateToDoc(self.presentationTargetDoc, self)')!;
+ PresBox.navigateToDocScript = ScriptField.MakeFunction('navigateToDoc(self.presentation_targetDoc, self)')!;
}
}
@@ -116,7 +116,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return DocListCast(this.rootDoc[this.presFieldKey]);
}
@computed get tagDocs() {
- return this.childDocs.map(doc => Cast(doc.presentationTargetDoc, Doc, null));
+ return this.childDocs.map(doc => Cast(doc.presentation_targetDoc, Doc, null));
}
@computed get itemIndex() {
return NumCast(this.rootDoc._itemIndex);
@@ -125,10 +125,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return DocCast(this.childDocs[NumCast(this.rootDoc._itemIndex)]);
}
@computed get targetDoc() {
- return Cast(this.activeItem?.presentationTargetDoc, Doc, null);
+ return Cast(this.activeItem?.presentation_targetDoc, Doc, null);
}
public static targetRenderedDoc = (doc: Doc) => {
- const targetDoc = Cast(doc?.presentationTargetDoc, Doc, null);
+ const targetDoc = Cast(doc?.presentation_targetDoc, Doc, null);
return targetDoc?.layout_unrendered ? DocCast(targetDoc.annotationOn) : targetDoc;
};
@computed get scrollable() {
@@ -149,7 +149,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get selectedDoc() {
return this.selectedDocumentView?.rootDoc;
}
- isActiveItemTarget = (layoutDoc: Doc) => this.activeItem?.presentationTargetDoc === layoutDoc;
+ isActiveItemTarget = (layoutDoc: Doc) => this.activeItem?.presentation_targetDoc === layoutDoc;
clearSelectedArray = () => this.selectedArray.clear();
addToSelectedArray = action((doc: Doc) => this.selectedArray.add(doc));
removeFromSelectedArray = action((doc: Doc) => this.selectedArray.delete(doc));
@@ -196,18 +196,18 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
this.turnOffEdit(true);
this._disposers.selection = reaction(
- () => SelectionManager.Views(),
+ () => SelectionManager.Views().slice(),
views => (!PresBox.Instance || views.some(view => view.props.Document === this.rootDoc)) && this.updateCurrentPresentation(),
{ fireImmediately: true }
);
this._disposers.editing = reaction(
- () => this.layoutDoc.presStatus === PresStatus.Edit,
+ () => this.layoutDoc.presentation_status === PresStatus.Edit,
editing => {
if (editing) {
this.childDocs.forEach(doc => {
- if (doc.presIndexed !== undefined) {
+ if (doc.presentation_indexed !== undefined) {
this.progressivizedItems(doc)?.forEach(indexedDoc => (indexedDoc.opacity = undefined));
- doc.presIndexed = Math.min(this.progressivizedItems(doc)?.length ?? 0, 1);
+ doc.presentation_indexed = Math.min(this.progressivizedItems(doc)?.length ?? 0, 1);
}
});
}
@@ -224,10 +224,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
_mediaTimer!: [NodeJS.Timeout, Doc];
// 'Play on next' for audio or video therefore first navigate to the audio/video before it should be played
startTempMedia = (targetDoc: Doc, activeItem: Doc) => {
- const duration: number = NumCast(activeItem.presEndTime) - NumCast(activeItem.presStartTime);
+ const duration: number = NumCast(activeItem.config_clipEnd) - NumCast(activeItem.config_clipStart);
if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as any)) {
const targMedia = DocumentManager.Instance.getDocumentView(targetDoc);
- targMedia?.ComponentView?.playFrom?.(NumCast(activeItem.presStartTime), NumCast(activeItem.presStartTime) + duration);
+ targMedia?.ComponentView?.playFrom?.(NumCast(activeItem.config_clipStart), NumCast(activeItem.config_clipStart) + duration);
}
};
@@ -251,12 +251,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
(nextSelected: number, force = false) =>
() => {
if (nextSelected < this.childDocs.length) {
- if (force || this.childDocs[nextSelected].groupWithUp) {
+ if (force || this.childDocs[nextSelected].presentation_groupWithUp) {
this.addToSelectedArray(this.childDocs[nextSelected]);
- const serial = nextSelected + 1 < this.childDocs.length && NumCast(this.childDocs[nextSelected + 1].groupWithUp) > 1;
+ const serial = nextSelected + 1 < this.childDocs.length && NumCast(this.childDocs[nextSelected + 1].presentation_groupWithUp) > 1;
if (serial) {
this.gotoDocument(nextSelected, this.activeItem, true, async () => {
- const waitTime = NumCast(this.activeItem.presDuration) - NumCast(this.activeItem.presTransition);
+ const waitTime = NumCast(this.activeItem.presentation_duration) - NumCast(this.activeItem.presentation_transition);
await new Promise<void>(res => setTimeout(() => res(), Math.max(0, waitTime)));
doGroupWithUp(nextSelected + 1)();
});
@@ -274,7 +274,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// docs within a slide target that will be progressively revealed
progressivizedItems = (doc: Doc) => {
const targetList = PresBox.targetRenderedDoc(doc);
- if (doc.presIndexed !== undefined && targetList) {
+ if (doc.presentation_indexed !== undefined && targetList) {
const listItems = (Cast(targetList[Doc.LayoutFieldKey(targetList)], listSpec(Doc), null)?.filter(d => d instanceof Doc) as Doc[]) ?? DocListCast(targetList[Doc.LayoutFieldKey(targetList) + '_annotations']);
return listItems.filter(doc => !doc.layout_unrendered);
}
@@ -283,7 +283,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@action
next = () => {
const progressiveReveal = (first: boolean) => {
- const presIndexed = Cast(this.activeItem?.presIndexed, 'number', null);
+ const presIndexed = Cast(this.activeItem?.presentation_indexed, 'number', null);
if (presIndexed !== undefined) {
const targetRenderedDoc = PresBox.targetRenderedDoc(this.activeItem);
targetRenderedDoc._dataTransition = 'all 1s';
@@ -296,8 +296,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const targetView = listItems && DocumentManager.Instance.getFirstDocumentView(listItemDoc);
Doc.linkFollowUnhighlight();
Doc.HighlightDoc(listItemDoc);
- listItemDoc.presEffect = this.activeItem.presBulletEffect;
- listItemDoc.presTransition = 500;
+ listItemDoc.presentation_effect = this.activeItem.presBulletEffect;
+ listItemDoc.presentation_transition = 500;
targetView?.setAnimEffect(listItemDoc, 500);
if (targetView?.docView && this.activeItem.presBulletExpand) {
targetView.docView._animateScalingTo = 1.2;
@@ -308,7 +308,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
});
}
listItemDoc.opacity = undefined;
- this.activeItem.presIndexed = presIndexed + 1;
+ this.activeItem.presentation_indexed = presIndexed + 1;
}
return true;
}
@@ -322,7 +322,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.nextSlide(curLast + 1 === this.childDocs.length ? (this.layoutDoc.presLoop ? 0 : curLast) : curLast + 1);
progressiveReveal(true); // shows first progressive document, but without a transition effect
} else {
- if (this.childDocs[this.itemIndex + 1] === undefined && (this.layoutDoc.presLoop || this.layoutDoc.presStatus === PresStatus.Edit)) {
+ if (this.childDocs[this.itemIndex + 1] === undefined && (this.layoutDoc.presLoop || this.layoutDoc.presentation_status === PresStatus.Edit)) {
// Case 2: Last slide and presLoop is toggled ON or it is in Edit mode
this.nextSlide(0);
progressiveReveal(true); // shows first progressive document, but without a transition effect
@@ -338,9 +338,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const activeItem: Doc = this.activeItem;
let prevSelected = this.itemIndex;
// Functionality for group with up
- let didZoom = activeItem.presMovement;
- for (; prevSelected > 0 && this.childDocs[Math.max(0, prevSelected - 1)].groupWithUp; prevSelected--) {
- didZoom = didZoom === 'none' ? this.childDocs[prevSelected].presMovement : didZoom;
+ let didZoom = activeItem.presentation_movement;
+ for (; prevSelected > 0 && this.childDocs[Math.max(0, prevSelected - 1)].presentation_groupWithUp; prevSelected--) {
+ didZoom = didZoom === 'none' ? this.childDocs[prevSelected].presentation_movement : didZoom;
}
if (activeItem && this.childDocs[this.itemIndex - 1] !== undefined) {
// Case 2: There are no other frames so it should go to the previous slide
@@ -361,20 +361,20 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
Doc.UnBrushAllDocs();
if (index >= 0 && index < this.childDocs.length) {
this.rootDoc._itemIndex = index;
- if (from?.mediaStopTriggerList && this.layoutDoc.presStatus !== PresStatus.Edit) {
+ if (from?.mediaStopTriggerList && this.layoutDoc.presentation_status !== PresStatus.Edit) {
DocListCast(from.mediaStopTriggerList).forEach(this.stopTempMedia);
}
- if (from?.mediaStop === 'auto' && this.layoutDoc.presStatus !== PresStatus.Edit) {
- this.stopTempMedia(from.presentationTargetDoc);
+ if (from?.mediaStop === 'auto' && this.layoutDoc.presentation_status !== PresStatus.Edit) {
+ this.stopTempMedia(from.presentation_targetDoc);
}
// If next slide is audio / video 'Play automatically' then the next slide should be played
- if (this.layoutDoc.presStatus !== PresStatus.Edit && (this.targetDoc.type === DocumentType.AUDIO || this.targetDoc.type === DocumentType.VID) && this.activeItem.mediaStart === 'auto') {
+ if (this.layoutDoc.presentation_status !== PresStatus.Edit && (this.targetDoc.type === DocumentType.AUDIO || this.targetDoc.type === DocumentType.VID) && this.activeItem.mediaStart === 'auto') {
this.startTempMedia(this.targetDoc, this.activeItem);
}
if (!group) this.clearSelectedArray();
this.childDocs[index] && this.addToSelectedArray(this.childDocs[index]); //Update selected array
this.turnOffEdit();
- this.navigateToActiveItem(finished); //Handles movement to element only when presTrail is list
+ this.navigateToActiveItem(finished); //Handles movement to element only when presentationTrail is list
this.doHideBeforeAfter(); //Handles hide after/before
}
});
@@ -398,33 +398,33 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@action
playAnnotation = (anno: AudioField) => {};
@action
- static restoreTargetDocView(bestTargetView: Opt<DocumentView>, activeItem: Doc, transTime: number, pinDocLayout: boolean = BoolCast(activeItem.presPinLayout), pinDataTypes?: pinDataTypes, targetDoc?: Doc) {
+ static restoreTargetDocView(bestTargetView: Opt<DocumentView>, activeItem: Doc, transTime: number, pinDocLayout: boolean = BoolCast(activeItem.config_pinLayout), pinDataTypes?: pinDataTypes, targetDoc?: Doc) {
const bestTarget = bestTargetView?.rootDoc ?? (targetDoc?.layout_unrendered ? DocCast(targetDoc?.annotationOn) : targetDoc);
if (!bestTarget) return;
let changed = false;
if (pinDocLayout) {
if (
- bestTarget.x !== NumCast(activeItem.presX, NumCast(bestTarget.x)) ||
- bestTarget.y !== NumCast(activeItem.presY, NumCast(bestTarget.y)) ||
- bestTarget.rotation !== NumCast(activeItem.presRotation, NumCast(bestTarget.rotation)) ||
- bestTarget.width !== NumCast(activeItem.presWidth, NumCast(bestTarget.width)) ||
- bestTarget.height !== NumCast(activeItem.presHeight, NumCast(bestTarget.height))
+ bestTarget.x !== NumCast(activeItem.config_x, NumCast(bestTarget.x)) ||
+ bestTarget.y !== NumCast(activeItem.config_y, NumCast(bestTarget.y)) ||
+ bestTarget.rotation !== NumCast(activeItem.config_rotation, NumCast(bestTarget.rotation)) ||
+ bestTarget.width !== NumCast(activeItem.config_width, NumCast(bestTarget.width)) ||
+ bestTarget.height !== NumCast(activeItem.config_height, NumCast(bestTarget.height))
) {
bestTarget._dataTransition = `all ${transTime}ms`;
- bestTarget.x = NumCast(activeItem.presX, NumCast(bestTarget.x));
- bestTarget.y = NumCast(activeItem.presY, NumCast(bestTarget.y));
- bestTarget.rotation = NumCast(activeItem.presRotation, NumCast(bestTarget.rotation));
- bestTarget.width = NumCast(activeItem.presWidth, NumCast(bestTarget.width));
- bestTarget.height = NumCast(activeItem.presHeight, NumCast(bestTarget.height));
+ bestTarget.x = NumCast(activeItem.config_x, NumCast(bestTarget.x));
+ bestTarget.y = NumCast(activeItem.config_y, NumCast(bestTarget.y));
+ bestTarget.rotation = NumCast(activeItem.config_rotation, NumCast(bestTarget.rotation));
+ bestTarget.width = NumCast(activeItem.config_width, NumCast(bestTarget.width));
+ bestTarget.height = NumCast(activeItem.config_height, NumCast(bestTarget.height));
setTimeout(() => (bestTarget._dataTransition = undefined), transTime + 10);
changed = true;
}
}
- const activeFrame = activeItem.presActiveFrame ?? activeItem.presCurrentFrame;
+ const activeFrame = activeItem.config_activeFrame ?? activeItem.config_currentFrame;
if (activeFrame !== undefined) {
- const transTime = NumCast(activeItem.presTransition, 500);
- const acontext = activeItem.presActiveFrame !== undefined ? DocCast(DocCast(activeItem.presentationTargetDoc).embedContainer) : DocCast(activeItem.presentationTargetDoc);
+ const transTime = NumCast(activeItem.presentation_transition, 500);
+ const acontext = activeItem.config_activeFrame !== undefined ? DocCast(DocCast(activeItem.presentation_targetDoc).embedContainer) : DocCast(activeItem.presentation_targetDoc);
const context = DocCast(acontext)?.annotationOn ? DocCast(DocCast(acontext).annotationOn) : acontext;
if (context) {
const ffview = DocumentManager.Instance.getFirstDocumentView(context)?.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView;
@@ -434,73 +434,73 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
}
}
- if ((pinDataTypes?.dataview && activeItem.presData !== undefined) || (!pinDataTypes && activeItem.presData !== undefined)) {
+ if ((pinDataTypes?.dataview && activeItem.config_data !== undefined) || (!pinDataTypes && activeItem.config_data !== undefined)) {
bestTarget._dataTransition = `all ${transTime}ms`;
const fkey = Doc.LayoutFieldKey(bestTarget);
const setData = bestTargetView?.ComponentView?.setData;
- if (setData) setData(activeItem.presData);
- else Doc.GetProto(bestTarget)[fkey] = activeItem.presData instanceof ObjectField ? activeItem.presData[Copy]() : activeItem.presData;
- bestTarget[fkey + '_usePath'] = activeItem.presUsePath;
+ if (setData) setData(activeItem.config_data);
+ else Doc.GetProto(bestTarget)[fkey] = activeItem.config_data instanceof ObjectField ? activeItem.config_data[Copy]() : activeItem.config_data;
+ bestTarget[fkey + '_usePath'] = activeItem.config_usePath;
setTimeout(() => (bestTarget._dataTransition = undefined), transTime + 10);
}
- if (pinDataTypes?.datarange || (!pinDataTypes && activeItem.presXRange !== undefined)) {
- if (bestTarget.xRange !== activeItem.presXRange) {
- bestTarget.xRange = (activeItem.presXRange as ObjectField)?.[Copy]();
+ if (pinDataTypes?.datarange || (!pinDataTypes && activeItem.config_xRange !== undefined)) {
+ if (bestTarget.xRange !== activeItem.config_xRange) {
+ bestTarget.xRange = (activeItem.config_xRange as ObjectField)?.[Copy]();
changed = true;
}
- if (bestTarget.yRange !== activeItem.presYRange) {
- bestTarget.yRange = (activeItem.presYRange as ObjectField)?.[Copy]();
+ if (bestTarget.yRange !== activeItem.config_yRange) {
+ bestTarget.yRange = (activeItem.config_yRange as ObjectField)?.[Copy]();
changed = true;
}
}
- if (pinDataTypes?.clippable || (!pinDataTypes && activeItem.presClipWidth !== undefined)) {
+ if (pinDataTypes?.clippable || (!pinDataTypes && activeItem.config_clipWidth !== undefined)) {
const fkey = '_' + Doc.LayoutFieldKey(bestTarget);
- if (bestTarget[fkey + '_clipWidth'] !== activeItem.presClipWidth) {
- bestTarget[fkey + '_clipWidth'] = activeItem.presClipWidth;
+ if (bestTarget[fkey + '_clipWidth'] !== activeItem.config_clipWidth) {
+ bestTarget[fkey + '_clipWidth'] = activeItem.config_clipWidth;
changed = true;
}
}
- if (pinDataTypes?.temporal || (!pinDataTypes && activeItem.presStartTime !== undefined)) {
- if (bestTarget._layout_currentTimecode !== activeItem.presStartTime) {
- bestTarget._layout_currentTimecode = activeItem.presStartTime;
+ if (pinDataTypes?.temporal || (!pinDataTypes && activeItem.config_clipStart !== undefined)) {
+ if (bestTarget._layout_currentTimecode !== activeItem.config_clipStart) {
+ bestTarget._layout_currentTimecode = activeItem.config_clipStart;
changed = true;
}
}
- if (pinDataTypes?.inkable || (!pinDataTypes && (activeItem.presFillColor !== undefined || activeItem.color !== undefined))) {
- if (bestTarget.fillColor !== activeItem.presFillColor) {
- Doc.GetProto(bestTarget).fillColor = activeItem.presFillColor;
+ if (pinDataTypes?.inkable || (!pinDataTypes && (activeItem.config_fillColor !== undefined || activeItem.color !== undefined))) {
+ if (bestTarget.fillColor !== activeItem.config_fillColor) {
+ Doc.GetProto(bestTarget).fillColor = activeItem.config_fillColor;
changed = true;
}
- if (bestTarget.color !== activeItem.presColor) {
- Doc.GetProto(bestTarget).color = activeItem.presColor;
+ if (bestTarget.color !== activeItem.config_color) {
+ Doc.GetProto(bestTarget).color = activeItem.config_color;
changed = true;
}
if (bestTarget.width !== activeItem.width) {
- bestTarget._width = NumCast(activeItem.presWidth, NumCast(bestTarget.width));
+ bestTarget._width = NumCast(activeItem.config_width, NumCast(bestTarget.width));
changed = true;
}
if (bestTarget.height !== activeItem.height) {
- bestTarget._height = NumCast(activeItem.presHeight, NumCast(bestTarget.height));
+ bestTarget._height = NumCast(activeItem.config_height, NumCast(bestTarget.height));
changed = true;
}
}
- if ((pinDataTypes?.type_collection && activeItem.presViewType !== undefined) || (!pinDataTypes && activeItem.presViewType !== undefined)) {
- if (bestTarget._type_collection !== activeItem.presViewType) {
- bestTarget._type_collection = activeItem.presViewType;
+ if ((pinDataTypes?.type_collection && activeItem.config_viewType !== undefined) || (!pinDataTypes && activeItem.config_viewType !== undefined)) {
+ if (bestTarget._type_collection !== activeItem.config_viewType) {
+ bestTarget._type_collection = activeItem.config_viewType;
changed = true;
}
}
- if ((pinDataTypes?.filters && activeItem.presDocFilters !== undefined) || (!pinDataTypes && activeItem.presDocFilters !== undefined)) {
- if (bestTarget.childFilters !== activeItem.presDocFilters) {
- bestTarget.childFilters = ObjectField.MakeCopy(activeItem.presDocFilters as ObjectField) || new List<string>([]);
+ if ((pinDataTypes?.filters && activeItem.config_docFilters !== undefined) || (!pinDataTypes && activeItem.config_docFilters !== undefined)) {
+ if (bestTarget.childFilters !== activeItem.config_docFilters) {
+ bestTarget.childFilters = ObjectField.MakeCopy(activeItem.config_docFilters as ObjectField) || new List<string>([]);
changed = true;
}
}
- if ((pinDataTypes?.pivot && activeItem.presPivotField !== undefined) || (!pinDataTypes && activeItem.presPivotField !== undefined)) {
- if (bestTarget.pivotField !== activeItem.presPivotField) {
- bestTarget.pivotField = activeItem.presPivotField;
+ if ((pinDataTypes?.pivot && activeItem.config_pivotField !== undefined) || (!pinDataTypes && activeItem.config_pivotField !== undefined)) {
+ if (bestTarget.pivotField !== activeItem.config_pivotField) {
+ bestTarget.pivotField = activeItem.config_pivotField;
bestTarget._prevFilterIndex = 1; // need to revisit this...see CollectionTimeView
changed = true;
}
@@ -509,21 +509,21 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
changed = true;
}
- if (pinDataTypes?.scrollable || (!pinDataTypes && activeItem.presViewScroll !== undefined)) {
- if (bestTarget._layout_scrollTop !== activeItem.presViewScroll) {
- bestTarget._layout_scrollTop = activeItem.presViewScroll;
+ if (pinDataTypes?.scrollable || (!pinDataTypes && activeItem.config_scrollTop !== undefined)) {
+ if (bestTarget._layout_scrollTop !== activeItem.config_scrollTop) {
+ bestTarget._layout_scrollTop = activeItem.config_scrollTop;
changed = true;
- const contentBounds = Cast(activeItem.presPinViewBounds, listSpec('number'));
+ const contentBounds = Cast(activeItem.config_viewBounds, listSpec('number'));
if (contentBounds) {
const dv = DocumentManager.Instance.getDocumentView(bestTarget)?.ComponentView;
- dv?.brushView?.({ panX: (contentBounds[0] + contentBounds[2]) / 2, panY: (contentBounds[1] + contentBounds[3]) / 2, width: contentBounds[2] - contentBounds[0], height: contentBounds[3] - contentBounds[1] });
+ dv?.brushView?.({ panX: (contentBounds[0] + contentBounds[2]) / 2, panY: (contentBounds[1] + contentBounds[3]) / 2, width: contentBounds[2] - contentBounds[0], height: contentBounds[3] - contentBounds[1] }, transTime);
}
}
}
- if (pinDataTypes?.dataannos || (!pinDataTypes && activeItem.presAnnotations !== undefined)) {
+ if (pinDataTypes?.dataannos || (!pinDataTypes && activeItem.config_annotations !== undefined)) {
const fkey = Doc.LayoutFieldKey(bestTarget);
const oldItems = DocListCast(bestTarget[fkey + '_annotations']).filter(doc => doc.layout_unrendered);
- const newItems = DocListCast(activeItem.presAnnotations).map(doc => {
+ const newItems = DocListCast(activeItem.config_annotations).map(doc => {
doc.hidden = false;
return doc;
});
@@ -536,11 +536,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const newList = new List<Doc>([...oldItems, ...hiddenItems, ...newItems]);
Doc.GetProto(bestTarget)[fkey + '_annotations'] = newList;
}
- if (pinDataTypes?.poslayoutview || (!pinDataTypes && activeItem.presPinLayoutData !== undefined)) {
+ if (pinDataTypes?.poslayoutview || (!pinDataTypes && activeItem.config_pinLayoutData !== undefined)) {
changed = true;
const layoutField = Doc.LayoutFieldKey(bestTarget);
const transitioned = new Set<Doc>();
- StrListCast(activeItem.presPinLayoutData)
+ StrListCast(activeItem.config_pinLayoutData)
.map(str => JSON.parse(str) as { id: string; x: number; y: number; back: string; fill: string; w: number; h: number; data: string; text: string })
.forEach(async data => {
const doc = DocCast(DocServer.GetCachedRefField(data.id));
@@ -562,8 +562,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
});
setTimeout(() => Array.from(transitioned).forEach(action(doc => (doc._dataTransition = undefined))), transTime + 10);
}
- if ((pinDataTypes?.pannable || (!pinDataTypes && (activeItem.presPinViewBounds !== undefined || activeItem.presPanX !== undefined || activeItem.presViewScale !== undefined))) && !bestTarget._isGroup) {
- const contentBounds = Cast(activeItem.presPinViewBounds, listSpec('number'));
+ if ((pinDataTypes?.pannable || (!pinDataTypes && (activeItem.config_viewBounds !== undefined || activeItem.config_panX !== undefined || activeItem.config_viewScale !== undefined))) && !bestTarget._isGroup) {
+ const contentBounds = Cast(activeItem.config_viewBounds, listSpec('number'));
if (contentBounds) {
const viewport = { panX: (contentBounds[0] + contentBounds[2]) / 2, panY: (contentBounds[1] + contentBounds[3]) / 2, width: contentBounds[2] - contentBounds[0], height: contentBounds[3] - contentBounds[1] };
bestTarget._freeform_panX = viewport.panX;
@@ -572,14 +572,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (dv) {
changed = true;
const computedScale = NumCast(activeItem.presZoom, 1) * Math.min(dv.props.PanelWidth() / viewport.width, dv.props.PanelHeight() / viewport.height);
- activeItem.presMovement === PresMovement.Zoom && (bestTarget._freeform_scale = computedScale);
- dv.ComponentView?.brushView?.(viewport);
+ activeItem.presentation_movement === PresMovement.Zoom && (bestTarget._freeform_scale = computedScale);
+ dv.ComponentView?.brushView?.(viewport, transTime);
}
} else {
- if (bestTarget._freeform_panX !== activeItem.presPanX || bestTarget._freeform_panY !== activeItem.presPanY || bestTarget._freeform_scale !== activeItem.presViewScale) {
- bestTarget._freeform_panX = activeItem.presPanX ?? bestTarget._freeform_panX;
- bestTarget._freeform_panY = activeItem.presPanY ?? bestTarget._freeform_panY;
- bestTarget._freeform_scale = activeItem.presViewScale ?? bestTarget._freeform_scale;
+ if (bestTarget._freeform_panX !== activeItem.config_panX || bestTarget._freeform_panY !== activeItem.config_panY || bestTarget._freeform_scale !== activeItem.config_viewScale) {
+ bestTarget._freeform_panX = activeItem.config_panX ?? bestTarget._freeform_panX;
+ bestTarget._freeform_panY = activeItem.config_panY ?? bestTarget._freeform_panY;
+ bestTarget._freeform_scale = activeItem.config_viewScale ?? bestTarget._freeform_scale;
changed = true;
}
}
@@ -594,17 +594,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
/// target doc when navigating to it.
@action
static pinDocView(pinDoc: Doc, pinProps: PinProps, targetDoc: Doc) {
+ pinDoc.presentation = true;
+ pinDoc.config = '';
if (pinProps.pinDocLayout) {
- pinDoc.presPinLayout = true;
- pinDoc.presX = NumCast(targetDoc.x);
- pinDoc.presY = NumCast(targetDoc.y);
- pinDoc.presRotation = NumCast(targetDoc.rotation);
- pinDoc.presWidth = NumCast(targetDoc.width);
- pinDoc.presHeight = NumCast(targetDoc.height);
+ pinDoc.config_pinLayout = true;
+ pinDoc.config_x = NumCast(targetDoc.x);
+ pinDoc.config_y = NumCast(targetDoc.y);
+ pinDoc.config_rotation = NumCast(targetDoc.rotation);
+ pinDoc.config_width = NumCast(targetDoc.width);
+ pinDoc.config_height = NumCast(targetDoc.height);
}
if (pinProps.pinAudioPlay) pinDoc.presPlayAudio = true;
if (pinProps.pinData) {
- pinDoc.presPinData =
+ pinDoc.config_pinData =
pinProps.pinData.scrollable ||
pinProps.pinData.temporal ||
pinProps.pinData.pannable ||
@@ -616,30 +618,30 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
pinProps?.activeFrame !== undefined;
const fkey = Doc.LayoutFieldKey(targetDoc);
if (pinProps.pinData.dataview) {
- pinDoc.presUsePath = targetDoc[fkey + '_usePath'];
- pinDoc.presData = targetDoc[fkey] instanceof ObjectField ? (targetDoc[fkey] as ObjectField)[Copy]() : targetDoc.data;
+ pinDoc.config_usePath = targetDoc[fkey + '_usePath'];
+ pinDoc.config_data = targetDoc[fkey] instanceof ObjectField ? (targetDoc[fkey] as ObjectField)[Copy]() : targetDoc.data;
}
if (pinProps.pinData.dataannos) {
const fkey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.presAnnotations = new List<Doc>(DocListCast(Doc.GetProto(targetDoc)[fkey + '_annotations']).filter(doc => !doc.layout_unrendered));
+ pinDoc.config_annotations = new List<Doc>(DocListCast(Doc.GetProto(targetDoc)[fkey + '_annotations']).filter(doc => !doc.layout_unrendered));
}
if (pinProps.pinData.inkable) {
- pinDoc.presFillColor = targetDoc.fillColor;
- pinDoc.presColor = targetDoc.color;
- pinDoc.presWidth = targetDoc._width;
- pinDoc.presHeight = targetDoc._height;
+ pinDoc.config_fillColor = targetDoc.fillColor;
+ pinDoc.config_color = targetDoc.color;
+ pinDoc.config_width = targetDoc._width;
+ pinDoc.config_height = targetDoc._height;
}
- if (pinProps.pinData.scrollable) pinDoc.presViewScroll = targetDoc._layout_scrollTop;
+ if (pinProps.pinData.scrollable) pinDoc.config_scrollTop = targetDoc._layout_scrollTop;
if (pinProps.pinData.clippable) {
const fkey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.presClipWidth = targetDoc[fkey + '_clipWidth'];
+ pinDoc.config_clipWidth = targetDoc[fkey + '_clipWidth'];
}
if (pinProps.pinData.datarange) {
- pinDoc.presXRange = undefined; //targetDoc?.xrange;
- pinDoc.presYRange = undefined; //targetDoc?.yrange;
+ pinDoc.config_xRange = undefined; //targetDoc?.xrange;
+ pinDoc.config_yRange = undefined; //targetDoc?.yrange;
}
if (pinProps.pinData.poslayoutview)
- pinDoc.presPinLayoutData = new List<string>(
+ pinDoc.config_pinLayoutData = new List<string>(
DocListCast(targetDoc[fkey] as ObjectField).map(d =>
JSON.stringify({
id: d[Id],
@@ -654,28 +656,28 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
})
)
);
- if (pinProps.pinData.type_collection) pinDoc.presViewType = targetDoc._type_collection;
- if (pinProps.pinData.filters) pinDoc.presDocFilters = ObjectField.MakeCopy(targetDoc.childFilters as ObjectField);
- if (pinProps.pinData.pivot) pinDoc.presPivotField = targetDoc._pivotField;
+ if (pinProps.pinData.type_collection) pinDoc.config_viewType = targetDoc._type_collection;
+ if (pinProps.pinData.filters) pinDoc.config_docFilters = ObjectField.MakeCopy(targetDoc.childFilters as ObjectField);
+ if (pinProps.pinData.pivot) pinDoc.config_pivotField = targetDoc._pivotField;
if (pinProps.pinData.pannable) {
- pinDoc.presPanX = NumCast(targetDoc._freeform_panX);
- pinDoc.presPanY = NumCast(targetDoc._freeform_panY);
- pinDoc.presViewScale = NumCast(targetDoc._freeform_scale, 1);
+ pinDoc.config_panX = NumCast(targetDoc._freeform_panX);
+ pinDoc.config_panY = NumCast(targetDoc._freeform_panY);
+ pinDoc.config_viewScale = NumCast(targetDoc._freeform_scale, 1);
}
if (pinProps.pinData.temporal) {
- pinDoc.presStartTime = targetDoc._layout_currentTimecode;
- const duration = NumCast(pinDoc[`${Doc.LayoutFieldKey(pinDoc)}_duration`], NumCast(targetDoc.presStartTime) + 0.1);
- pinDoc.presEndTime = NumCast(targetDoc.clipEnd, duration);
+ pinDoc.config_clipStart = targetDoc._layout_currentTimecode;
+ const duration = NumCast(pinDoc[`${Doc.LayoutFieldKey(pinDoc)}_duration`], NumCast(targetDoc.config_clipStart) + 0.1);
+ pinDoc.config_clipEnd = NumCast(targetDoc.clipEnd, duration);
}
}
if (pinProps?.pinViewport) {
// If pinWithView option set then update scale and x / y props of slide
const bounds = pinProps.pinViewport;
- pinDoc.presPinView = true;
- pinDoc.presViewScale = NumCast(targetDoc._freeform_scale, 1);
- pinDoc.presPanX = bounds.left + bounds.width / 2;
- pinDoc.presPanY = bounds.top + bounds.height / 2;
- pinDoc.presPinViewBounds = new List<number>([bounds.left, bounds.top, bounds.left + bounds.width, bounds.top + bounds.height]);
+ pinDoc.config_pinView = true;
+ pinDoc.config_viewScale = NumCast(targetDoc._freeform_scale, 1);
+ pinDoc.config_panX = bounds.left + bounds.width / 2;
+ pinDoc.config_panY = bounds.top + bounds.height / 2;
+ pinDoc.config_viewBounds = new List<number>([bounds.left, bounds.top, bounds.left + bounds.width, bounds.top + bounds.height]);
}
}
/**
@@ -712,23 +714,23 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
static NavigateToTarget(targetDoc: Doc, activeItem: Doc, finished?: () => void) {
- if (activeItem.presMovement === PresMovement.None && targetDoc.type === DocumentType.SCRIPTING) {
+ if (activeItem.presentation_movement === PresMovement.None && targetDoc.type === DocumentType.SCRIPTING) {
(DocumentManager.Instance.getFirstDocumentView(targetDoc)?.ComponentView as ScriptingBox)?.onRun?.();
return;
}
- const effect = activeItem.presEffect && activeItem.presEffect !== PresEffect.None ? activeItem.presEffect : undefined;
- const presTime = NumCast(activeItem.presTransition, effect ? 750 : 500);
+ const effect = activeItem.presentation_effect && activeItem.presentation_effect !== PresEffect.None ? activeItem.presentation_effect : undefined;
+ const presTime = NumCast(activeItem.presentation_transition, effect ? 750 : 500);
const options: DocFocusOptions = {
- willPan: activeItem.presMovement !== PresMovement.None,
- willZoomCentered: activeItem.presMovement === PresMovement.Zoom || activeItem.presMovement === PresMovement.Jump || activeItem.presMovement === PresMovement.Center,
- zoomScale: activeItem.presMovement === PresMovement.Center ? 0 : NumCast(activeItem.presZoom, 1),
- zoomTime: activeItem.presMovement === PresMovement.Jump ? 0 : Math.min(Math.max(effect ? 750 : 500, (effect ? 0.2 : 1) * presTime), presTime),
+ willPan: activeItem.presentation_movement !== PresMovement.None,
+ willZoomCentered: activeItem.presentation_movement === PresMovement.Zoom || activeItem.presentation_movement === PresMovement.Jump || activeItem.presentation_movement === PresMovement.Center,
+ zoomScale: activeItem.presentation_movement === PresMovement.Center ? 0 : NumCast(activeItem.presZoom, 1),
+ zoomTime: activeItem.presentation_movement === PresMovement.Jump ? 0 : Math.min(Math.max(effect ? 750 : 500, (effect ? 0.2 : 1) * presTime), presTime),
effect: activeItem,
noSelect: true,
openLocation: OpenWhere.addLeft,
anchorDoc: activeItem,
easeFunc: StrCast(activeItem.presEaseFunc, 'ease') as any,
- zoomTextSelections: BoolCast(activeItem.presZoomText),
+ zoomTextSelections: BoolCast(activeItem.presentation_zoomText),
playAudio: BoolCast(activeItem.presPlayAudio),
};
if (activeItem.presOpenInLightbox) {
@@ -738,7 +740,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
}
if (targetDoc) {
- if (activeItem.presentationTargetDoc instanceof Doc) activeItem.presentationTargetDoc[Animation] = undefined;
+ if (activeItem.presentation_targetDoc instanceof Doc) activeItem.presentation_targetDoc[Animation] = undefined;
DocumentManager.Instance.AddViewRenderedCb(LightboxView.LightboxDoc, dv => {
// if target or the doc it annotates is not in the lightbox, then close the lightbox
@@ -761,16 +763,16 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const tagDoc = PresBox.targetRenderedDoc(curDoc);
const itemIndexes: number[] = this.getAllIndexes(this.tagDocs, tagDoc);
let opacity: Opt<number> = index === this.itemIndex ? 1 : undefined;
- if (curDoc.presHide) {
+ if (curDoc.presentation_hide) {
if (index !== this.itemIndex) {
opacity = 1;
}
}
const hidingIndBef = itemIndexes.find(item => item >= this.itemIndex) ?? itemIndexes.slice().reverse().lastElement();
- if (curDoc.presHideBefore && index === hidingIndBef) {
+ if (curDoc.presentation_hideBefore && index === hidingIndBef) {
if (index > this.itemIndex) {
opacity = 0;
- } else if (index === this.itemIndex || !curDoc.presHideAfter) {
+ } else if (index === this.itemIndex || !curDoc.presentation_hideAfter) {
opacity = 1;
setTimeout(() => (tagDoc._dataTransition = undefined), 1000);
}
@@ -780,15 +782,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
.slice()
.reverse()
.find(item => item <= this.itemIndex) ?? itemIndexes.lastElement();
- if (curDoc.presHideAfter && index === hidingIndAft) {
+ if (curDoc.presentation_hideAfter && index === hidingIndAft) {
if (index < this.itemIndex) {
opacity = 0;
- } else if (index === this.itemIndex || !curDoc.presHideBefore) {
+ } else if (index === this.itemIndex || !curDoc.presentation_hideBefore) {
opacity = 1;
}
}
const hidingInd = itemIndexes.find(item => item === this.itemIndex);
- if (curDoc.presHide && index === hidingInd) {
+ if (curDoc.presentation_hide && index === hidingInd) {
if (index === this.itemIndex) {
opacity = 0;
}
@@ -846,9 +848,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// The function pauses the auto presentation
@action
pauseAutoPres = () => {
- if (this.layoutDoc.presStatus === PresStatus.Autoplay) {
+ if (this.layoutDoc.presentation_status === PresStatus.Autoplay) {
if (this._presTimer) clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
this.childDocs.forEach(this.stopTempMedia);
}
};
@@ -879,23 +881,23 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
runInAction(() => (this._expandBoolean = !this._expandBoolean));
this.rootDoc.expandBoolean = this._expandBoolean;
this.childDocs.forEach(doc => {
- doc.presExpandInlineButton = this._expandBoolean;
+ doc.presentation_expandInlineButton = this._expandBoolean;
});
};
initializePresState = (startIndex: number) => {
this.childDocs.forEach((doc, index) => {
const tagDoc = PresBox.targetRenderedDoc(doc);
- if (doc.presHideBefore && index > startIndex) tagDoc.opacity = 0;
- if (doc.presHideAfter && index < startIndex) tagDoc.opacity = 0;
- if (doc.presIndexed !== undefined && index >= startIndex) {
- const startInd = NumCast(doc.presIndexedStart);
+ if (doc.presentation_hideBefore && index > startIndex) tagDoc.opacity = 0;
+ if (doc.presentation_hideAfter && index < startIndex) tagDoc.opacity = 0;
+ if (doc.presentation_indexed !== undefined && index >= startIndex) {
+ const startInd = NumCast(doc.presentation_indexedStart);
this.progressivizedItems(doc)
?.slice(startInd)
.forEach(indexedDoc => (indexedDoc.opacity = 0));
- doc.presIndexed = Math.min(this.progressivizedItems(doc)?.length ?? 0, startInd);
+ doc.presentation_indexed = Math.min(this.progressivizedItems(doc)?.length ?? 0, startInd);
}
- // if (doc.presHide && this.childDocs.indexOf(doc) === startIndex) tagDoc.opacity = 0;
+ // if (doc.presentation_hide && this.childDocs.indexOf(doc) === startIndex) tagDoc.opacity = 0;
});
};
@@ -909,13 +911,13 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
PresBox.Instance = this;
clearTimeout(this._presTimer);
if (this.childDocs.length) {
- this.layoutDoc.presStatus = PresStatus.Autoplay;
+ this.layoutDoc.presentation_status = PresStatus.Autoplay;
this.initializePresState(startIndex);
const func = () => {
- const delay = NumCast(this.activeItem.presDuration, this.activeItem.type === DocumentType.SCRIPTING ? 0 : 2500) + NumCast(this.activeItem.presTransition);
+ const delay = NumCast(this.activeItem.presentation_duration, this.activeItem.type === DocumentType.SCRIPTING ? 0 : 2500) + NumCast(this.activeItem.presentation_transition);
this._presTimer = setTimeout(() => {
- if (!this.next()) this.layoutDoc.presStatus = this._exitTrail?.() ?? PresStatus.Manual;
- this.layoutDoc.presStatus === PresStatus.Autoplay && func();
+ if (!this.next()) this.layoutDoc.presentation_status = this._exitTrail?.() ?? PresStatus.Manual;
+ this.layoutDoc.presentation_status === PresStatus.Autoplay && func();
}, delay);
};
this.gotoDocument(startIndex, this.activeItem, undefined, func);
@@ -949,7 +951,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
doc._width = PresBox.minimizedWidth;
Doc.AddToMyOverlay(doc);
PresBox.Instance?.initializePresState(PresBox.Instance.itemIndex);
- return (doc.presStatus = PresStatus.Manual);
+ return (doc.presentation_status = PresStatus.Manual);
}
/**
@@ -993,34 +995,34 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
});
movementName = action((activeItem: Doc) => {
- if (![PresMovement.Zoom, PresMovement.Pan, PresMovement.Center, PresMovement.Jump, PresMovement.None].includes(StrCast(activeItem.presMovement) as any)) {
+ if (![PresMovement.Zoom, PresMovement.Pan, PresMovement.Center, PresMovement.Jump, PresMovement.None].includes(StrCast(activeItem.presentation_movement) as any)) {
return PresMovement.Zoom;
}
- return StrCast(activeItem.presMovement);
+ return StrCast(activeItem.presentation_movement);
});
whenChildContentsActiveChanged = action((isActive: boolean) => this.props.whenChildContentsActiveChanged((this._isChildActive = isActive)));
// For dragging documents into the presentation trail
addDocumentFilter = (docs: Doc[]) => {
docs.forEach((doc, i) => {
- if (doc.presentationTargetDoc) return true;
+ if (doc.presentation_targetDoc) return true;
if (doc.type === DocumentType.LABEL) {
const audio = Cast(doc.annotationOn, Doc, null);
if (audio) {
audio.mediaStart = 'manual';
audio.mediaStop = 'manual';
- audio.presStartTime = NumCast(doc._timecodeToShow /* audioStart */, NumCast(doc._timecodeToShow /* videoStart */));
- audio.presEndTime = NumCast(doc._timecodeToHide /* audioEnd */, NumCast(doc._timecodeToHide /* videoEnd */));
- audio.presDuration = audio.presStartTime - audio.presEndTime;
+ audio.config_clipStart = NumCast(doc._timecodeToShow /* audioStart */, NumCast(doc._timecodeToShow /* videoStart */));
+ audio.config_clipEnd = NumCast(doc._timecodeToHide /* audioEnd */, NumCast(doc._timecodeToHide /* videoEnd */));
+ audio.presentation_duration = audio.config_clipStart - audio.config_clipEnd;
TabDocView.PinDoc(audio, { audioRange: true });
setTimeout(() => this.removeDocument(doc), 0);
return false;
}
} else {
- if (!doc.presentationTargetDoc) doc.title = doc.title + ' - Slide';
- doc.presentationTargetDoc = doc.createdFrom; // dropped document will be a new embedding of an embedded document somewhere else.
- doc.presMovement = PresMovement.Zoom;
- if (this._expandBoolean) doc.presExpandInlineButton = true;
+ if (!doc.presentation_targetDoc) doc.title = doc.title + ' - Slide';
+ doc.presentation_targetDoc = doc.createdFrom; // dropped document will be a new embedding of an embedded document somewhere else.
+ doc.presentation_movement = PresMovement.Zoom;
+ if (this._expandBoolean) doc.presentation_expandInlineButton = true;
}
});
return true;
@@ -1040,7 +1042,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get listOfSelected() {
return Array.from(this.selectedArray).map((doc: Doc, index: any) => {
const curDoc = Cast(doc, Doc, null);
- const tagDoc = Cast(curDoc.presentationTargetDoc, Doc, null);
+ const tagDoc = Cast(curDoc.presentation_targetDoc, Doc, null);
if (curDoc && curDoc === this.activeItem)
return (
<div key={index} className="selectedList-items">
@@ -1146,7 +1148,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (anchorNode && anchorNode.className?.includes('lm_title')) return;
switch (e.key) {
case 'Backspace':
- if (this.layoutDoc.presStatus === 'edit') {
+ if (this.layoutDoc.presentation_status === 'edit') {
undoBatch(
action(() => {
for (const doc of this.selectedArray) {
@@ -1163,11 +1165,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
case 'Escape':
if (Doc.IsInMyOverlay(this.layoutDoc)) {
this.exitClicked();
- } else if (this.layoutDoc.presStatus === PresStatus.Edit) {
+ } else if (this.layoutDoc.presentation_status === PresStatus.Edit) {
this.clearSelectedArray();
this._eleArray.length = this._dragArray.length = 0;
} else {
- this.layoutDoc.presStatus = PresStatus.Edit;
+ this.layoutDoc.presentation_status = PresStatus.Edit;
}
if (this._presTimer) clearTimeout(this._presTimer);
handled = true;
@@ -1184,7 +1186,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.next();
if (this._presTimer) {
clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
}
}
handled = true;
@@ -1201,19 +1203,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.back();
if (this._presTimer) {
clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
}
}
handled = true;
break;
case 'Spacebar':
case ' ':
- if (this.layoutDoc.presStatus === PresStatus.Manual) this.startOrPause(true);
- else if (this.layoutDoc.presStatus === PresStatus.Autoplay) if (this._presTimer) clearTimeout(this._presTimer);
+ if (this.layoutDoc.presentation_status === PresStatus.Manual) this.startOrPause(true);
+ else if (this.layoutDoc.presentation_status === PresStatus.Autoplay) if (this._presTimer) clearTimeout(this._presTimer);
handled = true;
break;
case 'a':
- if ((e.metaKey || e.altKey) && this.layoutDoc.presStatus === 'edit') {
+ if ((e.metaKey || e.altKey) && this.layoutDoc.presentation_status === 'edit') {
this.clearSelectedArray();
this.childDocs.forEach(doc => this.addToSelectedArray(doc));
handled = true;
@@ -1236,9 +1238,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const presCollection = DocumentManager.GetContextPath(this.activeItem).reverse().lastElement();
const dv = DocumentManager.Instance.getDocumentView(presCollection);
this.childDocs
- .filter(doc => Cast(doc.presentationTargetDoc, Doc, null))
+ .filter(doc => Cast(doc.presentation_targetDoc, Doc, null))
.forEach((doc, index) => {
- const tagDoc = Cast(doc.presentationTargetDoc, Doc, null);
+ const tagDoc = Cast(doc.presentation_targetDoc, Doc, null);
const srcContext = Cast(tagDoc.embedContainer, Doc, null);
const width = NumCast(tagDoc._width) / 10;
const height = Math.max(NumCast(tagDoc._height) / 10, 15);
@@ -1271,17 +1273,17 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
);
}
- } else if (doc.presPinView && presCollection === tagDoc && dv) {
+ } else if (doc.config_pinView && presCollection === tagDoc && dv) {
// Case B: Document is presPinView and is presCollection
- const scale: number = 1 / NumCast(doc.presViewScale);
+ const scale: number = 1 / NumCast(doc.config_viewScale);
const height: number = dv.props.PanelHeight() * scale;
const width: number = dv.props.PanelWidth() * scale;
const indWidth = width / 10;
const indHeight = Math.max(height / 10, 15);
const indEdge = Math.max(indWidth, indHeight);
const indFontSize = indEdge * 0.8;
- const xLoc: number = NumCast(doc.presPanX) - width / 2;
- const yLoc: number = NumCast(doc.presPanY) - height / 2;
+ const xLoc: number = NumCast(doc.config_panX) - width / 2;
+ const yLoc: number = NumCast(doc.config_panY) - height / 2;
docs.push(tagDoc);
order.push(
<>
@@ -1307,15 +1309,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get paths() {
let pathPoints = '';
this.childDocs.forEach((doc, index) => {
- const tagDoc = Cast(doc.presentationTargetDoc, Doc, null);
+ const tagDoc = Cast(doc.presentation_targetDoc, Doc, null);
if (tagDoc) {
const n1x = NumCast(tagDoc.x) + NumCast(tagDoc._width) / 2;
const n1y = NumCast(tagDoc.y) + NumCast(tagDoc._height) / 2;
if ((index = 0)) pathPoints = n1x + ',' + n1y;
else pathPoints = pathPoints + ' ' + n1x + ',' + n1y;
- } else if (doc.presPinView) {
- const n1x = NumCast(doc.presPanX);
- const n1y = NumCast(doc.presPanY);
+ } else if (doc.config_pinView) {
+ const n1x = NumCast(doc.config_panX);
+ const n1y = NumCast(doc.config_panY);
if ((index = 0)) pathPoints = n1x + ',' + n1y;
else pathPoints = pathPoints + ' ' + n1x + ',' + n1y;
}
@@ -1339,7 +1341,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
getPaths = (collection: Doc) => this.paths; // needs to be smarter and figure out the paths to draw for this specific collection. or better yet, draw everything in an overlay layer instad of within a collection
- // Converts seconds to ms and updates presTransition
+ // Converts seconds to ms and updates presentation_transition
public static SetTransitionTime = (number: String, setter: (timeInMS: number) => void, change?: number) => {
let timeInMS = Number(number) * 1000;
if (change) timeInMS += change;
@@ -1350,10 +1352,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@undoBatch
updateTransitionTime = (number: String, change?: number) => {
- PresBox.SetTransitionTime(number, (timeInMS: number) => this.selectedArray.forEach(doc => (doc.presTransition = timeInMS)), change);
+ PresBox.SetTransitionTime(number, (timeInMS: number) => this.selectedArray.forEach(doc => (doc.presentation_transition = timeInMS)), change);
};
- // Converts seconds to ms and updates presTransition
+ // Converts seconds to ms and updates presentation_transition
@undoBatch
updateZoom = (number: String, change?: number) => {
let scale = Number(number) / 100;
@@ -1364,7 +1366,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
/*
- * Converts seconds to ms and updates presDuration
+ * Converts seconds to ms and updates presentation_duration
*/
@undoBatch
updateDurationTime = (number: String, change?: number) => {
@@ -1372,31 +1374,31 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (change) timeInMS += change;
if (timeInMS < 100) timeInMS = 100;
if (timeInMS > 20000) timeInMS = 20000;
- this.selectedArray.forEach(doc => (doc.presDuration = timeInMS));
+ this.selectedArray.forEach(doc => (doc.presentation_duration = timeInMS));
};
@undoBatch
- updateMovement = action((movement: PresMovement, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presMovement = movement)));
+ updateMovement = action((movement: PresMovement, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presentation_movement = movement)));
@undoBatch
@action
updateHideBefore = (activeItem: Doc) => {
- activeItem.presHideBefore = !activeItem.presHideBefore;
- this.selectedArray.forEach(doc => (doc.presHideBefore = activeItem.presHideBefore));
+ activeItem.presentation_hideBefore = !activeItem.presentation_hideBefore;
+ this.selectedArray.forEach(doc => (doc.presentation_hideBefore = activeItem.presentation_hideBefore));
};
@undoBatch
@action
updateHide = (activeItem: Doc) => {
- activeItem.presHide = !activeItem.presHide;
- this.selectedArray.forEach(doc => (doc.presHide = activeItem.presHide));
+ activeItem.presentation_hide = !activeItem.presentation_hide;
+ this.selectedArray.forEach(doc => (doc.presentation_hide = activeItem.presentation_hide));
};
@undoBatch
@action
updateHideAfter = (activeItem: Doc) => {
- activeItem.presHideAfter = !activeItem.presHideAfter;
- this.selectedArray.forEach(doc => (doc.presHideAfter = activeItem.presHideAfter));
+ activeItem.presentation_hideAfter = !activeItem.presentation_hideAfter;
+ this.selectedArray.forEach(doc => (doc.presentation_hideAfter = activeItem.presentation_hideAfter));
};
@undoBatch
@@ -1415,11 +1417,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@undoBatch
@action
- updateEffectDirection = (effect: PresEffectDirection, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presEffectDirection = effect));
+ updateEffectDirection = (effect: PresEffectDirection, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presentation_effectDirection = effect));
@undoBatch
@action
- updateEffect = (effect: PresEffect, bullet: boolean, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (bullet ? (doc.presBulletEffect = effect) : (doc.presEffect = effect)));
+ updateEffect = (effect: PresEffect, bullet: boolean, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (bullet ? (doc.presBulletEffect = effect) : (doc.presentation_effect = effect)));
static _sliderBatch: any;
public static inputter = (min: string, step: string, max: string, value: number, active: boolean, change: (val: string) => void, hmargin?: number) => {
@@ -1449,16 +1451,16 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@undoBatch
@action
applyTo = (array: Doc[]) => {
- this.updateMovement(this.activeItem.presMovement as PresMovement, true);
- this.updateEffect(this.activeItem.presEffect as PresEffect, false, true);
+ this.updateMovement(this.activeItem.presentation_movement as PresMovement, true);
+ this.updateEffect(this.activeItem.presentation_effect as PresEffect, false, true);
this.updateEffect(this.activeItem.presBulletEffect as PresEffect, true, true);
- this.updateEffectDirection(this.activeItem.presEffectDirection as PresEffectDirection, true);
- const { presTransition, presDuration, presHideBefore, presHideAfter } = this.activeItem;
+ this.updateEffectDirection(this.activeItem.presentation_effectDirection as PresEffectDirection, true);
+ const { presentation_transition, presentation_duration, presentation_hideBefore, presentation_hideAfter } = this.activeItem;
array.forEach(curDoc => {
- curDoc.presTransition = presTransition;
- curDoc.presDuration = presDuration;
- curDoc.presHideBefore = presHideBefore;
- curDoc.presHideAfter = presHideAfter;
+ curDoc.presentation_transition = presentation_transition;
+ curDoc.presentation_duration = presentation_duration;
+ curDoc.presentation_hideBefore = presentation_hideBefore;
+ curDoc.presentation_hideAfter = presentation_hideAfter;
});
};
@@ -1466,24 +1468,24 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const activeItem = this.activeItem;
if (activeItem && this.targetDoc) {
const targetType = this.targetDoc.type;
- let duration = activeItem.presDuration ? NumCast(activeItem.presDuration) / 1000 : 0;
+ let duration = activeItem.presentation_duration ? NumCast(activeItem.presentation_duration) / 1000 : 0;
if (activeItem.type === DocumentType.AUDIO) duration = NumCast(activeItem.duration);
return (
<div className="presBox-ribbon">
<div className="ribbon-doubleButton">
<Tooltip title={<div className="dash-tooltip">{'Hide before presented'}</div>}>
- <div className={`ribbon-toggle ${activeItem.presHideBefore ? 'active' : ''}`} onClick={() => this.updateHideBefore(activeItem)}>
+ <div className={`ribbon-toggle ${activeItem.presentation_hideBefore ? 'active' : ''}`} onClick={() => this.updateHideBefore(activeItem)}>
Hide before
</div>
</Tooltip>
<Tooltip title={<div className="dash-tooltip">{'Hide while presented'}</div>}>
- <div className={`ribbon-toggle ${activeItem.presHide ? 'active' : ''}`} onClick={() => this.updateHide(activeItem)}>
+ <div className={`ribbon-toggle ${activeItem.presentation_hide ? 'active' : ''}`} onClick={() => this.updateHide(activeItem)}>
Hide
</div>
</Tooltip>
<Tooltip title={<div className="dash-tooltip">{'Hide after presented'}</div>}>
- <div className={`ribbon-toggle ${activeItem.presHideAfter ? 'active' : ''}`} onClick={() => this.updateHideAfter(activeItem)}>
+ <div className={`ribbon-toggle ${activeItem.presentation_hideAfter ? 'active' : ''}`} onClick={() => this.updateHideAfter(activeItem)}>
Hide after
</div>
</Tooltip>
@@ -1532,7 +1534,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (activeItem && this.targetDoc) {
const effect = activeItem.presBulletEffect ? activeItem.presBulletEffect : PresMovement.None;
const bulletEffect = (effect: PresEffect) => (
- <div className={`presBox-dropdownOption ${activeItem.presEffect === effect || (effect === PresEffect.None && !activeItem.presEffect) ? 'active' : ''}`} onPointerDown={StopEvent} onClick={() => this.updateEffect(effect, true)}>
+ <div
+ className={`presBox-dropdownOption ${activeItem.presentation_effect === effect || (effect === PresEffect.None && !activeItem.presentation_effect) ? 'active' : ''}`}
+ onPointerDown={StopEvent}
+ onClick={() => this.updateEffect(effect, true)}>
{effect}
</div>
);
@@ -1545,25 +1550,31 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
style={{ margin: 10 }}
type="checkbox"
onChange={() => {
- activeItem.presIndexed = activeItem.presIndexed === undefined ? 0 : undefined;
- activeItem.presHideBefore = activeItem.presIndexed !== undefined;
+ activeItem.presentation_indexed = activeItem.presentation_indexed === undefined ? 0 : undefined;
+ activeItem.presentation_hideBefore = activeItem.presentation_indexed !== undefined;
const tagDoc = PresBox.targetRenderedDoc(this.activeItem);
const type = DocCast(tagDoc?.annotationOn)?.type ?? tagDoc.type;
- activeItem.presIndexedStart = type === DocumentType.COL ? 1 : 0;
+ activeItem.presentation_indexedStart = type === DocumentType.COL ? 1 : 0;
// a progressivized slide doesn't have sub-slides, but rather iterates over the data list of the target being progressivized.
// to avoid creating a new slide to correspond to each of the target's data list, we create a computedField to refernce the target's data list.
let dataField = Doc.LayoutFieldKey(tagDoc);
if (Cast(tagDoc[dataField], listSpec(Doc), null)?.filter(d => d instanceof Doc) === undefined) dataField = dataField + '_annotations';
- if (DocCast(activeItem.presentationTargetDoc).annotationOn) activeItem.data = ComputedField.MakeFunction(`self.presentationTargetDoc.annotationOn["${dataField}"]`);
- else activeItem.data = ComputedField.MakeFunction(`self.presentationTargetDoc["${dataField}"]`);
+ if (DocCast(activeItem.presentation_targetDoc).annotationOn) activeItem.data = ComputedField.MakeFunction(`self.presentation_targetDoc.annotationOn["${dataField}"]`);
+ else activeItem.data = ComputedField.MakeFunction(`self.presentation_targetDoc["${dataField}"]`);
}}
- checked={Cast(activeItem.presIndexed, 'number', null) !== undefined ? true : false}
+ checked={Cast(activeItem.presentation_indexed, 'number', null) !== undefined ? true : false}
/>
</div>
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Progressivize First Bullet</div>
- <input className="presBox-checkbox" style={{ margin: 10 }} type="checkbox" onChange={() => (activeItem.presIndexedStart = activeItem.presIndexedStart ? 0 : 1)} checked={!NumCast(activeItem.presIndexedStart)} />
+ <input
+ className="presBox-checkbox"
+ style={{ margin: 10 }}
+ type="checkbox"
+ onChange={() => (activeItem.presentation_indexedStart = activeItem.presentation_indexedStart ? 0 : 1)}
+ checked={!NumCast(activeItem.presentation_indexedStart)}
+ />
</div>
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Expand Current Bullet</div>
@@ -1598,18 +1609,21 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
@computed get transitionDropdown() {
const activeItem = this.activeItem;
- const presEffect = (effect: PresEffect) => (
- <div className={`presBox-dropdownOption ${activeItem.presEffect === effect || (effect === PresEffect.None && !activeItem.presEffect) ? 'active' : ''}`} onPointerDown={StopEvent} onClick={() => this.updateEffect(effect, false)}>
+ const preseEffect = (effect: PresEffect) => (
+ <div
+ className={`presBox-dropdownOption ${activeItem.presentation_effect === effect || (effect === PresEffect.None && !activeItem.presentation_effect) ? 'active' : ''}`}
+ onPointerDown={StopEvent}
+ onClick={() => this.updateEffect(effect, false)}>
{effect}
</div>
);
const presMovement = (movement: PresMovement) => (
- <div className={`presBox-dropdownOption ${activeItem.presMovement === movement ? 'active' : ''}`} onPointerDown={StopEvent} onClick={() => this.updateMovement(movement)}>
+ <div className={`presBox-dropdownOption ${activeItem.presentation_movement === movement ? 'active' : ''}`} onPointerDown={StopEvent} onClick={() => this.updateMovement(movement)}>
{movement}
</div>
);
const presDirection = (direction: PresEffectDirection, icon: string, gridColumn: number, gridRow: number, opts: object) => {
- const color = activeItem.presEffectDirection === direction || (direction === PresEffectDirection.Center && !activeItem.presEffectDirection) ? Colors.LIGHT_BLUE : 'black';
+ const color = activeItem.presentation_effectDirection === direction || (direction === PresEffectDirection.Center && !activeItem.presentation_effectDirection) ? Colors.LIGHT_BLUE : 'black';
return (
<Tooltip title={<div className="dash-tooltip">{direction}</div>}>
<div
@@ -1621,12 +1635,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
);
};
if (activeItem && this.targetDoc) {
- const transitionSpeed = activeItem.presTransition ? NumCast(activeItem.presTransition) / 1000 : 0.5;
+ const transitionSpeed = activeItem.presentation_transition ? NumCast(activeItem.presentation_transition) / 1000 : 0.5;
const zoom = NumCast(activeItem.presZoom, 1) * 100;
- const effect = activeItem.presEffect ? activeItem.presEffect : PresMovement.None;
+ const effect = activeItem.presentation_effect ? activeItem.presentation_effect : PresMovement.None;
return (
<div
- className={`presBox-ribbon ${this._transitionTools && this.layoutDoc.presStatus === PresStatus.Edit ? 'active' : ''}`}
+ className={`presBox-ribbon ${this._transitionTools && this.layoutDoc.presentation_status === PresStatus.Edit ? 'active' : ''}`}
onPointerDown={StopEvent}
onPointerUp={StopEvent}
onClick={action(e => {
@@ -1654,7 +1668,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
{presMovement(PresMovement.Jump)}
</div>
</div>
- <div className="ribbon-doubleButton" style={{ display: activeItem.presMovement === PresMovement.Zoom ? 'inline-flex' : 'none' }}>
+ <div className="ribbon-doubleButton" style={{ display: activeItem.presentation_movement === PresMovement.Zoom ? 'inline-flex' : 'none' }}>
<div className="presBox-subheading">Zoom (% screen filled)</div>
<div className="ribbon-property">
<input className="presBox-input" type="number" readOnly={true} value={zoom} onChange={e => this.updateZoom(e.target.value)} />%
@@ -1668,7 +1682,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
</div>
</div>
- {PresBox.inputter('0', '1', '100', zoom, activeItem.presMovement === PresMovement.Zoom, this.updateZoom)}
+ {PresBox.inputter('0', '1', '100', zoom, activeItem.presentation_movement === PresMovement.Zoom, this.updateZoom)}
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Transition Time</div>
<div className="ribbon-property">
@@ -1698,7 +1712,13 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Zoom Text Selections</div>
- <input className="presBox-checkbox" style={{ margin: 10 }} type="checkbox" onChange={() => (activeItem.presZoomText = !BoolCast(activeItem.presZoomText))} checked={BoolCast(activeItem.presZoomText)} />
+ <input
+ className="presBox-checkbox"
+ style={{ margin: 10 }}
+ type="checkbox"
+ onChange={() => (activeItem.presentation_zoomText = !BoolCast(activeItem.presentation_zoomText))}
+ checked={BoolCast(activeItem.presentation_zoomText)}
+ />
</div>
<div
className="presBox-dropdown"
@@ -1710,17 +1730,17 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
{effect?.toString()}
<FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openEffectDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon={'angle-down'} />
<div className={'presBox-dropdownOptions'} id={'presBoxMovementDropdown'} style={{ display: this._openEffectDropdown ? 'grid' : 'none' }} onPointerDown={e => e.stopPropagation()}>
- {presEffect(PresEffect.None)}
- {presEffect(PresEffect.Fade)}
- {presEffect(PresEffect.Flip)}
- {presEffect(PresEffect.Rotate)}
- {presEffect(PresEffect.Bounce)}
- {presEffect(PresEffect.Roll)}
+ {preseEffect(PresEffect.None)}
+ {preseEffect(PresEffect.Fade)}
+ {preseEffect(PresEffect.Flip)}
+ {preseEffect(PresEffect.Rotate)}
+ {preseEffect(PresEffect.Bounce)}
+ {preseEffect(PresEffect.Roll)}
</div>
</div>
<div className="ribbon-doubleButton" style={{ display: effect === PresEffectDirection.None ? 'none' : 'inline-flex' }}>
<div className="presBox-subheading">Effect direction</div>
- <div className="ribbon-property">{StrCast(this.activeItem.presEffectDirection)}</div>
+ <div className="ribbon-property">{StrCast(this.activeItem.presentation_effectDirection)}</div>
</div>
<div className="effectDirection" style={{ display: effect === PresEffectDirection.None ? 'none' : 'grid', width: 40 }}>
{presDirection(PresEffectDirection.Left, 'angle-right', 1, 2, {})}
@@ -1760,10 +1780,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
style={{ textAlign: 'center', width: '100%', height: 15, fontSize: 10 }}
type="number"
readOnly={true}
- value={NumCast(activeItem.presStartTime).toFixed(2)}
+ value={NumCast(activeItem.config_clipStart).toFixed(2)}
onKeyDown={e => e.stopPropagation()}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => {
- activeItem.presStartTime = Number(e.target.value);
+ activeItem.config_clipStart = Number(e.target.value);
})}
/>
</div>
@@ -1773,7 +1793,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
Duration (s)
</div>
<div className="slider-number" style={{ backgroundColor: Colors.LIGHT_BLUE }}>
- {Math.round((NumCast(activeItem.presEndTime) - NumCast(activeItem.presStartTime)) * 10) / 10}
+ {Math.round((NumCast(activeItem.config_clipEnd) - NumCast(activeItem.config_clipStart)) * 10) / 10}
</div>
</div>
<div className="slider-block">
@@ -1787,9 +1807,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
style={{ textAlign: 'center', width: '100%', height: 15, fontSize: 10 }}
type="number"
readOnly={true}
- value={NumCast(activeItem.presEndTime).toFixed(2)}
+ value={NumCast(activeItem.config_clipEnd).toFixed(2)}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => {
- activeItem.presEndTime = Number(e.target.value);
+ activeItem.config_clipEnd = Number(e.target.value);
})}
/>
</div>
@@ -1801,12 +1821,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
step="0.1"
min={clipStart}
max={clipEnd}
- value={NumCast(activeItem.presEndTime)}
+ value={NumCast(activeItem.config_clipEnd)}
style={{ gridColumn: 1, gridRow: 1 }}
className={`toolbar-slider ${'end'}`}
id="toolbar-slider"
onPointerDown={e => {
- this._batch = UndoManager.StartBatch('presEndTime');
+ this._batch = UndoManager.StartBatch('config_clipEnd');
const endBlock = document.getElementById('endTime');
if (endBlock) {
endBlock.style.color = Colors.LIGHT_GRAY;
@@ -1824,7 +1844,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
e.stopPropagation();
- activeItem.presEndTime = Number(e.target.value);
+ activeItem.config_clipEnd = Number(e.target.value);
}}
/>
<input
@@ -1832,12 +1852,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
step="0.1"
min={clipStart}
max={clipEnd}
- value={NumCast(activeItem.presStartTime)}
+ value={NumCast(activeItem.config_clipStart)}
style={{ gridColumn: 1, gridRow: 1 }}
className={`toolbar-slider ${'start'}`}
id="toolbar-slider"
onPointerDown={e => {
- this._batch = UndoManager.StartBatch('presStartTime');
+ this._batch = UndoManager.StartBatch('config_clipStart');
const startBlock = document.getElementById('startTime');
if (startBlock) {
startBlock.style.color = Colors.LIGHT_GRAY;
@@ -1855,7 +1875,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
e.stopPropagation();
- activeItem.presStartTime = Number(e.target.value);
+ activeItem.config_clipStart = Number(e.target.value);
}}
/>
</div>
@@ -1916,7 +1936,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return (
<div
className="presBox-toolbar-dropdown"
- style={{ display: this._newDocumentTools && this.layoutDoc.presStatus === 'edit' ? 'inline-flex' : 'none' }}
+ style={{ display: this._newDocumentTools && this.layoutDoc.presentation_status === 'edit' ? 'inline-flex' : 'none' }}
onClick={e => e.stopPropagation()}
onPointerUp={e => e.stopPropagation()}
onPointerDown={e => e.stopPropagation()}>
@@ -2053,10 +2073,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (doc) {
const tabMap = CollectionDockingView.Instance?.tabMap;
const tab = tabMap && Array.from(tabMap).find(tab => tab.DashDoc.type === DocumentType.COL)?.DashDoc;
- const presCollection = DocumentManager.GetContextPath(this.activeItem).reverse().lastElement().presentationTargetDoc ?? tab;
+ const presCollection = DocumentManager.GetContextPath(this.activeItem).reverse().lastElement().presentation_targetDoc ?? tab;
const data = Cast(presCollection?.data, listSpec(Doc));
- const presData = Cast(this.rootDoc.data, listSpec(Doc));
- if (data && presData) {
+ const config_data = Cast(this.rootDoc.data, listSpec(Doc));
+ if (data && config_data) {
data.push(doc);
TabDocView.PinDoc(doc, {});
this.gotoDocument(this.childDocs.length, this.activeItem);
@@ -2105,7 +2125,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
className="dropdown-play-button"
onClick={undoBatch(
action(() => {
- this.layoutDoc.presStatus = 'manual';
+ this.layoutDoc.presentation_status = 'manual';
this.initializePresState(this.itemIndex);
this.turnOffEdit(true);
this.gotoDocument(this.itemIndex, this.activeItem);
@@ -2181,7 +2201,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
className={`presBox-buttons${Doc.IsInMyOverlay(this.rootDoc) ? ' inOverlay' : ''}`}
style={{ background: Doc.ActivePresentation === this.rootDoc ? Colors.LIGHT_BLUE : undefined, display: !this.rootDoc._chromeHidden ? 'none' : undefined }}>
{isMini ? null : (
- <select className="presBox-viewPicker" style={{ display: this.layoutDoc.presStatus === 'edit' ? 'block' : 'none' }} onPointerDown={e => e.stopPropagation()} onChange={this.viewChanged} value={mode}>
+ <select className="presBox-viewPicker" style={{ display: this.layoutDoc.presentation_status === 'edit' ? 'block' : 'none' }} onPointerDown={e => e.stopPropagation()} onChange={this.viewChanged} value={mode}>
<option onPointerDown={StopEvent} value={CollectionViewType.Stacking}>
List
</option>
@@ -2196,12 +2216,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</select>
)}
<div className="presBox-presentPanel" style={{ opacity: this.childDocs.length ? 1 : 0.3 }}>
- <span className={`presBox-button ${this.layoutDoc.presStatus === PresStatus.Edit ? 'present' : ''}`}>
+ <span className={`presBox-button ${this.layoutDoc.presentation_status === PresStatus.Edit ? 'present' : ''}`}>
<div
className="presBox-button-left"
onClick={undoBatch(() => {
if (this.childDocs.length) {
- this.layoutDoc.presStatus = 'manual';
+ this.layoutDoc.presentation_status = 'manual';
this.initializePresState(this.itemIndex);
this.gotoDocument(this.itemIndex, this.activeItem);
}
@@ -2227,12 +2247,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
@computed get playButtons() {
- const presEnd = !this.layoutDoc.presLoop && this.itemIndex === this.childDocs.length - 1 && (this.activeItem.presIndexed === undefined || NumCast(this.activeItem.presIndexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
+ const presEnd =
+ !this.layoutDoc.presLoop &&
+ this.itemIndex === this.childDocs.length - 1 &&
+ (this.activeItem.presentation_indexed === undefined || NumCast(this.activeItem.presentation_indexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
const presStart: boolean = !this.layoutDoc.presLoop && this.itemIndex === 0;
const inOverlay = Doc.IsInMyOverlay(this.rootDoc);
// Case 1: There are still other frames and should go through all frames before going to next slide
return (
- <div className="presPanelOverlay" style={{ display: this.layoutDoc.presStatus !== 'edit' ? 'inline-flex' : 'none' }}>
+ <div className="presPanelOverlay" style={{ display: this.layoutDoc.presentation_status !== 'edit' ? 'inline-flex' : 'none' }}>
<Tooltip title={<div className="dash-tooltip">{'Loop'}</div>}>
<div
className="presPanel-button"
@@ -2255,7 +2278,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.back();
if (this._presTimer) {
clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
}
e.stopPropagation();
},
@@ -2265,9 +2288,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}>
<FontAwesomeIcon icon={'arrow-left'} />
</div>
- <Tooltip title={<div className="dash-tooltip">{this.layoutDoc.presStatus === PresStatus.Autoplay ? 'Pause' : 'Autoplay'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">{this.layoutDoc.presentation_status === PresStatus.Autoplay ? 'Pause' : 'Autoplay'}</div>}>
<div className="presPanel-button" onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, () => this.startOrPause(true), false, false)}>
- <FontAwesomeIcon color={this.layoutDoc.presStatus === PresStatus.Autoplay ? 'red' : undefined} icon={this.layoutDoc.presStatus === PresStatus.Autoplay ? 'pause' : 'play'} />
+ <FontAwesomeIcon color={this.layoutDoc.presentation_status === PresStatus.Autoplay ? 'red' : undefined} icon={this.layoutDoc.presentation_status === PresStatus.Autoplay ? 'pause' : 'play'} />
</div>
</Tooltip>
<div
@@ -2283,7 +2306,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.next();
if (this._presTimer) {
clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
}
e.stopPropagation();
},
@@ -2316,7 +2339,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</Tooltip>
<div className="presPanel-button-text" onClick={() => this.gotoDocument(0, this.activeItem)} style={{ display: inOverlay || this.props.PanelWidth() > 250 ? 'inline-flex' : 'none' }}>
{inOverlay ? '' : 'Slide'} {this.itemIndex + 1}
- {this.activeItem?.presIndexed !== undefined ? `(${this.activeItem.presIndexed}/${this.progressivizedItems(this.activeItem)?.length})` : ''} / {this.childDocs.length}
+ {this.activeItem?.presentation_indexed !== undefined ? `(${this.activeItem.presentation_indexed}/${this.progressivizedItems(this.activeItem)?.length})` : ''} / {this.childDocs.length}
</div>
<div className="presPanel-divider"></div>
{this.props.PanelWidth() > 250 ? (
@@ -2324,7 +2347,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
className="presPanel-button-text"
onClick={undoBatch(
action(() => {
- this.layoutDoc.presStatus = PresStatus.Edit;
+ this.layoutDoc.presentation_status = PresStatus.Edit;
clearTimeout(this._presTimer);
})
)}>
@@ -2342,7 +2365,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@action
startOrPause = (makeActive = true) => {
makeActive && this.updateCurrentPresentation();
- if (!this.layoutDoc.presStatus || this.layoutDoc.presStatus === PresStatus.Manual || this.layoutDoc.presStatus === PresStatus.Edit) this.startPresentation(this.itemIndex);
+ if (!this.layoutDoc.presentation_status || this.layoutDoc.presentation_status === PresStatus.Manual || this.layoutDoc.presentation_status === PresStatus.Edit) this.startPresentation(this.itemIndex);
else this.pauseAutoPres();
};
@@ -2351,7 +2374,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.back();
if (this._presTimer) {
clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
}
};
@@ -2360,19 +2383,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.next();
if (this._presTimer) {
clearTimeout(this._presTimer);
- this.layoutDoc.presStatus = PresStatus.Manual;
+ this.layoutDoc.presentation_status = PresStatus.Manual;
}
};
@undoBatch
@action
exitClicked = () => {
- this.layoutDoc.presStatus = this._exitTrail?.() ?? this.exitMinimize();
+ this.layoutDoc.presentation_status = this._exitTrail?.() ?? this.exitMinimize();
clearTimeout(this._presTimer);
};
AddToMap = (treeViewDoc: Doc, index: number[]) => {
- if (!treeViewDoc.presentationTargetDoc) return this.childDocs; // if treeViewDoc is not a pres elements, then it's a sub-bullet of a progressivized slide which isn't added to the linearized list of pres elements since it's not really a pres element.
+ if (!treeViewDoc.presentation_targetDoc) return this.childDocs; // if treeViewDoc is not a pres elements, then it's a sub-bullet of a progressivized slide which isn't added to the linearized list of pres elements since it's not really a pres element.
var indexNum = 0;
for (let i = 0; i < index.length; i++) {
indexNum += index[i] * 10 ** -i;
@@ -2388,20 +2411,23 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
RemFromMap = (treeViewDoc: Doc, index: number[]) => {
- if (!treeViewDoc.presentationTargetDoc) return this.childDocs; // if treeViewDoc is not a pres elements, then it's a sub-bullet of a progressivized slide which isn't added to the linearized list of pres elements since it's not really a pres element.
+ if (!treeViewDoc.presentation_targetDoc) return this.childDocs; // if treeViewDoc is not a pres elements, then it's a sub-bullet of a progressivized slide which isn't added to the linearized list of pres elements since it's not really a pres element.
if (!this._unmounting && this.isTree) {
this._treeViewMap.delete(treeViewDoc);
this.dataDoc[this.presFieldKey] = new List<Doc>(this.sort(this._treeViewMap));
}
};
- sort = (treeViewMap: Map<Doc, number>) => [...treeViewMap.entries()].sort((a: [Doc, number], b: [Doc, number]) => (a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0)).map(kv => kv[0]);
+ sort = (treeView_Map: Map<Doc, number>) => [...treeView_Map.entries()].sort((a: [Doc, number], b: [Doc, number]) => (a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0)).map(kv => kv[0]);
render() {
// needed to ensure that the childDocs are loaded for looking up fields
this.childDocs.slice();
const mode = StrCast(this.rootDoc._type_collection) as CollectionViewType;
- const presEnd = !this.layoutDoc.presLoop && this.itemIndex === this.childDocs.length - 1 && (this.activeItem.presIndexed === undefined || NumCast(this.activeItem.presIndexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
+ const presEnd =
+ !this.layoutDoc.presLoop &&
+ this.itemIndex === this.childDocs.length - 1 &&
+ (this.activeItem.presentation_indexed === undefined || NumCast(this.activeItem.presentation_indexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
const presStart = !this.layoutDoc.presLoop && this.itemIndex === 0;
return this.props.addDocTab === returnFalse ? ( // bcz: hack!! - addDocTab === returnFalse only when this is being rendered by the OverlayView which means the doc is a mini player
<div className="miniPres" onClick={e => e.stopPropagation()} onPointerEnter={action(e => (this._forceKeyEvents = true))}>
@@ -2420,9 +2446,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="presPanel-button" style={{ opacity: presStart ? 0.4 : 1 }} onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, this.prevClicked, false, false)}>
<FontAwesomeIcon icon={'arrow-left'} />
</div>
- <Tooltip title={<div className="dash-tooltip">{this.layoutDoc.presStatus === PresStatus.Autoplay ? 'Pause' : 'Autoplay'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">{this.layoutDoc.presentation_status === PresStatus.Autoplay ? 'Pause' : 'Autoplay'}</div>}>
<div className="presPanel-button" onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, () => this.startOrPause(true), false, false)}>
- <FontAwesomeIcon icon={this.layoutDoc.presStatus === 'auto' ? 'pause' : 'play'} />
+ <FontAwesomeIcon icon={this.layoutDoc.presentation_status === 'auto' ? 'pause' : 'play'} />
</div>
</Tooltip>
<div className="presPanel-button" style={{ opacity: presEnd ? 0.4 : 1 }} onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, this.nextClicked, false, false)}>
@@ -2436,7 +2462,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</Tooltip>
<div className="presPanel-button-text">
Slide {this.itemIndex + 1}
- {this.activeItem?.presIndexed !== undefined ? `(${this.activeItem.presIndexed}/${this.progressivizedItems(this.activeItem)?.length})` : ''} / {this.childDocs.length}
+ {this.activeItem?.presentation_indexed !== undefined ? `(${this.activeItem.presentation_indexed}/${this.progressivizedItems(this.activeItem)?.length})` : ''} / {this.childDocs.length}
</div>
<div className="presPanel-divider" />
<div className="presPanel-button-text" onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, this.exitClicked, false, false)}>
@@ -2460,6 +2486,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
moveDocument={returnFalse}
ignoreUnrendered={true}
childDragAction="move"
+ setContentView={emptyFunction}
//childLayoutFitWidth={returnTrue}
childOpacity={returnOne}
childClickScript={PresBox.navigateToDocScript}
diff --git a/src/client/views/nodes/trails/PresElementBox.tsx b/src/client/views/nodes/trails/PresElementBox.tsx
index f31cf6147..aa514be3b 100644
--- a/src/client/views/nodes/trails/PresElementBox.tsx
+++ b/src/client/views/nodes/trails/PresElementBox.tsx
@@ -58,13 +58,13 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
return this.props.DocumentView?.().props.docViewPath().lastElement()?.rootDoc;
}
@computed get targetDoc() {
- return Cast(this.rootDoc.presentationTargetDoc, Doc, null) || this.rootDoc;
+ return Cast(this.rootDoc.presentation_targetDoc, Doc, null) || this.rootDoc;
}
componentDidMount() {
this.layoutDoc.layout_hideLinkButton = true;
this._heightDisposer = reaction(
- () => ({ expand: this.rootDoc.presExpandInlineButton, height: this.collapsedHeight }),
+ () => ({ expand: this.rootDoc.presentation_expandInlineButton, height: this.collapsedHeight }),
({ expand, height }) => (this.layoutDoc._height = height + (expand ? this.expandViewHeight : 0)),
{ fireImmediately: true }
);
@@ -79,7 +79,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
ScreenToLocalListTransform = (xCord: number, yCord: number) => [xCord, yCord];
@action
- presExpandDocumentClick = () => (this.rootDoc.presExpandInlineButton = !this.rootDoc.presExpandInlineButton);
+ presExpandDocumentClick = () => (this.rootDoc.presentation_expandInlineButton = !this.rootDoc.presentation_expandInlineButton);
embedHeight = (): number => this.collapsedHeight + this.expandViewHeight;
// embedWidth = () => this.props.PanelWidth();
@@ -94,7 +94,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
* presentation element.
*/
@computed get renderEmbeddedInline() {
- return !this.rootDoc.presExpandInlineButton || !this.targetDoc ? null : (
+ return !this.rootDoc.presentation_expandInlineButton || !this.targetDoc ? null : (
<div className="presItem-embedded" style={{ height: this.embedHeight(), width: '50%' }}>
<DocumentView
Document={PresBox.targetRenderedDoc(this.rootDoc)}
@@ -158,9 +158,9 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get transition() {
let transitionInS: number;
- if (this.rootDoc.presTransition) transitionInS = NumCast(this.rootDoc.presTransition) / 1000;
+ if (this.rootDoc.presentation_transition) transitionInS = NumCast(this.rootDoc.presentation_transition) / 1000;
else transitionInS = 0.5;
- return this.rootDoc.presMovement === PresMovement.Jump || this.rootDoc.presMovement === PresMovement.None ? null : 'M: ' + transitionInS + 's';
+ return this.rootDoc.presentation_movement === PresMovement.Jump || this.rootDoc.presentation_movement === PresMovement.None ? null : 'M: ' + transitionInS + 's';
}
private _itemRef: React.RefObject<HTMLDivElement> = React.createRef();
@@ -238,7 +238,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
onPointerMove = (e: PointerEvent) => {
const slide = this._itemRef.current!;
- const dragIsPresItem = DragManager.docsBeingDragged.some(d => d.presentationTargetDoc);
+ const dragIsPresItem = DragManager.docsBeingDragged.some(d => d.presentation_targetDoc);
if (slide && dragIsPresItem) {
const rect = slide.getBoundingClientRect();
const y = e.clientY - rect.top; //y position within the element.
@@ -296,12 +296,12 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
@action
updateCapturedContainerLayout = (presTargetDoc: Doc, activeItem: Doc) => {
const targetDoc = DocCast(presTargetDoc.annotationOn) ?? presTargetDoc;
- activeItem.presX = NumCast(targetDoc.x);
- activeItem.presY = NumCast(targetDoc.y);
- activeItem.presRotation = NumCast(targetDoc.rotation);
- activeItem.presWidth = NumCast(targetDoc.width);
- activeItem.presHeight = NumCast(targetDoc.height);
- activeItem.presPinLayout = true;
+ activeItem.config_x = NumCast(targetDoc.x);
+ activeItem.config_y = NumCast(targetDoc.y);
+ activeItem.config_rotation = NumCast(targetDoc.rotation);
+ activeItem.config_width = NumCast(targetDoc.width);
+ activeItem.config_height = NumCast(targetDoc.height);
+ activeItem.config_pinLayout = true;
};
/**
* Method called for updating the view of the currently selected document
@@ -421,7 +421,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div
className="slideButton"
onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, () => this.updateCapturedContainerLayout(targetDoc, activeItem), true)}
- style={{ opacity: activeItem.presPinLayout ? 1 : 0.5, fontWeight: 700, display: 'flex' }}>
+ style={{ opacity: activeItem.config_pinLayout ? 1 : 0.5, fontWeight: 700, display: 'flex' }}>
L
</div>
</Tooltip>
@@ -431,7 +431,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div
className="slideButton"
onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, () => this.updateCapturedViewContents(targetDoc, activeItem))}
- style={{ opacity: activeItem.presPinData || activeItem.presPinView ? 1 : 0.5, fontWeight: 700, display: 'flex' }}>
+ style={{ opacity: activeItem.config_pinData || activeItem.config_pinView ? 1 : 0.5, fontWeight: 700, display: 'flex' }}>
C
</div>
</Tooltip>
@@ -445,19 +445,19 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
);
if (this.indexInPres !== 0) {
items.push(
- <Tooltip key="arrow" title={<div className="dash-tooltip">{activeItem.groupWithUp ? 'Ungroup' : 'Group with up'}</div>}>
+ <Tooltip key="arrow" title={<div className="dash-tooltip">{activeItem.presentation_groupWithUp ? 'Ungroup' : 'Group with up'}</div>}>
<div
className="slideButton"
- onClick={() => (activeItem.groupWithUp = (NumCast(activeItem.groupWithUp) + 1) % 3)}
+ onClick={() => (activeItem.presentation_groupWithUp = (NumCast(activeItem.presentation_groupWithUp) + 1) % 3)}
style={{
zIndex: 1000 - this.indexInPres,
fontWeight: 700,
- backgroundColor: activeItem.groupWithUp ? (presColorBool ? presBoxColor : Colors.MEDIUM_BLUE) : undefined,
- outline: NumCast(activeItem.groupWithUp) > 1 ? 'solid black 1px' : undefined,
- height: activeItem.groupWithUp ? 53 : 18,
- transform: activeItem.groupWithUp ? 'translate(0, -17px)' : undefined,
+ backgroundColor: activeItem.presentation_groupWithUp ? (presColorBool ? presBoxColor : Colors.MEDIUM_BLUE) : undefined,
+ outline: NumCast(activeItem.presentation_groupWithUp) > 1 ? 'solid black 1px' : undefined,
+ height: activeItem.presentation_groupWithUp ? 53 : 18,
+ transform: activeItem.presentation_groupWithUp ? 'translate(0, -17px)' : undefined,
}}>
- <div style={{ transform: activeItem.groupWithUp ? 'rotate(180deg) translate(0, -17.5px)' : 'rotate(0deg)' }}>
+ <div style={{ transform: activeItem.presentation_groupWithUp ? 'rotate(180deg) translate(0, -17.5px)' : 'rotate(0deg)' }}>
<FontAwesomeIcon icon={'arrow-up'} onPointerDown={e => e.stopPropagation()} />
</div>
</div>
@@ -465,14 +465,14 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
);
}
items.push(
- <Tooltip key="eye" title={<div className="dash-tooltip">{this.rootDoc.presExpandInlineButton ? 'Minimize' : 'Expand'}</div>}>
+ <Tooltip key="eye" title={<div className="dash-tooltip">{this.rootDoc.presentation_expandInlineButton ? 'Minimize' : 'Expand'}</div>}>
<div
className="slideButton"
onClick={e => {
e.stopPropagation();
this.presExpandDocumentClick();
}}>
- <FontAwesomeIcon icon={this.rootDoc.presExpandInlineButton ? 'eye-slash' : 'eye'} onPointerDown={e => e.stopPropagation()} />
+ <FontAwesomeIcon icon={this.rootDoc.presentation_expandInlineButton ? 'eye-slash' : 'eye'} onPointerDown={e => e.stopPropagation()} />
</div>
</Tooltip>
);
@@ -534,7 +534,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
style={{
display: 'inline-flex',
pointerEvents: isSelected ? undefined : 'none',
- width: `calc(100% ${this.rootDoc.presExpandInlineButton ? '- 50%' : ''} - ${this.presButtons.length * 22}px`,
+ width: `calc(100% ${this.rootDoc.presentation_expandInlineButton ? '- 50%' : ''} - ${this.presButtons.length * 22}px`,
cursor: isSelected ? 'text' : 'grab',
}}>
<div