wikiparser-node 1.3.7 → 1.3.8-b

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.
Files changed (153) hide show
  1. package/bundle/bundle.min.js +36 -0
  2. package/config/llwiki.json +1 -35
  3. package/config/moegirl.json +1 -44
  4. package/config/zhwiki.json +1 -466
  5. package/extensions/dist/base.js +64 -0
  6. package/extensions/dist/editor.js +159 -0
  7. package/extensions/dist/highlight.js +30 -0
  8. package/extensions/dist/lint.js +48 -0
  9. package/extensions/editor.css +63 -0
  10. package/extensions/ui.css +114 -0
  11. package/package.json +31 -13
  12. package/config/.schema.json +0 -172
  13. package/dist/addon/table.d.ts +0 -6
  14. package/dist/addon/table.js +0 -558
  15. package/dist/base.d.ts +0 -45
  16. package/dist/index.d.ts +0 -32
  17. package/dist/index.js +0 -209
  18. package/dist/internal.d.ts +0 -44
  19. package/dist/lib/element.d.ts +0 -154
  20. package/dist/lib/element.js +0 -630
  21. package/dist/lib/node.d.ts +0 -146
  22. package/dist/lib/node.js +0 -417
  23. package/dist/lib/range.d.ts +0 -104
  24. package/dist/lib/range.js +0 -385
  25. package/dist/lib/ranges.d.ts +0 -26
  26. package/dist/lib/ranges.js +0 -118
  27. package/dist/lib/text.d.ts +0 -62
  28. package/dist/lib/text.js +0 -255
  29. package/dist/lib/title.d.ts +0 -38
  30. package/dist/lib/title.js +0 -162
  31. package/dist/mixin/attributesParent.js +0 -89
  32. package/dist/mixin/fixed.js +0 -25
  33. package/dist/mixin/flagsParent.js +0 -70
  34. package/dist/mixin/hidden.js +0 -26
  35. package/dist/mixin/magicLinkParent.js +0 -41
  36. package/dist/mixin/singleLine.js +0 -25
  37. package/dist/mixin/sol.js +0 -43
  38. package/dist/mixin/syntax.js +0 -54
  39. package/dist/parser/braces.js +0 -128
  40. package/dist/parser/commentAndExt.js +0 -80
  41. package/dist/parser/converter.js +0 -40
  42. package/dist/parser/externalLinks.js +0 -28
  43. package/dist/parser/hrAndDoubleUnderscore.js +0 -38
  44. package/dist/parser/html.js +0 -36
  45. package/dist/parser/links.js +0 -94
  46. package/dist/parser/list.js +0 -66
  47. package/dist/parser/magicLinks.js +0 -40
  48. package/dist/parser/quotes.js +0 -67
  49. package/dist/parser/selector.js +0 -162
  50. package/dist/parser/table.js +0 -120
  51. package/dist/src/arg.d.ts +0 -56
  52. package/dist/src/arg.js +0 -187
  53. package/dist/src/atom.d.ts +0 -12
  54. package/dist/src/atom.js +0 -27
  55. package/dist/src/attribute.d.ts +0 -88
  56. package/dist/src/attribute.js +0 -398
  57. package/dist/src/attributes.d.ts +0 -109
  58. package/dist/src/attributes.js +0 -343
  59. package/dist/src/converter.d.ts +0 -53
  60. package/dist/src/converter.js +0 -79
  61. package/dist/src/converterFlags.d.ts +0 -87
  62. package/dist/src/converterFlags.js +0 -224
  63. package/dist/src/converterRule.d.ts +0 -77
  64. package/dist/src/converterRule.js +0 -208
  65. package/dist/src/extLink.d.ts +0 -55
  66. package/dist/src/extLink.js +0 -122
  67. package/dist/src/gallery.d.ts +0 -54
  68. package/dist/src/gallery.js +0 -121
  69. package/dist/src/heading.d.ts +0 -76
  70. package/dist/src/heading.js +0 -127
  71. package/dist/src/hidden.d.ts +0 -23
  72. package/dist/src/hidden.js +0 -23
  73. package/dist/src/html.d.ts +0 -104
  74. package/dist/src/html.js +0 -226
  75. package/dist/src/imageParameter.d.ts +0 -65
  76. package/dist/src/imageParameter.js +0 -245
  77. package/dist/src/imagemap.d.ts +0 -56
  78. package/dist/src/imagemap.js +0 -147
  79. package/dist/src/imagemapLink.d.ts +0 -61
  80. package/dist/src/imagemapLink.js +0 -40
  81. package/dist/src/index.d.ts +0 -140
  82. package/dist/src/index.js +0 -769
  83. package/dist/src/link/base.d.ts +0 -52
  84. package/dist/src/link/base.js +0 -209
  85. package/dist/src/link/category.d.ts +0 -13
  86. package/dist/src/link/category.js +0 -29
  87. package/dist/src/link/file.d.ts +0 -96
  88. package/dist/src/link/file.js +0 -257
  89. package/dist/src/link/galleryImage.d.ts +0 -45
  90. package/dist/src/link/galleryImage.js +0 -106
  91. package/dist/src/link/index.d.ts +0 -53
  92. package/dist/src/link/index.js +0 -124
  93. package/dist/src/magicLink.d.ts +0 -69
  94. package/dist/src/magicLink.js +0 -147
  95. package/dist/src/nested.d.ts +0 -43
  96. package/dist/src/nested.js +0 -86
  97. package/dist/src/nowiki/base.d.ts +0 -48
  98. package/dist/src/nowiki/base.js +0 -42
  99. package/dist/src/nowiki/comment.d.ts +0 -41
  100. package/dist/src/nowiki/comment.js +0 -67
  101. package/dist/src/nowiki/dd.d.ts +0 -8
  102. package/dist/src/nowiki/dd.js +0 -25
  103. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -47
  104. package/dist/src/nowiki/doubleUnderscore.js +0 -50
  105. package/dist/src/nowiki/hr.d.ts +0 -33
  106. package/dist/src/nowiki/hr.js +0 -14
  107. package/dist/src/nowiki/index.d.ts +0 -16
  108. package/dist/src/nowiki/index.js +0 -21
  109. package/dist/src/nowiki/list.d.ts +0 -31
  110. package/dist/src/nowiki/list.js +0 -48
  111. package/dist/src/nowiki/listBase.d.ts +0 -20
  112. package/dist/src/nowiki/listBase.js +0 -12
  113. package/dist/src/nowiki/noinclude.d.ts +0 -26
  114. package/dist/src/nowiki/noinclude.js +0 -24
  115. package/dist/src/nowiki/quote.d.ts +0 -24
  116. package/dist/src/nowiki/quote.js +0 -45
  117. package/dist/src/onlyinclude.d.ts +0 -16
  118. package/dist/src/onlyinclude.js +0 -57
  119. package/dist/src/paramTag/index.d.ts +0 -37
  120. package/dist/src/paramTag/index.js +0 -68
  121. package/dist/src/paramTag/inputbox.d.ts +0 -8
  122. package/dist/src/paramTag/inputbox.js +0 -23
  123. package/dist/src/parameter.d.ts +0 -86
  124. package/dist/src/parameter.js +0 -205
  125. package/dist/src/pre.d.ts +0 -28
  126. package/dist/src/pre.js +0 -51
  127. package/dist/src/syntax.d.ts +0 -30
  128. package/dist/src/syntax.js +0 -34
  129. package/dist/src/table/base.d.ts +0 -59
  130. package/dist/src/table/base.js +0 -78
  131. package/dist/src/table/index.d.ts +0 -228
  132. package/dist/src/table/index.js +0 -379
  133. package/dist/src/table/td.d.ts +0 -107
  134. package/dist/src/table/td.js +0 -263
  135. package/dist/src/table/tr.d.ts +0 -32
  136. package/dist/src/table/tr.js +0 -56
  137. package/dist/src/table/trBase.d.ts +0 -53
  138. package/dist/src/table/trBase.js +0 -153
  139. package/dist/src/tagPair/ext.d.ts +0 -58
  140. package/dist/src/tagPair/ext.js +0 -140
  141. package/dist/src/tagPair/include.d.ts +0 -54
  142. package/dist/src/tagPair/include.js +0 -63
  143. package/dist/src/tagPair/index.d.ts +0 -49
  144. package/dist/src/tagPair/index.js +0 -93
  145. package/dist/src/transclude.d.ts +0 -167
  146. package/dist/src/transclude.js +0 -698
  147. package/dist/util/constants.js +0 -113
  148. package/dist/util/debug.js +0 -83
  149. package/dist/util/diff.js +0 -72
  150. package/dist/util/lint.js +0 -30
  151. package/dist/util/string.js +0 -51
  152. package/errors/README +0 -1
  153. package/printed/README +0 -1
