wikiparser-node 1.10.0 → 1.11.0-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 (173) hide show
  1. package/bundle/bundle.min.js +38 -0
  2. package/config/enwiki.json +1 -814
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +64 -0
  7. package/extensions/dist/editor.js +159 -0
  8. package/extensions/dist/highlight.js +56 -0
  9. package/extensions/dist/lint.js +72 -0
  10. package/extensions/editor.css +64 -0
  11. package/extensions/ui.css +144 -0
  12. package/i18n/zh-hans.json +1 -1
  13. package/i18n/zh-hant.json +1 -1
  14. package/package.json +43 -33
  15. package/config/.schema.json +0 -186
  16. package/dist/addon/table.js +0 -486
  17. package/dist/addon/token.js +0 -324
  18. package/dist/addon/transclude.js +0 -185
  19. package/dist/base.d.ts +0 -81
  20. package/dist/base.js +0 -39
  21. package/dist/index.d.ts +0 -33
  22. package/dist/index.js +0 -231
  23. package/dist/internal.d.ts +0 -46
  24. package/dist/lib/element.d.ts +0 -125
  25. package/dist/lib/element.js +0 -374
  26. package/dist/lib/node.d.ts +0 -173
  27. package/dist/lib/node.js +0 -478
  28. package/dist/lib/range.d.ts +0 -105
  29. package/dist/lib/range.js +0 -406
  30. package/dist/lib/ranges.d.ts +0 -28
  31. package/dist/lib/ranges.js +0 -126
  32. package/dist/lib/rect.d.ts +0 -18
  33. package/dist/lib/rect.js +0 -34
  34. package/dist/lib/text.d.ts +0 -58
  35. package/dist/lib/text.js +0 -361
  36. package/dist/lib/title.d.ts +0 -42
  37. package/dist/lib/title.js +0 -205
  38. package/dist/mixin/attributesParent.d.ts +0 -49
  39. package/dist/mixin/attributesParent.js +0 -79
  40. package/dist/mixin/fixed.d.ts +0 -5
  41. package/dist/mixin/fixed.js +0 -32
  42. package/dist/mixin/flagsParent.d.ts +0 -41
  43. package/dist/mixin/flagsParent.js +0 -60
  44. package/dist/mixin/hidden.d.ts +0 -7
  45. package/dist/mixin/hidden.js +0 -37
  46. package/dist/mixin/magicLinkParent.d.ts +0 -19
  47. package/dist/mixin/magicLinkParent.js +0 -43
  48. package/dist/mixin/singleLine.d.ts +0 -5
  49. package/dist/mixin/singleLine.js +0 -25
  50. package/dist/mixin/sol.d.ts +0 -6
  51. package/dist/mixin/sol.js +0 -44
  52. package/dist/mixin/syntax.d.ts +0 -8
  53. package/dist/mixin/syntax.js +0 -46
  54. package/dist/parser/braces.js +0 -150
  55. package/dist/parser/commentAndExt.js +0 -79
  56. package/dist/parser/converter.js +0 -39
  57. package/dist/parser/externalLinks.js +0 -37
  58. package/dist/parser/hrAndDoubleUnderscore.js +0 -42
  59. package/dist/parser/html.js +0 -38
  60. package/dist/parser/links.js +0 -101
  61. package/dist/parser/list.js +0 -99
  62. package/dist/parser/magicLinks.js +0 -53
  63. package/dist/parser/quotes.js +0 -67
  64. package/dist/parser/redirect.js +0 -26
  65. package/dist/parser/selector.js +0 -394
  66. package/dist/parser/table.js +0 -123
  67. package/dist/src/arg.d.ts +0 -51
  68. package/dist/src/arg.js +0 -214
  69. package/dist/src/atom.d.ts +0 -14
  70. package/dist/src/atom.js +0 -52
  71. package/dist/src/attribute.d.ts +0 -64
  72. package/dist/src/attribute.js +0 -483
  73. package/dist/src/attributes.d.ts +0 -101
  74. package/dist/src/attributes.js +0 -382
  75. package/dist/src/converter.d.ts +0 -28
  76. package/dist/src/converter.js +0 -147
  77. package/dist/src/converterFlags.d.ts +0 -80
  78. package/dist/src/converterFlags.js +0 -242
  79. package/dist/src/converterRule.d.ts +0 -71
  80. package/dist/src/converterRule.js +0 -216
  81. package/dist/src/extLink.d.ts +0 -36
  82. package/dist/src/extLink.js +0 -198
  83. package/dist/src/gallery.d.ts +0 -47
  84. package/dist/src/gallery.js +0 -142
  85. package/dist/src/heading.d.ts +0 -40
  86. package/dist/src/heading.js +0 -191
  87. package/dist/src/hidden.d.ts +0 -9
  88. package/dist/src/hidden.js +0 -80
  89. package/dist/src/html.d.ts +0 -57
  90. package/dist/src/html.js +0 -343
  91. package/dist/src/imageParameter.d.ts +0 -58
  92. package/dist/src/imageParameter.js +0 -247
  93. package/dist/src/imagemap.d.ts +0 -47
  94. package/dist/src/imagemap.js +0 -146
  95. package/dist/src/imagemapLink.d.ts +0 -31
  96. package/dist/src/imagemapLink.js +0 -97
  97. package/dist/src/index.d.ts +0 -141
  98. package/dist/src/index.js +0 -795
  99. package/dist/src/link/base.d.ts +0 -54
  100. package/dist/src/link/base.js +0 -263
  101. package/dist/src/link/category.d.ts +0 -22
  102. package/dist/src/link/category.js +0 -34
  103. package/dist/src/link/file.d.ts +0 -96
  104. package/dist/src/link/file.js +0 -276
  105. package/dist/src/link/galleryImage.d.ts +0 -29
  106. package/dist/src/link/galleryImage.js +0 -132
  107. package/dist/src/link/index.d.ts +0 -39
  108. package/dist/src/link/index.js +0 -99
  109. package/dist/src/link/redirectTarget.d.ts +0 -27
  110. package/dist/src/link/redirectTarget.js +0 -72
  111. package/dist/src/magicLink.d.ts +0 -61
  112. package/dist/src/magicLink.js +0 -261
  113. package/dist/src/nested.d.ts +0 -40
  114. package/dist/src/nested.js +0 -106
  115. package/dist/src/nowiki/base.d.ts +0 -30
  116. package/dist/src/nowiki/base.js +0 -89
  117. package/dist/src/nowiki/comment.d.ts +0 -14
  118. package/dist/src/nowiki/comment.js +0 -124
  119. package/dist/src/nowiki/dd.d.ts +0 -8
  120. package/dist/src/nowiki/dd.js +0 -72
  121. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  122. package/dist/src/nowiki/doubleUnderscore.js +0 -97
  123. package/dist/src/nowiki/hr.d.ts +0 -5
  124. package/dist/src/nowiki/hr.js +0 -70
  125. package/dist/src/nowiki/index.d.ts +0 -14
  126. package/dist/src/nowiki/index.js +0 -31
  127. package/dist/src/nowiki/list.d.ts +0 -5
  128. package/dist/src/nowiki/list.js +0 -65
  129. package/dist/src/nowiki/listBase.d.ts +0 -17
  130. package/dist/src/nowiki/listBase.js +0 -75
  131. package/dist/src/nowiki/noinclude.d.ts +0 -6
  132. package/dist/src/nowiki/noinclude.js +0 -75
  133. package/dist/src/nowiki/quote.d.ts +0 -14
  134. package/dist/src/nowiki/quote.js +0 -135
  135. package/dist/src/onlyinclude.d.ts +0 -13
  136. package/dist/src/onlyinclude.js +0 -58
  137. package/dist/src/paramTag/index.d.ts +0 -30
  138. package/dist/src/paramTag/index.js +0 -78
  139. package/dist/src/paramTag/inputbox.d.ts +0 -8
  140. package/dist/src/paramTag/inputbox.js +0 -22
  141. package/dist/src/parameter.d.ts +0 -60
  142. package/dist/src/parameter.js +0 -268
  143. package/dist/src/pre.d.ts +0 -28
  144. package/dist/src/pre.js +0 -60
  145. package/dist/src/redirect.d.ts +0 -30
  146. package/dist/src/redirect.js +0 -126
  147. package/dist/src/syntax.d.ts +0 -17
  148. package/dist/src/syntax.js +0 -87
  149. package/dist/src/table/base.d.ts +0 -28
  150. package/dist/src/table/base.js +0 -81
  151. package/dist/src/table/index.d.ts +0 -230
  152. package/dist/src/table/index.js +0 -505
  153. package/dist/src/table/td.d.ts +0 -72
  154. package/dist/src/table/td.js +0 -370
  155. package/dist/src/table/tr.d.ts +0 -30
  156. package/dist/src/table/tr.js +0 -59
  157. package/dist/src/table/trBase.d.ts +0 -49
  158. package/dist/src/table/trBase.js +0 -164
  159. package/dist/src/tagPair/ext.d.ts +0 -29
  160. package/dist/src/tagPair/ext.js +0 -220
  161. package/dist/src/tagPair/include.d.ts +0 -33
  162. package/dist/src/tagPair/include.js +0 -130
  163. package/dist/src/tagPair/index.d.ts +0 -23
  164. package/dist/src/tagPair/index.js +0 -128
  165. package/dist/src/transclude.d.ts +0 -159
  166. package/dist/src/transclude.js +0 -587
  167. package/dist/util/constants.js +0 -25
  168. package/dist/util/debug.js +0 -95
  169. package/dist/util/diff.js +0 -83
  170. package/dist/util/lint.js +0 -32
  171. package/dist/util/string.js +0 -84
  172. package/errors/README +0 -3
  173. package/printed/README +0 -3
