wikiparser-node 1.6.2 → 1.7.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 (169) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/bundle/bundle.min.js +38 -0
  4. package/config/default.json +5 -0
  5. package/config/enwiki.json +4 -814
  6. package/config/llwiki.json +5 -35
  7. package/config/minimum.json +3 -0
  8. package/config/moegirl.json +5 -44
  9. package/config/zhwiki.json +6 -466
  10. package/extensions/dist/base.js +64 -0
  11. package/extensions/dist/editor.js +159 -0
  12. package/extensions/dist/highlight.js +58 -0
  13. package/extensions/dist/lint.js +72 -0
  14. package/extensions/editor.css +64 -0
  15. package/extensions/ui.css +144 -0
  16. package/i18n/zh-hans.json +2 -1
  17. package/i18n/zh-hant.json +2 -1
  18. package/package.json +37 -21
  19. package/config/.schema.json +0 -172
  20. package/dist/addon/table.d.ts +0 -1
  21. package/dist/addon/table.js +0 -485
  22. package/dist/base.d.ts +0 -69
  23. package/dist/base.js +0 -38
  24. package/dist/index.d.ts +0 -31
  25. package/dist/index.js +0 -212
  26. package/dist/internal.d.ts +0 -44
  27. package/dist/lib/element.d.ts +0 -151
  28. package/dist/lib/element.js +0 -618
  29. package/dist/lib/node.d.ts +0 -146
  30. package/dist/lib/node.js +0 -426
  31. package/dist/lib/range.d.ts +0 -104
  32. package/dist/lib/range.js +0 -385
  33. package/dist/lib/ranges.d.ts +0 -28
  34. package/dist/lib/ranges.js +0 -126
  35. package/dist/lib/text.d.ts +0 -63
  36. package/dist/lib/text.js +0 -354
  37. package/dist/lib/title.d.ts +0 -40
  38. package/dist/lib/title.js +0 -179
  39. package/dist/mixin/attributesParent.d.ts +0 -50
  40. package/dist/mixin/attributesParent.js +0 -81
  41. package/dist/mixin/fixed.d.ts +0 -6
  42. package/dist/mixin/fixed.js +0 -30
  43. package/dist/mixin/flagsParent.d.ts +0 -72
  44. package/dist/mixin/flagsParent.js +0 -59
  45. package/dist/mixin/hidden.d.ts +0 -5
  46. package/dist/mixin/hidden.js +0 -24
  47. package/dist/mixin/magicLinkParent.d.ts +0 -40
  48. package/dist/mixin/magicLinkParent.js +0 -42
  49. package/dist/mixin/singleLine.d.ts +0 -6
  50. package/dist/mixin/singleLine.js +0 -26
  51. package/dist/mixin/sol.d.ts +0 -6
  52. package/dist/mixin/sol.js +0 -43
  53. package/dist/mixin/syntax.d.ts +0 -9
  54. package/dist/mixin/syntax.js +0 -50
  55. package/dist/parser/braces.js +0 -130
  56. package/dist/parser/commentAndExt.js +0 -89
  57. package/dist/parser/converter.js +0 -40
  58. package/dist/parser/externalLinks.js +0 -45
  59. package/dist/parser/hrAndDoubleUnderscore.js +0 -40
  60. package/dist/parser/html.js +0 -38
  61. package/dist/parser/links.js +0 -97
  62. package/dist/parser/list.js +0 -97
  63. package/dist/parser/magicLinks.js +0 -42
  64. package/dist/parser/quotes.js +0 -67
  65. package/dist/parser/selector.js +0 -190
  66. package/dist/parser/table.js +0 -123
  67. package/dist/src/arg.d.ts +0 -58
  68. package/dist/src/arg.js +0 -214
  69. package/dist/src/atom.d.ts +0 -12
  70. package/dist/src/atom.js +0 -27
  71. package/dist/src/attribute.d.ts +0 -71
  72. package/dist/src/attribute.js +0 -502
  73. package/dist/src/attributes.d.ts +0 -109
  74. package/dist/src/attributes.js +0 -356
  75. package/dist/src/converter.d.ts +0 -33
  76. package/dist/src/converter.js +0 -134
  77. package/dist/src/converterFlags.d.ts +0 -87
  78. package/dist/src/converterFlags.js +0 -242
  79. package/dist/src/converterRule.d.ts +0 -77
  80. package/dist/src/converterRule.js +0 -209
  81. package/dist/src/extLink.d.ts +0 -43
  82. package/dist/src/extLink.js +0 -191
  83. package/dist/src/gallery.d.ts +0 -54
  84. package/dist/src/gallery.js +0 -139
  85. package/dist/src/heading.d.ts +0 -47
  86. package/dist/src/heading.js +0 -190
  87. package/dist/src/hidden.d.ts +0 -7
  88. package/dist/src/hidden.js +0 -23
  89. package/dist/src/html.d.ts +0 -65
  90. package/dist/src/html.js +0 -358
  91. package/dist/src/imageParameter.d.ts +0 -65
  92. package/dist/src/imageParameter.js +0 -257
  93. package/dist/src/imagemap.d.ts +0 -54
  94. package/dist/src/imagemap.js +0 -144
  95. package/dist/src/imagemapLink.d.ts +0 -31
  96. package/dist/src/imagemapLink.js +0 -93
  97. package/dist/src/index.d.ts +0 -143
  98. package/dist/src/index.js +0 -851
  99. package/dist/src/link/base.d.ts +0 -52
  100. package/dist/src/link/base.js +0 -228
  101. package/dist/src/link/category.d.ts +0 -13
  102. package/dist/src/link/category.js +0 -28
  103. package/dist/src/link/file.d.ts +0 -98
  104. package/dist/src/link/file.js +0 -272
  105. package/dist/src/link/galleryImage.d.ts +0 -32
  106. package/dist/src/link/galleryImage.js +0 -158
  107. package/dist/src/link/index.d.ts +0 -56
  108. package/dist/src/link/index.js +0 -133
  109. package/dist/src/magicLink.d.ts +0 -59
  110. package/dist/src/magicLink.js +0 -223
  111. package/dist/src/nested.d.ts +0 -43
  112. package/dist/src/nested.js +0 -105
  113. package/dist/src/nowiki/base.d.ts +0 -31
  114. package/dist/src/nowiki/base.js +0 -93
  115. package/dist/src/nowiki/comment.d.ts +0 -25
  116. package/dist/src/nowiki/comment.js +0 -76
  117. package/dist/src/nowiki/dd.d.ts +0 -8
  118. package/dist/src/nowiki/dd.js +0 -24
  119. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -18
  120. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  121. package/dist/src/nowiki/hr.d.ts +0 -5
  122. package/dist/src/nowiki/hr.js +0 -63
  123. package/dist/src/nowiki/index.d.ts +0 -16
  124. package/dist/src/nowiki/index.js +0 -27
  125. package/dist/src/nowiki/list.d.ts +0 -16
  126. package/dist/src/nowiki/list.js +0 -109
  127. package/dist/src/nowiki/listBase.d.ts +0 -5
  128. package/dist/src/nowiki/listBase.js +0 -61
  129. package/dist/src/nowiki/noinclude.d.ts +0 -10
  130. package/dist/src/nowiki/noinclude.js +0 -23
  131. package/dist/src/nowiki/quote.d.ts +0 -14
  132. package/dist/src/nowiki/quote.js +0 -131
  133. package/dist/src/onlyinclude.d.ts +0 -16
  134. package/dist/src/onlyinclude.js +0 -57
  135. package/dist/src/paramTag/index.d.ts +0 -37
  136. package/dist/src/paramTag/index.js +0 -77
  137. package/dist/src/paramTag/inputbox.d.ts +0 -8
  138. package/dist/src/paramTag/inputbox.js +0 -22
  139. package/dist/src/parameter.d.ts +0 -70
  140. package/dist/src/parameter.js +0 -264
  141. package/dist/src/pre.d.ts +0 -31
  142. package/dist/src/pre.js +0 -59
  143. package/dist/src/syntax.d.ts +0 -20
  144. package/dist/src/syntax.js +0 -86
  145. package/dist/src/table/base.d.ts +0 -27
  146. package/dist/src/table/base.js +0 -81
  147. package/dist/src/table/index.d.ts +0 -242
  148. package/dist/src/table/index.js +0 -497
  149. package/dist/src/table/td.d.ts +0 -86
  150. package/dist/src/table/td.js +0 -355
  151. package/dist/src/table/tr.d.ts +0 -32
  152. package/dist/src/table/tr.js +0 -58
  153. package/dist/src/table/trBase.d.ts +0 -53
  154. package/dist/src/table/trBase.js +0 -156
  155. package/dist/src/tagPair/ext.d.ts +0 -32
  156. package/dist/src/tagPair/ext.js +0 -203
  157. package/dist/src/tagPair/include.d.ts +0 -35
  158. package/dist/src/tagPair/include.js +0 -74
  159. package/dist/src/tagPair/index.d.ts +0 -27
  160. package/dist/src/tagPair/index.js +0 -128
  161. package/dist/src/transclude.d.ts +0 -167
  162. package/dist/src/transclude.js +0 -717
  163. package/dist/util/constants.js +0 -27
  164. package/dist/util/debug.js +0 -81
  165. package/dist/util/diff.js +0 -83
  166. package/dist/util/lint.js +0 -31
  167. package/dist/util/string.js +0 -60
  168. package/errors/README +0 -1
  169. package/printed/README +0 -1
