Skip to content
Snippets Groups Projects

Introduce native Gutenberg controls

Merged Erick Hitter requested to merge add/gutenberg-native-meta into master
Compare and Show latest version
6 files
+ 205
39
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 2
2
@@ -4,7 +4,7 @@ object-assign
(c) Sindre Sorhus
@license MIT
*/
var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,i){for(var s,c,u=o(e),a=1;a<arguments.length;a++){for(var l in s=Object(arguments[a]))r.call(s,l)&&(u[l]=s[l]);if(t){c=t(s);for(var p=0;p<c.length;p++)n.call(s,c[p])&&(u[c[p]]=s[c[p]])}}return u}},251:function(e,t,r){
var r=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var r={},t=0;t<10;t++)r["_"+String.fromCharCode(t)]=t;if("0123456789"!==Object.getOwnPropertyNames(r).map((function(e){return r[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,i){for(var s,c,a=o(e),u=1;u<arguments.length;u++){for(var l in s=Object(arguments[u]))t.call(s,l)&&(a[l]=s[l]);if(r){c=r(s);for(var p=0;p<c.length;p++)n.call(s,c[p])&&(a[c[p]]=s[c[p]])}}return a}},251:function(e,r,t){
/** @license React v17.0.2
* react-jsx-runtime.production.min.js
*
@@ -13,4 +13,4 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.pr
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
r(418);var n=r(804),o=60103;if(60107,"function"==typeof Symbol&&Symbol.for){var i=Symbol.for;o=i("react.element"),i("react.fragment")}var s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c=Object.prototype.hasOwnProperty,u={key:!0,ref:!0,__self:!0,__source:!0};function a(e,t,r){var n,i={},a=null,l=null;for(n in void 0!==r&&(a=""+r),void 0!==t.key&&(a=""+t.key),void 0!==t.ref&&(l=t.ref),t)c.call(t,n)&&!u.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===i[n]&&(i[n]=t[n]);return{$$typeof:o,type:e,key:a,ref:l,props:i,_owner:s.current}}t.jsx=a,t.jsxs=a},893:function(e,t,r){e.exports=r(251)},804:function(e){e.exports=React},190:function(e){e.exports=wp.components},405:function(e){e.exports=wp.compose},440:function(e){e.exports=wp.data},451:function(e){e.exports=wp.editPost},194:function(e){e.exports=wp.i18n},415:function(e){e.exports=wp.plugins}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}!function(){var e=r(893);function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n=r(190),o=n.Button,i=n.TextControl,s=r(405).compose,c=r(440),u=c.withSelect,a=c.withDispatch,l=r(451).PluginDocumentSettingPanel,p=r(194).__,f=r(415).registerPlugin,v="_wp_rev_ctl_limit",g="wp-revisions-control";f("plugin-document-setting-panel-demo",{render:s([u((function(e){var t=e("core/editor"),r=t.getCurrentPostRevisionsCount,n=t.getEditedPostAttribute,o=r(),i=n("meta")[v];return{limit:i,showPurgeButton:Boolean(i)&&o>parseInt(i)}})),a((function(e,r){var n=r.limit;return{manualPurge:function(){console.log("Purging!",n)},updateMeta:function(r){e("core/editor").editPost({meta:t({},v,r)})}}}))])((function(t){var r=t.limit,n=t.manualPurge,s=t.showPurgeButton,c=t.updateMeta;return(0,e.jsxs)(l,{name:g,title:p("WP Revisions Control","wp_revisions_control"),className:g,children:[(0,e.jsx)(i,{label:p("Number of revisions to retain:","wp_revisions_control"),help:p("Leave blank to keep all revisions.","wp_revisions_control"),value:r,onChange:c}),s&&(0,e.jsx)(o,{onClick:n,children:p("Purge excess revisions","wp_revisions_control")})]})})),icon:"backup"})}()}();
\ No newline at end of file
t(418);var n=t(804),o=60103;if(r.Fragment=60107,"function"==typeof Symbol&&Symbol.for){var i=Symbol.for;o=i("react.element"),r.Fragment=i("react.fragment")}var s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c=Object.prototype.hasOwnProperty,a={key:!0,ref:!0,__self:!0,__source:!0};function u(e,r,t){var n,i={},u=null,l=null;for(n in void 0!==t&&(u=""+t),void 0!==r.key&&(u=""+r.key),void 0!==r.ref&&(l=r.ref),r)c.call(r,n)&&!a.hasOwnProperty(n)&&(i[n]=r[n]);if(e&&e.defaultProps)for(n in r=e.defaultProps)void 0===i[n]&&(i[n]=r[n]);return{$$typeof:o,type:e,key:u,ref:l,props:i,_owner:s.current}}r.jsx=u,r.jsxs=u},893:function(e,r,t){e.exports=t(251)},804:function(e){e.exports=React},986:function(e){e.exports=wp.apiFetch},190:function(e){e.exports=wp.components},405:function(e){e.exports=wp.compose},440:function(e){e.exports=wp.data},451:function(e){e.exports=wp.editPost},724:function(e){e.exports=wp.element},194:function(e){e.exports=wp.i18n},415:function(e){e.exports=wp.plugins}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n](i,i.exports,t),i.exports}!function(){var e=t(893);function r(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,i=void 0;try{for(var s,c=e[Symbol.iterator]();!(n=(s=c.next()).done)&&(t.push(s.value),!r||t.length!==r);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw i}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var i=t(986),s=t(190),c=s.Button,a=s.Modal,u=s.TextControl,l=t(405).compose,p=t(440),f=p.withSelect,v=p.withDispatch,d=t(451).PluginDocumentSettingPanel,m=t(724).useState,b=t(194),h=b.__,y=b._n,w=b.sprintf,_=t(415).registerPlugin,g="_wp_rev_ctl_limit",j="wp-revisions-control",x=function(r,t){var o=n(m(!1),2),i=o[0],s=o[1],u=function(){return s(!1)},l=w(y("This will remove all but the most-recent revision.","This will remove all but the %1$d most-recent revisions.",parseInt(r),"wp_revisions_control"),r);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(c,{isSecondary:!0,onClick:function(){return s(!0)},children:h("Purge excess revisions","wp_revisions_control")}),i&&(0,e.jsxs)(a,{title:h("Purge excess revisions","wp_revisions_control"),contentLabel:l,onRequestClose:u,children:[(0,e.jsx)("p",{children:l}),(0,e.jsx)(c,{isSecondary:!0,onClick:u,children:h("Cancel","wp_revisions_control")}),(0,e.jsx)(c,{isPrimary:!0,onClick:function(){u(),t()},children:h("Purge","wp_revisions_control")})]})]})};_("plugin-document-setting-panel-demo",{render:l([f((function(e){var r=e("core/editor"),t=r.getCurrentPostRevisionsCount,n=r.getEditedPostAttribute,o=t(),i=n("meta")[g];return{limit:i,showPurgeButton:Boolean(i)&&o>parseInt(i)}})),v((function(e,t,n){t.limit;var o=n.select;return{manualPurge:function(){var r=o("core/editor").getCurrentPostId();i({path:"/wp-revisions-control/v1/schedule/".concat(r),method:"PUT"}).then((function(r){var t,n;r?(t="success",n=h("Excess revisions scheduled for removal.","wp_revisions_control")):(t="error",n=h("Failed to schedule excess revisions for removal.","wp_revisions_control")),e("core/notices").createNotice(t,n,{id:"wp-revisions-control-scheduled-purge",isDismissible:!0,type:"snackbar"})}))},updateMeta:function(t){e("core/editor").editPost({meta:r({},g,t)})}}}))])((function(r){var t=r.limit,n=r.manualPurge,o=r.showPurgeButton,i=r.updateMeta;return(0,e.jsxs)(d,{name:j,title:h("WP Revisions Control","wp_revisions_control"),className:j,children:[(0,e.jsx)(u,{label:h("Number of revisions to retain:","wp_revisions_control"),help:h("Leave blank to keep all revisions.","wp_revisions_control"),value:t,onChange:i}),o&&x(t,n)]})})),icon:"backup"})}()}();
\ No newline at end of file
Loading