@bhsd/codemirror-mediawiki 2.29.1 → 2.30.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/dist/openLinks.js CHANGED
@@ -14,22 +14,33 @@ const modKey = isMac ? 'metaKey' : 'ctrlKey', key = isMac ? 'Meta' : 'Control',
14
14
  'exttag-attribute-value.cm-mw-pagename',
15
15
  'file-text.cm-mw-pagename',
16
16
  ];
17
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
18
- globalThis.document?.addEventListener('keydown', e => {
19
- if (e.key === key) {
20
- for (const ele of document.querySelectorAll('.cm-content')) {
17
+ const toggleOpenLinks = (toggle) => {
18
+ for (const ele of document.querySelectorAll('.cm-content')) {
19
+ if (toggle) {
21
20
  ele.style.setProperty('--codemirror-cursor', 'pointer');
22
21
  }
22
+ else {
23
+ ele.style.removeProperty('--codemirror-cursor');
24
+ }
25
+ }
26
+ };
27
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
28
+ globalThis.document?.addEventListener('keydown', e => {
29
+ if (e.key === key) {
30
+ toggleOpenLinks(true);
23
31
  }
24
32
  });
25
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
26
33
  globalThis.document?.addEventListener('keyup', e => {
27
34
  if (e.key === key) {
28
- for (const ele of document.querySelectorAll('.cm-content')) {
29
- ele.style.removeProperty('--codemirror-cursor');
30
- }
35
+ toggleOpenLinks();
36
+ }
37
+ });
38
+ globalThis.document?.addEventListener('visibilitychange', () => {
39
+ if (document.hidden) {
40
+ toggleOpenLinks();
31
41
  }
32
42
  });
43
+ /* eslint-enable @typescript-eslint/no-unnecessary-condition */
33
44
  const wrapURL = (url) => url.startsWith('//') ? location.protocol + url : url;
34
45
  export const mouseEventListener = (e, view, langConfig) => {
35
46
  if (!e[modKey]
package/dist/statusBar.js CHANGED
@@ -110,12 +110,12 @@ export default (fixer) => showPanel.of(view => {
110
110
  dom.append(worker, message, position);
111
111
  return {
112
112
  dom,
113
- update({ state: { selection: { main }, doc }, transactions, docChanged, selectionSet }) {
113
+ update({ state: { selection: { main }, doc, readOnly }, transactions, docChanged, selectionSet }) {
114
114
  for (const tr of transactions) {
115
115
  for (const effect of tr.effects) {
116
116
  if (effect.is(setDiagnosticsEffect)) {
117
117
  diagnostics = effect.value;
118
- const fixable = Boolean(fixer) && diagnostics.some(hasFix), { classList } = fix.firstChild;
118
+ const fixable = !readOnly && Boolean(fixer) && diagnostics.some(hasFix), { classList } = fix.firstChild;
119
119
  classList.toggle('cm-status-fix-enabled', fixable);
120
120
  classList.toggle('cm-status-fix-disabled', !fixable);
121
121
  worker.classList.toggle('cm-status-worker-enabled', diagnostics.length > 0);