@wordpress/editor 14.25.0 → 14.26.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/post-author/combobox.js +1 -10
  3. package/build/components/post-author/combobox.js.map +1 -1
  4. package/build/components/post-publish-panel/maybe-tags-panel.js +11 -2
  5. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  6. package/build/hooks/media-upload.js +21 -1
  7. package/build/hooks/media-upload.js.map +1 -1
  8. package/build/store/selectors.js +20 -0
  9. package/build/store/selectors.js.map +1 -1
  10. package/build/utils/media-upload/index.js +13 -0
  11. package/build/utils/media-upload/index.js.map +1 -1
  12. package/build-module/components/post-author/combobox.js +1 -10
  13. package/build-module/components/post-author/combobox.js.map +1 -1
  14. package/build-module/components/post-publish-panel/maybe-tags-panel.js +12 -3
  15. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  16. package/build-module/hooks/media-upload.js +21 -1
  17. package/build-module/hooks/media-upload.js.map +1 -1
  18. package/build-module/store/selectors.js +20 -0
  19. package/build-module/store/selectors.js.map +1 -1
  20. package/build-module/utils/media-upload/index.js +13 -0
  21. package/build-module/utils/media-upload/index.js.map +1 -1
  22. package/build-types/components/post-author/combobox.d.ts.map +1 -1
  23. package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
  24. package/build-types/store/selectors.d.ts +20 -0
  25. package/build-types/store/selectors.d.ts.map +1 -1
  26. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  27. package/package.json +37 -37
  28. package/src/components/post-author/combobox.js +1 -10
  29. package/src/components/post-publish-panel/maybe-tags-panel.js +16 -4
  30. package/src/hooks/media-upload.js +14 -1
  31. package/src/store/selectors.js +20 -0
  32. package/src/utils/media-upload/index.js +17 -0
  33. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 14.26.0 (2025-06-25)
6
+
5
7
  ## 14.25.0 (2025-06-04)
6
8
 
7
9
  ## 14.24.0 (2025-05-22)
@@ -44,22 +44,13 @@ function PostAuthorCombobox() {
44
44
  author: postAuthorId
45
45
  });
46
46
  };
