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,7 +1,7 @@
import Token from "markdown-it/lib/token";
import { InputRule } from "prosemirror-inputrules";
import { Node as ProsemirrorNode, NodeSpec, NodeType } from "prosemirror-model";
import { TextSelection, NodeSelection, EditorState } from "prosemirror-state";
import { TextSelection, NodeSelection, Command } from "prosemirror-state";
import * as React from "react";
import { getEventFiles } from "../../utils/files";
import { sanitizeUrl } from "../../utils/urls";
@@ -11,7 +11,7 @@ import { default as ImageComponent } from "../components/Image";
import { MarkdownSerializerState } from "../lib/markdown/serializer";
import uploadPlaceholderPlugin from "../lib/uploadPlaceholder";
import uploadPlugin from "../lib/uploadPlugin";
import { ComponentProps, Dispatch } from "../types";
import { ComponentProps } from "../types";
import Node from "./Node";
export default class SimpleImage extends Node {
@@ -171,11 +171,11 @@ export default class SimpleImage extends Node {
commands({ type }: { type: NodeType }) {
return {
deleteImage: () => (state: EditorState, dispatch: Dispatch) => {
dispatch(state.tr.deleteSelection());
deleteImage: (): Command => (state, dispatch) => {
dispatch?.(state.tr.deleteSelection());
return true;
},
replaceImage: () => (state: EditorState) => {
replaceImage: (): Command => (state) => {
if (!(state.selection instanceof NodeSelection)) {
return false;
}
@@ -214,8 +214,8 @@ export default class SimpleImage extends Node {
return true;
},
createImage:
(attrs: Record<string, any>) =>
(state: EditorState, dispatch: Dispatch) => {
(attrs: Record<string, any>): Command =>
(state, dispatch) => {
const { selection } = state;
const position =
selection instanceof TextSelection
@@ -227,7 +227,7 @@ export default class SimpleImage extends Node {
const node = type.create(attrs);
const transaction = state.tr.insert(position, node);
dispatch(transaction);
dispatch?.(transaction);
return true;
},
};