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