prosemirror-schema-basic 1.0.0 → 1.1.2
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 +51 -0
- package/dist/index.es.js +167 -0
- package/dist/index.es.js.map +1 -0
- package/dist/{schema-basic.js → index.js} +23 -13
- package/dist/index.js.map +1 -0
- package/package.json +6 -5
- package/rollup.config.js +11 -4
- package/src/schema-basic.js +16 -11
- package/dist/schema-basic.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## 1.1.2 (2019-11-20)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Rename ES module files to use a .js extension, since Webpack gets confused by .mjs
|
|
6
|
+
|
|
7
|
+
## 1.1.1 (2019-11-19)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
The file referred to in the package's `module` field now is compiled down to ES5.
|
|
12
|
+
|
|
13
|
+
## 1.1.0 (2019-11-08)
|
|
14
|
+
|
|
15
|
+
### New features
|
|
16
|
+
|
|
17
|
+
Add a `module` field to package json file.
|
|
18
|
+
|
|
19
|
+
## 1.0.1 (2019-04-18)
|
|
20
|
+
|
|
21
|
+
### Bug fixes
|
|
22
|
+
|
|
23
|
+
Make sure images and links don't render whatever happens to be in `node.attrs` to the DOM.
|
|
24
|
+
|
|
25
|
+
## 0.19.0 (2017-03-16)
|
|
26
|
+
|
|
27
|
+
### Breaking changes
|
|
28
|
+
|
|
29
|
+
Link marks are now non-inclusive by default.
|
|
30
|
+
|
|
31
|
+
## 0.12.0 (2016-10-21)
|
|
32
|
+
|
|
33
|
+
### Bug fixes
|
|
34
|
+
|
|
35
|
+
Don't treat \<b style=font-weight: normal> as strong when parsing.
|
|
36
|
+
(Google Docs puts such ridiculous HTML on the clipboard.)
|
|
37
|
+
|
|
38
|
+
## 0.11.0 (2016-09-21)
|
|
39
|
+
|
|
40
|
+
### Breaking changes
|
|
41
|
+
|
|
42
|
+
Moved into a separate module.
|
|
43
|
+
|
|
44
|
+
No longer exports the [specs](http://prosemirror.net/docs/ref/version/0.11.0.html#model.NodeSpec) for the nodes and
|
|
45
|
+
marks separately, since they are now plain objects, not subclasses.
|
|
46
|
+
They are still exported through [nodes](http://prosemirror.net/docs/ref/version/0.11.0.html#schema-basic.nodes) and
|
|
47
|
+
[marks](http://prosemirror.net/docs/ref/version/0.11.0.html#schema-basic.marks) objects.
|
|
48
|
+
|
|
49
|
+
The list-related nodes were moved to the [schema-list](http://prosemirror.net/docs/ref/version/0.11.0.html#schema-list)
|
|
50
|
+
module.
|
|
51
|
+
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
var 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
|
+
var 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: function 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: function toDOM() { return blockquoteDOM }
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
33
|
+
horizontal_rule: {
|
|
34
|
+
group: "block",
|
|
35
|
+
parseDOM: [{tag: "hr"}],
|
|
36
|
+
toDOM: function 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: function 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: function 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: function getAttrs(dom) {
|
|
87
|
+
return {
|
|
88
|
+
src: dom.getAttribute("src"),
|
|
89
|
+
title: dom.getAttribute("title"),
|
|
90
|
+
alt: dom.getAttribute("alt")
|
|
91
|
+
}
|
|
92
|
+
}}],
|
|
93
|
+
toDOM: function toDOM(node) { var ref = node.attrs;
|
|
94
|
+
var src = ref.src;
|
|
95
|
+
var alt = ref.alt;
|
|
96
|
+
var title = ref.title; return ["img", {src: src, alt: alt, title: title}] }
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
|
|
100
|
+
hard_break: {
|
|
101
|
+
inline: true,
|
|
102
|
+
group: "inline",
|
|
103
|
+
selectable: false,
|
|
104
|
+
parseDOM: [{tag: "br"}],
|
|
105
|
+
toDOM: function toDOM() { return brDOM }
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var emDOM = ["em", 0], strongDOM = ["strong", 0], codeDOM = ["code", 0];
|
|
110
|
+
|
|
111
|
+
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
|
|
112
|
+
var marks = {
|
|
113
|
+
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
|
|
114
|
+
// defaults to the empty string. Rendered and parsed as an `<a>`
|
|
115
|
+
// element.
|
|
116
|
+
link: {
|
|
117
|
+
attrs: {
|
|
118
|
+
href: {},
|
|
119
|
+
title: {default: null}
|
|
120
|
+
},
|
|
121
|
+
inclusive: false,
|
|
122
|
+
parseDOM: [{tag: "a[href]", getAttrs: function getAttrs(dom) {
|
|
123
|
+
return {href: dom.getAttribute("href"), title: dom.getAttribute("title")}
|
|
124
|
+
}}],
|
|
125
|
+
toDOM: function toDOM(node) { var ref = node.attrs;
|
|
126
|
+
var href = ref.href;
|
|
127
|
+
var title = ref.title; return ["a", {href: href, title: title}, 0] }
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
|
|
131
|
+
// Has parse rules that also match `<i>` and `font-style: italic`.
|
|
132
|
+
em: {
|
|
133
|
+
parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}],
|
|
134
|
+
toDOM: function toDOM() { return emDOM }
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
|
|
138
|
+
// also match `<b>` and `font-weight: bold`.
|
|
139
|
+
strong: {
|
|
140
|
+
parseDOM: [{tag: "strong"},
|
|
141
|
+
// This works around a Google Docs misbehavior where
|
|
142
|
+
// pasted content will be inexplicably wrapped in `<b>`
|
|
143
|
+
// tags with a font-weight normal.
|
|
144
|
+
{tag: "b", getAttrs: function (node) { return node.style.fontWeight != "normal" && null; }},
|
|
145
|
+
{style: "font-weight", getAttrs: function (value) { return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null; }}],
|
|
146
|
+
toDOM: function toDOM() { return strongDOM }
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
// :: MarkSpec Code font mark. Represented as a `<code>` element.
|
|
150
|
+
code: {
|
|
151
|
+
parseDOM: [{tag: "code"}],
|
|
152
|
+
toDOM: function toDOM() { return codeDOM }
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// :: Schema
|
|
157
|
+
// This schema roughly corresponds to the document schema used by
|
|
158
|
+
// [CommonMark](http://commonmark.org/), minus the list elements,
|
|
159
|
+
// which are defined in the [`prosemirror-schema-list`](#schema-list)
|
|
160
|
+
// module.
|
|
161
|
+
//
|
|
162
|
+
// To reuse elements from this schema, extend or read from its
|
|
163
|
+
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
|
|
164
|
+
var schema = new Schema({nodes: nodes, marks: marks});
|
|
165
|
+
|
|
166
|
+
export { marks, nodes, schema };
|
|
167
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -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,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,EA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E,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;;;;"}
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var prosemirrorModel = require('prosemirror-model');
|
|
6
6
|
|
|
7
|
+
var pDOM = ["p", 0], blockquoteDOM = ["blockquote", 0], hrDOM = ["hr"],
|
|
8
|
+
preDOM = ["pre", ["code", 0]], brDOM = ["br"];
|
|
9
|
+
|
|
7
10
|
// :: Object
|
|
8
11
|
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
|
|
9
12
|
var nodes = {
|
|
@@ -18,7 +21,7 @@ var nodes = {
|
|
|
18
21
|
content: "inline*",
|
|
19
22
|
group: "block",
|
|
20
23
|
parseDOM: [{tag: "p"}],
|
|
21
|
-
toDOM: function toDOM() { return
|
|
24
|
+
toDOM: function toDOM() { return pDOM }
|
|
22
25
|
},
|
|
23
26
|
|
|
24
27
|
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
@@ -27,14 +30,14 @@ var nodes = {
|
|
|
27
30
|
group: "block",
|
|
28
31
|
defining: true,
|
|
29
32
|
parseDOM: [{tag: "blockquote"}],
|
|
30
|
-
toDOM: function toDOM() { return
|
|
33
|
+
toDOM: function toDOM() { return blockquoteDOM }
|
|
31
34
|
},
|
|
32
35
|
|
|
33
36
|
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
34
37
|
horizontal_rule: {
|
|
35
38
|
group: "block",
|
|
36
39
|
parseDOM: [{tag: "hr"}],
|
|
37
|
-
toDOM: function toDOM() { return
|
|
40
|
+
toDOM: function toDOM() { return hrDOM }
|
|
38
41
|
},
|
|
39
42
|
|
|
40
43
|
// :: NodeSpec A heading textblock, with a `level` attribute that
|
|
@@ -64,7 +67,7 @@ var nodes = {
|
|
|
64
67
|
code: true,
|
|
65
68
|
defining: true,
|
|
66
69
|
parseDOM: [{tag: "pre", preserveWhitespace: "full"}],
|
|
67
|
-
toDOM: function toDOM() { return
|
|
70
|
+
toDOM: function toDOM() { return preDOM }
|
|
68
71
|
},
|
|
69
72
|
|
|
70
73
|
// :: NodeSpec The text node.
|
|
@@ -91,7 +94,10 @@ var nodes = {
|
|
|
91
94
|
alt: dom.getAttribute("alt")
|
|
92
95
|
}
|
|
93
96
|
}}],
|
|
94
|
-
toDOM: function toDOM(node) {
|
|
97
|
+
toDOM: function toDOM(node) { var ref = node.attrs;
|
|
98
|
+
var src = ref.src;
|
|
99
|
+
var alt = ref.alt;
|
|
100
|
+
var title = ref.title; return ["img", {src: src, alt: alt, title: title}] }
|
|
95
101
|
},
|
|
96
102
|
|
|
97
103
|
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
|
|
@@ -100,10 +106,12 @@ var nodes = {
|
|
|
100
106
|
group: "inline",
|
|
101
107
|
selectable: false,
|
|
102
108
|
parseDOM: [{tag: "br"}],
|
|
103
|
-
toDOM: function toDOM() { return
|
|
109
|
+
toDOM: function toDOM() { return brDOM }
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
112
|
|
|
113
|
+
var emDOM = ["em", 0], strongDOM = ["strong", 0], codeDOM = ["code", 0];
|
|
114
|
+
|
|
107
115
|
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
|
|
108
116
|
var marks = {
|
|
109
117
|
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
|
|
@@ -118,14 +126,16 @@ var marks = {
|
|
|
118
126
|
parseDOM: [{tag: "a[href]", getAttrs: function getAttrs(dom) {
|
|
119
127
|
return {href: dom.getAttribute("href"), title: dom.getAttribute("title")}
|
|
120
128
|
}}],
|
|
121
|
-
toDOM: function toDOM(node) {
|
|
129
|
+
toDOM: function toDOM(node) { var ref = node.attrs;
|
|
130
|
+
var href = ref.href;
|
|
131
|
+
var title = ref.title; return ["a", {href: href, title: title}, 0] }
|
|
122
132
|
},
|
|
123
133
|
|
|
124
134
|
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
|
|
125
135
|
// Has parse rules that also match `<i>` and `font-style: italic`.
|
|
126
136
|
em: {
|
|
127
137
|
parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}],
|
|
128
|
-
toDOM: function toDOM() { return
|
|
138
|
+
toDOM: function toDOM() { return emDOM }
|
|
129
139
|
},
|
|
130
140
|
|
|
131
141
|
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
|
|
@@ -137,18 +147,18 @@ var marks = {
|
|
|
137
147
|
// tags with a font-weight normal.
|
|
138
148
|
{tag: "b", getAttrs: function (node) { return node.style.fontWeight != "normal" && null; }},
|
|
139
149
|
{style: "font-weight", getAttrs: function (value) { return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null; }}],
|
|
140
|
-
toDOM: function toDOM() { return
|
|
150
|
+
toDOM: function toDOM() { return strongDOM }
|
|
141
151
|
},
|
|
142
152
|
|
|
143
153
|
// :: MarkSpec Code font mark. Represented as a `<code>` element.
|
|
144
154
|
code: {
|
|
145
155
|
parseDOM: [{tag: "code"}],
|
|
146
|
-
toDOM: function toDOM() { return
|
|
156
|
+
toDOM: function toDOM() { return codeDOM }
|
|
147
157
|
}
|
|
148
158
|
};
|
|
149
159
|
|
|
150
160
|
// :: Schema
|
|
151
|
-
// This schema
|
|
161
|
+
// This schema roughly corresponds to the document schema used by
|
|
152
162
|
// [CommonMark](http://commonmark.org/), minus the list elements,
|
|
153
163
|
// which are defined in the [`prosemirror-schema-list`](#schema-list)
|
|
154
164
|
// module.
|
|
@@ -157,7 +167,7 @@ var marks = {
|
|
|
157
167
|
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
|
|
158
168
|
var schema = new prosemirrorModel.Schema({nodes: nodes, marks: marks});
|
|
159
169
|
|
|
160
|
-
exports.nodes = nodes;
|
|
161
170
|
exports.marks = marks;
|
|
171
|
+
exports.nodes = nodes;
|
|
162
172
|
exports.schema = schema;
|
|
163
|
-
//# sourceMappingURL=
|
|
173
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,qBAA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;;;;AAUD,AAAY,IAAC,MAAM,GAAG,IAAIC,uBAAM,CAAC,QAAC,KAAK,SAAE,KAAK,CAAC,CAAC;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-schema-basic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Basic schema elements for ProseMirror",
|
|
5
|
-
"main": "dist/
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"maintainers": [
|
|
8
9
|
{
|
|
@@ -16,11 +17,11 @@
|
|
|
16
17
|
"url": "git://github.com/prosemirror/prosemirror-schema-basic.git"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"prosemirror-model": "^1.
|
|
20
|
+
"prosemirror-model": "^1.2.0"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
|
-
"rollup": "^
|
|
23
|
-
"rollup
|
|
23
|
+
"rollup": "^1.26.3",
|
|
24
|
+
"@rollup/plugin-buble": "^0.20.0"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"test": "true",
|
package/rollup.config.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
input:
|
|
3
|
-
output: {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
input: './src/schema-basic.js',
|
|
3
|
+
output: [{
|
|
4
|
+
file: 'dist/index.js',
|
|
5
|
+
format: 'cjs',
|
|
6
|
+
sourcemap: true
|
|
7
|
+
}, {
|
|
8
|
+
file: 'dist/index.es.js',
|
|
9
|
+
format: 'es',
|
|
10
|
+
sourcemap: true
|
|
11
|
+
}],
|
|
12
|
+
plugins: [require('@rollup/plugin-buble')()],
|
|
6
13
|
external(id) { return !/^[\.\/]/.test(id) }
|
|
7
14
|
}
|
package/src/schema-basic.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {Schema} from "prosemirror-model"
|
|
2
2
|
|
|
3
|
+
const pDOM = ["p", 0], blockquoteDOM = ["blockquote", 0], hrDOM = ["hr"],
|
|
4
|
+
preDOM = ["pre", ["code", 0]], brDOM = ["br"]
|
|
5
|
+
|
|
3
6
|
// :: Object
|
|
4
7
|
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
|
|
5
8
|
export const nodes = {
|
|
@@ -14,7 +17,7 @@ export const nodes = {
|
|
|
14
17
|
content: "inline*",
|
|
15
18
|
group: "block",
|
|
16
19
|
parseDOM: [{tag: "p"}],
|
|
17
|
-
toDOM() { return
|
|
20
|
+
toDOM() { return pDOM }
|
|
18
21
|
},
|
|
19
22
|
|
|
20
23
|
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
@@ -23,14 +26,14 @@ export const nodes = {
|
|
|
23
26
|
group: "block",
|
|
24
27
|
defining: true,
|
|
25
28
|
parseDOM: [{tag: "blockquote"}],
|
|
26
|
-
toDOM() { return
|
|
29
|
+
toDOM() { return blockquoteDOM }
|
|
27
30
|
},
|
|
28
31
|
|
|
29
32
|
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
30
33
|
horizontal_rule: {
|
|
31
34
|
group: "block",
|
|
32
35
|
parseDOM: [{tag: "hr"}],
|
|
33
|
-
toDOM() { return
|
|
36
|
+
toDOM() { return hrDOM }
|
|
34
37
|
},
|
|
35
38
|
|
|
36
39
|
// :: NodeSpec A heading textblock, with a `level` attribute that
|
|
@@ -60,7 +63,7 @@ export const nodes = {
|
|
|
60
63
|
code: true,
|
|
61
64
|
defining: true,
|
|
62
65
|
parseDOM: [{tag: "pre", preserveWhitespace: "full"}],
|
|
63
|
-
toDOM() { return
|
|
66
|
+
toDOM() { return preDOM }
|
|
64
67
|
},
|
|
65
68
|
|
|
66
69
|
// :: NodeSpec The text node.
|
|
@@ -87,7 +90,7 @@ export const nodes = {
|
|
|
87
90
|
alt: dom.getAttribute("alt")
|
|
88
91
|
}
|
|
89
92
|
}}],
|
|
90
|
-
toDOM(node) { return ["img",
|
|
93
|
+
toDOM(node) { let {src, alt, title} = node.attrs; return ["img", {src, alt, title}] }
|
|
91
94
|
},
|
|
92
95
|
|
|
93
96
|
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
|
|
@@ -96,10 +99,12 @@ export const nodes = {
|
|
|
96
99
|
group: "inline",
|
|
97
100
|
selectable: false,
|
|
98
101
|
parseDOM: [{tag: "br"}],
|
|
99
|
-
toDOM() { return
|
|
102
|
+
toDOM() { return brDOM }
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
const emDOM = ["em", 0], strongDOM = ["strong", 0], codeDOM = ["code", 0]
|
|
107
|
+
|
|
103
108
|
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
|
|
104
109
|
export const marks = {
|
|
105
110
|
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
|
|
@@ -114,14 +119,14 @@ export const marks = {
|
|
|
114
119
|
parseDOM: [{tag: "a[href]", getAttrs(dom) {
|
|
115
120
|
return {href: dom.getAttribute("href"), title: dom.getAttribute("title")}
|
|
116
121
|
}}],
|
|
117
|
-
toDOM(node) { return ["a",
|
|
122
|
+
toDOM(node) { let {href, title} = node.attrs; return ["a", {href, title}, 0] }
|
|
118
123
|
},
|
|
119
124
|
|
|
120
125
|
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
|
|
121
126
|
// Has parse rules that also match `<i>` and `font-style: italic`.
|
|
122
127
|
em: {
|
|
123
128
|
parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}],
|
|
124
|
-
toDOM() { return
|
|
129
|
+
toDOM() { return emDOM }
|
|
125
130
|
},
|
|
126
131
|
|
|
127
132
|
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
|
|
@@ -133,18 +138,18 @@ export const marks = {
|
|
|
133
138
|
// tags with a font-weight normal.
|
|
134
139
|
{tag: "b", getAttrs: node => node.style.fontWeight != "normal" && null},
|
|
135
140
|
{style: "font-weight", getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null}],
|
|
136
|
-
toDOM() { return
|
|
141
|
+
toDOM() { return strongDOM }
|
|
137
142
|
},
|
|
138
143
|
|
|
139
144
|
// :: MarkSpec Code font mark. Represented as a `<code>` element.
|
|
140
145
|
code: {
|
|
141
146
|
parseDOM: [{tag: "code"}],
|
|
142
|
-
toDOM() { return
|
|
147
|
+
toDOM() { return codeDOM }
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
// :: Schema
|
|
147
|
-
// This schema
|
|
152
|
+
// This schema roughly corresponds to the document schema used by
|
|
148
153
|
// [CommonMark](http://commonmark.org/), minus the list elements,
|
|
149
154
|
// which are defined in the [`prosemirror-schema-list`](#schema-list)
|
|
150
155
|
// module.
|
package/dist/schema-basic.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-basic.js","sources":["../src/schema-basic.js"],"sourcesContent":["import {Schema} from \"prosemirror-model\"\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 [\"p\", 0] }\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 [\"blockquote\", 0] }\n },\n\n // :: NodeSpec A horizontal rule (`<hr>`).\n horizontal_rule: {\n group: \"block\",\n parseDOM: [{tag: \"hr\"}],\n toDOM() { return [\"hr\"] }\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 [\"pre\", [\"code\", 0]] }\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) { return [\"img\", node.attrs] }\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 [\"br\"] }\n }\n}\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) { return [\"a\", node.attrs] }\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 [\"em\"] }\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 [\"strong\"] }\n },\n\n // :: MarkSpec Code font mark. Represented as a `<code>` element.\n code: {\n parseDOM: [{tag: \"code\"}],\n toDOM() { return [\"code\"] }\n }\n}\n\n// :: Schema\n// This schema rougly 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":";;;;;;;;AAIA,AAAOA,IAAM,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,KAAK,gBAAA,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE;GAC5B;;;EAGD,UAAU,EAAE;IACV,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,OAAO;IACd,QAAQ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