@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/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__ */ (() => {
@@ -94,66 +94,144 @@ const updateMenu = (cm, allDiagnostics, main, classList, menu, fixer) => {
94
94
  menu.replaceChildren(...actions, ...quickfix);
95
95
  }
96
96
  };
97
+ 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
98
  // 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
- });
99
+ export default (cm, fixer) => [
100
+ showPanel.of(view => {
101
+ let diagnostics = [], menu;
102
+ if (!view.state.readOnly && (fixer || menuRegistry.length > 0)) {
103
+ menu = document.createElement('div');
104
+ menu.className = 'cm-status-fix-menu';
105
+ menu.tabIndex = -1;
106
+ if (fixer) {
107
+ menu.addEventListener('click', ({ target }) => {
108
+ if (target === menu) {
109
+ return;
115
110
  }
116
- view.focus();
117
- })();
111
+ (async () => {
112
+ const { doc } = view.state, output = await fixer(doc, target.dataset['rule']);
113
+ if (output !== doc.toString()) {
114
+ view.dispatch({
115
+ changes: { from: 0, to: doc.length, insert: output },
116
+ });
117
+ }
118
+ view.focus();
119
+ })();
120
+ });
121
+ }
122
+ menu.addEventListener('focusout', () => {
123
+ menu.style.display = 'none';
118
124
  });
125
+ view.dom.append(menu);
119
126
  }
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);
127
+ 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;
128
+ worker.className = 'cm-status-worker';
129
+ worker.append(error, warning, fix);
130
+ message.className = 'cm-status-message';
131
+ position.className = 'cm-status-line';
132
+ position.textContent = '0:0';
133
+ dom.className = 'cm-panel cm-panel-status';
134
+ dom.append(worker, message, position);
135
+ return {
136
+ dom,
137
+ update({ state: { selection: { main }, doc }, transactions, docChanged, selectionSet }) {
138
+ for (const tr of transactions) {
139
+ for (const effect of tr.effects) {
140
+ if (effect.is(setDiagnosticsEffect)) {
141
+ diagnostics = effect.value;
142
+ worker.classList.toggle('cm-status-worker-enabled', diagnostics.length > 0);
143
+ updateDiagnosticsCount(diagnostics, 'error', error);
144
+ updateDiagnosticsCount(diagnostics, 'warning', warning);
145
+ updateDiagnosticMessage(cm, diagnostics, main, message);
146
+ updateMenu(cm, diagnostics, main, classList, menu, fixer);
147
+ }
145
148
  }
146
149
  }
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})`;
150
+ if (docChanged || selectionSet) {
151
+ updateDiagnosticMessage(cm, diagnostics, main, message);
152
+ updateMenu(cm, diagnostics, main, classList, menu, fixer);
153
+ const { number, from } = doc.lineAt(main.head);
154
+ position.textContent = `${number}:${main.head - from}`;
155
+ if (!main.empty) {
156
+ position.textContent += ` (${main.to - main.from})`;
157
+ }
155
158
  }
156
- }
159
+ },
160
+ };
161
+ }),
162
+ EditorView.theme({
163
+ [panelSelector]: {
164
+ lineHeight: 1.4,
165
+ },
166
+ [`${panelSelector}>div`]: {
167
+ padding: '0 .3em',
168
+ display: 'table-cell',
169
+ },
170
+ [workerSelector]: {
171
+ '-webkitUserSelect': 'none',
172
+ userSelect: 'none',
173
+ },
174
+ [`${workerSelector}>*`]: {
175
+ display: 'table-cell',
176
+ whiteSpace: 'nowrap',
177
+ },
178
+ [`${errorSelector},${warningSelector}`]: {
179
+ paddingRight: '8px',
180
+ },
181
+ [`.cm-status-worker-enabled ${errorSelector},.cm-status-worker-enabled ${warningSelector}`]: {
182
+ cursor: 'pointer',
183
+ },
184
+ [`${workerSelector}>*>div`]: {
185
+ display: 'inline-block',
186
+ verticalAlign: 'middle',
187
+ },
188
+ [`${workerSelector}>*>div:first-child`]: {
189
+ marginRight: '4px',
190
+ width: '1em',
191
+ height: '1em',
192
+ },
193
+ [`${disabledSelector},${enabledSelector}`]: {
194
+ maskImage: "url('data:image/svg+xml,"
195
+ + '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">'
196
+ // eslint-disable-next-line @stylistic/max-len
197
+ + '<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"/>'
198
+ + '</svg>'
199
+ + "')",
200
+ maskSize: '100%',
201
+ maskRepeat: 'no-repeat',
202
+ maskPosition: 'center',
203
+ },
204
+ [disabledSelector]: {
205
+ backgroundColor: '#dadde3',
206
+ },
207
+ [enabledSelector]: {
208
+ backgroundColor: '#ffce31',
209
+ cursor: 'pointer',
210
+ },
211
+ [menuSelector]: {
212
+ display: 'none',
213
+ position: 'absolute',
214
+ zIndex: 301,
215
+ border: '1px solid #ddd',
216
+ borderRadius: '2px',
217
+ outline: 'none',
218
+ whiteSpace: 'nowrap',
219
+ },
220
+ [`${menuSelector}>div`]: {
221
+ padding: '1px 5px',
222
+ cursor: 'pointer',
223
+ },
224
+ [messageSelector]: {
225
+ borderStyle: 'solid',
226
+ borderWidth: '0 1px',
227
+ width: '100%',
228
+ },
229
+ [`${messageSelector} .cm-diagnosticAction`]: {
230
+ paddingTop: 0,
231
+ paddingBottom: 0,
232
+ },
233
+ '.cm-status-line': {
234
+ whiteSpace: 'nowrap',
157
235
  },
158
- };
159
- });
236
+ }),
237
+ ];
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',