Skip to content

Commit 3bb8897

Browse files
committed
fix(files): dispose onContextMenu listener and handle clipboard rejection
1 parent e64163b commit 3bb8897

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/files/components/file-viewer

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,30 +174,30 @@ const MonacoEditor = dynamic(
174174
colors: {
175175
'editor.background': '#fefefe',
176176
'editor.foreground': '#1a1a1a',
177-
'editorLineNumber.foreground': '#cccccc',
177+
'editorLineNumber.foreground': '#bbbbbb',
178178
'editorLineNumber.activeForeground': '#707070',
179-
'editor.selectionBackground': '#33b4ff22',
180-
'editor.inactiveSelectionBackground': '#33b4ff12',
179+
'editor.selectionBackground': '#0078d430',
180+
'editor.inactiveSelectionBackground': '#0078d418',
181181
'editor.lineHighlightBackground': '#f7f7f7',
182182
'editor.lineHighlightBorder': '#00000000',
183183
'editorGutter.background': '#fefefe',
184184
'editorWidget.background': '#ffffff',
185185
'editorWidget.border': '#dedede',
186186
'editorWidget.foreground': '#1a1a1a',
187-
'editor.findMatchBackground': '#33b4ff40',
188-
'editor.findMatchHighlightBackground': '#33b4ff1a',
189-
'editor.findMatchBorder': '#33b4ff',
187+
'editor.findMatchBackground': '#0078d428',
188+
'editor.findMatchHighlightBackground': '#0078d414',
189+
'editor.findMatchBorder': '#0078d4',
190190
'scrollbar.shadow': '#00000000',
191191
'scrollbarSlider.background': '#dedede80',
192192
'scrollbarSlider.hoverBackground': '#cccccc',
193193
'scrollbarSlider.activeBackground': '#b0b0b0',
194-
'editorBracketMatch.background': '#33b4ff1a',
195-
'editorBracketMatch.border': '#33b4ff80',
194+
'editorBracketMatch.background': '#0078d418',
195+
'editorBracketMatch.border': '#0078d480',
196196
'editorIndentGuide.background1': '#f0f0f0',
197197
'editorIndentGuide.activeBackground1': '#d8d8d8',
198198
'editorCursor.foreground': '#1a1a1a',
199-
'editor.wordHighlightBackground': '#33b4ff14',
200-
'editor.wordHighlightBorder': '#33b4ff40',
199+
'editor.wordHighlightBackground': '#0078d414',
200+
'editor.wordHighlightBorder': '#0078d450',
201201
'editorSuggestWidget.background': '#ffffff',
202202
'editorSuggestWidget.border': '#dedede',
203203
'editorSuggestWidget.foreground': '#1a1a1a',
@@ -208,11 +208,11 @@ const MonacoEditor = dynamic(
208208
'editorHoverWidget.foreground': '#1a1a1a',
209209
'minimap.background': '#fefefe',
210210
'minimapSlider.background': '#dedede80',
211-
focusBorder: '#33b4ff80',
211+
focusBorder: '#0078d480',
212212
'input.background': '#ffffff',
213213
'input.border': '#dedede',
214214
'input.foreground': '#1a1a1a',
215-
'inputOption.activeBorder': '#33b4ff',
215+
'inputOption.activeBorder': '#0078d4',
216216
},
217217
})
218218

@@ -626,7 +626,7 @@ export const TextEditor = memo(function TextEditor({
626626
editor.focus()
627627
}
628628

629-
editor.onContextMenu((e) => {
629+
const contextMenuDisposable = editor.onContextMenu((e) => {
630630
e.event.preventDefault()
631631
const sel = editor.getSelection()
632632
setContextMenu({
@@ -635,6 +635,7 @@ export const TextEditor = memo(function TextEditor({
635635
hasSelection: sel !== null && !sel.isEmpty(),
636636
})
637637
})
638+
editor.onDidDispose(() => contextMenuDisposable.dispose())
638639
}
639640

640641
const handleEditorChange = useCallback(
@@ -783,7 +784,7 @@ export const TextEditor = memo(function TextEditor({
783784
closeContextMenu()
784785
}}
785786
onCopyAll={() => {
786-
navigator.clipboard.writeText(monacoEditorRef.current?.getValue() ?? '')
787+
navigator.clipboard.writeText(monacoEditorRef.current?.getValue() ?? '').catch(() => {})
787788
closeContextMenu()
788789
}}
789790
onPaste={() => {

0 commit comments

Comments
 (0)