@@ -93,14 +93,18 @@ type EditorMenu = {
9393 title : string ;
9494 tooltip ?: string ;
9595 action ?: ( script : Script , e : editor . ICodeEditor ) => void ;
96- items ?: {
97- id : string ;
98- title : string ;
99- tooltip ?: string ;
100- hotKey ?: number ;
101- hotKeyString ?: string ;
102- action : ( script : Script , e : editor . ICodeEditor ) => void ;
103- } [ ] ;
96+ items ?: (
97+ | {
98+ id : string ;
99+ title : string ;
100+ tooltip ?: string ;
101+ hotKey ?: number ;
102+ hotKeyString ?: string ;
103+ action : ( script : Script , e : editor . ICodeEditor ) => void ;
104+ divider ?: never ;
105+ }
106+ | { divider : true }
107+ ) [ ] ;
104108} ;
105109
106110const emptyScript = async ( template : string , hotKeys : any , target ?: string ) => {
@@ -498,6 +502,77 @@ function ScriptEditor() {
498502 } ,
499503 ] ,
500504 } ,
505+ {
506+ title : t ( "edit" ) ,
507+ items : [
508+ {
509+ id : "undo" ,
510+ title : t ( "undo" ) ,
511+ hotKeyString : "Ctrl+Z" ,
512+ action ( _script , e ) {
513+ e . trigger ( "menu" , "undo" , null ) ;
514+ } ,
515+ } ,
516+ {
517+ id : "redo" ,
518+ title : t ( "redo" ) ,
519+ hotKeyString : "Ctrl+Shift+Z" ,
520+ action ( _script , e ) {
521+ e . trigger ( "menu" , "redo" , null ) ;
522+ } ,
523+ } ,
524+ { divider : true } ,
525+ {
526+ id : "cut" ,
527+ title : t ( "cut" ) ,
528+ hotKeyString : "Ctrl+X" ,
529+ action ( _script , e ) {
530+ e . trigger ( "menu" , "editor.action.clipboardCutAction" , null ) ;
531+ } ,
532+ } ,
533+ {
534+ id : "copy" ,
535+ title : t ( "copy" ) ,
536+ hotKeyString : "Ctrl+C" ,
537+ action ( _script , e ) {
538+ e . trigger ( "menu" , "editor.action.clipboardCopyAction" , null ) ;
539+ } ,
540+ } ,
541+ {
542+ id : "paste" ,
543+ title : t ( "paste" ) ,
544+ hotKeyString : "Ctrl+V" ,
545+ action ( _script , e ) {
546+ e . trigger ( "menu" , "editor.action.clipboardPasteAction" , null ) ;
547+ } ,
548+ } ,
549+ { divider : true } ,
550+ {
551+ id : "find" ,
552+ title : t ( "find" ) ,
553+ hotKeyString : "Ctrl+F" ,
554+ action ( _script , e ) {
555+ e . getAction ( "actions.find" ) ?. run ( ) ;
556+ } ,
557+ } ,
558+ {
559+ id : "replace" ,
560+ title : t ( "replace" ) ,
561+ hotKeyString : "Ctrl+H" ,
562+ action ( _script , e ) {
563+ e . getAction ( "editor.action.startFindReplaceAction" ) ?. run ( ) ;
564+ } ,
565+ } ,
566+ {
567+ id : "selectAll" ,
568+ title : t ( "select_all" ) ,
569+ hotKeyString : "Ctrl+A" ,
570+ action ( _script , e ) {
571+ e . trigger ( "menu" , "editor.action.selectAll" , null ) ;
572+ } ,
573+ } ,
574+ ] ,
575+ } ,
501576 {
502577 title : t ( "run" ) ,
503578 items : [
@@ -579,7 +654,7 @@ function ScriptEditor() {
579654 hotKeys . current = [ ] ;
580655 menu . forEach ( ( item ) => {
581656 item . items ?. forEach ( ( menuItem ) => {
582- if ( menuItem . hotKey ) {
657+ if ( ! menuItem . divider && menuItem . hotKey ) {
583658 hotKeys . current . push ( {
584659 id : menuItem . id ,
585660 title : menuItem . title ,
@@ -841,16 +916,25 @@ function ScriptEditor() {
841916 }
842917 return (
843918 < Dropdown
844- key = { `d_${ index . toString ( ) } ` }
919+ key = { `d_${ index } ` }
845920 droplist = {
846921 < Menu
847922 style = { {
848923 padding : "0" ,
849924 margin : "0" ,
850925 borderRadius : "0" ,
926+ maxHeight : "none" ,
927+ overflow : "visible" ,
851928 } }
852929 >
853930 { item . items . map ( ( menuItem , i ) => {
931+ if ( menuItem . divider ) {
932+ return (
933+ < div key = { `divider_${ i } ` } style = { { padding : "4px 0" , background : "var(--color-secondary)" } } >
934+ < div style = { { height : "1px" , backgroundColor : "var(--color-neutral-4)" } } />
935+ </ div >
936+ ) ;
937+ }
854938 const btn = (
855939 < Button
856940 style = { {
@@ -896,15 +980,15 @@ function ScriptEditor() {
896980 ) ;
897981 return (
898982 < Menu . Item
899- key = { `m_${ i . toString ( ) } ` }
983+ key = { `m_${ i } ` }
900984 style = { {
901985 height : "unset" ,
902986 padding : "0" ,
903987 lineHeight : "unset" ,
904988 } }
905989 >
906990 { menuItem . tooltip ? (
907- < Tooltip key = { `m${ i . toString ( ) } ` } position = "right" content = { menuItem . tooltip } >
991+ < Tooltip key = { `m${ i } ` } position = "right" content = { menuItem . tooltip } >
908992 { btn }
909993 </ Tooltip >
910994 ) : (
0 commit comments