html-standard 0.0.1 → 0.0.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/.prettierignore +1 -0
- package/.prettierrc +1 -0
- package/README.md +19 -1
- package/jest.config.js +7 -0
- package/package.json +20 -4
- package/src/elements/common/attributes.ts +34 -0
- package/src/elements/common/contents.ts +191 -0
- package/src/elements/document/html.ts +18 -0
- package/src/elements/document-metadata/base.ts +9 -0
- package/src/elements/document-metadata/head.ts +21 -0
- package/src/elements/document-metadata/link.ts +27 -0
- package/src/elements/document-metadata/meta.ts +15 -0
- package/src/elements/document-metadata/style.ts +14 -0
- package/src/elements/document-metadata/title.ts +14 -0
- package/src/elements/edits/del.ts +15 -0
- package/src/elements/edits/ins.ts +15 -0
- package/src/elements/embedded-content/area.ts +19 -0
- package/src/elements/embedded-content/audio.ts +57 -0
- package/src/elements/embedded-content/embed.ts +9 -0
- package/src/elements/embedded-content/iframe.ts +20 -0
- package/src/elements/embedded-content/img.ts +23 -0
- package/src/elements/embedded-content/map.ts +15 -0
- package/src/elements/embedded-content/object.ts +22 -0
- package/src/elements/embedded-content/picture.ts +31 -0
- package/src/elements/embedded-content/source.ts +17 -0
- package/src/elements/embedded-content/track.ts +16 -0
- package/src/elements/embedded-content/video.ts +63 -0
- package/src/elements/forms/button.ts +39 -0
- package/src/elements/forms/datalist.ts +29 -0
- package/src/elements/forms/fieldset.ts +19 -0
- package/src/elements/forms/form.ts +36 -0
- package/src/elements/forms/input.ts +45 -0
- package/src/elements/forms/label.ts +18 -0
- package/src/elements/forms/legend.ts +16 -0
- package/src/elements/forms/meter.ts +32 -0
- package/src/elements/forms/optgroup.ts +16 -0
- package/src/elements/forms/option.ts +45 -0
- package/src/elements/forms/output.ts +15 -0
- package/src/elements/forms/progress.ts +18 -0
- package/src/elements/forms/select.ts +29 -0
- package/src/elements/forms/textarea.ts +29 -0
- package/src/elements/grouping-content/blockquote.ts +15 -0
- package/src/elements/grouping-content/dd.ts +15 -0
- package/src/elements/grouping-content/div.ts +43 -0
- package/src/elements/grouping-content/dl.ts +52 -0
- package/src/elements/grouping-content/dt.ts +26 -0
- package/src/elements/grouping-content/figcaption.ts +15 -0
- package/src/elements/grouping-content/figure.ts +42 -0
- package/src/elements/grouping-content/hr.ts +9 -0
- package/src/elements/grouping-content/li.ts +31 -0
- package/src/elements/grouping-content/main.ts +15 -0
- package/src/elements/grouping-content/menu.ts +16 -0
- package/src/elements/grouping-content/ol.ts +16 -0
- package/src/elements/grouping-content/p.ts +15 -0
- package/src/elements/grouping-content/pre.ts +15 -0
- package/src/elements/grouping-content/search.ts +15 -0
- package/src/elements/grouping-content/ul.ts +16 -0
- package/src/elements/index.ts +137 -0
- package/src/elements/interactive-elements/details.ts +19 -0
- package/src/elements/interactive-elements/dialog.ts +15 -0
- package/src/elements/interactive-elements/summary.ts +16 -0
- package/src/elements/scripting/canvas.ts +19 -0
- package/src/elements/scripting/noscript.ts +15 -0
- package/src/elements/scripting/script.ts +26 -0
- package/src/elements/scripting/slot.ts +15 -0
- package/src/elements/scripting/template.ts +14 -0
- package/src/elements/sections/address.ts +26 -0
- package/src/elements/sections/article.ts +15 -0
- package/src/elements/sections/aside.ts +15 -0
- package/src/elements/sections/body.ts +34 -0
- package/src/elements/sections/footer.ts +21 -0
- package/src/elements/sections/h1.ts +15 -0
- package/src/elements/sections/h2.ts +2 -0
- package/src/elements/sections/h3.ts +2 -0
- package/src/elements/sections/h4.ts +2 -0
- package/src/elements/sections/h5.ts +2 -0
- package/src/elements/sections/h6.ts +2 -0
- package/src/elements/sections/header.ts +21 -0
- package/src/elements/sections/hrgroup.ts +39 -0
- package/src/elements/sections/nav.ts +15 -0
- package/src/elements/sections/section.ts +15 -0
- package/src/elements/tabular-data/caption.ts +18 -0
- package/src/elements/tabular-data/col.ts +9 -0
- package/src/elements/tabular-data/colgroup.ts +26 -0
- package/src/elements/tabular-data/table.ts +68 -0
- package/src/elements/tabular-data/tbody.ts +16 -0
- package/src/elements/tabular-data/td.ts +15 -0
- package/src/elements/tabular-data/tfoot.ts +16 -0
- package/src/elements/tabular-data/th.ts +32 -0
- package/src/elements/tabular-data/thead.ts +16 -0
- package/src/elements/tabular-data/tr.ts +16 -0
- package/src/elements/text-level-semantics/a.ts +49 -0
- package/src/elements/text-level-semantics/abbr.ts +15 -0
- package/src/elements/text-level-semantics/b.ts +15 -0
- package/src/elements/text-level-semantics/bdi.ts +15 -0
- package/src/elements/text-level-semantics/bdo.ts +15 -0
- package/src/elements/text-level-semantics/br.ts +9 -0
- package/src/elements/text-level-semantics/cite.ts +15 -0
- package/src/elements/text-level-semantics/code.ts +15 -0
- package/src/elements/text-level-semantics/data.ts +15 -0
- package/src/elements/text-level-semantics/dfn.ts +18 -0
- package/src/elements/text-level-semantics/em.ts +15 -0
- package/src/elements/text-level-semantics/i.ts +15 -0
- package/src/elements/text-level-semantics/kbd.ts +15 -0
- package/src/elements/text-level-semantics/mark.ts +15 -0
- package/src/elements/text-level-semantics/q.ts +15 -0
- package/src/elements/text-level-semantics/rp.ts +15 -0
- package/src/elements/text-level-semantics/rt.ts +15 -0
- package/src/elements/text-level-semantics/ruby.ts +16 -0
- package/src/elements/text-level-semantics/s.ts +15 -0
- package/src/elements/text-level-semantics/samp.ts +15 -0
- package/src/elements/text-level-semantics/small.ts +15 -0
- package/src/elements/text-level-semantics/span.ts +15 -0
- package/src/elements/text-level-semantics/strong.ts +15 -0
- package/src/elements/text-level-semantics/sub.ts +15 -0
- package/src/elements/text-level-semantics/sup.ts +3 -0
- package/src/elements/text-level-semantics/time.ts +30 -0
- package/src/elements/text-level-semantics/u.ts +15 -0
- package/src/elements/text-level-semantics/var.ts +15 -0
- package/src/elements/text-level-semantics/wbr.ts +9 -0
- package/src/elements/types.ts +71 -0
- package/src/elements/utils/contentAttributes.ts +23 -0
- package/src/elements/utils/contents.ts +0 -0
- package/src/getElementSpec.ts +20 -0
- package/src/index.ts +1 -0
- package/src/utils/set.ts +20 -0
- package/tsconfig.json +10 -0
- package/tsup.config.ts +11 -0
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dist
|
package/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/README.md
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
# html-
|
|
1
|
+
# html-standard
|
|
2
|
+
|
|
3
|
+
`html-standard` is a **work-in-progress** JavaScript/TypeScript library that provides structured data from the [HTML Living Standard](https://html.spec.whatwg.org/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```console
|
|
8
|
+
npm install html-standard
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { getElementSpec } from "html-standard";
|
|
15
|
+
|
|
16
|
+
const divSpec = getElementSpec("div");
|
|
17
|
+
|
|
18
|
+
divSpec.attributes.has("id"); // true
|
|
19
|
+
```
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-standard",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
6
13
|
"scripts": {
|
|
7
|
-
"
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"ts": "tsc --noEmit",
|
|
16
|
+
"test": "jest"
|
|
8
17
|
},
|
|
9
18
|
"author": "",
|
|
10
|
-
"license": "ISC"
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/jest": "^29.5.14",
|
|
22
|
+
"jest": "^29.7.0",
|
|
23
|
+
"prettier": "^3.5.3",
|
|
24
|
+
"ts-jest": "^29.3.1",
|
|
25
|
+
"tsup": "^8.4.0"
|
|
26
|
+
}
|
|
11
27
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const globalAttributes = new Set([
|
|
2
|
+
"accesskey",
|
|
3
|
+
"autocapitalize",
|
|
4
|
+
"autocorrect",
|
|
5
|
+
"autofocus",
|
|
6
|
+
"contenteditable",
|
|
7
|
+
"dir",
|
|
8
|
+
"draggable",
|
|
9
|
+
"enterkeyhint",
|
|
10
|
+
"hidden",
|
|
11
|
+
"inert",
|
|
12
|
+
"inputmode",
|
|
13
|
+
"is",
|
|
14
|
+
"itemid",
|
|
15
|
+
"itemprop",
|
|
16
|
+
"itemref",
|
|
17
|
+
"itemscope",
|
|
18
|
+
"itemtype",
|
|
19
|
+
"lang",
|
|
20
|
+
"nonce",
|
|
21
|
+
"popover",
|
|
22
|
+
"spellcheck",
|
|
23
|
+
"style",
|
|
24
|
+
"tabindex",
|
|
25
|
+
"title",
|
|
26
|
+
"translate",
|
|
27
|
+
"writingsuggestions",
|
|
28
|
+
"class",
|
|
29
|
+
"id",
|
|
30
|
+
"slot",
|
|
31
|
+
"xmlns",
|
|
32
|
+
"xml:lang",
|
|
33
|
+
"xml:space",
|
|
34
|
+
]);
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
export const contents = {
|
|
2
|
+
metadataContent: new Set([
|
|
3
|
+
"base",
|
|
4
|
+
"link",
|
|
5
|
+
"meta",
|
|
6
|
+
"noscript",
|
|
7
|
+
"script",
|
|
8
|
+
"style",
|
|
9
|
+
"template",
|
|
10
|
+
"title",
|
|
11
|
+
]),
|
|
12
|
+
flowContent: new Set([
|
|
13
|
+
"a",
|
|
14
|
+
"abbr",
|
|
15
|
+
"address",
|
|
16
|
+
"area",
|
|
17
|
+
"article",
|
|
18
|
+
"aside",
|
|
19
|
+
"audio",
|
|
20
|
+
"b",
|
|
21
|
+
"bdi",
|
|
22
|
+
"bdo",
|
|
23
|
+
"blockquote",
|
|
24
|
+
"br",
|
|
25
|
+
"button",
|
|
26
|
+
"canvas",
|
|
27
|
+
"cite",
|
|
28
|
+
"code",
|
|
29
|
+
"data",
|
|
30
|
+
"datalist",
|
|
31
|
+
"del",
|
|
32
|
+
"details",
|
|
33
|
+
"dfn",
|
|
34
|
+
"dialog",
|
|
35
|
+
"div",
|
|
36
|
+
"dl",
|
|
37
|
+
"em",
|
|
38
|
+
"embed",
|
|
39
|
+
"fieldset",
|
|
40
|
+
"figure",
|
|
41
|
+
"footer",
|
|
42
|
+
"form",
|
|
43
|
+
"h1",
|
|
44
|
+
"h2",
|
|
45
|
+
"h3",
|
|
46
|
+
"h4",
|
|
47
|
+
"h5",
|
|
48
|
+
"h6",
|
|
49
|
+
"header",
|
|
50
|
+
"hgroup",
|
|
51
|
+
"hr",
|
|
52
|
+
"i",
|
|
53
|
+
"iframe",
|
|
54
|
+
"img",
|
|
55
|
+
"input",
|
|
56
|
+
"ins",
|
|
57
|
+
"kbd",
|
|
58
|
+
"label",
|
|
59
|
+
"link",
|
|
60
|
+
"main",
|
|
61
|
+
"map",
|
|
62
|
+
"mark",
|
|
63
|
+
"math",
|
|
64
|
+
"menu",
|
|
65
|
+
"meta",
|
|
66
|
+
"meter",
|
|
67
|
+
"nav",
|
|
68
|
+
"noscript",
|
|
69
|
+
"object",
|
|
70
|
+
"ol",
|
|
71
|
+
"output",
|
|
72
|
+
"p",
|
|
73
|
+
"picture",
|
|
74
|
+
"pre",
|
|
75
|
+
"progress",
|
|
76
|
+
"q",
|
|
77
|
+
"ruby",
|
|
78
|
+
"s",
|
|
79
|
+
"samp",
|
|
80
|
+
"script",
|
|
81
|
+
"search",
|
|
82
|
+
"section",
|
|
83
|
+
"select",
|
|
84
|
+
"slot",
|
|
85
|
+
"small",
|
|
86
|
+
"span",
|
|
87
|
+
"strong",
|
|
88
|
+
"sub",
|
|
89
|
+
"sup",
|
|
90
|
+
"svg",
|
|
91
|
+
"table",
|
|
92
|
+
"template",
|
|
93
|
+
"textarea",
|
|
94
|
+
"time",
|
|
95
|
+
"u",
|
|
96
|
+
"ul",
|
|
97
|
+
"var",
|
|
98
|
+
"video",
|
|
99
|
+
"wbr",
|
|
100
|
+
"#text",
|
|
101
|
+
]),
|
|
102
|
+
phrasingContent: new Set([
|
|
103
|
+
"a",
|
|
104
|
+
"abbr",
|
|
105
|
+
"area",
|
|
106
|
+
"audio",
|
|
107
|
+
"b",
|
|
108
|
+
"bdi",
|
|
109
|
+
"bdo",
|
|
110
|
+
"br",
|
|
111
|
+
"button",
|
|
112
|
+
"canvas",
|
|
113
|
+
"cite",
|
|
114
|
+
"code",
|
|
115
|
+
"data",
|
|
116
|
+
"datalist",
|
|
117
|
+
"del",
|
|
118
|
+
"dfn",
|
|
119
|
+
"em",
|
|
120
|
+
"embed",
|
|
121
|
+
"i",
|
|
122
|
+
"iframe",
|
|
123
|
+
"img",
|
|
124
|
+
"input",
|
|
125
|
+
"ins",
|
|
126
|
+
"kbd",
|
|
127
|
+
"label",
|
|
128
|
+
"link",
|
|
129
|
+
"map",
|
|
130
|
+
"mark",
|
|
131
|
+
"math",
|
|
132
|
+
"meta",
|
|
133
|
+
"meter",
|
|
134
|
+
"noscript",
|
|
135
|
+
"object",
|
|
136
|
+
"output",
|
|
137
|
+
"picture",
|
|
138
|
+
"progress",
|
|
139
|
+
"q",
|
|
140
|
+
"ruby",
|
|
141
|
+
"s",
|
|
142
|
+
"samp",
|
|
143
|
+
"script",
|
|
144
|
+
"select",
|
|
145
|
+
"slot",
|
|
146
|
+
"small",
|
|
147
|
+
"span",
|
|
148
|
+
"strong",
|
|
149
|
+
"sub",
|
|
150
|
+
"sup",
|
|
151
|
+
"svg",
|
|
152
|
+
"template",
|
|
153
|
+
"textarea",
|
|
154
|
+
"time",
|
|
155
|
+
"u",
|
|
156
|
+
"var",
|
|
157
|
+
"video",
|
|
158
|
+
"wbr",
|
|
159
|
+
"#text",
|
|
160
|
+
]),
|
|
161
|
+
scriptSupportingElements: new Set(["script", "template"]),
|
|
162
|
+
headingContent: new Set(["h1", "h2", "h3", "h4", "h5", "h6", "hgroup"]),
|
|
163
|
+
sectioningContent: new Set(["article", "aside", "nav", "section"]),
|
|
164
|
+
transparentContent: new Set(["#transparent"]),
|
|
165
|
+
interactiveContent: new Set([
|
|
166
|
+
"a",
|
|
167
|
+
"audio",
|
|
168
|
+
"button",
|
|
169
|
+
"details",
|
|
170
|
+
"embed",
|
|
171
|
+
"iframe",
|
|
172
|
+
"img",
|
|
173
|
+
"input",
|
|
174
|
+
"label",
|
|
175
|
+
"select",
|
|
176
|
+
"text",
|
|
177
|
+
"area",
|
|
178
|
+
"video",
|
|
179
|
+
]),
|
|
180
|
+
text: new Set("#text"),
|
|
181
|
+
mediaElements: new Set(["audio", "video"]),
|
|
182
|
+
labelableElements: new Set([
|
|
183
|
+
"button",
|
|
184
|
+
"input",
|
|
185
|
+
"meter",
|
|
186
|
+
"output",
|
|
187
|
+
"progress",
|
|
188
|
+
"select",
|
|
189
|
+
"textarea",
|
|
190
|
+
]),
|
|
191
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
|
|
4
|
+
const htmlSpec: ElementSpec = {
|
|
5
|
+
contents: [
|
|
6
|
+
{
|
|
7
|
+
type: "required",
|
|
8
|
+
contents: new Set(["head"]),
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: "required",
|
|
12
|
+
contents: new Set(["body"]),
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
attributes: contentAttributes(true),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const html: GetElementSpec = () => htmlSpec;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const baseSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, ["href", "target"]),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const base: GetElementSpec = () => baseSpec;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { contents } from "../common/contents";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
4
|
+
|
|
5
|
+
const headSpec: ElementSpec = {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
type: "oneOrMore",
|
|
9
|
+
contents: contents.metadataContent,
|
|
10
|
+
constraints: {
|
|
11
|
+
children: new Map([
|
|
12
|
+
["title", { required: true }],
|
|
13
|
+
["base", { max: 1 }],
|
|
14
|
+
]),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
attributes: contentAttributes(true),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const head: GetElementSpec = () => headSpec;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const linkSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, [
|
|
7
|
+
"href",
|
|
8
|
+
"crossorigin",
|
|
9
|
+
"rel",
|
|
10
|
+
"media",
|
|
11
|
+
"integrity",
|
|
12
|
+
"hreflang",
|
|
13
|
+
"type",
|
|
14
|
+
"referrerpolicy",
|
|
15
|
+
"sizes",
|
|
16
|
+
"imagesrcset",
|
|
17
|
+
"imagesizes",
|
|
18
|
+
"as",
|
|
19
|
+
"blocking",
|
|
20
|
+
"color",
|
|
21
|
+
"disabled",
|
|
22
|
+
"fetchpriority",
|
|
23
|
+
"title",
|
|
24
|
+
]),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const link: GetElementSpec = () => linkSpec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const metaSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, [
|
|
7
|
+
"name",
|
|
8
|
+
"http-equiv",
|
|
9
|
+
"content",
|
|
10
|
+
"charset",
|
|
11
|
+
"media",
|
|
12
|
+
]),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const meta: GetElementSpec = () => metaSpec;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const styleSpec: ElementSpec = {
|
|
5
|
+
contents: [
|
|
6
|
+
{
|
|
7
|
+
type: "required",
|
|
8
|
+
contents: new Set(["#text"]),
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
attributes: contentAttributes(true, ["media", "blocking", "title"]),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const style: GetElementSpec = () => styleSpec;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const titleSpec: ElementSpec = {
|
|
5
|
+
contents: [
|
|
6
|
+
{
|
|
7
|
+
type: "required",
|
|
8
|
+
contents: new Set(["#text"]),
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
attributes: contentAttributes(true),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const title: GetElementSpec = () => titleSpec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { contents } from "../common/contents";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
4
|
+
|
|
5
|
+
const delSpec: ElementSpec = {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
type: "oneOrMore",
|
|
9
|
+
contents: contents.transparentContent,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
attributes: contentAttributes(true, ["cite", "datetime"]),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const del: GetElementSpec = () => delSpec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { contents } from "../common/contents";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
4
|
+
|
|
5
|
+
const insSpec: ElementSpec = {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
type: "oneOrMore",
|
|
9
|
+
contents: contents.transparentContent,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
attributes: contentAttributes(true, ["cite", "datetime"]),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ins: GetElementSpec = () => insSpec;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const areaSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, [
|
|
7
|
+
"alt",
|
|
8
|
+
"coords",
|
|
9
|
+
"shape",
|
|
10
|
+
"href",
|
|
11
|
+
"target",
|
|
12
|
+
"download",
|
|
13
|
+
"ping",
|
|
14
|
+
"rel",
|
|
15
|
+
"referrerpolicy",
|
|
16
|
+
]),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const area: GetElementSpec = () => areaSpec;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { setsToMap } from "../../utils/set";
|
|
2
|
+
import { contents } from "../common/contents";
|
|
3
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
4
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
5
|
+
|
|
6
|
+
const attributes = contentAttributes(true, [
|
|
7
|
+
"src",
|
|
8
|
+
"crossorigin",
|
|
9
|
+
"preload",
|
|
10
|
+
"autoplay",
|
|
11
|
+
"loop",
|
|
12
|
+
"muted",
|
|
13
|
+
"controls",
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const audioWithSrcSpec: ElementSpec = {
|
|
17
|
+
contents: [
|
|
18
|
+
{
|
|
19
|
+
type: "zeroOrMore",
|
|
20
|
+
contents: new Set(["track"]),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "oneOrMore",
|
|
24
|
+
contents: contents.transparentContent,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
attributes,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const audioWithoutSrcSpec: ElementSpec = {
|
|
31
|
+
contents: [
|
|
32
|
+
{
|
|
33
|
+
type: "zeroOrMore",
|
|
34
|
+
contents: new Set("source"),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: "zeroOrMore",
|
|
38
|
+
contents: new Set("track"),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "oneOrMore",
|
|
42
|
+
contents: contents.transparentContent,
|
|
43
|
+
constraints: {
|
|
44
|
+
descendants: setsToMap({ disallow: true }, contents.mediaElements),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
attributes,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const audio: GetElementSpec = (state) => {
|
|
52
|
+
const attributes = state?.attributes || {};
|
|
53
|
+
if (!!attributes["src"]) {
|
|
54
|
+
return audioWithSrcSpec;
|
|
55
|
+
}
|
|
56
|
+
return audioWithoutSrcSpec;
|
|
57
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const embedSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, ["src", "type", "width", "height"]),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const embed: GetElementSpec = () => embedSpec;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const iframeSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, [
|
|
7
|
+
"src",
|
|
8
|
+
"srcdoc",
|
|
9
|
+
"name",
|
|
10
|
+
"sandbox",
|
|
11
|
+
"allow",
|
|
12
|
+
"allowfullscreen",
|
|
13
|
+
"width",
|
|
14
|
+
"height",
|
|
15
|
+
"referrerpolicy",
|
|
16
|
+
"loading",
|
|
17
|
+
]),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const iframe: GetElementSpec = () => iframeSpec;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const imgSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, [
|
|
7
|
+
"alt",
|
|
8
|
+
"src",
|
|
9
|
+
"srcset",
|
|
10
|
+
"sizes",
|
|
11
|
+
"crossorigin",
|
|
12
|
+
"usemap",
|
|
13
|
+
"ismap",
|
|
14
|
+
"width",
|
|
15
|
+
"height",
|
|
16
|
+
"referrerpolicy",
|
|
17
|
+
"decoding",
|
|
18
|
+
"loading",
|
|
19
|
+
"fetchpriority",
|
|
20
|
+
]),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const img: GetElementSpec = () => imgSpec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { contents } from "../common/contents";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
4
|
+
|
|
5
|
+
const mapSpec: ElementSpec = {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
type: "oneOrMore",
|
|
9
|
+
contents: contents.transparentContent,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
attributes: contentAttributes(true, ["name"]),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const map: GetElementSpec = () => mapSpec;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { contents } from "../common/contents";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
4
|
+
|
|
5
|
+
const objectSpec: ElementSpec = {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
type: "oneOrMore",
|
|
9
|
+
contents: contents.transparentContent,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
attributes: contentAttributes(true, [
|
|
13
|
+
"data",
|
|
14
|
+
"type",
|
|
15
|
+
"name",
|
|
16
|
+
"form",
|
|
17
|
+
"width",
|
|
18
|
+
"height",
|
|
19
|
+
]),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const object: GetElementSpec = () => objectSpec;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { contents } from "../common/contents";
|
|
2
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
3
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
4
|
+
|
|
5
|
+
const pictureSpec: ElementSpec = {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
type: "zeroOrMore",
|
|
9
|
+
contents: contents.scriptSupportingElements,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: "zeroOrMore",
|
|
13
|
+
contents: new Set(["source"]),
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: "zeroOrMore",
|
|
17
|
+
contents: contents.scriptSupportingElements,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "required",
|
|
21
|
+
contents: new Set(["img"]),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: "zeroOrMore",
|
|
25
|
+
contents: contents.scriptSupportingElements,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
attributes: contentAttributes(true),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const picture: GetElementSpec = () => pictureSpec;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ElementSpec, GetElementSpec } from "../types";
|
|
2
|
+
import { contentAttributes } from "../utils/contentAttributes";
|
|
3
|
+
|
|
4
|
+
const sourceSpec: ElementSpec = {
|
|
5
|
+
contents: null,
|
|
6
|
+
attributes: contentAttributes(true, [
|
|
7
|
+
"type",
|
|
8
|
+
"media",
|
|
9
|
+
"src",
|
|
10
|
+
"srcset",
|
|
11
|
+
"sizes",
|
|
12
|
+
"width",
|
|
13
|
+
"height",
|
|
14
|
+
]),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const source: GetElementSpec = () => sourceSpec;
|