Skip to content

Commit 5654f03

Browse files
committed
Fixed CodeMirror editor autoresizing
1 parent bc727cf commit 5654f03

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function(grunt) {
99

1010
css: {
1111
files: ['css/**/*.scss'],
12-
tasks: ['css']
12+
tasks: ['postcss', 'csso']
1313
}
1414
},
1515

@@ -56,7 +56,7 @@ module.exports = function(grunt) {
5656
'css/min/tagit.css': [
5757
'js/vendor/jquery.tagit.css',
5858
'js/vendor/tagit.ui-zendesk.css'
59-
]rm
59+
]
6060
}
6161
}
6262
},

css/edit.scss

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,12 @@ ul.tagit {
4141
*/
4242
.CodeMirror {
4343
width: 100%;
44-
height: auto;
45-
min-height: 300px;
46-
44+
height: auto !important;
4745
border: 1px solid #dfdfdf;
4846
border-radius: 3px;
4947
background-color: #fff;
5048
}
5149

52-
.CodeMirror-scroll {
53-
overflow-x: auto;
54-
overflow-y: hidden;
55-
}
56-
5750
.CodeMirror-sizer {
5851
min-height: 300px !important;
5952
}

css/manage.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Custom styling for the snippets table
33
*/
44

5-
.column-name > a {
5+
%icon-after {
6+
padding-left: 5px;
7+
font-family: "dashicons";
8+
vertical-align: top;
9+
}
610

7-
%icon-after {
8-
padding-left: 5px;
9-
font-family: "dashicons";
10-
vertical-align: top;
11-
}
11+
.column-name > a {
1212

1313
.admin-scope &:after {
1414
@extend %icon-after;

css/settings.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
}
55

66
#code_snippets_editor_preview .CodeMirror {
7-
height: 200px;
7+
height: auto;
88
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
},
1010
"devDependencies": {
1111
"grunt": "^0.4.5",
12-
"grunt-autoprefixer": "^3.0.3",
1312
"grunt-contrib-clean": "^0.7.0",
1413
"grunt-contrib-copy": "^0.8.2",
1514
"grunt-contrib-imagemin": "^1.0.0",

php/settings/editor-preview.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ function example_custom_admin_footer_text( \$text ) {
8888
return 'Thank you for visiting <a href=\"' . get_home_url() . '\">' . get_bloginfo( 'name' ) . '</a>.';
8989
}
9090
91-
add_filter( 'admin_footer_text', 'example_custom_admin_footer_text' );";
91+
add_filter( 'admin_footer_text', 'example_custom_admin_footer_text' );
92+
93+
";
9294

9395
$atts = array(
9496
'mode' => 'text/x-php',
@@ -104,7 +106,10 @@ function example_custom_admin_footer_text( \$text ) {
104106
'use strict';
105107

106108
// Load CodeMirror
107-
var atts = <?php echo code_snippets_get_editor_atts( $atts, true ); ?>;
109+
var atts = [];
110+
atts = <?php echo code_snippets_get_editor_atts( $atts, true ); ?>;
111+
atts['viewportMargin'] = Infinity;
112+
108113
var editor = CodeMirror(document.getElementById('code_snippets_editor_preview'), atts);
109114

110115
// Dynamically change editor settings

php/views/edit.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
<?php _e( 'Code', 'code-snippets' ); ?>
5555
</label></h3>
5656

57-
<textarea id="snippet_code" name="snippet_code" rows="20" spellcheck="false" style="font-family: monospace; width: 100%;"><?php echo esc_textarea( $snippet->code ); ?></textarea>
57+
<textarea id="snippet_code" name="snippet_code" rows="200" spellcheck="false" style="font-family: monospace; width: 100%;"><?php
58+
echo esc_textarea( $snippet->code );
59+
?></textarea>
5860

5961
<?php
6062
/* Allow plugins to add fields and content to this page */
@@ -145,10 +147,13 @@
145147
*/
146148
(function() {
147149

148-
var atts = <?php
150+
var atts = [];
151+
atts = <?php
149152
$atts = array( 'mode' => 'text/x-php' );
150153
echo code_snippets_get_editor_atts( $atts, true );
151154
?>;
155+
atts['viewportMargin'] = Infinity;
156+
152157
CodeMirror.fromTextArea(document.getElementById('snippet_code'), atts);
153158
})();
154159
</script>

0 commit comments

Comments
 (0)