@@ -1,398 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AttributeToken = void 0;
4
- const lint_1 = require("../util/lint");
5
- const string_1 = require("../util/string");
6
- const debug_1 = require("../util/debug");
7
- const constants_1 = require("../util/constants");
8
- const fixed_1 = require("../mixin/fixed");
9
- const Parser = require("../index");
10
- const index_1 = require("./index");
11
- const atom_1 = require("./atom");
12
- const stages = { 'ext-attr': 0, 'html-attr': 2, 'table-attr': 3 };
13
- const commonHtmlAttrs = new Set([
14
- 'id',
15
- 'class',
16
- 'style',
17
- 'lang',
18
- 'dir',
19
- 'title',
20
- 'tabindex',
21
- 'aria-describedby',
22
- 'aria-flowto',
23
- 'aria-hidden',
24
- 'aria-label',
25
- 'aria-labelledby',
26
- 'aria-owns',
27
- 'role',
28
- 'about',
29
- 'property',
30
- 'resource',
31
- 'datatype',
32
- 'typeof',
33
- 'itemid',
34
- 'itemprop',
35
- 'itemref',
36
- 'itemscope',
37
- 'itemtype',
38
- ]), blockAttrs = new Set(['align']), citeAttrs = new Set(['cite']), citeAndAttrs = new Set(['cite', 'datetime']), widthAttrs = new Set(['width']), tdAttrs = new Set(['align', 'valign', 'abbr', 'axis', 'headers', 'scope', 'rowspan', 'colspan', 'width', 'height', 'bgcolor']), typeAttrs = new Set(['type']), htmlAttrs = {
39
- div: blockAttrs,
40
- h1: blockAttrs,
41
- h2: blockAttrs,
42
- h3: blockAttrs,
43
- h4: blockAttrs,
44
- h5: blockAttrs,
45
- h6: blockAttrs,
46
- blockquote: citeAttrs,
47
- q: citeAttrs,
48
- p: blockAttrs,
49
- br: new Set(['clear']),
50
- pre: widthAttrs,
51
- ins: citeAndAttrs,
52
- del: citeAndAttrs,
53
- ul: typeAttrs,
54
- ol: new Set(['type', 'start', 'reversed']),
55
- li: new Set(['type', 'value']),
56
- table: new Set(['summary', 'width', 'border', 'frame', 'rules', 'cellspacing', 'cellpadding', 'align', 'bgcolor']),
57
- caption: blockAttrs,
58
- tr: new Set(['bgcolor', 'align', 'valign']),
59
- td: tdAttrs,
60
- th: tdAttrs,
61
- img: new Set(['alt', 'src', 'width', 'height', 'srcset']),
62
- font: new Set(['size', 'color', 'face']),
63
- hr: widthAttrs,
64
- rt: new Set(['rbspan']),
65
- data: new Set(['value']),
66
- time: new Set(['datetime']),
67
- meta: new Set(['itemprop', 'content']),
68
- link: new Set(['itemprop', 'href', 'title']),
69
- gallery: new Set(['mode', 'showfilename', 'caption', 'perrow', 'widths', 'heights', 'showthumbnails', 'type']),
70
- poem: new Set(['compact', 'align']),
71
- categorytree: new Set([
72
- 'align',
73
- 'hideroot',
74
- 'onlyroot',
75
- 'depth',
76
- 'mode',
77
- 'hideprefix',
78
- 'namespaces',
79
- 'showcount',
80
- 'notranslations',
81
- ]),
82
- combooption: new Set(['name', 'for', 'inline', 'align']),
83
- }, empty = new Set(), extAttrs = {
84
- nowiki: empty,
85
- indicator: new Set(['name']),
86
- langconvert: new Set(['from', 'to']),
87
- ref: new Set(['group', 'name', 'extends', 'follow', 'dir']),
88
- references: new Set(['group', 'responsive']),
89
- charinsert: new Set(['label']),
90
- choose: new Set(['uncached', 'before', 'after']),
91
- option: new Set(['weight']),
92
- imagemap: empty,
93
- inputbox: empty,
94
- templatestyles: new Set(['src', 'wrapper']),
95
- dynamicpagelist: empty,
96
- poll: new Set(['id', 'show-results-before-voting']),
97
- sm2: typeAttrs,
98
- flashmp3: typeAttrs,
99
- score: new Set([
100
- 'line_width_inches',
101
- 'lang',
102
- 'override_midi',
103
- 'raw',
104
- 'note-language',
105
- 'override_audio',
106
- 'override_ogg',
107
- 'sound',
108
- 'vorbis',
109
- ]),
110
- seo: new Set([
111
- 'title',
112
- 'title_mode',
113
- 'title_separator',
114
- 'keywords',
115
- 'description',
116
- 'robots',
117
- 'google_bot',
118
- 'image',
119
- 'image_width',
120
- 'image_height',
121
- 'image_alt',
122
- 'type',
123
- 'site_name',
124
- 'locale',
125
- 'section',
126
- 'author',
127
- 'published_time',
128
- 'twitter_site',
129
- ]),
130
- tab: new Set([
131
- 'nested',
132
- 'name',
133
- 'index',
134
- 'class',
135
- 'block',
136
- 'inline',
137
- 'openname',
138
- 'closename',
139
- 'collapsed',
140
- 'dropdown',
141
- 'style',
142
- 'bgcolor',
143
- 'container',
144
- 'id',
145
- 'title',
146
- ]),
147
- tabs: new Set(['plain', 'class', 'container', 'id', 'title', 'style']),
148
- combobox: new Set(['placeholder', 'value', 'id', 'class', 'text', 'dropdown', 'style']),
149
- }, insecureStyle = new RegExp('expression'
150
- + '|'
151
- + '(?:filter|accelerator|-o-link(?:-source)?|-o-replace)\\s*:'
152
- + '|'
153
- + '(?:url|image(?:-set)?)\\s*\\('
154
- + '|'
155
- + 'attr\\s*\\([^)]+[\\s,]url', 'u');
156
- /**
157
- * 扩展和HTML标签属性
158
- * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
159
- */
160
- class AttributeToken extends (0, fixed_1.fixed)(index_1.Token) {
161
- #equal;
162
- #quotes;
163
- /** 引号是否匹配 */
164
- get balanced() {
165
- return !this.#equal || this.#quotes[0] === this.#quotes[1];
166
- }
167
- /* NOT FOR BROWSER */
168
- set balanced(value) {
169
- if (value) {
170
- this.close();
171
- }
172
- }
173
- /** getValue()的getter */
174
- get value() {
175
- return this.getValue();
176
- }
177
- set value(value) {
178
- this.setValue(value);
179
- }
180
- /* NOT FOR BROWSER END */
181
- /**
182
- * @param type 标签类型
183
- * @param tag 标签名
184
- * @param key 属性名
185
- * @param equal 等号
186
- * @param value 属性值
187
- * @param quotes 引号
188
- */
189
- constructor(type, tag, key, equal = '', value, quotes = [], config = Parser.getConfig(), accum = []) {
190
- const keyToken = new atom_1.AtomToken(key, 'attr-key', config, accum, {
191
- [type === 'ext-attr' ? 'AstText' : 'Stage-1']: ':', ArgToken: ':', TranscludeToken: ':',
192
- });
193
- let valueToken;
194
- if (key === 'title' || tag === 'img' && key === 'alt') {
195
- valueToken = new index_1.Token(value, config, accum, {
196
- [`Stage-${stages[type]}`]: ':', ConverterToken: ':',
197
- });
198
- valueToken.type = 'attr-value';
199
- valueToken.setAttribute('stage', constants_1.MAX_STAGE - 1);
200
- }
201
- else if (tag === 'gallery' && key === 'caption') {
202
- const newConfig = {
203
- ...config,
204
- excludes: [...config.excludes, 'quote', 'extLink', 'magicLink', 'list'],
205
- };
206
- valueToken = new index_1.Token(value, newConfig, accum, {
207
- AstText: ':', LinkToken: ':', FileToken: ':', CategoryToken: ':', ConverterToken: ':',
208
- });
209
- valueToken.type = 'attr-value';
210
- valueToken.setAttribute('stage', 5);
211
- }
212
- else if (tag === 'choose' && (key === 'before' || key === 'after')) {
213
- const newConfig = {
214
- ...config,
215
- excludes: [...config.excludes, 'heading', 'html', 'table', 'hr', 'list'],
216
- };
217
- valueToken = new index_1.Token(value, newConfig, accum, {
218
- ArgToken: ':',
219
- TranscludeToken: ':',
220
- LinkToken: ':',
221
- FileToken: ':',
222
- CategoryToken: ':',
223
- QuoteToken: ':',
224
- ExtLinkToken: ':',
225
- MagicLinkToken: ':',
226
- ConverterToken: ':',
227
- });
228
- valueToken.type = 'attr-value';
229
- valueToken.setAttribute('stage', 1);
230
- }
231
- else {
232
- valueToken = new atom_1.AtomToken(value, 'attr-value', config, accum, {
233
- [`Stage-${stages[type]}`]: ':',
234
- });
235
- }
236
- super(undefined, config, accum);
237
- this.type = type;
238
- this.append(keyToken, valueToken);
239
- this.#equal = equal;
240
- this.#quotes = [...quotes];
241
- this.tag = tag;
242
- this.seal('tag');
243
- this.setAttribute('name', (0, string_1.removeComment)(key).trim().toLowerCase());
244
- }
245
- /** @private */
246
- afterBuild() {
247
- if (this.#equal.includes('\0')) {
248
- this.#equal = this.buildFromStr(this.#equal, constants_1.BuildMethod.String);
249
- }
250
- if (this.parentNode) {
251
- this.setAttribute('tag', this.parentNode.name);
252
- }
253
- this.setAttribute('name', this.firstChild.text().trim().toLowerCase());
254
- }
255
- /** @private */
256
- toString(omit) {
257
- if (omit && this.matchesTypes(omit)) {
258
- return '';
259
- }
260
- const [quoteStart = '', quoteEnd = ''] = this.#quotes;
261
- return this.#equal
262
- ? `${super.toString(omit, `${this.#equal}${quoteStart}`)}${quoteEnd}`
263
- : this.firstChild.toString(omit);
264
- }
265
- /** @override */
266
- text() {
267
- return this.#equal ? `${super.text(`${this.#equal.trim()}"`)}"` : this.firstChild.text();
268
- }
269
- /** @private */
270
- getGaps() {
271
- return this.#equal ? this.#equal.length + (this.#quotes[0]?.length ?? 0) : 0;
272
- }
273
- /** @override */
274
- lint(start = this.getAbsoluteIndex()) {
275
- const errors = super.lint(start), { balanced, firstChild, lastChild, type, name, tag } = this, value = this.getValue();
276
- let rect;
277
- if (!balanced) {
278
- const root = this.getRootNode();
279
- rect = { start, ...root.posFromIndex(start) };
280
- const e = (0, lint_1.generateForChild)(lastChild, rect, Parser.msg('unclosed $1', 'quotes'), 'warning');
281
- errors.push({
282
- ...e,
283
- startIndex: e.startIndex - 1,
284
- startCol: e.startCol - 1,
285
- });
286
- }
287
- if (extAttrs[tag] && !extAttrs[tag].has(name)
288
- || (type === 'ext-attr' ? tag in htmlAttrs : !/\{\{[^{]+\}\}/u.test(name))
289
- && !htmlAttrs[tag]?.has(name)
290
- && !/^(?:xmlns:[\w:.-]+|data-[^:]*)$/u.test(name)
291
- && (tag === 'meta' || tag === 'link' || !commonHtmlAttrs.has(name))) {
292
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
293
- errors.push((0, lint_1.generateForChild)(firstChild, rect, 'illegal attribute name'));
294
- }
295
- else if (name === 'style' && typeof value === 'string' && insecureStyle.test(value)) {
296
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
297
- errors.push((0, lint_1.generateForChild)(lastChild, rect, 'insecure style'));
298
- }
299
- else if (name === 'tabindex' && typeof value === 'string' && value.trim() !== '0') {
300
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
301
- errors.push((0, lint_1.generateForChild)(lastChild, rect, 'nonzero tabindex'));
302
- }
303
- return errors;
304
- }
305
- /** 获取属性值 */
306
- getValue() {
307
- if (this.#equal) {
308
- const value = this.lastChild.text();
309
- if (this.#quotes[1]) {
310
- return value;
311
- }
312
- return value[this.#quotes[0] ? 'trimEnd' : 'trim']();
313
- }
314
- return this.type === 'ext-attr' || '';
315
- }
316
- /** @override */
317
- print() {
318
- const [quoteStart = '', quoteEnd = ''] = this.#quotes;
319
- return this.#equal ? super.print({ sep: `${this.#equal}${quoteStart}`, post: quoteEnd }) : super.print();
320
- }
321
- /* NOT FOR BROWSER */
322
- /** @private */
323
- getAttribute(key) {
324
- if (key === 'equal') {
325
- return this.#equal;
326
- }
327
- return key === 'quotes' ? this.#quotes : super.getAttribute(key);
328
- }
329
- /** @override */
330
- cloneNode() {
331
- const [key, value] = this.cloneChildNodes(), config = this.getAttribute('config');
332
- return debug_1.Shadow.run(() => {
333
- const token = new AttributeToken(this.type, this.tag, '', this.#equal, '', this.#quotes, config);
334
- token.firstChild.safeReplaceWith(key);
335
- token.lastChild.safeReplaceWith(value);
336
- token.setAttribute('name', this.name);
337
- return token;
338
- });
339
- }
340
- /** 转义等号 */
341
- escape() {
342
- this.#equal = '{{=}}';
343
- }
344
- /** 闭合引号 */
345
- close() {
346
- const [opening] = this.#quotes;
347
- if (opening) {
348
- this.#quotes[1] = opening;
349
- }
350
- }
351
- /**
352
- * 设置属性值
353
- * @param value 参数值
354
- * @throws `RangeError` 扩展标签属性不能包含 ">"
355
- * @throws `RangeError` 同时包含单引号和双引号
356
- */
357
- setValue(value) {
358
- if (value === false) {
359
- this.remove();
360
- return;
361
- }
362
- else if (value === true) {
363
- this.#equal = '';
364
- return;
365
- }
366
- else if (this.type === 'ext-attr' && value.includes('>')) {
367
- throw new RangeError('扩展标签属性不能包含 ">"!');
368
- }
369
- else if (value.includes('"') && value.includes(`'`)) {
370
- throw new RangeError('属性值不能同时包含单引号和双引号!');
371
- }
372
- const config = this.getAttribute('config'), { childNodes } = Parser.parse(value, this.getAttribute('include'), stages[this.type] + 1, config);
373
- this.lastChild.replaceChildren(...childNodes);
374
- if (value.includes('"')) {
375
- this.#quotes = [`'`, `'`];
376
- }
377
- else if (value.includes(`'`) || !this.#quotes[0]) {
378
- this.#quotes = ['"', '"'];
379
- }
380
- else {
381
- this.close();
382
- }
383
- }
384
- /**
385
- * 修改属性名
386
- * @param key 新属性名
387
- * @throws `Error` title和alt属性不能更名
388
- */
389
- rename(key) {
390
- if (this.name === 'title' || this.name === 'alt' && this.tag === 'img') {
391
- throw new Error(`${this.name} 属性不能更名!`);
392
- }
393
- const config = this.getAttribute('config'), { childNodes } = Parser.parse(key, this.getAttribute('include'), stages[this.type] + 1, config);
394
- this.firstChild.replaceChildren(...childNodes);
395
- }
396
- }
397
- exports.AttributeToken = AttributeToken;
398
- constants_1.classes['AttributeToken'] = __filename;
@@ -1,109 +0,0 @@
1
- import * as Parser from '../index';
2
- import { Token } from './index';
3
- import { AtomToken } from './atom';
4
- import { AttributeToken } from './attribute';
5
- import type { LintError } from '../base';
6
- import type { ExtToken, HtmlToken, TdToken, TrToken, TableToken } from '../internal';
7
- import type { AttributeTypes } from './attribute';
8
- declare type AttributesTypes = `${AttributeTypes}s`;
9
- /**
10
- * 扩展和HTML标签属性
11
- * @classdesc `{childNodes: ...AtomToken|AttributeToken}`
12
- */
13
- export declare class AttributesToken extends Token {
14
- #private;
15
- type: AttributesTypes;
16
- readonly name: string;
17
- readonly childNodes: (AtomToken | AttributeToken)[];
18
- abstract get children(): (AtomToken | AttributeToken)[];
19
- abstract get firstChild(): AtomToken | AttributeToken | undefined;
20
- abstract get firstElementChild(): AtomToken | AttributeToken | undefined;
21
- abstract get lastChild(): AtomToken | AttributeToken | undefined;
22
- abstract get lastElementChild(): AtomToken | AttributeToken | undefined;
23
- abstract get parentNode(): ExtToken | HtmlToken | TableToken | TrToken | TdToken | undefined;
24
- abstract get parentElement(): ExtToken | HtmlToken | TableToken | TrToken | TdToken | undefined;
25
- /** getAttrs()方法的getter写法 */
26
- get attributes(): Record<string, string | true>;
27
- set attributes(attrs: Record<string, string | true>);
28
- /** 以字符串表示的class属性 */
29
- get className(): string;
30
- set className(className: string);
31
- /** 以Set表示的class属性 */
32
- get classList(): Set<string>;
33
- set classList(classList: Set<string>);
34
- /** id属性 */
35
- get id(): string;
36
- set id(id: string);
37
- /** 是否含有无效属性 */
38
- get sanitized(): boolean;
39
- set sanitized(sanitized: boolean);
40
- /**
41
- * @param attr 标签属性
42
- * @param type 标签类型
43
- * @param name 标签名
44
- */
45
- constructor(attr: string | undefined, type: AttributesTypes, name: string, config?: Parser.Config, accum?: Token[]);
46
- /**
47
- * 所有指定属性名的AttributeToken
48
- * @param key 属性名
49
- */
50
- getAttrTokens(key?: string): readonly AttributeToken[];
51
- /**
52
- * 指定属性名的最后一个AttributeToken
53
- * @param key 属性名
54
- */
55
- getAttrToken(key: string): AttributeToken | undefined;
56
- /**
57
- * 获取指定属性
58
- * @param key 属性键
59
- */
60
- getAttr(key: string): string | true | undefined;
61
- /** @override */
62
- lint(start?: number): LintError[];
63
- /** @override */
64
- print(): string;
65
- /** 清理无效属性 */
66
- sanitize(): void;
67
- /** @override */
68
- cloneNode(): this;
69
- /**
70
- * @override
71
- * @param token 待插入的子节点
72
- * @param i 插入位置
73
- * @throws `RangeError` 标签不匹配
74
- */
75
- insertAt<T extends AttributeToken | AtomToken>(token: T, i?: number): T;
76
- /**
77
- * 设置指定属性
78
- * @param key 属性键
79
- * @param value 属性值
80
- * @param prop 属性对象
81
- * @throws `RangeError` 扩展标签属性不能包含">"
82
- */
83
- setAttr(key: string, value: string | boolean): void;
84
- setAttr(prop: Record<string, string | boolean>): void;
85
- /**
86
- * 标签是否具有某属性
87
- * @param key 属性键
88
- */
89
- hasAttr(key: string): boolean;
90
- /** 获取全部的属性名 */
91
- getAttrNames(): Set<string>;
92
- /** 获取全部属性 */
93
- getAttrs(): Record<string, string | true>;
94
- /**
95
- * 移除指定属性
96
- * @param key 属性键
97
- */
98
- removeAttr(key: string): void;
99
- /**
100
- * 开关指定属性
101
- * @param key 属性键
102
- * @param force 强制开启或关闭
103
- * @throws `RangeError` 不为Boolean类型的属性值
104
- */
105
- toggleAttr(key: string, force?: boolean): void;
106
- /** @override */
107
- text(): string;
108
- }
109
- export {};