Re added openInBrowser as preview, Fixed non patch save content, Fixed display context menu on editor

This commit is contained in:
xevidos 2020-01-28 18:14:01 -05:00
parent 1a47ed2b98
commit 806dbec3b7
5 changed files with 35 additions and 6 deletions

View File

@ -537,14 +537,14 @@
} else {
console.log( "calling save while failed diff", path, newContent, alerts );
codiad.filemanager.save_file( path, newContent, alerts )
codiad.filemanager.save_file( path, {content: newContent}, alerts )
.then( handleSuccess );
}
}, this );
} else {
console.log( "calling save without mtime and untainted", path, newContent, alerts );
codiad.filemanager.save_file( path, newContent, alerts )
codiad.filemanager.save_file( path, {content: newContent}, alerts )
.then( handleSuccess );
}
},

View File

@ -297,7 +297,7 @@
let path = codiad.active.getPath();
$( e.target ).attr( 'data-path', path );
codiad.filemanager.contextMenuShow( e, path, 'editor', 'editor' );
codiad.filemanager.display_context_menu( e, path, 'editor', 'editor' );
$( this ).addClass( 'context-menu-active' );
}
});

View File

@ -606,7 +606,7 @@ class Filemanager extends Common {
// OPEN IN BROWSER (Return URL)
//////////////////////////////////////////////////////////////////
public function openinbrowser( $path ) {
public function preview( $path ) {
$protocol = ( ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ) || $_SERVER['SERVER_PORT'] == 443 ) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'];

View File

@ -229,9 +229,9 @@ switch( $action ) {
$response = $Filemanager->open( $path );
break;
case 'open_in_browser':
case 'preview':
$response = $Filemanager->openinbrowser( $path );
$response = $Filemanager->preview( $path );
break;
case 'rename':

View File

@ -1346,7 +1346,36 @@
preview: function( path ) {
let _this = this;
$.ajax({
type: 'GET',
url: _this.controller + '?action=preview&path=' + encodeURIComponent( path ),
success: function( data ) {
console.log( data );
let r = JSON.parse( data );
if( r.status === "success" ) {
_this.preview = window.open( r.data, '_newtab' );
let editor = codiad.editor.getActive();
if( _this.auto_reload && editor !== null ) {
editor.addEventListener( "change", _this.refresh_preview );
}
} else {
codiad.message.error( i18n( r.message ) );
}
},
error: function( data ) {
codiad.message.error( i18n( r.message ) );
},
});
},
rescan: function( path ) {