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.tsx2
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx4
-rw-r--r--src/client/views/nodes/FunctionPlotBox.tsx20
-rw-r--r--src/client/views/nodes/KeyValueBox.tsx3
-rw-r--r--src/client/views/nodes/KeyValuePair.tsx2
-rw-r--r--src/client/views/nodes/PDFBox.tsx6
-rw-r--r--src/client/views/nodes/formattedText/EquationView.tsx10
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx6
8 files changed, 27 insertions, 26 deletions
diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index 69277b054..df6e74d85 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -429,7 +429,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
specificContextMenu = (): void => {
const cm = ContextMenu.Instance;
const options = cm.findByDescription('Options...');
- const optionItems = options && 'subitems' in options ? options.subitems : [];
+ const optionItems = options?.subitems ?? [];
optionItems.push({ description: `Analyze with AI`, event: () => this.askGPT(), icon: 'lightbulb' });
!options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'eye' });
};
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 8a2c4e530..b178d6554 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -89,8 +89,8 @@ export class DocumentContentsView extends ObservableReactComponent<DocumentConte
/**
* Set of all available rendering componets for Docs (e.g., ImageBox, CollectionFreeFormView, etc)
*/
- private static Components: { [key: string]: DocumentContentsViewProps };
- public static Init(defaultLayoutString: string, components: { [key: string]: DocumentContentsViewProps }) {
+ private static Components: { [key: string]: unknown };
+ public static Init(defaultLayoutString: string, components: { [key: string]: unknown }) {
DocumentContentsView.DefaultLayoutString = defaultLayoutString;
DocumentContentsView.Components = components;
}
diff --git a/src/client/views/nodes/FunctionPlotBox.tsx b/src/client/views/nodes/FunctionPlotBox.tsx
index 3d1bd7563..6b439cd64 100644
--- a/src/client/views/nodes/FunctionPlotBox.tsx
+++ b/src/client/views/nodes/FunctionPlotBox.tsx
@@ -1,4 +1,4 @@
-import functionPlot from 'function-plot';
+import functionPlot, { Chart } from 'function-plot';
import { computed, makeObservable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
@@ -22,11 +22,11 @@ export class FunctionPlotBox extends ViewBoxAnnotatableComponent<FieldViewProps>
return FieldView.LayoutString(FunctionPlotBox, fieldKey);
}
public static GraphCount = 0;
- _plot: any;
+ _plot: Chart | undefined;
_plotId = '';
- _plotEle: any;
+ _plotEle: HTMLDivElement | null = null;
- constructor(props: any) {
+ constructor(props: FieldViewProps) {
super(props);
makeObservable(this);
this._plotId = 'graph' + FunctionPlotBox.GraphCount++;
@@ -42,8 +42,10 @@ export class FunctionPlotBox extends ViewBoxAnnotatableComponent<FieldViewProps>
getAnchor = (addAsAnnotation: boolean, pinProps?: PinProps) => {
const anchor = Docs.Create.ConfigDocument({ annotationOn: this.Document });
PinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: { ...(pinProps?.pinData ?? {}), datarange: true } }, this.Document);
- 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 (this._plot) {
+ 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;
};
@@ -68,9 +70,9 @@ export class FunctionPlotBox extends ViewBoxAnnotatableComponent<FieldViewProps>
const width = this._props.PanelWidth();
const height = this._props.PanelHeight();
try {
- this._plotEle.children.length && this._plotEle.removeChild(this._plotEle.children[0]);
+ this._plotEle?.children.length && this._plotEle.removeChild(this._plotEle.children[0]);
this._plot = functionPlot({
- target: '#' + this._plotEle.id,
+ target: '#' + this._plotEle?.id,
width,
height,
xAxis: { domain: Cast(this.layoutDoc.xRange, listSpec('number'), [-10, 10]) },
@@ -104,7 +106,7 @@ export class FunctionPlotBox extends ViewBoxAnnotatableComponent<FieldViewProps>
return false;
};
- _dropDisposer: any;
+ _dropDisposer: DragManager.DragDropDisposer | undefined;
protected createDropTarget = (ele: HTMLDivElement) => {
this._dropDisposer?.();
if (ele) {
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 9e77e0973..95e344004 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -14,7 +14,6 @@ import { SetupDrag } from '../../util/DragManager';
import { CompiledScript } from '../../util/Scripting';
import { undoable } from '../../util/UndoManager';
import { ContextMenu } from '../ContextMenu';
-import { ContextMenuProps } from '../ContextMenuItem';
import { ViewBoxBaseComponent } from '../DocComponent';
import { DocumentIconContainer } from './DocumentIcon';
import { FieldView, FieldViewProps } from './FieldView';
@@ -296,7 +295,7 @@ export class KeyValueBox extends ViewBoxBaseComponent<FieldViewProps>() {
specificContextMenu = (): void => {
const cm = ContextMenu.Instance;
const open = cm.findByDescription('Change Perspective...');
- const openItems: ContextMenuProps[] = open && 'subitems' in open ? open.subitems : [];
+ const openItems = open?.subitems ?? [];
openItems.push({
description: 'Default Perspective',
event: () => {
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index 3023716b1..8e74e1ca2 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -110,7 +110,7 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> {
<td className="keyValuePair-td-value" style={{ width: `${100 - this._props.keyWidth}%` }} onContextMenu={this.onContextMenu}>
<div className="keyValuePair-td-value-container">
<EditableView
- contents={undefined}
+ contents={''}
fieldContents={{
Document: this._props.doc,
childFilters: returnEmptyFilter,
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index c03694dd9..b17275a1e 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -22,7 +22,6 @@ import { undoBatch, UndoManager } from '../../util/UndoManager';
import { CollectionFreeFormView } from '../collections/collectionFreeForm';
import { CollectionStackingView } from '../collections/CollectionStackingView';
import { ContextMenu } from '../ContextMenu';
-import { ContextMenuProps } from '../ContextMenuItem';
import { ViewBoxAnnotatableComponent } from '../DocComponent';
import { Colors } from '../global/globalEnums';
import { PDFViewer } from '../pdf/PDFViewer';
@@ -398,6 +397,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
</button>
</>
);
+
const searchTitle = `${!this._searching ? 'Open' : 'Close'} Search Bar`;
const curPage = NumCast(this.Document._layout_curPage) || 1;
return !this._props.isContentActive() || this._pdfViewer?.isAnnotating ? null : (
@@ -473,14 +473,14 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
specificContextMenu = (): void => {
const cm = ContextMenu.Instance;
const options = cm.findByDescription('Options...');
- const optionItems: ContextMenuProps[] = options && 'subitems' in options ? options.subitems : [];
+ const optionItems = options?.subitems ?? [];
!Doc.noviceMode && optionItems.push({ description: 'Toggle Sidebar Type', event: this.toggleSidebarType, icon: 'expand-arrows-alt' });
!Doc.noviceMode && optionItems.push({ description: 'update icon', event: () => this.pdfUrl && this.updateIcon(), icon: 'expand-arrows-alt' });
// optionItems.push({ description: "Toggle Sidebar ", event: () => this.toggleSidebar(), icon: "expand-arrows-alt" });
!options && ContextMenu.Instance.addItem({ description: 'Options...', subitems: optionItems, icon: 'asterisk' });
const help = cm.findByDescription('Help...');
- const helpItems: ContextMenuProps[] = help && 'subitems' in help ? help.subitems : [];
+ const helpItems = help?.subitems ?? [];
helpItems.push({ description: 'Copy path', event: () => this.pdfUrl && ClientUtils.CopyText(ClientUtils.prepend('') + this.pdfUrl.url.pathname), icon: 'expand-arrows-alt' });
!help && ContextMenu.Instance.addItem({ description: 'Help...', noexpand: true, subitems: helpItems, icon: 'asterisk' });
};
diff --git a/src/client/views/nodes/formattedText/EquationView.tsx b/src/client/views/nodes/formattedText/EquationView.tsx
index 4d0e9efee..df1421a33 100644
--- a/src/client/views/nodes/formattedText/EquationView.tsx
+++ b/src/client/views/nodes/formattedText/EquationView.tsx
@@ -17,7 +17,7 @@ interface IEquationViewInternal {
tbox: FormattedTextBox;
width: number;
height: number;
- getPos: () => number;
+ getPos: () => number | undefined;
setEditor: (editor: EquationEditor | undefined) => void;
}
@@ -47,7 +47,7 @@ export class EquationViewInternal extends React.Component<IEquationViewInternal>
className="equationView"
onKeyDown={e => {
if (e.key === 'Enter') {
- this.props.tbox.EditorView!.dispatch(this.props.tbox.EditorView!.state.tr.setSelection(new TextSelection(this.props.tbox.EditorView!.state.doc.resolve(this.props.getPos() + 1))));
+ this.props.tbox.EditorView!.dispatch(this.props.tbox.EditorView!.state.tr.setSelection(new TextSelection(this.props.tbox.EditorView!.state.doc.resolve((this.props.getPos() ?? 0) + 1))));
this.props.tbox.EditorView!.focus();
e.preventDefault();
}
@@ -82,8 +82,8 @@ export class EquationView {
tbox: FormattedTextBox;
view: EditorView;
_editor: EquationEditor | undefined;
- getPos: () => number;
- constructor(node: Node, view: EditorView, getPos: () => number, tbox: FormattedTextBox) {
+ getPos: () => number | undefined;
+ constructor(node: Node, view: EditorView, getPos: () => number | undefined, tbox: FormattedTextBox) {
this.tbox = tbox;
this.view = view;
this.getPos = getPos;
@@ -109,7 +109,7 @@ export class EquationView {
this._editor?.mathField.focus();
}
selectNode() {
- this.view.dispatch(this.view.state.tr.setSelection(new TextSelection(this.view.state.doc.resolve(this.getPos()))));
+ this.view.dispatch(this.view.state.tr.setSelection(new TextSelection(this.view.state.doc.resolve(this.getPos() ?? 0))));
this.tbox._applyingChange = this.tbox.fieldKey; // setting focus will make prosemirror lose focus, which will cause it to change its selection to a text selection, which causes this view to get rebuilt but it's no longer node selected, so the equationview won't have focus
setTimeout(() => {
this._editor?.mathField.focus();
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index c8b25e184..478039ffa 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -875,7 +875,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
})
);
const appearance = cm.findByDescription('Appearance...');
- const appearanceItems: ContextMenuProps[] = appearance && 'subitems' in appearance ? appearance.subitems : [];
+ const appearanceItems = appearance?.subitems ?? [];
appearanceItems.push({
description: !this.Document._layout_noSidebar ? 'Hide Sidebar Handle' : 'Show Sidebar Handle',
@@ -930,7 +930,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
!appearance && appearanceItems.length && cm.addItem({ description: 'Appearance...', subitems: appearanceItems, icon: 'eye' });
const options = cm.findByDescription('Options...');
- const optionItems = options && 'subitems' in options ? options.subitems : [];
+ const optionItems = options?.subitems ?? [];
optionItems.push({
description: `Toggle auto update from template`,
event: () => {
@@ -959,7 +959,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
});
!options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'eye' });
const help = cm.findByDescription('Help...');
- const helpItems = help && 'subitems' in help ? help.subitems : [];
+ const helpItems = help?.subitems ?? [];
helpItems.push({ description: `show markdown options`, event: () => RTFMarkup.Instance.setOpen(true), icon: <BsMarkdownFill /> });
!help && cm.addItem({ description: 'Help...', subitems: helpItems, icon: 'eye' });
};