47
-
48
- /**
49
- * Handle user input.
50
- *
51
- * @param {string} inputValue The current value of the input field.
52
- */
53
- const handleKeydown = inputValue => {
54
- setFieldValue(inputValue);
55
- };
56
47
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ComboboxControl, {
57
48
  __nextHasNoMarginBottom: true,
58
49
  __next40pxDefaultSize: true,
59
50
  label: (0, _i18n.__)('Author'),
60
51
  options: authorOptions,
61
52
  value: authorId,
62
- onFilterValueChange: (0, _compose.debounce)(handleKeydown, 300),
53
+ onFilterValueChange: (0, _compose.debounce)(setFieldValue, 300),
63
54
  onChange: handleSelect,
64
55
  allowReset: false,
65
56
  hideLabelFromVision: true,
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_element","_data","_i18n","_components","_store","_hook","_jsxRuntime","PostAuthorCombobox","fieldValue","setFieldValue","useState","editPost","useDispatch","editorStore","authorId","authorOptions","isLoading","useAuthorsQuery","handleSelect","postAuthorId","author","handleKeydown","inputValue","jsx","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","__","options","value","onFilterValueChange","debounce","onChange","allowReset","hideLabelFromVision"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions, isLoading } =\n\t\tuseAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tallowReset={ false }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAAyC,IAAAO,WAAA,GAAAP,OAAA;AAbzC;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASQ,kBAAkBA,CAAA,EAAG;EAC5C,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAG,IAAAC,iBAAQ,EAAC,CAAC;EAEhD,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC/C,MAAM;IAAEC,QAAQ;IAAEC,aAAa;IAAEC;EAAU,CAAC,GAC3C,IAAAC,qBAAe,EAAET,UAAW,CAAC;;EAE9B;AACD;AACA;AACA;AACA;EACC,MAAMU,YAAY,GAAKC,YAAY,IAAM;IACxC,IAAK,CAAEA,YAAY,EAAG;MACrB;IACD;IACAR,QAAQ,CAAE;MAAES,MAAM,EAAED;IAAa,CAAE,CAAC;EACrC,CAAC;;EAED;AACD;AACA;AACA;AACA;EACC,MAAME,aAAa,GAAKC,UAAU,IAAM;IACvCb,aAAa,CAAEa,UAAW,CAAC;EAC5B,CAAC;EAED,oBACC,IAAAhB,WAAA,CAAAiB,GAAA,EAACpB,WAAA,CAAAqB,eAAe;IACfC,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;IACxBC,OAAO,EAAGd,aAAe;IACzBe,KAAK,EAAGhB,QAAU;IAClBiB,mBAAmB,EAAG,IAAAC,iBAAQ,EAAEX,aAAa,EAAE,GAAI,CAAG;IACtDY,QAAQ,EAAGf,YAAc;IACzBgB,UAAU,EAAG,KAAO;IACpBC,mBAAmB;IACnBnB,SAAS,EAAGA;EAAW,CACvB,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_compose","require","_element","_data","_i18n","_components","_store","_hook","_jsxRuntime","PostAuthorCombobox","fieldValue","setFieldValue","useState","editPost","useDispatch","editorStore","authorId","authorOptions","isLoading","useAuthorsQuery","handleSelect","postAuthorId","author","jsx","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","__","options","value","onFilterValueChange","debounce","onChange","allowReset","hideLabelFromVision"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions, isLoading } =\n\t\tuseAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( setFieldValue, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tallowReset={ false }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAAyC,IAAAO,WAAA,GAAAP,OAAA;AAbzC;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASQ,kBAAkBA,CAAA,EAAG;EAC5C,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAG,IAAAC,iBAAQ,EAAC,CAAC;EAEhD,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC/C,MAAM;IAAEC,QAAQ;IAAEC,aAAa;IAAEC;EAAU,CAAC,GAC3C,IAAAC,qBAAe,EAAET,UAAW,CAAC;;EAE9B;AACD;AACA;AACA;AACA;EACC,MAAMU,YAAY,GAAKC,YAAY,IAAM;IACxC,IAAK,CAAEA,YAAY,EAAG;MACrB;IACD;IACAR,QAAQ,CAAE;MAAES,MAAM,EAAED;IAAa,CAAE,CAAC;EACrC,CAAC;EAED,oBACC,IAAAb,WAAA,CAAAe,GAAA,EAAClB,WAAA,CAAAmB,eAAe;IACfC,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;IACxBC,OAAO,EAAGZ,aAAe;IACzBa,KAAK,EAAGd,QAAU;IAClBe,mBAAmB,EAAG,IAAAC,iBAAQ,EAAErB,aAAa,EAAE,GAAI,CAAG;IACtDsB,QAAQ,EAAGb,YAAc;IACzBc,UAAU,EAAG,KAAO;IACpBC,mBAAmB;IACnBjB,SAAS,EAAGA;EAAW,CACvB,CAAC;AAEJ","ignoreList":[]}
@@ -22,15 +22,24 @@ var _jsxRuntime = require("react/jsx-runtime");
22
22
  */
23
23
 
24
24
  const TagsPanel = () => {
25
+ var _tagLabels$add_new_it, _tagLabels$name;
26
+ const tagLabels = (0, _data.useSelect)(select => {
27
+ const taxonomy = select(_coreData.store).getTaxonomy('post_tag');
28
+ return taxonomy?.labels;
29
+ }, []);
30
+ const addNewItem = (_tagLabels$add_new_it = tagLabels?.add_new_item) !== null && _tagLabels$add_new_it !== void 0 ? _tagLabels$add_new_it : (0, _i18n.__)('Add tag');
31
+ const tagLabel = (_tagLabels$name = tagLabels?.name) !== null && _tagLabels$name !== void 0 ? _tagLabels$name : (0, _i18n.__)('Tags');
25
32
  const panelBodyTitle = [(0, _i18n.__)('Suggestion:'), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
26
33
  className: "editor-post-publish-panel__link",
27
- children: (0, _i18n.__)('Add tags')
34
+ children: addNewItem
28
35
  }, "label")];
