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