988 module.exports = exports['default']; |
666 module.exports = exports['default']; |
989 }); |
667 }); |
990 |
668 |
991 /***/ }), |
669 /***/ }), |
992 |
670 |
993 /***/ 175: |
671 /***/ "HSyU": |
994 /***/ (function(module, exports, __webpack_require__) { |
672 /***/ (function(module, exports) { |
995 |
673 |
996 // Load in dependencies |
674 (function() { module.exports = window["wp"]["blocks"]; }()); |
997 var computedStyle = __webpack_require__(176); |
|
998 |
|
999 /** |
|
1000 * Calculate the `line-height` of a given node |
|
1001 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. |
|
1002 * @returns {Number} `line-height` of the element in pixels |
|
1003 */ |
|
1004 function lineHeight(node) { |
|
1005 // Grab the line-height via style |
|
1006 var lnHeightStr = computedStyle(node, 'line-height'); |
|
1007 var lnHeight = parseFloat(lnHeightStr, 10); |
|
1008 |
|
1009 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') |
|
1010 if (lnHeightStr === lnHeight + '') { |
|
1011 // Save the old lineHeight style and update the em unit to the element |
|
1012 var _lnHeightStyle = node.style.lineHeight; |
|
1013 node.style.lineHeight = lnHeightStr + 'em'; |
|
1014 |
|
1015 // Calculate the em based height |
|
1016 lnHeightStr = computedStyle(node, 'line-height'); |
|
1017 lnHeight = parseFloat(lnHeightStr, 10); |
|
1018 |
|
1019 // Revert the lineHeight style |
|
1020 if (_lnHeightStyle) { |
|
1021 node.style.lineHeight = _lnHeightStyle; |
|
1022 } else { |
|
1023 delete node.style.lineHeight; |
|
1024 } |
|
1025 } |
|
1026 |
|
1027 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) |
|
1028 // DEV: `em` units are converted to `pt` in IE6 |
|
1029 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length |
|
1030 if (lnHeightStr.indexOf('pt') !== -1) { |
|
1031 lnHeight *= 4; |
|
1032 lnHeight /= 3; |
|
1033 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) |
|
1034 } else if (lnHeightStr.indexOf('mm') !== -1) { |
|
1035 lnHeight *= 96; |
|
1036 lnHeight /= 25.4; |
|
1037 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) |
|
1038 } else if (lnHeightStr.indexOf('cm') !== -1) { |
|
1039 lnHeight *= 96; |
|
1040 lnHeight /= 2.54; |
|
1041 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) |
|
1042 } else if (lnHeightStr.indexOf('in') !== -1) { |
|
1043 lnHeight *= 96; |
|
1044 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) |
|
1045 } else if (lnHeightStr.indexOf('pc') !== -1) { |
|
1046 lnHeight *= 16; |
|
1047 } |
|
1048 |
|
1049 // Continue our computation |
|
1050 lnHeight = Math.round(lnHeight); |
|
1051 |
|
1052 // If the line-height is "normal", calculate by font-size |
|
1053 if (lnHeightStr === 'normal') { |
|
1054 // Create a temporary node |
|
1055 var nodeName = node.nodeName; |
|
1056 var _node = document.createElement(nodeName); |
|
1057 _node.innerHTML = ' '; |
|
1058 |
|
1059 // If we have a text area, reset it to only 1 row |
|
1060 // https://github.com/twolfson/line-height/issues/4 |
|
1061 if (nodeName.toUpperCase() === 'TEXTAREA') { |
|
1062 _node.setAttribute('rows', '1'); |
|
1063 } |
|
1064 |
|
1065 // Set the font-size of the element |
|
1066 var fontSizeStr = computedStyle(node, 'font-size'); |
|
1067 _node.style.fontSize = fontSizeStr; |
|
1068 |
|
1069 // Remove default padding/border which can affect offset height |
|
1070 // https://github.com/twolfson/line-height/issues/4 |
|
1071 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight |
|
1072 _node.style.padding = '0px'; |
|
1073 _node.style.border = '0px'; |
|
1074 |
|
1075 // Append it to the body |
|
1076 var body = document.body; |
|
1077 body.appendChild(_node); |
|
1078 |
|
1079 // Assume the line height of the element is the height |
|
1080 var height = _node.offsetHeight; |
|
1081 lnHeight = height; |
|
1082 |
|
1083 // Remove our child from the DOM |
|
1084 body.removeChild(_node); |
|
1085 } |
|
1086 |
|
1087 // Return the calculated height |
|
1088 return lnHeight; |
|
1089 } |
|
1090 |
|
1091 // Export lineHeight |
|
1092 module.exports = lineHeight; |
|
1093 |
|
1094 |
675 |
1095 /***/ }), |
676 /***/ }), |
1096 |
677 |
1097 /***/ 176: |
678 /***/ "JREk": |
1098 /***/ (function(module, exports) { |
679 /***/ (function(module, exports) { |
1099 |
680 |
1100 // This code has been refactored for 140 bytes |
681 (function() { module.exports = window["wp"]["serverSideRender"]; }()); |
1101 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js |
|
1102 var computedStyle = function (el, prop, getComputedStyle) { |
|
1103 getComputedStyle = window.getComputedStyle; |
|
1104 |
|
1105 // In one fell swoop |
|
1106 return ( |
|
1107 // If we have getComputedStyle |
|
1108 getComputedStyle ? |
|
1109 // Query it |
|
1110 // TODO: From CSS-Query notes, we might need (node, null) for FF |
|
1111 getComputedStyle(el) : |
|
1112 |
|
1113 // Otherwise, we are in IE and use currentStyle |
|
1114 el.currentStyle |
|
1115 )[ |
|
1116 // Switch to camelCase for CSSOM |
|
1117 // DEV: Grabbed from jQuery |
|
1118 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 |
|
1119 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 |
|
1120 prop.replace(/-(\w)/gi, function (word, letter) { |
|
1121 return letter.toUpperCase(); |
|
1122 }) |
|
1123 ]; |
|
1124 }; |
|
1125 |
|
1126 module.exports = computedStyle; |
|
1127 |
|
1128 |
682 |
1129 /***/ }), |
683 /***/ }), |
1130 |
684 |
1131 /***/ 177: |
685 /***/ "K2cm": |
1132 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
686 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
1133 |
687 |
1134 "use strict"; |
688 "use strict"; |
1135 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); |
689 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
1136 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
690 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
1137 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6); |
691 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
1138 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
692 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
1139 |
693 |
1140 |
694 |
1141 /** |
695 /** |
1142 * WordPress dependencies |
696 * WordPress dependencies |
1143 */ |
697 */ |
1144 |
698 |
1145 var closeSmall = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
699 const redo = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
1146 xmlns: "http://www.w3.org/2000/svg", |
700 xmlns: "http://www.w3.org/2000/svg", |
1147 viewBox: "0 0 24 24" |
701 viewBox: "0 0 24 24" |
1148 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
702 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
1149 d: "M13 11.9l3.3-3.4-1.1-1-3.2 3.3-3.2-3.3-1.1 1 3.3 3.4-3.5 3.6 1 1L12 13l3.5 3.5 1-1z" |
703 d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" |
1150 })); |
704 })); |
1151 /* harmony default export */ __webpack_exports__["a"] = (closeSmall); |
705 /* harmony default export */ __webpack_exports__["a"] = (redo); |
1152 |
706 |
1153 |
707 |
1154 /***/ }), |
708 /***/ }), |
1155 |
709 |
1156 /***/ 18: |
710 /***/ "K9lf": |
|
711 /***/ (function(module, exports) { |
|
712 |
|
713 (function() { module.exports = window["wp"]["compose"]; }()); |
|
714 |
|
715 /***/ }), |
|
716 |
|
717 /***/ "Mmq9": |
|
718 /***/ (function(module, exports) { |
|
719 |
|
720 (function() { module.exports = window["wp"]["url"]; }()); |
|
721 |
|
722 /***/ }), |
|
723 |
|
724 /***/ "NMb1": |
|
725 /***/ (function(module, exports) { |
|
726 |
|
727 (function() { module.exports = window["wp"]["deprecated"]; }()); |
|
728 |
|
729 /***/ }), |
|
730 |
|
731 /***/ "Ntru": |
1157 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
732 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
1158 |
733 |
1159 "use strict"; |
734 "use strict"; |
1160 |
735 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
1161 // EXPORTS |
|
1162 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); |
|
1163 |
|
1164 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js |
|
1165 var arrayLikeToArray = __webpack_require__(26); |
|
1166 |
|
1167 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
1168 |
|
1169 function _arrayWithoutHoles(arr) { |
|
1170 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr); |
|
1171 } |
|
1172 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
1173 var iterableToArray = __webpack_require__(35); |
|
1174 |
|
1175 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
1176 var unsupportedIterableToArray = __webpack_require__(29); |
|
1177 |
|
1178 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
1179 function _nonIterableSpread() { |
|
1180 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
1181 } |
|
1182 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 function _toConsumableArray(arr) { |
|
1188 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
1189 } |
|
1190 |
|
1191 /***/ }), |
|
1192 |
|
1193 /***/ 19: |
|
1194 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1195 |
|
1196 "use strict"; |
|
1197 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); |
|
1198 function _defineProperties(target, props) { |
|
1199 for (var i = 0; i < props.length; i++) { |
|
1200 var descriptor = props[i]; |
|
1201 descriptor.enumerable = descriptor.enumerable || false; |
|
1202 descriptor.configurable = true; |
|
1203 if ("value" in descriptor) descriptor.writable = true; |
|
1204 Object.defineProperty(target, descriptor.key, descriptor); |
|
1205 } |
|
1206 } |
|
1207 |
|
1208 function _createClass(Constructor, protoProps, staticProps) { |
|
1209 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
1210 if (staticProps) _defineProperties(Constructor, staticProps); |
|
1211 return Constructor; |
|
1212 } |
|
1213 |
|
1214 /***/ }), |
|
1215 |
|
1216 /***/ 2: |
|
1217 /***/ (function(module, exports) { |
|
1218 |
|
1219 (function() { module.exports = this["lodash"]; }()); |
|
1220 |
|
1221 /***/ }), |
|
1222 |
|
1223 /***/ 20: |
|
1224 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1225 |
|
1226 "use strict"; |
|
1227 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); |
|
1228 function _classCallCheck(instance, Constructor) { |
|
1229 if (!(instance instanceof Constructor)) { |
|
1230 throw new TypeError("Cannot call a class as a function"); |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 /***/ }), |
|
1235 |
|
1236 /***/ 202: |
|
1237 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1238 |
|
1239 "use strict"; |
|
1240 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); |
|
1241 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
736 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
1242 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6); |
737 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
1243 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
738 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
1244 |
739 |
1245 |
740 |
1246 /** |
741 /** |
1247 * WordPress dependencies |
742 * WordPress dependencies |
1248 */ |
743 */ |
1249 |
744 |
1250 var blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
745 const undo = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
1251 xmlns: "http://www.w3.org/2000/svg", |
746 xmlns: "http://www.w3.org/2000/svg", |
1252 viewBox: "0 0 24 24" |
747 viewBox: "0 0 24 24" |
1253 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
748 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
1254 d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" |
749 d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" |
1255 })); |
750 })); |
1256 /* harmony default export */ __webpack_exports__["a"] = (blockDefault); |
751 /* harmony default export */ __webpack_exports__["a"] = (undo); |
1257 |
752 |
1258 |
753 |
1259 /***/ }), |
754 /***/ }), |
1260 |
755 |
1261 /***/ 21: |
756 /***/ "O6Fj": |
1262 /***/ (function(module, exports) { |
757 /***/ (function(module, exports, __webpack_require__) { |
1263 |
758 |
1264 (function() { module.exports = this["wp"]["keycodes"]; }()); |
759 "use strict"; |
|
760 |
|
761 exports.__esModule = true; |
|
762 var TextareaAutosize_1 = __webpack_require__("CNgt"); |
|
763 exports["default"] = TextareaAutosize_1.TextareaAutosize; |
|
764 |
1265 |
765 |
1266 /***/ }), |
766 /***/ }), |
1267 |
767 |
1268 /***/ 22: |
768 /***/ "PLxR": |
1269 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1270 |
|
1271 "use strict"; |
|
1272 |
|
1273 // EXPORTS |
|
1274 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _inherits; }); |
|
1275 |
|
1276 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js |
|
1277 function _setPrototypeOf(o, p) { |
|
1278 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
|
1279 o.__proto__ = p; |
|
1280 return o; |
|
1281 }; |
|
1282 |
|
1283 return _setPrototypeOf(o, p); |
|
1284 } |
|
1285 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js |
|
1286 |
|
1287 function _inherits(subClass, superClass) { |
|
1288 if (typeof superClass !== "function" && superClass !== null) { |
|
1289 throw new TypeError("Super expression must either be null or a function"); |
|
1290 } |
|
1291 |
|
1292 subClass.prototype = Object.create(superClass && superClass.prototype, { |
|
1293 constructor: { |
|
1294 value: subClass, |
|
1295 writable: true, |
|
1296 configurable: true |
|
1297 } |
|
1298 }); |
|
1299 if (superClass) _setPrototypeOf(subClass, superClass); |
|
1300 } |
|
1301 |
|
1302 /***/ }), |
|
1303 |
|
1304 /***/ 23: |
|
1305 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1306 |
|
1307 "use strict"; |
|
1308 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); |
|
1309 /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40); |
|
1310 /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12); |
|
1311 |
|
1312 |
|
1313 function _possibleConstructorReturn(self, call) { |
|
1314 if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { |
|
1315 return call; |
|
1316 } |
|
1317 |
|
1318 return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); |
|
1319 } |
|
1320 |
|
1321 /***/ }), |
|
1322 |
|
1323 /***/ 24: |
|
1324 /***/ (function(module, exports) { |
|
1325 |
|
1326 (function() { module.exports = this["regeneratorRuntime"]; }()); |
|
1327 |
|
1328 /***/ }), |
|
1329 |
|
1330 /***/ 25: |
|
1331 /***/ (function(module, exports) { |
|
1332 |
|
1333 (function() { module.exports = this["wp"]["richText"]; }()); |
|
1334 |
|
1335 /***/ }), |
|
1336 |
|
1337 /***/ 26: |
|
1338 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1339 |
|
1340 "use strict"; |
|
1341 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); |
|
1342 function _arrayLikeToArray(arr, len) { |
|
1343 if (len == null || len > arr.length) len = arr.length; |
|
1344 |
|
1345 for (var i = 0, arr2 = new Array(len); i < len; i++) { |
|
1346 arr2[i] = arr[i]; |
|
1347 } |
|
1348 |
|
1349 return arr2; |
|
1350 } |
|
1351 |
|
1352 /***/ }), |
|
1353 |
|
1354 /***/ 28: |
|
1355 /***/ (function(module, exports, __webpack_require__) { |
|
1356 |
|
1357 /** |
|
1358 * Copyright (c) 2013-present, Facebook, Inc. |
|
1359 * |
|
1360 * This source code is licensed under the MIT license found in the |
|
1361 * LICENSE file in the root directory of this source tree. |
|
1362 */ |
|
1363 |
|
1364 if (false) { var throwOnDirectAccess, ReactIs; } else { |
|
1365 // By explicitly using `prop-types` you are opting into new production behavior. |
|
1366 // http://fb.me/prop-types-in-prod |
|
1367 module.exports = __webpack_require__(138)(); |
|
1368 } |
|
1369 |
|
1370 |
|
1371 /***/ }), |
|
1372 |
|
1373 /***/ 29: |
|
1374 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1375 |
|
1376 "use strict"; |
|
1377 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); |
|
1378 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26); |
|
1379 |
|
1380 function _unsupportedIterableToArray(o, minLen) { |
|
1381 if (!o) return; |
|
1382 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
1383 var n = Object.prototype.toString.call(o).slice(8, -1); |
|
1384 if (n === "Object" && o.constructor) n = o.constructor.name; |
|
1385 if (n === "Map" || n === "Set") return Array.from(o); |
|
1386 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
1387 } |
|
1388 |
|
1389 /***/ }), |
|
1390 |
|
1391 /***/ 298: |
|
1392 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1393 |
|
1394 "use strict"; |
|
1395 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); |
|
1396 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
1397 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6); |
|
1398 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
1399 |
|
1400 |
|
1401 /** |
|
1402 * WordPress dependencies |
|
1403 */ |
|
1404 |
|
1405 var layout = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
|
1406 xmlns: "http://www.w3.org/2000/svg", |
|
1407 viewBox: "-2 -2 24 24" |
|
1408 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
|
1409 d: "M2 2h5v11H2V2zm6 0h5v5H8V2zm6 0h4v16h-4V2zM8 8h5v5H8V8zm-6 6h11v4H2v-4z" |
|
1410 })); |
|
1411 /* harmony default export */ __webpack_exports__["a"] = (layout); |
|
1412 |
|
1413 |
|
1414 /***/ }), |
|
1415 |
|
1416 /***/ 3: |
|
1417 /***/ (function(module, exports) { |
|
1418 |
|
1419 (function() { module.exports = this["wp"]["components"]; }()); |
|
1420 |
|
1421 /***/ }), |
|
1422 |
|
1423 /***/ 302: |
|
1424 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1425 |
|
1426 "use strict"; |
|
1427 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); |
|
1428 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
1429 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6); |
|
1430 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
1431 |
|
1432 |
|
1433 /** |
|
1434 * WordPress dependencies |
|
1435 */ |
|
1436 |
|
1437 var grid = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
|
1438 xmlns: "http://www.w3.org/2000/svg", |
|
1439 viewBox: "-2 -2 24 24" |
|
1440 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
|
1441 d: "M9 9V3H3v6h6zm8 0V3h-6v6h6zm-8 8v-6H3v6h6zm8 0v-6h-6v6h6z" |
|
1442 })); |
|
1443 /* harmony default export */ __webpack_exports__["a"] = (grid); |
|
1444 |
|
1445 |
|
1446 /***/ }), |
|
1447 |
|
1448 /***/ 31: |
|
1449 /***/ (function(module, exports) { |
|
1450 |
|
1451 (function() { module.exports = this["wp"]["url"]; }()); |
|
1452 |
|
1453 /***/ }), |
|
1454 |
|
1455 /***/ 32: |
|
1456 /***/ (function(module, exports) { |
|
1457 |
|
1458 (function() { module.exports = this["wp"]["hooks"]; }()); |
|
1459 |
|
1460 /***/ }), |
|
1461 |
|
1462 /***/ 35: |
|
1463 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1464 |
|
1465 "use strict"; |
|
1466 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
1467 function _iterableToArray(iter) { |
|
1468 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); |
|
1469 } |
|
1470 |
|
1471 /***/ }), |
|
1472 |
|
1473 /***/ 36: |
|
1474 /***/ (function(module, exports) { |
|
1475 |
|
1476 (function() { module.exports = this["wp"]["dataControls"]; }()); |
|
1477 |
|
1478 /***/ }), |
|
1479 |
|
1480 /***/ 37: |
|
1481 /***/ (function(module, exports) { |
|
1482 |
|
1483 (function() { module.exports = this["wp"]["deprecated"]; }()); |
|
1484 |
|
1485 /***/ }), |
|
1486 |
|
1487 /***/ 38: |
|
1488 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1489 |
|
1490 "use strict"; |
|
1491 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
|
1492 function _arrayWithHoles(arr) { |
|
1493 if (Array.isArray(arr)) return arr; |
|
1494 } |
|
1495 |
|
1496 /***/ }), |
|
1497 |
|
1498 /***/ 39: |
|
1499 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1500 |
|
1501 "use strict"; |
|
1502 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
1503 function _nonIterableRest() { |
|
1504 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
1505 } |
|
1506 |
|
1507 /***/ }), |
|
1508 |
|
1509 /***/ 4: |
|
1510 /***/ (function(module, exports) { |
|
1511 |
|
1512 (function() { module.exports = this["wp"]["data"]; }()); |
|
1513 |
|
1514 /***/ }), |
|
1515 |
|
1516 /***/ 40: |
|
1517 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1518 |
|
1519 "use strict"; |
|
1520 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
|
1521 function _typeof(obj) { |
|
1522 "@babel/helpers - typeof"; |
|
1523 |
|
1524 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
|
1525 _typeof = function _typeof(obj) { |
|
1526 return typeof obj; |
|
1527 }; |
|
1528 } else { |
|
1529 _typeof = function _typeof(obj) { |
|
1530 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
1531 }; |
|
1532 } |
|
1533 |
|
1534 return _typeof(obj); |
|
1535 } |
|
1536 |
|
1537 /***/ }), |
|
1538 |
|
1539 /***/ 41: |
|
1540 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1541 |
|
1542 "use strict"; |
|
1543 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutPropertiesLoose; }); |
|
1544 function _objectWithoutPropertiesLoose(source, excluded) { |
|
1545 if (source == null) return {}; |
|
1546 var target = {}; |
|
1547 var sourceKeys = Object.keys(source); |
|
1548 var key, i; |
|
1549 |
|
1550 for (i = 0; i < sourceKeys.length; i++) { |
|
1551 key = sourceKeys[i]; |
|
1552 if (excluded.indexOf(key) >= 0) continue; |
|
1553 target[key] = source[key]; |
|
1554 } |
|
1555 |
|
1556 return target; |
|
1557 } |
|
1558 |
|
1559 /***/ }), |
|
1560 |
|
1561 /***/ 42: |
|
1562 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1563 |
|
1564 "use strict"; |
|
1565 |
|
1566 |
|
1567 var LEAF_KEY, hasWeakMap; |
|
1568 |
|
1569 /** |
|
1570 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
1571 * |
|
1572 * @type {Object} |
|
1573 */ |
|
1574 LEAF_KEY = {}; |
|
1575 |
|
1576 /** |
|
1577 * Whether environment supports WeakMap. |
|
1578 * |
|
1579 * @type {boolean} |
|
1580 */ |
|
1581 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
1582 |
|
1583 /** |
|
1584 * Returns the first argument as the sole entry in an array. |
|
1585 * |
|
1586 * @param {*} value Value to return. |
|
1587 * |
|
1588 * @return {Array} Value returned as entry in array. |
|
1589 */ |
|
1590 function arrayOf( value ) { |
|
1591 return [ value ]; |
|
1592 } |
|
1593 |
|
1594 /** |
|
1595 * Returns true if the value passed is object-like, or false otherwise. A value |
|
1596 * is object-like if it can support property assignment, e.g. object or array. |
|
1597 * |
|
1598 * @param {*} value Value to test. |
|
1599 * |
|
1600 * @return {boolean} Whether value is object-like. |
|
1601 */ |
|
1602 function isObjectLike( value ) { |
|
1603 return !! value && 'object' === typeof value; |
|
1604 } |
|
1605 |
|
1606 /** |
|
1607 * Creates and returns a new cache object. |
|
1608 * |
|
1609 * @return {Object} Cache object. |
|
1610 */ |
|
1611 function createCache() { |
|
1612 var cache = { |
|
1613 clear: function() { |
|
1614 cache.head = null; |
|
1615 }, |
|
1616 }; |
|
1617 |
|
1618 return cache; |
|
1619 } |
|
1620 |
|
1621 /** |
|
1622 * Returns true if entries within the two arrays are strictly equal by |
|
1623 * reference from a starting index. |
|
1624 * |
|
1625 * @param {Array} a First array. |
|
1626 * @param {Array} b Second array. |
|
1627 * @param {number} fromIndex Index from which to start comparison. |
|
1628 * |
|
1629 * @return {boolean} Whether arrays are shallowly equal. |
|
1630 */ |
|
1631 function isShallowEqual( a, b, fromIndex ) { |
|
1632 var i; |
|
1633 |
|
1634 if ( a.length !== b.length ) { |
|
1635 return false; |
|
1636 } |
|
1637 |
|
1638 for ( i = fromIndex; i < a.length; i++ ) { |
|
1639 if ( a[ i ] !== b[ i ] ) { |
|
1640 return false; |
|
1641 } |
|
1642 } |
|
1643 |
|
1644 return true; |
|
1645 } |
|
1646 |
|
1647 /** |
|
1648 * Returns a memoized selector function. The getDependants function argument is |
|
1649 * called before the memoized selector and is expected to return an immutable |
|
1650 * reference or array of references on which the selector depends for computing |
|
1651 * its own return value. The memoize cache is preserved only as long as those |
|
1652 * dependant references remain the same. If getDependants returns a different |
|
1653 * reference(s), the cache is cleared and the selector value regenerated. |
|
1654 * |
|
1655 * @param {Function} selector Selector function. |
|
1656 * @param {Function} getDependants Dependant getter returning an immutable |
|
1657 * reference or array of reference used in |
|
1658 * cache bust consideration. |
|
1659 * |
|
1660 * @return {Function} Memoized selector. |
|
1661 */ |
|
1662 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
1663 var rootCache, getCache; |
|
1664 |
|
1665 // Use object source as dependant if getter not provided |
|
1666 if ( ! getDependants ) { |
|
1667 getDependants = arrayOf; |
|
1668 } |
|
1669 |
|
1670 /** |
|
1671 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
1672 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
1673 * cache object. |
|
1674 * |
|
1675 * @return {(WeakMap|Object)} Root cache object. |
|
1676 */ |
|
1677 function getRootCache() { |
|
1678 return rootCache; |
|
1679 } |
|
1680 |
|
1681 /** |
|
1682 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
1683 * will be used to create a unique cache for each set of dependants. This |
|
1684 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
1685 * to occur on entries where the key object is no longer referenced. Since |
|
1686 * WeakMap requires the key to be an object, this is only possible when the |
|
1687 * dependant is object-like. The root cache is created as a hierarchy where |
|
1688 * each top-level key is the first entry in a dependants set, the value a |
|
1689 * WeakMap where each key is the next dependant, and so on. This continues |
|
1690 * so long as the dependants are object-like. If no dependants are object- |
|
1691 * like, then the cache is shared across all invocations. |
|
1692 * |
|
1693 * @see isObjectLike |
|
1694 * |
|
1695 * @param {Array} dependants Selector dependants. |
|
1696 * |
|
1697 * @return {Object} Cache object. |
|
1698 */ |
|
1699 function getWeakMapCache( dependants ) { |
|
1700 var caches = rootCache, |
|
1701 isUniqueByDependants = true, |
|
1702 i, dependant, map, cache; |
|
1703 |
|
1704 for ( i = 0; i < dependants.length; i++ ) { |
|
1705 dependant = dependants[ i ]; |
|
1706 |
|
1707 // Can only compose WeakMap from object-like key. |
|
1708 if ( ! isObjectLike( dependant ) ) { |
|
1709 isUniqueByDependants = false; |
|
1710 break; |
|
1711 } |
|
1712 |
|
1713 // Does current segment of cache already have a WeakMap? |
|
1714 if ( caches.has( dependant ) ) { |
|
1715 // Traverse into nested WeakMap. |
|
1716 caches = caches.get( dependant ); |
|
1717 } else { |
|
1718 // Create, set, and traverse into a new one. |
|
1719 map = new WeakMap(); |
|
1720 caches.set( dependant, map ); |
|
1721 caches = map; |
|
1722 } |
|
1723 } |
|
1724 |
|
1725 // We use an arbitrary (but consistent) object as key for the last item |
|
1726 // in the WeakMap to serve as our running cache. |
|
1727 if ( ! caches.has( LEAF_KEY ) ) { |
|
1728 cache = createCache(); |
|
1729 cache.isUniqueByDependants = isUniqueByDependants; |
|
1730 caches.set( LEAF_KEY, cache ); |
|
1731 } |
|
1732 |
|
1733 return caches.get( LEAF_KEY ); |
|
1734 } |
|
1735 |
|
1736 // Assign cache handler by availability of WeakMap |
|
1737 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
1738 |
|
1739 /** |
|
1740 * Resets root memoization cache. |
|
1741 */ |
|
1742 function clear() { |
|
1743 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
1744 } |
|
1745 |
|
1746 // eslint-disable-next-line jsdoc/check-param-names |
|
1747 /** |
|
1748 * The augmented selector call, considering first whether dependants have |
|
1749 * changed before passing it to underlying memoize function. |
|
1750 * |
|
1751 * @param {Object} source Source object for derivation. |
|
1752 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
1753 * |
|
1754 * @return {*} Selector result. |
|
1755 */ |
|
1756 function callSelector( /* source, ...extraArgs */ ) { |
|
1757 var len = arguments.length, |
|
1758 cache, node, i, args, dependants; |
|
1759 |
|
1760 // Create copy of arguments (avoid leaking deoptimization). |
|
1761 args = new Array( len ); |
|
1762 for ( i = 0; i < len; i++ ) { |
|
1763 args[ i ] = arguments[ i ]; |
|
1764 } |
|
1765 |
|
1766 dependants = getDependants.apply( null, args ); |
|
1767 cache = getCache( dependants ); |
|
1768 |
|
1769 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
1770 // of WeakMap support), shallow compare against last dependants and, if |
|
1771 // references have changed, destroy cache to recalculate result. |
|
1772 if ( ! cache.isUniqueByDependants ) { |
|
1773 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
1774 cache.clear(); |
|
1775 } |
|
1776 |
|
1777 cache.lastDependants = dependants; |
|
1778 } |
|
1779 |
|
1780 node = cache.head; |
|
1781 while ( node ) { |
|
1782 // Check whether node arguments match arguments |
|
1783 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
1784 node = node.next; |
|
1785 continue; |
|
1786 } |
|
1787 |
|
1788 // At this point we can assume we've found a match |
|
1789 |
|
1790 // Surface matched node to head if not already |
|
1791 if ( node !== cache.head ) { |
|
1792 // Adjust siblings to point to each other. |
|
1793 node.prev.next = node.next; |
|
1794 if ( node.next ) { |
|
1795 node.next.prev = node.prev; |
|
1796 } |
|
1797 |
|
1798 node.next = cache.head; |
|
1799 node.prev = null; |
|
1800 cache.head.prev = node; |
|
1801 cache.head = node; |
|
1802 } |
|
1803 |
|
1804 // Return immediately |
|
1805 return node.val; |
|
1806 } |
|
1807 |
|
1808 // No cached value found. Continue to insertion phase: |
|
1809 |
|
1810 node = { |
|
1811 // Generate the result from original function |
|
1812 val: selector.apply( null, args ), |
|
1813 }; |
|
1814 |
|
1815 // Avoid including the source object in the cache. |
|
1816 args[ 0 ] = null; |
|
1817 node.args = args; |
|
1818 |
|
1819 // Don't need to check whether node is already head, since it would |
|
1820 // have been returned above already if it was |
|
1821 |
|
1822 // Shift existing head down list |
|
1823 if ( cache.head ) { |
|
1824 cache.head.prev = node; |
|
1825 node.next = cache.head; |
|
1826 } |
|
1827 |
|
1828 cache.head = node; |
|
1829 |
|
1830 return node.val; |
|
1831 } |
|
1832 |
|
1833 callSelector.getDependants = getDependants; |
|
1834 callSelector.clear = clear; |
|
1835 clear(); |
|
1836 |
|
1837 return callSelector; |
|
1838 }); |
|
1839 |
|
1840 |
|
1841 /***/ }), |
|
1842 |
|
1843 /***/ 421: |
|
1844 /***/ (function(module, exports, __webpack_require__) { |
|
1845 |
|
1846 "use strict"; |
|
1847 |
|
1848 |
|
1849 var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; |
|
1850 |
|
1851 function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } |
|
1852 |
|
1853 var BEGIN = 'BEGIN'; |
|
1854 var COMMIT = 'COMMIT'; |
|
1855 var REVERT = 'REVERT'; |
|
1856 // Array({transactionID: string or null, beforeState: {object}, action: {object}} |
|
1857 var INITIAL_OPTIMIST = []; |
|
1858 |
|
1859 module.exports = optimist; |
|
1860 module.exports.BEGIN = BEGIN; |
|
1861 module.exports.COMMIT = COMMIT; |
|
1862 module.exports.REVERT = REVERT; |
|
1863 function optimist(fn) { |
|
1864 function beginReducer(state, action) { |
|
1865 var _separateState = separateState(state); |
|
1866 |
|
1867 var optimist = _separateState.optimist; |
|
1868 var innerState = _separateState.innerState; |
|
1869 |
|
1870 optimist = optimist.concat([{ beforeState: innerState, action: action }]); |
|
1871 innerState = fn(innerState, action); |
|
1872 validateState(innerState, action); |
|
1873 return _extends({ optimist: optimist }, innerState); |
|
1874 } |
|
1875 function commitReducer(state, action) { |
|
1876 var _separateState2 = separateState(state); |
|
1877 |
|
1878 var optimist = _separateState2.optimist; |
|
1879 var innerState = _separateState2.innerState; |
|
1880 |
|
1881 var newOptimist = [], |
|
1882 started = false, |
|
1883 committed = false; |
|
1884 optimist.forEach(function (entry) { |
|
1885 if (started) { |
|
1886 if (entry.beforeState && matchesTransaction(entry.action, action.optimist.id)) { |
|
1887 committed = true; |
|
1888 newOptimist.push({ action: entry.action }); |
|
1889 } else { |
|
1890 newOptimist.push(entry); |
|
1891 } |
|
1892 } else if (entry.beforeState && !matchesTransaction(entry.action, action.optimist.id)) { |
|
1893 started = true; |
|
1894 newOptimist.push(entry); |
|
1895 } else if (entry.beforeState && matchesTransaction(entry.action, action.optimist.id)) { |
|
1896 committed = true; |
|
1897 } |
|
1898 }); |
|
1899 if (!committed) { |
|
1900 console.error('Cannot commit transaction with id "' + action.optimist.id + '" because it does not exist'); |
|
1901 } |
|
1902 optimist = newOptimist; |
|
1903 return baseReducer(optimist, innerState, action); |
|
1904 } |
|
1905 function revertReducer(state, action) { |
|
1906 var _separateState3 = separateState(state); |
|
1907 |
|
1908 var optimist = _separateState3.optimist; |
|
1909 var innerState = _separateState3.innerState; |
|
1910 |
|
1911 var newOptimist = [], |
|
1912 started = false, |
|
1913 gotInitialState = false, |
|
1914 currentState = innerState; |
|
1915 optimist.forEach(function (entry) { |
|
1916 if (entry.beforeState && matchesTransaction(entry.action, action.optimist.id)) { |
|
1917 currentState = entry.beforeState; |
|
1918 gotInitialState = true; |
|
1919 } |
|
1920 if (!matchesTransaction(entry.action, action.optimist.id)) { |
|
1921 if (entry.beforeState) { |
|
1922 started = true; |
|
1923 } |
|
1924 if (started) { |
|
1925 if (gotInitialState && entry.beforeState) { |
|
1926 newOptimist.push({ |
|
1927 beforeState: currentState, |
|
1928 action: entry.action |
|
1929 }); |
|
1930 } else { |
|
1931 newOptimist.push(entry); |
|
1932 } |
|
1933 } |
|
1934 if (gotInitialState) { |
|
1935 currentState = fn(currentState, entry.action); |
|
1936 validateState(innerState, action); |
|
1937 } |
|
1938 } |
|
1939 }); |
|
1940 if (!gotInitialState) { |
|
1941 console.error('Cannot revert transaction with id "' + action.optimist.id + '" because it does not exist'); |
|
1942 } |
|
1943 optimist = newOptimist; |
|
1944 return baseReducer(optimist, currentState, action); |
|
1945 } |
|
1946 function baseReducer(optimist, innerState, action) { |
|
1947 if (optimist.length) { |
|
1948 optimist = optimist.concat([{ action: action }]); |
|
1949 } |
|
1950 innerState = fn(innerState, action); |
|
1951 validateState(innerState, action); |
|
1952 return _extends({ optimist: optimist }, innerState); |
|
1953 } |
|
1954 return function (state, action) { |
|
1955 if (action.optimist) { |
|
1956 switch (action.optimist.type) { |
|
1957 case BEGIN: |
|
1958 return beginReducer(state, action); |
|
1959 case COMMIT: |
|
1960 return commitReducer(state, action); |
|
1961 case REVERT: |
|
1962 return revertReducer(state, action); |
|
1963 } |
|
1964 } |
|
1965 |
|
1966 var _separateState4 = separateState(state); |
|
1967 |
|
1968 var optimist = _separateState4.optimist; |
|
1969 var innerState = _separateState4.innerState; |
|
1970 |
|
1971 if (state && !optimist.length) { |
|
1972 var nextState = fn(innerState, action); |
|
1973 if (nextState === innerState) { |
|
1974 return state; |
|
1975 } |
|
1976 validateState(nextState, action); |
|
1977 return _extends({ optimist: optimist }, nextState); |
|
1978 } |
|
1979 return baseReducer(optimist, innerState, action); |
|
1980 }; |
|
1981 } |
|
1982 |
|
1983 function matchesTransaction(action, id) { |
|
1984 return action.optimist && action.optimist.id === id; |
|
1985 } |
|
1986 |
|
1987 function validateState(newState, action) { |
|
1988 if (!newState || typeof newState !== 'object' || Array.isArray(newState)) { |
|
1989 throw new TypeError('Error while handling "' + action.type + '": Optimist requires that state is always a plain object.'); |
|
1990 } |
|
1991 } |
|
1992 |
|
1993 function separateState(state) { |
|
1994 if (!state) { |
|
1995 return { optimist: INITIAL_OPTIMIST, innerState: state }; |
|
1996 } else { |
|
1997 var _state$optimist = state.optimist; |
|
1998 |
|
1999 var _optimist = _state$optimist === undefined ? INITIAL_OPTIMIST : _state$optimist; |
|
2000 |
|
2001 var innerState = _objectWithoutProperties(state, ['optimist']); |
|
2002 |
|
2003 return { optimist: _optimist, innerState: innerState }; |
|
2004 } |
|
2005 } |
|
2006 |
|
2007 /***/ }), |
|
2008 |
|
2009 /***/ 438: |
|
2010 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
769 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
2011 |
770 |
2012 "use strict"; |
771 "use strict"; |
2013 // ESM COMPAT FLAG |
772 // ESM COMPAT FLAG |
2014 __webpack_require__.r(__webpack_exports__); |
773 __webpack_require__.r(__webpack_exports__); |
2015 |
774 |
2016 // EXPORTS |
775 // EXPORTS |
|
776 __webpack_require__.d(__webpack_exports__, "storeConfig", function() { return /* reexport */ storeConfig; }); |
|
777 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); |
2017 __webpack_require__.d(__webpack_exports__, "userAutocompleter", function() { return /* reexport */ autocompleters_user; }); |
778 __webpack_require__.d(__webpack_exports__, "userAutocompleter", function() { return /* reexport */ autocompleters_user; }); |
2018 __webpack_require__.d(__webpack_exports__, "AutosaveMonitor", function() { return /* reexport */ autosave_monitor; }); |
779 __webpack_require__.d(__webpack_exports__, "AutosaveMonitor", function() { return /* reexport */ autosave_monitor; }); |
2019 __webpack_require__.d(__webpack_exports__, "DocumentOutline", function() { return /* reexport */ document_outline; }); |
780 __webpack_require__.d(__webpack_exports__, "DocumentOutline", function() { return /* reexport */ document_outline; }); |
2020 __webpack_require__.d(__webpack_exports__, "DocumentOutlineCheck", function() { return /* reexport */ check; }); |
781 __webpack_require__.d(__webpack_exports__, "DocumentOutlineCheck", function() { return /* reexport */ check; }); |
2021 __webpack_require__.d(__webpack_exports__, "VisualEditorGlobalKeyboardShortcuts", function() { return /* reexport */ visual_editor_shortcuts; }); |
782 __webpack_require__.d(__webpack_exports__, "VisualEditorGlobalKeyboardShortcuts", function() { return /* reexport */ visual_editor_shortcuts; }); |
2022 __webpack_require__.d(__webpack_exports__, "EditorGlobalKeyboardShortcuts", function() { return /* reexport */ EditorGlobalKeyboardShortcuts; }); |
|
2023 __webpack_require__.d(__webpack_exports__, "TextEditorGlobalKeyboardShortcuts", function() { return /* reexport */ TextEditorGlobalKeyboardShortcuts; }); |
783 __webpack_require__.d(__webpack_exports__, "TextEditorGlobalKeyboardShortcuts", function() { return /* reexport */ TextEditorGlobalKeyboardShortcuts; }); |
2024 __webpack_require__.d(__webpack_exports__, "EditorKeyboardShortcutsRegister", function() { return /* reexport */ register_shortcuts; }); |
784 __webpack_require__.d(__webpack_exports__, "EditorKeyboardShortcutsRegister", function() { return /* reexport */ register_shortcuts; }); |
2025 __webpack_require__.d(__webpack_exports__, "EditorHistoryRedo", function() { return /* reexport */ editor_history_redo; }); |
785 __webpack_require__.d(__webpack_exports__, "EditorHistoryRedo", function() { return /* reexport */ editor_history_redo; }); |
2026 __webpack_require__.d(__webpack_exports__, "EditorHistoryUndo", function() { return /* reexport */ editor_history_undo; }); |
786 __webpack_require__.d(__webpack_exports__, "EditorHistoryUndo", function() { return /* reexport */ editor_history_undo; }); |
2027 __webpack_require__.d(__webpack_exports__, "EditorNotices", function() { return /* reexport */ editor_notices; }); |
787 __webpack_require__.d(__webpack_exports__, "EditorNotices", function() { return /* reexport */ editor_notices; }); |
|
788 __webpack_require__.d(__webpack_exports__, "EditorSnackbars", function() { return /* reexport */ EditorSnackbars; }); |
2028 __webpack_require__.d(__webpack_exports__, "EntitiesSavedStates", function() { return /* reexport */ EntitiesSavedStates; }); |
789 __webpack_require__.d(__webpack_exports__, "EntitiesSavedStates", function() { return /* reexport */ EntitiesSavedStates; }); |
2029 __webpack_require__.d(__webpack_exports__, "ErrorBoundary", function() { return /* reexport */ error_boundary; }); |
790 __webpack_require__.d(__webpack_exports__, "ErrorBoundary", function() { return /* reexport */ error_boundary; }); |
2030 __webpack_require__.d(__webpack_exports__, "LocalAutosaveMonitor", function() { return /* reexport */ local_autosave_monitor; }); |
791 __webpack_require__.d(__webpack_exports__, "LocalAutosaveMonitor", function() { return /* reexport */ local_autosave_monitor; }); |
2031 __webpack_require__.d(__webpack_exports__, "PageAttributesCheck", function() { return /* reexport */ page_attributes_check; }); |
792 __webpack_require__.d(__webpack_exports__, "PageAttributesCheck", function() { return /* reexport */ page_attributes_check; }); |
2032 __webpack_require__.d(__webpack_exports__, "PageAttributesOrder", function() { return /* reexport */ page_attributes_order; }); |
793 __webpack_require__.d(__webpack_exports__, "PageAttributesOrder", function() { return /* reexport */ page_attributes_order; }); |
2033 __webpack_require__.d(__webpack_exports__, "PageAttributesParent", function() { return /* reexport */ page_attributes_parent; }); |
794 __webpack_require__.d(__webpack_exports__, "PageAttributesParent", function() { return /* reexport */ page_attributes_parent; }); |
2034 __webpack_require__.d(__webpack_exports__, "PageTemplate", function() { return /* reexport */ page_attributes_template; }); |
795 __webpack_require__.d(__webpack_exports__, "PageTemplate", function() { return /* reexport */ post_template; }); |
2035 __webpack_require__.d(__webpack_exports__, "PostAuthor", function() { return /* reexport */ post_author; }); |
796 __webpack_require__.d(__webpack_exports__, "PostAuthor", function() { return /* reexport */ post_author; }); |
2036 __webpack_require__.d(__webpack_exports__, "PostAuthorCheck", function() { return /* reexport */ post_author_check; }); |
797 __webpack_require__.d(__webpack_exports__, "PostAuthorCheck", function() { return /* reexport */ post_author_check; }); |
2037 __webpack_require__.d(__webpack_exports__, "PostComments", function() { return /* reexport */ post_comments; }); |
798 __webpack_require__.d(__webpack_exports__, "PostComments", function() { return /* reexport */ post_comments; }); |
2038 __webpack_require__.d(__webpack_exports__, "PostExcerpt", function() { return /* reexport */ post_excerpt; }); |
799 __webpack_require__.d(__webpack_exports__, "PostExcerpt", function() { return /* reexport */ post_excerpt; }); |
2039 __webpack_require__.d(__webpack_exports__, "PostExcerptCheck", function() { return /* reexport */ post_excerpt_check; }); |
800 __webpack_require__.d(__webpack_exports__, "PostExcerptCheck", function() { return /* reexport */ post_excerpt_check; }); |
2040 __webpack_require__.d(__webpack_exports__, "PostFeaturedImage", function() { return /* reexport */ post_featured_image; }); |
801 __webpack_require__.d(__webpack_exports__, "PostFeaturedImage", function() { return /* reexport */ post_featured_image; }); |
2041 __webpack_require__.d(__webpack_exports__, "PostFeaturedImageCheck", function() { return /* reexport */ post_featured_image_check; }); |
802 __webpack_require__.d(__webpack_exports__, "PostFeaturedImageCheck", function() { return /* reexport */ post_featured_image_check; }); |
2042 __webpack_require__.d(__webpack_exports__, "PostFormat", function() { return /* reexport */ post_format; }); |
803 __webpack_require__.d(__webpack_exports__, "PostFormat", function() { return /* reexport */ PostFormat; }); |
2043 __webpack_require__.d(__webpack_exports__, "PostFormatCheck", function() { return /* reexport */ post_format_check; }); |
804 __webpack_require__.d(__webpack_exports__, "PostFormatCheck", function() { return /* reexport */ post_format_check; }); |
2044 __webpack_require__.d(__webpack_exports__, "PostLastRevision", function() { return /* reexport */ post_last_revision; }); |
805 __webpack_require__.d(__webpack_exports__, "PostLastRevision", function() { return /* reexport */ post_last_revision; }); |
2045 __webpack_require__.d(__webpack_exports__, "PostLastRevisionCheck", function() { return /* reexport */ post_last_revision_check; }); |
806 __webpack_require__.d(__webpack_exports__, "PostLastRevisionCheck", function() { return /* reexport */ post_last_revision_check; }); |
2046 __webpack_require__.d(__webpack_exports__, "PostLockedModal", function() { return /* reexport */ post_locked_modal; }); |
807 __webpack_require__.d(__webpack_exports__, "PostLockedModal", function() { return /* reexport */ PostLockedModal; }); |
2047 __webpack_require__.d(__webpack_exports__, "PostPendingStatus", function() { return /* reexport */ post_pending_status; }); |
808 __webpack_require__.d(__webpack_exports__, "PostPendingStatus", function() { return /* reexport */ post_pending_status; }); |
2048 __webpack_require__.d(__webpack_exports__, "PostPendingStatusCheck", function() { return /* reexport */ post_pending_status_check; }); |
809 __webpack_require__.d(__webpack_exports__, "PostPendingStatusCheck", function() { return /* reexport */ post_pending_status_check; }); |
2049 __webpack_require__.d(__webpack_exports__, "PostPingbacks", function() { return /* reexport */ post_pingbacks; }); |
810 __webpack_require__.d(__webpack_exports__, "PostPingbacks", function() { return /* reexport */ post_pingbacks; }); |
2050 __webpack_require__.d(__webpack_exports__, "PostPreviewButton", function() { return /* reexport */ post_preview_button; }); |
811 __webpack_require__.d(__webpack_exports__, "PostPreviewButton", function() { return /* reexport */ post_preview_button; }); |
2051 __webpack_require__.d(__webpack_exports__, "PostPublishButton", function() { return /* reexport */ post_publish_button; }); |
812 __webpack_require__.d(__webpack_exports__, "PostPublishButton", function() { return /* reexport */ post_publish_button; }); |
2052 __webpack_require__.d(__webpack_exports__, "PostPublishButtonLabel", function() { return /* reexport */ post_publish_button_label; }); |
813 __webpack_require__.d(__webpack_exports__, "PostPublishButtonLabel", function() { return /* reexport */ post_publish_button_label; }); |
2053 __webpack_require__.d(__webpack_exports__, "PostPublishPanel", function() { return /* reexport */ post_publish_panel; }); |
814 __webpack_require__.d(__webpack_exports__, "PostPublishPanel", function() { return /* reexport */ post_publish_panel; }); |
2054 __webpack_require__.d(__webpack_exports__, "PostSavedState", function() { return /* reexport */ post_saved_state; }); |
815 __webpack_require__.d(__webpack_exports__, "PostSavedState", function() { return /* reexport */ PostSavedState; }); |
2055 __webpack_require__.d(__webpack_exports__, "PostSchedule", function() { return /* reexport */ post_schedule; }); |
816 __webpack_require__.d(__webpack_exports__, "PostSchedule", function() { return /* reexport */ PostSchedule; }); |
2056 __webpack_require__.d(__webpack_exports__, "PostScheduleCheck", function() { return /* reexport */ post_schedule_check; }); |
817 __webpack_require__.d(__webpack_exports__, "PostScheduleCheck", function() { return /* reexport */ post_schedule_check; }); |
2057 __webpack_require__.d(__webpack_exports__, "PostScheduleLabel", function() { return /* reexport */ post_schedule_label; }); |
818 __webpack_require__.d(__webpack_exports__, "PostScheduleLabel", function() { return /* reexport */ post_schedule_label; }); |
2058 __webpack_require__.d(__webpack_exports__, "PostSlug", function() { return /* reexport */ post_slug; }); |
819 __webpack_require__.d(__webpack_exports__, "PostSlug", function() { return /* reexport */ post_slug; }); |
2059 __webpack_require__.d(__webpack_exports__, "PostSlugCheck", function() { return /* reexport */ PostSlugCheck; }); |
820 __webpack_require__.d(__webpack_exports__, "PostSlugCheck", function() { return /* reexport */ PostSlugCheck; }); |
2060 __webpack_require__.d(__webpack_exports__, "PostSticky", function() { return /* reexport */ post_sticky; }); |
821 __webpack_require__.d(__webpack_exports__, "PostSticky", function() { return /* reexport */ post_sticky; }); |
2061 __webpack_require__.d(__webpack_exports__, "PostStickyCheck", function() { return /* reexport */ post_sticky_check; }); |
822 __webpack_require__.d(__webpack_exports__, "PostStickyCheck", function() { return /* reexport */ post_sticky_check; }); |
2062 __webpack_require__.d(__webpack_exports__, "PostSwitchToDraftButton", function() { return /* reexport */ post_switch_to_draft_button; }); |
823 __webpack_require__.d(__webpack_exports__, "PostSwitchToDraftButton", function() { return /* reexport */ post_switch_to_draft_button; }); |
2063 __webpack_require__.d(__webpack_exports__, "PostTaxonomies", function() { return /* reexport */ post_taxonomies; }); |
824 __webpack_require__.d(__webpack_exports__, "PostTaxonomies", function() { return /* reexport */ post_taxonomies; }); |
2064 __webpack_require__.d(__webpack_exports__, "PostTaxonomiesCheck", function() { return /* reexport */ post_taxonomies_check; }); |
825 __webpack_require__.d(__webpack_exports__, "PostTaxonomiesCheck", function() { return /* reexport */ post_taxonomies_check; }); |
2065 __webpack_require__.d(__webpack_exports__, "PostTextEditor", function() { return /* reexport */ post_text_editor; }); |
826 __webpack_require__.d(__webpack_exports__, "PostTextEditor", function() { return /* reexport */ PostTextEditor; }); |
2066 __webpack_require__.d(__webpack_exports__, "PostTitle", function() { return /* reexport */ post_title; }); |
827 __webpack_require__.d(__webpack_exports__, "PostTitle", function() { return /* reexport */ PostTitle; }); |
2067 __webpack_require__.d(__webpack_exports__, "PostTrash", function() { return /* reexport */ post_trash; }); |
828 __webpack_require__.d(__webpack_exports__, "PostTrash", function() { return /* reexport */ post_trash; }); |
2068 __webpack_require__.d(__webpack_exports__, "PostTrashCheck", function() { return /* reexport */ post_trash_check; }); |
829 __webpack_require__.d(__webpack_exports__, "PostTrashCheck", function() { return /* reexport */ post_trash_check; }); |
2069 __webpack_require__.d(__webpack_exports__, "PostTypeSupportCheck", function() { return /* reexport */ post_type_support_check; }); |
830 __webpack_require__.d(__webpack_exports__, "PostTypeSupportCheck", function() { return /* reexport */ post_type_support_check; }); |
2070 __webpack_require__.d(__webpack_exports__, "PostVisibility", function() { return /* reexport */ post_visibility; }); |
831 __webpack_require__.d(__webpack_exports__, "PostVisibility", function() { return /* reexport */ post_visibility; }); |
2071 __webpack_require__.d(__webpack_exports__, "PostVisibilityLabel", function() { return /* reexport */ post_visibility_label; }); |
832 __webpack_require__.d(__webpack_exports__, "PostVisibilityLabel", function() { return /* reexport */ post_visibility_label; }); |
2072 __webpack_require__.d(__webpack_exports__, "PostVisibilityCheck", function() { return /* reexport */ post_visibility_check; }); |
833 __webpack_require__.d(__webpack_exports__, "PostVisibilityCheck", function() { return /* reexport */ post_visibility_check; }); |
2073 __webpack_require__.d(__webpack_exports__, "TableOfContents", function() { return /* reexport */ table_of_contents; }); |
834 __webpack_require__.d(__webpack_exports__, "TableOfContents", function() { return /* reexport */ table_of_contents; }); |
2074 __webpack_require__.d(__webpack_exports__, "UnsavedChangesWarning", function() { return /* reexport */ unsaved_changes_warning; }); |
835 __webpack_require__.d(__webpack_exports__, "UnsavedChangesWarning", function() { return /* reexport */ UnsavedChangesWarning; }); |
2075 __webpack_require__.d(__webpack_exports__, "WordCount", function() { return /* reexport */ word_count; }); |
836 __webpack_require__.d(__webpack_exports__, "WordCount", function() { return /* reexport */ WordCount; }); |
2076 __webpack_require__.d(__webpack_exports__, "EditorProvider", function() { return /* reexport */ provider; }); |
837 __webpack_require__.d(__webpack_exports__, "EditorProvider", function() { return /* reexport */ provider; }); |
2077 __webpack_require__.d(__webpack_exports__, "ServerSideRender", function() { return /* reexport */ external_this_wp_serverSideRender_default.a; }); |
838 __webpack_require__.d(__webpack_exports__, "ServerSideRender", function() { return /* reexport */ external_wp_serverSideRender_default.a; }); |
2078 __webpack_require__.d(__webpack_exports__, "RichText", function() { return /* reexport */ RichText; }); |
839 __webpack_require__.d(__webpack_exports__, "RichText", function() { return /* reexport */ RichText; }); |
2079 __webpack_require__.d(__webpack_exports__, "Autocomplete", function() { return /* reexport */ Autocomplete; }); |
840 __webpack_require__.d(__webpack_exports__, "Autocomplete", function() { return /* reexport */ Autocomplete; }); |
2080 __webpack_require__.d(__webpack_exports__, "AlignmentToolbar", function() { return /* reexport */ AlignmentToolbar; }); |
841 __webpack_require__.d(__webpack_exports__, "AlignmentToolbar", function() { return /* reexport */ AlignmentToolbar; }); |
2081 __webpack_require__.d(__webpack_exports__, "BlockAlignmentToolbar", function() { return /* reexport */ BlockAlignmentToolbar; }); |
842 __webpack_require__.d(__webpack_exports__, "BlockAlignmentToolbar", function() { return /* reexport */ BlockAlignmentToolbar; }); |
2082 __webpack_require__.d(__webpack_exports__, "BlockControls", function() { return /* reexport */ BlockControls; }); |
843 __webpack_require__.d(__webpack_exports__, "BlockControls", function() { return /* reexport */ BlockControls; }); |
2313 __webpack_require__.d(selectors_namespaceObject, "getBlockInsertionPoint", function() { return getBlockInsertionPoint; }); |
1001 __webpack_require__.d(selectors_namespaceObject, "getBlockInsertionPoint", function() { return getBlockInsertionPoint; }); |
2314 __webpack_require__.d(selectors_namespaceObject, "isBlockInsertionPointVisible", function() { return isBlockInsertionPointVisible; }); |
1002 __webpack_require__.d(selectors_namespaceObject, "isBlockInsertionPointVisible", function() { return isBlockInsertionPointVisible; }); |
2315 __webpack_require__.d(selectors_namespaceObject, "isValidTemplate", function() { return isValidTemplate; }); |
1003 __webpack_require__.d(selectors_namespaceObject, "isValidTemplate", function() { return isValidTemplate; }); |
2316 __webpack_require__.d(selectors_namespaceObject, "getTemplate", function() { return getTemplate; }); |
1004 __webpack_require__.d(selectors_namespaceObject, "getTemplate", function() { return getTemplate; }); |
2317 __webpack_require__.d(selectors_namespaceObject, "getTemplateLock", function() { return getTemplateLock; }); |
1005 __webpack_require__.d(selectors_namespaceObject, "getTemplateLock", function() { return getTemplateLock; }); |
2318 __webpack_require__.d(selectors_namespaceObject, "canInsertBlockType", function() { return selectors_canInsertBlockType; }); |
1006 __webpack_require__.d(selectors_namespaceObject, "canInsertBlockType", function() { return canInsertBlockType; }); |
2319 __webpack_require__.d(selectors_namespaceObject, "getInserterItems", function() { return getInserterItems; }); |
1007 __webpack_require__.d(selectors_namespaceObject, "getInserterItems", function() { return getInserterItems; }); |
2320 __webpack_require__.d(selectors_namespaceObject, "hasInserterItems", function() { return hasInserterItems; }); |
1008 __webpack_require__.d(selectors_namespaceObject, "hasInserterItems", function() { return hasInserterItems; }); |
2321 __webpack_require__.d(selectors_namespaceObject, "getBlockListSettings", function() { return getBlockListSettings; }); |
1009 __webpack_require__.d(selectors_namespaceObject, "getBlockListSettings", function() { return getBlockListSettings; }); |
2322 |
1010 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetDefaultTemplateTypes", function() { return __experimentalGetDefaultTemplateTypes; }); |
2323 // EXTERNAL MODULE: external {"this":["wp","blockEditor"]} |
1011 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetDefaultTemplatePartAreas", function() { return __experimentalGetDefaultTemplatePartAreas; }); |
2324 var external_this_wp_blockEditor_ = __webpack_require__(7); |
1012 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetDefaultTemplateType", function() { return __experimentalGetDefaultTemplateType; }); |
2325 |
1013 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetTemplateInfo", function() { return __experimentalGetTemplateInfo; }); |
2326 // EXTERNAL MODULE: external {"this":["wp","blocks"]} |
1014 |
2327 var external_this_wp_blocks_ = __webpack_require__(10); |
1015 // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/actions.js |
2328 |
1016 var actions_namespaceObject = {}; |
2329 // EXTERNAL MODULE: external {"this":["wp","coreData"]} |
1017 __webpack_require__.r(actions_namespaceObject); |
2330 var external_this_wp_coreData_ = __webpack_require__(98); |
1018 __webpack_require__.d(actions_namespaceObject, "setupEditor", function() { return actions_setupEditor; }); |
2331 |
1019 __webpack_require__.d(actions_namespaceObject, "__experimentalTearDownEditor", function() { return actions_experimentalTearDownEditor; }); |
2332 // EXTERNAL MODULE: external {"this":["wp","keyboardShortcuts"]} |
1020 __webpack_require__.d(actions_namespaceObject, "resetPost", function() { return resetPost; }); |
2333 var external_this_wp_keyboardShortcuts_ = __webpack_require__(52); |
1021 __webpack_require__.d(actions_namespaceObject, "resetAutosave", function() { return resetAutosave; }); |
2334 |
1022 __webpack_require__.d(actions_namespaceObject, "__experimentalRequestPostUpdateStart", function() { return __experimentalRequestPostUpdateStart; }); |
2335 // EXTERNAL MODULE: external {"this":["wp","notices"]} |
1023 __webpack_require__.d(actions_namespaceObject, "__experimentalRequestPostUpdateFinish", function() { return __experimentalRequestPostUpdateFinish; }); |
2336 var external_this_wp_notices_ = __webpack_require__(100); |
1024 __webpack_require__.d(actions_namespaceObject, "updatePost", function() { return updatePost; }); |
2337 |
1025 __webpack_require__.d(actions_namespaceObject, "setupEditorState", function() { return setupEditorState; }); |
2338 // EXTERNAL MODULE: external {"this":["wp","richText"]} |
1026 __webpack_require__.d(actions_namespaceObject, "editPost", function() { return actions_editPost; }); |
2339 var external_this_wp_richText_ = __webpack_require__(25); |
1027 __webpack_require__.d(actions_namespaceObject, "savePost", function() { return actions_savePost; }); |
2340 |
1028 __webpack_require__.d(actions_namespaceObject, "refreshPost", function() { return refreshPost; }); |
2341 // EXTERNAL MODULE: external {"this":["wp","viewport"]} |
1029 __webpack_require__.d(actions_namespaceObject, "trashPost", function() { return trashPost; }); |
2342 var external_this_wp_viewport_ = __webpack_require__(81); |
1030 __webpack_require__.d(actions_namespaceObject, "autosave", function() { return actions_autosave; }); |
2343 |
1031 __webpack_require__.d(actions_namespaceObject, "redo", function() { return actions_redo; }); |
2344 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
1032 __webpack_require__.d(actions_namespaceObject, "undo", function() { return actions_undo; }); |
2345 var defineProperty = __webpack_require__(5); |
1033 __webpack_require__.d(actions_namespaceObject, "createUndoLevel", function() { return createUndoLevel; }); |
2346 |
1034 __webpack_require__.d(actions_namespaceObject, "updatePostLock", function() { return actions_updatePostLock; }); |
2347 // EXTERNAL MODULE: external {"this":["wp","data"]} |
1035 __webpack_require__.d(actions_namespaceObject, "enablePublishSidebar", function() { return enablePublishSidebar; }); |
2348 var external_this_wp_data_ = __webpack_require__(4); |
1036 __webpack_require__.d(actions_namespaceObject, "disablePublishSidebar", function() { return disablePublishSidebar; }); |
2349 |
1037 __webpack_require__.d(actions_namespaceObject, "lockPostSaving", function() { return lockPostSaving; }); |
2350 // EXTERNAL MODULE: external {"this":["wp","dataControls"]} |
1038 __webpack_require__.d(actions_namespaceObject, "unlockPostSaving", function() { return unlockPostSaving; }); |
2351 var external_this_wp_dataControls_ = __webpack_require__(36); |
1039 __webpack_require__.d(actions_namespaceObject, "lockPostAutosaving", function() { return lockPostAutosaving; }); |
2352 |
1040 __webpack_require__.d(actions_namespaceObject, "unlockPostAutosaving", function() { return unlockPostAutosaving; }); |
2353 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js |
1041 __webpack_require__.d(actions_namespaceObject, "resetEditorBlocks", function() { return actions_resetEditorBlocks; }); |
2354 var esm_typeof = __webpack_require__(40); |
1042 __webpack_require__.d(actions_namespaceObject, "updateEditorSettings", function() { return actions_updateEditorSettings; }); |
2355 |
1043 __webpack_require__.d(actions_namespaceObject, "resetBlocks", function() { return resetBlocks; }); |
2356 // EXTERNAL MODULE: ./node_modules/redux-optimist/index.js |
1044 __webpack_require__.d(actions_namespaceObject, "receiveBlocks", function() { return receiveBlocks; }); |
2357 var redux_optimist = __webpack_require__(134); |
1045 __webpack_require__.d(actions_namespaceObject, "updateBlock", function() { return updateBlock; }); |
2358 var redux_optimist_default = /*#__PURE__*/__webpack_require__.n(redux_optimist); |
1046 __webpack_require__.d(actions_namespaceObject, "updateBlockAttributes", function() { return updateBlockAttributes; }); |
2359 |
1047 __webpack_require__.d(actions_namespaceObject, "selectBlock", function() { return actions_selectBlock; }); |
2360 // EXTERNAL MODULE: external {"this":"lodash"} |
1048 __webpack_require__.d(actions_namespaceObject, "startMultiSelect", function() { return startMultiSelect; }); |
2361 var external_this_lodash_ = __webpack_require__(2); |
1049 __webpack_require__.d(actions_namespaceObject, "stopMultiSelect", function() { return stopMultiSelect; }); |
|
1050 __webpack_require__.d(actions_namespaceObject, "multiSelect", function() { return multiSelect; }); |
|
1051 __webpack_require__.d(actions_namespaceObject, "clearSelectedBlock", function() { return actions_clearSelectedBlock; }); |
|
1052 __webpack_require__.d(actions_namespaceObject, "toggleSelection", function() { return toggleSelection; }); |
|
1053 __webpack_require__.d(actions_namespaceObject, "replaceBlocks", function() { return replaceBlocks; }); |
|
1054 __webpack_require__.d(actions_namespaceObject, "replaceBlock", function() { return replaceBlock; }); |
|
1055 __webpack_require__.d(actions_namespaceObject, "moveBlocksDown", function() { return moveBlocksDown; }); |
|
1056 __webpack_require__.d(actions_namespaceObject, "moveBlocksUp", function() { return moveBlocksUp; }); |
|
1057 __webpack_require__.d(actions_namespaceObject, "moveBlockToPosition", function() { return moveBlockToPosition; }); |
|
1058 __webpack_require__.d(actions_namespaceObject, "insertBlock", function() { return insertBlock; }); |
|
1059 __webpack_require__.d(actions_namespaceObject, "insertBlocks", function() { return actions_insertBlocks; }); |
|
1060 __webpack_require__.d(actions_namespaceObject, "showInsertionPoint", function() { return showInsertionPoint; }); |
|
1061 __webpack_require__.d(actions_namespaceObject, "hideInsertionPoint", function() { return hideInsertionPoint; }); |
|
1062 __webpack_require__.d(actions_namespaceObject, "setTemplateValidity", function() { return actions_setTemplateValidity; }); |
|
1063 __webpack_require__.d(actions_namespaceObject, "synchronizeTemplate", function() { return actions_synchronizeTemplate; }); |
|
1064 __webpack_require__.d(actions_namespaceObject, "mergeBlocks", function() { return mergeBlocks; }); |
|
1065 __webpack_require__.d(actions_namespaceObject, "removeBlocks", function() { return removeBlocks; }); |
|
1066 __webpack_require__.d(actions_namespaceObject, "removeBlock", function() { return removeBlock; }); |
|
1067 __webpack_require__.d(actions_namespaceObject, "toggleBlockMode", function() { return toggleBlockMode; }); |
|
1068 __webpack_require__.d(actions_namespaceObject, "startTyping", function() { return startTyping; }); |
|
1069 __webpack_require__.d(actions_namespaceObject, "stopTyping", function() { return stopTyping; }); |
|
1070 __webpack_require__.d(actions_namespaceObject, "enterFormattedText", function() { return enterFormattedText; }); |
|
1071 __webpack_require__.d(actions_namespaceObject, "exitFormattedText", function() { return exitFormattedText; }); |
|
1072 __webpack_require__.d(actions_namespaceObject, "insertDefaultBlock", function() { return actions_insertDefaultBlock; }); |
|
1073 __webpack_require__.d(actions_namespaceObject, "updateBlockListSettings", function() { return updateBlockListSettings; }); |
|
1074 |
|
1075 // EXTERNAL MODULE: external ["wp","blockEditor"] |
|
1076 var external_wp_blockEditor_ = __webpack_require__("axFQ"); |
|
1077 |
|
1078 // EXTERNAL MODULE: external ["wp","coreData"] |
|
1079 var external_wp_coreData_ = __webpack_require__("jZUy"); |
|
1080 |
|
1081 // EXTERNAL MODULE: external ["wp","richText"] |
|
1082 var external_wp_richText_ = __webpack_require__("qRz9"); |
|
1083 |
|
1084 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
1085 var esm_extends = __webpack_require__("wx14"); |
|
1086 |
|
1087 // EXTERNAL MODULE: external ["wp","element"] |
|
1088 var external_wp_element_ = __webpack_require__("GRId"); |
|
1089 |
|
1090 // EXTERNAL MODULE: external "lodash" |
|
1091 var external_lodash_ = __webpack_require__("YLtl"); |
|
1092 |
|
1093 // EXTERNAL MODULE: external ["wp","blocks"] |
|
1094 var external_wp_blocks_ = __webpack_require__("HSyU"); |
|
1095 |
|
1096 // EXTERNAL MODULE: external ["wp","data"] |
|
1097 var external_wp_data_ = __webpack_require__("1ZqX"); |
|
1098 |
|
1099 // EXTERNAL MODULE: external ["wp","compose"] |
|
1100 var external_wp_compose_ = __webpack_require__("K9lf"); |
|
1101 |
|
1102 // EXTERNAL MODULE: external ["wp","hooks"] |
|
1103 var external_wp_hooks_ = __webpack_require__("g56x"); |
|
1104 |
|
1105 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/custom-sources-backwards-compatibility.js |
|
1106 |
|
1107 |
|
1108 |
|
1109 /** |
|
1110 * External dependencies |
|
1111 */ |
|
1112 |
|
1113 /** |
|
1114 * WordPress dependencies |
|
1115 */ |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */ |
|
1124 |
|
1125 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */ |
|
1126 |
|
1127 /** |
|
1128 * Object whose keys are the names of block attributes, where each value |
|
1129 * represents the meta key to which the block attribute is intended to save. |
|
1130 * |
|
1131 * @see https://developer.wordpress.org/reference/functions/register_meta/ |
|
1132 * |
|
1133 * @typedef {Object<string,string>} WPMetaAttributeMapping |
|
1134 */ |
|
1135 |
|
1136 /** |
|
1137 * Given a mapping of attribute names (meta source attributes) to their |
|
1138 * associated meta key, returns a higher order component that overrides its |
|
1139 * `attributes` and `setAttributes` props to sync any changes with the edited |
|
1140 * post's meta keys. |
|
1141 * |
|
1142 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping. |
|
1143 * |
|
1144 * @return {WPHigherOrderComponent} Higher-order component. |
|
1145 */ |
|
1146 |
|
1147 const createWithMetaAttributeSource = metaAttributes => Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => ({ |
|
1148 attributes, |
|
1149 setAttributes, |
|
1150 ...props |
|
1151 }) => { |
|
1152 const postType = Object(external_wp_data_["useSelect"])(select => select('core/editor').getCurrentPostType(), []); |
|
1153 const [meta, setMeta] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'meta'); |
|
1154 const mergedAttributes = Object(external_wp_element_["useMemo"])(() => ({ ...attributes, |
|
1155 ...Object(external_lodash_["mapValues"])(metaAttributes, metaKey => meta[metaKey]) |
|
1156 }), [attributes, meta]); |
|
1157 return Object(external_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({ |
|
1158 attributes: mergedAttributes, |
|
1159 setAttributes: nextAttributes => { |
|
1160 const nextMeta = Object(external_lodash_["mapKeys"])( // Filter to intersection of keys between the updated |
|
1161 // attributes and those with an associated meta key. |
|
1162 Object(external_lodash_["pickBy"])(nextAttributes, (value, key) => metaAttributes[key]), // Rename the keys to the expected meta key name. |
|
1163 (value, attributeKey) => metaAttributes[attributeKey]); |
|
1164 |
|
1165 if (!Object(external_lodash_["isEmpty"])(nextMeta)) { |
|
1166 setMeta(nextMeta); |
|
1167 } |
|
1168 |
|
1169 setAttributes(nextAttributes); |
|
1170 } |
|
1171 }, props)); |
|
1172 }, 'withMetaAttributeSource'); |
|
1173 /** |
|
1174 * Filters a registered block's settings to enhance a block's `edit` component |
|
1175 * to upgrade meta-sourced attributes to use the post's meta entity property. |
|
1176 * |
|
1177 * @param {WPBlockSettings} settings Registered block settings. |
|
1178 * |
|
1179 * @return {WPBlockSettings} Filtered block settings. |
|
1180 */ |
|
1181 |
|
1182 |
|
1183 function shimAttributeSource(settings) { |
|
1184 /** @type {WPMetaAttributeMapping} */ |
|
1185 const metaAttributes = Object(external_lodash_["mapValues"])(Object(external_lodash_["pickBy"])(settings.attributes, { |
|
1186 source: 'meta' |
|
1187 }), 'meta'); |
|
1188 |
|
1189 if (!Object(external_lodash_["isEmpty"])(metaAttributes)) { |
|
1190 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit); |
|
1191 } |
|
1192 |
|
1193 return settings; |
|
1194 } |
|
1195 |
|
1196 Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource); // The above filter will only capture blocks registered after the filter was |
|
1197 // added. There may already be blocks registered by this point, and those must |
|
1198 // be updated to apply the shim. |
|
1199 // |
|
1200 // The following implementation achieves this, albeit with a couple caveats: |
|
1201 // - Only blocks registered on the global store will be modified. |
|
1202 // - The block settings are directly mutated, since there is currently no |
|
1203 // mechanism to update an existing block registration. This is the reason for |
|
1204 // `getBlockType` separate from `getBlockTypes`, since the latter returns a |
|
1205 // _copy_ of the block registration (i.e. the mutation would not affect the |
|
1206 // actual registered block settings). |
|
1207 // |
|
1208 // `getBlockTypes` or `getBlockType` implementation could change in the future |
|
1209 // in regards to creating settings clones, but the corresponding end-to-end |
|
1210 // tests for meta blocks should cover against any potential regressions. |
|
1211 // |
|
1212 // In the future, we could support updating block settings, at which point this |
|
1213 // implementation could use that mechanism instead. |
|
1214 |
|
1215 Object(external_wp_data_["select"])(external_wp_blocks_["store"]).getBlockTypes().map(({ |
|
1216 name |
|
1217 }) => Object(external_wp_data_["select"])(external_wp_blocks_["store"]).getBlockType(name)).forEach(shimAttributeSource); |
|
1218 |
|
1219 // EXTERNAL MODULE: external ["wp","apiFetch"] |
|
1220 var external_wp_apiFetch_ = __webpack_require__("ywyh"); |
|
1221 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_); |
|
1222 |
|
1223 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/user.js |
|
1224 |
|
1225 |
|
1226 /** |
|
1227 * WordPress dependencies |
|
1228 */ |
|
1229 |
|
1230 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */ |
|
1231 |
|
1232 /** |
|
1233 * A user mentions completer. |
|
1234 * |
|
1235 * @type {WPCompleter} |
|
1236 */ |
|
1237 |
|
1238 /* harmony default export */ var autocompleters_user = ({ |
|
1239 name: 'users', |
|
1240 className: 'editor-autocompleters__user', |
|
1241 triggerPrefix: '@', |
|
1242 |
|
1243 options(search) { |
|
1244 let payload = ''; |
|
1245 |
|
1246 if (search) { |
|
1247 payload = '?search=' + encodeURIComponent(search); |
|
1248 } |
|
1249 |
|
1250 return external_wp_apiFetch_default()({ |
|
1251 path: '/wp/v2/users' + payload |
|
1252 }); |
|
1253 }, |
|
1254 |
|
1255 isDebounced: true, |
|
1256 |
|
1257 getOptionKeywords(user) { |
|
1258 return [user.slug, user.name]; |
|
1259 }, |
|
1260 |
|
1261 getOptionLabel(user) { |
|
1262 const avatar = user.avatar_urls && user.avatar_urls[24] ? Object(external_wp_element_["createElement"])("img", { |
|
1263 key: "avatar", |
|
1264 className: "editor-autocompleters__user-avatar", |
|
1265 alt: "", |
|
1266 src: user.avatar_urls[24] |
|
1267 }) : Object(external_wp_element_["createElement"])("span", { |
|
1268 className: "editor-autocompleters__no-avatar" |
|
1269 }); |
|
1270 return [avatar, Object(external_wp_element_["createElement"])("span", { |
|
1271 key: "name", |
|
1272 className: "editor-autocompleters__user-name" |
|
1273 }, user.name), Object(external_wp_element_["createElement"])("span", { |
|
1274 key: "slug", |
|
1275 className: "editor-autocompleters__user-slug" |
|
1276 }, user.slug)]; |
|
1277 }, |
|
1278 |
|
1279 getOptionCompletion(user) { |
|
1280 return `@${user.slug}`; |
|
1281 } |
|
1282 |
|
1283 }); |
|
1284 |
|
1285 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/default-autocompleters.js |
|
1286 /** |
|
1287 * External dependencies |
|
1288 */ |
|
1289 |
|
1290 /** |
|
1291 * WordPress dependencies |
|
1292 */ |
|
1293 |
|
1294 |
|
1295 /** |
|
1296 * Internal dependencies |
|
1297 */ |
|
1298 |
|
1299 |
|
1300 |
|
1301 function setDefaultCompleters(completers = []) { |
|
1302 // Provide copies so filters may directly modify them. |
|
1303 completers.push(Object(external_lodash_["clone"])(autocompleters_user)); |
|
1304 return completers; |
|
1305 } |
|
1306 |
|
1307 Object(external_wp_hooks_["addFilter"])('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters); |
|
1308 |
|
1309 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/index.js |
|
1310 /** |
|
1311 * Internal dependencies |
|
1312 */ |
|
1313 |
|
1314 |
|
1315 |
|
1316 // EXTERNAL MODULE: external ["wp","dataControls"] |
|
1317 var external_wp_dataControls_ = __webpack_require__("51Zz"); |
2362 |
1318 |
2363 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/defaults.js |
1319 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/defaults.js |
2364 |
|
2365 |
|
2366 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2367 |
|
2368 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
2369 |
|
2370 /** |
1320 /** |
2371 * WordPress dependencies |
1321 * WordPress dependencies |
2372 */ |
1322 */ |
2373 |
1323 |
2374 var PREFERENCES_DEFAULTS = { |
1324 const PREFERENCES_DEFAULTS = { |
2375 insertUsage: {}, |
1325 insertUsage: {}, |
2376 // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580. |
1326 // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580. |
2377 isPublishSidebarEnabled: true |
1327 isPublishSidebarEnabled: true |
2378 }; |
1328 }; |
2379 /** |
1329 /** |
2788 * @param {Object} action Dispatched action. |
1620 * @param {Object} action Dispatched action. |
2789 * |
1621 * |
2790 * @return {Object} Updated state. |
1622 * @return {Object} Updated state. |
2791 */ |
1623 */ |
2792 |
1624 |
2793 function reducer_editorSettings() { |
1625 function reducer_editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) { |
2794 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EDITOR_SETTINGS_DEFAULTS; |
|
2795 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
2796 |
|
2797 switch (action.type) { |
1626 switch (action.type) { |
2798 case 'UPDATE_EDITOR_SETTINGS': |
1627 case 'UPDATE_EDITOR_SETTINGS': |
2799 return reducer_objectSpread({}, state, {}, action.settings); |
1628 return { ...state, |
|
1629 ...action.settings |
|
1630 }; |
2800 } |
1631 } |
2801 |
1632 |
2802 return state; |
1633 return state; |
2803 } |
1634 } |
2804 /* harmony default export */ var reducer = (redux_optimist_default()(Object(external_this_wp_data_["combineReducers"])({ |
1635 /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({ |
2805 postId: reducer_postId, |
1636 postId: reducer_postId, |
2806 postType: reducer_postType, |
1637 postType: reducer_postType, |
2807 preferences: preferences, |
1638 preferences, |
2808 saving: saving, |
1639 saving, |
2809 postLock: postLock, |
1640 postLock, |
2810 reusableBlocks: reducer_reusableBlocks, |
|
2811 template: reducer_template, |
1641 template: reducer_template, |
2812 postSavingLock: postSavingLock, |
1642 postSavingLock, |
2813 isReady: reducer_isReady, |
1643 isReady: reducer_isReady, |
2814 editorSettings: reducer_editorSettings, |
1644 editorSettings: reducer_editorSettings, |
2815 postAutosavingLock: postAutosavingLock |
1645 postAutosavingLock |
2816 }))); |
1646 })); |
2817 |
1647 |
2818 // EXTERNAL MODULE: ./node_modules/refx/refx.js |
1648 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
2819 var refx = __webpack_require__(110); |
1649 var rememo = __webpack_require__("pPDe"); |
2820 var refx_default = /*#__PURE__*/__webpack_require__.n(refx); |
1650 |
2821 |
1651 // EXTERNAL MODULE: external ["wp","date"] |
2822 // EXTERNAL MODULE: external {"this":"regeneratorRuntime"} |
1652 var external_wp_date_ = __webpack_require__("FqII"); |
2823 var external_this_regeneratorRuntime_ = __webpack_require__(24); |
1653 |
2824 var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_); |
1654 // EXTERNAL MODULE: external ["wp","url"] |
2825 |
1655 var external_wp_url_ = __webpack_require__("Mmq9"); |
2826 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js |
1656 |
2827 var asyncToGenerator = __webpack_require__(50); |
1657 // EXTERNAL MODULE: external ["wp","deprecated"] |
2828 |
1658 var external_wp_deprecated_ = __webpack_require__("NMb1"); |
2829 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} |
1659 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); |
2830 var external_this_wp_apiFetch_ = __webpack_require__(45); |
1660 |
2831 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); |
1661 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js |
2832 |
1662 var layout = __webpack_require__("Civd"); |
2833 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
2834 var external_this_wp_i18n_ = __webpack_require__(1); |
|
2835 |
|
2836 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
2837 var toConsumableArray = __webpack_require__(18); |
|
2838 |
|
2839 // EXTERNAL MODULE: external {"this":["wp","deprecated"]} |
|
2840 var external_this_wp_deprecated_ = __webpack_require__(37); |
|
2841 var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_); |
|
2842 |
1663 |
2843 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/constants.js |
1664 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/constants.js |
2844 /** |
1665 /** |
2845 * Set of post properties for which edits should assume a merging behavior, |
1666 * Set of post properties for which edits should assume a merging behavior, |
2846 * assuming an object value. |
1667 * assuming an object value. |
2847 * |
1668 * |
2848 * @type {Set} |
1669 * @type {Set} |
2849 */ |
1670 */ |
2850 var EDIT_MERGE_PROPERTIES = new Set(['meta']); |
1671 const EDIT_MERGE_PROPERTIES = new Set(['meta']); |
2851 /** |
1672 /** |
2852 * Constant for the store module (or reducer) key. |
1673 * Constant for the store module (or reducer) key. |
2853 * |
1674 * |
2854 * @type {string} |
1675 * @type {string} |
2855 */ |
1676 */ |
2856 |
1677 |
2857 var STORE_KEY = 'core/editor'; |
1678 const STORE_NAME = 'core/editor'; |
2858 var POST_UPDATE_TRANSACTION_ID = 'post-update'; |
1679 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID'; |
2859 var SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID'; |
1680 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID'; |
2860 var TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID'; |
1681 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/; |
2861 var PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/; |
1682 const ONE_MINUTE_IN_MS = 60 * 1000; |
2862 var ONE_MINUTE_IN_MS = 60 * 1000; |
1683 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content']; |
2863 var AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content']; |
1684 |
|
1685 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/url.js |
|
1686 /** |
|
1687 * External dependencies |
|
1688 */ |
|
1689 |
|
1690 /** |
|
1691 * WordPress dependencies |
|
1692 */ |
|
1693 |
|
1694 |
|
1695 /** |
|
1696 * Returns the URL of a WPAdmin Page. |
|
1697 * |
|
1698 * TODO: This should be moved to a module less specific to the editor. |
|
1699 * |
|
1700 * @param {string} page Page to navigate to. |
|
1701 * @param {Object} query Query Args. |
|
1702 * |
|
1703 * @return {string} WPAdmin URL. |
|
1704 */ |
|
1705 |
|
1706 function getWPAdminURL(page, query) { |
|
1707 return Object(external_wp_url_["addQueryArgs"])(page, query); |
|
1708 } |
|
1709 /** |
|
1710 * Performs some basic cleanup of a string for use as a post slug |
|
1711 * |
|
1712 * This replicates some of what sanitize_title() does in WordPress core, but |
|
1713 * is only designed to approximate what the slug will be. |
|
1714 * |
|
1715 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters. |
|
1716 * Removes combining diacritical marks. Converts whitespace, periods, |
|
1717 * and forward slashes to hyphens. Removes any remaining non-word characters |
|
1718 * except hyphens and underscores. Converts remaining string to lowercase. |
|
1719 * It does not account for octets, HTML entities, or other encoded characters. |
|
1720 * |
|
1721 * @param {string} string Title or slug to be processed |
|
1722 * |
|
1723 * @return {string} Processed string |
|
1724 */ |
|
1725 |
|
1726 function cleanForSlug(string) { |
|
1727 if (!string) { |
|
1728 return ''; |
|
1729 } |
|
1730 |
|
1731 return Object(external_lodash_["trim"])(Object(external_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\p{L}\p{N}_-]+/gu, '').toLowerCase(), '-'); |
|
1732 } |
|
1733 |
|
1734 // EXTERNAL MODULE: external ["wp","primitives"] |
|
1735 var external_wp_primitives_ = __webpack_require__("Tqx9"); |
|
1736 |
|
1737 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/header.js |
|
1738 |
|
1739 |
|
1740 /** |
|
1741 * WordPress dependencies |
|
1742 */ |
|
1743 |
|
1744 const header = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], { |
|
1745 xmlns: "http://www.w3.org/2000/svg", |
|
1746 viewBox: "0 0 24 24" |
|
1747 }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], { |
|
1748 d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" |
|
1749 })); |
|
1750 /* harmony default export */ var library_header = (header); |
|
1751 |
|
1752 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/footer.js |
|
1753 |
|
1754 |
|
1755 /** |
|
1756 * WordPress dependencies |
|
1757 */ |
|
1758 |
|
1759 const footer = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], { |
|
1760 xmlns: "http://www.w3.org/2000/svg", |
|
1761 viewBox: "0 0 24 24" |
|
1762 }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], { |
|
1763 fillRule: "evenodd", |
|
1764 d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" |
|
1765 })); |
|
1766 /* harmony default export */ var library_footer = (footer); |
|
1767 |
|
1768 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/sidebar.js |
|
1769 |
|
1770 |
|
1771 /** |
|
1772 * WordPress dependencies |
|
1773 */ |
|
1774 |
|
1775 const sidebar = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], { |
|
1776 xmlns: "http://www.w3.org/2000/svg", |
|
1777 viewBox: "0 0 24 24" |
|
1778 }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], { |
|
1779 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" |
|
1780 })); |
|
1781 /* harmony default export */ var library_sidebar = (sidebar); |
|
1782 |
|
1783 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/get-template-part-icon.js |
|
1784 /** |
|
1785 * WordPress dependencies |
|
1786 */ |
|
1787 |
|
1788 /** |
|
1789 * Helper function to retrieve the corresponding icon by name. |
|
1790 * |
|
1791 * @param {string} iconName The name of the icon. |
|
1792 * |
|
1793 * @return {Object} The corresponding icon. |
|
1794 */ |
|
1795 |
|
1796 function getTemplatePartIcon(iconName) { |
|
1797 if ('header' === iconName) { |
|
1798 return library_header; |
|
1799 } else if ('footer' === iconName) { |
|
1800 return library_footer; |
|
1801 } else if ('sidebar' === iconName) { |
|
1802 return library_sidebar; |
|
1803 } |
|
1804 |
|
1805 return layout["a" /* default */]; |
|
1806 } |
|
1807 |
|
1808 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/selectors.js |
|
1809 /** |
|
1810 * External dependencies |
|
1811 */ |
|
1812 |
|
1813 |
|
1814 /** |
|
1815 * WordPress dependencies |
|
1816 */ |
|
1817 |
|
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 /** |
|
1826 * Internal dependencies |
|
1827 */ |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 /** |
|
1835 * Shared reference to an empty object for cases where it is important to avoid |
|
1836 * returning a new object reference on every invocation, as in a connected or |
|
1837 * other pure component which performs `shouldComponentUpdate` check on props. |
|
1838 * This should be used as a last resort, since the normalized data should be |
|
1839 * maintained by the reducer result in state. |
|
1840 */ |
|
1841 |
|
1842 const EMPTY_OBJECT = {}; |
|
1843 /** |
|
1844 * Shared reference to an empty array for cases where it is important to avoid |
|
1845 * returning a new array reference on every invocation, as in a connected or |
|
1846 * other pure component which performs `shouldComponentUpdate` check on props. |
|
1847 * This should be used as a last resort, since the normalized data should be |
|
1848 * maintained by the reducer result in state. |
|
1849 */ |
|
1850 |
|
1851 const EMPTY_ARRAY = []; |
|
1852 /** |
|
1853 * Returns true if any past editor history snapshots exist, or false otherwise. |
|
1854 * |
|
1855 * @param {Object} state Global application state. |
|
1856 * |
|
1857 * @return {boolean} Whether undo history exists. |
|
1858 */ |
|
1859 |
|
1860 const hasEditorUndo = Object(external_wp_data_["createRegistrySelector"])(select => () => { |
|
1861 return select('core').hasUndo(); |
|
1862 }); |
|
1863 /** |
|
1864 * Returns true if any future editor history snapshots exist, or false |
|
1865 * otherwise. |
|
1866 * |
|
1867 * @param {Object} state Global application state. |
|
1868 * |
|
1869 * @return {boolean} Whether redo history exists. |
|
1870 */ |
|
1871 |
|
1872 const hasEditorRedo = Object(external_wp_data_["createRegistrySelector"])(select => () => { |
|
1873 return select('core').hasRedo(); |
|
1874 }); |
|
1875 /** |
|
1876 * Returns true if the currently edited post is yet to be saved, or false if |
|
1877 * the post has been saved. |
|
1878 * |
|
1879 * @param {Object} state Global application state. |
|
1880 * |
|
1881 * @return {boolean} Whether the post is new. |
|
1882 */ |
|
1883 |
|
1884 function selectors_isEditedPostNew(state) { |
|
1885 return selectors_getCurrentPost(state).status === 'auto-draft'; |
|
1886 } |
|
1887 /** |
|
1888 * Returns true if content includes unsaved changes, or false otherwise. |
|
1889 * |
|
1890 * @param {Object} state Editor state. |
|
1891 * |
|
1892 * @return {boolean} Whether content includes unsaved changes. |
|
1893 */ |
|
1894 |
|
1895 function hasChangedContent(state) { |
|
1896 const edits = selectors_getPostEdits(state); |
|
1897 return 'blocks' in edits || // `edits` is intended to contain only values which are different from |
|
1898 // the saved post, so the mere presence of a property is an indicator |
|
1899 // that the value is different than what is known to be saved. While |
|
1900 // content in Visual mode is represented by the blocks state, in Text |
|
1901 // mode it is tracked by `edits.content`. |
|
1902 'content' in edits; |
|
1903 } |
|
1904 /** |
|
1905 * Returns true if there are unsaved values for the current edit session, or |
|
1906 * false if the editing state matches the saved or new post. |
|
1907 * |
|
1908 * @param {Object} state Global application state. |
|
1909 * |
|
1910 * @return {boolean} Whether unsaved values exist. |
|
1911 */ |
|
1912 |
|
1913 const selectors_isEditedPostDirty = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
1914 // Edits should contain only fields which differ from the saved post (reset |
|
1915 // at initial load and save complete). Thus, a non-empty edits state can be |
|
1916 // inferred to contain unsaved values. |
|
1917 const postType = selectors_getCurrentPostType(state); |
|
1918 const postId = selectors_getCurrentPostId(state); |
|
1919 |
|
1920 if (select('core').hasEditsForEntityRecord('postType', postType, postId)) { |
|
1921 return true; |
|
1922 } |
|
1923 |
|
1924 return false; |
|
1925 }); |
|
1926 /** |
|
1927 * Returns true if there are unsaved edits for entities other than |
|
1928 * the editor's post, and false otherwise. |
|
1929 * |
|
1930 * @param {Object} state Global application state. |
|
1931 * |
|
1932 * @return {boolean} Whether there are edits or not. |
|
1933 */ |
|
1934 |
|
1935 const selectors_hasNonPostEntityChanges = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
1936 const dirtyEntityRecords = select('core').__experimentalGetDirtyEntityRecords(); |
|
1937 |
|
1938 const { |
|
1939 type, |
|
1940 id |
|
1941 } = selectors_getCurrentPost(state); |
|
1942 return Object(external_lodash_["some"])(dirtyEntityRecords, entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id); |
|
1943 }); |
|
1944 /** |
|
1945 * Returns true if there are no unsaved values for the current edit session and |
|
1946 * if the currently edited post is new (has never been saved before). |
|
1947 * |
|
1948 * @param {Object} state Global application state. |
|
1949 * |
|
1950 * @return {boolean} Whether new post and unsaved values exist. |
|
1951 */ |
|
1952 |
|
1953 function selectors_isCleanNewPost(state) { |
|
1954 return !selectors_isEditedPostDirty(state) && selectors_isEditedPostNew(state); |
|
1955 } |
|
1956 /** |
|
1957 * Returns the post currently being edited in its last known saved state, not |
|
1958 * including unsaved edits. Returns an object containing relevant default post |
|
1959 * values if the post has not yet been saved. |
|
1960 * |
|
1961 * @param {Object} state Global application state. |
|
1962 * |
|
1963 * @return {Object} Post object. |
|
1964 */ |
|
1965 |
|
1966 const selectors_getCurrentPost = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
1967 const postId = selectors_getCurrentPostId(state); |
|
1968 const postType = selectors_getCurrentPostType(state); |
|
1969 const post = select('core').getRawEntityRecord('postType', postType, postId); |
|
1970 |
|
1971 if (post) { |
|
1972 return post; |
|
1973 } // This exists for compatibility with the previous selector behavior |
|
1974 // which would guarantee an object return based on the editor reducer's |
|
1975 // default empty object state. |
|
1976 |
|
1977 |
|
1978 return EMPTY_OBJECT; |
|
1979 }); |
|
1980 /** |
|
1981 * Returns the post type of the post currently being edited. |
|
1982 * |
|
1983 * @param {Object} state Global application state. |
|
1984 * |
|
1985 * @return {string} Post type. |
|
1986 */ |
|
1987 |
|
1988 function selectors_getCurrentPostType(state) { |
|
1989 return state.postType; |
|
1990 } |
|
1991 /** |
|
1992 * Returns the ID of the post currently being edited, or null if the post has |
|
1993 * not yet been saved. |
|
1994 * |
|
1995 * @param {Object} state Global application state. |
|
1996 * |
|
1997 * @return {?number} ID of current post. |
|
1998 */ |
|
1999 |
|
2000 function selectors_getCurrentPostId(state) { |
|
2001 return state.postId; |
|
2002 } |
|
2003 /** |
|
2004 * Returns the number of revisions of the post currently being edited. |
|
2005 * |
|
2006 * @param {Object} state Global application state. |
|
2007 * |
|
2008 * @return {number} Number of revisions. |
|
2009 */ |
|
2010 |
|
2011 function getCurrentPostRevisionsCount(state) { |
|
2012 return Object(external_lodash_["get"])(selectors_getCurrentPost(state), ['_links', 'version-history', 0, 'count'], 0); |
|
2013 } |
|
2014 /** |
|
2015 * Returns the last revision ID of the post currently being edited, |
|
2016 * or null if the post has no revisions. |
|
2017 * |
|
2018 * @param {Object} state Global application state. |
|
2019 * |
|
2020 * @return {?number} ID of the last revision. |
|
2021 */ |
|
2022 |
|
2023 function getCurrentPostLastRevisionId(state) { |
|
2024 return Object(external_lodash_["get"])(selectors_getCurrentPost(state), ['_links', 'predecessor-version', 0, 'id'], null); |
|
2025 } |
|
2026 /** |
|
2027 * Returns any post values which have been changed in the editor but not yet |
|
2028 * been saved. |
|
2029 * |
|
2030 * @param {Object} state Global application state. |
|
2031 * |
|
2032 * @return {Object} Object of key value pairs comprising unsaved edits. |
|
2033 */ |
|
2034 |
|
2035 const selectors_getPostEdits = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2036 const postType = selectors_getCurrentPostType(state); |
|
2037 const postId = selectors_getCurrentPostId(state); |
|
2038 return select('core').getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT; |
|
2039 }); |
|
2040 /** |
|
2041 * Returns a new reference when edited values have changed. This is useful in |
|
2042 * inferring where an edit has been made between states by comparison of the |
|
2043 * return values using strict equality. |
|
2044 * |
|
2045 * @deprecated since Gutenberg 6.5.0. |
|
2046 * |
|
2047 * @example |
|
2048 * |
|
2049 * ``` |
|
2050 * const hasEditOccurred = ( |
|
2051 * getReferenceByDistinctEdits( beforeState ) !== |
|
2052 * getReferenceByDistinctEdits( afterState ) |
|
2053 * ); |
|
2054 * ``` |
|
2055 * |
|
2056 * @param {Object} state Editor state. |
|
2057 * |
|
2058 * @return {*} A value whose reference will change only when an edit occurs. |
|
2059 */ |
|
2060 |
|
2061 const getReferenceByDistinctEdits = Object(external_wp_data_["createRegistrySelector"])(select => () => |
|
2062 /* state */ |
|
2063 { |
|
2064 external_wp_deprecated_default()("`wp.data.select( 'core/editor' ).getReferenceByDistinctEdits`", { |
|
2065 since: '5.4', |
|
2066 alternative: "`wp.data.select( 'core' ).getReferenceByDistinctEdits`" |
|
2067 }); |
|
2068 return select('core').getReferenceByDistinctEdits(); |
|
2069 }); |
|
2070 /** |
|
2071 * Returns an attribute value of the saved post. |
|
2072 * |
|
2073 * @param {Object} state Global application state. |
|
2074 * @param {string} attributeName Post attribute name. |
|
2075 * |
|
2076 * @return {*} Post attribute value. |
|
2077 */ |
|
2078 |
|
2079 function selectors_getCurrentPostAttribute(state, attributeName) { |
|
2080 switch (attributeName) { |
|
2081 case 'type': |
|
2082 return selectors_getCurrentPostType(state); |
|
2083 |
|
2084 case 'id': |
|
2085 return selectors_getCurrentPostId(state); |
|
2086 |
|
2087 default: |
|
2088 const post = selectors_getCurrentPost(state); |
|
2089 |
|
2090 if (!post.hasOwnProperty(attributeName)) { |
|
2091 break; |
|
2092 } |
|
2093 |
|
2094 return getPostRawValue(post[attributeName]); |
|
2095 } |
|
2096 } |
|
2097 /** |
|
2098 * Returns a single attribute of the post being edited, preferring the unsaved |
|
2099 * edit if one exists, but merging with the attribute value for the last known |
|
2100 * saved state of the post (this is needed for some nested attributes like meta). |
|
2101 * |
|
2102 * @param {Object} state Global application state. |
|
2103 * @param {string} attributeName Post attribute name. |
|
2104 * |
|
2105 * @return {*} Post attribute value. |
|
2106 */ |
|
2107 |
|
2108 const getNestedEditedPostProperty = (state, attributeName) => { |
|
2109 const edits = selectors_getPostEdits(state); |
|
2110 |
|
2111 if (!edits.hasOwnProperty(attributeName)) { |
|
2112 return selectors_getCurrentPostAttribute(state, attributeName); |
|
2113 } |
|
2114 |
|
2115 return { ...selectors_getCurrentPostAttribute(state, attributeName), |
|
2116 ...edits[attributeName] |
|
2117 }; |
|
2118 }; |
|
2119 /** |
|
2120 * Returns a single attribute of the post being edited, preferring the unsaved |
|
2121 * edit if one exists, but falling back to the attribute for the last known |
|
2122 * saved state of the post. |
|
2123 * |
|
2124 * @param {Object} state Global application state. |
|
2125 * @param {string} attributeName Post attribute name. |
|
2126 * |
|
2127 * @return {*} Post attribute value. |
|
2128 */ |
|
2129 |
|
2130 |
|
2131 function selectors_getEditedPostAttribute(state, attributeName) { |
|
2132 // Special cases |
|
2133 switch (attributeName) { |
|
2134 case 'content': |
|
2135 return getEditedPostContent(state); |
|
2136 } // Fall back to saved post value if not edited. |
|
2137 |
|
2138 |
|
2139 const edits = selectors_getPostEdits(state); |
|
2140 |
|
2141 if (!edits.hasOwnProperty(attributeName)) { |
|
2142 return selectors_getCurrentPostAttribute(state, attributeName); |
|
2143 } // Merge properties are objects which contain only the patch edit in state, |
|
2144 // and thus must be merged with the current post attribute. |
|
2145 |
|
2146 |
|
2147 if (EDIT_MERGE_PROPERTIES.has(attributeName)) { |
|
2148 return getNestedEditedPostProperty(state, attributeName); |
|
2149 } |
|
2150 |
|
2151 return edits[attributeName]; |
|
2152 } |
|
2153 /** |
|
2154 * Returns an attribute value of the current autosave revision for a post, or |
|
2155 * null if there is no autosave for the post. |
|
2156 * |
|
2157 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector |
|
2158 * from the '@wordpress/core-data' package and access properties on the returned |
|
2159 * autosave object using getPostRawValue. |
|
2160 * |
|
2161 * @param {Object} state Global application state. |
|
2162 * @param {string} attributeName Autosave attribute name. |
|
2163 * |
|
2164 * @return {*} Autosave attribute value. |
|
2165 */ |
|
2166 |
|
2167 const getAutosaveAttribute = Object(external_wp_data_["createRegistrySelector"])(select => (state, attributeName) => { |
|
2168 if (!Object(external_lodash_["includes"])(AUTOSAVE_PROPERTIES, attributeName) && attributeName !== 'preview_link') { |
|
2169 return; |
|
2170 } |
|
2171 |
|
2172 const postType = selectors_getCurrentPostType(state); |
|
2173 const postId = selectors_getCurrentPostId(state); |
|
2174 const currentUserId = Object(external_lodash_["get"])(select('core').getCurrentUser(), ['id']); |
|
2175 const autosave = select('core').getAutosave(postType, postId, currentUserId); |
|
2176 |
|
2177 if (autosave) { |
|
2178 return getPostRawValue(autosave[attributeName]); |
|
2179 } |
|
2180 }); |
|
2181 /** |
|
2182 * Returns the current visibility of the post being edited, preferring the |
|
2183 * unsaved value if different than the saved post. The return value is one of |
|
2184 * "private", "password", or "public". |
|
2185 * |
|
2186 * @param {Object} state Global application state. |
|
2187 * |
|
2188 * @return {string} Post visibility. |
|
2189 */ |
|
2190 |
|
2191 function selectors_getEditedPostVisibility(state) { |
|
2192 const status = selectors_getEditedPostAttribute(state, 'status'); |
|
2193 |
|
2194 if (status === 'private') { |
|
2195 return 'private'; |
|
2196 } |
|
2197 |
|
2198 const password = selectors_getEditedPostAttribute(state, 'password'); |
|
2199 |
|
2200 if (password) { |
|
2201 return 'password'; |
|
2202 } |
|
2203 |
|
2204 return 'public'; |
|
2205 } |
|
2206 /** |
|
2207 * Returns true if post is pending review. |
|
2208 * |
|
2209 * @param {Object} state Global application state. |
|
2210 * |
|
2211 * @return {boolean} Whether current post is pending review. |
|
2212 */ |
|
2213 |
|
2214 function isCurrentPostPending(state) { |
|
2215 return selectors_getCurrentPost(state).status === 'pending'; |
|
2216 } |
|
2217 /** |
|
2218 * Return true if the current post has already been published. |
|
2219 * |
|
2220 * @param {Object} state Global application state. |
|
2221 * @param {Object?} currentPost Explicit current post for bypassing registry selector. |
|
2222 * |
|
2223 * @return {boolean} Whether the post has been published. |
|
2224 */ |
|
2225 |
|
2226 function selectors_isCurrentPostPublished(state, currentPost) { |
|
2227 const post = currentPost || selectors_getCurrentPost(state); |
|
2228 return ['publish', 'private'].indexOf(post.status) !== -1 || post.status === 'future' && !Object(external_wp_date_["isInTheFuture"])(new Date(Number(Object(external_wp_date_["getDate"])(post.date)) - ONE_MINUTE_IN_MS)); |
|
2229 } |
|
2230 /** |
|
2231 * Returns true if post is already scheduled. |
|
2232 * |
|
2233 * @param {Object} state Global application state. |
|
2234 * |
|
2235 * @return {boolean} Whether current post is scheduled to be posted. |
|
2236 */ |
|
2237 |
|
2238 function selectors_isCurrentPostScheduled(state) { |
|
2239 return selectors_getCurrentPost(state).status === 'future' && !selectors_isCurrentPostPublished(state); |
|
2240 } |
|
2241 /** |
|
2242 * Return true if the post being edited can be published. |
|
2243 * |
|
2244 * @param {Object} state Global application state. |
|
2245 * |
|
2246 * @return {boolean} Whether the post can been published. |
|
2247 */ |
|
2248 |
|
2249 function selectors_isEditedPostPublishable(state) { |
|
2250 const post = selectors_getCurrentPost(state); // TODO: Post being publishable should be superset of condition of post |
|
2251 // being saveable. Currently this restriction is imposed at UI. |
|
2252 // |
|
2253 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`) |
|
2254 |
|
2255 return selectors_isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1; |
|
2256 } |
|
2257 /** |
|
2258 * Returns true if the post can be saved, or false otherwise. A post must |
|
2259 * contain a title, an excerpt, or non-empty content to be valid for save. |
|
2260 * |
|
2261 * @param {Object} state Global application state. |
|
2262 * |
|
2263 * @return {boolean} Whether the post can be saved. |
|
2264 */ |
|
2265 |
|
2266 function selectors_isEditedPostSaveable(state) { |
|
2267 if (selectors_isSavingPost(state)) { |
|
2268 return false; |
|
2269 } // TODO: Post should not be saveable if not dirty. Cannot be added here at |
|
2270 // this time since posts where meta boxes are present can be saved even if |
|
2271 // the post is not dirty. Currently this restriction is imposed at UI, but |
|
2272 // should be moved here. |
|
2273 // |
|
2274 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition) |
|
2275 // See: <PostSavedState /> (`forceIsDirty` prop) |
|
2276 // See: <PostPublishButton /> (`forceIsDirty` prop) |
|
2277 // See: https://github.com/WordPress/gutenberg/pull/4184 |
|
2278 |
|
2279 |
|
2280 return !!selectors_getEditedPostAttribute(state, 'title') || !!selectors_getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_["Platform"].OS === 'native'; |
|
2281 } |
|
2282 /** |
|
2283 * Returns true if the edited post has content. A post has content if it has at |
|
2284 * least one saveable block or otherwise has a non-empty content property |
|
2285 * assigned. |
|
2286 * |
|
2287 * @param {Object} state Global application state. |
|
2288 * |
|
2289 * @return {boolean} Whether post has content. |
|
2290 */ |
|
2291 |
|
2292 function isEditedPostEmpty(state) { |
|
2293 // While the condition of truthy content string is sufficient to determine |
|
2294 // emptiness, testing saveable blocks length is a trivial operation. Since |
|
2295 // this function can be called frequently, optimize for the fast case as a |
|
2296 // condition of the mere existence of blocks. Note that the value of edited |
|
2297 // content takes precedent over block content, and must fall through to the |
|
2298 // default logic. |
|
2299 const blocks = getEditorBlocks(state); |
|
2300 |
|
2301 if (blocks.length) { |
|
2302 // Pierce the abstraction of the serializer in knowing that blocks are |
|
2303 // joined with with newlines such that even if every individual block |
|
2304 // produces an empty save result, the serialized content is non-empty. |
|
2305 if (blocks.length > 1) { |
|
2306 return false; |
|
2307 } // There are two conditions under which the optimization cannot be |
|
2308 // assumed, and a fallthrough to getEditedPostContent must occur: |
|
2309 // |
|
2310 // 1. getBlocksForSerialization has special treatment in omitting a |
|
2311 // single unmodified default block. |
|
2312 // 2. Comment delimiters are omitted for a freeform or unregistered |
|
2313 // block in its serialization. The freeform block specifically may |
|
2314 // produce an empty string in its saved output. |
|
2315 // |
|
2316 // For all other content, the single block is assumed to make a post |
|
2317 // non-empty, if only by virtue of its own comment delimiters. |
|
2318 |
|
2319 |
|
2320 const blockName = blocks[0].name; |
|
2321 |
|
2322 if (blockName !== Object(external_wp_blocks_["getDefaultBlockName"])() && blockName !== Object(external_wp_blocks_["getFreeformContentHandlerName"])()) { |
|
2323 return false; |
|
2324 } |
|
2325 } |
|
2326 |
|
2327 return !getEditedPostContent(state); |
|
2328 } |
|
2329 /** |
|
2330 * Returns true if the post can be autosaved, or false otherwise. |
|
2331 * |
|
2332 * @param {Object} state Global application state. |
|
2333 * @param {Object} autosave A raw autosave object from the REST API. |
|
2334 * |
|
2335 * @return {boolean} Whether the post can be autosaved. |
|
2336 */ |
|
2337 |
|
2338 const selectors_isEditedPostAutosaveable = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2339 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving. |
|
2340 if (!selectors_isEditedPostSaveable(state)) { |
|
2341 return false; |
|
2342 } // A post is not autosavable when there is a post autosave lock. |
|
2343 |
|
2344 |
|
2345 if (isPostAutosavingLocked(state)) { |
|
2346 return false; |
|
2347 } |
|
2348 |
|
2349 const postType = selectors_getCurrentPostType(state); |
|
2350 const postId = selectors_getCurrentPostId(state); |
|
2351 const hasFetchedAutosave = select('core').hasFetchedAutosaves(postType, postId); |
|
2352 const currentUserId = Object(external_lodash_["get"])(select('core').getCurrentUser(), ['id']); // Disable reason - this line causes the side-effect of fetching the autosave |
|
2353 // via a resolver, moving below the return would result in the autosave never |
|
2354 // being fetched. |
|
2355 // eslint-disable-next-line @wordpress/no-unused-vars-before-return |
|
2356 |
|
2357 const autosave = select('core').getAutosave(postType, postId, currentUserId); // If any existing autosaves have not yet been fetched, this function is |
|
2358 // unable to determine if the post is autosaveable, so return false. |
|
2359 |
|
2360 if (!hasFetchedAutosave) { |
|
2361 return false; |
|
2362 } // If we don't already have an autosave, the post is autosaveable. |
|
2363 |
|
2364 |
|
2365 if (!autosave) { |
|
2366 return true; |
|
2367 } // To avoid an expensive content serialization, use the content dirtiness |
|
2368 // flag in place of content field comparison against the known autosave. |
|
2369 // This is not strictly accurate, and relies on a tolerance toward autosave |
|
2370 // request failures for unnecessary saves. |
|
2371 |
|
2372 |
|
2373 if (hasChangedContent(state)) { |
|
2374 return true; |
|
2375 } // If the title or excerpt has changed, the post is autosaveable. |
|
2376 |
|
2377 |
|
2378 return ['title', 'excerpt'].some(field => getPostRawValue(autosave[field]) !== selectors_getEditedPostAttribute(state, field)); |
|
2379 }); |
|
2380 /** |
|
2381 * Returns the current autosave, or null if one is not set (i.e. if the post |
|
2382 * has yet to be autosaved, or has been saved or published since the last |
|
2383 * autosave). |
|
2384 * |
|
2385 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` |
|
2386 * selector from the '@wordpress/core-data' package. |
|
2387 * |
|
2388 * @param {Object} state Editor state. |
|
2389 * |
|
2390 * @return {?Object} Current autosave, if exists. |
|
2391 */ |
|
2392 |
|
2393 const getAutosave = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2394 external_wp_deprecated_default()("`wp.data.select( 'core/editor' ).getAutosave()`", { |
|
2395 since: '5.3', |
|
2396 alternative: "`wp.data.select( 'core' ).getAutosave( postType, postId, userId )`" |
|
2397 }); |
|
2398 const postType = selectors_getCurrentPostType(state); |
|
2399 const postId = selectors_getCurrentPostId(state); |
|
2400 const currentUserId = Object(external_lodash_["get"])(select('core').getCurrentUser(), ['id']); |
|
2401 const autosave = select('core').getAutosave(postType, postId, currentUserId); |
|
2402 return Object(external_lodash_["mapValues"])(Object(external_lodash_["pick"])(autosave, AUTOSAVE_PROPERTIES), getPostRawValue); |
|
2403 }); |
|
2404 /** |
|
2405 * Returns the true if there is an existing autosave, otherwise false. |
|
2406 * |
|
2407 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector |
|
2408 * from the '@wordpress/core-data' package and check for a truthy value. |
|
2409 * |
|
2410 * @param {Object} state Global application state. |
|
2411 * |
|
2412 * @return {boolean} Whether there is an existing autosave. |
|
2413 */ |
|
2414 |
|
2415 const hasAutosave = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2416 external_wp_deprecated_default()("`wp.data.select( 'core/editor' ).hasAutosave()`", { |
|
2417 since: '5.3', |
|
2418 alternative: "`!! wp.data.select( 'core' ).getAutosave( postType, postId, userId )`" |
|
2419 }); |
|
2420 const postType = selectors_getCurrentPostType(state); |
|
2421 const postId = selectors_getCurrentPostId(state); |
|
2422 const currentUserId = Object(external_lodash_["get"])(select('core').getCurrentUser(), ['id']); |
|
2423 return !!select('core').getAutosave(postType, postId, currentUserId); |
|
2424 }); |
|
2425 /** |
|
2426 * Return true if the post being edited is being scheduled. Preferring the |
|
2427 * unsaved status values. |
|
2428 * |
|
2429 * @param {Object} state Global application state. |
|
2430 * |
|
2431 * @return {boolean} Whether the post has been published. |
|
2432 */ |
|
2433 |
|
2434 function selectors_isEditedPostBeingScheduled(state) { |
|
2435 const date = selectors_getEditedPostAttribute(state, 'date'); // Offset the date by one minute (network latency) |
|
2436 |
|
2437 const checkedDate = new Date(Number(Object(external_wp_date_["getDate"])(date)) - ONE_MINUTE_IN_MS); |
|
2438 return Object(external_wp_date_["isInTheFuture"])(checkedDate); |
|
2439 } |
|
2440 /** |
|
2441 * Returns whether the current post should be considered to have a "floating" |
|
2442 * date (i.e. that it would publish "Immediately" rather than at a set time). |
|
2443 * |
|
2444 * Unlike in the PHP backend, the REST API returns a full date string for posts |
|
2445 * where the 0000-00-00T00:00:00 placeholder is present in the database. To |
|
2446 * infer that a post is set to publish "Immediately" we check whether the date |
|
2447 * and modified date are the same. |
|
2448 * |
|
2449 * @param {Object} state Editor state. |
|
2450 * |
|
2451 * @return {boolean} Whether the edited post has a floating date value. |
|
2452 */ |
|
2453 |
|
2454 function isEditedPostDateFloating(state) { |
|
2455 const date = selectors_getEditedPostAttribute(state, 'date'); |
|
2456 const modified = selectors_getEditedPostAttribute(state, 'modified'); // This should be the status of the persisted post |
|
2457 // It shouldn't use the "edited" status otherwise it breaks the |
|
2458 // infered post data floating status |
|
2459 // See https://github.com/WordPress/gutenberg/issues/28083 |
|
2460 |
|
2461 const status = selectors_getCurrentPost(state).status; |
|
2462 |
|
2463 if (status === 'draft' || status === 'auto-draft' || status === 'pending') { |
|
2464 return date === modified || date === null; |
|
2465 } |
|
2466 |
|
2467 return false; |
|
2468 } |
|
2469 /** |
|
2470 * Returns true if the post is currently being saved, or false otherwise. |
|
2471 * |
|
2472 * @param {Object} state Global application state. |
|
2473 * |
|
2474 * @return {boolean} Whether post is being saved. |
|
2475 */ |
|
2476 |
|
2477 const selectors_isSavingPost = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2478 const postType = selectors_getCurrentPostType(state); |
|
2479 const postId = selectors_getCurrentPostId(state); |
|
2480 return select('core').isSavingEntityRecord('postType', postType, postId); |
|
2481 }); |
|
2482 /** |
|
2483 * Returns true if a previous post save was attempted successfully, or false |
|
2484 * otherwise. |
|
2485 * |
|
2486 * @param {Object} state Global application state. |
|
2487 * |
|
2488 * @return {boolean} Whether the post was saved successfully. |
|
2489 */ |
|
2490 |
|
2491 const didPostSaveRequestSucceed = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2492 const postType = selectors_getCurrentPostType(state); |
|
2493 const postId = selectors_getCurrentPostId(state); |
|
2494 return !select('core').getLastEntitySaveError('postType', postType, postId); |
|
2495 }); |
|
2496 /** |
|
2497 * Returns true if a previous post save was attempted but failed, or false |
|
2498 * otherwise. |
|
2499 * |
|
2500 * @param {Object} state Global application state. |
|
2501 * |
|
2502 * @return {boolean} Whether the post save failed. |
|
2503 */ |
|
2504 |
|
2505 const didPostSaveRequestFail = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2506 const postType = selectors_getCurrentPostType(state); |
|
2507 const postId = selectors_getCurrentPostId(state); |
|
2508 return !!select('core').getLastEntitySaveError('postType', postType, postId); |
|
2509 }); |
|
2510 /** |
|
2511 * Returns true if the post is autosaving, or false otherwise. |
|
2512 * |
|
2513 * @param {Object} state Global application state. |
|
2514 * |
|
2515 * @return {boolean} Whether the post is autosaving. |
|
2516 */ |
|
2517 |
|
2518 function selectors_isAutosavingPost(state) { |
|
2519 if (!selectors_isSavingPost(state)) { |
|
2520 return false; |
|
2521 } |
|
2522 |
|
2523 return !!Object(external_lodash_["get"])(state.saving, ['options', 'isAutosave']); |
|
2524 } |
|
2525 /** |
|
2526 * Returns true if the post is being previewed, or false otherwise. |
|
2527 * |
|
2528 * @param {Object} state Global application state. |
|
2529 * |
|
2530 * @return {boolean} Whether the post is being previewed. |
|
2531 */ |
|
2532 |
|
2533 function isPreviewingPost(state) { |
|
2534 if (!selectors_isSavingPost(state)) { |
|
2535 return false; |
|
2536 } |
|
2537 |
|
2538 return !!state.saving.options.isPreview; |
|
2539 } |
|
2540 /** |
|
2541 * Returns the post preview link |
|
2542 * |
|
2543 * @param {Object} state Global application state. |
|
2544 * |
|
2545 * @return {string?} Preview Link. |
|
2546 */ |
|
2547 |
|
2548 function selectors_getEditedPostPreviewLink(state) { |
|
2549 if (state.saving.pending || selectors_isSavingPost(state)) { |
|
2550 return; |
|
2551 } |
|
2552 |
|
2553 let previewLink = getAutosaveAttribute(state, 'preview_link'); |
|
2554 |
|
2555 if (!previewLink) { |
|
2556 previewLink = selectors_getEditedPostAttribute(state, 'link'); |
|
2557 |
|
2558 if (previewLink) { |
|
2559 previewLink = Object(external_wp_url_["addQueryArgs"])(previewLink, { |
|
2560 preview: true |
|
2561 }); |
|
2562 } |
|
2563 } |
|
2564 |
|
2565 const featuredImageId = selectors_getEditedPostAttribute(state, 'featured_media'); |
|
2566 |
|
2567 if (previewLink && featuredImageId) { |
|
2568 return Object(external_wp_url_["addQueryArgs"])(previewLink, { |
|
2569 _thumbnail_id: featuredImageId |
|
2570 }); |
|
2571 } |
|
2572 |
|
2573 return previewLink; |
|
2574 } |
|
2575 /** |
|
2576 * Returns a suggested post format for the current post, inferred only if there |
|
2577 * is a single block within the post and it is of a type known to match a |
|
2578 * default post format. Returns null if the format cannot be determined. |
|
2579 * |
|
2580 * @param {Object} state Global application state. |
|
2581 * |
|
2582 * @return {?string} Suggested post format. |
|
2583 */ |
|
2584 |
|
2585 function selectors_getSuggestedPostFormat(state) { |
|
2586 const blocks = getEditorBlocks(state); |
|
2587 if (blocks.length > 2) return null; |
|
2588 let name; // If there is only one block in the content of the post grab its name |
|
2589 // so we can derive a suitable post format from it. |
|
2590 |
|
2591 if (blocks.length === 1) { |
|
2592 name = blocks[0].name; // check for core/embed `video` and `audio` eligible suggestions |
|
2593 |
|
2594 if (name === 'core/embed') { |
|
2595 var _blocks$0$attributes; |
|
2596 |
|
2597 const provider = (_blocks$0$attributes = blocks[0].attributes) === null || _blocks$0$attributes === void 0 ? void 0 : _blocks$0$attributes.providerNameSlug; |
|
2598 |
|
2599 if (['youtube', 'vimeo'].includes(provider)) { |
|
2600 name = 'core/video'; |
|
2601 } else if (['spotify', 'soundcloud'].includes(provider)) { |
|
2602 name = 'core/audio'; |
|
2603 } |
|
2604 } |
|
2605 } // If there are two blocks in the content and the last one is a text blocks |
|
2606 // grab the name of the first one to also suggest a post format from it. |
|
2607 |
|
2608 |
|
2609 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') { |
|
2610 name = blocks[0].name; |
|
2611 } // We only convert to default post formats in core. |
|
2612 |
|
2613 |
|
2614 switch (name) { |
|
2615 case 'core/image': |
|
2616 return 'image'; |
|
2617 |
|
2618 case 'core/quote': |
|
2619 case 'core/pullquote': |
|
2620 return 'quote'; |
|
2621 |
|
2622 case 'core/gallery': |
|
2623 return 'gallery'; |
|
2624 |
|
2625 case 'core/video': |
|
2626 return 'video'; |
|
2627 |
|
2628 case 'core/audio': |
|
2629 return 'audio'; |
|
2630 |
|
2631 default: |
|
2632 return null; |
|
2633 } |
|
2634 } |
|
2635 /** |
|
2636 * Returns a set of blocks which are to be used in consideration of the post's |
|
2637 * generated save content. |
|
2638 * |
|
2639 * @deprecated since Gutenberg 6.2.0. |
|
2640 * |
|
2641 * @param {Object} state Editor state. |
|
2642 * |
|
2643 * @return {WPBlock[]} Filtered set of blocks for save. |
|
2644 */ |
|
2645 |
|
2646 function getBlocksForSerialization(state) { |
|
2647 external_wp_deprecated_default()('`core/editor` getBlocksForSerialization selector', { |
|
2648 since: '5.3', |
|
2649 alternative: 'getEditorBlocks', |
|
2650 hint: 'Blocks serialization pre-processing occurs at save time' |
|
2651 }); |
|
2652 const blocks = state.editor.present.blocks.value; // WARNING: Any changes to the logic of this function should be verified |
|
2653 // against the implementation of isEditedPostEmpty, which bypasses this |
|
2654 // function for performance' sake, in an assumption of this current logic |
|
2655 // being irrelevant to the optimized condition of emptiness. |
|
2656 // A single unmodified default block is assumed to be equivalent to an |
|
2657 // empty post. |
|
2658 |
|
2659 const isSingleUnmodifiedDefaultBlock = blocks.length === 1 && Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])(blocks[0]); |
|
2660 |
|
2661 if (isSingleUnmodifiedDefaultBlock) { |
|
2662 return []; |
|
2663 } |
|
2664 |
|
2665 return blocks; |
|
2666 } |
|
2667 /** |
|
2668 * Returns the content of the post being edited. |
|
2669 * |
|
2670 * @param {Object} state Global application state. |
|
2671 * |
|
2672 * @return {string} Post content. |
|
2673 */ |
|
2674 |
|
2675 const getEditedPostContent = Object(external_wp_data_["createRegistrySelector"])(select => state => { |
|
2676 const postId = selectors_getCurrentPostId(state); |
|
2677 const postType = selectors_getCurrentPostType(state); |
|
2678 const record = select('core').getEditedEntityRecord('postType', postType, postId); |
|
2679 |
|
2680 if (record) { |
|
2681 if (typeof record.content === 'function') { |
|
2682 return record.content(record); |
|
2683 } else if (record.blocks) { |
|
2684 return Object(external_wp_blocks_["__unstableSerializeAndClean"])(record.blocks); |
|
2685 } else if (record.content) { |
|
2686 return record.content; |
|
2687 } |
|
2688 } |
|
2689 |
|
2690 return ''; |
|
2691 }); |
|
2692 /** |
|
2693 * Returns true if the post is being published, or false otherwise. |
|
2694 * |
|
2695 * @param {Object} state Global application state. |
|
2696 * |
|
2697 * @return {boolean} Whether post is being published. |
|
2698 */ |
|
2699 |
|
2700 function selectors_isPublishingPost(state) { |
|
2701 return selectors_isSavingPost(state) && !selectors_isCurrentPostPublished(state) && selectors_getEditedPostAttribute(state, 'status') === 'publish'; |
|
2702 } |
|
2703 /** |
|
2704 * Returns whether the permalink is editable or not. |
|
2705 * |
|
2706 * @param {Object} state Editor state. |
|
2707 * |
|
2708 * @return {boolean} Whether or not the permalink is editable. |
|
2709 */ |
|
2710 |
|
2711 function isPermalinkEditable(state) { |
|
2712 const permalinkTemplate = selectors_getEditedPostAttribute(state, 'permalink_template'); |
|
2713 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate); |
|
2714 } |
|
2715 /** |
|
2716 * Returns the permalink for the post. |
|
2717 * |
|
2718 * @param {Object} state Editor state. |
|
2719 * |
|
2720 * @return {?string} The permalink, or null if the post is not viewable. |
|
2721 */ |
|
2722 |
|
2723 function getPermalink(state) { |
|
2724 const permalinkParts = getPermalinkParts(state); |
|
2725 |
|
2726 if (!permalinkParts) { |
|
2727 return null; |
|
2728 } |
|
2729 |
|
2730 const { |
|
2731 prefix, |
|
2732 postName, |
|
2733 suffix |
|
2734 } = permalinkParts; |
|
2735 |
|
2736 if (isPermalinkEditable(state)) { |
|
2737 return prefix + postName + suffix; |
|
2738 } |
|
2739 |
|
2740 return prefix; |
|
2741 } |
|
2742 /** |
|
2743 * Returns the slug for the post being edited, preferring a manually edited |
|
2744 * value if one exists, then a sanitized version of the current post title, and |
|
2745 * finally the post ID. |
|
2746 * |
|
2747 * @param {Object} state Editor state. |
|
2748 * |
|
2749 * @return {string} The current slug to be displayed in the editor |
|
2750 */ |
|
2751 |
|
2752 function getEditedPostSlug(state) { |
|
2753 return selectors_getEditedPostAttribute(state, 'slug') || cleanForSlug(selectors_getEditedPostAttribute(state, 'title')) || selectors_getCurrentPostId(state); |
|
2754 } |
|
2755 /** |
|
2756 * Returns the permalink for a post, split into it's three parts: the prefix, |
|
2757 * the postName, and the suffix. |
|
2758 * |
|
2759 * @param {Object} state Editor state. |
|
2760 * |
|
2761 * @return {Object} An object containing the prefix, postName, and suffix for |
|
2762 * the permalink, or null if the post is not viewable. |
|
2763 */ |
|
2764 |
|
2765 function getPermalinkParts(state) { |
|
2766 const permalinkTemplate = selectors_getEditedPostAttribute(state, 'permalink_template'); |
|
2767 |
|
2768 if (!permalinkTemplate) { |
|
2769 return null; |
|
2770 } |
|
2771 |
|
2772 const postName = selectors_getEditedPostAttribute(state, 'slug') || selectors_getEditedPostAttribute(state, 'generated_slug'); |
|
2773 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX); |
|
2774 return { |
|
2775 prefix, |
|
2776 postName, |
|
2777 suffix |
|
2778 }; |
|
2779 } |
|
2780 /** |
|
2781 * Returns whether the post is locked. |
|
2782 * |
|
2783 * @param {Object} state Global application state. |
|
2784 * |
|
2785 * @return {boolean} Is locked. |
|
2786 */ |
|
2787 |
|
2788 function selectors_isPostLocked(state) { |
|
2789 return state.postLock.isLocked; |
|
2790 } |
|
2791 /** |
|
2792 * Returns whether post saving is locked. |
|
2793 * |
|
2794 * @param {Object} state Global application state. |
|
2795 * |
|
2796 * @return {boolean} Is locked. |
|
2797 */ |
|
2798 |
|
2799 function selectors_isPostSavingLocked(state) { |
|
2800 return Object.keys(state.postSavingLock).length > 0; |
|
2801 } |
|
2802 /** |
|
2803 * Returns whether post autosaving is locked. |
|
2804 * |
|
2805 * @param {Object} state Global application state. |
|
2806 * |
|
2807 * @return {boolean} Is locked. |
|
2808 */ |
|
2809 |
|
2810 function isPostAutosavingLocked(state) { |
|
2811 return Object.keys(state.postAutosavingLock).length > 0; |
|
2812 } |
|
2813 /** |
|
2814 * Returns whether the edition of the post has been taken over. |
|
2815 * |
|
2816 * @param {Object} state Global application state. |
|
2817 * |
|
2818 * @return {boolean} Is post lock takeover. |
|
2819 */ |
|
2820 |
|
2821 function isPostLockTakeover(state) { |
|
2822 return state.postLock.isTakeover; |
|
2823 } |
|
2824 /** |
|
2825 * Returns details about the post lock user. |
|
2826 * |
|
2827 * @param {Object} state Global application state. |
|
2828 * |
|
2829 * @return {Object} A user object. |
|
2830 */ |
|
2831 |
|
2832 function getPostLockUser(state) { |
|
2833 return state.postLock.user; |
|
2834 } |
|
2835 /** |
|
2836 * Returns the active post lock. |
|
2837 * |
|
2838 * @param {Object} state Global application state. |
|
2839 * |
|
2840 * @return {Object} The lock object. |
|
2841 */ |
|
2842 |
|
2843 function getActivePostLock(state) { |
|
2844 return state.postLock.activePostLock; |
|
2845 } |
|
2846 /** |
|
2847 * Returns whether or not the user has the unfiltered_html capability. |
|
2848 * |
|
2849 * @param {Object} state Editor state. |
|
2850 * |
|
2851 * @return {boolean} Whether the user can or can't post unfiltered HTML. |
|
2852 */ |
|
2853 |
|
2854 function selectors_canUserUseUnfilteredHTML(state) { |
|
2855 return Object(external_lodash_["has"])(selectors_getCurrentPost(state), ['_links', 'wp:action-unfiltered-html']); |
|
2856 } |
|
2857 /** |
|
2858 * Returns whether the pre-publish panel should be shown |
|
2859 * or skipped when the user clicks the "publish" button. |
|
2860 * |
|
2861 * @param {Object} state Global application state. |
|
2862 * |
|
2863 * @return {boolean} Whether the pre-publish panel should be shown or not. |
|
2864 */ |
|
2865 |
|
2866 function selectors_isPublishSidebarEnabled(state) { |
|
2867 if (state.preferences.hasOwnProperty('isPublishSidebarEnabled')) { |
|
2868 return state.preferences.isPublishSidebarEnabled; |
|
2869 } |
|
2870 |
|
2871 return PREFERENCES_DEFAULTS.isPublishSidebarEnabled; |
|
2872 } |
|
2873 /** |
|
2874 * Return the current block list. |
|
2875 * |
|
2876 * @param {Object} state |
|
2877 * @return {Array} Block list. |
|
2878 */ |
|
2879 |
|
2880 function getEditorBlocks(state) { |
|
2881 return selectors_getEditedPostAttribute(state, 'blocks') || EMPTY_ARRAY; |
|
2882 } |
|
2883 /** |
|
2884 * A block selection object. |
|
2885 * |
|
2886 * @typedef {Object} WPBlockSelection |
|
2887 * |
|
2888 * @property {string} clientId A block client ID. |
|
2889 * @property {string} attributeKey A block attribute key. |
|
2890 * @property {number} offset An attribute value offset, based on the rich |
|
2891 * text value. See `wp.richText.create`. |
|
2892 */ |
|
2893 |
|
2894 /** |
|
2895 * Returns the current selection start. |
|
2896 * |
|
2897 * @param {Object} state |
|
2898 * @return {WPBlockSelection} The selection start. |
|
2899 * |
|
2900 * @deprecated since Gutenberg 10.0.0. |
|
2901 */ |
|
2902 |
|
2903 function getEditorSelectionStart(state) { |
|
2904 var _getEditedPostAttribu; |
|
2905 |
|
2906 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", { |
|
2907 since: '10.0', |
|
2908 plugin: 'Gutenberg', |
|
2909 alternative: "select('core/editor').getEditorSelection" |
|
2910 }); |
|
2911 return (_getEditedPostAttribu = selectors_getEditedPostAttribute(state, 'selection')) === null || _getEditedPostAttribu === void 0 ? void 0 : _getEditedPostAttribu.selectionStart; |
|
2912 } |
|
2913 /** |
|
2914 * Returns the current selection end. |
|
2915 * |
|
2916 * @param {Object} state |
|
2917 * @return {WPBlockSelection} The selection end. |
|
2918 * |
|
2919 * @deprecated since Gutenberg 10.0.0. |
|
2920 */ |
|
2921 |
|
2922 function getEditorSelectionEnd(state) { |
|
2923 var _getEditedPostAttribu2; |
|
2924 |
|
2925 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", { |
|
2926 since: '10.0', |
|
2927 plugin: 'Gutenberg', |
|
2928 alternative: "select('core/editor').getEditorSelection" |
|
2929 }); |
|
2930 return (_getEditedPostAttribu2 = selectors_getEditedPostAttribute(state, 'selection')) === null || _getEditedPostAttribu2 === void 0 ? void 0 : _getEditedPostAttribu2.selectionEnd; |
|
2931 } |
|
2932 /** |
|
2933 * Returns the current selection. |
|
2934 * |
|
2935 * @param {Object} state |
|
2936 * @return {WPBlockSelection} The selection end. |
|
2937 */ |
|
2938 |
|
2939 function selectors_getEditorSelection(state) { |
|
2940 return selectors_getEditedPostAttribute(state, 'selection'); |
|
2941 } |
|
2942 /** |
|
2943 * Is the editor ready |
|
2944 * |
|
2945 * @param {Object} state |
|
2946 * @return {boolean} is Ready. |
|
2947 */ |
|
2948 |
|
2949 function selectors_unstableIsEditorReady(state) { |
|
2950 return state.isReady; |
|
2951 } |
|
2952 /** |
|
2953 * Returns the post editor settings. |
|
2954 * |
|
2955 * @param {Object} state Editor state. |
|
2956 * |
|
2957 * @return {Object} The editor settings object. |
|
2958 */ |
|
2959 |
|
2960 function selectors_getEditorSettings(state) { |
|
2961 return state.editorSettings; |
|
2962 } |
|
2963 /* |
|
2964 * Backward compatibility |
|
2965 */ |
|
2966 |
|
2967 /** |
|
2968 * Returns state object prior to a specified optimist transaction ID, or `null` |
|
2969 * if the transaction corresponding to the given ID cannot be found. |
|
2970 * |
|
2971 * @deprecated since Gutenberg 9.7.0. |
|
2972 */ |
|
2973 |
|
2974 function getStateBeforeOptimisticTransaction() { |
|
2975 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", { |
|
2976 since: '5.7', |
|
2977 hint: 'No state history is kept on this store anymore' |
|
2978 }); |
|
2979 return null; |
|
2980 } |
|
2981 /** |
|
2982 * Returns true if an optimistic transaction is pending commit, for which the |
|
2983 * before state satisfies the given predicate function. |
|
2984 * |
|
2985 * @deprecated since Gutenberg 9.7.0. |
|
2986 */ |
|
2987 |
|
2988 function inSomeHistory() { |
|
2989 external_wp_deprecated_default()("select('core/editor').inSomeHistory", { |
|
2990 since: '5.7', |
|
2991 hint: 'No state history is kept on this store anymore' |
|
2992 }); |
|
2993 return false; |
|
2994 } |
|
2995 |
|
2996 function getBlockEditorSelector(name) { |
|
2997 return Object(external_wp_data_["createRegistrySelector"])(select => (state, ...args) => { |
|
2998 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', { |
|
2999 since: '5.3', |
|
3000 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`' |
|
3001 }); |
|
3002 return select('core/block-editor')[name](...args); |
|
3003 }); |
|
3004 } |
|
3005 /** |
|
3006 * @see getBlockName in core/block-editor store. |
|
3007 */ |
|
3008 |
|
3009 |
|
3010 const getBlockName = getBlockEditorSelector('getBlockName'); |
|
3011 /** |
|
3012 * @see isBlockValid in core/block-editor store. |
|
3013 */ |
|
3014 |
|
3015 const isBlockValid = getBlockEditorSelector('isBlockValid'); |
|
3016 /** |
|
3017 * @see getBlockAttributes in core/block-editor store. |
|
3018 */ |
|
3019 |
|
3020 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes'); |
|
3021 /** |
|
3022 * @see getBlock in core/block-editor store. |
|
3023 */ |
|
3024 |
|
3025 const getBlock = getBlockEditorSelector('getBlock'); |
|
3026 /** |
|
3027 * @see getBlocks in core/block-editor store. |
|
3028 */ |
|
3029 |
|
3030 const selectors_getBlocks = getBlockEditorSelector('getBlocks'); |
|
3031 /** |
|
3032 * @see __unstableGetBlockWithoutInnerBlocks in core/block-editor store. |
|
3033 */ |
|
3034 |
|
3035 const __unstableGetBlockWithoutInnerBlocks = getBlockEditorSelector('__unstableGetBlockWithoutInnerBlocks'); |
|
3036 /** |
|
3037 * @see getClientIdsOfDescendants in core/block-editor store. |
|
3038 */ |
|
3039 |
|
3040 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants'); |
|
3041 /** |
|
3042 * @see getClientIdsWithDescendants in core/block-editor store. |
|
3043 */ |
|
3044 |
|
3045 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants'); |
|
3046 /** |
|
3047 * @see getGlobalBlockCount in core/block-editor store. |
|
3048 */ |
|
3049 |
|
3050 const selectors_getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount'); |
|
3051 /** |
|
3052 * @see getBlocksByClientId in core/block-editor store. |
|
3053 */ |
|
3054 |
|
3055 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId'); |
|
3056 /** |
|
3057 * @see getBlockCount in core/block-editor store. |
|
3058 */ |
|
3059 |
|
3060 const getBlockCount = getBlockEditorSelector('getBlockCount'); |
|
3061 /** |
|
3062 * @see getBlockSelectionStart in core/block-editor store. |
|
3063 */ |
|
3064 |
|
3065 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart'); |
|
3066 /** |
|
3067 * @see getBlockSelectionEnd in core/block-editor store. |
|
3068 */ |
|
3069 |
|
3070 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd'); |
|
3071 /** |
|
3072 * @see getSelectedBlockCount in core/block-editor store. |
|
3073 */ |
|
3074 |
|
3075 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount'); |
|
3076 /** |
|
3077 * @see hasSelectedBlock in core/block-editor store. |
|
3078 */ |
|
3079 |
|
3080 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock'); |
|
3081 /** |
|
3082 * @see getSelectedBlockClientId in core/block-editor store. |
|
3083 */ |
|
3084 |
|
3085 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId'); |
|
3086 /** |
|
3087 * @see getSelectedBlock in core/block-editor store. |
|
3088 */ |
|
3089 |
|
3090 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock'); |
|
3091 /** |
|
3092 * @see getBlockRootClientId in core/block-editor store. |
|
3093 */ |
|
3094 |
|
3095 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId'); |
|
3096 /** |
|
3097 * @see getBlockHierarchyRootClientId in core/block-editor store. |
|
3098 */ |
|
3099 |
|
3100 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId'); |
|
3101 /** |
|
3102 * @see getAdjacentBlockClientId in core/block-editor store. |
|
3103 */ |
|
3104 |
|
3105 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId'); |
|
3106 /** |
|
3107 * @see getPreviousBlockClientId in core/block-editor store. |
|
3108 */ |
|
3109 |
|
3110 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId'); |
|
3111 /** |
|
3112 * @see getNextBlockClientId in core/block-editor store. |
|
3113 */ |
|
3114 |
|
3115 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId'); |
|
3116 /** |
|
3117 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store. |
|
3118 */ |
|
3119 |
|
3120 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition'); |
|
3121 /** |
|
3122 * @see getMultiSelectedBlockClientIds in core/block-editor store. |
|
3123 */ |
|
3124 |
|
3125 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds'); |
|
3126 /** |
|
3127 * @see getMultiSelectedBlocks in core/block-editor store. |
|
3128 */ |
|
3129 |
|
3130 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks'); |
|
3131 /** |
|
3132 * @see getFirstMultiSelectedBlockClientId in core/block-editor store. |
|
3133 */ |
|
3134 |
|
3135 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId'); |
|
3136 /** |
|
3137 * @see getLastMultiSelectedBlockClientId in core/block-editor store. |
|
3138 */ |
|
3139 |
|
3140 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId'); |
|
3141 /** |
|
3142 * @see isFirstMultiSelectedBlock in core/block-editor store. |
|
3143 */ |
|
3144 |
|
3145 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock'); |
|
3146 /** |
|
3147 * @see isBlockMultiSelected in core/block-editor store. |
|
3148 */ |
|
3149 |
|
3150 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected'); |
|
3151 /** |
|
3152 * @see isAncestorMultiSelected in core/block-editor store. |
|
3153 */ |
|
3154 |
|
3155 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected'); |
|
3156 /** |
|
3157 * @see getMultiSelectedBlocksStartClientId in core/block-editor store. |
|
3158 */ |
|
3159 |
|
3160 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId'); |
|
3161 /** |
|
3162 * @see getMultiSelectedBlocksEndClientId in core/block-editor store. |
|
3163 */ |
|
3164 |
|
3165 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId'); |
|
3166 /** |
|
3167 * @see getBlockOrder in core/block-editor store. |
|
3168 */ |
|
3169 |
|
3170 const getBlockOrder = getBlockEditorSelector('getBlockOrder'); |
|
3171 /** |
|
3172 * @see getBlockIndex in core/block-editor store. |
|
3173 */ |
|
3174 |
|
3175 const getBlockIndex = getBlockEditorSelector('getBlockIndex'); |
|
3176 /** |
|
3177 * @see isBlockSelected in core/block-editor store. |
|
3178 */ |
|
3179 |
|
3180 const isBlockSelected = getBlockEditorSelector('isBlockSelected'); |
|
3181 /** |
|
3182 * @see hasSelectedInnerBlock in core/block-editor store. |
|
3183 */ |
|
3184 |
|
3185 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock'); |
|
3186 /** |
|
3187 * @see isBlockWithinSelection in core/block-editor store. |
|
3188 */ |
|
3189 |
|
3190 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection'); |
|
3191 /** |
|
3192 * @see hasMultiSelection in core/block-editor store. |
|
3193 */ |
|
3194 |
|
3195 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection'); |
|
3196 /** |
|
3197 * @see isMultiSelecting in core/block-editor store. |
|
3198 */ |
|
3199 |
|
3200 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting'); |
|
3201 /** |
|
3202 * @see isSelectionEnabled in core/block-editor store. |
|
3203 */ |
|
3204 |
|
3205 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled'); |
|
3206 /** |
|
3207 * @see getBlockMode in core/block-editor store. |
|
3208 */ |
|
3209 |
|
3210 const getBlockMode = getBlockEditorSelector('getBlockMode'); |
|
3211 /** |
|
3212 * @see isTyping in core/block-editor store. |
|
3213 */ |
|
3214 |
|
3215 const isTyping = getBlockEditorSelector('isTyping'); |
|
3216 /** |
|
3217 * @see isCaretWithinFormattedText in core/block-editor store. |
|
3218 */ |
|
3219 |
|
3220 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText'); |
|
3221 /** |
|
3222 * @see getBlockInsertionPoint in core/block-editor store. |
|
3223 */ |
|
3224 |
|
3225 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint'); |
|
3226 /** |
|
3227 * @see isBlockInsertionPointVisible in core/block-editor store. |
|
3228 */ |
|
3229 |
|
3230 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible'); |
|
3231 /** |
|
3232 * @see isValidTemplate in core/block-editor store. |
|
3233 */ |
|
3234 |
|
3235 const isValidTemplate = getBlockEditorSelector('isValidTemplate'); |
|
3236 /** |
|
3237 * @see getTemplate in core/block-editor store. |
|
3238 */ |
|
3239 |
|
3240 const getTemplate = getBlockEditorSelector('getTemplate'); |
|
3241 /** |
|
3242 * @see getTemplateLock in core/block-editor store. |
|
3243 */ |
|
3244 |
|
3245 const getTemplateLock = getBlockEditorSelector('getTemplateLock'); |
|
3246 /** |
|
3247 * @see canInsertBlockType in core/block-editor store. |
|
3248 */ |
|
3249 |
|
3250 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType'); |
|
3251 /** |
|
3252 * @see getInserterItems in core/block-editor store. |
|
3253 */ |
|
3254 |
|
3255 const getInserterItems = getBlockEditorSelector('getInserterItems'); |
|
3256 /** |
|
3257 * @see hasInserterItems in core/block-editor store. |
|
3258 */ |
|
3259 |
|
3260 const hasInserterItems = getBlockEditorSelector('hasInserterItems'); |
|
3261 /** |
|
3262 * @see getBlockListSettings in core/block-editor store. |
|
3263 */ |
|
3264 |
|
3265 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings'); |
|
3266 /** |
|
3267 * Returns the default template types. |
|
3268 * |
|
3269 * @param {Object} state Global application state. |
|
3270 * |
|
3271 * @return {Object} The template types. |
|
3272 */ |
|
3273 |
|
3274 function __experimentalGetDefaultTemplateTypes(state) { |
|
3275 var _getEditorSettings; |
|
3276 |
|
3277 return (_getEditorSettings = selectors_getEditorSettings(state)) === null || _getEditorSettings === void 0 ? void 0 : _getEditorSettings.defaultTemplateTypes; |
|
3278 } |
|
3279 /** |
|
3280 * Returns the default template part areas. |
|
3281 * |
|
3282 * @param {Object} state Global application state. |
|
3283 * |
|
3284 * @return {Array} The template part areas. |
|
3285 */ |
|
3286 |
|
3287 const __experimentalGetDefaultTemplatePartAreas = Object(rememo["a" /* default */])(state => { |
|
3288 var _getEditorSettings2; |
|
3289 |
|
3290 const areas = ((_getEditorSettings2 = selectors_getEditorSettings(state)) === null || _getEditorSettings2 === void 0 ? void 0 : _getEditorSettings2.defaultTemplatePartAreas) || []; |
|
3291 return areas === null || areas === void 0 ? void 0 : areas.map(item => { |
|
3292 return { ...item, |
|
3293 icon: getTemplatePartIcon(item.icon) |
|
3294 }; |
|
3295 }); |
|
3296 }, state => { |
|
3297 var _getEditorSettings3; |
|
3298 |
|
3299 return [(_getEditorSettings3 = selectors_getEditorSettings(state)) === null || _getEditorSettings3 === void 0 ? void 0 : _getEditorSettings3.defaultTemplatePartAreas]; |
|
3300 }); |
|
3301 /** |
|
3302 * Returns a default template type searched by slug. |
|
3303 * |
|
3304 * @param {Object} state Global application state. |
|
3305 * @param {string} slug The template type slug. |
|
3306 * |
|
3307 * @return {Object} The template type. |
|
3308 */ |
|
3309 |
|
3310 const __experimentalGetDefaultTemplateType = Object(rememo["a" /* default */])((state, slug) => Object(external_lodash_["find"])(__experimentalGetDefaultTemplateTypes(state), { |
|
3311 slug |
|
3312 }) || {}, (state, slug) => [__experimentalGetDefaultTemplateTypes(state), slug]); |
|
3313 /** |
|
3314 * Given a template entity, return information about it which is ready to be |
|
3315 * rendered, such as the title, description, and icon. |
|
3316 * |
|
3317 * @param {Object} state Global application state. |
|
3318 * @param {Object} template The template for which we need information. |
|
3319 * @return {Object} Information about the template, including title, description, and icon. |
|
3320 */ |
|
3321 |
|
3322 function __experimentalGetTemplateInfo(state, template) { |
|
3323 var _experimentalGetDefa; |
|
3324 |
|
3325 if (!template) { |
|
3326 return {}; |
|
3327 } |
|
3328 |
|
3329 const { |
|
3330 excerpt, |
|
3331 slug, |
|
3332 title, |
|
3333 area |
|
3334 } = template; |
|
3335 |
|
3336 const { |
|
3337 title: defaultTitle, |
|
3338 description: defaultDescription |
|
3339 } = __experimentalGetDefaultTemplateType(state, slug); |
|
3340 |
|
3341 const templateTitle = Object(external_lodash_["isString"])(title) ? title : title === null || title === void 0 ? void 0 : title.rendered; |
|
3342 const templateDescription = Object(external_lodash_["isString"])(excerpt) ? excerpt : excerpt === null || excerpt === void 0 ? void 0 : excerpt.raw; |
|
3343 const templateIcon = ((_experimentalGetDefa = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)) === null || _experimentalGetDefa === void 0 ? void 0 : _experimentalGetDefa.icon) || layout["a" /* default */]; |
|
3344 return { |
|
3345 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug, |
|
3346 description: templateDescription || defaultDescription, |
|
3347 icon: templateIcon |
|
3348 }; |
|
3349 } |
|
3350 |
|
3351 // EXTERNAL MODULE: external ["wp","notices"] |
|
3352 var external_wp_notices_ = __webpack_require__("onLe"); |
|
3353 |
|
3354 // EXTERNAL MODULE: external ["wp","i18n"] |
|
3355 var external_wp_i18n_ = __webpack_require__("l3Sj"); |
2864 |
3356 |
2865 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/notice-builder.js |
3357 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/notice-builder.js |
2866 /** |
3358 /** |
2867 * WordPress dependencies |
3359 * WordPress dependencies |
2868 */ |
3360 */ |
3289 * @param {Object} options Options for the edit. |
3673 * @param {Object} options Options for the edit. |
3290 * |
3674 * |
3291 * @yield {Object} Action object or control. |
3675 * @yield {Object} Action object or control. |
3292 */ |
3676 */ |
3293 |
3677 |
3294 function actions_editPost(edits, options) { |
3678 function* actions_editPost(edits, options) { |
3295 var _yield$select, id, type; |
3679 const { |
3296 |
3680 id, |
3297 return external_this_regeneratorRuntime_default.a.wrap(function editPost$(_context3) { |
3681 type |
3298 while (1) { |
3682 } = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
3299 switch (_context3.prev = _context3.next) { |
3683 yield external_wp_data_["controls"].dispatch('core', 'editEntityRecord', 'postType', type, id, edits, options); |
3300 case 0: |
3684 } |
3301 _context3.next = 2; |
3685 /** |
3302 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
3686 * Action generator for saving the current post in the editor. |
3303 |
3687 * |
3304 case 2: |
3688 * @param {Object} options |
3305 _yield$select = _context3.sent; |
3689 */ |
3306 id = _yield$select.id; |
3690 |
3307 type = _yield$select.type; |
3691 function* actions_savePost(options = {}) { |
3308 _context3.next = 7; |
3692 if (!(yield external_wp_data_["controls"].select(STORE_NAME, 'isEditedPostSaveable'))) { |
3309 return Object(external_this_wp_dataControls_["dispatch"])('core', 'editEntityRecord', 'postType', type, id, edits, options); |
3693 return; |
3310 |
3694 } |
3311 case 7: |
3695 |
3312 case "end": |
3696 let edits = { |
3313 return _context3.stop(); |
3697 content: yield external_wp_data_["controls"].select(STORE_NAME, 'getEditedPostContent') |
3314 } |
3698 }; |
|
3699 |
|
3700 if (!options.isAutosave) { |
|
3701 yield external_wp_data_["controls"].dispatch(STORE_NAME, 'editPost', edits, { |
|
3702 undoIgnore: true |
|
3703 }); |
|
3704 } |
|
3705 |
|
3706 yield __experimentalRequestPostUpdateStart(options); |
|
3707 const previousRecord = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
|
3708 edits = { |
|
3709 id: previousRecord.id, |
|
3710 ...(yield external_wp_data_["controls"].select('core', 'getEntityRecordNonTransientEdits', 'postType', previousRecord.type, previousRecord.id)), |
|
3711 ...edits |
|
3712 }; |
|
3713 yield external_wp_data_["controls"].dispatch('core', 'saveEntityRecord', 'postType', previousRecord.type, edits, options); |
|
3714 yield __experimentalRequestPostUpdateFinish(options); |
|
3715 const error = yield external_wp_data_["controls"].select('core', 'getLastEntitySaveError', 'postType', previousRecord.type, previousRecord.id); |
|
3716 |
|
3717 if (error) { |
|
3718 const args = getNotificationArgumentsForSaveFail({ |
|
3719 post: previousRecord, |
|
3720 edits, |
|
3721 error |
|
3722 }); |
|
3723 |
|
3724 if (args.length) { |
|
3725 yield external_wp_data_["controls"].dispatch(external_wp_notices_["store"], 'createErrorNotice', ...args); |
3315 } |
3726 } |
3316 }, _marked3); |
3727 } else { |
3317 } |
3728 const updatedRecord = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
3318 /** |
3729 const args = getNotificationArgumentsForSaveSuccess({ |
3319 * Returns action object produced by the updatePost creator augmented by |
3730 previousPost: previousRecord, |
3320 * an optimist option that signals optimistically applying updates. |
3731 post: updatedRecord, |
3321 * |
3732 postType: yield external_wp_data_["controls"].resolveSelect('core', 'getPostType', updatedRecord.type), |
3322 * @param {Object} edits Updated post fields. |
3733 options |
3323 * |
3734 }); |
3324 * @return {Object} Action object. |
3735 |
3325 */ |
3736 if (args.length) { |
3326 |
3737 yield external_wp_data_["controls"].dispatch(external_wp_notices_["store"], 'createSuccessNotice', ...args); |
3327 function __experimentalOptimisticUpdatePost(edits) { |
3738 } // Make sure that any edits after saving create an undo level and are |
3328 return actions_objectSpread({}, updatePost(edits), { |
3739 // considered for change detection. |
3329 optimist: { |
3740 |
3330 id: POST_UPDATE_TRANSACTION_ID |
3741 |
|
3742 if (!options.isAutosave) { |
|
3743 yield external_wp_data_["controls"].dispatch('core/block-editor', '__unstableMarkLastChangeAsPersistent'); |
3331 } |
3744 } |
|
3745 } |
|
3746 } |
|
3747 /** |
|
3748 * Action generator for handling refreshing the current post. |
|
3749 */ |
|
3750 |
|
3751 function* refreshPost() { |
|
3752 const post = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
|
3753 const postTypeSlug = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPostType'); |
|
3754 const postType = yield external_wp_data_["controls"].resolveSelect('core', 'getPostType', postTypeSlug); |
|
3755 const newPost = yield Object(external_wp_dataControls_["apiFetch"])({ |
|
3756 // Timestamp arg allows caller to bypass browser caching, which is |
|
3757 // expected for this specific function. |
|
3758 path: `/wp/v2/${postType.rest_base}/${post.id}` + `?context=edit&_timestamp=${Date.now()}` |
3332 }); |
3759 }); |
3333 } |
3760 yield external_wp_data_["controls"].dispatch(STORE_NAME, 'resetPost', newPost); |
3334 /** |
|
3335 * Action generator for saving the current post in the editor. |
|
3336 * |
|
3337 * @param {Object} options |
|
3338 */ |
|
3339 |
|
3340 function actions_savePost() { |
|
3341 var options, |
|
3342 edits, |
|
3343 previousRecord, |
|
3344 error, |
|
3345 args, |
|
3346 updatedRecord, |
|
3347 _args4, |
|
3348 _args5 = arguments; |
|
3349 |
|
3350 return external_this_regeneratorRuntime_default.a.wrap(function savePost$(_context4) { |
|
3351 while (1) { |
|
3352 switch (_context4.prev = _context4.next) { |
|
3353 case 0: |
|
3354 options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}; |
|
3355 _context4.next = 3; |
|
3356 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'isEditedPostSaveable'); |
|
3357 |
|
3358 case 3: |
|
3359 if (_context4.sent) { |
|
3360 _context4.next = 5; |
|
3361 break; |
|
3362 } |
|
3363 |
|
3364 return _context4.abrupt("return"); |
|
3365 |
|
3366 case 5: |
|
3367 _context4.next = 7; |
|
3368 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getEditedPostContent'); |
|
3369 |
|
3370 case 7: |
|
3371 _context4.t0 = _context4.sent; |
|
3372 edits = { |
|
3373 content: _context4.t0 |
|
3374 }; |
|
3375 |
|
3376 if (options.isAutosave) { |
|
3377 _context4.next = 12; |
|
3378 break; |
|
3379 } |
|
3380 |
|
3381 _context4.next = 12; |
|
3382 return Object(external_this_wp_dataControls_["dispatch"])(STORE_KEY, 'editPost', edits, { |
|
3383 undoIgnore: true |
|
3384 }); |
|
3385 |
|
3386 case 12: |
|
3387 _context4.next = 14; |
|
3388 return __experimentalRequestPostUpdateStart(options); |
|
3389 |
|
3390 case 14: |
|
3391 _context4.next = 16; |
|
3392 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
|
3393 |
|
3394 case 16: |
|
3395 previousRecord = _context4.sent; |
|
3396 _context4.t1 = actions_objectSpread; |
|
3397 _context4.t2 = { |
|
3398 id: previousRecord.id |
|
3399 }; |
|
3400 _context4.next = 21; |
|
3401 return Object(external_this_wp_dataControls_["select"])('core', 'getEntityRecordNonTransientEdits', 'postType', previousRecord.type, previousRecord.id); |
|
3402 |
|
3403 case 21: |
|
3404 _context4.t3 = _context4.sent; |
|
3405 _context4.t4 = {}; |
|
3406 _context4.t5 = edits; |
|
3407 edits = (0, _context4.t1)(_context4.t2, _context4.t3, _context4.t4, _context4.t5); |
|
3408 _context4.next = 27; |
|
3409 return Object(external_this_wp_dataControls_["dispatch"])('core', 'saveEntityRecord', 'postType', previousRecord.type, edits, options); |
|
3410 |
|
3411 case 27: |
|
3412 _context4.next = 29; |
|
3413 return __experimentalRequestPostUpdateFinish(options); |
|
3414 |
|
3415 case 29: |
|
3416 _context4.next = 31; |
|
3417 return Object(external_this_wp_dataControls_["select"])('core', 'getLastEntitySaveError', 'postType', previousRecord.type, previousRecord.id); |
|
3418 |
|
3419 case 31: |
|
3420 error = _context4.sent; |
|
3421 |
|
3422 if (!error) { |
|
3423 _context4.next = 39; |
|
3424 break; |
|
3425 } |
|
3426 |
|
3427 args = getNotificationArgumentsForSaveFail({ |
|
3428 post: previousRecord, |
|
3429 edits: edits, |
|
3430 error: error |
|
3431 }); |
|
3432 |
|
3433 if (!args.length) { |
|
3434 _context4.next = 37; |
|
3435 break; |
|
3436 } |
|
3437 |
|
3438 _context4.next = 37; |
|
3439 return external_this_wp_dataControls_["dispatch"].apply(void 0, ['core/notices', 'createErrorNotice'].concat(Object(toConsumableArray["a" /* default */])(args))); |
|
3440 |
|
3441 case 37: |
|
3442 _context4.next = 57; |
|
3443 break; |
|
3444 |
|
3445 case 39: |
|
3446 _context4.next = 41; |
|
3447 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
|
3448 |
|
3449 case 41: |
|
3450 updatedRecord = _context4.sent; |
|
3451 _context4.t6 = getNotificationArgumentsForSaveSuccess; |
|
3452 _context4.t7 = previousRecord; |
|
3453 _context4.t8 = updatedRecord; |
|
3454 _context4.next = 47; |
|
3455 return Object(external_this_wp_dataControls_["select"])('core', 'getPostType', updatedRecord.type); |
|
3456 |
|
3457 case 47: |
|
3458 _context4.t9 = _context4.sent; |
|
3459 _context4.t10 = options; |
|
3460 _context4.t11 = { |
|
3461 previousPost: _context4.t7, |
|
3462 post: _context4.t8, |
|
3463 postType: _context4.t9, |
|
3464 options: _context4.t10 |
|
3465 }; |
|
3466 _args4 = (0, _context4.t6)(_context4.t11); |
|
3467 |
|
3468 if (!_args4.length) { |
|
3469 _context4.next = 54; |
|
3470 break; |
|
3471 } |
|
3472 |
|
3473 _context4.next = 54; |
|
3474 return external_this_wp_dataControls_["dispatch"].apply(void 0, ['core/notices', 'createSuccessNotice'].concat(Object(toConsumableArray["a" /* default */])(_args4))); |
|
3475 |
|
3476 case 54: |
|
3477 if (options.isAutosave) { |
|
3478 _context4.next = 57; |
|
3479 break; |
|
3480 } |
|
3481 |
|
3482 _context4.next = 57; |
|
3483 return Object(external_this_wp_dataControls_["dispatch"])('core/block-editor', '__unstableMarkLastChangeAsPersistent'); |
|
3484 |
|
3485 case 57: |
|
3486 case "end": |
|
3487 return _context4.stop(); |
|
3488 } |
|
3489 } |
|
3490 }, _marked4); |
|
3491 } |
|
3492 /** |
|
3493 * Action generator for handling refreshing the current post. |
|
3494 */ |
|
3495 |
|
3496 function refreshPost() { |
|
3497 var post, postTypeSlug, postType, newPost; |
|
3498 return external_this_regeneratorRuntime_default.a.wrap(function refreshPost$(_context5) { |
|
3499 while (1) { |
|
3500 switch (_context5.prev = _context5.next) { |
|
3501 case 0: |
|
3502 _context5.next = 2; |
|
3503 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
|
3504 |
|
3505 case 2: |
|
3506 post = _context5.sent; |
|
3507 _context5.next = 5; |
|
3508 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPostType'); |
|
3509 |
|
3510 case 5: |
|
3511 postTypeSlug = _context5.sent; |
|
3512 _context5.next = 8; |
|
3513 return Object(external_this_wp_dataControls_["select"])('core', 'getPostType', postTypeSlug); |
|
3514 |
|
3515 case 8: |
|
3516 postType = _context5.sent; |
|
3517 _context5.next = 11; |
|
3518 return Object(external_this_wp_dataControls_["apiFetch"])({ |
|
3519 // Timestamp arg allows caller to bypass browser caching, which is |
|
3520 // expected for this specific function. |
|
3521 path: "/wp/v2/".concat(postType.rest_base, "/").concat(post.id) + "?context=edit&_timestamp=".concat(Date.now()) |
|
3522 }); |
|
3523 |
|
3524 case 11: |
|
3525 newPost = _context5.sent; |
|
3526 _context5.next = 14; |
|
3527 return Object(external_this_wp_dataControls_["dispatch"])(STORE_KEY, 'resetPost', newPost); |
|
3528 |
|
3529 case 14: |
|
3530 case "end": |
|
3531 return _context5.stop(); |
|
3532 } |
|
3533 } |
|
3534 }, _marked5); |
|
3535 } |
3761 } |
3536 /** |
3762 /** |
3537 * Action generator for trashing the current post in the editor. |
3763 * Action generator for trashing the current post in the editor. |
3538 */ |
3764 */ |
3539 |
3765 |
3540 function trashPost() { |
3766 function* trashPost() { |
3541 var postTypeSlug, postType, post; |
3767 const postTypeSlug = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPostType'); |
3542 return external_this_regeneratorRuntime_default.a.wrap(function trashPost$(_context6) { |
3768 const postType = yield external_wp_data_["controls"].resolveSelect('core', 'getPostType', postTypeSlug); |
3543 while (1) { |
3769 yield external_wp_data_["controls"].dispatch(external_wp_notices_["store"], 'removeNotice', TRASH_POST_NOTICE_ID); |
3544 switch (_context6.prev = _context6.next) { |
3770 |
3545 case 0: |
3771 try { |
3546 _context6.next = 2; |
3772 const post = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
3547 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPostType'); |
3773 yield Object(external_wp_dataControls_["apiFetch"])({ |
3548 |
3774 path: `/wp/v2/${postType.rest_base}/${post.id}`, |
3549 case 2: |
3775 method: 'DELETE' |
3550 postTypeSlug = _context6.sent; |
3776 }); |
3551 _context6.next = 5; |
3777 yield external_wp_data_["controls"].dispatch(STORE_NAME, 'savePost'); |
3552 return Object(external_this_wp_dataControls_["select"])('core', 'getPostType', postTypeSlug); |
3778 } catch (error) { |
3553 |
3779 yield external_wp_data_["controls"].dispatch(external_wp_notices_["store"], 'createErrorNotice', ...getNotificationArgumentsForTrashFail({ |
3554 case 5: |
3780 error |
3555 postType = _context6.sent; |
3781 })); |
3556 _context6.next = 8; |
3782 } |
3557 return Object(external_this_wp_dataControls_["dispatch"])('core/notices', 'removeNotice', TRASH_POST_NOTICE_ID); |
3783 } |
3558 |
3784 /** |
3559 case 8: |
3785 * Action generator used in signalling that the post should autosave. This |
3560 _context6.prev = 8; |
3786 * includes server-side autosaving (default) and client-side (a.k.a. local) |
3561 _context6.next = 11; |
3787 * autosaving (e.g. on the Web, the post might be committed to Session |
3562 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
3788 * Storage). |
3563 |
|
3564 case 11: |
|
3565 post = _context6.sent; |
|
3566 _context6.next = 14; |
|
3567 return Object(external_this_wp_dataControls_["apiFetch"])({ |
|
3568 path: "/wp/v2/".concat(postType.rest_base, "/").concat(post.id), |
|
3569 method: 'DELETE' |
|
3570 }); |
|
3571 |
|
3572 case 14: |
|
3573 _context6.next = 16; |
|
3574 return Object(external_this_wp_dataControls_["dispatch"])(STORE_KEY, 'savePost'); |
|
3575 |
|
3576 case 16: |
|
3577 _context6.next = 22; |
|
3578 break; |
|
3579 |
|
3580 case 18: |
|
3581 _context6.prev = 18; |
|
3582 _context6.t0 = _context6["catch"](8); |
|
3583 _context6.next = 22; |
|
3584 return external_this_wp_dataControls_["dispatch"].apply(void 0, ['core/notices', 'createErrorNotice'].concat(Object(toConsumableArray["a" /* default */])(getNotificationArgumentsForTrashFail({ |
|
3585 error: _context6.t0 |
|
3586 })))); |
|
3587 |
|
3588 case 22: |
|
3589 case "end": |
|
3590 return _context6.stop(); |
|
3591 } |
|
3592 } |
|
3593 }, _marked6, null, [[8, 18]]); |
|
3594 } |
|
3595 /** |
|
3596 * Action generator used in signalling that the post should autosave. |
|
3597 * |
3789 * |
3598 * @param {Object?} options Extra flags to identify the autosave. |
3790 * @param {Object?} options Extra flags to identify the autosave. |
3599 */ |
3791 */ |
3600 |
3792 |
3601 function actions_autosave(options) { |
3793 function* actions_autosave({ |
3602 return external_this_regeneratorRuntime_default.a.wrap(function autosave$(_context7) { |
3794 local = false, |
3603 while (1) { |
3795 ...options |
3604 switch (_context7.prev = _context7.next) { |
3796 } = {}) { |
3605 case 0: |
3797 if (local) { |
3606 _context7.next = 2; |
3798 const post = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
3607 return Object(external_this_wp_dataControls_["dispatch"])(STORE_KEY, 'savePost', actions_objectSpread({ |
3799 const isPostNew = yield external_wp_data_["controls"].select(STORE_NAME, 'isEditedPostNew'); |
3608 isAutosave: true |
3800 const title = yield external_wp_data_["controls"].select(STORE_NAME, 'getEditedPostAttribute', 'title'); |
3609 }, options)); |
3801 const content = yield external_wp_data_["controls"].select(STORE_NAME, 'getEditedPostAttribute', 'content'); |
3610 |
3802 const excerpt = yield external_wp_data_["controls"].select(STORE_NAME, 'getEditedPostAttribute', 'excerpt'); |
3611 case 2: |
3803 yield { |
3612 case "end": |
3804 type: 'LOCAL_AUTOSAVE_SET', |
3613 return _context7.stop(); |
3805 postId: post.id, |
3614 } |
3806 isPostNew, |
3615 } |
3807 title, |
3616 }, _marked7); |
3808 content, |
3617 } |
3809 excerpt |
3618 function actions_experimentalLocalAutosave() { |
3810 }; |
3619 var post, title, content, excerpt; |
3811 } else { |
3620 return external_this_regeneratorRuntime_default.a.wrap(function __experimentalLocalAutosave$(_context8) { |
3812 yield external_wp_data_["controls"].dispatch(STORE_NAME, 'savePost', { |
3621 while (1) { |
3813 isAutosave: true, |
3622 switch (_context8.prev = _context8.next) { |
3814 ...options |
3623 case 0: |
3815 }); |
3624 _context8.next = 2; |
3816 } |
3625 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
|
3626 |
|
3627 case 2: |
|
3628 post = _context8.sent; |
|
3629 _context8.next = 5; |
|
3630 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getEditedPostAttribute', 'title'); |
|
3631 |
|
3632 case 5: |
|
3633 title = _context8.sent; |
|
3634 _context8.next = 8; |
|
3635 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getEditedPostAttribute', 'content'); |
|
3636 |
|
3637 case 8: |
|
3638 content = _context8.sent; |
|
3639 _context8.next = 11; |
|
3640 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getEditedPostAttribute', 'excerpt'); |
|
3641 |
|
3642 case 11: |
|
3643 excerpt = _context8.sent; |
|
3644 _context8.next = 14; |
|
3645 return { |
|
3646 type: 'LOCAL_AUTOSAVE_SET', |
|
3647 postId: post.id, |
|
3648 title: title, |
|
3649 content: content, |
|
3650 excerpt: excerpt |
|
3651 }; |
|
3652 |
|
3653 case 14: |
|
3654 case "end": |
|
3655 return _context8.stop(); |
|
3656 } |
|
3657 } |
|
3658 }, _marked8); |
|
3659 } |
3817 } |
3660 /** |
3818 /** |
3661 * Returns an action object used in signalling that undo history should |
3819 * Returns an action object used in signalling that undo history should |
3662 * restore last popped state. |
3820 * restore last popped state. |
3663 * |
3821 * |
3664 * @yield {Object} Action object. |
3822 * @yield {Object} Action object. |
3665 */ |
3823 */ |
3666 |
3824 |
3667 function actions_redo() { |
3825 function* actions_redo() { |
3668 return external_this_regeneratorRuntime_default.a.wrap(function redo$(_context9) { |
3826 yield external_wp_data_["controls"].dispatch('core', 'redo'); |
3669 while (1) { |
|
3670 switch (_context9.prev = _context9.next) { |
|
3671 case 0: |
|
3672 _context9.next = 2; |
|
3673 return Object(external_this_wp_dataControls_["dispatch"])('core', 'redo'); |
|
3674 |
|
3675 case 2: |
|
3676 case "end": |
|
3677 return _context9.stop(); |
|
3678 } |
|
3679 } |
|
3680 }, _marked9); |
|
3681 } |
3827 } |
3682 /** |
3828 /** |
3683 * Returns an action object used in signalling that undo history should pop. |
3829 * Returns an action object used in signalling that undo history should pop. |
3684 * |
3830 * |
3685 * @yield {Object} Action object. |
3831 * @yield {Object} Action object. |
3686 */ |
3832 */ |
3687 |
3833 |
3688 function actions_undo() { |
3834 function* actions_undo() { |
3689 return external_this_regeneratorRuntime_default.a.wrap(function undo$(_context10) { |
3835 yield external_wp_data_["controls"].dispatch('core', 'undo'); |
3690 while (1) { |
|
3691 switch (_context10.prev = _context10.next) { |
|
3692 case 0: |
|
3693 _context10.next = 2; |
|
3694 return Object(external_this_wp_dataControls_["dispatch"])('core', 'undo'); |
|
3695 |
|
3696 case 2: |
|
3697 case "end": |
|
3698 return _context10.stop(); |
|
3699 } |
|
3700 } |
|
3701 }, _marked10); |
|
3702 } |
3836 } |
3703 /** |
3837 /** |
3704 * Returns an action object used in signalling that undo history record should |
3838 * Returns an action object used in signalling that undo history record should |
3705 * be created. |
3839 * be created. |
3706 * |
3840 * |
3976 * @param {?Object} options Optional options. |
4001 * @param {?Object} options Optional options. |
3977 * |
4002 * |
3978 * @yield {Object} Action object |
4003 * @yield {Object} Action object |
3979 */ |
4004 */ |
3980 |
4005 |
3981 function actions_resetEditorBlocks(blocks) { |
4006 function* actions_resetEditorBlocks(blocks, options = {}) { |
3982 var options, |
4007 const { |
3983 __unstableShouldCreateUndoLevel, |
4008 __unstableShouldCreateUndoLevel, |
3984 selectionStart, |
4009 selection |
3985 selectionEnd, |
4010 } = options; |
3986 edits, |
4011 const edits = { |
3987 _yield$select2, |
4012 blocks, |
|
4013 selection |
|
4014 }; |
|
4015 |
|
4016 if (__unstableShouldCreateUndoLevel !== false) { |
|
4017 const { |
3988 id, |
4018 id, |
3989 type, |
4019 type |
3990 noChange, |
4020 } = yield external_wp_data_["controls"].select(STORE_NAME, 'getCurrentPost'); |
3991 _args12 = arguments; |
4021 const noChange = (yield external_wp_data_["controls"].select('core', 'getEditedEntityRecord', 'postType', type, id)).blocks === edits.blocks; |
3992 |
4022 |
3993 return external_this_regeneratorRuntime_default.a.wrap(function resetEditorBlocks$(_context11) { |
4023 if (noChange) { |
3994 while (1) { |
4024 return yield external_wp_data_["controls"].dispatch('core', '__unstableCreateUndoLevel', 'postType', type, id); |
3995 switch (_context11.prev = _context11.next) { |
4025 } // We create a new function here on every persistent edit |
3996 case 0: |
4026 // to make sure the edit makes the post dirty and creates |
3997 options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {}; |
4027 // a new undo level. |
3998 __unstableShouldCreateUndoLevel = options.__unstableShouldCreateUndoLevel, selectionStart = options.selectionStart, selectionEnd = options.selectionEnd; |
4028 |
3999 edits = { |
4029 |
4000 blocks: blocks, |
4030 edits.content = ({ |
4001 selectionStart: selectionStart, |
4031 blocks: blocksForSerialization = [] |
4002 selectionEnd: selectionEnd |
4032 }) => Object(external_wp_blocks_["__unstableSerializeAndClean"])(blocksForSerialization); |
4003 }; |
4033 } |
4004 |
4034 |
4005 if (!(__unstableShouldCreateUndoLevel !== false)) { |
4035 yield* actions_editPost(edits); |
4006 _context11.next = 19; |
|
4007 break; |
|
4008 } |
|
4009 |
|
4010 _context11.next = 6; |
|
4011 return Object(external_this_wp_dataControls_["select"])(STORE_KEY, 'getCurrentPost'); |
|
4012 |
|
4013 case 6: |
|
4014 _yield$select2 = _context11.sent; |
|
4015 id = _yield$select2.id; |
|
4016 type = _yield$select2.type; |
|
4017 _context11.next = 11; |
|
4018 return Object(external_this_wp_dataControls_["__unstableSyncSelect"])('core', 'getEditedEntityRecord', 'postType', type, id); |
|
4019 |
|
4020 case 11: |
|
4021 _context11.t0 = _context11.sent.blocks; |
|
4022 _context11.t1 = edits.blocks; |
|
4023 noChange = _context11.t0 === _context11.t1; |
|
4024 |
|
4025 if (!noChange) { |
|
4026 _context11.next = 18; |
|
4027 break; |
|
4028 } |
|
4029 |
|
4030 _context11.next = 17; |
|
4031 return Object(external_this_wp_dataControls_["dispatch"])('core', '__unstableCreateUndoLevel', 'postType', type, id); |
|
4032 |
|
4033 case 17: |
|
4034 return _context11.abrupt("return", _context11.sent); |
|
4035 |
|
4036 case 18: |
|
4037 // We create a new function here on every persistent edit |
|
4038 // to make sure the edit makes the post dirty and creates |
|
4039 // a new undo level. |
|
4040 edits.content = function (_ref) { |
|
4041 var _ref$blocks = _ref.blocks, |
|
4042 blocksForSerialization = _ref$blocks === void 0 ? [] : _ref$blocks; |
|
4043 return serialize_blocks(blocksForSerialization); |
|
4044 }; |
|
4045 |
|
4046 case 19: |
|
4047 return _context11.delegateYield(actions_editPost(edits), "t2", 20); |
|
4048 |
|
4049 case 20: |
|
4050 case "end": |
|
4051 return _context11.stop(); |
|
4052 } |
|
4053 } |
|
4054 }, _marked11); |
|
4055 } |
4036 } |
4056 /* |
4037 /* |
4057 * Returns an action object used in signalling that the post editor settings have been updated. |
4038 * Returns an action object used in signalling that the post editor settings have been updated. |
4058 * |
4039 * |
4059 * @param {Object} settings Updated settings |
4040 * @param {Object} settings Updated settings |
4060 * |
4041 * |
4061 * @return {Object} Action object |
4042 * @return {Object} Action object |
4062 */ |
4043 */ |
4063 |
4044 |
4064 function updateEditorSettings(settings) { |
4045 function actions_updateEditorSettings(settings) { |
4065 return { |
4046 return { |
4066 type: 'UPDATE_EDITOR_SETTINGS', |
4047 type: 'UPDATE_EDITOR_SETTINGS', |
4067 settings: settings |
4048 settings |
4068 }; |
4049 }; |
4069 } |
4050 } |
4070 /** |
4051 /** |
4071 * Backward compatibility |
4052 * Backward compatibility |
4072 */ |
4053 */ |
4073 |
4054 |
4074 var actions_getBlockEditorAction = function getBlockEditorAction(name) { |
4055 const getBlockEditorAction = name => function* (...args) { |
4075 return /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee() { |
4056 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', { |
4076 var _len, |
4057 since: '5.3', |
4077 args, |
4058 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`' |
4078 _key, |
|
4079 _args13 = arguments; |
|
4080 |
|
4081 return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context12) { |
|
4082 while (1) { |
|
4083 switch (_context12.prev = _context12.next) { |
|
4084 case 0: |
|
4085 external_this_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', { |
|
4086 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`' |
|
4087 }); |
|
4088 |
|
4089 for (_len = _args13.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
|
4090 args[_key] = _args13[_key]; |
|
4091 } |
|
4092 |
|
4093 _context12.next = 4; |
|
4094 return external_this_wp_dataControls_["dispatch"].apply(void 0, ['core/block-editor', name].concat(args)); |
|
4095 |
|
4096 case 4: |
|
4097 case "end": |
|
4098 return _context12.stop(); |
|
4099 } |
|
4100 } |
|
4101 }, _callee); |
|
4102 }); |
4059 }); |
|
4060 yield external_wp_data_["controls"].dispatch('core/block-editor', name, ...args); |
4103 }; |
4061 }; |
4104 /** |
4062 /** |
4105 * @see resetBlocks in core/block-editor store. |
4063 * @see resetBlocks in core/block-editor store. |
4106 */ |
4064 */ |
4107 |
4065 |
4108 |
4066 |
4109 var resetBlocks = actions_getBlockEditorAction('resetBlocks'); |
4067 const resetBlocks = getBlockEditorAction('resetBlocks'); |
4110 /** |
4068 /** |
4111 * @see receiveBlocks in core/block-editor store. |
4069 * @see receiveBlocks in core/block-editor store. |
4112 */ |
4070 */ |
4113 |
4071 |
4114 var receiveBlocks = actions_getBlockEditorAction('receiveBlocks'); |
4072 const receiveBlocks = getBlockEditorAction('receiveBlocks'); |
4115 /** |
4073 /** |
4116 * @see updateBlock in core/block-editor store. |
4074 * @see updateBlock in core/block-editor store. |
4117 */ |
4075 */ |
4118 |
4076 |
4119 var updateBlock = actions_getBlockEditorAction('updateBlock'); |
4077 const updateBlock = getBlockEditorAction('updateBlock'); |
4120 /** |
4078 /** |
4121 * @see updateBlockAttributes in core/block-editor store. |
4079 * @see updateBlockAttributes in core/block-editor store. |
4122 */ |
4080 */ |
4123 |
4081 |
4124 var updateBlockAttributes = actions_getBlockEditorAction('updateBlockAttributes'); |
4082 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes'); |
4125 /** |
4083 /** |
4126 * @see selectBlock in core/block-editor store. |
4084 * @see selectBlock in core/block-editor store. |
4127 */ |
4085 */ |
4128 |
4086 |
4129 var actions_selectBlock = actions_getBlockEditorAction('selectBlock'); |
4087 const actions_selectBlock = getBlockEditorAction('selectBlock'); |
4130 /** |
4088 /** |
4131 * @see startMultiSelect in core/block-editor store. |
4089 * @see startMultiSelect in core/block-editor store. |
4132 */ |
4090 */ |
4133 |
4091 |
4134 var startMultiSelect = actions_getBlockEditorAction('startMultiSelect'); |
4092 const startMultiSelect = getBlockEditorAction('startMultiSelect'); |
4135 /** |
4093 /** |
4136 * @see stopMultiSelect in core/block-editor store. |
4094 * @see stopMultiSelect in core/block-editor store. |
4137 */ |
4095 */ |
4138 |
4096 |
4139 var stopMultiSelect = actions_getBlockEditorAction('stopMultiSelect'); |
4097 const stopMultiSelect = getBlockEditorAction('stopMultiSelect'); |
4140 /** |
4098 /** |
4141 * @see multiSelect in core/block-editor store. |
4099 * @see multiSelect in core/block-editor store. |
4142 */ |
4100 */ |
4143 |
4101 |
4144 var multiSelect = actions_getBlockEditorAction('multiSelect'); |
4102 const multiSelect = getBlockEditorAction('multiSelect'); |
4145 /** |
4103 /** |
4146 * @see clearSelectedBlock in core/block-editor store. |
4104 * @see clearSelectedBlock in core/block-editor store. |
4147 */ |
4105 */ |
4148 |
4106 |
4149 var clearSelectedBlock = actions_getBlockEditorAction('clearSelectedBlock'); |
4107 const actions_clearSelectedBlock = getBlockEditorAction('clearSelectedBlock'); |
4150 /** |
4108 /** |
4151 * @see toggleSelection in core/block-editor store. |
4109 * @see toggleSelection in core/block-editor store. |
4152 */ |
4110 */ |
4153 |
4111 |
4154 var toggleSelection = actions_getBlockEditorAction('toggleSelection'); |
4112 const toggleSelection = getBlockEditorAction('toggleSelection'); |
4155 /** |
4113 /** |
4156 * @see replaceBlocks in core/block-editor store. |
4114 * @see replaceBlocks in core/block-editor store. |
4157 */ |
4115 */ |
4158 |
4116 |
4159 var actions_replaceBlocks = actions_getBlockEditorAction('replaceBlocks'); |
4117 const replaceBlocks = getBlockEditorAction('replaceBlocks'); |
4160 /** |
4118 /** |
4161 * @see replaceBlock in core/block-editor store. |
4119 * @see replaceBlock in core/block-editor store. |
4162 */ |
4120 */ |
4163 |
4121 |
4164 var replaceBlock = actions_getBlockEditorAction('replaceBlock'); |
4122 const replaceBlock = getBlockEditorAction('replaceBlock'); |
4165 /** |
4123 /** |
4166 * @see moveBlocksDown in core/block-editor store. |
4124 * @see moveBlocksDown in core/block-editor store. |
4167 */ |
4125 */ |
4168 |
4126 |
4169 var moveBlocksDown = actions_getBlockEditorAction('moveBlocksDown'); |
4127 const moveBlocksDown = getBlockEditorAction('moveBlocksDown'); |
4170 /** |
4128 /** |
4171 * @see moveBlocksUp in core/block-editor store. |
4129 * @see moveBlocksUp in core/block-editor store. |
4172 */ |
4130 */ |
4173 |
4131 |
4174 var moveBlocksUp = actions_getBlockEditorAction('moveBlocksUp'); |
4132 const moveBlocksUp = getBlockEditorAction('moveBlocksUp'); |
4175 /** |
4133 /** |
4176 * @see moveBlockToPosition in core/block-editor store. |
4134 * @see moveBlockToPosition in core/block-editor store. |
4177 */ |
4135 */ |
4178 |
4136 |
4179 var moveBlockToPosition = actions_getBlockEditorAction('moveBlockToPosition'); |
4137 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition'); |
4180 /** |
4138 /** |
4181 * @see insertBlock in core/block-editor store. |
4139 * @see insertBlock in core/block-editor store. |
4182 */ |
4140 */ |
4183 |
4141 |
4184 var insertBlock = actions_getBlockEditorAction('insertBlock'); |
4142 const insertBlock = getBlockEditorAction('insertBlock'); |
4185 /** |
4143 /** |
4186 * @see insertBlocks in core/block-editor store. |
4144 * @see insertBlocks in core/block-editor store. |
4187 */ |
4145 */ |
4188 |
4146 |
4189 var insertBlocks = actions_getBlockEditorAction('insertBlocks'); |
4147 const actions_insertBlocks = getBlockEditorAction('insertBlocks'); |
4190 /** |
4148 /** |
4191 * @see showInsertionPoint in core/block-editor store. |
4149 * @see showInsertionPoint in core/block-editor store. |
4192 */ |
4150 */ |
4193 |
4151 |
4194 var showInsertionPoint = actions_getBlockEditorAction('showInsertionPoint'); |
4152 const showInsertionPoint = getBlockEditorAction('showInsertionPoint'); |
4195 /** |
4153 /** |
4196 * @see hideInsertionPoint in core/block-editor store. |
4154 * @see hideInsertionPoint in core/block-editor store. |
4197 */ |
4155 */ |
4198 |
4156 |
4199 var hideInsertionPoint = actions_getBlockEditorAction('hideInsertionPoint'); |
4157 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint'); |
4200 /** |
4158 /** |
4201 * @see setTemplateValidity in core/block-editor store. |
4159 * @see setTemplateValidity in core/block-editor store. |
4202 */ |
4160 */ |
4203 |
4161 |
4204 var setTemplateValidity = actions_getBlockEditorAction('setTemplateValidity'); |
4162 const actions_setTemplateValidity = getBlockEditorAction('setTemplateValidity'); |
4205 /** |
4163 /** |
4206 * @see synchronizeTemplate in core/block-editor store. |
4164 * @see synchronizeTemplate in core/block-editor store. |
4207 */ |
4165 */ |
4208 |
4166 |
4209 var synchronizeTemplate = actions_getBlockEditorAction('synchronizeTemplate'); |
4167 const actions_synchronizeTemplate = getBlockEditorAction('synchronizeTemplate'); |
4210 /** |
4168 /** |
4211 * @see mergeBlocks in core/block-editor store. |
4169 * @see mergeBlocks in core/block-editor store. |
4212 */ |
4170 */ |
4213 |
4171 |
4214 var mergeBlocks = actions_getBlockEditorAction('mergeBlocks'); |
4172 const mergeBlocks = getBlockEditorAction('mergeBlocks'); |
4215 /** |
4173 /** |
4216 * @see removeBlocks in core/block-editor store. |
4174 * @see removeBlocks in core/block-editor store. |
4217 */ |
4175 */ |
4218 |
4176 |
4219 var removeBlocks = actions_getBlockEditorAction('removeBlocks'); |
4177 const removeBlocks = getBlockEditorAction('removeBlocks'); |
4220 /** |
4178 /** |
4221 * @see removeBlock in core/block-editor store. |
4179 * @see removeBlock in core/block-editor store. |
4222 */ |
4180 */ |
4223 |
4181 |
4224 var removeBlock = actions_getBlockEditorAction('removeBlock'); |
4182 const removeBlock = getBlockEditorAction('removeBlock'); |
4225 /** |
4183 /** |
4226 * @see toggleBlockMode in core/block-editor store. |
4184 * @see toggleBlockMode in core/block-editor store. |
4227 */ |
4185 */ |
4228 |
4186 |
4229 var toggleBlockMode = actions_getBlockEditorAction('toggleBlockMode'); |
4187 const toggleBlockMode = getBlockEditorAction('toggleBlockMode'); |
4230 /** |
4188 /** |
4231 * @see startTyping in core/block-editor store. |
4189 * @see startTyping in core/block-editor store. |
4232 */ |
4190 */ |
4233 |
4191 |
4234 var startTyping = actions_getBlockEditorAction('startTyping'); |
4192 const startTyping = getBlockEditorAction('startTyping'); |
4235 /** |
4193 /** |
4236 * @see stopTyping in core/block-editor store. |
4194 * @see stopTyping in core/block-editor store. |
4237 */ |
4195 */ |
4238 |
4196 |
4239 var stopTyping = actions_getBlockEditorAction('stopTyping'); |
4197 const stopTyping = getBlockEditorAction('stopTyping'); |
4240 /** |
4198 /** |
4241 * @see enterFormattedText in core/block-editor store. |
4199 * @see enterFormattedText in core/block-editor store. |
4242 */ |
4200 */ |
4243 |
4201 |
4244 var enterFormattedText = actions_getBlockEditorAction('enterFormattedText'); |
4202 const enterFormattedText = getBlockEditorAction('enterFormattedText'); |
4245 /** |
4203 /** |
4246 * @see exitFormattedText in core/block-editor store. |
4204 * @see exitFormattedText in core/block-editor store. |
4247 */ |
4205 */ |
4248 |
4206 |
4249 var exitFormattedText = actions_getBlockEditorAction('exitFormattedText'); |
4207 const exitFormattedText = getBlockEditorAction('exitFormattedText'); |
4250 /** |
4208 /** |
4251 * @see insertDefaultBlock in core/block-editor store. |
4209 * @see insertDefaultBlock in core/block-editor store. |
4252 */ |
4210 */ |
4253 |
4211 |
4254 var insertDefaultBlock = actions_getBlockEditorAction('insertDefaultBlock'); |
4212 const actions_insertDefaultBlock = getBlockEditorAction('insertDefaultBlock'); |
4255 /** |
4213 /** |
4256 * @see updateBlockListSettings in core/block-editor store. |
4214 * @see updateBlockListSettings in core/block-editor store. |
4257 */ |
4215 */ |
4258 |
4216 |
4259 var updateBlockListSettings = actions_getBlockEditorAction('updateBlockListSettings'); |
4217 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings'); |
4260 |
|
4261 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
|
4262 var slicedToArray = __webpack_require__(14); |
|
4263 |
|
4264 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
4265 var rememo = __webpack_require__(42); |
|
4266 |
|
4267 // EXTERNAL MODULE: external {"this":["wp","date"]} |
|
4268 var external_this_wp_date_ = __webpack_require__(79); |
|
4269 |
|
4270 // EXTERNAL MODULE: external {"this":["wp","url"]} |
|
4271 var external_this_wp_url_ = __webpack_require__(31); |
|
4272 |
|
4273 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/url.js |
|
4274 /** |
|
4275 * External dependencies |
|
4276 */ |
|
4277 |
|
4278 /** |
|
4279 * WordPress dependencies |
|
4280 */ |
|
4281 |
|
4282 |
|
4283 /** |
|
4284 * Returns the URL of a WPAdmin Page. |
|
4285 * |
|
4286 * TODO: This should be moved to a module less specific to the editor. |
|
4287 * |
|
4288 * @param {string} page Page to navigate to. |
|
4289 * @param {Object} query Query Args. |
|
4290 * |
|
4291 * @return {string} WPAdmin URL. |
|
4292 */ |
|
4293 |
|
4294 function getWPAdminURL(page, query) { |
|
4295 return Object(external_this_wp_url_["addQueryArgs"])(page, query); |
|
4296 } |
|
4297 /** |
|
4298 * Performs some basic cleanup of a string for use as a post slug |
|
4299 * |
|
4300 * This replicates some of what sanitize_title() does in WordPress core, but |
|
4301 * is only designed to approximate what the slug will be. |
|
4302 * |
|
4303 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin |
|
4304 * letters. Removes combining diacritical marks. Converts whitespace, periods, |
|
4305 * and forward slashes to hyphens. Removes any remaining non-word characters |
|
4306 * except hyphens. Converts remaining string to lowercase. It does not account |
|
4307 * for octets, HTML entities, or other encoded characters. |
|
4308 * |
|
4309 * @param {string} string Title or slug to be processed |
|
4310 * |
|
4311 * @return {string} Processed string |
|
4312 */ |
|
4313 |
|
4314 function cleanForSlug(string) { |
|
4315 if (!string) { |
|
4316 return ''; |
|
4317 } |
|
4318 |
|
4319 return Object(external_this_lodash_["trim"])(Object(external_this_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-'); |
|
4320 } |
|
4321 |
|
4322 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/selectors.js |
|
4323 |
|
4324 |
|
4325 |
|
4326 function selectors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
4327 |
|
4328 function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
4329 |
|
4330 /** |
|
4331 * External dependencies |
|
4332 */ |
|
4333 |
|
4334 |
|
4335 /** |
|
4336 * WordPress dependencies |
|
4337 */ |
|
4338 |
|
4339 |
|
4340 |
|
4341 |
|
4342 |
|
4343 |
|
4344 /** |
|
4345 * Internal dependencies |
|
4346 */ |
|
4347 |
|
4348 |
|
4349 |
|
4350 |
|
4351 |
|
4352 |
|
4353 /** |
|
4354 * Shared reference to an empty object for cases where it is important to avoid |
|
4355 * returning a new object reference on every invocation, as in a connected or |
|
4356 * other pure component which performs `shouldComponentUpdate` check on props. |
|
4357 * This should be used as a last resort, since the normalized data should be |
|
4358 * maintained by the reducer result in state. |
|
4359 */ |
|
4360 |
|
4361 var EMPTY_OBJECT = {}; |
|
4362 /** |
|
4363 * Shared reference to an empty array for cases where it is important to avoid |
|
4364 * returning a new array reference on every invocation, as in a connected or |
|
4365 * other pure component which performs `shouldComponentUpdate` check on props. |
|
4366 * This should be used as a last resort, since the normalized data should be |
|
4367 * maintained by the reducer result in state. |
|
4368 */ |
|
4369 |
|
4370 var EMPTY_ARRAY = []; |
|
4371 /** |
|
4372 * Returns true if any past editor history snapshots exist, or false otherwise. |
|
4373 * |
|
4374 * @param {Object} state Global application state. |
|
4375 * |
|
4376 * @return {boolean} Whether undo history exists. |
|
4377 */ |
|
4378 |
|
4379 var hasEditorUndo = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4380 return function () { |
|
4381 return select('core').hasUndo(); |
|
4382 }; |
|
4383 }); |
|
4384 /** |
|
4385 * Returns true if any future editor history snapshots exist, or false |
|
4386 * otherwise. |
|
4387 * |
|
4388 * @param {Object} state Global application state. |
|
4389 * |
|
4390 * @return {boolean} Whether redo history exists. |
|
4391 */ |
|
4392 |
|
4393 var hasEditorRedo = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4394 return function () { |
|
4395 return select('core').hasRedo(); |
|
4396 }; |
|
4397 }); |
|
4398 /** |
|
4399 * Returns true if the currently edited post is yet to be saved, or false if |
|
4400 * the post has been saved. |
|
4401 * |
|
4402 * @param {Object} state Global application state. |
|
4403 * |
|
4404 * @return {boolean} Whether the post is new. |
|
4405 */ |
|
4406 |
|
4407 function isEditedPostNew(state) { |
|
4408 return selectors_getCurrentPost(state).status === 'auto-draft'; |
|
4409 } |
|
4410 /** |
|
4411 * Returns true if content includes unsaved changes, or false otherwise. |
|
4412 * |
|
4413 * @param {Object} state Editor state. |
|
4414 * |
|
4415 * @return {boolean} Whether content includes unsaved changes. |
|
4416 */ |
|
4417 |
|
4418 function hasChangedContent(state) { |
|
4419 var edits = selectors_getPostEdits(state); |
|
4420 return 'blocks' in edits || // `edits` is intended to contain only values which are different from |
|
4421 // the saved post, so the mere presence of a property is an indicator |
|
4422 // that the value is different than what is known to be saved. While |
|
4423 // content in Visual mode is represented by the blocks state, in Text |
|
4424 // mode it is tracked by `edits.content`. |
|
4425 'content' in edits; |
|
4426 } |
|
4427 /** |
|
4428 * Returns true if there are unsaved values for the current edit session, or |
|
4429 * false if the editing state matches the saved or new post. |
|
4430 * |
|
4431 * @param {Object} state Global application state. |
|
4432 * |
|
4433 * @return {boolean} Whether unsaved values exist. |
|
4434 */ |
|
4435 |
|
4436 var selectors_isEditedPostDirty = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4437 return function (state) { |
|
4438 // Edits should contain only fields which differ from the saved post (reset |
|
4439 // at initial load and save complete). Thus, a non-empty edits state can be |
|
4440 // inferred to contain unsaved values. |
|
4441 var postType = selectors_getCurrentPostType(state); |
|
4442 var postId = selectors_getCurrentPostId(state); |
|
4443 |
|
4444 if (select('core').hasEditsForEntityRecord('postType', postType, postId)) { |
|
4445 return true; |
|
4446 } |
|
4447 |
|
4448 return false; |
|
4449 }; |
|
4450 }); |
|
4451 /** |
|
4452 * Returns true if there are unsaved edits for entities other than |
|
4453 * the editor's post, and false otherwise. |
|
4454 * |
|
4455 * @param {Object} state Global application state. |
|
4456 * |
|
4457 * @return {boolean} Whether there are edits or not. |
|
4458 */ |
|
4459 |
|
4460 var selectors_hasNonPostEntityChanges = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4461 return function (state) { |
|
4462 var enableFullSiteEditing = selectors_getEditorSettings(state).__experimentalEnableFullSiteEditing; |
|
4463 |
|
4464 if (!enableFullSiteEditing) { |
|
4465 return false; |
|
4466 } |
|
4467 |
|
4468 var dirtyEntityRecords = select('core').__experimentalGetDirtyEntityRecords(); |
|
4469 |
|
4470 var _getCurrentPost = selectors_getCurrentPost(state), |
|
4471 type = _getCurrentPost.type, |
|
4472 id = _getCurrentPost.id; |
|
4473 |
|
4474 return Object(external_this_lodash_["some"])(dirtyEntityRecords, function (entityRecord) { |
|
4475 return entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id; |
|
4476 }); |
|
4477 }; |
|
4478 }); |
|
4479 /** |
|
4480 * Returns true if there are no unsaved values for the current edit session and |
|
4481 * if the currently edited post is new (has never been saved before). |
|
4482 * |
|
4483 * @param {Object} state Global application state. |
|
4484 * |
|
4485 * @return {boolean} Whether new post and unsaved values exist. |
|
4486 */ |
|
4487 |
|
4488 function selectors_isCleanNewPost(state) { |
|
4489 return !selectors_isEditedPostDirty(state) && isEditedPostNew(state); |
|
4490 } |
|
4491 /** |
|
4492 * Returns the post currently being edited in its last known saved state, not |
|
4493 * including unsaved edits. Returns an object containing relevant default post |
|
4494 * values if the post has not yet been saved. |
|
4495 * |
|
4496 * @param {Object} state Global application state. |
|
4497 * |
|
4498 * @return {Object} Post object. |
|
4499 */ |
|
4500 |
|
4501 var selectors_getCurrentPost = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4502 return function (state) { |
|
4503 var postId = selectors_getCurrentPostId(state); |
|
4504 var postType = selectors_getCurrentPostType(state); |
|
4505 var post = select('core').getRawEntityRecord('postType', postType, postId); |
|
4506 |
|
4507 if (post) { |
|
4508 return post; |
|
4509 } // This exists for compatibility with the previous selector behavior |
|
4510 // which would guarantee an object return based on the editor reducer's |
|
4511 // default empty object state. |
|
4512 |
|
4513 |
|
4514 return EMPTY_OBJECT; |
|
4515 }; |
|
4516 }); |
|
4517 /** |
|
4518 * Returns the post type of the post currently being edited. |
|
4519 * |
|
4520 * @param {Object} state Global application state. |
|
4521 * |
|
4522 * @return {string} Post type. |
|
4523 */ |
|
4524 |
|
4525 function selectors_getCurrentPostType(state) { |
|
4526 return state.postType; |
|
4527 } |
|
4528 /** |
|
4529 * Returns the ID of the post currently being edited, or null if the post has |
|
4530 * not yet been saved. |
|
4531 * |
|
4532 * @param {Object} state Global application state. |
|
4533 * |
|
4534 * @return {?number} ID of current post. |
|
4535 */ |
|
4536 |
|
4537 function selectors_getCurrentPostId(state) { |
|
4538 return state.postId; |
|
4539 } |
|
4540 /** |
|
4541 * Returns the number of revisions of the post currently being edited. |
|
4542 * |
|
4543 * @param {Object} state Global application state. |
|
4544 * |
|
4545 * @return {number} Number of revisions. |
|
4546 */ |
|
4547 |
|
4548 function getCurrentPostRevisionsCount(state) { |
|
4549 return Object(external_this_lodash_["get"])(selectors_getCurrentPost(state), ['_links', 'version-history', 0, 'count'], 0); |
|
4550 } |
|
4551 /** |
|
4552 * Returns the last revision ID of the post currently being edited, |
|
4553 * or null if the post has no revisions. |
|
4554 * |
|
4555 * @param {Object} state Global application state. |
|
4556 * |
|
4557 * @return {?number} ID of the last revision. |
|
4558 */ |
|
4559 |
|
4560 function getCurrentPostLastRevisionId(state) { |
|
4561 return Object(external_this_lodash_["get"])(selectors_getCurrentPost(state), ['_links', 'predecessor-version', 0, 'id'], null); |
|
4562 } |
|
4563 /** |
|
4564 * Returns any post values which have been changed in the editor but not yet |
|
4565 * been saved. |
|
4566 * |
|
4567 * @param {Object} state Global application state. |
|
4568 * |
|
4569 * @return {Object} Object of key value pairs comprising unsaved edits. |
|
4570 */ |
|
4571 |
|
4572 var selectors_getPostEdits = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4573 return function (state) { |
|
4574 var postType = selectors_getCurrentPostType(state); |
|
4575 var postId = selectors_getCurrentPostId(state); |
|
4576 return select('core').getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT; |
|
4577 }; |
|
4578 }); |
|
4579 /** |
|
4580 * Returns a new reference when edited values have changed. This is useful in |
|
4581 * inferring where an edit has been made between states by comparison of the |
|
4582 * return values using strict equality. |
|
4583 * |
|
4584 * @deprecated since Gutenberg 6.5.0. |
|
4585 * |
|
4586 * @example |
|
4587 * |
|
4588 * ``` |
|
4589 * const hasEditOccurred = ( |
|
4590 * getReferenceByDistinctEdits( beforeState ) !== |
|
4591 * getReferenceByDistinctEdits( afterState ) |
|
4592 * ); |
|
4593 * ``` |
|
4594 * |
|
4595 * @param {Object} state Editor state. |
|
4596 * |
|
4597 * @return {*} A value whose reference will change only when an edit occurs. |
|
4598 */ |
|
4599 |
|
4600 var getReferenceByDistinctEdits = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4601 return function () |
|
4602 /* state */ |
|
4603 { |
|
4604 external_this_wp_deprecated_default()("`wp.data.select( 'core/editor' ).getReferenceByDistinctEdits`", { |
|
4605 alternative: "`wp.data.select( 'core' ).getReferenceByDistinctEdits`" |
|
4606 }); |
|
4607 return select('core').getReferenceByDistinctEdits(); |
|
4608 }; |
|
4609 }); |
|
4610 /** |
|
4611 * Returns an attribute value of the saved post. |
|
4612 * |
|
4613 * @param {Object} state Global application state. |
|
4614 * @param {string} attributeName Post attribute name. |
|
4615 * |
|
4616 * @return {*} Post attribute value. |
|
4617 */ |
|
4618 |
|
4619 function selectors_getCurrentPostAttribute(state, attributeName) { |
|
4620 switch (attributeName) { |
|
4621 case 'type': |
|
4622 return selectors_getCurrentPostType(state); |
|
4623 |
|
4624 case 'id': |
|
4625 return selectors_getCurrentPostId(state); |
|
4626 |
|
4627 default: |
|
4628 var post = selectors_getCurrentPost(state); |
|
4629 |
|
4630 if (!post.hasOwnProperty(attributeName)) { |
|
4631 break; |
|
4632 } |
|
4633 |
|
4634 return getPostRawValue(post[attributeName]); |
|
4635 } |
|
4636 } |
|
4637 /** |
|
4638 * Returns a single attribute of the post being edited, preferring the unsaved |
|
4639 * edit if one exists, but merging with the attribute value for the last known |
|
4640 * saved state of the post (this is needed for some nested attributes like meta). |
|
4641 * |
|
4642 * @param {Object} state Global application state. |
|
4643 * @param {string} attributeName Post attribute name. |
|
4644 * |
|
4645 * @return {*} Post attribute value. |
|
4646 */ |
|
4647 |
|
4648 var getNestedEditedPostProperty = function getNestedEditedPostProperty(state, attributeName) { |
|
4649 var edits = selectors_getPostEdits(state); |
|
4650 |
|
4651 if (!edits.hasOwnProperty(attributeName)) { |
|
4652 return selectors_getCurrentPostAttribute(state, attributeName); |
|
4653 } |
|
4654 |
|
4655 return selectors_objectSpread({}, selectors_getCurrentPostAttribute(state, attributeName), {}, edits[attributeName]); |
|
4656 }; |
|
4657 /** |
|
4658 * Returns a single attribute of the post being edited, preferring the unsaved |
|
4659 * edit if one exists, but falling back to the attribute for the last known |
|
4660 * saved state of the post. |
|
4661 * |
|
4662 * @param {Object} state Global application state. |
|
4663 * @param {string} attributeName Post attribute name. |
|
4664 * |
|
4665 * @return {*} Post attribute value. |
|
4666 */ |
|
4667 |
|
4668 |
|
4669 function selectors_getEditedPostAttribute(state, attributeName) { |
|
4670 // Special cases |
|
4671 switch (attributeName) { |
|
4672 case 'content': |
|
4673 return getEditedPostContent(state); |
|
4674 } // Fall back to saved post value if not edited. |
|
4675 |
|
4676 |
|
4677 var edits = selectors_getPostEdits(state); |
|
4678 |
|
4679 if (!edits.hasOwnProperty(attributeName)) { |
|
4680 return selectors_getCurrentPostAttribute(state, attributeName); |
|
4681 } // Merge properties are objects which contain only the patch edit in state, |
|
4682 // and thus must be merged with the current post attribute. |
|
4683 |
|
4684 |
|
4685 if (EDIT_MERGE_PROPERTIES.has(attributeName)) { |
|
4686 return getNestedEditedPostProperty(state, attributeName); |
|
4687 } |
|
4688 |
|
4689 return edits[attributeName]; |
|
4690 } |
|
4691 /** |
|
4692 * Returns an attribute value of the current autosave revision for a post, or |
|
4693 * null if there is no autosave for the post. |
|
4694 * |
|
4695 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector |
|
4696 * from the '@wordpress/core-data' package and access properties on the returned |
|
4697 * autosave object using getPostRawValue. |
|
4698 * |
|
4699 * @param {Object} state Global application state. |
|
4700 * @param {string} attributeName Autosave attribute name. |
|
4701 * |
|
4702 * @return {*} Autosave attribute value. |
|
4703 */ |
|
4704 |
|
4705 var getAutosaveAttribute = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4706 return function (state, attributeName) { |
|
4707 if (!Object(external_this_lodash_["includes"])(AUTOSAVE_PROPERTIES, attributeName) && attributeName !== 'preview_link') { |
|
4708 return; |
|
4709 } |
|
4710 |
|
4711 var postType = selectors_getCurrentPostType(state); |
|
4712 var postId = selectors_getCurrentPostId(state); |
|
4713 var currentUserId = Object(external_this_lodash_["get"])(select('core').getCurrentUser(), ['id']); |
|
4714 var autosave = select('core').getAutosave(postType, postId, currentUserId); |
|
4715 |
|
4716 if (autosave) { |
|
4717 return getPostRawValue(autosave[attributeName]); |
|
4718 } |
|
4719 }; |
|
4720 }); |
|
4721 /** |
|
4722 * Returns the current visibility of the post being edited, preferring the |
|
4723 * unsaved value if different than the saved post. The return value is one of |
|
4724 * "private", "password", or "public". |
|
4725 * |
|
4726 * @param {Object} state Global application state. |
|
4727 * |
|
4728 * @return {string} Post visibility. |
|
4729 */ |
|
4730 |
|
4731 function selectors_getEditedPostVisibility(state) { |
|
4732 var status = selectors_getEditedPostAttribute(state, 'status'); |
|
4733 |
|
4734 if (status === 'private') { |
|
4735 return 'private'; |
|
4736 } |
|
4737 |
|
4738 var password = selectors_getEditedPostAttribute(state, 'password'); |
|
4739 |
|
4740 if (password) { |
|
4741 return 'password'; |
|
4742 } |
|
4743 |
|
4744 return 'public'; |
|
4745 } |
|
4746 /** |
|
4747 * Returns true if post is pending review. |
|
4748 * |
|
4749 * @param {Object} state Global application state. |
|
4750 * |
|
4751 * @return {boolean} Whether current post is pending review. |
|
4752 */ |
|
4753 |
|
4754 function isCurrentPostPending(state) { |
|
4755 return selectors_getCurrentPost(state).status === 'pending'; |
|
4756 } |
|
4757 /** |
|
4758 * Return true if the current post has already been published. |
|
4759 * |
|
4760 * @param {Object} state Global application state. |
|
4761 * @param {Object?} currentPost Explicit current post for bypassing registry selector. |
|
4762 * |
|
4763 * @return {boolean} Whether the post has been published. |
|
4764 */ |
|
4765 |
|
4766 function selectors_isCurrentPostPublished(state, currentPost) { |
|
4767 var post = currentPost || selectors_getCurrentPost(state); |
|
4768 return ['publish', 'private'].indexOf(post.status) !== -1 || post.status === 'future' && !Object(external_this_wp_date_["isInTheFuture"])(new Date(Number(Object(external_this_wp_date_["getDate"])(post.date)) - ONE_MINUTE_IN_MS)); |
|
4769 } |
|
4770 /** |
|
4771 * Returns true if post is already scheduled. |
|
4772 * |
|
4773 * @param {Object} state Global application state. |
|
4774 * |
|
4775 * @return {boolean} Whether current post is scheduled to be posted. |
|
4776 */ |
|
4777 |
|
4778 function selectors_isCurrentPostScheduled(state) { |
|
4779 return selectors_getCurrentPost(state).status === 'future' && !selectors_isCurrentPostPublished(state); |
|
4780 } |
|
4781 /** |
|
4782 * Return true if the post being edited can be published. |
|
4783 * |
|
4784 * @param {Object} state Global application state. |
|
4785 * |
|
4786 * @return {boolean} Whether the post can been published. |
|
4787 */ |
|
4788 |
|
4789 function selectors_isEditedPostPublishable(state) { |
|
4790 var post = selectors_getCurrentPost(state); // TODO: Post being publishable should be superset of condition of post |
|
4791 // being saveable. Currently this restriction is imposed at UI. |
|
4792 // |
|
4793 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`) |
|
4794 |
|
4795 return selectors_isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1; |
|
4796 } |
|
4797 /** |
|
4798 * Returns true if the post can be saved, or false otherwise. A post must |
|
4799 * contain a title, an excerpt, or non-empty content to be valid for save. |
|
4800 * |
|
4801 * @param {Object} state Global application state. |
|
4802 * |
|
4803 * @return {boolean} Whether the post can be saved. |
|
4804 */ |
|
4805 |
|
4806 function selectors_isEditedPostSaveable(state) { |
|
4807 if (selectors_isSavingPost(state)) { |
|
4808 return false; |
|
4809 } // TODO: Post should not be saveable if not dirty. Cannot be added here at |
|
4810 // this time since posts where meta boxes are present can be saved even if |
|
4811 // the post is not dirty. Currently this restriction is imposed at UI, but |
|
4812 // should be moved here. |
|
4813 // |
|
4814 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition) |
|
4815 // See: <PostSavedState /> (`forceIsDirty` prop) |
|
4816 // See: <PostPublishButton /> (`forceIsDirty` prop) |
|
4817 // See: https://github.com/WordPress/gutenberg/pull/4184 |
|
4818 |
|
4819 |
|
4820 return !!selectors_getEditedPostAttribute(state, 'title') || !!selectors_getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state); |
|
4821 } |
|
4822 /** |
|
4823 * Returns true if the edited post has content. A post has content if it has at |
|
4824 * least one saveable block or otherwise has a non-empty content property |
|
4825 * assigned. |
|
4826 * |
|
4827 * @param {Object} state Global application state. |
|
4828 * |
|
4829 * @return {boolean} Whether post has content. |
|
4830 */ |
|
4831 |
|
4832 function isEditedPostEmpty(state) { |
|
4833 // While the condition of truthy content string is sufficient to determine |
|
4834 // emptiness, testing saveable blocks length is a trivial operation. Since |
|
4835 // this function can be called frequently, optimize for the fast case as a |
|
4836 // condition of the mere existence of blocks. Note that the value of edited |
|
4837 // content takes precedent over block content, and must fall through to the |
|
4838 // default logic. |
|
4839 var blocks = selectors_getEditorBlocks(state); |
|
4840 |
|
4841 if (blocks.length) { |
|
4842 // Pierce the abstraction of the serializer in knowing that blocks are |
|
4843 // joined with with newlines such that even if every individual block |
|
4844 // produces an empty save result, the serialized content is non-empty. |
|
4845 if (blocks.length > 1) { |
|
4846 return false; |
|
4847 } // There are two conditions under which the optimization cannot be |
|
4848 // assumed, and a fallthrough to getEditedPostContent must occur: |
|
4849 // |
|
4850 // 1. getBlocksForSerialization has special treatment in omitting a |
|
4851 // single unmodified default block. |
|
4852 // 2. Comment delimiters are omitted for a freeform or unregistered |
|
4853 // block in its serialization. The freeform block specifically may |
|
4854 // produce an empty string in its saved output. |
|
4855 // |
|
4856 // For all other content, the single block is assumed to make a post |
|
4857 // non-empty, if only by virtue of its own comment delimiters. |
|
4858 |
|
4859 |
|
4860 var blockName = blocks[0].name; |
|
4861 |
|
4862 if (blockName !== Object(external_this_wp_blocks_["getDefaultBlockName"])() && blockName !== Object(external_this_wp_blocks_["getFreeformContentHandlerName"])()) { |
|
4863 return false; |
|
4864 } |
|
4865 } |
|
4866 |
|
4867 return !getEditedPostContent(state); |
|
4868 } |
|
4869 /** |
|
4870 * Returns true if the post can be autosaved, or false otherwise. |
|
4871 * |
|
4872 * @param {Object} state Global application state. |
|
4873 * @param {Object} autosave A raw autosave object from the REST API. |
|
4874 * |
|
4875 * @return {boolean} Whether the post can be autosaved. |
|
4876 */ |
|
4877 |
|
4878 var selectors_isEditedPostAutosaveable = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4879 return function (state) { |
|
4880 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving. |
|
4881 if (!selectors_isEditedPostSaveable(state)) { |
|
4882 return false; |
|
4883 } // A post is not autosavable when there is a post autosave lock. |
|
4884 |
|
4885 |
|
4886 if (isPostAutosavingLocked(state)) { |
|
4887 return false; |
|
4888 } |
|
4889 |
|
4890 var postType = selectors_getCurrentPostType(state); |
|
4891 var postId = selectors_getCurrentPostId(state); |
|
4892 var hasFetchedAutosave = select('core').hasFetchedAutosaves(postType, postId); |
|
4893 var currentUserId = Object(external_this_lodash_["get"])(select('core').getCurrentUser(), ['id']); // Disable reason - this line causes the side-effect of fetching the autosave |
|
4894 // via a resolver, moving below the return would result in the autosave never |
|
4895 // being fetched. |
|
4896 // eslint-disable-next-line @wordpress/no-unused-vars-before-return |
|
4897 |
|
4898 var autosave = select('core').getAutosave(postType, postId, currentUserId); // If any existing autosaves have not yet been fetched, this function is |
|
4899 // unable to determine if the post is autosaveable, so return false. |
|
4900 |
|
4901 if (!hasFetchedAutosave) { |
|
4902 return false; |
|
4903 } // If we don't already have an autosave, the post is autosaveable. |
|
4904 |
|
4905 |
|
4906 if (!autosave) { |
|
4907 return true; |
|
4908 } // To avoid an expensive content serialization, use the content dirtiness |
|
4909 // flag in place of content field comparison against the known autosave. |
|
4910 // This is not strictly accurate, and relies on a tolerance toward autosave |
|
4911 // request failures for unnecessary saves. |
|
4912 |
|
4913 |
|
4914 if (hasChangedContent(state)) { |
|
4915 return true; |
|
4916 } // If the title or excerpt has changed, the post is autosaveable. |
|
4917 |
|
4918 |
|
4919 return ['title', 'excerpt'].some(function (field) { |
|
4920 return getPostRawValue(autosave[field]) !== selectors_getEditedPostAttribute(state, field); |
|
4921 }); |
|
4922 }; |
|
4923 }); |
|
4924 /** |
|
4925 * Returns the current autosave, or null if one is not set (i.e. if the post |
|
4926 * has yet to be autosaved, or has been saved or published since the last |
|
4927 * autosave). |
|
4928 * |
|
4929 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` |
|
4930 * selector from the '@wordpress/core-data' package. |
|
4931 * |
|
4932 * @param {Object} state Editor state. |
|
4933 * |
|
4934 * @return {?Object} Current autosave, if exists. |
|
4935 */ |
|
4936 |
|
4937 var getAutosave = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4938 return function (state) { |
|
4939 external_this_wp_deprecated_default()("`wp.data.select( 'core/editor' ).getAutosave()`", { |
|
4940 alternative: "`wp.data.select( 'core' ).getAutosave( postType, postId, userId )`", |
|
4941 plugin: 'Gutenberg' |
|
4942 }); |
|
4943 var postType = selectors_getCurrentPostType(state); |
|
4944 var postId = selectors_getCurrentPostId(state); |
|
4945 var currentUserId = Object(external_this_lodash_["get"])(select('core').getCurrentUser(), ['id']); |
|
4946 var autosave = select('core').getAutosave(postType, postId, currentUserId); |
|
4947 return Object(external_this_lodash_["mapValues"])(Object(external_this_lodash_["pick"])(autosave, AUTOSAVE_PROPERTIES), getPostRawValue); |
|
4948 }; |
|
4949 }); |
|
4950 /** |
|
4951 * Returns the true if there is an existing autosave, otherwise false. |
|
4952 * |
|
4953 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector |
|
4954 * from the '@wordpress/core-data' package and check for a truthy value. |
|
4955 * |
|
4956 * @param {Object} state Global application state. |
|
4957 * |
|
4958 * @return {boolean} Whether there is an existing autosave. |
|
4959 */ |
|
4960 |
|
4961 var hasAutosave = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
4962 return function (state) { |
|
4963 external_this_wp_deprecated_default()("`wp.data.select( 'core/editor' ).hasAutosave()`", { |
|
4964 alternative: "`!! wp.data.select( 'core' ).getAutosave( postType, postId, userId )`", |
|
4965 plugin: 'Gutenberg' |
|
4966 }); |
|
4967 var postType = selectors_getCurrentPostType(state); |
|
4968 var postId = selectors_getCurrentPostId(state); |
|
4969 var currentUserId = Object(external_this_lodash_["get"])(select('core').getCurrentUser(), ['id']); |
|
4970 return !!select('core').getAutosave(postType, postId, currentUserId); |
|
4971 }; |
|
4972 }); |
|
4973 /** |
|
4974 * Return true if the post being edited is being scheduled. Preferring the |
|
4975 * unsaved status values. |
|
4976 * |
|
4977 * @param {Object} state Global application state. |
|
4978 * |
|
4979 * @return {boolean} Whether the post has been published. |
|
4980 */ |
|
4981 |
|
4982 function selectors_isEditedPostBeingScheduled(state) { |
|
4983 var date = selectors_getEditedPostAttribute(state, 'date'); // Offset the date by one minute (network latency) |
|
4984 |
|
4985 var checkedDate = new Date(Number(Object(external_this_wp_date_["getDate"])(date)) - ONE_MINUTE_IN_MS); |
|
4986 return Object(external_this_wp_date_["isInTheFuture"])(checkedDate); |
|
4987 } |
|
4988 /** |
|
4989 * Returns whether the current post should be considered to have a "floating" |
|
4990 * date (i.e. that it would publish "Immediately" rather than at a set time). |
|
4991 * |
|
4992 * Unlike in the PHP backend, the REST API returns a full date string for posts |
|
4993 * where the 0000-00-00T00:00:00 placeholder is present in the database. To |
|
4994 * infer that a post is set to publish "Immediately" we check whether the date |
|
4995 * and modified date are the same. |
|
4996 * |
|
4997 * @param {Object} state Editor state. |
|
4998 * |
|
4999 * @return {boolean} Whether the edited post has a floating date value. |
|
5000 */ |
|
5001 |
|
5002 function isEditedPostDateFloating(state) { |
|
5003 var date = selectors_getEditedPostAttribute(state, 'date'); |
|
5004 var modified = selectors_getEditedPostAttribute(state, 'modified'); |
|
5005 var status = selectors_getEditedPostAttribute(state, 'status'); |
|
5006 |
|
5007 if (status === 'draft' || status === 'auto-draft' || status === 'pending') { |
|
5008 return date === modified || date === null; |
|
5009 } |
|
5010 |
|
5011 return false; |
|
5012 } |
|
5013 /** |
|
5014 * Returns true if the post is currently being saved, or false otherwise. |
|
5015 * |
|
5016 * @param {Object} state Global application state. |
|
5017 * |
|
5018 * @return {boolean} Whether post is being saved. |
|
5019 */ |
|
5020 |
|
5021 var selectors_isSavingPost = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
5022 return function (state) { |
|
5023 var postType = selectors_getCurrentPostType(state); |
|
5024 var postId = selectors_getCurrentPostId(state); |
|
5025 return select('core').isSavingEntityRecord('postType', postType, postId); |
|
5026 }; |
|
5027 }); |
|
5028 /** |
|
5029 * Returns true if a previous post save was attempted successfully, or false |
|
5030 * otherwise. |
|
5031 * |
|
5032 * @param {Object} state Global application state. |
|
5033 * |
|
5034 * @return {boolean} Whether the post was saved successfully. |
|
5035 */ |
|
5036 |
|
5037 var didPostSaveRequestSucceed = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
5038 return function (state) { |
|
5039 var postType = selectors_getCurrentPostType(state); |
|
5040 var postId = selectors_getCurrentPostId(state); |
|
5041 return !select('core').getLastEntitySaveError('postType', postType, postId); |
|
5042 }; |
|
5043 }); |
|
5044 /** |
|
5045 * Returns true if a previous post save was attempted but failed, or false |
|
5046 * otherwise. |
|
5047 * |
|
5048 * @param {Object} state Global application state. |
|
5049 * |
|
5050 * @return {boolean} Whether the post save failed. |
|
5051 */ |
|
5052 |
|
5053 var didPostSaveRequestFail = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
5054 return function (state) { |
|
5055 var postType = selectors_getCurrentPostType(state); |
|
5056 var postId = selectors_getCurrentPostId(state); |
|
5057 return !!select('core').getLastEntitySaveError('postType', postType, postId); |
|
5058 }; |
|
5059 }); |
|
5060 /** |
|
5061 * Returns true if the post is autosaving, or false otherwise. |
|
5062 * |
|
5063 * @param {Object} state Global application state. |
|
5064 * |
|
5065 * @return {boolean} Whether the post is autosaving. |
|
5066 */ |
|
5067 |
|
5068 function selectors_isAutosavingPost(state) { |
|
5069 if (!selectors_isSavingPost(state)) { |
|
5070 return false; |
|
5071 } |
|
5072 |
|
5073 return !!Object(external_this_lodash_["get"])(state.saving, ['options', 'isAutosave']); |
|
5074 } |
|
5075 /** |
|
5076 * Returns true if the post is being previewed, or false otherwise. |
|
5077 * |
|
5078 * @param {Object} state Global application state. |
|
5079 * |
|
5080 * @return {boolean} Whether the post is being previewed. |
|
5081 */ |
|
5082 |
|
5083 function isPreviewingPost(state) { |
|
5084 if (!selectors_isSavingPost(state)) { |
|
5085 return false; |
|
5086 } |
|
5087 |
|
5088 return !!state.saving.options.isPreview; |
|
5089 } |
|
5090 /** |
|
5091 * Returns the post preview link |
|
5092 * |
|
5093 * @param {Object} state Global application state. |
|
5094 * |
|
5095 * @return {string?} Preview Link. |
|
5096 */ |
|
5097 |
|
5098 function selectors_getEditedPostPreviewLink(state) { |
|
5099 if (state.saving.pending || selectors_isSavingPost(state)) { |
|
5100 return; |
|
5101 } |
|
5102 |
|
5103 var previewLink = getAutosaveAttribute(state, 'preview_link'); |
|
5104 |
|
5105 if (!previewLink) { |
|
5106 previewLink = selectors_getEditedPostAttribute(state, 'link'); |
|
5107 |
|
5108 if (previewLink) { |
|
5109 previewLink = Object(external_this_wp_url_["addQueryArgs"])(previewLink, { |
|
5110 preview: true |
|
5111 }); |
|
5112 } |
|
5113 } |
|
5114 |
|
5115 var featuredImageId = selectors_getEditedPostAttribute(state, 'featured_media'); |
|
5116 |
|
5117 if (previewLink && featuredImageId) { |
|
5118 return Object(external_this_wp_url_["addQueryArgs"])(previewLink, { |
|
5119 _thumbnail_id: featuredImageId |
|
5120 }); |
|
5121 } |
|
5122 |
|
5123 return previewLink; |
|
5124 } |
|
5125 /** |
|
5126 * Returns a suggested post format for the current post, inferred only if there |
|
5127 * is a single block within the post and it is of a type known to match a |
|
5128 * default post format. Returns null if the format cannot be determined. |
|
5129 * |
|
5130 * @param {Object} state Global application state. |
|
5131 * |
|
5132 * @return {?string} Suggested post format. |
|
5133 */ |
|
5134 |
|
5135 function selectors_getSuggestedPostFormat(state) { |
|
5136 var blocks = selectors_getEditorBlocks(state); |
|
5137 var name; // If there is only one block in the content of the post grab its name |
|
5138 // so we can derive a suitable post format from it. |
|
5139 |
|
5140 if (blocks.length === 1) { |
|
5141 name = blocks[0].name; |
|
5142 } // If there are two blocks in the content and the last one is a text blocks |
|
5143 // grab the name of the first one to also suggest a post format from it. |
|
5144 |
|
5145 |
|
5146 if (blocks.length === 2) { |
|
5147 if (blocks[1].name === 'core/paragraph') { |
|
5148 name = blocks[0].name; |
|
5149 } |
|
5150 } // We only convert to default post formats in core. |
|
5151 |
|
5152 |
|
5153 switch (name) { |
|
5154 case 'core/image': |
|
5155 return 'image'; |
|
5156 |
|
5157 case 'core/quote': |
|
5158 case 'core/pullquote': |
|
5159 return 'quote'; |
|
5160 |
|
5161 case 'core/gallery': |
|
5162 return 'gallery'; |
|
5163 |
|
5164 case 'core/video': |
|
5165 case 'core-embed/youtube': |
|
5166 case 'core-embed/vimeo': |
|
5167 return 'video'; |
|
5168 |
|
5169 case 'core/audio': |
|
5170 case 'core-embed/spotify': |
|
5171 case 'core-embed/soundcloud': |
|
5172 return 'audio'; |
|
5173 } |
|
5174 |
|
5175 return null; |
|
5176 } |
|
5177 /** |
|
5178 * Returns a set of blocks which are to be used in consideration of the post's |
|
5179 * generated save content. |
|
5180 * |
|
5181 * @deprecated since Gutenberg 6.2.0. |
|
5182 * |
|
5183 * @param {Object} state Editor state. |
|
5184 * |
|
5185 * @return {WPBlock[]} Filtered set of blocks for save. |
|
5186 */ |
|
5187 |
|
5188 function getBlocksForSerialization(state) { |
|
5189 external_this_wp_deprecated_default()('`core/editor` getBlocksForSerialization selector', { |
|
5190 plugin: 'Gutenberg', |
|
5191 alternative: 'getEditorBlocks', |
|
5192 hint: 'Blocks serialization pre-processing occurs at save time' |
|
5193 }); |
|
5194 var blocks = state.editor.present.blocks.value; // WARNING: Any changes to the logic of this function should be verified |
|
5195 // against the implementation of isEditedPostEmpty, which bypasses this |
|
5196 // function for performance' sake, in an assumption of this current logic |
|
5197 // being irrelevant to the optimized condition of emptiness. |
|
5198 // A single unmodified default block is assumed to be equivalent to an |
|
5199 // empty post. |
|
5200 |
|
5201 var isSingleUnmodifiedDefaultBlock = blocks.length === 1 && Object(external_this_wp_blocks_["isUnmodifiedDefaultBlock"])(blocks[0]); |
|
5202 |
|
5203 if (isSingleUnmodifiedDefaultBlock) { |
|
5204 return []; |
|
5205 } |
|
5206 |
|
5207 return blocks; |
|
5208 } |
|
5209 /** |
|
5210 * Returns the content of the post being edited. |
|
5211 * |
|
5212 * @param {Object} state Global application state. |
|
5213 * |
|
5214 * @return {string} Post content. |
|
5215 */ |
|
5216 |
|
5217 var getEditedPostContent = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
5218 return function (state) { |
|
5219 var postId = selectors_getCurrentPostId(state); |
|
5220 var postType = selectors_getCurrentPostType(state); |
|
5221 var record = select('core').getEditedEntityRecord('postType', postType, postId); |
|
5222 |
|
5223 if (record) { |
|
5224 if (typeof record.content === 'function') { |
|
5225 return record.content(record); |
|
5226 } else if (record.blocks) { |
|
5227 return serialize_blocks(record.blocks); |
|
5228 } else if (record.content) { |
|
5229 return record.content; |
|
5230 } |
|
5231 } |
|
5232 |
|
5233 return ''; |
|
5234 }; |
|
5235 }); |
|
5236 /** |
|
5237 * Returns the reusable block with the given ID. |
|
5238 * |
|
5239 * @param {Object} state Global application state. |
|
5240 * @param {number|string} ref The reusable block's ID. |
|
5241 * |
|
5242 * @return {Object} The reusable block, or null if none exists. |
|
5243 */ |
|
5244 |
|
5245 var __experimentalGetReusableBlock = Object(rememo["a" /* default */])(function (state, ref) { |
|
5246 var block = state.reusableBlocks.data[ref]; |
|
5247 |
|
5248 if (!block) { |
|
5249 return null; |
|
5250 } |
|
5251 |
|
5252 var isTemporary = isNaN(parseInt(ref)); |
|
5253 return selectors_objectSpread({}, block, { |
|
5254 id: isTemporary ? ref : +ref, |
|
5255 isTemporary: isTemporary |
|
5256 }); |
|
5257 }, function (state, ref) { |
|
5258 return [state.reusableBlocks.data[ref]]; |
|
5259 }); |
|
5260 /** |
|
5261 * Returns whether or not the reusable block with the given ID is being saved. |
|
5262 * |
|
5263 * @param {Object} state Global application state. |
|
5264 * @param {string} ref The reusable block's ID. |
|
5265 * |
|
5266 * @return {boolean} Whether or not the reusable block is being saved. |
|
5267 */ |
|
5268 |
|
5269 function __experimentalIsSavingReusableBlock(state, ref) { |
|
5270 return state.reusableBlocks.isSaving[ref] || false; |
|
5271 } |
|
5272 /** |
|
5273 * Returns true if the reusable block with the given ID is being fetched, or |
|
5274 * false otherwise. |
|
5275 * |
|
5276 * @param {Object} state Global application state. |
|
5277 * @param {string} ref The reusable block's ID. |
|
5278 * |
|
5279 * @return {boolean} Whether the reusable block is being fetched. |
|
5280 */ |
|
5281 |
|
5282 function __experimentalIsFetchingReusableBlock(state, ref) { |
|
5283 return !!state.reusableBlocks.isFetching[ref]; |
|
5284 } |
|
5285 /** |
|
5286 * Returns an array of all reusable blocks. |
|
5287 * |
|
5288 * @param {Object} state Global application state. |
|
5289 * |
|
5290 * @return {Array} An array of all reusable blocks. |
|
5291 */ |
|
5292 |
|
5293 var selectors_experimentalGetReusableBlocks = Object(rememo["a" /* default */])(function (state) { |
|
5294 return Object(external_this_lodash_["map"])(state.reusableBlocks.data, function (value, ref) { |
|
5295 return __experimentalGetReusableBlock(state, ref); |
|
5296 }); |
|
5297 }, function (state) { |
|
5298 return [state.reusableBlocks.data]; |
|
5299 }); |
|
5300 /** |
|
5301 * Returns state object prior to a specified optimist transaction ID, or `null` |
|
5302 * if the transaction corresponding to the given ID cannot be found. |
|
5303 * |
|
5304 * @param {Object} state Current global application state. |
|
5305 * @param {Object} transactionId Optimist transaction ID. |
|
5306 * |
|
5307 * @return {Object} Global application state prior to transaction. |
|
5308 */ |
|
5309 |
|
5310 function getStateBeforeOptimisticTransaction(state, transactionId) { |
|
5311 var transaction = Object(external_this_lodash_["find"])(state.optimist, function (entry) { |
|
5312 return entry.beforeState && Object(external_this_lodash_["get"])(entry.action, ['optimist', 'id']) === transactionId; |
|
5313 }); |
|
5314 return transaction ? transaction.beforeState : null; |
|
5315 } |
|
5316 /** |
|
5317 * Returns true if the post is being published, or false otherwise. |
|
5318 * |
|
5319 * @param {Object} state Global application state. |
|
5320 * |
|
5321 * @return {boolean} Whether post is being published. |
|
5322 */ |
|
5323 |
|
5324 function selectors_isPublishingPost(state) { |
|
5325 if (!selectors_isSavingPost(state)) { |
|
5326 return false; |
|
5327 } // Saving is optimistic, so assume that current post would be marked as |
|
5328 // published if publishing |
|
5329 |
|
5330 |
|
5331 if (!selectors_isCurrentPostPublished(state)) { |
|
5332 return false; |
|
5333 } // Use post update transaction ID to retrieve the state prior to the |
|
5334 // optimistic transaction |
|
5335 |
|
5336 |
|
5337 var stateBeforeRequest = getStateBeforeOptimisticTransaction(state, POST_UPDATE_TRANSACTION_ID); // Consider as publishing when current post prior to request was not |
|
5338 // considered published |
|
5339 |
|
5340 return !!stateBeforeRequest && !selectors_isCurrentPostPublished(null, stateBeforeRequest.currentPost); |
|
5341 } |
|
5342 /** |
|
5343 * Returns whether the permalink is editable or not. |
|
5344 * |
|
5345 * @param {Object} state Editor state. |
|
5346 * |
|
5347 * @return {boolean} Whether or not the permalink is editable. |
|
5348 */ |
|
5349 |
|
5350 function isPermalinkEditable(state) { |
|
5351 var permalinkTemplate = selectors_getEditedPostAttribute(state, 'permalink_template'); |
|
5352 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate); |
|
5353 } |
|
5354 /** |
|
5355 * Returns the permalink for the post. |
|
5356 * |
|
5357 * @param {Object} state Editor state. |
|
5358 * |
|
5359 * @return {?string} The permalink, or null if the post is not viewable. |
|
5360 */ |
|
5361 |
|
5362 function getPermalink(state) { |
|
5363 var permalinkParts = getPermalinkParts(state); |
|
5364 |
|
5365 if (!permalinkParts) { |
|
5366 return null; |
|
5367 } |
|
5368 |
|
5369 var prefix = permalinkParts.prefix, |
|
5370 postName = permalinkParts.postName, |
|
5371 suffix = permalinkParts.suffix; |
|
5372 |
|
5373 if (isPermalinkEditable(state)) { |
|
5374 return prefix + postName + suffix; |
|
5375 } |
|
5376 |
|
5377 return prefix; |
|
5378 } |
|
5379 /** |
|
5380 * Returns the slug for the post being edited, preferring a manually edited |
|
5381 * value if one exists, then a sanitized version of the current post title, and |
|
5382 * finally the post ID. |
|
5383 * |
|
5384 * @param {Object} state Editor state. |
|
5385 * |
|
5386 * @return {string} The current slug to be displayed in the editor |
|
5387 */ |
|
5388 |
|
5389 function getEditedPostSlug(state) { |
|
5390 return selectors_getEditedPostAttribute(state, 'slug') || cleanForSlug(selectors_getEditedPostAttribute(state, 'title')) || selectors_getCurrentPostId(state); |
|
5391 } |
|
5392 /** |
|
5393 * Returns the permalink for a post, split into it's three parts: the prefix, |
|
5394 * the postName, and the suffix. |
|
5395 * |
|
5396 * @param {Object} state Editor state. |
|
5397 * |
|
5398 * @return {Object} An object containing the prefix, postName, and suffix for |
|
5399 * the permalink, or null if the post is not viewable. |
|
5400 */ |
|
5401 |
|
5402 function getPermalinkParts(state) { |
|
5403 var permalinkTemplate = selectors_getEditedPostAttribute(state, 'permalink_template'); |
|
5404 |
|
5405 if (!permalinkTemplate) { |
|
5406 return null; |
|
5407 } |
|
5408 |
|
5409 var postName = selectors_getEditedPostAttribute(state, 'slug') || selectors_getEditedPostAttribute(state, 'generated_slug'); |
|
5410 |
|
5411 var _permalinkTemplate$sp = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX), |
|
5412 _permalinkTemplate$sp2 = Object(slicedToArray["a" /* default */])(_permalinkTemplate$sp, 2), |
|
5413 prefix = _permalinkTemplate$sp2[0], |
|
5414 suffix = _permalinkTemplate$sp2[1]; |
|
5415 |
|
5416 return { |
|
5417 prefix: prefix, |
|
5418 postName: postName, |
|
5419 suffix: suffix |
|
5420 }; |
|
5421 } |
|
5422 /** |
|
5423 * Returns true if an optimistic transaction is pending commit, for which the |
|
5424 * before state satisfies the given predicate function. |
|
5425 * |
|
5426 * @param {Object} state Editor state. |
|
5427 * @param {Function} predicate Function given state, returning true if match. |
|
5428 * |
|
5429 * @return {boolean} Whether predicate matches for some history. |
|
5430 */ |
|
5431 |
|
5432 function inSomeHistory(state, predicate) { |
|
5433 var optimist = state.optimist; // In recursion, optimist state won't exist. Assume exhausted options. |
|
5434 |
|
5435 if (!optimist) { |
|
5436 return false; |
|
5437 } |
|
5438 |
|
5439 return optimist.some(function (_ref) { |
|
5440 var beforeState = _ref.beforeState; |
|
5441 return beforeState && predicate(beforeState); |
|
5442 }); |
|
5443 } |
|
5444 /** |
|
5445 * Returns whether the post is locked. |
|
5446 * |
|
5447 * @param {Object} state Global application state. |
|
5448 * |
|
5449 * @return {boolean} Is locked. |
|
5450 */ |
|
5451 |
|
5452 function isPostLocked(state) { |
|
5453 return state.postLock.isLocked; |
|
5454 } |
|
5455 /** |
|
5456 * Returns whether post saving is locked. |
|
5457 * |
|
5458 * @param {Object} state Global application state. |
|
5459 * |
|
5460 * @return {boolean} Is locked. |
|
5461 */ |
|
5462 |
|
5463 function selectors_isPostSavingLocked(state) { |
|
5464 return Object.keys(state.postSavingLock).length > 0; |
|
5465 } |
|
5466 /** |
|
5467 * Returns whether post autosaving is locked. |
|
5468 * |
|
5469 * @param {Object} state Global application state. |
|
5470 * |
|
5471 * @return {boolean} Is locked. |
|
5472 */ |
|
5473 |
|
5474 function isPostAutosavingLocked(state) { |
|
5475 return Object.keys(state.postAutosavingLock).length > 0; |
|
5476 } |
|
5477 /** |
|
5478 * Returns whether the edition of the post has been taken over. |
|
5479 * |
|
5480 * @param {Object} state Global application state. |
|
5481 * |
|
5482 * @return {boolean} Is post lock takeover. |
|
5483 */ |
|
5484 |
|
5485 function isPostLockTakeover(state) { |
|
5486 return state.postLock.isTakeover; |
|
5487 } |
|
5488 /** |
|
5489 * Returns details about the post lock user. |
|
5490 * |
|
5491 * @param {Object} state Global application state. |
|
5492 * |
|
5493 * @return {Object} A user object. |
|
5494 */ |
|
5495 |
|
5496 function getPostLockUser(state) { |
|
5497 return state.postLock.user; |
|
5498 } |
|
5499 /** |
|
5500 * Returns the active post lock. |
|
5501 * |
|
5502 * @param {Object} state Global application state. |
|
5503 * |
|
5504 * @return {Object} The lock object. |
|
5505 */ |
|
5506 |
|
5507 function getActivePostLock(state) { |
|
5508 return state.postLock.activePostLock; |
|
5509 } |
|
5510 /** |
|
5511 * Returns whether or not the user has the unfiltered_html capability. |
|
5512 * |
|
5513 * @param {Object} state Editor state. |
|
5514 * |
|
5515 * @return {boolean} Whether the user can or can't post unfiltered HTML. |
|
5516 */ |
|
5517 |
|
5518 function selectors_canUserUseUnfilteredHTML(state) { |
|
5519 return Object(external_this_lodash_["has"])(selectors_getCurrentPost(state), ['_links', 'wp:action-unfiltered-html']); |
|
5520 } |
|
5521 /** |
|
5522 * Returns whether the pre-publish panel should be shown |
|
5523 * or skipped when the user clicks the "publish" button. |
|
5524 * |
|
5525 * @param {Object} state Global application state. |
|
5526 * |
|
5527 * @return {boolean} Whether the pre-publish panel should be shown or not. |
|
5528 */ |
|
5529 |
|
5530 function selectors_isPublishSidebarEnabled(state) { |
|
5531 if (state.preferences.hasOwnProperty('isPublishSidebarEnabled')) { |
|
5532 return state.preferences.isPublishSidebarEnabled; |
|
5533 } |
|
5534 |
|
5535 return PREFERENCES_DEFAULTS.isPublishSidebarEnabled; |
|
5536 } |
|
5537 /** |
|
5538 * Return the current block list. |
|
5539 * |
|
5540 * @param {Object} state |
|
5541 * @return {Array} Block list. |
|
5542 */ |
|
5543 |
|
5544 function selectors_getEditorBlocks(state) { |
|
5545 return selectors_getEditedPostAttribute(state, 'blocks') || EMPTY_ARRAY; |
|
5546 } |
|
5547 /** |
|
5548 * A block selection object. |
|
5549 * |
|
5550 * @typedef {Object} WPBlockSelection |
|
5551 * |
|
5552 * @property {string} clientId A block client ID. |
|
5553 * @property {string} attributeKey A block attribute key. |
|
5554 * @property {number} offset An attribute value offset, based on the rich |
|
5555 * text value. See `wp.richText.create`. |
|
5556 */ |
|
5557 |
|
5558 /** |
|
5559 * Returns the current selection start. |
|
5560 * |
|
5561 * @param {Object} state |
|
5562 * @return {WPBlockSelection} The selection start. |
|
5563 */ |
|
5564 |
|
5565 function selectors_getEditorSelectionStart(state) { |
|
5566 return selectors_getEditedPostAttribute(state, 'selectionStart'); |
|
5567 } |
|
5568 /** |
|
5569 * Returns the current selection end. |
|
5570 * |
|
5571 * @param {Object} state |
|
5572 * @return {WPBlockSelection} The selection end. |
|
5573 */ |
|
5574 |
|
5575 function selectors_getEditorSelectionEnd(state) { |
|
5576 return selectors_getEditedPostAttribute(state, 'selectionEnd'); |
|
5577 } |
|
5578 /** |
|
5579 * Is the editor ready |
|
5580 * |
|
5581 * @param {Object} state |
|
5582 * @return {boolean} is Ready. |
|
5583 */ |
|
5584 |
|
5585 function __unstableIsEditorReady(state) { |
|
5586 return state.isReady; |
|
5587 } |
|
5588 /** |
|
5589 * Returns the post editor settings. |
|
5590 * |
|
5591 * @param {Object} state Editor state. |
|
5592 * |
|
5593 * @return {Object} The editor settings object. |
|
5594 */ |
|
5595 |
|
5596 function selectors_getEditorSettings(state) { |
|
5597 return state.editorSettings; |
|
5598 } |
|
5599 /* |
|
5600 * Backward compatibility |
|
5601 */ |
|
5602 |
|
5603 function getBlockEditorSelector(name) { |
|
5604 return Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
5605 return function (state) { |
|
5606 var _select; |
|
5607 |
|
5608 external_this_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', { |
|
5609 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`' |
|
5610 }); |
|
5611 |
|
5612 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
5613 args[_key - 1] = arguments[_key]; |
|
5614 } |
|
5615 |
|
5616 return (_select = select('core/block-editor'))[name].apply(_select, args); |
|
5617 }; |
|
5618 }); |
|
5619 } |
|
5620 /** |
|
5621 * @see getBlockName in core/block-editor store. |
|
5622 */ |
|
5623 |
|
5624 |
|
5625 var getBlockName = getBlockEditorSelector('getBlockName'); |
|
5626 /** |
|
5627 * @see isBlockValid in core/block-editor store. |
|
5628 */ |
|
5629 |
|
5630 var isBlockValid = getBlockEditorSelector('isBlockValid'); |
|
5631 /** |
|
5632 * @see getBlockAttributes in core/block-editor store. |
|
5633 */ |
|
5634 |
|
5635 var getBlockAttributes = getBlockEditorSelector('getBlockAttributes'); |
|
5636 /** |
|
5637 * @see getBlock in core/block-editor store. |
|
5638 */ |
|
5639 |
|
5640 var selectors_getBlock = getBlockEditorSelector('getBlock'); |
|
5641 /** |
|
5642 * @see getBlocks in core/block-editor store. |
|
5643 */ |
|
5644 |
|
5645 var selectors_getBlocks = getBlockEditorSelector('getBlocks'); |
|
5646 /** |
|
5647 * @see __unstableGetBlockWithoutInnerBlocks in core/block-editor store. |
|
5648 */ |
|
5649 |
|
5650 var __unstableGetBlockWithoutInnerBlocks = getBlockEditorSelector('__unstableGetBlockWithoutInnerBlocks'); |
|
5651 /** |
|
5652 * @see getClientIdsOfDescendants in core/block-editor store. |
|
5653 */ |
|
5654 |
|
5655 var getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants'); |
|
5656 /** |
|
5657 * @see getClientIdsWithDescendants in core/block-editor store. |
|
5658 */ |
|
5659 |
|
5660 var getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants'); |
|
5661 /** |
|
5662 * @see getGlobalBlockCount in core/block-editor store. |
|
5663 */ |
|
5664 |
|
5665 var getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount'); |
|
5666 /** |
|
5667 * @see getBlocksByClientId in core/block-editor store. |
|
5668 */ |
|
5669 |
|
5670 var selectors_getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId'); |
|
5671 /** |
|
5672 * @see getBlockCount in core/block-editor store. |
|
5673 */ |
|
5674 |
|
5675 var getBlockCount = getBlockEditorSelector('getBlockCount'); |
|
5676 /** |
|
5677 * @see getBlockSelectionStart in core/block-editor store. |
|
5678 */ |
|
5679 |
|
5680 var getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart'); |
|
5681 /** |
|
5682 * @see getBlockSelectionEnd in core/block-editor store. |
|
5683 */ |
|
5684 |
|
5685 var getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd'); |
|
5686 /** |
|
5687 * @see getSelectedBlockCount in core/block-editor store. |
|
5688 */ |
|
5689 |
|
5690 var getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount'); |
|
5691 /** |
|
5692 * @see hasSelectedBlock in core/block-editor store. |
|
5693 */ |
|
5694 |
|
5695 var hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock'); |
|
5696 /** |
|
5697 * @see getSelectedBlockClientId in core/block-editor store. |
|
5698 */ |
|
5699 |
|
5700 var getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId'); |
|
5701 /** |
|
5702 * @see getSelectedBlock in core/block-editor store. |
|
5703 */ |
|
5704 |
|
5705 var getSelectedBlock = getBlockEditorSelector('getSelectedBlock'); |
|
5706 /** |
|
5707 * @see getBlockRootClientId in core/block-editor store. |
|
5708 */ |
|
5709 |
|
5710 var getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId'); |
|
5711 /** |
|
5712 * @see getBlockHierarchyRootClientId in core/block-editor store. |
|
5713 */ |
|
5714 |
|
5715 var getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId'); |
|
5716 /** |
|
5717 * @see getAdjacentBlockClientId in core/block-editor store. |
|
5718 */ |
|
5719 |
|
5720 var getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId'); |
|
5721 /** |
|
5722 * @see getPreviousBlockClientId in core/block-editor store. |
|
5723 */ |
|
5724 |
|
5725 var getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId'); |
|
5726 /** |
|
5727 * @see getNextBlockClientId in core/block-editor store. |
|
5728 */ |
|
5729 |
|
5730 var getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId'); |
|
5731 /** |
|
5732 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store. |
|
5733 */ |
|
5734 |
|
5735 var getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition'); |
|
5736 /** |
|
5737 * @see getMultiSelectedBlockClientIds in core/block-editor store. |
|
5738 */ |
|
5739 |
|
5740 var getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds'); |
|
5741 /** |
|
5742 * @see getMultiSelectedBlocks in core/block-editor store. |
|
5743 */ |
|
5744 |
|
5745 var getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks'); |
|
5746 /** |
|
5747 * @see getFirstMultiSelectedBlockClientId in core/block-editor store. |
|
5748 */ |
|
5749 |
|
5750 var getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId'); |
|
5751 /** |
|
5752 * @see getLastMultiSelectedBlockClientId in core/block-editor store. |
|
5753 */ |
|
5754 |
|
5755 var getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId'); |
|
5756 /** |
|
5757 * @see isFirstMultiSelectedBlock in core/block-editor store. |
|
5758 */ |
|
5759 |
|
5760 var isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock'); |
|
5761 /** |
|
5762 * @see isBlockMultiSelected in core/block-editor store. |
|
5763 */ |
|
5764 |
|
5765 var isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected'); |
|
5766 /** |
|
5767 * @see isAncestorMultiSelected in core/block-editor store. |
|
5768 */ |
|
5769 |
|
5770 var isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected'); |
|
5771 /** |
|
5772 * @see getMultiSelectedBlocksStartClientId in core/block-editor store. |
|
5773 */ |
|
5774 |
|
5775 var getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId'); |
|
5776 /** |
|
5777 * @see getMultiSelectedBlocksEndClientId in core/block-editor store. |
|
5778 */ |
|
5779 |
|
5780 var getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId'); |
|
5781 /** |
|
5782 * @see getBlockOrder in core/block-editor store. |
|
5783 */ |
|
5784 |
|
5785 var getBlockOrder = getBlockEditorSelector('getBlockOrder'); |
|
5786 /** |
|
5787 * @see getBlockIndex in core/block-editor store. |
|
5788 */ |
|
5789 |
|
5790 var getBlockIndex = getBlockEditorSelector('getBlockIndex'); |
|
5791 /** |
|
5792 * @see isBlockSelected in core/block-editor store. |
|
5793 */ |
|
5794 |
|
5795 var isBlockSelected = getBlockEditorSelector('isBlockSelected'); |
|
5796 /** |
|
5797 * @see hasSelectedInnerBlock in core/block-editor store. |
|
5798 */ |
|
5799 |
|
5800 var hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock'); |
|
5801 /** |
|
5802 * @see isBlockWithinSelection in core/block-editor store. |
|
5803 */ |
|
5804 |
|
5805 var isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection'); |
|
5806 /** |
|
5807 * @see hasMultiSelection in core/block-editor store. |
|
5808 */ |
|
5809 |
|
5810 var hasMultiSelection = getBlockEditorSelector('hasMultiSelection'); |
|
5811 /** |
|
5812 * @see isMultiSelecting in core/block-editor store. |
|
5813 */ |
|
5814 |
|
5815 var isMultiSelecting = getBlockEditorSelector('isMultiSelecting'); |
|
5816 /** |
|
5817 * @see isSelectionEnabled in core/block-editor store. |
|
5818 */ |
|
5819 |
|
5820 var isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled'); |
|
5821 /** |
|
5822 * @see getBlockMode in core/block-editor store. |
|
5823 */ |
|
5824 |
|
5825 var getBlockMode = getBlockEditorSelector('getBlockMode'); |
|
5826 /** |
|
5827 * @see isTyping in core/block-editor store. |
|
5828 */ |
|
5829 |
|
5830 var isTyping = getBlockEditorSelector('isTyping'); |
|
5831 /** |
|
5832 * @see isCaretWithinFormattedText in core/block-editor store. |
|
5833 */ |
|
5834 |
|
5835 var isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText'); |
|
5836 /** |
|
5837 * @see getBlockInsertionPoint in core/block-editor store. |
|
5838 */ |
|
5839 |
|
5840 var getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint'); |
|
5841 /** |
|
5842 * @see isBlockInsertionPointVisible in core/block-editor store. |
|
5843 */ |
|
5844 |
|
5845 var isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible'); |
|
5846 /** |
|
5847 * @see isValidTemplate in core/block-editor store. |
|
5848 */ |
|
5849 |
|
5850 var isValidTemplate = getBlockEditorSelector('isValidTemplate'); |
|
5851 /** |
|
5852 * @see getTemplate in core/block-editor store. |
|
5853 */ |
|
5854 |
|
5855 var getTemplate = getBlockEditorSelector('getTemplate'); |
|
5856 /** |
|
5857 * @see getTemplateLock in core/block-editor store. |
|
5858 */ |
|
5859 |
|
5860 var getTemplateLock = getBlockEditorSelector('getTemplateLock'); |
|
5861 /** |
|
5862 * @see canInsertBlockType in core/block-editor store. |
|
5863 */ |
|
5864 |
|
5865 var selectors_canInsertBlockType = getBlockEditorSelector('canInsertBlockType'); |
|
5866 /** |
|
5867 * @see getInserterItems in core/block-editor store. |
|
5868 */ |
|
5869 |
|
5870 var getInserterItems = getBlockEditorSelector('getInserterItems'); |
|
5871 /** |
|
5872 * @see hasInserterItems in core/block-editor store. |
|
5873 */ |
|
5874 |
|
5875 var hasInserterItems = getBlockEditorSelector('hasInserterItems'); |
|
5876 /** |
|
5877 * @see getBlockListSettings in core/block-editor store. |
|
5878 */ |
|
5879 |
|
5880 var getBlockListSettings = getBlockEditorSelector('getBlockListSettings'); |
|
5881 |
|
5882 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/effects/reusable-blocks.js |
|
5883 |
|
5884 |
|
5885 |
|
5886 |
|
5887 function reusable_blocks_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
5888 |
|
5889 function reusable_blocks_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { reusable_blocks_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { reusable_blocks_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
5890 |
|
5891 /** |
|
5892 * External dependencies |
|
5893 */ |
|
5894 |
|
5895 |
|
5896 /** |
|
5897 * WordPress dependencies |
|
5898 */ |
|
5899 |
|
5900 |
|
5901 |
|
5902 // TODO: Ideally this would be the only dispatch in scope. This requires either |
|
5903 // refactoring editor actions to yielded controls, or replacing direct dispatch |
|
5904 // on the editor store with action creators (e.g. `REMOVE_REUSABLE_BLOCK`). |
|
5905 |
|
5906 |
|
5907 /** |
|
5908 * Internal dependencies |
|
5909 */ |
|
5910 |
|
5911 |
|
5912 |
|
5913 /** |
|
5914 * Module Constants |
|
5915 */ |
|
5916 |
|
5917 var REUSABLE_BLOCK_NOTICE_ID = 'REUSABLE_BLOCK_NOTICE_ID'; |
|
5918 /** |
|
5919 * Fetch Reusable blocks Effect Handler. |
|
5920 * |
|
5921 * @param {Object} action action object. |
|
5922 * @param {Object} store Redux Store. |
|
5923 */ |
|
5924 |
|
5925 var fetchReusableBlocks = /*#__PURE__*/function () { |
|
5926 var _ref = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee(action, store) { |
|
5927 var id, dispatch, postType, posts, results; |
|
5928 return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) { |
|
5929 while (1) { |
|
5930 switch (_context.prev = _context.next) { |
|
5931 case 0: |
|
5932 id = action.id; |
|
5933 dispatch = store.dispatch; // TODO: these are potentially undefined, this fix is in place |
|
5934 // until there is a filter to not use reusable blocks if undefined |
|
5935 |
|
5936 _context.next = 4; |
|
5937 return external_this_wp_apiFetch_default()({ |
|
5938 path: '/wp/v2/types/wp_block' |
|
5939 }); |
|
5940 |
|
5941 case 4: |
|
5942 postType = _context.sent; |
|
5943 |
|
5944 if (postType) { |
|
5945 _context.next = 7; |
|
5946 break; |
|
5947 } |
|
5948 |
|
5949 return _context.abrupt("return"); |
|
5950 |
|
5951 case 7: |
|
5952 _context.prev = 7; |
|
5953 |
|
5954 if (!id) { |
|
5955 _context.next = 15; |
|
5956 break; |
|
5957 } |
|
5958 |
|
5959 _context.next = 11; |
|
5960 return external_this_wp_apiFetch_default()({ |
|
5961 path: "/wp/v2/".concat(postType.rest_base, "/").concat(id) |
|
5962 }); |
|
5963 |
|
5964 case 11: |
|
5965 _context.t0 = _context.sent; |
|
5966 posts = [_context.t0]; |
|
5967 _context.next = 18; |
|
5968 break; |
|
5969 |
|
5970 case 15: |
|
5971 _context.next = 17; |
|
5972 return external_this_wp_apiFetch_default()({ |
|
5973 path: "/wp/v2/".concat(postType.rest_base, "?per_page=-1") |
|
5974 }); |
|
5975 |
|
5976 case 17: |
|
5977 posts = _context.sent; |
|
5978 |
|
5979 case 18: |
|
5980 results = Object(external_this_lodash_["compact"])(Object(external_this_lodash_["map"])(posts, function (post) { |
|
5981 if (post.status !== 'publish' || post.content.protected) { |
|
5982 return null; |
|
5983 } |
|
5984 |
|
5985 return reusable_blocks_objectSpread({}, post, { |
|
5986 content: post.content.raw, |
|
5987 title: post.title.raw |
|
5988 }); |
|
5989 })); |
|
5990 |
|
5991 if (results.length) { |
|
5992 dispatch(__experimentalReceiveReusableBlocks(results)); |
|
5993 } |
|
5994 |
|
5995 dispatch({ |
|
5996 type: 'FETCH_REUSABLE_BLOCKS_SUCCESS', |
|
5997 id: id |
|
5998 }); |
|
5999 _context.next = 26; |
|
6000 break; |
|
6001 |
|
6002 case 23: |
|
6003 _context.prev = 23; |
|
6004 _context.t1 = _context["catch"](7); |
|
6005 dispatch({ |
|
6006 type: 'FETCH_REUSABLE_BLOCKS_FAILURE', |
|
6007 id: id, |
|
6008 error: _context.t1 |
|
6009 }); |
|
6010 |
|
6011 case 26: |
|
6012 case "end": |
|
6013 return _context.stop(); |
|
6014 } |
|
6015 } |
|
6016 }, _callee, null, [[7, 23]]); |
|
6017 })); |
|
6018 |
|
6019 return function fetchReusableBlocks(_x, _x2) { |
|
6020 return _ref.apply(this, arguments); |
|
6021 }; |
|
6022 }(); |
|
6023 /** |
|
6024 * Save Reusable blocks Effect Handler. |
|
6025 * |
|
6026 * @param {Object} action action object. |
|
6027 * @param {Object} store Redux Store. |
|
6028 */ |
|
6029 |
|
6030 var saveReusableBlocks = /*#__PURE__*/function () { |
|
6031 var _ref2 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee2(action, store) { |
|
6032 var postType, id, dispatch, state, _getReusableBlock, title, content, isTemporary, data, path, method, updatedReusableBlock, message; |
|
6033 |
|
6034 return external_this_regeneratorRuntime_default.a.wrap(function _callee2$(_context2) { |
|
6035 while (1) { |
|
6036 switch (_context2.prev = _context2.next) { |
|
6037 case 0: |
|
6038 _context2.next = 2; |
|
6039 return external_this_wp_apiFetch_default()({ |
|
6040 path: '/wp/v2/types/wp_block' |
|
6041 }); |
|
6042 |
|
6043 case 2: |
|
6044 postType = _context2.sent; |
|
6045 |
|
6046 if (postType) { |
|
6047 _context2.next = 5; |
|
6048 break; |
|
6049 } |
|
6050 |
|
6051 return _context2.abrupt("return"); |
|
6052 |
|
6053 case 5: |
|
6054 id = action.id; |
|
6055 dispatch = store.dispatch; |
|
6056 state = store.getState(); |
|
6057 _getReusableBlock = __experimentalGetReusableBlock(state, id), title = _getReusableBlock.title, content = _getReusableBlock.content, isTemporary = _getReusableBlock.isTemporary; |
|
6058 data = isTemporary ? { |
|
6059 title: title, |
|
6060 content: content, |
|
6061 status: 'publish' |
|
6062 } : { |
|
6063 id: id, |
|
6064 title: title, |
|
6065 content: content, |
|
6066 status: 'publish' |
|
6067 }; |
|
6068 path = isTemporary ? "/wp/v2/".concat(postType.rest_base) : "/wp/v2/".concat(postType.rest_base, "/").concat(id); |
|
6069 method = isTemporary ? 'POST' : 'PUT'; |
|
6070 _context2.prev = 12; |
|
6071 _context2.next = 15; |
|
6072 return external_this_wp_apiFetch_default()({ |
|
6073 path: path, |
|
6074 data: data, |
|
6075 method: method |
|
6076 }); |
|
6077 |
|
6078 case 15: |
|
6079 updatedReusableBlock = _context2.sent; |
|
6080 dispatch({ |
|
6081 type: 'SAVE_REUSABLE_BLOCK_SUCCESS', |
|
6082 updatedId: updatedReusableBlock.id, |
|
6083 id: id |
|
6084 }); |
|
6085 message = isTemporary ? Object(external_this_wp_i18n_["__"])('Block created.') : Object(external_this_wp_i18n_["__"])('Block updated.'); |
|
6086 Object(external_this_wp_data_["dispatch"])('core/notices').createSuccessNotice(message, { |
|
6087 id: REUSABLE_BLOCK_NOTICE_ID, |
|
6088 type: 'snackbar' |
|
6089 }); |
|
6090 |
|
6091 Object(external_this_wp_data_["dispatch"])('core/block-editor').__unstableSaveReusableBlock(id, updatedReusableBlock.id); |
|
6092 |
|
6093 _context2.next = 26; |
|
6094 break; |
|
6095 |
|
6096 case 22: |
|
6097 _context2.prev = 22; |
|
6098 _context2.t0 = _context2["catch"](12); |
|
6099 dispatch({ |
|
6100 type: 'SAVE_REUSABLE_BLOCK_FAILURE', |
|
6101 id: id |
|
6102 }); |
|
6103 Object(external_this_wp_data_["dispatch"])('core/notices').createErrorNotice(_context2.t0.message, { |
|
6104 id: REUSABLE_BLOCK_NOTICE_ID |
|
6105 }); |
|
6106 |
|
6107 case 26: |
|
6108 case "end": |
|
6109 return _context2.stop(); |
|
6110 } |
|
6111 } |
|
6112 }, _callee2, null, [[12, 22]]); |
|
6113 })); |
|
6114 |
|
6115 return function saveReusableBlocks(_x3, _x4) { |
|
6116 return _ref2.apply(this, arguments); |
|
6117 }; |
|
6118 }(); |
|
6119 /** |
|
6120 * Delete Reusable blocks Effect Handler. |
|
6121 * |
|
6122 * @param {Object} action action object. |
|
6123 * @param {Object} store Redux Store. |
|
6124 */ |
|
6125 |
|
6126 var deleteReusableBlocks = /*#__PURE__*/function () { |
|
6127 var _ref3 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee3(action, store) { |
|
6128 var postType, id, getState, dispatch, reusableBlock, allBlocks, associatedBlocks, associatedBlockClientIds, transactionId, message; |
|
6129 return external_this_regeneratorRuntime_default.a.wrap(function _callee3$(_context3) { |
|
6130 while (1) { |
|
6131 switch (_context3.prev = _context3.next) { |
|
6132 case 0: |
|
6133 _context3.next = 2; |
|
6134 return external_this_wp_apiFetch_default()({ |
|
6135 path: '/wp/v2/types/wp_block' |
|
6136 }); |
|
6137 |
|
6138 case 2: |
|
6139 postType = _context3.sent; |
|
6140 |
|
6141 if (postType) { |
|
6142 _context3.next = 5; |
|
6143 break; |
|
6144 } |
|
6145 |
|
6146 return _context3.abrupt("return"); |
|
6147 |
|
6148 case 5: |
|
6149 id = action.id; |
|
6150 getState = store.getState, dispatch = store.dispatch; // Don't allow a reusable block with a temporary ID to be deleted |
|
6151 |
|
6152 reusableBlock = __experimentalGetReusableBlock(getState(), id); |
|
6153 |
|
6154 if (!(!reusableBlock || reusableBlock.isTemporary)) { |
|
6155 _context3.next = 10; |
|
6156 break; |
|
6157 } |
|
6158 |
|
6159 return _context3.abrupt("return"); |
|
6160 |
|
6161 case 10: |
|
6162 // Remove any other blocks that reference this reusable block |
|
6163 allBlocks = Object(external_this_wp_data_["select"])('core/block-editor').getBlocks(); |
|
6164 associatedBlocks = allBlocks.filter(function (block) { |
|
6165 return Object(external_this_wp_blocks_["isReusableBlock"])(block) && block.attributes.ref === id; |
|
6166 }); |
|
6167 associatedBlockClientIds = associatedBlocks.map(function (block) { |
|
6168 return block.clientId; |
|
6169 }); |
|
6170 transactionId = Object(external_this_lodash_["uniqueId"])(); |
|
6171 dispatch({ |
|
6172 type: 'REMOVE_REUSABLE_BLOCK', |
|
6173 id: id, |
|
6174 optimist: { |
|
6175 type: redux_optimist["BEGIN"], |
|
6176 id: transactionId |
|
6177 } |
|
6178 }); // Remove the parsed block. |
|
6179 |
|
6180 if (associatedBlockClientIds.length) { |
|
6181 Object(external_this_wp_data_["dispatch"])('core/block-editor').removeBlocks(associatedBlockClientIds); |
|
6182 } |
|
6183 |
|
6184 _context3.prev = 16; |
|
6185 _context3.next = 19; |
|
6186 return external_this_wp_apiFetch_default()({ |
|
6187 path: "/wp/v2/".concat(postType.rest_base, "/").concat(id), |
|
6188 method: 'DELETE' |
|
6189 }); |
|
6190 |
|
6191 case 19: |
|
6192 dispatch({ |
|
6193 type: 'DELETE_REUSABLE_BLOCK_SUCCESS', |
|
6194 id: id, |
|
6195 optimist: { |
|
6196 type: redux_optimist["COMMIT"], |
|
6197 id: transactionId |
|
6198 } |
|
6199 }); |
|
6200 message = Object(external_this_wp_i18n_["__"])('Block deleted.'); |
|
6201 Object(external_this_wp_data_["dispatch"])('core/notices').createSuccessNotice(message, { |
|
6202 id: REUSABLE_BLOCK_NOTICE_ID, |
|
6203 type: 'snackbar' |
|
6204 }); |
|
6205 _context3.next = 28; |
|
6206 break; |
|
6207 |
|
6208 case 24: |
|
6209 _context3.prev = 24; |
|
6210 _context3.t0 = _context3["catch"](16); |
|
6211 dispatch({ |
|
6212 type: 'DELETE_REUSABLE_BLOCK_FAILURE', |
|
6213 id: id, |
|
6214 optimist: { |
|
6215 type: redux_optimist["REVERT"], |
|
6216 id: transactionId |
|
6217 } |
|
6218 }); |
|
6219 Object(external_this_wp_data_["dispatch"])('core/notices').createErrorNotice(_context3.t0.message, { |
|
6220 id: REUSABLE_BLOCK_NOTICE_ID |
|
6221 }); |
|
6222 |
|
6223 case 28: |
|
6224 case "end": |
|
6225 return _context3.stop(); |
|
6226 } |
|
6227 } |
|
6228 }, _callee3, null, [[16, 24]]); |
|
6229 })); |
|
6230 |
|
6231 return function deleteReusableBlocks(_x5, _x6) { |
|
6232 return _ref3.apply(this, arguments); |
|
6233 }; |
|
6234 }(); |
|
6235 /** |
|
6236 * Convert a reusable block to a static block effect handler |
|
6237 * |
|
6238 * @param {Object} action action object. |
|
6239 * @param {Object} store Redux Store. |
|
6240 */ |
|
6241 |
|
6242 var reusable_blocks_convertBlockToStatic = function convertBlockToStatic(action, store) { |
|
6243 var state = store.getState(); |
|
6244 var oldBlock = Object(external_this_wp_data_["select"])('core/block-editor').getBlock(action.clientId); |
|
6245 var reusableBlock = __experimentalGetReusableBlock(state, oldBlock.attributes.ref); |
|
6246 var newBlocks = Object(external_this_wp_blocks_["parse"])(reusableBlock.content); |
|
6247 Object(external_this_wp_data_["dispatch"])('core/block-editor').replaceBlocks(oldBlock.clientId, newBlocks); |
|
6248 }; |
|
6249 /** |
|
6250 * Convert a static block to a reusable block effect handler |
|
6251 * |
|
6252 * @param {Object} action action object. |
|
6253 * @param {Object} store Redux Store. |
|
6254 */ |
|
6255 |
|
6256 var reusable_blocks_convertBlockToReusable = function convertBlockToReusable(action, store) { |
|
6257 var dispatch = store.dispatch; |
|
6258 var reusableBlock = { |
|
6259 id: Object(external_this_lodash_["uniqueId"])('reusable'), |
|
6260 title: Object(external_this_wp_i18n_["__"])('Untitled Reusable Block'), |
|
6261 content: Object(external_this_wp_blocks_["serialize"])(Object(external_this_wp_data_["select"])('core/block-editor').getBlocksByClientId(action.clientIds)) |
|
6262 }; |
|
6263 dispatch(__experimentalReceiveReusableBlocks([reusableBlock])); |
|
6264 dispatch(__experimentalSaveReusableBlock(reusableBlock.id)); |
|
6265 Object(external_this_wp_data_["dispatch"])('core/block-editor').replaceBlocks(action.clientIds, Object(external_this_wp_blocks_["createBlock"])('core/block', { |
|
6266 ref: reusableBlock.id |
|
6267 })); |
|
6268 }; |
|
6269 |
|
6270 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/effects.js |
|
6271 /** |
|
6272 * Internal dependencies |
|
6273 */ |
|
6274 |
|
6275 /* harmony default export */ var effects = ({ |
|
6276 FETCH_REUSABLE_BLOCKS: function FETCH_REUSABLE_BLOCKS(action, store) { |
|
6277 fetchReusableBlocks(action, store); |
|
6278 }, |
|
6279 SAVE_REUSABLE_BLOCK: function SAVE_REUSABLE_BLOCK(action, store) { |
|
6280 saveReusableBlocks(action, store); |
|
6281 }, |
|
6282 DELETE_REUSABLE_BLOCK: function DELETE_REUSABLE_BLOCK(action, store) { |
|
6283 deleteReusableBlocks(action, store); |
|
6284 }, |
|
6285 CONVERT_BLOCK_TO_STATIC: reusable_blocks_convertBlockToStatic, |
|
6286 CONVERT_BLOCK_TO_REUSABLE: reusable_blocks_convertBlockToReusable |
|
6287 }); |
|
6288 |
|
6289 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/middlewares.js |
|
6290 /** |
|
6291 * External dependencies |
|
6292 */ |
|
6293 |
|
6294 /** |
|
6295 * Internal dependencies |
|
6296 */ |
|
6297 |
|
6298 |
|
6299 /** |
|
6300 * Applies the custom middlewares used specifically in the editor module. |
|
6301 * |
|
6302 * @param {Object} store Store Object. |
|
6303 * |
|
6304 * @return {Object} Update Store Object. |
|
6305 */ |
|
6306 |
|
6307 function applyMiddlewares(store) { |
|
6308 var enhancedDispatch = function enhancedDispatch() { |
|
6309 throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.'); |
|
6310 }; |
|
6311 |
|
6312 var middlewareAPI = { |
|
6313 getState: store.getState, |
|
6314 dispatch: function dispatch() { |
|
6315 return enhancedDispatch.apply(void 0, arguments); |
|
6316 } |
|
6317 }; |
|
6318 enhancedDispatch = refx_default()(effects)(middlewareAPI)(store.dispatch); |
|
6319 store.dispatch = enhancedDispatch; |
|
6320 return store; |
|
6321 } |
|
6322 |
|
6323 /* harmony default export */ var middlewares = (applyMiddlewares); |
|
6324 |
4218 |
6325 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/controls.js |
4219 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/controls.js |
6326 /** |
|
6327 * WordPress dependencies |
|
6328 */ |
|
6329 |
|
6330 /** |
|
6331 * Returns a control descriptor signalling to subscribe to the registry and |
|
6332 * resolve the control promise only when the next state change occurs. |
|
6333 * |
|
6334 * @return {Object} Control descriptor. |
|
6335 */ |
|
6336 |
|
6337 function awaitNextStateChange() { |
|
6338 return { |
|
6339 type: 'AWAIT_NEXT_STATE_CHANGE' |
|
6340 }; |
|
6341 } |
|
6342 /** |
|
6343 * Returns a control descriptor signalling to resolve with the current data |
|
6344 * registry. |
|
6345 * |
|
6346 * @return {Object} Control descriptor. |
|
6347 */ |
|
6348 |
|
6349 function getRegistry() { |
|
6350 return { |
|
6351 type: 'GET_REGISTRY' |
|
6352 }; |
|
6353 } |
|
6354 /** |
4220 /** |
6355 * Function returning a sessionStorage key to set or retrieve a given post's |
4221 * Function returning a sessionStorage key to set or retrieve a given post's |
6356 * automatic session backup. |
4222 * automatic session backup. |
6357 * |
4223 * |
6358 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's |
4224 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's |
6359 * `loggedout` handler can clear sessionStorage of any user-private content. |
4225 * `loggedout` handler can clear sessionStorage of any user-private content. |
6360 * |
4226 * |
6361 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103 |
4227 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103 |
6362 * |
4228 * |
6363 * @param {string} postId Post ID. |
4229 * @param {string} postId Post ID. |
6364 * @return {string} sessionStorage key |
4230 * @param {boolean} isPostNew Whether post new. |
6365 */ |
4231 * @return {string} sessionStorage key |
6366 |
4232 */ |
6367 function postKey(postId) { |
4233 function postKey(postId, isPostNew) { |
6368 return "wp-autosave-block-editor-post-".concat(postId); |
4234 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`; |
6369 } |
4235 } |
6370 |
4236 |
6371 function localAutosaveGet(postId) { |
4237 function localAutosaveGet(postId, isPostNew) { |
6372 return window.sessionStorage.getItem(postKey(postId)); |
4238 return window.sessionStorage.getItem(postKey(postId, isPostNew)); |
6373 } |
4239 } |
6374 function localAutosaveSet(postId, title, content, excerpt) { |
4240 function localAutosaveSet(postId, isPostNew, title, content, excerpt) { |
6375 window.sessionStorage.setItem(postKey(postId), JSON.stringify({ |
4241 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({ |
6376 post_title: title, |
4242 post_title: title, |
6377 content: content, |
4243 content, |
6378 excerpt: excerpt |
4244 excerpt |
6379 })); |
4245 })); |
6380 } |
4246 } |
6381 function localAutosaveClear(postId) { |
4247 function localAutosaveClear(postId, isPostNew) { |
6382 window.sessionStorage.removeItem(postKey(postId)); |
4248 window.sessionStorage.removeItem(postKey(postId, isPostNew)); |
6383 } |
4249 } |
6384 var controls = { |
4250 const controls = { |
6385 AWAIT_NEXT_STATE_CHANGE: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
4251 LOCAL_AUTOSAVE_SET({ |
6386 return function () { |
4252 postId, |
6387 return new Promise(function (resolve) { |
4253 isPostNew, |
6388 var unsubscribe = registry.subscribe(function () { |
4254 title, |
6389 unsubscribe(); |
4255 content, |
6390 resolve(); |
4256 excerpt |
6391 }); |
4257 }) { |
6392 }); |
4258 localAutosaveSet(postId, isPostNew, title, content, excerpt); |
6393 }; |
4259 } |
6394 }), |
4260 |
6395 GET_REGISTRY: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
6396 return function () { |
|
6397 return registry; |
|
6398 }; |
|
6399 }), |
|
6400 LOCAL_AUTOSAVE_SET: function LOCAL_AUTOSAVE_SET(_ref) { |
|
6401 var postId = _ref.postId, |
|
6402 title = _ref.title, |
|
6403 content = _ref.content, |
|
6404 excerpt = _ref.excerpt; |
|
6405 localAutosaveSet(postId, title, content, excerpt); |
|
6406 } |
|
6407 }; |
4261 }; |
6408 /* harmony default export */ var store_controls = (controls); |
4262 /* harmony default export */ var store_controls = (controls); |
6409 |
4263 |
6410 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/index.js |
4264 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/index.js |
6411 |
|
6412 |
|
6413 function store_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
6414 |
|
6415 function store_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { store_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { store_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
6416 |
|
6417 /** |
4265 /** |
6418 * WordPress dependencies |
4266 * WordPress dependencies |
6419 */ |
4267 */ |
6420 |
4268 |
6421 |
4269 |
6426 |
4274 |
6427 |
4275 |
6428 |
4276 |
6429 |
4277 |
6430 |
4278 |
6431 |
|
6432 /** |
4279 /** |
6433 * Post editor data store configuration. |
4280 * Post editor data store configuration. |
6434 * |
4281 * |
6435 * @see https://github.com/WordPress/gutenberg/blob/master/packages/data/README.md#registerStore |
4282 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore |
6436 * |
4283 * |
6437 * @type {Object} |
4284 * @type {Object} |
6438 */ |
4285 */ |
6439 |
4286 |
6440 var storeConfig = { |
4287 const storeConfig = { |
6441 reducer: reducer, |
4288 reducer: reducer, |
6442 selectors: selectors_namespaceObject, |
4289 selectors: selectors_namespaceObject, |
6443 actions: actions_namespaceObject, |
4290 actions: actions_namespaceObject, |
6444 controls: store_objectSpread({}, external_this_wp_dataControls_["controls"], {}, store_controls) |
4291 controls: { ...external_wp_dataControls_["controls"], |
|
4292 ...store_controls |
|
4293 } |
6445 }; |
4294 }; |
6446 var store_store = Object(external_this_wp_data_["registerStore"])(STORE_KEY, store_objectSpread({}, storeConfig, { |
4295 /** |
|
4296 * Store definition for the editor namespace. |
|
4297 * |
|
4298 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
4299 * |
|
4300 * @type {Object} |
|
4301 */ |
|
4302 |
|
4303 const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { ...storeConfig, |
6447 persist: ['preferences'] |
4304 persist: ['preferences'] |
6448 })); |
4305 }); // Once we build a more generic persistence plugin that works across types of stores |
6449 middlewares(store_store); |
4306 // we'd be able to replace this with a register call. |
6450 /* harmony default export */ var build_module_store = (store_store); |
4307 |
6451 |
4308 Object(external_wp_data_["registerStore"])(STORE_NAME, { ...storeConfig, |
6452 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
4309 persist: ['preferences'] |
6453 var esm_extends = __webpack_require__(8); |
4310 }); |
6454 |
4311 |
6455 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js |
4312 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/index.js |
6456 var objectWithoutProperties = __webpack_require__(15); |
4313 |
6457 |
4314 |
6458 // EXTERNAL MODULE: external {"this":["wp","element"]} |
4315 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autosave-monitor/index.js |
6459 var external_this_wp_element_ = __webpack_require__(0); |
|
6460 |
|
6461 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
6462 var external_this_wp_compose_ = __webpack_require__(9); |
|
6463 |
|
6464 // EXTERNAL MODULE: external {"this":["wp","hooks"]} |
|
6465 var external_this_wp_hooks_ = __webpack_require__(32); |
|
6466 |
|
6467 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/custom-sources-backwards-compatibility.js |
|
6468 |
|
6469 |
|
6470 |
|
6471 |
|
6472 |
|
6473 |
|
6474 function custom_sources_backwards_compatibility_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
6475 |
|
6476 function custom_sources_backwards_compatibility_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { custom_sources_backwards_compatibility_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { custom_sources_backwards_compatibility_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
6477 |
|
6478 /** |
|
6479 * External dependencies |
|
6480 */ |
|
6481 |
|
6482 /** |
4316 /** |
6483 * WordPress dependencies |
4317 * WordPress dependencies |
6484 */ |
4318 */ |
6485 |
4319 |
6486 |
4320 |
6487 |
4321 |
6488 |
4322 /** |
6489 |
4323 * AutosaveMonitor invokes `props.autosave()` within at most `interval` seconds after an unsaved change is detected. |
6490 |
4324 * |
6491 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */ |
4325 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called. |
6492 |
4326 * The time between the change and the autosave varies but is no larger than `props.interval` seconds. Refer to the code below for more details, such as |
6493 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */ |
4327 * the specific way of detecting changes. |
6494 |
4328 * |
6495 /** |
4329 * There are two caveats: |
6496 * Object whose keys are the names of block attributes, where each value |
4330 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second. |
6497 * represents the meta key to which the block attribute is intended to save. |
4331 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`. |
6498 * |
4332 */ |
6499 * @see https://developer.wordpress.org/reference/functions/register_meta/ |
4333 |
6500 * |
4334 class autosave_monitor_AutosaveMonitor extends external_wp_element_["Component"] { |
6501 * @typedef {Object<string,string>} WPMetaAttributeMapping |
4335 constructor(props) { |
6502 */ |
4336 super(props); |
6503 |
4337 this.needsAutosave = !!(props.isDirty && props.isAutosaveable); |
6504 /** |
4338 } |
6505 * Given a mapping of attribute names (meta source attributes) to their |
4339 |
6506 * associated meta key, returns a higher order component that overrides its |
4340 componentDidMount() { |
6507 * `attributes` and `setAttributes` props to sync any changes with the edited |
4341 if (!this.props.disableIntervalChecks) { |
6508 * post's meta keys. |
4342 this.setAutosaveTimer(); |
6509 * |
|
6510 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping. |
|
6511 * |
|
6512 * @return {WPHigherOrderComponent} Higher-order component. |
|
6513 */ |
|
6514 |
|
6515 var custom_sources_backwards_compatibility_createWithMetaAttributeSource = function createWithMetaAttributeSource(metaAttributes) { |
|
6516 return Object(external_this_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) { |
|
6517 return function (_ref) { |
|
6518 var attributes = _ref.attributes, |
|
6519 _setAttributes = _ref.setAttributes, |
|
6520 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["attributes", "setAttributes"]); |
|
6521 |
|
6522 var postType = Object(external_this_wp_data_["useSelect"])(function (select) { |
|
6523 return select('core/editor').getCurrentPostType(); |
|
6524 }, []); |
|
6525 |
|
6526 var _useEntityProp = Object(external_this_wp_coreData_["useEntityProp"])('postType', postType, 'meta'), |
|
6527 _useEntityProp2 = Object(slicedToArray["a" /* default */])(_useEntityProp, 2), |
|
6528 meta = _useEntityProp2[0], |
|
6529 setMeta = _useEntityProp2[1]; |
|
6530 |
|
6531 var mergedAttributes = Object(external_this_wp_element_["useMemo"])(function () { |
|
6532 return custom_sources_backwards_compatibility_objectSpread({}, attributes, {}, Object(external_this_lodash_["mapValues"])(metaAttributes, function (metaKey) { |
|
6533 return meta[metaKey]; |
|
6534 })); |
|
6535 }, [attributes, meta]); |
|
6536 return Object(external_this_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({ |
|
6537 attributes: mergedAttributes, |
|
6538 setAttributes: function setAttributes(nextAttributes) { |
|
6539 var nextMeta = Object(external_this_lodash_["mapKeys"])( // Filter to intersection of keys between the updated |
|
6540 // attributes and those with an associated meta key. |
|
6541 Object(external_this_lodash_["pickBy"])(nextAttributes, function (value, key) { |
|
6542 return metaAttributes[key]; |
|
6543 }), // Rename the keys to the expected meta key name. |
|
6544 function (value, attributeKey) { |
|
6545 return metaAttributes[attributeKey]; |
|
6546 }); |
|
6547 |
|
6548 if (!Object(external_this_lodash_["isEmpty"])(nextMeta)) { |
|
6549 setMeta(nextMeta); |
|
6550 } |
|
6551 |
|
6552 _setAttributes(nextAttributes); |
|
6553 } |
|
6554 }, props)); |
|
6555 }; |
|
6556 }, 'withMetaAttributeSource'); |
|
6557 }; |
|
6558 /** |
|
6559 * Filters a registered block's settings to enhance a block's `edit` component |
|
6560 * to upgrade meta-sourced attributes to use the post's meta entity property. |
|
6561 * |
|
6562 * @param {WPBlockSettings} settings Registered block settings. |
|
6563 * |
|
6564 * @return {WPBlockSettings} Filtered block settings. |
|
6565 */ |
|
6566 |
|
6567 |
|
6568 function shimAttributeSource(settings) { |
|
6569 /** @type {WPMetaAttributeMapping} */ |
|
6570 var metaAttributes = Object(external_this_lodash_["mapValues"])(Object(external_this_lodash_["pickBy"])(settings.attributes, { |
|
6571 source: 'meta' |
|
6572 }), 'meta'); |
|
6573 |
|
6574 if (!Object(external_this_lodash_["isEmpty"])(metaAttributes)) { |
|
6575 settings.edit = custom_sources_backwards_compatibility_createWithMetaAttributeSource(metaAttributes)(settings.edit); |
|
6576 } |
|
6577 |
|
6578 return settings; |
|
6579 } |
|
6580 |
|
6581 Object(external_this_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource); // The above filter will only capture blocks registered after the filter was |
|
6582 // added. There may already be blocks registered by this point, and those must |
|
6583 // be updated to apply the shim. |
|
6584 // |
|
6585 // The following implementation achieves this, albeit with a couple caveats: |
|
6586 // - Only blocks registered on the global store will be modified. |
|
6587 // - The block settings are directly mutated, since there is currently no |
|
6588 // mechanism to update an existing block registration. This is the reason for |
|
6589 // `getBlockType` separate from `getBlockTypes`, since the latter returns a |
|
6590 // _copy_ of the block registration (i.e. the mutation would not affect the |
|
6591 // actual registered block settings). |
|
6592 // |
|
6593 // `getBlockTypes` or `getBlockType` implementation could change in the future |
|
6594 // in regards to creating settings clones, but the corresponding end-to-end |
|
6595 // tests for meta blocks should cover against any potential regressions. |
|
6596 // |
|
6597 // In the future, we could support updating block settings, at which point this |
|
6598 // implementation could use that mechanism instead. |
|
6599 |
|
6600 Object(external_this_wp_data_["select"])('core/blocks').getBlockTypes().map(function (_ref2) { |
|
6601 var name = _ref2.name; |
|
6602 return Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name); |
|
6603 }).forEach(shimAttributeSource); |
|
6604 |
|
6605 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/user.js |
|
6606 |
|
6607 |
|
6608 /** |
|
6609 * WordPress dependencies |
|
6610 */ |
|
6611 |
|
6612 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */ |
|
6613 |
|
6614 /** |
|
6615 * A user mentions completer. |
|
6616 * |
|
6617 * @type {WPCompleter} |
|
6618 */ |
|
6619 |
|
6620 /* harmony default export */ var autocompleters_user = ({ |
|
6621 name: 'users', |
|
6622 className: 'editor-autocompleters__user', |
|
6623 triggerPrefix: '@', |
|
6624 options: function options(search) { |
|
6625 var payload = ''; |
|
6626 |
|
6627 if (search) { |
|
6628 payload = '?search=' + encodeURIComponent(search); |
|
6629 } |
4343 } |
6630 |
4344 } |
6631 return external_this_wp_apiFetch_default()({ |
4345 |
6632 path: '/wp/v2/users' + payload |
4346 componentDidUpdate(prevProps) { |
6633 }); |
4347 if (this.props.disableIntervalChecks) { |
6634 }, |
4348 if (this.props.editsReference !== prevProps.editsReference) { |
6635 isDebounced: true, |
4349 this.props.autosave(); |
6636 getOptionKeywords: function getOptionKeywords(user) { |
|
6637 return [user.slug, user.name]; |
|
6638 }, |
|
6639 getOptionLabel: function getOptionLabel(user) { |
|
6640 var avatar = user.avatar_urls && user.avatar_urls[24] ? Object(external_this_wp_element_["createElement"])("img", { |
|
6641 key: "avatar", |
|
6642 className: "editor-autocompleters__user-avatar", |
|
6643 alt: "", |
|
6644 src: user.avatar_urls[24] |
|
6645 }) : Object(external_this_wp_element_["createElement"])("span", { |
|
6646 className: "editor-autocompleters__no-avatar" |
|
6647 }); |
|
6648 return [avatar, Object(external_this_wp_element_["createElement"])("span", { |
|
6649 key: "name", |
|
6650 className: "editor-autocompleters__user-name" |
|
6651 }, user.name), Object(external_this_wp_element_["createElement"])("span", { |
|
6652 key: "slug", |
|
6653 className: "editor-autocompleters__user-slug" |
|
6654 }, user.slug)]; |
|
6655 }, |
|
6656 getOptionCompletion: function getOptionCompletion(user) { |
|
6657 return "@".concat(user.slug); |
|
6658 } |
|
6659 }); |
|
6660 |
|
6661 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/default-autocompleters.js |
|
6662 /** |
|
6663 * External dependencies |
|
6664 */ |
|
6665 |
|
6666 /** |
|
6667 * WordPress dependencies |
|
6668 */ |
|
6669 |
|
6670 |
|
6671 /** |
|
6672 * Internal dependencies |
|
6673 */ |
|
6674 |
|
6675 |
|
6676 |
|
6677 function setDefaultCompleters() { |
|
6678 var completers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
6679 // Provide copies so filters may directly modify them. |
|
6680 completers.push(Object(external_this_lodash_["clone"])(autocompleters_user)); |
|
6681 return completers; |
|
6682 } |
|
6683 |
|
6684 Object(external_this_wp_hooks_["addFilter"])('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters); |
|
6685 |
|
6686 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/index.js |
|
6687 /** |
|
6688 * Internal dependencies |
|
6689 */ |
|
6690 |
|
6691 |
|
6692 |
|
6693 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/index.js |
|
6694 |
|
6695 |
|
6696 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js |
|
6697 var classCallCheck = __webpack_require__(20); |
|
6698 |
|
6699 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js |
|
6700 var createClass = __webpack_require__(19); |
|
6701 |
|
6702 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js |
|
6703 var possibleConstructorReturn = __webpack_require__(23); |
|
6704 |
|
6705 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js |
|
6706 var getPrototypeOf = __webpack_require__(16); |
|
6707 |
|
6708 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules |
|
6709 var inherits = __webpack_require__(22); |
|
6710 |
|
6711 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autosave-monitor/index.js |
|
6712 |
|
6713 |
|
6714 |
|
6715 |
|
6716 |
|
6717 |
|
6718 function _createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
6719 |
|
6720 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
6721 |
|
6722 /** |
|
6723 * WordPress dependencies |
|
6724 */ |
|
6725 |
|
6726 |
|
6727 |
|
6728 var autosave_monitor_AutosaveMonitor = /*#__PURE__*/function (_Component) { |
|
6729 Object(inherits["a" /* default */])(AutosaveMonitor, _Component); |
|
6730 |
|
6731 var _super = _createSuper(AutosaveMonitor); |
|
6732 |
|
6733 function AutosaveMonitor() { |
|
6734 Object(classCallCheck["a" /* default */])(this, AutosaveMonitor); |
|
6735 |
|
6736 return _super.apply(this, arguments); |
|
6737 } |
|
6738 |
|
6739 Object(createClass["a" /* default */])(AutosaveMonitor, [{ |
|
6740 key: "componentDidUpdate", |
|
6741 value: function componentDidUpdate(prevProps) { |
|
6742 var _this$props = this.props, |
|
6743 isDirty = _this$props.isDirty, |
|
6744 editsReference = _this$props.editsReference, |
|
6745 isAutosaveable = _this$props.isAutosaveable, |
|
6746 isAutosaving = _this$props.isAutosaving; // The edits reference is held for comparison to avoid scheduling an |
|
6747 // autosave if an edit has not been made since the last autosave |
|
6748 // completion. This is assigned when the autosave completes, and reset |
|
6749 // when an edit occurs. |
|
6750 // |
|
6751 // See: https://github.com/WordPress/gutenberg/issues/12318 |
|
6752 |
|
6753 if (editsReference !== prevProps.editsReference) { |
|
6754 this.didAutosaveForEditsReference = false; |
|
6755 } |
4350 } |
6756 |
4351 |
6757 if (!isAutosaving && prevProps.isAutosaving) { |
4352 return; |
6758 this.didAutosaveForEditsReference = true; |
|
6759 } |
|
6760 |
|
6761 if (prevProps.isDirty !== isDirty || prevProps.isAutosaveable !== isAutosaveable || prevProps.editsReference !== editsReference) { |
|
6762 this.toggleTimer(isDirty && isAutosaveable && !this.didAutosaveForEditsReference); |
|
6763 } |
|
6764 } |
4353 } |
6765 }, { |
4354 |
6766 key: "componentWillUnmount", |
4355 if (!this.props.isDirty) { |
6767 value: function componentWillUnmount() { |
4356 this.needsAutosave = false; |
6768 this.toggleTimer(false); |
4357 return; |
6769 } |
4358 } |
6770 }, { |
4359 |
6771 key: "toggleTimer", |
4360 if (this.props.isAutosaving && !prevProps.isAutosaving) { |
6772 value: function toggleTimer(isPendingSave) { |
4361 this.needsAutosave = false; |
6773 var _this = this; |
4362 return; |
6774 |
|
6775 var _this$props2 = this.props, |
|
6776 interval = _this$props2.interval, |
|
6777 _this$props2$shouldTh = _this$props2.shouldThrottle, |
|
6778 shouldThrottle = _this$props2$shouldTh === void 0 ? false : _this$props2$shouldTh; // By default, AutosaveMonitor will wait for a pause in editing before |
|
6779 // autosaving. In other words, its action is "debounced". |
|
6780 // |
|
6781 // The `shouldThrottle` props allows overriding this behaviour, thus |
|
6782 // making the autosave action "throttled". |
|
6783 |
|
6784 if (!shouldThrottle && this.pendingSave) { |
|
6785 clearTimeout(this.pendingSave); |
|
6786 delete this.pendingSave; |
|
6787 } |
|
6788 |
|
6789 if (isPendingSave && !(shouldThrottle && this.pendingSave)) { |
|
6790 this.pendingSave = setTimeout(function () { |
|
6791 _this.props.autosave(); |
|
6792 |
|
6793 delete _this.pendingSave; |
|
6794 }, interval * 1000); |
|
6795 } |
|
6796 } |
4363 } |
6797 }, { |
4364 |
6798 key: "render", |
4365 if (this.props.editsReference !== prevProps.editsReference) { |
6799 value: function render() { |
4366 this.needsAutosave = true; |
6800 return null; |
|
6801 } |
4367 } |
6802 }]); |
4368 } |
6803 |
4369 |
6804 return AutosaveMonitor; |
4370 componentWillUnmount() { |
6805 }(external_this_wp_element_["Component"]); |
4371 clearTimeout(this.timerId); |
6806 /* harmony default export */ var autosave_monitor = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
4372 } |
6807 var _select = select('core'), |
4373 |
6808 getReferenceByDistinctEdits = _select.getReferenceByDistinctEdits; |
4374 setAutosaveTimer(timeout = this.props.interval * 1000) { |
6809 |
4375 this.timerId = setTimeout(() => { |
6810 var _select2 = select('core/editor'), |
4376 this.autosaveTimerHandler(); |
6811 isEditedPostDirty = _select2.isEditedPostDirty, |
4377 }, timeout); |
6812 isEditedPostAutosaveable = _select2.isEditedPostAutosaveable, |
4378 } |
6813 isAutosavingPost = _select2.isAutosavingPost, |
4379 |
6814 getEditorSettings = _select2.getEditorSettings; |
4380 autosaveTimerHandler() { |
6815 |
4381 if (!this.props.isAutosaveable) { |
6816 var _ownProps$interval = ownProps.interval, |
4382 this.setAutosaveTimer(1000); |
6817 interval = _ownProps$interval === void 0 ? getEditorSettings().autosaveInterval : _ownProps$interval; |
4383 return; |
|
4384 } |
|
4385 |
|
4386 if (this.needsAutosave) { |
|
4387 this.needsAutosave = false; |
|
4388 this.props.autosave(); |
|
4389 } |
|
4390 |
|
4391 this.setAutosaveTimer(); |
|
4392 } |
|
4393 |
|
4394 render() { |
|
4395 return null; |
|
4396 } |
|
4397 |
|
4398 } |
|
4399 /* harmony default export */ var autosave_monitor = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])((select, ownProps) => { |
|
4400 const { |
|
4401 getReferenceByDistinctEdits |
|
4402 } = select('core'); |
|
4403 const { |
|
4404 isEditedPostDirty, |
|
4405 isEditedPostAutosaveable, |
|
4406 isAutosavingPost, |
|
4407 getEditorSettings |
|
4408 } = select('core/editor'); |
|
4409 const { |
|
4410 interval = getEditorSettings().autosaveInterval |
|
4411 } = ownProps; |
6818 return { |
4412 return { |
|
4413 editsReference: getReferenceByDistinctEdits(), |
6819 isDirty: isEditedPostDirty(), |
4414 isDirty: isEditedPostDirty(), |
6820 isAutosaveable: isEditedPostAutosaveable(), |
4415 isAutosaveable: isEditedPostAutosaveable(), |
6821 editsReference: getReferenceByDistinctEdits(), |
|
6822 isAutosaving: isAutosavingPost(), |
4416 isAutosaving: isAutosavingPost(), |
6823 interval: interval |
4417 interval |
6824 }; |
4418 }; |
6825 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps) { |
4419 }), Object(external_wp_data_["withDispatch"])((dispatch, ownProps) => ({ |
6826 return { |
4420 autosave() { |
6827 autosave: function autosave() { |
4421 const { |
6828 var _ownProps$autosave = ownProps.autosave, |
4422 autosave = dispatch('core/editor').autosave |
6829 autosave = _ownProps$autosave === void 0 ? dispatch('core/editor').autosave : _ownProps$autosave; |
4423 } = ownProps; |
6830 autosave(); |
4424 autosave(); |
6831 } |
4425 } |
6832 }; |
4426 |
6833 })])(autosave_monitor_AutosaveMonitor)); |
4427 }))])(autosave_monitor_AutosaveMonitor)); |
6834 |
4428 |
6835 // EXTERNAL MODULE: ./node_modules/classnames/index.js |
4429 // EXTERNAL MODULE: ./node_modules/classnames/index.js |
6836 var classnames = __webpack_require__(11); |
4430 var classnames = __webpack_require__("TSYQ"); |
6837 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); |
4431 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); |
6838 |
4432 |
6839 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/item.js |
4433 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/item.js |
6840 |
4434 |
6841 |
4435 |
6842 /** |
4436 /** |
6843 * External dependencies |
4437 * External dependencies |
6844 */ |
4438 */ |
6845 |
4439 |
|
4440 |
|
4441 const TableOfContentsItem = ({ |
|
4442 children, |
|
4443 isValid, |
|
4444 level, |
|
4445 href, |
|
4446 onSelect |
|
4447 }) => Object(external_wp_element_["createElement"])("li", { |
|
4448 className: classnames_default()('document-outline__item', `is-${level.toLowerCase()}`, { |
|
4449 'is-invalid': !isValid |
|
4450 }) |
|
4451 }, Object(external_wp_element_["createElement"])("a", { |
|
4452 href: href, |
|
4453 className: "document-outline__button", |
|
4454 onClick: onSelect |
|
4455 }, Object(external_wp_element_["createElement"])("span", { |
|
4456 className: "document-outline__emdash", |
|
4457 "aria-hidden": "true" |
|
4458 }), Object(external_wp_element_["createElement"])("strong", { |
|
4459 className: "document-outline__level" |
|
4460 }, level), Object(external_wp_element_["createElement"])("span", { |
|
4461 className: "document-outline__item-content" |
|
4462 }, children))); |
|
4463 |
|
4464 /* harmony default export */ var document_outline_item = (TableOfContentsItem); |
|
4465 |
|
4466 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/index.js |
|
4467 |
|
4468 |
|
4469 /** |
|
4470 * External dependencies |
|
4471 */ |
|
4472 |
6846 /** |
4473 /** |
6847 * WordPress dependencies |
4474 * WordPress dependencies |
6848 */ |
4475 */ |
6849 |
4476 |
6850 |
4477 |
6851 |
4478 |
6852 var item_TableOfContentsItem = function TableOfContentsItem(_ref) { |
|
6853 var children = _ref.children, |
|
6854 isValid = _ref.isValid, |
|
6855 level = _ref.level, |
|
6856 _ref$path = _ref.path, |
|
6857 path = _ref$path === void 0 ? [] : _ref$path, |
|
6858 href = _ref.href, |
|
6859 onSelect = _ref.onSelect; |
|
6860 return Object(external_this_wp_element_["createElement"])("li", { |
|
6861 className: classnames_default()('document-outline__item', "is-".concat(level.toLowerCase()), { |
|
6862 'is-invalid': !isValid |
|
6863 }) |
|
6864 }, Object(external_this_wp_element_["createElement"])("a", { |
|
6865 href: href, |
|
6866 className: "document-outline__button", |
|
6867 onClick: onSelect |
|
6868 }, Object(external_this_wp_element_["createElement"])("span", { |
|
6869 className: "document-outline__emdash", |
|
6870 "aria-hidden": "true" |
|
6871 }), // path is an array of nodes that are ancestors of the heading starting in the top level node. |
|
6872 // This mapping renders each ancestor to make it easier for the user to know where the headings are nested. |
|
6873 path.map(function (_ref2, index) { |
|
6874 var clientId = _ref2.clientId; |
|
6875 return Object(external_this_wp_element_["createElement"])("strong", { |
|
6876 key: index, |
|
6877 className: "document-outline__level" |
|
6878 }, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockTitle"], { |
|
6879 clientId: clientId |
|
6880 })); |
|
6881 }), Object(external_this_wp_element_["createElement"])("strong", { |
|
6882 className: "document-outline__level" |
|
6883 }, level), Object(external_this_wp_element_["createElement"])("span", { |
|
6884 className: "document-outline__item-content" |
|
6885 }, children))); |
|
6886 }; |
|
6887 |
|
6888 /* harmony default export */ var document_outline_item = (item_TableOfContentsItem); |
|
6889 |
|
6890 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/index.js |
|
6891 |
|
6892 |
|
6893 |
|
6894 |
|
6895 function document_outline_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
6896 |
|
6897 function document_outline_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { document_outline_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { document_outline_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
6898 |
|
6899 /** |
|
6900 * External dependencies |
|
6901 */ |
|
6902 |
|
6903 /** |
|
6904 * WordPress dependencies |
|
6905 */ |
|
6906 |
|
6907 |
|
6908 |
4479 |
6909 |
4480 |
6910 |
4481 |
6911 /** |
4482 /** |
6912 * Internal dependencies |
4483 * Internal dependencies |
7624 |
5169 |
7625 |
5170 |
7626 |
5171 |
7627 |
5172 |
7628 |
5173 |
|
5174 |
|
5175 |
7629 /** |
5176 /** |
7630 * Internal dependencies |
5177 * Internal dependencies |
7631 */ |
5178 */ |
7632 |
5179 |
7633 |
5180 |
7634 var ENTITY_NAMES = { |
5181 const TRANSLATED_SITE_PROTPERTIES = { |
7635 wp_template_part: function wp_template_part(number) { |
5182 title: Object(external_wp_i18n_["__"])('Title'), |
7636 return Object(external_this_wp_i18n_["_n"])('template part', 'template parts', number); |
5183 description: Object(external_wp_i18n_["__"])('Tagline'), |
7637 }, |
5184 site_logo: Object(external_wp_i18n_["__"])('Logo'), |
7638 wp_template: function wp_template(number) { |
5185 show_on_front: Object(external_wp_i18n_["__"])('Show on front'), |
7639 return Object(external_this_wp_i18n_["_n"])('template', 'templates', number); |
5186 page_on_front: Object(external_wp_i18n_["__"])('Page on front') |
7640 }, |
|
7641 post: function post(number) { |
|
7642 return Object(external_this_wp_i18n_["_n"])('post', 'posts', number); |
|
7643 }, |
|
7644 page: function page(number) { |
|
7645 return Object(external_this_wp_i18n_["_n"])('page', 'pages', number); |
|
7646 }, |
|
7647 site: function site(number) { |
|
7648 return Object(external_this_wp_i18n_["_n"])('site', 'sites', number); |
|
7649 } |
|
7650 }; |
5187 }; |
7651 var PLACEHOLDER_PHRASES = { |
5188 function EntitiesSavedStates({ |
7652 // 0 is a back up, but should never be observed. |
5189 close |
7653 0: Object(external_this_wp_i18n_["__"])('There are no changes.'), |
5190 }) { |
7654 |
5191 const saveButtonRef = Object(external_wp_element_["useRef"])(); |
7655 /* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */ |
5192 const { |
7656 1: Object(external_this_wp_i18n_["__"])('Changes have been made to your %s.'), |
5193 dirtyEntityRecords |
7657 |
5194 } = Object(external_wp_data_["useSelect"])(select => { |
7658 /* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */ |
5195 const dirtyRecords = select(external_wp_coreData_["store"]).__experimentalGetDirtyEntityRecords(); // Remove site object and decouple into its edited pieces. |
7659 2: Object(external_this_wp_i18n_["__"])('Changes have been made to your %1$s and %2$s.'), |
5196 |
7660 |
5197 |
7661 /* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */ |
5198 const dirtyRecordsWithoutSite = dirtyRecords.filter(record => !(record.kind === 'root' && record.name === 'site')); |
7662 3: Object(external_this_wp_i18n_["__"])('Changes have been made to your %1$s, %2$s, and %3$s.'), |
5199 const siteEdits = select(external_wp_coreData_["store"]).getEntityRecordEdits('root', 'site'); |
7663 |
5200 const siteEditsAsEntities = []; |
7664 /* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */ |
5201 |
7665 4: Object(external_this_wp_i18n_["__"])('Changes have been made to your %1$s, %2$s, %3$s, and %4$s.'), |
5202 for (const property in siteEdits) { |
7666 |
5203 siteEditsAsEntities.push({ |
7667 /* translators: placeholders represent pre-translated singular/plural entity names (page, post, template, site, etc.) */ |
5204 kind: 'root', |
7668 5: Object(external_this_wp_i18n_["__"])('Changes have been made to your %1$s, %2$s, %3$s, %4$s, and %5$s.') |
5205 name: 'site', |
7669 }; |
5206 title: TRANSLATED_SITE_PROTPERTIES[property] || property, |
7670 function EntitiesSavedStates(_ref) { |
5207 property |
7671 var isOpen = _ref.isOpen, |
5208 }); |
7672 close = _ref.close; |
5209 } |
7673 |
5210 |
7674 var _useSelect = Object(external_this_wp_data_["useSelect"])(function (select) { |
5211 const dirtyRecordsWithSiteItems = [...dirtyRecordsWithoutSite, ...siteEditsAsEntities]; |
7675 return { |
5212 return { |
7676 dirtyEntityRecords: select('core').__experimentalGetDirtyEntityRecords() |
5213 dirtyEntityRecords: dirtyRecordsWithSiteItems |
7677 }; |
5214 }; |
7678 }, []), |
5215 }, []); |
7679 dirtyEntityRecords = _useSelect.dirtyEntityRecords; |
5216 const { |
7680 |
5217 saveEditedEntityRecord, |
7681 var _useDispatch = Object(external_this_wp_data_["useDispatch"])('core'), |
5218 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits |
7682 saveEditedEntityRecord = _useDispatch.saveEditedEntityRecord; // To group entities by type. |
5219 } = Object(external_wp_data_["useDispatch"])(external_wp_coreData_["store"]); // To group entities by type. |
7683 |
5220 |
7684 |
5221 const partitionedSavables = Object.values(Object(external_lodash_["groupBy"])(dirtyEntityRecords, 'name')); // Unchecked entities to be ignored by save function. |
7685 var partitionedSavables = Object.values(Object(external_this_lodash_["groupBy"])(dirtyEntityRecords, 'name')); // Get labels for text-prompt phrase. |
5222 |
7686 |
5223 const [unselectedEntities, _setUnselectedEntities] = Object(external_wp_element_["useState"])([]); |
7687 var entityNamesForPrompt = []; |
5224 |
7688 partitionedSavables.forEach(function (list) { |
5225 const setUnselectedEntities = ({ |
7689 if (ENTITY_NAMES[list[0].name]) { |
5226 kind, |
7690 entityNamesForPrompt.push(ENTITY_NAMES[list[0].name](list.length)); |
5227 name, |
7691 } |
5228 key, |
7692 }); // Get text-prompt phrase based on number of entity types changed. |
5229 property |
7693 |
5230 }, checked) => { |
7694 var placeholderPhrase = PLACEHOLDER_PHRASES[entityNamesForPrompt.length] || // Fallback for edge case that should not be observed (more than 5 entity types edited). |
|
7695 Object(external_this_wp_i18n_["__"])('Changes have been made to multiple entity types.'); // eslint-disable-next-line @wordpress/valid-sprintf |
|
7696 |
|
7697 |
|
7698 var promptPhrase = external_this_wp_i18n_["sprintf"].apply(void 0, [placeholderPhrase].concat(entityNamesForPrompt)); // Unchecked entities to be ignored by save function. |
|
7699 |
|
7700 var _useState = Object(external_this_wp_element_["useState"])([]), |
|
7701 _useState2 = Object(slicedToArray["a" /* default */])(_useState, 2), |
|
7702 unselectedEntities = _useState2[0], |
|
7703 _setUnselectedEntities = _useState2[1]; |
|
7704 |
|
7705 var setUnselectedEntities = function setUnselectedEntities(_ref2, checked) { |
|
7706 var kind = _ref2.kind, |
|
7707 name = _ref2.name, |
|
7708 key = _ref2.key; |
|
7709 |
|
7710 if (checked) { |
5231 if (checked) { |
7711 _setUnselectedEntities(unselectedEntities.filter(function (elt) { |
5232 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property)); |
7712 return elt.kind !== kind || elt.name !== name || elt.key !== key; |
|
7713 })); |
|
7714 } else { |
5233 } else { |
7715 _setUnselectedEntities([].concat(Object(toConsumableArray["a" /* default */])(unselectedEntities), [{ |
5234 _setUnselectedEntities([...unselectedEntities, { |
7716 kind: kind, |
5235 kind, |
7717 name: name, |
5236 name, |
7718 key: key |
5237 key, |
7719 }])); |
5238 property |
|
5239 }]); |
7720 } |
5240 } |
7721 }; |
5241 }; |
7722 |
5242 |
7723 var saveCheckedEntities = function saveCheckedEntities() { |
5243 const saveCheckedEntities = () => { |
7724 var entitiesToSave = dirtyEntityRecords.filter(function (_ref3) { |
5244 const entitiesToSave = dirtyEntityRecords.filter(({ |
7725 var kind = _ref3.kind, |
5245 kind, |
7726 name = _ref3.name, |
5246 name, |
7727 key = _ref3.key; |
5247 key, |
7728 return !Object(external_this_lodash_["some"])(unselectedEntities, function (elt) { |
5248 property |
7729 return elt.kind === kind && elt.name === name && elt.key === key; |
5249 }) => { |
7730 }); |
5250 return !Object(external_lodash_["some"])(unselectedEntities, elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property); |
7731 }); |
5251 }); |
7732 close(entitiesToSave); |
5252 close(entitiesToSave); |
7733 entitiesToSave.forEach(function (_ref4) { |
5253 const siteItemsToSave = []; |
7734 var kind = _ref4.kind, |
5254 entitiesToSave.forEach(({ |
7735 name = _ref4.name, |
5255 kind, |
7736 key = _ref4.key; |
5256 name, |
7737 saveEditedEntityRecord(kind, name, key); |
5257 key, |
|
5258 property |
|
5259 }) => { |
|
5260 if ('root' === kind && 'site' === name) { |
|
5261 siteItemsToSave.push(property); |
|
5262 } else { |
|
5263 saveEditedEntityRecord(kind, name, key); |
|
5264 } |
7738 }); |
5265 }); |
7739 }; |
5266 saveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave); |
7740 |
|
7741 var _useState3 = Object(external_this_wp_element_["useState"])(false), |
|
7742 _useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2), |
|
7743 isReviewing = _useState4[0], |
|
7744 setIsReviewing = _useState4[1]; |
|
7745 |
|
7746 var toggleIsReviewing = function toggleIsReviewing() { |
|
7747 return setIsReviewing(function (value) { |
|
7748 return !value; |
|
7749 }); |
|
7750 }; // Explicitly define this with no argument passed. Using `close` on |
5267 }; // Explicitly define this with no argument passed. Using `close` on |
7751 // its own will use the event object in place of the expected saved entities. |
5268 // its own will use the event object in place of the expected saved entities. |
7752 |
5269 |
7753 |
5270 |
7754 var dismissPanel = Object(external_this_wp_element_["useCallback"])(function () { |
5271 const dismissPanel = Object(external_wp_element_["useCallback"])(() => close(), [close]); |
7755 return close(); |
5272 const [saveDialogRef, saveDialogProps] = Object(external_wp_compose_["__experimentalUseDialog"])({ |
7756 }, [close]); |
5273 onClose: () => dismissPanel() |
7757 return isOpen ? Object(external_this_wp_element_["createElement"])("div", { |
5274 }); |
|
5275 return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({ |
|
5276 ref: saveDialogRef |
|
5277 }, saveDialogProps, { |
7758 className: "entities-saved-states__panel" |
5278 className: "entities-saved-states__panel" |
7759 }, Object(external_this_wp_element_["createElement"])("div", { |
5279 }), Object(external_wp_element_["createElement"])("div", { |
7760 className: "entities-saved-states__panel-header" |
5280 className: "entities-saved-states__panel-header" |
7761 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
5281 }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
5282 ref: saveButtonRef, |
7762 isPrimary: true, |
5283 isPrimary: true, |
7763 disabled: dirtyEntityRecords.length - unselectedEntities.length === 0, |
5284 disabled: dirtyEntityRecords.length - unselectedEntities.length === 0, |
7764 onClick: saveCheckedEntities, |
5285 onClick: saveCheckedEntities, |
7765 className: "editor-entities-saved-states__save-button" |
5286 className: "editor-entities-saved-states__save-button" |
7766 }, Object(external_this_wp_i18n_["__"])('Save')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
5287 }, Object(external_wp_i18n_["__"])('Save')), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
5288 icon: library_close["a" /* default */], |
7767 onClick: dismissPanel, |
5289 onClick: dismissPanel, |
7768 icon: library_close["a" /* default */], |
5290 label: Object(external_wp_i18n_["__"])('Close panel') |
7769 label: Object(external_this_wp_i18n_["__"])('Close panel') |
5291 })), Object(external_wp_element_["createElement"])("div", { |
7770 })), Object(external_this_wp_element_["createElement"])("div", { |
|
7771 className: "entities-saved-states__text-prompt" |
5292 className: "entities-saved-states__text-prompt" |
7772 }, Object(external_this_wp_element_["createElement"])("strong", null, Object(external_this_wp_i18n_["__"])('Are you ready to save?')), Object(external_this_wp_element_["createElement"])("p", null, promptPhrase), Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
5293 }, Object(external_wp_element_["createElement"])("strong", null, Object(external_wp_i18n_["__"])('Select the changes you want to save')), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_i18n_["__"])('Some changes may affect other areas of your site.'))), partitionedSavables.map(list => { |
7773 onClick: toggleIsReviewing, |
5294 return Object(external_wp_element_["createElement"])(EntityTypeList, { |
7774 isLink: true, |
|
7775 className: "entities-saved-states__review-changes-button" |
|
7776 }, isReviewing ? Object(external_this_wp_i18n_["__"])('Hide changes.') : Object(external_this_wp_i18n_["__"])('Review changes.')))), isReviewing && partitionedSavables.map(function (list) { |
|
7777 return Object(external_this_wp_element_["createElement"])(EntityTypeList, { |
|
7778 key: list[0].name, |
5295 key: list[0].name, |
7779 list: list, |
5296 list: list, |
7780 closePanel: dismissPanel, |
5297 closePanel: dismissPanel, |
7781 unselectedEntities: unselectedEntities, |
5298 unselectedEntities: unselectedEntities, |
7782 setUnselectedEntities: setUnselectedEntities |
5299 setUnselectedEntities: setUnselectedEntities |
7783 }); |
5300 }); |
7784 })) : null; |
5301 })); |
7785 } |
5302 } |
7786 |
|
7787 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js |
|
7788 var assertThisInitialized = __webpack_require__(12); |
|
7789 |
5303 |
7790 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/error-boundary/index.js |
5304 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/error-boundary/index.js |
7791 |
5305 |
7792 |
5306 |
7793 |
|
7794 |
|
7795 |
|
7796 |
|
7797 |
|
7798 |
|
7799 function error_boundary_createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (error_boundary_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
7800 |
|
7801 function error_boundary_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
7802 |
|
7803 /** |
5307 /** |
7804 * WordPress dependencies |
5308 * WordPress dependencies |
7805 */ |
5309 */ |
7806 |
5310 |
7807 |
5311 |
7808 |
5312 |
7809 |
5313 |
7810 |
5314 |
7811 |
5315 |
7812 var error_boundary_ErrorBoundary = /*#__PURE__*/function (_Component) { |
5316 |
7813 Object(inherits["a" /* default */])(ErrorBoundary, _Component); |
5317 function CopyButton({ |
7814 |
5318 text, |
7815 var _super = error_boundary_createSuper(ErrorBoundary); |
5319 children |
7816 |
5320 }) { |
7817 function ErrorBoundary() { |
5321 const ref = Object(external_wp_compose_["useCopyToClipboard"])(text); |
7818 var _this; |
5322 return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
7819 |
5323 isSecondary: true, |
7820 Object(classCallCheck["a" /* default */])(this, ErrorBoundary); |
5324 ref: ref |
7821 |
5325 }, children); |
7822 _this = _super.apply(this, arguments); |
5326 } |
7823 _this.reboot = _this.reboot.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
5327 |
7824 _this.getContent = _this.getContent.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
5328 class error_boundary_ErrorBoundary extends external_wp_element_["Component"] { |
7825 _this.state = { |
5329 constructor() { |
|
5330 super(...arguments); |
|
5331 this.reboot = this.reboot.bind(this); |
|
5332 this.getContent = this.getContent.bind(this); |
|
5333 this.state = { |
7826 error: null |
5334 error: null |
7827 }; |
5335 }; |
7828 return _this; |
5336 } |
7829 } |
5337 |
7830 |
5338 componentDidCatch(error) { |
7831 Object(createClass["a" /* default */])(ErrorBoundary, [{ |
5339 this.setState({ |
7832 key: "componentDidCatch", |
5340 error |
7833 value: function componentDidCatch(error) { |
5341 }); |
7834 this.setState({ |
5342 } |
7835 error: error |
5343 |
7836 }); |
5344 reboot() { |
|
5345 this.props.onError(); |
|
5346 } |
|
5347 |
|
5348 getContent() { |
|
5349 try { |
|
5350 // While `select` in a component is generally discouraged, it is |
|
5351 // used here because it (a) reduces the chance of data loss in the |
|
5352 // case of additional errors by performing a direct retrieval and |
|
5353 // (b) avoids the performance cost associated with unnecessary |
|
5354 // content serialization throughout the lifetime of a non-erroring |
|
5355 // application. |
|
5356 return Object(external_wp_data_["select"])('core/editor').getEditedPostContent(); |
|
5357 } catch (error) {} |
|
5358 } |
|
5359 |
|
5360 render() { |
|
5361 const { |
|
5362 error |
|
5363 } = this.state; |
|
5364 |
|
5365 if (!error) { |
|
5366 return this.props.children; |
7837 } |
5367 } |
7838 }, { |
5368 |
7839 key: "reboot", |
5369 return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["Warning"], { |
7840 value: function reboot() { |
5370 className: "editor-error-boundary", |
7841 this.props.onError(); |
5371 actions: [Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
7842 } |
5372 key: "recovery", |
7843 }, { |
5373 onClick: this.reboot, |
7844 key: "getContent", |
5374 isSecondary: true |
7845 value: function getContent() { |
5375 }, Object(external_wp_i18n_["__"])('Attempt Recovery')), Object(external_wp_element_["createElement"])(CopyButton, { |
7846 try { |
5376 key: "copy-post", |
7847 // While `select` in a component is generally discouraged, it is |
5377 text: this.getContent |
7848 // used here because it (a) reduces the chance of data loss in the |
5378 }, Object(external_wp_i18n_["__"])('Copy Post Text')), Object(external_wp_element_["createElement"])(CopyButton, { |
7849 // case of additional errors by performing a direct retrieval and |
5379 key: "copy-error", |
7850 // (b) avoids the performance cost associated with unnecessary |
5380 text: error.stack |
7851 // content serialization throughout the lifetime of a non-erroring |
5381 }, Object(external_wp_i18n_["__"])('Copy Error'))] |
7852 // application. |
5382 }, Object(external_wp_i18n_["__"])('The editor has encountered an unexpected error.')); |
7853 return Object(external_this_wp_data_["select"])('core/editor').getEditedPostContent(); |
5383 } |
7854 } catch (error) {} |
5384 |
7855 } |
5385 } |
7856 }, { |
|
7857 key: "render", |
|
7858 value: function render() { |
|
7859 var error = this.state.error; |
|
7860 |
|
7861 if (!error) { |
|
7862 return this.props.children; |
|
7863 } |
|
7864 |
|
7865 return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["Warning"], { |
|
7866 className: "editor-error-boundary", |
|
7867 actions: [Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
7868 key: "recovery", |
|
7869 onClick: this.reboot, |
|
7870 isSecondary: true |
|
7871 }, Object(external_this_wp_i18n_["__"])('Attempt Recovery')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ClipboardButton"], { |
|
7872 key: "copy-post", |
|
7873 text: this.getContent, |
|
7874 isSecondary: true |
|
7875 }, Object(external_this_wp_i18n_["__"])('Copy Post Text')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ClipboardButton"], { |
|
7876 key: "copy-error", |
|
7877 text: error.stack, |
|
7878 isSecondary: true |
|
7879 }, Object(external_this_wp_i18n_["__"])('Copy Error'))] |
|
7880 }, Object(external_this_wp_i18n_["__"])('The editor has encountered an unexpected error.')); |
|
7881 } |
|
7882 }]); |
|
7883 |
|
7884 return ErrorBoundary; |
|
7885 }(external_this_wp_element_["Component"]); |
|
7886 |
5386 |
7887 /* harmony default export */ var error_boundary = (error_boundary_ErrorBoundary); |
5387 /* harmony default export */ var error_boundary = (error_boundary_ErrorBoundary); |
7888 |
5388 |
7889 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/local-autosave-monitor/index.js |
5389 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/local-autosave-monitor/index.js |
7890 |
5390 |
8175 /** |
5685 /** |
8176 * Internal dependencies |
5686 * Internal dependencies |
8177 */ |
5687 */ |
8178 |
5688 |
8179 |
5689 |
8180 var PageAttributesOrder = Object(external_this_wp_compose_["withState"])({ |
5690 const PageAttributesOrder = Object(external_wp_compose_["withState"])({ |
8181 orderInput: null |
5691 orderInput: null |
8182 })(function (_ref) { |
5692 })(({ |
8183 var onUpdateOrder = _ref.onUpdateOrder, |
5693 onUpdateOrder, |
8184 _ref$order = _ref.order, |
5694 order = 0, |
8185 order = _ref$order === void 0 ? 0 : _ref$order, |
5695 orderInput, |
8186 orderInput = _ref.orderInput, |
5696 setState |
8187 setState = _ref.setState; |
5697 }) => { |
8188 |
5698 const setUpdatedOrder = value => { |
8189 var setUpdatedOrder = function setUpdatedOrder(value) { |
|
8190 setState({ |
5699 setState({ |
8191 orderInput: value |
5700 orderInput: value |
8192 }); |
5701 }); |
8193 var newOrder = Number(value); |
5702 const newOrder = Number(value); |
8194 |
5703 |
8195 if (Number.isInteger(newOrder) && Object(external_this_lodash_["invoke"])(value, ['trim']) !== '') { |
5704 if (Number.isInteger(newOrder) && Object(external_lodash_["invoke"])(value, ['trim']) !== '') { |
8196 onUpdateOrder(Number(value)); |
5705 onUpdateOrder(Number(value)); |
8197 } |
5706 } |
8198 }; |
5707 }; |
8199 |
5708 |
8200 var value = orderInput === null ? order : orderInput; |
5709 const value = orderInput === null ? order : orderInput; |
8201 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextControl"], { |
5710 return Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], { |
8202 className: "editor-page-attributes__order", |
5711 className: "editor-page-attributes__order", |
8203 type: "number", |
5712 type: "number", |
8204 label: Object(external_this_wp_i18n_["__"])('Order'), |
5713 label: Object(external_wp_i18n_["__"])('Order'), |
8205 value: value, |
5714 value: value, |
8206 onChange: setUpdatedOrder, |
5715 onChange: setUpdatedOrder, |
8207 size: 6, |
5716 size: 6, |
8208 onBlur: function onBlur() { |
5717 onBlur: () => { |
8209 setState({ |
5718 setState({ |
8210 orderInput: null |
5719 orderInput: null |
8211 }); |
5720 }); |
8212 } |
5721 } |
8213 }); |
5722 }); |
8214 }); |
5723 }); |
8215 |
5724 |
8216 function PageAttributesOrderWithChecks(props) { |
5725 function PageAttributesOrderWithChecks(props) { |
8217 return Object(external_this_wp_element_["createElement"])(post_type_support_check, { |
5726 return Object(external_wp_element_["createElement"])(post_type_support_check, { |
8218 supportKeys: "page-attributes" |
5727 supportKeys: "page-attributes" |
8219 }, Object(external_this_wp_element_["createElement"])(PageAttributesOrder, props)); |
5728 }, Object(external_wp_element_["createElement"])(PageAttributesOrder, props)); |
8220 } |
5729 } |
8221 |
5730 |
8222 /* harmony default export */ var page_attributes_order = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
5731 /* harmony default export */ var page_attributes_order = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(select => { |
8223 return { |
5732 return { |
8224 order: select('core/editor').getEditedPostAttribute('menu_order') |
5733 order: select('core/editor').getEditedPostAttribute('menu_order') |
8225 }; |
5734 }; |
8226 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
5735 }), Object(external_wp_data_["withDispatch"])(dispatch => ({ |
8227 return { |
5736 onUpdateOrder(order) { |
8228 onUpdateOrder: function onUpdateOrder(order) { |
5737 dispatch('core/editor').editPost({ |
8229 dispatch('core/editor').editPost({ |
5738 menu_order: order |
8230 menu_order: order |
5739 }); |
|
5740 } |
|
5741 |
|
5742 }))])(PageAttributesOrderWithChecks)); |
|
5743 |
|
5744 // EXTERNAL MODULE: external ["wp","htmlEntities"] |
|
5745 var external_wp_htmlEntities_ = __webpack_require__("rmEH"); |
|
5746 |
|
5747 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/terms.js |
|
5748 /** |
|
5749 * External dependencies |
|
5750 */ |
|
5751 |
|
5752 /** |
|
5753 * Returns terms in a tree form. |
|
5754 * |
|
5755 * @param {Array} flatTerms Array of terms in flat format. |
|
5756 * |
|
5757 * @return {Array} Array of terms in tree format. |
|
5758 */ |
|
5759 |
|
5760 function buildTermsTree(flatTerms) { |
|
5761 const flatTermsWithParentAndChildren = flatTerms.map(term => { |
|
5762 return { |
|
5763 children: [], |
|
5764 parent: null, |
|
5765 ...term |
|
5766 }; |
|
5767 }); |
|
5768 const termsByParent = Object(external_lodash_["groupBy"])(flatTermsWithParentAndChildren, 'parent'); |
|
5769 |
|
5770 if (termsByParent.null && termsByParent.null.length) { |
|
5771 return flatTermsWithParentAndChildren; |
|
5772 } |
|
5773 |
|
5774 const fillWithChildren = terms => { |
|
5775 return terms.map(term => { |
|
5776 const children = termsByParent[term.id]; |
|
5777 return { ...term, |
|
5778 children: children && children.length ? fillWithChildren(children) : [] |
|
5779 }; |
|
5780 }); |
|
5781 }; |
|
5782 |
|
5783 return fillWithChildren(termsByParent['0'] || []); |
|
5784 } // Lodash unescape function handles ' but not ' which may be return in some API requests. |
|
5785 |
|
5786 const unescapeString = arg => { |
|
5787 return Object(external_lodash_["unescape"])(arg.replace(''', "'")); |
|
5788 }; |
|
5789 /** |
|
5790 * Returns a term object with name unescaped. |
|
5791 * The unescape of the name property is done using lodash unescape function. |
|
5792 * |
|
5793 * @param {Object} term The term object to unescape. |
|
5794 * |
|
5795 * @return {Object} Term object with name property unescaped. |
|
5796 */ |
|
5797 |
|
5798 const unescapeTerm = term => { |
|
5799 return { ...term, |
|
5800 name: unescapeString(term.name) |
|
5801 }; |
|
5802 }; |
|
5803 /** |
|
5804 * Returns an array of term objects with names unescaped. |
|
5805 * The unescape of each term is performed using the unescapeTerm function. |
|
5806 * |
|
5807 * @param {Object[]} terms Array of term objects to unescape. |
|
5808 * |
|
5809 * @return {Object[]} Array of term objects unescaped. |
|
5810 */ |
|
5811 |
|
5812 const unescapeTerms = terms => { |
|
5813 return Object(external_lodash_["map"])(terms, unescapeTerm); |
|
5814 }; |
|
5815 |
|
5816 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/parent.js |
|
5817 |
|
5818 |
|
5819 /** |
|
5820 * External dependencies |
|
5821 */ |
|
5822 |
|
5823 /** |
|
5824 * WordPress dependencies |
|
5825 */ |
|
5826 |
|
5827 |
|
5828 |
|
5829 |
|
5830 |
|
5831 |
|
5832 /** |
|
5833 * Internal dependencies |
|
5834 */ |
|
5835 |
|
5836 |
|
5837 |
|
5838 function getTitle(post) { |
|
5839 var _post$title; |
|
5840 |
|
5841 return post !== null && post !== void 0 && (_post$title = post.title) !== null && _post$title !== void 0 && _post$title.rendered ? Object(external_wp_htmlEntities_["decodeEntities"])(post.title.rendered) : `#${post.id} (${Object(external_wp_i18n_["__"])('no title')})`; |
|
5842 } |
|
5843 |
|
5844 const getItemPriority = (name, searchValue) => { |
|
5845 const normalizedName = Object(external_lodash_["deburr"])(name).toLowerCase(); |
|
5846 const normalizedSearch = Object(external_lodash_["deburr"])(searchValue).toLowerCase(); |
|
5847 |
|
5848 if (normalizedName === normalizedSearch) { |
|
5849 return 0; |
|
5850 } |
|
5851 |
|
5852 if (normalizedName.startsWith(normalizedSearch)) { |
|
5853 return normalizedName.length; |
|
5854 } |
|
5855 |
|
5856 return Infinity; |
|
5857 }; |
|
5858 function PageAttributesParent() { |
|
5859 const { |
|
5860 editPost |
|
5861 } = Object(external_wp_data_["useDispatch"])('core/editor'); |
|
5862 const [fieldValue, setFieldValue] = Object(external_wp_element_["useState"])(false); |
|
5863 const { |
|
5864 parentPost, |
|
5865 parentPostId, |
|
5866 items, |
|
5867 postType |
|
5868 } = Object(external_wp_data_["useSelect"])(select => { |
|
5869 const { |
|
5870 getPostType, |
|
5871 getEntityRecords, |
|
5872 getEntityRecord |
|
5873 } = select('core'); |
|
5874 const { |
|
5875 getCurrentPostId, |
|
5876 getEditedPostAttribute |
|
5877 } = select('core/editor'); |
|
5878 const postTypeSlug = getEditedPostAttribute('type'); |
|
5879 const pageId = getEditedPostAttribute('parent'); |
|
5880 const pType = getPostType(postTypeSlug); |
|
5881 const postId = getCurrentPostId(); |
|
5882 const isHierarchical = Object(external_lodash_["get"])(pType, ['hierarchical'], false); |
|
5883 const query = { |
|
5884 per_page: 100, |
|
5885 exclude: postId, |
|
5886 parent_exclude: postId, |
|
5887 orderby: 'menu_order', |
|
5888 order: 'asc', |
|
5889 _fields: 'id,title,parent' |
|
5890 }; // Perform a search when the field is changed. |
|
5891 |
|
5892 if (!!fieldValue) { |
|
5893 query.search = fieldValue; |
|
5894 } |
|
5895 |
|
5896 return { |
|
5897 parentPostId: pageId, |
|
5898 parentPost: pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null, |
|
5899 items: isHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [], |
|
5900 postType: pType |
|
5901 }; |
|
5902 }, [fieldValue]); |
|
5903 const isHierarchical = Object(external_lodash_["get"])(postType, ['hierarchical'], false); |
|
5904 const parentPageLabel = Object(external_lodash_["get"])(postType, ['labels', 'parent_item_colon']); |
|
5905 const pageItems = items || []; |
|
5906 const parentOptions = Object(external_wp_element_["useMemo"])(() => { |
|
5907 const getOptionsFromTree = (tree, level = 0) => { |
|
5908 const mappedNodes = tree.map(treeNode => [{ |
|
5909 value: treeNode.id, |
|
5910 label: Object(external_lodash_["repeat"])('— ', level) + Object(external_lodash_["unescape"])(treeNode.name), |
|
5911 rawName: treeNode.name |
|
5912 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]); |
|
5913 const sortedNodes = mappedNodes.sort(([a], [b]) => { |
|
5914 const priorityA = getItemPriority(a.rawName, fieldValue); |
|
5915 const priorityB = getItemPriority(b.rawName, fieldValue); |
|
5916 return priorityA >= priorityB ? 1 : -1; |
|
5917 }); |
|
5918 return Object(external_lodash_["flatten"])(sortedNodes); |
|
5919 }; |
|
5920 |
|
5921 let tree = pageItems.map(item => ({ |
|
5922 id: item.id, |
|
5923 parent: item.parent, |
|
5924 name: getTitle(item) |
|
5925 })); // Only build a hierarchical tree when not searching. |
|
5926 |
|
5927 if (!fieldValue) { |
|
5928 tree = buildTermsTree(tree); |
|
5929 } |
|
5930 |
|
5931 const opts = getOptionsFromTree(tree); // Ensure the current parent is in the options list. |
|
5932 |
|
5933 const optsHasParent = Object(external_lodash_["find"])(opts, item => item.value === parentPostId); |
|
5934 |
|
5935 if (parentPost && !optsHasParent) { |
|
5936 opts.unshift({ |
|
5937 value: parentPostId, |
|
5938 label: getTitle(parentPost) |
8231 }); |
5939 }); |
8232 } |
5940 } |
|
5941 |
|
5942 return opts; |
|
5943 }, [pageItems, fieldValue]); |
|
5944 |
|
5945 if (!isHierarchical || !parentPageLabel) { |
|
5946 return null; |
|
5947 } |
|
5948 /** |
|
5949 * Handle user input. |
|
5950 * |
|
5951 * @param {string} inputValue The current value of the input field. |
|
5952 */ |
|
5953 |
|
5954 |
|
5955 const handleKeydown = inputValue => { |
|
5956 setFieldValue(inputValue); |
8233 }; |
5957 }; |
8234 })])(PageAttributesOrderWithChecks)); |
5958 /** |
8235 |
5959 * Handle author selection. |
8236 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/terms.js |
5960 * |
8237 |
5961 * @param {Object} selectedPostId The selected Author. |
8238 |
5962 */ |
8239 function terms_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
5963 |
8240 |
5964 |
8241 function terms_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { terms_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { terms_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
5965 const handleChange = selectedPostId => { |
8242 |
5966 editPost({ |
8243 /** |
5967 parent: selectedPostId |
8244 * External dependencies |
|
8245 */ |
|
8246 |
|
8247 /** |
|
8248 * Returns terms in a tree form. |
|
8249 * |
|
8250 * @param {Array} flatTerms Array of terms in flat format. |
|
8251 * |
|
8252 * @return {Array} Array of terms in tree format. |
|
8253 */ |
|
8254 |
|
8255 function buildTermsTree(flatTerms) { |
|
8256 var flatTermsWithParentAndChildren = flatTerms.map(function (term) { |
|
8257 return terms_objectSpread({ |
|
8258 children: [], |
|
8259 parent: null |
|
8260 }, term); |
|
8261 }); |
|
8262 var termsByParent = Object(external_this_lodash_["groupBy"])(flatTermsWithParentAndChildren, 'parent'); |
|
8263 |
|
8264 if (termsByParent.null && termsByParent.null.length) { |
|
8265 return flatTermsWithParentAndChildren; |
|
8266 } |
|
8267 |
|
8268 var fillWithChildren = function fillWithChildren(terms) { |
|
8269 return terms.map(function (term) { |
|
8270 var children = termsByParent[term.id]; |
|
8271 return terms_objectSpread({}, term, { |
|
8272 children: children && children.length ? fillWithChildren(children) : [] |
|
8273 }); |
|
8274 }); |
5968 }); |
8275 }; |
5969 }; |
8276 |
5970 |
8277 return fillWithChildren(termsByParent['0'] || []); |
5971 return Object(external_wp_element_["createElement"])(external_wp_components_["ComboboxControl"], { |
8278 } |
|
8279 |
|
8280 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/parent.js |
|
8281 |
|
8282 |
|
8283 /** |
|
8284 * External dependencies |
|
8285 */ |
|
8286 |
|
8287 /** |
|
8288 * WordPress dependencies |
|
8289 */ |
|
8290 |
|
8291 |
|
8292 |
|
8293 |
|
8294 |
|
8295 /** |
|
8296 * Internal dependencies |
|
8297 */ |
|
8298 |
|
8299 |
|
8300 function PageAttributesParent(_ref) { |
|
8301 var parent = _ref.parent, |
|
8302 postType = _ref.postType, |
|
8303 items = _ref.items, |
|
8304 onUpdateParent = _ref.onUpdateParent; |
|
8305 var isHierarchical = Object(external_this_lodash_["get"])(postType, ['hierarchical'], false); |
|
8306 var parentPageLabel = Object(external_this_lodash_["get"])(postType, ['labels', 'parent_item_colon']); |
|
8307 var pageItems = items || []; |
|
8308 |
|
8309 if (!isHierarchical || !parentPageLabel || !pageItems.length) { |
|
8310 return null; |
|
8311 } |
|
8312 |
|
8313 var pagesTree = buildTermsTree(pageItems.map(function (item) { |
|
8314 return { |
|
8315 id: item.id, |
|
8316 parent: item.parent, |
|
8317 name: item.title && item.title.raw ? item.title.raw : "#".concat(item.id, " (").concat(Object(external_this_wp_i18n_["__"])('no title'), ")") |
|
8318 }; |
|
8319 })); |
|
8320 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TreeSelect"], { |
|
8321 className: "editor-page-attributes__parent", |
5972 className: "editor-page-attributes__parent", |
8322 label: parentPageLabel, |
5973 label: parentPageLabel, |
8323 noOptionLabel: "(".concat(Object(external_this_wp_i18n_["__"])('no parent'), ")"), |
5974 value: parentPostId, |
8324 tree: pagesTree, |
5975 options: parentOptions, |
8325 selectedId: parent, |
5976 onFilterValueChange: Object(external_lodash_["debounce"])(handleKeydown, 300), |
8326 onChange: onUpdateParent |
5977 onChange: handleChange |
8327 }); |
5978 }); |
8328 } |
5979 } |
8329 var applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select) { |
5980 /* harmony default export */ var page_attributes_parent = (PageAttributesParent); |
8330 var _select = select('core'), |
5981 |
8331 getPostType = _select.getPostType, |
5982 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/index.js |
8332 getEntityRecords = _select.getEntityRecords; |
5983 |
8333 |
5984 |
8334 var _select2 = select('core/editor'), |
5985 /** |
8335 getCurrentPostId = _select2.getCurrentPostId, |
5986 * External dependencies |
8336 getEditedPostAttribute = _select2.getEditedPostAttribute; |
5987 */ |
8337 |
5988 |
8338 var postTypeSlug = getEditedPostAttribute('type'); |
5989 /** |
8339 var postType = getPostType(postTypeSlug); |
5990 * WordPress dependencies |
8340 var postId = getCurrentPostId(); |
5991 */ |
8341 var isHierarchical = Object(external_this_lodash_["get"])(postType, ['hierarchical'], false); |
5992 |
8342 var query = { |
5993 |
8343 per_page: -1, |
5994 |
8344 exclude: postId, |
5995 |
8345 parent_exclude: postId, |
5996 |
8346 orderby: 'menu_order', |
5997 /** |
8347 order: 'asc' |
5998 * Internal dependencies |
8348 }; |
5999 */ |
8349 return { |
6000 |
8350 parent: getEditedPostAttribute('parent'), |
6001 |
8351 items: isHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [], |
6002 function PostTemplate({}) { |
8352 postType: postType |
6003 const { |
8353 }; |
6004 availableTemplates, |
8354 }); |
6005 selectedTemplate, |
8355 var applyWithDispatch = Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
6006 isViewable |
8356 var _dispatch = dispatch('core/editor'), |
6007 } = Object(external_wp_data_["useSelect"])(select => { |
8357 editPost = _dispatch.editPost; |
6008 var _getPostType$viewable, _getPostType; |
8358 |
6009 |
8359 return { |
6010 const { |
8360 onUpdateParent: function onUpdateParent(parent) { |
6011 getEditedPostAttribute, |
|
6012 getEditorSettings, |
|
6013 getCurrentPostType |
|
6014 } = select(store); |
|
6015 const { |
|
6016 getPostType |
|
6017 } = select(external_wp_coreData_["store"]); |
|
6018 return { |
|
6019 selectedTemplate: getEditedPostAttribute('template'), |
|
6020 availableTemplates: getEditorSettings().availableTemplates, |
|
6021 isViewable: (_getPostType$viewable = (_getPostType = getPostType(getCurrentPostType())) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false |
|
6022 }; |
|
6023 }, []); |
|
6024 const { |
|
6025 editPost |
|
6026 } = Object(external_wp_data_["useDispatch"])(store); |
|
6027 |
|
6028 if (!isViewable || Object(external_lodash_["isEmpty"])(availableTemplates)) { |
|
6029 return null; |
|
6030 } |
|
6031 |
|
6032 return Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], { |
|
6033 label: Object(external_wp_i18n_["__"])('Template:'), |
|
6034 value: selectedTemplate, |
|
6035 onChange: templateSlug => { |
8361 editPost({ |
6036 editPost({ |
8362 parent: parent || 0 |
|
8363 }); |
|
8364 } |
|
8365 }; |
|
8366 }); |
|
8367 /* harmony default export */ var page_attributes_parent = (Object(external_this_wp_compose_["compose"])([applyWithSelect, applyWithDispatch])(PageAttributesParent)); |
|
8368 |
|
8369 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/template.js |
|
8370 |
|
8371 |
|
8372 /** |
|
8373 * External dependencies |
|
8374 */ |
|
8375 |
|
8376 /** |
|
8377 * WordPress dependencies |
|
8378 */ |
|
8379 |
|
8380 |
|
8381 |
|
8382 |
|
8383 |
|
8384 function PageTemplate(_ref) { |
|
8385 var availableTemplates = _ref.availableTemplates, |
|
8386 selectedTemplate = _ref.selectedTemplate, |
|
8387 onUpdate = _ref.onUpdate; |
|
8388 |
|
8389 if (Object(external_this_lodash_["isEmpty"])(availableTemplates)) { |
|
8390 return null; |
|
8391 } |
|
8392 |
|
8393 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SelectControl"], { |
|
8394 label: Object(external_this_wp_i18n_["__"])('Template:'), |
|
8395 value: selectedTemplate, |
|
8396 onChange: onUpdate, |
|
8397 className: "editor-page-attributes__template", |
|
8398 options: Object(external_this_lodash_["map"])(availableTemplates, function (templateName, templateSlug) { |
|
8399 return { |
|
8400 value: templateSlug, |
|
8401 label: templateName |
|
8402 }; |
|
8403 }) |
|
8404 }); |
|
8405 } |
|
8406 /* harmony default export */ var page_attributes_template = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8407 var _select = select('core/editor'), |
|
8408 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
8409 getEditorSettings = _select.getEditorSettings; |
|
8410 |
|
8411 var _getEditorSettings = getEditorSettings(), |
|
8412 availableTemplates = _getEditorSettings.availableTemplates; |
|
8413 |
|
8414 return { |
|
8415 selectedTemplate: getEditedPostAttribute('template'), |
|
8416 availableTemplates: availableTemplates |
|
8417 }; |
|
8418 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8419 return { |
|
8420 onUpdate: function onUpdate(templateSlug) { |
|
8421 dispatch('core/editor').editPost({ |
|
8422 template: templateSlug || '' |
6037 template: templateSlug || '' |
8423 }); |
6038 }); |
|
6039 }, |
|
6040 options: Object(external_lodash_["map"])(availableTemplates, (templateName, templateSlug) => ({ |
|
6041 value: templateSlug, |
|
6042 label: templateName |
|
6043 })) |
|
6044 }); |
|
6045 } |
|
6046 /* harmony default export */ var post_template = (PostTemplate); |
|
6047 |
|
6048 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/combobox.js |
|
6049 |
|
6050 |
|
6051 /** |
|
6052 * External dependencies |
|
6053 */ |
|
6054 |
|
6055 /** |
|
6056 * WordPress dependencies |
|
6057 */ |
|
6058 |
|
6059 |
|
6060 |
|
6061 |
|
6062 |
|
6063 |
|
6064 function PostAuthorCombobox() { |
|
6065 const [fieldValue, setFieldValue] = Object(external_wp_element_["useState"])(); |
|
6066 const { |
|
6067 authorId, |
|
6068 isLoading, |
|
6069 authors, |
|
6070 postAuthor |
|
6071 } = Object(external_wp_data_["useSelect"])(select => { |
|
6072 const { |
|
6073 __unstableGetAuthor, |
|
6074 getAuthors, |
|
6075 isResolving |
|
6076 } = select('core'); |
|
6077 const { |
|
6078 getEditedPostAttribute |
|
6079 } = select('core/editor'); |
|
6080 |
|
6081 const author = __unstableGetAuthor(getEditedPostAttribute('author')); |
|
6082 |
|
6083 const query = !fieldValue || '' === fieldValue ? {} : { |
|
6084 search: fieldValue |
|
6085 }; |
|
6086 return { |
|
6087 authorId: getEditedPostAttribute('author'), |
|
6088 postAuthor: author, |
|
6089 authors: getAuthors(query), |
|
6090 isLoading: isResolving('core', 'getAuthors', [query]) |
|
6091 }; |
|
6092 }, [fieldValue]); |
|
6093 const { |
|
6094 editPost |
|
6095 } = Object(external_wp_data_["useDispatch"])('core/editor'); |
|
6096 const authorOptions = Object(external_wp_element_["useMemo"])(() => { |
|
6097 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => { |
|
6098 return { |
|
6099 value: author.id, |
|
6100 label: author.name |
|
6101 }; |
|
6102 }); // Ensure the current author is included in the dropdown list. |
|
6103 |
|
6104 const foundAuthor = fetchedAuthors.findIndex(({ |
|
6105 value |
|
6106 }) => (postAuthor === null || postAuthor === void 0 ? void 0 : postAuthor.id) === value); |
|
6107 |
|
6108 if (foundAuthor < 0 && postAuthor) { |
|
6109 return [{ |
|
6110 value: postAuthor.id, |
|
6111 label: postAuthor.name |
|
6112 }, ...fetchedAuthors]; |
8424 } |
6113 } |
|
6114 |
|
6115 return fetchedAuthors; |
|
6116 }, [authors, postAuthor]); // Initializes the post author properly |
|
6117 // Also ensures external changes are reflected. |
|
6118 |
|
6119 Object(external_wp_element_["useEffect"])(() => { |
|
6120 if (postAuthor) { |
|
6121 setFieldValue(postAuthor.name); |
|
6122 } |
|
6123 }, [postAuthor]); |
|
6124 /** |
|
6125 * Handle author selection. |
|
6126 * |
|
6127 * @param {number} postAuthorId The selected Author. |
|
6128 */ |
|
6129 |
|
6130 const handleSelect = postAuthorId => { |
|
6131 if (!postAuthorId) { |
|
6132 return; |
|
6133 } |
|
6134 |
|
6135 editPost({ |
|
6136 author: postAuthorId |
|
6137 }); |
8425 }; |
6138 }; |
8426 }))(PageTemplate)); |
6139 /** |
8427 |
6140 * Handle user input. |
8428 // EXTERNAL MODULE: external {"this":["wp","htmlEntities"]} |
6141 * |
8429 var external_this_wp_htmlEntities_ = __webpack_require__(75); |
6142 * @param {string} inputValue The current value of the input field. |
|
6143 */ |
|
6144 |
|
6145 |
|
6146 const handleKeydown = inputValue => { |
|
6147 setFieldValue(inputValue); |
|
6148 }; |
|
6149 |
|
6150 if (!postAuthor) { |
|
6151 return null; |
|
6152 } |
|
6153 |
|
6154 return Object(external_wp_element_["createElement"])(external_wp_components_["ComboboxControl"], { |
|
6155 label: Object(external_wp_i18n_["__"])('Author'), |
|
6156 options: authorOptions, |
|
6157 value: authorId, |
|
6158 onFilterValueChange: Object(external_lodash_["debounce"])(handleKeydown, 300), |
|
6159 onChange: handleSelect, |
|
6160 isLoading: isLoading, |
|
6161 allowReset: false |
|
6162 }); |
|
6163 } |
|
6164 |
|
6165 /* harmony default export */ var combobox = (PostAuthorCombobox); |
|
6166 |
|
6167 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/select.js |
|
6168 |
|
6169 |
|
6170 /** |
|
6171 * WordPress dependencies |
|
6172 */ |
|
6173 |
|
6174 |
|
6175 |
|
6176 |
|
6177 |
|
6178 function PostAuthorSelect() { |
|
6179 const { |
|
6180 editPost |
|
6181 } = Object(external_wp_data_["useDispatch"])('core/editor'); |
|
6182 const { |
|
6183 postAuthor, |
|
6184 authors |
|
6185 } = Object(external_wp_data_["useSelect"])(select => { |
|
6186 const authorsFromAPI = select('core').getAuthors(); |
|
6187 return { |
|
6188 postAuthor: select('core/editor').getEditedPostAttribute('author'), |
|
6189 authors: authorsFromAPI.map(author => ({ |
|
6190 label: Object(external_wp_htmlEntities_["decodeEntities"])(author.name), |
|
6191 value: author.id |
|
6192 })) |
|
6193 }; |
|
6194 }, []); |
|
6195 |
|
6196 const setAuthorId = value => { |
|
6197 const author = Number(value); |
|
6198 editPost({ |
|
6199 author |
|
6200 }); |
|
6201 }; |
|
6202 |
|
6203 return Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], { |
|
6204 className: "post-author-selector", |
|
6205 label: Object(external_wp_i18n_["__"])('Author'), |
|
6206 options: authors, |
|
6207 onChange: setAuthorId, |
|
6208 value: postAuthor |
|
6209 }); |
|
6210 } |
|
6211 |
|
6212 /* harmony default export */ var post_author_select = (PostAuthorSelect); |
|
6213 |
|
6214 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/index.js |
|
6215 |
|
6216 |
|
6217 /** |
|
6218 * WordPress dependencies |
|
6219 */ |
|
6220 |
|
6221 |
|
6222 /** |
|
6223 * Internal dependencies |
|
6224 */ |
|
6225 |
|
6226 |
|
6227 |
|
6228 const minimumUsersForCombobox = 25; |
|
6229 |
|
6230 function PostAuthor() { |
|
6231 const showCombobox = Object(external_wp_data_["useSelect"])(select => { |
|
6232 // Not using `getUsers()` because it requires `list_users` capability. |
|
6233 const authors = select(external_wp_coreData_["store"]).getAuthors(); |
|
6234 return (authors === null || authors === void 0 ? void 0 : authors.length) >= minimumUsersForCombobox; |
|
6235 }, []); |
|
6236 |
|
6237 if (showCombobox) { |
|
6238 return Object(external_wp_element_["createElement"])(combobox, null); |
|
6239 } |
|
6240 |
|
6241 return Object(external_wp_element_["createElement"])(post_author_select, null); |
|
6242 } |
|
6243 |
|
6244 /* harmony default export */ var post_author = (PostAuthor); |
8430 |
6245 |
8431 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/check.js |
6246 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/check.js |
8432 |
6247 |
8433 |
6248 |
8434 /** |
6249 /** |
9177 |
6893 |
9178 |
6894 |
9179 |
6895 |
9180 |
6896 |
9181 function writeInterstitialMessage(targetDocument) { |
6897 function writeInterstitialMessage(targetDocument) { |
9182 var markup = Object(external_this_wp_element_["renderToString"])(Object(external_this_wp_element_["createElement"])("div", { |
6898 let markup = Object(external_wp_element_["renderToString"])(Object(external_wp_element_["createElement"])("div", { |
9183 className: "editor-post-preview-button__interstitial-message" |
6899 className: "editor-post-preview-button__interstitial-message" |
9184 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
6900 }, Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], { |
9185 xmlns: "http://www.w3.org/2000/svg", |
6901 xmlns: "http://www.w3.org/2000/svg", |
9186 viewBox: "0 0 96 96" |
6902 viewBox: "0 0 96 96" |
9187 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
6903 }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], { |
9188 className: "outer", |
6904 className: "outer", |
9189 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36", |
6905 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36", |
9190 fill: "none" |
6906 fill: "none" |
9191 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
6907 }), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], { |
9192 className: "inner", |
6908 className: "inner", |
9193 d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z", |
6909 d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z", |
9194 fill: "none" |
6910 fill: "none" |
9195 })), Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_i18n_["__"])('Generating preview…')))); |
6911 })), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_i18n_["__"])('Generating preview…')))); |
9196 markup += "\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t"; |
6912 markup += ` |
|
6913 <style> |
|
6914 body { |
|
6915 margin: 0; |
|
6916 } |
|
6917 .editor-post-preview-button__interstitial-message { |
|
6918 display: flex; |
|
6919 flex-direction: column; |
|
6920 align-items: center; |
|
6921 justify-content: center; |
|
6922 height: 100vh; |
|
6923 width: 100vw; |
|
6924 } |
|
6925 @-webkit-keyframes paint { |
|
6926 0% { |
|
6927 stroke-dashoffset: 0; |
|
6928 } |
|
6929 } |
|
6930 @-moz-keyframes paint { |
|
6931 0% { |
|
6932 stroke-dashoffset: 0; |
|
6933 } |
|
6934 } |
|
6935 @-o-keyframes paint { |
|
6936 0% { |
|
6937 stroke-dashoffset: 0; |
|
6938 } |
|
6939 } |
|
6940 @keyframes paint { |
|
6941 0% { |
|
6942 stroke-dashoffset: 0; |
|
6943 } |
|
6944 } |
|
6945 .editor-post-preview-button__interstitial-message svg { |
|
6946 width: 192px; |
|
6947 height: 192px; |
|
6948 stroke: #555d66; |
|
6949 stroke-width: 0.75; |
|
6950 } |
|
6951 .editor-post-preview-button__interstitial-message svg .outer, |
|
6952 .editor-post-preview-button__interstitial-message svg .inner { |
|
6953 stroke-dasharray: 280; |
|
6954 stroke-dashoffset: 280; |
|
6955 -webkit-animation: paint 1.5s ease infinite alternate; |
|
6956 -moz-animation: paint 1.5s ease infinite alternate; |
|
6957 -o-animation: paint 1.5s ease infinite alternate; |
|
6958 animation: paint 1.5s ease infinite alternate; |
|
6959 } |
|
6960 p { |
|
6961 text-align: center; |
|
6962 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; |
|
6963 } |
|
6964 </style> |
|
6965 `; |
9197 /** |
6966 /** |
9198 * Filters the interstitial message shown when generating previews. |
6967 * Filters the interstitial message shown when generating previews. |
9199 * |
6968 * |
9200 * @param {string} markup The preview interstitial markup. |
6969 * @param {string} markup The preview interstitial markup. |
9201 */ |
6970 */ |
9202 |
6971 |
9203 markup = Object(external_this_wp_hooks_["applyFilters"])('editor.PostPreview.interstitialMarkup', markup); |
6972 markup = Object(external_wp_hooks_["applyFilters"])('editor.PostPreview.interstitialMarkup', markup); |
9204 targetDocument.write(markup); |
6973 targetDocument.write(markup); |
9205 targetDocument.title = Object(external_this_wp_i18n_["__"])('Generating preview…'); |
6974 targetDocument.title = Object(external_wp_i18n_["__"])('Generating preview…'); |
9206 targetDocument.close(); |
6975 targetDocument.close(); |
9207 } |
6976 } |
9208 |
6977 |
9209 var post_preview_button_PostPreviewButton = /*#__PURE__*/function (_Component) { |
6978 class post_preview_button_PostPreviewButton extends external_wp_element_["Component"] { |
9210 Object(inherits["a" /* default */])(PostPreviewButton, _Component); |
6979 constructor() { |
9211 |
6980 super(...arguments); |
9212 var _super = post_preview_button_createSuper(PostPreviewButton); |
6981 this.buttonRef = Object(external_wp_element_["createRef"])(); |
9213 |
6982 this.openPreviewWindow = this.openPreviewWindow.bind(this); |
9214 function PostPreviewButton() { |
6983 } |
9215 var _this; |
6984 |
9216 |
6985 componentDidUpdate(prevProps) { |
9217 Object(classCallCheck["a" /* default */])(this, PostPreviewButton); |
6986 const { |
9218 |
6987 previewLink |
9219 _this = _super.apply(this, arguments); |
6988 } = this.props; // This relies on the window being responsible to unset itself when |
9220 _this.buttonRef = Object(external_this_wp_element_["createRef"])(); |
6989 // navigation occurs or a new preview window is opened, to avoid |
9221 _this.openPreviewWindow = _this.openPreviewWindow.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
6990 // unintentional forceful redirects. |
9222 return _this; |
6991 |
9223 } |
6992 if (previewLink && !prevProps.previewLink) { |
9224 |
6993 this.setPreviewWindowLink(previewLink); |
9225 Object(createClass["a" /* default */])(PostPreviewButton, [{ |
6994 } |
9226 key: "componentDidUpdate", |
6995 } |
9227 value: function componentDidUpdate(prevProps) { |
6996 /** |
9228 var previewLink = this.props.previewLink; // This relies on the window being responsible to unset itself when |
6997 * Sets the preview window's location to the given URL, if a preview window |
9229 // navigation occurs or a new preview window is opened, to avoid |
6998 * exists and is not closed. |
9230 // unintentional forceful redirects. |
6999 * |
9231 |
7000 * @param {string} url URL to assign as preview window location. |
9232 if (previewLink && !prevProps.previewLink) { |
7001 */ |
9233 this.setPreviewWindowLink(previewLink); |
7002 |
|
7003 |
|
7004 setPreviewWindowLink(url) { |
|
7005 const { |
|
7006 previewWindow |
|
7007 } = this; |
|
7008 |
|
7009 if (previewWindow && !previewWindow.closed) { |
|
7010 previewWindow.location = url; |
|
7011 |
|
7012 if (this.buttonRef.current) { |
|
7013 this.buttonRef.current.focus(); |
9234 } |
7014 } |
9235 } |
7015 } |
9236 /** |
7016 } |
9237 * Sets the preview window's location to the given URL, if a preview window |
7017 |
9238 * exists and is not closed. |
7018 getWindowTarget() { |
9239 * |
7019 const { |
9240 * @param {string} url URL to assign as preview window location. |
7020 postId |
9241 */ |
7021 } = this.props; |
9242 |
7022 return `wp-preview-${postId}`; |
9243 }, { |
7023 } |
9244 key: "setPreviewWindowLink", |
7024 |
9245 value: function setPreviewWindowLink(url) { |
7025 openPreviewWindow(event) { |
9246 var previewWindow = this.previewWindow; |
7026 // Our Preview button has its 'href' and 'target' set correctly for a11y |
9247 |
7027 // purposes. Unfortunately, though, we can't rely on the default 'click' |
9248 if (previewWindow && !previewWindow.closed) { |
7028 // handler since sometimes it incorrectly opens a new tab instead of reusing |
9249 previewWindow.location = url; |
7029 // the existing one. |
9250 |
7030 // https://github.com/WordPress/gutenberg/pull/8330 |
9251 if (this.buttonRef.current) { |
7031 event.preventDefault(); // Open up a Preview tab if needed. This is where we'll show the preview. |
9252 this.buttonRef.current.focus(); |
7032 |
9253 } |
7033 if (!this.previewWindow || this.previewWindow.closed) { |
9254 } |
7034 this.previewWindow = window.open('', this.getWindowTarget()); |
9255 } |
7035 } // Focus the Preview tab. This might not do anything, depending on the browser's |
9256 }, { |
7036 // and user's preferences. |
9257 key: "getWindowTarget", |
7037 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus |
9258 value: function getWindowTarget() { |
7038 |
9259 var postId = this.props.postId; |
7039 |
9260 return "wp-preview-".concat(postId); |
7040 this.previewWindow.focus(); |
9261 } |
7041 |
9262 }, { |
7042 if ( // If we don't need to autosave the post before previewing, then we simply |
9263 key: "openPreviewWindow", |
7043 // load the Preview URL in the Preview tab. |
9264 value: function openPreviewWindow(event) { |
7044 !this.props.isAutosaveable || // Do not save or overwrite the post, if the post is already locked. |
9265 // Our Preview button has its 'href' and 'target' set correctly for a11y |
7045 this.props.isPostLocked) { |
9266 // purposes. Unfortunately, though, we can't rely on the default 'click' |
7046 this.setPreviewWindowLink(event.target.href); |
9267 // handler since sometimes it incorrectly opens a new tab instead of reusing |
7047 return; |
9268 // the existing one. |
7048 } // Request an autosave. This happens asynchronously and causes the component |
9269 // https://github.com/WordPress/gutenberg/pull/8330 |
7049 // to update when finished. |
9270 event.preventDefault(); // Open up a Preview tab if needed. This is where we'll show the preview. |
7050 |
9271 |
7051 |
9272 if (!this.previewWindow || this.previewWindow.closed) { |
7052 if (this.props.isDraft) { |
9273 this.previewWindow = window.open('', this.getWindowTarget()); |
7053 this.props.savePost({ |
9274 } // Focus the Preview tab. This might not do anything, depending on the browser's |
7054 isPreview: true |
9275 // and user's preferences. |
7055 }); |
9276 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus |
7056 } else { |
9277 |
7057 this.props.autosave({ |
9278 |
7058 isPreview: true |
9279 this.previewWindow.focus(); // If we don't need to autosave the post before previewing, then we simply |
7059 }); |
9280 // load the Preview URL in the Preview tab. |
7060 } // Display a 'Generating preview' message in the Preview tab while we wait for the |
9281 |
7061 // autosave to finish. |
9282 if (!this.props.isAutosaveable) { |
7062 |
9283 this.setPreviewWindowLink(event.target.href); |
7063 |
9284 return; |
7064 writeInterstitialMessage(this.previewWindow.document); |
9285 } // Request an autosave. This happens asynchronously and causes the component |
7065 } |
9286 // to update when finished. |
7066 |
9287 |
7067 render() { |
9288 |
7068 const { |
9289 if (this.props.isDraft) { |
7069 previewLink, |
9290 this.props.savePost({ |
7070 currentPostLink, |
9291 isPreview: true |
7071 isSaveable, |
9292 }); |
7072 role |
9293 } else { |
7073 } = this.props; // Link to the `?preview=true` URL if we have it, since this lets us see |
9294 this.props.autosave({ |
7074 // changes that were autosaved since the post was last published. Otherwise, |
9295 isPreview: true |
7075 // just link to the post's URL. |
9296 }); |
7076 |
9297 } // Display a 'Generating preview' message in the Preview tab while we wait for the |
7077 const href = previewLink || currentPostLink; |
9298 // autosave to finish. |
7078 const classNames = classnames_default()({ |
9299 |
7079 'editor-post-preview': !this.props.className |
9300 |
7080 }, this.props.className); |
9301 writeInterstitialMessage(this.previewWindow.document); |
7081 return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
9302 } |
7082 isTertiary: !this.props.className, |
9303 }, { |
7083 className: classNames, |
9304 key: "render", |
7084 href: href, |
9305 value: function render() { |
7085 target: this.getWindowTarget(), |
9306 var _this$props = this.props, |
7086 disabled: !isSaveable, |
9307 previewLink = _this$props.previewLink, |
7087 onClick: this.openPreviewWindow, |
9308 currentPostLink = _this$props.currentPostLink, |
7088 ref: this.buttonRef, |
9309 isSaveable = _this$props.isSaveable; // Link to the `?preview=true` URL if we have it, since this lets us see |
7089 role: role |
9310 // changes that were autosaved since the post was last published. Otherwise, |
7090 }, this.props.textContent ? this.props.textContent : Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_i18n_["_x"])('Preview', 'imperative verb'), Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], { |
9311 // just link to the post's URL. |
7091 as: "span" |
9312 |
7092 }, |
9313 var href = previewLink || currentPostLink; |
7093 /* translators: accessibility text */ |
9314 var classNames = classnames_default()({ |
7094 Object(external_wp_i18n_["__"])('(opens in a new tab)')))); |
9315 'editor-post-preview': !this.props.className |
7095 } |
9316 }, this.props.className); |
7096 |
9317 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
7097 } |
9318 isTertiary: !this.props.className, |
7098 /* harmony default export */ var post_preview_button = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])((select, { |
9319 className: classNames, |
7099 forcePreviewLink, |
9320 href: href, |
7100 forceIsAutosaveable |
9321 target: this.getWindowTarget(), |
7101 }) => { |
9322 disabled: !isSaveable, |
7102 const { |
9323 onClick: this.openPreviewWindow, |
7103 getCurrentPostId, |
9324 ref: this.buttonRef |
7104 getCurrentPostAttribute, |
9325 }, this.props.textContent ? this.props.textContent : Object(external_this_wp_i18n_["_x"])('Preview', 'imperative verb'), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["VisuallyHidden"], { |
7105 getEditedPostAttribute, |
9326 as: "span" |
7106 isEditedPostSaveable, |
9327 }, |
7107 isEditedPostAutosaveable, |
9328 /* translators: accessibility text */ |
7108 getEditedPostPreviewLink, |
9329 Object(external_this_wp_i18n_["__"])('(opens in a new tab)'))); |
7109 isPostLocked |
9330 } |
7110 } = select('core/editor'); |
9331 }]); |
7111 const { |
9332 |
7112 getPostType |
9333 return PostPreviewButton; |
7113 } = select('core'); |
9334 }(external_this_wp_element_["Component"]); |
7114 const previewLink = getEditedPostPreviewLink(); |
9335 /* harmony default export */ var post_preview_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
7115 const postType = getPostType(getEditedPostAttribute('type')); |
9336 var forcePreviewLink = _ref.forcePreviewLink, |
|
9337 forceIsAutosaveable = _ref.forceIsAutosaveable; |
|
9338 |
|
9339 var _select = select('core/editor'), |
|
9340 getCurrentPostId = _select.getCurrentPostId, |
|
9341 getCurrentPostAttribute = _select.getCurrentPostAttribute, |
|
9342 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
9343 isEditedPostSaveable = _select.isEditedPostSaveable, |
|
9344 isEditedPostAutosaveable = _select.isEditedPostAutosaveable, |
|
9345 getEditedPostPreviewLink = _select.getEditedPostPreviewLink; |
|
9346 |
|
9347 var _select2 = select('core'), |
|
9348 getPostType = _select2.getPostType; |
|
9349 |
|
9350 var previewLink = getEditedPostPreviewLink(); |
|
9351 var postType = getPostType(getEditedPostAttribute('type')); |
|
9352 return { |
7116 return { |
9353 postId: getCurrentPostId(), |
7117 postId: getCurrentPostId(), |
9354 currentPostLink: getCurrentPostAttribute('link'), |
7118 currentPostLink: getCurrentPostAttribute('link'), |
9355 previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink, |
7119 previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink, |
9356 isSaveable: isEditedPostSaveable(), |
7120 isSaveable: isEditedPostSaveable(), |
9357 isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(), |
7121 isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(), |
9358 isViewable: Object(external_this_lodash_["get"])(postType, ['viewable'], false), |
7122 isViewable: Object(external_lodash_["get"])(postType, ['viewable'], false), |
9359 isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1 |
7123 isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1, |
|
7124 isPostLocked: isPostLocked() |
9360 }; |
7125 }; |
9361 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
7126 }), Object(external_wp_data_["withDispatch"])(dispatch => ({ |
9362 return { |
7127 autosave: dispatch('core/editor').autosave, |
9363 autosave: dispatch('core/editor').autosave, |
7128 savePost: dispatch('core/editor').savePost |
9364 savePost: dispatch('core/editor').savePost |
7129 })), Object(external_wp_compose_["ifCondition"])(({ |
9365 }; |
7130 isViewable |
9366 }), Object(external_this_wp_compose_["ifCondition"])(function (_ref2) { |
7131 }) => isViewable)])(post_preview_button_PostPreviewButton)); |
9367 var isViewable = _ref2.isViewable; |
|
9368 return isViewable; |
|
9369 })])(post_preview_button_PostPreviewButton)); |
|
9370 |
7132 |
9371 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-locked-modal/index.js |
7133 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-locked-modal/index.js |
9372 |
7134 |
9373 |
7135 |
9374 |
|
9375 |
|
9376 |
|
9377 |
|
9378 |
|
9379 |
|
9380 function post_locked_modal_createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (post_locked_modal_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
9381 |
|
9382 function post_locked_modal_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
9383 |
|
9384 /** |
7136 /** |
9385 * External dependencies |
7137 * External dependencies |
9386 */ |
7138 */ |
9387 |
7139 |
9388 /** |
7140 /** |
9853 /** |
7525 /** |
9854 * Internal dependencies |
7526 * Internal dependencies |
9855 */ |
7527 */ |
9856 |
7528 |
9857 |
7529 |
9858 var post_publish_button_PostPublishButton = /*#__PURE__*/function (_Component) { |
7530 class post_publish_button_PostPublishButton extends external_wp_element_["Component"] { |
9859 Object(inherits["a" /* default */])(PostPublishButton, _Component); |
7531 constructor(props) { |
9860 |
7532 super(props); |
9861 var _super = post_publish_button_createSuper(PostPublishButton); |
7533 this.buttonNode = Object(external_wp_element_["createRef"])(); |
9862 |
7534 this.createOnClick = this.createOnClick.bind(this); |
9863 function PostPublishButton(props) { |
7535 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this); |
9864 var _this; |
7536 this.state = { |
9865 |
|
9866 Object(classCallCheck["a" /* default */])(this, PostPublishButton); |
|
9867 |
|
9868 _this = _super.call(this, props); |
|
9869 _this.buttonNode = Object(external_this_wp_element_["createRef"])(); |
|
9870 _this.createOnClick = _this.createOnClick.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
9871 _this.closeEntitiesSavedStates = _this.closeEntitiesSavedStates.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
9872 _this.state = { |
|
9873 entitiesSavedStatesCallback: false |
7537 entitiesSavedStatesCallback: false |
9874 }; |
7538 }; |
9875 return _this; |
7539 } |
9876 } |
7540 |
9877 |
7541 componentDidMount() { |
9878 Object(createClass["a" /* default */])(PostPublishButton, [{ |
7542 if (this.props.focusOnMount) { |
9879 key: "componentDidMount", |
7543 this.buttonNode.current.focus(); |
9880 value: function componentDidMount() { |
7544 } |
9881 if (this.props.focusOnMount) { |
7545 } |
9882 this.buttonNode.current.focus(); |
7546 |
|
7547 createOnClick(callback) { |
|
7548 return (...args) => { |
|
7549 const { |
|
7550 hasNonPostEntityChanges |
|
7551 } = this.props; |
|
7552 |
|
7553 if (hasNonPostEntityChanges) { |
|
7554 // The modal for multiple entity saving will open, |
|
7555 // hold the callback for saving/publishing the post |
|
7556 // so that we can call it if the post entity is checked. |
|
7557 this.setState({ |
|
7558 entitiesSavedStatesCallback: () => callback(...args) |
|
7559 }); // Open the save panel by setting its callback. |
|
7560 // To set a function on the useState hook, we must set it |
|
7561 // with another function (() => myFunction). Passing the |
|
7562 // function on its own will cause an error when called. |
|
7563 |
|
7564 this.props.setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates); |
|
7565 return external_lodash_["noop"]; |
9883 } |
7566 } |
|
7567 |
|
7568 return callback(...args); |
|
7569 }; |
|
7570 } |
|
7571 |
|
7572 closeEntitiesSavedStates(savedEntities) { |
|
7573 const { |
|
7574 postType, |
|
7575 postId |
|
7576 } = this.props; |
|
7577 const { |
|
7578 entitiesSavedStatesCallback |
|
7579 } = this.state; |
|
7580 this.setState({ |
|
7581 entitiesSavedStatesCallback: false |
|
7582 }, () => { |
|
7583 if (savedEntities && Object(external_lodash_["some"])(savedEntities, elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) { |
|
7584 // The post entity was checked, call the held callback from `createOnClick`. |
|
7585 entitiesSavedStatesCallback(); |
|
7586 } |
|
7587 }); |
|
7588 } |
|
7589 |
|
7590 render() { |
|
7591 const { |
|
7592 forceIsDirty, |
|
7593 forceIsSaving, |
|
7594 hasPublishAction, |
|
7595 isBeingScheduled, |
|
7596 isOpen, |
|
7597 isPostSavingLocked, |
|
7598 isPublishable, |
|
7599 isPublished, |
|
7600 isSaveable, |
|
7601 isSaving, |
|
7602 isAutoSaving, |
|
7603 isToggle, |
|
7604 onSave, |
|
7605 onStatusChange, |
|
7606 onSubmit = external_lodash_["noop"], |
|
7607 onToggle, |
|
7608 visibility, |
|
7609 hasNonPostEntityChanges |
|
7610 } = this.props; |
|
7611 const isButtonDisabled = isSaving || forceIsSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty; |
|
7612 const isToggleDisabled = isPublished || isSaving || forceIsSaving || !isSaveable || !isPublishable && !forceIsDirty; |
|
7613 let publishStatus; |
|
7614 |
|
7615 if (!hasPublishAction) { |
|
7616 publishStatus = 'pending'; |
|
7617 } else if (visibility === 'private') { |
|
7618 publishStatus = 'private'; |
|
7619 } else if (isBeingScheduled) { |
|
7620 publishStatus = 'future'; |
|
7621 } else { |
|
7622 publishStatus = 'publish'; |
9884 } |
7623 } |
9885 }, { |
7624 |
9886 key: "createOnClick", |
7625 const onClickButton = () => { |
9887 value: function createOnClick(callback) { |
7626 if (isButtonDisabled) { |
9888 var _this2 = this; |
7627 return; |
9889 |
|
9890 return function () { |
|
9891 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
|
9892 args[_key] = arguments[_key]; |
|
9893 } |
|
9894 |
|
9895 var hasNonPostEntityChanges = _this2.props.hasNonPostEntityChanges; |
|
9896 |
|
9897 if (hasNonPostEntityChanges) { |
|
9898 // The modal for multiple entity saving will open, |
|
9899 // hold the callback for saving/publishing the post |
|
9900 // so that we can call it if the post entity is checked. |
|
9901 _this2.setState({ |
|
9902 entitiesSavedStatesCallback: function entitiesSavedStatesCallback() { |
|
9903 return callback.apply(void 0, args); |
|
9904 } |
|
9905 }); // Open the save panel by setting its callback. |
|
9906 // To set a function on the useState hook, we must set it |
|
9907 // with another function (() => myFunction). Passing the |
|
9908 // function on its own will cause an error when called. |
|
9909 |
|
9910 |
|
9911 _this2.props.setEntitiesSavedStatesCallback(function () { |
|
9912 return _this2.closeEntitiesSavedStates; |
|
9913 }); |
|
9914 |
|
9915 return external_this_lodash_["noop"]; |
|
9916 } |
|
9917 |
|
9918 return callback.apply(void 0, args); |
|
9919 }; |
|
9920 } |
|
9921 }, { |
|
9922 key: "closeEntitiesSavedStates", |
|
9923 value: function closeEntitiesSavedStates(savedEntities) { |
|
9924 var _this$props = this.props, |
|
9925 postType = _this$props.postType, |
|
9926 postId = _this$props.postId; |
|
9927 var entitiesSavedStatesCallback = this.state.entitiesSavedStatesCallback; |
|
9928 this.setState({ |
|
9929 entitiesSavedStatesCallback: false |
|
9930 }, function () { |
|
9931 if (savedEntities && Object(external_this_lodash_["some"])(savedEntities, function (elt) { |
|
9932 return elt.kind === 'postType' && elt.name === postType && elt.key === postId; |
|
9933 })) { |
|
9934 // The post entity was checked, call the held callback from `createOnClick`. |
|
9935 entitiesSavedStatesCallback(); |
|
9936 } |
|
9937 }); |
|
9938 } |
|
9939 }, { |
|
9940 key: "render", |
|
9941 value: function render() { |
|
9942 var _this$props2 = this.props, |
|
9943 forceIsDirty = _this$props2.forceIsDirty, |
|
9944 forceIsSaving = _this$props2.forceIsSaving, |
|
9945 hasPublishAction = _this$props2.hasPublishAction, |
|
9946 isBeingScheduled = _this$props2.isBeingScheduled, |
|
9947 isOpen = _this$props2.isOpen, |
|
9948 isPostSavingLocked = _this$props2.isPostSavingLocked, |
|
9949 isPublishable = _this$props2.isPublishable, |
|
9950 isPublished = _this$props2.isPublished, |
|
9951 isSaveable = _this$props2.isSaveable, |
|
9952 isSaving = _this$props2.isSaving, |
|
9953 isToggle = _this$props2.isToggle, |
|
9954 onSave = _this$props2.onSave, |
|
9955 onStatusChange = _this$props2.onStatusChange, |
|
9956 _this$props2$onSubmit = _this$props2.onSubmit, |
|
9957 onSubmit = _this$props2$onSubmit === void 0 ? external_this_lodash_["noop"] : _this$props2$onSubmit, |
|
9958 onToggle = _this$props2.onToggle, |
|
9959 visibility = _this$props2.visibility, |
|
9960 hasNonPostEntityChanges = _this$props2.hasNonPostEntityChanges; |
|
9961 var isButtonDisabled = isSaving || forceIsSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty; |
|
9962 var isToggleDisabled = isPublished || isSaving || forceIsSaving || !isSaveable || !isPublishable && !forceIsDirty; |
|
9963 var publishStatus; |
|
9964 |
|
9965 if (!hasPublishAction) { |
|
9966 publishStatus = 'pending'; |
|
9967 } else if (visibility === 'private') { |
|
9968 publishStatus = 'private'; |
|
9969 } else if (isBeingScheduled) { |
|
9970 publishStatus = 'future'; |
|
9971 } else { |
|
9972 publishStatus = 'publish'; |
|
9973 } |
7628 } |
9974 |
7629 |
9975 var onClickButton = function onClickButton() { |
7630 onSubmit(); |
9976 if (isButtonDisabled) { |
7631 onStatusChange(publishStatus); |
9977 return; |
7632 onSave(); |
9978 } |
7633 }; |
9979 |
7634 |
9980 onSubmit(); |
7635 const onClickToggle = () => { |
9981 onStatusChange(publishStatus); |
7636 if (isToggleDisabled) { |
9982 onSave(); |
7637 return; |
9983 }; |
7638 } |
9984 |
7639 |
9985 var onClickToggle = function onClickToggle() { |
7640 onToggle(); |
9986 if (isToggleDisabled) { |
7641 }; |
9987 return; |
7642 |
9988 } |
7643 const buttonProps = { |
9989 |
7644 'aria-disabled': isButtonDisabled && !hasNonPostEntityChanges, |
9990 onToggle(); |
7645 className: 'editor-post-publish-button', |
9991 }; |
7646 isBusy: !isAutoSaving && isSaving && isPublished, |
9992 |
7647 isPrimary: true, |
9993 var buttonProps = { |
7648 onClick: this.createOnClick(onClickButton) |
9994 'aria-disabled': isButtonDisabled && !hasNonPostEntityChanges, |
7649 }; |
9995 className: 'editor-post-publish-button', |
7650 const toggleProps = { |
9996 isBusy: isSaving && isPublished, |
7651 'aria-disabled': isToggleDisabled && !hasNonPostEntityChanges, |
9997 isPrimary: true, |
7652 'aria-expanded': isOpen, |
9998 onClick: this.createOnClick(onClickButton) |
7653 className: 'editor-post-publish-panel__toggle', |
9999 }; |
7654 isBusy: isSaving && isPublished, |
10000 var toggleProps = { |
7655 isPrimary: true, |
10001 'aria-disabled': isToggleDisabled && !hasNonPostEntityChanges, |
7656 onClick: this.createOnClick(onClickToggle) |
10002 'aria-expanded': isOpen, |
7657 }; |
10003 className: 'editor-post-publish-panel__toggle', |
7658 const toggleChildren = isBeingScheduled ? Object(external_wp_i18n_["__"])('Schedule…') : Object(external_wp_i18n_["__"])('Publish'); |
10004 isBusy: isSaving && isPublished, |
7659 const buttonChildren = Object(external_wp_element_["createElement"])(post_publish_button_label, { |
10005 isPrimary: true, |
7660 forceIsSaving: forceIsSaving, |
10006 onClick: this.createOnClick(onClickToggle) |
7661 hasNonPostEntityChanges: hasNonPostEntityChanges |
10007 }; |
7662 }); |
10008 var toggleChildren = isBeingScheduled ? Object(external_this_wp_i18n_["__"])('Schedule…') : Object(external_this_wp_i18n_["__"])('Publish'); |
7663 const componentProps = isToggle ? toggleProps : buttonProps; |
10009 var buttonChildren = Object(external_this_wp_element_["createElement"])(post_publish_button_label, { |
7664 const componentChildren = isToggle ? toggleChildren : buttonChildren; |
10010 forceIsSaving: forceIsSaving, |
7665 return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({ |
10011 hasNonPostEntityChanges: hasNonPostEntityChanges |
7666 ref: this.buttonNode |
10012 }); |
7667 }, componentProps, { |
10013 var componentProps = isToggle ? toggleProps : buttonProps; |
7668 className: classnames_default()(componentProps.className, 'editor-post-publish-button__button', { |
10014 var componentChildren = isToggle ? toggleChildren : buttonChildren; |
7669 'has-changes-dot': hasNonPostEntityChanges |
10015 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], Object(esm_extends["a" /* default */])({ |
7670 }) |
10016 ref: this.buttonNode |
7671 }), componentChildren)); |
10017 }, componentProps, { |
7672 } |
10018 className: classnames_default()(componentProps.className, 'editor-post-publish-button__button', { |
7673 |
10019 'has-changes-dot': hasNonPostEntityChanges |
7674 } |
10020 }) |
7675 /* harmony default export */ var post_publish_button = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(select => { |
10021 }), componentChildren)); |
7676 const { |
10022 } |
7677 isSavingPost, |
10023 }]); |
7678 isAutosavingPost, |
10024 |
7679 isEditedPostBeingScheduled, |
10025 return PostPublishButton; |
7680 getEditedPostVisibility, |
10026 }(external_this_wp_element_["Component"]); |
7681 isCurrentPostPublished, |
10027 /* harmony default export */ var post_publish_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
7682 isEditedPostSaveable, |
10028 var _select = select('core/editor'), |
7683 isEditedPostPublishable, |
10029 isSavingPost = _select.isSavingPost, |
7684 isPostSavingLocked, |
10030 isEditedPostBeingScheduled = _select.isEditedPostBeingScheduled, |
7685 getCurrentPost, |
10031 getEditedPostVisibility = _select.getEditedPostVisibility, |
7686 getCurrentPostType, |
10032 isCurrentPostPublished = _select.isCurrentPostPublished, |
7687 getCurrentPostId, |
10033 isEditedPostSaveable = _select.isEditedPostSaveable, |
7688 hasNonPostEntityChanges |
10034 isEditedPostPublishable = _select.isEditedPostPublishable, |
7689 } = select('core/editor'); |
10035 isPostSavingLocked = _select.isPostSavingLocked, |
7690 |
10036 getCurrentPost = _select.getCurrentPost, |
7691 const _isAutoSaving = isAutosavingPost(); |
10037 getCurrentPostType = _select.getCurrentPostType, |
|
10038 getCurrentPostId = _select.getCurrentPostId, |
|
10039 hasNonPostEntityChanges = _select.hasNonPostEntityChanges; |
|
10040 |
7692 |
10041 return { |
7693 return { |
10042 isSaving: isSavingPost(), |
7694 isSaving: isSavingPost() || _isAutoSaving, |
|
7695 isAutoSaving: _isAutoSaving, |
10043 isBeingScheduled: isEditedPostBeingScheduled(), |
7696 isBeingScheduled: isEditedPostBeingScheduled(), |
10044 visibility: getEditedPostVisibility(), |
7697 visibility: getEditedPostVisibility(), |
10045 isSaveable: isEditedPostSaveable(), |
7698 isSaveable: isEditedPostSaveable(), |
10046 isPostSavingLocked: isPostSavingLocked(), |
7699 isPostSavingLocked: isPostSavingLocked(), |
10047 isPublishable: isEditedPostPublishable(), |
7700 isPublishable: isEditedPostPublishable(), |
10048 isPublished: isCurrentPostPublished(), |
7701 isPublished: isCurrentPostPublished(), |
10049 hasPublishAction: Object(external_this_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
7702 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
10050 postType: getCurrentPostType(), |
7703 postType: getCurrentPostType(), |
10051 postId: getCurrentPostId(), |
7704 postId: getCurrentPostId(), |
10052 hasNonPostEntityChanges: hasNonPostEntityChanges() |
7705 hasNonPostEntityChanges: hasNonPostEntityChanges() |
10053 }; |
7706 }; |
10054 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
7707 }), Object(external_wp_data_["withDispatch"])(dispatch => { |
10055 var _dispatch = dispatch('core/editor'), |
7708 const { |
10056 editPost = _dispatch.editPost, |
7709 editPost, |
10057 savePost = _dispatch.savePost; |
7710 savePost |
10058 |
7711 } = dispatch('core/editor'); |
10059 return { |
7712 return { |
10060 onStatusChange: function onStatusChange(status) { |
7713 onStatusChange: status => editPost({ |
10061 return editPost({ |
7714 status |
10062 status: status |
7715 }, { |
10063 }, { |
7716 undoIgnore: true |
10064 undoIgnore: true |
7717 }), |
10065 }); |
|
10066 }, |
|
10067 onSave: savePost |
7718 onSave: savePost |
10068 }; |
7719 }; |
10069 })])(post_publish_button_PostPublishButton)); |
7720 })])(post_publish_button_PostPublishButton)); |
10070 |
7721 |
10071 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js |
7722 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js |
10072 var close_small = __webpack_require__(177); |
7723 var close_small = __webpack_require__("bWcr"); |
|
7724 |
|
7725 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/wordpress.js |
|
7726 var wordpress = __webpack_require__("wduq"); |
10073 |
7727 |
10074 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/utils.js |
7728 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/utils.js |
10075 /** |
7729 /** |
10076 * WordPress dependencies |
7730 * WordPress dependencies |
10077 */ |
7731 */ |
10078 |
7732 |
10079 var visibilityOptions = [{ |
7733 const visibilityOptions = [{ |
10080 value: 'public', |
7734 value: 'public', |
10081 label: Object(external_this_wp_i18n_["__"])('Public'), |
7735 label: Object(external_wp_i18n_["__"])('Public'), |
10082 info: Object(external_this_wp_i18n_["__"])('Visible to everyone.') |
7736 info: Object(external_wp_i18n_["__"])('Visible to everyone.') |
10083 }, { |
7737 }, { |
10084 value: 'private', |
7738 value: 'private', |
10085 label: Object(external_this_wp_i18n_["__"])('Private'), |
7739 label: Object(external_wp_i18n_["__"])('Private'), |
10086 info: Object(external_this_wp_i18n_["__"])('Only visible to site admins and editors.') |
7740 info: Object(external_wp_i18n_["__"])('Only visible to site admins and editors.') |
10087 }, { |
7741 }, { |
10088 value: 'password', |
7742 value: 'password', |
10089 label: Object(external_this_wp_i18n_["__"])('Password Protected'), |
7743 label: Object(external_wp_i18n_["__"])('Password Protected'), |
10090 info: Object(external_this_wp_i18n_["__"])('Protected with a password you choose. Only those with the password can view this post.') |
7744 info: Object(external_wp_i18n_["__"])('Protected with a password you choose. Only those with the password can view this post.') |
10091 }]; |
7745 }]; |
10092 |
7746 |
10093 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/index.js |
7747 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/index.js |
10094 |
7748 |
10095 |
7749 |
10096 |
|
10097 |
|
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 function post_visibility_createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (post_visibility_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
10103 |
|
10104 function post_visibility_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
10105 |
|
10106 /** |
7750 /** |
10107 * WordPress dependencies |
7751 * WordPress dependencies |
10108 */ |
7752 */ |
10109 |
7753 |
10110 |
7754 |
10413 */ |
8062 */ |
10414 |
8063 |
10415 |
8064 |
10416 |
8065 |
10417 |
8066 |
10418 |
8067 /** |
10419 |
8068 * Internal dependencies |
10420 |
8069 */ |
10421 |
8070 |
10422 /** |
8071 |
10423 * Module constants |
8072 const MAX_MOST_USED_TERMS = 10; |
10424 */ |
8073 const DEFAULT_QUERY = { |
10425 |
8074 per_page: MAX_MOST_USED_TERMS, |
10426 var DEFAULT_QUERY = { |
|
10427 per_page: -1, |
|
10428 orderby: 'count', |
8075 orderby: 'count', |
10429 order: 'desc', |
8076 order: 'desc', |
10430 _fields: 'id,name' |
8077 hide_empty: true, |
|
8078 _fields: 'id,name,count' |
10431 }; |
8079 }; |
10432 var MAX_TERMS_SUGGESTIONS = 20; |
8080 function MostUsedTerms({ |
10433 |
8081 onSelect, |
10434 var isSameTermName = function isSameTermName(termA, termB) { |
8082 taxonomy |
10435 return termA.toLowerCase() === termB.toLowerCase(); |
8083 }) { |
|
8084 const { |
|
8085 _terms, |
|
8086 showTerms |
|
8087 } = Object(external_wp_data_["useSelect"])(select => { |
|
8088 const mostUsedTerms = select(external_wp_coreData_["store"]).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY); |
|
8089 return { |
|
8090 _terms: mostUsedTerms, |
|
8091 showTerms: (mostUsedTerms === null || mostUsedTerms === void 0 ? void 0 : mostUsedTerms.length) >= MAX_MOST_USED_TERMS |
|
8092 }; |
|
8093 }, []); |
|
8094 |
|
8095 if (!showTerms) { |
|
8096 return null; |
|
8097 } |
|
8098 |
|
8099 const terms = unescapeTerms(_terms); |
|
8100 const label = Object(external_lodash_["get"])(taxonomy, ['labels', 'most_used']); |
|
8101 return Object(external_wp_element_["createElement"])("div", { |
|
8102 className: "editor-post-taxonomies__flat-term-most-used" |
|
8103 }, Object(external_wp_element_["createElement"])("h3", { |
|
8104 className: "editor-post-taxonomies__flat-term-most-used-label" |
|
8105 }, label), Object(external_wp_element_["createElement"])("ul", { |
|
8106 role: "list", |
|
8107 className: "editor-post-taxonomies__flat-term-most-used-list" |
|
8108 }, terms.map(term => Object(external_wp_element_["createElement"])("li", { |
|
8109 key: term.id |
|
8110 }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
8111 isLink: true, |
|
8112 onClick: () => onSelect(term) |
|
8113 }, term.name))))); |
|
8114 } |
|
8115 |
|
8116 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/flat-term-selector.js |
|
8117 |
|
8118 |
|
8119 /** |
|
8120 * External dependencies |
|
8121 */ |
|
8122 |
|
8123 /** |
|
8124 * WordPress dependencies |
|
8125 */ |
|
8126 |
|
8127 |
|
8128 |
|
8129 |
|
8130 |
|
8131 |
|
8132 |
|
8133 |
|
8134 |
|
8135 /** |
|
8136 * Internal dependencies |
|
8137 */ |
|
8138 |
|
8139 |
|
8140 |
|
8141 |
|
8142 /** |
|
8143 * Module constants |
|
8144 */ |
|
8145 |
|
8146 const MAX_TERMS_SUGGESTIONS = 20; |
|
8147 const flat_term_selector_DEFAULT_QUERY = { |
|
8148 per_page: MAX_TERMS_SUGGESTIONS, |
|
8149 orderby: 'count', |
|
8150 order: 'desc', |
|
8151 _fields: 'id,name,count' |
10436 }; |
8152 }; |
10437 /** |
8153 |
10438 * Returns a term object with name unescaped. |
8154 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase(); |
10439 * The unescape of the name property is done using lodash unescape function. |
8155 |
10440 * |
8156 const termNamesToIds = (names, terms) => { |
10441 * @param {Object} term The term object to unescape. |
8157 return names.map(termName => Object(external_lodash_["find"])(terms, term => isSameTermName(term.name, termName)).id); |
10442 * |
|
10443 * @return {Object} Term object with name property unescaped. |
|
10444 */ |
|
10445 |
|
10446 |
|
10447 var flat_term_selector_unescapeTerm = function unescapeTerm(term) { |
|
10448 return flat_term_selector_objectSpread({}, term, { |
|
10449 name: Object(external_this_lodash_["unescape"])(term.name) |
|
10450 }); |
|
10451 }; |
8158 }; |
10452 /** |
8159 |
10453 * Returns an array of term objects with names unescaped. |
8160 class flat_term_selector_FlatTermSelector extends external_wp_element_["Component"] { |
10454 * The unescape of each term is performed using the unescapeTerm function. |
8161 constructor() { |
10455 * |
8162 super(...arguments); |
10456 * @param {Object[]} terms Array of term objects to unescape. |
8163 this.onChange = this.onChange.bind(this); |
10457 * |
8164 this.searchTerms = Object(external_lodash_["debounce"])(this.searchTerms.bind(this), 500); |
10458 * @return {Object[]} Array of term objects unescaped. |
8165 this.findOrCreateTerm = this.findOrCreateTerm.bind(this); |
10459 */ |
8166 this.appendTerm = this.appendTerm.bind(this); |
10460 |
8167 this.state = { |
10461 |
8168 loading: !Object(external_lodash_["isEmpty"])(this.props.terms), |
10462 var flat_term_selector_unescapeTerms = function unescapeTerms(terms) { |
|
10463 return Object(external_this_lodash_["map"])(terms, flat_term_selector_unescapeTerm); |
|
10464 }; |
|
10465 |
|
10466 var flat_term_selector_FlatTermSelector = /*#__PURE__*/function (_Component) { |
|
10467 Object(inherits["a" /* default */])(FlatTermSelector, _Component); |
|
10468 |
|
10469 var _super = flat_term_selector_createSuper(FlatTermSelector); |
|
10470 |
|
10471 function FlatTermSelector() { |
|
10472 var _this; |
|
10473 |
|
10474 Object(classCallCheck["a" /* default */])(this, FlatTermSelector); |
|
10475 |
|
10476 _this = _super.apply(this, arguments); |
|
10477 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
10478 _this.searchTerms = Object(external_this_lodash_["throttle"])(_this.searchTerms.bind(Object(assertThisInitialized["a" /* default */])(_this)), 500); |
|
10479 _this.findOrCreateTerm = _this.findOrCreateTerm.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
10480 _this.state = { |
|
10481 loading: !Object(external_this_lodash_["isEmpty"])(_this.props.terms), |
|
10482 availableTerms: [], |
8169 availableTerms: [], |
10483 selectedTerms: [] |
8170 selectedTerms: [] |
10484 }; |
8171 }; |
10485 return _this; |
8172 } |
10486 } |
8173 |
10487 |
8174 componentDidMount() { |
10488 Object(createClass["a" /* default */])(FlatTermSelector, [{ |
8175 if (!Object(external_lodash_["isEmpty"])(this.props.terms)) { |
10489 key: "componentDidMount", |
8176 this.initRequest = this.fetchTerms({ |
10490 value: function componentDidMount() { |
8177 include: this.props.terms.join(','), |
10491 var _this2 = this; |
8178 per_page: -1 |
10492 |
8179 }); |
10493 if (!Object(external_this_lodash_["isEmpty"])(this.props.terms)) { |
8180 this.initRequest.then(() => { |
10494 this.initRequest = this.fetchTerms({ |
8181 this.setState({ |
10495 include: this.props.terms.join(','), |
8182 loading: false |
10496 per_page: -1 |
|
10497 }); |
8183 }); |
10498 this.initRequest.then(function () { |
8184 }, xhr => { |
10499 _this2.setState({ |
8185 if (xhr.statusText === 'abort') { |
10500 loading: false |
8186 return; |
10501 }); |
8187 } |
10502 }, function (xhr) { |
8188 |
10503 if (xhr.statusText === 'abort') { |
8189 this.setState({ |
10504 return; |
8190 loading: false |
10505 } |
8191 }); |
10506 |
8192 }); |
10507 _this2.setState({ |
8193 } |
10508 loading: false |
8194 } |
10509 }); |
8195 |
|
8196 componentWillUnmount() { |
|
8197 Object(external_lodash_["invoke"])(this.initRequest, ['abort']); |
|
8198 Object(external_lodash_["invoke"])(this.searchRequest, ['abort']); |
|
8199 } |
|
8200 |
|
8201 componentDidUpdate(prevProps) { |
|
8202 if (prevProps.terms !== this.props.terms) { |
|
8203 this.updateSelectedTerms(this.props.terms); |
|
8204 } |
|
8205 } |
|
8206 |
|
8207 fetchTerms(params = {}) { |
|
8208 const { |
|
8209 taxonomy |
|
8210 } = this.props; |
|
8211 const query = { ...flat_term_selector_DEFAULT_QUERY, |
|
8212 ...params |
|
8213 }; |
|
8214 const request = external_wp_apiFetch_default()({ |
|
8215 path: Object(external_wp_url_["addQueryArgs"])(`/wp/v2/${taxonomy.rest_base}`, query) |
|
8216 }); |
|
8217 request.then(unescapeTerms).then(terms => { |
|
8218 this.setState(state => ({ |
|
8219 availableTerms: state.availableTerms.concat(terms.filter(term => !Object(external_lodash_["find"])(state.availableTerms, availableTerm => availableTerm.id === term.id))) |
|
8220 })); |
|
8221 this.updateSelectedTerms(this.props.terms); |
|
8222 }); |
|
8223 return request; |
|
8224 } |
|
8225 |
|
8226 updateSelectedTerms(terms = []) { |
|
8227 const selectedTerms = terms.reduce((accumulator, termId) => { |
|
8228 const termObject = Object(external_lodash_["find"])(this.state.availableTerms, term => term.id === termId); |
|
8229 |
|
8230 if (termObject) { |
|
8231 accumulator.push(termObject.name); |
|
8232 } |
|
8233 |
|
8234 return accumulator; |
|
8235 }, []); |
|
8236 this.setState({ |
|
8237 selectedTerms |
|
8238 }); |
|
8239 } |
|
8240 |
|
8241 findOrCreateTerm(termName) { |
|
8242 const { |
|
8243 taxonomy |
|
8244 } = this.props; |
|
8245 const termNameEscaped = Object(external_lodash_["escape"])(termName); // Tries to create a term or fetch it if it already exists. |
|
8246 |
|
8247 return external_wp_apiFetch_default()({ |
|
8248 path: `/wp/v2/${taxonomy.rest_base}`, |
|
8249 method: 'POST', |
|
8250 data: { |
|
8251 name: termNameEscaped |
|
8252 } |
|
8253 }).catch(error => { |
|
8254 const errorCode = error.code; |
|
8255 |
|
8256 if (errorCode === 'term_exists') { |
|
8257 // If the terms exist, fetch it instead of creating a new one. |
|
8258 this.addRequest = external_wp_apiFetch_default()({ |
|
8259 path: Object(external_wp_url_["addQueryArgs"])(`/wp/v2/${taxonomy.rest_base}`, { ...flat_term_selector_DEFAULT_QUERY, |
|
8260 search: termNameEscaped |
|
8261 }) |
|
8262 }).then(unescapeTerms); |
|
8263 return this.addRequest.then(searchResult => { |
|
8264 return Object(external_lodash_["find"])(searchResult, result => isSameTermName(result.name, termName)); |
10510 }); |
8265 }); |
10511 } |
8266 } |
|
8267 |
|
8268 return Promise.reject(error); |
|
8269 }).then(unescapeTerm); |
|
8270 } |
|
8271 |
|
8272 onChange(termNames) { |
|
8273 const uniqueTerms = Object(external_lodash_["uniqBy"])(termNames, term => term.toLowerCase()); |
|
8274 this.setState({ |
|
8275 selectedTerms: uniqueTerms |
|
8276 }); |
|
8277 const newTermNames = uniqueTerms.filter(termName => !Object(external_lodash_["find"])(this.state.availableTerms, term => isSameTermName(term.name, termName))); |
|
8278 |
|
8279 if (newTermNames.length === 0) { |
|
8280 return this.props.onUpdateTerms(termNamesToIds(uniqueTerms, this.state.availableTerms), this.props.taxonomy.rest_base); |
10512 } |
8281 } |
10513 }, { |
8282 |
10514 key: "componentWillUnmount", |
8283 Promise.all(newTermNames.map(this.findOrCreateTerm)).then(newTerms => { |
10515 value: function componentWillUnmount() { |
8284 const newAvailableTerms = this.state.availableTerms.concat(newTerms); |
10516 Object(external_this_lodash_["invoke"])(this.initRequest, ['abort']); |
8285 this.setState({ |
10517 Object(external_this_lodash_["invoke"])(this.searchRequest, ['abort']); |
8286 availableTerms: newAvailableTerms |
10518 } |
|
10519 }, { |
|
10520 key: "componentDidUpdate", |
|
10521 value: function componentDidUpdate(prevProps) { |
|
10522 if (prevProps.terms !== this.props.terms) { |
|
10523 this.updateSelectedTerms(this.props.terms); |
|
10524 } |
|
10525 } |
|
10526 }, { |
|
10527 key: "fetchTerms", |
|
10528 value: function fetchTerms() { |
|
10529 var _this3 = this; |
|
10530 |
|
10531 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
10532 var taxonomy = this.props.taxonomy; |
|
10533 |
|
10534 var query = flat_term_selector_objectSpread({}, DEFAULT_QUERY, {}, params); |
|
10535 |
|
10536 var request = external_this_wp_apiFetch_default()({ |
|
10537 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), query) |
|
10538 }); |
8287 }); |
10539 request.then(flat_term_selector_unescapeTerms).then(function (terms) { |
8288 return this.props.onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms), this.props.taxonomy.rest_base); |
10540 _this3.setState(function (state) { |
8289 }); |
10541 return { |
8290 } |
10542 availableTerms: state.availableTerms.concat(terms.filter(function (term) { |
8291 |
10543 return !Object(external_this_lodash_["find"])(state.availableTerms, function (availableTerm) { |
8292 searchTerms(search = '') { |
10544 return availableTerm.id === term.id; |
8293 Object(external_lodash_["invoke"])(this.searchRequest, ['abort']); |
10545 }); |
8294 |
10546 })) |
8295 if (search.length >= 3) { |
10547 }; |
8296 this.searchRequest = this.fetchTerms({ |
10548 }); |
8297 search |
10549 |
|
10550 _this3.updateSelectedTerms(_this3.props.terms); |
|
10551 }); |
|
10552 return request; |
|
10553 } |
|
10554 }, { |
|
10555 key: "updateSelectedTerms", |
|
10556 value: function updateSelectedTerms() { |
|
10557 var _this4 = this; |
|
10558 |
|
10559 var terms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
10560 var selectedTerms = terms.reduce(function (accumulator, termId) { |
|
10561 var termObject = Object(external_this_lodash_["find"])(_this4.state.availableTerms, function (term) { |
|
10562 return term.id === termId; |
|
10563 }); |
|
10564 |
|
10565 if (termObject) { |
|
10566 accumulator.push(termObject.name); |
|
10567 } |
|
10568 |
|
10569 return accumulator; |
|
10570 }, []); |
|
10571 this.setState({ |
|
10572 selectedTerms: selectedTerms |
|
10573 }); |
8298 }); |
10574 } |
8299 } |
10575 }, { |
8300 } |
10576 key: "findOrCreateTerm", |
8301 |
10577 value: function findOrCreateTerm(termName) { |
8302 appendTerm(newTerm) { |
10578 var _this5 = this; |
8303 const { |
10579 |
8304 onUpdateTerms, |
10580 var taxonomy = this.props.taxonomy; |
8305 taxonomy, |
10581 var termNameEscaped = Object(external_this_lodash_["escape"])(termName); // Tries to create a term or fetch it if it already exists. |
8306 terms = [], |
10582 |
8307 slug, |
10583 return external_this_wp_apiFetch_default()({ |
8308 speak |
10584 path: "/wp/v2/".concat(taxonomy.rest_base), |
8309 } = this.props; |
10585 method: 'POST', |
8310 |
10586 data: { |
8311 if (terms.includes(newTerm.id)) { |
10587 name: termNameEscaped |
8312 return; |
10588 } |
|
10589 }).catch(function (error) { |
|
10590 var errorCode = error.code; |
|
10591 |
|
10592 if (errorCode === 'term_exists') { |
|
10593 // If the terms exist, fetch it instead of creating a new one. |
|
10594 _this5.addRequest = external_this_wp_apiFetch_default()({ |
|
10595 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), flat_term_selector_objectSpread({}, DEFAULT_QUERY, { |
|
10596 search: termNameEscaped |
|
10597 })) |
|
10598 }).then(flat_term_selector_unescapeTerms); |
|
10599 return _this5.addRequest.then(function (searchResult) { |
|
10600 return Object(external_this_lodash_["find"])(searchResult, function (result) { |
|
10601 return isSameTermName(result.name, termName); |
|
10602 }); |
|
10603 }); |
|
10604 } |
|
10605 |
|
10606 return Promise.reject(error); |
|
10607 }).then(flat_term_selector_unescapeTerm); |
|
10608 } |
8313 } |
10609 }, { |
8314 |
10610 key: "onChange", |
8315 const newTerms = [...terms, newTerm.id]; |
10611 value: function onChange(termNames) { |
8316 const termAddedMessage = Object(external_wp_i18n_["sprintf"])( |
10612 var _this6 = this; |
8317 /* translators: %s: term name. */ |
10613 |
8318 Object(external_wp_i18n_["_x"])('%s added', 'term'), Object(external_lodash_["get"])(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? Object(external_wp_i18n_["__"])('Tag') : Object(external_wp_i18n_["__"])('Term'))); |
10614 var uniqueTerms = Object(external_this_lodash_["uniqBy"])(termNames, function (term) { |
8319 speak(termAddedMessage, 'assertive'); |
10615 return term.toLowerCase(); |
8320 this.setState({ |
10616 }); |
8321 availableTerms: [...this.state.availableTerms, newTerm] |
10617 this.setState({ |
8322 }); |
10618 selectedTerms: uniqueTerms |
8323 onUpdateTerms(newTerms, taxonomy.rest_base); |
10619 }); |
8324 } |
10620 var newTermNames = uniqueTerms.filter(function (termName) { |
8325 |
10621 return !Object(external_this_lodash_["find"])(_this6.state.availableTerms, function (term) { |
8326 render() { |
10622 return isSameTermName(term.name, termName); |
8327 const { |
10623 }); |
8328 slug, |
10624 }); |
8329 taxonomy, |
10625 |
8330 hasAssignAction |
10626 var termNamesToIds = function termNamesToIds(names, availableTerms) { |
8331 } = this.props; |
10627 return names.map(function (termName) { |
8332 |
10628 return Object(external_this_lodash_["find"])(availableTerms, function (term) { |
8333 if (!hasAssignAction) { |
10629 return isSameTermName(term.name, termName); |
8334 return null; |
10630 }).id; |
8335 } |
10631 }); |
8336 |
10632 }; |
8337 const { |
10633 |
8338 loading, |
10634 if (newTermNames.length === 0) { |
8339 availableTerms, |
10635 return this.props.onUpdateTerms(termNamesToIds(uniqueTerms, this.state.availableTerms), this.props.taxonomy.rest_base); |
8340 selectedTerms |
|
8341 } = this.state; |
|
8342 const termNames = availableTerms.map(term => term.name); |
|
8343 const newTermLabel = Object(external_lodash_["get"])(taxonomy, ['labels', 'add_new_item'], slug === 'post_tag' ? Object(external_wp_i18n_["__"])('Add new tag') : Object(external_wp_i18n_["__"])('Add new Term')); |
|
8344 const singularName = Object(external_lodash_["get"])(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? Object(external_wp_i18n_["__"])('Tag') : Object(external_wp_i18n_["__"])('Term')); |
|
8345 const termAddedLabel = Object(external_wp_i18n_["sprintf"])( |
|
8346 /* translators: %s: term name. */ |
|
8347 Object(external_wp_i18n_["_x"])('%s added', 'term'), singularName); |
|
8348 const termRemovedLabel = Object(external_wp_i18n_["sprintf"])( |
|
8349 /* translators: %s: term name. */ |
|
8350 Object(external_wp_i18n_["_x"])('%s removed', 'term'), singularName); |
|
8351 const removeTermLabel = Object(external_wp_i18n_["sprintf"])( |
|
8352 /* translators: %s: term name. */ |
|
8353 Object(external_wp_i18n_["_x"])('Remove %s', 'term'), singularName); |
|
8354 return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["FormTokenField"], { |
|
8355 value: selectedTerms, |
|
8356 suggestions: termNames, |
|
8357 onChange: this.onChange, |
|
8358 onInputChange: this.searchTerms, |
|
8359 maxSuggestions: MAX_TERMS_SUGGESTIONS, |
|
8360 disabled: loading, |
|
8361 label: newTermLabel, |
|
8362 messages: { |
|
8363 added: termAddedLabel, |
|
8364 removed: termRemovedLabel, |
|
8365 remove: removeTermLabel |
10636 } |
8366 } |
10637 |
8367 }), Object(external_wp_element_["createElement"])(MostUsedTerms, { |
10638 Promise.all(newTermNames.map(this.findOrCreateTerm)).then(function (newTerms) { |
8368 taxonomy: taxonomy, |
10639 var newAvailableTerms = _this6.state.availableTerms.concat(newTerms); |
8369 onSelect: this.appendTerm |
10640 |
8370 })); |
10641 _this6.setState({ |
8371 } |
10642 availableTerms: newAvailableTerms |
8372 |
10643 }); |
8373 } |
10644 |
8374 |
10645 return _this6.props.onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms), _this6.props.taxonomy.rest_base); |
8375 /* harmony default export */ var flat_term_selector = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])((select, { |
|
8376 slug |
|
8377 }) => { |
|
8378 const { |
|
8379 getCurrentPost |
|
8380 } = select(store); |
|
8381 const { |
|
8382 getTaxonomy |
|
8383 } = select(external_wp_coreData_["store"]); |
|
8384 const taxonomy = getTaxonomy(slug); |
|
8385 return { |
|
8386 hasCreateAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-create-' + taxonomy.rest_base], false) : false, |
|
8387 hasAssignAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-assign-' + taxonomy.rest_base], false) : false, |
|
8388 terms: taxonomy ? select(store).getEditedPostAttribute(taxonomy.rest_base) : [], |
|
8389 taxonomy |
|
8390 }; |
|
8391 }), Object(external_wp_data_["withDispatch"])(dispatch => { |
|
8392 return { |
|
8393 onUpdateTerms(terms, restBase) { |
|
8394 dispatch(store).editPost({ |
|
8395 [restBase]: terms |
10646 }); |
8396 }); |
10647 } |
8397 } |
10648 }, { |
8398 |
10649 key: "searchTerms", |
|
10650 value: function searchTerms() { |
|
10651 var search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
10652 Object(external_this_lodash_["invoke"])(this.searchRequest, ['abort']); |
|
10653 this.searchRequest = this.fetchTerms({ |
|
10654 search: search |
|
10655 }); |
|
10656 } |
|
10657 }, { |
|
10658 key: "render", |
|
10659 value: function render() { |
|
10660 var _this$props = this.props, |
|
10661 slug = _this$props.slug, |
|
10662 taxonomy = _this$props.taxonomy, |
|
10663 hasAssignAction = _this$props.hasAssignAction; |
|
10664 |
|
10665 if (!hasAssignAction) { |
|
10666 return null; |
|
10667 } |
|
10668 |
|
10669 var _this$state = this.state, |
|
10670 loading = _this$state.loading, |
|
10671 availableTerms = _this$state.availableTerms, |
|
10672 selectedTerms = _this$state.selectedTerms; |
|
10673 var termNames = availableTerms.map(function (term) { |
|
10674 return term.name; |
|
10675 }); |
|
10676 var newTermLabel = Object(external_this_lodash_["get"])(taxonomy, ['labels', 'add_new_item'], slug === 'post_tag' ? Object(external_this_wp_i18n_["__"])('Add new tag') : Object(external_this_wp_i18n_["__"])('Add new Term')); |
|
10677 var singularName = Object(external_this_lodash_["get"])(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? Object(external_this_wp_i18n_["__"])('Tag') : Object(external_this_wp_i18n_["__"])('Term')); |
|
10678 var termAddedLabel = Object(external_this_wp_i18n_["sprintf"])( |
|
10679 /* translators: %s: term name. */ |
|
10680 Object(external_this_wp_i18n_["_x"])('%s added', 'term'), singularName); |
|
10681 var termRemovedLabel = Object(external_this_wp_i18n_["sprintf"])( |
|
10682 /* translators: %s: term name. */ |
|
10683 Object(external_this_wp_i18n_["_x"])('%s removed', 'term'), singularName); |
|
10684 var removeTermLabel = Object(external_this_wp_i18n_["sprintf"])( |
|
10685 /* translators: %s: term name. */ |
|
10686 Object(external_this_wp_i18n_["_x"])('Remove %s', 'term'), singularName); |
|
10687 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["FormTokenField"], { |
|
10688 value: selectedTerms, |
|
10689 suggestions: termNames, |
|
10690 onChange: this.onChange, |
|
10691 onInputChange: this.searchTerms, |
|
10692 maxSuggestions: MAX_TERMS_SUGGESTIONS, |
|
10693 disabled: loading, |
|
10694 label: newTermLabel, |
|
10695 messages: { |
|
10696 added: termAddedLabel, |
|
10697 removed: termRemovedLabel, |
|
10698 remove: removeTermLabel |
|
10699 } |
|
10700 }); |
|
10701 } |
|
10702 }]); |
|
10703 |
|
10704 return FlatTermSelector; |
|
10705 }(external_this_wp_element_["Component"]); |
|
10706 |
|
10707 /* harmony default export */ var flat_term_selector = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
10708 var slug = _ref.slug; |
|
10709 |
|
10710 var _select = select('core/editor'), |
|
10711 getCurrentPost = _select.getCurrentPost; |
|
10712 |
|
10713 var _select2 = select('core'), |
|
10714 getTaxonomy = _select2.getTaxonomy; |
|
10715 |
|
10716 var taxonomy = getTaxonomy(slug); |
|
10717 return { |
|
10718 hasCreateAction: taxonomy ? Object(external_this_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-create-' + taxonomy.rest_base], false) : false, |
|
10719 hasAssignAction: taxonomy ? Object(external_this_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-assign-' + taxonomy.rest_base], false) : false, |
|
10720 terms: taxonomy ? select('core/editor').getEditedPostAttribute(taxonomy.rest_base) : [], |
|
10721 taxonomy: taxonomy |
|
10722 }; |
8399 }; |
10723 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
8400 }), external_wp_components_["withSpokenMessages"], Object(external_wp_components_["withFilters"])('editor.PostTaxonomyType'))(flat_term_selector_FlatTermSelector)); |
10724 return { |
|
10725 onUpdateTerms: function onUpdateTerms(terms, restBase) { |
|
10726 dispatch('core/editor').editPost(Object(defineProperty["a" /* default */])({}, restBase, terms)); |
|
10727 } |
|
10728 }; |
|
10729 }), Object(external_this_wp_components_["withFilters"])('editor.PostTaxonomyType'))(flat_term_selector_FlatTermSelector)); |
|
10730 |
8401 |
10731 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-tags-panel.js |
8402 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-tags-panel.js |
10732 |
8403 |
10733 |
8404 |
10734 |
|
10735 |
|
10736 |
|
10737 |
|
10738 |
|
10739 function maybe_tags_panel_createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (maybe_tags_panel_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
10740 |
|
10741 function maybe_tags_panel_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
10742 |
|
10743 /** |
8405 /** |
10744 * External dependencies |
8406 * External dependencies |
10745 */ |
8407 */ |
10746 |
8408 |
10747 /** |
8409 /** |
11184 */ |
8844 */ |
11185 |
8845 |
11186 |
8846 |
11187 |
8847 |
11188 |
8848 |
11189 var post_publish_panel_PostPublishPanel = /*#__PURE__*/function (_Component) { |
8849 class post_publish_panel_PostPublishPanel extends external_wp_element_["Component"] { |
11190 Object(inherits["a" /* default */])(PostPublishPanel, _Component); |
8850 constructor() { |
11191 |
8851 super(...arguments); |
11192 var _super = post_publish_panel_createSuper(PostPublishPanel); |
8852 this.onSubmit = this.onSubmit.bind(this); |
11193 |
8853 } |
11194 function PostPublishPanel() { |
8854 |
11195 var _this; |
8855 componentDidUpdate(prevProps) { |
11196 |
8856 // Automatically collapse the publish sidebar when a post |
11197 Object(classCallCheck["a" /* default */])(this, PostPublishPanel); |
8857 // is published and the user makes an edit. |
11198 |
8858 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) { |
11199 _this = _super.apply(this, arguments); |
8859 this.props.onClose(); |
11200 _this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11201 return _this; |
|
11202 } |
|
11203 |
|
11204 Object(createClass["a" /* default */])(PostPublishPanel, [{ |
|
11205 key: "componentDidUpdate", |
|
11206 value: function componentDidUpdate(prevProps) { |
|
11207 // Automatically collapse the publish sidebar when a post |
|
11208 // is published and the user makes an edit. |
|
11209 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) { |
|
11210 this.props.onClose(); |
|
11211 } |
|
11212 } |
8860 } |
11213 }, { |
8861 } |
11214 key: "onSubmit", |
8862 |
11215 value: function onSubmit() { |
8863 onSubmit() { |
11216 var _this$props = this.props, |
8864 const { |
11217 onClose = _this$props.onClose, |
8865 onClose, |
11218 hasPublishAction = _this$props.hasPublishAction, |
8866 hasPublishAction, |
11219 isPostTypeViewable = _this$props.isPostTypeViewable; |
8867 isPostTypeViewable |
11220 |
8868 } = this.props; |
11221 if (!hasPublishAction || !isPostTypeViewable) { |
8869 |
11222 onClose(); |
8870 if (!hasPublishAction || !isPostTypeViewable) { |
11223 } |
8871 onClose(); |
11224 } |
8872 } |
11225 }, { |
8873 } |
11226 key: "render", |
8874 |
11227 value: function render() { |
8875 render() { |
11228 var _this$props2 = this.props, |
8876 const { |
11229 forceIsDirty = _this$props2.forceIsDirty, |
8877 forceIsDirty, |
11230 forceIsSaving = _this$props2.forceIsSaving, |
8878 forceIsSaving, |
11231 isBeingScheduled = _this$props2.isBeingScheduled, |
8879 isBeingScheduled, |
11232 isPublished = _this$props2.isPublished, |
8880 isPublished, |
11233 isPublishSidebarEnabled = _this$props2.isPublishSidebarEnabled, |
8881 isPublishSidebarEnabled, |
11234 isScheduled = _this$props2.isScheduled, |
8882 isScheduled, |
11235 isSaving = _this$props2.isSaving, |
8883 isSaving, |
11236 onClose = _this$props2.onClose, |
8884 onClose, |
11237 onTogglePublishSidebar = _this$props2.onTogglePublishSidebar, |
8885 onTogglePublishSidebar, |
11238 PostPublishExtension = _this$props2.PostPublishExtension, |
8886 PostPublishExtension, |
11239 PrePublishExtension = _this$props2.PrePublishExtension, |
8887 PrePublishExtension, |
11240 additionalProps = Object(objectWithoutProperties["a" /* default */])(_this$props2, ["forceIsDirty", "forceIsSaving", "isBeingScheduled", "isPublished", "isPublishSidebarEnabled", "isScheduled", "isSaving", "onClose", "onTogglePublishSidebar", "PostPublishExtension", "PrePublishExtension"]); |
8888 ...additionalProps |
11241 |
8889 } = this.props; |
11242 var propsForPanel = Object(external_this_lodash_["omit"])(additionalProps, ['hasPublishAction', 'isDirty', 'isPostTypeViewable']); |
8890 const propsForPanel = Object(external_lodash_["omit"])(additionalProps, ['hasPublishAction', 'isDirty', 'isPostTypeViewable']); |
11243 var isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled; |
8891 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled; |
11244 var isPrePublish = !isPublishedOrScheduled && !isSaving; |
8892 const isPrePublish = !isPublishedOrScheduled && !isSaving; |
11245 var isPostPublish = isPublishedOrScheduled && !isSaving; |
8893 const isPostPublish = isPublishedOrScheduled && !isSaving; |
11246 return Object(external_this_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({ |
8894 return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({ |
11247 className: "editor-post-publish-panel" |
8895 className: "editor-post-publish-panel" |
11248 }, propsForPanel), Object(external_this_wp_element_["createElement"])("div", { |
8896 }, propsForPanel), Object(external_wp_element_["createElement"])("div", { |
11249 className: "editor-post-publish-panel__header" |
8897 className: "editor-post-publish-panel__header" |
11250 }, isPostPublish ? Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
8898 }, isPostPublish ? Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
11251 onClick: onClose, |
8899 onClick: onClose, |
11252 icon: close_small["a" /* default */], |
8900 icon: close_small["a" /* default */], |
11253 label: Object(external_this_wp_i18n_["__"])('Close panel') |
8901 label: Object(external_wp_i18n_["__"])('Close panel') |
11254 }) : Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])("div", { |
8902 }) : Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", { |
11255 className: "editor-post-publish-panel__header-publish-button" |
8903 className: "editor-post-publish-panel__header-publish-button" |
11256 }, Object(external_this_wp_element_["createElement"])(post_publish_button, { |
8904 }, Object(external_wp_element_["createElement"])(post_publish_button, { |
11257 focusOnMount: true, |
8905 focusOnMount: true, |
11258 onSubmit: this.onSubmit, |
8906 onSubmit: this.onSubmit, |
11259 forceIsDirty: forceIsDirty, |
8907 forceIsDirty: forceIsDirty, |
11260 forceIsSaving: forceIsSaving |
8908 forceIsSaving: forceIsSaving |
11261 })), Object(external_this_wp_element_["createElement"])("div", { |
8909 })), Object(external_wp_element_["createElement"])("div", { |
11262 className: "editor-post-publish-panel__header-cancel-button" |
8910 className: "editor-post-publish-panel__header-cancel-button" |
11263 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
8911 }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
11264 onClick: onClose, |
8912 onClick: onClose, |
11265 label: Object(external_this_wp_i18n_["__"])('Close panel'), |
8913 isSecondary: true |
11266 isSecondary: true |
8914 }, Object(external_wp_i18n_["__"])('Cancel'))))), Object(external_wp_element_["createElement"])("div", { |
11267 }, Object(external_this_wp_i18n_["__"])('Cancel'))))), Object(external_this_wp_element_["createElement"])("div", { |
8915 className: "editor-post-publish-panel__content" |
11268 className: "editor-post-publish-panel__content" |
8916 }, isPrePublish && Object(external_wp_element_["createElement"])(prepublish, null, PrePublishExtension && Object(external_wp_element_["createElement"])(PrePublishExtension, null)), isPostPublish && Object(external_wp_element_["createElement"])(postpublish, { |
11269 }, isPrePublish && Object(external_this_wp_element_["createElement"])(prepublish, null, PrePublishExtension && Object(external_this_wp_element_["createElement"])(PrePublishExtension, null)), isPostPublish && Object(external_this_wp_element_["createElement"])(postpublish, { |
8917 focusOnMount: true |
11270 focusOnMount: true |
8918 }, PostPublishExtension && Object(external_wp_element_["createElement"])(PostPublishExtension, null)), isSaving && Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null)), Object(external_wp_element_["createElement"])("div", { |
11271 }, PostPublishExtension && Object(external_this_wp_element_["createElement"])(PostPublishExtension, null)), isSaving && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Spinner"], null)), Object(external_this_wp_element_["createElement"])("div", { |
8919 className: "editor-post-publish-panel__footer" |
11272 className: "editor-post-publish-panel__footer" |
8920 }, Object(external_wp_element_["createElement"])(external_wp_components_["CheckboxControl"], { |
11273 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
8921 label: Object(external_wp_i18n_["__"])('Always show pre-publish checks.'), |
11274 label: Object(external_this_wp_i18n_["__"])('Always show pre-publish checks.'), |
8922 checked: isPublishSidebarEnabled, |
11275 checked: isPublishSidebarEnabled, |
8923 onChange: onTogglePublishSidebar |
11276 onChange: onTogglePublishSidebar |
8924 }))); |
11277 }))); |
8925 } |
11278 } |
8926 |
11279 }]); |
8927 } |
11280 |
8928 /* harmony default export */ var post_publish_panel = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(select => { |
11281 return PostPublishPanel; |
8929 const { |
11282 }(external_this_wp_element_["Component"]); |
8930 getPostType |
11283 /* harmony default export */ var post_publish_panel = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
8931 } = select('core'); |
11284 var _select = select('core'), |
8932 const { |
11285 getPostType = _select.getPostType; |
8933 getCurrentPost, |
11286 |
8934 getEditedPostAttribute, |
11287 var _select2 = select('core/editor'), |
8935 isCurrentPostPublished, |
11288 getCurrentPost = _select2.getCurrentPost, |
8936 isCurrentPostScheduled, |
11289 getEditedPostAttribute = _select2.getEditedPostAttribute, |
8937 isEditedPostBeingScheduled, |
11290 isCurrentPostPublished = _select2.isCurrentPostPublished, |
8938 isEditedPostDirty, |
11291 isCurrentPostScheduled = _select2.isCurrentPostScheduled, |
8939 isSavingPost |
11292 isEditedPostBeingScheduled = _select2.isEditedPostBeingScheduled, |
8940 } = select('core/editor'); |
11293 isEditedPostDirty = _select2.isEditedPostDirty, |
8941 const { |
11294 isSavingPost = _select2.isSavingPost; |
8942 isPublishSidebarEnabled |
11295 |
8943 } = select('core/editor'); |
11296 var _select3 = select('core/editor'), |
8944 const postType = getPostType(getEditedPostAttribute('type')); |
11297 isPublishSidebarEnabled = _select3.isPublishSidebarEnabled; |
|
11298 |
|
11299 var postType = getPostType(getEditedPostAttribute('type')); |
|
11300 return { |
8945 return { |
11301 hasPublishAction: Object(external_this_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
8946 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
11302 isPostTypeViewable: Object(external_this_lodash_["get"])(postType, ['viewable'], false), |
8947 isPostTypeViewable: Object(external_lodash_["get"])(postType, ['viewable'], false), |
11303 isBeingScheduled: isEditedPostBeingScheduled(), |
8948 isBeingScheduled: isEditedPostBeingScheduled(), |
11304 isDirty: isEditedPostDirty(), |
8949 isDirty: isEditedPostDirty(), |
11305 isPublished: isCurrentPostPublished(), |
8950 isPublished: isCurrentPostPublished(), |
11306 isPublishSidebarEnabled: isPublishSidebarEnabled(), |
8951 isPublishSidebarEnabled: isPublishSidebarEnabled(), |
11307 isSaving: isSavingPost(), |
8952 isSaving: isSavingPost(), |
11308 isScheduled: isCurrentPostScheduled() |
8953 isScheduled: isCurrentPostScheduled() |
11309 }; |
8954 }; |
11310 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref) { |
8955 }), Object(external_wp_data_["withDispatch"])((dispatch, { |
11311 var isPublishSidebarEnabled = _ref.isPublishSidebarEnabled; |
8956 isPublishSidebarEnabled |
11312 |
8957 }) => { |
11313 var _dispatch = dispatch('core/editor'), |
8958 const { |
11314 disablePublishSidebar = _dispatch.disablePublishSidebar, |
8959 disablePublishSidebar, |
11315 enablePublishSidebar = _dispatch.enablePublishSidebar; |
8960 enablePublishSidebar |
11316 |
8961 } = dispatch('core/editor'); |
11317 return { |
8962 return { |
11318 onTogglePublishSidebar: function onTogglePublishSidebar() { |
8963 onTogglePublishSidebar: () => { |
11319 if (isPublishSidebarEnabled) { |
8964 if (isPublishSidebarEnabled) { |
11320 disablePublishSidebar(); |
8965 disablePublishSidebar(); |
11321 } else { |
8966 } else { |
11322 enablePublishSidebar(); |
8967 enablePublishSidebar(); |
11323 } |
8968 } |
11324 } |
8969 } |
11325 }; |
8970 }; |
11326 }), external_this_wp_components_["withFocusReturn"], external_this_wp_components_["withConstrainedTabbing"]])(post_publish_panel_PostPublishPanel)); |
8971 }), external_wp_components_["withFocusReturn"], external_wp_components_["withConstrainedTabbing"]])(post_publish_panel_PostPublishPanel)); |
11327 |
8972 |
11328 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js |
8973 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js |
11329 var build_module_icon = __webpack_require__(137); |
8974 var build_module_icon = __webpack_require__("iClF"); |
11330 |
8975 |
11331 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud.js |
8976 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud.js |
11332 |
8977 |
11333 |
8978 |
11334 /** |
8979 /** |
11335 * WordPress dependencies |
8980 * WordPress dependencies |
11336 */ |
8981 */ |
11337 |
8982 |
11338 var cloud = Object(external_this_wp_element_["createElement"])(external_this_wp_primitives_["SVG"], { |
8983 const cloud = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], { |
11339 xmlns: "http://www.w3.org/2000/svg", |
8984 xmlns: "http://www.w3.org/2000/svg", |
11340 viewBox: "-2 -2 24 24" |
8985 viewBox: "0 0 24 24" |
11341 }, Object(external_this_wp_element_["createElement"])(external_this_wp_primitives_["Path"], { |
8986 }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], { |
11342 d: "M14.9 9c1.8.2 3.1 1.7 3.1 3.5 0 1.9-1.6 3.5-3.5 3.5h-10C2.6 16 1 14.4 1 12.5 1 10.7 2.3 9.3 4.1 9 4 8.9 4 8.7 4 8.5 4 7.1 5.1 6 6.5 6c.3 0 .7.1.9.2C8.1 4.9 9.4 4 11 4c2.2 0 4 1.8 4 4 0 .4-.1.7-.1 1z" |
8987 d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z" |
11343 })); |
8988 })); |
11344 /* harmony default export */ var library_cloud = (cloud); |
8989 /* harmony default export */ var library_cloud = (cloud); |
11345 |
8990 |
11346 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js |
8991 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js |
11347 var library_check = __webpack_require__(155); |
8992 var library_check = __webpack_require__("RMJe"); |
11348 |
8993 |
11349 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud-upload.js |
8994 // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud-upload.js |
11350 |
8995 |
11351 |
8996 |
11352 /** |
8997 /** |
11353 * WordPress dependencies |
8998 * WordPress dependencies |
11354 */ |
8999 */ |
11355 |
9000 |
11356 var cloudUpload = Object(external_this_wp_element_["createElement"])(external_this_wp_primitives_["SVG"], { |
9001 const cloudUpload = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], { |
11357 xmlns: "http://www.w3.org/2000/svg", |
9002 xmlns: "http://www.w3.org/2000/svg", |
11358 viewBox: "-2 -2 24 24" |
9003 viewBox: "0 0 24 24" |
11359 }, Object(external_this_wp_element_["createElement"])(external_this_wp_primitives_["Path"], { |
9004 }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], { |
11360 d: "M14.8 9c.1-.3.2-.6.2-1 0-2.2-1.8-4-4-4-1.5 0-2.9.9-3.5 2.2-.3-.1-.7-.2-1-.2C5.1 6 4 7.1 4 8.5c0 .2 0 .4.1.5-1.8.3-3.1 1.7-3.1 3.5C1 14.4 2.6 16 4.5 16H8v-3H5l4.5-4.5L14 13h-3v3h3.5c1.9 0 3.5-1.6 3.5-3.5 0-1.8-1.4-3.3-3.2-3.5z" |
9005 d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-4v-2.4L14 14l1-1-3-3-3 3 1 1 1.2-1.2v2.4H7.7c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4H9l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8 0 1-.8 1.8-1.7 1.8z" |
11361 })); |
9006 })); |
11362 /* harmony default export */ var cloud_upload = (cloudUpload); |
9007 /* harmony default export */ var cloud_upload = (cloudUpload); |
11363 |
9008 |
11364 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-switch-to-draft-button/index.js |
9009 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-switch-to-draft-button/index.js |
11365 |
9010 |
11900 |
9476 |
11901 /** |
9477 /** |
11902 * Module Constants |
9478 * Module Constants |
11903 */ |
9479 */ |
11904 |
9480 |
11905 var hierarchical_term_selector_DEFAULT_QUERY = { |
9481 const hierarchical_term_selector_DEFAULT_QUERY = { |
11906 per_page: -1, |
9482 per_page: -1, |
11907 orderby: 'name', |
9483 orderby: 'name', |
11908 order: 'asc', |
9484 order: 'asc', |
11909 _fields: 'id,name,parent' |
9485 _fields: 'id,name,parent' |
11910 }; |
9486 }; |
11911 var MIN_TERMS_COUNT_FOR_FILTER = 8; |
9487 const MIN_TERMS_COUNT_FOR_FILTER = 8; |
11912 |
9488 |
11913 var hierarchical_term_selector_HierarchicalTermSelector = /*#__PURE__*/function (_Component) { |
9489 class hierarchical_term_selector_HierarchicalTermSelector extends external_wp_element_["Component"] { |
11914 Object(inherits["a" /* default */])(HierarchicalTermSelector, _Component); |
9490 constructor() { |
11915 |
9491 super(...arguments); |
11916 var _super = hierarchical_term_selector_createSuper(HierarchicalTermSelector); |
9492 this.findTerm = this.findTerm.bind(this); |
11917 |
9493 this.onChange = this.onChange.bind(this); |
11918 function HierarchicalTermSelector() { |
9494 this.onChangeFormName = this.onChangeFormName.bind(this); |
11919 var _this; |
9495 this.onChangeFormParent = this.onChangeFormParent.bind(this); |
11920 |
9496 this.onAddTerm = this.onAddTerm.bind(this); |
11921 Object(classCallCheck["a" /* default */])(this, HierarchicalTermSelector); |
9497 this.onToggleForm = this.onToggleForm.bind(this); |
11922 |
9498 this.setFilterValue = this.setFilterValue.bind(this); |
11923 _this = _super.apply(this, arguments); |
9499 this.sortBySelected = this.sortBySelected.bind(this); |
11924 _this.findTerm = _this.findTerm.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
9500 this.state = { |
11925 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11926 _this.onChangeFormName = _this.onChangeFormName.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11927 _this.onChangeFormParent = _this.onChangeFormParent.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11928 _this.onAddTerm = _this.onAddTerm.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11929 _this.onToggleForm = _this.onToggleForm.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11930 _this.setFilterValue = _this.setFilterValue.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11931 _this.sortBySelected = _this.sortBySelected.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
11932 _this.state = { |
|
11933 loading: true, |
9501 loading: true, |
11934 availableTermsTree: [], |
9502 availableTermsTree: [], |
11935 availableTerms: [], |
9503 availableTerms: [], |
11936 adding: false, |
9504 adding: false, |
11937 formName: '', |
9505 formName: '', |
11938 formParent: '', |
9506 formParent: '', |
11939 showForm: false, |
9507 showForm: false, |
11940 filterValue: '', |
9508 filterValue: '', |
11941 filteredTermsTree: [] |
9509 filteredTermsTree: [] |
11942 }; |
9510 }; |
11943 return _this; |
9511 } |
11944 } |
9512 |
11945 |
9513 onChange(termId) { |
11946 Object(createClass["a" /* default */])(HierarchicalTermSelector, [{ |
9514 const { |
11947 key: "onChange", |
9515 onUpdateTerms, |
11948 value: function onChange(termId) { |
9516 terms = [], |
11949 var _this$props = this.props, |
9517 taxonomy |
11950 onUpdateTerms = _this$props.onUpdateTerms, |
9518 } = this.props; |
11951 _this$props$terms = _this$props.terms, |
9519 const hasTerm = terms.indexOf(termId) !== -1; |
11952 terms = _this$props$terms === void 0 ? [] : _this$props$terms, |
9520 const newTerms = hasTerm ? Object(external_lodash_["without"])(terms, termId) : [...terms, termId]; |
11953 taxonomy = _this$props.taxonomy; |
9521 onUpdateTerms(newTerms, taxonomy.rest_base); |
11954 var hasTerm = terms.indexOf(termId) !== -1; |
9522 } |
11955 var newTerms = hasTerm ? Object(external_this_lodash_["without"])(terms, termId) : [].concat(Object(toConsumableArray["a" /* default */])(terms), [termId]); |
9523 |
11956 onUpdateTerms(newTerms, taxonomy.rest_base); |
9524 onChangeFormName(event) { |
|
9525 const newValue = event.target.value.trim() === '' ? '' : event.target.value; |
|
9526 this.setState({ |
|
9527 formName: newValue |
|
9528 }); |
|
9529 } |
|
9530 |
|
9531 onChangeFormParent(newParent) { |
|
9532 this.setState({ |
|
9533 formParent: newParent |
|
9534 }); |
|
9535 } |
|
9536 |
|
9537 onToggleForm() { |
|
9538 this.setState(state => ({ |
|
9539 showForm: !state.showForm |
|
9540 })); |
|
9541 } |
|
9542 |
|
9543 findTerm(terms, parent, name) { |
|
9544 return Object(external_lodash_["find"])(terms, term => { |
|
9545 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase(); |
|
9546 }); |
|
9547 } |
|
9548 |
|
9549 onAddTerm(event) { |
|
9550 event.preventDefault(); |
|
9551 const { |
|
9552 onUpdateTerms, |
|
9553 taxonomy, |
|
9554 terms, |
|
9555 slug |
|
9556 } = this.props; |
|
9557 const { |
|
9558 formName, |
|
9559 formParent, |
|
9560 adding, |
|
9561 availableTerms |
|
9562 } = this.state; |
|
9563 |
|
9564 if (formName === '' || adding) { |
|
9565 return; |
|
9566 } // check if the term we are adding already exists |
|
9567 |
|
9568 |
|
9569 const existingTerm = this.findTerm(availableTerms, formParent, formName); |
|
9570 |
|
9571 if (existingTerm) { |
|
9572 // if the term we are adding exists but is not selected select it |
|
9573 if (!Object(external_lodash_["some"])(terms, term => term === existingTerm.id)) { |
|
9574 onUpdateTerms([...terms, existingTerm.id], taxonomy.rest_base); |
|
9575 } |
|
9576 |
|
9577 this.setState({ |
|
9578 formName: '', |
|
9579 formParent: '' |
|
9580 }); |
|
9581 return; |
11957 } |
9582 } |
11958 }, { |
9583 |
11959 key: "onChangeFormName", |
9584 this.setState({ |
11960 value: function onChangeFormName(event) { |
9585 adding: true |
11961 var newValue = event.target.value.trim() === '' ? '' : event.target.value; |
9586 }); |
|
9587 this.addRequest = external_wp_apiFetch_default()({ |
|
9588 path: `/wp/v2/${taxonomy.rest_base}`, |
|
9589 method: 'POST', |
|
9590 data: { |
|
9591 name: formName, |
|
9592 parent: formParent ? formParent : undefined |
|
9593 } |
|
9594 }); // Tries to create a term or fetch it if it already exists |
|
9595 |
|
9596 const findOrCreatePromise = this.addRequest.catch(error => { |
|
9597 const errorCode = error.code; |
|
9598 |
|
9599 if (errorCode === 'term_exists') { |
|
9600 // search the new category created since last fetch |
|
9601 this.addRequest = external_wp_apiFetch_default()({ |
|
9602 path: Object(external_wp_url_["addQueryArgs"])(`/wp/v2/${taxonomy.rest_base}`, { ...hierarchical_term_selector_DEFAULT_QUERY, |
|
9603 parent: formParent || 0, |
|
9604 search: formName |
|
9605 }) |
|
9606 }); |
|
9607 return this.addRequest.then(searchResult => { |
|
9608 return this.findTerm(searchResult, formParent, formName); |
|
9609 }); |
|
9610 } |
|
9611 |
|
9612 return Promise.reject(error); |
|
9613 }); |
|
9614 findOrCreatePromise.then(term => { |
|
9615 const hasTerm = !!Object(external_lodash_["find"])(this.state.availableTerms, availableTerm => availableTerm.id === term.id); |
|
9616 const newAvailableTerms = hasTerm ? this.state.availableTerms : [term, ...this.state.availableTerms]; |
|
9617 const termAddedMessage = Object(external_wp_i18n_["sprintf"])( |
|
9618 /* translators: %s: taxonomy name */ |
|
9619 Object(external_wp_i18n_["_x"])('%s added', 'term'), Object(external_lodash_["get"])(this.props.taxonomy, ['labels', 'singular_name'], slug === 'category' ? Object(external_wp_i18n_["__"])('Category') : Object(external_wp_i18n_["__"])('Term'))); |
|
9620 this.props.speak(termAddedMessage, 'assertive'); |
|
9621 this.addRequest = null; |
11962 this.setState({ |
9622 this.setState({ |
11963 formName: newValue |
9623 adding: false, |
|
9624 formName: '', |
|
9625 formParent: '', |
|
9626 availableTerms: newAvailableTerms, |
|
9627 availableTermsTree: this.sortBySelected(buildTermsTree(newAvailableTerms)) |
11964 }); |
9628 }); |
11965 } |
9629 onUpdateTerms([...terms, term.id], taxonomy.rest_base); |
11966 }, { |
9630 }, xhr => { |
11967 key: "onChangeFormParent", |
9631 if (xhr.statusText === 'abort') { |
11968 value: function onChangeFormParent(newParent) { |
|
11969 this.setState({ |
|
11970 formParent: newParent |
|
11971 }); |
|
11972 } |
|
11973 }, { |
|
11974 key: "onToggleForm", |
|
11975 value: function onToggleForm() { |
|
11976 this.setState(function (state) { |
|
11977 return { |
|
11978 showForm: !state.showForm |
|
11979 }; |
|
11980 }); |
|
11981 } |
|
11982 }, { |
|
11983 key: "findTerm", |
|
11984 value: function findTerm(terms, parent, name) { |
|
11985 return Object(external_this_lodash_["find"])(terms, function (term) { |
|
11986 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase(); |
|
11987 }); |
|
11988 } |
|
11989 }, { |
|
11990 key: "onAddTerm", |
|
11991 value: function onAddTerm(event) { |
|
11992 var _this2 = this; |
|
11993 |
|
11994 event.preventDefault(); |
|
11995 var _this$props2 = this.props, |
|
11996 onUpdateTerms = _this$props2.onUpdateTerms, |
|
11997 taxonomy = _this$props2.taxonomy, |
|
11998 terms = _this$props2.terms, |
|
11999 slug = _this$props2.slug; |
|
12000 var _this$state = this.state, |
|
12001 formName = _this$state.formName, |
|
12002 formParent = _this$state.formParent, |
|
12003 adding = _this$state.adding, |
|
12004 availableTerms = _this$state.availableTerms; |
|
12005 |
|
12006 if (formName === '' || adding) { |
|
12007 return; |
|
12008 } // check if the term we are adding already exists |
|
12009 |
|
12010 |
|
12011 var existingTerm = this.findTerm(availableTerms, formParent, formName); |
|
12012 |
|
12013 if (existingTerm) { |
|
12014 // if the term we are adding exists but is not selected select it |
|
12015 if (!Object(external_this_lodash_["some"])(terms, function (term) { |
|
12016 return term === existingTerm.id; |
|
12017 })) { |
|
12018 onUpdateTerms([].concat(Object(toConsumableArray["a" /* default */])(terms), [existingTerm.id]), taxonomy.rest_base); |
|
12019 } |
|
12020 |
|
12021 this.setState({ |
|
12022 formName: '', |
|
12023 formParent: '' |
|
12024 }); |
|
12025 return; |
9632 return; |
12026 } |
9633 } |
12027 |
9634 |
|
9635 this.addRequest = null; |
12028 this.setState({ |
9636 this.setState({ |
12029 adding: true |
9637 adding: false |
12030 }); |
9638 }); |
12031 this.addRequest = external_this_wp_apiFetch_default()({ |
9639 }); |
12032 path: "/wp/v2/".concat(taxonomy.rest_base), |
9640 } |
12033 method: 'POST', |
9641 |
12034 data: { |
9642 componentDidMount() { |
12035 name: formName, |
9643 this.fetchTerms(); |
12036 parent: formParent ? formParent : undefined |
9644 } |
12037 } |
9645 |
12038 }); // Tries to create a term or fetch it if it already exists |
9646 componentWillUnmount() { |
12039 |
9647 Object(external_lodash_["invoke"])(this.fetchRequest, ['abort']); |
12040 var findOrCreatePromise = this.addRequest.catch(function (error) { |
9648 Object(external_lodash_["invoke"])(this.addRequest, ['abort']); |
12041 var errorCode = error.code; |
9649 } |
12042 |
9650 |
12043 if (errorCode === 'term_exists') { |
9651 componentDidUpdate(prevProps) { |
12044 // search the new category created since last fetch |
9652 if (this.props.taxonomy !== prevProps.taxonomy) { |
12045 _this2.addRequest = external_this_wp_apiFetch_default()({ |
|
12046 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), hierarchical_term_selector_objectSpread({}, hierarchical_term_selector_DEFAULT_QUERY, { |
|
12047 parent: formParent || 0, |
|
12048 search: formName |
|
12049 })) |
|
12050 }); |
|
12051 return _this2.addRequest.then(function (searchResult) { |
|
12052 return _this2.findTerm(searchResult, formParent, formName); |
|
12053 }); |
|
12054 } |
|
12055 |
|
12056 return Promise.reject(error); |
|
12057 }); |
|
12058 findOrCreatePromise.then(function (term) { |
|
12059 var hasTerm = !!Object(external_this_lodash_["find"])(_this2.state.availableTerms, function (availableTerm) { |
|
12060 return availableTerm.id === term.id; |
|
12061 }); |
|
12062 var newAvailableTerms = hasTerm ? _this2.state.availableTerms : [term].concat(Object(toConsumableArray["a" /* default */])(_this2.state.availableTerms)); |
|
12063 var termAddedMessage = Object(external_this_wp_i18n_["sprintf"])( |
|
12064 /* translators: %s: taxonomy name */ |
|
12065 Object(external_this_wp_i18n_["_x"])('%s added', 'term'), Object(external_this_lodash_["get"])(_this2.props.taxonomy, ['labels', 'singular_name'], slug === 'category' ? Object(external_this_wp_i18n_["__"])('Category') : Object(external_this_wp_i18n_["__"])('Term'))); |
|
12066 |
|
12067 _this2.props.speak(termAddedMessage, 'assertive'); |
|
12068 |
|
12069 _this2.addRequest = null; |
|
12070 |
|
12071 _this2.setState({ |
|
12072 adding: false, |
|
12073 formName: '', |
|
12074 formParent: '', |
|
12075 availableTerms: newAvailableTerms, |
|
12076 availableTermsTree: _this2.sortBySelected(buildTermsTree(newAvailableTerms)) |
|
12077 }); |
|
12078 |
|
12079 onUpdateTerms([].concat(Object(toConsumableArray["a" /* default */])(terms), [term.id]), taxonomy.rest_base); |
|
12080 }, function (xhr) { |
|
12081 if (xhr.statusText === 'abort') { |
|
12082 return; |
|
12083 } |
|
12084 |
|
12085 _this2.addRequest = null; |
|
12086 |
|
12087 _this2.setState({ |
|
12088 adding: false |
|
12089 }); |
|
12090 }); |
|
12091 } |
|
12092 }, { |
|
12093 key: "componentDidMount", |
|
12094 value: function componentDidMount() { |
|
12095 this.fetchTerms(); |
9653 this.fetchTerms(); |
12096 } |
9654 } |
12097 }, { |
9655 } |
12098 key: "componentWillUnmount", |
9656 |
12099 value: function componentWillUnmount() { |
9657 fetchTerms() { |
12100 Object(external_this_lodash_["invoke"])(this.fetchRequest, ['abort']); |
9658 const { |
12101 Object(external_this_lodash_["invoke"])(this.addRequest, ['abort']); |
9659 taxonomy |
|
9660 } = this.props; |
|
9661 |
|
9662 if (!taxonomy) { |
|
9663 return; |
12102 } |
9664 } |
12103 }, { |
9665 |
12104 key: "componentDidUpdate", |
9666 this.fetchRequest = external_wp_apiFetch_default()({ |
12105 value: function componentDidUpdate(prevProps) { |
9667 path: Object(external_wp_url_["addQueryArgs"])(`/wp/v2/${taxonomy.rest_base}`, hierarchical_term_selector_DEFAULT_QUERY) |
12106 if (this.props.taxonomy !== prevProps.taxonomy) { |
9668 }); |
12107 this.fetchTerms(); |
9669 this.fetchRequest.then(terms => { |
12108 } |
9670 // resolve |
12109 } |
9671 const availableTermsTree = this.sortBySelected(buildTermsTree(terms)); |
12110 }, { |
9672 this.fetchRequest = null; |
12111 key: "fetchTerms", |
9673 this.setState({ |
12112 value: function fetchTerms() { |
9674 loading: false, |
12113 var _this3 = this; |
9675 availableTermsTree, |
12114 |
9676 availableTerms: terms |
12115 var taxonomy = this.props.taxonomy; |
9677 }); |
12116 |
9678 }, xhr => { |
12117 if (!taxonomy) { |
9679 // reject |
|
9680 if (xhr.statusText === 'abort') { |
12118 return; |
9681 return; |
12119 } |
9682 } |
12120 |
9683 |
12121 this.fetchRequest = external_this_wp_apiFetch_default()({ |
9684 this.fetchRequest = null; |
12122 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), hierarchical_term_selector_DEFAULT_QUERY) |
9685 this.setState({ |
|
9686 loading: false |
12123 }); |
9687 }); |
12124 this.fetchRequest.then(function (terms) { |
9688 }); |
12125 // resolve |
9689 } |
12126 var availableTermsTree = _this3.sortBySelected(buildTermsTree(terms)); |
9690 |
12127 |
9691 sortBySelected(termsTree) { |
12128 _this3.fetchRequest = null; |
9692 const { |
12129 |
9693 terms |
12130 _this3.setState({ |
9694 } = this.props; |
12131 loading: false, |
9695 |
12132 availableTermsTree: availableTermsTree, |
9696 const treeHasSelection = termTree => { |
12133 availableTerms: terms |
9697 if (terms.indexOf(termTree.id) !== -1) { |
12134 }); |
9698 return true; |
12135 }, function (xhr) { |
9699 } |
12136 // reject |
9700 |
12137 if (xhr.statusText === 'abort') { |
9701 if (undefined === termTree.children) { |
12138 return; |
9702 return false; |
|
9703 } |
|
9704 |
|
9705 const anyChildIsSelected = termTree.children.map(treeHasSelection).filter(child => child).length > 0; |
|
9706 |
|
9707 if (anyChildIsSelected) { |
|
9708 return true; |
|
9709 } |
|
9710 |
|
9711 return false; |
|
9712 }; |
|
9713 |
|
9714 const termOrChildIsSelected = (termA, termB) => { |
|
9715 const termASelected = treeHasSelection(termA); |
|
9716 const termBSelected = treeHasSelection(termB); |
|
9717 |
|
9718 if (termASelected === termBSelected) { |
|
9719 return 0; |
|
9720 } |
|
9721 |
|
9722 if (termASelected && !termBSelected) { |
|
9723 return -1; |
|
9724 } |
|
9725 |
|
9726 if (!termASelected && termBSelected) { |
|
9727 return 1; |
|
9728 } |
|
9729 |
|
9730 return 0; |
|
9731 }; |
|
9732 |
|
9733 termsTree.sort(termOrChildIsSelected); |
|
9734 return termsTree; |
|
9735 } |
|
9736 |
|
9737 setFilterValue(event) { |
|
9738 const { |
|
9739 availableTermsTree |
|
9740 } = this.state; |
|
9741 const filterValue = event.target.value; |
|
9742 const filteredTermsTree = availableTermsTree.map(this.getFilterMatcher(filterValue)).filter(term => term); |
|
9743 |
|
9744 const getResultCount = terms => { |
|
9745 let count = 0; |
|
9746 |
|
9747 for (let i = 0; i < terms.length; i++) { |
|
9748 count++; |
|
9749 |
|
9750 if (undefined !== terms[i].children) { |
|
9751 count += getResultCount(terms[i].children); |
12139 } |
9752 } |
12140 |
9753 } |
12141 _this3.fetchRequest = null; |
9754 |
12142 |
9755 return count; |
12143 _this3.setState({ |
9756 }; |
12144 loading: false |
9757 |
12145 }); |
9758 this.setState({ |
12146 }); |
9759 filterValue, |
|
9760 filteredTermsTree |
|
9761 }); |
|
9762 const resultCount = getResultCount(filteredTermsTree); |
|
9763 const resultsFoundMessage = Object(external_wp_i18n_["sprintf"])( |
|
9764 /* translators: %d: number of results */ |
|
9765 Object(external_wp_i18n_["_n"])('%d result found.', '%d results found.', resultCount), resultCount); |
|
9766 this.props.debouncedSpeak(resultsFoundMessage, 'assertive'); |
|
9767 } |
|
9768 |
|
9769 getFilterMatcher(filterValue) { |
|
9770 const matchTermsForFilter = originalTerm => { |
|
9771 if ('' === filterValue) { |
|
9772 return originalTerm; |
|
9773 } // Shallow clone, because we'll be filtering the term's children and |
|
9774 // don't want to modify the original term. |
|
9775 |
|
9776 |
|
9777 const term = { ...originalTerm |
|
9778 }; // Map and filter the children, recursive so we deal with grandchildren |
|
9779 // and any deeper levels. |
|
9780 |
|
9781 if (term.children.length > 0) { |
|
9782 term.children = term.children.map(matchTermsForFilter).filter(child => child); |
|
9783 } // If the term's name contains the filterValue, or it has children |
|
9784 // (i.e. some child matched at some point in the tree) then return it. |
|
9785 |
|
9786 |
|
9787 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) { |
|
9788 return term; |
|
9789 } // Otherwise, return false. After mapping, the list of terms will need |
|
9790 // to have false values filtered out. |
|
9791 |
|
9792 |
|
9793 return false; |
|
9794 }; |
|
9795 |
|
9796 return matchTermsForFilter; |
|
9797 } |
|
9798 |
|
9799 renderTerms(renderedTerms) { |
|
9800 const { |
|
9801 terms = [] |
|
9802 } = this.props; |
|
9803 return renderedTerms.map(term => { |
|
9804 return Object(external_wp_element_["createElement"])("div", { |
|
9805 key: term.id, |
|
9806 className: "editor-post-taxonomies__hierarchical-terms-choice" |
|
9807 }, Object(external_wp_element_["createElement"])(external_wp_components_["CheckboxControl"], { |
|
9808 checked: terms.indexOf(term.id) !== -1, |
|
9809 onChange: () => { |
|
9810 const termId = parseInt(term.id, 10); |
|
9811 this.onChange(termId); |
|
9812 }, |
|
9813 label: Object(external_lodash_["unescape"])(term.name) |
|
9814 }), !!term.children.length && Object(external_wp_element_["createElement"])("div", { |
|
9815 className: "editor-post-taxonomies__hierarchical-terms-subchoices" |
|
9816 }, this.renderTerms(term.children))); |
|
9817 }); |
|
9818 } |
|
9819 |
|
9820 render() { |
|
9821 const { |
|
9822 slug, |
|
9823 taxonomy, |
|
9824 instanceId, |
|
9825 hasCreateAction, |
|
9826 hasAssignAction |
|
9827 } = this.props; |
|
9828 |
|
9829 if (!hasAssignAction) { |
|
9830 return null; |
12147 } |
9831 } |
12148 }, { |
9832 |
12149 key: "sortBySelected", |
9833 const { |
12150 value: function sortBySelected(termsTree) { |
9834 availableTermsTree, |
12151 var terms = this.props.terms; |
9835 availableTerms, |
12152 |
9836 filteredTermsTree, |
12153 var treeHasSelection = function treeHasSelection(termTree) { |
9837 formName, |
12154 if (terms.indexOf(termTree.id) !== -1) { |
9838 formParent, |
12155 return true; |
9839 loading, |
12156 } |
9840 showForm, |
12157 |
9841 filterValue |
12158 if (undefined === termTree.children) { |
9842 } = this.state; |
12159 return false; |
9843 |
12160 } |
9844 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => Object(external_lodash_["get"])(taxonomy, ['labels', labelProperty], slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory); |
12161 |
9845 |
12162 var anyChildIsSelected = termTree.children.map(treeHasSelection).filter(function (child) { |
9846 const newTermButtonLabel = labelWithFallback('add_new_item', Object(external_wp_i18n_["__"])('Add new category'), Object(external_wp_i18n_["__"])('Add new term')); |
12163 return child; |
9847 const newTermLabel = labelWithFallback('new_item_name', Object(external_wp_i18n_["__"])('Add new category'), Object(external_wp_i18n_["__"])('Add new term')); |
12164 }).length > 0; |
9848 const parentSelectLabel = labelWithFallback('parent_item', Object(external_wp_i18n_["__"])('Parent Category'), Object(external_wp_i18n_["__"])('Parent Term')); |
12165 |
9849 const noParentOption = `— ${parentSelectLabel} —`; |
12166 if (anyChildIsSelected) { |
9850 const newTermSubmitLabel = newTermButtonLabel; |
12167 return true; |
9851 const inputId = `editor-post-taxonomies__hierarchical-terms-input-${instanceId}`; |
12168 } |
9852 const filterInputId = `editor-post-taxonomies__hierarchical-terms-filter-${instanceId}`; |
12169 |
9853 const filterLabel = Object(external_lodash_["get"])(this.props.taxonomy, ['labels', 'search_items'], Object(external_wp_i18n_["__"])('Search Terms')); |
12170 return false; |
9854 const groupLabel = Object(external_lodash_["get"])(this.props.taxonomy, ['name'], Object(external_wp_i18n_["__"])('Terms')); |
12171 }; |
9855 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER; |
12172 |
9856 return [showFilter && Object(external_wp_element_["createElement"])("label", { |
12173 var termOrChildIsSelected = function termOrChildIsSelected(termA, termB) { |
9857 key: "filter-label", |
12174 var termASelected = treeHasSelection(termA); |
9858 htmlFor: filterInputId |
12175 var termBSelected = treeHasSelection(termB); |
9859 }, filterLabel), showFilter && Object(external_wp_element_["createElement"])("input", { |
12176 |
9860 type: "search", |
12177 if (termASelected === termBSelected) { |
9861 id: filterInputId, |
12178 return 0; |
9862 value: filterValue, |
12179 } |
9863 onChange: this.setFilterValue, |
12180 |
9864 className: "editor-post-taxonomies__hierarchical-terms-filter", |
12181 if (termASelected && !termBSelected) { |
9865 key: "term-filter-input" |
12182 return -1; |
9866 }), Object(external_wp_element_["createElement"])("div", { |
12183 } |
9867 className: "editor-post-taxonomies__hierarchical-terms-list", |
12184 |
9868 key: "term-list", |
12185 if (!termASelected && termBSelected) { |
9869 tabIndex: "0", |
12186 return 1; |
9870 role: "group", |
12187 } |
9871 "aria-label": groupLabel |
12188 |
9872 }, this.renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)), !loading && hasCreateAction && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
12189 return 0; |
9873 key: "term-add-button", |
12190 }; |
9874 onClick: this.onToggleForm, |
12191 |
9875 className: "editor-post-taxonomies__hierarchical-terms-add", |
12192 termsTree.sort(termOrChildIsSelected); |
9876 "aria-expanded": showForm, |
12193 return termsTree; |
9877 isLink: true |
12194 } |
9878 }, newTermButtonLabel), showForm && Object(external_wp_element_["createElement"])("form", { |
12195 }, { |
9879 onSubmit: this.onAddTerm, |
12196 key: "setFilterValue", |
9880 key: "hierarchical-terms-form" |
12197 value: function setFilterValue(event) { |
9881 }, Object(external_wp_element_["createElement"])("label", { |
12198 var availableTermsTree = this.state.availableTermsTree; |
9882 htmlFor: inputId, |
12199 var filterValue = event.target.value; |
9883 className: "editor-post-taxonomies__hierarchical-terms-label" |
12200 var filteredTermsTree = availableTermsTree.map(this.getFilterMatcher(filterValue)).filter(function (term) { |
9884 }, newTermLabel), Object(external_wp_element_["createElement"])("input", { |
12201 return term; |
9885 type: "text", |
12202 }); |
9886 id: inputId, |
12203 |
9887 className: "editor-post-taxonomies__hierarchical-terms-input", |
12204 var getResultCount = function getResultCount(terms) { |
9888 value: formName, |
12205 var count = 0; |
9889 onChange: this.onChangeFormName, |
12206 |
9890 required: true |
12207 for (var i = 0; i < terms.length; i++) { |
9891 }), !!availableTerms.length && Object(external_wp_element_["createElement"])(external_wp_components_["TreeSelect"], { |
12208 count++; |
9892 label: parentSelectLabel, |
12209 |
9893 noOptionLabel: noParentOption, |
12210 if (undefined !== terms[i].children) { |
9894 onChange: this.onChangeFormParent, |
12211 count += getResultCount(terms[i].children); |
9895 selectedId: formParent, |
12212 } |
9896 tree: availableTermsTree |
12213 } |
9897 }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
12214 |
9898 isSecondary: true, |
12215 return count; |
9899 type: "submit", |
12216 }; |
9900 className: "editor-post-taxonomies__hierarchical-terms-submit" |
12217 |
9901 }, newTermSubmitLabel))]; |
12218 this.setState({ |
9902 } |
12219 filterValue: filterValue, |
9903 |
12220 filteredTermsTree: filteredTermsTree |
9904 } |
12221 }); |
9905 |
12222 var resultCount = getResultCount(filteredTermsTree); |
9906 /* harmony default export */ var hierarchical_term_selector = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])((select, { |
12223 var resultsFoundMessage = Object(external_this_wp_i18n_["sprintf"])( |
9907 slug |
12224 /* translators: %d: number of results */ |
9908 }) => { |
12225 Object(external_this_wp_i18n_["_n"])('%d result found.', '%d results found.', resultCount), resultCount); |
9909 const { |
12226 this.props.debouncedSpeak(resultsFoundMessage, 'assertive'); |
9910 getCurrentPost |
12227 } |
9911 } = select('core/editor'); |
12228 }, { |
9912 const { |
12229 key: "getFilterMatcher", |
9913 getTaxonomy |
12230 value: function getFilterMatcher(filterValue) { |
9914 } = select('core'); |
12231 var matchTermsForFilter = function matchTermsForFilter(originalTerm) { |
9915 const taxonomy = getTaxonomy(slug); |
12232 if ('' === filterValue) { |
|
12233 return originalTerm; |
|
12234 } // Shallow clone, because we'll be filtering the term's children and |
|
12235 // don't want to modify the original term. |
|
12236 |
|
12237 |
|
12238 var term = hierarchical_term_selector_objectSpread({}, originalTerm); // Map and filter the children, recursive so we deal with grandchildren |
|
12239 // and any deeper levels. |
|
12240 |
|
12241 |
|
12242 if (term.children.length > 0) { |
|
12243 term.children = term.children.map(matchTermsForFilter).filter(function (child) { |
|
12244 return child; |
|
12245 }); |
|
12246 } // If the term's name contains the filterValue, or it has children |
|
12247 // (i.e. some child matched at some point in the tree) then return it. |
|
12248 |
|
12249 |
|
12250 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) { |
|
12251 return term; |
|
12252 } // Otherwise, return false. After mapping, the list of terms will need |
|
12253 // to have false values filtered out. |
|
12254 |
|
12255 |
|
12256 return false; |
|
12257 }; |
|
12258 |
|
12259 return matchTermsForFilter; |
|
12260 } |
|
12261 }, { |
|
12262 key: "renderTerms", |
|
12263 value: function renderTerms(renderedTerms) { |
|
12264 var _this4 = this; |
|
12265 |
|
12266 var _this$props$terms2 = this.props.terms, |
|
12267 terms = _this$props$terms2 === void 0 ? [] : _this$props$terms2; |
|
12268 return renderedTerms.map(function (term) { |
|
12269 return Object(external_this_wp_element_["createElement"])("div", { |
|
12270 key: term.id, |
|
12271 className: "editor-post-taxonomies__hierarchical-terms-choice" |
|
12272 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
|
12273 checked: terms.indexOf(term.id) !== -1, |
|
12274 onChange: function onChange() { |
|
12275 var termId = parseInt(term.id, 10); |
|
12276 |
|
12277 _this4.onChange(termId); |
|
12278 }, |
|
12279 label: Object(external_this_lodash_["unescape"])(term.name) |
|
12280 }), !!term.children.length && Object(external_this_wp_element_["createElement"])("div", { |
|
12281 className: "editor-post-taxonomies__hierarchical-terms-subchoices" |
|
12282 }, _this4.renderTerms(term.children))); |
|
12283 }); |
|
12284 } |
|
12285 }, { |
|
12286 key: "render", |
|
12287 value: function render() { |
|
12288 var _this$props3 = this.props, |
|
12289 slug = _this$props3.slug, |
|
12290 taxonomy = _this$props3.taxonomy, |
|
12291 instanceId = _this$props3.instanceId, |
|
12292 hasCreateAction = _this$props3.hasCreateAction, |
|
12293 hasAssignAction = _this$props3.hasAssignAction; |
|
12294 |
|
12295 if (!hasAssignAction) { |
|
12296 return null; |
|
12297 } |
|
12298 |
|
12299 var _this$state2 = this.state, |
|
12300 availableTermsTree = _this$state2.availableTermsTree, |
|
12301 availableTerms = _this$state2.availableTerms, |
|
12302 filteredTermsTree = _this$state2.filteredTermsTree, |
|
12303 formName = _this$state2.formName, |
|
12304 formParent = _this$state2.formParent, |
|
12305 loading = _this$state2.loading, |
|
12306 showForm = _this$state2.showForm, |
|
12307 filterValue = _this$state2.filterValue; |
|
12308 |
|
12309 var labelWithFallback = function labelWithFallback(labelProperty, fallbackIsCategory, fallbackIsNotCategory) { |
|
12310 return Object(external_this_lodash_["get"])(taxonomy, ['labels', labelProperty], slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory); |
|
12311 }; |
|
12312 |
|
12313 var newTermButtonLabel = labelWithFallback('add_new_item', Object(external_this_wp_i18n_["__"])('Add new category'), Object(external_this_wp_i18n_["__"])('Add new term')); |
|
12314 var newTermLabel = labelWithFallback('new_item_name', Object(external_this_wp_i18n_["__"])('Add new category'), Object(external_this_wp_i18n_["__"])('Add new term')); |
|
12315 var parentSelectLabel = labelWithFallback('parent_item', Object(external_this_wp_i18n_["__"])('Parent Category'), Object(external_this_wp_i18n_["__"])('Parent Term')); |
|
12316 var noParentOption = "\u2014 ".concat(parentSelectLabel, " \u2014"); |
|
12317 var newTermSubmitLabel = newTermButtonLabel; |
|
12318 var inputId = "editor-post-taxonomies__hierarchical-terms-input-".concat(instanceId); |
|
12319 var filterInputId = "editor-post-taxonomies__hierarchical-terms-filter-".concat(instanceId); |
|
12320 var filterLabel = Object(external_this_lodash_["get"])(this.props.taxonomy, ['labels', 'search_items'], Object(external_this_wp_i18n_["__"])('Search Terms')); |
|
12321 var groupLabel = Object(external_this_lodash_["get"])(this.props.taxonomy, ['name'], Object(external_this_wp_i18n_["__"])('Terms')); |
|
12322 var showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER; |
|
12323 return [showFilter && Object(external_this_wp_element_["createElement"])("label", { |
|
12324 key: "filter-label", |
|
12325 htmlFor: filterInputId |
|
12326 }, filterLabel), showFilter && Object(external_this_wp_element_["createElement"])("input", { |
|
12327 type: "search", |
|
12328 id: filterInputId, |
|
12329 value: filterValue, |
|
12330 onChange: this.setFilterValue, |
|
12331 className: "editor-post-taxonomies__hierarchical-terms-filter", |
|
12332 key: "term-filter-input" |
|
12333 }), Object(external_this_wp_element_["createElement"])("div", { |
|
12334 className: "editor-post-taxonomies__hierarchical-terms-list", |
|
12335 key: "term-list", |
|
12336 tabIndex: "0", |
|
12337 role: "group", |
|
12338 "aria-label": groupLabel |
|
12339 }, this.renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)), !loading && hasCreateAction && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12340 key: "term-add-button", |
|
12341 onClick: this.onToggleForm, |
|
12342 className: "editor-post-taxonomies__hierarchical-terms-add", |
|
12343 "aria-expanded": showForm, |
|
12344 isLink: true |
|
12345 }, newTermButtonLabel), showForm && Object(external_this_wp_element_["createElement"])("form", { |
|
12346 onSubmit: this.onAddTerm, |
|
12347 key: "hierarchical-terms-form" |
|
12348 }, Object(external_this_wp_element_["createElement"])("label", { |
|
12349 htmlFor: inputId, |
|
12350 className: "editor-post-taxonomies__hierarchical-terms-label" |
|
12351 }, newTermLabel), Object(external_this_wp_element_["createElement"])("input", { |
|
12352 type: "text", |
|
12353 id: inputId, |
|
12354 className: "editor-post-taxonomies__hierarchical-terms-input", |
|
12355 value: formName, |
|
12356 onChange: this.onChangeFormName, |
|
12357 required: true |
|
12358 }), !!availableTerms.length && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TreeSelect"], { |
|
12359 label: parentSelectLabel, |
|
12360 noOptionLabel: noParentOption, |
|
12361 onChange: this.onChangeFormParent, |
|
12362 selectedId: formParent, |
|
12363 tree: availableTermsTree |
|
12364 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12365 isSecondary: true, |
|
12366 type: "submit", |
|
12367 className: "editor-post-taxonomies__hierarchical-terms-submit" |
|
12368 }, newTermSubmitLabel))]; |
|
12369 } |
|
12370 }]); |
|
12371 |
|
12372 return HierarchicalTermSelector; |
|
12373 }(external_this_wp_element_["Component"]); |
|
12374 |
|
12375 /* harmony default export */ var hierarchical_term_selector = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
12376 var slug = _ref.slug; |
|
12377 |
|
12378 var _select = select('core/editor'), |
|
12379 getCurrentPost = _select.getCurrentPost; |
|
12380 |
|
12381 var _select2 = select('core'), |
|
12382 getTaxonomy = _select2.getTaxonomy; |
|
12383 |
|
12384 var taxonomy = getTaxonomy(slug); |
|
12385 return { |
9916 return { |
12386 hasCreateAction: taxonomy ? Object(external_this_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-create-' + taxonomy.rest_base], false) : false, |
9917 hasCreateAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-create-' + taxonomy.rest_base], false) : false, |
12387 hasAssignAction: taxonomy ? Object(external_this_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-assign-' + taxonomy.rest_base], false) : false, |
9918 hasAssignAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-assign-' + taxonomy.rest_base], false) : false, |
12388 terms: taxonomy ? select('core/editor').getEditedPostAttribute(taxonomy.rest_base) : [], |
9919 terms: taxonomy ? select('core/editor').getEditedPostAttribute(taxonomy.rest_base) : [], |
12389 taxonomy: taxonomy |
9920 taxonomy |
12390 }; |
9921 }; |
12391 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
9922 }), Object(external_wp_data_["withDispatch"])(dispatch => ({ |
12392 return { |
9923 onUpdateTerms(terms, restBase) { |
12393 onUpdateTerms: function onUpdateTerms(terms, restBase) { |
9924 dispatch('core/editor').editPost({ |
12394 dispatch('core/editor').editPost(Object(defineProperty["a" /* default */])({}, restBase, terms)); |
9925 [restBase]: terms |
12395 } |
9926 }); |
12396 }; |
9927 } |
12397 }), external_this_wp_components_["withSpokenMessages"], external_this_wp_compose_["withInstanceId"], Object(external_this_wp_components_["withFilters"])('editor.PostTaxonomyType')])(hierarchical_term_selector_HierarchicalTermSelector)); |
9928 |
|
9929 })), external_wp_components_["withSpokenMessages"], external_wp_compose_["withInstanceId"], Object(external_wp_components_["withFilters"])('editor.PostTaxonomyType')])(hierarchical_term_selector_HierarchicalTermSelector)); |
12398 |
9930 |
12399 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/index.js |
9931 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/index.js |
12400 |
9932 |
12401 |
9933 |
12402 /** |
9934 /** |
12508 |
10025 |
12509 |
10026 |
12510 |
10027 |
12511 |
10028 |
12512 |
10029 |
12513 var post_text_editor_PostTextEditor = /*#__PURE__*/function (_Component) { |
10030 function PostTextEditor() { |
12514 Object(inherits["a" /* default */])(PostTextEditor, _Component); |
10031 const postContent = Object(external_wp_data_["useSelect"])(select => select('core/editor').getEditedPostContent(), []); |
12515 |
10032 const { |
12516 var _super = post_text_editor_createSuper(PostTextEditor); |
10033 editPost, |
12517 |
10034 resetEditorBlocks |
12518 function PostTextEditor() { |
10035 } = Object(external_wp_data_["useDispatch"])('core/editor'); |
12519 var _this; |
10036 const [value, setValue] = Object(external_wp_element_["useState"])(postContent); |
12520 |
10037 const [isDirty, setIsDirty] = Object(external_wp_element_["useState"])(false); |
12521 Object(classCallCheck["a" /* default */])(this, PostTextEditor); |
10038 const instanceId = Object(external_wp_compose_["useInstanceId"])(PostTextEditor); |
12522 |
10039 |
12523 _this = _super.apply(this, arguments); |
10040 if (!isDirty && value !== postContent) { |
12524 _this.edit = _this.edit.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
10041 setValue(postContent); |
12525 _this.stopEditing = _this.stopEditing.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
10042 } |
12526 _this.state = {}; |
10043 /** |
12527 return _this; |
10044 * Handles a textarea change event to notify the onChange prop callback and |
12528 } |
10045 * reflect the new value in the component's own state. This marks the start |
12529 |
10046 * of the user's edits, if not already changed, preventing future props |
12530 Object(createClass["a" /* default */])(PostTextEditor, [{ |
10047 * changes to value from replacing the rendered value. This is expected to |
12531 key: "edit", |
10048 * be followed by a reset to dirty state via `stopEditing`. |
12532 |
10049 * |
12533 /** |
10050 * @see stopEditing |
12534 * Handles a textarea change event to notify the onChange prop callback and |
10051 * |
12535 * reflect the new value in the component's own state. This marks the start |
10052 * @param {Event} event Change event. |
12536 * of the user's edits, if not already changed, preventing future props |
10053 */ |
12537 * changes to value from replacing the rendered value. This is expected to |
10054 |
12538 * be followed by a reset to dirty state via `stopEditing`. |
10055 |
12539 * |
10056 const onChange = event => { |
12540 * @see stopEditing |
10057 const newValue = event.target.value; |
12541 * |
10058 editPost({ |
12542 * @param {Event} event Change event. |
10059 content: newValue |
12543 */ |
10060 }); |
12544 value: function edit(event) { |
10061 setValue(newValue); |
12545 var value = event.target.value; |
10062 setIsDirty(true); |
12546 this.props.onChange(value); |
10063 }; |
12547 this.setState({ |
10064 /** |
12548 value: value, |
10065 * Function called when the user has completed their edits, responsible for |
12549 isDirty: true |
10066 * ensuring that changes, if made, are surfaced to the onPersist prop |
12550 }); |
10067 * callback and resetting dirty state. |
|
10068 */ |
|
10069 |
|
10070 |
|
10071 const stopEditing = () => { |
|
10072 if (isDirty) { |
|
10073 const blocks = Object(external_wp_blocks_["parse"])(value); |
|
10074 resetEditorBlocks(blocks); |
|
10075 setIsDirty(false); |
12551 } |
10076 } |
12552 /** |
10077 }; |
12553 * Function called when the user has completed their edits, responsible for |
10078 |
12554 * ensuring that changes, if made, are surfaced to the onPersist prop |
10079 return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], { |
12555 * callback and resetting dirty state. |
10080 as: "label", |
12556 */ |
10081 htmlFor: `post-content-${instanceId}` |
12557 |
10082 }, Object(external_wp_i18n_["__"])('Type text or HTML')), Object(external_wp_element_["createElement"])(lib_default.a, { |
12558 }, { |
10083 autoComplete: "off", |
12559 key: "stopEditing", |
10084 dir: "auto", |
12560 value: function stopEditing() { |
10085 value: value, |
12561 if (this.state.isDirty) { |
10086 onChange: onChange, |
12562 this.props.onPersist(this.state.value); |
10087 onBlur: stopEditing, |
12563 this.setState({ |
10088 className: "editor-post-text-editor", |
12564 isDirty: false |
10089 id: `post-content-${instanceId}`, |
12565 }); |
10090 placeholder: Object(external_wp_i18n_["__"])('Start writing with text or HTML') |
|
10091 })); |
|
10092 } |
|
10093 |
|
10094 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/index.js |
|
10095 |
|
10096 |
|
10097 /** |
|
10098 * External dependencies |
|
10099 */ |
|
10100 |
|
10101 |
|
10102 /** |
|
10103 * WordPress dependencies |
|
10104 */ |
|
10105 |
|
10106 |
|
10107 |
|
10108 |
|
10109 |
|
10110 |
|
10111 |
|
10112 |
|
10113 |
|
10114 |
|
10115 /** |
|
10116 * Internal dependencies |
|
10117 */ |
|
10118 |
|
10119 |
|
10120 /** |
|
10121 * Constants |
|
10122 */ |
|
10123 |
|
10124 const REGEXP_NEWLINES = /[\r\n]+/g; |
|
10125 function PostTitle() { |
|
10126 const instanceId = Object(external_wp_compose_["useInstanceId"])(PostTitle); |
|
10127 const ref = Object(external_wp_element_["useRef"])(); |
|
10128 const [isSelected, setIsSelected] = Object(external_wp_element_["useState"])(false); |
|
10129 const { |
|
10130 editPost |
|
10131 } = Object(external_wp_data_["useDispatch"])('core/editor'); |
|
10132 const { |
|
10133 insertDefaultBlock, |
|
10134 clearSelectedBlock, |
|
10135 insertBlocks |
|
10136 } = Object(external_wp_data_["useDispatch"])(external_wp_blockEditor_["store"]); |
|
10137 const { |
|
10138 isCleanNewPost, |
|
10139 title, |
|
10140 placeholder, |
|
10141 isFocusMode, |
|
10142 hasFixedToolbar |
|
10143 } = Object(external_wp_data_["useSelect"])(select => { |
|
10144 const { |
|
10145 getEditedPostAttribute, |
|
10146 isCleanNewPost: _isCleanNewPost |
|
10147 } = select('core/editor'); |
|
10148 const { |
|
10149 getSettings |
|
10150 } = select(external_wp_blockEditor_["store"]); |
|
10151 const { |
|
10152 titlePlaceholder, |
|
10153 focusMode, |
|
10154 hasFixedToolbar: _hasFixedToolbar |
|
10155 } = getSettings(); |
|
10156 return { |
|
10157 isCleanNewPost: _isCleanNewPost(), |
|
10158 title: getEditedPostAttribute('title'), |
|
10159 placeholder: titlePlaceholder, |
|
10160 isFocusMode: focusMode, |
|
10161 hasFixedToolbar: _hasFixedToolbar |
|
10162 }; |
|
10163 }); |
|
10164 Object(external_wp_element_["useEffect"])(() => { |
|
10165 if (!ref.current) { |
|
10166 return; |
|
10167 } |
|
10168 |
|
10169 const { |
|
10170 ownerDocument |
|
10171 } = ref.current; |
|
10172 const { |
|
10173 activeElement, |
|
10174 body |
|
10175 } = ownerDocument; // Only autofocus the title when the post is entirely empty. This should |
|
10176 // only happen for a new post, which means we focus the title on new |
|
10177 // post so the author can start typing right away, without needing to |
|
10178 // click anything. |
|
10179 |
|
10180 if (isCleanNewPost && (!activeElement || body === activeElement)) { |
|
10181 ref.current.focus(); |
|
10182 } |
|
10183 }, [isCleanNewPost]); |
|
10184 |
|
10185 function onEnterPress() { |
|
10186 insertDefaultBlock(undefined, undefined, 0); |
|
10187 } |
|
10188 |
|
10189 function onInsertBlockAfter(blocks) { |
|
10190 insertBlocks(blocks, 0); |
|
10191 } |
|
10192 |
|
10193 function onUpdate(newTitle) { |
|
10194 editPost({ |
|
10195 title: newTitle |
|
10196 }); |
|
10197 } |
|
10198 |
|
10199 function onSelect() { |
|
10200 setIsSelected(true); |
|
10201 clearSelectedBlock(); |
|
10202 } |
|
10203 |
|
10204 function onUnselect() { |
|
10205 setIsSelected(false); |
|
10206 } |
|
10207 |
|
10208 function onChange(event) { |
|
10209 onUpdate(event.target.value.replace(REGEXP_NEWLINES, ' ')); |
|
10210 } |
|
10211 |
|
10212 function onKeyDown(event) { |
|
10213 if (event.keyCode === external_wp_keycodes_["ENTER"]) { |
|
10214 event.preventDefault(); |
|
10215 onEnterPress(); |
|
10216 } |
|
10217 } |
|
10218 |
|
10219 function onPaste(event) { |
|
10220 const clipboardData = event.clipboardData; |
|
10221 let plainText = ''; |
|
10222 let html = ''; // IE11 only supports `Text` as an argument for `getData` and will |
|
10223 // otherwise throw an invalid argument error, so we try the standard |
|
10224 // arguments first, then fallback to `Text` if they fail. |
|
10225 |
|
10226 try { |
|
10227 plainText = clipboardData.getData('text/plain'); |
|
10228 html = clipboardData.getData('text/html'); |
|
10229 } catch (error1) { |
|
10230 try { |
|
10231 html = clipboardData.getData('Text'); |
|
10232 } catch (error2) { |
|
10233 // Some browsers like UC Browser paste plain text by default and |
|
10234 // don't support clipboardData at all, so allow default |
|
10235 // behaviour. |
|
10236 return; |
|
10237 } |
|
10238 } // Allows us to ask for this information when we get a report. |
|
10239 |
|
10240 |
|
10241 window.console.log('Received HTML:\n\n', html); |
|
10242 window.console.log('Received plain text:\n\n', plainText); |
|
10243 const content = Object(external_wp_blocks_["pasteHandler"])({ |
|
10244 HTML: html, |
|
10245 plainText |
|
10246 }); |
|
10247 |
|
10248 if (typeof content !== 'string' && content.length) { |
|
10249 event.preventDefault(); |
|
10250 const [firstBlock] = content; |
|
10251 |
|
10252 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) { |
|
10253 onUpdate(firstBlock.attributes.content); |
|
10254 onInsertBlockAfter(content.slice(1)); |
|
10255 } else { |
|
10256 onInsertBlockAfter(content); |
12566 } |
10257 } |
12567 } |
10258 } |
12568 }, { |
10259 } // The wp-block className is important for editor styles. |
12569 key: "render", |
10260 // This same block is used in both the visual and the code editor. |
12570 value: function render() { |
10261 |
12571 var value = this.state.value; |
10262 |
12572 var instanceId = this.props.instanceId; |
10263 const className = classnames_default()('wp-block editor-post-title editor-post-title__block', { |
12573 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["VisuallyHidden"], { |
10264 'is-selected': isSelected, |
12574 as: "label", |
10265 'is-focus-mode': isFocusMode, |
12575 htmlFor: "post-content-".concat(instanceId) |
10266 'has-fixed-toolbar': hasFixedToolbar |
12576 }, Object(external_this_wp_i18n_["__"])('Type text or HTML')), Object(external_this_wp_element_["createElement"])(lib_default.a, { |
10267 }); |
12577 autoComplete: "off", |
10268 const decodedPlaceholder = Object(external_wp_htmlEntities_["decodeEntities"])(placeholder); |
12578 dir: "auto", |
10269 return Object(external_wp_element_["createElement"])(post_type_support_check, { |
12579 value: value, |
10270 supportKeys: "title" |
12580 onChange: this.edit, |
10271 }, Object(external_wp_element_["createElement"])("div", { |
12581 onBlur: this.stopEditing, |
10272 className: className |
12582 className: "editor-post-text-editor", |
10273 }, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], { |
12583 id: "post-content-".concat(instanceId), |
10274 as: "label", |
12584 placeholder: Object(external_this_wp_i18n_["__"])('Start writing with text or HTML') |
10275 htmlFor: `post-title-${instanceId}` |
12585 })); |
10276 }, decodedPlaceholder || Object(external_wp_i18n_["__"])('Add title')), Object(external_wp_element_["createElement"])(lib_default.a, { |
12586 } |
10277 ref: ref, |
12587 }], [{ |
10278 id: `post-title-${instanceId}`, |
12588 key: "getDerivedStateFromProps", |
10279 className: "editor-post-title__input", |
12589 value: function getDerivedStateFromProps(props, state) { |
10280 value: title, |
12590 if (state.isDirty) { |
10281 onChange: onChange, |
12591 return null; |
10282 placeholder: decodedPlaceholder || Object(external_wp_i18n_["__"])('Add title'), |
12592 } |
10283 onFocus: onSelect, |
12593 |
10284 onBlur: onUnselect, |
12594 return { |
10285 onKeyDown: onKeyDown, |
12595 value: props.value, |
10286 onKeyPress: onUnselect, |
12596 isDirty: false |
10287 onPaste: onPaste |
12597 }; |
10288 }))); |
12598 } |
10289 } |
12599 }]); |
10290 |
12600 |
10291 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/index.js |
12601 return PostTextEditor; |
|
12602 }(external_this_wp_element_["Component"]); |
|
12603 /* harmony default export */ var post_text_editor = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12604 var _select = select('core/editor'), |
|
12605 getEditedPostContent = _select.getEditedPostContent; |
|
12606 |
|
12607 return { |
|
12608 value: getEditedPostContent() |
|
12609 }; |
|
12610 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12611 var _dispatch = dispatch('core/editor'), |
|
12612 editPost = _dispatch.editPost, |
|
12613 resetEditorBlocks = _dispatch.resetEditorBlocks; |
|
12614 |
|
12615 return { |
|
12616 onChange: function onChange(content) { |
|
12617 editPost({ |
|
12618 content: content |
|
12619 }); |
|
12620 }, |
|
12621 onPersist: function onPersist(content) { |
|
12622 var blocks = Object(external_this_wp_blocks_["parse"])(content); |
|
12623 resetEditorBlocks(blocks); |
|
12624 } |
|
12625 }; |
|
12626 }), external_this_wp_compose_["withInstanceId"]])(post_text_editor_PostTextEditor)); |
|
12627 |
|
12628 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/index.js |
|
12629 |
|
12630 |
|
12631 |
|
12632 |
|
12633 |
|
12634 |
|
12635 |
|
12636 |
|
12637 |
|
12638 function post_title_createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (post_title_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
12639 |
|
12640 function post_title_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
12641 |
|
12642 /** |
|
12643 * External dependencies |
|
12644 */ |
|
12645 |
10292 |
12646 |
10293 |
12647 /** |
10294 /** |
12648 * WordPress dependencies |
10295 * WordPress dependencies |
12649 */ |
10296 */ |
12650 |
10297 |
12651 |
10298 |
12652 |
10299 |
12653 |
10300 |
12654 |
10301 |
12655 |
10302 function PostTrash({ |
12656 |
10303 isNew, |
12657 |
10304 postId, |
12658 |
10305 postType, |
12659 /** |
10306 ...props |
12660 * Internal dependencies |
10307 }) { |
12661 */ |
|
12662 |
|
12663 |
|
12664 /** |
|
12665 * Constants |
|
12666 */ |
|
12667 |
|
12668 var REGEXP_NEWLINES = /[\r\n]+/g; |
|
12669 |
|
12670 var post_title_PostTitle = /*#__PURE__*/function (_Component) { |
|
12671 Object(inherits["a" /* default */])(PostTitle, _Component); |
|
12672 |
|
12673 var _super = post_title_createSuper(PostTitle); |
|
12674 |
|
12675 function PostTitle() { |
|
12676 var _this; |
|
12677 |
|
12678 Object(classCallCheck["a" /* default */])(this, PostTitle); |
|
12679 |
|
12680 _this = _super.apply(this, arguments); |
|
12681 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
12682 _this.onSelect = _this.onSelect.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
12683 _this.onUnselect = _this.onUnselect.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
12684 _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
12685 _this.onPaste = _this.onPaste.bind(Object(assertThisInitialized["a" /* default */])(_this)); |
|
12686 _this.state = { |
|
12687 isSelected: false |
|
12688 }; |
|
12689 return _this; |
|
12690 } |
|
12691 |
|
12692 Object(createClass["a" /* default */])(PostTitle, [{ |
|
12693 key: "onSelect", |
|
12694 value: function onSelect() { |
|
12695 this.setState({ |
|
12696 isSelected: true |
|
12697 }); |
|
12698 this.props.clearSelectedBlock(); |
|
12699 } |
|
12700 }, { |
|
12701 key: "onUnselect", |
|
12702 value: function onUnselect() { |
|
12703 this.setState({ |
|
12704 isSelected: false |
|
12705 }); |
|
12706 } |
|
12707 }, { |
|
12708 key: "onChange", |
|
12709 value: function onChange(event) { |
|
12710 var newTitle = event.target.value.replace(REGEXP_NEWLINES, ' '); |
|
12711 this.props.onUpdate(newTitle); |
|
12712 } |
|
12713 }, { |
|
12714 key: "onKeyDown", |
|
12715 value: function onKeyDown(event) { |
|
12716 if (event.keyCode === external_this_wp_keycodes_["ENTER"]) { |
|
12717 event.preventDefault(); |
|
12718 this.props.onEnterPress(); |
|
12719 } |
|
12720 } |
|
12721 }, { |
|
12722 key: "onPaste", |
|
12723 value: function onPaste(event) { |
|
12724 var _this$props = this.props, |
|
12725 title = _this$props.title, |
|
12726 onInsertBlockAfter = _this$props.onInsertBlockAfter, |
|
12727 onUpdate = _this$props.onUpdate; |
|
12728 var clipboardData = event.clipboardData; |
|
12729 var plainText = ''; |
|
12730 var html = ''; // IE11 only supports `Text` as an argument for `getData` and will |
|
12731 // otherwise throw an invalid argument error, so we try the standard |
|
12732 // arguments first, then fallback to `Text` if they fail. |
|
12733 |
|
12734 try { |
|
12735 plainText = clipboardData.getData('text/plain'); |
|
12736 html = clipboardData.getData('text/html'); |
|
12737 } catch (error1) { |
|
12738 try { |
|
12739 html = clipboardData.getData('Text'); |
|
12740 } catch (error2) { |
|
12741 // Some browsers like UC Browser paste plain text by default and |
|
12742 // don't support clipboardData at all, so allow default |
|
12743 // behaviour. |
|
12744 return; |
|
12745 } |
|
12746 } // Allows us to ask for this information when we get a report. |
|
12747 |
|
12748 |
|
12749 window.console.log('Received HTML:\n\n', html); |
|
12750 window.console.log('Received plain text:\n\n', plainText); |
|
12751 var content = Object(external_this_wp_blocks_["pasteHandler"])({ |
|
12752 HTML: html, |
|
12753 plainText: plainText |
|
12754 }); |
|
12755 |
|
12756 if (typeof content !== 'string' && content.length) { |
|
12757 event.preventDefault(); |
|
12758 |
|
12759 var _content = Object(slicedToArray["a" /* default */])(content, 1), |
|
12760 firstBlock = _content[0]; |
|
12761 |
|
12762 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) { |
|
12763 onUpdate(firstBlock.attributes.content); |
|
12764 onInsertBlockAfter(content.slice(1)); |
|
12765 } else { |
|
12766 onInsertBlockAfter(content); |
|
12767 } |
|
12768 } |
|
12769 } |
|
12770 }, { |
|
12771 key: "render", |
|
12772 value: function render() { |
|
12773 var _this$props2 = this.props, |
|
12774 hasFixedToolbar = _this$props2.hasFixedToolbar, |
|
12775 isCleanNewPost = _this$props2.isCleanNewPost, |
|
12776 isFocusMode = _this$props2.isFocusMode, |
|
12777 instanceId = _this$props2.instanceId, |
|
12778 placeholder = _this$props2.placeholder, |
|
12779 title = _this$props2.title; |
|
12780 var isSelected = this.state.isSelected; // The wp-block className is important for editor styles. |
|
12781 // This same block is used in both the visual and the code editor. |
|
12782 |
|
12783 var className = classnames_default()('wp-block editor-post-title editor-post-title__block', { |
|
12784 'is-selected': isSelected, |
|
12785 'is-focus-mode': isFocusMode, |
|
12786 'has-fixed-toolbar': hasFixedToolbar |
|
12787 }); |
|
12788 var decodedPlaceholder = Object(external_this_wp_htmlEntities_["decodeEntities"])(placeholder); |
|
12789 return Object(external_this_wp_element_["createElement"])(post_type_support_check, { |
|
12790 supportKeys: "title" |
|
12791 }, Object(external_this_wp_element_["createElement"])("div", { |
|
12792 className: className |
|
12793 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["VisuallyHidden"], { |
|
12794 as: "label", |
|
12795 htmlFor: "post-title-".concat(instanceId) |
|
12796 }, decodedPlaceholder || Object(external_this_wp_i18n_["__"])('Add title')), Object(external_this_wp_element_["createElement"])(lib_default.a, { |
|
12797 id: "post-title-".concat(instanceId), |
|
12798 className: "editor-post-title__input", |
|
12799 value: title, |
|
12800 onChange: this.onChange, |
|
12801 placeholder: decodedPlaceholder || Object(external_this_wp_i18n_["__"])('Add title'), |
|
12802 onFocus: this.onSelect, |
|
12803 onBlur: this.onUnselect, |
|
12804 onKeyDown: this.onKeyDown, |
|
12805 onKeyPress: this.onUnselect, |
|
12806 onPaste: this.onPaste |
|
12807 /* |
|
12808 Only autofocus the title when the post is entirely empty. |
|
12809 This should only happen for a new post, which means we |
|
12810 focus the title on new post so the author can start typing |
|
12811 right away, without needing to click anything. |
|
12812 */ |
|
12813 |
|
12814 /* eslint-disable jsx-a11y/no-autofocus */ |
|
12815 , |
|
12816 autoFocus: (document.body === document.activeElement || !document.activeElement) && isCleanNewPost |
|
12817 /* eslint-enable jsx-a11y/no-autofocus */ |
|
12818 |
|
12819 }))); |
|
12820 } |
|
12821 }]); |
|
12822 |
|
12823 return PostTitle; |
|
12824 }(external_this_wp_element_["Component"]); |
|
12825 |
|
12826 var post_title_applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12827 var _select = select('core/editor'), |
|
12828 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
12829 isCleanNewPost = _select.isCleanNewPost; |
|
12830 |
|
12831 var _select2 = select('core/block-editor'), |
|
12832 getSettings = _select2.getSettings; |
|
12833 |
|
12834 var _getSettings = getSettings(), |
|
12835 titlePlaceholder = _getSettings.titlePlaceholder, |
|
12836 focusMode = _getSettings.focusMode, |
|
12837 hasFixedToolbar = _getSettings.hasFixedToolbar; |
|
12838 |
|
12839 return { |
|
12840 isCleanNewPost: isCleanNewPost(), |
|
12841 title: getEditedPostAttribute('title'), |
|
12842 placeholder: titlePlaceholder, |
|
12843 isFocusMode: focusMode, |
|
12844 hasFixedToolbar: hasFixedToolbar |
|
12845 }; |
|
12846 }); |
|
12847 var post_title_applyWithDispatch = Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12848 var _dispatch = dispatch('core/block-editor'), |
|
12849 insertDefaultBlock = _dispatch.insertDefaultBlock, |
|
12850 clearSelectedBlock = _dispatch.clearSelectedBlock, |
|
12851 insertBlocks = _dispatch.insertBlocks; |
|
12852 |
|
12853 var _dispatch2 = dispatch('core/editor'), |
|
12854 editPost = _dispatch2.editPost; |
|
12855 |
|
12856 return { |
|
12857 onEnterPress: function onEnterPress() { |
|
12858 insertDefaultBlock(undefined, undefined, 0); |
|
12859 }, |
|
12860 onInsertBlockAfter: function onInsertBlockAfter(blocks) { |
|
12861 insertBlocks(blocks, 0); |
|
12862 }, |
|
12863 onUpdate: function onUpdate(title) { |
|
12864 editPost({ |
|
12865 title: title |
|
12866 }); |
|
12867 }, |
|
12868 clearSelectedBlock: clearSelectedBlock |
|
12869 }; |
|
12870 }); |
|
12871 /* harmony default export */ var post_title = (Object(external_this_wp_compose_["compose"])(post_title_applyWithSelect, post_title_applyWithDispatch, external_this_wp_compose_["withInstanceId"])(post_title_PostTitle)); |
|
12872 |
|
12873 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/index.js |
|
12874 |
|
12875 |
|
12876 |
|
12877 /** |
|
12878 * WordPress dependencies |
|
12879 */ |
|
12880 |
|
12881 |
|
12882 |
|
12883 |
|
12884 |
|
12885 function PostTrash(_ref) { |
|
12886 var isNew = _ref.isNew, |
|
12887 postId = _ref.postId, |
|
12888 postType = _ref.postType, |
|
12889 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["isNew", "postId", "postType"]); |
|
12890 |
|
12891 if (isNew || !postId) { |
10308 if (isNew || !postId) { |
12892 return null; |
10309 return null; |
12893 } |
10310 } |
12894 |
10311 |
12895 var onClick = function onClick() { |
10312 const onClick = () => props.trashPost(postId, postType); |
12896 return props.trashPost(postId, postType); |
10313 |
12897 }; |
10314 return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
12898 |
|
12899 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12900 className: "editor-post-trash", |
10315 className: "editor-post-trash", |
12901 isDestructive: true, |
10316 isDestructive: true, |
12902 isTertiary: true, |
10317 isTertiary: true, |
12903 onClick: onClick |
10318 onClick: onClick |
12904 }, Object(external_this_wp_i18n_["__"])('Move to trash')); |
10319 }, Object(external_wp_i18n_["__"])('Move to trash')); |
12905 } |
10320 } |
12906 |
10321 |
12907 /* harmony default export */ var post_trash = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
10322 /* harmony default export */ var post_trash = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(select => { |
12908 var _select = select('core/editor'), |
10323 const { |
12909 isEditedPostNew = _select.isEditedPostNew, |
10324 isEditedPostNew, |
12910 getCurrentPostId = _select.getCurrentPostId, |
10325 getCurrentPostId, |
12911 getCurrentPostType = _select.getCurrentPostType; |
10326 getCurrentPostType |
12912 |
10327 } = select('core/editor'); |
12913 return { |
10328 return { |
12914 isNew: isEditedPostNew(), |
10329 isNew: isEditedPostNew(), |
12915 postId: getCurrentPostId(), |
10330 postId: getCurrentPostId(), |
12916 postType: getCurrentPostType() |
10331 postType: getCurrentPostType() |
12917 }; |
10332 }; |
12918 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
10333 }), Object(external_wp_data_["withDispatch"])(dispatch => ({ |
12919 return { |
10334 trashPost: dispatch('core/editor').trashPost |
12920 trashPost: dispatch('core/editor').trashPost |
10335 }))])(PostTrash)); |
12921 }; |
|
12922 })])(PostTrash)); |
|
12923 |
10336 |
12924 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/check.js |
10337 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/check.js |
12925 /** |
10338 /** |
12926 * WordPress dependencies |
10339 * WordPress dependencies |
12927 */ |
10340 */ |
12928 |
10341 |
12929 |
10342 |
12930 function PostTrashCheck(_ref) { |
10343 function PostTrashCheck({ |
12931 var isNew = _ref.isNew, |
10344 isNew, |
12932 postId = _ref.postId, |
10345 postId, |
12933 canUserDelete = _ref.canUserDelete, |
10346 canUserDelete, |
12934 children = _ref.children; |
10347 children |
12935 |
10348 }) { |
12936 if (isNew || !postId || !canUserDelete) { |
10349 if (isNew || !postId || !canUserDelete) { |
12937 return null; |
10350 return null; |
12938 } |
10351 } |
12939 |
10352 |
12940 return children; |
10353 return children; |
12941 } |
10354 } |
12942 |
10355 |
12943 /* harmony default export */ var post_trash_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
10356 /* harmony default export */ var post_trash_check = (Object(external_wp_data_["withSelect"])(select => { |
12944 var _select = select('core/editor'), |
10357 const { |
12945 isEditedPostNew = _select.isEditedPostNew, |
10358 isEditedPostNew, |
12946 getCurrentPostId = _select.getCurrentPostId, |
10359 getCurrentPostId, |
12947 getCurrentPostType = _select.getCurrentPostType; |
10360 getCurrentPostType |
12948 |
10361 } = select('core/editor'); |
12949 var _select2 = select('core'), |
10362 const { |
12950 getPostType = _select2.getPostType, |
10363 getPostType, |
12951 canUser = _select2.canUser; |
10364 canUser |
12952 |
10365 } = select('core'); |
12953 var postId = getCurrentPostId(); |
10366 const postId = getCurrentPostId(); |
12954 var postType = getPostType(getCurrentPostType()); |
10367 const postType = getPostType(getCurrentPostType()); |
12955 var resource = (postType === null || postType === void 0 ? void 0 : postType['rest_base']) || ''; |
10368 const resource = (postType === null || postType === void 0 ? void 0 : postType.rest_base) || ''; // eslint-disable-line camelcase |
|
10369 |
12956 return { |
10370 return { |
12957 isNew: isEditedPostNew(), |
10371 isNew: isEditedPostNew(), |
12958 postId: postId, |
10372 postId, |
12959 canUserDelete: postId && resource ? canUser('delete', resource, postId) : false |
10373 canUserDelete: postId && resource ? canUser('delete', resource, postId) : false |
12960 }; |
10374 }; |
12961 })(PostTrashCheck)); |
10375 })(PostTrashCheck)); |
12962 |
10376 |
12963 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/check.js |
10377 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/check.js |
13383 */ |
10763 */ |
13384 |
10764 |
13385 |
10765 |
13386 |
10766 |
13387 |
10767 |
13388 |
10768 /** |
13389 |
10769 * Internal dependencies |
13390 |
10770 */ |
13391 function ReusableBlockConvertButton(_ref) { |
10771 |
13392 var isVisible = _ref.isVisible, |
10772 |
13393 isReusable = _ref.isReusable, |
10773 |
13394 onConvertToStatic = _ref.onConvertToStatic, |
10774 /** |
13395 onConvertToReusable = _ref.onConvertToReusable; |
10775 * React hook used to compute the block editor settings to use for the post editor. |
13396 |
10776 * |
13397 if (!isVisible) { |
10777 * @param {Object} settings EditorProvider settings prop. |
13398 return null; |
10778 * @param {boolean} hasTemplate Whether template mode is enabled. |
13399 } |
10779 * |
13400 |
10780 * @return {Object} Block Editor Settings. |
13401 return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockSettingsMenuControls"], null, function (_ref2) { |
10781 */ |
13402 var onClose = _ref2.onClose; |
10782 |
13403 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, !isReusable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
10783 function useBlockEditorSettings(settings, hasTemplate) { |
13404 onClick: function onClick() { |
10784 const { |
13405 onConvertToReusable(); |
10785 reusableBlocks, |
13406 onClose(); |
10786 hasUploadPermissions, |
13407 } |
10787 canUseUnfilteredHTML, |
13408 }, Object(external_this_wp_i18n_["__"])('Add to Reusable blocks')), isReusable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
10788 isTitleSelected |
13409 onClick: function onClick() { |
10789 } = Object(external_wp_data_["useSelect"])(select => { |
13410 onConvertToStatic(); |
10790 const { |
13411 onClose(); |
10791 canUserUseUnfilteredHTML, |
13412 } |
10792 isPostTitleSelected |
13413 }, Object(external_this_wp_i18n_["__"])('Convert to Regular Block'))); |
10793 } = select(store); |
|
10794 const { |
|
10795 canUser |
|
10796 } = select(external_wp_coreData_["store"]); |
|
10797 return { |
|
10798 canUseUnfilteredHTML: canUserUseUnfilteredHTML(), |
|
10799 reusableBlocks: select(external_wp_coreData_["store"]).getEntityRecords('postType', 'wp_block', |
|
10800 /** |
|
10801 * Unbounded queries are not supported on native so as a workaround, we set per_page with the maximum value that native version can handle. |
|
10802 * Related issue: https://github.com/wordpress-mobile/gutenberg-mobile/issues/2661 |
|
10803 */ |
|
10804 { |
|
10805 per_page: external_wp_element_["Platform"].select({ |
|
10806 web: -1, |
|
10807 native: 100 |
|
10808 }) |
|
10809 }), |
|
10810 hasUploadPermissions: Object(external_lodash_["defaultTo"])(canUser('create', 'media'), true), |
|
10811 // This selector is only defined on mobile. |
|
10812 isTitleSelected: isPostTitleSelected && isPostTitleSelected() |
|
10813 }; |
|
10814 }, []); |
|
10815 const { |
|
10816 undo |
|
10817 } = Object(external_wp_data_["useDispatch"])(store); |
|
10818 return Object(external_wp_element_["useMemo"])(() => ({ ...Object(external_lodash_["pick"])(settings, ['__experimentalBlockDirectory', '__experimentalBlockPatternCategories', '__experimentalBlockPatterns', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalGlobalStylesUserEntityId', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomGradients', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'hasFixedToolbar', 'hasReducedUI', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock']), |
|
10819 mediaUpload: hasUploadPermissions ? mediaUpload : undefined, |
|
10820 __experimentalReusableBlocks: reusableBlocks, |
|
10821 __experimentalFetchLinkSuggestions: (search, searchOptions) => Object(external_wp_coreData_["__experimentalFetchLinkSuggestions"])(search, searchOptions, settings), |
|
10822 __experimentalFetchRemoteUrlData: url => Object(external_wp_coreData_["__experimentalFetchRemoteUrlData"])(url), |
|
10823 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML, |
|
10824 __experimentalUndo: undo, |
|
10825 __experimentalShouldInsertAtTheTop: isTitleSelected, |
|
10826 outlineMode: hasTemplate |
|
10827 }), [settings, hasUploadPermissions, reusableBlocks, canUseUnfilteredHTML, undo, isTitleSelected, hasTemplate]); |
|
10828 } |
|
10829 |
|
10830 /* harmony default export */ var use_block_editor_settings = (useBlockEditorSettings); |
|
10831 |
|
10832 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/index.js |
|
10833 |
|
10834 |
|
10835 /** |
|
10836 * WordPress dependencies |
|
10837 */ |
|
10838 |
|
10839 |
|
10840 |
|
10841 |
|
10842 |
|
10843 |
|
10844 |
|
10845 /** |
|
10846 * Internal dependencies |
|
10847 */ |
|
10848 |
|
10849 |
|
10850 |
|
10851 |
|
10852 |
|
10853 function EditorProvider({ |
|
10854 __unstableTemplate, |
|
10855 post, |
|
10856 settings, |
|
10857 recovery, |
|
10858 initialEdits, |
|
10859 children |
|
10860 }) { |
|
10861 const defaultBlockContext = Object(external_wp_element_["useMemo"])(() => { |
|
10862 if (post.type === 'wp_template') { |
|
10863 return {}; |
|
10864 } |
|
10865 |
|
10866 return { |
|
10867 postId: post.id, |
|
10868 postType: post.type |
|
10869 }; |
|
10870 }, [post.id, post.type]); |
|
10871 const { |
|
10872 selection, |
|
10873 isReady |
|
10874 } = Object(external_wp_data_["useSelect"])(select => { |
|
10875 const { |
|
10876 getEditorSelection, |
|
10877 __unstableIsEditorReady |
|
10878 } = select(store); |
|
10879 return { |
|
10880 isReady: __unstableIsEditorReady(), |
|
10881 selection: getEditorSelection() |
|
10882 }; |
|
10883 }, []); |
|
10884 const { |
|
10885 id, |
|
10886 type |
|
10887 } = __unstableTemplate !== null && __unstableTemplate !== void 0 ? __unstableTemplate : post; |
|
10888 const [blocks, onInput, onChange] = Object(external_wp_coreData_["useEntityBlockEditor"])('postType', type, { |
|
10889 id |
13414 }); |
10890 }); |
13415 } |
10891 const editorSettings = use_block_editor_settings(settings, !!__unstableTemplate); |
13416 /* harmony default export */ var reusable_block_convert_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
10892 const { |
13417 var clientIds = _ref3.clientIds; |
10893 updatePostLock, |
13418 |
10894 setupEditor, |
13419 var _select = select('core/block-editor'), |
10895 updateEditorSettings, |
13420 getBlocksByClientId = _select.getBlocksByClientId, |
10896 __experimentalTearDownEditor |
13421 canInsertBlockType = _select.canInsertBlockType; |
10897 } = Object(external_wp_data_["useDispatch"])(store); |
13422 |
10898 const { |
13423 var _select2 = select('core/editor'), |
10899 createWarningNotice |
13424 getReusableBlock = _select2.__experimentalGetReusableBlock; |
10900 } = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]); // Iniitialize and tear down the editor. |
13425 |
10901 // Ideally this should be synced on each change and not just something you do once. |
13426 var _select3 = select('core'), |
10902 |
13427 canUser = _select3.canUser; |
10903 Object(external_wp_element_["useLayoutEffect"])(() => { |
13428 |
10904 // Assume that we don't need to initialize in the case of an error recovery. |
13429 var blocks = getBlocksByClientId(clientIds); |
10905 if (recovery) { |
13430 var isReusable = blocks.length === 1 && blocks[0] && Object(external_this_wp_blocks_["isReusableBlock"])(blocks[0]) && !!getReusableBlock(blocks[0].attributes.ref); // Show 'Convert to Regular Block' when selected block is a reusable block |
10906 return; |
13431 |
|
13432 var isVisible = isReusable || // Hide 'Add to Reusable blocks' when reusable blocks are disabled |
|
13433 canInsertBlockType('core/block') && Object(external_this_lodash_["every"])(blocks, function (block) { |
|
13434 return (// Guard against the case where a regular block has *just* been converted |
|
13435 !!block && // Hide 'Add to Reusable blocks' on invalid blocks |
|
13436 block.isValid && // Hide 'Add to Reusable blocks' when block doesn't support being made reusable |
|
13437 Object(external_this_wp_blocks_["hasBlockSupport"])(block.name, 'reusable', true) |
|
13438 ); |
|
13439 }) && // Hide 'Add to Reusable blocks' when current doesn't have permission to do that |
|
13440 !!canUser('create', 'blocks'); |
|
13441 return { |
|
13442 isReusable: isReusable, |
|
13443 isVisible: isVisible |
|
13444 }; |
|
13445 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref4) { |
|
13446 var clientIds = _ref4.clientIds; |
|
13447 |
|
13448 var _dispatch = dispatch('core/editor'), |
|
13449 convertBlockToReusable = _dispatch.__experimentalConvertBlockToReusable, |
|
13450 convertBlockToStatic = _dispatch.__experimentalConvertBlockToStatic; |
|
13451 |
|
13452 return { |
|
13453 onConvertToStatic: function onConvertToStatic() { |
|
13454 convertBlockToStatic(clientIds[0]); |
|
13455 }, |
|
13456 onConvertToReusable: function onConvertToReusable() { |
|
13457 convertBlockToReusable(clientIds); |
|
13458 } |
10907 } |
13459 }; |
10908 |
13460 })])(ReusableBlockConvertButton)); |
10909 updatePostLock(settings.postLock); |
13461 |
10910 setupEditor(post, initialEdits, settings.template); |
13462 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/reusable-blocks-buttons/reusable-block-delete-button.js |
10911 |
13463 |
10912 if (settings.autosave) { |
13464 |
10913 createWarningNotice(Object(external_wp_i18n_["__"])('There is an autosave of this post that is more recent than the version below.'), { |
13465 /** |
|
13466 * WordPress dependencies |
|
13467 */ |
|
13468 |
|
13469 |
|
13470 |
|
13471 |
|
13472 |
|
13473 |
|
13474 function ReusableBlockDeleteButton(_ref) { |
|
13475 var isVisible = _ref.isVisible, |
|
13476 isDisabled = _ref.isDisabled, |
|
13477 onDelete = _ref.onDelete; |
|
13478 |
|
13479 if (!isVisible) { |
|
13480 return null; |
|
13481 } |
|
13482 |
|
13483 return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockSettingsMenuControls"], null, function (_ref2) { |
|
13484 var onClose = _ref2.onClose; |
|
13485 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
13486 disabled: isDisabled, |
|
13487 onClick: function onClick() { |
|
13488 var hasConfirmed = onDelete(); |
|
13489 |
|
13490 if (hasConfirmed) { |
|
13491 onClose(); |
|
13492 } |
|
13493 } |
|
13494 }, Object(external_this_wp_i18n_["__"])('Remove from Reusable blocks')); |
|
13495 }); |
|
13496 } |
|
13497 /* harmony default export */ var reusable_block_delete_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
|
13498 var clientId = _ref3.clientId; |
|
13499 |
|
13500 var _select = select('core/block-editor'), |
|
13501 getBlock = _select.getBlock; |
|
13502 |
|
13503 var _select2 = select('core'), |
|
13504 canUser = _select2.canUser; |
|
13505 |
|
13506 var _select3 = select('core/editor'), |
|
13507 getReusableBlock = _select3.__experimentalGetReusableBlock; |
|
13508 |
|
13509 var block = getBlock(clientId); |
|
13510 var reusableBlock = block && Object(external_this_wp_blocks_["isReusableBlock"])(block) ? getReusableBlock(block.attributes.ref) : null; |
|
13511 return { |
|
13512 isVisible: !!reusableBlock && (reusableBlock.isTemporary || !!canUser('delete', 'blocks', reusableBlock.id)), |
|
13513 isDisabled: reusableBlock && reusableBlock.isTemporary |
|
13514 }; |
|
13515 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref4, _ref5) { |
|
13516 var clientId = _ref4.clientId; |
|
13517 var select = _ref5.select; |
|
13518 |
|
13519 var _dispatch = dispatch('core/editor'), |
|
13520 deleteReusableBlock = _dispatch.__experimentalDeleteReusableBlock; |
|
13521 |
|
13522 var _select4 = select('core/block-editor'), |
|
13523 getBlock = _select4.getBlock; |
|
13524 |
|
13525 return { |
|
13526 onDelete: function onDelete() { |
|
13527 // TODO: Make this a <Confirm /> component or similar |
|
13528 // eslint-disable-next-line no-alert |
|
13529 var hasConfirmed = window.confirm( // eslint-disable-next-line @wordpress/i18n-no-collapsible-whitespace |
|
13530 Object(external_this_wp_i18n_["__"])('Are you sure you want to delete this Reusable Block?\n\n' + 'It will be permanently removed from all posts and pages that use it.')); |
|
13531 |
|
13532 if (hasConfirmed) { |
|
13533 var block = getBlock(clientId); |
|
13534 deleteReusableBlock(block.attributes.ref); |
|
13535 } |
|
13536 |
|
13537 return hasConfirmed; |
|
13538 } |
|
13539 }; |
|
13540 })])(ReusableBlockDeleteButton)); |
|
13541 |
|
13542 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/reusable-blocks-buttons/index.js |
|
13543 |
|
13544 |
|
13545 /** |
|
13546 * WordPress dependencies |
|
13547 */ |
|
13548 |
|
13549 /** |
|
13550 * Internal dependencies |
|
13551 */ |
|
13552 |
|
13553 |
|
13554 |
|
13555 |
|
13556 function ReusableBlocksButtons(_ref) { |
|
13557 var clientIds = _ref.clientIds; |
|
13558 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(reusable_block_convert_button, { |
|
13559 clientIds: clientIds |
|
13560 }), clientIds.length === 1 && Object(external_this_wp_element_["createElement"])(reusable_block_delete_button, { |
|
13561 clientId: clientIds[0] |
|
13562 })); |
|
13563 } |
|
13564 |
|
13565 /* harmony default export */ var reusable_blocks_buttons = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
13566 var _select = select('core/block-editor'), |
|
13567 getSelectedBlockClientIds = _select.getSelectedBlockClientIds; |
|
13568 |
|
13569 return { |
|
13570 clientIds: getSelectedBlockClientIds() |
|
13571 }; |
|
13572 })(ReusableBlocksButtons)); |
|
13573 |
|
13574 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/convert-to-group-buttons/index.js |
|
13575 |
|
13576 |
|
13577 /** |
|
13578 * WordPress dependencies |
|
13579 */ |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 |
|
13585 |
|
13586 function ConvertToGroupButton(_ref) { |
|
13587 var onConvertToGroup = _ref.onConvertToGroup, |
|
13588 onConvertFromGroup = _ref.onConvertFromGroup, |
|
13589 _ref$isGroupable = _ref.isGroupable, |
|
13590 isGroupable = _ref$isGroupable === void 0 ? false : _ref$isGroupable, |
|
13591 _ref$isUngroupable = _ref.isUngroupable, |
|
13592 isUngroupable = _ref$isUngroupable === void 0 ? false : _ref$isUngroupable; |
|
13593 |
|
13594 if (!isGroupable && !isUngroupable) { |
|
13595 return null; |
|
13596 } |
|
13597 |
|
13598 return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockSettingsMenuControls"], null, function (_ref2) { |
|
13599 var onClose = _ref2.onClose; |
|
13600 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, isGroupable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
13601 onClick: function onClick() { |
|
13602 onConvertToGroup(); |
|
13603 onClose(); |
|
13604 } |
|
13605 }, Object(external_this_wp_i18n_["_x"])('Group', 'verb')), isUngroupable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
13606 onClick: function onClick() { |
|
13607 onConvertFromGroup(); |
|
13608 onClose(); |
|
13609 } |
|
13610 }, Object(external_this_wp_i18n_["_x"])('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor '))); |
|
13611 }); |
|
13612 } |
|
13613 /* harmony default export */ var convert_to_group_buttons = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
13614 var _select = select('core/block-editor'), |
|
13615 getBlockRootClientId = _select.getBlockRootClientId, |
|
13616 getBlocksByClientId = _select.getBlocksByClientId, |
|
13617 canInsertBlockType = _select.canInsertBlockType, |
|
13618 getSelectedBlockClientIds = _select.getSelectedBlockClientIds; |
|
13619 |
|
13620 var _select2 = select('core/blocks'), |
|
13621 getGroupingBlockName = _select2.getGroupingBlockName; |
|
13622 |
|
13623 var clientIds = getSelectedBlockClientIds(); |
|
13624 var groupingBlockName = getGroupingBlockName(); |
|
13625 var rootClientId = clientIds && clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined; |
|
13626 var groupingBlockAvailable = canInsertBlockType(groupingBlockName, rootClientId); |
|
13627 var blocksSelection = getBlocksByClientId(clientIds); |
|
13628 var isSingleGroupingBlock = blocksSelection.length === 1 && blocksSelection[0] && blocksSelection[0].name === groupingBlockName; // Do we have |
|
13629 // 1. Grouping block available to be inserted? |
|
13630 // 2. One or more blocks selected |
|
13631 // (we allow single Blocks to become groups unless |
|
13632 // they are a soltiary group block themselves) |
|
13633 |
|
13634 var isGroupable = groupingBlockAvailable && blocksSelection.length && !isSingleGroupingBlock; // Do we have a single Group Block selected and does that group have inner blocks? |
|
13635 |
|
13636 var isUngroupable = isSingleGroupingBlock && !!blocksSelection[0].innerBlocks.length; |
|
13637 return { |
|
13638 clientIds: clientIds, |
|
13639 isGroupable: isGroupable, |
|
13640 isUngroupable: isUngroupable, |
|
13641 blocksSelection: blocksSelection, |
|
13642 groupingBlockName: groupingBlockName |
|
13643 }; |
|
13644 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) { |
|
13645 var clientIds = _ref3.clientIds, |
|
13646 _ref3$blocksSelection = _ref3.blocksSelection, |
|
13647 blocksSelection = _ref3$blocksSelection === void 0 ? [] : _ref3$blocksSelection, |
|
13648 groupingBlockName = _ref3.groupingBlockName; |
|
13649 |
|
13650 var _dispatch = dispatch('core/block-editor'), |
|
13651 replaceBlocks = _dispatch.replaceBlocks; |
|
13652 |
|
13653 return { |
|
13654 onConvertToGroup: function onConvertToGroup() { |
|
13655 // Activate the `transform` on the Grouping Block which does the conversion |
|
13656 var newBlocks = Object(external_this_wp_blocks_["switchToBlockType"])(blocksSelection, groupingBlockName); |
|
13657 |
|
13658 if (newBlocks) { |
|
13659 replaceBlocks(clientIds, newBlocks); |
|
13660 } |
|
13661 }, |
|
13662 onConvertFromGroup: function onConvertFromGroup() { |
|
13663 var innerBlocks = blocksSelection[0].innerBlocks; |
|
13664 |
|
13665 if (!innerBlocks.length) { |
|
13666 return; |
|
13667 } |
|
13668 |
|
13669 replaceBlocks(clientIds, innerBlocks); |
|
13670 } |
|
13671 }; |
|
13672 })])(ConvertToGroupButton)); |
|
13673 |
|
13674 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/index.js |
|
13675 |
|
13676 |
|
13677 |
|
13678 |
|
13679 |
|
13680 |
|
13681 |
|
13682 |
|
13683 |
|
13684 |
|
13685 function provider_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
13686 |
|
13687 function provider_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { provider_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { provider_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
13688 |
|
13689 function provider_createSuper(Derived) { return function () { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (provider_isNativeReflectConstruct()) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } |
|
13690 |
|
13691 function provider_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } |
|
13692 |
|
13693 /** |
|
13694 * External dependencies |
|
13695 */ |
|
13696 |
|
13697 |
|
13698 /** |
|
13699 * WordPress dependencies |
|
13700 */ |
|
13701 |
|
13702 |
|
13703 |
|
13704 |
|
13705 |
|
13706 |
|
13707 |
|
13708 |
|
13709 |
|
13710 |
|
13711 /** |
|
13712 * Internal dependencies |
|
13713 */ |
|
13714 |
|
13715 |
|
13716 |
|
13717 |
|
13718 |
|
13719 /** |
|
13720 * Fetches link suggestions from the API. This function is an exact copy of a function found at: |
|
13721 * |
|
13722 * wordpress/editor/src/components/provider/index.js |
|
13723 * |
|
13724 * It seems like there is no suitable package to import this from. Ideally it would be either part of core-data. |
|
13725 * Until we refactor it, just copying the code is the simplest solution. |
|
13726 * |
|
13727 * @param {Object} search |
|
13728 * @param {number} perPage |
|
13729 * @return {Promise<Object[]>} List of suggestions |
|
13730 */ |
|
13731 |
|
13732 var fetchLinkSuggestions = /*#__PURE__*/function () { |
|
13733 var _ref = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee(search) { |
|
13734 var _ref2, |
|
13735 _ref2$perPage, |
|
13736 perPage, |
|
13737 posts, |
|
13738 _args = arguments; |
|
13739 |
|
13740 return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) { |
|
13741 while (1) { |
|
13742 switch (_context.prev = _context.next) { |
|
13743 case 0: |
|
13744 _ref2 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref2$perPage = _ref2.perPage, perPage = _ref2$perPage === void 0 ? 20 : _ref2$perPage; |
|
13745 _context.next = 3; |
|
13746 return external_this_wp_apiFetch_default()({ |
|
13747 path: Object(external_this_wp_url_["addQueryArgs"])('/wp/v2/search', { |
|
13748 search: search, |
|
13749 per_page: perPage, |
|
13750 type: 'post' |
|
13751 }) |
|
13752 }); |
|
13753 |
|
13754 case 3: |
|
13755 posts = _context.sent; |
|
13756 return _context.abrupt("return", Object(external_this_lodash_["map"])(posts, function (post) { |
|
13757 return { |
|
13758 id: post.id, |
|
13759 url: post.url, |
|
13760 title: Object(external_this_wp_htmlEntities_["decodeEntities"])(post.title) || Object(external_this_wp_i18n_["__"])('(no title)'), |
|
13761 type: post.subtype || post.type |
|
13762 }; |
|
13763 })); |
|
13764 |
|
13765 case 5: |
|
13766 case "end": |
|
13767 return _context.stop(); |
|
13768 } |
|
13769 } |
|
13770 }, _callee); |
|
13771 })); |
|
13772 |
|
13773 return function fetchLinkSuggestions(_x) { |
|
13774 return _ref.apply(this, arguments); |
|
13775 }; |
|
13776 }(); |
|
13777 |
|
13778 var provider_EditorProvider = /*#__PURE__*/function (_Component) { |
|
13779 Object(inherits["a" /* default */])(EditorProvider, _Component); |
|
13780 |
|
13781 var _super = provider_createSuper(EditorProvider); |
|
13782 |
|
13783 function EditorProvider(props) { |
|
13784 var _this; |
|
13785 |
|
13786 Object(classCallCheck["a" /* default */])(this, EditorProvider); |
|
13787 |
|
13788 _this = _super.apply(this, arguments); |
|
13789 _this.getBlockEditorSettings = memize_default()(_this.getBlockEditorSettings, { |
|
13790 maxSize: 1 |
|
13791 }); |
|
13792 _this.getDefaultBlockContext = memize_default()(_this.getDefaultBlockContext, { |
|
13793 maxSize: 1 |
|
13794 }); // Assume that we don't need to initialize in the case of an error recovery. |
|
13795 |
|
13796 if (props.recovery) { |
|
13797 return Object(possibleConstructorReturn["a" /* default */])(_this); |
|
13798 } |
|
13799 |
|
13800 props.updatePostLock(props.settings.postLock); |
|
13801 props.setupEditor(props.post, props.initialEdits, props.settings.template); |
|
13802 |
|
13803 if (props.settings.autosave) { |
|
13804 props.createWarningNotice(Object(external_this_wp_i18n_["__"])('There is an autosave of this post that is more recent than the version below.'), { |
|
13805 id: 'autosave-exists', |
10914 id: 'autosave-exists', |
13806 actions: [{ |
10915 actions: [{ |
13807 label: Object(external_this_wp_i18n_["__"])('View the autosave'), |
10916 label: Object(external_wp_i18n_["__"])('View the autosave'), |
13808 url: props.settings.autosave.editLink |
10917 url: settings.autosave.editLink |
13809 }] |
10918 }] |
13810 }); |
10919 }); |
13811 } |
10920 } |
13812 |
10921 |
13813 return _this; |
10922 return () => { |
13814 } |
10923 __experimentalTearDownEditor(); |
13815 |
10924 }; |
13816 Object(createClass["a" /* default */])(EditorProvider, [{ |
10925 }, []); // Synchronize the editor settings as they change |
13817 key: "getBlockEditorSettings", |
10926 |
13818 value: function getBlockEditorSettings(settings, reusableBlocks, __experimentalFetchReusableBlocks, hasUploadPermissions, canUserUseUnfilteredHTML, undo, shouldInsertAtTheTop) { |
10927 Object(external_wp_element_["useEffect"])(() => { |
13819 return provider_objectSpread({}, Object(external_this_lodash_["pick"])(settings, ['__experimentalBlockDirectory', '__experimentalBlockPatterns', '__experimentalBlockPatternCategories', '__experimentalEnableCustomSpacing', '__experimentalEnableLegacyWidgetBlock', '__experimentalEnableLinkColor', '__experimentalEnableFullSiteEditing', '__experimentalEnableFullSiteEditingDemo', '__experimentalFeatures', '__experimentalGlobalStylesUserEntityId', '__experimentalGlobalStylesBase', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', 'alignWide', 'allowedBlockTypes', 'availableLegacyWidgets', 'bodyPlaceholder', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomGradients', 'enableCustomUnits', 'enableCustomLineHeight', 'focusMode', 'fontSizes', 'gradients', 'hasFixedToolbar', 'hasPermissionsToManageWidgets', 'imageEditing', 'imageSizes', 'imageDimensions', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder']), { |
10928 updateEditorSettings(settings); |
13820 mediaUpload: hasUploadPermissions ? mediaUpload : undefined, |
10929 }, [settings]); |
13821 __experimentalReusableBlocks: reusableBlocks, |
10930 |
13822 __experimentalFetchReusableBlocks: __experimentalFetchReusableBlocks, |
10931 if (!isReady) { |
13823 __experimentalFetchLinkSuggestions: fetchLinkSuggestions, |
10932 return null; |
13824 __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML, |
10933 } |
13825 __experimentalUndo: undo, |
10934 |
13826 __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop |
10935 return Object(external_wp_element_["createElement"])(external_wp_coreData_["EntityProvider"], { |
13827 }); |
10936 kind: "root", |
13828 } |
10937 type: "site" |
13829 }, { |
10938 }, Object(external_wp_element_["createElement"])(external_wp_coreData_["EntityProvider"], { |
13830 key: "getDefaultBlockContext", |
10939 kind: "postType", |
13831 value: function getDefaultBlockContext(postId, postType) { |
10940 type: post.type, |
13832 return { |
10941 id: post.id |
13833 postId: postId, |
10942 }, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockContextProvider"], { |
13834 postType: postType |
10943 value: defaultBlockContext |
13835 }; |
10944 }, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockEditorProvider"], { |
13836 } |
10945 value: blocks, |
13837 }, { |
10946 onChange: onChange, |
13838 key: "componentDidMount", |
10947 onInput: onInput, |
13839 value: function componentDidMount() { |
10948 selection: selection, |
13840 this.props.updateEditorSettings(this.props.settings); |
10949 settings: editorSettings, |
13841 } |
10950 useSubRegistry: false |
13842 }, { |
10951 }, children, Object(external_wp_element_["createElement"])(external_wp_reusableBlocks_["ReusableBlocksMenuItems"], null))))); |
13843 key: "componentDidUpdate", |
10952 } |
13844 value: function componentDidUpdate(prevProps) { |
10953 |
13845 if (this.props.settings !== prevProps.settings) { |
10954 /* harmony default export */ var provider = (with_registry_provider(EditorProvider)); |
13846 this.props.updateEditorSettings(this.props.settings); |
10955 |
13847 } |
10956 // EXTERNAL MODULE: external ["wp","serverSideRender"] |
13848 } |
10957 var external_wp_serverSideRender_ = __webpack_require__("JREk"); |
13849 }, { |
10958 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_); |
13850 key: "componentWillUnmount", |
|
13851 value: function componentWillUnmount() { |
|
13852 this.props.tearDownEditor(); |
|
13853 } |
|
13854 }, { |
|
13855 key: "render", |
|
13856 value: function render() { |
|
13857 var _this$props = this.props, |
|
13858 canUserUseUnfilteredHTML = _this$props.canUserUseUnfilteredHTML, |
|
13859 children = _this$props.children, |
|
13860 post = _this$props.post, |
|
13861 blocks = _this$props.blocks, |
|
13862 resetEditorBlocks = _this$props.resetEditorBlocks, |
|
13863 selectionStart = _this$props.selectionStart, |
|
13864 selectionEnd = _this$props.selectionEnd, |
|
13865 isReady = _this$props.isReady, |
|
13866 settings = _this$props.settings, |
|
13867 reusableBlocks = _this$props.reusableBlocks, |
|
13868 resetEditorBlocksWithoutUndoLevel = _this$props.resetEditorBlocksWithoutUndoLevel, |
|
13869 hasUploadPermissions = _this$props.hasUploadPermissions, |
|
13870 isPostTitleSelected = _this$props.isPostTitleSelected, |
|
13871 __experimentalFetchReusableBlocks = _this$props.__experimentalFetchReusableBlocks, |
|
13872 undo = _this$props.undo; |
|
13873 |
|
13874 if (!isReady) { |
|
13875 return null; |
|
13876 } |
|
13877 |
|
13878 var editorSettings = this.getBlockEditorSettings(settings, reusableBlocks, __experimentalFetchReusableBlocks, hasUploadPermissions, canUserUseUnfilteredHTML, undo, isPostTitleSelected); |
|
13879 var defaultBlockContext = this.getDefaultBlockContext(post.id, post.type); |
|
13880 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["__unstableEditorStyles"], { |
|
13881 styles: settings.styles |
|
13882 }), Object(external_this_wp_element_["createElement"])(external_this_wp_coreData_["EntityProvider"], { |
|
13883 kind: "root", |
|
13884 type: "site" |
|
13885 }, Object(external_this_wp_element_["createElement"])(external_this_wp_coreData_["EntityProvider"], { |
|
13886 kind: "postType", |
|
13887 type: post.type, |
|
13888 id: post.id |
|
13889 }, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockContextProvider"], { |
|
13890 value: defaultBlockContext |
|
13891 }, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockEditorProvider"], { |
|
13892 value: blocks, |
|
13893 onInput: resetEditorBlocksWithoutUndoLevel, |
|
13894 onChange: resetEditorBlocks, |
|
13895 selectionStart: selectionStart, |
|
13896 selectionEnd: selectionEnd, |
|
13897 settings: editorSettings, |
|
13898 useSubRegistry: false |
|
13899 }, children, Object(external_this_wp_element_["createElement"])(reusable_blocks_buttons, null), Object(external_this_wp_element_["createElement"])(convert_to_group_buttons, null)))))); |
|
13900 } |
|
13901 }]); |
|
13902 |
|
13903 return EditorProvider; |
|
13904 }(external_this_wp_element_["Component"]); |
|
13905 |
|
13906 /* harmony default export */ var provider = (Object(external_this_wp_compose_["compose"])([with_registry_provider, Object(external_this_wp_data_["withSelect"])(function (select) { |
|
13907 var _select = select('core/editor'), |
|
13908 canUserUseUnfilteredHTML = _select.canUserUseUnfilteredHTML, |
|
13909 isEditorReady = _select.__unstableIsEditorReady, |
|
13910 getEditorBlocks = _select.getEditorBlocks, |
|
13911 getEditorSelectionStart = _select.getEditorSelectionStart, |
|
13912 getEditorSelectionEnd = _select.getEditorSelectionEnd, |
|
13913 __experimentalGetReusableBlocks = _select.__experimentalGetReusableBlocks, |
|
13914 isPostTitleSelected = _select.isPostTitleSelected; |
|
13915 |
|
13916 var _select2 = select('core'), |
|
13917 canUser = _select2.canUser; |
|
13918 |
|
13919 return { |
|
13920 canUserUseUnfilteredHTML: canUserUseUnfilteredHTML(), |
|
13921 isReady: isEditorReady(), |
|
13922 blocks: getEditorBlocks(), |
|
13923 selectionStart: getEditorSelectionStart(), |
|
13924 selectionEnd: getEditorSelectionEnd(), |
|
13925 reusableBlocks: __experimentalGetReusableBlocks(), |
|
13926 hasUploadPermissions: Object(external_this_lodash_["defaultTo"])(canUser('create', 'media'), true), |
|
13927 // This selector is only defined on mobile. |
|
13928 isPostTitleSelected: isPostTitleSelected && isPostTitleSelected() |
|
13929 }; |
|
13930 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
13931 var _dispatch = dispatch('core/editor'), |
|
13932 setupEditor = _dispatch.setupEditor, |
|
13933 updatePostLock = _dispatch.updatePostLock, |
|
13934 resetEditorBlocks = _dispatch.resetEditorBlocks, |
|
13935 updateEditorSettings = _dispatch.updateEditorSettings, |
|
13936 __experimentalFetchReusableBlocks = _dispatch.__experimentalFetchReusableBlocks, |
|
13937 __experimentalTearDownEditor = _dispatch.__experimentalTearDownEditor, |
|
13938 undo = _dispatch.undo; |
|
13939 |
|
13940 var _dispatch2 = dispatch('core/notices'), |
|
13941 createWarningNotice = _dispatch2.createWarningNotice; |
|
13942 |
|
13943 return { |
|
13944 setupEditor: setupEditor, |
|
13945 updatePostLock: updatePostLock, |
|
13946 createWarningNotice: createWarningNotice, |
|
13947 resetEditorBlocks: resetEditorBlocks, |
|
13948 updateEditorSettings: updateEditorSettings, |
|
13949 resetEditorBlocksWithoutUndoLevel: function resetEditorBlocksWithoutUndoLevel(blocks, options) { |
|
13950 resetEditorBlocks(blocks, provider_objectSpread({}, options, { |
|
13951 __unstableShouldCreateUndoLevel: false |
|
13952 })); |
|
13953 }, |
|
13954 tearDownEditor: __experimentalTearDownEditor, |
|
13955 __experimentalFetchReusableBlocks: __experimentalFetchReusableBlocks, |
|
13956 undo: undo |
|
13957 }; |
|
13958 })])(provider_EditorProvider)); |
|
13959 |
|
13960 // EXTERNAL MODULE: external {"this":["wp","serverSideRender"]} |
|
13961 var external_this_wp_serverSideRender_ = __webpack_require__(83); |
|
13962 var external_this_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_serverSideRender_); |
|
13963 |
10959 |
13964 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/deprecated.js |
10960 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/deprecated.js |
13965 |
10961 |
13966 |
10962 |
13967 // Block Creation Components |
10963 // Block Creation Components |
14155 |
11148 |
14156 |
11149 |
14157 |
11150 |
14158 /***/ }), |
11151 /***/ }), |
14159 |
11152 |
14160 /***/ 45: |
11153 /***/ "RMJe": |
|
11154 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11155 |
|
11156 "use strict"; |
|
11157 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
|
11158 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
11159 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
|
11160 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
11161 |
|
11162 |
|
11163 /** |
|
11164 * WordPress dependencies |
|
11165 */ |
|
11166 |
|
11167 const check = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
|
11168 xmlns: "http://www.w3.org/2000/svg", |
|
11169 viewBox: "0 0 24 24" |
|
11170 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
|
11171 d: "M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z" |
|
11172 })); |
|
11173 /* harmony default export */ __webpack_exports__["a"] = (check); |
|
11174 |
|
11175 |
|
11176 /***/ }), |
|
11177 |
|
11178 /***/ "Rk8H": |
|
11179 /***/ (function(module, exports, __webpack_require__) { |
|
11180 |
|
11181 // Load in dependencies |
|
11182 var computedStyle = __webpack_require__("jTPX"); |
|
11183 |
|
11184 /** |
|
11185 * Calculate the `line-height` of a given node |
|
11186 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. |
|
11187 * @returns {Number} `line-height` of the element in pixels |
|
11188 */ |
|
11189 function lineHeight(node) { |
|
11190 // Grab the line-height via style |
|
11191 var lnHeightStr = computedStyle(node, 'line-height'); |
|
11192 var lnHeight = parseFloat(lnHeightStr, 10); |
|
11193 |
|
11194 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') |
|
11195 if (lnHeightStr === lnHeight + '') { |
|
11196 // Save the old lineHeight style and update the em unit to the element |
|
11197 var _lnHeightStyle = node.style.lineHeight; |
|
11198 node.style.lineHeight = lnHeightStr + 'em'; |
|
11199 |
|
11200 // Calculate the em based height |
|
11201 lnHeightStr = computedStyle(node, 'line-height'); |
|
11202 lnHeight = parseFloat(lnHeightStr, 10); |
|
11203 |
|
11204 // Revert the lineHeight style |
|
11205 if (_lnHeightStyle) { |
|
11206 node.style.lineHeight = _lnHeightStyle; |
|
11207 } else { |
|
11208 delete node.style.lineHeight; |
|
11209 } |
|
11210 } |
|
11211 |
|
11212 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) |
|
11213 // DEV: `em` units are converted to `pt` in IE6 |
|
11214 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length |
|
11215 if (lnHeightStr.indexOf('pt') !== -1) { |
|
11216 lnHeight *= 4; |
|
11217 lnHeight /= 3; |
|
11218 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) |
|
11219 } else if (lnHeightStr.indexOf('mm') !== -1) { |
|
11220 lnHeight *= 96; |
|
11221 lnHeight /= 25.4; |
|
11222 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) |
|
11223 } else if (lnHeightStr.indexOf('cm') !== -1) { |
|
11224 lnHeight *= 96; |
|
11225 lnHeight /= 2.54; |
|
11226 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) |
|
11227 } else if (lnHeightStr.indexOf('in') !== -1) { |
|
11228 lnHeight *= 96; |
|
11229 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) |
|
11230 } else if (lnHeightStr.indexOf('pc') !== -1) { |
|
11231 lnHeight *= 16; |
|
11232 } |
|
11233 |
|
11234 // Continue our computation |
|
11235 lnHeight = Math.round(lnHeight); |
|
11236 |
|
11237 // If the line-height is "normal", calculate by font-size |
|
11238 if (lnHeightStr === 'normal') { |
|
11239 // Create a temporary node |
|
11240 var nodeName = node.nodeName; |
|
11241 var _node = document.createElement(nodeName); |
|
11242 _node.innerHTML = ' '; |
|
11243 |
|
11244 // If we have a text area, reset it to only 1 row |
|
11245 // https://github.com/twolfson/line-height/issues/4 |
|
11246 if (nodeName.toUpperCase() === 'TEXTAREA') { |
|
11247 _node.setAttribute('rows', '1'); |
|
11248 } |
|
11249 |
|
11250 // Set the font-size of the element |
|
11251 var fontSizeStr = computedStyle(node, 'font-size'); |
|
11252 _node.style.fontSize = fontSizeStr; |
|
11253 |
|
11254 // Remove default padding/border which can affect offset height |
|
11255 // https://github.com/twolfson/line-height/issues/4 |
|
11256 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight |
|
11257 _node.style.padding = '0px'; |
|
11258 _node.style.border = '0px'; |
|
11259 |
|
11260 // Append it to the body |
|
11261 var body = document.body; |
|
11262 body.appendChild(_node); |
|
11263 |
|
11264 // Assume the line height of the element is the height |
|
11265 var height = _node.offsetHeight; |
|
11266 lnHeight = height; |
|
11267 |
|
11268 // Remove our child from the DOM |
|
11269 body.removeChild(_node); |
|
11270 } |
|
11271 |
|
11272 // Return the calculated height |
|
11273 return lnHeight; |
|
11274 } |
|
11275 |
|
11276 // Export lineHeight |
|
11277 module.exports = lineHeight; |
|
11278 |
|
11279 |
|
11280 /***/ }), |
|
11281 |
|
11282 /***/ "RxS6": |
14161 /***/ (function(module, exports) { |
11283 /***/ (function(module, exports) { |
14162 |
11284 |
14163 (function() { module.exports = this["wp"]["apiFetch"]; }()); |
11285 (function() { module.exports = window["wp"]["keycodes"]; }()); |
14164 |
11286 |
14165 /***/ }), |
11287 /***/ }), |
14166 |
11288 |
14167 /***/ 5: |
11289 /***/ "TSYQ": |
14168 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
14169 |
|
14170 "use strict"; |
|
14171 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
14172 function _defineProperty(obj, key, value) { |
|
14173 if (key in obj) { |
|
14174 Object.defineProperty(obj, key, { |
|
14175 value: value, |
|
14176 enumerable: true, |
|
14177 configurable: true, |
|
14178 writable: true |
|
14179 }); |
|
14180 } else { |
|
14181 obj[key] = value; |
|
14182 } |
|
14183 |
|
14184 return obj; |
|
14185 } |
|
14186 |
|
14187 /***/ }), |
|
14188 |
|
14189 /***/ 50: |
|
14190 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
14191 |
|
14192 "use strict"; |
|
14193 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); |
|
14194 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
|
14195 try { |
|
14196 var info = gen[key](arg); |
|
14197 var value = info.value; |
|
14198 } catch (error) { |
|
14199 reject(error); |
|
14200 return; |
|
14201 } |
|
14202 |
|
14203 if (info.done) { |
|
14204 resolve(value); |
|
14205 } else { |
|
14206 Promise.resolve(value).then(_next, _throw); |
|
14207 } |
|
14208 } |
|
14209 |
|
14210 function _asyncToGenerator(fn) { |
|
14211 return function () { |
|
14212 var self = this, |
|
14213 args = arguments; |
|
14214 return new Promise(function (resolve, reject) { |
|
14215 var gen = fn.apply(self, args); |
|
14216 |
|
14217 function _next(value) { |
|
14218 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
|
14219 } |
|
14220 |
|
14221 function _throw(err) { |
|
14222 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
|
14223 } |
|
14224 |
|
14225 _next(undefined); |
|
14226 }); |
|
14227 }; |
|
14228 } |
|
14229 |
|
14230 /***/ }), |
|
14231 |
|
14232 /***/ 52: |
|
14233 /***/ (function(module, exports) { |
|
14234 |
|
14235 (function() { module.exports = this["wp"]["keyboardShortcuts"]; }()); |
|
14236 |
|
14237 /***/ }), |
|
14238 |
|
14239 /***/ 6: |
|
14240 /***/ (function(module, exports) { |
|
14241 |
|
14242 (function() { module.exports = this["wp"]["primitives"]; }()); |
|
14243 |
|
14244 /***/ }), |
|
14245 |
|
14246 /***/ 60: |
|
14247 /***/ (function(module, exports, __webpack_require__) { |
11290 /***/ (function(module, exports, __webpack_require__) { |
14248 |
11291 |
14249 /** |
11292 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! |
14250 * Memize options object. |
11293 Copyright (c) 2018 Jed Watson. |
14251 * |
11294 Licensed under the MIT License (MIT), see |
14252 * @typedef MemizeOptions |
11295 http://jedwatson.github.io/classnames |
14253 * |
11296 */ |
14254 * @property {number} [maxSize] Maximum size of the cache. |
11297 /* global define */ |
14255 */ |
11298 |
14256 |
11299 (function () { |
14257 /** |
11300 'use strict'; |
14258 * Internal cache entry. |
11301 |
14259 * |
11302 var hasOwn = {}.hasOwnProperty; |
14260 * @typedef MemizeCacheNode |
11303 |
14261 * |
11304 function classNames() { |
14262 * @property {?MemizeCacheNode|undefined} [prev] Previous node. |
11305 var classes = []; |
14263 * @property {?MemizeCacheNode|undefined} [next] Next node. |
11306 |
14264 * @property {Array<*>} args Function arguments for cache |
11307 for (var i = 0; i < arguments.length; i++) { |
14265 * entry. |
11308 var arg = arguments[i]; |
14266 * @property {*} val Function result. |
11309 if (!arg) continue; |
14267 */ |
11310 |
14268 |
11311 var argType = typeof arg; |
14269 /** |
11312 |
14270 * Properties of the enhanced function for controlling cache. |
11313 if (argType === 'string' || argType === 'number') { |
14271 * |
11314 classes.push(arg); |
14272 * @typedef MemizeMemoizedFunction |
11315 } else if (Array.isArray(arg)) { |
14273 * |
11316 if (arg.length) { |
14274 * @property {()=>void} clear Clear the cache. |
11317 var inner = classNames.apply(null, arg); |
14275 */ |
11318 if (inner) { |
14276 |
11319 classes.push(inner); |
14277 /** |
11320 } |
14278 * Accepts a function to be memoized, and returns a new memoized function, with |
11321 } |
14279 * optional options. |
11322 } else if (argType === 'object') { |
14280 * |
11323 if (arg.toString === Object.prototype.toString) { |
14281 * @template {Function} F |
11324 for (var key in arg) { |
14282 * |
11325 if (hasOwn.call(arg, key) && arg[key]) { |
14283 * @param {F} fn Function to memoize. |
11326 classes.push(key); |
14284 * @param {MemizeOptions} [options] Options object. |
11327 } |
14285 * |
11328 } |
14286 * @return {F & MemizeMemoizedFunction} Memoized function. |
11329 } else { |
14287 */ |
11330 classes.push(arg.toString()); |
14288 function memize( fn, options ) { |
|
14289 var size = 0; |
|
14290 |
|
14291 /** @type {?MemizeCacheNode|undefined} */ |
|
14292 var head; |
|
14293 |
|
14294 /** @type {?MemizeCacheNode|undefined} */ |
|
14295 var tail; |
|
14296 |
|
14297 options = options || {}; |
|
14298 |
|
14299 function memoized( /* ...args */ ) { |
|
14300 var node = head, |
|
14301 len = arguments.length, |
|
14302 args, i; |
|
14303 |
|
14304 searchCache: while ( node ) { |
|
14305 // Perform a shallow equality test to confirm that whether the node |
|
14306 // under test is a candidate for the arguments passed. Two arrays |
|
14307 // are shallowly equal if their length matches and each entry is |
|
14308 // strictly equal between the two sets. Avoid abstracting to a |
|
14309 // function which could incur an arguments leaking deoptimization. |
|
14310 |
|
14311 // Check whether node arguments match arguments length |
|
14312 if ( node.args.length !== arguments.length ) { |
|
14313 node = node.next; |
|
14314 continue; |
|
14315 } |
|
14316 |
|
14317 // Check whether node arguments match arguments values |
|
14318 for ( i = 0; i < len; i++ ) { |
|
14319 if ( node.args[ i ] !== arguments[ i ] ) { |
|
14320 node = node.next; |
|
14321 continue searchCache; |
|
14322 } |
11331 } |
14323 } |
11332 } |
14324 |
11333 } |
14325 // At this point we can assume we've found a match |
11334 |
14326 |
11335 return classes.join(' '); |
14327 // Surface matched node to head if not already |
11336 } |
14328 if ( node !== head ) { |
11337 |
14329 // As tail, shift to previous. Must only shift if not also |
11338 if ( true && module.exports) { |
14330 // head, since if both head and tail, there is no previous. |
11339 classNames.default = classNames; |
14331 if ( node === tail ) { |
11340 module.exports = classNames; |
14332 tail = node.prev; |
11341 } else if (true) { |
14333 } |
11342 // register as 'classnames', consistent with npm package name |
14334 |
11343 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
14335 // Adjust siblings to point to each other. If node was tail, |
11344 return classNames; |
14336 // this also handles new tail's empty `next` assignment. |
11345 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), |
14337 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; |
11346 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
14338 if ( node.next ) { |
11347 } else {} |
14339 node.next.prev = node.prev; |
11348 }()); |
14340 } |
11349 |
14341 |
11350 |
14342 node.next = head; |
11351 /***/ }), |
14343 node.prev = null; |
11352 |
14344 /** @type {MemizeCacheNode} */ ( head ).prev = node; |
11353 /***/ "Tqx9": |
14345 head = node; |
11354 /***/ (function(module, exports) { |
|
11355 |
|
11356 (function() { module.exports = window["wp"]["primitives"]; }()); |
|
11357 |
|
11358 /***/ }), |
|
11359 |
|
11360 /***/ "WbBG": |
|
11361 /***/ (function(module, exports, __webpack_require__) { |
|
11362 |
|
11363 "use strict"; |
|
11364 /** |
|
11365 * Copyright (c) 2013-present, Facebook, Inc. |
|
11366 * |
|
11367 * This source code is licensed under the MIT license found in the |
|
11368 * LICENSE file in the root directory of this source tree. |
|
11369 */ |
|
11370 |
|
11371 |
|
11372 |
|
11373 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; |
|
11374 |
|
11375 module.exports = ReactPropTypesSecret; |
|
11376 |
|
11377 |
|
11378 /***/ }), |
|
11379 |
|
11380 /***/ "YLtl": |
|
11381 /***/ (function(module, exports) { |
|
11382 |
|
11383 (function() { module.exports = window["lodash"]; }()); |
|
11384 |
|
11385 /***/ }), |
|
11386 |
|
11387 /***/ "axFQ": |
|
11388 /***/ (function(module, exports) { |
|
11389 |
|
11390 (function() { module.exports = window["wp"]["blockEditor"]; }()); |
|
11391 |
|
11392 /***/ }), |
|
11393 |
|
11394 /***/ "bWcr": |
|
11395 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11396 |
|
11397 "use strict"; |
|
11398 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
|
11399 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
11400 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
|
11401 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
11402 |
|
11403 |
|
11404 /** |
|
11405 * WordPress dependencies |
|
11406 */ |
|
11407 |
|
11408 const closeSmall = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
|
11409 xmlns: "http://www.w3.org/2000/svg", |
|
11410 viewBox: "0 0 24 24" |
|
11411 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
|
11412 d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" |
|
11413 })); |
|
11414 /* harmony default export */ __webpack_exports__["a"] = (closeSmall); |
|
11415 |
|
11416 |
|
11417 /***/ }), |
|
11418 |
|
11419 /***/ "cDcd": |
|
11420 /***/ (function(module, exports) { |
|
11421 |
|
11422 (function() { module.exports = window["React"]; }()); |
|
11423 |
|
11424 /***/ }), |
|
11425 |
|
11426 /***/ "diJD": |
|
11427 /***/ (function(module, exports) { |
|
11428 |
|
11429 (function() { module.exports = window["wp"]["reusableBlocks"]; }()); |
|
11430 |
|
11431 /***/ }), |
|
11432 |
|
11433 /***/ "g56x": |
|
11434 /***/ (function(module, exports) { |
|
11435 |
|
11436 (function() { module.exports = window["wp"]["hooks"]; }()); |
|
11437 |
|
11438 /***/ }), |
|
11439 |
|
11440 /***/ "hF7m": |
|
11441 /***/ (function(module, exports) { |
|
11442 |
|
11443 (function() { module.exports = window["wp"]["keyboardShortcuts"]; }()); |
|
11444 |
|
11445 /***/ }), |
|
11446 |
|
11447 /***/ "iClF": |
|
11448 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11449 |
|
11450 "use strict"; |
|
11451 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
|
11452 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
11453 /** |
|
11454 * WordPress dependencies |
|
11455 */ |
|
11456 |
|
11457 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ |
|
11458 |
|
11459 /** |
|
11460 * Return an SVG icon. |
|
11461 * |
|
11462 * @param {IconProps} props icon is the SVG component to render |
|
11463 * size is a number specifiying the icon size in pixels |
|
11464 * Other props will be passed to wrapped SVG component |
|
11465 * |
|
11466 * @return {JSX.Element} Icon component |
|
11467 */ |
|
11468 |
|
11469 function Icon({ |
|
11470 icon, |
|
11471 size = 24, |
|
11472 ...props |
|
11473 }) { |
|
11474 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["cloneElement"])(icon, { |
|
11475 width: size, |
|
11476 height: size, |
|
11477 ...props |
|
11478 }); |
|
11479 } |
|
11480 |
|
11481 /* harmony default export */ __webpack_exports__["a"] = (Icon); |
|
11482 |
|
11483 |
|
11484 /***/ }), |
|
11485 |
|
11486 /***/ "jTPX": |
|
11487 /***/ (function(module, exports) { |
|
11488 |
|
11489 // This code has been refactored for 140 bytes |
|
11490 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js |
|
11491 var computedStyle = function (el, prop, getComputedStyle) { |
|
11492 getComputedStyle = window.getComputedStyle; |
|
11493 |
|
11494 // In one fell swoop |
|
11495 return ( |
|
11496 // If we have getComputedStyle |
|
11497 getComputedStyle ? |
|
11498 // Query it |
|
11499 // TODO: From CSS-Query notes, we might need (node, null) for FF |
|
11500 getComputedStyle(el) : |
|
11501 |
|
11502 // Otherwise, we are in IE and use currentStyle |
|
11503 el.currentStyle |
|
11504 )[ |
|
11505 // Switch to camelCase for CSSOM |
|
11506 // DEV: Grabbed from jQuery |
|
11507 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 |
|
11508 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 |
|
11509 prop.replace(/-(\w)/gi, function (word, letter) { |
|
11510 return letter.toUpperCase(); |
|
11511 }) |
|
11512 ]; |
|
11513 }; |
|
11514 |
|
11515 module.exports = computedStyle; |
|
11516 |
|
11517 |
|
11518 /***/ }), |
|
11519 |
|
11520 /***/ "jZUy": |
|
11521 /***/ (function(module, exports) { |
|
11522 |
|
11523 (function() { module.exports = window["wp"]["coreData"]; }()); |
|
11524 |
|
11525 /***/ }), |
|
11526 |
|
11527 /***/ "l3Sj": |
|
11528 /***/ (function(module, exports) { |
|
11529 |
|
11530 (function() { module.exports = window["wp"]["i18n"]; }()); |
|
11531 |
|
11532 /***/ }), |
|
11533 |
|
11534 /***/ "onLe": |
|
11535 /***/ (function(module, exports) { |
|
11536 |
|
11537 (function() { module.exports = window["wp"]["notices"]; }()); |
|
11538 |
|
11539 /***/ }), |
|
11540 |
|
11541 /***/ "pPDe": |
|
11542 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11543 |
|
11544 "use strict"; |
|
11545 |
|
11546 |
|
11547 var LEAF_KEY, hasWeakMap; |
|
11548 |
|
11549 /** |
|
11550 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
11551 * |
|
11552 * @type {Object} |
|
11553 */ |
|
11554 LEAF_KEY = {}; |
|
11555 |
|
11556 /** |
|
11557 * Whether environment supports WeakMap. |
|
11558 * |
|
11559 * @type {boolean} |
|
11560 */ |
|
11561 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
11562 |
|
11563 /** |
|
11564 * Returns the first argument as the sole entry in an array. |
|
11565 * |
|
11566 * @param {*} value Value to return. |
|
11567 * |
|
11568 * @return {Array} Value returned as entry in array. |
|
11569 */ |
|
11570 function arrayOf( value ) { |
|
11571 return [ value ]; |
|
11572 } |
|
11573 |
|
11574 /** |
|
11575 * Returns true if the value passed is object-like, or false otherwise. A value |
|
11576 * is object-like if it can support property assignment, e.g. object or array. |
|
11577 * |
|
11578 * @param {*} value Value to test. |
|
11579 * |
|
11580 * @return {boolean} Whether value is object-like. |
|
11581 */ |
|
11582 function isObjectLike( value ) { |
|
11583 return !! value && 'object' === typeof value; |
|
11584 } |
|
11585 |
|
11586 /** |
|
11587 * Creates and returns a new cache object. |
|
11588 * |
|
11589 * @return {Object} Cache object. |
|
11590 */ |
|
11591 function createCache() { |
|
11592 var cache = { |
|
11593 clear: function() { |
|
11594 cache.head = null; |
|
11595 }, |
|
11596 }; |
|
11597 |
|
11598 return cache; |
|
11599 } |
|
11600 |
|
11601 /** |
|
11602 * Returns true if entries within the two arrays are strictly equal by |
|
11603 * reference from a starting index. |
|
11604 * |
|
11605 * @param {Array} a First array. |
|
11606 * @param {Array} b Second array. |
|
11607 * @param {number} fromIndex Index from which to start comparison. |
|
11608 * |
|
11609 * @return {boolean} Whether arrays are shallowly equal. |
|
11610 */ |
|
11611 function isShallowEqual( a, b, fromIndex ) { |
|
11612 var i; |
|
11613 |
|
11614 if ( a.length !== b.length ) { |
|
11615 return false; |
|
11616 } |
|
11617 |
|
11618 for ( i = fromIndex; i < a.length; i++ ) { |
|
11619 if ( a[ i ] !== b[ i ] ) { |
|
11620 return false; |
|
11621 } |
|
11622 } |
|
11623 |
|
11624 return true; |
|
11625 } |
|
11626 |
|
11627 /** |
|
11628 * Returns a memoized selector function. The getDependants function argument is |
|
11629 * called before the memoized selector and is expected to return an immutable |
|
11630 * reference or array of references on which the selector depends for computing |
|
11631 * its own return value. The memoize cache is preserved only as long as those |
|
11632 * dependant references remain the same. If getDependants returns a different |
|
11633 * reference(s), the cache is cleared and the selector value regenerated. |
|
11634 * |
|
11635 * @param {Function} selector Selector function. |
|
11636 * @param {Function} getDependants Dependant getter returning an immutable |
|
11637 * reference or array of reference used in |
|
11638 * cache bust consideration. |
|
11639 * |
|
11640 * @return {Function} Memoized selector. |
|
11641 */ |
|
11642 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
11643 var rootCache, getCache; |
|
11644 |
|
11645 // Use object source as dependant if getter not provided |
|
11646 if ( ! getDependants ) { |
|
11647 getDependants = arrayOf; |
|
11648 } |
|
11649 |
|
11650 /** |
|
11651 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
11652 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
11653 * cache object. |
|
11654 * |
|
11655 * @return {(WeakMap|Object)} Root cache object. |
|
11656 */ |
|
11657 function getRootCache() { |
|
11658 return rootCache; |
|
11659 } |
|
11660 |
|
11661 /** |
|
11662 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
11663 * will be used to create a unique cache for each set of dependants. This |
|
11664 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
11665 * to occur on entries where the key object is no longer referenced. Since |
|
11666 * WeakMap requires the key to be an object, this is only possible when the |
|
11667 * dependant is object-like. The root cache is created as a hierarchy where |
|
11668 * each top-level key is the first entry in a dependants set, the value a |
|
11669 * WeakMap where each key is the next dependant, and so on. This continues |
|
11670 * so long as the dependants are object-like. If no dependants are object- |
|
11671 * like, then the cache is shared across all invocations. |
|
11672 * |
|
11673 * @see isObjectLike |
|
11674 * |
|
11675 * @param {Array} dependants Selector dependants. |
|
11676 * |
|
11677 * @return {Object} Cache object. |
|
11678 */ |
|
11679 function getWeakMapCache( dependants ) { |
|
11680 var caches = rootCache, |
|
11681 isUniqueByDependants = true, |
|
11682 i, dependant, map, cache; |
|
11683 |
|
11684 for ( i = 0; i < dependants.length; i++ ) { |
|
11685 dependant = dependants[ i ]; |
|
11686 |
|
11687 // Can only compose WeakMap from object-like key. |
|
11688 if ( ! isObjectLike( dependant ) ) { |
|
11689 isUniqueByDependants = false; |
|
11690 break; |
14346 } |
11691 } |
14347 |
11692 |
14348 // Return immediately |
11693 // Does current segment of cache already have a WeakMap? |
14349 return node.val; |
11694 if ( caches.has( dependant ) ) { |
|
11695 // Traverse into nested WeakMap. |
|
11696 caches = caches.get( dependant ); |
|
11697 } else { |
|
11698 // Create, set, and traverse into a new one. |
|
11699 map = new WeakMap(); |
|
11700 caches.set( dependant, map ); |
|
11701 caches = map; |
|
11702 } |
14350 } |
11703 } |
14351 |
11704 |
14352 // No cached value found. Continue to insertion phase: |
11705 // We use an arbitrary (but consistent) object as key for the last item |
14353 |
11706 // in the WeakMap to serve as our running cache. |
14354 // Create a copy of arguments (avoid leaking deoptimization) |
11707 if ( ! caches.has( LEAF_KEY ) ) { |
|
11708 cache = createCache(); |
|
11709 cache.isUniqueByDependants = isUniqueByDependants; |
|
11710 caches.set( LEAF_KEY, cache ); |
|
11711 } |
|
11712 |
|
11713 return caches.get( LEAF_KEY ); |
|
11714 } |
|
11715 |
|
11716 // Assign cache handler by availability of WeakMap |
|
11717 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
11718 |
|
11719 /** |
|
11720 * Resets root memoization cache. |
|
11721 */ |
|
11722 function clear() { |
|
11723 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
11724 } |
|
11725 |
|
11726 // eslint-disable-next-line jsdoc/check-param-names |
|
11727 /** |
|
11728 * The augmented selector call, considering first whether dependants have |
|
11729 * changed before passing it to underlying memoize function. |
|
11730 * |
|
11731 * @param {Object} source Source object for derivation. |
|
11732 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
11733 * |
|
11734 * @return {*} Selector result. |
|
11735 */ |
|
11736 function callSelector( /* source, ...extraArgs */ ) { |
|
11737 var len = arguments.length, |
|
11738 cache, node, i, args, dependants; |
|
11739 |
|
11740 // Create copy of arguments (avoid leaking deoptimization). |
14355 args = new Array( len ); |
11741 args = new Array( len ); |
14356 for ( i = 0; i < len; i++ ) { |
11742 for ( i = 0; i < len; i++ ) { |
14357 args[ i ] = arguments[ i ]; |
11743 args[ i ] = arguments[ i ]; |
14358 } |
11744 } |
14359 |
11745 |
|
11746 dependants = getDependants.apply( null, args ); |
|
11747 cache = getCache( dependants ); |
|
11748 |
|
11749 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
11750 // of WeakMap support), shallow compare against last dependants and, if |
|
11751 // references have changed, destroy cache to recalculate result. |
|
11752 if ( ! cache.isUniqueByDependants ) { |
|
11753 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
11754 cache.clear(); |
|
11755 } |
|
11756 |
|
11757 cache.lastDependants = dependants; |
|
11758 } |
|
11759 |
|
11760 node = cache.head; |
|
11761 while ( node ) { |
|
11762 // Check whether node arguments match arguments |
|
11763 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
11764 node = node.next; |
|
11765 continue; |
|
11766 } |
|
11767 |
|
11768 // At this point we can assume we've found a match |
|
11769 |
|
11770 // Surface matched node to head if not already |
|
11771 if ( node !== cache.head ) { |
|
11772 // Adjust siblings to point to each other. |
|
11773 node.prev.next = node.next; |
|
11774 if ( node.next ) { |
|
11775 node.next.prev = node.prev; |
|
11776 } |
|
11777 |
|
11778 node.next = cache.head; |
|
11779 node.prev = null; |
|
11780 cache.head.prev = node; |
|
11781 cache.head = node; |
|
11782 } |
|
11783 |
|
11784 // Return immediately |
|
11785 return node.val; |
|
11786 } |
|
11787 |
|
11788 // No cached value found. Continue to insertion phase: |
|
11789 |
14360 node = { |
11790 node = { |
14361 args: args, |
|
14362 |
|
14363 // Generate the result from original function |
11791 // Generate the result from original function |
14364 val: fn.apply( null, args ), |
11792 val: selector.apply( null, args ), |
14365 }; |
11793 }; |
|
11794 |
|
11795 // Avoid including the source object in the cache. |
|
11796 args[ 0 ] = null; |
|
11797 node.args = args; |
14366 |
11798 |
14367 // Don't need to check whether node is already head, since it would |
11799 // Don't need to check whether node is already head, since it would |
14368 // have been returned above already if it was |
11800 // have been returned above already if it was |
14369 |
11801 |
14370 // Shift existing head down list |
11802 // Shift existing head down list |
14371 if ( head ) { |
11803 if ( cache.head ) { |
14372 head.prev = node; |
11804 cache.head.prev = node; |
14373 node.next = head; |
11805 node.next = cache.head; |
14374 } else { |
|
14375 // If no head, follows that there's no tail (at initial or reset) |
|
14376 tail = node; |
|
14377 } |
11806 } |
14378 |
11807 |
14379 // Trim tail if we're reached max size and are pending cache insertion |
11808 cache.head = node; |
14380 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { |
|
14381 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; |
|
14382 /** @type {MemizeCacheNode} */ ( tail ).next = null; |
|
14383 } else { |
|
14384 size++; |
|
14385 } |
|
14386 |
|
14387 head = node; |
|
14388 |
11809 |
14389 return node.val; |
11810 return node.val; |
14390 } |
11811 } |
14391 |
11812 |
14392 memoized.clear = function() { |
11813 callSelector.getDependants = getDependants; |
14393 head = null; |
11814 callSelector.clear = clear; |
14394 tail = null; |
11815 clear(); |
14395 size = 0; |
11816 |
14396 }; |
11817 return callSelector; |
14397 |
11818 }); |
14398 if ( false ) {} |
|
14399 |
|
14400 // Ignore reason: There's not a clear solution to create an intersection of |
|
14401 // the function with additional properties, where the goal is to retain the |
|
14402 // function signature of the incoming argument and add control properties |
|
14403 // on the return value. |
|
14404 |
|
14405 // @ts-ignore |
|
14406 return memoized; |
|
14407 } |
|
14408 |
|
14409 module.exports = memize; |
|
14410 |
11819 |
14411 |
11820 |
14412 /***/ }), |
11821 /***/ }), |
14413 |
11822 |
14414 /***/ 7: |
11823 /***/ "qRz9": |
14415 /***/ (function(module, exports) { |
11824 /***/ (function(module, exports) { |
14416 |
11825 |
14417 (function() { module.exports = this["wp"]["blockEditor"]; }()); |
11826 (function() { module.exports = window["wp"]["richText"]; }()); |
14418 |
11827 |
14419 /***/ }), |
11828 /***/ }), |
14420 |
11829 |
14421 /***/ 75: |
11830 /***/ "rmEH": |
14422 /***/ (function(module, exports) { |
11831 /***/ (function(module, exports) { |
14423 |
11832 |
14424 (function() { module.exports = this["wp"]["htmlEntities"]; }()); |
11833 (function() { module.exports = window["wp"]["htmlEntities"]; }()); |
14425 |
11834 |
14426 /***/ }), |
11835 /***/ }), |
14427 |
11836 |
14428 /***/ 79: |
11837 /***/ "tI+e": |
14429 /***/ (function(module, exports) { |
11838 /***/ (function(module, exports) { |
14430 |
11839 |
14431 (function() { module.exports = this["wp"]["date"]; }()); |
11840 (function() { module.exports = window["wp"]["components"]; }()); |
14432 |
11841 |
14433 /***/ }), |
11842 /***/ }), |
14434 |
11843 |
14435 /***/ 8: |
11844 /***/ "w95h": |
|
11845 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11846 |
|
11847 "use strict"; |
|
11848 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
|
11849 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
11850 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
|
11851 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
11852 |
|
11853 |
|
11854 /** |
|
11855 * WordPress dependencies |
|
11856 */ |
|
11857 |
|
11858 const close = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
|
11859 xmlns: "http://www.w3.org/2000/svg", |
|
11860 viewBox: "0 0 24 24" |
|
11861 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
|
11862 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" |
|
11863 })); |
|
11864 /* harmony default export */ __webpack_exports__["a"] = (close); |
|
11865 |
|
11866 |
|
11867 /***/ }), |
|
11868 |
|
11869 /***/ "wduq": |
|
11870 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11871 |
|
11872 "use strict"; |
|
11873 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
|
11874 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
11875 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
|
11876 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
11877 |
|
11878 |
|
11879 /** |
|
11880 * WordPress dependencies |
|
11881 */ |
|
11882 |
|
11883 const wordpress = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
|
11884 xmlns: "http://www.w3.org/2000/svg", |
|
11885 viewBox: "-2 -2 24 24" |
|
11886 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
|
11887 d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" |
|
11888 })); |
|
11889 /* harmony default export */ __webpack_exports__["a"] = (wordpress); |
|
11890 |
|
11891 |
|
11892 /***/ }), |
|
11893 |
|
11894 /***/ "wx14": |
14436 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
11895 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
14437 |
11896 |
14438 "use strict"; |
11897 "use strict"; |
14439 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
11898 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
14440 function _extends() { |
11899 function _extends() { |