@bhsd/codemirror-mediawiki 3.7.1 → 3.8.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/README.md +20 -0
- package/dist/codemirror.d.ts +2 -0
- package/dist/codemirror.js +17 -3
- package/dist/escape.js +2 -2
- package/dist/hover.d.ts +1 -1
- package/dist/hover.js +4 -2
- package/dist/index.js +5 -1
- package/dist/inlay.d.ts +1 -1
- package/dist/inlay.js +2 -1
- package/dist/linter.d.ts +1 -0
- package/dist/linter.js +7 -5
- package/dist/lintsource.d.ts +1 -1
- package/dist/lintsource.js +13 -13
- package/dist/main.min.js +26 -26
- package/dist/mediawiki.d.ts +1 -1
- package/dist/mediawiki.js +1 -1
- package/dist/mw.min.js +32 -32
- package/dist/mwConfig.js +4 -1
- package/dist/openLinks.js +9 -5
- package/dist/ref.d.ts +1 -1
- package/dist/ref.js +2 -1
- package/dist/signature.d.ts +1 -1
- package/dist/signature.js +2 -1
- package/dist/statusBar.js +5 -0
- package/dist/wiki.min.js +31 -31
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +6 -6
package/dist/mwConfig.js
CHANGED
|
@@ -117,6 +117,9 @@ var getStaticMwConfig = ({
|
|
|
117
117
|
redirection
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
// src/linter.ts
|
|
121
|
+
var wikilintRepo = "npm/wikiparser-node";
|
|
122
|
+
|
|
120
123
|
// mw/config.ts
|
|
121
124
|
var others = /* @__PURE__ */ new Set([...otherParserFunctions, "msgnw"]);
|
|
122
125
|
var getConfigPair = (magicWords, rule) => [true, false].map((bool) => getConfig(magicWords, rule, bool));
|
|
@@ -143,7 +146,7 @@ var getMwConfig = async (modes) => {
|
|
|
143
146
|
return { ...config, nsid };
|
|
144
147
|
} else if (location.hostname.endsWith(".moegirl.org.cn")) {
|
|
145
148
|
const parserConfig = await (await fetch(
|
|
146
|
-
`${CDN}/
|
|
149
|
+
`${CDN}/${wikilintRepo}/config/moegirl.json`
|
|
147
150
|
)).json();
|
|
148
151
|
setObject("wikilintConfig", parserConfig);
|
|
149
152
|
config = getStaticMwConfig(parserConfig, modes);
|
package/dist/openLinks.js
CHANGED
|
@@ -2,7 +2,8 @@ import { EditorView } from '@codemirror/view';
|
|
|
2
2
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
3
3
|
import { tokens } from './config';
|
|
4
4
|
import { isMac } from './constants';
|
|
5
|
-
|
|
5
|
+
import { hasTag } from './util';
|
|
6
|
+
const modKey = isMac ? 'metaKey' : 'ctrlKey', key = isMac ? 'Meta' : 'Control', tags = ['extLinkProtocol', 'extLink', 'freeExtLinkProtocol', 'freeExtLink', 'magicLink', 'pageName'], links = ['extlink-protocol', 'extlink', 'free-extlink-protocol', 'free-extlink', 'magic-link'], pagename = '.cm-mw-pagename', wikiLinks = [
|
|
6
7
|
'template-name',
|
|
7
8
|
'link-pagename',
|
|
8
9
|
`parserfunction${pagename}`,
|
|
@@ -42,18 +43,21 @@ export const mouseEventListener = (e, view, langConfig) => {
|
|
|
42
43
|
|| !(e.target instanceof Element && getComputedStyle(e.target).textDecorationLine === 'underline')) {
|
|
43
44
|
return undefined;
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
46
|
+
const position = view.posAtCoords(e);
|
|
47
|
+
if (!position) {
|
|
47
48
|
return undefined;
|
|
48
49
|
}
|
|
49
|
-
const { state } = view, tree = ensureSyntaxTree(state,
|
|
50
|
+
const { state } = view, tree = ensureSyntaxTree(state, position);
|
|
50
51
|
if (!tree) {
|
|
51
52
|
return undefined;
|
|
52
53
|
}
|
|
53
|
-
let node = tree.resolve(
|
|
54
|
+
let node = tree.resolve(position, -1);
|
|
54
55
|
if (node.name.includes(tokens.linkToSection)) {
|
|
55
56
|
node = node.prevSibling;
|
|
56
57
|
}
|
|
58
|
+
else if (!hasTag(new Set(node.name.split('_')), tags)) {
|
|
59
|
+
node = tree.resolve(position, 1);
|
|
60
|
+
}
|
|
57
61
|
const { name, from, to } = node;
|
|
58
62
|
if (name.includes(tokens.pageName) && typeof langConfig?.titleParser === 'function') {
|
|
59
63
|
return langConfig.titleParser(state, node);
|
package/dist/ref.d.ts
CHANGED
package/dist/ref.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getLSP } from '@bhsd/browser';
|
|
|
5
5
|
import elt from 'crelt';
|
|
6
6
|
import { tokens } from './config';
|
|
7
7
|
import { getTag } from './matchTag';
|
|
8
|
+
import { CodeMirror6 } from './codemirror';
|
|
8
9
|
import { indexToPos, posToIndex, escHTML } from './util';
|
|
9
10
|
const trees = new WeakMap(), selector = '.cm-tooltip-ref', noDef = '.cm-tooltip-no-def';
|
|
10
11
|
/**
|
|
@@ -44,7 +45,7 @@ export default (cm) => [
|
|
|
44
45
|
target = target.slice(1, target.slice(-1) === quote ? -1 : undefined).trim();
|
|
45
46
|
}
|
|
46
47
|
if (target) {
|
|
47
|
-
const { doc } = state, ref = await getLSP(view, false, cm.getWikiConfig)
|
|
48
|
+
const { doc } = state, ref = await getLSP(view, false, cm.getWikiConfig, CodeMirror6.CDN)
|
|
48
49
|
?.provideDefinition(doc.toString(), indexToPos(doc, first.to));
|
|
49
50
|
return {
|
|
50
51
|
pos,
|
package/dist/signature.d.ts
CHANGED
package/dist/signature.js
CHANGED
|
@@ -2,6 +2,7 @@ import { EditorView, showTooltip } from '@codemirror/view';
|
|
|
2
2
|
import { StateField, StateEffect } from '@codemirror/state';
|
|
3
3
|
import { getLSP } from '@bhsd/browser';
|
|
4
4
|
import { createTooltipView, indexToPos, escHTML } from './util';
|
|
5
|
+
import { CodeMirror6 } from './codemirror';
|
|
5
6
|
const stateEffect = StateEffect.define(), field = StateField.define({
|
|
6
7
|
create() {
|
|
7
8
|
return undefined;
|
|
@@ -35,7 +36,7 @@ export default (cm) => [
|
|
|
35
36
|
effects: stateEffect.of({
|
|
36
37
|
text,
|
|
37
38
|
cursor,
|
|
38
|
-
signatureHelp: await getLSP(view, false, cm.getWikiConfig)
|
|
39
|
+
signatureHelp: await getLSP(view, false, cm.getWikiConfig, CodeMirror6.CDN)
|
|
39
40
|
?.provideSignatureHelp(text, indexToPos(doc, cursor)),
|
|
40
41
|
}),
|
|
41
42
|
});
|
package/dist/statusBar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { showPanel, EditorView } from '@codemirror/view';
|
|
2
2
|
import { nextDiagnostic, setDiagnosticsEffect } from '@codemirror/lint';
|
|
3
|
+
import { gotoLine } from '@codemirror/search';
|
|
3
4
|
import elt from 'crelt';
|
|
4
5
|
import { menuRegistry } from './codemirror';
|
|
5
6
|
import { panelSelector, diagnosticSelector, menuSelector, messageSelector, actionSelector } from './constants';
|
|
@@ -113,6 +114,9 @@ export default (cm, fixer) => [
|
|
|
113
114
|
view.dom.append(menu);
|
|
114
115
|
}
|
|
115
116
|
const error = getLintMarker(view, 'error'), warning = getLintMarker(view, 'warning'), fix = getLintMarker(view, 'fix', menu), optionAll = elt('div', 'Fix all auto-fixable problems'), worker = elt('div', { class: workerSelector.slice(1) }, error, warning, fix), message = elt('div', { class: messageSelector.slice(1) }), position = elt('div', { class: lineCls }, '0:0'), dom = elt('div', { class: `${panelSelector.slice(1)} ${statusSelector.slice(1)}` }, worker, message, position), { classList } = fix.firstChild;
|
|
117
|
+
position.addEventListener('click', () => {
|
|
118
|
+
gotoLine(view);
|
|
119
|
+
});
|
|
116
120
|
return {
|
|
117
121
|
dom,
|
|
118
122
|
update({ state: { selection: { main }, doc }, transactions, docChanged, selectionSet }) {
|
|
@@ -217,6 +221,7 @@ export default (cm, fixer) => [
|
|
|
217
221
|
paddingBottom: 0,
|
|
218
222
|
},
|
|
219
223
|
[`.${lineCls}`]: {
|
|
224
|
+
cursor: 'pointer',
|
|
220
225
|
whiteSpace: 'nowrap',
|
|
221
226
|
},
|
|
222
227
|
[diagnosticSelector]: {
|