@bhsd/codemirror-mediawiki 3.11.0 → 3.11.2
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.js +2 -13
- package/dist/javascript-globals.d.ts +1 -0
- package/dist/javascript-globals.js +78 -0
- package/dist/javascript.js +18 -10
- package/dist/linter.d.ts +6 -1
- package/dist/linter.js +5 -3
- package/dist/lintsource.js +34 -8
- package/dist/main.min.js +33 -28
- package/dist/mediawiki.d.ts +8 -0
- package/dist/mediawiki.js +8 -1
- package/dist/mw.min.js +36 -31
- package/dist/openLinks.js +5 -9
- package/dist/util.d.ts +0 -8
- package/dist/util.js +0 -7
- package/dist/wiki.min.js +36 -31
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +20 -20
package/dist/openLinks.js
CHANGED
|
@@ -2,8 +2,7 @@ import { EditorView } from '@codemirror/view';
|
|
|
2
2
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
3
3
|
import { tokens } from './config.js';
|
|
4
4
|
import { isMac } from './constants.js';
|
|
5
|
-
|
|
6
|
-
const tags = ['extLinkProtocol', 'extLink', 'freeExtLinkProtocol', 'freeExtLink', 'magicLink', 'pageName'], links = ['extlink-protocol', 'extlink', 'free-extlink-protocol', 'free-extlink', 'magic-link'], pagename = '.cm-mw-pagename', wikiLinks = [
|
|
5
|
+
const links = ['extlink-protocol', 'extlink', 'free-extlink-protocol', 'free-extlink', 'magic-link'], pagename = '.cm-mw-pagename', wikiLinks = [
|
|
7
6
|
'template-name',
|
|
8
7
|
'link-pagename',
|
|
9
8
|
`parserfunction${pagename}`,
|
|
@@ -36,21 +35,18 @@ export const mouseEventListener = (e, view, isbnParser, titleParser) => {
|
|
|
36
35
|
|| !(e.target instanceof Element && getComputedStyle(e.target).textDecorationLine === 'underline')) {
|
|
37
36
|
return undefined;
|
|
38
37
|
}
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
38
|
+
const posAndSide = view.posAndSideAtCoords(e);
|
|
39
|
+
if (!posAndSide) {
|
|
41
40
|
return undefined;
|
|
42
41
|
}
|
|
43
|
-
const { state } = view, tree = ensureSyntaxTree(state,
|
|
42
|
+
const { pos, assoc } = posAndSide, { state } = view, tree = ensureSyntaxTree(state, pos);
|
|
44
43
|
if (!tree) {
|
|
45
44
|
return undefined;
|
|
46
45
|
}
|
|
47
|
-
let node = tree.resolve(
|
|
46
|
+
let node = tree.resolve(pos, assoc);
|
|
48
47
|
if (node.name.includes(tokens.linkToSection)) {
|
|
49
48
|
node = node.prevSibling;
|
|
50
49
|
}
|
|
51
|
-
else if (node.to === position && !hasTag(new Set(node.name.split('_')), tags)) {
|
|
52
|
-
node = tree.resolve(position, 1);
|
|
53
|
-
}
|
|
54
50
|
const { name, from, to } = node;
|
|
55
51
|
if (name.includes('-extlink-protocol')) {
|
|
56
52
|
return wrapURL(state.sliceDoc(from, node.nextSibling.to));
|
package/dist/util.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { Text, EditorState, SelectionRange } from '@codemirror/state';
|
|
|
3
3
|
import type { SyntaxNode } from '@lezer/common';
|
|
4
4
|
import type { Position } from 'vscode-languageserver-types';
|
|
5
5
|
import type { ConfigGetter } from '@bhsd/browser';
|
|
6
|
-
import type { TagName } from './config';
|
|
7
6
|
/**
|
|
8
7
|
* 转义HTML字符串
|
|
9
8
|
* @param text 原字符串
|
|
@@ -56,13 +55,6 @@ export declare const isTemplate: (node: SyntaxNode) => boolean;
|
|
|
56
55
|
* @test
|
|
57
56
|
*/
|
|
58
57
|
export declare const findTemplateName: (state: EditorState, node: SyntaxNode) => [string | null, string];
|
|
59
|
-
/**
|
|
60
|
-
* 判断节点是否包含指定类型
|
|
61
|
-
* @param types 节点类型
|
|
62
|
-
* @param names 指定类型
|
|
63
|
-
* @test
|
|
64
|
-
*/
|
|
65
|
-
export declare const hasTag: (types: Set<string>, names: TagName | TagName[]) => boolean;
|
|
66
58
|
export declare const toConfigGetter: (configGetter?: ConfigGetter, articlePath?: string) => ConfigGetter | undefined;
|
|
67
59
|
/**
|
|
68
60
|
* 获取字符串开头的空白字符
|
package/dist/util.js
CHANGED
|
@@ -109,13 +109,6 @@ export const findTemplateName = (state, node) => {
|
|
|
109
109
|
}
|
|
110
110
|
return [prevSibling && page, parameter];
|
|
111
111
|
};
|
|
112
|
-
/**
|
|
113
|
-
* 判断节点是否包含指定类型
|
|
114
|
-
* @param types 节点类型
|
|
115
|
-
* @param names 指定类型
|
|
116
|
-
* @test
|
|
117
|
-
*/
|
|
118
|
-
export const hasTag = (types, names) => (Array.isArray(names) ? names : [names]).some(name => types.has(name in tokens ? tokens[name] : name));
|
|
119
112
|
export const toConfigGetter = (configGetter, articlePath) => articlePath
|
|
120
113
|
? async () => Object.assign(await (configGetter ?? wikiparse.getConfig)(), { articlePath })
|
|
121
114
|
: configGetter;
|