From 90ad450a5954525db75a35e21a91032b1543f7d4 Mon Sep 17 00:00:00 2001 From: prcdevgitbot Date: Thu, 22 Feb 2024 13:38:33 +0000 Subject: [PATCH] See https://github.com/pewresearch/pewresearch-org/commit/d5601fa9df3f5d9917b4dec192f6dedbab0e4382 from refs/heads/release/5.0 --- blocks/core-heading/core-heading.php | 5 + blocks/form-captcha/README.md | 10 +- .../table-of-contents/build/index.asset.php | 2 +- blocks/table-of-contents/build/index.css.map | 1 + blocks/table-of-contents/build/index.js | 2 +- blocks/table-of-contents/build/index.js.map | 2 +- .../build/style-index.css.map | 1 + blocks/table-of-contents/build/view.asset.php | 2 +- blocks/table-of-contents/build/view.js | 2 +- blocks/table-of-contents/build/view.js.map | 2 +- blocks/table-of-contents/package.json | 5 +- blocks/table-of-contents/src/edit.jsx | 197 ++++++++++-------- blocks/table-of-contents/src/view.js | 90 +++++++- .../table-of-contents/table-of-contents.php | 60 +++++- 14 files changed, 271 insertions(+), 110 deletions(-) create mode 100644 blocks/table-of-contents/build/index.css.map create mode 100644 blocks/table-of-contents/build/style-index.css.map diff --git a/blocks/core-heading/core-heading.php b/blocks/core-heading/core-heading.php index 967eff8fd..bf4d414ce 100644 --- a/blocks/core-heading/core-heading.php +++ b/blocks/core-heading/core-heading.php @@ -170,6 +170,11 @@ public function render( $block_content, $block ) { if ( array_key_exists('isChapter', $block['attrs']) && true === $block['attrs']['isChapter'] ) { $heading_tag->set_attribute( 'data-is-chapter', 'true' ); + $heading_tag->set_attribute( 'data-wp-interactive', wp_json_encode(array('namespace' => 'prc-block/table-of-contents')) ); + $heading_tag->set_attribute( 'data-wp-context', wp_json_encode(array( + 'id' => $id, + ))); + $heading_tag->set_attribute( 'data-wp-on-document--scroll', 'callbacks.watchForChapterScroll' ); } $block_content = $heading_tag->get_updated_html(); diff --git a/blocks/form-captcha/README.md b/blocks/form-captcha/README.md index 1df499a2a..d89913707 100644 --- a/blocks/form-captcha/README.md +++ b/blocks/form-captcha/README.md @@ -6,18 +6,18 @@ Stable tag: 1.0.0 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html -Display a captcha form element +Display a captcha form element, conditionally. ## Description -This is the long description. No limit, and you can use Markdown (as well as in the following sections). +This captcha is powered by Cloudflare's Turnstile. It is a simple captcha that can be used to protect block applications from bots and spam. +It is conditionally displayed when it's parent and target namespace have a context.captchaHidden value of false, by default most applications will have this set to true. -For backwards compatibility, if this section is missing, the full length of the short description will be used, and -Markdown parsed. +Upon successful completion of the captcha, the challenge token will be returned back to the targetnamespace at `context.captchaToken` which you should further validate in your rest request. See `\PRC\Platform\Mailchimp->verify_captcha()` for an example of how to validate the captcha token. ## Instructions -This section describes how to use the block. +Drop block in block application, set the targetnamespace attribute in the PRC Interactiity API panel. This will be the namespace of the parent block that will control the captcha visibility. It is incumbent upon the parent block to handle toggling the block on|off and further validation of the returned challenge token. ## Frequently Asked Questions diff --git a/blocks/table-of-contents/build/index.asset.php b/blocks/table-of-contents/build/index.asset.php index 2d7991f69..fea829687 100644 --- a/blocks/table-of-contents/build/index.asset.php +++ b/blocks/table-of-contents/build/index.asset.php @@ -1 +1 @@ - array('classnames', 'prc-block-utils', 'prc-icons', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '372ced25c6d3d5574964'); + array('classnames', 'prc-block-utils', 'prc-icons', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'f25b1b9713df21afa5c5'); diff --git a/blocks/table-of-contents/build/index.css.map b/blocks/table-of-contents/build/index.css.map new file mode 100644 index 000000000..b5812e86f --- /dev/null +++ b/blocks/table-of-contents/build/index.css.map @@ -0,0 +1 @@ +{"version":3,"file":"index.css","mappings":";;;AAAA;;;;EAAA;AAMA;EACC;EACA;AAAD;AAEE;EACC;EACA;AAAH,C","sources":["webpack://table-of-contents/./src/editor.scss"],"sourcesContent":["/**\n * The following styles get applied inside the editor only.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.wp-block-prc-block-table-of-contents.wp-block {\n\tcolor: inherit;\n\tbackground: inherit;\n\t.wp-block-prc-block-table-of-contents__heading {\n\t\t&.is-hidden {\n\t\t\tdisplay: block;\n\t\t\topacity: 0.6;\n\t\t}\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/table-of-contents/build/index.js b/blocks/table-of-contents/build/index.js index 3d53b788b..6fb61bf98 100644 --- a/blocks/table-of-contents/build/index.js +++ b/blocks/table-of-contents/build/index.js @@ -1,2 +1,2 @@ -(()=>{"use strict";var e,o={718:(e,o,t)=>{const r=window.wp.blocks,l=window.wp.domReady;var a=t.n(l);const n=window.React,c=window.classnames;var s=t.n(c);const i=window.prcBlockUtils,d=window.wp.blockEditor,u=window.wp.data,p=window.wp.i18n,g=window.wp.element,h=window.wp.components;function C({attributes:e,colors:o,clientId:t}){const{className:r}=e,l=(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),a=(0,g.useMemo)((()=>{const{dropdownBackgroundColor:e,setDropdownBackgroundColor:t,dropdownTextColor:l,setDropdownTextColor:a,headingBackgroundColor:n,setHeadingBackgroundColor:c,headingTextColor:s,setHeadingTextColor:i,activeBackgroundColor:d,setActiveBackgroundColor:u,activeTextColor:g,setActiveTextColor:h,hoverBackgroundColor:C,setHoverBackgroundColor:b,hoverTextColor:k,setHoverTextColor:w}=o,v=[{colorValue:l?.color,onColorChange:a,label:(0,p.__)("(Mobile) Dropdown Text")},{colorValue:e?.color,onColorChange:t,label:(0,p.__)("(Mobile) Dropdown Background")},{colorValue:s?.color,onColorChange:i,label:(0,p.__)("(Desktop) Heading Text")},{colorValue:n?.color,onColorChange:c,label:(0,p.__)("(Desktop) Heading Background")},{colorValue:g?.color,onColorChange:h,label:(0,p.__)("Active Text")},{colorValue:d?.color,onColorChange:u,label:(0,p.__)("Active Background")},{colorValue:k?.color,onColorChange:w,label:(0,p.__)("Hover Text")},{colorValue:C?.color,onColorChange:b,label:(0,p.__)("Hover Background")}];return"is-style-dropdown"===r&&(v[0].label=(0,p.__)("Dropdown Text"),v[1].label=(0,p.__)("Dropdown Background"),v.splice(2,2)),v}),[o,r]);return(0,n.createElement)(d.InspectorControls,{group:"color"},(0,n.createElement)(d.__experimentalColorGradientSettingsDropdown,{settings:a,panelId:t,hasColorsOrGradients:!1,disableCustomColors:!0,__experimentalIsRenderedInSidebar:!0,...l}))}function b({attributes:e,setAttributes:o,colors:t,clientId:r}){const{showCurrentChapter:l,hideHeading:a,className:c,autoDropdownWidth:s,autoDropdownEnabled:i}=e;return(0,n.createElement)(g.Fragment,null,(0,n.createElement)(C,{attributes:e,colors:t,clientId:r}),(0,n.createElement)(d.InspectorControls,null,(0,n.createElement)(h.PanelBody,{title:(0,p.__)("Settings","prc-block-library")},(0,n.createElement)(h.ToggleControl,{label:(0,p.__)("Highlight Current Chapter"),checked:l,onChange:()=>{o({showCurrentChapter:!l})},help:(0,p.__)("Highlight the current chapter in the table of contents when scrolling.","prc-block-library")}),"is-style-default"===c&&(0,n.createElement)(g.Fragment,null,(0,n.createElement)(h.ToggleControl,{label:(0,p.__)("Hide Heading"),checked:a,onChange:()=>{o({hideHeading:!a})},help:(0,p.__)('Hide the heading from the front end when in "Baseball Card" style.',"prc-block-library")}),(0,n.createElement)(h.BaseControl,{label:(0,p.__)("Auto Dropdown"),help:(0,p.__)("Automatically switch to the dropdown style when the container is less than the specified width.","prc-block-library")},(0,n.createElement)(h.ToggleControl,{label:(0,p.__)("Enable"),checked:i,onChange:()=>{o({autoDropdownEnabled:!i})}}),i&&(0,n.createElement)(h.__experimentalNumberControl,{label:(0,p.__)("Container Width Threshold"),onChange:e=>o({autoDropdownWidth:e}),shiftStep:10,value:s}))))))}const k=window.wp.coreData;const w=(0,d.withColors)({dropdownBackgroundColor:"color"},{dropdownTextColor:"color"},{headingBackgroundColor:"color"},{headingTextColor:"color"},{activeBackgroundColor:"color"},{activeTextColor:"color"},{hoverBackgroundColor:"color"},{hoverTextColor:"color"})((function({attributes:e,setAttributes:o,context:t,clientId:r,isSelected:l,dropdownBackgroundColor:a,setDropdownBackgroundColor:c,dropdownTextColor:p,setDropdownTextColor:h,headingBackgroundColor:C,setHeadingBackgroundColor:w,headingTextColor:v,setHeadingTextColor:f,activeBackgroundColor:m,setActiveBackgroundColor:_,activeTextColor:x,setActiveTextColor:T,hoverBackgroundColor:y,setHoverBackgroundColor:B,hoverTextColor:E,setHoverTextColor:D}){const{postId:N,postType:H}=t,{chapters:I=[]}=function({postId:e,postType:o}){const{record:t,isResolving:r}=(0,k.useEntityRecord)("postType",o,e),l=(0,g.useMemo)((()=>!t||r?[{id:e,title:"Chapter 1...",internalChapters:[{title:"Chapter 1.1...",id:1},{title:"Chapter 1.2...",id:2},{title:"Chapter 1.3...",id:3}]},{id:2,title:"Chapter 2..."},{id:3,title:"Chapter 3..."}]:t?.table_of_contents),[t,r]),a=function(){const{currentChapters:e=[]}=(0,u.useSelect)((e=>{const o=e("core/block-editor").getBlocks().filter((e=>"core/heading"===e.name&&!0===e.attributes?.isChapter));return{currentChapters:0===o.length?[{attributes:{content:"Chapter 1..."}},{attributes:{content:"Chapter 2..."}},{attributes:{content:"Chapter 3..."}}]:o}}),[]);return e}();return{chapters:(0,g.useMemo)((()=>l?.map((o=>{const t=e===o?.id?a.map((e=>({title:e.attributes?.content,id:e?.id,clientId:e?.clientId,link:e?.link}))):o?.internal_chapters;return{id:o.id,title:o?.title,link:o?.link,internalChapters:t}}))),[a,l])}}({postId:N,postType:H}),{heading:A,showCurrentChapter:M,className:O,hideHeading:S,autoDropdownEnabled:$,autoDropdownWidth:V,style:R}=e,{selectBlock:j}=(0,u.useDispatch)("core/block-editor"),[G,W]=(0,n.useState)(!1),[F,z]=(0,n.useState)(null),P=(0,n.useRef)(null);(0,n.useEffect)((()=>{if(!$)return z(!1);const e=()=>{P?.current&&z(P?.current.parentNode.parentNode.offsetWidth<=V)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[$,P?.current?.parentNode?.parentNode.offsetWidth,P?.current?.parentNode?.parentNode,V]);const L=(0,n.useMemo)((()=>({dropdownBackgroundColor:a,setDropdownBackgroundColor:c,dropdownTextColor:p,setDropdownTextColor:h,headingBackgroundColor:C,setHeadingBackgroundColor:w,headingTextColor:v,setHeadingTextColor:f,activeBackgroundColor:m,setActiveBackgroundColor:_,activeTextColor:x,setActiveTextColor:T,hoverBackgroundColor:y,setHoverBackgroundColor:B,hoverTextColor:E,setHoverTextColor:D})),[a,c,p,h,C,w,v,f,m,_,x,T,y,B,E,D]),U=(0,n.useMemo)((()=>s()(O,"common-block-style--baseball-card",{"is-switched":F})),[F,O]),J=(0,n.useMemo)((()=>s()("wp-block-prc-block-table-of-contents__heading",{"has-text-color":!!L?.headingTextColor?.color||!!L?.headingTextColor?.class,[`has-${L?.headingTextColor?.slug}-color`]:!!L?.headingTextColor?.slug,"has-background":!!L?.headingBackgroundColor?.color||!!L?.headingBackgroundColor?.class,[`has-${L?.headingBackgroundColor?.slug}-background-color`]:!!L?.headingBackgroundColor?.slug,"is-hidden":S})),[L,S]),Y=(0,n.useMemo)((()=>s()("wp-block-prc-block-table-of-contents__dropdown__heading",{"has-text-color":!!L?.dropdownTextColor?.color||!!L?.dropdownTextColor?.class,[`has-${L?.dropdownTextColor?.slug}-color`]:!!L?.dropdownTextColor?.slug,"has-background":!!L?.dropdownBackgroundColor?.color||!!L?.dropdownBackgroundColor?.class,[`has-${L?.dropdownBackgroundColor?.slug}-background-color`]:!!L?.dropdownBackgroundColor?.slug})),[L]),q=(0,n.useMemo)((()=>({className:U,"data-auto-dropdown-enabled":$,"data-auto-dropdown-width":V,"data-show-current-chapter":M,"aria-expanded":G})),[U,$,V,M,G]),K=(0,d.useBlockProps)(q);return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(b,{attributes:e,setAttributes:o,colors:L,clientId:r}),(0,n.createElement)("div",{...K},(0,n.createElement)("div",{ref:P},(0,n.createElement)("div",{className:J},(0,n.createElement)(d.RichText,{tagName:"h2",placeholder:"Table of Contents",value:A,onChange:e=>o({heading:e})})),(0,n.createElement)("div",{className:Y},(0,n.createElement)(d.RichText,{tagName:"h2",placeholder:"Table of Contents",value:A,onChange:e=>o({heading:e})}),(0,n.createElement)("div",{className:"wp-block-prc-block-table-of-contents__dropdown-trigger",onClick:()=>W(!G)},"+")),(0,n.createElement)("ul",{className:"wp-block-prc-block-table-of-contents__list",style:{"--block-gap":(0,i.getBlockGapSupportValue)(e)}},0!==I.length&&I.map((e=>(0,n.createElement)("li",{key:e.id,className:s()("wp-block-prc-block-table-of-contents__list-item",{"is-active":N===e?.id,"has-active-background":!!L.activeBackgroundColor.color||L.activeBackgroundColor.class,[`has-active-${L?.activeBackgroundColor?.slug}-background-color`]:!!L?.activeBackgroundColor?.slug,"has-active-color":!!L.activeTextColor.color||L.activeTextColor.class,[`has-active-${L?.activeTextColor?.slug}-color`]:!!L?.activeTextColor?.slug,"has-focus-background":!!L.activeBackgroundColor.color||L.activeBackgroundColor.class,[`has-focus-${L?.activeBackgroundColor?.slug}-background-color`]:!!L?.activeBackgroundColor?.slug,"has-focus-color":!!L.activeTextColor.color||L.activeTextColor.class,[`has-focus-${L?.activeTextColor?.slug}-color`]:!!L?.activeTextColor?.slug,"has-hover-background":!!L.hoverBackgroundColor.color||L.hoverBackgroundColor.class,[`has-hover-${L?.hoverBackgroundColor?.slug}-background-color`]:!!L?.activeBackgroundColor?.slug,"has-hover-color":!!L.hoverTextColor.color||L.hoverTextColor.class,[`has-hover-${L?.hoverTextColor?.slug}-color`]:!!L?.hoverTextColor?.slug})},(0,n.createElement)("span",null,e?.title),N===e?.id&&e?.internalChapters&&(0,n.createElement)("ul",{className:"wp-block-prc-block-table-of-contents__list"},e.internalChapters.map((e=>(0,n.createElement)("li",{key:e.id},(0,n.createElement)("a",{onClick:()=>{e.clientId&&j(e.clientId)}},e.title))))))))))))})),v=window.prcIcons,f=[{name:"table-of-contents",isDefault:!0,title:(0,p.__)("Table of Contents (Default)"),description:(0,p.__)('The default table of contents block. Displays a list of links to chapters and back-chapters in a post in a "Baseball Card" style. On mobile this transforms to a dropdown.'),attributes:{className:"is-style-default"},scope:["inserter","transform"],isActive:(e,o)=>o.className===e.className},{name:"table-of-contents-dropdown",isDefault:!0,title:(0,p.__)("Table of Contents (Dropdown)"),description:(0,p.__)("Displays a list of chapters and back-chapters in a post in a dropdown style."),attributes:{className:"is-style-dropdown"},scope:["inserter","transform"],isActive:(e,o)=>o.className===e.className}],m=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"prc-block/table-of-contents","version":"0.1.0","title":"Table of Contents","category":"theme","description":"Displays a list of all heading blocks set to chapter headings.","attributes":{"showCurrentChapter":{"type":"boolean","default":false},"dropdownBackgroundColor":{"type":"string","default":"white"},"dropdownTextColor":{"type":"string","default":"ui-black"},"autoDropdownEnabled":{"type":"boolean","default":true},"autoDropdownWidth":{"type":"number","default":300},"headingBackgroundColor":{"type":"string","default":"ui-black"},"headingTextColor":{"type":"string","default":"white"},"backgroundColor":{"type":"string","default":"white"},"textColor":{"type":"string","default":"ui-black"},"linkColor":{"type":"string","default":"ui-black"},"activeBackgroundColor":{"type":"string","default":"ui-gray-very-light"},"activeTextColor":{"type":"string","default":"ui-black"},"hoverBackgroundColor":{"type":"string","default":"ui-beige-very-light"},"hoverTextColor":{"type":"string","default":"ui-black"},"heading":{"type":"string","default":"Table of Contents"},"hideHeading":{"type":"boolean","default":false},"style":{"type":"object","default":{"spacing":{"blockGap":"var:preset|spacing|20"}}}},"supports":{"anchor":true,"html":false,"align":["left","right"],"color":{"background":true,"text":true,"link":true},"spacing":{"margin":["top","bottom","left","right"],"blockGap":true,"__experimentalDefaultControls":{"margin":true,"blockGap":true}},"position":{"sticky":true},"typography":{"__experimentalFontFamily":true,"fontSizes":true,"lineHeight":true,"__experimentalDefaultControls":{"__experimentalFontFamily":true,"fontSizes":true}},"__experimentalBorder":{"color":true,"radius":false,"style":true,"width":true,"__experimentalDefaultControls":{"color":true,"radius":false,"style":true,"width":true}}},"selectors":{"root":".wp-block-prc-block-table-of-contents","spacing":{"blockGap":".wp-block-prc-block-table-of-contents__list"}},"example":{"attributes":{"className":"is-style-default"},"viewportWidth":320},"usesContext":["postId","postType"],"textdomain":"table-of-contents","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":["file:./style-index.css","prc-block-library--baseball-card","prc-block-library--additional-color-supports"],"viewScriptModule":"file:./view.js"}'),{name:_}=m,x={icon:function(){return(0,n.createElement)(v.Icon,{icon:v.icons.faListTree,height:18,preserveAspectRatio:"xMidYMid meet"})},edit:w,variations:f};(0,r.registerBlockType)(_,{...m,...x}),a()((()=>{(0,r.unregisterBlockType)("core/table-of-contents"),(0,r.unregisterBlockType)("yoast-seo/table-of-contents")}))}},t={};function r(e){var l=t[e];if(void 0!==l)return l.exports;var a=t[e]={exports:{}};return o[e](a,a.exports,r),a.exports}r.m=o,e=[],r.O=(o,t,l,a)=>{if(!t){var n=1/0;for(d=0;d=a)&&Object.keys(r.O).every((e=>r.O[e](t[s])))?t.splice(s--,1):(c=!1,a0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[t,l,a]},r.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return r.d(o,{a:o}),o},r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={57:0,350:0};r.O.j=o=>0===e[o];var o=(o,t)=>{var l,a,[n,c,s]=t,i=0;if(n.some((o=>0!==e[o]))){for(l in c)r.o(c,l)&&(r.m[l]=c[l]);if(s)var d=s(r)}for(o&&o(t);ir(718)));l=r.O(l)})(); +(()=>{"use strict";var e,o={718:(e,o,t)=>{const r=window.wp.blocks,l=window.wp.domReady;var a=t.n(l);const n=window.React,c=window.classnames;var s=t.n(c);const i=window.prcBlockUtils,d=window.wp.blockEditor,u=window.wp.data,p=window.wp.i18n,g=window.wp.element,h=window.wp.components;function C({attributes:e,colors:o,clientId:t}){const{className:r}=e,l=(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),a=(0,g.useMemo)((()=>{const{dropdownBackgroundColor:e,setDropdownBackgroundColor:t,dropdownTextColor:l,setDropdownTextColor:a,headingBackgroundColor:n,setHeadingBackgroundColor:c,headingTextColor:s,setHeadingTextColor:i,activeBackgroundColor:d,setActiveBackgroundColor:u,activeTextColor:g,setActiveTextColor:h,hoverBackgroundColor:C,setHoverBackgroundColor:b,hoverTextColor:k,setHoverTextColor:w}=o,v=[{colorValue:l?.color,onColorChange:a,label:(0,p.__)("(Mobile) Dropdown Text")},{colorValue:e?.color,onColorChange:t,label:(0,p.__)("(Mobile) Dropdown Background")},{colorValue:s?.color,onColorChange:i,label:(0,p.__)("(Desktop) Heading Text")},{colorValue:n?.color,onColorChange:c,label:(0,p.__)("(Desktop) Heading Background")},{colorValue:g?.color,onColorChange:h,label:(0,p.__)("Active Text")},{colorValue:d?.color,onColorChange:u,label:(0,p.__)("Active Background")},{colorValue:k?.color,onColorChange:w,label:(0,p.__)("Hover Text")},{colorValue:C?.color,onColorChange:b,label:(0,p.__)("Hover Background")}];return"is-style-dropdown"===r&&(v[0].label=(0,p.__)("Dropdown Text"),v[1].label=(0,p.__)("Dropdown Background"),v.splice(2,2)),v}),[o,r]);return(0,n.createElement)(d.InspectorControls,{group:"color"},(0,n.createElement)(d.__experimentalColorGradientSettingsDropdown,{settings:a,panelId:t,hasColorsOrGradients:!1,disableCustomColors:!0,__experimentalIsRenderedInSidebar:!0,...l}))}function b({attributes:e,setAttributes:o,colors:t,clientId:r}){const{showCurrentChapter:l,hideHeading:a,className:c,autoDropdownWidth:s,autoDropdownEnabled:i}=e;return(0,n.createElement)(g.Fragment,null,(0,n.createElement)(C,{attributes:e,colors:t,clientId:r}),(0,n.createElement)(d.InspectorControls,null,(0,n.createElement)(h.PanelBody,{title:(0,p.__)("Settings","prc-block-library")},(0,n.createElement)(h.ToggleControl,{label:(0,p.__)("Highlight Current Chapter"),checked:l,onChange:()=>{o({showCurrentChapter:!l})},help:(0,p.__)("Highlight the current chapter in the table of contents when scrolling.","prc-block-library")}),"is-style-default"===c&&(0,n.createElement)(g.Fragment,null,(0,n.createElement)(h.ToggleControl,{label:(0,p.__)("Hide Heading"),checked:a,onChange:()=>{o({hideHeading:!a})},help:(0,p.__)('Hide the heading from the front end when in "Baseball Card" style.',"prc-block-library")}),(0,n.createElement)(h.BaseControl,{label:(0,p.__)("Auto Dropdown"),help:(0,p.__)("Automatically switch to the dropdown style when the container is less than the specified width.","prc-block-library")},(0,n.createElement)(h.ToggleControl,{label:(0,p.__)("Enable"),checked:i,onChange:()=>{o({autoDropdownEnabled:!i})}}),i&&(0,n.createElement)(h.__experimentalNumberControl,{label:(0,p.__)("Container Width Threshold"),onChange:e=>o({autoDropdownWidth:e}),shiftStep:10,value:s}))))))}const k=window.wp.coreData;function w({internalChapters:e}){const{selectBlock:o}=(0,u.useDispatch)("core/block-editor");return(0,n.createElement)("ul",{className:"wp-block-prc-block-table-of-contents__list"},Object.values(e).map((e=>{const t=e.title?.originalHTML||e.title;return(0,n.createElement)("li",{key:e.id},(0,n.createElement)("a",{onClick:()=>{e.clientId&&o(e.clientId)}},t))})))}const v=(0,d.withColors)({dropdownBackgroundColor:"color"},{dropdownTextColor:"color"},{headingBackgroundColor:"color"},{headingTextColor:"color"},{activeBackgroundColor:"color"},{activeTextColor:"color"},{hoverBackgroundColor:"color"},{hoverTextColor:"color"})((function({attributes:e,setAttributes:o,context:t,clientId:r,isSelected:l,dropdownBackgroundColor:a,setDropdownBackgroundColor:c,dropdownTextColor:p,setDropdownTextColor:h,headingBackgroundColor:C,setHeadingBackgroundColor:v,headingTextColor:f,setHeadingTextColor:m,activeBackgroundColor:_,setActiveBackgroundColor:x,activeTextColor:T,setActiveTextColor:y,hoverBackgroundColor:B,setHoverBackgroundColor:E,hoverTextColor:D,setHoverTextColor:H}){const{postId:N,postType:I}=t,{chapters:A=[]}=function({postId:e,postType:o}){const{record:t,isResolving:r}=(0,k.useEntityRecord)("postType",o,e),l=(0,g.useMemo)((()=>!t||r?[{id:e,title:"Chapter 1...",internalChapters:[{title:"Chapter 1.1...",id:1},{title:"Chapter 1.2...",id:2},{title:"Chapter 1.3...",id:3}]},{id:2,title:"Chapter 2..."},{id:3,title:"Chapter 3..."}]:t?.table_of_contents),[t,r]),a=function(){const{currentChapters:e=[]}=(0,u.useSelect)((e=>{const o=e("core/block-editor").getBlocks().filter((e=>"core/heading"===e.name&&!0===e.attributes?.isChapter));return{currentChapters:0===o.length?[{attributes:{content:"Chapter 1..."}},{attributes:{content:"Chapter 2..."}},{attributes:{content:"Chapter 3..."}}]:o}}),[]);return e}();return{chapters:(0,g.useMemo)((()=>l?.map((o=>{const t=e===o?.id?a.map((e=>({title:e.attributes?.content,id:e?.id,clientId:e?.clientId,link:e?.link}))):o?.internal_chapters;return{id:o.id,title:o?.title,link:o?.link,internalChapters:t}}))),[a,l])}}({postId:N,postType:I}),{heading:M,showCurrentChapter:O,className:S,hideHeading:$,autoDropdownEnabled:V,autoDropdownWidth:j,style:R}=e,[G,W]=(0,n.useState)(!1),[F,z]=(0,n.useState)(!1),L=(0,n.useRef)(null);(0,n.useEffect)((()=>{if(!V)return z(!1);const e=()=>{L?.current&&z(L?.current.parentNode.parentNode.offsetWidth<=j)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[V,L?.current?.parentNode?.parentNode.offsetWidth,L?.current?.parentNode?.parentNode,j]);const P=(0,n.useMemo)((()=>({dropdownBackgroundColor:a,setDropdownBackgroundColor:c,dropdownTextColor:p,setDropdownTextColor:h,headingBackgroundColor:C,setHeadingBackgroundColor:v,headingTextColor:f,setHeadingTextColor:m,activeBackgroundColor:_,setActiveBackgroundColor:x,activeTextColor:T,setActiveTextColor:y,hoverBackgroundColor:B,setHoverBackgroundColor:E,hoverTextColor:D,setHoverTextColor:H})),[a,c,p,h,C,v,f,m,_,x,T,y,B,E,D,H]),U=(0,n.useMemo)((()=>s()(S,"common-block-style--baseball-card",{"is-switched":F})),[F,S]),J=(0,n.useMemo)((()=>s()("wp-block-prc-block-table-of-contents__heading",{"has-text-color":!!P?.headingTextColor?.color||!!P?.headingTextColor?.class,[`has-${P?.headingTextColor?.slug}-color`]:!!P?.headingTextColor?.slug,"has-background":!!P?.headingBackgroundColor?.color||!!P?.headingBackgroundColor?.class,[`has-${P?.headingBackgroundColor?.slug}-background-color`]:!!P?.headingBackgroundColor?.slug,"is-hidden":$})),[P,$]),Y=(0,n.useMemo)((()=>s()("wp-block-prc-block-table-of-contents__dropdown__heading",{"has-text-color":!!P?.dropdownTextColor?.color||!!P?.dropdownTextColor?.class,[`has-${P?.dropdownTextColor?.slug}-color`]:!!P?.dropdownTextColor?.slug,"has-background":!!P?.dropdownBackgroundColor?.color||!!P?.dropdownBackgroundColor?.class,[`has-${P?.dropdownBackgroundColor?.slug}-background-color`]:!!P?.dropdownBackgroundColor?.slug})),[P]),q=(0,n.useMemo)((()=>({className:U,"data-auto-dropdown-enabled":V,"data-auto-dropdown-width":j,"data-show-current-chapter":O,"aria-expanded":G})),[U,V,j,O,G]),K=(0,d.useBlockProps)(q);return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(b,{attributes:e,setAttributes:o,colors:P,clientId:r}),(0,n.createElement)("div",{...K},(0,n.createElement)("div",{ref:L},(0,n.createElement)("div",{className:J},(0,n.createElement)(d.RichText,{tagName:"h2",placeholder:"Table of Contents",value:M,onChange:e=>o({heading:e})})),(0,n.createElement)("div",{className:Y},(0,n.createElement)(d.RichText,{tagName:"h2",placeholder:"Table of Contents",value:M,onChange:e=>o({heading:e})}),(0,n.createElement)("div",{className:"wp-block-prc-block-table-of-contents__dropdown-trigger",onClick:()=>W(!G)},"+")),(0,n.createElement)("ul",{className:"wp-block-prc-block-table-of-contents__list",style:{"--block-gap":(0,i.getBlockGapSupportValue)(e)}},0!==A.length&&A.map((e=>(0,n.createElement)("li",{key:e.id,className:s()("wp-block-prc-block-table-of-contents__list-item",{"is-active":N===e?.id,"has-active-background":!!P.activeBackgroundColor.color||P.activeBackgroundColor.class,[`has-active-${P?.activeBackgroundColor?.slug}-background-color`]:!!P?.activeBackgroundColor?.slug,"has-active-color":!!P.activeTextColor.color||P.activeTextColor.class,[`has-active-${P?.activeTextColor?.slug}-color`]:!!P?.activeTextColor?.slug,"has-focus-background":!!P.activeBackgroundColor.color||P.activeBackgroundColor.class,[`has-focus-${P?.activeBackgroundColor?.slug}-background-color`]:!!P?.activeBackgroundColor?.slug,"has-focus-color":!!P.activeTextColor.color||P.activeTextColor.class,[`has-focus-${P?.activeTextColor?.slug}-color`]:!!P?.activeTextColor?.slug,"has-hover-background":!!P.hoverBackgroundColor.color||P.hoverBackgroundColor.class,[`has-hover-${P?.hoverBackgroundColor?.slug}-background-color`]:!!P?.activeBackgroundColor?.slug,"has-hover-color":!!P.hoverTextColor.color||P.hoverTextColor.class,[`has-hover-${P?.hoverTextColor?.slug}-color`]:!!P?.hoverTextColor?.slug})},(0,n.createElement)("span",null,e.title),N===e.id&&e?.internalChapters&&(0,n.createElement)(w,{internalChapters:e?.internalChapters}))))))))})),f=window.prcIcons,m=[{name:"table-of-contents",isDefault:!0,title:(0,p.__)("Table of Contents (Default)"),description:(0,p.__)('The default table of contents block. Displays a list of links to chapters and back-chapters in a post in a "Baseball Card" style. On mobile this transforms to a dropdown.'),attributes:{className:"is-style-default"},scope:["inserter","transform"],isActive:(e,o)=>o.className===e.className},{name:"table-of-contents-dropdown",isDefault:!0,title:(0,p.__)("Table of Contents (Dropdown)"),description:(0,p.__)("Displays a list of chapters and back-chapters in a post in a dropdown style."),attributes:{className:"is-style-dropdown"},scope:["inserter","transform"],isActive:(e,o)=>o.className===e.className}],_=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"prc-block/table-of-contents","version":"0.1.0","title":"Table of Contents","category":"theme","description":"Displays a list of all heading blocks set to chapter headings.","attributes":{"showCurrentChapter":{"type":"boolean","default":false},"dropdownBackgroundColor":{"type":"string","default":"white"},"dropdownTextColor":{"type":"string","default":"ui-black"},"autoDropdownEnabled":{"type":"boolean","default":true},"autoDropdownWidth":{"type":"number","default":300},"headingBackgroundColor":{"type":"string","default":"ui-black"},"headingTextColor":{"type":"string","default":"white"},"backgroundColor":{"type":"string","default":"white"},"textColor":{"type":"string","default":"ui-black"},"linkColor":{"type":"string","default":"ui-black"},"activeBackgroundColor":{"type":"string","default":"ui-gray-very-light"},"activeTextColor":{"type":"string","default":"ui-black"},"hoverBackgroundColor":{"type":"string","default":"ui-beige-very-light"},"hoverTextColor":{"type":"string","default":"ui-black"},"heading":{"type":"string","default":"Table of Contents"},"hideHeading":{"type":"boolean","default":false},"style":{"type":"object","default":{"spacing":{"blockGap":"var:preset|spacing|20"}}}},"supports":{"anchor":true,"html":false,"align":["left","right"],"color":{"background":true,"text":true,"link":true},"spacing":{"margin":["top","bottom","left","right"],"blockGap":true,"__experimentalDefaultControls":{"margin":true,"blockGap":true}},"position":{"sticky":true},"typography":{"__experimentalFontFamily":true,"fontSizes":true,"lineHeight":true,"__experimentalDefaultControls":{"__experimentalFontFamily":true,"fontSizes":true}},"__experimentalBorder":{"color":true,"radius":false,"style":true,"width":true,"__experimentalDefaultControls":{"color":true,"radius":false,"style":true,"width":true}}},"selectors":{"root":".wp-block-prc-block-table-of-contents","spacing":{"blockGap":".wp-block-prc-block-table-of-contents__list"}},"example":{"attributes":{"className":"is-style-default"},"viewportWidth":320},"usesContext":["postId","postType"],"textdomain":"table-of-contents","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":["file:./style-index.css","prc-block-library--baseball-card","prc-block-library--additional-color-supports"],"viewScriptModule":"file:./view.js"}'),{name:x}=_,T={icon:function(){return(0,n.createElement)(f.Icon,{icon:f.icons.faListTree,height:18,preserveAspectRatio:"xMidYMid meet"})},edit:v,variations:m};(0,r.registerBlockType)(x,{..._,...T}),a()((()=>{(0,r.unregisterBlockType)("core/table-of-contents"),(0,r.unregisterBlockType)("yoast-seo/table-of-contents")}))}},t={};function r(e){var l=t[e];if(void 0!==l)return l.exports;var a=t[e]={exports:{}};return o[e](a,a.exports,r),a.exports}r.m=o,e=[],r.O=(o,t,l,a)=>{if(!t){var n=1/0;for(d=0;d=a)&&Object.keys(r.O).every((e=>r.O[e](t[s])))?t.splice(s--,1):(c=!1,a0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[t,l,a]},r.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return r.d(o,{a:o}),o},r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={57:0,350:0};r.O.j=o=>0===e[o];var o=(o,t)=>{var l,a,[n,c,s]=t,i=0;if(n.some((o=>0!==e[o]))){for(l in c)r.o(c,l)&&(r.m[l]=c[l]);if(s)var d=s(r)}for(o&&o(t);ir(718)));l=r.O(l)})(); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/blocks/table-of-contents/build/index.js.map b/blocks/table-of-contents/build/index.js.map index 3d0dc3cfc..22dd1d47f 100644 --- a/blocks/table-of-contents/build/index.js.map +++ b/blocks/table-of-contents/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":"uBAAIA,E,iBCAJ,MAAM,EAA+BC,OAAW,GAAU,OCApD,EAA+BA,OAAW,GAAY,S,aCA5D,MAAM,EAA+BA,OAAc,MCA7C,EAA+BA,OAAmB,W,aCAxD,MAAM,EAA+BA,OAAsB,cCArD,EAA+BA,OAAW,GAAe,YCAzD,EAA+BA,OAAW,GAAQ,KCAlD,EAA+BA,OAAW,GAAQ,KCAlD,EAA+BA,OAAW,GAAW,QCArD,EAA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3C,EAClC,CAEA,IADGwC,GAA4BA,EAA2BC,GACrD1B,EAAIL,EAASzE,OAAQ8E,IACzBuB,EAAU5B,EAASK,GAChBf,EAAoB4B,EAAES,EAAiBC,IAAYD,EAAgBC,IACrED,EAAgBC,GAAS,KAE1BD,EAAgBC,GAAW,EAE5B,OAAOtC,EAAoBQ,EAAEC,EAAO,EAGjCoC,EAAqBC,WAA0C,8BAAIA,WAA0C,+BAAK,GACtHD,EAAmBE,QAAQR,EAAqBS,KAAK,KAAM,IAC3DH,EAAmBI,KAAOV,EAAqBS,KAAK,KAAMH,EAAmBI,KAAKD,KAAKH,G,KC9CvF,IAAIK,EAAsBlD,EAAoBQ,OAAEL,EAAW,CAAC,MAAM,IAAOH,EAAoB,OAC7FkD,EAAsBlD,EAAoBQ,EAAE0C,E","sources":["webpack://table-of-contents/webpack/runtime/chunk loaded","webpack://table-of-contents/external window [\"wp\",\"blocks\"]","webpack://table-of-contents/external window [\"wp\",\"domReady\"]","webpack://table-of-contents/external window \"React\"","webpack://table-of-contents/external window \"classnames\"","webpack://table-of-contents/external window \"prcBlockUtils\"","webpack://table-of-contents/external window [\"wp\",\"blockEditor\"]","webpack://table-of-contents/external window [\"wp\",\"data\"]","webpack://table-of-contents/external window [\"wp\",\"i18n\"]","webpack://table-of-contents/external window [\"wp\",\"element\"]","webpack://table-of-contents/external window [\"wp\",\"components\"]","webpack://table-of-contents/./src/color-controls.jsx","webpack://table-of-contents/./src/controls.jsx","webpack://table-of-contents/external window [\"wp\",\"coreData\"]","webpack://table-of-contents/./src/edit.jsx","webpack://table-of-contents/./src/use-toc.js","webpack://table-of-contents/external window \"prcIcons\"","webpack://table-of-contents/./src/variations.js","webpack://table-of-contents/./src/index.js","webpack://table-of-contents/./src/icon.jsx","webpack://table-of-contents/webpack/bootstrap","webpack://table-of-contents/webpack/runtime/compat get default export","webpack://table-of-contents/webpack/runtime/define property getters","webpack://table-of-contents/webpack/runtime/hasOwnProperty shorthand","webpack://table-of-contents/webpack/runtime/jsonp chunk loading","webpack://table-of-contents/webpack/startup"],"sourcesContent":["var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"blocks\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"domReady\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"React\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"classnames\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"prcBlockUtils\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"blockEditor\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"data\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"i18n\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"element\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"components\"];","/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\tInspectorControls,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\n\nexport default function ColorControls({ attributes, colors, clientId }) {\n\tconst { className } = attributes;\n\n\tconst colorProps = useMultipleOriginColorsAndGradients();\n\n\tconst colorSettings = useMemo(() => {\n\t\tconst {\n\t\t\tdropdownBackgroundColor,\n\t\t\tsetDropdownBackgroundColor,\n\t\t\tdropdownTextColor,\n\t\t\tsetDropdownTextColor,\n\t\t\theadingBackgroundColor,\n\t\t\tsetHeadingBackgroundColor,\n\t\t\theadingTextColor,\n\t\t\tsetHeadingTextColor,\n\t\t\tactiveBackgroundColor,\n\t\t\tsetActiveBackgroundColor,\n\t\t\tactiveTextColor,\n\t\t\tsetActiveTextColor,\n\t\t\thoverBackgroundColor,\n\t\t\tsetHoverBackgroundColor,\n\t\t\thoverTextColor,\n\t\t\tsetHoverTextColor,\n\t\t} = colors;\n\n\t\tconst t = [\n\t\t\t{\n\t\t\t\tcolorValue: dropdownTextColor?.color,\n\t\t\t\tonColorChange: setDropdownTextColor,\n\t\t\t\tlabel: __('(Mobile) Dropdown Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: dropdownBackgroundColor?.color,\n\t\t\t\tonColorChange: setDropdownBackgroundColor,\n\t\t\t\tlabel: __('(Mobile) Dropdown Background'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: headingTextColor?.color,\n\t\t\t\tonColorChange: setHeadingTextColor,\n\t\t\t\tlabel: __('(Desktop) Heading Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: headingBackgroundColor?.color,\n\t\t\t\tonColorChange: setHeadingBackgroundColor,\n\t\t\t\tlabel: __('(Desktop) Heading Background'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: activeTextColor?.color,\n\t\t\t\tonColorChange: setActiveTextColor,\n\t\t\t\tlabel: __('Active Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: activeBackgroundColor?.color,\n\t\t\t\tonColorChange: setActiveBackgroundColor,\n\t\t\t\tlabel: __('Active Background'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: hoverTextColor?.color,\n\t\t\t\tonColorChange: setHoverTextColor,\n\t\t\t\tlabel: __('Hover Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: hoverBackgroundColor?.color,\n\t\t\t\tonColorChange: setHoverBackgroundColor,\n\t\t\t\tlabel: __('Hover Background'),\n\t\t\t},\n\t\t];\n\t\tif ('is-style-dropdown' === className) {\n\t\t\t// change the label of the first item to just be \"Dropdown Text\" and the second to just be \"Dropdown Background\", remove the 3rd and 4th items.\n\t\t\tt[0].label = __('Dropdown Text');\n\t\t\tt[1].label = __('Dropdown Background');\n\t\t\tt.splice(2, 2);\n\t\t}\n\t\treturn t;\n\t}, [colors, className]);\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\n}\n","/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\tNotice,\n\tPanelBody,\n\tRangeControl,\n\tBaseControl,\n\tToggleControl,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { InspectorControls } from '@wordpress/block-editor';\n\n/**\n * Internal Dependencies\n */\nimport ColorControls from './color-controls';\n\nexport default function Controls({\n\tattributes,\n\tsetAttributes,\n\tcolors,\n\tclientId,\n}) {\n\tconst {\n\t\tshowCurrentChapter,\n\t\thideHeading,\n\t\tclassName,\n\t\tautoDropdownWidth,\n\t\tautoDropdownEnabled,\n\t} = attributes;\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\tshowCurrentChapter: !showCurrentChapter,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}}\n\t\t\t\t\t\thelp={__(\n\t\t\t\t\t\t\t'Highlight the current chapter in the table of contents when scrolling.',\n\t\t\t\t\t\t\t'prc-block-library'\n\t\t\t\t\t\t)}\n\t\t\t\t\t/>\n\t\t\t\t\t{'is-style-default' === className && (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\thideHeading: !hideHeading,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\thelp={__(\n\t\t\t\t\t\t\t\t\t'Hide the heading from the front end when in \"Baseball Card\" style.',\n\t\t\t\t\t\t\t\t\t'prc-block-library'\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\t\tautoDropdownEnabled:\n\t\t\t\t\t\t\t\t\t\t\t\t!autoDropdownEnabled,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{autoDropdownEnabled && (\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\t\t\tautoDropdownWidth: value,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tshiftStep={10}\n\t\t\t\t\t\t\t\t\t\tvalue={autoDropdownWidth}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\n\t\t\n\t);\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"coreData\"];","/* eslint-disable max-lines */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/anchor-is-valid */\n/* eslint-disable max-lines-per-function */\n/**\n * External Dependencies\n */\nimport classNames from 'classnames';\nimport { getBlockGapSupportValue } from '@prc/block-utils';\n\n/**\n * WordPress Dependencies\n */\nimport {\n\tFragment,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n} from 'react';\nimport {\n\tuseBlockProps,\n\tRichText,\n\twithColors,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal Dependencies\n */\nimport Controls from './controls';\nimport useTOC from './use-toc';\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit\n *\n * @param {Object} props Properties passed to the function.\n * @param {Object} props.attributes Available block attributes.\n * @param props.context\n * @param props.clientId\n * @param props.isSelected\n * @param props.dropdownBackgroundColor\n * @param props.setDropdownBackgroundColor\n * @param props.dropdownTextColor\n * @param props.setDropdownTextColor\n * @param props.headingBackgroundColor\n * @param props.setHeadingBackgroundColor\n * @param props.headingTextColor\n * @param props.setHeadingTextColor\n * @param props.activeBackgroundColor\n * @param props.setActiveBackgroundColor\n * @param props.activeTextColor\n * @param props.setActiveTextColor\n * @param props.hoverBackgroundColor\n * @param props.setHoverBackgroundColor\n * @param props.hoverTextColor\n * @param props.setHoverTextColor\n * @param {Function} props.setAttributes Function that updates individual attributes.\n *\n * @return {WPElement} Element to render.\n */\nfunction Edit({\n\tattributes,\n\tsetAttributes,\n\tcontext,\n\tclientId,\n\tisSelected,\n\tdropdownBackgroundColor,\n\tsetDropdownBackgroundColor,\n\tdropdownTextColor,\n\tsetDropdownTextColor,\n\theadingBackgroundColor,\n\tsetHeadingBackgroundColor,\n\theadingTextColor,\n\tsetHeadingTextColor,\n\tactiveBackgroundColor,\n\tsetActiveBackgroundColor,\n\tactiveTextColor,\n\tsetActiveTextColor,\n\thoverBackgroundColor,\n\tsetHoverBackgroundColor,\n\thoverTextColor,\n\tsetHoverTextColor,\n}) {\n\tconst { postId, postType } = context;\n\tconst { chapters = [] } = useTOC({ postId, postType });\n\tconst {\n\t\theading,\n\t\tshowCurrentChapter,\n\t\tclassName,\n\t\thideHeading,\n\t\tautoDropdownEnabled,\n\t\tautoDropdownWidth,\n\t\tstyle,\n\t} = attributes;\n\tconst { selectBlock } = useDispatch('core/block-editor');\n\tconst [isDropdownOpen, setDropdownOpen] = useState(false);\n\tconst [isAutoDropdownSwitched, setDropdownSwitch] = useState(null);\n\n\t// Add a ref to the component\n\tconst componentRef = useRef(null);\n\n\tuseEffect(() => {\n\t\tif (!autoDropdownEnabled) {\n\t\t\treturn setDropdownSwitch(false);\n\t\t}\n\n\t\tconst updateAutoDropdownSwitch = () => {\n\t\t\tif (componentRef?.current) {\n\t\t\t\tsetDropdownSwitch(\n\t\t\t\t\tcomponentRef?.current.parentNode.parentNode.offsetWidth <=\n\t\t\t\t\t\tautoDropdownWidth\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tupdateAutoDropdownSwitch();\n\n\t\twindow.addEventListener('resize', updateAutoDropdownSwitch); // Add a listener for the window resize event\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener('resize', updateAutoDropdownSwitch); // Remove the listener when the component unmounts\n\t\t};\n\t}, [\n\t\tautoDropdownEnabled,\n\t\tcomponentRef?.current?.parentNode?.parentNode.offsetWidth,\n\t\tcomponentRef?.current?.parentNode?.parentNode,\n\t\tautoDropdownWidth,\n\t]);\n\n\t// Construct a colors object that contains the color values and helper functions, re-compute whenever the color values change.\n\tconst colors = useMemo(\n\t\t() => ({\n\t\t\tdropdownBackgroundColor,\n\t\t\tsetDropdownBackgroundColor,\n\t\t\tdropdownTextColor,\n\t\t\tsetDropdownTextColor,\n\t\t\theadingBackgroundColor,\n\t\t\tsetHeadingBackgroundColor,\n\t\t\theadingTextColor,\n\t\t\tsetHeadingTextColor,\n\t\t\tactiveBackgroundColor,\n\t\t\tsetActiveBackgroundColor,\n\t\t\tactiveTextColor,\n\t\t\tsetActiveTextColor,\n\t\t\thoverBackgroundColor,\n\t\t\tsetHoverBackgroundColor,\n\t\t\thoverTextColor,\n\t\t\tsetHoverTextColor,\n\t\t}),\n\t\t[\n\t\t\tdropdownBackgroundColor,\n\t\t\tsetDropdownBackgroundColor,\n\t\t\tdropdownTextColor,\n\t\t\tsetDropdownTextColor,\n\t\t\theadingBackgroundColor,\n\t\t\tsetHeadingBackgroundColor,\n\t\t\theadingTextColor,\n\t\t\tsetHeadingTextColor,\n\t\t\tactiveBackgroundColor,\n\t\t\tsetActiveBackgroundColor,\n\t\t\tactiveTextColor,\n\t\t\tsetActiveTextColor,\n\t\t\thoverBackgroundColor,\n\t\t\tsetHoverBackgroundColor,\n\t\t\thoverTextColor,\n\t\t\tsetHoverTextColor,\n\t\t]\n\t);\n\n\tconst blockWrapperClassNames = useMemo(() => {\n\t\treturn classNames(className, 'common-block-style--baseball-card', {\n\t\t\t'is-switched': isAutoDropdownSwitched,\n\t\t});\n\t}, [isAutoDropdownSwitched, className]);\n\n\tconst headingClassNames = useMemo(() => {\n\t\treturn classNames('wp-block-prc-block-table-of-contents__heading', {\n\t\t\t'has-text-color':\n\t\t\t\t!!colors?.headingTextColor?.color ||\n\t\t\t\t!!colors?.headingTextColor?.class,\n\t\t\t[`has-${colors?.headingTextColor?.slug}-color`]:\n\t\t\t\t!!colors?.headingTextColor?.slug,\n\t\t\t'has-background':\n\t\t\t\t!!colors?.headingBackgroundColor?.color ||\n\t\t\t\t!!colors?.headingBackgroundColor?.class,\n\t\t\t[`has-${colors?.headingBackgroundColor?.slug}-background-color`]:\n\t\t\t\t!!colors?.headingBackgroundColor?.slug,\n\t\t\t'is-hidden': hideHeading,\n\t\t});\n\t}, [colors, hideHeading]);\n\n\tconst dropDownClassNames = useMemo(() => {\n\t\treturn classNames(\n\t\t\t'wp-block-prc-block-table-of-contents__dropdown__heading',\n\t\t\t{\n\t\t\t\t'has-text-color':\n\t\t\t\t\t!!colors?.dropdownTextColor?.color ||\n\t\t\t\t\t!!colors?.dropdownTextColor?.class,\n\t\t\t\t[`has-${colors?.dropdownTextColor?.slug}-color`]:\n\t\t\t\t\t!!colors?.dropdownTextColor?.slug,\n\t\t\t\t'has-background':\n\t\t\t\t\t!!colors?.dropdownBackgroundColor?.color ||\n\t\t\t\t\t!!colors?.dropdownBackgroundColor?.class,\n\t\t\t\t[`has-${colors?.dropdownBackgroundColor?.slug}-background-color`]:\n\t\t\t\t\t!!colors?.dropdownBackgroundColor?.slug,\n\t\t\t}\n\t\t);\n\t}, [colors]);\n\n\tconst blockPropArgs = useMemo(() => {\n\t\treturn {\n\t\t\tclassName: blockWrapperClassNames,\n\t\t\t'data-auto-dropdown-enabled': autoDropdownEnabled,\n\t\t\t'data-auto-dropdown-width': autoDropdownWidth,\n\t\t\t'data-show-current-chapter': showCurrentChapter,\n\t\t\t'aria-expanded': isDropdownOpen,\n\t\t};\n\t}, [\n\t\tblockWrapperClassNames,\n\t\tautoDropdownEnabled,\n\t\tautoDropdownWidth,\n\t\tshowCurrentChapter,\n\t\tisDropdownOpen,\n\t]);\n\n\tconst blockProps = useBlockProps(blockPropArgs);\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tsetAttributes({ heading: newHeading }),\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tsetAttributes({ heading: newHeading }),\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t setDropdownOpen(!isDropdownOpen)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t+\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t{0 !== chapters.length &&\n\t\t\t\t\t\t\tchapters.map((chapter) => (\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t{chapter?.title}\n\t\t\t\t\t\t\t\t\t{postId === chapter?.id &&\n\t\t\t\t\t\t\t\t\t\tchapter?.internalChapters && (\n\t\t\t\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\t\t\t\t{chapter.internalChapters.map(\n\t\t\t\t\t\t\t\t\t\t\t\t\t(internalChapter) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tinternalChapter.clientId\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tselectBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tinternalChapter.clientId\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tinternalChapter.title\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t
\n\t);\n}\n\nexport default withColors(\n\t{ dropdownBackgroundColor: 'color' },\n\t{ dropdownTextColor: 'color' },\n\t{ headingBackgroundColor: 'color' },\n\t{ headingTextColor: 'color' },\n\t{ activeBackgroundColor: 'color' },\n\t{ activeTextColor: 'color' },\n\t{ hoverBackgroundColor: 'color' },\n\t{ hoverTextColor: 'color' }\n)(Edit);\n","/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecord } from '@wordpress/core-data';\n\n/**\n * Internal Dependencies\n */\n\nfunction useCurrentChapters() {\n\t// This loads the chapters currently in the editor context.\n\tconst { currentChapters = [] } = useSelect(\n\t\t(select) => {\n\t\t\tconst foundChapters = select('core/block-editor').getBlocks().filter(\n\t\t\t\t(block) => 'core/heading' === block.name && block.attributes?.isChapter === true,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcurrentChapters: 0 === foundChapters.length ? [\n\t\t\t\t\t{\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\tcontent: 'Chapter 1...',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\tcontent: 'Chapter 2...',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\tcontent: 'Chapter 3...',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t] : foundChapters,\n\t\t\t};\n\t\t},\n\t\t[],\n\t);\n\treturn currentChapters;\n}\n\nexport default function useTOC( { postId, postType } ) {\n\tconst { record, isResolving } = useEntityRecord( 'postType', postType, postId );\n\n\tconst tableOfContents = useMemo(() => {\n\t\tif (!record || isResolving) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: postId,\n\t\t\t\t\ttitle: 'Chapter 1...',\n\t\t\t\t\tinternalChapters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: 'Chapter 1.1...',\n\t\t\t\t\t\t\tid: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: 'Chapter 1.2...',\n\t\t\t\t\t\t\tid: 2,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: 'Chapter 1.3...',\n\t\t\t\t\t\t\tid: 3,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 2,\n\t\t\t\t\ttitle: 'Chapter 2...',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 3,\n\t\t\t\t\ttitle: 'Chapter 3...',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn record?.table_of_contents;\n\t}, [record, isResolving]);\n\n\tconst currentPostChapters = useCurrentChapters();\n\n\tconst memoizedChapters = useMemo(() => {\n\t\treturn tableOfContents?.map((chapter) => {\n\t\t\tconst internalChapters = postId === chapter?.id ? currentPostChapters.map((chapter) => ({\n\t\t\t\ttitle: chapter.attributes?.content,\n\t\t\t\tid: chapter?.id,\n\t\t\t\tclientId: chapter?.clientId,\n\t\t\t\tlink: chapter?.link,\n\t\t\t})) : chapter?.internal_chapters;\n\n\t\t\treturn {\n\t\t\t\tid: chapter.id,\n\t\t\t\ttitle: chapter?.title,\n\t\t\t\tlink: chapter?.link,\n\t\t\t\tinternalChapters: internalChapters,\n\t\t\t}\n\t\t});\n\t}, [currentPostChapters, tableOfContents]);\n\n\treturn {\n\t\tchapters: memoizedChapters,\n\t};\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"prcIcons\"];","/**\n * WordPress Dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport default [\n\t{\n\t\tname: 'table-of-contents',\n\t\tisDefault: true,\n\t\ttitle: __('Table of Contents (Default)'),\n\t\tdescription: __('The default table of contents block. Displays a list of links to chapters and back-chapters in a post in a \"Baseball Card\" style. On mobile this transforms to a dropdown.'),\n\t\tattributes: { className: 'is-style-default' },\n\t\tscope: ['inserter', 'transform'],\n\t\tisActive: (blockAttributes, variationAttributes) => variationAttributes.className === blockAttributes.className,\n\t},\n\t{\n\t\tname: 'table-of-contents-dropdown',\n\t\tisDefault: true,\n\t\ttitle: __('Table of Contents (Dropdown)'),\n\t\tdescription: __('Displays a list of chapters and back-chapters in a post in a dropdown style.'),\n\t\tattributes: { className: 'is-style-dropdown' },\n\t\tscope: ['inserter', 'transform'],\n\t\tisActive: (blockAttributes, variationAttributes) => variationAttributes.className === blockAttributes.className,\n\t}\n];\n","/**\n * Registers a new block provided a unique name and an object defining its behavior.\n *\n * @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block\n */\n\n/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { registerBlockType, unregisterBlockType } from '@wordpress/blocks';\nimport domReady from '@wordpress/dom-ready';\n\n/**\n * Internal Dependencies\n */\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * All files containing `style` keyword are bundled together. The code used\n * gets applied both to the front of your site and to the editor. All other files\n * get applied to the editor only.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './style.scss';\nimport './editor.scss';\nimport edit from './edit';\nimport icon from './icon';\nimport variations from './variations';\n\nimport metadata from './block.json';\n\nconst { name } = metadata;\n\nconst settings = {\n\ticon,\n\tedit,\n\tvariations,\n};\n\n/**\n * Every block starts by registering a new block type definition.\n *\n * @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block\n */\nregisterBlockType(name, { ...metadata, ...settings });\n\n/**\n * Unregister the core/table-of-contents block, since we are replacing it with our own.\n */\ndomReady(() => {\n\tunregisterBlockType('core/table-of-contents');\n\tunregisterBlockType('yoast-seo/table-of-contents');\n});\n","/**\n * External Dependencies\n */\nimport { icons, Icon } from '@prc/icons';\n\nexport default function() {\n\treturn(\n\t\t\n\t);\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t57: 0,\n\t350: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunktable_of_contents\"] = globalThis[\"webpackChunktable_of_contents\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [350], () => (__webpack_require__(718)))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["deferred","window","ColorControls","attributes","colors","clientId","className","colorProps","useMultipleOriginColorsAndGradients","colorSettings","useMemo","dropdownBackgroundColor","setDropdownBackgroundColor","dropdownTextColor","setDropdownTextColor","headingBackgroundColor","setHeadingBackgroundColor","headingTextColor","setHeadingTextColor","activeBackgroundColor","setActiveBackgroundColor","activeTextColor","setActiveTextColor","hoverBackgroundColor","setHoverBackgroundColor","hoverTextColor","setHoverTextColor","t","colorValue","color","onColorChange","label","__","splice","createElement","InspectorControls","group","ColorGradientSettingsDropdown","settings","panelId","hasColorsOrGradients","disableCustomColors","__experimentalIsRenderedInSidebar","Controls","setAttributes","showCurrentChapter","hideHeading","autoDropdownWidth","autoDropdownEnabled","Fragment","PanelBody","title","ToggleControl","checked","onChange","help","BaseControl","NumberControl","value","shiftStep","withColors","context","isSelected","postId","postType","chapters","record","isResolving","useEntityRecord","tableOfContents","id","internalChapters","table_of_contents","currentPostChapters","currentChapters","useSelect","select","foundChapters","getBlocks","filter","block","name","isChapter","length","content","useCurrentChapters","map","chapter","link","internal_chapters","useTOC","heading","style","selectBlock","useDispatch","isDropdownOpen","setDropdownOpen","useState","isAutoDropdownSwitched","setDropdownSwitch","componentRef","useRef","useEffect","updateAutoDropdownSwitch","current","parentNode","offsetWidth","addEventListener","removeEventListener","blockWrapperClassNames","classNames","headingClassNames","class","slug","dropDownClassNames","blockPropArgs","blockProps","useBlockProps","ref","RichText","tagName","placeholder","newHeading","onClick","getBlockGapSupportValue","key","internalChapter","isDefault","description","scope","isActive","blockAttributes","variationAttributes","metadata","icon","Icon","icons","faListTree","height","preserveAspectRatio","edit","variations","registerBlockType","domReady","unregisterBlockType","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","m","O","result","chunkIds","fn","priority","notFulfilled","Infinity","i","fulfilled","j","Object","keys","every","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","installedChunks","chunkId","webpackJsonpCallback","parentChunkLoadingFunction","data","moreModules","runtime","some","chunkLoadingGlobal","globalThis","forEach","bind","push","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":"uBAAIA,E,iBCAJ,MAAM,EAA+BC,OAAW,GAAU,OCApD,EAA+BA,OAAW,GAAY,S,aCA5D,MAAM,EAA+BA,OAAc,MCA7C,EAA+BA,OAAmB,W,aCAxD,MAAM,EAA+BA,OAAsB,cCArD,EAA+BA,OAAW,GA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vC,EAAUoC,GAHT3B,EAAU+B,EAAaC,GAAWF,EAGhBzB,EAAI,EAC3B,GAAGL,EAASiC,MAAM3H,GAAgC,IAAxBoH,EAAgBpH,KAAa,CACtD,IAAIiF,KAAYwC,EACZzC,EAAoB2B,EAAEc,EAAaxC,KACrCD,EAAoBO,EAAEN,GAAYwC,EAAYxC,IAGhD,GAAGyC,EAAS,IAAIjC,EAASiC,EAAQ1C,EAClC,CAEA,IADGuC,GAA4BA,EAA2BC,GACrDzB,EAAIL,EAASnE,OAAQwE,IACzBsB,EAAU3B,EAASK,GAChBf,EAAoB2B,EAAES,EAAiBC,IAAYD,EAAgBC,IACrED,EAAgBC,GAAS,KAE1BD,EAAgBC,GAAW,EAE5B,OAAOrC,EAAoBQ,EAAEC,EAAO,EAGjCmC,EAAqBC,WAA0C,8BAAIA,WAA0C,+BAAK,GACtHD,EAAmBE,QAAQR,EAAqBS,KAAK,KAAM,IAC3DH,EAAmBI,KAAOV,EAAqBS,KAAK,KAAMH,EAAmBI,KAAKD,KAAKH,G,KC9CvF,IAAIK,EAAsBjD,EAAoBQ,OAAEL,EAAW,CAAC,MAAM,IAAOH,EAAoB,OAC7FiD,EAAsBjD,EAAoBQ,EAAEyC,E","sources":["webpack://table-of-contents/webpack/runtime/chunk loaded","webpack://table-of-contents/external window [\"wp\",\"blocks\"]","webpack://table-of-contents/external window [\"wp\",\"domReady\"]","webpack://table-of-contents/external window \"React\"","webpack://table-of-contents/external window \"classnames\"","webpack://table-of-contents/external window \"prcBlockUtils\"","webpack://table-of-contents/external window [\"wp\",\"blockEditor\"]","webpack://table-of-contents/external window [\"wp\",\"data\"]","webpack://table-of-contents/external window [\"wp\",\"i18n\"]","webpack://table-of-contents/external window [\"wp\",\"element\"]","webpack://table-of-contents/external window [\"wp\",\"components\"]","webpack://table-of-contents/./src/color-controls.jsx","webpack://table-of-contents/./src/controls.jsx","webpack://table-of-contents/external window [\"wp\",\"coreData\"]","webpack://table-of-contents/./src/edit.jsx","webpack://table-of-contents/./src/use-toc.js","webpack://table-of-contents/external window \"prcIcons\"","webpack://table-of-contents/./src/variations.js","webpack://table-of-contents/./src/index.js","webpack://table-of-contents/./src/icon.jsx","webpack://table-of-contents/webpack/bootstrap","webpack://table-of-contents/webpack/runtime/compat get default export","webpack://table-of-contents/webpack/runtime/define property getters","webpack://table-of-contents/webpack/runtime/hasOwnProperty shorthand","webpack://table-of-contents/webpack/runtime/jsonp chunk loading","webpack://table-of-contents/webpack/startup"],"sourcesContent":["var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"blocks\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"domReady\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"React\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"classnames\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"prcBlockUtils\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"blockEditor\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"data\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"i18n\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"element\"];","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"components\"];","/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\tInspectorControls,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\n\nexport default function ColorControls({ attributes, colors, clientId }) {\n\tconst { className } = attributes;\n\n\tconst colorProps = useMultipleOriginColorsAndGradients();\n\n\tconst colorSettings = useMemo(() => {\n\t\tconst {\n\t\t\tdropdownBackgroundColor,\n\t\t\tsetDropdownBackgroundColor,\n\t\t\tdropdownTextColor,\n\t\t\tsetDropdownTextColor,\n\t\t\theadingBackgroundColor,\n\t\t\tsetHeadingBackgroundColor,\n\t\t\theadingTextColor,\n\t\t\tsetHeadingTextColor,\n\t\t\tactiveBackgroundColor,\n\t\t\tsetActiveBackgroundColor,\n\t\t\tactiveTextColor,\n\t\t\tsetActiveTextColor,\n\t\t\thoverBackgroundColor,\n\t\t\tsetHoverBackgroundColor,\n\t\t\thoverTextColor,\n\t\t\tsetHoverTextColor,\n\t\t} = colors;\n\n\t\tconst t = [\n\t\t\t{\n\t\t\t\tcolorValue: dropdownTextColor?.color,\n\t\t\t\tonColorChange: setDropdownTextColor,\n\t\t\t\tlabel: __('(Mobile) Dropdown Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: dropdownBackgroundColor?.color,\n\t\t\t\tonColorChange: setDropdownBackgroundColor,\n\t\t\t\tlabel: __('(Mobile) Dropdown Background'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: headingTextColor?.color,\n\t\t\t\tonColorChange: setHeadingTextColor,\n\t\t\t\tlabel: __('(Desktop) Heading Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: headingBackgroundColor?.color,\n\t\t\t\tonColorChange: setHeadingBackgroundColor,\n\t\t\t\tlabel: __('(Desktop) Heading Background'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: activeTextColor?.color,\n\t\t\t\tonColorChange: setActiveTextColor,\n\t\t\t\tlabel: __('Active Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: activeBackgroundColor?.color,\n\t\t\t\tonColorChange: setActiveBackgroundColor,\n\t\t\t\tlabel: __('Active Background'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: hoverTextColor?.color,\n\t\t\t\tonColorChange: setHoverTextColor,\n\t\t\t\tlabel: __('Hover Text'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tcolorValue: hoverBackgroundColor?.color,\n\t\t\t\tonColorChange: setHoverBackgroundColor,\n\t\t\t\tlabel: __('Hover Background'),\n\t\t\t},\n\t\t];\n\t\tif ('is-style-dropdown' === className) {\n\t\t\t// change the label of the first item to just be \"Dropdown Text\" and the second to just be \"Dropdown Background\", remove the 3rd and 4th items.\n\t\t\tt[0].label = __('Dropdown Text');\n\t\t\tt[1].label = __('Dropdown Background');\n\t\t\tt.splice(2, 2);\n\t\t}\n\t\treturn t;\n\t}, [colors, className]);\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\n}\n","/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\tNotice,\n\tPanelBody,\n\tRangeControl,\n\tBaseControl,\n\tToggleControl,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { InspectorControls } from '@wordpress/block-editor';\n\n/**\n * Internal Dependencies\n */\nimport ColorControls from './color-controls';\n\nexport default function Controls({\n\tattributes,\n\tsetAttributes,\n\tcolors,\n\tclientId,\n}) {\n\tconst {\n\t\tshowCurrentChapter,\n\t\thideHeading,\n\t\tclassName,\n\t\tautoDropdownWidth,\n\t\tautoDropdownEnabled,\n\t} = attributes;\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\tshowCurrentChapter: !showCurrentChapter,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}}\n\t\t\t\t\t\thelp={__(\n\t\t\t\t\t\t\t'Highlight the current chapter in the table of contents when scrolling.',\n\t\t\t\t\t\t\t'prc-block-library'\n\t\t\t\t\t\t)}\n\t\t\t\t\t/>\n\t\t\t\t\t{'is-style-default' === className && (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\thideHeading: !hideHeading,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\thelp={__(\n\t\t\t\t\t\t\t\t\t'Hide the heading from the front end when in \"Baseball Card\" style.',\n\t\t\t\t\t\t\t\t\t'prc-block-library'\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\t\tautoDropdownEnabled:\n\t\t\t\t\t\t\t\t\t\t\t\t!autoDropdownEnabled,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{autoDropdownEnabled && (\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes({\n\t\t\t\t\t\t\t\t\t\t\t\tautoDropdownWidth: value,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tshiftStep={10}\n\t\t\t\t\t\t\t\t\t\tvalue={autoDropdownWidth}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\n\t\t\n\t);\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"coreData\"];","/* eslint-disable max-lines */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/anchor-is-valid */\n/* eslint-disable max-lines-per-function */\n/**\n * External Dependencies\n */\nimport classNames from 'classnames';\nimport { getBlockGapSupportValue } from '@prc/block-utils';\n\n/**\n * WordPress Dependencies\n */\nimport { Fragment, useMemo, useState, useRef, useEffect } from 'react';\nimport {\n\tuseBlockProps,\n\tRichText,\n\twithColors,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal Dependencies\n */\nimport Controls from './controls';\nimport useTOC from './use-toc';\n\nfunction InternalChapters({ internalChapters }) {\n\tconst { selectBlock } = useDispatch('core/block-editor');\n\treturn (\n\t\t
    \n\t\t\t{Object.values(internalChapters).map((internalChapter) => {\n\t\t\t\tconst title =\n\t\t\t\t\tinternalChapter.title?.originalHTML ||\n\t\t\t\t\tinternalChapter.title;\n\t\t\t\treturn (\n\t\t\t\t\t
  • \n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\tif (internalChapter.clientId) {\n\t\t\t\t\t\t\t\t\tselectBlock(internalChapter.clientId);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t\n\t\t\t\t\t
  • \n\t\t\t\t);\n\t\t\t})}\n\t\t
\n\t);\n}\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit\n *\n * @param {Object} props Properties passed to the function.\n * @param {Object} props.attributes Available block attributes.\n * @param props.context\n * @param props.clientId\n * @param props.isSelected\n * @param props.dropdownBackgroundColor\n * @param props.setDropdownBackgroundColor\n * @param props.dropdownTextColor\n * @param props.setDropdownTextColor\n * @param props.headingBackgroundColor\n * @param props.setHeadingBackgroundColor\n * @param props.headingTextColor\n * @param props.setHeadingTextColor\n * @param props.activeBackgroundColor\n * @param props.setActiveBackgroundColor\n * @param props.activeTextColor\n * @param props.setActiveTextColor\n * @param props.hoverBackgroundColor\n * @param props.setHoverBackgroundColor\n * @param props.hoverTextColor\n * @param props.setHoverTextColor\n * @param {Function} props.setAttributes Function that updates individual attributes.\n *\n * @return {WPElement} Element to render.\n */\nfunction Edit({\n\tattributes,\n\tsetAttributes,\n\tcontext,\n\tclientId,\n\tisSelected,\n\tdropdownBackgroundColor,\n\tsetDropdownBackgroundColor,\n\tdropdownTextColor,\n\tsetDropdownTextColor,\n\theadingBackgroundColor,\n\tsetHeadingBackgroundColor,\n\theadingTextColor,\n\tsetHeadingTextColor,\n\tactiveBackgroundColor,\n\tsetActiveBackgroundColor,\n\tactiveTextColor,\n\tsetActiveTextColor,\n\thoverBackgroundColor,\n\tsetHoverBackgroundColor,\n\thoverTextColor,\n\tsetHoverTextColor,\n}) {\n\tconst { postId, postType } = context;\n\tconst { chapters = [] } = useTOC({ postId, postType });\n\tconst {\n\t\theading,\n\t\tshowCurrentChapter,\n\t\tclassName,\n\t\thideHeading,\n\t\tautoDropdownEnabled,\n\t\tautoDropdownWidth,\n\t\tstyle,\n\t} = attributes;\n\tconst [isDropdownOpen, setDropdownOpen] = useState(false);\n\tconst [isAutoDropdownSwitched, setDropdownSwitch] = useState(false);\n\n\t// Add a ref to the component\n\tconst componentRef = useRef(null);\n\n\tuseEffect(() => {\n\t\tif (!autoDropdownEnabled) {\n\t\t\treturn setDropdownSwitch(false);\n\t\t}\n\n\t\tconst updateAutoDropdownSwitch = () => {\n\t\t\tif (componentRef?.current) {\n\t\t\t\tsetDropdownSwitch(\n\t\t\t\t\tcomponentRef?.current.parentNode.parentNode.offsetWidth <=\n\t\t\t\t\t\tautoDropdownWidth\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tupdateAutoDropdownSwitch();\n\n\t\twindow.addEventListener('resize', updateAutoDropdownSwitch); // Add a listener for the window resize event\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener('resize', updateAutoDropdownSwitch); // Remove the listener when the component unmounts\n\t\t};\n\t}, [\n\t\tautoDropdownEnabled,\n\t\tcomponentRef?.current?.parentNode?.parentNode.offsetWidth,\n\t\tcomponentRef?.current?.parentNode?.parentNode,\n\t\tautoDropdownWidth,\n\t]);\n\n\t// Construct a colors object that contains the color values and helper functions, re-compute whenever the color values change.\n\tconst colors = useMemo(\n\t\t() => ({\n\t\t\tdropdownBackgroundColor,\n\t\t\tsetDropdownBackgroundColor,\n\t\t\tdropdownTextColor,\n\t\t\tsetDropdownTextColor,\n\t\t\theadingBackgroundColor,\n\t\t\tsetHeadingBackgroundColor,\n\t\t\theadingTextColor,\n\t\t\tsetHeadingTextColor,\n\t\t\tactiveBackgroundColor,\n\t\t\tsetActiveBackgroundColor,\n\t\t\tactiveTextColor,\n\t\t\tsetActiveTextColor,\n\t\t\thoverBackgroundColor,\n\t\t\tsetHoverBackgroundColor,\n\t\t\thoverTextColor,\n\t\t\tsetHoverTextColor,\n\t\t}),\n\t\t[\n\t\t\tdropdownBackgroundColor,\n\t\t\tsetDropdownBackgroundColor,\n\t\t\tdropdownTextColor,\n\t\t\tsetDropdownTextColor,\n\t\t\theadingBackgroundColor,\n\t\t\tsetHeadingBackgroundColor,\n\t\t\theadingTextColor,\n\t\t\tsetHeadingTextColor,\n\t\t\tactiveBackgroundColor,\n\t\t\tsetActiveBackgroundColor,\n\t\t\tactiveTextColor,\n\t\t\tsetActiveTextColor,\n\t\t\thoverBackgroundColor,\n\t\t\tsetHoverBackgroundColor,\n\t\t\thoverTextColor,\n\t\t\tsetHoverTextColor,\n\t\t]\n\t);\n\n\tconst blockWrapperClassNames = useMemo(() => {\n\t\treturn classNames(className, 'common-block-style--baseball-card', {\n\t\t\t'is-switched': isAutoDropdownSwitched,\n\t\t});\n\t}, [isAutoDropdownSwitched, className]);\n\n\tconst headingClassNames = useMemo(() => {\n\t\treturn classNames('wp-block-prc-block-table-of-contents__heading', {\n\t\t\t'has-text-color':\n\t\t\t\t!!colors?.headingTextColor?.color ||\n\t\t\t\t!!colors?.headingTextColor?.class,\n\t\t\t[`has-${colors?.headingTextColor?.slug}-color`]:\n\t\t\t\t!!colors?.headingTextColor?.slug,\n\t\t\t'has-background':\n\t\t\t\t!!colors?.headingBackgroundColor?.color ||\n\t\t\t\t!!colors?.headingBackgroundColor?.class,\n\t\t\t[`has-${colors?.headingBackgroundColor?.slug}-background-color`]:\n\t\t\t\t!!colors?.headingBackgroundColor?.slug,\n\t\t\t'is-hidden': hideHeading,\n\t\t});\n\t}, [colors, hideHeading]);\n\n\tconst dropDownClassNames = useMemo(() => {\n\t\treturn classNames(\n\t\t\t'wp-block-prc-block-table-of-contents__dropdown__heading',\n\t\t\t{\n\t\t\t\t'has-text-color':\n\t\t\t\t\t!!colors?.dropdownTextColor?.color ||\n\t\t\t\t\t!!colors?.dropdownTextColor?.class,\n\t\t\t\t[`has-${colors?.dropdownTextColor?.slug}-color`]:\n\t\t\t\t\t!!colors?.dropdownTextColor?.slug,\n\t\t\t\t'has-background':\n\t\t\t\t\t!!colors?.dropdownBackgroundColor?.color ||\n\t\t\t\t\t!!colors?.dropdownBackgroundColor?.class,\n\t\t\t\t[`has-${colors?.dropdownBackgroundColor?.slug}-background-color`]:\n\t\t\t\t\t!!colors?.dropdownBackgroundColor?.slug,\n\t\t\t}\n\t\t);\n\t}, [colors]);\n\n\tconst blockPropArgs = useMemo(() => {\n\t\treturn {\n\t\t\tclassName: blockWrapperClassNames,\n\t\t\t'data-auto-dropdown-enabled': autoDropdownEnabled,\n\t\t\t'data-auto-dropdown-width': autoDropdownWidth,\n\t\t\t'data-show-current-chapter': showCurrentChapter,\n\t\t\t'aria-expanded': isDropdownOpen,\n\t\t};\n\t}, [\n\t\tblockWrapperClassNames,\n\t\tautoDropdownEnabled,\n\t\tautoDropdownWidth,\n\t\tshowCurrentChapter,\n\t\tisDropdownOpen,\n\t]);\n\n\tconst blockProps = useBlockProps(blockPropArgs);\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tsetAttributes({ heading: newHeading }),\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tsetAttributes({ heading: newHeading }),\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t setDropdownOpen(!isDropdownOpen)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t+\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t{0 !== chapters.length &&\n\t\t\t\t\t\t\tchapters.map((chapter) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t{chapter.title}\n\t\t\t\t\t\t\t\t\t\t{postId === chapter.id &&\n\t\t\t\t\t\t\t\t\t\t\tchapter?.internalChapters && (\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t
\n\t);\n}\n\nexport default withColors(\n\t{ dropdownBackgroundColor: 'color' },\n\t{ dropdownTextColor: 'color' },\n\t{ headingBackgroundColor: 'color' },\n\t{ headingTextColor: 'color' },\n\t{ activeBackgroundColor: 'color' },\n\t{ activeTextColor: 'color' },\n\t{ hoverBackgroundColor: 'color' },\n\t{ hoverTextColor: 'color' }\n)(Edit);\n","/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecord } from '@wordpress/core-data';\n\n/**\n * Internal Dependencies\n */\n\nfunction useCurrentChapters() {\n\t// This loads the chapters currently in the editor context.\n\tconst { currentChapters = [] } = useSelect(\n\t\t(select) => {\n\t\t\tconst foundChapters = select('core/block-editor').getBlocks().filter(\n\t\t\t\t(block) => 'core/heading' === block.name && block.attributes?.isChapter === true,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcurrentChapters: 0 === foundChapters.length ? [\n\t\t\t\t\t{\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\tcontent: 'Chapter 1...',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\tcontent: 'Chapter 2...',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\tcontent: 'Chapter 3...',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t] : foundChapters,\n\t\t\t};\n\t\t},\n\t\t[],\n\t);\n\treturn currentChapters;\n}\n\nexport default function useTOC( { postId, postType } ) {\n\tconst { record, isResolving } = useEntityRecord( 'postType', postType, postId );\n\n\tconst tableOfContents = useMemo(() => {\n\t\tif (!record || isResolving) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: postId,\n\t\t\t\t\ttitle: 'Chapter 1...',\n\t\t\t\t\tinternalChapters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: 'Chapter 1.1...',\n\t\t\t\t\t\t\tid: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: 'Chapter 1.2...',\n\t\t\t\t\t\t\tid: 2,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: 'Chapter 1.3...',\n\t\t\t\t\t\t\tid: 3,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 2,\n\t\t\t\t\ttitle: 'Chapter 2...',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 3,\n\t\t\t\t\ttitle: 'Chapter 3...',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn record?.table_of_contents;\n\t}, [record, isResolving]);\n\n\tconst currentPostChapters = useCurrentChapters();\n\n\tconst memoizedChapters = useMemo(() => {\n\t\treturn tableOfContents?.map((chapter) => {\n\t\t\tconst internalChapters = postId === chapter?.id ? currentPostChapters.map((chapter) => ({\n\t\t\t\ttitle: chapter.attributes?.content,\n\t\t\t\tid: chapter?.id,\n\t\t\t\tclientId: chapter?.clientId,\n\t\t\t\tlink: chapter?.link,\n\t\t\t})) : chapter?.internal_chapters;\n\n\t\t\treturn {\n\t\t\t\tid: chapter.id,\n\t\t\t\ttitle: chapter?.title,\n\t\t\t\tlink: chapter?.link,\n\t\t\t\tinternalChapters: internalChapters,\n\t\t\t}\n\t\t});\n\t}, [currentPostChapters, tableOfContents]);\n\n\treturn {\n\t\tchapters: memoizedChapters,\n\t};\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"prcIcons\"];","/**\n * WordPress Dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport default [\n\t{\n\t\tname: 'table-of-contents',\n\t\tisDefault: true,\n\t\ttitle: __('Table of Contents (Default)'),\n\t\tdescription: __('The default table of contents block. Displays a list of links to chapters and back-chapters in a post in a \"Baseball Card\" style. On mobile this transforms to a dropdown.'),\n\t\tattributes: { className: 'is-style-default' },\n\t\tscope: ['inserter', 'transform'],\n\t\tisActive: (blockAttributes, variationAttributes) => variationAttributes.className === blockAttributes.className,\n\t},\n\t{\n\t\tname: 'table-of-contents-dropdown',\n\t\tisDefault: true,\n\t\ttitle: __('Table of Contents (Dropdown)'),\n\t\tdescription: __('Displays a list of chapters and back-chapters in a post in a dropdown style.'),\n\t\tattributes: { className: 'is-style-dropdown' },\n\t\tscope: ['inserter', 'transform'],\n\t\tisActive: (blockAttributes, variationAttributes) => variationAttributes.className === blockAttributes.className,\n\t}\n];\n","/**\n * Registers a new block provided a unique name and an object defining its behavior.\n *\n * @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block\n */\n\n/**\n * External Dependencies\n */\n\n/**\n * WordPress Dependencies\n */\nimport { registerBlockType, unregisterBlockType } from '@wordpress/blocks';\nimport domReady from '@wordpress/dom-ready';\n\n/**\n * Internal Dependencies\n */\n\n/**\n * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.\n * All files containing `style` keyword are bundled together. The code used\n * gets applied both to the front of your site and to the editor. All other files\n * get applied to the editor only.\n *\n * @see https://www.npmjs.com/package/@wordpress/scripts#using-css\n */\nimport './style.scss';\nimport './editor.scss';\nimport edit from './edit';\nimport icon from './icon';\nimport variations from './variations';\n\nimport metadata from './block.json';\n\nconst { name } = metadata;\n\nconst settings = {\n\ticon,\n\tedit,\n\tvariations,\n};\n\n/**\n * Every block starts by registering a new block type definition.\n *\n * @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block\n */\nregisterBlockType(name, { ...metadata, ...settings });\n\n/**\n * Unregister the core/table-of-contents block, since we are replacing it with our own.\n */\ndomReady(() => {\n\tunregisterBlockType('core/table-of-contents');\n\tunregisterBlockType('yoast-seo/table-of-contents');\n});\n","/**\n * External Dependencies\n */\nimport { icons, Icon } from '@prc/icons';\n\nexport default function() {\n\treturn(\n\t\t\n\t);\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t57: 0,\n\t350: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunktable_of_contents\"] = globalThis[\"webpackChunktable_of_contents\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [350], () => (__webpack_require__(718)))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["deferred","window","ColorControls","attributes","colors","clientId","className","colorProps","useMultipleOriginColorsAndGradients","colorSettings","useMemo","dropdownBackgroundColor","setDropdownBackgroundColor","dropdownTextColor","setDropdownTextColor","headingBackgroundColor","setHeadingBackgroundColor","headingTextColor","setHeadingTextColor","activeBackgroundColor","setActiveBackgroundColor","activeTextColor","setActiveTextColor","hoverBackgroundColor","setHoverBackgroundColor","hoverTextColor","setHoverTextColor","t","colorValue","color","onColorChange","label","__","splice","createElement","InspectorControls","group","ColorGradientSettingsDropdown","settings","panelId","hasColorsOrGradients","disableCustomColors","__experimentalIsRenderedInSidebar","Controls","setAttributes","showCurrentChapter","hideHeading","autoDropdownWidth","autoDropdownEnabled","Fragment","PanelBody","title","ToggleControl","checked","onChange","help","BaseControl","NumberControl","value","shiftStep","InternalChapters","internalChapters","selectBlock","useDispatch","Object","values","map","internalChapter","originalHTML","key","id","onClick","withColors","context","isSelected","postId","postType","chapters","record","isResolving","useEntityRecord","tableOfContents","table_of_contents","currentPostChapters","currentChapters","useSelect","select","foundChapters","getBlocks","filter","block","name","isChapter","length","content","useCurrentChapters","chapter","link","internal_chapters","useTOC","heading","style","isDropdownOpen","setDropdownOpen","useState","isAutoDropdownSwitched","setDropdownSwitch","componentRef","useRef","useEffect","updateAutoDropdownSwitch","current","parentNode","offsetWidth","addEventListener","removeEventListener","blockWrapperClassNames","classNames","headingClassNames","class","slug","dropDownClassNames","blockPropArgs","blockProps","useBlockProps","ref","RichText","tagName","placeholder","newHeading","getBlockGapSupportValue","isDefault","description","scope","isActive","blockAttributes","variationAttributes","metadata","icon","Icon","icons","faListTree","height","preserveAspectRatio","edit","variations","registerBlockType","domReady","unregisterBlockType","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","m","O","result","chunkIds","fn","priority","notFulfilled","Infinity","i","fulfilled","j","keys","every","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","installedChunks","chunkId","webpackJsonpCallback","parentChunkLoadingFunction","data","moreModules","runtime","some","chunkLoadingGlobal","globalThis","forEach","bind","push","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/table-of-contents/build/style-index.css.map b/blocks/table-of-contents/build/style-index.css.map new file mode 100644 index 000000000..07f210681 --- /dev/null +++ b/blocks/table-of-contents/build/style-index.css.map @@ -0,0 +1 @@ +{"version":3,"file":"./style-index.css","mappings":";;;AAAA;EACC;AACD;AAGE;EACC;AADH;AAGE;EACC;AADH;AAME;EACC;EACA;EACA;UAAA;EACA;EACA;AAJH;;AAWC;;EACC;AAPF;AAUC;;EACC;EACA;AAPF;AAUC;;EACC;AAPF;AAUC;;;EAEC;AAPF;AASC;;EACC;AANF,C","sources":["webpack://table-of-contents/./src/style.scss"],"sourcesContent":[".wp-block-prc-block-table-of-contents {\n\tmargin-top: 24px;\n\n\t&:not(.is-style-dropdown):not(.is-switched),\n\t&[data-auto-dropdown-enabled=\"false\"] {\n\t\t.wp-block-prc-block-table-of-contents__heading.is-hidden {\n\t\t\tdisplay: none;\n\t\t}\n\t\t.wp-block-prc-block-table-of-contents__dropdown__heading {\n\t\t\tdisplay: none;\n\t\t}\n\t}\n\n\t.wp-block-prc-block-table-of-contents__dropdown__heading {\n\t\t.wp-block-prc-block-table-of-contents__dropdown-trigger {\n\t\t\tcursor: pointer;\n\t\t\tbackground: none;\n\t\t\tappearance: none;\n\t\t\tbox-shadow: none;\n\t\t\tborder: none;\n\t\t}\n\t}\n}\n\n.wp-block-prc-block-table-of-contents.is-style-dropdown,\n.wp-block-prc-block-table-of-contents[data-auto-dropdown-enabled=\"true\"].is-switched {\n\t.wp-block-prc-block-table-of-contents__heading {\n\t\tdisplay: none;\n\t}\n\n\t& > .wp-block-prc-block-table-of-contents__list {\n\t\theight: 100vh;\n\t\toverflow-y: auto;\n\t}\n\n\t.wp-block-prc-block-table-of-contents__list {\n\t\tmargin-top: 0;\n\t}\n\n\t&[aria-expanded] .wp-block-prc-block-table-of-contents__list,\n\t&[aria-expanded=\"false\"] .wp-block-prc-block-table-of-contents__list {\n\t\tdisplay: none;\n\t}\n\t&[aria-expanded=\"true\"] .wp-block-prc-block-table-of-contents__list {\n\t\tdisplay: block;\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/table-of-contents/build/view.asset.php b/blocks/table-of-contents/build/view.asset.php index b6e8b2f7b..10ae39972 100644 --- a/blocks/table-of-contents/build/view.asset.php +++ b/blocks/table-of-contents/build/view.asset.php @@ -1 +1 @@ - array('@wordpress/interactivity', 'wp-polyfill'), 'version' => '0546a0d95d4ff4a902b7', 'type' => 'module'); + array('@wordpress/interactivity', 'wp-polyfill'), 'version' => '98f81adb1630c9745c08', 'type' => 'module'); diff --git a/blocks/table-of-contents/build/view.js b/blocks/table-of-contents/build/view.js index a75e7fa4a..7f4b9a786 100644 --- a/blocks/table-of-contents/build/view.js +++ b/blocks/table-of-contents/build/view.js @@ -1,2 +1,2 @@ -import*as t from"@wordpress/interactivity";var e={d:(t,o)=>{for(var l in o)e.o(o,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:o[l]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const o=(n={getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store},r={},e.d(r,n),r),{actions:l}=(0,o.store)("prc-block/table-of-contents",{actions:{getInternalChaptersList:()=>{const{ref:t}=(0,o.getElement)();return t.querySelector(".wp-block-prc-block-table-of-contents__list .is-top-level")?t.querySelector(".wp-block-prc-block-table-of-contents__list"):t.querySelector(".wp-block-prc-block-table-of-contents__list .wp-block-prc-block-table-of-contents__list")},initSmoothScrollClickHandler:()=>{l.getInternalChaptersList().querySelectorAll("a").forEach((t=>{t.addEventListener("click",(e=>{const o=t.getAttribute("href");if(0===o.indexOf("#")){e.preventDefault();const t=document.getElementById(o.replace("#",""));t&&(console.log("target",t),t.scrollIntoView({behavior:"smooth"},!0),window.history.pushState(null,null,o))}}))}))},onDropdownClick:t=>{t.preventDefault();const e=(0,o.getContext)();console.log("onDropdownClick",e,t),e.isDropdownOpen=!e.isDropdownOpen}},callbacks:{onInit:()=>{l.initSmoothScrollClickHandler()}}});var n,r; +import*as t from"@wordpress/interactivity";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const o=(l={getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store},c={},e.d(c,l),c),{actions:n,state:r}=(0,o.store)("prc-block/table-of-contents",{state:{*isListItemActive(){const t=(0,o.getElement)(),e=t?.["data-ref-value"]?.replace("#","");return console.log("isListItemActive",t,r,r.currentChapter,e),e===r.currentChapter}},actions:{getInternalChaptersList:()=>{const{ref:t}=(0,o.getElement)();return t.querySelector(".wp-block-prc-block-table-of-contents__list .is-top-level")?t.querySelector(".wp-block-prc-block-table-of-contents__list"):t.querySelector(".wp-block-prc-block-table-of-contents__list .wp-block-prc-block-table-of-contents__list")},initSmoothScrollClickHandler:()=>{n.getInternalChaptersList().querySelectorAll("a").forEach((t=>{t.addEventListener("click",(e=>{const o=t.getAttribute("href");if(0===o.indexOf("#")){e.preventDefault();const t=document.getElementById(o.replace("#",""));t&&(console.log("target",t),t.scrollIntoView({behavior:"smooth"},!0),window.history.pushState(null,null,o))}}))}))},onDropdownClick:t=>{t.preventDefault();const e=(0,o.getContext)(),{isDropdown:n,isDropdownOpen:r}=e;console.log("onDropdownClick",e,t),e.isDropdownOpen=!e.isDropdownOpen}},callbacks:{onInit:()=>{const t=(0,o.getContext)(),{ref:e}=(0,o.getElement)();n.initSmoothScrollClickHandler(),console.log("onInit",e,t,r);const{showCurrentChapter:l}=t;if(!0===l){const{postId:t}=r,e=r.chapters.find((e=>e.id===t))||{},o=e?.internal_chapters||[];r.enableWatchForChapterScroll=!0,r.chaptersWatchList=o}},onResize:()=>{const t=(0,o.getContext)(),{autoDropdownEnabled:e,autoDropdownWidth:n}=t;if(!e)return;const{ref:l}=(0,o.getElement)(),c=l.offsetWidth;console.log("onResize",l,c,t,r),t.isDropdown=!!(c{if(!r.enableWatchForChapterScroll)return;const{ref:t}=(0,o.getElement)(),e=r.chaptersWatchList,n=window.scrollY;let l=null,c=!1;const s=e.findIndex((e=>e.id===t?.id));s0&&(l=t?.id),l!==r.currentChapter&&(r.currentChapter=l),console.log("scroll::",t?.id,i,p)}}});var l,c; //# sourceMappingURL=view.js.map \ No newline at end of file diff --git a/blocks/table-of-contents/build/view.js.map b/blocks/table-of-contents/build/view.js.map index 715f018c7..9073aa325 100644 --- a/blocks/table-of-contents/build/view.js.map +++ b/blocks/table-of-contents/build/view.js.map @@ -1 +1 @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,IAACV,EACJE","sources":["webpack://table-of-contents/webpack/bootstrap","webpack://table-of-contents/webpack/runtime/define property getters","webpack://table-of-contents/webpack/runtime/hasOwnProperty shorthand","webpack://table-of-contents/external module \"@wordpress/interactivity\"","webpack://table-of-contents/./src/view.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var x = (y) => {\n\tvar x = {}; __webpack_require__.d(x, y); return x\n} \nvar y = (x) => (() => (x))\nconst __WEBPACK_NAMESPACE_OBJECT__ = x({ [\"getContext\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), [\"getElement\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), [\"store\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });","/**\n * WordPress Dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nconst { actions } = store('prc-block/table-of-contents', {\n\tactions: {\n\t\tgetInternalChaptersList: () => {\n\t\t\tconst { ref } = getElement();\n\t\t\t// check if the first level of the list has list-items with is-top-level class\n\t\t\t// if so, return the first level of the list\n\t\t\tif (\n\t\t\t\tref.querySelector(\n\t\t\t\t\t'.wp-block-prc-block-table-of-contents__list .is-top-level'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn ref.querySelector(\n\t\t\t\t\t'.wp-block-prc-block-table-of-contents__list'\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn ref.querySelector(\n\t\t\t\t'.wp-block-prc-block-table-of-contents__list .wp-block-prc-block-table-of-contents__list'\n\t\t\t);\n\t\t},\n\t\tinitSmoothScrollClickHandler: () => {\n\t\t\tconst internalChaptersList = actions.getInternalChaptersList();\n\t\t\tconst links = internalChaptersList.querySelectorAll('a');\n\t\t\tlinks.forEach((link) => {\n\t\t\t\tlink.addEventListener('click', (e) => {\n\t\t\t\t\tconst href = link.getAttribute('href');\n\t\t\t\t\t// If the link is a hash link, we need to smooth scroll to the hash.\n\t\t\t\t\tif (0 === href.indexOf('#')) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tconst target = document.getElementById(\n\t\t\t\t\t\t\thref.replace('#', '')\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (target) {\n\t\t\t\t\t\t\tconsole.log('target', target);\n\t\t\t\t\t\t\ttarget.scrollIntoView({ behavior: 'smooth' }, true);\n\t\t\t\t\t\t\t// Add the hash to the end of the URL.\n\t\t\t\t\t\t\twindow.history.pushState(null, null, href);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\t\tonDropdownClick: (event) => {\n\t\t\tevent.preventDefault();\n\t\t\tconst context = getContext();\n\t\t\tconsole.log('onDropdownClick', context, event);\n\t\t\tcontext.isDropdownOpen = !context.isDropdownOpen;\n\t\t},\n\t},\n\tcallbacks: {\n\t\tonInit: () => {\n\t\t\tactions.initSmoothScrollClickHandler();\n\t\t},\n\t},\n});\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","y","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","x","d","actions","store","getInternalChaptersList","ref","getElement","querySelector","initSmoothScrollClickHandler","querySelectorAll","forEach","link","addEventListener","e","href","getAttribute","indexOf","preventDefault","target","document","getElementById","replace","console","log","scrollIntoView","behavior","window","history","pushState","onDropdownClick","event","context","getContext","isDropdownOpen","callbacks","onInit"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"view.js","mappings":"2CACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC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E,EAAsBD,EAAsBT,EAE9CM,EAAW,GAAKI,EAAsB,IACzCzD,EAAiBE,GAAKN,IAGnBI,IAAmBT,EAAMS,iBAC5BT,EAAMS,eAAiBA,GAGxBF,QAAQC,IAAI,WAAYG,GAAKN,GAAIyD,EAAUI,EAAoB,KD/I1D,IAACvE,EACJE","sources":["webpack://table-of-contents/webpack/bootstrap","webpack://table-of-contents/webpack/runtime/define property getters","webpack://table-of-contents/webpack/runtime/hasOwnProperty shorthand","webpack://table-of-contents/external module \"@wordpress/interactivity\"","webpack://table-of-contents/./src/view.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var x = (y) => {\n\tvar x = {}; __webpack_require__.d(x, y); return x\n} \nvar y = (x) => (() => (x))\nconst __WEBPACK_NAMESPACE_OBJECT__ = x({ [\"getContext\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), [\"getElement\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), [\"store\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });","/**\n * WordPress Dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nconst { actions, state } = store('prc-block/table-of-contents', {\n\tstate: {\n\t\t*isListItemActive() {\n\t\t\tconst elm = getElement();\n\t\t\t// set const id to elm.data-ref-value but remove the # from the beginning\n\t\t\tconst id = elm?.['data-ref-value']?.replace('#', '');\n\t\t\tconsole.log('isListItemActive', elm, state, state.currentChapter, id);\n\n\t\t\tif (id === state.currentChapter) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t},\n\tactions: {\n\t\tgetInternalChaptersList: () => {\n\t\t\tconst { ref } = getElement();\n\t\t\t// check if the first level of the list has list-items with is-top-level class\n\t\t\t// if so, return the first level of the list\n\t\t\tif (\n\t\t\t\tref.querySelector(\n\t\t\t\t\t'.wp-block-prc-block-table-of-contents__list .is-top-level'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn ref.querySelector(\n\t\t\t\t\t'.wp-block-prc-block-table-of-contents__list'\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn ref.querySelector(\n\t\t\t\t'.wp-block-prc-block-table-of-contents__list .wp-block-prc-block-table-of-contents__list'\n\t\t\t);\n\t\t},\n\t\tinitSmoothScrollClickHandler: () => {\n\t\t\tconst internalChaptersList = actions.getInternalChaptersList();\n\t\t\tconst links = internalChaptersList.querySelectorAll('a');\n\t\t\tlinks.forEach((link) => {\n\t\t\t\tlink.addEventListener('click', (e) => {\n\t\t\t\t\tconst href = link.getAttribute('href');\n\t\t\t\t\t// If the link is a hash link, we need to smooth scroll to the hash.\n\t\t\t\t\tif (0 === href.indexOf('#')) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tconst target = document.getElementById(\n\t\t\t\t\t\t\thref.replace('#', '')\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (target) {\n\t\t\t\t\t\t\tconsole.log('target', target);\n\t\t\t\t\t\t\ttarget.scrollIntoView({ behavior: 'smooth' }, true);\n\t\t\t\t\t\t\t// Add the hash to the end of the URL.\n\t\t\t\t\t\t\twindow.history.pushState(null, null, href);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\t\tonDropdownClick: (event) => {\n\t\t\tevent.preventDefault();\n\t\t\tconst context = getContext();\n\t\t\tconst { isDropdown, isDropdownOpen } = context;\n\t\t\tconsole.log('onDropdownClick', context, event);\n\t\t\tcontext.isDropdownOpen = !context.isDropdownOpen;\n\t\t},\n\t},\n\tcallbacks: {\n\t\tonInit: () => {\n\t\t\tconst context = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tactions.initSmoothScrollClickHandler();\n\t\t\tconsole.log('onInit', ref, context, state);\n\t\t\t// So long as there is one TOC block that has this enabled we will enable the watch for chapter scroll function.\n\t\t\tconst { showCurrentChapter } = context;\n\t\t\tif (true === showCurrentChapter) {\n\t\t\t\tconst { postId } = state;\n\t\t\t\t// get the object our of state.chapters with the same id as the postId\n\t\t\t\tconst thisChapter =\n\t\t\t\t\tstate.chapters.find((chapter) => chapter.id === postId) ||\n\t\t\t\t\t{};\n\t\t\t\tconst internalChapters = thisChapter?.internal_chapters || [];\n\n\t\t\t\tstate.enableWatchForChapterScroll = true;\n\t\t\t\tstate.chaptersWatchList = internalChapters;\n\t\t\t}\n\t\t},\n\t\tonResize: () => {\n\t\t\tconst context = getContext();\n\t\t\tconst { autoDropdownEnabled, autoDropdownWidth } = context;\n\t\t\tif (!autoDropdownEnabled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { ref } = getElement();\n\t\t\t// get the width of the ref\n\t\t\tconst width = ref.offsetWidth;\n\t\t\tconsole.log('onResize', ref, width, context, state);\n\t\t\t// if the width is less than the autoDropdownWidth and autoDropdownEnabled is true\n\t\t\t// set isDropdown to true\n\t\t\tif (width < autoDropdownWidth && autoDropdownEnabled) {\n\t\t\t\tcontext.isDropdown = true;\n\t\t\t} else {\n\t\t\t\tcontext.isDropdown = false;\n\t\t\t}\n\t\t},\n\t\twatchForChapterScroll: () => {\n\t\t\tif (!state.enableWatchForChapterScroll) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { ref } = getElement();\n\t\t\t// get the internal chapters list\n\t\t\tconst internalChaptersList = state.chaptersWatchList;\n\t\t\t// get the current scroll position\n\t\t\tconst scrollPosition = window.scrollY;\n\t\t\t// get the current chapter\n\t\t\tlet currentChapter = null;\n\t\t\t// loop through the internal chapters list\n\n\t\t\tlet nextChapter = false;\n\t\t\t// get the current chapter position in the internalChaptersList by id\n\t\t\tconst currentChapterIndex = internalChaptersList.findIndex(\n\t\t\t\t(chapter) => chapter.id === ref?.id\n\t\t\t);\n\t\t\tif (currentChapterIndex < internalChaptersList.length - 1) {\n\t\t\t\tnextChapter = internalChaptersList[currentChapterIndex + 1];\n\t\t\t}\n\n\t\t\tconst chapterPosition = ref.getBoundingClientRect().top;\n\t\t\tconst distance = chapterPosition - scrollPosition;\n\t\t\tconst nextChapterPosition = document\n\t\t\t\t.getElementById(nextChapter?.id)\n\t\t\t\t?.getBoundingClientRect().top;\n\t\t\tconst nextChapterDistance = nextChapterPosition - scrollPosition;\n\n\t\t\tif (distance < 0 && nextChapterDistance > 0) {\n\t\t\t\tcurrentChapter = ref?.id;\n\t\t\t}\n\n\t\t\tif (currentChapter !== state.currentChapter) {\n\t\t\t\tstate.currentChapter = currentChapter;\n\t\t\t}\n\n\t\t\tconsole.log('scroll::', ref?.id, distance, nextChapterDistance);\n\t\t},\n\t},\n});\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","y","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","x","d","actions","state","store","isListItemActive","elm","getElement","id","replace","console","log","currentChapter","getInternalChaptersList","ref","querySelector","initSmoothScrollClickHandler","querySelectorAll","forEach","link","addEventListener","e","href","getAttribute","indexOf","preventDefault","target","document","getElementById","scrollIntoView","behavior","window","history","pushState","onDropdownClick","event","context","getContext","isDropdown","isDropdownOpen","callbacks","onInit","showCurrentChapter","postId","thisChapter","chapters","find","chapter","internalChapters","internal_chapters","enableWatchForChapterScroll","chaptersWatchList","onResize","autoDropdownEnabled","autoDropdownWidth","width","offsetWidth","watchForChapterScroll","internalChaptersList","scrollPosition","scrollY","nextChapter","currentChapterIndex","findIndex","length","distance","getBoundingClientRect","top","nextChapterPosition","nextChapterDistance"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/table-of-contents/package.json b/blocks/table-of-contents/package.json index 415c21399..18d458426 100644 --- a/blocks/table-of-contents/package.json +++ b/blocks/table-of-contents/package.json @@ -7,13 +7,14 @@ "homepage": "https://github.com/pewresearch/pewresearch-org/blob/main/plugins/prc-block-library/blocks/", "main": "build/index.js", "scripts": { - "build": "wp-scripts build --webpack-copy-php --experimental-modules", + "build": "wp-scripts build --experimental-modules", "format": "wp-scripts format", "lint:css": "wp-scripts lint-style", "lint:js": "wp-scripts lint-js", "packages-update": "wp-scripts packages-update", "plugin-zip": "wp-scripts plugin-zip", - "start": "wp-scripts start --webpack-copy-php --experimental-modules" + "start": "wp-scripts start --experimental-modules", + "watch": "wp-scripts start --experimental-modules" }, "devDependencies": { "@wordpress/scripts": "^27.2.0" diff --git a/blocks/table-of-contents/src/edit.jsx b/blocks/table-of-contents/src/edit.jsx index 1369040f6..d519f574c 100644 --- a/blocks/table-of-contents/src/edit.jsx +++ b/blocks/table-of-contents/src/edit.jsx @@ -12,13 +12,7 @@ import { getBlockGapSupportValue } from '@prc/block-utils'; /** * WordPress Dependencies */ -import { - Fragment, - useMemo, - useState, - useRef, - useEffect, -} from 'react'; +import { Fragment, useMemo, useState, useRef, useEffect } from 'react'; import { useBlockProps, RichText, @@ -33,6 +27,32 @@ import { useDispatch } from '@wordpress/data'; import Controls from './controls'; import useTOC from './use-toc'; +function InternalChapters({ internalChapters }) { + const { selectBlock } = useDispatch('core/block-editor'); + return ( + + ); +} + /** * The edit function describes the structure of your block in the context of the * editor. This represents what the editor will render when the block is used. @@ -98,9 +118,8 @@ function Edit({ autoDropdownWidth, style, } = attributes; - const { selectBlock } = useDispatch('core/block-editor'); const [isDropdownOpen, setDropdownOpen] = useState(false); - const [isAutoDropdownSwitched, setDropdownSwitch] = useState(null); + const [isAutoDropdownSwitched, setDropdownSwitch] = useState(false); // Add a ref to the component const componentRef = useRef(null); @@ -278,90 +297,84 @@ function Edit({ }} > {0 !== chapters.length && - chapters.map((chapter) => ( -
  • - {chapter?.title} - {postId === chapter?.id && - chapter?.internalChapters && ( - + chapters.map((chapter) => { + return ( +
  • - ))} + > + {chapter.title} + {postId === chapter.id && + chapter?.internalChapters && ( + + )} +
  • + ); + })} diff --git a/blocks/table-of-contents/src/view.js b/blocks/table-of-contents/src/view.js index b1226ce70..2a5e79cfd 100644 --- a/blocks/table-of-contents/src/view.js +++ b/blocks/table-of-contents/src/view.js @@ -3,7 +3,21 @@ */ import { store, getContext, getElement } from '@wordpress/interactivity'; -const { actions } = store('prc-block/table-of-contents', { +const { actions, state } = store('prc-block/table-of-contents', { + state: { + *isListItemActive() { + const elm = getElement(); + // set const id to elm.data-ref-value but remove the # from the beginning + const id = elm?.['data-ref-value']?.replace('#', ''); + console.log('isListItemActive', elm, state, state.currentChapter, id); + + if (id === state.currentChapter) { + return true; + } + + return false; + }, + }, actions: { getInternalChaptersList: () => { const { ref } = getElement(); @@ -47,13 +61,87 @@ const { actions } = store('prc-block/table-of-contents', { onDropdownClick: (event) => { event.preventDefault(); const context = getContext(); + const { isDropdown, isDropdownOpen } = context; console.log('onDropdownClick', context, event); context.isDropdownOpen = !context.isDropdownOpen; }, }, callbacks: { onInit: () => { + const context = getContext(); + const { ref } = getElement(); actions.initSmoothScrollClickHandler(); + console.log('onInit', ref, context, state); + // So long as there is one TOC block that has this enabled we will enable the watch for chapter scroll function. + const { showCurrentChapter } = context; + if (true === showCurrentChapter) { + const { postId } = state; + // get the object our of state.chapters with the same id as the postId + const thisChapter = + state.chapters.find((chapter) => chapter.id === postId) || + {}; + const internalChapters = thisChapter?.internal_chapters || []; + + state.enableWatchForChapterScroll = true; + state.chaptersWatchList = internalChapters; + } + }, + onResize: () => { + const context = getContext(); + const { autoDropdownEnabled, autoDropdownWidth } = context; + if (!autoDropdownEnabled) { + return; + } + const { ref } = getElement(); + // get the width of the ref + const width = ref.offsetWidth; + console.log('onResize', ref, width, context, state); + // if the width is less than the autoDropdownWidth and autoDropdownEnabled is true + // set isDropdown to true + if (width < autoDropdownWidth && autoDropdownEnabled) { + context.isDropdown = true; + } else { + context.isDropdown = false; + } + }, + watchForChapterScroll: () => { + if (!state.enableWatchForChapterScroll) { + return; + } + const { ref } = getElement(); + // get the internal chapters list + const internalChaptersList = state.chaptersWatchList; + // get the current scroll position + const scrollPosition = window.scrollY; + // get the current chapter + let currentChapter = null; + // loop through the internal chapters list + + let nextChapter = false; + // get the current chapter position in the internalChaptersList by id + const currentChapterIndex = internalChaptersList.findIndex( + (chapter) => chapter.id === ref?.id + ); + if (currentChapterIndex < internalChaptersList.length - 1) { + nextChapter = internalChaptersList[currentChapterIndex + 1]; + } + + const chapterPosition = ref.getBoundingClientRect().top; + const distance = chapterPosition - scrollPosition; + const nextChapterPosition = document + .getElementById(nextChapter?.id) + ?.getBoundingClientRect().top; + const nextChapterDistance = nextChapterPosition - scrollPosition; + + if (distance < 0 && nextChapterDistance > 0) { + currentChapter = ref?.id; + } + + if (currentChapter !== state.currentChapter) { + state.currentChapter = currentChapter; + } + + console.log('scroll::', ref?.id, distance, nextChapterDistance); }, }, }); diff --git a/blocks/table-of-contents/table-of-contents.php b/blocks/table-of-contents/table-of-contents.php index 765284681..bc79149a3 100644 --- a/blocks/table-of-contents/table-of-contents.php +++ b/blocks/table-of-contents/table-of-contents.php @@ -83,7 +83,7 @@ public function get_list_items($chapters = false, $depth = 0, $attributes = arra ); echo wp_sprintf( - '
  • %2$s %3$s
  • ', + '
  • %2$s %3$s
  • ', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped \PRC\Platform\Block_Utils\classNames( 'wp-block-prc-block-table-of-contents__list-item', @@ -94,6 +94,7 @@ public function get_list_items($chapters = false, $depth = 0, $attributes = arra $chapter_link, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $internal_chapters, + 0 !== $depth ? 'data-wp-class--is-active="state.isListItemActive" data-ref-value="'.$link.'"' : '', ); } ?> get_list_items( $chapters, 0, $attributes, $return_top_level ), + $post_id + ); + + if (empty($list)) { + return; + } + + $sub_list_template = wp_sprintf( + '
    ', + '
  • ', + ); + + $list_item_template = wp_sprintf( + '
  • %1$s
  • ', + $sub_list_template, + ); + + $list_template = wp_sprintf( + '', + $list_item_template, + ); + + return wp_sprintf( + '
      %2$s
    ', + 'style="--block-gap: ' . $block_gap . ';"', + $list_template, + ); + } + public function render_block_callback( $attributes, $content, $block ) { $post_id = $block->context['postId']; $report_package = new \PRC\Platform\Post_Report_Package(null, null); @@ -166,6 +202,18 @@ public function render_block_callback( $attributes, $content, $block ) { return; } + wp_interactivity_state('prc-block/table-of-contents', array( + 'chapters' => $chapters, + 'currentChapter' => null, + 'enableWatchForChapterScroll' => false, + 'postId' => $post_id, + 'chaptersWatchList' => array(), + )); + + $default_to_dropdown = array_key_exists('className', $attributes) && false !== strpos($attributes['className'], 'is-style-dropdown'); + // remove the is-style-dropdown class from the block attributes + $attributes['className'] = str_replace('is-style-dropdown', '', $attributes['className']); + $block_attrs = array( 'class' => \PRC\Platform\Block_Utils\classNames( array_key_exists('className', $attributes) ? $attributes['className'] : '', @@ -178,15 +226,19 @@ public function render_block_callback( $attributes, $content, $block ) { ), ), 'data-wp-interactive' => wp_json_encode(array('namespace' => 'prc-block/table-of-contents')), - 'data-wp-bind--aria-expanded' => 'context.isDropdownOpen', 'data-wp-context' => wp_json_encode(array( - 'chapters' => $chapters, - 'isDropdown' => array_key_exists('className', $attributes) && false !== strpos($attributes['className'], 'is-style-dropdown'), + 'isDropdown' => $default_to_dropdown, 'isDropdownOpen' => false, 'autoDropdownEnabled' => $attributes['autoDropdownEnabled'], 'autoDropdownWidth' => $attributes['autoDropdownWidth'], 'showCurrentChapter' => $attributes['showCurrentChapter'], )), + 'data-wp-init' => 'callbacks.onInit', + 'data-wp-class--is-style-dropdown' => 'context.isDropdown', + 'data-wp-bind--aria-expanded' => 'context.isDropdownOpen', + 'data-wp-bind--data-auto-dropdown-enabled' => 'context.autoDropdownEnabled', + 'data-wp-bind--data-auto-dropdown-width' => 'context.autoDropdownWidth', + 'data-wp-on-window--resize' => 'callbacks.onResize', ); $block_attrs = get_block_wrapper_attributes($block_attrs);