wikiparser-node 1.16.4 → 1.16.5

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 (150) hide show
  1. package/README.md +1 -1
  2. package/bundle/bundle.es7.js +27 -27
  3. package/bundle/bundle.lsp.js +30 -30
  4. package/bundle/bundle.min.js +29 -29
  5. package/dist/addon/table.js +7 -4
  6. package/dist/addon/token.js +13 -7
  7. package/dist/addon/transclude.js +7 -5
  8. package/dist/base.d.mts +99 -30
  9. package/dist/base.d.ts +99 -30
  10. package/dist/index.d.ts +10 -4
  11. package/dist/index.js +59 -14
  12. package/dist/lib/attributes.js +2 -2
  13. package/dist/lib/element.d.ts +96 -42
  14. package/dist/lib/element.js +97 -45
  15. package/dist/lib/lsp.d.ts +64 -35
  16. package/dist/lib/lsp.js +99 -71
  17. package/dist/lib/node.d.ts +122 -53
  18. package/dist/lib/node.js +172 -75
  19. package/dist/lib/range.d.ts +83 -31
  20. package/dist/lib/range.js +83 -31
  21. package/dist/lib/ranges.d.ts +1 -1
  22. package/dist/lib/ranges.js +3 -2
  23. package/dist/lib/text.d.ts +40 -14
  24. package/dist/lib/text.js +47 -19
  25. package/dist/lib/title.d.ts +50 -16
  26. package/dist/lib/title.js +77 -36
  27. package/dist/mixin/attributesParent.d.ts +37 -21
  28. package/dist/mixin/attributesParent.js +0 -2
  29. package/dist/mixin/flagsParent.d.ts +38 -12
  30. package/dist/mixin/hidden.d.ts +0 -2
  31. package/dist/mixin/hidden.js +0 -2
  32. package/dist/mixin/magicLinkParent.d.ts +11 -5
  33. package/dist/mixin/singleLine.d.ts +0 -2
  34. package/dist/mixin/singleLine.js +3 -3
  35. package/dist/mixin/sol.d.ts +0 -2
  36. package/dist/mixin/sol.js +2 -3
  37. package/dist/mixin/syntax.d.ts +0 -2
  38. package/dist/mixin/syntax.js +0 -2
  39. package/dist/parser/braces.js +4 -2
  40. package/dist/parser/links.js +13 -7
  41. package/dist/parser/list.js +3 -1
  42. package/dist/parser/quotes.js +22 -2
  43. package/dist/parser/redirect.js +4 -1
  44. package/dist/src/arg.d.ts +19 -9
  45. package/dist/src/arg.js +34 -15
  46. package/dist/src/atom.d.ts +5 -1
  47. package/dist/src/atom.js +5 -1
  48. package/dist/src/attribute.d.ts +26 -8
  49. package/dist/src/attribute.js +30 -11
  50. package/dist/src/attributes.d.ts +50 -22
  51. package/dist/src/attributes.js +54 -26
  52. package/dist/src/converter.d.ts +4 -2
  53. package/dist/src/converter.js +12 -9
  54. package/dist/src/converterFlags.d.ts +45 -15
  55. package/dist/src/converterFlags.js +45 -15
  56. package/dist/src/converterRule.d.ts +30 -11
  57. package/dist/src/converterRule.js +46 -16
  58. package/dist/src/extLink.d.ts +6 -2
  59. package/dist/src/extLink.js +14 -11
  60. package/dist/src/gallery.d.ts +13 -9
  61. package/dist/src/gallery.js +35 -21
  62. package/dist/src/heading.d.ts +13 -7
  63. package/dist/src/heading.js +21 -11
  64. package/dist/src/hidden.d.ts +5 -1
  65. package/dist/src/hidden.js +7 -3
  66. package/dist/src/html.d.ts +11 -5
  67. package/dist/src/html.js +16 -7
  68. package/dist/src/imageParameter.d.ts +23 -11
  69. package/dist/src/imageParameter.js +22 -10
  70. package/dist/src/imagemap.d.ts +4 -4
  71. package/dist/src/imagemap.js +9 -5
  72. package/dist/src/imagemapLink.d.ts +3 -1
  73. package/dist/src/imagemapLink.js +3 -1
  74. package/dist/src/index.d.ts +65 -20
  75. package/dist/src/index.js +111 -39
  76. package/dist/src/link/base.d.ts +14 -6
  77. package/dist/src/link/base.js +40 -17
  78. package/dist/src/link/category.d.ts +7 -2
  79. package/dist/src/link/category.js +20 -4
  80. package/dist/src/link/file.d.ts +71 -23
  81. package/dist/src/link/file.js +100 -36
  82. package/dist/src/link/galleryImage.d.ts +8 -4
  83. package/dist/src/link/galleryImage.js +15 -8
  84. package/dist/src/link/index.d.ts +12 -4
  85. package/dist/src/link/index.js +15 -5
  86. package/dist/src/link/redirectTarget.d.ts +3 -2
  87. package/dist/src/link/redirectTarget.js +5 -3
  88. package/dist/src/magicLink.d.ts +24 -11
  89. package/dist/src/magicLink.js +36 -19
  90. package/dist/src/nested.d.ts +5 -3
  91. package/dist/src/nested.js +9 -6
  92. package/dist/src/nowiki/base.d.ts +4 -2
  93. package/dist/src/nowiki/base.js +6 -5
  94. package/dist/src/nowiki/comment.d.ts +6 -2
  95. package/dist/src/nowiki/comment.js +8 -3
  96. package/dist/src/nowiki/dd.d.ts +0 -3
  97. package/dist/src/nowiki/dd.js +0 -8
  98. package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
  99. package/dist/src/nowiki/doubleUnderscore.js +5 -1
  100. package/dist/src/nowiki/index.d.ts +5 -1
  101. package/dist/src/nowiki/index.js +5 -1
  102. package/dist/src/nowiki/list.d.ts +5 -1
  103. package/dist/src/nowiki/list.js +5 -1
  104. package/dist/src/nowiki/listBase.d.ts +15 -5
  105. package/dist/src/nowiki/listBase.js +40 -9
  106. package/dist/src/nowiki/noinclude.d.ts +5 -1
  107. package/dist/src/nowiki/noinclude.js +5 -1
  108. package/dist/src/nowiki/quote.d.ts +15 -8
  109. package/dist/src/nowiki/quote.js +32 -12
  110. package/dist/src/onlyinclude.d.ts +4 -2
  111. package/dist/src/onlyinclude.js +4 -2
  112. package/dist/src/paramTag/index.d.ts +1 -1
  113. package/dist/src/paramTag/index.js +1 -1
  114. package/dist/src/parameter.d.ts +24 -12
  115. package/dist/src/parameter.js +45 -27
  116. package/dist/src/pre.d.ts +1 -1
  117. package/dist/src/pre.js +1 -1
  118. package/dist/src/redirect.d.ts +2 -0
  119. package/dist/src/redirect.js +2 -0
  120. package/dist/src/syntax.d.ts +5 -1
  121. package/dist/src/syntax.js +5 -1
  122. package/dist/src/table/base.d.ts +5 -1
  123. package/dist/src/table/base.js +10 -3
  124. package/dist/src/table/index.d.ts +134 -66
  125. package/dist/src/table/index.js +149 -81
  126. package/dist/src/table/td.d.ts +18 -10
  127. package/dist/src/table/td.js +23 -15
  128. package/dist/src/table/tr.d.ts +13 -3
  129. package/dist/src/table/tr.js +14 -6
  130. package/dist/src/table/trBase.d.ts +28 -12
  131. package/dist/src/table/trBase.js +28 -18
  132. package/dist/src/tagPair/ext.d.ts +3 -1
  133. package/dist/src/tagPair/ext.js +10 -8
  134. package/dist/src/tagPair/include.d.ts +8 -2
  135. package/dist/src/tagPair/include.js +8 -2
  136. package/dist/src/tagPair/index.d.ts +6 -2
  137. package/dist/src/tagPair/index.js +6 -2
  138. package/dist/src/transclude.d.ts +102 -33
  139. package/dist/src/transclude.js +114 -42
  140. package/dist/util/debug.js +2 -7
  141. package/dist/util/html.js +1 -18
  142. package/dist/util/string.js +7 -1
  143. package/extensions/dist/base.js +25 -8
  144. package/extensions/dist/codejar.js +2 -1
  145. package/extensions/dist/lsp.js +5 -10
  146. package/extensions/es7/base.js +25 -8
  147. package/extensions/ui.css +1 -162
  148. package/i18n/zh-hans.json +1 -1
  149. package/i18n/zh-hant.json +1 -1
  150. package/package.json +3 -3
@@ -27,7 +27,11 @@ exports.isRowEnd = isRowEnd;
27
27
  /** @extends {Array<TableCoords[]>} */
28
28
  class Layout extends Array {
29
29
  /* NOT FOR BROWSER */
30
- /** 打印表格布局 */
30
+ /**
31
+ * Print the table layout
32
+ *
33
+ * 打印表格布局
34
+ */
31
35
  print() {
32
36
  const hBorders = emptyArray(this.length + 1, i => {
33
37
  const prev = this[i - 1] ?? [], next = this[i] ?? [];
@@ -50,15 +54,17 @@ class Layout extends Array {
50
54
  }
51
55
  exports.Layout = Layout;
52
56
  /**
57
+ * table
58
+ *
53
59
  * 表格
54
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
60
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
55
61
  */
56
62
  class TableToken extends trBase_1.TrBaseToken {
57
63
  /* NOT FOR BROWSER END */
58
64
  get type() {
59
65
  return 'table';
60
66
  }
61
- /** 表格是否闭合 */
67
+ /** whether the table is closed / 表格是否闭合 */
62
68
  get closed() {
63
69
  return this.lastChild.type === 'table-syntax';
64
70
  }
@@ -114,17 +120,19 @@ class TableToken extends trBase_1.TrBaseToken {
114
120
  return errors;
115
121
  }
116
122
  /**
123
+ * Close the table syntax
124
+ *
117
125
  * 闭合表格语法
118
- * @param syntax 表格结尾语法
126
+ * @param syntax syntax of the table end / 表格结尾语法
119
127
  * @param halfParsed
120
128
  */
121
129
  close(syntax = '\n|}', halfParsed) {
122
- const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed ? [syntax] : index_1.default.parse(syntax, this.getAttribute('include'), 2, config).childNodes;
130
+ const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed
131
+ ? [syntax]
132
+ : index_1.default.parse(syntax, this.getAttribute('include'), 2, config).childNodes;
123
133
  if (this.lastChild.type !== 'table-syntax') {
124
134
  debug_1.Shadow.run(() => {
125
- const token = new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum, {
126
- 'Stage-1': ':', '!ExtToken': '', TranscludeToken: ':',
127
- });
135
+ const token = new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum, { 'Stage-1': ':', '!ExtToken': '', TranscludeToken: ':' });
128
136
  super.insertAt(token);
129
137
  if (!halfParsed) {
130
138
  token.afterBuild();
@@ -134,12 +142,14 @@ class TableToken extends trBase_1.TrBaseToken {
134
142
  this.lastChild.replaceChildren(...inner);
135
143
  }
136
144
  /**
145
+ * Get the table layout
146
+ *
137
147
  * 获取表格布局
138
- * @param stop 中止条件
139
- * @param stop.row 中止行
140
- * @param stop.column 中止列
141
- * @param stop.x 中止行
142
- * @param stop.y 中止列
148
+ * @param stop stop condition / 中止条件
149
+ * @param stop.row stop at the row / 中止行
150
+ * @param stop.column stop at the column / 中止列
151
+ * @param stop.x stop at the row / 中止行
152
+ * @param stop.y stop at the column / 中止列
143
153
  */
144
154
  getLayout(stop) {
145
155
  const rows = this.getAllRows(), { length } = rows, layout = new Layout(...emptyArray(length, () => []));
@@ -186,7 +196,11 @@ class TableToken extends trBase_1.TrBaseToken {
186
196
  }
187
197
  return layout;
188
198
  }
189
- /** 获取所有行 */
199
+ /**
200
+ * Get all rows
201
+ *
202
+ * 获取所有行
203
+ */
190
204
  getAllRows() {
191
205
  return [
192
206
  ...super.getRowCount() ? [this] : [],
@@ -194,17 +208,6 @@ class TableToken extends trBase_1.TrBaseToken {
194
208
  .filter((child) => child.type === 'tr' && child.getRowCount() > 0),
195
209
  ];
196
210
  }
197
- /**
198
- * 获取指定坐标的单元格
199
- * @param coords 表格坐标
200
- */
201
- getNthCell(coords) {
202
- let rawCoords = coords;
203
- if (coords.row === undefined) {
204
- rawCoords = this.toRawCoords(coords);
205
- }
206
- return rawCoords && this.getNthRow(rawCoords.row, false, false)?.getNthCol(rawCoords.column);
207
- }
208
211
  getNthRow(n, force, insert) {
209
212
  const isRow = super.getRowCount();
210
213
  /* NOT FOR BROWSER */
@@ -225,31 +228,32 @@ class TableToken extends trBase_1.TrBaseToken {
225
228
  n--;
226
229
  }
227
230
  for (const child of this.childNodes.slice(2)) {
228
- if (child.type === 'tr' && child.getRowCount()) {
231
+ const { type } = child;
232
+ if (type === 'tr' && child.getRowCount()) {
229
233
  n--;
230
234
  if (n < 0) {
231
235
  return child;
232
236
  }
233
237
  /* NOT FOR BROWSER */
234
238
  }
235
- else if (child.type === 'table-syntax') {
239
+ else if (type === 'table-syntax') {
236
240
  return child;
237
241
  /* NOT FOR BROWSER END */
238
242
  }
239
243
  }
240
244
  return undefined;
241
245
  }
242
- /** @override */
243
- json() {
244
- const json = super.json();
246
+ /** @private */
247
+ json(_, start = this.getAbsoluteIndex()) {
248
+ const json = super.json(undefined, start);
245
249
  json['closed'] = this.closed;
246
250
  return json;
247
251
  }
248
252
  /* NOT FOR BROWSER */
249
253
  /**
250
254
  * @override
251
- * @param token 待插入的子节点
252
- * @param i 插入位置
255
+ * @param token node to be inserted / 待插入的子节点
256
+ * @param i position to be inserted at / 插入位置
253
257
  * @throws `SyntaxError` 表格的闭合部分非法
254
258
  */
255
259
  insertAt(token, i = this.length) {
@@ -268,83 +272,120 @@ class TableToken extends trBase_1.TrBaseToken {
268
272
  getRowCount() {
269
273
  return super.getRowCount() + this.childNodes.filter(child => child.type === 'tr' && child.getRowCount()).length;
270
274
  }
271
- /** 获取下一行 */
275
+ /**
276
+ * Get the next row
277
+ *
278
+ * 获取下一行
279
+ */
272
280
  getNextRow() {
273
281
  return this.getNthRow(super.getRowCount() ? 1 : 0, false, false);
274
282
  }
275
- /** 打印表格布局 */
283
+ /**
284
+ * Get the cell with the specified coordinates
285
+ *
286
+ * 获取指定坐标的单元格
287
+ * @param coords table coordinates / 表格坐标
288
+ */
289
+ getNthCell(coords) {
290
+ let rawCoords = coords;
291
+ if (coords.row === undefined) {
292
+ rawCoords = this.toRawCoords(coords);
293
+ }
294
+ return rawCoords && this.getNthRow(rawCoords.row, false, false)?.getNthCol(rawCoords.column);
295
+ }
296
+ /**
297
+ * Print the table layout
298
+ *
299
+ * 打印表格布局
300
+ */
276
301
  printLayout() {
277
302
  require('../../addon/table');
278
303
  this.printLayout();
279
304
  }
280
305
  /**
306
+ * Convert to table coordinates after rendering
307
+ *
281
308
  * 转换为渲染后的表格坐标
282
- * @param {TableCoords} coord wikitext中的表格坐标
309
+ * @param {TableCoords} coord table coordinates in wikitext / wikitext中的表格坐标
283
310
  */
284
311
  toRenderedCoords(coord) {
285
312
  require('../../addon/table');
286
313
  return this.toRenderedCoords(coord);
287
314
  }
288
315
  /**
316
+ * Convert to table coordinates in wikitext
317
+ *
289
318
  * 转换为wikitext中的表格坐标
290
- * @param {TableRenderedCoords} coord 渲染后的表格坐标
319
+ * @param {TableRenderedCoords} coord table coordinates after rendering / 渲染后的表格坐标
291
320
  */
292
321
  toRawCoords(coord) {
293
322
  require('../../addon/table');
294
323
  return this.toRawCoords(coord);
295
324
  }
296
325
  /**
326
+ * Get the full row
327
+ *
297
328
  * 获取完整行
298
- * @param y 行号
329
+ * @param y row number / 行号
299
330
  */
300
331
  getFullRow(y) {
301
332
  require('../../addon/table');
302
333
  return this.getFullRow(y);
303
334
  }
304
335
  /**
336
+ * Get the full column
337
+ *
305
338
  * 获取完整列
306
- * @param x 列号
339
+ * @param x column number / 列号
307
340
  */
308
341
  getFullCol(x) {
309
342
  require('../../addon/table');
310
343
  return this.getFullCol(x);
311
344
  }
312
345
  /**
346
+ * Format the row
347
+ *
313
348
  * 设置行格式
314
- * @param y 行号
315
- * @param attr 表格属性
316
- * @param multiRow 是否对所有单元格设置,或是仅对行首单元格设置
349
+ * @param y row number / 行号
350
+ * @param attr table attribute / 表格属性
351
+ * @param multiRow whether to format multi-row cells / 是否对所有单元格设置,或是仅对行首单元格设置
317
352
  */
318
353
  formatTableRow(y, attr, multiRow) {
319
354
  require('../../addon/table');
320
355
  this.formatTableRow(y, attr, multiRow);
321
356
  }
322
357
  /**
358
+ * Format the column
359
+ *
323
360
  * 设置列格式
324
- * @param x 列号
325
- * @param attr 表格属性
326
- * @param multiCol 是否对所有单元格设置,或是仅对行首单元格设置
361
+ * @param x column number / 列号
362
+ * @param attr table attribute / 表格属性
363
+ * @param multiCol whether to format multi-column cells / 是否对所有单元格设置,或是仅对行首单元格设置
327
364
  */
328
365
  formatTableCol(x, attr, multiCol) {
329
366
  require('../../addon/table');
330
367
  this.formatTableCol(x, attr, multiCol);
331
368
  }
332
369
  /**
370
+ * Fill the table row
371
+ *
333
372
  * 填补表格行
334
- * @param y 行号
335
- * @param inner 填充内容
336
- * @param subtype 单元格类型
337
- * @param attr 表格属性
373
+ * @param y row number / 行号
374
+ * @param inner content to fill / 填充内容
375
+ * @param subtype type of the cell / 单元格类型
376
+ * @param attr table attribute / 表格属性
338
377
  */
339
378
  fillTableRow(y, inner, subtype, attr) {
340
379
  require('../../addon/table');
341
380
  this.fillTableRow(y, inner, subtype, attr);
342
381
  }
343
382
  /**
383
+ * Fill the table
384
+ *
344
385
  * 填补表格
345
- * @param inner 填充内容
346
- * @param subtype 单元格类型
347
- * @param attr 表格属性
386
+ * @param inner content to fill / 填充内容
387
+ * @param subtype type of the cell / 单元格类型
388
+ * @param attr table attribute / 表格属性
348
389
  */
349
390
  fillTable(inner, subtype, attr) {
350
391
  require('../../addon/table');
@@ -360,23 +401,27 @@ class TableToken extends trBase_1.TrBaseToken {
360
401
  return this.prependTableRow();
361
402
  }
362
403
  /**
404
+ * Insert a table row
405
+ *
363
406
  * 插入表格行
364
- * @param y 行号
365
- * @param attr 表格行属性
366
- * @param inner 内部wikitext
367
- * @param subtype 单元格类型
368
- * @param innerAttr 单元格属性
407
+ * @param y row number / 行号
408
+ * @param attr table row attribute / 表格行属性
409
+ * @param inner inner wikitext / 内部wikitext
410
+ * @param subtype type of the cell / 单元格类型
411
+ * @param innerAttr cell attribute / 单元格属性
369
412
  */
370
413
  insertTableRow(y, attr, inner, subtype, innerAttr) {
371
414
  require('../../addon/table');
372
415
  return this.insertTableRow(y, attr, inner, subtype, innerAttr);
373
416
  }
374
417
  /**
418
+ * Insert a table column
419
+ *
375
420
  * 插入表格列
376
- * @param x 列号
377
- * @param inner 内部wikitext
378
- * @param subtype 单元格类型
379
- * @param attr 单元格属性
421
+ * @param x column number / 列号
422
+ * @param inner inner wikitext / 内部wikitext
423
+ * @param subtype type of the cell / 单元格类型
424
+ * @param attr cell attribute / 单元格属性
380
425
  * @throws `RangeError` 列号过大
381
426
  */
382
427
  insertTableCol(x, inner, subtype, attr) {
@@ -384,25 +429,31 @@ class TableToken extends trBase_1.TrBaseToken {
384
429
  this.insertTableCol(x, inner, subtype, attr);
385
430
  }
386
431
  /**
432
+ * Remove a table row
433
+ *
387
434
  * 移除表格行
388
- * @param y 行号
435
+ * @param y row number / 行号
389
436
  */
390
437
  removeTableRow(y) {
391
438
  require('../../addon/table');
392
439
  return this.removeTableRow(y);
393
440
  }
394
441
  /**
442
+ * Remove a table column
443
+ *
395
444
  * 移除表格列
396
- * @param x 列号
445
+ * @param x column number / 列号
397
446
  */
398
447
  removeTableCol(x) {
399
448
  require('../../addon/table');
400
449
  this.removeTableCol(x);
401
450
  }
402
451
  /**
452
+ * Marge cells
453
+ *
403
454
  * 合并单元格
404
- * @param xlim 列范围
405
- * @param ylim 行范围
455
+ * @param xlim column range / 列范围
456
+ * @param ylim row range / 行范围
406
457
  * @throws `RangeError` 待合并区域与外侧区域有重叠
407
458
  */
408
459
  mergeCells(xlim, ylim) {
@@ -415,40 +466,50 @@ class TableToken extends trBase_1.TrBaseToken {
415
466
  this.split(coords, dirs);
416
467
  }
417
468
  /**
469
+ * Split a cell into rows
470
+ *
418
471
  * 分裂成多行
419
- * @param coords 单元格坐标
472
+ * @param coords coordinates of the cell / 单元格坐标
420
473
  */
421
474
  splitIntoRows(coords) {
422
475
  require('../../addon/table');
423
476
  this.splitIntoRows(coords);
424
477
  }
425
478
  /**
479
+ * Split a cell into columns
480
+ *
426
481
  * 分裂成多列
427
- * @param coords 单元格坐标
482
+ * @param coords coordinates of the cell / 单元格坐标
428
483
  */
429
484
  splitIntoCols(coords) {
430
485
  require('../../addon/table');
431
486
  this.splitIntoCols(coords);
432
487
  }
433
488
  /**
489
+ * Split a cell into cells
490
+ *
434
491
  * 分裂成单元格
435
- * @param coords 单元格坐标
492
+ * @param coords coordinates of the cell / 单元格坐标
436
493
  */
437
494
  splitIntoCells(coords) {
438
495
  require('../../addon/table');
439
496
  this.splitIntoCells(coords);
440
497
  }
441
498
  /**
499
+ * Replicate a row and insert the result before the row
500
+ *
442
501
  * 复制一行并插入该行之前
443
- * @param row 行号
502
+ * @param row row number / 行号
444
503
  */
445
504
  replicateTableRow(row) {
446
505
  require('../../addon/table');
447
506
  return this.replicateTableRow(row);
448
507
  }
449
508
  /**
509
+ * Replicate a column and insert the result before the column
510
+ *
450
511
  * 复制一列并插入该列之前
451
- * @param x 列号
512
+ * @param x column number / 列号
452
513
  */
453
514
  replicateTableCol(x) {
454
515
  require('../../addon/table');
@@ -460,9 +521,11 @@ class TableToken extends trBase_1.TrBaseToken {
460
521
  this.moveCol(x, reference, after);
461
522
  }
462
523
  /**
524
+ * Move a table row
525
+ *
463
526
  * 移动表格行
464
- * @param y 行号
465
- * @param before 新位置
527
+ * @param y row number / 行号
528
+ * @param before new position / 新位置
466
529
  * @throws `RangeError` 无法移动
467
530
  */
468
531
  moveTableRowBefore(y, before) {
@@ -470,9 +533,11 @@ class TableToken extends trBase_1.TrBaseToken {
470
533
  return this.moveTableRowBefore(y, before);
471
534
  }
472
535
  /**
536
+ * Move a table row
537
+ *
473
538
  * 移动表格行
474
- * @param y 行号
475
- * @param after 新位置
539
+ * @param y row number / 行号
540
+ * @param after new position / 新位置
476
541
  * @throws `RangeError` 无法移动
477
542
  */
478
543
  moveTableRowAfter(y, after) {
@@ -480,18 +545,22 @@ class TableToken extends trBase_1.TrBaseToken {
480
545
  return this.moveTableRowAfter(y, after);
481
546
  }
482
547
  /**
548
+ * Move a table column
549
+ *
483
550
  * 移动表格列
484
- * @param x 列号
485
- * @param before 新位置
551
+ * @param x column number / 列号
552
+ * @param before new position / 新位置
486
553
  */
487
554
  moveTableColBefore(x, before) {
488
555
  require('../../addon/table');
489
556
  this.moveTableColBefore(x, before);
490
557
  }
491
558
  /**
559
+ * Move a table column
560
+ *
492
561
  * 移动表格列
493
- * @param x 列号
494
- * @param after 新位置
562
+ * @param x column number / 列号
563
+ * @param after new position / 新位置
495
564
  */
496
565
  moveTableColAfter(x, after) {
497
566
  require('../../addon/table');
@@ -504,10 +573,9 @@ class TableToken extends trBase_1.TrBaseToken {
504
573
  * @param token 表格或表格行
505
574
  */
506
575
  const filter = (token) => token.childNodes.filter((0, debug_1.isToken)('table-inter'));
507
- const { childNodes } = this, tr = childNodes.filter((0, debug_1.isToken)('tr')), newOpt = { ...opt, nowrap: true },
508
- // eslint-disable-next-line es-x/no-array-prototype-flat
509
- inter = [this, ...tr].flatMap(filter).map(token => token.toHtmlInternal(newOpt).trim()).join(' ');
510
- return `${inter}<table${childNodes[1].toHtmlInternal()}>${opt?.nowrap ? ' ' : '\n'}<tbody>${super.toHtmlInternal(opt)}${(0, html_1.html)(tr, '', opt)}</tbody></table>`;
576
+ const { childNodes } = this, tr = childNodes.filter((0, debug_1.isToken)('tr')), newOpt = { ...opt, nowrap: true };
577
+ return `${[this, ...tr].flatMap(filter) // eslint-disable-line es-x/no-array-prototype-flat
578
+ .map(token => token.toHtmlInternal(newOpt).trim()).join(' ')}<table${childNodes[1].toHtmlInternal()}>${opt?.nowrap ? ' ' : '\n'}<tbody>${super.toHtmlInternal(opt)}${(0, html_1.html)(tr, '', opt)}</tbody></table>`;
511
579
  }
512
580
  }
513
581
  exports.TableToken = TableToken;
@@ -12,7 +12,9 @@ declare type TdAttrGetter<T extends string> = T extends keyof TdSpanAttrs ? numb
12
12
  declare type TdAttrSetter<T extends string> = T extends keyof TdSpanAttrs ? number : string | boolean;
13
13
  export type TdAttrs = Record<string, string | true> & TdSpanAttrs;
14
14
  /**
15
- * `<td>`、`<th>`和`<caption>`
15
+ * `<td>`, `<th>` or `<caption>`
16
+ *
17
+ * `<td>`、`<th>`或`<caption>`
16
18
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
17
19
  */
18
20
  export declare abstract class TdToken extends TableBaseToken {
@@ -29,12 +31,12 @@ export declare abstract class TdToken extends TableBaseToken {
29
31
  get rowspan(): number;
30
32
  /** colspan */
31
33
  get colspan(): number;
32
- /** 单元格类型 */
34
+ /** cell type / 单元格类型 */
33
35
  get subtype(): TdSubtypes;
34
36
  set subtype(subtype: TdSubtypes);
35
37
  set rowspan(rowspan: number);
36
38
  set colspan(colspan: number);
37
- /** 内部wikitext */
39
+ /** inner wikitext / 内部wikitext */
38
40
  get innerText(): string;
39
41
  set innerText(text: string);
40
42
  /**
@@ -42,20 +44,26 @@ export declare abstract class TdToken extends TableBaseToken {
42
44
  * @param inner 内部wikitext
43
45
  */
44
46
  constructor(syntax: string, inner?: string, config?: Parser.Config, accum?: Token[]);
45
- /** 是否位于行首 */
47
+ /**
48
+ * Check if the cell is at the beginning of a line
49
+ *
50
+ * 是否位于行首
51
+ */
46
52
  isIndependent(): boolean;
47
53
  getAttr<T extends string>(key: T): TdAttrGetter<T>;
48
- /** @override */
49
- json(): AST;
50
54
  cloneNode(): this;
51
- /** 改为独占一行 */
55
+ /**
56
+ * Move to a new line
57
+ *
58
+ * 改为独占一行
59
+ */
52
60
  independence(): void;
53
61
  getAttrs(): TdAttrs;
54
62
  /**
55
63
  * @override
56
- * @param key 属性键
57
- * @param value 属性值
58
- * @param prop 属性对象
64
+ * @param key attribute name / 属性键
65
+ * @param value attribute value / 属性值
66
+ * @param prop attribute object / 属性对象
59
67
  */
60
68
  setAttr<T extends string>(key: T, value: TdAttrSetter<T>): void;
61
69
  setAttr(prop: Record<string, string | number | boolean>): void;
@@ -47,7 +47,9 @@ const string_1 = require("../../util/string");
47
47
  const fixed_1 = require("../../mixin/fixed");
48
48
  /* NOT FOR BROWSER END */
49
49
  /**
50
- * `<td>`、`<th>`和`<caption>`
50
+ * `<td>`, `<th>` or `<caption>`
51
+ *
52
+ * `<td>`、`<th>`或`<caption>`
51
53
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
52
54
  */
53
55
  let TdToken = (() => {
@@ -80,7 +82,7 @@ let TdToken = (() => {
80
82
  get colspan() {
81
83
  return this.getAttr('colspan');
82
84
  }
83
- /** 单元格类型 */
85
+ /** cell type / 单元格类型 */
84
86
  get subtype() {
85
87
  return this.#getSyntax().subtype;
86
88
  }
@@ -94,7 +96,7 @@ let TdToken = (() => {
94
96
  set colspan(colspan) {
95
97
  this.setAttr('colspan', colspan);
96
98
  }
97
- /** 内部wikitext */
99
+ /** inner wikitext / 内部wikitext */
98
100
  get innerText() {
99
101
  return this.lastChild.text().trim();
100
102
  }
@@ -155,12 +157,10 @@ let TdToken = (() => {
155
157
  /* NOT FOR BROWSER */
156
158
  const str = previousSibling.lastChild.toString();
157
159
  result.escape ||= esc;
158
- result.correction = str.includes('\n') && debug_1.Shadow.run(() => {
159
- const config = this.getAttribute('config'), include = this.getAttribute('include');
160
- return new index_2.Token(str, config).parseOnce(0, include).parseOnce().parseOnce()
161
- .toString()
162
- .includes('\n');
163
- });
160
+ result.correction = str.includes('\n') && debug_1.Shadow.run(() => new index_2.Token(str, this.getAttribute('config'))
161
+ .parseOnce(0, this.getAttribute('include')).parseOnce().parseOnce()
162
+ .toString()
163
+ .includes('\n'));
164
164
  if (subtype === 'th' && result.subtype !== 'th') {
165
165
  result.subtype = 'th';
166
166
  result.correction = true;
@@ -235,7 +235,11 @@ let TdToken = (() => {
235
235
  }
236
236
  return errors;
237
237
  }
238
- /** 是否位于行首 */
238
+ /**
239
+ * Check if the cell is at the beginning of a line
240
+ *
241
+ * 是否位于行首
242
+ */
239
243
  isIndependent() {
240
244
  return this.firstChild.text().startsWith('\n');
241
245
  }
@@ -249,10 +253,10 @@ let TdToken = (() => {
249
253
  const { childNodes: [syntax, attr, inner] } = this;
250
254
  return `<span class="wpb-td">${syntax.print()}${attr.print()}${this.#innerSyntax}${inner.print()}</span>`;
251
255
  }
252
- /** @override */
253
- json() {
254
- const json = super.json();
255
- json['subtype'] = this.subtype;
256
+ /** @private */
257
+ json(_, start = this.getAbsoluteIndex()) {
258
+ const json = super.json(undefined, start);
259
+ Object.assign(json, { subtype: this.subtype, rowspan: this.rowspan, colspan: this.colspan });
256
260
  return json;
257
261
  }
258
262
  /* NOT FOR BROWSER */
@@ -285,7 +289,11 @@ let TdToken = (() => {
285
289
  this.setSyntax(subtype, escape);
286
290
  }
287
291
  }
288
- /** 改为独占一行 */
292
+ /**
293
+ * Move to a new line
294
+ *
295
+ * 改为独占一行
296
+ */
289
297
  independence() {
290
298
  if (!this.isIndependent()) {
291
299
  const { subtype, escape } = this.#getSyntax();
@@ -2,8 +2,10 @@ import { TrBaseToken } from './trBase';
2
2
  import type { Config } from '../../base';
3
3
  import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '../../internal';
4
4
  /**
5
+ * table row that contains the newline at the beginning but not at the end
6
+ *
5
7
  * 表格行,含开头的换行,不含结尾的换行
6
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
8
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
7
9
  */
8
10
  export declare abstract class TrToken extends TrBaseToken {
9
11
  #private;
@@ -23,8 +25,16 @@ export declare abstract class TrToken extends TrBaseToken {
23
25
  * @param attr 表格属性
24
26
  */
25
27
  constructor(syntax: string, attr?: string, config?: Config, accum?: Token[]);
26
- /** 获取下一行 */
28
+ /**
29
+ * Get the next row
30
+ *
31
+ * 获取下一行
32
+ */
27
33
  getNextRow(): TrToken | undefined;
28
- /** 获取前一行 */
34
+ /**
35
+ * Get the previous row
36
+ *
37
+ * 获取前一行
38
+ */
29
39
  getPreviousRow(): TrToken | undefined;
30
40
  }