@wordpress/editor 12.10.0 → 12.13.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 (154) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/document-outline/index.js +7 -9
  3. package/build/components/document-outline/index.js.map +1 -1
  4. package/build/components/error-boundary/index.js +3 -0
  5. package/build/components/error-boundary/index.js.map +1 -1
  6. package/build/components/index.js +61 -9
  7. package/build/components/index.js.map +1 -1
  8. package/build/components/local-autosave-monitor/index.js +24 -19
  9. package/build/components/local-autosave-monitor/index.js.map +1 -1
  10. package/build/components/page-attributes/order.js +3 -7
  11. package/build/components/page-attributes/order.js.map +1 -1
  12. package/build/components/page-attributes/parent.js +8 -4
  13. package/build/components/page-attributes/parent.js.map +1 -1
  14. package/build/components/post-format/index.js +5 -8
  15. package/build/components/post-format/index.js.map +1 -1
  16. package/build/components/post-locked-modal/index.js +1 -1
  17. package/build/components/post-locked-modal/index.js.map +1 -1
  18. package/build/components/post-publish-panel/maybe-category-panel.js +2 -4
  19. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  20. package/build/components/post-schedule/label.js +93 -13
  21. package/build/components/post-schedule/label.js.map +1 -1
  22. package/build/components/post-slug/index.js +8 -13
  23. package/build/components/post-slug/index.js.map +1 -1
  24. package/build/components/post-taxonomies/flat-term-selector.js +8 -4
  25. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  26. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -0
  27. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  28. package/build/components/post-taxonomies/index.js +3 -1
  29. package/build/components/post-taxonomies/index.js.map +1 -1
  30. package/build/components/post-template/index.js +1 -2
  31. package/build/components/post-template/index.js.map +1 -1
  32. package/build/components/post-title/index.js +8 -2
  33. package/build/components/post-title/index.js.map +1 -1
  34. package/build/components/post-url/check.js +54 -0
  35. package/build/components/post-url/check.js.map +1 -0
  36. package/build/components/post-url/index.js +115 -0
  37. package/build/components/post-url/index.js.map +1 -0
  38. package/build/components/post-url/label.js +30 -0
  39. package/build/components/post-url/label.js.map +1 -0
  40. package/build/components/post-visibility/index.js +3 -1
  41. package/build/components/post-visibility/index.js.map +1 -1
  42. package/build/components/post-visibility/label.js +5 -0
  43. package/build/components/post-visibility/label.js.map +1 -1
  44. package/build/components/provider/index.native.js +3 -2
  45. package/build/components/provider/index.native.js.map +1 -1
  46. package/build/components/provider/use-block-editor-settings.js +2 -2
  47. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  48. package/build/components/table-of-contents/panel.js +5 -1
  49. package/build/components/table-of-contents/panel.js.map +1 -1
  50. package/build/components/time-to-read/index.js +60 -0
  51. package/build/components/time-to-read/index.js.map +1 -0
  52. package/build/store/actions.js +5 -1
  53. package/build/store/actions.js.map +1 -1
  54. package/build/store/reducer.js +1 -1
  55. package/build/store/reducer.js.map +1 -1
  56. package/build/store/selectors.js +3 -3
  57. package/build/store/selectors.js.map +1 -1
  58. package/build-module/components/document-outline/index.js +7 -8
  59. package/build-module/components/document-outline/index.js.map +1 -1
  60. package/build-module/components/error-boundary/index.js +2 -0
  61. package/build-module/components/error-boundary/index.js.map +1 -1
  62. package/build-module/components/index.js +7 -4
  63. package/build-module/components/index.js.map +1 -1
  64. package/build-module/components/local-autosave-monitor/index.js +24 -18
  65. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  66. package/build-module/components/page-attributes/order.js +3 -6
  67. package/build-module/components/page-attributes/order.js.map +1 -1
  68. package/build-module/components/page-attributes/parent.js +6 -5
  69. package/build-module/components/page-attributes/parent.js.map +1 -1
  70. package/build-module/components/post-format/index.js +5 -8
  71. package/build-module/components/post-format/index.js.map +1 -1
  72. package/build-module/components/post-locked-modal/index.js +1 -1
  73. package/build-module/components/post-locked-modal/index.js.map +1 -1
  74. package/build-module/components/post-publish-panel/maybe-category-panel.js +2 -4
  75. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  76. package/build-module/components/post-schedule/label.js +90 -13
  77. package/build-module/components/post-schedule/label.js.map +1 -1
  78. package/build-module/components/post-slug/index.js +8 -14
  79. package/build-module/components/post-slug/index.js.map +1 -1
  80. package/build-module/components/post-taxonomies/flat-term-selector.js +8 -6
  81. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  82. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  83. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  84. package/build-module/components/post-taxonomies/index.js +4 -1
  85. package/build-module/components/post-taxonomies/index.js.map +1 -1
  86. package/build-module/components/post-template/index.js +1 -2
  87. package/build-module/components/post-template/index.js.map +1 -1
  88. package/build-module/components/post-title/index.js +8 -2
  89. package/build-module/components/post-title/index.js.map +1 -1
  90. package/build-module/components/post-url/check.js +44 -0
  91. package/build-module/components/post-url/check.js.map +1 -0
  92. package/build-module/components/post-url/index.js +102 -0
  93. package/build-module/components/post-url/index.js.map +1 -0
  94. package/build-module/components/post-url/label.js +18 -0
  95. package/build-module/components/post-url/label.js.map +1 -0
  96. package/build-module/components/post-visibility/index.js +4 -2
  97. package/build-module/components/post-visibility/index.js.map +1 -1
  98. package/build-module/components/post-visibility/label.js +3 -0
  99. package/build-module/components/post-visibility/label.js.map +1 -1
  100. package/build-module/components/provider/index.native.js +3 -2
  101. package/build-module/components/provider/index.native.js.map +1 -1
  102. package/build-module/components/provider/use-block-editor-settings.js +2 -2
  103. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  104. package/build-module/components/table-of-contents/panel.js +4 -1
  105. package/build-module/components/table-of-contents/panel.js.map +1 -1
  106. package/build-module/components/time-to-read/index.js +50 -0
  107. package/build-module/components/time-to-read/index.js.map +1 -0
  108. package/build-module/store/actions.js +5 -1
  109. package/build-module/store/actions.js.map +1 -1
  110. package/build-module/store/reducer.js +2 -2
  111. package/build-module/store/reducer.js.map +1 -1
  112. package/build-module/store/selectors.js +4 -4
  113. package/build-module/store/selectors.js.map +1 -1
  114. package/build-style/style-rtl.css +19 -18
  115. package/build-style/style.css +23 -18
  116. package/package.json +30 -29
  117. package/src/components/README.md +1 -1
  118. package/src/components/document-outline/index.js +9 -8
  119. package/src/components/error-boundary/index.js +3 -0
  120. package/src/components/index.js +13 -4
  121. package/src/components/local-autosave-monitor/index.js +24 -18
  122. package/src/components/page-attributes/order.js +1 -9
  123. package/src/components/page-attributes/parent.js +6 -13
  124. package/src/components/post-format/index.js +13 -19
  125. package/src/components/post-format/style.scss +2 -17
  126. package/src/components/post-locked-modal/index.js +1 -1
  127. package/src/components/post-publish-panel/maybe-category-panel.js +7 -6
  128. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +1 -1
  129. package/src/components/post-schedule/label.js +111 -17
  130. package/src/components/post-schedule/test/label.js +127 -15
  131. package/src/components/post-slug/index.js +7 -13
  132. package/src/components/post-slug/test/index.js +7 -6
  133. package/src/components/post-taxonomies/flat-term-selector.js +6 -5
  134. package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -1
  135. package/src/components/post-taxonomies/index.js +3 -1
  136. package/src/components/post-template/index.js +1 -1
  137. package/src/components/post-title/index.js +8 -2
  138. package/src/components/post-title/style.scss +1 -1
  139. package/src/components/post-trash/style.scss +3 -0
  140. package/src/components/post-url/check.js +38 -0
  141. package/src/components/post-url/index.js +122 -0
  142. package/src/components/post-url/label.js +22 -0
  143. package/src/components/post-url/style.scss +16 -0
  144. package/src/components/post-visibility/index.js +2 -2
  145. package/src/components/post-visibility/label.js +4 -0
  146. package/src/components/provider/index.native.js +4 -8
  147. package/src/components/provider/use-block-editor-settings.js +4 -1
  148. package/src/components/table-of-contents/panel.js +7 -2
  149. package/src/components/time-to-read/index.js +59 -0
  150. package/src/store/actions.js +3 -1
  151. package/src/store/reducer.js +2 -2
  152. package/src/store/selectors.js +5 -6
  153. package/src/store/test/selectors.js +8 -10
  154. package/src/style.scss +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 12.13.0 (2022-07-27)