@@ -1,497 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableToken = exports.Layout = exports.isRowEnd = 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
- * @param {Token} cell 表格单元格
16
- */
17
- const isRowEnd = ({ type }) => type === 'tr' || type === 'table-syntax';
18
- exports.isRowEnd = isRowEnd;
19
- /** @extends {Array<TableCoords[]>} */
20
- class Layout extends Array {
21
- /* NOT FOR BROWSER */
22
- /** 打印表格布局 */
23
- print() {
24
- const hBorders = (0, debug_1.emptyArray)(this.length + 1, i => {
25
- const prev = this[i - 1] ?? [], next = this[i] ?? [];
26
- return (0, debug_1.emptyArray)(Math.max(prev.length, next.length), j => prev[j] !== next[j]);
27
- }), vBorders = this.map(cur => (0, debug_1.emptyArray)(cur.length + 1, j => cur[j - 1] !== cur[j]));
28
- let out = '';
29
- for (let i = 0; i <= this.length; i++) {
30
- const hBorder = hBorders[i].map(Number), vBorderTop = (vBorders[i - 1] ?? []).map(Number), vBorderBottom = (vBorders[i] ?? []).map(Number),
31
- // eslint-disable-next-line no-sparse-arrays
32
- border = [' ', , , '┌', , '┐', '─', '┬', , '│', '└', '├', '┘', '┤', '┴', '┼'];
33
- for (let j = 0; j <= hBorder.length; j++) {
34
- const bit = (vBorderTop[j] << 3) + (vBorderBottom[j] << 0)
35
- + (hBorder[j - 1] << 2) + (hBorder[j] << 1);
36
- out += `${border[bit]}${hBorder[j] ? '─' : ' '}`;
37
- }
38
- out += '\n';
39
- }
40
- console.log(out.slice(0, -1));
41
- }
42
- }
43
- exports.Layout = Layout;
44
- /**
45
- * 表格
46
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
47
- */
48
- class TableToken extends trBase_1.TrBaseToken {
49
- type = 'table';
50
- /* NOT FOR BROWSER END */
51
- /** 表格是否闭合 */
52
- get closed() {
53
- return this.lastChild.type === 'table-syntax';
54
- }
55
- /* NOT FOR BROWSER */
56
- set closed(closed) {
57
- if (closed && !this.closed) {
58
- this.close(this.closest('parameter-value') ? '\n{{!}}}' : '\n|}');
59
- }
60
- }
61
- /* NOT FOR BROWSER END */
62
- /**
63
- * @param syntax 表格语法
64
- * @param attr 表格属性
65
- */
66
- constructor(syntax, attr, config = index_1.default.getConfig(), accum = []) {
67
- super(/^(?:\{\||\{\{\{\s*!\s*\}\}|\{\{\s*\(!\s*\}\})$/u, syntax, attr, config, accum, {
68
- Token: 2, SyntaxToken: [0, -1], AttributesToken: 1, TdToken: '2:', TrToken: '2:',
69
- });
70
- }
71
- /** @override */
72
- lint(start = this.getAbsoluteIndex(), re) {
73
- const errors = super.lint(start, re);
74
- if (!this.closed) {
75
- errors.push((0, lint_1.generateForChild)(this.firstChild, { start }, 'unclosed-table', index_1.default.msg('unclosed $1', 'table')));
76
- }
77
- const layout = this.getLayout(), { length } = layout;
78
- if (length > 1) {
79
- let low = 1, high = Infinity, j = 0;
80
- for (; j < length; j++) {
81
- const row = layout[j], max = row.length;
82
- if (max < low) {
83
- break;
84
- }
85
- else if (max < high) {
86
- high = max;
87
- }
88
- const { colspan } = this.getNthCell(row[row.length - 1]), min = max - colspan + 1;
89
- if (min > high) {
90
- break;
91
- }
92
- else if (min > low) {
93
- low = min;
94
- }
95
- }
96
- if (j < length) {
97
- const e = (0, lint_1.generateForChild)(this.getNthRow(j), { start }, 'table-layout', 'inconsistent table layout', 'warning');
98
- e.startIndex++;
99
- e.startLine++;
100
- e.startCol = 0;
101
- errors.push(e);
102
- }
103
- }
104
- return errors;
105
- }
106
- /**
107
- * 闭合表格语法
108
- * @param syntax 表格结尾语法
109
- * @param halfParsed
110
- */
111
- close(syntax = '\n|}', halfParsed) {
112
- const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed ? [syntax] : index_1.default.parse(syntax, this.getAttribute('include'), 2, config).childNodes;
113
- if (this.lastChild.type !== 'table-syntax') {
114
- const token = debug_1.Shadow.run(() => super.insertAt(new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum, {
115
- 'Stage-1': ':', '!ExtToken': '', TranscludeToken: ':',
116
- })));
117
- if (!halfParsed) {
118
- token.afterBuild();
119
- }
120
- }
121
- this.lastChild.replaceChildren(...inner);
122
- }
123
- /**
124
- * 获取表格布局
125
- * @param stop 中止条件
126
- * @param stop.row 中止行
127
- * @param stop.column 中止列
128
- * @param stop.x 中止行
129
- * @param stop.y 中止列
130
- */
131
- getLayout(stop) {
132
- const rows = this.getAllRows(), { length } = rows, layout = new Layout(...(0, debug_1.emptyArray)(length, () => []));
133
- for (let i = 0; i < length; i++) {
134
- /* NOT FOR BROWSER */
135
- if (i > (stop?.row ?? stop?.y ?? NaN)) {
136
- break;
137
- }
138
- /* NOT FOR BROWSER END */
139
- const rowLayout = layout[i];
140
- let j = 0, k = 0, last;
141
- for (const cell of rows[i].childNodes.slice(2)) {
142
- if (cell.type === 'td') {
143
- if (cell.isIndependent()) {
144
- last = cell.subtype !== 'caption';
145
- }
146
- if (last) {
147
- const coords = { row: i, column: j }, { rowspan, colspan } = cell;
148
- j++;
149
- while (rowLayout[k]) {
150
- k++;
151
- }
152
- /* NOT FOR BROWSER */
153
- if (i === stop?.row && j > stop.column) {
154
- layout[i][k] = coords;
155
- return layout;
156
- }
157
- /* NOT FOR BROWSER END */
158
- for (let y = i; y < Math.min(i + rowspan, length); y++) {
159
- for (let x = k; x < k + colspan; x++) {
160
- layout[y][x] = coords;
161
- }
162
- }
163
- k += colspan;
164
- /* NOT FOR BROWSER */
165
- if (i === stop?.y && k > (stop.x ?? NaN)) {
166
- return layout;
167
- }
168
- }
169
- }
170
- else if ((0, exports.isRowEnd)(cell)) {
171
- break;
172
- }
173
- }
174
- }
175
- return layout;
176
- }
177
- /** 获取所有行 */
178
- getAllRows() {
179
- return [
180
- ...super.getRowCount() ? [this] : [],
181
- ...this.childNodes.slice(1)
182
- .filter((child) => child.type === 'tr' && child.getRowCount() > 0),
183
- ];
184
- }
185
- /**
186
- * 获取指定坐标的单元格
187
- * @param coords 表格坐标
188
- */
189
- getNthCell(coords) {
190
- const rawCoords = coords.row === undefined
191
- ? this.toRawCoords(coords)
192
- : coords;
193
- return rawCoords && this.getNthRow(rawCoords.row, false, false)?.getNthCol(rawCoords.column);
194
- }
195
- getNthRow(n, force, insert) {
196
- const isRow = super.getRowCount();
197
- /* NOT FOR BROWSER */
198
- const nRows = this.getRowCount();
199
- n += n < 0 ? nRows : 0;
200
- /* NOT FOR BROWSER END */
201
- if (n === 0
202
- && (isRow
203
- || force && nRows === 0)) {
204
- return this;
205
- /* NOT FOR BROWSER */
206
- }
207
- else if (n < 0 || n > nRows || n === nRows && !insert) {
208
- throw new RangeError(`不存在第 ${n} 行!`);
209
- /* NOT FOR BROWSER END */
210
- }
211
- else if (isRow) {
212
- n--;
213
- }
214
- for (const child of this.childNodes.slice(2)) {
215
- if (child.type === 'tr' && child.getRowCount()) {
216
- n--;
217
- if (n < 0) {
218
- return child;
219
- }
220
- /* NOT FOR BROWSER */
221
- }
222
- else if (child.type === 'table-syntax') {
223
- return child;
224
- /* NOT FOR BROWSER END */
225
- }
226
- }
227
- return undefined;
228
- }
229
- /** @override */
230
- json() {
231
- const json = super.json();
232
- json['closed'] = this.closed;
233
- return json;
234
- }
235
- /* NOT FOR BROWSER */
236
- /**
237
- * @override
238
- * @param token 待插入的子节点
239
- * @param i 插入位置
240
- * @throws `SyntaxError` 表格的闭合部分非法
241
- */
242
- insertAt(token, i = this.length) {
243
- i += i < 0 ? this.length : 0;
244
- const previous = this.childNodes[i - 1];
245
- if (typeof token !== 'string' && token.type === 'td' && previous?.type === 'tr') {
246
- index_1.default.warn('改为将单元格插入当前行。');
247
- return previous.insertAt(token);
248
- }
249
- else if (i > 0 && token instanceof syntax_1.SyntaxToken && token.pattern !== closingPattern) {
250
- throw new SyntaxError(`表格的闭合部分不符合语法:${(0, string_1.noWrap)(String(token))}`);
251
- }
252
- return super.insertAt(token, i);
253
- }
254
- /** @override */
255
- getRowCount() {
256
- return super.getRowCount() + this.childNodes.filter(child => child.type === 'tr' && child.getRowCount()).length;
257
- }
258
- /** 获取下一行 */
259
- getNextRow() {
260
- return this.getNthRow(super.getRowCount() ? 1 : 0, false, false);
261
- }
262
- /** 打印表格布局 */
263
- printLayout() {
264
- require('../../addon/table');
265
- this.printLayout();
266
- }
267
- /**
268
- * 转换为渲染后的表格坐标
269
- * @param {TableCoords} coord wikitext中的表格坐标
270
- */
271
- toRenderedCoords(coord) {
272
- require('../../addon/table');
273
- return this.toRenderedCoords(coord);
274
- }
275
- /**
276
- * 转换为wikitext中的表格坐标
277
- * @param {TableRenderedCoords} coord 渲染后的表格坐标
278
- */
279
- toRawCoords(coord) {
280
- require('../../addon/table');
281
- return this.toRawCoords(coord);
282
- }
283
- /**
284
- * 获取完整行
285
- * @param y 行号
286
- */
287
- getFullRow(y) {
288
- require('../../addon/table');
289
- return this.getFullRow(y);
290
- }
291
- /**
292
- * 获取完整列
293
- * @param x 列号
294
- */
295
- getFullCol(x) {
296
- require('../../addon/table');
297
- return this.getFullCol(x);
298
- }
299
- /**
300
- * 设置行格式
301
- * @param y 行号
302
- * @param attr 表格属性
303
- * @param multiRow 是否对所有单元格设置,或是仅对行首单元格设置
304
- */
305
- formatTableRow(y, attr = {}, multiRow) {
306
- require('../../addon/table');
307
- this.formatTableRow(y, attr, multiRow);
308
- }
309
- /**
310
- * 设置列格式
311
- * @param x 列号
312
- * @param attr 表格属性
313
- * @param multiCol 是否对所有单元格设置,或是仅对行首单元格设置
314
- */
315
- formatTableCol(x, attr = {}, multiCol) {
316
- require('../../addon/table');
317
- this.formatTableCol(x, attr, multiCol);
318
- }
319
- /**
320
- * 填补表格行
321
- * @param y 行号
322
- * @param inner 填充内容
323
- * @param subtype 单元格类型
324
- * @param attr 表格属性
325
- */
326
- fillTableRow(y, inner, subtype = 'td', attr = {}) {
327
- require('../../addon/table');
328
- this.fillTableRow(y, inner, subtype, attr);
329
- }
330
- /**
331
- * 填补表格
332
- * @param inner 填充内容
333
- * @param subtype 单元格类型
334
- * @param attr 表格属性
335
- */
336
- fillTable(inner, subtype = 'td', attr = {}) {
337
- require('../../addon/table');
338
- this.fillTable(inner, subtype, attr);
339
- }
340
- /**
341
- * @override
342
- * @param inner 单元格内部wikitext
343
- * @param coords 单元格坐标
344
- * @param subtype 单元格类型
345
- * @param attr 单元格属性
346
- * @throws `RangeError` 指定的坐标不是单元格起始点
347
- */
348
- insertTableCell(inner, coords, subtype = 'td', attr = {}) {
349
- require('../../addon/table');
350
- return this.insertTableCell(inner, coords, subtype, attr);
351
- }
352
- /** @private */
353
- prependTableRow() {
354
- require('../../addon/table');
355
- return this.prependTableRow();
356
- }
357
- /**
358
- * 插入表格行
359
- * @param y 行号
360
- * @param attr 表格行属性
361
- * @param inner 内部wikitext
362
- * @param subtype 单元格类型
363
- * @param innerAttr 单元格属性
364
- */
365
- insertTableRow(y, attr = {}, inner, subtype = 'td', innerAttr = {}) {
366
- require('../../addon/table');
367
- return this.insertTableRow(y, attr, inner, subtype, innerAttr);
368
- }
369
- /**
370
- * 插入表格列
371
- * @param x 列号
372
- * @param inner 内部wikitext
373
- * @param subtype 单元格类型
374
- * @param attr 单元格属性
375
- * @throws `RangeError` 列号过大
376
- */
377
- insertTableCol(x, inner, subtype = 'td', attr = {}) {
378
- require('../../addon/table');
379
- this.insertTableCol(x, inner, subtype, attr);
380
- }
381
- /**
382
- * 移除表格行
383
- * @param y 行号
384
- */
385
- removeTableRow(y) {
386
- require('../../addon/table');
387
- return this.removeTableRow(y);
388
- }
389
- /**
390
- * 移除表格列
391
- * @param x 列号
392
- */
393
- removeTableCol(x) {
394
- require('../../addon/table');
395
- this.removeTableCol(x);
396
- }
397
- /**
398
- * 合并单元格
399
- * @param xlim 列范围
400
- * @param ylim 行范围
401
- * @throws `RangeError` 待合并区域与外侧区域有重叠
402
- */
403
- mergeCells(xlim, ylim) {
404
- require('../../addon/table');
405
- return this.mergeCells(xlim, ylim);
406
- }
407
- /** @private */
408
- split(coords, dirs) {
409
- require('../../addon/table');
410
- this.split(coords, dirs);
411
- }
412
- /**
413
- * 分裂成多行
414
- * @param coords 单元格坐标
415
- */
416
- splitIntoRows(coords) {
417
- require('../../addon/table');
418
- this.splitIntoRows(coords);
419
- }
420
- /**
421
- * 分裂成多列
422
- * @param coords 单元格坐标
423
- */
424
- splitIntoCols(coords) {
425
- require('../../addon/table');
426
- this.splitIntoCols(coords);
427
- }
428
- /**
429
- * 分裂成单元格
430
- * @param coords 单元格坐标
431
- */
432
- splitIntoCells(coords) {
433
- require('../../addon/table');
434
- this.splitIntoCells(coords);
435
- }
436
- /**
437
- * 复制一行并插入该行之前
438
- * @param row 行号
439
- */
440
- replicateTableRow(row) {
441
- require('../../addon/table');
442
- return this.replicateTableRow(row);
443
- }
444
- /**
445
- * 复制一列并插入该列之前
446
- * @param x 列号
447
- */
448
- replicateTableCol(x) {
449
- require('../../addon/table');
450
- return this.replicateTableCol(x);
451
- }
452
- /** @private */
453
- moveCol(x, reference, after) {
454
- require('../../addon/table');
455
- this.moveCol(x, reference, after);
456
- }
457
- /**
458
- * 移动表格行
459
- * @param y 行号
460
- * @param before 新位置
461
- * @throws `RangeError` 无法移动
462
- */
463
- moveTableRowBefore(y, before) {
464
- require('../../addon/table');
465
- return this.moveTableRowBefore(y, before);
466
- }
467
- /**
468
- * 移动表格行
469
- * @param y 行号
470
- * @param after 新位置
471
- * @throws `RangeError` 无法移动
472
- */
473
- moveTableRowAfter(y, after) {
474
- require('../../addon/table');
475
- return this.moveTableRowAfter(y, after);
476
- }
477
- /**
478
- * 移动表格列
479
- * @param x 列号
480
- * @param before 新位置
481
- */
482
- moveTableColBefore(x, before) {
483
- require('../../addon/table');
484
- this.moveTableColBefore(x, before);
485
- }
486
- /**
487
- * 移动表格列
488
- * @param x 列号
489
- * @param after 新位置
490
- */
491
- moveTableColAfter(x, after) {
492
- require('../../addon/table');
493
- this.moveTableColAfter(x, after);
494
- }
495
- }
496
- exports.TableToken = TableToken;
497
- constants_1.classes['TableToken'] = __filename;
@@ -1,86 +0,0 @@
1
- import Parser from '../../index';
2
- import { Token } from '../index';
3
- import { TableBaseToken } from './base';
4
- import type { LintError, AST } from '../../base';
5
- import type { SyntaxToken, AttributesToken, TrToken, TableToken } from '../../internal';
6
- export type TdSubtypes = 'td' | 'th' | 'caption';
7
- export interface TdSpanAttrs {
8
- rowspan?: number;
9
- colspan?: number;
10
- }
11
- declare type TdAttrGetter<T extends string> = T extends keyof TdSpanAttrs ? number : string | true | undefined;
12
- declare type TdAttrSetter<T extends string> = T extends keyof TdSpanAttrs ? number : string | boolean;
13
- export type TdAttrs = Record<string, string | true> & TdSpanAttrs;
14
- /**
15
- * `<td>`、`<th>`和`<caption>`
16
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
17
- */
18
- export declare abstract class TdToken extends TableBaseToken {
19
- #private;
20
- readonly type = "td";
21
- readonly childNodes: readonly [SyntaxToken, AttributesToken, Token];
22
- abstract get parentNode(): TrToken | TableToken | undefined;
23
- abstract get nextSibling(): this | TrToken | SyntaxToken | undefined;
24
- abstract get previousSibling(): Token | undefined;
25
- abstract get children(): [SyntaxToken, AttributesToken, Token];
26
- abstract get parentElement(): TrToken | TableToken | undefined;
27
- abstract get nextElementSibling(): this | TrToken | SyntaxToken | undefined;
28
- /** rowspan */
29
- get rowspan(): number;
30
- /** colspan */
31
- get colspan(): number;
32
- /** 单元格类型 */
33
- get subtype(): TdSubtypes;
34
- set subtype(subtype: TdSubtypes);
35
- set rowspan(rowspan: number);
36
- set colspan(colspan: number);
37
- /** 内部wikitext */
38
- get innerText(): string;
39
- set innerText(text: string);
40
- /**
41
- * @param syntax 单元格语法
42
- * @param inner 内部wikitext
43
- */
44
- constructor(syntax: string, inner?: string, config?: Parser.Config, accum?: Token[]);
45
- /** @override */
46
- text(): string;
47
- /** @override */
48
- lint(start?: number, re?: RegExp): LintError[];
49
- /** 是否位于行首 */
50
- isIndependent(): boolean;
51
- /**
52
- * @override
53
- * @param key 属性键
54
- */
55
- getAttr<T extends string>(key: T): TdAttrGetter<T>;
56
- /** @override */
57
- print(): string;
58
- /** @override */
59
- json(): AST;
60
- /** @override */
61
- cloneNode(): this;
62
- /** 改为独占一行 */
63
- independence(): void;
64
- /** @override */
65
- getAttrs(): TdAttrs;
66
- /**
67
- * @override
68
- * @param key 属性键
69
- * @param value 属性值
70
- * @param prop 属性对象
71
- */
72
- setAttr<T extends string>(key: T, value: TdAttrSetter<T>): void;
73
- setAttr(prop: Record<string, string | number | boolean>): void;
74
- /** @override */
75
- escape(): void;
76
- }
77
- /**
78
- * 创建新的单元格
79
- * @param inner 内部wikitext
80
- * @param subtype 单元格类型
81
- * @param attr 单元格属性
82
- * @param include 是否嵌入
83
- * @param config
84
- */
85
- export declare const createTd: (inner: string | Token, subtype?: TdSubtypes, attr?: TdAttrs, include?: boolean, config?: Parser.Config) => TdToken;
86
- export {};