@wordpress/editor 13.3.6 → 13.5.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 (127) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/document-outline/index.js +7 -1
  3. package/build/components/document-outline/index.js.map +1 -1
  4. package/build/components/page-attributes/check.js +6 -10
  5. package/build/components/page-attributes/check.js.map +1 -1
  6. package/build/components/page-attributes/order.js +3 -5
  7. package/build/components/page-attributes/order.js.map +1 -1
  8. package/build/components/page-attributes/parent.js +9 -6
  9. package/build/components/page-attributes/parent.js.map +1 -1
  10. package/build/components/post-author/check.js +3 -7
  11. package/build/components/post-author/check.js.map +1 -1
  12. package/build/components/post-featured-image/index.js +7 -12
  13. package/build/components/post-featured-image/index.js.map +1 -1
  14. package/build/components/post-locked-modal/index.js +1 -7
  15. package/build/components/post-locked-modal/index.js.map +1 -1
  16. package/build/components/post-pending-status/check.js +3 -7
  17. package/build/components/post-pending-status/check.js.map +1 -1
  18. package/build/components/post-preview-button/index.js +3 -3
  19. package/build/components/post-preview-button/index.js.map +1 -1
  20. package/build/components/post-publish-button/index.js +4 -4
  21. package/build/components/post-publish-button/index.js.map +1 -1
  22. package/build/components/post-publish-button/label.js +3 -7
  23. package/build/components/post-publish-button/label.js.map +1 -1
  24. package/build/components/post-publish-panel/index.js +4 -8
  25. package/build/components/post-publish-panel/index.js.map +1 -1
  26. package/build/components/post-publish-panel/maybe-post-format-panel.js +3 -7
  27. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  28. package/build/components/post-publish-panel/postpublish.js +5 -9
  29. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  30. package/build/components/post-publish-panel/prepublish.js +3 -7
  31. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  32. package/build/components/post-schedule/check.js +3 -7
  33. package/build/components/post-schedule/check.js.map +1 -1
  34. package/build/components/post-sticky/check.js +3 -7
  35. package/build/components/post-sticky/check.js.map +1 -1
  36. package/build/components/post-taxonomies/flat-term-selector.js +12 -9
  37. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  38. package/build/components/post-taxonomies/hierarchical-term-selector.js +18 -12
  39. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  40. package/build/components/post-taxonomies/most-used-terms.js +2 -9
  41. package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
  42. package/build/components/post-title/index.native.js +1 -0
  43. package/build/components/post-title/index.native.js.map +1 -1
  44. package/build/components/post-visibility/check.js +3 -7
  45. package/build/components/post-visibility/check.js.map +1 -1
  46. package/build/components/theme-support-check/index.js +3 -7
  47. package/build/components/theme-support-check/index.js.map +1 -1
  48. package/build/store/utils/notice-builder.js +4 -8
  49. package/build/store/utils/notice-builder.js.map +1 -1
  50. package/build-module/components/document-outline/index.js +8 -2
  51. package/build-module/components/document-outline/index.js.map +1 -1
  52. package/build-module/components/page-attributes/check.js +6 -9
  53. package/build-module/components/page-attributes/check.js.map +1 -1
  54. package/build-module/components/page-attributes/order.js +4 -6
  55. package/build-module/components/page-attributes/order.js.map +1 -1
  56. package/build-module/components/page-attributes/parent.js +9 -5
  57. package/build-module/components/page-attributes/parent.js.map +1 -1
  58. package/build-module/components/post-author/check.js +3 -6
  59. package/build-module/components/post-author/check.js.map +1 -1
  60. package/build-module/components/post-featured-image/index.js +7 -11
  61. package/build-module/components/post-featured-image/index.js.map +1 -1
  62. package/build-module/components/post-locked-modal/index.js +1 -6
  63. package/build-module/components/post-locked-modal/index.js.map +1 -1
  64. package/build-module/components/post-pending-status/check.js +3 -6
  65. package/build-module/components/post-pending-status/check.js.map +1 -1
  66. package/build-module/components/post-preview-button/index.js +3 -2
  67. package/build-module/components/post-preview-button/index.js.map +1 -1
  68. package/build-module/components/post-publish-button/index.js +4 -3
  69. package/build-module/components/post-publish-button/index.js.map +1 -1
  70. package/build-module/components/post-publish-button/label.js +3 -6
  71. package/build-module/components/post-publish-button/label.js.map +1 -1
  72. package/build-module/components/post-publish-panel/index.js +4 -7
  73. package/build-module/components/post-publish-panel/index.js.map +1 -1
  74. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +3 -6
  75. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  76. package/build-module/components/post-publish-panel/postpublish.js +5 -8
  77. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  78. package/build-module/components/post-publish-panel/prepublish.js +3 -6
  79. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  80. package/build-module/components/post-schedule/check.js +3 -6
  81. package/build-module/components/post-schedule/check.js.map +1 -1
  82. package/build-module/components/post-sticky/check.js +3 -6
  83. package/build-module/components/post-sticky/check.js.map +1 -1
  84. package/build-module/components/post-taxonomies/flat-term-selector.js +12 -8
  85. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  86. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +18 -11
  87. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  88. package/build-module/components/post-taxonomies/most-used-terms.js +2 -8
  89. package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
  90. package/build-module/components/post-title/index.native.js +1 -0
  91. package/build-module/components/post-title/index.native.js.map +1 -1
  92. package/build-module/components/post-visibility/check.js +3 -6
  93. package/build-module/components/post-visibility/check.js.map +1 -1
  94. package/build-module/components/theme-support-check/index.js +3 -6
  95. package/build-module/components/theme-support-check/index.js.map +1 -1
  96. package/build-module/store/utils/notice-builder.js +4 -7
  97. package/build-module/store/utils/notice-builder.js.map +1 -1
  98. package/build-style/style-rtl.css +1 -13
  99. package/build-style/style.css +1 -13
  100. package/package.json +30 -30
  101. package/src/components/document-outline/index.js +6 -3
  102. package/src/components/page-attributes/check.js +3 -12
  103. package/src/components/page-attributes/order.js +18 -12
  104. package/src/components/page-attributes/parent.js +41 -41
  105. package/src/components/post-author/check.js +2 -10
  106. package/src/components/post-featured-image/index.js +5 -10
  107. package/src/components/post-locked-modal/index.js +1 -6
  108. package/src/components/post-pending-status/check.js +2 -10
  109. package/src/components/post-preview-button/index.js +1 -2
  110. package/src/components/post-publish-button/index.js +3 -7
  111. package/src/components/post-publish-button/label.js +2 -10
  112. package/src/components/post-publish-panel/index.js +3 -11
  113. package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -10
  114. package/src/components/post-publish-panel/postpublish.js +3 -8
  115. package/src/components/post-publish-panel/prepublish.js +2 -10
  116. package/src/components/post-publish-panel/style.scss +1 -1
  117. package/src/components/post-schedule/check.js +2 -10
  118. package/src/components/post-sticky/check.js +1 -10
  119. package/src/components/post-taxonomies/flat-term-selector.js +14 -34
  120. package/src/components/post-taxonomies/hierarchical-term-selector.js +15 -37
  121. package/src/components/post-taxonomies/most-used-terms.js +15 -18
  122. package/src/components/post-title/index.native.js +1 -0
  123. package/src/components/post-visibility/check.js +2 -10
  124. package/src/components/theme-support-check/index.js +1 -6
  125. package/src/store/utils/notice-builder.js +2 -7
  126. package/src/style.scss +0 -1
  127. package/src/components/page-attributes/style.scss +0 -12
