medium-proeditor
Version:
A powerful & customizable Medium-style rich text editor
44 lines • 1.35 kB
TypeScript
import type { Schema } from 'prosemirror-model';
import { type EditorState, Plugin } from 'prosemirror-state';
import type { Editor } from './Editor';
import type { Commands, ExtendedRegExpMatchArray, Range } from './types';
import type { EditorView } from 'prosemirror-view';
export type InputRuleMatch = {
index: number;
text: string;
replaceWith?: string;
match?: RegExpMatchArray;
data?: Record<string, any>;
};
export type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
export declare class InputRule {
find: InputRuleFinder;
handler: (props: {
state: EditorState;
range: Range;
match: ExtendedRegExpMatchArray;
commands: Commands;
}) => void;
constructor(config: {
find: InputRuleFinder;
handler: (props: {
state: EditorState;
range: Range;
match: ExtendedRegExpMatchArray;
commands: Commands;
}) => void;
});
}
/**
* Create an input rules plugin. When enabled, it will cause text
* input that matches any of the given rules to trigger the rule’s
* action.
*/
export declare function inputRulesPlugin(props: {
editor: Editor;
view: EditorView;
schema: Schema;
commands: Commands;
rules: InputRule[];
}): Plugin;
//# sourceMappingURL=InputRule.d.ts.map