@bhsd/codemirror-mediawiki 3.3.0 → 3.4.1

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/ref.js CHANGED
@@ -82,4 +82,13 @@ export default (cm) => [
82
82
  }
83
83
  }
84
84
  }),
85
+ EditorView.theme({
86
+ '.cm-tooltip-ref': {
87
+ padding: '2px 5px',
88
+ width: 'max-content',
89
+ maxWidth: '60vw',
90
+ cursor: 'pointer',
91
+ whiteSpace: 'pre-wrap',
92
+ },
93
+ }),
85
94
  ];
package/dist/statusBar.js CHANGED
@@ -1,4 +1,4 @@
1
- import { showPanel } from '@codemirror/view';
1
+ import { showPanel, EditorView } from '@codemirror/view';
2
2
  import { nextDiagnostic, setDiagnosticsEffect } from '@codemirror/lint';
3
3
  import { menuRegistry } from './codemirror';
4
4
  const optionAll = /* @__PURE__ */ (() => {
@@ -42,8 +42,6 @@ function getLintMarker(view, severity, menu) {
42
42
  const updateDiagnosticsCount = (diagnostics, s, marker) => {
43
43
  marker.lastChild.textContent = String(diagnostics.filter(({ severity }) => severity === s).length);
44
44
  };
45
- const hasFix = (diagnostic) => diagnostic.actions?.some(({ name }) => name === 'fix' || name.startsWith('Fix:'));
46
- const isItemActionable = (cm, { name, isActionable }) => cm.hasPreference(name) && isActionable(cm);
47
45
  const toggleClass = (classList, enabled) => {
48
46
  classList.toggle('cm-status-fix-enabled', enabled);
49
47
  classList.toggle('cm-status-fix-disabled', !enabled);
@@ -74,8 +72,8 @@ const updateDiagnosticMessage = (cm, allDiagnostics, main, msg) => {
74
72
  };
75
73
  const updateMenu = (cm, allDiagnostics, main, classList, menu, fixer) => {
76
74
  if (menu) {
77
- const actionable = menuRegistry.filter(item => isItemActionable(cm, item)), fixable = new Set(fixer && getDiagnostics(allDiagnostics, main).filter(hasFix)
78
- .map(({ message }) => / \(([^()]+)\)$/u.exec(message)?.[1])
75
+ 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
+ || name !== 'Fix: Stylelint' && name.startsWith('Fix:'))).map(({ message }) => / \(([^()]+)\)$/u.exec(message)?.[1])
79
77
  .filter(Boolean));
80
78
  if (actionable.length === 0 && fixable.size === 0) {
81
79
  toggleClass(classList, false);
@@ -94,66 +92,144 @@ const updateMenu = (cm, allDiagnostics, main, classList, menu, fixer) => {
94
92
  menu.replaceChildren(...actions, ...quickfix);
95
93
  }
96
94
  };
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';
97
96
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
98
- export default (cm, fixer) => showPanel.of(view => {
99
- let diagnostics = [], menu;
100
- if (!view.state.readOnly && (fixer || menuRegistry.length > 0)) {
101
- menu = document.createElement('div');
102
- menu.className = 'cm-status-fix-menu';
103
- menu.tabIndex = -1;
104
- if (fixer) {
105
- menu.addEventListener('click', ({ target }) => {
106
- if (target === menu) {
107
- return;
108
- }
109
- (async () => {
110
- const { doc } = view.state, output = await fixer(doc, target.dataset['rule']);
111
- if (output !== doc.toString()) {
112
- view.dispatch({
113
- changes: { from: 0, to: doc.length, insert: output },
114
- });
97
+ export default (cm, fixer) => [
98
+ showPanel.of(view => {
99
+ let diagnostics = [], menu;
100
+ if (!view.state.readOnly && (fixer || menuRegistry.length > 0)) {
101
+ menu = document.createElement('div');
102
+ menu.className = 'cm-status-fix-menu';
103
+ menu.tabIndex = -1;
104
+ if (fixer) {
105
+ menu.addEventListener('click', ({ target }) => {
106
+ if (target === menu) {
107
+ return;
115
108
  }
116
- view.focus();
117
- })();
109
+ (async () => {
110
+ const { doc } = view.state, output = await fixer(doc, target.dataset['rule']);
111
+ if (output !== doc.toString()) {
112
+ view.dispatch({
113
+ changes: { from: 0, to: doc.length, insert: output },
114
+ });
115
+ }
116
+ view.focus();
117
+ })();
118
+ });
119
+ }
120
+ menu.addEventListener('focusout', () => {
121
+ menu.style.display = 'none';
118
122
  });
123
+ view.dom.append(menu);
119
124
  }
120
- menu.addEventListener('focusout', () => {
121
- menu.style.display = 'none';
122
- });
123
- view.dom.append(menu);
124
- }
125
- const dom = document.createElement('div'), worker = document.createElement('div'), message = document.createElement('div'), position = document.createElement('div'), error = getLintMarker(view, 'error'), warning = getLintMarker(view, 'warning'), fix = getLintMarker(view, 'fix', menu), { classList } = fix.firstChild;
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);
133
- return {
134
- dom,
135
- update({ state: { selection: { main }, doc }, transactions, docChanged, selectionSet }) {
136
- for (const tr of transactions) {
137
- for (const effect of tr.effects) {
138
- if (effect.is(setDiagnosticsEffect)) {
139
- diagnostics = effect.value;
140
- worker.classList.toggle('cm-status-worker-enabled', diagnostics.length > 0);
141
- updateDiagnosticsCount(diagnostics, 'error', error);
142
- updateDiagnosticsCount(diagnostics, 'warning', warning);
143
- updateDiagnosticMessage(cm, diagnostics, main, message);
144
- updateMenu(cm, diagnostics, main, classList, menu, fixer);
125
+ const dom = document.createElement('div'), worker = document.createElement('div'), message = document.createElement('div'), position = document.createElement('div'), error = getLintMarker(view, 'error'), warning = getLintMarker(view, 'warning'), fix = getLintMarker(view, 'fix', menu), { classList } = fix.firstChild;
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);
133
+ return {
134
+ dom,
135
+ update({ state: { selection: { main }, doc }, transactions, docChanged, selectionSet }) {
136
+ for (const tr of transactions) {
137
+ for (const effect of tr.effects) {
138
+ if (effect.is(setDiagnosticsEffect)) {
139
+ diagnostics = effect.value;
140
+ worker.classList.toggle('cm-status-worker-enabled', diagnostics.length > 0);
141
+ updateDiagnosticsCount(diagnostics, 'error', error);
142
+ updateDiagnosticsCount(diagnostics, 'warning', warning);
143
+ updateDiagnosticMessage(cm, diagnostics, main, message);
144
+ updateMenu(cm, diagnostics, main, classList, menu, fixer);
145
+ }
145
146
  }
146
147
  }
147
- }
148
- if (docChanged || selectionSet) {
149
- updateDiagnosticMessage(cm, diagnostics, main, message);
150
- updateMenu(cm, diagnostics, main, classList, menu, fixer);
151
- const { number, from } = doc.lineAt(main.head);
152
- position.textContent = `${number}:${main.head - from}`;
153
- if (!main.empty) {
154
- position.textContent += ` (${main.to - main.from})`;
148
+ if (docChanged || selectionSet) {
149
+ updateDiagnosticMessage(cm, diagnostics, main, message);
150
+ updateMenu(cm, diagnostics, main, classList, menu, fixer);
151
+ const { number, from } = doc.lineAt(main.head);
152
+ position.textContent = `${number}:${main.head - from}`;
153
+ if (!main.empty) {
154
+ position.textContent += ` (${main.to - main.from})`;
155
+ }
155
156
  }
156
- }
157
+ },
158
+ };
159
+ }),
160
+ EditorView.theme({
161
+ [panelSelector]: {
162
+ lineHeight: 1.4,
163
+ },
164
+ [`${panelSelector}>div`]: {
165
+ padding: '0 .3em',
166
+ display: 'table-cell',
167
+ },
168
+ [workerSelector]: {
169
+ '-webkitUserSelect': 'none',
170
+ userSelect: 'none',
171
+ },
172
+ [`${workerSelector}>*`]: {
173
+ display: 'table-cell',
174
+ whiteSpace: 'nowrap',
175
+ },
176
+ [`${errorSelector},${warningSelector}`]: {
177
+ paddingRight: '8px',
178
+ },
179
+ [`.cm-status-worker-enabled ${errorSelector},.cm-status-worker-enabled ${warningSelector}`]: {
180
+ cursor: 'pointer',
181
+ },
182
+ [`${workerSelector}>*>div`]: {
183
+ display: 'inline-block',
184
+ verticalAlign: 'middle',
185
+ },
186
+ [`${workerSelector}>*>div:first-child`]: {
187
+ marginRight: '4px',
188
+ width: '1em',
189
+ height: '1em',
190
+ },
191
+ [`${disabledSelector},${enabledSelector}`]: {
192
+ maskImage: "url('data:image/svg+xml,"
193
+ + '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">'
194
+ // eslint-disable-next-line @stylistic/max-len
195
+ + '<path d="M8 19a1 1 0 001 1h2a1 1 0 001-1v-1H8zm9-12a7 7 0 10-12 4.9S7 14 7 15v1a1 1 0 001 1h4a1 1 0 001-1v-1c0-1 2-3.1 2-3.1A7 7 0 0017 7"/>'
196
+ + '</svg>'
197
+ + "')",
198
+ maskSize: '100%',
199
+ maskRepeat: 'no-repeat',
200
+ maskPosition: 'center',
201
+ },
202
+ [disabledSelector]: {
203
+ backgroundColor: '#dadde3',
204
+ },
205
+ [enabledSelector]: {
206
+ backgroundColor: '#ffce31',
207
+ cursor: 'pointer',
208
+ },
209
+ [menuSelector]: {
210
+ display: 'none',
211
+ position: 'absolute',
212
+ zIndex: 301,
213
+ border: '1px solid #ddd',
214
+ borderRadius: '2px',
215
+ outline: 'none',
216
+ whiteSpace: 'nowrap',
217
+ },
218
+ [`${menuSelector}>div`]: {
219
+ padding: '1px 5px',
220
+ cursor: 'pointer',
221
+ },
222
+ [messageSelector]: {
223
+ borderStyle: 'solid',
224
+ borderWidth: '0 1px',
225
+ width: '100%',
226
+ },
227
+ [`${messageSelector} .cm-diagnosticAction`]: {
228
+ paddingTop: 0,
229
+ paddingBottom: 0,
230
+ },
231
+ '.cm-status-line': {
232
+ whiteSpace: 'nowrap',
157
233
  },
158
- };
159
- });
234
+ }),
235
+ ];
package/dist/theme.js CHANGED
@@ -53,15 +53,15 @@ nord = [
53
53
  nordBase,
54
54
  /* @__PURE__ */ EditorView.theme({
55
55
  'div.cm-activeLine': {
56
- backgroundColor: '#4c566a44',
57
- },
58
- '&.cm-focused .cm-matchingTag, &.cm-focused .cm-nonmatchingTag': {
59
- outline: '1px solid #8fbcbb',
56
+ backgroundColor: 'rgb(76,86,106,.27)',
60
57
  },
61
58
  '&.cm-focused .cm-matchingTag': {
62
59
  backgroundColor: '#eceff4',
63
60
  color: '#434c5e',
64
61
  },
62
+ '&.cm-focused .cm-nonmatchingTag': {
63
+ backgroundColor: 'rgb(235,203,139,.32)',
64
+ },
65
65
  ['&.cm-focused>.cm-scroller>.cm-selectionLayer div.cm-selectionBackground,'
66
66
  + '.cm-tooltip-hover code, .cm-status-fix-menu>div:hover, .cm-diagnosticAction, div.cm-tooltip-fold']: {
67
67
  backgroundColor: '#4c566a',