@bhsd/codemirror-mediawiki 2.1.2 → 2.1.3

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.
@@ -16,6 +16,11 @@ export interface MwConfig {
16
16
  }
17
17
  /**
18
18
  * Gets a LanguageSupport instance for the MediaWiki mode.
19
+ * @param config Configuration for the MediaWiki mode
19
20
  */
20
21
  export declare const mediawiki: (config: MwConfig) => LanguageSupport;
22
+ /**
23
+ * Gets a LanguageSupport instance for the mixed MediaWiki-HTML mode.
24
+ * @param config Configuration for the MediaWiki mode
25
+ */
21
26
  export declare const html: (config: MwConfig) => LanguageSupport;
package/mw/dist/base.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.2/dist/main.min.js';
1
+ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.3/dist/main.min.js';
2
2
  (() => {
3
3
  var _a;
4
- mw.loader.load('https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.2/mediawiki.min.css', 'text/css');
4
+ mw.loader.load('https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.3/mediawiki.min.css', 'text/css');
5
5
  const instances = new WeakMap();
6
6
  $.valHooks['textarea'] = {
7
7
  get(elem) {
@@ -139,7 +139,6 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
139
139
  class CodeMirror extends CodeMirror6 {
140
140
  constructor(textarea, lang, config) {
141
141
  super(textarea, lang, config);
142
- this.visible = true;
143
142
  instances.set(textarea, this);
144
143
  if (mw.loader.getState('jquery.textSelection') === 'ready') {
145
144
  $(textarea).data('jquery.textSelection', textSelection);
@@ -147,24 +146,17 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
147
146
  mw.hook('wiki-codemirror6').fire(this);
148
147
  }
149
148
  toggle(show = !this.visible) {
150
- if (show && !this.visible) {
151
- this.view.dispatch({
152
- changes: { from: 0, to: this.view.state.doc.length, insert: this.textarea.value },
153
- });
154
- }
155
- this.visible = show;
156
- this.view.dom.style.setProperty('display', show ? '' : 'none', 'important');
157
- this.textarea.style.display = show ? 'none' : '';
149
+ super.toggle(show);
158
150
  $(this.textarea).data('jquery.textSelection', show && textSelection);
159
151
  }
160
- async defaultLint(on) {
152
+ async defaultLint(on, opt) {
161
153
  if (!on) {
162
154
  this.lint();
163
155
  return;
164
156
  }
165
157
  const { lang } = this;
166
158
  if (!(lang in linters)) {
167
- linters[lang] = await this.getLinter();
159
+ linters[lang] = await this.getLinter(opt);
168
160
  if (this.lang === 'mediawiki' || this.lang === 'html') {
169
161
  const mwConfig = await getMwConfig(), config = {
170
162
  ...await wikiparse.getConfig(),
@@ -200,7 +192,7 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
200
192
  }
201
193
  }
202
194
  document.body.addEventListener('click', e => {
203
- if (e.target instanceof HTMLTextAreaElement && (e.ctrlKey || e.metaKey) && !instances.has(e.target)) {
195
+ if (e.target instanceof HTMLTextAreaElement && e.shiftKey && !instances.has(e.target)) {
204
196
  e.preventDefault();
205
197
  (async () => {
206
198
  var _a;
@@ -231,7 +223,17 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
231
223
  }
232
224
  }
233
225
  const cm = await CodeMirror.fromTextArea(e.target, lang);
234
- void cm.defaultLint(true);
226
+ let opt;
227
+ if (lang === 'mediawiki' && wgNamespaceNumber === 10) {
228
+ opt = { include: true };
229
+ }
230
+ else if (lang === 'javascript' && (wgNamespaceNumber === 8 || wgNamespaceNumber === 2300)) {
231
+ opt = {
232
+ env: { browser: true, es6: true },
233
+ parserOptions: { ecmaVersion: 6 },
234
+ };
235
+ }
236
+ await cm.defaultLint(true, opt);
235
237
  })();
236
238
  }
237
239
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/codemirror-mediawiki",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror",
5
5
  "keywords": [
6
6
  "mediawiki",