* adjst for monaco editor.
This commit is contained in:
@@ -38,7 +38,7 @@ class editor extends control
|
||||
{
|
||||
$moduleFiles = $this->editor->getModuleFiles($moduleDir);
|
||||
$this->view->module = $moduleDir;
|
||||
$this->view->tree = $this->editor->printTree($moduleFiles);
|
||||
$this->view->tree = $this->editor->printTree($moduleFiles);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ class editor extends control
|
||||
public function edit($filePath = '', $action = '', $isExtends = '')
|
||||
{
|
||||
$this->view->safeFilePath = $filePath;
|
||||
$fileContent = '';
|
||||
$fileContent = '';
|
||||
$extension = 'php';
|
||||
if($filePath)
|
||||
{
|
||||
$filePath = helper::safe64Decode($filePath);
|
||||
@@ -98,10 +99,14 @@ class editor extends control
|
||||
{
|
||||
$fileContent = "<?php\n";
|
||||
}
|
||||
|
||||
$fileName = basename($filePath);
|
||||
if(strpos($fileName, '.') !== false) $extension = substr($fileName, strpos($fileName, '.') + 1);
|
||||
}
|
||||
$this->view->fileContent = $fileContent;
|
||||
$this->view->filePath = $filePath;
|
||||
$this->view->action = $action;
|
||||
$this->view->fileContent = $fileContent;
|
||||
$this->view->filePath = $filePath;
|
||||
$this->view->fileExtension = $extension;
|
||||
$this->view->action = $action;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
body{padding-bottom:0px;background-color:#fff;}
|
||||
#showContentEditor, #fileContentEditor {border:1px solid #ddd;}
|
||||
.main-content {padding:0px;}
|
||||
.checkbox-primary {display:inline-block; padding-left:12px;}
|
||||
.checkbox-primary label {padding-left:12px;}
|
||||
|
||||
@@ -26,7 +26,6 @@ js::import($jsRoot . 'monaco-editor/min/vs/loader.js');
|
||||
</div>
|
||||
</div>
|
||||
<form method='post' target='hiddenwin' action='<?php echo inlink('save', "filePath=$safeFilePath&action=$action")?>'>
|
||||
<div class='main-content'>
|
||||
<table class='table table-form'>
|
||||
<?php if(!empty($showContent)):?>
|
||||
<tr>
|
||||
@@ -72,6 +71,11 @@ js::import($jsRoot . 'monaco-editor/min/vs/loader.js');
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='text-center'>
|
||||
<?php echo html::submitButton()?>
|
||||
<?php if($action and $action != 'edit' and $action != 'newPage'):?>
|
||||
<div class='checkbox-primary'>
|
||||
<input type='checkbox' name='override' id='override' />
|
||||
@@ -80,16 +84,14 @@ js::import($jsRoot . 'monaco-editor/min/vs/loader.js');
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td align='center'><?php echo html::submitButton()?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php if(!empty($showContent)) js::set('showContent', $showContent);?>
|
||||
<?php js::set('fileContent', $fileContent);?>
|
||||
<?php js::set('language', $fileExtension == 'js' ? 'javascript' : $fileExtension);?>
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
var lang = 'php';
|
||||
fileContentEditor = showContentEditor = null;
|
||||
require.config({
|
||||
paths: {vs: jsRoot + 'monaco-editor/min/vs'},
|
||||
@@ -102,35 +104,35 @@ $(function()
|
||||
<?php if(!empty($showContent)):?>
|
||||
showContentEditor = monaco.editor.create(document.getElementById('showContentEditor'),
|
||||
{
|
||||
value: showContent.toString(),
|
||||
language: lang,
|
||||
readOnly: true,
|
||||
autoIndent: true,
|
||||
contextmenu: true,
|
||||
automaticLayout: true,
|
||||
EditorMinimapOptions: {enabled: false}
|
||||
value: showContent.toString(),
|
||||
language: language,
|
||||
readOnly: true,
|
||||
autoIndent: true,
|
||||
contextmenu: true,
|
||||
automaticLayout: true,
|
||||
minimap: {enabled: false}
|
||||
});
|
||||
<?php endif;?>
|
||||
fileContentEditor = monaco.editor.create(document.getElementById('fileContentEditor'),
|
||||
{
|
||||
value: fileContent.toString(),
|
||||
language: lang,
|
||||
readOnly: false,
|
||||
autoIndent: true,
|
||||
contextmenu: true,
|
||||
automaticLayout: true,
|
||||
EditorMinimapOptions: {enabled: false}
|
||||
value: fileContent.toString(),
|
||||
language: language,
|
||||
readOnly: false,
|
||||
autoIndent: true,
|
||||
contextmenu: true,
|
||||
automaticLayout: true,
|
||||
minimap: {enabled: false}
|
||||
});
|
||||
var codeHeight = top.window.innerHeight - 300;
|
||||
<?php if(!empty($showContent)):?>
|
||||
contentHeight = showContentEditor.getContentHeight();
|
||||
if(contentHeight > 300) contentHeight = 300;
|
||||
if(contentHeight < 200) contentHeight = 200;
|
||||
$('#showContentEditor').height(contentHeight);
|
||||
codeHeight -= contentHeight + 30;
|
||||
if(codeHeight < 300) codeHeight = 300;
|
||||
<?php endif;?>
|
||||
contentHeight = fileContentEditor.getContentHeight();
|
||||
if(contentHeight > 450) contentHeight = 450;
|
||||
if(contentHeight < 100) contentHeight = 100;
|
||||
$('#fileContentEditor').height(contentHeight);
|
||||
$('#fileContentEditor').height(codeHeight);
|
||||
});
|
||||
$('#submit').click(function()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user