chore: Upgrade all of prosemirror (#5366)

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
Tom Moor
2023-05-24 22:24:05 -04:00
committed by GitHub
parent e340e568e2
commit d5341a486c
77 changed files with 875 additions and 675 deletions

View File

@@ -1,12 +1,12 @@
import Token from "markdown-it/lib/token";
import { InputRule } from "prosemirror-inputrules";
import { Node as ProsemirrorNode, NodeSpec, NodeType } from "prosemirror-model";
import { NodeSelection, EditorState, Plugin } from "prosemirror-state";
import { NodeSelection, Plugin, Command } from "prosemirror-state";
import * as React from "react";
import { sanitizeUrl } from "../../utils/urls";
import { default as ImageComponent, Caption } from "../components/Image";
import { MarkdownSerializerState } from "../lib/markdown/serializer";
import { ComponentProps, Dispatch } from "../types";
import { ComponentProps } from "../types";
import SimpleImage from "./SimpleImage";
const imageSizeRegex = /\s=(\d+)?x(\d+)?$/;
@@ -282,7 +282,7 @@ export default class Image extends SimpleImage {
commands({ type }: { type: NodeType }) {
return {
...super.commands({ type }),
downloadImage: () => (state: EditorState) => {
downloadImage: (): Command => (state) => {
if (!(state.selection instanceof NodeSelection)) {
return false;
}
@@ -296,7 +296,7 @@ export default class Image extends SimpleImage {
return true;
},
alignRight: () => (state: EditorState, dispatch: Dispatch) => {
alignRight: (): Command => (state, dispatch) => {
if (!(state.selection instanceof NodeSelection)) {
return false;
}
@@ -306,10 +306,10 @@ export default class Image extends SimpleImage {
layoutClass: "right-50",
};
const { selection } = state;
dispatch(state.tr.setNodeMarkup(selection.from, undefined, attrs));
dispatch?.(state.tr.setNodeMarkup(selection.from, undefined, attrs));
return true;
},
alignLeft: () => (state: EditorState, dispatch: Dispatch) => {
alignLeft: (): Command => (state, dispatch) => {
if (!(state.selection instanceof NodeSelection)) {
return false;
}
@@ -319,10 +319,10 @@ export default class Image extends SimpleImage {
layoutClass: "left-50",
};
const { selection } = state;
dispatch(state.tr.setNodeMarkup(selection.from, undefined, attrs));
dispatch?.(state.tr.setNodeMarkup(selection.from, undefined, attrs));
return true;
},
alignFullWidth: () => (state: EditorState, dispatch: Dispatch) => {
alignFullWidth: (): Command => (state, dispatch) => {
if (!(state.selection instanceof NodeSelection)) {
return false;
}
@@ -332,16 +332,16 @@ export default class Image extends SimpleImage {
layoutClass: "full-width",
};
const { selection } = state;
dispatch(state.tr.setNodeMarkup(selection.from, undefined, attrs));
dispatch?.(state.tr.setNodeMarkup(selection.from, undefined, attrs));
return true;
},
alignCenter: () => (state: EditorState, dispatch: Dispatch) => {
alignCenter: (): Command => (state, dispatch) => {
if (!(state.selection instanceof NodeSelection)) {
return false;
}
const attrs = { ...state.selection.node.attrs, layoutClass: null };
const { selection } = state;
dispatch(state.tr.setNodeMarkup(selection.from, undefined, attrs));
dispatch?.(state.tr.setNodeMarkup(selection.from, undefined, attrs));
return true;
},
};