@bhsd/codemirror-mediawiki 3.3.0 → 3.4.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 +2 -23
- package/dist/codemirror.js +15 -2
- package/dist/fold.d.ts +2 -1
- package/dist/fold.js +13 -1
- package/dist/hover.d.ts +2 -1
- package/dist/hover.js +40 -18
- package/dist/inlay.js +8 -0
- package/dist/lintsource.js +2 -2
- package/dist/main.min.js +29 -25
- package/dist/mediawiki.js +145 -1
- package/dist/mw.min.js +33 -29
- package/dist/ref.js +9 -0
- package/dist/statusBar.js +134 -56
- package/dist/theme.js +4 -4
- package/dist/wiki.min.js +32 -28
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +2 -4
- package/mediawiki.css +0 -6
package/README.md
CHANGED
|
@@ -15,8 +15,6 @@ Nonetheless, this repository also provides a customized version with additional
|
|
|
15
15
|
|
|
16
16
|
- [Installation](#installation)
|
|
17
17
|
- [Browser Usage](#browser-usage)
|
|
18
|
-
- [Download JavaScript](#download-javascript)
|
|
19
|
-
- [Download CSS](#download-css)
|
|
20
18
|
- [Language modes](#language-modes)
|
|
21
19
|
- [css](#css)
|
|
22
20
|
- [html](#html)
|
|
@@ -104,13 +102,11 @@ import {
|
|
|
104
102
|
|
|
105
103
|
# Browser Usage
|
|
106
104
|
|
|
107
|
-
You can download the code via CDN, for example:
|
|
108
|
-
|
|
109
|
-
## Download JavaScript
|
|
110
|
-
|
|
111
105
|
<details>
|
|
112
106
|
<summary>Expand</summary>
|
|
113
107
|
|
|
108
|
+
You can download the code via CDN, for example:
|
|
109
|
+
|
|
114
110
|
```js
|
|
115
111
|
// static import
|
|
116
112
|
import {
|
|
@@ -173,23 +169,6 @@ const {
|
|
|
173
169
|
|
|
174
170
|
</details>
|
|
175
171
|
|
|
176
|
-
## Download CSS
|
|
177
|
-
|
|
178
|
-
<details>
|
|
179
|
-
<summary>Expand</summary>
|
|
180
|
-
|
|
181
|
-
```html
|
|
182
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki/mediawiki.css">
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
or
|
|
186
|
-
|
|
187
|
-
```html
|
|
188
|
-
<link rel="stylesheet" href="https://unpkg.com/@bhsd/codemirror-mediawiki/mediawiki.css">
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
</details>
|
|
192
|
-
|
|
193
172
|
# Language modes
|
|
194
173
|
|
|
195
174
|
## css
|
package/dist/codemirror.js
CHANGED
|
@@ -121,7 +121,18 @@ export class CodeMirror6 {
|
|
|
121
121
|
},
|
|
122
122
|
]),
|
|
123
123
|
EditorView.theme({
|
|
124
|
-
'.cm-panels': {
|
|
124
|
+
'.cm-panels': {
|
|
125
|
+
direction: document.dir,
|
|
126
|
+
},
|
|
127
|
+
'& .cm-lineNumbers .cm-gutterElement': {
|
|
128
|
+
textAlign: 'end',
|
|
129
|
+
},
|
|
130
|
+
'.cm-textfield, .cm-button, .cm-panel.cm-search label, .cm-panel.cm-gotoLine label': {
|
|
131
|
+
fontSize: 'inherit',
|
|
132
|
+
},
|
|
133
|
+
'.cm-panel [name="close"]': {
|
|
134
|
+
color: 'inherit',
|
|
135
|
+
},
|
|
125
136
|
}),
|
|
126
137
|
EditorView.updateListener.of(({ state: { doc }, startState: { doc: startDoc }, docChanged, focusChanged, }) => {
|
|
127
138
|
if (docChanged) {
|
|
@@ -143,7 +154,9 @@ export class CodeMirror6 {
|
|
|
143
154
|
EditorState.readOnly.of(true),
|
|
144
155
|
EditorState.transactionFilter.of(tr => tr.docChanged ? [] : tr),
|
|
145
156
|
EditorView.theme({
|
|
146
|
-
'input[type="color"]': {
|
|
157
|
+
'input[type="color"]': {
|
|
158
|
+
pointerEvents: 'none',
|
|
159
|
+
},
|
|
147
160
|
}),
|
|
148
161
|
]
|
|
149
162
|
: [
|
package/dist/fold.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EditorView } from '@codemirror/view';
|
|
2
|
+
import type { Command } from '@codemirror/view';
|
|
2
3
|
import type { EditorState, Extension } from '@codemirror/state';
|
|
3
4
|
import type { SyntaxNode, Tree } from '@lezer/common';
|
|
4
5
|
export interface DocRange {
|
package/dist/fold.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { showTooltip, keymap, GutterMarker, gutter, ViewPlugin } from '@codemirror/view';
|
|
1
|
+
import { showTooltip, keymap, GutterMarker, gutter, ViewPlugin, EditorView } from '@codemirror/view';
|
|
2
2
|
import { StateField, RangeSetBuilder, RangeSet } from '@codemirror/state';
|
|
3
3
|
import { syntaxTree, ensureSyntaxTree, foldEffect, unfoldEffect, foldedRanges, unfoldAll, codeFolding, foldGutter, foldKeymap, foldState, language, } from '@codemirror/language';
|
|
4
4
|
import { getRegex } from '@bhsd/common';
|
|
@@ -334,6 +334,7 @@ const foldCommand = (refOnly) => view => {
|
|
|
334
334
|
};
|
|
335
335
|
export const foldRef = /* @__PURE__ */ foldCommand(true);
|
|
336
336
|
export default ((e = defaultFoldExtension) => e);
|
|
337
|
+
const selector = '.cm-tooltip-fold';
|
|
337
338
|
export const mediaWikiFold = /* @__PURE__ */ (() => [
|
|
338
339
|
codeFolding({
|
|
339
340
|
placeholderDOM(view) {
|
|
@@ -446,6 +447,17 @@ export const mediaWikiFold = /* @__PURE__ */ (() => [
|
|
|
446
447
|
},
|
|
447
448
|
},
|
|
448
449
|
}),
|
|
450
|
+
EditorView.theme({
|
|
451
|
+
[selector]: {
|
|
452
|
+
cursor: 'pointer',
|
|
453
|
+
lineHeight: 1.2,
|
|
454
|
+
padding: '0 1px',
|
|
455
|
+
opacity: 0.6,
|
|
456
|
+
},
|
|
457
|
+
[`${selector}:hover`]: {
|
|
458
|
+
opacity: 1,
|
|
459
|
+
},
|
|
460
|
+
}),
|
|
449
461
|
])();
|
|
450
462
|
/**
|
|
451
463
|
* 点击提示折叠模板参数
|
package/dist/hover.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EditorView } from '@codemirror/view';
|
|
2
|
+
import type { TooltipView } from '@codemirror/view';
|
|
2
3
|
import type { Text, Extension } from '@codemirror/state';
|
|
3
4
|
import type { Position } from 'vscode-languageserver-types';
|
|
4
5
|
import type { CodeMirror6 } from './codemirror';
|
package/dist/hover.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hoverTooltip } from '@codemirror/view';
|
|
1
|
+
import { hoverTooltip, EditorView } from '@codemirror/view';
|
|
2
2
|
import { loadScript, getLSP } from '@bhsd/browser';
|
|
3
3
|
/**
|
|
4
4
|
* 将索引转换为位置
|
|
@@ -31,20 +31,42 @@ export const createTooltipView = (view, innerHTML) => {
|
|
|
31
31
|
inner.innerHTML = innerHTML;
|
|
32
32
|
return { dom };
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
34
|
+
const selector = '.cm-tooltip-hover';
|
|
35
|
+
export default (cm) => [
|
|
36
|
+
hoverTooltip(async (view, pos) => {
|
|
37
|
+
const { state: { doc } } = view, hover = await getLSP(view, false, cm.getWikiConfig)
|
|
38
|
+
?.provideHover(doc.toString(), indexToPos(doc, pos));
|
|
39
|
+
if (hover) {
|
|
40
|
+
await loadScript('npm/marked/lib/marked.umd.js', 'marked', true);
|
|
41
|
+
const { end } = hover.range;
|
|
42
|
+
return {
|
|
43
|
+
pos,
|
|
44
|
+
end: posToIndex(doc, end),
|
|
45
|
+
above: true,
|
|
46
|
+
create() {
|
|
47
|
+
return createTooltipView(view, marked.parse(hover.contents.value));
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}),
|
|
53
|
+
EditorView.theme({
|
|
54
|
+
[selector]: {
|
|
55
|
+
padding: '2px 5px',
|
|
56
|
+
width: 'max-content',
|
|
57
|
+
maxWidth: '60vw',
|
|
58
|
+
},
|
|
59
|
+
[`${selector} *`]: {
|
|
60
|
+
marginTop: '0!important',
|
|
61
|
+
marginBottom: '0!important',
|
|
62
|
+
},
|
|
63
|
+
[`${selector}>div`]: {
|
|
64
|
+
fontSize: '90%',
|
|
65
|
+
lineHeight: 1.4,
|
|
66
|
+
},
|
|
67
|
+
[`${selector} code`]: {
|
|
68
|
+
padding: '.1em .4em',
|
|
69
|
+
borderRadius: '.4em',
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
];
|
package/dist/inlay.js
CHANGED
package/dist/lintsource.js
CHANGED
|
@@ -125,7 +125,7 @@ export const getCssLintSource = async (opt) => {
|
|
|
125
125
|
export const getVueLintSource = async (opt) => {
|
|
126
126
|
const styleLint = await getCssLinter(), esLint = await getJsLinter();
|
|
127
127
|
return async (state) => {
|
|
128
|
-
const { doc } = state, option = await getOpt(opt) ?? {}, js = option['js'], css = option['css'];
|
|
128
|
+
const { doc } = state, option = await getOpt(opt, true) ?? {}, js = option['js'], css = option['css'];
|
|
129
129
|
return [
|
|
130
130
|
...(await Promise.all(cssLanguage.findRegions(state)
|
|
131
131
|
.map(({ from, to }) => cssLintSource(styleLint, state.sliceDoc(from, to), css, doc, from, to)))).flat(),
|
|
@@ -137,7 +137,7 @@ export const getVueLintSource = async (opt) => {
|
|
|
137
137
|
export const getHTMLLintSource = async (opt, view, language) => {
|
|
138
138
|
const vueLintSource = await getVueLintSource(opt), wikiLint = await getWikiLinter({ include: false, ...await getOpt(opt) }, view);
|
|
139
139
|
return async (state) => {
|
|
140
|
-
const { doc } = state, option = await getOpt(opt) ?? {}, wiki = option['wiki'];
|
|
140
|
+
const { doc } = state, option = await getOpt(opt, true) ?? {}, wiki = option['wiki'];
|
|
141
141
|
return [
|
|
142
142
|
...await vueLintSource(state),
|
|
143
143
|
...(await Promise.all(language.findRegions(state)
|