Code Editor: Define default gutters
and toggle lint markers based on changes to lint
option.
Explicitly define `gutters` in base `defaultSettings` to improve merges of multiple calls to `wp_enqueue_code_editor()`. Props westonruter, georgestephanis for testing. Amends [41974]. See #12423. git-svn-id: https://develop.svn.wordpress.org/trunk@41992 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
18f91933fb
commit
c0a61efdad
@ -136,13 +136,19 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
|
|||||||
|
|
||||||
// Keep lint options populated.
|
// Keep lint options populated.
|
||||||
editor.on( 'optionChange', function( cm, option ) {
|
editor.on( 'optionChange', function( cm, option ) {
|
||||||
var options;
|
var options, gutters, gutterName = 'CodeMirror-lint-markers';
|
||||||
if ( 'lint' !== option ) {
|
if ( 'lint' !== option ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
gutters = editor.getOption( 'gutters' ) || [];
|
||||||
options = editor.getOption( 'lint' );
|
options = editor.getOption( 'lint' );
|
||||||
if ( true === options ) {
|
if ( true === options ) {
|
||||||
|
if ( ! _.contains( gutters, gutterName ) ) {
|
||||||
|
editor.setOption( 'gutters', [ gutterName ].concat( gutters ) );
|
||||||
|
}
|
||||||
editor.setOption( 'lint', getLintOptions() ); // Expand to include linting options.
|
editor.setOption( 'lint', getLintOptions() ); // Expand to include linting options.
|
||||||
|
} else if ( ! options ) {
|
||||||
|
editor.setOption( 'gutters', _.without( gutters, gutterName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force update on error notice to show or hide.
|
// Force update on error notice to show or hide.
|
||||||
|
@ -3157,6 +3157,7 @@ function wp_enqueue_code_editor( $args ) {
|
|||||||
'Alt-F' => 'findPersistent',
|
'Alt-F' => 'findPersistent',
|
||||||
),
|
),
|
||||||
'direction' => 'ltr', // Code is shown in LTR even in RTL languages.
|
'direction' => 'ltr', // Code is shown in LTR even in RTL languages.
|
||||||
|
'gutters' => array(),
|
||||||
),
|
),
|
||||||
'csslint' => array(
|
'csslint' => array(
|
||||||
'errors' => true, // Parsing errors.
|
'errors' => true, // Parsing errors.
|
||||||
|
Loading…
Reference in New Issue
Block a user