From c7d2d778e4c18e9cc65919d9d8cdc552f89e36e0 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Tue, 5 Mar 2024 11:53:43 +0200 Subject: [PATCH 1/2] PCH Excerpt Generator: Update UI --- .../excerpt-generator.asset.php | 2 +- build/content-helper/excerpt-generator.css | 3 +- build/content-helper/excerpt-generator.js | 4 +- .../components/excerpt-panel.tsx | 70 +++++++++++++++---- .../excerpt-generator/excerpt-generator.scss | 44 +++++++----- 5 files changed, 85 insertions(+), 38 deletions(-) diff --git a/build/content-helper/excerpt-generator.asset.php b/build/content-helper/excerpt-generator.asset.php index df0c30533..c9c140099 100644 --- a/build/content-helper/excerpt-generator.asset.php +++ b/build/content-helper/excerpt-generator.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-url', 'wp-wordcount'), 'version' => '1e64abc52d06c6e4a1e5'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'a5537755af9f5a3e93da'); diff --git a/build/content-helper/excerpt-generator.css b/build/content-helper/excerpt-generator.css index 7e6f306ef..59583e834 100644 --- a/build/content-helper/excerpt-generator.css +++ b/build/content-helper/excerpt-generator.css @@ -1,2 +1 @@ -.wp-parsely-beta-badge{align-self:end;background-color:var(--parsely-green);border-radius:.34em;box-shadow:0 .0625rem .1875rem rgba(0,0,0,.2);color:#fff;display:inline-block;font-size:.75rem;font-weight:700;margin:.125em .125em .125em auto;opacity:.8;padding:.15em .65em;text-transform:uppercase;-webkit-user-select:none;-moz-user-select:none;user-select:none}.parsely-tone-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;gap:var(--grid-unit-05,.25rem);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-tone-selector-dropdown button{height:2.0625rem}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-tone-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle svg:first-of-type path{transform:scale(1.4);transform-origin:center}.parsely-tone-selector-dropdown .parsely-tone-selector-label{flex-grow:2;padding:0 var(--grid-unit-10,.5rem);text-align:left}.parsely-tone-selector-dropdown .parsely-tone-selector-label:first-letter{text-transform:uppercase}.parsely-persona-selector-custom{width:100%}.parsely-persona-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;gap:var(--grid-unit-05,.25rem);height:2.5rem;padding:var(--grid-unit-15,.75rem) var(--grid-unit-20,1rem)}#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.settings_page_parsely,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.parsely-persona-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;gap:var(--grid-unit-05,.25rem);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-persona-selector-dropdown button{height:2.0625rem}.parsely-persona-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-persona-selector-dropdown .parsely-persona-selector-label{flex-grow:2;padding:0 var(--grid-unit-10,.5rem);text-align:left}.parsely-persona-selector-dropdown .parsely-persona-selector-label:first-letter{text-transform:uppercase}.parsely-tone-selector-custom{width:100%}.parsely-tone-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;gap:var(--grid-unit-05,.25rem);height:2.5rem;padding:var(--grid-unit-15,.75rem) var(--grid-unit-20,1rem)}.parsely-panel-settings{width:100%}.parsely-panel-settings .parsely-panel-settings-header{display:flex;margin:.625rem 0;width:100%}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label{flex-grow:2;margin:0 0 0 .3125rem;text-align:left}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field{align-items:center;display:flex;justify-content:space-between}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field .components-base-control__label{margin-bottom:0}.wp-parsely-content-helper-error{align-self:flex-start;margin:0}.wp-parsely-content-helper-error p{margin:0}.wp-parsely-content-helper-error .content-helper-error-message{margin:0!important} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.settings_page_parsely,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__spinner{align-items:center;background:hsla(0,0%,100%,.7);bottom:0;display:flex;justify-content:center;left:0;position:absolute;right:0;top:1.25rem;z-index:10}.editor-post-excerpt__spinner.has-word-count{bottom:1.25rem}.wp-parsely-excerpt-generator{margin-top:.9375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start;margin-bottom:.625rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:500;line-height:1.4;margin-left:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{align-items:center;display:flex;gap:.9375rem;justify-content:center} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.settings_page_parsely,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{left:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:.5rem}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-left:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-left:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:.5rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:.5rem;margin-top:.5rem;padding:var(--grid-unit-10,8px) var(--grid-unit-15,12px)} diff --git a/build/content-helper/excerpt-generator.js b/build/content-helper/excerpt-generator.js index bf6fb1929..bb952a9a4 100644 --- a/build/content-helper/excerpt-generator.js +++ b/build/content-helper/excerpt-generator.js @@ -1,3 +1,3 @@ -!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,o={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)s.call(t,n)&&!l.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:o,_owner:i.current}}t.Fragment=o,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n=window.wp.hooks,a=window.wp.data,o=window.wp.plugins,s=r(893),i=window.wp.components,l=window.wp.editPost,c=window.wp.editor,u=window.wp.element,p=window.wp.i18n,d=window.wp.wordcount,y=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t,r){return void 0===r&&(r={}),n=this,a=void 0,s=function(){var n;return function(e,t){var r,n,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(s=0)),s;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(o),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),f=(y.trackEvent,function(e){var t=e.text,r=void 0===t?(0,p.__)("Beta","wp-parsely"):t,n=e.color,a=void 0===n?"var(--parsely-green)":n,o=e.fontSize,i={backgroundColor:a,fontSize:void 0===o?"0.75rem":o};return(0,s.jsx)("div",{className:"wp-parsely-beta-badge",style:i,children:r})}),h=function(e){var t=e.size,r=void 0===t?24:t,n=e.className,a=void 0===n?"wp-parsely-icon":n;return(0,s.jsxs)(i.SVG,{className:a,height:r,viewBox:"0 0 60 65",width:r,xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},w=window.wp.apiFetch,v=r.n(w),_=window.wp.url,m=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,s.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},P=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function __(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)});!function(e){e.CannotFormulateApiQuery="ch_cannot_formulate_api_query",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e[e.ParselyApiForbidden=403]="ParselyApiForbidden",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e[e.ParselyApiUnauthorized=401]="ParselyApiUnauthorized",e[e.ParselyInternalServerError=500]="ParselyInternalServerError",e[e.ParselySchemaValidationFailed=422]="ParselySchemaValidationFailed",e[e.ParselyUpstreamMalformedResponse=507]="ParselyUpstreamMalformedResponse",e[e.ParselyUpstreamNotAvailable=503]="ParselyUpstreamNotAvailable",e.PluginCredentialsNotSetMessageDetected="parsely_credentials_not_set_message_detected",e.PluginSettingsApiSecretNotSet="parsely_api_secret_not_set",e.PluginSettingsSiteIdNotSet="parsely_site_id_not_set",e.PostIsNotPublished="ch_post_not_published"}(t||(t={}));var g=function(e){function r(n,a,o){void 0===o&&(o=(0,p.__)("Error: ","wp-parsely"));var s=e.call(this,o+n)||this;s.hint=null,s.name=s.constructor.name,s.code=a;var i=[t.ParselyApiForbidden,t.ParselyApiResponseContainsError,t.ParselyApiReturnedNoData,t.ParselyApiReturnedTooManyResults,t.ParselyApiUnauthorized,t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsApiSecretNotSet,t.PluginSettingsSiteIdNotSet,t.PostIsNotPublished];return s.retryFetch=!i.includes(s.code),Object.setPrototypeOf(s,r.prototype),s.code===t.ParselyApiUnauthorized?s.message=(0,p.__)("This feature is accessible to select customers participating in its beta testing.","wp-parsely"):s.code===t.ParselyInternalServerError?s.message=(0,p.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):s.code===t.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,p.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===t.ParselySchemaValidationFailed?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):s.code===t.ParselyUpstreamMalformedResponse&&s.message.includes("Insufficient Storage")?s.message=(0,p.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===t.ParselyUpstreamMalformedResponse?s.message=(0,p.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):s.code===t.ParselyUpstreamNotAvailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return P(r,e),r.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){return void 0===e&&(e=null),(0,s.jsx)(m,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:window.wpParselyEmptyCredentialsMessage})}(e):(this.code===t.FetchError&&(this.hint=this.Hint((0,p.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code===t.ParselyApiForbidden&&(this.hint=this.Hint((0,p.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===t.HttpRequestFailed&&(this.hint=this.Hint((0,p.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,s.jsx)(m,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},r.prototype.Hint=function(e){return'