@@ -7,8 +7,6 @@ exports.default = MostUsedTerms;
7
7
 
8
8
  var _element = require("@wordpress/element");
9
9
 
10
- var _lodash = require("lodash");
11
-
12
10
  var _components = require("@wordpress/components");
13
11
 
14
12
  var _data = require("@wordpress/data");
@@ -17,10 +15,6 @@ var _coreData = require("@wordpress/core-data");
17
15
 
18
16
  var _terms2 = require("../../utils/terms");
19
17
 
20
- /**
21
- * External dependencies
22
- */
23
-
24
18
  /**
25
19
  * WordPress dependencies
26
20
  */
@@ -52,20 +46,19 @@ function MostUsedTerms(_ref) {
52
46
  _terms: mostUsedTerms,
53
47
  showTerms: (mostUsedTerms === null || mostUsedTerms === void 0 ? void 0 : mostUsedTerms.length) >= MIN_MOST_USED_TERMS
54
48
  };
55
- }, []);
49
+ }, [taxonomy.slug]);
56
50
 
57
51
  if (!showTerms) {
58
52
  return null;
59
53
  }
60
54
 
61
55
  const terms = (0, _terms2.unescapeTerms)(_terms);
62
- const label = (0, _lodash.get)(taxonomy, ['labels', 'most_used']);
63
56
  return (0, _element.createElement)("div", {
64
57
  className: "editor-post-taxonomies__flat-term-most-used"
65
58
  }, (0, _element.createElement)(_components.BaseControl.VisualLabel, {
66
59
  as: "h3",
67
60
  className: "editor-post-taxonomies__flat-term-most-used-label"
68
- }, label), (0, _element.createElement)("ul", {
61
+ }, taxonomy.labels.most_used), (0, _element.createElement)("ul", {
69
62
  role: "list",
70
63
  className: "editor-post-taxonomies__flat-term-most-used-list"
71
64
  }, terms.map(term => (0, _element.createElement)("li", {
@@ -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,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"]}
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","labels","most_used","map","term","id","name"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;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,qBAC3BC,MAAF,IAAc;AACb,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,GAX4B,EAY7B,CAAEU,QAAQ,CAACO,IAAX,CAZ6B,CAA9B;;AAeA,MAAK,CAAEL,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMO,KAAK,GAAG,2BAAeR,MAAf,CAAd;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,uBAAD,CAAa,WAAb;AACC,IAAA,EAAE,EAAC,IADJ;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,QAAQ,CAACU,MAAT,CAAgBC,SAJnB,CADD,EAYC;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGF,KAAK,CAACG,GAAN,CAAaC,IAAF,IACZ;AAAI,IAAA,GAAG,EAAGA,IAAI,CAACC;AAAf,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMf,QAAQ,CAAEc,IAAF;AAFzB,KAIGA,IAAI,CAACE,IAJR,CADD,CADC,CAJH,CAZD,CADD;AA+BA","sourcesContent":["/**\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(\n\t\t( select ) => {\n\t\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\tDEFAULT_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t_terms: mostUsedTerms,\n\t\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t\t};\n\t\t},\n\t\t[ taxonomy.slug ]\n\t);\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\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{ taxonomy.labels.most_used }\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"]}
@@ -133,6 +133,7 @@ class PostTitle extends _element.Component {
133
133
  })
134
134
  };
135
135
  return (0, _element.createElement)(_reactNative.View, {
136
+ testID: "post-title",
136
137
  style: [_style.default.titleContainer, borderStyle, {
137
138
  borderColor
138
139
  }, isDimmed && _style.default.dimmed],
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"names":["PostTitle","Component","constructor","props","setRef","bind","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","onPaste","value","onChange","plainText","content","mode","tagName","valueToInsert","html","richText","getTitle","title","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","styles","titleContainer","dimmed","onBlur","onUpdate","onEnterPress","select","isPostTitleSelected","getEditedPostAttribute","editorStore","getSelectedBlockClientId","getBlockRootClientId","getSettings","blockEditorStore","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","clearSelectedB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AAkB;AAClB,KATK;;AAUNrD,IAAAA,UAAU,GAAG;AACZoD,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAZK,GAAP;AAcA,CArBD,CApBc,EA0CdM,uBA1Cc,EA2CdC,4BA3Cc,EA4CZvE,SA5CY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\t__experimentalRichText as RichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText.\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText } ) {\n\t\tconst content = pasteHandler( {\n\t\t\tplainText,\n\t\t\tmode: 'INLINE',\n\t\t\ttagName: 'p',\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn ! title\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn ! title\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t></RichText>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } =\n\t\t\tselect( editorStore );\n\t\tconst { getSelectedBlockClientId, getBlockRootClientId, getSettings } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles =\n\t\t\tgetSettings()?.__experimentalGlobalStylesBaseStyles?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection } =\n\t\t\tdispatch( editorStore );\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock } =\n\t\t\tdispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"names":["PostTitle","Component","constructor","props","setRef","bind","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","onPaste","value","onChange","plainText","content","mode","tagName","valueToInsert","html","richText","getTitle","title","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","styles","titleContainer","dimmed","onBlur","onUpdate","onEnterPress","select","isPostTitleSelected","getEditedPostAttribute","editorStore","getSelectedBlockClientId","getBlockRootClientId","getSettings","blockEditorStore","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","clearSelectedBlock","insertDefaultBlock","undefined","onUndo","onRedo","withInstanceId","withFocusOutside"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AA1BA;AACA;AAC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dM,uBA1Cc,EA2CdC,4BA3Cc,EA4CZvE,SA5CY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\t__experimentalRichText as RichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText.\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText } ) {\n\t\tconst content = pasteHandler( {\n\t\t\tplainText,\n\t\t\tmode: 'INLINE',\n\t\t\ttagName: 'p',\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn ! title\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn ! title\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\ttestID=\"post-title\"\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t></RichText>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } =\n\t\t\tselect( editorStore );\n\t\tconst { getSelectedBlockClientId, getBlockRootClientId, getSettings } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles =\n\t\t\tgetSettings()?.__experimentalGlobalStylesBaseStyles?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection } =\n\t\t\tdispatch( editorStore );\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock } =\n\t\t\tdispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"]}
@@ -6,18 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PostVisibilityCheck = PostVisibilityCheck;
7
7
  exports.default = void 0;
8
8
 
9
- var _lodash = require("lodash");
10
-
11
9
  var _compose = require("@wordpress/compose");
12
10
 
13
11
  var _data = require("@wordpress/data");
14
12
 
15
13
  var _store = require("../../store");
16
14
 
17
- /**
18
- * External dependencies
19
- */
20
-
21
15
  /**
22
16
  * WordPress dependencies
23
17
  */
@@ -37,12 +31,14 @@ function PostVisibilityCheck(_ref) {
37
31
  }
38
32
 
39
33
  var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
34
+ var _getCurrentPost$_link, _getCurrentPost$_link2;
35
+
40
36
  const {
41
37
  getCurrentPost,
42
38
  getCurrentPostType
43
39
  } = select(_store.store);
44
40
  return {
45
- hasPublishAction: (0, _lodash.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
41
+ hasPublishAction: (_getCurrentPost$_link = (_getCurrentPost$_link2 = getCurrentPost()._links) === null || _getCurrentPost$_link2 === void 0 ? void 0 : _getCurrentPost$_link2['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
46
42
  postType: getCurrentPostType()
47
43
  };
48
44
  })])(PostVisibilityCheck);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-visibility/check.js"],"names":["PostVisibilityCheck","hasPublishAction","render","canEdit","select","getCurrentPost","getCurrentPostType","editorStore","postType"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,mBAAT,OAA6D;AAAA,MAA/B;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAA+B;AACnE,QAAMC,OAAO,GAAGF,gBAAhB;AACA,SAAOC,MAAM,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAAb;AACA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AACzB,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,SAAO;AACNN,IAAAA,gBAAgB,EAAE,iBACjBI,cAAc,EADG,EAEjB,CAAE,QAAF,EAAY,mBAAZ,CAFiB,EAGjB,KAHiB,CADZ;AAMNG,IAAAA,QAAQ,EAAEF,kBAAkB;AANtB,GAAP;AAQA,CAVD,CADuB,CAAT,EAYVN,mBAZU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PostVisibilityCheck( { hasPublishAction, render } ) {\n\tconst canEdit = hasPublishAction;\n\treturn render( { canEdit } );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\thasPublishAction: get(\n\t\t\t\tgetCurrentPost(),\n\t\t\t\t[ '_links', 'wp:action-publish' ],\n\t\t\t\tfalse\n\t\t\t),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t} ),\n] )( PostVisibilityCheck );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-visibility/check.js"],"names":["PostVisibilityCheck","hasPublishAction","render","canEdit","select","getCurrentPost","getCurrentPostType","editorStore","_links","postType"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,mBAAT,OAA6D;AAAA,MAA/B;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAA+B;AACnE,QAAMC,OAAO,GAAGF,gBAAhB;AACA,SAAOC,MAAM,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAAb;AACA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AAAA;;AACzB,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,SAAO;AACNN,IAAAA,gBAAgB,qDACfI,cAAc,GAAGG,MADF,2DACf,uBAA2B,mBAA3B,CADe,yEACqC,KAF/C;AAGNC,IAAAA,QAAQ,EAAEH,kBAAkB;AAHtB,GAAP;AAKA,CAPD,CADuB,CAAT,EASVN,mBATU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PostVisibilityCheck( { hasPublishAction, render } ) {\n\tconst canEdit = hasPublishAction;\n\treturn render( { canEdit } );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t} ),\n] )( PostVisibilityCheck );\n"]}
