Started adding context menu to editor and active files.

This commit is contained in:
xevidos 2019-01-18 00:32:10 -05:00
parent eb9d51e9be
commit 81c3d8d4f9
3 changed files with 84 additions and 2 deletions

View file

@ -289,6 +289,15 @@
.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')
@ -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() {
}
};

View file

@ -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();"
}
]

View file

@ -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();
}