@fsegurai/codemirror-theme-high-contrast-light 6.0.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.js ADDED
@@ -0,0 +1,495 @@
1
+ import { EditorView } from '@codemirror/view';
2
+ import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
3
+ import { tags } from '@lezer/highlight';
4
+
5
+ // 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
+ borderRadious: '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
+ /**
54
+ * Function to apply merge revert styles for a theme
55
+ * @param styles Styles for the merge revert buttons
56
+ * @param styles.backgroundColor Background color of the revert area
57
+ * @param styles.borderColor Border color of the revert area
58
+ * @param styles.buttonColor Color of the revert buttons
59
+ * @param styles.buttonHoverColor Hover color of the revert buttons
60
+ */
61
+ function applyMergeRevertStyles(styles) {
62
+ // Create a stylesheet
63
+ const styleEl = document.createElement('style');
64
+ styleEl.id = 'cm-merge-revert-styles';
65
+ // Define CSS with the theme-specific values
66
+ styleEl.textContent = `
67
+ .cm-merge-revert {
68
+ display: flex;
69
+ flex-direction: column;
70
+ align-items: center;
71
+ justify-content: flex-start;
72
+ padding: 4px;
73
+ background-color: ${styles.backgroundColor};
74
+ border-left: 1px solid ${styles.borderColor};
75
+ border-right: 1px solid ${styles.borderColor};
76
+ width: 32px;
77
+ }
78
+
79
+ .cm-merge-revert button {
80
+ width: 100%;
81
+ height: auto;
82
+ background-color: transparent;
83
+ border: none;
84
+ color: ${styles.buttonColor};
85
+ cursor: pointer;
86
+ margin: 0 auto;
87
+ font-size: 20px;
88
+ }
89
+
90
+ .cm-merge-revert button:hover {
91
+ background-color: ${styles.buttonHoverColor};
92
+ }
93
+ `;
94
+ // Remove any existing merge styles
95
+ const existingStyle = document.getElementById('cm-merge-revert-styles');
96
+ if (existingStyle)
97
+ existingStyle.remove();
98
+ // Add the new styles
99
+ document.head.appendChild(styleEl);
100
+ }
101
+
102
+ /**
103
+ * High Contrast Light theme color definitions
104
+ * -------------------------------------------
105
+ * Maximum contrast theme for accessibility (light variant)
106
+ */
107
+ // Base colors - Pure white and black for maximum contrast
108
+ const base00 = '#ffffff', // Background - pure white
109
+ base01 = '#e0e0e0', // Selection background
110
+ base02 = '#707070', // Comments - medium grey
111
+ base03 = '#505050', // Dark grey
112
+ base04 = '#000000', // Foreground - pure black
113
+ // High contrast accent colors for a light background
114
+ darkBlue = '#0000ff', darkCyan = '#008080', darkGreen = '#008000', darkRed = '#c80000', darkMagenta = '#800080', darkOrange = '#d04800', darkPurple = '#6600cc', darkBrown = '#7c3400';
115
+ // UI specific colors
116
+ const invalid = darkRed, lightBackground = base00, background = base00, tooltipBackground = '#f0f0f0', selection = '#0078d4', selectionMatch = '#0078d480', cursor = darkBlue, activeBracketBg = '#e0e0e0', activeBracketBorder = darkCyan, diagnosticWarning = darkOrange, linkColor = darkBlue, visitedLinkColor = darkPurple;
117
+ // Diff/merge specific colors
118
+ const addedBackground = '#00800040', removedBackground = '#c8000040', addedText = darkGreen, removedText = darkRed;
119
+ /**
120
+ * Enhanced editor theme styles for High Contrast Light
121
+ */
122
+ const highContrastLightTheme = /*@__PURE__*/EditorView.theme({
123
+ // Base editor styles
124
+ '&': {
125
+ color: base04,
126
+ backgroundColor: background,
127
+ fontSize: generalContent.fontSize,
128
+ fontFamily: generalContent.fontFamily,
129
+ border: `2px solid ${base04}`,
130
+ },
131
+ // Content and cursor
132
+ '.cm-content': {
133
+ caretColor: cursor,
134
+ lineHeight: generalContent.lineHeight,
135
+ },
136
+ '.cm-cursor, .cm-dropCursor': {
137
+ borderLeftColor: cursor,
138
+ borderLeftWidth: '3px',
139
+ },
140
+ '.cm-fat-cursor': {
141
+ backgroundColor: cursor,
142
+ color: background,
143
+ border: `2px solid ${base04}`,
144
+ },
145
+ // Selection
146
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': {
147
+ backgroundColor: '#4d90fe',
148
+ outline: `2px solid ${darkBlue}`,
149
+ },
150
+ // Make sure selection appears above active line
151
+ '.cm-selectionLayer': {
152
+ zIndex: 100,
153
+ },
154
+ // Search functionality
155
+ '.cm-searchMatch': {
156
+ backgroundColor: '#ffff00',
157
+ outline: `2px solid ${darkOrange}`,
158
+ color: base04,
159
+ borderRadius: generalSearchField.borderRadius,
160
+ '& span': {
161
+ color: base04,
162
+ },
163
+ },
164
+ '.cm-searchMatch.cm-searchMatch-selected': {
165
+ backgroundColor: darkOrange,
166
+ color: base00,
167
+ padding: generalSearchField.padding,
168
+ outline: `2px solid ${base04}`,
169
+ '& span': {
170
+ color: base00,
171
+ },
172
+ },
173
+ '.cm-search.cm-panel.cm-textfield': {
174
+ color: base04,
175
+ backgroundColor: base00,
176
+ border: `2px solid ${base04}`,
177
+ borderRadius: generalSearchField.borderRadius,
178
+ padding: generalSearchField.padding,
179
+ },
180
+ // Panels
181
+ '.cm-panels': {
182
+ backgroundColor: lightBackground,
183
+ color: base04,
184
+ borderRadius: '4px',
185
+ border: `2px solid ${base04}`,
186
+ },
187
+ '.cm-panels.cm-panels-top': {
188
+ borderBottom: `2px solid ${base04}`,
189
+ },
190
+ '.cm-panels.cm-panels-bottom': {
191
+ borderTop: `2px solid ${base04}`,
192
+ },
193
+ '.cm-panel button': {
194
+ backgroundColor: tooltipBackground,
195
+ color: darkBlue,
196
+ border: `2px solid ${base04}`,
197
+ borderRadius: generalPanel.borderRadius,
198
+ padding: generalPanel.padding,
199
+ },
200
+ '.cm-panel button:hover': {
201
+ backgroundColor: base01,
202
+ border: `2px solid ${darkBlue}`,
203
+ },
204
+ // Line highlighting
205
+ '.cm-activeLine': {
206
+ backgroundColor: '#ffffccba',
207
+ borderRadius: generalLine.borderRadius,
208
+ borderLeft: `3px solid ${darkBlue}`,
209
+ borderRight: `1px solid ${base02}`,
210
+ zIndex: 1,
211
+ },
212
+ // Gutters
213
+ '.cm-gutters': {
214
+ backgroundColor: lightBackground,
215
+ color: base03,
216
+ border: generalGutter.border,
217
+ borderRight: `2px solid ${base04}`,
218
+ paddingRight: generalGutter.paddingRight,
219
+ },
220
+ '.cm-activeLineGutter': {
221
+ backgroundColor: base01,
222
+ color: darkBlue,
223
+ fontWeight: 'bold',
224
+ border: `1px solid ${base02}`,
225
+ },
226
+ '.cm-lineNumbers': {
227
+ fontSize: generalGutter.fontSize,
228
+ lineHeight: generalGutter.lineHeight,
229
+ },
230
+ '.cm-foldGutter': {
231
+ fontSize: generalGutter.fontSize,
232
+ lineHeight: generalGutter.lineHeight,
233
+ },
234
+ '.cm-foldGutter .cm-gutterElement': {
235
+ color: base03,
236
+ cursor: 'pointer',
237
+ },
238
+ '.cm-foldGutter .cm-gutterElement:hover': {
239
+ color: darkCyan,
240
+ },
241
+ // Diff/Merge View Styles
242
+ '.cm-insertedLine': {
243
+ textDecoration: generalDiff.insertedTextDecoration,
244
+ backgroundColor: addedBackground,
245
+ color: addedText,
246
+ padding: generalDiff.insertedLinePadding,
247
+ borderRadius: generalDiff.borderRadious,
248
+ border: `2px solid ${addedText}`,
249
+ },
250
+ 'ins.cm-insertedLine, ins.cm-insertedLine:not(:has(.cm-changedText))': {
251
+ textDecoration: generalDiff.insertedTextDecoration,
252
+ backgroundColor: `${addedBackground} !important`,
253
+ color: addedText,
254
+ padding: generalDiff.insertedLinePadding,
255
+ borderRadius: generalDiff.borderRadious,
256
+ border: `2px solid ${addedText}`,
257
+ },
258
+ 'ins.cm-insertedLine .cm-changedText': {
259
+ background: 'transparent !important',
260
+ },
261
+ '.cm-deletedLine': {
262
+ textDecoration: generalDiff.deletedTextDecoration,
263
+ backgroundColor: removedBackground,
264
+ color: removedText,
265
+ padding: generalDiff.insertedLinePadding,
266
+ borderRadius: generalDiff.borderRadious,
267
+ border: `2px solid ${removedText}`,
268
+ },
269
+ 'del.cm-deletedLine, del, del:not(:has(.cm-deletedText))': {
270
+ textDecoration: generalDiff.deletedTextDecoration,
271
+ backgroundColor: `${removedBackground} !important`,
272
+ color: removedText,
273
+ padding: generalDiff.insertedLinePadding,
274
+ borderRadius: generalDiff.borderRadious,
275
+ border: `2px solid ${removedText}`,
276
+ },
277
+ 'del .cm-deletedText, del .cm-changedText': {
278
+ background: 'transparent !important',
279
+ },
280
+ // Tooltips and autocomplete
281
+ '.cm-tooltip': {
282
+ backgroundColor: tooltipBackground,
283
+ border: `2px solid ${darkBlue}`,
284
+ borderRadius: generalTooltip.borderRadius,
285
+ padding: generalTooltip.padding,
286
+ color: base04,
287
+ },
288
+ '.cm-tooltip-autocomplete': {
289
+ '& > ul': {
290
+ backgroundColor: tooltipBackground,
291
+ border: `2px solid ${base04}`,
292
+ },
293
+ '& > ul > li': {
294
+ padding: generalTooltip.padding,
295
+ lineHeight: generalTooltip.lineHeight,
296
+ },
297
+ '& > ul > li[aria-selected]': {
298
+ backgroundColor: selection,
299
+ color: base00,
300
+ borderRadius: generalTooltip.borderRadiusSelected,
301
+ border: `2px solid ${darkBlue}`,
302
+ },
303
+ '& > ul > li > span.cm-completionIcon': {
304
+ color: darkCyan,
305
+ paddingRight: generalTooltip.paddingRight,
306
+ },
307
+ '& > ul > li > span.cm-completionDetail': {
308
+ color: darkOrange,
309
+ fontStyle: 'italic',
310
+ },
311
+ },
312
+ '.cm-tooltip .cm-tooltip-arrow:before': {
313
+ borderTopColor: 'transparent',
314
+ borderBottomColor: 'transparent',
315
+ },
316
+ '.cm-tooltip .cm-tooltip-arrow:after': {
317
+ borderTopColor: darkBlue,
318
+ borderBottomColor: darkBlue,
319
+ },
320
+ // Diagnostics styling
321
+ '.cm-diagnostic': {
322
+ '&-error': {
323
+ borderLeft: `4px solid ${darkRed}`,
324
+ backgroundColor: '#ff000020',
325
+ },
326
+ '&-warning': {
327
+ borderLeft: `4px solid ${diagnosticWarning}`,
328
+ backgroundColor: '#ff990020',
329
+ },
330
+ '&-info': {
331
+ borderLeft: `4px solid ${linkColor}`,
332
+ backgroundColor: '#0000ff20',
333
+ },
334
+ },
335
+ '.cm-lintPoint-error': {
336
+ borderBottom: `3px wavy ${darkRed}`,
337
+ },
338
+ '.cm-lintPoint-warning': {
339
+ borderBottom: `3px wavy ${diagnosticWarning}`,
340
+ },
341
+ // Matching brackets
342
+ '.cm-matchingBracket': {
343
+ backgroundColor: activeBracketBg,
344
+ outline: `2px solid ${activeBracketBorder}`,
345
+ borderRadius: generalMatching.borderRadius,
346
+ },
347
+ '.cm-nonmatchingBracket': {
348
+ backgroundColor: '#ff000030',
349
+ outline: `2px solid ${invalid}`,
350
+ borderRadius: generalMatching.borderRadius,
351
+ },
352
+ // Selection matches
353
+ '.cm-selectionMatch': {
354
+ backgroundColor: selectionMatch,
355
+ outline: `2px solid ${darkBlue}50`,
356
+ borderRadius: generalMatching.borderRadius,
357
+ },
358
+ // Fold placeholder
359
+ '.cm-foldPlaceholder': {
360
+ backgroundColor: tooltipBackground,
361
+ color: darkBlue,
362
+ border: `2px solid ${darkBlue}`,
363
+ borderRadius: generalPlaceholder.borderRadius,
364
+ padding: generalPlaceholder.padding,
365
+ margin: generalPlaceholder.margin,
366
+ },
367
+ // Focus outline
368
+ '&.cm-focused': {
369
+ outline: `3px solid ${darkBlue}`,
370
+ outlineOffset: '2px',
371
+ },
372
+ // Scrollbars
373
+ '& .cm-scroller::-webkit-scrollbar': {
374
+ width: generalScroller.width,
375
+ height: generalScroller.height,
376
+ },
377
+ '& .cm-scroller::-webkit-scrollbar-track': {
378
+ background: lightBackground,
379
+ border: `2px solid ${base04}`,
380
+ },
381
+ '& .cm-scroller::-webkit-scrollbar-thumb': {
382
+ backgroundColor: base03,
383
+ border: `2px solid ${base04}`,
384
+ borderRadius: generalScroller.borderRadius,
385
+ },
386
+ '& .cm-scroller::-webkit-scrollbar-thumb:hover': {
387
+ backgroundColor: darkBlue,
388
+ },
389
+ // Ghost text
390
+ '.cm-ghostText': {
391
+ opacity: '0.7',
392
+ color: base02,
393
+ },
394
+ }, { dark: false });
395
+ /**
396
+ * Enhanced syntax highlighting for High Contrast Light theme
397
+ */
398
+ const highContrastLightHighlightStyle = /*@__PURE__*/HighlightStyle.define([
399
+ // Keywords and control flow
400
+ { tag: tags.keyword, color: darkMagenta, fontWeight: 'bold' },
401
+ { tag: tags.controlKeyword, color: darkMagenta, fontWeight: 'bold' },
402
+ { tag: tags.moduleKeyword, color: darkMagenta, fontWeight: 'bold' },
403
+ // Names and variables
404
+ { tag: [tags.name, tags.deleted, tags.character, tags.macroName], color: base04 },
405
+ { tag: [tags.variableName], color: base04 },
406
+ { tag: [tags.propertyName], color: darkBlue, fontStyle: 'normal' },
407
+ // Classes and types
408
+ { tag: [tags.typeName], color: darkCyan },
409
+ { tag: [tags.className], color: darkCyan, fontStyle: 'italic' },
410
+ { tag: [tags.namespace], color: darkOrange, fontStyle: 'italic' },
411
+ // Operators and punctuation
412
+ { tag: [tags.operator, tags.operatorKeyword], color: darkCyan },
413
+ { tag: [tags.bracket], color: darkBrown },
414
+ { tag: [tags.brace], color: darkCyan },
415
+ { tag: [tags.punctuation], color: base04 },
416
+ // Functions and parameters
417
+ { tag: [/*@__PURE__*/tags.function(tags.variableName), tags.labelName], color: darkBlue },
418
+ { tag: [/*@__PURE__*/tags.definition(/*@__PURE__*/tags.function(tags.variableName))], color: darkBlue },
419
+ { tag: [/*@__PURE__*/tags.definition(tags.variableName)], color: darkOrange },
420
+ // Constants and literals
421
+ { tag: tags.number, color: darkOrange },
422
+ { tag: tags.changed, color: darkOrange },
423
+ { tag: tags.annotation, color: darkRed, fontStyle: 'italic' },
424
+ { tag: tags.modifier, color: darkPurple, fontStyle: 'italic' },
425
+ { tag: tags.self, color: darkRed },
426
+ { tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)], color: darkOrange },
427
+ { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)], color: darkOrange },
428
+ // Strings and regex
429
+ { tag: [tags.processingInstruction, tags.inserted], color: darkGreen },
430
+ { tag: [/*@__PURE__*/tags.special(tags.string), tags.regexp], color: darkMagenta },
431
+ { tag: tags.string, color: darkGreen },
432
+ // Punctuation and structure
433
+ { tag: /*@__PURE__*/tags.definition(tags.typeName), color: darkCyan, fontWeight: 'bold' },
434
+ { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator], color: darkBlue },
435
+ // Comments and documentation
436
+ { tag: tags.meta, color: base02 },
437
+ { tag: tags.comment, fontStyle: 'italic', color: base02 },
438
+ { tag: tags.docComment, fontStyle: 'italic', color: base02 },
439
+ // HTML/XML elements
440
+ { tag: [tags.tagName], color: darkMagenta },
441
+ { tag: [tags.attributeName], color: darkCyan },
442
+ // Markdown and text formatting
443
+ { tag: [tags.heading], fontWeight: 'bold', color: darkMagenta },
444
+ { tag: [tags.strong], fontWeight: 'bold', color: darkOrange },
445
+ { tag: [tags.emphasis], fontStyle: 'italic', color: darkMagenta },
446
+ // Links and URLs
447
+ {
448
+ tag: [tags.link],
449
+ color: visitedLinkColor,
450
+ fontWeight: '500',
451
+ textDecoration: 'underline',
452
+ textUnderlinePosition: 'under',
453
+ },
454
+ {
455
+ tag: [tags.url],
456
+ color: linkColor,
457
+ textDecoration: 'underline',
458
+ textUnderlineOffset: '2px',
459
+ },
460
+ // Special states
461
+ {
462
+ tag: [tags.invalid],
463
+ color: darkRed,
464
+ textDecoration: 'underline wavy',
465
+ borderBottom: `2px wavy ${darkRed}`,
466
+ },
467
+ { tag: [tags.strikethrough], color: darkRed, textDecoration: 'line-through' },
468
+ // Enhanced syntax highlighting
469
+ { tag: /*@__PURE__*/tags.constant(tags.name), color: darkOrange },
470
+ { tag: tags.deleted, color: darkRed },
471
+ { tag: tags.squareBracket, color: darkBrown },
472
+ { tag: tags.angleBracket, color: darkCyan },
473
+ // Additional specific styles
474
+ { tag: tags.monospace, color: darkBlue, fontStyle: 'italic' },
475
+ { tag: [tags.contentSeparator], color: darkPurple },
476
+ { tag: tags.quote, color: darkPurple },
477
+ ]);
478
+ /**
479
+ * Combined High Contrast Light theme extension
480
+ */
481
+ const highContrastLight = [
482
+ highContrastLightTheme,
483
+ /*@__PURE__*/syntaxHighlighting(highContrastLightHighlightStyle),
484
+ ];
485
+ /**
486
+ * High Contrast Light merge revert styles configuration
487
+ */
488
+ const highContrastLightMergeStyles = {
489
+ backgroundColor: lightBackground,
490
+ borderColor: darkBlue,
491
+ buttonColor: darkBlue,
492
+ buttonHoverColor: darkOrange,
493
+ };
494
+
495
+ export { applyMergeRevertStyles, highContrastLight, highContrastLightMergeStyles };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@fsegurai/codemirror-theme-high-contrast-light",
3
+ "description": "High Contrast Light theme for the CodeMirror editor",
4
+ "version": "6.0.0",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "exports": {
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs"
10
+ },
11
+ "types": "dist/index.d.ts",
12
+ "module": "dist/index.js",
13
+ "sideEffects": false,
14
+ "scripts": {
15
+ "test": "cm-runtests",
16
+ "prepare": "cm-buildhelper src/index.ts"
17
+ },
18
+ "keywords": [
19
+ "editor",
20
+ "diff",
21
+ "diff-editor",
22
+ "code",
23
+ "codemirror",
24
+ "theme",
25
+ "themes",
26
+ "syntax",
27
+ "highlight",
28
+ "high-contrast",
29
+ "accessibility",
30
+ "a11y"
31
+ ],
32
+ "author": {
33
+ "name": "Fabián Segura",
34
+ "url": "https://www.fsegurai.com/"
35
+ },
36
+ "license": "MIT",
37
+ "peerDependencies": {
38
+ "@lezer/highlight": "^1.0.0",
39
+ "@codemirror/language": "^6.0.0",
40
+ "@codemirror/state": "^6.0.0",
41
+ "@codemirror/view": "^6.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@codemirror/buildhelper": "^1.0.2"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/fsegurai/codemirror-themes.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/fsegurai/codemirror-themes/issues"
52
+ },
53
+ "homepage": "https://github.com/fsegurai/codemirror-themes#readme"
54
+ }