Skip to content

Commit 6123e65

Browse files
author
Akshay Paghdar
committed
Fixed editor for file types.
1 parent e54c214 commit 6123e65

3 files changed

Lines changed: 43 additions & 12 deletions

File tree

assets/admin/css/style.css

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,61 @@ ul.tree-list ul > li:last-child {
2121
}
2222
ul.tree-list a {
2323
text-decoration: none;
24+
display: block;
2425
}
26+
ul.tree-list a .folder-name{font-weight:bold;}
2527
ul.tree-list a:hover, ul.tree-list a:focus {
2628
text-decoration: underline;
2729
box-shadow: none;
30+
background: #e0eefc;
2831
}
2932
ul.tree-list span{outline:none !important;}
3033
ul.tree-list li {
3134
text-align : justify;
3235
line-height: 25px;
3336
position: relative;
3437
}
35-
38+
ul.tree-list label input[type=file]{
39+
display: none;
40+
}
3641
.file-list {
3742
border : 1px solid #cccccc40;
3843
padding : 10px;
3944
border-radius: 5px;
4045
background : #fbfbfb;
4146
}
47+
.tree-folder{
48+
display: inline-block;
49+
width: 100%;
50+
position: absolute;
51+
top: 0;
52+
right: 0;
53+
}
4254
.tree-file{}
55+
.tree-folder:hover,
4356
.tree-file:hover{
4457
background: #e0eefc;
4558
}
59+
li a:hover .folder-actions{display:inline-block;}
4660
.tree-file:hover .file-actions{display:inline-block;}
61+
.folder-actions,
4762
.file-actions{
4863
position: absolute;
4964
top: 0;
5065
right: 0;
5166
display: none;
5267
}
68+
.folder-actions span,
69+
.folder-actions label,
5370
.file-actions a{
71+
display: inline-block !important;
5472
font-size: 12px;
5573
padding: 0 5px;
5674
border-right: 1px solid #DDD;
75+
vertical-align: middle;
5776
}
77+
.folder-actions label:last-child,
78+
.folder-actions span:last-child,
5879
.file-actions a:last-child{border:0;}
5980
.tree-file-editable-area{
6081
position: relative;

assets/admin/js/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ jQuery(function ($) {
207207
parent.slideToggle();
208208
if (active == '0') {
209209
jQuery(this).attr('data-state', '1');
210-
var settings = cm_settings.ext;
211-
var cm_editor = wp.codeEditor.initialize($('#editor-'+slug+'-textarea'), settings);
210+
var settings = cm_settings[ext];
211+
var cm_editor = wp.codeEditor.initialize(jQuery('#editor-'+slug+'-textarea'), settings);
212212
parent.find('.CodeMirror-code').on('keyup',function(){
213213
$('#editor-'+slug+'-textarea').text(cm_editor.codemirror.getValue());
214214
$('#editor-'+slug+'-textarea').trigger('change');

includes/post-types/contentsView.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ public function admin_enqueue_scripts() {
3939
if (!$this->isValidPostType()) {
4040
return false;
4141
}
42-
$cm_settings['php']['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/html', 'codemirror' => array('autoRefresh' => true)));
43-
$cm_settings['html']['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/html', 'codemirror' => array('autoRefresh' => true)));
44-
$cm_settings['css']['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/css', 'codemirror' => array('autoRefresh' => true)));
45-
$cm_settings['js']['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/javascript', 'codemirror' => array('autoRefresh' => true)));
42+
$cm_settings['php'] = wp_enqueue_code_editor(array('file' => 'example.php', 'codemirror' => array('autoRefresh' => true), 'htmlhint' => array('space-tab-mixed-disabled' => 'space')));
43+
$cm_settings['html'] = wp_enqueue_code_editor(array('file' => 'example.html', 'codemirror' => array('autoRefresh' => true), 'htmlhint' => array('space-tab-mixed-disabled' => 'space')));
44+
$cm_settings['css'] = wp_enqueue_code_editor(array('file' => 'example.css', 'codemirror' => array('autoRefresh' => true)));
45+
$cm_settings['js'] = wp_enqueue_code_editor(array('file' => 'example.js', 'codemirror' => array('autoRefresh' => true)));
46+
4647
wp_localize_script('jquery', 'cm_settings', $cm_settings);
4748
wp_enqueue_script('wp-theme-plugin-editor');
4849
wp_enqueue_style('wp-codemirror');
@@ -100,16 +101,25 @@ function listFolderFiles($dir, $url = '') {
100101
$file_path = str_replace(ABSPATH, '', $dir) . '/' . $ff;
101102
$file_url = site_url('/') . $file_path;
102103
if (is_dir($dir . '/' . $ff)) {
103-
$output .= '<strong>' . $ff . '/</strong>';
104+
$output .= '<span class="folder-name">' . $ff . '/</span>';
105+
/*$output .= '<div class="tree-folder">';
106+
$output .= '<div class="folder-actions">';
107+
$output .= '<label title="'.__('Upload', 'drophtml').'" class="upload-to-tree-folder" target="_blank">';
108+
$output .= '<i class="dashicons dashicons-upload"></i>';
109+
$output .= '<input type="file" name="tf[]" multiple="multiple">';
110+
$output .= '</label>';
111+
$output .= '<span title="'.__('Delete', 'drophtml').'" class="delete-tree-folder" data-folder="' . $file_path . '"><i class="dashicons dashicons-trash"></i></span>';
112+
$output .= '</div>';
113+
$output .= '</div>';*/
104114
} else {
105-
$fileSlug = sanitize_title($dir.$ff);
115+
$fileSlug = sanitize_title($file_path);
106116
$output .= '<div class="tree-file">' . $ff;
107117
$output .= '<div class="file-actions">';
108-
$output .= '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E" . $file_url . '" target="_blank"><span class="dashicons dashicons-visibility"></span></a>';
118+
$output .= '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E" . $file_url . '" title="'.__('Preview', 'drophtml').'" target="_blank"><span class="dashicons dashicons-visibility"></span></a>';
109119
if ($this->isAllowEdit($dir . '/' . $ff)) {
110-
$output .= '<a href="javascript:void(0)" class="edit-tree-file" data-ext="'.$this->getFileExt($ff).'" data-slug="'.$fileSlug.'" data-file="' . $file_path . '" data-state="0"><span class="dashicons dashicons-edit"></span></a>';
120+
$output .= '<a href="javascript:void(0)" title="'.__('Edit', 'drophtml').'" class="edit-tree-file" data-ext="'.$this->getFileExt($ff).'" data-slug="'.$fileSlug.'" data-file="' . $file_path . '" data-state="0"><span class="dashicons dashicons-edit"></span></a>';
111121
}
112-
$output .= '<a href="javascript:void(0)" class="delete-tree-file" data-file="' . $file_path . '"><span class="dashicons dashicons-trash"></span></a>';
122+
$output .= '<a href="javascript:void(0)" title="'.__('Delete', 'drophtml').'" class="delete-tree-file" data-file="' . $file_path . '"><span class="dashicons dashicons-trash"></span></a>';
113123
$output .= '</div>';
114124
if ($this->isAllowEdit($dir . '/' . $ff)) {
115125
$content = file_get_contents($dir . '/' . $ff);

0 commit comments

Comments
 (0)