mirror of
https://github.com/xevidos/codiad.git
synced 2024-11-14 07:41:14 +01:00
Merge branch 'development' into 'master'
v.2.9.3.3 Added context menu to editor See merge request xevidos/codiad!24
This commit is contained in:
commit
fd3a791ce9
5 changed files with 200 additions and 52 deletions
|
@ -16,54 +16,87 @@ checkSession();
|
|||
|
||||
?>
|
||||
<form onsubmit="return false;">
|
||||
<?php
|
||||
<?php
|
||||
switch( $_GET['action'] ) {
|
||||
|
||||
switch($_GET['action']){
|
||||
case 'search':
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Find & Replace
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
case 'search':
|
||||
|
||||
$type = $_GET['type'];
|
||||
?>
|
||||
<label><?php i18n("Find:"); ?></label>
|
||||
<input name="find" autofocus="autofocus" autocomplete="off">
|
||||
<textarea style="display: none;" name="find" autofocus="autofocus" autocomplete="off"></textarea>
|
||||
<?php
|
||||
if( $type == 'replace' ) {
|
||||
|
||||
<?php if($type=='replace'){ ?>
|
||||
|
||||
<label><?php i18n("Replace:"); ?></label>
|
||||
?>
|
||||
<label><?php i18n("Replace:");?></label>
|
||||
<input name="replace">
|
||||
<textarea style="display: none;" name="replace"></textarea>
|
||||
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<button class="btn-left" onclick="codiad.editor.search('find');return false;"><?php i18n("Find"); ?></button>
|
||||
<button class="btn-mid" onclick="codiad.editor.toggleMultiLine( this );return false;"><?php i18n("Multi Line"); ?></button>
|
||||
<?php if($type=='replace'){ ?>
|
||||
<?php
|
||||
if( $type == 'replace' ) {
|
||||
|
||||
?>
|
||||
<button class="btn-mid" onclick="codiad.editor.search('replace');return false;"><?php i18n("Replace"); ?></button>
|
||||
<button class="btn-mid" onclick="codiad.editor.search('replaceAll');return false;"><?php i18n("Replace ALL"); ?></button>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
case 'sort':
|
||||
|
||||
?>
|
||||
<label><?php i18n("Sort:"); ?></label>
|
||||
<textarea style="" name="sort" autofocus="autofocus" autocomplete="off"></textarea>
|
||||
<div>
|
||||
<label><input name="case_sensitive" style="display:inline-block;vertical-align: bottom;" type="checkbox"> Case Sensitive</label>
|
||||
</div>
|
||||
<div style="display: none;" >
|
||||
<label>Delimiter:</label>
|
||||
<input type="text" name="delimiter" value="">
|
||||
</div>
|
||||
<button class="btn-left" onclick="codiad.editor.sort( '<?php echo addcslashes( PHP_EOL, PHP_EOL );?>' );return false;"><?php i18n("Sort"); ?></button>
|
||||
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
<script>
|
||||
$(function(){
|
||||
<?php if($_GET['action']=='search'){ ?>
|
||||
$( function() {
|
||||
<?php
|
||||
if( $_GET['action'] == 'search' ) {
|
||||
?>
|
||||
if( codiad.editor.multi_line ) {
|
||||
|
||||
$('textarea[name="find"]').val(codiad.active.getSelectedText());
|
||||
$('textarea[name="find"]').val( codiad.active.getSelectedText() );
|
||||
$('textarea[name="find"]').focus();
|
||||
} else {
|
||||
|
||||
$('input[name="find"]').val(codiad.active.getSelectedText());
|
||||
$('input[name="find"]').val( codiad.active.getSelectedText() );
|
||||
$('input[name="find"]').focus();
|
||||
}
|
||||
<?php } ?>
|
||||
});
|
||||
<?php
|
||||
} elseif( $_GET['action'] == 'sort' ) {
|
||||
|
||||
?>
|
||||
$('textarea[name="sort"]').val( codiad.active.getSelectedText() );
|
||||
$('textarea[name="sort"]').focus();
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -289,6 +289,20 @@
|
|||
.trigger('v-resize');
|
||||
});
|
||||
|
||||
$("#root-editor-wrapper").live("contextmenu", function( e ) {
|
||||
|
||||
// Context Menu
|
||||
e.preventDefault();
|
||||
_this = codiad.editor
|
||||
|
||||
if( _this.getActive() ) {
|
||||
|
||||
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 +1512,59 @@
|
|||
$('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.active.getSelectedText() != "" ) {
|
||||
|
||||
codiad.modal.load( 400, 'components/editor/dialog.php?action=sort' );
|
||||
codiad.modal.hideOverlay();
|
||||
} else {
|
||||
|
||||
codiad.message.error('No text selected');
|
||||
}
|
||||
},
|
||||
|
||||
sort: function( eol ) {
|
||||
|
||||
let text = $('#modal textarea[name="sort"]').val();
|
||||
let array = text.split( eol );
|
||||
array = array.sort( codiad.editor.sort_a );
|
||||
let sorted = array.join( eol );
|
||||
|
||||
console.log( text, eol, array, sorted );
|
||||
codiad.modal.unload();
|
||||
codiad.editor.getActive().insert( sorted );
|
||||
codiad.editor.getActive().focus();
|
||||
},
|
||||
|
||||
sort_a: function( a, b ) {
|
||||
|
||||
let pos = 0;
|
||||
let case_sensitive = $( '#modal input[name="case_sensitive"]' ).prop( 'checked' )
|
||||
|
||||
if( ! case_sensitive ) {
|
||||
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
}
|
||||
|
||||
if( a < b ) {
|
||||
|
||||
pos = -1;
|
||||
} else if( a > b ) {
|
||||
|
||||
pos = 1;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class Update {
|
|||
// CONSTANTS
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
CONST VERSION = "v.2.9.3.2";
|
||||
CONST VERSION = "v.2.9.3.3";
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// PROPERTIES
|
||||
|
|
Loading…
Reference in a new issue