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