aboutsummaryrefslogtreecommitdiff
path: root/src/client/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util')
-rw-r--r--src/client/util/ProseMirrorEditorView.tsx8
-rw-r--r--src/client/util/RichTextMenu.tsx13
2 files changed, 11 insertions, 10 deletions
diff --git a/src/client/util/ProseMirrorEditorView.tsx b/src/client/util/ProseMirrorEditorView.tsx
index 3e5fd0604..b42adfbb4 100644
--- a/src/client/util/ProseMirrorEditorView.tsx
+++ b/src/client/util/ProseMirrorEditorView.tsx
@@ -18,23 +18,23 @@ export class ProseMirrorEditorView extends React.Component<ProseMirrorEditorView
private _editorView?: EditorView;
_createEditorView = (element: HTMLDivElement | null) => {
- if (element != null) {
+ if (element !== null) {
this._editorView = new EditorView(element, {
state: this.props.editorState,
dispatchTransaction: this.dispatchTransaction,
});
}
- };
+ }
dispatchTransaction = (tx: any) => {
// In case EditorView makes any modification to a state we funnel those
// modifications up to the parent and apply to the EditorView itself.
const editorState = this.props.editorState.apply(tx);
- if (this._editorView != null) {
+ if (this._editorView) {
this._editorView.updateState(editorState);
}
this.props.onEditorState(editorState);
- };
+ }
focus() {
if (this._editorView) {
diff --git a/src/client/util/RichTextMenu.tsx b/src/client/util/RichTextMenu.tsx
index 639772faa..419d7caf9 100644
--- a/src/client/util/RichTextMenu.tsx
+++ b/src/client/util/RichTextMenu.tsx
@@ -175,7 +175,7 @@ export default class RichTextMenu extends AntimodeMenu {
setMark = (mark: Mark, state: EditorState<any>, dispatch: any) => {
if (mark) {
const node = (state.selection as NodeSelection).node;
- if (node ?.type === schema.nodes.ordered_list) {
+ if (node?.type === schema.nodes.ordered_list) {
let attrs = node.attrs;
if (mark.type === schema.marks.pFontFamily) attrs = { ...attrs, setFontFamily: mark.attrs.family };
if (mark.type === schema.marks.pFontSize) attrs = { ...attrs, setFontSize: mark.attrs.fontSize };
@@ -294,8 +294,8 @@ export default class RichTextMenu extends AntimodeMenu {
e.preventDefault();
e.stopPropagation();
self.view && self.view.focus();
- self.view && command && command(self.view!.state, self.view!.dispatch, self.view);
- self.view && onclick && onclick(self.view!.state, self.view!.dispatch, self.view);
+ self.view && command && command(self.view.state, self.view.dispatch, self.view);
+ self.view && onclick && onclick(self.view.state, self.view.dispatch, self.view);
self.setActiveMarkButtons(self.getActiveMarksOnSelection());
}
@@ -602,7 +602,7 @@ export default class RichTextMenu extends AntimodeMenu {
const link = this.currentLink ? this.currentLink : "";
- const button = <FontAwesomeIcon icon="link" size="lg" />
+ const button = <FontAwesomeIcon icon="link" size="lg" />;
const dropdownContent =
<div className="dropdown link-menu">
@@ -684,8 +684,9 @@ export default class RichTextMenu extends AntimodeMenu {
}
} else {
if (node) {
- const extension = this.linkExtend(this.view!.state.selection.$anchor, href);
- this.view!.dispatch(this.view!.state.tr.removeMark(extension.from, extension.to, this.view!.state.schema.marks.link));
+ const { tr, schema, selection } = this.view.state;
+ const extension = this.linkExtend(selection.$anchor, href);
+ this.view.dispatch(tr.removeMark(extension.from, extension.to, schema.marks.link));
}
}
}