64 lines
26 KiB
JavaScript
64 lines
26 KiB
JavaScript
(()=>{"use strict";var e={865:(e,t,o)=>{var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=i(o(609)),s=i(o(848)),a=i(o(812));function i(e){return e&&e.__esModule?e:{default:e}}var l=void 0;function u(e,t){var o,a,i,c,d,p,m,g,h=[],f={};for(p=0;p<e.length;p++)if("string"!==(d=e[p]).type){if(!t.hasOwnProperty(d.value)||void 0===t[d.value])throw new Error("Invalid interpolation, missing component node: `"+d.value+"`");if("object"!==n(t[d.value]))throw new Error("Invalid interpolation, component node must be a ReactElement or null: `"+d.value+"`","\n> "+l);if("componentClose"===d.type)throw new Error("Missing opening component token: `"+d.value+"`");if("componentOpen"===d.type){o=t[d.value],i=p;break}h.push(t[d.value])}else h.push(d.value);return o&&(c=function(e,t){var o,n,r=t[e],s=0;for(n=e+1;n<t.length;n++)if((o=t[n]).value===r.value){if("componentOpen"===o.type){s++;continue}if("componentClose"===o.type){if(0===s)return n;s--}}throw new Error("Missing closing component token `"+r.value+"`")}(i,e),m=u(e.slice(i+1,c),t),a=r.default.cloneElement(o,{},m),h.push(a),c<e.length-1&&(g=u(e.slice(c+1),t),h=h.concat(g))),1===h.length?h[0]:(h.forEach((function(e,t){e&&(f["interpolation-child-"+t]=e)})),(0,s.default)(f))}t.A=function(e){var t=e.mixedString,o=e.components,r=e.throwErrors;if(l=t,!o)return t;if("object"!==(void 0===o?"undefined":n(o))){if(r)throw new Error("Interpolation Error: unable to process `"+t+"` because components is not an object");return t}var s=(0,a.default)(t);try{return u(s,o)}catch(e){if(r)throw new Error("Interpolation Error: unable to process `"+t+"` because of error `"+e.message+"`");return t}}},812:e=>{function t(e){return e.match(/^\{\{\//)?{type:"componentClose",value:e.replace(/\W/g,"")}:e.match(/\/\}\}$/)?{type:"componentSelfClosing",value:e.replace(/\W/g,"")}:e.match(/^\{\{/)?{type:"componentOpen",value:e.replace(/\W/g,"")}:{type:"string",value:e}}e.exports=function(e){return e.split(/(\{\{\/?\s*\w+\s*\/?\}\})/g).map(t)}},848:(e,t,o)=>{var n=o(609),r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,s=o(650),a=o(163),i=o(759),l=".",u=":",c="function"==typeof Symbol&&Symbol.iterator,d="@@iterator";function p(e,t){return e&&"object"==typeof e&&null!=e.key?(o=e.key,n={"=":"=0",":":"=2"},"$"+(""+o).replace(/[=:]/g,(function(e){return n[e]}))):t.toString(36);var o,n}function m(e,t,o,n){var s,i=typeof e;if("undefined"!==i&&"boolean"!==i||(e=null),null===e||"string"===i||"number"===i||"object"===i&&e.$$typeof===r)return o(n,e,""===t?l+p(e,0):t),1;var g=0,h=""===t?l:t+u;if(Array.isArray(e))for(var f=0;f<e.length;f++)g+=m(s=e[f],h+p(s,f),o,n);else{var b=function(e){var t=e&&(c&&e[c]||e[d]);if("function"==typeof t)return t}(e);if(b)for(var y,w=b.call(e),v=0;!(y=w.next()).done;)g+=m(s=y.value,h+p(s,v++),o,n);else if("object"===i){var k=""+e;a(!1,"Objects are not valid as a React child (found: %s).%s","[object Object]"===k?"object with keys {"+Object.keys(e).join(", ")+"}":k,"")}}return g}var g=/\/+/g;function h(e){return(""+e).replace(g,"$&/")}var f,b,y=w,w=function(e){var t=this;if(t.instancePool.length){var o=t.instancePool.pop();return t.call(o,e),o}return new t(e)};function v(e,t,o,n){this.result=e,this.keyPrefix=t,this.func=o,this.context=n,this.count=0}function k(e,t,o){var r,a,i=e.result,l=e.keyPrefix,u=e.func,c=e.context,d=u.call(c,t,e.count++);Array.isArray(d)?_(d,i,o,s.thatReturnsArgument):null!=d&&(n.isValidElement(d)&&(r=d,a=l+(!d.key||t&&t.key===d.key?"":h(d.key)+"/")+o,d=n.cloneElement(r,{key:a},void 0!==r.props?r.props.children:void 0)),i.push(d))}function _(e,t,o,n,r){var s="";null!=o&&(s=h(o)+"/");var a=v.getPooled(t,s,n,r);!function(e,t,o){null==e||m(e,"",t,o)}(e,k,a),v.release(a)}v.prototype.destructor=function(){this.result=null,this.keyPrefix=null,this.func=null,this.context=null,this.count=0},f=function(e,t,o,n){var r=this;if(r.instancePool.length){var s=r.instancePool.pop();return r.call(s,e,t,o,n),s}return new r(e,t,o,n)},(b=v).instancePool=[],b.getPooled=f||y,b.poolSize||(b.poolSize=10),b.release=function(e){var t=this;a(e instanceof t,"Trying to release an instance into a pool of a different type."),e.destructor(),t.instancePool.length<t.poolSize&&t.instancePool.push(e)},e.exports=function(e){if("object"!=typeof e||!e||Array.isArray(e))return i(!1,"React.addons.createFragment only accepts a single object. Got: %s",e),e;if(n.isValidElement(e))return i(!1,"React.addons.createFragment does not accept a ReactElement without a wrapper object."),e;a(1!==e.nodeType,"React.addons.createFragment(...): Encountered an invalid child; DOM elements are not valid children of React components.");var t=[];for(var o in e)_(e[o],t,o,s.thatReturnsArgument);return t}},650:e=>{function t(e){return function(){return e}}var o=function(){};o.thatReturns=t,o.thatReturnsFalse=t(!1),o.thatReturnsTrue=t(!0),o.thatReturnsNull=t(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},163:e=>{e.exports=function(e,t,o,n,r,s,a,i){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[o,n,r,s,a,i],c=0;(l=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw l.framesToPop=1,l}}},759:(e,t,o)=>{var n=o(650);e.exports=n},609:e=>{e.exports=window.React}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,o),s.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=window.lodash;var t=o(609);const n=window.wp.blocks,r=window.wp.blockEditor,s=window.wp.components,a=window.wp.data,i=window.wp.domReady;var l=o.n(i);const u=window.wp.element,c=window.wp.i18n,d=window.wp.a11y,p=window.wp.url,m=window.yoast.helpers;var g=o(865);const h=window.yoast.propTypes;var f=o.n(h);const b=window.yoast.styledComponents;var y=o.n(b);const w=window.yoast.componentsNew,v=window.yoast.styleGuide,k=y().div`
|
||
display: flex;
|
||
align-items: normal;
|
||
min-height: 40px;
|
||
margin: 10px 0 5px;
|
||
`,_=(0,m.createSvgIconComponent)({copy:{viewbox:"0 0 448 512",path:"M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"},check:{viewbox:"0 0 512 512",path:"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"}}),x=y().div`
|
||
background-color: #e5e5e5;
|
||
width: 100%;
|
||
height: 1px;
|
||
`,E=y().button`
|
||
box-sizing: border-box;
|
||
flex: 0 0 30px;
|
||
height: 30px;
|
||
width: 30px;
|
||
background-color: ${e=>e.iconBackground};
|
||
border-radius: 5px;
|
||
cursor: pointer;
|
||
outline: none;
|
||
border: 1px solid ${e=>e.iconBorder};
|
||
margin-left: 3px;
|
||
|
||
&:focus {
|
||
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);
|
||
}
|
||
`;E.props={iconBackground:f().string,iconBorder:f().string},E.defaultProps={iconBackground:v.colors.$color_button,iconBorder:v.colors.$color_button_border};const A=y().div`
|
||
flex: auto;
|
||
`,S=(0,m.makeOutboundLink)(y().a`
|
||
text-overflow: ellipsis;
|
||
display: -webkit-box;
|
||
-webkit-line-clamp: 2;
|
||
/* -webkit-box-orient: vertical; */
|
||
/* -moz-box-orient: vertical; */
|
||
max-height: 40px;
|
||
margin-bottom: 4px;
|
||
-webkit-box-orient: vertical;
|
||
overflow: hidden;
|
||
padding: 0 0 4px;
|
||
`),C=y().div`
|
||
flex-wrap: wrap;
|
||
display: flex;
|
||
flex-direction: row;
|
||
justify-content: unset;
|
||
margin-top: 4px;
|
||
`,R=y().span`
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
text-align: center;
|
||
padding: 3px 8px;
|
||
font-size: 0.85em;
|
||
background-color: #f3f4f5;
|
||
border-radius: 2px;
|
||
margin-bottom: 4px;
|
||
margin-right: 4px;
|
||
text-transform: lowercase;
|
||
`,T=({badges:e})=>(0,t.createElement)(C,null,e.map(((e,o)=>(0,t.createElement)(R,{key:o},e))));T.propTypes={badges:f().array.isRequired};const B=({value:e,url:o,isActive:n,labels:r})=>{const s=(0,c.__)("Copy link","wordpress-seo-premium"),a=(0,c.sprintf)(/* translators: Hidden accessibility text; %s expands to the link value */ /* translators: Hidden accessibility text; %s expands to the link value */
|
||
(0,c.__)("Copy link to suggested article: %s","wordpress-seo-premium"),e),i=(0,u.useCallback)((e=>{e.nativeEvent.target.setAttribute("aria-label",a),e.nativeEvent.target.setAttribute("data-label",s)}),[a,s]);let l="copy",d=v.colors.$color_black,p=v.colors.$color_button,m="#979797";return n&&(l="check",d=v.colors.$color_alert_success_text,p=v.colors.$color_alert_success_background,m=v.colors.$color_alert_success_background),(0,t.createElement)("div",null,(0,t.createElement)(x,null),(0,t.createElement)(k,{className:"yoast-link-suggestion__wrapper"},(0,t.createElement)(A,{className:"yoast-link-suggestion__container"},(0,t.createElement)(S,{href:o},e),(0,t.createElement)(T,{badges:r})),(0,t.createElement)(E,{type:"button",className:"yoast-link-suggestion__copy yoast-tooltip yoast-tooltip-alt yoast-tooltip-s",onBlur:i,"data-clipboard-text":o,"aria-label":a,"data-label":s,iconBackground:p,iconBorder:m},(0,t.createElement)(_,{icon:l,color:d}),(0,t.createElement)(w.ScreenReaderText,null,s))))};B.propTypes={value:f().string.isRequired,url:f().string.isRequired,isActive:f().bool,labels:f().array.isRequired},B.defaultProps={isActive:!1};const M=B,L=y().div`
|
||
display: table-cell;
|
||
`,P=(0,c.__)("We could not find any relevant articles on your website that you could link to from your post.","wordpress-seo-premium"),$=(0,c.__)("To improve your site structure, consider linking to other relevant posts or pages on your website.","wordpress-seo-premium");let N;const O=e=>{const t=(0,c.__)("Copied!","wordpress-seo-premium");e.trigger.focus(),e.trigger.setAttribute("aria-label",t),e.trigger.setAttribute("data-label",t),(0,d.speak)(t,"assertive")},j=e=>{const t=(0,c.__)("Not supported!","wordpress-seo-premium");e.trigger.el.setAttribute("aria-label",t),e.trigger.setAttribute("data-label",t),(0,d.speak)(t,"assertive")},I=({suggestions:e,maxSuggestions:o,customMessages:n,location:r})=>{const s=function(e){const o=(0,m.makeOutboundLink)(),n=(0,p.addQueryArgs)(wpseoAdminL10n["shortlinks.site_structure_metabox"],{context:e});return(0,g.A)({
|
||
// Translators: Text between {{a}} and {{/a}} will be a link to an article about site structure.
|
||
mixedString:(0,c.__)("{{a}}Read our guide on internal linking for SEO{{/a}} to learn more.","wordpress-seo-premium"),components:{a:(0,t.createElement)(o,{href:n})}})}(r);if(0===e.length){let e=n.lengthMessage;return e=""===e?P:e,(0,t.createElement)("div",null,(0,t.createElement)("p",null,e),(0,t.createElement)("p",null,n.metaMessage),(0,t.createElement)("p",null,s))}return e.length>o&&(e.length=o),(0,t.createElement)(L,null,(0,t.createElement)("p",null,$," ",s),(0,t.createElement)("p",null,n.metaMessage),e.map(((e,o)=>(0,t.createElement)(M,{key:o,...e}))))};I.propTypes={suggestions:f().array.isRequired,maxSuggestions:f().number,customMessages:f().object,location:f().string},I.defaultProps={maxSuggestions:10,customMessages:{lengthMessage:"",metaMessage:""},location:""};const D=()=>{window.open("admin.php?page=wpseo_tools&start-indexation=true","yoastSeoAnalyzeProminentWords")},F=()=>{
|
||
/* translators: 1: link to yoast.com post about internal linking suggestion. 2: is anchor closing.
|
||
3: button to the recalculation option. 4: closing button */
|
||
let e=(0,c.__)("We need to optimize your site’s SEO data so we can offer you the best %1$slinking suggestions%2$s.\n\n%3$sStart SEO Data optimization%4$s","wordpress-seo-premium");return e=e.replace("%1$s","{{a}}"),e=e.replace("%2$s","{{/a}}"),e=e.replace("%3$s","{{startAnalysis}}"),e=e.replace("%4$s","{{/startAnalysis}}"),e=e.replace("\n\n","{{br /}}{{br /}}"),e=(0,g.A)({mixedString:e,components:{a:(0,t.createElement)("a",{href:wpseoAdminL10n["shortlinks.notification_internal_link"],target:"_blank"}),startAnalysis:(0,t.createElement)("button",{type:"button",className:"button",onClick:D}),br:(0,t.createElement)("br",null)}}),(0,t.createElement)("div",{className:"notice notice-warning notice-alt wpseo-notice-breakout-inside yoast-links-suggestions-notice"},(0,t.createElement)("p",null,e))},W=e=>{if((0,u.useEffect)((()=>(e.suggester.subscribe(),()=>{e.suggester.unsubscribe()})),[]),e.isLoading)return(0,t.createElement)("div",{className:"yoast-link-suggestions"},(0,t.createElement)("p",null,(0,c.__)("It takes a few seconds to show you a list of related content to which you could link. The suggestions will be shown here as soon as we have them.","wordpress-seo-premium")));N||(N=new ClipboardJS(".yoast-link-suggestion__copy"),N.on("success",O),N.on("error",j));let o=null;e.showUnindexedWarning&&(o=F());const n=(e=>{let t="";e.hasWordsForLinking||(t=(0,c.__)("Once you add a bit more copy, we'll give you a list of related content here to which you could link in your post.","wordpress-seo-premium"));const o=((e,t,o)=>{switch(!0){case o&&!t&&""===e:return(0,c.__)("Add a title to your post for the best internal linking suggestions.","wordpress-seo-premium");case!o&&t&&""===e:return(0,c.__)("Add a metadescription to your post for the best internal linking suggestions.","wordpress-seo-premium");case!o&&!t&&""===e:return(0,c.__)("Add a title and a metadescription to your post for the best internal linking suggestions.","wordpress-seo-premium");case o&&!t&&""!==e:return(0,c.__)("Also, add a title to your post for the best internal linking suggestions.","wordpress-seo-premium");case!o&&t&&""!==e:return(0,c.__)("Also, add a metadescription to your post for the best internal linking suggestions.","wordpress-seo-premium");case!o&&!t&&""!==e:return(0,c.__)("Also, add a title and a metadescription to your post for the best internal linking suggestions.","wordpress-seo-premium")}})(t,e.hasTitle,e.hasMetaDescription);return{lengthMessage:t,metaMessage:o}})({...e.messageData,hasWordsForLinking:Array.isArray(e.wordsForLinking)&&e.wordsForLinking.length>0});return(0,t.createElement)("div",{className:"yoast-link-suggestions"},o,(0,t.createElement)(I,{suggestions:e.suggestions,customMessages:n,location:e.location}))};function H(e,t){for(const o of e)t(o),o.innerBlocks&&H(o.innerBlocks,t)}W.propTypes={suggester:f().object,suggestions:f().array.isRequired,wordsForLinking:f().array,messageData:f().object,isLoading:f().bool.isRequired,showUnindexedWarning:f().bool,location:f().string},W.defaultProps={suggester:null,showUnindexedWarning:!1,messageData:{hasMetaDescription:!1,hasTitle:!1},wordsForLinking:[],location:""};const q=window.yoast.editorModules.helpers.createInterpolateElement;function z(e,t,o,n){t!==o&&n(e,{status:t})}function V(t){if(!(0,a.select)("yoast-seo-premium/editor"))return void setTimeout(V.bind(null,t),500);(0,e.get)(YoastSEO,"analysis.linkSuggester")&&YoastSEO.analysis.linkSuggester.update();const{linkSuggestionsAreLoading:o}=(0,a.select)("yoast-seo-premium/editor"),{getBlockAttributes:n}=(0,a.select)("core/block-editor"),r=n(t);"loaded"!==r.status&&(o()?setTimeout(V.bind(null,t),500):function(e,t){const{linkSuggestionsAreUnindexed:o,getLinkSuggestions:n,getWordsForLinking:r}=(0,a.select)("yoast-seo-premium/editor"),{updateBlockAttributes:s}=(0,a.dispatch)("core/block-editor");if(o())return void z(e,"unindexed",t.status,s);const i=r();if(!Array.isArray(i)||0===i.length)return void z(e,"no-content",t.status,s);const l=n();0!==l.length?"loading"===t.status?s(e,{values:l.map((e=>`<li><a href="${e.url}">${e.value}</a></li>`)).join(""),status:"loaded"}):z(e,"has-suggestions",t.status,s):z(e,"no-suggestions",t.status,s)}(t,r))}function U(e,o="warning"){const n=`notice notice-${o} notice-alt wpseo-notice-breakout-inside yoast-links-suggestions-notice`;return(0,t.createElement)("div",{className:n},(0,t.createElement)("p",null,e))}function Y(){return(0,a.select)("yoast-seo-premium/editor")?(0,a.select)("yoast-seo-premium/editor").getLinkSuggestions():null}function G(){return(0,a.select)("yoast-seo-premium/editor")?(0,a.select)("yoast-seo-premium/editor").getWordsForLinking():null}const J=window.wp.hooks,Q=window.yoast.analysis,{stripHTMLTags:K}=Q.languageProcessing,X=(t,o)=>{const r=`h-${function(t){const o=new RegExp("[^\\p{L}\\p{N}]+","gu");return(0,e.trim)((0,e.deburr)(K(t)).replace(o,"-").toLowerCase(),"-")}((0,n.getBlockContent)(t))}`;let s=r,a=0;for(;o.includes(s);)s=`${r}-${a}`,a++;return s};const Z=e=>{const t=[];return H(e,(e=>{"core/heading"===e.name&&t.push(e.attributes.anchor)})),t};function ee(e,t){let o=e;for(;o&&o.level>=t;)o=o.parent;return o}function te(e){const o=e.map((e=>{let o=null;return e.children&&e.children.length>0&&(o=te(e.children)),(0,t.createElement)("li",{key:e.href},(0,t.createElement)("a",{href:e.href,"data-level":e.level},e.content),o)}));return(0,t.createElement)("ul",null,o)}function oe(e,t=99){return e&&0!==e.length?te(e=function(e){const t=[];let o;for(const n of e){const e=parseInt(n.level,10),r={children:[],parent:null,...n,level:e},s=ee(o,e);s?(r.parent=s,s.children.push(r)):t.push(r),o=r}return t}(e=e.filter((e=>e.level<=t)))):null}(0,J.addFilter)("blocks.switchToBlockType.transformedBlock","yoast-seo-table-of-contents/transformed-block",(t=>{if((0,e.isNil)(t.attributes.anchor)&&"core/heading"===t.name){const e=(0,a.select)("core/block-editor").getBlocks(),o=Z(e);t.attributes.anchor=X(t,o)}return t})),l()((()=>{window.wpseoPremiumMetaboxData?function(){let t=(0,a.select)("core/block-editor").getBlocks(),o=G(),n=Y();(0,a.subscribe)((()=>{const r=(0,a.select)("core/block-editor").getBlocks(),s=G(),i=Y(),l=!(0,e.isEqual)(t,r),u=!(0,e.isEqual)(o,s),c=!(0,e.isEqual)(n,i);(l||u||c)&&H(r,(e=>{"yoast-seo/related-links"===e.name&&(l&&"loading"===e.attributes.status?V(e.clientId):(u&&"no-content"===e.attributes.status&&V(e.clientId),c&&"loaded"!==e.attributes.status&&V(e.clientId)))})),t=r,o=s,n=i}))}():(0,n.unregisterBlockType)("yoast-seo/related-links")})),(0,n.registerBlockType)("yoast-seo/related-links",{title:(0,c.__)("Yoast Related Links","wordpress-seo-premium"),icon:"editor-ul",category:"yoast-internal-linking-blocks",description:(0,c.__)("Adds a list of links related to this page.","wordpress-seo-premium"),keywords:[(0,c.__)("seo","wordpress-seo-premium"),(0,c.__)("internal linking","wordpress-seo-premium"),(0,c.__)("site structure","wordpress-seo-premium"),(0,c.__)("related posts","wordpress-seo-premium"),(0,c.__)("related pages","wordpress-seo-premium")],attributes:{status:{type:"string",default:"loading"},values:{type:"string",source:"html",selector:"ul",multiline:"li",default:""}},example:{attributes:{status:"loaded",values:"<li><a href='https://example.org'>Related link 1</a></li><li><a href='https://example.org'>Related link 2</a></li><li><a href='https://example.org'>Related link 3</a></li>"}},edit:function({clientId:e,attributes:o,setAttributes:a,mergeBlocks:i,onReplace:l}){const{values:d,status:p}=o,m=()=>{a({status:"loading"}),V(e)};(0,u.useEffect)((()=>{"loaded"!==p&&m()}),[]);const g=(0,u.useCallback)((e=>{a({values:e})}),[a]),h=(0,u.useCallback)((e=>{(0,n.createBlock)(name,{...o,values:e})}),[o]),f=(0,u.useCallback)((()=>{l([])}),l);return window.wpseoPremiumMetaboxData.data.restApi.available&&window.wpseoPremiumMetaboxData.data.restApi.contentEndpointsAvailable&&"enabled"===window.wpseoPremiumMetaboxData.data.linkSuggestionsEnabled&&window.wpseoPremiumMetaboxData.data.linkSuggestionsAvailable||"loaded"===p?"loaded"!==p?function(e,o){if("unindexed"===e)return F();let n=(0,c.__)("We could not find any relevant articles on your website that you could link to from your post.","wordpress-seo-premium");return"no-content"===e&&(n=(0,c.__)("Once you add a bit more copy, we'll give you a list of related content here to which you could link in your post.","wordpress-seo-premium")),"loading"===e&&(n=(0,c.__)("It takes a few seconds to show you a list of related content to which you could link. The suggestions will be shown here as soon as we have them.","wordpress-seo-premium")),"has-suggestions"===e&&(n=(0,t.createElement)(u.Fragment,null,n,(0,t.createElement)("br",null),(0,t.createElement)("br",null),(0,t.createElement)("button",{type:"button",className:"button",onClick:o},(0,c.__)("Load suggestions","wordpress-seo-premium")))),U(n)}(p,m):(0,t.createElement)(r.RichText,{identifier:"values",multiline:"li",tagName:"ul",onChange:g,value:d,placeholder:(0,c.__)("Write list…","wordpress-seo-premium"),onMerge:i,onSplit:h,onReplace:l,onRemove:f},(()=>(0,t.createElement)(r.BlockControls,null,(0,t.createElement)(s.ToolbarGroup,{controls:[{icon:"image-rotate",title:(0,c.__)("Refresh suggestions","wordpress-seo-premium"),isActive:!1,onClick:m}]})))):U(q((0,c.__)("You have disabled Link suggestions, which is needed for Related links to work. If you want to add Related links, please go to <a>Site features</a> and enable Link suggestions.","wordpress-seo-premium"),{a:(0,t.createElement)("a",{href:wpseoPremiumMetaboxData.data.settingsPageUrl,target:"_blank"},"#21441-gutenberg")}),"error")},save:function({attributes:e}){return"loaded"!==e.status?null:(0,t.createElement)(r.RichText.Content,{tagName:"ul",multiline:"li",value:e.values})}}),(0,e.get)(window,"wpseoTOCData.data.disableTableOfContents",!1)||function(){const o=(0,e.get)(window,"wpseoTOCData.data",{}).TOCTitle;var i;l()((()=>{!function(){let t=null,o="",r=!1,s=[];const i={};(0,a.subscribe)((()=>{if(r)return;const l=(0,a.select)("core/block-editor").getBlocks(),u=[];if(t!==l){const t=[],c=[];let d="";r=!0;const p=Z(l).every((t=>(0,e.isUndefined)(t)));H(l,(o=>{if("core/heading"===o.name){const l=K((0,n.getBlockContent)(o)),c=o.attributes.level,m=function(t,o,r,s,i){let l=t.attributes.anchor;const u=o[t.clientId],c=K((0,n.getBlockContent)(t));return u&&u===c||l&&!l.startsWith("h-")||(l=function(t,o,r,s){return!(0,e.isNil)(t.attributes.anchor)||s||(0,e.isEmpty)((0,n.getBlockContent)(t))||r.includes(t.clientId)?X(t,o):""}(t,r,s,i),l!==t.attributes.anchor&&(0,a.dispatch)("core/block-editor").updateBlockAttributes(t.clientId,{anchor:l})),l}(o,i,u,s,p);if(i[o.clientId]=l,""===m||(0,e.isEmpty)(l))return;u.push(m),t.push({content:(r=l,(new DOMParser).parseFromString(r,"text/html").documentElement.textContent),href:"#"+m,level:c}),d+="$"+c+":"+m+":"+l}else c.push(o.clientId);var r})),H(l,(e=>{if("yoast-seo/table-of-contents"===e.name){const n=e.attributes.headings&&e.attributes.headings.length>0;(o!==d||t.length>0&&!n)&&(0,a.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{headings:t})}})),r=!1,o=d,s=c}t=l}))}()})),i=o,(0,n.registerBlockType)("yoast-seo/table-of-contents",{title:(0,c.__)("Yoast Table of Contents","wordpress-seo-premium"),icon:"editor-ul",category:"yoast-internal-linking-blocks",description:(0,c.__)("Adds a table of contents to this page.","wordpress-seo-premium"),keywords:[(0,c.__)("seo","wordpress-seo-premium"),(0,c.__)("links","wordpress-seo-premium"),(0,c.__)("site structure","wordpress-seo-premium"),(0,c.__)("toc","wordpress-seo-premium")],attributes:{title:{type:"string",source:"html",selector:"h1,h2,h3,h4,h5,h6",default:i},level:{type:"number",default:2},maxHeadingLevel:{type:"number",default:3},headings:{type:"array",source:"query",selector:"a",query:{content:{type:"string",source:"html"},href:{type:"string",source:"attribute",attribute:"href"},level:{type:"string",source:"attribute",attribute:"data-level"}}}},example:{attributes:{headings:[{content:"Heading 1",href:"#heading-1",level:"2"},{content:"Subheading 1",href:"#subheading-1",level:"3"},{content:"Subheading 2",href:"#subheading-2",level:"3"},{content:"Heading 2",href:"#heading-2",level:"2"}]}},edit:function({attributes:e,setAttributes:o}){const n=(0,u.useCallback)((e=>o({title:e})),[o]),a=(0,u.useCallback)((e=>o({level:e})),[o]),i=(0,u.useCallback)((e=>o({maxHeadingLevel:Number(e)})),[o]);return(0,t.createElement)(u.Fragment,null,(0,t.createElement)(r.BlockControls,null,(0,t.createElement)(s.ToolbarGroup,null,(0,t.createElement)(r.HeadingLevelDropdown,{value:e.level,options:[1,2,3,4,5,6],onChange:a}))),(0,t.createElement)(r.InspectorControls,null,(0,t.createElement)(s.PanelBody,{title:(0,c.__)("Settings","wordpress-seo-premium"),className:"yoast-table-of-contents-controls"},(0,t.createElement)(s.SelectControl,{label:(0,c.__)("Maximum heading level","wordpress-seo-premium"),value:e.maxHeadingLevel,options:[1,2,3,4,5,6].map((e=>({label:(0,c.sprintf)((0,c.__)("Heading %d"),e),value:e}))),onChange:i}))),(0,t.createElement)("div",{className:"yoast-table-of-contents"},(0,t.createElement)(r.RichText,{tagName:"h"+e.level,value:e.title,onChange:n}),oe(e.headings,e.maxHeadingLevel)))},save:function({attributes:e}){let o=null;return e.title&&(o=(0,t.createElement)(r.RichText.Content,{tagName:"h"+e.level,value:e.title})),(0,t.createElement)("div",{className:"yoast-table-of-contents"},o,oe(e.headings,e.maxHeadingLevel))},deprecated:[{attributes:{title:{type:"string",source:"html",selector:"h2",default:(0,c.__)("Table of contents","wordpress-seo-premium")},level:{type:"number",default:2},headings:{type:"array",source:"query",selector:"a",query:{content:{type:"string",source:"html"},href:{type:"string",source:"attribute",attribute:"href"},level:{type:"string",source:"attribute",attribute:"data-level"}}}},migrate:e=>({maxHeadingLevel:6,...e}),save:({attributes:e})=>{let o=null;return e.title&&(o=(0,t.createElement)(r.RichText.Content,{tagName:"h"+e.level,value:e.title})),(0,t.createElement)("div",{className:"yoast-table-of-contents"},o,oe(e.headings))}}]})}()})()})(); |