-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathexample.py
107 lines (104 loc) · 3.21 KB
/
example.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from prosemirror.model import Node, Schema
basic_spec = {
"nodes": {
"doc": {"content": "block+"},
"paragraph": {
"content": "inline*",
"group": "block",
"parseDOM": [{"tag": "p"}],
},
"blockquote": {
"content": "block+",
"group": "block",
"defining": True,
"parseDOM": [{"tag": "blockquote"}],
},
"horizontal_rule": {"group": "block", "parseDOM": [{"tag": "hr"}]},
"heading": {
"attrs": {"level": {"default": 1}},
"content": "inline*",
"group": "block",
"defining": True,
"parseDOM": [
{"tag": "h1", "attrs": {"level": 1}},
{"tag": "h2", "attrs": {"level": 2}},
{"tag": "h3", "attrs": {"level": 3}},
{"tag": "h4", "attrs": {"level": 4}},
{"tag": "h5", "attrs": {"level": 5}},
{"tag": "h6", "attrs": {"level": 6}},
],
},
"code_block": {
"content": "text*",
"marks": "",
"group": "block",
"code": True,
"defining": True,
"parseDOM": [{"tag": "pre", "preserveWhitespace": "full"}],
},
"text": {"group": "inline"},
"image": {
"inline": True,
"attrs": {"src": {}, "alt": {"default": None}, "title": {"default": None}},
"group": "inline",
"draggable": True,
"parseDOM": [{"tag": "img[src]"}],
},
"hard_break": {
"inline": True,
"group": "inline",
"selectable": False,
"parseDOM": [{"tag": "br"}],
},
"ordered_list": {
"attrs": {"order": {"default": 1}},
"parseDOM": [{"tag": "ol"}],
"content": "list_item+",
"group": "block",
},
"bullet_list": {
"parseDOM": [{"tag": "ul"}],
"content": "list_item+",
"group": "block",
},
"list_item": {
"parseDOM": [{"tag": "li"}],
"defining": True,
"content": "paragraph block*",
},
},
"marks": {
"link": {
"attrs": {"href": {}, "title": {"default": None}},
"inclusive": False,
"parseDOM": [{"tag": "a[href]"}],
},
"em": {
"parseDOM": [{"tag": "i"}, {"tag": "em"}, {"style": "font-style=italic"}],
},
"strong": {
"parseDOM": [{"tag": "strong"}, {"tag": "b"}, {"style": "font-weight"}],
},
"code": {"parseDOM": [{"tag": "code"}]},
},
}
basic_schema = Schema(basic_spec)
basic_doc = {
"type": "doc",
"content": [
{
"type": "heading",
"attrs": {"level": 1},
"content": [{"type": "text", "text": "Fellow"}],
},
{
"type": "paragraph",
"content": [
{"type": "text", "text": "Test "},
{"type": "text", "marks": [{"type": "strong"}], "text": "this"},
{"type": "text", "text": " text"},
],
},
],
}
doc_node = Node.from_json(basic_schema, basic_doc)