prosemirror-schema-basic 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -4
- package/README.md +6 -6
- package/dist/index.cjs +232 -0
- package/dist/index.d.ts +87 -0
- package/dist/{index.mjs → index.es.js} +1 -1
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +171 -169
- package/dist/index.js.map +1 -1
- package/package.json +14 -9
- package/src/schema-basic.ts +158 -0
- package/dist/index.mjs.map +0 -1
- package/rollup.config.js +0 -14
- package/src/schema-basic.js +0 -159
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 1.2.0 (2022-05-30)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
Include TypeScript type declarations.
|
|
6
|
+
|
|
7
|
+
## 1.1.2 (2019-11-20)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Rename ES module files to use a .js extension, since Webpack gets confused by .mjs
|
|
12
|
+
|
|
1
13
|
## 1.1.1 (2019-11-19)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
|
@@ -35,11 +47,11 @@ Don't treat \<b style=font-weight: normal> as strong when parsing.
|
|
|
35
47
|
|
|
36
48
|
Moved into a separate module.
|
|
37
49
|
|
|
38
|
-
No longer exports the [specs](
|
|
50
|
+
No longer exports the [specs](https://prosemirror.net/docs/ref/version/0.11.0.html#model.NodeSpec) for the nodes and
|
|
39
51
|
marks separately, since they are now plain objects, not subclasses.
|
|
40
|
-
They are still exported through [nodes](
|
|
41
|
-
[marks](
|
|
52
|
+
They are still exported through [nodes](https://prosemirror.net/docs/ref/version/0.11.0.html#schema-basic.nodes) and
|
|
53
|
+
[marks](https://prosemirror.net/docs/ref/version/0.11.0.html#schema-basic.marks) objects.
|
|
42
54
|
|
|
43
|
-
The list-related nodes were moved to the [schema-list](
|
|
55
|
+
The list-related nodes were moved to the [schema-list](https://prosemirror.net/docs/ref/version/0.11.0.html#schema-list)
|
|
44
56
|
module.
|
|
45
57
|
|
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# prosemirror-schema-basic
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](
|
|
3
|
+
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**GITTER**](https://gitter.im/ProseMirror/prosemirror) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
|
-
This is a [schema module](
|
|
5
|
+
This is a [schema module](https://prosemirror.net/docs/ref/#schema-basic) for [ProseMirror](https://prosemirror.net).
|
|
6
6
|
ProseMirror is a well-behaved rich semantic content editor based on
|
|
7
7
|
contentEditable, with support for collaborative editing and custom
|
|
8
8
|
document schemas.
|
|
9
9
|
|
|
10
|
-
This [module](
|
|
10
|
+
This [module](https://prosemirror.net/docs/ref/#schema-basic) defines a
|
|
11
11
|
basic ProseMirror document schema, whose elements can be reused in
|
|
12
12
|
other schemas.
|
|
13
13
|
|
|
14
|
-
The [project page](
|
|
15
|
-
number of [examples](
|
|
16
|
-
[documentation](
|
|
14
|
+
The [project page](https://prosemirror.net) has more information, a
|
|
15
|
+
number of [examples](https://prosemirror.net/examples/) and the
|
|
16
|
+
[documentation](https://prosemirror.net/docs/).
|
|
17
17
|
|
|
18
18
|
This code is released under an
|
|
19
19
|
[MIT license](https://github.com/prosemirror/prosemirror/tree/master/LICENSE).
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var prosemirrorModel = require('prosemirror-model');
|
|
8
|
+
|
|
9
|
+
var pDOM = ["p", 0],
|
|
10
|
+
blockquoteDOM = ["blockquote", 0],
|
|
11
|
+
hrDOM = ["hr"],
|
|
12
|
+
preDOM = ["pre", ["code", 0]],
|
|
13
|
+
brDOM = ["br"];
|
|
14
|
+
var nodes = {
|
|
15
|
+
doc: {
|
|
16
|
+
content: "block+"
|
|
17
|
+
},
|
|
18
|
+
paragraph: {
|
|
19
|
+
content: "inline*",
|
|
20
|
+
group: "block",
|
|
21
|
+
parseDOM: [{
|
|
22
|
+
tag: "p"
|
|
23
|
+
}],
|
|
24
|
+
toDOM: function toDOM() {
|
|
25
|
+
return pDOM;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
blockquote: {
|
|
29
|
+
content: "block+",
|
|
30
|
+
group: "block",
|
|
31
|
+
defining: true,
|
|
32
|
+
parseDOM: [{
|
|
33
|
+
tag: "blockquote"
|
|
34
|
+
}],
|
|
35
|
+
toDOM: function toDOM() {
|
|
36
|
+
return blockquoteDOM;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
horizontal_rule: {
|
|
40
|
+
group: "block",
|
|
41
|
+
parseDOM: [{
|
|
42
|
+
tag: "hr"
|
|
43
|
+
}],
|
|
44
|
+
toDOM: function toDOM() {
|
|
45
|
+
return hrDOM;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
heading: {
|
|
49
|
+
attrs: {
|
|
50
|
+
level: {
|
|
51
|
+
"default": 1
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
content: "inline*",
|
|
55
|
+
group: "block",
|
|
56
|
+
defining: true,
|
|
57
|
+
parseDOM: [{
|
|
58
|
+
tag: "h1",
|
|
59
|
+
attrs: {
|
|
60
|
+
level: 1
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
tag: "h2",
|
|
64
|
+
attrs: {
|
|
65
|
+
level: 2
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
tag: "h3",
|
|
69
|
+
attrs: {
|
|
70
|
+
level: 3
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
tag: "h4",
|
|
74
|
+
attrs: {
|
|
75
|
+
level: 4
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
tag: "h5",
|
|
79
|
+
attrs: {
|
|
80
|
+
level: 5
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
tag: "h6",
|
|
84
|
+
attrs: {
|
|
85
|
+
level: 6
|
|
86
|
+
}
|
|
87
|
+
}],
|
|
88
|
+
toDOM: function toDOM(node) {
|
|
89
|
+
return ["h" + node.attrs.level, 0];
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
code_block: {
|
|
93
|
+
content: "text*",
|
|
94
|
+
marks: "",
|
|
95
|
+
group: "block",
|
|
96
|
+
code: true,
|
|
97
|
+
defining: true,
|
|
98
|
+
parseDOM: [{
|
|
99
|
+
tag: "pre",
|
|
100
|
+
preserveWhitespace: "full"
|
|
101
|
+
}],
|
|
102
|
+
toDOM: function toDOM() {
|
|
103
|
+
return preDOM;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
text: {
|
|
107
|
+
group: "inline"
|
|
108
|
+
},
|
|
109
|
+
image: {
|
|
110
|
+
inline: true,
|
|
111
|
+
attrs: {
|
|
112
|
+
src: {},
|
|
113
|
+
alt: {
|
|
114
|
+
"default": null
|
|
115
|
+
},
|
|
116
|
+
title: {
|
|
117
|
+
"default": null
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
group: "inline",
|
|
121
|
+
draggable: true,
|
|
122
|
+
parseDOM: [{
|
|
123
|
+
tag: "img[src]",
|
|
124
|
+
getAttrs: function getAttrs(dom) {
|
|
125
|
+
return {
|
|
126
|
+
src: dom.getAttribute("src"),
|
|
127
|
+
title: dom.getAttribute("title"),
|
|
128
|
+
alt: dom.getAttribute("alt")
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}],
|
|
132
|
+
toDOM: function toDOM(node) {
|
|
133
|
+
var _node$attrs = node.attrs,
|
|
134
|
+
src = _node$attrs.src,
|
|
135
|
+
alt = _node$attrs.alt,
|
|
136
|
+
title = _node$attrs.title;
|
|
137
|
+
return ["img", {
|
|
138
|
+
src: src,
|
|
139
|
+
alt: alt,
|
|
140
|
+
title: title
|
|
141
|
+
}];
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
hard_break: {
|
|
145
|
+
inline: true,
|
|
146
|
+
group: "inline",
|
|
147
|
+
selectable: false,
|
|
148
|
+
parseDOM: [{
|
|
149
|
+
tag: "br"
|
|
150
|
+
}],
|
|
151
|
+
toDOM: function toDOM() {
|
|
152
|
+
return brDOM;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var emDOM = ["em", 0],
|
|
157
|
+
strongDOM = ["strong", 0],
|
|
158
|
+
codeDOM = ["code", 0];
|
|
159
|
+
var marks = {
|
|
160
|
+
link: {
|
|
161
|
+
attrs: {
|
|
162
|
+
href: {},
|
|
163
|
+
title: {
|
|
164
|
+
"default": null
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
inclusive: false,
|
|
168
|
+
parseDOM: [{
|
|
169
|
+
tag: "a[href]",
|
|
170
|
+
getAttrs: function getAttrs(dom) {
|
|
171
|
+
return {
|
|
172
|
+
href: dom.getAttribute("href"),
|
|
173
|
+
title: dom.getAttribute("title")
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}],
|
|
177
|
+
toDOM: function toDOM(node) {
|
|
178
|
+
var _node$attrs2 = node.attrs,
|
|
179
|
+
href = _node$attrs2.href,
|
|
180
|
+
title = _node$attrs2.title;
|
|
181
|
+
return ["a", {
|
|
182
|
+
href: href,
|
|
183
|
+
title: title
|
|
184
|
+
}, 0];
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
em: {
|
|
188
|
+
parseDOM: [{
|
|
189
|
+
tag: "i"
|
|
190
|
+
}, {
|
|
191
|
+
tag: "em"
|
|
192
|
+
}, {
|
|
193
|
+
style: "font-style=italic"
|
|
194
|
+
}],
|
|
195
|
+
toDOM: function toDOM() {
|
|
196
|
+
return emDOM;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
strong: {
|
|
200
|
+
parseDOM: [{
|
|
201
|
+
tag: "strong"
|
|
202
|
+
}, {
|
|
203
|
+
tag: "b",
|
|
204
|
+
getAttrs: function getAttrs(node) {
|
|
205
|
+
return node.style.fontWeight != "normal" && null;
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
style: "font-weight",
|
|
209
|
+
getAttrs: function getAttrs(value) {
|
|
210
|
+
return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
|
|
211
|
+
}
|
|
212
|
+
}],
|
|
213
|
+
toDOM: function toDOM() {
|
|
214
|
+
return strongDOM;
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
code: {
|
|
218
|
+
parseDOM: [{
|
|
219
|
+
tag: "code"
|
|
220
|
+
}],
|
|
221
|
+
toDOM: function toDOM() {
|
|
222
|
+
return codeDOM;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var schema = new prosemirrorModel.Schema({
|
|
227
|
+
nodes: nodes,
|
|
228
|
+
marks: marks
|
|
229
|
+
});
|
|
230
|
+
exports.marks = marks;
|
|
231
|
+
exports.nodes = nodes;
|
|
232
|
+
exports.schema = schema;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
[Specs](https://prosemirror.net/docs/ref/#model.NodeSpec) for the nodes defined in this schema.
|
|
5
|
+
*/
|
|
6
|
+
declare const nodes: {
|
|
7
|
+
/**
|
|
8
|
+
NodeSpec The top level document node.
|
|
9
|
+
*/
|
|
10
|
+
doc: NodeSpec;
|
|
11
|
+
/**
|
|
12
|
+
A plain paragraph textblock. Represented in the DOM
|
|
13
|
+
as a `<p>` element.
|
|
14
|
+
*/
|
|
15
|
+
paragraph: NodeSpec;
|
|
16
|
+
/**
|
|
17
|
+
A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
18
|
+
*/
|
|
19
|
+
blockquote: NodeSpec;
|
|
20
|
+
/**
|
|
21
|
+
A horizontal rule (`<hr>`).
|
|
22
|
+
*/
|
|
23
|
+
horizontal_rule: NodeSpec;
|
|
24
|
+
/**
|
|
25
|
+
A heading textblock, with a `level` attribute that
|
|
26
|
+
should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
27
|
+
`<h6>` elements.
|
|
28
|
+
*/
|
|
29
|
+
heading: NodeSpec;
|
|
30
|
+
/**
|
|
31
|
+
A code listing. Disallows marks or non-text inline
|
|
32
|
+
nodes by default. Represented as a `<pre>` element with a
|
|
33
|
+
`<code>` element inside of it.
|
|
34
|
+
*/
|
|
35
|
+
code_block: NodeSpec;
|
|
36
|
+
/**
|
|
37
|
+
The text node.
|
|
38
|
+
*/
|
|
39
|
+
text: NodeSpec;
|
|
40
|
+
/**
|
|
41
|
+
An inline image (`<img>`) node. Supports `src`,
|
|
42
|
+
`alt`, and `href` attributes. The latter two default to the empty
|
|
43
|
+
string.
|
|
44
|
+
*/
|
|
45
|
+
image: NodeSpec;
|
|
46
|
+
/**
|
|
47
|
+
A hard line break, represented in the DOM as `<br>`.
|
|
48
|
+
*/
|
|
49
|
+
hard_break: NodeSpec;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
[Specs](https://prosemirror.net/docs/ref/#model.MarkSpec) for the marks in the schema.
|
|
53
|
+
*/
|
|
54
|
+
declare const marks: {
|
|
55
|
+
/**
|
|
56
|
+
A link. Has `href` and `title` attributes. `title`
|
|
57
|
+
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
58
|
+
element.
|
|
59
|
+
*/
|
|
60
|
+
link: MarkSpec;
|
|
61
|
+
/**
|
|
62
|
+
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
63
|
+
that also match `<i>` and `font-style: italic`.
|
|
64
|
+
*/
|
|
65
|
+
em: MarkSpec;
|
|
66
|
+
/**
|
|
67
|
+
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
68
|
+
`<b>` and `font-weight: bold`.
|
|
69
|
+
*/
|
|
70
|
+
strong: MarkSpec;
|
|
71
|
+
/**
|
|
72
|
+
Code font mark. Represented as a `<code>` element.
|
|
73
|
+
*/
|
|
74
|
+
code: MarkSpec;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
This schema roughly corresponds to the document schema used by
|
|
78
|
+
[CommonMark](http://commonmark.org/), minus the list elements,
|
|
79
|
+
which are defined in the [`prosemirror-schema-list`](https://prosemirror.net/docs/ref/#schema-list)
|
|
80
|
+
module.
|
|
81
|
+
|
|
82
|
+
To reuse elements from this schema, extend or read from its
|
|
83
|
+
`spec.nodes` and `spec.marks` [properties](https://prosemirror.net/docs/ref/#model.Schema.spec).
|
|
84
|
+
*/
|
|
85
|
+
declare const schema: Schema;
|
|
86
|
+
|
|
87
|
+
export { marks, nodes, schema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/schema-basic.js"],"sourcesContent":["import {Schema} from \"prosemirror-model\"\n\nconst pDOM = [\"p\", 0], blockquoteDOM = [\"blockquote\", 0], hrDOM = [\"hr\"],\n preDOM = [\"pre\", [\"code\", 0]], brDOM = [\"br\"]\n\n// :: Object\n// [Specs](#model.NodeSpec) for the nodes defined in this schema.\nexport const nodes = {\n // :: NodeSpec The top level document node.\n doc: {\n content: \"block+\"\n },\n\n // :: NodeSpec A plain paragraph textblock. Represented in the DOM\n // as a `<p>` element.\n paragraph: {\n content: \"inline*\",\n group: \"block\",\n parseDOM: [{tag: \"p\"}],\n toDOM() { return pDOM }\n },\n\n // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.\n blockquote: {\n content: \"block+\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"blockquote\"}],\n toDOM() { return blockquoteDOM }\n },\n\n // :: NodeSpec A horizontal rule (`<hr>`).\n horizontal_rule: {\n group: \"block\",\n parseDOM: [{tag: \"hr\"}],\n toDOM() { return hrDOM }\n },\n\n // :: NodeSpec A heading textblock, with a `level` attribute that\n // should hold the number 1 to 6. Parsed and serialized as `<h1>` to\n // `<h6>` elements.\n heading: {\n attrs: {level: {default: 1}},\n content: \"inline*\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"h1\", attrs: {level: 1}},\n {tag: \"h2\", attrs: {level: 2}},\n {tag: \"h3\", attrs: {level: 3}},\n {tag: \"h4\", attrs: {level: 4}},\n {tag: \"h5\", attrs: {level: 5}},\n {tag: \"h6\", attrs: {level: 6}}],\n toDOM(node) { return [\"h\" + node.attrs.level, 0] }\n },\n\n // :: NodeSpec A code listing. Disallows marks or non-text inline\n // nodes by default. Represented as a `<pre>` element with a\n // `<code>` element inside of it.\n code_block: {\n content: \"text*\",\n marks: \"\",\n group: \"block\",\n code: true,\n defining: true,\n parseDOM: [{tag: \"pre\", preserveWhitespace: \"full\"}],\n toDOM() { return preDOM }\n },\n\n // :: NodeSpec The text node.\n text: {\n group: \"inline\"\n },\n\n // :: NodeSpec An inline image (`<img>`) node. Supports `src`,\n // `alt`, and `href` attributes. The latter two default to the empty\n // string.\n image: {\n inline: true,\n attrs: {\n src: {},\n alt: {default: null},\n title: {default: null}\n },\n group: \"inline\",\n draggable: true,\n parseDOM: [{tag: \"img[src]\", getAttrs(dom) {\n return {\n src: dom.getAttribute(\"src\"),\n title: dom.getAttribute(\"title\"),\n alt: dom.getAttribute(\"alt\")\n }\n }}],\n toDOM(node) { let {src, alt, title} = node.attrs; return [\"img\", {src, alt, title}] }\n },\n\n // :: NodeSpec A hard line break, represented in the DOM as `<br>`.\n hard_break: {\n inline: true,\n group: \"inline\",\n selectable: false,\n parseDOM: [{tag: \"br\"}],\n toDOM() { return brDOM }\n }\n}\n\nconst emDOM = [\"em\", 0], strongDOM = [\"strong\", 0], codeDOM = [\"code\", 0]\n\n// :: Object [Specs](#model.MarkSpec) for the marks in the schema.\nexport const marks = {\n // :: MarkSpec A link. Has `href` and `title` attributes. `title`\n // defaults to the empty string. Rendered and parsed as an `<a>`\n // element.\n link: {\n attrs: {\n href: {},\n title: {default: null}\n },\n inclusive: false,\n parseDOM: [{tag: \"a[href]\", getAttrs(dom) {\n return {href: dom.getAttribute(\"href\"), title: dom.getAttribute(\"title\")}\n }}],\n toDOM(node) { let {href, title} = node.attrs; return [\"a\", {href, title}, 0] }\n },\n\n // :: MarkSpec An emphasis mark. Rendered as an `<em>` element.\n // Has parse rules that also match `<i>` and `font-style: italic`.\n em: {\n parseDOM: [{tag: \"i\"}, {tag: \"em\"}, {style: \"font-style=italic\"}],\n toDOM() { return emDOM }\n },\n\n // :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules\n // also match `<b>` and `font-weight: bold`.\n strong: {\n parseDOM: [{tag: \"strong\"},\n // This works around a Google Docs misbehavior where\n // pasted content will be inexplicably wrapped in `<b>`\n // tags with a font-weight normal.\n {tag: \"b\", getAttrs: node => node.style.fontWeight != \"normal\" && null},\n {style: \"font-weight\", getAttrs: value => /^(bold(er)?|[5-9]\\d{2,})$/.test(value) && null}],\n toDOM() { return strongDOM }\n },\n\n // :: MarkSpec Code font mark. Represented as a `<code>` element.\n code: {\n parseDOM: [{tag: \"code\"}],\n toDOM() { return codeDOM }\n }\n}\n\n// :: Schema\n// This schema roughly corresponds to the document schema used by\n// [CommonMark](http://commonmark.org/), minus the list elements,\n// which are defined in the [`prosemirror-schema-list`](#schema-list)\n// module.\n//\n// To reuse elements from this schema, extend or read from its\n// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).\nexport const schema = new Schema({nodes, marks})\n"],"names":["const"],"mappings":";;AAEAA,IAAM,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,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C,GAAG,EAAE,QAAQ,CAAC;AAC9B;AACA;AACA;AACA,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,YAAE,IAAI,EAAA,EAAA,OAAI,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,QAAQ,IAAI,OAAI,CAAC;AACtF,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,YAAE,KAAK,EAAA,EAAA,OAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAA,CAAA,EAAI,CAAC,CAAC;AAC1G,IAAI,KAAK,EAAA,SAAA,KAAA,GAAG,EAAE,OAAO,SAAS,EAAE;AAChC,GAAG;AACH;AACA;AACA,EAAE,IAAI,EAAE;AACR,IAAI,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC7B,IAAI,KAAK,EAAA,SAAA,KAAA,GAAG,EAAE,OAAO,OAAO,EAAE;AAC9B,GAAG;AACH,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,IAAC,MAAM,GAAG,IAAI,MAAM,CAAC,CAAA,KAAA,EAAC,KAAK,EAAA,KAAA,EAAE,KAAK,CAAC;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,173 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// :: NodeSpec The top level document node.
|
|
14
|
-
doc: {
|
|
15
|
-
content: "block+"
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
|
|
19
|
-
// as a `<p>` element.
|
|
20
|
-
paragraph: {
|
|
21
|
-
content: "inline*",
|
|
22
|
-
group: "block",
|
|
23
|
-
parseDOM: [{tag: "p"}],
|
|
24
|
-
toDOM: function toDOM() { return pDOM }
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
28
|
-
blockquote: {
|
|
29
|
-
content: "block+",
|
|
30
|
-
group: "block",
|
|
31
|
-
defining: true,
|
|
32
|
-
parseDOM: [{tag: "blockquote"}],
|
|
33
|
-
toDOM: function toDOM() { return blockquoteDOM }
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
37
|
-
horizontal_rule: {
|
|
38
|
-
group: "block",
|
|
39
|
-
parseDOM: [{tag: "hr"}],
|
|
40
|
-
toDOM: function toDOM() { return hrDOM }
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
// :: NodeSpec A heading textblock, with a `level` attribute that
|
|
44
|
-
// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
45
|
-
// `<h6>` elements.
|
|
46
|
-
heading: {
|
|
47
|
-
attrs: {level: {default: 1}},
|
|
48
|
-
content: "inline*",
|
|
49
|
-
group: "block",
|
|
50
|
-
defining: true,
|
|
51
|
-
parseDOM: [{tag: "h1", attrs: {level: 1}},
|
|
52
|
-
{tag: "h2", attrs: {level: 2}},
|
|
53
|
-
{tag: "h3", attrs: {level: 3}},
|
|
54
|
-
{tag: "h4", attrs: {level: 4}},
|
|
55
|
-
{tag: "h5", attrs: {level: 5}},
|
|
56
|
-
{tag: "h6", attrs: {level: 6}}],
|
|
57
|
-
toDOM: function toDOM(node) { return ["h" + node.attrs.level, 0] }
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
61
|
-
// nodes by default. Represented as a `<pre>` element with a
|
|
62
|
-
// `<code>` element inside of it.
|
|
63
|
-
code_block: {
|
|
64
|
-
content: "text*",
|
|
65
|
-
marks: "",
|
|
66
|
-
group: "block",
|
|
67
|
-
code: true,
|
|
68
|
-
defining: true,
|
|
69
|
-
parseDOM: [{tag: "pre", preserveWhitespace: "full"}],
|
|
70
|
-
toDOM: function toDOM() { return preDOM }
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
// :: NodeSpec The text node.
|
|
74
|
-
text: {
|
|
75
|
-
group: "inline"
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
|
|
79
|
-
// `alt`, and `href` attributes. The latter two default to the empty
|
|
80
|
-
// string.
|
|
81
|
-
image: {
|
|
82
|
-
inline: true,
|
|
83
|
-
attrs: {
|
|
84
|
-
src: {},
|
|
85
|
-
alt: {default: null},
|
|
86
|
-
title: {default: null}
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
const pDOM = ["p", 0], blockquoteDOM = ["blockquote", 0], hrDOM = ["hr"], preDOM = ["pre", ["code", 0]], brDOM = ["br"];
|
|
4
|
+
/**
|
|
5
|
+
[Specs](https://prosemirror.net/docs/ref/#model.NodeSpec) for the nodes defined in this schema.
|
|
6
|
+
*/
|
|
7
|
+
const nodes = {
|
|
8
|
+
/**
|
|
9
|
+
NodeSpec The top level document node.
|
|
10
|
+
*/
|
|
11
|
+
doc: {
|
|
12
|
+
content: "block+"
|
|
87
13
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
14
|
+
/**
|
|
15
|
+
A plain paragraph textblock. Represented in the DOM
|
|
16
|
+
as a `<p>` element.
|
|
17
|
+
*/
|
|
18
|
+
paragraph: {
|
|
19
|
+
content: "inline*",
|
|
20
|
+
group: "block",
|
|
21
|
+
parseDOM: [{ tag: "p" }],
|
|
22
|
+
toDOM() { return pDOM; }
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
26
|
+
*/
|
|
27
|
+
blockquote: {
|
|
28
|
+
content: "block+",
|
|
29
|
+
group: "block",
|
|
30
|
+
defining: true,
|
|
31
|
+
parseDOM: [{ tag: "blockquote" }],
|
|
32
|
+
toDOM() { return blockquoteDOM; }
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
A horizontal rule (`<hr>`).
|
|
36
|
+
*/
|
|
37
|
+
horizontal_rule: {
|
|
38
|
+
group: "block",
|
|
39
|
+
parseDOM: [{ tag: "hr" }],
|
|
40
|
+
toDOM() { return hrDOM; }
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
A heading textblock, with a `level` attribute that
|
|
44
|
+
should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
45
|
+
`<h6>` elements.
|
|
46
|
+
*/
|
|
47
|
+
heading: {
|
|
48
|
+
attrs: { level: { default: 1 } },
|
|
49
|
+
content: "inline*",
|
|
50
|
+
group: "block",
|
|
51
|
+
defining: true,
|
|
52
|
+
parseDOM: [{ tag: "h1", attrs: { level: 1 } },
|
|
53
|
+
{ tag: "h2", attrs: { level: 2 } },
|
|
54
|
+
{ tag: "h3", attrs: { level: 3 } },
|
|
55
|
+
{ tag: "h4", attrs: { level: 4 } },
|
|
56
|
+
{ tag: "h5", attrs: { level: 5 } },
|
|
57
|
+
{ tag: "h6", attrs: { level: 6 } }],
|
|
58
|
+
toDOM(node) { return ["h" + node.attrs.level, 0]; }
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
A code listing. Disallows marks or non-text inline
|
|
62
|
+
nodes by default. Represented as a `<pre>` element with a
|
|
63
|
+
`<code>` element inside of it.
|
|
64
|
+
*/
|
|
65
|
+
code_block: {
|
|
66
|
+
content: "text*",
|
|
67
|
+
marks: "",
|
|
68
|
+
group: "block",
|
|
69
|
+
code: true,
|
|
70
|
+
defining: true,
|
|
71
|
+
parseDOM: [{ tag: "pre", preserveWhitespace: "full" }],
|
|
72
|
+
toDOM() { return preDOM; }
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
The text node.
|
|
76
|
+
*/
|
|
77
|
+
text: {
|
|
78
|
+
group: "inline"
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
An inline image (`<img>`) node. Supports `src`,
|
|
82
|
+
`alt`, and `href` attributes. The latter two default to the empty
|
|
83
|
+
string.
|
|
84
|
+
*/
|
|
85
|
+
image: {
|
|
86
|
+
inline: true,
|
|
87
|
+
attrs: {
|
|
88
|
+
src: {},
|
|
89
|
+
alt: { default: null },
|
|
90
|
+
title: { default: null }
|
|
91
|
+
},
|
|
92
|
+
group: "inline",
|
|
93
|
+
draggable: true,
|
|
94
|
+
parseDOM: [{ tag: "img[src]", getAttrs(dom) {
|
|
95
|
+
return {
|
|
96
|
+
src: dom.getAttribute("src"),
|
|
97
|
+
title: dom.getAttribute("title"),
|
|
98
|
+
alt: dom.getAttribute("alt")
|
|
99
|
+
};
|
|
100
|
+
} }],
|
|
101
|
+
toDOM(node) { let { src, alt, title } = node.attrs; return ["img", { src, alt, title }]; }
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
A hard line break, represented in the DOM as `<br>`.
|
|
105
|
+
*/
|
|
106
|
+
hard_break: {
|
|
107
|
+
inline: true,
|
|
108
|
+
group: "inline",
|
|
109
|
+
selectable: false,
|
|
110
|
+
parseDOM: [{ tag: "br" }],
|
|
111
|
+
toDOM() { return brDOM; }
|
|
112
|
+
}
|
|
111
113
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
const emDOM = ["em", 0], strongDOM = ["strong", 0], codeDOM = ["code", 0];
|
|
115
|
+
/**
|
|
116
|
+
[Specs](https://prosemirror.net/docs/ref/#model.MarkSpec) for the marks in the schema.
|
|
117
|
+
*/
|
|
118
|
+
const marks = {
|
|
119
|
+
/**
|
|
120
|
+
A link. Has `href` and `title` attributes. `title`
|
|
121
|
+
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
122
|
+
element.
|
|
123
|
+
*/
|
|
124
|
+
link: {
|
|
125
|
+
attrs: {
|
|
126
|
+
href: {},
|
|
127
|
+
title: { default: null }
|
|
128
|
+
},
|
|
129
|
+
inclusive: false,
|
|
130
|
+
parseDOM: [{ tag: "a[href]", getAttrs(dom) {
|
|
131
|
+
return { href: dom.getAttribute("href"), title: dom.getAttribute("title") };
|
|
132
|
+
} }],
|
|
133
|
+
toDOM(node) { let { href, title } = node.attrs; return ["a", { href, title }, 0]; }
|
|
124
134
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// :: MarkSpec Code font mark. Represented as a `<code>` element.
|
|
154
|
-
code: {
|
|
155
|
-
parseDOM: [{tag: "code"}],
|
|
156
|
-
toDOM: function toDOM() { return codeDOM }
|
|
157
|
-
}
|
|
135
|
+
/**
|
|
136
|
+
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
137
|
+
that also match `<i>` and `font-style: italic`.
|
|
138
|
+
*/
|
|
139
|
+
em: {
|
|
140
|
+
parseDOM: [{ tag: "i" }, { tag: "em" }, { style: "font-style=italic" }],
|
|
141
|
+
toDOM() { return emDOM; }
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
145
|
+
`<b>` and `font-weight: bold`.
|
|
146
|
+
*/
|
|
147
|
+
strong: {
|
|
148
|
+
parseDOM: [{ tag: "strong" },
|
|
149
|
+
// This works around a Google Docs misbehavior where
|
|
150
|
+
// pasted content will be inexplicably wrapped in `<b>`
|
|
151
|
+
// tags with a font-weight normal.
|
|
152
|
+
{ tag: "b", getAttrs: (node) => node.style.fontWeight != "normal" && null },
|
|
153
|
+
{ style: "font-weight", getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null }],
|
|
154
|
+
toDOM() { return strongDOM; }
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
Code font mark. Represented as a `<code>` element.
|
|
158
|
+
*/
|
|
159
|
+
code: {
|
|
160
|
+
parseDOM: [{ tag: "code" }],
|
|
161
|
+
toDOM() { return codeDOM; }
|
|
162
|
+
}
|
|
158
163
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
exports.nodes = nodes;
|
|
172
|
-
exports.schema = schema;
|
|
173
|
-
//# sourceMappingURL=index.js.map
|
|
164
|
+
/**
|
|
165
|
+
This schema roughly corresponds to the document schema used by
|
|
166
|
+
[CommonMark](http://commonmark.org/), minus the list elements,
|
|
167
|
+
which are defined in the [`prosemirror-schema-list`](https://prosemirror.net/docs/ref/#schema-list)
|
|
168
|
+
module.
|
|
169
|
+
|
|
170
|
+
To reuse elements from this schema, extend or read from its
|
|
171
|
+
`spec.nodes` and `spec.marks` [properties](https://prosemirror.net/docs/ref/#model.Schema.spec).
|
|
172
|
+
*/
|
|
173
|
+
const schema = new Schema({ nodes, marks });
|
|
174
|
+
|
|
175
|
+
export { marks, nodes, schema };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/schema-basic.js"],"sourcesContent":["import {Schema} from \"prosemirror-model\"\n\nconst pDOM = [\"p\", 0], blockquoteDOM = [\"blockquote\", 0], hrDOM = [\"hr\"],\n preDOM = [\"pre\", [\"code\", 0]], brDOM = [\"br\"]\n\n// :: Object\n// [Specs](#model.NodeSpec) for the nodes defined in this schema.\nexport const nodes = {\n // :: NodeSpec The top level document node.\n doc: {\n content: \"block+\"\n },\n\n // :: NodeSpec A plain paragraph textblock. Represented in the DOM\n // as a `<p>` element.\n paragraph: {\n content: \"inline*\",\n group: \"block\",\n parseDOM: [{tag: \"p\"}],\n toDOM() { return pDOM }\n },\n\n // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.\n blockquote: {\n content: \"block+\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"blockquote\"}],\n toDOM() { return blockquoteDOM }\n },\n\n // :: NodeSpec A horizontal rule (`<hr>`).\n horizontal_rule: {\n group: \"block\",\n parseDOM: [{tag: \"hr\"}],\n toDOM() { return hrDOM }\n },\n\n // :: NodeSpec A heading textblock, with a `level` attribute that\n // should hold the number 1 to 6. Parsed and serialized as `<h1>` to\n // `<h6>` elements.\n heading: {\n attrs: {level: {default: 1}},\n content: \"inline*\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"h1\", attrs: {level: 1}},\n {tag: \"h2\", attrs: {level: 2}},\n {tag: \"h3\", attrs: {level: 3}},\n {tag: \"h4\", attrs: {level: 4}},\n {tag: \"h5\", attrs: {level: 5}},\n {tag: \"h6\", attrs: {level: 6}}],\n toDOM(node) { return [\"h\" + node.attrs.level, 0] }\n },\n\n // :: NodeSpec A code listing. Disallows marks or non-text inline\n // nodes by default. Represented as a `<pre>` element with a\n // `<code>` element inside of it.\n code_block: {\n content: \"text*\",\n marks: \"\",\n group: \"block\",\n code: true,\n defining: true,\n parseDOM: [{tag: \"pre\", preserveWhitespace: \"full\"}],\n toDOM() { return preDOM }\n },\n\n // :: NodeSpec The text node.\n text: {\n group: \"inline\"\n },\n\n // :: NodeSpec An inline image (`<img>`) node. Supports `src`,\n // `alt`, and `href` attributes. The latter two default to the empty\n // string.\n image: {\n inline: true,\n attrs: {\n src: {},\n alt: {default: null},\n title: {default: null}\n },\n group: \"inline\",\n draggable: true,\n parseDOM: [{tag: \"img[src]\", getAttrs(dom) {\n return {\n src: dom.getAttribute(\"src\"),\n title: dom.getAttribute(\"title\"),\n alt: dom.getAttribute(\"alt\")\n }\n }}],\n toDOM(node) { let {src, alt, title} = node.attrs; return [\"img\", {src, alt, title}] }\n },\n\n // :: NodeSpec A hard line break, represented in the DOM as `<br>`.\n hard_break: {\n inline: true,\n group: \"inline\",\n selectable: false,\n parseDOM: [{tag: \"br\"}],\n toDOM() { return brDOM }\n }\n}\n\nconst emDOM = [\"em\", 0], strongDOM = [\"strong\", 0], codeDOM = [\"code\", 0]\n\n// :: Object [Specs](#model.MarkSpec) for the marks in the schema.\nexport const marks = {\n // :: MarkSpec A link. Has `href` and `title` attributes. `title`\n // defaults to the empty string. Rendered and parsed as an `<a>`\n // element.\n link: {\n attrs: {\n href: {},\n title: {default: null}\n },\n inclusive: false,\n parseDOM: [{tag: \"a[href]\", getAttrs(dom) {\n return {href: dom.getAttribute(\"href\"), title: dom.getAttribute(\"title\")}\n }}],\n toDOM(node) { let {href, title} = node.attrs; return [\"a\", {href, title}, 0] }\n },\n\n // :: MarkSpec An emphasis mark. Rendered as an `<em>` element.\n // Has parse rules that also match `<i>` and `font-style: italic`.\n em: {\n parseDOM: [{tag: \"i\"}, {tag: \"em\"}, {style: \"font-style=italic\"}],\n toDOM() { return emDOM }\n },\n\n // :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules\n // also match `<b>` and `font-weight: bold`.\n strong: {\n parseDOM: [{tag: \"strong\"},\n // This works around a Google Docs misbehavior where\n // pasted content will be inexplicably wrapped in `<b>`\n // tags with a font-weight normal.\n {tag: \"b\", getAttrs: node => node.style.fontWeight != \"normal\" && null},\n {style: \"font-weight\", getAttrs: value => /^(bold(er)?|[5-9]\\d{2,})$/.test(value) && null}],\n toDOM() { return strongDOM }\n },\n\n // :: MarkSpec Code font mark. Represented as a `<code>` element.\n code: {\n parseDOM: [{tag: \"code\"}],\n toDOM() { return codeDOM }\n }\n}\n\n// :: Schema\n// This schema roughly corresponds to the document schema used by\n// [CommonMark](http://commonmark.org/), minus the list elements,\n// which are defined in the [`prosemirror-schema-list`](#schema-list)\n// module.\n//\n// To reuse elements from this schema, extend or read from its\n// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).\nexport const schema = new Schema({nodes, marks})\n"],"names":["const","Schema"],"mappings":";;;;;;AAEAA,IAAM,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC;MAClE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,EAAC;;;;AAInD,AAAY,IAAC,KAAK,GAAG;;EAEnB,GAAG,EAAE;IACH,OAAO,EAAE,QAAQ;GAClB;;;;EAID,SAAS,EAAE;IACT,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,qBAAK,GAAG,EAAE,OAAO,IAAI,EAAE;GACxB;;;EAGD,UAAU,EAAE;IACV,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAC/B,qBAAK,GAAG,EAAE,OAAO,aAAa,EAAE;GACjC;;;EAGD,eAAe,EAAE;IACf,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,C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|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/schema-basic.js"],"sourcesContent":["import {Schema} from \"prosemirror-model\"\n\nconst pDOM = [\"p\", 0], blockquoteDOM = [\"blockquote\", 0], hrDOM = [\"hr\"],\n preDOM = [\"pre\", [\"code\", 0]], brDOM = [\"br\"]\n\n// :: Object\n// [Specs](#model.NodeSpec) for the nodes defined in this schema.\nexport const nodes = {\n // :: NodeSpec The top level document node.\n doc: {\n content: \"block+\"\n },\n\n // :: NodeSpec A plain paragraph textblock. Represented in the DOM\n // as a `<p>` element.\n paragraph: {\n content: \"inline*\",\n group: \"block\",\n parseDOM: [{tag: \"p\"}],\n toDOM() { return pDOM }\n },\n\n // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.\n blockquote: {\n content: \"block+\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"blockquote\"}],\n toDOM() { return blockquoteDOM }\n },\n\n // :: NodeSpec A horizontal rule (`<hr>`).\n horizontal_rule: {\n group: \"block\",\n parseDOM: [{tag: \"hr\"}],\n toDOM() { return hrDOM }\n },\n\n // :: NodeSpec A heading textblock, with a `level` attribute that\n // should hold the number 1 to 6. Parsed and serialized as `<h1>` to\n // `<h6>` elements.\n heading: {\n attrs: {level: {default: 1}},\n content: \"inline*\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"h1\", attrs: {level: 1}},\n {tag: \"h2\", attrs: {level: 2}},\n {tag: \"h3\", attrs: {level: 3}},\n {tag: \"h4\", attrs: {level: 4}},\n {tag: \"h5\", attrs: {level: 5}},\n {tag: \"h6\", attrs: {level: 6}}],\n toDOM(node) { return [\"h\" + node.attrs.level, 0] }\n },\n\n // :: NodeSpec A code listing. Disallows marks or non-text inline\n // nodes by default. Represented as a `<pre>` element with a\n // `<code>` element inside of it.\n code_block: {\n content: \"text*\",\n marks: \"\",\n group: \"block\",\n code: true,\n defining: true,\n parseDOM: [{tag: \"pre\", preserveWhitespace: \"full\"}],\n toDOM() { return preDOM }\n },\n\n // :: NodeSpec The text node.\n text: {\n group: \"inline\"\n },\n\n // :: NodeSpec An inline image (`<img>`) node. Supports `src`,\n // `alt`, and `href` attributes. The latter two default to the empty\n // string.\n image: {\n inline: true,\n attrs: {\n src: {},\n alt: {default: null},\n title: {default: null}\n },\n group: \"inline\",\n draggable: true,\n parseDOM: [{tag: \"img[src]\", getAttrs(dom) {\n return {\n src: dom.getAttribute(\"src\"),\n title: dom.getAttribute(\"title\"),\n alt: dom.getAttribute(\"alt\")\n }\n }}],\n toDOM(node) { let {src, alt, title} = node.attrs; return [\"img\", {src, alt, title}] }\n },\n\n // :: NodeSpec A hard line break, represented in the DOM as `<br>`.\n hard_break: {\n inline: true,\n group: \"inline\",\n selectable: false,\n parseDOM: [{tag: \"br\"}],\n toDOM() { return brDOM }\n }\n}\n\nconst emDOM = [\"em\", 0], strongDOM = [\"strong\", 0], codeDOM = [\"code\", 0]\n\n// :: Object [Specs](#model.MarkSpec) for the marks in the schema.\nexport const marks = {\n // :: MarkSpec A link. Has `href` and `title` attributes. `title`\n // defaults to the empty string. Rendered and parsed as an `<a>`\n // element.\n link: {\n attrs: {\n href: {},\n title: {default: null}\n },\n inclusive: false,\n parseDOM: [{tag: \"a[href]\", getAttrs(dom) {\n return {href: dom.getAttribute(\"href\"), title: dom.getAttribute(\"title\")}\n }}],\n toDOM(node) { let {href, title} = node.attrs; return [\"a\", {href, title}, 0] }\n },\n\n // :: MarkSpec An emphasis mark. Rendered as an `<em>` element.\n // Has parse rules that also match `<i>` and `font-style: italic`.\n em: {\n parseDOM: [{tag: \"i\"}, {tag: \"em\"}, {style: \"font-style=italic\"}],\n toDOM() { return emDOM }\n },\n\n // :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules\n // also match `<b>` and `font-weight: bold`.\n strong: {\n parseDOM: [{tag: \"strong\"},\n // This works around a Google Docs misbehavior where\n // pasted content will be inexplicably wrapped in `<b>`\n // tags with a font-weight normal.\n {tag: \"b\", getAttrs: node => node.style.fontWeight != \"normal\" && null},\n {style: \"font-weight\", getAttrs: value => /^(bold(er)?|[5-9]\\d{2,})$/.test(value) && null}],\n toDOM() { return strongDOM }\n },\n\n // :: MarkSpec Code font mark. Represented as a `<code>` element.\n code: {\n parseDOM: [{tag: \"code\"}],\n toDOM() { return codeDOM }\n }\n}\n\n// :: Schema\n// This schema roughly corresponds to the document schema used by\n// [CommonMark](http://commonmark.org/), minus the list elements,\n// which are defined in the [`prosemirror-schema-list`](#schema-list)\n// module.\n//\n// To reuse elements from this schema, extend or read from its\n// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).\nexport const schema = new Schema({nodes, marks})\n"],"names":["const","Schema"],"mappings":";;;;;;AAEAA,IAAM,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC;AACxE,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,EAAC;AACnD;AACA;AACA;AACY,IAAC,KAAK,GAAG;AACrB;AACA,EAAE,GAAG,EAAE;AACP,IAAI,OAAO,EAAE,QAAQ;AACrB,GAAG;AACH;AACA;AACA;AACA,EAAE,SAAS,EAAE;AACb,IAAI,OAAO,EAAE,SAAS;AACtB,IAAI,KAAK,EAAE,OAAO;AAClB,IAAI,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1B,IAAI,KAAK,EAAA,SAAA,KAAA,GAAG,EAAE,OAAO,IAAI,EAAE;AAC3B,GAAG;AACH;AACA;AACA,EAAE,UAAU,EAAE;AACd,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,KAAK,EAAE,OAAO;AAClB,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AACnC,IAAI,K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AA,EAAC,KAAK,EAAA,KAAA,EAAE,KAAK,CAAC;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-schema-basic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Basic schema elements for ProseMirror",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"sideEffects": false,
|
|
7
14
|
"license": "MIT",
|
|
8
15
|
"maintainers": [
|
|
9
16
|
{
|
|
@@ -20,13 +27,11 @@
|
|
|
20
27
|
"prosemirror-model": "^1.2.0"
|
|
21
28
|
},
|
|
22
29
|
"devDependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
30
|
+
"@prosemirror/buildhelper": "^0.1.5",
|
|
31
|
+
"prosemirror-test-builder": "^1.0.0"
|
|
25
32
|
},
|
|
26
33
|
"scripts": {
|
|
27
|
-
"test": "
|
|
28
|
-
"
|
|
29
|
-
"watch": "rollup -c -w",
|
|
30
|
-
"prepare": "npm run build"
|
|
34
|
+
"test": "pm-runtests",
|
|
35
|
+
"prepare": "pm-buildhelper src/schema-basic.ts"
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {Schema, NodeSpec, MarkSpec, DOMOutputSpec} from "prosemirror-model"
|
|
2
|
+
|
|
3
|
+
const pDOM: DOMOutputSpec = ["p", 0], blockquoteDOM: DOMOutputSpec = ["blockquote", 0],
|
|
4
|
+
hrDOM: DOMOutputSpec = ["hr"], preDOM: DOMOutputSpec = ["pre", ["code", 0]],
|
|
5
|
+
brDOM: DOMOutputSpec = ["br"]
|
|
6
|
+
|
|
7
|
+
/// [Specs](#model.NodeSpec) for the nodes defined in this schema.
|
|
8
|
+
export const nodes = {
|
|
9
|
+
/// NodeSpec The top level document node.
|
|
10
|
+
doc: {
|
|
11
|
+
content: "block+"
|
|
12
|
+
} as NodeSpec,
|
|
13
|
+
|
|
14
|
+
/// A plain paragraph textblock. Represented in the DOM
|
|
15
|
+
/// as a `<p>` element.
|
|
16
|
+
paragraph: {
|
|
17
|
+
content: "inline*",
|
|
18
|
+
group: "block",
|
|
19
|
+
parseDOM: [{tag: "p"}],
|
|
20
|
+
toDOM() { return pDOM }
|
|
21
|
+
} as NodeSpec,
|
|
22
|
+
|
|
23
|
+
/// A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
24
|
+
blockquote: {
|
|
25
|
+
content: "block+",
|
|
26
|
+
group: "block",
|
|
27
|
+
defining: true,
|
|
28
|
+
parseDOM: [{tag: "blockquote"}],
|
|
29
|
+
toDOM() { return blockquoteDOM }
|
|
30
|
+
} as NodeSpec,
|
|
31
|
+
|
|
32
|
+
/// A horizontal rule (`<hr>`).
|
|
33
|
+
horizontal_rule: {
|
|
34
|
+
group: "block",
|
|
35
|
+
parseDOM: [{tag: "hr"}],
|
|
36
|
+
toDOM() { return hrDOM }
|
|
37
|
+
} as NodeSpec,
|
|
38
|
+
|
|
39
|
+
/// A heading textblock, with a `level` attribute that
|
|
40
|
+
/// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
41
|
+
/// `<h6>` elements.
|
|
42
|
+
heading: {
|
|
43
|
+
attrs: {level: {default: 1}},
|
|
44
|
+
content: "inline*",
|
|
45
|
+
group: "block",
|
|
46
|
+
defining: true,
|
|
47
|
+
parseDOM: [{tag: "h1", attrs: {level: 1}},
|
|
48
|
+
{tag: "h2", attrs: {level: 2}},
|
|
49
|
+
{tag: "h3", attrs: {level: 3}},
|
|
50
|
+
{tag: "h4", attrs: {level: 4}},
|
|
51
|
+
{tag: "h5", attrs: {level: 5}},
|
|
52
|
+
{tag: "h6", attrs: {level: 6}}],
|
|
53
|
+
toDOM(node) { return ["h" + node.attrs.level, 0] }
|
|
54
|
+
} as NodeSpec,
|
|
55
|
+
|
|
56
|
+
/// A code listing. Disallows marks or non-text inline
|
|
57
|
+
/// nodes by default. Represented as a `<pre>` element with a
|
|
58
|
+
/// `<code>` element inside of it.
|
|
59
|
+
code_block: {
|
|
60
|
+
content: "text*",
|
|
61
|
+
marks: "",
|
|
62
|
+
group: "block",
|
|
63
|
+
code: true,
|
|
64
|
+
defining: true,
|
|
65
|
+
parseDOM: [{tag: "pre", preserveWhitespace: "full"}],
|
|
66
|
+
toDOM() { return preDOM }
|
|
67
|
+
} as NodeSpec,
|
|
68
|
+
|
|
69
|
+
/// The text node.
|
|
70
|
+
text: {
|
|
71
|
+
group: "inline"
|
|
72
|
+
} as NodeSpec,
|
|
73
|
+
|
|
74
|
+
/// An inline image (`<img>`) node. Supports `src`,
|
|
75
|
+
/// `alt`, and `href` attributes. The latter two default to the empty
|
|
76
|
+
/// string.
|
|
77
|
+
image: {
|
|
78
|
+
inline: true,
|
|
79
|
+
attrs: {
|
|
80
|
+
src: {},
|
|
81
|
+
alt: {default: null},
|
|
82
|
+
title: {default: null}
|
|
83
|
+
},
|
|
84
|
+
group: "inline",
|
|
85
|
+
draggable: true,
|
|
86
|
+
parseDOM: [{tag: "img[src]", getAttrs(dom: HTMLElement) {
|
|
87
|
+
return {
|
|
88
|
+
src: dom.getAttribute("src"),
|
|
89
|
+
title: dom.getAttribute("title"),
|
|
90
|
+
alt: dom.getAttribute("alt")
|
|
91
|
+
}
|
|
92
|
+
}}],
|
|
93
|
+
toDOM(node) { let {src, alt, title} = node.attrs; return ["img", {src, alt, title}] }
|
|
94
|
+
} as NodeSpec,
|
|
95
|
+
|
|
96
|
+
/// A hard line break, represented in the DOM as `<br>`.
|
|
97
|
+
hard_break: {
|
|
98
|
+
inline: true,
|
|
99
|
+
group: "inline",
|
|
100
|
+
selectable: false,
|
|
101
|
+
parseDOM: [{tag: "br"}],
|
|
102
|
+
toDOM() { return brDOM }
|
|
103
|
+
} as NodeSpec
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const emDOM: DOMOutputSpec = ["em", 0], strongDOM: DOMOutputSpec = ["strong", 0], codeDOM: DOMOutputSpec = ["code", 0]
|
|
107
|
+
|
|
108
|
+
/// [Specs](#model.MarkSpec) for the marks in the schema.
|
|
109
|
+
export const marks = {
|
|
110
|
+
/// A link. Has `href` and `title` attributes. `title`
|
|
111
|
+
/// defaults to the empty string. Rendered and parsed as an `<a>`
|
|
112
|
+
/// element.
|
|
113
|
+
link: {
|
|
114
|
+
attrs: {
|
|
115
|
+
href: {},
|
|
116
|
+
title: {default: null}
|
|
117
|
+
},
|
|
118
|
+
inclusive: false,
|
|
119
|
+
parseDOM: [{tag: "a[href]", getAttrs(dom: HTMLElement) {
|
|
120
|
+
return {href: dom.getAttribute("href"), title: dom.getAttribute("title")}
|
|
121
|
+
}}],
|
|
122
|
+
toDOM(node) { let {href, title} = node.attrs; return ["a", {href, title}, 0] }
|
|
123
|
+
} as MarkSpec,
|
|
124
|
+
|
|
125
|
+
/// An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
126
|
+
/// that also match `<i>` and `font-style: italic`.
|
|
127
|
+
em: {
|
|
128
|
+
parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}],
|
|
129
|
+
toDOM() { return emDOM }
|
|
130
|
+
} as MarkSpec,
|
|
131
|
+
|
|
132
|
+
/// A strong mark. Rendered as `<strong>`, parse rules also match
|
|
133
|
+
/// `<b>` and `font-weight: bold`.
|
|
134
|
+
strong: {
|
|
135
|
+
parseDOM: [{tag: "strong"},
|
|
136
|
+
// This works around a Google Docs misbehavior where
|
|
137
|
+
// pasted content will be inexplicably wrapped in `<b>`
|
|
138
|
+
// tags with a font-weight normal.
|
|
139
|
+
{tag: "b", getAttrs: (node: HTMLElement) => node.style.fontWeight != "normal" && null},
|
|
140
|
+
{style: "font-weight", getAttrs: (value: string) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null}],
|
|
141
|
+
toDOM() { return strongDOM }
|
|
142
|
+
} as MarkSpec,
|
|
143
|
+
|
|
144
|
+
/// Code font mark. Represented as a `<code>` element.
|
|
145
|
+
code: {
|
|
146
|
+
parseDOM: [{tag: "code"}],
|
|
147
|
+
toDOM() { return codeDOM }
|
|
148
|
+
} as MarkSpec
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// This schema roughly corresponds to the document schema used by
|
|
152
|
+
/// [CommonMark](http://commonmark.org/), minus the list elements,
|
|
153
|
+
/// which are defined in the [`prosemirror-schema-list`](#schema-list)
|
|
154
|
+
/// module.
|
|
155
|
+
///
|
|
156
|
+
/// To reuse elements from this schema, extend or read from its
|
|
157
|
+
/// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
|
|
158
|
+
export const schema = new Schema({nodes, marks})
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/schema-basic.js"],"sourcesContent":["import {Schema} from \"prosemirror-model\"\n\nconst pDOM = [\"p\", 0], blockquoteDOM = [\"blockquote\", 0], hrDOM = [\"hr\"],\n preDOM = [\"pre\", [\"code\", 0]], brDOM = [\"br\"]\n\n// :: Object\n// [Specs](#model.NodeSpec) for the nodes defined in this schema.\nexport const nodes = {\n // :: NodeSpec The top level document node.\n doc: {\n content: \"block+\"\n },\n\n // :: NodeSpec A plain paragraph textblock. Represented in the DOM\n // as a `<p>` element.\n paragraph: {\n content: \"inline*\",\n group: \"block\",\n parseDOM: [{tag: \"p\"}],\n toDOM() { return pDOM }\n },\n\n // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.\n blockquote: {\n content: \"block+\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"blockquote\"}],\n toDOM() { return blockquoteDOM }\n },\n\n // :: NodeSpec A horizontal rule (`<hr>`).\n horizontal_rule: {\n group: \"block\",\n parseDOM: [{tag: \"hr\"}],\n toDOM() { return hrDOM }\n },\n\n // :: NodeSpec A heading textblock, with a `level` attribute that\n // should hold the number 1 to 6. Parsed and serialized as `<h1>` to\n // `<h6>` elements.\n heading: {\n attrs: {level: {default: 1}},\n content: \"inline*\",\n group: \"block\",\n defining: true,\n parseDOM: [{tag: \"h1\", attrs: {level: 1}},\n {tag: \"h2\", attrs: {level: 2}},\n {tag: \"h3\", attrs: {level: 3}},\n {tag: \"h4\", attrs: {level: 4}},\n {tag: \"h5\", attrs: {level: 5}},\n {tag: \"h6\", attrs: {level: 6}}],\n toDOM(node) { return [\"h\" + node.attrs.level, 0] }\n },\n\n // :: NodeSpec A code listing. Disallows marks or non-text inline\n // nodes by default. Represented as a `<pre>` element with a\n // `<code>` element inside of it.\n code_block: {\n content: \"text*\",\n marks: \"\",\n group: \"block\",\n code: true,\n defining: true,\n parseDOM: [{tag: \"pre\", preserveWhitespace: \"full\"}],\n toDOM() { return preDOM }\n },\n\n // :: NodeSpec The text node.\n text: {\n group: \"inline\"\n },\n\n // :: NodeSpec An inline image (`<img>`) node. Supports `src`,\n // `alt`, and `href` attributes. The latter two default to the empty\n // string.\n image: {\n inline: true,\n attrs: {\n src: {},\n alt: {default: null},\n title: {default: null}\n },\n group: \"inline\",\n draggable: true,\n parseDOM: [{tag: \"img[src]\", getAttrs(dom) {\n return {\n src: dom.getAttribute(\"src\"),\n title: dom.getAttribute(\"title\"),\n alt: dom.getAttribute(\"alt\")\n }\n }}],\n toDOM(node) { let {src, alt, title} = node.attrs; return [\"img\", {src, alt, title}] }\n },\n\n // :: NodeSpec A hard line break, represented in the DOM as `<br>`.\n hard_break: {\n inline: true,\n group: \"inline\",\n selectable: false,\n parseDOM: [{tag: \"br\"}],\n toDOM() { return brDOM }\n }\n}\n\nconst emDOM = [\"em\", 0], strongDOM = [\"strong\", 0], codeDOM = [\"code\", 0]\n\n// :: Object [Specs](#model.MarkSpec) for the marks in the schema.\nexport const marks = {\n // :: MarkSpec A link. Has `href` and `title` attributes. `title`\n // defaults to the empty string. Rendered and parsed as an `<a>`\n // element.\n link: {\n attrs: {\n href: {},\n title: {default: null}\n },\n inclusive: false,\n parseDOM: [{tag: \"a[href]\", getAttrs(dom) {\n return {href: dom.getAttribute(\"href\"), title: dom.getAttribute(\"title\")}\n }}],\n toDOM(node) { let {href, title} = node.attrs; return [\"a\", {href, title}, 0] }\n },\n\n // :: MarkSpec An emphasis mark. Rendered as an `<em>` element.\n // Has parse rules that also match `<i>` and `font-style: italic`.\n em: {\n parseDOM: [{tag: \"i\"}, {tag: \"em\"}, {style: \"font-style=italic\"}],\n toDOM() { return emDOM }\n },\n\n // :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules\n // also match `<b>` and `font-weight: bold`.\n strong: {\n parseDOM: [{tag: \"strong\"},\n // This works around a Google Docs misbehavior where\n // pasted content will be inexplicably wrapped in `<b>`\n // tags with a font-weight normal.\n {tag: \"b\", getAttrs: node => node.style.fontWeight != \"normal\" && null},\n {style: \"font-weight\", getAttrs: value => /^(bold(er)?|[5-9]\\d{2,})$/.test(value) && null}],\n toDOM() { return strongDOM }\n },\n\n // :: MarkSpec Code font mark. Represented as a `<code>` element.\n code: {\n parseDOM: [{tag: \"code\"}],\n toDOM() { return codeDOM }\n }\n}\n\n// :: Schema\n// This schema roughly corresponds to the document schema used by\n// [CommonMark](http://commonmark.org/), minus the list elements,\n// which are defined in the [`prosemirror-schema-list`](#schema-list)\n// module.\n//\n// To reuse elements from this schema, extend or read from its\n// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).\nexport const schema = new Schema({nodes, marks})\n"],"names":["const"],"mappings":";;AAEAA,IAAM,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC;MAClE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAA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,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC;;;;eAIf,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,YAAE,MAAK,SAAG,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,QAAQ,IAAI,OAAI,CAAC;eACvE,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,YAAE,OAAM,SAAG,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,OAAI,CAAC,CAAC;IACtG,qBAAK,GAAG,EAAE,OAAO,SAAS,EAAE;GAC7B;;;EAGD,IAAI,EAAE;IACJ,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzB,qBAAK,GAAG,EAAE,OAAO,OAAO,EAAE;GAC3B;EACF;;;;;;;;;;AAUD,AAAY,IAAC,MAAM,GAAG,IAAI,MAAM,CAAC,QAAC,KAAK,SAAE,KAAK,CAAC,CAAC;;;;"}
|
package/rollup.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
input: './src/schema-basic.js',
|
|
3
|
-
output: [{
|
|
4
|
-
file: 'dist/index.js',
|
|
5
|
-
format: 'cjs',
|
|
6
|
-
sourcemap: true
|
|
7
|
-
}, {
|
|
8
|
-
file: 'dist/index.mjs',
|
|
9
|
-
format: 'es',
|
|
10
|
-
sourcemap: true
|
|
11
|
-
}],
|
|
12
|
-
plugins: [require('@rollup/plugin-buble')()],
|
|
13
|
-
external(id) { return !/^[\.\/]/.test(id) }
|
|
14
|
-
}
|
package/src/schema-basic.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import {Schema} from "prosemirror-model"
|
|
2
|
-
|
|
3
|
-
const pDOM = ["p", 0], blockquoteDOM = ["blockquote", 0], hrDOM = ["hr"],
|
|
4
|
-
preDOM = ["pre", ["code", 0]], brDOM = ["br"]
|
|
5
|
-
|
|
6
|
-
// :: Object
|
|
7
|
-
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
|
|
8
|
-
export const nodes = {
|
|
9
|
-
// :: NodeSpec The top level document node.
|
|
10
|
-
doc: {
|
|
11
|
-
content: "block+"
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
|
|
15
|
-
// as a `<p>` element.
|
|
16
|
-
paragraph: {
|
|
17
|
-
content: "inline*",
|
|
18
|
-
group: "block",
|
|
19
|
-
parseDOM: [{tag: "p"}],
|
|
20
|
-
toDOM() { return pDOM }
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
24
|
-
blockquote: {
|
|
25
|
-
content: "block+",
|
|
26
|
-
group: "block",
|
|
27
|
-
defining: true,
|
|
28
|
-
parseDOM: [{tag: "blockquote"}],
|
|
29
|
-
toDOM() { return blockquoteDOM }
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
33
|
-
horizontal_rule: {
|
|
34
|
-
group: "block",
|
|
35
|
-
parseDOM: [{tag: "hr"}],
|
|
36
|
-
toDOM() { return hrDOM }
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
// :: NodeSpec A heading textblock, with a `level` attribute that
|
|
40
|
-
// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
41
|
-
// `<h6>` elements.
|
|
42
|
-
heading: {
|
|
43
|
-
attrs: {level: {default: 1}},
|
|
44
|
-
content: "inline*",
|
|
45
|
-
group: "block",
|
|
46
|
-
defining: true,
|
|
47
|
-
parseDOM: [{tag: "h1", attrs: {level: 1}},
|
|
48
|
-
{tag: "h2", attrs: {level: 2}},
|
|
49
|
-
{tag: "h3", attrs: {level: 3}},
|
|
50
|
-
{tag: "h4", attrs: {level: 4}},
|
|
51
|
-
{tag: "h5", attrs: {level: 5}},
|
|
52
|
-
{tag: "h6", attrs: {level: 6}}],
|
|
53
|
-
toDOM(node) { return ["h" + node.attrs.level, 0] }
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
57
|
-
// nodes by default. Represented as a `<pre>` element with a
|
|
58
|
-
// `<code>` element inside of it.
|
|
59
|
-
code_block: {
|
|
60
|
-
content: "text*",
|
|
61
|
-
marks: "",
|
|
62
|
-
group: "block",
|
|
63
|
-
code: true,
|
|
64
|
-
defining: true,
|
|
65
|
-
parseDOM: [{tag: "pre", preserveWhitespace: "full"}],
|
|
66
|
-
toDOM() { return preDOM }
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// :: NodeSpec The text node.
|
|
70
|
-
text: {
|
|
71
|
-
group: "inline"
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
|
|
75
|
-
// `alt`, and `href` attributes. The latter two default to the empty
|
|
76
|
-
// string.
|
|
77
|
-
image: {
|
|
78
|
-
inline: true,
|
|
79
|
-
attrs: {
|
|
80
|
-
src: {},
|
|
81
|
-
alt: {default: null},
|
|
82
|
-
title: {default: null}
|
|
83
|
-
},
|
|
84
|
-
group: "inline",
|
|
85
|
-
draggable: true,
|
|
86
|
-
parseDOM: [{tag: "img[src]", getAttrs(dom) {
|
|
87
|
-
return {
|
|
88
|
-
src: dom.getAttribute("src"),
|
|
89
|
-
title: dom.getAttribute("title"),
|
|
90
|
-
alt: dom.getAttribute("alt")
|
|
91
|
-
}
|
|
92
|
-
}}],
|
|
93
|
-
toDOM(node) { let {src, alt, title} = node.attrs; return ["img", {src, alt, title}] }
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
|
|
97
|
-
hard_break: {
|
|
98
|
-
inline: true,
|
|
99
|
-
group: "inline",
|
|
100
|
-
selectable: false,
|
|
101
|
-
parseDOM: [{tag: "br"}],
|
|
102
|
-
toDOM() { return brDOM }
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const emDOM = ["em", 0], strongDOM = ["strong", 0], codeDOM = ["code", 0]
|
|
107
|
-
|
|
108
|
-
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
|
|
109
|
-
export const marks = {
|
|
110
|
-
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
|
|
111
|
-
// defaults to the empty string. Rendered and parsed as an `<a>`
|
|
112
|
-
// element.
|
|
113
|
-
link: {
|
|
114
|
-
attrs: {
|
|
115
|
-
href: {},
|
|
116
|
-
title: {default: null}
|
|
117
|
-
},
|
|
118
|
-
inclusive: false,
|
|
119
|
-
parseDOM: [{tag: "a[href]", getAttrs(dom) {
|
|
120
|
-
return {href: dom.getAttribute("href"), title: dom.getAttribute("title")}
|
|
121
|
-
}}],
|
|
122
|
-
toDOM(node) { let {href, title} = node.attrs; return ["a", {href, title}, 0] }
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
|
|
126
|
-
// Has parse rules that also match `<i>` and `font-style: italic`.
|
|
127
|
-
em: {
|
|
128
|
-
parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}],
|
|
129
|
-
toDOM() { return emDOM }
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
|
|
133
|
-
// also match `<b>` and `font-weight: bold`.
|
|
134
|
-
strong: {
|
|
135
|
-
parseDOM: [{tag: "strong"},
|
|
136
|
-
// This works around a Google Docs misbehavior where
|
|
137
|
-
// pasted content will be inexplicably wrapped in `<b>`
|
|
138
|
-
// tags with a font-weight normal.
|
|
139
|
-
{tag: "b", getAttrs: node => node.style.fontWeight != "normal" && null},
|
|
140
|
-
{style: "font-weight", getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null}],
|
|
141
|
-
toDOM() { return strongDOM }
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
// :: MarkSpec Code font mark. Represented as a `<code>` element.
|
|
145
|
-
code: {
|
|
146
|
-
parseDOM: [{tag: "code"}],
|
|
147
|
-
toDOM() { return codeDOM }
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// :: Schema
|
|
152
|
-
// This schema roughly corresponds to the document schema used by
|
|
153
|
-
// [CommonMark](http://commonmark.org/), minus the list elements,
|
|
154
|
-
// which are defined in the [`prosemirror-schema-list`](#schema-list)
|
|
155
|
-
// module.
|
|
156
|
-
//
|
|
157
|
-
// To reuse elements from this schema, extend or read from its
|
|
158
|
-
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
|
|
159
|
-
export const schema = new Schema({nodes, marks})
|