PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/scripts/patterns/index.js +38 -54 23.4.022.7.0 View file →
@@ -210,9 +210,9 @@
210 210 const fileContent = await file.text();
211 211 let parsedContent;
212 212 try {
213 213 parsedContent = JSON.parse(fileContent);
214 - } catch {
214 + } catch (e) {
215 215 throw new Error("Invalid JSON file");
216 216 }
217 217 if (parsedContent.__file !== "wp_block" || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== "string" || typeof parsedContent.content !== "string" || parsedContent.syncStatus && typeof parsedContent.syncStatus !== "string") {
218 218 throw new Error("Invalid pattern JSON file");
@@ -885,8 +885,9 @@
885 885 ref: pattern.id
886 886 });
887 887 replaceBlocks(clientIds, newBlock);
888 888 setEditingPattern2(newBlock.clientId, true);
889 + closeBlockSettingsMenu();
889 890 }
890 891 createSuccessNotice(
891 892 pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? (0, import_i18n6.sprintf)(
892 893 // translators: %s: the name the user has given to the pattern.
@@ -902,9 +903,8 @@
902 903 id: "convert-to-pattern-success"
903 904 }
904 905 );
905 906 setIsModalOpen(false);
906 - closeBlockSettingsMenu();
907 907 };
908 908 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
909 909 /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
910 910 import_components5.MenuItem,
@@ -938,15 +938,13 @@
938 938 var import_components6 = __toESM(require_components(), 1);
939 939 var import_i18n7 = __toESM(require_i18n(), 1);
940 940 var import_blocks3 = __toESM(require_blocks(), 1);
941 941 var import_data9 = __toESM(require_data(), 1);
942 - var import_element7 = __toESM(require_element(), 1);
943 942 var import_block_editor4 = __toESM(require_block_editor(), 1);
944 943 var import_url = __toESM(require_url(), 1);
945 944 var import_core_data7 = __toESM(require_core_data(), 1);
946 945 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
947 - function PatternsManageButton({ clientId, onClose }) {
948 - const [showConfirmDialog, setShowConfirmDialog] = (0, import_element7.useState)(false);
946 + function PatternsManageButton({ clientId }) {
949 947 const {
950 948 attributes,
951 949 canDetach,
952 950 isVisible,
@@ -996,42 +994,29 @@
996 994 );
997 995 if (!isVisible || !canEdit) {
998 996 return null;
999 997 }
1000 - const handleDetach = () => {
1001 - if (isSyncedPattern) {
1002 - convertSyncedPatternToStatic2(clientId);
1003 - }
1004 - if (isUnsyncedPattern) {
1005 - const { patternName, ...attributesWithoutPatternName } = attributes?.metadata ?? {};
1006 - updateBlockAttributes(clientId, {
1007 - metadata: attributesWithoutPatternName
1008 - });
1009 - }
1010 - onClose?.();
1011 - setShowConfirmDialog(false);
1012 - };
1013 998 return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1014 - canDetach && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1015 - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components6.MenuItem, { onClick: () => setShowConfirmDialog(true), children: (0, import_i18n7.__)("Detach") }),
1016 - /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1017 - import_components6.__experimentalConfirmDialog,
1018 - {
1019 - isOpen: showConfirmDialog,
1020 - onConfirm: handleDetach,
1021 - onCancel: () => setShowConfirmDialog(false),
1022 - confirmButtonText: (0, import_i18n7.__)("Detach"),
1023 - size: "medium",
1024 - title: (0, import_i18n7.__)("Detach pattern?"),
1025 - __experimentalHideHeader: false,
1026 - children: isSyncedPattern ? (0, import_i18n7.__)(
1027 - "The blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here."
1028 - ) : (0, import_i18n7.__)(
1029 - "Blocks will no longer be associated with this pattern and will be fully editable."
1030 - )
1031 - }
1032 - )
1033 - ] }),
999 + canDetach && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1000 + import_components6.MenuItem,
1001 + {
1002 + onClick: () => {
1003 + if (isSyncedPattern) {
1004 + convertSyncedPatternToStatic2(clientId);
1005 + }
1006 + if (isUnsyncedPattern) {
1007 + const {
1008 + patternName,
1009 + ...attributesWithoutPatternName
1010 + } = attributes?.metadata ?? {};
1011 + updateBlockAttributes(clientId, {
1012 + metadata: attributesWithoutPatternName
1013 + });
1014 + }
1015 + },
1016 + children: isSyncedPattern ? (0, import_i18n7.__)("Disconnect pattern") : (0, import_i18n7.__)("Detach pattern")
1017 + }
1018 + ),
1034 1019 /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components6.MenuItem, { href: managePatternsUrl, children: (0, import_i18n7.__)("Manage patterns") })
1035 1020 ] });
1036 1021 }
1037 1022 var patterns_manage_button_default = PatternsManageButton;
@@ -1050,10 +1035,9 @@
1050 1035 ),
1051 1036 selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1052 1037 patterns_manage_button_default,
1053 1038 {
1054 - clientId: selectedClientIds[0],
1055 - onClose
1039 + clientId: selectedClientIds[0]
1056 1040 }
1057 1041 )
1058 1042 ] }) });
1059 1043 }
@@ -1061,9 +1045,9 @@
1061 1045 // packages/patterns/build-module/components/rename-pattern-category-modal.mjs
1062 1046 var import_components7 = __toESM(require_components(), 1);
1063 1047 var import_core_data8 = __toESM(require_core_data(), 1);
1064 1048 var import_data10 = __toESM(require_data(), 1);
1065 - var import_element8 = __toESM(require_element(), 1);
1049 + var import_element7 = __toESM(require_element(), 1);
1066 1050 var import_html_entities3 = __toESM(require_html_entities(), 1);
1067 1051 var import_i18n8 = __toESM(require_i18n(), 1);
1068 1052 var import_notices5 = __toESM(require_notices(), 1);
1069 1053 var import_a11y = __toESM(require_a11y(), 1);
@@ -1075,13 +1059,13 @@
1075 1059 onError,
1076 1060 onSuccess,
1077 1061 ...props
1078 1062 }) {
1079 - const id = (0, import_element8.useId)();
1080 - const textControlRef = (0, import_element8.useRef)();
1081 - const [name, setName] = (0, import_element8.useState)((0, import_html_entities3.decodeEntities)(category.name));
1082 - const [isSaving, setIsSaving] = (0, import_element8.useState)(false);
1083 - const [validationMessage, setValidationMessage] = (0, import_element8.useState)(false);
1063 + const id = (0, import_element7.useId)();
1064 + const textControlRef = (0, import_element7.useRef)();
1065 + const [name, setName] = (0, import_element7.useState)((0, import_html_entities3.decodeEntities)(category.name));
1066 + const [isSaving, setIsSaving] = (0, import_element7.useState)(false);
1067 + const [validationMessage, setValidationMessage] = (0, import_element7.useState)(false);
1084 1068 const validationMessageId = validationMessage ? `patterns-rename-pattern-category-modal__validation-message-${id}` : void 0;
1085 1069 const { saveEntityRecord, invalidateResolution } = (0, import_data10.useDispatch)(import_core_data8.store);
1086 1070 const { createErrorNotice, createSuccessNotice } = (0, import_data10.useDispatch)(import_notices5.store);
1087 1071 const onChange = (newName) => {
@@ -1202,9 +1186,9 @@
1202 1186 );
1203 1187 }
1204 1188
1205 1189 // packages/patterns/build-module/components/pattern-overrides-controls.mjs
1206 - var import_element10 = __toESM(require_element(), 1);
1190 + var import_element9 = __toESM(require_element(), 1);
1207 1191 var import_block_editor6 = __toESM(require_block_editor(), 1);
1208 1192 var import_components9 = __toESM(require_components(), 1);
1209 1193 var import_i18n10 = __toESM(require_i18n(), 1);
1210 1194
@@ -1210,9 +1194,9 @@
1210 1194
1211 1195 // packages/patterns/build-module/components/allow-overrides-modal.mjs
1212 1196 var import_components8 = __toESM(require_components(), 1);
1213 1197 var import_i18n9 = __toESM(require_i18n(), 1);
1214 - var import_element9 = __toESM(require_element(), 1);
1198 + var import_element8 = __toESM(require_element(), 1);
1215 1199 var import_a11y2 = __toESM(require_a11y(), 1);
1216 1200 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1217 1201 function AllowOverridesModal({
1218 1202 placeholder,
@@ -1219,10 +1203,10 @@
1219 1203 initialName = "",
1220 1204 onClose,
1221 1205 onSave
1222 1206 }) {
1223 - const [editedBlockName, setEditedBlockName] = (0, import_element9.useState)(initialName);
1224 - const descriptionId = (0, import_element9.useId)();
1207 + const [editedBlockName, setEditedBlockName] = (0, import_element8.useState)(initialName);
1208 + const descriptionId = (0, import_element8.useId)();
1225 1209 const isNameValid = !!editedBlockName.trim();
1226 1210 const handleSubmit = () => {
1227 1211 if (editedBlockName !== initialName) {
1228 1212 const message = (0, import_i18n9.sprintf)(
@@ -1297,9 +1281,9 @@
1297 1281 }
1298 1282 );
1299 1283 }
1300 1284 function DisallowOverridesModal({ onClose, onSave }) {
1301 - const descriptionId = (0, import_element9.useId)();
1285 + const descriptionId = (0, import_element8.useId)();
1302 1286 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1303 1287 import_components8.Modal,
1304 1288 {
1305 1289 title: (0, import_i18n9.__)("Disable overrides"),
@@ -1351,11 +1335,11 @@
1351 1335 attributes,
1352 1336 setAttributes,
1353 1337 name: blockName
1354 1338 }) {
1355 - const controlId = (0, import_element10.useId)();
1356 - const [showAllowOverridesModal, setShowAllowOverridesModal] = (0, import_element10.useState)(false);
1357 - const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0, import_element10.useState)(false);
1339 + const controlId = (0, import_element9.useId)();
1340 + const [showAllowOverridesModal, setShowAllowOverridesModal] = (0, import_element9.useState)(false);
1341 + const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0, import_element9.useState)(false);
1358 1342 const hasName = !!attributes.metadata?.name;
1359 1343 const defaultBindings = attributes.metadata?.bindings?.__default;
1360 1344 const hasOverrides = hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE;
1361 1345 const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== PATTERN_OVERRIDES_BINDING_SOURCE;