chore: Upgrade all of prosemirror (#5366)
Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
@@ -1,16 +1,10 @@
|
||||
import { PluginSimple } from "markdown-it";
|
||||
import { InputRule } from "prosemirror-inputrules";
|
||||
import { NodeType, MarkType, Schema } from "prosemirror-model";
|
||||
import { EditorState, Plugin } from "prosemirror-state";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import { Command, Plugin } from "prosemirror-state";
|
||||
import { Editor } from "../../../app/editor";
|
||||
import { Dispatch } from "../types";
|
||||
|
||||
export type Command = (state: EditorState, dispatch: Dispatch) => boolean;
|
||||
|
||||
export type CommandFactory = (
|
||||
attrs?: Record<string, any>
|
||||
) => (state: EditorState, dispatch: Dispatch, view: EditorView) => boolean;
|
||||
export type CommandFactory = (attrs?: Record<string, any>) => Command;
|
||||
|
||||
export default class Extension {
|
||||
options: any;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PluginSimple } from "markdown-it";
|
||||
import { keymap } from "prosemirror-keymap";
|
||||
import { MarkdownParser, TokenConfig } from "prosemirror-markdown";
|
||||
import { MarkdownParser } from "prosemirror-markdown";
|
||||
import { Schema } from "prosemirror-model";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import { Editor } from "~/editor";
|
||||
@@ -110,19 +110,19 @@ export default class ExtensionManager {
|
||||
rules?: Record<string, any>;
|
||||
plugins?: PluginSimple[];
|
||||
}): MarkdownParser {
|
||||
const tokens: Record<string, TokenConfig> = this.extensions
|
||||
const tokens = this.extensions
|
||||
.filter(
|
||||
(extension) => extension.type === "mark" || extension.type === "node"
|
||||
)
|
||||
.reduce((nodes, extension: Node | Mark) => {
|
||||
const md = extension.parseMarkdown();
|
||||
if (!md) {
|
||||
const parseSpec = extension.parseMarkdown();
|
||||
if (!parseSpec) {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
return {
|
||||
...nodes,
|
||||
[extension.markdownToken || extension.name]: md,
|
||||
[extension.markdownToken || extension.name]: parseSpec,
|
||||
};
|
||||
}, {});
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { EditorState, Transaction } from "prosemirror-state";
|
||||
import { Dispatch } from "../types";
|
||||
import { Command, Transaction } from "prosemirror-state";
|
||||
|
||||
export default function chainTransactions(
|
||||
...commands: ((state: EditorState, dispatch?: Dispatch) => boolean)[]
|
||||
) {
|
||||
return (state: EditorState, dispatch?: Dispatch): boolean => {
|
||||
export default function chainTransactions(...commands: Command[]): Command {
|
||||
return (state, dispatch): boolean => {
|
||||
const dispatcher = (tr: Transaction): void => {
|
||||
state = state.apply(tr);
|
||||
dispatch?.(tr);
|
||||
|
||||
@@ -95,7 +95,7 @@ export function findPlaceholder(
|
||||
state: EditorState,
|
||||
id: string
|
||||
): [number, number] | null {
|
||||
const decos: DecorationSet = uploadPlaceholder.getState(state);
|
||||
const found = decos.find(undefined, undefined, (spec) => spec.id === id);
|
||||
return found.length ? [found[0].from, found[0].to] : null;
|
||||
const decos = uploadPlaceholder.getState(state);
|
||||
const found = decos?.find(undefined, undefined, (spec) => spec.id === id);
|
||||
return found?.length ? [found[0].from, found[0].to] : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user