|
| 1 | +import fairyflossTheme from '../components/Shared/fairyfloss.tmTheme.js'; |
| 2 | + |
| 3 | +const { parseTmTheme } = require('monaco-themes'); |
| 4 | + |
| 5 | +/** |
| 6 | + * Sets up the Monaco Editor theme |
| 7 | + */ |
| 8 | +export function setTheme(editor: any, monaco: any) { |
| 9 | + const themeData = parseTmTheme(fairyflossTheme); |
| 10 | + monaco.editor.defineTheme('my-theme', themeData); |
| 11 | + monaco.editor.setTheme('my-theme'); |
| 12 | +} |
| 13 | + |
| 14 | +/** |
| 15 | + * Gets improved Monaco Editor options with better text selection support |
| 16 | + */ |
| 17 | +export function getMonacoEditorOptions( |
| 18 | + overrides: Record<string, any> = {}, |
| 19 | +): Record<string, any> { |
| 20 | + return { |
| 21 | + // Text selection improvements |
| 22 | + selectOnLineNumbers: true, |
| 23 | + selectionHighlight: true, |
| 24 | + occurrencesHighlight: true, |
| 25 | + // Smart selection - enables expanding selection intelligently |
| 26 | + // Use Alt+Shift+Right to expand selection, Alt+Shift+Left to shrink |
| 27 | + selectLeadingAndTrailingWhitespace: true, |
| 28 | + // Multi-cursor and column selection |
| 29 | + multiCursorModifier: 'ctrlCmd', |
| 30 | + columnSelection: true, |
| 31 | + // Rendering improvements |
| 32 | + renderLineHighlight: 'all', |
| 33 | + renderWhitespace: 'selection', |
| 34 | + // Editing improvements |
| 35 | + dragAndDrop: true, |
| 36 | + formatOnPaste: true, |
| 37 | + formatOnType: false, |
| 38 | + // Autocomplete |
| 39 | + quickSuggestions: true, |
| 40 | + wordBasedSuggestions: false, |
| 41 | + // UI improvements |
| 42 | + minimap: { enabled: false }, |
| 43 | + fontSize: 14, |
| 44 | + lineNumbers: 'on', |
| 45 | + scrollBeyondLastLine: false, |
| 46 | + automaticLayout: true, |
| 47 | + // Word wrap and cursor |
| 48 | + wordWrap: 'off', |
| 49 | + cursorStyle: 'line', |
| 50 | + // Better selection visual feedback |
| 51 | + renderIndentGuides: true, |
| 52 | + highlightActiveIndentGuide: true, |
| 53 | + // Accept suggestion on commit characters |
| 54 | + acceptSuggestionOnCommitCharacter: true, |
| 55 | + acceptSuggestionOnEnter: 'on', |
| 56 | + // Tab behavior |
| 57 | + tabSize: 2, |
| 58 | + insertSpaces: true, |
| 59 | + // Accessibility |
| 60 | + accessibilitySupport: 'auto', |
| 61 | + // ... allow overrides |
| 62 | + ...overrides, |
| 63 | + }; |
| 64 | +} |
0 commit comments