wikiparser-node 1.5.2-b → 1.5.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.
Files changed (163) hide show
  1. package/config/.schema.json +172 -0
  2. package/config/enwiki.json +814 -1
  3. package/config/llwiki.json +35 -1
  4. package/config/moegirl.json +44 -1
  5. package/config/zhwiki.json +466 -1
  6. package/dist/addon/table.d.ts +6 -0
  7. package/dist/addon/table.js +564 -0
  8. package/dist/base.d.ts +72 -0
  9. package/dist/base.js +38 -0
  10. package/dist/index.d.ts +30 -0
  11. package/dist/index.js +214 -0
  12. package/dist/internal.d.ts +44 -0
  13. package/dist/lib/element.d.ts +150 -0
  14. package/dist/lib/element.js +613 -0
  15. package/dist/lib/node.d.ts +146 -0
  16. package/dist/lib/node.js +428 -0
  17. package/dist/lib/range.d.ts +104 -0
  18. package/dist/lib/range.js +385 -0
  19. package/dist/lib/ranges.d.ts +26 -0
  20. package/dist/lib/ranges.js +118 -0
  21. package/dist/lib/text.d.ts +62 -0
  22. package/dist/lib/text.js +361 -0
  23. package/dist/lib/title.d.ts +38 -0
  24. package/dist/lib/title.js +166 -0
  25. package/dist/mixin/attributesParent.d.ts +50 -0
  26. package/dist/mixin/attributesParent.js +78 -0
  27. package/dist/mixin/fixed.d.ts +6 -0
  28. package/dist/mixin/fixed.js +30 -0
  29. package/dist/mixin/flagsParent.d.ts +72 -0
  30. package/dist/mixin/flagsParent.js +59 -0
  31. package/dist/mixin/hidden.d.ts +5 -0
  32. package/dist/mixin/hidden.js +24 -0
  33. package/dist/mixin/magicLinkParent.d.ts +40 -0
  34. package/dist/mixin/magicLinkParent.js +42 -0
  35. package/dist/mixin/singleLine.d.ts +6 -0
  36. package/dist/mixin/singleLine.js +26 -0
  37. package/dist/mixin/sol.d.ts +6 -0
  38. package/dist/mixin/sol.js +43 -0
  39. package/dist/mixin/syntax.d.ts +9 -0
  40. package/dist/mixin/syntax.js +50 -0
  41. package/dist/parser/braces.js +131 -0
  42. package/dist/parser/commentAndExt.js +90 -0
  43. package/dist/parser/converter.js +41 -0
  44. package/dist/parser/externalLinks.js +32 -0
  45. package/dist/parser/hrAndDoubleUnderscore.js +41 -0
  46. package/dist/parser/html.js +39 -0
  47. package/dist/parser/links.js +95 -0
  48. package/dist/parser/list.js +98 -0
  49. package/dist/parser/magicLinks.js +43 -0
  50. package/dist/parser/quotes.js +68 -0
  51. package/dist/parser/selector.js +162 -0
  52. package/dist/parser/table.js +124 -0
  53. package/dist/src/arg.d.ts +58 -0
  54. package/dist/src/arg.js +214 -0
  55. package/dist/src/atom.d.ts +12 -0
  56. package/dist/src/atom.js +27 -0
  57. package/dist/src/attribute.d.ts +71 -0
  58. package/dist/src/attribute.js +502 -0
  59. package/dist/src/attributes.d.ts +109 -0
  60. package/dist/src/attributes.js +356 -0
  61. package/dist/src/converter.d.ts +33 -0
  62. package/dist/src/converter.js +134 -0
  63. package/dist/src/converterFlags.d.ts +87 -0
  64. package/dist/src/converterFlags.js +242 -0
  65. package/dist/src/converterRule.d.ts +77 -0
  66. package/dist/src/converterRule.js +209 -0
  67. package/dist/src/extLink.d.ts +43 -0
  68. package/dist/src/extLink.js +186 -0
  69. package/dist/src/gallery.d.ts +54 -0
  70. package/dist/src/gallery.js +139 -0
  71. package/dist/src/heading.d.ts +47 -0
  72. package/dist/src/heading.js +190 -0
  73. package/dist/src/hidden.d.ts +7 -0
  74. package/dist/src/hidden.js +23 -0
  75. package/dist/src/html.d.ts +65 -0
  76. package/dist/src/html.js +358 -0
  77. package/dist/src/imageParameter.d.ts +65 -0
  78. package/dist/src/imageParameter.js +257 -0
  79. package/dist/src/imagemap.d.ts +56 -0
  80. package/dist/src/imagemap.js +150 -0
  81. package/dist/src/imagemapLink.d.ts +31 -0
  82. package/dist/src/imagemapLink.js +93 -0
  83. package/dist/src/index.d.ts +143 -0
  84. package/dist/src/index.js +813 -0
  85. package/dist/src/link/base.d.ts +52 -0
  86. package/dist/src/link/base.js +229 -0
  87. package/dist/src/link/category.d.ts +13 -0
  88. package/dist/src/link/category.js +28 -0
  89. package/dist/src/link/file.d.ts +98 -0
  90. package/dist/src/link/file.js +272 -0
  91. package/dist/src/link/galleryImage.d.ts +32 -0
  92. package/dist/src/link/galleryImage.js +157 -0
  93. package/dist/src/link/index.d.ts +56 -0
  94. package/dist/src/link/index.js +133 -0
  95. package/dist/src/magicLink.d.ts +59 -0
  96. package/dist/src/magicLink.js +223 -0
  97. package/dist/src/nested.d.ts +43 -0
  98. package/dist/src/nested.js +105 -0
  99. package/dist/src/nowiki/base.d.ts +31 -0
  100. package/dist/src/nowiki/base.js +93 -0
  101. package/dist/src/nowiki/comment.d.ts +25 -0
  102. package/dist/src/nowiki/comment.js +76 -0
  103. package/dist/src/nowiki/dd.d.ts +8 -0
  104. package/dist/src/nowiki/dd.js +24 -0
  105. package/dist/src/nowiki/doubleUnderscore.d.ts +18 -0
  106. package/dist/src/nowiki/doubleUnderscore.js +101 -0
  107. package/dist/src/nowiki/hr.d.ts +5 -0
  108. package/dist/src/nowiki/hr.js +63 -0
  109. package/dist/src/nowiki/index.d.ts +16 -0
  110. package/dist/src/nowiki/index.js +27 -0
  111. package/dist/src/nowiki/list.d.ts +16 -0
  112. package/dist/src/nowiki/list.js +97 -0
  113. package/dist/src/nowiki/listBase.d.ts +5 -0
  114. package/dist/src/nowiki/listBase.js +61 -0
  115. package/dist/src/nowiki/noinclude.d.ts +10 -0
  116. package/dist/src/nowiki/noinclude.js +23 -0
  117. package/dist/src/nowiki/quote.d.ts +14 -0
  118. package/dist/src/nowiki/quote.js +131 -0
  119. package/dist/src/onlyinclude.d.ts +16 -0
  120. package/dist/src/onlyinclude.js +57 -0
  121. package/dist/src/paramTag/index.d.ts +37 -0
  122. package/dist/src/paramTag/index.js +77 -0
  123. package/dist/src/paramTag/inputbox.d.ts +8 -0
  124. package/dist/src/paramTag/inputbox.js +22 -0
  125. package/dist/src/parameter.d.ts +70 -0
  126. package/dist/src/parameter.js +264 -0
  127. package/dist/src/pre.d.ts +28 -0
  128. package/dist/src/pre.js +55 -0
  129. package/dist/src/syntax.d.ts +20 -0
  130. package/dist/src/syntax.js +86 -0
  131. package/dist/src/table/base.d.ts +30 -0
  132. package/dist/src/table/base.js +132 -0
  133. package/dist/src/table/index.d.ts +233 -0
  134. package/dist/src/table/index.js +396 -0
  135. package/dist/src/table/td.d.ts +86 -0
  136. package/dist/src/table/td.js +350 -0
  137. package/dist/src/table/tr.d.ts +32 -0
  138. package/dist/src/table/tr.js +58 -0
  139. package/dist/src/table/trBase.d.ts +53 -0
  140. package/dist/src/table/trBase.js +152 -0
  141. package/dist/src/tagPair/ext.d.ts +32 -0
  142. package/dist/src/tagPair/ext.js +203 -0
  143. package/dist/src/tagPair/include.d.ts +35 -0
  144. package/dist/src/tagPair/include.js +74 -0
  145. package/dist/src/tagPair/index.d.ts +27 -0
  146. package/dist/src/tagPair/index.js +128 -0
  147. package/dist/src/transclude.d.ts +167 -0
  148. package/dist/src/transclude.js +717 -0
  149. package/dist/util/constants.js +28 -0
  150. package/dist/util/debug.js +88 -0
  151. package/dist/util/diff.js +83 -0
  152. package/dist/util/lint.js +31 -0
  153. package/dist/util/string.js +54 -0
  154. package/errors/README +1 -0
  155. package/package.json +14 -27
  156. package/printed/README +1 -0
  157. package/bundle/bundle.min.js +0 -37
  158. package/extensions/dist/base.js +0 -64
  159. package/extensions/dist/editor.js +0 -159
  160. package/extensions/dist/highlight.js +0 -59
  161. package/extensions/dist/lint.js +0 -60
  162. package/extensions/editor.css +0 -63
  163. package/extensions/ui.css +0 -141
