@@ -3,11 +3,10 @@ import { EditorView, keymap, lineNumbers, gutter } from "@codemirror/view";
33import { basicSetup } from "codemirror" ;
44import { javascript } from "@codemirror/lang-javascript" ;
55import { defaultKeymap , indentWithTab } from "@codemirror/commands" ;
6- import { parseUserScriptMetadata } from './metadataParser.js' ;
6+ import { parseUserScriptMetadata } from '../utils /metadataParser.js' ;
77import { autocompletion , closeBrackets } from "@codemirror/autocomplete" ;
88import { bracketMatching , foldGutter } from "@codemirror/language" ;
99import { linter , lintGutter } from "@codemirror/lint" ;
10- import { js_beautify } from 'js-beautify' ;
1110import { showMinimap } from '@replit/codemirror-minimap' ;
1211import { oneDark } from '@codemirror/theme-one-dark' ;
1312
@@ -183,7 +182,6 @@ export class CodeEditorManager {
183182 indentWithTab ,
184183 { key : "Ctrl-s" , run : ( ) => { this . onSaveCallback ?. ( ) ; return true ; } } ,
185184 { key : "Cmd-s" , run : ( ) => { this . onSaveCallback ?. ( ) ; return true ; } } ,
186- { key : "Alt-f" , run : ( ) => { this . formatCode ( true ) ; return true ; } } ,
187185 { key : "F11" , run : ( view ) => {
188186 if ( view . dom . requestFullscreen ) {
189187 view . dom . requestFullscreen ( ) ;
@@ -386,40 +384,6 @@ export class CodeEditorManager {
386384 return this . state . lintingEnabled ;
387385 }
388386
389- async formatCode ( showMessage = true , onFormatComplete ) {
390- try {
391- if ( ! this . codeEditor ) {
392- throw new Error ( "Code editor not initialized" ) ;
393- }
394-
395- const unformattedCode = this . getValue ( ) ;
396- const formattedCode = js_beautify ( unformattedCode , {
397- indent_size : 2 ,
398- space_in_empty_paren : true ,
399- } ) ;
400-
401- this . setValue ( formattedCode ) ;
402-
403- if ( showMessage && this . onStatusCallback ) {
404- this . onStatusCallback ( "Code formatted" , "success" ) ;
405- setTimeout (
406- ( ) => this . onStatusCallback ( null ) ,
407- this . config . STATUS_TIMEOUT
408- ) ;
409- }
410-
411- if ( typeof onFormatComplete === 'function' ) {
412- await onFormatComplete ( ) ;
413- }
414- } catch ( error ) {
415- console . error ( "Error formatting code:" , error ) ;
416- if ( showMessage && this . onStatusCallback ) {
417- this . onStatusCallback ( "Could not format code" , "error" ) ;
418- }
419- return false ;
420- }
421- }
422-
423387 insertTemplateCode ( template ) {
424388 const wrappedCode = `(function() {
425389 'use strict';
@@ -428,7 +392,6 @@ export class CodeEditorManager {
428392
429393 })();` ;
430394 this . setValue ( wrappedCode ) ;
431- this . formatCode ( false ) ;
432395 }
433396
434397 insertDefaultTemplate ( ) {
@@ -441,7 +404,6 @@ export class CodeEditorManager {
441404 })();` ;
442405
443406 this . setValue ( defaultCode ) ;
444- this . formatCode ( false ) ;
445407 }
446408
447409 getValue ( ) {
0 commit comments