@fsegurai/codemirror-theme-solarized-dark 6.3.0 → 6.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/index.cjs CHANGED
@@ -1,57 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var language = require('@codemirror/language');
4
- var view = require('@codemirror/view');
5
- var highlight = require('@lezer/highlight');
3
+ var codemirrorThemeCore = require('@fsegurai/codemirror-theme-core');
6
4
 
7
5
  // Helper module for styling options
8
- const generalContent = {
9
- fontSize: '14px',
10
- fontFamily: 'JetBrains Mono, Consolas, monospace',
11
- lineHeight: '1.6',
12
- };
13
- const generalDiff = {
14
- insertedTextDecoration: 'none',
15
- deletedTextDecoration: 'line-through',
16
- insertedLinePadding: '1px 3px',
17
- borderRadius: '3px'};
18
- const generalGutter = {
19
- border: 'none',
20
- paddingRight: '8px',
21
- fontSize: '0.9em',
22
- lineHeight: '1.78', // Adjusted to compensate for 0.9em fontSize (1.6 / 0.9 ≈ 1.78)
23
- };
24
- const generalPanel = {
25
- borderRadius: '4px',
26
- padding: '2px 10px',
27
- };
28
- const generalLine = {
29
- borderRadius: '2px',
30
- };
31
- const generalMatching = {
32
- borderRadius: '2px',
33
- };
34
- const generalPlaceholder = {
35
- borderRadius: '4px',
36
- padding: '0 5px',
37
- margin: '0 2px',
38
- };
39
- const generalScroller = {
40
- width: '12px',
41
- height: '12px',
42
- borderRadius: '6px',
43
- };
44
- const generalSearchField = {
45
- borderRadius: '4px',
46
- padding: '2px 6px',
47
- };
48
- const generalTooltip = {
49
- borderRadius: '4px',
50
- borderRadiusSelected: '3px',
51
- lineHeight: '1.3',
52
- padding: '4px 8px',
53
- paddingRight: '8px',
54
- };
55
6
  /**
56
7
  * Function to apply merge revert styles for a theme
57
8
  * @param styles Styles for the merge revert buttons
@@ -101,498 +52,6 @@ function applyMergeRevertStyles(styles) {
101
52
  document.head.appendChild(styleEl);
102
53
  }
103
54
 
104
- // Shared theme core: every theme package describes a palette (`ThemeDefinition`) and this module turns it into the
105
- // CodeMirror extension. Generated into each package by `bun run generate:helpers`; edit only the copy in
106
- // `packages/.helper/utils/`.
107
- /** Parent of every fine role: an omitted fine role resolves to its parent. */
108
- const ROLE_PARENTS = {
109
- controlKeyword: 'keyword',
110
- moduleKeyword: 'keyword',
111
- definitionKeyword: 'keyword',
112
- operatorKeyword: 'operator',
113
- modifier: 'keyword',
114
- arithmeticOperator: 'operator',
115
- logicOperator: 'operator',
116
- compareOperator: 'operator',
117
- bitwiseOperator: 'operator',
118
- updateOperator: 'operator',
119
- derefOperator: 'operator',
120
- definitionOperator: 'operator',
121
- typeOperator: 'operator',
122
- controlOperator: 'operator',
123
- separator: 'punctuation',
124
- bracket: 'punctuation',
125
- paren: 'bracket',
126
- brace: 'bracket',
127
- squareBracket: 'bracket',
128
- angleBracket: 'bracket',
129
- character: 'name',
130
- macroName: 'name',
131
- variable: 'name',
132
- localVariable: 'variable',
133
- variableDefinition: 'variable',
134
- nameDefinition: 'variableDefinition',
135
- functionDefinition: 'function',
136
- self: 'variable',
137
- label: 'name',
138
- propertyDefinition: 'property',
139
- method: 'property',
140
- methodDefinition: 'method',
141
- specialProperty: 'property',
142
- typeDefinition: 'type',
143
- className: 'type',
144
- namespace: 'type',
145
- standardTag: 'tag',
146
- annotation: 'meta',
147
- documentMeta: 'meta',
148
- processingInstruction: 'meta',
149
- attributeValue: 'string',
150
- literal: 'string',
151
- docString: 'string',
152
- regexp: 'string',
153
- specialString: 'regexp',
154
- escape: 'string',
155
- unit: 'number',
156
- atom: 'constant',
157
- bool: 'atom',
158
- null: 'constant',
159
- constantName: 'constant',
160
- standardName: 'constant',
161
- color: 'standardName',
162
- specialVariable: 'constant',
163
- docComment: 'comment',
164
- headingLevel: 'heading',
165
- heading1: 'headingLevel',
166
- heading2: 'headingLevel',
167
- heading3: 'headingLevel',
168
- heading4: 'headingLevel',
169
- heading5: 'headingLevel',
170
- heading6: 'headingLevel',
171
- list: 'name',
172
- quote: 'string',
173
- monospace: 'string',
174
- contentSeparator: 'punctuation',
175
- };
176
- /**
177
- * Canonical tag → role table shared by every theme: every Lezer base tag and the modifier combinations that the
178
- * official grammars emit. Each tag appears once, so no rule is shadowed by a later one.
179
- */
180
- const SYNTAX_TAGS = [
181
- ['keyword', [highlight.tags.keyword]],
182
- ['controlKeyword', [highlight.tags.controlKeyword]],
183
- ['moduleKeyword', [highlight.tags.moduleKeyword]],
184
- ['definitionKeyword', [highlight.tags.definitionKeyword]],
185
- ['operatorKeyword', [highlight.tags.operatorKeyword]],
186
- ['modifier', [highlight.tags.modifier]],
187
- ['operator', [highlight.tags.operator]],
188
- ['arithmeticOperator', [highlight.tags.arithmeticOperator]],
189
- ['logicOperator', [highlight.tags.logicOperator]],
190
- ['compareOperator', [highlight.tags.compareOperator]],
191
- ['bitwiseOperator', [highlight.tags.bitwiseOperator]],
192
- ['updateOperator', [highlight.tags.updateOperator]],
193
- ['derefOperator', [highlight.tags.derefOperator]],
194
- ['definitionOperator', [highlight.tags.definitionOperator]],
195
- ['typeOperator', [highlight.tags.typeOperator]],
196
- ['controlOperator', [highlight.tags.controlOperator]],
197
- ['punctuation', [highlight.tags.punctuation, highlight.tags.function(highlight.tags.punctuation)]],
198
- ['separator', [highlight.tags.separator]],
199
- ['bracket', [highlight.tags.bracket]],
200
- ['paren', [highlight.tags.paren]],
201
- ['brace', [highlight.tags.brace, highlight.tags.special(highlight.tags.brace)]],
202
- ['squareBracket', [highlight.tags.squareBracket]],
203
- ['angleBracket', [highlight.tags.angleBracket]],
204
- ['name', [highlight.tags.name, highlight.tags.special(highlight.tags.name)]],
205
- ['character', [highlight.tags.character]],
206
- ['macroName', [highlight.tags.macroName]],
207
- ['variable', [highlight.tags.variableName, highlight.tags.standard(highlight.tags.variableName)]],
208
- ['localVariable', [highlight.tags.local(highlight.tags.variableName)]],
209
- ['variableDefinition', [highlight.tags.definition(highlight.tags.variableName)]],
210
- ['nameDefinition', [highlight.tags.definition(highlight.tags.name)]],
211
- ['function', [highlight.tags.function(highlight.tags.variableName)]],
212
- ['functionDefinition', [highlight.tags.definition(highlight.tags.function(highlight.tags.variableName))]],
213
- ['self', [highlight.tags.self]],
214
- ['label', [highlight.tags.labelName]],
215
- ['property', [highlight.tags.propertyName]],
216
- ['propertyDefinition', [highlight.tags.definition(highlight.tags.propertyName)]],
217
- ['method', [highlight.tags.function(highlight.tags.propertyName)]],
218
- ['methodDefinition', [highlight.tags.definition(highlight.tags.function(highlight.tags.propertyName))]],
219
- ['specialProperty', [highlight.tags.special(highlight.tags.propertyName), highlight.tags.definition(highlight.tags.special(highlight.tags.propertyName))]],
220
- ['type', [highlight.tags.typeName, highlight.tags.standard(highlight.tags.typeName)]],
221
- ['typeDefinition', [highlight.tags.definition(highlight.tags.typeName)]],
222
- ['className', [highlight.tags.className, highlight.tags.definition(highlight.tags.className), highlight.tags.constant(highlight.tags.className)]],
223
- ['namespace', [highlight.tags.namespace]],
224
- ['tag', [highlight.tags.tagName]],
225
- ['standardTag', [highlight.tags.standard(highlight.tags.tagName)]],
226
- ['attribute', [highlight.tags.attributeName, highlight.tags.special(highlight.tags.attributeName)]],
227
- ['attributeValue', [highlight.tags.attributeValue]],
228
- ['literal', [highlight.tags.literal]],
229
- ['string', [highlight.tags.string]],
230
- ['docString', [highlight.tags.docString]],
231
- ['regexp', [highlight.tags.regexp]],
232
- ['specialString', [highlight.tags.special(highlight.tags.string), highlight.tags.special(highlight.tags.docString)]],
233
- ['escape', [highlight.tags.escape]],
234
- ['number', [highlight.tags.number, highlight.tags.integer, highlight.tags.float]],
235
- ['unit', [highlight.tags.unit]],
236
- ['atom', [highlight.tags.atom]],
237
- ['bool', [highlight.tags.bool]],
238
- ['null', [highlight.tags.null]],
239
- ['constantName', [highlight.tags.constant(highlight.tags.name)]],
240
- ['standardName', [highlight.tags.standard(highlight.tags.name)]],
241
- ['color', [highlight.tags.color]],
242
- ['specialVariable', [highlight.tags.special(highlight.tags.variableName)]],
243
- ['comment', [highlight.tags.comment, highlight.tags.lineComment, highlight.tags.blockComment]],
244
- ['docComment', [highlight.tags.docComment]],
245
- ['meta', [highlight.tags.meta]],
246
- ['documentMeta', [highlight.tags.documentMeta]],
247
- ['processingInstruction', [highlight.tags.processingInstruction]],
248
- ['annotation', [highlight.tags.annotation]],
249
- ['content', [highlight.tags.content, highlight.tags.special(highlight.tags.content)]],
250
- ['heading', [highlight.tags.heading]],
251
- ['heading1', [highlight.tags.heading1]],
252
- ['heading2', [highlight.tags.heading2]],
253
- ['heading3', [highlight.tags.heading3]],
254
- ['heading4', [highlight.tags.heading4]],
255
- ['heading5', [highlight.tags.heading5]],
256
- ['heading6', [highlight.tags.heading6]],
257
- ['list', [highlight.tags.list]],
258
- ['quote', [highlight.tags.quote]],
259
- ['monospace', [highlight.tags.monospace]],
260
- ['contentSeparator', [highlight.tags.contentSeparator]],
261
- ['link', [highlight.tags.link]],
262
- ['url', [highlight.tags.url]],
263
- ['emphasis', [highlight.tags.emphasis]],
264
- ['strong', [highlight.tags.strong]],
265
- ['strikethrough', [highlight.tags.strikethrough]],
266
- ['invalid', [highlight.tags.invalid]],
267
- ['inserted', [highlight.tags.inserted]],
268
- ['deleted', [highlight.tags.deleted]],
269
- ['changed', [highlight.tags.changed]],
270
- ];
271
- /** Inline SVG image (same encoding as `@codemirror/lint`), used to draw lint markers in the theme colors. */
272
- function svg(content, attrs = 'viewBox="0 0 40 40"') {
273
- return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
274
- }
275
- /** Wavy underline of a lint range. */
276
- function lintUnderline(color) {
277
- return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
278
- }
279
- /**
280
- * Canonical UI template: the same selectors for every theme, only palette values differ. Rules of equal specificity
281
- * keep the order of the original theme files (later rules win).
282
- */
283
- function uiTemplate(ui) {
284
- return {
285
- '&': {
286
- color: ui.foreground,
287
- backgroundColor: ui.background,
288
- border: ui.border,
289
- fontSize: generalContent.fontSize,
290
- fontFamily: generalContent.fontFamily,
291
- },
292
- '.cm-content': { caretColor: ui.cursor, lineHeight: generalContent.lineHeight },
293
- '.cm-cursor, .cm-dropCursor': {
294
- borderLeftColor: ui.cursor,
295
- borderLeftWidth: ui.cursorWidth,
296
- boxShadow: ui.cursorShadow,
297
- },
298
- '.cm-cursor-secondary': { borderLeftColor: ui.cursor, opacity: '0.6' },
299
- '.cm-fat-cursor': {
300
- backgroundColor: ui.fatCursor.background,
301
- color: ui.background,
302
- border: ui.fatCursor.border,
303
- boxShadow: ui.cursorShadow,
304
- },
305
- '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': { backgroundColor: ui.selection, color: ui.selectionForeground, outline: ui.selectionOutline },
306
- '&:not(.cm-focused) .cm-selectionBackground': { backgroundColor: ui.selectionInactive },
307
- '.cm-selectionLayer': { zIndex: 100 },
308
- '.cm-searchMatch': {
309
- backgroundColor: ui.searchMatch.background,
310
- outline: `${ui.outlineWidth} solid ${ui.searchMatch.outline}`,
311
- color: ui.searchMatch.foreground,
312
- borderRadius: generalSearchField.borderRadius,
313
- boxShadow: ui.searchMatch.shadow,
314
- },
315
- '.cm-searchMatch span': { color: ui.searchMatch.foreground },
316
- '.cm-searchMatch.cm-searchMatch-selected': {
317
- backgroundColor: ui.searchMatch.selectedBackground,
318
- color: ui.searchMatch.selectedForeground,
319
- padding: generalSearchField.padding,
320
- outline: ui.searchMatch.selectedOutline,
321
- boxShadow: ui.searchMatch.selectedShadow,
322
- },
323
- '.cm-searchMatch.cm-searchMatch-selected span': { color: ui.searchMatch.selectedForeground },
324
- '.cm-search.cm-panel.cm-textfield': {
325
- color: ui.panel.foreground,
326
- borderRadius: generalSearchField.borderRadius,
327
- padding: generalSearchField.padding,
328
- },
329
- '.cm-textfield': {
330
- backgroundColor: ui.panel.inputBackground,
331
- color: ui.panel.foreground,
332
- border: ui.panel.inputBorder,
333
- borderRadius: generalSearchField.borderRadius,
334
- padding: generalSearchField.padding,
335
- },
336
- '.cm-panels': {
337
- backgroundColor: ui.panel.background,
338
- color: ui.panel.foreground,
339
- border: ui.panel.outline,
340
- borderRadius: generalPanel.borderRadius,
341
- boxShadow: ui.panel.shadow,
342
- },
343
- '.cm-panels.cm-panels-top': { borderBottom: `${ui.panel.borderWidth} solid ${ui.panel.border}` },
344
- '.cm-panels.cm-panels-bottom': { borderTop: `${ui.panel.borderWidth} solid ${ui.panel.border}` },
345
- '.cm-panel.cm-gotoLine': { color: ui.panel.foreground, padding: generalPanel.padding },
346
- '.cm-panel button, .cm-button': {
347
- backgroundColor: ui.panel.buttonBackground,
348
- backgroundImage: 'none',
349
- color: ui.panel.buttonForeground,
350
- border: ui.panel.buttonBorder,
351
- borderRadius: generalPanel.borderRadius,
352
- padding: generalPanel.padding,
353
- },
354
- '.cm-panel button:hover, .cm-button:hover': {
355
- backgroundColor: ui.panel.buttonHoverBackground,
356
- color: ui.panel.buttonHoverForeground,
357
- border: ui.panel.buttonHoverBorder,
358
- boxShadow: ui.panel.buttonHoverShadow,
359
- },
360
- '.cm-activeLine': {
361
- backgroundColor: ui.activeLine,
362
- borderLeft: ui.activeLineBorder.left,
363
- borderRight: ui.activeLineBorder.right,
364
- borderRadius: generalLine.borderRadius,
365
- zIndex: 1,
366
- },
367
- '.cm-gutters': {
368
- backgroundColor: ui.gutter.background,
369
- color: ui.gutter.foreground,
370
- border: generalGutter.border,
371
- borderRight: `${ui.outlineWidth} solid ${ui.gutter.border}`,
372
- paddingRight: generalGutter.paddingRight,
373
- },
374
- '.cm-activeLineGutter': {
375
- backgroundColor: ui.gutter.activeBackground,
376
- color: ui.gutter.activeForeground,
377
- fontWeight: ui.gutter.activeFontWeight,
378
- border: ui.gutter.activeBorder,
379
- },
380
- '.cm-lineNumbers': { fontSize: generalGutter.fontSize, lineHeight: generalGutter.lineHeight },
381
- '.cm-foldGutter': { fontSize: generalGutter.fontSize, lineHeight: generalGutter.lineHeight },
382
- '.cm-foldGutter .cm-gutterElement': { color: ui.gutter.foreground, cursor: 'pointer' },
383
- '.cm-foldGutter .cm-gutterElement:hover': { color: ui.gutter.foldHover },
384
- '.cm-gutter-lint': { color: ui.gutter.foreground },
385
- '.cm-lint-marker': { width: '1em', height: '1em' },
386
- '.cm-lint-marker-error': {
387
- content: svg(`<circle cx="20" cy="20" r="15" fill="${ui.diagnostic.error}" stroke="${ui.background}" stroke-width="4"/>`),
388
- },
389
- '.cm-lint-marker-warning': {
390
- content: svg(`<path fill="${ui.diagnostic.warning}" stroke="${ui.background}" stroke-width="4" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
391
- },
392
- '.cm-lint-marker-info': {
393
- content: svg(`<path fill="${ui.diagnostic.info}" stroke="${ui.background}" stroke-width="4" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`),
394
- },
395
- '.cm-changeGutter': { backgroundColor: ui.gutter.background },
396
- '.cm-merge-b .cm-changedLineGutter, .cm-inlineChangedLineGutter': { background: ui.diff.insertedForeground },
397
- '.cm-merge-a .cm-changedLineGutter, .cm-deletedLineGutter': { background: ui.diff.deletedForeground },
398
- '.cm-insertedLine': {
399
- textDecoration: generalDiff.insertedTextDecoration,
400
- backgroundColor: ui.diff.insertedBackground,
401
- color: ui.diff.insertedForeground,
402
- padding: generalDiff.insertedLinePadding,
403
- borderRadius: generalDiff.borderRadius,
404
- },
405
- 'ins.cm-insertedLine, ins.cm-insertedLine:not(:has(.cm-changedText))': {
406
- textDecoration: generalDiff.insertedTextDecoration,
407
- backgroundColor: `${ui.diff.insertedBackground} !important`,
408
- color: ui.diff.insertedForeground,
409
- padding: generalDiff.insertedLinePadding,
410
- borderRadius: generalDiff.borderRadius,
411
- border: ui.diff.insertedBorder,
412
- },
413
- 'ins.cm-insertedLine .cm-changedText': { background: 'transparent !important' },
414
- '.cm-deletedLine': {
415
- textDecoration: generalDiff.deletedTextDecoration,
416
- backgroundColor: ui.diff.deletedBackground,
417
- color: ui.diff.deletedForeground,
418
- padding: generalDiff.insertedLinePadding,
419
- borderRadius: generalDiff.borderRadius,
420
- },
421
- // Merge view deletions only: `del` decorations, inline deletion widgets and the lines of deleted chunks. `:where()`
422
- // keeps the specificity of the former bare `del` selector without styling other `del` elements.
423
- 'del.cm-deletedLine, del.cm-deletedText, :where(.cm-deletedChunk) del, :where(.cm-deletedChunk) del:not(:has(.cm-deletedText))': {
424
- textDecoration: generalDiff.deletedTextDecoration,
425
- backgroundColor: `${ui.diff.deletedBackground} !important`,
426
- color: ui.diff.deletedForeground,
427
- padding: generalDiff.insertedLinePadding,
428
- borderRadius: generalDiff.borderRadius,
429
- border: ui.diff.deletedBorder,
430
- },
431
- ':where(.cm-deletedChunk) del .cm-deletedText, :where(.cm-deletedChunk) del .cm-changedText, del:where(.cm-deletedLine) .cm-deletedText, del:where(.cm-deletedLine) .cm-changedText': { background: 'transparent !important' },
432
- '.cm-merge-b .cm-changedLine, .cm-inlineChangedLine': { backgroundColor: ui.diff.insertedBackground },
433
- '.cm-merge-a .cm-changedLine, .cm-deletedChunk': { backgroundColor: ui.diff.deletedBackground },
434
- '.cm-collapsedLines': {
435
- background: ui.foldPlaceholder.background,
436
- color: ui.foldPlaceholder.foreground,
437
- },
438
- '.cm-mergeSpacer': { background: ui.merge.backgroundColor },
439
- '.cm-tooltip': {
440
- backgroundColor: ui.tooltip.background,
441
- color: ui.tooltip.foreground,
442
- border: `${ui.outlineWidth} solid ${ui.tooltip.border}`,
443
- borderRadius: generalTooltip.borderRadius,
444
- padding: generalTooltip.padding,
445
- boxShadow: ui.tooltip.shadow,
446
- },
447
- '.cm-tooltip-autocomplete > ul': { backgroundColor: ui.tooltip.listBackground, border: ui.tooltip.listBorder },
448
- '.cm-tooltip-autocomplete > ul > li': { padding: generalTooltip.padding, lineHeight: generalTooltip.lineHeight },
449
- '.cm-tooltip-autocomplete > ul > li:hover': { backgroundColor: ui.tooltip.hoverBackground },
450
- '.cm-tooltip-autocomplete > ul > li[aria-selected]': {
451
- backgroundColor: ui.tooltip.selectedBackground,
452
- color: ui.tooltip.selectedForeground,
453
- border: ui.tooltip.selectedBorder,
454
- borderRadius: generalTooltip.borderRadiusSelected,
455
- },
456
- '.cm-tooltip-autocomplete > ul > li > span.cm-completionIcon': {
457
- color: ui.tooltip.icon,
458
- paddingRight: generalTooltip.paddingRight,
459
- },
460
- '.cm-tooltip-autocomplete > ul > li > span.cm-completionDetail': { color: ui.tooltip.detail, fontStyle: 'italic' },
461
- '.cm-completionMatchedText': {
462
- color: 'inherit',
463
- fontWeight: 'bold',
464
- textDecoration: 'underline',
465
- textDecorationColor: ui.matchingBracket.outline,
466
- },
467
- '.cm-completionInfo': {
468
- backgroundColor: ui.tooltip.background,
469
- color: ui.tooltip.foreground,
470
- border: `${ui.outlineWidth} solid ${ui.tooltip.border}`,
471
- padding: generalTooltip.padding,
472
- },
473
- '.cm-tooltip .cm-tooltip-arrow:before': { borderTopColor: 'transparent', borderBottomColor: 'transparent' },
474
- '.cm-tooltip .cm-tooltip-arrow:after': {
475
- borderTopColor: ui.tooltip.background,
476
- borderBottomColor: ui.tooltip.background,
477
- },
478
- '.cm-tooltip-lint': { color: ui.tooltip.foreground, padding: '0' },
479
- '.cm-tooltip-section:not(:first-child)': { borderTop: `1px solid ${ui.tooltip.border}` },
480
- '.cm-diagnostic-error': {
481
- borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.error}`,
482
- backgroundColor: ui.diagnostic.errorBackground,
483
- },
484
- '.cm-diagnostic-warning': {
485
- borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.warning}`,
486
- backgroundColor: ui.diagnostic.warningBackground,
487
- },
488
- '.cm-diagnostic-info': {
489
- borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.info}`,
490
- backgroundColor: ui.diagnostic.infoBackground,
491
- },
492
- '.cm-diagnostic-hint': { borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.hint}` },
493
- '.cm-diagnosticAction': {
494
- backgroundColor: ui.panel.buttonBackground,
495
- color: ui.panel.buttonForeground,
496
- border: ui.panel.buttonBorder,
497
- borderRadius: generalPanel.borderRadius,
498
- },
499
- '.cm-lintRange-error': { backgroundImage: lintUnderline(ui.diagnostic.error) },
500
- '.cm-lintRange-warning': { backgroundImage: lintUnderline(ui.diagnostic.warning) },
501
- '.cm-lintRange-info': { backgroundImage: lintUnderline(ui.diagnostic.info) },
502
- '.cm-lintRange-hint': { backgroundImage: lintUnderline(ui.diagnostic.hint) },
503
- '.cm-lintPoint-error': { borderBottom: `${ui.diagnostic.underlineWidth} wavy ${ui.diagnostic.error}` },
504
- '.cm-lintPoint-warning': { borderBottom: `${ui.diagnostic.underlineWidth} wavy ${ui.diagnostic.warning}` },
505
- '.cm-lintPoint-info': { borderBottom: `${ui.diagnostic.underlineWidth} wavy ${ui.diagnostic.info}` },
506
- '.cm-matchingBracket': {
507
- backgroundColor: ui.matchingBracket.background,
508
- outline: `${ui.outlineWidth} solid ${ui.matchingBracket.outline}`,
509
- borderRadius: generalMatching.borderRadius,
510
- boxShadow: ui.matchingBracket.shadow,
511
- },
512
- '.cm-nonmatchingBracket': {
513
- backgroundColor: ui.nonMatchingBracket.background,
514
- outline: `${ui.outlineWidth} solid ${ui.nonMatchingBracket.outline}`,
515
- borderRadius: generalMatching.borderRadius,
516
- },
517
- '.cm-selectionMatch': {
518
- backgroundColor: ui.selectionMatch.background,
519
- outline: `${ui.outlineWidth} solid ${ui.selectionMatch.outline}`,
520
- borderRadius: generalMatching.borderRadius,
521
- },
522
- '.cm-snippetField': {
523
- backgroundColor: ui.selectionMatch.background,
524
- outline: `1px dashed ${ui.selectionMatch.outline}`,
525
- borderRadius: generalMatching.borderRadius,
526
- },
527
- '.cm-snippetFieldPosition': { borderLeft: `1px dotted ${ui.cursor}` },
528
- '.cm-foldPlaceholder': {
529
- backgroundColor: ui.foldPlaceholder.background,
530
- color: ui.foldPlaceholder.foreground,
531
- border: `${ui.outlineWidth} ${ui.foldPlaceholder.borderStyle} ${ui.foldPlaceholder.border}`,
532
- borderRadius: generalPlaceholder.borderRadius,
533
- padding: generalPlaceholder.padding,
534
- margin: generalPlaceholder.margin,
535
- },
536
- // Transparent outline: invisible normally, repainted with the system color in forced-colors mode (drops box-shadow).
537
- '&.cm-focused': { outline: '2px solid transparent', boxShadow: ui.focusRing },
538
- '& .cm-scroller::-webkit-scrollbar': { width: generalScroller.width, height: generalScroller.height },
539
- '& .cm-scroller::-webkit-scrollbar-track': { background: ui.scrollbar.track, border: ui.scrollbar.trackBorder },
540
- '& .cm-scroller::-webkit-scrollbar-thumb': {
541
- backgroundColor: ui.scrollbar.thumb,
542
- borderRadius: generalScroller.borderRadius,
543
- border: ui.scrollbar.thumbBorder,
544
- },
545
- '& .cm-scroller::-webkit-scrollbar-thumb:hover': {
546
- backgroundColor: ui.scrollbar.thumbHover,
547
- boxShadow: ui.scrollbar.thumbHoverShadow,
548
- },
549
- '.cm-ghostText': { opacity: ui.ghostTextOpacity, color: ui.ghostText },
550
- '.cm-placeholder': { color: ui.ghostText },
551
- '.cm-specialChar': { color: ui.specialChar },
552
- '.cm-trailingSpace': { backgroundColor: ui.diff.deletedBackground },
553
- '.cm-highlightSpace': {
554
- backgroundImage: `radial-gradient(circle at 50% 55%, ${ui.gutter.foreground} 20%, transparent 0)`,
555
- },
556
- '.cm-crosshair': { cursor: 'crosshair' },
557
- };
558
- }
559
- /** Drops `null` declarations and selectors left without declarations. */
560
- function emittedRules(spec) {
561
- const result = {};
562
- for (const [selector, declarations] of Object.entries(spec)) {
563
- const emitted = Object.entries(declarations).filter((entry) => entry[1] !== null);
564
- if (emitted.length > 0)
565
- result[selector] = Object.fromEntries(emitted);
566
- }
567
- return result;
568
- }
569
- /** Style of a role, falling back through `ROLE_PARENTS` for omitted fine roles. */
570
- function resolveRole(syntax, role) {
571
- let current = role;
572
- while (current) {
573
- const style = syntax[current];
574
- if (style)
575
- return style;
576
- current = ROLE_PARENTS[current];
577
- }
578
- return {};
579
- }
580
- /** Highlight rules of a theme: one rule per entry of the canonical table. */
581
- function highlightRules(definition) {
582
- return SYNTAX_TAGS.map(([role, tagList]) => (Object.assign({ tag: [...tagList] }, resolveRole(definition.syntax, role))));
583
- }
584
- /** Builds the editor theme, the syntax highlighting and the merge view styles of a theme definition. */
585
- function defineTheme(definition) {
586
- const theme = view.EditorView.theme(emittedRules(uiTemplate(definition.ui)), { dark: definition.dark });
587
- const highlightStyle = language.HighlightStyle.define(highlightRules(definition));
588
- return {
589
- extension: [theme, language.syntaxHighlighting(highlightStyle)],
590
- theme,
591
- highlightStyle,
592
- mergeStyles: Object.assign({}, definition.ui.merge),
593
- };
594
- }
595
-
596
55
  /**
597
56
  * Enhanced Solarized Dark theme color definitions
598
57
  * ---------------------------------------------
@@ -626,7 +85,8 @@ activeBracketBg = '#586e7540'; // Active bracket background with opacity
626
85
  // Diff/merge specific colors
627
86
  const addedBackground = '#2aa19820', // Solarized cyan with transparency for insertions
628
87
  removedBackground = '#dc322f20'; // Solarized red with transparency for deletions
629
- const theme = defineTheme({
88
+ const theme = codemirrorThemeCore.defineTheme({
89
+ name: 'Solarized Dark',
630
90
  dark: true,
631
91
  ui: {
632
92
  background: base00,
package/dist/index.js CHANGED
@@ -1,55 +1,6 @@
1
- import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
2
- import { EditorView } from '@codemirror/view';
3
- import { tags } from '@lezer/highlight';
1
+ import { defineTheme } from '@fsegurai/codemirror-theme-core';
4
2
 
5
3
  // Helper module for styling options
6
- const generalContent = {
7
- fontSize: '14px',
8
- fontFamily: 'JetBrains Mono, Consolas, monospace',
9
- lineHeight: '1.6',
10
- };
11
- const generalDiff = {
12
- insertedTextDecoration: 'none',
13
- deletedTextDecoration: 'line-through',
14
- insertedLinePadding: '1px 3px',
15
- borderRadius: '3px'};
16
- const generalGutter = {
17
- border: 'none',
18
- paddingRight: '8px',
19
- fontSize: '0.9em',
20
- lineHeight: '1.78', // Adjusted to compensate for 0.9em fontSize (1.6 / 0.9 ≈ 1.78)
21
- };
22
- const generalPanel = {
23
- borderRadius: '4px',
24
- padding: '2px 10px',
25
- };
26
- const generalLine = {
27
- borderRadius: '2px',
28
- };
29
- const generalMatching = {
30
- borderRadius: '2px',
31
- };
32
- const generalPlaceholder = {
33
- borderRadius: '4px',
34
- padding: '0 5px',
35
- margin: '0 2px',
36
- };
37
- const generalScroller = {
38
- width: '12px',
39
- height: '12px',
40
- borderRadius: '6px',
41
- };
42
- const generalSearchField = {
43
- borderRadius: '4px',
44
- padding: '2px 6px',
45
- };
46
- const generalTooltip = {
47
- borderRadius: '4px',
48
- borderRadiusSelected: '3px',
49
- lineHeight: '1.3',
50
- padding: '4px 8px',
51
- paddingRight: '8px',
52
- };
53
4
  /**
54
5
  * Function to apply merge revert styles for a theme
55
6
  * @param styles Styles for the merge revert buttons
@@ -99,498 +50,6 @@ function applyMergeRevertStyles(styles) {
99
50
  document.head.appendChild(styleEl);
100
51
  }
101
52
 
102
- // Shared theme core: every theme package describes a palette (`ThemeDefinition`) and this module turns it into the
103
- // CodeMirror extension. Generated into each package by `bun run generate:helpers`; edit only the copy in
104
- // `packages/.helper/utils/`.
105
- /** Parent of every fine role: an omitted fine role resolves to its parent. */
106
- const ROLE_PARENTS = {
107
- controlKeyword: 'keyword',
108
- moduleKeyword: 'keyword',
109
- definitionKeyword: 'keyword',
110
- operatorKeyword: 'operator',
111
- modifier: 'keyword',
112
- arithmeticOperator: 'operator',
113
- logicOperator: 'operator',
114
- compareOperator: 'operator',
115
- bitwiseOperator: 'operator',
116
- updateOperator: 'operator',
117
- derefOperator: 'operator',
118
- definitionOperator: 'operator',
119
- typeOperator: 'operator',
120
- controlOperator: 'operator',
121
- separator: 'punctuation',
122
- bracket: 'punctuation',
123
- paren: 'bracket',
124
- brace: 'bracket',
125
- squareBracket: 'bracket',
126
- angleBracket: 'bracket',
127
- character: 'name',
128
- macroName: 'name',
129
- variable: 'name',
130
- localVariable: 'variable',
131
- variableDefinition: 'variable',
132
- nameDefinition: 'variableDefinition',
133
- functionDefinition: 'function',
134
- self: 'variable',
135
- label: 'name',
136
- propertyDefinition: 'property',
137
- method: 'property',
138
- methodDefinition: 'method',
139
- specialProperty: 'property',
140
- typeDefinition: 'type',
141
- className: 'type',
142
- namespace: 'type',
143
- standardTag: 'tag',
144
- annotation: 'meta',
145
- documentMeta: 'meta',
146
- processingInstruction: 'meta',
147
- attributeValue: 'string',
148
- literal: 'string',
149
- docString: 'string',
150
- regexp: 'string',
151
- specialString: 'regexp',
152
- escape: 'string',
153
- unit: 'number',
154
- atom: 'constant',
155
- bool: 'atom',
156
- null: 'constant',
157
- constantName: 'constant',
158
- standardName: 'constant',
159
- color: 'standardName',
160
- specialVariable: 'constant',
161
- docComment: 'comment',
162
- headingLevel: 'heading',
163
- heading1: 'headingLevel',
164
- heading2: 'headingLevel',
165
- heading3: 'headingLevel',
166
- heading4: 'headingLevel',
167
- heading5: 'headingLevel',
168
- heading6: 'headingLevel',
169
- list: 'name',
170
- quote: 'string',
171
- monospace: 'string',
172
- contentSeparator: 'punctuation',
173
- };
174
- /**
175
- * Canonical tag → role table shared by every theme: every Lezer base tag and the modifier combinations that the
176
- * official grammars emit. Each tag appears once, so no rule is shadowed by a later one.
177
- */
178
- const SYNTAX_TAGS = [
179
- ['keyword', [tags.keyword]],
180
- ['controlKeyword', [tags.controlKeyword]],
181
- ['moduleKeyword', [tags.moduleKeyword]],
182
- ['definitionKeyword', [tags.definitionKeyword]],
183
- ['operatorKeyword', [tags.operatorKeyword]],
184
- ['modifier', [tags.modifier]],
185
- ['operator', [tags.operator]],
186
- ['arithmeticOperator', [tags.arithmeticOperator]],
187
- ['logicOperator', [tags.logicOperator]],
188
- ['compareOperator', [tags.compareOperator]],
189
- ['bitwiseOperator', [tags.bitwiseOperator]],
190
- ['updateOperator', [tags.updateOperator]],
191
- ['derefOperator', [tags.derefOperator]],
192
- ['definitionOperator', [tags.definitionOperator]],
193
- ['typeOperator', [tags.typeOperator]],
194
- ['controlOperator', [tags.controlOperator]],
195
- ['punctuation', [tags.punctuation, /*@__PURE__*/tags.function(tags.punctuation)]],
196
- ['separator', [tags.separator]],
197
- ['bracket', [tags.bracket]],
198
- ['paren', [tags.paren]],
199
- ['brace', [tags.brace, /*@__PURE__*/tags.special(tags.brace)]],
200
- ['squareBracket', [tags.squareBracket]],
201
- ['angleBracket', [tags.angleBracket]],
202
- ['name', [tags.name, /*@__PURE__*/tags.special(tags.name)]],
203
- ['character', [tags.character]],
204
- ['macroName', [tags.macroName]],
205
- ['variable', [tags.variableName, /*@__PURE__*/tags.standard(tags.variableName)]],
206
- ['localVariable', [/*@__PURE__*/tags.local(tags.variableName)]],
207
- ['variableDefinition', [/*@__PURE__*/tags.definition(tags.variableName)]],
208
- ['nameDefinition', [/*@__PURE__*/tags.definition(tags.name)]],
209
- ['function', [/*@__PURE__*/tags.function(tags.variableName)]],
210
- ['functionDefinition', [/*@__PURE__*/tags.definition(/*@__PURE__*/tags.function(tags.variableName))]],
211
- ['self', [tags.self]],
212
- ['label', [tags.labelName]],
213
- ['property', [tags.propertyName]],
214
- ['propertyDefinition', [/*@__PURE__*/tags.definition(tags.propertyName)]],
215
- ['method', [/*@__PURE__*/tags.function(tags.propertyName)]],
216
- ['methodDefinition', [/*@__PURE__*/tags.definition(/*@__PURE__*/tags.function(tags.propertyName))]],
217
- ['specialProperty', [/*@__PURE__*/tags.special(tags.propertyName), /*@__PURE__*/tags.definition(/*@__PURE__*/tags.special(tags.propertyName))]],
218
- ['type', [tags.typeName, /*@__PURE__*/tags.standard(tags.typeName)]],
219
- ['typeDefinition', [/*@__PURE__*/tags.definition(tags.typeName)]],
220
- ['className', [tags.className, /*@__PURE__*/tags.definition(tags.className), /*@__PURE__*/tags.constant(tags.className)]],
221
- ['namespace', [tags.namespace]],
222
- ['tag', [tags.tagName]],
223
- ['standardTag', [/*@__PURE__*/tags.standard(tags.tagName)]],
224
- ['attribute', [tags.attributeName, /*@__PURE__*/tags.special(tags.attributeName)]],
225
- ['attributeValue', [tags.attributeValue]],
226
- ['literal', [tags.literal]],
227
- ['string', [tags.string]],
228
- ['docString', [tags.docString]],
229
- ['regexp', [tags.regexp]],
230
- ['specialString', [/*@__PURE__*/tags.special(tags.string), /*@__PURE__*/tags.special(tags.docString)]],
231
- ['escape', [tags.escape]],
232
- ['number', [tags.number, tags.integer, tags.float]],
233
- ['unit', [tags.unit]],
234
- ['atom', [tags.atom]],
235
- ['bool', [tags.bool]],
236
- ['null', [tags.null]],
237
- ['constantName', [/*@__PURE__*/tags.constant(tags.name)]],
238
- ['standardName', [/*@__PURE__*/tags.standard(tags.name)]],
239
- ['color', [tags.color]],
240
- ['specialVariable', [/*@__PURE__*/tags.special(tags.variableName)]],
241
- ['comment', [tags.comment, tags.lineComment, tags.blockComment]],
242
- ['docComment', [tags.docComment]],
243
- ['meta', [tags.meta]],
244
- ['documentMeta', [tags.documentMeta]],
245
- ['processingInstruction', [tags.processingInstruction]],
246
- ['annotation', [tags.annotation]],
247
- ['content', [tags.content, /*@__PURE__*/tags.special(tags.content)]],
248
- ['heading', [tags.heading]],
249
- ['heading1', [tags.heading1]],
250
- ['heading2', [tags.heading2]],
251
- ['heading3', [tags.heading3]],
252
- ['heading4', [tags.heading4]],
253
- ['heading5', [tags.heading5]],
254
- ['heading6', [tags.heading6]],
255
- ['list', [tags.list]],
256
- ['quote', [tags.quote]],
257
- ['monospace', [tags.monospace]],
258
- ['contentSeparator', [tags.contentSeparator]],
259
- ['link', [tags.link]],
260
- ['url', [tags.url]],
261
- ['emphasis', [tags.emphasis]],
262
- ['strong', [tags.strong]],
263
- ['strikethrough', [tags.strikethrough]],
264
- ['invalid', [tags.invalid]],
265
- ['inserted', [tags.inserted]],
266
- ['deleted', [tags.deleted]],
267
- ['changed', [tags.changed]],
268
- ];
269
- /** Inline SVG image (same encoding as `@codemirror/lint`), used to draw lint markers in the theme colors. */
270
- function svg(content, attrs = 'viewBox="0 0 40 40"') {
271
- return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
272
- }
273
- /** Wavy underline of a lint range. */
274
- function lintUnderline(color) {
275
- return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
276
- }
277
- /**
278
- * Canonical UI template: the same selectors for every theme, only palette values differ. Rules of equal specificity
279
- * keep the order of the original theme files (later rules win).
280
- */
281
- function uiTemplate(ui) {
282
- return {
283
- '&': {
284
- color: ui.foreground,
285
- backgroundColor: ui.background,
286
- border: ui.border,
287
- fontSize: generalContent.fontSize,
288
- fontFamily: generalContent.fontFamily,
289
- },
290
- '.cm-content': { caretColor: ui.cursor, lineHeight: generalContent.lineHeight },
291
- '.cm-cursor, .cm-dropCursor': {
292
- borderLeftColor: ui.cursor,
293
- borderLeftWidth: ui.cursorWidth,
294
- boxShadow: ui.cursorShadow,
295
- },
296
- '.cm-cursor-secondary': { borderLeftColor: ui.cursor, opacity: '0.6' },
297
- '.cm-fat-cursor': {
298
- backgroundColor: ui.fatCursor.background,
299
- color: ui.background,
300
- border: ui.fatCursor.border,
301
- boxShadow: ui.cursorShadow,
302
- },
303
- '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': { backgroundColor: ui.selection, color: ui.selectionForeground, outline: ui.selectionOutline },
304
- '&:not(.cm-focused) .cm-selectionBackground': { backgroundColor: ui.selectionInactive },
305
- '.cm-selectionLayer': { zIndex: 100 },
306
- '.cm-searchMatch': {
307
- backgroundColor: ui.searchMatch.background,
308
- outline: `${ui.outlineWidth} solid ${ui.searchMatch.outline}`,
309
- color: ui.searchMatch.foreground,
310
- borderRadius: generalSearchField.borderRadius,
311
- boxShadow: ui.searchMatch.shadow,
312
- },
313
- '.cm-searchMatch span': { color: ui.searchMatch.foreground },
314
- '.cm-searchMatch.cm-searchMatch-selected': {
315
- backgroundColor: ui.searchMatch.selectedBackground,
316
- color: ui.searchMatch.selectedForeground,
317
- padding: generalSearchField.padding,
318
- outline: ui.searchMatch.selectedOutline,
319
- boxShadow: ui.searchMatch.selectedShadow,
320
- },
321
- '.cm-searchMatch.cm-searchMatch-selected span': { color: ui.searchMatch.selectedForeground },
322
- '.cm-search.cm-panel.cm-textfield': {
323
- color: ui.panel.foreground,
324
- borderRadius: generalSearchField.borderRadius,
325
- padding: generalSearchField.padding,
326
- },
327
- '.cm-textfield': {
328
- backgroundColor: ui.panel.inputBackground,
329
- color: ui.panel.foreground,
330
- border: ui.panel.inputBorder,
331
- borderRadius: generalSearchField.borderRadius,
332
- padding: generalSearchField.padding,
333
- },
334
- '.cm-panels': {
335
- backgroundColor: ui.panel.background,
336
- color: ui.panel.foreground,
337
- border: ui.panel.outline,
338
- borderRadius: generalPanel.borderRadius,
339
- boxShadow: ui.panel.shadow,
340
- },
341
- '.cm-panels.cm-panels-top': { borderBottom: `${ui.panel.borderWidth} solid ${ui.panel.border}` },
342
- '.cm-panels.cm-panels-bottom': { borderTop: `${ui.panel.borderWidth} solid ${ui.panel.border}` },
343
- '.cm-panel.cm-gotoLine': { color: ui.panel.foreground, padding: generalPanel.padding },
344
- '.cm-panel button, .cm-button': {
345
- backgroundColor: ui.panel.buttonBackground,
346
- backgroundImage: 'none',
347
- color: ui.panel.buttonForeground,
348
- border: ui.panel.buttonBorder,
349
- borderRadius: generalPanel.borderRadius,
350
- padding: generalPanel.padding,
351
- },
352
- '.cm-panel button:hover, .cm-button:hover': {
353
- backgroundColor: ui.panel.buttonHoverBackground,
354
- color: ui.panel.buttonHoverForeground,
355
- border: ui.panel.buttonHoverBorder,
356
- boxShadow: ui.panel.buttonHoverShadow,
357
- },
358
- '.cm-activeLine': {
359
- backgroundColor: ui.activeLine,
360
- borderLeft: ui.activeLineBorder.left,
361
- borderRight: ui.activeLineBorder.right,
362
- borderRadius: generalLine.borderRadius,
363
- zIndex: 1,
364
- },
365
- '.cm-gutters': {
366
- backgroundColor: ui.gutter.background,
367
- color: ui.gutter.foreground,
368
- border: generalGutter.border,
369
- borderRight: `${ui.outlineWidth} solid ${ui.gutter.border}`,
370
- paddingRight: generalGutter.paddingRight,
371
- },
372
- '.cm-activeLineGutter': {
373
- backgroundColor: ui.gutter.activeBackground,
374
- color: ui.gutter.activeForeground,
375
- fontWeight: ui.gutter.activeFontWeight,
376
- border: ui.gutter.activeBorder,
377
- },
378
- '.cm-lineNumbers': { fontSize: generalGutter.fontSize, lineHeight: generalGutter.lineHeight },
379
- '.cm-foldGutter': { fontSize: generalGutter.fontSize, lineHeight: generalGutter.lineHeight },
380
- '.cm-foldGutter .cm-gutterElement': { color: ui.gutter.foreground, cursor: 'pointer' },
381
- '.cm-foldGutter .cm-gutterElement:hover': { color: ui.gutter.foldHover },
382
- '.cm-gutter-lint': { color: ui.gutter.foreground },
383
- '.cm-lint-marker': { width: '1em', height: '1em' },
384
- '.cm-lint-marker-error': {
385
- content: svg(`<circle cx="20" cy="20" r="15" fill="${ui.diagnostic.error}" stroke="${ui.background}" stroke-width="4"/>`),
386
- },
387
- '.cm-lint-marker-warning': {
388
- content: svg(`<path fill="${ui.diagnostic.warning}" stroke="${ui.background}" stroke-width="4" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
389
- },
390
- '.cm-lint-marker-info': {
391
- content: svg(`<path fill="${ui.diagnostic.info}" stroke="${ui.background}" stroke-width="4" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`),
392
- },
393
- '.cm-changeGutter': { backgroundColor: ui.gutter.background },
394
- '.cm-merge-b .cm-changedLineGutter, .cm-inlineChangedLineGutter': { background: ui.diff.insertedForeground },
395
- '.cm-merge-a .cm-changedLineGutter, .cm-deletedLineGutter': { background: ui.diff.deletedForeground },
396
- '.cm-insertedLine': {
397
- textDecoration: generalDiff.insertedTextDecoration,
398
- backgroundColor: ui.diff.insertedBackground,
399
- color: ui.diff.insertedForeground,
400
- padding: generalDiff.insertedLinePadding,
401
- borderRadius: generalDiff.borderRadius,
402
- },
403
- 'ins.cm-insertedLine, ins.cm-insertedLine:not(:has(.cm-changedText))': {
404
- textDecoration: generalDiff.insertedTextDecoration,
405
- backgroundColor: `${ui.diff.insertedBackground} !important`,
406
- color: ui.diff.insertedForeground,
407
- padding: generalDiff.insertedLinePadding,
408
- borderRadius: generalDiff.borderRadius,
409
- border: ui.diff.insertedBorder,
410
- },
411
- 'ins.cm-insertedLine .cm-changedText': { background: 'transparent !important' },
412
- '.cm-deletedLine': {
413
- textDecoration: generalDiff.deletedTextDecoration,
414
- backgroundColor: ui.diff.deletedBackground,
415
- color: ui.diff.deletedForeground,
416
- padding: generalDiff.insertedLinePadding,
417
- borderRadius: generalDiff.borderRadius,
418
- },
419
- // Merge view deletions only: `del` decorations, inline deletion widgets and the lines of deleted chunks. `:where()`
420
- // keeps the specificity of the former bare `del` selector without styling other `del` elements.
421
- 'del.cm-deletedLine, del.cm-deletedText, :where(.cm-deletedChunk) del, :where(.cm-deletedChunk) del:not(:has(.cm-deletedText))': {
422
- textDecoration: generalDiff.deletedTextDecoration,
423
- backgroundColor: `${ui.diff.deletedBackground} !important`,
424
- color: ui.diff.deletedForeground,
425
- padding: generalDiff.insertedLinePadding,
426
- borderRadius: generalDiff.borderRadius,
427
- border: ui.diff.deletedBorder,
428
- },
429
- ':where(.cm-deletedChunk) del .cm-deletedText, :where(.cm-deletedChunk) del .cm-changedText, del:where(.cm-deletedLine) .cm-deletedText, del:where(.cm-deletedLine) .cm-changedText': { background: 'transparent !important' },
430
- '.cm-merge-b .cm-changedLine, .cm-inlineChangedLine': { backgroundColor: ui.diff.insertedBackground },
431
- '.cm-merge-a .cm-changedLine, .cm-deletedChunk': { backgroundColor: ui.diff.deletedBackground },
432
- '.cm-collapsedLines': {
433
- background: ui.foldPlaceholder.background,
434
- color: ui.foldPlaceholder.foreground,
435
- },
436
- '.cm-mergeSpacer': { background: ui.merge.backgroundColor },
437
- '.cm-tooltip': {
438
- backgroundColor: ui.tooltip.background,
439
- color: ui.tooltip.foreground,
440
- border: `${ui.outlineWidth} solid ${ui.tooltip.border}`,
441
- borderRadius: generalTooltip.borderRadius,
442
- padding: generalTooltip.padding,
443
- boxShadow: ui.tooltip.shadow,
444
- },
445
- '.cm-tooltip-autocomplete > ul': { backgroundColor: ui.tooltip.listBackground, border: ui.tooltip.listBorder },
446
- '.cm-tooltip-autocomplete > ul > li': { padding: generalTooltip.padding, lineHeight: generalTooltip.lineHeight },
447
- '.cm-tooltip-autocomplete > ul > li:hover': { backgroundColor: ui.tooltip.hoverBackground },
448
- '.cm-tooltip-autocomplete > ul > li[aria-selected]': {
449
- backgroundColor: ui.tooltip.selectedBackground,
450
- color: ui.tooltip.selectedForeground,
451
- border: ui.tooltip.selectedBorder,
452
- borderRadius: generalTooltip.borderRadiusSelected,
453
- },
454
- '.cm-tooltip-autocomplete > ul > li > span.cm-completionIcon': {
455
- color: ui.tooltip.icon,
456
- paddingRight: generalTooltip.paddingRight,
457
- },
458
- '.cm-tooltip-autocomplete > ul > li > span.cm-completionDetail': { color: ui.tooltip.detail, fontStyle: 'italic' },
459
- '.cm-completionMatchedText': {
460
- color: 'inherit',
461
- fontWeight: 'bold',
462
- textDecoration: 'underline',
463
- textDecorationColor: ui.matchingBracket.outline,
464
- },
465
- '.cm-completionInfo': {
466
- backgroundColor: ui.tooltip.background,
467
- color: ui.tooltip.foreground,
468
- border: `${ui.outlineWidth} solid ${ui.tooltip.border}`,
469
- padding: generalTooltip.padding,
470
- },
471
- '.cm-tooltip .cm-tooltip-arrow:before': { borderTopColor: 'transparent', borderBottomColor: 'transparent' },
472
- '.cm-tooltip .cm-tooltip-arrow:after': {
473
- borderTopColor: ui.tooltip.background,
474
- borderBottomColor: ui.tooltip.background,
475
- },
476
- '.cm-tooltip-lint': { color: ui.tooltip.foreground, padding: '0' },
477
- '.cm-tooltip-section:not(:first-child)': { borderTop: `1px solid ${ui.tooltip.border}` },
478
- '.cm-diagnostic-error': {
479
- borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.error}`,
480
- backgroundColor: ui.diagnostic.errorBackground,
481
- },
482
- '.cm-diagnostic-warning': {
483
- borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.warning}`,
484
- backgroundColor: ui.diagnostic.warningBackground,
485
- },
486
- '.cm-diagnostic-info': {
487
- borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.info}`,
488
- backgroundColor: ui.diagnostic.infoBackground,
489
- },
490
- '.cm-diagnostic-hint': { borderLeft: `${ui.diagnostic.borderWidth} solid ${ui.diagnostic.hint}` },
491
- '.cm-diagnosticAction': {
492
- backgroundColor: ui.panel.buttonBackground,
493
- color: ui.panel.buttonForeground,
494
- border: ui.panel.buttonBorder,
495
- borderRadius: generalPanel.borderRadius,
496
- },
497
- '.cm-lintRange-error': { backgroundImage: lintUnderline(ui.diagnostic.error) },
498
- '.cm-lintRange-warning': { backgroundImage: lintUnderline(ui.diagnostic.warning) },
499
- '.cm-lintRange-info': { backgroundImage: lintUnderline(ui.diagnostic.info) },
500
- '.cm-lintRange-hint': { backgroundImage: lintUnderline(ui.diagnostic.hint) },
501
- '.cm-lintPoint-error': { borderBottom: `${ui.diagnostic.underlineWidth} wavy ${ui.diagnostic.error}` },
502
- '.cm-lintPoint-warning': { borderBottom: `${ui.diagnostic.underlineWidth} wavy ${ui.diagnostic.warning}` },
503
- '.cm-lintPoint-info': { borderBottom: `${ui.diagnostic.underlineWidth} wavy ${ui.diagnostic.info}` },
504
- '.cm-matchingBracket': {
505
- backgroundColor: ui.matchingBracket.background,
506
- outline: `${ui.outlineWidth} solid ${ui.matchingBracket.outline}`,
507
- borderRadius: generalMatching.borderRadius,
508
- boxShadow: ui.matchingBracket.shadow,
509
- },
510
- '.cm-nonmatchingBracket': {
511
- backgroundColor: ui.nonMatchingBracket.background,
512
- outline: `${ui.outlineWidth} solid ${ui.nonMatchingBracket.outline}`,
513
- borderRadius: generalMatching.borderRadius,
514
- },
515
- '.cm-selectionMatch': {
516
- backgroundColor: ui.selectionMatch.background,
517
- outline: `${ui.outlineWidth} solid ${ui.selectionMatch.outline}`,
518
- borderRadius: generalMatching.borderRadius,
519
- },
520
- '.cm-snippetField': {
521
- backgroundColor: ui.selectionMatch.background,
522
- outline: `1px dashed ${ui.selectionMatch.outline}`,
523
- borderRadius: generalMatching.borderRadius,
524
- },
525
- '.cm-snippetFieldPosition': { borderLeft: `1px dotted ${ui.cursor}` },
526
- '.cm-foldPlaceholder': {
527
- backgroundColor: ui.foldPlaceholder.background,
528
- color: ui.foldPlaceholder.foreground,
529
- border: `${ui.outlineWidth} ${ui.foldPlaceholder.borderStyle} ${ui.foldPlaceholder.border}`,
530
- borderRadius: generalPlaceholder.borderRadius,
531
- padding: generalPlaceholder.padding,
532
- margin: generalPlaceholder.margin,
533
- },
534
- // Transparent outline: invisible normally, repainted with the system color in forced-colors mode (drops box-shadow).
535
- '&.cm-focused': { outline: '2px solid transparent', boxShadow: ui.focusRing },
536
- '& .cm-scroller::-webkit-scrollbar': { width: generalScroller.width, height: generalScroller.height },
537
- '& .cm-scroller::-webkit-scrollbar-track': { background: ui.scrollbar.track, border: ui.scrollbar.trackBorder },
538
- '& .cm-scroller::-webkit-scrollbar-thumb': {
539
- backgroundColor: ui.scrollbar.thumb,
540
- borderRadius: generalScroller.borderRadius,
541
- border: ui.scrollbar.thumbBorder,
542
- },
543
- '& .cm-scroller::-webkit-scrollbar-thumb:hover': {
544
- backgroundColor: ui.scrollbar.thumbHover,
545
- boxShadow: ui.scrollbar.thumbHoverShadow,
546
- },
547
- '.cm-ghostText': { opacity: ui.ghostTextOpacity, color: ui.ghostText },
548
- '.cm-placeholder': { color: ui.ghostText },
549
- '.cm-specialChar': { color: ui.specialChar },
550
- '.cm-trailingSpace': { backgroundColor: ui.diff.deletedBackground },
551
- '.cm-highlightSpace': {
552
- backgroundImage: `radial-gradient(circle at 50% 55%, ${ui.gutter.foreground} 20%, transparent 0)`,
553
- },
554
- '.cm-crosshair': { cursor: 'crosshair' },
555
- };
556
- }
557
- /** Drops `null` declarations and selectors left without declarations. */
558
- function emittedRules(spec) {
559
- const result = {};
560
- for (const [selector, declarations] of Object.entries(spec)) {
561
- const emitted = Object.entries(declarations).filter((entry) => entry[1] !== null);
562
- if (emitted.length > 0)
563
- result[selector] = Object.fromEntries(emitted);
564
- }
565
- return result;
566
- }
567
- /** Style of a role, falling back through `ROLE_PARENTS` for omitted fine roles. */
568
- function resolveRole(syntax, role) {
569
- let current = role;
570
- while (current) {
571
- const style = syntax[current];
572
- if (style)
573
- return style;
574
- current = ROLE_PARENTS[current];
575
- }
576
- return {};
577
- }
578
- /** Highlight rules of a theme: one rule per entry of the canonical table. */
579
- function highlightRules(definition) {
580
- return SYNTAX_TAGS.map(([role, tagList]) => (Object.assign({ tag: [...tagList] }, resolveRole(definition.syntax, role))));
581
- }
582
- /** Builds the editor theme, the syntax highlighting and the merge view styles of a theme definition. */
583
- function defineTheme(definition) {
584
- const theme = EditorView.theme(emittedRules(uiTemplate(definition.ui)), { dark: definition.dark });
585
- const highlightStyle = HighlightStyle.define(highlightRules(definition));
586
- return {
587
- extension: [theme, syntaxHighlighting(highlightStyle)],
588
- theme,
589
- highlightStyle,
590
- mergeStyles: Object.assign({}, definition.ui.merge),
591
- };
592
- }
593
-
594
53
  /**
595
54
  * Enhanced Solarized Dark theme color definitions
596
55
  * ---------------------------------------------
@@ -625,6 +84,7 @@ activeBracketBg = '#586e7540'; // Active bracket background with opacity
625
84
  const addedBackground = '#2aa19820', // Solarized cyan with transparency for insertions
626
85
  removedBackground = '#dc322f20'; // Solarized red with transparency for deletions
627
86
  const theme = /*@__PURE__*/defineTheme({
87
+ name: 'Solarized Dark',
628
88
  dark: true,
629
89
  ui: {
630
90
  background: base00,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fsegurai/codemirror-theme-solarized-dark",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "Solarized Dark theme for the CodeMirror editor",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -49,6 +49,9 @@
49
49
  "@codemirror/state": "^6.0.0",
50
50
  "@codemirror/view": "^6.0.0"
51
51
  },
52
+ "dependencies": {
53
+ "@fsegurai/codemirror-theme-core": "6.0.0"
54
+ },
52
55
  "devDependencies": {
53
56
  "@codemirror/buildhelper": "^1.0.2"
54
57
  },