@@ -6,18 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ThemeSupportCheck = ThemeSupportCheck;
7
7
  exports.default = void 0;
8
8
 
9
- var _lodash = require("lodash");
10
-
11
9
  var _data = require("@wordpress/data");
12
10
 
13
11
  var _coreData = require("@wordpress/core-data");
14
12
 
15
13
  var _store = require("../../store");
16
14
 
17
- /**
18
- * External dependencies
19
- */
20
-
21
15
  /**
22
16
  * WordPress dependencies
23
17
  */
@@ -33,7 +27,9 @@ function ThemeSupportCheck(_ref) {
33
27
  supportKeys
34
28
  } = _ref;
35
29
  const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
36
- const supported = (0, _lodash.get)(themeSupports, [key], false); // 'post-thumbnails' can be boolean or an array of post types.
30
+ var _themeSupports$key;
31
+
32
+ const supported = (_themeSupports$key = themeSupports === null || themeSupports === void 0 ? void 0 : themeSupports[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false; // 'post-thumbnails' can be boolean or an array of post types.
37
33
  // In the latter case, we need to verify `postType` exists
38
34
  // within `supported`. If `postType` isn't passed, then the check
39
35
  // should fail.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/theme-support-check/index.js"],"names":["ThemeSupportCheck","themeSupports","children","postType","supportKeys","isSupported","Array","isArray","some","key","supported","includes","select","getThemeSupports","coreStore","getEditedPostAttribute","editorStore"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAKH;AAAA,MAL+B;AAClCC,IAAAA,aADkC;AAElCC,IAAAA,QAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC,IAAAA;AAJkC,GAK/B;AACH,QAAMC,WAAW,GAAG,CACnBC,KAAK,CAACC,OAAN,CAAeH,WAAf,IAA+BA,WAA/B,GAA6C,CAAEA,WAAF,CAD1B,EAEjBI,IAFiB,CAETC,GAAF,IAAW;AACnB,UAAMC,SAAS,GAAG,iBAAKT,aAAL,EAAoB,CAAEQ,GAAF,CAApB,EAA6B,KAA7B,CAAlB,CADmB,CAEnB;AACA;AACA;AACA;;AACA,QAAK,sBAAsBA,GAAtB,IAA6BH,KAAK,CAACC,OAAN,CAAeG,SAAf,CAAlC,EAA+D;AAC9D,aAAOA,SAAS,CAACC,QAAV,CAAoBR,QAApB,CAAP;AACA;;AACD,WAAOO,SAAP;AACA,GAZmB,CAApB;;AAcA,MAAK,CAAEL,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SAAOH,QAAP;AACA;;eAEc,sBAAcU,MAAF,IAAc;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6BH,MAAM,CAAEI,YAAF,CAAzC;AACA,SAAO;AACNb,IAAAA,QAAQ,EAAEY,sBAAsB,CAAE,MAAF,CAD1B;AAENd,IAAAA,aAAa,EAAEY,gBAAgB;AAFzB,GAAP;AAIA,CAPc,EAOVb,iBAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function ThemeSupportCheck( {\n\tthemeSupports,\n\tchildren,\n\tpostType,\n\tsupportKeys,\n} ) {\n\tconst isSupported = (\n\t\tArray.isArray( supportKeys ) ? supportKeys : [ supportKeys ]\n\t ).some( ( key ) => {\n\t\tconst supported = get( themeSupports, [ key ], false );\n\t\t// 'post-thumbnails' can be boolean or an array of post types.\n\t\t// In the latter case, we need to verify `postType` exists\n\t\t// within `supported`. If `postType` isn't passed, then the check\n\t\t// should fail.\n\t\tif ( 'post-thumbnails' === key && Array.isArray( supported ) ) {\n\t\t\treturn supported.includes( postType );\n\t\t}\n\t\treturn supported;\n\t} );\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getThemeSupports } = select( coreStore );\n\tconst { getEditedPostAttribute } = select( editorStore );\n\treturn {\n\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\tthemeSupports: getThemeSupports(),\n\t};\n} )( ThemeSupportCheck );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/theme-support-check/index.js"],"names":["ThemeSupportCheck","themeSupports","children","postType","supportKeys","isSupported","Array","isArray","some","key","supported","includes","select","getThemeSupports","coreStore","getEditedPostAttribute","editorStore"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAKH;AAAA,MAL+B;AAClCC,IAAAA,aADkC;AAElCC,IAAAA,QAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC,IAAAA;AAJkC,GAK/B;AACH,QAAMC,WAAW,GAAG,CACnBC,KAAK,CAACC,OAAN,CAAeH,WAAf,IAA+BA,WAA/B,GAA6C,CAAEA,WAAF,CAD1B,EAEjBI,IAFiB,CAETC,GAAF,IAAW;AAAA;;AACnB,UAAMC,SAAS,yBAAGT,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAIQ,GAAJ,CAAhB,mEAA6B,KAA5C,CADmB,CAEnB;AACA;AACA;AACA;;AACA,QAAK,sBAAsBA,GAAtB,IAA6BH,KAAK,CAACC,OAAN,CAAeG,SAAf,CAAlC,EAA+D;AAC9D,aAAOA,SAAS,CAACC,QAAV,CAAoBR,QAApB,CAAP;AACA;;AACD,WAAOO,SAAP;AACA,GAZmB,CAApB;;AAcA,MAAK,CAAEL,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SAAOH,QAAP;AACA;;eAEc,sBAAcU,MAAF,IAAc;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6BH,MAAM,CAAEI,YAAF,CAAzC;AACA,SAAO;AACNb,IAAAA,QAAQ,EAAEY,sBAAsB,CAAE,MAAF,CAD1B;AAENd,IAAAA,aAAa,EAAEY,gBAAgB;AAFzB,GAAP;AAIA,CAPc,EAOVb,iBAPU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function ThemeSupportCheck( {\n\tthemeSupports,\n\tchildren,\n\tpostType,\n\tsupportKeys,\n} ) {\n\tconst isSupported = (\n\t\tArray.isArray( supportKeys ) ? supportKeys : [ supportKeys ]\n\t ).some( ( key ) => {\n\t\tconst supported = themeSupports?.[ key ] ?? false;\n\t\t// 'post-thumbnails' can be boolean or an array of post types.\n\t\t// In the latter case, we need to verify `postType` exists\n\t\t// within `supported`. If `postType` isn't passed, then the check\n\t\t// should fail.\n\t\tif ( 'post-thumbnails' === key && Array.isArray( supported ) ) {\n\t\t\treturn supported.includes( postType );\n\t\t}\n\t\treturn supported;\n\t} );\n\n\tif ( ! isSupported ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getThemeSupports } = select( coreStore );\n\tconst { getEditedPostAttribute } = select( editorStore );\n\treturn {\n\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\tthemeSupports: getThemeSupports(),\n\t};\n} )( ThemeSupportCheck );\n"]}
@@ -11,8 +11,6 @@ var _i18n = require("@wordpress/i18n");
11
11
 
12
12
  var _constants = require("../constants");
13
13
 
14
- var _lodash = require("lodash");
15
-
16
14
  /**
17
15
  * WordPress dependencies
18
16
  */
@@ -21,10 +19,6 @@ var _lodash = require("lodash");
21
19
  * Internal dependencies
22
20
  */
23
21
 
24
- /**
25
- * External dependencies
26
- */
27
-
28
22
  /**
29
23
  * Builds the arguments for a success notification dispatch.
30
24
  *
@@ -34,13 +28,15 @@ var _lodash = require("lodash");
34
28
  * notification should be sent.
35
29
  */
36
30
  function getNotificationArgumentsForSaveSuccess(data) {
31
+ var _data$options, _postType$viewable;
32
+
37
33
  const {
38
34
  previousPost,
39
35
  post,
40
36
  postType
41
37
  } = data; // Autosaves are neither shown a notice nor redirected.
42
38
 
43
- if ((0, _lodash.get)(data.options, ['isAutosave'])) {
39
+ if ((_data$options = data.options) !== null && _data$options !== void 0 && _data$options.isAutosave) {
44
40
  return [];
45
41
  } // No notice is shown after trashing a post
46
42
 
@@ -53,7 +49,7 @@ function getNotificationArgumentsForSaveSuccess(data) {
53
49
  const isPublished = publishStatus.includes(previousPost.status);
54
50
  const willPublish = publishStatus.includes(post.status);
55
51
  let noticeMessage;
56
- let shouldShowLink = (0, _lodash.get)(postType, ['viewable'], false);
52
+ let shouldShowLink = (_postType$viewable = postType === null || postType === void 0 ? void 0 : postType.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
57
53
  let isDraft; // Always should a notice, which will be spoken for accessibility.
58
54
 
59
55
  if (!isPublished && !willPublish) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"names":["getNotificationArgumentsForSaveSuccess","data","previousPost","post","postType","options","status","publishStatus","isPublished","includes","willPublish","noticeMessage","shouldShowLink","isDraft","labels","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","SAVE_POST_NOTICE_ID","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail","TRASH_POST_NOTICE_ID"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sCAAT,CAAiDC,IAAjD,EAAwD;AAC9D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA;AAAtB,MAAmCH,IAAzC,CAD8D,CAE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Q,CAAEJ,KAAK,CAAC3B,MAAR,CADX,GAEG,cAAI,kBAAJ,CAHJ,CAjB2D,CAsB3D;AACA;;AACA,MAAK4B,KAAK,CAACI,OAAN,IAAiB,CAAE,aAAaC,IAAb,CAAmBL,KAAK,CAACI,OAAzB,CAAxB,EAA6D;AAC5D3B,IAAAA,aAAa,GAAG,CAAEA,aAAF,EAAiBuB,KAAK,CAACI,OAAvB,EAAiCE,IAAjC,CAAuC,GAAvC,CAAhB;AACA;;AACD,SAAO,CACN7B,aADM,EAEN;AACCkB,IAAAA,EAAE,EAAEC;AADL,GAFM,CAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASW,oCAAT,CAA+CxC,IAA/C,EAAsD;AAC5D,SAAO,CACNA,IAAI,CAACiC,KAAL,CAAWI,OAAX,IAAsBrC,IAAI,CAACiC,KAAL,CAAWC,IAAX,KAAoB,eAA1C,GACGlC,IAAI,CAACiC,KAAL,CAAWI,OADd,GAEG,cAAI,iBAAJ,CAHG,EAIN;AACCT,IAAAA,EAAE,EAAEa;AADL,GAJM,CAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( get( data.options, [ 'isAutosave' ] ) ) {\n\t\treturn [];\n\t}\n\n\t// No notice is shown after trashing a post\n\tif ( post.status === 'trash' && previousPost.status !== 'trash' ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.includes( previousPost.status );\n\tconst willPublish = publishStatus.includes( post.status );\n\n\tlet noticeMessage;\n\tlet shouldShowLink = get( postType, [ 'viewable' ], false );\n\tlet isDraft;\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved.' );\n\t\tisDraft = true;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: isDraft ? __( 'View Preview' ) : postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"names":["getNotificationArgumentsForSaveSuccess","data","previousPost","post","postType","options","isAutosave","status","publishStatus","isPublished","includes","willPublish","noticeMessage","shouldShowLink","viewable","isDraft","labels","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","SAVE_POST_NOTICE_ID","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail","TRASH_POST_NOTICE_ID"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sCAAT,CAAiDC,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AIV,aAAa,GAChB,CAAEH,WAAF,IAAiBD,aAAa,CAAC8B,OAAd,CAAuBH,KAAK,CAAC5B,MAA7B,MAA0C,CAAC,CAA5D,GACGgC,QAAQ,CAAEJ,KAAK,CAAC5B,MAAR,CADX,GAEG,cAAI,kBAAJ,CAHJ,CAjB2D,CAsB3D;AACA;;AACA,MAAK6B,KAAK,CAACI,OAAN,IAAiB,CAAE,aAAaC,IAAb,CAAmBL,KAAK,CAACI,OAAzB,CAAxB,EAA6D;AAC5D5B,IAAAA,aAAa,GAAG,CAAEA,aAAF,EAAiBwB,KAAK,CAACI,OAAvB,EAAiCE,IAAjC,CAAuC,GAAvC,CAAhB;AACA;;AACD,SAAO,CACN9B,aADM,EAEN;AACCmB,IAAAA,EAAE,EAAEC;AADL,GAFM,CAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASW,oCAAT,CAA+C1C,IAA/C,EAAsD;AAC5D,SAAO,CACNA,IAAI,CAACmC,KAAL,CAAWI,OAAX,IAAsBvC,IAAI,CAACmC,KAAL,CAAWC,IAAX,KAAoB,eAA1C,GACGpC,IAAI,CAACmC,KAAL,CAAWI,OADd,GAEG,cAAI,iBAAJ,CAHG,EAIN;AACCT,IAAAA,EAAE,EAAEa;AADL,GAJM,CAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( data.options?.isAutosave ) {\n\t\treturn [];\n\t}\n\n\t// No notice is shown after trashing a post\n\tif ( post.status === 'trash' && previousPost.status !== 'trash' ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.includes( previousPost.status );\n\tconst willPublish = publishStatus.includes( post.status );\n\n\tlet noticeMessage;\n\tlet shouldShowLink = postType?.viewable ?? false;\n\tlet isDraft;\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved.' );\n\t\tisDraft = true;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: isDraft ? __( 'View Preview' ) : postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"]}
@@ -5,7 +5,7 @@ import { createElement } from "@wordpress/element";
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { compose } from '@wordpress/compose';
8
- import { withSelect } from '@wordpress/data';
8
+ import { withSelect, useDispatch } from '@wordpress/data';
9
9
  import { create, getTextContent } from '@wordpress/rich-text';
10
10
  import { store as blockEditorStore } from '@wordpress/block-editor';
11
11
  import { store as coreStore } from '@wordpress/core-data';
@@ -72,6 +72,9 @@ export const DocumentOutline = _ref => {
72
72
  hasOutlineItemsDisabled
73
73
  } = _ref;
74
74
  const headings = computeOutlineHeadings(blocks);
75
+ const {
76
+ selectBlock
77
+ } = useDispatch(blockEditorStore);
75
78
 
76
79
  if (headings.length < 1) {
77
80
  return null;
@@ -105,7 +108,10 @@ export const DocumentOutline = _ref => {
105
108
  isValid: isValid,
106
109
  isDisabled: hasOutlineItemsDisabled,
107
110
  href: `#block-${item.clientId}`,
108
- onSelect: onSelect
111
+ onSelect: () => {
112
+ selectBlock(item.clientId);
113
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
114
+ }
109
115
  }, item.isEmpty ? emptyHeadingContent : getTextContent(create({
110
116
  html: item.attributes.content
111
117
  })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/document-outline/index.js"],"names":["__","compose","withSelect","create","getTextContent","store","blockEditorStore","coreStore","DocumentOutlineItem","editorStore","emptyHeadingContent","incorrectLevelContent","singleH1Headings","multipleH1Headings","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","length","DocumentOutline","title","onSelect","isTitleSupported","hasOutlineItemsDisabled","headings","prevHeadingLevel","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","id","map","item","index","isIncorrectLevel","isValid","clientId","html","select","getBlocks","getEditedPostAttribute","getPostType","postType","supports"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,UAAT,QAA2B,iBAA3B;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,sBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,QAAhC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,aAArC;AAEA;AACA;AACA;;AACA,MAAM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KAAK,EAAEwB,sBAAsB,CAAE,OAAF,CADvB;AAENrC,IAAAA,MAAM,EAAEoC,SAAS,EAFX;AAGNrB,IAAAA,gBAAgB,2BAAEwB,QAAF,aAAEA,QAAF,6CAAEA,QAAQ,CAAEC,QAAZ,uDAAE,mBAAoB3B,KAAtB,yEAA+B;AAHzC,GAAP;AAKA,CAXS,CADW,CAAP,CAaZD,eAbY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content || heading.attributes.content.length === 0;\n\nexport const DocumentOutline = ( {\n\tblocks = [],\n\ttitle,\n\tonSelect,\n\tisTitleSupported,\n\thasOutlineItemsDisabled,\n} ) => {\n\tconst headings = computeOutlineHeadings( blocks );\n\n\tif ( headings.length < 1 ) {\n\t\treturn null;\n\t}\n\n\tlet prevHeadingLevel = 1;\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item, index ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel = item.level > prevHeadingLevel + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevel = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t{ isIncorrectLevel && incorrectLevelContent }\n\t\t\t\t\t\t\t{ item.level === 1 &&\n\t\t\t\t\t\t\t\thasMultipleH1 &&\n\t\t\t\t\t\t\t\tmultipleH1Headings }\n\t\t\t\t\t\t\t{ hasTitle &&\n\t\t\t\t\t\t\t\titem.level === 1 &&\n\t\t\t\t\t\t\t\t! hasMultipleH1 &&\n\t\t\t\t\t\t\t\tsingleH1Headings }\n\t\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</div>\n\t);\n};\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} )\n)( DocumentOutline );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/document-outline/index.js"],"names":["__","compose","withSelect","useDispatch","create","getTextContent","store","blockEditorStore","coreStore","DocumentOutlineItem","editorStore","emptyHeadingContent","incorrectLevelContent","singleH1Headings","multipleH1Headings","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","length","DocumentOutline","title","onSelect","isTitleSupported","hasOutlineItemsDisabled","headings","selectBlock","prevHeadingLevel","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","id","map","item","index","isIncorrectLevel","isValid","clientId","html","select","getBlocks","getEditedPostAttribute","getPostType","postType","supports"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,iBAAxC;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,sBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,QAAhC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,aAArC;AAEA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,0BAAMX,EAAE,CAAE,iBAAF,CAAR,CAA5B;AACA,MAAMY,qBAAqB,GAAG,CAC7B;AAAI,EAAA,GAAG,EAAC;AAAR,EAD6B,EAE7B;AAAI,EAAA,GAAG,EAAC;AAAR,GAA8BZ,EAAE,CAAE,2BAAF,CAAhC,CAF6B,CAA9B;AAIA,MAAMa,gBAAgB,GAAG,CACxB;AAAI,EAAA,GAAG,EAAC;AAAR,EADwB,EAExB;AAAI,EAAA,GAAG,EAAC;AAAR,GACGb,EAAE,CAAE,sDAAF,CADL,CAFwB,CAAzB;AAMA,M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AAE,mBAAoB5B,KAAtB,yEAA+B;AAHzC,GAAP;AAKA,CAXS,CADW,CAAP,CAaZD,eAbY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { compose } from '@wordpress/compose';\nimport { withSelect, useDispatch } from '@wordpress/data';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content || heading.attributes.content.length === 0;\n\nexport const DocumentOutline = ( {\n\tblocks = [],\n\ttitle,\n\tonSelect,\n\tisTitleSupported,\n\thasOutlineItemsDisabled,\n} ) => {\n\tconst headings = computeOutlineHeadings( blocks );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tif ( headings.length < 1 ) {\n\t\treturn null;\n\t}\n\n\tlet prevHeadingLevel = 1;\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item, index ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel = item.level > prevHeadingLevel + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevel = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\tselectBlock( item.clientId );\n\t\t\t\t\t\t\t\tonSelect?.();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t{ isIncorrectLevel && incorrectLevelContent }\n\t\t\t\t\t\t\t{ item.level === 1 &&\n\t\t\t\t\t\t\t\thasMultipleH1 &&\n\t\t\t\t\t\t\t\tmultipleH1Headings }\n\t\t\t\t\t\t\t{ hasTitle &&\n\t\t\t\t\t\t\t\titem.level === 1 &&\n\t\t\t\t\t\t\t\t! hasMultipleH1 &&\n\t\t\t\t\t\t\t\tsingleH1Headings }\n\t\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</div>\n\t);\n};\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} )\n)( DocumentOutline );\n"]}
@@ -1,11 +1,6 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { get } from 'lodash';
5
1
  /**
6
2
  * WordPress dependencies
7
3
  */
8
-
9
4
  import { useSelect } from '@wordpress/data';
10
5
  import { store as coreStore } from '@wordpress/core-data';
11
6
  /**
@@ -17,16 +12,18 @@ export function PageAttributesCheck(_ref) {
17
12
  let {
18
13
  children
19
14
  } = _ref;
20
- const postType = useSelect(select => {
15
+ const supportsPageAttributes = useSelect(select => {
16
+ var _postType$supports;
17
+
21
18
  const {
22
19
  getEditedPostAttribute
23
20
  } = select(editorStore);
24
21
  const {
25
22
  getPostType
26
23
  } = select(coreStore);
27
- return getPostType(getEditedPostAttribute('type'));
28
- }, []);
29
- const supportsPageAttributes = get(postType, ['supports', 'page-attributes'], false); // Only render fields if post type supports page attributes or available templates exist.
24
+ const postType = getPostType(getEditedPostAttribute('type'));
25
+ return !!(postType !== null && postType !== void 0 && (_postType$supports = postType.supports) !== null && _postType$supports !== void 0 && _postType$supports['page-attributes']);
26
+ }, []); // Only render fields if post type supports page attributes or available templates exist.
30
27
 
31
28
  if (!supportsPageAttributes) {
32
29
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/check.js"],"names":["get","useSelect","store","coreStore","editorStore","PageAttributesCheck","children","postType","select","getEditedPostAttribute","getPostType","supportsPageAttributes"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,mBAAT,OAA6C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAMC,QAAQ,GAAGN,SAAS,CAAIO,MAAF,IAAc;AACzC,UAAM;AAAEC,MAAAA;AAAF,QAA6BD,MAAM,CAAEJ,WAAF,CAAzC;AACA,UAAM;AAAEM,MAAAA;AAAF,QAAkBF,MAAM,CAAEL,SAAF,CAA9B;AAEA,WAAOO,WAAW,CAAED,sBAAsB,CAAE,MAAF,CAAxB,CAAlB;AACA,GALyB,EAKvB,EALuB,CAA1B;AAMA,QAAME,sBAAsB,GAAGX,GAAG,CACjCO,QADiC,EAEjC,CAAE,UAAF,EAAc,iBAAd,CAFiC,EAGjC,KAHiC,CAAlC,CAPmD,CAanD;;AACA,MAAK,CAAEI,sBAAP,EAAgC;AAC/B,WAAO,IAAP;AACA;;AAED,SAAOL,QAAP;AACA;AAED,eAAeD,mBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PageAttributesCheck( { children } ) {\n\tconst postType = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn getPostType( getEditedPostAttribute( 'type' ) );\n\t}, [] );\n\tconst supportsPageAttributes = get(\n\t\tpostType,\n\t\t[ 'supports', 'page-attributes' ],\n\t\tfalse\n\t);\n\n\t// Only render fields if post type supports page attributes or available templates exist.\n\tif ( ! supportsPageAttributes ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default PageAttributesCheck;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/check.js"],"names":["useSelect","store","coreStore","editorStore","PageAttributesCheck","children","supportsPageAttributes","select","getEditedPostAttribute","getPostType","postType","supports"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;AAEA,OAAO,SAASC,mBAAT,OAA6C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAMC,sBAAsB,GAAGN,SAAS,CAAIO,MAAF,IAAc;AAAA;;AACvD,UAAM;AAAEC,MAAAA;AAAF,QAA6BD,MAAM,CAAEJ,WAAF,CAAzC;AACA,UAAM;AAAEM,MAAAA;AAAF,QAAkBF,MAAM,CAAEL,SAAF,CAA9B;AACA,UAAMQ,QAAQ,GAAGD,WAAW,CAAED,sBAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,WAAO,CAAC,EAAEE,QAAF,aAAEA,QAAF,qCAAEA,QAAQ,CAAEC,QAAZ,+CAAE,mBAAsB,iBAAtB,CAAF,CAAR;AACA,GANuC,EAMrC,EANqC,CAAxC,CADmD,CASnD;;AACA,MAAK,CAAEL,sBAAP,EAAgC;AAC/B,WAAO,IAAP;AACA;;AAED,SAAOD,QAAP;AACA;AAED,eAAeD,mBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PageAttributesCheck( { children } ) {\n\tconst supportsPageAttributes = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn !! postType?.supports?.[ 'page-attributes' ];\n\t}, [] );\n\n\t// Only render fields if post type supports page attributes or available templates exist.\n\tif ( ! supportsPageAttributes ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default PageAttributesCheck;\n"]}
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
- import { TextControl } from '@wordpress/components';
7
+ import { Flex, FlexBlock, __experimentalNumberControl as NumberControl } from '@wordpress/components';
8
8
  import { withSelect, withDispatch } from '@wordpress/data';
9
9
  import { compose } from '@wordpress/compose';
10
10
  import { useState } from '@wordpress/element';
@@ -33,17 +33,15 @@ export const PageAttributesOrder = _ref => {
33
33
  };
34
34
 
35
35
  const value = orderInput === null ? order : orderInput;
36
- return createElement(TextControl, {
37
- className: "editor-page-attributes__order",
38
- type: "number",
36
+ return createElement(Flex, null, createElement(FlexBlock, null, createElement(NumberControl, {
39
37
  label: __('Order'),
40
38
  value: value,
41
39
  onChange: setUpdatedOrder,
42
- size: 6,
40
+ labelPosition: "side",
43
41
  onBlur: () => {
44
42
  setOrderInput(null);
45
43
  }
46
- });
44
+ })));
47
45
  };
48
46
 
49
47
  function PageAttributesOrderWithChecks(props) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/order.js"],"names":["__","TextControl","withSelect","withDispatch","compose","useState","PostTypeSupportCheck","store","editorStore","PageAttributesOrder","onUpdateOrder","order","orderInput","setOrderInput","setUpdatedOrder","value","newOrder","Number","isInteger","trim","PageAttributesOrderWithChecks","props","select","getEditedPostAttribute","dispatch","editPost","menu_order"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,MAAMC,mBAAmB,GAAG,QAAoC;AAAA,MAAlC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,KAAK,GAAG;AAAzB,GAAkC;AACtE,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgCR,QAAQ,CAAE,IAAF,CAA9C;;AAEA,QAAMS,eAAe,GAAKC,KAAF,IAAa;AAAA;;AACpCF,IAAAA,aAAa,C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AbU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\nexport const PageAttributesOrder = ( { onUpdateOrder, order = 0 } ) => {\n\tconst [ orderInput, setOrderInput ] = useState( null );\n\n\tconst setUpdatedOrder = ( value ) => {\n\t\tsetOrderInput( value );\n\t\tconst newOrder = Number( value );\n\t\tif ( Number.isInteger( newOrder ) && value.trim?.() !== '' ) {\n\t\t\tonUpdateOrder( Number( value ) );\n\t\t}\n\t};\n\tconst value = orderInput === null ? order : orderInput;\n\treturn (\n\t\t<TextControl\n\t\t\tclassName=\"editor-page-attributes__order\"\n\t\t\ttype=\"number\"\n\t\t\tlabel={ __( 'Order' ) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ setUpdatedOrder }\n\t\t\tsize={ 6 }\n\t\t\tonBlur={ () => {\n\t\t\t\tsetOrderInput( null );\n\t\t\t} }\n\t\t/>\n\t);\n};\n\nfunction PageAttributesOrderWithChecks( props ) {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"page-attributes\">\n\t\t\t<PageAttributesOrder { ...props } />\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\torder: select( editorStore ).getEditedPostAttribute( 'menu_order' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonUpdateOrder( order ) {\n\t\t\tdispatch( editorStore ).editPost( {\n\t\t\t\tmenu_order: order,\n\t\t\t} );\n\t\t},\n\t} ) ),\n] )( PageAttributesOrderWithChecks );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/order.js"],"names":["__","Flex","FlexBlock","__experimentalNumberControl","NumberControl","withSelect","withDispatch","compose","useState","PostTypeSupportCheck","store","editorStore","PageAttributesOrder","onUpdateOrder","order","orderInput","setOrderInput","setUpdatedOrder","value","newOrder","Number","isInteger","trim","PageAttributesOrderWithChecks","props","select","getEditedPostAttribute","dispatch","editPost","menu_order"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,IADD,EAECC,SAFD,EAGCC,2BAA2B,IAAIC,aAHhC,QAIO,uBAJP;AAKA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA,OAAO,MAAMC,mBAAmB,GAAG,QAAoC;AAAA,MAAlC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,KAAK,GAAG;AAAzB,GAAkC;AACtE,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgCR,QAAQ,CAAE,IAAF,CAA9C;;AAEA,QAAMS,eAAe,GAAKC,KAAF,IAAa;AAAA;;AACpCF,IAAAA,aAAa,CAAEE,KAAF,CAAb;AACA,UAAMC,QAAQ,GAAGC,MAAM,CAAEF,KAAF,CAAvB;;AACA,QAAKE,MAAM,CAACC,SAAP,CAAkBF,QAAlB,KAAgC,gBAAAD,KAAK,CAACI,IAAN,iEAAAJ,KAAK,OAAc,EAAxD,EAA6D;AAC5DL,MAAAA,aAAa,CAAEO,MAAM,CAAEF,KAAF,CAAR,CAAb;AACA;AACD,GAND;;AAOA,QAAMA,KAAK,GAAGH,UAAU,KAAK,IAAf,GAAsBD,KAAtB,GAA8BC,UAA5C;AACA,SACC,cAAC,IAAD,QACC,cAAC,SAAD,QACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGf,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,KAAK,EAAGkB,KAFT;AAGC,IAAA,QAAQ,EAAGD,eAHZ;AAIC,IAAA,aAAa,EAAC,MAJf;AAKC,IAAA,MAAM,EAAG,MAAM;AACdD,MAAAA,aAAa,CAAE,IAAF,CAAb;AACA;AAPF,IADD,CADD,CADD;AAeA,CA1BM;;AA4BP,SAASO,6BAAT,CAAwCC,KAAxC,EAAgD;AAC/C,SACC,cAAC,oBAAD;AAAsB,IAAA,WAAW,EAAC;AAAlC,KACC,cAAC,mBAAD,EAA0BA,KAA1B,CADD,CADD;AAKA;;AAED,eAAejB,OAAO,CAAE,CACvBF,UAAU,CAAIoB,MAAF,IAAc;AACzB,SAAO;AACNX,IAAAA,KAAK,EAAEW,MAAM,CAAEd,WAAF,CAAN,CAAsBe,sBAAtB,CAA8C,YAA9C;AADD,GAAP;AAGA,CAJS,CADa,EAMvBpB,YAAY,CAAIqB,QAAF,KAAkB;AAC/Bd,EAAAA,aAAa,CAAEC,KAAF,EAAU;AACtBa,IAAAA,QAAQ,CAAEhB,WAAF,CAAR,CAAwBiB,QAAxB,CAAkC;AACjCC,MAAAA,UAAU,EAAEf;AADqB,KAAlC;AAGA;;AAL8B,CAAlB,CAAF,CANW,CAAF,CAAP,CAaVS,6BAbU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tFlex,\n\tFlexBlock,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\nexport const PageAttributesOrder = ( { onUpdateOrder, order = 0 } ) => {\n\tconst [ orderInput, setOrderInput ] = useState( null );\n\n\tconst setUpdatedOrder = ( value ) => {\n\t\tsetOrderInput( value );\n\t\tconst newOrder = Number( value );\n\t\tif ( Number.isInteger( newOrder ) && value.trim?.() !== '' ) {\n\t\t\tonUpdateOrder( Number( value ) );\n\t\t}\n\t};\n\tconst value = orderInput === null ? order : orderInput;\n\treturn (\n\t\t<Flex>\n\t\t\t<FlexBlock>\n\t\t\t\t<NumberControl\n\t\t\t\t\tlabel={ __( 'Order' ) }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ setUpdatedOrder }\n\t\t\t\t\tlabelPosition=\"side\"\n\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\tsetOrderInput( null );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t</Flex>\n\t);\n};\n\nfunction PageAttributesOrderWithChecks( props ) {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"page-attributes\">\n\t\t\t<PageAttributesOrder { ...props } />\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\torder: select( editorStore ).getEditedPostAttribute( 'menu_order' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonUpdateOrder( order ) {\n\t\t\tdispatch( editorStore ).editPost( {\n\t\t\t\tmenu_order: order,\n\t\t\t} );\n\t\t},\n\t} ) ),\n] )( PageAttributesOrderWithChecks );\n"]}
@@ -3,7 +3,6 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { get } from 'lodash';
7
6
  import removeAccents from 'remove-accents';
8
7
  /**
9
8
  * WordPress dependencies
@@ -44,16 +43,21 @@ export const getItemPriority = (name, searchValue) => {
44
43
  return Infinity;
45
44
  };
46
45
  export function PageAttributesParent() {
46
+ var _postType$labels;
47
+
47
48
  const {
48
49
  editPost
49
50
  } = useDispatch(editorStore);
50
51
  const [fieldValue, setFieldValue] = useState(false);
51
52
  const {
53
+ isHierarchical,
52
54
  parentPost,
53
55
  parentPostId,
54
56
  items,
55
57
  postType
56
58
  } = useSelect(select => {
59
+ var _pType$hierarchical;
60
+
57
61
  const {
58
62
  getPostType,
59
63
  getEntityRecords,
@@ -67,7 +71,7 @@ export function PageAttributesParent() {
67
71
  const pageId = getEditedPostAttribute('parent');
68
72
  const pType = getPostType(postTypeSlug);
69
73
  const postId = getCurrentPostId();
70
- const isHierarchical = get(pType, ['hierarchical'], false);
74
+ const postIsHierarchical = (_pType$hierarchical = pType === null || pType === void 0 ? void 0 : pType.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false;
71
75
  const query = {
72
76
  per_page: 100,
73
77
  exclude: postId,
@@ -82,14 +86,14 @@ export function PageAttributesParent() {
82
86
  }
83
87
 
84
88
  return {
89
+ isHierarchical: postIsHierarchical,
85
90
  parentPostId: pageId,
86
91
  parentPost: pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null,
87
- items: isHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [],
92
+ items: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [],
88
93
  postType: pType
89
94
  };
90
95
  }, [fieldValue]);
91
- const isHierarchical = get(postType, ['hierarchical'], false);
92
- const parentPageLabel = get(postType, ['labels', 'parent_item_colon']);
96
+ const parentPageLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.parent_item_colon;
93
97
  const pageItems = items || [];
94
98
  const parentOptions = useMemo(() => {
95
99
  const getOptionsFromTree = function (tree) {