'.concat((0,p.__)("Hint:","wp-parsely")," ").concat(e,"

")},r}(Error),b=function(){function e(){}return e.prototype.generateExcerpt=function(e,r){var n,a,o,s,i;return a=this,o=void 0,i=function(){var a,o;return function(e,t){var r,n,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(s=0)),s;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0,N=(0,d.count)(o||S,"words",{}),j=(0,p.sprintf)( +!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,p=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:p,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n=window.wp.hooks,a=window.wp.data,s=window.wp.plugins,o=r(893),i=window.wp.components,l=window.wp.editPost,c=window.wp.editor,p=window.wp.element,u=window.wp.i18n,d=window.wp.wordcount,y=r(196),h=window.wp.primitives,f=(0,y.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,y.createElement)(h.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),w=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t,r){return void 0===r&&(r={}),n=this,a=void 0,o=function(){var n;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),v=(w.trackEvent,function(e){var t=e.size,r=void 0===t?24:t,n=e.className,a=void 0===n?"wp-parsely-icon":n;return(0,o.jsxs)(i.SVG,{className:a,height:r,viewBox:"0 0 60 65",width:r,xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})}),_=window.wp.apiFetch,m=r.n(_),g=window.wp.url,P=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,o.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},b=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function __(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)});!function(e){e.CannotFormulateApiQuery="ch_cannot_formulate_api_query",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e[e.ParselyApiForbidden=403]="ParselyApiForbidden",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e[e.ParselyApiUnauthorized=401]="ParselyApiUnauthorized",e[e.ParselyInternalServerError=500]="ParselyInternalServerError",e[e.ParselySchemaValidationFailed=422]="ParselySchemaValidationFailed",e[e.ParselyUpstreamMalformedResponse=507]="ParselyUpstreamMalformedResponse",e[e.ParselyUpstreamNotAvailable=503]="ParselyUpstreamNotAvailable",e.PluginCredentialsNotSetMessageDetected="parsely_credentials_not_set_message_detected",e.PluginSettingsApiSecretNotSet="parsely_api_secret_not_set",e.PluginSettingsSiteIdNotSet="parsely_site_id_not_set",e.PostIsNotPublished="ch_post_not_published"}(t||(t={}));var x=function(e){function r(n,a,s){void 0===s&&(s=(0,u.__)("Error: ","wp-parsely"));var o=e.call(this,s+n)||this;o.hint=null,o.name=o.constructor.name,o.code=a;var i=[t.ParselyApiForbidden,t.ParselyApiResponseContainsError,t.ParselyApiReturnedNoData,t.ParselyApiReturnedTooManyResults,t.ParselyApiUnauthorized,t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsApiSecretNotSet,t.PluginSettingsSiteIdNotSet,t.PostIsNotPublished];return o.retryFetch=!i.includes(o.code),Object.setPrototypeOf(o,r.prototype),o.code===t.ParselyApiUnauthorized?o.message=(0,u.__)("This feature is accessible to select customers participating in its beta testing.","wp-parsely"):o.code===t.ParselyInternalServerError?o.message=(0,u.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):o.code===t.HttpRequestFailed&&o.message.includes("cURL error 28")?o.message=(0,u.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):o.code===t.ParselySchemaValidationFailed?o.message=(0,u.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):o.code===t.ParselyUpstreamMalformedResponse&&o.message.includes("Insufficient Storage")?o.message=(0,u.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):o.code===t.ParselyUpstreamMalformedResponse?o.message=(0,u.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):o.code===t.ParselyUpstreamNotAvailable&&(o.message=(0,u.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),o}return b(r,e),r.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){return void 0===e&&(e=null),(0,o.jsx)(P,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:window.wpParselyEmptyCredentialsMessage})}(e):(this.code===t.FetchError&&(this.hint=this.Hint((0,u.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code===t.ParselyApiForbidden&&(this.hint=this.Hint((0,u.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===t.HttpRequestFailed&&(this.hint=this.Hint((0,u.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,o.jsx)(P,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},r.prototype.Hint=function(e){return'

