diff --git a/components/editor/init.js b/components/editor/init.js index c12c822..462872d 100755 --- a/components/editor/init.js +++ b/components/editor/init.js @@ -288,8 +288,17 @@ .height($(this).height()) .trigger('v-resize'); }); - - + + $("#root-editor-wrapper").live("contextmenu", function( e ) { + + // Context Menu + e.preventDefault(); + let path = codiad.active.getPath(); + $(e.target).attr('data-path', path); + codiad.filemanager.contextMenuShow( e, path, 'editor', 'editor'); + $(this).addClass('context-menu-active'); + }); + $(window).resize(function(){ $('#editor-region') .trigger('h-resize-init') @@ -1498,6 +1507,31 @@ $('textarea[name="replace"]').hide(); $('input[name="replace"]').val( $('textarea[name="replace"]').val() ); } + }, + + paste: function() { + //this works only in chrome + console.log( "this works only in chrome." ); + navigator.clipboard.readText().then(text => {codiad.editor.getActive().insert( text )}); + }, + + openSort: function() { + + if ( this.getActive() ) { + + codiad.modal.load(400, + 'components/editor/dialog.php?action=search&type=' + + type); + codiad.modal.hideOverlay(); + } else { + + codiad.message.error('No Open Files'); + } + }, + + sort: function() { + + } }; diff --git a/components/filemanager/context_menu.json b/components/filemanager/context_menu.json index 2036dc1..5bcfc93 100755 --- a/components/filemanager/context_menu.json +++ b/components/filemanager/context_menu.json @@ -130,5 +130,47 @@ "icon": "icon-arrows-ccw", "applies-to" : "directory-only", "onclick": "codiad.filemanager.rescan($('#context-menu').attr('data-path'));" + }, + { + "title": "Copy", + "icon": "icon-doc", + "applies-to" : "editor-only", + "onclick": "document.execCommand( 'copy' );" + }, + { + "title": "Paste", + "icon": "icon-docs", + "applies-to" : "editor-only", + "onclick": "codiad.editor.paste();" + }, + { + "title": "Break", + "icon": null, + "applies-to" : "editor-only", + "onclick": null + }, + { + "title": "Find", + "icon": "icon-docs", + "applies-to" : "editor-only", + "onclick": "codiad.editor.openSearch('find');" + }, + { + "title": "Replace", + "icon": "icon-docs", + "applies-to" : "editor-only", + "onclick": "codiad.editor.openSearch('replace');" + }, + { + "title": "Break", + "icon": null, + "applies-to" : "editor-only", + "onclick": null + }, + { + "title": "Sort", + "icon": "icon-docs", + "applies-to" : "editor-only", + "onclick": "codiad.editor.openSort();" } ] diff --git a/components/filemanager/init.js b/components/filemanager/init.js index bccba17..62935c6 100755 --- a/components/filemanager/init.js +++ b/components/filemanager/init.js @@ -173,9 +173,15 @@ $('#context-menu .non-root, #context-menu .file-only') .hide(); break; + case 'editor': + $('#context-menu a, #context-menu hr').hide(); + $('#context-menu .editor-only').show(); + break; } if(codiad.project.isAbsPath($('#file-manager a[data-type="root"]').attr('data-path'))) { $('#context-menu .no-external').hide(); + } else if( type == "editor" ) { + $('#context-menu .no-external').hide(); } else { $('#context-menu .no-external').show(); }