1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import {
inputRules,
wrappingInputRule,
textblockTypeInputRule,
smartQuotes,
emDash,
ellipsis
} from "prosemirror-inputrules";
import { Schema, NodeSpec, MarkSpec, DOMOutputSpecArray, NodeType } from "prosemirror-model";
import { schema } from "./RichTextSchema";
export const inpRules = {
rules: [
...smartQuotes,
ellipsis,
emDash,
// > blockquote
wrappingInputRule(/^\s*>\s$/, schema.nodes.blockquote),
// 1. ordered list
wrappingInputRule(
/^(\d+)\.\s$/,
schema.nodes.ordered_list,
match => ({ order: +match[1] }),
(match, node) => node.childCount + node.attrs.order === +match[1]
),
// * bullet list
wrappingInputRule(/^\s*([-+*])\s$/, schema.nodes.bullet_list),
// ``` code block
textblockTypeInputRule(/^```$/, schema.nodes.code_block),
// # heading
textblockTypeInputRule(
new RegExp("^(#{1,6})\\s$"),
schema.nodes.heading,
match => ({ level: match[1].length })
)
]
};
|