'.concat((0,u.__)("Hint:","wp-parsely")," ").concat(e,"

")},r}(Error),E=function(){function e(){}return e.prototype.generateExcerpt=function(e,r){var n,a,s,o,i;return a=this,s=void 0,i=function(){var a,s;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0,O=(0,d.count)(s||N,"words",{}),C=(0,u.sprintf)( // Translators: %1$s the number of words in the excerpt. -(0,p._n)("%1$s word","%1$s words",N,"wp-parsely"),N);return(0,u.useEffect)((function(){var e=document.querySelector(".editor-post-excerpt textarea");e&&(e.scrollTop=0)}),[o]),(0,s.jsxs)("div",{className:"editor-post-excerpt",children:[(0,s.jsxs)("div",{style:{position:"relative"},children:[t&&(0,s.jsx)("div",{className:"editor-post-excerpt__spinner"+(N>0?" has-word-count":""),children:(0,s.jsx)(i.Spinner,{})}),(0,s.jsx)(i.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,p.__)("Write an excerpt (optional)","wp-parsely"),className:"editor-post-excerpt__textarea",onChange:function(e){return m({excerpt:e})},disabled:t||A,value:A?o:S,help:N?j:null})]}),(0,s.jsx)(i.ExternalLink,{href:(0,p.__)("https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt","wp-parsely"),children:(0,p.__)("Learn more about manual excerpts","wp-parsely")}),(0,s.jsxs)("div",{className:"wp-parsely-excerpt-generator",children:[(0,s.jsxs)("div",{className:"wp-parsely-excerpt-generator-header",children:[(0,s.jsx)(h,{size:20}),(0,s.jsx)("div",{className:"wp-parsely-excerpt-generator-header-label",children:(0,p.__)("Parse.ly AI","wp-parsely")}),(0,s.jsx)(f,{})]}),v&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-excerpt-generator-error",children:v.Message()}),(0,s.jsx)("div",{className:"wp-parsely-excerpt-generator-controls",children:A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Button,{variant:"secondary",onClick:function(){return x(void 0,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,m({excerpt:o})];case 1:return e.sent(),l(""),y.trackEvent("excerpt_generator_accepted"),[2]}}))}))},children:(0,p.__)("Accept","wp-parsely")}),(0,s.jsx)(i.Button,{isDestructive:!0,variant:"secondary",onClick:function(){return x(void 0,void 0,void 0,(function(){return E(this,(function(e){return l(""),y.trackEvent("excerpt_generator_discarded"),[2]}))}))},children:(0,p.__)("Discard","wp-parsely")})]}):(0,s.jsx)(i.Button,{onClick:function(){return x(void 0,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:r(!0),_(void 0),n.label=1;case 1:return n.trys.push([1,3,4,5]),y.trackEvent("excerpt_generator_pressed"),[4,P.generateExcerpt(k,T)];case 2:return e=n.sent(),l(e),[3,5];case 3:return t=n.sent(),_(t),[3,5];case 4:return r(!1),[7];case 5:return[2]}}))}))},variant:"primary",isBusy:t,disabled:t,children:t?(0,p.__)("Generating…","wp-parsely"):(0,p.__)("Generate Excerpt","wp-parsely")})})]})]})},T=function(){return(0,s.jsx)(c.PostTypeSupportCheck,{supportKeys:"excerpt",children:(0,s.jsx)(l.PluginDocumentSettingPanel,{name:"parsely-post-excerpt",title:"Excerpt",children:(0,s.jsx)(S,{})})})};(0,n.addFilter)("plugins.registerPlugin","wp-parsely-excerpt-generator",(function(e,t){var r,s;return"wp-parsely-block-editor-sidebar"!==t||((null===(r=null===window||void 0===window?void 0:window.Jetpack_Editor_Initial_State)||void 0===r?void 0:r.available_blocks["ai-content-lens"])&&(console.log("Parse.ly: Jetpack AI is enabled and will be disabled."),(0,n.removeFilter)("blocks.registerBlockType","jetpack/ai-content-lens-features")),(0,o.registerPlugin)("wp-parsely-excerpt-generator",{render:T}),null===(s=(0,a.dispatch)("core/edit-post"))||void 0===s||s.removeEditorPanel("post-excerpt")),e}),1e3)}()}(); \ No newline at end of file +(0,u._n)("%1$s word","%1$s words",O,"wp-parsely"),O);return(0,p.useEffect)((function(){var e=document.querySelector(".editor-post-excerpt textarea");e&&(e.scrollTop=0)}),[s]),(0,o.jsxs)("div",{className:"editor-post-excerpt",children:[(0,o.jsxs)("div",{style:{position:"relative"},children:[t&&(0,o.jsx)("div",{className:"editor-post-excerpt__loading_animation",children:(0,o.jsx)(A,{})}),(0,o.jsx)(i.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,u.__)("Write an excerpt (optional)","wp-parsely"),className:"editor-post-excerpt__textarea",onChange:function(e){return b({excerpt:e})},readOnly:t||R,value:t?"":R?s:N,help:O?C:null})]}),(0,o.jsxs)(i.Button,{href:(0,u.__)("https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt","wp-parsely"),target:"_blank",variant:"link",children:[(0,u.__)("Learn more about manual excerpts","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator",children:[(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header",children:[(0,o.jsx)(v,{size:16}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header-label",children:[(0,u.__)("Generate With Parse.ly","wp-parsely"),(0,o.jsx)("span",{className:"beta-label",children:(0,u.__)("Beta","wp-parsely")})]})]}),g&&(0,o.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-excerpt-generator-error",children:g.Message()}),(0,o.jsx)("div",{className:"wp-parsely-excerpt-generator-controls",children:R?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Button,{variant:"secondary",onClick:function(){return S(void 0,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,b({excerpt:s})];case 1:return e.sent(),l(""),w.trackEvent("excerpt_generator_accepted"),[2]}}))}))},children:(0,u.__)("Accept","wp-parsely")}),(0,o.jsx)(i.Button,{isDestructive:!0,variant:"secondary",onClick:function(){return S(void 0,void 0,void 0,(function(){return k(this,(function(e){return l(""),w.trackEvent("excerpt_generator_discarded"),[2]}))}))},children:(0,u.__)("Discard","wp-parsely")})]}):(0,o.jsxs)(i.Button,{onClick:function(){return S(void 0,void 0,void 0,(function(){var e,t;return k(this,(function(n){switch(n.label){case 0:r(!0),P(void 0),_(h+1),n.label=1;case 1:return n.trys.push([1,3,4,5]),w.trackEvent("excerpt_generator_pressed"),[4,x.generateExcerpt(I,j)];case 2:return e=n.sent(),l(e),[3,5];case 3:return t=n.sent(),P(t),[3,5];case 4:return r(!1),[7];case 5:return[2]}}))}))},variant:"primary",isBusy:t,disabled:t,children:[t&&(0,u.__)("Generating Excerpt…","wp-parsely"),!t&&h>0&&(0,u.__)("Regenerate Excerpt","wp-parsely"),!t&&0===h&&(0,u.__)("Generate Excerpt","wp-parsely")]})}),(0,o.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-excerpt-generator-beta",target:"_blank",variant:"link",children:[(0,u.__)("Learn more about Parse.ly AI","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]})]})]})},A=function(){return(0,o.jsx)(i.Animate,{type:"loading",children:function(e){var t=e.className;return(0,o.jsx)("span",{className:t,children:(0,u.__)("Generating…","wp-parsely")})}})},N=function(){return(0,o.jsx)(c.PostTypeSupportCheck,{supportKeys:"excerpt",children:(0,o.jsx)(l.PluginDocumentSettingPanel,{name:"parsely-post-excerpt",title:"Excerpt",children:(0,o.jsx)(T,{})})})};(0,n.addFilter)("plugins.registerPlugin","wp-parsely-excerpt-generator",(function(e,t){var r,o;return"wp-parsely-block-editor-sidebar"!==t||((null===(r=null===window||void 0===window?void 0:window.Jetpack_Editor_Initial_State)||void 0===r?void 0:r.available_blocks["ai-content-lens"])&&(console.log("Parse.ly: Jetpack AI is enabled and will be disabled."),(0,n.removeFilter)("blocks.registerBlockType","jetpack/ai-content-lens-features")),(0,s.registerPlugin)("wp-parsely-excerpt-generator",{render:N}),null===(o=(0,a.dispatch)("core/edit-post"))||void 0===o||o.removeEditorPanel("post-excerpt")),e}),1e3)}()}(); \ No newline at end of file diff --git a/src/content-helper/excerpt-generator/components/excerpt-panel.tsx b/src/content-helper/excerpt-generator/components/excerpt-panel.tsx index 34133375a..9b991c153 100644 --- a/src/content-helper/excerpt-generator/components/excerpt-panel.tsx +++ b/src/content-helper/excerpt-generator/components/excerpt-panel.tsx @@ -2,10 +2,10 @@ * WordPress dependencies */ import { + Animate, Button, - ExternalLink, + Icon, Notice, - Spinner, TextareaControl, } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; @@ -18,9 +18,9 @@ import { count } from '@wordpress/wordcount'; /** * Internal dependencies */ +import { external } from '@wordpress/icons'; import { GutenbergFunction } from '../../../@types/gutenberg/types'; import { Telemetry } from '../../../js/telemetry/telemetry'; -import { BetaBadge } from '../../common/components/beta-badge'; import { ContentHelperError } from '../../common/content-helper-error'; import { LeafIcon } from '../../common/icons/leaf-icon'; import { ExcerptGeneratorProvider } from '../provider'; @@ -33,6 +33,7 @@ import { ExcerptGeneratorProvider } from '../provider'; const PostExcerptGenerator = () => { const [ isLoading, setLoading ] = useState( false ); const [ generatedExcerpt, setGeneratedExcerpt ] = useState( '' ); + const [ generatedExcerptCount, setGeneratedExcerptCount ] = useState( 0 ); const [ error, setError ] = useState(); const { editPost } = useDispatch( editorStore ); @@ -84,6 +85,7 @@ const PostExcerptGenerator = () => { const generateExcerpt = async () => { setLoading( true ); setError( undefined ); + setGeneratedExcerptCount( generatedExcerptCount + 1 ); try { Telemetry.trackEvent( 'excerpt_generator_pressed' ); @@ -134,8 +136,8 @@ const PostExcerptGenerator = () => {
{ isLoading && ( -
0 ? ' has-word-count' : '' ) }> - +
+
) } { label={ __( 'Write an excerpt (optional)', 'wp-parsely' ) } className="editor-post-excerpt__textarea" onChange={ ( value ) => editPost( { excerpt: value } ) } - disabled={ isLoading || hasGeneratedExcerpt } - value={ getExcerptTextareaValue() } + readOnly={ isLoading || hasGeneratedExcerpt } + value={ isLoading ? '' : getExcerptTextareaValue() } help={ wordCount ? wordCountString : null } />
- { __( 'Learn more about manual excerpts', 'wp-parsely' ) } - - + +
- +
- { __( 'Parse.ly AI', 'wp-parsely' ) } + { __( 'Generate With Parse.ly', 'wp-parsely' ) } + { __( 'Beta', 'wp-parsely' ) }
-
{ error && ( { isBusy={ isLoading } disabled={ isLoading } > - { isLoading ? __( 'Generating…', 'wp-parsely' ) - : __( 'Generate Excerpt', 'wp-parsely' ) } + { isLoading && __( 'Generating Excerpt…', 'wp-parsely' ) } + { ! isLoading && generatedExcerptCount > 0 && __( 'Regenerate Excerpt', 'wp-parsely' ) } + { ! isLoading && generatedExcerptCount === 0 && __( 'Generate Excerpt', 'wp-parsely' ) } ) }
+
); }; +/** + * Component that renders a loading animation. + * + * @since 3.14.0 + * + * @return {JSX.Element} The loading animation component. + */ +const LoadingAnimation = (): JSX.Element => { + return ( + + { ( { className } ) => ( + + { __( 'Generating…', 'wp-parsely' ) } + + ) } + + ); +}; + /** * The ExcerptPanel component verifies that the current post type supports excerpts, * and then renders the PostExcerptGenerator component. diff --git a/src/content-helper/excerpt-generator/excerpt-generator.scss b/src/content-helper/excerpt-generator/excerpt-generator.scss index 5a6705bec..d7078b76e 100644 --- a/src/content-helper/excerpt-generator/excerpt-generator.scss +++ b/src/content-helper/excerpt-generator/excerpt-generator.scss @@ -1,47 +1,55 @@ @import "../common/css/variables"; @import "../common/css/functions"; -.editor-post-excerpt__spinner { +.editor-post-excerpt__loading_animation { position: absolute; - top: to_rem(20px); - left: 0; - right: 0; - bottom: 0; - display: flex; - justify-content: center; - align-items: center; - background: rgba(255, 255, 255, 0.7); // semi-transparent white background. - z-index: 10; + top: to_rem(29px); + left: to_rem(9px); } -.editor-post-excerpt__spinner.has-word-count { - bottom: to_rem(20px); +.editor-post-excerpt__textarea { + margin-bottom: to_rem(8px); + + textarea:read-only { + background-color: var(--Gutenberg-White, #fff); + } } .wp-parsely-excerpt-generator { - margin-top: to_rem(15px); + margin-top: to_rem(20px); .wp-parsely-excerpt-generator-header { align-items: center; display: flex; justify-content: flex-start; - margin-bottom: to_rem(10px); .wp-parsely-excerpt-generator-header-label { font-size: to_rem(11px); - font-weight: 500; + font-weight: 600; line-height: 1.4; text-transform: uppercase; display: inline-block; padding: 0; margin-left: to_rem(5px); + + span.beta-label { + padding-left: to_rem(6px); + color: var(--Gutenberg-Gray-700, #757575); + } } } .wp-parsely-excerpt-generator-controls { display: flex; - justify-content: center; - align-items: center; - gap: to_rem(15px); + gap: to_rem(8px); + + button { + flex-grow: 1; + height: to_rem(40px); + justify-content: center; + margin-bottom: to_rem(8px); + margin-top: to_rem(8px); + padding: var(--grid-unit-10, 8px) var(--grid-unit-15, 12px); + } } } From 8bf3b413f99ef10f15e6cf4edb0b76057b4f408f Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:24:48 +0200 Subject: [PATCH 2/2] excerpt-generator.scss: Use variables --- build/content-helper/excerpt-generator.asset.php | 2 +- build/content-helper/excerpt-generator.css | 2 +- .../excerpt-generator/excerpt-generator.scss | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/content-helper/excerpt-generator.asset.php b/build/content-helper/excerpt-generator.asset.php index c9c140099..ab739db43 100644 --- a/build/content-helper/excerpt-generator.asset.php +++ b/build/content-helper/excerpt-generator.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'a5537755af9f5a3e93da'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'ea68bf618136df730e5a'); diff --git a/build/content-helper/excerpt-generator.css b/build/content-helper/excerpt-generator.css index 59583e834..535190b0b 100644 --- a/build/content-helper/excerpt-generator.css +++ b/build/content-helper/excerpt-generator.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.settings_page_parsely,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{left:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:.5rem}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-left:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-left:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:.5rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:.5rem;margin-top:.5rem;padding:var(--grid-unit-10,8px) var(--grid-unit-15,12px)} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.settings_page_parsely,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{left:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:var(--grid-unit-10,.5rem)}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-left:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-left:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:var(--grid-unit-10,.5rem)}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:var(--grid-unit-10,.5rem);margin-top:var(--grid-unit-10,.5rem);padding:var(--grid-unit-10,.5rem) var(--grid-unit-15,.75rem)} diff --git a/src/content-helper/excerpt-generator/excerpt-generator.scss b/src/content-helper/excerpt-generator/excerpt-generator.scss index d7078b76e..3583de591 100644 --- a/src/content-helper/excerpt-generator/excerpt-generator.scss +++ b/src/content-helper/excerpt-generator/excerpt-generator.scss @@ -8,7 +8,7 @@ } .editor-post-excerpt__textarea { - margin-bottom: to_rem(8px); + margin-bottom: var(--grid-unit-10, to_rem(8px)); textarea:read-only { background-color: var(--Gutenberg-White, #fff); @@ -41,15 +41,15 @@ .wp-parsely-excerpt-generator-controls { display: flex; - gap: to_rem(8px); + gap: var(--grid-unit-10, to_rem(8px)); button { flex-grow: 1; height: to_rem(40px); justify-content: center; - margin-bottom: to_rem(8px); - margin-top: to_rem(8px); - padding: var(--grid-unit-10, 8px) var(--grid-unit-15, 12px); + margin-bottom: var(--grid-unit-10, to_rem(8px)); + margin-top: var(--grid-unit-10, to_rem(8px)); + padding: var(--grid-unit-10, to_rem(8px)) var(--grid-unit-15, to_rem(12px)); } } }