1/** 2 * Generated by a build script. Do not modify. 3 * Check orginal .jsx file. 4 */ 5/* eslint-disable */ 6 7(function(wp2) { 8 const { components, element, data, editPost, i18n, plugins } = wp2; 9 const { useSelect, useDispatch } = data; 10 const { registerPlugin } = plugins; 11 const { PluginSidebar } = editPost; 12 const { 13 BaseControl, 14 Button, 15 CheckboxControl, 16 PanelBody, 17 PanelRow 18 } = components; 19 const { Fragment, useState, useEffect } = element; 20 const { __ } = i18n; 21 const Sidebar = () => { 22 const dirtyEntityRecords = useSelect( 23 (select) => select("core").__experimentalGetDirtyEntityRecords() 24 ).filter((item) => item.name === "wp_block"); 25 const { createNotice } = useDispatch("core/notices"); 26 const { saveEditedEntityRecord } = useDispatch("core"); 27 const { setEntitiesToSave } = useDispatch("drupal"); 28 const [unselectedEntities, _setUnselectedEntities] = useState([]); 29 const setUnselectedEntities = ({ kind, name, key, property }, checked) => { 30 if (checked) { 31 _setUnselectedEntities( 32 unselectedEntities.filter( 33 (elt) => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property 34 ) 35 ); 36 } else { 37 _setUnselectedEntities([ 38 ...unselectedEntities, 39 { kind, name, key, property } 40 ]); 41 } 42 }; 43 function getEntitiesToSave() { 44 return dirtyEntityRecords.filter( 45 ({ kind, name, key, property }) => !unselectedEntities.some( 46 (elt) => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property 47 ) 48 ); 49 } 50 function saveItems() { 51 const entitiesToSave = getEntitiesToSave(); 52 entitiesToSave.forEach(({ kind, name, key, property }) => { 53 saveEditedEntityRecord(kind, name, key, property); 54 }); 55 createNotice("success", __("Synced pattern saved!"), { 56 type: "snackbar" 57 // isDismissible: true, 58 }); 59 } 60 useEffect(() => { 61 setEntitiesToSave(getEntitiesToSave()); 62 }); 63 return /* @__PURE__ */ React.createElement(Fragment, null, dirtyEntityRecords.length > 0 && /* @__PURE__ */ React.createElement( 64 PluginSidebar, 65 { 66 name: "state", 67 title: __("Synced Patterns"), 68 icon: "block-default" 69 },
70 /* @__PURE__ */ React.createElement(PanelBody, null, /* @__PURE__ */ React.createElement( 71 BaseControl, 72 { 73 help: __( 74 "Saving synced patterns will affect other places where they are being used. You can de-select to not save." 75 ) 76 }, 77 /* @__PURE__ */ React.createElement(BaseControl.VisualLabel, null, __( 78 'The selected synced patterns will be saved when saving the content. Press "Save now" button to save immediately.' 79 )) 80 ), dirtyEntityRecords.map((item) => /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement( 81 CheckboxControl, 82 { 83 key: item.key, 84 label: item.title, 85 checked: !unselectedEntities.some( 86 (elt) => elt.kind === item.kind && elt.name === item.name && elt.key === item.key && elt.property === item.property 87 ), 88 onChange: (checked) => setUnselectedEntities(item, checked) 89 } 90 ))), /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(Button, { isPrimary: true, onClick: () => saveItems() }, __("Save now")))) 91 )); 92 }; 93 registerPlugin("reusable-blocks-save", { 94 render: () => /* @__PURE__ */ React.createElement(Sidebar, null) 95 }); 96})(wp);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.