Skip to content

Commit 7e65df1

Browse files
committed
Restore: Sync Gutenberg @ e499abfb843a43ac88455ca319220c5f181e1cf3
See changelog in e7d40e7
2 parents 7ab2295 + e7d40e7 commit 7e65df1

151 files changed

Lines changed: 4430 additions & 9455 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/js/_enqueues/admin/common.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,9 +1350,11 @@ $( function() {
13501350
event.stopPropagation();
13511351
$( 'html, body' ).animate( { scrollTop: 0 } );
13521352

1353-
var errorMessage = __( 'Please select at least one item to perform this action on.' );
1353+
var errorMessage = value !== '-1' ?
1354+
__( 'Please select at least one item to perform this action on.' ) :
1355+
__( 'Please select a bulk action to perform.' );
13541356
addAdminNotice( {
1355-
id: 'no-items-selected',
1357+
id: value !== '-1' ? 'no-items-selected' : 'no-bulk-action-selected',
13561358
type: 'error',
13571359
message: errorMessage,
13581360
dismissible: true,

src/js/_enqueues/admin/link.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,37 @@ jQuery( function($) {
1919
*
2020
* @return {boolean} Always returns false to prevent the default behavior.
2121
*/
22-
$('#category-tabs a').on( 'click', function(){
22+
$('#category-tabs a').on( 'click keyup keydown', function( event ){
2323
var t = $(this).attr('href');
24-
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
25-
$('.tabs-panel').hide();
26-
$(t).show();
27-
if ( '#categories-all' == t )
28-
deleteUserSetting('cats');
29-
else
30-
setUserSetting('cats','pop');
31-
return false;
24+
if ( event.type === 'keydown' && event.key === ' ' ) {
25+
event.preventDefault();
26+
}
27+
if ( ( event.type === 'keyup' && event.key === ' ' ) || ( event.type === 'keydown' && event.key === 'Enter' ) || event.type === 'click' ) {
28+
event.preventDefault();
29+
$('#category-tabs a').removeAttr( 'aria-selected' ).attr( 'tabindex', '-1' );
30+
$(this).attr( 'aria-selected', 'true' ).removeAttr( 'tabindex' );
31+
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
32+
$('.tabs-panel').hide();
33+
$(t).show();
34+
if ( '#categories-all' == t ) {
35+
deleteUserSetting('cats');
36+
} else {
37+
setUserSetting('cats','pop');
38+
}
39+
return false;
40+
}
41+
if ( event.type === 'keyup' && ( event.key === 'ArrowRight' || event.key === 'ArrowLeft' ) ) {
42+
$(this).attr( 'tabindex', '-1' );
43+
let next = $(this).parent('li').next();
44+
let prev = $(this).parent('li').prev();
45+
if ( next.length > 0 ) {
46+
next.find('a').removeAttr( 'tabindex');
47+
next.find('a').trigger( 'focus' );
48+
} else {
49+
prev.find('a').removeAttr( 'tabindex');
50+
prev.find('a').trigger( 'focus' );
51+
}
52+
}
3253
});
3354
if ( getUserSetting('cats') )
3455
$('#category-tabs a[href="#categories-pop"]').trigger( 'click' );

src/js/_enqueues/admin/post.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,35 @@ jQuery( function($) {
566566
}
567567

568568
// @todo Move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js.
569-
$('a', '#' + taxonomy + '-tabs').on( 'click', function( e ) {
570-
e.preventDefault();
569+
$('a', '#' + taxonomy + '-tabs').on( 'click keyup keydown', function( event ) {
571570
var t = $(this).attr('href');
572-
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
573-
$('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
574-
$(t).show();
575-
if ( '#' + taxonomy + '-all' == t ) {
576-
deleteUserSetting( settingName );
577-
} else {
578-
setUserSetting( settingName, 'pop' );
571+
if ( event.type === 'keydown' && event.key === ' ' ) {
572+
event.preventDefault();
573+
}
574+
if ( ( event.type === 'keyup' && event.key === ' ' ) || ( event.type === 'keydown' && event.key === 'Enter' ) || event.type === 'click' ) {
575+
event.preventDefault();
576+
$('#' + taxonomy + '-tabs a').removeAttr( 'aria-selected' ).attr( 'tabindex', '-1' );
577+
$(this).attr( 'aria-selected', 'true' ).removeAttr( 'tabindex' );
578+
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
579+
$('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
580+
$(t).show();
581+
if ( '#' + taxonomy + '-all' == t ) {
582+
deleteUserSetting( settingName );
583+
} else {
584+
setUserSetting( settingName, 'pop' );
585+
}
586+
}
587+
if ( event.type === 'keyup' && ( event.key === 'ArrowRight' || event.key === 'ArrowLeft' ) ) {
588+
$(this).attr( 'tabindex', '-1' );
589+
let next = $(this).parent('li').next();
590+
let prev = $(this).parent('li').prev();
591+
if ( next.length > 0 ) {
592+
next.find('a').removeAttr( 'tabindex');
593+
next.find('a').trigger( 'focus' );
594+
} else {
595+
prev.find('a').removeAttr( 'tabindex');
596+
prev.find('a').trigger( 'focus' );
597+
}
579598
}
580599
});
581600

src/js/_enqueues/vendor/codemirror/fakejshint.js renamed to src/js/_enqueues/deprecated/fakejshint.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
// JSHINT has some GPL Compatability issues, so we are faking it out and using esprima for validation
2-
// Based on https://github.com/jquery/esprima/blob/gh-pages/demo/validate.js which is MIT licensed
1+
/**
2+
* JSHINT has some GPL Compatability issues, so we are faking it out and using esprima for validation
3+
* Based on https://github.com/jquery/esprima/blob/gh-pages/demo/validate.js which is MIT licensed.
4+
* This is now deprecated in favor of Espree.
5+
*
6+
* @since 4.9.3
7+
* @deprecated 7.0.0
8+
* @output wp-includes/js/codemirror/fakejshint.js
9+
* @see https://core.trac.wordpress.org/ticket/42850
10+
* @see https://core.trac.wordpress.org/ticket/64558
11+
*/
312

13+
/* jshint -W057, -W058 */
414
var fakeJSHINT = new function() {
515
var syntax, errors;
616
var that = this;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": [ "javascript-lint.js" ],
5+
"parserOptions": {
6+
"sourceType": "module",
7+
"ecmaVersion": 2020
8+
}
9+
},
10+
{
11+
"files": [ "htmlhint-kses.js" ],
12+
"parserOptions": {
13+
"ecmaVersion": 2020
14+
}
15+
}
16+
]
17+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* global HTMLHint */
2+
/* eslint no-magic-numbers: ["error", { "ignore": [1] }] */
3+
HTMLHint.addRule( {
4+
id: 'kses',
5+
description: 'Element or attribute cannot be used.',
6+
7+
/**
8+
* Initialize.
9+
*
10+
* @this {import('htmlhint/types').Rule}
11+
* @param {import('htmlhint').HTMLParser} parser - Parser.
12+
* @param {import('htmlhint').Reporter} reporter - Reporter.
13+
* @param {Record<string, Record<string, boolean>>} options - KSES options.
14+
* @return {void}
15+
*/
16+
init: function ( parser, reporter, options ) {
17+
'use strict';
18+
19+
parser.addListener( 'tagstart', ( event ) => {
20+
const tagName = event.tagName.toLowerCase();
21+
if ( ! options[ tagName ] ) {
22+
reporter.error(
23+
`Tag <${ event.tagName }> is not allowed.`,
24+
event.line,
25+
event.col,
26+
this,
27+
event.raw
28+
);
29+
return;
30+
}
31+
32+
const allowedAttributes = options[ tagName ];
33+
const column = event.col + event.tagName.length + 1;
34+
for ( const attribute of event.attrs ) {
35+
if ( ! allowedAttributes[ attribute.name.toLowerCase() ] ) {
36+
reporter.error(
37+
`Tag attribute [${ attribute.raw }] is not allowed.`,
38+
event.line,
39+
column + attribute.index,
40+
this,
41+
attribute.raw
42+
);
43+
}
44+
}
45+
} );
46+
},
47+
} );

src/js/_enqueues/vendor/codemirror/javascript-lint.js renamed to src/js/_enqueues/lib/codemirror/javascript-lint.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import CodeMirror from 'codemirror';
2525
* @see https://www.npmjs.com/package/espree#options
2626
*
2727
* @typedef {Object} SupportedJSHintOptions
28-
* @property {number} [esversion] - "This option is used to specify the ECMAScript version to which the code must adhere."
28+
* @property {import('espree').Options['ecmaVersion']} [esversion] - "This option is used to specify the ECMAScript version to which the code must adhere."
2929
* @property {boolean} [es5] - "This option enables syntax first defined in the ECMAScript 5.1 specification. This includes allowing reserved keywords as object properties."
3030
* @property {boolean} [es3] - "This option tells JSHint that your code needs to adhere to ECMAScript 3 specification. Use this option if you need your program to be executable in older browsers—such as Internet Explorer 6/7/8/9—and other legacy JavaScript environments."
3131
* @property {boolean} [module] - "This option informs JSHint that the input code describes an ECMAScript 6 module. All module code is interpreted as strict mode code."
@@ -50,19 +50,20 @@ async function validator( text, options ) {
5050
loc: true,
5151
} );
5252
} catch ( error ) {
53+
const enhancedError = /** @type {Error & { lineNumber?: number, column?: number }} */ ( error );
5354
if (
5455
// This is an `EnhancedSyntaxError` in Espree: <https://github.com/brettz9/espree/blob/3c1120280b24f4a5e4c3125305b072fa0dfca22b/packages/espree/lib/espree.js#L48-L54>.
5556
error instanceof SyntaxError &&
56-
typeof error.lineNumber === 'number' &&
57-
typeof error.column === 'number'
57+
typeof enhancedError.lineNumber === 'number' &&
58+
typeof enhancedError.column === 'number'
5859
) {
59-
const line = error.lineNumber - 1;
60-
errors.push( {
60+
const line = enhancedError.lineNumber - 1;
61+
errors.push( /** @type {CodeMirrorLintError} */ ( {
6162
message: error.message,
6263
severity: 'error',
63-
from: CodeMirror.Pos( line, error.column - 1 ),
64-
to: CodeMirror.Pos( line, error.column ),
65-
} );
64+
from: CodeMirror.Pos( line, enhancedError.column - 1 ),
65+
to: CodeMirror.Pos( line, enhancedError.column ),
66+
} ) );
6667
} else {
6768
console.warn( '[CodeMirror] Unable to lint JavaScript:', error ); // jshint ignore:line
6869
}
@@ -80,13 +81,15 @@ CodeMirror.registerHelper( 'lint', 'javascript', validator );
8081
*
8182
* @param {SupportedJSHintOptions} options - Linting options for JSHint.
8283
* @return {{
83-
* ecmaVersion?: number|'latest',
84+
* ecmaVersion?: import('espree').Options['ecmaVersion'],
85+
* sourceType?: 'module'|'script',
8486
* ecmaFeatures?: {
8587
* impliedStrict?: true
8688
* }
8789
* }}
8890
*/
8991
function getEspreeOptions( options ) {
92+
/** @type {{ impliedStrict?: true }} */
9093
const ecmaFeatures = {};
9194
if ( options.strict === 'implied' ) {
9295
ecmaFeatures.impliedStrict = true;
@@ -105,10 +108,10 @@ function getEspreeOptions( options ) {
105108
* @since 7.0.0
106109
*
107110
* @param {SupportedJSHintOptions} options - Options.
108-
* @return {number|'latest'} ECMAScript version.
111+
* @return {import('espree').Options['ecmaVersion']} ECMAScript version.
109112
*/
110113
function getEcmaVersion( options ) {
111-
if ( typeof options.esversion === 'number' ) {
114+
if ( options.esversion ) {
112115
return options.esversion;
113116
}
114117
if ( options.es5 ) {

0 commit comments

Comments
 (0)