@@ -1,54 +0,0 @@
1
- import Parser from '../../index';
2
- import { Token } from '../index';
3
- import { AtomToken } from '../atom';
4
- import type { LintError } from '../../base';
5
- import type { Title } from '../../lib/title';
6
- /**
7
- * 内链
8
- * @classdesc `{childNodes: [AtomToken, ...Token]}`
9
- */
10
- export declare abstract class LinkBaseToken extends Token {
11
- #private;
12
- readonly name: string;
13
- abstract get type(): 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'redirect-target';
14
- readonly childNodes: readonly [AtomToken, ...Token[]];
15
- abstract get firstChild(): AtomToken;
16
- abstract get lastChild(): Token;
17
- abstract get children(): [AtomToken, ...Token[]];
18
- abstract get firstElementChild(): AtomToken;
19
- abstract get lastElementChild(): Token;
20
- /** 完整链接 */
21
- get link(): string | Title;
22
- set link(link: string);
23
- /** fragment */
24
- get fragment(): string | undefined;
25
- set fragment(fragment: string | undefined);
26
- /** interwiki */
27
- get interwiki(): string;
28
- /** @throws `RangeError` 非法的跨维基前缀 */
29
- set interwiki(interwiki: string);
30
- /**
31
- * @param link 链接标题
32
- * @param linkText 链接显示文字
33
- * @param delimiter `|`
34
- */
35
- constructor(link: string, linkText?: string, config?: Parser.Config, accum?: Token[], delimiter?: string);
36
- cloneNode(this: this & {
37
- constructor: new (...args: any[]) => unknown;
38
- }): this;
39
- /**
40
- * 设置链接目标
41
- * @param link 链接目标
42
- */
43
- setTarget(link: string): void;
44
- /**
45
- * 设置fragment
46
- * @param fragment fragment
47
- */
48
- setFragment(fragment?: string): void;
49
- /**
50
- * 设置链接显示文字
51
- * @param linkStr 链接显示文字
52
- */
53
- setLinkText(linkStr?: string): void;
54
- }
@@ -1,263 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LinkBaseToken = void 0;
4
- const lint_1 = require("../../util/lint");
5
- const constants_1 = require("../../util/constants");
6
- const debug_1 = require("../../util/debug");
7
- const string_1 = require("../../util/string");
8
- const rect_1 = require("../../lib/rect");
9
- const index_1 = require("../../index");
10
- const index_2 = require("../index");
11
- const atom_1 = require("../atom");
12
- /**
13
- * 是否为普通内链
14
- * @param type 节点类型
15
- */
16
- const isLink = (type) => type === 'redirect-target' || type === 'link';
17
- /* NOT FOR BROWSER */
18
- const fileTypes = new Set(['file', 'gallery-image', 'imagemap-image']);
19
- /* NOT FOR BROWSER END */
20
- /**
21
- * 内链
22
- * @classdesc `{childNodes: [AtomToken, ...Token]}`
23
- */
24
- class LinkBaseToken extends index_2.Token {
25
- #bracket = true;
26
- #delimiter;
27
- #title;
28
- /** 完整链接 */
29
- get link() {
30
- return this.#title;
31
- }
32
- set link(link) {
33
- this.setTarget(link);
34
- }
35
- /** fragment */
36
- get fragment() {
37
- return this.#title.fragment;
38
- }
39
- set fragment(fragment) {
40
- this.setFragment(fragment);
41
- }
42
- /** interwiki */
43
- get interwiki() {
44
- return this.#title.interwiki;
45
- }
46
- /** @throws `RangeError` 非法的跨维基前缀 */
47
- set interwiki(interwiki) {
48
- if (isLink(this.type)) {
49
- const { prefix, main, fragment } = this.#title, link = `${interwiki}:${prefix}${main}${fragment === undefined ? '' : `#${fragment}`}`;
50
- if (interwiki && !this.isInterwiki(link)) {
51
- throw new RangeError(`${interwiki} is not a valid interwiki prefix!`);
52
- }
53
- this.setTarget(link);
54
- }
55
- }
56
- /* NOT FOR BROWSER END */
57
- /**
58
- * @param link 链接标题
59
- * @param linkText 链接显示文字
60
- * @param delimiter `|`
61
- */
62
- constructor(link, linkText, config = index_1.default.getConfig(), accum = [], delimiter = '|') {
63
- super(undefined, config, accum, {
64
- AtomToken: 0, Token: 1,
65
- });
66
- this.insertAt(new atom_1.AtomToken(link, 'link-target', config, accum, {
67
- 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '',
68
- }));
69
- if (linkText !== undefined) {
70
- const inner = new index_2.Token(linkText, config, accum, {
71
- 'Stage-5': ':', QuoteToken: ':', ConverterToken: ':',
72
- });
73
- inner.type = 'link-text';
74
- inner.setAttribute('stage', constants_1.MAX_STAGE - 1);
75
- this.insertAt(inner);
76
- }
77
- this.#delimiter = delimiter;
78
- /* NOT FOR BROWSER */
79
- this.protectChildren(0);
80
- }
81
- /** @private */
82
- afterBuild() {
83
- this.#title = this.getTitle();
84
- if (this.#delimiter.includes('\0')) {
85
- this.#delimiter = this.buildFromStr(this.#delimiter, constants_1.BuildMethod.String);
86
- }
87
- this.setAttribute('name', this.#title.title);
88
- super.afterBuild();
89
- /* NOT FOR BROWSER */
90
- const /** @implements */ linkListener = (e, data) => {
91
- const { prevTarget } = e;
92
- if (prevTarget?.type === 'link-target') {
93
- const name = prevTarget.toString(true), titleObj = this.getTitle(), { title, interwiki, ns, valid } = titleObj;
94
- if (!valid) {
95
- (0, debug_1.undo)(e, data);
96
- throw new Error(`Invalid link target: ${name}`);
97
- }
98
- else if (this.type === 'category' && (interwiki || ns !== 14)
99
- || fileTypes.has(this.type) && (interwiki || ns !== 6)) {
100
- (0, debug_1.undo)(e, data);
101
- throw new Error(`${this.type === 'category' ? 'Category' : 'File'} link cannot change namespace: ${name}`);
102
- }
103
- else if (this.type === 'link'
104
- && !interwiki
105
- && (ns === 6 || ns === 14)
106
- && !name.trim().startsWith(':')) {
107
- const { firstChild } = prevTarget;
108
- if (firstChild?.type === 'text') {
109
- firstChild.insertData(0, ':');
110
- }
111
- else {
112
- prevTarget.prepend(':');
113
- }
114
- }
115
- this.#title = titleObj;
116
- this.setAttribute('name', title);
117
- }
118
- };
119
- this.addEventListener(['remove', 'insert', 'replace', 'text'], linkListener);
120
- }
121
- /** @private */
122
- setAttribute(key, value) {
123
- if (key === 'bracket') {
124
- this.#bracket = value;
125
- }
126
- else if (key === 'title') {
127
- this.#title = value;
128
- }
129
- else {
130
- super.setAttribute(key, value);
131
- }
132
- }
133
- /** @private */
134
- toString(skip) {
135
- const str = super.toString(skip, this.#delimiter);
136
- return this.#bracket ? `[[${str}]]` : str;
137
- }
138
- /** @private */
139
- text() {
140
- const str = super.text('|');
141
- return this.#bracket ? `[[${str}]]` : str;
142
- }
143
- /** @private */
144
- getAttribute(key) {
145
- if (key === 'title') {
146
- return this.#title;
147
- }
148
- return key === 'padding' ? 2 : super.getAttribute(key);
149
- }
150
- /** @private */
151
- getGaps(i) {
152
- return i === 0 ? this.#delimiter.length : 1;
153
- }
154
- /** @private */
155
- lint(start = this.getAbsoluteIndex(), re) {
156
- const errors = super.lint(start, re), { childNodes: [target, linkText], type } = this, { encoded, fragment } = this.#title, rect = new rect_1.BoundingRect(this, start);
157
- if (target.childNodes.some(({ type: t }) => t === 'template')) {
158
- errors.push((0, lint_1.generateForChild)(target, rect, 'unknown-page', 'template in an internal link target', 'warning'));
159
- }
160
- if (encoded) {
161
- errors.push((0, lint_1.generateForChild)(target, rect, 'url-encoding', 'unnecessary URL encoding in an internal link'));
162
- }
163
- if (type === 'link' || type === 'category') {
164
- const textNode = linkText?.childNodes.find((c) => c.type === 'text' && c.data.includes('|'));
165
- if (textNode) {
166
- const e = (0, lint_1.generateForChild)(linkText, rect, 'pipe-like', 'additional "|" in the link text', 'warning');
167
- e.suggestions = [
168
- {
169
- desc: 'escape',
170
- range: [
171
- e.startIndex + textNode.getRelativeIndex(),
172
- e.startIndex + textNode.getRelativeIndex() + textNode.data.length,
173
- ],
174
- text: textNode.data.replace(/\|/gu, '|'),
175
- },
176
- ];
177
- errors.push(e);
178
- }
179
- }
180
- if (fragment !== undefined && !isLink(type)) {
181
- const e = (0, lint_1.generateForChild)(target, rect, 'no-ignored', 'useless fragment'), textNode = target.childNodes.find((c) => c.type === 'text' && c.data.includes('#'));
182
- if (textNode) {
183
- e.fix = {
184
- range: [e.startIndex + textNode.getRelativeIndex() + textNode.data.indexOf('#'), e.endIndex],
185
- text: '',
186
- };
187
- }
188
- errors.push(e);
189
- }
190
- return errors;
191
- }
192
- /** @private */
193
- getTitle(halfParsed) {
194
- return this.normalizeTitle(this.firstChild.toString(true), 0, halfParsed, true, true);
195
- }
196
- /** @private */
197
- print() {
198
- return super.print(this.#bracket ? { pre: '[[', post: ']]', sep: this.#delimiter } : { sep: this.#delimiter });
199
- }
200
- /* NOT FOR BROWSER */
201
- cloneNode() {
202
- const [link, ...linkText] = this.cloneChildNodes();
203
- return debug_1.Shadow.run(() => {
204
- const token = new this.constructor('', undefined, this.getAttribute('config'));
205
- token.firstChild.safeReplaceWith(link);
206
- token.append(...linkText);
207
- return token;
208
- });
209
- }
210
- /**
211
- * 设置链接目标
212
- * @param link 链接目标
213
- */
214
- setTarget(link) {
215
- const config = this.getAttribute('config'), { childNodes } = index_1.default.parse(link, this.getAttribute('include'), 2, config), token = debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'link-target', config, [], {
216
- 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '',
217
- }));
218
- token.append(...childNodes);
219
- this.firstChild.safeReplaceWith(token);
220
- }
221
- /**
222
- * 设置fragment
223
- * @param fragment fragment
224
- */
225
- setFragment(fragment) {
226
- const { type, name } = this;
227
- if (fragment === undefined || isLink(type)) {
228
- fragment &&= (0, string_1.encode)(fragment);
229
- this.setTarget(`${name}${fragment === undefined ? '' : `#${fragment}`}`);
230
- }
231
- }
232
- /**
233
- * 设置链接显示文字
234
- * @param linkStr 链接显示文字
235
- */
236
- setLinkText(linkStr) {
237
- if (linkStr === undefined) {
238
- this.childNodes[1]?.remove();
239
- return;
240
- }
241
- const root = index_1.default.parse(linkStr, this.getAttribute('include'), undefined, this.getAttribute('config'));
242
- if (this.length === 1) {
243
- root.type = 'link-text';
244
- root.setAttribute('acceptable', {
245
- 'Stage-5': ':', QuoteToken: ':', ConverterToken: ':',
246
- });
247
- this.insertAt(root);
248
- }
249
- else {
250
- this.lastChild.replaceChildren(...root.childNodes);
251
- }
252
- }
253
- /** @private */
254
- toHtml() {
255
- if (this.is('link') || this.is('redirect-target')) {
256
- const { link, length, lastChild, type } = this;
257
- return `<a ${link.interwiki && 'class="extiw" '}href="${link.getUrl()}" title="${link.title.replace(/"/gu, '&quot;')}">${type === 'link' && length > 1 ? lastChild.toHtml(true) : this.innerText}</a>`;
258
- }
259
- return '';
260
- }
261
- }
262
- exports.LinkBaseToken = LinkBaseToken;
263
- constants_1.classes['LinkBaseToken'] = __filename;
@@ -1,22 +0,0 @@
1
- import { LinkBaseToken } from './base';
2
- import type { Title } from '../../lib/title';
3
- import type { Token, AtomToken } from '../../internal';
4
- /**
5
- * 分类
6
- * @classdesc `{childNodes: [AtomToken, ?Token]}`
7
- */
8
- export declare abstract class CategoryToken extends LinkBaseToken {
9
- readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token];
10
- abstract get children(): [AtomToken] | [AtomToken, Token];
11
- abstract get link(): Title;
12
- abstract set link(link: string);
13
- get type(): 'category';
14
- /** 分类排序关键字 */
15
- get sortkey(): string | undefined;
16
- set sortkey(text: string | undefined);
17
- /**
18
- * 设置排序关键字
19
- * @param text 排序关键字
20
- */
21
- setSortkey(text?: string): void;
22
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CategoryToken = void 0;
4
- const string_1 = require("../../util/string");
5
- const constants_1 = require("../../util/constants");
6
- const base_1 = require("./base");
7
- /**
8
- * 分类
9
- * @classdesc `{childNodes: [AtomToken, ?Token]}`
10
- */
11
- class CategoryToken extends base_1.LinkBaseToken {
12
- /* NOT FOR BROWSER END */
13
- get type() {
14
- return 'category';
15
- }
16
- /* NOT FOR BROWSER */
17
- /** 分类排序关键字 */
18
- get sortkey() {
19
- const { childNodes: [, child] } = this;
20
- return child && (0, string_1.decodeHtml)(child.text());
21
- }
22
- set sortkey(text) {
23
- this.setSortkey(text);
24
- }
25
- /**
26
- * 设置排序关键字
27
- * @param text 排序关键字
28
- */
29
- setSortkey(text) {
30
- this.setLinkText(text);
31
- }
32
- }
33
- exports.CategoryToken = CategoryToken;
34
- constants_1.classes['CategoryToken'] = __filename;
@@ -1,96 +0,0 @@
1
- import Parser from '../../index';
2
- import { LinkBaseToken } from './base';
3
- import { ImageParameterToken } from '../imageParameter';
4
- import type { Title } from '../../lib/title';
5
- import type { LintError } from '../../base';
6
- import type { Token, AtomToken } from '../../internal';
7
- /**
8
- * 图片
9
- * @classdesc `{childNodes: [AtomToken, ...ImageParameterToken]}`
10
- */
11
- export declare abstract class FileToken extends LinkBaseToken {
12
- #private;
13
- readonly childNodes: readonly [AtomToken, ...ImageParameterToken[]];
14
- abstract get lastChild(): AtomToken | ImageParameterToken;
15
- abstract get children(): [AtomToken, ...ImageParameterToken[]];
16
- abstract get lastElementChild(): AtomToken | ImageParameterToken;
17
- get type(): 'file' | 'gallery-image' | 'imagemap-image';
18
- /** 扩展名 */
19
- get extension(): string | undefined;
20
- /** 图片链接 */
21
- get link(): string | Title;
22
- set link(value: string);
23
- /** 图片大小 */
24
- get size(): {
25
- width: string;
26
- height: string;
27
- } | undefined;
28
- set size(size: {
29
- width: string;
30
- height: string;
31
- } | undefined);
32
- /** 图片宽度 */
33
- get width(): string | undefined;
34
- set width(width: string | undefined);
35
- /** 图片高度 */
36
- get height(): string | undefined;
37
- set height(height: string | undefined);
38
- /**
39
- * @param link 文件名
40
- * @param text 图片参数
41
- * @param delimiter `|`
42
- */
43
- constructor(link: string, text?: string, config?: Parser.Config, accum?: Token[], delimiter?: string);
44
- /** 获取所有图片参数节点 */
45
- getAllArgs(): ImageParameterToken[];
46
- /**
47
- * 获取指定图片参数
48
- * @param key 参数名
49
- */
50
- getArgs(key: string): ImageParameterToken[];
51
- /** 获取图片框架属性参数节点 */
52
- getFrameArgs(): ImageParameterToken[];
53
- /** 获取图片水平对齐参数节点 */
54
- getHorizAlignArgs(): ImageParameterToken[];
55
- /** 获取图片垂直对齐参数节点 */
56
- getVertAlignArgs(): ImageParameterToken[];
57
- /**
58
- * 获取生效的指定图片参数
59
- * @param key 参数名
60
- */
61
- getArg(key: string): ImageParameterToken | undefined;
62
- /**
63
- * 获取生效的指定图片参数值
64
- * @param key 参数名
65
- */
66
- getValue(key: string): string | true | undefined;
67
- /**
68
- * 是否具有指定图片参数
69
- * @param key 参数名
70
- */
71
- hasArg(key: string): boolean;
72
- /**
73
- * 移除指定图片参数
74
- * @param key 参数名
75
- */
76
- removeArg(key: string): void;
77
- /** 获取图片参数名 */
78
- getKeys(): Set<string>;
79
- /**
80
- * 获取指定的图片参数值
81
- * @param key 参数名
82
- */
83
- getValues(key: string): (string | true)[];
84
- /**
85
- * 设置图片参数
86
- * @param key 参数名
87
- * @param value 参数值
88
- * @throws `RangeError` 未定义的图片参数
89
- */
90
- setValue(key: string, value?: string | boolean): void;
91
- /**
92
- * @override
93
- * @throws `Error` 不适用于图片
94
- */
95
- setLinkText(): never;
96
- }