mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-22 05:42:17 +01:00
Started adding context menu to editor and active files.
This commit is contained in:
parent
eb9d51e9be
commit
81c3d8d4f9
3 changed files with 84 additions and 2 deletions
|
@ -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() {
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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();"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue