From de436f0b5e35590f8b5f2e95cd9a2f0ce7a59ab1 Mon Sep 17 00:00:00 2001 From: Chandler Abraham Date: Sun, 1 Jun 2025 09:07:49 -0700 Subject: [PATCH] run prettier linter --- packages/codemirror/dragdrop.mjs | 28 ++++++++----------- website/src/repl/Repl.css | 2 +- .../src/repl/components/DownloadButton.jsx | 28 ++++++------------- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/packages/codemirror/dragdrop.mjs b/packages/codemirror/dragdrop.mjs index d2c57d578..9db58b90f 100644 --- a/packages/codemirror/dragdrop.mjs +++ b/packages/codemirror/dragdrop.mjs @@ -14,11 +14,9 @@ async function readFileContent(file) { // Check for common text file formats, to avoid // accidentally loading images or other files function isCodeFile(file) { - const codeExtensions = [ - '.js', '.strudel', '.str' - ]; + const codeExtensions = ['.js', '.strudel', '.str']; const fileName = file.name.toLowerCase(); - return codeExtensions.some(ext => fileName.endsWith(ext)) || file.type.startsWith('text/'); + return codeExtensions.some((ext) => fileName.endsWith(ext)) || file.type.startsWith('text/'); } // Create drag and drop extension @@ -30,7 +28,7 @@ export const dragDropPlugin = ViewPlugin.fromClass( this.handleDragOver = this.handleDragOver.bind(this); this.handleDragEnter = this.handleDragEnter.bind(this); this.handleDragLeave = this.handleDragLeave.bind(this); - + // Add event listeners view.dom.addEventListener('drop', this.handleDrop); view.dom.addEventListener('dragover', this.handleDragOver); @@ -65,10 +63,10 @@ export const dragDropPlugin = ViewPlugin.fromClass( this.view.dom.classList.remove('cm-drag-over'); const files = Array.from(e.dataTransfer.files); - + // Filter for code files only const codeFiles = files.filter(isCodeFile); - + if (codeFiles.length === 0) { logger('No code files were dropped. Please drop text-based files.', 'warning'); return; @@ -80,29 +78,27 @@ export const dragDropPlugin = ViewPlugin.fromClass( codeFiles.map(async (file) => { const content = await readFileContent(file); return `// File: ${file.name}\n${content}`; - }) + }), ); // Combine content const newContent = fileContents.join('\n\n'); - + // Replace entire editor contents this.view.dispatch({ changes: { from: 0, to: this.view.state.doc.length, insert: newContent }, - selection: { anchor: newContent.length } + selection: { anchor: newContent.length }, }); // Focus the editor this.view.focus(); - + // Show success message - const fileNames = codeFiles.map(f => f.name).join(', '); + const fileNames = codeFiles.map((f) => f.name).join(', '); logger(`Successfully loaded ${codeFiles.length} file(s): ${fileNames}`, 'highlight'); - } catch (error) { console.error('Error reading dropped files:', error); logger(`Error loading files: ${error.message}`, 'error'); - } } @@ -112,5 +108,5 @@ export const dragDropPlugin = ViewPlugin.fromClass( this.view.dom.removeEventListener('dragenter', this.handleDragEnter); this.view.dom.removeEventListener('dragleave', this.handleDragLeave); } - } -); \ No newline at end of file + }, +); diff --git a/website/src/repl/Repl.css b/website/src/repl/Repl.css index 2fda68308..7e5d89066 100644 --- a/website/src/repl/Repl.css +++ b/website/src/repl/Repl.css @@ -72,7 +72,7 @@ /* Drag and drop styles */ #code .cm-editor.cm-drag-over { - outline: 2px dashed #4CAF50; + outline: 2px dashed #4caf50; outline-offset: -2px; background-color: rgba(76, 175, 80, 0.05) !important; } diff --git a/website/src/repl/components/DownloadButton.jsx b/website/src/repl/components/DownloadButton.jsx index a582a7bb3..554414a8b 100644 --- a/website/src/repl/components/DownloadButton.jsx +++ b/website/src/repl/components/DownloadButton.jsx @@ -4,13 +4,13 @@ export default function DownloadButton({ context }) { const handleDownload = useCallback(() => { // Get the current code from the editor const code = context.editorRef?.current?.code || ''; - + // Create a blob with the code const blob = new Blob([code], { type: 'text/javascript' }); - + // Create a temporary URL for the blob const url = window.URL.createObjectURL(blob); - + // Create a temporary anchor element and trigger download const a = document.createElement('a'); a.href = url; @@ -18,7 +18,7 @@ export default function DownloadButton({ context }) { document.body.appendChild(a); a.click(); document.body.removeChild(a); - + // Clean up the URL window.URL.revokeObjectURL(url); }, []); @@ -30,22 +30,10 @@ export default function DownloadButton({ context }) { title="Download pattern as .js file" aria-label="Download pattern" > - - - + + + ); -} \ No newline at end of file +}