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,10 @@
import { toggleMark } from "prosemirror-commands";
import { MarkSpec, MarkType, Schema } from "prosemirror-model";
import { EditorState, Plugin } from "prosemirror-state";
import { Command, Plugin } from "prosemirror-state";
import { v4 as uuidv4 } from "uuid";
import collapseSelection from "../commands/collapseSelection";
import { Command } from "../lib/Extension";
import chainTransactions from "../lib/chainTransactions";
import isMarkActive from "../queries/isMarkActive";
import { Dispatch } from "../types";
import Mark from "./Mark";
export default class Comment extends Mark {
@@ -32,7 +30,7 @@ export default class Comment extends Mark {
keys({ type }: { type: MarkType }): Record<string, Command> {
return this.options.onCreateCommentMark
? {
"Mod-Alt-m": (state: EditorState, dispatch: Dispatch) => {
"Mod-Alt-m": (state, dispatch) => {
if (isMarkActive(state.schema.marks.comment)(state)) {
return false;
}
@@ -53,7 +51,7 @@ export default class Comment extends Mark {
commands({ type }: { type: MarkType; schema: Schema }) {
return this.options.onCreateCommentMark
? () => (state: EditorState, dispatch: Dispatch) => {
? (): Command => (state, dispatch) => {
if (isMarkActive(state.schema.marks.comment)(state)) {
return false;
}

View File

@@ -1,7 +1,7 @@
import { toggleMark } from "prosemirror-commands";
import { InputRule } from "prosemirror-inputrules";
import { MarkSpec, MarkType } from "prosemirror-model";
import { Command } from "../lib/Extension";
import { Command } from "prosemirror-state";
import markInputRule from "../lib/markInputRule";
import Mark from "./Mark";

View File

@@ -9,7 +9,7 @@ import {
Node,
Mark as ProsemirrorMark,
} from "prosemirror-model";
import { EditorState, Plugin } from "prosemirror-state";
import { Command, EditorState, Plugin } from "prosemirror-state";
import { Decoration, DecorationSet, EditorView } from "prosemirror-view";
import * as React from "react";
import ReactDOM from "react-dom";
@@ -17,7 +17,7 @@ import { isExternalUrl, sanitizeUrl } from "../../utils/urls";
import findLinkNodes from "../queries/findLinkNodes";
import getMarkRange from "../queries/getMarkRange";
import isMarkActive from "../queries/isMarkActive";
import { EventType, Dispatch } from "../types";
import { EventType } from "../types";
import Mark from "./Mark";
const LINK_INPUT_REGEX = /\[([^[]+)]\((\S+)\)$/;
@@ -113,9 +113,9 @@ export default class Link extends Mark {
];
}
keys({ type }: { type: MarkType }) {
keys({ type }: { type: MarkType }): Record<string, Command> {
return {
"Mod-k": (state: EditorState, dispatch: Dispatch) => {
"Mod-k": (state, dispatch) => {
if (state.selection.empty) {
this.editor.events.emit(EventType.LinkToolbarOpen);
return true;
@@ -123,7 +123,7 @@ export default class Link extends Mark {
return toggleMark(type, { href: "" })(state, dispatch);
},
"Mod-Enter": (state: EditorState) => {
"Mod-Enter": (state) => {
if (isMarkActive(type)(state)) {
const range = getMarkRange(
state.selection.$from,
@@ -303,7 +303,7 @@ export default class Link extends Mark {
? ">"
: "](" +
state.esc(mark.attrs.href) +
(mark.attrs.title ? " " + state.quote(mark.attrs.title) : "") +
(mark.attrs.title ? " " + this.quote(mark.attrs.title) : "") +
")";
},
};
@@ -318,4 +318,10 @@ export default class Link extends Mark {
}),
};
}
private quote(str: string) {
const wrap =
str.indexOf('"') === -1 ? '""' : str.indexOf("'") === -1 ? "''" : "()";
return wrap[0] + str + wrap[1];
}
}

View File

@@ -1,13 +1,14 @@
import { toggleMark } from "prosemirror-commands";
import { InputRule } from "prosemirror-inputrules";
import { TokenConfig } from "prosemirror-markdown";
import { ParseSpec } from "prosemirror-markdown";
import {
MarkSpec,
MarkType,
Node as ProsemirrorNode,
Schema,
} from "prosemirror-model";
import Extension, { Command, CommandFactory } from "../lib/Extension";
import { Command } from "prosemirror-state";
import Extension, { CommandFactory } from "../lib/Extension";
import { MarkdownSerializerState } from "../lib/markdown/serializer";
export default abstract class Mark extends Extension {
@@ -35,7 +36,7 @@ export default abstract class Mark extends Extension {
throw new Error("toMarkdown not implemented");
}
parseMarkdown(): TokenConfig | void {
parseMarkdown(): ParseSpec | void {
return undefined;
}