29
36
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.PanelBody, {
30
37
  initialOpen: false,
31
38
  title: panelBodyTitle,
32
39
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
33
- children: (0, _i18n.__)('Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.')
40
+ children: (0, _i18n.sprintf)(
41
+ // translators: %s is the taxonomy name (e.g., "Tags").
42
+ (0, _i18n.__)('%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'), tagLabel)
34
43
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_flatTermSelector.default, {
35
44
  slug: "post_tag",
36
45
  __nextHasNoMarginBottom: true
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_data","_components","_coreData","_flatTermSelector","_interopRequireDefault","_store","_jsxRuntime","TagsPanel","panelBodyTitle","__","jsx","className","children","jsxs","PanelBody","initialOpen","title","default","slug","__nextHasNoMarginBottom","MaybeTagsPanel","postHasTags","siteHasTags","isPostTypeSupported","useSelect","select","postType","editorStore","getCurrentPostType","tagsTaxonomy","coreStore","getEntityRecord","_isPostTypeSupported","types","includes","areTagsFetched","undefined","tags","getEditedPostAttribute","rest_base","siteTags","getEntityRecords","per_page","length","hadTagsWhenOpeningThePanel","useState","_default","exports"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Add tags' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\" __nextHasNoMarginBottom />\n\t\t</PanelBody>\n\t);\n};\n\nconst MaybeTagsPanel = () => {\n\tconst { postHasTags, siteHasTags, isPostTypeSupported } = useSelect(\n\t\t( select ) => {\n\t\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\t\tconst tagsTaxonomy = select( coreStore ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t'post_tag'\n\t\t\t);\n\t\t\tconst _isPostTypeSupported =\n\t\t\t\ttagsTaxonomy?.types?.includes( postType );\n\t\t\tconst areTagsFetched = tagsTaxonomy !== undefined;\n\t\t\tconst tags =\n\t\t\t\ttagsTaxonomy &&\n\t\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t\t);\n\t\t\tconst siteTags = _isPostTypeSupported\n\t\t\t\t? !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'taxonomy',\n\t\t\t\t\t\t'post_tag',\n\t\t\t\t\t\t{ per_page: 1 }\n\t\t\t\t )?.length\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tpostHasTags: !! tags?.length,\n\t\t\t\tsiteHasTags: siteTags,\n\t\t\t\tisPostTypeSupported: areTagsFetched && _isPostTypeSupported,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ hadTagsWhenOpeningThePanel ] = useState( postHasTags );\n\n\t/**\n\t * We only want to show the tag panel if the post type supports\n\t * tags and the site has tags.\n\t */\n\tif ( ! isPostTypeSupported || ! siteHasTags ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.postHasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.postHasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more than one tag.\n\t */\n\tif ( ! hadTagsWhenOpe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,YAAY,GAAGJ,MAAM,CAAEK,eAAU,CAAC,CAACC,eAAe,CACvD,MAAM,EACN,UAAU,EACV,UACD,CAAC;IACD,MAAMC,oBAAoB,GACzBH,YAAY,EAAEI,KAAK,EAAEC,QAAQ,CAAER,QAAS,CAAC;IAC1C,MAAMS,cAAc,GAAGN,YAAY,KAAKO,SAAS;IACjD,MAAMC,IAAI,GACTR,YAAY,IACZJ,MAAM,CAAEE,YAAY,CAAC,CAACW,sBAAsB,CAC3CT,YAAY,CAACU,SACd,CAAC;IACF,MAAMC,QAAQ,GAAGR,oBAAoB,GAClC,CAAC,CAAEP,MAAM,CAAEK,eAAU,CAAC,CAACW,gBAAgB,CACvC,UAAU,EACV,UAAU,EACV;MAAEC,QAAQ,EAAE;IAAE,CACd,CAAC,EAAEC,MAAM,GACT,KAAK;IAER,OAAO;MACNtB,WAAW,EAAE,CAAC,CAAEgB,IAAI,EAAEM,MAAM;MAC5BrB,WAAW,EAAEkB,QAAQ;MACrBjB,mBAAmB,EAAEY,cAAc,IAAIH;IACxC,CAAC;EACF,CAAC,EACD,EACD,CAAC;EACD,MAAM,CAAEY,0BAA0B,CAAE,GAAG,IAAAC,iBAAQ,EAAExB,WAAY,CAAC;;EAE9D;AACD;AACA;AACA;EACC,IAAK,CAAEE,mBAAmB,IAAI,CAAED,WAAW,EAAG;IAC7C,OAAO,IAAI;EACZ;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,IAAK,CAAEsB,0BAA0B,EAAG;IACnC,oBAAO,IAAAtC,WAAA,CAAAI,GAAA,EAACH,SAAS,IAAE,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ,CAAC;AAAC,IAAAuC,QAAA,GAAAC,OAAA,CAAA9B,OAAA,GAEaG,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_element","_data","_components","_coreData","_flatTermSelector","_interopRequireDefault","_store","_jsxRuntime","TagsPanel","_tagLabels$add_new_it","_tagLabels$name","tagLabels","useSelect","select","taxonomy","coreStore","getTaxonomy","labels","addNewItem","add_new_item","__","tagLabel","name","panelBodyTitle","jsx","className","children","jsxs","PanelBody","initialOpen","title","sprintf","default","slug","__nextHasNoMarginBottom","MaybeTagsPanel","postHasTags","siteHasTags","isPostTypeSupported","postType","editorStore","getCurrentPostType","tagsTaxonomy","getEntityRecord","_isPostTypeSupported","types","includes","areTagsFetched","undefined","tags","getEditedPostAttribute","rest_base","siteTags","getEntityRecords","per_page","length","hadTagsWhenOpeningThePanel","useState","_default","exports"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst tagLabels = useSelect( ( select ) => {\n\t\tconst taxonomy = select( coreStore ).getTaxonomy( 'post_tag' );\n\t\treturn taxonomy?.labels;\n\t}, [] );\n\n\tconst addNewItem = tagLabels?.add_new_item ?? __( 'Add tag' );\n\tconst tagLabel = tagLabels?.name ?? __( 'Tags' );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ addNewItem }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s is the taxonomy name (e.g., \"Tags\").\n\t\t\t\t\t__(\n\t\t\t\t\t\t'%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t\t),\n\t\t\t\t\ttagLabel\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\" __nextHasNoMarginBottom />\n\t\t</PanelBody>\n\t);\n};\n\nconst MaybeTagsPanel = () => {\n\tconst { postHasTags, siteHasTags, isPostTypeSupported } = useSelect(\n\t\t( select ) => {\n\t\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\t\tconst tagsTaxonomy = select( coreStore ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t'post_tag'\n\t\t\t);\n\t\t\tconst _isPostTypeSupported =\n\t\t\t\ttagsTaxonomy?.types?.includes( postType );\n\t\t\tconst areTagsFetched = tagsTaxonomy !== undefined;\n\t\t\tconst tags =\n\t\t\t\ttagsTaxonomy &&\n\t\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t\t);\n\t\t\tconst siteTags = _isPostTypeSupported\n\t\t\t\t? !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'taxonomy',\n\t\t\t\t\t\t'post_tag',\n\t\t\t\t\t\t{ per_page: 1 }\n\t\t\t\t )?.length\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tpostHasTags: !! tags?.length,\n\t\t\t\tsiteHasTags: siteTags,\n\t\t\t\tisPostTypeSupported: areTagsFetched && _isPostTypeSupported,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ hadTagsWhenOpeningThePanel ] = useState( postHasTags );\n\n\t/**\n\t * We only want to show the tag panel if the post type supports\n\t * tags and the site has tags.\n\t */\n\tif ( ! isPostTypeSupported || ! siteHasTags ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.postHasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.postHasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more than one tag.\n\t */\n\tif ( ! hadTagsWhenOpeningThePanel ) {\n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GAAG,IAAAC,iBAAQ,EAAErB,WAAY,CAAC;;EAE9D;AACD;AACA;AACA;EACC,IAAK,CAAEE,mBAAmB,IAAI,CAAED,WAAW,EAAG;IAC7C,OAAO,IAAI;EACZ;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,IAAK,CAAEmB,0BAA0B,EAAG;IACnC,oBAAO,IAAAjD,WAAA,CAAAiB,GAAA,EAAChB,SAAS,IAAE,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ,CAAC;AAAC,IAAAkD,QAAA,GAAAC,OAAA,CAAA3B,OAAA,GAEaG,cAAc","ignoreList":[]}
@@ -2,9 +2,29 @@
2
2
 
3
3
  var _hooks = require("@wordpress/hooks");
4
4
  var _mediaUtils = require("@wordpress/media-utils");
5
+ var _coreData = require("@wordpress/core-data");
6
+ var _data = require("@wordpress/data");
7
+ var _jsxRuntime = require("react/jsx-runtime");
5
8
  /**
6
9
  * WordPress dependencies
7
10
  */
8
11
 
9
- (0, _hooks.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => _mediaUtils.MediaUpload);
12
+ function MediaUploadWithCacheInvalidation(props) {
13
+ const {
14
+ invalidateResolutionForStoreSelector
15
+ } = (0, _data.useDispatch)(_coreData.store);
16
+ const {
17
+ onClose: originalOnClose,
18
+ ...rest
19
+ } = props;
20
+ const onClose = (...onCloseArgs) => {
21
+ invalidateResolutionForStoreSelector('getMediaItems');
22
+ originalOnClose?.(...onCloseArgs);
23
+ };
24
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_mediaUtils.MediaUpload, {
25
+ onClose: onClose,
26
+ ...rest
27
+ });
28
+ }
29
+ (0, _hooks.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => MediaUploadWithCacheInvalidation);
10
30
  //# sourceMappingURL=media-upload.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_hooks","require","_mediaUtils","addFilter","MediaUpload"],"sources":["@wordpress/editor/src/hooks/media-upload.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/editor/components/media-upload',\n\t() => MediaUpload\n);\n"],"mappings":";;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,IAAAE,gBAAS,EACR,oBAAoB,EACpB,qCAAqC,EACrC,MAAMC,uBACP,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_hooks","require","_mediaUtils","_coreData","_data","_jsxRuntime","MediaUploadWithCacheInvalidation","props","invalidateResolutionForStoreSelector","useDispatch","coreStore","onClose","originalOnClose","rest","onCloseArgs","jsx","MediaUpload","addFilter"],"sources":["@wordpress/editor/src/hooks/media-upload.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\n\nfunction MediaUploadWithCacheInvalidation( props ) {\n\tconst { invalidateResolutionForStoreSelector } = useDispatch( coreStore );\n\tconst { onClose: originalOnClose, ...rest } = props;\n\n\tconst onClose = ( ...onCloseArgs ) => {\n\t\tinvalidateResolutionForStoreSelector( 'getMediaItems' );\n\t\toriginalOnClose?.( ...onCloseArgs );\n\t};\n\treturn <MediaUpload onClose={ onClose } { ...rest } />;\n}\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/editor/components/media-upload',\n\t() => MediaUploadWithCacheInvalidation\n);\n"],"mappings":";;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAN9C;AACA;AACA;;AAMA,SAASK,gCAAgCA,CAAEC,KAAK,EAAG;EAClD,MAAM;IAAEC;EAAqC,CAAC,GAAG,IAAAC,iBAAW,EAAEC,eAAU,CAAC;EACzE,MAAM;IAAEC,OAAO,EAAEC,eAAe;IAAE,GAAGC;EAAK,CAAC,GAAGN,KAAK;EAEnD,MAAMI,OAAO,GAAGA,CAAE,GAAGG,WAAW,KAAM;IACrCN,oCAAoC,CAAE,eAAgB,CAAC;IACvDI,eAAe,GAAI,GAAGE,WAAY,CAAC;EACpC,CAAC;EACD,oBAAO,IAAAT,WAAA,CAAAU,GAAA,EAACb,WAAA,CAAAc,WAAW;IAACL,OAAO,EAAGA,OAAS;IAAA,GAAME;EAAI,CAAI,CAAC;AACvD;AAEA,IAAAI,gBAAS,EACR,oBAAoB,EACpB,qCAAqC,EACrC,MAAMX,gCACP,CAAC","ignoreList":[]}
@@ -968,6 +968,26 @@ function isPostLocked(state) {
968
968
  *
969
969
  * @param {Object} state Global application state.
970
970
  *
971
+ * @example
972
+ * ```jsx
973
+ * import { __ } from '@wordpress/i18n';
974
+ * import { store as editorStore } from '@wordpress/editor';
975
+ * import { useSelect } from '@wordpress/data';
976
+ *
977
+ * const ExampleComponent = () => {
978
+ * const isSavingLocked = useSelect(
979
+ * ( select ) => select( editorStore ).isPostSavingLocked(),
980
+ * []
981
+ * );
982
+ *
983
+ * return isSavingLocked ? (
984
+ * <p>{ __( 'Post saving is locked' ) }</p>
985
+ * ) : (
986
+ * <p>{ __( 'Post saving is not locked' ) }</p>
987
+ * );
988
+ * };
989
+ * ```
990
+ *
971
991
  * @return {boolean} Is locked.
972
992
  */
973
993
  function isPostSavingLocked(state) {