@bhsd/codemirror-mediawiki 2.12.6 → 2.13.1
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.
- package/README.md +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/fold.d.ts +1 -0
- package/dist/main.min.js +15 -15
- package/dist/matchTag.d.ts +4 -4
- package/dist/mediawiki.d.ts +203 -0
- package/dist/mw.min.js +21 -23
- package/i18n/en.json +1 -12
- package/i18n/zh-hans.json +3 -1
- package/i18n/zh-hant.json +3 -1
- package/mediawiki.css +10 -5
- package/package.json +7 -5
package/dist/matchTag.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ declare interface TagMatchResult extends MatchResult {
|
|
|
9
9
|
end?: Tag;
|
|
10
10
|
}
|
|
11
11
|
declare class Tag {
|
|
12
|
-
type: TagType;
|
|
13
|
-
name: string;
|
|
14
|
-
first: SyntaxNode;
|
|
15
|
-
last: SyntaxNode;
|
|
12
|
+
readonly type: TagType;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly first: SyntaxNode;
|
|
15
|
+
readonly last: SyntaxNode;
|
|
16
16
|
get closing(): boolean;
|
|
17
17
|
get selfClosing(): boolean;
|
|
18
18
|
get from(): number;
|
package/dist/mediawiki.d.ts
CHANGED
|
@@ -4,6 +4,92 @@
|
|
|
4
4
|
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
5
5
|
*/
|
|
6
6
|
import { LanguageSupport } from '@codemirror/language';
|
|
7
|
+
import { Tag } from '@lezer/highlight';
|
|
8
|
+
import type { StreamParser, StringStream, TagStyle } from '@codemirror/language';
|
|
9
|
+
import type { CompletionSource, Completion } from '@codemirror/autocomplete';
|
|
10
|
+
declare const tokens: {
|
|
11
|
+
apostrophes: string;
|
|
12
|
+
comment: string;
|
|
13
|
+
doubleUnderscore: string;
|
|
14
|
+
em: string;
|
|
15
|
+
error: string;
|
|
16
|
+
extLink: string;
|
|
17
|
+
extLinkBracket: string;
|
|
18
|
+
extLinkProtocol: string;
|
|
19
|
+
extLinkText: string;
|
|
20
|
+
extTag: string;
|
|
21
|
+
extTagAttribute: string;
|
|
22
|
+
extTagBracket: string;
|
|
23
|
+
extTagName: string;
|
|
24
|
+
fileText: string;
|
|
25
|
+
freeExtLink: string;
|
|
26
|
+
freeExtLinkProtocol: string;
|
|
27
|
+
hr: string;
|
|
28
|
+
htmlEntity: string;
|
|
29
|
+
htmlTagAttribute: string;
|
|
30
|
+
htmlTagBracket: string;
|
|
31
|
+
htmlTagName: string;
|
|
32
|
+
imageParameter: string;
|
|
33
|
+
linkBracket: string;
|
|
34
|
+
linkDelimiter: string;
|
|
35
|
+
linkPageName: string;
|
|
36
|
+
linkText: string;
|
|
37
|
+
linkToSection: string;
|
|
38
|
+
list: string;
|
|
39
|
+
pageName: string;
|
|
40
|
+
parserFunction: string;
|
|
41
|
+
parserFunctionBracket: string;
|
|
42
|
+
parserFunctionDelimiter: string;
|
|
43
|
+
parserFunctionName: string;
|
|
44
|
+
redirect: string;
|
|
45
|
+
section: string;
|
|
46
|
+
sectionHeader: string;
|
|
47
|
+
signature: string;
|
|
48
|
+
skipFormatting: string;
|
|
49
|
+
strong: string;
|
|
50
|
+
tableBracket: string;
|
|
51
|
+
tableCaption: string;
|
|
52
|
+
tableDefinition: string;
|
|
53
|
+
tableDelimiter: string;
|
|
54
|
+
tableDelimiter2: string;
|
|
55
|
+
template: string;
|
|
56
|
+
templateArgumentName: string;
|
|
57
|
+
templateBracket: string;
|
|
58
|
+
templateDelimiter: string;
|
|
59
|
+
templateName: string;
|
|
60
|
+
templateVariable: string;
|
|
61
|
+
templateVariableBracket: string;
|
|
62
|
+
templateVariableDelimiter: string;
|
|
63
|
+
templateVariableName: string;
|
|
64
|
+
};
|
|
65
|
+
declare type Style = string | [string];
|
|
66
|
+
declare type Tokenizer<T = Style> = (stream: StringStream, state: State) => T;
|
|
67
|
+
declare type TagName = keyof typeof tokens;
|
|
68
|
+
declare type NestCount = 'nTemplate' | 'nExt' | 'nVar' | 'nLink' | 'nExtLink';
|
|
69
|
+
declare interface Nesting extends Record<NestCount, number> {
|
|
70
|
+
extName: string | false;
|
|
71
|
+
extState: object | false;
|
|
72
|
+
}
|
|
73
|
+
declare interface State extends Nesting {
|
|
74
|
+
tokenize: Tokenizer;
|
|
75
|
+
readonly stack: Tokenizer[];
|
|
76
|
+
readonly inHtmlTag: string[];
|
|
77
|
+
extMode: StreamParser<object> | false;
|
|
78
|
+
lbrack: boolean | undefined;
|
|
79
|
+
bold: boolean;
|
|
80
|
+
italic: boolean;
|
|
81
|
+
dt: Partial<Nesting> & {
|
|
82
|
+
n: number;
|
|
83
|
+
};
|
|
84
|
+
redirect: boolean;
|
|
85
|
+
}
|
|
86
|
+
declare type ExtState = Omit<State, 'dt'> & Partial<Pick<State, 'dt'>>;
|
|
87
|
+
declare interface Token {
|
|
88
|
+
pos: number;
|
|
89
|
+
readonly string: string;
|
|
90
|
+
style: Style;
|
|
91
|
+
readonly state: State;
|
|
92
|
+
}
|
|
7
93
|
export type ApiSuggestions = [string, string?][];
|
|
8
94
|
/**
|
|
9
95
|
* 获取维基链接建议
|
|
@@ -27,6 +113,122 @@ export interface MwConfig {
|
|
|
27
113
|
linkSuggest?: ApiSuggest;
|
|
28
114
|
paramSuggest?: ApiSuggest;
|
|
29
115
|
}
|
|
116
|
+
declare const enum TableCell {
|
|
117
|
+
Td = 0,
|
|
118
|
+
Th = 1,
|
|
119
|
+
Caption = 2
|
|
120
|
+
}
|
|
121
|
+
/** Adapted from the original CodeMirror 5 stream parser by Pavel Astakhov */
|
|
122
|
+
export declare class MediaWiki {
|
|
123
|
+
#private;
|
|
124
|
+
/** 已解析的节点 */
|
|
125
|
+
readonly readyTokens: Token[];
|
|
126
|
+
/** 当前起始位置 */
|
|
127
|
+
oldToken: Token | null;
|
|
128
|
+
/** 可能需要回滚的`'''` */
|
|
129
|
+
mark: number | null;
|
|
130
|
+
readonly config: MwConfig;
|
|
131
|
+
firstSingleLetterWord: number | null;
|
|
132
|
+
firstMultiLetterWord: number | null;
|
|
133
|
+
firstSpace: number | null;
|
|
134
|
+
readonly tokenTable: {
|
|
135
|
+
[x: string]: Tag;
|
|
136
|
+
};
|
|
137
|
+
readonly hiddenTable: Record<string, Tag>;
|
|
138
|
+
readonly permittedHtmlTags: Set<string>;
|
|
139
|
+
readonly implicitlyClosedHtmlTags: Set<string>;
|
|
140
|
+
readonly urlProtocols: RegExp;
|
|
141
|
+
readonly fileRegex: RegExp;
|
|
142
|
+
readonly nsRegex: RegExp;
|
|
143
|
+
readonly redirectRegex: RegExp;
|
|
144
|
+
readonly imgRegex: RegExp;
|
|
145
|
+
readonly functionSynonyms: Completion[];
|
|
146
|
+
readonly doubleUnderscore: Completion[];
|
|
147
|
+
readonly extTags: Completion[];
|
|
148
|
+
readonly htmlTags: Completion[];
|
|
149
|
+
readonly protocols: Completion[];
|
|
150
|
+
readonly imgKeys: Completion[];
|
|
151
|
+
readonly htmlAttrs: Completion[];
|
|
152
|
+
readonly elementAttrs: Map<string | undefined, Completion[]>;
|
|
153
|
+
readonly extAttrs: Map<string, Completion[]>;
|
|
154
|
+
constructor(config: MwConfig);
|
|
155
|
+
/**
|
|
156
|
+
* Dynamically register a token in CodeMirror.
|
|
157
|
+
* This is solely for use by this.addTag() and CodeMirrorModeMediaWiki.makeLocalStyle().
|
|
158
|
+
*
|
|
159
|
+
* @param token
|
|
160
|
+
* @param hidden Whether the token is not highlighted
|
|
161
|
+
* @param parent
|
|
162
|
+
*/
|
|
163
|
+
addToken(token: string, hidden?: boolean, parent?: Tag): void;
|
|
164
|
+
/**
|
|
165
|
+
* Register the ground tokens. These aren't referenced directly in the StreamParser, nor do
|
|
166
|
+
* they have a parent Tag, so we don't need them as constants like we do for other tokens.
|
|
167
|
+
* See this.makeLocalStyle() for how these tokens are used.
|
|
168
|
+
*/
|
|
169
|
+
registerGroundTokens(): void;
|
|
170
|
+
/**
|
|
171
|
+
* This defines the actual CSS class assigned to each tag/token.
|
|
172
|
+
*
|
|
173
|
+
* @see https://codemirror.net/docs/ref/#language.TagStyle
|
|
174
|
+
*/
|
|
175
|
+
getTagStyles(): TagStyle[];
|
|
176
|
+
makeFullStyle(style: Style, state: ExtState): string;
|
|
177
|
+
makeTagStyle(tag: TagName, state: State, endGround?: NestCount): [string];
|
|
178
|
+
makeStyle(style: string, state: ExtState, endGround?: NestCount): [string];
|
|
179
|
+
makeLocalTagStyle(tag: TagName, state: State, endGround?: NestCount): string;
|
|
180
|
+
makeLocalStyle(style: string, state: ExtState, endGround?: NestCount): string;
|
|
181
|
+
inStr(str: string, tag: TagName | false, errorTag?: TagName): Tokenizer;
|
|
182
|
+
/**
|
|
183
|
+
* @todo 添加stage参数
|
|
184
|
+
* @ignore
|
|
185
|
+
*/
|
|
186
|
+
eatWikiText(style: string): Tokenizer;
|
|
187
|
+
eatApostrophes(obj: Pick<State, 'bold' | 'italic'>): Tokenizer<string | false>;
|
|
188
|
+
eatExternalLinkProtocol(chars: string, free?: boolean): Tokenizer;
|
|
189
|
+
inExternalLink(text?: boolean): Tokenizer;
|
|
190
|
+
get eatFreeExternalLink(): Tokenizer;
|
|
191
|
+
inLink(file: boolean, section?: boolean): Tokenizer;
|
|
192
|
+
inLinkText(file: boolean): Tokenizer;
|
|
193
|
+
toEatImageParameter(stream: StringStream, state: State): void;
|
|
194
|
+
eatList(stream: StringStream, state: State): string;
|
|
195
|
+
eatDoubleUnderscore(style: string): Tokenizer;
|
|
196
|
+
get eatStartTable(): Tokenizer;
|
|
197
|
+
inTableDefinition(tr?: boolean): Tokenizer;
|
|
198
|
+
get inTable(): Tokenizer;
|
|
199
|
+
inTableCell(needAttr: boolean, type: TableCell, firstLine?: boolean): Tokenizer;
|
|
200
|
+
inSectionHeader(str: string): Tokenizer;
|
|
201
|
+
get inComment(): Tokenizer;
|
|
202
|
+
eatTagName(name: string, isCloseTag?: boolean, isHtmlTag?: boolean): Tokenizer;
|
|
203
|
+
inHtmlTagAttribute(name: string): Tokenizer;
|
|
204
|
+
inExtTagAttribute(name: string): Tokenizer;
|
|
205
|
+
eatExtTagArea(name: string): Tokenizer;
|
|
206
|
+
inExtTokens(origString: string): Tokenizer;
|
|
207
|
+
inVariable(pos: number): Tokenizer;
|
|
208
|
+
inParserFunctionName(invoke?: boolean): Tokenizer;
|
|
209
|
+
inTemplatePageName(haveEaten?: boolean, anchor?: boolean): Tokenizer;
|
|
210
|
+
inParserFunctionArgument(module?: boolean): Tokenizer;
|
|
211
|
+
inTemplateArgument(expectName?: boolean): Tokenizer;
|
|
212
|
+
eatEntity(stream: StringStream, style: string): string;
|
|
213
|
+
get eatNowiki(): Tokenizer<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Remembers position and status for rollbacking.
|
|
216
|
+
* It is needed for changing from bold to italic with apostrophes before it, if required.
|
|
217
|
+
*
|
|
218
|
+
* @see https://phabricator.wikimedia.org/T108455
|
|
219
|
+
* @param stream
|
|
220
|
+
*/
|
|
221
|
+
prepareItalicForCorrection(stream: StringStream): void;
|
|
222
|
+
/**
|
|
223
|
+
* main entry
|
|
224
|
+
*
|
|
225
|
+
* @see https://codemirror.net/docs/ref/#language.StreamParser
|
|
226
|
+
*/
|
|
227
|
+
get mediawiki(): StreamParser<State>;
|
|
228
|
+
get 'text/mediawiki'(): StreamParser<State>;
|
|
229
|
+
/** 自动补全魔术字和标签名 */
|
|
230
|
+
get completionSource(): CompletionSource;
|
|
231
|
+
}
|
|
30
232
|
/**
|
|
31
233
|
* Gets a LanguageSupport instance for the MediaWiki mode.
|
|
32
234
|
* @param config Configuration for the MediaWiki mode
|
|
@@ -37,3 +239,4 @@ export declare const mediawiki: (config: MwConfig) => LanguageSupport;
|
|
|
37
239
|
* @param config Configuration for the MediaWiki mode
|
|
38
240
|
*/
|
|
39
241
|
export declare const html: (config: MwConfig) => LanguageSupport;
|
|
242
|
+
export {};
|