6
+
7
+ ## 12.12.0 (2022-07-13)
8
+
9
+ ## 12.11.0 (2022-06-29)
10
+
5
11
  ## 12.10.0 (2022-06-15)
6
12
 
7
13
  ## 12.9.0 (2022-06-01)
@@ -9,8 +9,6 @@ exports.default = exports.DocumentOutline = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
- var _lodash = require("lodash");
13
-
14
12
  var _i18n = require("@wordpress/i18n");
15
13
 
16
14
  var _compose = require("@wordpress/compose");
@@ -27,10 +25,6 @@ var _item = _interopRequireDefault(require("./item"));
27
25
 
28
26
  var _store = require("../../store");
29
27
 
30
- /**
31
- * External dependencies
32
- */
33
-
34
28
  /**
35
29
  * WordPress dependencies
36
30
  */
@@ -70,7 +64,7 @@ const multipleH1Headings = [(0, _element.createElement)("br", {
70
64
 
71
65
  const computeOutlineHeadings = function () {
72
66
  let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
73
- return (0, _lodash.flatMap)(blocks, function () {
67
+ return blocks.flatMap(function () {
74
68
  let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
75
69
 
76
70
  if (block.name === 'core/heading') {
@@ -104,7 +98,9 @@ const DocumentOutline = _ref => {
104
98
 
105
99
  const titleNode = document.querySelector('.editor-post-title__input');
106
100
  const hasTitle = isTitleSupported && title && titleNode;
107
- const countByLevel = (0, _lodash.countBy)(headings, 'level');
101
+ const countByLevel = headings.reduce((acc, heading) => ({ ...acc,
102
+ [heading.level]: (acc[heading.level] || 0) + 1
103
+ }), {});
108
104
  const hasMultipleH1 = countByLevel[1] > 1;
109
105
  return (0, _element.createElement)("div", {
110
106
  className: "document-outline"
@@ -136,6 +132,8 @@ const DocumentOutline = _ref => {
136
132
  exports.DocumentOutline = DocumentOutline;
137
133
 
138
134
  var _default = (0, _compose.compose)((0, _data.withSelect)(select => {
135
+ var _postType$supports$ti, _postType$supports;
136
+
139
137
  const {
140
138
  getBlocks
141
139
  } = select(_blockEditor.store);
@@ -149,7 +147,7 @@ var _default = (0, _compose.compose)((0, _data.withSelect)(select => {
149
147
  return {
150
148
  title: getEditedPostAttribute('title'),
151
149
  blocks: getBlocks(),
152
- isTitleSupported: (0, _lodash.get)(postType, ['supports', 'title'], false)
150
+ isTitleSupported: (_postType$supports$ti = postType === null || postType === void 0 ? void 0 : (_postType$supports = postType.supports) === null || _postType$supports === void 0 ? void 0 : _postType$supports.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
153
151
  };
154
152
  }))(DocumentOutline);
155
153
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/document-outline/index.js"],"names":["emptyHeadingContent","incorrectLevelContent","singleH1Headings","multipleH1Headings","computeOutlineHeadings","blocks","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","length","DocumentOutline","title","onSelect","isTitleSupported","hasOutlineItemsDisabled","headings","prevHeadingLevel","titleNode","document","querySelector","hasTitle","countByLevel","hasMultipleH1","id","map","item","index","isIncorrectLevel","isValid","clientId","html","select","getBlocks","blockEditorStore","getEditedPostAttribute","editorStore","getPostType","coreStore","postType"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,wCAAM,cAAI,iBAAJ,CAAN,CAA5B;AACA,MAAMC,qBAAqB,GAAG,CAC7B;AAAI,EAAA,GAAG,EAAC;AAAR,EAD6B,EAE7B;AAAI,EAAA,GAAG,EAAC;AAAR,GAA8B,cAAI,2BAAJ,CAA9B,CAF6B,CAA9B;AAIA,MAAMC,gBAAgB,GAAG,CACxB;AAAI,EAAA,GAAG,EAAC;AAAR,EADwB,EAExB;AAAI,EAAA,GAAG,EAAC;AAAR,GACG,cAAI,sDAAJ,CADH,CAFwB,CAAzB;AA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R,CADA,CAVJ,EAeGmB,gBAAgB,IAAIhC,qBAfvB,EAgBG8B,IAAI,CAACvB,KAAL,KAAe,CAAf,IACDoB,aADC,IAEDzB,kBAlBF,EAmBGuB,QAAQ,IACTK,IAAI,CAACvB,KAAL,KAAe,CADd,IAED,CAAEoB,aAFD,IAGD1B,gBAtBF,CADD;AA0BA,GAvCC,CAZH,CADD,CADD;AAyDA,CA9EM;;;;eAgFQ,sBACd,sBAAcmC,MAAF,IAAc;AACzB,QAAM;AAAEC,IAAAA;AAAF,MAAgBD,MAAM,CAAEE,kBAAF,CAA5B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6BH,MAAM,CAAEI,YAAF,CAAzC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAkBL,MAAM,CAAEM,eAAF,CAA9B;AACA,QAAMC,QAAQ,GAAGF,WAAW,CAAEF,sBAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,SAAO;AACNvB,IAAAA,KAAK,EAAEuB,sBAAsB,CAAE,OAAF,CADvB;AAENnC,IAAAA,MAAM,EAAEiC,SAAS,EAFX;AAGNnB,IAAAA,gBAAgB,EAAE,iBAAKyB,QAAL,EAAe,CAAE,UAAF,EAAc,OAAd,CAAf,EAAwC,KAAxC;AAHZ,GAAP;AAKA,CAXD,CADc,EAaZ5B,eAbY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { countBy, flatMap, get } from 'lodash';\n\n/**\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 flatMap( blocks, ( 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 = countBy( headings, 'level' );\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: get( 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":["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","blockEditorStore","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","supports"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,wCAAM,cAAI,iBAAJ,CAAN,CAA5B;AACA,MAAMC,qBAAqB,GAAG,CAC7B;AAAI,EAAA,GAAG,EAAC;AAAR,EAD6B,EAE7B;AAAI,EAAA,GAAG,EAAC;AAAR,GAA8B,cAAI,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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"]}
@@ -17,6 +17,8 @@ var _blockEditor = require("@wordpress/block-editor");
17
17
 
18
18
  var _compose = require("@wordpress/compose");
19
19
 
20
+ var _hooks = require("@wordpress/hooks");
21
+
20
22
  var _store = require("../../store");
21
23
 
22
24
  /**
@@ -52,6 +54,7 @@ class ErrorBoundary extends _element.Component {
52
54
  this.setState({
53
55
  error
54
56
  });
57
+ (0, _hooks.doAction)('editor.ErrorBoundary.errorLogged', error);
55
58
  }
56
59
 
57
60
  reboot() {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["CopyButton","text","children","ref","ErrorBoundary","Component","constructor","arguments","reboot","bind","getContent","state","error","componentDidCatch","setState","props","onError","editorStore","getEditedPostContent","render","stack"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGA,SAASA,UAAT,OAA0C;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AACzC,QAAMC,GAAG,GAAG,iCAAoBF,IAApB,CAAZ;AACA,SACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,MAAME,aAAN,SAA4BC,kBAA5B,CAAsC;AACrCC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AACA,SAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBD,IAAhB,CAAsB,IAAtB,CAAlB;AAEA,SAAKE,KAAL,GAAa;AACZC,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDC,EAAAA,iBAAiB,CAAED,KAAF,EAAU;AAC1B,SAAKE,QAAL,CAAe;AAAEF,MAAAA;AAAF,KAAf;AACA;;AAEDJ,EAAAA,MAAM,GAAG;AACR,SAAKO,KAAL,CAAWC,OAAX;AACA;;AAEDN,EAAAA,UAAU,GAAG;AACZ,QAAI;AACH;AACA;AACA;AACA;AACA;AACA;AACA,aAAO,kBAAQO,YAAR,EAAsBC,oBAAtB,EAAP;AACA,KARD,CAQE,OAAQN,KAAR,EAAgB,CAAE;AACpB;;AAEDO,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEP,MAAAA;AAAF,QAAY,KAAKD,KAAvB;;AACA,QAAK,CAAEC,KAAP,EAAe;AACd,aAAO,KAAKG,KAAL,CAAWb,QAAlB;AACA;;AAED,WACC,4BAAC,oBAAD;AACC,MAAA,SAAS,EAAC,uBADX;AAEC,MAAA,OAAO,EAAG,CACT,4BAAC,kBAAD;AACC,QAAA,GAAG,EAAC,UADL;AAEC,QAAA,OAAO,EAAG,KAAKM,MAFhB;AAGC,QAAA,OAAO,EAAC;AAHT,SAKG,cAAI,kBAAJ,CALH,CADS,EAQT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,WAAhB;AAA4B,QAAA,IAAI,EAAG,KAAKE;AAAxC,SACG,cAAI,gBAAJ,CADH,CARS,EAWT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,YAAhB;AAA6B,QAAA,IAAI,EAAGE,KAAK,CAACQ;AAA1C,SACG,cAAI,YAAJ,CADH,CAXS;AAFX,OAkBG,cAAI,iDAAJ,CAlBH,CADD;AAsBA;;AA5DoC;;eA+DvBhB,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { select } from '@wordpress/data';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.reboot = this.reboot.bind( this );\n\t\tthis.getContent = this.getContent.bind( this );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tthis.setState( { error } );\n\t}\n\n\treboot() {\n\t\tthis.props.onError();\n\t}\n\n\tgetContent() {\n\t\ttry {\n\t\t\t// While `select` in a component is generally discouraged, it is\n\t\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t\t// case of additional errors by performing a direct retrieval and\n\t\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t\t// application.\n\t\t\treturn select( editorStore ).getEditedPostContent();\n\t\t} catch ( error ) {}\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tclassName=\"editor-error-boundary\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"recovery\"\n\t\t\t\t\t\tonClick={ this.reboot }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Attempt Recovery' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<CopyButton key=\"copy-post\" text={ this.getContent }>\n\t\t\t\t\t\t{ __( 'Copy Post Text' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n\nexport default ErrorBoundary;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["CopyButton","text","children","ref","ErrorBoundary","Component","constructor","arguments","reboot","bind","getContent","state","error","componentDidCatch","setState","props","onError","editorStore","getEditedPostContent","render","stack"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AA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hB;AAGC,QAAA,OAAO,EAAC;AAHT,SAKG,cAAI,kBAAJ,CALH,CADS,EAQT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,WAAhB;AAA4B,QAAA,IAAI,EAAG,KAAKE;AAAxC,SACG,cAAI,gBAAJ,CADH,CARS,EAWT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,YAAhB;AAA6B,QAAA,IAAI,EAAGE,KAAK,CAACQ;AAA1C,SACG,cAAI,YAAJ,CADH,CAXS;AAFX,OAkBG,cAAI,iDAAJ,CAlBH,CADD;AAsBA;;AA9DoC;;eAiEvBhB,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { select } from '@wordpress/data';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.reboot = this.reboot.bind( this );\n\t\tthis.getContent = this.getContent.bind( this );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tthis.setState( { error } );\n\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\treboot() {\n\t\tthis.props.onError();\n\t}\n\n\tgetContent() {\n\t\ttry {\n\t\t\t// While `select` in a component is generally discouraged, it is\n\t\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t\t// case of additional errors by performing a direct retrieval and\n\t\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t\t// application.\n\t\t\treturn select( editorStore ).getEditedPostContent();\n\t\t} catch ( error ) {}\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tclassName=\"editor-error-boundary\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"recovery\"\n\t\t\t\t\t\tonClick={ this.reboot }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Attempt Recovery' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<CopyButton key=\"copy-post\" text={ this.getContent }>\n\t\t\t\t\t\t{ __( 'Copy Post Text' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n\nexport default ErrorBoundary;\n"]}
@@ -46,6 +46,7 @@ var _exportNames = {
46
46
  PostSchedule: true,
47
47
  PostScheduleCheck: true,
48
48
  PostScheduleLabel: true,
49
+ usePostScheduleLabel: true,
49
50
  PostSlug: true,
50
51
  PostSlugCheck: true,
51
52
  PostSticky: true,
@@ -60,8 +61,13 @@ var _exportNames = {
60
61
  PostTrash: true,
61
62
  PostTrashCheck: true,
62
63
  PostTypeSupportCheck: true,
64
+ PostURL: true,
65
+ PostURLCheck: true,
66
+ PostURLLabel: true,
67
+ usePostURLLabel: true,
63
68
  PostVisibility: true,
64
69
  PostVisibilityLabel: true,
70
+ usePostVisibilityLabel: true,
65
71
  PostVisibilityCheck: true,
66
72
  TableOfContents: true,
67
73
  ThemeSupportCheck: true,
@@ -348,13 +354,13 @@ Object.defineProperty(exports, "PostTaxonomiesCheck", {
348
354
  Object.defineProperty(exports, "PostTaxonomiesFlatTermSelector", {
349
355
  enumerable: true,
350
356
  get: function () {
351
- return _flatTermSelector.default;
357
+ return _flatTermSelector.FlatTermSelector;
352
358
  }
353
359
  });
354
360
  Object.defineProperty(exports, "PostTaxonomiesHierarchicalTermSelector", {
355
361
  enumerable: true,
356
362
  get: function () {
357
- return _hierarchicalTermSelector.default;
363
+ return _hierarchicalTermSelector.HierarchicalTermSelector;
358
364
  }
359
365
  });
360
366
  Object.defineProperty(exports, "PostTextEditor", {
@@ -387,6 +393,24 @@ Object.defineProperty(exports, "PostTypeSupportCheck", {
387
393
  return _postTypeSupportCheck.default;
388
394
  }
389
395
  });
396
+ Object.defineProperty(exports, "PostURL", {
397
+ enumerable: true,
398
+ get: function () {
399
+ return _postUrl.default;
400
+ }
401
+ });
402
+ Object.defineProperty(exports, "PostURLCheck", {
403
+ enumerable: true,
404
+ get: function () {
405
+ return _check14.default;
406
+ }
407
+ });
408
+ Object.defineProperty(exports, "PostURLLabel", {
409
+ enumerable: true,
410
+ get: function () {
411
+ return _label3.default;
412
+ }
413
+ });
390
414
  Object.defineProperty(exports, "PostVisibility", {
391
415
  enumerable: true,
392
416
  get: function () {
@@ -396,13 +420,13 @@ Object.defineProperty(exports, "PostVisibility", {
396
420
  Object.defineProperty(exports, "PostVisibilityCheck", {
397
421
  enumerable: true,
398
422
  get: function () {
399
- return _check14.default;
423
+ return _check15.default;
400
424
  }
401
425
  });
402
426
  Object.defineProperty(exports, "PostVisibilityLabel", {
403
427
  enumerable: true,
404
428
  get: function () {
405
- return _label3.default;
429
+ return _label4.default;
406
430
  }
407
431
  });
408
432
  Object.defineProperty(exports, "TableOfContents", {
@@ -441,6 +465,24 @@ Object.defineProperty(exports, "WordCount", {
441
465
  return _wordCount.default;
442
466
  }
443
467
  });
468
+ Object.defineProperty(exports, "usePostScheduleLabel", {
469
+ enumerable: true,
470
+ get: function () {
471
+ return _label2.usePostScheduleLabel;
472
+ }
473
+ });
474
+ Object.defineProperty(exports, "usePostURLLabel", {
475
+ enumerable: true,
476
+ get: function () {
477
+ return _label3.usePostURLLabel;
478
+ }
479
+ });
480
+ Object.defineProperty(exports, "usePostVisibilityLabel", {
481
+ enumerable: true,
482
+ get: function () {
483
+ return _label4.usePostVisibilityLabel;
484
+ }
485
+ });
444
486
 
445
487
  var _autocompleters = require("./autocompleters");
446
488
 
@@ -534,7 +576,7 @@ var _postSchedule = _interopRequireDefault(require("./post-schedule"));
534
576
 
535
577
  var _check9 = _interopRequireDefault(require("./post-schedule/check"));
536
578
 
537
- var _label2 = _interopRequireDefault(require("./post-schedule/label"));
579
+ var _label2 = _interopRequireWildcard(require("./post-schedule/label"));
538
580
 
539
581
  var _postSlug = _interopRequireDefault(require("./post-slug"));
540
582
 
@@ -548,9 +590,9 @@ var _postSwitchToDraftButton = _interopRequireDefault(require("./post-switch-to-
548
590
 
549
591
  var _postTaxonomies = _interopRequireDefault(require("./post-taxonomies"));
550
592
 
551
- var _flatTermSelector = _interopRequireDefault(require("./post-taxonomies/flat-term-selector"));
593
+ var _flatTermSelector = require("./post-taxonomies/flat-term-selector");
552
594
 
553
- var _hierarchicalTermSelector = _interopRequireDefault(require("./post-taxonomies/hierarchical-term-selector"));
595
+ var _hierarchicalTermSelector = require("./post-taxonomies/hierarchical-term-selector");
554
596
 
555
597
  var _check12 = _interopRequireDefault(require("./post-taxonomies/check"));
556
598
 
@@ -564,11 +606,17 @@ var _check13 = _interopRequireDefault(require("./post-trash/check"));
564
606
 
565
607
  var _postTypeSupportCheck = _interopRequireDefault(require("./post-type-support-check"));
566
608
 
609
+ var _postUrl = _interopRequireDefault(require("./post-url"));
610
+
611
+ var _check14 = _interopRequireDefault(require("./post-url/check"));
612
+
613
+ var _label3 = _interopRequireWildcard(require("./post-url/label"));
614
+
567
615
  var _postVisibility = _interopRequireDefault(require("./post-visibility"));
568
616
 
569
- var _label3 = _interopRequireDefault(require("./post-visibility/label"));
617
+ var _label4 = _interopRequireWildcard(require("./post-visibility/label"));
570
618
 
571
- var _check14 = _interopRequireDefault(require("./post-visibility/check"));
619
+ var _check15 = _interopRequireDefault(require("./post-visibility/check"));
572
620
 
573
621
  var _tableOfContents = _interopRequireDefault(require("./table-of-contents"));
574
622
 
@@ -593,4 +641,8 @@ Object.keys(_deprecated).forEach(function (key) {
593
641
  }
594
642
  });
595
643
  });
644
+
645
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
646
+
647
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
596
648
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// Block Creation Components.\nexport * from './autocompleters';\n\n// Post Related Components.\nexport { default as AutosaveMonitor } from './autosave-monitor';\nexport { default as DocumentOutline } from './document-outline';\nexport { default as DocumentOutlineCheck } from './document-outline/check';\nexport { default as VisualEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/visual-editor-shortcuts';\nexport { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts';\nexport { default as EditorKeyboardShortcutsRegister } from './global-keyboard-shortcuts/register-shortcuts';\nexport { default as EditorHistoryRedo } from './editor-history/redo';\nexport { default as EditorHistoryUndo } from './editor-history/undo';\nexport { default as EditorNotices } from './editor-notices';\nexport { default as EditorSnackbars } from './editor-snackbars';\nexport { default as EntitiesSavedStates } from './entities-saved-states';\nexport { default as ErrorBoundary } from './error-boundary';\nexport { default as LocalAutosaveMonitor } from './local-autosave-monitor';\nexport { default as PageAttributesCheck } from './page-attributes/check';\nexport { default as PageAttributesOrder } from './page-attributes/order';\nexport { default as PageAttributesParent } from './page-attributes/parent';\nexport { default as PageTemplate } from './post-template';\nexport { default as PostAuthor } from './post-author';\nexport { default as PostAuthorCheck } from './post-author/check';\nexport { default as PostComments } from './post-comments';\nexport { default as PostExcerpt } from './post-excerpt';\nexport { default as PostExcerptCheck } from './post-excerpt/check';\nexport { default as PostFeaturedImage } from './post-featured-image';\nexport { default as PostFeaturedImageCheck } from './post-featured-image/check';\nexport { default as PostFormat } from './post-format';\nexport { default as PostFormatCheck } from './post-format/check';\nexport { default as PostLastRevision } from './post-last-revision';\nexport { default as PostLastRevisionCheck } from './post-last-revision/check';\nexport { default as PostLockedModal } from './post-locked-modal';\nexport { default as PostPendingStatus } from './post-pending-status';\nexport { default as PostPendingStatusCheck } from './post-pending-status/check';\nexport { default as PostPingbacks } from './post-pingbacks';\nexport { default as PostPreviewButton } from './post-preview-button';\nexport { default as PostPublishButton } from './post-publish-button';\nexport { default as PostPublishButtonLabel } from './post-publish-button/label';\nexport { default as PostPublishPanel } from './post-publish-panel';\nexport { default as PostSavedState } from './post-saved-state';\nexport { default as PostSchedule } from './post-schedule';\nexport { default as PostScheduleCheck } from './post-schedule/check';\nexport { default as PostScheduleLabel } from './post-schedule/label';\nexport { default as PostSlug } from './post-slug';\nexport { default as PostSlugCheck } from './post-slug/check';\nexport { default as PostSticky } from './post-sticky';\nexport { default as PostStickyCheck } from './post-sticky/check';\nexport { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';\nexport { default as PostTaxonomies } from './post-taxonomies';\nexport { default as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';\nexport { default as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';\nexport { default as PostTaxonomiesCheck } from './post-taxonomies/check';\nexport { default as PostTextEditor } from './post-text-editor';\nexport { default as PostTitle } from './post-title';\nexport { default as PostTrash } from './post-trash';\nexport { default as PostTrashCheck } from './post-trash/check';\nexport { default as PostTypeSupportCheck } from './post-type-support-check';\nexport { default as PostVisibility } from './post-visibility';\nexport { default as PostVisibilityLabel } from './post-visibility/label';\nexport { default as PostVisibilityCheck } from './post-visibility/check';\nexport { default as TableOfContents } from './table-of-contents';\nexport { default as ThemeSupportCheck } from './theme-support-check';\nexport { default as UnsavedChangesWarning } from './unsaved-changes-warning';\nexport { default as WordCount } from './word-count';\n\n// State Related Components.\nexport { default as EditorProvider } from './provider';\n\nexport * from './deprecated';\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// Block Creation Components.\nexport * from './autocompleters';\n\n// Post Related Components.\nexport { default as AutosaveMonitor } from './autosave-monitor';\nexport { default as DocumentOutline } from './document-outline';\nexport { default as DocumentOutlineCheck } from './document-outline/check';\nexport { default as VisualEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/visual-editor-shortcuts';\nexport { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts';\nexport { default as EditorKeyboardShortcutsRegister } from './global-keyboard-shortcuts/register-shortcuts';\nexport { default as EditorHistoryRedo } from './editor-history/redo';\nexport { default as EditorHistoryUndo } from './editor-history/undo';\nexport { default as EditorNotices } from './editor-notices';\nexport { default as EditorSnackbars } from './editor-snackbars';\nexport { default as EntitiesSavedStates } from './entities-saved-states';\nexport { default as ErrorBoundary } from './error-boundary';\nexport { default as LocalAutosaveMonitor } from './local-autosave-monitor';\nexport { default as PageAttributesCheck } from './page-attributes/check';\nexport { default as PageAttributesOrder } from './page-attributes/order';\nexport { default as PageAttributesParent } from './page-attributes/parent';\nexport { default as PageTemplate } from './post-template';\nexport { default as PostAuthor } from './post-author';\nexport { default as PostAuthorCheck } from './post-author/check';\nexport { default as PostComments } from './post-comments';\nexport { default as PostExcerpt } from './post-excerpt';\nexport { default as PostExcerptCheck } from './post-excerpt/check';\nexport { default as PostFeaturedImage } from './post-featured-image';\nexport { default as PostFeaturedImageCheck } from './post-featured-image/check';\nexport { default as PostFormat } from './post-format';\nexport { default as PostFormatCheck } from './post-format/check';\nexport { default as PostLastRevision } from './post-last-revision';\nexport { default as PostLastRevisionCheck } from './post-last-revision/check';\nexport { default as PostLockedModal } from './post-locked-modal';\nexport { default as PostPendingStatus } from './post-pending-status';\nexport { default as PostPendingStatusCheck } from './post-pending-status/check';\nexport { default as PostPingbacks } from './post-pingbacks';\nexport { default as PostPreviewButton } from './post-preview-button';\nexport { default as PostPublishButton } from './post-publish-button';\nexport { default as PostPublishButtonLabel } from './post-publish-button/label';\nexport { default as PostPublishPanel } from './post-publish-panel';\nexport { default as PostSavedState } from './post-saved-state';\nexport { default as PostSchedule } from './post-schedule';\nexport { default as PostScheduleCheck } from './post-schedule/check';\nexport {\n\tdefault as PostScheduleLabel,\n\tusePostScheduleLabel,\n} from './post-schedule/label';\nexport { default as PostSlug } from './post-slug';\nexport { default as PostSlugCheck } from './post-slug/check';\nexport { default as PostSticky } from './post-sticky';\nexport { default as PostStickyCheck } from './post-sticky/check';\nexport { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';\nexport { default as PostTaxonomies } from './post-taxonomies';\nexport { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';\nexport { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';\nexport { default as PostTaxonomiesCheck } from './post-taxonomies/check';\nexport { default as PostTextEditor } from './post-text-editor';\nexport { default as PostTitle } from './post-title';\nexport { default as PostTrash } from './post-trash';\nexport { default as PostTrashCheck } from './post-trash/check';\nexport { default as PostTypeSupportCheck } from './post-type-support-check';\nexport { default as PostURL } from './post-url';\nexport { default as PostURLCheck } from './post-url/check';\nexport { default as PostURLLabel, usePostURLLabel } from './post-url/label';\nexport { default as PostVisibility } from './post-visibility';\nexport {\n\tdefault as PostVisibilityLabel,\n\tusePostVisibilityLabel,\n} from './post-visibility/label';\nexport { default as PostVisibilityCheck } from './post-visibility/check';\nexport { default as TableOfContents } from './table-of-contents';\nexport { default as ThemeSupportCheck } from './theme-support-check';\nexport { default as UnsavedChangesWarning } from './unsaved-changes-warning';\nexport { default as WordCount } from './word-count';\n\n// State Related Components.\nexport { default as EditorProvider } from './provider';\n\nexport * from './deprecated';\n"]}
@@ -9,8 +9,6 @@ exports.default = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
- var _lodash = require("lodash");
13
-
14
12
  var _compose = require("@wordpress/compose");
15
13
 
16
14
  var _data = require("@wordpress/data");
@@ -27,10 +25,6 @@ var _localAutosave = require("../../store/local-autosave");
27
25
 
28
26
  var _store = require("../../store");
29
27
 
30
- /**
31
- * External dependencies
32
- */
33
-
34
28
  /**
35
29
  * WordPress dependencies
36
30
  */
@@ -39,29 +33,36 @@ var _store = require("../../store");
39
33
  * Internal dependencies
40
34
  */
41
35
  const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
36
+ let hasStorageSupport;
37
+ let uniqueId = 0;
42
38
  /**
43
39
  * Function which returns true if the current environment supports browser
44
40
  * sessionStorage, or false otherwise. The result of this function is cached and
45
41
  * reused in subsequent invocations.
46
42
  */
47
43
 
48
- const hasSessionStorageSupport = (0, _lodash.once)(() => {
49
- try {
50
- // Private Browsing in Safari 10 and earlier will throw an error when
51
- // attempting to set into sessionStorage. The test here is intentional in
52
- // causing a thrown error as condition bailing from local autosave.
53
- window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
54
- window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
55
- return true;
56
- } catch (error) {
57
- return false;
44
+ const hasSessionStorageSupport = () => {
45
+ if (typeof hasStorageSupport === 'undefined') {
46
+ try {
47
+ // Private Browsing in Safari 10 and earlier will throw an error when
48
+ // attempting to set into sessionStorage. The test here is intentional in
49
+ // causing a thrown error as condition bailing from local autosave.
50
+ window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
51
+ window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
52
+ hasStorageSupport = true;
53
+ } catch (error) {
54
+ hasStorageSupport = false;
55
+ }
58
56
  }
59
- });
57
+
58
+ return hasStorageSupport;
59
+ };
60
60
  /**
61
61
  * Custom hook which manages the creation of a notice prompting the user to
62
62
  * restore a local autosave, if one exists.
63
63
  */
64
64
 
65
+
65
66
  function useAutosaveNotice() {
66
67
  const {
67
68
  postId,
@@ -125,14 +126,18 @@ function useAutosaveNotice() {
125
126
  return;
126
127
  }
127
128
 
128
- const noticeId = (0, _lodash.uniqueId)('wpEditorAutosaveRestore');
129
+ const noticeId = `wpEditorAutosaveRestore${++uniqueId}`;
129
130
  createWarningNotice((0, _i18n.__)('The backup of this post in your browser is different from the version below.'), {
130
131
  id: noticeId,
131
132
  actions: [{
132
133
  label: (0, _i18n.__)('Restore the backup'),
133
134
 
134
135
  onClick() {
135
- editPost((0, _lodash.omit)(edits, ['content']));
136
+ const {
137
+ content: editsContent,
138
+ ...editsWithoutContent
139
+ } = edits;
140
+ editPost(editsWithoutContent);
136
141
  resetEditorBlocks((0, _blocks.parse)(edits.content));
137
142
  removeNotice(noticeId);
138
143
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","editorStore","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","noticesStore","editPost","resetEditorBlocks","localAutosave","JSON","parse","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval"],"mappings":";;;;;;;;;AAQA;;AALA;;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0BAAW,MAAM;AAChB,QAAK2C,UAAU,KAAK3C,MAAf,IAAyB0C,gBAAzB,IAA6C,CAAEzC,eAApD,EAAsE;AACrE,6CAAoBD,MAApB,EAA4B,IAA5B;AACA;AACD,GAJD,EAIG,CAAEC,eAAF,EAAmBD,MAAnB,CAJH;AAKA;;AAED,SAAS4C,oBAAT,GAAgC;AAC/B,QAAM;AAAErC,IAAAA;AAAF,MAAe,uBAAaH,YAAb,CAArB;AACA,QAAMyC,gBAAgB,GAAG,0BAAa,MAAM;AAC3CtD,IAAAA,mBAAmB,CAAE,MAAMgB,QAAQ,CAAE;AAAEuC,MAAAA,KAAK,EAAE;AAAT,KAAF,CAAhB,CAAnB;AACA,GAFwB,EAEtB,EAFsB,CAAzB;AAGA/C,EAAAA,iBAAiB;AACjBiC,EAAAA,gBAAgB;AAEhB,QAAM;AAAEe,IAAAA;AAAF,MAA4B,qBAC/B5C,MAAF,KAAgB;AACf4C,IAAAA,qBAAqB,EACpB5C,MAAM,CAAEC,YAAF,CAAN,CAAsBE,iBAAtB,GAA0CyC;AAF5B,GAAhB,CADiC,EAKjC,EALiC,CAAlC;AAQA,SACC,4BAAC,wBAAD;AACC,IAAA,QAAQ,EAAGA,qBADZ;AAEC,IAAA,QAAQ,EAAGF;AAFZ,IADD;AAMA;;eAEc,0BAAanD,wBAAb,EAAyCkD,oBAAzC,C","sourcesContent":["/**\n * External dependencies\n */\nimport { once, uniqueId, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport {\n\tlocalAutosaveGet,\n\tlocalAutosaveClear,\n} from '../../store/local-autosave';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave:\n\t\t\t\t!! select( editorStore ).getEditorSettings().autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst { postId, isEditedPostNew, isDirty, isAutosaving, didError } =\n\t\tuseSelect(\n\t\t\t( select ) => ( {\n\t\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval:\n\t\t\t\tselect( editorStore ).getEditorSettings().localAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["requestIdleCallback","window","requestAnimationFrame","hasStorageSupport","uniqueId","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","editorStore","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","noticesStore","editPost","resetEditorBlocks","localAutosave","JSON","parse","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","editsContent","editsWithoutContent","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AAlBA;AACA;AACA;;AAQA;AACA;AACA;AAQA,MAAMA,mBAAmB,GAAGC,MAAM,CAACD,mBAAP,GACzBC,MAAM,CAACD,mBADkB,GAEzBC,MAAM,CAACC,qBAFV;AAIA,IAAIC,iBAAJ;AACA,IAAIC,QAAQ,GAAG,CAAf;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,wBAAwB,GAAG,MAAM;AACtC,MAAK,OAAOF,iBAAP,KAA6B,WAAlC,EAAgD;AAC/C,QAAI;AACH;AACA;AACA;AACAF,MAAAA,MAAM,CAACK,cAAP,CAAsBC,OAAtB,CAA+B,8BAA/B,EAA+D,EAA/D;AACAN,MAAAA,MAAM,CAACK,cAAP,CAAsBE,UAAtB,CAAkC,8BAAlC;AACAL,MAAAA,iBAAiB,GAAG,IAApB;AACA,KAPD,CAOE,OAAQM,KAAR,EAAgB;AACjBN,MAAAA,iBAAiB,GAAG,KAApB;AACA;AACD;;AAED,SAAOA,iBAAP;AACA,CAfD;AAiBA;AACA;AACA;AACA;;;AACA,SAASO,iBAAT,GAA6B;AAC5B,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,eAAV;AAA2BC,IAAAA;AAA3B,MAAiD,qBACpDC,MAAF,KAAgB;AACfH,IAAAA,MAAM,EAAEG,MAAM,CAAEC,YAAF,CAAN,CAAsBC,gBAAtB,EADO;AAEfJ,IAAAA,eAAe,EAAEE,MAAM,CAAEC,YAAF,CAAN,CAAsBH,eAAtB,EAFF;AAGfC,IAAAA,iBAAiB,EAChB,CAAC,CAAEC,MAAM,CAAEC,YAAF,CAAN,CAAsBE,iB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\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport {\n\tlocalAutosaveGet,\n\tlocalAutosaveClear,\n} from '../../store/local-autosave';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\nlet hasStorageSupport;\nlet uniqueId = 0;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = () => {\n\tif ( typeof hasStorageSupport === 'undefined' ) {\n\t\ttry {\n\t\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t\t// causing a thrown error as condition bailing from local autosave.\n\t\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\t\thasStorageSupport = true;\n\t\t} catch ( error ) {\n\t\t\thasStorageSupport = false;\n\t\t}\n\t}\n\n\treturn hasStorageSupport;\n};\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave:\n\t\t\t\t!! select( editorStore ).getEditorSettings().autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = `wpEditorAutosaveRestore${ ++uniqueId }`;\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tcontent: editsContent,\n\t\t\t\t\t\t\t\t...editsWithoutContent\n\t\t\t\t\t\t\t} = edits;\n\t\t\t\t\t\t\teditPost( editsWithoutContent );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst { postId, isEditedPostNew, isDirty, isAutosaving, didError } =\n\t\tuseSelect(\n\t\t\t( select ) => ( {\n\t\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval:\n\t\t\t\tselect( editorStore ).getEditorSettings().localAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
@@ -9,8 +9,6 @@ exports.default = exports.PageAttributesOrder = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
- var _lodash = require("lodash");
13
-
14
12
  var _i18n = require("@wordpress/i18n");
15
13
 
16
14
  var _components = require("@wordpress/components");
@@ -23,10 +21,6 @@ var _postTypeSupportCheck = _interopRequireDefault(require("../post-type-support
23
21
 
24
22
  var _store = require("../../store");
25
23
 
26
- /**
27
- * External dependencies
28
- */
29
-
30
24
  /**
31
25
  * WordPress dependencies
32
26
  */
@@ -42,10 +36,12 @@ const PageAttributesOrder = _ref => {
42
36
  const [orderInput, setOrderInput] = (0, _element.useState)(null);
43
37
 
44
38
  const setUpdatedOrder = value => {
39
+ var _value$trim;
40
+
45
41
  setOrderInput(value);
46
42
  const newOrder = Number(value);
47
43
 
48
- if (Number.isInteger(newOrder) && (0, _lodash.invoke)(value, ['trim']) !== '') {
44
+ if (Number.isInteger(newOrder) && ((_value$trim = value.trim) === null || _value$trim === void 0 ? void 0 : _value$trim.call(value)) !== '') {
49
45
  onUpdateOrder(Number(value));
50
46
  }
51
47
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/order.js"],"names":["PageAttributesOrder","onUpdateOrder","order","orderInput","setOrderInput","setUpdatedOrder","value","newOrder","Number","isInteger","PageAttributesOrderWithChecks","props","select","editorStore","getEditedPostAttribute","dispatch","editPost","menu_order"],"mappings":";;;;;;;;;AAYA;;AATA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIO,MAAMA,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AAA,aAAa,CAAEC,KAAF,EAAU;AACtBa,IAAAA,QAAQ,CAAEF,YAAF,CAAR,CAAwBG,QAAxB,CAAkC;AACjCC,MAAAA,UAAU,EAAEf;AADqB,KAAlC;AAGA;;AAL8B,CAAlB,CAAd,CANuB,CAAT,EAaVQ,6BAbU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { invoke } from 'lodash';\n\n/**\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 (\n\t\t\tNumber.isInteger( newOrder ) &&\n\t\t\tinvoke( value, [ 'trim' ] ) !== ''\n\t\t) {\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":["PageAttributesOrder","onUpdateOrder","order","orderInput","setOrderInput","setUpdatedOrder","value","newOrder","Number","isInteger","trim","PageAttributesOrderWithChecks","props","select","editorStore","getEditedPostAttribute","dispatch","editPost","menu_order"],"mappings":";;;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIO,MAAMA,mBAAmB,GAAG,QAAoC;AAAA,MAAlC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,KAAK,GAAG;AAAzB,GAAkC;AACtE,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,IAAV,CAAtC;;AAEA,QAAMC,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,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,IAAA,KAAK,EAAGG,KAJT;AAKC,IAAA,QAAQ,EAAGD,eALZ;AAMC,IAAA,IAAI,EAAG,CANR;AAOC,IAAA,MAAM,EAAG,MAAM;AACdD,MAAAA,aAAa,CAAE,IAAF,CAAb;AACA;AATF,IADD;AAaA,CAxBM;;;;AA0BP,SAASO,6BAAT,CAAwCC,KAAxC,EAAgD;AAC/C,SACC,4BAAC,6BAAD;AAAsB,IAAA,WAAW,EAAC;AAAlC,KACC,4BAAC,mBAAD,EAA0BA,KAA1B,CADD,CADD;AAKA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AACzB,SAAO;AACNX,IAAAA,KAAK,EAAEW,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,YAA9C;AADD,GAAP;AAGA,CAJD,CADuB,EAMvB,wBAAgBC,QAAF,KAAkB;AAC/Bf,EAAAA,aAAa,CAAEC,KAAF,EAAU;AACtBc,IAAAA,QAAQ,CAAEF,YAAF,CAAR,CAAwBG,QAAxB,CAAkC;AACjCC,MAAAA,UAAU,EAAEhB;AADqB,KAAlC;AAGA;;AAL8B,CAAlB,CAAd,CANuB,CAAT,EAaVS,6BAbU,C","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,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -10,6 +12,8 @@ var _element = require("@wordpress/element");
10
12
 
11
13
  var _lodash = require("lodash");
12
14
 
15
+ var _removeAccents = _interopRequireDefault(require("remove-accents"));
16
+
13
17
  var _i18n = require("@wordpress/i18n");
14
18
 
15
19
  var _components = require("@wordpress/components");
@@ -42,8 +46,8 @@ function getTitle(post) {
42
46
  }
43
47
 
44
48
  const getItemPriority = (name, searchValue) => {
45
- const normalizedName = (0, _lodash.deburr)(name).toLowerCase();
46
- const normalizedSearch = (0, _lodash.deburr)(searchValue).toLowerCase();
49
+ const normalizedName = (0, _removeAccents.default)(name || '').toLowerCase();
50
+ const normalizedSearch = (0, _removeAccents.default)(searchValue || '').toLowerCase();
47
51
 
48
52
  if (normalizedName === normalizedSearch) {
49
53
  return 0;
@@ -111,7 +115,7 @@ function PageAttributesParent() {
111
115
  let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
112
116
  const mappedNodes = tree.map(treeNode => [{
113
117
  value: treeNode.id,
114
- label: (0, _lodash.repeat)('— ', level) + (0, _lodash.unescape)(treeNode.name),
118
+ label: '— '.repeat(level) + (0, _lodash.unescape)(treeNode.name),
115
119
  rawName: treeNode.name
116
120
  }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
117
121
  const sortedNodes = mappedNodes.sort((_ref, _ref2) => {
@@ -121,7 +125,7 @@ function PageAttributesParent() {
121
125
  const priorityB = getItemPriority(b.rawName, fieldValue);
122
126
  return priorityA >= priorityB ? 1 : -1;
123
127
  });
124
- return (0, _lodash.flatten)(sortedNodes);
128
+ return sortedNodes.flat();
125
129
  };
126
130
 
127
131
  let tree = pageItems.map(item => ({