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