@wordpress/editor 13.20.1 → 13.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/utils/notice-builder.js +5 -6
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +5 -6
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/package.json +31 -31
- package/src/lock-unlock.js +1 -1
- package/src/store/test/actions.js +7 -1
- package/src/store/utils/notice-builder.js +6 -6
- package/src/store/utils/test/notice-builder.js +6 -1
package/CHANGELOG.md
CHANGED
package/build/lock-unlock.js
CHANGED
|
@@ -12,7 +12,7 @@ var _privateApis = require("@wordpress/private-apis");
|
|
|
12
12
|
const {
|
|
13
13
|
lock,
|
|
14
14
|
unlock
|
|
15
|
-
} = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my
|
|
15
|
+
} = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor');
|
|
16
16
|
exports.unlock = unlock;
|
|
17
17
|
exports.lock = lock;
|
|
18
18
|
//# sourceMappingURL=lock-unlock.js.map
|
package/build/lock-unlock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/editor/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my
|
|
1
|
+
{"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/editor/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/editor'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAEO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,iHAAiH,EACjH,mBACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
|
|
@@ -35,20 +35,19 @@ function getNotificationArgumentsForSaveSuccess(data) {
|
|
|
35
35
|
if (data.options?.isAutosave) {
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
// No notice is shown after trashing a post
|
|
40
|
-
if (post.status === 'trash' && previousPost.status !== 'trash') {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
38
|
const publishStatus = ['publish', 'private', 'future'];
|
|
44
39
|
const isPublished = publishStatus.includes(previousPost.status);
|
|
45
40
|
const willPublish = publishStatus.includes(post.status);
|
|
41
|
+
const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
|
|
46
42
|
let noticeMessage;
|
|
47
43
|
let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
|
|
48
44
|
let isDraft;
|
|
49
45
|
|
|
50
46
|
// Always should a notice, which will be spoken for accessibility.
|
|
51
|
-
if (
|
|
47
|
+
if (willTrash) {
|
|
48
|
+
noticeMessage = postType.labels.item_trashed;
|
|
49
|
+
shouldShowLink = false;
|
|
50
|
+
} else if (!isPublished && !willPublish) {
|
|
52
51
|
// If saving a non-published post, don't show notice.
|
|
53
52
|
noticeMessage = (0, _i18n.__)('Draft saved.');
|
|
54
53
|
isDraft = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_constants","getNotificationArgumentsForSaveSuccess","data","_postType$viewable","previousPost","post","postType","options","isAutosave","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_constants","getNotificationArgumentsForSaveSuccess","data","_postType$viewable","previousPost","post","postType","options","isAutosave","publishStatus","isPublished","includes","status","willPublish","willTrash","noticeMessage","shouldShowLink","viewable","isDraft","labels","item_trashed","__","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","SAVE_POST_NOTICE_ID","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail","TRASH_POST_NOTICE_ID"],"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( data.options?.isAutosave ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.includes( previousPost.status );\n\tconst willPublish = publishStatus.includes( post.status );\n\tconst willTrash =\n\t\tpost.status === 'trash' && previousPost.status !== 'trash';\n\n\tlet noticeMessage;\n\tlet shouldShowLink = postType?.viewable ?? false;\n\tlet isDraft;\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( willTrash ) {\n\t\tnoticeMessage = postType.labels.item_trashed;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved.' );\n\t\tisDraft = true;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: isDraft ? __( 'View Preview' ) : postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,sCAAsCA,CAAEC,IAAI,EAAG;EAAA,IAAAC,kBAAA;EAC9D,MAAM;IAAEC,YAAY;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGJ,IAAI;EAC7C;EACA,IAAKA,IAAI,CAACK,OAAO,EAAEC,UAAU,EAAG;IAC/B,OAAO,EAAE;EACV;EAEA,MAAMC,aAAa,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAE;EACxD,MAAMC,WAAW,GAAGD,aAAa,CAACE,QAAQ,CAAEP,YAAY,CAACQ,MAAO,CAAC;EACjE,MAAMC,WAAW,GAAGJ,aAAa,CAACE,QAA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,EACb;IACCqB,EAAE,EAAEC;EACL,CAAC,CACD;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,oCAAoCA,CAAE9C,IAAI,EAAG;EAC5D,OAAO,CACNA,IAAI,CAACuC,KAAK,CAACI,OAAO,IAAI3C,IAAI,CAACuC,KAAK,CAACC,IAAI,KAAK,eAAe,GACtDxC,IAAI,CAACuC,KAAK,CAACI,OAAO,GAClB,IAAAxB,QAAE,EAAE,iBAAkB,CAAC,EAC1B;IACCe,EAAE,EAAEa;EACL,CAAC,CACD;AACF"}
|
|
@@ -5,5 +5,5 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
|
|
|
5
5
|
export const {
|
|
6
6
|
lock,
|
|
7
7
|
unlock
|
|
8
|
-
} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my
|
|
8
|
+
} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor');
|
|
9
9
|
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/editor/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my
|
|
1
|
+
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/editor/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/editor'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAC1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,iHAAiH,EACjH,mBACD,CAAC"}
|
|
@@ -27,20 +27,19 @@ export function getNotificationArgumentsForSaveSuccess(data) {
|
|
|
27
27
|
if (data.options?.isAutosave) {
|
|
28
28
|
return [];
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
// No notice is shown after trashing a post
|
|
32
|
-
if (post.status === 'trash' && previousPost.status !== 'trash') {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
30
|
const publishStatus = ['publish', 'private', 'future'];
|
|
36
31
|
const isPublished = publishStatus.includes(previousPost.status);
|
|
37
32
|
const willPublish = publishStatus.includes(post.status);
|
|
33
|
+
const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
|
|
38
34
|
let noticeMessage;
|
|
39
35
|
let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
|
|
40
36
|
let isDraft;
|
|
41
37
|
|
|
42
38
|
// Always should a notice, which will be spoken for accessibility.
|
|
43
|
-
if (
|
|
39
|
+
if (willTrash) {
|
|
40
|
+
noticeMessage = postType.labels.item_trashed;
|
|
41
|
+
shouldShowLink = false;
|
|
42
|
+
} else if (!isPublished && !willPublish) {
|
|
44
43
|
// If saving a non-published post, don't show notice.
|
|
45
44
|
noticeMessage = __('Draft saved.');
|
|
46
45
|
isDraft = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","SAVE_POST_NOTICE_ID","TRASH_POST_NOTICE_ID","getNotificationArgumentsForSaveSuccess","data","_postType$viewable","previousPost","post","postType","options","isAutosave","
|
|
1
|
+
{"version":3,"names":["__","SAVE_POST_NOTICE_ID","TRASH_POST_NOTICE_ID","getNotificationArgumentsForSaveSuccess","data","_postType$viewable","previousPost","post","postType","options","isAutosave","publishStatus","isPublished","includes","status","willPublish","willTrash","noticeMessage","shouldShowLink","viewable","isDraft","labels","item_trashed","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail"],"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( data.options?.isAutosave ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.includes( previousPost.status );\n\tconst willPublish = publishStatus.includes( post.status );\n\tconst willTrash =\n\t\tpost.status === 'trash' && previousPost.status !== 'trash';\n\n\tlet noticeMessage;\n\tlet shouldShowLink = postType?.viewable ?? false;\n\tlet isDraft;\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( willTrash ) {\n\t\tnoticeMessage = postType.labels.item_trashed;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved.' );\n\t\tisDraft = true;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: isDraft ? __( 'View Preview' ) : postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,cAAc;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sCAAsCA,CAAEC,IAAI,EAAG;EAAA,IAAAC,kBAAA;EAC9D,MAAM;IAAEC,YAAY;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGJ,IAAI;EAC7C;EACA,IAAKA,IAAI,CAACK,OAAO,EAAEC,UAAU,EAAG;IAC/B,OAAO,EAAE;EACV;EAEA,MAAMC,aAAa,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAE;EACxD,MAAMC,WAAW,GAAGD,aAAa,CAACE,QAAQ,CAAEP,YAAY,CAACQ,MAAO,CAAC;EACjE,MAAMC,WAAW,GAAGJ,aAAa,CAACE,QAAQ,CAAEN,IAAI,CAACO,MAAO,CAAC;EACzD,MAAME,SAAS,GACdT,IAAI,CAACO,MAAM,KAAK,OAAO,IAAIR,YAAY,CAACQ,MAAM,KAAK,OAAO;EAE3D,IAAIG,aAAa;EACjB,IAAIC,cAAc,IAAAb,kBAAA,GAAGG,QAAQ,EAAEW,QAAQ,cAAAd,kBAAA,cAAAA,kBAAA,GAAI,KAAK;EAChD,IAAIe,OAAO;;EAEX;EACA,IAAKJ,SAAS,EAAG;IAChBC,aAAa,G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AEnC;EACL,CAAC,CACD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.21.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,35 +31,35 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^6.
|
|
36
|
-
"@wordpress/blob": "^3.
|
|
37
|
-
"@wordpress/block-editor": "^12.
|
|
38
|
-
"@wordpress/blocks": "^12.
|
|
39
|
-
"@wordpress/components": "^25.
|
|
40
|
-
"@wordpress/compose": "^6.
|
|
41
|
-
"@wordpress/core-data": "^6.
|
|
42
|
-
"@wordpress/data": "^9.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^5.
|
|
47
|
-
"@wordpress/hooks": "^3.
|
|
48
|
-
"@wordpress/html-entities": "^3.
|
|
49
|
-
"@wordpress/i18n": "^4.
|
|
50
|
-
"@wordpress/icons": "^9.
|
|
51
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
52
|
-
"@wordpress/keycodes": "^3.
|
|
53
|
-
"@wordpress/media-utils": "^4.
|
|
54
|
-
"@wordpress/notices": "^4.
|
|
55
|
-
"@wordpress/patterns": "^1.
|
|
56
|
-
"@wordpress/preferences": "^3.
|
|
57
|
-
"@wordpress/private-apis": "^0.
|
|
58
|
-
"@wordpress/reusable-blocks": "^4.
|
|
59
|
-
"@wordpress/rich-text": "^6.
|
|
60
|
-
"@wordpress/server-side-render": "^4.
|
|
61
|
-
"@wordpress/url": "^3.
|
|
62
|
-
"@wordpress/wordcount": "^3.
|
|
34
|
+
"@wordpress/a11y": "^3.44.0",
|
|
35
|
+
"@wordpress/api-fetch": "^6.41.0",
|
|
36
|
+
"@wordpress/blob": "^3.44.0",
|
|
37
|
+
"@wordpress/block-editor": "^12.12.0",
|
|
38
|
+
"@wordpress/blocks": "^12.21.0",
|
|
39
|
+
"@wordpress/components": "^25.10.0",
|
|
40
|
+
"@wordpress/compose": "^6.21.0",
|
|
41
|
+
"@wordpress/core-data": "^6.21.0",
|
|
42
|
+
"@wordpress/data": "^9.14.0",
|
|
43
|
+
"@wordpress/date": "^4.44.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.44.0",
|
|
45
|
+
"@wordpress/dom": "^3.44.0",
|
|
46
|
+
"@wordpress/element": "^5.21.0",
|
|
47
|
+
"@wordpress/hooks": "^3.44.0",
|
|
48
|
+
"@wordpress/html-entities": "^3.44.0",
|
|
49
|
+
"@wordpress/i18n": "^4.44.0",
|
|
50
|
+
"@wordpress/icons": "^9.35.0",
|
|
51
|
+
"@wordpress/keyboard-shortcuts": "^4.21.0",
|
|
52
|
+
"@wordpress/keycodes": "^3.44.0",
|
|
53
|
+
"@wordpress/media-utils": "^4.35.0",
|
|
54
|
+
"@wordpress/notices": "^4.12.0",
|
|
55
|
+
"@wordpress/patterns": "^1.5.0",
|
|
56
|
+
"@wordpress/preferences": "^3.21.0",
|
|
57
|
+
"@wordpress/private-apis": "^0.26.0",
|
|
58
|
+
"@wordpress/reusable-blocks": "^4.21.0",
|
|
59
|
+
"@wordpress/rich-text": "^6.21.0",
|
|
60
|
+
"@wordpress/server-side-render": "^4.21.0",
|
|
61
|
+
"@wordpress/url": "^3.45.0",
|
|
62
|
+
"@wordpress/wordcount": "^3.44.0",
|
|
63
63
|
"classnames": "^2.3.1",
|
|
64
64
|
"date-fns": "^2.28.0",
|
|
65
65
|
"memize": "^2.1.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "f83bb1a71e8fa416131b81a9f282a72a1dc6c694"
|
|
78
78
|
}
|
package/src/lock-unlock.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
|
|
5
5
|
export const { lock, unlock } =
|
|
6
6
|
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
7
|
-
'I know using unstable features means my
|
|
7
|
+
'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
|
|
8
8
|
'@wordpress/editor'
|
|
9
9
|
);
|
|
@@ -33,6 +33,7 @@ const postTypeEntity = {
|
|
|
33
33
|
item_updated: 'Updated Post',
|
|
34
34
|
item_published: 'Post published',
|
|
35
35
|
item_reverted_to_draft: 'Post reverted to draft.',
|
|
36
|
+
item_trashed: 'Post trashed.',
|
|
36
37
|
},
|
|
37
38
|
};
|
|
38
39
|
|
|
@@ -286,7 +287,12 @@ describe( 'Post actions', () => {
|
|
|
286
287
|
|
|
287
288
|
// Check that there are no notices.
|
|
288
289
|
const notices = registry.select( noticesStore ).getNotices();
|
|
289
|
-
expect( notices ).
|
|
290
|
+
expect( notices ).toMatchObject( [
|
|
291
|
+
{
|
|
292
|
+
status: 'success',
|
|
293
|
+
content: 'Post trashed.',
|
|
294
|
+
},
|
|
295
|
+
] );
|
|
290
296
|
|
|
291
297
|
// Check the new status.
|
|
292
298
|
const { status } = registry.select( editorStore ).getCurrentPost();
|
|
@@ -23,21 +23,21 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
|
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// No notice is shown after trashing a post
|
|
27
|
-
if ( post.status === 'trash' && previousPost.status !== 'trash' ) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
26
|
const publishStatus = [ 'publish', 'private', 'future' ];
|
|
32
27
|
const isPublished = publishStatus.includes( previousPost.status );
|
|
33
28
|
const willPublish = publishStatus.includes( post.status );
|
|
29
|
+
const willTrash =
|
|
30
|
+
post.status === 'trash' && previousPost.status !== 'trash';
|
|
34
31
|
|
|
35
32
|
let noticeMessage;
|
|
36
33
|
let shouldShowLink = postType?.viewable ?? false;
|
|
37
34
|
let isDraft;
|
|
38
35
|
|
|
39
36
|
// Always should a notice, which will be spoken for accessibility.
|
|
40
|
-
if (
|
|
37
|
+
if ( willTrash ) {
|
|
38
|
+
noticeMessage = postType.labels.item_trashed;
|
|
39
|
+
shouldShowLink = false;
|
|
40
|
+
} else if ( ! isPublished && ! willPublish ) {
|
|
41
41
|
// If saving a non-published post, don't show notice.
|
|
42
42
|
noticeMessage = __( 'Draft saved.' );
|
|
43
43
|
isDraft = true;
|
|
@@ -17,6 +17,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
|
|
|
17
17
|
item_scheduled: 'scheduled',
|
|
18
18
|
item_updated: 'updated',
|
|
19
19
|
view_item: 'view',
|
|
20
|
+
item_trashed: 'trash',
|
|
20
21
|
},
|
|
21
22
|
viewable: false,
|
|
22
23
|
};
|
|
@@ -74,7 +75,11 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
|
|
|
74
75
|
},
|
|
75
76
|
],
|
|
76
77
|
],
|
|
77
|
-
[
|
|
78
|
+
[
|
|
79
|
+
'when post will be trashed',
|
|
80
|
+
[ 'publish', 'trash', true ],
|
|
81
|
+
[ 'trash', defaultExpectedAction ],
|
|
82
|
+
],
|
|
78
83
|
].forEach(
|
|
79
84
|
( [
|
|
80
85
|
description,
|