@@ -0,0 +1,233 @@
1
+ import Parser from '../../index';
2
+ import { TrBaseToken } from './trBase';
3
+ import { SyntaxToken } from '../syntax';
4
+ import type { LintError, AST } from '../../base';
5
+ import type { SyntaxBase } from '../../mixin/syntax';
6
+ import type { AttributesToken, TdToken, TrToken, Token } from '../../internal';
7
+ import type { TableCoords } from './trBase';
8
+ import type { TdAttrs, TdSubtypes, TdSpanAttrs } from './td';
9
+ import type { Layout } from '../../addon/table';
10
+ export interface TableRenderedCoords {
11
+ readonly row?: undefined;
12
+ readonly column?: undefined;
13
+ readonly x: number;
14
+ readonly y: number;
15
+ }
16
+ export interface TableToken extends SyntaxBase {
17
+ }
18
+ /**
19
+ * 表格
20
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
21
+ */
22
+ export declare abstract class TableToken extends TrBaseToken {
23
+ readonly type = "table";
24
+ readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
25
+ abstract get lastChild(): AttributesToken | TdToken | TrToken | SyntaxToken;
26
+ abstract get children(): [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
27
+ abstract get lastElementChild(): AttributesToken | TdToken | TrToken | SyntaxToken;
28
+ /** 表格是否闭合 */
29
+ get closed(): boolean;
30
+ set closed(closed: boolean);
31
+ /**
32
+ * @param syntax 表格语法
33
+ * @param attr 表格属性
34
+ */
35
+ constructor(syntax: string, attr?: string, config?: Parser.Config, accum?: Token[]);
36
+ /** @override */
37
+ lint(start?: number): LintError[];
38
+ /**
39
+ * 闭合表格语法
40
+ * @param syntax 表格结尾语法
41
+ * @param halfParsed
42
+ */
43
+ close(syntax?: string, halfParsed?: boolean): void;
44
+ /** @override */
45
+ json(): AST;
46
+ /**
47
+ * @override
48
+ * @param token 待插入的子节点
49
+ * @param i 插入位置
50
+ * @throws `SyntaxError` 表格的闭合部分非法
51
+ */
52
+ insertAt<T extends Token>(token: T, i?: number): T;
53
+ /** @override */
54
+ getRowCount(): number;
55
+ /** 获取下一行 */
56
+ getNextRow(): TrToken | undefined;
57
+ /**
58
+ * 获取第n行
59
+ * @param n 行号
60
+ * @param force 是否将表格自身视为第一行
61
+ * @param insert 是否用于判断插入新行的位置
62
+ * @throws `RangeError` 不存在该行
63
+ */
64
+ getNthRow(n: number, force?: boolean, insert?: false): TrToken | this | undefined;
65
+ getNthRow(n: number, force: boolean, insert: true): TrToken | this | SyntaxToken | undefined;
66
+ /** 获取所有行 */
67
+ getAllRows(): (TrToken | this)[];
68
+ /**
69
+ * 获取指定坐标的单元格
70
+ * @param coords 表格坐标
71
+ */
72
+ getNthCell(coords: TableCoords | TableRenderedCoords): TdToken | undefined;
73
+ /**
74
+ * 获取表格布局
75
+ * @param stop 中止条件
76
+ * @param stop.row 中止行
77
+ * @param stop.column 中止列
78
+ * @param stop.x 中止行
79
+ * @param stop.y 中止列
80
+ */
81
+ getLayout(stop?: {
82
+ row?: number;
83
+ column?: number;
84
+ x?: number;
85
+ y?: number;
86
+ }): Layout;
87
+ /** 打印表格布局 */
88
+ printLayout(): void;
89
+ /**
90
+ * 转换为渲染后的表格坐标
91
+ * @param {TableCoords} coord wikitext中的表格坐标
92
+ */
93
+ toRenderedCoords(coord: TableCoords): TableRenderedCoords | undefined;
94
+ /**
95
+ * 转换为wikitext中的表格坐标
96
+ * @param {TableRenderedCoords} coord 渲染后的表格坐标
97
+ */
98
+ toRawCoords(coord: TableRenderedCoords): TableCoords | undefined;
99
+ /**
100
+ * 获取完整行
101
+ * @param y 行号
102
+ */
103
+ getFullRow(y: number): Map<TdToken, boolean>;
104
+ /**
105
+ * 获取完整列
106
+ * @param x 列号
107
+ */
108
+ getFullCol(x: number): Map<TdToken, boolean>;
109
+ /**
110
+ * 设置行格式
111
+ * @param y 行号
112
+ * @param attr 表格属性
113
+ * @param multiRow 是否对所有单元格设置,或是仅对行首单元格设置
114
+ */
115
+ formatTableRow(y: number, attr?: TdAttrs | string, multiRow?: boolean): void;
116
+ /**
117
+ * 设置列格式
118
+ * @param x 列号
119
+ * @param attr 表格属性
120
+ * @param multiCol 是否对所有单元格设置,或是仅对行首单元格设置
121
+ */
122
+ formatTableCol(x: number, attr?: TdAttrs | string, multiCol?: boolean): void;
123
+ /**
124
+ * 填补表格行
125
+ * @param y 行号
126
+ * @param inner 填充内容
127
+ * @param subtype 单元格类型
128
+ * @param attr 表格属性
129
+ */
130
+ fillTableRow(y: number, inner: string | Token, subtype?: TdSubtypes, attr?: TdAttrs): void;
131
+ /**
132
+ * 填补表格
133
+ * @param inner 填充内容
134
+ * @param subtype 单元格类型
135
+ * @param attr 表格属性
136
+ */
137
+ fillTable(inner: string | Token, subtype?: TdSubtypes, attr?: TdAttrs): void;
138
+ /**
139
+ * @override
140
+ * @param inner 单元格内部wikitext
141
+ * @param coords 单元格坐标
142
+ * @param subtype 单元格类型
143
+ * @param attr 单元格属性
144
+ * @throws `RangeError` 指定的坐标不是单元格起始点
145
+ */
146
+ insertTableCell(inner: string | Token, coords: TableCoords | TableRenderedCoords, subtype?: TdSubtypes, attr?: TdAttrs): TdToken;
147
+ /**
148
+ * 插入表格行
149
+ * @param y 行号
150
+ * @param attr 表格行属性
151
+ * @param inner 内部wikitext
152
+ * @param subtype 单元格类型
153
+ * @param innerAttr 单元格属性
154
+ */
155
+ insertTableRow(y: number, attr?: Record<string, string | true>, inner?: string | Token, subtype?: TdSubtypes, innerAttr?: TdAttrs): TrToken;
156
+ /**
157
+ * 插入表格列
158
+ * @param x 列号
159
+ * @param inner 内部wikitext
160
+ * @param subtype 单元格类型
161
+ * @param attr 单元格属性
162
+ * @throws `RangeError` 列号过大
163
+ */
164
+ insertTableCol(x: number, inner: string | Token, subtype?: TdSubtypes, attr?: TdAttrs): void;
165
+ /**
166
+ * 移除表格行
167
+ * @param y 行号
168
+ */
169
+ removeTableRow(y: number): TrToken;
170
+ /**
171
+ * 移除表格列
172
+ * @param x 列号
173
+ */
174
+ removeTableCol(x: number): void;
175
+ /**
176
+ * 合并单元格
177
+ * @param xlim 列范围
178
+ * @param ylim 行范围
179
+ * @throws `RangeError` 待合并区域与外侧区域有重叠
180
+ */
181
+ mergeCells(xlim: readonly [number, number], ylim: readonly [number, number]): TdToken;
182
+ /**
183
+ * 分裂成多行
184
+ * @param coords 单元格坐标
185
+ */
186
+ splitIntoRows(coords: TableCoords | TableRenderedCoords): void;
187
+ /**
188
+ * 分裂成多列
189
+ * @param coords 单元格坐标
190
+ */
191
+ splitIntoCols(coords: TableCoords | TableRenderedCoords): void;
192
+ /**
193
+ * 分裂成单元格
194
+ * @param coords 单元格坐标
195
+ */
196
+ splitIntoCells(coords: TableCoords | TableRenderedCoords): void;
197
+ /**
198
+ * 复制一行并插入该行之前
199
+ * @param row 行号
200
+ */
201
+ replicateTableRow(row: number): TrToken;
202
+ /**
203
+ * 复制一列并插入该列之前
204
+ * @param x 列号
205
+ */
206
+ replicateTableCol(x: number): TdToken[];
207
+ /**
208
+ * 移动表格行
209
+ * @param y 行号
210
+ * @param before 新位置
211
+ * @throws `RangeError` 无法移动
212
+ */
213
+ moveTableRowBefore(y: number, before: number): TrToken;
214
+ /**
215
+ * 移动表格行
216
+ * @param y 行号
217
+ * @param after 新位置
218
+ * @throws `RangeError` 无法移动
219
+ */
220
+ moveTableRowAfter(y: number, after: number): TrToken;
221
+ /**
222
+ * 移动表格列
223
+ * @param x 列号
224
+ * @param before 新位置
225
+ */
226
+ moveTableColBefore(x: number, before: number): void;
227
+ /**
228
+ * 移动表格列
229
+ * @param x 列号
230
+ * @param after 新位置
231
+ */
232
+ moveTableColAfter(x: number, after: number): void;
233
+ }
@@ -0,0 +1,396 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableToken = void 0;
4
+ const lint_1 = require("../../util/lint");
5
+ const debug_1 = require("../../util/debug");
6
+ const string_1 = require("../../util/string");
7
+ const constants_1 = require("../../util/constants");
8
+ const index_1 = require("../../index");
9
+ const trBase_1 = require("./trBase");
10
+ const syntax_1 = require("../syntax");
11
+ /* NOT FOR BROWSER END */
12
+ const closingPattern = /^\n[^\S\n]*(?:\|\}|\{\{\s*!\s*\}\}\}|\{\{\s*!\)\s*\}\})$/u;
13
+ /**
14
+ * 表格
15
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
16
+ */
17
+ class TableToken extends trBase_1.TrBaseToken {
18
+ type = 'table';
19
+ /* NOT FOR BROWSER END */
20
+ /** 表格是否闭合 */
21
+ get closed() {
22
+ return this.lastChild.type === 'table-syntax';
23
+ }
24
+ /* NOT FOR BROWSER */
25
+ set closed(closed) {
26
+ if (closed && !this.closed) {
27
+ this.close(this.closest('parameter-value') ? '\n{{!}}}' : '\n|}');
28
+ }
29
+ }
30
+ /* NOT FOR BROWSER END */
31
+ /**
32
+ * @param syntax 表格语法
33
+ * @param attr 表格属性
34
+ */
35
+ constructor(syntax, attr, config = index_1.default.getConfig(), accum = []) {
36
+ super(/^(?:\{\||\{\{\{\s*!\s*\}\}|\{\{\s*\(!\s*\}\})$/u, syntax, attr, config, accum, {
37
+ Token: 2, SyntaxToken: [0, -1], AttributesToken: 1, TdToken: '2:', TrToken: '2:',
38
+ });
39
+ }
40
+ /** @override */
41
+ lint(start = this.getAbsoluteIndex()) {
42
+ const errors = super.lint(start);
43
+ if (!this.closed) {
44
+ errors.push((0, lint_1.generateForChild)(this.firstChild, { start }, 'unclosed-table', index_1.default.msg('unclosed $1', 'table')));
45
+ }
46
+ /* NOT FOR BROWSER */
47
+ const layout = this.getLayout(), { length } = layout;
48
+ if (length > 1) {
49
+ const j = new Array(length - 1).fill(undefined)
50
+ .findIndex((_, i) => layout[i].length !== layout[i + 1].length) + 1;
51
+ if (j) {
52
+ errors.push((0, lint_1.generateForChild)(this.getNthRow(j), { start }, 'table-layout', 'inconsistent table layout', 'warning'));
53
+ }
54
+ }
55
+ /* NOT FOR BROWSER END */
56
+ return errors;
57
+ }
58
+ /**
59
+ * 闭合表格语法
60
+ * @param syntax 表格结尾语法
61
+ * @param halfParsed
62
+ */
63
+ close(syntax = '\n|}', halfParsed = false) {
64
+ const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed ? [syntax] : index_1.default.parse(syntax, this.getAttribute('include'), 2, config).childNodes;
65
+ if (this.lastChild.type !== 'table-syntax') {
66
+ const token = debug_1.Shadow.run(() => super.insertAt(new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum, {
67
+ 'Stage-1': ':', '!ExtToken': '', TranscludeToken: ':',
68
+ })));
69
+ if (!halfParsed) {
70
+ token.afterBuild();
71
+ }
72
+ }
73
+ this.lastChild.replaceChildren(...inner);
74
+ }
75
+ /** @override */
76
+ json() {
77
+ const json = super.json();
78
+ json['closed'] = this.closed;
79
+ return json;
80
+ }
81
+ /* NOT FOR BROWSER */
82
+ /**
83
+ * @override
84
+ * @param token 待插入的子节点
85
+ * @param i 插入位置
86
+ * @throws `SyntaxError` 表格的闭合部分非法
87
+ */
88
+ insertAt(token, i = this.length) {
89
+ i += i < 0 ? this.length : 0;
90
+ const previous = this.childNodes[i - 1];
91
+ if (typeof token !== 'string' && token.type === 'td' && previous?.type === 'tr') {
92
+ index_1.default.warn('改为将单元格插入当前行。');
93
+ return previous.insertAt(token);
94
+ }
95
+ else if (i > 0 && token instanceof syntax_1.SyntaxToken && token.pattern !== closingPattern) {
96
+ throw new SyntaxError(`表格的闭合部分不符合语法:${(0, string_1.noWrap)(String(token))}`);
97
+ }
98
+ return super.insertAt(token, i);
99
+ }
100
+ /** @override */
101
+ getRowCount() {
102
+ return super.getRowCount() + this.childNodes.filter(child => child.type === 'tr' && child.getRowCount()).length;
103
+ }
104
+ /** 获取下一行 */
105
+ getNextRow() {
106
+ return this.getNthRow(super.getRowCount() ? 1 : 0, false, false);
107
+ }
108
+ getNthRow(n, force = false, insert = false) {
109
+ const nRows = this.getRowCount(), isRow = super.getRowCount();
110
+ n += n < 0 ? nRows : 0;
111
+ if (n === 0 && (isRow || force && nRows === 0)) {
112
+ return this;
113
+ }
114
+ else if (n < 0 || n > nRows || n === nRows && !insert) {
115
+ throw new RangeError(`不存在第 ${n} 行!`);
116
+ }
117
+ else if (isRow) {
118
+ n--;
119
+ }
120
+ for (const child of this.childNodes.slice(2)) {
121
+ if (child.type === 'tr' && child.getRowCount()) {
122
+ n--;
123
+ if (n < 0) {
124
+ return child;
125
+ }
126
+ }
127
+ else if (child.type === 'table-syntax') {
128
+ return child;
129
+ }
130
+ }
131
+ return undefined;
132
+ }
133
+ /** 获取所有行 */
134
+ getAllRows() {
135
+ return [
136
+ ...super.getRowCount() ? [this] : [],
137
+ ...this.childNodes.slice(1)
138
+ .filter((child) => child.type === 'tr' && child.getRowCount() > 0),
139
+ ];
140
+ }
141
+ /**
142
+ * 获取指定坐标的单元格
143
+ * @param coords 表格坐标
144
+ */
145
+ getNthCell(coords) {
146
+ require('../../addon/table');
147
+ return this.getNthCell(coords);
148
+ }
149
+ /**
150
+ * 获取表格布局
151
+ * @param stop 中止条件
152
+ * @param stop.row 中止行
153
+ * @param stop.column 中止列
154
+ * @param stop.x 中止行
155
+ * @param stop.y 中止列
156
+ */
157
+ getLayout(stop) {
158
+ require('../../addon/table');
159
+ return this.getLayout(stop);
160
+ }
161
+ /** 打印表格布局 */
162
+ printLayout() {
163
+ require('../../addon/table');
164
+ this.printLayout();
165
+ }
166
+ /**
167
+ * 转换为渲染后的表格坐标
168
+ * @param {TableCoords} coord wikitext中的表格坐标
169
+ */
170
+ toRenderedCoords(coord) {
171
+ require('../../addon/table');
172
+ return this.toRenderedCoords(coord);
173
+ }
174
+ /**
175
+ * 转换为wikitext中的表格坐标
176
+ * @param {TableRenderedCoords} coord 渲染后的表格坐标
177
+ */
178
+ toRawCoords(coord) {
179
+ require('../../addon/table');
180
+ return this.toRawCoords(coord);
181
+ }
182
+ /**
183
+ * 获取完整行
184
+ * @param y 行号
185
+ */
186
+ getFullRow(y) {
187
+ require('../../addon/table');
188
+ return this.getFullRow(y);
189
+ }
190
+ /**
191
+ * 获取完整列
192
+ * @param x 列号
193
+ */
194
+ getFullCol(x) {
195
+ require('../../addon/table');
196
+ return this.getFullCol(x);
197
+ }
198
+ /**
199
+ * 设置行格式
200
+ * @param y 行号
201
+ * @param attr 表格属性
202
+ * @param multiRow 是否对所有单元格设置,或是仅对行首单元格设置
203
+ */
204
+ formatTableRow(y, attr = {}, multiRow = false) {
205
+ require('../../addon/table');
206
+ this.formatTableRow(y, attr, multiRow);
207
+ }
208
+ /**
209
+ * 设置列格式
210
+ * @param x 列号
211
+ * @param attr 表格属性
212
+ * @param multiCol 是否对所有单元格设置,或是仅对行首单元格设置
213
+ */
214
+ formatTableCol(x, attr = {}, multiCol = false) {
215
+ require('../../addon/table');
216
+ this.formatTableCol(x, attr, multiCol);
217
+ }
218
+ /**
219
+ * 填补表格行
220
+ * @param y 行号
221
+ * @param inner 填充内容
222
+ * @param subtype 单元格类型
223
+ * @param attr 表格属性
224
+ */
225
+ fillTableRow(y, inner, subtype = 'td', attr = {}) {
226
+ require('../../addon/table');
227
+ this.fillTableRow(y, inner, subtype, attr);
228
+ }
229
+ /**
230
+ * 填补表格
231
+ * @param inner 填充内容
232
+ * @param subtype 单元格类型
233
+ * @param attr 表格属性
234
+ */
235
+ fillTable(inner, subtype = 'td', attr = {}) {
236
+ require('../../addon/table');
237
+ this.fillTable(inner, subtype, attr);
238
+ }
239
+ /**
240
+ * @override
241
+ * @param inner 单元格内部wikitext
242
+ * @param coords 单元格坐标
243
+ * @param subtype 单元格类型
244
+ * @param attr 单元格属性
245
+ * @throws `RangeError` 指定的坐标不是单元格起始点
246
+ */
247
+ insertTableCell(inner, coords, subtype = 'td', attr = {}) {
248
+ require('../../addon/table');
249
+ return this.insertTableCell(inner, coords, subtype, attr);
250
+ }
251
+ /** @private */
252
+ prependTableRow() {
253
+ require('../../addon/table');
254
+ return this.prependTableRow();
255
+ }
256
+ /**
257
+ * 插入表格行
258
+ * @param y 行号
259
+ * @param attr 表格行属性
260
+ * @param inner 内部wikitext
261
+ * @param subtype 单元格类型
262
+ * @param innerAttr 单元格属性
263
+ */
264
+ insertTableRow(y, attr = {}, inner, subtype = 'td', innerAttr = {}) {
265
+ require('../../addon/table');
266
+ return this.insertTableRow(y, attr, inner, subtype, innerAttr);
267
+ }
268
+ /**
269
+ * 插入表格列
270
+ * @param x 列号
271
+ * @param inner 内部wikitext
272
+ * @param subtype 单元格类型
273
+ * @param attr 单元格属性
274
+ * @throws `RangeError` 列号过大
275
+ */
276
+ insertTableCol(x, inner, subtype = 'td', attr = {}) {
277
+ require('../../addon/table');
278
+ this.insertTableCol(x, inner, subtype, attr);
279
+ }
280
+ /**
281
+ * 移除表格行
282
+ * @param y 行号
283
+ */
284
+ removeTableRow(y) {
285
+ require('../../addon/table');
286
+ return this.removeTableRow(y);
287
+ }
288
+ /**
289
+ * 移除表格列
290
+ * @param x 列号
291
+ */
292
+ removeTableCol(x) {
293
+ require('../../addon/table');
294
+ this.removeTableCol(x);
295
+ }
296
+ /**
297
+ * 合并单元格
298
+ * @param xlim 列范围
299
+ * @param ylim 行范围
300
+ * @throws `RangeError` 待合并区域与外侧区域有重叠
301
+ */
302
+ mergeCells(xlim, ylim) {
303
+ require('../../addon/table');
304
+ return this.mergeCells(xlim, ylim);
305
+ }
306
+ /** @private */
307
+ split(coords, dirs) {
308
+ require('../../addon/table');
309
+ this.split(coords, dirs);
310
+ }
311
+ /**
312
+ * 分裂成多行
313
+ * @param coords 单元格坐标
314
+ */
315
+ splitIntoRows(coords) {
316
+ require('../../addon/table');
317
+ this.splitIntoRows(coords);
318
+ }
319
+ /**
320
+ * 分裂成多列
321
+ * @param coords 单元格坐标
322
+ */
323
+ splitIntoCols(coords) {
324
+ require('../../addon/table');
325
+ this.splitIntoCols(coords);
326
+ }
327
+ /**
328
+ * 分裂成单元格
329
+ * @param coords 单元格坐标
330
+ */
331
+ splitIntoCells(coords) {
332
+ require('../../addon/table');
333
+ this.splitIntoCells(coords);
334
+ }
335
+ /**
336
+ * 复制一行并插入该行之前
337
+ * @param row 行号
338
+ */
339
+ replicateTableRow(row) {
340
+ require('../../addon/table');
341
+ return this.replicateTableRow(row);
342
+ }
343
+ /**
344
+ * 复制一列并插入该列之前
345
+ * @param x 列号
346
+ */
347
+ replicateTableCol(x) {
348
+ require('../../addon/table');
349
+ return this.replicateTableCol(x);
350
+ }
351
+ /** @private */
352
+ moveCol(x, reference, after) {
353
+ require('../../addon/table');
354
+ this.moveCol(x, reference, after);
355
+ }
356
+ /**
357
+ * 移动表格行
358
+ * @param y 行号
359
+ * @param before 新位置
360
+ * @throws `RangeError` 无法移动
361
+ */
362
+ moveTableRowBefore(y, before) {
363
+ require('../../addon/table');
364
+ return this.moveTableRowBefore(y, before);
365
+ }
366
+ /**
367
+ * 移动表格行
368
+ * @param y 行号
369
+ * @param after 新位置
370
+ * @throws `RangeError` 无法移动
371
+ */
372
+ moveTableRowAfter(y, after) {
373
+ require('../../addon/table');
374
+ return this.moveTableRowAfter(y, after);
375
+ }
376
+ /**
377
+ * 移动表格列
378
+ * @param x 列号
379
+ * @param before 新位置
380
+ */
381
+ moveTableColBefore(x, before) {
382
+ require('../../addon/table');
383
+ this.moveTableColBefore(x, before);
384
+ }
385
+ /**
386
+ * 移动表格列
387
+ * @param x 列号
388
+ * @param after 新位置
389
+ */
390
+ moveTableColAfter(x, after) {
391
+ require('../../addon/table');
392
+ this.moveTableColAfter(x, after);
393
+ }
394
+ }
395
+ exports.TableToken = TableToken;
396
+ constants_1.classes['TableToken'] = __filename;