@bhsd/codemirror-mediawiki 3.5.1 → 3.6.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 +1 -1
- package/dist/bidi.js +5 -4
- package/dist/codemirror.d.ts +3 -3
- package/dist/codemirror.js +22 -7
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +9 -0
- package/dist/escape.js +3 -5
- package/dist/fold.d.ts +0 -6
- package/dist/fold.js +17 -28
- package/dist/hover.d.ts +1 -22
- package/dist/hover.js +32 -39
- package/dist/html.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- package/dist/inlay.js +5 -6
- package/dist/lintsource.js +4 -2
- package/dist/lua.js +4 -0
- package/dist/main.min.js +28 -27
- package/dist/matchTag.js +2 -1
- package/dist/mediawiki.d.ts +0 -7
- package/dist/mediawiki.js +11 -18
- package/dist/mw.min.js +31 -30
- package/dist/mwConfig.js +22 -4
- package/dist/openLinks.d.ts +0 -1
- package/dist/openLinks.js +6 -10
- package/dist/ref.js +26 -9
- package/dist/signature.js +1 -1
- package/dist/static.js +3 -2
- package/dist/statusBar.js +26 -42
- package/dist/theme.js +51 -52
- package/dist/token.d.ts +6 -4
- package/dist/token.js +18 -13
- package/dist/util.d.ts +39 -0
- package/dist/util.js +53 -0
- package/dist/vue.js +1 -1
- package/dist/wiki.min.js +30 -29
- package/i18n/en.json +2 -2
- package/i18n/zh-hans.json +2 -2
- package/i18n/zh-hant.json +2 -2
- package/package.json +8 -11
package/dist/mwConfig.js
CHANGED
|
@@ -12,6 +12,14 @@ var compareVersion = (version, baseVersion) => {
|
|
|
12
12
|
|
|
13
13
|
// ../cm-util/dist/index.mjs
|
|
14
14
|
var otherParserFunctions = /* @__PURE__ */ new Set(["msg", "raw", "subst", "safesubst"]);
|
|
15
|
+
var isUnderscore = (s) => !/^_{2}.+_{2}$/u.test(s);
|
|
16
|
+
var cleanAliases = (aliases) => {
|
|
17
|
+
for (const key in aliases) {
|
|
18
|
+
if (/^[^##].*:$/u.test(key)) {
|
|
19
|
+
delete aliases[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
15
23
|
var getConfig = (magicWords, rule, flip) => {
|
|
16
24
|
const words = magicWords.filter(rule);
|
|
17
25
|
return Object.fromEntries(
|
|
@@ -32,10 +40,12 @@ var getParserConfig = (minConfig, mwConfig) => {
|
|
|
32
40
|
redirection
|
|
33
41
|
} = mwConfig, [insensitive, sensitive] = functionSynonyms, behaviorSwitch = doubleUnderscore.map(
|
|
34
42
|
(obj, i) => Object.entries(obj).map(([k, v]) => [
|
|
35
|
-
k.slice(2, -2),
|
|
43
|
+
isUnderscore(k) ? k.slice(2, -2) : k,
|
|
36
44
|
i && typeof v === "string" ? v.toUpperCase() : v
|
|
37
45
|
])
|
|
38
46
|
);
|
|
47
|
+
cleanAliases(insensitive);
|
|
48
|
+
cleanAliases(sensitive);
|
|
39
49
|
for (const [k, v] of Object.entries(insensitive)) {
|
|
40
50
|
if (k in sensitive) {
|
|
41
51
|
delete insensitive[k];
|
|
@@ -48,7 +58,9 @@ var getParserConfig = (minConfig, mwConfig) => {
|
|
|
48
58
|
ext: Object.keys(tags),
|
|
49
59
|
parserFunction: [{ ...insensitive }, { ...sensitive, "=": "=" }, [], []],
|
|
50
60
|
doubleUnderscore: [
|
|
51
|
-
...behaviorSwitch.map(
|
|
61
|
+
...behaviorSwitch.map(
|
|
62
|
+
(entries) => entries.filter(([k]) => isUnderscore(k)).map(([k]) => k)
|
|
63
|
+
),
|
|
52
64
|
...behaviorSwitch.map(Object.fromEntries)
|
|
53
65
|
],
|
|
54
66
|
protocol: urlProtocols.replace(/\|\\?\/\\?\/$|\\(?=[:/])/gu, ""),
|
|
@@ -87,8 +99,12 @@ var getStaticMwConfig = ({
|
|
|
87
99
|
tags: Object.fromEntries(ext.map((s) => [s, true])),
|
|
88
100
|
tagModes: modes,
|
|
89
101
|
doubleUnderscore: [
|
|
90
|
-
Object.fromEntries(
|
|
91
|
-
|
|
102
|
+
Object.fromEntries(
|
|
103
|
+
(d2 && d0.length === 0 ? Object.keys(d2) : d0).map((s) => [isUnderscore(s) ? `__${s}__` : s, true])
|
|
104
|
+
),
|
|
105
|
+
Object.fromEntries(
|
|
106
|
+
(d3 && d1.length === 0 ? Object.keys(d3) : d1).map((s) => [isUnderscore(s) ? `__${s}__` : s, true])
|
|
107
|
+
)
|
|
92
108
|
],
|
|
93
109
|
functionHooks: functionHook,
|
|
94
110
|
variableIDs: variable,
|
|
@@ -152,6 +168,7 @@ var getMwConfig = async (modes) => {
|
|
|
152
168
|
if (config && !isIPE) {
|
|
153
169
|
const { functionSynonyms: [insensitive] } = config;
|
|
154
170
|
if (!("subst" in insensitive)) {
|
|
171
|
+
cleanAliases(insensitive);
|
|
155
172
|
Object.assign(insensitive, getConfig(magicwords, ({ name }) => others.has(name)));
|
|
156
173
|
}
|
|
157
174
|
} else {
|
|
@@ -169,6 +186,7 @@ var getMwConfig = async (modes) => {
|
|
|
169
186
|
)
|
|
170
187
|
};
|
|
171
188
|
}
|
|
189
|
+
cleanAliases(config.functionSynonyms[1]);
|
|
172
190
|
Object.assign(config, {
|
|
173
191
|
...getKeywords(magicwords, true),
|
|
174
192
|
tagModes: modes,
|
package/dist/openLinks.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { EditorView } from '@codemirror/view';
|
|
|
2
2
|
import type { Extension } from '@codemirror/state';
|
|
3
3
|
import type { CodeMirror6 } from './codemirror';
|
|
4
4
|
import type { MwConfig } from './token';
|
|
5
|
-
export declare const isMac: boolean;
|
|
6
5
|
export declare const mouseEventListener: (e: MouseEvent, view: EditorView, langConfig: MwConfig | undefined) => string | undefined;
|
|
7
6
|
declare const _default: ({ langConfig }: CodeMirror6) => Extension;
|
|
8
7
|
export default _default;
|
package/dist/openLinks.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { EditorView } from '@codemirror/view';
|
|
2
2
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
3
3
|
import { tokens } from './config';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const isMac = vendor?.includes('Apple Computer')
|
|
8
|
-
&& (userAgent.includes('Mobile/') || maxTouchPoints > 2)
|
|
9
|
-
|| platform.includes('Mac');
|
|
10
|
-
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'], wikiLinks = [
|
|
4
|
+
import { isMac } from './constants';
|
|
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 = [
|
|
11
7
|
'template-name',
|
|
12
8
|
'link-pagename',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
`parserfunction${pagename}`,
|
|
10
|
+
`exttag-attribute-value${pagename}`,
|
|
11
|
+
`file-text${pagename}`,
|
|
16
12
|
];
|
|
17
13
|
const toggleOpenLinks = (toggle) => {
|
|
18
14
|
for (const ele of document.querySelectorAll('.cm-content')) {
|
package/dist/ref.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { hoverTooltip, EditorView } from '@codemirror/view';
|
|
2
|
-
import { ensureSyntaxTree } from '@codemirror/language';
|
|
2
|
+
import { ensureSyntaxTree, language, highlightingFor } from '@codemirror/language';
|
|
3
|
+
import { highlightCode } from '@lezer/highlight';
|
|
3
4
|
import { getLSP } from '@bhsd/browser';
|
|
4
|
-
import
|
|
5
|
+
import elt from 'crelt';
|
|
5
6
|
import { tokens } from './config';
|
|
6
|
-
import {
|
|
7
|
-
|
|
7
|
+
import { getTag } from './matchTag';
|
|
8
|
+
import { indexToPos, posToIndex, escHTML } from './util';
|
|
9
|
+
const trees = new WeakMap(), selector = '.cm-tooltip-ref', noDef = '.cm-tooltip-no-def';
|
|
8
10
|
/**
|
|
9
11
|
* 获取节点内容
|
|
10
12
|
* @param state
|
|
@@ -49,21 +51,33 @@ export default (cm) => [
|
|
|
49
51
|
end: to,
|
|
50
52
|
above: true,
|
|
51
53
|
create() {
|
|
52
|
-
const dom =
|
|
53
|
-
dom.className = 'cm-tooltip-ref';
|
|
54
|
+
const dom = elt('div', { class: selector.slice(1) });
|
|
54
55
|
dom.style.font = getComputedStyle(view.contentDOM).font;
|
|
55
56
|
if (ref) {
|
|
56
|
-
const { range: { start, end } } = ref[0], anchor = posToIndex(doc, start), head = posToIndex(doc, end);
|
|
57
|
-
|
|
57
|
+
const { range: { start, end } } = ref[0], anchor = posToIndex(doc, start), head = posToIndex(doc, end), text = state.sliceDoc(anchor, head);
|
|
58
|
+
let result = '';
|
|
59
|
+
highlightCode(text, state.facet(language).parser.parse(text), {
|
|
60
|
+
style(tags) {
|
|
61
|
+
return highlightingFor(state, tags);
|
|
62
|
+
},
|
|
63
|
+
}, (code, classes) => {
|
|
64
|
+
const escaped = escHTML(code);
|
|
65
|
+
result += classes ? `<span class="${classes}">${escaped}</span>` : escaped;
|
|
66
|
+
}, () => {
|
|
67
|
+
result += '<br>';
|
|
68
|
+
});
|
|
69
|
+
dom.innerHTML = result;
|
|
58
70
|
dom.addEventListener('click', () => {
|
|
59
71
|
view.dispatch({
|
|
60
72
|
selection: { anchor, head },
|
|
61
73
|
scrollIntoView: true,
|
|
62
74
|
});
|
|
75
|
+
view.focus();
|
|
63
76
|
});
|
|
64
77
|
}
|
|
65
78
|
else {
|
|
66
79
|
dom.textContent = state.phrase('No definition found');
|
|
80
|
+
dom.classList.add(noDef.slice(1));
|
|
67
81
|
}
|
|
68
82
|
return { dom };
|
|
69
83
|
},
|
|
@@ -83,12 +97,15 @@ export default (cm) => [
|
|
|
83
97
|
}
|
|
84
98
|
}),
|
|
85
99
|
EditorView.theme({
|
|
86
|
-
|
|
100
|
+
[selector]: {
|
|
87
101
|
padding: '2px 5px',
|
|
88
102
|
width: 'max-content',
|
|
89
103
|
maxWidth: '60vw',
|
|
90
104
|
cursor: 'pointer',
|
|
91
105
|
whiteSpace: 'pre-wrap',
|
|
92
106
|
},
|
|
107
|
+
[noDef]: {
|
|
108
|
+
color: 'var(--cm-comment)',
|
|
109
|
+
},
|
|
93
110
|
}),
|
|
94
111
|
];
|
package/dist/signature.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EditorView, showTooltip } from '@codemirror/view';
|
|
2
2
|
import { StateField, StateEffect } from '@codemirror/state';
|
|
3
3
|
import { getLSP } from '@bhsd/browser';
|
|
4
|
-
import {
|
|
4
|
+
import { createTooltipView, indexToPos } from './util';
|
|
5
5
|
const stateEffect = StateEffect.define(), field = StateField.define({
|
|
6
6
|
create() {
|
|
7
7
|
return undefined;
|
package/dist/static.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUnderscore } from '@bhsd/cm-util';
|
|
1
2
|
export const tagModes = {
|
|
2
3
|
onlyinclude: 'mediawiki',
|
|
3
4
|
includeonly: 'mediawiki',
|
|
@@ -24,8 +25,8 @@ export const getStaticMwConfig = ({ variable, parserFunction: [p0, p1, ...p2], p
|
|
|
24
25
|
tags: Object.fromEntries(ext.map(s => [s, true])),
|
|
25
26
|
tagModes: modes,
|
|
26
27
|
doubleUnderscore: [
|
|
27
|
-
Object.fromEntries((d2 && d0.length === 0 ? Object.keys(d2) : d0).map(s => [`__${s}__
|
|
28
|
-
Object.fromEntries((d3 && d1.length === 0 ? Object.keys(d3) : d1).map(s => [`__${s}__
|
|
28
|
+
Object.fromEntries((d2 && d0.length === 0 ? Object.keys(d2) : d0).map(s => [isUnderscore(s) ? `__${s}__` : s, true])),
|
|
29
|
+
Object.fromEntries((d3 && d1.length === 0 ? Object.keys(d3) : d1).map(s => [isUnderscore(s) ? `__${s}__` : s, true])),
|
|
29
30
|
],
|
|
30
31
|
functionHooks: functionHook,
|
|
31
32
|
variableIDs: variable,
|
package/dist/statusBar.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { showPanel, EditorView } from '@codemirror/view';
|
|
2
2
|
import { nextDiagnostic, setDiagnosticsEffect } from '@codemirror/lint';
|
|
3
|
+
import elt from 'crelt';
|
|
3
4
|
import { menuRegistry } from './codemirror';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ele.textContent = 'Fix all auto-fixable problems';
|
|
7
|
-
return ele;
|
|
8
|
-
})();
|
|
5
|
+
import { panelSelector, diagnosticSelector, menuSelector, messageSelector, actionSelector } from './constants';
|
|
6
|
+
const statusSelector = '.cm-panel-status', workerSelector = '.cm-status-worker', errorSelector = '.cm-status-error', warningSelector = '.cm-status-warning', enabledSelector = '.cm-status-fix-enabled', disabledSelector = '.cm-status-fix-disabled', workerCls = 'cm-status-worker-enabled', lineCls = 'cm-status-line';
|
|
9
7
|
function getLintMarker(view, severity, menu) {
|
|
10
|
-
const marker =
|
|
11
|
-
marker.className = `cm-status-${severity}`;
|
|
8
|
+
const marker = elt('div', { class: `cm-status-${severity}` }), icon = elt('div');
|
|
12
9
|
if (severity === 'fix') {
|
|
13
|
-
icon.className =
|
|
10
|
+
icon.className = disabledSelector.slice(1);
|
|
14
11
|
marker.title = 'Fix all';
|
|
15
12
|
marker.append(icon);
|
|
16
13
|
if (menu) {
|
|
17
14
|
marker.addEventListener('click', ({ clientX, clientY }) => {
|
|
18
|
-
if (icon.className ===
|
|
15
|
+
if (icon.className === enabledSelector.slice(1)) {
|
|
19
16
|
const { bottom, left } = view.dom.getBoundingClientRect();
|
|
20
17
|
menu.style.bottom = `${bottom - clientY + 5}px`;
|
|
21
18
|
menu.style.left = `${clientX - 20 - left}px`;
|
|
@@ -27,11 +24,9 @@ function getLintMarker(view, severity, menu) {
|
|
|
27
24
|
}
|
|
28
25
|
else {
|
|
29
26
|
icon.className = `cm-lint-marker-${severity}`;
|
|
30
|
-
|
|
31
|
-
count.textContent = '0';
|
|
32
|
-
marker.append(icon, count);
|
|
27
|
+
marker.append(icon, elt('div', '0'));
|
|
33
28
|
marker.addEventListener('click', () => {
|
|
34
|
-
if (marker.parentElement?.classList.contains(
|
|
29
|
+
if (marker.parentElement?.classList.contains(workerCls)) {
|
|
35
30
|
nextDiagnostic(view);
|
|
36
31
|
view.focus();
|
|
37
32
|
}
|
|
@@ -43,8 +38,8 @@ const updateDiagnosticsCount = (diagnostics, s, marker) => {
|
|
|
43
38
|
marker.lastChild.textContent = String(diagnostics.filter(({ severity }) => severity === s).length);
|
|
44
39
|
};
|
|
45
40
|
const toggleClass = (classList, enabled) => {
|
|
46
|
-
classList.toggle(
|
|
47
|
-
classList.toggle(
|
|
41
|
+
classList.toggle(enabledSelector.slice(1), enabled);
|
|
42
|
+
classList.toggle(disabledSelector.slice(1), !enabled);
|
|
48
43
|
};
|
|
49
44
|
const getDiagnostics = (all, main) => all.filter(({ from, to }) => from <= main.to && to >= main.from);
|
|
50
45
|
const updateDiagnosticMessage = (cm, allDiagnostics, main, msg) => {
|
|
@@ -57,10 +52,7 @@ const updateDiagnosticMessage = (cm, allDiagnostics, main, msg) => {
|
|
|
57
52
|
msg.textContent = diagnostic.message;
|
|
58
53
|
if (diagnostic.actions) {
|
|
59
54
|
msg.append(...diagnostic.actions.map(({ name, apply }) => {
|
|
60
|
-
const button =
|
|
61
|
-
button.type = 'button';
|
|
62
|
-
button.className = 'cm-diagnosticAction';
|
|
63
|
-
button.textContent = name;
|
|
55
|
+
const button = elt('button', { type: 'button', class: actionSelector.slice(1) }, name);
|
|
64
56
|
button.addEventListener('click', e => {
|
|
65
57
|
e.preventDefault();
|
|
66
58
|
apply(view, diagnostic.from, diagnostic.to);
|
|
@@ -70,7 +62,7 @@ const updateDiagnosticMessage = (cm, allDiagnostics, main, msg) => {
|
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
64
|
};
|
|
73
|
-
const updateMenu = (cm, allDiagnostics, main, classList, menu, fixer) => {
|
|
65
|
+
const updateMenu = (cm, allDiagnostics, main, classList, optionAll, menu, fixer) => {
|
|
74
66
|
if (menu) {
|
|
75
67
|
const actionable = menuRegistry.filter(({ name, isActionable }) => cm.hasPreference(name) && isActionable(cm)), fixable = new Set(fixer && getDiagnostics(allDiagnostics, main).filter(({ actions }) => actions?.some(({ name }) => name === 'fix'
|
|
76
68
|
|| name !== 'Fix: Stylelint' && name.startsWith('Fix:'))).map(({ message }) => / \(([^()]+)\)$/u.exec(message)?.[1])
|
|
@@ -81,8 +73,7 @@ const updateMenu = (cm, allDiagnostics, main, classList, menu, fixer) => {
|
|
|
81
73
|
}
|
|
82
74
|
toggleClass(classList, true);
|
|
83
75
|
const actions = actionable.flatMap(({ getItems }) => getItems(cm)), quickfix = [...fixable].map(rule => {
|
|
84
|
-
const option =
|
|
85
|
-
option.textContent = `Fix all ${rule} problems`;
|
|
76
|
+
const option = elt('div', `Fix all ${rule} problems`);
|
|
86
77
|
option.dataset['rule'] = rule;
|
|
87
78
|
return option;
|
|
88
79
|
});
|
|
@@ -92,15 +83,12 @@ const updateMenu = (cm, allDiagnostics, main, classList, menu, fixer) => {
|
|
|
92
83
|
menu.replaceChildren(...actions, ...quickfix);
|
|
93
84
|
}
|
|
94
85
|
};
|
|
95
|
-
const panelSelector = '.cm-panel-status', workerSelector = '.cm-status-worker', errorSelector = '.cm-status-error', warningSelector = '.cm-status-warning', enabledSelector = '.cm-status-fix-enabled', disabledSelector = '.cm-status-fix-disabled', menuSelector = '.cm-status-fix-menu', messageSelector = '.cm-status-message';
|
|
96
86
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
97
87
|
export default (cm, fixer) => [
|
|
98
88
|
showPanel.of(view => {
|
|
99
89
|
let diagnostics = [], menu;
|
|
100
90
|
if (!view.state.readOnly && (fixer || menuRegistry.length > 0)) {
|
|
101
|
-
menu =
|
|
102
|
-
menu.className = 'cm-status-fix-menu';
|
|
103
|
-
menu.tabIndex = -1;
|
|
91
|
+
menu = elt('div', { class: menuSelector.slice(1), tabIndex: -1 });
|
|
104
92
|
if (fixer) {
|
|
105
93
|
menu.addEventListener('click', ({ target }) => {
|
|
106
94
|
if (target === menu) {
|
|
@@ -122,14 +110,7 @@ export default (cm, fixer) => [
|
|
|
122
110
|
});
|
|
123
111
|
view.dom.append(menu);
|
|
124
112
|
}
|
|
125
|
-
const
|
|
126
|
-
worker.className = 'cm-status-worker';
|
|
127
|
-
worker.append(error, warning, fix);
|
|
128
|
-
message.className = 'cm-status-message';
|
|
129
|
-
position.className = 'cm-status-line';
|
|
130
|
-
position.textContent = '0:0';
|
|
131
|
-
dom.className = 'cm-panel cm-panel-status';
|
|
132
|
-
dom.append(worker, message, position);
|
|
113
|
+
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;
|
|
133
114
|
return {
|
|
134
115
|
dom,
|
|
135
116
|
update({ state: { selection: { main }, doc }, transactions, docChanged, selectionSet }) {
|
|
@@ -137,17 +118,17 @@ export default (cm, fixer) => [
|
|
|
137
118
|
for (const effect of tr.effects) {
|
|
138
119
|
if (effect.is(setDiagnosticsEffect)) {
|
|
139
120
|
diagnostics = effect.value;
|
|
140
|
-
worker.classList.toggle(
|
|
121
|
+
worker.classList.toggle(workerCls, diagnostics.length > 0);
|
|
141
122
|
updateDiagnosticsCount(diagnostics, 'error', error);
|
|
142
123
|
updateDiagnosticsCount(diagnostics, 'warning', warning);
|
|
143
124
|
updateDiagnosticMessage(cm, diagnostics, main, message);
|
|
144
|
-
updateMenu(cm, diagnostics, main, classList, menu, fixer);
|
|
125
|
+
updateMenu(cm, diagnostics, main, classList, optionAll, menu, fixer);
|
|
145
126
|
}
|
|
146
127
|
}
|
|
147
128
|
}
|
|
148
129
|
if (docChanged || selectionSet) {
|
|
149
130
|
updateDiagnosticMessage(cm, diagnostics, main, message);
|
|
150
|
-
updateMenu(cm, diagnostics, main, classList, menu, fixer);
|
|
131
|
+
updateMenu(cm, diagnostics, main, classList, optionAll, menu, fixer);
|
|
151
132
|
const { number, from } = doc.lineAt(main.head);
|
|
152
133
|
position.textContent = `${number}:${main.head - from}`;
|
|
153
134
|
if (!main.empty) {
|
|
@@ -158,10 +139,10 @@ export default (cm, fixer) => [
|
|
|
158
139
|
};
|
|
159
140
|
}),
|
|
160
141
|
EditorView.theme({
|
|
161
|
-
[
|
|
142
|
+
[statusSelector]: {
|
|
162
143
|
lineHeight: 1.4,
|
|
163
144
|
},
|
|
164
|
-
[`${
|
|
145
|
+
[`${statusSelector}>div`]: {
|
|
165
146
|
padding: '0 .3em',
|
|
166
147
|
display: 'table-cell',
|
|
167
148
|
},
|
|
@@ -182,7 +163,7 @@ export default (cm, fixer) => [
|
|
|
182
163
|
[`${errorSelector},${warningSelector}`]: {
|
|
183
164
|
paddingRight: '8px',
|
|
184
165
|
},
|
|
185
|
-
[
|
|
166
|
+
[`.${workerCls} ${errorSelector},.${workerCls} ${warningSelector}`]: {
|
|
186
167
|
cursor: 'pointer',
|
|
187
168
|
},
|
|
188
169
|
[`${workerSelector}>*>div`]: {
|
|
@@ -229,12 +210,15 @@ export default (cm, fixer) => [
|
|
|
229
210
|
borderWidth: '0 1px',
|
|
230
211
|
width: '100%',
|
|
231
212
|
},
|
|
232
|
-
[`${messageSelector}
|
|
213
|
+
[`${messageSelector} ${actionSelector}`]: {
|
|
233
214
|
paddingTop: 0,
|
|
234
215
|
paddingBottom: 0,
|
|
235
216
|
},
|
|
236
|
-
|
|
217
|
+
[`.${lineCls}`]: {
|
|
237
218
|
whiteSpace: 'nowrap',
|
|
238
219
|
},
|
|
220
|
+
[diagnosticSelector]: {
|
|
221
|
+
cursor: 'pointer',
|
|
222
|
+
},
|
|
239
223
|
}),
|
|
240
224
|
];
|
package/dist/theme.js
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
1
|
import { EditorView } from '@codemirror/view';
|
|
2
2
|
import { nord as nordBase } from 'cm6-theme-nord';
|
|
3
|
+
import { foldSelector, hoverSelector, matchingCls, nonmatchingCls, menuSelector, messageSelector, actionSelector, panelsSelector, } from './constants';
|
|
4
|
+
const focused = '&.cm-focused', matching = `${focused} .${matchingCls}`, nonmatching = `${focused} .${nonmatchingCls}`, code = `${hoverSelector} code`, menuHover = `${menuSelector}>div:hover`;
|
|
3
5
|
export const light = /* @__PURE__ */ EditorView.theme({
|
|
4
6
|
'&': {
|
|
5
7
|
backgroundColor: '#fff',
|
|
6
|
-
},
|
|
7
|
-
'&.cm-focused .cm-matchingTag': {
|
|
8
|
-
backgroundColor: 'rgb(50,140,130,.32)',
|
|
9
|
-
},
|
|
10
|
-
'&.cm-focused .cm-nonmatchingTag': {
|
|
11
|
-
backgroundColor: 'rgb(187,85,85,.27)',
|
|
12
|
-
},
|
|
13
|
-
'.cm-tooltip-hover code': {
|
|
14
|
-
backgroundColor: '#e0e6eb',
|
|
15
|
-
},
|
|
16
|
-
'.cm-status-fix-menu': {
|
|
17
|
-
backgroundColor: '#f5f5f5',
|
|
18
|
-
boxShadow: '0 2px 2px 0 rgb(0,0,0,.25)',
|
|
19
|
-
},
|
|
20
|
-
'.cm-status-fix-menu>div:hover': {
|
|
21
|
-
backgroundColor: '#e2f2ff',
|
|
22
|
-
},
|
|
23
|
-
'.cm-status-message': {
|
|
24
|
-
borderColor: '#c8ccd1',
|
|
25
|
-
},
|
|
26
|
-
'.cm-content': {
|
|
27
8
|
'--cm-arg': '#b0c',
|
|
28
9
|
'--cm-attr': '#179b1c',
|
|
29
10
|
'--cm-comment': '#7b8c8f',
|
|
@@ -43,39 +24,77 @@ export const light = /* @__PURE__ */ EditorView.theme({
|
|
|
43
24
|
'--cm-var': '#ad9300',
|
|
44
25
|
'--cm-var-name': '#ac6600',
|
|
45
26
|
},
|
|
27
|
+
[matching]: {
|
|
28
|
+
backgroundColor: 'rgb(50,140,130,.32)',
|
|
29
|
+
},
|
|
30
|
+
[nonmatching]: {
|
|
31
|
+
backgroundColor: 'rgb(187,85,85,.27)',
|
|
32
|
+
},
|
|
33
|
+
[code]: {
|
|
34
|
+
backgroundColor: '#e0e6eb',
|
|
35
|
+
},
|
|
36
|
+
[menuSelector]: {
|
|
37
|
+
backgroundColor: '#f5f5f5',
|
|
38
|
+
boxShadow: '0 2px 2px 0 rgb(0,0,0,.25)',
|
|
39
|
+
},
|
|
40
|
+
[menuHover]: {
|
|
41
|
+
backgroundColor: '#e2f2ff',
|
|
42
|
+
},
|
|
43
|
+
[messageSelector]: {
|
|
44
|
+
borderColor: '#c8ccd1',
|
|
45
|
+
},
|
|
46
46
|
}),
|
|
47
47
|
/**
|
|
48
48
|
* @author 鬼影233
|
|
49
49
|
* @author Bhsd
|
|
50
50
|
* @see https://zh.moegirl.org.cn/User:%E9%AC%BC%E5%BD%B1233/nord-moeskin.css
|
|
51
51
|
*/
|
|
52
|
-
nord = [
|
|
52
|
+
nord = /* @__PURE__ */ (() => [
|
|
53
53
|
nordBase,
|
|
54
|
-
|
|
54
|
+
EditorView.theme({
|
|
55
|
+
'&': {
|
|
56
|
+
'--cm-arg': '#9f78a5',
|
|
57
|
+
'--cm-attr': '#97b757',
|
|
58
|
+
'--cm-comment': '#4c566a',
|
|
59
|
+
'--cm-convert': '#b68',
|
|
60
|
+
'--cm-entity': '#00a1a1',
|
|
61
|
+
'--cm-error': '#bf616a',
|
|
62
|
+
'--cm-func': '#bf616a',
|
|
63
|
+
'--cm-hr': '#5e81ac',
|
|
64
|
+
'--cm-hr-bg': '#3b4252',
|
|
65
|
+
'--cm-link': '#5e81ac',
|
|
66
|
+
'--cm-sect': '#81a1c1',
|
|
67
|
+
'--cm-sp': '#88c0d0',
|
|
68
|
+
'--cm-table': '#b48ead',
|
|
69
|
+
'--cm-table-attr': '#9f78a5',
|
|
70
|
+
'--cm-tag': '#a3be8c',
|
|
71
|
+
'--cm-tpl': '#9f78a5',
|
|
72
|
+
'--cm-var': '#d08770',
|
|
73
|
+
'--cm-var-name': '#d08770',
|
|
74
|
+
},
|
|
55
75
|
'div.cm-activeLine': {
|
|
56
76
|
backgroundColor: 'rgb(76,86,106,.27)',
|
|
57
77
|
},
|
|
58
|
-
|
|
78
|
+
[matching]: {
|
|
59
79
|
backgroundColor: '#eceff4',
|
|
60
80
|
color: '#434c5e',
|
|
61
81
|
},
|
|
62
|
-
|
|
82
|
+
[nonmatching]: {
|
|
63
83
|
backgroundColor: 'rgb(235,203,139,.32)',
|
|
64
84
|
},
|
|
65
|
-
[
|
|
66
|
-
+ '.cm-tooltip-hover code, .cm-status-fix-menu>div:hover, .cm-diagnosticAction, div.cm-tooltip-fold']: {
|
|
85
|
+
[`${focused}>.cm-scroller>.cm-selectionLayer div.cm-selectionBackground, ${code}, ${menuHover}, ${actionSelector}, div${foldSelector}`]: {
|
|
67
86
|
backgroundColor: '#4c566a',
|
|
68
87
|
},
|
|
69
|
-
|
|
88
|
+
[`div${panelsSelector}`]: {
|
|
70
89
|
color: '#d8dee9',
|
|
71
90
|
},
|
|
72
|
-
|
|
91
|
+
[menuSelector]: {
|
|
73
92
|
backgroundColor: '#252a33',
|
|
74
93
|
},
|
|
75
|
-
|
|
94
|
+
[messageSelector]: {
|
|
76
95
|
borderColor: '#000',
|
|
77
96
|
},
|
|
78
|
-
|
|
97
|
+
[`${focused} .cm-searchMatch.cm-searchMatch-selected`]: {
|
|
79
98
|
color: '#b48ead',
|
|
80
99
|
},
|
|
81
100
|
'div.cm-tooltip-autocomplete ul li[aria-selected]': {
|
|
@@ -84,25 +103,5 @@ nord = [
|
|
|
84
103
|
'div.cm-gutters': {
|
|
85
104
|
color: '#5e81ac',
|
|
86
105
|
},
|
|
87
|
-
'.cm-content': {
|
|
88
|
-
'--cm-arg': '#9f78a5',
|
|
89
|
-
'--cm-attr': '#97b757',
|
|
90
|
-
'--cm-comment': '#4c566a',
|
|
91
|
-
'--cm-convert': '#b68',
|
|
92
|
-
'--cm-entity': '#00a1a1',
|
|
93
|
-
'--cm-error': '#bf616a',
|
|
94
|
-
'--cm-func': '#bf616a',
|
|
95
|
-
'--cm-hr': '#5e81ac',
|
|
96
|
-
'--cm-hr-bg': '#3b4252',
|
|
97
|
-
'--cm-link': '#5e81ac',
|
|
98
|
-
'--cm-sect': '#81a1c1',
|
|
99
|
-
'--cm-sp': '#88c0d0',
|
|
100
|
-
'--cm-table': '#b48ead',
|
|
101
|
-
'--cm-table-attr': '#9f78a5',
|
|
102
|
-
'--cm-tag': '#a3be8c',
|
|
103
|
-
'--cm-tpl': '#9f78a5',
|
|
104
|
-
'--cm-var': '#d08770',
|
|
105
|
-
'--cm-var-name': '#d08770',
|
|
106
|
-
},
|
|
107
106
|
}),
|
|
108
|
-
];
|
|
107
|
+
])();
|
package/dist/token.d.ts
CHANGED
|
@@ -49,14 +49,16 @@ declare interface StringStream extends StringStreamBase {
|
|
|
49
49
|
match(pattern: RegExp, consume?: boolean): RegExpMatchArray | null;
|
|
50
50
|
}
|
|
51
51
|
export type TagName = keyof typeof tokens;
|
|
52
|
-
export type ApiSuggestions = [string, string?][]
|
|
52
|
+
export type ApiSuggestions = [string, string?][] & {
|
|
53
|
+
description?: string;
|
|
54
|
+
};
|
|
53
55
|
/**
|
|
54
56
|
* 获取维基链接建议
|
|
55
57
|
* @param search 搜索字符串,开头不包含` `
|
|
56
|
-
* @param namespace 命名空间
|
|
57
58
|
* @param subpage 是否为子页面
|
|
59
|
+
* @param namespace 命名空间
|
|
58
60
|
*/
|
|
59
|
-
export type ApiSuggest = (search: string,
|
|
61
|
+
export type ApiSuggest = (search: string, subpage?: boolean, namespace?: number) => ApiSuggestions | Promise<ApiSuggestions>;
|
|
60
62
|
export interface MwConfig extends MwConfigBase {
|
|
61
63
|
nsid: Record<string, number>;
|
|
62
64
|
variants?: string[];
|
|
@@ -138,7 +140,7 @@ export declare class MediaWiki {
|
|
|
138
140
|
inLinkText(file: boolean, gallery?: boolean): Tokenizer;
|
|
139
141
|
toEatImageParameter(stream: StringStream, state: State): void;
|
|
140
142
|
eatList(stream: StringStream, state: State): string;
|
|
141
|
-
eatDoubleUnderscore(style: string, stream: StringStream, state: State): Style;
|
|
143
|
+
eatDoubleUnderscore(style: string, ch: '_' | '_', stream: StringStream, state: State): Style;
|
|
142
144
|
get eatStartTable(): Tokenizer<string>;
|
|
143
145
|
inTableDefinition(tr?: boolean, quote?: string): Tokenizer;
|
|
144
146
|
get inTable(): Tokenizer;
|