aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-08-09 16:48:18 -0400
committerbobzel <zzzman@gmail.com>2024-08-09 16:48:18 -0400
commit762ac2bf354e4cc2c4b15f42502da939f5061646 (patch)
tree7c7b2a908d66b08372dbe13956d749b966487ce7 /src/client/views/nodes/formattedText
parent4574b7f03ccc85c4bebdbfd9475788456086704f (diff)
a bunch more typing fixes.
Diffstat (limited to 'src/client/views/nodes/formattedText')
-rw-r--r--src/client/views/nodes/formattedText/EquationView.tsx10
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx6
2 files changed, 8 insertions, 8 deletions
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' });
};