fictoan-react 1.9.1-alpha.25 → 1.9.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/dist/components/CodeBlock/CodeBlock.js +75 -2259
- package/dist/index.css +1 -1
- package/package.json +8 -2
- package/dist/components/CodeBlock/prism.js +0 -6
- package/dist/prism-3zG3kdoy.js +0 -14605
|
@@ -1,2255 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client;";
|
|
3
|
-
import React
|
|
4
|
-
import {
|
|
5
|
-
import { Element as Element$1 } from "../Element/Element.js";
|
|
3
|
+
import React, { useState, useEffect } from "react";
|
|
4
|
+
import { Element } from "../Element/Element.js";
|
|
6
5
|
import { Button } from "../Button/Button.js";
|
|
7
6
|
import { Badge } from "../Badge/Badge.js";
|
|
8
|
-
|
|
9
|
-
var htmlToDom = {};
|
|
10
|
-
var domparser$1 = {};
|
|
11
|
-
Object.defineProperty(domparser$1, "__esModule", { value: true });
|
|
12
|
-
domparser$1.default = domparser;
|
|
13
|
-
var HTML = "html";
|
|
14
|
-
var HEAD = "head";
|
|
15
|
-
var BODY = "body";
|
|
16
|
-
var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/;
|
|
17
|
-
var HEAD_TAG_REGEX = /<head[^]*>/i;
|
|
18
|
-
var BODY_TAG_REGEX = /<body[^]*>/i;
|
|
19
|
-
var parseFromDocument = function(html, tagName) {
|
|
20
|
-
throw new Error("This browser does not support `document.implementation.createHTMLDocument`");
|
|
21
|
-
};
|
|
22
|
-
var parseFromString = function(html, tagName) {
|
|
23
|
-
throw new Error("This browser does not support `DOMParser.prototype.parseFromString`");
|
|
24
|
-
};
|
|
25
|
-
var DOMParser = typeof window === "object" && window.DOMParser;
|
|
26
|
-
if (typeof DOMParser === "function") {
|
|
27
|
-
var domParser_1 = new DOMParser();
|
|
28
|
-
var mimeType_1 = "text/html";
|
|
29
|
-
parseFromString = function(html, tagName) {
|
|
30
|
-
if (tagName) {
|
|
31
|
-
html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
|
|
32
|
-
}
|
|
33
|
-
return domParser_1.parseFromString(html, mimeType_1);
|
|
34
|
-
};
|
|
35
|
-
parseFromDocument = parseFromString;
|
|
36
|
-
}
|
|
37
|
-
if (typeof document === "object" && document.implementation) {
|
|
38
|
-
var htmlDocument_1 = document.implementation.createHTMLDocument();
|
|
39
|
-
parseFromDocument = function(html, tagName) {
|
|
40
|
-
if (tagName) {
|
|
41
|
-
var element = htmlDocument_1.documentElement.querySelector(tagName);
|
|
42
|
-
if (element) {
|
|
43
|
-
element.innerHTML = html;
|
|
44
|
-
}
|
|
45
|
-
return htmlDocument_1;
|
|
46
|
-
}
|
|
47
|
-
htmlDocument_1.documentElement.innerHTML = html;
|
|
48
|
-
return htmlDocument_1;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
var template = typeof document === "object" && document.createElement("template");
|
|
52
|
-
var parseFromTemplate;
|
|
53
|
-
if (template && template.content) {
|
|
54
|
-
parseFromTemplate = function(html) {
|
|
55
|
-
template.innerHTML = html;
|
|
56
|
-
return template.content.childNodes;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function domparser(html) {
|
|
60
|
-
var _a, _b;
|
|
61
|
-
var match = html.match(FIRST_TAG_REGEX);
|
|
62
|
-
var firstTagName = match && match[1] ? match[1].toLowerCase() : "";
|
|
63
|
-
switch (firstTagName) {
|
|
64
|
-
case HTML: {
|
|
65
|
-
var doc = parseFromString(html);
|
|
66
|
-
if (!HEAD_TAG_REGEX.test(html)) {
|
|
67
|
-
var element = doc.querySelector(HEAD);
|
|
68
|
-
(_a = element === null || element === void 0 ? void 0 : element.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(element);
|
|
69
|
-
}
|
|
70
|
-
if (!BODY_TAG_REGEX.test(html)) {
|
|
71
|
-
var element = doc.querySelector(BODY);
|
|
72
|
-
(_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
73
|
-
}
|
|
74
|
-
return doc.querySelectorAll(HTML);
|
|
75
|
-
}
|
|
76
|
-
case HEAD:
|
|
77
|
-
case BODY: {
|
|
78
|
-
var elements = parseFromDocument(html).querySelectorAll(firstTagName);
|
|
79
|
-
if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
|
|
80
|
-
return elements[0].parentNode.childNodes;
|
|
81
|
-
}
|
|
82
|
-
return elements;
|
|
83
|
-
}
|
|
84
|
-
default: {
|
|
85
|
-
if (parseFromTemplate) {
|
|
86
|
-
return parseFromTemplate(html);
|
|
87
|
-
}
|
|
88
|
-
var element = parseFromDocument(html, BODY).querySelector(BODY);
|
|
89
|
-
return element.childNodes;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
var utilities$2 = {};
|
|
94
|
-
var lib$2 = {};
|
|
95
|
-
var lib$1 = {};
|
|
96
|
-
(function(exports) {
|
|
97
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
98
|
-
exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
|
|
99
|
-
var ElementType;
|
|
100
|
-
(function(ElementType2) {
|
|
101
|
-
ElementType2["Root"] = "root";
|
|
102
|
-
ElementType2["Text"] = "text";
|
|
103
|
-
ElementType2["Directive"] = "directive";
|
|
104
|
-
ElementType2["Comment"] = "comment";
|
|
105
|
-
ElementType2["Script"] = "script";
|
|
106
|
-
ElementType2["Style"] = "style";
|
|
107
|
-
ElementType2["Tag"] = "tag";
|
|
108
|
-
ElementType2["CDATA"] = "cdata";
|
|
109
|
-
ElementType2["Doctype"] = "doctype";
|
|
110
|
-
})(ElementType = exports.ElementType || (exports.ElementType = {}));
|
|
111
|
-
function isTag2(elem) {
|
|
112
|
-
return elem.type === ElementType.Tag || elem.type === ElementType.Script || elem.type === ElementType.Style;
|
|
113
|
-
}
|
|
114
|
-
exports.isTag = isTag2;
|
|
115
|
-
exports.Root = ElementType.Root;
|
|
116
|
-
exports.Text = ElementType.Text;
|
|
117
|
-
exports.Directive = ElementType.Directive;
|
|
118
|
-
exports.Comment = ElementType.Comment;
|
|
119
|
-
exports.Script = ElementType.Script;
|
|
120
|
-
exports.Style = ElementType.Style;
|
|
121
|
-
exports.Tag = ElementType.Tag;
|
|
122
|
-
exports.CDATA = ElementType.CDATA;
|
|
123
|
-
exports.Doctype = ElementType.Doctype;
|
|
124
|
-
})(lib$1);
|
|
125
|
-
var node = {};
|
|
126
|
-
var __extends = commonjsGlobal && commonjsGlobal.__extends || /* @__PURE__ */ function() {
|
|
127
|
-
var extendStatics = function(d, b) {
|
|
128
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
129
|
-
d2.__proto__ = b2;
|
|
130
|
-
} || function(d2, b2) {
|
|
131
|
-
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
132
|
-
};
|
|
133
|
-
return extendStatics(d, b);
|
|
134
|
-
};
|
|
135
|
-
return function(d, b) {
|
|
136
|
-
if (typeof b !== "function" && b !== null)
|
|
137
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
138
|
-
extendStatics(d, b);
|
|
139
|
-
function __() {
|
|
140
|
-
this.constructor = d;
|
|
141
|
-
}
|
|
142
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
143
|
-
};
|
|
144
|
-
}();
|
|
145
|
-
var __assign = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
146
|
-
__assign = Object.assign || function(t) {
|
|
147
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
148
|
-
s = arguments[i];
|
|
149
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
150
|
-
t[p] = s[p];
|
|
151
|
-
}
|
|
152
|
-
return t;
|
|
153
|
-
};
|
|
154
|
-
return __assign.apply(this, arguments);
|
|
155
|
-
};
|
|
156
|
-
Object.defineProperty(node, "__esModule", { value: true });
|
|
157
|
-
node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.CDATA = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
|
|
158
|
-
var domelementtype_1 = lib$1;
|
|
159
|
-
var Node = (
|
|
160
|
-
/** @class */
|
|
161
|
-
function() {
|
|
162
|
-
function Node2() {
|
|
163
|
-
this.parent = null;
|
|
164
|
-
this.prev = null;
|
|
165
|
-
this.next = null;
|
|
166
|
-
this.startIndex = null;
|
|
167
|
-
this.endIndex = null;
|
|
168
|
-
}
|
|
169
|
-
Object.defineProperty(Node2.prototype, "parentNode", {
|
|
170
|
-
// Read-write aliases for properties
|
|
171
|
-
/**
|
|
172
|
-
* Same as {@link parent}.
|
|
173
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
174
|
-
*/
|
|
175
|
-
get: function() {
|
|
176
|
-
return this.parent;
|
|
177
|
-
},
|
|
178
|
-
set: function(parent) {
|
|
179
|
-
this.parent = parent;
|
|
180
|
-
},
|
|
181
|
-
enumerable: false,
|
|
182
|
-
configurable: true
|
|
183
|
-
});
|
|
184
|
-
Object.defineProperty(Node2.prototype, "previousSibling", {
|
|
185
|
-
/**
|
|
186
|
-
* Same as {@link prev}.
|
|
187
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
188
|
-
*/
|
|
189
|
-
get: function() {
|
|
190
|
-
return this.prev;
|
|
191
|
-
},
|
|
192
|
-
set: function(prev) {
|
|
193
|
-
this.prev = prev;
|
|
194
|
-
},
|
|
195
|
-
enumerable: false,
|
|
196
|
-
configurable: true
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(Node2.prototype, "nextSibling", {
|
|
199
|
-
/**
|
|
200
|
-
* Same as {@link next}.
|
|
201
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
202
|
-
*/
|
|
203
|
-
get: function() {
|
|
204
|
-
return this.next;
|
|
205
|
-
},
|
|
206
|
-
set: function(next) {
|
|
207
|
-
this.next = next;
|
|
208
|
-
},
|
|
209
|
-
enumerable: false,
|
|
210
|
-
configurable: true
|
|
211
|
-
});
|
|
212
|
-
Node2.prototype.cloneNode = function(recursive) {
|
|
213
|
-
if (recursive === void 0) {
|
|
214
|
-
recursive = false;
|
|
215
|
-
}
|
|
216
|
-
return cloneNode(this, recursive);
|
|
217
|
-
};
|
|
218
|
-
return Node2;
|
|
219
|
-
}()
|
|
220
|
-
);
|
|
221
|
-
node.Node = Node;
|
|
222
|
-
var DataNode = (
|
|
223
|
-
/** @class */
|
|
224
|
-
function(_super) {
|
|
225
|
-
__extends(DataNode2, _super);
|
|
226
|
-
function DataNode2(data) {
|
|
227
|
-
var _this = _super.call(this) || this;
|
|
228
|
-
_this.data = data;
|
|
229
|
-
return _this;
|
|
230
|
-
}
|
|
231
|
-
Object.defineProperty(DataNode2.prototype, "nodeValue", {
|
|
232
|
-
/**
|
|
233
|
-
* Same as {@link data}.
|
|
234
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
235
|
-
*/
|
|
236
|
-
get: function() {
|
|
237
|
-
return this.data;
|
|
238
|
-
},
|
|
239
|
-
set: function(data) {
|
|
240
|
-
this.data = data;
|
|
241
|
-
},
|
|
242
|
-
enumerable: false,
|
|
243
|
-
configurable: true
|
|
244
|
-
});
|
|
245
|
-
return DataNode2;
|
|
246
|
-
}(Node)
|
|
247
|
-
);
|
|
248
|
-
node.DataNode = DataNode;
|
|
249
|
-
var Text = (
|
|
250
|
-
/** @class */
|
|
251
|
-
function(_super) {
|
|
252
|
-
__extends(Text2, _super);
|
|
253
|
-
function Text2() {
|
|
254
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
255
|
-
_this.type = domelementtype_1.ElementType.Text;
|
|
256
|
-
return _this;
|
|
257
|
-
}
|
|
258
|
-
Object.defineProperty(Text2.prototype, "nodeType", {
|
|
259
|
-
get: function() {
|
|
260
|
-
return 3;
|
|
261
|
-
},
|
|
262
|
-
enumerable: false,
|
|
263
|
-
configurable: true
|
|
264
|
-
});
|
|
265
|
-
return Text2;
|
|
266
|
-
}(DataNode)
|
|
267
|
-
);
|
|
268
|
-
node.Text = Text;
|
|
269
|
-
var Comment = (
|
|
270
|
-
/** @class */
|
|
271
|
-
function(_super) {
|
|
272
|
-
__extends(Comment2, _super);
|
|
273
|
-
function Comment2() {
|
|
274
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
275
|
-
_this.type = domelementtype_1.ElementType.Comment;
|
|
276
|
-
return _this;
|
|
277
|
-
}
|
|
278
|
-
Object.defineProperty(Comment2.prototype, "nodeType", {
|
|
279
|
-
get: function() {
|
|
280
|
-
return 8;
|
|
281
|
-
},
|
|
282
|
-
enumerable: false,
|
|
283
|
-
configurable: true
|
|
284
|
-
});
|
|
285
|
-
return Comment2;
|
|
286
|
-
}(DataNode)
|
|
287
|
-
);
|
|
288
|
-
node.Comment = Comment;
|
|
289
|
-
var ProcessingInstruction = (
|
|
290
|
-
/** @class */
|
|
291
|
-
function(_super) {
|
|
292
|
-
__extends(ProcessingInstruction2, _super);
|
|
293
|
-
function ProcessingInstruction2(name, data) {
|
|
294
|
-
var _this = _super.call(this, data) || this;
|
|
295
|
-
_this.name = name;
|
|
296
|
-
_this.type = domelementtype_1.ElementType.Directive;
|
|
297
|
-
return _this;
|
|
298
|
-
}
|
|
299
|
-
Object.defineProperty(ProcessingInstruction2.prototype, "nodeType", {
|
|
300
|
-
get: function() {
|
|
301
|
-
return 1;
|
|
302
|
-
},
|
|
303
|
-
enumerable: false,
|
|
304
|
-
configurable: true
|
|
305
|
-
});
|
|
306
|
-
return ProcessingInstruction2;
|
|
307
|
-
}(DataNode)
|
|
308
|
-
);
|
|
309
|
-
node.ProcessingInstruction = ProcessingInstruction;
|
|
310
|
-
var NodeWithChildren = (
|
|
311
|
-
/** @class */
|
|
312
|
-
function(_super) {
|
|
313
|
-
__extends(NodeWithChildren2, _super);
|
|
314
|
-
function NodeWithChildren2(children) {
|
|
315
|
-
var _this = _super.call(this) || this;
|
|
316
|
-
_this.children = children;
|
|
317
|
-
return _this;
|
|
318
|
-
}
|
|
319
|
-
Object.defineProperty(NodeWithChildren2.prototype, "firstChild", {
|
|
320
|
-
// Aliases
|
|
321
|
-
/** First child of the node. */
|
|
322
|
-
get: function() {
|
|
323
|
-
var _a;
|
|
324
|
-
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
|
325
|
-
},
|
|
326
|
-
enumerable: false,
|
|
327
|
-
configurable: true
|
|
328
|
-
});
|
|
329
|
-
Object.defineProperty(NodeWithChildren2.prototype, "lastChild", {
|
|
330
|
-
/** Last child of the node. */
|
|
331
|
-
get: function() {
|
|
332
|
-
return this.children.length > 0 ? this.children[this.children.length - 1] : null;
|
|
333
|
-
},
|
|
334
|
-
enumerable: false,
|
|
335
|
-
configurable: true
|
|
336
|
-
});
|
|
337
|
-
Object.defineProperty(NodeWithChildren2.prototype, "childNodes", {
|
|
338
|
-
/**
|
|
339
|
-
* Same as {@link children}.
|
|
340
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
341
|
-
*/
|
|
342
|
-
get: function() {
|
|
343
|
-
return this.children;
|
|
344
|
-
},
|
|
345
|
-
set: function(children) {
|
|
346
|
-
this.children = children;
|
|
347
|
-
},
|
|
348
|
-
enumerable: false,
|
|
349
|
-
configurable: true
|
|
350
|
-
});
|
|
351
|
-
return NodeWithChildren2;
|
|
352
|
-
}(Node)
|
|
353
|
-
);
|
|
354
|
-
node.NodeWithChildren = NodeWithChildren;
|
|
355
|
-
var CDATA = (
|
|
356
|
-
/** @class */
|
|
357
|
-
function(_super) {
|
|
358
|
-
__extends(CDATA2, _super);
|
|
359
|
-
function CDATA2() {
|
|
360
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
361
|
-
_this.type = domelementtype_1.ElementType.CDATA;
|
|
362
|
-
return _this;
|
|
363
|
-
}
|
|
364
|
-
Object.defineProperty(CDATA2.prototype, "nodeType", {
|
|
365
|
-
get: function() {
|
|
366
|
-
return 4;
|
|
367
|
-
},
|
|
368
|
-
enumerable: false,
|
|
369
|
-
configurable: true
|
|
370
|
-
});
|
|
371
|
-
return CDATA2;
|
|
372
|
-
}(NodeWithChildren)
|
|
373
|
-
);
|
|
374
|
-
node.CDATA = CDATA;
|
|
375
|
-
var Document = (
|
|
376
|
-
/** @class */
|
|
377
|
-
function(_super) {
|
|
378
|
-
__extends(Document2, _super);
|
|
379
|
-
function Document2() {
|
|
380
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
381
|
-
_this.type = domelementtype_1.ElementType.Root;
|
|
382
|
-
return _this;
|
|
383
|
-
}
|
|
384
|
-
Object.defineProperty(Document2.prototype, "nodeType", {
|
|
385
|
-
get: function() {
|
|
386
|
-
return 9;
|
|
387
|
-
},
|
|
388
|
-
enumerable: false,
|
|
389
|
-
configurable: true
|
|
390
|
-
});
|
|
391
|
-
return Document2;
|
|
392
|
-
}(NodeWithChildren)
|
|
393
|
-
);
|
|
394
|
-
node.Document = Document;
|
|
395
|
-
var Element = (
|
|
396
|
-
/** @class */
|
|
397
|
-
function(_super) {
|
|
398
|
-
__extends(Element2, _super);
|
|
399
|
-
function Element2(name, attribs, children, type) {
|
|
400
|
-
if (children === void 0) {
|
|
401
|
-
children = [];
|
|
402
|
-
}
|
|
403
|
-
if (type === void 0) {
|
|
404
|
-
type = name === "script" ? domelementtype_1.ElementType.Script : name === "style" ? domelementtype_1.ElementType.Style : domelementtype_1.ElementType.Tag;
|
|
405
|
-
}
|
|
406
|
-
var _this = _super.call(this, children) || this;
|
|
407
|
-
_this.name = name;
|
|
408
|
-
_this.attribs = attribs;
|
|
409
|
-
_this.type = type;
|
|
410
|
-
return _this;
|
|
411
|
-
}
|
|
412
|
-
Object.defineProperty(Element2.prototype, "nodeType", {
|
|
413
|
-
get: function() {
|
|
414
|
-
return 1;
|
|
415
|
-
},
|
|
416
|
-
enumerable: false,
|
|
417
|
-
configurable: true
|
|
418
|
-
});
|
|
419
|
-
Object.defineProperty(Element2.prototype, "tagName", {
|
|
420
|
-
// DOM Level 1 aliases
|
|
421
|
-
/**
|
|
422
|
-
* Same as {@link name}.
|
|
423
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
424
|
-
*/
|
|
425
|
-
get: function() {
|
|
426
|
-
return this.name;
|
|
427
|
-
},
|
|
428
|
-
set: function(name) {
|
|
429
|
-
this.name = name;
|
|
430
|
-
},
|
|
431
|
-
enumerable: false,
|
|
432
|
-
configurable: true
|
|
433
|
-
});
|
|
434
|
-
Object.defineProperty(Element2.prototype, "attributes", {
|
|
435
|
-
get: function() {
|
|
436
|
-
var _this = this;
|
|
437
|
-
return Object.keys(this.attribs).map(function(name) {
|
|
438
|
-
var _a, _b;
|
|
439
|
-
return {
|
|
440
|
-
name,
|
|
441
|
-
value: _this.attribs[name],
|
|
442
|
-
namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
|
|
443
|
-
prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name]
|
|
444
|
-
};
|
|
445
|
-
});
|
|
446
|
-
},
|
|
447
|
-
enumerable: false,
|
|
448
|
-
configurable: true
|
|
449
|
-
});
|
|
450
|
-
return Element2;
|
|
451
|
-
}(NodeWithChildren)
|
|
452
|
-
);
|
|
453
|
-
node.Element = Element;
|
|
454
|
-
function isTag(node2) {
|
|
455
|
-
return (0, domelementtype_1.isTag)(node2);
|
|
456
|
-
}
|
|
457
|
-
node.isTag = isTag;
|
|
458
|
-
function isCDATA(node2) {
|
|
459
|
-
return node2.type === domelementtype_1.ElementType.CDATA;
|
|
460
|
-
}
|
|
461
|
-
node.isCDATA = isCDATA;
|
|
462
|
-
function isText(node2) {
|
|
463
|
-
return node2.type === domelementtype_1.ElementType.Text;
|
|
464
|
-
}
|
|
465
|
-
node.isText = isText;
|
|
466
|
-
function isComment(node2) {
|
|
467
|
-
return node2.type === domelementtype_1.ElementType.Comment;
|
|
468
|
-
}
|
|
469
|
-
node.isComment = isComment;
|
|
470
|
-
function isDirective(node2) {
|
|
471
|
-
return node2.type === domelementtype_1.ElementType.Directive;
|
|
472
|
-
}
|
|
473
|
-
node.isDirective = isDirective;
|
|
474
|
-
function isDocument(node2) {
|
|
475
|
-
return node2.type === domelementtype_1.ElementType.Root;
|
|
476
|
-
}
|
|
477
|
-
node.isDocument = isDocument;
|
|
478
|
-
function hasChildren(node2) {
|
|
479
|
-
return Object.prototype.hasOwnProperty.call(node2, "children");
|
|
480
|
-
}
|
|
481
|
-
node.hasChildren = hasChildren;
|
|
482
|
-
function cloneNode(node2, recursive) {
|
|
483
|
-
if (recursive === void 0) {
|
|
484
|
-
recursive = false;
|
|
485
|
-
}
|
|
486
|
-
var result;
|
|
487
|
-
if (isText(node2)) {
|
|
488
|
-
result = new Text(node2.data);
|
|
489
|
-
} else if (isComment(node2)) {
|
|
490
|
-
result = new Comment(node2.data);
|
|
491
|
-
} else if (isTag(node2)) {
|
|
492
|
-
var children = recursive ? cloneChildren(node2.children) : [];
|
|
493
|
-
var clone_1 = new Element(node2.name, __assign({}, node2.attribs), children);
|
|
494
|
-
children.forEach(function(child) {
|
|
495
|
-
return child.parent = clone_1;
|
|
496
|
-
});
|
|
497
|
-
if (node2.namespace != null) {
|
|
498
|
-
clone_1.namespace = node2.namespace;
|
|
499
|
-
}
|
|
500
|
-
if (node2["x-attribsNamespace"]) {
|
|
501
|
-
clone_1["x-attribsNamespace"] = __assign({}, node2["x-attribsNamespace"]);
|
|
502
|
-
}
|
|
503
|
-
if (node2["x-attribsPrefix"]) {
|
|
504
|
-
clone_1["x-attribsPrefix"] = __assign({}, node2["x-attribsPrefix"]);
|
|
505
|
-
}
|
|
506
|
-
result = clone_1;
|
|
507
|
-
} else if (isCDATA(node2)) {
|
|
508
|
-
var children = recursive ? cloneChildren(node2.children) : [];
|
|
509
|
-
var clone_2 = new CDATA(children);
|
|
510
|
-
children.forEach(function(child) {
|
|
511
|
-
return child.parent = clone_2;
|
|
512
|
-
});
|
|
513
|
-
result = clone_2;
|
|
514
|
-
} else if (isDocument(node2)) {
|
|
515
|
-
var children = recursive ? cloneChildren(node2.children) : [];
|
|
516
|
-
var clone_3 = new Document(children);
|
|
517
|
-
children.forEach(function(child) {
|
|
518
|
-
return child.parent = clone_3;
|
|
519
|
-
});
|
|
520
|
-
if (node2["x-mode"]) {
|
|
521
|
-
clone_3["x-mode"] = node2["x-mode"];
|
|
522
|
-
}
|
|
523
|
-
result = clone_3;
|
|
524
|
-
} else if (isDirective(node2)) {
|
|
525
|
-
var instruction = new ProcessingInstruction(node2.name, node2.data);
|
|
526
|
-
if (node2["x-name"] != null) {
|
|
527
|
-
instruction["x-name"] = node2["x-name"];
|
|
528
|
-
instruction["x-publicId"] = node2["x-publicId"];
|
|
529
|
-
instruction["x-systemId"] = node2["x-systemId"];
|
|
530
|
-
}
|
|
531
|
-
result = instruction;
|
|
532
|
-
} else {
|
|
533
|
-
throw new Error("Not implemented yet: ".concat(node2.type));
|
|
534
|
-
}
|
|
535
|
-
result.startIndex = node2.startIndex;
|
|
536
|
-
result.endIndex = node2.endIndex;
|
|
537
|
-
if (node2.sourceCodeLocation != null) {
|
|
538
|
-
result.sourceCodeLocation = node2.sourceCodeLocation;
|
|
539
|
-
}
|
|
540
|
-
return result;
|
|
541
|
-
}
|
|
542
|
-
node.cloneNode = cloneNode;
|
|
543
|
-
function cloneChildren(childs) {
|
|
544
|
-
var children = childs.map(function(child) {
|
|
545
|
-
return cloneNode(child, true);
|
|
546
|
-
});
|
|
547
|
-
for (var i = 1; i < children.length; i++) {
|
|
548
|
-
children[i].prev = children[i - 1];
|
|
549
|
-
children[i - 1].next = children[i];
|
|
550
|
-
}
|
|
551
|
-
return children;
|
|
552
|
-
}
|
|
553
|
-
(function(exports) {
|
|
554
|
-
var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
555
|
-
if (k2 === void 0) k2 = k;
|
|
556
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
557
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
558
|
-
desc = { enumerable: true, get: function() {
|
|
559
|
-
return m[k];
|
|
560
|
-
} };
|
|
561
|
-
}
|
|
562
|
-
Object.defineProperty(o, k2, desc);
|
|
563
|
-
} : function(o, m, k, k2) {
|
|
564
|
-
if (k2 === void 0) k2 = k;
|
|
565
|
-
o[k2] = m[k];
|
|
566
|
-
});
|
|
567
|
-
var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function(m, exports2) {
|
|
568
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
569
|
-
};
|
|
570
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
571
|
-
exports.DomHandler = void 0;
|
|
572
|
-
var domelementtype_12 = lib$1;
|
|
573
|
-
var node_js_1 = node;
|
|
574
|
-
__exportStar(node, exports);
|
|
575
|
-
var defaultOpts = {
|
|
576
|
-
withStartIndices: false,
|
|
577
|
-
withEndIndices: false,
|
|
578
|
-
xmlMode: false
|
|
579
|
-
};
|
|
580
|
-
var DomHandler = (
|
|
581
|
-
/** @class */
|
|
582
|
-
function() {
|
|
583
|
-
function DomHandler2(callback, options, elementCB) {
|
|
584
|
-
this.dom = [];
|
|
585
|
-
this.root = new node_js_1.Document(this.dom);
|
|
586
|
-
this.done = false;
|
|
587
|
-
this.tagStack = [this.root];
|
|
588
|
-
this.lastNode = null;
|
|
589
|
-
this.parser = null;
|
|
590
|
-
if (typeof options === "function") {
|
|
591
|
-
elementCB = options;
|
|
592
|
-
options = defaultOpts;
|
|
593
|
-
}
|
|
594
|
-
if (typeof callback === "object") {
|
|
595
|
-
options = callback;
|
|
596
|
-
callback = void 0;
|
|
597
|
-
}
|
|
598
|
-
this.callback = callback !== null && callback !== void 0 ? callback : null;
|
|
599
|
-
this.options = options !== null && options !== void 0 ? options : defaultOpts;
|
|
600
|
-
this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
|
601
|
-
}
|
|
602
|
-
DomHandler2.prototype.onparserinit = function(parser) {
|
|
603
|
-
this.parser = parser;
|
|
604
|
-
};
|
|
605
|
-
DomHandler2.prototype.onreset = function() {
|
|
606
|
-
this.dom = [];
|
|
607
|
-
this.root = new node_js_1.Document(this.dom);
|
|
608
|
-
this.done = false;
|
|
609
|
-
this.tagStack = [this.root];
|
|
610
|
-
this.lastNode = null;
|
|
611
|
-
this.parser = null;
|
|
612
|
-
};
|
|
613
|
-
DomHandler2.prototype.onend = function() {
|
|
614
|
-
if (this.done)
|
|
615
|
-
return;
|
|
616
|
-
this.done = true;
|
|
617
|
-
this.parser = null;
|
|
618
|
-
this.handleCallback(null);
|
|
619
|
-
};
|
|
620
|
-
DomHandler2.prototype.onerror = function(error) {
|
|
621
|
-
this.handleCallback(error);
|
|
622
|
-
};
|
|
623
|
-
DomHandler2.prototype.onclosetag = function() {
|
|
624
|
-
this.lastNode = null;
|
|
625
|
-
var elem = this.tagStack.pop();
|
|
626
|
-
if (this.options.withEndIndices) {
|
|
627
|
-
elem.endIndex = this.parser.endIndex;
|
|
628
|
-
}
|
|
629
|
-
if (this.elementCB)
|
|
630
|
-
this.elementCB(elem);
|
|
631
|
-
};
|
|
632
|
-
DomHandler2.prototype.onopentag = function(name, attribs) {
|
|
633
|
-
var type = this.options.xmlMode ? domelementtype_12.ElementType.Tag : void 0;
|
|
634
|
-
var element = new node_js_1.Element(name, attribs, void 0, type);
|
|
635
|
-
this.addNode(element);
|
|
636
|
-
this.tagStack.push(element);
|
|
637
|
-
};
|
|
638
|
-
DomHandler2.prototype.ontext = function(data) {
|
|
639
|
-
var lastNode = this.lastNode;
|
|
640
|
-
if (lastNode && lastNode.type === domelementtype_12.ElementType.Text) {
|
|
641
|
-
lastNode.data += data;
|
|
642
|
-
if (this.options.withEndIndices) {
|
|
643
|
-
lastNode.endIndex = this.parser.endIndex;
|
|
644
|
-
}
|
|
645
|
-
} else {
|
|
646
|
-
var node2 = new node_js_1.Text(data);
|
|
647
|
-
this.addNode(node2);
|
|
648
|
-
this.lastNode = node2;
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
DomHandler2.prototype.oncomment = function(data) {
|
|
652
|
-
if (this.lastNode && this.lastNode.type === domelementtype_12.ElementType.Comment) {
|
|
653
|
-
this.lastNode.data += data;
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
var node2 = new node_js_1.Comment(data);
|
|
657
|
-
this.addNode(node2);
|
|
658
|
-
this.lastNode = node2;
|
|
659
|
-
};
|
|
660
|
-
DomHandler2.prototype.oncommentend = function() {
|
|
661
|
-
this.lastNode = null;
|
|
662
|
-
};
|
|
663
|
-
DomHandler2.prototype.oncdatastart = function() {
|
|
664
|
-
var text = new node_js_1.Text("");
|
|
665
|
-
var node2 = new node_js_1.CDATA([text]);
|
|
666
|
-
this.addNode(node2);
|
|
667
|
-
text.parent = node2;
|
|
668
|
-
this.lastNode = text;
|
|
669
|
-
};
|
|
670
|
-
DomHandler2.prototype.oncdataend = function() {
|
|
671
|
-
this.lastNode = null;
|
|
672
|
-
};
|
|
673
|
-
DomHandler2.prototype.onprocessinginstruction = function(name, data) {
|
|
674
|
-
var node2 = new node_js_1.ProcessingInstruction(name, data);
|
|
675
|
-
this.addNode(node2);
|
|
676
|
-
};
|
|
677
|
-
DomHandler2.prototype.handleCallback = function(error) {
|
|
678
|
-
if (typeof this.callback === "function") {
|
|
679
|
-
this.callback(error, this.dom);
|
|
680
|
-
} else if (error) {
|
|
681
|
-
throw error;
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
DomHandler2.prototype.addNode = function(node2) {
|
|
685
|
-
var parent = this.tagStack[this.tagStack.length - 1];
|
|
686
|
-
var previousSibling = parent.children[parent.children.length - 1];
|
|
687
|
-
if (this.options.withStartIndices) {
|
|
688
|
-
node2.startIndex = this.parser.startIndex;
|
|
689
|
-
}
|
|
690
|
-
if (this.options.withEndIndices) {
|
|
691
|
-
node2.endIndex = this.parser.endIndex;
|
|
692
|
-
}
|
|
693
|
-
parent.children.push(node2);
|
|
694
|
-
if (previousSibling) {
|
|
695
|
-
node2.prev = previousSibling;
|
|
696
|
-
previousSibling.next = node2;
|
|
697
|
-
}
|
|
698
|
-
node2.parent = parent;
|
|
699
|
-
this.lastNode = null;
|
|
700
|
-
};
|
|
701
|
-
return DomHandler2;
|
|
702
|
-
}()
|
|
703
|
-
);
|
|
704
|
-
exports.DomHandler = DomHandler;
|
|
705
|
-
exports.default = DomHandler;
|
|
706
|
-
})(lib$2);
|
|
707
|
-
var constants = {};
|
|
708
|
-
(function(exports) {
|
|
709
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
710
|
-
exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES = void 0;
|
|
711
|
-
exports.CASE_SENSITIVE_TAG_NAMES = [
|
|
712
|
-
"animateMotion",
|
|
713
|
-
"animateTransform",
|
|
714
|
-
"clipPath",
|
|
715
|
-
"feBlend",
|
|
716
|
-
"feColorMatrix",
|
|
717
|
-
"feComponentTransfer",
|
|
718
|
-
"feComposite",
|
|
719
|
-
"feConvolveMatrix",
|
|
720
|
-
"feDiffuseLighting",
|
|
721
|
-
"feDisplacementMap",
|
|
722
|
-
"feDropShadow",
|
|
723
|
-
"feFlood",
|
|
724
|
-
"feFuncA",
|
|
725
|
-
"feFuncB",
|
|
726
|
-
"feFuncG",
|
|
727
|
-
"feFuncR",
|
|
728
|
-
"feGaussianBlur",
|
|
729
|
-
"feImage",
|
|
730
|
-
"feMerge",
|
|
731
|
-
"feMergeNode",
|
|
732
|
-
"feMorphology",
|
|
733
|
-
"feOffset",
|
|
734
|
-
"fePointLight",
|
|
735
|
-
"feSpecularLighting",
|
|
736
|
-
"feSpotLight",
|
|
737
|
-
"feTile",
|
|
738
|
-
"feTurbulence",
|
|
739
|
-
"foreignObject",
|
|
740
|
-
"linearGradient",
|
|
741
|
-
"radialGradient",
|
|
742
|
-
"textPath"
|
|
743
|
-
];
|
|
744
|
-
exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES.reduce(function(accumulator, tagName) {
|
|
745
|
-
accumulator[tagName.toLowerCase()] = tagName;
|
|
746
|
-
return accumulator;
|
|
747
|
-
}, {});
|
|
748
|
-
})(constants);
|
|
749
|
-
Object.defineProperty(utilities$2, "__esModule", { value: true });
|
|
750
|
-
utilities$2.formatAttributes = formatAttributes;
|
|
751
|
-
utilities$2.formatDOM = formatDOM;
|
|
752
|
-
var domhandler_1 = lib$2;
|
|
753
|
-
var constants_1 = constants;
|
|
754
|
-
function getCaseSensitiveTagName(tagName) {
|
|
755
|
-
return constants_1.CASE_SENSITIVE_TAG_NAMES_MAP[tagName];
|
|
756
|
-
}
|
|
757
|
-
function formatAttributes(attributes) {
|
|
758
|
-
var map = {};
|
|
759
|
-
var index = 0;
|
|
760
|
-
var attributesLength = attributes.length;
|
|
761
|
-
for (; index < attributesLength; index++) {
|
|
762
|
-
var attribute = attributes[index];
|
|
763
|
-
map[attribute.name] = attribute.value;
|
|
764
|
-
}
|
|
765
|
-
return map;
|
|
766
|
-
}
|
|
767
|
-
function formatTagName(tagName) {
|
|
768
|
-
tagName = tagName.toLowerCase();
|
|
769
|
-
var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
|
|
770
|
-
if (caseSensitiveTagName) {
|
|
771
|
-
return caseSensitiveTagName;
|
|
772
|
-
}
|
|
773
|
-
return tagName;
|
|
774
|
-
}
|
|
775
|
-
function formatDOM(nodes, parent, directive) {
|
|
776
|
-
if (parent === void 0) {
|
|
777
|
-
parent = null;
|
|
778
|
-
}
|
|
779
|
-
var domNodes = [];
|
|
780
|
-
var current;
|
|
781
|
-
var index = 0;
|
|
782
|
-
var nodesLength = nodes.length;
|
|
783
|
-
for (; index < nodesLength; index++) {
|
|
784
|
-
var node2 = nodes[index];
|
|
785
|
-
switch (node2.nodeType) {
|
|
786
|
-
case 1: {
|
|
787
|
-
var tagName = formatTagName(node2.nodeName);
|
|
788
|
-
current = new domhandler_1.Element(tagName, formatAttributes(node2.attributes));
|
|
789
|
-
current.children = formatDOM(
|
|
790
|
-
// template children are on content
|
|
791
|
-
tagName === "template" ? node2.content.childNodes : node2.childNodes,
|
|
792
|
-
current
|
|
793
|
-
);
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
case 3:
|
|
797
|
-
current = new domhandler_1.Text(node2.nodeValue);
|
|
798
|
-
break;
|
|
799
|
-
case 8:
|
|
800
|
-
current = new domhandler_1.Comment(node2.nodeValue);
|
|
801
|
-
break;
|
|
802
|
-
default:
|
|
803
|
-
continue;
|
|
804
|
-
}
|
|
805
|
-
var prev = domNodes[index - 1] || null;
|
|
806
|
-
if (prev) {
|
|
807
|
-
prev.next = current;
|
|
808
|
-
}
|
|
809
|
-
current.parent = parent;
|
|
810
|
-
current.prev = prev;
|
|
811
|
-
current.next = null;
|
|
812
|
-
domNodes.push(current);
|
|
813
|
-
}
|
|
814
|
-
if (directive) {
|
|
815
|
-
current = new domhandler_1.ProcessingInstruction(directive.substring(0, directive.indexOf(" ")).toLowerCase(), directive);
|
|
816
|
-
current.next = domNodes[0] || null;
|
|
817
|
-
current.parent = parent;
|
|
818
|
-
domNodes.unshift(current);
|
|
819
|
-
if (domNodes[1]) {
|
|
820
|
-
domNodes[1].prev = domNodes[0];
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
return domNodes;
|
|
824
|
-
}
|
|
825
|
-
var __importDefault$3 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
826
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
827
|
-
};
|
|
828
|
-
Object.defineProperty(htmlToDom, "__esModule", { value: true });
|
|
829
|
-
htmlToDom.default = HTMLDOMParser;
|
|
830
|
-
var domparser_1 = __importDefault$3(domparser$1);
|
|
831
|
-
var utilities_1$3 = utilities$2;
|
|
832
|
-
var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/;
|
|
833
|
-
function HTMLDOMParser(html) {
|
|
834
|
-
if (typeof html !== "string") {
|
|
835
|
-
throw new TypeError("First argument must be a string");
|
|
836
|
-
}
|
|
837
|
-
if (!html) {
|
|
838
|
-
return [];
|
|
839
|
-
}
|
|
840
|
-
var match = html.match(DIRECTIVE_REGEX);
|
|
841
|
-
var directive = match ? match[1] : void 0;
|
|
842
|
-
return (0, utilities_1$3.formatDOM)((0, domparser_1.default)(html), null, directive);
|
|
843
|
-
}
|
|
844
|
-
var attributesToProps$1 = {};
|
|
845
|
-
var lib = {};
|
|
846
|
-
var possibleStandardNamesOptimized$1 = {};
|
|
847
|
-
var SAME$1 = 0;
|
|
848
|
-
possibleStandardNamesOptimized$1.SAME = SAME$1;
|
|
849
|
-
var CAMELCASE$1 = 1;
|
|
850
|
-
possibleStandardNamesOptimized$1.CAMELCASE = CAMELCASE$1;
|
|
851
|
-
possibleStandardNamesOptimized$1.possibleStandardNames = {
|
|
852
|
-
accept: 0,
|
|
853
|
-
acceptCharset: 1,
|
|
854
|
-
"accept-charset": "acceptCharset",
|
|
855
|
-
accessKey: 1,
|
|
856
|
-
action: 0,
|
|
857
|
-
allowFullScreen: 1,
|
|
858
|
-
alt: 0,
|
|
859
|
-
as: 0,
|
|
860
|
-
async: 0,
|
|
861
|
-
autoCapitalize: 1,
|
|
862
|
-
autoComplete: 1,
|
|
863
|
-
autoCorrect: 1,
|
|
864
|
-
autoFocus: 1,
|
|
865
|
-
autoPlay: 1,
|
|
866
|
-
autoSave: 1,
|
|
867
|
-
capture: 0,
|
|
868
|
-
cellPadding: 1,
|
|
869
|
-
cellSpacing: 1,
|
|
870
|
-
challenge: 0,
|
|
871
|
-
charSet: 1,
|
|
872
|
-
checked: 0,
|
|
873
|
-
children: 0,
|
|
874
|
-
cite: 0,
|
|
875
|
-
class: "className",
|
|
876
|
-
classID: 1,
|
|
877
|
-
className: 1,
|
|
878
|
-
cols: 0,
|
|
879
|
-
colSpan: 1,
|
|
880
|
-
content: 0,
|
|
881
|
-
contentEditable: 1,
|
|
882
|
-
contextMenu: 1,
|
|
883
|
-
controls: 0,
|
|
884
|
-
controlsList: 1,
|
|
885
|
-
coords: 0,
|
|
886
|
-
crossOrigin: 1,
|
|
887
|
-
dangerouslySetInnerHTML: 1,
|
|
888
|
-
data: 0,
|
|
889
|
-
dateTime: 1,
|
|
890
|
-
default: 0,
|
|
891
|
-
defaultChecked: 1,
|
|
892
|
-
defaultValue: 1,
|
|
893
|
-
defer: 0,
|
|
894
|
-
dir: 0,
|
|
895
|
-
disabled: 0,
|
|
896
|
-
disablePictureInPicture: 1,
|
|
897
|
-
disableRemotePlayback: 1,
|
|
898
|
-
download: 0,
|
|
899
|
-
draggable: 0,
|
|
900
|
-
encType: 1,
|
|
901
|
-
enterKeyHint: 1,
|
|
902
|
-
for: "htmlFor",
|
|
903
|
-
form: 0,
|
|
904
|
-
formMethod: 1,
|
|
905
|
-
formAction: 1,
|
|
906
|
-
formEncType: 1,
|
|
907
|
-
formNoValidate: 1,
|
|
908
|
-
formTarget: 1,
|
|
909
|
-
frameBorder: 1,
|
|
910
|
-
headers: 0,
|
|
911
|
-
height: 0,
|
|
912
|
-
hidden: 0,
|
|
913
|
-
high: 0,
|
|
914
|
-
href: 0,
|
|
915
|
-
hrefLang: 1,
|
|
916
|
-
htmlFor: 1,
|
|
917
|
-
httpEquiv: 1,
|
|
918
|
-
"http-equiv": "httpEquiv",
|
|
919
|
-
icon: 0,
|
|
920
|
-
id: 0,
|
|
921
|
-
innerHTML: 1,
|
|
922
|
-
inputMode: 1,
|
|
923
|
-
integrity: 0,
|
|
924
|
-
is: 0,
|
|
925
|
-
itemID: 1,
|
|
926
|
-
itemProp: 1,
|
|
927
|
-
itemRef: 1,
|
|
928
|
-
itemScope: 1,
|
|
929
|
-
itemType: 1,
|
|
930
|
-
keyParams: 1,
|
|
931
|
-
keyType: 1,
|
|
932
|
-
kind: 0,
|
|
933
|
-
label: 0,
|
|
934
|
-
lang: 0,
|
|
935
|
-
list: 0,
|
|
936
|
-
loop: 0,
|
|
937
|
-
low: 0,
|
|
938
|
-
manifest: 0,
|
|
939
|
-
marginWidth: 1,
|
|
940
|
-
marginHeight: 1,
|
|
941
|
-
max: 0,
|
|
942
|
-
maxLength: 1,
|
|
943
|
-
media: 0,
|
|
944
|
-
mediaGroup: 1,
|
|
945
|
-
method: 0,
|
|
946
|
-
min: 0,
|
|
947
|
-
minLength: 1,
|
|
948
|
-
multiple: 0,
|
|
949
|
-
muted: 0,
|
|
950
|
-
name: 0,
|
|
951
|
-
noModule: 1,
|
|
952
|
-
nonce: 0,
|
|
953
|
-
noValidate: 1,
|
|
954
|
-
open: 0,
|
|
955
|
-
optimum: 0,
|
|
956
|
-
pattern: 0,
|
|
957
|
-
placeholder: 0,
|
|
958
|
-
playsInline: 1,
|
|
959
|
-
poster: 0,
|
|
960
|
-
preload: 0,
|
|
961
|
-
profile: 0,
|
|
962
|
-
radioGroup: 1,
|
|
963
|
-
readOnly: 1,
|
|
964
|
-
referrerPolicy: 1,
|
|
965
|
-
rel: 0,
|
|
966
|
-
required: 0,
|
|
967
|
-
reversed: 0,
|
|
968
|
-
role: 0,
|
|
969
|
-
rows: 0,
|
|
970
|
-
rowSpan: 1,
|
|
971
|
-
sandbox: 0,
|
|
972
|
-
scope: 0,
|
|
973
|
-
scoped: 0,
|
|
974
|
-
scrolling: 0,
|
|
975
|
-
seamless: 0,
|
|
976
|
-
selected: 0,
|
|
977
|
-
shape: 0,
|
|
978
|
-
size: 0,
|
|
979
|
-
sizes: 0,
|
|
980
|
-
span: 0,
|
|
981
|
-
spellCheck: 1,
|
|
982
|
-
src: 0,
|
|
983
|
-
srcDoc: 1,
|
|
984
|
-
srcLang: 1,
|
|
985
|
-
srcSet: 1,
|
|
986
|
-
start: 0,
|
|
987
|
-
step: 0,
|
|
988
|
-
style: 0,
|
|
989
|
-
summary: 0,
|
|
990
|
-
tabIndex: 1,
|
|
991
|
-
target: 0,
|
|
992
|
-
title: 0,
|
|
993
|
-
type: 0,
|
|
994
|
-
useMap: 1,
|
|
995
|
-
value: 0,
|
|
996
|
-
width: 0,
|
|
997
|
-
wmode: 0,
|
|
998
|
-
wrap: 0,
|
|
999
|
-
about: 0,
|
|
1000
|
-
accentHeight: 1,
|
|
1001
|
-
"accent-height": "accentHeight",
|
|
1002
|
-
accumulate: 0,
|
|
1003
|
-
additive: 0,
|
|
1004
|
-
alignmentBaseline: 1,
|
|
1005
|
-
"alignment-baseline": "alignmentBaseline",
|
|
1006
|
-
allowReorder: 1,
|
|
1007
|
-
alphabetic: 0,
|
|
1008
|
-
amplitude: 0,
|
|
1009
|
-
arabicForm: 1,
|
|
1010
|
-
"arabic-form": "arabicForm",
|
|
1011
|
-
ascent: 0,
|
|
1012
|
-
attributeName: 1,
|
|
1013
|
-
attributeType: 1,
|
|
1014
|
-
autoReverse: 1,
|
|
1015
|
-
azimuth: 0,
|
|
1016
|
-
baseFrequency: 1,
|
|
1017
|
-
baselineShift: 1,
|
|
1018
|
-
"baseline-shift": "baselineShift",
|
|
1019
|
-
baseProfile: 1,
|
|
1020
|
-
bbox: 0,
|
|
1021
|
-
begin: 0,
|
|
1022
|
-
bias: 0,
|
|
1023
|
-
by: 0,
|
|
1024
|
-
calcMode: 1,
|
|
1025
|
-
capHeight: 1,
|
|
1026
|
-
"cap-height": "capHeight",
|
|
1027
|
-
clip: 0,
|
|
1028
|
-
clipPath: 1,
|
|
1029
|
-
"clip-path": "clipPath",
|
|
1030
|
-
clipPathUnits: 1,
|
|
1031
|
-
clipRule: 1,
|
|
1032
|
-
"clip-rule": "clipRule",
|
|
1033
|
-
color: 0,
|
|
1034
|
-
colorInterpolation: 1,
|
|
1035
|
-
"color-interpolation": "colorInterpolation",
|
|
1036
|
-
colorInterpolationFilters: 1,
|
|
1037
|
-
"color-interpolation-filters": "colorInterpolationFilters",
|
|
1038
|
-
colorProfile: 1,
|
|
1039
|
-
"color-profile": "colorProfile",
|
|
1040
|
-
colorRendering: 1,
|
|
1041
|
-
"color-rendering": "colorRendering",
|
|
1042
|
-
contentScriptType: 1,
|
|
1043
|
-
contentStyleType: 1,
|
|
1044
|
-
cursor: 0,
|
|
1045
|
-
cx: 0,
|
|
1046
|
-
cy: 0,
|
|
1047
|
-
d: 0,
|
|
1048
|
-
datatype: 0,
|
|
1049
|
-
decelerate: 0,
|
|
1050
|
-
descent: 0,
|
|
1051
|
-
diffuseConstant: 1,
|
|
1052
|
-
direction: 0,
|
|
1053
|
-
display: 0,
|
|
1054
|
-
divisor: 0,
|
|
1055
|
-
dominantBaseline: 1,
|
|
1056
|
-
"dominant-baseline": "dominantBaseline",
|
|
1057
|
-
dur: 0,
|
|
1058
|
-
dx: 0,
|
|
1059
|
-
dy: 0,
|
|
1060
|
-
edgeMode: 1,
|
|
1061
|
-
elevation: 0,
|
|
1062
|
-
enableBackground: 1,
|
|
1063
|
-
"enable-background": "enableBackground",
|
|
1064
|
-
end: 0,
|
|
1065
|
-
exponent: 0,
|
|
1066
|
-
externalResourcesRequired: 1,
|
|
1067
|
-
fill: 0,
|
|
1068
|
-
fillOpacity: 1,
|
|
1069
|
-
"fill-opacity": "fillOpacity",
|
|
1070
|
-
fillRule: 1,
|
|
1071
|
-
"fill-rule": "fillRule",
|
|
1072
|
-
filter: 0,
|
|
1073
|
-
filterRes: 1,
|
|
1074
|
-
filterUnits: 1,
|
|
1075
|
-
floodOpacity: 1,
|
|
1076
|
-
"flood-opacity": "floodOpacity",
|
|
1077
|
-
floodColor: 1,
|
|
1078
|
-
"flood-color": "floodColor",
|
|
1079
|
-
focusable: 0,
|
|
1080
|
-
fontFamily: 1,
|
|
1081
|
-
"font-family": "fontFamily",
|
|
1082
|
-
fontSize: 1,
|
|
1083
|
-
"font-size": "fontSize",
|
|
1084
|
-
fontSizeAdjust: 1,
|
|
1085
|
-
"font-size-adjust": "fontSizeAdjust",
|
|
1086
|
-
fontStretch: 1,
|
|
1087
|
-
"font-stretch": "fontStretch",
|
|
1088
|
-
fontStyle: 1,
|
|
1089
|
-
"font-style": "fontStyle",
|
|
1090
|
-
fontVariant: 1,
|
|
1091
|
-
"font-variant": "fontVariant",
|
|
1092
|
-
fontWeight: 1,
|
|
1093
|
-
"font-weight": "fontWeight",
|
|
1094
|
-
format: 0,
|
|
1095
|
-
from: 0,
|
|
1096
|
-
fx: 0,
|
|
1097
|
-
fy: 0,
|
|
1098
|
-
g1: 0,
|
|
1099
|
-
g2: 0,
|
|
1100
|
-
glyphName: 1,
|
|
1101
|
-
"glyph-name": "glyphName",
|
|
1102
|
-
glyphOrientationHorizontal: 1,
|
|
1103
|
-
"glyph-orientation-horizontal": "glyphOrientationHorizontal",
|
|
1104
|
-
glyphOrientationVertical: 1,
|
|
1105
|
-
"glyph-orientation-vertical": "glyphOrientationVertical",
|
|
1106
|
-
glyphRef: 1,
|
|
1107
|
-
gradientTransform: 1,
|
|
1108
|
-
gradientUnits: 1,
|
|
1109
|
-
hanging: 0,
|
|
1110
|
-
horizAdvX: 1,
|
|
1111
|
-
"horiz-adv-x": "horizAdvX",
|
|
1112
|
-
horizOriginX: 1,
|
|
1113
|
-
"horiz-origin-x": "horizOriginX",
|
|
1114
|
-
ideographic: 0,
|
|
1115
|
-
imageRendering: 1,
|
|
1116
|
-
"image-rendering": "imageRendering",
|
|
1117
|
-
in2: 0,
|
|
1118
|
-
in: 0,
|
|
1119
|
-
inlist: 0,
|
|
1120
|
-
intercept: 0,
|
|
1121
|
-
k1: 0,
|
|
1122
|
-
k2: 0,
|
|
1123
|
-
k3: 0,
|
|
1124
|
-
k4: 0,
|
|
1125
|
-
k: 0,
|
|
1126
|
-
kernelMatrix: 1,
|
|
1127
|
-
kernelUnitLength: 1,
|
|
1128
|
-
kerning: 0,
|
|
1129
|
-
keyPoints: 1,
|
|
1130
|
-
keySplines: 1,
|
|
1131
|
-
keyTimes: 1,
|
|
1132
|
-
lengthAdjust: 1,
|
|
1133
|
-
letterSpacing: 1,
|
|
1134
|
-
"letter-spacing": "letterSpacing",
|
|
1135
|
-
lightingColor: 1,
|
|
1136
|
-
"lighting-color": "lightingColor",
|
|
1137
|
-
limitingConeAngle: 1,
|
|
1138
|
-
local: 0,
|
|
1139
|
-
markerEnd: 1,
|
|
1140
|
-
"marker-end": "markerEnd",
|
|
1141
|
-
markerHeight: 1,
|
|
1142
|
-
markerMid: 1,
|
|
1143
|
-
"marker-mid": "markerMid",
|
|
1144
|
-
markerStart: 1,
|
|
1145
|
-
"marker-start": "markerStart",
|
|
1146
|
-
markerUnits: 1,
|
|
1147
|
-
markerWidth: 1,
|
|
1148
|
-
mask: 0,
|
|
1149
|
-
maskContentUnits: 1,
|
|
1150
|
-
maskUnits: 1,
|
|
1151
|
-
mathematical: 0,
|
|
1152
|
-
mode: 0,
|
|
1153
|
-
numOctaves: 1,
|
|
1154
|
-
offset: 0,
|
|
1155
|
-
opacity: 0,
|
|
1156
|
-
operator: 0,
|
|
1157
|
-
order: 0,
|
|
1158
|
-
orient: 0,
|
|
1159
|
-
orientation: 0,
|
|
1160
|
-
origin: 0,
|
|
1161
|
-
overflow: 0,
|
|
1162
|
-
overlinePosition: 1,
|
|
1163
|
-
"overline-position": "overlinePosition",
|
|
1164
|
-
overlineThickness: 1,
|
|
1165
|
-
"overline-thickness": "overlineThickness",
|
|
1166
|
-
paintOrder: 1,
|
|
1167
|
-
"paint-order": "paintOrder",
|
|
1168
|
-
panose1: 0,
|
|
1169
|
-
"panose-1": "panose1",
|
|
1170
|
-
pathLength: 1,
|
|
1171
|
-
patternContentUnits: 1,
|
|
1172
|
-
patternTransform: 1,
|
|
1173
|
-
patternUnits: 1,
|
|
1174
|
-
pointerEvents: 1,
|
|
1175
|
-
"pointer-events": "pointerEvents",
|
|
1176
|
-
points: 0,
|
|
1177
|
-
pointsAtX: 1,
|
|
1178
|
-
pointsAtY: 1,
|
|
1179
|
-
pointsAtZ: 1,
|
|
1180
|
-
prefix: 0,
|
|
1181
|
-
preserveAlpha: 1,
|
|
1182
|
-
preserveAspectRatio: 1,
|
|
1183
|
-
primitiveUnits: 1,
|
|
1184
|
-
property: 0,
|
|
1185
|
-
r: 0,
|
|
1186
|
-
radius: 0,
|
|
1187
|
-
refX: 1,
|
|
1188
|
-
refY: 1,
|
|
1189
|
-
renderingIntent: 1,
|
|
1190
|
-
"rendering-intent": "renderingIntent",
|
|
1191
|
-
repeatCount: 1,
|
|
1192
|
-
repeatDur: 1,
|
|
1193
|
-
requiredExtensions: 1,
|
|
1194
|
-
requiredFeatures: 1,
|
|
1195
|
-
resource: 0,
|
|
1196
|
-
restart: 0,
|
|
1197
|
-
result: 0,
|
|
1198
|
-
results: 0,
|
|
1199
|
-
rotate: 0,
|
|
1200
|
-
rx: 0,
|
|
1201
|
-
ry: 0,
|
|
1202
|
-
scale: 0,
|
|
1203
|
-
security: 0,
|
|
1204
|
-
seed: 0,
|
|
1205
|
-
shapeRendering: 1,
|
|
1206
|
-
"shape-rendering": "shapeRendering",
|
|
1207
|
-
slope: 0,
|
|
1208
|
-
spacing: 0,
|
|
1209
|
-
specularConstant: 1,
|
|
1210
|
-
specularExponent: 1,
|
|
1211
|
-
speed: 0,
|
|
1212
|
-
spreadMethod: 1,
|
|
1213
|
-
startOffset: 1,
|
|
1214
|
-
stdDeviation: 1,
|
|
1215
|
-
stemh: 0,
|
|
1216
|
-
stemv: 0,
|
|
1217
|
-
stitchTiles: 1,
|
|
1218
|
-
stopColor: 1,
|
|
1219
|
-
"stop-color": "stopColor",
|
|
1220
|
-
stopOpacity: 1,
|
|
1221
|
-
"stop-opacity": "stopOpacity",
|
|
1222
|
-
strikethroughPosition: 1,
|
|
1223
|
-
"strikethrough-position": "strikethroughPosition",
|
|
1224
|
-
strikethroughThickness: 1,
|
|
1225
|
-
"strikethrough-thickness": "strikethroughThickness",
|
|
1226
|
-
string: 0,
|
|
1227
|
-
stroke: 0,
|
|
1228
|
-
strokeDasharray: 1,
|
|
1229
|
-
"stroke-dasharray": "strokeDasharray",
|
|
1230
|
-
strokeDashoffset: 1,
|
|
1231
|
-
"stroke-dashoffset": "strokeDashoffset",
|
|
1232
|
-
strokeLinecap: 1,
|
|
1233
|
-
"stroke-linecap": "strokeLinecap",
|
|
1234
|
-
strokeLinejoin: 1,
|
|
1235
|
-
"stroke-linejoin": "strokeLinejoin",
|
|
1236
|
-
strokeMiterlimit: 1,
|
|
1237
|
-
"stroke-miterlimit": "strokeMiterlimit",
|
|
1238
|
-
strokeWidth: 1,
|
|
1239
|
-
"stroke-width": "strokeWidth",
|
|
1240
|
-
strokeOpacity: 1,
|
|
1241
|
-
"stroke-opacity": "strokeOpacity",
|
|
1242
|
-
suppressContentEditableWarning: 1,
|
|
1243
|
-
suppressHydrationWarning: 1,
|
|
1244
|
-
surfaceScale: 1,
|
|
1245
|
-
systemLanguage: 1,
|
|
1246
|
-
tableValues: 1,
|
|
1247
|
-
targetX: 1,
|
|
1248
|
-
targetY: 1,
|
|
1249
|
-
textAnchor: 1,
|
|
1250
|
-
"text-anchor": "textAnchor",
|
|
1251
|
-
textDecoration: 1,
|
|
1252
|
-
"text-decoration": "textDecoration",
|
|
1253
|
-
textLength: 1,
|
|
1254
|
-
textRendering: 1,
|
|
1255
|
-
"text-rendering": "textRendering",
|
|
1256
|
-
to: 0,
|
|
1257
|
-
transform: 0,
|
|
1258
|
-
typeof: 0,
|
|
1259
|
-
u1: 0,
|
|
1260
|
-
u2: 0,
|
|
1261
|
-
underlinePosition: 1,
|
|
1262
|
-
"underline-position": "underlinePosition",
|
|
1263
|
-
underlineThickness: 1,
|
|
1264
|
-
"underline-thickness": "underlineThickness",
|
|
1265
|
-
unicode: 0,
|
|
1266
|
-
unicodeBidi: 1,
|
|
1267
|
-
"unicode-bidi": "unicodeBidi",
|
|
1268
|
-
unicodeRange: 1,
|
|
1269
|
-
"unicode-range": "unicodeRange",
|
|
1270
|
-
unitsPerEm: 1,
|
|
1271
|
-
"units-per-em": "unitsPerEm",
|
|
1272
|
-
unselectable: 0,
|
|
1273
|
-
vAlphabetic: 1,
|
|
1274
|
-
"v-alphabetic": "vAlphabetic",
|
|
1275
|
-
values: 0,
|
|
1276
|
-
vectorEffect: 1,
|
|
1277
|
-
"vector-effect": "vectorEffect",
|
|
1278
|
-
version: 0,
|
|
1279
|
-
vertAdvY: 1,
|
|
1280
|
-
"vert-adv-y": "vertAdvY",
|
|
1281
|
-
vertOriginX: 1,
|
|
1282
|
-
"vert-origin-x": "vertOriginX",
|
|
1283
|
-
vertOriginY: 1,
|
|
1284
|
-
"vert-origin-y": "vertOriginY",
|
|
1285
|
-
vHanging: 1,
|
|
1286
|
-
"v-hanging": "vHanging",
|
|
1287
|
-
vIdeographic: 1,
|
|
1288
|
-
"v-ideographic": "vIdeographic",
|
|
1289
|
-
viewBox: 1,
|
|
1290
|
-
viewTarget: 1,
|
|
1291
|
-
visibility: 0,
|
|
1292
|
-
vMathematical: 1,
|
|
1293
|
-
"v-mathematical": "vMathematical",
|
|
1294
|
-
vocab: 0,
|
|
1295
|
-
widths: 0,
|
|
1296
|
-
wordSpacing: 1,
|
|
1297
|
-
"word-spacing": "wordSpacing",
|
|
1298
|
-
writingMode: 1,
|
|
1299
|
-
"writing-mode": "writingMode",
|
|
1300
|
-
x1: 0,
|
|
1301
|
-
x2: 0,
|
|
1302
|
-
x: 0,
|
|
1303
|
-
xChannelSelector: 1,
|
|
1304
|
-
xHeight: 1,
|
|
1305
|
-
"x-height": "xHeight",
|
|
1306
|
-
xlinkActuate: 1,
|
|
1307
|
-
"xlink:actuate": "xlinkActuate",
|
|
1308
|
-
xlinkArcrole: 1,
|
|
1309
|
-
"xlink:arcrole": "xlinkArcrole",
|
|
1310
|
-
xlinkHref: 1,
|
|
1311
|
-
"xlink:href": "xlinkHref",
|
|
1312
|
-
xlinkRole: 1,
|
|
1313
|
-
"xlink:role": "xlinkRole",
|
|
1314
|
-
xlinkShow: 1,
|
|
1315
|
-
"xlink:show": "xlinkShow",
|
|
1316
|
-
xlinkTitle: 1,
|
|
1317
|
-
"xlink:title": "xlinkTitle",
|
|
1318
|
-
xlinkType: 1,
|
|
1319
|
-
"xlink:type": "xlinkType",
|
|
1320
|
-
xmlBase: 1,
|
|
1321
|
-
"xml:base": "xmlBase",
|
|
1322
|
-
xmlLang: 1,
|
|
1323
|
-
"xml:lang": "xmlLang",
|
|
1324
|
-
xmlns: 0,
|
|
1325
|
-
"xml:space": "xmlSpace",
|
|
1326
|
-
xmlnsXlink: 1,
|
|
1327
|
-
"xmlns:xlink": "xmlnsXlink",
|
|
1328
|
-
xmlSpace: 1,
|
|
1329
|
-
y1: 0,
|
|
1330
|
-
y2: 0,
|
|
1331
|
-
y: 0,
|
|
1332
|
-
yChannelSelector: 1,
|
|
1333
|
-
z: 0,
|
|
1334
|
-
zoomAndPan: 1
|
|
1335
|
-
};
|
|
1336
|
-
const RESERVED = 0;
|
|
1337
|
-
const STRING = 1;
|
|
1338
|
-
const BOOLEANISH_STRING = 2;
|
|
1339
|
-
const BOOLEAN = 3;
|
|
1340
|
-
const OVERLOADED_BOOLEAN = 4;
|
|
1341
|
-
const NUMERIC = 5;
|
|
1342
|
-
const POSITIVE_NUMERIC = 6;
|
|
1343
|
-
function getPropertyInfo(name) {
|
|
1344
|
-
return properties.hasOwnProperty(name) ? properties[name] : null;
|
|
1345
|
-
}
|
|
1346
|
-
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
|
|
1347
|
-
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
|
|
1348
|
-
this.attributeName = attributeName;
|
|
1349
|
-
this.attributeNamespace = attributeNamespace;
|
|
1350
|
-
this.mustUseProperty = mustUseProperty;
|
|
1351
|
-
this.propertyName = name;
|
|
1352
|
-
this.type = type;
|
|
1353
|
-
this.sanitizeURL = sanitizeURL;
|
|
1354
|
-
this.removeEmptyString = removeEmptyString;
|
|
1355
|
-
}
|
|
1356
|
-
const properties = {};
|
|
1357
|
-
const reservedProps = [
|
|
1358
|
-
"children",
|
|
1359
|
-
"dangerouslySetInnerHTML",
|
|
1360
|
-
// TODO: This prevents the assignment of defaultValue to regular
|
|
1361
|
-
// elements (not just inputs). Now that ReactDOMInput assigns to the
|
|
1362
|
-
// defaultValue property -- do we need this?
|
|
1363
|
-
"defaultValue",
|
|
1364
|
-
"defaultChecked",
|
|
1365
|
-
"innerHTML",
|
|
1366
|
-
"suppressContentEditableWarning",
|
|
1367
|
-
"suppressHydrationWarning",
|
|
1368
|
-
"style"
|
|
1369
|
-
];
|
|
1370
|
-
reservedProps.forEach((name) => {
|
|
1371
|
-
properties[name] = new PropertyInfoRecord(
|
|
1372
|
-
name,
|
|
1373
|
-
RESERVED,
|
|
1374
|
-
false,
|
|
1375
|
-
// mustUseProperty
|
|
1376
|
-
name,
|
|
1377
|
-
// attributeName
|
|
1378
|
-
null,
|
|
1379
|
-
// attributeNamespace
|
|
1380
|
-
false,
|
|
1381
|
-
// sanitizeURL
|
|
1382
|
-
false
|
|
1383
|
-
// removeEmptyString
|
|
1384
|
-
);
|
|
1385
|
-
});
|
|
1386
|
-
[
|
|
1387
|
-
["acceptCharset", "accept-charset"],
|
|
1388
|
-
["className", "class"],
|
|
1389
|
-
["htmlFor", "for"],
|
|
1390
|
-
["httpEquiv", "http-equiv"]
|
|
1391
|
-
].forEach(([name, attributeName]) => {
|
|
1392
|
-
properties[name] = new PropertyInfoRecord(
|
|
1393
|
-
name,
|
|
1394
|
-
STRING,
|
|
1395
|
-
false,
|
|
1396
|
-
// mustUseProperty
|
|
1397
|
-
attributeName,
|
|
1398
|
-
// attributeName
|
|
1399
|
-
null,
|
|
1400
|
-
// attributeNamespace
|
|
1401
|
-
false,
|
|
1402
|
-
// sanitizeURL
|
|
1403
|
-
false
|
|
1404
|
-
// removeEmptyString
|
|
1405
|
-
);
|
|
1406
|
-
});
|
|
1407
|
-
["contentEditable", "draggable", "spellCheck", "value"].forEach((name) => {
|
|
1408
|
-
properties[name] = new PropertyInfoRecord(
|
|
1409
|
-
name,
|
|
1410
|
-
BOOLEANISH_STRING,
|
|
1411
|
-
false,
|
|
1412
|
-
// mustUseProperty
|
|
1413
|
-
name.toLowerCase(),
|
|
1414
|
-
// attributeName
|
|
1415
|
-
null,
|
|
1416
|
-
// attributeNamespace
|
|
1417
|
-
false,
|
|
1418
|
-
// sanitizeURL
|
|
1419
|
-
false
|
|
1420
|
-
// removeEmptyString
|
|
1421
|
-
);
|
|
1422
|
-
});
|
|
1423
|
-
[
|
|
1424
|
-
"autoReverse",
|
|
1425
|
-
"externalResourcesRequired",
|
|
1426
|
-
"focusable",
|
|
1427
|
-
"preserveAlpha"
|
|
1428
|
-
].forEach((name) => {
|
|
1429
|
-
properties[name] = new PropertyInfoRecord(
|
|
1430
|
-
name,
|
|
1431
|
-
BOOLEANISH_STRING,
|
|
1432
|
-
false,
|
|
1433
|
-
// mustUseProperty
|
|
1434
|
-
name,
|
|
1435
|
-
// attributeName
|
|
1436
|
-
null,
|
|
1437
|
-
// attributeNamespace
|
|
1438
|
-
false,
|
|
1439
|
-
// sanitizeURL
|
|
1440
|
-
false
|
|
1441
|
-
// removeEmptyString
|
|
1442
|
-
);
|
|
1443
|
-
});
|
|
1444
|
-
[
|
|
1445
|
-
"allowFullScreen",
|
|
1446
|
-
"async",
|
|
1447
|
-
// Note: there is a special case that prevents it from being written to the DOM
|
|
1448
|
-
// on the client side because the browsers are inconsistent. Instead we call focus().
|
|
1449
|
-
"autoFocus",
|
|
1450
|
-
"autoPlay",
|
|
1451
|
-
"controls",
|
|
1452
|
-
"default",
|
|
1453
|
-
"defer",
|
|
1454
|
-
"disabled",
|
|
1455
|
-
"disablePictureInPicture",
|
|
1456
|
-
"disableRemotePlayback",
|
|
1457
|
-
"formNoValidate",
|
|
1458
|
-
"hidden",
|
|
1459
|
-
"loop",
|
|
1460
|
-
"noModule",
|
|
1461
|
-
"noValidate",
|
|
1462
|
-
"open",
|
|
1463
|
-
"playsInline",
|
|
1464
|
-
"readOnly",
|
|
1465
|
-
"required",
|
|
1466
|
-
"reversed",
|
|
1467
|
-
"scoped",
|
|
1468
|
-
"seamless",
|
|
1469
|
-
// Microdata
|
|
1470
|
-
"itemScope"
|
|
1471
|
-
].forEach((name) => {
|
|
1472
|
-
properties[name] = new PropertyInfoRecord(
|
|
1473
|
-
name,
|
|
1474
|
-
BOOLEAN,
|
|
1475
|
-
false,
|
|
1476
|
-
// mustUseProperty
|
|
1477
|
-
name.toLowerCase(),
|
|
1478
|
-
// attributeName
|
|
1479
|
-
null,
|
|
1480
|
-
// attributeNamespace
|
|
1481
|
-
false,
|
|
1482
|
-
// sanitizeURL
|
|
1483
|
-
false
|
|
1484
|
-
// removeEmptyString
|
|
1485
|
-
);
|
|
1486
|
-
});
|
|
1487
|
-
[
|
|
1488
|
-
"checked",
|
|
1489
|
-
// Note: `option.selected` is not updated if `select.multiple` is
|
|
1490
|
-
// disabled with `removeAttribute`. We have special logic for handling this.
|
|
1491
|
-
"multiple",
|
|
1492
|
-
"muted",
|
|
1493
|
-
"selected"
|
|
1494
|
-
// NOTE: if you add a camelCased prop to this list,
|
|
1495
|
-
// you'll need to set attributeName to name.toLowerCase()
|
|
1496
|
-
// instead in the assignment below.
|
|
1497
|
-
].forEach((name) => {
|
|
1498
|
-
properties[name] = new PropertyInfoRecord(
|
|
1499
|
-
name,
|
|
1500
|
-
BOOLEAN,
|
|
1501
|
-
true,
|
|
1502
|
-
// mustUseProperty
|
|
1503
|
-
name,
|
|
1504
|
-
// attributeName
|
|
1505
|
-
null,
|
|
1506
|
-
// attributeNamespace
|
|
1507
|
-
false,
|
|
1508
|
-
// sanitizeURL
|
|
1509
|
-
false
|
|
1510
|
-
// removeEmptyString
|
|
1511
|
-
);
|
|
1512
|
-
});
|
|
1513
|
-
[
|
|
1514
|
-
"capture",
|
|
1515
|
-
"download"
|
|
1516
|
-
// NOTE: if you add a camelCased prop to this list,
|
|
1517
|
-
// you'll need to set attributeName to name.toLowerCase()
|
|
1518
|
-
// instead in the assignment below.
|
|
1519
|
-
].forEach((name) => {
|
|
1520
|
-
properties[name] = new PropertyInfoRecord(
|
|
1521
|
-
name,
|
|
1522
|
-
OVERLOADED_BOOLEAN,
|
|
1523
|
-
false,
|
|
1524
|
-
// mustUseProperty
|
|
1525
|
-
name,
|
|
1526
|
-
// attributeName
|
|
1527
|
-
null,
|
|
1528
|
-
// attributeNamespace
|
|
1529
|
-
false,
|
|
1530
|
-
// sanitizeURL
|
|
1531
|
-
false
|
|
1532
|
-
// removeEmptyString
|
|
1533
|
-
);
|
|
1534
|
-
});
|
|
1535
|
-
[
|
|
1536
|
-
"cols",
|
|
1537
|
-
"rows",
|
|
1538
|
-
"size",
|
|
1539
|
-
"span"
|
|
1540
|
-
// NOTE: if you add a camelCased prop to this list,
|
|
1541
|
-
// you'll need to set attributeName to name.toLowerCase()
|
|
1542
|
-
// instead in the assignment below.
|
|
1543
|
-
].forEach((name) => {
|
|
1544
|
-
properties[name] = new PropertyInfoRecord(
|
|
1545
|
-
name,
|
|
1546
|
-
POSITIVE_NUMERIC,
|
|
1547
|
-
false,
|
|
1548
|
-
// mustUseProperty
|
|
1549
|
-
name,
|
|
1550
|
-
// attributeName
|
|
1551
|
-
null,
|
|
1552
|
-
// attributeNamespace
|
|
1553
|
-
false,
|
|
1554
|
-
// sanitizeURL
|
|
1555
|
-
false
|
|
1556
|
-
// removeEmptyString
|
|
1557
|
-
);
|
|
1558
|
-
});
|
|
1559
|
-
["rowSpan", "start"].forEach((name) => {
|
|
1560
|
-
properties[name] = new PropertyInfoRecord(
|
|
1561
|
-
name,
|
|
1562
|
-
NUMERIC,
|
|
1563
|
-
false,
|
|
1564
|
-
// mustUseProperty
|
|
1565
|
-
name.toLowerCase(),
|
|
1566
|
-
// attributeName
|
|
1567
|
-
null,
|
|
1568
|
-
// attributeNamespace
|
|
1569
|
-
false,
|
|
1570
|
-
// sanitizeURL
|
|
1571
|
-
false
|
|
1572
|
-
// removeEmptyString
|
|
1573
|
-
);
|
|
1574
|
-
});
|
|
1575
|
-
const CAMELIZE = /[\-\:]([a-z])/g;
|
|
1576
|
-
const capitalize$1 = (token) => token[1].toUpperCase();
|
|
1577
|
-
[
|
|
1578
|
-
"accent-height",
|
|
1579
|
-
"alignment-baseline",
|
|
1580
|
-
"arabic-form",
|
|
1581
|
-
"baseline-shift",
|
|
1582
|
-
"cap-height",
|
|
1583
|
-
"clip-path",
|
|
1584
|
-
"clip-rule",
|
|
1585
|
-
"color-interpolation",
|
|
1586
|
-
"color-interpolation-filters",
|
|
1587
|
-
"color-profile",
|
|
1588
|
-
"color-rendering",
|
|
1589
|
-
"dominant-baseline",
|
|
1590
|
-
"enable-background",
|
|
1591
|
-
"fill-opacity",
|
|
1592
|
-
"fill-rule",
|
|
1593
|
-
"flood-color",
|
|
1594
|
-
"flood-opacity",
|
|
1595
|
-
"font-family",
|
|
1596
|
-
"font-size",
|
|
1597
|
-
"font-size-adjust",
|
|
1598
|
-
"font-stretch",
|
|
1599
|
-
"font-style",
|
|
1600
|
-
"font-variant",
|
|
1601
|
-
"font-weight",
|
|
1602
|
-
"glyph-name",
|
|
1603
|
-
"glyph-orientation-horizontal",
|
|
1604
|
-
"glyph-orientation-vertical",
|
|
1605
|
-
"horiz-adv-x",
|
|
1606
|
-
"horiz-origin-x",
|
|
1607
|
-
"image-rendering",
|
|
1608
|
-
"letter-spacing",
|
|
1609
|
-
"lighting-color",
|
|
1610
|
-
"marker-end",
|
|
1611
|
-
"marker-mid",
|
|
1612
|
-
"marker-start",
|
|
1613
|
-
"overline-position",
|
|
1614
|
-
"overline-thickness",
|
|
1615
|
-
"paint-order",
|
|
1616
|
-
"panose-1",
|
|
1617
|
-
"pointer-events",
|
|
1618
|
-
"rendering-intent",
|
|
1619
|
-
"shape-rendering",
|
|
1620
|
-
"stop-color",
|
|
1621
|
-
"stop-opacity",
|
|
1622
|
-
"strikethrough-position",
|
|
1623
|
-
"strikethrough-thickness",
|
|
1624
|
-
"stroke-dasharray",
|
|
1625
|
-
"stroke-dashoffset",
|
|
1626
|
-
"stroke-linecap",
|
|
1627
|
-
"stroke-linejoin",
|
|
1628
|
-
"stroke-miterlimit",
|
|
1629
|
-
"stroke-opacity",
|
|
1630
|
-
"stroke-width",
|
|
1631
|
-
"text-anchor",
|
|
1632
|
-
"text-decoration",
|
|
1633
|
-
"text-rendering",
|
|
1634
|
-
"underline-position",
|
|
1635
|
-
"underline-thickness",
|
|
1636
|
-
"unicode-bidi",
|
|
1637
|
-
"unicode-range",
|
|
1638
|
-
"units-per-em",
|
|
1639
|
-
"v-alphabetic",
|
|
1640
|
-
"v-hanging",
|
|
1641
|
-
"v-ideographic",
|
|
1642
|
-
"v-mathematical",
|
|
1643
|
-
"vector-effect",
|
|
1644
|
-
"vert-adv-y",
|
|
1645
|
-
"vert-origin-x",
|
|
1646
|
-
"vert-origin-y",
|
|
1647
|
-
"word-spacing",
|
|
1648
|
-
"writing-mode",
|
|
1649
|
-
"xmlns:xlink",
|
|
1650
|
-
"x-height"
|
|
1651
|
-
// NOTE: if you add a camelCased prop to this list,
|
|
1652
|
-
// you'll need to set attributeName to name.toLowerCase()
|
|
1653
|
-
// instead in the assignment below.
|
|
1654
|
-
].forEach((attributeName) => {
|
|
1655
|
-
const name = attributeName.replace(CAMELIZE, capitalize$1);
|
|
1656
|
-
properties[name] = new PropertyInfoRecord(
|
|
1657
|
-
name,
|
|
1658
|
-
STRING,
|
|
1659
|
-
false,
|
|
1660
|
-
// mustUseProperty
|
|
1661
|
-
attributeName,
|
|
1662
|
-
null,
|
|
1663
|
-
// attributeNamespace
|
|
1664
|
-
false,
|
|
1665
|
-
// sanitizeURL
|
|
1666
|
-
false
|
|
1667
|
-
// removeEmptyString
|
|
1668
|
-
);
|
|
1669
|
-
});
|
|
1670
|
-
[
|
|
1671
|
-
"xlink:actuate",
|
|
1672
|
-
"xlink:arcrole",
|
|
1673
|
-
"xlink:role",
|
|
1674
|
-
"xlink:show",
|
|
1675
|
-
"xlink:title",
|
|
1676
|
-
"xlink:type"
|
|
1677
|
-
// NOTE: if you add a camelCased prop to this list,
|
|
1678
|
-
// you'll need to set attributeName to name.toLowerCase()
|
|
1679
|
-
// instead in the assignment below.
|
|
1680
|
-
].forEach((attributeName) => {
|
|
1681
|
-
const name = attributeName.replace(CAMELIZE, capitalize$1);
|
|
1682
|
-
properties[name] = new PropertyInfoRecord(
|
|
1683
|
-
name,
|
|
1684
|
-
STRING,
|
|
1685
|
-
false,
|
|
1686
|
-
// mustUseProperty
|
|
1687
|
-
attributeName,
|
|
1688
|
-
"http://www.w3.org/1999/xlink",
|
|
1689
|
-
false,
|
|
1690
|
-
// sanitizeURL
|
|
1691
|
-
false
|
|
1692
|
-
// removeEmptyString
|
|
1693
|
-
);
|
|
1694
|
-
});
|
|
1695
|
-
[
|
|
1696
|
-
"xml:base",
|
|
1697
|
-
"xml:lang",
|
|
1698
|
-
"xml:space"
|
|
1699
|
-
// NOTE: if you add a camelCased prop to this list,
|
|
1700
|
-
// you'll need to set attributeName to name.toLowerCase()
|
|
1701
|
-
// instead in the assignment below.
|
|
1702
|
-
].forEach((attributeName) => {
|
|
1703
|
-
const name = attributeName.replace(CAMELIZE, capitalize$1);
|
|
1704
|
-
properties[name] = new PropertyInfoRecord(
|
|
1705
|
-
name,
|
|
1706
|
-
STRING,
|
|
1707
|
-
false,
|
|
1708
|
-
// mustUseProperty
|
|
1709
|
-
attributeName,
|
|
1710
|
-
"http://www.w3.org/XML/1998/namespace",
|
|
1711
|
-
false,
|
|
1712
|
-
// sanitizeURL
|
|
1713
|
-
false
|
|
1714
|
-
// removeEmptyString
|
|
1715
|
-
);
|
|
1716
|
-
});
|
|
1717
|
-
["tabIndex", "crossOrigin"].forEach((attributeName) => {
|
|
1718
|
-
properties[attributeName] = new PropertyInfoRecord(
|
|
1719
|
-
attributeName,
|
|
1720
|
-
STRING,
|
|
1721
|
-
false,
|
|
1722
|
-
// mustUseProperty
|
|
1723
|
-
attributeName.toLowerCase(),
|
|
1724
|
-
// attributeName
|
|
1725
|
-
null,
|
|
1726
|
-
// attributeNamespace
|
|
1727
|
-
false,
|
|
1728
|
-
// sanitizeURL
|
|
1729
|
-
false
|
|
1730
|
-
// removeEmptyString
|
|
1731
|
-
);
|
|
1732
|
-
});
|
|
1733
|
-
const xlinkHref = "xlinkHref";
|
|
1734
|
-
properties[xlinkHref] = new PropertyInfoRecord(
|
|
1735
|
-
"xlinkHref",
|
|
1736
|
-
STRING,
|
|
1737
|
-
false,
|
|
1738
|
-
// mustUseProperty
|
|
1739
|
-
"xlink:href",
|
|
1740
|
-
"http://www.w3.org/1999/xlink",
|
|
1741
|
-
true,
|
|
1742
|
-
// sanitizeURL
|
|
1743
|
-
false
|
|
1744
|
-
// removeEmptyString
|
|
1745
|
-
);
|
|
1746
|
-
["src", "href", "action", "formAction"].forEach((attributeName) => {
|
|
1747
|
-
properties[attributeName] = new PropertyInfoRecord(
|
|
1748
|
-
attributeName,
|
|
1749
|
-
STRING,
|
|
1750
|
-
false,
|
|
1751
|
-
// mustUseProperty
|
|
1752
|
-
attributeName.toLowerCase(),
|
|
1753
|
-
// attributeName
|
|
1754
|
-
null,
|
|
1755
|
-
// attributeNamespace
|
|
1756
|
-
true,
|
|
1757
|
-
// sanitizeURL
|
|
1758
|
-
true
|
|
1759
|
-
// removeEmptyString
|
|
1760
|
-
);
|
|
1761
|
-
});
|
|
1762
|
-
const {
|
|
1763
|
-
CAMELCASE,
|
|
1764
|
-
SAME,
|
|
1765
|
-
possibleStandardNames: possibleStandardNamesOptimized
|
|
1766
|
-
} = possibleStandardNamesOptimized$1;
|
|
1767
|
-
const ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
1768
|
-
const ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
1769
|
-
const isCustomAttribute = RegExp.prototype.test.bind(
|
|
1770
|
-
// eslint-disable-next-line no-misleading-character-class
|
|
1771
|
-
new RegExp("^(data|aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$")
|
|
1772
|
-
);
|
|
1773
|
-
const possibleStandardNames = Object.keys(
|
|
1774
|
-
possibleStandardNamesOptimized
|
|
1775
|
-
).reduce((accumulator, standardName) => {
|
|
1776
|
-
const propName = possibleStandardNamesOptimized[standardName];
|
|
1777
|
-
if (propName === SAME) {
|
|
1778
|
-
accumulator[standardName] = standardName;
|
|
1779
|
-
} else if (propName === CAMELCASE) {
|
|
1780
|
-
accumulator[standardName.toLowerCase()] = standardName;
|
|
1781
|
-
} else {
|
|
1782
|
-
accumulator[standardName] = propName;
|
|
1783
|
-
}
|
|
1784
|
-
return accumulator;
|
|
1785
|
-
}, {});
|
|
1786
|
-
lib.BOOLEAN = BOOLEAN;
|
|
1787
|
-
lib.BOOLEANISH_STRING = BOOLEANISH_STRING;
|
|
1788
|
-
lib.NUMERIC = NUMERIC;
|
|
1789
|
-
lib.OVERLOADED_BOOLEAN = OVERLOADED_BOOLEAN;
|
|
1790
|
-
lib.POSITIVE_NUMERIC = POSITIVE_NUMERIC;
|
|
1791
|
-
lib.RESERVED = RESERVED;
|
|
1792
|
-
lib.STRING = STRING;
|
|
1793
|
-
lib.getPropertyInfo = getPropertyInfo;
|
|
1794
|
-
lib.isCustomAttribute = isCustomAttribute;
|
|
1795
|
-
lib.possibleStandardNames = possibleStandardNames;
|
|
1796
|
-
var utilities$1 = {};
|
|
1797
|
-
var cjs$1 = {};
|
|
1798
|
-
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
1799
|
-
var NEWLINE_REGEX = /\n/g;
|
|
1800
|
-
var WHITESPACE_REGEX = /^\s*/;
|
|
1801
|
-
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
|
1802
|
-
var COLON_REGEX = /^:\s*/;
|
|
1803
|
-
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
|
1804
|
-
var SEMICOLON_REGEX = /^[;\s]*/;
|
|
1805
|
-
var TRIM_REGEX = /^\s+|\s+$/g;
|
|
1806
|
-
var NEWLINE = "\n";
|
|
1807
|
-
var FORWARD_SLASH = "/";
|
|
1808
|
-
var ASTERISK = "*";
|
|
1809
|
-
var EMPTY_STRING = "";
|
|
1810
|
-
var TYPE_COMMENT = "comment";
|
|
1811
|
-
var TYPE_DECLARATION = "declaration";
|
|
1812
|
-
var inlineStyleParser = function(style, options) {
|
|
1813
|
-
if (typeof style !== "string") {
|
|
1814
|
-
throw new TypeError("First argument must be a string");
|
|
1815
|
-
}
|
|
1816
|
-
if (!style) return [];
|
|
1817
|
-
options = options || {};
|
|
1818
|
-
var lineno = 1;
|
|
1819
|
-
var column = 1;
|
|
1820
|
-
function updatePosition(str) {
|
|
1821
|
-
var lines = str.match(NEWLINE_REGEX);
|
|
1822
|
-
if (lines) lineno += lines.length;
|
|
1823
|
-
var i = str.lastIndexOf(NEWLINE);
|
|
1824
|
-
column = ~i ? str.length - i : column + str.length;
|
|
1825
|
-
}
|
|
1826
|
-
function position() {
|
|
1827
|
-
var start = { line: lineno, column };
|
|
1828
|
-
return function(node2) {
|
|
1829
|
-
node2.position = new Position(start);
|
|
1830
|
-
whitespace();
|
|
1831
|
-
return node2;
|
|
1832
|
-
};
|
|
1833
|
-
}
|
|
1834
|
-
function Position(start) {
|
|
1835
|
-
this.start = start;
|
|
1836
|
-
this.end = { line: lineno, column };
|
|
1837
|
-
this.source = options.source;
|
|
1838
|
-
}
|
|
1839
|
-
Position.prototype.content = style;
|
|
1840
|
-
function error(msg) {
|
|
1841
|
-
var err = new Error(
|
|
1842
|
-
options.source + ":" + lineno + ":" + column + ": " + msg
|
|
1843
|
-
);
|
|
1844
|
-
err.reason = msg;
|
|
1845
|
-
err.filename = options.source;
|
|
1846
|
-
err.line = lineno;
|
|
1847
|
-
err.column = column;
|
|
1848
|
-
err.source = style;
|
|
1849
|
-
if (options.silent) ;
|
|
1850
|
-
else {
|
|
1851
|
-
throw err;
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
function match(re) {
|
|
1855
|
-
var m = re.exec(style);
|
|
1856
|
-
if (!m) return;
|
|
1857
|
-
var str = m[0];
|
|
1858
|
-
updatePosition(str);
|
|
1859
|
-
style = style.slice(str.length);
|
|
1860
|
-
return m;
|
|
1861
|
-
}
|
|
1862
|
-
function whitespace() {
|
|
1863
|
-
match(WHITESPACE_REGEX);
|
|
1864
|
-
}
|
|
1865
|
-
function comments(rules) {
|
|
1866
|
-
var c;
|
|
1867
|
-
rules = rules || [];
|
|
1868
|
-
while (c = comment()) {
|
|
1869
|
-
if (c !== false) {
|
|
1870
|
-
rules.push(c);
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
return rules;
|
|
1874
|
-
}
|
|
1875
|
-
function comment() {
|
|
1876
|
-
var pos = position();
|
|
1877
|
-
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
1878
|
-
var i = 2;
|
|
1879
|
-
while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) {
|
|
1880
|
-
++i;
|
|
1881
|
-
}
|
|
1882
|
-
i += 2;
|
|
1883
|
-
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
1884
|
-
return error("End of comment missing");
|
|
1885
|
-
}
|
|
1886
|
-
var str = style.slice(2, i - 2);
|
|
1887
|
-
column += 2;
|
|
1888
|
-
updatePosition(str);
|
|
1889
|
-
style = style.slice(i);
|
|
1890
|
-
column += 2;
|
|
1891
|
-
return pos({
|
|
1892
|
-
type: TYPE_COMMENT,
|
|
1893
|
-
comment: str
|
|
1894
|
-
});
|
|
1895
|
-
}
|
|
1896
|
-
function declaration() {
|
|
1897
|
-
var pos = position();
|
|
1898
|
-
var prop = match(PROPERTY_REGEX);
|
|
1899
|
-
if (!prop) return;
|
|
1900
|
-
comment();
|
|
1901
|
-
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
1902
|
-
var val = match(VALUE_REGEX);
|
|
1903
|
-
var ret = pos({
|
|
1904
|
-
type: TYPE_DECLARATION,
|
|
1905
|
-
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
|
1906
|
-
value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
|
|
1907
|
-
});
|
|
1908
|
-
match(SEMICOLON_REGEX);
|
|
1909
|
-
return ret;
|
|
1910
|
-
}
|
|
1911
|
-
function declarations() {
|
|
1912
|
-
var decls = [];
|
|
1913
|
-
comments(decls);
|
|
1914
|
-
var decl;
|
|
1915
|
-
while (decl = declaration()) {
|
|
1916
|
-
if (decl !== false) {
|
|
1917
|
-
decls.push(decl);
|
|
1918
|
-
comments(decls);
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
return decls;
|
|
1922
|
-
}
|
|
1923
|
-
whitespace();
|
|
1924
|
-
return declarations();
|
|
1925
|
-
};
|
|
1926
|
-
function trim(str) {
|
|
1927
|
-
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
1928
|
-
}
|
|
1929
|
-
var __importDefault$2 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
1930
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1931
|
-
};
|
|
1932
|
-
Object.defineProperty(cjs$1, "__esModule", { value: true });
|
|
1933
|
-
cjs$1.default = StyleToObject;
|
|
1934
|
-
var inline_style_parser_1 = __importDefault$2(inlineStyleParser);
|
|
1935
|
-
function StyleToObject(style, iterator) {
|
|
1936
|
-
var styleObject = null;
|
|
1937
|
-
if (!style || typeof style !== "string") {
|
|
1938
|
-
return styleObject;
|
|
1939
|
-
}
|
|
1940
|
-
var declarations = (0, inline_style_parser_1.default)(style);
|
|
1941
|
-
var hasIterator = typeof iterator === "function";
|
|
1942
|
-
declarations.forEach(function(declaration) {
|
|
1943
|
-
if (declaration.type !== "declaration") {
|
|
1944
|
-
return;
|
|
1945
|
-
}
|
|
1946
|
-
var property = declaration.property, value = declaration.value;
|
|
1947
|
-
if (hasIterator) {
|
|
1948
|
-
iterator(property, value, declaration);
|
|
1949
|
-
} else if (value) {
|
|
1950
|
-
styleObject = styleObject || {};
|
|
1951
|
-
styleObject[property] = value;
|
|
1952
|
-
}
|
|
1953
|
-
});
|
|
1954
|
-
return styleObject;
|
|
1955
|
-
}
|
|
1956
|
-
var utilities = {};
|
|
1957
|
-
Object.defineProperty(utilities, "__esModule", { value: true });
|
|
1958
|
-
utilities.camelCase = void 0;
|
|
1959
|
-
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/;
|
|
1960
|
-
var HYPHEN_REGEX = /-([a-z])/g;
|
|
1961
|
-
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
1962
|
-
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
1963
|
-
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
1964
|
-
var skipCamelCase = function(property) {
|
|
1965
|
-
return !property || NO_HYPHEN_REGEX.test(property) || CUSTOM_PROPERTY_REGEX.test(property);
|
|
1966
|
-
};
|
|
1967
|
-
var capitalize = function(match, character) {
|
|
1968
|
-
return character.toUpperCase();
|
|
1969
|
-
};
|
|
1970
|
-
var trimHyphen = function(match, prefix) {
|
|
1971
|
-
return "".concat(prefix, "-");
|
|
1972
|
-
};
|
|
1973
|
-
var camelCase = function(property, options) {
|
|
1974
|
-
if (options === void 0) {
|
|
1975
|
-
options = {};
|
|
1976
|
-
}
|
|
1977
|
-
if (skipCamelCase(property)) {
|
|
1978
|
-
return property;
|
|
1979
|
-
}
|
|
1980
|
-
property = property.toLowerCase();
|
|
1981
|
-
if (options.reactCompat) {
|
|
1982
|
-
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
1983
|
-
} else {
|
|
1984
|
-
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
1985
|
-
}
|
|
1986
|
-
return property.replace(HYPHEN_REGEX, capitalize);
|
|
1987
|
-
};
|
|
1988
|
-
utilities.camelCase = camelCase;
|
|
1989
|
-
var __importDefault$1 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
1990
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1991
|
-
};
|
|
1992
|
-
var style_to_object_1 = __importDefault$1(cjs$1);
|
|
1993
|
-
var utilities_1$2 = utilities;
|
|
1994
|
-
function StyleToJS(style, options) {
|
|
1995
|
-
var output = {};
|
|
1996
|
-
if (!style || typeof style !== "string") {
|
|
1997
|
-
return output;
|
|
1998
|
-
}
|
|
1999
|
-
(0, style_to_object_1.default)(style, function(property, value) {
|
|
2000
|
-
if (property && value) {
|
|
2001
|
-
output[(0, utilities_1$2.camelCase)(property, options)] = value;
|
|
2002
|
-
}
|
|
2003
|
-
});
|
|
2004
|
-
return output;
|
|
2005
|
-
}
|
|
2006
|
-
StyleToJS.default = StyleToJS;
|
|
2007
|
-
var cjs = StyleToJS;
|
|
2008
|
-
(function(exports) {
|
|
2009
|
-
var __importDefault2 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
2010
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2011
|
-
};
|
|
2012
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2013
|
-
exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
2014
|
-
exports.isCustomComponent = isCustomComponent;
|
|
2015
|
-
exports.setStyleProp = setStyleProp;
|
|
2016
|
-
var react_12 = React$1;
|
|
2017
|
-
var style_to_js_1 = __importDefault2(cjs);
|
|
2018
|
-
var RESERVED_SVG_MATHML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
2019
|
-
"annotation-xml",
|
|
2020
|
-
"color-profile",
|
|
2021
|
-
"font-face",
|
|
2022
|
-
"font-face-src",
|
|
2023
|
-
"font-face-uri",
|
|
2024
|
-
"font-face-format",
|
|
2025
|
-
"font-face-name",
|
|
2026
|
-
"missing-glyph"
|
|
2027
|
-
]);
|
|
2028
|
-
function isCustomComponent(tagName, props) {
|
|
2029
|
-
if (!tagName.includes("-")) {
|
|
2030
|
-
return Boolean(props && typeof props.is === "string");
|
|
2031
|
-
}
|
|
2032
|
-
if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
|
|
2033
|
-
return false;
|
|
2034
|
-
}
|
|
2035
|
-
return true;
|
|
2036
|
-
}
|
|
2037
|
-
var styleOptions = {
|
|
2038
|
-
reactCompat: true
|
|
2039
|
-
};
|
|
2040
|
-
function setStyleProp(style, props) {
|
|
2041
|
-
if (typeof style !== "string") {
|
|
2042
|
-
return;
|
|
2043
|
-
}
|
|
2044
|
-
if (!style.trim()) {
|
|
2045
|
-
props.style = {};
|
|
2046
|
-
return;
|
|
2047
|
-
}
|
|
2048
|
-
try {
|
|
2049
|
-
props.style = (0, style_to_js_1.default)(style, styleOptions);
|
|
2050
|
-
} catch (error) {
|
|
2051
|
-
props.style = {};
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
exports.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_12.version.split(".")[0]) >= 16;
|
|
2055
|
-
exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = /* @__PURE__ */ new Set([
|
|
2056
|
-
"tr",
|
|
2057
|
-
"tbody",
|
|
2058
|
-
"thead",
|
|
2059
|
-
"tfoot",
|
|
2060
|
-
"colgroup",
|
|
2061
|
-
"table",
|
|
2062
|
-
"head",
|
|
2063
|
-
"html",
|
|
2064
|
-
"frameset"
|
|
2065
|
-
]);
|
|
2066
|
-
var canTextBeChildOfNode = function(node2) {
|
|
2067
|
-
return !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node2.name);
|
|
2068
|
-
};
|
|
2069
|
-
exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2070
|
-
var returnFirstArg = function(arg) {
|
|
2071
|
-
return arg;
|
|
2072
|
-
};
|
|
2073
|
-
exports.returnFirstArg = returnFirstArg;
|
|
2074
|
-
})(utilities$1);
|
|
2075
|
-
Object.defineProperty(attributesToProps$1, "__esModule", { value: true });
|
|
2076
|
-
attributesToProps$1.default = attributesToProps;
|
|
2077
|
-
var react_property_1 = lib;
|
|
2078
|
-
var utilities_1$1 = utilities$1;
|
|
2079
|
-
var UNCONTROLLED_COMPONENT_ATTRIBUTES = ["checked", "value"];
|
|
2080
|
-
var UNCONTROLLED_COMPONENT_NAMES = ["input", "select", "textarea"];
|
|
2081
|
-
var valueOnlyInputs = {
|
|
2082
|
-
reset: true,
|
|
2083
|
-
submit: true
|
|
2084
|
-
};
|
|
2085
|
-
function attributesToProps(attributes, nodeName) {
|
|
2086
|
-
if (attributes === void 0) {
|
|
2087
|
-
attributes = {};
|
|
2088
|
-
}
|
|
2089
|
-
var props = {};
|
|
2090
|
-
var isInputValueOnly = Boolean(attributes.type && valueOnlyInputs[attributes.type]);
|
|
2091
|
-
for (var attributeName in attributes) {
|
|
2092
|
-
var attributeValue = attributes[attributeName];
|
|
2093
|
-
if ((0, react_property_1.isCustomAttribute)(attributeName)) {
|
|
2094
|
-
props[attributeName] = attributeValue;
|
|
2095
|
-
continue;
|
|
2096
|
-
}
|
|
2097
|
-
var attributeNameLowerCased = attributeName.toLowerCase();
|
|
2098
|
-
var propName = getPropName(attributeNameLowerCased);
|
|
2099
|
-
if (propName) {
|
|
2100
|
-
var propertyInfo = (0, react_property_1.getPropertyInfo)(propName);
|
|
2101
|
-
if (UNCONTROLLED_COMPONENT_ATTRIBUTES.includes(propName) && UNCONTROLLED_COMPONENT_NAMES.includes(nodeName) && !isInputValueOnly) {
|
|
2102
|
-
propName = getPropName("default" + attributeNameLowerCased);
|
|
2103
|
-
}
|
|
2104
|
-
props[propName] = attributeValue;
|
|
2105
|
-
switch (propertyInfo && propertyInfo.type) {
|
|
2106
|
-
case react_property_1.BOOLEAN:
|
|
2107
|
-
props[propName] = true;
|
|
2108
|
-
break;
|
|
2109
|
-
case react_property_1.OVERLOADED_BOOLEAN:
|
|
2110
|
-
if (attributeValue === "") {
|
|
2111
|
-
props[propName] = true;
|
|
2112
|
-
}
|
|
2113
|
-
break;
|
|
2114
|
-
}
|
|
2115
|
-
continue;
|
|
2116
|
-
}
|
|
2117
|
-
if (utilities_1$1.PRESERVE_CUSTOM_ATTRIBUTES) {
|
|
2118
|
-
props[attributeName] = attributeValue;
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
(0, utilities_1$1.setStyleProp)(attributes.style, props);
|
|
2122
|
-
return props;
|
|
2123
|
-
}
|
|
2124
|
-
function getPropName(attributeName) {
|
|
2125
|
-
return react_property_1.possibleStandardNames[attributeName];
|
|
2126
|
-
}
|
|
2127
|
-
var domToReact$1 = {};
|
|
2128
|
-
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
2129
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2130
|
-
};
|
|
2131
|
-
Object.defineProperty(domToReact$1, "__esModule", { value: true });
|
|
2132
|
-
domToReact$1.default = domToReact;
|
|
2133
|
-
var react_1 = React$1;
|
|
2134
|
-
var attributes_to_props_1 = __importDefault(attributesToProps$1);
|
|
2135
|
-
var utilities_1 = utilities$1;
|
|
2136
|
-
var React = {
|
|
2137
|
-
cloneElement: react_1.cloneElement,
|
|
2138
|
-
createElement: react_1.createElement,
|
|
2139
|
-
isValidElement: react_1.isValidElement
|
|
2140
|
-
};
|
|
2141
|
-
function domToReact(nodes, options) {
|
|
2142
|
-
if (options === void 0) {
|
|
2143
|
-
options = {};
|
|
2144
|
-
}
|
|
2145
|
-
var reactElements = [];
|
|
2146
|
-
var hasReplace = typeof options.replace === "function";
|
|
2147
|
-
var transform = options.transform || utilities_1.returnFirstArg;
|
|
2148
|
-
var _a = options.library || React, cloneElement = _a.cloneElement, createElement = _a.createElement, isValidElement = _a.isValidElement;
|
|
2149
|
-
var nodesLength = nodes.length;
|
|
2150
|
-
for (var index = 0; index < nodesLength; index++) {
|
|
2151
|
-
var node2 = nodes[index];
|
|
2152
|
-
if (hasReplace) {
|
|
2153
|
-
var replaceElement = options.replace(node2, index);
|
|
2154
|
-
if (isValidElement(replaceElement)) {
|
|
2155
|
-
if (nodesLength > 1) {
|
|
2156
|
-
replaceElement = cloneElement(replaceElement, {
|
|
2157
|
-
key: replaceElement.key || index
|
|
2158
|
-
});
|
|
2159
|
-
}
|
|
2160
|
-
reactElements.push(transform(replaceElement, node2, index));
|
|
2161
|
-
continue;
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
if (node2.type === "text") {
|
|
2165
|
-
var isWhitespace = !node2.data.trim().length;
|
|
2166
|
-
if (isWhitespace && node2.parent && !(0, utilities_1.canTextBeChildOfNode)(node2.parent)) {
|
|
2167
|
-
continue;
|
|
2168
|
-
}
|
|
2169
|
-
if (options.trim && isWhitespace) {
|
|
2170
|
-
continue;
|
|
2171
|
-
}
|
|
2172
|
-
reactElements.push(transform(node2.data, node2, index));
|
|
2173
|
-
continue;
|
|
2174
|
-
}
|
|
2175
|
-
var element = node2;
|
|
2176
|
-
var props = {};
|
|
2177
|
-
if (skipAttributesToProps(element)) {
|
|
2178
|
-
(0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
|
|
2179
|
-
props = element.attribs;
|
|
2180
|
-
} else if (element.attribs) {
|
|
2181
|
-
props = (0, attributes_to_props_1.default)(element.attribs, element.name);
|
|
2182
|
-
}
|
|
2183
|
-
var children = void 0;
|
|
2184
|
-
switch (node2.type) {
|
|
2185
|
-
case "script":
|
|
2186
|
-
case "style":
|
|
2187
|
-
if (node2.children[0]) {
|
|
2188
|
-
props.dangerouslySetInnerHTML = {
|
|
2189
|
-
__html: node2.children[0].data
|
|
2190
|
-
};
|
|
2191
|
-
}
|
|
2192
|
-
break;
|
|
2193
|
-
case "tag":
|
|
2194
|
-
if (node2.name === "textarea" && node2.children[0]) {
|
|
2195
|
-
props.defaultValue = node2.children[0].data;
|
|
2196
|
-
} else if (node2.children && node2.children.length) {
|
|
2197
|
-
children = domToReact(node2.children, options);
|
|
2198
|
-
}
|
|
2199
|
-
break;
|
|
2200
|
-
default:
|
|
2201
|
-
continue;
|
|
2202
|
-
}
|
|
2203
|
-
if (nodesLength > 1) {
|
|
2204
|
-
props.key = index;
|
|
2205
|
-
}
|
|
2206
|
-
reactElements.push(transform(createElement(node2.name, props, children), node2, index));
|
|
2207
|
-
}
|
|
2208
|
-
return reactElements.length === 1 ? reactElements[0] : reactElements;
|
|
2209
|
-
}
|
|
2210
|
-
function skipAttributesToProps(node2) {
|
|
2211
|
-
return utilities_1.PRESERVE_CUSTOM_ATTRIBUTES && node2.type === "tag" && (0, utilities_1.isCustomComponent)(node2.name, node2.attribs);
|
|
2212
|
-
}
|
|
2213
|
-
(function(exports) {
|
|
2214
|
-
var __importDefault2 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
2215
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2216
|
-
};
|
|
2217
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2218
|
-
exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
|
|
2219
|
-
exports.default = HTMLReactParser2;
|
|
2220
|
-
var html_dom_parser_1 = __importDefault2(htmlToDom);
|
|
2221
|
-
exports.htmlToDOM = html_dom_parser_1.default;
|
|
2222
|
-
var attributes_to_props_12 = __importDefault2(attributesToProps$1);
|
|
2223
|
-
exports.attributesToProps = attributes_to_props_12.default;
|
|
2224
|
-
var dom_to_react_1 = __importDefault2(domToReact$1);
|
|
2225
|
-
exports.domToReact = dom_to_react_1.default;
|
|
2226
|
-
var domhandler_12 = lib$2;
|
|
2227
|
-
Object.defineProperty(exports, "Comment", { enumerable: true, get: function() {
|
|
2228
|
-
return domhandler_12.Comment;
|
|
2229
|
-
} });
|
|
2230
|
-
Object.defineProperty(exports, "Element", { enumerable: true, get: function() {
|
|
2231
|
-
return domhandler_12.Element;
|
|
2232
|
-
} });
|
|
2233
|
-
Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function() {
|
|
2234
|
-
return domhandler_12.ProcessingInstruction;
|
|
2235
|
-
} });
|
|
2236
|
-
Object.defineProperty(exports, "Text", { enumerable: true, get: function() {
|
|
2237
|
-
return domhandler_12.Text;
|
|
2238
|
-
} });
|
|
2239
|
-
var domParserOptions = { lowerCaseAttributeNames: false };
|
|
2240
|
-
function HTMLReactParser2(html, options) {
|
|
2241
|
-
if (typeof html !== "string") {
|
|
2242
|
-
throw new TypeError("First argument must be a string");
|
|
2243
|
-
}
|
|
2244
|
-
if (!html) {
|
|
2245
|
-
return [];
|
|
2246
|
-
}
|
|
2247
|
-
return (0, dom_to_react_1.default)((0, html_dom_parser_1.default)(html, (options === null || options === void 0 ? void 0 : options.htmlparser2) || domParserOptions), options);
|
|
2248
|
-
}
|
|
2249
|
-
})(lib$3);
|
|
2250
|
-
const HTMLReactParser = /* @__PURE__ */ getDefaultExportFromCjs(lib$3);
|
|
2251
|
-
const parse = HTMLReactParser.default || HTMLReactParser;
|
|
2252
|
-
const CodeBlock = React$1.forwardRef(
|
|
7
|
+
const CodeBlock = React.forwardRef(
|
|
2253
8
|
({
|
|
2254
9
|
children,
|
|
2255
10
|
source,
|
|
@@ -2257,10 +12,13 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2257
12
|
showCopyButton,
|
|
2258
13
|
showLineNumbers,
|
|
2259
14
|
description,
|
|
15
|
+
withSyntaxHighlighting = false,
|
|
2260
16
|
...props
|
|
2261
17
|
}, ref) => {
|
|
2262
18
|
const [isCodeCopied, setIsCodeCopied] = useState(false);
|
|
2263
|
-
|
|
19
|
+
const [highlightedCode, setHighlightedCode] = useState("");
|
|
20
|
+
const [prismModule, setPrismModule] = useState(null);
|
|
21
|
+
let code = typeof children === "string" ? children : React.Children.toArray(children).join("");
|
|
2264
22
|
if (!children) {
|
|
2265
23
|
code = typeof source === "object" ? JSON.stringify(source, null, 2) : source ?? "";
|
|
2266
24
|
}
|
|
@@ -2269,10 +27,68 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2269
27
|
classNames.push("show-line-numbers");
|
|
2270
28
|
}
|
|
2271
29
|
const lines = code.split(/\r\n|\r|\n/gm);
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2274
|
-
|
|
30
|
+
const loadLanguage = async (languageName) => {
|
|
31
|
+
try {
|
|
32
|
+
await import(
|
|
33
|
+
/* @vite-ignore */
|
|
34
|
+
`prismjs/components/prism-${languageName}`
|
|
35
|
+
);
|
|
36
|
+
return true;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.warn(`Language '${languageName}' could not be loaded:`, error);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
2275
41
|
};
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!withSyntaxHighlighting) {
|
|
44
|
+
setHighlightedCode(code);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (prismModule && code) {
|
|
48
|
+
const languageGrammar = prismModule.languages[language];
|
|
49
|
+
if (languageGrammar) {
|
|
50
|
+
const highlighted = prismModule.highlight(code, languageGrammar, language);
|
|
51
|
+
setHighlightedCode(highlighted);
|
|
52
|
+
} else {
|
|
53
|
+
loadLanguage(language).then((success) => {
|
|
54
|
+
if (success && prismModule.languages[language]) {
|
|
55
|
+
const highlighted = prismModule.highlight(
|
|
56
|
+
code,
|
|
57
|
+
prismModule.languages[language],
|
|
58
|
+
language
|
|
59
|
+
);
|
|
60
|
+
setHighlightedCode(highlighted);
|
|
61
|
+
} else {
|
|
62
|
+
setHighlightedCode(code);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const loadPrismWithLanguage = async () => {
|
|
69
|
+
try {
|
|
70
|
+
const [prism] = await Promise.all([
|
|
71
|
+
import("prismjs"),
|
|
72
|
+
loadLanguage(language)
|
|
73
|
+
]);
|
|
74
|
+
setPrismModule(prism.default);
|
|
75
|
+
if (prism.default.languages[language]) {
|
|
76
|
+
const highlighted = prism.default.highlight(
|
|
77
|
+
code,
|
|
78
|
+
prism.default.languages[language],
|
|
79
|
+
language
|
|
80
|
+
);
|
|
81
|
+
setHighlightedCode(highlighted);
|
|
82
|
+
} else {
|
|
83
|
+
setHighlightedCode(code);
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.warn("Syntax highlighting doesnt seem to work:", error);
|
|
87
|
+
setHighlightedCode(code);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
loadPrismWithLanguage();
|
|
91
|
+
}, [withSyntaxHighlighting, code, language, prismModule]);
|
|
2276
92
|
const copyToClipboard = async () => {
|
|
2277
93
|
try {
|
|
2278
94
|
await navigator.clipboard.writeText(code);
|
|
@@ -2288,8 +104,8 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2288
104
|
await copyToClipboard();
|
|
2289
105
|
}
|
|
2290
106
|
};
|
|
2291
|
-
return /* @__PURE__ */ React
|
|
2292
|
-
Element
|
|
107
|
+
return /* @__PURE__ */ React.createElement(
|
|
108
|
+
Element,
|
|
2293
109
|
{
|
|
2294
110
|
"data-code-block": true,
|
|
2295
111
|
as: "div",
|
|
@@ -2298,7 +114,7 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2298
114
|
"aria-label": description || `Code block in ${language}`,
|
|
2299
115
|
...props
|
|
2300
116
|
},
|
|
2301
|
-
showCopyButton ? isCodeCopied ? /* @__PURE__ */ React
|
|
117
|
+
showCopyButton ? isCodeCopied ? /* @__PURE__ */ React.createElement(
|
|
2302
118
|
Badge,
|
|
2303
119
|
{
|
|
2304
120
|
className: "code-block-copied-badge",
|
|
@@ -2307,7 +123,7 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2307
123
|
"aria-live": "polite"
|
|
2308
124
|
},
|
|
2309
125
|
"Copied!"
|
|
2310
|
-
) : /* @__PURE__ */ React
|
|
126
|
+
) : /* @__PURE__ */ React.createElement(
|
|
2311
127
|
Button,
|
|
2312
128
|
{
|
|
2313
129
|
type: "button",
|
|
@@ -2320,7 +136,7 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2320
136
|
},
|
|
2321
137
|
"Copy"
|
|
2322
138
|
) : null,
|
|
2323
|
-
/* @__PURE__ */ React
|
|
139
|
+
/* @__PURE__ */ React.createElement(
|
|
2324
140
|
"pre",
|
|
2325
141
|
{
|
|
2326
142
|
ref,
|
|
@@ -2328,7 +144,7 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2328
144
|
tabIndex: 0,
|
|
2329
145
|
"aria-label": `Code in ${language}`
|
|
2330
146
|
},
|
|
2331
|
-
showLineNumbers && Array.from(Array(lines.length).keys()).map((index) => /* @__PURE__ */ React
|
|
147
|
+
showLineNumbers && Array.from(Array(lines.length).keys()).map((index) => /* @__PURE__ */ React.createElement(
|
|
2332
148
|
"span",
|
|
2333
149
|
{
|
|
2334
150
|
key: index,
|
|
@@ -2337,7 +153,7 @@ const CodeBlock = React$1.forwardRef(
|
|
|
2337
153
|
},
|
|
2338
154
|
index + 1
|
|
2339
155
|
)),
|
|
2340
|
-
|
|
156
|
+
withSyntaxHighlighting ? /* @__PURE__ */ React.createElement("code", { dangerouslySetInnerHTML: { __html: highlightedCode } }) : /* @__PURE__ */ React.createElement("code", null, code)
|
|
2341
157
|
)
|
|
2342
158
|
);
|
|
2343
159
|
}
|