@wordpress/editor 12.17.1-next.4d3b314fd5.0 → 12.19.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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 12.19.0 (2022-10-19)
6
+
7
+ ## 12.18.0 (2022-10-05)
8
+
5
9
  ## 12.17.0 (2022-09-21)
6
10
 
7
11
  ## 12.16.0 (2022-09-13)
@@ -62,7 +62,8 @@ function MostUsedTerms(_ref) {
62
62
  const label = (0, _lodash.get)(taxonomy, ['labels', 'most_used']);
63
63
  return (0, _element.createElement)("div", {
64
64
  className: "editor-post-taxonomies__flat-term-most-used"
65
- }, (0, _element.createElement)("h3", {
65
+ }, (0, _element.createElement)(_components.BaseControl.VisualLabel, {
66
+ as: "h3",
66
67
  className: "editor-post-taxonomies__flat-term-most-used-label"
67
68
  }, label), (0, _element.createElement)("ul", {
68
69
  role: "list",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"names":["MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","coreStore","getEntityRecords","slug","length","terms","label","map","term","id","name"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,UAAU,EAAE,IAJS;AAKrBC,EAAAA,OAAO,EAAE,eALY;AAMrBC,EAAAA,OAAO,EAAE;AANY,CAAtB;;AASe,SAASC,aAAT,OAAiD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AAC/D,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAwB,qBAAaC,MAAF,IAAc;AACtD,UAAMC,aAAa,GAAGD,MAAM,CAAEE,eAAF,CAAN,CAAoBC,gBAApB,CACrB,UADqB,EAErBN,QAAQ,CAACO,IAFY,EAGrBhB,aAHqB,CAAtB;AAKA,WAAO;AACNU,MAAAA,MAAM,EAAEG,aADF;AAENF,MAAAA,SAAS,EAAE,CAAAE,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAEI,MAAf,KAAyBlB;AAF9B,KAAP;AAIA,GAV6B,EAU3B,EAV2B,CAA9B;;AAYA,MAAK,CAAEY,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMO,KAAK,GAAG,2BAAeR,MAAf,CAAd;AACA,QAAMS,KAAK,GAAG,iBAAKV,QAAL,EAAe,CAAE,QAAF,EAAY,WAAZ,CAAf,CAAd;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGU,KADH,CADD,EASC;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,KAAK,CAACE,GAAN,CAAaC,IAAF,IACZ;AAAI,IAAA,GAAG,EAAGA,IAAI,CAACC;AAAf,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMd,QAAQ,CAAEa,IAAF;AAFzB,KAIGA,IAAI,CAACE,IAJR,CADD,CADC,CAJH,CATD,CADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect( ( select ) => {\n\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\ttaxonomy.slug,\n\t\t\tDEFAULT_QUERY\n\t\t);\n\t\treturn {\n\t\t\t_terms: mostUsedTerms,\n\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t};\n\t}, [] );\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\tconst label = get( taxonomy, [ 'labels', 'most_used' ] );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<h3 className=\"editor-post-taxonomies__flat-term-most-used-label\">\n\t\t\t\t{ label }\n\t\t\t</h3>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"names":["MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","coreStore","getEntityRecords","slug","length","terms","label","map","term","id","name"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,UAAU,EAAE,IAJS;AAKrBC,EAAAA,OAAO,EAAE,eALY;AAMrBC,EAAAA,OAAO,EAAE;AANY,CAAtB;;AASe,SAASC,aAAT,OAAiD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AAC/D,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAwB,qBAAaC,MAAF,IAAc;AACtD,UAAMC,aAAa,GAAGD,MAAM,CAAEE,eAAF,CAAN,CAAoBC,gBAApB,CACrB,UADqB,EAErBN,QAAQ,CAACO,IAFY,EAGrBhB,aAHqB,CAAtB;AAKA,WAAO;AACNU,MAAAA,MAAM,EAAEG,aADF;AAENF,MAAAA,SAAS,EAAE,CAAAE,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAEI,MAAf,KAAyBlB;AAF9B,KAAP;AAIA,GAV6B,EAU3B,EAV2B,CAA9B;;AAYA,MAAK,CAAEY,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMO,KAAK,GAAG,2BAAeR,MAAf,CAAd;AACA,QAAMS,KAAK,GAAG,iBAAKV,QAAL,EAAe,CAAE,QAAF,EAAY,WAAZ,CAAf,CAAd;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,uBAAD,CAAa,WAAb;AACC,IAAA,EAAE,EAAC,IADJ;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGU,KAJH,CADD,EAYC;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,KAAK,CAACE,GAAN,CAAaC,IAAF,IACZ;AAAI,IAAA,GAAG,EAAGA,IAAI,CAACC;AAAf,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMd,QAAQ,CAAEa,IAAF;AAFzB,KAIGA,IAAI,CAACE,IAJR,CADD,CADC,CAJH,CAZD,CADD;AA+BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { BaseControl, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect( ( select ) => {\n\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\ttaxonomy.slug,\n\t\t\tDEFAULT_QUERY\n\t\t);\n\t\treturn {\n\t\t\t_terms: mostUsedTerms,\n\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t};\n\t}, [] );\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\tconst label = get( taxonomy, [ 'labels', 'most_used' ] );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<BaseControl.VisualLabel\n\t\t\t\tas=\"h3\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-label\"\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"]}
@@ -118,7 +118,7 @@ function useBlockEditorSettings(settings, hasTemplate) {
118
118
  return saveEntityRecord('postType', 'page', options);
119
119
  };
120
120
 
121
- return (0, _element.useMemo)(() => ({ ...(0, _lodash.pick)(settings, ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'canLockBlocks', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasReducedUI', 'hasInlineToolbar', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableResolvedAssets']),
121
+ return (0, _element.useMemo)(() => ({ ...(0, _lodash.pick)(settings, ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'canLockBlocks', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'isDistractionFree', 'hasInlineToolbar', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableResolvedAssets']),
122
122
  mediaUpload: hasUploadPermissions ? _utils.mediaUpload : undefined,
123
123
  __experimentalReusableBlocks: reusableBlocks,
124
124
  __experimentalBlockPatterns: blockPatterns,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","postType","select","canUserUseUnfilteredHTML","getCurrentPostType","editorStore","isWeb","Platform","OS","canUser","getEntityRecord","coreStore","siteSettings","undefined","getEntityRecords","per_page","page_on_front","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","mediaUpload","__experimentalReusableBlocks","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAT,CAAiCC,QAAjC,EAA2CC,WAA3C,EAAyD;AAAA;;AACxD,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,oBAHK;AAILC,IAAAA,kBAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOF,qBAAaC,MAAF,IAAc;AAAA;;AAC5B,UAAM;AAAEC,MAAAA,wBAAF;AAA4BC,MAAAA;AAA5B,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAMC,KAAK,GAAGC,kBAASC,EAAT,KAAgB,KAA9B;AACA,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,QAA+BR,MAAM,CAAES,eAAF,CAA3C;AAEA,UAAMC,YAAY,GAAGH,OAAO,CAAE,MAAF,EAAU,UAAV,CAAP,GAClBC,eAAe,CAAE,MAAF,EAAU,MAAV,CADG,GAElBG,SAFH;AAIA,WAAO;AACNf,MAAAA,oBAAoB,EAAEK,wBAAwB,EADxC;AAENP,MAAAA,cAAc,EAAEU,KA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D,EAECG,oBAFD,EAGCD,cAHD,EAIC+B,aAJD,EAKCY,sBALD,EAMCzC,oBAND,EAOC0C,IAPD,EAQC7C,WARD,EASCI,kBATD,EAUCC,WAVD,CA7DM,CAAP;AA0EA;;eAEcP,sB","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: [], // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...pick( settings, [\n\t\t\t\t'__experimentalBlockDirectory',\n\t\t\t\t'__experimentalDiscussionSettings',\n\t\t\t\t'__experimentalFeatures',\n\t\t\t\t'__experimentalPreferredStyleVariations',\n\t\t\t\t'__experimentalSetIsInserterOpened',\n\t\t\t\t'__unstableGalleryWithImageBlocks',\n\t\t\t\t'alignWide',\n\t\t\t\t'allowedBlockTypes',\n\t\t\t\t'bodyPlaceholder',\n\t\t\t\t'canLockBlocks',\n\t\t\t\t'codeEditingEnabled',\n\t\t\t\t'colors',\n\t\t\t\t'disableCustomColors',\n\t\t\t\t'disableCustomFontSizes',\n\t\t\t\t'disableCustomSpacingSizes',\n\t\t\t\t'disableCustomGradients',\n\t\t\t\t'disableLayoutStyles',\n\t\t\t\t'enableCustomLineHeight',\n\t\t\t\t'enableCustomSpacing',\n\t\t\t\t'enableCustomUnits',\n\t\t\t\t'focusMode',\n\t\t\t\t'fontSizes',\n\t\t\t\t'gradients',\n\t\t\t\t'generateAnchors',\n\t\t\t\t'hasFixedToolbar',\n\t\t\t\t'hasReducedUI',\n\t\t\t\t'hasInlineToolbar',\n\t\t\t\t'imageDefaultSize',\n\t\t\t\t'imageDimensions',\n\t\t\t\t'imageEditing',\n\t\t\t\t'imageSizes',\n\t\t\t\t'isRTL',\n\t\t\t\t'keepCaretInsideBlock',\n\t\t\t\t'maxWidth',\n\t\t\t\t'onUpdateDefaultBlockStyles',\n\t\t\t\t'styles',\n\t\t\t\t'template',\n\t\t\t\t'templateLock',\n\t\t\t\t'titlePlaceholder',\n\t\t\t\t'supportsLayout',\n\t\t\t\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t\t\t\t'__unstableResolvedAssets',\n\t\t\t] ),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","postType","select","canUserUseUnfilteredHTML","getCurrentPostType","editorStore","isWeb","Platform","OS","canUser","getEntityRecord","coreStore","siteSettings","undefined","getEntityRecords","per_page","page_on_front","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","mediaUpload","__experimentalReusableBlocks","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAT,CAAiCC,QAAjC,EAA2CC,WAA3C,EAAyD;AAAA;;AACxD,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,oBAHK;AAILC,IAAAA,kBAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOF,qBAAaC,MAAF,IAAc;AAAA;;AAC5B,UAAM;AAAEC,MAAAA,wBAAF;AAA4BC,MAAAA;AAA5B,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAMC,KAAK,GAAGC,kBAASC,EAAT,KAAgB,KAA9B;AACA,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,QAA+BR,MAAM,CAAES,eAAF,CAA3C;AAEA,UAAMC,YAAY,GAAGH,OAAO,CAAE,MAAF,EAAU,UAAV,CAAP,GAClBC,eAAe,CAAE,MAAF,EAAU,MAAV,CADG,GAElBG,SAFH;AAIA,WAAO;A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DO;AA0DP2D,IAAAA,kCAAkC,EAAEhE;AA1D7B,GAAR,CADM,EA6DN,CACCD,QADD,EAECG,oBAFD,EAGCD,cAHD,EAIC+B,aAJD,EAKCY,sBALD,EAMCzC,oBAND,EAOC0C,IAPD,EAQC7C,WARD,EASCI,kBATD,EAUCC,WAVD,CA7DM,CAAP;AA0EA;;eAEcP,sB","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: [], // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...pick( settings, [\n\t\t\t\t'__experimentalBlockDirectory',\n\t\t\t\t'__experimentalDiscussionSettings',\n\t\t\t\t'__experimentalFeatures',\n\t\t\t\t'__experimentalPreferredStyleVariations',\n\t\t\t\t'__experimentalSetIsInserterOpened',\n\t\t\t\t'__unstableGalleryWithImageBlocks',\n\t\t\t\t'alignWide',\n\t\t\t\t'allowedBlockTypes',\n\t\t\t\t'bodyPlaceholder',\n\t\t\t\t'canLockBlocks',\n\t\t\t\t'codeEditingEnabled',\n\t\t\t\t'colors',\n\t\t\t\t'disableCustomColors',\n\t\t\t\t'disableCustomFontSizes',\n\t\t\t\t'disableCustomSpacingSizes',\n\t\t\t\t'disableCustomGradients',\n\t\t\t\t'disableLayoutStyles',\n\t\t\t\t'enableCustomLineHeight',\n\t\t\t\t'enableCustomSpacing',\n\t\t\t\t'enableCustomUnits',\n\t\t\t\t'focusMode',\n\t\t\t\t'fontSizes',\n\t\t\t\t'gradients',\n\t\t\t\t'generateAnchors',\n\t\t\t\t'hasFixedToolbar',\n\t\t\t\t'isDistractionFree',\n\t\t\t\t'hasInlineToolbar',\n\t\t\t\t'imageDefaultSize',\n\t\t\t\t'imageDimensions',\n\t\t\t\t'imageEditing',\n\t\t\t\t'imageSizes',\n\t\t\t\t'isRTL',\n\t\t\t\t'keepCaretInsideBlock',\n\t\t\t\t'maxWidth',\n\t\t\t\t'onUpdateDefaultBlockStyles',\n\t\t\t\t'styles',\n\t\t\t\t'template',\n\t\t\t\t'templateLock',\n\t\t\t\t'titlePlaceholder',\n\t\t\t\t'supportsLayout',\n\t\t\t\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t\t\t\t'__unstableResolvedAssets',\n\t\t\t] ),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
@@ -8,7 +8,7 @@ import { get } from 'lodash';
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { Button } from '@wordpress/components';
11
+ import { BaseControl, Button } from '@wordpress/components';
12
12
  import { useSelect } from '@wordpress/data';
13
13
  import { store as coreStore } from '@wordpress/core-data';
14
14
  /**
@@ -49,7 +49,8 @@ export default function MostUsedTerms(_ref) {
49
49
  const label = get(taxonomy, ['labels', 'most_used']);
50
50
  return createElement("div", {
51
51
  className: "editor-post-taxonomies__flat-term-most-used"
52
- }, createElement("h3", {
52
+ }, createElement(BaseControl.VisualLabel, {
53
+ as: "h3",
53
54
  className: "editor-post-taxonomies__flat-term-most-used-label"
54
55
  }, label), createElement("ul", {
55
56
  role: "list",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"names":["get","Button","useSelect","store","coreStore","unescapeTerms","MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","getEntityRecords","slug","length","terms","label","map","term","id","name"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,mBAA9B;AAEA,MAAMC,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,UAAU,EAAE,IAJS;AAKrBC,EAAAA,OAAO,EAAE,eALY;AAMrBC,EAAAA,OAAO,EAAE;AANY,CAAtB;AASA,eAAe,SAASC,aAAT,OAAiD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AAC/D,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAwBhB,SAAS,CAAIiB,MAAF,IAAc;AACtD,UAAMC,aAAa,GAAGD,MAAM,CAAEf,SAAF,CAAN,CAAoBiB,gBAApB,CACrB,UADqB,EAErBL,QAAQ,CAACM,IAFY,EAGrBf,aAHqB,CAAtB;AAKA,WAAO;AACNU,MAAAA,MAAM,EAAEG,aADF;AAENF,MAAAA,SAAS,EAAE,CAAAE,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAEG,MAAf,KAAyBjB;AAF9B,KAAP;AAIA,GAVsC,EAUpC,EAVoC,CAAvC;;AAYA,MAAK,CAAEY,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMM,KAAK,GAAGnB,aAAa,CAAEY,MAAF,CAA3B;AACA,QAAMQ,KAAK,GAAGzB,GAAG,CAAEgB,QAAF,EAAY,CAAE,QAAF,EAAY,WAAZ,CAAZ,CAAjB;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGS,KADH,CADD,EASC;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,KAAK,CAACE,GAAN,CAAaC,IAAF,IACZ;AAAI,IAAA,GAAG,EAAGA,IAAI,CAACC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMb,QAAQ,CAAEY,IAAF;AAFzB,KAIGA,IAAI,CAACE,IAJR,CADD,CADC,CAJH,CATD,CADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect( ( select ) => {\n\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\ttaxonomy.slug,\n\t\t\tDEFAULT_QUERY\n\t\t);\n\t\treturn {\n\t\t\t_terms: mostUsedTerms,\n\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t};\n\t}, [] );\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\tconst label = get( taxonomy, [ 'labels', 'most_used' ] );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<h3 className=\"editor-post-taxonomies__flat-term-most-used-label\">\n\t\t\t\t{ label }\n\t\t\t</h3>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"names":["get","BaseControl","Button","useSelect","store","coreStore","unescapeTerms","MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","getEntityRecords","slug","length","terms","label","map","term","id","name"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,uBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,mBAA9B;AAEA,MAAMC,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,UAAU,EAAE,IAJS;AAKrBC,EAAAA,OAAO,EAAE,eALY;AAMrBC,EAAAA,OAAO,EAAE;AANY,CAAtB;AASA,eAAe,SAASC,aAAT,OAAiD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AAC/D,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAwBhB,SAAS,CAAIiB,MAAF,IAAc;AACtD,UAAMC,aAAa,GAAGD,MAAM,CAAEf,SAAF,CAAN,CAAoBiB,gBAApB,CACrB,UADqB,EAErBL,QAAQ,CAACM,IAFY,EAGrBf,aAHqB,CAAtB;AAKA,WAAO;AACNU,MAAAA,MAAM,EAAEG,aADF;AAENF,MAAAA,SAAS,EAAE,CAAAE,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAEG,MAAf,KAAyBjB;AAF9B,KAAP;AAIA,GAVsC,EAUpC,EAVoC,CAAvC;;AAYA,MAAK,CAAEY,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMM,KAAK,GAAGnB,aAAa,CAAEY,MAAF,CAA3B;AACA,QAAMQ,KAAK,GAAG1B,GAAG,CAAEiB,QAAF,EAAY,CAAE,QAAF,EAAY,WAAZ,CAAZ,CAAjB;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,WAAD,CAAa,WAAb;AACC,IAAA,EAAE,EAAC,IADJ;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGS,KAJH,CADD,EAYC;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,KAAK,CAACE,GAAN,CAAaC,IAAF,IACZ;AAAI,IAAA,GAAG,EAAGA,IAAI,CAACC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMb,QAAQ,CAAEY,IAAF;AAFzB,KAIGA,IAAI,CAACE,IAJR,CADD,CADC,CAJH,CAZD,CADD;AA+BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { BaseControl, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect( ( select ) => {\n\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\ttaxonomy.slug,\n\t\t\tDEFAULT_QUERY\n\t\t);\n\t\treturn {\n\t\t\t_terms: mostUsedTerms,\n\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t};\n\t}, [] );\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\tconst label = get( taxonomy, [ 'labels', 'most_used' ] );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<BaseControl.VisualLabel\n\t\t\t\tas=\"h3\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-label\"\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"]}
@@ -104,7 +104,7 @@ function useBlockEditorSettings(settings, hasTemplate) {
104
104
  return saveEntityRecord('postType', 'page', options);
105
105
  };
106
106
 
107
- return useMemo(() => ({ ...pick(settings, ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'canLockBlocks', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasReducedUI', 'hasInlineToolbar', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableResolvedAssets']),
107
+ return useMemo(() => ({ ...pick(settings, ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'canLockBlocks', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'isDistractionFree', 'hasInlineToolbar', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableResolvedAssets']),
108
108
  mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
109
109
  __experimentalReusableBlocks: reusableBlocks,
110
110
  __experimentalBlockPatterns: blockPatterns,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["pick","Platform","useMemo","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","mediaUpload","editorStore","useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","postType","select","canUserUseUnfilteredHTML","getCurrentPostType","isWeb","OS","canUser","getEntityRecord","siteSettings","undefined","getEntityRecords","per_page","page_on_front","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","__experimentalReusableBlocks","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,KAAK,IAAIC,SADV,EAECC,kCAAkC,IAAIC,oBAFvC,EAGCC,0BAA0B,IAAIC,YAH/B,QAIO,sBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,SAASP,KAAK,IAAIQ,WAAlB,QAAqC,aAArC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,sBAAT,CAAiCC,QAAjC,EAA2CC,WAA3C,EAAyD;AAAA;;AACxD,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,oBAHK;AAILC,IAAAA,kBAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFlB,SAAS,CAAImB,MAAF,IAAc;AAAA;;AAC5B,UAAM;AAAEC,MA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EAAEiB,sBAhD/B;AAiDPlD,IAAAA,kCAAkC,EAAE,CAAE2D,MAAF,EAAUC,aAAV,KACnC3D,oBAAoB,CAAE0D,MAAF,EAAUC,aAAV,EAAyBpD,QAAzB,CAlDd;AAmDPqD,IAAAA,8BAA8B,EAAE1D,YAnDzB;AAoDP2D,IAAAA,sCAAsC,EAAElD,oBApDjC;AAqDPmD,IAAAA,kBAAkB,EAAEZ,IArDb;AAsDPa,IAAAA,WAAW,EAAEvD,WAtDN;AAuDPwD,IAAAA,8BAA8B,EAAEZ,gBAvDzB;AAwDPa,IAAAA,gCAAgC,EAAErD,kBAxD3B;AAyDPC,IAAAA,WAzDO;AA0DPqD,IAAAA,kCAAkC,EAAE1D;AA1D7B,GAAR,CADa,EA6Db,CACCD,QADD,EAECG,oBAFD,EAGCD,cAHD,EAIC4B,aAJD,EAKCY,sBALD,EAMCtC,oBAND,EAOCuC,IAPD,EAQC1C,WARD,EASCI,kBATD,EAUCC,WAVD,CA7Da,CAAd;AA0EA;;AAED,eAAeP,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: [], // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...pick( settings, [\n\t\t\t\t'__experimentalBlockDirectory',\n\t\t\t\t'__experimentalDiscussionSettings',\n\t\t\t\t'__experimentalFeatures',\n\t\t\t\t'__experimentalPreferredStyleVariations',\n\t\t\t\t'__experimentalSetIsInserterOpened',\n\t\t\t\t'__unstableGalleryWithImageBlocks',\n\t\t\t\t'alignWide',\n\t\t\t\t'allowedBlockTypes',\n\t\t\t\t'bodyPlaceholder',\n\t\t\t\t'canLockBlocks',\n\t\t\t\t'codeEditingEnabled',\n\t\t\t\t'colors',\n\t\t\t\t'disableCustomColors',\n\t\t\t\t'disableCustomFontSizes',\n\t\t\t\t'disableCustomSpacingSizes',\n\t\t\t\t'disableCustomGradients',\n\t\t\t\t'disableLayoutStyles',\n\t\t\t\t'enableCustomLineHeight',\n\t\t\t\t'enableCustomSpacing',\n\t\t\t\t'enableCustomUnits',\n\t\t\t\t'focusMode',\n\t\t\t\t'fontSizes',\n\t\t\t\t'gradients',\n\t\t\t\t'generateAnchors',\n\t\t\t\t'hasFixedToolbar',\n\t\t\t\t'hasReducedUI',\n\t\t\t\t'hasInlineToolbar',\n\t\t\t\t'imageDefaultSize',\n\t\t\t\t'imageDimensions',\n\t\t\t\t'imageEditing',\n\t\t\t\t'imageSizes',\n\t\t\t\t'isRTL',\n\t\t\t\t'keepCaretInsideBlock',\n\t\t\t\t'maxWidth',\n\t\t\t\t'onUpdateDefaultBlockStyles',\n\t\t\t\t'styles',\n\t\t\t\t'template',\n\t\t\t\t'templateLock',\n\t\t\t\t'titlePlaceholder',\n\t\t\t\t'supportsLayout',\n\t\t\t\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t\t\t\t'__unstableResolvedAssets',\n\t\t\t] ),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["pick","Platform","useMemo","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","mediaUpload","editorStore","useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","postType","select","canUserUseUnfilteredHTML","getCurrentPostType","isWeb","OS","canUser","getEntityRecord","siteSettings","undefined","getEntityRecords","per_page","page_on_front","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","__experimentalReusableBlocks","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,KAAK,IAAIC,S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BlB,iBAxBkB,EAyBlB,iBAzBkB,EA0BlB,mBA1BkB,EA2BlB,kBA3BkB,EA4BlB,kBA5BkB,EA6BlB,iBA7BkB,EA8BlB,cA9BkB,EA+BlB,YA/BkB,EAgClB,OAhCkB,EAiClB,sBAjCkB,EAkClB,UAlCkB,EAmClB,4BAnCkB,EAoClB,QApCkB,EAqClB,UArCkB,EAsClB,cAtCkB,EAuClB,kBAvCkB,EAwClB,gBAxCkB,EAyClB,wCAzCkB,EA0ClB,0BA1CkB,CAAZ,CADA;AA6CPH,IAAAA,WAAW,EAAEM,oBAAoB,GAAGN,WAAH,GAAiBmB,SA7C3C;AA8CPkC,IAAAA,4BAA4B,EAAEhD,cA9CvB;AA+CPoB,IAAAA,2BAA2B,EAAEQ,aA/CtB;AAgDPL,IAAAA,oCAAoC,EAAEiB,sBAhD/B;AAiDPlD,IAAAA,kCAAkC,EAAE,CAAE2D,MAAF,EAAUC,aAAV,KACnC3D,oBAAoB,CAAE0D,MAAF,EAAUC,aAAV,EAAyBpD,QAAzB,CAlDd;AAmDPqD,IAAAA,8BAA8B,EAAE1D,YAnDzB;AAoDP2D,IAAAA,sCAAsC,EAAElD,oBApDjC;AAqDPmD,IAAAA,kBAAkB,EAAEZ,IArDb;AAsDPa,IAAAA,WAAW,EAAEvD,WAtDN;AAuDPwD,IAAAA,8BAA8B,EAAEZ,gBAvDzB;AAwDPa,IAAAA,gCAAgC,EAAErD,kBAxD3B;AAyDPC,IAAAA,WAzDO;AA0DPqD,IAAAA,kCAAkC,EAAE1D;AA1D7B,GAAR,CADa,EA6Db,CACCD,QADD,EAECG,oBAFD,EAGCD,cAHD,EAIC4B,aAJD,EAKCY,sBALD,EAMCtC,oBAND,EAOCuC,IAPD,EAQC1C,WARD,EASCI,kBATD,EAUCC,WAVD,CA7Da,CAAd;AA0EA;;AAED,eAAeP,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: [], // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...pick( settings, [\n\t\t\t\t'__experimentalBlockDirectory',\n\t\t\t\t'__experimentalDiscussionSettings',\n\t\t\t\t'__experimentalFeatures',\n\t\t\t\t'__experimentalPreferredStyleVariations',\n\t\t\t\t'__experimentalSetIsInserterOpened',\n\t\t\t\t'__unstableGalleryWithImageBlocks',\n\t\t\t\t'alignWide',\n\t\t\t\t'allowedBlockTypes',\n\t\t\t\t'bodyPlaceholder',\n\t\t\t\t'canLockBlocks',\n\t\t\t\t'codeEditingEnabled',\n\t\t\t\t'colors',\n\t\t\t\t'disableCustomColors',\n\t\t\t\t'disableCustomFontSizes',\n\t\t\t\t'disableCustomSpacingSizes',\n\t\t\t\t'disableCustomGradients',\n\t\t\t\t'disableLayoutStyles',\n\t\t\t\t'enableCustomLineHeight',\n\t\t\t\t'enableCustomSpacing',\n\t\t\t\t'enableCustomUnits',\n\t\t\t\t'focusMode',\n\t\t\t\t'fontSizes',\n\t\t\t\t'gradients',\n\t\t\t\t'generateAnchors',\n\t\t\t\t'hasFixedToolbar',\n\t\t\t\t'isDistractionFree',\n\t\t\t\t'hasInlineToolbar',\n\t\t\t\t'imageDefaultSize',\n\t\t\t\t'imageDimensions',\n\t\t\t\t'imageEditing',\n\t\t\t\t'imageSizes',\n\t\t\t\t'isRTL',\n\t\t\t\t'keepCaretInsideBlock',\n\t\t\t\t'maxWidth',\n\t\t\t\t'onUpdateDefaultBlockStyles',\n\t\t\t\t'styles',\n\t\t\t\t'template',\n\t\t\t\t'templateLock',\n\t\t\t\t'titlePlaceholder',\n\t\t\t\t'supportsLayout',\n\t\t\t\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t\t\t\t'__unstableResolvedAssets',\n\t\t\t] ),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
@@ -669,8 +669,7 @@
669
669
  }
670
670
 
671
671
  .editor-post-taxonomies__flat-term-most-used .editor-post-taxonomies__flat-term-most-used-label {
672
- font-weight: 400;
673
- margin-bottom: 12px;
672
+ margin-bottom: 4px;
674
673
  }
675
674
 
676
675
  .editor-post-taxonomies__flat-term-most-used-list {
@@ -669,8 +669,7 @@
669
669
  }
670
670
 
671
671
  .editor-post-taxonomies__flat-term-most-used .editor-post-taxonomies__flat-term-most-used-label {
672
- font-weight: 400;
673
- margin-bottom: 12px;
672
+ margin-bottom: 4px;
674
673
  }
675
674
 
676
675
  .editor-post-taxonomies__flat-term-most-used-list {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "12.17.1-next.4d3b314fd5.0",
3
+ "version": "12.19.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,32 +31,32 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.18.1-next.4d3b314fd5.0",
35
- "@wordpress/api-fetch": "^6.15.1-next.4d3b314fd5.0",
36
- "@wordpress/blob": "^3.18.1-next.4d3b314fd5.0",
37
- "@wordpress/block-editor": "^10.1.1-next.4d3b314fd5.0",
38
- "@wordpress/blocks": "^11.18.1-next.4d3b314fd5.0",
39
- "@wordpress/components": "^21.1.2-next.4d3b314fd5.0",
40
- "@wordpress/compose": "^5.16.1-next.4d3b314fd5.0",
41
- "@wordpress/core-data": "^5.1.1-next.4d3b314fd5.0",
42
- "@wordpress/data": "^7.2.1-next.4d3b314fd5.0",
43
- "@wordpress/date": "^4.18.1-next.4d3b314fd5.0",
44
- "@wordpress/deprecated": "^3.18.1-next.4d3b314fd5.0",
45
- "@wordpress/element": "^4.16.1-next.4d3b314fd5.0",
46
- "@wordpress/hooks": "^3.18.1-next.4d3b314fd5.0",
47
- "@wordpress/html-entities": "^3.18.1-next.4d3b314fd5.0",
48
- "@wordpress/i18n": "^4.18.1-next.4d3b314fd5.0",
49
- "@wordpress/icons": "^9.9.1-next.4d3b314fd5.0",
50
- "@wordpress/keyboard-shortcuts": "^3.16.1-next.4d3b314fd5.0",
51
- "@wordpress/keycodes": "^3.18.1-next.4d3b314fd5.0",
52
- "@wordpress/media-utils": "^4.9.1-next.4d3b314fd5.0",
53
- "@wordpress/notices": "^3.18.1-next.4d3b314fd5.0",
54
- "@wordpress/preferences": "^2.10.1-next.4d3b314fd5.0",
55
- "@wordpress/reusable-blocks": "^3.16.1-next.4d3b314fd5.0",
56
- "@wordpress/rich-text": "^5.16.1-next.4d3b314fd5.0",
57
- "@wordpress/server-side-render": "^3.16.1-next.4d3b314fd5.0",
58
- "@wordpress/url": "^3.19.1-next.4d3b314fd5.0",
59
- "@wordpress/wordcount": "^3.18.1-next.4d3b314fd5.0",
34
+ "@wordpress/a11y": "^3.20.0",
35
+ "@wordpress/api-fetch": "^6.17.0",
36
+ "@wordpress/blob": "^3.20.0",
37
+ "@wordpress/block-editor": "^10.3.0",
38
+ "@wordpress/blocks": "^11.19.0",
39
+ "@wordpress/components": "^21.3.0",
40
+ "@wordpress/compose": "^5.18.0",
41
+ "@wordpress/core-data": "^5.3.0",
42
+ "@wordpress/data": "^7.4.0",
43
+ "@wordpress/date": "^4.20.0",
44
+ "@wordpress/deprecated": "^3.20.0",
45
+ "@wordpress/element": "^4.18.0",
46
+ "@wordpress/hooks": "^3.20.0",
47
+ "@wordpress/html-entities": "^3.20.0",
48
+ "@wordpress/i18n": "^4.20.0",
49
+ "@wordpress/icons": "^9.11.0",
50
+ "@wordpress/keyboard-shortcuts": "^3.18.0",
51
+ "@wordpress/keycodes": "^3.20.0",
52
+ "@wordpress/media-utils": "^4.11.0",
53
+ "@wordpress/notices": "^3.20.0",
54
+ "@wordpress/preferences": "^2.12.0",
55
+ "@wordpress/reusable-blocks": "^3.18.0",
56
+ "@wordpress/rich-text": "^5.18.0",
57
+ "@wordpress/server-side-render": "^3.18.0",
58
+ "@wordpress/url": "^3.21.0",
59
+ "@wordpress/wordcount": "^3.20.0",
60
60
  "classnames": "^2.3.1",
61
61
  "lodash": "^4.17.21",
62
62
  "memize": "^1.1.0",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "25054766423cb49d959eb656c2533530073ff5c2"
74
+ "gitHead": "a2ff0e6471c88436dad0287beb88d1729aa6f5dd"
75
75
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { shallow } from 'enzyme';
4
+ import { render } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -9,7 +9,6 @@ import { shallow } from 'enzyme';
9
9
  import { AutosaveMonitor } from '../';
10
10
 
11
11
  describe( 'AutosaveMonitor', () => {
12
- let wrapper;
13
12
  let setAutosaveTimerSpy;
14
13
  beforeEach( () => {
15
14
  jest.useFakeTimers( 'legacy' );
@@ -17,9 +16,6 @@ describe( 'AutosaveMonitor', () => {
17
16
  AutosaveMonitor.prototype,
18
17
  'setAutosaveTimer'
19
18
  );
20
- wrapper = shallow( <AutosaveMonitor isDirty />, {
21
- lifecycleExperimental: true,
22
- } );
23
19
  } );
24
20
 
25
21
  afterEach( () => {
@@ -29,128 +25,167 @@ describe( 'AutosaveMonitor', () => {
29
25
  setAutosaveTimerSpy.mockClear();
30
26
  } );
31
27
 
28
+ it( 'should render nothing', () => {
29
+ const { container } = render( <AutosaveMonitor isDirty /> );
30
+
31
+ expect( container ).toBeEmptyDOMElement();
32
+ } );
33
+
32
34
  it( 'should start autosave timer after being mounted', () => {
35
+ render( <AutosaveMonitor isDirty /> );
36
+
33
37
  expect( setAutosaveTimerSpy ).toHaveBeenCalled();
34
38
  } );
35
39
 
36
40
  it( 'should clear the autosave timer after being unmounted', () => {
37
- wrapper.unmount();
41
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
42
+
43
+ rerender( <div /> );
44
+
45
+ expect( clearTimeout ).toHaveBeenCalled();
46
+ } );
47
+
48
+ it( 'should clear and restart autosave timer when the interval changes', () => {
49
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
50
+
51
+ rerender( <AutosaveMonitor isDirty interval={ 999 } /> );
52
+
38
53
  expect( clearTimeout ).toHaveBeenCalled();
54
+ expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
39
55
  } );
40
56
 
41
- describe( '#componentDidUpdate()', () => {
42
- it( 'should clear and restart autosave timer when the interval changes', () => {
43
- wrapper.setProps( { interval: 999 } );
44
- expect( clearTimeout ).toHaveBeenCalled();
45
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
46
- } );
47
-
48
- it( 'should set needsAutosave=true when editReference changes', () => {
49
- expect( wrapper.instance().needsAutosave ).toBe( false );
50
- wrapper.setProps( {
51
- editsReference: [],
52
- } );
53
- expect( wrapper.instance().needsAutosave ).toBe( true );
54
- } );
55
-
56
- it( 'should set needsAutosave=true when editReference changes and the post becomes dirty', () => {
57
- expect( wrapper.instance().needsAutosave ).toBe( false );
58
- wrapper.setProps( {
59
- isDirty: true,
60
- editsReference: [],
61
- } );
62
- expect( wrapper.instance().needsAutosave ).toBe( true );
63
- } );
64
-
65
- it( 'should not set needsAutosave=true when editReference changes and the post is not dirty anymore', () => {
66
- expect( wrapper.instance().needsAutosave ).toBe( false );
67
- wrapper.setProps( {
68
- isDirty: true,
69
- editsReference: [],
70
- } );
71
- wrapper.setProps( {
72
- isDirty: false,
73
- editsReference: [],
74
- } );
75
- expect( wrapper.instance().needsAutosave ).toBe( false );
76
- } );
77
-
78
- it( 'should set needsAutosave=true when editReference changes and the post is not autosaving', () => {
79
- expect( wrapper.instance().needsAutosave ).toBe( false );
80
- wrapper.setProps( {
81
- isAutosaving: false,
82
- editsReference: [],
83
- } );
84
- expect( wrapper.instance().needsAutosave ).toBe( true );
85
- } );
86
-
87
- it( 'should not set needsAutosave=true when editReference changes and the post started autosaving', () => {
88
- expect( wrapper.instance().needsAutosave ).toBe( false );
89
- wrapper.setProps( {
90
- isAutosaving: false,
91
- editsReference: [],
92
- } );
93
- wrapper.setProps( {
94
- isAutosaving: true,
95
- editsReference: [],
96
- } );
97
- expect( wrapper.instance().needsAutosave ).toBe( false );
98
- } );
57
+ it( 'should autosave when `editReference` changes', () => {
58
+ const autosave = jest.fn();
59
+ const { rerender } = render(
60
+ <AutosaveMonitor isDirty isAutosaveable autosave={ autosave } />
61
+ );
62
+
63
+ expect( autosave ).not.toHaveBeenCalled();
64
+
65
+ rerender(
66
+ <AutosaveMonitor
67
+ isDirty
68
+ isAutosaveable
69
+ autosave={ autosave }
70
+ editsReference={ [] }
71
+ />
72
+ );
73
+
74
+ jest.runOnlyPendingTimers();
75
+
76
+ expect( autosave ).toHaveBeenCalledTimes( 1 );
99
77
  } );
100
78
 
101
- describe( '#autosaveTimerHandler()', () => {
102
- it( 'should schedule itself in another {interval} ms', () => {
103
- wrapper.setProps( {
104
- isAutosaveable: true,
105
- interval: 5,
106
- } );
107
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
108
- wrapper.instance().autosaveTimerHandler();
109
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 3 );
110
- expect( setTimeout ).lastCalledWith( expect.any( Function ), 5000 );
111
- } );
112
-
113
- it( 'should schedule itself in 1000 ms if the post is not autosaveable at a time', () => {
114
- wrapper.setProps( {
115
- isAutosaveable: false,
116
- interval: 5,
117
- } );
118
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
119
- wrapper.instance().autosaveTimerHandler();
120
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 3 );
121
- expect( setTimeout ).lastCalledWith( expect.any( Function ), 1000 );
122
- } );
123
-
124
- it( 'should call autosave if needsAutosave=true', () => {
125
- const autosave = jest.fn();
126
- wrapper.setProps( {
127
- isAutosaveable: true,
128
- interval: 5,
129
- autosave,
130
- } );
131
- wrapper.instance().needsAutosave = true;
132
- expect( autosave ).toHaveBeenCalledTimes( 0 );
133
- wrapper.instance().autosaveTimerHandler();
134
- expect( autosave ).toHaveBeenCalledTimes( 1 );
135
- } );
136
-
137
- it( 'should not call autosave if needsAutosave is not true', () => {
138
- const autosave = jest.fn();
139
- wrapper.setProps( {
140
- isAutosaveable: true,
141
- interval: 5,
142
- autosave,
143
- } );
144
- wrapper.instance().needsAutosave = false;
145
- expect( autosave ).toHaveBeenCalledTimes( 0 );
146
- wrapper.instance().autosaveTimerHandler();
147
- expect( autosave ).toHaveBeenCalledTimes( 0 );
148
- } );
79
+ it( 'should autosave when `editReference` changes and the post becomes dirty', () => {
80
+ const autosave = jest.fn();
81
+ const { rerender } = render(
82
+ <AutosaveMonitor isAutosaveable autosave={ autosave } />
83
+ );
84
+
85
+ expect( autosave ).not.toHaveBeenCalled();
86
+
87
+ rerender(
88
+ <AutosaveMonitor
89
+ isDirty
90
+ isAutosaveable
91
+ autosave={ autosave }
92
+ editsReference={ [] }
93
+ />
94
+ );
95
+
96
+ jest.runOnlyPendingTimers();
97
+
98
+ expect( autosave ).toHaveBeenCalledTimes( 1 );
149
99
  } );
150
100
 
151
- describe( '#render()', () => {
152
- it( 'should render nothing', () => {
153
- expect( wrapper.type() ).toBe( null );
154
- } );
101
+ it( 'should not autosave when `editReference` changes and the post is not dirty anymore', () => {
102
+ const autosave = jest.fn();
103
+ const { rerender } = render(
104
+ <AutosaveMonitor isDirty isAutosaveable autosave={ autosave } />
105
+ );
106
+
107
+ expect( autosave ).not.toHaveBeenCalled();
108
+
109
+ rerender(
110
+ <AutosaveMonitor
111
+ isAutosaveable
112
+ autosave={ autosave }
113
+ editsReference={ [] }
114
+ />
115
+ );
116
+
117
+ jest.runOnlyPendingTimers();
118
+
119
+ expect( autosave ).not.toHaveBeenCalled();
120
+ } );
121
+
122
+ it( 'should not autosave when `editReference` changes and the post is not autosaving', () => {
123
+ const autosave = jest.fn();
124
+ const { rerender } = render(
125
+ <AutosaveMonitor isAutosaveable autosave={ autosave } />
126
+ );
127
+
128
+ expect( autosave ).not.toHaveBeenCalled();
129
+
130
+ rerender(
131
+ <AutosaveMonitor
132
+ isAutosaveable
133
+ autosave={ autosave }
134
+ isAutosaving={ false }
135
+ editsReference={ [] }
136
+ />
137
+ );
138
+
139
+ jest.runOnlyPendingTimers();
140
+
141
+ expect( autosave ).not.toHaveBeenCalled();
142
+ } );
143
+
144
+ it( 'should not autosave when `editReference` changes and the post started autosaving', () => {
145
+ const autosave = jest.fn();
146
+ const { rerender } = render(
147
+ <AutosaveMonitor
148
+ isAutosaveable
149
+ autosave={ autosave }
150
+ isAutosaving={ false }
151
+ />
152
+ );
153
+
154
+ expect( autosave ).not.toHaveBeenCalled();
155
+
156
+ rerender(
157
+ <AutosaveMonitor
158
+ isAutosaveable
159
+ autosave={ autosave }
160
+ isAutosaving
161
+ editsReference={ [] }
162
+ />
163
+ );
164
+
165
+ jest.runOnlyPendingTimers();
166
+
167
+ expect( autosave ).not.toHaveBeenCalled();
168
+ } );
169
+
170
+ it( 'should schedule itself in another {interval} ms', () => {
171
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
172
+
173
+ rerender( <AutosaveMonitor isDirty isAutosaveable interval={ 5 } /> );
174
+
175
+ jest.runOnlyPendingTimers();
176
+
177
+ expect( setTimeout ).lastCalledWith( expect.any( Function ), 5000 );
178
+ } );
179
+
180
+ it( 'should schedule itself in 1000 ms if the post is not autosaveable at a time', () => {
181
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
182
+
183
+ rerender(
184
+ <AutosaveMonitor isDirty isAutosaveable={ false } interval={ 5 } />
185
+ );
186
+
187
+ jest.runOnlyPendingTimers();
188
+
189
+ expect( setTimeout ).lastCalledWith( expect.any( Function ), 1000 );
155
190
  } );
156
191
  } );
@@ -108,11 +108,11 @@ describe( 'DocumentOutline', () => {
108
108
  const blocks = [ headingH2 ];
109
109
  render( <DocumentOutline blocks={ blocks } /> );
110
110
 
111
- const tableOfContentItems = within(
111
+ const tableOfContentItem = within(
112
112
  screen.getByRole( 'list' )
113
- ).getAllByRole( 'listitem' );
114
- expect( tableOfContentItems ).toHaveLength( 1 );
115
- expect( tableOfContentItems[ 0 ] ).toHaveTextContent( 'Heading 2' );
113
+ ).getByRole( 'listitem' );
114
+ expect( tableOfContentItem ).toBeInTheDocument();
115
+ expect( tableOfContentItem ).toHaveTextContent( 'Heading 2' );
116
116
  } );
117
117
 
118
118
  it( 'should render two items when two headings and some paragraphs provided', () => {
@@ -111,7 +111,7 @@ describe( 'PostPreviewButton', () => {
111
111
  it( 'should not be disabled if post is saveable.', async () => {
112
112
  render( <PostPreviewButton isSaveable postId={ 123 } /> );
113
113
 
114
- expect( screen.getByRole( 'button' ) ).not.toBeDisabled();
114
+ expect( screen.getByRole( 'button' ) ).toBeEnabled();
115
115
  } );
116
116
 
117
117
  it( 'should set `href` to `previewLink` if `previewLink` is specified.', async () => {
@@ -6,7 +6,7 @@ import { get } from 'lodash';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { Button } from '@wordpress/components';
9
+ import { BaseControl, Button } from '@wordpress/components';
10
10
  import { useSelect } from '@wordpress/data';
11
11
  import { store as coreStore } from '@wordpress/core-data';
12
12
 
@@ -47,9 +47,12 @@ export default function MostUsedTerms( { onSelect, taxonomy } ) {
47
47
 
48
48
  return (
49
49
  <div className="editor-post-taxonomies__flat-term-most-used">
50
- <h3 className="editor-post-taxonomies__flat-term-most-used-label">
50
+ <BaseControl.VisualLabel
51
+ as="h3"
52
+ className="editor-post-taxonomies__flat-term-most-used-label"
53
+ >
51
54
  { label }
52
- </h3>
55
+ </BaseControl.VisualLabel>
53
56
  { /*
54
57
  * Disable reason: The `list` ARIA role is redundant but
55
58
  * Safari+VoiceOver won't announce the list otherwise.
@@ -38,8 +38,7 @@
38
38
 
39
39
  .editor-post-taxonomies__flat-term-most-used {
40
40
  .editor-post-taxonomies__flat-term-most-used-label {
41
- font-weight: 400;
42
- margin-bottom: $grid-unit-15;
41
+ margin-bottom: $grid-unit-05;
43
42
  }
44
43
  }
45
44
 
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { act, create } from 'react-test-renderer';
5
- import Textarea from 'react-autosize-textarea';
4
+ import { render, screen } from '@testing-library/react';
5
+ import userEvent from '@testing-library/user-event';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -38,6 +38,8 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
38
38
  };
39
39
  } );
40
40
 
41
+ jest.useRealTimers();
42
+
41
43
  describe( 'PostTextEditor', () => {
42
44
  beforeEach( () => {
43
45
  useSelect.mockImplementation( () => 'Hello World' );
@@ -47,132 +49,106 @@ describe( 'PostTextEditor', () => {
47
49
  } );
48
50
 
49
51
  it( 'should render via the value from useSelect', () => {
50
- let wrapper;
51
-
52
- act( () => {
53
- wrapper = create( <PostTextEditor /> );
54
- } );
52
+ render( <PostTextEditor /> );
55
53
 
56
- const textarea = wrapper.root.findByType( Textarea );
57
- expect( textarea.props.value ).toBe( 'Hello World' );
54
+ expect( screen.getByLabelText( 'Type text or HTML' ) ).toHaveValue(
55
+ 'Hello World'
56
+ );
58
57
  } );
59
58
 
60
- it( 'should render via the state value when edits made', () => {
61
- let wrapper;
59
+ it( 'should render via the state value when edits made', async () => {
60
+ const user = userEvent.setup();
61
+ render( <PostTextEditor /> );
62
62
 
63
- act( () => {
64
- wrapper = create( <PostTextEditor /> );
65
- } );
63
+ const textarea = screen.getByLabelText( 'Type text or HTML' );
66
64
 
67
- const textarea = wrapper.root.findByType( Textarea );
65
+ await user.clear( textarea );
66
+ await user.type( textarea, 'Hello Chicken' );
68
67
 
69
- act( () =>
70
- textarea.props.onChange( { target: { value: 'Hello Chicken' } } )
71
- );
72
-
73
- expect( textarea.props.value ).toBe( 'Hello Chicken' );
68
+ expect( textarea ).toHaveValue( 'Hello Chicken' );
74
69
  expect( mockEditPost ).toHaveBeenCalledWith( {
75
70
  content: 'Hello Chicken',
76
71
  } );
77
72
  } );
78
73
 
79
- it( 'should render via the state value when edits made, even if prop value changes', () => {
80
- let wrapper;
81
-
82
- act( () => {
83
- wrapper = create( <PostTextEditor /> );
84
- } );
74
+ it( 'should render via the state value when edits made, even if prop value changes', async () => {
75
+ const user = userEvent.setup();
76
+ const { rerender } = render( <PostTextEditor /> );
85
77
 
86
- const textarea = wrapper.root.findByType( Textarea );
78
+ const textarea = screen.getByLabelText( 'Type text or HTML' );
87
79
 
88
- act( () =>
89
- textarea.props.onChange( { target: { value: 'Hello Chicken' } } )
90
- );
80
+ await user.clear( textarea );
81
+ await user.type( textarea, 'Hello Chicken' );
91
82
 
92
83
  useSelect.mockImplementation( () => 'Goodbye World' );
93
84
 
94
- act( () => {
95
- wrapper.update( <PostTextEditor /> );
96
- } );
85
+ rerender( <PostTextEditor /> );
97
86
 
98
- expect( textarea.props.value ).toBe( 'Hello Chicken' );
87
+ expect( textarea ).toHaveValue( 'Hello Chicken' );
99
88
  expect( mockEditPost ).toHaveBeenCalledWith( {
100
89
  content: 'Hello Chicken',
101
90
  } );
102
91
  } );
103
92
 
104
- it( 'should render via the state value when edits made, even if prop value changes and state value empty', () => {
105
- let wrapper;
93
+ it( 'should render via the state value when edits made, even if prop value changes and state value empty', async () => {
94
+ const user = userEvent.setup();
95
+ const { rerender } = render( <PostTextEditor /> );
106
96
 
107
- act( () => {
108
- wrapper = create( <PostTextEditor /> );
109
- } );
97
+ const textarea = screen.getByLabelText( 'Type text or HTML' );
110
98
 
111
- const textarea = wrapper.root.findByType( Textarea );
112
- act( () => textarea.props.onChange( { target: { value: '' } } ) );
99
+ await user.clear( textarea );
113
100
 
114
101
  useSelect.mockImplementation( () => 'Goodbye World' );
115
102
 
116
- act( () => {
117
- wrapper.update( <PostTextEditor /> );
118
- } );
103
+ rerender( <PostTextEditor /> );
119
104
 
120
- expect( textarea.props.value ).toBe( '' );
105
+ expect( textarea ).toHaveValue( '' );
121
106
  expect( mockEditPost ).toHaveBeenCalledWith( {
122
107
  content: '',
123
108
  } );
124
109
  } );
125
110
 
126
- it( 'calls onPersist after changes made and user stops editing', () => {
127
- let wrapper;
111
+ it( 'calls onPersist after changes made and user stops editing', async () => {
112
+ const user = userEvent.setup();
113
+ render( <PostTextEditor /> );
128
114
 
129
- act( () => {
130
- wrapper = create( <PostTextEditor /> );
131
- } );
115
+ const textarea = screen.getByLabelText( 'Type text or HTML' );
132
116
 
133
- const textarea = wrapper.root.findByType( Textarea );
117
+ await user.clear( textarea );
134
118
 
135
- act( () => textarea.props.onChange( { target: { value: '' } } ) );
136
- act( () => textarea.props.onBlur() );
119
+ // Stop editing.
120
+ textarea.blur();
137
121
 
138
122
  expect( mockResetEditorBlocks ).toHaveBeenCalledWith( [] );
139
123
  } );
140
124
 
141
125
  it( 'does not call onPersist after user stops editing without changes', () => {
142
- let wrapper;
126
+ render( <PostTextEditor /> );
143
127
 
144
- act( () => {
145
- wrapper = create( <PostTextEditor /> );
146
- } );
147
-
148
- const textarea = wrapper.root.findByType( Textarea );
149
- act( () => textarea.props.onBlur() );
128
+ // Stop editing.
129
+ screen.getByLabelText( 'Type text or HTML' ).blur();
150
130
 
151
131
  expect( mockResetEditorBlocks ).not.toHaveBeenCalled();
152
132
  } );
153
133
 
154
- it( 'resets to prop value after user stops editing', () => {
134
+ it( 'resets to prop value after user stops editing', async () => {
155
135
  // This isn't the most realistic case, since typically we'd assume the
156
136
  // parent renderer to pass the value as it had received onPersist. The
157
137
  // test here is more an edge case to stress that it's intentionally
158
138
  // differentiating between state and prop values.
159
- let wrapper;
139
+ const user = userEvent.setup();
140
+ const { rerender } = render( <PostTextEditor /> );
160
141
 
161
- act( () => {
162
- wrapper = create( <PostTextEditor /> );
163
- } );
142
+ const textarea = screen.getByLabelText( 'Type text or HTML' );
164
143
 
165
- const textarea = wrapper.root.findByType( Textarea );
166
- act( () => textarea.props.onChange( { target: { value: '' } } ) );
144
+ await user.clear( textarea );
167
145
 
168
146
  useSelect.mockImplementation( () => 'Goodbye World' );
169
147
 
170
- act( () => {
171
- wrapper.update( <PostTextEditor /> );
172
- } );
148
+ rerender( <PostTextEditor /> );
173
149
 
174
- act( () => textarea.props.onBlur() );
150
+ textarea.blur();
175
151
 
176
- expect( textarea.props.value ).toBe( 'Goodbye World' );
152
+ expect( textarea ).toHaveValue( 'Goodbye World' );
177
153
  } );
178
154
  } );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { create } from 'react-test-renderer';
4
+ import { render } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -10,27 +10,26 @@ import { PostTypeSupportCheck } from '../';
10
10
 
11
11
  describe( 'PostTypeSupportCheck', () => {
12
12
  it( 'renders its children when post type is not known', () => {
13
- let postType;
14
- const tree = create(
15
- <PostTypeSupportCheck postType={ postType } supportKeys="title">
13
+ const { container } = render(
14
+ <PostTypeSupportCheck postType={ undefined } supportKeys="title">
16
15
  Supported
17
16
  </PostTypeSupportCheck>
18
17
  );
19
18
 
20
- expect( tree.toJSON() ).toBe( 'Supported' );
19
+ expect( container ).toHaveTextContent( 'Supported' );
21
20
  } );
22
21
 
23
22
  it( 'does not render its children when post type is known and not supports', () => {
24
23
  const postType = {
25
24
  supports: {},
26
25
  };
27
- const tree = create(
26
+ const { container } = render(
28
27
  <PostTypeSupportCheck postType={ postType } supportKeys="title">
29
28
  Supported
30
29
  </PostTypeSupportCheck>
31
30
  );
32
31
 
33
- expect( tree.toJSON() ).toBe( null );
32
+ expect( container ).not.toHaveTextContent( 'Supported' );
34
33
  } );
35
34
 
36
35
  it( 'renders its children when post type is known and supports', () => {
@@ -39,13 +38,13 @@ describe( 'PostTypeSupportCheck', () => {
39
38
  title: true,
40
39
  },
41
40
  };
42
- const tree = create(
41
+ const { container } = render(
43
42
  <PostTypeSupportCheck postType={ postType } supportKeys="title">
44
43
  Supported
45
44
  </PostTypeSupportCheck>
46
45
  );
47
46
 
48
- expect( tree.toJSON() ).toBe( 'Supported' );
47
+ expect( container ).toHaveTextContent( 'Supported' );
49
48
  } );
50
49
 
51
50
  it( 'renders its children if some of keys supported', () => {
@@ -54,7 +53,7 @@ describe( 'PostTypeSupportCheck', () => {
54
53
  title: true,
55
54
  },
56
55
  };
57
- const tree = create(
56
+ const { container } = render(
58
57
  <PostTypeSupportCheck
59
58
  postType={ postType }
60
59
  supportKeys={ [ 'title', 'thumbnail' ] }
@@ -63,14 +62,14 @@ describe( 'PostTypeSupportCheck', () => {
63
62
  </PostTypeSupportCheck>
64
63
  );
65
64
 
66
- expect( tree.toJSON() ).toBe( 'Supported' );
65
+ expect( container ).toHaveTextContent( 'Supported' );
67
66
  } );
68
67
 
69
68
  it( 'does not render its children if none of keys supported', () => {
70
69
  const postType = {
71
70
  supports: {},
72
71
  };
73
- const tree = create(
72
+ const { container } = render(
74
73
  <PostTypeSupportCheck
75
74
  postType={ postType }
76
75
  supportKeys={ [ 'title', 'thumbnail' ] }
@@ -79,6 +78,6 @@ describe( 'PostTypeSupportCheck', () => {
79
78
  </PostTypeSupportCheck>
80
79
  );
81
80
 
82
- expect( tree.toJSON() ).toBe( null );
81
+ expect( container ).not.toHaveTextContent( 'Supported' );
83
82
  } );
84
83
  } );
@@ -159,7 +159,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
159
159
  'gradients',
160
160
  'generateAnchors',
161
161
  'hasFixedToolbar',
162
- 'hasReducedUI',
162
+ 'isDistractionFree',
163
163
  'hasInlineToolbar',
164
164
  'imageDefaultSize',
165
165
  'imageDimensions',